[後台] 修改點位同步全棟問題

This commit is contained in:
dev02 2023-09-18 13:00:24 +08:00
parent 7ab418c7b1
commit 80be5b1fa2

View File

@ -557,21 +557,33 @@ namespace Backend.Controllers
}
else
{
Dictionary<string, object> Device_itemDic = new Dictionary<string, object>()
{
{ "@full_name", device_Item.full_name},
{ "@points", device_Item.points},
{ "@unit", device_Item.unit},
{ "@is_show", device_Item.is_show},
{ "@is_show_riserDiagram", device_Item.is_show_riserDiagram},
{ "@is_controll", device_Item.is_controll},
{ "@is_bool", device_Item.is_bool},
{ "@is_show_history", device_Item.is_show_history},
{ "@updated_by", myUserInfo.Userinfo_guid},
{ "@updated_at", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")},
};
var sql = $@"SELECT di.id FROM device_item di
WHERE di.deleted = 0 AND device_system_tag = @device_system_tag and device_name_tag = @device_name_tag and points = @points";
await backendRepository.UpdateOneByCustomTable(Device_itemDic, "device_item", "id='" + device_Item.id + "'");
var deviceItemId = await backendRepository.GetAllAsync<int>(sql,
new { points = device_Item.points, device_system_tag = main_tag, device_name_tag = sub_tag });
if (deviceItemId.Count() > 0)
{
foreach (var id in deviceItemId)
{
Dictionary<string, object> Device_itemDic = new Dictionary<string, object>()
{
{ "@full_name", device_Item.full_name},
{ "@points", device_Item.points},
{ "@unit", device_Item.unit},
{ "@is_show", device_Item.is_show},
{ "@is_show_riserDiagram", device_Item.is_show_riserDiagram},
{ "@is_controll", device_Item.is_controll},
{ "@is_bool", device_Item.is_bool},
{ "@is_show_history", device_Item.is_show_history},
{ "@updated_by", myUserInfo.Userinfo_guid},
{ "@updated_at", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")},
};
await backendRepository.UpdateOneByCustomTable(Device_itemDic, "device_item", "id='" + id + "'");
}
}
apiResult.Code = "0000";
apiResult.Msg = "修改成功";
@ -652,7 +664,7 @@ namespace Backend.Controllers
{
string sWhere = @$"deleted = @Deleted AND id = @id";
object param = new { Deleted = 0, id = id};
object param = new { Deleted = 0, id = id };
var device_Item = await backendRepository.GetOneAsync<Device_item>("device_item", sWhere, param);
@ -663,7 +675,9 @@ namespace Backend.Controllers
return apiResult;
}
await backendRepository.DeleteOne(id.ToString(), "device_item", "id");
string sql = $@"update device_item set deleted = 1 where device_system_tag = '{device_Item.device_system_tag}' and device_name_tag = '{device_Item.device_name_tag}' and deleted = 0
and points = '{device_Item.points}'";
await backendRepository.ExecuteSql(sql);
apiResult.Code = "0000";
apiResult.Msg = "刪除成功";