diff --git a/Backend/Controllers/SystemCategoryController.cs b/Backend/Controllers/SystemCategoryController.cs index 0030edd..1c3bac6 100644 --- a/Backend/Controllers/SystemCategoryController.cs +++ b/Backend/Controllers/SystemCategoryController.cs @@ -557,21 +557,33 @@ namespace Backend.Controllers } else { - Dictionary Device_itemDic = new Dictionary() - { - { "@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(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 Device_itemDic = new Dictionary() + { + { "@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", 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 = "刪除成功";