Merge branch 'refs/heads/feature/DM/nflg-bom' into dev

# Conflicts:
#	nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/mapper/master/BomNewEbomParentMapper.java
#	nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/mapper/master/BomNewOriginalParentMapper.java
#	nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewOriginalParentService.java
#	nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewEbomParentMapper.xml
#	nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewOriginalParentMapper.xml
This commit is contained in:
曹鹏飞 2024-04-13 20:20:05 +08:00
commit a655f0e745
9 changed files with 356 additions and 182 deletions

View File

@ -4,12 +4,11 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity; import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity;
import com.nflg.product.bomnew.pojo.query.BomNewEbomParentQuery; import com.nflg.product.bomnew.pojo.query.BomNewEbomParentQuery;
import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO; import com.nflg.product.bomnew.pojo.query.OriginalBomQuery;
import com.nflg.product.bomnew.pojo.vo.BomNewEbomUpgradeChangeVO; import com.nflg.product.bomnew.pojo.vo.*;
import com.nflg.product.bomnew.pojo.vo.MaterialHistoryProjectTypeVO;
import com.nflg.product.bomnew.pojo.vo.ReverseReportVO;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@ -53,9 +52,9 @@ public interface BomNewEbomParentMapper extends BaseMapper<BomNewEbomParentEntit
Set<String> getSelfParentMaterialNo(@Param("createdBy") String createdBy ,@Param("list") Set<String> list); Set<String> getSelfParentMaterialNo(@Param("createdBy") String createdBy ,@Param("list") Set<String> list);
List<BomNewEbomParentVO> getParentForMaterialNoSeach(@Param("materialNoList") List<String> materialNoList ,@Param("dataType") Integer dataType); List<BomNewEbomParentVO> getParentForMaterialNoSeach(@Param("materialNoList") List<String> materialNoList ,@Param("dataType") Integer dataType , @Param("createdBy") String createdBy);
List<BomNewEbomParentVO> getChildForMaterialNoSeach(@Param("materialNoList") List<String> materialNoList,@Param("materialNo") String materialNo,@Param("dataType") Integer dataType ); List<BomNewEbomParentVO> getChildForMaterialNoSeach(@Param("materialNoList") List<String> materialNoList,@Param("bomRowIds") Collection<Long> bomRowIds , @Param("createdBy") String createdBy );
void updateRootState(); void updateRootState();
@ -73,4 +72,6 @@ public interface BomNewEbomParentMapper extends BaseMapper<BomNewEbomParentEntit
void updateRootForWaitReview(); void updateRootForWaitReview();
void resetBomExist(Long rowId); void resetBomExist(Long rowId);
Set<String> getMaterialParent(@Param("materialNos") Collection<String> materialNos ,@Param("createdBy") String createdBy);
} }

View File

@ -7,6 +7,7 @@ import com.nflg.product.bomnew.pojo.query.OriginalBomQuery;
import com.nflg.product.bomnew.pojo.vo.BomOriginalListVO; import com.nflg.product.bomnew.pojo.vo.BomOriginalListVO;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@ -58,9 +59,16 @@ public interface BomNewOriginalParentMapper extends BaseMapper<BomNewOriginalPar
* @param InHasConvertBomIs * @param InHasConvertBomIs
* @return * @return
*/ */
List<BomOriginalListVO> getParentForDrawingNoSeach(@Param("drawingNos") Set<String> drawingNos, @Param("state") Integer state); List<BomOriginalListVO> getParentForDrawingNoSeach(@Param("drawingNos") List<String> drawingNos ,@Param("state") Integer state);
List<BomOriginalListVO> getChildForDrawingNoSeach(@Param("drawingNos") Set<String> drawingNos, @Param("state") Integer state); List<BomOriginalListVO> getChildForDrawingNoSeach(@Param("drawingNos") List<String> drawingNos,@Param("bomRowIds") Collection<Long> bomRowIds);
/**
* 获取父级图号
* @param drawingNos
* @return
*/
Set<String> getMaterialParent(@Param("drawingNos") Collection<String> drawingNos);
void resetBomExist(Long rowId); void resetBomExist(Long rowId);

View File

