From ca8f5a8f133e7f5b00b9d35ff6d15720804569af Mon Sep 17 00:00:00 2001
From: zyx <zyx123456>
Date: 星期三, 31 一月 2024 10:15:32 +0800
Subject: [PATCH] Merge branch 'ryzhwcs' of http://47.97.1.152:5880/r/zy-wcs into ryzhwcs
---
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 137 +++++++++++++++++++++++----------------------
1 files changed, 70 insertions(+), 67 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 ccfc32e..db2aad0 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -4,21 +4,14 @@
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.common.Cools;
-import com.core.common.R;
-import com.core.common.SpringUtils;
import com.core.exception.CoolException;
-import com.fasterxml.jackson.databind.ObjectMapper;
import com.zy.asrs.domain.enums.TaskStatusType;
import com.zy.asrs.entity.*;
import com.zy.asrs.entity.param.TaskOverToWms;
-import com.zy.asrs.entity.param.WMSAndAGVInterfaceParam;
-import com.zy.asrs.entity.param.taskCreateParam;
import com.zy.asrs.mapper.*;
import com.zy.asrs.service.*;
import com.zy.asrs.utils.CommandUtils;
-import com.zy.asrs.utils.PostMesDataUtils;
import com.zy.asrs.utils.Utils;
-import com.zy.common.service.CommonService;
import com.zy.common.utils.HttpHandler;
import com.zy.core.CrnThread;
import com.zy.core.DevpThread;
@@ -34,7 +27,6 @@
import com.zy.core.model.protocol.StaProtocol;
import com.zy.core.properties.SlaveProperties;
import com.zy.core.thread.BarcodeThread;
-import com.zy.core.thread.LedThread;
import com.zy.core.thread.SiemensDevpThread;
import com.zy.system.entity.Config;
import com.zy.system.service.ConfigService;
@@ -43,6 +35,7 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
import java.io.IOException;
import java.util.*;
@@ -100,20 +93,23 @@
public void generateStoreWrkFile() throws IOException, InterruptedException {
- // 鏍规嵁杈撻�佺嚎plc閬嶅巻
- for (DevpSlave devp : slaveProperties.getDevp()) {
- // 閬嶅巻鍏ュ簱鍙�
- for (DevpSlave.Sta inSta : devp.getInSta()) {
- // 鑾峰彇鍏ュ簱绔欎俊鎭�
- DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
- StaProtocol staProtocol = devpThread.getStation().get(inSta.getStaNo());
- if (staProtocol == null) {
- continue;
- } else {
- staProtocol = staProtocol.clone();
- }
- Short workNo = staProtocol.getWorkNo();
- Short stano = staProtocol.getStaNo();
+ try {
+
+
+ // 鏍规嵁杈撻�佺嚎plc閬嶅巻
+ for (DevpSlave devp : slaveProperties.getDevp()) {
+ // 閬嶅巻鍏ュ簱鍙�
+ for (DevpSlave.Sta inSta : devp.getInSta()) {
+ // 鑾峰彇鍏ュ簱绔欎俊鎭�
+ DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
+ StaProtocol staProtocol = devpThread.getStation().get(inSta.getStaNo());
+ if (staProtocol == null) {
+ continue;
+ } else {
+ staProtocol = staProtocol.clone();
+ }
+ Short workNo = staProtocol.getWorkNo();
+ Short stano = staProtocol.getStaNo();
@@ -171,22 +167,21 @@
}
continue;
}
- // 鍒ゆ柇鏄惁婊¤冻鍏ュ簱鏉′欢
- if (staProtocol.isAutoing() && staProtocol.isLoading()
- && staProtocol.isInEnable()
- && !staProtocol.isEmptyMk() && (workNo >= 0)
- && staProtocol.isPakMk()) {
- // 鑾峰彇鏉$爜鎵弿浠俊鎭�
- BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, inSta.getBarcode());
- if (barcodeThread == null) {
- continue;
- }
- String barcode = barcodeThread.getBarcode();
- if(!Cools.isEmpty(barcode)) {
- // 璇锋眰wms鎺ュ彛锛岃幏鍙栧伐浣滃彿鍜岀洰鏍囧簱浣�
- ToWmsDTO toWmsDTO = new ToWmsDTO(barcode,staProtocol.getSiteId());
- String response;
- try {
+ // 鍒ゆ柇鏄惁婊¤冻鍏ュ簱鏉′欢
+ if (staProtocol.isAutoing() && staProtocol.isLoading()
+ && staProtocol.isInEnable()
+ && !staProtocol.isEmptyMk() && (workNo >= 0)
+ && staProtocol.isPakMk()) {
+ // 鑾峰彇鏉$爜鎵弿浠俊鎭�
+ BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, inSta.getBarcode());
+ if (barcodeThread == null) {
+ continue;
+ }
+ String barcode = barcodeThread.getBarcode();
+ if(!Cools.isEmpty(barcode)) {
+ // 璇锋眰wms鎺ュ彛锛岃幏鍙栧伐浣滃彿鍜岀洰鏍囧簱浣�
+ ToWmsDTO toWmsDTO = new ToWmsDTO(barcode,staProtocol.getSiteId());
+ String response;
response = new HttpHandler.Builder()
.setHeaders(null)
.setUri(wmsUrl)
@@ -194,33 +189,37 @@
.setJson(JSON.toJSONString(toWmsDTO))
.build()
.doPost();
- }catch (Exception e){
- log.error("wms閫氳澶辫触,"+e.getMessage());
- continue;
- }
- JSONObject jsonObject = JSON.parseObject(response);
- if (jsonObject.getInteger("code").equals(200) && !Cools.isEmpty(jsonObject.get("data").toString())) {
- GetWmsDto getWmsDto = JSON.parseObject(jsonObject.get("data").toString(), GetWmsDto.class);
- // 鍒涙柊涓�涓叆搴撳伐浣滄。
- TaskWrk taskWrk = taskWrkService.selectByTaskNo(getWmsDto.getTaskNo());
- if(Cools.isEmpty(taskWrk)) {
- taskWrk = createTask(getWmsDto,staProtocol.getStaNo().intValue());
- if (Cools.isEmpty(taskWrk)){
- log.error("搴撲綅寮傚父锛屽簱浣嶅彿锛歿}", getWmsDto.getTargetLocationCode());
- }else {
- taskWrkService.insert(taskWrk);
- StaDesc staDesc = staDescService.selectOne(new EntityWrapper<StaDesc>()
- .eq("crn_no", taskWrk.getCrnNo()).eq("type_no",1).eq("stn_no",staProtocol.getStaNo().intValue()));
- staProtocol.setWorkNo(taskWrk.getWrkNo().shortValue());
- staProtocol.setStaNo(staDesc.getCrnStn().shortValue());
- MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
+ JSONObject jsonObject = JSON.parseObject(response);
+ apiLogService.save("wms璇锋眰鍏ュ簱璐т綅鎺ュ彛"
+ ,wmsUrl+inboundTaskApplyPath
+ ,null
+ ,"127.0.0.1"
+ ,JSON.toJSONString(toWmsDTO)
+ ,response
+ ,true
+ );
+ if (jsonObject.getInteger("code").equals(200) && !Cools.isEmpty(jsonObject.get("data").toString())) {
+ GetWmsDto getWmsDto = JSON.parseObject(jsonObject.get("data").toString(), GetWmsDto.class);
+ // 鍒涙柊涓�涓叆搴撳伐浣滄。
+ TaskWrk taskWrk = taskWrkService.selectByTaskNo(getWmsDto.getTaskNo());
+ if(Cools.isEmpty(taskWrk)) {
+ taskWrk = createTask(getWmsDto,staProtocol.getStaNo().intValue());
+ if (Cools.isEmpty(taskWrk)){
+ log.error("搴撲綅寮傚父锛屽簱浣嶅彿锛歿}", getWmsDto.getTargetLocationCode());
+ }else {
+ taskWrkService.insert(taskWrk);
+ StaDesc staDesc = staDescService.selectOne(new EntityWrapper<StaDesc>()
+ .eq("crn_no", taskWrk.getCrnNo()).eq("type_no",1).eq("stn_no",staProtocol.getStaNo().intValue()));
+ staProtocol.setWorkNo(taskWrk.getWrkNo().shortValue());
+ staProtocol.setStaNo(staDesc.getCrnStn().shortValue());
+ MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
+ }
}
- }
- }else {
- continue;
- }
+ }else {
+ continue;
+ }
// StaDescService staDescService = SpringUtils.getBean(StaDescService.class);
//
@@ -295,11 +294,15 @@
// }
// }
+ }
}
+
+
}
-
-
}
+ } catch (Exception e) {
+ log.error("generateStoreWrkFile e", e);
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
}
}
@@ -519,7 +522,7 @@
}
}
- // return;
+ // return;
}
}
@@ -932,7 +935,7 @@
}
}
}
- // 鏃犱换鍔�
+ // 鏃犱换鍔�
} else {
BasErrLog latest = basErrLogService.findLatest(crn.getId());
// 鏈夊紓甯�
@@ -968,7 +971,7 @@
log.error("鍫嗗灈鏈簆lc寮傚父璁板綍澶辫触 ===>> [id:{}] [error:{}]", crn.getId(), errName);
}
}
- // 鏃犲紓甯�
+ // 鏃犲紓甯�
} else {
// 寮傚父淇
if (latest != null && latest.getStatus() == 1) {
--
Gitblit v1.9.1