This commit is contained in:
parent
c42b94c04d
commit
592d61ab74
|
|
@ -17,4 +17,30 @@ public enum MaterialGetEnum implements ValueEnum<Integer> {
|
|||
|
||||
private final Integer value;
|
||||
private final String description;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum MaterialStateEnum implements ValueEnum<Integer> {
|
||||
//物料状态 1:正常 2:禁止采购 3:售后专用 4:冻结 5:完全弃用
|
||||
OK(1, "正常"),
|
||||
STATE_NO_2(2, "禁止采购"),
|
||||
STATE_NO_3(3, "售后专用"),
|
||||
STATE_NO_4(4, "冻结"),
|
||||
STATE_NO_5(5, "完全弃用")
|
||||
;
|
||||
|
||||
|
||||
private final Integer value;
|
||||
private final String description;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@ package com.nflg.product.bomnew.service;
|
|||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
|
@ -81,28 +84,28 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
*/
|
||||
public Page<BomNewEbomParentVO> workDetailsListByPage(BomNewEbomParentQuery query) {
|
||||
|
||||
Page<BomNewEbomParentVO>returnResult = new Page<>();
|
||||
Page<BomNewEbomParentVO> returnResult = new Page<>();
|
||||
//物料编码搜索或图号搜索
|
||||
if(StrUtil.isNotBlank(query.getMaterialNo()) || StrUtil.isNotBlank(query.getDrawingNo())) {
|
||||
String materialNo=query.getMaterialNo();
|
||||
if(StrUtil.isBlank(materialNo)){
|
||||
if (StrUtil.isNotBlank(query.getMaterialNo()) || StrUtil.isNotBlank(query.getDrawingNo())) {
|
||||
String materialNo = query.getMaterialNo();
|
||||
if (StrUtil.isBlank(materialNo)) {
|
||||
List<MaterialMainEntity> materialList = materialMainService.lambdaQuery().eq(MaterialMainEntity::getDrawingNo, query.getDrawingNo()).list();
|
||||
if(CollUtil.isNotEmpty(materialList)){
|
||||
materialNo=materialList.get(0).getMaterialNo();
|
||||
if (CollUtil.isNotEmpty(materialList)) {
|
||||
materialNo = materialList.get(0).getMaterialNo();
|
||||
}
|
||||
}
|
||||
if(StrUtil.isNotBlank(materialNo)){
|
||||
if (StrUtil.isNotBlank(materialNo)) {
|
||||
List<String> parentMaterialByMaterialNo = getParentMaterialByMaterialNo(materialNo, !userRoleService.technician());
|
||||
if(CollUtil.isNotEmpty(parentMaterialByMaterialNo)) {
|
||||
if (CollUtil.isNotEmpty(parentMaterialByMaterialNo)) {
|
||||
List<BomNewEbomParentVO> parents = this.getBaseMapper().getParentForMaterialNoSeach(parentMaterialByMaterialNo);
|
||||
List<BomNewEbomParentVO> childs = this.getBaseMapper().getChildForMaterialNoSeach(parentMaterialByMaterialNo, materialNo);
|
||||
|
||||
returnResult = handSeachToTree(parents, childs);
|
||||
}
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
Page<BomNewEbomParentVO> result = this.getBaseMapper().getEBomListPage(new Page<>(query.getPage(), query.getPageSize()), query, userRoleService.getUserJob(), SessionUtil.getUserCode());
|
||||
returnResult=result;
|
||||
returnResult = result;
|
||||
// materialMainService.intiMaterialInfo(result.getRecords());
|
||||
// Page<TreeNode<BomNewEbomParentVO>> resutlData = new Page<>();
|
||||
// BeanUtil.copyProperties(result, resutlData);
|
||||
|
|
@ -111,7 +114,8 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
}
|
||||
return returnResult;
|
||||
}
|
||||
private Page<BomNewEbomParentVO> handSeachToTree(List<BomNewEbomParentVO> parents, List<BomNewEbomParentVO> childs){
|
||||
|
||||
private Page<BomNewEbomParentVO> handSeachToTree(List<BomNewEbomParentVO> parents, List<BomNewEbomParentVO> childs) {
|
||||
Page<BomNewEbomParentVO> resutlData = new Page<>();
|
||||
Set<String> parentSet = parents.stream().map(u -> u.getMaterialNo()).collect(Collectors.toSet());
|
||||
Set<String> childSet = childs.stream().map(u -> u.getMaterialNo()).collect(Collectors.toSet());
|
||||
|
|
@ -121,16 +125,16 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
resutlData.setSize(difference.size());
|
||||
resutlData.setPages(1);
|
||||
resutlData.setCurrent(1L);
|
||||
List<BomNewEbomParentVO> all=new ArrayList<>();
|
||||
List<BomNewEbomParentVO> all = new ArrayList<>();
|
||||
all.addAll(parents);
|
||||
all.addAll(childs);
|
||||
List<BomNewEbomParentVO> result=new ArrayList<>();
|
||||
List<BomNewEbomParentVO> result = new ArrayList<>();
|
||||
for (BomNewEbomParentVO vo : resultParents) {
|
||||
vo.setParentRowId(0L);
|
||||
result.addAll( CTreeUtils.toTree(0L, all, BomNewEbomParentVO::getParentRowId, BomNewEbomParentVO::getBomRowId));
|
||||
result.addAll(CTreeUtils.toTree(0L, all, BomNewEbomParentVO::getParentRowId, BomNewEbomParentVO::getBomRowId));
|
||||
}
|
||||
resutlData.setRecords(result);
|
||||
return resutlData;
|
||||
return resutlData;
|
||||
}
|
||||
|
||||
// private List<BomNewEbomParentVO> handNodeToTree(List<BomNewEbomParentVO> list){
|
||||
|
|
@ -146,16 +150,17 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
|
||||
/**
|
||||
* 获取物料所有父节点
|
||||
*
|
||||
* @param materialNo
|
||||
* @return
|
||||
*/
|
||||
private List<String> getParentMaterialByMaterialNo(String materialNo , Boolean selfIs) {
|
||||
private List<String> getParentMaterialByMaterialNo(String materialNo, Boolean selfIs) {
|
||||
BomNewEbomMaterialUseEntity materialBom = bomNewEbomMaterialUseService.lambdaQuery().eq(BomNewEbomMaterialUseEntity::getMaterialNo, materialNo).one();
|
||||
List<String> result = new ArrayList<>();
|
||||
if (Objects.nonNull(materialBom) && StrUtil.isNotBlank(materialBom.getParentMaterialNo())) {
|
||||
Set<String> relSkuNo = Sets.newHashSet(StrUtil.split(materialBom.getParentMaterialNo(), ","));
|
||||
if(selfIs && CollUtil.isNotEmpty(relSkuNo)){
|
||||
relSkuNo=getSelfMaterialNo(relSkuNo);
|
||||
if (selfIs && CollUtil.isNotEmpty(relSkuNo)) {
|
||||
relSkuNo = getSelfMaterialNo(relSkuNo);
|
||||
}
|
||||
while (CollUtil.isNotEmpty(relSkuNo)) {
|
||||
result.addAll(relSkuNo);
|
||||
|
|
@ -164,19 +169,19 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
Set<String> finalRelSkuNo = relSkuNo;
|
||||
relSkuList.forEach(k -> {
|
||||
if (StrUtil.isNotBlank(k.getParentMaterialNo())) {
|
||||
finalRelSkuNo.addAll(Sets.newHashSet(StrUtil.split(k.getParentMaterialNo(), ",")) );
|
||||
finalRelSkuNo.addAll(Sets.newHashSet(StrUtil.split(k.getParentMaterialNo(), ",")));
|
||||
}
|
||||
});
|
||||
relSkuNo=finalRelSkuNo;
|
||||
if(CollUtil.isNotEmpty(relSkuNo) && selfIs){
|
||||
relSkuNo=getSelfMaterialNo(relSkuNo);
|
||||
relSkuNo = finalRelSkuNo;
|
||||
if (CollUtil.isNotEmpty(relSkuNo) && selfIs) {
|
||||
relSkuNo = getSelfMaterialNo(relSkuNo);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private Set<String> getSelfMaterialNo(Set<String> relSkuNo){
|
||||
private Set<String> getSelfMaterialNo(Set<String> relSkuNo) {
|
||||
Set<String> selfParentMaterialNo = this.getBaseMapper().getSelfParentMaterialNo(SessionUtil.getUserCode(), relSkuNo);
|
||||
return selfParentMaterialNo;
|
||||
}
|
||||
|
|
@ -184,6 +189,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
|
||||
/**
|
||||
* 正式工作表
|
||||
*
|
||||
* @param query
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -195,8 +201,6 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取子级
|
||||
*
|
||||
|
|
@ -225,7 +229,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
child.setLevelNum(parentEntity.getLevelNum());
|
||||
child.setDeptName(parentEntity.getDeptName());
|
||||
child.setSource(parentEntity.getSource());
|
||||
if(parentEntity.getStatus().equals(EBomStatusEnum.PUBLISHED.getValue())){
|
||||
if (parentEntity.getStatus().equals(EBomStatusEnum.PUBLISHED.getValue())) {
|
||||
child.setStatus(OriginalStatusEnum.BORROWED_PARTS.getValue());
|
||||
}
|
||||
|
||||
|
|
@ -275,12 +279,11 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
|
||||
}
|
||||
|
||||
public List<BomNewEbomParentVO> buildBomTree(Long rowId) throws Exception{
|
||||
return getBomTree(rowId);
|
||||
public List<BomNewEbomParentVO> buildBomTree(Long rowId) throws Exception {
|
||||
return getBomTree(rowId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 初始化-项目类别
|
||||
*/
|
||||
|
|
@ -478,19 +481,18 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
|
||||
|
||||
//重新创建保存list 避免污染
|
||||
List<BomNewEbomParentEntity> updateList=new ArrayList<>();
|
||||
bomNewEbomParentEntityList.forEach(item->{
|
||||
BomNewEbomParentEntity entity=new BomNewEbomParentEntity();
|
||||
List<BomNewEbomParentEntity> updateList = new ArrayList<>();
|
||||
bomNewEbomParentEntityList.forEach(item -> {
|
||||
BomNewEbomParentEntity entity = new BomNewEbomParentEntity();
|
||||
entity.setRowId(item.getRowId());
|
||||
entity .setEditStatus(EbomEditStatusEnum.HANDLER_CREATED.getValue());
|
||||
entity.setEditStatus(EbomEditStatusEnum.HANDLER_CREATED.getValue());
|
||||
entity.setRevertTime(LocalDateTime.now());
|
||||
entity.setRevertUserName(dto.getRevertUserName());
|
||||
updateList.add(entity);
|
||||
});
|
||||
|
||||
|
||||
|
||||
if (! this.updateBatchById(updateList)) {
|
||||
if (!this.updateBatchById(updateList)) {
|
||||
throw new NflgBusinessException(STATE.Error, "退回设计失败");
|
||||
}
|
||||
|
||||
|
|
@ -498,15 +500,15 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
|
||||
/**
|
||||
* 设计复核
|
||||
* 1. 是否存在空物料编号、空数量的数据信息;
|
||||
* 2. 是否存在在主数据平台的物料信息没有的数据;
|
||||
* 3. 同一层级是否存在相同的物料编码数据;
|
||||
* 4. 是否存在子级物料BOM引用父级物料编码(是否存在循环引用);
|
||||
* 5. 项目类别是否填写正确(项目类别请参照“项目类别自动赋值”规则);
|
||||
* 6. 是否存在“已冻结/永久禁用”的物料;
|
||||
* 1. 是否存在空物料编号、空数量的数据信息;
|
||||
* 2. 是否存在在主数据平台的物料信息没有的数据;
|
||||
* 3. 同一层级是否存在相同的物料编码数据;
|
||||
* 4. 是否存在子级物料BOM引用父级物料编码(是否存在循环引用);
|
||||
* 5. 项目类别是否填写正确(项目类别请参照“项目类别自动赋值”规则);
|
||||
* 6. 是否存在“已冻结/永久禁用”的物料;
|
||||
*/
|
||||
// @Transactional(rollbackFor = Exception.class)
|
||||
public ResultVO<Boolean> designReview(BomNewEBomRevertDTO dto){
|
||||
// @Transactional(rollbackFor = Exception.class)
|
||||
public ResultVO<Boolean> designReview(BomNewEBomRevertDTO dto) {
|
||||
|
||||
List<Long> rowIds = dto.getRowIdList();
|
||||
|
||||
|
|
@ -521,32 +523,133 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
return ResultVO.error("选择数据中包含有下级BOM无法进行复核");
|
||||
}
|
||||
|
||||
for (BomNewEbomParentEntity item:
|
||||
bomNewEbomParentEntityList) {
|
||||
if(item.getStatus().equals(EBomStatusEnum.CHECKED.getValue())){
|
||||
continue;
|
||||
}
|
||||
for (BomNewEbomParentEntity item :
|
||||
bomNewEbomParentEntityList) {
|
||||
|
||||
if( item.getNum().equals(EBomExceptionStatusEnum.INIT.getValue())){
|
||||
return ResultVO.error("请调整数据后进行复核");
|
||||
}
|
||||
|
||||
if (item.getStatus().equals(EBomStatusEnum.CHECKED.getValue())) {
|
||||
return ResultVO.error(StrUtil.format("{} 已复核过,不需重复复核", item.getMaterialNo()));
|
||||
}
|
||||
|
||||
if (item.getNum().equals(EBomExceptionStatusEnum.INIT.getValue())) {
|
||||
return ResultVO.error("请调整数据后进行复核");
|
||||
}
|
||||
|
||||
if (item.getNum().equals(EbomEditStatusEnum.HANDLER_CREATED.getValue())) {
|
||||
return ResultVO.error("请先提交确认后进行复核");
|
||||
}
|
||||
|
||||
|
||||
if (StrUtil.isEmpty(item.getMaterialNo()) || (item.getNum() == null || item.getNum().floatValue() == 0)) {
|
||||
return ResultVO.error(EBomExceptionStatusEnum.EXCEPT_NO_4.getDescription());
|
||||
}
|
||||
|
||||
MaterialMainEntity entity = materialMainService.lambdaQuery().eq(MaterialMainEntity::getMaterialNo, item.getMaterialNo()).one();
|
||||
|
||||
if (entity == null) {
|
||||
return ResultVO.error("物料编码[" + item.getMaterialNo() + "]物料不存在");
|
||||
}
|
||||
|
||||
if (Objects.equals(entity.getMaterialState(), MaterialGetEnum.MaterialStateEnum.STATE_NO_4)
|
||||
|| Objects.equals(entity.getMaterialState(), MaterialGetEnum.MaterialStateEnum.STATE_NO_5)) {
|
||||
return ResultVO.error("物料编码[" + item.getMaterialNo() + "]冻结/完全弃用异常");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
List<Long> updateReviewIdList=new ArrayList<>();
|
||||
//子bom检查
|
||||
for (BomNewEbomParentEntity item :
|
||||
bomNewEbomParentEntityList) {
|
||||
|
||||
List<BomNewEbomParentVO> childBomList;
|
||||
try {
|
||||
childBomList = buildBomTree(item.getRowId());
|
||||
} catch (Exception e) {
|
||||
return ResultVO.error("获取Bom数据失败");
|
||||
}
|
||||
|
||||
|
||||
if (CollUtil.isNotEmpty(childBomList)) {
|
||||
|
||||
for (BomNewEbomParentVO childBomItem :
|
||||
childBomList) {
|
||||
|
||||
|
||||
if (childBomItem.getNum().equals(EBomExceptionStatusEnum.INIT.getValue())) {
|
||||
return ResultVO.error("请调整数据后进行复核");
|
||||
}
|
||||
|
||||
if (childBomItem.getExceptionStatus().equals(EBomExceptionStatusEnum.EXCEPT_NO_2.getValue())) {
|
||||
return ResultVO.error(StrUtil.format("物料{} {}", childBomItem.getMaterialNo(), EBomExceptionStatusEnum.EXCEPT_NO_2.getDescription()));
|
||||
}
|
||||
|
||||
if (childBomItem.getExceptionStatus().equals(EBomExceptionStatusEnum.EXCEPT_NO_3.getValue())) {
|
||||
return ResultVO.error(StrUtil.format("物料{} {}", childBomItem.getMaterialNo(), EBomExceptionStatusEnum.EXCEPT_NO_3.getDescription()));
|
||||
}
|
||||
|
||||
if (childBomItem.getExceptionStatus().equals(EBomExceptionStatusEnum.EXCEPT_NO_4.getValue())) {
|
||||
return ResultVO.error(StrUtil.format("物料{} {}", childBomItem.getMaterialNo(), EBomExceptionStatusEnum.EXCEPT_NO_4.getDescription()));
|
||||
}
|
||||
|
||||
if (childBomItem.getExceptionStatus().equals(EBomExceptionStatusEnum.EXCEPT_NO_6.getValue())) {
|
||||
return ResultVO.error(StrUtil.format("物料{} {}", childBomItem.getMaterialNo(), EBomExceptionStatusEnum.EXCEPT_NO_6.getDescription()));
|
||||
}
|
||||
|
||||
if (childBomItem.getExceptionStatus().equals(EBomExceptionStatusEnum.EXCEPT_NO_7.getValue())) {
|
||||
return ResultVO.error(StrUtil.format("物料{} {}", childBomItem.getMaterialNo(), EBomExceptionStatusEnum.EXCEPT_NO_7.getDescription()));
|
||||
}
|
||||
|
||||
|
||||
if (childBomItem.getExceptionStatus().equals(EBomExceptionStatusEnum.EXCEPT_NO_7.getValue())) {
|
||||
return ResultVO.error(StrUtil.format("物料{} {}", childBomItem.getMaterialNo(), EBomExceptionStatusEnum.EXCEPT_NO_7.getDescription()));
|
||||
}
|
||||
|
||||
if (childBomItem.getExceptionStatus().equals(EBomExceptionStatusEnum.EXCEPT_NO_8.getValue())) {
|
||||
return ResultVO.error(StrUtil.format("物料{} {}", childBomItem.getMaterialNo(), EBomExceptionStatusEnum.EXCEPT_NO_8.getDescription()));
|
||||
}
|
||||
if (childBomItem.getExceptionStatus().equals(EBomExceptionStatusEnum.EXCEPT_NO_9.getValue())) {
|
||||
return ResultVO.error(StrUtil.format("物料{} {}", childBomItem.getMaterialNo(), EBomExceptionStatusEnum.EXCEPT_NO_9.getDescription()));
|
||||
|
||||
}
|
||||
if (childBomItem.getExceptionStatus().equals(EBomExceptionStatusEnum.EXCEPT_NO_10.getValue())) {
|
||||
return ResultVO.error(StrUtil.format("物料{} {}", childBomItem.getMaterialNo(), EBomExceptionStatusEnum.EXCEPT_NO_10.getDescription()));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if(StrUtil.isEmpty(item.getMaterialNo()) || (item.getNum()==null||item.getNum().floatValue()==0) ){
|
||||
return ResultVO.error(EBomExceptionStatusEnum.EXCEPT_NO_4.getDescription());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
updateReviewIdList.addAll( childBomList.stream().map(BomNewEbomParentVO::getRowId).collect(Collectors.toList()));
|
||||
|
||||
}
|
||||
|
||||
|
||||
//改变复核状态
|
||||
|
||||
List<BomNewEbomParentEntity> updateReviewList=new ArrayList<>();
|
||||
for(Long id:updateReviewIdList){
|
||||
BomNewEbomParentEntity entity=new BomNewEbomParentEntity();
|
||||
entity.setRowId(id);
|
||||
entity.setAuditTime(LocalDateTime.now());
|
||||
entity.setAuditUserName(dto.getRevertUserName());
|
||||
updateReviewList.add(entity);
|
||||
}
|
||||
if (!this.updateBatchById(updateReviewList)) {
|
||||
throw new NflgBusinessException(STATE.Error, "复核失败");
|
||||
}
|
||||
|
||||
return ResultVO.success(true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ package com.nflg.product.bomnew.service;
|
|||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.lang.TypeReference;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
|
@ -50,6 +52,9 @@ public class MaterialMainService extends ServiceImpl<MaterialMainMapper, Materia
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 初始化物料基本信息
|
||||
*
|
||||
|
|
@ -170,4 +175,23 @@ public class MaterialMainService extends ServiceImpl<MaterialMainMapper, Materia
|
|||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public List<BaseMaterialVO> getExceptStatList(List<String> materialNos,List<Integer> states) {
|
||||
if (CollUtil.isNotEmpty(materialNos)) {
|
||||
return null;
|
||||
}
|
||||
List<MaterialMainEntity> list= this.lambdaQuery().in(MaterialMainEntity::getMaterialState, states)
|
||||
.in(MaterialMainEntity::getMaterialNo, materialNos).list();
|
||||
return Convert.convert(new TypeReference<List<BaseMaterialVO> >(){
|
||||
|
||||
},list);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue