/// <summary> /// 工单查询 /// </summary> /// <param name="request"></param> /// <returns></returns> public async Task <List <MaintenanceInfoResponse> > GetListAsync(MaintenanceInfoSearchRequest request) { var myRequest = Mapper.Map <MaintenanceInfoPageRequest>(request); var result = await this.GetPageListAsync(myRequest); return(result?.Items); }
public async Task <IActionResult> ExportMaintenances(MaintenanceInfoSearchRequest request) { _logger.Info(new LogInfo() { Method = nameof(ExportMaintenances), Argument = new { request }, Description = "导出工单数据" }); //获取库存详情 var result = await this._MaintenanceInfoService.GetListAsync(request); List <string> menus = new List <string>() { "工单单号", "创建时间", "工单类型", "客户名称", "客户地址", "当前状态", "服务商" }; var stream = ExportWithOneTier(nameof(ExportMaintenances), menus, result, (item, i) => { string value = string.Empty; switch (i) { case 0: value = item.Numbers; break; case 1: value = item.CreationTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); break; case 2: value = item.MaintenancTypeName; break; case 3: value = item.UserName; break; case 4: value = item.UserProvince + item.UserCity + item.UserCounty + item.UserAddress; break; case 5: value = item.MaintenancStatusName; break; case 6: value = item.ServiceBusiness?.ServiceBusinessName; break; } return(value); }); return(File(stream, "application/ms-excel;charset=UTF-8")); }
private Tuple <string, DynamicParameters> GetWhere(MaintenanceInfoSearchRequest request, DynamicParameters parameters) { StringBuilder sbWhere = new StringBuilder(); //判断是否根据Id查询 if (request.Id.HasValue) { sbWhere.Append(" AND m.Id = @Id "); parameters.Add("@Id", request.Id.Value); } if (request.RoleId.HasValue) { var roleId = request.RoleId; //不同角色获取不同tab菜单的工单数据 if (request.MaintenancType.HasValue) { var maintenancType = request.MaintenancType.Value; List <int> maintenancStatusList = new List <int>(); //客户 if (roleId == 1) { //获取自己下的工单 if (request.UserId.HasValue) { sbWhere.Append(" AND m.UserId = @UserId "); parameters.Add("@UserId", request.UserId.Value); } #region 工单状态 //三种状态 //待受理 if (maintenancType == (int)EMaintenancTabType.ToBeAccepted) { maintenancStatusList.Add((int)EMaintenancStatus.UnAssign); maintenancStatusList.Add((int)EMaintenancStatus.Assigned); maintenancStatusList.Add((int)EMaintenancStatus.Received); sbWhere.Append(" AND m.MaintenancStatus IN (@MaintenancStatus) "); parameters.Add("@MaintenancStatus", maintenancStatusList); } //受理中 else if (maintenancType == (int)EMaintenancTabType.Acceptance) { maintenancStatusList.Add((int)EMaintenancStatus.AssignRP); maintenancStatusList.Add((int)EMaintenancStatus.Accepting); sbWhere.Append(" AND m.MaintenancStatus IN (@MaintenancStatus) "); parameters.Add("@MaintenancStatus", maintenancStatusList); } //已关闭 else if (maintenancType == (int)EMaintenancTabType.Closed) { maintenancStatusList.Add((int)EMaintenancStatus.Complete); maintenancStatusList.Add((int)EMaintenancStatus.Closed); sbWhere.Append(" AND m.MaintenancStatus IN (@MaintenancStatus) "); parameters.Add("@MaintenancStatus", maintenancStatusList); } else { maintenancStatusList.Add((int)EMaintenancStatus.UnAssign); maintenancStatusList.Add((int)EMaintenancStatus.Assigned); maintenancStatusList.Add((int)EMaintenancStatus.Received); maintenancStatusList.Add((int)EMaintenancStatus.AssignRP); maintenancStatusList.Add((int)EMaintenancStatus.Accepting); maintenancStatusList.Add((int)EMaintenancStatus.Complete); maintenancStatusList.Add((int)EMaintenancStatus.Closed); sbWhere.Append(" AND m.MaintenancStatus IN (@MaintenancStatus) "); parameters.Add("@MaintenancStatus", maintenancStatusList); } #endregion } //服务商 else if (roleId == 2) { //指定为本服务商的工单 if (request.RepairId.HasValue) { sbWhere.Append(" AND m.RepairId = @RepairId "); parameters.Add("@RepairId", request.RepairId.Value); } #region 工单状态 //待受理 if (maintenancType == (int)EMaintenancTabType.ToBeAccepted) { maintenancStatusList.Add((int)EMaintenancStatus.Assigned); maintenancStatusList.Add((int)EMaintenancStatus.Received); sbWhere.Append(" AND m.MaintenancStatus IN (@MaintenancStatus) "); parameters.Add("@MaintenancStatus", maintenancStatusList); } //已受理 else if (maintenancType == (int)EMaintenancTabType.Accepted) { maintenancStatusList.Add((int)EMaintenancStatus.AssignRP); sbWhere.Append(" AND m.MaintenancStatus IN (@MaintenancStatus) "); parameters.Add("@MaintenancStatus", maintenancStatusList); } //受理中 else if (maintenancType == (int)EMaintenancTabType.Acceptance) { maintenancStatusList.Add((int)EMaintenancStatus.Accepting); sbWhere.Append(" AND m.MaintenancStatus IN (@MaintenancStatus) "); parameters.Add("@MaintenancStatus", maintenancStatusList); } //已关闭 else if (maintenancType == (int)EMaintenancTabType.Closed) { maintenancStatusList.Add((int)EMaintenancStatus.Complete); maintenancStatusList.Add((int)EMaintenancStatus.Closed); sbWhere.Append(" AND m.MaintenancStatus IN (@MaintenancStatus) "); parameters.Add("@MaintenancStatus", maintenancStatusList); } else { maintenancStatusList.Add((int)EMaintenancStatus.Assigned); maintenancStatusList.Add((int)EMaintenancStatus.Received); maintenancStatusList.Add((int)EMaintenancStatus.AssignRP); maintenancStatusList.Add((int)EMaintenancStatus.Accepting); maintenancStatusList.Add((int)EMaintenancStatus.Complete); maintenancStatusList.Add((int)EMaintenancStatus.Closed); sbWhere.Append(" AND m.MaintenancStatus IN (@MaintenancStatus) "); parameters.Add("@MaintenancStatus", maintenancStatusList); } #endregion } //维修员 else if (roleId == 3) { //指派给某一个维修员的工单 if (request.RepairManId.HasValue) { sbWhere.Append(" AND m.RepairmanId = @RepairmanId "); parameters.Add("@RepairmanId", request.RepairManId.Value); } #region 工单状态 //已受理 if (maintenancType == (int)EMaintenancTabType.Accepted) { maintenancStatusList.Add((int)EMaintenancStatus.AssignRP); sbWhere.Append(" AND m.MaintenancStatus IN (@MaintenancStatus) "); parameters.Add("@MaintenancStatus", maintenancStatusList); } //受理中 else if (maintenancType == (int)EMaintenancTabType.Acceptance) { maintenancStatusList.Add((int)EMaintenancStatus.Accepting); sbWhere.Append(" AND m.MaintenancStatus IN (@MaintenancStatus) "); parameters.Add("@MaintenancStatus", maintenancStatusList); } //已关闭 else if (maintenancType == (int)EMaintenancTabType.Closed) { maintenancStatusList.Add((int)EMaintenancStatus.Complete); maintenancStatusList.Add((int)EMaintenancStatus.Closed); sbWhere.Append(" AND m.MaintenancStatus IN (@MaintenancStatus) "); parameters.Add("@MaintenancStatus", maintenancStatusList); } else { maintenancStatusList.Add((int)EMaintenancStatus.AssignRP); maintenancStatusList.Add((int)EMaintenancStatus.Accepting); maintenancStatusList.Add((int)EMaintenancStatus.Complete); maintenancStatusList.Add((int)EMaintenancStatus.Closed); sbWhere.Append(" AND m.MaintenancStatus IN (@MaintenancStatus) "); parameters.Add("@MaintenancStatus", maintenancStatusList); } #endregion } } } return(new Tuple <string, DynamicParameters>(sbWhere.ToString(), parameters)); }