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

View File

@ -336,7 +336,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
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)) {
List<String> materialNos = parentChild.stream().map(BaseMaterialVO::getMaterialNo).filter(StrUtil::isNotBlank).collect(Collectors.toList());
if (CollUtil.isNotEmpty(materialNos)) {
@ -833,11 +833,22 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
//31 须有虚拟包
List<BomNewEbomParentEntity> parents = this.getBaseMapper().selectBatchIds(paramDto.getBomRowIds());
VUtils.isTure(paramDto.getFacCodes().contains("1020") && parents.stream().anyMatch(u -> u.getMaterialNo().startsWith("31")))
.throwMessage("31码不能生成仙桃(1020)的pbom");
// VUtils.isTure(paramDto.getFacCodes().contains("1020") && parents.stream().anyMatch(u -> u.getMaterialNo().startsWith("31")))
// .throwMessage("31码不能生成仙桃(1020)的pbom");
VUtils.isTure(parents.stream().anyMatch(u -> u.getMaterialNo().startsWith("31") && u.getVirtrualPackageEnum() <= 0))
.throwMessage("31码须有虚拟包");
// VUtils.isTure(parents.stream().anyMatch(u -> u.getMaterialNo().startsWith("31") && u.getVirtrualPackageEnum() <= 0))
// .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
for (BomNewEbomParentEntity parent : parents){
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.setParentRowId(0L);
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();
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())
// .eq(PBomStatusEnum.PUBLISH.equalsValue(parent.getStatus()),BomNewPbomParentEntity::getStatus, PBomStatusEnum.PUBLISH.getValue())
.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();
Map<String, BomNewPbomParentEntity> bomListMap= list.parallelStream()

View File

@ -1,7 +1,6 @@
package com.nflg.product.bomnew.service;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
@ -305,33 +304,26 @@ public class EBomImportService {
parent = parents.stream().filter(p -> p.getMaterialNo().equals(data.getParentMaterialNo()))
.findFirst()
.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 (datas.stream().noneMatch(d -> d.getMaterialNo().equals(data.getParentMaterialNo()))) {
parents.add(buildRoot(materialBaseInfos, data.getParentMaterialNo(), data.getParentMaterialDesc()));
} else {
parents.add(buildParent(materialBaseInfos, data));
}
}
}
for (EbomExcelDTO data : datas) {
parent = parents.stream().filter(p -> p.getMaterialNo().equals(data.getMaterialNo()))
.findFirst()
.get();
buildChild(children, materialBaseInfos, parent, data
buildChild(children, materialBaseInfos, data
, parents.stream().filter(p -> p.getMaterialNo().equals(data.getParentMaterialNo())).findFirst().get());
}
return Pair.of(parents, children);
}
private void buildChild(List<BomNewEbomChildEntity> children, List<BaseMaterialVO> materialBaseInfos, BomNewEbomParentEntity parent, EbomExcelDTO data, BomNewEbomParentEntity p) {
BomNewEbomChildEntity child = Convert.convert(BomNewEbomChildEntity.class, parent);
private void buildChild(List<BomNewEbomChildEntity> children, List<BaseMaterialVO> materialBaseInfos, EbomExcelDTO data, BomNewEbomParentEntity p) {
BomNewEbomChildEntity child = new BomNewEbomChildEntity();
child.setRowId(IdWorker.getId());
child.setParentRowId(p.getRowId());
parent.setOrderNumber("");
child.setMaterialNo(data.getMaterialNo());
List<BomNewEbomChildEntity> pcs = children.stream()
.filter(c -> Objects.equals(c.getParentRowId(), p.getRowId()))
.collect(Collectors.toList());
@ -341,11 +333,23 @@ public class EBomImportService {
String maxOrderNum = pcs.get(pcs.size() - 1).getOrderNumber();
child.setOrderNumber(OrderNoUtil.next(maxOrderNum));
}
child.setDrawingNo(parent.getDrawingNo());
child.setMaterialDesc(parent.getMaterialDesc());
child.setUnitWeight(parent.getUnitWeight());
child.setMaterialUnit(data.getUnit());
child.setMaterialOriginalUnit(parent.getMaterialOriginalUnit());
child.setMaterialDesc(data.getMaterialDesc());
BaseMaterialVO vo = materialBaseInfos.stream()
.filter(m -> m.getMaterialNo().equals(child.getMaterialNo()))
.findFirst()
.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.setRemark(data.getRemark());
child.setTotalWeight(BomUtil.calculateTotalWeight(child.getNum(), child.getUnitWeight()));
@ -355,13 +359,11 @@ public class EBomImportService {
if (p.getMaterialNo().startsWith("31")) {
child.setVirtualPartRootMaterialNo(p.getMaterialNo());
}
BaseMaterialVO vo = materialBaseInfos.stream()
.filter(m -> m.getMaterialNo().equals(child.getMaterialNo()))
.findFirst()
.orElse(null);
if (!Objects.isNull(vo)) {
child.setMaterialCategoryCode(vo.getMaterialCategoryCode());
}
child.setEditStatus(EbomEditStatusEnum.HANDLER_CREATED.getValue());
child.setExceptionStatus(EBomExceptionStatusEnum.INIT.getValue());
child.setCreatedBy(SessionUtil.getUserCode());
child.setRemark(data.getRemark());
child.setSource(EBomSourceEnum.FROM_EXCE.getValue());
setVirtualPackageType(child);
children.add(child);
}
@ -371,10 +373,10 @@ public class EBomImportService {
parent.setRowId(IdWorker.getId());
parent.setCurrentVersion(OriginalConstant.DEFAULT_BOM_VERSION);
parent.setMaterialNo(data.getMaterialNo());
parent.setMaterialDesc(data.getMaterialDesc());
parent.setMaterialNo(data.getParentMaterialNo());
parent.setMaterialDesc(data.getParentMaterialDesc());
BaseMaterialVO vo = materialBaseInfos.stream()
.filter(m -> m.getMaterialNo().equals(data.getMaterialNo()))
.filter(m -> m.getMaterialNo().equals(data.getParentMaterialNo()))
.findFirst()
.orElse(null);
if (!Objects.isNull(vo)) {
@ -382,12 +384,12 @@ public class EBomImportService {
parent.setUnitWeight(vo.getMaterialWeight());
parent.setMaterialName(vo.getMaterialName());
parent.setMaterialTexture(vo.getMaterialTexture());
parent.setMaterialUnit(vo.getMaterialUnit());
if (StrUtil.isBlank(data.getMaterialDesc())) {
if (StrUtil.isBlank(data.getParentMaterialDesc())) {
parent.setMaterialDesc(vo.getMaterialDesc());
}
parent.setMaterialUnit(vo.getMaterialUnit());
parent.setMaterialOriginalUnit(vo.getMaterialUnit());
}
parent.setMaterialOriginalUnit(data.getUnit());
parent.setNum(BigDecimal.ONE);
parent.setTotalWeight(null);
parent.setUserRootIs(0);
@ -411,7 +413,7 @@ public class EBomImportService {
parent.setExceptionStatus(EBomExceptionStatusEnum.INIT.getValue());
parent.setCreatedBy(SessionUtil.getUserCode());
parent.setRemark("");
parent.setOrderNumber(data.getOrderNum());
//parent.setOrderNumber(data.getOrderNum());
parent.setDeptName(SessionUtil.getDepartName());
parent.setSource(EBomSourceEnum.FROM_EXCE.getValue());
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.convert.Convert;
import cn.hutool.core.lang.TypeReference;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.*;
import cn.hutool.extra.spring.SpringUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
@ -198,7 +195,7 @@ public class EBomEdit {
EBomEdit.checkVirtualPackage(child);
//新增数据
if (child.getRowId() == null || child.getRowId().longValue() == 0) {
if (child.getRowId() == null || child.getRowId() == 0) {
child.setRowId(IdWorker.getId());
child.setIdentityNo(StrUtil.join("_", parentEntity.getRowId(), child.getRowId()));
child.setSource(source);
@ -207,7 +204,7 @@ public class EBomEdit {
child.setSourceRowId("");
child.setParentRowId(parentEntity.getRowId());
if(StrUtil.isEmpty(child.getOrderNumber())){
child.setOrderNumber("00");
child.setOrderNumber("001");
}
if (dto.getOpType() == 2) {
child.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue());
@ -218,6 +215,9 @@ public class EBomEdit {
child.setProjectType(child.getProjectType().toUpperCase());
}
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())) {
child.setMaterialUnit("PC");
}
@ -228,6 +228,9 @@ public class EBomEdit {
child.setNum(BigDecimal.ONE);
}
}
if (parentEntity.getMaterialNo().startsWith("31")) {
child.setVirtualPartRootMaterialNo(parentEntity.getMaterialNo());
}
}