调整比对

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

View File

@ -5,6 +5,7 @@ import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil; import cn.hutool.extra.spring.SpringUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 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.EBomConstant;
import com.nflg.product.bomnew.constant.MBomConstantEnum; import com.nflg.product.bomnew.constant.MBomConstantEnum;
import com.nflg.product.bomnew.mapper.master.BomNewMbomParentMapper; 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()); BomNewMbomMiddleVO parent = this.getBaseMapper().getParentById(item.getBomRowId());
parent.setParentRowId(0l); parent.setParentRowId(0l);
parent.setBomRowId(parent.getRowId()); 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()); 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); IndexListTree.listToTree(parent, childList);
page.getRecords().add(parent); 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; return page;
} }

View File

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

View File

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

View File

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

View File

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

View File

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