You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

893 lines
46 KiB
Java

package com.nmgs.controller;
import com.nmgs.config.Constant;
import com.nmgs.entity.export.CpDetailExcel;
import com.nmgs.entity.export.FixedPointExcel;
import com.nmgs.entity.export.GSCpDetailExcel;
import com.nmgs.entity.export.IsmDetailExcel;
import com.nmgs.entity.export.OverDetailExcel;
import com.nmgs.entity.export.VdDetailExcel;
import com.nmgs.entity.export.ZDOverDetailExcel;
import com.nmgs.enumeration.MessageEnum;
import com.nmgs.exception.PPException;
import com.nmgs.mapper.CpDetailMapper;
import com.nmgs.mapper.FpDetailMapper;
import com.nmgs.mapper.GSCpDetailMapper;
import com.nmgs.mapper.IsmDetailMapper;
import com.nmgs.mapper.OverLoadDetailMapper;
import com.nmgs.mapper.VdDetailMapper;
import com.nmgs.mapper.zdzcpt.ZDZCMapper;
import com.nmgs.util.DateTimeUtil;
import com.nmgs.util.ExcelUtil;
import com.nmgs.util.UuidUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author: shuguang
* @date: 2024年04月17日 10:57
* @description: 导出
*/
@RestController
@RequestMapping("/export")
@Slf4j
public class ExportController {
@Resource
private CpDetailMapper cpDetailMapper;
@Resource
private IsmDetailMapper ismDetailMapper;
@Resource
private FpDetailMapper fpDetailMapper;
@Resource
private OverLoadDetailMapper overLoadDetailMapper;
@Resource
private VdDetailMapper vdDetailMapper;
@Resource
private GSCpDetailMapper gsCpDetailMapper;
@Resource
private ZDZCMapper zdzcMapper;
@RequestMapping(value = "/exportZDPTOverExcel", method = RequestMethod.POST)
public void exportZDPTOverExcel(HttpServletResponse response,@RequestBody Map<String, Object> map) {
String fileName = "总队治超平台数据";
String uuid = UuidUtil.getUuid();
log.info("[uuid:{}]-开始根据参数{}查询总队治超平台数据并导出到Excel", uuid, map);
List<ZDOverDetailExcel> list;
Map<String, Object> params = new HashMap<>();
try {
if (ObjectUtils.isNotEmpty(map.get("lineId"))) {
params.put("lineId", map.get("lineId"));
}
if (ObjectUtils.isNotEmpty(map.get("stationid"))) {
params.put("stationid", map.get("stationid"));
}
if (ObjectUtils.isNotEmpty(map.get("vehplate"))) {
params.put("vehplate", StringUtils.trimAllWhitespace(map.get("vehplate").toString().toUpperCase()));
}
if (ObjectUtils.isNotEmpty(map.get("plateColor"))) {
params.put("plateColor", map.get("plateColor").toString());
}
if (ObjectUtils.isNotEmpty(map.get("overlimitflag")) && 0 != (int) map.get("overlimitflag")) {
params.put("overlimitflag", map.get("overlimitflag"));
if (ObjectUtils.isNotEmpty(map.get("limitrange"))) {
String limitrange = (String) map.get("limitrange");
if (limitrange.contains(Constant.STR_COMMA)) {
String[] split = limitrange.split(Constant.STR_COMMA);
int limitstart = Integer.parseInt(split[0]);
int limitend = Integer.parseInt(split[1]);
params.put("limitstart", limitstart);
params.put("limitend", limitend);
} else {
int limitstart = Integer.parseInt(limitrange);
params.put("limitstart", limitstart);
}
}
}
if (ObjectUtils.isNotEmpty(map.get("starttime"))) {
params.put("starttime", map.get("starttime"));
}
if (ObjectUtils.isNotEmpty(map.get("endtime"))) {
params.put("endtime", map.get("endtime"));
}
if (ObjectUtils.isEmpty(map.get("starttime")) && ObjectUtils.isEmpty(map.get("endtime"))) {
int selectedTimeRange = (int) map.get("selectedTimeRange");
Date now = new Date();
String nowEnd = DateTimeUtil.getFormateString(DateTimeUtil.addDateDays(now, 1), Constant.YYYY_MM_DD);
String nowStart = DateTimeUtil.getFormateString(DateTimeUtil.addDateDays(now, -selectedTimeRange + 1), Constant.YYYY_MM_DD);
params.put("starttime",nowStart);
params.put("endtime", nowEnd);
}
if (ObjectUtils.isNotEmpty(map.get("axiscountStart")) && ObjectUtils.isNotEmpty(map.get("axiscountEnd"))) {
params.put("axiscountStart", map.get("axiscountStart"));
params.put("axiscountEnd", map.get("axiscountEnd"));
}
if (ObjectUtils.isNotEmpty(map.get("inweightStart")) && ObjectUtils.isNotEmpty(map.get("inweightEnd"))) {
params.put("inweightStart", map.get("inweightStart"));
params.put("inweightEnd", map.get("inweightEnd"));
}
if (ObjectUtils.isNotEmpty(map.get("discountWeightStart")) && ObjectUtils.isNotEmpty(map.get("discountWeightEnd"))) {
params.put("discountWeightStart", map.get("discountWeightStart"));
params.put("discountWeightEnd", map.get("discountWeightEnd"));
}
if (ObjectUtils.isNotEmpty(map.get("overWeightStart")) && ObjectUtils.isNotEmpty(map.get("overWeightEnd"))) {
params.put("overWeightStart", map.get("overWeightStart"));
params.put("overWeightEnd", map.get("overWeightEnd"));
}
list =
zdzcMapper.selectOverExcelList(params);;
ExcelUtil.process(fileName, list, ZDOverDetailExcel.class, response);
} catch (IOException e) {
log.error("[uuid:{}]-根据条件导出高速卡口数据失败,报错{}", uuid, e.getMessage());
throw new PPException(MessageEnum.Excel.getCode(), MessageEnum.Excel.getMessage());
}
log.info("[uuid:{}]-根据条件{},导出总队治超平台数据完成,导出条数为{}", uuid, map,list.size());
}
@RequestMapping(value = "/GSCpExcel", method = RequestMethod.POST)
public void GSCpExcel(HttpServletResponse response,@RequestBody Map<String, Object> map) {
String fileName = "高速卡口数据";
String uuid = UuidUtil.getUuid();
log.info("[uuid:{}]-开始根据参数{}查询高速卡口数据并导出到Excel", uuid, map);
List<GSCpDetailExcel> list;
try {
//String whereSql = " where 1=1 and spaceCode IS NOt NULL ";
String whereSql = " where 1=1 ";
if (!ObjectUtils.isEmpty(map.get("subcomno"))) {
whereSql = whereSql + " and t1.subcomno= " + map.get("subcomno") ;
}
if (!ObjectUtils.isEmpty(map.get("lineid"))) {
whereSql = whereSql + " and t1.lineid= '" + map.get("lineid") +"'";
}
if (!ObjectUtils.isEmpty(map.get("plateColor"))) {
whereSql = whereSql + " and plateColor= " + map.get("plateColor") ;
}
if (!ObjectUtils.isEmpty(map.get("plateType"))) {
whereSql = whereSql + " and plateType= " + map.get("plateType") ;
}
if (!ObjectUtils.isEmpty(map.get("vehicleType"))) {
whereSql = whereSql + " and vehicleType= " + map.get("vehicleType") ;
}
if (!ObjectUtils.isEmpty(map.get("vehicleColor"))) {
whereSql = whereSql + " and vehicleColor= " + map.get("vehicleColor") ;
}
if (!ObjectUtils.isEmpty(map.get("stationid"))) {
whereSql = whereSql + " and siteCode= '" + map.get("stationid") +"'";
}
if (!ObjectUtils.isEmpty(map.get("vehplate"))) {
whereSql = whereSql + " and plateNumber like '%" + StringUtils.trimAllWhitespace(map.get("vehplate").toString().toUpperCase())+"%'";
}
if (ObjectUtils.isNotEmpty(map.get("spaceInOrOut")) && 0 != (int)map.get("spaceInOrOut")) {
whereSql = whereSql + " and t.spaceInOrOut ="+map.get("spaceInOrOut");
}
if (!ObjectUtils.isEmpty(map.get("starttime"))) {
whereSql = whereSql + " and captureTime >= '" + map.get("starttime") +"'";
}
if (!ObjectUtils.isEmpty(map.get("endtime"))) {
whereSql = whereSql + " and captureTime <= '" + map.get("endtime") +"'";
}
if (ObjectUtils.isEmpty(map.get("starttime")) && ObjectUtils.isEmpty(map.get("endtime"))) {
int selectedTimeRange = (int) map.get("selectedTimeRange");
Date now = new Date();
String nowEnd = DateTimeUtil.getFormateString(DateTimeUtil.addDateDays(now, 1), Constant.YYYY_MM_DD);
String nowStart = DateTimeUtil.getFormateString(DateTimeUtil.addDateDays(now, -selectedTimeRange+1), Constant.YYYY_MM_DD);
whereSql = whereSql+ " and captureTime >= '" + nowStart + "' and captureTime <= '" + nowEnd +"'";
}
list =
gsCpDetailMapper.selectExportList(whereSql);
ExcelUtil.process(fileName, list, GSCpDetailExcel.class, response);
} catch (IOException e) {
log.error("[uuid:{}]-根据条件导出高速卡口数据失败,报错{}", uuid, e.getMessage());
throw new PPException(MessageEnum.Excel.getCode(), MessageEnum.Excel.getMessage());
}
log.info("[uuid:{}]-根据条件{},导出高速卡口数据完成,导出条数为{}", uuid, map,list.size());
}
@RequestMapping(value = "/exportGSRoughCpExcel", method = RequestMethod.POST)
public void exportGSRoughCpExcel(HttpServletResponse response,@RequestBody Map<String, Object> map) {
String fileName = "高速卡口数据";
String uuid = UuidUtil.getUuid();
log.info("[uuid:{}]-开始根据参数{}粗略查询高速卡口数据并导出到Excel", uuid, map);
List<GSCpDetailExcel> list;
try {
//String whereSql = " where 1=1 and spaceCode IS NOt NULL ";
String whereSql = " where 1=1 ";
if (!ObjectUtils.isEmpty(map.get("subcomno"))) {
whereSql = whereSql + " and t1.subcomno= " + map.get("subcomno") ;
}
if (!ObjectUtils.isEmpty(map.get("lineid"))) {
whereSql = whereSql + " and t1.lineid= '" + map.get("lineid") +"'";
}
if (!ObjectUtils.isEmpty(map.get("stationid"))) {
whereSql = whereSql + " and siteCode= '" + map.get("stationid") +"'";
}
if (!ObjectUtils.isEmpty(map.get("vehplate"))) {
whereSql = whereSql + " and plateNumber like '%" + StringUtils.trimAllWhitespace(map.get("vehplate").toString().toUpperCase())+"%'";
}
if (ObjectUtils.isNotEmpty(map.get("spaceInOrOut")) && 0 != (int)map.get("spaceInOrOut")) {
whereSql = whereSql + " and t.spaceInOrOut ="+map.get("spaceInOrOut");
}
if (ObjectUtils.isNotEmpty(map.get("selectedTimeRange"))) {
int selectedTimeRange = (int) map.get("selectedTimeRange");
Date now = new Date();
String nowEnd = DateTimeUtil.getFormateString(DateTimeUtil.addDateDays(now, 1), Constant.YYYY_MM_DD);
String nowStart = DateTimeUtil.getFormateString(DateTimeUtil.addDateDays(now, -selectedTimeRange+1), Constant.YYYY_MM_DD);
whereSql = whereSql+ " and captureTime >= '" + nowStart + "' and captureTime <= '" + nowEnd +"'";
}
list =
gsCpDetailMapper.selectExportList(whereSql);
ExcelUtil.process(fileName, list, GSCpDetailExcel.class, response);
} catch (IOException e) {
log.error("[uuid:{}]-根据条件粗略查询导出高速卡口数据失败,报错{}", uuid, e.getMessage());
throw new PPException(MessageEnum.Excel.getCode(), MessageEnum.Excel.getMessage());
}
log.info("[uuid:{}]-根据条件{},粗略查询导出高速卡口数据完成,导出条数为{}", uuid, map,list.size());
}
@RequestMapping(value = "/exportRoughVdExcel", method = RequestMethod.POST)
public void exportRoughVdExcel(HttpServletResponse response,@RequestBody Map<String, Object> map) {
String fileName = "车型识别数据";
String uuid = UuidUtil.getUuid();
log.info("[uuid:{}]-开始根据参数{}粗略查询车型识别数据并导出到Excel", uuid, map);
List<VdDetailExcel> list;
try {
String whereSql = " where 1=1 ";
if (!ObjectUtils.isEmpty(map.get("subcomno"))) {
whereSql = whereSql + " and t.subcomno= " + map.get("subcomno") ;
}
if (!ObjectUtils.isEmpty(map.get("lineid"))) {
whereSql = whereSql + " and t1.lineid= '" + map.get("lineid") +"'";
}
if (!ObjectUtils.isEmpty(map.get("stationid"))) {
whereSql = whereSql + " and t.siteCode= '" + map.get("stationid") +"'";
}
if (!ObjectUtils.isEmpty(map.get("vehplate"))) {
whereSql = whereSql + " and t.vehicleplate like '%" + StringUtils.trimAllWhitespace(map.get("vehplate").toString().toUpperCase())+"%'";
}
if (!ObjectUtils.isEmpty(map.get("vehicleColor"))) {
whereSql = whereSql + " and t.vehicleColor =" + map.get("vehicleColor") ;
}
if (!ObjectUtils.isEmpty(map.get("vehicleType"))) {
whereSql = whereSql + " and t.identifyType =" + map.get("vehicleType") ;
}
if (ObjectUtils.isEmpty(map.get("selectedTimeRange"))) {
int selectedTimeRange = (int) map.get("selectedTimeRange");
Date now = new Date();
String nowEnd = DateTimeUtil.getFormateString(DateTimeUtil.addDateDays(now, 1), Constant.YYYY_MM_DD);
String nowStart = DateTimeUtil.getFormateString(DateTimeUtil.addDateDays(now, -selectedTimeRange + 1), Constant.YYYY_MM_DD);
whereSql = whereSql+ " and t.picTime >= '" + nowStart + "' and t.picTime <= '" + nowEnd +"'";
}
list =
vdDetailMapper.selectVdExcelList(whereSql);
ExcelUtil.process(fileName, list, VdDetailExcel.class, response);
} catch (IOException e) {
log.error("[uuid:{}]-根据条件导出粗略查询车型识别失败,报错{}", uuid, e.getMessage());
throw new PPException(MessageEnum.Excel.getCode(), MessageEnum.Excel.getMessage());
}
log.info("[uuid:{}]-根据条件{},导出粗略查询车型识别数据完成,导出条数为{}", uuid, map,list.size());
}
@RequestMapping(value = "/exportVdExcel", method = RequestMethod.POST)
public void exportVdExcel(HttpServletResponse response,@RequestBody Map<String, Object> map) {
String fileName = "车型识别数据";
String uuid = UuidUtil.getUuid();
log.info("[uuid:{}]-开始根据参数{}精准查询车型识别数据并导出到Excel", uuid, map);
List<VdDetailExcel> list;
try {
String whereSql = " where 1=1 ";
if (!ObjectUtils.isEmpty(map.get("subcomno"))) {
whereSql = whereSql + " and t.subcomno= " + map.get("subcomno") ;
}
if (!ObjectUtils.isEmpty(map.get("lineid"))) {
whereSql = whereSql + " and t1.lineid= '" + map.get("lineid") +"'";
}
if (!ObjectUtils.isEmpty(map.get("stationid"))) {
whereSql = whereSql + " and t.siteCode= '" + map.get("stationid") +"'";
}
if (!ObjectUtils.isEmpty(map.get("vehplate"))) {
whereSql = whereSql + " and t.vehicleplate like '%" +StringUtils.trimAllWhitespace(map.get("vehplate").toString().toUpperCase())+"%'";
}
if (!ObjectUtils.isEmpty(map.get("plateColor"))) {
whereSql = whereSql + " and t.plateColor =" + map.get("plateColor");
}
if (!ObjectUtils.isEmpty(map.get("vehicleColor"))) {
whereSql = whereSql + " and t.vehicleColor =" + map.get("vehicleColor") ;
}
if (!ObjectUtils.isEmpty(map.get("vehicleType"))) {
whereSql = whereSql + " and t.identifyType =" + map.get("vehicleType") ;
}
if (!ObjectUtils.isEmpty(map.get("starttime"))) {
whereSql = whereSql + " and t.picTime >= '" + map.get("starttime") +"'";
}
if (!ObjectUtils.isEmpty(map.get("endtime"))) {
whereSql = whereSql + " and t.picTime <= '" + map.get("endtime") +"'";
}
if (ObjectUtils.isEmpty(map.get("starttime")) && ObjectUtils.isEmpty(map.get("endtime"))) {
int selectedTimeRange = (int) map.get("selectedTimeRange");
Date now = new Date();
String nowEnd = DateTimeUtil.getFormateString(DateTimeUtil.addDateDays(now, 1), Constant.YYYY_MM_DD);
String nowStart = DateTimeUtil.getFormateString(DateTimeUtil.addDateDays(now, -selectedTimeRange + 1), Constant.YYYY_MM_DD);
whereSql = whereSql+ " and t.picTime >= '" + nowStart + "' and t.picTime <= '" + nowEnd +"'";
}
list =
vdDetailMapper.selectVdExcelList(whereSql);
ExcelUtil.process(fileName, list, VdDetailExcel.class, response);
} catch (IOException e) {
log.error("[uuid:{}]-根据条件导出精准查询车型识别数据失败,报错{}", uuid, e.getMessage());
throw new PPException(MessageEnum.Excel.getCode(), MessageEnum.Excel.getMessage());
}
log.info("[uuid:{}]-根据条件{},导出精准查询车型识别数据完成,导出条数为{}", uuid, map,list.size());
}
@RequestMapping(value = "/OverExcel", method = RequestMethod.POST)
public void OverExcel(HttpServletResponse response,@RequestBody Map<String, Object> map) {
String fileName = "治超数据";
String uuid = UuidUtil.getUuid();
log.info("[uuid:{}]-开始根据参数{}精准查询治超数据并导出到Excel", uuid, map);
List<OverDetailExcel> list;
Map<String, Object> params = new HashMap<>();
try {
assignmentParams(map, params);
list =
overLoadDetailMapper.selectOverExcelList(params);
ExcelUtil.process(fileName, list, OverDetailExcel.class, response);
} catch (IOException e) {
log.error("[uuid:{}]-根据条件导出精准查询治超数据失败,报错{}", uuid, e.getMessage());
throw new PPException(MessageEnum.Excel.getCode(), MessageEnum.Excel.getMessage());
}
log.info("[uuid:{}]-根据条件{},导出精准查询治超数据完成,导出条数为{}", uuid, map,list.size());
}
public static void assignmentParams(@RequestBody Map<String, Object> map, Map<String, Object> params) {
if (ObjectUtils.isNotEmpty(map.get("subcomno"))) {
params.put("subcomno", map.get("subcomno"));
}
if (ObjectUtils.isNotEmpty(map.get("lineid"))) {
params.put("lineid", map.get("lineid"));
}
if (ObjectUtils.isNotEmpty(map.get("stationid"))) {
params.put("stationid", map.get("stationid"));
}
if (ObjectUtils.isNotEmpty(map.get("vehplate"))) {
params.put("vehplate", StringUtils.trimAllWhitespace(map.get("vehplate").toString().toUpperCase()));
}
if (ObjectUtils.isNotEmpty(map.get("plateColor"))) {
params.put("plateColor", map.get("plateColor").toString());
}
if (ObjectUtils.isNotEmpty(map.get("overlimitflag")) && 0 != (int) map.get("overlimitflag")) {
params.put("overlimitflag", map.get("overlimitflag"));
if (ObjectUtils.isNotEmpty(map.get("limitrange"))) {
String limitrange = (String) map.get("limitrange");
if (limitrange.contains(Constant.STR_COMMA)) {
String[] split = limitrange.split(Constant.STR_COMMA);
int limitstart = Integer.parseInt(split[0]);
int limitend = Integer.parseInt(split[1]);
params.put("limitstart", limitstart);
params.put("limitend", limitend);
} else {
int limitstart = Integer.parseInt(limitrange);
params.put("limitstart", limitstart);
}
}
}
if (ObjectUtils.isNotEmpty(map.get("starttime"))) {
params.put("starttime", map.get("starttime"));
}
if (ObjectUtils.isNotEmpty(map.get("endtime"))) {
params.put("endtime", map.get("endtime"));
}
if (ObjectUtils.isEmpty(map.get("starttime")) && ObjectUtils.isEmpty(map.get("endtime"))) {
int selectedTimeRange = (int) map.get("selectedTimeRange");
Date now = new Date();
String nowEnd = DateTimeUtil.getFormateString(DateTimeUtil.addDateDays(now, 1), Constant.YYYY_MM_DD);
String nowStart = DateTimeUtil.getFormateString(DateTimeUtil.addDateDays(now, -selectedTimeRange + 1), Constant.YYYY_MM_DD);
params.put("starttime",nowStart);
params.put("endtime", nowEnd);
}
if (ObjectUtils.isNotEmpty(map.get("axiscountStart")) && ObjectUtils.isNotEmpty(map.get("axiscountEnd"))) {
params.put("axiscountStart", map.get("axiscountStart"));
params.put("axiscountEnd", map.get("axiscountEnd"));
}
if (ObjectUtils.isNotEmpty(map.get("inweightStart")) && ObjectUtils.isNotEmpty(map.get("inweightEnd"))) {
params.put("inweightStart", map.get("inweightStart"));
params.put("inweightEnd", map.get("inweightEnd"));
}
if (ObjectUtils.isNotEmpty(map.get("discountWeightStart")) && ObjectUtils.isNotEmpty(map.get("discountWeightEnd"))) {
params.put("discountWeightStart", map.get("discountWeightStart"));
params.put("discountWeightEnd", map.get("discountWeightEnd"));
}
if (ObjectUtils.isNotEmpty(map.get("overWeightStart")) && ObjectUtils.isNotEmpty(map.get("overWeightEnd"))) {
params.put("overWeightStart", map.get("overWeightStart"));
params.put("overWeightEnd", map.get("overWeightEnd"));
}
}
@RequestMapping(value = "/exportRoughOverExcel", method = RequestMethod.POST)
public void exportRoughOverExcel(HttpServletResponse response,@RequestBody Map<String, Object> map) {
String fileName = "治超数据";
String uuid = UuidUtil.getUuid();
log.info("[uuid:{}]-开始根据参数{}粗略查询治超数据并导出到Excel", uuid, map);
List<OverDetailExcel> list;
Map<String, Object> params = new HashMap<>();
try {
if (ObjectUtils.isNotEmpty(map.get("subcomno"))) {
params.put("subcomno", map.get("subcomno"));
}
if (ObjectUtils.isNotEmpty(map.get("lineid"))) {
params.put("lineid", map.get("lineid"));
}
if (ObjectUtils.isNotEmpty(map.get("stationid"))) {
params.put("stationid", map.get("stationid"));
}
if (ObjectUtils.isNotEmpty(map.get("vehplate"))) {
params.put("vehplate", org.springframework.util.StringUtils.trimAllWhitespace(map.get("vehplate").toString().toUpperCase()));
}
if (ObjectUtils.isNotEmpty(map.get("plateColor"))) {
params.put("plateColor", map.get("plateColor").toString());
}
if (ObjectUtils.isNotEmpty(map.get("overlimitflag")) && 0 != (int) map.get("overlimitflag")) {
params.put("overlimitflag", map.get("overlimitflag"));
if (ObjectUtils.isNotEmpty(map.get("limitrange"))) {
String limitrange = (String) map.get("limitrange");
if (limitrange.contains(Constant.STR_COMMA)) {
String[] split = limitrange.split(Constant.STR_COMMA);
int limitstart = Integer.parseInt(split[0]);
int limitend = Integer.parseInt(split[1]);
params.put("limitstart", limitstart);
params.put("limitend", limitend);
} else {
int limitstart = Integer.parseInt(limitrange);
params.put("limitstart", limitstart);
}
}
}
if (ObjectUtils.isNotEmpty(map.get("selectedTimeRange"))) {
int selectedTimeRange = (int) map.get("selectedTimeRange");
Date now = new Date();
String nowEnd = DateTimeUtil.getFormateString(DateTimeUtil.addDateDays(now, 1), Constant.YYYY_MM_DD);
String nowStart = DateTimeUtil.getFormateString(DateTimeUtil.addDateDays(now, -selectedTimeRange + 1), Constant.YYYY_MM_DD);
params.put("starttime",nowStart);
params.put("endtime", nowEnd);
}
list =
overLoadDetailMapper.selectOverExcelList(params);
ExcelUtil.process(fileName, list, OverDetailExcel.class, response);
} catch (IOException e) {
log.error("[uuid:{}]-根据条件导出粗略查询治超数据失败,报错{}", uuid, e.getMessage());
throw new PPException(MessageEnum.Excel.getCode(), MessageEnum.Excel.getMessage());
}
log.info("[uuid:{}]-根据条件{},导出粗略查询治超数据完成,导出条数为{}", uuid, map,list.size());
}
@RequestMapping(value = "/exportRoughFixedPointExcel", method = RequestMethod.POST)
public void exportRoughFixedPointExcel(HttpServletResponse response,@RequestBody Map<String, Object> map) {
String fileName = "定点测速数据";
String uuid = UuidUtil.getUuid();
log.info("[uuid:{}]-开始根据参数{}粗略查询定点测速数据并导出到Excel", uuid, map);
List<FixedPointExcel> list;
try {
//String whereSql = " where 1=1 and spaceCode in( NULL ,'')";
String whereSql = " where 1=1 ";
if (!ObjectUtils.isEmpty(map.get("subcomno"))) {
whereSql = whereSql + " and t1.subcomno= " + map.get("subcomno") ;
}
if (!ObjectUtils.isEmpty(map.get("lineid"))) {
whereSql = whereSql + " and t1.lineid= '" + map.get("lineid") +"'";
}
if (!ObjectUtils.isEmpty(map.get("stationid"))) {
whereSql = whereSql + " and siteCode= '" + map.get("stationid") +"'";
}
if (!ObjectUtils.isEmpty(map.get("vehplate"))) {
whereSql = whereSql + " and plateNumber like '%" + StringUtils.trimAllWhitespace(map.get("vehplate").toString().toUpperCase())+"%'";
}
if (ObjectUtils.isNotEmpty(map.get("overspeedflag")) && 2 != (int)map.get("overspeedflag")) {
if(0 == (int)map.get("overspeedflag")){
whereSql = whereSql + " and t.vehicleSpeed <= t.limitSpeed";
}else if(1 == (int)map.get("overspeedflag")){
whereSql = whereSql + " and t.vehicleSpeed > t.limitSpeed";
}
}
if (ObjectUtils.isNotEmpty(map.get("selectedTimeRange"))) {
int selectedTimeRange = (int) map.get("selectedTimeRange");
Date now = new Date();
String nowEnd = DateTimeUtil.getFormateString(DateTimeUtil.addDateDays(now, 1), Constant.YYYY_MM_DD);
String nowStart = DateTimeUtil.getFormateString(DateTimeUtil.addDateDays(now, -selectedTimeRange+1), Constant.YYYY_MM_DD);
whereSql = whereSql+ " and captureTime >= '" + nowStart + "' and captureTime <= '" + nowEnd +"'";
}
list =
fpDetailMapper.selectFixedPointExcelList(whereSql);
ExcelUtil.process(fileName, list, FixedPointExcel.class, response);
} catch (IOException e) {
log.error("[uuid:{}]-根据条件导出粗略查询定点测速数据失败,报错{}", uuid, e.getMessage());
throw new PPException(MessageEnum.Excel.getCode(), MessageEnum.Excel.getMessage());
}
log.info("[uuid:{}]-根据条件{},导出粗略查询定点测速数据完成,导出条数为{}", uuid, map,list.size());
}
@RequestMapping(value = "/FixedPointExcel", method = RequestMethod.POST)
public void FixedPointExcel(HttpServletResponse response,@RequestBody Map<String, Object> map) {
String fileName = "定点测速数据";
String uuid = UuidUtil.getUuid();
log.info("[uuid:{}]-开始根据参数{}查询定点测速数据并导出到Excel", uuid, map);
List<FixedPointExcel> list;
try {
//String whereSql = " where 1=1 and spaceCode in( NULL ,'')";
String whereSql = " where 1=1 ";
if (!ObjectUtils.isEmpty(map.get("subcomno"))) {
whereSql = whereSql + " and t1.subcomno= " + map.get("subcomno") ;
}
if (!ObjectUtils.isEmpty(map.get("lineid"))) {
whereSql = whereSql + " and t1.lineid= '" + map.get("lineid") +"'";
}
if (!ObjectUtils.isEmpty(map.get("plateColor"))) {
whereSql = whereSql + " and plateColor= " + map.get("plateColor") ;
}
if (!ObjectUtils.isEmpty(map.get("plateType"))) {
whereSql = whereSql + " and plateType= " + map.get("plateType") ;
}
if (!ObjectUtils.isEmpty(map.get("vehicleType"))) {
whereSql = whereSql + " and vehicleType= " + map.get("vehicleType") ;
}
if (!ObjectUtils.isEmpty(map.get("vehicleColor"))) {
whereSql = whereSql + " and vehicleColor= " + map.get("vehicleColor") ;
}
if (!ObjectUtils.isEmpty(map.get("stationid"))) {
whereSql = whereSql + " and siteCode= '" + map.get("stationid") +"'";
}
if (!ObjectUtils.isEmpty(map.get("vehplate"))) {
whereSql = whereSql + " and plateNumber like '%" + StringUtils.trimAllWhitespace(map.get("vehplate").toString().toUpperCase())+"%'";
}
if (!ObjectUtils.isEmpty(map.get("starttime"))) {
whereSql = whereSql + " and captureTime >= '" + map.get("starttime") +"'";
}
if (!ObjectUtils.isEmpty(map.get("endtime"))) {
whereSql = whereSql + " and captureTime <= '" + map.get("endtime") +"'";
}
if (ObjectUtils.isNotEmpty(map.get("overspeedflag")) && 2 != (int)map.get("overspeedflag")) {
if(0 == (int)map.get("overspeedflag")){
whereSql = whereSql + " and t.vehicleSpeed <= t.limitSpeed";
}else if(1 == (int)map.get("overspeedflag")){
whereSql = whereSql + " and t.vehicleSpeed > t.limitSpeed";
}
}
if (ObjectUtils.isEmpty(map.get("starttime")) && ObjectUtils.isEmpty(map.get("endtime"))) {
int selectedTimeRange = (int) map.get("selectedTimeRange");
Date now = new Date();
String nowEnd = DateTimeUtil.getFormateString(DateTimeUtil.addDateDays(now, 1), Constant.YYYY_MM_DD);
String nowStart = DateTimeUtil.getFormateString(DateTimeUtil.addDateDays(now, -selectedTimeRange+1), Constant.YYYY_MM_DD);
whereSql = whereSql+ " and captureTime >= '" + nowStart + "' and captureTime <= '" + nowEnd +"'";
}
list =
fpDetailMapper.selectFixedPointExcelList(whereSql);
ExcelUtil.process(fileName, list, FixedPointExcel.class, response);
} catch (IOException e) {
log.error("[uuid:{}]-根据条件导出定点测速数据失败,报错{}", uuid, e.getMessage());
throw new PPException(MessageEnum.Excel.getCode(), MessageEnum.Excel.getMessage());
}
log.info("[uuid:{}]-根据条件{},导出定点测速数据完成,导出条数为{}", uuid, map,list.size());
}
@RequestMapping(value = "/CpExcel", method = RequestMethod.POST)
public void CpExcel(HttpServletResponse response,@RequestBody Map<String, Object> map) {
String fileName = "区间卡口数据";
String uuid = UuidUtil.getUuid();
log.info("[uuid:{}]-开始根据参数{}查询区间卡口数据并导出到Excel", uuid, map);
List<CpDetailExcel> list;
try {
String whereSql = " where 1=1 and spaceCode IS NOt NULL ";
//String whereSql = " where 1=1 and spaceCode not in( NULL ,'') ";
if (!ObjectUtils.isEmpty(map.get("subcomno"))) {
whereSql = whereSql + " and t1.subcomno= " + map.get("subcomno") ;
}
if (!ObjectUtils.isEmpty(map.get("lineid"))) {
whereSql = whereSql + " and t1.lineid= '" + map.get("lineid") +"'";
}
if (!ObjectUtils.isEmpty(map.get("plateColor"))) {
whereSql = whereSql + " and plateColor= " + map.get("plateColor") ;
}
if (!ObjectUtils.isEmpty(map.get("plateType"))) {
whereSql = whereSql + " and plateType= " + map.get("plateType") ;
}
if (!ObjectUtils.isEmpty(map.get("vehicleType"))) {
whereSql = whereSql + " and vehicleType= " + map.get("vehicleType") ;
}
if (!ObjectUtils.isEmpty(map.get("vehicleColor"))) {
whereSql = whereSql + " and vehicleColor= " + map.get("vehicleColor") ;
}
if (!ObjectUtils.isEmpty(map.get("stationid"))) {
whereSql = whereSql + " and siteCode= '" + map.get("stationid") +"'";
}
if (!ObjectUtils.isEmpty(map.get("vehplate"))) {
whereSql = whereSql + " and plateNumber like '%" + StringUtils.trimAllWhitespace(map.get("vehplate").toString().toUpperCase())+"%'";
}
if (ObjectUtils.isNotEmpty(map.get("spaceInOrOut")) && 0 != (int)map.get("spaceInOrOut")) {
whereSql = whereSql + " and t.spaceInOrOut ="+map.get("spaceInOrOut");
}
if (!ObjectUtils.isEmpty(map.get("starttime"))) {
whereSql = whereSql + " and captureTime >= '" + map.get("starttime") +"'";
}
if (!ObjectUtils.isEmpty(map.get("endtime"))) {
whereSql = whereSql + " and captureTime <= '" + map.get("endtime") +"'";
}
if (ObjectUtils.isEmpty(map.get("starttime")) && ObjectUtils.isEmpty(map.get("endtime"))) {
int selectedTimeRange = (int) map.get("selectedTimeRange");
Date now = new Date();
String nowEnd = DateTimeUtil.getFormateString(DateTimeUtil.addDateDays(now, 1), Constant.YYYY_MM_DD);
String nowStart = DateTimeUtil.getFormateString(DateTimeUtil.addDateDays(now, -selectedTimeRange+1), Constant.YYYY_MM_DD);
whereSql = whereSql+ " and captureTime >= '" + nowStart + "' and captureTime <= '" + nowEnd +"'";
}
list =
cpDetailMapper.selectExportList(whereSql);
ExcelUtil.process(fileName, list, CpDetailExcel.class, response);
} catch (IOException e) {
log.error("[uuid:{}]-根据条件导出区间卡口数据失败,报错{}", uuid, e.getMessage());
throw new PPException(MessageEnum.Excel.getCode(), MessageEnum.Excel.getMessage());
}
log.info("[uuid:{}]-根据条件{},导出区间卡口数据完成,导出条数为{}", uuid, map,list.size());
}
@RequestMapping(value = "/exportRoughCpExcel", method = RequestMethod.POST)
public void exportRoughCpExcel(HttpServletResponse response,@RequestBody Map<String, Object> map) {
String fileName = "区间卡口数据";
String uuid = UuidUtil.getUuid();
log.info("[uuid:{}]-开始根据参数{}粗略查询区间卡口数据并导出到Excel", uuid, map);
List<CpDetailExcel> list;
try {
String whereSql = " where 1=1 and spaceCode IS NOt NULL ";
if (!ObjectUtils.isEmpty(map.get("subcomno"))) {
whereSql = whereSql + " and t1.subcomno= " + map.get("subcomno") ;
}
if (!ObjectUtils.isEmpty(map.get("lineid"))) {
whereSql = whereSql + " and t1.lineid= '" + map.get("lineid") +"'";
}
if (!ObjectUtils.isEmpty(map.get("stationid"))) {
whereSql = whereSql + " and siteCode= '" + map.get("stationid") +"'";
}
if (!ObjectUtils.isEmpty(map.get("vehplate"))) {
whereSql = whereSql + " and plateNumber like '%" + StringUtils.trimAllWhitespace(map.get("vehplate").toString().toUpperCase())+"%'";
}
if (ObjectUtils.isNotEmpty(map.get("spaceInOrOut")) && 0 != (int)map.get("spaceInOrOut")) {
whereSql = whereSql + " and t.spaceInOrOut ="+map.get("spaceInOrOut");
}
if (ObjectUtils.isNotEmpty(map.get("selectedTimeRange"))) {
int selectedTimeRange = (int) map.get("selectedTimeRange");
Date now = new Date();
String nowEnd = DateTimeUtil.getFormateString(DateTimeUtil.addDateDays(now, 1), Constant.YYYY_MM_DD);
String nowStart = DateTimeUtil.getFormateString(DateTimeUtil.addDateDays(now, -selectedTimeRange+1), Constant.YYYY_MM_DD);
whereSql = whereSql+ " and captureTime >= '" + nowStart + "' and captureTime <= '" + nowEnd +"'";
}
list =
cpDetailMapper.selectExportList(whereSql);
ExcelUtil.process(fileName, list, CpDetailExcel.class, response);
} catch (IOException e) {
log.error("[uuid:{}]-根据条件粗略查询导出区间卡口数据失败,报错{}", uuid, e.getMessage());
throw new PPException(MessageEnum.Excel.getCode(), MessageEnum.Excel.getMessage());
}
log.info("[uuid:{}]-根据条件{},粗略查询导出区间卡口数据完成,导出条数为{}", uuid, map,list.size());
}
@RequestMapping(value = "/IsmExcel", method = RequestMethod.POST)
public void IsmExcel(HttpServletResponse response,@RequestBody Map<String, Object> map) {
String fileName = "区间测速数据";
String uuid = UuidUtil.getUuid();
log.info("[uuid:{}]-开始根据参数{}查询区间测速数据并导出到Excel", uuid, map);
List<IsmDetailExcel> list;
try {
String whereSql = " where 1=1 ";
if (!ObjectUtils.isEmpty(map.get("subcomno"))) {
whereSql = whereSql + " and t1.subcomno= " + map.get("subcomno") ;
}
if (!ObjectUtils.isEmpty(map.get("lineid"))) {
whereSql = whereSql + " and t1.lineid= '" + map.get("lineid") +"'";
}
if (!ObjectUtils.isEmpty(map.get("plateColor"))) {
whereSql = whereSql + " and plateColor= " + map.get("plateColor") ;
}
if (!ObjectUtils.isEmpty(map.get("plateType"))) {
whereSql = whereSql + " and plateType= " + map.get("plateType") ;
}
if (!ObjectUtils.isEmpty(map.get("vehicleType"))) {
whereSql = whereSql + " and vehicleType= " + map.get("vehicleType") ;
}
if (!ObjectUtils.isEmpty(map.get("vehicleColor"))) {
whereSql = whereSql + " and vehicleColor= " + map.get("vehicleColor") ;
}
if (!ObjectUtils.isEmpty(map.get("istationid"))) {
whereSql = whereSql + " and isiteCode= '" + map.get("istationid") +"'";
}
if (!ObjectUtils.isEmpty(map.get("stationid"))) {
whereSql = whereSql + " and siteCode= '" + map.get("stationid") +"'";
}
if (!ObjectUtils.isEmpty(map.get("vehplate"))) {
whereSql = whereSql + " and plateNumber like '%" + StringUtils.trimAllWhitespace(map.get("vehplate").toString().toUpperCase())+"%'";
}
if (!ObjectUtils.isEmpty(map.get("istarttime"))) {
whereSql = whereSql + " and icaptureTime >= '" + map.get("istarttime") +"'";
}
if (!ObjectUtils.isEmpty(map.get("iendtime"))) {
whereSql = whereSql + " and icaptureTime <= '" + map.get("iendtime") +"'";
}
if (!ObjectUtils.isEmpty(map.get("starttime"))) {
whereSql = whereSql + " and captureTime >= '" + map.get("starttime") +"'";
}
if (!ObjectUtils.isEmpty(map.get("endtime"))) {
whereSql = whereSql + " and captureTime <= '" + map.get("endtime") +"'";
}
if (ObjectUtils.isEmpty(map.get("istarttime")) && ObjectUtils.isEmpty(map.get("iendtime")) && ObjectUtils.isEmpty(map.get("starttime")) && ObjectUtils.isEmpty(map.get("endtime"))) {
int selectedTimeRange = (int) map.get("selectedTimeRange");
Date now = new Date();
String nowEnd = DateTimeUtil.getFormateString(DateTimeUtil.addDateDays(now, 1), Constant.YYYY_MM_DD);
String nowStart = DateTimeUtil.getFormateString(DateTimeUtil.addDateDays(now, -selectedTimeRange+1), Constant.YYYY_MM_DD);
whereSql = whereSql+ " and captureTime >= '" + nowStart + "' and captureTime <= '" + nowEnd +"'";
}
if (ObjectUtils.isNotEmpty(map.get("overspeedflag")) && 2 != (int)map.get("overspeedflag")) {
if(0 == (int)map.get("overspeedflag")){
whereSql = whereSql + " and t.rangeSpeed <= t.limitSpeed";
}else if(1 == (int)map.get("overspeedflag")){
whereSql = whereSql + " and t.rangeSpeed > t.limitSpeed";
}
}
if (ObjectUtils.isNotEmpty(map.get("percentageStart")) ) {
whereSql = whereSql +
" and ((t.rangeSpeed-t.limitSpeed)/t.limitSpeed) *100 >= "+map.get("percentageStart");
}
if (ObjectUtils.isNotEmpty(map.get("percentageEnd")) ) {
whereSql = whereSql + " and ((t.rangeSpeed-t.limitSpeed)/t.limitSpeed) *100 < " + map.get("percentageEnd");
}
list =
ismDetailMapper.selectExportList(whereSql);
ExcelUtil.process(fileName, list, IsmDetailExcel.class, response);
} catch (IOException e) {
log.error("[uuid:{}]-根据条件导出区间测速数据失败,报错{}", uuid, e.getMessage());
throw new PPException(MessageEnum.Excel.getCode(), MessageEnum.Excel.getMessage());
}
log.info("[uuid:{}]-根据条件{},导出区间测速数据完成,导出条数为{}", uuid, map,list.size());
}
@RequestMapping(value = "/roughIsmExcel", method = RequestMethod.POST)
public void roughIsmExcel(HttpServletResponse response,@RequestBody Map<String, Object> map) {
String fileName = "区间测速数据";
String uuid = UuidUtil.getUuid();
log.info("[uuid:{}]-开始根据参数{}粗略查询区间测速数据并导出到Excel", uuid, map);
List<IsmDetailExcel> list;
try {
String whereSql = " where 1=1 ";
if (!ObjectUtils.isEmpty(map.get("subcomno"))) {
whereSql = whereSql + " and t1.subcomno= " + map.get("subcomno") ;
}
if (!ObjectUtils.isEmpty(map.get("lineid"))) {
whereSql = whereSql + " and t1.lineid= '" + map.get("lineid") +"'";
}
if (!ObjectUtils.isEmpty(map.get("vehplate"))) {
whereSql = whereSql + " and plateNumber like '%" + StringUtils.trimAllWhitespace(map.get("vehplate").toString().toUpperCase())+"%'";
}
if (ObjectUtils.isNotEmpty(map.get("overspeedflag")) && 2 != (int)map.get("overspeedflag")) {
if(0 == (int)map.get("overspeedflag")){
whereSql = whereSql + " and t.rangeSpeed <= t.limitSpeed";
}else if(1 == (int)map.get("overspeedflag")){
whereSql = whereSql + " and t.rangeSpeed > t.limitSpeed";
}
}
if (ObjectUtils.isNotEmpty(map.get("selectedTimeRange"))) {
int selectedTimeRange = (int) map.get("selectedTimeRange");
Date now = new Date();
String nowEnd = DateTimeUtil.getFormateString(DateTimeUtil.addDateDays(now, 1), Constant.YYYY_MM_DD);
String nowStart = DateTimeUtil.getFormateString(DateTimeUtil.addDateDays(now, -selectedTimeRange), Constant.YYYY_MM_DD);
whereSql = whereSql+ " and icaptureTime >= '" + nowStart + "' and icaptureTime <= '" + nowEnd +"'";
}
list =
ismDetailMapper.selectExportList(whereSql);
ExcelUtil.process(fileName, list, IsmDetailExcel.class, response);
} catch (IOException e) {
log.error("[uuid:{}]-根据条件导出粗略查询区间测速数据失败,报错{}", uuid, e.getMessage());
throw new PPException(MessageEnum.Excel.getCode(), MessageEnum.Excel.getMessage());
}
log.info("[uuid:{}]-根据条件{},导出粗略查询区间测速数据完成,导出条数为{}", uuid, map,list.size());
}
}