调整比对

This commit is contained in:
jing's 2024-03-11 17:23:13 +08:00
parent 8c87b8f058
commit 73b5df914d
7 changed files with 91 additions and 110 deletions

View File

@ -8,6 +8,7 @@ import org.ttzero.excel.annotation.ExcelColumn;
import org.ttzero.excel.annotation.MediaColumn;
import java.io.File;
import java.io.InputStream;
import java.math.BigDecimal;
@Data
@ -50,8 +51,8 @@ public class CompareReportField {
//@ExcelProperty("比对结果")
@MediaColumn
@ExcelColumn(value="比对结果")
// @ColumnWidth(50)
private File compareSymbol;
@ColumnWidth(10)
private InputStream compareSymbol;

View File

@ -5,6 +5,7 @@ import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.ImmutableList;
import com.nflg.product.bomnew.constant.EBomConstant;
import com.nflg.product.bomnew.constant.MBomConstantEnum;
import com.nflg.product.bomnew.mapper.master.BomNewMbomParentMapper;
@ -68,14 +69,17 @@ public class BomNewMbomParentService extends ServiceImpl<BomNewMbomParentMapper,
BomNewMbomMiddleVO parent = this.getBaseMapper().getParentById(item.getBomRowId());
parent.setParentRowId(0l);
parent.setBomRowId(parent.getRowId());
SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(ImmutableList.of(parent), EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT2);
List<BomNewMbomMiddleVO> childList = this.getBaseMapper().searchList(item.getRowId());
SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(childList, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT2);
IndexListTree.listToTree(parent, childList);
page.getRecords().add(parent);
}
SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(page.getRecords(), EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT2);
// SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(page.getRecords(), EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT2);
return page;
}

View File

