Browse Source

[update] 区间统计逻辑整改, 基于区间开始时间及区间结束时间计算, 不获取司机日货损统计

miajio 1 week ago
parent
commit
cfeb7ccca9
34 changed files with 871 additions and 180 deletions
  1. 2 1
      warehouse-admin-component/src/main/java/com/yr/warehouse/admin/component/driver/DriverDeviceSalesComponent.java
  2. 27 0
      warehouse-admin-data/src/main/java/com/yr/warehouse/admin/areastaff/mapper/DriverWarehouseMapper.java
  3. 129 0
      warehouse-admin-data/src/main/java/com/yr/warehouse/admin/areastaff/vo/AreaStaffVo.java
  4. 5 0
      warehouse-admin-data/src/main/java/com/yr/warehouse/admin/driver/bo/DriverIntervalCargoDamageGeneratorBo.java
  5. 2 2
      warehouse-admin-data/src/main/java/com/yr/warehouse/admin/driver/data/DriverGoodsLossIntervalDetail.java
  6. 6 0
      warehouse-admin-data/src/main/java/com/yr/warehouse/admin/driver/data/DriverGoodsLossIntervalMain.java
  7. 3 2
      warehouse-admin-data/src/main/java/com/yr/warehouse/admin/driver/mapper/DriverEquipmentLossRecordMapper.java
  8. 2 2
      warehouse-admin-data/src/main/java/com/yr/warehouse/admin/driver/mapper/DriverGoodsLossIntervalMainMapper.java
  9. 1 1
      warehouse-admin-data/src/main/java/com/yr/warehouse/admin/driver/mapper/DriverGoodsLossRecordMapper.java
  10. 2 1
      warehouse-admin-data/src/main/java/com/yr/warehouse/admin/driver/mapper/DriverOnRouteDetailLogMapper.java
  11. 10 0
      warehouse-admin-data/src/main/java/com/yr/warehouse/admin/driver/vo/DriverIntervalCargoDamageVo.java
  12. 13 7
      warehouse-admin-data/src/main/java/com/yr/warehouse/admin/statistics/mapper/BillingQuantityStatisticsMapper.java
  13. 71 0
      warehouse-admin-data/src/main/java/com/yr/warehouse/admin/statistics/vo/DriverStatisticsVo.java
  14. 67 0
      warehouse-admin-data/src/main/resources/mapper/areaStaff/DriverWarehouseMapper.xml
  15. 1 1
      warehouse-admin-data/src/main/resources/mapper/driver/DriverEquipmentLossRecordMapper.xml
  16. 11 6
      warehouse-admin-data/src/main/resources/mapper/driver/DriverGoodsLossIntervalMainMapper.xml
  17. 1 1
      warehouse-admin-data/src/main/resources/mapper/driver/DriverGoodsLossRecordMapper.xml
  18. 1 1
      warehouse-admin-data/src/main/resources/mapper/driver/DriverOnRouteDetailLogMapper.xml
  19. 117 65
      warehouse-admin-data/src/main/resources/mapper/statistics/BillingQuantityStatisticsMapper.xml
  20. 4 4
      warehouse-admin-event/src/main/java/com/yr/warehouse/admin/event/task/DriverCargoDamageStatisticsTask.java
  21. 3 2
      warehouse-admin-server/src/main/java/com/yr/warehouse/admin/service/driver/DriverGoodsLossIntervalMainService.java
  22. 19 0
      warehouse-admin-server/src/main/java/com/yr/warehouse/admin/service/driver/DriverWarehouseService.java
  23. 2 2
      warehouse-admin-server/src/main/java/com/yr/warehouse/admin/service/driver/impl/DriverGoodsLossIntervalMainServiceImpl.java
  24. 28 24
      warehouse-admin-server/src/main/java/com/yr/warehouse/admin/service/driver/impl/DriverGoodsLossIntervalServiceImpl.java
  25. 30 0
      warehouse-admin-server/src/main/java/com/yr/warehouse/admin/service/driver/impl/DriverWarehouseServiceImpl.java
  26. 0 17
      warehouse-admin-server/src/main/java/com/yr/warehouse/admin/service/statistics/DriverStatistics.java
  27. 30 0
      warehouse-admin-server/src/main/java/com/yr/warehouse/admin/service/statistics/DriverStatisticsService.java
  28. 79 36
      warehouse-admin-server/src/main/java/com/yr/warehouse/admin/service/statistics/impl/DriverStatisticsServiceImpl.java
  29. 5 5
      warehouse-admin-web/src/main/java/com/yr/warehouse/admin/web/driver/controller/DriverIntervalCargoDamageController.java
  30. 40 0
      warehouse-admin-web/src/main/java/com/yr/warehouse/admin/web/driver/controller/DriverWarehouseController.java
  31. 16 0
      warehouse-admin-web/src/main/java/com/yr/warehouse/admin/web/driver/mapstruct/DriverWarehouseMapStruct.java
  32. 6 0
      warehouse-admin-web/src/main/java/com/yr/warehouse/admin/web/driver/request/DriverIntervalCargoDamageGeneratorRequest.java
  33. 128 0
      warehouse-admin-web/src/main/java/com/yr/warehouse/admin/web/driver/response/DriverAreaStaffResponse.java
  34. 10 0
      warehouse-admin-web/src/main/java/com/yr/warehouse/admin/web/driver/response/DriverIntervalCargoDamageResponse.java

+ 2 - 1
warehouse-admin-component/src/main/java/com/yr/warehouse/admin/component/driver/DriverDeviceSalesComponent.java

