From 7df6ab7f0cede6c1a9aa51e496f910026a4bfce6 Mon Sep 17 00:00:00 2001
From: mrzhssss <pro6@qq.com>
Date: 星期二, 07 十二月 2021 09:43:09 +0800
Subject: [PATCH] 2021.12.7
---
src/main/java/zy/cloud/wms/common/service/erp/ErpScheduler.java | 312 +++++++++++++++++++++++++++------------------------
1 files changed, 166 insertions(+), 146 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 f1ba192..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;
@@ -40,6 +41,7 @@
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";
@@ -67,6 +69,9 @@
private DocLogService docLogService;
@Autowired
private RequestLogService requestLogService;
+ @Autowired
+ private MatCodeMapper matCodeMapper;
+
/**
* 鍟嗗搧涓嬭浇
@@ -86,6 +91,159 @@
.build()
.doPost();
if (!Cools.isEmpty(response)) {
+ log.info(response);
+ Date now = new Date();
+ Result result = JSON.parseObject(response, Result.class);
+ if (result.getCode() != 1) {
+ return;
+ }
+ List<GetBasisResult> list = JSON.parseArray(result.getData(), GetBasisResult.class);
+ Tag first = null;
+ for (GetBasisResult data : list) {
+ Mat mat = matService.selectByMatnr(data.getUserCode());
+ String modifyDate = data.getModifyDate();
+ Date updateTime = null;
+ if (!Cools.isEmpty(modifyDate)) {
+ updateTime = DateUtils.convert(data.getModifyDate());
+ }
+
+ // 鍒嗙被
+ Tag second = tagService.selectOne(new EntityWrapper<Tag>().eq("name", data.getYjfl()).eq("level", 2));
+ if (second == null) {
+ if (first == null) {
+ first = tagService.selectOne(new EntityWrapper<Tag>().eq("level", 1));
+ if (first == null) {
+ throw new CoolException("鍏ㄩ儴鍒嗙被鍑洪敊");
+ }
+ }
+ NodeUtils nodeUtils = new NodeUtils();
+ nodeUtils.executePath(first.getId());
+ second = new Tag(
+ null, // 缂栧彿
+ data.getYjfl(), // 鍚嶇О
+ first.getId(), // 鐖剁骇
+ first.getName(), // 鐖剁骇鍚嶇О
+ nodeUtils.path.toString(), // 鍏宠仈璺緞
+ nodeUtils.pathName.toString(), // 鍏宠仈璺緞鍚�
+ 0, // 绫诲瀷
+ null, // 璐熻矗浜�
+ null, // 鍥剧墖
+ null, // 绠�瑕佹弿杩�
+ null, // 鏁伴噺
+ 2, // 绛夌骇
+ null, // 鎺掑簭
+ 1, // 鐘舵��
+ now, // 娣诲姞鏃堕棿
+ null, // 娣诲姞浜哄憳
+ now, // 淇敼鏃堕棿
+ null, // 淇敼浜哄憳
+ null // 澶囨敞
+ );
+ if (tagMapper.insert(second) == 0) {
+ throw new CoolException("鎻掑叆鍒嗙被澶辫触");
+ }
+ }
+
+ Tag third = tagService.selectOne(new EntityWrapper<Tag>().eq("level", 3).eq("name", data.getEjfl()).eq("parent_name", data.getYjfl()));
+ if (third == null) {
+ NodeUtils nodeUtils = new NodeUtils();
+ nodeUtils.executePath(second.getId());
+ third = new Tag(
+ null, // 缂栧彿
+ data.getEjfl(), // 鍚嶇О
+ second.getId(), // 鐖剁骇
+ second.getName(), // 鐖剁骇鍚嶇О
+ nodeUtils.path.toString(), // 鍏宠仈璺緞
+ nodeUtils.pathName.toString(), // 鍏宠仈璺緞鍚�
+ 0, // 绫诲瀷
+ null, // 璐熻矗浜�
+ null, // 鍥剧墖
+ null, // 绠�瑕佹弿杩�
+ null, // 鏁伴噺
+ 3, // 绛夌骇
+ null, // 鎺掑簭
+ 1, // 鐘舵��
+ now, // 娣诲姞鏃堕棿
+ null, // 娣诲姞浜哄憳
+ now, // 淇敼鏃堕棿
+ null, // 淇敼浜哄憳
+ null // 澶囨敞
+ );
+ if (tagMapper.insert(third) == 0) {
+ throw new CoolException("鎻掑叆鍒嗙被澶辫触");
+ }
+ }
+
+ if (null == mat) {
+ // 骞充粨
+ mat = new Mat(
+ String.valueOf(data.getRec()), // 缂栧彿
+ null, // 鎵�灞炲尯鍩�
+ third.getId(), // 鎵�灞炲綊绫�
+ data.getUserCode(), // 鍟嗗搧缂栧彿
+ data.getFullName(), // 鍟嗗搧鍚嶇О
+ null, // 鍚嶇О
+ data.getStandard(), // 瑙勬牸
+ null, // 鍨嬪彿
+ null, // 鎵瑰彿
+ data.getUnit3(), // 鍗曚綅
+ data.getBarcode(), // 鏉$爜
+ null, // 鍗曟嵁绫诲瀷
+ null, // 鍗曟嵁缂栧彿
+ null, // 瀹㈡埛鍚嶇О
+ null, // 鍝侀」鏁�
+ null, // 搴撳瓨浣欓噺
+ null, // 閲嶉噺
+ 1, //
+ null, // 娣诲姞浜哄憳
+ now, // 娣诲姞鏃堕棿
+ null, // 淇敼浜哄憳
+ updateTime, // 淇敼鏃堕棿
+ null // 澶囨敞
+ );
+
+ matService.insert(mat);
+ // 绔嬪簱
+
+ } else {
+ // 骞充粨
+ mat.setUuid(String.valueOf(data.getRec()));
+ mat.setMatnr(data.getUserCode());
+ mat.setMaktx(data.getFullName());
+ mat.setSpecs(data.getStandard());
+ mat.setUpdateTime(updateTime);
+ mat.setBarcode(data.getBarcode());
+ mat.setUnit(data.getUnit3());
+ matService.updateById(mat);
+ // 绔嬪簱
+
+ }
+ log.info("====>> 鏇存柊鐗╂枡锛歿}", data.getUserCode());
+ }
+
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new RuntimeException(e.getMessage());
+ }
+ }
+
+ /**
+ * 鍟嗗搧涓嬭浇
+ */
+ @Scheduled(cron = "0 */2 * * * ? ")
+ public void updateMatExecute(){
+ try {
+ Map<String, Object> param = new HashMap<>();
+ param.put("Flag", 6);
+ String response = new HttpHandler.Builder()
+ .setUri(URI)
+ .setPath(GET_BASIS)
+ .setJson(JSON.toJSONString(param))
+ .build()
+ .doPost();
+ if (!Cools.isEmpty(response)) {
+ log.info("鍟嗗搧鏁版嵁鏇存柊锛�");
log.info(response);
Date now = new Date();
Result result = JSON.parseObject(response, Result.class);
@@ -195,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());
@@ -204,152 +366,10 @@
mat.setUpdateTime(updateTime);
mat.setBarcode(data.getBarcode());
mat.setUnit(data.getUnit3());
- matService.updateById(mat);
- }
- log.info("====>> 鏇存柊鐗╂枡锛歿}", data.getUserCode());
- }
-
- }
- } catch (Exception e) {
- e.printStackTrace();
- throw new RuntimeException(e.getMessage());
- }
- }
-
- /**
- * 鍟嗗搧涓嬭浇
- */
- @Scheduled(cron = "0 */2 * * * ? ")
- public void updateMatExecute(){
- try {
- Map<String, Object> param = new HashMap<>();
- param.put("Flag", 6);
- String response = new HttpHandler.Builder()
- .setUri(URI)
- .setPath(GET_BASIS)
- .setJson(JSON.toJSONString(param))
- .build()
- .doPost();
- if (!Cools.isEmpty(response)) {
-// log.info(response);
- Date now = new Date();
- Result result = JSON.parseObject(response, Result.class);
- if (result.getCode() != 1) {
- return;
- }
- List<GetBasisResult> list = JSON.parseArray(result.getData(), GetBasisResult.class);
- Tag first = null;
- for (GetBasisResult data : list) {
- Mat mat = matService.selectByMatnr(data.getUserCode());
- String modifyDate = data.getModifyDate();
- Date updateTime = null;
- if (!Cools.isEmpty(modifyDate)) {
- updateTime = DateUtils.convert(data.getModifyDate());
- }
-
- // 鍒嗙被
- Tag second = tagService.selectOne(new EntityWrapper<Tag>().eq("name", data.getYjfl()).eq("level", 2));
- if (second == null) {
- if (first == null) {
- first = tagService.selectOne(new EntityWrapper<Tag>().eq("level", 1));
- if (first == null) {
- throw new CoolException("鍏ㄩ儴鍒嗙被鍑洪敊");
- }
+ if (matService.updateById(mat)) {
+ MatCode matCode = mat.beMatCode();
+ matCodeMapper.updateById(matCode);
}
- NodeUtils nodeUtils = new NodeUtils();
- nodeUtils.executePath(first.getId());
- second = new Tag(
- null, // 缂栧彿
- data.getYjfl(), // 鍚嶇О
- first.getId(), // 鐖剁骇
- first.getName(), // 鐖剁骇鍚嶇О
- nodeUtils.path.toString(), // 鍏宠仈璺緞
- nodeUtils.pathName.toString(), // 鍏宠仈璺緞鍚�
- 0, // 绫诲瀷
- null, // 璐熻矗浜�
- null, // 鍥剧墖
- null, // 绠�瑕佹弿杩�
- null, // 鏁伴噺
- 2, // 绛夌骇
- null, // 鎺掑簭
- 1, // 鐘舵��
- now, // 娣诲姞鏃堕棿
- null, // 娣诲姞浜哄憳
- now, // 淇敼鏃堕棿
- null, // 淇敼浜哄憳
- null // 澶囨敞
- );
- if (tagMapper.insert(second) == 0) {
- throw new CoolException("鎻掑叆鍒嗙被澶辫触");
- }
- }
-
- Tag third = tagService.selectOne(new EntityWrapper<Tag>().eq("level", 3).eq("name", data.getEjfl()).eq("parent_name", data.getYjfl()));
- if (third == null) {
- NodeUtils nodeUtils = new NodeUtils();
- nodeUtils.executePath(second.getId());
- third = new Tag(
- null, // 缂栧彿
- data.getEjfl(), // 鍚嶇О
- second.getId(), // 鐖剁骇
- second.getName(), // 鐖剁骇鍚嶇О
- nodeUtils.path.toString(), // 鍏宠仈璺緞
- nodeUtils.pathName.toString(), // 鍏宠仈璺緞鍚�
- 0, // 绫诲瀷
- null, // 璐熻矗浜�
- null, // 鍥剧墖
- null, // 绠�瑕佹弿杩�
- null, // 鏁伴噺
- 3, // 绛夌骇
- null, // 鎺掑簭
- 1, // 鐘舵��
- now, // 娣诲姞鏃堕棿
- null, // 娣诲姞浜哄憳
- now, // 淇敼鏃堕棿
- null, // 淇敼浜哄憳
- null // 澶囨敞
- );
- if (tagMapper.insert(third) == 0) {
- throw new CoolException("鎻掑叆鍒嗙被澶辫触");
- }
- }
-
- if (null == mat) {
- mat = new Mat(
- String.valueOf(data.getRec()), // 缂栧彿
- null, // 鎵�灞炲尯鍩�
- third.getId(), // 鎵�灞炲綊绫�
- data.getUserCode(), // 鍟嗗搧缂栧彿
- data.getFullName(), // 鍟嗗搧鍚嶇О
- null, // 鍚嶇О
- data.getStandard(), // 瑙勬牸
- null, // 鍨嬪彿
- null, // 鎵瑰彿
- data.getUnit3(), // 鍗曚綅
- data.getBarcode(), // 鏉$爜
- null, // 鍗曟嵁绫诲瀷
- null, // 鍗曟嵁缂栧彿
- null, // 瀹㈡埛鍚嶇О
- null, // 鍝侀」鏁�
- null, // 搴撳瓨浣欓噺
- null, // 閲嶉噺
- 1, //
- null, // 娣诲姞浜哄憳
- now, // 娣诲姞鏃堕棿
- null, // 淇敼浜哄憳
- updateTime, // 淇敼鏃堕棿
- null // 澶囨敞
- );
- matService.insert(mat);
- } else {
- mat.setUuid(String.valueOf(data.getRec()));
- mat.setMatnr(data.getUserCode());
- mat.setMaktx(data.getFullName());
- mat.setSpecs(data.getStandard());
- mat.setUpdateTime(updateTime);
- mat.setBarcode(data.getBarcode());
- mat.setUnit(data.getUnit3());
- matService.updateById(mat);
}
log.info("====>> 鏇存柊鐗╂枡锛歿}", data.getUserCode());
}
--
Gitblit v1.9.1