+比对报表

This commit is contained in:
jing's 2024-03-10 20:20:21 +08:00
parent 75562248e1
commit 3bb1fe3eef
11 changed files with 234 additions and 72 deletions

View File

@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nflg.product.base.core.api.BaseApi;
import com.nflg.product.base.core.exception.NflgBusinessException;
import com.nflg.product.bomnew.constant.ReportConstant;
import com.nflg.product.bomnew.pojo.query.ChildBomReportQuery;
import com.nflg.product.bomnew.pojo.query.CompareReportQuery;
@ -13,6 +14,7 @@ import com.nflg.product.bomnew.pojo.vo.*;
import com.nflg.product.bomnew.service.CompareReportService;
import com.nflg.product.bomnew.service.ForwardReportService;
import com.nflg.product.bomnew.service.ReverseReportService;
import com.nflg.product.bomnew.util.EecExcelUtil;
import com.nflg.product.bomnew.util.VUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -132,6 +134,25 @@ public class BomReportApi extends BaseApi {
}
@PostMapping("compareExport")
@ApiOperation("bom-比对导出")
public void compareExport(@RequestBody CompareReportQuery query,HttpServletResponse response) throws IOException {
ResultVO resultBom1VO = checkQueryParam(query.getLeft());
ResultVO resultBom2VO = checkQueryParam(query.getRight());
if (resultBom1VO != null) {
new NflgBusinessException(STATE.Error,resultBom1VO.getMsg());
}
if (resultBom2VO != null) {
new NflgBusinessException(STATE.Error,resultBom1VO.getMsg());
}
EecExcelUtil.setResponseExcelHeader(response, "BOM比对");
compareReportService.compareBomExport( response.getOutputStream(),query);
}
@PostMapping("forwardExport")
@ApiOperation("bom-正查导出")

View File

