1、ebom-工作列表通过物料编码可以查询到已发布的BOM

2、ebom-发起变更问题解决
This commit is contained in:
大米 2024-03-07 17:28:06 +08:00
parent ddc67786f9
commit 4c8f653b13
5 changed files with 104 additions and 60 deletions

View File

@ -199,7 +199,7 @@ public class PBomApi extends BaseApi {
@PostMapping("getAllocationFactoryBom") @PostMapping("getAllocationFactoryBom")
@ApiOperation("分工厂-获取BOM树") @ApiOperation("分工厂-获取BOM树")
public ResultVO<List<BomNewPbomParentVO> > getAllocationFactoryBom(@Valid @RequestBody AllocationFactoryBomQuery param ) throws ExecutionException, InterruptedException { public ResultVO<List<BomNewPbomParentVO> > getAllocationFactoryBom(@Valid @RequestBody AllocationFactoryBomQuery param ) throws ExecutionException, InterruptedException {
return ResultVO.success(bomNewPbomParentService.getAllocationFactoryBom(param)); return ResultVO.success(bomNewPbomParentService.getAllocationFactoryBomTree(param));
} }

View File

@ -63,4 +63,8 @@ public interface BomNewEbomParentMapper extends BaseMapper<BomNewEbomParentEntit
void delBatch(@Param("rowIds") List<Long> rowIds); void delBatch(@Param("rowIds") List<Long> rowIds);
void updateStateBatchByRowIds(@Param("status") Integer status, @Param("list") List<Long> list ); void updateStateBatchByRowIds(@Param("status") Integer status, @Param("list") List<Long> list );
Integer checkIsRoot(@Param("materialNo") String materialNo);
Integer checkIsUserRoot(@Param("materialNo")String materialNo, @Param("jobNo")String jobNo);
} }

View File

