feat: 推荐采购加返回字段:需求库存在途
This commit is contained in:
@@ -73,5 +73,16 @@ public class WmsPurchasePlanDetailVo {
|
||||
@ExcelProperty(value = "原材料编码")
|
||||
private String rawMaterialCode;
|
||||
|
||||
|
||||
/**
|
||||
* 需求量
|
||||
*/
|
||||
private BigDecimal demand;
|
||||
/**
|
||||
* 库存量
|
||||
*/
|
||||
private BigDecimal inventory;
|
||||
/**
|
||||
* 在途量
|
||||
*/
|
||||
private BigDecimal onTheWay;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ import com.klp.domain.vo.WmsPurchasePlanDetailVo;
|
||||
import com.klp.common.core.mapper.BaseMapperPlus;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 采购计划明细Mapper接口
|
||||
*
|
||||
@@ -18,4 +20,9 @@ import org.apache.ibatis.annotations.Param;
|
||||
public interface WmsPurchasePlanDetailMapper extends BaseMapperPlus<WmsPurchasePlanDetailMapper, WmsPurchasePlanDetail, WmsPurchasePlanDetailVo> {
|
||||
|
||||
Page<WmsPurchasePlanDetailVo> selectVoPagePlus(Page<?> page, @Param("ew") Wrapper<WmsPurchasePlanDetail> wrapper);
|
||||
|
||||
/**
|
||||
* 查在途的原材料
|
||||
*/
|
||||
BigDecimal getByRawMaterialIdAndOnTheWay(Long rawMaterialId);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.klp.common.utils.StringUtils;
|
||||
import com.klp.domain.WmsProductBom;
|
||||
import com.klp.domain.WmsPurchasePlanDetail;
|
||||
import com.klp.domain.WmsRawMaterial;
|
||||
import com.klp.domain.vo.WmsOrderDetailVo;
|
||||
import com.klp.domain.vo.WmsPurchasePlanDetailVo;
|
||||
import com.klp.mapper.WmsPurchasePlanDetailMapper;
|
||||
@@ -84,14 +85,27 @@ public class WmsPurchasePlanServiceImpl implements IWmsPurchasePlanService {
|
||||
vo.setRawMaterialId(bom.getRawMaterialId());
|
||||
vo.setQuantity(vo.getQuantity() == null ? needQty : vo.getQuantity().add(needQty));
|
||||
vo.setUnit(bom.getUnit());
|
||||
vo.setRawMaterialName(wmsRawMaterialMapper.selectById(bom.getRawMaterialId()).getRawMaterialName());
|
||||
vo.setRawMaterialCode(wmsRawMaterialMapper.selectById(bom.getRawMaterialId()).getRawMaterialCode());
|
||||
// 挂载原材料名称编号
|
||||
WmsRawMaterial wmsRawMaterial = wmsRawMaterialMapper.selectById(bom.getRawMaterialId());
|
||||
vo.setRawMaterialName(wmsRawMaterial.getRawMaterialName());
|
||||
vo.setRawMaterialCode(wmsRawMaterial.getRawMaterialCode());
|
||||
materialMap.put(bom.getRawMaterialId(), vo);
|
||||
}
|
||||
}
|
||||
// 3. 查询库存并计算推荐采购量
|
||||
for (WmsPurchasePlanDetailVo vo : materialMap.values()) {
|
||||
// 需求量
|
||||
vo.setDemand(vo.getQuantity());
|
||||
BigDecimal stockQty = wmsStockService.getStockByItemId(vo.getRawMaterialId());
|
||||
// 库存量
|
||||
vo.setInventory(stockQty);
|
||||
// 在途量
|
||||
BigDecimal onTheWayQty = BigDecimal.ZERO;
|
||||
BigDecimal byRawMaterialIdAndOnTheWay = wmsPurchasePlanDetailMapper.getByRawMaterialIdAndOnTheWay(vo.getRawMaterialId());
|
||||
if (byRawMaterialIdAndOnTheWay != null) {
|
||||
onTheWayQty = byRawMaterialIdAndOnTheWay;
|
||||
}
|
||||
vo.setOnTheWay(onTheWayQty);
|
||||
// 要是物料不是产品
|
||||
BigDecimal recommendQty = BigDecimal.ZERO;
|
||||
if (stockQty != null) {
|
||||
|
||||
@@ -31,5 +31,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
|
||||
<select id="getByRawMaterialIdAndOnTheWay" resultType="java.math.BigDecimal">
|
||||
select sum(wpd.quantity)
|
||||
from wms_purchase_plan_detail wpd
|
||||
where wpd.raw_material_id = #{rawMaterialId}
|
||||
and wpd.status = 1
|
||||
and wpd.del_flag = 0
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user