新增首頁工單,已完成、未完成數量

This commit is contained in:
史萬澤 2023-02-24 14:16:03 +08:00
parent dc379c32fd
commit 7c4b695b73

View File

@ -1020,6 +1020,67 @@ namespace FrontendWebApi.ApiControllers
#endregion
#region /
/// <summary>
/// 維修/保養 列表(work_type)
/// </summary>
/// <param name="ofl"></param>
/// <returns></returns>
public async Task<ApiResult<object>> OpeRecListAllTime([FromBody] OperationFindList ofl)
{
ApiResult<object> apiResult = new ApiResult<object>();
List<Operation_Record> orl = new List<Operation_Record>();
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<Operation_Record>(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;
}
/// <summary>
/// 維修/保養 列表(work_type)
/// </summary>