Merge remote-tracking branch 'origin/0.8.X' into 0.8.X
This commit is contained in:
@@ -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;
|
||||
@@ -80,23 +81,38 @@ public class WmsPurchasePlanServiceImpl implements IWmsPurchasePlanService {
|
||||
List<WmsProductBom> bomList = wmsProductBomService.listByProductId(detail.getProductId());
|
||||
for (WmsProductBom bom : bomList) {
|
||||
BigDecimal needQty = bom.getQuantity().multiply(detail.getQuantity());
|
||||
WmsPurchasePlanDetailVo vo = materialMap.getOrDefault(bom.getRawMaterialId(), new WmsPurchasePlanDetailVo());
|
||||
WmsPurchasePlanDetailVo vo =
|
||||
materialMap.getOrDefault(bom.getRawMaterialId(), new WmsPurchasePlanDetailVo());
|
||||
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());
|
||||
// 要是物料不是产品
|
||||
BigDecimal recommendQty = BigDecimal.ZERO;
|
||||
if (stockQty != null) {
|
||||
recommendQty = vo.getQuantity().subtract(stockQty);
|
||||
// 库存量
|
||||
if(stockQty == null){
|
||||
stockQty = BigDecimal.ZERO;
|
||||
}
|
||||
vo.setInventory(stockQty);
|
||||
// 在途量
|
||||
BigDecimal onTheWayQty = BigDecimal.ZERO;
|
||||
BigDecimal byRawMaterialIdAndOnTheWay =
|
||||
wmsPurchasePlanDetailMapper.getByRawMaterialIdAndOnTheWay(vo.getRawMaterialId());
|
||||
if (byRawMaterialIdAndOnTheWay != null) {
|
||||
onTheWayQty = byRawMaterialIdAndOnTheWay;
|
||||
}
|
||||
vo.setOnTheWay(onTheWayQty);
|
||||
// 计算推荐采购量
|
||||
BigDecimal recommendQty = vo.getQuantity().subtract(onTheWayQty).subtract(stockQty);
|
||||
vo.setQuantity(recommendQty.compareTo(BigDecimal.ZERO) > 0 ? recommendQty : BigDecimal.ZERO);
|
||||
}
|
||||
// 4. 组装主VO
|
||||
@@ -182,9 +198,11 @@ public class WmsPurchasePlanServiceImpl implements IWmsPurchasePlanService {
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
// 逻辑删除采购明细
|
||||
LambdaQueryWrapper<WmsPurchasePlanDetail> lqw = Wrappers.lambdaQuery();
|
||||
lqw.in(WmsPurchasePlanDetail::getPlanId, ids);
|
||||
wmsPurchasePlanDetailMapper.delete(lqw);
|
||||
// 逻辑删除采购计划主表
|
||||
return baseMapper.deleteBatchIds(ids) > 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user