[後端] 修改新增小類deviceitem, 修改新增小類問題, 修改新增樓層問題

This commit is contained in:
dev02 2023-08-28 09:53:35 +08:00
parent 685a4fcf59
commit 23485396df
2 changed files with 25 additions and 37 deletions

View File

@ -495,7 +495,7 @@ namespace Backend.Controllers
try
{
var check = await backendRepository.GetOneAsync<string>($@"select floor_guid from variable where floor_guid != {post.Floor_guid} and building_tag = '{post.Building_tag}' and
var check = await backendRepository.GetOneAsync<string>($@"select floor_guid from floor where floor_guid != '{post.Floor_guid ?? ""}' and building_tag = '{post.Building_tag}' and
full_name = '{post.Full_name}' and deleted = 0;");
if (!string.IsNullOrEmpty(check))
{

View File

@ -317,7 +317,7 @@ namespace Backend.Controllers
try
{
var check = await backendRepository.GetOneAsync<string>($"select id from variable where id != {post.id} and system_type = '{sub_system_type}' and system_value = '{post.system_value}' and deleted = 0;");
var check = await backendRepository.GetOneAsync<string>($"select id from variable where id != {post.id} and system_type = '{sub_system_type}' and system_value = '{post.system_value}' and system_parent_id = {post.system_parent_id} and deleted = 0;");
if (!string.IsNullOrEmpty(check))
{
apiResult.Code = "9998";
@ -331,19 +331,8 @@ namespace Backend.Controllers
var systemSub = await backendRepository.GetOneAsync<VariableInfo>("variable", sWhere, param);
sWhere = @$"deleted = 0 AND system_type = @sub_system_type AND system_value = @system_value";
param = new { sub_system_type = sub_system_type, system_value = post.system_value };
var subV = await backendRepository.GetOneAsync<VariableInfo>("variable", sWhere, param);
if (systemSub == null)
{
if (subV != null)
{
apiResult.Code = "0001";
apiResult.Msg = "不可新增相同的系統小類代號。";
return apiResult;
}
{
//新增
//產生一組GUID
//獲取最新的大類
@ -370,13 +359,6 @@ namespace Backend.Controllers
}
else
{
if (subV != null)
{
apiResult.Code = "0001";
apiResult.Msg = "不可修改成相同的系統小類代號。";
return apiResult;
}
Dictionary<string, object> systemSubDic = new Dictionary<string, object>()
{
@ -546,23 +528,29 @@ namespace Backend.Controllers
if (device_Item.id == 0)
{
//新增
Dictionary<string, object> Device_itemDic = new Dictionary<string, object>()
var building = await backendRepository.GetAllAsync<string>("select building_tag from building where deleted = 0");
foreach (var b in building)
{
{ "@device_system_tag", main_tag},
{ "@device_name_tag", sub_tag},
{ "@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},
{ "@created_by", myUserInfo.Userinfo_guid},
};
await backendRepository.AddOneByCustomTable(Device_itemDic, "device_item");
//新增
Dictionary<string, object> Device_itemDic = new Dictionary<string, object>()
{
{ "@device_system_tag", main_tag},
{ "@device_name_tag", sub_tag},
{ "@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},
{ "@created_by", myUserInfo.Userinfo_guid},
{ "@device_building_tag", b},
{ "@is_link", "1"},
};
await backendRepository.AddOneByCustomTable(Device_itemDic, "device_item");
}
apiResult.Code = "0000";
apiResult.Msg = "新增成功";