From 8353d857cae5c623e29406dcbe8c9a870d527b6e Mon Sep 17 00:00:00 2001
From: lsh <lsh>
Date: 星期四, 16 五月 2024 09:33:24 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/asrs/controller/SiteController.java | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 117 insertions(+), 1 deletions(-)
diff --git a/src/main/java/com/zy/asrs/controller/SiteController.java b/src/main/java/com/zy/asrs/controller/SiteController.java
index 0270d59..e9cb0fb 100644
--- a/src/main/java/com/zy/asrs/controller/SiteController.java
+++ b/src/main/java/com/zy/asrs/controller/SiteController.java
@@ -7,17 +7,23 @@
import com.zy.asrs.domain.vo.PlcErrorTableVo;
import com.zy.asrs.domain.vo.SiteTableVo;
import com.zy.asrs.entity.BasDevp;
+import com.zy.asrs.entity.BasExt;
import com.zy.asrs.service.BasDevpService;
+import com.zy.asrs.service.BasExtService;
import com.zy.asrs.utils.CommandUtils;
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.ExtSlave;
import com.zy.core.model.Task;
+import com.zy.core.model.protocol.ExtProtocol;
import com.zy.core.model.protocol.StaProtocol;
import com.zy.core.properties.SlaveProperties;
import com.zy.core.DevpThread;
+import com.zy.core.thread.BarcodeThread;
+import com.zy.core.thread.MelsecExtThread;
import com.zy.core.thread.SiemensDevpThread;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -36,6 +42,8 @@
private SlaveProperties slaveProperties;
@Autowired
private BasDevpService basDevpService;
+ @Autowired
+ private BasExtService basExtService;
@GetMapping("/io/mode/info/site")
@@ -113,6 +121,23 @@
vo.setStaNo(staProtocol.getStaNo()); // 鐩爣绔�
// vo.setLocType1(staProtocol.isHigh() != staProtocol.isLow() && staProtocol.isLow() ? "浣�" : "楂�"); //楂樹綆搴撲綅
vo.setLocType1(devp.getDevNo()==102 ? "楂�" : "浣�");
+ vo.setBarcode(staProtocol.getBarcode());
+ }
+ return R.ok().add(list);
+ }
+
+ @GetMapping("/list/ext/auth")
+ @ManagerAuth(memo = "鏈烘鑷備俊鎭�")
+ public R extList(){
+ List<SiteTableVo> list = new ArrayList<>();
+ // 鎸佷箙鏁版嵁
+ List<BasExt> basExts = basExtService.selectList(new EntityWrapper<BasExt>().orderBy("ext_no"));
+ for (BasExt ext : basExts) {
+ SiteTableVo vo = new SiteTableVo();
+ vo.setDevNo(ext.getExtNo()); // 绔欑偣缂栧彿
+ vo.setInEnable(ext.getExtTask()); // 鍙叆 鍙彇
+ vo.setOutEnable(ext.getExtPut()); // 鍙嚭 鍙斁
+ list.add(vo);
}
return R.ok().add(list);
}
@@ -126,7 +151,10 @@
Map<Integer, StaProtocol> station = devpThread.getStation();
for(Map.Entry<Integer, StaProtocol> entry : station.entrySet()) {
- list = staPlcErr(entry);
+ if (!Cools.isEmpty(staPlcErr(entry))){
+ list.add(staPlcErr(entry).get(0)) ;
+ }
+
}
}
return R.ok().add(list);
@@ -229,6 +257,94 @@
}
return R.error("鏇存柊澶辫触");
}
+ @PostMapping("/detl/out")
+ @ManagerAuth(memo = "淇敼绔欑偣鏁版嵁")
+ public R siteDetlout(@RequestParam Integer devNo,
+ @RequestParam Short workNo,
+ @RequestParam Short staNo,
+ @RequestParam(required = false) String pakMk,
+ @RequestParam(required = false) Boolean inEnable,
+ @RequestParam(required = false) Boolean outEnable
+ ) {
+ BasDevp basDevp = basDevpService.selectById(devNo);
+ if (basDevp == null) {
+ return R.error("绔欑偣涓嶅瓨鍦�");
+ }
+ 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 (devNo.equals(entry.getKey())) {
+ StaProtocol staProtocol = entry.getValue();
+ if (staProtocol == null) {
+ continue;
+ } else {
+ staProtocol = staProtocol.clone();
+ }
+ if (pakMk != null) {
+ staProtocol.setPakMk(pakMk.equals("Y"));
+ }
+ if (inEnable != null) {
+ staProtocol.setInEnable(inEnable);
+ basDevp.setInEnable(inEnable ? "Y" : "N");
+ }
+ if (outEnable != null) {
+ staProtocol.setOutEnable(outEnable);
+ basDevp.setOutEnable(outEnable ? "Y" : "N");
+ }
+ staProtocol.setWorkNo((short) 0);
+ staProtocol.setStaNo((short) 0);
+ basDevpService.updateById(basDevp);
+ boolean result = CommandUtils.offer(SlaveType.Devp, devp.getId(), new Task(3, staProtocol), false);
+ if (result) {
+ return R.ok();
+ } else {
+ return R.error("涓嬪彂鍛戒护澶辫触");
+ }
+ }
+ }
+ }
+ return R.error("鏇存柊澶辫触");
+ }
+ @PostMapping("/detl/in")
+ @ManagerAuth(memo = "淇敼绔欑偣鏁版嵁")
+ public R siteDetlint(@RequestParam Integer devNo,
+ @RequestParam Short workNo,
+ @RequestParam Short staNo,
+ @RequestParam(required = false) String pakMk,
+ @RequestParam(required = false) Boolean inEnable,
+ @RequestParam(required = false) Boolean outEnable
+ ) {
+ BasDevp basDevp = basDevpService.selectById(devNo);
+ if (basDevp == null) {
+ return R.error("绔欑偣涓嶅瓨鍦�");
+ }
+ for (DevpSlave devp : slaveProperties.getDevp()) {
+ // 閬嶅巻鍏ュ簱鍙�
+ for (DevpSlave.Sta inSta : devp.getInSta()) {
+ if (!devNo.equals(inSta.getBackSta()) ){
+ continue;
+ }
+ // 鑾峰彇鍏ュ簱绔欎俊鎭�
+ DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
+ StaProtocol staProtocol = devpThread.getStation().get(inSta.getBackSta());
+ if (staProtocol == null) {
+ continue;
+ } else {
+ staProtocol = staProtocol.clone();
+ }
+ staProtocol.setWorkNo((short) 9999);
+ staProtocol.setStaNo(inSta.getStaNo().shortValue());
+ boolean result = CommandUtils.offer(SlaveType.Devp, devp.getId(), new Task(3, staProtocol), false);
+ if (result) {
+ return R.ok();
+ } else {
+ return R.error("涓嬪彂鍛戒护澶辫触");
+ }
+ }
+ }
+ return R.error("鏇存柊澶辫触");
+ }
public List<PlcErrorTableVo> staPlcErr(Map.Entry<Integer, StaProtocol> entry){
List<PlcErrorTableVo> list = new ArrayList<>();
--
Gitblit v1.9.1