修改系統監控作業, 修改運維新增編輯

This commit is contained in:
dev02 2022-11-15 19:00:36 +08:00
parent 35758f6dd1
commit d4daa1188c
3 changed files with 111 additions and 32 deletions

View File

@ -175,7 +175,7 @@ namespace FrontendWebApi.ApiControllers
try
{
var sqlString = $@"select floor_tag, full_name from floor where deleted = 0 and building_tag = @building_tag and full_name = ifnull(@floor_tag, full_name)";
var sqlString = $@"select floor_tag, full_name, InitMapName as map_name, floor_map_name + '.svg' as floor_map_name from floor where deleted = 0 and building_tag = @building_tag and full_name = ifnull(@floor_tag, full_name)";
var param = new { @building_tag = fd.building_tag, @floor_tag = fd.floor_tag };
var fl = await backendRepository.GetAllAsync<FloorList>(sqlString, param);
@ -200,41 +200,67 @@ namespace FrontendWebApi.ApiControllers
return Ok(apiResult);
}
/// <summary>
/// 獲取設備資料
/// </summary>
/// <param name="fd"></param>
/// <returns></returns>
[HttpPost]
[Route("api/Device/GetOneDevice")]
public async Task<ActionResult<ApiResult<Device>>> GetOneDevice(string device_number)
[Route("api/Device/GetBaseDevice")]
public async Task<ActionResult<ApiResult<DeviceBaseInfo>>> GetBaseDevice([FromBody] FindDevice fd)
{
ApiResult<Device> apiResult = new ApiResult<Device>(jwt_str);
if (!jwtlife)
{
apiResult.Code = "5000";
return BadRequest(apiResult);
}
ApiResult<DeviceBaseInfo> apiResult = new ApiResult<DeviceBaseInfo>();
try
{
string sql = $@"SELECT
d.*,
d.full_name AS Device_full_name,
b.full_name AS Building_full_name,
ms.full_name AS Main_system_full_name,
ss.full_name AS Sub_system_full_name,
f.full_name AS Floor_full_name
FROM (
SELECT *
FROM device d
WHERE
d.device_number = @Device_number
AND d.deleted = @Deleted
) d
JOIN building b ON d.building_guid = b.building_guid
JOIN main_system ms ON d.main_system_guid = ms.main_system_guid
JOIN sub_system ss ON d.sub_system_guid = ss.sub_system_guid
JOIN floor f ON d.floor_guid = f.floor_guid
";
string sql = $@"select device_number, full_name, device_coordinate, device_coordinate_3d from device where deleted = 0 and device_guid = @device_guid";
object param = new { @device_guid = fd.device_guid };
var device = await backendRepository.GetOneAsync<DeviceBaseInfo>(sql, param);
object param = new { Deleted = 0, Device_number = device_number };
if(device == null)
{
apiResult.Msg = "查無次設備";
apiResult.Code = "0001";
return apiResult;
}
var device = await backendRepository.GetOneAsync<Device>(sql, param);
apiResult.Data = device;
apiResult.Code = "0000";
}
catch (Exception exception)
{
apiResult.Code = "9999";
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
return Ok(apiResult);
}
return Ok(apiResult);
}
/// <summary>
/// 獲取設備運維資料
/// </summary>
/// <param name="fd"></param>
/// <returns></returns>
[HttpPost]
[Route("api/Device/GetOpeDevice")]
public async Task<ActionResult<ApiResult<List<DeviceOpeRecord>>>> GetOpeDevice([FromBody] FindDevice fd)
{
ApiResult<List<DeviceOpeRecord>> apiResult = new ApiResult<List<DeviceOpeRecord>>();
try
{
string sql = $@"select orr.work_type, orr.fix_do, ui.full_name as work_person_name, finish_time, created_at
from device d
join operation_record orr on d.device_number = orr.fix_do_code and orr.deleted = 0
left join userinfo ui on orr.work_person_id = ui.userinfo_guid
where d.deleted = 0 and d.device_guid = @device_guid";
object param = new { @device_guid = fd.device_guid };
var device = await backendRepository.GetAllAsync<DeviceOpeRecord>(sql, param);
if (device.Count == 0)
{
apiResult.Msg = "查無次設備";
apiResult.Code = "0001";
return apiResult;
}
apiResult.Data = device;
apiResult.Code = "0000";

View File

@ -1021,7 +1021,7 @@ namespace FrontendWebApi.ApiControllers
sqlString = $@"select formId from operation_record where convert(created_at, DATE) = convert(NOW(), DATE) order by id desc limit 1";
var formId = await backendRepository.GetOneAsync<string>(sqlString);
formId = formId != null ? "op" + DateTime.Now.ToString("yyyyMMdd") + (Int32.Parse(formId.Substring(10)) + 1) : "op" + DateTime.Now.ToString("yyyyMMdd") + "001";
formId = formId != null ? "op" + DateTime.Now.ToString("yyyyMMdd") + (Int32.Parse(formId.Substring(10)) + 1).ToString().PadLeft(3, '0') : "op" + DateTime.Now.ToString("yyyyMMdd") + "001";
if (ori == null) //create
{
@ -1036,6 +1036,7 @@ namespace FrontendWebApi.ApiControllers
{ "@device_system_category_layer3", or.device_system_category_layer3},
{ "@work_type", or.work_type},
{ "@error_code", or.work_type == 2 ? new_guid.ToString() : null},
{ "@fix_do", or.fix_do},
{ "@fix_do_code", or.fix_do_code },
{ "@fix_firm", or.fix_firm},
{ "@status", or.status},
@ -1096,6 +1097,7 @@ namespace FrontendWebApi.ApiControllers
{ "@location_code", or.location_code},
{ "@device_system_category_layer2", or.device_system_category_layer2},
{ "@device_system_category_layer3", or.device_system_category_layer3},
{ "@fix_do", or.fix_do},
{ "@fix_do_code", or.fix_do_code },
{ "@fix_firm", or.fix_firm},
{ "@status", or.status},

View File

@ -1,4 +1,6 @@
using System.Collections.Generic;
using iTextSharp.xmp.impl;
using System;
using System.Collections.Generic;
namespace FrontendWebApi.Models
{
@ -7,6 +9,7 @@ namespace FrontendWebApi.Models
public string main_system_tag { get; set; }
public string building_tag { get; set; }
public string floor_tag { get; set; }
public string device_guid { get; set; }
}
public class BuildList
@ -19,6 +22,8 @@ namespace FrontendWebApi.Models
{
public string full_name { get; set; }
public string floor_tag { get; set; }
public string map_name { get; set; }
public string floor_map_name { get; set; }
public List<DeviceLists> device_list {get; set;}
}
@ -27,6 +32,7 @@ namespace FrontendWebApi.Models
public string device_guid { get; set; }
public string full_name { get; set; }
public string device_coordinate { get; set; }
public string device_coordinate_3d { get; set; }
public string status { get; set; }
public string device_status
{
@ -42,4 +48,49 @@ namespace FrontendWebApi.Models
}
}
}
public class DeviceBaseInfo
{
public string device_number { get; set; }
public string device_coordinate { get; set; }
public string device_coordinate_3d { get; set; }
public string full_name { get; set; }
public string device_ip { get; set; }
}
public class DeviceOpeRecord
{
public string fix_do { get; set; }
public byte work_type { get; set; }
public string work_type_name
{
get
{
Dictionary<byte, string> name = new Dictionary<byte, string>()
{
{ 1 , "保養" },
{ 2 , "維修" }
};
return name[work_type];
}
}
public string work_person_name { get; set; }
public DateTime finish_time { get; set; }
public DateTime created_at { get; set; }
public string Created_at
{
get
{
return Convert.ToDateTime(created_at).ToString("yyyy-MM-dd HH:mm:ss");
}
} //創建時間
public string Finish_time
{
get
{
return Convert.ToDateTime(finish_time).ToString("yyyy-MM-dd HH:mm:ss");
}
} //結束時間
}
}