diff --git a/Backend/Controllers/DeviceManageController.cs b/Backend/Controllers/DeviceManageController.cs index 00c8da0..4325c9a 100644 --- a/Backend/Controllers/DeviceManageController.cs +++ b/Backend/Controllers/DeviceManageController.cs @@ -805,7 +805,7 @@ namespace Backend.Controllers try { - var rawDatas = await backendRepository.GetAllAsync("device_import_ckeck_temp", "is_correct = 1 ORDER BY device_building_tag, device_system_tag, device_floor_tag, device_name_tag"); + var rawDatas = await backendRepository.GetAllAsync("import_niagara_tag", null, null, "device_building_tag, device_system_tag, device_floor_tag, device_name_tag"); var rawDatas_Group_Building_tag = rawDatas.GroupBy(x => x.Device_building_tag).ToList(); List tempFilters = new List(); @@ -871,37 +871,34 @@ namespace Backend.Controllers try { - string sql = @"SELECT - di.device_building_tag, - di.device_system_tag, - di.device_floor_tag, - di.device_name_tag, - di.device_serial_tag, - di.device_number, - di.device_system_category_layer3, - STRING_AGG( ISNULL(v.system_value, ' '), ',') AS Device_disasters, - STRING_AGG( ISNULL(v.system_key, ' '), ',') AS Device_disaster_type_text - FROM - (SELECT - * - FROM device_import_ckeck_temp di - WHERE device_building_tag = @Device_building_tag - AND device_system_tag = @Device_system_tag - AND device_floor_tag = @Device_floor_tag - AND device_name_tag = @Device_name_tag - AND is_correct = 1 - AND device_number NOT IN (SELECT d.device_number FROM device d WHERE d.deleted = 0) - ) di - CROSS APPLY STRING_SPLIT(di.device_disaster, ',') dd - LEFT JOIN variable v ON v.system_type = 'disaster' AND v.system_value = dd.value - GROUP BY di.device_building_tag, - di.device_system_tag, - di.device_floor_tag, - di.device_name_tag, - di.device_serial_tag, - di.device_number, - di.device_system_category_layer3"; - + string sql = @"SELECT + di.device_building_tag, + di.device_system_tag, + di.device_floor_tag, + di.device_last_name_tag as device_name_tag, + di.device_serial_tag, + 0 as device_disaster, + di.niagara_tags as device_number + FROM + ( + SELECT + * + FROM + import_niagara_tag intag + WHERE + device_building_tag = @Device_building_tag + AND device_system_tag = @Device_system_tag + AND device_floor_tag = @Device_floor_tag + AND device_name_tag = @Device_name_tag + AND convert(intag.niagara_tags, nchar) NOT IN ( SELECT convert(d.device_number, nchar) FROM device d WHERE d.deleted = 0 ) + ) di + GROUP BY + di.device_building_tag, + di.device_system_tag, + di.device_floor_tag, + di.device_last_name_tag, + di.device_serial_tag, + di.niagara_tags"; var deviceImports = await backendRepository.GetAllAsync(sql, post);