From f140f8d9e17f4465f029134b008ec7f644b0e3db Mon Sep 17 00:00:00 2001
From: Junjie <540245094@qq.com>
Date: 星期五, 14 十一月 2025 11:08:05 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/asrs/controller/ConsoleController.java | 386 +++++++++++++++++++++++++++++--------------------------
1 files changed, 203 insertions(+), 183 deletions(-)
diff --git a/src/main/java/com/zy/asrs/controller/ConsoleController.java b/src/main/java/com/zy/asrs/controller/ConsoleController.java
index 1c61d5e..b45fedb 100644
--- a/src/main/java/com/zy/asrs/controller/ConsoleController.java
+++ b/src/main/java/com/zy/asrs/controller/ConsoleController.java
@@ -1,41 +1,45 @@
package com.zy.asrs.controller;
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.annotations.ManagerAuth;
import com.core.common.Cools;
import com.core.common.R;
+import com.zy.asrs.domain.enums.CrnStatusType;
+import com.zy.asrs.domain.enums.StationStatusType;
import com.zy.asrs.domain.param.SystemSwitchParam;
+import com.zy.asrs.domain.vo.CrnDetailVo;
+import com.zy.asrs.domain.vo.CrnLatestDataVo;
+import com.zy.asrs.domain.vo.StationLatestDataVo;
+import com.zy.asrs.entity.BasCrnpErr;
import com.zy.asrs.entity.BasMap;
import com.zy.asrs.entity.DeviceConfig;
-import com.zy.asrs.entity.LocMast;
+import com.zy.asrs.entity.WrkMast;
+import com.zy.asrs.service.BasCrnpErrService;
import com.zy.asrs.service.BasMapService;
import com.zy.asrs.service.DeviceConfigService;
-import com.zy.asrs.service.LocMastService;
-import com.zy.asrs.utils.Utils;
+import com.zy.asrs.service.WrkMastService;
+import com.zy.common.CodeRes;
import com.zy.common.model.MapNode;
-import com.zy.common.model.NavigateNode;
import com.zy.common.model.enums.NavigationMapType;
-import com.zy.common.utils.NavigateMapData;
import com.zy.common.utils.RedisUtil;
import com.zy.core.cache.SlaveConnection;
+import com.zy.core.enums.CrnModeType;
import com.zy.core.enums.RedisKeyType;
import com.zy.core.enums.SlaveType;
-import com.zy.core.model.command.ShuttleRedisCommand;
-import com.zy.core.model.protocol.ShuttleProtocol;
+import com.zy.core.model.protocol.CrnProtocol;
+import com.zy.core.model.protocol.StationProtocol;
import com.zy.core.properties.SystemProperties;
-import com.zy.core.thread.ShuttleThread;
+import com.zy.core.thread.CrnThread;
+import com.zy.core.thread.StationThread;
+
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
-import javax.servlet.http.HttpServletRequest;
import java.util.*;
/**
* 涓绘帶鍥炬帴鍙�
- * Created by vincent on 2020-06-01
*/
@Slf4j
@RestController
@@ -43,39 +47,215 @@
public class ConsoleController {
@Autowired
+ private DeviceConfigService deviceConfigService;
+ @Autowired
+ private WrkMastService wrkMastService;
+ @Autowired
+ private BasCrnpErrService basCrnpErrService;
+ @Autowired
private BasMapService basMapService;
@Autowired
private RedisUtil redisUtil;
- @Autowired
- private NavigateMapData navigateMapData;
- @Autowired
- private LocMastService locMastService;
- @Autowired
- private DeviceConfigService deviceConfigService;
@PostMapping("/system/running/status")
@ManagerAuth(memo = "绯荤粺杩愯鐘舵��")
- public R systemRunningStatus(){
+ public R systemRunningStatus() {
return R.ok().add(Cools.add("status", SystemProperties.WCS_RUNNING_STATUS.get()));
}
@PostMapping("/system/switch")
@ManagerAuth(memo = "绯荤粺杩愯寮�鍏虫搷浣�")
public R systemSwitch(SystemSwitchParam param) throws InterruptedException {
- if (Cools.isEmpty(param.getOperatorType())){
+ if (Cools.isEmpty(param.getOperatorType())) {
return R.error();
}
if (param.getOperatorType() == 0) {
- if (Cools.isEmpty(param.getPassword())){
+ if (Cools.isEmpty(param.getPassword())) {
return R.error("璇疯緭鍏ュ彛浠�");
}
- if (!param.getPassword().equals(SystemProperties.WCS_PASSWORD)){
+ if (!param.getPassword().equals(SystemProperties.WCS_PASSWORD)) {
return R.error("鍙d护閿欒");
}
}
Thread.sleep(200L);
- SystemProperties.WCS_RUNNING_STATUS.set(param.getOperatorType()==1?Boolean.TRUE:Boolean.FALSE);
+ SystemProperties.WCS_RUNNING_STATUS.set(param.getOperatorType() == 1 ? Boolean.TRUE : Boolean.FALSE);
return R.ok().add(Cools.add("status", SystemProperties.WCS_RUNNING_STATUS.get()));
+ }
+
+ @PostMapping("/latest/data/station")
+ @ManagerAuth(memo = "绔欑偣瀹炴椂鏁版嵁")
+ public R stationLatestData() {
+ List<StationLatestDataVo> vos = new ArrayList<>();
+
+ List<DeviceConfig> devpList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
+ .eq("device_type", String.valueOf(SlaveType.Devp)));
+ for (DeviceConfig deviceConfig : devpList) {
+ StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp,
+ deviceConfig.getDeviceNo());
+ if (stationThread == null) {
+ continue;
+ }
+
+ List<StationProtocol> statusList = stationThread.getStatus();
+ if (statusList == null || statusList.isEmpty()) {
+ continue;
+ }
+ for (StationProtocol stationProtocol : statusList) {
+ StationLatestDataVo vo = new StationLatestDataVo();
+ vo.setStationId(stationProtocol.getStationId()); // 绔欑偣缂栧彿
+ vo.setTaskNo(stationProtocol.getTaskNo()); // 浠诲姟鍙�
+ vo.setTargetStaNo(stationProtocol.getTargetStaNo()); // 鐩爣绔欑偣
+ vo.setAutoing(stationProtocol.isAutoing()); // 鏄惁鑷姩
+ vo.setLoading(stationProtocol.isLoading()); // 鏄惁鏈夌墿
+ vo.setInEnable(stationProtocol.isInEnable()); // 鏄惁鍙叆
+ vo.setOutEnable(stationProtocol.isOutEnable()); // 鏄惁鍙嚭
+ vo.setEmptyMk(stationProtocol.isEmptyMk()); // 鏄惁绌烘澘
+ vo.setFullPlt(stationProtocol.isFullPlt()); // 鏄惁婊℃澘
+ vo.setPalletHeight(stationProtocol.getPalletHeight()); // 鎵樼洏楂樺害
+ vo.setError(stationProtocol.getError()); // 閿欒鐮�
+ vo.setBarcode(stationProtocol.getBarcode()); // 鏉$爜
+ String stationStatus = StationStatusType.process(stationProtocol).toString().toLowerCase().replaceAll("_", "-");
+ vo.setStationStatus(stationStatus);
+ vos.add(vo);
+ }
+
+ }
+ return R.ok().add(vos);
+ }
+
+ @PostMapping("/latest/data/crn")
+ @ManagerAuth(memo = "鍫嗗灈鏈哄疄鏃舵暟鎹�")
+ public R crnLatestData() {
+ List<CrnLatestDataVo> vos = new ArrayList<>();
+
+ List<DeviceConfig> crnList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
+ .eq("device_type", String.valueOf(SlaveType.Crn)));
+ for (DeviceConfig deviceConfig : crnList) {
+ // 鑾峰彇鍫嗗灈鏈轰俊鎭�
+ CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, deviceConfig.getDeviceNo());
+ if (crnThread == null) {
+ continue;
+ }
+
+ CrnProtocol crnProtocol = crnThread.getStatus();
+ if (crnProtocol == null) {
+ continue;
+ }
+ CrnLatestDataVo vo = new CrnLatestDataVo();
+ vo.setCrnId(crnProtocol.getCrnNo()); // 鍫嗗灈鏈虹紪鍙�
+
+ vo.setOffset((double) new Random().nextInt(560)); // 鍫嗗灈鏈哄亸绉婚噺
+ vo.setBay(crnProtocol.getBay()); // 褰撳墠鍒�
+ /**
+ * 鍫嗗灈鏈虹姸鎬佸垽鏂�
+ */
+ if (crnProtocol.getAlarm() > 0) {
+ vo.setCrnStatus(CrnStatusType.MACHINE_ERROR);
+ } else {
+ if (crnProtocol.getTaskNo() > 0) {
+ WrkMast wrkMast = wrkMastService.selectById(crnProtocol.getTaskNo());
+ if (wrkMast != null) {
+ vo.setCrnStatus(CrnStatusType.process(wrkMast.getIoType()));
+ } else {
+ vo.setCrnStatus(crnProtocol.modeType.equals(CrnModeType.AUTO) ? CrnStatusType.MACHINE_AUTO
+ : CrnStatusType.MACHINE_UN_AUTO);
+ }
+ } else {
+ vo.setCrnStatus(crnProtocol.modeType.equals(CrnModeType.AUTO) ? CrnStatusType.MACHINE_AUTO
+ : CrnStatusType.MACHINE_UN_AUTO);
+ }
+ }
+ vos.add(vo);
+ }
+ return R.ok().add(vos);
+ }
+
+ // @PostMapping("/latest/data/rgv")
+ // @ManagerAuth(memo = "RGV瀹炴椂鏁版嵁")
+ // public R rgvLatestData(){
+ // List<RgvLatestDataVo> vos = new ArrayList<>();
+ // for (RgvSlave rgvSlave : slaveProperties.getRgv()) {
+ // // 鑾峰彇鍫嗗灈鏈轰俊鎭�
+ // RgvThread rgvThread = (RgvThread) SlaveConnection.get(SlaveType.Rgv,
+ // rgvSlave.getId());
+ // if (rgvThread == null) {
+ // continue;
+ // }
+ // RgvProtocol rgvProtocol = rgvThread.getRgvProtocol();
+ // if (rgvProtocol == null) {
+ // continue;
+ // }
+ // RgvLatestDataVo vo = new RgvLatestDataVo();
+ // vo.setRgvId(rgvProtocol.getRgvNo()); // RGV缂栧彿
+ // vo.setTrackSiteNo(String.valueOf(rgvProtocol.getRgvPos()));
+ // vo.setRgvStatus(rgvProtocol.getStatusType());
+ // vos.add(vo);
+ //
+ // }
+ // Object object = redisUtil.get("rgvLatestData");
+ // List<Object> siteLatestDataVos = JSON.parseArray(object.toString());
+ // return R.ok().add(siteLatestDataVos);
+ // }
+
+ // @PostMapping("/latest/data/barcode")
+ // @ManagerAuth(memo = "鏉$爜鎵弿浠疄鏃舵暟鎹�")
+ // public R barcodeLatestData(){
+ // List<BarcodeDataVo> list = new ArrayList<>();
+ // for (Slave barcode : slaveProperties.getBarcode()) {
+ // BarcodeThread barcodeThread = (BarcodeThread)
+ // SlaveConnection.get(SlaveType.Barcode, barcode.getId());
+ // if (null == barcodeThread) {
+ // continue;
+ // }
+ // BarcodeDataVo vo = new BarcodeDataVo();
+ // vo.setBarcodeId(barcode.getId());
+ // vo.setCodeValue(barcodeThread.getBarcode());
+ // list.add(vo);
+ // }
+ // return R.ok().add(list);
+ // }
+
+ @PostMapping("/crn/detail")
+ @ManagerAuth(memo = "鍫嗗灈鏈鸿澶囨暟鎹鎯�")
+ public R crnDetail(@RequestParam Integer crnNo) {
+ if (Cools.isEmpty(crnNo)) {
+ return R.parse(CodeRes.EMPTY);
+ }
+ CrnDetailVo vo = new CrnDetailVo();
+
+ DeviceConfig deviceConfig = deviceConfigService.selectOne(new EntityWrapper<DeviceConfig>()
+ .eq("device_type", String.valueOf(SlaveType.Crn))
+ .eq("device_no", crnNo));
+
+ if (deviceConfig == null) {
+ return R.error("璁惧涓嶅瓨鍦�");
+ }
+
+ CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crnNo);
+ CrnProtocol crnProtocol = crnThread.getStatus();
+ vo.setCrnNo(crnNo);
+ vo.setWorkNo(crnProtocol.getTaskNo());
+ vo.setCrnStatus(crnProtocol.getStatusType().desc);
+
+ if (crnProtocol.getAlarm() > 0) {
+ BasCrnpErr crnError = basCrnpErrService.selectById(crnProtocol.getAlarm());
+ vo.setError(crnError == null ? "鏈煡寮傚父" : crnError.getErrName());
+ }
+
+ if (crnProtocol.getTaskNo() > 0) {
+ WrkMast wrkMast = wrkMastService.selectById(crnProtocol.getTaskNo());
+ if (wrkMast != null) {
+ vo.setSourceStaNo(String.valueOf(wrkMast.getSourceStaNo()));
+ vo.setStaNo(String.valueOf(wrkMast.getStaNo()));
+ vo.setWrkSts(wrkMast.getWrkSts$()); // 宸ヤ綔鐘舵��
+ vo.setIoType(wrkMast.getIoType$()); // 鍏ュ嚭搴撶被鍨�
+ vo.setSourceLocNo(wrkMast.getSourceLocNo$());
+ vo.setLocNo(wrkMast.getLocNo$());
+ vo.setCrnStatus(crnProtocol.getStatusType().desc);
+ vo.setError(""); // todo
+ }
+ }
+ return R.ok().add(vo);
}
/**
@@ -103,167 +283,7 @@
return R.error();
}
- List<List<MapNode>> arrayList = (List<List<MapNode>>) data;
- List<List<MapNode>> lists = navigateMapData.filterMap(NavigationMapType.getMapTypes(NavigationMapType.NONE, NavigationMapType.PATH_LOCK), arrayList, lev, null, null);//杩囨护鍦板浘鏁版嵁
- return R.ok().add(lists);
- }
-
- /**
- * 鑾峰彇搴撲綅鍦板浘鏁版嵁
- */
- @GetMapping("/locMap/{lev}/auth")
- @ManagerAuth
- public R getLocMap(@PathVariable Integer lev) {
- Object data = redisUtil.get(RedisKeyType.MAP.key + lev);
- if (data == null) {
- return R.error();
- }
-
- List<List<MapNode>> arrayList = (List<List<MapNode>>) data;
- List<List<MapNode>> lists = navigateMapData.filterMap(NavigationMapType.getMapTypes(NavigationMapType.NONE), arrayList, lev, null, null);//杩囨护鍦板浘鏁版嵁
-
- //鑾峰彇褰撳墠妤煎眰搴撲綅鏁版嵁
- List<LocMast> locMasts = locMastService.selectLocByLev(lev);
- for (LocMast locMast : locMasts) {
- Integer row = locMast.getRow1();
- Integer bay = locMast.getBay1();
-
- List<MapNode> list = lists.get(row);
- MapNode mapNode = list.get(bay);
-
- mapNode.setLocSts(locMast.getLocSts());
- mapNode.setLocNo(locMast.getLocNo());
-
- //鏇存柊list
- list.set(bay, mapNode);
- lists.set(row, list);
- }
- return R.ok().add(lists);
- }
-
- /**
- * 閲嶇疆redis涓殑鍦板浘锛屽皢鍗犵敤鐨勫簱浣嶅叏閮ㄨВ闄�
- */
- @GetMapping("/map/resetMap/auth")
- @ManagerAuth
- public R resetMapToRedis() {
- List<BasMap> basMaps = basMapService.selectList(new EntityWrapper<BasMap>().orderBy("lev", true));
- for (BasMap basMap : basMaps) {
- Integer lev = basMap.getLev();
- redisUtil.del(RedisKeyType.MAP.key + lev);
- }
return R.ok();
- }
-
- /**
- * 閲嶇疆redis涓殑鍦板浘锛屽皢鍗犵敤鐨勫簱浣嶅叏閮ㄨВ闄�
- */
- @GetMapping("/map/resetMap/{lev}")
- @ManagerAuth(memo = "閲嶇疆Redis鍦板浘")
- public R resetMapToRedisByLev(@PathVariable Integer lev, HttpServletRequest request) {
- redisUtil.del(RedisKeyType.MAP.key + lev);
- return R.ok();
- }
-
- /**
- * 鑾峰彇棰勮璺緞
- */
- @GetMapping("/getMoveAdvancePath/{lev}/auth")
- @ManagerAuth
- public R getMoveAdvancePath(@PathVariable Integer lev) {
- HashMap<String, Object> pathMap = new HashMap<>();
-
- List<DeviceConfig> shuttleList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
- .eq("device_type", String.valueOf(SlaveType.Shuttle)));
- for (DeviceConfig deviceConfig : shuttleList) {
- // 鑾峰彇鍥涘悜绌挎杞︿俊鎭�
- ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, deviceConfig.getDeviceNo());
- if (shuttleThread == null) {
- continue;
- }
- ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
- if (shuttleProtocol == null || shuttleProtocol.getShuttleNo()==null) {
- continue;
- }
-
- if (shuttleProtocol.getCurrentLocNo() == null) {
- continue;
- }
-
- if (Utils.getLev(shuttleProtocol.getCurrentLocNo()) != lev) {
- continue;
- }
-
- if (shuttleProtocol.getTaskNo() == 0) {
-
- }
-
- //瀛樺湪浠诲姟锛岃幏鍙栨寚浠�
- Object object = redisUtil.get(RedisKeyType.SHUTTLE_WORK_FLAG.key + shuttleProtocol.getTaskNo());
- if (object != null) {
- ShuttleRedisCommand redisCommand = JSON.parseObject(object.toString(), ShuttleRedisCommand.class);
- List<NavigateNode> nodes = redisCommand.getAssignCommand().getNodes();//绌挎杞﹂璁¤矾寰�
-
- for (NavigateNode node : nodes) {
- String locNo = Utils.getLocNo(node.getX(), node.getY(), node.getZ());
-
- List<Integer> shuttleNoList = new ArrayList<>();
- Object tmp = pathMap.get(locNo);
- if(tmp != null) {
- shuttleNoList = (List<Integer>) tmp;
- }
-
- if (!shuttleNoList.contains(shuttleProtocol.getShuttleNo())) {
- shuttleNoList.add(shuttleProtocol.getShuttleNo());
- }
-
- pathMap.put(locNo, shuttleNoList);
- }
- }
- }
-
- List<HashMap<String, Object>> pathList = new ArrayList<>();
- for (Map.Entry<String, Object> entry : pathMap.entrySet()) {
- String locNo = entry.getKey();
- Object shuttleNoList = entry.getValue();
-
- HashMap<String, Object> map = new HashMap<>();
- map.put("locNo", locNo);
- map.put("x", Utils.getRow(locNo));
- map.put("y", Utils.getBay(locNo));
- map.put("z", Utils.getLev(locNo));
- map.put("shuttleNoList", shuttleNoList);
- pathList.add(map);
- }
- return R.ok().add(pathList);
- }
-
- /**
- * 鑾峰彇閿佸畾璺緞
- */
- @GetMapping("/getLockPath/{lev}/auth")
- @ManagerAuth
- public R getLockPath(@PathVariable Integer lev) {
- HashMap<String, Object> lockMap = new HashMap<>();
- Object o = redisUtil.get(RedisKeyType.LOCK_MAP_NODES.key + lev);
- if (o != null) {
- lockMap = (HashMap<String, Object>) o;
- }
-
- List<HashMap<String, Object>> lockList = new ArrayList<>();
- for (Map.Entry<String, Object> entry : lockMap.entrySet()) {
- String locNo = entry.getKey();
- Object shuttleNo = entry.getValue();
-
- HashMap<String, Object> map = new HashMap<>();
- map.put("locNo", locNo);
- map.put("x", Utils.getRow(locNo));
- map.put("y", Utils.getBay(locNo));
- map.put("z", Utils.getLev(locNo));
- map.put("shuttleNo", shuttleNo);
- lockList.add(map);
- }
- return R.ok().add(lockList);
}
}
--
Gitblit v1.9.1