From dc9228656b202a8f1ec7720d78eb0421a94a28c9 Mon Sep 17 00:00:00 2001
From: pang.jiabao <pang_jiabao@163.com>
Date: 星期四, 23 十月 2025 16:20:14 +0800
Subject: [PATCH] 聚乳酸明细增加丙交酯含量,%指标
---
src/main/java/com/zy/asrs/utils/PlaExcelListener.java | 195 +++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 167 insertions(+), 28 deletions(-)
diff --git a/src/main/java/com/zy/asrs/utils/PlaExcelListener.java b/src/main/java/com/zy/asrs/utils/PlaExcelListener.java
index fae28c7..568bae8 100644
--- a/src/main/java/com/zy/asrs/utils/PlaExcelListener.java
+++ b/src/main/java/com/zy/asrs/utils/PlaExcelListener.java
@@ -5,28 +5,34 @@
import com.core.common.Cools;
import com.core.common.SpringUtils;
import com.core.exception.CoolException;
+import com.zy.asrs.entity.Mat;
import com.zy.asrs.entity.Node;
import com.zy.asrs.entity.Pla;
import com.zy.asrs.entity.param.GlobleParameter;
+import com.zy.asrs.service.MatService;
import com.zy.asrs.service.NodeService;
import com.zy.asrs.service.PlaService;
import com.zy.common.entity.MatExcel;
import com.zy.common.entity.PlaExcel;
+import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
/**
* Created by vincent on 2019-11-25
*/
@Slf4j
+@Data
public class PlaExcelListener extends AnalysisEventListener<PlaExcel> {
+ private static final String OWNER_HZ = "娴锋鐢熺墿";
+ private static final String OWNER_HNE = "娴疯灏�";
+
private int total = 0;
+ private int index = 1;
+ private String recordLog = "";
private Long userId;
public PlaExcelListener() {
@@ -55,45 +61,137 @@
*/
@Override
public void invoke(PlaExcel excel, AnalysisContext ctx) {
+ index ++;
PlaService plaService = SpringUtils.getBean(PlaService.class);
NodeService nodeService = SpringUtils.getBean(NodeService.class);
+ MatService matService = SpringUtils.getBean(MatService.class);
Date now = new Date();
+
+
// 鍟嗗搧
if(Cools.isEmpty(excel.getBatch()) || Cools.isEmpty(excel.getPackageNo())){
- return;
+ throw new CoolException("绗�" + index++ + "鏁版嵁閿欒锛屽寘鍙锋垨鑰呮壒鍙蜂负绌�");
}
- Pla pla = plaService.selectByBatchAndPackageNo(excel.getBatch(),excel.getPackageNo());
+ Pla pla = plaService.selectByBatchAndPackageNo(excel.getBatch(),excel.getPackageNo(),excel.getBrand());
if (pla == null) {
- pla = excel;
- pla.setStep(2);
+ pla = plaCreate(pla,excel,matService,nodeService);
pla.setCreateTime(new Date());
- pla.setModifyTime(new Date());
- pla.setStatus(GlobleParameter.PLA_STATUS_00);
- pla.setStockFreeze(1);
- if(!Cools.isEmpty(pla.getLocNo())){
- Node node = nodeService.selectByUuid(pla.getLocNo());
- if(Cools.isEmpty(node)){
- throw new CoolException("鏈兘鎵惧埌鐩稿簲鐨勫簱浣嶄俊鎭�");
- }
- pla.setStash(node.getParentName());
- pla.setLocNo(node.getUuid());
- pla.setStatus(GlobleParameter.PLA_STATUS_1);
- pla.setPakinTime(new Date());
+ try {
+ plaService.insert(pla);
+ }catch (Exception e){
+ log.error("淇濆瓨鍟嗗搧淇℃伅澶辫触锛屾壒鍙凤細" + excel.getBatch() + ", 鍖呭彿锛�" + excel.getPackageNo() + "鍘熷洜涓猴細" + e.getMessage());
+ throw new CoolException("淇濆瓨鍟嗗搧淇℃伅澶辫触锛屾壒鍙凤細" + excel.getBatch() + ", 鍖呭彿锛�" + excel.getPackageNo() + "鍘熷洜涓猴細" + e.getMessage());
}
- if (!plaService.insert(pla)) {
- throw new CoolException("淇濆瓨鍟嗗搧淇℃伅澶辫触锛屽晢鍝佺紪鐮侊細" + excel.getMatnr());
- }
+// if (!plaService.insert(pla)) {
+// throw new CoolException("淇濆瓨鍟嗗搧淇℃伅澶辫触锛屽晢鍝佺紪鐮侊細" + excel.getMatnr());
+// }
total++;
- }else if (pla.getStatus().equals(GlobleParameter.PLA_STATUS_00)){
+ }else if(Cools.eq(pla.getStatus(),GlobleParameter.PLA_STATUS_0) || Cools.eq(pla.getStatus(),GlobleParameter.PLA_STATUS_00) || Cools.eq(pla.getStatus(),GlobleParameter.PLA_STATUS_1) ){
excel.setId(pla.getId());
excel.setCreateTime(pla.getCreateTime());
- excel.setModifyTime(new Date());
- excel.setStep(2);
- excel.setStatus(GlobleParameter.PLA_STATUS_00);
+ excel.setStatus(pla.getStatus());
+ excel.setPakinTime(pla.getPakinTime());
+ excel.setStash(pla.getStash());
+ excel.setStockFreeze(pla.getStockFreeze());
+ if(Cools.isEmpty(excel.getLocNo())){
+ excel.setLocNo(pla.getLocNo());
+ }
BeanUtils.copyProperties(excel,pla);
- plaService.updateById(pla);
+ pla = plaCreate(pla,excel,matService,nodeService);
+ try {
+ plaService.updateById(pla);
+ recordLog = recordLog + index + "," + pla.getBatch() + "," + pla.getPackageNo() + ";" ;
+ }catch (Exception e){
+ log.error("淇濆瓨鍟嗗搧淇℃伅澶辫触锛屾壒鍙凤細" + excel.getBatch() + ", 鍖呭彿锛�" + excel.getPackageNo() + "鍘熷洜涓猴細" + e.getMessage());
+ throw new CoolException("淇濆瓨鍟嗗搧淇℃伅澶辫触锛屾壒鍙凤細" + excel.getBatch() + ", 鍖呭彿锛�" + excel.getPackageNo() + "鍘熷洜涓猴細" + e.getMessage());
+ }
total++;
+ } else if (Cools.eq(pla.getStatus(),GlobleParameter.PLA_STATUS_2) || Cools.eq(pla.getStatus(),GlobleParameter.PLA_STATUS_3) || Cools.eq(pla.getStatus(),GlobleParameter.PLA_STATUS_4)) {
+ // 琛ヤ紶璐ㄩ噺鎸囨爣
+ pla.setProDate(excel.getProDate());
+ pla.setWeight(excel.getWeight());
+ pla.setPackageType(excel.getPackageType());
+ pla.setZpalletType(excel.getZpalletType());
+ pla.setFingerMelting(excel.getFingerMelting());
+ pla.setWater(excel.getWater());
+ pla.setFusingPoint(excel.getFusingPoint());
+ pla.setVadf1(excel.getVadf1());
+ pla.setVadf2(excel.getVadf2());
+ pla.setYellowness(excel.getYellowness());
+ pla.setOpacity(excel.getOpacity());
+ pla.setLactideContent(excel.getLactideContent());
+ pla.setL(excel.getL());
+ pla.setA(excel.getA());
+ pla.setB(excel.getB());
+ pla.setFillIn(excel.getFillIn());
+ pla.setStr1(excel.getStr1());
+ pla.setStr2(excel.getStr2());
+ pla.setStr3(excel.getStr3());
+ pla.setStr4(excel.getStr4());
+ pla.setStr5(excel.getStr5());
+ pla.setStr6(excel.getStr6());
+ pla.setMassState(excel.getMassState());
+ pla.setProblem(excel.getProblem());
+ pla.setModifyTime(now);
+ try {
+ plaService.updateById(pla);
+ recordLog = recordLog + index + "," + pla.getBatch() + "," + pla.getPackageNo() + ";" ;
+ } catch (Exception e){
+ log.error("琛ヤ紶璐ㄩ噺鎸囨爣寮傚父锛屾壒鍙凤細" + excel.getBatch() + ", 鍖呭彿锛�" + excel.getPackageNo() + "鍘熷洜涓猴細" + e.getMessage());
+ throw new CoolException("琛ヤ紶璐ㄩ噺鎸囨爣寮傚父锛屾壒鍙凤細" + excel.getBatch() + ", 鍖呭彿锛�" + excel.getPackageNo() + "鍘熷洜涓猴細" + e.getMessage());
+ }
+ total++;
+ }
+ }
+
+ private String getType(String matnr){
+ String type = matnr.substring(0,3);
+ if(Cools.eq(type,"301")){
+ return "绾爲鑴�";
+ }
+ if (Cools.eq(type,"302")){
+ return "鏀规�ф爲鑴�";
+ }
+ if (Cools.eq(type,"303")){
+ return "鍓骇鐗�";
+ }
+ if (Cools.eq(type,"304")){
+ return "濮旀墭鍔犲伐浜у搧";
+ }
+ if (Cools.eq(type,"305")){
+ return "涓欎氦閰�";
+ }
+
+ return "";
+ }
+
+ private void setPla(Pla pla){
+ String batch = pla.getBatch();
+ String line = batch.substring(8,10);
+
+ if(Cools.isEmpty(pla.getLine())){
+ pla.setLine(line);
+ }
+
+ if(Cools.isEmpty(pla.getOwner()) && Cools.isEmpty(pla.getWorkshop())){
+ if("绾爲鑴�".equals(pla.getType())){
+ if("01".equals(line) || "02".equals(line)){
+ pla.setOwner(OWNER_HZ);
+ pla.setWorkshop("涓�杞﹂棿");
+ }else {
+ pla.setOwner(OWNER_HNE);
+ pla.setWorkshop("涓夎溅闂�");
+ }
+ }else if ("鏀规�ф爲鑴�".equals(pla.getType())){
+ if (pla.getBrand() != null && (pla.getBrand().equals("161") || pla.getBrand().equals("171") || pla.getBrand().equals("181"))) {
+ pla.setOwner(OWNER_HZ);
+ pla.setWorkshop("涓�杞﹂棿");
+ } else if ("01".equals(line) || "02".equals(line) || "03".equals(line) || "04".equals(line)){
+ pla.setOwner(OWNER_HNE);
+ pla.setWorkshop("浜岃溅闂�");
+ }
+ }
}
}
@@ -109,4 +207,45 @@
public int getTotal() {
return total;
}
+
+ private Pla plaCreate(Pla pla, PlaExcel excel, MatService matService, NodeService nodeService){
+ pla = excel;
+ pla.setStep(2);
+ pla.setModifyTime(new Date());
+ pla.setStatus(GlobleParameter.PLA_STATUS_00);
+ pla.setStockFreeze(Cools.isEmpty(excel.getStockFreeze()) ? 1 : excel.getStockFreeze());
+ pla.setWeightAnfme(pla.getWeight());
+ Mat mat = matService.selectByMaktx(pla.getBrand());
+ if(Cools.isEmpty(mat)){
+ throw new CoolException("鏃犳硶鎵惧埌瀵瑰簲鐨勭墝鍙蜂俊鎭紝鐗屽彿=" + pla.getBrand());
+ }
+ if (!Cools.isEmpty(excel.getProblem()) && excel.getProblem().contains("瀹為獙鏂�")) {
+ excel.setMassState("瀹為獙鏂�");
+ }
+ pla.setMatnr(mat.getMatnr());
+ try {
+ if(Cools.isEmpty(pla.getType())){
+ pla.setType(getType(mat.getMatnr()));
+ }
+ //杞﹂棿銆佷骇绾裤�佷富浣�
+ setPla(pla);
+ }catch (Exception e){
+ log.info(e.getMessage() + "Pla: " + pla.getBatch());
+ throw new CoolException(e.getMessage() + "锛屾壒鍙凤細" + excel.getBatch() + ", 鍖呭彿锛�" + excel.getPackageNo());
+ }
+
+ if(!Cools.isEmpty(pla.getLocNo())){
+ Node node = nodeService.selectByUuid(pla.getLocNo());
+ if(Cools.isEmpty(node)){
+ throw new CoolException("鏈兘鎵惧埌鐩稿簲鐨勫簱浣嶄俊鎭紝搴撲綅缂栧彿=" +pla.getLocNo());
+ //log.info("鏈兘鎵惧埌鐩稿簲鐨勫簱浣嶄俊鎭紝搴撲綅缂栧彿={}",pla.getLocNo());
+ }
+ pla.setStash(node.getParentName());
+ pla.setLocNo(node.getUuid());
+ pla.setStatus(GlobleParameter.PLA_STATUS_1);
+ pla.setPakinTime(new Date());
+ }
+
+ return pla;
+ }
}
--
Gitblit v1.9.1