package com.ruoyi.wrzs.report.mapper;
|
|
import com.ruoyi.wrzs.report.pojo.vo.CarrierPerformanceVo;
|
import com.ruoyi.wrzs.report.pojo.vo.DailyWeighbridgeVo;
|
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Select;
|
|
import java.time.LocalDateTime;
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* 报表中心统计查询
|
*/
|
@Mapper
|
public interface ReportCenterMapper {
|
|
/** 每日过磅统计(自动称重记录) */
|
@Select("select date_format(first_weight_time, '%Y-%m-%d') as statDate, "
|
+ "count(*) as tripCount, "
|
+ "ifnull(sum(net_weight), 0) / 1000 as cargoVolume, "
|
+ "ifnull(avg(order_deviation), 0) as deviationRate, "
|
+ "sum(case when cheat_flag = '1' then 1 else 0 end) as cheatCount "
|
+ "from wrzs_weighbridge_record "
|
+ "where weigh_status = '2' and first_weight_time between #{start} and #{end} "
|
+ "group by date_format(first_weight_time, '%Y-%m-%d') order by statDate")
|
List<DailyWeighbridgeVo> dailyStat(@Param("start") LocalDateTime start, @Param("end") LocalDateTime end);
|
|
/** 每日过磅统计(历史手工过磅记录,兜底) */
|
@Select("select date_format(weight_time, '%Y-%m-%d') as statDate, "
|
+ "count(*) as tripCount, "
|
+ "ifnull(sum(gross_weight), 0) / 1000 as cargoVolume, "
|
+ "ifnull(avg(position_offset), 0) as deviationRate, "
|
+ "0 as cheatCount "
|
+ "from unattended_operation "
|
+ "where weight_time between #{start} and #{end} "
|
+ "group by date_format(weight_time, '%Y-%m-%d') order by statDate")
|
List<DailyWeighbridgeVo> dailyStatLegacy(@Param("start") LocalDateTime start, @Param("end") LocalDateTime end);
|
|
/** 承运商绩效统计 */
|
@Select("select carrier_name as carrierName, "
|
+ "count(*) as totalTrips, "
|
+ "sum(case when appointment_time is not null and first_weight_time <= appointment_time then 1 else 0 end) as onTimeTrips, "
|
+ "sum(case when appointment_time is not null and first_weight_time > appointment_time then 1 else 0 end) as lateTrips, "
|
+ "sum(case when cheat_flag = '1' then 1 else 0 end) as cheatCount, "
|
+ "ifnull(avg(order_deviation), 0) as avgDeviation, "
|
+ "ifnull(sum(net_weight), 0) / 1000 as totalNetWeight "
|
+ "from wrzs_weighbridge_record "
|
+ "where weigh_status = '2' and first_weight_time between #{start} and #{end} "
|
+ "and carrier_name is not null and carrier_name <> '' "
|
+ "group by carrier_name order by totalTrips desc")
|
List<CarrierPerformanceVo> carrierPerformance(@Param("start") LocalDateTime start, @Param("end") LocalDateTime end);
|
|
/** 区间总览 */
|
@Select("select count(*) as totalTrips, "
|
+ "ifnull(sum(net_weight), 0) / 1000 as totalNetWeight, "
|
+ "ifnull(avg(order_deviation), 0) as avgDeviation, "
|
+ "sum(case when cheat_flag = '1' then 1 else 0 end) as cheatCount, "
|
+ "sum(case when appointment_time is not null and first_weight_time <= appointment_time then 1 else 0 end) as onTimeTrips, "
|
+ "sum(case when appointment_time is not null then 1 else 0 end) as appointmentTrips, "
|
+ "sum(case when erp_sync_status = '1' then 1 else 0 end) as erpSyncedCount "
|
+ "from wrzs_weighbridge_record "
|
+ "where weigh_status = '2' and first_weight_time between #{start} and #{end}")
|
Map<String, Object> overview(@Param("start") LocalDateTime start, @Param("end") LocalDateTime end);
|
}
|