Prechádzať zdrojové kódy

运单表关联订单表修改

czh 1 rok pred
rodič
commit
6fc85b0d89

+ 4 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/dao/KwtWaybillOrderV1Mapper.java

@@ -118,4 +118,8 @@ public interface KwtWaybillOrderV1Mapper extends BaseMapper<KwtWaybillOrderV1> {
      * @return 运单信息
      **/
     List<KwtWaybillOrderV1> findWaybillOrder(Map<String, Object> params);
+
+    WaybillCountVo findWaybillOrderCount(Map<String, Object> map);
+
+    int selectDataByLorderId(@Param("id") String id, @Param("statusList") List<Integer> statusList);
 }

+ 4 - 3
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/KwtCommonService.java

@@ -28,6 +28,7 @@ import com.sckw.transport.common.config.MessageUrlConfig;
 import com.sckw.transport.dao.KwtLogisticsOrderContractMapper;
 import com.sckw.transport.dao.KwtLogisticsOrderMapper;
 import com.sckw.transport.dao.KwtWaybillOrderMapper;
+import com.sckw.transport.dao.KwtWaybillOrderV1Mapper;
 import com.sckw.transport.model.KwtLogisticsOrder;
 import com.sckw.transport.model.KwtLogisticsOrderContract;
 import com.sckw.transport.model.KwtLogisticsOrderUnit;
@@ -83,7 +84,7 @@ public class KwtCommonService {
     private KwtLogisticsOrderContractMapper logisticsOrderContractMapper;
 
     @Autowired
-    private KwtWaybillOrderMapper waybillOrderMapper;
+    private KwtWaybillOrderV1Mapper kwtWaybillOrderV1Mapper;
 
     /**
      * 组装返回数据
@@ -215,7 +216,7 @@ public class KwtCommonService {
                 put("upperlOrderId", logisticsOrder.getId());
                 put("passStatus", Global.NUMERICAL_ONE);
             }};
-            WaybillCountVo waybillOrderCount = waybillOrderMapper.findWaybillOrderCount(map);
+            WaybillCountVo waybillOrderCount = kwtWaybillOrderV1Mapper.findWaybillOrderCount(map);
             actualAmount = waybillOrderCount == null ? NumberConstant.ZERO_TWO : new BigDecimal(waybillOrderCount.getTotalComplete());
         } else if (DictEnum.CHARGING_TYPE_4.getValue().equals(billingMode)) {
             log.debug("“该方式不处理合同");
@@ -622,7 +623,7 @@ public class KwtCommonService {
         statusList.add(CarWaybillEnum.APPROVAL_IN.getCode());
         statusList.add(CarWaybillEnum.APPROVAL_NO_PASS.getCode());
 //        statusList.add(CarWaybillEnum.APPROVAL_PASS.getCode());
-        int count = waybillOrderMapper.selectDataByLorderId(id, statusList);
+        int count = kwtWaybillOrderV1Mapper.selectDataByLorderId(id, statusList);
         if (count > NumberConstant.ZERO) {
             flag = true;
         }

+ 67 - 0
sckw-modules/sckw-transport/src/main/resources/mapper/KwtWaybillOrderV1Mapper.xml

@@ -381,4 +381,71 @@
             </when>
         </choose>
     </select>
+    <select id="findWaybillOrderCount" resultType="com.sckw.transport.model.vo.WaybillCountVo">
+        SELECT
+        count(case when c.status = 8 then 1 end) totalComplete,
+        count(case when c.status not in (1, 9, 10, 11) then 1 end) totalTake,
+        count(case when c.status in (3, 4, 5, 6) then 1 end) totalExecute,
+        count(DISTINCT case when lo.status in (0, 1, 2, 3) then lo.id end) totalUnfinished,
+        IFNULL(SUM(c.entrust_amount), 0.0) entrustAmount, IFNULL(SUM(c.load_amount), 0.0) loadAmount,
+        IFNULL(SUM(c.unload_amount), 0.0) unloadAmount, IFNULL(SUM(c.deficit_amount), 0.0) deficitAmount,
+        MIN(wot1.operate_time) loadTime, MAX(wot2.operate_time) unloadTime
+        from kwt_waybill_order wo
+        left join kwt_waybill_order_subtask c on wo.id = c.w_order_id
+        left join kwt_waybill_order_ticket wot1 on wot1.w_order_id = wo.id and wot1.type = 1 and c.unit = wot1.unit and wot1.type = 1 and wot1.del_flag = 0
+        left join kwt_waybill_order_ticket wot2 on wot2.w_order_id = wo.id and wot2.type = 2 and c.unit = wot2.unit and wot1.type = 2  and wot2.del_flag = 0
+
+        left join kwt_logistics_order lo on lo.id = c.l_order_id
+        where c.del_flag = 0 and lo.del_flag = 0
+        <if test="driverId != null and driverId != ''">
+            and wo.driver_id = #{driverId, jdbcType=BIGINT}
+        </if>
+        <if test="truckId != null and truckId != ''">
+            and wo.truck_id = #{truckId, jdbcType=BIGINT}
+        </if>
+        <if test="passStatus != null and passStatus != ''">
+            and c.status = 8
+        </if>
+        <if test="loadCountStatus != null and loadCountStatus != ''">
+            and c.status in (5, 6, 7, 8, 12, 13)
+        </if>
+        <if test="unloadCountStatus != null and unloadCountStatus != ''">
+            and c.status in (7, 8, 12, 13)
+        </if>
+        <if test="tOrderId != null and tOrderId != ''">
+            and lo.t_order_id = #{tOrderId, jdbcType=BIGINT}
+        </if>
+        <if test="lOrderId != null and lOrderId != ''">
+            and lo.id = #{lOrderId, jdbcType=BIGINT}
+        </if>
+        <if test="logisticsStatus != null and logisticsStatus != ''">
+            and lo.status = #{logisticsStatus, jdbcType=INTEGER}
+        </if>
+        <if test="upperlOrderId != null and upperlOrderId != ''">
+            and FIND_IN_SET(#{upperlOrderId, jdbcType=BIGINT}, lo.pids)
+        </if>
+        <if test="belowlOrderId != null and belowlOrderId != ''">
+            and FIND_IN_SET(lo.id, #{belowlOrderId, jdbcType=VARCHAR})
+        </if>
+        <if test="ownOrderId != null and ownOrderId != ''">
+            and lo.id != #{ownOrderId, jdbcType=BIGINT}
+        </if>
+    </select>
+    <select id="selectDataByLorderId" resultType="java.lang.Integer">
+        SELECT COUNT(b.id)
+        FROM kwt_waybill_order_subtask k
+        left join kwt_waybill_order a on k.w_order_id = a.id and a.del_flag = 0 and k.del_flag = 0
+        LEFT JOIN kwt_logistics_order b ON k.l_order_id = b.id AND a.del_flag = 0 AND b.del_flag = 0
+        <where>
+            <if test="id != null and id !=''">
+                and b.id = #{id}
+            </if>
+            <if test="statusList != null and statusList.size() >0">
+                AND a.`status` IN
+                <foreach collection="statusList" item="item" open="(" close=")" separator=",">
+                    #{item}
+                </foreach>
+            </if>
+        </where>
+    </select>
 </mapper>