Browse Source

[update] 司机货损统计逻辑整改

miajio 5 days ago
parent
commit
9ed374e414

+ 11 - 0
warehouse-admin-data/src/main/java/com/yr/warehouse/admin/driver/mapper/DriverGoodsLossStatUnReplenishSnapshotMapper.java

@@ -4,6 +4,7 @@ import com.yr.warehouse.admin.driver.data.DriverGoodsLossStatUnReplenishSnapshot
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 
+import java.time.LocalDateTime;
 import java.util.List;
 
 /**
@@ -22,4 +23,14 @@ public interface DriverGoodsLossStatUnReplenishSnapshotMapper extends BaseMapper
      * @param driverGoodsLossStatUnReplenishSnapshots 司机区域货损统计未补货补货单快照
      */
     void insertBatch(@Param("goodsLossMonthlyMainId") Long goodsLossMonthlyMainId, @Param("driverGoodsLossStatUnReplenishSnapshots") List<DriverGoodsLossStatUnReplenishSnapshot> driverGoodsLossStatUnReplenishSnapshots);
+
+    /**
+     * 查询未补货的补货单
+     *
+     * @param areaStaffIds 区域员工id
+     * @param intervalStartTime 开始时间
+     * @param intervalEndTime 结束时间
+     * @return 未补货的补货单
+     */
+    List<DriverGoodsLossStatUnReplenishSnapshot> searchDriverGoodsLossStatUnReplenishSnapshot(@Param("areaStaffIds") List<Long> areaStaffIds, @Param("intervalStartTime") LocalDateTime intervalStartTime, @Param("intervalEndTime") LocalDateTime intervalEndTime);
 }

+ 0 - 9
warehouse-admin-data/src/main/java/com/yr/warehouse/admin/replenish/mapper/ReplenishOrderInfoMapper.java

@@ -18,13 +18,4 @@ import java.util.List;
  */
 public interface ReplenishOrderInfoMapper extends BaseMapper<ReplenishOrderInfo> {
 
-    /**
-     * 查询未补货的补货单
-     *
-     * @param areaStaffIds 区域员工id
-     * @param intervalStartTime 开始时间
-     * @param intervalEndTime 结束时间
-     * @return 未补货的补货单
-     */
-    List<DriverGoodsLossStatUnReplenishSnapshot> searchDriverGoodsLossStatUnReplenishSnapshot(@Param("areaStaffIds") List<Long> areaStaffIds, @Param("intervalStartTime") LocalDateTime intervalStartTime, @Param("intervalEndTime") LocalDateTime intervalEndTime);
 }

+ 23 - 0
warehouse-admin-data/src/main/resources/mapper/driver/DriverGoodsLossStatUnReplenishSnapshotMapper.xml

