|  |  |  | 
|---|
|  |  |  | queryDeviceExtDTO1.setRootDepartId(user.getRootDepartment().getId()); | 
|---|
|  |  |  | List<DeviceExtListVO> list1= deviceExtService.getListByCondition(queryDeviceExtDTO1);*/ | 
|---|
|  |  |  | if(list.size()>0){ | 
|---|
|  |  |  | return ApiResponse.failed("设备编码,不允许添加"); | 
|---|
|  |  |  | return ApiResponse.failed("设备编码已存在,不允许添加"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | device.setDeleted(Constants.ZERO); | 
|---|
|  |  |  | device.setCreateTime(new Date()); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<String> departName = new ArrayList<>(); | 
|---|
|  |  |  | List<String> procedureName = new ArrayList<>(); | 
|---|
|  |  |  | plansList.forEach(s->{ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | int num =0; | 
|---|
|  |  |  | for(DeviceImportDTO s : plansList){ | 
|---|
|  |  |  | if (StringUtils.isBlank(s.getDeviceName()) | 
|---|
|  |  |  | || s.getDeviceName().length() > 50 | 
|---|
|  |  |  | || StringUtils.isBlank(s.getDepartName()) | 
|---|
|  |  |  | 
|---|
|  |  |  | || StringUtils.isBlank(s.getFinishWarehouseLocationName())){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"导入数据内容有误"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(isRepeatCode(s,num,plansList)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"文档中设备号【"+s.getDeviceCode()+"】重复!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | departName.add(s.getDepartName()); | 
|---|
|  |  |  | procedureName.add(s.getProcedureName()); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | num++; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | plansList.forEach(s->{ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | if(Objects.isNull(procedures)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"工序名称不存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | QueryDeviceExtDTO queryDeviceExtDTO=new QueryDeviceExtDTO(); | 
|---|
|  |  |  | queryDeviceExtDTO.setDeleted(Constants.ZERO); | 
|---|
|  |  |  | queryDeviceExtDTO.setCode(s.getDeviceCode()); | 
|---|
|  |  |  | queryDeviceExtDTO.setRootDepartId(user.getRootDepartment().getId()); | 
|---|
|  |  |  | List<DeviceExtListVO> list= deviceExtService.getListByCondition(queryDeviceExtDTO); | 
|---|
|  |  |  | if(list.size() > 0){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"设备编码不存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //            QueryDeviceExtDTO queryDeviceExtDTO=new QueryDeviceExtDTO(); | 
|---|
|  |  |  | //            queryDeviceExtDTO.setDeleted(Constants.ZERO); | 
|---|
|  |  |  | //            queryDeviceExtDTO.setCode(s.getDeviceCode()); | 
|---|
|  |  |  | //            queryDeviceExtDTO.setRootDepartId(user.getRootDepartment().getId()); | 
|---|
|  |  |  | //            List<DeviceExtListVO> list= deviceExtService.getListByCondition(queryDeviceExtDTO); | 
|---|
|  |  |  | //            if(list.size() > 0){ | 
|---|
|  |  |  | //                throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"设备编码不存在"); | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | WarehouseLocation finishWarehouseLocations = warehouseLocationMapper.selectOne(warehouseLocationQuery); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (Objects.isNull(finishWarehouseLocations)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"已完工货位不存在"); | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"已完工货位不是混合属性"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Map<String, WarehouseLocation> collect =new HashMap<>(); | 
|---|
|  |  |  | 
|---|
|  |  |  | device.setRootDepartId(user.getRootDepartment().getId()); | 
|---|
|  |  |  | device.setDepartId(user.getCurComDepartment().getId()); | 
|---|
|  |  |  | device.setProcedureId(procedures.getId()); | 
|---|
|  |  |  | device.setCode(StringUtils.isNotBlank(s.getDeviceCode()) ? s.getDeviceCode() : this.getNextCode(user.getCompany().getId())); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | device.setCode(StringUtils.isNotBlank(device.getCode()) ? device.getCode() : this.getNextCode(user.getCompany().getId())); | 
|---|
|  |  |  | device.setType(StringUtils.isNotBlank(device.getCode()) ? device.getCode().trim().equals("设备") ? 1 : 0 : 1); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Device ttt=new Device(); | 
|---|
|  |  |  | ttt.setDeleted(Constants.ZERO); | 
|---|
|  |  |  | ttt.setCode(device.getCode()); | 
|---|
|  |  |  | ttt.setRootDepartId(user.getRootDepartment().getId()); | 
|---|
|  |  |  | if(findOne(ttt) !=null){ | 
|---|
|  |  |  | throw  new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"设备编码【"+device.getCode()+"重复】,不允许添加"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(StringUtils.isNotBlank(s.getType()) && StringUtils.equals("设备组",s.getType())){ | 
|---|
|  |  |  | device.setType(0); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | device.setType(1); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //            device.setType(StringUtils.isNotBlank(device.getCode()) ? device.getCode().trim().equals("设备") ? 1 : 0 : 1); | 
|---|
|  |  |  | device.setName(s.getDeviceName()); | 
|---|
|  |  |  | device.setModel(s.getModel()); | 
|---|
|  |  |  | device.setStatus(Constants.ZERO); | 
|---|
|  |  |  | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private boolean isRepeatCode(DeviceImportDTO s,int num,List<DeviceImportDTO> plansList) { | 
|---|
|  |  |  | if(StringUtils.isNotBlank(s.getDeviceCode())){ | 
|---|
|  |  |  | int tNum = 0; | 
|---|
|  |  |  | for(DeviceImportDTO d :plansList){ | 
|---|
|  |  |  | if(num != tNum && StringUtils.equals(s.getDeviceCode(), d.getDeviceCode())){ | 
|---|
|  |  |  | return  true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | tNum++; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return  false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public synchronized String  getNextCode(Integer comId ){ | 
|---|
|  |  |  | String prefix =  "S-" + DateUtil.getDate(new Date(),"yyyyMMdd") +"-"; | 
|---|