From e941917741b9b9b589d55fca1480126b78a0e2e3 Mon Sep 17 00:00:00 2001
From: zjj <3272660260@qq.com>
Date: 星期一, 05 五月 2025 14:48:55 +0800
Subject: [PATCH] #存在移库任务禁止执行出库任务
---
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/map/service/MapService.java | 225 ++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 203 insertions(+), 22 deletions(-)
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/map/service/MapService.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/map/service/MapService.java
index 0ec2113..66c59da 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/map/service/MapService.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/map/service/MapService.java
@@ -5,15 +5,38 @@
import com.zy.asrs.framework.common.Cools;
import com.zy.asrs.framework.exception.CoolException;
import com.zy.asrs.wcs.common.domain.enums.DictType;
+import com.zy.asrs.wcs.core.entity.BasShuttle;
+import com.zy.asrs.wcs.core.entity.Loc;
import com.zy.asrs.wcs.core.map.controller.param.MapDataParam;
import com.zy.asrs.wcs.core.map.controller.param.MapQueryParam;
+import com.zy.asrs.wcs.core.map.controller.result.LiftVo;
+import com.zy.asrs.wcs.core.map.controller.result.LocVo;
+import com.zy.asrs.wcs.core.map.controller.result.ShuttleVo;
+import com.zy.asrs.wcs.core.map.entity.MapItem;
+import com.zy.asrs.wcs.core.model.enums.DeviceCtgType;
+import com.zy.asrs.wcs.core.model.enums.LocStsType;
+import com.zy.asrs.wcs.core.service.BasShuttleService;
+import com.zy.asrs.wcs.core.service.LocService;
+import com.zy.asrs.wcs.core.service.LocStsService;
+import com.zy.asrs.wcs.core.utils.Utils;
+import com.zy.asrs.wcs.rcs.entity.Device;
+import com.zy.asrs.wcs.rcs.model.protocol.LiftProtocol;
+import com.zy.asrs.wcs.rcs.model.protocol.ShuttleProtocol;
+import com.zy.asrs.wcs.rcs.service.DeviceService;
+import com.zy.asrs.wcs.rcs.service.DeviceTypeService;
import com.zy.asrs.wcs.system.entity.Dict;
import com.zy.asrs.wcs.system.service.DictService;
import com.zy.asrs.wcs.system.service.UserService;
+import com.zy.asrs.wcs.utils.CommonUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import java.util.ArrayList;
import java.util.Date;
+import java.util.List;
+import java.util.Optional;
+import java.util.stream.Collectors;
/**
* Created by vincent on 3/15/2024
@@ -25,27 +48,45 @@
private UserService userService;
@Autowired
private DictService dictService;
+ @Autowired
+ private DeviceTypeService deviceTypeService;
+ @Autowired
+ private DeviceService deviceService;
+ @Autowired
+ private LocService locService;
+ @Autowired
+ private LocStsService locStsService;
+ @Autowired
+ private BasShuttleService basShuttleService;
- public MapDataParam getMapData(MapQueryParam param, Long userId) {
-
- String mapKey = getMapKey(param.getFloor());
- Dict dict = dictService.getOne(new LambdaQueryWrapper<Dict>().eq(Dict::getFlag, mapKey));
- if (Cools.isEmpty(dict)) {
- return null;
- } else {
- return JSON.parseObject(dict.getValue(), MapDataParam.class) ;
+ public String getMapFloorList(Long userId) {
+ String floorKey = "floor-list";
+ Dict dict = dictService.getOne(new LambdaQueryWrapper<Dict>().eq(Dict::getFlag, floorKey));
+ if (null == dict) {
+ dict = new Dict();
+ dict.setName(floorKey);
+ dict.setFlag(floorKey);
+ dict.setType(DictType.JSON.flag);
+ dict.setValue(floorListStr);
+ dict.setCreateBy(userId);
+ dict.setUpdateBy(userId);
+ if (!dictService.save(dict)) {
+ throw new CoolException("鏈嶅姟鍣ㄥ唴閮ㄩ敊璇�");
+ }
}
-
-
-// User user = userService.getById(userId);
-// if (Cools.isEmpty(user.getMemo())) {
-// return new MapDataParam();
-// }
-// return JSON.parseObject(user.getMemo(), MapDataParam.class);
+ return Optional.ofNullable(dict).map(Dict::getValue).orElse(null);
}
- public void saveMapData(MapDataParam param, Long userId) {
+ public String getMapData(MapQueryParam param, Long userId) {
+ String mapKey = getMapKey(param.getFloor());
+ Dict dict = dictService.getOne(new LambdaQueryWrapper<Dict>().eq(Dict::getFlag, mapKey));
+ return Optional.ofNullable(dict).map(Dict::getValue).orElse(null);
+ }
+ @Transactional
+ public void saveMapData(MapDataParam param, Long userId) {
+ Date now = new Date();
+ // dict
String mapKey = getMapKey(param.getFloor());
Dict dict = dictService.getOne(new LambdaQueryWrapper<Dict>().eq(Dict::getFlag, mapKey));
if (Cools.isEmpty(dict)) {
@@ -54,25 +95,158 @@
dict.setFlag(mapKey);
dict.setType(DictType.JSON.flag);
dict.setValue(JSON.toJSONString(param.getItemList()));
+ dict.setCreateBy(userId);
+ dict.setUpdateBy(userId);
if (!dictService.save(dict)) {
throw new CoolException("鏈嶅姟鍣ㄥ唴閮ㄩ敊璇�");
}
} else {
dict.setValue(JSON.toJSONString(param.getItemList()));
dict.setUpdateTime(new Date());
+ dict.setUpdateBy(userId);
if (!dictService.updateById(dict)) {
throw new CoolException("鏈嶅姟鍣ㄥ唴閮ㄩ敊璇�");
}
}
+ // loc
+ List<String> newLocList = new ArrayList<>();
+ for (MapItem item : param.getItemList()) {
+ int row = Integer.parseInt(String.valueOf(item.getProperty().get("row")));
+ int bay = Integer.parseInt(String.valueOf(item.getProperty().get("bay")));
+ String locNo = Utils.getLocNo(row, bay, param.getFloor());
+ newLocList.add(locNo);
+ }
-//
-// User user = userService.getById(userId);
-// user.setMemo(JSON.toJSONString(param));
-// if (!userService.updateById(user)) {
-// throw new CoolException("鏈嶅姟鍣ㄥ唴閮ㄩ敊璇�");
-// }
+ List<String> existLocList = locService.list(new LambdaQueryWrapper<Loc>().eq(Loc::getLev, param.getFloor()))
+ .stream().map(Loc::getLocNo).collect(Collectors.toList());
+
+
+ List<String> locListToSave = newLocList.stream().filter(locNo -> !existLocList.contains(locNo)).collect(Collectors.toList());
+
+ List<String> locListToRemove = existLocList.stream().filter(locNo -> !newLocList.contains(locNo)).collect(Collectors.toList());
+
+ List<String> locListInBoth = newLocList.stream().filter(existLocList::contains).collect(Collectors.toList());
+
+ for (String locNo : locListToSave) {
+ Loc loc = new Loc();
+ loc.setLocNo(locNo);
+ loc.setName(locNo);
+ loc.setRow(Utils.getRow(locNo));
+ loc.setBay(Utils.getBay(locNo));
+ loc.setLev(Utils.getLev(locNo));
+ loc.setLocSts(LocStsType.O.val());
+ loc.setCreateBy(userId);
+ loc.setCreateTime(now);
+ loc.setUpdateBy(userId);
+ loc.setUpdateTime(now);
+ if (!locService.save(loc)) {
+ throw new CoolException("鏈嶅姟鍣ㄥ唴閮ㄩ敊璇�");
+ }
+ }
+
+ for (String locNo : locListToRemove) {
+ if (!locService.remove(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, locNo))) {
+ throw new CoolException("鏈嶅姟鍣ㄥ唴閮ㄩ敊璇�");
+ }
+ }
+
+ for (String locNo : locListInBoth) {
+
+ }
}
+ public List<LocVo> getShelfLocNoGroup(String locNo) {
+ List<LocVo> locVos = new ArrayList<>();
+ int row = Utils.getRow(locNo);
+ int bay = Utils.getBay(locNo);
+ List<Loc> locList = locService.list(new LambdaQueryWrapper<Loc>().eq(Loc::getRow, row).eq(Loc::getBay, bay).orderByAsc(Loc::getLev));
+ for (Loc loc : locList) {
+ LocVo locVo = new LocVo();
+ locVo.setLocNo(loc.getLocNo());
+ locVo.setLocSts(loc.getLocStsFlag());
+ locVo.setZpallet(loc.getZpallet());
+ locVo.setEnable(CommonUtils.getStatusBool(loc.getStatus()));
+ locVos.add(locVo);
+ }
+ return locVos;
+ }
+
+ public LocVo getShelfLocNoInfo(String locNo) {
+ LocVo locVo = new LocVo();
+ locVo.setLocNo(locNo);
+ Loc loc = locService.selectByLocNo(locNo);
+ if (null == loc) {
+ return locVo;
+ }
+ locVo.setLocSts(loc.getLocStsFlag());
+ locVo.setZpallet(loc.getZpallet());
+ locVo.setEnable(CommonUtils.getStatusBool(loc.getStatus()));
+ return locVo;
+ }
+
+ public ShuttleVo getShuttleInfo(String shuttleNo) {
+ ShuttleVo vo = new ShuttleVo();
+ vo.setShuttleNo(shuttleNo);
+ Device device = deviceService.getOne(new LambdaQueryWrapper<Device>()
+ .eq(Device::getDeviceType, DeviceCtgType.SHUTTLE.val())
+ .eq(Device::getDeviceNo, shuttleNo)
+ .eq(Device::getStatus, 1)
+ );
+ if (null == device) {
+ return vo;
+ }
+ BasShuttle basShuttle = basShuttleService.getOne(new LambdaQueryWrapper<BasShuttle>().eq(BasShuttle::getDeviceId, device.getId()));
+ if (null == basShuttle || Cools.isEmpty(basShuttle.getProtocol())) {
+ return vo;
+ }
+ ShuttleProtocol protocol = JSON.parseObject(basShuttle.getProtocol(), ShuttleProtocol.class);
+// ShuttleThread thread = (ShuttleThread)SlaveConnection.get(SlaveType.Shuttle, device.getId().intValue());
+// if (null == thread) {
+// return vo;
+// }
+// ShuttleProtocol protocol = thread.getStatus();
+// if (null == protocol) {
+// return vo;
+// }
+ vo.setTaskNo(String.valueOf(protocol.getTaskNo()));
+ vo.setStatus(protocol.getProtocolStatusType().desc);
+ vo.setOriginLocNo(protocol.getSourceLocNo());
+ vo.setDestLocNo(protocol.getLocNo());
+ vo.setCurrentCode(protocol.getCurrentCode());
+ vo.setCurrentLocNo(protocol.getCurrentLocNo());
+ vo.setBatteryPower(protocol.getBatteryPower());
+ vo.setErrorCode(protocol.getErrorCode());
+ vo.setBatteryTemp(protocol.getBatteryTemp());
+ vo.setHasLift(protocol.getHasLift());
+ vo.setHasPallet(protocol.getHasPallet());
+ vo.setHasCharge(protocol.getHasCharge());
+ vo.setBatteryVoltage(String.valueOf(protocol.getBatteryVoltage()));
+// vo.setZpallet();
+ vo.setPakMk(protocol.getPakMk());
+ vo.setEnable(CommonUtils.getStatusBool(basShuttle.getStatus()));
+ return vo;
+ }
+
+ public LiftVo getLiftInfo(String liftNo) {
+ LiftVo vo = new LiftVo();
+ vo.setLiftNo(liftNo);
+ LiftProtocol protocol = new LiftProtocol();
+ // todo checkout protocol
+// vo.setTaskNo(String.valueOf(protocol.getTaskNo()));
+// vo.setStatus(protocol.getProtocolStatusType().desc);
+// vo.setOriginLocNo(protocol.getSourceLocNo());
+// vo.setDestLocNo(protocol.getLocNo());
+// vo.setCurrentCode(protocol.getCurrentCode());
+// vo.setBatteryPower(protocol.getBatteryPower());
+// vo.setErrorCode(protocol.getErrorCode());
+// vo.setBatteryTemp(protocol.getBatteryTemp());
+// vo.setHasLift(protocol.getHasLift());
+// vo.setHasPallet(protocol.getHasPallet());
+// vo.setHasCharge(protocol.getHasCharge());
+// vo.setBatteryVoltage(String.valueOf(protocol.getBatteryVoltage()));
+// vo.setPakMk(protocol.getPakMk());
+ return vo;
+ }
private String getMapKey(Integer floor) {
if (null != floor) {
@@ -81,4 +255,11 @@
return "map";
}
+ private final String floorListStr = "[\n" +
+ " {\n" +
+ " label: '1F',\n" +
+ " value: 1\n" +
+ " },\n" +
+ "]";
+
}
--
Gitblit v1.9.1