From e5a85d904ce028a35229ab6245ab894afbca6531 Mon Sep 17 00:00:00 2001 From: lyh <925863403@qq.com> Date: 星期六, 26 七月 2025 17:07:30 +0800 Subject: [PATCH] 维修工单 --- lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcEquipmentController.java | 53 +++++++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 47 insertions(+), 6 deletions(-) diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcEquipmentController.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcEquipmentController.java index f0777d6..612a87e 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcEquipmentController.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcEquipmentController.java @@ -23,6 +23,9 @@ import org.jeecg.modules.mdc.vo.MdcEquipmentVo; import org.jeecg.modules.system.model.DepartIdModel; import org.jeecg.modules.system.model.ProductionIdModel; +import org.jeecgframework.poi.excel.def.NormalExcelConstants; +import org.jeecgframework.poi.excel.entity.ExportParams; +import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.ModelAndView; @@ -232,6 +235,7 @@ Result<MdcEquipment> result = new Result<>(); String selectedDeparts = mdcEquipment.getSelectedDeparts(); String selectedProduction = mdcEquipment.getSelectedProduction(); + mdcEquipment.setEquipmentStatus(CommonConstant.STATUS_NORMAL); try { mdcEquipmentService.saveMdcEquipment(mdcEquipment, selectedDeparts, selectedProduction); result.success("娣诲姞鎴愬姛锛�"); @@ -381,12 +385,12 @@ @AutoLog(value = "璁惧琛�-鍔犺浇閮ㄩ棬璁惧鏍�") @ApiOperation(value = "璁惧琛�-鍔犺浇閮ㄩ棬璁惧鏍�", notes = "璁惧琛�-鍔犺浇閮ㄩ棬璁惧鏍�") @GetMapping(value = "/queryTreeListByDepart") - public Result<List<MdcEquipmentTree>> queryTreeListByDepart() { + public Result<List<MdcEquipmentTree>> queryTreeListByDepart(@RequestParam(name = "key", required = false) String key) { Result<List<MdcEquipmentTree>> result = new Result<>(); LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); String userId = user.getId(); try { - List<MdcEquipmentTree> mdcEquipmentTreeList = mdcEquipmentService.loadTreeListByDepart(userId); + List<MdcEquipmentTree> mdcEquipmentTreeList = mdcEquipmentService.loadTreeListByDepart(userId, key); result.setSuccess(true); result.setResult(mdcEquipmentTreeList); } catch (Exception e) { @@ -401,12 +405,12 @@ @AutoLog(value = "璁惧琛�-鍔犺浇浜х嚎璁惧鏍�") @ApiOperation(value = "璁惧琛�-鍔犺浇浜х嚎璁惧鏍�", notes = "璁惧琛�-鍔犺浇浜х嚎璁惧鏍�") @GetMapping(value = "/queryTreeListByProduction") - public Result<List<MdcEquipmentTree>> queryTreeListByProduction() { + public Result<List<MdcEquipmentTree>> queryTreeListByProduction(@RequestParam(name = "key", required = false) String key) { Result<List<MdcEquipmentTree>> result = new Result<>(); LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); String userId = user.getId(); try { - List<MdcEquipmentTree> mdcEquipmentTreeList = mdcEquipmentService.loadTreeListByProduction(userId); + List<MdcEquipmentTree> mdcEquipmentTreeList = mdcEquipmentService.loadTreeListByProduction(userId, key); result.setSuccess(true); result.setResult(mdcEquipmentTreeList); } catch (Exception e) { @@ -422,8 +426,29 @@ * @param mdcEquipment */ @RequestMapping(value = "/exportXls") - public ModelAndView exportXls(HttpServletRequest request, MdcEquipment mdcEquipment) { - return super.exportXls(request, mdcEquipment, MdcEquipment.class, "璁惧琛�"); + public ModelAndView exportXls(HttpServletRequest request, MdcEquipmentVo mdcEquipment) { + // Step.1 缁勮鏌ヨ鏉′欢 + //QueryWrapper<MdcEquipment> queryWrapper = QueryGenerator.initQueryWrapper(mdcEquipment, request.getParameterMap()); + //Step.2 AutoPoi 瀵煎嚭Excel + ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); + List<MdcEquipment> pageList = mdcEquipmentService.exportXlsList(mdcEquipment); + List<String> equipmentIds = pageList.stream().map(MdcEquipment::getId).collect(Collectors.toList()); + if (!equipmentIds.isEmpty()) { + Map<String, String> equDepNames = mdcEquipmentService.getDepNamesByEquipmentIds(equipmentIds); + Map<String, String> equProNames = mdcEquipmentService.getProNamesByEquipmentIds(equipmentIds); + pageList.forEach(item -> { + item.setOrgCodeTxt(equDepNames.get(item.getId())); + item.setProductionName(equProNames.get(item.getId())); + }); + } + mv.addObject(NormalExcelConstants.FILE_NAME, "璁惧鍒楄〃"); + mv.addObject(NormalExcelConstants.CLASS, MdcEquipment.class); + LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + ExportParams exportParams = new ExportParams("璁惧鍒楄〃鏁版嵁", "瀵煎嚭浜�:" + user.getRealname(), "瀵煎嚭淇℃伅"); +// exportParams.setImageBasePath(upLoadPath); + mv.addObject(NormalExcelConstants.PARAMS, exportParams); + mv.addObject(NormalExcelConstants.DATA_LIST, pageList); + return mv; } /** @@ -500,4 +525,20 @@ } return Result.OK("鍙嶉鎴愬姛锛�"); } + + + @AutoLog(value = "璁惧琛�-閫氳繃杞﹂棿ids鑾峰彇璁惧鏍�") + @ApiOperation(value = "璁惧琛�-閫氳繃杞﹂棿ids鑾峰彇璁惧鏍�", notes = "璁惧琛�-閫氳繃杞﹂棿ids鑾峰彇璁惧鏍�") + @GetMapping(value = "/loadTreeListByProductionIds") + public Result<?> loadTreeListByProductionIds(@RequestParam(name = "ids", required = true) String ids) { + Result<List<MdcEquipmentTree>> result = new Result<>(); + try { + List<MdcEquipmentTree> mdcEquipmentTreeList = mdcEquipmentService.loadTreeListByProductionIds(ids); + result.setSuccess(true); + result.setResult(mdcEquipmentTreeList); + } catch (Exception e) { + log.error(e.getMessage(), e); + } + return result; + } } -- Gitblit v1.9.3