fix(ebom): 优化从excel导入
This commit is contained in:
parent
1da8f1f7bb
commit
cb8c71bca6
|
|
@ -105,16 +105,32 @@ public class BomNewEbomGenerateVirtualPackageServiceFor31Impl implements IBomNew
|
||||||
|
|
||||||
private void selected1020Cancel1010(BomNewEbomParentEntity root, BomNewEbomChildEntity child, ChildListForGenerateVirtualPackageVO old) {
|
private void selected1020Cancel1010(BomNewEbomParentEntity root, BomNewEbomChildEntity child, ChildListForGenerateVirtualPackageVO old) {
|
||||||
if (old.isHasGenerated1010()) {
|
if (old.isHasGenerated1010()) {
|
||||||
buildDelDeliveryVirtualPackage(root, child, false);
|
buildDelVirtualPackage(root, child, false);
|
||||||
}
|
}
|
||||||
if (!old.isHasGenerated1020()) {
|
if (!old.isHasGenerated1020()) {
|
||||||
build1020VirtualPackage(root, true, child);
|
build1020VirtualPackage(root, true, child);
|
||||||
|
} else {
|
||||||
|
String dnMaking = buildDrawingNo(root.getDrawingNo(), child.getMaterialName(), VirtualPackageTypeEnum.MAKING_PACKAGE, true);
|
||||||
|
BomNewEbomParentEntity p = ebomParentService.lambdaQuery()
|
||||||
|
.eq(BomNewEbomParentEntity::getDrawingNo, dnMaking)
|
||||||
|
.one();
|
||||||
|
if (Objects.isNull(p)) {
|
||||||
|
BomNewEbomChildEntity c = ebomChildService.lambdaQuery()
|
||||||
|
.eq(BomNewEbomChildEntity::getDrawingNo, dnMaking)
|
||||||
|
.one();
|
||||||
|
p = buildVirtualPackage(ebomParentService.lambdaQuery()
|
||||||
|
.eq(BomNewEbomParentEntity::getDrawingNo, buildDrawingNo(root.getDrawingNo(), child.getMaterialName(), VirtualPackageTypeEnum.DELIVERY_PACKAGE, true))
|
||||||
|
.one(), c);
|
||||||
|
}
|
||||||
|
child.setParentRowId(p.getRowId());
|
||||||
|
child.setModifyTime(LocalDateTime.now());
|
||||||
|
children.add(child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void selected1010Cancel1020(BomNewEbomParentEntity root, BomNewEbomChildEntity child, ChildListForGenerateVirtualPackageVO old) {
|
private void selected1010Cancel1020(BomNewEbomParentEntity root, BomNewEbomChildEntity child, ChildListForGenerateVirtualPackageVO old) {
|
||||||
if (old.isHasGenerated1020()) {
|
if (old.isHasGenerated1020()) {
|
||||||
buildDelDeliveryVirtualPackage(root, child, true);
|
buildDelVirtualPackage(root, child, true);
|
||||||
}
|
}
|
||||||
if (!old.isHasGenerated1010()) {
|
if (!old.isHasGenerated1010()) {
|
||||||
build1010VirtualPackage(root, child);
|
build1010VirtualPackage(root, child);
|
||||||
|
|
@ -168,28 +184,33 @@ public class BomNewEbomGenerateVirtualPackageServiceFor31Impl implements IBomNew
|
||||||
child.setModifyTime(LocalDateTime.now());
|
child.setModifyTime(LocalDateTime.now());
|
||||||
children.add(child);
|
children.add(child);
|
||||||
if (old.isHasGenerated1010()) {
|
if (old.isHasGenerated1010()) {
|
||||||
buildDelDeliveryVirtualPackage(root, child, false);
|
buildDelVirtualPackage(root, child, false);
|
||||||
}
|
}
|
||||||
if (old.isHasGenerated1020()) {
|
if (old.isHasGenerated1020()) {
|
||||||
buildDelDeliveryVirtualPackage(root, child, true);
|
buildDelVirtualPackage(root, child, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// private void buildDelAllVirtualPackage(BomNewEbomParentEntity root, BomNewEbomChildEntity child, boolean is1020Factory) {
|
||||||
|
// buildDelVirtualPackage(root, child, VirtualPackageTypeEnum.DELIVERY_PACKAGE, is1020Factory);
|
||||||
|
// buildDelVirtualPackage(root, child, VirtualPackageTypeEnum.MAKING_PACKAGE, is1020Factory);
|
||||||
|
// buildDelVirtualPackage(root, child, VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE, is1020Factory);
|
||||||
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除发货包
|
* 删除发货包
|
||||||
* @param root 根节点
|
* @param root 根节点
|
||||||
* @param child 物料
|
* @param child 物料
|
||||||
* @param is1020Factory 是否是仙桃工厂
|
* @param is1020Factory 是否是仙桃工厂
|
||||||
*/
|
*/
|
||||||
private void buildDelDeliveryVirtualPackage(BomNewEbomParentEntity root, BomNewEbomChildEntity child, boolean is1020Factory) {
|
private void buildDelVirtualPackage(BomNewEbomParentEntity root, BomNewEbomChildEntity child, boolean is1020Factory) {
|
||||||
//发货包
|
|
||||||
String drawingNo = buildDrawingNo(root.getDrawingNo(), child.getMaterialName(), VirtualPackageTypeEnum.DELIVERY_PACKAGE, is1020Factory);
|
String drawingNo = buildDrawingNo(root.getDrawingNo(), child.getMaterialName(), VirtualPackageTypeEnum.DELIVERY_PACKAGE, is1020Factory);
|
||||||
BomNewEbomChildEntity c = ebomChildService.lambdaQuery()
|
BomNewEbomChildEntity c = ebomChildService.lambdaQuery()
|
||||||
.eq(BomNewEbomChildEntity::getParentRowId, root.getRowId())
|
.eq(BomNewEbomChildEntity::getParentRowId, root.getRowId())
|
||||||
.eq(BomNewEbomChildEntity::getDrawingNo, drawingNo)
|
.eq(BomNewEbomChildEntity::getDrawingNo, drawingNo)
|
||||||
.one();
|
.one();
|
||||||
if (Objects.isNull(c)) {
|
if (Objects.isNull(c)) {
|
||||||
LOGGER.error("{}应有发货包“{}”但未找到", root.getMaterialNo(), drawingNo);
|
LOGGER.error("{}应有{}“{}”但未找到", root.getMaterialNo(), VirtualPackageTypeEnum.DELIVERY_PACKAGE.getDescription(), drawingNo);
|
||||||
} else {
|
} else {
|
||||||
childRowIdsForDel.add(c.getRowId());
|
childRowIdsForDel.add(c.getRowId());
|
||||||
}
|
}
|
||||||
|
|
@ -224,26 +245,39 @@ 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) {
|
, BomNewEbomChildEntity material, VirtualPackageTypeEnum type, String orderNo) {
|
||||||
BomNewEbomChildEntity child = new BomNewEbomChildEntity();
|
String drawingNo = buildDrawingNo(root.getDrawingNo(), material.getMaterialName(), type, is1020Factory);
|
||||||
child.setRowId(IdWorker.getId());
|
BomNewEbomChildEntity child = ebomChildService.lambdaQuery()
|
||||||
child.setParentRowId(parentRowId);
|
.eq(BomNewEbomChildEntity::getParentRowId, parentRowId)
|
||||||
child.setIdentityNo(parentRowId + "_" + child.getRowId());
|
.eq(BomNewEbomChildEntity::getDrawingNo, drawingNo)
|
||||||
child.setOrderNumber(orderNo);
|
.one();
|
||||||
child.setNum(new BigDecimal(1));
|
if (Objects.isNull(child)) {
|
||||||
child.setEditStatus(root.getEditStatus());
|
child = new BomNewEbomChildEntity();
|
||||||
child.setSource(EBomSourceEnum.FROM_MDM.getValue());
|
child.setRowId(IdWorker.getId());
|
||||||
child.setVirtualPartType(type.getValue());
|
BomNewEbomParentEntity p = ebomParentService.lambdaQuery()
|
||||||
child.setProjectType("L");
|
.eq(BomNewEbomParentEntity::getDrawingNo, drawingNo)
|
||||||
child.setProjectTypeInputType(ProjectTypeInputTypeEnum.MANUAL_INPUT.getValue());
|
.one();
|
||||||
child.setMaterialUnit("PC");
|
if (Objects.nonNull(p)) {
|
||||||
child.setMaterialOriginalUnit("PC");
|
child.setMaterialNo(p.getMaterialNo());
|
||||||
//child.setVirtualPartRootMaterialNo(rootMaterialNo);
|
}
|
||||||
child.setCreatedBy(SessionUtil.getUserCode());
|
child.setParentRowId(parentRowId);
|
||||||
child.setDrawingNo(buildDrawingNo(root.getDrawingNo(), material.getMaterialName(), type, is1020Factory));
|
child.setIdentityNo(parentRowId + "_" + child.getRowId());
|
||||||
child.setMaterialDesc(child.getDrawingNo());
|
child.setOrderNumber(orderNo);
|
||||||
child.setMaterialName(child.getDrawingNo());
|
child.setNum(new BigDecimal(1));
|
||||||
child.setMaterialCategoryCode(type.getMaterialCategoryCode());
|
child.setEditStatus(root.getEditStatus());
|
||||||
children.add(child);
|
child.setSource(EBomSourceEnum.FROM_MDM.getValue());
|
||||||
|
child.setVirtualPartType(type.getValue());
|
||||||
|
child.setProjectType("L");
|
||||||
|
child.setProjectTypeInputType(ProjectTypeInputTypeEnum.MANUAL_INPUT.getValue());
|
||||||
|
child.setMaterialUnit("PC");
|
||||||
|
child.setMaterialOriginalUnit("PC");
|
||||||
|
child.setCreatedBy(SessionUtil.getUserCode());
|
||||||
|
child.setDrawingNo(drawingNo);
|
||||||
|
child.setMaterialDesc(child.getDrawingNo());
|
||||||
|
child.setMaterialName(child.getDrawingNo());
|
||||||
|
child.setMaterialCategoryCode(type.getMaterialCategoryCode());
|
||||||
|
child.setVirtualPartRootMaterialNo(root.getMaterialNo());
|
||||||
|
children.add(child);
|
||||||
|
}
|
||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2373,6 +2373,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
||||||
public List<ChildListForGenerateVirtualPackageVO> getChildListForGenerateVirtualPackage(BomNewEbomParentEntity parent) {
|
public List<ChildListForGenerateVirtualPackageVO> getChildListForGenerateVirtualPackage(BomNewEbomParentEntity parent) {
|
||||||
List<BomNewEbomChildEntity> children = ebomChildService.lambdaQuery()
|
List<BomNewEbomChildEntity> children = ebomChildService.lambdaQuery()
|
||||||
.eq(BomNewEbomChildEntity::getVirtualPartRootMaterialNo, parent.getMaterialNo())
|
.eq(BomNewEbomChildEntity::getVirtualPartRootMaterialNo, parent.getMaterialNo())
|
||||||
|
.eq(BomNewEbomChildEntity::getVirtualPartType, VirtualPackageTypeEnum.UN_VIRTUAL_PACKAGE.getValue())
|
||||||
.ne(BomNewEbomChildEntity::getProjectType, BomConstant.PROJECT_TYPE_TEMPORARY)
|
.ne(BomNewEbomChildEntity::getProjectType, BomConstant.PROJECT_TYPE_TEMPORARY)
|
||||||
.orderByAsc(BomNewEbomChildEntity::getOrderNumber)
|
.orderByAsc(BomNewEbomChildEntity::getOrderNumber)
|
||||||
.list();
|
.list();
|
||||||
|
|
|
||||||
|
|
@ -70,13 +70,18 @@ public class EBomImportService {
|
||||||
}
|
}
|
||||||
|
|
||||||
Pair<List<BomNewEbomParentEntity>, List<BomNewEbomChildEntity>> pcs = convertToBom(datas);
|
Pair<List<BomNewEbomParentEntity>, List<BomNewEbomChildEntity>> pcs = convertToBom(datas);
|
||||||
VUtils.isTure(checkInconsistentData(pcs.getLeft().get(0), pcs.getLeft(), pcs.getRight()))
|
VUtils.isTure(checkInconsistentData(pcs.getLeft().get(0), pcs.getLeft(), pcs.getRight())).throwMessage("导入的数据已存在,请勿重复导入");
|
||||||
.throwMessage("导入的数据已存在,请勿重复导入");
|
|
||||||
|
|
||||||
save(pcs.getLeft(), pcs.getRight());
|
save(pcs.getLeft(), pcs.getRight());
|
||||||
|
|
||||||
bomNewEbomParentService.resetAllBomExist();
|
bomNewEbomParentService.resetAllBomExist();
|
||||||
|
|
||||||
|
bomNewEbomParentService.batchCheckAndSaveEBomException(pcs.getLeft().stream()
|
||||||
|
.filter(p -> p.getRootIs() == 1)
|
||||||
|
.map(BomNewEbomParentEntity::getRowId)
|
||||||
|
.collect(Collectors.toList())
|
||||||
|
);
|
||||||
|
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
} finally {
|
} finally {
|
||||||
excelContextTL.remove();
|
excelContextTL.remove();
|
||||||
|
|
@ -87,14 +92,10 @@ public class EBomImportService {
|
||||||
public void save(List<BomNewEbomParentEntity> parents, List<BomNewEbomChildEntity> children) {
|
public void save(List<BomNewEbomParentEntity> parents, List<BomNewEbomChildEntity> children) {
|
||||||
Set<String> pMaterialNos = parents.stream().map(BomNewEbomParentEntity::getMaterialNo).collect(Collectors.toSet());
|
Set<String> pMaterialNos = parents.stream().map(BomNewEbomParentEntity::getMaterialNo).collect(Collectors.toSet());
|
||||||
List<BomNewEbomParentEntity> oldParents = bomNewEbomParentService.getLatestByMaterialNo(pMaterialNos);
|
List<BomNewEbomParentEntity> oldParents = bomNewEbomParentService.getLatestByMaterialNo(pMaterialNos);
|
||||||
parents.forEach(p -> {
|
oldParents.forEach(p -> {
|
||||||
BomNewEbomParentEntity oldParent = oldParents.stream()
|
if (!Objects.equals(p.getStatus(), EBomStatusEnum.PUBLISHED.getValue())) {
|
||||||
.filter(op -> op.getMaterialNo().equals(p.getMaterialNo()))
|
bomNewEbomParentService.getBaseMapper().deleteById(p.getRowId());
|
||||||
.findFirst()
|
bomNewEbomChildService.deleteAllChildren(p.getRowId());
|
||||||
.orElse(null);
|
|
||||||
if (!Objects.isNull(oldParent) && !Objects.equals(oldParent.getStatus(), EBomStatusEnum.PUBLISHED.getValue())) {
|
|
||||||
bomNewEbomParentService.getBaseMapper().deleteById(oldParent.getRowId());
|
|
||||||
bomNewEbomChildService.deleteAllChildren(oldParent.getRowId());
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
bomNewEbomParentService.setLastVersionIs0(pMaterialNos);
|
bomNewEbomParentService.setLastVersionIs0(pMaterialNos);
|
||||||
|
|
@ -108,7 +109,15 @@ public class EBomImportService {
|
||||||
BomNewEbomParentEntity oldParent = bomNewEbomParentService.getLatestByMaterialNo(parent.getMaterialNo());
|
BomNewEbomParentEntity oldParent = bomNewEbomParentService.getLatestByMaterialNo(parent.getMaterialNo());
|
||||||
boolean isSame = true;
|
boolean isSame = true;
|
||||||
if (Objects.isNull(oldParent)) {
|
if (Objects.isNull(oldParent)) {
|
||||||
return false;
|
List<BomNewEbomChildEntity> cc = children.stream()
|
||||||
|
.filter(c -> c.getParentRowId().equals(parent.getRowId()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
for (BomNewEbomChildEntity ccc : cc) {
|
||||||
|
if (!checkInconsistentData(parent.getRowId(), ccc, parents, children)) {
|
||||||
|
isSame = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return isSame;
|
||||||
}
|
}
|
||||||
isSame = Objects.equals(parent.getMaterialUnit(), oldParent.getMaterialUnit())
|
isSame = Objects.equals(parent.getMaterialUnit(), oldParent.getMaterialUnit())
|
||||||
&& NumberUtil.equals(parent.getNum(), oldParent.getNum())
|
&& NumberUtil.equals(parent.getNum(), oldParent.getNum())
|
||||||
|
|
@ -205,6 +214,12 @@ public class EBomImportService {
|
||||||
String id = RandomUtil.randomNumbers(9);
|
String id = RandomUtil.randomNumbers(9);
|
||||||
dto.setMaterialNo(BomConstant.PROJECT_TYPE_TEMPORARY + id);
|
dto.setMaterialNo(BomConstant.PROJECT_TYPE_TEMPORARY + id);
|
||||||
dto.setDrawingNo(BomConstant.PROJECT_TYPE_TEMPORARY + id);
|
dto.setDrawingNo(BomConstant.PROJECT_TYPE_TEMPORARY + id);
|
||||||
|
if (Objects.isNull(dto.getNum())) {
|
||||||
|
dto.setNum(BigDecimal.ONE);
|
||||||
|
}
|
||||||
|
if (Objects.isNull(dto.getUnit())) {
|
||||||
|
dto.setUnit("PC");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
excelContextTL.get().add(dto);
|
excelContextTL.get().add(dto);
|
||||||
|
|
@ -260,6 +275,15 @@ public class EBomImportService {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
numError = datas.stream().filter(u -> StrUtil.equals(u.getMaterialNo(), u.getParentMaterialNo()))
|
||||||
|
.map(BaseImportExcelDTO::getRowNum)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
if (!numError.isEmpty()) {
|
||||||
|
errorMsg.addAll(numError.stream().map(n -> OperationErrorMsgVO.create("第" + n + "行", "项目物料与抬头物料相同"))
|
||||||
|
.collect(Collectors.toList())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return errorMsg;
|
return errorMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -336,6 +360,7 @@ public class EBomImportService {
|
||||||
BomNewEbomParentEntity parent = new BomNewEbomParentEntity();
|
BomNewEbomParentEntity parent = new BomNewEbomParentEntity();
|
||||||
parent.setRowId(IdWorker.getId());
|
parent.setRowId(IdWorker.getId());
|
||||||
|
|
||||||
|
parent.setCurrentVersion(OriginalConstant.DEFAULT_BOM_VERSION);
|
||||||
parent.setMaterialNo(data.getMaterialNo());
|
parent.setMaterialNo(data.getMaterialNo());
|
||||||
parent.setMaterialDesc(data.getMaterialDesc());
|
parent.setMaterialDesc(data.getMaterialDesc());
|
||||||
BaseMaterialVO vo = materialBaseInfos.stream()
|
BaseMaterialVO vo = materialBaseInfos.stream()
|
||||||
|
|
@ -355,7 +380,6 @@ public class EBomImportService {
|
||||||
parent.setMaterialOriginalUnit(data.getUnit());
|
parent.setMaterialOriginalUnit(data.getUnit());
|
||||||
parent.setNum(data.getNum());
|
parent.setNum(data.getNum());
|
||||||
parent.setTotalWeight(BomUtil.calculateTotalWeight(parent.getNum(), parent.getUnitWeight()));
|
parent.setTotalWeight(BomUtil.calculateTotalWeight(parent.getNum(), parent.getUnitWeight()));
|
||||||
parent.setCurrentVersion(OriginalConstant.DEFAULT_BOM_VERSION);
|
|
||||||
parent.setUserRootIs(0);
|
parent.setUserRootIs(0);
|
||||||
parent.setRootIs(0);
|
parent.setRootIs(0);
|
||||||
if (userRoleService.technician()) {
|
if (userRoleService.technician()) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue