|
@@ -44,7 +44,9 @@ import com.fjhx.purchase.service.subscribe.SubscribeDetailService;
|
|
|
import com.fjhx.purchase.service.subscribe.SubscribeService;
|
|
|
import com.fjhx.supply.entity.supplier.po.SupplierInfo;
|
|
|
import com.fjhx.supply.service.supplier.SupplierInfoService;
|
|
|
+import com.fjhx.wms.entity.stock.po.Stock;
|
|
|
import com.fjhx.wms.entity.warehouse.po.Warehouse;
|
|
|
+import com.fjhx.wms.service.stock.StockService;
|
|
|
import com.fjhx.wms.service.warehouse.WarehouseService;
|
|
|
import com.obs.services.internal.ServiceException;
|
|
|
import com.ruoyi.common.core.domain.BaseSelectDto;
|
|
@@ -114,6 +116,9 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseMapper, Purchase>
|
|
|
@Autowired
|
|
|
private ISysUserService userService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private StockService stockService;
|
|
|
+
|
|
|
/**
|
|
|
* 列表
|
|
|
*
|
|
@@ -298,8 +303,7 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseMapper, Purchase>
|
|
|
PurchaseVo result = BeanUtil.toBean(purchase, PurchaseVo.class);
|
|
|
result.setSupplyName(info.getName());
|
|
|
//查询出采购明细列表
|
|
|
- List<PurchaseDetail> purchaseDetailList = purchaseDetailService.
|
|
|
- list(Wrappers.<PurchaseDetail>query().lambda().eq(PurchaseDetail::getPurchaseId, id));
|
|
|
+ List<PurchaseDetail> purchaseDetailList = purchaseDetailService.list(Wrappers.<PurchaseDetail>query().lambda().eq(PurchaseDetail::getPurchaseId, id));
|
|
|
//查询出产品
|
|
|
if (CollectionUtils.isNotEmpty(purchaseDetailList)) {
|
|
|
//赋值申购编号
|
|
@@ -315,6 +319,8 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseMapper, Purchase>
|
|
|
List<Long> productIds = purchaseDetailList.stream().map(PurchaseDetail::getBussinessId).collect(Collectors.toList());
|
|
|
List<ProductInfoVo> productInfos = productInfoService.getListByProductIds(productIds);
|
|
|
Map<Long, List<ProductInfoVo>> productMap = productInfos.stream().distinct().collect(Collectors.groupingBy(ProductInfoVo::getId));
|
|
|
+ //获取所有仓库次品数量
|
|
|
+ Map<Long, List<Stock>> stockMap = stockService.mapKGroup(Stock::getProductId, q -> q.in(Stock::getProductId, productIds));
|
|
|
if (MapUtils.isNotEmpty(productMap)) {
|
|
|
for (PurchaseDetail p : purchaseDetailList) {
|
|
|
//查询出到货总量
|
|
@@ -329,6 +335,18 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseMapper, Purchase>
|
|
|
p.setProductUnit(vo.getUnit());
|
|
|
p.setProductSpec(vo.getSpec());
|
|
|
p.setProductCustomCode(vo.getCustomCode());
|
|
|
+ //赋值次品数量
|
|
|
+ List<Stock> stockList = stockMap.get(p.getBussinessId());
|
|
|
+ if (ObjectUtils.isNotEmpty(stockList)) {
|
|
|
+ BigDecimal defectiveQuantity = BigDecimal.ZERO;
|
|
|
+ for (Stock stock : stockList) {
|
|
|
+ JSONObject json = JSONObject.parseObject(stock.getVictoriatouristJson());
|
|
|
+ if (ObjectUtils.isNotEmpty(json) && ObjectUtil.isNotEmpty(json.get("defectiveQuantity"))) {
|
|
|
+ defectiveQuantity = defectiveQuantity.add(json.getBigDecimal("defectiveQuantity"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ p.setDefectiveQuantity(defectiveQuantity);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|