| | |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.poi.hssf.usermodel.HSSFSheet; |
| | | import org.apache.poi.hssf.usermodel.HSSFWorkbook; |
| | | import org.apache.poi.ss.usermodel.*; |
| | | import org.apache.poi.xssf.usermodel.XSSFSheet; |
| | | import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
| | | import org.jeecg.common.api.vo.FileUploadResult; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.common.aspect.annotation.AutoLog; |
| | | import org.jeecg.common.constant.CommonConstant; |
| | | import org.jeecg.common.exception.JeecgBootException; |
| | | import org.jeecg.common.system.base.controller.JeecgController; |
| | | import org.jeecg.common.util.FileUtil; |
| | | import org.jeecg.modules.eam.constant.BusinessCodeConst; |
| | | import org.jeecg.modules.eam.constant.MaintenanceCategoryEnum; |
| | | import org.jeecg.modules.eam.constant.MaintenanceStandardStatusEnum; |
| | |
| | | import org.jeecg.modules.eam.request.EamMaintenanceStandardRequest; |
| | | import org.jeecg.modules.eam.service.IEamEquipmentService; |
| | | import org.jeecg.modules.eam.service.IEamMaintenanceStandardService; |
| | | import org.jeecg.modules.eam.vo.EamMaintenanceStandardVo; |
| | | import org.jeecg.modules.system.service.ISysBusinessCodeRuleService; |
| | | import org.jeecgframework.poi.excel.ExcelImportUtil; |
| | | import org.jeecgframework.poi.excel.entity.ImportParams; |
| | | import org.jeecgframework.poi.util.PoiPublicUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | |
| | | private ISysBusinessCodeRuleService businessCodeRuleService; |
| | | @Autowired |
| | | private IEamEquipmentService eamEquipmentService; |
| | | |
| | | /** |
| | | * 流程启动,保存对应的数据 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "保养标准-流程启动保存对应的数据", notes = "保养标准-流程启动保存对应的数据") |
| | | @GetMapping(value = "/saveEamMaintenanceStandardProcess") |
| | | public Result<?> saveEamMaintenanceStandardProcess(String id){ |
| | | return eamMaintenanceStandardService.saveEamMaintenanceStandardProcess(id); |
| | | } |
| | | |
| | | /** |
| | | * 流程审核 |
| | | * @param eamMaintenanceStandardVo |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "保养标准-流程审核", notes = "保养标准-流程审核") |
| | | @PostMapping(value = "/audit") |
| | | public Result<?> auditEamMaintenanceStandard(@RequestBody EamMaintenanceStandardVo eamMaintenanceStandardVo){ |
| | | return eamMaintenanceStandardService.auditEamMaintenanceStandard(eamMaintenanceStandardVo); |
| | | } |
| | | |
| | | /** |
| | | * 分页列表查询 |
| | |
| | | */ |
| | | @AutoLog(value = "保养标准-升版") |
| | | @ApiOperation(value = "保养标准-升版", notes = "保养标准-升版") |
| | | @RequestMapping(value = "/upgrade", method = {RequestMethod.PUT, RequestMethod.POST}) |
| | | @PutMapping(value = "/upgrade") |
| | | public Result<?> upgrade(@RequestBody EamMaintenanceStandardRequest standardRequest) { |
| | | if (standardRequest == null) { |
| | | return Result.error("添加的对象不能为空!"); |
| | |
| | | @RequestMapping(value = "/exportXls") |
| | | public ModelAndView exportXls(HttpServletRequest request, EamMaintenanceStandard eamMaintenanceStandard) { |
| | | return super.exportXls(request, eamMaintenanceStandard, EamMaintenanceStandard.class, "保养标准"); |
| | | } |
| | | |
| | | @PostMapping("/import") |
| | | public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { |
| | | MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; |
| | | Map<String, MultipartFile> fileMap = multipartRequest.getFileMap(); |
| | | for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) { |
| | | // 获取上传文件对象 |
| | | MultipartFile file = entity.getValue(); |
| | | eamMaintenanceStandardService.importPointInspectionExcel(file); |
| | | } |
| | | return Result.ok("导入成功"); |
| | | } |
| | | |
| | | /** |
| | |
| | | //文件编码 |
| | | Cell fileCode = row.getCell(13); |
| | | request.setFileCode(fileCode.getStringCellValue()); |
| | | |
| | | Map<String, PictureData> pictures; |
| | | if (isXSSFWorkbook) { |
| | | pictures = PoiPublicUtil.getSheetPictrues07((XSSFSheet) book.getSheetAt(0), (XSSFWorkbook) book); |
| | | } else { |
| | | pictures = PoiPublicUtil.getSheetPictrues03((HSSFSheet) book.getSheetAt(0), (HSSFWorkbook) book); |
| | | } |
| | | |
| | | if (CollectionUtil.isNotEmpty(pictures)) { |
| | | //只会存在一张图片 |
| | | PictureData pictureData = pictures.get(pictures.keySet().iterator().next()); |
| | | byte[] data = pictureData.getData(); |
| | | String fileName = request.getEquipmentCode() + "[" + request.getFileCode() + "]" + "." + pictureData.suggestFileExtension(); |
| | | FileUploadResult fileUploadResult = FileUtil.uploadFile(data, fileName); |
| | | if(fileUploadResult != null) { |
| | | List<FileUploadResult> fileList = request.getFileList(); |
| | | if(fileList == null) { |
| | | fileList = new ArrayList<FileUploadResult>(); |
| | | } |
| | | fileList.add(fileUploadResult); |
| | | request.setFileList(fileList); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("读取Excel信息失败:{}", e.getMessage(), e); |
| | | } |