| | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.poi.ss.usermodel.*; |
| | | import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
| | | |
| | | 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.modules.eam.constant.BusinessCodeConst; |
| | | import org.jeecg.modules.eam.constant.MaintenanceCategoryEnum; |
| | | |
| | | import org.jeecg.modules.eam.constant.MaintenanceStandardStatusEnum; |
| | | import org.jeecg.modules.eam.entity.EamMaintenanceStandard; |
| | | import org.jeecg.modules.eam.entity.EamMaintenanceStandardDetail; |
| | | |
| | | 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.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | |
| | | import org.springframework.web.servlet.ModelAndView; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | |
| | | /** |
| | | * @Description: 保养标准 |
| | |
| | | @DeleteMapping(value = "/deleteBatch") |
| | | public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) { |
| | | List<String> list = Arrays.asList(ids.split(",")); |
| | | AtomicInteger i = new AtomicInteger(); |
| | | list.forEach(id -> { |
| | | EamMaintenanceStandard entity = eamMaintenanceStandardService.getById(id); |
| | | if (entity != null) { |
| | | if (entity != null&&entity.getStandardStatus().equals(MaintenanceStandardStatusEnum.WAIT_SUBMIT.name())) { |
| | | //只删除状态为待提交的 |
| | | i.getAndIncrement(); |
| | | entity.setDelFlag(CommonConstant.DEL_FLAG_1); |
| | | eamMaintenanceStandardService.updateById(entity); |
| | | } |
| | | }); |
| | | return Result.OK("批量删除成功!"); |
| | | return Result.OK("批量删除成功,已删除状态为待提交的保养标准,删除数量为"+i); |
| | | } |
| | | |
| | | /** |
| | |
| | | for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) { |
| | | MultipartFile file = entity.getValue(); |
| | | String fileName = file.getOriginalFilename(); |
| | | |
| | | Result<?> importResult = eamMaintenanceStandardService.importPointInspectionExcel(file); |
| | | |
| | | Result<?> importResult=eamMaintenanceStandardService.importPointInspectionExcel(file); |
| | | if (importResult.isSuccess()) { |
| | | results.put(fileName, "成功: " + importResult.getMessage()); |
| | | successCount++; |
| | | } else { |
| | | results.put(fileName, "失败: " + importResult.getMessage()); |
| | | results.put(fileName, importResult.getMessage()); |
| | | failureCount++; |
| | | } |
| | | } |
| | | |
| | | // 构建响应 |
| | | Map<String, Object> response = new HashMap<>(); |
| | | response.put("results", results); |
| | | response.put("totalFiles", fileMap.size()); |
| | | response.put("successCount", successCount); |
| | | response.put("failureCount", failureCount); |
| | | |
| | | if (failureCount == 0) { |
| | | return Result.ok("所有点检文件导入成功"+response); |
| | | } else if (successCount == 0) { |
| | | return Result.error("所有点检文件导入失败", response); |
| | | } else { |
| | | return Result.error("部分点检文件导入失败", response); |
| | | } |
| | | // 构建最终响应 |
| | | return getResult(results, fileMap.size(), successCount, failureCount); |
| | | |
| | | } catch (Exception e) { |
| | | log.error("点检导入处理异常", e); |
| | |
| | | for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) { |
| | | MultipartFile file = entity.getValue(); |
| | | String fileName = file.getOriginalFilename(); |
| | | |
| | | Result<?> importResult = eamMaintenanceStandardService.importMaintenanceStandard(file, "SECOND"); |
| | | |
| | | Result<?> importResult=eamMaintenanceStandardService.importMaintenanceStandard(file, "SECOND"); |
| | | if (importResult.isSuccess()) { |
| | | results.put(fileName, "成功: " + importResult.getMessage()); |
| | | successCount++; |
| | | } else { |
| | | results.put(fileName, "失败: " + importResult.getMessage()); |
| | | results.put(fileName, importResult.getMessage()); |
| | | failureCount++; |
| | | } |
| | | } |
| | | |
| | | // 构建最终响应 |
| | | Map<String, Object> response = new HashMap<>(); |
| | | response.put("results", results); |
| | | response.put("totalFiles", fileMap.size()); |
| | | response.put("successCount", successCount); |
| | | response.put("failureCount", failureCount); |
| | | |
| | | if (failureCount > 0) { |
| | | return Result.error("部分文件导入失败", response); |
| | | } |
| | | |
| | | return Result.ok("所有文件导入成功"+response); |
| | | return getResult(results, fileMap.size(), successCount, failureCount); |
| | | |
| | | } catch (Exception e) { |
| | | log.error("导入处理异常", e); |
| | |
| | | for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) { |
| | | MultipartFile file = entity.getValue(); |
| | | String fileName = file.getOriginalFilename(); |
| | | |
| | | Result<?> importResult = eamMaintenanceStandardService.importMaintenanceStandard(file, "THIRD"); |
| | | |
| | | Result<?> importResult= eamMaintenanceStandardService.importMaintenanceStandard(file, "THIRD"); |
| | | if (importResult.isSuccess()) { |
| | | results.put(fileName, "成功: " + importResult.getMessage()); |
| | | successCount++; |
| | | } else { |
| | | results.put(fileName, "失败: " + importResult.getMessage()); |
| | | results.put(fileName, importResult.getMessage()); |
| | | failureCount++; |
| | | } |
| | | } |
| | | |
| | | // 构建最终响应 |
| | | Map<String, Object> response = new HashMap<>(); |
| | | response.put("results", results); |
| | | response.put("totalFiles", fileMap.size()); |
| | | response.put("successCount", successCount); |
| | | response.put("failureCount", failureCount); |
| | | |
| | | if (failureCount > 0) { |
| | | return Result.error("部分文件导入失败", response); |
| | | } |
| | | |
| | | return Result.ok("所有文件导入成功"+response); |
| | | return getResult(results, fileMap.size(), successCount, failureCount); |
| | | |
| | | } catch (Exception e) { |
| | | log.error("导入处理异常", e); |
| | |
| | | } |
| | | } |
| | | |
| | | private Result<?> getResult(Map<String, String> results, int fileCount, int successCount, int failureCount) { |
| | | List<String> response = new ArrayList<>(); |
| | | response.add("总文件数:" + fileCount); |
| | | response.add("成功数:" + successCount); |
| | | response.add("失败数:" + failureCount); |
| | | if (failureCount > 0) { |
| | | response.add("错误信息:" + results.values()); |
| | | return Result.error("部分文件导入失败:" + response); |
| | | } |
| | | return Result.ok("所有文件导入成功:" + response); |
| | | } |
| | | |
| | | } |