1.临时提交

master
董哲奇 4 weeks ago
parent 36722d66d3
commit 6866dc0c5e

@ -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.entity.PartFlowInfo;
import com.dsic.gj_erp.jszb.excel.ExcelFlowInfoListener; import com.dsic.gj_erp.jszb.excel.ExcelFlowInfoListener;
import com.dsic.gj_erp.jszb.service.FlowInfoService; import com.dsic.gj_erp.jszb.service.FlowInfoService;
import com.dsic.gj_erp.jszb.service.WeightInfoService;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@ -31,6 +32,7 @@ import java.util.stream.Stream;
public class JszbController { public class JszbController {
private final FlowInfoService flowInfoService; private final FlowInfoService flowInfoService;
private final WeightInfoService weightInfoService;
@GetMapping("exportJSzb") @GetMapping("exportJSzb")
public void exportJSzb(String ch,String begin,String end){ public void exportJSzb(String ch,String begin,String end){
@ -39,18 +41,12 @@ public class JszbController {
@GetMapping("getFlowInfoList") @GetMapping("getFlowInfoList")
public ResultBean<?> getFlowInfoList(String ch,String begin,String end) { public ResultBean<?> getFlowInfoList(String ch,String begin,String end) {
List<PartFlowInfo> list = flowInfoService.list(Wrappers.<PartFlowInfo>lambdaQuery() List<PartFlowInfo> list = flowInfoService.getList(ch,begin,end);
.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)
);
return new ResultBean<>(list); return new ResultBean<>(list);
} }
@PostMapping("importFLowInfo") @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(); ExcelFlowInfoListener objectListener = new ExcelFlowInfoListener();
EasyExcel.read(file.getInputStream(), PartFlowInfo.class, objectListener).sheet(0).headRowNumber(1).doRead(); EasyExcel.read(file.getInputStream(), PartFlowInfo.class, objectListener).sheet(0).headRowNumber(1).doRead();
@ -61,14 +57,16 @@ public class JszbController {
List<PartFlowInfo> objList2 = objectListener1.getObjectList(); List<PartFlowInfo> objList2 = objectListener1.getObjectList();
List<PartFlowInfo> _list=new ArrayList<>(); List<PartFlowInfo> _list=new ArrayList<>();
item2: for (PartFlowInfo item:objList2){
for (PartFlowInfo item2:objList2){ if(item.getProject()!=null){
for (PartFlowInfo item1:objList){ item.setCh(item.getProject());
if (ObjUtil.equal(item1.getCh(),item2.getCh())&&ObjUtil.equal(item1.getPartName(),item2.getPartName())){ item.setFd(item.getBlock());
continue item2; item.setPartName(item.getPartName0());
} }
if (!item.check()) {
throw new CustomException(99999, "有数据船号/分段/零件编号为空无法继续处理,请检查数据并修改后重新导入");
} }
_list.add(item2); _list.add(item);
} }
objList.addAll(_list); objList.addAll(_list);
}catch (Exception ignored){} }catch (Exception ignored){}
@ -76,57 +74,11 @@ public class JszbController {
List<String> errors = objectListener.getErrors(); List<String> errors = objectListener.getErrors();
if (!objList.isEmpty()){ if (!objList.isEmpty()){
String ch=objList.get(0).getDcch(); if(objList.get(0).getProject()!=null){
List<PartFlowInfo> list = flowInfoService.list(Wrappers.<PartFlowInfo>lambdaQuery().eq(PartFlowInfo::getCh, ch)); weightInfoService.saveOrUpdateBatch(objList);
}else{
List<PartFlowInfo> updateList=new ArrayList<>(); flowInfoService.saveOrUpdateBatch(objList);
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);
}
// objList.forEach(item->{
// PartFlowInfo one = flowInfoService.getOne(Wrappers.<PartFlowInfo>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<PartFlowInfo> collect = updateList.stream()
.filter(item -> "2205".equals(item.getFd()))
.collect(Collectors.toList());
System.out.printf(collect.toString());
flowInfoService.saveOrUpdateBatch(updateList);
} }
return new ResultBean<>(errors); return new ResultBean<>(errors);

@ -1,5 +1,6 @@
package com.dsic.gj_erp.jszb.entity; package com.dsic.gj_erp.jszb.entity;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.excel.EasyExcel; import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.IdType; 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.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.dsic.gj_erp.jszb.excel.ExcelFlowInfoListener; import com.dsic.gj_erp.jszb.excel.ExcelFlowInfoListener;
import com.github.jeffreyning.mybatisplus.anno.MppMultiId;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
@ -17,14 +19,15 @@ import java.util.List;
@Setter @Setter
@TableName("part_flow_info") @TableName("part_flow_info")
public class PartFlowInfo { public class PartFlowInfo {
@TableId(value = "id", type = IdType.ASSIGN_UUID) @MppMultiId
private String id;
@ExcelProperty("船号") @ExcelProperty("船号")
private String ch; private String ch;
@MppMultiId
@ExcelProperty("分段号") @ExcelProperty("分段号")
private String fd; private String fd;
@ExcelProperty("批量") @ExcelProperty("批量")
private String pl; private String pl;
@MppMultiId
@ExcelProperty("零件名称") @ExcelProperty("零件名称")
private String partName; private String partName;
@ExcelProperty("种类") @ExcelProperty("种类")
@ -143,11 +146,17 @@ public class PartFlowInfo {
return this.ch!=null?this.ch:this.project; 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) { public static void main(String[] args) {
ExcelFlowInfoListener objectListener = new ExcelFlowInfoListener(); ExcelFlowInfoListener objectListener = new ExcelFlowInfoListener();
EasyExcel.read(new File("E:\\文档\\润芃\\项目管理\\钢加\\生产管控\\实施相关\\2025年4月\\技术准备\\零件重量信息.xls"), PartFlowInfo.class, objectListener).sheet(0).headRowNumber(1).doRead(); EasyExcel.read(new File("E:\\文档\\润芃\\项目管理\\钢加\\生产管控\\实施相关\\2025年4月\\技术准备\\零件重量信息.xls"), PartFlowInfo.class, objectListener).sheet(0).headRowNumber(1).doRead();
List<PartFlowInfo> objList = objectListener.getObjectList(); List<PartFlowInfo> objList = objectListener.getObjectList();
System.out.println(objList); System.out.println(objList);
} }
} }

@ -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;
}
}

@ -3,6 +3,7 @@ package com.dsic.gj_erp.jszb.excel;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.context.AnalysisContext; import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener; import com.alibaba.excel.event.AnalysisEventListener;
import com.dsic.gj_erp.exception.CustomException;
import com.dsic.gj_erp.jszb.entity.PartFlowInfo; import com.dsic.gj_erp.jszb.entity.PartFlowInfo;
import lombok.Getter; import lombok.Getter;
@ -26,15 +27,6 @@ public class ExcelFlowInfoListener extends AnalysisEventListener<PartFlowInfo> {
@Override @Override
public void invoke(PartFlowInfo excelDemo, AnalysisContext analysisContext) { 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); objectList.add(excelDemo);
} }

