diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device/service/DeviceService.java b/acs/nladmin-system/src/main/java/org/nl/acs/device/service/DeviceService.java index 60d23f6..0768fe9 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device/service/DeviceService.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device/service/DeviceService.java @@ -296,4 +296,9 @@ public interface DeviceService { void downDeviceDBloadSmartCSV(JSONArray queryDeviceProtocol, HttpServletResponse response); void downDeviceDBloadFX5UCSV(JSONArray queryDeviceProtocol, HttpServletResponse response); + + + void addDeviceCodeByAddress(StorageCellDto dto); + + void updateDeviceCodeByAddress(StorageCellDto dto); } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java index a05597f..e66ecc5 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java @@ -1966,4 +1966,34 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial return map; } } + + @Override + public void updateDeviceCodeByAddress(StorageCellDto dto){ + Iterator iterator = storageCells.iterator(); + StorageCellDto dto1 = null; + while (iterator.hasNext()) { + StorageCellDto storageCellDto = (StorageCellDto) iterator.next(); + if(StrUtil.equals(storageCellDto.getStorage_code(),dto.getStorage_code())){ + storageCells.remove(storageCellDto); + storageCells.add(dto); + } + } + } + + @Override + public void addDeviceCodeByAddress(StorageCellDto dto){ + Iterator iterator = storageCells.iterator(); + StorageCellDto dto1 = null; + while (iterator.hasNext()) { + StorageCellDto storageCellDto = (StorageCellDto) iterator.next(); + if(StrUtil.equals(storageCellDto.getStorage_code(),dto.getStorage_code())){ + dto1 = storageCellDto; + } + } + if(ObjectUtil.isEmpty(dto1)){ + storageCells.add(dto); + } + } + + } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device/service/impl/StorageCellServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/device/service/impl/StorageCellServiceImpl.java index ba8af22..afc10f5 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device/service/impl/StorageCellServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device/service/impl/StorageCellServiceImpl.java @@ -11,6 +11,7 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.nl.acs.device.service.DeviceService; import org.nl.acs.device.service.StorageCellService; import org.nl.acs.device.service.dto.StorageCellDto; import org.nl.modules.common.exception.BadRequestException; @@ -40,6 +41,9 @@ import java.util.Map; @Slf4j public class StorageCellServiceImpl implements StorageCellService { + private final DeviceService deviceService; + + @Override public Map queryAll(Map whereJson, Pageable page) { String storage_code = MapUtil.getStr(whereJson, "storage_code"); @@ -97,19 +101,30 @@ public class StorageCellServiceImpl implements StorageCellService { @Override @Transactional(rollbackFor = Exception.class) public void create(StorageCellDto dto) { + JSONArray arr; + WQLObject wo = WQLObject.getWQLObject("acs_storage_cell"); + if(dto.getAddress()!=0) { + arr = wo.query("address ='" + dto.getAddress() + "'").getResultJSONArray(0); + if (arr.size() != 0) { + throw new BadRequestException("AGV编码非0时不能重复!"); + } + } + arr = wo.query("storage_code ='" + dto.getStorage_code() + "'").getResultJSONArray(0); + if(arr.size()!=0){ + throw new BadRequestException("货位编码不能重复!"); + } + String currentUsername = SecurityUtils.getCurrentUsername(); String now = DateUtil.now(); - dto.setStorage_id(IdUtil.simpleUUID()); dto.setCreate_by(currentUsername); dto.setUpdate_by(currentUsername); dto.setUpdate_time(now); dto.setCreate_time(now); - - WQLObject wo = WQLObject.getWQLObject("acs_storage_cell"); JSONObject json = (JSONObject) JSONObject.toJSON(dto); - wo.insert(json); + deviceService.addDeviceCodeByAddress(dto); + } @Override diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/route/service/impl/RouteLineServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/route/service/impl/RouteLineServiceImpl.java index ee860d1..d284ba9 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/route/service/impl/RouteLineServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/route/service/impl/RouteLineServiceImpl.java @@ -257,11 +257,12 @@ public class RouteLineServiceImpl implements RouteLineService, ApplicationAutoIn if (arr.size() == 0) { wo.insert(json); } else { - throw new BadRequestException("已存在该路由路线!"); +// throw new BadRequestException("已存在该路由路线!"); + continue; } } } -// reload(); + reload(); } @Override