diff --git a/RuoYi-Vue/ruoyi-admin/src/main/java/com/ruoyi/page/controller/EventController.java b/RuoYi-Vue/ruoyi-admin/src/main/java/com/ruoyi/page/controller/EventController.java index 5efa1da..e466f9c 100644 --- a/RuoYi-Vue/ruoyi-admin/src/main/java/com/ruoyi/page/controller/EventController.java +++ b/RuoYi-Vue/ruoyi-admin/src/main/java/com/ruoyi/page/controller/EventController.java @@ -1,19 +1,23 @@ -package com.ruoyi.system.controller; +package com.ruoyi.page.controller; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.page.TableDataInfo; - +import com.ruoyi.page.domain.Event; import com.ruoyi.page.domain.dto.request.EventPageRequest; import com.ruoyi.page.service.IEventService; -import com.ruoyi.system.domain.Event; - import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; -import javax.servlet.http.HttpServletResponse; import java.util.List; /** diff --git a/RuoYi-Vue/ruoyi-admin/src/main/java/com/ruoyi/page/domain/Event.java b/RuoYi-Vue/ruoyi-admin/src/main/java/com/ruoyi/page/domain/Event.java index 1baa634..4695237 100644 --- a/RuoYi-Vue/ruoyi-admin/src/main/java/com/ruoyi/page/domain/Event.java +++ b/RuoYi-Vue/ruoyi-admin/src/main/java/com/ruoyi/page/domain/Event.java @@ -1,28 +1,24 @@ -package com.ruoyi.system.domain; +package com.ruoyi.page.domain; -import java.time.LocalDateTime; -import java.util.Date; import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.core.domain.BaseEntity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; -import com.ruoyi.common.annotation.Excel; -import com.ruoyi.common.core.domain.BaseEntity; import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; + /** * 事故对象 event - * + * * @author ruoyi * @date 2024-05-30 */ @Data @ApiModel("事故实体类") -public class Event extends BaseEntity -{ +public class Event extends BaseEntity { private static final long serialVersionUID = 1L; /** diff --git a/RuoYi-Vue/ruoyi-admin/src/main/java/com/ruoyi/page/mapper/EventMapper.java b/RuoYi-Vue/ruoyi-admin/src/main/java/com/ruoyi/page/mapper/EventMapper.java index 47eccbe..2a6c39e 100644 --- a/RuoYi-Vue/ruoyi-admin/src/main/java/com/ruoyi/page/mapper/EventMapper.java +++ b/RuoYi-Vue/ruoyi-admin/src/main/java/com/ruoyi/page/mapper/EventMapper.java @@ -1,12 +1,11 @@ package com.ruoyi.page.mapper; -import java.util.List; - - +import com.ruoyi.page.domain.Event; import com.ruoyi.page.domain.dto.request.EventPageRequest; -import com.ruoyi.system.domain.Event; import org.apache.ibatis.annotations.Param; +import java.util.List; + /** * 事故Mapper接口 * diff --git a/RuoYi-Vue/ruoyi-admin/src/main/java/com/ruoyi/page/service/IEventService.java b/RuoYi-Vue/ruoyi-admin/src/main/java/com/ruoyi/page/service/IEventService.java index 74899f0..fab1c72 100644 --- a/RuoYi-Vue/ruoyi-admin/src/main/java/com/ruoyi/page/service/IEventService.java +++ b/RuoYi-Vue/ruoyi-admin/src/main/java/com/ruoyi/page/service/IEventService.java @@ -1,10 +1,9 @@ package com.ruoyi.page.service; -import java.util.List; - - +import com.ruoyi.page.domain.Event; import com.ruoyi.page.domain.dto.request.EventPageRequest; -import com.ruoyi.system.domain.Event; + +import java.util.List; /** * 事故Service接口 diff --git a/RuoYi-Vue/ruoyi-admin/src/main/java/com/ruoyi/page/service/impl/EventServiceImpl.java b/RuoYi-Vue/ruoyi-admin/src/main/java/com/ruoyi/page/service/impl/EventServiceImpl.java index e1ccb8b..c6ed4af 100644 --- a/RuoYi-Vue/ruoyi-admin/src/main/java/com/ruoyi/page/service/impl/EventServiceImpl.java +++ b/RuoYi-Vue/ruoyi-admin/src/main/java/com/ruoyi/page/service/impl/EventServiceImpl.java @@ -1,14 +1,13 @@ package com.ruoyi.page.service.impl; -import java.util.List; - - +import com.ruoyi.page.domain.Event; import com.ruoyi.page.domain.dto.request.EventPageRequest; +import com.ruoyi.page.mapper.EventMapper; import com.ruoyi.page.service.IEventService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import com.ruoyi.page.mapper.EventMapper; -import com.ruoyi.system.domain.Event; + +import java.util.List; /** diff --git a/RuoYi-Vue/ruoyi-admin/src/main/resources/application-druid.yml b/RuoYi-Vue/ruoyi-admin/src/main/resources/application-druid.yml index 791726a..a3a7ec1 100644 --- a/RuoYi-Vue/ruoyi-admin/src/main/resources/application-druid.yml +++ b/RuoYi-Vue/ruoyi-admin/src/main/resources/application-druid.yml @@ -6,9 +6,9 @@ spring: druid: # 主库数据源 master: - url: jdbc:mysql://localhost:3306/mudu?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + url: jdbc:mysql://localhost:3306/algorithms?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 username: root - password: adminadmin + password: 123456 # 从库数据源 slave: # 从数据源开关/默认关闭 diff --git a/RuoYi-Vue/ruoyi-admin/src/main/resources/application.yml b/RuoYi-Vue/ruoyi-admin/src/main/resources/application.yml index 2e9de7f..a6c8a69 100644 --- a/RuoYi-Vue/ruoyi-admin/src/main/resources/application.yml +++ b/RuoYi-Vue/ruoyi-admin/src/main/resources/application.yml @@ -36,8 +36,8 @@ server: # 日志配置 logging: level: - com.ruoyi: debug - org.springframework: warn + com.ruoyi: error + org.springframework: error # 用户配置 user: @@ -74,7 +74,7 @@ spring: # 端口,默认为6379 port: 6379 # 数据库索引 - database: 0 + database: 4 # 密码 password: # 连接超时时间 @@ -116,7 +116,7 @@ pagehelper: # Swagger配置 knife4j: - enable: true + enable: false # 防止XSS攻击 diff --git a/fire/pom.xml b/fire/pom.xml new file mode 100644 index 0000000..58552db --- /dev/null +++ b/fire/pom.xml @@ -0,0 +1,52 @@ + + + 4.0.0 + + com.yingji + yingjiAlgorithms + 0.0.1-SNAPSHOT + + + fire + + + 8 + 8 + UTF-8 + + + + + fire + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 1.8 + 1.8 + UTF-8 + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring-boot.version} + + com.yingji.FireApplication + + + + repackage + + repackage + + + + + + + \ No newline at end of file diff --git a/fire/src/main/java/com/yingji/FireApplication.java b/fire/src/main/java/com/yingji/FireApplication.java new file mode 100644 index 0000000..5aaba80 --- /dev/null +++ b/fire/src/main/java/com/yingji/FireApplication.java @@ -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); + + } +} \ No newline at end of file diff --git a/fire/src/main/java/com/yingji/base/constant/HttpStatus.java b/fire/src/main/java/com/yingji/base/constant/HttpStatus.java new file mode 100644 index 0000000..1d2ac09 --- /dev/null +++ b/fire/src/main/java/com/yingji/base/constant/HttpStatus.java @@ -0,0 +1,93 @@ +package com.yingji.base.constant; + +/** + * 返回状态码 + * + * @author ruoyi + */ +public class HttpStatus { + /** + * 操作成功 + */ + public static final int SUCCESS = 200; + + /** + * 对象创建成功 + */ + public static final int CREATED = 201; + + /** + * 请求已经被接受 + */ + public static final int ACCEPTED = 202; + + /** + * 操作已经执行成功,但是没有返回数据 + */ + public static final int NO_CONTENT = 204; + + /** + * 资源已被移除 + */ + public static final int MOVED_PERM = 301; + + /** + * 重定向 + */ + public static final int SEE_OTHER = 303; + + /** + * 资源没有被修改 + */ + public static final int NOT_MODIFIED = 304; + + /** + * 参数列表错误(缺少,格式不匹配) + */ + public static final int BAD_REQUEST = 400; + + /** + * 未授权 + */ + public static final int UNAUTHORIZED = 401; + + /** + * 访问受限,授权过期 + */ + public static final int FORBIDDEN = 403; + + /** + * 资源,服务未找到 + */ + public static final int NOT_FOUND = 404; + + /** + * 不允许的http方法 + */ + public static final int BAD_METHOD = 405; + + /** + * 资源冲突,或者资源被锁 + */ + public static final int CONFLICT = 409; + + /** + * 不支持的数据,媒体类型 + */ + public static final int UNSUPPORTED_TYPE = 415; + + /** + * 系统内部错误 + */ + public static final int ERROR = 500; + + /** + * 接口未实现 + */ + public static final int NOT_IMPLEMENTED = 501; + + /** + * 系统警告消息 + */ + public static final int WARN = 601; +} diff --git a/fire/src/main/java/com/yingji/base/controller/BaseController.java b/fire/src/main/java/com/yingji/base/controller/BaseController.java new file mode 100644 index 0000000..6af991b --- /dev/null +++ b/fire/src/main/java/com/yingji/base/controller/BaseController.java @@ -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(); + } + +} diff --git a/fire/src/main/java/com/yingji/base/domain/AjaxResult.java b/fire/src/main/java/com/yingji/base/domain/AjaxResult.java new file mode 100644 index 0000000..06fb8a0 --- /dev/null +++ b/fire/src/main/java/com/yingji/base/domain/AjaxResult.java @@ -0,0 +1,202 @@ +package com.yingji.base.domain; + + +import cn.hutool.core.bean.BeanUtil; +import com.yingji.base.constant.HttpStatus; + +import java.util.HashMap; +import java.util.Objects; + +/** + * 操作消息提醒 + * + * @author ruoyi + */ +public class AjaxResult extends HashMap { + /** + * 状态码 + */ + public static final String CODE_TAG = "code"; + /** + * 返回内容 + */ + public static final String MSG_TAG = "msg"; + /** + * 数据对象 + */ + public static final String DATA_TAG = "data"; + private static final long serialVersionUID = 1L; + + /** + * 初始化一个新创建的 AjaxResult 对象,使其表示一个空消息。 + */ + public AjaxResult() { + } + + /** + * 初始化一个新创建的 AjaxResult 对象 + * + * @param code 状态码 + * @param msg 返回内容 + */ + public AjaxResult(int code, String msg) { + super.put(CODE_TAG, code); + super.put(MSG_TAG, msg); + } + + /** + * 初始化一个新创建的 AjaxResult 对象 + * + * @param code 状态码 + * @param msg 返回内容 + * @param data 数据对象 + */ + public AjaxResult(int code, String msg, Object data) { + super.put(CODE_TAG, code); + super.put(MSG_TAG, msg); + if (BeanUtil.isNotEmpty(data)) { + super.put(DATA_TAG, data); + } + } + + /** + * 返回成功消息 + * + * @return 成功消息 + */ + public static AjaxResult success() { + return AjaxResult.success("操作成功"); + } + + /** + * 返回成功数据 + * + * @return 成功消息 + */ + public static AjaxResult success(Object data) { + return AjaxResult.success("操作成功", data); + } + + /** + * 返回成功消息 + * + * @param msg 返回内容 + * @return 成功消息 + */ + public static AjaxResult success(String msg) { + return AjaxResult.success(msg, null); + } + + /** + * 返回成功消息 + * + * @param msg 返回内容 + * @param data 数据对象 + * @return 成功消息 + */ + public static AjaxResult success(String msg, Object data) { + return new AjaxResult(HttpStatus.SUCCESS, msg, data); + } + + /** + * 返回警告消息 + * + * @param msg 返回内容 + * @return 警告消息 + */ + public static AjaxResult warn(String msg) { + return AjaxResult.warn(msg, null); + } + + /** + * 返回警告消息 + * + * @param msg 返回内容 + * @param data 数据对象 + * @return 警告消息 + */ + public static AjaxResult warn(String msg, Object data) { + return new AjaxResult(HttpStatus.WARN, msg, data); + } + + /** + * 返回错误消息 + * + * @return 错误消息 + */ + public static AjaxResult error() { + return AjaxResult.error("操作失败"); + } + + /** + * 返回错误消息 + * + * @param msg 返回内容 + * @return 错误消息 + */ + public static AjaxResult error(String msg) { + return AjaxResult.error(msg, null); + } + + /** + * 返回错误消息 + * + * @param msg 返回内容 + * @param data 数据对象 + * @return 错误消息 + */ + public static AjaxResult error(String msg, Object data) { + return new AjaxResult(HttpStatus.ERROR, msg, data); + } + + /** + * 返回错误消息 + * + * @param code 状态码 + * @param msg 返回内容 + * @return 错误消息 + */ + public static AjaxResult error(int code, String msg) { + return new AjaxResult(code, msg, null); + } + + /** + * 是否为成功消息 + * + * @return 结果 + */ + public boolean isSuccess() { + return Objects.equals(HttpStatus.SUCCESS, this.get(CODE_TAG)); + } + + /** + * 是否为警告消息 + * + * @return 结果 + */ + public boolean isWarn() { + return Objects.equals(HttpStatus.WARN, this.get(CODE_TAG)); + } + + /** + * 是否为错误消息 + * + * @return 结果 + */ + public boolean isError() { + return Objects.equals(HttpStatus.ERROR, this.get(CODE_TAG)); + } + + /** + * 方便链式调用 + * + * @param key 键 + * @param value 值 + * @return 数据对象 + */ + @Override + public AjaxResult put(String key, Object value) { + super.put(key, value); + return this; + } +} diff --git a/fire/src/main/java/com/yingji/config/MybatisPlusConfig.java b/fire/src/main/java/com/yingji/config/MybatisPlusConfig.java new file mode 100644 index 0000000..5943191 --- /dev/null +++ b/fire/src/main/java/com/yingji/config/MybatisPlusConfig.java @@ -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; + } +} diff --git a/fire/src/main/java/com/yingji/config/SwaggerConfig.java b/fire/src/main/java/com/yingji/config/SwaggerConfig.java new file mode 100644 index 0000000..e33e2f6 --- /dev/null +++ b/fire/src/main/java/com/yingji/config/SwaggerConfig.java @@ -0,0 +1,74 @@ +package com.yingji.config; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc; + +/** + * Swagger2的接口配置 + * + * @author ruoyi + */ +@Configuration +@EnableSwagger2WebMvc +public class SwaggerConfig { + + + /** + * 是否开启swagger + */ + @Value("${knife4j.enable}") + private boolean enabled; + + /** + * 创建API + */ + @Bean + public Docket createRestApi() { + return new Docket(DocumentationType.SWAGGER_2) + // 是否启用Swagger + .enable(enabled) + //分组名称 + .groupName("应急算法") + // 用来创建该API的基本信息,展示在文档的页面中(自定义展示的信息) + .apiInfo(apiInfo()) + // 设置哪些接口暴露给Swagger展示 + .select() + // 扫描所有有注解的api,用这种方式更灵活 + .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) + // 扫描指定包中的swagger注解 + // .apis(RequestHandlerSelectors.basePackage("com.ruoyi.project.tool.swagger")) + // 扫描所有 .apis(RequestHandlerSelectors.any()) + .paths(PathSelectors.any()) + .build() +// .pathMapping(pathMapping) + // 排除mybatis-plus的分页参数 + .ignoredParameterTypes(Page.class, IPage.class); + } + + + /** + * 添加摘要信息 + */ + private ApiInfo apiInfo() { + // 用ApiInfoBuilder进行定制 + return new ApiInfoBuilder() + // 设置标题 + .title("应急算法") + // 描述 + .description("描述:用于应急算法") + // 版本 + .version("版本号:" + 1) + .build(); + } +} diff --git a/fire/src/main/java/com/yingji/entity/Fire.java b/fire/src/main/java/com/yingji/entity/Fire.java new file mode 100644 index 0000000..903afea --- /dev/null +++ b/fire/src/main/java/com/yingji/entity/Fire.java @@ -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; + +} diff --git a/fire/src/main/java/com/yingji/exception/GlobalExceptionHandler.java b/fire/src/main/java/com/yingji/exception/GlobalExceptionHandler.java new file mode 100644 index 0000000..59aa9d6 --- /dev/null +++ b/fire/src/main/java/com/yingji/exception/GlobalExceptionHandler.java @@ -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()); + } +} diff --git a/fire/src/main/java/com/yingji/exception/ServiceException.java b/fire/src/main/java/com/yingji/exception/ServiceException.java new file mode 100644 index 0000000..4d1e94a --- /dev/null +++ b/fire/src/main/java/com/yingji/exception/ServiceException.java @@ -0,0 +1,64 @@ +package com.yingji.exception; + +/** + * 业务异常 + * + * @author ruoyi + */ +public final class ServiceException extends RuntimeException { + private static final long serialVersionUID = 1L; + + /** + * 错误码 + */ + private Integer code; + + /** + * 错误提示 + */ + private String message; + + /** + * 错误明细,内部调试错误 + *

+ * 和 {@link CommonResult#getDetailMessage()} 一致的设计 + */ + private String detailMessage; + + /** + * 空构造方法,避免反序列化问题 + */ + public ServiceException() { + } + + public ServiceException(String message) { + this.message = message; + } + + public ServiceException(String message, Integer code) { + this.message = message; + this.code = code; + } + + public String getDetailMessage() { + return detailMessage; + } + + public String getMessage() { + return message; + } + + public Integer getCode() { + return code; + } + + public ServiceException setMessage(String message) { + this.message = message; + return this; + } + + public ServiceException setDetailMessage(String detailMessage) { + this.detailMessage = detailMessage; + return this; + } +} \ No newline at end of file diff --git a/fire/src/main/java/com/yingji/mapper/FireMapper.java b/fire/src/main/java/com/yingji/mapper/FireMapper.java new file mode 100644 index 0000000..168da15 --- /dev/null +++ b/fire/src/main/java/com/yingji/mapper/FireMapper.java @@ -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 { + + + /** + * 批量插入数据 + * + * @param list 数据 + */ + void saveAll(List list); +} + diff --git a/fire/src/main/java/com/yingji/quartz/FireQuartz.java b/fire/src/main/java/com/yingji/quartz/FireQuartz.java new file mode 100644 index 0000000..aeac211 --- /dev/null +++ b/fire/src/main/java/com/yingji/quartz/FireQuartz.java @@ -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 list = fireService.findDataList(token); + // 110算法接口 + if (CollectionUtil.isNotEmpty(list)) { + fireService.saveAll(list); + } + log.info("119接口结束" + LocalDateTime.now()); + } else { + log.error("============119算法接口获取token失败119接口结束============="); + } + } + +} diff --git a/fire/src/main/java/com/yingji/redis/RedisCache.java b/fire/src/main/java/com/yingji/redis/RedisCache.java new file mode 100644 index 0000000..faa2a01 --- /dev/null +++ b/fire/src/main/java/com/yingji/redis/RedisCache.java @@ -0,0 +1,248 @@ +package com.yingji.redis; + +import org.springframework.data.redis.core.BoundSetOperations; +import org.springframework.data.redis.core.HashOperations; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.core.ValueOperations; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.TimeUnit; + +/** + * spring redis 工具类 + * + * @author wu + **/ +@SuppressWarnings(value = {"unchecked", "rawtypes"}) +@Component +public class RedisCache { + + @Resource + public RedisTemplate redisTemplate; + + /** + * 缓存基本的对象,Integer、String、实体类等 + * + * @param key 缓存的键值 + * @param value 缓存的值 + */ + public void setCacheObject(final String key, final T value) { + redisTemplate.opsForValue().set(key, value); + } + + /** + * 缓存基本的对象,Integer、String、实体类等 + * + * @param key 缓存的键值 + * @param value 缓存的值 + * @param timeout 时间 + * @param timeUnit 时间颗粒度 + */ + public void setCacheObject(final String key, final T value, final Integer timeout, final TimeUnit timeUnit) { + redisTemplate.opsForValue().set(key, value, timeout, timeUnit); + } + + /** + * 设置有效时间 + * + * @param key Redis键 + * @param timeout 超时时间 + * @return true=设置成功;false=设置失败 + */ + public boolean expire(final String key, final long timeout) { + return expire(key, timeout, TimeUnit.SECONDS); + } + + /** + * 设置有效时间 + * + * @param key Redis键 + * @param timeout 超时时间 + * @param unit 时间单位 + * @return true=设置成功;false=设置失败 + */ + public boolean expire(final String key, final long timeout, final TimeUnit unit) { + return redisTemplate.expire(key, timeout, unit); + } + + /** + * 获取有效时间 + * + * @param key Redis键 + * @return 有效时间 + */ + public long getExpire(final String key) { + return redisTemplate.getExpire(key); + } + + /** + * 判断 key是否存在 + * + * @param key 键 + * @return true 存在 false不存在 + */ + public Boolean hasKey(String key) { + return redisTemplate.hasKey(key); + } + + /** + * 获得缓存的基本对象。 + * + * @param key 缓存键值 + * @return 缓存键值对应的数据 + */ + public T getCacheObject(final String key) { + ValueOperations operation = redisTemplate.opsForValue(); + return operation.get(key); + } + + /** + * 删除单个对象 + * + * @param key + */ + public boolean deleteObject(final String key) { + return redisTemplate.delete(key); + } + + /** + * 删除集合对象 + * + * @param collection 多个对象 + * @return + */ + public boolean deleteObject(final Collection collection) { + return redisTemplate.delete(collection) > 0; + } + + /** + * 缓存List数据 + * + * @param key 缓存的键值 + * @param dataList 待缓存的List数据 + * @return 缓存的对象 + */ + public long setCacheList(final String key, final List dataList) { + Long count = redisTemplate.opsForList().rightPushAll(key, dataList); + return count == null ? 0 : count; + } + + /** + * 获得缓存的list对象 + * + * @param key 缓存的键值 + * @return 缓存键值对应的数据 + */ + public List getCacheList(final String key) { + return redisTemplate.opsForList().range(key, 0, -1); + } + + /** + * 缓存Set + * + * @param key 缓存键值 + * @param dataSet 缓存的数据 + * @return 缓存数据的对象 + */ + public BoundSetOperations setCacheSet(final String key, final Set dataSet) { + BoundSetOperations setOperation = redisTemplate.boundSetOps(key); + Iterator it = dataSet.iterator(); + while (it.hasNext()) { + setOperation.add(it.next()); + } + return setOperation; + } + + /** + * 获得缓存的set + * + * @param key + * @return + */ + public Set getCacheSet(final String key) { + return redisTemplate.opsForSet().members(key); + } + + /** + * 缓存Map + * + * @param key + * @param dataMap + */ + public void setCacheMap(final String key, final Map dataMap) { + if (dataMap != null) { + redisTemplate.opsForHash().putAll(key, dataMap); + } + } + + /** + * 获得缓存的Map + * + * @param key + * @return + */ + public Map getCacheMap(final String key) { + return redisTemplate.opsForHash().entries(key); + } + + /** + * 往Hash中存入数据 + * + * @param key Redis键 + * @param hKey Hash键 + * @param value 值 + */ + public void setCacheMapValue(final String key, final String hKey, final T value) { + redisTemplate.opsForHash().put(key, hKey, value); + } + + /** + * 获取Hash中的数据 + * + * @param key Redis键 + * @param hKey Hash键 + * @return Hash中的对象 + */ + public T getCacheMapValue(final String key, final String hKey) { + HashOperations opsForHash = redisTemplate.opsForHash(); + return opsForHash.get(key, hKey); + } + + /** + * 获取多个Hash中的数据 + * + * @param key Redis键 + * @param hKeys Hash键集合 + * @return Hash对象集合 + */ + public List getMultiCacheMapValue(final String key, final Collection hKeys) { + return redisTemplate.opsForHash().multiGet(key, hKeys); + } + + /** + * 删除Hash中的某条数据 + * + * @param key Redis键 + * @param hKey Hash键 + * @return 是否成功 + */ + public boolean deleteCacheMapValue(final String key, final String hKey) { + return redisTemplate.opsForHash().delete(key, hKey) > 0; + } + + /** + * 获得缓存的基本对象列表 + * + * @param pattern 字符串前缀 + * @return 对象列表 + */ + public Collection keys(final String pattern) { + return redisTemplate.keys(pattern); + } +} diff --git a/fire/src/main/java/com/yingji/service/FireService.java b/fire/src/main/java/com/yingji/service/FireService.java new file mode 100644 index 0000000..5dbbb68 --- /dev/null +++ b/fire/src/main/java/com/yingji/service/FireService.java @@ -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 { + + + /** + * 查询数据 + * + * @param req 查询条件 + * @param token token + * @return 数据List + */ + List findDataList(String token); + + /** + * 获取110token + * + * @return token + */ + String getToken(); + + + /** + * 批量插入数据 + * + * @param list 数据 + */ + void saveAll(List list); +} + diff --git a/fire/src/main/java/com/yingji/service/impl/FireServiceImpl.java b/fire/src/main/java/com/yingji/service/impl/FireServiceImpl.java new file mode 100644 index 0000000..4c31c68 --- /dev/null +++ b/fire/src/main/java/com/yingji/service/impl/FireServiceImpl.java @@ -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 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 findDataList(String token) { + List 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 list) { + baseMapper.saveAll(list); + } +} + diff --git a/fire/src/main/resources/application-dev.yml b/fire/src/main/resources/application-dev.yml new file mode 100644 index 0000000..4feda61 --- /dev/null +++ b/fire/src/main/resources/application-dev.yml @@ -0,0 +1,41 @@ +# DataSource Config +spring: + datasource: + url: jdbc:mysql://localhost:3306/algorithms?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + username: root + password: 123456 + driverClassName: com.mysql.cj.jdbc.Driver + + + +# 日志配置 +logging: + level: + com.yingji: debug + org.springframework: warn + +# MyBatis配置 +mybatis-plus: + # 指定实体类所在包的路径,MyBatis-Plus 会自动扫描该路径下的实体类 + typeAliasesPackage: com.yingji.entity + # 指定 Mapper 接口所在包的路径,MyBatis-Plus 会自动扫描该路径下的 Mapper 接口 + mapperLocations: classpath*:mapper/yingji/*Mapper.xml + +knife4j: + enable: true +# openapi: +# group: +# test1: +# group-name: 应急算法 + +# 119获取token +getToken: http://2.46.4.198:8008/token + +# 119获取数据 +specificWarn: http://2.46.4.198:8008/rs/8uu6d/DataAnalysisService/st/data/fire_alarm + +# 119clientId +clientId: BFShT3/WwPhZJQdL8e4FdnQ11h0QOeKqBdn+xesCSJGlDHKPk5fxnmnLk1onkm3YzdfjE0gLGEZ7H7vfLs21sGM= + +# 119clientSecret +clientSecret: GtbgRfNImXjmBqW0npxUiGi/s0mb5ZdvXANqUCgmIm4= diff --git a/fire/src/main/resources/application.yml b/fire/src/main/resources/application.yml new file mode 100644 index 0000000..3d91528 --- /dev/null +++ b/fire/src/main/resources/application.yml @@ -0,0 +1,40 @@ +server: + port: 9008 +spring: + profiles: + active: dev + + redis: + host: localhost + port: 6379 + password: + database: 1 + jedis: + pool: + max-active: 8 # 最大连接数 + max-wait: 1ms # 最大阻塞时间 + max-idle: 4 + min-idle: 0 +# 日志配置 +logging: + level: + com.yingji: info + org.springframework: info + +sa-token: + # token 名称(同时也是 cookie 名称) + token-name: token + # token 有效期(单位:秒) 默认30天,-1 代表永久有效 + timeout: 86400 + # token 最低活跃频率(单位:秒),如果 token 超过此时间没有访问系统就会被冻结,默认-1 代表不限制,永不冻结 + active-timeout: -1 + # 是否允许同一账号多地同时登录 (为 true 时允许一起登录, 为 false 时新登录挤掉旧登录) + is-concurrent: true + # 在多人登录同一账号时,是否共用一个 token (为 true 时所有登录共用一个 token, 为 false 时每次登录新建一个 token) + is-share: true + # token 风格(默认可取值:uuid、simple-uuid、random-32、random-64、random-128、tik) + token-style: uuid + # 是否输出操作日志 + is-log: true + + diff --git a/fire/src/main/resources/com/yingji/mapper/FireMapper.xml b/fire/src/main/resources/com/yingji/mapper/FireMapper.xml new file mode 100644 index 0000000..62172ec --- /dev/null +++ b/fire/src/main/resources/com/yingji/mapper/FireMapper.xml @@ -0,0 +1,21 @@ + + + + + + + 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 + + (#{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}) + + + + \ No newline at end of file diff --git a/fire/src/main/resources/logback.xml b/fire/src/main/resources/logback.xml new file mode 100644 index 0000000..3ee87b6 --- /dev/null +++ b/fire/src/main/resources/logback.xml @@ -0,0 +1,93 @@ + + + + + + + + + + + ${log.pattern} + + + + + + ${log.path}/sys-info.log + + + + ${log.path}/sys-info.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + + + INFO + + ACCEPT + + DENY + + + + + ${log.path}/sys-error.log + + + + ${log.path}/sys-error.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + + + ERROR + + ACCEPT + + DENY + + + + + + ${log.path}/sys-user.log + + + ${log.path}/sys-user.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/page/src/main/java/com/yingji/controller/AlarmController.java b/page/src/main/java/com/yingji/controller/AlarmController.java index ead4160..3f16930 100644 --- a/page/src/main/java/com/yingji/controller/AlarmController.java +++ b/page/src/main/java/com/yingji/controller/AlarmController.java @@ -55,8 +55,8 @@ public class AlarmController extends BaseController { @ApiOperation(value = "分页条件查询报警事件", response = Alarm.class) public AjaxResult page(Page page, AlarmFindRequest req) { StpUtil.checkLogin(); - if (page.getSize() > 500) { - page.setSize(500); + if (page.getSize() > 1000) { + page.setSize(1000); } return success(alarmService.page(page, req)); } diff --git a/page/src/main/java/com/yingji/controller/EventController.java b/page/src/main/java/com/yingji/controller/EventController.java index a8298b9..aa561e9 100644 --- a/page/src/main/java/com/yingji/controller/EventController.java +++ b/page/src/main/java/com/yingji/controller/EventController.java @@ -55,8 +55,8 @@ public class EventController extends BaseController { @ApiOperation(value = "分页条件查询事故", response = Event.class) public AjaxResult page(Page page, EventPageRequest event) { StpUtil.checkLogin(); - if (page.getSize() > 500) { - page.setSize(500); + if (page.getSize() > 1000) { + page.setSize(1000); } return success(eventService.page(page, event)); } diff --git a/page/src/main/java/com/yingji/controller/FireController.java b/page/src/main/java/com/yingji/controller/FireController.java new file mode 100644 index 0000000..2d659df --- /dev/null +++ b/page/src/main/java/com/yingji/controller/FireController.java @@ -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 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)); + } + + +} + diff --git a/page/src/main/java/com/yingji/entity/Event.java b/page/src/main/java/com/yingji/entity/Event.java index 25dab10..4c6611d 100644 --- a/page/src/main/java/com/yingji/entity/Event.java +++ b/page/src/main/java/com/yingji/entity/Event.java @@ -132,5 +132,22 @@ public class Event implements Serializable { @ApiModelProperty(value = "110的emergency_event_id") @TableField(value = "ai_110_id") private Long ai110Id; + + /** + * 创建时间 + */ + @ApiModelProperty(value = "创建时间") + @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; + + /** + * 最后更新时间 + */ + @ApiModelProperty(value = "最后更新时间") + @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 updateTime; + } diff --git a/page/src/main/java/com/yingji/entity/Fire.java b/page/src/main/java/com/yingji/entity/Fire.java new file mode 100644 index 0000000..919d805 --- /dev/null +++ b/page/src/main/java/com/yingji/entity/Fire.java @@ -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; +} + diff --git a/page/src/main/java/com/yingji/entity/dto/request/FireFindRequest.java b/page/src/main/java/com/yingji/entity/dto/request/FireFindRequest.java new file mode 100644 index 0000000..1ee8c37 --- /dev/null +++ b/page/src/main/java/com/yingji/entity/dto/request/FireFindRequest.java @@ -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; +} diff --git a/page/src/main/java/com/yingji/mapper/FireMapper.java b/page/src/main/java/com/yingji/mapper/FireMapper.java new file mode 100644 index 0000000..7c45267 --- /dev/null +++ b/page/src/main/java/com/yingji/mapper/FireMapper.java @@ -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 { + +} + diff --git a/page/src/main/java/com/yingji/service/FireService.java b/page/src/main/java/com/yingji/service/FireService.java new file mode 100644 index 0000000..d74bfad --- /dev/null +++ b/page/src/main/java/com/yingji/service/FireService.java @@ -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 { + + /** + * 分页条件查询所有数据 + * + * @param page 分页条件 + * @param fire 查询条件 + * @return 所有数据 + */ + Page page(Page page, FireFindRequest fire); +} + diff --git a/page/src/main/java/com/yingji/service/impl/EventServiceImpl.java b/page/src/main/java/com/yingji/service/impl/EventServiceImpl.java index d724799..0cc327c 100644 --- a/page/src/main/java/com/yingji/service/impl/EventServiceImpl.java +++ b/page/src/main/java/com/yingji/service/impl/EventServiceImpl.java @@ -57,8 +57,8 @@ public class EventServiceImpl extends ServiceImpl implements .like(StrUtil.isNotEmpty(event.getEventName()), "event_name", event.getEventName()) .eq(StrUtil.isNotEmpty(event.getEventType()), "event_type", event.getEventType()) .eq(StrUtil.isNotEmpty(event.getEventLevel()), "event_level", event.getEventLevel()) - .ge(event.getStartTime() != null, "event_date_time", event.getStartTime()) - .le(event.getEndTime() != null, "event_date_time", event.getEndTime()) + .ge(event.getStartTime() != null, "create_time", event.getStartTime()) + .le(event.getEndTime() != null, "create_time", event.getEndTime()) .like(StrUtil.isNotEmpty(event.getEventArea()), "event_area", event.getEventArea()) .like(StrUtil.isNotEmpty(event.getEventAddress()), "event_address", event.getEventAddress()) .eq(event.getSendAmbCount() != null, "send_amb_count", event.getSendAmbCount()) diff --git a/page/src/main/java/com/yingji/service/impl/FireServiceImpl.java b/page/src/main/java/com/yingji/service/impl/FireServiceImpl.java new file mode 100644 index 0000000..eb40c79 --- /dev/null +++ b/page/src/main/java/com/yingji/service/impl/FireServiceImpl.java @@ -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 implements FireService { + + /** + * 分页条件查询所有数据 + * + * @param page 分页条件 + * @param fire 查询条件 + * @return 所有数据 + */ + @Override + public Page page(Page page, FireFindRequest fire) { + QueryWrapper 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); + } +} + diff --git a/page/src/main/resources/mapper/yingji/AlarmMapper.xml b/page/src/main/resources/mapper/yingji/AlarmMapper.xml index 8b29db9..80b3b23 100644 --- a/page/src/main/resources/mapper/yingji/AlarmMapper.xml +++ b/page/src/main/resources/mapper/yingji/AlarmMapper.xml @@ -9,13 +9,10 @@ select * from alarm where ai_class is not null - and emergency_event_time >= #{req.startTime} + and create_time >= #{req.startTime} - and emergency_event_time <= #{req.endTime} - - - and emergency_event_time <= #{req.endTime} + and create_time <= #{req.endTime} and emergency_event_desc like concat('%', #{req.emergencyEventDesc}, '%') diff --git a/pom.xml b/pom.xml index b3daa0e..7e65813 100644 --- a/pom.xml +++ b/pom.xml @@ -12,6 +12,7 @@ alarm rescue page + fire 1.8 diff --git a/rescue/src/main/java/com/yingji/entity/Event.java b/rescue/src/main/java/com/yingji/entity/Event.java index 25dab10..1a88050 100644 --- a/rescue/src/main/java/com/yingji/entity/Event.java +++ b/rescue/src/main/java/com/yingji/entity/Event.java @@ -132,5 +132,21 @@ public class Event implements Serializable { @ApiModelProperty(value = "110的emergency_event_id") @TableField(value = "ai_110_id") private Long ai110Id; + + /** + * 创建时间 + */ + @ApiModelProperty(value = "创建时间") + @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; + + /** + * 最后更新时间 + */ + @ApiModelProperty(value = "最后更新时间") + @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 updateTime; } diff --git a/rescue/src/main/java/com/yingji/service/impl/AccidentServiceImpl.java b/rescue/src/main/java/com/yingji/service/impl/AccidentServiceImpl.java index 9fae1e7..e4f20d5 100644 --- a/rescue/src/main/java/com/yingji/service/impl/AccidentServiceImpl.java +++ b/rescue/src/main/java/com/yingji/service/impl/AccidentServiceImpl.java @@ -187,10 +187,14 @@ public class AccidentServiceImpl implements AccidentService { wrapper.eq("event_id", event.getEventId()); Event one = eventService.getOne(wrapper); if (BeanUtil.isEmpty(one)) { + event.setCreateTime(LocalDateTime.now()); + event.setUpdateTime(LocalDateTime.now()); eventService.save(event); // 调用120和110事件对比接口 linkAlgorithm(event.getEventId()); + log.info("======调用120和110事件对比接口======"); } else { + event.setUpdateTime(LocalDateTime.now()); eventService.updateById(event); } }