feat(wms): 添加原材料在途信息功能
- 在 WmsStockServiceImpl 中添加填充原材料在途信息的方法 - 在 WmsStockVo 中添加在途量字段 - 通过查询采购计划明细来获取在途量
This commit is contained in:
@@ -86,4 +86,10 @@ public class WmsStockVo {
|
||||
@ExcelProperty(value = "仓库/库区名称")
|
||||
private String warehouseName;
|
||||
|
||||
/**
|
||||
* 在途量
|
||||
*/
|
||||
@ExcelProperty(value = "在途量")
|
||||
private BigDecimal onTheWay;
|
||||
|
||||
}
|
||||
|
||||
@@ -8,6 +8,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.klp.common.utils.StringUtils;
|
||||
import com.klp.domain.bo.WmsPurchasePlanDetailBo;
|
||||
import com.klp.domain.vo.WmsPurchasePlanDetailVo;
|
||||
import com.klp.domain.vo.WmsRawMaterialVo;
|
||||
import com.klp.service.IWmsPurchasePlanDetailService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.klp.domain.bo.WmsStockBo;
|
||||
@@ -36,6 +40,8 @@ public class WmsStockServiceImpl implements IWmsStockService {
|
||||
|
||||
private final WmsStockMapper baseMapper;
|
||||
private final WmsWarehouseMapper warehouseMapper;
|
||||
private final IWmsPurchasePlanDetailService purchasePlanDetailService;
|
||||
|
||||
|
||||
/**
|
||||
* 查询库存:原材料/产品与库区/库位的存放关系
|
||||
@@ -52,9 +58,40 @@ public class WmsStockServiceImpl implements IWmsStockService {
|
||||
public TableDataInfo<WmsStockVo> queryPageList(WmsStockBo bo, PageQuery pageQuery) {
|
||||
QueryWrapper<WmsStock> lqw = buildQueryWrapperPlus(bo);
|
||||
Page<WmsStockVo> result = baseMapper.selectVoPagePlus(pageQuery.build(), lqw);
|
||||
fillDemandInfo(result.getRecords());
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 填充原材料在途信息
|
||||
*/
|
||||
private void fillDemandInfo(List<WmsStockVo> rawMaterialList) {
|
||||
if (rawMaterialList == null || rawMaterialList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
// 为每个原材料填充信息
|
||||
for (WmsStockVo vo : rawMaterialList) {
|
||||
Long rawMaterialId = vo.getItemId();
|
||||
// 查询在途量(采购计划明细)
|
||||
BigDecimal onTheWay = getOnTheWayQuantity(rawMaterialId);
|
||||
vo.setOnTheWay(onTheWay);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取在途量
|
||||
*/
|
||||
private BigDecimal getOnTheWayQuantity(Long rawMaterialId) {
|
||||
WmsPurchasePlanDetailBo bo = new WmsPurchasePlanDetailBo();
|
||||
bo.setRawMaterialId(rawMaterialId);
|
||||
List<WmsPurchasePlanDetailVo> list = purchasePlanDetailService.queryList(bo);
|
||||
return list.stream()
|
||||
.filter(item -> item.getStatus() != null && item.getStatus() == 1) // 在途状态
|
||||
.map(WmsPurchasePlanDetailVo::getQuantity)
|
||||
.filter(qty -> qty != null)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询库存:原材料/产品与库区/库位的存放关系列表
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user