@@ -24,5 +24,28 @@
             (#{goodsLossMonthlyMainId}, #{item.areaStaffId}, #{item.unReplenishOrderNumber}, #{item.unReplenishedNum})
         </foreach>
     </insert>
+    <select id="searchDriverGoodsLossStatUnReplenishSnapshot" resultType="com.yr.warehouse.admin.driver.data.DriverGoodsLossStatUnReplenishSnapshot">
+        select
+        roi.area_staff_id as areaStaffId,
+        roi.order_number as unReplenishOrderNumber,
+        sum(rod.picking_number) as unReplenishedNum
+        from yr_replenish_order_info as roi
+        left join yr_replenish_order_detail as rod on roi.order_number = rod.order_number
+        where roi.replenish_time is null
+        and roi.replenish_status = 0
+        <if test="areaStaffIds != null and areaStaffIds.size > 0">
+            and roi.area_staff_id in
+            <foreach item="item" collection="areaStaffIds" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test="intervalStartTime != null">
+            and roi.create_time >= #{intervalStartTime}
+        </if>
+        <if test="intervalEndTime != null">
+            and #{intervalEndTime} >= roi.create_time
+        </if>
+        group by roi.area_staff_id, roi.order_number
+    </select>
 
 </mapper>

+ 0 - 23
warehouse-admin-data/src/main/resources/mapper/replenish/ReplenishOrderInfoMapper.xml

@@ -31,27 +31,4 @@
     <sql id="Base_Column_List">
         id, operator_id, operator_chain, order_number, parent_order_number, warehouse_info_id, device_id, area_staff_id, replenish_account_id, replenish_user_name, replenish_user_id, replenish_time, replenish_type, replenish_status, file_urls, create_time, create_uid, create_name, modify_time, modify_uid, modify_name
     </sql>
-    <select id="searchDriverGoodsLossStatUnReplenishSnapshot" resultType="com.yr.warehouse.admin.driver.data.DriverGoodsLossStatUnReplenishSnapshot">
-        select
-            roi.area_staff_id as areaStaffId,
-            roi.order_number as unReplenishOrderNumber,
-            sum(rod.picking_number) as unReplenishedNum
-        from yr_replenish_order_info as roi
-        left join yr_replenish_order_detail as rod on roi.order_number = rod.order_number
-        where roi.replenish_time is null
-        and roi.replenish_status = 0
-        <if test="areaStaffIds != null and areaStaffIds.size > 0">
-            and roi.area_staff_id in
-            <foreach item="item" collection="areaStaffIds" open="(" separator="," close=")">
-                #{item}
-            </foreach>
-        </if>
-        <if test="intervalStartTime != null">
-            and roi.create_time >= #{intervalStartTime}
-        </if>
-        <if test="intervalEndTime != null">
-            and #{intervalEndTime} >= roi.create_time
-        </if>
-        order by roi.id desc
-    </select>
 </mapper>

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

@@ -22,6 +22,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.support.TransactionTemplate;
 
 import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
 import java.util.*;
 import java.util.function.Function;
 import java.util.stream.Collectors;
@@ -108,8 +109,11 @@ public class DriverGoodsLossIntervalServiceImpl implements DriverGoodsLossInterv
         if (null == areaStaffVos || areaStaffVos.isEmpty()) {
             throw new MessageException("当前仓库下没有司机");
         }
-        bo.setIntervalStartTime(LocalDateTime.parse(bo.getIntervalStartTime().toLocalDate() + " 04:00:00"));
-        bo.setIntervalEndTime(LocalDateTime.parse(bo.getIntervalEndTime().toLocalDate() + " 03:59:59"));
+
+        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+        DateTimeFormatter dateTimeFormatterWithTime = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+        bo.setIntervalStartTime(LocalDateTime.parse(bo.getIntervalStartTime().toLocalDate().format(dateTimeFormatter) + " 04:00:00", dateTimeFormatterWithTime));
+        bo.setIntervalEndTime(LocalDateTime.parse(bo.getIntervalEndTime().toLocalDate().format(dateTimeFormatter) + " 03:59:59", dateTimeFormatterWithTime));
 
         bo.setBeginStatDate(bo.getIntervalStartTime().toLocalDate());
         bo.setEndStatDate(bo.getIntervalEndTime().toLocalDate());
@@ -127,7 +131,7 @@ public class DriverGoodsLossIntervalServiceImpl implements DriverGoodsLossInterv
         }
 
         // 获取司机未补货的补货单列表
-        List<DriverGoodsLossStatUnReplenishSnapshot> driverGoodsLossStatUnReplenishSnapshots = replenishOrderInfoMapper.searchDriverGoodsLossStatUnReplenishSnapshot(bo.getAreaStaffIds(), bo.getIntervalStartTime(), bo.getIntervalEndTime());
+        List<DriverGoodsLossStatUnReplenishSnapshot> driverGoodsLossStatUnReplenishSnapshots = driverGoodsLossStatUnReplenishSnapshotMapper.searchDriverGoodsLossStatUnReplenishSnapshot(bo.getAreaStaffIds(), bo.getIntervalStartTime(), bo.getIntervalEndTime());
         List<ReplenishOrderDetail> unReplenishOrderDetails = new ArrayList<>();
         if (null != driverGoodsLossStatUnReplenishSnapshots && !driverGoodsLossStatUnReplenishSnapshots.isEmpty()) {
             unReplenishOrderDetails = replenishOrderDetailMapper.searchByOrderNumbers(driverGoodsLossStatUnReplenishSnapshots.stream().map(DriverGoodsLossStatUnReplenishSnapshot::getUnReplenishOrderNumber).collect(Collectors.toList()));