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();