绿通后台代码提交

master
gsy 10 months ago
parent dfad15be6d
commit 20b0c6127f

@ -179,7 +179,11 @@
<version>3.2.5</version>
</dependency>
<dependency>
<groupId>com.goldendb</groupId>
<artifactId>goldendb</artifactId>
<version>5.1.46.67</version>
</dependency>
<dependency>
@ -187,6 +191,11 @@
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
</dependency>
</dependencies>

@ -1,14 +1,24 @@
package com.nmgs;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.data.redis.LettuceClientConfigurationBuilderCustomizer;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
@EnableAsync
@SpringBootApplication
//@MapperScan(basePackages = {"com.nmgs.mapper.green"}, sqlSessionFactoryRef = "sqlSessionFactoryGreen")
//@MapperScan(basePackages = {"com.nmgs.mapper.check"}, sqlSessionFactoryRef = "sqlSessionFactoryCheck")
@EnableScheduling //开启任务调度
public class GreenTrafficApplication extends SpringBootServletInitializer {
@Override
@ -21,4 +31,14 @@ public class GreenTrafficApplication extends SpringBootServletInitializer {
SpringApplication.run(GreenTrafficApplication.class, args);
}
@Bean
public TaskScheduler taskScheduler() {
//注入定时器线程池,一次定时器,处理三次数据
ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
taskScheduler.setPoolSize(10);
return taskScheduler;
}
}

