From e67503fd8cc820ff14fa3398a9a7e072d4964444 Mon Sep 17 00:00:00 2001
From: mrzhssss <pro6@qq.com>
Date: 星期五, 06 五月 2022 14:25:57 +0800
Subject: [PATCH] 新增导出功能
---
src/main/java/zy/cloud/wms/common/service/erp/ErpScheduler.java | 68 +++++++++++++++++++++++++--------
1 files changed, 51 insertions(+), 17 deletions(-)
diff --git a/src/main/java/zy/cloud/wms/common/service/erp/ErpScheduler.java b/src/main/java/zy/cloud/wms/common/service/erp/ErpScheduler.java
index 372581a..d13c6de 100644
--- a/src/main/java/zy/cloud/wms/common/service/erp/ErpScheduler.java
+++ b/src/main/java/zy/cloud/wms/common/service/erp/ErpScheduler.java
@@ -17,6 +17,7 @@
import zy.cloud.wms.common.service.erp.entity.*;
import zy.cloud.wms.common.utils.VersionUtils;
import zy.cloud.wms.manager.entity.*;
+import zy.cloud.wms.manager.mapper.MatCodeMapper;
import zy.cloud.wms.manager.mapper.TagMapper;
import zy.cloud.wms.manager.service.*;
import zy.cloud.wms.manager.utils.HttpHandler;
@@ -35,11 +36,12 @@
@RestController
public class ErpScheduler {
- public static final String URI = "http://8.133.182.21:6220/api";
+ public static final String URI = "http://123.60.34.127:6220/api";
public static final String GET_ORDERS = "cM/basis/getOrders";
public static final String GET_BASIS = "cM/basis/getBasis";
public static final String UPLOAD_BILL = "cM/basis/uploadBill";
public static final String UPLOAD_STOCK = "cM/basis/uploadStock";
+ public static final String GET_STOCK = "cM/ptype/GetStock";
public static final String OVER_BILL = "cM/basis/OverBill";
public static final String UPLOAD_CANCEL_RESULT = "cM/basis/cancelOrders";
@@ -65,6 +67,11 @@
private NodeService nodeService;
@Autowired
private DocLogService docLogService;
+ @Autowired
+ private RequestLogService requestLogService;
+ @Autowired
+ private MatCodeMapper matCodeMapper;
+
/**
* 鍟嗗搧涓嬭浇
@@ -168,6 +175,7 @@
}
if (null == mat) {
+ // 骞充粨
mat = new Mat(
String.valueOf(data.getRec()), // 缂栧彿
null, // 鎵�灞炲尯鍩�
@@ -193,8 +201,12 @@
updateTime, // 淇敼鏃堕棿
null // 澶囨敞
);
+
matService.insert(mat);
+ // 绔嬪簱
+
} else {
+ // 骞充粨
mat.setUuid(String.valueOf(data.getRec()));
mat.setMatnr(data.getUserCode());
mat.setMaktx(data.getFullName());
@@ -203,6 +215,8 @@
mat.setBarcode(data.getBarcode());
mat.setUnit(data.getUnit3());
matService.updateById(mat);
+ // 绔嬪簱
+
}
log.info("====>> 鏇存柊鐗╂枡锛歿}", data.getUserCode());
}
@@ -217,7 +231,7 @@
/**
* 鍟嗗搧涓嬭浇
*/
- @Scheduled(cron = "0/5 * * * * ? ")
+ @Scheduled(cron = "0 */2 * * * ? ")
public void updateMatExecute(){
try {
Map<String, Object> param = new HashMap<>();
@@ -229,7 +243,8 @@
.build()
.doPost();
if (!Cools.isEmpty(response)) {
-// log.info(response);
+ log.info("鍟嗗搧鏁版嵁鏇存柊锛�");
+ log.info(response);
Date now = new Date();
Result result = JSON.parseObject(response, Result.class);
if (result.getCode() != 1) {
@@ -338,7 +353,11 @@
updateTime, // 淇敼鏃堕棿
null // 澶囨敞
);
- matService.insert(mat);
+ if (matService.insert(mat)) {
+ MatCode matCode = mat.beMatCode();
+ matCodeMapper.insert(matCode);
+ }
+
} else {
mat.setUuid(String.valueOf(data.getRec()));
mat.setMatnr(data.getUserCode());
@@ -347,7 +366,10 @@
mat.setUpdateTime(updateTime);
mat.setBarcode(data.getBarcode());
mat.setUnit(data.getUnit3());
- matService.updateById(mat);
+ if (matService.updateById(mat)) {
+ MatCode matCode = mat.beMatCode();
+ matCodeMapper.updateById(matCode);
+ }
}
log.info("====>> 鏇存柊鐗╂枡锛歿}", data.getUserCode());
}
@@ -425,7 +447,7 @@
/**
* 鎸佷箙鍖栭攢鍞鍗�
*/
- @Scheduled(cron = "0/5 * * * * ? ")
+ @Scheduled(cron = "0 */1 * * * ?")
@Transactional
// @PostConstruct
public void getOrdersExecute(){
@@ -602,7 +624,17 @@
.doPost();
try {
- docLogService.insertBatch(docLogs);
+ for (DocLog docLog : docLogs) {
+ docLogService.insert(docLog);
+ }
+
+ RequestLog logInfo = new RequestLog();
+ logInfo.setName("鍗曟嵁涓婁紶锛屽崟鎹被鍨�" + 11);
+ logInfo.setRequest(JSON.toJSONString(getOrderResult0)); // 鍏ュ弬
+ logInfo.setResponse(response); // 鍑哄弬
+ logInfo.setCreateTime(new Date());
+ requestLogService.insert(logInfo);
+
} catch (Exception e) {
log.error(e.getMessage());
}
@@ -610,20 +642,13 @@
if (!Cools.isEmpty(response)) {
log.warn(response);
Result result = JSON.parseObject(response, Result.class);
- if (result.getCode() != 1) {
+ if (result.getCode() != 1 && !result.getMsg().equals("鍗曟嵁宸茬粡瀹℃牳瀹屾垚鎴栧垹闄わ紝涓嶈兘瀹℃牳銆�")) {
continue;
}
if (!orderService.updateSettle(order.getOrderNo(), 6L)) {
throw new CoolException("淇敼璁㈠崟鐘舵�佸け璐�");
}
-// // 杞巻鍙叉。
-// int save = custOrderMapper.saveLog(getOrderResult0.getNumber());
-// if (save > 0) {
-// if (custOrderMapper.delete(new EntityWrapper<CustOrder>().eq("number", getOrderResult0.getNumber())) == 0) {
-// throw new CoolException("鍒犻櫎閿�鍞鍗曞け璐�");
-// }
-// log.info("{}閿�鍞鍗曟嫞璐х粨鏉�", getOrderResult0.getNumber());
-// }
+
}
}
@@ -702,7 +727,16 @@
.doPost();
try {
- docLogService.insertBatch(docLogs);
+ for (DocLog docLog : docLogs) {
+ docLogService.insert(docLog);
+ }
+
+ RequestLog logInfo = new RequestLog();
+ logInfo.setName("鍗曟嵁涓婁紶锛屽崟鎹被鍨�" + 6);
+ logInfo.setRequest(JSON.toJSONString(getOrderResult0)); // 鍏ュ弬
+ logInfo.setResponse(response); // 鍑哄弬
+ logInfo.setCreateTime(new Date());
+ requestLogService.insert(logInfo);
} catch (Exception e) {
log.error(e.getMessage());
}
--
Gitblit v1.9.1