@ -17,6 +17,7 @@ import com.nflg.product.bomnew.util.VUtils;
import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Service;
import org.springframework.util.FileCopyUtils;
import org.ttzero.excel.entity.ListSheet;
import java.io.*;
@ -65,90 +66,67 @@ public class CompareReportService {
/**
* 比较导出
*
*
* @param query
*/
public void compareBomExport(OutputStream filePath,CompareReportQuery query) throws IOException {
CompareReportListVO list=compareBom(query);
public void compareBomExport(OutputStream filePath, CompareReportQuery query) throws IOException {
CompareReportListVO list = compareBom(query);
if(CollUtil.isEmpty(list.getChildNodes())){
return;
}
List<CompareReportField> excelList=new ArrayList<>();
for (CompareReportVO compareReportVO:
list.getChildNodes()) {
CompareReportField compareReportField=null;
if(compareReportVO.getLeft()!=null){
compareReportField= Convert.convert(CompareReportField.class,compareReportVO.getLeft());
}else{
compareReportField= Convert.convert(CompareReportField.class,compareReportVO.getLeft());
if (CollUtil.isEmpty(list.getChildNodes())) {
return;
}
if(compareReportField==null){
continue;
}
excelList.add(compareReportField);
List<CompareReportField> excelList = new ArrayList<>();
for (CompareReportVO compareReportVO :
list.getChildNodes()) {
if(ObjectUtil.equal(compareReportVO.getSymbol(),ReportConstant.SymbolEnum.EQ.getValue())
||ObjectUtil.equal(compareReportVO.getSymbol(),ReportConstant.SymbolEnum.NON_EQ.getValue())) {
compareReportField.setLevelNum(compareReportVO.getLeft().getLevelNum());
compareReportField.setNum(compareReportVO.getLeft().getNum());
compareReportField.setMaterialUnit(compareReportVO.getLeft().getMaterialUnit());
compareReportField.setLevelNum2(compareReportVO.getRight().getLevelNum());
compareReportField.setNum2(compareReportVO.getRight().getNum());
compareReportField.setMaterialUnit2(compareReportVO.getRight().getMaterialUnit());
if(ObjectUtil.equal(compareReportVO.getLeft().getTag(),ReportConstant.TagEnum.SIGMA.getValue())
||ObjectUtil.equal(compareReportVO.getRight().getTag(),ReportConstant.TagEnum.SIGMA.getValue())
) {
compareReportField.setSumSymbol("Σ");
}
}else if (ObjectUtil.equal(compareReportVO.getSymbol(),ReportConstant.SymbolEnum.L_NULL.getValue())){
compareReportField.setLevelNum(compareReportVO.getLeft().getLevelNum());
compareReportField.setNum(compareReportVO.getLeft().getNum());
compareReportField.setMaterialUnit(compareReportVO.getLeft().getMaterialUnit());
if(ObjectUtil.equal(compareReportVO.getLeft().getTag(),ReportConstant.TagEnum.SIGMA.getValue())
) {
compareReportField.setSumSymbol("Σ");
}
compareReportField.setLevelNum2(null);
compareReportField.setNum2(null);
compareReportField.setMaterialUnit2(null);
}else if (ObjectUtil.equal(compareReportVO.getSymbol(),ReportConstant.SymbolEnum.NULL_R.getValue())){
compareReportField.setLevelNum(null);
compareReportField.setNum(null);
compareReportField.setMaterialUnit(null);
compareReportField.setLevelNum2(compareReportVO.getRight().getLevelNum());
compareReportField.setNum2(compareReportVO.getRight().getNum());
compareReportField.setMaterialUnit2(compareReportVO.getRight().getMaterialUnit());
if(ObjectUtil.equal(compareReportVO.getRight().getTag(),ReportConstant.TagEnum.SIGMA.getValue())
) {
compareReportField.setSumSymbol("Σ");
}
}
compareReportField.setCompareSymbol(getFile(compareReportVO.getSymbol()));
if(compareReportVO.getLeft()!=null){
CompareReportField compareReportField = null;
if (compareReportVO.getLeft() != null) {
compareReportField = Convert.convert(CompareReportField.class, compareReportVO.getLeft());
} else {
compareReportField = Convert.convert(CompareReportField.class, compareReportVO.getLeft());
}
if (compareReportField == null) {
continue;
}
excelList.add(compareReportField);
if (ObjectUtil.equal(compareReportVO.getSymbol(), ReportConstant.SymbolEnum.EQ.getValue())
|| ObjectUtil.equal(compareReportVO.getSymbol(), ReportConstant.SymbolEnum.NON_EQ.getValue())) {
compareReportField.setLevelNum(compareReportVO.getLeft().getLevelNum());
compareReportField.setNum(compareReportVO.getLeft().getNum());
compareReportField.setMaterialUnit(compareReportVO.getLeft().getMaterialUnit());
compareReportField.setLevelNum2(compareReportVO.getRight().getLevelNum());
compareReportField.setNum2(compareReportVO.getRight().getNum());
compareReportField.setMaterialUnit2(compareReportVO.getRight().getMaterialUnit());
if (ObjectUtil.equal(compareReportVO.getLeft().getTag(), ReportConstant.TagEnum.SIGMA.getValue())
|| ObjectUtil.equal(compareReportVO.getRight().getTag(), ReportConstant.TagEnum.SIGMA.getValue())) {
compareReportField.setSumSymbol("Σ");
}
} else if (ObjectUtil.equal(compareReportVO.getSymbol(), ReportConstant.SymbolEnum.L_NULL.getValue())) {
compareReportField.setLevelNum(compareReportVO.getLeft().getLevelNum());
compareReportField.setNum(compareReportVO.getLeft().getNum());
compareReportField.setMaterialUnit(compareReportVO.getLeft().getMaterialUnit());
if (ObjectUtil.equal(compareReportVO.getLeft().getTag(), ReportConstant.TagEnum.SIGMA.getValue())) {
compareReportField.setSumSymbol("Σ");
}
compareReportField.setLevelNum2(null);
compareReportField.setNum2(null);
compareReportField.setMaterialUnit2(null);
} else if (ObjectUtil.equal(compareReportVO.getSymbol(), ReportConstant.SymbolEnum.NULL_R.getValue())) {
compareReportField.setLevelNum(null);
compareReportField.setNum(null);
compareReportField.setMaterialUnit(null);
compareReportField.setLevelNum2(compareReportVO.getRight().getLevelNum());
compareReportField.setNum2(compareReportVO.getRight().getNum());
compareReportField.setMaterialUnit2(compareReportVO.getRight().getMaterialUnit());
if (ObjectUtil.equal(compareReportVO.getRight().getTag(), ReportConstant.TagEnum.SIGMA.getValue())) {
compareReportField.setSumSymbol("Σ");
}
}
compareReportField.setCompareSymbol(getFile(compareReportVO.getSymbol()));
}
// EasyExcel.write(filePath)
// .needHead(true)
// .excelType(ExcelTypeEnum.XLSX)
@ -167,51 +145,46 @@ public class CompareReportService {
// return n++ < pages ? excelList : null;
// }
// };
ListSheet<CompareReportField> listSheet = new ListSheet(excelList);
ListSheet<CompareReportField> listSheet = new ListSheet(excelList);
EecExcelUtil.eecExcel("BOM比对", listSheet, filePath);
}
File getFile(Integer type) throws IOException {
InputStream getFile(Integer type) throws IOException {
String filePath="0.png";
if(ObjectUtil.equal(type,ReportConstant.SymbolEnum.EQ.getValue())
) {
String filePath = "0.png";
if (ObjectUtil.equal(type, ReportConstant.SymbolEnum.EQ.getValue())
) {
filePath="1.png";
filePath = "1.png";
} else if (ObjectUtil.equal(type,ReportConstant.SymbolEnum.NON_EQ.getValue())) {
filePath="0.png";
} else if (ObjectUtil.equal(type, ReportConstant.SymbolEnum.NON_EQ.getValue())) {
filePath = "0.png";
}else if (ObjectUtil.equal(type,ReportConstant.SymbolEnum.L_NULL.getValue())){
filePath="2.png";
} else if (ObjectUtil.equal(type, ReportConstant.SymbolEnum.L_NULL.getValue())) {
filePath = "2.png";
}else if (ObjectUtil.equal(type,ReportConstant.SymbolEnum.NULL_R.getValue())){
filePath="2.png";
} else if (ObjectUtil.equal(type, ReportConstant.SymbolEnum.NULL_R.getValue())) {
filePath = "2.png";
}
ClassPathResource resource = new ClassPathResource("template/" + filePath);
return resource.getInputStream();
// byte[] bdata = FileCopyUtils.copyToByteArray(resource.getInputStream());
// File input = resource.getFile();
// return input;
}
ClassPathResource resource = new ClassPathResource("template/"+filePath);
File input = resource.getFile();
return input;
}
/**
* 左倾斜 或右倾斜
*
* @param leftNode
* @param rightNode
* @return
@ -321,7 +294,7 @@ File getFile(Integer type) throws IOException {
compareReportVOList.add(compareReportVO);
if (CollUtil.isNotEmpty(toCompareList)) {
compareReportVOList.add(compareReportVO);
ForwardReportVO to = null;
for (ForwardReportVO item :
toCompareList) {
@ -342,8 +315,8 @@ File getFile(Integer type) throws IOException {
}
//多层比较父级物料编码/图号
if (queryType.compareTo(ReportConstant.QueryTypeEnum.MULTI.getValue()) == 0) {
if (CollUtil.isEmpty(leftMaterialNoMap.get(from.getParentRowId()))
|| CollUtil.isEmpty(rightMaterialNoMap.get(to.getParentRowId()))) {
if (CollUtil.isEmpty(leftBomRowIdMap.get(from.getParentRowId()))
|| CollUtil.isEmpty(leftBomRowIdMap.get(to.getParentRowId()))) {
compareReportVO.setSymbol(ReportConstant.SymbolEnum.NON_EQ.getValue());
continue;
}

View File

@ -28,7 +28,7 @@ public class EBomFormalTreeTask extends RecursiveTask<List<BomNewEbomParentForma
@Getter
@Setter
public static int levelNum=1;
private int levelNum=1;
List<BomNewEbomParentFormalVO> result = new ArrayList<>();
@ -93,6 +93,7 @@ public class EBomFormalTreeTask extends RecursiveTask<List<BomNewEbomParentForma
if(CollUtil.isNotEmpty(childBowIds)) {
List<BomNewEbomParentFormalVO> bom = SpringUtil.getBean(BomNewEbomParentFormalService.class).getBaseMapper().getParentChildBatch(childBowIds);
EBomFormalTreeTask task = new EBomFormalTreeTask(bom);
task.setLevelNum(levelNum);
task.fork();
bomDetail.addAll(task.join());
return bomDetail;

View File

@ -174,7 +174,7 @@ public class EBomForwardReport extends BaseForwardReport {
*
* @return
*/
List<BomNewEbomParentFormalVO> bomDetailList(Long bomRowId) {
synchronized List<BomNewEbomParentFormalVO> bomDetailList(Long bomRowId) {
List<BomNewEbomParentFormalVO> childList = SpringUtil.getBean(BomNewEbomParentFormalService.class).getBaseMapper().getParentChild(bomRowId);
EBomFormalTreeTask task = new EBomFormalTreeTask(childList);
ForkJoinPool pool = new ForkJoinPool();

View File

@ -27,7 +27,7 @@ public class OriginalBomFormalTreeTask extends RecursiveTask<List<BomOriginalLis
@Getter
@Setter
public static int levelNum=1;
private int levelNum=1;
List<BomOriginalListVO> result = new ArrayList<>();
@ -92,6 +92,7 @@ public class OriginalBomFormalTreeTask extends RecursiveTask<List<BomOriginalLis
if(CollUtil.isNotEmpty(childBowIds)) {
List<BomOriginalListVO> bom = SpringUtil.getBean(BomNewOriginalParentService.class).getBaseMapper().getParentChildBatch(childBowIds);
OriginalBomFormalTreeTask task = new OriginalBomFormalTreeTask(bom);
task.setLevelNum(levelNum);
task.fork();
bomDetail.addAll(task.join());
return bomDetail;

View File

@ -25,7 +25,7 @@ public class PBomFormalTreeTask extends RecursiveTask<List<BomNewPbomParentForma
@Getter
@Setter
public static int levelNum=1;
private int levelNum=1;
List<BomNewPbomParentFormalVO> result = new ArrayList<>();
@ -89,6 +89,7 @@ public class PBomFormalTreeTask extends RecursiveTask<List<BomNewPbomParentForma
if(CollUtil.isNotEmpty(childBowIds)) {
List<BomNewPbomParentFormalVO> bom = SpringUtil.getBean(BomNewPbomParentFormalService.class).getBaseMapper().getParentChildBatch(childBowIds);
PBomFormalTreeTask task = new PBomFormalTreeTask(bom);
task.setLevelNum(levelNum);
task.fork();
bomDetail.addAll(task.join());
return bomDetail;