@ -40,17 +40,34 @@ public class MyEnvironmentPostProcessor implements EnvironmentPostProcessor {
String DBType = properties.getProperty("DBType") == null ? "1" : properties.getProperty("DBType");
Newproperties.load(new FileInputStream(NewPath));
properties.setProperty("spring.logback.logPath",PathUtil.TomcatPath+"/logs");
properties.setProperty("spring.datasource.url",properties.getProperty("DBUrl"));
properties.setProperty("spring.datasource.username",properties.getProperty("DBUserName"));
System.out.println(properties.getProperty("DBPassWord"));
//System.out.println(PassWordUtils.encrypt("sysadmin"));
System.out.println(PassWordUtils.decrypt(properties.getProperty("DBPassWord")));
System.out.println(properties.getProperty("DBPassWord").toCharArray().length);
properties.setProperty("spring.datasource.password",PassWordUtils.decrypt(properties.getProperty("DBPassWord")));
properties.setProperty("spring.datasource.password",PassWordUtils.decrypt(properties.getProperty("DBPassWord")));
// properties.setProperty("spring.datasource.db-green.jdbc-url",properties.getProperty("DBUrl"));
// properties.setProperty("spring.datasource.db-green.username",properties.getProperty("DBUserName"));
// properties.setProperty("spring.datasource.db-green.password",PassWordUtils.decrypt(properties.getProperty("DBPassWord")));
// properties.setProperty("spring.datasource.db-green.jdbc-url",properties.getProperty("GreenDBUrl"));
// properties.setProperty("spring.datasource.db-green.username",properties.getProperty("GreenDBUserName"));
// properties.setProperty("spring.datasource.db-green.password",PassWordUtils.decrypt(properties.getProperty("GreenDBPassWord")));
//
//
// properties.setProperty("spring.datasource.db-check.jdbc-url",properties.getProperty("ResultDBUrl"));
// properties.setProperty("spring.datasource.db-check.username",properties.getProperty("ResultDBUserName"));
// properties.setProperty("spring.datasource.db-check.password",PassWordUtils.decrypt(properties.getProperty("ResultDBPassWord")));
if(null != properties.getProperty("IsGolDen") && properties.getProperty("IsGolDen").equals("1")){
properties.setProperty("spring.datasource.driver-class-name",Newproperties.getProperty("GoldenClassName"));
properties.setProperty("spring.datasource.validationQuery",Newproperties.getProperty("MySQLvalidationQuery"));
properties.setProperty("spring.datasource.hikari.connection-test-query",Newproperties.getProperty("MySQLvalidationQuery"));
}else{
if(DBType.equals("1")){
properties.setProperty("spring.datasource.driver-class-name",Newproperties.getProperty("sqlClassName"));
properties.setProperty("spring.datasource.validationQuery",Newproperties.getProperty("sqlvalidationQuery"));
@ -68,6 +85,7 @@ public class MyEnvironmentPostProcessor implements EnvironmentPostProcessor {
properties.setProperty("spring.datasource.validationQuery",Newproperties.getProperty("MySQLvalidationQuery"));
properties.setProperty("spring.datasource.hikari.connection-test-query",Newproperties.getProperty("MySQLvalidationQuery"));
}
}
System.out.println("---------------------------GreenTraffic本次载入数据库----------------------");
System.out.println("server.port: " + properties.getProperty("server.port"));

@ -37,7 +37,13 @@ public class CorsConfig implements WebMvcConfigurer {
"/ETCLanePay/**",
"/Manager/**",
"/queryPage/**",
"/staSubcomCollection/**",
"/staDetilCollection/**",
"/freightCollection/**",
"/index/**",
"/carTrack/**",
"/printView/**",
"/trackMap/**",
"/logManager/**",
"/wxCarUserInfo/**",
"/showStanEcharts/**",

@ -0,0 +1,40 @@
//package com.nmgs.config;
//
//
//import com.baomidou.mybatisplus.core.MybatisConfiguration;
//import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
//import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
//import org.apache.ibatis.session.SqlSessionFactory;
//import org.mybatis.spring.SqlSessionTemplate;
//import org.mybatis.spring.annotation.MapperScan;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Qualifier;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
//
//import javax.sql.DataSource;
//
//@Configuration
//@MapperScan(basePackages = {"com.nmgs.mapper.check"}, sqlSessionFactoryRef = "sqlSessionFactoryCheck")
//public class DBSrcCheck {
//
// @Autowired
// MybatisPlusInterceptor mybatisPlusInterceptor;
// @Bean
// public SqlSessionFactory sqlSessionFactoryCheck(@Qualifier("db_check") DataSource dataSource) throws Exception {
// MybatisSqlSessionFactoryBean sqlSessionFactory = new MybatisSqlSessionFactoryBean();
// sqlSessionFactory.setDataSource(dataSource);
// MybatisConfiguration configuration = new MybatisConfiguration();
// configuration.addInterceptor(mybatisPlusInterceptor);
// sqlSessionFactory.setConfiguration(configuration);
//// sqlSessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver()
//// .getResources("classpath:mapper/check/**/*.xml"));
// return sqlSessionFactory.getObject();
// }
//
// @Bean
// public SqlSessionTemplate sqlSessionTemplateCheck(@Qualifier("sqlSessionFactoryCheck") SqlSessionFactory sqlSessionFactory) throws Exception {
// return new SqlSessionTemplate(sqlSessionFactory);
// }
//}

@ -0,0 +1,48 @@
//package com.nmgs.config;
//
//
//
//import com.baomidou.mybatisplus.core.MybatisConfiguration;
//import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
//import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
//import org.apache.ibatis.session.SqlSessionFactory;
//import org.mybatis.spring.SqlSessionTemplate;
//import org.mybatis.spring.annotation.MapperScan;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Qualifier;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.Primary;
//import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
//
//import javax.sql.DataSource;
//
//
//@Configuration
//@MapperScan(basePackages = {"com.nmgs.mapper.green"}, sqlSessionFactoryRef = "sqlSessionFactoryGreen")
//public class DBSrcGreen {
//
// @Autowired
// MybatisPlusInterceptor mybatisPlusInterceptor;
//
//
// @Bean
// @Primary
// public SqlSessionFactory sqlSessionFactoryGreen(@Qualifier("db_green") DataSource dataSource) throws Exception {
// MybatisSqlSessionFactoryBean sqlSessionFactory = new MybatisSqlSessionFactoryBean();
// sqlSessionFactory.setDataSource(dataSource);
// // 添加分页插件
// MybatisConfiguration configuration = new MybatisConfiguration();
// configuration.addInterceptor(mybatisPlusInterceptor);
// sqlSessionFactory.setConfiguration(configuration);
//// sqlSessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver()
//// .getResources("classpath:mapper/green/**/*.xml"));
// return sqlSessionFactory.getObject();
// }
//
// @Bean
// @Primary
// public SqlSessionTemplate sqlSessionTemplateGreen(@Qualifier("sqlSessionFactoryGreen") SqlSessionFactory sqlSessionFactory) throws Exception {
// return new SqlSessionTemplate(sqlSessionFactory);
// }
//}

@ -0,0 +1,62 @@
//package com.nmgs.config;
//
//
//import com.zaxxer.hikari.HikariConfig;
//import com.zaxxer.hikari.HikariDataSource;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.boot.context.properties.ConfigurationProperties;
//import org.springframework.boot.jdbc.DataSourceBuilder;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.Primary;
//import javax.sql.DataSource;
//
//
//@Configuration
//public class DataSourceConfig {
// @Bean
// @ConfigurationProperties(prefix = "spring.datasource.hikari")
// public HikariConfig hikariConfig(){
// return new HikariConfig();
// }
//
// @Primary
// @Bean(name = "db_green")
// @ConfigurationProperties(prefix = "spring.datasource.db-green")
// public DataSource dBSrcGreen() {
//
// HikariDataSource hikariDataSource = new HikariDataSource();
// hikariDataSource.setMaximumPoolSize(hikariConfig().getMaximumPoolSize());
// hikariDataSource.setAutoCommit(hikariConfig().isAutoCommit());
// hikariDataSource.setIdleTimeout(hikariConfig().getIdleTimeout());
// hikariDataSource.setPoolName(hikariConfig().getPoolName());
// hikariDataSource.setMaxLifetime(hikariConfig().getMaxLifetime());
// hikariDataSource.setConnectionTimeout(hikariConfig().getConnectionTimeout());
// hikariDataSource.setMinimumIdle(hikariConfig().getMinimumIdle());
// hikariDataSource.setAllowPoolSuspension(hikariConfig().isAllowPoolSuspension());
// hikariDataSource.setRegisterMbeans(hikariConfig().isRegisterMbeans());
// hikariDataSource.setLeakDetectionThreshold(hikariConfig().getLeakDetectionThreshold());
//
// return hikariDataSource;
// }
//
// @Primary
// @Bean(name = "db_check")
// @ConfigurationProperties(prefix = "spring.datasource.db-check")
// public DataSource dBSrcCheck() {
//
// HikariDataSource hikariDataSource = new HikariDataSource();
// hikariDataSource.setMaximumPoolSize(hikariConfig().getMaximumPoolSize());
// hikariDataSource.setAutoCommit(hikariConfig().isAutoCommit());
// hikariDataSource.setIdleTimeout(hikariConfig().getIdleTimeout());
// hikariDataSource.setPoolName(hikariConfig().getPoolName());
// hikariDataSource.setMaxLifetime(hikariConfig().getMaxLifetime());
// hikariDataSource.setConnectionTimeout(hikariConfig().getConnectionTimeout());
// hikariDataSource.setMinimumIdle(hikariConfig().getMinimumIdle());
// hikariDataSource.setAllowPoolSuspension(hikariConfig().isAllowPoolSuspension());
// hikariDataSource.setRegisterMbeans(hikariConfig().isRegisterMbeans());
// hikariDataSource.setLeakDetectionThreshold(hikariConfig().getLeakDetectionThreshold());
//
// return hikariDataSource;
// }
//}

@ -17,8 +17,8 @@ public class ThreadPoolConfig {
public Executor executorNormal() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(4);
executor.setMaxPoolSize(10);
executor.setQueueCapacity(10);
executor.setMaxPoolSize(120);
executor.setQueueCapacity(30000);
executor.setKeepAliveSeconds(60);
executor.setThreadNamePrefix("NORMAL--");
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy());

@ -3,6 +3,7 @@ import com.nmgs.entity.GreenTrafficCheckResult;
import com.nmgs.mapper.GreenTrafficCheckResultMapper;
import com.nmgs.mapper.GreenTrafficMapper;
import com.nmgs.service.IGreenTrafficService;
import com.nmgs.util.PropertiesUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -12,6 +13,7 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -32,6 +34,7 @@ public class GreenTrafficController {
private GreenTrafficCheckResultMapper greenTrafficCheckResultMapper;
@PostMapping("/getGreenTrafficPage")
@ResponseBody
public Object getGreenTrafficPage(@RequestBody Map<String, Object> params){
@ -48,8 +51,8 @@ public class GreenTrafficController {
System.out.println(params);
Map<String, Object> resultMap = new HashMap<>();
if("N".equals(params.get("isChange"))){
resultMap.put("CarNoColorList", greenTrafficMapper.selectCarNoColorList());
resultMap.put("RoadList", greenTrafficMapper.selectRoadList());
resultMap.put("carNoColorList", greenTrafficMapper.selectCarNoColorList());
resultMap.put("roadList", greenTrafficMapper.selectRoadList());
resultMap.put("staList", greenTrafficMapper.selectStaList(params));
}else{
resultMap.put("staList", greenTrafficMapper.selectStaList(params));
@ -58,6 +61,15 @@ public class GreenTrafficController {
return resultMap;
}
@PostMapping("/getFreightTypes")
@ResponseBody
public Object getFreightTypes(@RequestBody Map<String, Object> params) {
System.out.println(params);
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("freightTypeList", greenTrafficMapper.selectFreightTypeList(params));
return resultMap;
}
@PostMapping("/getGreenTrafficCheckFromData")
@ -149,5 +161,130 @@ public class GreenTrafficController {
@PostMapping("/greenTotalCountByProvince")
@ResponseBody
public Object greenTotalCountByProvince(@RequestBody Map<String, Object> params){
return greenTrafficService.greenTotalCountByProvince(params);
}
@PostMapping("/getStaSubComCollectionData")
@ResponseBody
public Object getStaSubComCollectionData(@RequestBody Map<String, Object> params) {
// return greenTrafficService.getStaSubComCollectionData(params);
Map<String, Object> resultMap = new HashMap<>();
//从配置文件中读取数据库连接类型
params.put("DBTYPE", PropertiesUtil.getValue("DBType"));
resultMap.put("unionList", greenTrafficMapper.getGreenTrafficListGroupByUnionName(params));
resultMap.put("subComList", greenTrafficMapper.getGreenTrafficListGroupBySubCom(params));
return resultMap;
}
@PostMapping("/getStaSubComCollectionSearchData")
@ResponseBody
public Object getStaSubComCollectionSearchData(@RequestBody Map<String, Object> params) {
System.out.println(params);
Map<String, Object> resultMap = new HashMap<>();
if("N".equals(params.get("isChange"))){
resultMap.put("unionList", greenTrafficMapper.selectUnionList());
resultMap.put("staList", greenTrafficMapper.selectStaList(params));
}else{
resultMap.put("staList", greenTrafficMapper.selectStaList(params));
}
return resultMap;
}
@PostMapping("/getStaDetilCollection")
@ResponseBody
public Object getStaDetilCollection(@RequestBody Map<String, Object> params) {
return greenTrafficService.getStaDetilCollection(params);
}
@PostMapping("/getStaDetilSearchData")
@ResponseBody
public Object getStaDetilSearchData(@RequestBody Map<String, Object> params) {
System.out.println(params);
Map<String, Object> resultMap = new HashMap<>();
if("N".equals(params.get("isChange"))){
resultMap.put("subComList", greenTrafficMapper.selectSubComList());
resultMap.put("staList", greenTrafficMapper.selectStaList(params));
resultMap.put("roadList", greenTrafficMapper.selectRoadList());
}else{
resultMap.put("staList", greenTrafficMapper.selectStaList(params));
}
return resultMap;
}
@PostMapping("/getFigthTypeCollection")
@ResponseBody
public Object getStaFigthTypeCollectionByfreightType(@RequestBody Map<String, Object> params){
return greenTrafficService.getStaFigthTypeCollection(params);
}
@PostMapping("/getFigthTypeCollectionSearchData")
@ResponseBody
public Object getStaFigthTypeCollectionSearchData(@RequestBody Map<String, Object> params) {
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("unionList", greenTrafficMapper.selectUnionList());
resultMap.put("freightTypeList", greenTrafficMapper.selectFreightTypeList(params));
return resultMap;
}
@PostMapping("/getGreenTotalCollection")
@ResponseBody
public Object getGreenTotalCollection(@RequestBody Map<String, Object> params){
return greenTrafficService.getGreenTotalCollection(params);
}
@PostMapping("/getGreenFeeTotalCollection")
@ResponseBody
public Object getGreenFeeTotalCollection(@RequestBody Map<String, Object> params){
return greenTrafficService.getGreenFeeTotalCollection(params);
}
@PostMapping("/getFreightTotalCollection")
@ResponseBody
public Object getFreightTotalCollection(@RequestBody Map<String, Object> params){
return greenTrafficService.getFreightTotalCollection(params);
}
@PostMapping("/getUnionFreightCollection")
@ResponseBody
public Object getUnionFreightCollection(@RequestBody Map<String, Object> params){
return greenTrafficService.getUnionFreightCollection(params);
}
@PostMapping("/getSingleCarTrack")
@ResponseBody
public Object getSingleCarTrack(@RequestBody Map<String, Object> params){
//先判断车牌号码是否正确
List<Map<String, Object>> greenAcarNoByAcarNoStr = greenTrafficMapper.getGreenAcarNoByAcarNoStr(params);
if(null == greenAcarNoByAcarNoStr || greenAcarNoByAcarNoStr.isEmpty()){
return "输入的车牌号码再绿通流水中未找到";
}
return greenTrafficService.getSingleCarTrack(params);
}
@PostMapping("/getGreenAcarNoByAcarNoStr")
@ResponseBody
public Object getGreenAcarNoByAcarNoStr(@RequestBody Map<String, Object> params){
return greenTrafficMapper.getGreenAcarNoByAcarNoStr(params);
}
@PostMapping("/getMenuByUserIdAndMenId")
@ResponseBody
public Object getMenuByUserIdAndMenId(@RequestBody Map<String, Object> params){
return greenTrafficMapper.getMenuByUserIdAndMenId(params);
}
}

@ -0,0 +1,106 @@
package com.nmgs.controller;
import com.nmgs.mapper.GreenTrafficCheckResultMapper;
import com.nmgs.mapper.GreenTrafficMapper;
import com.nmgs.service.IGreenTrafficExportExcelService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
@Controller
@RequestMapping("/GreenTrafficExportExcel")
@CrossOrigin(origins = "*")
public class GreenTrafficExportExcelController {
public static Logger logger = LoggerFactory.getLogger(GreenTrafficExportExcelController.class);
@Autowired
private IGreenTrafficExportExcelService greenTrafficExportExcelService;
@Autowired
private GreenTrafficMapper greenTrafficMapper;
@Autowired
private GreenTrafficCheckResultMapper greenTrafficCheckResultMapper;
@GetMapping("/exportStaUnionCollectionExcle")
@ResponseBody
public void exportstaUnionCollectionExcle(String searchForm, HttpServletResponse response){
logger.info("searchForm============"+searchForm.toString());
try {
greenTrafficExportExcelService.exportstaUnionCollectionExcle(searchForm,response);
} catch (Exception e) {
logger.error("com.nmgs.controller.GreenTrafficExportExcelController.exportstaUnionCollectionExcle: 导出失败"+e);
}
}
@GetMapping("/exportStaCollectionExcle")
@ResponseBody
public void exportstaCollectionExcle(String searchForm, HttpServletResponse response){
logger.info("searchForm============"+searchForm.toString());
try {
greenTrafficExportExcelService.exportstaCollectionExcle(searchForm,response);
} catch (Exception e) {
logger.error("com.nmgs.controller.GreenTrafficExportExcelController.exportstaCollectionExcle: 导出失败"+e);
}
}
@GetMapping("/exportUnionFreightCollectionExcle")
@ResponseBody
public void exportUnionFreightCollectionExcle(String searchForm, HttpServletResponse response){
logger.info("searchForm============"+searchForm.toString());
try {
greenTrafficExportExcelService.exportUnionFreightCollectionExcle(searchForm,response);
} catch (Exception e) {
logger.error("com.nmgs.controller.GreenTrafficExportExcelController.exportUnionFreightCollectionExcle: 导出失败"+e);
}
}
@GetMapping("/exportSingleTrackExcle")
@ResponseBody
public void exportSingleTrackExcle(String searchForm, HttpServletResponse response){
logger.info("searchForm============"+searchForm.toString());
try {
greenTrafficExportExcelService.exportSingleTrackExcle(searchForm,response);
} catch (Exception e) {
logger.error("com.nmgs.controller.GreenTrafficExportExcelController.exportSingleTrackExcle: 导出失败"+e);
}
}
@GetMapping("/exportUnionTotalExcle")
@ResponseBody
public void exportUnionTotalExcle(String searchForm, HttpServletResponse response){
logger.info("searchForm============"+searchForm.toString());
try {
greenTrafficExportExcelService.exportUnionTotalExcle(searchForm,response);
} catch (Exception e) {
logger.error("com.nmgs.controller.GreenTrafficExportExcelController.exportSingleTrackExcle: 导出失败"+e);
}
}
@GetMapping("/exportSubComTotalExcle")
@ResponseBody
public void exportSubComTotalExcle(String searchForm, HttpServletResponse response){
logger.info("searchForm============"+searchForm.toString());
try {
greenTrafficExportExcelService.exportSubComTotalExcle(searchForm,response);
} catch (Exception e) {
logger.error("com.nmgs.controller.GreenTrafficExportExcelController.exportSingleTrackExcle: 导出失败"+e);
}
}
}

@ -0,0 +1,100 @@
package com.nmgs.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.github.jeffreyning.mybatisplus.anno.MppMultiId;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
@Data
@TableName("CHECK_RESULT_GREEN_FREIGHTTYPES")
@NoArgsConstructor
@AllArgsConstructor
public class CheckResultGreenFreightTypes {
@TableId(value = "TRANSACTIONID")
private String transActionId;
@TableField("FREIGHTTYPES")
private String freightTypes;
@TableField("CHECKTIME")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
private Date checkTime;
@TableField("LISTNO")
private String listNo;
@TableField("APPOINTMENTID")
private String appointmentId;
@TableField("CHECKID")
private String checkId;
@TableField("CHECKRESULT")
private Integer checkResult;
@TableField("CRATETYPE")
private Integer crateType;
@TableField("CRATETYPETEXT")
private String crateTypeText;
@TableField("DRIVERTELEPHONE")
private String driverTelephone;
@TableField("ENSTATIONID")
private String enStationId;
@TableField("ENWEIGHT")
private Integer enWeight;
@TableField("EXSTATIONID")
private String exStationId;
@TableField("EXTIME")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
private Date exTime;
@TableField("EXWEIGHT")
private Integer exWeight;
@TableField("INSPECTOR")
private String inspector;
@TableField("MEMO")
private String memo;
@TableField("PASSID")
private String passId;
@TableField("PAYFEE")
private Integer payFee;
@TableField("REASON")
private String reason;
@TableField("REVIEWER")
private String reviewer;
@TableField("VEHICLEID")
private String vehicleId;
@TableField("VEHICLETYPE")
private Integer vehicleType;
@TableField("RESULTTRANSACTIONID")
private String resultTransActionId;
@TableField(exist = false)
private String freightTypesText;
}

@ -64,6 +64,9 @@ public class GreenTraffic {;
@TableField("ID")
private String id;
@TableField("ISASYNC")
private String isAsync;
@TableField(exist = false)
@JsonProperty("aTypeValue")
@ -74,7 +77,31 @@ public class GreenTraffic {;
@TableField(exist = false)
private String staName;//收费站名称
@TableField(exist = false)
private String inStaNo;//入口收费站NO
@TableField(exist = false)
private String inStaName;//入口收费站名称
@TableField(exist = false)
private String roadName;//道路名称
@TableField(exist = false)
private String freightTypes;//运输货物类型
@TableField(exist = false)
private String freightTypeName;//运输货物名称
@TableField(exist = false)
private String passId;//交易id
@TableField(exist = false)
private String inInWeight;//入口称重
@TableField(exist = false)
private String inAxisCnt;//入口车轴
}

@ -0,0 +1,35 @@
package com.nmgs.mapper;
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
import com.nmgs.entity.CheckResultGreenFreightTypes;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Mapper
public interface CheckResultGreenFreightTypesMapper extends MppBaseMapper<CheckResultGreenFreightTypes> {
@Select("select TRANSACTIONID,CHECKTIME from CHECK_RESULT_GREEN_FREIGHTTYPES where CHECKTIME = (select MAX(CHECKTIME) from CHECK_RESULT_GREEN_FREIGHTTYPES)")
List<Map<String,Object>> getMaxCheckTime();
int insertAll(@Param("params")HashMap<String, Object> params, @Param("freightTypes") List<CheckResultGreenFreightTypes> checkResultGreenFreightTypes);
@Update("UPDATE CHECK_RESULT_GREEN_FREIGHTTYPES SET FREIGHTTYPES=#{freightType} WHERE TRANSACTIONID=#{transActionId} ")
int updateFreightTypesByTransActionId(@Param("transActionId")String transActionId, @Param("freightType")String freightType);
/**
* listNo
* @param params
* @return
*/
List<CheckResultGreenFreightTypes> geCheckResultByListNo(@Param("params")Map<String, Object> params);
}

@ -0,0 +1,89 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.nmgs.mapper.CheckResultGreenFreightTypesMapper">
<insert id="insertAll">
<if test="params.DBTYPE == 1">
INSERT INTO CHECK_RESULT_GREEN_FREIGHTTYPES (TRANSACTIONID, FREIGHTTYPES, CHECKTIME) VALUES
<foreach collection="freightTypes" item="freightType" separator=",">
(#{freightType.transActionId}, #{freightType.freightTypes}, #{freightType.checkTime})
</foreach>
</if>
<if test="params.DBTYPE == 2">
INSERT ALL
<foreach collection="freightTypes" item="freightType" separator="">
INTO CHECK_RESULT_GREEN_FREIGHTTYPES (TRANSACTIONID, FREIGHTTYPES, CHECKTIME) VALUES (#{freightType.transActionId}, #{freightType.freightTypes}, #{freightType.checkTime})
</foreach>
SELECT * FROM dual
</if>
<if test="params.DBTYPE == 3">
INSERT INTO CHECK_RESULT_GREEN_FREIGHTTYPES (TRANSACTIONID, FREIGHTTYPES, CHECKTIME) VALUES
<foreach collection="freightTypes" item="freightType" separator=",">
(#{freightType.transActionId}, #{freightType.freightTypes}, #{freightType.checkTime})
</foreach>
</if>
<if test="params.DBTYPE == 4">
INSERT INTO CHECK_RESULT_GREEN_FREIGHTTYPES (TRANSACTIONID, FREIGHTTYPES, CHECKTIME) VALUES
<foreach collection="freightTypes" item="freightType" separator=",">
(#{freightType.transActionId}, #{freightType.freightTypes}, #{freightType.checkTime})
</foreach>
</if>
</insert>
<select id="geCheckResultByListNo" parameterType="java.util.HashMap" resultType="com.nmgs.entity.CheckResultGreenFreightTypes">
SELECT
result.TRANSACTIONID,
result.FREIGHTTYPES ,
result.CHECKTIME ,
result.APPOINTMENTID,
result.CHECKID ,
result.CHECKRESULT ,
result.CRATETYPE ,
result.CRATETYPETEXT ,
result.DRIVERTELEPHONE ,
result.ENSTATIONID ,
result.ENWEIGHT ,
result.EXTIME ,
result.EXWEIGHT ,
result.INSPECTOR ,
result.MEMO ,
result.PASSID ,
result.PAYFEE ,
result.REASON ,
result.REVIEWER ,
result.VEHICLEID ,
result.VEHICLETYPE ,
result.EXSTATIONID,
LISTAGG(types.TEXT, ', ') WITHIN GROUP (ORDER BY types.TEXT) AS freightTypesText
FROM
CHECK_RESULT_GREEN_FREIGHTTYPES result
left join FREIGHTTYPE_TEXT types on LENGTH(types.TREECODE) >= 12 AND INSTR(result.FREIGHTTYPES,types.VALUE) > 0
<where>
<!-- 如果是从本省或者跨省页面搜索的数据增加相关的sql语句 -->
<if test="params.listNo != null and params.listNo != ''">
and result.LISTNO = #{params.listNo}
</if>
</where>
GROUP BY RESULT.LISTNO,result.TRANSACTIONID,result.FREIGHTTYPES ,result.CHECKTIME,
result.APPOINTMENTID,result.CHECKID ,
result.CHECKRESULT ,result.CRATETYPE ,
result.CRATETYPETEXT ,result.DRIVERTELEPHONE ,
result.ENSTATIONID ,result.ENWEIGHT ,
result.EXTIME ,result.EXWEIGHT ,
result.INSPECTOR ,result.MEMO ,
result.PASSID ,result.PAYFEE ,
result.REASON ,result.REVIEWER ,
result.VEHICLEID ,result.VEHICLETYPE ,result.EXSTATIONID
</select>
</mapper>

@ -7,6 +7,7 @@ import com.nmgs.entity.GreenTraffic;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import java.util.HashMap;
import java.util.List;
@ -42,6 +43,25 @@ public interface GreenTrafficMapper extends MppBaseMapper<GreenTraffic> {
*/
List<Map<String,Object>> selectStaList(@Param("params")Map<String, Object> params);
/**
*
* @return
*/
List<Map<String,Object>> selectSubComList();
/**
*
* @return
*/
List<Map<String,Object>> selectUnionList();
/**
*
* @return
*/
List<Map<String,Object>> selectFreightTypeList(@Param("params")Map<String, Object> params);
/**
* 绿
* @param listNo
@ -57,4 +77,141 @@ public interface GreenTrafficMapper extends MppBaseMapper<GreenTraffic> {
*/
@Select("select TEXT from TYPE_TEXT where VALUE=#{vehicleType}")
String getVehicleTypeNameByType(@Param("vehicleType")Integer vehicleType);
/**
* 绿绿
* @return
*/
List<Map<String,Object>> greenTotalCountByProvince(@Param("params")Map<String, Object> params);
/**
* 绿
* @param page
* @param params
* @return
*/
Page<Map<String, Object>> getStaSubComCollectionData(Page<Map<String, Object>> page, @Param("params")Map<String, Object> params);
/**
* 绿
* @param page
* @param params
* @return
*/
Page<Map<String, Object>> getStaDetilCollection(Page<Map<String, Object>> page, @Param("params")Map<String, Object> params);
/**
*
* @param page
* @param params
* @return
*/
Page<Map<String, Object>> getStaFigthTypeCollection(Page<Map<String, Object>> page, @Param("params")Map<String, Object> params);
/**
* 绿
* @return
*/
@Select("select min(CLASSDATE) from GREENTRAFFIC_TABLE")
String getMinClassDate();
/**
* id绿
* @param transactionId
* @return
*/
@Select("select ACARNO from GREENTRAFFIC_TABLE where ID = #{transactionId} ")
List<String> getAcarNoById(@Param("transactionId")String transactionId);
List<GreenTraffic> getGreenTrafficNoAsyncList(@Param("params")HashMap<String, Object> params);
/**
* 绿
* @param id
* @return
*/
@Update("update GREENTRAFFIC_TABLE set ISASYNC='Y' where ID=#{id} ")
int updateIsAsyncById(@Param("id")String id);
/**
*
* @param freightTypeQuery
* @return
*/
@Select(" select TEXT from FREIGHTTYPE_TEXT where VALUE = #{freightTypeQuery} ")
String getFreightTypeNameBYFreightTypes(@Param("freightTypeQuery")Integer freightTypeQuery);
/**
* idid
* @param params
* @return
*/
List<Map<String,Object>> getMenuByUserIdAndMenId(@Param("params")Map<String, Object> params);
/**
* 绿
*
* @param params
* @return
*/
List<Map<String,Object>> getGreenTotalCollection(@Param("params")Map<String, Object> params);
/***
*
* @param params
* @return
*/
List<Map<String, Object>> getGreenFeeTotalCollection(@Param("params")Map<String, Object> params);
/**
* 绿
* @param params
* @return
*/
List<Map<String, Object>> getFreightTotalCollection(@Param("params")Map<String, Object> params);
/**
* 绿
* @param params
* @return
*/
List<Map<String, Object>> getUnionFreightCollection(@Param("params")Map<String, Object> params);
/**
* 绿
*
* @param page
* @param params
* @return
*/
Page<Map<String, Object>> getSingleCarTrack(Page<Map<String, Object>> page, @Param("params")Map<String, Object> params);
/**
* 绿
* @param params
* @return
*/
List<Map<String, Object>> getGreenAcarNoByAcarNoStr(@Param("params")Map<String, Object> params);
/**
* 绿
* @return
*/
List<Map<String, Object>> getGreenTrafficListGroupByUnionName(@Param("params")Map<String, Object> params);
/**
* 绿
* @return
*/
List<Map<String, Object>> getGreenTrafficListGroupBySubCom(@Param("params")Map<String, Object> params);
/**
* 绿
* @param params
* @return
*/
List<Map<String, Object>> getGreenDetilInfoByListNo(@Param("params")Map<String, Object> params);
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,52 @@
package com.nmgs.service;
import javax.servlet.http.HttpServletResponse;
public interface IGreenTrafficExportExcelService {
/**
* 绿Excel
* @param searchForm
* @param response
* @throws Exception
*/
void exportstaUnionCollectionExcle(String searchForm, HttpServletResponse response) throws Exception;
/**
* 绿Excel
* @param searchForm
* @param response
*/
void exportstaCollectionExcle(String searchForm, HttpServletResponse response)throws Exception;
/**
* Excel
* @param searchForm
* @param response
*/
void exportUnionFreightCollectionExcle(String searchForm, HttpServletResponse response)throws Exception;
/**
*
* @param searchForm
* @param response
*/
void exportSingleTrackExcle(String searchForm, HttpServletResponse response) throws Exception ;
/**
* 绿
* @param searchForm
* @param response
*/
void exportUnionTotalExcle(String searchForm, HttpServletResponse response) throws Exception ;
/**
* 绿
* @param searchForm
* @param response
*/
void exportSubComTotalExcle(String searchForm, HttpServletResponse response) throws Exception ;
}

@ -1,11 +1,13 @@
package com.nmgs.service;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nmgs.entity.GreenTraffic;
import com.nmgs.entity.GreenTrafficCheckResult;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
public interface IGreenTrafficService {
@ -49,4 +51,79 @@ public interface IGreenTrafficService {
* @return
*/
void exportGreenTrafficExcle(String params, HttpServletResponse response) throws Exception;
/**
* 绿绿
* @return
*/
List<Map<String,Object>> greenTotalCountByProvince(Map<String, Object> params);
/**
* 绿
* @param params
* @return
*/
Page<Map<String,Object>> getStaSubComCollectionData(Map<String, Object> params);
/**
* 绿
* @param params
* @return
*/
Page<Map<String,Object>> getStaDetilCollection(Map<String, Object> params);
/**
* 绿
* @param params
* @return
*/
Page<Map<String, Object>> getStaFigthTypeCollection(Map<String, Object> params);
/**
* 绿
*
* @param params
* @return
*/
JSONArray getGreenTotalCollection(Map<String, Object> params);
/**
*
* @param params
* @return
* @throws Exception
*/
JSONArray getGreenFeeTotalCollection(Map<String, Object> params);
/**
* 绿
* @param params
* @return
*/
List<Map<String,Object>> getFreightTotalCollection(Map<String, Object> params);
/**
* 绿
* @param params
* @return
*/
List<Map<String,Object>> getUnionFreightCollection(Map<String, Object> params);
/**
*
* @param params
* @return
*/
Page<Map<String, Object>> getSingleCarTrack(Map<String, Object> params);
/**
* 使绿
* @param params
* @return
*/
List<Map<String, Object>> getGreenAcarNoByAcarNoStr(Map<String, Object> params);
}

@ -0,0 +1,941 @@
package com.nmgs.service.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
//import com.nmgs.entity.GreenTraffic;
//import com.nmgs.mapper.check.CheckResultMapper;
import com.nmgs.entity.GreenTraffic;
import com.nmgs.mapper.GreenTrafficCheckMapper;
import com.nmgs.mapper.GreenTrafficCheckPicMapper;
import com.nmgs.mapper.GreenTrafficCheckResultMapper;
import com.nmgs.mapper.GreenTrafficMapper;
import com.nmgs.service.IGreenTrafficExportExcelService;
import com.nmgs.util.PropertiesUtil;
import com.nmgs.util.ReadExcel;
import org.apache.commons.codec.Charsets;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.URLEncoder;
import java.sql.Timestamp;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.Executor;
@Service
@Transactional
public class GreenTrafficExportExcelServiceImpl implements IGreenTrafficExportExcelService {
@Autowired
private GreenTrafficMapper greenTrafficMapper;
@Autowired
private GreenTrafficCheckMapper greenTrafficCheckMapper;
@Autowired
private GreenTrafficCheckPicMapper greenTrafficCheckPicMapper;
@Autowired
private GreenTrafficCheckResultMapper greenTrafficCheckResultMapper;
@Autowired
private Executor greenTrafficThreadPool;
// @Autowired
// private CheckResultMapper checkResultMapper;
public static Logger logger = LoggerFactory.getLogger(GreenTrafficExportExcelServiceImpl.class);
/**
*
* @param searchForm
* @param response
* @throws Exception
*/
@Override
public void exportstaUnionCollectionExcle(String searchForm, HttpServletResponse response) throws Exception {
//设置导出文件名称
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
Date date = new Date();
StringBuilder filename = new StringBuilder();
//定义一个标题数组
List<String> title = new ArrayList<>();
int arrayIndex = 0;
HashMap<String,Object> paramsMap = new HashMap<>();
//如果传进来的参数有值,拼接参数
if(null != searchForm && !"".equals(searchForm)){
paramsMap = JSON.parseObject(searchForm, HashMap.class);
}
//定义查询列根据params条件动态拼接
StringBuilder selectColumn = new StringBuilder(" sum( 1 ) AS greenCount," +
"sum( green.CASH ) AS fee," +
"sum( green.INCASH + green.PAYCASH ) AS actualFee," +
"sum( green.CASH - ( green.INCASH + green.PAYCASH ) ) AS derateFee ");
StringBuilder group = new StringBuilder();
StringBuilder order = new StringBuilder(" order by "+paramsMap.get("orderColumn")+" "+paramsMap.get("orderType"));
//从配置文件中读取数据库连接类型
paramsMap.put("DBTYPE", PropertiesUtil.getValue("DBType"));
//设置分页
Integer pageNum = (Integer) paramsMap.get("pageNum");
Integer pageSize = (Integer) paramsMap.get("pageSize");
Page<Map<String, Object>> page = new Page<>(pageNum,50000);
for (Map.Entry<String, Object> entry : paramsMap.entrySet()) {
Object value = entry.getValue();
if("unionCollection".equals(value)){
//拼接查询列
selectColumn.append(" ,sta.REGIONNAME as REGIONNAME ");
//拼接分组条件
if(group.toString().equals("")){
group = new StringBuilder("group by sta.REGIONNAME ");
}else{
group.append(" ,sta.REGIONNAME ");
}
title.add("盟市");
if(filename.length() == 0){
filename = new StringBuilder("盟市");
}else{
filename.append(",盟市");
}
}
if("staCollection".equals(value)){
//拼接查询列
selectColumn.append(" ,sta.STANAME as staName,green.STANO ");
//拼接分组条件
if(group.toString().equals("")){
group = new StringBuilder("group by green.STANO,sta.STANAME ");
}else{
group.append(" ,green.STANO,sta.STANAME ");
}
title.add("收费站");
if(filename.length() == 0){
filename = new StringBuilder("收费站");
}else{
filename.append(",收费站");
}
}
}
//设置文件名
filename.append("绿通车数据统计").append(simpleDateFormat.format(date)).append(".xlsx");
paramsMap.put("selectColumn", selectColumn.toString());
logger.info("selectColumn=========="+selectColumn);
paramsMap.put("group", group.toString());
logger.info("group=========="+group);
paramsMap.put("order", order.toString());
logger.info("order=========="+order);
page = greenTrafficMapper.getStaSubComCollectionData(page,paramsMap);
//创建一个Excel表格
Workbook wb = new XSSFWorkbook();
//创建sheet页面
Sheet sheet = wb.createSheet("绿通");
//如果没有数据返回一个空的Excel
List<Map<String, Object>> records = page.getRecords();
if(null == records){
//导出Excel
writeToExcel(response,wb, filename.toString());
}
title.add("绿通车数量");
title.add("应收金额(元)");
title.add("实收金额(元)");
title.add("减免金额(元)");
//定义内容数据
List<String[]> rowValues = new ArrayList<>();
for (Map<String, Object> result : records) {
String[] rowValue = new String[title.size()];
for(int j = 0 ; j < title.size() ; j++){
if(title.get(j).equals("盟市")){
rowValue[j] = (String) result.get("REGIONNAME");
}
if(title.get(j).equals("收费站")){
rowValue[j] = (String) result.get("STANAME");
}
if(title.get(j).equals("绿通车数量")){
rowValue[j] = ((BigDecimal) result.get("GREENCOUNT")).toString();
}
if(title.get(j).equals("应收金额(元)")){
rowValue[j] = ((BigDecimal) result.get("FEE")).toString();
}
if(title.get(j).equals("实收金额(元)")){
rowValue[j] = ((BigDecimal) result.get("ACTUALFEE")).toString();
}
if(title.get(j).equals("减免金额(元)")){
rowValue[j] = ((BigDecimal) result.get("DERATEFEE")).toString();
}
}
rowValues.add(rowValue);
}
//设置标题单元格式
CellStyle cellStyleTitle = wb.createCellStyle();
cellStyleTitle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());//设置背景色
cellStyleTitle.setFillPattern((short) 1);//必须设置 否则无效
//设置水平垂直居中
cellStyleTitle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
cellStyleTitle.setVerticalAlignment(HSSFCellStyle.ALIGN_CENTER);
// 设置边框样式
cellStyleTitle.setBorderBottom(XSSFCellStyle.BORDER_THIN);
cellStyleTitle.setBorderLeft(XSSFCellStyle.BORDER_THIN);
cellStyleTitle.setBorderRight(XSSFCellStyle.BORDER_THIN);
cellStyleTitle.setBorderTop(XSSFCellStyle.BORDER_THIN);
//定义标题内容
Row currentRow = sheet.createRow(0);
// 往Excel表格中添加标题的数据
for (int j = 0; j < title.size(); j++) {
// 设置列宽
sheet.setColumnWidth(j, 4100);
Cell cell = currentRow.createCell(j);
cell.setCellStyle(cellStyleTitle);
//每个单元格的值目前做 String 处理
//cell.setCellType(CellType.STRING);
cell.setCellValue(title.get(j));
}
//设置内容单元格式
CellStyle cellStyleValue = wb.createCellStyle();
//设置水平垂直居中
cellStyleValue.setAlignment(HSSFCellStyle.ALIGN_CENTER);
cellStyleValue.setVerticalAlignment(HSSFCellStyle.ALIGN_CENTER);
// 设置边框样式
cellStyleValue.setBorderBottom(XSSFCellStyle.BORDER_THIN);
cellStyleValue.setBorderLeft(XSSFCellStyle.BORDER_THIN);
cellStyleValue.setBorderRight(XSSFCellStyle.BORDER_THIN);
cellStyleValue.setBorderTop(XSSFCellStyle.BORDER_THIN);
//往Excel表格中添加具体数据
for (int i = 0; i < rowValues.size(); i++) {
Row Row = sheet.createRow((i+1));
for (int j = 0; j < title.size(); j++) {
// 设置列宽
sheet.setColumnWidth(j, 4100);
Cell cell = Row.createCell(j);
cell.setCellStyle(cellStyleValue);
//每个单元格的值目前做 String 处理
//cell.setCellType(CellType.STRING);
cell.setCellValue(rowValues.get(i)[j]);
}
}
//导出Excel
writeToExcel(response,wb, filename.toString());
}
@Override
public void exportstaCollectionExcle(String searchForm, HttpServletResponse response) throws Exception {
//设置导出文件名称
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
Date date = new Date();
//如果传进来的参数有值,拼接参数
HashMap<String,Object> paramsMap = new HashMap<>();
if(null != searchForm && !"".equals(searchForm)){
paramsMap = JSON.parseObject(searchForm, HashMap.class);
}
//获取数据
//从配置文件中读取数据库连接类型
paramsMap.put("DBTYPE", PropertiesUtil.getValue("DBType"));
//设置分页
Integer pageNum = (Integer) paramsMap.get("pageNum");
//Integer pageSize = (Integer) paramsMap.get("pageSize");
Page<Map<String, Object>> page = new Page<>(pageNum,50000);
//设置排序条件
StringBuilder order = new StringBuilder(" order by "+paramsMap.get("orderColumn")+" "+paramsMap.get("orderType"));
paramsMap.put("order", order.toString());
logger.info("order=========="+order);
page = greenTrafficMapper.getStaDetilCollection(page, paramsMap);
//定义文件名称
StringBuilder filename = new StringBuilder();
filename.append("收费站本省跨省绿通车数据统计").append(simpleDateFormat.format(date)).append(".xlsx");
//读取模版文件
//创建Excel工作薄
//2. 通过POI将数据写入到Excel文件中
InputStream in = this.getClass().getClassLoader().getResourceAsStream("excel/staGreenCollectionExcelmod.xlsx");
Workbook work = ReadExcel.getWorkbook(in,"staGreenCollectionExcelmod.xlsx");
//如果没有数据返回一个空的Excel
List<Map<String, Object>> records = page.getRecords();
if(null == records){
//导出Excel
writeToExcel(response,work, filename.toString());
}
//获取sheet页面
Sheet sheet = work.getSheet("绿通");
//设置内容单元格式
CellStyle cellStyleValue = work.createCellStyle();
//设置水平垂直居中
cellStyleValue.setAlignment(HSSFCellStyle.ALIGN_CENTER);
cellStyleValue.setVerticalAlignment(HSSFCellStyle.ALIGN_CENTER);
// 设置边框样式
cellStyleValue.setBorderBottom(XSSFCellStyle.BORDER_THIN);
cellStyleValue.setBorderLeft(XSSFCellStyle.BORDER_THIN);
cellStyleValue.setBorderRight(XSSFCellStyle.BORDER_THIN);
cellStyleValue.setBorderTop(XSSFCellStyle.BORDER_THIN);
//设置金额的格式
DecimalFormat decimalFormat = new DecimalFormat("#.00");
//定义数据在Excel中的开始行数
int row = 2;
//往Excel表格中添加具体数据
for (int i = 0; i < records.size(); i++) {
// 合并第row行的前三列A到C
//sheet.addMergedRegion(new CellRangeAddress(row, row, 0, 2));
Row Row = sheet.createRow(row);
for (int j = 0; j < 10; j++) {
// 设置列宽
//sheet.setColumnWidth(j, 4100);
Cell cell = Row.createCell(j);
cell.setCellStyle(cellStyleValue);
//每个单元格的值目前做 String 处理
//cell.setCellType(CellType.STRING);
if(j == 0){cell.setCellValue((String) records.get(i).get("SUBCOMNAME"));}
if(j == 1){cell.setCellValue(records.get(i).get("REGIONNAME").toString());}
if(j == 2){cell.setCellValue(records.get(i).get("ROADNAME").toString());}
if(j == 3){cell.setCellValue(records.get(i).get("STANAME").toString());}
if(j == 4){cell.setCellValue(((BigDecimal) records.get(i).get("GREENCOUNT")).toString());}
if(j == 5){cell.setCellValue(((BigDecimal)records.get(i).get("DERATEFEETOTAL")).setScale(2, RoundingMode.HALF_UP).toString());}
if(j == 6){cell.setCellValue(((BigDecimal) records.get(i).get("PROVINCETOTAL")).toString());}
//if(j == 7){cell.setCellValue(((BigDecimal) records.get(i).get("PROVINCEDERATEFEE")).toString());}
if(j == 7){cell.setCellValue(((BigDecimal)records.get(i).get("PROVINCEDERATEFEE")).setScale(2, RoundingMode.HALF_UP).toString());}
if(j == 8){cell.setCellValue(((BigDecimal) records.get(i).get("OTHERPROVINCETOTAL")).toString());}
//if(j == 9){cell.setCellValue(((BigDecimal) records.get(i).get("OTHERPROVINCEDERATEFEE")).toString());}
if(j == 9){cell.setCellValue(((BigDecimal)records.get(i).get("OTHERPROVINCEDERATEFEE")).setScale(2, RoundingMode.HALF_UP).toString());}
}
row++;
}
//导出Excel
writeToExcel(response,work, filename.toString());
}
/**
* Excel
* @param searchForm
* @param response
*/
@Override
public void exportUnionFreightCollectionExcle(String searchForm, HttpServletResponse response) throws Exception {
//设置导出文件名称
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
Date date = new Date();
StringBuilder filename = new StringBuilder();
//定义一个标题数组
List<String> title = new ArrayList<>();
int arrayIndex = 0;
HashMap<String,Object> paramsMap = new HashMap<>();
//如果传进来的参数有值,拼接参数
if(null != searchForm && !"".equals(searchForm)){
paramsMap = JSON.parseObject(searchForm, HashMap.class);
}
//根据类型查询类型名称
//String typeName = greenTrafficMapper.getFreightTypeNameBYFreightTypes((Integer)paramsMap.get("freightTypeQuery"));
//设置文件名
filename.append("货物绿通车统计").append(simpleDateFormat.format(date)).append(".xlsx");
//从配置文件中读取数据库连接类型
paramsMap.put("DBTYPE", PropertiesUtil.getValue("DBType"));
//设置分页
Integer pageNum = (Integer) paramsMap.get("pageNum");
//Integer pageSize = (Integer) paramsMap.get("pageSize");
Page<Map<String, Object>> page = new Page<>(pageNum,50000);
//设置排序条件
StringBuilder order = new StringBuilder(" order by "+paramsMap.get("orderColumn")+" "+paramsMap.get("orderType"));
paramsMap.put("order", order.toString());
logger.info("order=========="+order);
page = greenTrafficMapper.getStaFigthTypeCollection(page,paramsMap);
//创建一个Excel表格
Workbook wb = new XSSFWorkbook();
//创建sheet页面
Sheet sheet = wb.createSheet("绿通");
//如果没有数据返回一个空的Excel
List<Map<String, Object>> records = page.getRecords();
if(null == records){
//导出Excel
writeToExcel(response,wb, filename.toString());
}
title.add("货物类型");
title.add("货物绿通车数量");
//定义内容数据
List<String[]> rowValues = new ArrayList<>();
for (Map<String, Object> result : records) {
String[] rowValue = new String[title.size()];
for(int j = 0 ; j < title.size() ; j++){
if(title.get(j).equals("货物类型")){
rowValue[j] = (String) result.get("TEXT");
}
if(title.get(j).equals("货物绿通车数量")){
rowValue[j] = ((BigDecimal) result.get("REGIONFREIGHTCOUNT")).toString();
}
}
rowValues.add(rowValue);
}
//设置标题单元格式
CellStyle cellStyleTitle = wb.createCellStyle();
cellStyleTitle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());//设置背景色
cellStyleTitle.setFillPattern((short) 1);//必须设置 否则无效
//设置水平垂直居中
cellStyleTitle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
cellStyleTitle.setVerticalAlignment(HSSFCellStyle.ALIGN_CENTER);
// 设置边框样式
cellStyleTitle.setBorderBottom(XSSFCellStyle.BORDER_THIN);
cellStyleTitle.setBorderLeft(XSSFCellStyle.BORDER_THIN);
cellStyleTitle.setBorderRight(XSSFCellStyle.BORDER_THIN);
cellStyleTitle.setBorderTop(XSSFCellStyle.BORDER_THIN);
//定义标题内容
Row currentRow = sheet.createRow(0);
// 往Excel表格中添加标题的数据
for (int j = 0; j < title.size(); j++) {
// 设置列宽
sheet.setColumnWidth(j, 6000);
Cell cell = currentRow.createCell(j);
cell.setCellStyle(cellStyleTitle);
//每个单元格的值目前做 String 处理
//cell.setCellType(CellType.STRING);
cell.setCellValue(title.get(j));
}
//设置内容单元格式
CellStyle cellStyleValue = wb.createCellStyle();
//设置水平垂直居中
cellStyleValue.setAlignment(HSSFCellStyle.ALIGN_CENTER);
cellStyleValue.setVerticalAlignment(HSSFCellStyle.ALIGN_CENTER);
// 设置边框样式
cellStyleValue.setBorderBottom(XSSFCellStyle.BORDER_THIN);
cellStyleValue.setBorderLeft(XSSFCellStyle.BORDER_THIN);
cellStyleValue.setBorderRight(XSSFCellStyle.BORDER_THIN);
cellStyleValue.setBorderTop(XSSFCellStyle.BORDER_THIN);
//往Excel表格中添加具体数据
for (int i = 0; i < rowValues.size(); i++) {
Row Row = sheet.createRow((i+1));
for (int j = 0; j < title.size(); j++) {
// 设置列宽
sheet.setColumnWidth(j, 4100);
Cell cell = Row.createCell(j);
cell.setCellStyle(cellStyleValue);
//每个单元格的值目前做 String 处理
//cell.setCellType(CellType.STRING);
cell.setCellValue(rowValues.get(i)[j]);
}
}
//导出Excel
writeToExcel(response,wb, filename.toString());
}
@Override
public void exportSingleTrackExcle(String searchForm, HttpServletResponse response) throws Exception {
//设置导出文件名称
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
Date date = new Date();
String filename = "单车轨迹查验-" + simpleDateFormat.format(date) + ".xlsx";
HashMap<String, Object> paramsMap = new HashMap<>();
//如果传进来的参数有值,拼接参数
if (null != searchForm && !"".equals(searchForm)) {
paramsMap = JSON.parseObject(searchForm, HashMap.class);
}
//根据条件查询绿通数据
//从配置文件中读取数据库连接类型
paramsMap.put("DBTYPE", PropertiesUtil.getValue("DBType"));
//设置分页
Integer pageNum = (Integer) paramsMap.get("pageNum");
Integer pageSize = (Integer) paramsMap.get("pageSize");
//设置数据条数,不超过五万条
Page<Map<String,Object>> page = new Page<>(pageNum, 50000);
page = greenTrafficMapper.getSingleCarTrack(page, paramsMap);
//创建一个Excel表格
Workbook wb = new XSSFWorkbook();
//创建sheet页面
Sheet sheet = wb.createSheet("绿通");
//如果没有数据返回一个空的Excel
List<Map<String, Object>> singleCarTrack = page.getRecords();
if (null == singleCarTrack) {
//导出Excel
writeToExcel(response, wb, filename);
}
//定义一个标题数组
String[] title = {"入口在", "出口站", "车道操作时间", "车牌号", "出口车种", "绿通车货物类型", "入口车种", "入口称重", "应收金额(元)",
"实收金额(元)", "减免金额(元)"};
//设置金额的格式
DecimalFormat decimalFormat = new DecimalFormat("#.00");
//设置统计时间日期格式
SimpleDateFormat simpleDateFormatClassData = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat simpleDateFormatDt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//定义内容数据
List<String[]> rowValues = new ArrayList<>();
for (Map<String, Object> result : singleCarTrack) {
String[] rowValue = new String[title.length];
for(int j = 0 ; j < title.length ; j++){
if(title[j].equals("入口在")){
rowValue[j] = (String) result.get("ENTOLLSTATIONNAME");
}
if(title[j].equals("出口站")){
rowValue[j] = (String) result.get("EXTOLLSTATIONNAME");
}
if(title[j].equals("车道操作时间")){
rowValue[j] = simpleDateFormatDt.format(((Timestamp) result.get("DT")));
}
if(title[j].equals("车牌号")){
rowValue[j] = ((String) result.get("ACARNO")).toString();
}
if(title[j].equals("出口车种")){
rowValue[j] = ((String) result.get("OUTKINDNAME")).toString();
}
if(title[j].equals("绿通车货物类型")){
rowValue[j] = result.get("FREIGHTTYPENAME") != null ?((String) result.get("FREIGHTTYPENAME")).toString():"";
}
if(title[j].equals("入口车种")){
rowValue[j] = ((String) result.get("INKINDNAME")).toString();
}
if(title[j].equals("入口称重")){
rowValue[j] = ((BigDecimal) result.get("ININWEIGHT")).toString();
}
BigDecimal cash = (BigDecimal) result.get("CASH");
BigDecimal inCash = (BigDecimal) result.get("INCASH");
BigDecimal payCash = (BigDecimal) result.get("PAYCASH");
if(title[j].equals("应收金额(元)")){
rowValue[j] = cash.setScale(2, RoundingMode.HALF_UP).toString();
}
if(title[j].equals("实收金额(元)")){
rowValue[j] = inCash.add(payCash).setScale(2, RoundingMode.HALF_UP).toString();
}
if(title[j].equals("减免金额(元)")){
rowValue[j] = cash.subtract(inCash.add(payCash)).setScale(2, RoundingMode.HALF_UP).toString();
}
}
rowValues.add(rowValue);
}
//设置标题单元格式
CellStyle cellStyleTitle = wb.createCellStyle();
cellStyleTitle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());//设置背景色
cellStyleTitle.setFillPattern((short) 1);//必须设置 否则无效
//设置水平垂直居中
cellStyleTitle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
cellStyleTitle.setVerticalAlignment(HSSFCellStyle.ALIGN_CENTER);
// 设置边框样式
cellStyleTitle.setBorderBottom(XSSFCellStyle.BORDER_THIN);
cellStyleTitle.setBorderLeft(XSSFCellStyle.BORDER_THIN);
cellStyleTitle.setBorderRight(XSSFCellStyle.BORDER_THIN);
cellStyleTitle.setBorderTop(XSSFCellStyle.BORDER_THIN);
//定义标题内容
Row currentRow = sheet.createRow(0);
// 往Excel表格中添加标题的数据
for (int j = 0; j < title.length; j++) {
// 设置列宽
sheet.setColumnWidth(j, 4100);
Cell cell = currentRow.createCell(j);
cell.setCellStyle(cellStyleTitle);
//每个单元格的值目前做 String 处理
//cell.setCellType(CellType.STRING);
cell.setCellValue(title[j]);
}
//设置内容单元格式
CellStyle cellStyleValue = wb.createCellStyle();
//设置水平垂直居中
cellStyleValue.setAlignment(HSSFCellStyle.ALIGN_CENTER);
cellStyleValue.setVerticalAlignment(HSSFCellStyle.ALIGN_CENTER);
// 设置边框样式
cellStyleValue.setBorderBottom(XSSFCellStyle.BORDER_THIN);
cellStyleValue.setBorderLeft(XSSFCellStyle.BORDER_THIN);
cellStyleValue.setBorderRight(XSSFCellStyle.BORDER_THIN);
cellStyleValue.setBorderTop(XSSFCellStyle.BORDER_THIN);
//往Excel表格中添加具体数据
for (int i = 0; i < rowValues.size(); i++) {
Row Row = sheet.createRow((i + 1));
for (int j = 0; j < title.length; j++) {
// 设置列宽
sheet.setColumnWidth(j, 4100);
Cell cell = Row.createCell(j);
cell.setCellStyle(cellStyleValue);
//每个单元格的值目前做 String 处理
//cell.setCellType(CellType.STRING);
cell.setCellValue(rowValues.get(i)[j]);
}
}
//导出Excel
writeToExcel(response, wb, filename);
}
@Override
public void exportUnionTotalExcle(String searchForm, HttpServletResponse response) throws Exception {
//设置导出文件名称
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
Date date = new Date();
String filename = "盟市绿通数据统计-" + simpleDateFormat.format(date) + ".xlsx";
HashMap<String, Object> paramsMap = new HashMap<>();
//如果传进来的参数有值,拼接参数
if (null != searchForm && !"".equals(searchForm)) {
paramsMap = JSON.parseObject(searchForm, HashMap.class);
}
//根据条件查询绿通数据
//从配置文件中读取数据库连接类型
paramsMap.put("DBTYPE", PropertiesUtil.getValue("DBType"));
//设置分页
Integer pageNum = (Integer) paramsMap.get("pageNum");
//Integer pageSize = (Integer) paramsMap.get("pageSize");
//设置数据条数,不超过五万条
Page<GreenTraffic> page = new Page<>(pageNum, 50000);
List<Map<String, Object>> maps = greenTrafficMapper.getGreenTrafficListGroupByUnionName(paramsMap);
//创建一个Excel表格
Workbook wb = new XSSFWorkbook();
//创建sheet页面
Sheet sheet = wb.createSheet("绿通");
//如果没有数据返回一个空的Excel
//List<GreenTraffic> records = page.getRecords();
if (null == maps) {
//导出Excel
writeToExcel(response, wb, filename);
}
//定义一个标题数组
String[] title = {"盟市", "绿通车数量", "减免金额(元)"};
//设置金额的格式
DecimalFormat decimalFormat = new DecimalFormat("#.00");
//设置统计时间日期格式
SimpleDateFormat simpleDateFormatClassData = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat simpleDateFormatDt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//定义内容数据
List<String[]> rowValues = new ArrayList<>();
for (Map<String, Object> greenTraffic : maps) {
String[] rowValue = {
null == greenTraffic.get("REGIONNAME") ? "" : greenTraffic.get("REGIONNAME").toString(),
null == greenTraffic.get("COUNTNUM") ? "" : ((BigDecimal)greenTraffic.get("COUNTNUM")).toString(),
null == greenTraffic.get("DERATEFEETOTAL") ? "" : ((BigDecimal)greenTraffic.get("DERATEFEETOTAL")).setScale(2, RoundingMode.HALF_UP).toString(),
};
rowValues.add(rowValue);
}
//设置标题单元格式
CellStyle cellStyleTitle = wb.createCellStyle();
cellStyleTitle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());//设置背景色
cellStyleTitle.setFillPattern((short) 1);//必须设置 否则无效
//设置水平垂直居中
cellStyleTitle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
cellStyleTitle.setVerticalAlignment(HSSFCellStyle.ALIGN_CENTER);
// 设置边框样式
cellStyleTitle.setBorderBottom(XSSFCellStyle.BORDER_THIN);
cellStyleTitle.setBorderLeft(XSSFCellStyle.BORDER_THIN);
cellStyleTitle.setBorderRight(XSSFCellStyle.BORDER_THIN);
cellStyleTitle.setBorderTop(XSSFCellStyle.BORDER_THIN);
//定义标题内容
Row currentRow = sheet.createRow(0);
// 往Excel表格中添加标题的数据
for (int j = 0; j < title.length; j++) {
// 设置列宽
sheet.setColumnWidth(j, 4100);
Cell cell = currentRow.createCell(j);
cell.setCellStyle(cellStyleTitle);
//每个单元格的值目前做 String 处理
//cell.setCellType(CellType.STRING);
cell.setCellValue(title[j]);
}
//设置内容单元格式
CellStyle cellStyleValue = wb.createCellStyle();
//设置水平垂直居中
cellStyleValue.setAlignment(HSSFCellStyle.ALIGN_CENTER);
cellStyleValue.setVerticalAlignment(HSSFCellStyle.ALIGN_CENTER);
// 设置边框样式
cellStyleValue.setBorderBottom(XSSFCellStyle.BORDER_THIN);
cellStyleValue.setBorderLeft(XSSFCellStyle.BORDER_THIN);
cellStyleValue.setBorderRight(XSSFCellStyle.BORDER_THIN);
cellStyleValue.setBorderTop(XSSFCellStyle.BORDER_THIN);
//往Excel表格中添加具体数据
for (int i = 0; i < rowValues.size(); i++) {
Row Row = sheet.createRow((i + 1));
for (int j = 0; j < title.length; j++) {
// 设置列宽
sheet.setColumnWidth(j, 4100);
Cell cell = Row.createCell(j);
cell.setCellStyle(cellStyleValue);
//每个单元格的值目前做 String 处理
//cell.setCellType(CellType.STRING);
cell.setCellValue(rowValues.get(i)[j]);
}
}
//导出Excel
writeToExcel(response, wb, filename);
}
@Override
public void exportSubComTotalExcle(String searchForm, HttpServletResponse response) throws Exception {
//设置导出文件名称
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
Date date = new Date();
String filename = "分公司绿通数据统计-" + simpleDateFormat.format(date) + ".xlsx";
HashMap<String, Object> paramsMap = new HashMap<>();
//如果传进来的参数有值,拼接参数
if (null != searchForm && !"".equals(searchForm)) {
paramsMap = JSON.parseObject(searchForm, HashMap.class);
}
//根据条件查询绿通数据
//从配置文件中读取数据库连接类型
paramsMap.put("DBTYPE", PropertiesUtil.getValue("DBType"));
//设置分页
Integer pageNum = (Integer) paramsMap.get("pageNum");
//Integer pageSize = (Integer) paramsMap.get("pageSize");
//设置数据条数,不超过五万条
Page<GreenTraffic> page = new Page<>(pageNum, 50000);
List<Map<String, Object>> maps = greenTrafficMapper.getGreenTrafficListGroupBySubCom(paramsMap);
//创建一个Excel表格
Workbook wb = new XSSFWorkbook();
//创建sheet页面
Sheet sheet = wb.createSheet("绿通");
//如果没有数据返回一个空的Excel
//List<GreenTraffic> records = page.getRecords();
if (null == maps) {
//导出Excel
writeToExcel(response, wb, filename);
}
//定义一个标题数组
String[] title = {"分公司", "绿通车数量", "减免金额(元)"};
//设置金额的格式
DecimalFormat decimalFormat = new DecimalFormat("#.00");
//设置统计时间日期格式
SimpleDateFormat simpleDateFormatClassData = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat simpleDateFormatDt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//定义内容数据
List<String[]> rowValues = new ArrayList<>();
for (Map<String, Object> greenTraffic : maps) {
String[] rowValue = {
null == greenTraffic.get("SUBCOMNAME") ? "" : greenTraffic.get("SUBCOMNAME").toString(),
null == greenTraffic.get("COUNTNUM") ? "" : ((BigDecimal)greenTraffic.get("COUNTNUM")).toString(),
null == greenTraffic.get("DERATEFEETOTAL") ? "" : ((BigDecimal)greenTraffic.get("DERATEFEETOTAL")).setScale(2, RoundingMode.HALF_UP).toString(),
};
rowValues.add(rowValue);
}
//设置标题单元格式
CellStyle cellStyleTitle = wb.createCellStyle();
cellStyleTitle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());//设置背景色
cellStyleTitle.setFillPattern((short) 1);//必须设置 否则无效
//设置水平垂直居中
cellStyleTitle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
cellStyleTitle.setVerticalAlignment(HSSFCellStyle.ALIGN_CENTER);
// 设置边框样式
cellStyleTitle.setBorderBottom(XSSFCellStyle.BORDER_THIN);
cellStyleTitle.setBorderLeft(XSSFCellStyle.BORDER_THIN);
cellStyleTitle.setBorderRight(XSSFCellStyle.BORDER_THIN);
cellStyleTitle.setBorderTop(XSSFCellStyle.BORDER_THIN);
//定义标题内容
Row currentRow = sheet.createRow(0);
// 往Excel表格中添加标题的数据
for (int j = 0; j < title.length; j++) {
// 设置列宽
sheet.setColumnWidth(j, 4100);
Cell cell = currentRow.createCell(j);
cell.setCellStyle(cellStyleTitle);
//每个单元格的值目前做 String 处理
//cell.setCellType(CellType.STRING);
cell.setCellValue(title[j]);
}
//设置内容单元格式
CellStyle cellStyleValue = wb.createCellStyle();
//设置水平垂直居中
cellStyleValue.setAlignment(HSSFCellStyle.ALIGN_CENTER);
cellStyleValue.setVerticalAlignment(HSSFCellStyle.ALIGN_CENTER);
// 设置边框样式
cellStyleValue.setBorderBottom(XSSFCellStyle.BORDER_THIN);
cellStyleValue.setBorderLeft(XSSFCellStyle.BORDER_THIN);
cellStyleValue.setBorderRight(XSSFCellStyle.BORDER_THIN);
cellStyleValue.setBorderTop(XSSFCellStyle.BORDER_THIN);
//往Excel表格中添加具体数据
for (int i = 0; i < rowValues.size(); i++) {
Row Row = sheet.createRow((i + 1));
for (int j = 0; j < title.length; j++) {
// 设置列宽
sheet.setColumnWidth(j, 4100);
Cell cell = Row.createCell(j);
cell.setCellStyle(cellStyleValue);
//每个单元格的值目前做 String 处理
//cell.setCellType(CellType.STRING);
cell.setCellValue(rowValues.get(i)[j]);
}
}
//导出Excel
writeToExcel(response, wb, filename);
}
/**
* Excelresponse
* @param response
* @param wb
* @param fileName
* @throws Exception
*/
public void writeToExcel(HttpServletResponse response, Workbook wb, String fileName) throws Exception {
OutputStream os = null;
response.setContentType("application/vnd.ms-excel;charset=UTF-8");
response.setCharacterEncoding(Charsets.UTF_8.name());
response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, String.format("attachment; filename=%s", new String(URLEncoder.encode(fileName, Charsets.UTF_8.name())
.getBytes(Charsets.UTF_8), Charsets.ISO_8859_1)));
os = response.getOutputStream();
wb.write(os);
os.flush();
}
}

@ -0,0 +1,158 @@
package com.nmgs.task;
import com.nmgs.mapper.CheckResultGreenFreightTypesMapper;
import com.nmgs.mapper.GreenTrafficMapper;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
/**
*
*/
@Component
@Async
@Slf4j
public class GreenCheckReustInfoUploadTask {
@Autowired
private CheckResultGreenFreightTypesMapper checkResultGreenFreightTypesMapper;
@Autowired
private GreenTrafficMapper GreenTrafficMapper;
public static Logger logger = LoggerFactory.getLogger(GreenCheckReustInfoUploadTask.class);
// @Scheduled(cron = " 0 0/2 * * * ? ")//15秒执行一次
// @Transactional
// public void GreenCheckReustInfoUpload() {
//
//
// //1.从集团绿通流水表中获取500条没有同步过的数据
// HashMap<String,Object> params = new HashMap<>();
// params.put("DBTYPE", PropertiesUtil.getValue("DBType"));
// List<GreenTraffic> greens = GreenTrafficMapper.getGreenTrafficNoAsyncList(params);
//
// if(null != greens && !greens.isEmpty()){
// logger.info("获取数据============="+greens.size());
//
// for (GreenTraffic record : greens) {
// logger.info("要查询的车牌号============="+record.getAcarNo()+"和transActionId============="+record.getId());
//
// //获取最大的货物信息
// String freightType = checkResultMapper.getMaxFreightByTransActionId(record.getId(),'%'+record.getAcarNo()+'%');
// //获取查验信息
// List<Map<String,Object>> result = checkResultMapper.getResultListByTransActionId(record.getId(),'%'+record.getAcarNo()+'%');
// try{
// //插入数据
// if(null != result && !result.isEmpty() && null != freightType && !freightType.isEmpty()){
// Map<String, Object> resultMap = result.get(0);
//
// CheckResultGreenFreightTypes freightTypes = new CheckResultGreenFreightTypes();
//
// //把查验结果保存在实体类中
// if(resultMap.get("TRANSACTIONID").equals(record.getId())){
// freightTypes.setTransActionId(record.getId());
// }else{
// freightTypes.setTransActionId(record.getId());
// freightTypes.setResultTransActionId((String) resultMap.get("TRANSACTIONID"));
// }
// //如果为空,说明没查到数据,就不添加数据
// freightTypes.setFreightTypes(freightType);
// freightTypes.setCheckTime((Date) resultMap.get("CHECKTIME"));
// freightTypes.setListNo(record.getListNo());
// freightTypes.setAppointmentId(null==resultMap.get("APPOINTMENTID")?"非预约": (String) resultMap.get("APPOINTMENTID"));
// freightTypes.setCheckId((String) resultMap.get("CHECKID"));
// freightTypes.setCheckResult(((BigDecimal)resultMap.get("CHECKRESULT")).intValue());
// freightTypes.setCrateType(((BigDecimal)resultMap.get("CRATETYPE")).intValue());
// freightTypes.setCrateTypeText((String) resultMap.get("CRATETYPETEXT"));
// freightTypes.setDriverTelephone((String) resultMap.get("DRIVERTELEPHONE"));
// freightTypes.setEnStationId((String) resultMap.get("ENSTATIONID"));
// freightTypes.setEnWeight(((BigDecimal)resultMap.get("ENWEIGHT")).intValue());
// freightTypes.setExTime((Date) resultMap.get("EXTIME"));
// freightTypes.setExWeight(((BigDecimal)resultMap.get("EXWEIGHT")).intValue());
// freightTypes.setInspector((String) resultMap.get("INSPECTOR"));
// freightTypes.setMemo((String) resultMap.get("MEMO"));
// freightTypes.setPassId((String) resultMap.get("PASSID"));
// freightTypes.setPayFee(((BigDecimal)resultMap.get("PAYFEE")).intValue());
// freightTypes.setReason((String) resultMap.get("REASON"));
// freightTypes.setReviewer((String) resultMap.get("REVIEWER"));
// freightTypes.setVehicleId((String) resultMap.get("VEHICLEID"));
// freightTypes.setVehicleType(((BigDecimal)resultMap.get("VEHICLETYPE")).intValue());
// freightTypes.setExStationId((String) resultMap.get("EXSTATIONID"));
// int res = checkResultGreenFreightTypesMapper.insert(freightTypes);
// logger.info("插入数据res============="+record.getId());
//
// //同步green表
// int updateRes = GreenTrafficMapper.updateIsAsyncById(record.getId());
// logger.info("修改绿通流水同步状态============="+record.getId());
// }else{
// //获取最大的货物信息
// freightType = checkResultMapper.getMaxFreightByPassId(record.getPassId(),'%'+record.getAcarNo()+'%');
// //获取查验信息
// result = checkResultMapper.getResultListByPassId(record.getPassId(),'%'+record.getAcarNo()+'%');
// if(null != result && !result.isEmpty() && null != freightType && !freightType.isEmpty()){
// Map<String, Object> resultMap = result.get(0);
// CheckResultGreenFreightTypes freightTypes = new CheckResultGreenFreightTypes();
// //把查验结果保存在实体类中
// if(resultMap.get("TRANSACTIONID").equals(record.getId())){
// freightTypes.setTransActionId(record.getId());
// }else{
// freightTypes.setTransActionId(record.getId());
// freightTypes.setResultTransActionId((String) resultMap.get("TRANSACTIONID"));
// }
// //如果为空,说明没查到数据,就不添加数据
// freightTypes.setFreightTypes(freightType);
// freightTypes.setCheckTime((Date) resultMap.get("CHECKTIME"));
// freightTypes.setListNo(record.getListNo());
// freightTypes.setAppointmentId(null==resultMap.get("APPOINTMENTID")?"非预约": (String) resultMap.get("APPOINTMENTID"));
// freightTypes.setCheckId((String) resultMap.get("CHECKID"));
// freightTypes.setCheckResult(((BigDecimal)resultMap.get("CHECKRESULT")).intValue());
// freightTypes.setCrateType(((BigDecimal)resultMap.get("CRATETYPE")).intValue());
// freightTypes.setCrateTypeText((String) resultMap.get("CRATETYPETEXT"));
// freightTypes.setDriverTelephone((String) resultMap.get("DRIVERTELEPHONE"));
// freightTypes.setEnStationId((String) resultMap.get("ENSTATIONID"));
// freightTypes.setEnWeight(((BigDecimal)resultMap.get("ENWEIGHT")).intValue());
// freightTypes.setExTime((Date) resultMap.get("EXTIME"));
// freightTypes.setExWeight(((BigDecimal)resultMap.get("EXWEIGHT")).intValue());
// freightTypes.setInspector((String) resultMap.get("INSPECTOR"));
// freightTypes.setMemo((String) resultMap.get("MEMO"));
// freightTypes.setPassId((String) resultMap.get("PASSID"));
// freightTypes.setPayFee(((BigDecimal)resultMap.get("PAYFEE")).intValue());
// freightTypes.setReason((String) resultMap.get("REASON"));
// freightTypes.setReviewer((String) resultMap.get("REVIEWER"));
// freightTypes.setVehicleId((String) resultMap.get("VEHICLEID"));
// freightTypes.setVehicleType(((BigDecimal)resultMap.get("VEHICLETYPE")).intValue());
// freightTypes.setExStationId((String) resultMap.get("EXSTATIONID"));
// int res = checkResultGreenFreightTypesMapper.insert(freightTypes);
// logger.info("插入数据res============="+record.getId());
//
// //同步green表
// int updateRes = GreenTrafficMapper.updateIsAsyncById(record.getId());
// logger.info("修改绿通流水同步状态============="+record.getId());
// }
// }
// }catch (Exception ignored){
// //如果货物类型不为空,修改货物类型
// if(null != freightType && !freightType.isEmpty()){
// int res = checkResultGreenFreightTypesMapper.updateFreightTypesByTransActionId(record.getId(),freightType);
// logger.info("修改res============="+record.getId());
// }
// }
//
// }
//
//
//
// }
//
// }
}

@ -0,0 +1,252 @@
package com.nmgs.util;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
/**
* @Description:
* @Auther: xuxiaojun
* @Date: 2020-03-19
*/
public class DateSplitUtils {
public enum IntervalType {
DAY,
HOUR,
MINUTE,
SECOND,
;
}
/**
*
* @param startTime
* @param endTime
* @param intervalType
* @param interval >0
* @return
*/
public static List<DateSplit> splitDate(Date startTime, Date endTime, IntervalType intervalType, int interval) {
if (interval < 0) {
return null;
}
if (endTime.getTime() <= startTime.getTime()) {
return null;
}
if (intervalType == IntervalType.DAY) {
return splitByDay(startTime, endTime, interval);
}
if (intervalType == IntervalType.HOUR) {
return splitByHour(startTime, endTime, interval);
}
if (intervalType == IntervalType.MINUTE) {
return splitByMinute(startTime, endTime, interval);
}
if (intervalType == IntervalType.SECOND) {
return splitBySecond(startTime, endTime, interval);
}
return null;
}
/**
*
*/
public static List<DateSplit> splitByHour(Date startTime, Date endTime, int intervalHours) {
if (endTime.getTime() <= startTime.getTime()) {
return null;
}
List<DateSplit> dateSplits = new ArrayList<>(256);
DateSplit param = new DateSplit();
param.setStartDateTime(startTime);
param.setEndDateTime(endTime);
param.setEndDateTime(addHours(startTime, intervalHours));
while (true) {
param.setStartDateTime(startTime);
Date tempEndTime = addHours(startTime, intervalHours);
if (tempEndTime.getTime() >= endTime.getTime()) {
tempEndTime = endTime;
}
param.setEndDateTime(tempEndTime);
dateSplits.add(new DateSplit(param.getStartDateTime(), param.getEndDateTime()));
startTime = addHours(startTime, intervalHours);
if (startTime.getTime() >= endTime.getTime()) {
break;
}
if (param.getEndDateTime().getTime() >= endTime.getTime()) {
break;
}
}
return dateSplits;
}
/**
*
*/
public static List<DateSplit> splitBySecond(Date startTime, Date endTime, int intervalSeconds) {
if (endTime.getTime() <= startTime.getTime()) {
return null;
}
List<DateSplit> dateSplits = new ArrayList<>(256);
DateSplit param = new DateSplit();
param.setStartDateTime(startTime);
param.setEndDateTime(endTime);
param.setEndDateTime(addSeconds(startTime, intervalSeconds));
while (true) {
param.setStartDateTime(startTime);
Date tempEndTime = addSeconds(startTime, intervalSeconds);
if (tempEndTime.getTime() >= endTime.getTime()) {
tempEndTime = endTime;
}
param.setEndDateTime(tempEndTime);
dateSplits.add(new DateSplit(param.getStartDateTime(), param.getEndDateTime()));
startTime = addSeconds(startTime, intervalSeconds);
if (startTime.getTime() >= endTime.getTime()) {
break;
}
if (param.getEndDateTime().getTime() >= endTime.getTime()) {
break;
}
}
return dateSplits;
}
/**
*
*/
public static List<DateSplit> splitByDay(Date startTime, Date endTime, int intervalDays) {
if (endTime.getTime() <= startTime.getTime()) {
return null;
}
List<DateSplit> dateSplits = new ArrayList<>(256);
DateSplit param = new DateSplit();
param.setStartDateTime(startTime);
param.setEndDateTime(endTime);
param.setEndDateTime(addDays(startTime, intervalDays));
while (true) {
param.setStartDateTime(startTime);
Date tempEndTime = addDays(startTime, intervalDays);
if (tempEndTime.getTime() >= endTime.getTime()) {
tempEndTime = endTime;
}
param.setEndDateTime(tempEndTime);
dateSplits.add(new DateSplit(param.getStartDateTime(), param.getEndDateTime()));
startTime = addDays(startTime, intervalDays);
if (startTime.getTime() >= endTime.getTime()) {
break;
}
if (param.getEndDateTime().getTime() >= endTime.getTime()) {
break;
}
}
return dateSplits;
}
/**
*
*
* @param startTime
* @param endTime
* @param intervalMinutes
* @return
*/
public static List<DateSplit> splitByMinute(Date startTime, Date endTime, int intervalMinutes) {
if (endTime.getTime() <= startTime.getTime()) {
return null;
}
List<DateSplit> dateSplits = new ArrayList<>(256);
DateSplit param = new DateSplit();
param.setStartDateTime(startTime);
param.setEndDateTime(endTime);
param.setEndDateTime(addMinute(startTime, intervalMinutes));
while (true) {
param.setStartDateTime(startTime);
Date tempEndTime = addMinute(startTime, intervalMinutes);
if (tempEndTime.getTime() >= endTime.getTime()) {
tempEndTime = endTime;
}
param.setEndDateTime(tempEndTime);
dateSplits.add(new DateSplit(param.getStartDateTime(), param.getEndDateTime()));
startTime = addMinute(startTime, intervalMinutes);
if (startTime.getTime() >= endTime.getTime()) {
break;
}
if (param.getEndDateTime().getTime() >= endTime.getTime()) {
break;
}
}
return dateSplits;
}
private static Date addDays(Date date, int days) {
return add(date, Calendar.DAY_OF_MONTH, days);
}
private static Date addHours(Date date, int hours) {
return add(date, Calendar.HOUR_OF_DAY, hours);
}
private static Date addMinute(Date date, int minute) {
return add(date, Calendar.MINUTE, minute);
}
private static Date addSeconds(Date date, int second) {
return add(date, Calendar.SECOND, second);
}
private static Date add(final Date date, final int calendarField, final int amount) {
final Calendar c = Calendar.getInstance();
c.setTime(date);
c.add(calendarField, amount);
return c.getTime();
}
private static String formatDateTime(Date date) {
if (date == null) {
return "";
}
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return simpleDateFormat.format(date);
}
@Data
@AllArgsConstructor
@NoArgsConstructor
public static class DateSplit {
private Date startDateTime;
private Date endDateTime;
public String getStartDateTimeStr() {
return formatDateTime(startDateTime);
}
public String getEndDateTimeStr() {
return formatDateTime(endDateTime);
}
}
}

@ -0,0 +1,93 @@
package com.nmgs.util;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.util.*;
public class DateTimeSplitUtil {
private static SimpleDateFormat sfMin00=new SimpleDateFormat("yyyy-MM-dd HH:00:00");
private static SimpleDateFormat sfMin59=new SimpleDateFormat("yyyy-MM-dd HH:59:59");
private static SimpleDateFormat sf00=new SimpleDateFormat("yyyy-MM-dd 00:00:00");
private static SimpleDateFormat sf23=new SimpleDateFormat("yyyy-MM-dd 23:59:59");
private static SimpleDateFormat format =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
public static void main(String[] args) throws ParseException, CloneNotSupportedException, InterruptedException {
String startTime="2023-05-01 00:00:00";
String endTime="2023-05-16 10:53:22";
System.out.println(splitDateByDay(startTime,endTime));
// System.out.println(splitDateByDay(startTime,endTime));;
}
public static List<Map<String,String>> splitDateByHour(String startTime, String endTime) throws ParseException{
Date currentDate = null;
Date endDate= null;
try {
currentDate= format.parse(startTime);;//DateUtility.parse(startTime)
}catch (Exception e){
LocalDate today = LocalDate.now(); // 获取当前日期
LocalDate firstDayOfMonth = today.withDayOfMonth(1); // 设置当前日期为本月第一天
currentDate = Date.from(firstDayOfMonth.atStartOfDay(ZoneId.systemDefault()).toInstant());
}
try {
endDate= format.parse(endTime); //endTime.parse(endTime)
}catch (Exception e){
endDate = format.parse(format.format(new Date()));
}
List<Map<String,String>> dataList=new ArrayList<>();
boolean first=true;
while(currentDate.compareTo(endDate)<=0){
Map<String,String> dataMap=new HashMap<>();
dataMap.put("startTime",first?format.format(currentDate):sfMin00.format(currentDate));
first=false;
dataMap.put("endTime", DateUtils.addHours(currentDate,1).compareTo(endDate)>0?format.format(endDate):sfMin59.format(currentDate));
dataList.add(dataMap);
currentDate=DateUtils.addHours(currentDate,1);
}
return dataList;
}
public static List<Map<String,String>> splitDateByDay(String startTime,String endTime)throws ParseException{
Date currentDate = null;
Date endDate= null;
try {
currentDate= format.parse(startTime);;//DateUtility.parse(startTime)
}catch (Exception e){
// 获取当前日期
LocalDateTime now = LocalDateTime.now();
// 获取当前日期的00:00:00时间
LocalTime midnight = LocalTime.MIDNIGHT;
LocalDateTime localDateTime = midnight.atDate(LocalDate.now());
// 转换为java.util.Date
ZoneId zoneId = ZoneId.systemDefault(); // 使用系统默认时区
currentDate = Date.from(localDateTime.atZone(zoneId).toInstant());
}
try {
endDate= format.parse(endTime); //endTime.parse(endTime)
}catch (Exception e){
endDate = format.parse(format.format(new Date()));
}
List<Map<String,String>> dataList=new ArrayList<>();
boolean first=true;
while(currentDate.compareTo(endDate)<=0){
Map<String,String> dataMap=new HashMap<>();
dataMap.put("startTime",first?format.format(currentDate):sf00.format(currentDate));
first=false;
dataMap.put("endTime", DateUtils.addDays(currentDate,1).compareTo(endDate)>0?format.format(endDate):sf23.format(currentDate));
dataList.add(dataMap);
currentDate=DateUtils.addDays(currentDate,1);
}
return dataList;
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -5,8 +5,9 @@
<link rel="icon" href="/favicon.ico"/>
<title></title>
<script type="module" crossorigin src="./assets/index.3715579c.js"></script>
<link rel="stylesheet" href="./assets/index.a4241367.css">
<script type="module" crossorigin src="./assets/index.bdc840af.js"></script>
<link rel="stylesheet" href="./assets/index.79767bea.css">
<link rel="stylesheet" type="text/css" href="./static/hdmap.css">
</head>
<body>
<div id="app">
@ -27,6 +28,9 @@
</div>
</div>
<script type="text/javascript" src="../static/bmapOffline/map_load.js"></script>
<script type="text/javascript" src="./static/map_load.js"></script>
<script type="text/javascript" src="./static/hdmap.js"></script>
<script type="text/javascript" src="./static/turf.min.js"></script>
</body>
</html>

File diff suppressed because one or more lines are too long

@ -0,0 +1,335 @@
var BMap = window.BMap
var BMapLib = (window.BMapLib = BMapLib || {})
;(function () {
var b = function (m, l, j) {
l = d(l)
var n = m.pointToPixel(l.getNorthEast())
var i = m.pointToPixel(l.getSouthWest())
n.x += j
n.y -= j
i.x -= j
i.y += j
var h = m.pixelToPoint(n)
var k = m.pixelToPoint(i)
return new BMap.Bounds(k, h)
}
var d = function (i) {
var k = f(i.getNorthEast().lng, -180, 180)
var h = f(i.getSouthWest().lng, -180, 180)
var j = f(i.getNorthEast().lat, -74, 74)
var l = f(i.getSouthWest().lat, -74, 74)
return new BMap.Bounds(new BMap.Point(h, l), new BMap.Point(k, j))
}
var f = function (j, k, h) {
k && (j = Math.max(j, k))
h && (j = Math.min(j, h))
return j
}
var a = function (h) {
return '[object Array]' === Object.prototype.toString.call(h)
}
var c = function (l, n) {
var j = -1
if (a(n)) {
if (n.indexOf) {
j = n.indexOf(l)
} else {
for (var k = 0, h; (h = n[k]); k++) {
if (h === l) {
j = k
break
}
}
}
}
return j
}
var e = (BMapLib.MarkerClusterer = function (l, h) {
if (!l) {
return
}
this._map = l
this._markers = []
this._clusters = []
var k = h || {}
this._gridSize = k.gridSize || 60
this._maxZoom = k.maxZoom || 18
this._minClusterSize = k.minClusterSize || 2
this._isAverageCenter = false
if (k.isAverageCenter != undefined) {
this._isAverageCenter = k.isAverageCenter
}
this._styles = k.styles || []
var j = this
this._map.addEventListener('zoomend', function () {
j._redraw()
})
this._map.addEventListener('moveend', function () {
j._redraw()
})
var i = k.markers
a(i) && this.addMarkers(i)
})
e.prototype.addMarkers = function (k) {
for (var j = 0, h = k.length; j < h; j++) {
this._pushMarkerTo(k[j])
}
this._createClusters()
}
e.prototype._pushMarkerTo = function (h) {
var i = c(h, this._markers)
if (i === -1) {
h.isInCluster = false
this._markers.push(h)
}
}
e.prototype.addMarker = function (h) {
this._pushMarkerTo(h)
this._createClusters()
}
e.prototype._createClusters = function () {
var j = this._map.getBounds()
var l = b(this._map, j, this._gridSize)
for (var k = 0, h; (h = this._markers[k]); k++) {
if (!h.isInCluster && l.containsPoint(h.getPosition())) {
this._addToClosestCluster(h)
}
}
}
e.prototype._addToClosestCluster = function (l) {
var p = 4000000
var n = null
// var k = l.getPosition()
for (var m = 0, j; (j = this._clusters[m]); m++) {
var h = j.getCenter()
if (h) {
var o = this._map.getDistance(h, l.getPosition())
if (o < p) {
p = o
n = j
}
}
}
if (n && n.isMarkerInClusterBounds(l)) {
n.addMarker(l)
} else {
// eslint-disable-next-line
var j = new g(this)
j.addMarker(l)
this._clusters.push(j)
}
}
e.prototype._clearLastClusters = function () {
for (var j = 0, h; (h = this._clusters[j]); j++) {
h.remove()
}
this._clusters = []
this._removeMarkersFromCluster()
}
e.prototype._removeMarkersFromCluster = function () {
for (var j = 0, h; (h = this._markers[j]); j++) {
h.isInCluster = false
}
}
e.prototype._removeMarkersFromMap = function () {
for (var j = 0, h; (h = this._markers[j]); j++) {
h.isInCluster = false
this._map.removeOverlay(h)
}
}
e.prototype._removeMarker = function (h) {
var i = c(h, this._markers)
if (i === -1) {
return false
}
this._map.removeOverlay(h)
this._markers.splice(i, 1)
return true
}
e.prototype.removeMarker = function (h) {
var i = this._removeMarker(h)
if (i) {
this._clearLastClusters()
this._createClusters()
}
return i
}
e.prototype.removeMarkers = function (l) {
var k = false
for (var h = 0; h < l.length; h++) {
var j = this._removeMarker(l[h])
k = k || j
}
if (k) {
this._clearLastClusters()
this._createClusters()
}
return k
}
e.prototype.clearMarkers = function () {
this._clearLastClusters()
this._removeMarkersFromMap()
this._markers = []
}
e.prototype._redraw = function () {
this._clearLastClusters()
this._createClusters()
}
e.prototype.getGridSize = function () {
return this._gridSize
}
e.prototype.setGridSize = function (h) {
this._gridSize = h
this._redraw()
}
e.prototype.getMaxZoom = function () {
return this._maxZoom
}
e.prototype.setMaxZoom = function (h) {
this._maxZoom = h
this._redraw()
}
e.prototype.getStyles = function () {
return this._styles
}
e.prototype.setStyles = function (h) {
this._styles = h
this._redraw()
}
e.prototype.getMinClusterSize = function () {
return this._minClusterSize
}
e.prototype.setMinClusterSize = function (h) {
this._minClusterSize = h
this._redraw()
}
e.prototype.isAverageCenter = function () {
return this._isAverageCenter
}
e.prototype.getMap = function () {
return this._map
}
e.prototype.getMarkers = function () {
return this._markers
}
e.prototype.getClustersCount = function () {
var k = 0
for (var j = 0, h; (h = this._clusters[j]); j++) {
h.isReal() && k++
}
return k
}
function g(h) {
this._markerClusterer = h
this._map = h.getMap()
this._minClusterSize = h.getMinClusterSize()
this._isAverageCenter = h.isAverageCenter()
this._center = null
this._markers = []
this._gridBounds = null
this._isReal = false
this._clusterMarker = new BMapLib.TextIconOverlay(
this._center,
this._markers.length,
{
styles: this._markerClusterer.getStyles(),
}
)
}
g.prototype.addMarker = function (k) {
if (this.isMarkerInCluster(k)) {
return false
}
if (!this._center) {
this._center = k.getPosition()
this.updateGridBounds()
} else {
if (this._isAverageCenter) {
var j = this._markers.length + 1
var o = (this._center.lat * (j - 1) + k.getPosition().lat) / j
var m = (this._center.lng * (j - 1) + k.getPosition().lng) / j
this._center = new BMap.Point(m, o)
this.updateGridBounds()
}
}
k.isInCluster = true
this._markers.push(k)
var h = this._markers.length
if (h < this._minClusterSize) {
this._map.addOverlay(k)
return true
} else {
if (h === this._minClusterSize) {
for (var n = 0; n < h; n++) {
this._markers[n].getMap() && this._map.removeOverlay(this._markers[n])
}
}
}
this._map.addOverlay(this._clusterMarker)
this._isReal = true
this.updateClusterMarker()
return true
}
g.prototype.isMarkerInCluster = function (j) {
if (this._markers.indexOf) {
return this._markers.indexOf(j) != -1
} else {
for (var k = 0, h; (h = this._markers[k]); k++) {
if (h === j) {
return true
}
}
}
return false
}
g.prototype.isMarkerInClusterBounds = function (h) {
return this._gridBounds.containsPoint(h.getPosition())
}
g.prototype.isReal = function () {
return this._isReal
}
g.prototype.updateGridBounds = function () {
var h = new BMap.Bounds(this._center, this._center)
this._gridBounds = b(this._map, h, this._markerClusterer.getGridSize())
}
g.prototype.updateClusterMarker = function () {
if (this._map.getZoom() > this._markerClusterer.getMaxZoom()) {
this._clusterMarker && this._map.removeOverlay(this._clusterMarker)
for (var l = 0, j; (j = this._markers[l]); l++) {
this._map.addOverlay(j)
}
return
}
if (this._markers.length < this._minClusterSize) {
this._clusterMarker.hide()
return
}
this._clusterMarker.setPosition(this._center)
this._clusterMarker.setText(this._markers.length)
var k = this._map
var h = this.getBounds()
this._clusterMarker.addEventListener('click', function () {
k.setViewport(h)
})
}
g.prototype.remove = function () {
// eslint-disable-next-line
for (var j = 0, h; (h = this._markers[j]); j++) {
this._markers[j].getMap() && this._map.removeOverlay(this._markers[j])
}
this._map.removeOverlay(this._clusterMarker)
this._markers.length = 0
delete this._markers
}
g.prototype.getBounds = function () {
var k = new BMap.Bounds(this._center, this._center)
for (var j = 0, h; (h = this._markers[j]); j++) {
k.extend(h.getPosition())
}
return k
}
g.prototype.getCenter = function () {
return this._center
}
})()

File diff suppressed because one or more lines are too long

@ -0,0 +1,2 @@
window.mapCenter = [111.80282489244144, 41.72225716089292]
window.mapZoom = 5.4

File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save