| | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alibaba.fastjson.parser.Feature; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.common.constant.CommonConstant; |
| | | import org.jeecg.common.system.vo.LoginUser; |
| | | import org.jeecg.common.util.DateUtils; |
| | | import org.jeecg.common.util.TranslateDictTextUtils; |
| | | import org.jeecg.modules.eam.constant.EquipmentMaintenanceStatus; |
| | | import org.jeecg.modules.eam.constant.EquipmentRepairStatus; |
| | | import org.jeecg.modules.eam.entity.EamEquipment; |
| | | import org.jeecg.modules.eam.service.IEamEquipmentService; |
| | | import org.jeecg.modules.eam.service.IEamInspectionOrderService; |
| | | import org.jeecg.modules.eam.service.IEamReportRepairService; |
| | | import org.jeecg.modules.eam.service.IEamWeekMaintenanceOrderService; |
| | | import org.jeecg.modules.eam.constant.*; |
| | | import org.jeecg.modules.eam.entity.*; |
| | | import org.jeecg.modules.eam.request.EamInspectionOrderQuery; |
| | | import org.jeecg.modules.eam.request.EamReportRepairQuery; |
| | | import org.jeecg.modules.eam.request.EamWeekMaintenanceQuery; |
| | | import org.jeecg.modules.eam.service.*; |
| | | import org.jeecg.modules.eam.vo.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | |
| | | private IEamWeekMaintenanceOrderService weekMaintenanceOrderService; |
| | | @Resource |
| | | private ObjectMapper objectMapper; |
| | | |
| | | @Resource |
| | | private TranslateDictTextUtils translateDictTextUtils; |
| | | @Autowired |
| | | private IEamRepairOrderService repairOrderService; |
| | | |
| | | |
| | | @ApiOperation(value = "看板接口-维保状态统计", notes = "看板接口-维保状态统计") |
| | | @GetMapping(value = "/equipmentStatusStatistics") |
| | |
| | | @GetMapping(value = "/repairList") |
| | | public Result<?> repairList() { |
| | | List<EquipmentRepairListVO> list = reportRepairService.repairList(); |
| | | if(CollectionUtil.isEmpty(list)) { |
| | | if (CollectionUtil.isEmpty(list)) { |
| | | return Result.ok(Collections.emptyList()); |
| | | } |
| | | List<JSONObject> items = new ArrayList<>(); |
| | | try { |
| | | for(EquipmentRepairListVO vo : list) { |
| | | for (EquipmentRepairListVO vo : list) { |
| | | String json = objectMapper.writeValueAsString(vo); |
| | | JSONObject item = JSONObject.parseObject(json, Feature.OrderedField); |
| | | translateDictTextUtils.translateField("reportOperator", vo.getReportOperator(), item, "sys_user,realname,username"); |
| | |
| | | items.add(item); |
| | | } |
| | | return Result.OK(items); |
| | | }catch (Exception e) { |
| | | } catch (Exception e) { |
| | | return Result.error("数据转译失败!"); |
| | | } |
| | | } |
| | |
| | | @ApiOperation(value = "维修看板-维修工排名", notes = "维修看板-维修工排名") |
| | | @GetMapping(value = "/repairmanRanking") |
| | | public Result<?> repairmanRanking() { |
| | | return null; |
| | | LocalDate today = LocalDate.now(); |
| | | LocalDate end = today.plusDays(1); |
| | | LocalDate start = today.minusDays(30); |
| | | //只取前7名 |
| | | List<RepairmanRankingVO> list = repairOrderService.repairmanRanking(start.toString(), end.toString()); |
| | | if (CollectionUtil.isEmpty(list)) { |
| | | return Result.ok(Collections.emptyList()); |
| | | } |
| | | if (list.size() > 7) { |
| | | list = list.subList(0, 7); |
| | | } |
| | | List<JSONObject> items = new ArrayList<>(); |
| | | try { |
| | | for (RepairmanRankingVO vo : list) { |
| | | String json = objectMapper.writeValueAsString(vo); |
| | | JSONObject item = JSONObject.parseObject(json, Feature.OrderedField); |
| | | translateDictTextUtils.translateField("repairer", vo.getRepairer(), item, "sys_user,realname,username"); |
| | | items.add(item); |
| | | } |
| | | return Result.OK(items); |
| | | } catch (Exception e) { |
| | | return Result.error("数据转译失败!"); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "维修看板-故障类型统计", notes = "维修看板-故障类型统计") |
| | | @GetMapping(value = "/faultTypeStatistics") |
| | | public Result<?> faultTypeStatistics() { |
| | | //统计今年来故障分类情况 |
| | | LocalDate today = LocalDate.now(); |
| | | LocalDate end = today.plusDays(1); |
| | | //今年第一天 |
| | | LocalDate start = today.withDayOfYear(1); |
| | | // 统计个数 |
| | | List<FaultTypeStatisticsVO> list = reportRepairService.faultTypeStatistics(start.toString(), end.toString()); |
| | | if (CollectionUtil.isEmpty(list)) { |
| | | return Result.ok(Collections.emptyList()); |
| | | } |
| | | List<JSONObject> items = new ArrayList<>(); |
| | | try { |
| | | for (FaultTypeStatisticsVO vo : list) { |
| | | String json = objectMapper.writeValueAsString(vo); |
| | | JSONObject item = JSONObject.parseObject(json, Feature.OrderedField); |
| | | translateDictTextUtils.translateField("faultType", vo.getFaultType(), item, "fault_reason_category"); |
| | | if (item.get("faultType" + CommonConstant.DICT_TEXT_SUFFIX) != null) { |
| | | items.add(item); |
| | | } |
| | | } |
| | | return Result.OK(items); |
| | | } catch (Exception e) { |
| | | return Result.error("数据转译失败!"); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "H5首页-待执行工单数量统计", notes = "H5首页-待执行工单数量统计") |
| | | @GetMapping(value = "/pendingExecOrderCountBySelf") |
| | | public Result<?> pendingExecOrderCountBySelf() { |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | Map<String, Integer> countMap = CollectionUtil.newHashMap(); |
| | | if (user == null) { |
| | | return Result.ok(countMap); |
| | | } |
| | | String post = user.getPost(); |
| | | |
| | | if (BusinessCodeConst.PCR0001.equals(post)) { |
| | | //是操作工,查询可领取的点检、周保工单 |
| | | Page<EamInspectionOrder> inspectionOrderPage = new Page<>(1, 99999999); |
| | | EamInspectionOrderQuery inspectionOrderQuery = new EamInspectionOrderQuery(); |
| | | inspectionOrderQuery.setInspectionStatus(InspectionStatus.WAIT_INSPECTION.name()); |
| | | List<EamInspectionOrder> unReceivedInspectionOrderList = inspectionOrderService.queryPageList(inspectionOrderPage, inspectionOrderQuery).getRecords(); |
| | | |
| | | Page<EamWeekMaintenanceOrder> maintenanceOrderPage = new Page<>(1, 99999999); |
| | | EamWeekMaintenanceQuery weekMaintenanceQuery = new EamWeekMaintenanceQuery(); |
| | | weekMaintenanceQuery.setMaintenanceStatus(WeekMaintenanceStatusEnum.WAIT_MAINTENANCE.name()); |
| | | List<EamWeekMaintenanceOrder> unReceivedMaintenanceOrderList = weekMaintenanceOrderService.queryPageList(maintenanceOrderPage, weekMaintenanceQuery).getRecords(); |
| | | countMap.put("unExecInspectionOrderCount", unReceivedInspectionOrderList.size()); |
| | | countMap.put("unExecMaintenanceOrderCount", unReceivedMaintenanceOrderList.size()); |
| | | countMap.put("unExecRepairOrderCount", 0); |
| | | } else if (BusinessCodeConst.PCR0002.equals(post)) { |
| | | //是维修工,查询可领取的报修单 |
| | | Page<EamReportRepair> maintenanceOrderPage = new Page<>(1, 99999999); |
| | | EamReportRepairQuery reportRepairQuery = new EamReportRepairQuery(); |
| | | reportRepairQuery.setReportStatus(EquipmentRepairStatus.WAIT_REPAIR.name()); |
| | | List<EamReportRepair> unReceivedOrderList = reportRepairService.pageList(maintenanceOrderPage, reportRepairQuery).getRecords(); |
| | | |
| | | countMap.put("unExecInspectionOrderCount", 0); |
| | | countMap.put("unExecMaintenanceOrderCount", 0); |
| | | countMap.put("unExecRepairOrderCount", unReceivedOrderList.size()); |
| | | } else { |
| | | countMap.put("unExecInspectionOrderCount", 0); |
| | | countMap.put("unExecMaintenanceOrderCount", 0); |
| | | countMap.put("unExecRepairOrderCount", 0); |
| | | } |
| | | return Result.OK(countMap); |
| | | } |
| | | } |