24282 2 år sedan
förälder
incheckning
ac8fbf84ad

+ 1 - 1
hx-service-api/victoriatourist-api/src/main/java/com/fjhx/entity/apply/ApplyPurchase.java

@@ -64,7 +64,7 @@ public class ApplyPurchase extends BaseEntity {
     private Long receiptWarehouseId;
     private Long receiptWarehouseId;
 
 
     /**
     /**
-     * 状态:10、待采购;20、已驳回;30、采购审批中;40、已采购;50、已完成
+     * 状态:10、申购审批中;20、申购审批已驳回;30、申购审批已通过;40、采购审批中;50、采购审批已驳回;60、采购审批已通过;70、已完成
      */
      */
     private Integer status;
     private Integer status;
 
 

+ 8 - 1
hx-service-api/victoriatourist-api/src/main/java/com/fjhx/entity/purchase/Purchase.java

@@ -39,7 +39,7 @@ public class Purchase extends BaseEntity {
     private BigDecimal price;
     private BigDecimal price;
 
 
     /**
     /**
-     * 状态:10、审批中;20、驳回;30、未到货;40、部分到货;50、已到货;99、取消
+     * 发货状态:10、审批中;20、驳回;30、未到货;40、部分到货;50、已到货;99、取消
      */
      */
     private Integer status;
     private Integer status;
 
 
@@ -94,4 +94,11 @@ public class Purchase extends BaseEntity {
      */
      */
     @TableField(exist = false)
     @TableField(exist = false)
     private List<ApplyPurchase> goodsList;
     private List<ApplyPurchase> goodsList;
+
+    /**
+     * 供应商名称
+     */
+    @TableField(exist = false)
+    private String supplierName;
+
 }
 }

+ 35 - 18
hx-service/victoriatourist/src/main/java/com/fjhx/service/purchase/impl/PurchaseServiceImpl.java

@@ -3,15 +3,18 @@ package com.fjhx.service.purchase.impl;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fjhx.base.BaseEntity;
 import com.fjhx.entity.apply.ApplyPurchase;
 import com.fjhx.entity.apply.ApplyPurchase;
 import com.fjhx.entity.logistics.LogisticsInfo;
 import com.fjhx.entity.logistics.LogisticsInfo;
 import com.fjhx.entity.purchase.Purchase;
 import com.fjhx.entity.purchase.Purchase;
+import com.fjhx.entity.supplier.Supplier;
 import com.fjhx.enums.apply.ApplyPurchaseStatusEnum;
 import com.fjhx.enums.apply.ApplyPurchaseStatusEnum;
 import com.fjhx.enums.purchase.PurchaseStatusEnum;
 import com.fjhx.enums.purchase.PurchaseStatusEnum;
 import com.fjhx.mapper.purchase.PurchaseMapper;
 import com.fjhx.mapper.purchase.PurchaseMapper;
 import com.fjhx.service.apply.ApplyPurchaseService;
 import com.fjhx.service.apply.ApplyPurchaseService;
 import com.fjhx.service.logistics.LogisticsInfoService;
 import com.fjhx.service.logistics.LogisticsInfoService;
 import com.fjhx.service.purchase.PurchaseService;
 import com.fjhx.service.purchase.PurchaseService;
+import com.fjhx.service.supplier.SupplierService;
 import com.fjhx.utils.UserClientUtil;
 import com.fjhx.utils.UserClientUtil;
 import com.fjhx.utils.wrapperUtil.IWrapper;
 import com.fjhx.utils.wrapperUtil.IWrapper;
 import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.log.exception.ServiceException;
@@ -41,6 +44,9 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseMapper, Purchase> i
     @Autowired
     @Autowired
     private LogisticsInfoService logisticsInfoService;
     private LogisticsInfoService logisticsInfoService;
 
 
+    @Autowired
+    private SupplierService supplierService;
+
     /**
     /**
      * 待采购列表
      * 待采购列表
      *
      *
@@ -69,25 +75,36 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseMapper, Purchase> i
                 .orderByDesc(ApplyPurchase::getId);
                 .orderByDesc(ApplyPurchase::getId);
 
 
         Page<Purchase> page = page(condition, wrapper);
         Page<Purchase> page = page(condition, wrapper);
-        if (Func.isNotEmpty(page.getRecords())) {
-            //采购ID集合
-            List<Long> purchaseIds = page.getRecords().stream().map(Purchase::getId).distinct().collect(Collectors.toList());
-            //查询物流信息
-            Map<Long, List<LogisticsInfo>> logisticsInfoMap = logisticsInfoService.getByPurchaseIdsToMap(purchaseIds);
-
-            //采购人名称map
-            Map<Long, String> userNameMap = UserClientUtil.getUserNameMap(page.getRecords(), Purchase::getCreateUser);
-
-            for (Purchase record : page.getRecords()) {
-                if (Func.isNotEmpty(logisticsInfoMap) && Func.isNotEmpty(logisticsInfoMap.get(record.getId()))) {
-                    List<LogisticsInfo> infos = logisticsInfoMap.get(record.getId());
-                    record.setLogisticsCode(infos.stream().map(LogisticsInfo::getCode).distinct().collect(Collectors.joining(",")));
-                }
-
-                if (Func.isNotEmpty(userNameMap) && Func.isNotEmpty(userNameMap.get(record.getCreateUser()))) {
-                    record.setCreateName(userNameMap.get(record.getCreateUser()));
-                }
+
+        List<Purchase> records = page.getRecords();
+
+        if (records.size() == 0) {
+            return page;
+        }
+
+        // 采购ID集合
+        List<Long> purchaseIds = records.stream().map(Purchase::getId).distinct().collect(Collectors.toList());
+
+        // 查询物流信息
+        Map<Long, List<LogisticsInfo>> logisticsInfoMap = logisticsInfoService.getByPurchaseIdsToMap(purchaseIds);
+
+        // 采购人名称map
+        Map<Long, String> userNameMap = UserClientUtil.getUserNameMap(records, Purchase::getCreateUser);
+
+        // 供应商
+        List<Long> supplierIdList = records.stream().map(Purchase::getSupplierId).filter(ObjectUtil::isNotEmpty).collect(Collectors.toList());
+        Map<Long, String> supplierIdNameMap = supplierService.getKV(Supplier::getId, Supplier::getName, q -> q.in(BaseEntity::getId, supplierIdList));
+
+        for (Purchase record : records) {
+            // 赋值物流单号
+            List<LogisticsInfo> logisticsInfos = logisticsInfoMap.get(record.getId());
+            if (ObjectUtil.isNotEmpty(logisticsInfos)) {
+                record.setLogisticsCode(logisticsInfos.stream().map(LogisticsInfo::getCode).distinct().collect(Collectors.joining(",")));
             }
             }
+            // 赋值采购人名称
+            record.setCreateName(userNameMap.get(record.getCreateUser()));
+            // 赋值供应商名称
+            record.setSupplierName(supplierIdNameMap.get(ObjectUtil.defaultIfNull(record.getSupplierId(), -1L)));
         }
         }
 
 
         return page;
         return page;