From a40b871aa511865d1a7363c88ffb733f6b084d35 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期一, 02 三月 2026 17:14:15 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/asrs/controller/StationController.java | 90 +++++++++++++++++++++++++++++++++++++-------
1 files changed, 75 insertions(+), 15 deletions(-)
diff --git a/src/main/java/com/zy/asrs/controller/StationController.java b/src/main/java/com/zy/asrs/controller/StationController.java
index d232d99..75a7367 100644
--- a/src/main/java/com/zy/asrs/controller/StationController.java
+++ b/src/main/java/com/zy/asrs/controller/StationController.java
@@ -1,12 +1,18 @@
package com.zy.asrs.controller;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
+import com.zy.asrs.domain.param.StationCommandBarcodeParam;
import com.zy.asrs.entity.BasDevp;
+import com.zy.asrs.entity.DeviceConfig;
import com.zy.asrs.service.BasDevpService;
+import com.zy.asrs.service.DeviceConfigService;
import com.zy.common.utils.RedisUtil;
import com.zy.core.enums.RedisKeyType;
import com.zy.core.enums.StationCommandType;
import com.zy.core.model.StationObjModel;
+import com.zy.system.entity.Config;
+import com.zy.system.service.ConfigService;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@@ -29,10 +35,16 @@
@RequestMapping("/station")
public class StationController {
+ @Value("${mainProcessPlugin}")
+ private String mainProcessPlugin;
@Autowired
private BasDevpService basDevpService;
@Autowired
private RedisUtil redisUtil;
+ @Autowired
+ private ConfigService configService;
+ @Autowired
+ private DeviceConfigService deviceConfigService;
@PostMapping("/command/move")
public R commandMove(@RequestBody StationCommandMoveParam param) {
@@ -44,21 +56,7 @@
Integer taskNo = param.getTaskNo();
Integer targetStationId = param.getTargetStationId();
- StationObjModel finalStation = null;
- List<BasDevp> basDevps = basDevpService.selectList(new EntityWrapper<BasDevp>());
- for (BasDevp basDevp : basDevps) {
- List<StationObjModel> list = basDevp.getStationList$();
- for (StationObjModel entity : list) {
- if(entity.getStationId().equals(stationId)){
- finalStation = entity;
- break;
- }
- }
-
- if(finalStation != null){
- break;
- }
- }
+ StationObjModel finalStation = findStation(stationId);
if(finalStation == null){
return R.error("绔欑偣涓嶅瓨鍦�");
@@ -76,6 +74,51 @@
return R.ok();
}
+ @PostMapping("/command/barcode")
+ public R commandBarcode(@RequestBody StationCommandBarcodeParam param) {
+ if (Cools.isEmpty(param) || Cools.isEmpty(param.getStationId())) {
+ return R.error("缂哄皯鍙傛暟");
+ }
+
+ if (!mainProcessPlugin.contains("Fake")) {
+ return R.error("褰撳墠绯荤粺鏈惎鐢ㄤ豢鐪熸彃浠�");
+ }
+
+ Config enableFakeConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "enableFake"));
+ if (enableFakeConfig == null || !"Y".equals(enableFakeConfig.getValue())) {
+ return R.error("褰撳墠闈炰豢鐪熻繍琛屾ā寮忥紝绂佹淇敼鏉$爜");
+ }
+
+ Integer stationId = param.getStationId();
+ StationObjModel finalStation = findStation(stationId);
+ if (finalStation == null) {
+ return R.error("绔欑偣涓嶅瓨鍦�");
+ }
+
+ Integer devpNo = finalStation.getDeviceNo();
+ DeviceConfig deviceConfig = deviceConfigService.selectOne(new EntityWrapper<DeviceConfig>()
+ .eq("device_no", devpNo)
+ .eq("device_type", String.valueOf(SlaveType.Devp)));
+ if (deviceConfig == null || deviceConfig.getFake() == null || deviceConfig.getFake() != 1) {
+ return R.error("褰撳墠绔欑偣璁惧鏈惎鐢ㄤ豢鐪燂紝绂佹淇敼鏉$爜");
+ }
+
+ StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, devpNo);
+ if (stationThread == null) {
+ return R.error("绾跨▼涓嶅瓨鍦�");
+ }
+
+ String barcode = param.getBarcode();
+ if (barcode == null) {
+ barcode = "";
+ }
+
+ StationCommand command = stationThread.getCommand(StationCommandType.WRITE_INFO, 9997, stationId, stationId, 0);
+ command.setBarcode(barcode.trim());
+ MessageQueue.offer(SlaveType.Devp, devpNo, new Task(2, command));
+ return R.ok();
+ }
+
@PostMapping("/command/reset")
public R commandReset(@RequestBody StationCommandMoveParam param) {
if (Cools.isEmpty(param)) {
@@ -87,4 +130,21 @@
return R.ok();
}
+ private StationObjModel findStation(Integer stationId) {
+ if (Cools.isEmpty(stationId)) {
+ return null;
+ }
+
+ List<BasDevp> basDevps = basDevpService.selectList(new EntityWrapper<BasDevp>());
+ for (BasDevp basDevp : basDevps) {
+ List<StationObjModel> list = basDevp.getStationList$();
+ for (StationObjModel entity : list) {
+ if (entity.getStationId().equals(stationId)) {
+ return entity;
+ }
+ }
+ }
+ return null;
+ }
+
}
--
Gitblit v1.9.1