|
|
@ -33,9 +33,7 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* bomService业务层处理 |
|
|
@ -212,7 +210,6 @@ private ISysAttachService attachService; |
|
|
|
return resultList; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//List<ErpBom> filterOneLevelList = oneLevelList.stream().filter(bom -> "1".equals(bom.getUseStatus()) && "1".equals(bom.getAuditStatus())).collect(Collectors.toList());
|
|
|
|
|
|
|
|
// 一阶集合
|
|
|
@ -229,6 +226,91 @@ private ISysAttachService attachService; |
|
|
|
return resultList; |
|
|
|
} |
|
|
|
|
|
|
|
//查询bom子阶(遇到采购类型停止)
|
|
|
|
@Override |
|
|
|
public List<ErpBom> selectPurchaseLimitedErpBomAllLevelList(ErpBom erpBom) { |
|
|
|
List<ErpBom> resultList = new ArrayList<>(); |
|
|
|
//先判断当前父亲节点的bom是否审核通过
|
|
|
|
Long parentId = erpBom.getParentId(); |
|
|
|
//父节点的id
|
|
|
|
Long id = parentId; |
|
|
|
ErpBomVo erpBomVo = erpBomMapper.selectErpBomById(id); |
|
|
|
if (!"1".equals(erpBomVo.getAuditStatus()) && !"1".equals(erpBomVo.getUseStatus())){ |
|
|
|
return resultList; |
|
|
|
} |
|
|
|
// 一阶集合
|
|
|
|
List<ErpBom> oneLevelList = erpBomMapper.selectOtherOrderErpBomSubList(erpBom); |
|
|
|
if(CollectionUtils.isNotEmpty(oneLevelList)){ |
|
|
|
for (ErpBom bom: oneLevelList) { |
|
|
|
resultList.add(bom); |
|
|
|
String materialNo = bom.getMaterialNo(); |
|
|
|
Long level = bom.getLevel(); |
|
|
|
recursionLimitedSubBom(resultList, materialNo, level); |
|
|
|
} |
|
|
|
} |
|
|
|
return resultList; |
|
|
|
} |
|
|
|
|
|
|
|
//循环查询bom子阶(遇到采购类型停止)
|
|
|
|
public void recursionLimitedSubBom(List<ErpBom> resultList, String materialNo, Long level) { |
|
|
|
ErpBom subBom = erpBomMapper.selectErpBomByOneMaterialNo(materialNo); |
|
|
|
if(subBom!=null){ |
|
|
|
Long subId = subBom.getId(); |
|
|
|
ErpBom erpBom1 = new ErpBom(); |
|
|
|
erpBom1.setParentId(subId); |
|
|
|
List<ErpBom> subLevelList = erpBomMapper.selectErpBomSubList(erpBom1); |
|
|
|
if(CollectionUtils.isNotEmpty(subLevelList)){ |
|
|
|
for (ErpBom sub: subLevelList) { |
|
|
|
Long level1 = level+1; |
|
|
|
if(level1 >= 8){ |
|
|
|
break; |
|
|
|
} |
|
|
|
sub.setLevel(level1); |
|
|
|
resultList.add(sub); |
|
|
|
//采购类型的物料生成生产订单时无下阶
|
|
|
|
if(sub.getProcessMethod().equals("0")){ |
|
|
|
break; |
|
|
|
} |
|
|
|
String materialNo1 = sub.getMaterialNo(); |
|
|
|
recursionLimitedSubBom(resultList,materialNo1,level1); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
/** |
|
|
|
* 生产订单关联bom信息列表 |
|
|
|
* */ |
|
|
|
@Override |
|
|
|
public List<ErpBom> selectMakeOrderErpBomAllLevelList(String[] materialNos) { |
|
|
|
List<ErpBom> resultList = new ArrayList<>(); |
|
|
|
//先判断当前节点的bom是否审核通过
|
|
|
|
for (int i = 0;i<materialNos.length;i++){ |
|
|
|
ErpBom erpBom = erpBomMapper.selectErpBomByOneMaterialNo(materialNos[i]); |
|
|
|
if(erpBom==null){ |
|
|
|
/*bom数据库中查询不到该物料,说明未被添加为bom,生成只有料号和层级(1层)的空对象以便页面替换*/ |
|
|
|
ErpBom nullErpBom = new ErpBom(); |
|
|
|
nullErpBom.setMaterialNo(materialNos[i]); |
|
|
|
nullErpBom.setLevel(1L); |
|
|
|
resultList.add(nullErpBom); |
|
|
|
}else{ |
|
|
|
if (!"1".equals(erpBom.getAuditStatus()) && !"1".equals(erpBom.getUseStatus())){ |
|
|
|
throw new BusinessException("料号"+materialNos[i]+"审核未通过或已作废"); |
|
|
|
} |
|
|
|
// 一阶集合(页面上是二阶)
|
|
|
|
List<ErpBom> oneLevelList = erpBomMapper.selectOtherOrderErpBomSubList(erpBom); |
|
|
|
if(CollectionUtils.isNotEmpty(oneLevelList)){ |
|
|
|
for (ErpBom bom: oneLevelList) { |
|
|
|
Long level = bom.getLevel()+1; |
|
|
|
bom.setLevel(level); |
|
|
|
resultList.add(bom); |
|
|
|
String materialNo = bom.getMaterialNo(); |
|
|
|
recursionLimitedSubBom(resultList, materialNo, level); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return resultList; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
@ -576,7 +658,7 @@ private ISysAttachService attachService; |
|
|
|
{ |
|
|
|
ErpBomImportVo bomImportVo = bomImportVos.get(i); |
|
|
|
String materialNo = bomImportVo.getMaterialNo(); |
|
|
|
Double useNum = bomImportVo.getUseNum(); |
|
|
|
Integer useNum = bomImportVo.getUseNum(); |
|
|
|
Double lossRate = bomImportVo.getLossRate(); |
|
|
|
String remark = bomImportVo.getRemark(); |
|
|
|
ErpMaterialVo erpMaterialVo = materialMapper.selectErpMaterialByMaterialNo(materialNo); |
|
|
|