[後端] 修改新增小類deviceitem, 修改新增小類問題, 修改新增樓層問題
This commit is contained in:
parent
685a4fcf59
commit
23485396df
@ -495,7 +495,7 @@ namespace Backend.Controllers
|
|||||||
|
|
||||||
try
|
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;");
|
full_name = '{post.Full_name}' and deleted = 0;");
|
||||||
if (!string.IsNullOrEmpty(check))
|
if (!string.IsNullOrEmpty(check))
|
||||||
{
|
{
|
||||||
|
@ -317,7 +317,7 @@ namespace Backend.Controllers
|
|||||||
|
|
||||||
try
|
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))
|
if (!string.IsNullOrEmpty(check))
|
||||||
{
|
{
|
||||||
apiResult.Code = "9998";
|
apiResult.Code = "9998";
|
||||||
@ -331,19 +331,8 @@ namespace Backend.Controllers
|
|||||||
|
|
||||||
var systemSub = await backendRepository.GetOneAsync<VariableInfo>("variable", sWhere, param);
|
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 (systemSub == null)
|
||||||
{
|
{
|
||||||
if (subV != null)
|
|
||||||
{
|
|
||||||
apiResult.Code = "0001";
|
|
||||||
apiResult.Msg = "不可新增相同的系統小類代號。";
|
|
||||||
return apiResult;
|
|
||||||
}
|
|
||||||
|
|
||||||
//新增
|
//新增
|
||||||
//產生一組GUID
|
//產生一組GUID
|
||||||
//獲取最新的大類
|
//獲取最新的大類
|
||||||
@ -370,13 +359,6 @@ namespace Backend.Controllers
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (subV != null)
|
|
||||||
{
|
|
||||||
apiResult.Code = "0001";
|
|
||||||
apiResult.Msg = "不可修改成相同的系統小類代號。";
|
|
||||||
return apiResult;
|
|
||||||
}
|
|
||||||
|
|
||||||
Dictionary<string, object> systemSubDic = new Dictionary<string, object>()
|
Dictionary<string, object> systemSubDic = new Dictionary<string, object>()
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -546,7 +528,9 @@ namespace Backend.Controllers
|
|||||||
|
|
||||||
if (device_Item.id == 0)
|
if (device_Item.id == 0)
|
||||||
{
|
{
|
||||||
|
var building = await backendRepository.GetAllAsync<string>("select building_tag from building where deleted = 0");
|
||||||
|
foreach (var b in building)
|
||||||
|
{
|
||||||
//新增
|
//新增
|
||||||
Dictionary<string, object> Device_itemDic = new Dictionary<string, object>()
|
Dictionary<string, object> Device_itemDic = new Dictionary<string, object>()
|
||||||
{
|
{
|
||||||
@ -561,9 +545,13 @@ namespace Backend.Controllers
|
|||||||
{ "@is_bool", device_Item.is_bool},
|
{ "@is_bool", device_Item.is_bool},
|
||||||
{ "@is_show_history", device_Item.is_show_history},
|
{ "@is_show_history", device_Item.is_show_history},
|
||||||
{ "@created_by", myUserInfo.Userinfo_guid},
|
{ "@created_by", myUserInfo.Userinfo_guid},
|
||||||
|
{ "@device_building_tag", b},
|
||||||
|
{ "@is_link", "1"},
|
||||||
};
|
};
|
||||||
await backendRepository.AddOneByCustomTable(Device_itemDic, "device_item");
|
await backendRepository.AddOneByCustomTable(Device_itemDic, "device_item");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
apiResult.Code = "0000";
|
apiResult.Code = "0000";
|
||||||
apiResult.Msg = "新增成功";
|
apiResult.Msg = "新增成功";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user