修改系統列表

This commit is contained in:
dev02 2022-11-18 17:40:43 +08:00
parent 46e7515d44
commit c779fd32f3
2 changed files with 21 additions and 3 deletions

View File

@ -42,7 +42,7 @@ namespace FrontendWebApi.ApiControllers
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
[Route("api/Device/GetMainSub")] [Route("api/Device/GetMainSub")]
public async Task<ActionResult<ApiResult<History_MainSubBuildFloor>>> GetMainSub() public async Task<ActionResult<ApiResult<History_MainSubBuildFloor>>> GetMainSub([FromBody] FindDevice fd)
{ {
ApiResult<History_MainSubBuildFloor> apiResult = new ApiResult<History_MainSubBuildFloor>(jwt_str); ApiResult<History_MainSubBuildFloor> apiResult = new ApiResult<History_MainSubBuildFloor>(jwt_str);
if (!jwtlife) if (!jwtlife)
@ -50,17 +50,26 @@ namespace FrontendWebApi.ApiControllers
apiResult.Code = "5000"; apiResult.Code = "5000";
return BadRequest(apiResult); return BadRequest(apiResult);
} }
else if (string.IsNullOrEmpty(fd.building_tag))
{
apiResult.Code = "0002";
apiResult.Msg = "必須選擇東別";
return apiResult;
}
try try
{ {
var dbsub = await frontendRepository.GetAllAsync<HistoryDBMainSub>( var dbsub = await frontendRepository.GetAllAsync<HistoryDBMainSub>(
@$"select distinct v1.system_key main_name, v1.system_value main_system_tag, v2.system_key sub_name, v2.system_value sub_system_tag, v1.system_priority, v2.system_priority @$"select distinct v1.system_key main_name, v1.system_value main_system_tag, v2.system_key sub_name, v2.system_value sub_system_tag, v1.system_priority, v2.system_priority,
dk.device_normal_color, dk.device_error_color, dk.device_error_color
from role_auth a from role_auth a
join auth_page b on a.AuthCode = b.AuthCode join auth_page b on a.AuthCode = b.AuthCode
join userinfo c on c.role_guid = a.role_guid join userinfo c on c.role_guid = a.role_guid
join variable v2 on b.ShowView = v2.id and v2.system_type = @sub_system_type join variable v2 on b.ShowView = v2.id and v2.system_type = @sub_system_type
join variable v1 on v1.id = v2.system_parent_id and v1.system_type = @main_system_type join variable v1 on v1.id = v2.system_parent_id and v1.system_type = @main_system_type
left join device_kind dk on v1.system_value = dk.device_system_tag and v2.system_value = dk.device_name_tag and dk.device_building_tag = @building_tag
where c.account = @account where c.account = @account
order by v1.system_priority, v2.system_priority", new { @account = myUser.account, @sub_system_type = sub_system_type, @main_system_type = main_system_type }); order by v1.system_priority, v2.system_priority", new { @account = myUser.account, @sub_system_type = sub_system_type, @main_system_type = main_system_type, @building_tag = fd.building_tag });
var mains = dbsub.GroupBy(a => a.main_system_tag).ToList(); var mains = dbsub.GroupBy(a => a.main_system_tag).ToList();
apiResult.Data = new History_MainSubBuildFloor(); apiResult.Data = new History_MainSubBuildFloor();
apiResult.Data.history_Main_Systems = new List<History_Main_system>(); apiResult.Data.history_Main_Systems = new List<History_Main_system>();
@ -78,6 +87,9 @@ namespace FrontendWebApi.ApiControllers
History_Sub_system history_Sub_System = new History_Sub_system(); History_Sub_system history_Sub_System = new History_Sub_system();
history_Sub_System.sub_system_tag = sub.sub_system_tag; history_Sub_System.sub_system_tag = sub.sub_system_tag;
history_Sub_System.full_name = sub.sub_name; history_Sub_System.full_name = sub.sub_name;
history_Sub_System.device_normal_color = sub.device_normal_color;
history_Sub_System.device_close_color = sub.device_close_color;
history_Sub_System.device_error_color = sub.device_error_color;
history_Main_System.History_Sub_systems.Add(history_Sub_System); history_Main_System.History_Sub_systems.Add(history_Sub_System);
} }

View File

@ -59,6 +59,9 @@ namespace FrontendWebApi.Models
public string main_name { get; set; } public string main_name { get; set; }
public string sub_system_tag { get; set; } public string sub_system_tag { get; set; }
public string sub_name { get; set; } public string sub_name { get; set; }
public string device_normal_color { get; set; }
public string device_close_color { get; set; }
public string device_error_color { get; set; }
} }
public class BuildingFloorRawData public class BuildingFloorRawData
@ -96,6 +99,9 @@ namespace FrontendWebApi.Models
{ {
public string sub_system_tag { get; set; } public string sub_system_tag { get; set; }
public string full_name { get; set; } public string full_name { get; set; }
public string device_normal_color { get; set; }
public string device_close_color { get; set; }
public string device_error_color { get; set; }
} }
public class History_PostDevice public class History_PostDevice
{ {