|
|
|
|
@ -4,13 +4,11 @@ import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.convert.Convert;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import cn.hutool.extra.spring.SpringUtil;
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
|
|
import com.nflg.product.base.core.conmon.util.SessionUtil;
|
|
|
|
|
import com.nflg.product.bomnew.client.MaterialMainClient;
|
|
|
|
|
import com.nflg.product.bomnew.constant.EBomSourceEnum;
|
|
|
|
|
import com.nflg.product.bomnew.constant.OriginalConstant;
|
|
|
|
|
import com.nflg.product.bomnew.constant.ProjectTypeInputTypeEnum;
|
|
|
|
|
import com.nflg.product.bomnew.constant.VirtualPackageTypeEnum;
|
|
|
|
|
import com.nflg.product.bomnew.constant.*;
|
|
|
|
|
import com.nflg.product.bomnew.pojo.dto.AddVirtrualMaterialDTO;
|
|
|
|
|
import com.nflg.product.bomnew.pojo.dto.MaterialUpdateBillDTO;
|
|
|
|
|
import com.nflg.product.bomnew.pojo.entity.BomNewEbomChildEntity;
|
|
|
|
|
@ -20,6 +18,8 @@ import com.nflg.product.bomnew.pojo.vo.ChildListForGenerateVirtualPackageVO;
|
|
|
|
|
import com.nflg.product.bomnew.pojo.vo.MaterialMainVO;
|
|
|
|
|
import com.nflg.product.bomnew.pojo.vo.OperationErrorMsgVO;
|
|
|
|
|
import com.nflg.product.bomnew.util.VUtils;
|
|
|
|
|
import com.nflg.product.bomnew.util.VersionUtil;
|
|
|
|
|
import nflg.product.common.dto.LoginUserInfoDTO;
|
|
|
|
|
import nflg.product.common.vo.ResultVO;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
@ -27,11 +27,8 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author 曹鹏飞
|
|
|
|
|
@ -43,15 +40,20 @@ public class BomNewEbomGenerateVirtualPackageServiceFor31Impl implements IBomNew
|
|
|
|
|
|
|
|
|
|
private final BomNewEbomParentService ebomParentService = SpringUtil.getBean(BomNewEbomParentService.class);
|
|
|
|
|
private final BomNewEbomChildService ebomChildService = SpringUtil.getBean(BomNewEbomChildService.class);
|
|
|
|
|
|
|
|
|
|
private final MaterialMainClient materialMainClient = SpringUtil.getBean(MaterialMainClient.class);
|
|
|
|
|
private final MaterialService materialService = SpringUtil.getBean(MaterialService.class);
|
|
|
|
|
|
|
|
|
|
private final List<BomNewEbomChildEntity> children = new ArrayList<>();
|
|
|
|
|
private final List<BomNewEbomParentEntity> parents = new ArrayList<>();
|
|
|
|
|
private final List<BomNewEbomChildEntity> childrenForAdd = Collections.synchronizedList(new ArrayList<>());
|
|
|
|
|
private final List<BomNewEbomChildEntity> childrenForUpdate = Collections.synchronizedList(new ArrayList<>());
|
|
|
|
|
private final List<BomNewEbomParentEntity> parentsForAdd = Collections.synchronizedList(new ArrayList<>());
|
|
|
|
|
private final List<BomNewEbomParentEntity> parentsForUpdate = Collections.synchronizedList(new ArrayList<>());
|
|
|
|
|
private final List<Long> childRowIdsForDel = new ArrayList<>();
|
|
|
|
|
private final List<OperationErrorMsgVO> errorMsgList = Collections.synchronizedList(new ArrayList<>());
|
|
|
|
|
private final Map<String, String> materialUpdateBill = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
private final List<OperationErrorMsgVO> errorMsgList = new ArrayList<>();
|
|
|
|
|
private final static List<Long> DOING_ROWID = Collections.synchronizedList(new ArrayList<>());
|
|
|
|
|
|
|
|
|
|
private final LoginUserInfoDTO userInfo = SessionUtil.getUser();
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<OperationErrorMsgVO> generate(GenerateVirtualPackageQuery query) {
|
|
|
|
|
@ -61,42 +63,58 @@ public class BomNewEbomGenerateVirtualPackageServiceFor31Impl implements IBomNew
|
|
|
|
|
VUtils.isTure(root.getMaterialNo().startsWith("21")).throwMessage("21编码接口调用错误");
|
|
|
|
|
VUtils.isTure(!root.getMaterialNo().startsWith("31")).throwMessage("该编码的物料不能生成发货包:" + root.getMaterialNo());
|
|
|
|
|
|
|
|
|
|
List<ChildListForGenerateVirtualPackageVO> olds = ebomParentService.getChildListForGenerateVirtualPackage(root);
|
|
|
|
|
query.getChildren().forEach(it -> {
|
|
|
|
|
ChildListForGenerateVirtualPackageVO old = olds.stream().filter(f -> Objects.equals(f.getRowId(), it.getRowId())).findFirst().orElse(null);
|
|
|
|
|
VUtils.isTure(Objects.isNull(old)).throwMessage(it.getRowId() + "无效");
|
|
|
|
|
BomNewEbomChildEntity child = ebomChildService.getById(it.getRowId());
|
|
|
|
|
if (it.isGenerate1010() && it.isGenerate1020()) {
|
|
|
|
|
selectedAll(root, child, old);
|
|
|
|
|
} else if (!it.isGenerate1010() && !it.isGenerate1020()) {
|
|
|
|
|
cancelAll(root, child, old);
|
|
|
|
|
} else if (it.isGenerate1010()) {
|
|
|
|
|
selected1010Cancel1020(root, child, old);
|
|
|
|
|
} else {
|
|
|
|
|
selected1020Cancel1010(root, child, old);
|
|
|
|
|
VUtils.isTure(DOING_ROWID.contains(query.getParentRowId())).throwMessage(root.getMaterialNo() + "正在生成虚拟包,请勿重复操作");
|
|
|
|
|
try {
|
|
|
|
|
DOING_ROWID.add(query.getParentRowId());
|
|
|
|
|
List<ChildListForGenerateVirtualPackageVO> olds = ebomParentService.getChildListForGenerateVirtualPackage(root);
|
|
|
|
|
List<CompletableFuture<Void>> futures = new ArrayList<>();
|
|
|
|
|
query.getChildren().forEach(it -> {
|
|
|
|
|
CompletableFuture<Void> future = CompletableFuture.runAsync(() -> {
|
|
|
|
|
ChildListForGenerateVirtualPackageVO old = olds.stream().filter(f -> Objects.equals(f.getRowId(), it.getRowId())).findFirst().orElse(null);
|
|
|
|
|
VUtils.isTure(Objects.isNull(old)).throwMessage(it.getRowId() + "无效");
|
|
|
|
|
BomNewEbomChildEntity child = ebomChildService.getById(it.getRowId());
|
|
|
|
|
if (it.isGenerate1010() && it.isGenerate1020()) {
|
|
|
|
|
selectedAll(root, child, old);
|
|
|
|
|
} else if (!it.isGenerate1010() && !it.isGenerate1020()) {
|
|
|
|
|
cancelAll(root, child, old);
|
|
|
|
|
} else if (it.isGenerate1010()) {
|
|
|
|
|
selected1010Cancel1020(root, child, old);
|
|
|
|
|
} else {
|
|
|
|
|
selected1020Cancel1010(root, child, old);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
futures.add(future);
|
|
|
|
|
});
|
|
|
|
|
CompletableFuture<Void> combinedFuture = CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]));
|
|
|
|
|
combinedFuture.join();
|
|
|
|
|
|
|
|
|
|
// List<AddVirtrualMaterialDTO> addM = children.stream().filter(c -> StrUtil.isBlank(c.getMaterialNo())).map(c -> {
|
|
|
|
|
// AddVirtrualMaterialDTO ent = new AddVirtrualMaterialDTO();
|
|
|
|
|
// ent.setKey(c.getRowId().toString());
|
|
|
|
|
// ent.setDrawingNo(c.getDrawingNo());
|
|
|
|
|
// ent.setMaterialName(c.getMaterialName());
|
|
|
|
|
// ent.setMaterialDesc(c.getMaterialDesc());
|
|
|
|
|
// ent.setMaterialCategoryCode(c.getMaterialCategoryCode());
|
|
|
|
|
// return ent;
|
|
|
|
|
// }).collect(Collectors.toList());
|
|
|
|
|
// Map<String, AddVirtrualMaterialDTO> vMNosResult = materialService.batchAddMaterial(addM);
|
|
|
|
|
// vMNosResult.forEach((k, v) -> {
|
|
|
|
|
// children.stream().filter(c -> Objects.equals(c.getRowId(), Convert.toLong(k))).forEach(c -> {
|
|
|
|
|
// c.setMaterialNo(v.getMaterialNo());
|
|
|
|
|
// });
|
|
|
|
|
// parents.stream().filter(c -> Objects.equals(c.getRowId(), Convert.toLong(k))).forEach(c -> {
|
|
|
|
|
// c.setMaterialNo(v.getMaterialNo());
|
|
|
|
|
// });
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
save();
|
|
|
|
|
|
|
|
|
|
if (!materialUpdateBill.isEmpty()) {
|
|
|
|
|
materialUpdateBill.forEach(this::addMaterialUpdateBillEntity);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
List<AddVirtrualMaterialDTO> addM = children.stream().filter(c -> StrUtil.isBlank(c.getMaterialNo())).map(c -> {
|
|
|
|
|
AddVirtrualMaterialDTO ent = new AddVirtrualMaterialDTO();
|
|
|
|
|
ent.setKey(c.getRowId().toString());
|
|
|
|
|
ent.setDrawingNo(c.getDrawingNo());
|
|
|
|
|
ent.setMaterialName(c.getMaterialName());
|
|
|
|
|
ent.setMaterialDesc(c.getMaterialDesc());
|
|
|
|
|
ent.setMaterialCategoryCode(c.getMaterialCategoryCode());
|
|
|
|
|
return ent;
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
Map<String, AddVirtrualMaterialDTO> vMNosResult = materialService.batchAddMaterial(addM);
|
|
|
|
|
vMNosResult.forEach((k, v) -> {
|
|
|
|
|
children.stream().filter(c -> Objects.equals(c.getRowId(), Convert.toLong(k))).forEach(c -> {
|
|
|
|
|
c.setMaterialNo(v.getMaterialNo());
|
|
|
|
|
});
|
|
|
|
|
parents.stream().filter(c -> Objects.equals(c.getRowId(), Convert.toLong(k))).forEach(c -> {
|
|
|
|
|
c.setMaterialNo(v.getMaterialNo());
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
save();
|
|
|
|
|
} finally {
|
|
|
|
|
DOING_ROWID.remove(query.getParentRowId());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return errorMsgList;
|
|
|
|
|
}
|
|
|
|
|
@ -106,11 +124,25 @@ public class BomNewEbomGenerateVirtualPackageServiceFor31Impl implements IBomNew
|
|
|
|
|
if (CollUtil.isNotEmpty(childRowIdsForDel)) {
|
|
|
|
|
ebomChildService.getBaseMapper().deleteBatchIds(childRowIdsForDel);
|
|
|
|
|
}
|
|
|
|
|
if (CollUtil.isNotEmpty(children)) {
|
|
|
|
|
ebomChildService.saveOrUpdateBatch(children);
|
|
|
|
|
if (CollUtil.isNotEmpty(childrenForAdd)) {
|
|
|
|
|
LOGGER.debug("ebomChildService.saveBatch");
|
|
|
|
|
LOGGER.debug(JSON.toJSONString(childrenForAdd));
|
|
|
|
|
ebomChildService.saveBatch(childrenForAdd);
|
|
|
|
|
}
|
|
|
|
|
if (CollUtil.isNotEmpty(parents)) {
|
|
|
|
|
ebomParentService.saveOrUpdateBatch(parents);
|
|
|
|
|
if (CollUtil.isNotEmpty(childrenForUpdate)) {
|
|
|
|
|
LOGGER.debug("ebomChildService.updateBatchById");
|
|
|
|
|
LOGGER.debug(JSON.toJSONString(childrenForUpdate));
|
|
|
|
|
ebomChildService.updateBatchById(childrenForUpdate);
|
|
|
|
|
}
|
|
|
|
|
if (CollUtil.isNotEmpty(parentsForAdd)) {
|
|
|
|
|
LOGGER.debug("ebomParentService.saveBatch");
|
|
|
|
|
LOGGER.debug(JSON.toJSONString(parentsForAdd));
|
|
|
|
|
ebomParentService.saveBatch(parentsForAdd);
|
|
|
|
|
}
|
|
|
|
|
if (CollUtil.isNotEmpty(parentsForUpdate)) {
|
|
|
|
|
LOGGER.debug("ebomParentService.updateBatchById");
|
|
|
|
|
LOGGER.debug(JSON.toJSONString(parentsForUpdate));
|
|
|
|
|
ebomParentService.updateBatchById(parentsForUpdate);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -120,6 +152,7 @@ public class BomNewEbomGenerateVirtualPackageServiceFor31Impl implements IBomNew
|
|
|
|
|
String dnMaking = buildDrawingNo(root.getDrawingNo(), child.getMaterialName(), VirtualPackageTypeEnum.MAKING_PACKAGE, true);
|
|
|
|
|
BomNewEbomParentEntity p = ebomParentService.lambdaQuery()
|
|
|
|
|
.eq(BomNewEbomParentEntity::getDrawingNo, dnMaking)
|
|
|
|
|
.lt(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue())
|
|
|
|
|
.one();
|
|
|
|
|
if (Objects.isNull(p)) {
|
|
|
|
|
BomNewEbomChildEntity c = ebomChildService.lambdaQuery()
|
|
|
|
|
@ -131,7 +164,7 @@ public class BomNewEbomGenerateVirtualPackageServiceFor31Impl implements IBomNew
|
|
|
|
|
}
|
|
|
|
|
child.setParentRowId(p.getRowId());
|
|
|
|
|
child.setModifyTime(LocalDateTime.now());
|
|
|
|
|
children.add(child);
|
|
|
|
|
childrenForUpdate.add(child);
|
|
|
|
|
} else if (!old.isHasGenerated1010() && !old.isHasGenerated1020()) {
|
|
|
|
|
build1020VirtualPackage(root, true, child);
|
|
|
|
|
} else if (old.isHasGenerated1010()) {
|
|
|
|
|
@ -140,12 +173,14 @@ public class BomNewEbomGenerateVirtualPackageServiceFor31Impl implements IBomNew
|
|
|
|
|
String newDrawingNo = buildDrawingNo(root.getDrawingNo(), child.getMaterialName(), VirtualPackageTypeEnum.DELIVERY_PACKAGE, true);
|
|
|
|
|
BomNewEbomParentEntity fp = ebomParentService.lambdaQuery()
|
|
|
|
|
.eq(BomNewEbomParentEntity::getDrawingNo, newDrawingNo)
|
|
|
|
|
.lt(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue())
|
|
|
|
|
.one();
|
|
|
|
|
if (Objects.nonNull(fp)) {
|
|
|
|
|
buildVirtualPackage(true, root.getRowId(), root, child, VirtualPackageTypeEnum.DELIVERY_PACKAGE, child.getOrderNumber());
|
|
|
|
|
String dnMaking = buildDrawingNo(root.getDrawingNo(), child.getMaterialName(), VirtualPackageTypeEnum.MAKING_PACKAGE, true);
|
|
|
|
|
BomNewEbomParentEntity zp = ebomParentService.lambdaQuery()
|
|
|
|
|
.eq(BomNewEbomParentEntity::getDrawingNo, dnMaking)
|
|
|
|
|
.lt(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue())
|
|
|
|
|
.one();
|
|
|
|
|
if (Objects.isNull(zp)) {
|
|
|
|
|
BomNewEbomChildEntity c = ebomChildService.lambdaQuery()
|
|
|
|
|
@ -158,7 +193,7 @@ public class BomNewEbomGenerateVirtualPackageServiceFor31Impl implements IBomNew
|
|
|
|
|
//挂载物料
|
|
|
|
|
child.setParentRowId(zp.getRowId());
|
|
|
|
|
child.setModifyTime(LocalDateTime.now());
|
|
|
|
|
children.add(child);
|
|
|
|
|
childrenForUpdate.add(child);
|
|
|
|
|
} else {
|
|
|
|
|
fp = updateParentVirtualPackage(oldDrawingNo, newDrawingNo);
|
|
|
|
|
updateChildVirtualPackage(root.getRowId(), oldDrawingNo, newDrawingNo);
|
|
|
|
|
@ -174,7 +209,7 @@ public class BomNewEbomGenerateVirtualPackageServiceFor31Impl implements IBomNew
|
|
|
|
|
//挂载物料
|
|
|
|
|
child.setParentRowId(zp.getRowId());
|
|
|
|
|
child.setModifyTime(LocalDateTime.now());
|
|
|
|
|
children.add(child);
|
|
|
|
|
childrenForUpdate.add(child);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -182,15 +217,17 @@ public class BomNewEbomGenerateVirtualPackageServiceFor31Impl implements IBomNew
|
|
|
|
|
private BomNewEbomParentEntity updateParentVirtualPackage(String oldDrawingNo, String newDrawingNo) {
|
|
|
|
|
BomNewEbomParentEntity p = ebomParentService.lambdaQuery()
|
|
|
|
|
.eq(BomNewEbomParentEntity::getDrawingNo, newDrawingNo)
|
|
|
|
|
.lt(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue())
|
|
|
|
|
.one();
|
|
|
|
|
if (Objects.isNull(p)) {
|
|
|
|
|
p = ebomParentService.lambdaQuery()
|
|
|
|
|
.eq(BomNewEbomParentEntity::getDrawingNo, oldDrawingNo)
|
|
|
|
|
.lt(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue())
|
|
|
|
|
.one();
|
|
|
|
|
p.setDrawingNo(newDrawingNo);
|
|
|
|
|
p.setMaterialDesc(newDrawingNo);
|
|
|
|
|
p.setMaterialName(newDrawingNo);
|
|
|
|
|
parents.add(p);
|
|
|
|
|
parentsForUpdate.add(p);
|
|
|
|
|
}
|
|
|
|
|
return p;
|
|
|
|
|
}
|
|
|
|
|
@ -200,32 +237,38 @@ public class BomNewEbomGenerateVirtualPackageServiceFor31Impl implements IBomNew
|
|
|
|
|
.eq(BomNewEbomChildEntity::getParentRowId, parentRowId)
|
|
|
|
|
.eq(BomNewEbomChildEntity::getDrawingNo, oldDrawingNo)
|
|
|
|
|
.one();
|
|
|
|
|
addMaterialUpdateBillEntity(c.getMaterialNo(), newDrawingNo);
|
|
|
|
|
//addMaterialUpdateBillEntity(c.getMaterialNo(), newDrawingNo);
|
|
|
|
|
c.setDrawingNo(newDrawingNo);
|
|
|
|
|
c.setMaterialDesc(newDrawingNo);
|
|
|
|
|
c.setMaterialName(newDrawingNo);
|
|
|
|
|
children.add(c);
|
|
|
|
|
childrenForUpdate.add(c);
|
|
|
|
|
materialUpdateBill.putIfAbsent(c.getMaterialNo(), newDrawingNo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void addMaterialUpdateBillEntity(String materialNo, String newDrawingNo) {
|
|
|
|
|
ResultVO<MaterialMainVO> result = materialMainClient.selectByMaterialNo(materialNo);
|
|
|
|
|
if (result.getState() != 200) {
|
|
|
|
|
errorMsgList.add(OperationErrorMsgVO.create(materialNo, result.getMsg()));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
MaterialMainVO vo = result.getData();
|
|
|
|
|
MaterialUpdateBillDTO dto = Convert.convert(MaterialUpdateBillDTO.class, vo);
|
|
|
|
|
dto.setOpEnum(1);
|
|
|
|
|
dto.setDrawingNo(newDrawingNo);
|
|
|
|
|
dto.setMaterialDesc(newDrawingNo);
|
|
|
|
|
dto.setMaterialName(newDrawingNo);
|
|
|
|
|
dto.setOldMaterialDesc(vo.getMaterialDesc());
|
|
|
|
|
dto.setOldMaterialState(vo.getMaterialState());
|
|
|
|
|
dto.setOldCategoryCode(vo.getMaterialCategoryCode());
|
|
|
|
|
dto.setUpdateResion("发货包工厂切换");
|
|
|
|
|
ResultVO<Boolean> result1 = materialMainClient.addMaterialUpdateBillEntity(dto);
|
|
|
|
|
if (result1.getState() != 200) {
|
|
|
|
|
errorMsgList.add(OperationErrorMsgVO.create(materialNo, result1.getMsg()));
|
|
|
|
|
try {
|
|
|
|
|
ResultVO<MaterialMainVO> result = materialMainClient.selectByMaterialNo(materialNo);
|
|
|
|
|
if (result.getState() != 200) {
|
|
|
|
|
errorMsgList.add(OperationErrorMsgVO.create(materialNo, result.getMsg()));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
MaterialMainVO vo = result.getData();
|
|
|
|
|
MaterialUpdateBillDTO dto = Convert.convert(MaterialUpdateBillDTO.class, vo);
|
|
|
|
|
dto.setOpEnum(1);
|
|
|
|
|
dto.setDrawingNo(newDrawingNo);
|
|
|
|
|
dto.setMaterialDesc(newDrawingNo);
|
|
|
|
|
dto.setMaterialName(newDrawingNo);
|
|
|
|
|
dto.setOldMaterialDesc(vo.getMaterialDesc());
|
|
|
|
|
dto.setOldMaterialState(vo.getMaterialState());
|
|
|
|
|
dto.setOldCategoryCode(vo.getMaterialCategoryCode());
|
|
|
|
|
dto.setUpdateResion("发货包工厂切换");
|
|
|
|
|
ResultVO<Boolean> result1 = materialMainClient.addMaterialUpdateBillEntity(dto);
|
|
|
|
|
if (result1.getState() != 200) {
|
|
|
|
|
errorMsgList.add(OperationErrorMsgVO.create(materialNo, result1.getMsg()));
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
LOGGER.error(StrUtil.format("物料变更失败,materialNo:{},drawingNo:", materialNo, newDrawingNo), ex);
|
|
|
|
|
errorMsgList.add(OperationErrorMsgVO.create(materialNo, "物料变更失败:" + ex.getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -241,12 +284,14 @@ public class BomNewEbomGenerateVirtualPackageServiceFor31Impl implements IBomNew
|
|
|
|
|
String newDrawingNo = buildDrawingNo(root.getDrawingNo(), child.getMaterialName(), VirtualPackageTypeEnum.DELIVERY_PACKAGE, false);
|
|
|
|
|
BomNewEbomParentEntity fp = ebomParentService.lambdaQuery()
|
|
|
|
|
.eq(BomNewEbomParentEntity::getDrawingNo, newDrawingNo)
|
|
|
|
|
.lt(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue())
|
|
|
|
|
.one();
|
|
|
|
|
if (Objects.nonNull(fp)) {
|
|
|
|
|
buildVirtualPackage(true, root.getRowId(), root, child, 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, false);
|
|
|
|
|
BomNewEbomParentEntity zp = ebomParentService.lambdaQuery()
|
|
|
|
|
.eq(BomNewEbomParentEntity::getDrawingNo, dnMaking)
|
|
|
|
|
.lt(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue())
|
|
|
|
|
.one();
|
|
|
|
|
if (Objects.isNull(zp)) {
|
|
|
|
|
BomNewEbomChildEntity c = ebomChildService.lambdaQuery()
|
|
|
|
|
@ -259,7 +304,7 @@ public class BomNewEbomGenerateVirtualPackageServiceFor31Impl implements IBomNew
|
|
|
|
|
//挂载物料
|
|
|
|
|
child.setParentRowId(zp.getRowId());
|
|
|
|
|
child.setModifyTime(LocalDateTime.now());
|
|
|
|
|
children.add(child);
|
|
|
|
|
childrenForUpdate.add(child);
|
|
|
|
|
} else {
|
|
|
|
|
fp = updateParentVirtualPackage(oldDrawingNo, newDrawingNo);
|
|
|
|
|
updateChildVirtualPackage(root.getRowId(), oldDrawingNo, newDrawingNo);
|
|
|
|
|
@ -275,7 +320,7 @@ public class BomNewEbomGenerateVirtualPackageServiceFor31Impl implements IBomNew
|
|
|
|
|
//挂载物料
|
|
|
|
|
child.setParentRowId(zp.getRowId());
|
|
|
|
|
child.setModifyTime(LocalDateTime.now());
|
|
|
|
|
children.add(child);
|
|
|
|
|
childrenForUpdate.add(child);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -289,7 +334,7 @@ public class BomNewEbomGenerateVirtualPackageServiceFor31Impl implements IBomNew
|
|
|
|
|
BomNewEbomParentEntity qp2 = buildVirtualPackage(qp1, qc2);
|
|
|
|
|
child.setParentRowId(qp2.getRowId());
|
|
|
|
|
child.setModifyTime(LocalDateTime.now());
|
|
|
|
|
children.add(child);
|
|
|
|
|
childrenForUpdate.add(child);
|
|
|
|
|
//直发包
|
|
|
|
|
buildVirtualPackage(false, qp1.getRowId(), root, child, VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE, "002");
|
|
|
|
|
}
|
|
|
|
|
@ -304,7 +349,7 @@ public class BomNewEbomGenerateVirtualPackageServiceFor31Impl implements IBomNew
|
|
|
|
|
BomNewEbomParentEntity xp2 = buildVirtualPackage(xp1, xc2);
|
|
|
|
|
child.setParentRowId(xp2.getRowId());
|
|
|
|
|
child.setModifyTime(LocalDateTime.now());
|
|
|
|
|
children.add(child);
|
|
|
|
|
childrenForUpdate.add(child);
|
|
|
|
|
}
|
|
|
|
|
//直发包
|
|
|
|
|
buildVirtualPackage(true, xp1.getRowId(), root, child, VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE, "002");
|
|
|
|
|
@ -325,7 +370,7 @@ public class BomNewEbomGenerateVirtualPackageServiceFor31Impl implements IBomNew
|
|
|
|
|
private void cancelAll(BomNewEbomParentEntity root, BomNewEbomChildEntity child, ChildListForGenerateVirtualPackageVO old) {
|
|
|
|
|
child.setParentRowId(root.getRowId());
|
|
|
|
|
child.setModifyTime(LocalDateTime.now());
|
|
|
|
|
children.add(child);
|
|
|
|
|
childrenForUpdate.add(child);
|
|
|
|
|
if (old.isHasGenerated1010()) {
|
|
|
|
|
buildDelVirtualPackage(root, child, false);
|
|
|
|
|
}
|
|
|
|
|
@ -362,30 +407,46 @@ public class BomNewEbomGenerateVirtualPackageServiceFor31Impl implements IBomNew
|
|
|
|
|
private BomNewEbomParentEntity buildVirtualPackage(BomNewEbomParentEntity parent, BomNewEbomChildEntity child) {
|
|
|
|
|
BomNewEbomParentEntity p = ebomParentService.lambdaQuery()
|
|
|
|
|
.eq(BomNewEbomParentEntity::getDrawingNo, child.getDrawingNo())
|
|
|
|
|
.orderByDesc(BomNewEbomParentEntity::getRowId)
|
|
|
|
|
.last(" limit 1")
|
|
|
|
|
.one();
|
|
|
|
|
if (Objects.isNull(p)) {
|
|
|
|
|
p = Convert.convert(BomNewEbomParentEntity.class, child);
|
|
|
|
|
p.setCreatedBy(SessionUtil.getUserCode());
|
|
|
|
|
p.setCurrentVersion(OriginalConstant.DEFAULT_BOM_VERSION);
|
|
|
|
|
p.setVirtualPackageIs(1);
|
|
|
|
|
p.setRootIs(0);
|
|
|
|
|
p.setUserRootIs(0);
|
|
|
|
|
p.setDeviseName(SessionUtil.getRealName());
|
|
|
|
|
p.setDeviseUserCode(SessionUtil.getUserCode());
|
|
|
|
|
p.setDeptName(SessionUtil.getDepartName());
|
|
|
|
|
p.setRootIsForWaitReview(0);
|
|
|
|
|
p.setAuditTime(parent.getAuditTime());
|
|
|
|
|
p.setAuditUserName(parent.getAuditUserName());
|
|
|
|
|
p.setStatus(parent.getStatus());
|
|
|
|
|
p.setLastVersionIs(1);
|
|
|
|
|
p.setBatchNo("");
|
|
|
|
|
p.setLevelNum(parent.getLevelNum() + 1);
|
|
|
|
|
p.setBomExist(1);
|
|
|
|
|
parents.add(p);
|
|
|
|
|
if (Objects.nonNull(p)) {
|
|
|
|
|
if (Objects.equals(p.getStatus(), EBomStatusEnum.PUBLISHED.getValue())) {
|
|
|
|
|
p.setLastVersionIs(0);
|
|
|
|
|
parentsForUpdate.add(p);
|
|
|
|
|
BomNewEbomParentEntity p1 = buildParent(parent, child);
|
|
|
|
|
p1.setCurrentVersion(VersionUtil.getNextVersion(p.getCurrentVersion()));
|
|
|
|
|
parentsForAdd.add(p1);
|
|
|
|
|
return p1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
p = buildParent(parent, child);
|
|
|
|
|
parentsForAdd.add(p);
|
|
|
|
|
}
|
|
|
|
|
return p;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private BomNewEbomParentEntity buildParent(BomNewEbomParentEntity parent, BomNewEbomChildEntity child) {
|
|
|
|
|
BomNewEbomParentEntity p = Convert.convert(BomNewEbomParentEntity.class, child);
|
|
|
|
|
p.setCreatedBy(userInfo.getUserCode());
|
|
|
|
|
p.setCurrentVersion(OriginalConstant.DEFAULT_BOM_VERSION);
|
|
|
|
|
p.setVirtualPackageIs(1);
|
|
|
|
|
p.setRootIs(0);
|
|
|
|
|
p.setUserRootIs(0);
|
|
|
|
|
p.setDeviseName(userInfo.getRealName());
|
|
|
|
|
p.setDeviseUserCode(userInfo.getUserCode());
|
|
|
|
|
p.setDeptName(userInfo.getDepartName());
|
|
|
|
|
p.setRootIsForWaitReview(0);
|
|
|
|
|
p.setAuditTime(parent.getAuditTime());
|
|
|
|
|
p.setAuditUserName(parent.getAuditUserName());
|
|
|
|
|
p.setStatus(parent.getStatus());
|
|
|
|
|
p.setLastVersionIs(1);
|
|
|
|
|
p.setBatchNo("");
|
|
|
|
|
p.setLevelNum(parent.getLevelNum() + 1);
|
|
|
|
|
p.setBomExist(1);
|
|
|
|
|
return p;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private BomNewEbomChildEntity buildVirtualPackage(boolean is1020Factory, Long parentRowId, BomNewEbomParentEntity root
|
|
|
|
|
, BomNewEbomChildEntity material, VirtualPackageTypeEnum type, String orderNo) {
|
|
|
|
|
String drawingNo = buildDrawingNo(root.getDrawingNo(), material.getMaterialName(), type, is1020Factory);
|
|
|
|
|
@ -396,12 +457,6 @@ public class BomNewEbomGenerateVirtualPackageServiceFor31Impl implements IBomNew
|
|
|
|
|
if (Objects.isNull(child)) {
|
|
|
|
|
child = new BomNewEbomChildEntity();
|
|
|
|
|
child.setRowId(IdWorker.getId());
|
|
|
|
|
BomNewEbomParentEntity p = ebomParentService.lambdaQuery()
|
|
|
|
|
.eq(BomNewEbomParentEntity::getDrawingNo, drawingNo)
|
|
|
|
|
.one();
|
|
|
|
|
if (Objects.nonNull(p)) {
|
|
|
|
|
child.setMaterialNo(p.getMaterialNo());
|
|
|
|
|
}
|
|
|
|
|
child.setParentRowId(parentRowId);
|
|
|
|
|
child.setIdentityNo(parentRowId + "_" + child.getRowId());
|
|
|
|
|
child.setOrderNumber(orderNo);
|
|
|
|
|
@ -413,13 +468,22 @@ public class BomNewEbomGenerateVirtualPackageServiceFor31Impl implements IBomNew
|
|
|
|
|
child.setProjectTypeInputType(ProjectTypeInputTypeEnum.MANUAL_INPUT.getValue());
|
|
|
|
|
child.setMaterialUnit("PC");
|
|
|
|
|
child.setMaterialOriginalUnit("PC");
|
|
|
|
|
child.setCreatedBy(SessionUtil.getUserCode());
|
|
|
|
|
child.setCreatedBy(userInfo.getUserCode());
|
|
|
|
|
child.setDrawingNo(drawingNo);
|
|
|
|
|
child.setMaterialDesc(child.getDrawingNo());
|
|
|
|
|
child.setMaterialName(child.getDrawingNo());
|
|
|
|
|
child.setMaterialCategoryCode(type.getMaterialCategoryCode());
|
|
|
|
|
child.setVirtualPartRootMaterialNo(root.getMaterialNo());
|
|
|
|
|
children.add(child);
|
|
|
|
|
BomNewEbomParentEntity p = ebomParentService.lambdaQuery()
|
|
|
|
|
.eq(BomNewEbomParentEntity::getDrawingNo, drawingNo)
|
|
|
|
|
.lt(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue())
|
|
|
|
|
.one();
|
|
|
|
|
if (Objects.nonNull(p)) {
|
|
|
|
|
child.setMaterialNo(p.getMaterialNo());
|
|
|
|
|
} else {
|
|
|
|
|
child.setMaterialNo(getMaterialNoForAdd(child));
|
|
|
|
|
}
|
|
|
|
|
childrenForAdd.add(child);
|
|
|
|
|
}
|
|
|
|
|
return child;
|
|
|
|
|
}
|
|
|
|
|
@ -427,4 +491,15 @@ public class BomNewEbomGenerateVirtualPackageServiceFor31Impl implements IBomNew
|
|
|
|
|
public static String buildDrawingNo(String drawingNo, String materialName, VirtualPackageTypeEnum type, boolean is1020Factory) {
|
|
|
|
|
return StrUtil.format("({})({}{})({})", drawingNo, materialName, is1020Factory ? "仙桃" : "", type.getConMaterialName());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String getMaterialNoForAdd(BomNewEbomChildEntity c) {
|
|
|
|
|
AddVirtrualMaterialDTO ent = new AddVirtrualMaterialDTO();
|
|
|
|
|
ent.setKey(c.getRowId().toString());
|
|
|
|
|
ent.setDrawingNo(c.getDrawingNo());
|
|
|
|
|
ent.setMaterialName(c.getMaterialName());
|
|
|
|
|
ent.setMaterialDesc(c.getMaterialDesc());
|
|
|
|
|
ent.setMaterialCategoryCode(c.getMaterialCategoryCode());
|
|
|
|
|
Map<String, AddVirtrualMaterialDTO> vMNosResult = materialService.batchAddMaterial(Collections.singletonList(ent), userInfo);
|
|
|
|
|
return vMNosResult.get(c.getRowId().toString()).getMaterialNo();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|