From 04e6352d22eb928700d606bdf4e40e0eb2cfe61b Mon Sep 17 00:00:00 2001
From: mrzhssss <pro6@qq.com>
Date: 星期四, 16 十二月 2021 14:29:26 +0800
Subject: [PATCH] 更新
---
src/main/java/com/zy/common/service/erp/task/ErpScheduler.java | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 54 insertions(+), 6 deletions(-)
diff --git a/src/main/java/com/zy/common/service/erp/task/ErpScheduler.java b/src/main/java/com/zy/common/service/erp/task/ErpScheduler.java
index 9a2bfa6..1ff3a2e 100644
--- a/src/main/java/com/zy/common/service/erp/task/ErpScheduler.java
+++ b/src/main/java/com/zy/common/service/erp/task/ErpScheduler.java
@@ -16,6 +16,7 @@
import com.zy.common.service.erp.ErpService;
import com.zy.common.service.erp.dto.InStockDto;
import com.zy.common.service.erp.entity.*;
+import lombok.Synchronized;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
@@ -23,6 +24,7 @@
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.PostConstruct;
+import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@@ -52,15 +54,35 @@
/**
* 鍘熸潗鏂欏叆搴撳崟
*/
- @Scheduled(cron = "0/5 * * * * ? ")
+ @Scheduled(cron = "0/30 * * * * ? ")
+ @Synchronized
// @PostConstruct
public void inStockExecute(){
+// inStock鐨勮〃澶村拰琛ㄨ韩
List<InStockDto> readyInStock = erpService.getReadyInStock();
+
for (InStockDto dto : readyInStock) {
+
+ //鍚屼竴鍗曞彿瀛樺湪鐩稿悓鐗╂枡缂栫爜鏁版嵁锛岃鍗曞彿涓嶄簣澶勭悊
+ Number fnumberCount = erpService.QueryFnumberInCount(dto.getInStockBill().getFInterID());
+ if(fnumberCount.intValue() > 1){
+ if (!erpService.haveReadInStock(dto.getInStockBill().getFBillNo(),-1)) {
+ log.error("鏍囪鍘熸潗鏂欏叆搴撻�氱煡鍗曞凡璇籌nStockBill涓�-1澶辫触[FBillNo={},FInterID={}]", dto.getInStockBill().getFBillNo(),dto.getInStockBill().getFInterID());
+ }
+ continue;
+ }
+ log.info("璧板埌涓�鍙蜂綅缃�");
+ if (Cools.isEmpty(dto) || Cools.isEmpty(dto.getInStockBillEntries())) {
+ log.info(Cools.isEmpty(dto)+"#@@@");
+ log.info(Cools.isEmpty(dto.getInStockBillEntries())+"###@");
+ continue;
+ }
+ log.info("璧板埌浜屽彿浣嶇疆");
for (InStockBillEntry entry : dto.getInStockBillEntries()) {
MatCode matCode = matCodeService.selectById(entry.getFnumber());
if (null != matCode) {
// 鐢熸垚鍏ュ簱閫氱煡鍗�
+ log.info("璧板埌涓夊彿浣嶇疆");
WaitPakin waitPakin = new WaitPakin();
waitPakin.setMemo("鍘熸潗鏂�");
waitPakin.setStatus("Y"); // 鐘舵��
@@ -95,12 +117,13 @@
}
}
} catch (Exception e) {
+ log.error("fail", e);
e.printStackTrace();
System.out.println(JSON.toJSON(waitPakin));
}
}
}
- if (!erpService.haveReadInStock(dto.getInStockBill().getFBillNo())) {
+ if (!erpService.haveReadInStock(dto.getInStockBill().getFBillNo(),1)) {
log.error("鏍囪鍘熸潗鏂欏叆搴撻�氱煡鍗曞凡璇籌nStockBill澶辫触[FBillNo={}]", dto.getInStockBill().getFBillNo());
}
}
@@ -111,11 +134,22 @@
/**
* 鎴愬搧鍏ュ簱鍗�
*/
- @Scheduled(cron = "0/5 * * * * ? ")
+ @Scheduled(cron = "0/20 * * * * ? ")
+ @Synchronized
// @PostConstruct
public void inCPICMOExecute(){
List<CPICMO> cpicmos = erpService.getReadyCPICMO();
for (CPICMO cpicmo : cpicmos) {
+
+ //鍚屼竴鍗曞彿瀛樺湪鐩稿悓鐗╂枡缂栫爜鏁版嵁锛岃鍗曞彿涓嶄簣澶勭悊
+ Number fnumberCount = erpService.QueryFnumberCPICMOCount(cpicmo.getFInterID());
+ if(fnumberCount.intValue() > 1){
+ if (!erpService.haveReadCPICMO(cpicmo.getFInterID(),-1)) {
+ log.error("鏍囪鎴愬搧鍏ュ簱閫氱煡鍗曞凡璇籆PICMO涓�-1澶辫触[Fnumber={},FInterID={}]", cpicmo.getFnumber(),cpicmo.getFInterID());
+ }
+ continue;
+ }
+
MatCode matCode = matCodeService.selectById(cpicmo.getFnumber());
if (null != matCode) {
// 鐢熸垚鍏ュ簱閫氱煡鍗�
@@ -151,14 +185,15 @@
log.info("鍚屾鏇存柊鎴愬搧鍏ュ簱閫氱煡鍗旵PICMO澶辫触[FBillNo={},Fnumber={}]", waitPakin.getSupplier(), waitPakin.getMatnr());
}
}
- if (!erpService.haveReadCPICMO(cpicmo.getFBillNo())) {
+ if (!erpService.haveReadCPICMO(cpicmo.getFInterID(),1)) {
log.error("鏍囪鎴愬搧鍏ュ簱閫氱煡鍗曞凡璇籆PICMO澶辫触[FBillNo={}]", cpicmo.getFBillNo());
}
}
}
}
- @Scheduled(cron = "0/5 * * * * ? ")
+ @Scheduled(cron = "0/30 * * * * ? ")
+ @Synchronized
public void syncMat(){
List<M_item> items = erpService.getItem();
for (M_item item : items) {
@@ -193,11 +228,22 @@
* 鎴愬搧鍑哄簱 鍙戣揣閫氱煡鍗曡〃澶�,琛ㄦ槑缁�
*/
@Scheduled(cron = "0/15 * * * * ? ")
+ @Synchronized
@Transactional
public void syncOutStock(){
List<OutStockBill> outStockBills = erpService.syncOutStock();
for (Integer i = 0; i < outStockBills.size(); i++) {
OutStockBill outStockBill = outStockBills.get(i);
+
+ //鍚屼竴鍗曞彿瀛樺湪鐩稿悓鐗╂枡缂栫爜鏁版嵁锛岃鍗曞彿涓嶄簣澶勭悊
+ Number fnumberCount = erpService.QueryFnumberOutCount(outStockBill.getFInterID());
+ if(fnumberCount.intValue() > 1){
+ if (!erpService.haveReadOutBill(outStockBill.getFBillNo(),outStockBill.getFInterID(),-1)) {
+ log.error("鏇存柊鍑哄簱閫氱煡鍗曡鍙栫姸鎬佷负-1澶辫触[FBrNo={},FInterID={}]", outStockBill.getFBrNo(),outStockBill.getFInterID());
+ }
+ continue;
+ }
+
OutStockBill main = outStockMainService.selectOne(new EntityWrapper<OutStockBill>().eq("FBillNo",outStockBill.getFBillNo()).and().eq("FInterID", outStockBill.getFInterID()));
if (null == main) {
outStockBill.setFflag_rw(1);
@@ -214,6 +260,7 @@
if (null == one) {
// String Fnumber = (Cools.isEmpty(outStockBillEntry.getFSourceBillNo())) ? outStockBillEntry.getFnumber() : outStockBillEntry.getFnumber()+"|"+outStockBillEntry.getFSourceBillNo();
// outStockBillEntry.setFnumber(Fnumber); //浜у搧浠g爜|鐢熶骇鍗曞彿
+ outStockBillEntry.setFAmount(new BigDecimal(0));
if (!outStockService.insert(outStockBillEntry)) {
log.info("鎻愬彇鍑哄簱閫氱煡鏄庣粏琛∣utStockBillEntry澶辫触[FBrNo={},FInterID={},FEntryID={}]",outStockBillEntry.getFBrNo(),
outStockBillEntry.getFInterID(),outStockBillEntry.getFEntryID());
@@ -226,6 +273,7 @@
} else {
// 鏁伴噺鏈夊彉鍖栬繘琛屾洿鏂�
if (Double.doubleToLongBits(one.getFAuxQty().doubleValue()) != Double.doubleToLongBits(outStockBillEntry.getFAuxQty().doubleValue())) {
+ outStockBillEntry.setFAmount(new BigDecimal(0));
if (!outStockService.update(outStockBillEntry, wrapper)) {
log.info("鍚屾鏇存柊閫氱煡鏄庣粏琛∣utStockBillEntry澶辫触[FBrNo={},FInterID={},FEntryID={}]",outStockBillEntry.getFBrNo(),
outStockBillEntry.getFInterID(),outStockBillEntry.getFEntryID());
@@ -242,7 +290,7 @@
}
- if (!erpService.haveReadOutBill(outStockBill.getFBillNo(),outStockBill.getFInterID())) {
+ if (!erpService.haveReadOutBill(outStockBill.getFBillNo(),outStockBill.getFInterID(),1)) {
log.error("鏇存柊鍑哄簱閫氱煡鍗曡鍙栫姸鎬佸け璐FBrNo={},FInterID={}]", outStockBill.getFBrNo(),outStockBill.getFInterID());
}
}
--
Gitblit v1.9.1