diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java index 86e4ff70..d1c45701 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java @@ -158,12 +158,20 @@ public class EbomApi extends BaseApi { } @PostMapping("exportBom") - @ApiOperation("导出") + @ApiOperation("工作明细导出") public void exportBom(@RequestBody List bomRowIds, HttpServletResponse response) throws IOException { VUtils.isTure(CollUtil.isEmpty(bomRowIds)).throwMessage("请选择要导出的物料行"); bomNewEbomParentService.exportBom(bomRowIds, response); } + @PostMapping("editExportBom") + @ApiOperation("编辑导出") + public void editExportBom(@RequestBody List 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 createBomImport(@ModelAttribute BomNewEbomImportDTO dto) throws IOException, ExecutionException, InterruptedException { + public ResultVO 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); } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/dto/BomNewEbomImportDTO.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/dto/BomNewEbomImportDTO.java index 2fc9efeb..c65fea2a 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/dto/BomNewEbomImportDTO.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/dto/BomNewEbomImportDTO.java @@ -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; diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/EbomExcelEditVO.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/EbomExcelEditVO.java new file mode 100644 index 00000000..7a26032b --- /dev/null +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/EbomExcelEditVO.java @@ -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; + + + +} diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/EbomExcelVO.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/EbomExcelVO.java index 1707ea48..ef3e6c6e 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/EbomExcelVO.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/EbomExcelVO.java @@ -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; diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java index 1115ed1e..3d9ee064 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java @@ -552,19 +552,47 @@ public class BomNewEbomParentService extends ServiceImpl bomRowIds, HttpServletResponse response) throws IOException { + + + + public void editExportBom(List list, HttpServletResponse response) throws IOException { + final ListSheet listSheet = new ListSheet() { + Long n = 0L; + Long pages = 1L; + @Override + protected List more() { + + return n++ < pages ? Convert.toList(EbomExcelEditVO.class, list) : null; + } + }; + EecExcelUtil.eecExcel("bom列表", listSheet, response); + + } + + + + + + + public void exportBom(List bomRowIds, HttpServletResponse response) throws IOException { final ListSheet listSheet = new ListSheet() { + + Long n = 0L; + Long pages = 1L; @Override protected List more() { - - List child = getChildBatch(bomRowIds); - return Convert.toList(EbomExcelVO.class, child); + List 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 result = EecExcelUtil.getExcelContext(inputStream, BomNewEBomImportExcelDTO.class); if(CollectionUtil.isEmpty(result)){ - + throw new NflgBusinessException(STATE.Error,"上传数据为空"); } @@ -626,14 +654,16 @@ public class BomNewEbomParentService extends ServiceImpl datas = Convert.convert(new TypeReference>() { }, 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 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 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); diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/EBomEdit.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/EBomEdit.java index 90361da5..e16592bd 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/EBomEdit.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/EBomEdit.java @@ -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()); diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/util/EecExcelUtil.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/util/EecExcelUtil.java index c46d98e6..7c30fa57 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/util/EecExcelUtil.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/util/EecExcelUtil.java @@ -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 *