|
|
|
@ -180,7 +180,7 @@ public class ChanjetSchedule {
|
|
|
|
|
if(CollUtil.isNotEmpty(projectOrderSubDOS)){
|
|
|
|
|
for (ProjectOrderSubDO so : projectOrderSubDOS) {
|
|
|
|
|
if(!codes.contains(so.getProjectSubCode()) && !StringUtils.isEmpty(so.getWarehouseId())) {
|
|
|
|
|
List<BomMaterialVO> bomMaterialVOS = chanjetManager.queryProcessBom(so.getProjectSubCode(), so.getWarehouseId());
|
|
|
|
|
List<BomMaterialVO> bomMaterialVOS = queryProcessBom(so.getProjectSubCode(), so.getWarehouseId());
|
|
|
|
|
if (CollUtil.isNotEmpty(bomMaterialVOS)) {
|
|
|
|
|
|
|
|
|
|
List<TplusLastestBomDO> insertList = BeanUtils.toBean(bomMaterialVOS, TplusLastestBomDO.class);
|
|
|
|
@ -201,6 +201,71 @@ public class ChanjetSchedule {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<BomMaterialVO> queryProcessBom(String materialCode, Long warehouseId) throws ChanjetApiException {
|
|
|
|
|
|
|
|
|
|
List<BomMaterialVO> resultData = new ArrayList<>(16);
|
|
|
|
|
|
|
|
|
|
List<BOMChildDTOs> bomDataList = null;
|
|
|
|
|
// 设置为“否”,关闭所有与用友通信的接口;为“是”,打开所有与用友通信的接口
|
|
|
|
|
if(getSystemParameters()) {
|
|
|
|
|
CommonResult<List<QueryBomResVO>> result =
|
|
|
|
|
chanjetSpi.invokeRetList(QUERY_BOM, new QueryBomReqVO(new QueryBomReqVO.QueryBomDTO(materialCode)), QueryBomResVO.class);
|
|
|
|
|
if (!result.isSuccess()) {
|
|
|
|
|
throw exception(CALL_API_ERROR);
|
|
|
|
|
}
|
|
|
|
|
if (CollUtil.isNotEmpty(result.getData())) {
|
|
|
|
|
QueryBomResVO topLayer = result.getData().get(0);
|
|
|
|
|
bomDataList = topLayer.getBOMChildDTOs();
|
|
|
|
|
if (CollUtil.isNotEmpty(bomDataList)) {
|
|
|
|
|
for (BOMChildDTOs dto : bomDataList) {
|
|
|
|
|
ChildBOM childBOM = dto.getChildBOM();
|
|
|
|
|
if (childBOM != null) {
|
|
|
|
|
dto.setVersion(childBOM.getVersion())
|
|
|
|
|
.setBOMChildDTOs(queryProcessBomById(childBOM.getID()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 数据包装
|
|
|
|
|
if(CollUtil.isNotEmpty(bomDataList)){
|
|
|
|
|
for (BOMChildDTOs dto : bomDataList) {
|
|
|
|
|
resultData.addAll(getChildrenBomMaterial(2, dto.getBOMChildDTOs(), warehouseId));
|
|
|
|
|
dto.setBOMChildDTOs(null); // 避免重复数据
|
|
|
|
|
resultData.addAll(getChildrenBomMaterial(1, Arrays.asList(dto), warehouseId));
|
|
|
|
|
}
|
|
|
|
|
resultData.sort(Comparator.comparing(BomMaterialVO::getSort));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return resultData;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<BOMChildDTOs> queryProcessBomById(String bomId) throws ChanjetApiException {
|
|
|
|
|
// 设置为“否”,关闭所有与用友通信的接口
|
|
|
|
|
if(!getSystemParameters()) return null;
|
|
|
|
|
List<BOMChildDTOs> resultData = null;
|
|
|
|
|
QueryBomReqVO.QueryBomDTO queryBomDTO = new QueryBomReqVO.QueryBomDTO();
|
|
|
|
|
queryBomDTO.setID(bomId);
|
|
|
|
|
CommonResult<List<QueryBomResVO>> result = chanjetSpi.invokeRetList(QUERY_BOM, new QueryBomReqVO(queryBomDTO), QueryBomResVO.class);
|
|
|
|
|
if(!result.isSuccess()){
|
|
|
|
|
throw exception(CALL_API_ERROR);
|
|
|
|
|
}
|
|
|
|
|
if(CollUtil.isNotEmpty(result.getData())){
|
|
|
|
|
QueryBomResVO topLayer = result.getData().get(0);
|
|
|
|
|
resultData = topLayer.getBOMChildDTOs();
|
|
|
|
|
if(CollUtil.isNotEmpty(resultData)){
|
|
|
|
|
for (BOMChildDTOs dto : resultData) {
|
|
|
|
|
ChildBOM childBOM = dto.getChildBOM();
|
|
|
|
|
if(childBOM != null){
|
|
|
|
|
dto.setBOMChildDTOs(queryProcessBomById(childBOM.getID()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return resultData;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<BomMaterialVO> getChildrenBomMaterial(int layer, List<BOMChildDTOs> childrenBomList, Long warehouseId) throws ChanjetApiException {
|
|
|
|
|
List<BomMaterialVO> resultData = new ArrayList<>(16);
|
|
|
|
|
if (CollUtil.isNotEmpty(childrenBomList)){
|
|
|
|
@ -231,46 +296,22 @@ public class ChanjetSchedule {
|
|
|
|
|
}
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public List<QueryCurrentStockResVO> queryStock(List<String> materialCodeList, Long warehouseId) throws ChanjetApiException {
|
|
|
|
|
List<QueryCurrentStockResVO> dataList = null;
|
|
|
|
|
// 设置为“否”,关闭所有与用友通信的接口;为“是”,打开所有与用友通信的接口
|
|
|
|
|
if(getSystemParameters()) {
|
|
|
|
|
CommonResult<List<QueryCurrentStockResVO>> result = chanjetSpi.invokeRetList(QUERY_CURRENT_STOCK, new QueryCurrentStockReqVO(new QueryCurrentStockReqVO.QueryCurrentStockParamVO(materialCodeList)), QueryCurrentStockResVO.class);
|
|
|
|
|
if (!result.isSuccess()) {
|
|
|
|
|
throw exception(CALL_API_ERROR);
|
|
|
|
|
}
|
|
|
|
|
dataList = result.getData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(dataList == null) dataList = new ArrayList<>(16);
|
|
|
|
|
List<QueryCurrentStockResVO> dataList = new ArrayList<>(16);
|
|
|
|
|
|
|
|
|
|
List<MaterialDO> materialDOList = materialMapper.selectList(MaterialDO::getCode, materialCodeList);
|
|
|
|
|
Map<String, List<MaterialDO>> materialsGroupByCode = materialDOList.stream().collect(Collectors.groupingBy(MaterialDO::getCode));
|
|
|
|
|
|
|
|
|
|
// 无存货信息,物料信息从物料表取
|
|
|
|
|
for (String code : materialCodeList) {
|
|
|
|
|
MaterialDO aDo = materialsGroupByCode.get(code).get(0);
|
|
|
|
|
List<QueryCurrentStockResVO> currentStockList = dataList.stream().filter(vo -> code.equals(vo.getInventoryCode())).collect(Collectors.toList());
|
|
|
|
|
if(CollUtil.isEmpty(currentStockList)){
|
|
|
|
|
QueryCurrentStockResVO resVO = new QueryCurrentStockResVO();
|
|
|
|
|
resVO.setInventoryCode(code)
|
|
|
|
|
.setInventoryName(aDo.getName())
|
|
|
|
|
.setInventoryClassCode(aDo.getMaterialType())
|
|
|
|
|
.setSpecification(aDo.getSpec())
|
|
|
|
|
.setUnitID(aDo.getUnit())
|
|
|
|
|
.setUnitName(aDo.getUnit())
|
|
|
|
|
.setInventoryID(aDo.getId())
|
|
|
|
|
.setAvailableQuantity("0");
|
|
|
|
|
dataList.add(resVO);
|
|
|
|
|
}else{
|
|
|
|
|
currentStockList.forEach(currentStock -> {
|
|
|
|
|
if(!StringUtils.isEmpty(currentStock.getSpecification())){
|
|
|
|
|
currentStock.setSpecification(aDo.getSpec());
|
|
|
|
|
}
|
|
|
|
|
if(warehouseId != null && currentStock.getWarehouseID().longValue() != warehouseId.longValue()){
|
|
|
|
|
currentStock.setAvailableQuantity("0");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
for (MaterialDO aDo : materialDOList) {
|
|
|
|
|
QueryCurrentStockResVO resVO = new QueryCurrentStockResVO();
|
|
|
|
|
resVO.setInventoryCode(aDo.getCode())
|
|
|
|
|
.setInventoryName(aDo.getName())
|
|
|
|
|
.setInventoryClassCode(aDo.getMaterialType())
|
|
|
|
|
.setSpecification(aDo.getSpec())
|
|
|
|
|
.setUnitID(aDo.getUnit())
|
|
|
|
|
.setUnitName(aDo.getUnit())
|
|
|
|
|
.setInventoryID(aDo.getId())
|
|
|
|
|
.setAvailableQuantity("0");
|
|
|
|
|
dataList.add(resVO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return dataList;
|
|
|
|
@ -536,7 +577,8 @@ public class ChanjetSchedule {
|
|
|
|
|
newDo.setMaterialId(materialDO.getId());
|
|
|
|
|
newDo.setWarehouseId(warehouseDO.getId());
|
|
|
|
|
newDo.setAmount(absValue.abs().intValue());
|
|
|
|
|
newDo.setOrderAmount(absValue.abs().intValue());
|
|
|
|
|
// 生成挤塑订单时,订单数量要给0
|
|
|
|
|
newDo.setOrderAmount(0);
|
|
|
|
|
newDo.setStatus(true);
|
|
|
|
|
subDOList.add(newDo);
|
|
|
|
|
}
|
|
|
|
@ -569,13 +611,4 @@ public class ChanjetSchedule {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 自定义多字段去重比较器
|
|
|
|
|
public static <T> Predicate<T> distinctByKeys(Function<? super T, ? extends List<?>> keyExtractors) {
|
|
|
|
|
Map<List<?>, Boolean> seen = new ConcurrentHashMap<>();
|
|
|
|
|
return t -> {
|
|
|
|
|
List<?> keys = keyExtractors.apply(t);
|
|
|
|
|
return seen.putIfAbsent(keys, Boolean.TRUE) == null;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|