[後台] 修改後台回報錯誤

This commit is contained in:
dev02 2023-08-04 11:52:36 +08:00
parent 53473bcffe
commit ec1512d470
7 changed files with 99 additions and 34 deletions

View File

@ -495,6 +495,15 @@ 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
full_name = '{post.Full_name}';");
if (!string.IsNullOrEmpty(check))
{
apiResult.Code = "9998";
apiResult.Msg = "已有相同樓層";
return apiResult;
}
string sWhere = @$"deleted = @Deleted AND floor_guid = @Guid";
object param = new { Deleted = 0, Guid = post.Floor_guid };
@ -680,7 +689,7 @@ namespace Backend.Controllers
ssf.main_system_tag,
ssf.sub_system_tag
FROM sub_system_floor ssf
WHERE ssf.deleted = 0 AND ssf.floor_tag = @floor_tag
WHERE ssf.deleted = 0 AND ssf.floor_tag = @floor_tag and ssf.building_tag = '{buildFloor.Building_tag}'
) ssf
LEFT JOIN building b ON ssf.building_tag = b.building_tag AND b.deleted = 0
LEFT JOIN variable mv ON ssf.main_system_tag = mv.system_value AND mv.system_type = @main_system_type AND mv.deleted = 0

View File

@ -99,6 +99,13 @@ namespace Backend.Controllers
object param = new { Deleted = 0, id = post.id };
var check = await backendRepository.GetOneAsync<string>($"select id from variable where id != {post.id} and system_type = '{main_system_type}' and system_value = '{post.system_value}';");
if (!string.IsNullOrEmpty(check))
{
apiResult.Code = "9998";
apiResult.Msg = "已有相同大類";
return apiResult;
}
var systemMain = await backendRepository.GetOneAsync<VariableInfo>("variable", sWhere, param);
if (systemMain == null)
@ -310,6 +317,14 @@ 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}';");
if (!string.IsNullOrEmpty(check))
{
apiResult.Code = "9998";
apiResult.Msg = "已有相同小類";
return apiResult;
}
string sWhere = @$"deleted = @Deleted AND id = @id";
object param = new { Deleted = 0, id = post.id };

View File

