From 587fcf4a73c44330a5d75ced8ccf0274666c3cbe Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期二, 16 三月 2021 08:17:59 +0800
Subject: [PATCH] #
---
src/main/java/zy/cloud/wms/common/service/erp/ErpScheduler.java | 211 ++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 200 insertions(+), 11 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 387f582..ee72258 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
@@ -1,14 +1,23 @@
package zy.cloud.wms.common.service.erp;
import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.common.Cools;
+import com.core.common.DateUtils;
+import com.core.exception.CoolException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
-import zy.cloud.wms.common.service.erp.entity.GetDataResult;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RestController;
+import zy.cloud.wms.common.service.erp.entity.GetBasisResult;
+import zy.cloud.wms.common.service.erp.entity.GetOrderResult;
+import zy.cloud.wms.manager.entity.Cstmr;
import zy.cloud.wms.manager.entity.CustOrder;
-import zy.cloud.wms.manager.service.CustOrderService;
+import zy.cloud.wms.manager.entity.Mat;
+import zy.cloud.wms.manager.mapper.TagMapper;
+import zy.cloud.wms.manager.service.*;
import zy.cloud.wms.manager.utils.HttpHandler;
import java.io.IOException;
@@ -24,13 +33,114 @@
*/
@Slf4j
@Component
+@RestController
public class ErpScheduler {
- public static final String URI = "http://8.133.182.21:8080/api/";
+ public static final String URI = "http://8.133.182.21:8080/api";
public static final String GET_ORDERS = "cM/basis/getOrders";
+ public static final String GET_BASIS = "cM/basis/getBasis";
+ public static final String UPLOAD_STOCK = "cM/basis/uploadStock";
@Autowired
private CustOrderService custOrderService;
+ @Autowired
+ private MatService matService;
+ @Autowired
+ private CstmrService cstmrService;
+ @Autowired
+ private LocDetlService locDetlService;
+ @Autowired
+ private TagService tagService;
+ @Autowired
+ private TagMapper tagMapper;
+
+ /**
+ * 鍟嗗搧涓嬭浇
+ */
+ // @Scheduled(cron = "0/5 * * * * ? ")
+ @GetMapping("/test1")
+// @PostConstruct
+ public void getBasis1Execute(){
+ try {
+ Map<String, Object> param = new HashMap<>();
+ param.put("rec", 0);
+ param.put("Flag", 1);
+ String response = new HttpHandler.Builder()
+ .setUri(URI)
+ .setPath(GET_BASIS)
+ .setJson(JSON.toJSONString(param))
+ .build()
+ .doPost();
+ if (!Cools.isEmpty(response)) {
+
+
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * 瀹㈡埛涓嬭浇
+ */
+ // @Scheduled(cron = "0/5 * * * * ? ")
+// @PostConstruct
+ public void getBasis2Execute(){
+ try {
+ Map<String, Object> param = new HashMap<>();
+ param.put("rec", 0);
+ param.put("Flag", 2);
+ 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);
+ for (GetBasisResult data : list) {
+ Cstmr cstmr = cstmrService.selectOne(new EntityWrapper<Cstmr>().eq("uuid", data.getUserCode()));
+ String modifyDate = data.getModifyDate();
+ Date updateTime = null;
+ if (!Cools.isEmpty(modifyDate)) {
+ updateTime = DateUtils.convert(data.getModifyDate());
+ }
+ if (null == cstmr) {
+ cstmr = new Cstmr(
+ data.getUserCode(), // 瀹㈡埛缂栧彿[闈炵┖]
+ data.getFullName(), // 瀹㈡埛鍚嶇О
+ null, // 鑱旂郴浜�
+ null, // 鑱旂郴鐢佃瘽
+ null, // 鑱旂郴鍦板潃
+ 1, // 鐘舵��
+ null, // 娣诲姞浜哄憳
+ now, // 娣诲姞鏃堕棿
+ null, // 淇敼浜哄憳
+ updateTime, // 淇敼鏃堕棿
+ String.valueOf(data.getRec()) // 澶囨敞
+ );
+ cstmrService.insert(cstmr);
+ } else {
+ cstmr.setUuid(data.getUserCode());
+ cstmr.setName(data.getFullName());
+ cstmr.setUpdateTime(updateTime);
+ cstmr.setMemo(String.valueOf(data.getRec()));
+ cstmrService.updateById(cstmr);
+ }
+ log.info("====>> 鏇存柊瀹㈡埛璧勬枡锛歿}", data.getUserCode());
+ }
+
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
/**
* 鎸佷箙鍖栭攢鍞鍗�
@@ -47,19 +157,20 @@
.setJson(JSON.toJSONString(json))
.build()
.doPost();
- if (Cools.isEmpty(response)) {
- log.error("璇锋眰锛歿}\nError锛屽搷搴旂粨鏋滀负绌�!", URI + GET_ORDERS);
- } else {
+ if (!Cools.isEmpty(response)) {
log.info(response);
Date now = new Date();
Result result = JSON.parseObject(response, Result.class);
if (result.getCode() != 1) {
return;
}
- List<GetDataResult> list = JSON.parseArray(result.getData(), GetDataResult.class);
+ List<GetOrderResult> list = JSON.parseArray(result.getData(), GetOrderResult.class);
if (!Cools.isEmpty(list)) {
boolean complete = true;
- for (GetDataResult data : list) {
+ for (GetOrderResult data : list) {
+ if (custOrderService.selectCount(new EntityWrapper<CustOrder>().eq("number", data.getNumber()).ne("bType_id", data.getBTypeID())) > 0) {
+ throw new CoolException("鎶辨瓑鍗曞彿宸插瓨鍦紝璇蜂慨鏀瑰崟鍙凤細" + data.getNumber());
+ }
CustOrder custOrder = new CustOrder(
data.getNumber(), // 閿�鍞崟鍙�
data.getBillDate(), // 鍗曟嵁鏃ユ湡[闈炵┖]
@@ -69,7 +180,7 @@
data.getQty(), // 鍟嗗搧鏁伴噺
data.getPrice(), // 鍟嗗搧鍗曚环
data.getComment(), // 鍟嗗搧澶囨敞[闈炵┖]
- 1, // 鐘舵��
+ 0, // 鐘舵��
now, // 娣诲姞鏃堕棿
now, // 淇敼鏃堕棿
null // 澶囨敞
@@ -81,9 +192,9 @@
}
}
if (complete) {
- List<String> collect = list.stream().map(GetDataResult::getNumber).distinct().collect(Collectors.toList());
+ List<String> collect = list.stream().map(GetOrderResult::getNumber).distinct().collect(Collectors.toList());
for (String number : collect) {
- custOrderService.completeLoading(number);
+ custOrderService.updateStatus(number, 1);
}
}
@@ -96,5 +207,83 @@
}
+ /**
+ * 鏇存柊搴撳瓨
+ */
+// @Scheduled(cron = "0/3 * * * * ? ")
+ public void uploadStockExecute(){
+ try {
+
+// locDetlService
+
+ Map<String, Object> param = new HashMap<>();
+ param.put("rec", 0);
+ param.put("Flag", 1);
+ 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);
+ 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());
+ }
+ if (null == mat) {
+ mat = new Mat(
+ String.valueOf(data.getRec()), // 缂栧彿
+ null, // 鎵�灞炲尯鍩�
+ null, // 鎵�灞炲綊绫�
+ data.getUserCode(), // 鍟嗗搧缂栧彿
+ data.getFullName(), // 鍟嗗搧鍚嶇О
+ null, // 鍚嶇О
+ null, // 瑙勬牸
+ null, // 鍨嬪彿
+ null, // 鎵瑰彿
+ null, // 鍗曚綅
+ null, // 鏉$爜
+ 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.setUpdateTime(updateTime);
+ matService.updateById(mat);
+ }
+ log.info("====>> 鏇存柊鐗╂枡锛歿}", data.getUserCode());
+ }
+
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+
+ }
+
}
--
Gitblit v1.9.1