From 2c6fd8b6dab2ea9507938fd2f30bea3350676c78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=91=A3=E5=93=B2=E5=A5=87?= <13840175730@139.com> Date: Tue, 9 Sep 2025 16:05:28 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BC=98=E5=8C=96=E6=8A=80=E6=9C=AF=E5=87=86?= =?UTF-8?q?=E5=A4=87=E6=95=B0=E6=8D=AE=E4=B8=8A=E4=BC=A0=E9=80=BB=E8=BE=91?= =?UTF-8?q?=202.=E8=A7=A3=E5=86=B3=E5=AF=BC=E5=87=BA=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gj_erp/jszb/control/JszbController.java | 88 ++++++++++++++----- .../dsic/gj_erp/jszb/entity/PartFlowInfo.java | 4 + 2 files changed, 72 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/dsic/gj_erp/jszb/control/JszbController.java b/src/main/java/com/dsic/gj_erp/jszb/control/JszbController.java index b3cf825..3334a31 100644 --- a/src/main/java/com/dsic/gj_erp/jszb/control/JszbController.java +++ b/src/main/java/com/dsic/gj_erp/jszb/control/JszbController.java @@ -1,6 +1,7 @@ package com.dsic.gj_erp.jszb.control; import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; import cn.hutool.core.util.ObjUtil; import cn.hutool.core.util.StrUtil; import com.alibaba.excel.EasyExcel; @@ -39,6 +40,7 @@ public class JszbController { List list = flowInfoService.list(Wrappers.lambdaQuery() .eq(PartFlowInfo::getCh, ch) .eq(StrUtil.isEmpty(end) && StrUtil.isNotEmpty(begin), PartFlowInfo::getPl, begin) + .isNotNull(PartFlowInfo::getPl) .between(StrUtil.isAllNotEmpty(begin, end), PartFlowInfo::getPl, begin, end) .orderByAsc(PartFlowInfo::getPl,PartFlowInfo::getFd) ); @@ -51,31 +53,77 @@ public class JszbController { EasyExcel.read(file.getInputStream(), PartFlowInfo.class, objectListener).sheet(0).headRowNumber(1).doRead(); List objList = objectListener.getObjectList(); - List errors = objectListener.getErrors(); - List updateList=new ArrayList<>(); - objList.forEach(item->{ - PartFlowInfo one = flowInfoService.getOne(Wrappers.lambdaQuery() - .eq(StrUtil.isNotEmpty(item.getCh()),PartFlowInfo::getCh, item.getCh()) - .eq(StrUtil.isNotEmpty(item.getCh()),PartFlowInfo::getPartName,item.getPartName()) - .eq(StrUtil.isNotEmpty(item.getProject()),PartFlowInfo::getCh,item.getProject()) - .eq(StrUtil.isNotEmpty(item.getProject()),PartFlowInfo::getPartName,item.getPartName0()) - ); - - if (ObjUtil.isEmpty(one)){ - one = new PartFlowInfo(); + try { + ExcelFlowInfoListener objectListener1 = new ExcelFlowInfoListener(); + EasyExcel.read(file.getInputStream(), PartFlowInfo.class, objectListener1).sheet(1).headRowNumber(1).doRead(); + List objList2 = objectListener1.getObjectList(); + + List _list=new ArrayList<>(); + item2: + for (PartFlowInfo item2:objList2){ + for (PartFlowInfo item1:objList){ + if (ObjUtil.equal(item1.getCh(),item2.getCh())&&ObjUtil.equal(item1.getPartName(),item2.getPartName())){ + continue item2; + } + } + _list.add(item2); } + objList.addAll(_list); + }catch (Exception ignored){} + + List errors = objectListener.getErrors(); - BeanUtil.copyProperties(item,one,"id"); + if (!objList.isEmpty()){ + String ch=objList.get(0).getDcch(); + List list = flowInfoService.list(Wrappers.lambdaQuery().eq(PartFlowInfo::getCh, ch)); - if(item.getProject()!=null){ - one.setCh(item.getProject()); - one.setFd(item.getBlock()); - one.setPartName(item.getPartName0()); + List updateList=new ArrayList<>(); + + a: + for (PartFlowInfo item1:objList){ + for (PartFlowInfo item2:list){ + if ((ObjUtil.equal(item1.getCh(),item2.getCh())&&ObjUtil.equal(item1.getPartName(),item2.getPartName()) + ||(ObjUtil.equal(item1.getProject(),item2.getCh())&&ObjUtil.equal(item1.getPartName0(),item2.getPartName())))){ + CopyOptions copyOptions = CopyOptions.create().setIgnoreNullValue(true); + copyOptions.setIgnoreProperties("id"); + BeanUtil.copyProperties(item1,item2,copyOptions); + updateList.add(item2); + continue a; + } + } + if(item1.getProject()!=null){ + item1.setCh(item1.getProject()); + item1.setFd(item1.getBlock()); + item1.setPartName(item1.getPartName0()); + } + updateList.add(item1); } - updateList.add(one); - }); - flowInfoService.saveOrUpdateBatch(updateList); +// objList.forEach(item->{ +// PartFlowInfo one = flowInfoService.getOne(Wrappers.lambdaQuery() +// .eq(StrUtil.isNotEmpty(item.getCh()),PartFlowInfo::getCh, item.getCh()) +// .eq(StrUtil.isNotEmpty(item.getCh()),PartFlowInfo::getPartName,item.getPartName()) +// .eq(StrUtil.isNotEmpty(item.getProject()),PartFlowInfo::getCh,item.getProject()) +// .eq(StrUtil.isNotEmpty(item.getProject()),PartFlowInfo::getPartName,item.getPartName0()) +// ); +// +// if (ObjUtil.isEmpty(one)){ +// one = new PartFlowInfo(); +// } +// +// BeanUtil.copyProperties(item,one,"id"); +// +// if(item.getProject()!=null){ +// one.setCh(item.getProject()); +// one.setFd(item.getBlock()); +// one.setPartName(item.getPartName0()); +// } +// updateList.add(one); +// }); + + flowInfoService.saveOrUpdateBatch(updateList); + } + return new ResultBean<>(errors); } diff --git a/src/main/java/com/dsic/gj_erp/jszb/entity/PartFlowInfo.java b/src/main/java/com/dsic/gj_erp/jszb/entity/PartFlowInfo.java index 11f280d..a13506e 100644 --- a/src/main/java/com/dsic/gj_erp/jszb/entity/PartFlowInfo.java +++ b/src/main/java/com/dsic/gj_erp/jszb/entity/PartFlowInfo.java @@ -139,6 +139,10 @@ public class PartFlowInfo { @ExcelProperty("NESTNAME") private String nestName; + public String getDcch(){ + return this.ch!=null?this.ch:this.project; + } + public static void main(String[] args) { ExcelFlowInfoListener objectListener = new ExcelFlowInfoListener(); EasyExcel.read(new File("E:\\文档\\润芃\\项目管理\\钢加\\生产管控\\实施相关\\2025年4月\\技术准备\\零件重量信息.xls"), PartFlowInfo.class, objectListener).sheet(0).headRowNumber(1).doRead();