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

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

View File

@ -556,6 +556,16 @@ namespace Backend.Controllers
apiResult.Msg = "新增成功"; apiResult.Msg = "新增成功";
} }
else else
{
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";
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>() Dictionary<string, object> Device_itemDic = new Dictionary<string, object>()
{ {
@ -571,7 +581,9 @@ namespace Backend.Controllers
{ "@updated_at", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}, { "@updated_at", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")},
}; };
await backendRepository.UpdateOneByCustomTable(Device_itemDic, "device_item", "id='" + device_Item.id + "'"); await backendRepository.UpdateOneByCustomTable(Device_itemDic, "device_item", "id='" + id + "'");
}
}
apiResult.Code = "0000"; apiResult.Code = "0000";
apiResult.Msg = "修改成功"; apiResult.Msg = "修改成功";
@ -663,7 +675,9 @@ namespace Backend.Controllers
return apiResult; 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.Code = "0000";
apiResult.Msg = "刪除成功"; apiResult.Msg = "刪除成功";