From 86b8273226c7aa87e7c346659ed9e76278dcc471 Mon Sep 17 00:00:00 2001
From: zyx <zyx123456>
Date: 星期日, 15 十月 2023 11:28:01 +0800
Subject: [PATCH] AGV工作档取消和完成
---
src/main/java/com/zy/common/service/erp/task/ErpScheduler.java | 88 +++++++++++++++++++++++++++++++++++++++----
1 files changed, 79 insertions(+), 9 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 d60e592..0b38dcd 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
@@ -1,22 +1,28 @@
package com.zy.common.service.erp.task;
-import com.alibaba.fastjson.JSON;
import com.core.common.Cools;
+import com.core.common.DateUtils;
import com.core.exception.CoolException;
+import com.zy.asrs.entity.AllLocDetl;
+import com.zy.asrs.entity.InventoryVariance;
import com.zy.asrs.entity.Mat;
import com.zy.asrs.entity.Tag;
+import com.zy.asrs.service.AllLocDetlService;
+import com.zy.asrs.service.InventoryVarianceService;
import com.zy.asrs.service.MatService;
import com.zy.asrs.service.TagService;
import com.zy.asrs.task.AbstractHandler;
import com.zy.common.service.erp.ErpService;
import com.zy.common.service.erp.entity.Goods;
+import com.zy.common.service.erp.entity.WlzhVStRd;
import lombok.Synchronized;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
+import java.util.ArrayList;
+import java.util.Date;
import java.util.List;
/**
@@ -33,33 +39,97 @@
private TagService tagService;
@Autowired
private MatService matService;
+ @Autowired
+ private AllLocDetlService allLocDetlService;
+ @Autowired
+ private InventoryVarianceService inventoryVarianceService;
- @Scheduled(cron = "0/5 * * * * ? ")
+ //@Scheduled(cron = "0/5 * * * * ? ")
@Synchronized
@Transactional
public synchronized void syncMat() {
Tag top = tagService.getTop();
- List<Goods> goods = erpService.selectGoods(1);
+ List<Goods> goods = erpService.selectGoods(0);
+ Date now = new Date();
if (!Cools.isEmpty(goods)) {
for (Goods good : goods) {
- Mat mat = matService.selectByMatnr(good.getBarCode());
+ Mat mat = matService.selectByMatnr(good.getMaterialNO());
if (mat == null) {
mat = new Mat();
mat.setTagId(top.getId());
- mat.setMatnr(good.getBarCode());
- mat.setMaktx(good.getMaterialNO());
+ mat.setMatnr(good.getMaterialNO());
+// mat.setMaktx(good.getBarCode());
mat.setSpecs(good.getProdSpec());
mat.setModel(good.getBatch());
mat.setWeight(good.getNWT());
mat.setUnits(good.getNumOfBobbins()==null?null:good.getNumOfBobbins().doubleValue());
mat.setManuDate(good.getProdDate());
- if (!matService.insert(mat)) {
- throw new CoolException(JSON.toJSONString(good) + "鍟嗗搧鍚屾澶辫触");
+ mat.setCreateTime(now);
+ mat.setSku(good.getLocation());
+ if (!Cools.isEmpty(good.getLastUpdatedDate())) {
+ mat.setUpdateTime(DateUtils.convert(good.getLastUpdatedDate().substring(0, 19)));
}
+
+ if (!matService.insert(mat)) {
+ throw new CoolException(good.getBarCode() + "鍟嗗搧鍚屾澶辫触");
+ }
+ }
+ int state = 1;
+ if (!erpService.updateStateForGoods(good.getBarCode(), state)) {
+ throw new CoolException(good.getBarCode() + "鍟嗗搧淇敼State涓�"+state+"澶辫触");
}
}
}
}
+ //@Scheduled(cron = "0/5 * * * * ? ")
+ @Synchronized
+ @Transactional
+ public void syncLocDetl(){
+
+ List<InventoryVariance> inventoryVariances = new ArrayList<>();
+
+ int pageSize = 500;
+ int pageNumber = 0;
+ while (true){
+ List<WlzhVStRd> wlzhVStRds = erpService.selectPage(pageSize, pageNumber);
+ if(wlzhVStRds.size() < pageSize){
+ break;
+ }
+
+ //ERP搴撳瓨涓庣珛搴撳簱瀛樻瘮瀵�
+ compileStock(wlzhVStRds,inventoryVariances);
+ pageNumber ++;
+
+ }
+
+ inventoryVarianceService.insertBatch(inventoryVariances);
+
+ }
+
+ private void compileStock(List<WlzhVStRd> wlzhVStRds, List<InventoryVariance> inventoryVariances){
+ wlzhVStRds.forEach(wlzhVStRd -> {
+ String matnr = wlzhVStRd.getCInvCode();
+ String csocode = wlzhVStRd.getCsocode();
+ String isoseq = wlzhVStRd.getIsoseq();
+ Double iQuantity = wlzhVStRd.getIQuantity();
+
+ Double anfme = 0.0;
+
+ List<AllLocDetl> allLocDetlList = allLocDetlService.getByMatnrAndCsocodeAndIsoseq(matnr, csocode, isoseq);
+ for(AllLocDetl allLocDetl : allLocDetlList){
+ anfme += allLocDetl.getAnfme();
+ }
+
+ int compare = Double.compare(iQuantity, anfme);
+ if(compare != 0){
+ InventoryVariance inventoryVarianceParam = new InventoryVariance(matnr,csocode,isoseq,iQuantity,anfme);
+ inventoryVariances.add(inventoryVarianceParam);
+ }
+
+ });
+ }
+
+
}
--
Gitblit v1.9.1