parent
38b848da85
commit
6d38844948
@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.yingji</groupId>
|
||||
<artifactId>yingjiAlgorithms</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>fire</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<!--打包成jar包时的名字-->
|
||||
<finalName>fire</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
<configuration>
|
||||
<mainClass>com.yingji.FireApplication</mainClass>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>repackage</id>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -0,0 +1,23 @@
|
||||
package com.yingji;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
/**
|
||||
* @author wu
|
||||
* @since 2024/2/26 10:24
|
||||
*/
|
||||
|
||||
@SpringBootApplication
|
||||
@MapperScan("com.yingji.mapper")
|
||||
@EnableAsync
|
||||
@EnableScheduling
|
||||
public class FireApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(FireApplication.class, args);
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
package com.yingji.base.controller;
|
||||
|
||||
import com.yingji.base.domain.AjaxResult;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* web层通用数据处理
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class BaseController {
|
||||
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
|
||||
/**
|
||||
* 返回成功
|
||||
*/
|
||||
public AjaxResult success() {
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回失败消息
|
||||
*/
|
||||
public AjaxResult error() {
|
||||
return AjaxResult.error();
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回成功消息
|
||||
*/
|
||||
public AjaxResult success(String message) {
|
||||
return AjaxResult.success(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回成功消息
|
||||
*/
|
||||
public AjaxResult success(Object data) {
|
||||
return AjaxResult.success(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回失败消息
|
||||
*/
|
||||
public AjaxResult error(String message) {
|
||||
return AjaxResult.error(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回警告消息
|
||||
*/
|
||||
public AjaxResult warn(String message) {
|
||||
return AjaxResult.warn(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 响应返回结果
|
||||
*
|
||||
* @param rows 影响行数
|
||||
* @return 操作结果
|
||||
*/
|
||||
protected AjaxResult toAjax(int rows) {
|
||||
return rows > 0 ? AjaxResult.success() : AjaxResult.error();
|
||||
}
|
||||
|
||||
/**
|
||||
* 响应返回结果
|
||||
*
|
||||
* @param result 结果
|
||||
* @return 操作结果
|
||||
*/
|
||||
protected AjaxResult toAjax(boolean result) {
|
||||
return result ? success() : error();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package com.yingji.config;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.DbType;
|
||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author wu
|
||||
* @since 2024/2/26 11:28
|
||||
*/
|
||||
@Configuration
|
||||
public class MybatisPlusConfig {
|
||||
|
||||
/**
|
||||
* 添加分页插件
|
||||
*/
|
||||
@Bean
|
||||
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));//如果配置多个插件,切记分页最后添加
|
||||
//interceptor.addInnerInterceptor(new PaginationInnerInterceptor()); 如果有多数据源可以不配具体类型 否则都建议配上具体的DbType
|
||||
return interceptor;
|
||||
}
|
||||
}
|
@ -0,0 +1,133 @@
|
||||
package com.yingji.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author wu
|
||||
* @since 2024/6/4 下午4:26
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("实体类")
|
||||
@TableName(value = "Fire")
|
||||
public class Fire implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 9084065880894382754L;
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 行政区划
|
||||
*/
|
||||
private String xzqh;
|
||||
|
||||
/**
|
||||
* 案件编号
|
||||
*/
|
||||
private String ajbh;
|
||||
|
||||
/**
|
||||
* 案件描述
|
||||
*/
|
||||
private String ajms;
|
||||
|
||||
/**
|
||||
* 归队时间
|
||||
*/
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime gdsj;
|
||||
|
||||
private String jjyxm;
|
||||
|
||||
/**
|
||||
* 时间戳
|
||||
*/
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime sjc;
|
||||
|
||||
/**
|
||||
* 纬度
|
||||
*/
|
||||
private String wd;
|
||||
|
||||
/**
|
||||
* 经度
|
||||
*/
|
||||
private String jd;
|
||||
|
||||
/**
|
||||
* 备注信息
|
||||
*/
|
||||
private String bcxx;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime jssj;
|
||||
|
||||
/**
|
||||
* 案发地址
|
||||
*/
|
||||
private String afdz;
|
||||
|
||||
/**
|
||||
* 出动时间
|
||||
*/
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime cdsj;
|
||||
|
||||
/**
|
||||
* 立案方式代码
|
||||
*/
|
||||
private String lafsdm;
|
||||
|
||||
/**
|
||||
* topic
|
||||
*/
|
||||
private String topic;
|
||||
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime xdsj;
|
||||
|
||||
/**
|
||||
* 立案时间
|
||||
*/
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime lasj;
|
||||
|
||||
/**
|
||||
* 行政区划名称
|
||||
*/
|
||||
private String xzqhmc;
|
||||
|
||||
/**
|
||||
* 到达现场时间
|
||||
*/
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime ddxcsj;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
package com.yingji.exception;
|
||||
|
||||
import cn.dev33.satoken.exception.NotLoginException;
|
||||
import com.yingji.base.domain.AjaxResult;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.validation.BindException;
|
||||
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* 全局异常处理器
|
||||
*
|
||||
* @author wu
|
||||
*/
|
||||
@RestControllerAdvice
|
||||
public class GlobalExceptionHandler {
|
||||
private static final Logger log = LoggerFactory.getLogger(GlobalExceptionHandler.class);
|
||||
|
||||
|
||||
/**
|
||||
* 请求方式不支持
|
||||
*/
|
||||
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
|
||||
public AjaxResult handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException e,
|
||||
HttpServletRequest request) {
|
||||
String requestURI = request.getRequestURI();
|
||||
log.error("请求地址'{}',不支持'{}'请求", requestURI, e.getMethod());
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 拦截未知的运行时异常
|
||||
*/
|
||||
@ExceptionHandler(RuntimeException.class)
|
||||
public AjaxResult handleRuntimeException(RuntimeException e, HttpServletRequest request) {
|
||||
String requestURI = request.getRequestURI();
|
||||
log.error("请求地址'{}',发生未知异常.", requestURI, e);
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* 系统异常
|
||||
*/
|
||||
@ExceptionHandler(Exception.class)
|
||||
public AjaxResult handleException(Exception e, HttpServletRequest request) {
|
||||
String requestURI = request.getRequestURI();
|
||||
log.error("请求地址'{}',发生系统异常.", requestURI, e);
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义验证异常
|
||||
*/
|
||||
@ExceptionHandler(BindException.class)
|
||||
public AjaxResult handleBindException(BindException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
String message = e.getAllErrors().get(0).getDefaultMessage();
|
||||
return AjaxResult.error(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义验证异常
|
||||
*/
|
||||
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||
public Object handleMethodArgumentNotValidException(MethodArgumentNotValidException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
String message = e.getBindingResult().getFieldError().getDefaultMessage();
|
||||
return AjaxResult.error(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录异常
|
||||
*/
|
||||
@ExceptionHandler(NotLoginException.class)
|
||||
public AjaxResult handleDemoModeException(NotLoginException e) {
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* 业务异常
|
||||
*/
|
||||
@ExceptionHandler(ServiceException.class)
|
||||
public AjaxResult handleServiceException(ServiceException e, HttpServletRequest request) {
|
||||
log.error(e.getMessage(), e);
|
||||
Integer code = e.getCode();
|
||||
return code != null ? AjaxResult.error(code, e.getMessage()) : AjaxResult.error(e.getMessage());
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.yingji.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.yingji.entity.Fire;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 119数据库访问层
|
||||
*
|
||||
* @author wu
|
||||
* @since 2024-05-06 09:15:01
|
||||
*/
|
||||
public interface FireMapper extends BaseMapper<Fire> {
|
||||
|
||||
|
||||
/**
|
||||
* 批量插入数据
|
||||
*
|
||||
* @param list 数据
|
||||
*/
|
||||
void saveAll(List<Fire> list);
|
||||
}
|
||||
|
@ -0,0 +1,53 @@
|
||||
package com.yingji.quartz;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.yingji.entity.Fire;
|
||||
import com.yingji.service.FireService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 119数据保存定时任务
|
||||
*
|
||||
* @author wu
|
||||
* @since 2024/05/06 10:18
|
||||
*/
|
||||
@Configuration
|
||||
public class FireQuartz {
|
||||
|
||||
public static final Logger log = LoggerFactory.getLogger(FireQuartz.class);
|
||||
|
||||
@Resource
|
||||
private FireService fireService;
|
||||
|
||||
/**
|
||||
* 保存所有数据
|
||||
*/
|
||||
@Async
|
||||
@Scheduled(cron = "0 */5 * * * ? ")
|
||||
public void savaData() {
|
||||
log.info("119接口开始" + LocalDateTime.now());
|
||||
// 获取token
|
||||
String token = fireService.getToken();
|
||||
if (StrUtil.isNotEmpty(token)) {
|
||||
// 根据id查询数据保存
|
||||
List<Fire> list = fireService.findDataList(token);
|
||||
// 110算法接口
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
fireService.saveAll(list);
|
||||
}
|
||||
log.info("119接口结束" + LocalDateTime.now());
|
||||
} else {
|
||||
log.error("============119算法接口获取token失败119接口结束=============");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package com.yingji.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.yingji.entity.Fire;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 119表服务接口
|
||||
*
|
||||
* @author wu
|
||||
* @since 2024-05-06 09:15:01
|
||||
*/
|
||||
public interface FireService extends IService<Fire> {
|
||||
|
||||
|
||||
/**
|
||||
* 查询数据
|
||||
*
|
||||
* @param req 查询条件
|
||||
* @param token token
|
||||
* @return 数据List
|
||||
*/
|
||||
List<Fire> findDataList(String token);
|
||||
|
||||
/**
|
||||
* 获取110token
|
||||
*
|
||||
* @return token
|
||||
*/
|
||||
String getToken();
|
||||
|
||||
|
||||
/**
|
||||
* 批量插入数据
|
||||
*
|
||||
* @param list 数据
|
||||
*/
|
||||
void saveAll(List<Fire> list);
|
||||
}
|
||||
|
@ -0,0 +1,136 @@
|
||||
package com.yingji.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpException;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.yingji.entity.Fire;
|
||||
import com.yingji.mapper.FireMapper;
|
||||
import com.yingji.service.FireService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* 119服务实现类
|
||||
*
|
||||
* @author wu
|
||||
* @since 2024-05-06 09:15:01
|
||||
*/
|
||||
@Service("fireService")
|
||||
public class FireServiceImpl extends ServiceImpl<FireMapper, Fire> implements FireService {
|
||||
|
||||
public static final Logger log = LoggerFactory.getLogger(FireServiceImpl.class);
|
||||
@Value("${clientId}")
|
||||
private String clientId;
|
||||
|
||||
@Value("${clientSecret}")
|
||||
private String clientSecret;
|
||||
|
||||
@Value("${getToken}")
|
||||
private String getToken;
|
||||
|
||||
@Value("${specificWarn}")
|
||||
private String specificWarn;
|
||||
|
||||
/**
|
||||
* base64加密密钥
|
||||
*
|
||||
* @return base64加密后的密钥
|
||||
*/
|
||||
public String findBase() {
|
||||
String str = clientId + ":" + clientSecret;
|
||||
return Base64.encode(str);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询数据
|
||||
*
|
||||
* @param token token
|
||||
* @return 数据List
|
||||
*/
|
||||
@Override
|
||||
public List<Fire> findDataList(String token) {
|
||||
List<Fire> records = null;
|
||||
// 获取id
|
||||
String body = HttpRequest.post(specificWarn).header("Authorization", "Basic " + token).header("Content-Type", "application/json").execute().body();
|
||||
log.info("===============================");
|
||||
log.info("119body数据为:" + body);
|
||||
try {
|
||||
JSONObject json = JSONObject.parse(body);
|
||||
Object response = json.get("response");
|
||||
if (BeanUtil.isNotEmpty(response)) {
|
||||
String recordsStr = JSONUtil.toJsonStr(response);
|
||||
if (StrUtil.isEmpty(recordsStr)) {
|
||||
return null;
|
||||
}
|
||||
records = JSONUtil.toList(recordsStr, Fire.class);
|
||||
if (records == null) {
|
||||
return null;
|
||||
}
|
||||
return records.stream()
|
||||
.filter(district -> "苏州市".equals(district.getXzqhmc()))
|
||||
.peek(district -> district.setCreateTime(LocalDateTime.now())) // 使用peek设置时间戳
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.info("json解析错误");
|
||||
}
|
||||
return records;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取119token
|
||||
*
|
||||
* @return token
|
||||
*/
|
||||
@Override
|
||||
public String getToken() {
|
||||
String accessToken = null;
|
||||
String body = null;
|
||||
try {
|
||||
body = HttpRequest.get(getToken)
|
||||
.header("Authorization", "Basic QkZTaFQzL1d3UGhaSlFkTDhlNEZkblExMWgwUU9lS3FCZG4reGVzQ1NKR2xESEtQazVmeG5tbkxrMW9ua20zWXpkZmpFMGdMR0VaN0g3dmZMczIxc0dNPTpHdGJnUmZOSW1Yam1CcVcwbnB4VWlHaS9zMG1iNVpkdlhBTnFVQ2dtSW00PQ==")
|
||||
.header("Content-Type", "application/json")
|
||||
.form("grant_type", "client_credentials").execute().body();
|
||||
} catch (HttpException e) {
|
||||
log.error("获取token接口响应超时");
|
||||
}
|
||||
JSONObject json = JSONObject.parse(body);
|
||||
if (json == null) {
|
||||
return accessToken;
|
||||
}
|
||||
Object response = json.get("response");
|
||||
if (BeanUtil.isNotEmpty(response)) {
|
||||
String recordsStr = JSONUtil.toJsonStr(response);
|
||||
JSONObject res = JSONObject.parse(recordsStr);
|
||||
accessToken = (String) res.get("access_token");
|
||||
}
|
||||
log.info("=======================================");
|
||||
log.info("119token为:" + accessToken);
|
||||
return accessToken;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 批量插入数据
|
||||
*
|
||||
* @param list 数据
|
||||
*/
|
||||
@Override
|
||||
public void saveAll(List<Fire> list) {
|
||||
baseMapper.saveAll(list);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,21 @@
|
||||
<?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.yingji.mapper.FireMapper">
|
||||
|
||||
|
||||
<insert id="saveAll">
|
||||
INSERT IGNORE INTO `fire`(
|
||||
id, xzqh, ajbh, ajms, gdsj, jjyxm, sjc, wd, jd, bcxx, jssj, afdz, cdsj, lafsdm, topic, xdsj, lasj, xzqhmc,
|
||||
ddxcsj, create_time
|
||||
) VALUES
|
||||
<foreach collection="list" item="item" index="index" separator=",">
|
||||
(#{item.id}, #{item.xzqh}, #{item.ajbh}, #{item.ajms}, #{item.gdsj}, #{item.jjyxm}, #{item.sjc}, #{item.wd},
|
||||
#{item.jd}, #{item.bcxx}, #{item.jssj}, #{item.afdz},
|
||||
#{item.cdsj}, #{item.lafsdm}, #{item.topic}, #{item.xdsj}, #{item.lasj}, #{item.xzqhmc}, #{item.ddxcsj},
|
||||
#{item.createTime})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,93 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<!-- 日志存放路径 -->
|
||||
<property name="log.path" value="/home/logs/fire" />
|
||||
<!-- 日志输出格式 -->
|
||||
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
|
||||
|
||||
<!-- 控制台输出 -->
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 系统日志输出 -->
|
||||
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/sys-info.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/sys-info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>INFO</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/sys-error.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/sys-error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>ERROR</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<!-- 用户访问日志输出 -->
|
||||
<appender name="sys-user" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/sys-user.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 按天回滚 daily -->
|
||||
<fileNamePattern>${log.path}/sys-user.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 系统模块日志级别控制 -->
|
||||
<logger name="com.ruoyi" level="info" />
|
||||
<!-- Spring日志级别控制 -->
|
||||
<logger name="org.springframework" level="warn" />
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="console" />
|
||||
</root>
|
||||
|
||||
<!--系统操作日志-->
|
||||
<root level="info">
|
||||
<appender-ref ref="file_info" />
|
||||
<appender-ref ref="file_error" />
|
||||
</root>
|
||||
|
||||
<!--系统用户操作日志-->
|
||||
<logger name="sys-user" level="info">
|
||||
<appender-ref ref="sys-user"/>
|
||||
</logger>
|
||||
</configuration>
|
@ -0,0 +1,71 @@
|
||||
package com.yingji.controller;
|
||||
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.yingji.base.controller.BaseController;
|
||||
import com.yingji.base.domain.AjaxResult;
|
||||
import com.yingji.entity.Fire;
|
||||
import com.yingji.entity.dto.request.FireFindRequest;
|
||||
import com.yingji.service.FireService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 119数据(Fire)表控制层
|
||||
*
|
||||
* @author wu
|
||||
* @since 2024-06-05 09:24:14
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("algorithms/fire")
|
||||
@Api(tags = "119数据")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class FireController extends BaseController {
|
||||
/**
|
||||
* 服务对象
|
||||
*/
|
||||
@Resource
|
||||
private FireService fireService;
|
||||
|
||||
/**
|
||||
* 分页条件查询所有数据
|
||||
*
|
||||
* @param page 分页条件
|
||||
* @param fire 查询条件
|
||||
* @return 所有数据
|
||||
*/
|
||||
@GetMapping
|
||||
@ApiOperation(value = "分页条件查询119数据", response = Fire.class)
|
||||
public AjaxResult page(Page<Fire> page, FireFindRequest fire) {
|
||||
StpUtil.checkLogin();
|
||||
if (page.getSize() > 1000) {
|
||||
page.setSize(1000);
|
||||
}
|
||||
return success(fireService.page(page, fire));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过主键查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 单条数据
|
||||
*/
|
||||
@GetMapping("{id}")
|
||||
@ApiOperation(value = "通过主键查询单条119数据", response = Fire.class)
|
||||
public AjaxResult getById(@PathVariable Serializable id) {
|
||||
StpUtil.checkLogin();
|
||||
return success(fireService.getById(id));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,117 @@
|
||||
package com.yingji.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
/**
|
||||
* 119数据(Fire)表实体类
|
||||
*
|
||||
* @author wu
|
||||
* @since 2024-06-05 09:24:14
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("119数据实体类")
|
||||
@TableName(value = "fire")
|
||||
public class Fire implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -96682169109217319L;
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@ApiModelProperty(value = "主键id")
|
||||
private String id;
|
||||
/**
|
||||
* 行政区划
|
||||
*/
|
||||
@ApiModelProperty(value = "行政区划")
|
||||
private String xzqh;
|
||||
/**
|
||||
* 案件编号
|
||||
*/
|
||||
@ApiModelProperty(value = "案件编号")
|
||||
private String ajbh;
|
||||
/**
|
||||
* 案件描述
|
||||
*/
|
||||
@ApiModelProperty(value = "案件描述")
|
||||
private String ajms;
|
||||
/**
|
||||
* 归队时间
|
||||
*/
|
||||
@ApiModelProperty(value = "归队时间")
|
||||
private Date gdsj;
|
||||
private String jjyxm;
|
||||
/**
|
||||
* 时间戳
|
||||
*/
|
||||
@ApiModelProperty(value = "时间戳")
|
||||
private Date sjc;
|
||||
/**
|
||||
* 纬度
|
||||
*/
|
||||
@ApiModelProperty(value = "纬度")
|
||||
private String wd;
|
||||
/**
|
||||
* 经度
|
||||
*/
|
||||
@ApiModelProperty(value = "经度")
|
||||
private String jd;
|
||||
/**
|
||||
* 备注信息
|
||||
*/
|
||||
@ApiModelProperty(value = "备注信息")
|
||||
private String bcxx;
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
@ApiModelProperty(value = "结束时间")
|
||||
private Date jssj;
|
||||
/**
|
||||
* 案发地址
|
||||
*/
|
||||
@ApiModelProperty(value = "案发地址")
|
||||
private String afdz;
|
||||
/**
|
||||
* 出动时间
|
||||
*/
|
||||
@ApiModelProperty(value = "出动时间")
|
||||
private Date cdsj;
|
||||
/**
|
||||
* 立案方式代码
|
||||
*/
|
||||
@ApiModelProperty(value = "立案方式代码")
|
||||
private String lafsdm;
|
||||
/**
|
||||
* topic
|
||||
*/
|
||||
@ApiModelProperty(value = "topic")
|
||||
private String topic;
|
||||
private Date xdsj;
|
||||
/**
|
||||
* 立案时间
|
||||
*/
|
||||
@ApiModelProperty(value = "立案时间")
|
||||
private Date lasj;
|
||||
/**
|
||||
* 行政区划名称
|
||||
*/
|
||||
@ApiModelProperty(value = "行政区划名称")
|
||||
private String xzqhmc;
|
||||
/**
|
||||
* 到达现场时间
|
||||
*/
|
||||
@ApiModelProperty(value = "到达现场时间")
|
||||
private Date ddxcsj;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Date createTime;
|
||||
}
|
||||
|
@ -0,0 +1,57 @@
|
||||
package com.yingji.entity.dto.request;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 119查询请求类
|
||||
*
|
||||
* @author wu
|
||||
* @since 2024/4/30 下午3:59
|
||||
*/
|
||||
@ApiModel(value = "119查询请求类")
|
||||
@Data
|
||||
public class FireFindRequest implements Serializable {
|
||||
|
||||
|
||||
private static final long serialVersionUID = -3688091864596277161L;
|
||||
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
@ApiModelProperty("开始时间")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime startTime;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
@ApiModelProperty("结束时间")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime endTime;
|
||||
|
||||
/**
|
||||
* 案件编号
|
||||
*/
|
||||
@ApiModelProperty(value = "案件编号")
|
||||
private String ajbh;
|
||||
/**
|
||||
* 案件描述
|
||||
*/
|
||||
@ApiModelProperty(value = "案件描述")
|
||||
private String ajms;
|
||||
|
||||
/**
|
||||
* 案发地址
|
||||
*/
|
||||
@ApiModelProperty(value = "案发地址")
|
||||
private String afdz;
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.yingji.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.yingji.entity.Fire;
|
||||
|
||||
/**
|
||||
* 119数据(Fire)表数据库访问层
|
||||
*
|
||||
* @author wu
|
||||
* @since 2024-06-05 09:24:14
|
||||
*/
|
||||
public interface FireMapper extends BaseMapper<Fire> {
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,25 @@
|
||||
package com.yingji.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.yingji.entity.Fire;
|
||||
import com.yingji.entity.dto.request.FireFindRequest;
|
||||
|
||||
/**
|
||||
* 119数据(Fire)表服务接口
|
||||
*
|
||||
* @author wu
|
||||
* @since 2024-06-05 09:24:14
|
||||
*/
|
||||
public interface FireService extends IService<Fire> {
|
||||
|
||||
/**
|
||||
* 分页条件查询所有数据
|
||||
*
|
||||
* @param page 分页条件
|
||||
* @param fire 查询条件
|
||||
* @return 所有数据
|
||||
*/
|
||||
Page<Fire> page(Page<Fire> page, FireFindRequest fire);
|
||||
}
|
||||
|
@ -0,0 +1,40 @@
|
||||
package com.yingji.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.yingji.entity.Fire;
|
||||
import com.yingji.entity.dto.request.FireFindRequest;
|
||||
import com.yingji.mapper.FireMapper;
|
||||
import com.yingji.service.FireService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 119数据(Fire)表服务实现类
|
||||
*
|
||||
* @author wu
|
||||
* @since 2024-06-05 09:24:14
|
||||
*/
|
||||
@Service("fireService")
|
||||
public class FireServiceImpl extends ServiceImpl<FireMapper, Fire> implements FireService {
|
||||
|
||||
/**
|
||||
* 分页条件查询所有数据
|
||||
*
|
||||
* @param page 分页条件
|
||||
* @param fire 查询条件
|
||||
* @return 所有数据
|
||||
*/
|
||||
@Override
|
||||
public Page<Fire> page(Page<Fire> page, FireFindRequest fire) {
|
||||
QueryWrapper<Fire> wrapper = new QueryWrapper<>();
|
||||
wrapper.like(StrUtil.isNotEmpty(fire.getAjbh()), "ajbh", fire.getAjbh())
|
||||
.ge(fire.getStartTime() != null, "create_time", fire.getStartTime())
|
||||
.le(fire.getEndTime() != null, "create_time", fire.getEndTime())
|
||||
.like(StrUtil.isNotEmpty(fire.getAjms()), "ajms", fire.getAjms())
|
||||
.like(StrUtil.isNotEmpty(fire.getAfdz()), "afdz", fire.getAfdz());
|
||||
return this.page(page, wrapper);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in new issue