From 0e10bf39c53b0b79cbdc051ddb10845d361042c3 Mon Sep 17 00:00:00 2001
From: dubin <bindu_bean@163.com>
Date: 星期三, 06 五月 2026 09:51:50 +0800
Subject: [PATCH] 初始化
---
src/main/java/com/zy/common/task/GhlnWcsScheduler.java | 131 ++++++++++++++++++++++++-------------------
1 files changed, 74 insertions(+), 57 deletions(-)
diff --git a/src/main/java/com/zy/common/task/GhlnWcsScheduler.java b/src/main/java/com/zy/common/task/GhlnWcsScheduler.java
index 049777e..a151a05 100644
--- a/src/main/java/com/zy/common/task/GhlnWcsScheduler.java
+++ b/src/main/java/com/zy/common/task/GhlnWcsScheduler.java
@@ -12,6 +12,7 @@
import com.zy.entity.BasDevp;
import com.zy.entity.WrkDetl;
import com.zy.entity.WrkMast;
+import com.zy.enums.AgvApi;
import com.zy.service.BasDevpService;
import com.zy.service.WrkDetlService;
import com.zy.service.WrkMastService;
@@ -22,7 +23,9 @@
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
/**
@@ -48,57 +51,65 @@
@Scheduled(cron = "0/5 * * * * ?")
private void wcsOpenComplete() {
SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, 1);
- StaProtocol staProtocol305 = devpThread.getStation().get(305);
- if (staProtocol305!= null && staProtocol305.getIfOpenDoor()) {
- BasDevp basDevp = basDevpService.selectOne(new EntityWrapper<BasDevp>().eq("dev_no", 305));
- if (basDevp.getWrkNo() != 0) {
- WrkMast wrkMast = wrkMastService.selectById(basDevp.getWrkNo());
- if (wrkMast == null || wrkMast.getWhsType() == null || wrkMast.getWhsType() == 3){
- return;
- }
- if (wrkMast.getWhsType() == 4) {
- return;
- }
- WrkDetl wrkDetl = wrkDetlService.selectOne(new EntityWrapper<WrkDetl>().eq("wrk_no", wrkMast.getWrkNo()));
- // 鍒ゆ柇寮�闂ㄥ畬鎴愶紝鍒欓�氱煡agv鍙互鏀捐揣
- // 璋冪敤缁撴灉
- boolean success = false;
- // 鏋勯�犺姹傚ご
- Map<String, Object> headers = new HashMap<>();
- headers.put("Content-Type", "application/json;charset=UTF-8");
- // 鏋勯�犺姹備綋
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("matnr",wrkDetl.getMatnr());
- jsonObject.put("batch",wrkDetl.getBatch());
- jsonObject.put("flag",wrkMast.getIoType() > 100 ? "0" : "1");
- String body = jsonObject.toJSONString();
- String response = "";
- try {
- response = new HttpHandler.Builder()
- .setUri("http://192.168.204.44:8010")
- .setPath("/api/TaskCreat/AllowEntry")
- .setHeaders(headers)
- .setJson(body)
- .build()
- .doPost();
- if (!Cools.isEmpty(response)) {
- JSONObject jsonObject1 = JSONObject.parseObject(response);
- if ((Integer) jsonObject1.get("code") == 200) {
- success = true;
- wrkMast.setWhsType(3);
- wrkMastService.updateById(wrkMast);
- }
- } else {
- log.error("wcs寮�闂ㄥ畬鎴愰�氱煡agv鎺ュ彛寮傚父鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", "", body, response);
+ List<StaProtocol> staProtocols = new ArrayList<StaProtocol>() {{
+ add(devpThread.getStation().get(305));
+ add(devpThread.getStation().get(1202));
+ }};
+// StaProtocol staProtocol305 = devpThread.getStation().get(305);
+ for (StaProtocol staProtocol : staProtocols) {
+// if (staProtocol305 != null && staProtocol305.getIfOpenDoor()) {
+ if (staProtocol != null && staProtocol.getIfOpenDoor()) {
+ BasDevp basDevp = basDevpService.selectOne(new EntityWrapper<BasDevp>().eq("dev_no", staProtocol.getSiteId()));
+ if (basDevp.getWrkNo() != 0) {
+ WrkMast wrkMast = wrkMastService.selectById(basDevp.getWrkNo());
+ if (wrkMast == null || wrkMast.getWhsType() == null || wrkMast.getWhsType() == 3) {
+ return;
}
- } catch (Exception e) {
- log.error("wcs寮�闂ㄥ畬鎴愰�氱煡agv鎺ュ彛寮傚父锛歿}", e.getMessage());
- } finally {
- log.error("wcs寮�闂ㄥ畬鎴愰�氱煡agv鎺ュ彛锛歿}", success);
+ if (wrkMast.getWhsType() == 4) {
+ return;
+ }
+ WrkDetl wrkDetl = wrkDetlService.selectOne(new EntityWrapper<WrkDetl>().eq("wrk_no", wrkMast.getWrkNo()));
+ // 鍒ゆ柇寮�闂ㄥ畬鎴愶紝鍒欓�氱煡agv鍙互鏀捐揣
+ // 璋冪敤缁撴灉
+ boolean success = false;
+ // 鏋勯�犺姹傚ご
+ Map<String, Object> headers = new HashMap<>();
+ headers.put("Content-Type", "application/json;charset=UTF-8");
+ // 鏋勯�犺姹備綋
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put("matnr", wrkDetl.getMatnr());
+ jsonObject.put("batch", wrkDetl.getBatch());
+ jsonObject.put("flag", wrkMast.getIoType() > 100 ? "0" : "1");
+ String body = jsonObject.toJSONString();
+ String response = "";
+ try {
+ response = new HttpHandler.Builder()
+ .setUri(AgvApi.OPEN_COMPLETE_PUSH.getURI())
+ .setPath(AgvApi.OPEN_COMPLETE_PUSH.getPath())
+ .setHeaders(headers)
+ .setJson(body)
+ .build()
+ .doPost();
+ if (!Cools.isEmpty(response)) {
+ JSONObject jsonObject1 = JSONObject.parseObject(response);
+ if ((Integer) jsonObject1.get("code") == 200) {
+ success = true;
+ wrkMast.setWhsType(3);
+ wrkMastService.updateById(wrkMast);
+ }
+ } else {
+ log.error("wcs寮�闂ㄥ畬鎴愰�氱煡agv鎺ュ彛寮傚父鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", "", body, response);
+ }
+ } catch (Exception e) {
+ log.error("wcs寮�闂ㄥ畬鎴愰�氱煡agv鎺ュ彛寮傚父锛歿}", e.getMessage());
+ } finally {
+ log.error("wcs寮�闂ㄥ畬鎴愰�氱煡agv鎺ュ彛锛歿}", success);
+ }
}
}
}
- }
+
+ }
/**
* 璇诲凡鍏抽棬
@@ -106,22 +117,27 @@
@Scheduled(cron = "0/5 * * * * ?")
private void wcsCloseComplete() {
SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, 1);
- StaProtocol staProtocol = devpThread.getStation().get(305);
- if (staProtocol == null) {
- return;
- } else {
- staProtocol = staProtocol.clone();
- }
- BasDevp basDevp = basDevpService.selectOne(new EntityWrapper<BasDevp>().eq("dev_no", 305));
+ List<StaProtocol> staProtocols = new ArrayList<StaProtocol>() {{
+ add(devpThread.getStation().get(305));
+ add(devpThread.getStation().get(1202));
+ }};
+// StaProtocol staProtocol = devpThread.getStation().get(305);
+ for (StaProtocol staProtocol : staProtocols) {
+ if (staProtocol == null) {
+ return;
+ } else {
+ staProtocol = staProtocol.clone();
+ }
+ BasDevp basDevp = basDevpService.selectOne(new EntityWrapper<BasDevp>().eq("dev_no", staProtocol.getSiteId()));
if (basDevp.getWrkNo() != 0 && basDevp.getWrkNo() != 9999) {
WrkMast wrkMast = wrkMastService.selectById(basDevp.getWrkNo());
- if (wrkMast == null || wrkMast.getWhsType() == null ||wrkMast.getWhsType() != 4) {
+ if (wrkMast == null || wrkMast.getWhsType() == null || wrkMast.getWhsType() != 4) {
return;
}
if (wrkMast.getIoType() == 1 && wrkMast.getWrkSts() == 1) {
staProtocol.setWorkNo(wrkMast.getWrkNo());
staProtocol.setStaNo(wrkMast.getStaNo().shortValue());
- if(!MessageQueue.offer(SlaveType.Devp, 1, new Task(2, staProtocol))){
+ if (!MessageQueue.offer(SlaveType.Devp, 1, new Task(2, staProtocol))) {
log.error("鍏ュ簱鍏抽棬瀹屾垚澶辫触");
}
wrkMast.setWrkSts(2L);
@@ -131,12 +147,13 @@
} else if (wrkMast.getIoType() == 101) {
staProtocol.setWorkNo(9999);
staProtocol.setStaNo(wrkMast.getSourceStaNo().shortValue());
- if(!MessageQueue.offer(SlaveType.Devp, 1, new Task(2, staProtocol))){
+ if (!MessageQueue.offer(SlaveType.Devp, 1, new Task(2, staProtocol))) {
log.error("鍑哄簱鍏抽棬瀹屾垚澶辫触");
}
basDevp.setWrkNo(staProtocol.getWorkNo());
basDevpService.updateById(basDevp);
}
}
+ }
}
}
--
Gitblit v1.9.1