ebom编辑重构
This commit is contained in:
parent
49f606a9ae
commit
5175f8a606
|
|
@ -281,14 +281,16 @@ public class EbomApi extends BaseApi {
|
|||
|
||||
@GetMapping("editDetail")
|
||||
@ApiOperation("编辑物料列表")
|
||||
public ResultVO<BomNewEbomEditDetailVO> editDetail(@RequestParam("bomRowId") Long bomRowId,@RequestParam("projectType") String projectType) {
|
||||
|
||||
public ResultVO<BomNewEbomEditDetailVO> editDetail(@RequestParam("rowId") Long rowId,@RequestParam("bomRowId") Long bomRowId,@RequestParam("projectType") String projectType) {
|
||||
if(Objects.isNull(bomRowId)){
|
||||
VUtils.isTure(true ).throwMessage("rowId 不能为空");
|
||||
}
|
||||
if(Objects.isNull(bomRowId)){
|
||||
VUtils.isTure(true ).throwMessage("bomRowId不能为空");
|
||||
}
|
||||
|
||||
ResultVO resultVO = new ResultVO();
|
||||
resultVO.setData(bomNewEbomParentService.editDetail(bomRowId,projectType));
|
||||
resultVO.setData(bomNewEbomParentService.editDetail(rowId,bomRowId,projectType));
|
||||
return resultVO;
|
||||
}
|
||||
|
||||
|
|
@ -350,7 +352,8 @@ public class EbomApi extends BaseApi {
|
|||
|
||||
@PostMapping("temporary")
|
||||
@ApiOperation("暂存")
|
||||
public ResultVO<Boolean> temporary(@RequestBody BomNewEBomParentEditDTO dto) throws ExecutionException, InterruptedException {
|
||||
@LogRecord(success = "Ebom-暂存,物料编码:{{#dto.parent.materialNo}}-版本:{{#dto.parent.currentVersion}},操作结果:{{#_ret}}", bizNo = "{{#dto.parent.rowId}}",type = "Ebom-暂存")
|
||||
public ResultVO<BomNewEbomParentVO> temporary(@RequestBody BomNewEBomParentEditDTO dto) throws ExecutionException, InterruptedException {
|
||||
return ResultVO.success(bomNewEbomParentService.temporary(dto));
|
||||
}
|
||||
|
||||
|
|
@ -364,9 +367,11 @@ public class EbomApi extends BaseApi {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@PostMapping("intiException")
|
||||
@ApiOperation("初始化错误类型")
|
||||
@LogRecord(success = "Ebom-初始化错误类型,操作结果:{{#_ret}}", bizNo = "{{#bomRowIds.toString()}}",type = "Ebom-提交")
|
||||
@LogRecord(success = "Ebom-初始化错误类型,操作结果:{{#_ret}}", bizNo = "{{#bomRowIds.toString()}}",type = "Ebom-初始化错误类型")
|
||||
public ResultVO<Boolean> intiException(@RequestBody List<Long> bomRowIds) throws ExecutionException, InterruptedException {
|
||||
|
||||
bomNewEbomParentService.batchCheckAndSaveEBomException(bomRowIds );
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ import lombok.Getter;
|
|||
@Getter
|
||||
public enum EbomEditStatusEnum implements ValueEnum<Integer> {
|
||||
|
||||
HANDLER_CREATED(1, "待处理"),
|
||||
HANDLER_FINISHED(2, "处理完成");
|
||||
HANDLER_CREATED(1, "待处理"),//待处理=暂存
|
||||
HANDLER_FINISHED(2, "已处理"); //已处理=提交
|
||||
|
||||
|
||||
private final Integer value;
|
||||
|
|
|
|||
|
|
@ -17,6 +17,10 @@ public class BomNewEbomImportDTO {
|
|||
// private BomNewEbomParentVO parent;
|
||||
@ApiModelProperty("父物料id")
|
||||
private Long rowId;
|
||||
|
||||
@ApiModelProperty("bom id")
|
||||
private Long bomRowId;
|
||||
|
||||
@ApiModelProperty("操作类型(1:删除 2:追加)")
|
||||
private Integer opType;
|
||||
|
||||
|
|
|
|||
|
|
@ -914,6 +914,10 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
}, result);
|
||||
|
||||
BomNewEbomParentEntity parentEntity = this.getBaseMapper().selectById(dto.getRowId());
|
||||
if(parentEntity==null){
|
||||
throw new NflgBusinessException(STATE.Error, StrUtil.format("bom {} 数据未查询到",dto.getRowId()));
|
||||
}
|
||||
|
||||
BomNewEbomParentVO parentVO = Convert.convert(BomNewEbomParentVO.class, parentEntity);
|
||||
parentVO.setBomRowId(parentVO.getRowId());
|
||||
parentVO.setParentRowId(0l);
|
||||
|
|
@ -924,7 +928,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
BomNewEBomParentEditDTO bomNewEBomParentEditDTO = new BomNewEBomParentEditDTO();
|
||||
bomNewEBomParentEditDTO.setParent(parentVO);
|
||||
bomNewEBomParentEditDTO.setDatas(datas);
|
||||
eBomEdit.temporary(bomNewEBomParentEditDTO);
|
||||
eBomEdit.handleBom(bomNewEBomParentEditDTO);
|
||||
|
||||
|
||||
int orderNo = 1;
|
||||
|
|
@ -934,6 +938,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
deleteBom(dto.getRowId());
|
||||
}
|
||||
} else {
|
||||
//最后一个序列号
|
||||
QueryWrapper<BomNewEbomChildEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(BomNewEbomChildEntity::getParentRowId, dto.getRowId()).last("limit 1");
|
||||
queryWrapper.lambda().orderByDesc(BomNewEbomChildEntity::getOrderNumber);
|
||||
|
|
@ -948,26 +953,26 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
|
||||
for (BomNewEbomChildEntity childEntities : eBomEdit.childEntities) {
|
||||
childEntities.setOrderNumber(OrderNoUtil.orderNo2Str(orderNo));
|
||||
if (childEntities.getMaterialName().contains(VirtualPackageTypeEnum.MAKING_PACKAGE.getConMaterialName())) {
|
||||
childEntities.setVirtualPartType(VirtualPackageTypeEnum.MAKING_PACKAGE.getValue());
|
||||
childEntities.setVirtualPartIs(1);
|
||||
|
||||
} else if (childEntities.getMaterialName().contains(VirtualPackageTypeEnum.DELIVERY_PACKAGE.getConMaterialName())) {
|
||||
childEntities.setVirtualPartType(VirtualPackageTypeEnum.DELIVERY_PACKAGE.getValue());
|
||||
childEntities.setVirtualPartIs(1);
|
||||
} else if (childEntities.getMaterialName().contains(VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getConMaterialName())) {
|
||||
childEntities.setVirtualPartType(VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getValue());
|
||||
childEntities.setVirtualPartIs(1);
|
||||
} else if (childEntities.getMaterialName().contains(VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getConMaterialName())) {
|
||||
childEntities.setVirtualPartType(VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getValue());
|
||||
childEntities.setVirtualPartIs(1);
|
||||
}
|
||||
// if (childEntities.getMaterialName().contains(VirtualPackageTypeEnum.MAKING_PACKAGE.getConMaterialName())) {
|
||||
// childEntities.setVirtualPartType(VirtualPackageTypeEnum.MAKING_PACKAGE.getValue());
|
||||
// childEntities.setVirtualPartIs(1);
|
||||
//
|
||||
// } else if (childEntities.getMaterialName().contains(VirtualPackageTypeEnum.DELIVERY_PACKAGE.getConMaterialName())) {
|
||||
// childEntities.setVirtualPartType(VirtualPackageTypeEnum.DELIVERY_PACKAGE.getValue());
|
||||
// childEntities.setVirtualPartIs(1);
|
||||
// } else if (childEntities.getMaterialName().contains(VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getConMaterialName())) {
|
||||
// childEntities.setVirtualPartType(VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getValue());
|
||||
// childEntities.setVirtualPartIs(1);
|
||||
// } else if (childEntities.getMaterialName().contains(VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getConMaterialName())) {
|
||||
// childEntities.setVirtualPartType(VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getValue());
|
||||
// childEntities.setVirtualPartIs(1);
|
||||
// }
|
||||
orderNo++;
|
||||
}
|
||||
|
||||
|
||||
if (CollectionUtil.isNotEmpty(eBomEdit.parentEntities)) {
|
||||
this.saveOrUpdateBatch(eBomEdit.parentEntities);
|
||||
if ( eBomEdit.getParentEntity()!=null) {
|
||||
this.saveOrUpdate( eBomEdit.getParentEntity());
|
||||
}
|
||||
|
||||
if (CollectionUtil.isNotEmpty(eBomEdit.childEntities)) {
|
||||
|
|
@ -1282,17 +1287,36 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
return true;
|
||||
}
|
||||
|
||||
public BomNewEbomEditDetailVO editDetail(Long bomRowId, String projectType) {
|
||||
public BomNewEbomEditDetailVO editDetail( Long rowId,Long bomRowId, String projectType) {
|
||||
|
||||
BomNewEbomEditDetailVO vo = new BomNewEbomEditDetailVO();
|
||||
BomNewEbomParentEntity parent = this.getBaseMapper().selectById(bomRowId);
|
||||
BomNewEbomParentVO parentVO = Convert.convert(BomNewEbomParentVO.class, parent);
|
||||
BomNewEbomParentVO parentVO;
|
||||
if(bomRowId==null || bomRowId.longValue()==0) {
|
||||
|
||||
BomNewEbomChildEntity child = SpringUtil.getBean(BomNewEbomChildService.class).getBaseMapper().selectById(rowId);
|
||||
|
||||
parentVO.setBomRowId(parentVO.getRowId());
|
||||
parentVO.setParentRowId(0l);
|
||||
parentVO.setProjectType(projectType);
|
||||
parentVO = Convert.convert(BomNewEbomParentVO.class, child);
|
||||
materialMainService.intiMaterialInfo(ImmutableList.of(parentVO), EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT2);
|
||||
|
||||
materialMainService.intiMaterialInfo(ImmutableList.of(parentVO), EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT2);
|
||||
if (MaterialshouldBomExistUtil.checkShouldBomExist(parentVO)
|
||||
|| (parentVO.getMaterialCategoryCode().startsWith("20") && (MaterialGetEnum.outsource.equalsValue(parentVO.getMaterialGetType()) || MaterialGetEnum.purchase.equalsValue(parentVO.getMaterialGetType())))
|
||||
|| parentVO.getMaterialCategoryCode().equals("7013")) {
|
||||
;
|
||||
}else{
|
||||
VUtils.isTure(true).throwMessage("编辑条件需满足,1.存在下级物料或是缺BOM 2.物料的分类20且流程类型为外协和采购部分\n" +
|
||||
" 3.分类70中的7013时的物料 ");
|
||||
}
|
||||
vo.setDatas(new ArrayList<>());
|
||||
}else{
|
||||
BomNewEbomParentEntity parent = this.getBaseMapper().selectById(bomRowId);
|
||||
parentVO = Convert.convert(BomNewEbomParentVO.class, parent);
|
||||
|
||||
parentVO.setBomRowId(parentVO.getRowId());
|
||||
parentVO.setProjectType(projectType);
|
||||
parentVO.setParentRowId(0l);
|
||||
materialMainService.intiMaterialInfo(ImmutableList.of(parentVO), EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT2);
|
||||
vo.setDatas(getChild(bomRowId));
|
||||
}
|
||||
|
||||
|
||||
// materialMainService.intiMaterialInfo(ImmutableList.of(parentVO));
|
||||
|
|
@ -1303,7 +1327,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
// materialMainService.intiMaterialInfo(parentList);
|
||||
//
|
||||
|
||||
vo.setDatas(getChild(bomRowId));
|
||||
|
||||
vo.setParent(parentVO);
|
||||
return vo;
|
||||
|
||||
|
|
@ -1487,13 +1511,11 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
*/
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean temporary(BomNewEBomParentEditDTO dto) throws ExecutionException, InterruptedException {
|
||||
public BomNewEbomParentVO temporary(BomNewEBomParentEditDTO dto) throws ExecutionException, InterruptedException {
|
||||
|
||||
EBomEdit eBomEdit = new EBomEdit(EBomSourceEnum.FROM_MDM.getValue());
|
||||
dto.setOpType(EbomEditStatusEnum.HANDLER_CREATED.getValue());
|
||||
eBomEdit.temporary(dto);
|
||||
|
||||
|
||||
eBomEdit.handleBom(dto);
|
||||
|
||||
|
||||
if (dto.getParent() != null) {
|
||||
|
|
@ -1502,8 +1524,8 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
}
|
||||
}
|
||||
|
||||
if (CollectionUtil.isNotEmpty(eBomEdit.parentEntities)) {
|
||||
this.saveOrUpdateBatch(eBomEdit.parentEntities);
|
||||
if (eBomEdit.getParentEntity()!=null) {
|
||||
this.saveOrUpdate(eBomEdit.getParentEntity());
|
||||
}
|
||||
|
||||
if (CollUtil.isNotEmpty(eBomEdit.childEntities)) {
|
||||
|
|
@ -1513,19 +1535,15 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
|
||||
superMaterialStatus(dto.getDatas());
|
||||
|
||||
|
||||
|
||||
List<BomNewEbomParentVO> childList = dto.getDatas();
|
||||
|
||||
if (dto.getParent().getRootIs() == null || dto.getParent().getRootIs() == 0) {
|
||||
childList.add(dto.getParent());
|
||||
}
|
||||
// checkAndSaveEBomException(childList);
|
||||
//不要异步
|
||||
ebomChildService.getBaseMapper().updateEBomMaterialUse();
|
||||
// ThreadUtil.execAsync(() -> computeLevelNumAndRootState());
|
||||
|
||||
return true;
|
||||
BomNewEbomParentVO retParentVO= Convert.convert(BomNewEbomParentVO.class,eBomEdit.getParentEntity());
|
||||
retParentVO.setBomRowId(retParentVO.getRowId());
|
||||
|
||||
return retParentVO;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1538,7 +1556,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
|
||||
EBomEdit eBomEdit = new EBomEdit(EBomSourceEnum.FROM_MDM.getValue());
|
||||
dto.setOpType(EbomEditStatusEnum.HANDLER_FINISHED.getValue());
|
||||
eBomEdit.submit(dto);
|
||||
eBomEdit.handleBom(dto);
|
||||
|
||||
List<Integer> checkStatus = CollectionUtil.toList(new Integer[]{
|
||||
EBomExceptionStatusEnum.EXCEPT_NO_2.getValue(),
|
||||
|
|
@ -1557,27 +1575,22 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
if ( eBomEdit.getParentEntity()!=null) {
|
||||
this.saveOrUpdate(eBomEdit.getParentEntity());
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (CollectionUtil.isNotEmpty(eBomEdit.childEntities)) {
|
||||
|
||||
|
||||
List<BomNewEbomParentVO> allBom = Convert.convert(new TypeReference<List<BomNewEbomParentVO>>() {
|
||||
}, eBomEdit.childEntities);
|
||||
|
||||
BomNewEbomParentVO parent = Convert.convert(BomNewEbomParentVO.class
|
||||
, eBomEdit.parentEntities.get(0));
|
||||
|
||||
// if (dto.getParent().getRootIs() == null || dto.getParent().getRootIs() == 0) {
|
||||
// allBom.add(parent);
|
||||
// }
|
||||
|
||||
CheckEBomException checkEBomException = new CheckEBomException(allBom);
|
||||
checkEBomException.checkContainExcept(checkStatus);
|
||||
}
|
||||
|
||||
if (CollectionUtil.isNotEmpty(eBomEdit.parentEntities)) {
|
||||
this.saveOrUpdateBatch(eBomEdit.parentEntities);
|
||||
|
||||
}
|
||||
|
||||
if (CollectionUtil.isNotEmpty(eBomEdit.childEntities)) {
|
||||
ebomChildService.saveOrUpdateBatch(eBomEdit.childEntities);
|
||||
|
|
@ -1611,6 +1624,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
if (CollectionUtil.isEmpty(delList)) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<BomNewEbomParentVO> delTagList = new ArrayList<>();
|
||||
|
||||
List<BomNewEbomParentVO> okList = delList.stream().filter(u -> Objects.equals(EBomSourceEnum.FROM_BOM.getValue(), u.getSource())
|
||||
|
|
|
|||
|
|
@ -19,43 +19,50 @@ import com.nflg.product.bomnew.pojo.entity.BomNewEbomChildEntity;
|
|||
import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity;
|
||||
import com.nflg.product.bomnew.pojo.vo.BaseMaterialVO;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
|
||||
import com.nflg.product.bomnew.service.BomNewEbomParentService;
|
||||
import com.nflg.product.bomnew.service.MaterialMainService;
|
||||
import com.nflg.product.bomnew.service.UserRoleService;
|
||||
import com.nflg.product.bomnew.util.MaterialshouldBomExistUtil;
|
||||
import com.nflg.product.bomnew.util.VUtils;
|
||||
import lombok.Getter;
|
||||
import nflg.product.common.constant.STATE;
|
||||
import org.ttzero.excel.reader.Col;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class EBomEdit {
|
||||
|
||||
public List<BomNewEbomParentEntity> parentEntities;
|
||||
@Getter
|
||||
private BomNewEbomParentEntity parentEntity;
|
||||
|
||||
public List<BomNewEbomChildEntity> childEntities;
|
||||
|
||||
Integer source;
|
||||
List<String> roleList;
|
||||
|
||||
public EBomEdit(Integer source) {
|
||||
this.source = source;
|
||||
|
||||
parentEntities = new ArrayList<>();
|
||||
childEntities = new ArrayList<>();
|
||||
roleList = SpringUtil.getBean(UserRoleService.class).getUserPost();
|
||||
}
|
||||
|
||||
BomNewEbomParentEntity createParentBomInfo(BomNewEbomParentVO vo) {
|
||||
|
||||
BomNewEbomParentEntity parent = new BomNewEbomParentEntity();
|
||||
BeanUtil.copyProperties(vo,parent);
|
||||
BomNewEbomParentEntity parent = Convert.convert(BomNewEbomParentEntity.class, vo);
|
||||
//BeanUtil.copyProperties(vo,parent);
|
||||
|
||||
// BaseMaterialVO material = materialVOMap.get(vo.getMaterialNo());
|
||||
String batchNo = IdUtil.simpleUUID();
|
||||
parent.setRowId(IdWorker.getId());
|
||||
parent.setBatchNo(batchNo);
|
||||
|
||||
|
||||
parent.setTotalWeight(NumberUtil.mul(vo.getUnitWeight(), vo.getNum()));
|
||||
parent.setDeviseUserCode(SessionUtil.getUserCode());
|
||||
parent.setCurrentVersion("A00");
|
||||
|
|
@ -64,7 +71,7 @@ public class EBomEdit {
|
|||
parent.setSourceRowId(0l);
|
||||
parent.setSource(source);
|
||||
parent.setStatus(EBomStatusEnum.WAIT_CHECK.getValue());
|
||||
|
||||
parent.setNum(new BigDecimal(1));
|
||||
parent.setBomExist(1);
|
||||
parent.setLastVersionIs(1);
|
||||
parent.setEditStatus(EbomEditStatusEnum.HANDLER_CREATED.getValue());
|
||||
|
|
@ -74,37 +81,102 @@ public class EBomEdit {
|
|||
parent.setStatus(SpringUtil.getBean(UserRoleService.class).technician() ? EBomStatusEnum.CHECKED.getValue() : EBomStatusEnum.WAIT_CHECK.getValue());
|
||||
parent.setCreatedJob(SpringUtil.getBean(UserRoleService.class).technician() ? UserJobEnum.ENGINEER.getValue() : UserJobEnum.DESIGNER.getValue());
|
||||
|
||||
|
||||
parent.setModifyTime(LocalDateTime.now());
|
||||
|
||||
parent.setExpireEndTime( LocalDateTime.parse("9999-12-31 23:59:59", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss") ));
|
||||
|
||||
return parent;
|
||||
}
|
||||
|
||||
|
||||
void createBom(BomNewEBomParentEditDTO createDTO){
|
||||
|
||||
List<String> materialNos = createDTO.getDatas().stream().map(u -> u.getMaterialNo()).collect(Collectors.toList());
|
||||
materialNos.add(createDTO.getParent().getMaterialNo());
|
||||
//检查物料编码是否在主数据中存在
|
||||
List<BaseMaterialVO> materialBaseInfo = SpringUtil.getBean(MaterialMainService.class).getMaterialBaseInfo(materialNos);
|
||||
List<String> effectiveMaterialNos = materialBaseInfo.stream().map(u -> u.getMaterialNo()).collect(Collectors.toList());
|
||||
Set<String> difference = Sets.difference(new HashSet<>(materialNos), new HashSet<>(effectiveMaterialNos));
|
||||
VUtils.isTure(CollUtil.isNotEmpty(difference)).throwMessage(StrUtil.join(",", difference) + "在物料档案中不存在");
|
||||
|
||||
|
||||
List<BomNewEbomParentEntity> existBomlist =SpringUtil.getBean(MaterialMainService.class).lambdaQuery().eq(BomNewEbomParentEntity::getMaterialNo, createDTO.getParent().getMaterialNo()).list();
|
||||
|
||||
QueryWrapper<BomNewEbomParentEntity>
|
||||
|
||||
VUtils.isTure(CollUtil.isNotEmpty(existBomlist)).throwMessage("该物料已存在BOM");
|
||||
|
||||
|
||||
|
||||
|
||||
void checkHadBom(String materialNo){
|
||||
QueryWrapper<BomNewEbomParentEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(BomNewEbomParentEntity::getMaterialNo, materialNo);
|
||||
List<BomNewEbomParentEntity> existBomlist = SpringUtil.getBean(BomNewEbomParentService.class).list(queryWrapper);
|
||||
VUtils.isTure(CollUtil.isNotEmpty(existBomlist)).throwMessage(materialNo+"该物料已存在BOM");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void createRootBom(BomNewEBomParentEditDTO createDTO) {
|
||||
|
||||
checkHadBom(createDTO.getParent().getMaterialNo());
|
||||
|
||||
parentEntity = createParentBomInfo(createDTO.getParent());
|
||||
parentEntity.setEditStatus(createDTO.getOpType());
|
||||
|
||||
parentEntity.setRootIs(1);
|
||||
parentEntity.setUserRootIs(1);
|
||||
createDTO.getDatas().forEach(k -> {
|
||||
k.setParentRowId(parentEntity.getRowId());
|
||||
});
|
||||
|
||||
|
||||
if (Objects.equals(createDTO.getOpType(), EbomEditStatusEnum.HANDLER_FINISHED.getValue())) {
|
||||
//工艺人员
|
||||
if (roleList.contains(EBomConstant.TECHNICIAN)) {
|
||||
parentEntity.setStatus(EBomStatusEnum.CHECKED.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
childEntities.addAll(updateOrCreateChild(createDTO));
|
||||
|
||||
}
|
||||
|
||||
List<BomNewEbomChildEntity> updateOrCreateChild(BomNewEBomParentEditDTO dto) {
|
||||
List<BomNewEbomChildEntity> childEntity = Convert.convert(new TypeReference<List<BomNewEbomChildEntity>>() {
|
||||
}, dto.getDatas());
|
||||
|
||||
|
||||
for (BomNewEbomChildEntity child :
|
||||
childEntity) {
|
||||
|
||||
child.setEditStatus(dto.getOpType());
|
||||
child.setTotalWeight(NumberUtil.mul(child.getUnitWeight(), child.getNum()));
|
||||
child.setModifyTime(LocalDateTime.now());
|
||||
|
||||
if (child.getMaterialName().contains(VirtualPackageTypeEnum.MAKING_PACKAGE.getConMaterialName())) {
|
||||
child.setVirtualPartType(VirtualPackageTypeEnum.MAKING_PACKAGE.getValue());
|
||||
child.setVirtualPartIs(1);
|
||||
|
||||
} else if (child.getMaterialName().contains(VirtualPackageTypeEnum.DELIVERY_PACKAGE.getConMaterialName())) {
|
||||
child.setVirtualPartType(VirtualPackageTypeEnum.DELIVERY_PACKAGE.getValue());
|
||||
child.setVirtualPartIs(1);
|
||||
} else if (child.getMaterialName().contains(VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getConMaterialName())) {
|
||||
child.setVirtualPartType(VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getValue());
|
||||
child.setVirtualPartIs(1);
|
||||
} else if (child.getMaterialName().contains(VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getConMaterialName())) {
|
||||
child.setVirtualPartType(VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getValue());
|
||||
child.setVirtualPartIs(1);
|
||||
}
|
||||
|
||||
|
||||
//新增数据
|
||||
if (child.getRowId() == null || child.getRowId().longValue() == 0) {
|
||||
child.setRowId(IdWorker.getId());
|
||||
child.setIdentityNo(StrUtil.join("_", parentEntity.getRowId(), child.getRowId()));
|
||||
child.setSource(source);
|
||||
child.setCreatedTime(LocalDateTime.now());
|
||||
child.setCreatedBy(SessionUtil.getUserCode());
|
||||
child.setSourceRowId(0l);
|
||||
child.setParentRowId(parentEntity.getRowId());
|
||||
if(StrUtil.isEmpty(child.getOrderNumber())){
|
||||
child.setOrderNumber("00");
|
||||
}
|
||||
child.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue());
|
||||
// parent.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue());
|
||||
checkExcept(dto.getParent(), child);
|
||||
if (StrUtil.isNotBlank(child.getProjectType())) {
|
||||
child.setProjectType(child.getProjectType().toUpperCase());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return childEntity;
|
||||
}
|
||||
|
||||
|
||||
private void checkExcept(BomNewEbomParentVO parent, BomNewEbomChildEntity child) {
|
||||
|
|
@ -127,32 +199,79 @@ public class EBomEdit {
|
|||
|
||||
}
|
||||
|
||||
void checkDataRule(BomNewEBomParentEditDTO dto){
|
||||
if(dto.getParent()==null){
|
||||
throw new NflgBusinessException(STATE.Error,"parent 数据不能为空");
|
||||
void checkDataRule(BomNewEBomParentEditDTO dto) {
|
||||
if (dto.getParent() == null) {
|
||||
throw new NflgBusinessException(STATE.Error, "parent 数据不能为空");
|
||||
}
|
||||
|
||||
if(CollUtil.isEmpty(dto.getDatas())){
|
||||
throw new NflgBusinessException(STATE.Error,"datas 数据不能为空");
|
||||
if (CollUtil.isEmpty(dto.getDatas())) {
|
||||
throw new NflgBusinessException(STATE.Error, "datas 数据不能为空");
|
||||
}
|
||||
|
||||
List<String> materialNos = dto.getDatas().stream().map(u -> u.getMaterialNo()).collect(Collectors.toList());
|
||||
if(materialNos.contains(dto.getParent().getMaterialNo())){
|
||||
VUtils.isTure(true).throwMessage(StrUtil.format("上下级存在相同物料{}",dto.getParent().getMaterialNo()));
|
||||
}
|
||||
materialNos.add(dto.getParent().getMaterialNo());
|
||||
//检查物料编码是否在主数据中存在
|
||||
List<BaseMaterialVO> materialBaseInfo = SpringUtil.getBean(MaterialMainService.class).getMaterialBaseInfo(materialNos);
|
||||
List<String> effectiveMaterialNos = materialBaseInfo.stream().map(u -> u.getMaterialNo()).collect(Collectors.toList());
|
||||
Set<String> difference = Sets.difference(new HashSet<>(materialNos), new HashSet<>(effectiveMaterialNos));
|
||||
VUtils.isTure(CollUtil.isNotEmpty(difference)).throwMessage(StrUtil.join(",", difference) + "在物料主数据中不存在");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void handleBom(BomNewEBomParentEditDTO dto) {
|
||||
checkDataRule(dto);
|
||||
//添加根节点数据
|
||||
//rowId is null 必定是未入库作为根
|
||||
if (dto.getParent().getRowId() == null || dto.getParent().getRowId().longValue() == 0) {
|
||||
createRootBom(dto);
|
||||
return;
|
||||
}
|
||||
|
||||
//缺bom
|
||||
if (dto.getParent().getBomRowId() == null || dto.getParent().getBomRowId().longValue() == 0) {
|
||||
|
||||
checkHadBom(dto.getParent().getMaterialNo());
|
||||
dto.getParent().setBomRowId(dto.getParent().getRowId());
|
||||
parentEntity = createParentBomInfo(dto.getParent());
|
||||
|
||||
dto.getDatas().forEach(k -> {
|
||||
k.setParentRowId(parentEntity.getRowId());
|
||||
});
|
||||
parentEntity.setEditStatus(dto.getOpType());
|
||||
|
||||
}else{
|
||||
parentEntity = Convert.convert(BomNewEbomParentEntity.class, dto.getParent());
|
||||
parentEntity.setModifyTime(LocalDateTime.now());
|
||||
}
|
||||
parentEntity.setEditStatus(dto.getOpType());
|
||||
//提交
|
||||
if (Objects.equals(dto.getOpType(), EbomEditStatusEnum.HANDLER_FINISHED.getValue())) {
|
||||
//工艺人员
|
||||
if (roleList.contains(EBomConstant.TECHNICIAN)) {
|
||||
parentEntity.setStatus(EBomStatusEnum.CHECKED.getValue());
|
||||
}
|
||||
}
|
||||
childEntities.addAll(updateOrCreateChild(dto));
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 废弃
|
||||
* @param dto
|
||||
*/
|
||||
@Deprecated
|
||||
public void temporary(BomNewEBomParentEditDTO dto) {
|
||||
|
||||
|
||||
checkDataRule(dto);
|
||||
|
||||
List<String> roleList = SpringUtil.getBean(UserRoleService.class).getUserPost();
|
||||
//添加数据
|
||||
if(dto.getParent().getRowId()==null){
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (dto.getParent() == null) {
|
||||
|
|
@ -226,7 +345,11 @@ public class EBomEdit {
|
|||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 废弃
|
||||
* @param dto
|
||||
*/
|
||||
@Deprecated
|
||||
public void submit(BomNewEBomParentEditDTO dto) {
|
||||
|
||||
|
||||
|
|
@ -256,7 +379,7 @@ public class EBomEdit {
|
|||
if (dto.getParent().getBomRowId() == null || dto.getParent().getBomRowId().longValue() == 0) {
|
||||
dto.getParent().setBomRowId(dto.getParent().getRowId());
|
||||
parent = createParentBomInfo(dto.getParent());
|
||||
dto.getDatas().forEach(k->{
|
||||
dto.getDatas().forEach(k -> {
|
||||
k.setParentRowId(parent.getRowId());
|
||||
});
|
||||
parent.setEditStatus(dto.getOpType());
|
||||
|
|
@ -305,7 +428,7 @@ public class EBomEdit {
|
|||
// parent.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue());
|
||||
checkExcept(dto.getParent(), child);
|
||||
|
||||
}else {
|
||||
} else {
|
||||
child.setModifyTime(LocalDateTime.now());
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue