[設備管理][設備基本資料] 設備種類新增及修改程序調整完成

This commit is contained in:
dev01 2022-10-26 15:42:56 +08:00
parent bb309d8613
commit fc884ddb61
4 changed files with 147 additions and 64 deletions

View File

@ -201,7 +201,8 @@ namespace Backend.Controllers
LEFT JOIN device_kind dk ON dk.device_building_tag = d.device_building_tag AND dk.device_system_tag = d.device_system_tag AND dk.device_name_tag = d.device_name_tag LEFT JOIN device_kind dk ON dk.device_building_tag = d.device_building_tag AND dk.device_system_tag = d.device_system_tag AND dk.device_name_tag = d.device_name_tag
ORDER BY d.priority ASC, d.device_number ASC"; ORDER BY d.priority ASC, d.device_number ASC";
var devices = await backendRepository.GetAllAsync<Device>(sql, new { var devices = await backendRepository.GetAllAsync<Device>(sql, new
{
building_tag = post.building_tag, building_tag = post.building_tag,
main_system_tag = post.device_system_tag, main_system_tag = post.device_system_tag,
sub_system_tag = post.device_name_tag, sub_system_tag = post.device_name_tag,
@ -269,7 +270,7 @@ namespace Backend.Controllers
JOIN floor f ON d.device_floor_tag = f.full_name JOIN floor f ON d.device_floor_tag = f.full_name
"; ";
object param = new { Deleted = 0, Device_guid = guid ,main_system_type = main_system_type , sub_system_type = sub_system_type }; object param = new { Deleted = 0, Device_guid = guid, main_system_type = main_system_type, sub_system_type = sub_system_type };
var device = await backendRepository.GetOneAsync<Device>(sql, param); var device = await backendRepository.GetOneAsync<Device>(sql, param);
@ -333,7 +334,7 @@ namespace Backend.Controllers
{ {
List<Dictionary<string, object>> deviceDics = new List<Dictionary<string, object>>(); List<Dictionary<string, object>> deviceDics = new List<Dictionary<string, object>>();
List<Dictionary<string, object>> device_disaster_dicts = new List<Dictionary<string, object>>(); List<Dictionary<string, object>> device_disaster_dicts = new List<Dictionary<string, object>>();
PostDeviceKind postDeviceKind = new PostDeviceKind();
using (var reader = new StreamReader(post.SelectedDevicesFile.OpenReadStream())) using (var reader = new StreamReader(post.SelectedDevicesFile.OpenReadStream()))
{ {
string content = reader.ReadToEnd(); string content = reader.ReadToEnd();
@ -376,6 +377,14 @@ namespace Backend.Controllers
{ "@created_by", myUserInfo.Userinfo_guid}, { "@created_by", myUserInfo.Userinfo_guid},
}; };
postDeviceKind = new PostDeviceKind()
{
Device_building_tag = device_building_tag,
Device_system_tag = device_system_tag,
Device_floor_tag = device_floor_tag,
Device_name_tag = device_name_tag,
};
deviceDics.Add(deviceDic); deviceDics.Add(deviceDic);
if (device.Device_disasters != null) if (device.Device_disasters != null)
@ -405,6 +414,8 @@ namespace Backend.Controllers
await ResetDeviceGroup(); //重新寫入設備群組 await ResetDeviceGroup(); //重新寫入設備群組
await AddDeviceKind(postDeviceKind);
apiResult.Code = "0000"; apiResult.Code = "0000";
apiResult.Msg = "修改成功"; apiResult.Msg = "修改成功";
@ -807,7 +818,7 @@ namespace Backend.Controllers
try try
{ {
var rawDatas = await backendRepository.GetAllAsync<DeviceImportCheckTempRawData>("import_niagara_tag", null,null,"device_building_tag, device_system_tag, device_floor_tag, device_name_tag"); var rawDatas = await backendRepository.GetAllAsync<DeviceImportCheckTempRawData>("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(); var rawDatas_Group_Building_tag = rawDatas.GroupBy(x => x.Device_building_tag).ToList();
List<DeviceImportCheckTempFilter> tempFilters = new List<DeviceImportCheckTempFilter>(); List<DeviceImportCheckTempFilter> tempFilters = new List<DeviceImportCheckTempFilter>();
@ -966,8 +977,8 @@ namespace Backend.Controllers
FROM device d FROM device d
WHERE WHERE
d.device_building_tag = @building_tag d.device_building_tag = @building_tag
AND d.device_system_tag = @main_system_tag AND d.device_system_tag = @device_system_tag
AND d.device_name_tag = @sub_system_tag AND d.device_name_tag = @device_name_tag
-- AND d.floor_guid = @Floor_tag -- AND d.floor_guid = @Floor_tag
AND d.deleted = 0 AND d.deleted = 0
) d ) d
@ -1028,6 +1039,70 @@ namespace Backend.Controllers
return apiResult; return apiResult;
} }
public async Task AddDeviceKind(PostDeviceKind post)
{
string sWhere = @$"device_building_tag = @building_tag and device_system_tag = @system_tag and device_name_tag = @name_tag";
object param = new { building_tag = post.Device_building_tag, system_tag = post.Device_system_tag, name_tag = post.Device_name_tag };
var deviceKind = await backendRepository.GetOneAsync<DeviceKind>("device_kind", sWhere, param);
if (deviceKind == null)
{
//新增
//產生一組GUID
var guid = Guid.NewGuid();
//抓出點位名稱
//var point_name = new PointName();
//var sql_device_normal_point = @"SELECT n.points AS device_normal_point_name FROM (SELECT * FROM device_item di WHERE di.device_item_id = @device_normal_point_guid) n";
//point_name.Device_normal_point_name = await backendRepository.GetOneAsync<string>(sql_device_normal_point, new { device_normal_point_guid = post.Device_normal_point_guid });
//var sql_device_close_point = @"SELECT c.points AS device_close_point_name FROM (SELECT * FROM device_item di WHERE di.device_item_guid = @device_close_point_guid) c";
//point_name.Device_close_point_name = await backendRepository.GetOneAsync<string>(sql_device_close_point, new { device_close_point_guid = post.Device_close_point_guid });
//var sql_device_error_point = @"SELECT e.points AS device_error_point_name FROM (SELECT * FROM device_item di WHERE di.device_item_guid = @device_error_point_guid) e";
//point_name.Device_error_point_name = await backendRepository.GetOneAsync<string>(sql_device_error_point, new { device_error_point_guid = post.Device_error_point_guid });
Dictionary<string, object> deviceKindDic = new Dictionary<string, object>()
{
{ "@device_kind_guid", guid},
{ "@device_building_tag", post.Device_building_tag},
{ "@device_system_tag", post.Device_system_tag},
//{ "@device_floor_tag", post.Device_floor_tag},
{ "@device_name_tag", post.Device_name_tag},
{ "@device_image", null },
{ "@device_normal_text", post.Device_normal_text},
{ "@device_normal_point_guid", post.Device_normal_point_guid},
{ "@device_normal_point_name", null},
{ "@device_normal_point_col", post.Device_normal_point_col},
{ "@device_normal_point_value", post.Device_normal_point_value},
{ "@device_normal_color", post.Device_normal_color},
{ "@device_normal_flashing", post.Device_normal_flashing},
{ "@device_close_text", post.Device_close_text},
{ "@device_close_point_guid", post.Device_close_point_guid},
{ "@device_close_point_name", null},
{ "@device_close_point_col", post.Device_close_point_col},
{ "@device_close_point_value", post.Device_close_point_value},
{ "@device_close_color", post.Device_close_color},
{ "@device_close_flashing", post.Device_close_flashing},
{ "@device_error_text", post.Device_error_text},
{ "@device_error_point_guid", post.Device_error_point_guid},
{ "@device_error_point_name", null},
{ "@device_error_point_col", post.Device_error_point_col},
{ "@device_error_point_value", post.Device_error_point_value},
{ "@device_error_color", post.Device_error_color},
{ "@device_error_flashing", post.Device_error_flashing},
{ "@device_error_independent", post.Device_error_independent},
{ "@created_by", myUserInfo.Userinfo_guid}
};
await backendRepository.AddOneByCustomTable(deviceKindDic, "device_kind");
}
}
/// <summary> /// <summary>
/// 修改 設備基本資料 /// 修改 設備基本資料
/// </summary> /// </summary>
@ -1065,14 +1140,14 @@ namespace Backend.Controllers
//抓出點位名稱 //抓出點位名稱
var point_name = new PointName(); var point_name = new PointName();
var sql_device_normal_point = @"SELECT n.points AS device_normal_point_name FROM (SELECT * FROM device_item di WHERE di.device_item_guid = @device_normal_point_guid) n"; var sql_device_normal_point = @"SELECT n.points AS device_normal_point_name FROM (SELECT * FROM device_item di WHERE di.id = @device_normal_point_id) n";
point_name.Device_normal_point_name = await backendRepository.GetOneAsync<string>(sql_device_normal_point, new { device_normal_point_guid = post.Device_normal_point_guid }); point_name.Device_normal_point_name = await backendRepository.GetOneAsync<string>(sql_device_normal_point, new { device_normal_point_id = post.Device_normal_point_guid });
var sql_device_close_point = @"SELECT c.points AS device_close_point_name FROM (SELECT * FROM device_item di WHERE di.device_item_guid = @device_close_point_guid) c"; var sql_device_close_point = @"SELECT c.points AS device_close_point_name FROM (SELECT * FROM device_item di WHERE di.id = @device_close_point_id) c";
point_name.Device_close_point_name = await backendRepository.GetOneAsync<string>(sql_device_close_point, new { device_close_point_guid = post.Device_close_point_guid }); point_name.Device_close_point_name = await backendRepository.GetOneAsync<string>(sql_device_close_point, new { device_close_point_id = post.Device_close_point_guid });
var sql_device_error_point = @"SELECT e.points AS device_error_point_name FROM (SELECT * FROM device_item di WHERE di.device_item_guid = @device_error_point_guid) e"; var sql_device_error_point = @"SELECT e.points AS device_error_point_name FROM (SELECT * FROM device_item di WHERE di.id = @device_error_point_id) e";
point_name.Device_error_point_name = await backendRepository.GetOneAsync<string>(sql_device_error_point, new { device_error_point_guid = post.Device_error_point_guid }); point_name.Device_error_point_name = await backendRepository.GetOneAsync<string>(sql_device_error_point, new { device_error_point_id = post.Device_error_point_guid });
Dictionary<string, object> deviceKindDic = new Dictionary<string, object>() Dictionary<string, object> deviceKindDic = new Dictionary<string, object>()
{ {
@ -1122,23 +1197,23 @@ namespace Backend.Controllers
} }
#region #region
List<Repository.Models.FileInfo> fileInfos = new List<Repository.Models.FileInfo>(); //List<Repository.Models.FileInfo> fileInfos = new List<Repository.Models.FileInfo>();
if (post.Device_image_file != null) //if (post.Device_image_file != null)
{ //{
var split = post.Device_image_file.FileName.Split("."); // var split = post.Device_image_file.FileName.Split(".");
var fileName = guid + "." + split[split.Length - 1]; // var fileName = guid + "." + split[split.Length - 1];
var fullPath = Path.Combine(deviceKindFileSaveAsPath, fileName); // var fullPath = Path.Combine(deviceKindFileSaveAsPath, fileName);
Repository.Models.FileInfo fileInfo = new Repository.Models.FileInfo(); // Repository.Models.FileInfo fileInfo = new Repository.Models.FileInfo();
fileInfo.Folder = "device_icon"; // fileInfo.Folder = "device_icon";
fileInfo.OriginalFileName = null; // fileInfo.OriginalFileName = null;
fileInfo.FileName = fileName; // fileInfo.FileName = fileName;
fileInfo.File = fullPath; // fileInfo.File = fullPath;
fileInfos.Add(fileInfo); // fileInfos.Add(fileInfo);
await backendRepository.ManualInsertFileBackgroundServiceTask("", "", "device_kind", fileInfos); // await backendRepository.ManualInsertFileBackgroundServiceTask("", "", "device_kind", fileInfos);
} //}
#endregion #endregion
apiResult.Code = "0000"; apiResult.Code = "0000";
@ -1163,14 +1238,14 @@ namespace Backend.Controllers
//抓出點位名稱 //抓出點位名稱
var point_name = new PointName(); var point_name = new PointName();
var sql_device_normal_point = @"SELECT n.points AS device_normal_point_name FROM (SELECT * FROM device_item di WHERE di.device_item_guid = @device_normal_point_guid) n"; var sql_device_normal_point = @"SELECT n.points AS device_normal_point_name FROM (SELECT * FROM device_item di WHERE di.id = @device_normal_point_id) n";
point_name.Device_normal_point_name = await backendRepository.GetOneAsync<string>(sql_device_normal_point, new { device_normal_point_guid = post.Device_normal_point_guid }); point_name.Device_normal_point_name = await backendRepository.GetOneAsync<string>(sql_device_normal_point, new { device_normal_point_id = post.Device_normal_point_guid });
var sql_device_close_point = @"SELECT c.points AS device_close_point_name FROM (SELECT * FROM device_item di WHERE di.device_item_guid = @device_close_point_guid) c"; var sql_device_close_point = @"SELECT c.points AS device_close_point_name FROM (SELECT * FROM device_item di WHERE di.id = @device_close_point_id) c";
point_name.Device_close_point_name = await backendRepository.GetOneAsync<string>(sql_device_close_point, new { device_close_point_guid = post.Device_close_point_guid }); point_name.Device_close_point_name = await backendRepository.GetOneAsync<string>(sql_device_close_point, new { device_close_point_id = post.Device_close_point_guid });
var sql_device_error_point = @"SELECT e.points AS device_error_point_name FROM (SELECT * FROM device_item di WHERE di.device_item_guid = @device_error_point_guid) e"; var sql_device_error_point = @"SELECT e.points AS device_error_point_name FROM (SELECT * FROM device_item di WHERE di.id = @device_error_point_id) e";
point_name.Device_error_point_name = await backendRepository.GetOneAsync<string>(sql_device_error_point, new { device_error_point_guid = post.Device_error_point_guid }); point_name.Device_error_point_name = await backendRepository.GetOneAsync<string>(sql_device_error_point, new { device_error_point_id = post.Device_error_point_guid });
Dictionary<string, object> deviceKindDic = new Dictionary<string, object>() Dictionary<string, object> deviceKindDic = new Dictionary<string, object>()
{ {
@ -1220,23 +1295,23 @@ namespace Backend.Controllers
} }
#region #region
List<Repository.Models.FileInfo> fileInfos = new List<Repository.Models.FileInfo>(); //List<Repository.Models.FileInfo> fileInfos = new List<Repository.Models.FileInfo>();
if (post.Device_image_file != null) //if (post.Device_image_file != null)
{ //{
var split = post.Device_image_file.FileName.Split("."); // var split = post.Device_image_file.FileName.Split(".");
var fileName = image_guid + "." + split[split.Length - 1]; // var fileName = image_guid + "." + split[split.Length - 1];
var fullPath = Path.Combine(deviceKindFileSaveAsPath, fileName); // var fullPath = Path.Combine(deviceKindFileSaveAsPath, fileName);
Repository.Models.FileInfo fileInfo = new Repository.Models.FileInfo(); // Repository.Models.FileInfo fileInfo = new Repository.Models.FileInfo();
fileInfo.Folder = "device_icon"; // fileInfo.Folder = "device_icon";
fileInfo.OriginalFileName = deviceKind.Device_image; // fileInfo.OriginalFileName = deviceKind.Device_image;
fileInfo.FileName = fileName; // fileInfo.FileName = fileName;
fileInfo.File = fullPath; // fileInfo.File = fullPath;
fileInfos.Add(fileInfo); // fileInfos.Add(fileInfo);
await backendRepository.ManualInsertFileBackgroundServiceTask("", "", "device_kind", fileInfos); // await backendRepository.ManualInsertFileBackgroundServiceTask("", "", "device_kind", fileInfos);
} //}
#endregion #endregion
apiResult.Code = "0000"; apiResult.Code = "0000";
@ -1390,7 +1465,7 @@ namespace Backend.Controllers
{ {
string sWhere = "device_master_guid = @Device_master_guid"; string sWhere = "device_master_guid = @Device_master_guid";
object param = new {Device_master_guid = guid }; object param = new { Device_master_guid = guid };
var deviceMaster = await backendRepository.GetOneAsync<DeviceMaster>("device_master", sWhere, param); var deviceMaster = await backendRepository.GetOneAsync<DeviceMaster>("device_master", sWhere, param);
@ -1442,7 +1517,7 @@ namespace Backend.Controllers
} }
string temp_device_master_number = null; string temp_device_master_number = null;
if (!string.IsNullOrEmpty( post.Device_building_tag) && !string.IsNullOrEmpty(post.Device_name_tag)) if (!string.IsNullOrEmpty(post.Device_building_tag) && !string.IsNullOrEmpty(post.Device_name_tag))
{ {
temp_device_master_number = post.Device_building_tag + "_" + post.Device_name_tag; temp_device_master_number = post.Device_building_tag + "_" + post.Device_name_tag;
} }
@ -1585,7 +1660,7 @@ namespace Backend.Controllers
try try
{ {
string sWhere = "deleted = 0 AND sub_system_tag = @Sub_system_tag"; string sWhere = "deleted = 0 AND device_name_tag = @Sub_system_tag";
object param = new { Sub_system_tag = sub_system_tag }; object param = new { Sub_system_tag = sub_system_tag };

View File

@ -175,8 +175,8 @@
</div> </div>
</div> </div>
</div> </div>
<div class="form-group col-12" id="" name="drawing_extend"> <div class="form-group col-12" id="build_menu_planimetric_modal_div" name="drawing_extend" >
<div class="col-12 mb-2 custom-control custom-checkbox align-content-center"> <div class="col-12 mb-2 custom-control custom-checkbox align-content-center" >
<input type="checkbox" class="custom-control-input" name="planimetric_click" id="planimetric_click" value="1" /> <input type="checkbox" class="custom-control-input" name="planimetric_click" id="planimetric_click" value="1" />
<label class="custom-control-label" for="planimetric_click">是否顯示平面圖</label> <label class="custom-control-label" for="planimetric_click">是否顯示平面圖</label>
</div> </div>
@ -263,7 +263,13 @@
<label class="form-label"><span class="text-danger">*</span>預設頁面</label> <label class="form-label"><span class="text-danger">*</span>預設頁面</label>
<div class="row" id="build_menu_drawing_modal_r"> <div class="row" id="build_menu_drawing_modal_r">
<div class="col"> <div class="col">
<input type="radio" name="drawing_r" id="drawing_4_r" value="4" checked> <input type="radio" name="drawing_r" id="drawing_0_r" value="0" checked>
<label for="drawing_0_r">
不顯示
</label>
</div>
<div class="col">
<input type="radio" name="drawing_r" id="drawing_4_r" value="4">
<label for="drawing_4_r"> <label for="drawing_4_r">
昇位圖 昇位圖
</label> </label>
@ -294,7 +300,7 @@
</div> </div>
</div> </div>
</div> </div>
<div class="form-group col-12" id="" name="drawing_extend_r"> <div class="form-group col-12" id="build_menu_planimetric_modal_div_r" name="drawing_extend_r">
<div class="col-12 mb-2 custom-control custom-checkbox align-content-center"> <div class="col-12 mb-2 custom-control custom-checkbox align-content-center">
<input type="checkbox" class="custom-control-input" name="planimetric_click_r" id="planimetric_click_r" value="1" /> <input type="checkbox" class="custom-control-input" name="planimetric_click_r" id="planimetric_click_r" value="1" />
<label class="custom-control-label" for="planimetric_click_r">是否顯示平面圖</label> <label class="custom-control-label" for="planimetric_click_r">是否顯示平面圖</label>
@ -973,7 +979,7 @@
$(drawingParent).find('[id^=build_menu_icon_click_url_width_height_modal_div]').hide(); $(drawingParent).find('[id^=build_menu_icon_click_url_width_height_modal_div]').hide();
$(drawingParent).find('[id^=build_menu_planimetric_floor_modal_div]').hide(); $(drawingParent).find('[id^=build_menu_planimetric_floor_modal_div]').hide();
$(drawingParent).find('[id^=build_menu_systemurl_modal_div]').hide(); $(drawingParent).find('[id^=build_menu_systemurl_modal_div]').hide();
$(drawingParent).find('[id^=build_menu_planimetric_modal_div]').show();
if ($(value).val() == 2) { if ($(value).val() == 2) {
$(drawingParent).find('[id^=planimetric_click]').attr("disabled", false); $(drawingParent).find('[id^=planimetric_click]').attr("disabled", false);
$(drawingParent).find('[id^=build_menu_systemurl_modal_div]').show(); $(drawingParent).find('[id^=build_menu_systemurl_modal_div]').show();
@ -992,6 +998,8 @@
$(drawingParent).find('[id^=build_menu_blankurl_modal_div]').show(); $(drawingParent).find('[id^=build_menu_blankurl_modal_div]').show();
} else if ($(value).val() == 3) { } else if ($(value).val() == 3) {
$(drawingParent).find('[id^=planimetric_click]').prop("checked", false).attr("disabled", true); $(drawingParent).find('[id^=planimetric_click]').prop("checked", false).attr("disabled", true);
} else {
$(drawingParent).find('[id^=build_menu_planimetric_modal_div]').hide();
} }
}) })

View File

@ -1494,10 +1494,10 @@
"url": "/DeviceManage/DeviceKindTableList", "url": "/DeviceManage/DeviceKindTableList",
"type": "POST", "type": "POST",
"data": function (d) { "data": function (d) {
d.Building_tag = selected_building_menu.building_tag ? selected_building_menu.building_tag : ""; d.building_tag = selected_building_menu.building_tag ? selected_building_menu.building_tag : "";
d.Main_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.main_system_tag : ""; d.device_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.main_system_tag : "";
d.Sub_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.sub_system ? selected_building_menu.main_system.sub_system.sub_system_tag : "" : ""; d.device_name_tag = selected_building_menu.main_system ? selected_building_menu.main_system.sub_system ? selected_building_menu.main_system.sub_system.sub_system_tag : "" : "";
d.Floor_tag = selected_floor_tag ? selected_floor_tag : ""; //d.Floor_tag = selected_floor_tag ? selected_floor_tag : "";
}, },
"dataSrc": function (rel) { "dataSrc": function (rel) {
if (rel.code == "9999") { if (rel.code == "9999") {
@ -1574,9 +1574,9 @@
$("#device_close_point_name_modal").append($("<option />").val("").text("未選擇")); $("#device_close_point_name_modal").append($("<option />").val("").text("未選擇"));
$("#device_error_point_name_modal").append($("<option />").val("").text("未選擇")); $("#device_error_point_name_modal").append($("<option />").val("").text("未選擇"));
$.each(rel.data, function (index, val) { $.each(rel.data, function (index, val) {
$("#device_normal_point_name_modal").append($("<option />").val(val.device_item_guid).text(val.points)); $("#device_normal_point_name_modal").append($("<option />").val(val.id).text(val.points));
$("#device_close_point_name_modal").append($("<option />").val(val.device_item_guid).text(val.points)); $("#device_close_point_name_modal").append($("<option />").val(val.id).text(val.points));
$("#device_error_point_name_modal").append($("<option />").val(val.device_item_guid).text(val.points)); $("#device_error_point_name_modal").append($("<option />").val(val.id).text(val.points));
}); });

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB