更新Company生成子資料庫

This commit is contained in:
b110212000 2021-06-29 11:36:59 +08:00
parent faf77371a7
commit cbb5afd9be
8 changed files with 219 additions and 147 deletions

View File

@ -773,5 +773,6 @@ namespace SolarPower.Controllers
apiResult.Msg = errorCode.GetString(apiResult.Code); apiResult.Msg = errorCode.GetString(apiResult.Code);
return apiResult; return apiResult;
} }
} }
} }

View File

@ -2064,14 +2064,14 @@ namespace SolarPower.Controllers
if (inverter != null) if (inverter != null)
{ {
apiResult.Code = "0099"; apiResult.Code = "0002";
apiResult.Msg = "請先刪除相關逆變器"; apiResult.Msg = errorCode.GetString(apiResult.Code);
return apiResult; return apiResult;
} }
if (device != null) if (device != null)
{ {
apiResult.Code = "0099"; apiResult.Code = "0003";
apiResult.Msg = "請先刪除相關設備"; apiResult.Msg = errorCode.GetString(apiResult.Code);
return apiResult; return apiResult;
} }

View File

@ -17,6 +17,8 @@ namespace SolarPower.Models
{ {
{ "0000", "OK" }, { "0000", "OK" },
{ "0001", "傳入參數錯誤。" }, { "0001", "傳入參數錯誤。" },
{ "0002","請先刪除相關逆變器"},
{ "0003","請先刪除相關設備"},
{ "9986", "該帳號已被註冊,請重新輸入"}, { "9986", "該帳號已被註冊,請重新輸入"},
{ "9987", "查無該運維作業記錄檔案"}, { "9987", "查無該運維作業記錄檔案"},
{ "9988", "查無該資料紀錄"}, { "9988", "查無該資料紀錄"},

View File

@ -520,13 +520,17 @@ namespace SolarPower.Models.PowerStation
public string CreatedName { get; set; } public string CreatedName { get; set; }
public string Function { get; set; } public string Function { get; set; }
} }
/// <summary>
/// 下拉式選單用
/// </summary>
public class PowerstationOption public class PowerstationOption
{ {
public string Text { get; set; } public string Text { get; set; }
public string Value { get; set; } public string Value { get; set; }
} }
/// <summary>
/// 共享設備
/// </summary>
public class Sharedevice : Created public class Sharedevice : Created
{ {
public int Id { get; set; } public int Id { get; set; }

View File

@ -428,46 +428,76 @@ namespace SolarPower.Repository.Implement
CREATE DATABASE IF NOT EXISTS `{db_name}`; CREATE DATABASE IF NOT EXISTS `{db_name}`;
USE `{db_name}`; USE `{db_name}`;
-- controller
CREATE TABLE IF NOT EXISTS `controller` (
`Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`Deleted` tinyint(4) NOT NULL DEFAULT '0' COMMENT ' 0: 1:',
`PowerStationId` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '',
`ControllerId` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '',
`SerialNumber` varchar(4) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '',
`CreatedBy` int(10) unsigned NOT NULL,
`CreatedAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`UpdatedBy` int(10) unsigned DEFAULT NULL,
`UpdatedAt` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='';
-- device -- device
CREATE TABLE IF NOT EXISTS `device` ( CREATE TABLE IF NOT EXISTS `device` (
`Id` int(10) unsigned NOT NULL AUTO_INCREMENT, `Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`Deleted` tinyint(4) NOT NULL DEFAULT 0 COMMENT ' 0: 1:', `Deleted` tinyint(4) NOT NULL DEFAULT '0' COMMENT ' 0: 1:',
`UID` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT ' ++(0001~9999)+(3) + SN(3)', `UID` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT ' ++(0001~9999)+(3) + SN(3)',
`PowerStationId` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '', `PowerStationId` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '',
`Name` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '', `SerialNumber` varchar(4) COLLATE utf8mb4_unicode_ci DEFAULT '0' COMMENT '',
`Type` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '', `Name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '',
`TypeName` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '', `Type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '',
`Brand` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '', `TypeName` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '',
`ProductModel` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '', `ControllerId` int(10) unsigned DEFAULT NULL COMMENT 'Id',
`DBName` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `Brand` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '',
`TableName` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `ProductModel` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '',
`ColName` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `DBName` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`Remark` text COLLATE utf8mb4_unicode_ci DEFAULT NULL, `TableName` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`ColName` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`Remark` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '',
`CreatedBy` int(10) unsigned NOT NULL COMMENT '', `CreatedBy` int(10) unsigned NOT NULL COMMENT '',
`CreatedAt` timestamp NOT NULL DEFAULT current_timestamp() COMMENT '', `CreatedAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '',
`UpdatedBy` int(10) unsigned DEFAULT NULL COMMENT '', `UpdatedBy` int(10) unsigned DEFAULT NULL COMMENT '',
`UpdatedAt` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp() COMMENT '', `UpdatedAt` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '',
PRIMARY KEY (`Id`) USING BTREE, PRIMARY KEY (`Id`) USING BTREE,
KEY `IDX_01` (`Deleted`) USING BTREE, KEY `IDX_01` (`Deleted`) USING BTREE,
KEY `IDX_02` (`UID`,`PowerStationId`) KEY `IDX_02` (`UID`,`PowerStationId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT=''; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='';
-- inverter
CREATE TABLE IF NOT EXISTS `inverter` (
`Id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '',
`Deleted` tinyint(4) DEFAULT '0' COMMENT '',
`SerialNumber` varchar(4) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '()',
`InverterId` varchar(50) DEFAULT NULL COMMENT 'UID',
`ControllerId` int(10) DEFAULT NULL COMMENT '',
`CreatedBy` int(10) unsigned NOT NULL,
`CreatedAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`UpdatedBy` int(10) DEFAULT NULL,
`UpdatedAt` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='';
-- land_building -- land_building
CREATE TABLE IF NOT EXISTS `land_building` ( CREATE TABLE IF NOT EXISTS `land_building` (
`Id` int(10) unsigned NOT NULL AUTO_INCREMENT, `Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`Deleted` tinyint(4) NOT NULL DEFAULT 0 COMMENT ' 0: 1:', `Deleted` tinyint(4) NOT NULL DEFAULT '0' COMMENT ' 0: 1:',
`PowerStationId` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '', `PowerStationId` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '',
`Address` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '', `Address` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '',
`LeaseNotarizationAt` timestamp NULL DEFAULT NULL COMMENT '', `LeaseNotarizationAt` timestamp NULL DEFAULT NULL COMMENT '',
`Landowner` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '', `Landowner` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '',
`Purpose` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '', `Purpose` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '',
`LeaseRate` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '(%)', `LeaseRate` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '(%)',
`Coordinate` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '', `Coordinate` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '',
`Phone` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '', `Phone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '',
`CreatedBy` int(10) unsigned NOT NULL COMMENT '', `CreatedBy` int(10) unsigned NOT NULL COMMENT '',
`CreatedAt` timestamp NOT NULL DEFAULT current_timestamp() COMMENT '', `CreatedAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '',
`UpdatedBy` int(10) unsigned DEFAULT NULL COMMENT '', `UpdatedBy` int(10) unsigned DEFAULT NULL COMMENT '',
`UpdatedAt` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp() COMMENT '', `UpdatedAt` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '',
PRIMARY KEY (`Id`), PRIMARY KEY (`Id`),
KEY `IDX_01` (`Deleted`,`PowerStationId`) KEY `IDX_01` (`Deleted`,`PowerStationId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT=''; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='';
@ -475,71 +505,71 @@ namespace SolarPower.Repository.Implement
-- operation_firm -- operation_firm
CREATE TABLE IF NOT EXISTS `operation_firm` ( CREATE TABLE IF NOT EXISTS `operation_firm` (
`Id` int(10) unsigned NOT NULL AUTO_INCREMENT, `Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`Deleted` tinyint(4) NOT NULL DEFAULT 0 COMMENT ' 0: 1:', `Deleted` tinyint(4) NOT NULL DEFAULT '0' COMMENT ' 0: 1:',
`PowerStationId` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '', `PowerStationId` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '',
`Name` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '', `Name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '',
`Type` tinyint(4) NOT NULL DEFAULT 0 COMMENT '0: 1: 2:', `Type` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0: 1: 2:',
`ContactPerson` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '', `ContactPerson` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '',
`Phone` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '', `Phone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '',
`Email` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Email', `Email` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Email',
`CreatedBy` int(10) unsigned NOT NULL COMMENT '', `CreatedBy` int(10) unsigned NOT NULL COMMENT '',
`CreatedAt` timestamp NOT NULL DEFAULT current_timestamp() COMMENT '', `CreatedAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '',
`UpdatedBy` int(10) unsigned DEFAULT NULL COMMENT '', `UpdatedBy` int(10) unsigned DEFAULT NULL COMMENT '',
`UpdatedAt` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp() COMMENT '', `UpdatedAt` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '',
PRIMARY KEY (`Id`), PRIMARY KEY (`Id`),
KEY `IDX_01` (`Deleted`,`PowerStationId`) KEY `IDX_01` (`Deleted`,`PowerStationId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT=''; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='';
-- power_station -- power_station
CREATE TABLE IF NOT EXISTS `power_station` ( CREATE TABLE IF NOT EXISTS `power_station` (
`Id` int(10) unsigned NOT NULL DEFAULT 0, `Id` int(10) unsigned NOT NULL DEFAULT '0',
`Deleted` tinyint(4) NOT NULL DEFAULT 0 COMMENT ' 0: 1:', `Deleted` tinyint(4) NOT NULL DEFAULT '0' COMMENT ' 0: 1:',
`CompanyId` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '', `CompanyId` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '',
`CityId` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '', `CityId` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '',
`AreaId` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '', `AreaId` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '',
`Address` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '', `Address` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '',
`Name` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '', `Name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '',
`Code` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '++', `Code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '++',
`SerialNumber` varchar(4) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '', `SerialNumber` varchar(4) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '',
`IsEscrow` tinyint(4) NOT NULL DEFAULT 0 COMMENT '0: 1:', `IsEscrow` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0: 1:',
`EscrowName` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '', `EscrowName` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '',
`ElectricityMeterAt` timestamp NULL DEFAULT NULL COMMENT '', `ElectricityMeterAt` timestamp NULL DEFAULT NULL COMMENT '',
`EstimatedRecoveryTime` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '', `EstimatedRecoveryTime` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '',
`GeneratingCapacity` decimal(10,1) NOT NULL DEFAULT 0.0 COMMENT '()', `GeneratingCapacity` decimal(10,1) NOT NULL DEFAULT '0.0' COMMENT '()',
`PowerRate` decimal(10,3) NOT NULL DEFAULT 0.000 COMMENT '', `PowerRate` decimal(10,3) NOT NULL DEFAULT '0.000' COMMENT '',
`Coordinate` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '', `Coordinate` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '',
`InverterBrand` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '', `InverterBrand` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '',
`InverterProductModel` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '', `InverterProductModel` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '',
`InverterAmount` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '', `InverterAmount` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '',
`PhotovoltaicPanelBrand` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '', `PhotovoltaicPanelBrand` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '',
`PhotovoltaicPanelProductModel` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '', `PhotovoltaicPanelProductModel` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '',
`PhotovoltaicPanelSpecification` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '', `PhotovoltaicPanelSpecification` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '',
`PhotovoltaicPanelAmount` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '', `PhotovoltaicPanelAmount` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '',
`BoEFileName` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '', `BoEFileName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '',
`BoEFile` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '', `BoEFile` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '',
`BoEDiscountRate` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '', `BoEDiscountRate` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '',
`BoEDeviceRegisterNumber` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '', `BoEDeviceRegisterNumber` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '',
`BoERentRatio` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '(%)', `BoERentRatio` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '(%)',
`TPCContractNumber` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '', `TPCContractNumber` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '',
`TPCContractAt` timestamp NULL DEFAULT NULL COMMENT '', `TPCContractAt` timestamp NULL DEFAULT NULL COMMENT '',
`TPCSellDeadline` int(10) unsigned DEFAULT 0 COMMENT '()', `TPCSellDeadline` int(10) unsigned DEFAULT '0' COMMENT '()',
`TPCMeterReading` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '', `TPCMeterReading` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '',
`TPCPurchaseElectricityAt` timestamp NULL DEFAULT NULL COMMENT '', `TPCPurchaseElectricityAt` timestamp NULL DEFAULT NULL COMMENT '',
`TPCSellElectricityAt` timestamp NULL DEFAULT NULL COMMENT '', `TPCSellElectricityAt` timestamp NULL DEFAULT NULL COMMENT '',
`kwh` decimal(10,3) unsigned NOT NULL DEFAULT 0.000, `kwh` decimal(10,3) unsigned NOT NULL DEFAULT '0.000',
`Today_kwh` decimal(10,3) unsigned NOT NULL DEFAULT 0.000 COMMENT '', `Today_kwh` decimal(10,3) unsigned NOT NULL DEFAULT '0.000' COMMENT '',
`Total_kwh` decimal(10,3) unsigned NOT NULL DEFAULT 0.000 COMMENT '', `Total_kwh` decimal(10,3) unsigned NOT NULL DEFAULT '0.000' COMMENT '',
`kwhkwp` decimal(10,3) unsigned NOT NULL DEFAULT 0.000, `kwhkwp` decimal(10,3) unsigned NOT NULL DEFAULT '0.000',
`PR` decimal(5,2) unsigned NOT NULL DEFAULT 0.00 COMMENT 'Pr值', `PR` decimal(5,2) unsigned NOT NULL DEFAULT '0.00' COMMENT 'Pr值',
`MP` decimal(5,2) unsigned NOT NULL DEFAULT 0.00, `MP` decimal(5,2) unsigned NOT NULL DEFAULT '0.00',
`SolarHour` decimal(5,2) unsigned NOT NULL DEFAULT 0.00 COMMENT '', `SolarHour` decimal(5,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '',
`SiteDB` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0.000' COMMENT ' DB name: solar_com', `SiteDB` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0.000' COMMENT ' DB name: solar_com',
`TodayWeather` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0.000' COMMENT '', `TodayWeather` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0.000' COMMENT '',
`TodayWeatherTemp` decimal(5,2) unsigned NOT NULL DEFAULT 0.00 COMMENT '', `TodayWeatherTemp` decimal(5,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '',
`CreatedBy` int(10) unsigned NOT NULL COMMENT '', `CreatedBy` int(10) unsigned NOT NULL COMMENT '',
`CreatedAt` timestamp NOT NULL DEFAULT current_timestamp() COMMENT '', `CreatedAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '',
`UpdatedBy` int(10) unsigned DEFAULT NULL COMMENT '', `UpdatedBy` int(10) unsigned DEFAULT NULL COMMENT '',
`UpdatedAt` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp() COMMENT '', `UpdatedAt` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '',
PRIMARY KEY (`Id`), PRIMARY KEY (`Id`),
KEY `IDX_01` (`Deleted`), KEY `IDX_01` (`Deleted`),
KEY `IDX_02` (`CompanyId`), KEY `IDX_02` (`CompanyId`),
@ -549,16 +579,16 @@ namespace SolarPower.Repository.Implement
-- power_station_exception -- power_station_exception
CREATE TABLE IF NOT EXISTS `power_station_exception` ( CREATE TABLE IF NOT EXISTS `power_station_exception` (
`Id` int(10) unsigned NOT NULL AUTO_INCREMENT, `Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`Deleted` tinyint(4) NOT NULL DEFAULT 0 COMMENT ' 0: 1:', `Deleted` tinyint(4) NOT NULL DEFAULT '0' COMMENT ' 0: 1:',
`PowerStationId` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '', `PowerStationId` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '',
`Type` tinyint(4) NOT NULL DEFAULT 0 COMMENT '0:PR值', `Type` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0:PR值',
`UpperLimit` decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '', `UpperLimit` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '',
`LowerLimit` decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '', `LowerLimit` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '',
`Alarm` tinyint(4) NOT NULL DEFAULT 0 COMMENT '0:email通知', `Alarm` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0:email通知',
`CreatedBy` int(10) unsigned NOT NULL COMMENT '', `CreatedBy` int(10) unsigned NOT NULL COMMENT '',
`CreatedAt` timestamp NOT NULL DEFAULT current_timestamp() COMMENT '', `CreatedAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '',
`UpdatedBy` int(10) unsigned DEFAULT NULL COMMENT '', `UpdatedBy` int(10) unsigned DEFAULT NULL COMMENT '',
`UpdatedAt` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp() COMMENT '', `UpdatedAt` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '',
PRIMARY KEY (`Id`), PRIMARY KEY (`Id`),
KEY `IDX_01` (`Deleted`,`PowerStationId`) KEY `IDX_01` (`Deleted`,`PowerStationId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT=''; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='';
@ -566,14 +596,14 @@ namespace SolarPower.Repository.Implement
-- power_station_image -- power_station_image
CREATE TABLE IF NOT EXISTS `power_station_image` ( CREATE TABLE IF NOT EXISTS `power_station_image` (
`Id` int(10) unsigned NOT NULL AUTO_INCREMENT, `Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`Deleted` tinyint(4) NOT NULL DEFAULT 0 COMMENT ' 0: 1:', `Deleted` tinyint(4) NOT NULL DEFAULT '0' COMMENT ' 0: 1:',
`PowerStationId` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '', `PowerStationId` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '',
`IsMainDisplay` tinyint(4) NOT NULL DEFAULT 0 COMMENT ' 0: 1:', `IsMainDisplay` tinyint(4) NOT NULL DEFAULT '0' COMMENT ' 0: 1:',
`Image` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '', `Image` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '',
`CreatedBy` int(10) unsigned NOT NULL COMMENT '', `CreatedBy` int(10) unsigned NOT NULL COMMENT '',
`CreatedAt` timestamp NOT NULL DEFAULT current_timestamp() COMMENT '', `CreatedAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '',
`UpdatedBy` int(10) unsigned DEFAULT NULL COMMENT '', `UpdatedBy` int(10) unsigned DEFAULT NULL COMMENT '',
`UpdatedAt` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp() COMMENT '', `UpdatedAt` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '',
PRIMARY KEY (`Id`), PRIMARY KEY (`Id`),
KEY `IDX_01` (`Deleted`,`IsMainDisplay`,`PowerStationId`) USING BTREE KEY `IDX_01` (`Deleted`,`IsMainDisplay`,`PowerStationId`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT=''; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='';
@ -581,14 +611,24 @@ namespace SolarPower.Repository.Implement
-- power_station_single_line_diagram -- power_station_single_line_diagram
CREATE TABLE IF NOT EXISTS `power_station_single_line_diagram` ( CREATE TABLE IF NOT EXISTS `power_station_single_line_diagram` (
`Id` int(10) unsigned NOT NULL AUTO_INCREMENT, `Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`Deleted` tinyint(4) NOT NULL DEFAULT 0 COMMENT ' 0: 1:', `Deleted` tinyint(4) NOT NULL DEFAULT '0' COMMENT ' 0: 1:',
`PowerStationId` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '', `PowerStationId` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '',
`Image` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '', `Image` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '',
`CreatedBy` int(10) unsigned NOT NULL COMMENT '', `CreatedBy` int(10) unsigned NOT NULL COMMENT '',
`CreatedAt` timestamp NOT NULL DEFAULT current_timestamp() COMMENT '', `CreatedAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '',
PRIMARY KEY (`Id`), PRIMARY KEY (`Id`),
KEY `IDX_01` (`Deleted`,`PowerStationId`) USING BTREE KEY `IDX_01` (`Deleted`,`PowerStationId`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT=''; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='';
-- sharedevice
CREATE TABLE IF NOT EXISTS `sharedevice` (
`Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`PowerStationId` int(10) DEFAULT NULL COMMENT '',
`DeviceId` int(10) DEFAULT NULL COMMENT '',
`CreatedBy` int(10) unsigned NOT NULL,
`CreatedAt` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='';
"; ";
await conn.ExecuteAsync(sql, trans); await conn.ExecuteAsync(sql, trans);

View File

@ -493,5 +493,6 @@ namespace SolarPower.Repository.Implement
} }
} }
} }
} }
} }

View File

@ -1371,7 +1371,6 @@ namespace SolarPower.Repository.Implement
return powerstation; return powerstation;
} }
public async Task<List<OperationPersonnelSelectItemList>> GetOperationPersonnelSelectOptionListAsync(int powerStationId) public async Task<List<OperationPersonnelSelectItemList>> GetOperationPersonnelSelectOptionListAsync(int powerStationId)
{ {
List<OperationPersonnelSelectItemList> result; List<OperationPersonnelSelectItemList> result;
@ -1393,7 +1392,13 @@ namespace SolarPower.Repository.Implement
return result; return result;
} }
} }
/// <summary>
/// 新增控制器
/// </summary>
/// <param name="deviceController"></param>
/// <param name="properties"></param>
/// <param name="db_name"></param>
/// <returns></returns>
public async Task AddDeviceController(DeviceController deviceController, List<string> properties, string db_name) public async Task AddDeviceController(DeviceController deviceController, List<string> properties, string db_name)
{ {
using (IDbConnection conn = _databaseHelper.GetConnection()) using (IDbConnection conn = _databaseHelper.GetConnection())
@ -1417,7 +1422,12 @@ namespace SolarPower.Repository.Implement
} }
} }
} }
/// <summary>
/// 控制器dataTable
/// </summary>
/// <param name="stationId"></param>
/// <param name="db_name"></param>
/// <returns></returns>
public async Task<List<DeviceControllerTable>> DeviceControllerTable(int stationId, string db_name) public async Task<List<DeviceControllerTable>> DeviceControllerTable(int stationId, string db_name)
{ {
@ -1643,7 +1653,14 @@ namespace SolarPower.Repository.Implement
return Device; return Device;
} }
/// <summary>
/// 取一筆各型態資料
/// </summary>
/// <typeparam name="A"></typeparam>
/// <param name="where"></param>
/// <param name="db_name"></param>
/// <param name="table_name"></param>
/// <returns></returns>
public async Task<A> GetoneData<A>(string where, string db_name, string table_name) public async Task<A> GetoneData<A>(string where, string db_name, string table_name)
{ {
A result; A result;

View File

@ -407,7 +407,14 @@ namespace SolarPower.Repository.Interface
/// <param name="db_name"></param> /// <param name="db_name"></param>
/// <returns></returns> /// <returns></returns>
Task<List<DeviceTable>> shareDeviceTables(int stationId, string db_name); Task<List<DeviceTable>> shareDeviceTables(int stationId, string db_name);
/// <summary>
/// 取一筆各型態資料
/// </summary>
/// <typeparam name="A"></typeparam>
/// <param name="where"></param>
/// <param name="db_name"></param>
/// <param name="table_name"></param>
/// <returns></returns>
Task<A> GetoneData<A>(string where, string db_name, string table_name); Task<A> GetoneData<A>(string where, string db_name, string table_name);
} }
} }