@ -124,12 +124,18 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
return returnResult; return returnResult;
} }
List<String> materialNos = new ArrayList<>(); List<String> materialNos = new ArrayList<>();
List<String> parentMaterialByMaterialNo = getParentMaterialByMaterialNo(materialNo, !userRoleService.technician()).stream().collect(Collectors.toList()); // List<String> parentMaterialByMaterialNo = getParentMaterialByMaterialNo(materialNo, !userRoleService.technician()).stream().collect(Collectors.toList());
materialNos.add(materialNo); //获取父级物料
Boolean getSelfIs=!userRoleService.technician();
List<String> parentMaterialByMaterialNo = getParentMaterial(ImmutableList.of(materialNo),(getSelfIs && query.getDataType().equals(0) ) ).stream().collect(Collectors.toList());
// materialNos.add(materialNo);
materialNos.addAll(parentMaterialByMaterialNo); materialNos.addAll(parentMaterialByMaterialNo);
if (CollUtil.isNotEmpty(materialNos)) { if (CollUtil.isNotEmpty(materialNos)) {
List<BomNewEbomParentVO> parents = this.getBaseMapper().getParentForMaterialNoSeach(materialNos, query.getDataType()); List<BomNewEbomParentVO> childs=new ArrayList<>();
List<BomNewEbomParentVO> childs = this.getBaseMapper().getChildForMaterialNoSeach(materialNos, materialNo, query.getDataType()); List<BomNewEbomParentVO> parents = this.getBaseMapper().getParentForMaterialNoSeach(materialNos, query.getDataType() ,(getSelfIs && query.getDataType().equals(0) )?SessionUtil.getUserCode():null );
if(CollUtil.isNotEmpty(parents)) {
childs = this.getBaseMapper().getChildForMaterialNoSeach(materialNos, parents.stream().map(u -> u.getRowId()).collect(Collectors.toSet()), (getSelfIs && query.getDataType().equals(0)) ? SessionUtil.getUserCode() : null);
}
List<BomNewEbomParentVO> data = new ArrayList<>(); List<BomNewEbomParentVO> data = new ArrayList<>();
data.addAll(parents); data.addAll(parents);
data.addAll(childs); data.addAll(childs);
@ -221,6 +227,32 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
return result; return result;
} }
/**
* 获取父级物料 (包含查询物料本身)
*
* @param materialNoList
* @param bomType
* @return
*/
public List<String> getParentMaterial(List<String> materialNoList, Boolean bomType) {
Set<String> result = new HashSet<>();
result.addAll(materialNoList);
Set<String> useMaterialSku = this.getBaseMapper().getMaterialParent(materialNoList, bomType ? SessionUtil.getUserCode() : null);
while (CollUtil.isNotEmpty(useMaterialSku)) {
//防止数据错误循环依赖-死循环
Set<String> difference = Sets.difference(useMaterialSku, result);
if (CollUtil.isNotEmpty(difference)) {
useMaterialSku = this.getBaseMapper().getMaterialParent(difference, bomType ? SessionUtil.getUserCode() : null);
result.addAll(difference);
} else {
break;
}
}
return new ArrayList<>(result);
}
/** /**
* 批量获取物料所有父节点 * 批量获取物料所有父节点
@ -267,6 +299,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
public Page<BomNewEbomParentVO> formalWorksheet(BomNewEbomParentQuery query) { public Page<BomNewEbomParentVO> formalWorksheet(BomNewEbomParentQuery query) {
Page<BomNewEbomParentVO> result = this.getBaseMapper().formalWorksheet(new Page<>(query.getPage(), query.getPageSize()), query); Page<BomNewEbomParentVO> result = this.getBaseMapper().formalWorksheet(new Page<>(query.getPage(), query.getPageSize()), query);
if (CollUtil.isNotEmpty(result.getRecords())) { if (CollUtil.isNotEmpty(result.getRecords())) {
materialMainService.intiMaterialInfo(result.getRecords()); materialMainService.intiMaterialInfo(result.getRecords());
} }
@ -302,12 +335,12 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
List<String> materialNos = parentChild.stream().filter(u -> StrUtil.isNotBlank(u.getMaterialNo())).map(u -> u.getMaterialNo()).collect(Collectors.toList()); List<String> materialNos = parentChild.stream().filter(u -> StrUtil.isNotBlank(u.getMaterialNo())).map(u -> u.getMaterialNo()).collect(Collectors.toList());
if (CollUtil.isNotEmpty(materialNos)) { if (CollUtil.isNotEmpty(materialNos)) {
List<BomNewEbomParentEntity> list = this.lambdaQuery().in(BomNewEbomParentEntity::getMaterialNo, materialNos) List<BomNewEbomParentEntity> list = this.lambdaQuery().in(BomNewEbomParentEntity::getMaterialNo, materialNos)
.eq(!EBomStatusEnum.PUBLISHED.equalsValue(parent.getStatus()) ,BomNewEbomParentEntity::getLastVersionIs, 1) .eq(!EBomStatusEnum.PUBLISHED.equalsValue(parent.getStatus()), BomNewEbomParentEntity::getLastVersionIs, 1)
.eq(EBomStatusEnum.PUBLISHED.equalsValue(parent.getStatus()), BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue()).list(); .eq(EBomStatusEnum.PUBLISHED.equalsValue(parent.getStatus()), BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue()).list();
if(EBomStatusEnum.CHECKED.equalsValue(parent.getStatus())){ if (EBomStatusEnum.CHECKED.equalsValue(parent.getStatus())) {
list=list.stream().filter(u->EBomStatusEnum.CHECKED.equalsValue(u.getStatus())).collect(Collectors.toList()); list = list.stream().filter(u -> EBomStatusEnum.CHECKED.equalsValue(u.getStatus())).collect(Collectors.toList());
} }
Map<String, BomNewEbomParentEntity> bomListMap= list.parallelStream() Map<String, BomNewEbomParentEntity> bomListMap = list.parallelStream()
.collect(Collectors.toMap( .collect(Collectors.toMap(
BomNewEbomParentEntity::getMaterialNo, // key: DrawingNo BomNewEbomParentEntity::getMaterialNo, // key: DrawingNo
Function.identity(), Function.identity(),
@ -377,6 +410,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
/** /**
* 生成虚拟包时-获取子级 * 生成虚拟包时-获取子级
*
* @param rowId * @param rowId
* @return * @return
*/ */
@ -392,7 +426,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
List<BomNewEbomParentEntity> list = this.lambdaQuery().in(BomNewEbomParentEntity::getMaterialNo, materialNos) List<BomNewEbomParentEntity> list = this.lambdaQuery().in(BomNewEbomParentEntity::getMaterialNo, materialNos)
.eq(BomNewEbomParentEntity::getLastVersionIs, 1).list(); .eq(BomNewEbomParentEntity::getLastVersionIs, 1).list();
Map<String, BomNewEbomParentEntity> bomListMap= list.parallelStream() Map<String, BomNewEbomParentEntity> bomListMap = list.parallelStream()
.collect(Collectors.toMap( .collect(Collectors.toMap(
BomNewEbomParentEntity::getMaterialNo, // key: DrawingNo BomNewEbomParentEntity::getMaterialNo, // key: DrawingNo
Function.identity(), Function.identity(),
@ -744,23 +778,27 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
public void generateVirtualPackage(VirtualPackageParamDto paramDto) throws IOException { public void generateVirtualPackage(VirtualPackageParamDto paramDto) throws IOException {
BomNewEbomParentEntity root = this.getById(paramDto.getBomRowId()); BomNewEbomParentEntity root = this.getById(paramDto.getBomRowId());
VUtils.isTure(Objects.isNull(root)).throwMessage("Bom不存在"); VUtils.isTure(Objects.isNull(root)).throwMessage("Bom不存在");
//初始化虚拟包-判断枚举不是手工生成虚拟包的情况
checkAndInitVirtualPackageEnum(paramDto, root);
VUtils.isTure(root.getVirtrualPackageEnum() > 0).throwMessage("已生成过虚拟包不能2次生成");
VUtils.isTure(!Objects.equals(root.getExceptionStatus(), EBomExceptionStatusEnum.OK.getValue())) VUtils.isTure(!Objects.equals(root.getExceptionStatus(), EBomExceptionStatusEnum.OK.getValue()))
.throwMessage("异常状态下不允许生成虚拟包"); .throwMessage("异常状态下不允许生成虚拟包");
LogRecordContext.putVariable("gvbom", root); LogRecordContext.putVariable("gvbom", root);
//初始化虚拟包-判断枚举不是手工生成虚拟包的情况
checkAndInitVirtualPackageEnum(paramDto, root); // Boolean flag = true;
Boolean flag = true; // for (Integer f : paramDto.getVirtualPackageValue()) {
for (Integer f : paramDto.getVirtualPackageValue()) { // flag = flag & ((root.getVirtrualPackageEnum() & f) == f);
flag = flag & ((root.getVirtrualPackageEnum() & f) == f); // }
} // VUtils.isTure(flag).throwMessage("已生成虚拟包,无需重复生成");
VUtils.isTure(flag).throwMessage("已生成虚拟包,无需重复生成");
BomNewEbomParentVO parent = Convert.convert(BomNewEbomParentVO.class, root); BomNewEbomParentVO parent = Convert.convert(BomNewEbomParentVO.class, root);
materialMainService.intiMaterialInfo(ImmutableList.of(parent), BomNewEbomParentVO::getMaterialNo); materialMainService.intiMaterialInfo(ImmutableList.of(parent), BomNewEbomParentVO::getMaterialNo);
if (parent.getMaterialCategoryCode().startsWith("30") || ImmutableList.of("200601","200401").contains(parent.getMaterialCategoryCode())) { if (parent.getMaterialCategoryCode().startsWith("30") || ImmutableList.of("200601", "200401").contains(parent.getMaterialCategoryCode())) {
VirtualPackageBase generate; VirtualPackageBase generate;
if (parent.getMaterialCategoryCode().startsWith("30")) { if (parent.getMaterialCategoryCode().startsWith("30")) {
generate = new VirtualPackageFor31(paramDto.getBomRowId(), paramDto.getVirtualPackageValue()); generate = new VirtualPackageFor31(paramDto.getBomRowId(), paramDto.getVirtualPackageValue());
@ -935,11 +973,11 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
public void editExportBom(EbomEditExportDTO param, OutputStream response) throws IOException { public void editExportBom(EbomEditExportDTO param, OutputStream response) throws IOException {
List<BomNewEbomParentVO> result=param.getList(); List<BomNewEbomParentVO> result = param.getList();
if(CollUtil.isEmpty(param.getList())){ if (CollUtil.isEmpty(param.getList())) {
result=getChild(param.getBomRowId()); result = getChild(param.getBomRowId());
} }
final ListSheet<EbomExcelEditVO> listSheet = new ListSheet<EbomExcelEditVO>(Convert.toList(EbomExcelEditVO.class,result) ); final ListSheet<EbomExcelEditVO> listSheet = new ListSheet<EbomExcelEditVO>(Convert.toList(EbomExcelEditVO.class, result));
EecExcelUtil.eecExcel("bom列表", listSheet, response); EecExcelUtil.eecExcel("bom列表", listSheet, response);
} }
@ -1024,7 +1062,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
parentVO.setParentRowId(0l); parentVO.setParentRowId(0l);
//原始bom强制追加 //原始bom强制追加
if(ObjectUtil.equal(EBomSourceEnum.FROM_BOM.getValue(),parentVO.getSource())){ if (ObjectUtil.equal(EBomSourceEnum.FROM_BOM.getValue(), parentVO.getSource())) {
dto.setOpType(EBomConstant.EBomExcelImportEnum.IMPORT_TYPE_APPEND.getValue()); dto.setOpType(EBomConstant.EBomExcelImportEnum.IMPORT_TYPE_APPEND.getValue());
} }
@ -1044,8 +1082,8 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|| parentVO.getSource().equals(EBomSourceEnum.FROM_EXCE.getValue()))) { || parentVO.getSource().equals(EBomSourceEnum.FROM_EXCE.getValue()))) {
// deleteBom(dto.getRowId()); // deleteBom(dto.getRowId());
//当前bom下列表数据 //当前bom下列表数据
QueryWrapper<BomNewEbomChildEntity > delWrapper=new QueryWrapper<>(); QueryWrapper<BomNewEbomChildEntity> delWrapper = new QueryWrapper<>();
delWrapper.lambda().eq(BomNewEbomChildEntity::getParentRowId,dto.getRowId()); delWrapper.lambda().eq(BomNewEbomChildEntity::getParentRowId, dto.getRowId());
SpringUtil.getBean(BomNewEbomChildService.class).getBaseMapper().delete(delWrapper); SpringUtil.getBean(BomNewEbomChildService.class).getBaseMapper().delete(delWrapper);
} }
@ -1088,16 +1126,16 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
} }
List<String> sameList=null; List<String> sameList = null;
if (CollectionUtil.isNotEmpty(eBomEdit.childEntities)) { if (CollectionUtil.isNotEmpty(eBomEdit.childEntities)) {
QueryWrapper<BomNewEbomChildEntity > queryWrapper=new QueryWrapper<>(); QueryWrapper<BomNewEbomChildEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(BomNewEbomChildEntity::getParentRowId,dto.getRowId()); queryWrapper.lambda().eq(BomNewEbomChildEntity::getParentRowId, dto.getRowId());
List<BomNewEbomChildEntity> oldChildList= SpringUtil.getBean(BomNewEbomChildService.class).list(queryWrapper); List<BomNewEbomChildEntity> oldChildList = SpringUtil.getBean(BomNewEbomChildService.class).list(queryWrapper);
ebomChildService.saveOrUpdateBatch(eBomEdit.childEntities); ebomChildService.saveOrUpdateBatch(eBomEdit.childEntities);
if(CollUtil.isNotEmpty(oldChildList)) { if (CollUtil.isNotEmpty(oldChildList)) {
//追加里包含相同 //追加里包含相同
List<String> appendList = eBomEdit.childEntities.stream().map(BomNewEbomChildEntity::getMaterialNo).collect(Collectors.toList()); List<String> appendList = eBomEdit.childEntities.stream().map(BomNewEbomChildEntity::getMaterialNo).collect(Collectors.toList());
List<String> oldList = oldChildList.stream().map(BomNewEbomChildEntity::getMaterialNo).collect(Collectors.toList()); List<String> oldList = oldChildList.stream().map(BomNewEbomChildEntity::getMaterialNo).collect(Collectors.toList());
@ -1111,10 +1149,10 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
//不要异步 //不要异步
computeLevelNumAndRootState(); computeLevelNumAndRootState();
if(CollUtil.isEmpty(sameList)){ if (CollUtil.isEmpty(sameList)) {
return ResultVO.success(); return ResultVO.success();
}else{ } else {
return ResultVO.error(StrUtil.format("导入数据存在重复物料 {}",StrUtil.join(",",sameList))); return ResultVO.error(StrUtil.format("导入数据存在重复物料 {}", StrUtil.join(",", sameList)));
} }
} }
@ -1186,7 +1224,6 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
* 退回设计,不用判断角色 工艺岗才能看见已复核数据 * 退回设计,不用判断角色 工艺岗才能看见已复核数据
* 1.已发布不能退 * 1.已发布不能退
* 2.被工艺岗位添加的物料不可以退回但是可以被删除只能是当前工艺岗位的用户创建的物料 * 2.被工艺岗位添加的物料不可以退回但是可以被删除只能是当前工艺岗位的用户创建的物料
*
*/ */
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void revertDesign(BomNewEBomRevertDTO dto) throws ExecutionException, InterruptedException { public void revertDesign(BomNewEBomRevertDTO dto) throws ExecutionException, InterruptedException {
@ -1227,21 +1264,20 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
revertList.clear(); revertList.clear();
//忽略叶子节点 工艺人员不退回设计 ,只退回设计复核部分 //忽略叶子节点 工艺人员不退回设计 ,只退回设计复核部分
revertList.addAll(bomTreeList.stream() revertList.addAll(bomTreeList.stream()
.filter(u -> (ObjectUtil.isNotNull(u.getBomRowId()) && u.getBomRowId().longValue() > 0 ) .filter(u -> (ObjectUtil.isNotNull(u.getBomRowId()) && u.getBomRowId().longValue() > 0)
&& !ObjectUtil.equal(UserJobEnum.ENGINEER.getValue(),u.getCreatedJob()) && !ObjectUtil.equal(UserJobEnum.ENGINEER.getValue(), u.getCreatedJob())
&& ObjectUtil.equal(EBomStatusEnum.CHECKED.getValue(),u.getStatus()) && ObjectUtil.equal(EBomStatusEnum.CHECKED.getValue(), u.getStatus())
) )
.map(BomNewEbomParentVO::getBomRowId).collect(Collectors.toList())); .map(BomNewEbomParentVO::getBomRowId).collect(Collectors.toList()));
if (CollectionUtil.isNotEmpty(revertList)) { if (CollectionUtil.isNotEmpty(revertList)) {
//parent表状态 //parent表状态
UpdateWrapper<BomNewEbomParentEntity> updateWrapper = new UpdateWrapper<>(); UpdateWrapper<BomNewEbomParentEntity> updateWrapper = new UpdateWrapper<>();
updateWrapper.lambda() updateWrapper.lambda()
.set(BomNewEbomParentEntity::getRevertTime, LocalDateTime.now()) .set(BomNewEbomParentEntity::getRevertTime, LocalDateTime.now())
.set(BomNewEbomParentEntity::getRevertUserName, SessionUtil.getUserName()) .set(BomNewEbomParentEntity::getRevertUserName, SessionUtil.getUserName())
.set(BomNewEbomParentEntity::getRevertDesc,dto.getRevertDesc()) .set(BomNewEbomParentEntity::getRevertDesc, dto.getRevertDesc())
.set(BomNewEbomParentEntity::getStatus, EBomStatusEnum.RETURNED.getValue()) .set(BomNewEbomParentEntity::getStatus, EBomStatusEnum.RETURNED.getValue())
.set(BomNewEbomParentEntity::getEditStatus, EbomEditStatusEnum.HANDLER_CREATED.getValue()) .set(BomNewEbomParentEntity::getEditStatus, EbomEditStatusEnum.HANDLER_CREATED.getValue())
.in(BomNewEbomParentEntity::getRowId, revertList); .in(BomNewEbomParentEntity::getRowId, revertList);
@ -1253,8 +1289,8 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
.set(BomNewEbomChildEntity::getEditStatus, EbomEditStatusEnum.HANDLER_CREATED.getValue()) .set(BomNewEbomChildEntity::getEditStatus, EbomEditStatusEnum.HANDLER_CREATED.getValue())
.in(BomNewEbomChildEntity::getParentRowId, revertList); .in(BomNewEbomChildEntity::getParentRowId, revertList);
this.update(updateWrapper ); this.update(updateWrapper);
ebomChildService.update(childWrapper) ; ebomChildService.update(childWrapper);
} }
@ -1264,13 +1300,11 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
} }
} }
/** /**
* 设计复核 * 设计复核
*设计人员只可以复核自己的物料如果存在引用其他用户创建的物料时不可以改变被引用物料的审核状态 * 设计人员只可以复核自己的物料如果存在引用其他用户创建的物料时不可以改变被引用物料的审核状态
* 异常检查 * 异常检查
* 1. 是否存在空物料编号空数量的数据信息; * 1. 是否存在空物料编号空数量的数据信息;
* 2. 是否存在在主数据平台的物料信息没有的数据 * 2. 是否存在在主数据平台的物料信息没有的数据
@ -1292,10 +1326,10 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
} }
//检查顶级bom是否是设计自己 //检查顶级bom是否是设计自己
List<BomNewEbomParentEntity> checkList=bomNewEbomParentEntityList.stream().filter(u->!u.getCreatedBy().equals(SessionUtil.getUserCode())).collect(Collectors.toList()); List<BomNewEbomParentEntity> checkList = bomNewEbomParentEntityList.stream().filter(u -> !u.getCreatedBy().equals(SessionUtil.getUserCode())).collect(Collectors.toList());
if(CollUtil.isNotEmpty(checkList)) { if (CollUtil.isNotEmpty(checkList)) {
String checkListMaterialNo=StrUtil.join(",",checkList.stream().map(BomNewEbomParentEntity::getMaterialNo).collect(Collectors.toList())); String checkListMaterialNo = StrUtil.join(",", checkList.stream().map(BomNewEbomParentEntity::getMaterialNo).collect(Collectors.toList()));
VUtils.isTure(true).throwMessage(StrUtil.format("{} 该节点不属于你,你无权复核",checkListMaterialNo)); VUtils.isTure(true).throwMessage(StrUtil.format("{} 该节点不属于你,你无权复核", checkListMaterialNo));
} }
@ -1346,8 +1380,8 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
.set(BomNewEbomParentEntity::getAuditUserName, SessionUtil.getUserName()) .set(BomNewEbomParentEntity::getAuditUserName, SessionUtil.getUserName())
.set(BomNewEbomParentEntity::getStatus, EBomStatusEnum.CHECKED.getValue()) .set(BomNewEbomParentEntity::getStatus, EBomStatusEnum.CHECKED.getValue())
.set(BomNewEbomParentEntity::getEditStatus, EbomEditStatusEnum.HANDLER_FINISHED.getValue()) .set(BomNewEbomParentEntity::getEditStatus, EbomEditStatusEnum.HANDLER_FINISHED.getValue())
.set(BomNewEbomParentEntity::getRootIsForWaitReview,0) .set(BomNewEbomParentEntity::getRootIsForWaitReview, 0)
.set(BomNewEbomParentEntity::getRevertDesc,"") .set(BomNewEbomParentEntity::getRevertDesc, "")
.in(BomNewEbomParentEntity::getRowId, updateReviewIdList); .in(BomNewEbomParentEntity::getRowId, updateReviewIdList);
@ -1376,13 +1410,10 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
public Boolean updateProjectType(BomNewEbomProjectTypeDTO dto) { public Boolean updateProjectType(BomNewEbomProjectTypeDTO dto) {
List<Long> rowIdList = dto.getRowIdList().stream().map(BomNewEbomProjectTypeDTO.BomNewEbomChangeProjectType::getRowId).collect(Collectors.toList()); List<Long> rowIdList = dto.getRowIdList().stream().map(BomNewEbomProjectTypeDTO.BomNewEbomChangeProjectType::getRowId).collect(Collectors.toList());
List<Long> bomRowIdList = dto.getRowIdList().stream().filter(u -> u.getBomRowId() > 0).map(BomNewEbomProjectTypeDTO.BomNewEbomChangeProjectType::getBomRowId).collect(Collectors.toList()); List<Long> bomRowIdList = dto.getRowIdList().stream().filter(u -> u.getBomRowId() > 0).map(BomNewEbomProjectTypeDTO.BomNewEbomChangeProjectType::getBomRowId).collect(Collectors.toList());
// if (CollectionUtil.isNotEmpty(bomRowIdList)) { // if (CollectionUtil.isNotEmpty(bomRowIdList)) {
// UpdateWrapper<BomNewEbomParentEntity> parentUpdate = new UpdateWrapper<>(); // UpdateWrapper<BomNewEbomParentEntity> parentUpdate = new UpdateWrapper<>();
// parentUpdate.lambda() // parentUpdate.lambda()
@ -1478,7 +1509,6 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
} }
BomNewEbomChildEntity childEntity = null; BomNewEbomChildEntity childEntity = null;
@ -1496,15 +1526,12 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
//编辑查询物料id未变化 //编辑查询物料id未变化
if (childEntity.getMaterialNo().equals(materialMainEntity.getMaterialNo()) || childEntity.getDrawingNo().equals(materialMainEntity.getDrawingNo())) { if (childEntity.getMaterialNo().equals(materialMainEntity.getMaterialNo()) || childEntity.getDrawingNo().equals(materialMainEntity.getDrawingNo())) {
BeanUtil.copyProperties(childEntity, baseMaterialVO); BeanUtil.copyProperties(childEntity, baseMaterialVO);
SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(ImmutableList.of(baseMaterialVO),EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT2); SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(ImmutableList.of(baseMaterialVO), EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT2);
return baseMaterialVO; return baseMaterialVO;
} }
} }
//编辑数据 新增或物料编码已变化 //编辑数据 新增或物料编码已变化
BomNewEbomParentEntity bomParent = null; BomNewEbomParentEntity bomParent = null;
if (query.getBomRowId() != null && query.getBomRowId().longValue() != 0) { if (query.getBomRowId() != null && query.getBomRowId().longValue() != 0) {
@ -1536,12 +1563,11 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
if (StrUtil.isNotBlank(materialMainEntity.getMaterialWeight())) { if (StrUtil.isNotBlank(materialMainEntity.getMaterialWeight())) {
baseMaterialVO.setUnitWeight(new BigDecimal(materialMainEntity.getMaterialWeight())); baseMaterialVO.setUnitWeight(new BigDecimal(materialMainEntity.getMaterialWeight()));
} }
if(ObjectUtil.isNull(baseMaterialVO.getNum())){ if (ObjectUtil.isNull(baseMaterialVO.getNum())) {
baseMaterialVO.setNum(new BigDecimal(1)); baseMaterialVO.setNum(new BigDecimal(1));
} }
if (StrUtil.isNotBlank(baseMaterialVO.getMaterialNo()) if (StrUtil.isNotBlank(baseMaterialVO.getMaterialNo())
&& (MaterialGetEnum.MaterialStateEnum.STATE_NO_4.equalsValue(baseMaterialVO.getMaterialState()) && (MaterialGetEnum.MaterialStateEnum.STATE_NO_4.equalsValue(baseMaterialVO.getMaterialState())
|| MaterialGetEnum.MaterialStateEnum.STATE_NO_5.equalsValue(baseMaterialVO.getMaterialState()))) { || MaterialGetEnum.MaterialStateEnum.STATE_NO_5.equalsValue(baseMaterialVO.getMaterialState()))) {
@ -1577,9 +1603,9 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Boolean deleteBom(Long bomRowId) throws ExecutionException, InterruptedException { public Boolean deleteBom(Long bomRowId) throws ExecutionException, InterruptedException {
QueryWrapper<BomNewEbomParentEntity> queryWrapper=new QueryWrapper<>(); QueryWrapper<BomNewEbomParentEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda() .eq(BomNewEbomParentEntity::getRowId, bomRowId) queryWrapper.lambda().eq(BomNewEbomParentEntity::getRowId, bomRowId)
.eq(BomNewEbomParentEntity::getUserRootIs, 1); .eq(BomNewEbomParentEntity::getUserRootIs, 1);
BomNewEbomParentEntity parentEntity = this.getBaseMapper().selectOne(queryWrapper); BomNewEbomParentEntity parentEntity = this.getBaseMapper().selectOne(queryWrapper);
@ -1605,19 +1631,19 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
if (CollectionUtil.isNotEmpty(eBomDel.getDelEBom())) { if (CollectionUtil.isNotEmpty(eBomDel.getDelEBom())) {
//取bom信息删除 //取bom信息删除
List<Long> parentList= eBomDel.getDelEBom().stream().filter(u -> (ObjectUtil.isNotNull(u.getBomRowId()) && u.getBomRowId() > 0)) List<Long> parentList = eBomDel.getDelEBom().stream().filter(u -> (ObjectUtil.isNotNull(u.getBomRowId()) && u.getBomRowId() > 0))
.map(BomNewEbomParentVO::getBomRowId).collect(Collectors.toList()); .map(BomNewEbomParentVO::getBomRowId).collect(Collectors.toList());
List<Long> childList= eBomDel.getDelEBom().stream().filter(u -> (ObjectUtil.isNull(u.getBomRowId()) || u.getBomRowId().longValue()==0l)) List<Long> childList = eBomDel.getDelEBom().stream().filter(u -> (ObjectUtil.isNull(u.getBomRowId()) || u.getBomRowId().longValue() == 0l))
.map(BomNewEbomParentVO::getRowId).collect(Collectors.toList()); .map(BomNewEbomParentVO::getRowId).collect(Collectors.toList());
if(CollUtil.isNotEmpty(parentList)) { if (CollUtil.isNotEmpty(parentList)) {
this.getBaseMapper().delBatch(parentList); this.getBaseMapper().delBatch(parentList);
} }
// QueryWrapper<BomNewEbomParentEntity> parentWrapper=new QueryWrapper<>(); // QueryWrapper<BomNewEbomParentEntity> parentWrapper=new QueryWrapper<>();
// parentWrapper.lambda().in(BomNewEbomParentEntity::getRowId,parentList); // parentWrapper.lambda().in(BomNewEbomParentEntity::getRowId,parentList);
// //
if(CollUtil.isNotEmpty(childList)) { if (CollUtil.isNotEmpty(childList)) {
QueryWrapper<BomNewEbomChildEntity> childWrapper = new QueryWrapper<>(); QueryWrapper<BomNewEbomChildEntity> childWrapper = new QueryWrapper<>();
childWrapper.lambda().in(BomNewEbomChildEntity::getRowId, childList); childWrapper.lambda().in(BomNewEbomChildEntity::getRowId, childList);
// //
@ -1626,7 +1652,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
} }
}else{ } else {
VUtils.isTure(true).throwMessage("该bom下没有你删除的数据"); VUtils.isTure(true).throwMessage("该bom下没有你删除的数据");
} }
@ -1638,7 +1664,6 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
} }
if (CollectionUtil.isNotEmpty(eBomDel.getDelEBom())) { if (CollectionUtil.isNotEmpty(eBomDel.getDelEBom())) {
//ThreadUtil.execAsync(() -> computeLevelNumAndRootState()); //ThreadUtil.execAsync(() -> computeLevelNumAndRootState());
@ -1678,11 +1703,11 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
} }
void checkUserRoleAuth(String bomCreatedBy){ void checkUserRoleAuth(String bomCreatedBy) {
//1.设计岗操作自己数据 //1.设计岗操作自己数据
//2.工艺人员可以修改自己创建的或是已通过设计复核的数据工艺岗能看见设计岗数据必定是已复核或双角色岗设计+工艺 //2.工艺人员可以修改自己创建的或是已通过设计复核的数据工艺岗能看见设计岗数据必定是已复核或双角色岗设计+工艺
if(!SpringUtil.getBean(UserRoleService.class).technician()){ if (!SpringUtil.getBean(UserRoleService.class).technician()) {
if(!bomCreatedBy.equals(SessionUtil.getUserCode())){ if (!bomCreatedBy.equals(SessionUtil.getUserCode())) {
VUtils.isTure(true).throwMessage("该节点不属于你,你无权操作"); VUtils.isTure(true).throwMessage("该节点不属于你,你无权操作");
} }
} }
@ -1690,9 +1715,6 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
} }
/** /**
* 暂存 * 暂存
* <p> * <p>
@ -1706,7 +1728,6 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
checkUserRoleAuth(dto.getParent().getCreatedBy()); checkUserRoleAuth(dto.getParent().getCreatedBy());
//暂存数据为空后面不处理 //暂存数据为空后面不处理
if (CollUtil.isEmpty(dto.getDatas())) { if (CollUtil.isEmpty(dto.getDatas())) {
return dto.getParent(); return dto.getParent();
@ -1718,8 +1739,6 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
eBomEdit.handleBom(dto); eBomEdit.handleBom(dto);
if (eBomEdit.getParentEntity() != null) { if (eBomEdit.getParentEntity() != null) {
eBomEdit.nextVersion(); eBomEdit.nextVersion();
@ -1744,8 +1763,6 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
} }
BomNewEbomParentVO retParentVO = Convert.convert(BomNewEbomParentVO.class, eBomEdit.getParentEntity()); BomNewEbomParentVO retParentVO = Convert.convert(BomNewEbomParentVO.class, eBomEdit.getParentEntity());
retParentVO.setBomRowId(retParentVO.getRowId()); retParentVO.setBomRowId(retParentVO.getRowId());
@ -1762,7 +1779,6 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
checkUserRoleAuth(dto.getParent().getCreatedBy()); checkUserRoleAuth(dto.getParent().getCreatedBy());
//无提交数据后面不处理 //无提交数据后面不处理
if (CollUtil.isEmpty(dto.getDatas())) { if (CollUtil.isEmpty(dto.getDatas())) {
return true; return true;
@ -1824,14 +1840,14 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
* 用户可以直接删除用户单击暂存或是提交时才会保存至数据库 * 用户可以直接删除用户单击暂存或是提交时才会保存至数据库
*/ */
public void deleteBomChild(List<BomNewEbomParentVO> delList) { public void deleteBomChild(List<BomNewEbomParentVO> delList) {
if(CollUtil.isEmpty(delList)){ if (CollUtil.isEmpty(delList)) {
return; return;
} }
List<Long> rowIds=delList.stream().map(BomNewEbomParentVO::getRowId).collect(Collectors.toList()); List<Long> rowIds = delList.stream().map(BomNewEbomParentVO::getRowId).collect(Collectors.toList());
QueryWrapper<BomNewEbomChildEntity> queryChildWrapper=new QueryWrapper<>(); QueryWrapper<BomNewEbomChildEntity> queryChildWrapper = new QueryWrapper<>();
queryChildWrapper.lambda().in(BomNewEbomChildEntity::getRowId,rowIds); queryChildWrapper.lambda().in(BomNewEbomChildEntity::getRowId, rowIds);
List<BomNewEbomChildEntity> delChildList=SpringUtil.getBean(BomNewEbomChildService.class).list(queryChildWrapper); List<BomNewEbomChildEntity> delChildList = SpringUtil.getBean(BomNewEbomChildService.class).list(queryChildWrapper);
List<BomNewEbomChildEntity> delTagList = new ArrayList<>(); List<BomNewEbomChildEntity> delTagList = new ArrayList<>();
@ -1840,7 +1856,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
&& Objects.equals(u.getExceptionStatus(), EBomExceptionStatusEnum.OK.getValue())).collect(Collectors.toList()); && Objects.equals(u.getExceptionStatus(), EBomExceptionStatusEnum.OK.getValue())).collect(Collectors.toList());
if (CollUtil.isNotEmpty(check1List)) { if (CollUtil.isNotEmpty(check1List)) {
throw new NflgBusinessException(STATE.Error,StrUtil.format("从原始Bom导入的数据数据没有异常的情况下{} 不可以删除 ",StrUtil.join(",", check1List.stream().map(BomNewEbomChildEntity::getMaterialNo).collect(Collectors.toList()) ))); throw new NflgBusinessException(STATE.Error, StrUtil.format("从原始Bom导入的数据数据没有异常的情况下{} 不可以删除 ", StrUtil.join(",", check1List.stream().map(BomNewEbomChildEntity::getMaterialNo).collect(Collectors.toList()))));
} }
//检查有bom数据关系是否可以删 //检查有bom数据关系是否可以删
@ -1852,7 +1868,6 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
// } // }
//原始bom不正常 //原始bom不正常
List<BomNewEbomChildEntity> s1List = delChildList.stream().filter(u -> Objects.equals(EBomSourceEnum.FROM_BOM.getValue(), u.getSource()) List<BomNewEbomChildEntity> s1List = delChildList.stream().filter(u -> Objects.equals(EBomSourceEnum.FROM_BOM.getValue(), u.getSource())
&& !Objects.equals(u.getExceptionStatus(), EBomExceptionStatusEnum.OK.getValue())).collect(Collectors.toList()); && !Objects.equals(u.getExceptionStatus(), EBomExceptionStatusEnum.OK.getValue())).collect(Collectors.toList());
@ -1868,14 +1883,14 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
// 设计自己删除自己 // 设计自己删除自己
//工艺岗用户1 可以删工艺岗用户2 的数据 //工艺岗用户1 可以删工艺岗用户2 的数据
if (CollectionUtil.isNotEmpty(s2List)) { if (CollectionUtil.isNotEmpty(s2List)) {
for (BomNewEbomChildEntity vo: for (BomNewEbomChildEntity vo :
s2List) { s2List) {
if( userRoleService.technician() ){ //工艺岗可删 if (userRoleService.technician()) { //工艺岗可删
delTagList.add(vo); delTagList.add(vo);
}else if ( userRoleService.designer() && vo.getCreatedBy().equals(SessionUtil.getUserCode())){ //自己的数据可删 } else if (userRoleService.designer() && vo.getCreatedBy().equals(SessionUtil.getUserCode())) { //自己的数据可删
delTagList.add(vo); delTagList.add(vo);
}else{ } else {
throw new NflgBusinessException(STATE.Error,StrUtil.format("{}数据不是你的,无权删除",vo.getMaterialNo())); throw new NflgBusinessException(STATE.Error, StrUtil.format("{}数据不是你的,无权删除", vo.getMaterialNo()));
} }
} }

View File

@ -114,6 +114,30 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
return result; return result;
} }
/**
* 获取父级图号包含查询的图号
* @param drawingNos
* @return
*/
public List<String> getParentMaterialByDrawingNo(List<String> drawingNos) {
Set<String> result = new HashSet<>();
result.addAll(drawingNos);
Set<String> useMaterialSku = this.getBaseMapper().getMaterialParent(drawingNos);
while (CollUtil.isNotEmpty(useMaterialSku)) {
//防止数据错误循环依赖-死循环
Set<String> difference = Sets.difference(useMaterialSku, result);
if (CollUtil.isNotEmpty(difference)) {
useMaterialSku = this.getBaseMapper().getMaterialParent(difference);
result.addAll(difference);
} else {
break;
}
}
return new ArrayList<>(result);
}
private Page<BomOriginalListVO> handSeachToTree(List<BomOriginalListVO> parents, List<BomOriginalListVO> childs) { private Page<BomOriginalListVO> handSeachToTree(List<BomOriginalListVO> parents, List<BomOriginalListVO> childs) {
Page<BomOriginalListVO> resutlData = new Page<>(); Page<BomOriginalListVO> resutlData = new Page<>();
Set<String> parentSet = parents.stream().map(u -> u.getDrawingNo()).collect(Collectors.toSet()); Set<String> parentSet = parents.stream().map(u -> u.getDrawingNo()).collect(Collectors.toSet());
@ -157,10 +181,34 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
} }
} }
if (CollUtil.isNotEmpty(queryDrawingNos)) { if (CollUtil.isNotEmpty(queryDrawingNos)) {
// List<BomNewOriginalParentEntity> materialBoms = this.lambdaQuery().in(BomNewOriginalParentEntity::getDrawingNo, queryDrawingNos).eq(BomNewOriginalParentEntity::getLastVersionIs, 1)
// .eq(BomNewOriginalParentEntity::getStatus, OriginalStatusEnum.UN_CONVERT.getValue()).list();
// if(query.getStatus().equals(1) && CollUtil.isEmpty(materialBoms)){
// return result;
// }
List<String> parentDrawingNos = new ArrayList<>(getParentMaterialByDrawingNo(queryDrawingNos));
// parentDrawingNos.addAll(queryDrawingNos);
Set<String> parentDrawingNos = new HashSet<>(getParentDrawingNoByMaterialNo(queryDrawingNos)); Set<String> parentDrawingNos = new HashSet<>(getParentDrawingNoByMaterialNo(queryDrawingNos));
parentDrawingNos.addAll(queryDrawingNos); parentDrawingNos.addAll(queryDrawingNos);
if (CollUtil.isNotEmpty(parentDrawingNos)) { if (CollUtil.isNotEmpty(parentDrawingNos)) {
List<BomOriginalListVO> childs=new ArrayList<>();
List<BomOriginalListVO> parents = this.getBaseMapper().getParentForDrawingNoSeach(parentDrawingNos, query.getStatus()); List<BomOriginalListVO> parents = this.getBaseMapper().getParentForDrawingNoSeach(parentDrawingNos, query.getStatus());
materialMainService.intiMaterialInfo(parents, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
if(CollUtil.isNotEmpty(parents)) {
childs = this.getBaseMapper().getChildForDrawingNoSeach(parentDrawingNos, parents.stream().map(u -> u.getRowId()).collect(Collectors.toSet()));
materialMainService.intiMaterialInfo(childs, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
childs.stream().filter(f -> StrUtil.isBlank(f.getCurrentVersion())).forEach(f -> {
if (MaterialshouldBomExistUtil.checkShouldBomExist(f.getMaterialCategoryCode(), f.getMaterialGetType())) {
f.setCurrentVersion(OriginalConstant.NO_BOM_VERSION);
} else {
f.setCurrentVersion(OriginalConstant.DEFAULT_BOM_VERSION);
}
});
}
// List<BomOriginalListVO> data = new ArrayList<>();
// data.addAll(parents);
// data.addAll(childs);
// materialMainService.intiMaterialInfo(data, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
materialMainService.intiMaterialInfo(parents, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT2); materialMainService.intiMaterialInfo(parents, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT2);
List<BomOriginalListVO> childs = this.getBaseMapper().getChildForDrawingNoSeach(parentDrawingNos,query.getStatus()); List<BomOriginalListVO> childs = this.getBaseMapper().getChildForDrawingNoSeach(parentDrawingNos,query.getStatus());
materialMainService.intiMaterialInfo(childs, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT2); materialMainService.intiMaterialInfo(childs, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT2);

View File

@ -170,10 +170,12 @@ public class EBomToPBom {
pBomParent.setFacCode(facCode); pBomParent.setFacCode(facCode);
pBomParent.setTechnologyUserCode(SessionUtil.getUserCode()); pBomParent.setTechnologyUserCode(SessionUtil.getUserCode());
pBomParent.setTechnologyUserName(SessionUtil.getRealName()); pBomParent.setTechnologyUserName(SessionUtil.getRealName());
pBomParent.setCurrentVersion(VersionUtil.getNextVersion("")); //pBomParent.setCurrentVersion(VersionUtil.getNextVersion(""));
//版本=EBom版本
pBomParent.setCurrentVersion(parentVo.getCurrentVersion());
pBomParent.setEditStatus(PBomEditStatusEnum.HANDLER_CREATED.getValue()); pBomParent.setEditStatus(PBomEditStatusEnum.HANDLER_CREATED.getValue());
if(Objects.nonNull(oldParent)){ if(Objects.nonNull(oldParent)){
pBomParent.setCurrentVersion(VersionUtil.getNextVersion(oldParent.getCurrentVersion())); // pBomParent.setCurrentVersion(VersionUtil.getNextVersion(oldParent.getCurrentVersion()));
oldParent.setExpireEndTime(LocalDateTime.now()); oldParent.setExpireEndTime(LocalDateTime.now());
oldParent.setLastVersionIs(0); oldParent.setLastVersionIs(0);
} }

View File

@ -39,7 +39,7 @@ public class VirtualPackageFor21 extends VirtualPackageBase {
BomNewEbomParentEntity parent = getParentByRowId(bomRowId); BomNewEbomParentEntity parent = getParentByRowId(bomRowId);
BomNewEbomParentVO vo= Convert.convert(BomNewEbomParentVO.class,parent ); BomNewEbomParentVO vo= Convert.convert(BomNewEbomParentVO.class,parent );
if(virtualPackageValue.contains(VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getValue()) && (parent.getVirtrualPackageEnum()| VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getValue())!=VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getValue()){ if(virtualPackageValue.contains(VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getValue()) && (parent.getVirtrualPackageEnum()&VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getValue())!= VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getValue()){
generateVMNoF21(parent.getDrawingNo(), ImmutableList.of(vo),VirtualPackageTypeEnum.MAKING_PACKAGE, VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE,VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE); generateVMNoF21(parent.getDrawingNo(), ImmutableList.of(vo),VirtualPackageTypeEnum.MAKING_PACKAGE, VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE,VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE);
} }
else { else {
@ -58,7 +58,7 @@ public class VirtualPackageFor21 extends VirtualPackageBase {
buildChild(directDeliveryPackage, bomRowId, "002", VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE,parent.getMaterialNo()); buildChild(directDeliveryPackage, bomRowId, "002", VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE,parent.getMaterialNo());
} }
if(virtualPackageValue.contains(VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getValue()) && (parent.getVirtrualPackageEnum()| VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getValue())!=VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getValue()) { if(virtualPackageValue.contains(VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getValue()) && (parent.getVirtrualPackageEnum()& VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getValue())!=VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getValue()) {
//构建构建发货前装配包 //构建构建发货前装配包
if(Objects.isNull(makingPackage)){ if(Objects.isNull(makingPackage)){
makingPackage=getParentZhiZuo(parent.getDrawingNo()); makingPackage=getParentZhiZuo(parent.getDrawingNo());

View File

@ -98,45 +98,98 @@
<!--物料编码搜索-父级--> <!--物料编码搜索-父级-->
<select id="getParentForMaterialNoSeach" resultType="com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO"> <select id="getParentForMaterialNoSeach" resultType="com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO">
SELECT if(status=4 and #{dataType}!=1, 99,status) status, created_by as bomCreatedBy , row_id as bomRowId, row_id as childBomRowId, a.* SELECT status , 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 FROM t_bom_new_ebom_parent a
<!-- <if test="dataType!=1 and !hasParentIs" >--> join (select material_no,max(current_version) current_version from t_bom_new_ebom_parent where
<!-- and a.status &lt; 4--> <if test="dataType==1" >
<!-- </if>--> status = 4
<if test="dataType==1"> </if>
and a.status = 4 <if test="dataType==0" >
status &lt; 4
<if test="createdBy!=null and createdBy!=''">
and created_by=#{createdBy}
</if> </if>
</if>
and material_no in and material_no in
<foreach collection="materialNoList" item="item" open="(" separator="," close=")"> <foreach collection="materialNoList" item="item" open="(" separator="," close=")">
#{item} #{item}
</foreach> </foreach>
group by material_no ) b on a.material_no=b.material_no and a.current_version=b.current_version
</select> </select>
<!-- &lt;!&ndash;物料编码搜索-父级&ndash;&gt;-->
<!-- <select id="getParentForMaterialNoSeach" resultType="com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO">-->
<!-- SELECT if(status=4 and #{dataType}!=1, 99,status) status, 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-->
<!--&lt;!&ndash; <if test="dataType!=1 and !hasParentIs" >&ndash;&gt;-->
<!--&lt;!&ndash; and a.status &lt; 4&ndash;&gt;-->
<!--&lt;!&ndash; </if>&ndash;&gt;-->
<!-- <if test="dataType==1">-->
<!-- and a.status = 4-->
<!-- </if>-->
<!-- and material_no in-->
<!-- <foreach collection="materialNoList" item="item" open="(" separator="," close=")">-->
<!-- #{item}-->
<!-- </foreach>-->
<!-- </select>-->
<!--物料编码搜索-子级-->
<!-- <select id="getChildForMaterialNoSeach" resultType="com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO">-->
<!-- select if(#{dataType}!=1 and c.status=4,99,c.status) as status ,c.current_version , c.created_by as bomCreatedBy-->
<!-- ,c.devise_name,c.devise_user_code,c.dept_name ,-->
<!-- c.source, if(c.row_id is null,0,c.row_id) as bomRowId, c.row_id as childBomRowId, b.*-->
<!-- from t_bom_new_ebom_parent a-->
<!-- 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-->
<!-- where a.last_version_is=1-->
<!-- <if test="dataType!=1">-->
<!-- and a.status &lt; 4-->
<!-- </if>-->
<!-- <if test="dataType==1">-->
<!-- and a.status = 4-->
<!-- </if>-->
<!-- and ( b.material_no in-->
<!-- <foreach collection="materialNoList" item="item" open="(" separator="," close=")">-->
<!-- #{item}-->
<!-- </foreach>-->
<!-- or b.material_no=#{materialNo})-->
<!-- </select>-->
<!--物料编码搜索-子级--> <!--物料编码搜索-子级-->
<select id="getChildForMaterialNoSeach" resultType="com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO"> <select id="getChildForMaterialNoSeach" resultType="com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO">
select if(#{dataType}!=1 and c.status=4,99,c.status) as status ,c.current_version , c.created_by as bomCreatedBy select a.status ,a.current_version , a.created_by as bomCreatedBy,
,c.devise_name,c.devise_user_code,c.dept_name , a.devise_name ,a.devise_user_code
c.source, if(c.row_id is null,0,c.row_id) as bomRowId, c.row_id as childBomRowId, b.* ,a.dept_name,a.source,ifnull( a.row_id,0) as bomRowId
from t_bom_new_ebom_parent a ,ifnull( a.row_id,0) as childBomRowId, b.* from t_bom_new_ebom_child b
join t_bom_new_ebom_child b on a.row_id =b.parent_row_id left join t_bom_new_ebom_parent a on a.material_no=b.material_no and a.row_id in
left join t_bom_new_ebom_parent c on b.material_no=c.material_no and c.last_version_is=1 <foreach collection="bomRowIds" item="item" open="(" separator="," close=")">
where a.last_version_is=1 #{item}
<if test="dataType!=1"> </foreach>
and a.status &lt; 4 where b.parent_row_id in
</if> <foreach collection="bomRowIds" item="item" open="(" separator="," close=")">
<if test="dataType==1"> #{item}
and a.status = 4 </foreach>
</if> and b.material_no in
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>
or b.material_no=#{materialNo}) <if test="createdBy!=null and createdBy!=''">
and b.created_by=#{createdBy}
</if>
</select> </select>
<!--BOM-正式工作表--> <!--BOM-正式工作表-->
<select id="formalWorksheet" resultType="com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO"> <select id="formalWorksheet" resultType="com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO">
select * , row_id as bomRowId from t_bom_new_ebom_parent where status=4 select * , row_id as bomRowId from t_bom_new_ebom_parent a
join (select material_no, max(current_version) current_version from t_bom_new_ebom_parent
where status=4 <include refid="whr"/>
group by material_no) b on a.material_no=b.material_no and a.current_version=b.current_version
where a.status=4
<include refid="whr"/> <include refid="whr"/>
</select> </select>
@ -222,8 +275,9 @@
</update> </update>
<!--更新-待复核根节点--> <!--更新-待复核根节点-->
<update id="updateRootForWaitReview"> <update id="updateRootForWaitReview">
update t_bom_new_ebom_parent set root_is_for_wait_review=0 ;
update t_bom_new_ebom_parent a left join ( update t_bom_new_ebom_parent a left join (
select b.row_id, b.material_no,a.`status` 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` =2 select b.row_id, b.material_no,a.`status` 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` in(1,3) and last_version_is=1
) b on a.material_no=b.material_no ) b on a.material_no=b.material_no
set a.root_is_for_wait_review=1 set a.root_is_for_wait_review=1
where a.`status` in (1,3) and last_version_is=1 and b.row_id is null ; where a.`status` in (1,3) and last_version_is=1 and b.row_id is null ;
@ -283,6 +337,18 @@
select COUNT(1) from t_bom_new_ebom_child where material_no=#{materialNo} and edit_status=1 select COUNT(1) from t_bom_new_ebom_child where material_no=#{materialNo} and edit_status=1
</select> </select>
<select id="getMaterialParent" resultType="java.lang.String">
select a.material_no from t_bom_new_ebom_parent a join t_bom_new_ebom_child b on a.row_id=b.parent_row_id
where a.last_version_is=1
<if test="createdBy!=null and createdBy!=''">
and a.created_by=#{createdBy}
</if>
and b.material_no in
<foreach collection="materialNos" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</select>
<select id="resetBomExist"> <select id="resetBomExist">
UPDATE t_bom_new_ebom_parent p UPDATE t_bom_new_ebom_parent p
SET p.bom_exist = (IF(EXISTS (SELECT 1 FROM t_bom_new_ebom_child WHERE parent_row_id = p.row_id), 1, 0)) SET p.bom_exist = (IF(EXISTS (SELECT 1 FROM t_bom_new_ebom_child WHERE parent_row_id = p.row_id), 1, 0))

View File

@ -192,30 +192,62 @@
<!--物料编码搜索-父级--> <!--物料编码搜索-父级-->
<select id="getParentForDrawingNoSeach" resultType="com.nflg.product.bomnew.pojo.vo.BomOriginalListVO"> <select id="getParentForDrawingNoSeach" resultType="com.nflg.product.bomnew.pojo.vo.BomOriginalListVO">
SELECT status,row_id as bomRowId, row_id as childBomRowId, a.* SELECT status , created_by as bomCreatedBy , row_id as bomRowId, row_id as childBomRowId, a.*
FROM t_bom_new_original_parent a FROM t_bom_new_original_parent a
where status=#{state} join (select drawing_no,max(current_version) current_version from t_bom_new_original_parent where status=#{state}
and drawing_no in and drawing_no in
<foreach collection="drawingNos" item="item" open="(" separator="," close=")"> <foreach collection="drawingNos" item="item" open="(" separator="," close=")">
#{item} #{item}
</foreach> </foreach>
order by row_id desc group by drawing_no ) b on a.drawing_no=b.drawing_no and a.current_version=b.current_version
order by created_time desc
</select> </select>
<!--物料编码搜索-子级--> <!--物料编码搜索-子级-->
<select id="getChildForDrawingNoSeach" resultType="com.nflg.product.bomnew.pojo.vo.BomOriginalListVO"> <select id="getChildForDrawingNoSeach" resultType="com.nflg.product.bomnew.pojo.vo.BomOriginalListVO">
select IFNULL(IF(a.`status`=1 and c.`status`!=1,3,c.`status`),a.`status`) `status`,c.current_version select a.status ,a.current_version , a.created_by as bomCreatedBy,
,IFNULL(c.devise_name,a.devise_name) as devise_name,IFNULL(c.devise_user_code,a.devise_user_code) AS devise_user_code a.devise_name ,a.devise_user_code
,IFNULL(c.dept_name,a.dept_name) AS dept_name,IFNULL(c.source,a.source) AS source,IFNULL(c.row_id,"0") as bomRowId ,a.dept_name,a.source,ifnull( a.row_id,0) as bomRowId
,IFNULL(c.row_id,"0") as childBomRowId, b.* ,ifnull( a.row_id,0) as childBomRowId, b.* from t_bom_new_original_child b
from t_bom_new_original_parent a left join t_bom_new_original_parent a on a.drawing_no=b.drawing_no and a.row_id in
join t_bom_new_original_child b on a.row_id =b.parent_row_id <foreach collection="bomRowIds" item="item" open="(" separator="," close=")">
left join t_bom_new_original_parent c on b.drawing_no=c.drawing_no #{item}
where b.`status` = #{state} and b.drawing_no in </foreach>
where b.parent_row_id in
<foreach collection="bomRowIds" item="item" open="(" separator="," close=")">
#{item}
</foreach>
and b.drawing_no in
<foreach collection="drawingNos" item="item" open="(" separator="," close=")"> <foreach collection="drawingNos" item="item" open="(" separator="," close=")">
#{item} #{item}
</foreach> </foreach>
</select> </select>
<!-- &lt;!&ndash;物料编码搜索-子级&ndash;&gt;-->
<!-- <select id="getChildForDrawingNoSeach" resultType="com.nflg.product.bomnew.pojo.vo.BomOriginalListVO">-->
<!-- select c.status ,c.current_version , c.created_by as bomCreatedBy-->
<!-- ,IFNULL(c.devise_name,a.devise_name) as devise_name,IFNULL(c.devise_user_code,a.devise_user_code) AS devise_user_code-->
<!-- ,IFNULL(c.dept_name,a.dept_name) AS dept_name,IFNULL(c.source,a.source) AS source,IFNULL(c.row_id,"0") as bomRowId-->
<!-- ,IFNULL(c.row_id,"0") as childBomRowId, b.*-->
<!-- from t_bom_new_original_parent a-->
<!-- join t_bom_new_original_child b on a.row_id =b.parent_row_id-->
<!-- left join t_bom_new_original_parent c on b.drawing_no=c.drawing_no and c.last_version_is=1-->
<!-- where a.last_version_is=1 and b.drawing_no in-->
<!-- <foreach collection="drawingNos" item="item" open="(" separator="," close=")">-->
<!-- #{item}-->
<!-- </foreach>-->
<!-- </select>-->
<!--获取父级图号-->
<select id="getMaterialParent" resultType="java.lang.String">
select a.drawing_no from t_bom_new_original_parent a join t_bom_new_original_child b on a.row_id=b.parent_row_id
where a.last_version_is=1
and b.drawing_no in
<foreach collection="drawingNos" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</select>
<select id="resetBomExist"> <select id="resetBomExist">
UPDATE t_bom_new_original_parent p UPDATE t_bom_new_original_parent p
SET p.bom_exist = (IF(EXISTS (SELECT 1 FROM t_bom_new_original_child WHERE parent_row_id = p.row_id), 1, 0)) SET p.bom_exist = (IF(EXISTS (SELECT 1 FROM t_bom_new_original_child WHERE parent_row_id = p.row_id), 1, 0))

View File

@ -1,6 +1,7 @@
package nflg.product.common.dto; package nflg.product.common.dto;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors;
//import org.omg.CORBA.PRIVATE_MEMBER; //import org.omg.CORBA.PRIVATE_MEMBER;
import java.util.List; import java.util.List;
@ -11,6 +12,7 @@ import java.util.List;
* @Date 2022/7/14 10:38 * @Date 2022/7/14 10:38
**/ **/
@Data @Data
@Accessors(chain = true)
public class LoginUserInfoDTO { public class LoginUserInfoDTO {
private Long rowId; private Long rowId;