From 46ef1825a0fcbe8b042e31ac81b9e0d20f464661 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期一, 22 五月 2023 10:04:22 +0800
Subject: [PATCH] WMS任务完成、取消功能
---
src/main/java/com/zy/asrs/controller/SiteController.java | 177 ++++++++++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 146 insertions(+), 31 deletions(-)
diff --git a/src/main/java/com/zy/asrs/controller/SiteController.java b/src/main/java/com/zy/asrs/controller/SiteController.java
index ca3242f..bbcb229 100644
--- a/src/main/java/com/zy/asrs/controller/SiteController.java
+++ b/src/main/java/com/zy/asrs/controller/SiteController.java
@@ -1,21 +1,29 @@
package com.zy.asrs.controller;
+import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.annotations.ManagerAuth;
import com.core.common.R;
import com.zy.asrs.domain.vo.PlcErrorTableVo;
import com.zy.asrs.domain.vo.SiteTableVo;
+import com.zy.asrs.entity.BasDevp;
+import com.zy.asrs.service.BasDevpService;
+import com.zy.core.cache.MessageQueue;
+import com.zy.core.cache.OutputQueue;
import com.zy.core.cache.SlaveConnection;
import com.zy.core.enums.SlaveType;
import com.zy.core.model.DevpSlave;
+import com.zy.core.model.Task;
import com.zy.core.model.protocol.StaProtocol;
import com.zy.core.properties.SlaveProperties;
-import com.zy.core.thread.DevpThread;
+import com.zy.core.DevpThread;
+import com.zy.core.thread.SiemensDevpThread;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
/**
* 杈撻�佽澶囨帴鍙�
@@ -27,31 +35,52 @@
@Autowired
private SlaveProperties slaveProperties;
+ @Autowired
+ private BasDevpService basDevpService;
+
+ @GetMapping("/io/mode/info/site")
+ @ManagerAuth(memo = "鍏ュ嚭搴撴ā寮�")
+ public R ioMode(){
+ List<Map<String, Object>> res = new ArrayList<>();
+ for (DevpSlave devp : slaveProperties.getDevp()) {
+ SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
+ Map<String, Object> map2 = new HashMap<>();
+ map2.put("floor", 2);
+ map2.put("modeVal", devpThread.ioModeOf2F.id);
+ map2.put("modeDesc", devpThread.ioModeOf2F.desc);
+ res.add(map2);
+ }
+ return R.ok().add(res);
+ }
@PostMapping("/table/site")
@ManagerAuth(memo = "绔欑偣淇℃伅琛�")
public R siteTable(){
List<SiteTableVo> list = new ArrayList<>();
-
+ // 鍐呭瓨鏁版嵁
+ Map<Integer, StaProtocol> station = new HashMap<>();
for (DevpSlave devp : slaveProperties.getDevp()) {
DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
- Map<Integer, StaProtocol> station = devpThread.getStation();
- for (Map.Entry<Integer, StaProtocol> entry : station.entrySet()) {
- StaProtocol staProtocol = entry.getValue();
- SiteTableVo vo = new SiteTableVo();
-
- vo.setDevNo(entry.getKey()); // 绔欑偣缂栧彿
- vo.setWorkNo(staProtocol.getWorkNo()); // 宸ヤ綔鍙�
- vo.setAutoing(staProtocol.isAutoing()?"Y":"N"); // 鑷姩
- vo.setLoading(staProtocol.isLoading()?"Y":"N"); // 鏈夌墿
- vo.setInEnable(staProtocol.isInEnable()?"Y":"N"); // 鍙叆
- vo.setOutEnable(staProtocol.isOutEnable()?"Y":"N"); // 鍙嚭
- vo.setInreq1(staProtocol.isInreq1()?"Y":"N"); // 闇�姹�1
- vo.setEmptyMk(staProtocol.isEmptyMk()?"Y":"N"); // 绌烘澘淇″彿
- vo.setStaNo(staProtocol.getStaNo()); // 鐩爣绔�
-
- list.add(vo);
- }
+ station.putAll(devpThread.getStation());
+ }
+ // 鎸佷箙鏁版嵁
+ List<BasDevp> basDevps = basDevpService.selectList(new EntityWrapper<BasDevp>().orderBy("dev_no"));
+ for (BasDevp devp : basDevps) {
+ SiteTableVo vo = new SiteTableVo();
+ vo.setDevNo(devp.getDevNo()); // 绔欑偣缂栧彿
+ list.add(vo);
+ StaProtocol staProtocol = station.get(devp.getDevNo());
+ if (null == staProtocol) { continue; }
+ vo.setWorkNo(staProtocol.getWorkNo()); // 宸ヤ綔鍙�
+ vo.setAutoing(staProtocol.isAutoing()?"Y":"N"); // 鑷姩
+ vo.setLoading(staProtocol.isLoading()?"Y":"N"); // 鏈夌墿
+ vo.setInEnable(staProtocol.isInEnable()?"Y":"N"); // 鍙叆
+ vo.setOutEnable(staProtocol.isOutEnable()?"Y":"N"); // 鍙嚭
+ vo.setPakMk(staProtocol.isPakMk()?"Y":"N"); // 鍏ュ簱鏍囪
+ vo.setEmptyMk(staProtocol.isEmptyMk()?"Y":"N"); // 绌烘澘淇″彿
+ vo.setStaNo(staProtocol.getStaNo()); // 鐩爣绔�
+// vo.setLocType1(staProtocol.isHigh() != staProtocol.isLow() && staProtocol.isLow() ? "浣�" : "楂�"); //楂樹綆搴撲綅
+ vo.setLocType1(devp.getDevNo()==102 ? "楂�" : "浣�");
}
return R.ok().add(list);
}
@@ -60,13 +89,24 @@
@ManagerAuth(memo = "杈撻�佽澶噋lc寮傚父淇℃伅琛�")
public R plcErrorTable(){
List<PlcErrorTableVo> list = new ArrayList<>();
- for (int i = 0; i<new Random().nextInt(13); i++){
- PlcErrorTableVo table = new PlcErrorTableVo();
- table.setNo(String.valueOf(i));
- table.setError("寮傚父淇℃伅");
- table.setPlcDesc("plc寮傚父鎻忚堪");
- list.add(table);
+ for (DevpSlave devp : slaveProperties.getDevp()) {
+ DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
+ Map<Integer, StaProtocol> station = devpThread.getStation();
+
+ for(Map.Entry<Integer, StaProtocol> entry : station.entrySet()) {
+ StaProtocol staProtocol = entry.getValue();
+// if (staProtocol) {
+// PlcErrorTableVo vo = new PlcErrorTableVo();
+// vo.setNo(entry.getKey()); // 搴忓彿
+//
+// vo.setPlcDesc(""); // todo:luxiaotao plc閿欒鎻忚堪
+// vo.setError(""); // todo:luxiaotao 寮傚父淇℃伅
+// list.add(vo);
+// }
+ }
+
}
+
list.sort((o1, o2) -> {
if (o1.getNo().compareTo(o2.getNo()) > 0){
return 1;
@@ -83,8 +123,83 @@
@PostMapping("/output/site")
@ManagerAuth(memo = "绔欑偣璁惧鎶ユ枃鏃ュ織杈撳嚭")
public R siteOutput(){
- String str = "\n" +new Date().toLocaleString() + "銆�2020-5-29 13:14:22銆戞壂鎻弍lcA 鐩爣绔�--27328372372832763643234323432342";
- return R.ok().add(str);
+ StringBuilder str = new StringBuilder();
+ String s;
+ int i = 0;
+ while((s = OutputQueue.DEVP.poll()) != null && i <=10) {
+ str.append("\n").append(s);
+ i++;
+ }
+ return R.ok().add(str.toString());
}
+ /****************************************************************/
+ /************************** 璇︽儏鎿嶄綔 ******************************/
+ /****************************************************************/
+
+ @GetMapping("/detl/{siteId}")
+ public R siteDetl(@PathVariable("siteId") Integer siteId){
+ SiteTableVo vo = new SiteTableVo();
+ for (DevpSlave devp : slaveProperties.getDevp()) {
+ DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
+ Map<Integer, StaProtocol> station = devpThread.getStation();
+ for (Map.Entry<Integer, StaProtocol> entry : station.entrySet()) {
+ if (siteId.equals(entry.getKey())) {
+ StaProtocol staProtocol = entry.getValue();
+ vo.setDevNo(entry.getKey()); // 绔欑偣缂栧彿
+ vo.setWorkNo(staProtocol.getWorkNo()); // 宸ヤ綔鍙�
+ vo.setAutoing(staProtocol.isAutoing()?"Y":"N"); // 鑷姩
+ vo.setLoading(staProtocol.isLoading()?"Y":"N"); // 鏈夌墿
+ vo.setInEnable(staProtocol.isInEnable()?"Y":"N"); // 鍙叆
+ vo.setOutEnable(staProtocol.isOutEnable()?"Y":"N"); // 鍙嚭
+ vo.setPakMk(staProtocol.isPakMk()?"Y":"N"); // 闇�姹�1
+ vo.setEmptyMk(staProtocol.isEmptyMk()?"Y":"N"); // 绌烘澘淇″彿
+ vo.setStaNo(staProtocol.getStaNo()); // 鐩爣绔�
+ vo.setLocType1(staProtocol.isHigh() != staProtocol.isLow() && staProtocol.isLow() ? "浣�" : "楂�"); //楂樹綆搴撲綅
+ return R.ok().add(vo);
+ }
+ }
+ }
+ return R.error("plc宸叉帀绾�");
+ }
+
+ @PostMapping("/detl/update")
+ @ManagerAuth(memo = "淇敼绔欑偣鏁版嵁")
+ public R siteDetlUpdate(@RequestParam Integer siteId,
+ @RequestParam Short workNo,
+ @RequestParam Short staNo,
+ @RequestParam String pakMk){
+ for (DevpSlave devp : slaveProperties.getDevp()) {
+ DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
+ Map<Integer, StaProtocol> station = devpThread.getStation();
+ for (Map.Entry<Integer, StaProtocol> entry : station.entrySet()) {
+ if (siteId.equals(entry.getKey())) {
+ StaProtocol staProtocol = entry.getValue();
+ if (staProtocol == null) {
+ continue;
+ } else {
+ staProtocol = staProtocol.clone();
+ }
+ if (workNo != null) {
+ staProtocol.setWorkNo(workNo);
+ }
+ if (staNo != null) {
+ staProtocol.setStaNo(staNo);
+ }
+ if (pakMk != null) {
+ staProtocol.setPakMk(pakMk.equals("Y"));
+ }
+ boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
+ if (result) {
+ return R.ok();
+ } else {
+ return R.error("涓嬪彂鍛戒护澶辫触");
+ }
+ }
+ }
+ }
+ return R.error("plc宸叉帀绾�");
+ }
+
+
}
--
Gitblit v1.9.1