导出报表

This commit is contained in:
jing's 2023-12-30 17:43:13 +08:00
parent 5ac9665214
commit a042d1fdbf
7 changed files with 220 additions and 25 deletions

View File

@ -158,12 +158,20 @@ public class EbomApi extends BaseApi {
}
@PostMapping("exportBom")
@ApiOperation("导出")
@ApiOperation("工作明细导出")
public void exportBom(@RequestBody List<Long> bomRowIds, HttpServletResponse response) throws IOException {
VUtils.isTure(CollUtil.isEmpty(bomRowIds)).throwMessage("请选择要导出的物料行");
bomNewEbomParentService.exportBom(bomRowIds, response);
}
@PostMapping("editExportBom")
@ApiOperation("编辑导出")
public void editExportBom(@RequestBody List<BomNewEbomParentVO> list, HttpServletResponse response) throws IOException {
VUtils.isTure(CollectionUtil.isEmpty(list)).throwMessage("请选择要导出的物料行");
bomNewEbomParentService.editExportBom(list, response);
}
@GetMapping("createBomDownExcelTmp")
@ApiOperation("创建EBOM-导入时模版下载")
@ -186,19 +194,30 @@ public class EbomApi extends BaseApi {
// }
@PostMapping("createBomImport")
@ApiOperation("创建EBOM-导入")
public ResultVO<Boolean> createBomImport(@ModelAttribute BomNewEbomImportDTO dto) throws IOException, ExecutionException, InterruptedException {
public ResultVO<Boolean> createBomImport(
@RequestParam(value = "type") Integer type, @RequestParam(value = "rowId") Long rowId, @RequestParam(value = "file") MultipartFile file
) throws IOException, ExecutionException, InterruptedException {
if (Objects.isNull(dto.getParent())) {
if (Objects.isNull(rowId)) {
return ResultVO.error(STATE.Error, "请先保存编辑BOM列表再导入数据");
}
if (Objects.isNull(dto.getOpType())) {
if (Objects.isNull(type)) {
return ResultVO.error(STATE.Error, "请选择清除原数据或追加行");
}
if (dto.getFile() != null && !dto.getFile().getOriginalFilename().endsWith("xls") && !dto.getFile().getOriginalFilename().endsWith("xlsx")) {
if (file != null && !file.getOriginalFilename().endsWith("xls") && !file.getOriginalFilename().endsWith("xlsx")) {
return ResultVO.error("请上传Excel文件");
}
bomNewEbomParentService.createBomImport(dto,dto.getFile().getInputStream());
BomNewEbomImportDTO dto=new BomNewEbomImportDTO();
dto.setOpType(type);
dto.setRowId(rowId);
if( !(dto.isDel() || dto.isAppend() )){
return ResultVO.error("清除原数据或追加行数据错误");
}
bomNewEbomParentService.createBomImport(dto,file.getInputStream());
return ResultVO.success(true);
}

View File

@ -13,8 +13,10 @@ public class BomNewEbomImportDTO {
@ApiModelProperty("excel文件")
private MultipartFile file;
@ApiModelProperty("物料数据")
private BomNewEbomParentVO parent;
// @ApiModelProperty("物料数据")
// private BomNewEbomParentVO parent;
@ApiModelProperty("父物料id")
private Long rowId;
@ApiModelProperty("操作类型(1:删除 2:追加)")
private Integer opType;

View File

@ -0,0 +1,126 @@
package com.nflg.product.bomnew.pojo.vo;
import com.nflg.product.bomnew.constant.EBomExceptionStatusEnum;
import com.nflg.product.bomnew.constant.EBomStatusEnum;
import com.nflg.product.bomnew.util.EnumUtils;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.ttzero.excel.annotation.ExcelColumn;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Objects;
@Data
public class EbomExcelEditVO {
@ExcelColumn(value = "异常状态",colIndex = 0)
private String errorStatus;
public String getErrorStatus(){
return EnumUtils.getValueEnum(EBomExceptionStatusEnum.class, this.status).getDescription();
}
private Integer exceptionStatus;
@ExcelColumn(value ="序号",colIndex = 1)
private String orderNumber;
@ExcelColumn(value ="项目类别",colIndex = 2)
private String projectType;
@ExcelColumn(value ="物料编码",colIndex = 3)
private String materialNo;
@ExcelColumn(value ="版本号",colIndex = 4)
private String currentVersion;
@ExcelColumn(value ="图号",colIndex = 5)
private String drawingNo;
@ExcelColumn(value ="物料描述",colIndex = 6)
private String materialDesc;
//@ExcelColumn("物料名称")
private String materialName;
@ExcelColumn(value ="数量",colIndex = 7)
private BigDecimal num;
@ExcelColumn(value ="单位",colIndex = 8)
private String materialUnit;
@ExcelColumn(value ="重量",colIndex = 9)
private BigDecimal totalWeight;
@ExcelColumn(value ="有下级BOM",colIndex = 10)
private String bomExistStr;
private Long bomRowId;
public String getBomExistStr(){
if(Objects.isNull(bomRowId) || bomRowId==0){
return "";
}
return "";
}
@ExcelColumn(value ="识别号",colIndex = 11)
private String batchId;
@ExcelColumn(value ="虚拟件",colIndex = 12)
private String virtualPart;
private Integer virtualPartIs;
public String getVirtualPart(){
if(Objects.isNull(virtualPartIs) || virtualPartIs==0){
return "";
}
return "";
}
@ExcelColumn(value ="类别",colIndex = 13)
private String categoryName;
@ExcelColumn(value ="创建日期",colIndex = 14)
private LocalDateTime createdTime;
@ExcelColumn(value ="修改日期",colIndex = 15)
private LocalDateTime modifTime;
@ExcelColumn(value ="有效起始日",colIndex = 16)
private String startTime;
public LocalDateTime getStartTime(){
return createdTime;
}
@ExcelColumn(value ="版本过期时间",colIndex = 16)
private LocalDateTime expireEndTime;
@ExcelColumn(value ="物料状态",colIndex = 17)
private String materialStatus;
@ApiModelProperty(value = "1=待复核、2=已复核、3=已退回、4=定版已发布PBOM")
private Integer status;
@ExcelColumn(value ="BOM状态",colIndex = 18)
private String statusName;
public String getStatusName() {
return EnumUtils.getValueEnum(EBomStatusEnum.class, this.status).getDescription();
}
@ExcelColumn(value = "设计人员")
private String deviseName ;
@ExcelColumn(value = "设计维护部门名称")
private String deptName;
@ExcelColumn("通知单号")
private String noticeNo;
@ExcelColumn("升版说明")
private String upgradeRemark;
@ExcelColumn("备注")
private String remark;
}

View File

@ -3,12 +3,14 @@ package com.nflg.product.bomnew.pojo.vo;
import com.nflg.product.bomnew.constant.EBomExceptionStatusEnum;
import com.nflg.product.bomnew.constant.EBomStatusEnum;
import com.nflg.product.bomnew.util.EnumUtils;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.ttzero.excel.annotation.ExcelColumn;
import java.math.BigDecimal;
import java.util.Map;
/**
@ -34,7 +36,7 @@ public class EbomExcelVO {
private String drawingNo;
@ExcelColumn(value = "数量")
private Integer num;
private BigDecimal num;
@ApiModelProperty(value = "1=待复核、2=已复核、3=已退回、4=定版已发布PBOM")
private Integer status;
@ -50,6 +52,13 @@ public class EbomExcelVO {
@ExcelColumn("异常状态")
private String errorStatus;
public String getErrorStatus(){
return EnumUtils.getValueEnum(EBomExceptionStatusEnum.class, this.status).getDescription();
}
private Integer exceptionStatus;
@ExcelColumn(value = "设计人员-名称")
private String deviseName;
@ -63,7 +72,8 @@ public class EbomExcelVO {
@ExcelColumn("升版说明")
private String upgradeRemark;
@ExcelColumn("任务时间")
private String createdTime;
@ExcelColumn("备注")
private String remark;

View File

@ -552,19 +552,47 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
}
public void exportBom(List<Long> bomRowIds, HttpServletResponse response) throws IOException {
public void editExportBom(List<BomNewEbomParentVO> list, HttpServletResponse response) throws IOException {
final ListSheet<EbomExcelEditVO> listSheet = new ListSheet<EbomExcelEditVO>() {
Long n = 0L;
Long pages = 1L;
@Override
protected List<EbomExcelEditVO> more() {
return n++ < pages ? Convert.toList(EbomExcelEditVO.class, list) : null;
}
};
EecExcelUtil.eecExcel("bom列表", listSheet, response);
}
public void exportBom(List<Long> bomRowIds, HttpServletResponse response) throws IOException {
final ListSheet<EbomExcelVO> listSheet = new ListSheet<EbomExcelVO>() {
Long n = 0L;
Long pages = 1L;
@Override
protected List<EbomExcelVO> more() {
List<BomNewEbomParentVO> child = getChildBatch(bomRowIds);
return Convert.toList(EbomExcelVO.class, child);
List<BomNewEbomParentVO> child = getChildBatch(bomRowIds);
return n++ < pages ? Convert.toList(EbomExcelVO.class, child) : null;
}
};
EecExcelUtil.eecExcel("bom列表", listSheet, response);
}
/**
* 计算BOM树高度
*
@ -614,7 +642,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
List<BomNewEBomImportExcelDTO> result = EecExcelUtil.getExcelContext(inputStream, BomNewEBomImportExcelDTO.class);
if(CollectionUtil.isEmpty(result)){
throw new NflgBusinessException(STATE.Error,"上传数据为空");
}
@ -626,14 +654,16 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
List<BomNewEbomParentVO> datas = Convert.convert(new TypeReference<List<BomNewEbomParentVO>>() {
}, result);
BomNewEbomParentEntity parentEntity = this.getBaseMapper().selectById(dto.getRowId());
BomNewEbomParentVO parentVO=Convert.convert(BomNewEbomParentVO.class,parentEntity);
parentVO.setBomRowId(parentVO.getRowId());
parentVO.setParentRowId(0l);
materialMainService.intiMaterialInfo(datas, "projectType",
"materialUnit");
materialMainService.intiMaterialInfo(datas, "projectType","materialWeight",
"material_texture");
EBomEdit eBomEdit = new EBomEdit(EBomSourceEnum.FROM_EXCE.getValue());
BomNewEBomParentEditDTO bomNewEBomParentEditDTO = new BomNewEBomParentEditDTO();
bomNewEBomParentEditDTO.setParent(dto.getParent());
bomNewEBomParentEditDTO.setParent(parentVO);
bomNewEBomParentEditDTO.setDatas(datas);
eBomEdit.temporary(bomNewEBomParentEditDTO);
@ -642,13 +672,13 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
int orderNo=1;
if(dto.isDel()){
if (dto.getParent().getBomRowId() > 0 && (dto.getParent().getSource().equals(EBomSourceEnum.FROM_MDM.getValue())
|| dto.getParent().getSource().equals(EBomSourceEnum.FROM_EXCE.getValue()))) {
deleteBom(dto.getParent().getBomRowId());
if ( (parentVO.getSource().equals(EBomSourceEnum.FROM_MDM.getValue())
|| parentVO.getSource().equals(EBomSourceEnum.FROM_EXCE.getValue()))) {
deleteBom(dto.getRowId());
}
}else {
QueryWrapper<BomNewEbomChildEntity > queryWrapper=new QueryWrapper<>();
queryWrapper.lambda().eq(BomNewEbomChildEntity::getParentRowId,dto.getParent().getBomRowId()).last("limit 1");
queryWrapper.lambda().eq(BomNewEbomChildEntity::getParentRowId,dto.getRowId()).last("limit 1");
queryWrapper.lambda().orderByDesc(BomNewEbomChildEntity::getOrderNumber);
BomNewEbomChildEntity entity= ebomChildService.getOne(queryWrapper);

View File

@ -128,7 +128,7 @@ public class EBomEdit {
//新增数据
if(child.getRowId()==null || child.getRowId().longValue()==0){
child.setRowId(IdWorker.getId());
child.setIdentityNo(StrUtil.join("-", parent.getRowId(), parent.getRowId()));
child.setIdentityNo(StrUtil.join("_", parent.getRowId(), child.getRowId()));
child.setSource(source);
child.setEditStatus(EbomEditStatusEnum.HANDLER_CREATED.getValue());

View File

@ -67,6 +67,14 @@ public class EecExcelUtil {
}
public static void eecExcel(String fileName, ListSheet sheet, OutputStream outputStream) throws IOException {
//setResponseExcelHeader(response, fileName);
new Workbook().addSheet(sheet
).writeTo(outputStream);
}
/**
* 行读取excel sheet 0
*