Merge branch 'refs/heads/dev' into sit

This commit is contained in:
曹鹏飞 2024-05-20 17:06:33 +08:00
commit 8d0b9f9ac6
5 changed files with 68 additions and 51 deletions

View File

@ -76,8 +76,7 @@ public class EbomV2Api extends BaseApi {
@ApiOperation("从excel导入数据") @ApiOperation("从excel导入数据")
@PostMapping("importBom") @PostMapping("importBom")
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@LogRecord(success = "原始BOM-导入:文件名:{{#fileNme}},操作结果:{{#_ret}}", @LogRecord(success = "EBOM-导入:文件名:{{#fileNme}},操作结果:{{#_ret}}", bizNo = "", type = "EBOM导入")
bizNo = "", type = "原始BOM导入")
public ResultVO<List<OperationErrorMsgVO>> importBom(@RequestParam(value = "file") MultipartFile file) throws Exception { public ResultVO<List<OperationErrorMsgVO>> importBom(@RequestParam(value = "file") MultipartFile file) throws Exception {
if (file != null && !file.getOriginalFilename().endsWith("xls") && !file.getOriginalFilename().endsWith("xlsx")) { if (file != null && !file.getOriginalFilename().endsWith("xls") && !file.getOriginalFilename().endsWith("xlsx")) {
return ResultVO.error("请上传Excel文件"); return ResultVO.error("请上传Excel文件");

View File

@ -336,7 +336,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
List<BomNewEbomParentVO> parentChild = this.getBaseMapper().getParentChild(rowId); List<BomNewEbomParentVO> parentChild = this.getBaseMapper().getParentChild(rowId);
//排除项目类别的赋值 //排除项目类别的赋值
//materialMainService.intiMaterialInfoInPattern(parentChild, "^21 | ^31", EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT); materialMainService.intiMaterialInfoInPattern(parentChild, "^21 | ^31", EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT2);
if (CollUtil.isNotEmpty(parentChild)) { if (CollUtil.isNotEmpty(parentChild)) {
List<String> materialNos = parentChild.stream().map(BaseMaterialVO::getMaterialNo).filter(StrUtil::isNotBlank).collect(Collectors.toList()); List<String> materialNos = parentChild.stream().map(BaseMaterialVO::getMaterialNo).filter(StrUtil::isNotBlank).collect(Collectors.toList());
if (CollUtil.isNotEmpty(materialNos)) { if (CollUtil.isNotEmpty(materialNos)) {
@ -833,11 +833,22 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
//31 须有虚拟包 //31 须有虚拟包
List<BomNewEbomParentEntity> parents = this.getBaseMapper().selectBatchIds(paramDto.getBomRowIds()); List<BomNewEbomParentEntity> parents = this.getBaseMapper().selectBatchIds(paramDto.getBomRowIds());
VUtils.isTure(paramDto.getFacCodes().contains("1020") && parents.stream().anyMatch(u -> u.getMaterialNo().startsWith("31"))) // VUtils.isTure(paramDto.getFacCodes().contains("1020") && parents.stream().anyMatch(u -> u.getMaterialNo().startsWith("31")))
.throwMessage("31码不能生成仙桃(1020)的pbom"); // .throwMessage("31码不能生成仙桃(1020)的pbom");
VUtils.isTure(parents.stream().anyMatch(u -> u.getMaterialNo().startsWith("31") && u.getVirtrualPackageEnum() <= 0)) // VUtils.isTure(parents.stream().anyMatch(u -> u.getMaterialNo().startsWith("31") && u.getVirtrualPackageEnum() <= 0))
.throwMessage("31码须有虚拟包"); // .throwMessage("31码须有虚拟包");
parents.forEach(p -> {
if (p.getMaterialNo().startsWith("31")) {
List<String> errors = new ArrayList<>();
if (ebomChildService.lambdaQuery().eq(BomNewEbomChildEntity::getParentRowId, p.getRowId())
.eq(BomNewEbomChildEntity::getVirtualPartType, VirtualPackageTypeEnum.UN_VIRTUAL_PACKAGE.getValue())
.exists()) {
errors.add(p.getMaterialNo() + "下还有未生成发货包的物料");
}
VUtils.isTure(CollUtil.isNotEmpty(errors)).throwMessage(StrUtil.join("<br/>", errors));
}
});
//检查该版本是否已转换过该工厂的Pbom //检查该版本是否已转换过该工厂的Pbom
for (BomNewEbomParentEntity parent : parents){ for (BomNewEbomParentEntity parent : parents){
List<BomNewPbomParentEntity> list = pBomParentService.lambdaQuery().eq(BomNewPbomParentEntity::getMaterialNo, parent.getMaterialNo()).eq(BomNewPbomParentEntity::getCurrentVersion, parent.getCurrentVersion()) List<BomNewPbomParentEntity> list = pBomParentService.lambdaQuery().eq(BomNewPbomParentEntity::getMaterialNo, parent.getMaterialNo()).eq(BomNewPbomParentEntity::getCurrentVersion, parent.getCurrentVersion())
@ -859,7 +870,9 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
parent.setChildBomRowId(parent.getRowId()); parent.setChildBomRowId(parent.getRowId());
parent.setParentRowId(0L); parent.setParentRowId(0L);
bomTree.add(parent); bomTree.add(parent);
EBomToPBom eBomToPBom = new EBomToPBom(parent, bomTree, paramDto.getFacCodes(), 0L); EBomToPBom eBomToPBom = new EBomToPBom(parent, bomTree
, parent.getMaterialNo().startsWith("31") ? Collections.singletonList("1010") : paramDto.getFacCodes()
, 0L);
eBomToPBom.convert(); eBomToPBom.convert();
if (CollUtil.isNotEmpty(eBomToPBom.getPBomParentResult())) { if (CollUtil.isNotEmpty(eBomToPBom.getPBomParentResult())) {

View File

@ -265,7 +265,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
// .lt(!PBomStatusEnum.PUBLISH.equalsValue(parent.getStatus()),BomNewPbomParentEntity::getStatus,PBomStatusEnum.PUBLISH.getValue()) // .lt(!PBomStatusEnum.PUBLISH.equalsValue(parent.getStatus()),BomNewPbomParentEntity::getStatus,PBomStatusEnum.PUBLISH.getValue())
// .eq(PBomStatusEnum.PUBLISH.equalsValue(parent.getStatus()),BomNewPbomParentEntity::getStatus, PBomStatusEnum.PUBLISH.getValue()) // .eq(PBomStatusEnum.PUBLISH.equalsValue(parent.getStatus()),BomNewPbomParentEntity::getStatus, PBomStatusEnum.PUBLISH.getValue())
.eq(PBomStatusEnum.PUBLISH.getValue() > parent.getStatus(), BomNewPbomParentEntity::getLastVersionIs, 1) .eq(PBomStatusEnum.PUBLISH.getValue() > parent.getStatus(), BomNewPbomParentEntity::getLastVersionIs, 1)
.gt(PBomStatusEnum.PUBLISH.getValue() <= parent.getStatus(), BomNewPbomParentEntity::getStatus, PBomStatusEnum.PUBLISH.getValue()) .ge(PBomStatusEnum.PUBLISH.getValue() <= parent.getStatus(), BomNewPbomParentEntity::getStatus, PBomStatusEnum.PUBLISH.getValue())
.list(); .list();
Map<String, BomNewPbomParentEntity> bomListMap= list.parallelStream() Map<String, BomNewPbomParentEntity> bomListMap= list.parallelStream()

View File

@ -1,7 +1,6 @@
package com.nflg.product.bomnew.service; package com.nflg.product.bomnew.service;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.RandomUtil; import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
@ -305,33 +304,26 @@ public class EBomImportService {
parent = parents.stream().filter(p -> p.getMaterialNo().equals(data.getParentMaterialNo())) parent = parents.stream().filter(p -> p.getMaterialNo().equals(data.getParentMaterialNo()))
.findFirst() .findFirst()
.orElse(null); .orElse(null);
if (Objects.isNull(parent) && datas.stream().noneMatch(d -> d.getMaterialNo().equals(data.getParentMaterialNo()))) {
parents.add(buildRoot(materialBaseInfos, data.getParentMaterialNo(), data.getParentMaterialDesc()));
}
}
for (EbomExcelDTO data : datas) {
parent = parents.stream().filter(p -> p.getMaterialNo().equals(data.getMaterialNo()))
.findFirst()
.orElse(null);
if (Objects.isNull(parent)) { if (Objects.isNull(parent)) {
if (datas.stream().noneMatch(d -> d.getMaterialNo().equals(data.getParentMaterialNo()))) {
parents.add(buildRoot(materialBaseInfos, data.getParentMaterialNo(), data.getParentMaterialDesc()));
} else {
parents.add(buildParent(materialBaseInfos, data)); parents.add(buildParent(materialBaseInfos, data));
} }
} }
}
for (EbomExcelDTO data : datas) { for (EbomExcelDTO data : datas) {
parent = parents.stream().filter(p -> p.getMaterialNo().equals(data.getMaterialNo())) buildChild(children, materialBaseInfos, data
.findFirst()
.get();
buildChild(children, materialBaseInfos, parent, data
, parents.stream().filter(p -> p.getMaterialNo().equals(data.getParentMaterialNo())).findFirst().get()); , parents.stream().filter(p -> p.getMaterialNo().equals(data.getParentMaterialNo())).findFirst().get());
} }
return Pair.of(parents, children); return Pair.of(parents, children);
} }
private void buildChild(List<BomNewEbomChildEntity> children, List<BaseMaterialVO> materialBaseInfos, BomNewEbomParentEntity parent, EbomExcelDTO data, BomNewEbomParentEntity p) { private void buildChild(List<BomNewEbomChildEntity> children, List<BaseMaterialVO> materialBaseInfos, EbomExcelDTO data, BomNewEbomParentEntity p) {
BomNewEbomChildEntity child = Convert.convert(BomNewEbomChildEntity.class, parent); BomNewEbomChildEntity child = new BomNewEbomChildEntity();
child.setRowId(IdWorker.getId()); child.setRowId(IdWorker.getId());
child.setParentRowId(p.getRowId()); child.setParentRowId(p.getRowId());
parent.setOrderNumber(""); child.setMaterialNo(data.getMaterialNo());
List<BomNewEbomChildEntity> pcs = children.stream() List<BomNewEbomChildEntity> pcs = children.stream()
.filter(c -> Objects.equals(c.getParentRowId(), p.getRowId())) .filter(c -> Objects.equals(c.getParentRowId(), p.getRowId()))
.collect(Collectors.toList()); .collect(Collectors.toList());
@ -341,11 +333,23 @@ public class EBomImportService {
String maxOrderNum = pcs.get(pcs.size() - 1).getOrderNumber(); String maxOrderNum = pcs.get(pcs.size() - 1).getOrderNumber();
child.setOrderNumber(OrderNoUtil.next(maxOrderNum)); child.setOrderNumber(OrderNoUtil.next(maxOrderNum));
} }
child.setDrawingNo(parent.getDrawingNo()); child.setMaterialDesc(data.getMaterialDesc());
child.setMaterialDesc(parent.getMaterialDesc()); BaseMaterialVO vo = materialBaseInfos.stream()
child.setUnitWeight(parent.getUnitWeight()); .filter(m -> m.getMaterialNo().equals(child.getMaterialNo()))
child.setMaterialUnit(data.getUnit()); .findFirst()
child.setMaterialOriginalUnit(parent.getMaterialOriginalUnit()); .orElse(null);
if (!Objects.isNull(vo)) {
child.setMaterialCategoryCode(vo.getMaterialCategoryCode());
child.setMaterialName(vo.getMaterialName());
child.setDrawingNo(vo.getDrawingNo());
child.setUnitWeight(vo.getMaterialWeight());
child.setMaterialUnit(vo.getMaterialUnit());
child.setMaterialTexture(vo.getMaterialTexture());
if (StrUtil.isBlank(child.getMaterialDesc())) {
child.setMaterialDesc(vo.getMaterialDesc());
}
}
child.setMaterialOriginalUnit(data.getUnit());
child.setNum(data.getNum()); child.setNum(data.getNum());
child.setRemark(data.getRemark()); child.setRemark(data.getRemark());
child.setTotalWeight(BomUtil.calculateTotalWeight(child.getNum(), child.getUnitWeight())); child.setTotalWeight(BomUtil.calculateTotalWeight(child.getNum(), child.getUnitWeight()));
@ -355,13 +359,11 @@ public class EBomImportService {
if (p.getMaterialNo().startsWith("31")) { if (p.getMaterialNo().startsWith("31")) {
child.setVirtualPartRootMaterialNo(p.getMaterialNo()); child.setVirtualPartRootMaterialNo(p.getMaterialNo());
} }
BaseMaterialVO vo = materialBaseInfos.stream() child.setEditStatus(EbomEditStatusEnum.HANDLER_CREATED.getValue());
.filter(m -> m.getMaterialNo().equals(child.getMaterialNo())) child.setExceptionStatus(EBomExceptionStatusEnum.INIT.getValue());
.findFirst() child.setCreatedBy(SessionUtil.getUserCode());
.orElse(null); child.setRemark(data.getRemark());
if (!Objects.isNull(vo)) { child.setSource(EBomSourceEnum.FROM_EXCE.getValue());
child.setMaterialCategoryCode(vo.getMaterialCategoryCode());
}
setVirtualPackageType(child); setVirtualPackageType(child);
children.add(child); children.add(child);
} }
@ -371,10 +373,10 @@ public class EBomImportService {
parent.setRowId(IdWorker.getId()); parent.setRowId(IdWorker.getId());
parent.setCurrentVersion(OriginalConstant.DEFAULT_BOM_VERSION); parent.setCurrentVersion(OriginalConstant.DEFAULT_BOM_VERSION);
parent.setMaterialNo(data.getMaterialNo()); parent.setMaterialNo(data.getParentMaterialNo());
parent.setMaterialDesc(data.getMaterialDesc()); parent.setMaterialDesc(data.getParentMaterialDesc());
BaseMaterialVO vo = materialBaseInfos.stream() BaseMaterialVO vo = materialBaseInfos.stream()
.filter(m -> m.getMaterialNo().equals(data.getMaterialNo())) .filter(m -> m.getMaterialNo().equals(data.getParentMaterialNo()))
.findFirst() .findFirst()
.orElse(null); .orElse(null);
if (!Objects.isNull(vo)) { if (!Objects.isNull(vo)) {
@ -382,12 +384,12 @@ public class EBomImportService {
parent.setUnitWeight(vo.getMaterialWeight()); parent.setUnitWeight(vo.getMaterialWeight());
parent.setMaterialName(vo.getMaterialName()); parent.setMaterialName(vo.getMaterialName());
parent.setMaterialTexture(vo.getMaterialTexture()); parent.setMaterialTexture(vo.getMaterialTexture());
parent.setMaterialUnit(vo.getMaterialUnit()); if (StrUtil.isBlank(data.getParentMaterialDesc())) {
if (StrUtil.isBlank(data.getMaterialDesc())) {
parent.setMaterialDesc(vo.getMaterialDesc()); parent.setMaterialDesc(vo.getMaterialDesc());
} }
parent.setMaterialUnit(vo.getMaterialUnit());
parent.setMaterialOriginalUnit(vo.getMaterialUnit());
} }
parent.setMaterialOriginalUnit(data.getUnit());
parent.setNum(BigDecimal.ONE); parent.setNum(BigDecimal.ONE);
parent.setTotalWeight(null); parent.setTotalWeight(null);
parent.setUserRootIs(0); parent.setUserRootIs(0);
@ -411,7 +413,7 @@ public class EBomImportService {
parent.setExceptionStatus(EBomExceptionStatusEnum.INIT.getValue()); parent.setExceptionStatus(EBomExceptionStatusEnum.INIT.getValue());
parent.setCreatedBy(SessionUtil.getUserCode()); parent.setCreatedBy(SessionUtil.getUserCode());
parent.setRemark(""); parent.setRemark("");
parent.setOrderNumber(data.getOrderNum()); //parent.setOrderNumber(data.getOrderNum());
parent.setDeptName(SessionUtil.getDepartName()); parent.setDeptName(SessionUtil.getDepartName());
parent.setSource(EBomSourceEnum.FROM_EXCE.getValue()); parent.setSource(EBomSourceEnum.FROM_EXCE.getValue());
parent.setSourceRowId(""); parent.setSourceRowId("");

View File

@ -3,10 +3,7 @@ package com.nflg.product.bomnew.service.domain.EBom;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert; import cn.hutool.core.convert.Convert;
import cn.hutool.core.lang.TypeReference; import cn.hutool.core.lang.TypeReference;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.*;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil; import cn.hutool.extra.spring.SpringUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.core.toolkit.IdWorker;
@ -198,7 +195,7 @@ public class EBomEdit {
EBomEdit.checkVirtualPackage(child); EBomEdit.checkVirtualPackage(child);
//新增数据 //新增数据
if (child.getRowId() == null || child.getRowId().longValue() == 0) { if (child.getRowId() == null || child.getRowId() == 0) {
child.setRowId(IdWorker.getId()); child.setRowId(IdWorker.getId());
child.setIdentityNo(StrUtil.join("_", parentEntity.getRowId(), child.getRowId())); child.setIdentityNo(StrUtil.join("_", parentEntity.getRowId(), child.getRowId()));
child.setSource(source); child.setSource(source);
@ -207,7 +204,7 @@ public class EBomEdit {
child.setSourceRowId(""); child.setSourceRowId("");
child.setParentRowId(parentEntity.getRowId()); child.setParentRowId(parentEntity.getRowId());
if(StrUtil.isEmpty(child.getOrderNumber())){ if(StrUtil.isEmpty(child.getOrderNumber())){
child.setOrderNumber("00"); child.setOrderNumber("001");
} }
if (dto.getOpType() == 2) { if (dto.getOpType() == 2) {
child.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue()); child.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue());
@ -218,6 +215,9 @@ public class EBomEdit {
child.setProjectType(child.getProjectType().toUpperCase()); child.setProjectType(child.getProjectType().toUpperCase());
} }
if (StrUtil.equals(BomConstant.PROJECT_TYPE_TEMPORARY, child.getProjectType(), true)) { if (StrUtil.equals(BomConstant.PROJECT_TYPE_TEMPORARY, child.getProjectType(), true)) {
String id = RandomUtil.randomNumbers(9);
child.setMaterialNo(BomConstant.PROJECT_TYPE_TEMPORARY + id);
child.setDrawingNo(BomConstant.PROJECT_TYPE_TEMPORARY + id);
if (StrUtil.isBlank(child.getMaterialUnit())) { if (StrUtil.isBlank(child.getMaterialUnit())) {
child.setMaterialUnit("PC"); child.setMaterialUnit("PC");
} }
@ -228,6 +228,9 @@ public class EBomEdit {
child.setNum(BigDecimal.ONE); child.setNum(BigDecimal.ONE);
} }
} }
if (parentEntity.getMaterialNo().startsWith("31")) {
child.setVirtualPartRootMaterialNo(parentEntity.getMaterialNo());
}
} }