feat(ebom): 31码生成虚拟包添加对油漆包的支持
This commit is contained in:
parent
ec18157276
commit
14ae4b4129
|
|
@ -9,17 +9,19 @@ import lombok.Getter;
|
||||||
public enum VirtualPackageTypeEnum implements ValueEnum<Integer>{
|
public enum VirtualPackageTypeEnum implements ValueEnum<Integer>{
|
||||||
//1-发货包 2-制作包 4-直发包 8-发货前装配包
|
//1-发货包 2-制作包 4-直发包 8-发货前装配包
|
||||||
|
|
||||||
UN_VIRTUAL_PACKAGE(0,"非虚拟包","" ,"", ""),
|
UN_VIRTUAL_PACKAGE(0, "非虚拟包", "", "", "", ""),
|
||||||
DELIVERY_PACKAGE(1,"发货包","发货" ,"201101", ""),
|
DELIVERY_PACKAGE(1, "发货包", "发货", "201101", "", "(发货)"),
|
||||||
MAKING_PACKAGE(2,"制作包","制作","201101",""),
|
MAKING_PACKAGE(2, "制作包", "制作", "201101", "", "(制作)"),
|
||||||
DIRECT_DELIVERY_PACKAGE(4,"直发包","直发","201101","F"),
|
DIRECT_DELIVERY_PACKAGE(4, "直发包", "直发", "201101", "F", "(直发)"),
|
||||||
PRE_ASSEMBLY_PACKAGE(8,"发货前装配包","发货前装配","200601","Z");
|
PRE_ASSEMBLY_PACKAGE(8, "发货前装配包", "发货前装配", "200601", "Z", "(发货前装配)"),
|
||||||
|
PAINT_PACKAGE(16, "油漆包", "油漆包", "201101", "", "");
|
||||||
|
|
||||||
private final Integer value;
|
private final Integer value;
|
||||||
private final String description;
|
private final String description;
|
||||||
private final String conMaterialName;
|
private final String conMaterialName;
|
||||||
private final String materialCategoryCode;
|
private final String materialCategoryCode;
|
||||||
private final String productTypeKey;
|
private final String productTypeKey;
|
||||||
|
private final String findConMaterialName;
|
||||||
|
|
||||||
|
|
||||||
public static Integer getAll(){
|
public static Integer getAll(){
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ import com.nflg.product.bomnew.pojo.dto.AddVirtrualMaterialDTO;
|
||||||
import com.nflg.product.bomnew.pojo.dto.MaterialUpdateBillDTO;
|
import com.nflg.product.bomnew.pojo.dto.MaterialUpdateBillDTO;
|
||||||
import com.nflg.product.bomnew.pojo.entity.BomNewEbomChildEntity;
|
import com.nflg.product.bomnew.pojo.entity.BomNewEbomChildEntity;
|
||||||
import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity;
|
import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity;
|
||||||
|
import com.nflg.product.bomnew.pojo.query.GenerateVirtualPackageItem;
|
||||||
import com.nflg.product.bomnew.pojo.query.GenerateVirtualPackageQuery;
|
import com.nflg.product.bomnew.pojo.query.GenerateVirtualPackageQuery;
|
||||||
import com.nflg.product.bomnew.pojo.vo.ChildListForGenerateVirtualPackageVO;
|
import com.nflg.product.bomnew.pojo.vo.ChildListForGenerateVirtualPackageVO;
|
||||||
import com.nflg.product.bomnew.pojo.vo.MaterialMainVO;
|
import com.nflg.product.bomnew.pojo.vo.MaterialMainVO;
|
||||||
|
|
@ -69,21 +70,29 @@ public class BomNewEbomGenerateVirtualPackageServiceFor31Impl implements IBomNew
|
||||||
List<ChildListForGenerateVirtualPackageVO> olds = ebomParentService.getChildListForGenerateVirtualPackage(root);
|
List<ChildListForGenerateVirtualPackageVO> olds = ebomParentService.getChildListForGenerateVirtualPackage(root);
|
||||||
List<CompletableFuture<Void>> futures = new ArrayList<>();
|
List<CompletableFuture<Void>> futures = new ArrayList<>();
|
||||||
query.getChildren().forEach(it -> {
|
query.getChildren().forEach(it -> {
|
||||||
CompletableFuture<Void> future = CompletableFuture.runAsync(() -> {
|
if (it.getRowId() > 0) {
|
||||||
ChildListForGenerateVirtualPackageVO old = olds.stream().filter(f -> Objects.equals(f.getRowId(), it.getRowId())).findFirst().orElse(null);
|
CompletableFuture<Void> future = CompletableFuture.runAsync(() -> {
|
||||||
VUtils.isTure(Objects.isNull(old)).throwMessage(it.getRowId() + "无效");
|
ChildListForGenerateVirtualPackageVO old = olds.stream().filter(f -> Objects.equals(f.getRowId(), it.getRowId())).findFirst().orElse(null);
|
||||||
BomNewEbomChildEntity child = ebomChildService.getById(it.getRowId());
|
VUtils.isTure(Objects.isNull(old)).throwMessage(it.getRowId() + "无效");
|
||||||
if (it.isGenerate1010() && it.isGenerate1020()) {
|
BomNewEbomChildEntity child = ebomChildService.getById(it.getRowId());
|
||||||
selectedAll(root, child, old);
|
if (it.isGenerate1010() && it.isGenerate1020()) {
|
||||||
} else if (!it.isGenerate1010() && !it.isGenerate1020()) {
|
selectedAll(root, child, old);
|
||||||
cancelAll(root, child, old);
|
} else if (!it.isGenerate1010() && !it.isGenerate1020()) {
|
||||||
} else if (it.isGenerate1010()) {
|
cancelAll(root, child, old);
|
||||||
selected1010Cancel1020(root, child, old);
|
} else if (it.isGenerate1010()) {
|
||||||
} else {
|
selected1010Cancel1020(root, child, old);
|
||||||
selected1020Cancel1010(root, child, old);
|
} else {
|
||||||
}
|
selected1020Cancel1010(root, child, old);
|
||||||
});
|
}
|
||||||
futures.add(future);
|
});
|
||||||
|
futures.add(future);
|
||||||
|
} else {
|
||||||
|
//油漆包
|
||||||
|
CompletableFuture<Void> future = CompletableFuture.runAsync(() -> {
|
||||||
|
buildPaintVirtualPackage(it, root, query);
|
||||||
|
});
|
||||||
|
futures.add(future);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
CompletableFuture<Void> combinedFuture = CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]));
|
CompletableFuture<Void> combinedFuture = CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]));
|
||||||
combinedFuture.join();
|
combinedFuture.join();
|
||||||
|
|
@ -119,6 +128,39 @@ public class BomNewEbomGenerateVirtualPackageServiceFor31Impl implements IBomNew
|
||||||
return errorMsgList;
|
return errorMsgList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void buildPaintVirtualPackage(GenerateVirtualPackageItem it, BomNewEbomParentEntity root, GenerateVirtualPackageQuery query) {
|
||||||
|
if (it.isGenerate1010()) {
|
||||||
|
BomNewEbomChildEntity xc1 = buildVirtualPackage(false, root.getRowId(), root
|
||||||
|
, root.getMaterialName(), VirtualPackageTypeEnum.PAINT_PACKAGE
|
||||||
|
, StrUtil.padPre(String.valueOf(query.getChildren().size()), 3, '0'));
|
||||||
|
buildVirtualPackage(root, xc1);
|
||||||
|
}
|
||||||
|
if (it.isGenerate1020()) {
|
||||||
|
BomNewEbomChildEntity xc1 = buildVirtualPackage(true, root.getRowId(), root
|
||||||
|
, root.getMaterialName(), VirtualPackageTypeEnum.PAINT_PACKAGE
|
||||||
|
, StrUtil.padPre(String.valueOf(query.getChildren().size() + 1), 3, '0'));
|
||||||
|
buildVirtualPackage(root, xc1);
|
||||||
|
}
|
||||||
|
if (!it.isGenerate1010() || !it.isGenerate1020()) {
|
||||||
|
List<BomNewEbomChildEntity> cs = ebomChildService.lambdaQuery()
|
||||||
|
.eq(BomNewEbomChildEntity::getParentRowId, root.getRowId())
|
||||||
|
.eq(BomNewEbomChildEntity::getVirtualPartType, VirtualPackageTypeEnum.PAINT_PACKAGE.getValue())
|
||||||
|
.list();
|
||||||
|
if (!it.isGenerate1010()) {
|
||||||
|
BomNewEbomChildEntity c = cs.stream().filter(f -> !f.getDrawingNo().contains("仙桃")).findFirst().orElse(null);
|
||||||
|
if (Objects.nonNull(c)) {
|
||||||
|
childRowIdsForDel.add(c.getRowId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!it.isGenerate1020()) {
|
||||||
|
BomNewEbomChildEntity c = cs.stream().filter(f -> f.getDrawingNo().contains("仙桃")).findFirst().orElse(null);
|
||||||
|
if (Objects.nonNull(c)) {
|
||||||
|
childRowIdsForDel.add(c.getRowId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void save() {
|
public void save() {
|
||||||
if (CollUtil.isNotEmpty(childRowIdsForDel)) {
|
if (CollUtil.isNotEmpty(childRowIdsForDel)) {
|
||||||
|
|
@ -176,7 +218,7 @@ public class BomNewEbomGenerateVirtualPackageServiceFor31Impl implements IBomNew
|
||||||
.lt(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue())
|
.lt(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue())
|
||||||
.one();
|
.one();
|
||||||
if (Objects.nonNull(fp)) {
|
if (Objects.nonNull(fp)) {
|
||||||
buildVirtualPackage(true, root.getRowId(), root, child, VirtualPackageTypeEnum.DELIVERY_PACKAGE, child.getOrderNumber());
|
buildVirtualPackage(true, root.getRowId(), root, child.getMaterialName(), VirtualPackageTypeEnum.DELIVERY_PACKAGE, child.getOrderNumber());
|
||||||
String dnMaking = buildDrawingNo(root.getDrawingNo(), child.getMaterialName(), VirtualPackageTypeEnum.MAKING_PACKAGE, true);
|
String dnMaking = buildDrawingNo(root.getDrawingNo(), child.getMaterialName(), VirtualPackageTypeEnum.MAKING_PACKAGE, true);
|
||||||
BomNewEbomParentEntity zp = ebomParentService.lambdaQuery()
|
BomNewEbomParentEntity zp = ebomParentService.lambdaQuery()
|
||||||
.eq(BomNewEbomParentEntity::getDrawingNo, dnMaking)
|
.eq(BomNewEbomParentEntity::getDrawingNo, dnMaking)
|
||||||
|
|
@ -288,7 +330,7 @@ public class BomNewEbomGenerateVirtualPackageServiceFor31Impl implements IBomNew
|
||||||
.lt(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue())
|
.lt(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue())
|
||||||
.one();
|
.one();
|
||||||
if (Objects.nonNull(fp)) {
|
if (Objects.nonNull(fp)) {
|
||||||
buildVirtualPackage(true, root.getRowId(), root, child, VirtualPackageTypeEnum.DELIVERY_PACKAGE, child.getOrderNumber());
|
buildVirtualPackage(true, root.getRowId(), root, child.getMaterialName(), VirtualPackageTypeEnum.DELIVERY_PACKAGE, child.getOrderNumber());
|
||||||
String dnMaking = buildDrawingNo(root.getDrawingNo(), child.getMaterialName(), VirtualPackageTypeEnum.MAKING_PACKAGE, false);
|
String dnMaking = buildDrawingNo(root.getDrawingNo(), child.getMaterialName(), VirtualPackageTypeEnum.MAKING_PACKAGE, false);
|
||||||
BomNewEbomParentEntity zp = ebomParentService.lambdaQuery()
|
BomNewEbomParentEntity zp = ebomParentService.lambdaQuery()
|
||||||
.eq(BomNewEbomParentEntity::getDrawingNo, dnMaking)
|
.eq(BomNewEbomParentEntity::getDrawingNo, dnMaking)
|
||||||
|
|
@ -329,25 +371,25 @@ public class BomNewEbomGenerateVirtualPackageServiceFor31Impl implements IBomNew
|
||||||
|
|
||||||
private void build1010VirtualPackage(BomNewEbomParentEntity root, BomNewEbomChildEntity child) {
|
private void build1010VirtualPackage(BomNewEbomParentEntity root, BomNewEbomChildEntity child) {
|
||||||
//发货包
|
//发货包
|
||||||
BomNewEbomChildEntity qc1 = buildVirtualPackage(false, root.getRowId(), root, child, VirtualPackageTypeEnum.DELIVERY_PACKAGE, child.getOrderNumber());
|
BomNewEbomChildEntity qc1 = buildVirtualPackage(false, root.getRowId(), root, child.getMaterialName(), VirtualPackageTypeEnum.DELIVERY_PACKAGE, child.getOrderNumber());
|
||||||
BomNewEbomParentEntity qp1 = buildVirtualPackage(root, qc1);
|
BomNewEbomParentEntity qp1 = buildVirtualPackage(root, qc1);
|
||||||
//制作包
|
//制作包
|
||||||
BomNewEbomChildEntity qc2 = buildVirtualPackage(false, qp1.getRowId(), root, child, VirtualPackageTypeEnum.MAKING_PACKAGE, "001");
|
BomNewEbomChildEntity qc2 = buildVirtualPackage(false, qp1.getRowId(), root, child.getMaterialName(), VirtualPackageTypeEnum.MAKING_PACKAGE, "001");
|
||||||
BomNewEbomParentEntity qp2 = buildVirtualPackage(qp1, qc2);
|
BomNewEbomParentEntity qp2 = buildVirtualPackage(qp1, qc2);
|
||||||
child.setParentRowId(qp2.getRowId());
|
child.setParentRowId(qp2.getRowId());
|
||||||
child.setModifyTime(LocalDateTime.now());
|
child.setModifyTime(LocalDateTime.now());
|
||||||
childrenForUpdate.add(child);
|
childrenForUpdate.add(child);
|
||||||
//直发包
|
//直发包
|
||||||
BomNewEbomChildEntity qc3 = buildVirtualPackage(false, qp1.getRowId(), root, child, VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE, "002");
|
BomNewEbomChildEntity qc3 = buildVirtualPackage(false, qp1.getRowId(), root, child.getMaterialName(), VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE, "002");
|
||||||
buildVirtualPackage(qp1, qc3);
|
buildVirtualPackage(qp1, qc3);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void build1020VirtualPackage(BomNewEbomParentEntity root, boolean mount, BomNewEbomChildEntity child) {
|
private void build1020VirtualPackage(BomNewEbomParentEntity root, boolean mount, BomNewEbomChildEntity child) {
|
||||||
//发货包
|
//发货包
|
||||||
BomNewEbomChildEntity xc1 = buildVirtualPackage(true, root.getRowId(), root, child, VirtualPackageTypeEnum.DELIVERY_PACKAGE, child.getOrderNumber());
|
BomNewEbomChildEntity xc1 = buildVirtualPackage(true, root.getRowId(), root, child.getMaterialName(), VirtualPackageTypeEnum.DELIVERY_PACKAGE, child.getOrderNumber());
|
||||||
BomNewEbomParentEntity xp1 = buildVirtualPackage(root, xc1);
|
BomNewEbomParentEntity xp1 = buildVirtualPackage(root, xc1);
|
||||||
//制作包
|
//制作包
|
||||||
BomNewEbomChildEntity xc2 = buildVirtualPackage(true, xp1.getRowId(), root, child, VirtualPackageTypeEnum.MAKING_PACKAGE, "001");
|
BomNewEbomChildEntity xc2 = buildVirtualPackage(true, xp1.getRowId(), root, child.getMaterialName(), VirtualPackageTypeEnum.MAKING_PACKAGE, "001");
|
||||||
BomNewEbomParentEntity xp2 = buildVirtualPackage(xp1, xc2);
|
BomNewEbomParentEntity xp2 = buildVirtualPackage(xp1, xc2);
|
||||||
if (mount) {
|
if (mount) {
|
||||||
child.setParentRowId(xp2.getRowId());
|
child.setParentRowId(xp2.getRowId());
|
||||||
|
|
@ -355,7 +397,7 @@ public class BomNewEbomGenerateVirtualPackageServiceFor31Impl implements IBomNew
|
||||||
childrenForUpdate.add(child);
|
childrenForUpdate.add(child);
|
||||||
}
|
}
|
||||||
//直发包
|
//直发包
|
||||||
BomNewEbomChildEntity xc3 = buildVirtualPackage(true, xp1.getRowId(), root, child, VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE, "002");
|
BomNewEbomChildEntity xc3 = buildVirtualPackage(true, xp1.getRowId(), root, child.getMaterialName(), VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE, "002");
|
||||||
buildVirtualPackage(xp1, xc3);
|
buildVirtualPackage(xp1, xc3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -452,8 +494,8 @@ public class BomNewEbomGenerateVirtualPackageServiceFor31Impl implements IBomNew
|
||||||
}
|
}
|
||||||
|
|
||||||
private BomNewEbomChildEntity buildVirtualPackage(boolean is1020Factory, Long parentRowId, BomNewEbomParentEntity root
|
private BomNewEbomChildEntity buildVirtualPackage(boolean is1020Factory, Long parentRowId, BomNewEbomParentEntity root
|
||||||
, BomNewEbomChildEntity material, VirtualPackageTypeEnum type, String orderNo) {
|
, String materialName, VirtualPackageTypeEnum type, String orderNo) {
|
||||||
String drawingNo = buildDrawingNo(root.getDrawingNo(), material.getMaterialName(), type, is1020Factory);
|
String drawingNo = buildDrawingNo(root.getDrawingNo(), materialName, type, is1020Factory);
|
||||||
BomNewEbomChildEntity child = ebomChildService.lambdaQuery()
|
BomNewEbomChildEntity child = ebomChildService.lambdaQuery()
|
||||||
.eq(BomNewEbomChildEntity::getParentRowId, parentRowId)
|
.eq(BomNewEbomChildEntity::getParentRowId, parentRowId)
|
||||||
.eq(BomNewEbomChildEntity::getDrawingNo, drawingNo)
|
.eq(BomNewEbomChildEntity::getDrawingNo, drawingNo)
|
||||||
|
|
|
||||||
|
|
@ -952,7 +952,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
||||||
public List<OperationErrorMsgVO> importToSAP(Long rootBomRowId) {
|
public List<OperationErrorMsgVO> importToSAP(Long rootBomRowId) {
|
||||||
BomNewEbomParentEntity root = this.getById(rootBomRowId);
|
BomNewEbomParentEntity root = this.getById(rootBomRowId);
|
||||||
VUtils.isTure(Objects.isNull(root)).throwMessage("数据不存在");
|
VUtils.isTure(Objects.isNull(root)).throwMessage("数据不存在");
|
||||||
VUtils.isTure(root.getRootIs() != 1).throwMessage("请选择根节点");
|
//VUtils.isTure(root.getRootIs() != 1).throwMessage("请选择根节点");
|
||||||
VUtils.isTure(Objects.equals(root.getSapState(), SapStatusEnum.PUB_RUNNING.getValue()))
|
VUtils.isTure(Objects.equals(root.getSapState(), SapStatusEnum.PUB_RUNNING.getValue()))
|
||||||
.throwMessage("正在导入中,请等待操作完成");
|
.throwMessage("正在导入中,请等待操作完成");
|
||||||
|
|
||||||
|
|
@ -2502,6 +2502,30 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
||||||
}
|
}
|
||||||
cvos.add(cvo);
|
cvos.add(cvo);
|
||||||
});
|
});
|
||||||
|
//油漆包
|
||||||
|
List<BomNewEbomChildEntity> paintPackages = ebomChildService.lambdaQuery()
|
||||||
|
.eq(BomNewEbomChildEntity::getParentRowId, parent.getRowId())
|
||||||
|
.eq(BomNewEbomChildEntity::getVirtualPartType, VirtualPackageTypeEnum.PAINT_PACKAGE.getValue())
|
||||||
|
.list();
|
||||||
|
ChildListForGenerateVirtualPackageVO vo = new ChildListForGenerateVirtualPackageVO();
|
||||||
|
vo.setRowId(0L);
|
||||||
|
vo.setOrderNumber(StrUtil.padPre(String.valueOf(children.size() + 1), 3, '0'));
|
||||||
|
vo.setMaterialDesc(VirtualPackageTypeEnum.PAINT_PACKAGE.getConMaterialName());
|
||||||
|
if (CollUtil.isEmpty(paintPackages)) {
|
||||||
|
vo.setHasGenerated1010(false);
|
||||||
|
vo.setHasGenerated1020(false);
|
||||||
|
} else if (paintPackages.size() >= 2) {
|
||||||
|
vo.setHasGenerated1010(true);
|
||||||
|
vo.setHasGenerated1020(true);
|
||||||
|
} else if (paintPackages.stream().anyMatch(p -> p.getDrawingNo().contains("仙桃"))) {
|
||||||
|
vo.setHasGenerated1010(false);
|
||||||
|
vo.setHasGenerated1020(true);
|
||||||
|
} else {
|
||||||
|
vo.setHasGenerated1010(true);
|
||||||
|
vo.setHasGenerated1020(false);
|
||||||
|
}
|
||||||
|
cvos.add(vo);
|
||||||
|
|
||||||
return cvos;
|
return cvos;
|
||||||
}
|
}
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue