Bladeren bron

[update] 日货损统计异常问题修复

miajio 1 week geleden
bovenliggende
commit
a21f193096

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

@@ -28,10 +28,11 @@ public interface DriverOnRouteDetailLogMapper extends BaseMapper<DriverOnRouteDe
 
     /**
      * 按统计日期查询
+     * @param areaStaffIds 补货司机ids
      * @param statDate 统计日期
      * @return
      */
-    List<DriverOnRouteDetailLog> searchByStatDate(@Param("statDate") LocalDate statDate);
+    List<DriverOnRouteDetailLog> searchByStatDate(@Param("areaStaffIds") List<Long> areaStaffIds, @Param("statDate") LocalDate statDate);
 
     /**
      * 分页查询

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

@@ -44,6 +44,12 @@
     <select id="searchByStatDate" resultType="com.yr.warehouse.admin.driver.data.DriverOnRouteDetailLog"
             parameterType="java.time.LocalDate">
         select <include refid="Base_Column_List" /> from yr_driver_on_route_detail_log where statDate = #{statDate}
+        <if test="areaStaffIds != null and areaStaffIds.size > 0">
+            and areaStaffId in
+            <foreach item="item" index="index" collection="areaStaffIds" separator="," open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
     </select>
     <select id="searchForPage" resultType="com.yr.warehouse.admin.driver.vo.DriverRouteDetailVo">
         select

+ 16 - 4
warehouse-admin-server/src/main/java/com/yr/warehouse/admin/service/statistics/impl/DriverStatisticsServiceImpl.java

@@ -102,6 +102,11 @@ public class DriverStatisticsServiceImpl implements DriverStatisticsService {
             DriverStatisticsVo vo = priGeneratorDriverStatisticsVo(deviceInventoryNumVos, areaStaffIds, statDate, beginTime, endTime);
             List<DriverGoodsLossRecord> driverGoodsLossRecords = vo.getDriverGoodsLossRecords();
             List<DriverEquipmentLossRecord> driverEquipmentLossRecords = vo.getDriverEquipmentLossRecords();
+
+            if (null == driverGoodsLossRecords || driverGoodsLossRecords.isEmpty() || null == driverEquipmentLossRecords || driverEquipmentLossRecords.isEmpty()) {
+                continue;
+            }
+
             driverGoodsLossRecordMapper.insertBatch(driverGoodsLossRecords);
             driverEquipmentLossRecordMapper.insertBatch(driverEquipmentLossRecords);
 
@@ -114,7 +119,7 @@ public class DriverStatisticsServiceImpl implements DriverStatisticsService {
                     driverStatisticsMergeLogic.groupByAreaStaffGoods(vo.getDriverReplenishNumVos()),
                     driverStatisticsMergeLogic.groupByAreaStaffGoods(vo.getDriverReturnNumVos())
             );
-            if (!driverOnRouteDetailLogs.isEmpty()) {
+            if (null != driverOnRouteDetailLogs && !driverOnRouteDetailLogs.isEmpty()) {
                 driverOnRouteDetailLogMapper.insertBatch(driverOnRouteDetailLogs);
             }
         }
@@ -136,6 +141,9 @@ public class DriverStatisticsServiceImpl implements DriverStatisticsService {
                                                               LocalDate statDate,
                                                               LocalDateTime beginTime,
                                                               LocalDateTime endTime) {
+
+        List<DriverGoodsOrderNumVo> inDeviceInventoryNumVos = deviceInventoryNumVos.stream().filter(deviceInventoryNumVo -> areaStaffIds.contains(deviceInventoryNumVo.getAreaStaffId())).collect(Collectors.toList());
+
         // 司机拣货单开单数 - 含商品id
         List<DriverGoodsOrderNumVo> pickingBillingQuantityNumVos = billingQuantityStatisticsMapper.queryPickingBillingQuantity(areaStaffIds, beginTime, endTime);
         // 司机整件单开单数 - 含商品id
@@ -156,7 +164,7 @@ public class DriverStatisticsServiceImpl implements DriverStatisticsService {
 
         // 提取所有数据中的司机ID并去重
         List<Long> allAreaStaffIds = driverStatisticsMergeLogic.getAreaStaffIds(
-                deviceInventoryNumVos,
+                inDeviceInventoryNumVos,
                 pickingBillingQuantityNumVos,
                 aggregationBillingQuantityNumVos,
                 unOutStockCancelNumVos,
@@ -186,7 +194,7 @@ public class DriverStatisticsServiceImpl implements DriverStatisticsService {
                 areaStaffMap,
                 driverStatisticsMergeLogic.groupByAreaStaffId(deviceReplenishNumVos),
                 driverStatisticsMergeLogic.groupByAreaStaffId(driverDeviceSalesNumVos),
-                driverStatisticsMergeLogic.groupByAreaStaffId(deviceInventoryNumVos)
+                driverStatisticsMergeLogic.groupByAreaStaffId(inDeviceInventoryNumVos)
         );
 
         DriverStatisticsVo res = new DriverStatisticsVo();
@@ -377,7 +385,11 @@ public class DriverStatisticsServiceImpl implements DriverStatisticsService {
                                                                          Map<Long, Map<Integer, Long>> driverReplenishNumVoMap,
                                                                          Map<Long, Map<Integer, Long>> driverReturnNumVoMap
     ) {
-        List<DriverOnRouteDetailLog> yesterdayDriverOnRouteDetailLogs = driverOnRouteDetailLogMapper.searchByStatDate(statDate.minusDays(1));
+        if (null == driverGoodsLossRecords || driverGoodsLossRecords.isEmpty()) {
+            return null;
+        }
+        List<Long> areaStaffIds = driverGoodsLossRecords.stream().map(DriverGoodsLossRecord::getAreaStaffId).distinct().collect(Collectors.toList());
+        List<DriverOnRouteDetailLog> yesterdayDriverOnRouteDetailLogs = driverOnRouteDetailLogMapper.searchByStatDate(areaStaffIds, statDate.minusDays(1));
         Map<Long, Map<Integer, Long>> yesterdayDriverOnRouteDetailLogMap;
         if (null != yesterdayDriverOnRouteDetailLogs && !yesterdayDriverOnRouteDetailLogs.isEmpty()) {
             yesterdayDriverOnRouteDetailLogMap = yesterdayDriverOnRouteDetailLogs.stream()