| | |
| | | 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.getDeviceCode(),plansList)){ |
| | | 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->{ |
| | | |
| | |
| | | }); |
| | | } |
| | | |
| | | private boolean isRepeatCode(String deviceCode, List<DeviceImportDTO> plansList) { |
| | | if(StringUtils.isNotBlank(deviceCode)){ |
| | | private boolean isRepeatCode(DeviceImportDTO s,int num,List<DeviceImportDTO> plansList) { |
| | | if(StringUtils.isNotBlank(s.getDeviceCode())){ |
| | | int tNum = 0; |
| | | for(DeviceImportDTO d :plansList){ |
| | | if(StringUtils.equals(deviceCode, d.getDeviceCode())){ |
| | | if(num != tNum && StringUtils.equals(s.getDeviceCode(), d.getDeviceCode())){ |
| | | return true; |
| | | } |
| | | tNum++; |
| | | } |
| | | } |
| | | return false; |