From 6866dc0c5e8de93a2f2c5de30bb5ff8ae2938d5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=91=A3=E5=93=B2=E5=A5=87?= <13840175730@139.com> Date: Thu, 8 Jan 2026 12:11:47 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=B8=B4=E6=97=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gj_erp/jszb/control/JszbController.java | 82 ++-------- .../dsic/gj_erp/jszb/entity/PartFlowInfo.java | 13 +- .../gj_erp/jszb/entity/PartWeightInfo.java | 145 ++++++++++++++++++ .../jszb/excel/ExcelFlowInfoListener.java | 10 +- .../jszb/mapper/PartFlowInfoMapper.java | 7 +- .../jszb/mapper/PartWeightInfoMapper.java | 9 ++ .../gj_erp/jszb/service/FlowInfoService.java | 9 +- .../jszb/service/WeightInfoService.java | 33 ++++ .../resources/mappers/jszb/JszbMapper.xml | 67 ++++++++ 9 files changed, 297 insertions(+), 78 deletions(-) create mode 100644 src/main/java/com/dsic/gj_erp/jszb/entity/PartWeightInfo.java create mode 100644 src/main/java/com/dsic/gj_erp/jszb/mapper/PartWeightInfoMapper.java create mode 100644 src/main/java/com/dsic/gj_erp/jszb/service/WeightInfoService.java 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 a7f5f61..ac5b0a7 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 @@ -13,6 +13,7 @@ import com.dsic.gj_erp.exception.ServiceException; import com.dsic.gj_erp.jszb.entity.PartFlowInfo; import com.dsic.gj_erp.jszb.excel.ExcelFlowInfoListener; import com.dsic.gj_erp.jszb.service.FlowInfoService; +import com.dsic.gj_erp.jszb.service.WeightInfoService; import lombok.AllArgsConstructor; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -31,6 +32,7 @@ import java.util.stream.Stream; public class JszbController { private final FlowInfoService flowInfoService; + private final WeightInfoService weightInfoService; @GetMapping("exportJSzb") public void exportJSzb(String ch,String begin,String end){ @@ -39,18 +41,12 @@ public class JszbController { @GetMapping("getFlowInfoList") public ResultBean getFlowInfoList(String ch,String begin,String end) { - 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) - ); + List list = flowInfoService.getList(ch,begin,end); return new ResultBean<>(list); } @PostMapping("importFLowInfo") - public ResultBean importFLowInfo(@RequestParam("file") MultipartFile file) throws IOException { + public ResultBean importFLowInfo(@RequestParam("file") MultipartFile file) throws IOException, CustomException { ExcelFlowInfoListener objectListener = new ExcelFlowInfoListener(); EasyExcel.read(file.getInputStream(), PartFlowInfo.class, objectListener).sheet(0).headRowNumber(1).doRead(); @@ -61,14 +57,16 @@ public class JszbController { 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; - } + for (PartFlowInfo item:objList2){ + if(item.getProject()!=null){ + item.setCh(item.getProject()); + item.setFd(item.getBlock()); + item.setPartName(item.getPartName0()); } - _list.add(item2); + if (!item.check()) { + throw new CustomException(99999, "有数据船号/分段/零件编号为空无法继续处理,请检查数据并修改后重新导入"); + } + _list.add(item); } objList.addAll(_list); }catch (Exception ignored){} @@ -76,57 +74,11 @@ public class JszbController { List errors = objectListener.getErrors(); if (!objList.isEmpty()){ - String ch=objList.get(0).getDcch(); - List list = flowInfoService.list(Wrappers.lambdaQuery().eq(PartFlowInfo::getCh, ch)); - - 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); + if(objList.get(0).getProject()!=null){ + weightInfoService.saveOrUpdateBatch(objList); + }else{ + flowInfoService.saveOrUpdateBatch(objList); } - -// 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); -// }); - List collect = updateList.stream() - .filter(item -> "2205".equals(item.getFd())) - .collect(Collectors.toList()); - System.out.printf(collect.toString()); - 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 a13506e..ca842f3 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 @@ -1,5 +1,6 @@ package com.dsic.gj_erp.jszb.entity; +import cn.hutool.core.util.ObjectUtil; import com.alibaba.excel.EasyExcel; import com.alibaba.excel.annotation.ExcelProperty; import com.baomidou.mybatisplus.annotation.IdType; @@ -7,6 +8,7 @@ import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.dsic.gj_erp.jszb.excel.ExcelFlowInfoListener; +import com.github.jeffreyning.mybatisplus.anno.MppMultiId; import lombok.Getter; import lombok.Setter; @@ -17,14 +19,15 @@ import java.util.List; @Setter @TableName("part_flow_info") public class PartFlowInfo { - @TableId(value = "id", type = IdType.ASSIGN_UUID) - private String id; + @MppMultiId @ExcelProperty("船号") private String ch; + @MppMultiId @ExcelProperty("分段号") private String fd; @ExcelProperty("批量") private String pl; + @MppMultiId @ExcelProperty("零件名称") private String partName; @ExcelProperty("种类") @@ -143,11 +146,17 @@ public class PartFlowInfo { return this.ch!=null?this.ch:this.project; } + public boolean check(){ + return ObjectUtil.isAllNotEmpty(this.ch,this.fd,this.partName); + } + 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(); List objList = objectListener.getObjectList(); System.out.println(objList); + + } } diff --git a/src/main/java/com/dsic/gj_erp/jszb/entity/PartWeightInfo.java b/src/main/java/com/dsic/gj_erp/jszb/entity/PartWeightInfo.java new file mode 100644 index 0000000..5614c48 --- /dev/null +++ b/src/main/java/com/dsic/gj_erp/jszb/entity/PartWeightInfo.java @@ -0,0 +1,145 @@ +package com.dsic.gj_erp.jszb.entity; + +import cn.hutool.core.util.ObjectUtil; +import com.alibaba.excel.annotation.ExcelProperty; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.github.jeffreyning.mybatisplus.anno.MppMultiId; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +@TableName("part_weight_info") +public class PartWeightInfo{ + + @MppMultiId + @ExcelProperty("船号") + private String ch; + @MppMultiId + @ExcelProperty("分段号") + private String fd; + @ExcelProperty("批量") + private String pl; + @MppMultiId + @ExcelProperty("零件名称") + private String partName; + @ExcelProperty("种类") + private String type; + @ExcelProperty("规格") + private String specification; + @ExcelProperty("数量") + private String quantity; + @ExcelProperty("材质") + private String material; + @ExcelProperty("特征") + private String feature; + @ExcelProperty("流向") + private String flow; + @ExcelProperty("下级") + private String nextLevel; + @ExcelProperty("套料图信息") + private String nestingInfo; + @ExcelProperty("场地") + private String location; + + //========重量信息======== + @TableField(exist = false) + @ExcelProperty("PROJECT") + private String project; + @TableField(exist = false) + @ExcelProperty("BLOCK") + private String block; + @TableField(exist = false) + @ExcelProperty("PARTNAME") + private String partName0; + @ExcelProperty("PARTNO") + private String partNo; + @ExcelProperty("MATERIAL") + private String material0; + @ExcelProperty("THICK") + private String thickness; + @ExcelProperty("TYPE") + private String type0; + @ExcelProperty("P") + private String p; + @ExcelProperty("C") + private String c; + @ExcelProperty("S") + private String s; + @ExcelProperty("NP") + private String np; + @ExcelProperty("NC") + private String nc; + @ExcelProperty("NS") + private String ns; + @ExcelProperty("AREA") + private String area; + @ExcelProperty("WEIGHT") + private String weight; + @ExcelProperty("CUTLEN") + private String cutLength; + @ExcelProperty("MARKLEN") + private String markLength; + + @ExcelProperty("X-SIZE") + @TableField("x_size") + private String xxSize;//x-size + @ExcelProperty("Y-SIZE") + @TableField("y_size") + private String yySize;//y-size + + @ExcelProperty("OPTION") + private String option0; + @ExcelProperty("MPARTNAME") + private String m_part_name; + @ExcelProperty("SPARTNAME") + private String s_part_name; + @ExcelProperty("LOT") + private String lot; + @ExcelProperty("BAREA") + @TableField("b_area") + private String bbArea; + @ExcelProperty("SANGLE") + @TableField("s_angle") + private String ssAngle; + @ExcelProperty("SSIZE-X") + @TableField("s_size_x") + private String ssSizeX; + @ExcelProperty("SSIZE-Y") + @TableField("s_size_y") + private String ssSizeY; + @ExcelProperty("GOID") + private String goid; + @ExcelProperty("DATE") + private String date; + @ExcelProperty("TIME") + private String time; + @ExcelProperty("SHAPE") + private String shape; + @ExcelProperty("ASSEMBLY") + private String assembly; + @ExcelProperty("OPTION1") + private String option1; + @ExcelProperty("OPTION2") + private String option2; + @ExcelProperty("OPTION3") + private String option3; + @ExcelProperty("OPTION4") + private String option4; + @ExcelProperty("OPTION5") + private String option5; + @ExcelProperty("DIRECTION") + private String direction; + @ExcelProperty("ISMODIFY") + private String isModify; + @ExcelProperty("NESTNAME") + private String nestName; + + public String getDcch(){ + return this.ch!=null?this.ch:this.project; + } + +} diff --git a/src/main/java/com/dsic/gj_erp/jszb/excel/ExcelFlowInfoListener.java b/src/main/java/com/dsic/gj_erp/jszb/excel/ExcelFlowInfoListener.java index 2340a30..2b4e2a6 100644 --- a/src/main/java/com/dsic/gj_erp/jszb/excel/ExcelFlowInfoListener.java +++ b/src/main/java/com/dsic/gj_erp/jszb/excel/ExcelFlowInfoListener.java @@ -3,6 +3,7 @@ package com.dsic.gj_erp.jszb.excel; import cn.hutool.core.util.StrUtil; import com.alibaba.excel.context.AnalysisContext; import com.alibaba.excel.event.AnalysisEventListener; +import com.dsic.gj_erp.exception.CustomException; import com.dsic.gj_erp.jszb.entity.PartFlowInfo; import lombok.Getter; @@ -26,15 +27,6 @@ public class ExcelFlowInfoListener extends AnalysisEventListener { @Override public void invoke(PartFlowInfo excelDemo, AnalysisContext analysisContext) { -// String partName=excelDemo.getPartName0()!=null?excelDemo.getPartName0():excelDemo.getPartName(); -// if (map.containsKey(partName)){ -// String error= StrUtil.format("存在重复数据,检查修改后单独导入即可,零件编号:{},已过滤该行",partName); -// this.errors.add(error); -// return; -// } -// -// map.put(partName,excelDemo); - objectList.add(excelDemo); } diff --git a/src/main/java/com/dsic/gj_erp/jszb/mapper/PartFlowInfoMapper.java b/src/main/java/com/dsic/gj_erp/jszb/mapper/PartFlowInfoMapper.java index 89732c4..86cea03 100644 --- a/src/main/java/com/dsic/gj_erp/jszb/mapper/PartFlowInfoMapper.java +++ b/src/main/java/com/dsic/gj_erp/jszb/mapper/PartFlowInfoMapper.java @@ -2,6 +2,11 @@ package com.dsic.gj_erp.jszb.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.dsic.gj_erp.jszb.entity.PartFlowInfo; +import com.github.jeffreyning.mybatisplus.base.MppBaseMapper; -public interface PartFlowInfoMapper extends BaseMapper { +import java.util.List; + +public interface PartFlowInfoMapper extends MppBaseMapper { + + List getFlownInfo(String ch,String begin,String end); } diff --git a/src/main/java/com/dsic/gj_erp/jszb/mapper/PartWeightInfoMapper.java b/src/main/java/com/dsic/gj_erp/jszb/mapper/PartWeightInfoMapper.java new file mode 100644 index 0000000..b7dce29 --- /dev/null +++ b/src/main/java/com/dsic/gj_erp/jszb/mapper/PartWeightInfoMapper.java @@ -0,0 +1,9 @@ +package com.dsic.gj_erp.jszb.mapper; + +import com.dsic.gj_erp.jszb.entity.PartWeightInfo; +import com.github.jeffreyning.mybatisplus.base.MppBaseMapper; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface PartWeightInfoMapper extends MppBaseMapper { +} diff --git a/src/main/java/com/dsic/gj_erp/jszb/service/FlowInfoService.java b/src/main/java/com/dsic/gj_erp/jszb/service/FlowInfoService.java index df8b7e3..f7c7101 100644 --- a/src/main/java/com/dsic/gj_erp/jszb/service/FlowInfoService.java +++ b/src/main/java/com/dsic/gj_erp/jszb/service/FlowInfoService.java @@ -3,8 +3,15 @@ package com.dsic.gj_erp.jszb.service; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.dsic.gj_erp.jszb.entity.PartFlowInfo; import com.dsic.gj_erp.jszb.mapper.PartFlowInfoMapper; +import com.github.jeffreyning.mybatisplus.service.MppServiceImpl; import org.springframework.stereotype.Service; +import java.util.List; + @Service -public class FlowInfoService extends ServiceImpl { +public class FlowInfoService extends MppServiceImpl { + + public List getList(String ch,String begin,String end){ + return baseMapper.getFlownInfo(ch,begin,end); + } } diff --git a/src/main/java/com/dsic/gj_erp/jszb/service/WeightInfoService.java b/src/main/java/com/dsic/gj_erp/jszb/service/WeightInfoService.java new file mode 100644 index 0000000..c9d1902 --- /dev/null +++ b/src/main/java/com/dsic/gj_erp/jszb/service/WeightInfoService.java @@ -0,0 +1,33 @@ +package com.dsic.gj_erp.jszb.service; + +import cn.hutool.core.bean.BeanUtil; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.dsic.gj_erp.exception.CustomException; +import com.dsic.gj_erp.jszb.entity.PartFlowInfo; +import com.dsic.gj_erp.jszb.entity.PartWeightInfo; +import com.dsic.gj_erp.jszb.mapper.PartFlowInfoMapper; +import com.dsic.gj_erp.jszb.mapper.PartWeightInfoMapper; +import com.github.jeffreyning.mybatisplus.service.MppServiceImpl; +import com.google.protobuf.ServiceException; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +@Service +public class WeightInfoService extends MppServiceImpl { + + @Transactional(rollbackFor = Exception.class) + public void saveOrUpdateBatch(List objList) { + + List collect = new ArrayList<>(); + for (PartFlowInfo partFlowInfo : objList) { + PartWeightInfo partWeightInfo = new PartWeightInfo(); + BeanUtil.copyProperties(partFlowInfo, partWeightInfo); + collect.add(partWeightInfo); + } + this.saveOrUpdateBatch(collect); + } +} diff --git a/src/main/resources/mappers/jszb/JszbMapper.xml b/src/main/resources/mappers/jszb/JszbMapper.xml index 75e24fa..7725217 100644 --- a/src/main/resources/mappers/jszb/JszbMapper.xml +++ b/src/main/resources/mappers/jszb/JszbMapper.xml @@ -2,4 +2,71 @@ +