Browse Source

一类交调站综合查询修改

develop
lau572 1 month ago
parent
commit
91e61b7ea4
  1. 21
      zc-business/src/main/java/com/zc/business/controller/DcTrafficSurveyDataController.java
  2. 33
      zc-business/src/main/java/com/zc/business/domain/DcTrafficSurveyData.java
  3. 8
      zc-business/src/main/java/com/zc/business/service/IDcTrafficSurveyDataService.java
  4. 551
      zc-business/src/main/java/com/zc/business/service/impl/DcTrafficSurveyDataServiceImpl.java
  5. 21
      zc-business/src/main/resources/mapper/business/DcTrafficSurveyDataMapper.xml

21
zc-business/src/main/java/com/zc/business/controller/DcTrafficSurveyDataController.java

@ -335,13 +335,22 @@ public class DcTrafficSurveyDataController extends BaseController
return dcTrafficSurveyDataService.selectDcTrafficSurveyDataList(dcTrafficSurveyData); return dcTrafficSurveyDataService.selectDcTrafficSurveyDataList(dcTrafficSurveyData);
} }
/**
* 查询一类交调数据列表
*/
@GetMapping("/listNew")
public AjaxResult listNew(DcTrafficSurveyData dcTrafficSurveyData)
{
return dcTrafficSurveyDataService.selectDcTrafficSurveyDataListNew(dcTrafficSurveyData);
}
/** /**
* 导出一类交调数据列表 * 导出一类交调数据列表
*/ */
@Log(title = "一类交调数据", businessType = BusinessType.EXPORT) @Log(title = "一类交调数据", businessType = BusinessType.EXPORT)
@PostMapping("/export") @PostMapping("/export")
public void export(HttpServletResponse response, DcTrafficSurveyData dcTrafficSurveyData) throws IOException { public void export(HttpServletResponse response, DcTrafficSurveyData dcTrafficSurveyData) throws IOException {
AjaxResult ajaxResult = dcTrafficSurveyDataService.selectDcTrafficSurveyDataList(dcTrafficSurveyData); AjaxResult ajaxResult = dcTrafficSurveyDataService.selectDcTrafficSurveyDataListNew(dcTrafficSurveyData);
if (ajaxResult.get("code").equals(UniversalEnum.TWO_HUNDRED.getNumber())) { if (ajaxResult.get("code").equals(UniversalEnum.TWO_HUNDRED.getNumber())) {
Map<String,Object> data = (Map<String, Object>) ajaxResult.get("data"); Map<String,Object> data = (Map<String, Object>) ajaxResult.get("data");
List<Map<String,String>> columnList = (List<Map<String,String>>) data.get("columnList"); List<Map<String,String>> columnList = (List<Map<String,String>>) data.get("columnList");
@ -407,15 +416,7 @@ public class DcTrafficSurveyDataController extends BaseController
cell.setCellStyle(dataStyle); cell.setCellStyle(dataStyle);
cell = subHeaderRow.createCell(UniversalEnum.ONE.getNumber()); cell = subHeaderRow.createCell(UniversalEnum.ONE.getNumber());
String direction = rowList.get(j).get("direction").toString(); String direction = rowList.get(j).get("direction").toString();
String directionStr = "济南方向"; cell.setCellValue(direction);
if (direction.equals("1")){
directionStr = "济南方向";
} else if (direction.equals("2")){
directionStr = "合计";
} else if (direction.equals("3")){
directionStr = "菏泽方向";
}
cell.setCellValue(directionStr);
cell.setCellStyle(dataStyle); cell.setCellStyle(dataStyle);
int k = 0; int k = 0;
for (k = 0; k < columnList.size(); k++) { for (k = 0; k < columnList.size(); k++) {

33
zc-business/src/main/java/com/zc/business/domain/DcTrafficSurveyData.java

@ -114,6 +114,15 @@ public class DcTrafficSurveyData extends BaseEntity
private String times; private String times;
/** 数据类型 1:全部 2:分方向 3:分车型 */
private String rowType;
/** 客车 */
private Integer bus;
/** 货车 */
private Integer goodsCar;
public void setId(Long id) public void setId(Long id)
{ {
this.id = id; this.id = id;
@ -369,6 +378,30 @@ public class DcTrafficSurveyData extends BaseEntity
this.endTime = endTime; this.endTime = endTime;
} }
public String getRowType() {
return rowType;
}
public void setRowType(String rowType) {
this.rowType = rowType;
}
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;
}
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

8
zc-business/src/main/java/com/zc/business/service/IDcTrafficSurveyDataService.java

@ -34,6 +34,14 @@ public interface IDcTrafficSurveyDataService
*/ */
AjaxResult selectDcTrafficSurveyDataList(DcTrafficSurveyData dcTrafficSurveyData); AjaxResult selectDcTrafficSurveyDataList(DcTrafficSurveyData dcTrafficSurveyData);
/**
* 查询一类交调数据列表
*
* @param dcTrafficSurveyData 一类交调数据
* @return 一类交调数据集合
*/
AjaxResult selectDcTrafficSurveyDataListNew(DcTrafficSurveyData dcTrafficSurveyData);
/** /**
* 新增一类交调数据 * 新增一类交调数据
* *

551
zc-business/src/main/java/com/zc/business/service/impl/DcTrafficSurveyDataServiceImpl.java

@ -83,7 +83,7 @@ public class DcTrafficSurveyDataServiceImpl implements IDcTrafficSurveyDataServi
//单个设备济南方向数据 //单个设备济南方向数据
row = new HashMap<>(); row = new HashMap<>();
row.put("stakeMark",dcDevice.getStakeMark()); row.put("stakeMark",dcDevice.getStakeMark());
row.put("direction","1"); row.put("direction","3");
//单个设备合计数据 //单个设备合计数据
Map<String,Object> totalRow = new HashMap<>(); Map<String,Object> totalRow = new HashMap<>();
@ -94,10 +94,10 @@ public class DcTrafficSurveyDataServiceImpl implements IDcTrafficSurveyDataServi
totalRow.put("total",0); totalRow.put("total",0);
} }
if (directionData.containsKey("1")){ if (directionData.containsKey("3")){
Integer total = 0; Integer total = 0;
//单个设备济南方向分时数据 //单个设备济南方向分时数据
Map<String,List<DcTrafficSurveyData>> directionList = directionData.get("1"); Map<String,List<DcTrafficSurveyData>> directionList = directionData.get("3");
for (Map<String, String> columnMap : columnList) { for (Map<String, String> columnMap : columnList) {
if (directionList.containsKey(columnMap.get("key"))){ if (directionList.containsKey(columnMap.get("key"))){
List<DcTrafficSurveyData> timeList = directionList.get(columnMap.get("key")); List<DcTrafficSurveyData> timeList = directionList.get(columnMap.get("key"));
@ -121,11 +121,11 @@ public class DcTrafficSurveyDataServiceImpl implements IDcTrafficSurveyDataServi
//单个设备菏泽方向数据 //单个设备菏泽方向数据
row = new HashMap<>(); row = new HashMap<>();
row.put("stakeMark",dcDevice.getStakeMark()); row.put("stakeMark",dcDevice.getStakeMark());
row.put("direction","3"); row.put("direction","1");
if (directionData.containsKey("3")){ if (directionData.containsKey("1")){
Integer total = 0; Integer total = 0;
//单个设备菏泽方向分时数据 //单个设备菏泽方向分时数据
Map<String,List<DcTrafficSurveyData>> directionList = directionData.get("3"); Map<String,List<DcTrafficSurveyData>> directionList = directionData.get("1");
for (Map<String, String> columnMap : columnList) { for (Map<String, String> columnMap : columnList) {
if (directionList.containsKey(columnMap.get("key"))){ if (directionList.containsKey(columnMap.get("key"))){
List<DcTrafficSurveyData> timeList = directionList.get(columnMap.get("key")); List<DcTrafficSurveyData> timeList = directionList.get(columnMap.get("key"));
@ -185,6 +185,545 @@ public class DcTrafficSurveyDataServiceImpl implements IDcTrafficSurveyDataServi
} }
/**
* 查询一类交调数据列表
*
* @param dcTrafficSurveyData 一类交调数据
* @return 一类交调数据
*/
@Override
public AjaxResult selectDcTrafficSurveyDataListNew(DcTrafficSurveyData dcTrafficSurveyData)
{
List<Map<String,Object>> rowList = new ArrayList<>();
List<Map<String,String>> columnList = getColumnList(dcTrafficSurveyData);
List<DcTrafficSurveyData> dataList = new ArrayList<>();
if (dcTrafficSurveyData.getType().equals("day")){
dataList = dcTrafficSurveyDataMapper.selectDay(dcTrafficSurveyData);
} else if (dcTrafficSurveyData.getType().equals("month")){
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<String,Map<String, Map<String, List<DcTrafficSurveyData>>>> groupedData = dataList.stream()
.collect(Collectors.groupingBy(
DcTrafficSurveyData::getIotDeviceId, // 第一级分组:按设备Id
Collectors.groupingBy(DcTrafficSurveyData::getDirection, // 第二级分组:按方向
Collectors.groupingBy(DcTrafficSurveyData::getTimes) // 第三级分组:按时间
)));
List<DcDevice> deviceList = dcTrafficSurveyDataMapper.selectDeviceList();
Map<String,Object> row = new HashMap<>();
for (DcDevice dcDevice : deviceList) {
if (groupedData.containsKey(dcDevice.getIotDeviceId())){
Map<String,Map<String, List<DcTrafficSurveyData>>> directionData = groupedData.get(dcDevice.getIotDeviceId());
if (dcTrafficSurveyData.getRowType().equals("1")){
//单个设备济南方向数据
row = new HashMap<>();
row.put("stakeMark",dcDevice.getStakeMark());
row.put("direction","济南");
//单个设备客车数据
Map<String,Object> busRow = new HashMap<>();
busRow.put("stakeMark",dcDevice.getStakeMark());
busRow.put("direction","客车");
for (Map<String, String> columnMap : columnList) {
busRow.put(columnMap.get("key"),0);
busRow.put("total",0);
}
//单个设备货车数据
Map<String,Object> goodsCarRow = new HashMap<>();
goodsCarRow.put("stakeMark",dcDevice.getStakeMark());
goodsCarRow.put("direction","货车");
for (Map<String, String> columnMap : columnList) {
goodsCarRow.put(columnMap.get("key"),0);
goodsCarRow.put("total",0);
}
//单个设备合计数据
Map<String,Object> totalRow = new HashMap<>();
totalRow.put("stakeMark",dcDevice.getStakeMark());
totalRow.put("direction","合计");
for (Map<String, String> columnMap : columnList) {
totalRow.put(columnMap.get("key"),0);
totalRow.put("total",0);
}
if (directionData.containsKey("3")){
Integer bus = 0;
Integer goodsCar = 0;
Integer total = 0;
//单个设备济南方向分时数据
Map<String,List<DcTrafficSurveyData>> directionList = directionData.get("3");
for (Map<String, String> columnMap : columnList) {
if (directionList.containsKey(columnMap.get("key"))){
List<DcTrafficSurveyData> timeList = directionList.get(columnMap.get("key"));
row.put(columnMap.get("key"),timeList.get(0).getTrafficVolume());
busRow.put(columnMap.get("key"),timeList.get(0).getBus());
goodsCarRow.put(columnMap.get("key"),timeList.get(0).getGoodsCar());
totalRow.put(columnMap.get("key"),timeList.get(0).getTrafficVolume());
bus += timeList.get(0).getBus();
goodsCar += timeList.get(0).getGoodsCar();
total += timeList.get(0).getTrafficVolume().intValue();
} else {
row.put(columnMap.get("key"),0);
}
}
row.put("total",total);
busRow.put("total",bus);
goodsCarRow.put("total",goodsCar);
totalRow.put("total",total);
} else {
for (Map<String, String> columnMap : columnList) {
row.put(columnMap.get("key"),0);
row.put("total",0);
}
}
rowList.add(row);
//单个设备菏泽方向数据
row = new HashMap<>();
row.put("stakeMark",dcDevice.getStakeMark());
row.put("direction","菏泽");
if (directionData.containsKey("1")){
Integer bus = 0;
Integer goodsCar = 0;
Integer total = 0;
//单个设备菏泽方向分时数据
Map<String,List<DcTrafficSurveyData>> directionList = directionData.get("1");
for (Map<String, String> columnMap : columnList) {
if (directionList.containsKey(columnMap.get("key"))){
List<DcTrafficSurveyData> timeList = directionList.get(columnMap.get("key"));
row.put(columnMap.get("key"),timeList.get(0).getTrafficVolume());
Long busRowData = Long.parseLong(busRow.get(columnMap.get("key")).toString());
busRow.put(columnMap.get("key"),busRowData + timeList.get(0).getBus());
Long goodsCarRowData = Long.parseLong(goodsCarRow.get(columnMap.get("key")).toString());
goodsCarRow.put(columnMap.get("key"),goodsCarRowData + timeList.get(0).getGoodsCar());
Long totalRowData = Long.parseLong(totalRow.get(columnMap.get("key")).toString());
totalRow.put(columnMap.get("key"),totalRowData + timeList.get(0).getTrafficVolume());
bus += timeList.get(0).getBus();
goodsCar += timeList.get(0).getGoodsCar();
total += timeList.get(0).getTrafficVolume().intValue();
} else {
row.put(columnMap.get("key"),0);
}
}
row.put("total",total);
busRow.put("total",Integer.parseInt(busRow.get("total").toString()) + bus);
goodsCarRow.put("total",Integer.parseInt(goodsCarRow.get("total").toString()) + goodsCar);
totalRow.put("total",Integer.parseInt(totalRow.get("total").toString()) + total);
} else {
for (Map<String, String> columnMap : columnList) {
row.put(columnMap.get("key"),0);
row.put("total",0);
}
}
rowList.add(row);
//客车
rowList.add(busRow);
//客车占比
Map<String,Object> busRatioRow = new HashMap<>();
busRatioRow.put("stakeMark",dcDevice.getStakeMark());
busRatioRow.put("direction","客车占比");
for (Map<String, String> columnMap : columnList) {
Integer busTotal = Integer.valueOf(busRow.get(columnMap.get("key")).toString());
Integer total = Integer.valueOf(totalRow.get(columnMap.get("key")).toString());
if (total > 0){
busRatioRow.put(columnMap.get("key"),String.format("%.2f",(double) busTotal / total * 100) + "%");
} else {
busRatioRow.put(columnMap.get("key"),"0.00%");
}
}
Integer allBusTotal = Integer.valueOf(busRow.get("total").toString());
Integer allTotal = Integer.valueOf(totalRow.get("total").toString());
if (allTotal > 0){
busRatioRow.put("total",String.format("%.2f",(double) allBusTotal / allTotal * 100) + "%");
} else {
busRatioRow.put("total","0.00%");
}
rowList.add(busRatioRow);
//货车
rowList.add(goodsCarRow);
//货车占比
Map<String,Object> goodsCarRatioRow = new HashMap<>();
goodsCarRatioRow.put("stakeMark",dcDevice.getStakeMark());
goodsCarRatioRow.put("direction","货车占比");
for (Map<String, String> columnMap : columnList) {
Integer goodsCarTotal = Integer.valueOf(goodsCarRow.get(columnMap.get("key")).toString());
Integer total = Integer.valueOf(totalRow.get(columnMap.get("key")).toString());
if (total > 0) {
goodsCarRatioRow.put(columnMap.get("key"), String.format("%.2f", (double) goodsCarTotal / total * 100) + "%");
} else {
goodsCarRatioRow.put(columnMap.get("key"),"0.00%");
}
}
Integer allGoodsCarTotal = Integer.valueOf(goodsCarRow.get("total").toString());
if (allTotal > 0){
goodsCarRatioRow.put("total",String.format("%.2f",(double) allGoodsCarTotal / allTotal * 100) + "%");
} else {
goodsCarRatioRow.put("total","0.00%");
}
rowList.add(goodsCarRatioRow);
//最后加入合计
rowList.add(totalRow);
} else if (dcTrafficSurveyData.getRowType().equals("2")){
//单个设备济南方向数据
row = new HashMap<>();
row.put("stakeMark",dcDevice.getStakeMark());
row.put("direction","济南");
//单个设备合计数据
Map<String,Object> totalRow = new HashMap<>();
totalRow.put("stakeMark",dcDevice.getStakeMark());
totalRow.put("direction","合计");
for (Map<String, String> columnMap : columnList) {
totalRow.put(columnMap.get("key"),0);
totalRow.put("total",0);
}
if (directionData.containsKey("3")){
Integer total = 0;
//单个设备济南方向分时数据
Map<String,List<DcTrafficSurveyData>> directionList = directionData.get("3");
for (Map<String, String> columnMap : columnList) {
if (directionList.containsKey(columnMap.get("key"))){
List<DcTrafficSurveyData> 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<String, String> columnMap : columnList) {
row.put(columnMap.get("key"),0);
row.put("total",0);
}
}
rowList.add(row);
//单个设备菏泽方向数据
row = new HashMap<>();
row.put("stakeMark",dcDevice.getStakeMark());
row.put("direction","菏泽");
if (directionData.containsKey("1")){
Integer total = 0;
//单个设备菏泽方向分时数据
Map<String,List<DcTrafficSurveyData>> directionList = directionData.get("1");
for (Map<String, String> columnMap : columnList) {
if (directionList.containsKey(columnMap.get("key"))){
List<DcTrafficSurveyData> 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<String, String> columnMap : columnList) {
row.put(columnMap.get("key"),0);
row.put("total",0);
}
}
rowList.add(row);
//最后加入合计
rowList.add(totalRow);
} else {
//单个设备客车数据
Map<String,Object> busRow = new HashMap<>();
busRow.put("stakeMark",dcDevice.getStakeMark());
busRow.put("direction","客车");
for (Map<String, String> columnMap : columnList) {
busRow.put(columnMap.get("key"),0);
busRow.put("total",0);
}
//单个设备货车数据
Map<String,Object> goodsCarRow = new HashMap<>();
goodsCarRow.put("stakeMark",dcDevice.getStakeMark());
goodsCarRow.put("direction","货车");
for (Map<String, String> columnMap : columnList) {
goodsCarRow.put(columnMap.get("key"),0);
goodsCarRow.put("total",0);
}
//单个设备合计数据
Map<String,Object> totalRow = new HashMap<>();
totalRow.put("stakeMark",dcDevice.getStakeMark());
totalRow.put("direction","合计");
for (Map<String, String> columnMap : columnList) {
totalRow.put(columnMap.get("key"),0);
totalRow.put("total",0);
}
if (directionData.containsKey("3")){
Integer bus = 0;
Integer goodsCar = 0;
Integer total = 0;
//单个设备济南方向分时数据
Map<String,List<DcTrafficSurveyData>> directionList = directionData.get("3");
for (Map<String, String> columnMap : columnList) {
if (directionList.containsKey(columnMap.get("key"))){
List<DcTrafficSurveyData> timeList = directionList.get(columnMap.get("key"));
busRow.put(columnMap.get("key"),timeList.get(0).getBus());
goodsCarRow.put(columnMap.get("key"),timeList.get(0).getGoodsCar());
totalRow.put(columnMap.get("key"),timeList.get(0).getTrafficVolume());
bus += timeList.get(0).getBus();
goodsCar += timeList.get(0).getGoodsCar();
total += timeList.get(0).getTrafficVolume().intValue();
}
}
busRow.put("total",bus);
goodsCarRow.put("total",goodsCar);
totalRow.put("total",total);
}
//单个设备菏泽方向数据
if (directionData.containsKey("1")){
Integer bus = 0;
Integer goodsCar = 0;
Integer total = 0;
//单个设备菏泽方向分时数据
Map<String,List<DcTrafficSurveyData>> directionList = directionData.get("1");
for (Map<String, String> columnMap : columnList) {
if (directionList.containsKey(columnMap.get("key"))){
List<DcTrafficSurveyData> timeList = directionList.get(columnMap.get("key"));
Long busRowData = Long.parseLong(busRow.get(columnMap.get("key")).toString());
Long goodsCarRowData = Long.parseLong(goodsCarRow.get(columnMap.get("key")).toString());
Long totalRowData = Long.parseLong(totalRow.get(columnMap.get("key")).toString());
busRow.put(columnMap.get("key"),busRowData + timeList.get(0).getBus());
goodsCarRow.put(columnMap.get("key"),goodsCarRowData + timeList.get(0).getGoodsCar());
totalRow.put(columnMap.get("key"),totalRowData + timeList.get(0).getTrafficVolume());
bus += timeList.get(0).getBus();
goodsCar += timeList.get(0).getGoodsCar();
total += timeList.get(0).getTrafficVolume().intValue();
}
}
busRow.put("total",Integer.parseInt(busRow.get("total").toString()) + bus);
goodsCarRow.put("total",Integer.parseInt(goodsCarRow.get("total").toString()) + goodsCar);
totalRow.put("total",Integer.parseInt(totalRow.get("total").toString()) + total);
}
//客车
rowList.add(busRow);
//客车占比
Map<String,Object> busRatioRow = new HashMap<>();
busRatioRow.put("stakeMark",dcDevice.getStakeMark());
busRatioRow.put("direction","客车占比");
for (Map<String, String> columnMap : columnList) {
Integer busTotal = Integer.valueOf(busRow.get(columnMap.get("key")).toString());
Integer total = Integer.valueOf(totalRow.get(columnMap.get("key")).toString());
if (total > 0){
busRatioRow.put(columnMap.get("key"),String.format("%.2f",(double) busTotal / total * 100) + "%");
} else {
busRatioRow.put(columnMap.get("key"),"0.00%");
}
}
Integer allBusTotal = Integer.valueOf(busRow.get("total").toString());
Integer allTotal = Integer.valueOf(totalRow.get("total").toString());
if (allTotal > 0){
busRatioRow.put("total",String.format("%.2f",(double) allBusTotal / allTotal * 100) + "%");
} else {
busRatioRow.put("total","0.00%");
}
rowList.add(busRatioRow);
//货车
rowList.add(goodsCarRow);
//货车占比
Map<String,Object> goodsCarRatioRow = new HashMap<>();
goodsCarRatioRow.put("stakeMark",dcDevice.getStakeMark());
goodsCarRatioRow.put("direction","货车占比");
for (Map<String, String> columnMap : columnList) {
Integer goodsCarTotal = Integer.valueOf(goodsCarRow.get(columnMap.get("key")).toString());
Integer total = Integer.valueOf(totalRow.get(columnMap.get("key")).toString());
if (total > 0) {
goodsCarRatioRow.put(columnMap.get("key"), String.format("%.2f", (double) goodsCarTotal / total * 100) + "%");
} else {
goodsCarRatioRow.put(columnMap.get("key"),"0.00%");
}
}
Integer allGoodsCarTotal = Integer.valueOf(goodsCarRow.get("total").toString());
if (allTotal > 0){
goodsCarRatioRow.put("total",String.format("%.2f",(double) allGoodsCarTotal / allTotal * 100) + "%");
} else {
goodsCarRatioRow.put("total","0.00%");
}
rowList.add(goodsCarRatioRow);
//最后加入合计
rowList.add(totalRow);
}
} else {
if (dcTrafficSurveyData.getRowType().equals("1")){
row = new HashMap<>();
row.put("stakeMark", dcDevice.getStakeMark());
row.put("direction", "济南");
for (Map<String, String> columnMap : columnList) {
row.put(columnMap.get("key"), 0);
}
row.put("total", 0);
rowList.add(row);
row = new HashMap<>();
row.put("stakeMark", dcDevice.getStakeMark());
row.put("direction", "菏泽");
for (Map<String, String> columnMap : columnList) {
row.put(columnMap.get("key"), 0);
}
row.put("total", 0);
rowList.add(row);
row = new HashMap<>();
row.put("stakeMark", dcDevice.getStakeMark());
row.put("direction", "客车");
for (Map<String, String> columnMap : columnList) {
row.put(columnMap.get("key"), 0);
}
row.put("total", 0);
rowList.add(row);
row = new HashMap<>();
row.put("stakeMark", dcDevice.getStakeMark());
row.put("direction", "客车占比");
for (Map<String, String> columnMap : columnList) {
row.put(columnMap.get("key"), 0);
}
row.put("total", 0);
rowList.add(row);
row = new HashMap<>();
row.put("stakeMark", dcDevice.getStakeMark());
row.put("direction", "货车");
for (Map<String, String> columnMap : columnList) {
row.put(columnMap.get("key"), 0);
}
row.put("total", 0);
rowList.add(row);
row = new HashMap<>();
row.put("stakeMark", dcDevice.getStakeMark());
row.put("direction", "货车占比");
for (Map<String, String> columnMap : columnList) {
row.put(columnMap.get("key"), 0);
}
row.put("total", 0);
rowList.add(row);
//单个设备合计数据
row = new HashMap<>();
row.put("stakeMark", dcDevice.getStakeMark());
row.put("direction", "合计");
for (Map<String, String> columnMap : columnList) {
row.put(columnMap.get("key"), 0);
}
row.put("total", 0);
rowList.add(row);
} else if (dcTrafficSurveyData.getRowType().equals("2")) {
row = new HashMap<>();
row.put("stakeMark", dcDevice.getStakeMark());
row.put("direction", "济南");
for (Map<String, String> columnMap : columnList) {
row.put(columnMap.get("key"), 0);
}
row.put("total", 0);
rowList.add(row);
row = new HashMap<>();
row.put("stakeMark", dcDevice.getStakeMark());
row.put("direction", "菏泽");
for (Map<String, String> columnMap : columnList) {
row.put(columnMap.get("key"), 0);
}
row.put("total", 0);
rowList.add(row);
//单个设备合计数据
row = new HashMap<>();
row.put("stakeMark", dcDevice.getStakeMark());
row.put("direction", "合计");
for (Map<String, String> columnMap : columnList) {
row.put(columnMap.get("key"), 0);
}
row.put("total", 0);
rowList.add(row);
} else {
row = new HashMap<>();
row.put("stakeMark", dcDevice.getStakeMark());
row.put("direction", "客车");
for (Map<String, String> columnMap : columnList) {
row.put(columnMap.get("key"), 0);
}
row.put("total", 0);
rowList.add(row);
row = new HashMap<>();
row.put("stakeMark", dcDevice.getStakeMark());
row.put("direction", "客车占比");
for (Map<String, String> columnMap : columnList) {
row.put(columnMap.get("key"), 0);
}
row.put("total", 0);
rowList.add(row);
row = new HashMap<>();
row.put("stakeMark", dcDevice.getStakeMark());
row.put("direction", "货车");
for (Map<String, String> columnMap : columnList) {
row.put(columnMap.get("key"), 0);
}
row.put("total", 0);
rowList.add(row);
row = new HashMap<>();
row.put("stakeMark", dcDevice.getStakeMark());
row.put("direction", "货车占比");
for (Map<String, String> columnMap : columnList) {
row.put(columnMap.get("key"), 0);
}
row.put("total", 0);
rowList.add(row);
//单个设备合计数据
row = new HashMap<>();
row.put("stakeMark", dcDevice.getStakeMark());
row.put("direction", "合计");
for (Map<String, String> columnMap : columnList) {
row.put(columnMap.get("key"), 0);
}
row.put("total", 0);
rowList.add(row);
}
}
}
Map<String,Object> result = new HashMap<>();
result.put("rowList",rowList);
result.put("columnList",columnList);
return AjaxResult.success(result);
}
public List<Map<String,String>> getColumnList(DcTrafficSurveyData dcTrafficSurveyData){ public List<Map<String,String>> getColumnList(DcTrafficSurveyData dcTrafficSurveyData){
List<Map<String,String>> columnList = new ArrayList<>(); List<Map<String,String>> columnList = new ArrayList<>();
Map<String,String> column; Map<String,String> column;

21
zc-business/src/main/resources/mapper/business/DcTrafficSurveyDataMapper.xml

@ -44,25 +44,38 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
SELECT * FROM `dc_device` where device_type = '11' and iot_device_id is not null SELECT * FROM `dc_device` where device_type = '11' and iot_device_id is not null
</select> </select>
<select id="selectDay" resultType="com.zc.business.domain.DcTrafficSurveyData"> <select id="selectDay" resultType="com.zc.business.domain.DcTrafficSurveyData">
SELECT iot_device_id,stake_mark,direction,HOUR(`timestamp`) times,SUM(traffic_volume) trafficVolume SELECT iot_device_id,stake_mark,direction,HOUR(`timestamp`) times,SUM(traffic_volume) trafficVolume,
SUM(traffic_number_of_in_and_small) + SUM(bus_traffic_volume) bus,
SUM(traffic_volume_of_small_trucks) + SUM(medium_truck_traffic_volume)
+ SUM(large_truck_traffic_volume) + SUM(extra_large_trucks_traffic_volume) goodsCar
FROM `dc_traffic_survey_data` FROM `dc_traffic_survey_data`
where DATE_FORMAT(`timestamp`,'%Y-%m-%d') = DATE_FORMAT(#{timestamp},'%Y-%m-%d') where DATE_FORMAT(`timestamp`,'%Y-%m-%d') = DATE_FORMAT(#{timestamp},'%Y-%m-%d')
GROUP BY iot_device_id,direction,times GROUP BY iot_device_id,direction,times
</select> </select>
<select id="selectMonth" resultType="com.zc.business.domain.DcTrafficSurveyData"> <select id="selectMonth" resultType="com.zc.business.domain.DcTrafficSurveyData">
SELECT iot_device_id,stake_mark,direction,DAY(`timestamp`) times,SUM(traffic_volume) trafficVolume SELECT iot_device_id,stake_mark,direction,DAY(`timestamp`) times,SUM(traffic_volume) trafficVolume,
SUM(traffic_number_of_in_and_small) + SUM(bus_traffic_volume) bus,
SUM(traffic_volume_of_small_trucks) + SUM(medium_truck_traffic_volume)
+ SUM(large_truck_traffic_volume) + SUM(extra_large_trucks_traffic_volume) goodsCar
FROM `dc_traffic_survey_data` FROM `dc_traffic_survey_data`
where DATE_FORMAT(`timestamp`,'%Y-%m') = DATE_FORMAT(#{timestamp},'%Y-%m') where DATE_FORMAT(`timestamp`,'%Y-%m') = DATE_FORMAT(#{timestamp},'%Y-%m')
GROUP BY iot_device_id,direction,times GROUP BY iot_device_id,direction,times
</select> </select>
<select id="selectYear" resultType="com.zc.business.domain.DcTrafficSurveyData"> <select id="selectYear" resultType="com.zc.business.domain.DcTrafficSurveyData">
SELECT iot_device_id,stake_mark,direction,MONTH(`timestamp`) times,SUM(traffic_volume) trafficVolume SELECT iot_device_id,stake_mark,direction,MONTH(`timestamp`) times,SUM(traffic_volume) trafficVolume,
SUM(traffic_number_of_in_and_small) + SUM(bus_traffic_volume) bus,
SUM(traffic_volume_of_small_trucks) + SUM(medium_truck_traffic_volume)
+ SUM(large_truck_traffic_volume) + SUM(extra_large_trucks_traffic_volume) goodsCar
FROM `dc_traffic_survey_data` FROM `dc_traffic_survey_data`
where DATE_FORMAT(`timestamp`,'%Y') = DATE_FORMAT(#{timestamp},'%Y') where DATE_FORMAT(`timestamp`,'%Y') = DATE_FORMAT(#{timestamp},'%Y')
GROUP BY iot_device_id,direction,times GROUP BY iot_device_id,direction,times
</select> </select>
<select id="selectRange" resultType="com.zc.business.domain.DcTrafficSurveyData"> <select id="selectRange" resultType="com.zc.business.domain.DcTrafficSurveyData">
SELECT iot_device_id,stake_mark,direction,DATE_FORMAT(`timestamp`, '%m-%d') times,SUM(traffic_volume) trafficVolume SELECT iot_device_id,stake_mark,direction,DATE_FORMAT(`timestamp`, '%m-%d') times,
SUM(traffic_volume) trafficVolume,
SUM(traffic_number_of_in_and_small) + SUM(bus_traffic_volume) bus,
SUM(traffic_volume_of_small_trucks) + SUM(medium_truck_traffic_volume)
+ SUM(large_truck_traffic_volume) + SUM(extra_large_trucks_traffic_volume) goodsCar
FROM `dc_traffic_survey_data` FROM `dc_traffic_survey_data`
where DATE_FORMAT(`timestamp`,'%Y-%m-%d') >= DATE_FORMAT(#{timestamp},'%Y-%m-%d') where DATE_FORMAT(`timestamp`,'%Y-%m-%d') >= DATE_FORMAT(#{timestamp},'%Y-%m-%d')
and DATE_FORMAT(`timestamp`,'%Y-%m-%d') &lt;= DATE_FORMAT(#{endTime},'%Y-%m-%d') and DATE_FORMAT(`timestamp`,'%Y-%m-%d') &lt;= DATE_FORMAT(#{endTime},'%Y-%m-%d')

Loading…
Cancel
Save