[後端] 修改api錯誤, dbs改用巨蛋

This commit is contained in:
dev02 2023-04-20 13:31:10 +08:00
parent a38a4473dd
commit 693804320f
7 changed files with 100 additions and 91 deletions

View File

@ -578,100 +578,103 @@ namespace Backend.Controllers
-- OR ct.disaster_system_value != d.device_disaster"; -- OR ct.disaster_system_value != d.device_disaster";
} }
string sql_temp = $@" if (!string.IsNullOrEmpty(post.Building_tag) && !string.IsNullOrEmpty(post.System_category) && !string.IsNullOrEmpty(post.System_tag))
SELECT {
ct.device_number AS check_temp_device_number, string sql_temp = $@"
ct.device_system_category_layer3 AS check_temp_device_system_category_layer3, SELECT
ct.system_category_system_key AS check_temp_device_system_category_layer3_key, ct.device_number AS check_temp_device_number,
ct.disaster_system_value AS check_temp_disaster, ct.device_system_category_layer3 AS check_temp_device_system_category_layer3,
ct.disaster_system_key AS check_temp_disaster_key, ct.system_category_system_key AS check_temp_device_system_category_layer3_key,
d.device_number, ct.disaster_system_value AS check_temp_disaster,
d.device_system_category_layer3 AS device_system_category_layer3, ct.disaster_system_key AS check_temp_disaster_key,
d.system_key AS device_system_category_layer3_key, d.device_number,
d.device_disaster, d.device_system_category_layer3 AS device_system_category_layer3,
d.device_disaster_type_text, d.system_key AS device_system_category_layer3_key,
d.device_coordinate, d.device_disaster,
CASE d.device_disaster_type_text,
WHEN ct.device_number = d.device_number d.device_coordinate,
THEN 0 CASE
ELSE 1 WHEN ct.device_number = d.device_number
END AS compare_device_number, THEN 0
CASE ELSE 1
WHEN ct.device_system_category_layer3 = d.device_system_category_layer3 END AS compare_device_number,
THEN 0 CASE
ELSE 1 WHEN ct.device_system_category_layer3 = d.device_system_category_layer3
END AS compare_system_category_layer3, THEN 0
CASE ELSE 1
WHEN ct.disaster_system_value = d.device_disaster END AS compare_system_category_layer3,
THEN 0 CASE
ELSE 1 WHEN ct.disaster_system_value = d.device_disaster
END AS compare_device_disaster THEN 0
FROM ( ELSE 1
SELECT END AS compare_device_disaster
ct.* , FROM (
v.system_type AS system_category_system_type, SELECT
v.system_key AS system_category_system_key, ct.* ,
v.system_value AS system_category_system_value, v.system_type AS system_category_system_type,
v2.system_type AS disaster_system_type, v.system_key AS system_category_system_key,
v2.system_key AS disaster_system_key, v.system_value AS system_category_system_value,
v2.system_value AS disaster_system_value v2.system_type AS disaster_system_type,
FROM device_import_ckeck_temp ct v2.system_key AS disaster_system_key,
LEFT JOIN variable v ON v.system_type = 'device_system_category_layer3' AND ct.device_system_category_layer3 = v.system_value v2.system_value AS disaster_system_value
LEFT JOIN variable v2 ON v2.system_type = 'disaster' AND v2.system_value = ct.device_disaster FROM device_import_ckeck_temp ct
{{0}} LEFT JOIN variable v ON v.system_type = 'device_system_category_layer3' AND ct.device_system_category_layer3 = v.system_value
) ct LEFT JOIN variable v2 ON v2.system_type = 'disaster' AND v2.system_value = ct.device_disaster
FULL JOIN ( {{0}}
SELECT ) ct
d.* , LEFT JOIN (
v.system_type, SELECT
v.system_key, d.* ,
v.system_value, v.system_type,
(SELECT v.system_key,
STRING_AGG( ISNULL(system_value, ' '), ',') v.system_value,
FROM device_disaster dd (SELECT
JOIN variable v ON v.deleted = 0 AND v.system_type = 'disaster' AND v.system_value = dd.device_system_value GROUP_CONCAT( ifnull(system_value, ' '), ',')
WHERE dd.device_guid = d.device_guid FROM device_disaster dd
) AS device_disaster, JOIN variable v ON v.deleted = 0 AND v.system_type = 'disaster' AND v.system_value = dd.device_system_value
(SELECT WHERE dd.device_guid = d.device_guid
STRING_AGG( ISNULL(system_key, ' '), ',') ) AS device_disaster,
FROM device_disaster dd (SELECT
JOIN variable v ON v.deleted = 0 AND v.system_type = 'disaster' AND v.system_value = dd.device_system_value GROUP_CONCAT( ifnull(system_key, ' '), ',')
WHERE dd.device_guid = d.device_guid FROM device_disaster dd
) AS device_disaster_type_text JOIN variable v ON v.deleted = 0 AND v.system_type = 'disaster' AND v.system_value = dd.device_system_value
FROM device d WHERE dd.device_guid = d.device_guid
LEFT JOIN variable v ON v.system_type = 'device_system_category_layer3' AND d.device_system_category_layer3 = v.system_value ) AS device_disaster_type_text
{{1}} FROM device d
AND d.deleted = 0 LEFT JOIN variable v ON v.system_type = 'device_system_category_layer3' AND d.device_system_category_layer3 = v.system_value
{{1}}
AND d.deleted = 0
)d ON ct.device_number = d.device_number )d ON ct.device_number = d.device_number
{{2}} {{2}}
ORDER BY d.device_number DESC ORDER BY d.device_number DESC
"; ";
var sql = string.Format(sql_temp, string.Format(sSubTableWhere, "ct"), string.Format(sSubTableWhere, "d"), sWhere); var sql = string.Format(sql_temp, string.Format(sSubTableWhere, "ct"), string.Format(sSubTableWhere, "d"), sWhere);
var param = new { Device_building_tag = post.Building_tag, Device_system_tag = post.System_tag, Device_system_category_layer3 = post.System_category }; var param = new { Device_building_tag = post.Building_tag, Device_system_tag = post.System_tag, Device_system_category_layer3 = post.System_category };
var deviceCheckTableList = await backendRepository.GetAllAsync<DeviceCheckTable>(sql, param); var deviceCheckTableList = await backendRepository.GetAllAsync<DeviceCheckTable>(sql, param);
sSubTableWhere = " WHERE {0}.device_building_tag = @Device_building_tag"; sSubTableWhere = " WHERE {0}.device_building_tag = @Device_building_tag";
sWhere = @"WHERE ct.device_number IS NULL AND d.device_number IS NOT NULL sWhere = @"WHERE ct.device_number IS NULL AND d.device_number IS NOT NULL
-- OR ct.device_system_category_layer3 != d.device_system_category_layer3 -- OR ct.device_system_category_layer3 != d.device_system_category_layer3
-- OR ct.disaster_system_value != d.device_disaster"; -- OR ct.disaster_system_value != d.device_disaster";
var sql_abnormal_amount = string.Format(sql_temp, string.Format(sSubTableWhere, "ct"), string.Format(sSubTableWhere, "d") + " AND d.deleted = 0", sWhere); var sql_abnormal_amount = string.Format(sql_temp, string.Format(sSubTableWhere, "ct"), string.Format(sSubTableWhere, "d") + " AND d.deleted = 0", sWhere);
var abnormal = await backendRepository.GetAllAsync<DeviceCheckTable>(sql_abnormal_amount, param); var abnormal = await backendRepository.GetAllAsync<DeviceCheckTable>(sql_abnormal_amount, param);
var abnormal_amount = abnormal.Count(); var abnormal_amount = abnormal.Count();
DeviceCheck deviceCheck = new DeviceCheck(); DeviceCheck deviceCheck = new DeviceCheck();
deviceCheck.DeviceCheckAmount = abnormal_amount; deviceCheck.DeviceCheckAmount = abnormal_amount;
deviceCheck.DeviceCheckTableList = deviceCheckTableList; deviceCheck.DeviceCheckTableList = deviceCheckTableList;
apiResult.Code = "0000"; apiResult.Code = "0000";
apiResult.Data = deviceCheck; apiResult.Data = deviceCheck;
}
} }
catch (Exception exception) catch (Exception exception)
{ {

View File

@ -18,8 +18,8 @@
"Port": "js2LutKe+rdjzdxMPQUrvQ==", "Port": "js2LutKe+rdjzdxMPQUrvQ==",
//"Database": "VJB2XC+lAtzuHObDGMVOAA==", //30 //"Database": "VJB2XC+lAtzuHObDGMVOAA==", //30
//"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp //"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp
//"Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome "Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome
"Database": "siTUcDaC/g2yGTMFWD72Kg==", //tpe_dome_hotel //"Database": "siTUcDaC/g2yGTMFWD72Kg==", //tpe_dome_hotel
"Root": "SzdxEgaJJ7tcTCrUl2zKsA==", "Root": "SzdxEgaJJ7tcTCrUl2zKsA==",
"Password": "FVAPxztxpY4gJJKQ/se4bQ==" "Password": "FVAPxztxpY4gJJKQ/se4bQ=="
} }
@ -57,8 +57,8 @@
//"ObixHisBqlQuery": "7C/j7U8PmDqMxpb7f6gMpHFicuOA83OZeuWHBFdi/xpfEIklxyQ/wP75bEKwrdh+fXXgjmpc9cLX9GqbBC7eGw==", // //"ObixHisBqlQuery": "7C/j7U8PmDqMxpb7f6gMpHFicuOA83OZeuWHBFdi/xpfEIklxyQ/wP75bEKwrdh+fXXgjmpc9cLX9GqbBC7eGw==", //
//"ObixHisUrlQuery": "7C/j7U8PmDqMxpb7f6gMpD06cJcRzpVx0+IAssROlE4MlzSDPojSI17+XkQIL9Eu" // //"ObixHisUrlQuery": "7C/j7U8PmDqMxpb7f6gMpD06cJcRzpVx0+IAssROlE4MlzSDPojSI17+XkQIL9Eu" //
//"UrlSlot": "e1dUH6340WkFoHPJYq7IYQ==", // D2 "UrlSlot": "e1dUH6340WkFoHPJYq7IYQ==", // D2
"UrlSlot": "f9cDBTw5PCfbDTOt4Kwbew==", // slot:/Arena/H| //"UrlSlot": "f9cDBTw5PCfbDTOt4Kwbew==", // slot:/Arena/H|
"ObixQuery": "7C/j7U8PmDqMxpb7f6gMpIDkLYyNwmXoqhx+N1G+fqQxEETrRbFLZfC7Sud5yX24CphfLlSUbfjft7gcP6v+gw==", // http://192.168.0.136:8082/obix/config/Program/ObixQuery/query/ "ObixQuery": "7C/j7U8PmDqMxpb7f6gMpIDkLYyNwmXoqhx+N1G+fqQxEETrRbFLZfC7Sud5yX24CphfLlSUbfjft7gcP6v+gw==", // http://192.168.0.136:8082/obix/config/Program/ObixQuery/query/
"ObixHisBqlQuery": "7C/j7U8PmDqMxpb7f6gMpIDkLYyNwmXoqhx+N1G+fqQxEETrRbFLZfC7Sud5yX24CphfLlSUbfjft7gcP6v+gw==", // http://192.168.0.136:8082/obix/config/Program/ObixQuery/query/ "ObixHisBqlQuery": "7C/j7U8PmDqMxpb7f6gMpIDkLYyNwmXoqhx+N1G+fqQxEETrRbFLZfC7Sud5yX24CphfLlSUbfjft7gcP6v+gw==", // http://192.168.0.136:8082/obix/config/Program/ObixQuery/query/
"ObixHisUrlQuery": "7C/j7U8PmDqMxpb7f6gMpEVUZrrjJT0WiTUBn0FzipXfBFsxYAX3plIWBcJ+oZzW", // http://192.168.0.136:8081/obix/histories "ObixHisUrlQuery": "7C/j7U8PmDqMxpb7f6gMpEVUZrrjJT0WiTUBn0FzipXfBFsxYAX3plIWBcJ+oZzW", // http://192.168.0.136:8081/obix/histories

