1、Pbom问题处理
This commit is contained in:
parent
b0e36ecb7d
commit
a8d70e3784
|
|
@ -45,4 +45,8 @@ public interface BomNewPbomParentMapper extends BaseMapper<BomNewPbomParentEntit
|
|||
|
||||
List<BomNewPbomParentVO> getChildForMaterialNoSeach(@Param("userFac") String userFac,@Param("materialNoList") List<String> materialNoList,@Param("materialNo")String materialNo);
|
||||
|
||||
|
||||
Integer checkIsRoot(@Param("materialNo")String materialNo);
|
||||
|
||||
Integer checkIsUserRoot(@Param("materialNo") String materialNo, @Param("jobNo") String jobNo);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -886,6 +886,8 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|||
|
||||
//检查物料是否被冻结
|
||||
materialMainService.checkMaterialFreeze(allBom);
|
||||
//更新root标志
|
||||
upRootMark(parent);
|
||||
|
||||
List<Long> bomRowIds = allBom.stream().filter(u -> PBomStatusEnum.WAIT_PUBLISH.equalsValue(u.getStatus()) && u.getBomRowId() > 0).map(u -> u.getBomRowId()).collect(Collectors.toList());
|
||||
Integer state = (parent.getMaterialNo().startsWith("31") && parent.getFacCode().equals(EBomConstant.MAIN_FACTORY_CODE_1010)) ? PBomStatusEnum.WAIT_FACTORY.getValue() : PBomStatusEnum.PUBLISH.getValue();
|
||||
|
|
@ -914,6 +916,16 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|||
|
||||
}
|
||||
|
||||
private void upRootMark(BomNewPbomParentEntity parent){
|
||||
Integer rootIs = this.getBaseMapper().checkIsRoot(parent.getMaterialNo());
|
||||
Integer userRootIs=this.getBaseMapper().checkIsUserRoot(parent.getMaterialNo(),parent.getCreatedBy());
|
||||
parent.setRootIs(rootIs>0?0:1);
|
||||
parent.setUserRootIs(userRootIs>0?0:1);
|
||||
this.updateById(parent);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void importSap(BomNewPbomParentEntity parent, List<BomNewPbomParentVO> children) {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,17 @@
|
|||
package com.nflg.product.bomnew.service.domain.PBom;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.nflg.product.base.core.conmon.util.SessionUtil;
|
||||
import com.nflg.product.bomnew.constant.PBomStatusEnum;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewPbomChildEntity;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewPbomParentEntity;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomNewPbomParentVO;
|
||||
import com.nflg.product.bomnew.service.BomNewPbomParentService;
|
||||
import com.nflg.product.bomnew.util.VUtils;
|
||||
import com.nflg.product.bomnew.util.VersionUtil;
|
||||
import lombok.Getter;
|
||||
|
||||
|
|
@ -15,12 +19,14 @@ import java.time.LocalDateTime;
|
|||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.nflg.product.bomnew.util.ListCommonUtil;
|
||||
|
||||
/**
|
||||
* 升级变更
|
||||
*/
|
||||
public class PBomUpgrade {
|
||||
|
||||
private BomNewPbomParentEntity root;
|
||||
private BomNewPbomParentEntity root;
|
||||
|
||||
private List<BomNewPbomParentVO> allBom;
|
||||
|
||||
|
|
@ -31,44 +37,66 @@ public class PBomUpgrade {
|
|||
private List<BomNewPbomChildEntity> childResult;
|
||||
|
||||
|
||||
public PBomUpgrade (BomNewPbomParentEntity root,List<BomNewPbomParentVO> allBom) {
|
||||
public PBomUpgrade(BomNewPbomParentEntity root, List<BomNewPbomParentVO> allBom) {
|
||||
this.root = root;
|
||||
this.allBom = allBom;
|
||||
BomNewPbomParentVO rootVo = Convert.convert(BomNewPbomParentVO.class, root);
|
||||
rootVo.setBomRowId(rootVo.getRowId());
|
||||
allBom.add(rootVo);
|
||||
|
||||
//allBom.add(rootVo);
|
||||
|
||||
}
|
||||
|
||||
public void upgrade(){
|
||||
public void upgrade() {
|
||||
//
|
||||
for (BomNewPbomParentVO parentEnt :allBom) {
|
||||
if( parentEnt.getStatus()>=PBomStatusEnum.PUBLISH.getValue()) {
|
||||
buildParent(parentEnt);
|
||||
}
|
||||
check();
|
||||
//处理根节点
|
||||
BomNewPbomParentVO rootVo = Convert.convert(BomNewPbomParentVO.class, root);
|
||||
rootVo.setBomRowId(rootVo.getRowId());
|
||||
|
||||
buildParent(rootVo,true);
|
||||
|
||||
List<BomNewPbomParentVO> parents = allBom.stream().filter(u -> u.getBomRowId() > 0).collect(Collectors.toList());
|
||||
List<BomNewPbomParentVO> distinctParents = ListCommonUtil.toDistinct(parents, BomNewPbomParentVO::getBomRowId);
|
||||
for (BomNewPbomParentVO parentEnt : distinctParents) {
|
||||
if (parentEnt.getStatus() >= PBomStatusEnum.PUBLISH.getValue()) {
|
||||
buildParent(parentEnt,false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buildParent(BomNewPbomParentVO parentVO){
|
||||
BomNewPbomParentEntity pbomParent=new BomNewPbomParentEntity();
|
||||
BeanUtil.copyProperties(parentVO,pbomParent);
|
||||
/**
|
||||
* 父表-不能有待发布的Pbom
|
||||
*/
|
||||
private void check() {
|
||||
List<BomNewPbomParentEntity> waitPublishList = SpringUtil.getBean(BomNewPbomParentService.class).lambdaQuery().eq(BomNewPbomParentEntity::getMaterialNo, root.getMaterialNo())
|
||||
.eq(BomNewPbomParentEntity::getFacCode, root.getMaterialNo())
|
||||
.lt(BomNewPbomParentEntity::getStatus, PBomStatusEnum.PUBLISH.getValue()).list();
|
||||
VUtils.isTure(CollUtil.isNotEmpty(waitPublishList)).throwMessage(root.getMaterialNo() + "存在待发布的版本,无法升级");
|
||||
}
|
||||
|
||||
private void buildParent(BomNewPbomParentVO parentVO, boolean rootIs) {
|
||||
BomNewPbomParentEntity pbomParent = new BomNewPbomParentEntity();
|
||||
BeanUtil.copyProperties(parentVO, pbomParent);
|
||||
pbomParent.setRowId(IdWorker.getId());
|
||||
pbomParent.setCreatedTime(LocalDateTime.now());
|
||||
pbomParent.setCreatedBy(SessionUtil.getRealName());
|
||||
pbomParent.setModifyTime(LocalDateTime.now());
|
||||
pbomParent.setStatus(PBomStatusEnum.WAIT_PUBLISH.getValue());
|
||||
pbomParent.setCurrentVersion(VersionUtil.getNextVersion(parentVO.getCurrentVersion()));
|
||||
if (rootIs) {
|
||||
pbomParent.setRootIs(1);
|
||||
pbomParent.setUserRootIs(1);
|
||||
}
|
||||
this.parentResult.add(pbomParent);
|
||||
|
||||
buildChild(parentVO,pbomParent);
|
||||
buildChild(parentVO, pbomParent);
|
||||
}
|
||||
|
||||
private void buildChild(BomNewPbomParentVO oldParent, BomNewPbomParentEntity newParent){
|
||||
private void buildChild(BomNewPbomParentVO oldParent, BomNewPbomParentEntity newParent) {
|
||||
|
||||
List<BomNewPbomParentVO> chilren = allBom.stream().filter(u -> u.getParentRowId().equals(oldParent.getBomRowId())).collect(Collectors.toList());
|
||||
for (BomNewPbomParentVO childVO : chilren) {
|
||||
BomNewPbomChildEntity child=new BomNewPbomChildEntity();
|
||||
BeanUtil.copyProperties(childVO,child);
|
||||
BomNewPbomChildEntity child = new BomNewPbomChildEntity();
|
||||
BeanUtil.copyProperties(childVO, child);
|
||||
child.setRowId(IdWorker.getId());
|
||||
child.setParentRowId(newParent.getRowId());
|
||||
child.setCreatedTime(LocalDateTime.now());
|
||||
|
|
@ -82,5 +110,4 @@ public class PBomUpgrade {
|
|||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -201,6 +201,18 @@
|
|||
</select>
|
||||
|
||||
|
||||
<!--检查是否已发布数据的跟节点-->
|
||||
<select id="checkIsRoot" resultType="java.lang.Integer">
|
||||
select COUNT(1) from t_bom_new_pbom_parent a join t_bom_new_pbom_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_pbom_parent a join t_bom_new_pbom_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>
|
||||
|
|
|
|||
Loading…
Reference in New Issue