| | |
| | | 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; |
| | | |
| | |
| | | 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("添加成功!"); |
| | |
| | | * @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; |
| | | } |
| | | |
| | | /** |