| | |
| | | import springfox.documentation.swagger2.annotations.EnableSwagger2; |
| | | |
| | | /** |
| | | * 应用程序 |
| | | * @author WWW |
| | | * 排除Security:, exclude = {SecurityAutoConfiguration.class, SecurityFilterAutoConfiguration.class} |
| | | * |
| | | * jar -> war:继承 SpringBootServletInitializer,实现 configure 函数 |
| | |
| | | import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; |
| | | import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; |
| | | |
| | | /** |
| | | * @author wMeng |
| | | * @ClassName CorsConfig |
| | | * @Description 跨域配置 |
| | | * @date 2022/10/31 16:42 |
| | | * @Version 1.0 |
| | | */ |
| | | @Configuration |
| | | public class CorsConfig extends WebMvcConfigurationSupport { |
| | | @Override |
| | | public void addViewControllers(ViewControllerRegistry registry) { |
| | | // 设置访问路径为 “/” 跳转到指定页面 |
| | | registry.addViewController("/").setViewName("redirect:/doc.html"); |
| | | // 设置为最高优先级 |
| | | registry.setOrder(Ordered.HIGHEST_PRECEDENCE); |
| | | } |
| | | |
| | |
| | | |
| | | @Override |
| | | public void addResourceHandlers(ResourceHandlerRegistry registry) { |
| | | //设置静态资源映射 |
| | | registry.addResourceHandler("/backend/**").addResourceLocations("classpath:/backend/"); |
| | | registry.addResourceHandler("/front/**").addResourceLocations("classpath:/front/"); |
| | | |
| | |
| | | |
| | | import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j; |
| | | |
| | | /** |
| | | * @author wMeng |
| | | * @ClassName SwaggerConfig |
| | | * @Description TODO |
| | | * @date 2022/10/31 18:55 |
| | | * @Version 1.0 |
| | | */ |
| | | @Configuration |
| | | @EnableKnife4j |
| | | public class Knife4jConfig { |
| | |
| | | @Value("${knife4j.enabled}") |
| | | private boolean enabled; |
| | | |
| | | /** |
| | | * 设置请求的统一前缀 |
| | | */ |
| | | @Value("${knife4j.pathMapping}") |
| | | private String pathMapping; |
| | | |
| | |
| | | |
| | | private ApiInfo apiInfo() { |
| | | return new ApiInfoBuilder() |
| | | //描述字段支持Markdown语法 |
| | | .description("我的接口测试文档") |
| | | .contact(new Contact("张腾飞", "http://127.0.0.1:9001/doc.html", "893732661@qq.com")) |
| | | .version("2.0.0") |
| | |
| | | |
| | | //String md5 = FileUtils.getFileMd5(filePath); |
| | | //if (null != md5 && md5List.contains(md5)) { |
| | | // continue; // csv已入库 |
| | | // continue; |
| | | //} |
| | | |
| | | int count = vocValsService.countByTime(time); |
| | | if (count > 0) { |
| | | //vocValsService.deleteByTime(time); // 删除已入库 |
| | | //vocValsService.deleteByTime(time); |
| | | continue; |
| | | } |
| | | |
| | |
| | | logger.info(file.getAbsolutePath() + " is not exist !"); |
| | | return; |
| | | } |
| | | //创建表 |
| | | |
| | | String newTableName = TableStrategy.getTableStrategy(time); |
| | | suYuanService.createNewTable(newTableName); |
| | | dictRecordService.insertDictRecord(new DictRecord(1L, newTableName, Long.parseLong(time), "")); |
| | | EasyCsv.read(filePath, SuYuan.class, new CsvParser(suYuanService, time)).doRead(); |
| | | //计算预警/报警,并且进行入库操作 |
| | | |
| | | try { |
| | | Thread.sleep(60 * 1000); |
| | | } catch (InterruptedException e) { |
| | |
| | | warningAnalyseService.warningOperationStorage(date); |
| | | } |
| | | |
| | | /** |
| | | * 创建日报:每日0时1分 |
| | | */ |
| | | @Scheduled(cron = "0 1 0 * * ?") |
| | | public void createDayReport() { |
| | | Calendar calendar = getCalendar(1); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 创建周报:每周一0时5分 |
| | | */ |
| | | @Scheduled(cron = "0 5 0 ? * MON") |
| | | public void createWeekReport() { |
| | | Calendar calendar = getCalendar(7 * 24); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 创建月报:每月1日0时9分 |
| | | */ |
| | | @Scheduled(cron = "0 9 0 1 * ?") |
| | | public void createMonthReport() { |
| | | Calendar calendar = Calendar.getInstance(); |
| | |
| | | import org.springframework.scheduling.annotation.EnableAsync; |
| | | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; |
| | | |
| | | /** |
| | | * 线程池配置 |
| | | * |
| | | * @author tam |
| | | **/ |
| | | @Configuration |
| | | @EnableAsync |
| | | public class ThreadPoolConfig { |
| | | // 核心线程池大小 |
| | | private int corePoolSize = 50; |
| | | |
| | | // 最大可创建的线程数 |
| | | private int maxPoolSize = 200; |
| | | |
| | | // 队列最大长度 |
| | | private int queueCapacity = 1000; |
| | | |
| | | // 线程池维护线程所允许的空闲时间 |
| | | private int keepAliveSeconds = 300; |
| | | |
| | | //配置线程池中的线程的名称前缀 |
| | | |
| | | private String threadNamePrefix = "async-importDB-"; |
| | | |
| | | @Bean(name = "threadPoolTaskExecutor") |
| | |
| | | executor.setQueueCapacity(queueCapacity); |
| | | executor.setKeepAliveSeconds(keepAliveSeconds); |
| | | executor.setThreadNamePrefix(threadNamePrefix); |
| | | // 线程池对拒绝任务(无线程可用)的处理策略 |
| | | executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); |
| | | return executor; |
| | | } |
| | | |
| | | } |
| | |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.web.socket.server.standard.ServerEndpointExporter; |
| | | |
| | | /** |
| | | * WebSocket配置类 |
| | | * @author WWW |
| | | */ |
| | | @Component |
| | | public class WebSocketConfig { |
| | | /** |
| | | * 自动注册使用@ServerEndpoint |
| | | */ |
| | | @Bean |
| | | public ServerEndpointExporter serverEndpointExporter() { |
| | | return new ServerEndpointExporter(); |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | /** |
| | | * @author lishijia |
| | | * @ClassName YsshPfshController |
| | | * @Description TODO |
| | | * @date 2022/11/24 14:44 |
| | | * @Version 1.0 |
| | | */ |
| | | @Api(tags="排放点") |
| | | @RestController |
| | | @RequestMapping("/emission") |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | /** |
| | | * @author wMeng |
| | | * @ClassName YsshLocationController |
| | | * @Description YsshLocationController |
| | | * @date 2022/10/30 13:21 |
| | | * @Version 1.0 |
| | | */ |
| | | @Api(tags="厂区热点点位") |
| | | @RestController |
| | | @RequestMapping("/location") |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | /** |
| | | * @author lishijia |
| | | * @ClassName Yssh2dreliController |
| | | * @Description Yssh2dreliController |
| | | * @date 2022/12/3 21:21 |
| | | * @Version 1.0 |
| | | */ |
| | | @Api(tags="溯源信息") |
| | | @RestController |
| | | @RequestMapping("/suYuan") |
| | |
| | | package com.yssh.controller; |
| | | |
| | | import com.yssh.entity.Qxsh; |
| | | import com.yssh.entity.Report; |
| | | import com.yssh.utils.CacheUtils; |
| | | import com.yssh.utils.DateUtils; |
| | |
| | | package com.yssh.controller; |
| | | |
| | | import com.yssh.entity.Location; |
| | | import com.yssh.entity.Weather; |
| | | import com.yssh.service.WeatherService; |
| | | import com.yssh.utils.CacheUtils; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author wMeng |
| | | * @ClassName YsshWeatherController |
| | | * @Description TODO |
| | | * @date 2022/10/30 13:21 |
| | | * @Version 1.0 |
| | | */ |
| | | @Api(tags="天气") |
| | | @RestController |
| | | @RequestMapping("/weather") |
| | |
| | | package com.yssh.entity; |
| | | |
| | | /** |
| | | * 坐标 |
| | | * @author WWW |
| | | * @date 2023-06-18 |
| | | */ |
| | | public class Coordinate { |
| | | private double x; |
| | | |
| | |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | |
| | | /** |
| | | * 字典记录对象 yssh_dict_record |
| | | * |
| | | * @author xingjinshuang@smartearth.cn |
| | | * @date 2023-02-06 |
| | | */ |
| | | |
| | | @ToString |
| | | @Data |
| | | public class DictRecord implements Serializable { |
| | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 厂区热点点位 |
| | | * @author wMeng |
| | | * @date 2022/10/30 13:16 |
| | | * @version 1.0 |
| | | */ |
| | | @Data |
| | | @ApiModel(value = "厂区热点点位",description = "厂区热点点位") |
| | | public class Location implements Serializable { |
| | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author WWW |
| | | * @date 2023-05-18 |
| | | * qxsh |
| | | */ |
| | | @Data |
| | | @ApiModel(value = "Qxsh",description = "Qxsh") |
| | | public class Qxsh { |
| | |
| | | import com.yssh.utils.CalculateUtils; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | |
| | | /** |
| | | * 报告 |
| | | * @author WWW |
| | | * @date 2023-06-18 |
| | | */ |
| | | public class Report { |
| | | @ApiModelProperty(value = "溯源ID") |
| | | private String id; |
| | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 溯源700表 |
| | | * @author www |
| | | * @date 2023-06-23 |
| | | */ |
| | | @Data |
| | | public class SuYuan700 implements Serializable { |
| | | private static final long serialVersionUID = 2023062302487367361L; |
| | |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 快速溯源表 |
| | | * @author WWW |
| | | * @date 2023-11-05 |
| | | */ |
| | | @Data |
| | | public class SuYuanFast { |
| | | private static final long serialVersionUID = 2023110510570000000L; |
| | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | |
| | | /** |
| | | * @author wMeng |
| | | * @ClassName YsshWeather |
| | | * @Description 天气数据 |
| | | * @date 2022/10/30 13:18 |
| | | * @Version 1.0 |
| | | */ |
| | | @Data |
| | | @ApiModel(value = "天气数据",description = "天气数据") |
| | | public class Weather { |
| | |
| | | package com.yssh.entity.xls; |
| | | |
| | | /** |
| | | * 日报Excel |
| | | * @author WWW |
| | | * @date 2023-08-08 |
| | | */ |
| | | public class DayExcel { |
| | | /** |
| | | * 日均值 |
| | |
| | | import java.lang.annotation.RetentionPolicy; |
| | | import java.lang.annotation.Target; |
| | | |
| | | /** |
| | | * Excel标题头类 |
| | | * @author WWW |
| | | * @date 2023-08-08 |
| | | */ |
| | | @Target(ElementType.TYPE) |
| | | @Retention(RetentionPolicy.RUNTIME) |
| | | public @interface ExcelHead { |
| | | /** |
| | | * Excel头行数 |
| | | * |
| | | * @return 头行数 |
| | | */ |
| | | int headRows() default 1; |
| | | |
| | | /** |
| | | * 排除的Sheet名称(多个用逗号隔开) |
| | | * |
| | | * @return |
| | | */ |
| | | String excludeSheets() default ""; |
| | | } |
| | |
| | | package com.yssh.entity.xls; |
| | | |
| | | /** |
| | | * 月报Excel |
| | | * @author WWW |
| | | * @date 2023-08-08 |
| | | */ |
| | | public class MonthExcel { |
| | | /** |
| | | * 上月 |
| | |
| | | public MonthExcel() { |
| | | } |
| | | |
| | | /** |
| | | * 月报Excel |
| | | * |
| | | * @param sy 上月 |
| | | * @param yhb 月环比 |
| | | * @param ytq 月同期 |
| | | * @param ytb 月同比 |
| | | * @param lj 累计 |
| | | * @param ljtb 累计同比 |
| | | * @param qyn 较前一年均值变化幅度 |
| | | * @param ys 受影响因素及原因 |
| | | * @param fs 风速 |
| | | * @param fx 风向 |
| | | * @param wd 温度 |
| | | */ |
| | | public MonthExcel(String sy, String yhb, String ytq, String ytb, String lj, String ljtb, String qyn, String ys, String fs, String fx, String wd) { |
| | | this.sy = sy; |
| | | this.yhb = yhb; |
| | |
| | | package com.yssh.entity.xls; |
| | | |
| | | /** |
| | | * 周报Excel |
| | | * @author WWW |
| | | * @date 2023-08-08 |
| | | */ |
| | | public class WeekExcel { |
| | | /** |
| | | * 上周 |
| | |
| | | public WeekExcel() { |
| | | } |
| | | |
| | | /** |
| | | * 周报Excel |
| | | * |
| | | * @param sz 上周 |
| | | * @param zhb 周环比 |
| | | * @param ztq 周同期 |
| | | * @param ztb 周同比 |
| | | * @param lj 累计 |
| | | * @param ljtb 累计同比 |
| | | * @param syn 较上一年度变化幅度 |
| | | * @param ys 受影响因素及原因 |
| | | * @param fs 风速 |
| | | * @param fx 风向 |
| | | * @param wd 温度 |
| | | */ |
| | | public WeekExcel(String sz, String zhb, String ztq, String ztb, String lj, String ljtb, String syn, String ys, String fs, String fx, String wd) { |
| | | this.sz = sz; |
| | | this.zhb = zhb; |
| | |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * Excel报告实体类 |
| | | * @author WWW |
| | | * @date 2023-08-09 |
| | | */ |
| | | public class XlsReport { |
| | | @ApiModelProperty(value = "主键") |
| | | private Long id; |
| | |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | /** |
| | | * @ClassName: CommonMapper |
| | | * @Description: 通用的mapper |
| | | * @author zhangtengfei |
| | | * @date 2023年2月27日下午2:27:55 |
| | | */ |
| | | @Mapper |
| | | public interface CommonMapper{ |
| | | |
| | | /** |
| | | * 使用information_schema检查表是否存在 |
| | | * @param tableSchema |
| | |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | /** |
| | | * 字典记录Mapper接口 |
| | | * |
| | | * @author xingjinshuang@smartearth.cn |
| | | * @date 2023-02-06 |
| | | */ |
| | | @Mapper |
| | | public interface DictRecordMapper { |
| | | |
| | | /** |
| | | * 查询字典记录列表 |
| | | * @param dictRecord 字典记录 |
| | |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | /** |
| | | * @author wMeng |
| | | * @ClassName YsshQxshMapper |
| | | * @Description TODO |
| | | * @date 2022/10/31 14:45 |
| | | * @Version 1.0 |
| | | */ |
| | | @Mapper |
| | | public interface EmissionMapper { |
| | | List<Emission> query(@Param("name") String name); |
| | |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author wMeng |
| | | * @date 2022/10/30 13:37 |
| | | * @version 1.0 |
| | | */ |
| | | @Mapper |
| | | public interface LocationMapper { |
| | | List<Location> query(@Param("name") String name, @Param("type") String type); |
| | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author WWW |
| | | * @date 2023-05-18 |
| | | * QxshMapper |
| | | */ |
| | | @Mapper |
| | | public interface QxshMapper { |
| | | List<SuYuanMonitorData> getNewMonitorData(String name, String start, String end); |
| | |
| | | |
| | | @Mapper |
| | | public interface ThuAccuracyMapper { |
| | | |
| | | //查询过去七天精确平均值统计 |
| | | public Double selectSevenDayAccuracyAvg(Long beginTime); |
| | | |
| | |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * Voc值Mapper接口 |
| | | * @author WWW |
| | | * @date 2023-06-05 |
| | | */ |
| | | @Mapper |
| | | public interface VocValsMapper { |
| | | /** |
| | |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author wMeng |
| | | * @ClassName YsshWeatherMapper |
| | | * @Description TODO |
| | | * @date 2022/10/30 14:16 |
| | | * @Version 1.0 |
| | | */ |
| | | @Mapper |
| | | public interface WeatherMapper { |
| | | List<Weather> query(@Param("begin") String begin, @Param("end") String end); |
| | |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * XlsReportMapper |
| | | * @author WWW |
| | | * @date 2023-08-09 |
| | | */ |
| | | @Mapper |
| | | public interface XlsReportMapper { |
| | | /** |
| | |
| | | @Resource |
| | | protected DatFilePathConfig datFilePathConfig; |
| | | |
| | | /** |
| | | * 检查表是否存在 |
| | | */ |
| | | public boolean checkTableExists(String tableName) { |
| | | try { |
| | | Integer count = commonMapper.checkTableExistsWithSchema(TABLE_SCHEMA, tableName); |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | /** |
| | | * 字典记录Service业务层处理 |
| | | * @author xingjinshuang@smartearth.cn |
| | | * @date 2023-02-06 |
| | | */ |
| | | @Service |
| | | public class DictRecordService { |
| | | @Resource |
| | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 邮件服务类 |
| | | * |
| | | * @author www |
| | | * @date 2024-03-21 |
| | | */ |
| | | @Service |
| | | public class EmailService { |
| | | @Value("${email.userName}") |
| | |
| | | protected final Logger logger = LoggerFactory.getLogger(this.getClass()); |
| | | |
| | | public Session createSession() { |
| | | // 创建一个配置文件,并保存 |
| | | Properties props = new Properties(); |
| | | |
| | | // SMTP服务器连接信息:126—smtp.126.com,163—smtp.163.com,qq-smtp.qq.com" |
| | | props.put("mail.smtp.host", smtpHost); // SMTP主机名 |
| | | props.put("mail.smtp.port", smtpPort); // 主机端口号:126—25,163—645,qq-587 |
| | | props.put("mail.smtp.auth", smtpAuth); // 是否需要用户认证 |
| | | props.put("mail.smtp.starttls.enale", smtpTls); // 启用TlS加密 |
| | | // 126—smtp.126.com,163—smtp.163.com,qq-smtp.qq.com" |
| | | props.put("mail.smtp.host", smtpHost); |
| | | props.put("mail.smtp.port", smtpPort); |
| | | props.put("mail.smtp.auth", smtpAuth); |
| | | props.put("mail.smtp.starttls.enale", smtpTls); |
| | | |
| | | Session session = Session.getInstance(props, new Authenticator() { |
| | | @Override |
| | |
| | | } |
| | | }); |
| | | |
| | | // 控制台打印调试信息 |
| | | session.setDebug(debug); |
| | | |
| | | return session; |
| | |
| | | return null; |
| | | } |
| | | |
| | | // 创建Session会话 |
| | | Session session = createSession(); |
| | | |
| | | // 创建邮件对象 |
| | | MimeMessage message = new MimeMessage(session); |
| | | message.setSubject(title); |
| | | message.setText(text); |
| | |
| | | message.setRecipients(Message.RecipientType.CC, ias); |
| | | } |
| | | |
| | | // 发送 |
| | | Transport.send(message); |
| | | |
| | | return true; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | /** |
| | | * @author wMeng |
| | | * @ClassName YsshQxshServiceImpl |
| | | * @Description TODO |
| | | * @date 2022/10/31 14:45 |
| | | * @Version 1.0 |
| | | */ |
| | | @Service |
| | | public class EmissionService { |
| | | @Resource |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author wMeng |
| | | * @date 2022/10/30 13:25 |
| | | * @version 1.0 |
| | | */ |
| | | @Service |
| | | public class LocationService { |
| | | @Resource |
| | |
| | | import java.io.PrintWriter; |
| | | import java.net.Socket; |
| | | |
| | | /** |
| | | * Socket服务类 |
| | | * @author WWW |
| | | * @date 2023-11-06 |
| | | */ |
| | | @Service |
| | | public class SocketService { |
| | | /** |
| | | * Socket的IP |
| | | */ |
| | | @Value("${socket.ip}") |
| | | private String ip; |
| | | |
| | | /** |
| | | * Socket的端口 |
| | | */ |
| | | @Value("${socket.port}") |
| | | private int port; |
| | | |
| | | /** |
| | | * Socket的端口 |
| | | */ |
| | | @Value("${cmd.runPy}") |
| | | private String runPy; |
| | | |
| | | private final Logger logger = LoggerFactory.getLogger(this.getClass()); |
| | | |
| | | /** |
| | | * 发送消息 |
| | | */ |
| | | public String sendMsg(String msg) throws Exception { |
| | | try { |
| | | // 创建Socket对象,指定服务端的IP地址和端口号 |
| | | Socket socket = new Socket(ip, port); |
| | | |
| | | // 获取输入流和输出流 输入流和输出流是通过socket对象来进行数据传输的。 |
| | | BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream())); |
| | | PrintWriter out = new PrintWriter(socket.getOutputStream(), true); |
| | | |
| | | // 将用户输入的信息发送给服务端 |
| | | out.println(msg); |
| | | |
| | | // 接收服务端的响应并打印 |
| | | String rs = in.readLine(); |
| | | |
| | | socket.close(); |
| | | |
| | | // 执行Python脚本 |
| | | exec(runPy); |
| | | |
| | | return rs; |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 执行命令 |
| | | * |
| | | * @param cmd 命令 |
| | | */ |
| | | public void exec(String cmd) { |
| | | try { |
| | | Process process = Runtime.getRuntime().exec(cmd); |
| | |
| | | //@Transactional |
| | | @Async("threadPoolTaskExecutor") |
| | | public void insertSuYuanDatasAsync(List<SuYuan> lists, String time) throws Exception { |
| | | //插入数据 |
| | | List<List<SuYuan>> list = Lists.partition(lists, AsyncService.BATCH_INSERT_NUMBER); |
| | | CountDownLatch countDownLatch = new CountDownLatch(list.size()); |
| | | for (List<SuYuan> corpReserveList : list) { |
| | |
| | | return suYuanId; |
| | | } |
| | | |
| | | /** |
| | | * 根据ID查询快速溯源 |
| | | */ |
| | | public List<SuYuanFast> selectFastById(String id, Date date) { |
| | | String time = DateUtils.getYyyyMmDdHhMmSs(date); |
| | | |
| | |
| | | |
| | | private void executeAsync(List<VocVals> corpList, CountDownLatch countDownLatch) { |
| | | try { |
| | | // 异步线程要做的事情 |
| | | vocValsMapper.inserts(corpList); |
| | | } finally { |
| | | // 很关键, 无论上面程序是否异常必须执行countDown,否则await无法释放 |
| | | countDownLatch.countDown(); |
| | | } |
| | | } |
| | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author wMeng |
| | | * @ClassName YsshWeatherServiceImpl |
| | | * @Description TODO |
| | | * @date 2022/10/30 14:11 |
| | | * @Version 1.0 |
| | | */ |
| | | @Service |
| | | public class WeatherService { |
| | | @Resource |
| | |
| | | import java.io.IOException; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * Excel导出服务类 |
| | | * @author WWW |
| | | * @author 2023-08-05 |
| | | */ |
| | | @Service |
| | | public class XlsReportService { |
| | | protected final Logger logger = LoggerFactory.getLogger(this.getClass()); |
| | |
| | | @Value("${report.templates}") |
| | | private String templates; |
| | | |
| | | /** |
| | | * 获取导出路径 |
| | | */ |
| | | private String getExpPath(String type) { |
| | | String path = reportPath + File.separator + type; |
| | | |
| | |
| | | return path; |
| | | } |
| | | |
| | | /** |
| | | * 获取Excel模板 |
| | | */ |
| | | private String getXslTemplate(String type) throws IOException { |
| | | //ClassPathResource resource = new ClassPathResource(String.format("templates/%s.xlsx", type)); |
| | | //return resource.exists() ? resource.getFile().getPath() : null; |
| | |
| | | return String.format(templates + File.separator + type + ".xlsx"); |
| | | } |
| | | |
| | | /** |
| | | * 创建Excel |
| | | */ |
| | | private <T> void createExcel(String source, String target, List<T> list) { |
| | | Map<String, List<T>> map = new HashMap<>(); |
| | | map.put("data", list); |
| | |
| | | ExcelUtils.writeToTemplate(source, target, map); |
| | | } |
| | | |
| | | /** |
| | | * 获取字符串日期 |
| | | */ |
| | | private String getStrDate(String type, Date date) { |
| | | return DateUtils.parseDateToStr("month".equals(type) ? DateUtils.YYYYMM : DateUtils.YYYYMMDD, date); |
| | | } |
| | | |
| | | /** |
| | | * 获取目标文件 |
| | | */ |
| | | private String getTarget(String type, Date date) { |
| | | String strData = getStrDate(type, date); |
| | | |
| | | return String.format("%s\\%s.xlsx", getExpPath(type), strData); |
| | | } |
| | | |
| | | /** |
| | | * Excel是/否存在 |
| | | */ |
| | | private boolean xlsExists(String type, Date date) { |
| | | String target = getTarget(type, date); |
| | | File f = new File(target); |
| | |
| | | return f.exists() && !f.isDirectory(); |
| | | } |
| | | |
| | | /** |
| | | * 创建Excel |
| | | */ |
| | | private <T> String createExcel(String type, Date date, List<T> list) throws Exception { |
| | | String source = getXslTemplate(type); |
| | | String strData = getStrDate(type, date); |
| | |
| | | return String.format("%s\\%s.xlsx", type, strData); |
| | | } |
| | | |
| | | /** |
| | | * 记录是/否存在 |
| | | */ |
| | | private boolean recordExists(String type, Date date) { |
| | | String name = String.format("%s.xlsx", getStrDate(type, date)); |
| | | int rows = mapper.reportExists(type, name); |
| | |
| | | return rows > 0; |
| | | } |
| | | |
| | | /** |
| | | * 保存结果 |
| | | */ |
| | | private <T> void saveResult(String type, Date date, List<T> list) throws Exception { |
| | | String filePath = createExcel(type, date, list); |
| | | if (recordExists(type, date)) return; |
| | |
| | | mapper.insertReport(xls); |
| | | } |
| | | |
| | | /** |
| | | * 获取受影响因素及原因 |
| | | */ |
| | | public String getYs(List<SuYuan700> suList) { |
| | | if (null == suList || 0 == suList.size()) return ""; |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据ID下载 |
| | | */ |
| | | public void downloadById(Integer id, HttpServletResponse res) { |
| | | XlsReport xlsReport = mapper.selectById(id); |
| | | if (null == xlsReport) return; |
| | |
| | | |
| | | import java.util.HashMap; |
| | | |
| | | /** |
| | | * 操作消息提醒 |
| | | * |
| | | * @author xingjinshuang@smartearth.cn |
| | | * @date 2023-02-06 |
| | | */ |
| | | public class AjaxResult extends HashMap<String, Object> { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | |
| | | |
| | | BigInteger bigInt = new BigInteger(1, byteArray); |
| | | |
| | | // 参数16表示16进制 |
| | | String result = bigInt.toString(16); |
| | | |
| | | // 不足32位高位补零 |
| | | while (result.length() < 32) { |
| | | result = "0" + result; |
| | | } |
| | |
| | | import org.geotools.referencing.crs.DefaultGeographicCRS; |
| | | import org.opengis.referencing.crs.CoordinateReferenceSystem; |
| | | |
| | | @SuppressWarnings("ALL") |
| | | public class CalculateUtils { |
| | | /** |
| | | * 默认地球半径,赤道半径(单位m) |
| | | */ |
| | | private final static double EARTH_RADIUS1 = 6371000; |
| | | |
| | | /** |
| | | * 转化为弧度(rad) |
| | | */ |
| | | private static double rad(double d) { |
| | | return d * Math.PI / 180.0; |
| | | } |
| | | |
| | | /** |
| | | * 计算距离1 |
| | | */ |
| | | public static double getDistance1(double lon1, double lat1, double lon2, double lat2) { |
| | | double radLat1 = rad(lat1); |
| | | double radLat2 = rad(lat2); |
| | |
| | | return round2(s); |
| | | } |
| | | |
| | | /** |
| | | * 计算距离2 |
| | | */ |
| | | public static double getDistance2(double x1, double y1, double x2, double y2) { |
| | | // 84坐标系构造GeodeticCalculator |
| | | GeodeticCalculator geodeticCalculator = new GeodeticCalculator(DefaultGeographicCRS.WGS84); |
| | |
| | | return round2(distance); |
| | | } |
| | | |
| | | /** |
| | | * 保留2位小数 |
| | | */ |
| | | public static double round2(double d) { |
| | | return ((long) (d * 100)) / 100D; |
| | | } |
| | | |
| | | /** |
| | | * 保留6位小数 |
| | | */ |
| | | public static double round6(double d) { |
| | | return ((long) (d * 1000000)) / 1000000D; |
| | | } |
| | | |
| | | /** |
| | | * 计算角度 |
| | | */ |
| | | public static double getAngle(double x1, double y1, double x2, double y2) { |
| | | try { |
| | | CoordinateReferenceSystem crs = CRS.decode("EPSG:4326"); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 计算角度2 |
| | | */ |
| | | public static double getAngle2(double x1, double y1, double x2, double y2) { |
| | | try { |
| | | DirectPosition2D p1 = new DirectPosition2D(x1, y1); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取坐标 |
| | | * |
| | | * @param su |
| | | * @return |
| | | */ |
| | | public static Coordinate getCoordinate(DistanceSuYuan su) { |
| | | String[] sirs = su.getId().split("_"); |
| | | |
| | |
| | | return new Coordinate(lon, lat); |
| | | } |
| | | |
| | | /** |
| | | * 计算经度 |
| | | * |
| | | * @param @param x |
| | | * @param @param y |
| | | * @param @return 参数 |
| | | * @return double 返回类型 |
| | | * @throws |
| | | * @Title: getLon |
| | | * @Description: 计算经度 |
| | | */ |
| | | public static double getLon(int x, int y) { |
| | | double lon = 115.9165227 + 0.000116732 * (x - 0.5) + 0.00000116862 * (y - 0.5); |
| | | if (lon < 115 || lon > 116) { |
| | |
| | | return round6(lon); |
| | | } |
| | | |
| | | /** |
| | | * 计算维度 |
| | | * |
| | | * @param @param x |
| | | * @param @param y |
| | | * @param @return 参数 |
| | | * @return double 返回类型 |
| | | * @throws |
| | | * @Title: getLat |
| | | * @Description: 计算维度 |
| | | */ |
| | | public static double getLat(int x, int y) { |
| | | double lat = 39.77250000 + 0.000001000 * (x - 0.5) - 0.00009000000 * (y - 0.5); |
| | | if (lat < 39 || lat > 40) { |
| | |
| | | return round6(lat); |
| | | } |
| | | |
| | | /** |
| | | * @param @param checkPoints |
| | | * @param @return 参数 |
| | | * @return List<String> 返回类型 |
| | | * @throws |
| | | * @Title: assembleId |
| | | * @Description: 组装id |
| | | */ |
| | | public static List<String> assembleId(List<MonitorPointPosition> checkPoints) { |
| | | List<String> ids2d = new ArrayList<>(); |
| | | for (MonitorPointPosition point : checkPoints) { |
| | |
| | | return ids2d; |
| | | } |
| | | |
| | | /** |
| | | * @param @param checkPoint |
| | | * @param @param range |
| | | * @param @return 参数 |
| | | * @return List<String> 返回类型 |
| | | * @Title: aloneCrosswiseScope |
| | | * @Description: 单独点位横向范围扩展 |
| | | * @backup 强制将层级改为 0 |
| | | */ |
| | | public static List<String> aloneCrosswiseExtend(MonitorPointPosition checkPoint, int range) { |
| | | List<String> ids = new ArrayList<>(); |
| | | Integer x = checkPoint.getX(); |
| | |
| | | return ids; |
| | | } |
| | | |
| | | /** |
| | | * 根据范围获取查询条件 |
| | | */ |
| | | public static String getFilterByExtend(MonitorPointPosition point, int range) { |
| | | Integer x = point.getX(); |
| | | Integer y = point.getY(); |
| | |
| | | return ids3d; |
| | | } |
| | | |
| | | /** |
| | | * 获取方向 |
| | | */ |
| | | public static String getDir(double direction) { |
| | | if (direction < 0) { |
| | | direction = direction + 360; |
| | |
| | | return "北"; |
| | | } |
| | | |
| | | /** |
| | | * 计算X、Y值的矩形框 |
| | | */ |
| | | public static List<Coordinate> calcRect(double x, double y) { |
| | | double buffer = 10; |
| | | double dis = round6(Math.sqrt(Math.pow(buffer / 2, 2) * 2)); |
| | |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 根据距离和角度获取目标点 |
| | | */ |
| | | private static Coordinate getPointByDisAndAngle(double x, double y, double angle, double dis) { |
| | | try { |
| | | DirectPosition2D p1 = new DirectPosition2D(x, y); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @param @return 参数 |
| | | * @return Double 返回类型 |
| | | * @throws |
| | | * @Title: getWindSpeed |
| | | * @Description: 计算风速 |
| | | */ |
| | | public static Double getWindSpeed(double v, double u) { |
| | | return round6(Math.sqrt(v * v + u * u)); |
| | | } |
| | | |
| | | /** |
| | | * @param @param v |
| | | * @param @param u |
| | | * @param @return 参数 |
| | | * @return double 返回类型 |
| | | * @throws |
| | | * @Title: getWindDirection |
| | | * @Description: 计算风向 |
| | | */ |
| | | public static double getWindDirection(double v, double u) { |
| | | double result = Math.atan(u / (v + Math.pow(10, -5))) / Math.PI * 180; |
| | | if (result < 0) { |
| | |
| | | return round6(result); |
| | | } |
| | | |
| | | /** |
| | | * @param @param list 排序对象 |
| | | * @param @param property 排序参数 |
| | | * @param @param order 排序顺序 |
| | | * @param @return 参数 |
| | | * @return List<Map < String, Object>> 返回类型 |
| | | * @throws |
| | | * @Title: sort |
| | | * @Description: 排序 |
| | | */ |
| | | public static List<Map<String, Object>> sort(List<Map<String, Object>> list, final String property, final boolean order) { |
| | | if (list == null || property == null) { |
| | | return null; |
| | |
| | | package com.yssh.utils; |
| | | |
| | | /** |
| | | * @author wMeng |
| | | * @ClassName CommonConstant |
| | | * @Description TODO |
| | | * @date 2022/10/30 13:30 |
| | | * @Version 1.0 |
| | | */ |
| | | public interface CommonConstant { |
| | | |
| | | /** {@code 500 Server Error} (HTTP/1.0 - RFC 1945) */ |
| | | /** |
| | | * {@code 500 Server Error} (HTTP/1.0 - RFC 1945) |
| | | */ |
| | | public static final Integer SC_INTERNAL_SERVER_ERROR_500 = 500; |
| | | /** {@code 200 OK} (HTTP/1.0 - RFC 1945) */ |
| | | /** |
| | | * {@code 200 OK} (HTTP/1.0 - RFC 1945) |
| | | */ |
| | | public static final Integer SC_OK_200 = 200; |
| | | |
| | | /**访问权限认证未通过 510*/ |
| | | public static final Integer SC_JEECG_NO_AUTHZ=510; |
| | | |
| | | |
| | | |
| | | /** |
| | | * 访问权限认证未通过 510 |
| | | */ |
| | | public static final Integer SC_JEECG_NO_AUTHZ = 510; |
| | | } |
| | |
| | | |
| | | import org.apache.commons.lang3.time.DateFormatUtils; |
| | | |
| | | /** |
| | | * 时间工具类 |
| | | * |
| | | * @author tam |
| | | */ |
| | | public class DateUtils extends org.apache.commons.lang3.time.DateUtils { |
| | | public static String YYYY = "yyyy"; |
| | | |
| | |
| | | "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM", "yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", |
| | | "yyyy.MM.dd HH:mm", "yyyy.MM"}; |
| | | |
| | | /** |
| | | * 获取当前Date型日期 |
| | | * |
| | | * @return Date() 当前日期 |
| | | */ |
| | | public static Date getNowDate() { |
| | | return new Date(); |
| | | } |
| | | |
| | | /** |
| | | * 获取当前日期, 默认格式为yyyy-MM-dd |
| | | * |
| | | * @return String |
| | | */ |
| | | public static String getDate() { |
| | | return dateTimeNow(YYYY_MM_DD); |
| | | } |
| | |
| | | |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * Excel帮助类 |
| | | * @author WWW |
| | | * @date 2023-08-08 |
| | | */ |
| | | public class ExcelUtils { |
| | | /** |
| | | * 读取Excel |
| | | * |
| | | * @param pathName 文件路径 |
| | | * @param <T> 泛型类 |
| | | * @return 泛型类集合 |
| | | */ |
| | | public static <T> List<T> readExcel(Class<?> clazz, String pathName) { |
| | | ExcelHead head = getExcelHead(clazz); |
| | | int headRowNumber = head == null ? 1 : head.headRows(); |
| | |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 获取Excel头注解类 |
| | | * |
| | | * @param clazz Class |
| | | * @param <T> 泛型类 |
| | | * @return 头行数 |
| | | */ |
| | | public static <T> ExcelHead getExcelHead(Class<?> clazz) { |
| | | ExcelHead head = clazz.getAnnotation(ExcelHead.class); |
| | | |
| | | return head; |
| | | } |
| | | |
| | | /** |
| | | * 写入Excel模板 |
| | | * |
| | | * @param source 源文件(模板) |
| | | * @param target 目录文件 |
| | | * @param map 数据源 |
| | | */ |
| | | public static <T> void writeToTemplate(String source, String target, Map<String, List<T>> map) { |
| | | // 根据模板写入数据,如果目标文件不存在,则自动创建文件 |
| | | ExcelWriter excelWriter = EasyExcel.write(target).withTemplate(source).build(); |
| | | |
| | | // 在工作簿0中写入数据,如果模板中不存在练习工作簿,则会在目标文件中自动创建 |
| | | WriteSheet writeSheet = EasyExcel.writerSheet(0).build(); |
| | | |
| | | // 垂直写入数据,如果要水平写入,将VERTICAL替换为HORIZONTAL |
| | | FillConfig fillConfig = FillConfig.builder().direction(WriteDirectionEnum.VERTICAL).build(); |
| | | |
| | | // 写入数据 |
| | | map.forEach((k, v) -> excelWriter.fill(new FillWrapper(k, v), fillConfig, writeSheet)); |
| | | |
| | | // 结束写入 |
| | | excelWriter.finish(); |
| | | } |
| | | } |
| | |
| | | import java.nio.channels.FileChannel; |
| | | import java.security.MessageDigest; |
| | | |
| | | /** |
| | | * 文件工具类 |
| | | * @author WWW |
| | | * @date 2023-06-06 |
| | | */ |
| | | public class FileUtils { |
| | | public final static int SIXTEEN = 16; |
| | | |
| | | public static final char[] HEX_DIGITS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; |
| | | |
| | | /** |
| | | * 1.获取文件的MD5 |
| | | */ |
| | | @SuppressWarnings("unused") |
| | | public static String getFileMd5(String filePath) { |
| | | FileInputStream fis = null; |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 字节码转16进制 |
| | | */ |
| | | public static String byteToHexString(byte[] tmp) { |
| | | // 每个字节用 16 进制表示的话,使用两个字符, |
| | | char[] str = new char[16 * 2]; |
| | | |
| | | // 所以表示成 16 进制需要 32 个字符,表示转换结果中对应的字符位置 |
| | | int k = 0; |
| | | // 从第一个字节开始,对 MD5 的每一个字节 |
| | | for (int i = 0; i < SIXTEEN; i++) { |
| | | // 转换成 16 进制字符的转换 |
| | | byte byte0 = tmp[i]; |
| | | // 取字节中高 4 位的数字转换 |
| | | str[k++] = HEX_DIGITS[byte0 >>> 4 & 0xf]; |
| | | // >>> 为逻辑右移,将符号位一起右移, 取字节中低 4 位的数字转换 |
| | | str[k++] = HEX_DIGITS[byte0 & 0xf]; |
| | | } |
| | | // 换后的结果转换为字符串 |
| | | |
| | | return new String(str); |
| | | } |
| | | } |
| | |
| | | import org.opengis.referencing.operation.MathTransform; |
| | | |
| | | public class GisUtil { |
| | | |
| | | /** |
| | | * @param srcNo |
| | | * 源坐标系EPSG代号 |
| | | * @param targetNo |
| | | * 目标坐标系EPSG代号 |
| | | * @param x |
| | | * 源坐标x |
| | | * @param y |
| | | * 源坐标y |
| | | * @Description: 坐标系转换 |
| | | */ |
| | | public static Coordinate coordinateTransform(String sourceCRS, String targetCRS, |
| | | double x, double y) { |
| | | Coordinate tar = new Coordinate(); |
| | |
| | | package com.yssh.utils; |
| | | |
| | | |
| | | /** |
| | | * 返回状态码 |
| | | * |
| | | * @author xingjinshuang@smartearth.cn |
| | | * @date 2023-02-06 |
| | | */ |
| | | public class HttpStatus |
| | | { |
| | | /** |
| | |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * @author wMeng |
| | | * @ClassName Result |
| | | * @Description TODO |
| | | * @date 2022/10/30 13:29 |
| | | * @Version 1.0 |
| | | */ |
| | | @Data |
| | | @ApiModel(value = "通用结果集",description = "通用结果集") |
| | | public class Result<T> implements Serializable { |
| | |
| | | |
| | | import com.yssh.Application; |
| | | |
| | | /** |
| | | * @author wMeng |
| | | * @ClassName ServletInitializer |
| | | * @Description TODO |
| | | * @date 2022/10/31 18:46 |
| | | * @Version 1.0 |
| | | */ |
| | | |
| | | public class ServletInitializer extends SpringBootServletInitializer { |
| | | |
| | | @Override |
| | |
| | | import org.springframework.context.ApplicationContextAware; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | |
| | | /** |
| | | * spring工具类 方便在非spring管理环境中获取bean |
| | | * |
| | | * @author tam |
| | | */ |
| | | @Component |
| | | public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationContextAware { |
| | | /** Spring应用上下文环境 */ |
| | |
| | | import java.util.Set; |
| | | import org.springframework.util.AntPathMatcher; |
| | | |
| | | /** |
| | | * 字符串工具类 |
| | | * |
| | | * @author xingjinshuang@smartearth.cn |
| | | * @date 2023-02-06 |
| | | */ |
| | | |
| | | public class StringUtils extends org.apache.commons.lang3.StringUtils { |
| | | /** 空字符串 */ |
| | | private static final String NULLSTR = ""; |
| | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * VOC转换类 |
| | | * @author WWW |
| | | * @date 2023-06-05 |
| | | */ |
| | | public class VocParser extends AbstractCsvFileParser<VocVals> { |
| | | protected final Logger logger = LoggerFactory.getLogger(this.getClass()); |
| | | |
| | | private final SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHH0000"); |
| | | |
| | | /** |
| | | * 每隔5000条入库一次 |
| | | */ |
| | | public static final int BATCH_COUNT = 100000; |
| | | |
| | | private BigInteger startId; |
| | |
| | | import java.net.URLEncoder; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * Web工具类 |
| | | * @author WWW |
| | | * @date 2023-08-09 |
| | | */ |
| | | public class WebUtils { |
| | | /** |
| | | * 字符点 |
| | | */ |
| | | public final static String POINT = "."; |
| | | |
| | | /** |
| | | * 下载文件 |
| | | * |
| | | * @param file 文件 |
| | | * @param fileName 文件名 |
| | | * @param res 响应 |
| | | * @throws Exception 异常 |
| | | */ |
| | | public static void download(String file, String fileName, boolean inline, HttpServletResponse res) throws Exception { |
| | | if (StringUtils.isEmpty(fileName)) { |
| | | fileName = DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSS, new Date()); |
| | |
| | | fileName = URLEncoder.encode(fileName, "UTF-8").replace("+", "%20"); |
| | | String dispose = inline ? "inline" : "attachment"; |
| | | |
| | | // 设置响应头中文件的下载方式为附件方式,以及设置文件名 |
| | | res.setHeader("Content-Disposition", dispose + "; filename*=UTF-8''" + fileName); |
| | | // 设置响应头的编码格式为 UTF-8 |
| | | res.setCharacterEncoding("UTF-8"); |
| | | |
| | | // 通过response对象设置响应数据格式(如:"text/plain; charset=utf-8") |
| | | String ext = getExtension(file); |
| | | String mime = getMime(ext); |
| | | res.setContentType(mime); |
| | | |
| | | // 通过response对象,获取到输出流 |
| | | ServletOutputStream outputStream = res.getOutputStream(); |
| | | // 定义输入流,通过输入流读取文件内容 |
| | | FileInputStream fileInputStream = new FileInputStream(file); |
| | | |
| | | int len = 0; |
| | | byte[] bytes = new byte[1024]; |
| | | while ((len = fileInputStream.read(bytes)) != -1) { |
| | | // 通过输入流读取文件数据,然后通过上述的输出流写回浏览器 |
| | | outputStream.write(bytes, 0, len); |
| | | outputStream.flush(); |
| | | } |
| | | |
| | | // 关闭资源 |
| | | fileInputStream.close(); |
| | | outputStream.close(); |
| | | } |
| | | |
| | | /** |
| | | * 获取文件扩展名 |
| | | */ |
| | | public static String getExtension(String fileName) { |
| | | if (StringUtils.isEmpty(fileName)) { |
| | | return ""; |
| | |
| | | return fileName.substring(idx).toLowerCase(); |
| | | } |
| | | |
| | | /** |
| | | * 获取多用途互联网邮件扩展类型 |
| | | * |
| | | * @param ext 文件扩展名 |
| | | * @return MIME |
| | | */ |
| | | public static String getMime(String ext) { |
| | | switch (ext) { |
| | | // 图片 |
| | | case ".tif": |
| | | case ".tiff": |
| | | return "image/tiff"; |
| | |
| | | return "image/jpeg"; |
| | | case ".png": |
| | | return "image/png"; |
| | | // 音/视频 |
| | | case ".mp3": |
| | | return "audio/mp3"; |
| | | case ".mp4": |
| | |
| | | return "application/vnd.rn-realmedia"; |
| | | case ".rmvb": |
| | | return "application/vnd.rn-realmedia-vbr"; |
| | | // 网页 |
| | | case ".js": |
| | | return "application/x-javascript"; |
| | | case ".css": |
| | |
| | | case ".xml": |
| | | case ".svg": |
| | | return "text/xml"; |
| | | // 文件 |
| | | case ".txt": |
| | | return "text/plain"; |
| | | case ".dbf": |
| | |
| | | return "application/x-dwg"; |
| | | case ".ext": |
| | | return "application/x-msdownload"; |
| | | // 默认 |
| | | default: |
| | | return "application/octet-stream"; |
| | | } |
| | |
| | | |
| | | SHOW BINARY LOGS; |
| | | RESET MASTER; |
| | | |
| | | create index index_yssh_gcsj_time on yssh_gcsj(time); |
| | | drop index index_yssh_gcsj_time on yssh_gcsj; |
| | | |
| | | https://blog.csdn.net/qq_63161848/article/details/141591514 |
| | | ---------------------------------------------------------------------- |
| | | create table voc_vals ( |
| | | id bigint not null primary key comment '主键', |
| | |
| | | val double(25, 10) comment '值', |
| | | create_time datetime comment '值' |
| | | ); |
| | | |
| | | create index voc_vals_val on voc_vals (val); |
| | | create index voc_vals_time on voc_vals (create_time); |
| | | ---------------------------------------------------------------------- |