|
@@ -25,6 +25,7 @@ import com.fjhx.purchase.service.subscribe.SubscribeDetailService;
|
|
|
import com.fjhx.tenant.entity.dict.dto.DictTenantDataSelectDto;
|
|
|
import com.fjhx.tenant.entity.dict.vo.DictTenantDataVo;
|
|
|
import com.fjhx.tenant.service.dict.DictTenantDataService;
|
|
|
+import com.fjhx.tenant.utils.DeptUstil;
|
|
|
import com.fjhx.wms.service.warehouse.WarehouseService;
|
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
@@ -113,52 +114,60 @@ public class SubscribeDetailServiceImpl extends ServiceImpl<SubscribeDetailMappe
|
|
|
}
|
|
|
|
|
|
//按类型倒序 先显示合同数据 再显示申购数据
|
|
|
- wrapper.orderByDesc("t2", SubscribeDetail::getDataType);
|
|
|
- wrapper.orderByDesc("t2", SubscribeDetail::getCreateTime);
|
|
|
-
|
|
|
- Page<SubscribeDetailVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
- List<SubscribeDetailVo> list = page.getRecords();
|
|
|
-
|
|
|
- if (list.size() == 0) {
|
|
|
- return page;
|
|
|
- }
|
|
|
-
|
|
|
- // 赋值产品信息
|
|
|
- for (SubscribeDetailVo s : list) {
|
|
|
- Map<Long, ProductInfoVo> productMap = productList.stream().collect(Collectors.toMap(ProductInfoVo::getId, Function.identity()));
|
|
|
- ProductInfoVo productInfo = productMap.get(s.getProductId());
|
|
|
- s.setProductCode(productInfo.getCustomCode());
|
|
|
- s.setProductName(productInfo.getName());
|
|
|
- s.setProductType(productInfo.getType());
|
|
|
- s.setProductCategory(productInfo.getClassifyName());
|
|
|
- s.setProductUnit(productInfo.getUnit());
|
|
|
- s.setProductDefinition(productInfo.getDefinition());
|
|
|
- s.setProductCustomCode(productInfo.getCustomCode());
|
|
|
- s.setProductSpec(productInfo.getSpec());
|
|
|
-
|
|
|
- s.setProductLength(productInfo.getLength());
|
|
|
- s.setProductWidth(productInfo.getWidth());
|
|
|
- s.setProductHeight(productInfo.getHeight());
|
|
|
- }
|
|
|
+ wrapper.orderByDesc("t2", SubscribeDetail::getDataType);
|
|
|
+ wrapper.orderByDesc("t2", SubscribeDetail::getCreateTime);
|
|
|
+
|
|
|
+ Page<SubscribeDetailVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
+ List<SubscribeDetailVo> records = page.getRecords();
|
|
|
+
|
|
|
+ if (records.size() == 0) {
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取生产公司信息
|
|
|
+ List<Long> companyIds = records.stream().map(SubscribeDetail::getCompanyId).collect(Collectors.toList());
|
|
|
+ Map<Long, String> companyNameMap = DeptUstil.getDeptNameMap(companyIds);
|
|
|
+
|
|
|
+ // 赋值产品信息
|
|
|
+ for (SubscribeDetailVo record : records) {
|
|
|
+ Map<Long, ProductInfoVo> productMap = productList.stream().collect(Collectors.toMap(ProductInfoVo::getId, Function.identity()));
|
|
|
+ ProductInfoVo productInfo = productMap.get(record.getProductId());
|
|
|
+ record.setProductCode(productInfo.getCustomCode());
|
|
|
+ record.setProductName(productInfo.getName());
|
|
|
+ record.setProductType(productInfo.getType());
|
|
|
+ record.setProductCategory(productInfo.getClassifyName());
|
|
|
+ record.setProductUnit(productInfo.getUnit());
|
|
|
+ record.setProductDefinition(productInfo.getDefinition());
|
|
|
+ record.setProductCustomCode(productInfo.getCustomCode());
|
|
|
+ record.setProductSpec(productInfo.getSpec());
|
|
|
+
|
|
|
+ record.setProductLength(productInfo.getLength());
|
|
|
+ record.setProductWidth(productInfo.getWidth());
|
|
|
+ record.setProductHeight(productInfo.getHeight());
|
|
|
+
|
|
|
+
|
|
|
+ //赋值生产公司名称
|
|
|
+ record.setCompanyName(companyNameMap.get(record.getCompanyId()));
|
|
|
+ }
|
|
|
|
|
|
// 赋值采购数量
|
|
|
- List<Long> subscribeDetailIds = list.stream().map(SubscribeDetail::getId).collect(Collectors.toList());
|
|
|
- List<PurchaseDetailVo> purchaseDetailsList = purchaseDetailService.getPurchaseCountListBySubscribeDetailIds(subscribeDetailIds);
|
|
|
+ List<Long> subscribeDetailIds = records.stream().map(SubscribeDetail::getId).collect(Collectors.toList());
|
|
|
+ List<PurchaseDetailVo> purchaseDetailsList = purchaseDetailService.getPurchaseCountListBySubscribeDetailIds(subscribeDetailIds);
|
|
|
// List<PurchaseDetail> purchaseDetailsList = purchaseDetailService.list(q -> q.in(PurchaseDetail::getSubscribeDetailId, subscribeDetailIds));
|
|
|
Map<Long, List<PurchaseDetail>> purchaseDetailsMap = purchaseDetailsList.stream().collect(Collectors.groupingBy(PurchaseDetail::getSubscribeDetailId));
|
|
|
- for (SubscribeDetailVo subscribeDetailVo : list) {
|
|
|
- List<PurchaseDetail> purchaseDetails = purchaseDetailsMap.get(subscribeDetailVo.getId());
|
|
|
- if (ObjectUtil.isEmpty(purchaseDetails)) {
|
|
|
- subscribeDetailVo.setPurchaseCount(BigDecimal.ZERO);
|
|
|
- continue;
|
|
|
- }
|
|
|
- BigDecimal count = purchaseDetails.stream().map(PurchaseDetail::getCount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- subscribeDetailVo.setPurchaseCount(count);
|
|
|
- }
|
|
|
-
|
|
|
- corporationService.attributeAssign(list, SubscribeDetailVo::getCorporationId, (item, corporation) -> {
|
|
|
- item.setCorporationName(corporation.getName());
|
|
|
- });
|
|
|
+ for (SubscribeDetailVo subscribeDetailVo : records) {
|
|
|
+ List<PurchaseDetail> purchaseDetails = purchaseDetailsMap.get(subscribeDetailVo.getId());
|
|
|
+ if (ObjectUtil.isEmpty(purchaseDetails)) {
|
|
|
+ subscribeDetailVo.setPurchaseCount(BigDecimal.ZERO);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ BigDecimal count = purchaseDetails.stream().map(PurchaseDetail::getCount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ subscribeDetailVo.setPurchaseCount(count);
|
|
|
+ }
|
|
|
+
|
|
|
+ corporationService.attributeAssign(records, SubscribeDetailVo::getCorporationId, (item, corporation) -> {
|
|
|
+ item.setCorporationName(corporation.getName());
|
|
|
+ });
|
|
|
|
|
|
return page;
|
|
|
}
|