This commit is contained in:
dev01 2023-05-25 18:41:58 +08:00
commit e986fa9305
5 changed files with 58 additions and 33 deletions

View File

@ -1662,7 +1662,7 @@ namespace Backend.Controllers
try
{
string sWhere = "deleted = 0 AND device_name_tag = @Sub_system_tag and device_building_tag = @device_building_tag";
string sWhere = "deleted = 0 AND device_name_tag = @Sub_system_tag and device_building_tag = @device_building_tag and is_link = 1 and is_controll = 1";
object param = new { Sub_system_tag = input.sub_system_tag, device_building_tag = input.building_tag };

View File

@ -501,26 +501,37 @@ namespace Backend.Controllers
try
{
var main_tag = await backendRepository.GetOneAsync<string>($@"SELECT system_value FROM variable WHERE id = @id", new { id = device_Item.device_system_tag });
var sub_tag = await backendRepository.GetOneAsync<string>($@"SELECT system_value FROM variable WHERE id = @id", new { id = device_Item.device_name_tag });
//檢查是否有未刪除的區域選單
if(device_Item.is_show_riserDiagram == 1)
if (device_Item.is_show_riserDiagram == 1)
{
var sql_show_riserDiagram = $@"SELECT * FROM device_item di
WHERE di.id = @id AND di.deleted = 0 AND is_show_riserDiagram = 1";
var sql_show_riserDiagram = $@"SELECT di.id FROM device_item di
WHERE di.id != @id AND di.deleted = 0 AND is_show_riserDiagram = 1 and device_system_tag = @device_system_tag
and device_name_tag = @device_name_tag";
var is_show_riserDiagram = await backendRepository.GetAllAsync<string>(sql_show_riserDiagram, new { id = device_Item.id });
var deviceItemId = await backendRepository.GetAllAsync<int>(sql_show_riserDiagram,
new { id = device_Item.id, device_system_tag = main_tag, device_name_tag = sub_tag });
if (is_show_riserDiagram.Count() > 0)
if (deviceItemId.Count() > 0)
{
apiResult.Code = "9998";
apiResult.Msg = "請先取消已選擇顯示於昇位圖點位。";
return apiResult;
foreach (var id in deviceItemId)
{
Dictionary<string, object> Device_itemDic = new Dictionary<string, object>()
{
{ "@is_show_riserDiagram", false},
{ "@updated_by", myUserInfo.Userinfo_guid},
{ "@updated_at", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")},
};
await backendRepository.UpdateOneByCustomTable(Device_itemDic, "device_item", "id='" + id + "'");
}
}
}
if (device_Item.id == 0)
{
var main_tag = await backendRepository.GetOneAsync<string>($@"SELECT system_value FROM variable WHERE id = @id", new { id = device_Item.device_system_tag });
var sub_tag = await backendRepository.GetOneAsync<string>($@"SELECT system_value FROM variable WHERE id = @id", new { id = device_Item.device_name_tag });
//新增
Dictionary<string, object> Device_itemDic = new Dictionary<string, object>()
{
@ -586,7 +597,7 @@ namespace Backend.Controllers
FROM device_item di
JOIN variable sv ON di.device_name_tag = sv.system_value
JOIN variable mv ON sv.system_parent_id = mv.id AND di.device_system_tag = mv.system_value
WHERE sv.id = @id AND di.deleted = @Deleted and di.device_building_tag = @building_tag";
WHERE sv.id = @id AND di.deleted = @Deleted and di.device_building_tag = @building_tag and di.is_link = 1";
object param = new { Deleted = 0, id = id, building_tag = building_tag.Split("/")[1] };

View File

@ -219,6 +219,7 @@
pageAct.selAllSysSub = false;
first = true;
let dataAlarm = [];
var historyTable = null;
$(function () {
initDropzone();
@ -651,8 +652,11 @@
}
});
}
else {
$('#alertTable').DataTable().clear().draw();
$(loadEle).Loading("close");
}
}
$(loadEle).Loading("close");
}
function stackData(res) {
@ -663,7 +667,8 @@
}
function callBackFromAllDeviceAlert(res) {
refTable(res.data);
AlertList(res.data);
if (historyTable != null) {
let t = $('#alertTable').dataTable();
@ -674,7 +679,7 @@
}
function callBackFromOneDeviceAlert(res) {
refTable(res);
AlertList(res);
if (historyTable != null) {
let t = $('#alertTable').dataTable();
@ -686,14 +691,8 @@
}
function refTable(data) {
console.log(data)
let tag = "#alertTable";
$.each(data, function (i, v) {
// console.log(v.uuid.$val, v.uuid)
v.formId = AlertList(v.uuid.$val || v.uuid);
});
let column_defs = [
{ "targets": [0], "width": "5%", "sortable": true },
{ "targets": [1], "width": "5%", "sortable": true },
@ -771,19 +770,25 @@
];
historyTable = new YourTeam.JqDataTables.getTableByStatic(tag, data, columns, column_defs, null, null, null, null, "tpi");
$(loadEle).Loading("close");
}
function AlertList(errCode) {
objSendData.Data = { uuid: errCode };
let a = null
function AlertList(data) {
objSendData.Data = [];
$.each(data, function (i, v) {
objSendData.Data.push({ uuid: v.uuid.$val || v.uuid })
});
url = baseApiUrl + "/Alert/AlertList";
ytAjax = new YourTeam.Ajax(url, objSendData, function (rel) {
if (rel.code == "0000")
a = rel.data;
// console.log(rel)
if (rel.code == "0000") {
$.each(rel.data, function (i, v) {
let index = data.findIndex(x => (x.uuid.$val || x.uuid) === v.uuid);
data[index].formId = v.formId;
});
refTable(data)
}
}, null, "POST").send();
return a;
}
function selDevice() {

View File

@ -10,6 +10,8 @@ using System.IO;
using System.Data.SqlTypes;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using NPOI.HSSF.Record.Chart;
using System.Linq;
namespace FrontendWebApi.ApiControllers
{
@ -169,13 +171,19 @@ namespace FrontendWebApi.ApiControllers
}
[HttpPost]
public async Task<ApiResult<string>> AlertList([FromBody] FindFormId alerts)
public async Task<ApiResult<List<FindFormId>>> AlertList([FromBody] List<FindFormId> alerts)
{
ApiResult<string> apiResult = new ApiResult<string>();
ApiResult<List<FindFormId>> apiResult = new ApiResult<List<FindFormId>>();
try
{
var sqlString = $@"select formId from operation_record where error_code = @error_code and deleted = 0 limit 1";
var formId = await backendRepository.GetOneAsync<string>(sqlString, new { @error_code = alerts.uuid });
var formId = new List<FindFormId>();
foreach(var fi in alerts)
{
var sqlString = $@"select error_code uuid, formId from operation_record where error_code = @error_code and deleted = 0 limit 1";
var data = await backendRepository.GetOneAsync<FindFormId>(sqlString, new { @error_code = fi.uuid });
if (data != null)
formId.Add(data);
}
apiResult.Code = "0000";
apiResult.Data = formId;

View File

@ -33,6 +33,7 @@ namespace FrontendWebApi.Models
public class FindFormId
{
public string uuid { get; set; }
public string formId { get; set; }
}
}