From faca977b813f962b967e37a4b3ed4d762ec578a5 Mon Sep 17 00:00:00 2001 From: jing's Date: Sat, 23 Dec 2023 18:27:09 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nflg/product/bomnew/api/user/EbomApi.java | 38 ++- .../constant/ProjectTypeInputTypeEnum.java | 14 ++ .../bomnew/pojo/dto/BomNewEbomImportDTO.java | 24 ++ .../pojo/dto/BomNewEbomProjectTypeDTO.java | 22 ++ .../service/BomNewEbomParentService.java | 235 +++++++++++------- .../bomnew/service/domain/EBom/EBomEdit.java | 54 +++- 6 files changed, 272 insertions(+), 115 deletions(-) create mode 100644 nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/dto/BomNewEbomImportDTO.java create mode 100644 nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/dto/BomNewEbomProjectTypeDTO.java 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 ef7fdb3f..83beb01d 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 @@ -153,19 +153,28 @@ public class EbomApi extends BaseApi { new Workbook("eBom-create-template", "").addSheet(new ListSheet<>("sheet1", ImmutableList.of(new BomNewEBomImportExcelDTO()))).writeTo(response.getOutputStream()); } - @GetMapping("createBomImport") +// @PostMapping("createBomImport") +// @ApiOperation("创建EBOM-导入") +// public ResultVO> createBomImport(@ModelAttribute BomNewEbomImportDTO dto) throws IOException { +// if (dto.getFile() != null && !dto.getFile().getOriginalFilename().endsWith("xls") && !dto.getFile().getOriginalFilename().endsWith("xlsx")) { +// return ResultVO.error("请上传Excel文件"); +// } +// List result = EecExcelUtil.getExcelContext(dto.getFile().getInputStream(), BomNewEBomImportExcelDTO.class); +// +// +// materialMainService.intiMaterialInfo(result, BomNewEBomImportExcelDTO::getMaterialNo); +// return ResultVO.success(result); +// } + @PostMapping("createBomImport") @ApiOperation("创建EBOM-导入") - public ResultVO> createBomImport(@RequestParam(value = "file") MultipartFile file) throws IOException { - if (file != null && !file.getOriginalFilename().endsWith("xls") && !file.getOriginalFilename().endsWith("xlsx")) { + public ResultVO createBomImport(@ModelAttribute BomNewEbomImportDTO dto) throws IOException { + if (dto.getFile() != null && !dto.getFile().getOriginalFilename().endsWith("xls") && !dto.getFile().getOriginalFilename().endsWith("xlsx")) { return ResultVO.error("请上传Excel文件"); } - List result = EecExcelUtil.getExcelContext(file.getInputStream(), BomNewEBomImportExcelDTO.class); - - materialMainService.intiMaterialInfo(result, BomNewEBomImportExcelDTO::getMaterialNo); - return ResultVO.success(result); + bomNewEbomParentService.createBomImport(dto,dto.getFile().getInputStream()); + return ResultVO.success(true); } - @PostMapping("createBom") @ApiOperation("创建BOM") public ResultVO createBom(@RequestBody BomNewEBomCreateDTO createDTO) { @@ -214,6 +223,19 @@ public class EbomApi extends BaseApi { return resultVO; } + @PostMapping("updateProjectType") + @ApiOperation("更新项目类型") + public ResultVO updateProjectType(@RequestBody BomNewEbomProjectTypeDTO dto) { + + VUtils.isTure(StrUtil.isEmpty(dto.getProjectType())).throwMessage("项目类型不能为空"); + + VUtils.isTure(CollUtil.isEmpty(dto.getRowIdList())).throwMessage("选择要修改的数据"); + bomNewEbomParentService.updateProjectType(dto); + + return ResultVO.success(true); + } + + @PostMapping("queryMaterial") @ApiOperation("查询物料信息") diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/ProjectTypeInputTypeEnum.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/ProjectTypeInputTypeEnum.java index 8b702f57..9e0e5654 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/ProjectTypeInputTypeEnum.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/ProjectTypeInputTypeEnum.java @@ -25,4 +25,18 @@ public enum ProjectTypeInputTypeEnum implements ValueEnum { private final Integer value; private final String description; + + + + @Getter + @AllArgsConstructor + public enum ProjectTypeEnum implements ValueEnum { + TYPE_Q("Q", "Q"), + TYPE_F("F", "F"); + + private final String value; + private final String description; + + } + } 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 new file mode 100644 index 00000000..f5f95d51 --- /dev/null +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/dto/BomNewEbomImportDTO.java @@ -0,0 +1,24 @@ +package com.nflg.product.bomnew.pojo.dto; + +import com.nflg.product.bomnew.constant.EBomSourceEnum; +import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springframework.web.multipart.MultipartFile; + +@Data +public class BomNewEbomImportDTO { + + @ApiModelProperty("excel文件") + private MultipartFile file; + @ApiModelProperty("物料数据") + private BomNewEbomParentVO parent; + @ApiModelProperty("操作类型(1:删除 2:追加)") + private Integer opType; + + @ApiModelProperty("忽略") + private Integer source= EBomSourceEnum.FROM_EXCE.getValue(); + + + +} diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/dto/BomNewEbomProjectTypeDTO.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/dto/BomNewEbomProjectTypeDTO.java new file mode 100644 index 00000000..06a4ae5d --- /dev/null +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/dto/BomNewEbomProjectTypeDTO.java @@ -0,0 +1,22 @@ +package com.nflg.product.bomnew.pojo.dto; + +import com.nflg.product.bomnew.constant.EBomSourceEnum; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +@Data +@ApiModel(value = "com-nflg-product-bomnew-pojo-new-dto-BomNewEbomProjectTypeDTO") +public class BomNewEbomProjectTypeDTO { + + @ApiModelProperty("行rowId") + private List rowIdList; + + @ApiModelProperty("项目类型") + private String projectType; + + +} 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 a25e8124..c26d5da5 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 @@ -7,9 +7,11 @@ import cn.hutool.core.convert.Convert; import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.LocalDateTimeUtil; +import cn.hutool.core.lang.TypeReference; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.StrUtil; +import cn.hutool.extra.spring.SpringUtil; import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -39,6 +41,7 @@ import org.ttzero.excel.entity.ListSheet; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import java.io.IOException; +import java.io.InputStream; import java.math.BigDecimal; import java.time.LocalDateTime; import java.util.*; @@ -138,8 +141,6 @@ public class BomNewEbomParentService extends ServiceImpl list){ - CheckEBomException checkEBomException=new CheckEBomException(list); + public void initBomException(List list) { + CheckEBomException checkEBomException = new CheckEBomException(list); checkEBomException.initException(); } /** * 初始化bom 异常信息 + * * @param bomRowId bom行ID */ - public void initBomException (Long bomRowId) throws ExecutionException, InterruptedException { - CheckEBomException checkEBomException=new CheckEBomException(bomRowId); + public void initBomException(Long bomRowId) throws ExecutionException, InterruptedException { + CheckEBomException checkEBomException = new CheckEBomException(bomRowId); checkEBomException.initException(); } /** * 检查 并保存异常信息 */ - public void checkAndSaveEBomException(Long bomRowId) throws ExecutionException, InterruptedException { - CheckEBomException checkEBomException=new CheckEBomException(bomRowId); + public void checkAndSaveEBomException(Long bomRowId) throws ExecutionException, InterruptedException { + CheckEBomException checkEBomException = new CheckEBomException(bomRowId); checkEBomException.initException(); List allBomDetail = checkEBomException.getAllBomDetail(); //父级 List parents = allBomDetail.stream().filter(u -> u.getBomRowId() > 0).collect(Collectors.toList()); if (CollUtil.isNotEmpty(parents)) { - List pentList=new ArrayList<>(); - parents.forEach(k->{ - BomNewEbomParentEntity pEnt=new BomNewEbomParentEntity(); + List pentList = new ArrayList<>(); + parents.forEach(k -> { + BomNewEbomParentEntity pEnt = new BomNewEbomParentEntity(); pEnt.setRowId(k.getBomRowId()); pEnt.setExceptionStatus(k.getExceptionStatus()); pentList.add(pEnt); }); - if(CollUtil.isNotEmpty(pentList)){ + if (CollUtil.isNotEmpty(pentList)) { this.updateBatchById(pentList); } } //子级 List child = allBomDetail.stream().filter(u -> u.getRowId() > 0).collect(Collectors.toList()); if (CollUtil.isNotEmpty(parents)) { - List childList=new ArrayList<>(); - parents.forEach(k->{ - BomNewEbomChildEntity pEnt=new BomNewEbomChildEntity(); + List childList = new ArrayList<>(); + parents.forEach(k -> { + BomNewEbomChildEntity pEnt = new BomNewEbomChildEntity(); pEnt.setRowId(k.getRowId()); pEnt.setExceptionStatus(k.getExceptionStatus()); childList.add(pEnt); }); - if(CollUtil.isNotEmpty(childList)){ + if (CollUtil.isNotEmpty(childList)) { ebomChildService.updateBatchById(childList); } } - } @@ -445,21 +447,22 @@ public class BomNewEbomParentService extends ServiceImpl bomRowIds){ + public void upgradeChanges(List bomRowIds) { List list = this.lambdaQuery().in(BomNewEbomParentEntity::getRowId, bomRowIds).list(); List notConvertToPbom = list.stream().filter(u -> u.getStatus() < EBomStatusEnum.PUBLISHED.getValue()).map(u -> u.getMaterialNo()).collect(Collectors.toList()); - VUtils.isTure(CollUtil.isNotEmpty(notConvertToPbom)).throwMessage(StrUtil.join(",", notConvertToPbom)+"未转PBom,不能发起变更"); - List parentResult=new ArrayList<>(); - List childResult=new ArrayList<>(); + VUtils.isTure(CollUtil.isNotEmpty(notConvertToPbom)).throwMessage(StrUtil.join(",", notConvertToPbom) + "未转PBom,不能发起变更"); + List parentResult = new ArrayList<>(); + List childResult = new ArrayList<>(); for (Long bomRowId : bomRowIds) { BomNewEbomParentEntity parent = this.getById(bomRowId); List child = ebomChildService.lambdaQuery().eq(BomNewEbomChildEntity::getParentRowId, bomRowId).list(); - BomNewEbomParentEntity newParent=new BomNewEbomParentEntity(); - BeanUtil.copyProperties(parent,newParent); + BomNewEbomParentEntity newParent = new BomNewEbomParentEntity(); + BeanUtil.copyProperties(parent, newParent); newParent.setRowId(IdWorker.getId()); newParent.setLastVersionIs(1); newParent.setCurrentVersion(VersionUtil.getNextVersionForSmallVersion(parent.getCurrentVersion())); @@ -468,19 +471,19 @@ public class BomNewEbomParentService extends ServiceImpl list = this.lambdaQuery().le(BomNewEbomParentEntity ::getLevelNum, 0).list(); + List list = this.lambdaQuery().le(BomNewEbomParentEntity::getLevelNum, 0).list(); if (CollUtil.isNotEmpty(list)) { for (BomNewEbomParentEntity bom : list) { bom.setRootIs(1); List bomDetail = this.getBaseMapper().getParentChild(bom.getRowId()); - EBomDetailTask detailTask = new EBomDetailTask(bomDetail); + EBomDetailTask detailTask = new EBomDetailTask(bomDetail); detailTask.setLevelNum(1); ForkJoinTask> submit = bomDetailPool.submit(detailTask); submit.get(); @@ -535,12 +539,30 @@ public class BomNewEbomParentService extends ServiceImpl result = EecExcelUtil.getExcelContext(inputStream, BomNewEBomImportExcelDTO.class); + + List datas = Convert.convert(new TypeReference>() { + }, result); + + materialMainService.intiMaterialInfo(datas, BomNewEbomParentVO::getMaterialNo); + EBomEdit eBomEdit = new EBomEdit(EBomSourceEnum.FROM_EXCE.getValue()); + + BomNewEBomParentEditDTO bomNewEBomParentEditDTO=new BomNewEBomParentEditDTO(); + bomNewEBomParentEditDTO.setParent(dto.getParent()); + bomNewEBomParentEditDTO.setDatas(datas); + eBomEdit.temporary(bomNewEBomParentEditDTO); + + + } /** @@ -813,46 +835,73 @@ public class BomNewEbomParentService extends ServiceImpl childEntity=new ArrayList<>(); + dto.getRowIdList().forEach(rowid->{ + BomNewEbomChildEntity entity=new BomNewEbomChildEntity(); + entity.setRowId(rowid); + entity.setProjectTypeInputType(ProjectTypeInputTypeEnum.MANUAL_INPUT.getValue()); + entity.setProjectType(dto.getProjectType()); + entity.setModifyTime(LocalDateTime.now()); + }); + + SpringUtil.getBean(BomNewEbomChildService.class).updateBatchById(childEntity); + return true; + + } + public BomNewEbomEditDetailVO editDetail(Long bomRowId) { BomNewEbomEditDetailVO vo = new BomNewEbomEditDetailVO(); - BomNewEbomParentEntity parent = this.getBaseMapper().selectById(bomRowId); - BomNewEbomParentVO parentVO = Convert.convert(BomNewEbomParentVO.class, parent); - List parentList = new ArrayList<>(); - parentList.add(parentVO); - materialMainService.intiMaterialInfo(parentList); + + + BomNewEbomParentEntity parent= this.getById(bomRowId); + + BomNewEbomParentVO parentVO = Convert.convert(BomNewEbomParentVO.class,parent); + parentVO.setBomRowId(parentVO.getRowId()); +// List parentList = new ArrayList<>(); +// parentList.add(parentVO); +// materialMainService.intiMaterialInfo(parentList); +// + vo.setDatas(getChild(bomRowId)); - vo.setParent(parentList.get(0)); + vo.setParent(parentVO); return vo; } public BomNewEbomParentVO queryMaterial(BomNewEbomMaterialQuery query) { - List materialMainList=null; + List materialMainList = null; if (StringUtils.isNotEmpty(query.getMaterialNo())) { materialMainList = materialMainService.lambdaQuery().eq(MaterialMainEntity::getMaterialNo, query.getMaterialNo()).list(); if (CollUtil.isEmpty(materialMainList)) { - throw new NflgBusinessException(STATE.Error, StrUtil.format("{} 物料编码的物料信息不存在",query.getMaterialNo())); + throw new NflgBusinessException(STATE.Error, StrUtil.format("{} 物料编码的物料信息不存在", query.getMaterialNo())); } if (CollUtil.isNotEmpty(materialMainList) && materialMainList.size() > 1) { - throw new NflgBusinessException(STATE.Error, StrUtil.format("同时存在{}多条相同物料编码的物料信息",query.getMaterialNo())); + throw new NflgBusinessException(STATE.Error, StrUtil.format("同时存在{}多条相同物料编码的物料信息", query.getMaterialNo())); } - }else if (StringUtils.isNotEmpty(query.getDrawingNo())) { + } else if (StringUtils.isNotEmpty(query.getDrawingNo())) { materialMainList = materialMainService.lambdaQuery().eq(MaterialMainEntity::getDrawingNo, query.getDrawingNo()).list(); if (CollUtil.isEmpty(materialMainList)) { - throw new NflgBusinessException(STATE.Error, StrUtil.format("{} 图号的物料信息不存在",query.getDrawingNo())); + throw new NflgBusinessException(STATE.Error, StrUtil.format("{} 图号的物料信息不存在", query.getDrawingNo())); } if (CollUtil.isNotEmpty(materialMainList) && materialMainList.size() > 1) { - throw new NflgBusinessException(STATE.Error, StrUtil.format("同时存在多条 {} 图号的物料信息",query.getDrawingNo())); + throw new NflgBusinessException(STATE.Error, StrUtil.format("同时存在多条 {} 图号的物料信息", query.getDrawingNo())); } } - if(CollUtil.isNotEmpty(materialMainList)){ + if (CollUtil.isNotEmpty(materialMainList)) { MaterialMainEntity materialMainEntity = materialMainList.get(0); - BomNewEbomParentVO baseMaterialVO = new BomNewEbomParentVO(); + BomNewEbomParentVO baseMaterialVO = new BomNewEbomParentVO(); BeanUtil.copyProperties(materialMainEntity, baseMaterialVO); baseMaterialVO.setExceptionStatus(materialMainEntity.getMaterialState()); @@ -861,11 +910,7 @@ public class BomNewEbomParentService extends ServiceImpl bomTree = getBomTree(bomRowId); - List delBom=null; + List delBom = null; if (userRoleService.designer()) { delBom = bomTree.stream().filter(u -> u.getBomRowId() > 0 && u.getSource().equals(EBomSourceEnum.FROM_MDM.getValue()) - && EBomStatusEnum.PUBLISHED.equalsValue(u.getStatus())) + && EBomStatusEnum.PUBLISHED.equalsValue(u.getStatus())) .collect(Collectors.toList()); } - if(CollUtil.isNotEmpty(delBom)) { + if (CollUtil.isNotEmpty(delBom)) { List delParentRowId = new ArrayList<>(); for (BomNewEbomParentVO bom : delBom) { @@ -898,30 +943,59 @@ public class BomNewEbomParentService extends ServiceImpl + * 用户临时处理数据,数据的处理状态为“待处理”,当用户单击暂存的时候,所有的数据都不需要校验,直接保存即可。 */ - public Boolean temporary(BomNewEBomParentEditDTO dto){ + public Boolean temporary(BomNewEBomParentEditDTO dto) { - EBomEdit eBomEdit=new EBomEdit(); + EBomEdit eBomEdit = new EBomEdit(EBomSourceEnum.FROM_MDM.getValue()); eBomEdit.temporary(dto); - if(CollectionUtil.isNotEmpty(eBomEdit.parentEntities)){ - this.saveOrUpdateBatch(eBomEdit.parentEntities ); + if (CollectionUtil.isNotEmpty(eBomEdit.parentEntities)) { + this.saveOrUpdateBatch(eBomEdit.parentEntities); } - if(CollUtil.isNotEmpty(eBomEdit.childEntities)){ + if (CollUtil.isNotEmpty(eBomEdit.childEntities)) { + ebomChildService.saveOrUpdateBatch(eBomEdit.childEntities); + } + if (dto.getParent() != null) { + if (dto.getParent().getSource().equals(EBomSourceEnum.FROM_MDM.getValue()) || dto.getParent().getSource().equals(EBomSourceEnum.FROM_EXCE.getValue())) { + if (CollUtil.isNotEmpty(dto.getDelDatas())) { + List rowIdList = dto.getDelDatas().stream().filter(u -> u.getRowId().longValue() > 0).map(BomNewEbomParentVO::getRowId).collect(Collectors.toList()); + ebomChildService.removeByIds(rowIdList); + + } + } + } + + return true; + } + + /** + * 提交物料 + */ + public Boolean submit(BomNewEBomParentEditDTO dto) { + + EBomEdit eBomEdit = new EBomEdit(EBomSourceEnum.FROM_MDM.getValue()); + eBomEdit.temporary(dto); + if (CollectionUtil.isNotEmpty(eBomEdit.parentEntities)) { + this.saveOrUpdateBatch(eBomEdit.parentEntities); + } + + if (CollUtil.isNotEmpty(eBomEdit.childEntities)) { ebomChildService.saveOrUpdateBatch(eBomEdit.childEntities); } - if(dto.getParent()!=null){ - if(dto.getParent().getSource().equals(EBomSourceEnum.FROM_MDM.getValue()) || dto.getParent().getSource().equals(EBomSourceEnum.FROM_EXCE.getValue())){ - if(CollUtil.isNotEmpty(dto.getDelDatas())) { + if (dto.getParent() != null) { + if (dto.getParent().getSource().equals(EBomSourceEnum.FROM_MDM.getValue()) + || dto.getParent().getSource().equals(EBomSourceEnum.FROM_EXCE.getValue())) { + + if (CollUtil.isNotEmpty(dto.getDelDatas())) { List rowIdList = dto.getDelDatas().stream().filter(u -> u.getRowId().longValue() > 0).map(BomNewEbomParentVO::getRowId).collect(Collectors.toList()); ebomChildService.removeByIds(rowIdList); @@ -929,37 +1003,8 @@ public class BomNewEbomParentService extends ServiceImpl rowIdList = dto.getDelDatas().stream().filter(u -> u.getRowId().longValue() > 0).map(BomNewEbomParentVO::getRowId).collect(Collectors.toList()); - ebomChildService.removeByIds(rowIdList); - - } - } - } - - return true; - - } - } 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 231c5e1f..f071d22a 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 @@ -9,12 +9,10 @@ import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.extra.spring.SpringUtil; import com.baomidou.mybatisplus.core.toolkit.IdWorker; +import com.google.common.collect.ImmutableList; import com.google.common.collect.Sets; import com.nflg.product.base.core.conmon.util.SessionUtil; -import com.nflg.product.bomnew.constant.EBomSourceEnum; -import com.nflg.product.bomnew.constant.EBomStatusEnum; -import com.nflg.product.bomnew.constant.EbomEditStatusEnum; -import com.nflg.product.bomnew.constant.ProjectTypeInputTypeEnum; +import com.nflg.product.bomnew.constant.*; import com.nflg.product.bomnew.pojo.dto.BomNewEBomParentEditDTO; import com.nflg.product.bomnew.pojo.entity.BomNewEbomChildEntity; import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity; @@ -23,8 +21,10 @@ import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO; import com.nflg.product.bomnew.pojo.vo.OptionalEbomConfigVO; import com.nflg.product.bomnew.service.BomNewEbomParentService; import com.nflg.product.bomnew.service.MaterialMainService; +import com.nflg.product.bomnew.service.UserRoleService; import com.nflg.product.bomnew.util.ListCommonUtil; import com.nflg.product.bomnew.util.VUtils; +import io.swagger.models.auth.In; import java.math.BigDecimal; import java.time.LocalDateTime; @@ -37,8 +37,16 @@ public class EBomEdit { public List childEntities; + Integer source; + + public EBomEdit(Integer source){ + this.source=source; + } BomNewEbomParentEntity createParentBomInfo(BomNewEbomParentVO vo) { + + + BomNewEbomParentEntity parent = new BomNewEbomParentEntity(); BeanUtil.copyProperties(parent, vo); @@ -51,20 +59,26 @@ public class EBomEdit { // parent.setMaterialName(material.getMaterialName()); // parent.setMaterialDesc(material.getMaterialDesc()); // parent.setMaterialTexture(material.getMaterial()); - parent.setNum(vo.getNum() == null ? new BigDecimal(1) : vo.getNum()); + // parent.setNum(vo.getNum() == null ? new BigDecimal(1) : vo.getNum()); parent.setTotalWeight(NumberUtil.mul(vo.getUnitWeight(), vo.getNum())); parent.setDeviseUserCode(SessionUtil.getUserCode()); parent.setCurrentVersion("A00"); parent.setDeviseName(SessionUtil.getRealName()); parent.setDeptName(SessionUtil.getDepartName()); - - parent.setSource(EBomSourceEnum.FROM_MDM.getValue()); + parent.setSourceRowId(0l); + parent.setSource(source); parent.setStatus(EBomStatusEnum.WAIT_CHECK.getValue()); parent.setBomExist(1); parent.setLastVersionIs(1); parent.setEditStatus(EbomEditStatusEnum.HANDLER_CREATED.getValue()); + if(StrUtil.isEmpty(parent.getProjectType())){ + parent.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_8.getValue()); + } + + parent.setStatus(SpringUtil.getBean(UserRoleService.class).technician()? EBomStatusEnum.CHECKED.getValue():EBomStatusEnum.WAIT_CHECK.getValue()); + parent.setCreatedJob(SpringUtil.getBean(UserRoleService.class).technician()?UserJobEnum.ENGINEER.getValue():UserJobEnum.DESIGNER.getValue()); return parent; } @@ -114,24 +128,40 @@ public class EBomEdit { for (BomNewEbomChildEntity child : childEntities) { - child.setRowId(IdWorker.getId()); - child.setProjectTypeInputType(ProjectTypeInputTypeEnum.MANUAL_INPUT.getValue()); + + //child.setProjectTypeInputType(ProjectTypeInputTypeEnum.MANUAL_INPUT.getValue()); child.setTotalWeight(NumberUtil.mul(child.getUnitWeight(), child.getNum())); //新增数据 if(child.getRowId()==null || child.getRowId().longValue()==0){ + child.setRowId(IdWorker.getId()); child.setIdentityNo(StrUtil.join("-", parent.getRowId(), parent.getRowId())); - child.setSource(EBomSourceEnum.FROM_MDM.getValue()); + child.setSource(source); child.setEditStatus(EbomEditStatusEnum.HANDLER_CREATED.getValue()); child.setCreatedTime(LocalDateTime.now()); child.setCreatedBy(SessionUtil.getUserCode()); - } + child.setSourceRowId(0l); + } + parent.setTotalWeight(NumberUtil.mul(child.getUnitWeight(), child.getNum())); child.setParentRowId(parent.getRowId()); - VUtils.isTure(parent.getProjectType().equals(child.getProjectType())).throwMessage("父、子级项目类型不能相同"); + if(StrUtil.isEmpty(child.getProjectType())){ + child.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_8.getValue()); + } + + if(StrUtil.isNotEmpty(parent.getProjectType()) && StrUtil.containsAny(parent.getProjectType(),ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_Q.getValue(),ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_F.getValue())){ + if(StrUtil.equals(ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_Q.getValue(),child.getProjectType())){ + child.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_9.getValue()); + } + if(StrUtil.equals(ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_F.getValue(),child.getProjectType())){ + child.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_10.getValue()); + } + } + + // VUtils.isTure(parent.getProjectType().equals(child.getProjectType())).throwMessage("父、子级项目类型不能相同"); } }