@ -704,6 +704,8 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
if (CollUtil.isNotEmpty(eBomToPBom.getPBomChildResult())) { if (CollUtil.isNotEmpty(eBomToPBom.getPBomChildResult())) {
pBomChildService.saveOrUpdateBatch(eBomToPBom.getPBomChildResult()); pBomChildService.saveOrUpdateBatch(eBomToPBom.getPBomChildResult());
} }
//标记跟节点
upRootMark(parent);
if (CollUtil.isNotEmpty(eBomToPBom.getVirtualPackageCompositionResult())) { if (CollUtil.isNotEmpty(eBomToPBom.getVirtualPackageCompositionResult())) {
//先删除 //先删除
Set<String> delSet = eBomToPBom.getVirtualPackageCompositionResult().stream().map(u -> StrUtil.join("-", u.getVirtualPackageMaterialNo(), u.getParentMaterialNo())).collect(Collectors.toSet()); Set<String> delSet = eBomToPBom.getVirtualPackageCompositionResult().stream().map(u -> StrUtil.join("-", u.getVirtualPackageMaterialNo(), u.getParentMaterialNo())).collect(Collectors.toSet());
@ -754,6 +756,18 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
} }
} }
private void upRootMark(BomNewEbomParentVO parent){
Integer rootIs = this.getBaseMapper().checkIsRoot(parent.getMaterialNo());
Integer userRootIs=this.getBaseMapper().checkIsUserRoot(parent.getMaterialNo(),parent.getCreatedBy());
BomNewEbomParentEntity ebomParent=new BomNewEbomParentEntity();
ebomParent.setRowId(parent.getRowId());
ebomParent.setRootIs(rootIs>0?0:1);
ebomParent.setUserRootIs(userRootIs>0?0:1);
this.updateById(ebomParent);
}
/** /**
* 发起变更 * 发起变更
* *
@ -764,15 +778,19 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
List<BomNewEbomParentEntity> list = this.lambdaQuery().in(BomNewEbomParentEntity::getRowId, paramDTO.getBomRowIds()).list(); List<BomNewEbomParentEntity> list = this.lambdaQuery().in(BomNewEbomParentEntity::getRowId, paramDTO.getBomRowIds()).list();
List<String> notConvertToPbom = list.stream().filter(u -> u.getStatus() < EBomStatusEnum.PUBLISHED.getValue()).map(u -> u.getMaterialNo()).collect(Collectors.toList()); List<String> notConvertToPbom = list.stream().filter(u -> u.getStatus() < EBomStatusEnum.PUBLISHED.getValue()).map(u -> u.getMaterialNo()).collect(Collectors.toList());
VUtils.isTure(CollUtil.isNotEmpty(notConvertToPbom)).throwMessage(StrUtil.join(",", notConvertToPbom) + "未转PBom,不能发起变更"); VUtils.isTure(CollUtil.isNotEmpty(notConvertToPbom)).throwMessage(StrUtil.join(",", notConvertToPbom) + "未转PBom,不能发起变更");
//检查是否存在发布前的版本有则不能发起变更
List<String> materialNos = list.stream().map(u -> u.getMaterialNo()).collect(Collectors.toList());
List<BomNewEbomParentEntity> existEnt = this.lambdaQuery().in(BomNewEbomParentEntity::getMaterialNo, materialNos).lt(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue()).list();
Set<String> existMaterialNos = existEnt.stream().map(u -> u.getMaterialNo()).collect(Collectors.toSet());
VUtils.isTure(CollUtil.isNotEmpty(existMaterialNos)).throwMessage(StrUtil.join(",", existMaterialNos, "存在发布前版本。"));
List<BomNewEbomParentEntity> parentResult = new ArrayList<>(); List<BomNewEbomParentEntity> parentResult = new ArrayList<>();
List<BomNewEbomChildEntity> childResult = new ArrayList<>(); List<BomNewEbomChildEntity> childResult = new ArrayList<>();
for (Long bomRowId : paramDTO.getBomRowIds()) { for (Long bomRowId : paramDTO.getBomRowIds()) {
BomNewEbomParentEntity parent = this.getById(bomRowId); BomNewEbomParentEntity parent = this.getById(bomRowId);
LogRecordContext.putVariable("bom", parent); LogRecordContext.putVariable("bom", parent);
List<BomNewEbomParentEntity> existEnt = this.lambdaQuery().eq(BomNewEbomParentEntity::getMaterialNo, parent.getMaterialNo()).lt(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue()).list();
//含发布前版本则无需升级
if (CollUtil.isEmpty(existEnt)) {
List<BomNewEbomChildEntity> child = ebomChildService.lambdaQuery().eq(BomNewEbomChildEntity::getParentRowId, bomRowId).list(); List<BomNewEbomChildEntity> child = ebomChildService.lambdaQuery().eq(BomNewEbomChildEntity::getParentRowId, bomRowId).list();
BomNewEbomParentEntity newParent = new BomNewEbomParentEntity(); BomNewEbomParentEntity newParent = new BomNewEbomParentEntity();
BeanUtil.copyProperties(parent, newParent); BeanUtil.copyProperties(parent, newParent);
@ -783,6 +801,8 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
newParent.setChangeDesc(paramDTO.getChangeDesc()); newParent.setChangeDesc(paramDTO.getChangeDesc());
newParent.setNoticeNums(paramDTO.getNoticeNums()); newParent.setNoticeNums(paramDTO.getNoticeNums());
newParent.setStatus(EBomStatusEnum.WAIT_CHECK.getValue()); newParent.setStatus(EBomStatusEnum.WAIT_CHECK.getValue());
newParent.setRootIs(1);
newParent.setUserRootIs(1);
parent.setLastVersionIs(0); parent.setLastVersionIs(0);
parentResult.add(newParent); parentResult.add(newParent);
parentResult.add(parent); parentResult.add(parent);
@ -793,7 +813,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
newChild.setParentRowId(newParent.getRowId()); newChild.setParentRowId(newParent.getRowId());
childResult.add(newChild); childResult.add(newChild);
} }
}
} }
if (CollUtil.isNotEmpty(parentResult)) { if (CollUtil.isNotEmpty(parentResult)) {
@ -1274,7 +1294,6 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
BomNewEbomParentVO parentVO = Convert.convert(BomNewEbomParentVO.class, parent); BomNewEbomParentVO parentVO = Convert.convert(BomNewEbomParentVO.class, parent);
parentVO.setBomRowId(parentVO.getRowId()); parentVO.setBomRowId(parentVO.getRowId());
parentVO.setParentRowId(0l); parentVO.setParentRowId(0l);
parentVO.setProjectType(projectType); parentVO.setProjectType(projectType);
@ -1282,8 +1301,6 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
materialMainService.intiMaterialInfo(ImmutableList.of(parentVO), EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT2); materialMainService.intiMaterialInfo(ImmutableList.of(parentVO), EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT2);
// materialMainService.intiMaterialInfo(ImmutableList.of(parentVO)); // materialMainService.intiMaterialInfo(ImmutableList.of(parentVO));
@ -1443,6 +1460,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
/** /**
* 2. 只有含有BOM的物料才可以打超级物料的标签如果不存在下级BOM时不可以打标 * 2. 只有含有BOM的物料才可以打超级物料的标签如果不存在下级BOM时不可以打标
* 3. 需求编辑页面需要添加一个是否为超级物料的选项属于一个打标签的功能 * 3. 需求编辑页面需要添加一个是否为超级物料的选项属于一个打标签的功能
*
* @param datas * @param datas
*/ */
private void superMaterialStatus(List<BomNewEbomParentVO> datas) { private void superMaterialStatus(List<BomNewEbomParentVO> datas) {

View File

@ -592,10 +592,16 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
return CTreePBomUtils.toTree(bomRowId, allBom, BomNewPbomParentVO::getParentRowId, BomNewPbomParentVO::getBomRowId); return CTreePBomUtils.toTree(bomRowId, allBom, BomNewPbomParentVO::getParentRowId, BomNewPbomParentVO::getBomRowId);
} }
public List<BomNewPbomParentVO> getAllocationFactoryBomTree(AllocationFactoryBomQuery param) throws ExecutionException, InterruptedException {
List<BomNewPbomParentVO> allBom = getAllBom(param.getBomRowId(), 0);
materialMainService.intiMaterialInfo(allBom, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
return CTreePBomUtils.toTree(param.getBomRowId(), allBom, BomNewPbomParentVO::getParentRowId, BomNewPbomParentVO::getBomRowId);
}
public List<BomNewPbomParentVO> getAllocationFactoryBom(AllocationFactoryBomQuery param) throws ExecutionException, InterruptedException { public List<BomNewPbomParentVO> getAllocationFactoryBom(AllocationFactoryBomQuery param) throws ExecutionException, InterruptedException {
List<BomNewPbomParentVO> allBom = getAllBom(param.getBomRowId(), 1); List<BomNewPbomParentVO> allBom = getAllBom(param.getBomRowId(), 1);
materialMainService.intiMaterialInfo(allBom, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT); materialMainService.intiMaterialInfo(allBom, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
return CTreePBomUtils.toTree(param.getBomRowId(), allBom, BomNewPbomParentVO::getParentRowId, BomNewPbomParentVO::getBomRowId);
} }
@ -621,7 +627,10 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
}else { }else {
params.getData().forEach(k->{ params.getData().forEach(k->{
try { try {
List<BomNewPbomParentVO> allBom = this.getAllBomTree(k.getBomRowId()); AllocationFactoryBomQuery query=new AllocationFactoryBomQuery();
query.setBomRowId(k.getBomRowId());
List<BomNewPbomParentVO> allBom = this.getAllocationFactoryBom(query);
List<Long> rowIds =new ArrayList<>(); List<Long> rowIds =new ArrayList<>();
rowIds.add(k.getRowId()); rowIds.add(k.getRowId());
rowIds.addAll(allBom.stream().map(u -> u.getRowId()).collect(Collectors.toList())); rowIds.addAll(allBom.stream().map(u -> u.getRowId()).collect(Collectors.toList()));

View File

@ -95,7 +95,7 @@
<!--物料编码搜索-父级--> <!--物料编码搜索-父级-->
<select id="getParentForMaterialNoSeach" resultType="com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO"> <select id="getParentForMaterialNoSeach" resultType="com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO">
SELECT created_by as bomCreatedBy , row_id as bomRowId, row_id as childBomRowId, a.* SELECT created_by as bomCreatedBy , row_id as bomRowId, row_id as childBomRowId, a.*
FROM t_bom_new_ebom_parent a where a.last_version_is=1 and material_no in FROM t_bom_new_ebom_parent a where a.last_version_is=1 and a.status &lt; 4 and material_no in
<foreach collection="materialNoList" item="item" open="(" separator="," close=")"> <foreach collection="materialNoList" item="item" open="(" separator="," close=")">
#{item} #{item}
</foreach> </foreach>
@ -108,7 +108,7 @@
from t_bom_new_ebom_parent a from t_bom_new_ebom_parent a
join t_bom_new_ebom_child b on a.row_id =b.parent_row_id join t_bom_new_ebom_child b on a.row_id =b.parent_row_id
left join t_bom_new_ebom_parent c on b.material_no=c.material_no and c.last_version_is=1 left join t_bom_new_ebom_parent c on b.material_no=c.material_no and c.last_version_is=1
where a.last_version_is=1 and ( b.material_no in where a.last_version_is=1 and a.status &lt; 4 and ( b.material_no in
<foreach collection="materialNoList" item="item" open="(" separator="," close=")"> <foreach collection="materialNoList" item="item" open="(" separator="," close=")">
#{item} #{item}
</foreach> </foreach>
@ -215,4 +215,17 @@
#{item} #{item}
</foreach> </foreach>
</update> </update>
<!--检查是否已发布数据的跟节点-->
<select id="checkIsRoot" resultType="java.lang.Integer">
select COUNT(1) from t_bom_new_ebom_parent a join t_bom_new_ebom_child b on a.row_id=b.parent_row_id and a.`status`=4 and a.last_version_is=1
and b.material_no=#{materialNo}
</select>
<!--检查是否已发布数据的用户跟节点-->
<select id="checkIsUserRoot" resultType="java.lang.Integer">
select COUNT(1) from t_bom_new_ebom_parent a join t_bom_new_ebom_child b on a.row_id=b.parent_row_id and a.`status`=4 and a.last_version_is=1
and b.material_no=#{materialNo} and b.created_by=#{jobNo}
</select>
</mapper> </mapper>