@@ -28,11 +28,12 @@ public class DriverDeviceSalesComponent {
      * @param endTime 结束时间
      * @return
      */
-    public List<DriverDeviceSalesResponse> list(LocalDateTime startTime, LocalDateTime endTime) {
+    public List<DriverDeviceSalesResponse> list(List<Long> areaStaffIds, LocalDateTime startTime, LocalDateTime endTime) {
         DriverDeviceSalesRequest request = new DriverDeviceSalesRequest();
         request.setAppId(apolloConfigEvent.getAppId());
         request.setStartTime(startTime);
         request.setEndTime(endTime);
+        request.setAreaStaffIds(areaStaffIds);
         Result<List<DriverDeviceSalesResponse>> result = driverDeviceSalesApi.list(request);
         return result.getData();
     }

+ 27 - 0
warehouse-admin-data/src/main/java/com/yr/warehouse/admin/areastaff/mapper/DriverWarehouseMapper.java

@@ -0,0 +1,27 @@
+package com.yr.warehouse.admin.areastaff.mapper;
+
+import com.yr.warehouse.admin.areastaff.vo.AreaStaffVo;
+import com.yr.warehouse.admin.common.bo.BaseIdBo;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 仓库司机关系映射器
+ */
+@Mapper
+public interface DriverWarehouseMapper {
+    /**
+     * 根据仓库id查询仓库司机关系
+     * @param warehouseId 仓库id
+     * @return 仓库司机关系
+     */
+    List<AreaStaffVo> searchByWarehouseId(@Param("warehouseId") Long warehouseId);
+
+    /**
+     * 查询所有仓库司机
+     * @return 所有仓库司机
+     */
+    List<AreaStaffVo> all();
+}

+ 129 - 0
warehouse-admin-data/src/main/java/com/yr/warehouse/admin/areastaff/vo/AreaStaffVo.java

@@ -0,0 +1,129 @@
+package com.yr.warehouse.admin.areastaff.vo;
+
+import com.yr.warehouse.admin.areastaff.fase.AreaStaffIdFace;
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+/**
+ * 区域员工信息
+ */
+@Data
+public class AreaStaffVo implements AreaStaffIdFace, Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 区域员工id
+     */
+    private Long areaStaffId;
+
+    /**
+     * 区域员工名称
+     */
+    private String areaStaffName;
+
+    /**
+     * 区域链名称
+     */
+    private String areaChainName;
+
+    /**
+     * 区域员工id
+     */
+    private Long id;
+
+    /**
+     * 运营商id
+     */
+    private Long operatorId;
+
+    /**
+     * 运营商id链
+     */
+    private String operatorChain;
+
+    /**
+     * 区域id
+     */
+    private Long areaId;
+
+    /**
+     * 区域链
+     */
+    private String areaChain;
+
+    /**
+     * 员工id
+     */
+    private Long employeeId;
+
+    /**
+     * 员工名称
+     */
+    private String employeeName;
+
+    /**
+     * 账号id
+     */
+    private Long accountId;
+
+    /**
+     * 汽车装框数
+     */
+    private Integer carBoxNum;
+
+    /**
+     * 最大整件单修改拣货数比例
+     */
+    private BigDecimal maxAggregationPickingRatio;
+
+    /**
+     * 创建时间
+     */
+    private LocalDateTime createTime;
+
+    /**
+     * 创建人uid
+     */
+    private Long createUid;
+
+    /**
+     * 创建人名称
+     */
+    private String createName;
+
+    /**
+     * 修改时间
+     */
+    private LocalDateTime modifyTime;
+
+    /**
+     * 修改人uid
+     */
+    private Long modifyUid;
+
+    /**
+     * 修改人名称
+     */
+    private String modifyName;
+
+    /**
+     * 删除状态:NORMAL:正常|DELETE:删除
+     */
+    private String isDelete;
+
+    /**
+     * 员工负责人账户id
+     */
+    private Long managerAccountId;
+
+    /**
+     * 员工负责人账户名称
+     */
+    private String managerAccountName;
+}

+ 5 - 0
warehouse-admin-data/src/main/java/com/yr/warehouse/admin/driver/bo/DriverIntervalCargoDamageGeneratorBo.java

@@ -26,6 +26,11 @@ public class DriverIntervalCargoDamageGeneratorBo extends BaseBo implements Seri
     private Long operatorId;
 
     /**
+     * 仓库id
+     */
+    private Long warehouseId;
+
+    /**
      * 统计类型 SPOT_CHECK 抽查(指定补货员) REGULAR 定期(全部补货员)
      */
     private String stockTakingType;

+ 2 - 2
warehouse-admin-data/src/main/java/com/yr/warehouse/admin/driver/data/DriverGoodsLossIntervalDetail.java

@@ -86,13 +86,13 @@ public class DriverGoodsLossIntervalDetail implements Serializable {
     private Long returnWarehouseNum;
 
     /**
-     * 剩余未补货数 - 理论计算
+     * 剩余未补货数 - 实际流水
      */
     @TableField("remainingUnReplenishedNum")
     private Long remainingUnReplenishedNum;
 
     /**
-     * 在途库存数 - 实际流水
+     * 在途库存数 - 理论计算
      */
     @TableField("onRouteStock")
     private Long onRouteStock;

+ 6 - 0
warehouse-admin-data/src/main/java/com/yr/warehouse/admin/driver/data/DriverGoodsLossIntervalMain.java

@@ -56,6 +56,12 @@ public class DriverGoodsLossIntervalMain implements Serializable {
     private String operatorChain;
 
     /**
+     * 仓库id
+     */
+    @TableField("warehouseId")
+    private Long warehouseId;
+
+    /**
      * 统计类型 SPOT_CHECK 抽查(指定补货员) REGULAR 定期(全部补货员)
      */
     @TableField("stockTakingType")

+ 3 - 2
warehouse-admin-data/src/main/java/com/yr/warehouse/admin/driver/mapper/DriverEquipmentLossRecordMapper.java

@@ -13,7 +13,7 @@ import java.util.List;
  * 司机设备货损记录表 Mapper 接口
  * </p>
  *
- * @author 
+ * @author
  * @since 2025-12-03 15:26:37
  */
 public interface DriverEquipmentLossRecordMapper extends BaseMapper<DriverEquipmentLossRecord> {
@@ -40,7 +40,8 @@ public interface DriverEquipmentLossRecordMapper extends BaseMapper<DriverEquipm
 
     /**
      * 删除旧数据
+     * @param operatorId 运营商id
      * @param statDate 统计日期
      */
-    void deleteOld(@Param("statDate") LocalDate statDate);
+    void deleteOld(@Param("operatorId") Long operatorId, @Param("statDate") LocalDate statDate);
 }

+ 2 - 2
warehouse-admin-data/src/main/java/com/yr/warehouse/admin/driver/mapper/DriverGoodsLossIntervalMainMapper.java

@@ -24,7 +24,7 @@ public interface DriverGoodsLossIntervalMainMapper extends BaseMapper<DriverGood
      * @param operatorId
      * @return
      */
-    LocalDateTime searchLastTotalTime(@Param("operatorId") Long operatorId);
+    LocalDateTime searchLastTotalTime(@Param("operatorId") Long operatorId, @Param("warehouseId") Long warehouseId);
 
     /**
      * 分页查询区间生成统计记录
@@ -39,6 +39,6 @@ public interface DriverGoodsLossIntervalMainMapper extends BaseMapper<DriverGood
      * @param operatorId 运营商id
      * @return 司机货损统计记录
      */
-    DriverGoodsLossIntervalMain queryLastByOperatorId(@Param("operatorId") Long operatorId);
+    DriverGoodsLossIntervalMain queryLastByOperatorId(@Param("operatorId") Long operatorId, @Param("warehouseId") Long warehouseId);
 
 }

+ 1 - 1
warehouse-admin-data/src/main/java/com/yr/warehouse/admin/driver/mapper/DriverGoodsLossRecordMapper.java

@@ -52,7 +52,7 @@ public interface DriverGoodsLossRecordMapper extends BaseMapper<DriverGoodsLossR
      * 删除旧数据
      * @param statDate 统计日期
      */
-    void deleteOld(@Param("statDate") LocalDate statDate);
+    void deleteOld(@Param("operatorId") Long operatorId, @Param("statDate") LocalDate statDate);
 
     /**
      * 根据区域员工id和统计日期查询

+ 2 - 1
warehouse-admin-data/src/main/java/com/yr/warehouse/admin/driver/mapper/DriverOnRouteDetailLogMapper.java

@@ -43,7 +43,8 @@ public interface DriverOnRouteDetailLogMapper extends BaseMapper<DriverOnRouteDe
 
     /**
      * 删除旧数据
+     * @param operatorId 运营商id
      * @param statDate 统计日期
      */
-    void deleteOld(@Param("statDate") LocalDate statDate);
+    void deleteOld(@Param("operatorId") Long operatorId, @Param("statDate") LocalDate statDate);
 }

+ 10 - 0
warehouse-admin-data/src/main/java/com/yr/warehouse/admin/driver/vo/DriverIntervalCargoDamageVo.java

@@ -41,6 +41,16 @@ public class DriverIntervalCargoDamageVo implements Serializable {
     private String operatorChainName;
 
     /**
+     * 仓库id
+     */
+    private Long warehouseId;
+
+    /**
+     * 仓库名称
+     */
+    private String warehouseName;
+
+    /**
      * 区间开始时间
      */
     private LocalDateTime intervalStartTime;

+ 13 - 7
warehouse-admin-data/src/main/java/com/yr/warehouse/admin/statistics/mapper/BillingQuantityStatisticsMapper.java

@@ -10,35 +10,39 @@ public interface BillingQuantityStatisticsMapper {
 
     /**
      * 查询拣货单开单数
+     * @param areaStaffIds 区域员工ids
      * @param beginTime 开始时间
      * @param endTime 结束时间
      * @return 开单数
      */
-    List<DriverGoodsOrderNumVo> queryPickingBillingQuantity(@Param("beginTime") LocalDateTime beginTime, @Param("endTime") LocalDateTime endTime);
+    List<DriverGoodsOrderNumVo> queryPickingBillingQuantity(@Param("areaStaffIds") List<Long> areaStaffIds, @Param("beginTime") LocalDateTime beginTime, @Param("endTime") LocalDateTime endTime);
 
     /**
      * 获取整件单开单数
+     * @param areaStaffIds 区域员工ids
      * @param beginTime 开始时间
      * @param endTime 结束时间
      * @return
      */
-    List<DriverGoodsOrderNumVo> queryAggregationBillingQuantity(@Param("beginTime") LocalDateTime beginTime, @Param("endTime") LocalDateTime endTime);
+    List<DriverGoodsOrderNumVo> queryAggregationBillingQuantity(@Param("areaStaffIds") List<Long> areaStaffIds, @Param("beginTime") LocalDateTime beginTime, @Param("endTime") LocalDateTime endTime);
 
     /**
      * 查询未出库取消数
+     * @param areaStaffIds 区域员工ids
      * @param beginTime 开始时间
      * @param endTime 结束时间
      * @return
      */
-    List<DriverGoodsOrderNumVo> queryUnOutStockCancelNum(@Param("beginTime") LocalDateTime beginTime, @Param("endTime") LocalDateTime endTime);
+    List<DriverGoodsOrderNumVo> queryUnOutStockCancelNum(@Param("areaStaffIds") List<Long> areaStaffIds, @Param("beginTime") LocalDateTime beginTime, @Param("endTime") LocalDateTime endTime);
 
     /**
      * 查询已出库取消数
+     * @param areaStaffIds 区域员工ids
      * @param beginTime 开始时间
      * @param endTime 接受时间
      * @return
      */
-    List<DriverGoodsOrderNumVo> queryOutStockCancelNum(@Param("beginTime") LocalDateTime beginTime, @Param("endTime") LocalDateTime endTime);
+    List<DriverGoodsOrderNumVo> queryOutStockCancelNum(@Param("areaStaffIds") List<Long> areaStaffIds, @Param("beginTime") LocalDateTime beginTime, @Param("endTime") LocalDateTime endTime);
 
     /**
      * 查询司机补货数
@@ -46,23 +50,25 @@ public interface BillingQuantityStatisticsMapper {
      * @param endTime 结束时间
      * @return
      */
-    List<DriverGoodsOrderNumVo> queryDriverReplenishNum(@Param("beginTime") LocalDateTime beginTime, @Param("endTime") LocalDateTime endTime);
+    List<DriverGoodsOrderNumVo> queryDriverReplenishNum(@Param("areaStaffIds") List<Long> areaStaffIds, @Param("beginTime") LocalDateTime beginTime, @Param("endTime") LocalDateTime endTime);
 
     /**
      * 查询设备补货数
+     * @param areaStaffIds 区域员工ids
      * @param beginTime 开始时间
      * @param endTime 结束时间
      * @return
      */
-    List<DriverGoodsOrderNumVo> queryDeviceReplenishNum(@Param("beginTime") LocalDateTime beginTime, @Param("endTime") LocalDateTime endTime);
+    List<DriverGoodsOrderNumVo> queryDeviceReplenishNum(@Param("areaStaffIds") List<Long> areaStaffIds, @Param("beginTime") LocalDateTime beginTime, @Param("endTime") LocalDateTime endTime);
 
     /**
      * 查询司机回仓数
+     * @param areaStaffIds 区域员工ids
      * @param beginTime 开始时间
      * @param endTime 结束时间
      * @return
      */
-    List<DriverGoodsOrderNumVo> queryDriverReturnNum(@Param("beginTime") LocalDateTime beginTime, @Param("endTime") LocalDateTime endTime);
+    List<DriverGoodsOrderNumVo> queryDriverReturnNum(@Param("areaStaffIds") List<Long> areaStaffIds, @Param("beginTime") LocalDateTime beginTime, @Param("endTime") LocalDateTime endTime);
 
     /**
      * 获取设备库存数

+ 71 - 0
warehouse-admin-data/src/main/java/com/yr/warehouse/admin/statistics/vo/DriverStatisticsVo.java

@@ -0,0 +1,71 @@
+package com.yr.warehouse.admin.statistics.vo;
+
+import com.yr.warehouse.admin.driver.data.DriverEquipmentLossRecord;
+import com.yr.warehouse.admin.driver.data.DriverGoodsLossRecord;
+import com.yr.warehouse.admin.replenish.vo.DriverGoodsOrderNumVo;
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 司机统计vo
+ */
+@Data
+public class DriverStatisticsVo implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 司机拣货单开单数 - 含商品id
+     */
+    private List<DriverGoodsOrderNumVo> pickingBillingQuantityNumVos;
+
+    /**
+     * 司机整件单开单数 - 含商品id
+     */
+    private List<DriverGoodsOrderNumVo> aggregationBillingQuantityNumVos;
+
+    /**
+     * 未出库取消数 - 含商品id
+     */
+    private List<DriverGoodsOrderNumVo> unOutStockCancelNumVos;
+
+    /**
+     * 已出库取消数 - 含商品id
+     */
+    private List<DriverGoodsOrderNumVo> outStockCancelNumVos;
+    /**
+     * 司机补货数 - 含商品id
+     */
+    private List<DriverGoodsOrderNumVo> driverReplenishNumVos;
+
+    /**
+     * 设备补货数 - 不含商品id
+     */
+    private List<DriverGoodsOrderNumVo> deviceReplenishNumVos;
+
+    /**
+     * 司机回仓数 - 含商品id
+     */
+    private List<DriverGoodsOrderNumVo> driverReturnNumVos;
+
+    /**
+     * 司机设备销量统计 - 不含商品id
+     */
+    private List<DriverGoodsOrderNumVo> driverDeviceSalesNumVos;
+
+
+    /**
+     * 司机日货损统计列表
+     */
+    private List<DriverGoodsLossRecord> driverGoodsLossRecords;
+
+    /**
+     * 司机日设备损统计列表
+     */
+    private List<DriverEquipmentLossRecord> driverEquipmentLossRecords;
+
+}

+ 67 - 0
warehouse-admin-data/src/main/resources/mapper/areaStaff/DriverWarehouseMapper.xml

@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.yr.warehouse.admin.areastaff.mapper.DriverWarehouseMapper">
+
+    <select id="searchByWarehouseId" resultType="com.yr.warehouse.admin.areastaff.vo.AreaStaffVo"
+            parameterType="com.yr.warehouse.admin.common.bo.BaseIdBo">
+        with warehouse_area_staff as (select wd.warehouseInfoId,
+                                             ods.areaStaffId
+                                      from yr_warehouse_info as wi
+                                               left join yr_warehouse_device as wd on wd.warehouseInfoId = wi.id
+                                               left join yr_operators_device as od on wd.deviceId = od.id
+                                               left join yr_operators_device_site as ods on od.id = ods.deviceId
+                                      where od.putStatus = 'USED'
+                                        and od.isDelete = 'NORMAL'
+                                        and ods.isDelete = 'NORMAL'
+                                        and wi.status != 'DELETE'
+                                      group by wd.warehouseInfoId, ods.areaStaffId)
+        select oas.id                         as id,
+               oas.id                         as areaStaffId,
+               oas.operatorId                 as operatorId,
+               oas.operatorChain              as operatorChain,
+               oas.areaId                     as areaId,
+               oas.areaChain                  as areaChain,
+               oas.employeeId                 as employeeId,
+               oas.employeeName               as employeeName,
+               oas.accountId                  as accountId,
+               oas.carBoxNum                  as carBoxNum,
+               oas.maxAggregationPickingRatio as maxAggregationPickingRatio,
+               oas.createTime                 as createTime,
+               oas.createUid                  as createUid,
+               oas.createName                 as createName,
+               oas.modifyTime                 as modifyTime,
+               oas.modifyUid                  as modifyUid,
+               oas.modifyName                 as modifyName,
+               oas.isDelete                   as isDelete,
+               oas.managerAccountId           as managerAccountId,
+               oas.managerAccountName         as managerAccountName
+        from yr_operators_area_staff as oas
+                 left join warehouse_area_staff as was on oas.id = was.areaStaffId
+        where oas.isDelete = 'NORMAL'
+          and was.warehouseInfoId = #{warehouseId}
+    </select>
+    <select id="all" resultType="com.yr.warehouse.admin.areastaff.vo.AreaStaffVo">
+        select oas.id                         as id,
+               oas.id                         as areaStaffId,
+               oas.operatorId                 as operatorId,
+               oas.operatorChain              as operatorChain,
+               oas.areaId                     as areaId,
+               oas.areaChain                  as areaChain,
+               oas.employeeId                 as employeeId,
+               oas.employeeName               as employeeName,
+               oas.accountId                  as accountId,
+               oas.carBoxNum                  as carBoxNum,
+               oas.maxAggregationPickingRatio as maxAggregationPickingRatio,
+               oas.createTime                 as createTime,
+               oas.createUid                  as createUid,
+               oas.createName                 as createName,
+               oas.modifyTime                 as modifyTime,
+               oas.modifyUid                  as modifyUid,
+               oas.modifyName                 as modifyName,
+               oas.isDelete                   as isDelete,
+               oas.managerAccountId           as managerAccountId,
+               oas.managerAccountName         as managerAccountName
+        from yr_operators_area_staff as oas
+        where oas.isDelete = 'NORMAL'
+    </select>
+</mapper>

+ 1 - 1
warehouse-admin-data/src/main/resources/mapper/driver/DriverEquipmentLossRecordMapper.xml

@@ -36,7 +36,7 @@
         </foreach>
     </insert>
     <delete id="deleteOld" parameterType="java.time.LocalDate">
-        delete from yr_driver_equipment_loss_record where statDate = #{statDate}
+        delete from yr_driver_equipment_loss_record where operatorId = #{operatorId} and statDate = #{statDate}
     </delete>
     <select id="searchByStatDate" resultType="com.yr.warehouse.admin.driver.data.DriverEquipmentLossRecord"
             parameterType="java.time.LocalDate">

+ 11 - 6
warehouse-admin-data/src/main/resources/mapper/driver/DriverGoodsLossIntervalMainMapper.xml

@@ -9,6 +9,7 @@
         <result column="intervalEndTime" property="intervalEndTime" />
         <result column="operatorId" property="operatorId" />
         <result column="operatorChain" property="operatorChain" />
+        <result column="warehouseId" property="warehouseId" />
         <result column="stockTakingType" property="stockTakingType" />
         <result column="pickingOrderCreateNum" property="pickingOrderCreateNum" />
         <result column="wholeOrderCreateNum" property="wholeOrderCreateNum" />
@@ -32,16 +33,18 @@
 
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
-        id, intervalStartTime, intervalEndTime, operatorId, operatorChain, stockTakingType, pickingOrderCreateNum, wholeOrderCreateNum, replenishNum, returnWarehouseNum, onRouteInventoryNum, unshippedCancelNum, shippedCancelNum, unReplenishedNum, driverProfitLossNum, equipmentProfitLossNum, totalProfitLossNum, createTime, createUid, createName, modifyTime, modifyUid, modifyName, isDelete
+        id, intervalStartTime, intervalEndTime, operatorId, operatorChain, warehouseId, stockTakingType, pickingOrderCreateNum, wholeOrderCreateNum, replenishNum, returnWarehouseNum, onRouteInventoryNum, unshippedCancelNum, shippedCancelNum, unReplenishedNum, driverProfitLossNum, equipmentProfitLossNum, totalProfitLossNum, createTime, createUid, createName, modifyTime, modifyUid, modifyName, isDelete
     </sql>
-    <select id="searchLastTotalTime" resultType="java.time.LocalDateTime" parameterType="java.lang.Long">
-        select MAX(intervalEndTime) from yr_driver_goods_loss_interval_main where operatorId = #{operatorId} and stockTakingType = 'REGULAR'
+    <select id="searchLastTotalTime" resultType="java.time.LocalDateTime">
+        select MAX(intervalEndTime) from yr_driver_goods_loss_interval_main where operatorId = #{operatorId} and warehouseId = #{warehouseId} and stockTakingType = 'REGULAR'
     </select>
     <select id="searchForPage" resultType="com.yr.warehouse.admin.driver.vo.DriverIntervalCargoDamageVo">
         select
         dglim.id as id,
         dglim.operatorId as operatorId,
         dglim.operatorChain as operatorChain,
+        dglim.warehouseId as warehouseId,
+        wi.name as warehouseName,
         dglim.intervalStartTime as intervalStartTime,
         dglim.intervalEndTime as intervalEndTime,
         dglim.pickingOrderCreateNum as pickingOrderCreateNum,
@@ -56,6 +59,7 @@
         dglim.equipmentProfitLossNum as equipmentProfitLossNum,
         dglim.totalProfitLossNum as totalProfitLossNum
         from yr_driver_goods_loss_interval_main as dglim
+        left join yr_warehouse_info as wi on dglim.warehouseId = wi.id
         <where>
             <if test="bo.operatorId != null and bo.operatorId > 0">
                 and dglim.operatorId = #{bo.operatorId}
@@ -78,9 +82,10 @@
         </where>
         order by dglim.intervalEndTime desc
     </select>
-    <select id="queryLastByOperatorId" resultType="com.yr.warehouse.admin.driver.data.DriverGoodsLossIntervalMain"
-            parameterType="java.lang.Long">
-        select * from yr_driver_goods_loss_interval_main where operatorId = #{operatorId} and stockTakingType = 'REGULAR'
+    <select id="queryLastByOperatorId" resultType="com.yr.warehouse.admin.driver.data.DriverGoodsLossIntervalMain">
+        select
+            <include refid="Base_Column_List" />
+            from yr_driver_goods_loss_interval_main where operatorId = #{operatorId} and warehouseId = #{warehouseId} and stockTakingType = 'REGULAR'
         order by intervalEndTime desc limit 1
     </select>
 

+ 1 - 1
warehouse-admin-data/src/main/resources/mapper/driver/DriverGoodsLossRecordMapper.xml

@@ -42,7 +42,7 @@
         </foreach>
     </insert>
     <delete id="deleteOld" parameterType="java.time.LocalDate">
-        delete from yr_driver_goods_loss_record where statDate = #{statDate}
+        delete from yr_driver_goods_loss_record where operatorId = #{operatorId} and statDate = #{statDate}
     </delete>
     <select id="searchByStatDate"
             resultType="com.yr.warehouse.admin.driver.data.DriverGoodsLossRecord"

+ 1 - 1
warehouse-admin-data/src/main/resources/mapper/driver/DriverOnRouteDetailLogMapper.xml

@@ -39,7 +39,7 @@
         </foreach>
     </insert>
     <delete id="deleteOld" parameterType="java.time.LocalDate">
-        delete from yr_driver_on_route_detail_log where statDate = #{statDate}
+        delete from yr_driver_on_route_detail_log where operatorId = #{operatorId} and statDate = #{statDate}
     </delete>
     <select id="searchByStatDate" resultType="com.yr.warehouse.admin.driver.data.DriverOnRouteDetailLog"
             parameterType="java.time.LocalDate">

+ 117 - 65
warehouse-admin-data/src/main/resources/mapper/statistics/BillingQuantityStatisticsMapper.xml

@@ -5,117 +5,169 @@
     <select id="queryPickingBillingQuantity" resultType="com.yr.warehouse.admin.replenish.vo.DriverGoodsOrderNumVo">
         select poi.area_staff_id as areaStaffId, pod.goods_id as goodsId, SUM(pod.picking_number) as totalNum
         from yr_picking_order_detail as pod
-                 left join yr_picking_order_info as poi on pod.order_number = poi.order_number
+        left join yr_picking_order_info as poi on pod.order_number = poi.order_number
         where
         poi.picking_time is not null
         and poi.picking_time between #{beginTime} and #{endTime}
         and pod.is_aggregation = 0
+        <if test="areaStaffIds != null and areaStaffIds.size > 0">
+            <foreach collection="areaStaffIds" item="areaStaffId" open="and poi.area_staff_id in (" separator=","
+                     close=")">
+                #{areaStaffId}
+            </foreach>
+        </if>
         group by poi.area_staff_id, pod.goods_id
     </select>
 
     <select id="queryAggregationBillingQuantity" resultType="com.yr.warehouse.admin.replenish.vo.DriverGoodsOrderNumVo">
-        select api.area_staff_id                                                    as areaStaffId,
-               apd.goods_id                                                         as goodsId,
-               IFNULL(sum(apd.picking_number), 0) + IFNULL(sum(apd.more_number), 0) as totalNum
+        select api.area_staff_id as areaStaffId,
+        apd.goods_id as goodsId,
+        IFNULL(sum(apd.picking_number), 0) + IFNULL(sum(apd.more_number), 0) as totalNum
         from yr_aggregation_pick_detail as apd
-                 left join yr_aggregation_pick_info as api on apd.order_number = api.order_number
+        left join yr_aggregation_pick_info as api on apd.order_number = api.order_number
         where
-            api.picking_time is not null
+        api.picking_time is not null
         and api.picking_time between #{beginTime} and #{endTime}
+        <if test="areaStaffIds != null and areaStaffIds.size > 0">
+            <foreach collection="areaStaffIds" item="areaStaffId" open="and api.area_staff_id in (" separator=","
+                     close=")">
+                #{areaStaffId}
+            </foreach>
+        </if>
         group by api.area_staff_id, apd.goods_id
     </select>
 
     <select id="queryUnOutStockCancelNum"
             resultType="com.yr.warehouse.admin.replenish.vo.DriverGoodsOrderNumVo">
-        with cancel_data as (select poi.area_staff_id                  as areaStaffId,
-                                    pod.goods_id                       as goodsId,
-                                    IFNULL(SUM(pod.picking_number), 0) as pickingNumber
-                             from yr_picking_order_detail as pod
-                                      left join yr_picking_order_info as poi on pod.order_number = poi.order_number
-                             where poi.modify_time between #{beginTime} and #{endTime}
-                               and pod.is_aggregation = 0
-                               and poi.picking_status = 3
-                             group by poi.area_staff_id, pod.goods_id
-                             union all
-                             select api.area_staff_id                                                    as areaStaffId,
-                                    apd.goods_id                                                         as goodsId,
-                                    IFNULL(sum(apd.picking_number), 0) + IFNULL(sum(apd.more_number), 0) as pickingNumber
-                             from yr_aggregation_pick_detail as apd
-                                      left join yr_aggregation_pick_info as api on apd.order_number = api.order_number
-                             where api.modify_time between #{beginTime} and #{endTime}
-                               and api.status = 'CANCEL')
+        with cancel_data as (select poi.area_staff_id as areaStaffId,
+        pod.goods_id as goodsId,
+        IFNULL(SUM(pod.picking_number), 0) as pickingNumber
+        from yr_picking_order_detail as pod
+        left join yr_picking_order_info as poi on pod.order_number = poi.order_number
+        where poi.modify_time between #{beginTime} and #{endTime}
+        and pod.is_aggregation = 0
+        and poi.picking_status = 3
+        group by poi.area_staff_id, pod.goods_id
+        union all
+        select api.area_staff_id as areaStaffId,
+        apd.goods_id as goodsId,
+        IFNULL(sum(apd.picking_number), 0) + IFNULL(sum(apd.more_number), 0) as pickingNumber
+        from yr_aggregation_pick_detail as apd
+        left join yr_aggregation_pick_info as api on apd.order_number = api.order_number
+        where api.modify_time between #{beginTime} and #{endTime}
+        and api.status = 'CANCEL')
         select areaStaffId, goodsId, sum(pickingNumber) as totalNum
         from cancel_data
         where areaStaffId IS NOT NULL
+        <if test="areaStaffIds != null and areaStaffIds.size > 0">
+            <foreach collection="areaStaffIds" item="areaStaffId" open="and areaStaffId in (" separator=","
+                     close=")">
+                #{areaStaffId}
+            </foreach>
+        </if>
         group by areaStaffId, goodsId
     </select>
     <select id="queryOutStockCancelNum" resultType="com.yr.warehouse.admin.replenish.vo.DriverGoodsOrderNumVo">
-        with cancel_data as (select poi.area_staff_id                  as areaStaffId,
-                                    pod.goods_id                       as goodsId,
-                                    IFNULL(SUM(pod.picking_number), 0) as pickingNumber
-                             from yr_picking_order_detail as pod
-                                      left join yr_picking_order_info as poi on pod.order_number = poi.order_number
-                             where poi.modify_time between #{beginTime} and #{endTime}
-                               and pod.is_aggregation = 0
-                               and poi.picking_status = 4
-                             group by poi.area_staff_id, pod.goods_id
-                             union all
-                             select api.area_staff_id                                                    as areaStaffId,
-                                    apd.goods_id                                                         as goodsId,
-                                    IFNULL(sum(apd.picking_number), 0) + IFNULL(sum(apd.more_number), 0) as pickingNumber
-                             from yr_aggregation_pick_detail as apd
-                                      left join yr_aggregation_pick_info as api on apd.order_number = api.order_number
-                             where api.modify_time between #{beginTime} and #{endTime}
-                               and api.status = 'OUT_CANCEL')
+        with cancel_data as (select poi.area_staff_id as areaStaffId,
+        pod.goods_id as goodsId,
+        IFNULL(SUM(pod.picking_number), 0) as pickingNumber
+        from yr_picking_order_detail as pod
+        left join yr_picking_order_info as poi on pod.order_number = poi.order_number
+        where poi.modify_time between #{beginTime} and #{endTime}
+        and pod.is_aggregation = 0
+        and poi.picking_status = 4
+        group by poi.area_staff_id, pod.goods_id
+        union all
+        select api.area_staff_id as areaStaffId,
+        apd.goods_id as goodsId,
+        IFNULL(sum(apd.picking_number), 0) + IFNULL(sum(apd.more_number), 0) as pickingNumber
+        from yr_aggregation_pick_detail as apd
+        left join yr_aggregation_pick_info as api on apd.order_number = api.order_number
+        where api.modify_time between #{beginTime} and #{endTime}
+        and api.status = 'OUT_CANCEL')
         select areaStaffId, goodsId, sum(pickingNumber) as totalNum
         from cancel_data
         where areaStaffId IS NOT NULL
+        <if test="areaStaffIds != null and areaStaffIds.size > 0">
+            <foreach collection="areaStaffIds" item="areaStaffId" open="and areaStaffId in (" separator=","
+                     close=")">
+                #{areaStaffId}
+            </foreach>
+        </if>
         group by areaStaffId, goodsId
     </select>
 
     <select id="queryDriverReplenishNum" resultType="com.yr.warehouse.admin.replenish.vo.DriverGoodsOrderNumVo">
+        with replenish_data as (
         select
-            IF(roi.replenish_user_id != roi.replenish_account_id, IFNULL(oas.id, roi.area_staff_id), roi.area_staff_id) as areaStaffId,
-               rod.goods_id                      as goodsId,
-               sum(rod.real_picking_number)      as totalNum
+        IF(roi.replenish_user_id != roi.replenish_account_id, IFNULL(oas.id, roi.area_staff_id), roi.area_staff_id) as
+        areaStaffId,
+        rod.goods_id as goodsId,
+        sum(rod.real_picking_number) as totalNum
         from yr_replenish_order_detail as rod
-                 left join yr_replenish_order_info as roi on rod.order_number = roi.order_number
-                 left join (select id, accountId
-                            from yr_operators_area_staff
-                            where isDelete = 'NORMAL'
-                            group by accountId) as oas on roi.replenish_user_id = oas.accountId
+        left join yr_replenish_order_info as roi on rod.order_number = roi.order_number
+        left join (select id, accountId
+        from yr_operators_area_staff
+        where isDelete = 'NORMAL'
+        group by accountId) as oas on roi.replenish_user_id = oas.accountId
         where roi.replenish_time between #{beginTime} and #{endTime}
-          and roi.replenish_status = 2
+        and roi.replenish_status = 2
         group by oas.id, rod.goods_id
+        )
+        select rd.areaStaffId as areaStaffId,
+        rd.goodsId as goodsId,
+        rd.totalNum as totalNum
+        from replenish_data as rd
+        <where>
+            <if test="areaStaffIds != null and areaStaffIds.size > 0">
+                <foreach collection="areaStaffIds" item="areaStaffId" open="and rd.areaStaffId in (" separator=","
+                         close=")">
+                    #{areaStaffId}
+                </foreach>
+            </if>
+        </where>
     </select>
 
     <select id="queryDeviceReplenishNum" resultType="com.yr.warehouse.admin.replenish.vo.DriverGoodsOrderNumVo">
         select
-            IF(roi.replenish_user_id != roi.replenish_account_id, IFNULL(oas.id, roi.area_staff_id), roi.area_staff_id) as areaStaffId,
-            sum(rod.real_picking_number) as totalNum
+        IF(roi.replenish_user_id != roi.replenish_account_id, IFNULL(oas.id, roi.area_staff_id), roi.area_staff_id) as
+        areaStaffId,
+        sum(rod.real_picking_number) as totalNum
         from yr_replenish_order_detail as rod
-                 left join yr_replenish_order_info as roi on rod.order_number = roi.order_number
-                 left join (select id, accountId
-                            from yr_operators_area_staff
-                            where isDelete = 'NORMAL'
-                            group by accountId) as oas on roi.replenish_user_id = oas.accountId
+        left join yr_replenish_order_info as roi on rod.order_number = roi.order_number
+        left join (select id, accountId
+        from yr_operators_area_staff
+        where isDelete = 'NORMAL'
+        group by accountId) as oas on roi.replenish_user_id = oas.accountId
         where roi.replenish_time between #{beginTime} and #{endTime}
-          and roi.replenish_status = 2
-          and rod.real_picking_number > 0
+        and roi.replenish_status = 2
+        and rod.real_picking_number > 0
+        <if test="areaStaffIds != null and areaStaffIds.size > 0">
+            <foreach collection="areaStaffIds" item="areaStaffId" open="and roi.area_staff_id in (" separator=","
+                     close=")">
+                #{areaStaffId}
+            </foreach>
+        </if>
         group by roi.area_staff_id
     </select>
 
     <select id="queryDriverReturnNum" resultType="com.yr.warehouse.admin.replenish.vo.DriverGoodsOrderNumVo">
         select oas.id as areaStaffId, wbod.productSpecId as goodsId, wbod.realBackNumber as totalNum
         from yr_warehouse_back_order_detail as wbod
-                 left join yr_warehouse_back_order_info as wboi on wbod.backOrderId = wboi.id
-                 left join (select id, accountId
-                            from yr_operators_area_staff
-                            where isDelete = 'NORMAL'
-                            group by accountId) as oas on oas.accountId = wboi.replenishId
+        left join yr_warehouse_back_order_info as wboi on wbod.backOrderId = wboi.id
+        left join (select id, accountId
+        from yr_operators_area_staff
+        where isDelete = 'NORMAL'
+        group by accountId) as oas on oas.accountId = wboi.replenishId
         where wboi.backTime between #{beginTime} and #{endTime}
-          and wboi.backStatus = 'BACK_SUCCESS'
-          and wboi.sourceBack = 'DRIVER'
+        and wboi.backStatus = 'BACK_SUCCESS'
+        and wboi.sourceBack = 'DRIVER'
+        <if test="areaStaffIds != null and areaStaffIds.size > 0">
+            <foreach collection="areaStaffIds" item="areaStaffId" open="and oas.id in (" separator=","
+                     close=")">
+                #{areaStaffId}
+            </foreach>
+        </if>
         group by wboi.replenishId, wbod.productSpecId
     </select>
     <select id="queryDriverDeviceInventoryNum"

+ 4 - 4
warehouse-admin-event/src/main/java/com/yr/warehouse/admin/event/task/DriverCargoDamageStatisticsTask.java

@@ -3,7 +3,7 @@ package com.yr.warehouse.admin.event.task;
 import com.xxl.job.core.context.XxlJobHelper;
 import com.xxl.job.core.handler.annotation.XxlJob;
 import com.yr.warehouse.admin.service.context.TransactionAwareComponent;
-import com.yr.warehouse.admin.service.statistics.DriverStatistics;
+import com.yr.warehouse.admin.service.statistics.DriverStatisticsService;
 import jakarta.annotation.Resource;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
@@ -19,7 +19,7 @@ import java.time.LocalDate;
 public class DriverCargoDamageStatisticsTask {
 
     @Resource
-    private DriverStatistics driverStatistics;
+    private DriverStatisticsService driverStatisticsService;
 
     @Resource
     private TransactionAwareComponent transactionAwareComponent;
@@ -35,7 +35,7 @@ public class DriverCargoDamageStatisticsTask {
         if (StringUtils.isNotBlank(dayParamStr) && dayParamStr.contains("-")) {
             for (String dayStr : dayParamStr.split(",")) {
                 LocalDate day = LocalDate.parse(dayStr);
-                driverStatistics.cargoDamageStatistics(day);
+                driverStatisticsService.cargoDamageStatistics(day);
                 XxlJobHelper.log("结束执行司机货损统计任务:{}", day);
             }
             return;
@@ -43,7 +43,7 @@ public class DriverCargoDamageStatisticsTask {
 
 
         transactionAwareComponent.execute(status -> {
-            driverStatistics.cargoDamageStatistics(LocalDate.now());
+            driverStatisticsService.cargoDamageStatistics(LocalDate.now());
             return null;
         });
         XxlJobHelper.log("结束执行司机货损统计任务:{}", LocalDate.now());

+ 3 - 2
warehouse-admin-server/src/main/java/com/yr/warehouse/admin/service/driver/DriverGoodsLossIntervalMainService.java

@@ -20,9 +20,10 @@ public interface DriverGoodsLossIntervalMainService extends IService<DriverGoods
 
     /**
      * 查询运营商对应的区间货损最后统计时间
-     * @param operatorId
+     * @param operatorId 运营商id
+     * @param warehouseId 仓库id
      */
-    LocalDateTime searchLastTotalTime(Long operatorId);
+    LocalDateTime searchLastTotalTime(Long operatorId, Long warehouseId);
 
     /**
      * 生成区间统计记录

+ 19 - 0
warehouse-admin-server/src/main/java/com/yr/warehouse/admin/service/driver/DriverWarehouseService.java

@@ -0,0 +1,19 @@
+package com.yr.warehouse.admin.service.driver;
+
+import com.yr.warehouse.admin.areastaff.vo.AreaStaffVo;
+import com.yr.warehouse.admin.common.bo.BaseIdBo;
+
+import java.util.List;
+
+/**
+ * 司机仓库服务接口
+ */
+public interface DriverWarehouseService {
+
+    /**
+     * 获取仓库司机列表
+     * @param bo id查询条件 - 仓库id
+     * @return 司机列表
+     */
+    List<AreaStaffVo> list(BaseIdBo bo);
+}

+ 2 - 2
warehouse-admin-server/src/main/java/com/yr/warehouse/admin/service/driver/impl/DriverGoodsLossIntervalMainServiceImpl.java

@@ -24,8 +24,8 @@ import java.time.LocalDateTime;
 public class DriverGoodsLossIntervalMainServiceImpl extends ServiceImpl<DriverGoodsLossIntervalMainMapper, DriverGoodsLossIntervalMain> implements DriverGoodsLossIntervalMainService {
 
     @Override
-    public LocalDateTime searchLastTotalTime(Long operatorId) {
-        LocalDateTime intervalEndTime = baseMapper.searchLastTotalTime(operatorId);
+    public LocalDateTime searchLastTotalTime(Long operatorId, Long warehouseId) {
+        LocalDateTime intervalEndTime = baseMapper.searchLastTotalTime(operatorId, warehouseId);
 
         // 如果 intervalEndTime 为 null,则返回上月1号 00:00:00
         if (intervalEndTime == null) {

+ 28 - 24
warehouse-admin-server/src/main/java/com/yr/warehouse/admin/service/driver/impl/DriverGoodsLossIntervalServiceImpl.java

@@ -1,9 +1,9 @@
 package com.yr.warehouse.admin.service.driver.impl;
 
-import com.supplychain.api.response.areastaff.AreaStaffResponse;
 import com.yr.bluecat.common.entity.exception.MessageException;
+import com.yr.warehouse.admin.areastaff.mapper.DriverWarehouseMapper;
+import com.yr.warehouse.admin.areastaff.vo.AreaStaffVo;
 import com.yr.warehouse.admin.common.menu.BoolEnum;
-import com.yr.warehouse.admin.component.areastaff.AreaStaffComponent;
 import com.yr.warehouse.admin.component.auth.OperatorComponent;
 import com.yr.warehouse.admin.component.auth.vo.OrgOperatorVo;
 import com.yr.warehouse.admin.driver.bo.DriverIntervalCargoDamageGeneratorBo;
@@ -12,6 +12,8 @@ import com.yr.warehouse.admin.driver.mapper.*;
 import com.yr.warehouse.admin.driver.menu.DriverGoodsLossIntervalStockTakingType;
 import com.yr.warehouse.admin.driver.vo.DriverGoodsLossIntervalVo;
 import com.yr.warehouse.admin.service.driver.DriverGoodsLossIntervalService;
+import com.yr.warehouse.admin.service.statistics.DriverStatisticsService;
+import com.yr.warehouse.admin.statistics.vo.DriverStatisticsVo;
 import jakarta.annotation.Resource;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.support.TransactionTemplate;
@@ -26,18 +28,12 @@ import java.util.stream.Collectors;
 @Service
 public class DriverGoodsLossIntervalServiceImpl implements DriverGoodsLossIntervalService {
     @Resource
-    private AreaStaffComponent areaStaffComponent;
+    private DriverStatisticsService driverStatisticsService;
 
     @Resource
     private OperatorComponent operatorComponent;
 
     @Resource
-    private DriverGoodsLossRecordMapper driverGoodsLossRecordMapper;
-
-    @Resource
-    private DriverEquipmentLossRecordMapper driverEquipmentLossRecordMapper;
-
-    @Resource
     private DriverGoodsLossIntervalMainMapper driverGoodsLossIntervalMainMapper;
 
     @Resource
@@ -50,15 +46,18 @@ public class DriverGoodsLossIntervalServiceImpl implements DriverGoodsLossInterv
     private EquipmentLossIntervalDetailMapper equipmentLossIntervalDetailMapper;
 
     @Resource
+    private DriverWarehouseMapper driverWarehouseMapper;
+
+    @Resource
     private TransactionTemplate transactionTemplate;
 
 
     @Override
     public void generator(DriverIntervalCargoDamageGeneratorBo bo) {
-        // 获取当前运营商下所有司机
-        List<AreaStaffResponse> areaStaffResponses = areaStaffComponent.searchByOperatorId(bo.getOperatorId());
-        if (null == areaStaffResponses || areaStaffResponses.isEmpty()) {
-            throw new MessageException("当前运营商下没有司机");
+        // 获取当前仓库下所有司机
+        List<AreaStaffVo> areaStaffVos = driverWarehouseMapper.searchByWarehouseId(bo.getWarehouseId());
+        if (null == areaStaffVos || areaStaffVos.isEmpty()) {
+            throw new MessageException("当前仓库下没有司机");
         }
 
         bo.setBeginStatDate(bo.getIntervalStartTime().toLocalDate());
@@ -67,7 +66,7 @@ public class DriverGoodsLossIntervalServiceImpl implements DriverGoodsLossInterv
         // 获取当前运营商id链
         OrgOperatorVo orgOperatorVo = operatorComponent.queryOperatorById(bo.getOperatorId());
 
-        List<Long> operatorAreaStaffIds = areaStaffResponses.stream().map(AreaStaffResponse::getId).collect(Collectors.toList());
+        List<Long> operatorAreaStaffIds = areaStaffVos.stream().map(AreaStaffVo::getId).collect(Collectors.toList());
         // 基于参数中运营商司机id列表及运营商实际司机id列表进行校验,判断当前生成逻辑是定期货损统计还是抽查货损统计
         String stockTakingType = checkStockTakingType(bo.getAreaStaffIds(), operatorAreaStaffIds);
 
@@ -77,7 +76,7 @@ public class DriverGoodsLossIntervalServiceImpl implements DriverGoodsLossInterv
         }
 
         // 获取上一次司机的货损统计记录
-        DriverGoodsLossIntervalMain lastDriverGoodsLossIntervalMain = driverGoodsLossIntervalMainMapper.queryLastByOperatorId(bo.getOperatorId());
+        DriverGoodsLossIntervalMain lastDriverGoodsLossIntervalMain = driverGoodsLossIntervalMainMapper.queryLastByOperatorId(bo.getOperatorId(), bo.getWarehouseId());
         List<DriverGoodsLossIntervalDetail> lastDriverGoodsLossIntervalDetails = null;
         List<EquipmentLossIntervalDetail> lastEquipmentLossIntervalDetails = null;
         if (null != lastDriverGoodsLossIntervalMain) {
@@ -90,14 +89,18 @@ public class DriverGoodsLossIntervalServiceImpl implements DriverGoodsLossInterv
         Map<Long, DriverOnRouteAccountRecordMain> driverOnRouteAccountRecordMainMap = driverOnRouteAccountRecordMains.stream().collect(Collectors.toMap(DriverOnRouteAccountRecordMain::getAreaStaffId, Function.identity()));
 
         // 基于开始时间及结束时间抽取这段时间内每日统计的司机货损记录及设备货损记录
-        List<DriverGoodsLossRecord> driverGoodsLossRecords = driverGoodsLossRecordMapper.searchGeneratorParam(bo);
-        List<DriverEquipmentLossRecord> driverEquipmentLossRecords = driverEquipmentLossRecordMapper.searchGeneratorParam(bo);
+        // List<DriverGoodsLossRecord> driverGoodsLossRecords = driverGoodsLossRecordMapper.searchGeneratorParam(bo);
+
+        DriverStatisticsVo driverStatisticsVo = driverStatisticsService.generatorDriverStatisticsVo(bo.getAreaStaffIds(), bo.getIntervalStartTime(), bo.getIntervalEndTime());
+
+
+        // List<DriverEquipmentLossRecord> driverEquipmentLossRecords = driverEquipmentLossRecordMapper.searchGeneratorParam(bo);
 
         // 基于司机货损记录及设备货损记录生成司机对应的货损统计记录
         Map<Long, DriverGoodsLossIntervalVo> driverGoodsLossIntervalDetailMap = generatorDriverGoodsLossIntervalDetailMap(bo.getAreaStaffIds(),
                 driverOnRouteAccountRecordMainMap,
-                driverGoodsLossRecords,
-                driverEquipmentLossRecords,
+                driverStatisticsVo.getDriverGoodsLossRecords(),
+                driverStatisticsVo.getDriverEquipmentLossRecords(),
                 lastDriverGoodsLossIntervalDetails,
                 lastEquipmentLossIntervalDetails);
 
@@ -109,6 +112,7 @@ public class DriverGoodsLossIntervalServiceImpl implements DriverGoodsLossInterv
         driverGoodsLossIntervalMain.setIntervalEndTime(bo.getIntervalEndTime());
         driverGoodsLossIntervalMain.setOperatorId(bo.getOperatorId());
         driverGoodsLossIntervalMain.setOperatorChain(orgOperatorVo.getOperatorChain());
+        driverGoodsLossIntervalMain.setWarehouseId(bo.getWarehouseId());
         driverGoodsLossIntervalMain.setStockTakingType(stockTakingType);
         long pickingOrderCreateNum = 0L; // 拣货单创建数
         long wholeOrderCreateNum = 0L; // 整单创建数
@@ -284,7 +288,7 @@ public class DriverGoodsLossIntervalServiceImpl implements DriverGoodsLossInterv
         Long shippedCancelNum = 0L; // 已出库取消数
         Long replenishNum = 0L; // 补货数
         Long returnWarehouseNum = 0L; // 回仓数
-        Long onRouteStock = 0L; // 当日在途数
+        Long remainingUnReplenishedNum = 0L; // 当日在途数
 
 
         if (null != driverGoodsLossRecordList && !driverGoodsLossRecordList.isEmpty()) {
@@ -300,17 +304,17 @@ public class DriverGoodsLossIntervalServiceImpl implements DriverGoodsLossInterv
             // 获取 driverGoodsLossRecordList 中 id 最大 driverGoodsLossRecord 对象
             DriverGoodsLossRecord driverGoodsLossRecord = driverGoodsLossRecordList.stream().max(Comparator.comparing(DriverGoodsLossRecord::getId)).get();
             if (BoolEnum.isYes(driverGoodsLossRecord.getUseVerified())) {
-                onRouteStock = driverGoodsLossRecord.getVerifiedNum();
+                remainingUnReplenishedNum = driverGoodsLossRecord.getVerifiedNum();
             } else {
-                onRouteStock = driverGoodsLossRecord.getCurrentOnRouteNum();
+                remainingUnReplenishedNum = driverGoodsLossRecord.getCurrentOnRouteNum();
             }
         }
 
         // 理论剩余未补数
-        Long remainingUnReplenishedNum = lastRemainingOnRouteStock + pickingOrderCreateNum + wholeOrderCreateNum - unshippedCancelNum - replenishNum - returnWarehouseNum;
+        Long onRouteStock = lastRemainingOnRouteStock + pickingOrderCreateNum + wholeOrderCreateNum - unshippedCancelNum - replenishNum - returnWarehouseNum;
 
         // 盈亏数
-        Long profitLossNum = remainingUnReplenishedNum - onRouteStock;
+        Long profitLossNum = onRouteStock - wholeVerifyNum;
 
         driverGoodsLossIntervalDetail.setPickingOrderCreateNum(pickingOrderCreateNum);
         driverGoodsLossIntervalDetail.setWholeOrderCreateNum(wholeOrderCreateNum);

+ 30 - 0
warehouse-admin-server/src/main/java/com/yr/warehouse/admin/service/driver/impl/DriverWarehouseServiceImpl.java

@@ -0,0 +1,30 @@
+package com.yr.warehouse.admin.service.driver.impl;
+
+import com.yr.warehouse.admin.areastaff.mapper.DriverWarehouseMapper;
+import com.yr.warehouse.admin.areastaff.vo.AreaStaffVo;
+import com.yr.warehouse.admin.common.bo.BaseIdBo;
+import com.yr.warehouse.admin.service.areastaff.AreaStaffService;
+import com.yr.warehouse.admin.service.driver.DriverWarehouseService;
+import jakarta.annotation.Resource;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * 司机仓库服务实现
+ */
+@Service
+public class DriverWarehouseServiceImpl implements DriverWarehouseService {
+
+    @Resource
+    private DriverWarehouseMapper driverWarehouseMapper;
+    @Resource
+    private AreaStaffService areaStaffService;
+
+    @Override
+    public List<AreaStaffVo> list(BaseIdBo bo) {
+        List<AreaStaffVo> driverWarehouseVos = driverWarehouseMapper.searchByWarehouseId(bo.getId());
+        areaStaffService.buildAreaStaffName(driverWarehouseVos);
+        return driverWarehouseVos;
+    }
+}

+ 0 - 17
warehouse-admin-server/src/main/java/com/yr/warehouse/admin/service/statistics/DriverStatistics.java

@@ -1,17 +0,0 @@
-package com.yr.warehouse.admin.service.statistics;
-
-import java.time.LocalDate;
-
-/**
- * 司机统计
- */
-public interface DriverStatistics {
-
-
-    /**
-     * 货损统计
-     * @param statDate 统计日期
-     */
-    void cargoDamageStatistics(LocalDate statDate);
-
-}

+ 30 - 0
warehouse-admin-server/src/main/java/com/yr/warehouse/admin/service/statistics/DriverStatisticsService.java

@@ -0,0 +1,30 @@
+package com.yr.warehouse.admin.service.statistics;
+
+import com.yr.warehouse.admin.statistics.vo.DriverStatisticsVo;
+
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.util.List;
+
+/**
+ * 司机统计
+ */
+public interface DriverStatisticsService {
+
+
+    /**
+     * 货损统计
+     * @param statDate 统计日期
+     */
+    void cargoDamageStatistics(LocalDate statDate);
+
+    /**
+     * 司机货损记录查询
+     * @param areaStaffIds 司机ids
+     * @param beginTime 开始时间
+     * @param endTime 结束时间
+     * @return 司机货损记录列表
+     */
+    DriverStatisticsVo generatorDriverStatisticsVo(List<Long> areaStaffIds, LocalDateTime beginTime, LocalDateTime endTime);
+
+}

+ 79 - 36
warehouse-admin-server/src/main/java/com/yr/warehouse/admin/service/statistics/impl/DriverStatisticsImpl.java → warehouse-admin-server/src/main/java/com/yr/warehouse/admin/service/statistics/impl/DriverStatisticsServiceImpl.java

@@ -5,6 +5,8 @@ import com.alibaba.fastjson2.JSONObject;
 import com.supplychain.api.response.areastaff.AreaStaffResponse;
 import com.yr.bluecat.common.redis.RedisComponent;
 import com.yr.shopping.admin.support.response.DriverDeviceSalesResponse;
+import com.yr.warehouse.admin.areastaff.mapper.DriverWarehouseMapper;
+import com.yr.warehouse.admin.areastaff.vo.AreaStaffVo;
 import com.yr.warehouse.admin.common.menu.BoolEnum;
 import com.yr.warehouse.admin.component.areastaff.AreaStaffComponent;
 import com.yr.warehouse.admin.component.driver.DriverDeviceSalesComponent;
@@ -17,10 +19,11 @@ import com.yr.warehouse.admin.driver.mapper.DriverEquipmentLossRecordMapper;
 import com.yr.warehouse.admin.driver.mapper.DriverGoodsLossRecordMapper;
 import com.yr.warehouse.admin.driver.mapper.DriverOnRouteDetailLogMapper;
 import com.yr.warehouse.admin.replenish.vo.DriverGoodsOrderNumVo;
-import com.yr.warehouse.admin.service.statistics.DriverStatistics;
+import com.yr.warehouse.admin.service.statistics.DriverStatisticsService;
 import com.yr.warehouse.admin.service.statistics.logic.DriverStatisticsMergeLogic;
 import com.yr.warehouse.admin.service.statistics.mapstruct.DriverStatisticsMapStruct;
 import com.yr.warehouse.admin.statistics.mapper.BillingQuantityStatisticsMapper;
+import com.yr.warehouse.admin.statistics.vo.DriverStatisticsVo;
 import jakarta.annotation.Resource;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
@@ -32,6 +35,7 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.TimeUnit;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 
@@ -40,7 +44,7 @@ import java.util.stream.Collectors;
  */
 @Slf4j
 @Service
-public class DriverStatisticsImpl implements DriverStatistics {
+public class DriverStatisticsServiceImpl implements DriverStatisticsService {
     @Resource
     private RedisComponent redisComponent;
 
@@ -48,6 +52,9 @@ public class DriverStatisticsImpl implements DriverStatistics {
     private AreaStaffComponent areaStaffComponent;
 
     @Resource
+    private DriverWarehouseMapper driverWarehouseMapper;
+
+    @Resource
     private DriverDeviceSalesComponent driverDeviceSalesComponent;
 
     @Resource
@@ -77,33 +84,75 @@ public class DriverStatisticsImpl implements DriverStatistics {
         // 货损统计业务开始
         log.info(String.format("司机货损统计开始:开始时间[%s], 结束时间[%s]", beginTime, endTime));
 
+        // 司机设备库存 - 不含商品id - 需锚定司机设备库存, 保证异常情况后重新查询时设备库存值不变
+        List<DriverGoodsOrderNumVo> deviceInventoryNumVos = queryDriverDeviceInventoryNum(beginTime, endTime);
+
 
-        driverGoodsLossRecordMapper.deleteOld(statDate);
-        driverEquipmentLossRecordMapper.deleteOld(statDate);
-        driverOnRouteDetailLogMapper.deleteOld(statDate);
+        List<AreaStaffVo> areaStaffVos = driverWarehouseMapper.all();
+        Map<Long, List<AreaStaffVo>> operatorAreaStaffMap = areaStaffVos.stream().collect(Collectors.groupingBy(AreaStaffVo::getOperatorId));
+
+        for (Map.Entry<Long, List<AreaStaffVo>> entry : operatorAreaStaffMap.entrySet()) {
+            Long operatorId = entry.getKey();
+            driverGoodsLossRecordMapper.deleteOld(operatorId, statDate);
+            driverEquipmentLossRecordMapper.deleteOld(operatorId, statDate);
+            driverOnRouteDetailLogMapper.deleteOld(operatorId, statDate);
+
+            List<Long> areaStaffIds = entry.getValue().stream().map(AreaStaffVo::getId).collect(Collectors.toList());
+
+            DriverStatisticsVo vo = priGeneratorDriverStatisticsVo(deviceInventoryNumVos, areaStaffIds, statDate, beginTime, endTime);
+            List<DriverGoodsLossRecord> driverGoodsLossRecords = vo.getDriverGoodsLossRecords();
+            List<DriverEquipmentLossRecord> driverEquipmentLossRecords = vo.getDriverEquipmentLossRecords();
+            driverGoodsLossRecordMapper.insertBatch(driverGoodsLossRecords);
+            driverEquipmentLossRecordMapper.insertBatch(driverEquipmentLossRecords);
+
+            List<DriverOnRouteDetailLog> driverOnRouteDetailLogs = generatorDriverOnRouteDetailLog(statDate,
+                    driverGoodsLossRecords,
+                    driverStatisticsMergeLogic.groupByAreaStaffGoods(vo.getPickingBillingQuantityNumVos()),
+                    driverStatisticsMergeLogic.groupByAreaStaffGoods(vo.getAggregationBillingQuantityNumVos()),
+                    driverStatisticsMergeLogic.groupByAreaStaffGoods(vo.getUnOutStockCancelNumVos()),
+                    driverStatisticsMergeLogic.groupByAreaStaffGoods(vo.getOutStockCancelNumVos()),
+                    driverStatisticsMergeLogic.groupByAreaStaffGoods(vo.getDriverReplenishNumVos()),
+                    driverStatisticsMergeLogic.groupByAreaStaffGoods(vo.getDriverReturnNumVos())
+            );
+            if (!driverOnRouteDetailLogs.isEmpty()) {
+                driverOnRouteDetailLogMapper.insertBatch(driverOnRouteDetailLogs);
+            }
+        }
+        log.info(String.format("司机货损统计结束:开始时间[%s], 结束时间[%s]", beginTime, endTime));
+    }
 
+    @Override
+    public DriverStatisticsVo generatorDriverStatisticsVo(List<Long> areaStaffIds, LocalDateTime beginTime, LocalDateTime endTime) {
         // 司机设备库存 - 不含商品id - 需锚定司机设备库存, 保证异常情况后重新查询时设备库存值不变
         List<DriverGoodsOrderNumVo> deviceInventoryNumVos = queryDriverDeviceInventoryNum(beginTime, endTime);
+        return priGeneratorDriverStatisticsVo(deviceInventoryNumVos, areaStaffIds, null, beginTime, endTime);
+    }
+
+    private DriverStatisticsVo priGeneratorDriverStatisticsVo(List<DriverGoodsOrderNumVo> deviceInventoryNumVos,
+                                                              List<Long> areaStaffIds,
+                                                              LocalDate statDate,
+                                                              LocalDateTime beginTime,
+                                                              LocalDateTime endTime) {
         // 司机拣货单开单数 - 含商品id
-        List<DriverGoodsOrderNumVo> pickingBillingQuantityNumVos = billingQuantityStatisticsMapper.queryPickingBillingQuantity(beginTime, endTime);
+        List<DriverGoodsOrderNumVo> pickingBillingQuantityNumVos = billingQuantityStatisticsMapper.queryPickingBillingQuantity(areaStaffIds, beginTime, endTime);
         // 司机整件单开单数 - 含商品id
-        List<DriverGoodsOrderNumVo> aggregationBillingQuantityNumVos = billingQuantityStatisticsMapper.queryAggregationBillingQuantity(beginTime, endTime);
+        List<DriverGoodsOrderNumVo> aggregationBillingQuantityNumVos = billingQuantityStatisticsMapper.queryAggregationBillingQuantity(areaStaffIds, beginTime, endTime);
         // 未出库取消数 - 含商品id
-        List<DriverGoodsOrderNumVo> unOutStockCancelNumVos = billingQuantityStatisticsMapper.queryUnOutStockCancelNum(beginTime, endTime);
+        List<DriverGoodsOrderNumVo> unOutStockCancelNumVos = billingQuantityStatisticsMapper.queryUnOutStockCancelNum(areaStaffIds, beginTime, endTime);
         // 已出库取消数 - 含商品id
-        List<DriverGoodsOrderNumVo> outStockCancelNumVos = billingQuantityStatisticsMapper.queryOutStockCancelNum(beginTime, endTime);
+        List<DriverGoodsOrderNumVo> outStockCancelNumVos = billingQuantityStatisticsMapper.queryOutStockCancelNum(areaStaffIds, beginTime, endTime);
         // 查询司机补货数 - 含商品id
-        List<DriverGoodsOrderNumVo> driverReplenishNumVos = billingQuantityStatisticsMapper.queryDriverReplenishNum(beginTime, endTime);
+        List<DriverGoodsOrderNumVo> driverReplenishNumVos = billingQuantityStatisticsMapper.queryDriverReplenishNum(areaStaffIds, beginTime, endTime);
         // 查询设备补货数 - 不含商品id
-        List<DriverGoodsOrderNumVo> deviceReplenishNumVos = billingQuantityStatisticsMapper.queryDeviceReplenishNum(beginTime, endTime);
+        List<DriverGoodsOrderNumVo> deviceReplenishNumVos = billingQuantityStatisticsMapper.queryDeviceReplenishNum(areaStaffIds, beginTime, endTime);
         // 查询司机回仓数 - 含商品id
-        List<DriverGoodsOrderNumVo> driverReturnNumVos = billingQuantityStatisticsMapper.queryDriverReturnNum(beginTime, endTime);
+        List<DriverGoodsOrderNumVo> driverReturnNumVos = billingQuantityStatisticsMapper.queryDriverReturnNum(areaStaffIds, beginTime, endTime);
         // 司机设备销量统计 - 不含商品id
-        List<DriverDeviceSalesResponse> driverDeviceSalesResponses = driverDeviceSalesComponent.list(beginTime, endTime);
+        List<DriverDeviceSalesResponse> driverDeviceSalesResponses = driverDeviceSalesComponent.list(areaStaffIds, beginTime, endTime);
         List<DriverGoodsOrderNumVo> driverDeviceSalesNumVos = DriverStatisticsMapStruct.INSTANCE.driverDeviceSalesToVo(driverDeviceSalesResponses);
 
         // 提取所有数据中的司机ID并去重
-        List<Long> areaStaffIds = driverStatisticsMergeLogic.getAreaStaffIds(
+        List<Long> allAreaStaffIds = driverStatisticsMergeLogic.getAreaStaffIds(
                 deviceInventoryNumVos,
                 pickingBillingQuantityNumVos,
                 aggregationBillingQuantityNumVos,
@@ -114,12 +163,12 @@ public class DriverStatisticsImpl implements DriverStatistics {
                 driverReturnNumVos,
                 driverDeviceSalesNumVos);
 
-        List<AreaStaffResponse> areaStaffResponses = areaStaffComponent.searchByStaffIds(areaStaffIds);
+        List<AreaStaffResponse> areaStaffResponses = areaStaffComponent.searchByStaffIds(allAreaStaffIds);
         Map<Long, AreaStaffResponse> areaStaffMap = areaStaffResponses.stream().collect(Collectors.toMap(AreaStaffResponse::getId, areaStaffResponse -> areaStaffResponse));
 
         // 生成司机货损记录
         List<DriverGoodsLossRecord> driverGoodsLossRecords = generatorDriverGoodsLossRecord(statDate,
-                areaStaffIds,
+                allAreaStaffIds,
                 areaStaffMap,
                 driverStatisticsMergeLogic.groupByAreaStaffId(pickingBillingQuantityNumVos),
                 driverStatisticsMergeLogic.groupByAreaStaffId(aggregationBillingQuantityNumVos),
@@ -128,33 +177,27 @@ public class DriverStatisticsImpl implements DriverStatistics {
                 driverStatisticsMergeLogic.groupByAreaStaffId(driverReplenishNumVos),
                 driverStatisticsMergeLogic.groupByAreaStaffId(driverReturnNumVos));
 
-        driverGoodsLossRecordMapper.insertBatch(driverGoodsLossRecords);
-
-
         // 生成司机设备货损记录
         List<DriverEquipmentLossRecord> driverEquipmentLossRecords = generatorDriverEquipmentLossRecord(statDate,
-                areaStaffIds,
+                allAreaStaffIds,
                 areaStaffMap,
                 driverStatisticsMergeLogic.groupByAreaStaffId(deviceReplenishNumVos),
                 driverStatisticsMergeLogic.groupByAreaStaffId(driverDeviceSalesNumVos),
                 driverStatisticsMergeLogic.groupByAreaStaffId(deviceInventoryNumVos)
         );
-        driverEquipmentLossRecordMapper.insertBatch(driverEquipmentLossRecords);
-
-        List<DriverOnRouteDetailLog> driverOnRouteDetailLogs = generatorDriverOnRouteDetailLog(statDate,
-                driverGoodsLossRecords,
-                driverStatisticsMergeLogic.groupByAreaStaffGoods(pickingBillingQuantityNumVos),
-                driverStatisticsMergeLogic.groupByAreaStaffGoods(aggregationBillingQuantityNumVos),
-                driverStatisticsMergeLogic.groupByAreaStaffGoods(unOutStockCancelNumVos),
-                driverStatisticsMergeLogic.groupByAreaStaffGoods(outStockCancelNumVos),
-                driverStatisticsMergeLogic.groupByAreaStaffGoods(driverReplenishNumVos),
-                driverStatisticsMergeLogic.groupByAreaStaffGoods(driverReturnNumVos)
-        );
-        if (!driverOnRouteDetailLogs.isEmpty()) {
-            driverOnRouteDetailLogMapper.insertBatch(driverOnRouteDetailLogs);
-        }
 
-        log.info(String.format("司机货损统计结束:开始时间[%s], 结束时间[%s]", beginTime, endTime));
+        DriverStatisticsVo res = new DriverStatisticsVo();
+        res.setDriverGoodsLossRecords(driverGoodsLossRecords);
+        res.setDriverEquipmentLossRecords(driverEquipmentLossRecords);
+        res.setPickingBillingQuantityNumVos(pickingBillingQuantityNumVos);
+        res.setAggregationBillingQuantityNumVos(aggregationBillingQuantityNumVos);
+        res.setUnOutStockCancelNumVos(unOutStockCancelNumVos);
+        res.setOutStockCancelNumVos(outStockCancelNumVos);
+        res.setDriverReplenishNumVos(driverReplenishNumVos);
+        res.setDeviceReplenishNumVos(deviceReplenishNumVos);
+        res.setDriverReturnNumVos(driverReturnNumVos);
+        res.setDriverDeviceSalesNumVos(driverDeviceSalesNumVos);
+        return res;
     }
 
     /**
@@ -187,7 +230,7 @@ public class DriverStatisticsImpl implements DriverStatistics {
         }
 
         // 缓存司机设备库存数
-        redisComponent.cacheValue(key, JSONObject.toJSONString(result));
+        redisComponent.cacheValue(key, JSONObject.toJSONString(result), 1, TimeUnit.DAYS);
         return result;
     }
 

+ 5 - 5
warehouse-admin-web/src/main/java/com/yr/warehouse/admin/web/driver/controller/DriverIntervalCargoDamageController.java

@@ -82,10 +82,10 @@ public class DriverIntervalCargoDamageController extends BaseController {
     /**
      * 查询运营商对应的区间货损最后统计时间
      */
-    @GetMapping("/searchLastTotalTime/{operatorId}")
+    @GetMapping("/searchLastTotalTime")
     @ResponseBody
-    public Result<String> searchLastTotalTime(@PathVariable("operatorId") Long operatorId) {
-        LocalDateTime localDateTime = driverGoodsLossIntervalMainService.searchLastTotalTime(operatorId);
+    public Result<String> searchLastTotalTime(@RequestParam("operatorId") Long operatorId, @RequestParam("warehouseId") Long warehouseId) {
+        LocalDateTime localDateTime = driverGoodsLossIntervalMainService.searchLastTotalTime(operatorId, warehouseId);
         return Result.success(localDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
     }
 
@@ -139,8 +139,8 @@ public class DriverIntervalCargoDamageController extends BaseController {
                 driverIntervalCargoDamageVo.setOperatorChainName(operatorVo.getOperatorChainName());
             }
         });
-        List<DriverIntervalCargoDamageResponse> driverIntervalCargoDamageRespons = DriverIntervalCargoDamageMapStruct.MAPSTRUCT.voListToPageResponseList(driverIntervalCargoDamageVos);
-        return pageResult.success(page.getTotal(), driverIntervalCargoDamageRespons);
+        List<DriverIntervalCargoDamageResponse> driverIntervalCargoDamageResponses = DriverIntervalCargoDamageMapStruct.MAPSTRUCT.voListToPageResponseList(driverIntervalCargoDamageVos);
+        return pageResult.success(page.getTotal(), driverIntervalCargoDamageResponses);
     }
 
     /**

+ 40 - 0
warehouse-admin-web/src/main/java/com/yr/warehouse/admin/web/driver/controller/DriverWarehouseController.java

@@ -0,0 +1,40 @@
+package com.yr.warehouse.admin.web.driver.controller;
+
+import com.yr.bluecat.common.entity.response.Result;
+import com.yr.prism.auth.core.user.AdminUserInfo;
+import com.yr.warehouse.admin.areastaff.vo.AreaStaffVo;
+import com.yr.warehouse.admin.common.bo.BaseIdBo;
+import com.yr.warehouse.admin.service.driver.DriverWarehouseService;
+import com.yr.warehouse.admin.web.common.BaseController;
+import com.yr.warehouse.admin.web.driver.mapstruct.DriverWarehouseMapStruct;
+import com.yr.warehouse.admin.web.driver.response.DriverAreaStaffResponse;
+import jakarta.annotation.Resource;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * 司机仓库控制器
+ */
+@RestController
+@RequestMapping("/driver/warehouse")
+public class DriverWarehouseController extends BaseController {
+
+    @Resource
+    private DriverWarehouseService driverWarehouseService;
+
+    /**
+     * 获取仓库司机列表
+     * @param warehouseId 仓库id
+     * @return 司机列表
+     */
+    @GetMapping("/list/{warehouseId}")
+    @ResponseBody
+    public Result<List<DriverAreaStaffResponse>> list(@PathVariable("warehouseId") Long warehouseId, AdminUserInfo adminUserInfo) {
+        BaseIdBo bo = new BaseIdBo();
+        bo.setId(warehouseId);
+        buildUserInfo(bo, adminUserInfo);
+        List<AreaStaffVo> driverWarehouseVos = driverWarehouseService.list(bo);
+        return Result.success(DriverWarehouseMapStruct.MAPSTRUCT.areaStaffVo2DDriverAreaStaffResponse(driverWarehouseVos));
+    }
+}

+ 16 - 0
warehouse-admin-web/src/main/java/com/yr/warehouse/admin/web/driver/mapstruct/DriverWarehouseMapStruct.java

@@ -0,0 +1,16 @@
+package com.yr.warehouse.admin.web.driver.mapstruct;
+
+import com.yr.warehouse.admin.areastaff.vo.AreaStaffVo;
+import com.yr.warehouse.admin.web.driver.response.DriverAreaStaffResponse;
+import org.mapstruct.Mapper;
+import org.mapstruct.factory.Mappers;
+
+import java.util.List;
+
+@Mapper
+public interface DriverWarehouseMapStruct {
+
+    DriverWarehouseMapStruct MAPSTRUCT = Mappers.getMapper(DriverWarehouseMapStruct.class);
+
+    List<DriverAreaStaffResponse> areaStaffVo2DDriverAreaStaffResponse(List<AreaStaffVo> driverWarehouseVos);
+}

+ 6 - 0
warehouse-admin-web/src/main/java/com/yr/warehouse/admin/web/driver/request/DriverIntervalCargoDamageGeneratorRequest.java

@@ -25,6 +25,12 @@ public class DriverIntervalCargoDamageGeneratorRequest implements Serializable {
     private Long operatorId;
 
     /**
+     * 仓库id
+     */
+    @NotNull(message = "请选择仓库")
+    private Long warehouseId;
+
+    /**
      * 区间开始时间
      */
     @NotNull(message = "请选择区间开始时间")

+ 128 - 0
warehouse-admin-web/src/main/java/com/yr/warehouse/admin/web/driver/response/DriverAreaStaffResponse.java

@@ -0,0 +1,128 @@
+package com.yr.warehouse.admin.web.driver.response;
+
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+/**
+ * 司机区域员工关系响应
+ */
+@Data
+public class DriverAreaStaffResponse implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 区域员工id
+     */
+    private Long areaStaffId;
+
+    /**
+     * 区域员工名称
+     */
+    private String areaStaffName;
+
+    /**
+     * 区域链名称
+     */
+    private String areaChainName;
+
+    /**
+     * 区域员工id
+     */
+    private Long id;
+
+    /**
+     * 运营商id
+     */
+    private Long operatorId;
+
+    /**
+     * 运营商id链
+     */
+    private String operatorChain;
+
+    /**
+     * 区域id
+     */
+    private Long areaId;
+
+    /**
+     * 区域链
+     */
+    private String areaChain;
+
+    /**
+     * 员工id
+     */
+    private Long employeeId;
+
+    /**
+     * 员工名称
+     */
+    private String employeeName;
+
+    /**
+     * 账号id
+     */
+    private Long accountId;
+
+    /**
+     * 汽车装框数
+     */
+    private Integer carBoxNum;
+
+    /**
+     * 最大整件单修改拣货数比例
+     */
+    private BigDecimal maxAggregationPickingRatio;
+
+    /**
+     * 创建时间
+     */
+    private LocalDateTime createTime;
+
+    /**
+     * 创建人uid
+     */
+    private Long createUid;
+
+    /**
+     * 创建人名称
+     */
+    private String createName;
+
+    /**
+     * 修改时间
+     */
+    private LocalDateTime modifyTime;
+
+    /**
+     * 修改人uid
+     */
+    private Long modifyUid;
+
+    /**
+     * 修改人名称
+     */
+    private String modifyName;
+
+    /**
+     * 删除状态:NORMAL:正常|DELETE:删除
+     */
+    private String isDelete;
+
+    /**
+     * 员工负责人账户id
+     */
+    private Long managerAccountId;
+
+    /**
+     * 员工负责人账户名称
+     */
+    private String managerAccountName;
+}

+ 10 - 0
warehouse-admin-web/src/main/java/com/yr/warehouse/admin/web/driver/response/DriverIntervalCargoDamageResponse.java

@@ -42,6 +42,16 @@ public class DriverIntervalCargoDamageResponse implements Serializable {
     private String operatorChainName;
 
     /**
+     * 仓库id
+     */
+    private Long warehouseId;
+
+    /**
+     * 仓库名称
+     */
+    private String warehouseName;
+
+    /**
      * 区间开始时间
      */
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")