From 7c4b695b7365e819c661ef3284821b956c2160ae Mon Sep 17 00:00:00 2001 From: "mjmUser\\mjmTech" Date: Fri, 24 Feb 2023 14:16:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=A6=96=E9=A0=81=E5=B7=A5?= =?UTF-8?q?=E5=96=AE,=E5=B7=B2=E5=AE=8C=E6=88=90=E3=80=81=E6=9C=AA?= =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=95=B8=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApiControllers/OperationController.cs | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/FrontendWebApi/ApiControllers/OperationController.cs b/FrontendWebApi/ApiControllers/OperationController.cs index f62c885..58e07a2 100644 --- a/FrontendWebApi/ApiControllers/OperationController.cs +++ b/FrontendWebApi/ApiControllers/OperationController.cs @@ -1020,6 +1020,67 @@ namespace FrontendWebApi.ApiControllers #endregion #region 維修/保養 + + /// + /// 維修/保養 列表(work_type) + /// + /// + /// + public async Task> OpeRecListAllTime([FromBody] OperationFindList ofl) + { + ApiResult apiResult = new ApiResult(); + List orl = new List(); + string sWhere = ""; + try + { + if (ofl.work_type != 1 && ofl.work_type != 2) + { + apiResult.Code = "0001"; + apiResult.Msg = "無此項目類別"; + return apiResult; + } + + + + + if (ofl.serial_number != null) + { + sWhere += $@" and opr.formId like '%{ofl.serial_number}%'"; + } + var sqlString = $@"select distinct(error_code) ,opr.status, concat(d.device_floor_tag, ' ', d.full_name) as device_name, ui.full_name as user_full_name + from operation_record opr + left join device d on opr.fix_do_code = d.device_number and d.deleted = 0 and d.device_area_tag = SUBSTRING_INDEX(opr.fix_do_code, '_', 1) + and d.device_building_tag = SUBSTRING_INDEX(SUBSTRING_INDEX(fix_do_code, '_', 2), '_', -1) + and d.device_floor_tag = SUBSTRING_INDEX(SUBSTRING_INDEX(fix_do_code, '_', 5), '_', -1) + and d.device_system_tag = opr.device_system_category_layer2 and d.device_name_tag = opr.device_system_category_layer3 + left join userinfo ui on opr.work_person_id = ui.userinfo_guid and ui.deleted = 0 + where opr.deleted = 0 and opr.work_type = 2" + sWhere; + + + + orl = await backendRepository.GetAllAsync(sqlString); + int Finished = orl.Where(x => x.status_name == "完成").Count(); + int NotFinished = orl.Where(x => x.status_name == "未完成").Count(); + + object Status = new {finish= Finished, notfinish= NotFinished }; + apiResult.Code = "0000"; + apiResult.Data = Status; + } + catch (Exception exception) + { + apiResult.Code = "9999"; + apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; + string json = System.Text.Json.JsonSerializer.Serialize(ofl); + Logger.LogError("【" + controllerName + "/" + actionName + "】" + json); + Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + } + + return apiResult; + } + + + + /// /// 維修/保養 列表(work_type) ///