监管大屏统计
parent
6d3e1b631b
commit
f568e7551a
|
|
@ -43,4 +43,6 @@ public class StatisticsController {
|
|||
public R<?> obtainOrder(Long userId) {
|
||||
return R.success(statisticsService.obtainOrder(userId));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
package com.njzscloud.supervisory.statistics.controller;
|
||||
|
||||
import com.njzscloud.common.core.utils.R;
|
||||
import com.njzscloud.supervisory.statistics.service.SupervisionStatisticsService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/statistics/supervision")
|
||||
public class SupervisionStatisticsController {
|
||||
private final SupervisionStatisticsService supervisionStatisticsService;
|
||||
|
||||
|
||||
@GetMapping("/obtain_data")
|
||||
public R<?> obtainData() {
|
||||
long l = System.currentTimeMillis();
|
||||
Map<String, Object> data = supervisionStatisticsService.obtainData();
|
||||
System.out.println("耗时: " + (System.currentTimeMillis() - l));
|
||||
return R.success(data);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
package com.njzscloud.supervisory.statistics.mapper;
|
||||
|
||||
import com.njzscloud.supervisory.statistics.pojo.*;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface SupervisionStatisticsMapper {
|
||||
DispatchSummary getDispatchSummary();
|
||||
|
||||
YuYueSummary getYuYueSummary();
|
||||
|
||||
Integer getDisposeTotalWeight();
|
||||
|
||||
CarSummary getCarSummary();
|
||||
|
||||
Integer getTodayCarCount();
|
||||
|
||||
RegionSummary getRegionSummary();
|
||||
|
||||
List<CompanySummary> getCompanySummary();
|
||||
|
||||
List<StationInfo> getStationInfo();
|
||||
|
||||
List<Order> getOrders();
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.njzscloud.supervisory.statistics.pojo;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@Accessors(chain = true)
|
||||
public class CarSummary {
|
||||
private Integer yunShuZhong;
|
||||
private Integer carCount;
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.njzscloud.supervisory.statistics.pojo;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@Accessors(chain = true)
|
||||
public class CompanySummary {
|
||||
private String company;
|
||||
private Integer totalWeight;
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.njzscloud.supervisory.statistics.pojo;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@Accessors(chain = true)
|
||||
public class DispatchSummary {
|
||||
private Integer daiPaiChe;
|
||||
private Integer weiJieDan;
|
||||
private Integer yunShuZhong;
|
||||
private Integer yiWanCheng;
|
||||
}
|
||||
|
|
@ -0,0 +1,177 @@
|
|||
package com.njzscloud.supervisory.statistics.pojo;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@Accessors(chain = true)
|
||||
public class Order {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer id;
|
||||
|
||||
private String orderNo;
|
||||
|
||||
private Integer userId;
|
||||
|
||||
private String carNumber;
|
||||
|
||||
private Integer goodsCategoryId;
|
||||
|
||||
private Integer goodsId;
|
||||
|
||||
private Byte unit;
|
||||
|
||||
private Integer tare;
|
||||
|
||||
private Integer weightRough;
|
||||
|
||||
private Integer weight;
|
||||
|
||||
private Integer deduct;
|
||||
|
||||
private Integer priceUnit;
|
||||
|
||||
private Integer priceTotal;
|
||||
|
||||
private Integer priceFix;
|
||||
|
||||
private Integer priceDiscount;
|
||||
|
||||
private Integer price;
|
||||
|
||||
private Byte status;
|
||||
|
||||
private Byte carStatus;
|
||||
|
||||
private Long carUpdated;
|
||||
|
||||
private String carInFront;
|
||||
|
||||
private String carInBody;
|
||||
|
||||
private String carOutFront;
|
||||
|
||||
private String carOutBody;
|
||||
|
||||
private Integer feeOil;
|
||||
|
||||
private String remark;
|
||||
|
||||
private Byte feeType;
|
||||
|
||||
private Byte whoPay;
|
||||
|
||||
private Byte type;
|
||||
|
||||
private Integer vipUser;
|
||||
|
||||
private Long createTime;
|
||||
|
||||
private Long updateTime;
|
||||
|
||||
private String laneId;
|
||||
|
||||
private Byte adminStatus;
|
||||
|
||||
private Long adminTime;
|
||||
|
||||
private Long payTime;
|
||||
|
||||
private Integer amountRefund;
|
||||
|
||||
private Byte vipCheck;
|
||||
|
||||
private Byte payType;
|
||||
|
||||
private String mobile;
|
||||
|
||||
private Integer klUid;
|
||||
|
||||
private String klNote;
|
||||
|
||||
private Integer payAmount;
|
||||
|
||||
private Byte doType;
|
||||
|
||||
private Byte finish;
|
||||
|
||||
private Byte ownerPay;
|
||||
|
||||
private Long inTime;
|
||||
|
||||
private Long outTime;
|
||||
|
||||
private Integer suffixNo;
|
||||
|
||||
private Integer companyId;
|
||||
|
||||
private String noteBf;
|
||||
|
||||
private String noteCw;
|
||||
|
||||
private Integer amount;
|
||||
|
||||
private Integer fare;
|
||||
|
||||
private Integer fareUnit;
|
||||
|
||||
private Byte fareType;
|
||||
|
||||
private Integer stationId;
|
||||
|
||||
private Byte weightCheck;
|
||||
|
||||
private String goodsName;
|
||||
|
||||
private String companyName;
|
||||
|
||||
private Integer transferSid;
|
||||
|
||||
private Byte transferType;
|
||||
|
||||
private Integer qualityPrice;
|
||||
|
||||
private Integer elasticPrice;
|
||||
|
||||
private Byte useRole;
|
||||
|
||||
private Integer cube;
|
||||
|
||||
private Integer transferUid;
|
||||
|
||||
private Integer points;
|
||||
|
||||
private String tspPhotos;
|
||||
|
||||
private String zcPhotos;
|
||||
|
||||
private String address;
|
||||
|
||||
private BigDecimal lon;
|
||||
|
||||
private BigDecimal lat;
|
||||
|
||||
private BigDecimal km;
|
||||
|
||||
private Integer transportUid;
|
||||
|
||||
private Integer driverUid;
|
||||
|
||||
|
||||
private Long dispatchTime;
|
||||
|
||||
|
||||
private Long workTime;
|
||||
|
||||
private Integer projectId;
|
||||
|
||||
private Integer communityId;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.njzscloud.supervisory.statistics.pojo;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@Accessors(chain = true)
|
||||
public class RegionSummary {
|
||||
private String address;
|
||||
private Integer totalWeight;
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.njzscloud.supervisory.statistics.pojo;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@Accessors(chain = true)
|
||||
public class StationInfo {
|
||||
private String name;
|
||||
private Double longitude;
|
||||
private Double latitude;
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.njzscloud.supervisory.statistics.pojo;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@Accessors(chain = true)
|
||||
public class YuYueSummary {
|
||||
private Integer zuoTian;
|
||||
private Integer jinTian;
|
||||
private Double zengZhangLv;
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
package com.njzscloud.supervisory.statistics.service;
|
||||
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import com.njzscloud.supervisory.statistics.mapper.SupervisionStatisticsMapper;
|
||||
import com.njzscloud.supervisory.statistics.pojo.*;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SupervisionStatisticsService {
|
||||
private final SupervisionStatisticsMapper supervisionStatisticsMapper;
|
||||
|
||||
public Map<String, Object> obtainData() {
|
||||
|
||||
DispatchSummary dispatchSummary = supervisionStatisticsMapper.getDispatchSummary();
|
||||
|
||||
YuYueSummary yuYueSummary = supervisionStatisticsMapper.getYuYueSummary();
|
||||
|
||||
Integer disposeTotalWeight = supervisionStatisticsMapper.getDisposeTotalWeight();
|
||||
|
||||
CarSummary carSummary = supervisionStatisticsMapper.getCarSummary();
|
||||
Integer todayCarCount = supervisionStatisticsMapper.getTodayCarCount();
|
||||
RegionSummary regionSummary = supervisionStatisticsMapper.getRegionSummary();
|
||||
List<CompanySummary> companySummary = supervisionStatisticsMapper.getCompanySummary();
|
||||
List<StationInfo> stationInfo = supervisionStatisticsMapper.getStationInfo();
|
||||
List<Order> orders = supervisionStatisticsMapper.getOrders();
|
||||
|
||||
return MapUtil.<String, Object>builder()
|
||||
.put("dispatchSummary", dispatchSummary)
|
||||
.put("yuYueSummary", yuYueSummary)
|
||||
.put("disposeTotalWeight", disposeTotalWeight)
|
||||
.put("carSummary", carSummary)
|
||||
.put("todayCarCount", todayCarCount)
|
||||
.put("regionSummary", regionSummary)
|
||||
.put("companySummary", companySummary)
|
||||
.put("stationInfo", stationInfo)
|
||||
.put("orders", orders)
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,187 @@
|
|||
<?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.njzscloud.supervisory.statistics.mapper.SupervisionStatisticsMapper">
|
||||
<select id="getDispatchSummary" resultType="com.njzscloud.supervisory.statistics.pojo.DispatchSummary">
|
||||
SELECT MAX(IF(t = 0, c, 0)) dai_pai_che,
|
||||
MAX(IF(t = 1, c, 0)) wei_jie_dan,
|
||||
MAX(IF(t = 2, c, 0)) yun_shu_zhong,
|
||||
MAX(IF(t = 3, c, 0)) yi_wan_cheng
|
||||
FROM (SELECT COUNT(*) c, 0 t
|
||||
FROM ba_order
|
||||
WHERE type = 5
|
||||
AND finish = 0
|
||||
AND car_number = ''
|
||||
UNION ALL
|
||||
SELECT COUNT(*) c, 1 t
|
||||
FROM ba_order_dispatch
|
||||
WHERE status = 1
|
||||
UNION ALL
|
||||
SELECT COUNT(*) c, 2 t
|
||||
FROM ba_order_dispatch
|
||||
WHERE status = 2
|
||||
UNION ALL
|
||||
SELECT COUNT(*) c, 3 t
|
||||
FROM ba_order_dispatch
|
||||
WHERE status = 3) t
|
||||
</select>
|
||||
|
||||
<select id="getYuYueSummary" resultType="com.njzscloud.supervisory.statistics.pojo.YuYueSummary">
|
||||
SELECT zuo_tian,
|
||||
jin_tian,
|
||||
IF(zuo_tian = 0, IF(jin_tian = 0, 0, 100),
|
||||
ROUND((jin_tian - zuo_tian / zuo_tian) * 100, 2)) zeng_zhang_lv
|
||||
FROM (SELECT MAX(IF(t = 1, c, 0)) zuo_tian,
|
||||
MAX(IF(t = 2, c, 0)) jin_tian
|
||||
FROM (SELECT COUNT(*) c, 1 t
|
||||
FROM ba_order a
|
||||
INNER JOIN ba_order_dispatch b ON b.order_no = a.order_no
|
||||
WHERE a.create_time >= UNIX_TIMESTAMP(CURDATE())
|
||||
AND a.create_time <![CDATA[ < ]]> UNIX_TIMESTAMP(DATE_ADD(CURDATE(), INTERVAL -24 HOUR))
|
||||
UNION ALL
|
||||
SELECT COUNT(*) c, 2 t
|
||||
FROM ba_order a
|
||||
INNER JOIN ba_order_dispatch b ON b.order_no = a.order_no
|
||||
WHERE a.create_time >= UNIX_TIMESTAMP(CURDATE())
|
||||
AND a.create_time <![CDATA[ < ]]> UNIX_TIMESTAMP(DATE_ADD(CURDATE(), INTERVAL 24 HOUR))) t) tt
|
||||
</select>
|
||||
|
||||
<select id="getDisposeTotalWeight" resultType="java.lang.Integer">
|
||||
SELECT SUM(weight) total_weight
|
||||
FROM ba_order a
|
||||
INNER JOIN ba_order_dispatch b ON b.order_no = a.order_no
|
||||
WHERE a.status = 1
|
||||
</select>
|
||||
|
||||
<select id="getCarSummary" resultType="com.njzscloud.supervisory.statistics.pojo.CarSummary">
|
||||
SELECT MAX(IF(t = 1, c, 0)) yun_shu_zhong,
|
||||
MAX(IF(t = 2, c, 0)) car_count
|
||||
FROM (SELECT COUNT(*) c, 1 t
|
||||
FROM ba_order_dispatch
|
||||
WHERE status = 2
|
||||
UNION ALL
|
||||
SELECT COUNT(*) c, 2 t
|
||||
FROM ba_car) t
|
||||
</select>
|
||||
|
||||
<select id="getTodayCarCount" resultType="java.lang.Integer">
|
||||
SELECT COUNT(*) car_count
|
||||
FROM ba_order a
|
||||
INNER JOIN ba_order_dispatch b ON b.order_no = a.order_no
|
||||
WHERE a.create_time >= UNIX_TIMESTAMP(CURDATE())
|
||||
AND a.create_time <![CDATA[ < ]]> UNIX_TIMESTAMP(DATE_ADD(CURDATE(), INTERVAL 24 HOUR))
|
||||
AND a.status = 1
|
||||
</select>
|
||||
|
||||
<select id="getRegionSummary" resultType="com.njzscloud.supervisory.statistics.pojo.RegionSummary">
|
||||
SELECT a.address,
|
||||
SUM(a.weight) total_weight
|
||||
FROM ba_order a
|
||||
INNER JOIN ba_order_dispatch b ON b.order_no = a.order_no
|
||||
WHERE a.status = 1
|
||||
GROUP BY a.address
|
||||
</select>
|
||||
|
||||
<select id="getCompanySummary" resultType="com.njzscloud.supervisory.statistics.pojo.CompanySummary">
|
||||
SELECT t1.total_weight, t2.company
|
||||
FROM (SELECT SUM(a.weight) total_weight, b.transport_uid
|
||||
FROM ba_order a
|
||||
INNER JOIN ba_order_dispatch b ON b.order_no = a.order_no
|
||||
WHERE a.status = 1
|
||||
GROUP BY b.transport_uid) t1
|
||||
INNER JOIN ba_user t2 ON t2.group_id = 2 AND t2.id = t1.transport_uid
|
||||
ORDER BY t1.total_weight DESC
|
||||
LIMIT 5
|
||||
</select>
|
||||
|
||||
<select id="getStationInfo" resultType="com.njzscloud.supervisory.statistics.pojo.StationInfo">
|
||||
SELECT name, longitude, latitude
|
||||
FROM ba_station
|
||||
</select>
|
||||
|
||||
<select id="getOrders" resultType="com.njzscloud.supervisory.statistics.pojo.Order">
|
||||
SELECT a.order_no,
|
||||
a.user_id,
|
||||
a.car_number,
|
||||
a.goods_category_id,
|
||||
a.goods_id,
|
||||
a.unit,
|
||||
a.tare,
|
||||
a.weight_rough,
|
||||
a.weight,
|
||||
a.deduct,
|
||||
a.price_unit,
|
||||
a.price_total,
|
||||
a.price_fix,
|
||||
a.price_discount,
|
||||
a.price,
|
||||
a.status,
|
||||
a.car_status,
|
||||
a.car_updated,
|
||||
a.car_in_front,
|
||||
a.car_in_body,
|
||||
a.car_out_front,
|
||||
a.car_out_body,
|
||||
a.fee_oil,
|
||||
a.remark,
|
||||
a.fee_type,
|
||||
a.who_pay,
|
||||
a.type,
|
||||
a.vip_user,
|
||||
a.create_time,
|
||||
a.update_time,
|
||||
a.lane_id,
|
||||
a.admin_status,
|
||||
a.admin_time,
|
||||
a.pay_time,
|
||||
a.amount_refund,
|
||||
a.vip_check,
|
||||
a.pay_type,
|
||||
a.mobile,
|
||||
a.kl_uid,
|
||||
a.kl_note,
|
||||
a.pay_amount,
|
||||
a.do_type,
|
||||
a.finish,
|
||||
a.owner_pay,
|
||||
a.in_time,
|
||||
a.out_time,
|
||||
a.suffix_no,
|
||||
a.company_id,
|
||||
a.note_bf,
|
||||
a.note_cw,
|
||||
a.amount,
|
||||
a.fare,
|
||||
a.fare_unit,
|
||||
a.fare_type,
|
||||
a.station_id,
|
||||
a.weight_check,
|
||||
a.goods_name,
|
||||
a.company_name,
|
||||
a.transfer_sid,
|
||||
a.transfer_type,
|
||||
a.quality_price,
|
||||
a.elastic_price,
|
||||
a.use_role,
|
||||
a.`cube`,
|
||||
a.transfer_uid,
|
||||
a.points,
|
||||
a.tsp_photos,
|
||||
a.zc_photos,
|
||||
|
||||
b.address,
|
||||
b.lon,
|
||||
b.lat,
|
||||
b.km,
|
||||
b.transport_uid,
|
||||
b.driver_uid,
|
||||
b.dispatch_time,
|
||||
b.fare,
|
||||
b.work_time,
|
||||
b.project_id,
|
||||
b.community_id
|
||||
FROM ba_order a
|
||||
INNER JOIN ba_order_dispatch b ON b.order_no = a.order_no
|
||||
WHERE b.status = 2
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue