From 855d5898c4721d45ac69258a34ff4f3b8e474a16 Mon Sep 17 00:00:00 2001 From: lau572 <1010031226@qq.com> Date: Mon, 17 Feb 2025 11:29:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=80=E7=B1=BB=E4=BA=A4=E8=B0=83=201.?= =?UTF-8?q?=E8=BD=A6=E5=9E=8B=E5=8C=BA=E5=88=86=E5=A4=A7=E5=B0=8F=E7=B1=BB?= =?UTF-8?q?=202.=E6=97=B6=E9=97=B4=E8=8C=83=E5=9B=B4=E7=AD=9B=E9=80=89=203?= =?UTF-8?q?.=E5=8F=8C=E5=90=91=E5=90=88=E8=AE=A1=204.=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=8A=98=E7=AE=97=E5=B9=B3=E5=9D=87=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DcTrafficSurveyDataController.java | 15 +- .../domain/DcTrafficSpeedCarTypeData.java | 104 +++++++++ .../DcTrafficSpeedDirectionCarTypeData.java | 143 ++++++++++++ .../business/domain/DcTrafficSurveyData.java | 12 ++ .../DcTrafficSurveyDataQueryParams.java | 35 +++ .../domain/DcTrafficVolumeCarTypeData.java | 104 +++++++++ .../DcTrafficVolumeDirectionCarTypeData.java | 156 ++++++++++++++ .../mapper/DcTrafficSurveyDataMapper.java | 1 + .../impl/DcTrafficSurveyDataServiceImpl.java | 204 +++++++++++++++++- .../business/DcTrafficSurveyDataMapper.xml | 20 ++ 10 files changed, 785 insertions(+), 9 deletions(-) create mode 100644 zc-business/src/main/java/com/zc/business/domain/DcTrafficSpeedCarTypeData.java create mode 100644 zc-business/src/main/java/com/zc/business/domain/DcTrafficSpeedDirectionCarTypeData.java create mode 100644 zc-business/src/main/java/com/zc/business/domain/DcTrafficVolumeCarTypeData.java create mode 100644 zc-business/src/main/java/com/zc/business/domain/DcTrafficVolumeDirectionCarTypeData.java diff --git a/zc-business/src/main/java/com/zc/business/controller/DcTrafficSurveyDataController.java b/zc-business/src/main/java/com/zc/business/controller/DcTrafficSurveyDataController.java index 21b9c4b2..df7541e3 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcTrafficSurveyDataController.java +++ b/zc-business/src/main/java/com/zc/business/controller/DcTrafficSurveyDataController.java @@ -406,7 +406,16 @@ public class DcTrafficSurveyDataController extends BaseController cell.setCellValue("一类交调站"+rowList.get(j).get("stakeMark").toString()); cell.setCellStyle(dataStyle); cell = subHeaderRow.createCell(UniversalEnum.ONE.getNumber()); - cell.setCellValue(rowList.get(j).get("direction").toString().equals("1") ? "济南方向" : "菏泽方向"); + String direction = rowList.get(j).get("direction").toString(); + String directionStr = "济南方向"; + if (direction.equals("1")){ + directionStr = "济南方向"; + } else if (direction.equals("2")){ + directionStr = "合计"; + } else if (direction.equals("3")){ + directionStr = "菏泽方向"; + } + cell.setCellValue(directionStr); cell.setCellStyle(dataStyle); int k = 0; for (k = 0; k < columnList.size(); k++) { @@ -470,7 +479,7 @@ public class DcTrafficSurveyDataController extends BaseController } /** - * 综合查询 + * 站点查询 */ @PostMapping("/selectComprehensiveData") public AjaxResult selectComprehensiveData(@RequestBody DcTrafficSurveyDataQueryParams dcTrafficSurveyDataQueryParams){ @@ -478,7 +487,7 @@ public class DcTrafficSurveyDataController extends BaseController } /** - * 导出综合查询 + * 导出站点查询 */ @PostMapping("/exportComprehensiveData") public void exportComprehensiveData(HttpServletResponse response,@RequestBody DcTrafficSurveyDataQueryParams dcTrafficSurveyDataQueryParams) diff --git a/zc-business/src/main/java/com/zc/business/domain/DcTrafficSpeedCarTypeData.java b/zc-business/src/main/java/com/zc/business/domain/DcTrafficSpeedCarTypeData.java new file mode 100644 index 00000000..21e4eee5 --- /dev/null +++ b/zc-business/src/main/java/com/zc/business/domain/DcTrafficSpeedCarTypeData.java @@ -0,0 +1,104 @@ +package com.zc.business.domain; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 一类交调数据对象 dc_traffic_survey_data + * + * @author liuwenge + * @date 2024-10-29 + */ +public class DcTrafficSpeedCarTypeData extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + private Long id; + + /** 物联设备主键 */ + private String iotDeviceId; + + /** 方向1-上行,2-中,3-下行 */ + private String direction; + + /** 时间 */ + @Excel(name = "时间") + private String time; + + /** 客车平均地点车速 */ + @Excel(name = "客车") + private Integer busVehicleSpeed; + + /** 货车平均地点车速 */ + @Excel(name = "货车") + private Integer goodsCarVehicleSpeed; + + /** 平均地点车速 */ + @Excel(name = "平均车速") + private Integer avgSpeed; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getIotDeviceId() { + return iotDeviceId; + } + + public void setIotDeviceId(String iotDeviceId) { + this.iotDeviceId = iotDeviceId; + } + + public String getDirection() { + return direction; + } + + public void setDirection(String direction) { + this.direction = direction; + } + + public String getTime() { + return time; + } + + public void setTime(String time) { + this.time = time; + } + + public Integer getBusVehicleSpeed() { + return busVehicleSpeed; + } + + public void setBusVehicleSpeed(Integer busVehicleSpeed) { + this.busVehicleSpeed = busVehicleSpeed; + } + + public Integer getGoodsCarVehicleSpeed() { + return goodsCarVehicleSpeed; + } + + public void setGoodsCarVehicleSpeed(Integer goodsCarVehicleSpeed) { + this.goodsCarVehicleSpeed = goodsCarVehicleSpeed; + } + + public Integer getAvgSpeed() { + return avgSpeed; + } + + public void setAvgSpeed(Integer avgSpeed) { + this.avgSpeed = avgSpeed; + } + + public DcTrafficSpeedCarTypeData(){} + + public DcTrafficSpeedCarTypeData(Integer initData){ + this.busVehicleSpeed = initData; + this.goodsCarVehicleSpeed = initData; + this.avgSpeed = initData; + } +} diff --git a/zc-business/src/main/java/com/zc/business/domain/DcTrafficSpeedDirectionCarTypeData.java b/zc-business/src/main/java/com/zc/business/domain/DcTrafficSpeedDirectionCarTypeData.java new file mode 100644 index 00000000..519d6d1a --- /dev/null +++ b/zc-business/src/main/java/com/zc/business/domain/DcTrafficSpeedDirectionCarTypeData.java @@ -0,0 +1,143 @@ +package com.zc.business.domain; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 一类交调数据对象(分方向) dc_traffic_survey_data + * + * @author liuwenge + * @date 2024-10-29 + */ +public class DcTrafficSpeedDirectionCarTypeData extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + private Long id; + + /** 物联设备主键 */ + private String iotDeviceId; + + /** 方向1-上行,2-中,3-下行 */ + private String direction; + + /** 时间 */ + @Excel(name = "时间") + private String time; + + /** 客车平均地点车速 */ + @Excel(name = "客车-菏泽") + private Integer busVehicleSpeedHZ; + + /** 客车平均地点车速 */ + @Excel(name = "客车-济南") + private Integer busVehicleSpeedJN; + + /** 货车平均地点车速 */ + @Excel(name = "货车-菏泽") + private Integer goodsCarVehicleSpeedHZ; + + /** 货车平均地点车速 */ + @Excel(name = "货车-济南") + private Integer goodsCarVehicleSpeedJN; + + /** 平均地点车速 */ + @Excel(name = "平均车速-菏泽") + private Integer avgSpeedHZ; + + /** 平均地点车速 */ + @Excel(name = "平均车速-济南") + private Integer avgSpeedJN; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getIotDeviceId() { + return iotDeviceId; + } + + public void setIotDeviceId(String iotDeviceId) { + this.iotDeviceId = iotDeviceId; + } + + public String getDirection() { + return direction; + } + + public void setDirection(String direction) { + this.direction = direction; + } + + public String getTime() { + return time; + } + + public void setTime(String time) { + this.time = time; + } + + public Integer getBusVehicleSpeedHZ() { + return busVehicleSpeedHZ; + } + + public void setBusVehicleSpeedHZ(Integer busVehicleSpeedHZ) { + this.busVehicleSpeedHZ = busVehicleSpeedHZ; + } + + public Integer getBusVehicleSpeedJN() { + return busVehicleSpeedJN; + } + + public void setBusVehicleSpeedJN(Integer busVehicleSpeedJN) { + this.busVehicleSpeedJN = busVehicleSpeedJN; + } + + public Integer getGoodsCarVehicleSpeedHZ() { + return goodsCarVehicleSpeedHZ; + } + + public void setGoodsCarVehicleSpeedHZ(Integer goodsCarVehicleSpeedHZ) { + this.goodsCarVehicleSpeedHZ = goodsCarVehicleSpeedHZ; + } + + public Integer getGoodsCarVehicleSpeedJN() { + return goodsCarVehicleSpeedJN; + } + + public void setGoodsCarVehicleSpeedJN(Integer goodsCarVehicleSpeedJN) { + this.goodsCarVehicleSpeedJN = goodsCarVehicleSpeedJN; + } + + public Integer getAvgSpeedHZ() { + return avgSpeedHZ; + } + + public void setAvgSpeedHZ(Integer avgSpeedHZ) { + this.avgSpeedHZ = avgSpeedHZ; + } + + public Integer getAvgSpeedJN() { + return avgSpeedJN; + } + + public void setAvgSpeedJN(Integer avgSpeedJN) { + this.avgSpeedJN = avgSpeedJN; + } + + public DcTrafficSpeedDirectionCarTypeData(){} + + public DcTrafficSpeedDirectionCarTypeData(Integer initData){ + this.busVehicleSpeedHZ = initData; + this.busVehicleSpeedJN = initData; + this.goodsCarVehicleSpeedHZ = initData; + this.goodsCarVehicleSpeedJN = initData; + this.avgSpeedHZ = initData; + this.avgSpeedJN = initData; + } +} diff --git a/zc-business/src/main/java/com/zc/business/domain/DcTrafficSurveyData.java b/zc-business/src/main/java/com/zc/business/domain/DcTrafficSurveyData.java index 5a17f849..3340aff8 100644 --- a/zc-business/src/main/java/com/zc/business/domain/DcTrafficSurveyData.java +++ b/zc-business/src/main/java/com/zc/business/domain/DcTrafficSurveyData.java @@ -37,6 +37,10 @@ public class DcTrafficSurveyData extends BaseEntity @Excel(name = "采集时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") private Date timestamp; + /** 范围查询-结束时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date endTime; + /** 车流量 */ @Excel(name = "车流量") private Long trafficVolume; @@ -357,6 +361,14 @@ public class DcTrafficSurveyData extends BaseEntity this.avgSpeed = avgSpeed; } + public Date getEndTime() { + return endTime; + } + + public void setEndTime(Date endTime) { + this.endTime = endTime; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/zc-business/src/main/java/com/zc/business/domain/DcTrafficSurveyDataQueryParams.java b/zc-business/src/main/java/com/zc/business/domain/DcTrafficSurveyDataQueryParams.java index a079d000..48b1a3e7 100644 --- a/zc-business/src/main/java/com/zc/business/domain/DcTrafficSurveyDataQueryParams.java +++ b/zc-business/src/main/java/com/zc/business/domain/DcTrafficSurveyDataQueryParams.java @@ -28,12 +28,23 @@ public class DcTrafficSurveyDataQueryParams extends BaseEntity @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date date; + /** 开始时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date startTime; + + /** 结束时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date endTime; + /** 类型 (1:日, 2:月, 3:年) */ private String type; /** 数据类型 (1:流量, 2:车速) */ private String dataType; + /** 车型 (1:小类, 2:大类) */ + private String carType; + public String getIotDeviceId() { return iotDeviceId; } @@ -73,4 +84,28 @@ public class DcTrafficSurveyDataQueryParams extends BaseEntity public void setDataType(String dataType) { this.dataType = dataType; } + + public Date getStartTime() { + return startTime; + } + + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + + public Date getEndTime() { + return endTime; + } + + public void setEndTime(Date endTime) { + this.endTime = endTime; + } + + public String getCarType() { + return carType; + } + + public void setCarType(String carType) { + this.carType = carType; + } } diff --git a/zc-business/src/main/java/com/zc/business/domain/DcTrafficVolumeCarTypeData.java b/zc-business/src/main/java/com/zc/business/domain/DcTrafficVolumeCarTypeData.java new file mode 100644 index 00000000..5d913c72 --- /dev/null +++ b/zc-business/src/main/java/com/zc/business/domain/DcTrafficVolumeCarTypeData.java @@ -0,0 +1,104 @@ +package com.zc.business.domain; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 一类交调数据对象 dc_traffic_survey_data + * + * @author liuwenge + * @date 2024-10-29 + */ +public class DcTrafficVolumeCarTypeData extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + private Long id; + + /** 物联设备主键 */ + private String iotDeviceId; + + /** 方向 */ + private String direction; + + /** 时间 */ + @Excel(name = "时间") + private String time; + + /** 客车 */ + @Excel(name = "客车") + private Integer bus; + + /** 货车交通量 */ + @Excel(name = "货车") + private Integer goodsCar; + + /** 合计 */ + @Excel(name = "合计") + private Integer trafficVolume; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getIotDeviceId() { + return iotDeviceId; + } + + public void setIotDeviceId(String iotDeviceId) { + this.iotDeviceId = iotDeviceId; + } + + public String getDirection() { + return direction; + } + + public void setDirection(String direction) { + this.direction = direction; + } + + public String getTime() { + return time; + } + + public void setTime(String time) { + this.time = time; + } + + public Integer getBus() { + return bus; + } + + public void setBus(Integer bus) { + this.bus = bus; + } + + public Integer getGoodsCar() { + return goodsCar; + } + + public void setGoodsCar(Integer goodsCar) { + this.goodsCar = goodsCar; + } + + public Integer getTrafficVolume() { + return trafficVolume; + } + + public void setTrafficVolume(Integer trafficVolume) { + this.trafficVolume = trafficVolume; + } + + public DcTrafficVolumeCarTypeData(){} + + public DcTrafficVolumeCarTypeData(Integer initData){ + this.bus = initData; + this.goodsCar = initData; + this.trafficVolume = initData; + } +} diff --git a/zc-business/src/main/java/com/zc/business/domain/DcTrafficVolumeDirectionCarTypeData.java b/zc-business/src/main/java/com/zc/business/domain/DcTrafficVolumeDirectionCarTypeData.java new file mode 100644 index 00000000..bae3eb25 --- /dev/null +++ b/zc-business/src/main/java/com/zc/business/domain/DcTrafficVolumeDirectionCarTypeData.java @@ -0,0 +1,156 @@ +package com.zc.business.domain; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 一类交调数据对象(区分方向) dc_traffic_survey_data + * + * @author liuwenge + * @date 2024-10-29 + */ +public class DcTrafficVolumeDirectionCarTypeData extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + private Long id; + + /** 物联设备主键 */ + private String iotDeviceId; + + /** 方向 */ + private String direction; + + /** 时间 */ + @Excel(name = "时间") + private String time; + + /** 菏泽客车交通量 */ + @Excel(name = "客车-菏泽") + private Integer busHZ; + + /** 济南客车交通量 */ + @Excel(name = "客车-济南") + private Integer busJN; + + /** 菏泽货车交通量 */ + @Excel(name = "小型货车-菏泽") + private Integer goodsCarHZ; + + /** 济南货车交通量 */ + @Excel(name = "小型货车-济南") + private Integer goodsCarJN; + + /** 合计 */ + @Excel(name = "合计-菏泽") + private Integer trafficVolumeHZ; + + /** 合计 */ + @Excel(name = "合计-济南") + private Integer trafficVolumeJN; + + /** 总计车流量 */ + @Excel(name = "总计车流量") + private Integer allTrafficVolume; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getIotDeviceId() { + return iotDeviceId; + } + + public void setIotDeviceId(String iotDeviceId) { + this.iotDeviceId = iotDeviceId; + } + + public String getDirection() { + return direction; + } + + public void setDirection(String direction) { + this.direction = direction; + } + + public String getTime() { + return time; + } + + public void setTime(String time) { + this.time = time; + } + + public Integer getBusHZ() { + return busHZ; + } + + public void setBusHZ(Integer busHZ) { + this.busHZ = busHZ; + } + + public Integer getBusJN() { + return busJN; + } + + public void setBusJN(Integer busJN) { + this.busJN = busJN; + } + + public Integer getGoodsCarHZ() { + return goodsCarHZ; + } + + public void setGoodsCarHZ(Integer goodsCarHZ) { + this.goodsCarHZ = goodsCarHZ; + } + + public Integer getGoodsCarJN() { + return goodsCarJN; + } + + public void setGoodsCarJN(Integer goodsCarJN) { + this.goodsCarJN = goodsCarJN; + } + + public Integer getTrafficVolumeHZ() { + return trafficVolumeHZ; + } + + public void setTrafficVolumeHZ(Integer trafficVolumeHZ) { + this.trafficVolumeHZ = trafficVolumeHZ; + } + + public Integer getTrafficVolumeJN() { + return trafficVolumeJN; + } + + public void setTrafficVolumeJN(Integer trafficVolumeJN) { + this.trafficVolumeJN = trafficVolumeJN; + } + + public Integer getAllTrafficVolume() { + return allTrafficVolume; + } + + public void setAllTrafficVolume(Integer allTrafficVolume) { + this.allTrafficVolume = allTrafficVolume; + } + + public DcTrafficVolumeDirectionCarTypeData(){} + + public DcTrafficVolumeDirectionCarTypeData(Integer initData){ + this.busJN = initData; + this.busHZ = initData; + this.goodsCarJN = initData; + this.goodsCarHZ = initData; + this.trafficVolumeJN = initData; + this.trafficVolumeHZ = initData; + this.allTrafficVolume = initData; + } +} diff --git a/zc-business/src/main/java/com/zc/business/mapper/DcTrafficSurveyDataMapper.java b/zc-business/src/main/java/com/zc/business/mapper/DcTrafficSurveyDataMapper.java index e89300ca..afe12783 100644 --- a/zc-business/src/main/java/com/zc/business/mapper/DcTrafficSurveyDataMapper.java +++ b/zc-business/src/main/java/com/zc/business/mapper/DcTrafficSurveyDataMapper.java @@ -32,6 +32,7 @@ public interface DcTrafficSurveyDataMapper List selectDay(DcTrafficSurveyData dcTrafficSurveyData); List selectMonth(DcTrafficSurveyData dcTrafficSurveyData); List selectYear(DcTrafficSurveyData dcTrafficSurveyData); + List selectRange(DcTrafficSurveyData dcTrafficSurveyData); /** * 新增一类交调数据 diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcTrafficSurveyDataServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcTrafficSurveyDataServiceImpl.java index db8d9bc1..3dec7a95 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcTrafficSurveyDataServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcTrafficSurveyDataServiceImpl.java @@ -64,6 +64,8 @@ public class DcTrafficSurveyDataServiceImpl implements IDcTrafficSurveyDataServi dataList = dcTrafficSurveyDataMapper.selectMonth(dcTrafficSurveyData); } else if (dcTrafficSurveyData.getType().equals("year")){ dataList = dcTrafficSurveyDataMapper.selectYear(dcTrafficSurveyData); + } else if (dcTrafficSurveyData.getType().equals("range")){ + dataList = dcTrafficSurveyDataMapper.selectRange(dcTrafficSurveyData); } Map>>> groupedData = dataList.stream() .collect(Collectors.groupingBy( @@ -83,6 +85,15 @@ public class DcTrafficSurveyDataServiceImpl implements IDcTrafficSurveyDataServi row.put("stakeMark",dcDevice.getStakeMark()); row.put("direction","1"); + //单个设备合计数据 + Map totalRow = new HashMap<>(); + totalRow.put("stakeMark",dcDevice.getStakeMark()); + totalRow.put("direction","2"); + for (Map columnMap : columnList) { + totalRow.put(columnMap.get("key"),0); + totalRow.put("total",0); + } + if (directionData.containsKey("1")){ Integer total = 0; //单个设备济南方向分时数据 @@ -91,12 +102,14 @@ public class DcTrafficSurveyDataServiceImpl implements IDcTrafficSurveyDataServi if (directionList.containsKey(columnMap.get("key"))){ List timeList = directionList.get(columnMap.get("key")); row.put(columnMap.get("key"),timeList.get(0).getTrafficVolume()); + totalRow.put(columnMap.get("key"),timeList.get(0).getTrafficVolume()); total += timeList.get(0).getTrafficVolume().intValue(); } else { row.put(columnMap.get("key"),0); } } row.put("total",total); + totalRow.put("total",total); } else { for (Map columnMap : columnList) { row.put(columnMap.get("key"),0); @@ -117,12 +130,15 @@ public class DcTrafficSurveyDataServiceImpl implements IDcTrafficSurveyDataServi if (directionList.containsKey(columnMap.get("key"))){ List timeList = directionList.get(columnMap.get("key")); row.put(columnMap.get("key"),timeList.get(0).getTrafficVolume()); + Long totalRowData = Long.parseLong(totalRow.get(columnMap.get("key")).toString()); + totalRow.put(columnMap.get("key"),totalRowData + timeList.get(0).getTrafficVolume()); total += timeList.get(0).getTrafficVolume().intValue(); } else { row.put(columnMap.get("key"),0); } } row.put("total",total); + totalRow.put("total",Integer.parseInt(totalRow.get("total").toString()) + total); } else { for (Map columnMap : columnList) { row.put(columnMap.get("key"),0); @@ -130,6 +146,8 @@ public class DcTrafficSurveyDataServiceImpl implements IDcTrafficSurveyDataServi } } rowList.add(row); + + rowList.add(totalRow); } else { row = new HashMap<>(); row.put("stakeMark",dcDevice.getStakeMark()); @@ -148,6 +166,16 @@ public class DcTrafficSurveyDataServiceImpl implements IDcTrafficSurveyDataServi } row.put("total",0); rowList.add(row); + + //单个设备合计数据 + row = new HashMap<>(); + row.put("stakeMark",dcDevice.getStakeMark()); + row.put("direction","2"); + for (Map columnMap : columnList) { + row.put(columnMap.get("key"),0); + } + row.put("total",0); + rowList.add(row); } } Map result = new HashMap<>(); @@ -184,6 +212,23 @@ public class DcTrafficSurveyDataServiceImpl implements IDcTrafficSurveyDataServi column.put("key",String.valueOf(i)); columnList.add(column); } + } else if (dcTrafficSurveyData.getType().equals("range")){ + Calendar startCal = Calendar.getInstance(); + startCal.setTime(dcTrafficSurveyData.getTimestamp()); + Calendar endCal = Calendar.getInstance(); + endCal.setTime(dcTrafficSurveyData.getEndTime()); + + SimpleDateFormat sf = new SimpleDateFormat("MM-dd"); + while (startCal.before(endCal) || startCal.equals(endCal)) { + column = new HashMap<>(); + Date currentDate = startCal.getTime(); + + column.put("label",sf.format(currentDate)); + column.put("key",sf.format(currentDate)); + columnList.add(column); + + startCal.add(Calendar.DATE, 1); + } } return columnList; } @@ -258,7 +303,7 @@ public class DcTrafficSurveyDataServiceImpl implements IDcTrafficSurveyDataServi } /** - * 综合查询 + * 站点查询 * * @param dcTrafficSurveyDataQueryParams * @return 结果 @@ -268,8 +313,6 @@ public class DcTrafficSurveyDataServiceImpl implements IDcTrafficSurveyDataServi if (StringUtils.isEmpty(dcTrafficSurveyDataQueryParams.getIotDeviceId())){ return AjaxResult.error("请选择设备"); - } else if (dcTrafficSurveyDataQueryParams.getDate() == null){ - return AjaxResult.error("请选择查询时间"); } else if (StringUtils.isEmpty(dcTrafficSurveyDataQueryParams.getType())){ return AjaxResult.error("请选择时间类型"); } else if (StringUtils.isEmpty(dcTrafficSurveyDataQueryParams.getDataType())){ @@ -421,11 +464,75 @@ public class DcTrafficSurveyDataServiceImpl implements IDcTrafficSurveyDataServi naturalAvg.setTrafficVolumeJN(naturalAvgTrafficVolumeJN); naturalAvg.setAllTrafficVolume(naturalAvgTrafficVolumeHZ + naturalAvgTrafficVolumeJN); + //折算平均值 + DcTrafficVolumeDirectionData conversionAvg = new DcTrafficVolumeDirectionData(0); + conversionAvg.setTime("折算平均值"); + conversionAvg.setTrafficNumberOfInAndSmallHZ(conversionValue.getTrafficNumberOfInAndSmallHZ() / result.size()); + conversionAvg.setTrafficNumberOfInAndSmallJN(conversionValue.getTrafficNumberOfInAndSmallJN() / result.size()); + conversionAvg.setBusTrafficVolumeHZ(conversionValue.getBusTrafficVolumeHZ() / result.size()); + conversionAvg.setBusTrafficVolumeJN(conversionValue.getBusTrafficVolumeJN() / result.size()); + conversionAvg.setTrafficVolumeOfSmallTrucksHZ(conversionValue.getTrafficVolumeOfSmallTrucksHZ() / result.size()); + conversionAvg.setTrafficVolumeOfSmallTrucksJN(conversionValue.getTrafficVolumeOfSmallTrucksJN() / result.size()); + conversionAvg.setMediumTruckTrafficVolumeHZ(conversionValue.getMediumTruckTrafficVolumeHZ() / result.size()); + conversionAvg.setMediumTruckTrafficVolumeJN(conversionValue.getMediumTruckTrafficVolumeJN() / result.size()); + conversionAvg.setLargeTruckTrafficVolumeHZ(conversionValue.getLargeTruckTrafficVolumeHZ() / result.size()); + conversionAvg.setLargeTruckTrafficVolumeJN(conversionValue.getLargeTruckTrafficVolumeJN() / result.size()); + conversionAvg.setExtraLargeTrucksTrafficVolumeHZ(conversionValue.getExtraLargeTrucksTrafficVolumeHZ() / result.size()); + conversionAvg.setExtraLargeTrucksTrafficVolumeJN(conversionValue.getExtraLargeTrucksTrafficVolumeJN() / result.size()); + conversionAvg.setContainerTruckTrafficVolumeHZ(conversionValue.getContainerTruckTrafficVolumeHZ() / result.size()); + conversionAvg.setContainerTruckTrafficVolumeJN(conversionValue.getContainerTruckTrafficVolumeJN() / result.size()); + conversionAvg.setMotorcycleTrafficVolumeHZ(conversionValue.getMotorcycleTrafficVolumeHZ() / result.size()); + conversionAvg.setMotorcycleTrafficVolumeJN(conversionValue.getMotorcycleTrafficVolumeJN() / result.size()); + conversionAvg.setTractorTrafficVolumeHZ(conversionValue.getTractorTrafficVolumeHZ() / result.size()); + conversionAvg.setTractorTrafficVolumeJN(conversionValue.getTractorTrafficVolumeJN() / result.size()); + Integer conversionAvgTrafficVolumeHZ = conversionAvg.getTrafficNumberOfInAndSmallHZ() + conversionAvg.getBusTrafficVolumeHZ() + + conversionAvg.getTrafficVolumeOfSmallTrucksHZ() + conversionAvg.getMediumTruckTrafficVolumeHZ() + + conversionAvg.getLargeTruckTrafficVolumeHZ() + conversionAvg.getExtraLargeTrucksTrafficVolumeHZ() + + conversionAvg.getContainerTruckTrafficVolumeHZ() + conversionAvg.getMotorcycleTrafficVolumeHZ() + + conversionAvg.getTractorTrafficVolumeHZ(); + conversionAvg.setTrafficVolumeHZ(conversionAvgTrafficVolumeHZ); + Integer conversionAvgTrafficVolumeJN = conversionAvg.getTrafficNumberOfInAndSmallJN() + conversionAvg.getBusTrafficVolumeJN() + + conversionAvg.getTrafficVolumeOfSmallTrucksJN() + conversionAvg.getMediumTruckTrafficVolumeJN() + + conversionAvg.getLargeTruckTrafficVolumeJN() + conversionAvg.getExtraLargeTrucksTrafficVolumeJN() + + conversionAvg.getContainerTruckTrafficVolumeJN() + conversionAvg.getMotorcycleTrafficVolumeJN() + + conversionAvg.getTractorTrafficVolumeJN(); + conversionAvg.setTrafficVolumeJN(conversionAvgTrafficVolumeJN); + conversionAvg.setAllTrafficVolume(conversionAvgTrafficVolumeHZ + conversionAvgTrafficVolumeJN); + result = result.stream().sorted(Comparator.comparing(DcTrafficVolumeDirectionData::getTime)).collect(Collectors.toList()); result.add(naturalTotal); result.add(conversionValue); result.add(naturalAvg); - return AjaxResult.success(result); + result.add(conversionAvg); + + //车型大类 + if(dcTrafficSurveyDataQueryParams.getCarType().equals("2")){ + List carTypeResult = new ArrayList<>(); + for (DcTrafficVolumeDirectionData dcTrafficVolumeDirectionData : result) { + DcTrafficVolumeDirectionCarTypeData carTypeData = new DcTrafficVolumeDirectionCarTypeData(0); + carTypeData.setTime(dcTrafficVolumeDirectionData.getTime()); + carTypeData.setBusHZ(dcTrafficVolumeDirectionData.getTrafficNumberOfInAndSmallHZ() + dcTrafficVolumeDirectionData.getBusTrafficVolumeHZ()); + carTypeData.setBusJN(dcTrafficVolumeDirectionData.getTrafficNumberOfInAndSmallJN() + dcTrafficVolumeDirectionData.getBusTrafficVolumeJN()); + carTypeData.setGoodsCarHZ(dcTrafficVolumeDirectionData.getTrafficVolumeOfSmallTrucksHZ() + + dcTrafficVolumeDirectionData.getMediumTruckTrafficVolumeHZ() + + dcTrafficVolumeDirectionData.getLargeTruckTrafficVolumeHZ() + + dcTrafficVolumeDirectionData.getExtraLargeTrucksTrafficVolumeHZ() + ); + carTypeData.setGoodsCarJN(dcTrafficVolumeDirectionData.getTrafficVolumeOfSmallTrucksJN() + + dcTrafficVolumeDirectionData.getMediumTruckTrafficVolumeJN() + + dcTrafficVolumeDirectionData.getLargeTruckTrafficVolumeJN() + + dcTrafficVolumeDirectionData.getExtraLargeTrucksTrafficVolumeJN() + ); + carTypeData.setTrafficVolumeHZ(dcTrafficVolumeDirectionData.getTrafficVolumeHZ()); + carTypeData.setTrafficVolumeJN(dcTrafficVolumeDirectionData.getTrafficVolumeJN()); + carTypeData.setAllTrafficVolume(dcTrafficVolumeDirectionData.getAllTrafficVolume()); + carTypeResult.add(carTypeData); + } + + return AjaxResult.success(carTypeResult); + } else { + return AjaxResult.success(result); + } } else if (dcTrafficSurveyDataQueryParams.getDirection().equals("2")){ //自然合计值 DcTrafficVolumeData naturalTotal = new DcTrafficVolumeData(0); @@ -481,14 +588,55 @@ public class DcTrafficSurveyDataServiceImpl implements IDcTrafficSurveyDataServi naturalAvg.getTractorTrafficVolume(); naturalAvg.setTrafficVolume(naturalAvgTrafficVolume); + //折算平均值 + DcTrafficVolumeData conversionAvg = new DcTrafficVolumeData(0); + conversionAvg.setTime("自然平均值"); + conversionAvg.setTrafficNumberOfInAndSmall(conversionValue.getTrafficNumberOfInAndSmall() / dcTrafficVolumeData.size()); + conversionAvg.setBusTrafficVolume(conversionValue.getBusTrafficVolume() / dcTrafficVolumeData.size()); + conversionAvg.setTrafficVolumeOfSmallTrucks(conversionValue.getTrafficVolumeOfSmallTrucks() / dcTrafficVolumeData.size()); + conversionAvg.setMediumTruckTrafficVolume(conversionValue.getMediumTruckTrafficVolume() / dcTrafficVolumeData.size()); + conversionAvg.setLargeTruckTrafficVolume(conversionValue.getLargeTruckTrafficVolume() / dcTrafficVolumeData.size()); + conversionAvg.setExtraLargeTrucksTrafficVolume(conversionValue.getExtraLargeTrucksTrafficVolume() / dcTrafficVolumeData.size()); + conversionAvg.setContainerTruckTrafficVolume(conversionValue.getContainerTruckTrafficVolume() / dcTrafficVolumeData.size()); + conversionAvg.setMotorcycleTrafficVolume(conversionValue.getMotorcycleTrafficVolume() / dcTrafficVolumeData.size()); + conversionAvg.setTractorTrafficVolume(conversionValue.getTractorTrafficVolume() / dcTrafficVolumeData.size()); + Integer conversionAvgTrafficVolume = conversionAvg.getTrafficNumberOfInAndSmall() + conversionAvg.getBusTrafficVolume() + + conversionAvg.getTrafficVolumeOfSmallTrucks() + conversionAvg.getMediumTruckTrafficVolume() + + conversionAvg.getLargeTruckTrafficVolume() + conversionAvg.getExtraLargeTrucksTrafficVolume() + + conversionAvg.getContainerTruckTrafficVolume() + conversionAvg.getMotorcycleTrafficVolume() + + conversionAvg.getTractorTrafficVolume(); + conversionAvg.setTrafficVolume(conversionAvgTrafficVolume); + dcTrafficVolumeData.add(naturalTotal); dcTrafficVolumeData.add(conversionValue); dcTrafficVolumeData.add(naturalAvg); + dcTrafficVolumeData.add(conversionAvg); + + } } - return AjaxResult.success(dcTrafficVolumeData); + //车型大类 + if(dcTrafficSurveyDataQueryParams.getCarType().equals("2")){ + List carTypeResult = new ArrayList<>(); + + for (DcTrafficVolumeData dcTrafficVolumeDatum : dcTrafficVolumeData) { + DcTrafficVolumeCarTypeData carTypeData = new DcTrafficVolumeCarTypeData(0); + carTypeData.setTime(dcTrafficVolumeDatum.getTime()); + carTypeData.setBus(dcTrafficVolumeDatum.getTrafficNumberOfInAndSmall() + dcTrafficVolumeDatum.getBusTrafficVolume()); + carTypeData.setGoodsCar(dcTrafficVolumeDatum.getTrafficVolumeOfSmallTrucks() + + dcTrafficVolumeDatum.getMediumTruckTrafficVolume() + + dcTrafficVolumeDatum.getLargeTruckTrafficVolume() + + dcTrafficVolumeDatum.getExtraLargeTrucksTrafficVolume() + ); + carTypeData.setTrafficVolume(dcTrafficVolumeDatum.getTrafficVolume()); + carTypeResult.add(carTypeData); + } + return AjaxResult.success(carTypeResult); + } else { + return AjaxResult.success(dcTrafficVolumeData); + } } else { //车速 List dcTrafficSpeedData = dcTrafficSurveyDataMapper.selectSpeed(dcTrafficSurveyDataQueryParams); @@ -581,7 +729,33 @@ public class DcTrafficSurveyDataServiceImpl implements IDcTrafficSurveyDataServi avgSpeed.setAvgSpeedJN(avgSpeed.getAvgSpeedJN() / result.size()); result.add(avgSpeed); - return AjaxResult.success(result); + //车型大类 + if(dcTrafficSurveyDataQueryParams.getCarType().equals("2")){ + List carTypeList = new ArrayList<>(); + + for (DcTrafficSpeedDirectionData speedDirectionData : result) { + DcTrafficSpeedDirectionCarTypeData carTypeData = new DcTrafficSpeedDirectionCarTypeData(0); + carTypeData.setTime(speedDirectionData.getTime()); + + carTypeData.setBusVehicleSpeedHZ((speedDirectionData.getInAndSmallAverageVehicleSpeedHZ() + speedDirectionData.getAverageSpeedOfBusHZ()) / 2); + carTypeData.setBusVehicleSpeedJN((speedDirectionData.getInAndSmallAverageVehicleSpeedJN() + speedDirectionData.getAverageSpeedOfBusJN()) / 2); + carTypeData.setGoodsCarVehicleSpeedHZ((speedDirectionData.getSmallTrucksAverageVehicleSpeedHZ() + + speedDirectionData.getAverageSpeedOfMediumSizeTrucksHZ() + + speedDirectionData.getAverageSpeedOfLargeTrucksHZ() + + speedDirectionData.getAverageSpeedOfExtraLargeTrucksHZ()) / 4); + carTypeData.setGoodsCarVehicleSpeedJN((speedDirectionData.getSmallTrucksAverageVehicleSpeedJN() + + speedDirectionData.getAverageSpeedOfMediumSizeTrucksJN() + + speedDirectionData.getAverageSpeedOfLargeTrucksJN() + + speedDirectionData.getAverageSpeedOfExtraLargeTrucksJN()) / 4); + carTypeData.setAvgSpeedHZ(speedDirectionData.getAvgSpeedHZ()); + carTypeData.setAvgSpeedJN(speedDirectionData.getAvgSpeedJN()); + carTypeList.add(carTypeData); + } + + return AjaxResult.success(carTypeList); + } else { + return AjaxResult.success(result); + } } else { DcTrafficSpeedData avgSpeed = new DcTrafficSpeedData(0); avgSpeed.setTime("车速平均值"); @@ -610,6 +784,24 @@ public class DcTrafficSurveyDataServiceImpl implements IDcTrafficSurveyDataServi avgSpeed.setAvgSpeed(avgSpeed.getAvgSpeed() / dcTrafficSpeedData.size()); dcTrafficSpeedData.add(avgSpeed); } + //车型大类 + if(dcTrafficSurveyDataQueryParams.getCarType().equals("2")){ + List carTypeResult = new ArrayList<>(); + + for (DcTrafficSpeedData speedData : dcTrafficSpeedData) { + DcTrafficSpeedCarTypeData carTypeData = new DcTrafficSpeedCarTypeData(0); + carTypeData.setTime(speedData.getTime()); + carTypeData.setBusVehicleSpeed((speedData.getInAndSmallAverageVehicleSpeed() + speedData.getAverageSpeedOfBus()) / 2); + carTypeData.setGoodsCarVehicleSpeed((speedData.getSmallTrucksAverageVehicleSpeed() + + speedData.getAverageSpeedOfMediumSizeTrucks() + + speedData.getAverageSpeedOfLargeTrucks() + + speedData.getAverageSpeedOfExtraLargeTrucks()) / 4); + carTypeData.setAvgSpeed(speedData.getAvgSpeed()); + carTypeResult.add(carTypeData); + } + + return AjaxResult.success(carTypeResult); + } } return AjaxResult.success(dcTrafficSpeedData); } diff --git a/zc-business/src/main/resources/mapper/business/DcTrafficSurveyDataMapper.xml b/zc-business/src/main/resources/mapper/business/DcTrafficSurveyDataMapper.xml index 58cfa08b..f9cb186b 100644 --- a/zc-business/src/main/resources/mapper/business/DcTrafficSurveyDataMapper.xml +++ b/zc-business/src/main/resources/mapper/business/DcTrafficSurveyDataMapper.xml @@ -61,6 +61,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where DATE_FORMAT(`timestamp`,'%Y') = DATE_FORMAT(#{timestamp},'%Y') GROUP BY iot_device_id,direction,times +