From e332a71fb583d1b621f6646d91d794d8ed36f9b9 Mon Sep 17 00:00:00 2001 From: jiangping <jp@doumee.com> Date: 星期五, 25 八月 2023 18:43:45 +0800 Subject: [PATCH] 修复bug --- server/src/main/java/doumeemes/service/business/impl/DeviceServiceImpl.java | 35 ++++++++++++++++++++++++++++++++--- 1 files changed, 32 insertions(+), 3 deletions(-) diff --git a/server/src/main/java/doumeemes/service/business/impl/DeviceServiceImpl.java b/server/src/main/java/doumeemes/service/business/impl/DeviceServiceImpl.java index 849381b..c9fb3a3 100644 --- a/server/src/main/java/doumeemes/service/business/impl/DeviceServiceImpl.java +++ b/server/src/main/java/doumeemes/service/business/impl/DeviceServiceImpl.java @@ -303,6 +303,9 @@ || StringUtils.isBlank(s.getFinishWarehouseLocationName())){ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵煎叆鏁版嵁鍐呭鏈夎"); } + if(isRepeatCode(s.getDeviceCode(),plansList)){ + throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"鏂囨。涓澶囧彿銆�"+s.getDeviceCode()+"銆戦噸澶嶏紒"); + } departName.add(s.getDepartName()); procedureName.add(s.getProcedureName()); }); @@ -368,7 +371,7 @@ 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<>(); @@ -385,9 +388,24 @@ 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.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); @@ -413,6 +431,17 @@ }); } + private boolean isRepeatCode(String deviceCode, List<DeviceImportDTO> plansList) { + if(StringUtils.isNotBlank(deviceCode)){ + for(DeviceImportDTO d :plansList){ + if(StringUtils.equals(deviceCode, d.getDeviceCode())){ + return true; + } + } + } + return false; + } + public synchronized String getNextCode(Integer comId ){ String prefix = "S-" + DateUtil.getDate(new Date(),"yyyyMMdd") +"-"; -- Gitblit v1.9.3