From 08cd84454ec525569c606e81a643fa8dc5759a35 Mon Sep 17 00:00:00 2001
From: Junjie <DELL@qq.com>
Date: 星期四, 25 十二月 2025 14:01:30 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/asrs/controller/ConsoleController.java | 97 +++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 87 insertions(+), 10 deletions(-)
diff --git a/src/main/java/com/zy/asrs/controller/ConsoleController.java b/src/main/java/com/zy/asrs/controller/ConsoleController.java
index 4f9560e..466a081 100644
--- a/src/main/java/com/zy/asrs/controller/ConsoleController.java
+++ b/src/main/java/com/zy/asrs/controller/ConsoleController.java
@@ -1,8 +1,10 @@
package com.zy.asrs.controller;
import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
+import com.baomidou.mybatisplus.plugins.Page;
import com.core.annotations.ManagerAuth;
import com.core.common.Cools;
import com.core.common.R;
@@ -15,21 +17,16 @@
import com.zy.asrs.domain.vo.RgvLatestDataVo;
import com.zy.asrs.entity.*;
import com.zy.asrs.service.*;
-import com.zy.asrs.utils.Utils;
import com.zy.common.CodeRes;
-import com.zy.common.model.MapNode;
import com.zy.common.utils.RedisUtil;
-import com.zy.core.News;
import com.zy.core.cache.SlaveConnection;
-import com.zy.core.enums.CrnModeType;
-import com.zy.core.enums.MapNodeType;
-import com.zy.core.enums.RedisKeyType;
-import com.zy.core.enums.RgvStatusType;
-import com.zy.core.enums.SlaveType;
+import com.zy.core.enums.*;
import com.zy.core.model.protocol.CrnProtocol;
+import com.zy.core.model.protocol.DualCrnProtocol;
import com.zy.core.model.protocol.StationProtocol;
import com.zy.core.properties.SystemProperties;
import com.zy.core.thread.CrnThread;
+import com.zy.core.thread.DualCrnThread;
import com.zy.core.thread.StationThread;
import com.zy.core.thread.RgvThread;
import com.zy.core.model.protocol.RgvProtocol;
@@ -55,7 +52,7 @@
@Autowired
private BasCrnpErrService basCrnpErrService;
@Autowired
- private BasMapService basMapService;
+ private WrkLastnoService wrkLastnoService;
@Autowired
private RedisUtil redisUtil;
@Autowired
@@ -91,6 +88,9 @@
public R stationLatestData() {
List<StationLatestDataVo> vos = new ArrayList<>();
+ WrkLastno inTaskRange = wrkLastnoService.selectById(WrkIoType.IN.id);
+ WrkLastno outTaskRange = wrkLastnoService.selectById(WrkIoType.OUT.id);
+
List<DeviceConfig> devpList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
.eq("device_type", String.valueOf(SlaveType.Devp)));
for (DeviceConfig deviceConfig : devpList) {
@@ -115,16 +115,43 @@
vo.setOutEnable(stationProtocol.isOutEnable()); // 鏄惁鍙嚭
vo.setEmptyMk(stationProtocol.isEmptyMk()); // 鏄惁绌烘澘
vo.setFullPlt(stationProtocol.isFullPlt()); // 鏄惁婊℃澘
+ vo.setRunBlock(stationProtocol.isRunBlock());// 杩愯鍫靛
vo.setPalletHeight(stationProtocol.getPalletHeight()); // 鎵樼洏楂樺害
vo.setError(stationProtocol.getError()); // 閿欒鐮�
vo.setBarcode(stationProtocol.getBarcode()); // 鏉$爜
String stationStatus = StationStatusType.process(stationProtocol).toString().toLowerCase().replaceAll("_", "-");
+ if (stationProtocol.isAutoing() && stationProtocol.isLoading() && stationProtocol.getTaskNo() > 0 && !stationProtocol.isRunBlock()) {
+ String taskClass = getStationTaskClass(stationProtocol.getTaskNo(), inTaskRange, outTaskRange);
+ if (taskClass != null) {
+ stationStatus = taskClass;
+ }
+ }
vo.setStationStatus(stationStatus);
vos.add(vo);
}
}
return R.ok().add(vos);
+ }
+
+ private String getStationTaskClass(Integer taskNo, WrkLastno inTaskRange, WrkLastno outTaskRange) {
+ if (taskNo == null || taskNo <= 0) {
+ return null;
+ }
+ if (isInRange(taskNo, inTaskRange)) {
+ return "machine-pakin";
+ }
+ if (isInRange(taskNo, outTaskRange)) {
+ return "machine-pakout";
+ }
+ return null;
+ }
+
+ private boolean isInRange(Integer taskNo, WrkLastno taskRange) {
+ if (taskRange == null || taskRange.getSNo() == null || taskRange.getENo() == null) {
+ return false;
+ }
+ return taskNo >= taskRange.getSNo() && taskNo <= taskRange.getENo();
}
@PostMapping("/latest/data/crn")
@@ -148,8 +175,10 @@
CrnLatestDataVo vo = new CrnLatestDataVo();
vo.setCrnId(crnProtocol.getCrnNo()); // 鍫嗗灈鏈虹紪鍙�
- vo.setOffset((double) new Random().nextInt(560)); // 鍫嗗灈鏈哄亸绉婚噺
+ // 浣跨敤瀹為檯鍒楀�间綔涓哄亸绉诲弬鑰冿紝閬垮厤闅忔満鍧愭爣瀵艰嚧鐣岄潰婕傜Щ
+ vo.setOffset(Double.valueOf(crnProtocol.getBay()));
vo.setBay(crnProtocol.getBay()); // 褰撳墠鍒�
+ vo.setTaskNo(crnProtocol.getTaskNo());
/**
* 鍫嗗灈鏈虹姸鎬佸垽鏂�
*/
@@ -174,6 +203,39 @@
return R.ok().add(vos);
}
+ @PostMapping("/latest/data/dualcrn")
+ @ManagerAuth(memo = "鍙屽伐浣嶅爢鍨涙満瀹炴椂鏁版嵁")
+ public R dualCrnLatestData() {
+ List<CrnLatestDataVo> vos = new ArrayList<>();
+ List<DeviceConfig> dualCrnList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
+ .eq("device_type", String.valueOf(SlaveType.DualCrn)));
+ for (DeviceConfig deviceConfig : dualCrnList) {
+ DualCrnThread crnThread = (DualCrnThread) SlaveConnection.get(SlaveType.DualCrn, deviceConfig.getDeviceNo());
+ if (crnThread == null) { continue; }
+ DualCrnProtocol p = crnThread.getStatus();
+ if (p == null) { continue; }
+ CrnLatestDataVo vo = new CrnLatestDataVo();
+ vo.setCrnId(p.getCrnNo());
+ Integer bay = p.getBay() != null ? p.getBay() : p.getBayTwo();
+ vo.setOffset(bay == null ? 0.0 : Double.valueOf(bay));
+ vo.setBay(bay);
+ Integer taskNo = (p.getTaskNo() != null && p.getTaskNo() > 0) ? p.getTaskNo()
+ : ((p.getTaskNoTwo() != null && p.getTaskNoTwo() > 0) ? p.getTaskNoTwo() : 0);
+ vo.setTaskNo(taskNo);
+ if (p.getAlarm() != null && p.getAlarm() > 0) {
+ vo.setCrnStatus(CrnStatusType.MACHINE_ERROR);
+ } else {
+ if (taskNo != null && taskNo > 0) {
+ vo.setCrnStatus(p.getModeType() == DualCrnModeType.AUTO ? CrnStatusType.MACHINE_AUTO : CrnStatusType.MACHINE_UN_AUTO);
+ } else {
+ vo.setCrnStatus(p.getModeType() == DualCrnModeType.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(){
@@ -191,6 +253,7 @@
}
RgvLatestDataVo vo = new RgvLatestDataVo();
vo.setRgvNo(rgvProtocol.getRgvNo());
+ vo.setTaskNo(rgvProtocol.getTaskNo());
vo.setTrackSiteNo(String.valueOf(rgvProtocol.getRgvPos()));
vo.setRgvStatus(RgvStatusType.get(rgvProtocol.getStatus()));
vos.add(vo);
@@ -289,4 +352,18 @@
return R.ok().add(mapNodeList);
}
+ @RequestMapping(value = "/map/locList")
+ public R mapLocList() {
+ Object object = redisUtil.get(RedisKeyType.LOC_MAST_MAP_LIST.key);
+ if (object != null) {
+ JSONArray data = JSON.parseArray(object.toString());
+ return R.ok().add(data);
+ }
+ EntityWrapper<LocMast> wrapper = new EntityWrapper<>();
+ wrapper.eq("lev1", 1);
+ List<LocMast> locMasts = locMastService.selectList(wrapper);
+ redisUtil.set(RedisKeyType.LOC_MAST_MAP_LIST.key, JSON.toJSONString(locMasts), 60 * 60 * 24);
+ return R.ok().add(locMasts);
+ }
+
}
--
Gitblit v1.9.1