@ -314,6 +314,14 @@ namespace Backend.Controllers
try
{
var check = await backendRepository.GetOneAsync<string>($"select role_guid from role where role_guid != '{post.Id}' and full_name = '{post.Name}';");
if (!string.IsNullOrEmpty(check))
{
apiResult.Code = "9998";
apiResult.Msg = "已有相同角色";
return apiResult;
}
roleManager = await backendRepository.GetOneAsync<RoleManagerList>("role", $"role_guid='{post.Id.ToString()}'");
if (roleManager == null)
@ -475,7 +483,7 @@ namespace Backend.Controllers
FROM role_auth A
LEFT JOIN role B ON A.role_guid=B.role_guid AND B.deleted=0
INNER JOIN auth_page C ON A.AuthCode=C.AuthCode
LEFT JOIN building D ON C.building_guid=D.building_guid AND D.deleted=0
LEFT JOIN building D ON C.building_tag=D.building_tag AND D.deleted=0
WHERE A.role_guid='{post.SelectedRoleId}'
ORDER BY A.created_at DESC";
roleAuthList = await backendRepository.GetAllAsync<RoleAuthList>(sqlString);

View File

@ -128,6 +128,15 @@ namespace Backend.Controllers
try
{
var check = await backendRepository.GetOneAsync<string>($@"select id from variable where id != {post.id} and system_type = '{post.System_type}' and system_value = '{post.system_value}'
and system_key = '{post.System_key}';");
if (!string.IsNullOrEmpty(check))
{
apiResult.Code = "9998";
apiResult.Msg = "已有相同系統變數";
return apiResult;
}
string sWhere = @$"deleted = 0 AND id = @Id";
object param = new { Id = post.id };

View File

@ -16,9 +16,9 @@
"MySqlDBConfig": {
"Server": "FYlY+w0XDIz+jmF2rlZWJw==", //0.201
"Port": "js2LutKe+rdjzdxMPQUrvQ==",
"Database": "VJB2XC+lAtzuHObDGMVOAA==", //30
//"Database": "VJB2XC+lAtzuHObDGMVOAA==", //30
//"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp
//"Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome
"Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome
//"Database": "siTUcDaC/g2yGTMFWD72Kg==", //tpe_dome_hotel
//"Database": "iuaY0h0+TWkir44/eZLDqw==", //tpe_dome_office
//"Database": "Rq7Gn4x6LwBvVtl7GY8LbA==", //mcut

View File

@ -16,9 +16,9 @@
"MySqlDBConfig": {
"Server": "FYlY+w0XDIz+jmF2rlZWJw==", //0.201
"Port": "js2LutKe+rdjzdxMPQUrvQ==",
"Database": "VJB2XC+lAtzuHObDGMVOAA==", //30
//"Database": "VJB2XC+lAtzuHObDGMVOAA==", //30
//"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp
//"Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome
"Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome
//"Database": "siTUcDaC/g2yGTMFWD72Kg==", //tpe_dome_hotel
//"Database": "iuaY0h0+TWkir44/eZLDqw==", //tpe_dome_office
//"Database": "Rq7Gn4x6LwBvVtl7GY8LbA==", //MCUT

View File

@ -55,7 +55,7 @@ namespace Repository.BackendRepository.Implement
`atDateTime` datetime(1) DEFAULT NULL,
`is_used` smallint(1) DEFAULT 0,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;";
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;";
await conn.ExecuteAsync(sql);
sql = "delete from import_niagara_tag where device_building_tag = '" + b + "' limit 10000";
await conn.ExecuteAsync(sql);
@ -198,7 +198,7 @@ namespace Repository.BackendRepository.Implement
`parent_path` varchar(50) DEFAULT NULL,
`full_name` varchar(50) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=59 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;";
) ENGINE=InnoDB AUTO_INCREMENT=59 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;";
await conn.ExecuteAsync(sql);
sql = "delete from import_niagara_item where device_building_tag = '" + b + "' limit 10000;";
await conn.ExecuteAsync(sql);
@ -249,8 +249,8 @@ namespace Repository.BackendRepository.Implement
if (isDome == "ibms_dome_dome/D2" || isDome == "ibms_dome_hotel/H")
{
sb.Append($@" update import_niagara_item a join dic_system b
on a.device_name_tag COLLATE utf8mb4_general_ci = b.s2_code
set device_system_tag = b.s1_code
on a.device_name_tag COLLATE utf8mb4_0900_ai_ci = b.s2_code COLLATE utf8mb4_0900_ai_ci
set device_system_tag = b.s1_code
where (device_system_tag <> 'S' and device_system_tag <> 'CWB');");
}
@ -373,7 +373,7 @@ namespace Repository.BackendRepository.Implement
WHERE NOT EXISTS (
SELECT 1
FROM device_node d
WHERE m.niagara_tags = d.device_number
WHERE m.niagara_tags COLLATE utf8mb4_0900_ai_ci = d.device_number COLLATE utf8mb4_0900_ai_ci
);");
result = (await conn.QueryAsync<NiagaraTags>(sb.ToString())).ToList<NiagaraTags>();
sb.Clear();
@ -416,18 +416,28 @@ namespace Repository.BackendRepository.Implement
//device有niagara沒有is_link 更新成 0
sb.Append($@" SET SQL_SAFE_UPDATES = 0;
UPDATE device
SET is_link = 0
WHERE is_link = 1 AND device_number NOT IN (SELECT niagara_tags FROM import_niagara_tag);");
UPDATE device d
left JOIN (
SELECT niagara_tags
FROM import_niagara_tag
LIMIT 100000
) i ON d.device_number COLLATE utf8mb4_0900_ai_ci = i.niagara_tags COLLATE utf8mb4_0900_ai_ci
SET d.is_link = 0
WHERE d.is_link = 1 and i.niagara_tags is null;");
await conn.ExecuteAsync(sb.ToString());
sb.Clear();
// device_node 有, niagara沒有, is_link 更新成 0
sb.Append($@" SET SQL_SAFE_UPDATES = 0;
UPDATE device_node
SET is_link = 0
WHERE is_link = 1 AND device_number NOT IN (SELECT niagara_tags FROM import_niagara_tag);");
UPDATE device_node dn
left JOIN (
SELECT niagara_tags
FROM import_niagara_tag
LIMIT 100000
) i ON dn.device_number COLLATE utf8mb4_0900_ai_ci = i.niagara_tags COLLATE utf8mb4_0900_ai_ci
SET dn.is_link = 0
WHERE dn.is_link = 1 and i.niagara_tags is null;");
await conn.ExecuteAsync(sb.ToString());
}
catch (Exception exception)
@ -571,7 +581,9 @@ namespace Repository.BackendRepository.Implement
group by device_building_tag, device_system_tag, device_name_tag
) AS a
LEFT JOIN building_menu b
ON a.device_building_tag = b.device_building_tag and a.device_system_tag = b.device_system_tag and a.device_name_tag = b.sub_system_tag
ON a.device_building_tag COLLATE utf8mb4_0900_ai_ci = b.device_building_tag COLLATE utf8mb4_0900_ai_ci and
a.device_system_tag COLLATE utf8mb4_0900_ai_ci = b.device_system_tag COLLATE utf8mb4_0900_ai_ci and
a.device_name_tag COLLATE utf8mb4_0900_ai_ci = b.sub_system_tag COLLATE utf8mb4_0900_ai_ci
WHERE b.device_building_tag IS NULL");
result = (await conn.QueryAsync<NiagaraTags>(sb.ToString())).ToList<NiagaraTags>();
#endregion
@ -609,8 +621,8 @@ namespace Repository.BackendRepository.Implement
select device_building_tag, device_system_tag, device_name_tag
from import_niagara_tag
group by device_building_tag, device_system_tag, device_name_tag
) AS a ON b.building_tag = a.device_building_tag
and a.device_system_tag = b.main_system_tag and a.device_name_tag = b.sub_system_tag
) AS a ON b.building_tag COLLATE utf8mb4_0900_ai_ci = a.device_building_tag COLLATE utf8mb4_0900_ai_ci
and a.device_system_tag COLLATE utf8mb4_0900_ai_ci = b.main_system_tag COLLATE utf8mb4_0900_ai_ci and a.device_name_tag COLLATE utf8mb4_0900_ai_ci = b.sub_system_tag COLLATE utf8mb4_0900_ai_ci
SET b.is_link = 0
WHERE b.building_tag IS NULL");
await conn.ExecuteAsync(sb.ToString());
@ -649,7 +661,10 @@ namespace Repository.BackendRepository.Implement
group by device_building_tag, device_system_tag, device_name_tag, device_floor_tag
) AS a
LEFT JOIN sub_system_floor b
ON a.device_building_tag = b.building_tag and a.device_system_tag = b.main_system_tag and a.device_name_tag = b.sub_system_tag and a.device_floor_tag = b.floor_tag
ON a.device_building_tag COLLATE utf8mb4_0900_ai_ci = b.building_tag COLLATE utf8mb4_0900_ai_ci and
a.device_system_tag COLLATE utf8mb4_0900_ai_ci = b.main_system_tag COLLATE utf8mb4_0900_ai_ci and
a.device_name_tag COLLATE utf8mb4_0900_ai_ci = b.sub_system_tag COLLATE utf8mb4_0900_ai_ci and
a.device_floor_tag COLLATE utf8mb4_0900_ai_ci = b.floor_tag COLLATE utf8mb4_0900_ai_ci
WHERE b.building_tag IS NULL");
result = (await conn.QueryAsync<NiagaraTags>(sb.ToString())).ToList<NiagaraTags>();
#endregion
@ -682,8 +697,10 @@ namespace Repository.BackendRepository.Implement
select device_building_tag, device_system_tag, device_name_tag, device_floor_tag
from import_niagara_tag
group by device_building_tag, device_system_tag, device_name_tag, device_floor_tag
) AS a ON b.building_tag = a.device_building_tag
and b.main_system_tag = a.device_system_tag and b.sub_system_tag = a.device_name_tag and b.floor_tag = a.device_floor_tag
) AS a ON b.building_tag COLLATE utf8mb4_0900_ai_ci = a.device_building_tag COLLATE utf8mb4_0900_ai_ci
and b.main_system_tag COLLATE utf8mb4_0900_ai_ci = a.device_system_tag COLLATE utf8mb4_0900_ai_ci
and b.sub_system_tag COLLATE utf8mb4_0900_ai_ci = a.device_name_tag COLLATE utf8mb4_0900_ai_ci
and b.floor_tag COLLATE utf8mb4_0900_ai_ci = a.device_floor_tag COLLATE utf8mb4_0900_ai_ci
SET b.is_link = 0
WHERE b.building_tag IS NULL");
await conn.ExecuteAsync(sb.ToString());
@ -774,15 +791,18 @@ namespace Repository.BackendRepository.Implement
try
{
StringBuilder sb = new StringBuilder();
sb.Append(@"UPDATE device d
INNER JOIN import_niagara_tag m ON m.niagara_tags = d.device_number
sb.Append(@"SET SQL_SAFE_UPDATES = 0;
update device d
JOIN (
select niagara_tags, device_full_name from import_niagara_tag limit 100000
) m ON m.niagara_tags COLLATE utf8mb4_0900_ai_ci = d.device_number COLLATE utf8mb4_0900_ai_ci
LEFT JOIN (
SELECT niagara_tags, device_full_name
FROM import_niagara_tag
LIMIT 100000
) m2 ON m2.niagara_tags COLLATE utf8mb4_0900_ai_ci = d.device_number COLLATE utf8mb4_0900_ai_ci AND m2.device_full_name COLLATE utf8mb4_0900_ai_ci = d.full_name COLLATE utf8mb4_0900_ai_ci
SET d.full_name = m.device_full_name
WHERE NOT EXISTS (
SELECT 1
FROM import_niagara_tag m2
WHERE m2.niagara_tags = d.device_number
AND m2.device_full_name = d.full_name
);");
WHERE m2.niagara_tags IS NULL;");
await conn.ExecuteAsync(sb.ToString());
}
catch (Exception exception)
@ -819,7 +839,7 @@ namespace Repository.BackendRepository.Implement
inner JOIN import_niagara_item m ON
m.device_system_tag = d.device_system_tag and
m.device_name_tag = d.device_name_tag and
m.device_point_name = d.points
m.device_point_name = d.points
set d.full_name=m.full_name
where d.full_name<>m.full_name;");
await conn.ExecuteAsync(sb.ToString());
@ -964,7 +984,9 @@ namespace Repository.BackendRepository.Implement
group by device_building_tag, device_floor_tag
) AS tag
LEFT JOIN floor f
ON tag.device_building_tag = f.building_tag and tag.device_floor_tag = f.full_name and f.deleted = 0
ON tag.device_building_tag COLLATE utf8mb4_0900_ai_ci = f.building_tag COLLATE utf8mb4_0900_ai_ci
and tag.device_floor_tag COLLATE utf8mb4_0900_ai_ci = f.full_name COLLATE utf8mb4_0900_ai_ci
and f.deleted = 0
WHERE f.building_tag IS NULL;");
result = (await conn.QueryAsync<NiagaraTags>(sb.ToString())).ToList<NiagaraTags>();
#endregion
@ -1009,7 +1031,9 @@ namespace Repository.BackendRepository.Implement
group by device_building_tag, device_floor_tag
) AS tag
LEFT JOIN floor f
ON tag.device_building_tag = f.building_tag and tag.device_floor_tag = f.full_name and f.deleted = 0
ON tag.device_building_tag COLLATE utf8mb4_0900_ai_ci = f.building_tag COLLATE utf8mb4_0900_ai_ci
and tag.device_floor_tag COLLATE utf8mb4_0900_ai_ci = f.full_name COLLATE utf8mb4_0900_ai_ci
and f.deleted = 0
) as f2 on f1.floor_guid = f2.floor_guid
where f2.floor_guid is null and f1.deleted = 0;")).ToList<BuildFloor>();