@ -2,6 +2,11 @@ package com.dsic.gj_erp.jszb.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dsic.gj_erp.jszb.entity.PartFlowInfo; import com.dsic.gj_erp.jszb.entity.PartFlowInfo;
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
public interface PartFlowInfoMapper extends BaseMapper<PartFlowInfo> { import java.util.List;
public interface PartFlowInfoMapper extends MppBaseMapper<PartFlowInfo> {
List<PartFlowInfo> getFlownInfo(String ch,String begin,String end);
} }

@ -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<PartWeightInfo> {
}

@ -3,8 +3,15 @@ package com.dsic.gj_erp.jszb.service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dsic.gj_erp.jszb.entity.PartFlowInfo; import com.dsic.gj_erp.jszb.entity.PartFlowInfo;
import com.dsic.gj_erp.jszb.mapper.PartFlowInfoMapper; import com.dsic.gj_erp.jszb.mapper.PartFlowInfoMapper;
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
@Service @Service
public class FlowInfoService extends ServiceImpl<PartFlowInfoMapper, PartFlowInfo> { public class FlowInfoService extends MppServiceImpl<PartFlowInfoMapper, PartFlowInfo> {
public List<PartFlowInfo> getList(String ch,String begin,String end){
return baseMapper.getFlownInfo(ch,begin,end);
}
} }

@ -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<PartWeightInfoMapper, PartWeightInfo> {
@Transactional(rollbackFor = Exception.class)
public void saveOrUpdateBatch(List<PartFlowInfo> objList) {
List<PartWeightInfo> collect = new ArrayList<>();
for (PartFlowInfo partFlowInfo : objList) {
PartWeightInfo partWeightInfo = new PartWeightInfo();
BeanUtil.copyProperties(partFlowInfo, partWeightInfo);
collect.add(partWeightInfo);
}
this.saveOrUpdateBatch(collect);
}
}

@ -2,4 +2,71 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.dsic.gj_erp.jszb.mapper.PartFlowInfoMapper"> <mapper namespace="com.dsic.gj_erp.jszb.mapper.PartFlowInfoMapper">
<select id="getFlownInfo" resultType="com.dsic.gj_erp.jszb.entity.PartFlowInfo">
select
a.ch,
a.fd,
a.pl,
a.part_name,
a.type,
a.specification,
a.quantity,
a.material,
a.feature,
a.flow,
a.next_level,
a.nesting_info,
a.location,
b.part_no,
b.material0,
b.thickness,
b.type0,
b.p,
b.c,
b.s,
b.np,
b.nc,
b.ns,
b.area,
b.weight,
b.cut_length,
b.mark_length,
b.x_size,
b.y_size,
b.option0,
b.m_part_name,
b.s_part_name,
b.lot,
b.b_area,
b.s_angle,
b.s_size_x,
b.s_size_y,
b.goid,
b.date,
b.time,
b.shape,
b.assembly,
b.option1,
b.option2,
b.option3,
b.option4,
b.option5,
b.direction,
b.is_modify,
b.nest_name
from
part_flow_info a
left join part_weight_info b on a.ch = b.ch and a.fd = b.fd and a.part_name = b.part_name
where
a.ch = #{ch}
<if test="begin !=null and begin!='' and end!=null and end!=''">
and a.pl between #{begin} and #{end}
</if>
<if test="begin !=null and begin!='' and (end==null or end=='')">
and a.pl>=#{begin}
</if>
<if test="(begin ==null or begin=='') and end!=null and end!=''">
and a.pl &lt;=#{end}
</if>
</select>
</mapper> </mapper>

Loading…
Cancel
Save