| | |
| | | */ |
| | | @RequestMapping(value = "/importExcel", method = RequestMethod.POST) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | //工区、型号、设备状态、技术状态、ABC标识有空值;维护部门、维修班组为编码需要有对照值。 |
| | | public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { |
| | | MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; |
| | | LoginUser user= (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | |
| | | String manageId = equipmentImportVo.getManageId(); |
| | | String constructorId = equipmentImportVo.getConstructorId(); |
| | | String teamId = equipmentImportVo.getTeamId(); |
| | | String propertyStatus = equipmentImportVo.getPropertyStatus(); |
| | | String abc = equipmentImportVo.getEquipmentImportanceId(); |
| | | if(StringUtils.isBlank(equipmentImportVo.getNum())){ |
| | | exceptionInfo = exceptionInfo+"第"+(i+2)+"行导入失败,原因:统一编码缺失,请填写必填项后再导入;"; |
| | | exceptionNum++; |
| | |
| | | exceptionNum++; |
| | | continue; |
| | | } |
| | | else if(StringUtils.isBlank(equipmentImportVo.getTeamId())){ |
| | | exceptionInfo = exceptionInfo+"第"+(i+2)+"行导入失败,原因:维修班组缺失,请填写必填项后再导入;"; |
| | | exceptionNum++; |
| | | continue; |
| | | } |
| | | else if(StringUtils.isBlank(equipmentImportVo.getEquipmentImportanceId())){ |
| | | exceptionInfo = exceptionInfo+"第"+(i+2)+"行导入失败,原因:ABC标识缺失,请填写必填项后再导入;"; |
| | | exceptionNum++; |
| | | continue; |
| | | } |
| | | // else if(StringUtils.isBlank(equipmentImportVo.getEquipmentImportanceId())){ |
| | | // exceptionInfo = exceptionInfo+"第"+(i+2)+"行导入失败,原因:ABC标识缺失,请填写必填项后再导入;"; |
| | | // exceptionNum++; |
| | | // continue; |
| | | // } |
| | | else if(StringUtils.isBlank(equipmentImportVo.getEquipmentStatus())){ |
| | | exceptionInfo = exceptionInfo+"第"+(i+2)+"行导入失败,原因:设备状态缺失,请填写必填项后再导入;"; |
| | | exceptionNum++; |
| | | continue; |
| | | } |
| | | else if(StringUtils.isBlank(equipmentImportVo.getTechnologyStatus())){ |
| | | exceptionInfo = exceptionInfo+"第"+(i+2)+"行导入失败,原因:设备技术状态缺失,请填写必填项后再导入;"; |
| | | exceptionInfo = exceptionInfo+"第"+(i+2)+"行导入失败,原因:技术状态缺失,请填写必填项后再导入;"; |
| | | exceptionNum++; |
| | | continue; |
| | | } |
| | |
| | | // } |
| | | else{ |
| | | SysDepart use = departService.getOne(new QueryWrapper<SysDepart>().eq("depart_name",useId.trim()),false); |
| | | if(ObjectUtils.isNull(useId)){ |
| | | if(ObjectUtils.isNotNull(use)){ |
| | | equipment.setUseId(use.getId()); |
| | | }else { |
| | | exceptionInfo = exceptionInfo+"第"+(i+2)+"行导入失败,原因:不存在该使用部门,请维护部门数据后再导入;"; |
| | |
| | | continue; |
| | | } |
| | | Area area = areaService.getOne(new QueryWrapper<Area>().eq("name",areaId.trim())); |
| | | Area area1 = areaService.getOne(new QueryWrapper<Area>().eq("num",areaId.trim())); |
| | | if(ObjectUtils.isNotNull(area)){ |
| | | equipment.setFactoryModelId(area.getId()); |
| | | }else if(ObjectUtils.isNotNull(area1)) { |
| | | equipment.setFactoryModelId(area1.getId()); |
| | | }else { |
| | | exceptionInfo = exceptionInfo+"第"+(i+2)+"行导入失败,原因:不存在该工区,请维护工区数据后再导入;"; |
| | | exceptionNum++; |
| | |
| | | continue; |
| | | } |
| | | Team team = teamService.getOne(new QueryWrapper<Team>().eq("name",teamId.trim()),false); |
| | | Team team1 = teamService.getOne(new QueryWrapper<Team>().eq("num",teamId.trim()),false); |
| | | if(ObjectUtils.isNotNull(team)){ |
| | | equipment.setTeamId(team.getId()); |
| | | }else if(ObjectUtils.isNotNull(team1)) { |
| | | equipment.setTeamId(team1.getId()); |
| | | }else { |
| | | exceptionInfo = exceptionInfo+"第"+(i+2)+"行导入失败,原因:不存在该班组,请先维护班组数据后再导入;"; |
| | | exceptionNum++; |
| | |
| | | equipment.setConstructorId(constructor.getId()); |
| | | } |
| | | } |
| | | if(equipmentImportVo.getPropertyStatus().equals("warranty")){ |
| | | if(StringUtils.isNotBlank(propertyStatus)&&propertyStatus.equals("warranty")){ |
| | | if( |
| | | ObjectUtils.isNull(equipmentImportVo.getWarrantyStart()) |
| | | ||ObjectUtils.isNull(equipmentImportVo.getWarrantyEnd()) |
| | | ){ |
| | | exceptionInfo = exceptionInfo+"第"+(i+2)+"行导入失败,原因:该设备处于质保期,质保信息缺失,请先维护质保开始时间或结束时间;"; |
| | | exceptionNum++; |
| | | continue; |
| | | } |
| | | |
| | | }else{ |
| | |
| | | &&!equipmentCategory.getEquipmentCategoryUda1().equals("filesCarousel") |
| | | &&!equipmentCategory.getEquipmentCategoryUda1().equals("tester") |
| | | ){ |
| | | if(equipmentImportVo.getEquipmentImportanceId().equals("A")){ |
| | | equipment.setCheckPeriod(365*3+""); |
| | | if(StringUtils.isNotBlank(abc)){ |
| | | if(abc.equals("A")){ |
| | | equipment.setCheckPeriod(365*3+""); |
| | | } |
| | | if( |
| | | abc.equals("B") |
| | | ||abc.equals("C") |
| | | ||abc.equals("D") |
| | | ){ |
| | | equipment.setCheckPeriod(365*4+""); |
| | | } |
| | | } |
| | | if( |
| | | equipmentImportVo.getEquipmentImportanceId().equals("B") |
| | | ||equipmentImportVo.getEquipmentImportanceId().equals("C") |
| | | ||equipmentImportVo.getEquipmentImportanceId().equals("D") |
| | | ){ |
| | | equipment.setCheckPeriod(365*4+""); |
| | | } |
| | | } |
| | | equipmentService.save(equipment); |
| | | }else { |