1.优化技术准备数据上传逻辑

2.解决导出数据错误问题
master
董哲奇 2 weeks ago
parent aaeecbc12f
commit 2c6fd8b6da

@ -1,6 +1,7 @@
package com.dsic.gj_erp.jszb.control; package com.dsic.gj_erp.jszb.control;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.util.ObjUtil; import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.EasyExcel; import com.alibaba.excel.EasyExcel;
@ -39,6 +40,7 @@ public class JszbController {
List<PartFlowInfo> list = flowInfoService.list(Wrappers.<PartFlowInfo>lambdaQuery() List<PartFlowInfo> list = flowInfoService.list(Wrappers.<PartFlowInfo>lambdaQuery()
.eq(PartFlowInfo::getCh, ch) .eq(PartFlowInfo::getCh, ch)
.eq(StrUtil.isEmpty(end) && StrUtil.isNotEmpty(begin), PartFlowInfo::getPl, begin) .eq(StrUtil.isEmpty(end) && StrUtil.isNotEmpty(begin), PartFlowInfo::getPl, begin)
.isNotNull(PartFlowInfo::getPl)
.between(StrUtil.isAllNotEmpty(begin, end), PartFlowInfo::getPl, begin, end) .between(StrUtil.isAllNotEmpty(begin, end), PartFlowInfo::getPl, begin, end)
.orderByAsc(PartFlowInfo::getPl,PartFlowInfo::getFd) .orderByAsc(PartFlowInfo::getPl,PartFlowInfo::getFd)
); );
@ -51,31 +53,77 @@ public class JszbController {
EasyExcel.read(file.getInputStream(), PartFlowInfo.class, objectListener).sheet(0).headRowNumber(1).doRead(); EasyExcel.read(file.getInputStream(), PartFlowInfo.class, objectListener).sheet(0).headRowNumber(1).doRead();
List<PartFlowInfo> objList = objectListener.getObjectList(); List<PartFlowInfo> objList = objectListener.getObjectList();
try {
ExcelFlowInfoListener objectListener1 = new ExcelFlowInfoListener();
EasyExcel.read(file.getInputStream(), PartFlowInfo.class, objectListener1).sheet(1).headRowNumber(1).doRead();
List<PartFlowInfo> objList2 = objectListener1.getObjectList();
List<PartFlowInfo> _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<String> errors = objectListener.getErrors(); List<String> errors = objectListener.getErrors();
if (!objList.isEmpty()){
String ch=objList.get(0).getDcch();
List<PartFlowInfo> list = flowInfoService.list(Wrappers.<PartFlowInfo>lambdaQuery().eq(PartFlowInfo::getCh, ch));
List<PartFlowInfo> updateList=new ArrayList<>(); List<PartFlowInfo> updateList=new ArrayList<>();
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)){ a:
one = new PartFlowInfo(); 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);
} }
BeanUtil.copyProperties(item,one,"id"); // 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);
// });
if(item.getProject()!=null){ flowInfoService.saveOrUpdateBatch(updateList);
one.setCh(item.getProject());
one.setFd(item.getBlock());
one.setPartName(item.getPartName0());
} }
updateList.add(one);
});
flowInfoService.saveOrUpdateBatch(updateList);
return new ResultBean<>(errors); return new ResultBean<>(errors);
} }

@ -139,6 +139,10 @@ public class PartFlowInfo {
@ExcelProperty("NESTNAME") @ExcelProperty("NESTNAME")
private String nestName; private String nestName;
public String getDcch(){
return this.ch!=null?this.ch:this.project;
}
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();

Loading…
Cancel
Save