From 10610f52857314807b054d16e81b7fcda0137f58 Mon Sep 17 00:00:00 2001
From: lty <876263681@qq.com>
Date: 星期日, 30 三月 2025 12:49:25 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/jxjdzwcs' into jxjdzwcs
---
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 149 ++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 139 insertions(+), 10 deletions(-)
diff --git a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
index aea5740..c270c19 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -39,15 +39,18 @@
import com.zy.core.thread.SiemensDevpThread;
import com.zy.system.entity.Config;
import com.zy.system.service.ConfigService;
+import lombok.Synchronized;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
+import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import java.io.IOException;
import java.util.*;
+import java.util.concurrent.CompletableFuture;
/**
* 绔嬩綋浠撳簱WCS绯荤粺涓绘祦绋嬩笟鍔�
@@ -94,7 +97,10 @@
private ApiLogService apiLogService;
@Autowired
private CommonService commonService;
-
+ @Value("${wms.count}")
+ private Integer maxCount;
+ @Autowired
+ private WrkMastService wrkMastService;
@Value("${wms.url}")
private String wmsUrl;
@Value("${wms.inboundTaskApplyPath}")
@@ -107,6 +113,115 @@
private CrnController crnController;
@Autowired
private SiteController siteController;
+ @Synchronized
+ public void shiftTargetToCyclePoint() throws IOException, InterruptedException {
+ try {
+ for (DevpSlave devp : slaveProperties.getDevp()) {
+ for (DevpSlave.Sta outSta : devp.getOutSta()) {
+ DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
+ if (devpThread == null) {
+ continue;
+ }
+
+ StaProtocol staProtocol = getClonedStation(devpThread, outSta.getStaNo());
+ if (staProtocol == null) {
+ continue;
+ }
+
+ // 鑾峰彇鍏朵粬鐩稿叧绔欑偣
+ StaProtocol staProtocol1 = getClonedStation(devpThread, 1001);
+ StaProtocol staProtocol2 = getClonedStation(devpThread, 1002);
+ StaProtocol staProtocol3 = getClonedStation(devpThread, 1003);
+ StaProtocol staProtocol4 = getClonedStation(devpThread, 1004);
+ StaProtocol staProtocol6 = getClonedStation(devpThread, 111);
+
+ boolean result = false;
+ switch (outSta.getStaNo()) {
+ case 105:
+ result = (staProtocol1 != null && staProtocol1.isLoading() && staProtocol.isLoading() && staProtocol.getStaNo() == 105);
+ break;
+ case 107:
+ result = (staProtocol2 != null && staProtocol2.isLoading());
+ break;
+ case 109:
+ result = (staProtocol3 != null && staProtocol3.isLoading());
+ break;
+ case 110:
+ result = ((staProtocol4 != null && staProtocol4.isLoading() && staProtocol.isLoading() && staProtocol.getStaNo() == 110) ||
+ (staProtocol6 != null && staProtocol6.isLoading() && staProtocol.isLoading() && staProtocol.getStaNo() == 111));
+ break;
+ default:
+ break;
+ }
+
+ if (result) {
+ if (staProtocol.getSiteId() == 107 || staProtocol.getSiteId() == 109) {
+ StaProtocol staProtocol5 = getClonedStation(devpThread, staProtocol.getSiteId() - 1);
+ if (staProtocol5 != null && (staProtocol5.isLoading() && (staProtocol5.getStaNo() == 107 || staProtocol5.getStaNo() == 109))) {
+ short workNo = staProtocol5.getWorkNo();
+ staProtocol5.setWorkNo(workNo);
+ staProtocol5.setStaNo((short) 112);
+ MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(4, staProtocol5));
+ }
+ } else {
+ if(staProtocol.isLoading() && (staProtocol.getStaNo() == 105 || staProtocol.getStaNo() == 110 || staProtocol.getStaNo() == 111)){
+ short workNo = staProtocol.getWorkNo();
+ staProtocol.setWorkNo(workNo);
+ staProtocol.setStaNo((short) 112);
+ MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(4, staProtocol));
+ }
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ log.error("shiftTargetToCyclePoint error", e);
+ }
+ }
+
+ /**
+ * 鑾峰彇绔欑偣骞跺厠闅�
+ */
+ private StaProtocol getClonedStation(DevpThread devpThread, int staNo) {
+ StaProtocol staProtocol = devpThread.getStation().get(staNo);
+ return (staProtocol != null) ? staProtocol.clone() : null;
+ }
+
+ // 112寰幆绔欑偣鑷冲嚭搴撶珯
+ public synchronized void shiftCyclePointToTarget() throws IOException, InterruptedException {
+ try {
+ for (DevpSlave devp : slaveProperties.getDevp()) {
+ DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
+ if (devpThread == null) {
+ continue;
+ }
+
+ StaProtocol staProtocol = devpThread.getStation().get(112);
+ if (staProtocol.getStaNo() != 112 || staProtocol.getWorkNo() == 0 || !staProtocol.isLoading() || staProtocol.getWorkNo() > 9000 || staProtocol.getWorkNo() < 6000) {
+ continue;
+ }
+ // 鏌ヨ浠诲姟淇℃伅
+ TaskWrk taskWrk = taskWrkMapper.selectStaWorking(Integer.valueOf(staProtocol.getWorkNo()));
+ if (taskWrk == null || taskWrk.getWrkNo() < 6001 || taskWrk.getWrkNo() > 9000) {
+ continue;
+ }
+
+ short workNo = staProtocol.getWorkNo();
+ // 鍐嶅啓鍏ョ洰鏍囩珯鐐�
+ staProtocol.setWorkNo(workNo);
+ staProtocol.setStaNo(Short.valueOf(taskWrk.getTargetPoint()));
+ MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(4, staProtocol));
+ Thread.sleep(200);
+
+ log.info("Shifted from cycle station 112 to target {}, workNo: {}", taskWrk.getTargetPoint(), workNo);
+ }
+ } catch (Exception e) {
+ log.error("shiftCyclePointToTarget error", e);
+ }
+ }
+
+
+
public synchronized void generateStoreWrkFile1() throws IOException, InterruptedException {
@@ -205,7 +320,7 @@
staProtocol.setStaNo((short)107);
}else if (staProtocol.getWorkNo()>=9851&&staProtocol.getWorkNo()<=9875) {
staProtocol.setStaNo((short)109);
- }else{
+ }else if (staProtocol.getWorkNo()>=9876 && staProtocol.getWorkNo() <= 9900){
staProtocol.setStaNo((short)110);
}
devpThread.setPakMk(staProtocol.getSiteId(), false);
@@ -722,6 +837,7 @@
continue;
}
+
// 鑾峰彇宸ヤ綔鐘舵�佷负2锛堣澶囦笂璧帮級鐨勫叆搴撳伐浣滄。
TaskWrk taskWrk = taskWrkMapper.selectPakIn(slave.getId(), staProtocol.getWorkNo().intValue(), staDesc.getStnNo().toString());
if (null == taskWrk) {
@@ -847,6 +963,12 @@
if (!crnProtocol.getStatusType().equals(CrnStatusType.IDLE) || crnProtocol.getTaskNo() != 0) {
break;
}
+ int storeCount = basDevpService.getStoreCount();
+ if(storeCount >= maxCount){
+ log.error("杈撻�佺嚎鏆傚瓨鏁拌揪鍒颁笂闄恵}",storeCount);
+ break;
+ }
+
// 宸茬粡瀛樺湪鍚婅溅鎵ц浠诲姟鏃讹紝鍒欒繃婊�
if (taskWrkMapper.selectCrnWorking(slave.getId()) != null) {
@@ -977,15 +1099,15 @@
// 淇敼宸ヤ綔妗g姸鎬� 11.鐢熸垚鍑哄簱ID => 12.鍚婅溅鍑哄簱涓�
Date now = new Date();
taskWrk.setWrkSts(12);
- taskWrk.setStatus(2);
taskWrk.setModiTime(now);
if (taskWrkMapper.updateById(taskWrk) == 0) {
log.error("淇敼宸ヤ綔妗g姸鎬� 11.鐢熸垚鍑哄簱ID => 12.鍚婅溅鍑哄簱涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", taskWrk.getWrkNo());
}
+ String response = "";
+ Boolean bool=false;
+ HashMap<String, Object> headParam = new HashMap<>();
+ headParam.put("TaskNo", taskWrk.getTaskNo());
try {
- HashMap<String, Object> headParam = new HashMap<>();
- headParam.put("TaskNo", taskWrk.getTaskNo());
- String response;
response = new HttpHandler.Builder()
// .setHeaders(headParam)
.setUri(wmsUrl)
@@ -994,17 +1116,24 @@
.build()
.doPost();
JSONObject jsonObject = JSON.parseObject(response);
+ if(jsonObject.get("ReturnStatus").equals(0)){
+ bool = true;
+ taskWrk.setStatus(2);
+ taskWrkMapper.updateById(taskWrk);
+ }
+
+ } catch (Exception e) {
+ log.error("wcs娲惧彂绉诲簱搴撲换鍔′笂鎶ms澶辫触", taskWrk);
+// throw new CoolException("wcs娲惧彂绉诲簱搴撲换鍔′笂鎶ms澶辫触");
+ }finally {
apiLogService.save("wcs娲惧彂绉诲簱浠诲姟涓婃姤wms"
, wmsUrl + taskStatusFeedbackPath
, null
, "127.0.0.1"
, JSON.toJSONString(headParam)
, response
- , true
+ , bool
);
- } catch (Exception e) {
- log.error("wcs娲惧彂绉诲簱搴撲换鍔′笂鎶ms澶辫触", taskWrk);
-// throw new CoolException("wcs娲惧彂绉诲簱搴撲换鍔′笂鎶ms澶辫触");
}
}
--
Gitblit v1.9.1