電站管理-裝置設定: 加上sensorTypeId和sensorTypeDetailId的值

This commit is contained in:
wanling040@gmail.com 2022-08-15 14:23:58 +08:00
parent 1aae1190d9
commit a56620286a
3 changed files with 17 additions and 2 deletions

View File

@ -1177,7 +1177,9 @@ namespace SolarPower.Controllers
"Status", "Status",
"Enabled", "Enabled",
"InstallDate", "InstallDate",
"BrandNum" "BrandNum",
"SensorTypeId",
"SensorTypeDetailId"
}; };
if (Device.WarrantyDate != "0001-01-01") if (Device.WarrantyDate != "0001-01-01")
{ {
@ -1246,7 +1248,9 @@ namespace SolarPower.Controllers
"Status", "Status",
"Enabled", "Enabled",
"InstallDate", "InstallDate",
"BrandNum" "BrandNum",
"SensorTypeId",
"SensorTypeDetailId"
}; };
if (Device.WarrantyDate != "0001-01-01") if (Device.WarrantyDate != "0001-01-01")
{ {

View File

@ -442,6 +442,8 @@ namespace SolarPower.Models.PowerStation
public string InstallDate { get { return Convert.ToDateTime(installDate).ToString("yyyy-MM-dd"); } set { installDate = value; } } //安裝日期 public string InstallDate { get { return Convert.ToDateTime(installDate).ToString("yyyy-MM-dd"); } set { installDate = value; } } //安裝日期
public string BrandNum { get; set; }//廠商序號 public string BrandNum { get; set; }//廠商序號
public string WarrantyDate { get { return Convert.ToDateTime(warrantyDate).ToString("yyyy-MM-dd"); } set { warrantyDate = value; } } //保固日期 public string WarrantyDate { get { return Convert.ToDateTime(warrantyDate).ToString("yyyy-MM-dd"); } set { warrantyDate = value; } } //保固日期
public int SensorTypeId { get; set; }
public int SensorTypeDetailId { get; set; }
} }
public class Device : DeviceInfo public class Device : DeviceInfo

View File

@ -1018,6 +1018,10 @@ namespace SolarPower.Repository.Implement
var trans = conn.BeginTransaction(); var trans = conn.BeginTransaction();
try try
{ {
string getSensorTypeId = $@"SELECT id from sensor_type
WHERE SensorEName = '{DeviceInfo.Type}' AND Deleted = 0";
DeviceInfo.SensorTypeId = await conn.QueryFirstOrDefaultAsync<int>(getSensorTypeId);
DeviceInfo.SensorTypeDetailId = DeviceInfo.SensorTypeId;
string sql = GenerateInsertQueryWithCustomDBNameAndTable(properties, db_name, "device"); string sql = GenerateInsertQueryWithCustomDBNameAndTable(properties, db_name, "device");
await conn.ExecuteAsync(sql, DeviceInfo); await conn.ExecuteAsync(sql, DeviceInfo);
@ -1050,6 +1054,11 @@ namespace SolarPower.Repository.Implement
var trans = conn.BeginTransaction(); var trans = conn.BeginTransaction();
try try
{ {
string getSensorTypeId = $@"SELECT id from sensor_type
WHERE SensorEName = '{DeviceInfo.Type}' AND Deleted = 0";
DeviceInfo.SensorTypeId = await conn.QueryFirstOrDefaultAsync<int>(getSensorTypeId);
DeviceInfo.SensorTypeDetailId = DeviceInfo.SensorTypeId;
var updateQuery = GenerateUpdateQueryWithCustomDBNameAndTable(properties, db_name, "device"); var updateQuery = GenerateUpdateQueryWithCustomDBNameAndTable(properties, db_name, "device");
await conn.ExecuteAsync(updateQuery.ToString(), DeviceInfo, trans); await conn.ExecuteAsync(updateQuery.ToString(), DeviceInfo, trans);
trans.Commit(); trans.Commit();