| | |
| | | import org.jeecg.common.system.vo.LoginUser; |
| | | import org.jeecg.common.util.oConvertUtils; |
| | | import org.jeecg.modules.eam.entity.*; |
| | | import org.jeecg.modules.eam.mapper.RepairOrderMapper; |
| | | import org.jeecg.modules.eam.service.*; |
| | | import org.jeecg.modules.eam.vo.EquipmentAvailabilityVo; |
| | | import org.jeecg.modules.eam.vo.RepairReportExportVo; |
| | | import org.jeecg.modules.system.entity.SysUser; |
| | | import org.jeecg.modules.system.mapper.SysUserMapper; |
| | | import org.jeecgframework.poi.excel.ExcelImportUtil; |
| | | import org.jeecgframework.poi.excel.def.NormalExcelConstants; |
| | | import org.jeecgframework.poi.excel.entity.ExportParams; |
| | | import org.jeecgframework.poi.excel.entity.ImportParams; |
| | | import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | @Autowired |
| | | @Lazy |
| | | private IdentityService sysIdentityService; |
| | | @Autowired |
| | | private RepairOrderMapper repairOrderMapper; |
| | | @Autowired |
| | | private SysUserMapper sysUserMapper; |
| | | @Value("${jeecg.path.upload}") |
| | | private String upLoadPath; |
| | | |
| | | |
| | | |
| | |
| | | HttpServletRequest req) { |
| | | Page<RepairOrder> page = new Page<RepairOrder>(pageNo, pageSize); |
| | | IPage<RepairOrder> pageList = repairOrderService.getRepairOrderList(page, repairOrder); |
| | | List<RepairOrder> records = pageList.getRecords(); |
| | | for (RepairOrder record : records) { |
| | | record.setFaultCauseCount("故障原因统计"); |
| | | List<Map<String, Object>> allFaultCause = repairOrderService.getAllFaultCause(); |
| | | record.setAllFaultCause(allFaultCause); |
| | | |
| | | String equipmentId = record.getEquipmentId(); |
| | | List<Map<String, Object>> faultCause = repairOrderService.getFaultCause(equipmentId); |
| | | record.setEquipmentFaultCause(faultCause); |
| | | } |
| | | // for(RepairOrder repairOrder1 : pageList.getRecords()){ |
| | | // if(StringUtils.isNotBlank(repairOrder1.getReportRepairId())){ |
| | | // EquipmentReportRepair equipmentReportRepair = equipmentReportRepairService.getById(repairOrder1.getReportRepairId()); |
| | |
| | | return Result.OK("批量删除成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 导出 |
| | | * @return |
| | | */ |
| | | //@RequiresPermissions("org.jeecg.modules.demo:mom_eam_repair_order:exportXls") |
| | | @RequestMapping(value = "/exportXls") |
| | | public ModelAndView exportXls(HttpServletRequest request, RepairOrder repairOrder) { |
| | | return super.exportXls(request, repairOrder, RepairOrder.class, "维修工单"); |
| | | } |
| | | @RequestMapping(value = "/exportXls") |
| | | public ModelAndView exportXls(HttpServletRequest request, RepairOrder repairOrder) { |
| | | // Step.1 组装查询条件 |
| | | String title = "维修履历"; |
| | | LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | // Step.2 获取导出数据 |
| | | if(StringUtils.isNotBlank(repairOrder.getUserId())){ |
| | | SysUser user = sysUserMapper.selectById(repairOrder.getUserId()); |
| | | repairOrder.setTeamId(user.getTeamId()); |
| | | }else{ |
| | | repairOrder.setTeamId(""); |
| | | } |
| | | List<String> equipNums = new ArrayList<>(); |
| | | if(StringUtils.isNotBlank(repairOrder.getNums())){ |
| | | equipNums = Arrays.asList(repairOrder.getNums().trim().split("\n")).stream().filter(num->!num.equals("\n")).collect(Collectors.toList()); |
| | | } |
| | | List<RepairOrder> exportList = repairOrderMapper.getRepairOrderList(null,repairOrder.getId(), |
| | | repairOrder.getNum(), |
| | | repairOrder.getEquipmentNum(), |
| | | repairOrder.getEquipmentName(), |
| | | repairOrder.getStatus(), |
| | | repairOrder.getRepairOrderType(), |
| | | repairOrder.getEquipmentCategoryId(), |
| | | repairOrder.getFactoryModelId(), |
| | | repairOrder.getSpecificEquipment(), |
| | | repairOrder.getTeamId(), |
| | | equipNums, |
| | | repairOrder.getRepairOrderUda1(), |
| | | repairOrder.getFaultStartTime(), |
| | | repairOrder.getFaultEndTime(), |
| | | repairOrder.getCreateStartTime(), |
| | | repairOrder.getCreateEndTime(), |
| | | repairOrder.getEquipmentImportanceId(), |
| | | repairOrder.getFaultCause()); |
| | | |
| | | // Step.3 AutoPoi 导出Excel |
| | | ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); |
| | | //此处设置的filename无效 ,前端会重更新设置一下 |
| | | mv.addObject(NormalExcelConstants.FILE_NAME, title); |
| | | mv.addObject(NormalExcelConstants.CLASS, RepairOrder.class); |
| | | //update-begin--Author:liusq Date:20210126 for:图片导出报错,ImageBasePath未设置-------------------- |
| | | ExportParams exportParams=new ExportParams(title + "报表", "导出人:" + sysUser.getRealname(), title); |
| | | exportParams.setImageBasePath(upLoadPath); |
| | | //update-end--Author:liusq Date:20210126 for:图片导出报错,ImageBasePath未设置---------------------- |
| | | mv.addObject(NormalExcelConstants.PARAMS,exportParams); |
| | | mv.addObject(NormalExcelConstants.DATA_LIST, exportList); |
| | | return mv; |
| | | } |
| | | |
| | | /** |
| | | * 导入 |
| | |
| | | @PutMapping(value = "/report") |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | | public Result<?> orderReport(@RequestBody RepairOrder repairOrder){ |
| | | String id = repairOrder.getId(); |
| | | List<RepairOrderActualWorkHours> hoursList = repairOrderActualWorkHoursService.list(new QueryWrapper<RepairOrderActualWorkHours>().eq("repair_order_id",id).eq("del_flag",0)); |
| | | List<RepairOrderActualWorkHours> mainStuff = repairOrderActualWorkHoursService.list(new QueryWrapper<RepairOrderActualWorkHours>().eq("repair_order_id",id).eq("del_flag",0).eq("principal_contractor","1")); |
| | | if(hoursList.size()<2){ |
| | | return Result.error("操作失败,请至少添加两个承修人,并且设置一个主承修人"); |
| | | } |
| | | if(mainStuff.size()!=1){ |
| | | return Result.error("操作失败,请设置主承修人,有且只有一个"); |
| | | } |
| | | if(StringUtils.isNotBlank(repairOrder.getProjectMaintenanceOrderId())){ |
| | | //判断项目性维修子表状态 |
| | | ProjectMaintenanceOrderDetail projectMaintenanceOrderDetail = projectMaintenanceOrderDetailService.getById(repairOrder.getProjectMaintenanceOrderId()); |
| | |
| | | repairOrder.setStatus("4"); |
| | | repairOrder.setActualEndTime(now); |
| | | repairOrder.setActualHour(hours); |
| | | repairOrder.setRecipientUserId(user.getId()); |
| | | repairOrder.setRecipientUserId(mainStuff.get(0).getUserId()); |
| | | repairOrderService.updateById(repairOrder); |
| | | if(StringUtils.isNotBlank(repairOrder.getEquipmentId())){ |
| | | Equipment equipment = equipmentService.getById(repairOrder.getEquipmentId()); |
| | |
| | | jsonObject.put("data",list); |
| | | return jsonObject; |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 设备维修柱状图 |
| | | * qsw 2024-7-11 |
| | | */ |
| | | @GetMapping("getFaultCausePie") |
| | | public Result<?> getFaultCausePie(@RequestParam Map<String, Object> params) { |
| | | List<Map<String, Object>> faultCausePie = repairOrderService.getFaultCausePie(params); |
| | | return Result.ok(faultCausePie); |
| | | } |
| | | |
| | | /** |
| | | * 设备维修扇形图 |
| | | * qsw 2024-7-11 |
| | | */ |
| | | @GetMapping("getFaultCauseBar") |
| | | public Result<?> getFaultCauseBar(@RequestParam Map<String, Object> params) { |
| | | List<Map<String, Object>> faultCauseBar = repairOrderService.getFaultCauseBar(params); |
| | | return Result.ok(faultCauseBar); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * MTPF |
| | | * qsw 2024-7-11 |
| | | */ |
| | | @GetMapping("getMTPF") |
| | | public Result<?> getMTPF(@RequestParam("pageNo") Integer pageNo, |
| | | @RequestParam("pageSize") Integer pageSize, |
| | | @RequestParam Map<String, Object> params) { |
| | | IPage<Map<String, Object>> mtpf = repairOrderService.getMTPF(pageNo, pageSize, params); |
| | | return Result.ok(mtpf); |
| | | } |
| | | |
| | | } |