From 411c7bcfb64581060c459d6a124b58cafadd983a Mon Sep 17 00:00:00 2001
From: Junjie <xjj@123>
Date: 星期四, 11 四月 2024 20:35:37 +0800
Subject: [PATCH] #
---
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/map/service/MapService.java | 154 +++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 136 insertions(+), 18 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 ee3728c..309c69e 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
@@ -4,14 +4,22 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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.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.utils.Utils;
+import com.zy.asrs.wcs.rcs.model.protocol.LiftProtocol;
+import com.zy.asrs.wcs.rcs.model.protocol.ShuttleProtocol;
import com.zy.asrs.wcs.system.entity.Dict;
-import com.zy.asrs.wcs.system.entity.User;
import com.zy.asrs.wcs.system.service.DictService;
import com.zy.asrs.wcs.system.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+
+import java.util.*;
/**
* Created by vincent on 3/15/2024
@@ -24,29 +32,139 @@
@Autowired
private DictService dictService;
- public MapDataParam getMapData(MapQueryParam param, Long userId) {
-
- String dictFlag = "map-" + param.getFloor();
- Dict dict = dictService.getOne(new LambdaQueryWrapper<Dict>().eq(Dict::getFlag, dictFlag));
- 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("鏈嶅姟鍣ㄥ唴閮ㄩ敊璇�");
+ }
}
+ return Optional.ofNullable(dict).map(Dict::getValue).orElse(null);
+ }
-// User user = userService.getById(userId);
-// if (Cools.isEmpty(user.getMemo())) {
-// return new MapDataParam();
-// }
-// return JSON.parseObject(user.getMemo(), MapDataParam.class);
+ 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);
}
public void saveMapData(MapDataParam param, Long userId) {
- User user = userService.getById(userId);
- user.setMemo(JSON.toJSONString(param));
- if (!userService.updateById(user)) {
- throw new CoolException("鏈嶅姟鍣ㄥ唴閮ㄩ敊璇�");
+ String mapKey = getMapKey(param.getFloor());
+ Dict dict = dictService.getOne(new LambdaQueryWrapper<Dict>().eq(Dict::getFlag, mapKey));
+ if (Cools.isEmpty(dict)) {
+ dict = new Dict();
+ dict.setName(mapKey);
+ 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("鏈嶅姟鍣ㄥ唴閮ㄩ敊璇�");
+ }
}
}
+
+ public List<LocVo> getShelfLocNoList(String locNo) {
+ List<LocVo> locVos = new ArrayList<>();
+ int row = Utils.getRow(locNo);
+ int bay = Utils.getBay(locNo);
+
+
+ String[] statusOptions = {"F", "D", "O"};
+ Random random = new Random();
+ for (int lev = 1; lev < 6; lev++) {
+ locVos.add(new LocVo(Utils.getLocNo(row, bay, lev), statusOptions[random.nextInt(statusOptions.length)]));
+ }
+ return locVos;
+ }
+
+ public ShuttleVo getShuttleInfo(String shuttleNo) {
+ ShuttleVo vo = new ShuttleVo();
+ vo.setShuttleNo(shuttleNo);
+ ShuttleProtocol protocol = new ShuttleProtocol();
+ // 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;
+ }
+
+ 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) {
+ return "map-" + floor;
+ }
+ return "map";
+ }
+
+ private final String floorListStr = "[\n" +
+ " {\n" +
+ " label: '1F',\n" +
+ " value: 1\n" +
+ " },\n" +
+ " {\n" +
+ " label: '2F',\n" +
+ " value: 2\n" +
+ " },\n" +
+ " {\n" +
+ " label: '3F',\n" +
+ " value: 3\n" +
+ " },\n" +
+ " {\n" +
+ " label: '4F',\n" +
+ " value: 4\n" +
+ " },\n" +
+ " {\n" +
+ " label: '5F',\n" +
+ " value: 5\n" +
+ " },\n" +
+ "]";
+
}
--
Gitblit v1.9.1