@ -79,7 +79,7 @@ public class ReportConstant {
@AllArgsConstructor
@Getter
public enum SymbolEnum implements ValueEnum<Integer> {
public static enum SymbolEnum implements ValueEnum<Integer> {
//比对
EQ(1, "相等"),

View File

@ -1,57 +0,0 @@
package com.nflg.product.bomnew.excel;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.File;
import java.math.BigDecimal;
@Data
public class CompareReportField {
// @ApiModelProperty("汇总")
// @ExcelProperty(value="汇总")
// private Integer levelNum;
@ApiModelProperty("物料编码")
@ExcelProperty(value="物料编码")
private String materialNo;
@ApiModelProperty("图号")
@ExcelProperty(value="图号")
private String drawingNo;
@ApiModelProperty("物料描述")
@ExcelProperty(value="物料描述")
private String materialDesc;
@ApiModelProperty("数量")
@ExcelProperty(value = "数量")
private BigDecimal num;
@ApiModelProperty("单位")
@ExcelProperty(value = "单位")
private String materialUnit;
@ApiModelProperty("层级")
@ExcelProperty(value="层级")
private Integer levelNum;
@ApiModelProperty("比对结果")
@ExcelProperty("比对结果")
private File compareSymbol;
@ApiModelProperty("数量")
@ExcelProperty(value = "数量")
private BigDecimal num2;
@ApiModelProperty("单位")
@ExcelProperty(value = "单位")
private String materialUnit2;
@ApiModelProperty("层级")
@ExcelProperty(value="层级")
private Integer levelNum2;
}

View File

@ -0,0 +1,70 @@
package com.nflg.product.bomnew.pojo.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.ttzero.excel.annotation.ExcelColumn;
import org.ttzero.excel.annotation.MediaColumn;
import java.io.File;
import java.math.BigDecimal;
@Data
public class CompareReportField {
@ApiModelProperty("汇总")
@ExcelColumn(value="汇总")
private String sumSymbol;
@ApiModelProperty("物料编码")
// @ExcelProperty(value="物料编码")
@ExcelColumn(value="物料编码")
private String materialNo;
@ApiModelProperty("图号")
// @ExcelProperty(value="图号")
@ExcelColumn(value="图号")
private String drawingNo;
@ApiModelProperty("物料描述")
// @ExcelProperty(value="物料描述")
@ExcelColumn(value="物料描述")
private String materialDesc;
@ApiModelProperty("数量")
// @ExcelProperty(value = "数量")
@ExcelColumn(value="数量")
private BigDecimal num;
@ApiModelProperty("单位")
// @ExcelProperty(value = "单位")
@ExcelColumn(value="单位")
private String materialUnit;
@ApiModelProperty("层级")
// @ExcelProperty(value="层级")
@ExcelColumn(value="层级")
private Integer levelNum;
@ApiModelProperty("比对结果")
//@ExcelProperty("比对结果")
@MediaColumn
@ExcelColumn(value="比对结果")
private File compareSymbol;
@ApiModelProperty("数量")
// @ExcelProperty(value = "数量2")
@ExcelColumn(value="数量 ")
private BigDecimal num2;
@ApiModelProperty("单位")
// @ExcelProperty(value = "单位2")
@ExcelColumn(value="单位 ")
private String materialUnit2;
@ApiModelProperty("层级")
@ExcelColumn(value="层级 ")
//@ExcelProperty(value="层级2")
private Integer levelNum2;
}

View File

@ -36,6 +36,7 @@ import nflg.product.common.vo.ResultVO;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.ttzero.excel.entity.ListSheet;
import org.ttzero.excel.entity.Workbook;
import javax.annotation.Resource;
@ -223,7 +224,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
EecExcelUtil.setResponseExcelHeader(response, "bom明细列表");
List<BomNewPbomWorkExcelVO> result = this.getBaseMapper().workDetailsExcel(userRoleService.getUserFactory());
materialMainService.intiMaterialInfo(result, BomNewPbomWorkExcelVO::getMaterialNo, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
new Workbook().addSheet(result).writeTo(response.getOutputStream());
new Workbook().addSheet(new ListSheet<>(result)).writeTo(response.getOutputStream());
}
/**
@ -238,7 +239,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
List<BomNewPbomWorkExcelVO> result = this.getBaseMapper().releaseListExcel(query);
materialMainService.intiMaterialInfo(result, BomNewPbomWorkExcelVO::getMaterialNo, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
new Workbook().addSheet(result).writeTo(response.getOutputStream());
new Workbook().addSheet(new ListSheet<>(result)).writeTo(response.getOutputStream());
}
public List<BomNewPbomParentVO> getChild(Long rowId) {
@ -396,7 +397,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
List<BomNewPbomParentVO> child = this.getChild(bomRowId);
List<BomNewPbomEditExcelVO> result = Convert.toList(BomNewPbomEditExcelVO.class, child);
new Workbook().addSheet(result).writeTo(response.getOutputStream());
new Workbook().addSheet(new ListSheet<>(result)).writeTo(response.getOutputStream());
}
@ -408,8 +409,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
}
List<BomNewPbomEditExcelVO> result = Convert.toList(BomNewPbomEditExcelVO.class, child);
new Workbook().addSheet(result).writeTo(response.getOutputStream());
new Workbook().addSheet(new ListSheet<>(result)).writeTo(response.getOutputStream() );
}

View File

@ -2,21 +2,24 @@ package com.nflg.product.bomnew.service;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.lang.TypeReference;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.support.ExcelTypeEnum;
import com.nflg.product.bomnew.constant.ReportConstant;
import com.nflg.product.bomnew.excel.CompareReportField;
import com.nflg.product.bomnew.pojo.vo.*;
import com.nflg.product.bomnew.pojo.query.CompareReportQuery;
import com.nflg.product.bomnew.pojo.vo.CompareReportListVO;
import com.nflg.product.bomnew.pojo.vo.CompareReportVO;
import com.nflg.product.bomnew.pojo.vo.ForwardReportVO;
import com.nflg.product.bomnew.pojo.vo.ReportBomVO;
import com.nflg.product.bomnew.util.EecExcelUtil;
import com.nflg.product.bomnew.util.VUtils;
import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Service;
import org.ttzero.excel.entity.ListSheet;
import java.io.*;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
@ -28,6 +31,9 @@ import java.util.stream.Collectors;
public class CompareReportService {
public CompareReportService() throws IOException {
}
public CompareReportListVO compareBom(CompareReportQuery query) {
ReportBomVO left = SpringUtil.getBean(ForwardReportService.class).factoryBomType(query.getLeft());
ReportBomVO right = SpringUtil.getBean(ForwardReportService.class).factoryBomType(query.getRight());
@ -56,32 +62,154 @@ public class CompareReportService {
}
public void compareBomExport(CompareReportQuery query) {
/**
* 比较导出
*
* @param 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(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()));
if(compareReportVO.getLeft()!=null){
}
}
}
// EasyExcel.write(filePath)
// .needHead(true)
// .excelType(ExcelTypeEnum.XLSX)
// .autoCloseStream(Boolean.FALSE)
//
// .sheet("Mbom")
// .doWrite(excelList);
// final ListSheet<CompareReportField> listSheet = new ListSheet<CompareReportField>() {
// Long n = 0L;
// Long pages = 1L;
//
// @Override
// protected List<CompareReportField> more() {
// return n++ < pages ? excelList : null;
// }
// };
ListSheet<CompareReportField> listSheet = new ListSheet(excelList);
EecExcelUtil.eecExcel("BOM比对", listSheet, filePath);
}
File getFile(Integer type) throws IOException {
String filePath="0.png";
if(ObjectUtil.equal(type,ReportConstant.SymbolEnum.EQ.getValue())
) {
filePath="1.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.NULL_R.getValue())){
filePath="2.png";
}
ClassPathResource resource = new ClassPathResource("template/"+filePath);
File input = resource.getFile();
return input;
}
/**
* 左倾斜 或右倾斜
* @param leftNode

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 680 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 977 B

View File

@ -57,7 +57,7 @@
<jedis-version>2.9.0</jedis-version>
<hutool-version>5.6.5</hutool-version>
<commons-beanutils-version>1.9.3</commons-beanutils-version>
<eec.version>0.4.14</eec.version>
<eec.version>0.5.13</eec.version>
<jcifs.version>1.3.17</jcifs.version>
</properties>
<dependencies>