View File

@ -17,7 +17,8 @@
"Server": "FYlY+w0XDIz+jmF2rlZWJw==", //0.201 "Server": "FYlY+w0XDIz+jmF2rlZWJw==", //0.201
"Port": "js2LutKe+rdjzdxMPQUrvQ==", "Port": "js2LutKe+rdjzdxMPQUrvQ==",
//"Database": "VJB2XC+lAtzuHObDGMVOAA==", // //"Database": "VJB2XC+lAtzuHObDGMVOAA==", //
"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp //"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp
"Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome
"Root": "SzdxEgaJJ7tcTCrUl2zKsA==", "Root": "SzdxEgaJJ7tcTCrUl2zKsA==",
"Password": "FVAPxztxpY4gJJKQ/se4bQ==" "Password": "FVAPxztxpY4gJJKQ/se4bQ=="
} }

View File

@ -12,11 +12,14 @@
"SignKey": "TaipeiDome123456", //ñ<EFBFBD><EFBFBD>//<EFBFBD>̤<EFBFBD>16<EFBFBD>r<EFBFBD><EFBFBD> "SignKey": "TaipeiDome123456", //ñ<EFBFBD><EFBFBD>//<EFBFBD>̤<EFBFBD>16<EFBFBD>r<EFBFBD><EFBFBD>
"JwtLifeSeconds": 3600 "JwtLifeSeconds": 3600
}, },
"DBConfig": { "DBConfig": {
"MySqlDBConfig": { "MySqlDBConfig": {
"Server": "FYlY+w0XDIz+jmF2rlZWJw==", //0.201 "Server": "FYlY+w0XDIz+jmF2rlZWJw==", //0.201
"Port": "js2LutKe+rdjzdxMPQUrvQ==", "Port": "js2LutKe+rdjzdxMPQUrvQ==",
"Database": "VJB2XC+lAtzuHObDGMVOAA==", //30 //"Database": "VJB2XC+lAtzuHObDGMVOAA==", //30
//"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp
"Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome
//"Database": "siTUcDaC/g2yGTMFWD72Kg==", //tpe_dome_hotel
"Root": "SzdxEgaJJ7tcTCrUl2zKsA==", "Root": "SzdxEgaJJ7tcTCrUl2zKsA==",
"Password": "FVAPxztxpY4gJJKQ/se4bQ==" "Password": "FVAPxztxpY4gJJKQ/se4bQ=="
} }

View File

@ -23,7 +23,9 @@
"Server": "FYlY+w0XDIz+jmF2rlZWJw==", //0.201 "Server": "FYlY+w0XDIz+jmF2rlZWJw==", //0.201
"Port": "js2LutKe+rdjzdxMPQUrvQ==", "Port": "js2LutKe+rdjzdxMPQUrvQ==",
//"Database": "VJB2XC+lAtzuHObDGMVOAA==", // //"Database": "VJB2XC+lAtzuHObDGMVOAA==", //
"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp //"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp
"Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome
//"Database": "siTUcDaC/g2yGTMFWD72Kg==", //tpe_dome_hotel
"Root": "SzdxEgaJJ7tcTCrUl2zKsA==", "Root": "SzdxEgaJJ7tcTCrUl2zKsA==",
"Password": "FVAPxztxpY4gJJKQ/se4bQ==" "Password": "FVAPxztxpY4gJJKQ/se4bQ=="
}, },