From 7635dc25bd2a4d565df496b2d96354639966768d Mon Sep 17 00:00:00 2001
From: Junjie <xjj@123>
Date: 星期四, 25 九月 2025 11:09:44 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/asrs/controller/OpenController.java | 409 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 408 insertions(+), 1 deletions(-)
diff --git a/src/main/java/com/zy/asrs/controller/OpenController.java b/src/main/java/com/zy/asrs/controller/OpenController.java
index b8b27d5..fd3e4f6 100644
--- a/src/main/java/com/zy/asrs/controller/OpenController.java
+++ b/src/main/java/com/zy/asrs/controller/OpenController.java
@@ -1,16 +1,40 @@
package com.zy.asrs.controller;
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.common.R;
-import com.zy.asrs.domain.NotifyDto;
+import com.zy.asrs.domain.ShuttleGatherResult;
import com.zy.asrs.domain.enums.NotifyMsgType;
import com.zy.asrs.domain.param.*;
+import com.zy.asrs.entity.ApiLog;
+import com.zy.asrs.entity.DeviceConfig;
+import com.zy.asrs.entity.LocMast;
+import com.zy.asrs.entity.WrkMast;
+import com.zy.asrs.service.ApiLogService;
+import com.zy.asrs.service.DeviceConfigService;
+import com.zy.asrs.service.LocMastService;
+import com.zy.asrs.service.WrkMastService;
import com.zy.asrs.utils.NotifyUtils;
+import com.zy.common.annotations.OpenApiLog;
import com.zy.common.service.CommonService;
+import com.zy.core.cache.SlaveConnection;
import com.zy.core.dispatcher.ShuttleDispatchUtils;
import com.zy.core.enums.SlaveType;
+import com.zy.core.enums.WrkIoType;
+import com.zy.core.model.protocol.ForkLiftProtocol;
+import com.zy.core.model.protocol.LiftProtocol;
+import com.zy.core.model.protocol.ShuttleProtocol;
+import com.zy.core.thread.ForkLiftThread;
+import com.zy.core.thread.LiftThread;
+import com.zy.core.thread.ShuttleThread;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
@Slf4j
@RestController
@@ -23,13 +47,38 @@
private ShuttleDispatchUtils shuttleDispatchUtils;
@Autowired
private NotifyUtils notifyUtils;
+ @Autowired
+ private ApiLogService apiLogService;
+ @Autowired
+ private LocMastService locMastService;
+ @Autowired
+ private WrkMastService wrkMastService;
+ @Autowired
+ private DeviceConfigService deviceConfigService;
@PostMapping("/createMoveTask")
+ @OpenApiLog(memo = "灏忚溅绉诲姩浠诲姟")
public R createMoveTask(@RequestBody CreateMoveTaskParam param) {
if (param == null) {
return R.error("鍙傛暟涓嶈兘涓虹┖");
}
boolean dispatchShuttle = shuttleDispatchUtils.dispatchShuttle(null, param.getLocNo(), param.getShuttleNo());
+ apiLogService.insert(new ApiLog(
+ null
+ , "灏忚溅绉诲姩浠诲姟"
+ , "/createMoveTask"
+ , null
+ , null
+ , null
+ , JSON.toJSONString(param)
+ , null
+ , null
+ , dispatchShuttle ? 1 : 0
+ , 1
+ , new Date()
+ , null
+ , null
+ ));
if (dispatchShuttle) {
return R.ok();
}
@@ -38,11 +87,28 @@
//绉诲簱浠诲姟
@PostMapping("/createLocMoveTask")
+ @OpenApiLog(memo = "绉诲簱浠诲姟")
public R createLocMoveTask(@RequestBody CreateLocMoveTaskParam param) {
if (param == null) {
return R.error("鍙傛暟涓嶈兘涓虹┖");
}
boolean result = commonService.createLocMoveTask(param);
+ apiLogService.insert(new ApiLog(
+ null
+ , "绉诲簱浠诲姟"
+ , "/createLocMoveTask"
+ , null
+ , null
+ , null
+ , JSON.toJSONString(param)
+ , null
+ , null
+ , result ? 1 : 0
+ , 1
+ , new Date()
+ , null
+ , null
+ ));
if (result) {
return R.ok();
}
@@ -51,11 +117,28 @@
//鍏ュ簱浠诲姟
@PostMapping("/createInTask")
+ @OpenApiLog(memo = "鍏ュ簱浠诲姟")
public R createInTask(@RequestBody CreateInTaskParam param) {
if (param == null) {
return R.error("鍙傛暟涓嶈兘涓虹┖");
}
boolean result = commonService.createInTask(param);
+ apiLogService.insert(new ApiLog(
+ null
+ , "鍏ュ簱浠诲姟"
+ , "/createInTask"
+ , null
+ , null
+ , null
+ , JSON.toJSONString(param)
+ , null
+ , null
+ , result ? 1 : 0
+ , 1
+ , new Date()
+ , null
+ , null
+ ));
if (result) {
return R.ok();
}
@@ -64,11 +147,28 @@
//鍑哄簱浠诲姟
@PostMapping("/createOutTask")
+ @OpenApiLog(memo = "鍑哄簱浠诲姟")
public R createOutTask(@RequestBody CreateOutTaskParam param) {
if (param == null) {
return R.error("鍙傛暟涓嶈兘涓虹┖");
}
boolean result = commonService.createOutTask(param);
+ apiLogService.insert(new ApiLog(
+ null
+ , "鍑哄簱浠诲姟"
+ , "/createOutTask"
+ , null
+ , null
+ , null
+ , JSON.toJSONString(param)
+ , null
+ , null
+ , result ? 1 : 0
+ , 1
+ , new Date()
+ , null
+ , null
+ ));
if (result) {
return R.ok();
}
@@ -76,11 +176,28 @@
}
@PostMapping("/completeTask")
+ @OpenApiLog(memo = "浠诲姟瀹屾垚")
public R completeTask(@RequestBody CompleteTaskParam param) {
if (param == null) {
return R.error("鍙傛暟涓嶈兘涓虹┖");
}
boolean completeTask = commonService.completeTask(param);
+ apiLogService.insert(new ApiLog(
+ null
+ , "浠诲姟瀹屾垚"
+ , "/completeTask"
+ , null
+ , null
+ , null
+ , JSON.toJSONString(param)
+ , null
+ , null
+ , completeTask ? 1 : 0
+ , 1
+ , new Date()
+ , null
+ , null
+ ));
if (completeTask) {
return R.ok();
}
@@ -88,17 +205,307 @@
}
@PostMapping("/cancelTask")
+ @OpenApiLog(memo = "浠诲姟鍙栨秷")
public R cancelTask(@RequestBody CancelTaskParam param) {
if (param == null) {
return R.error("鍙傛暟涓嶈兘涓虹┖");
}
boolean completeTask = commonService.cancelTask(param);
+ apiLogService.insert(new ApiLog(
+ null
+ , "浠诲姟鍙栨秷"
+ , "/cancelTask"
+ , null
+ , null
+ , null
+ , JSON.toJSONString(param)
+ , null
+ , null
+ , completeTask ? 1 : 0
+ , 1
+ , new Date()
+ , null
+ , null
+ ));
if (completeTask) {
return R.ok();
}
return R.error("浠诲姟鍙栨秷澶辫触");
}
+ @RequestMapping("/deviceStatus")
+ @OpenApiLog(memo = "鑾峰彇璁惧鐘舵��")
+ public R getDeviceStatus() {
+ HashMap<String, Object> map = new HashMap<>();
+ //鑾峰彇灏忚溅鏁版嵁
+ ArrayList<ShuttleProtocol> shuttleProtocols = new ArrayList<>();
+ List<DeviceConfig> shuttleList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
+ .eq("device_type", String.valueOf(SlaveType.Shuttle)));
+ for (DeviceConfig device : shuttleList) {
+ ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getDeviceNo());
+ if (shuttleThread == null) {
+ continue;
+ }
+
+ ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
+ if (shuttleProtocol == null) {
+ continue;
+ }
+ shuttleProtocols.add(shuttleProtocol);
+ }
+
+ //鑾峰彇璐у弶鎻愬崌鏈烘暟鎹�
+ ArrayList<ForkLiftProtocol> forkLiftProtocols = new ArrayList<>();
+ List<DeviceConfig> forkLiftList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
+ .eq("device_type", String.valueOf(SlaveType.ForkLift)));
+ for (DeviceConfig device : forkLiftList) {
+ ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, device.getDeviceNo());
+ if (forkLiftThread == null) {
+ continue;
+ }
+
+ ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus();
+ if (forkLiftProtocol == null) {
+ continue;
+ }
+ forkLiftProtocols.add(forkLiftProtocol);
+ }
+
+ //鑾峰彇鎻愬崌鏈烘暟鎹�
+ ArrayList<LiftProtocol> liftProtocols = new ArrayList<>();
+ List<DeviceConfig> liftList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
+ .eq("device_type", String.valueOf(SlaveType.Lift)));
+ for (DeviceConfig device : liftList) {
+ LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, device.getDeviceNo());
+ if (liftThread == null) {
+ continue;
+ }
+
+ LiftProtocol liftProtocol = liftThread.getStatus();
+ if (liftProtocol == null) {
+ continue;
+ }
+ liftProtocols.add(liftProtocol);
+ }
+
+ map.put("shuttle", shuttleProtocols);
+ map.put("forkLift", forkLiftProtocols);
+ map.put("lift", liftProtocols);
+
+ apiLogService.insert(new ApiLog(
+ null
+ , "鑾峰彇璁惧鐘舵��"
+ , "/deviceStatus"
+ , null
+ , null
+ , null
+ , null
+ , JSON.toJSONString(map)
+ , null
+ , null
+ , 1
+ , new Date()
+ , null
+ , null
+ ));
+
+ return R.ok().add(map);
+ }
+
+ @RequestMapping("/liftDeviceOriginData")
+ @OpenApiLog(memo = "鑾峰彇鎻愬崌鏈哄師濮嬫暟鎹�")
+ public R getLiftDeviceOriginData() {
+ HashMap<Integer, String> map = new HashMap<>();
+
+ //鑾峰彇鎻愬崌鏈烘暟鎹�
+ List<DeviceConfig> liftList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
+ .eq("device_type", String.valueOf(SlaveType.Lift)));
+ for (DeviceConfig device : liftList) {
+ LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, device.getDeviceNo());
+ if (liftThread == null) {
+ continue;
+ }
+
+ map.put(device.getDeviceNo(), liftThread.getRealtimeOriginData());
+ }
+
+ apiLogService.insert(new ApiLog(
+ null
+ , "鑾峰彇鎻愬崌鏈哄師濮嬫暟鎹�"
+ , "/liftDeviceOriginData"
+ , null
+ , null
+ , null
+ , null
+ , JSON.toJSONString(map)
+ , null
+ , null
+ , 1
+ , new Date()
+ , null
+ , null
+ ));
+
+ return R.ok().add(map);
+ }
+
+ @PostMapping("/getLocInformation")
+ @OpenApiLog(memo = "鑾峰彇鎸囧畾搴撲綅淇℃伅")
+ public R getLocInformation(@RequestBody GetLocInformationParam param) {
+ if (param == null) {
+ return R.error("鍙傛暟涓嶈兘涓虹┖");
+ }
+ LocMast locMast = locMastService.queryByLoc(param.getLocNo());
+ if (locMast == null) {
+ return R.error("搴撲綅淇℃伅涓嶅瓨鍦�");
+ }
+
+ HashMap<String, Object> map = new HashMap<>();
+ map.put("locNo", locMast.getLocNo());
+ map.put("locSts", locMast.getLocSts());
+
+ apiLogService.insert(new ApiLog(
+ null
+ , "鑾峰彇鎸囧畾搴撲綅淇℃伅"
+ , "/getLocInformation"
+ , null
+ , null
+ , null
+ , JSON.toJSONString(param)
+ , JSON.toJSONString(map)
+ , null
+ , null
+ , 1
+ , new Date()
+ , null
+ , null
+ ));
+
+ return R.ok().add(map);
+ }
+
+ @PostMapping("/getAllLocInformation")
+ @OpenApiLog(memo = "鑾峰彇鍏ㄩ儴搴撲綅淇℃伅")
+ public R getAllLocInformation() {
+ List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>());
+ if (locMasts.isEmpty()) {
+ return R.error("搴撲綅淇℃伅涓嶅瓨鍦�");
+ }
+
+ ArrayList<HashMap<String, Object>> list = new ArrayList<>();
+ for (LocMast locMast : locMasts) {
+ HashMap<String, Object> map = new HashMap<>();
+ map.put("locNo", locMast.getLocNo());
+ map.put("locSts", locMast.getLocSts());
+ list.add(map);
+ }
+
+ apiLogService.insert(new ApiLog(
+ null
+ , "鑾峰彇鍏ㄩ儴搴撲綅淇℃伅"
+ , "/getAllLocInformation"
+ , null
+ , null
+ , null
+ , null
+ , JSON.toJSONString(list)
+ , null
+ , null
+ , 1
+ , new Date()
+ , null
+ , null
+ ));
+
+ return R.ok().add(list);
+ }
+
+ @PostMapping("/shuttleGather")
+ @OpenApiLog(memo = "灏忚溅闆嗗悎")
+ public R shuttleGather(@RequestBody ShuttleGatherParam param) {
+ List<ShuttleGatherResult> shuttleGather = shuttleDispatchUtils.shuttleGather(param);
+
+ apiLogService.insert(new ApiLog(
+ null
+ , "灏忚溅闆嗗悎"
+ , "/shuttleGather"
+ , null
+ , null
+ , null
+ , JSON.toJSONString(param)
+ , JSON.toJSONString(shuttleGather)
+ , null
+ , null
+ , 1
+ , new Date()
+ , null
+ , null
+ ));
+
+ return R.ok().add(shuttleGather);
+ }
+
+ @PostMapping("/shuttleDemo")
+ @OpenApiLog(memo = "灏忚溅婕旂ず")
+ public R shuttleDemo(@RequestBody ShuttleDemoParam param) {
+ shuttleDispatchUtils.shuttleDemo(param);
+
+ apiLogService.insert(new ApiLog(
+ null
+ , "灏忚溅婕旂ず"
+ , "/shuttleDemo"
+ , null
+ , null
+ , null
+ , JSON.toJSONString(param)
+ , null
+ , null
+ , null
+ , 1
+ , new Date()
+ , null
+ , null
+ ));
+
+ return R.ok();
+ }
+
+ @PostMapping("/queryTask")
+ @OpenApiLog(memo = "鏌ヨ浠诲姟")
+ public R queryTask(@RequestBody QueryTaskParam param) {
+ EntityWrapper<WrkMast> wrapper = new EntityWrapper<>();
+ if(param.getTaskNo() != null) {
+ wrapper.eq("wms_wrk_no", param.getTaskNo());
+ }
+
+ if(param.getTaskType() != null) {
+ WrkIoType ioType = WrkIoType.get(param.getTaskType());
+ if(ioType == null) {
+ return R.error("浠诲姟绫诲瀷涓嶅瓨鍦�");
+ }
+ wrapper.eq("io_type", ioType.id);
+ }
+ List<WrkMast> wrkMasts = wrkMastService.selectList(wrapper);
+ apiLogService.insert(new ApiLog(
+ null
+ , "鏌ヨ浠诲姟"
+ , "/queryTask"
+ , null
+ , null
+ , null
+ , JSON.toJSONString(param)
+ , JSON.toJSONString(wrkMasts)
+ , null
+ , null
+ , 1
+ , new Date()
+ , null
+ , null
+ ));
+
+ return R.ok().add(wrkMasts);
+ }
+
@GetMapping("/test")
public R test() {
notifyUtils.notify("task", 1, "9999", "W9999", NotifyMsgType.SHUTTLE_MOVING, "data");
--
Gitblit v1.9.1