commit 47fd93810215fee6fd91ab053589f9c688c57198 Author: liuzhenlei Date: Tue Oct 15 16:57:28 2024 +0800 init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..549e00a --- /dev/null +++ b/.gitignore @@ -0,0 +1,33 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..9a5e1b2 --- /dev/null +++ b/pom.xml @@ -0,0 +1,138 @@ + + + + org.springframework.boot + spring-boot-starter-parent + 2.5.12 + + + 4.0.0 + com.hxl + dataToPuyang + 1.0 + dataToPuyang + 龙德阳 + jar + + 1.8 + UTF-8 + UTF-8 + 2.5.12 + true + + + + + + org.springframework.boot + spring-boot-starter + ${spring-boot.version} + + + + + org.springframework.boot + spring-boot-starter-web + ${spring-boot.version} + + + + org.springframework.boot + spring-boot-starter-thymeleaf + ${spring-boot.version} + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + org.springframework.boot + spring-boot-starter-aop + + + + + org.projectlombok + lombok + 1.16.18 + true + + + + cn.hutool + hutool-all + 5.7.20 + + + + + mysql + mysql-connector-java + 8.0.17 + + + + + + com.baomidou + mybatis-plus-boot-starter + 3.4.0 + + + + + com.baomidou + dynamic-datasource-spring-boot-starter + 3.4.0 + + + + + com.xuxueli + xxl-job-core + 2.4.0 + + + + io.netty + netty-all + + + + + + + + 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.hxl.puyang.DataToPuyangApplication + + + + repackage + + repackage + + + + + + + diff --git a/src/main/java/com/hxl/puyang/DataToPuyangApplication.java b/src/main/java/com/hxl/puyang/DataToPuyangApplication.java new file mode 100644 index 0000000..a4d15fa --- /dev/null +++ b/src/main/java/com/hxl/puyang/DataToPuyangApplication.java @@ -0,0 +1,17 @@ +package com.hxl.puyang; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * @author lzl + * @date 2024-10-15 + */ +@SpringBootApplication +public class DataToPuyangApplication { + + public static void main(String[] args) { + SpringApplication.run(DataToPuyangApplication.class, args); + } + +} diff --git a/src/main/java/com/hxl/puyang/actuator/ActuatorFactory.java b/src/main/java/com/hxl/puyang/actuator/ActuatorFactory.java new file mode 100644 index 0000000..251f996 --- /dev/null +++ b/src/main/java/com/hxl/puyang/actuator/ActuatorFactory.java @@ -0,0 +1,79 @@ +package com.hxl.puyang.actuator; + +import cn.hutool.core.date.DatePattern; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.exceptions.ExceptionUtil; +import com.hxl.puyang.config.netty.BootNettyClient; +import com.hxl.puyang.location.service.LocationAlarmHistoryService; +import com.hxl.puyang.location.service.LocationRealdataService; +import com.hxl.puyang.location.service.LocationUserService; +import com.xxl.job.core.handler.annotation.XxlJob; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; + +/** + * xxl-job执行器类 + * + * @author 刘振雷 + */ +@Component +@Slf4j +public class ActuatorFactory { + + @Resource + private BootNettyClient bootNettyClient; + + @Resource + private LocationUserService locationUserService; + + @Resource + private LocationRealdataService locationRealdataService; + + @Resource + private LocationAlarmHistoryService locationAlarmHistoryService; + + /** + * 上报人员基础信息 + */ + @XxlJob("demo") + public void demo() { + try { + bootNettyClient.sendData(DateUtil.format(DateUtil.date(), DatePattern.NORM_DATETIME_PATTERN), null, null); + } catch (Exception e) { + log.error("数据发送失败"); + log.error(ExceptionUtil.stacktraceToString(e)); + } + } + + /** + * 心跳 + */ + @XxlJob("heart") + public void heart() { + log.info("发送心跳开始"); + try { + bootNettyClient.sendData("@@", null, null); + } catch (Exception e) { + log.error("数据发送失败"); + log.error(ExceptionUtil.stacktraceToString(e)); + } + log.info("发送心跳结束"); + } + + /** + * 人员基础信息 + */ + @XxlJob("reportPersonnel") + public void reportPersonnel() { + log.info("发送人员基础信息开始"); + try { + locationUserService.reportPersonnel(); + } catch (Exception e) { + log.error("数据发送失败"); + log.error(ExceptionUtil.stacktraceToString(e)); + } + log.info("发送人员基础信息结束"); + } +} diff --git a/src/main/java/com/hxl/puyang/common/Response.java b/src/main/java/com/hxl/puyang/common/Response.java new file mode 100644 index 0000000..00270ba --- /dev/null +++ b/src/main/java/com/hxl/puyang/common/Response.java @@ -0,0 +1,12 @@ +package com.hxl.puyang.common; + +import lombok.Data; + +/** + * @author lzl + * @date 2024-10-15 + */ +@Data +public class Response { + private int code; +} diff --git a/src/main/java/com/hxl/puyang/config/NettyConfig.java b/src/main/java/com/hxl/puyang/config/NettyConfig.java new file mode 100644 index 0000000..590ac3d --- /dev/null +++ b/src/main/java/com/hxl/puyang/config/NettyConfig.java @@ -0,0 +1,25 @@ +package com.hxl.puyang.config; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +/** + * netty服务器信息 + * + * @author lzl + * @date 2024-10-15 + */ +@Component +@ConfigurationProperties(prefix = "netty-config") +@Data +public class NettyConfig { + /** + * 企业编码 + */ + private String ip; + /** + * 请求接口前置地址 + */ + private Integer port; +} diff --git a/src/main/java/com/hxl/puyang/config/ReportConfig.java b/src/main/java/com/hxl/puyang/config/ReportConfig.java new file mode 100644 index 0000000..54733d3 --- /dev/null +++ b/src/main/java/com/hxl/puyang/config/ReportConfig.java @@ -0,0 +1,42 @@ +package com.hxl.puyang.config; + +import cn.hutool.core.text.CharSequenceUtil; +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +/** + * 上报相关参数配置数据 + * + * @author lzl + * @date 2024-10-15 + */ +@Component +@ConfigurationProperties(prefix = "report-config") +@Data +public class ReportConfig { + /** + * 企业编码 + */ + private String companyCode; + /** + * 请求接口前置地址 + */ + private String companyName; + + /** + * 自定义验证数据完整性 + * + * @return + */ + public boolean checkParam() throws Exception { + boolean b = true; + if (CharSequenceUtil.isEmpty(companyName)) { + throw new Exception("上报参数:companyName不合法"); + } + if (CharSequenceUtil.isEmpty(companyCode)) { + throw new Exception("上报参数:companyCode不合法"); + } + return b; + } +} diff --git a/src/main/java/com/hxl/puyang/config/XxlJobConfig.java b/src/main/java/com/hxl/puyang/config/XxlJobConfig.java new file mode 100644 index 0000000..e593647 --- /dev/null +++ b/src/main/java/com/hxl/puyang/config/XxlJobConfig.java @@ -0,0 +1,78 @@ +package com.hxl.puyang.config; + +import com.xxl.job.core.executor.impl.XxlJobSpringExecutor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * xxl-job config + * + * @author xuxueli 2017-04-28 + */ +@Configuration +public class XxlJobConfig { + private Logger logger = LoggerFactory.getLogger(XxlJobConfig.class); + + @Value("${xxl.job.admin.addresses}") + private String adminAddresses; + + @Value("${xxl.job.accessToken}") + private String accessToken; + + @Value("${xxl.job.executor.appname}") + private String appname; + + @Value("${xxl.job.executor.address}") + private String address; + + @Value("${xxl.job.executor.ip}") + private String ip; + + @Value("${xxl.job.executor.port}") + private int port; + + @Value("${xxl.job.executor.logpath}") + private String logPath; + + @Value("${xxl.job.executor.logretentiondays}") + private int logRetentionDays; + + + @Bean + public XxlJobSpringExecutor xxlJobExecutor() { + logger.info(">>>>>>>>>>> xxl-job config init."); + XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor(); + xxlJobSpringExecutor.setAdminAddresses(adminAddresses); + xxlJobSpringExecutor.setAppname(appname); + xxlJobSpringExecutor.setAddress(address); + xxlJobSpringExecutor.setIp(ip); + xxlJobSpringExecutor.setPort(port); + xxlJobSpringExecutor.setAccessToken(accessToken); + xxlJobSpringExecutor.setLogPath(logPath); + xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays); + + return xxlJobSpringExecutor; + } + + /** + * 针对多网卡、容器内部署等情况,可借助 "spring-cloud-commons" 提供的 "InetUtils" 组件灵活定制注册IP; + * + * 1、引入依赖: + * + * org.springframework.cloud + * spring-cloud-commons + * ${version} + * + * + * 2、配置文件,或者容器启动变量 + * spring.cloud.inetutils.preferred-networks: 'xxx.xxx.xxx.' + * + * 3、获取IP + * String ip_ = inetUtils.findFirstNonLoopbackHostInfo().getIpAddress(); + */ + + +} \ No newline at end of file diff --git a/src/main/java/com/hxl/puyang/config/annotation/MyLog.java b/src/main/java/com/hxl/puyang/config/annotation/MyLog.java new file mode 100644 index 0000000..e6931c9 --- /dev/null +++ b/src/main/java/com/hxl/puyang/config/annotation/MyLog.java @@ -0,0 +1,16 @@ +package com.hxl.puyang.config.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * @author lzl + * @date 2024-10-15 + */ +@Target({ElementType.METHOD, ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +public @interface MyLog { + String value() default ""; +} diff --git a/src/main/java/com/hxl/puyang/config/aop/LogAspect.java b/src/main/java/com/hxl/puyang/config/aop/LogAspect.java new file mode 100644 index 0000000..0401cbe --- /dev/null +++ b/src/main/java/com/hxl/puyang/config/aop/LogAspect.java @@ -0,0 +1,47 @@ +package com.hxl.puyang.config.aop; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.exceptions.ExceptionUtil; +import com.hxl.puyang.config.annotation.MyLog; +import com.hxl.puyang.config.exception.MyException; +import lombok.extern.slf4j.Slf4j; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; +import org.aspectj.lang.reflect.MethodSignature; +import org.springframework.stereotype.Component; + +/** + * @Author lzl + * @Date 2024-3-21 14:03:20 + */ +@Component +@Slf4j +@Aspect +public class LogAspect { + @Pointcut("@annotation(com.hxl.puyang.config.annotation.MyLog)") + public void logPoint() { + } + + @Around("logPoint()") + public Object around(ProceedingJoinPoint point) throws Exception { + MethodSignature signature = (MethodSignature) point.getSignature(); + MyLog annotation = signature.getMethod().getAnnotation(MyLog.class); + String methodName = annotation.value(); + log.info("执行[方法]:{}开始", methodName); + // 发送异步日志事件 + long startTime = DateUtil.current(); + Object obj; + try { + obj = point.proceed(); + } catch (Throwable e) { + log.error("执行[方法]:{}时异常", methodName); + log.error("错误详情:{}", ExceptionUtil.stacktraceToString(e)); + throw new MyException(e); + } finally { + log.info("执行[方法]:{}结束,用时:{}ms", methodName, DateUtil.current() - startTime); + } + return obj; + } +} diff --git a/src/main/java/com/hxl/puyang/config/exception/MyException.java b/src/main/java/com/hxl/puyang/config/exception/MyException.java new file mode 100644 index 0000000..d253757 --- /dev/null +++ b/src/main/java/com/hxl/puyang/config/exception/MyException.java @@ -0,0 +1,22 @@ +package com.hxl.puyang.config.exception; +/** + * @author lzl + * @date 2024-10-15 + */ +public class MyException extends RuntimeException { + public MyException() { + super(); + } + + public MyException(String message, Throwable cause) { + super(message, cause); + } + + public MyException(String message) { + super(message); + } + + public MyException(Throwable cause) { + super(cause); + } +} diff --git a/src/main/java/com/hxl/puyang/config/netty/BootNettyChannelInboundHandlerAdapter.java b/src/main/java/com/hxl/puyang/config/netty/BootNettyChannelInboundHandlerAdapter.java new file mode 100644 index 0000000..1e417f4 --- /dev/null +++ b/src/main/java/com/hxl/puyang/config/netty/BootNettyChannelInboundHandlerAdapter.java @@ -0,0 +1,55 @@ +package com.hxl.puyang.config.netty; + +import cn.hutool.extra.spring.SpringUtil; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelInboundHandlerAdapter; +import lombok.extern.slf4j.Slf4j; + +/** + * @author: 刘振雷 + * @time: 2024/10/15 + */ +@Slf4j +public class BootNettyChannelInboundHandlerAdapter extends ChannelInboundHandlerAdapter { + + /** + * 户端与服务端 断连时 执行 + * + * @param ctx + * @throws Exception + */ + @Override + public void channelInactive(ChannelHandlerContext ctx) throws Exception { + log.info("与netty服务器断开连接,尝试重新连接。。。"); + super.channelInactive(ctx); + ctx.close(); + BootNettyClient bootNettyClient = SpringUtil.getBean(BootNettyClient.class); + bootNettyClient.connect(); + } + + /** + * 客户端与服务端第一次建立连接时 执行 + * + * @param ctx + * @throws Exception + */ + @Override + public void channelActive(ChannelHandlerContext ctx) throws Exception { + super.channelActive(ctx); + log.info("netty服务器连接成功"); + } + + /** + * 当出现 Throwable 对象才会被调用,即当 Netty 由于 IO 错误或者处理器在处理事件时抛出的异常时 + * + * @param ctx + * @param cause + */ + @Override + public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { + log.info("netty服务异常"); + super.exceptionCaught(ctx, cause); + cause.printStackTrace(); + ctx.close(); + } +} diff --git a/src/main/java/com/hxl/puyang/config/netty/BootNettyChannelInitializer.java b/src/main/java/com/hxl/puyang/config/netty/BootNettyChannelInitializer.java new file mode 100644 index 0000000..5702b81 --- /dev/null +++ b/src/main/java/com/hxl/puyang/config/netty/BootNettyChannelInitializer.java @@ -0,0 +1,30 @@ +package com.hxl.puyang.config.netty; + +import io.netty.channel.Channel; +import io.netty.channel.ChannelInitializer; +import io.netty.handler.codec.string.StringDecoder; +import io.netty.handler.codec.string.StringEncoder; + +/** + * @author: 刘振雷 + * @time: 2024/10/15 + */ +public class BootNettyChannelInitializer extends ChannelInitializer { + + @Override + protected void initChannel(Channel ch) throws Exception { + // ChannelOutboundHandler,依照逆序执行 + ch.pipeline().addLast("encoder", new StringEncoder()); + + // 属于ChannelInboundHandler,依照顺序执行 + ch.pipeline().addLast("decoder", new StringDecoder()); + /* + * + * 自定义ChannelInboundHandlerAdapter + * 该项在源码中放在了上面两项上面,实际上需要调整到后面 + */ + ch.pipeline().addLast(new BootNettyChannelInboundHandlerAdapter()); + + } + +} diff --git a/src/main/java/com/hxl/puyang/config/netty/BootNettyClient.java b/src/main/java/com/hxl/puyang/config/netty/BootNettyClient.java new file mode 100644 index 0000000..46980cc --- /dev/null +++ b/src/main/java/com/hxl/puyang/config/netty/BootNettyClient.java @@ -0,0 +1,123 @@ +package com.hxl.puyang.config.netty; + +import cn.hutool.core.exceptions.ExceptionUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.extra.spring.SpringUtil; +import cn.hutool.json.JSONUtil; +import com.hxl.puyang.config.NettyConfig; +import com.hxl.puyang.enums.DataTypeEnum; +import com.hxl.puyang.location.entity.LocationAlarmHistory; +import com.hxl.puyang.location.entity.LocationUser; +import com.hxl.puyang.location.service.LocationAlarmHistoryService; +import com.hxl.puyang.location.service.LocationUserService; +import io.netty.bootstrap.Bootstrap; +import io.netty.channel.*; +import io.netty.channel.nio.NioEventLoopGroup; +import io.netty.channel.socket.SocketChannel; +import io.netty.channel.socket.nio.NioSocketChannel; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import javax.annotation.PreDestroy; +import javax.annotation.Resource; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @author: 刘振雷 + * @time: 2024/10/15 + */ +@Component +@Slf4j +public class BootNettyClient { + + @Resource + private NettyConfig nettyConfig; + + private Channel channel; + + private EventLoopGroup group; + + public void connect() { + log.info("连接"); + //客户端的NIO线程组 + group = new NioEventLoopGroup(); + + try { + //Bootstrap 是一个启动NIO服务的辅助启动类 客户端的 + Bootstrap bootstrap = new Bootstrap(); + //设置group + bootstrap = bootstrap.group(group); + //关联客户端通道 + bootstrap = bootstrap.channel(NioSocketChannel.class).option(ChannelOption.SO_KEEPALIVE, true); + //设置 I/O处理类,主要用于网络I/O事件,记录日志,编码、解码消息 + bootstrap = bootstrap.handler(new BootNettyChannelInitializer()); + log.info("netty client start success!"); + //连接服务端 + ChannelFuture f = bootstrap.connect(nettyConfig.getIp(), nettyConfig.getPort()).sync(); + channel = f.channel(); + } catch (Exception e) { + log.error("连接netty服务器异常"); + log.error(ExceptionUtil.stacktraceToString(e)); + } + } + + /** + * 通道可用检查,不可用则重连 + */ + public void checkChannel() throws Exception { + if (ObjectUtil.isNull(channel) || !channel.isRegistered() || !channel.isActive()) { + connect(); + } + } + + /** + * 发送数据 + * + * @param data + * @return + */ + public void sendData(String data, List list, DataTypeEnum dataTypeEnum) throws Exception { + checkChannel(); + ChannelFuture channelFuture = channel.writeAndFlush(data); + channelFuture.addListener((ChannelFutureListener) future1 -> { + if (future1.isSuccess()) { + log.info("数据发送成功!"); + if(null!= dataTypeEnum){ + switch (dataTypeEnum) { + case PERSONNEL_INFO: + LocationUserService locationUserService = SpringUtil.getBean(LocationUserService.class); + List locationUsers = list.stream() + .filter(element -> element instanceof LocationUser) + .map(element -> (LocationUser) element).collect(Collectors.toList()); + locationUserService.updateBatchById(locationUsers); + break; + case PERSONNEL_WARN: + LocationAlarmHistoryService locationAlarmHistoryService = SpringUtil.getBean(LocationAlarmHistoryService.class); + List locationAlarmHistories = list.stream() + .filter(element -> element instanceof LocationAlarmHistory) + .map(element -> (LocationAlarmHistory) element).collect(Collectors.toList()); + locationAlarmHistoryService.updateBatchById(locationAlarmHistories); + break; + case HEART: + log.info("心跳数据发送成功!"); + break; + default: + } + } + } else { + log.info("数据发送失败: " + future1.cause()); + } + }); + } + + @PreDestroy + public void stopClient() throws Exception { + if (channel != null) { + channel.close().sync(); + } + if (group != null) { + group.shutdownGracefully().sync(); + } + } +} diff --git a/src/main/java/com/hxl/puyang/config/netty/NettyClientStarter.java b/src/main/java/com/hxl/puyang/config/netty/NettyClientStarter.java new file mode 100644 index 0000000..3d1f07a --- /dev/null +++ b/src/main/java/com/hxl/puyang/config/netty/NettyClientStarter.java @@ -0,0 +1,23 @@ +package com.hxl.puyang.config.netty; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import javax.annotation.PostConstruct; + +/** + * @author: 刘振雷 + * @time: 2024/10/15 + */ +@Component +public class NettyClientStarter { + + @Autowired + private BootNettyClient bootNettyClient; + + @PostConstruct + public void start() throws Exception { + bootNettyClient.connect(); + } +} diff --git a/src/main/java/com/hxl/puyang/enums/DataTypeEnum.java b/src/main/java/com/hxl/puyang/enums/DataTypeEnum.java new file mode 100644 index 0000000..b201e34 --- /dev/null +++ b/src/main/java/com/hxl/puyang/enums/DataTypeEnum.java @@ -0,0 +1,35 @@ +package com.hxl.puyang.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.ToString; + +/** + * 服务类型 + * + * @author lzl + * @date 2024-9-5 + */ +@Getter +@ToString +@AllArgsConstructor +public enum DataTypeEnum { + /** + * 人员数据 + */ + PERSONNEL_INFO("PERSONNEL_INFO"), + /** + * 人员定位 + */ + PERSONNEL_REAL("PERSONNEL_REAL"), + /** + * 人员报警 + */ + PERSONNEL_WARN("PERSONNEL_WARN"), + /** + * 人员报警 + */ + HEART("HEART"); + + private final String serviceId; +} diff --git a/src/main/java/com/hxl/puyang/location/entity/LocationAlarmHistory.java b/src/main/java/com/hxl/puyang/location/entity/LocationAlarmHistory.java new file mode 100644 index 0000000..ea9547a --- /dev/null +++ b/src/main/java/com/hxl/puyang/location/entity/LocationAlarmHistory.java @@ -0,0 +1,155 @@ +package com.hxl.puyang.location.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * 历史求救记录表 + * + * @author lzl + * @TableName hxl_location_alarm_history + */ +@TableName(value = "hxl_location_alarm_history") +@Data +public class LocationAlarmHistory implements Serializable { + /** + * id + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 卡ID + */ + @TableField(value = "card_id") + private String cardId; + + /** + * 信标ID + */ + @TableField(value = "beacon_id") + private String beaconId; + + /** + * 求救时间 + */ + @TableField(value = "alarm_time") + private Date alarmTime; + + /** + * 报警类型 + */ + @TableField(value = "police_type") + private Integer policeType; + + /** + * 处理状态 + */ + @TableField(value = "handle_status") + private Integer handleStatus; + + /** + * 处理信息 + */ + @TableField(value = "handle_measures") + private String handleMeasures; + + /** + * 是否忽略提醒 + */ + @TableField(value = "is_ignore") + private Integer isIgnore; + + /** + * 备注 + */ + @TableField(value = "remark") + private String remark; + + /** + * 是否误报(0不是 1是) + */ + @TableField(value = "false_positives") + private Integer falsePositives; + + /** + * + */ + @TableField(value = "dealing_with_people") + private String dealingWithPeople; + + /** + * + */ + @TableField(value = "processing_time") + private Date processingTime; + + /** + * + */ + @TableField(value = "grid_id") + private Integer gridId; + + /** + * + */ + @TableField(value = "end_time") + private Date endTime; + + /** + * + */ + @TableField(value = "build_id") + private Long buildId; + + /** + * + */ + @TableField(value = "floor_id") + private Long floorId; + + /** + * + */ + @TableField(value = "coor_info_sat_lon") + private Double coorInfoSatLon; + + /** + * + */ + @TableField(value = "coor_info_sat_lat") + private Double coorInfoSatLat; + + /** + * 是否上报:1.已上报0.未上报 + */ + @TableField(value = "is_report") + private String isReport; + + /** + * + */ + @TableField(value = "dealing_with_people_id") + private Long dealingWithPeopleId; + + /** + * 园区上报状态:0.待上报/1.已上报/2.已删除/3.待更新 + */ + @TableField(value = "is_report_yq") + private Integer isReportYq; + + /** + * 上报ID + */ + @TableField(value = "rid") + private String rid; + + @TableField(exist = false) + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/src/main/java/com/hxl/puyang/location/entity/LocationRealdata.java b/src/main/java/com/hxl/puyang/location/entity/LocationRealdata.java new file mode 100644 index 0000000..c911f41 --- /dev/null +++ b/src/main/java/com/hxl/puyang/location/entity/LocationRealdata.java @@ -0,0 +1,96 @@ +package com.hxl.puyang.location.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * 实时定位表 + * + * @author lzl + * @TableName hxl_location_realdata + */ +@TableName(value = "hxl_location_realdata") +@Data +public class LocationRealdata implements Serializable { + /** + * id + */ + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + /** + * 卡ID + */ + @TableField(value = "card_id") + private String cardId; + + /** + * 卡是否报警(0:否;1:是) + */ + @TableField(value = "is_alarm") + private Integer isAlarm; + + /** + * 卡是否低电量(0:否;1:是) + */ + @TableField(value = "is_low_power") + private Integer isLowPower; + + /** + * 卡是否静止(0:否;1:是) + */ + @TableField(value = "is_still") + private Integer isStill; + + /** + * 当前信标ID + */ + @TableField(value = "beacon_id") + private String beaconId; + + /** + * 距离信标距离 + */ + @TableField(value = "distance") + private BigDecimal distance; + + /** + * 获取信号时间 + */ + @TableField(value = "signal_time") + private Date signalTime; + + /** + * 上一信标ID + */ + @TableField(value = "pre_beacon_id") + private String preBeaconId; + + /** + * 上一信标信号获取时间 + */ + @TableField(value = "pre_signal_time") + private Date preSignalTime; + + /** + * 数据创建时间 + */ + @TableField(value = "create_time") + private Date createTime; + + /** + * 数据更新时间 + */ + @TableField(value = "update_time") + private Date updateTime; + + @TableField(exist = false) + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/src/main/java/com/hxl/puyang/location/entity/LocationUser.java b/src/main/java/com/hxl/puyang/location/entity/LocationUser.java new file mode 100644 index 0000000..468f93c --- /dev/null +++ b/src/main/java/com/hxl/puyang/location/entity/LocationUser.java @@ -0,0 +1,239 @@ +package com.hxl.puyang.location.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * 定位人员信息表 + * + * @author lzl + * @TableName hxl_location_user + */ +@TableName(value = "hxl_location_user") +@Data +public class LocationUser implements Serializable { + /** + * + */ + @TableId(value = "ID", type = IdType.AUTO) + private Long id; + + /** + * 卡号 + */ + @TableField(value = "CARD_NO") + private String cardNo; + + /** + * + */ + @TableField(value = "CARD_NO_TYPE") + private String cardNoType; + + /** + * 姓名 + */ + @TableField(value = "USER_NAME") + private String userName; + + /** + * + */ + @TableField(value = "WORK_NUMBER") + private String workNumber; + + /** + * 身份证号 + */ + @TableField(value = "USER_CARD_NO") + private String userCardNo; + + /** + * + */ + @TableField(value = "IMG_NAME") + private String imgName; + + /** + * + */ + @TableField(value = "IMG_ID") + private String imgId; + + /** + * + */ + @TableField(value = "IMG_PATH") + private String imgPath; + + /** + * 手机号 + */ + @TableField(value = "USER_PHONE") + private String userPhone; + + /** + * + */ + @TableField(value = "USER_EMAIL") + private String userEmail; + + /** + * + */ + @TableField(value = "USER_DEPT") + private Long userDept; + + /** + * + */ + @TableField(value = "USER_POSITION") + private String userPosition; + + /** + * + */ + @TableField(value = "ROOM_NUMBER") + private String roomNumber; + + /** + * + */ + @TableField(value = "ROOM_NAME") + private String roomName; + + /** + * + */ + @TableField(value = "GEO_X") + private String geoX; + + /** + * + */ + @TableField(value = "GEO_Y") + private String geoY; + + /** + * + */ + @TableField(value = "POLICE_TYPE") + private String policeType; + + /** + * 人员类型,1:员工 + */ + @TableField(value = "USER_TYPE") + private String userType; + + /** + * + */ + @TableField(value = "IC_NUMBER") + private String icNumber; + + /** + * 性别 1男 2女 + */ + @TableField(value = "USER_SEX") + private String userSex; + + /** + * + */ + @TableField(value = "BIRTH_DATA") + private Date birthData; + + /** + * + */ + @TableField(value = "ENTRY_DATA") + private Date entryData; + + /** + * + */ + @TableField(value = "IS_TRAINING") + private String isTraining; + + /** + * + */ + @TableField(value = "IS_CERTIFICATE") + private String isCertificate; + + /** + * + */ + @TableField(value = "REMARKS") + private String remarks; + + /** + * + */ + @TableField(value = "ELECTRICITY_TYPE") + private String electricityType; + + /** + * + */ + @TableField(value = "USER_CARDNO_TYPE") + private String userCardnoType; + + /** + * + */ + @TableField(value = "CREATE_DATA") + private Date createData; + + /** + * + */ + @TableField(value = "COMPANY_AFFILIATION_ID") + private Long companyAffiliationId; + + /** + * 安全帽 + */ + @TableField(value = "safety_hat") + private String safetyHat; + + /** + * + */ + @TableField(value = "is_delete") + private String isDelete; + + /** + * + */ + @TableField(value = "origin_id") + private String originId; + + /** + * + */ + @TableField(value = "origin_dept") + private String originDept; + + /** + * 园区上报状态:0.待上报/1.已上报/2.已删除/3.待更新 + */ + @TableField(value = "is_report_yq") + private Integer isReportYq; + + /** + * 上报ID + */ + @TableField(value = "rid") + private String rid; + + @TableField(exist = false) + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/src/main/java/com/hxl/puyang/location/mapper/LocationAlarmHistoryMapper.java b/src/main/java/com/hxl/puyang/location/mapper/LocationAlarmHistoryMapper.java new file mode 100644 index 0000000..a92f0dd --- /dev/null +++ b/src/main/java/com/hxl/puyang/location/mapper/LocationAlarmHistoryMapper.java @@ -0,0 +1,20 @@ +package com.hxl.puyang.location.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hxl.puyang.location.entity.LocationAlarmHistory; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author lzl + * @description 针对表【hxl_location_alarm_history(历史求救记录表)】的数据库操作Mapper + * @createDate 2024-10-15 14:00:33 + * @Entity com.hxl.puyang.location.entity.LocationAlarmHistory + */ +@Mapper +public interface LocationAlarmHistoryMapper extends BaseMapper { + +} + + + + diff --git a/src/main/java/com/hxl/puyang/location/mapper/LocationRealdataMapper.java b/src/main/java/com/hxl/puyang/location/mapper/LocationRealdataMapper.java new file mode 100644 index 0000000..d6a7ca6 --- /dev/null +++ b/src/main/java/com/hxl/puyang/location/mapper/LocationRealdataMapper.java @@ -0,0 +1,20 @@ +package com.hxl.puyang.location.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hxl.puyang.location.entity.LocationRealdata; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author lzl + * @description 针对表【hxl_location_realdata(实时定位表)】的数据库操作Mapper + * @createDate 2024-10-15 11:04:40 + * @Entity com.hxl.puyang.location.entity.LocationRealdata + */ +@Mapper +public interface LocationRealdataMapper extends BaseMapper { + +} + + + + diff --git a/src/main/java/com/hxl/puyang/location/mapper/LocationUserMapper.java b/src/main/java/com/hxl/puyang/location/mapper/LocationUserMapper.java new file mode 100644 index 0000000..e9876d3 --- /dev/null +++ b/src/main/java/com/hxl/puyang/location/mapper/LocationUserMapper.java @@ -0,0 +1,30 @@ +package com.hxl.puyang.location.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hxl.puyang.location.entity.LocationUser; +import com.hxl.puyang.location.model.PersonnelModel; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * @author lzl + * @description 针对表【hxl_location_user】的数据库操作Mapper + * @createDate 2024-10-15 14:01:40 + * @Entity com.hxl.puyang.location.entity.LocationUser + */ +@Mapper +public interface LocationUserMapper extends BaseMapper { + + + /** + * 获取需要上报的人员信息 + * + * @return + */ + List getPersonnel(); +} + + + + diff --git a/src/main/java/com/hxl/puyang/location/model/AlarmDataModel.java b/src/main/java/com/hxl/puyang/location/model/AlarmDataModel.java new file mode 100644 index 0000000..f4ed6e7 --- /dev/null +++ b/src/main/java/com/hxl/puyang/location/model/AlarmDataModel.java @@ -0,0 +1,76 @@ +package com.hxl.puyang.location.model; + +import lombok.Data; + +/** + * @author: 刘振雷 + * @time: 2024/10/15 + */ +@Data +public class AlarmDataModel { + + /** + * 主键ID,必须 + */ + private String id; + /** + * 报警设备编码,必须 + */ + private String deviceCode; + /** + * 报警设备类型1:定位终端;2、 电子围栏; 3:其他,必须 + */ + private String deviceType; + /** + * 报警时间,格式 yyyyMMddHHmmss,必须 + */ + private String alarmStartTime; + /** + * 报警类型1、入侵;2、超速;3、 求救;4、滞留,必须 + */ + private String alarmType; + /** + * 经度(WGS84,9位,最大六位小 数),必须 + */ + private String longitude; + /** + * 纬度(WGS84,9位,最大六位小 数),必须 + */ + private String latitude; + /** + * 处置状态 1:已处置 2:未处置,必须 + */ + private String alarmStatus; + /** + * 处置时间,格式 yyyyMMddHHmmss,必须 + */ + private String alarmEndTime; + /** + * 删除标志:正常:0;已删除: 1,必须 + */ + private String deleted; + /** + * 创建时间 格式yyyyMMddHHmmss,必须 + */ + private String createDate; + /** + * 创建人,必须 + */ + private String createBy; + /** + * 最后修改时间(新创建的数据和创 建时间相同) 格式yyyyMMddHHmmss,必须 + */ + private String updateDate; + /** + * 最后修改人,必须 + */ + private String updateBy; + /** + * 报警编码,必须 + */ + private String alarmCode; + /** + * 数据的源ID + */ + private long oid; +} diff --git a/src/main/java/com/hxl/puyang/location/model/DataModel.java b/src/main/java/com/hxl/puyang/location/model/DataModel.java new file mode 100644 index 0000000..79ee262 --- /dev/null +++ b/src/main/java/com/hxl/puyang/location/model/DataModel.java @@ -0,0 +1,30 @@ +package com.hxl.puyang.location.model; + +import lombok.Data; + +/** + * 上报数据的最终模型 + * + * @author: 刘振雷 + * @time: 2024/10/15 + */ +@Data +public class DataModel { + /** + * 企业编码,园区提供 + */ + private String companyCode; + /** + * 服务信息 + * 序号 数据内容 serviceId + * 1 人员数据 PERSONNEL_INFO + * 2 人员定位 PERSONNEL_REAL + * 3 人员报警 PERSONNEL_WARN + */ + private String serviceId; + /** + * 加密数据字符串 + */ + private String data; + +} diff --git a/src/main/java/com/hxl/puyang/location/model/DataSecureModel.java b/src/main/java/com/hxl/puyang/location/model/DataSecureModel.java new file mode 100644 index 0000000..e6e7509 --- /dev/null +++ b/src/main/java/com/hxl/puyang/location/model/DataSecureModel.java @@ -0,0 +1,21 @@ +package com.hxl.puyang.location.model; + +import lombok.Data; + +import java.util.List; + +/** + * @author: 刘振雷 + * @time: 2024/10/15 + */ +@Data +public class DataSecureModel { + /** + * 采集时间戳,格式 yyyyMMddHHmmss + */ + private String collectTime; + /** + * 数据包 + */ + private List datas; +} diff --git a/src/main/java/com/hxl/puyang/location/model/PersonnelModel.java b/src/main/java/com/hxl/puyang/location/model/PersonnelModel.java new file mode 100644 index 0000000..16168c9 --- /dev/null +++ b/src/main/java/com/hxl/puyang/location/model/PersonnelModel.java @@ -0,0 +1,81 @@ +package com.hxl.puyang.location.model; + +import lombok.Data; + +/** + * 上报人员信息模型 + * + * @author: 刘振雷 + * @time: 2024/10/15 + */ +@Data +public class PersonnelModel { + /** + * 主键,36位UUID,必须 + */ + private String id; + /** + * 人员编码36位,必须 + */ + private String staffCode; + /** + * 人员姓名,必须 + */ + private String staffName; + /** + * 人员姓名,人员类型1:企业内部人员 ,2: 园 区工作人员 ,3:承包商人员 ,4: 临时访客 ,5:应急救援人员 ,6: 上级部门检查人员 ,7:驾驶员,8:押运员 ,9:其他;必须 + */ + private String staffType; + /** + * 所属单位,必须 + */ + private String affiliation; + /** + * 删除标志:正常:0;已删除: 1,必须 + */ + private String deleted; + /** + * 创建时间 格式yyyyMMddHHmmss,必须 + */ + private String createDate; + /** + * 创建人,必须 + */ + private String createBy; + /** + * 最后修改时间(新创建的数据和创 建时间相同) 格式yyyyMMddHHmmss,必须 + */ + private String updateDate; + /** + * 最后修改人,必须 + */ + private String updateBy; + /** + * 职位名称,非必须 + */ + private String staffPosition; + /** + * 性别: 0:男性 ,1:女性,必须 + */ + private String staffGender; + /** + * 专业,非必须 + */ + private String staffMajor; + /** + * 证件号码,必须 + */ + private String idCard; + /** + * 其他证件,非必须 + */ + private String papers; + /** + * 联系方式,必须 + */ + private String telephone; + /** + * 数据的源ID + */ + private long oid; +} diff --git a/src/main/java/com/hxl/puyang/location/model/RealDataModel.java b/src/main/java/com/hxl/puyang/location/model/RealDataModel.java new file mode 100644 index 0000000..67268b1 --- /dev/null +++ b/src/main/java/com/hxl/puyang/location/model/RealDataModel.java @@ -0,0 +1,55 @@ +package com.hxl.puyang.location.model; + +import lombok.Data; + +/** + * @author: 刘振雷 + * @time: 2024/10/15 + */ +@Data +public class RealDataModel { + /** + * 主键,必须 + */ + private String id; + /** + * 经度(WGS84,9位,最大六位小 数),必须 + */ + private String longitude; + /** + * 纬度(WGS84,9位,最大六位小 数),必须 + */ + private String latitude; + /** + * 定位终端编码,必须 + */ + private String locaterCode; + /** + * 人员编码,必须 + */ + private String staffCode; + /** + * 位置描述,非必须 + */ + private String address; + /** + * 删除标志:正常:0;已删除: 1,必须 + */ + private String deleted; + /** + * 创建时间 格式yyyyMMddHHmmss,必须 + */ + private String createDate; + /** + * 创建人,必须 + */ + private String createBy; + /** + * 最后修改时间(新创建的数据和创 建时间相同) 格式yyyyMMddHHmmss,必须 + */ + private String updateDate; + /** + * 最后修改人,必须 + */ + private String updateBy; +} diff --git a/src/main/java/com/hxl/puyang/location/service/LocationAlarmHistoryService.java b/src/main/java/com/hxl/puyang/location/service/LocationAlarmHistoryService.java new file mode 100644 index 0000000..03d5a5a --- /dev/null +++ b/src/main/java/com/hxl/puyang/location/service/LocationAlarmHistoryService.java @@ -0,0 +1,13 @@ +package com.hxl.puyang.location.service; + +import com.hxl.puyang.location.entity.LocationAlarmHistory; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + * @author lzl + * @description 针对表【hxl_location_alarm_history(历史求救记录表)】的数据库操作Service + * @createDate 2024-10-15 14:00:33 + */ +public interface LocationAlarmHistoryService extends IService { + +} diff --git a/src/main/java/com/hxl/puyang/location/service/LocationRealdataService.java b/src/main/java/com/hxl/puyang/location/service/LocationRealdataService.java new file mode 100644 index 0000000..6026b2f --- /dev/null +++ b/src/main/java/com/hxl/puyang/location/service/LocationRealdataService.java @@ -0,0 +1,13 @@ +package com.hxl.puyang.location.service; + +import com.hxl.puyang.location.entity.LocationRealdata; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + * @author lzl + * @description 针对表【hxl_location_realdata(实时定位表)】的数据库操作Service + * @createDate 2024-10-15 11:04:40 + */ +public interface LocationRealdataService extends IService { + +} diff --git a/src/main/java/com/hxl/puyang/location/service/LocationUserService.java b/src/main/java/com/hxl/puyang/location/service/LocationUserService.java new file mode 100644 index 0000000..7676c2f --- /dev/null +++ b/src/main/java/com/hxl/puyang/location/service/LocationUserService.java @@ -0,0 +1,18 @@ +package com.hxl.puyang.location.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hxl.puyang.location.entity.LocationUser; + +/** + * @author lzl + * @description 针对表【hxl_location_user】的数据库操作Service + * @createDate 2024-10-15 14:01:40 + */ +public interface LocationUserService extends IService { + + /** + * 上报人员基础信息 + */ + void reportPersonnel(); + +} diff --git a/src/main/java/com/hxl/puyang/location/service/impl/LocationAlarmHistoryServiceImpl.java b/src/main/java/com/hxl/puyang/location/service/impl/LocationAlarmHistoryServiceImpl.java new file mode 100644 index 0000000..c27b331 --- /dev/null +++ b/src/main/java/com/hxl/puyang/location/service/impl/LocationAlarmHistoryServiceImpl.java @@ -0,0 +1,22 @@ +package com.hxl.puyang.location.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hxl.puyang.location.entity.LocationAlarmHistory; +import com.hxl.puyang.location.service.LocationAlarmHistoryService; +import com.hxl.puyang.location.mapper.LocationAlarmHistoryMapper; +import org.springframework.stereotype.Service; + +/** + * @author lzl + * @description 针对表【hxl_location_alarm_history(历史求救记录表)】的数据库操作Service实现 + * @createDate 2024-10-15 14:00:33 + */ +@Service +public class LocationAlarmHistoryServiceImpl extends ServiceImpl + implements LocationAlarmHistoryService { + +} + + + + diff --git a/src/main/java/com/hxl/puyang/location/service/impl/LocationRealdataServiceImpl.java b/src/main/java/com/hxl/puyang/location/service/impl/LocationRealdataServiceImpl.java new file mode 100644 index 0000000..586cfe4 --- /dev/null +++ b/src/main/java/com/hxl/puyang/location/service/impl/LocationRealdataServiceImpl.java @@ -0,0 +1,22 @@ +package com.hxl.puyang.location.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hxl.puyang.location.entity.LocationRealdata; +import com.hxl.puyang.location.service.LocationRealdataService; +import com.hxl.puyang.location.mapper.LocationRealdataMapper; +import org.springframework.stereotype.Service; + +/** + * @author lzl + * @description 针对表【hxl_location_realdata(实时定位表)】的数据库操作Service实现 + * @createDate 2024-10-15 11:04:40 + */ +@Service +public class LocationRealdataServiceImpl extends ServiceImpl + implements LocationRealdataService { + +} + + + + diff --git a/src/main/java/com/hxl/puyang/location/service/impl/LocationUserServiceImpl.java b/src/main/java/com/hxl/puyang/location/service/impl/LocationUserServiceImpl.java new file mode 100644 index 0000000..b45debc --- /dev/null +++ b/src/main/java/com/hxl/puyang/location/service/impl/LocationUserServiceImpl.java @@ -0,0 +1,105 @@ +package com.hxl.puyang.location.service.impl; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.date.DatePattern; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.exceptions.ExceptionUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.json.JSONUtil; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hxl.puyang.common.Response; +import com.hxl.puyang.config.ReportConfig; +import com.hxl.puyang.config.netty.BootNettyClient; +import com.hxl.puyang.enums.DataTypeEnum; +import com.hxl.puyang.location.entity.LocationUser; +import com.hxl.puyang.location.mapper.LocationUserMapper; +import com.hxl.puyang.location.model.DataModel; +import com.hxl.puyang.location.model.DataSecureModel; +import com.hxl.puyang.location.model.PersonnelModel; +import com.hxl.puyang.location.service.LocationUserService; +import com.hxl.puyang.utils.DataSecureUtil; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; + +/** + * @author lzl + * @description 针对表【hxl_location_user】的数据库操作Service实现 + * @createDate 2024-10-15 14:01:40 + */ +@Service +@Slf4j +public class LocationUserServiceImpl extends ServiceImpl + implements LocationUserService { + + @Resource + private LocationUserMapper locationUserMapper; + + @Resource + private ReportConfig reportConfig; + + @Resource + private BootNettyClient bootNettyClient; + + private final static String END_STR = "@@"; + private final static int CODE = 200; + + /** + * 上报人员基础信息 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void reportPersonnel() { + log.info("开始上报——上报人员基础信息"); + try { + //验证ReportConfig数据完整性 + if (reportConfig.checkParam()) { + //1收集信息 + List personnelModels = locationUserMapper.getPersonnel(); + //用于成功后改变状态 + List locationUsers = new ArrayList<>(); + if (CollectionUtil.isNotEmpty(personnelModels)) { + for (PersonnelModel p : personnelModels) { + p.setAffiliation(reportConfig.getCompanyName()); + if (ObjectUtil.isNull(p.getId())) { + String uuid = StrUtil.uuid(); + p.setId(uuid); + p.setStaffCode(uuid); + } + LocationUser locationUser = new LocationUser(); + locationUser.setId(p.getOid()); + locationUser.setIsReportYq(1); + locationUser.setRid(p.getId()); + locationUsers.add(locationUser); + } + //包装数据 + DataSecureModel dataSecureModel = new DataSecureModel<>(); + dataSecureModel.setCollectTime(DateUtil.format(DateUtil.date(), DatePattern.PURE_DATETIME_PATTERN)); + dataSecureModel.setDatas(personnelModels); + //加密数据 + String secureStr = DataSecureUtil.encryptBase64(JSONUtil.toJsonStr(dataSecureModel)); + DataModel dataModel = new DataModel(); + dataModel.setCompanyCode(reportConfig.getCompanyCode()); + dataModel.setServiceId(DataTypeEnum.PERSONNEL_INFO.getServiceId()); + dataModel.setData(secureStr); + bootNettyClient.sendData(JSONUtil.toJsonStr(dataModel) + END_STR,locationUsers,DataTypeEnum.PERSONNEL_INFO); + } else { + log.info("上报人员基础信息,未收集到可上报的数据"); + } + } + } catch (Exception e) { + log.error("上报定位卡信息数据出错"); + log.error(ExceptionUtil.stacktraceToString(e)); + } + log.info("结束上报——上报定位卡信息数据"); + } +} + + + + diff --git a/src/main/java/com/hxl/puyang/utils/DataSecureUtil.java b/src/main/java/com/hxl/puyang/utils/DataSecureUtil.java new file mode 100644 index 0000000..3109ded --- /dev/null +++ b/src/main/java/com/hxl/puyang/utils/DataSecureUtil.java @@ -0,0 +1,37 @@ +package com.hxl.puyang.utils; + +import cn.hutool.crypto.SecureUtil; + +import java.nio.charset.StandardCharsets; + +/** + * @author: 刘振雷 + * @time: 2024/10/15 + */ +public class DataSecureUtil { + + /** + * 秘钥 + */ + private final static String KEY = "f271379419e349ba"; + + /** + * 加密数据 + * + * @param dataStr + * @return + */ + public static String encryptBase64(String dataStr) { + return SecureUtil.aes(KEY.getBytes()).encryptBase64(dataStr, StandardCharsets.UTF_8); + } + + /** + * 加密数据 + * + * @param encryptBase64Str + * @return + */ + public static String decryptBase64(String encryptBase64Str) { + return SecureUtil.aes(KEY.getBytes()).decryptStr(encryptBase64Str, StandardCharsets.UTF_8); + } +} diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml new file mode 100644 index 0000000..0d17d22 --- /dev/null +++ b/src/main/resources/application-dev.yml @@ -0,0 +1,41 @@ +spring: + datasource: + dynamic: + primary: master #设置默认的数据源或者数据源组,默认值即为master + strict: false #严格匹配数据源,默认false. true未匹配到指定数据源时抛异常,false使用默认数据源 + datasource: + master: + url: jdbc:mysql://127.0.0.1:3306/safety_chemistry_all?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true + username: root + password: root + driver-class-name: com.mysql.cj.jdbc.Driver + +mybatis-plus: + configuration: + map-underscore-to-camel-case: true + auto-mapping-behavior: full + #log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl + mapper-locations: classpath*:mybatis/**/*Mapper.xml + +xxl: + job: + admin: + addresses: http://127.0.0.1:10489/xxl-job-admin + executor: + appname: longdeyang + address: + ip: 10.8.33.15 + port: 8901 + logpath: /data/applogs/xxl-job/jobhandler + logretentiondays: 30 + accessToken: default_token + +report-config: + company-name: 濮阳龙德洋新材料有限公司 #企业名称 + company-code: 123456789 #企业编码 + +# netty 连接信息 +netty-config: + ip: 10.8.33.15 + port: 8866 diff --git a/src/main/resources/application-pro.yml b/src/main/resources/application-pro.yml new file mode 100644 index 0000000..dd74db9 --- /dev/null +++ b/src/main/resources/application-pro.yml @@ -0,0 +1,41 @@ +spring: + datasource: + dynamic: + primary: master #设置默认的数据源或者数据源组,默认值即为master + strict: false #严格匹配数据源,默认false. true未匹配到指定数据源时抛异常,false使用默认数据源 + datasource: + master: + url: jdbc:mysql://127.0.0.1:3307/safety_chemistry_all?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true + username: root + password: x5 + driver-class-name: com.mysql.cj.jdbc.Driver + +mybatis-plus: + configuration: + map-underscore-to-camel-case: true + auto-mapping-behavior: full + #log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl + mapper-locations: classpath*:mybatis/**/*Mapper.xml + +xxl: + job: + admin: + addresses: http://127.0.0.1:10489/xxl-job-admin + executor: + appname: longdeyang + address: + ip: 127.0.0.1 + port: 8901 + logpath: /data/applogs/xxl-job/jobhandler + logretentiondays: 30 + accessToken: default_token + +report-config: + company-name: 濮阳龙德洋新材料有限公司 #企业名称 + company-code: 123456789 #企业编码 + +# netty 连接信息 +netty-config: + ip: 10.8.33.15 + port: 8866 diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml new file mode 100644 index 0000000..d43b54d --- /dev/null +++ b/src/main/resources/application.yml @@ -0,0 +1,7 @@ +# 应用服务 WEB 访问端口 +server: + port: 8900 + +spring: + profiles: + active: dev diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml new file mode 100644 index 0000000..d3724fa --- /dev/null +++ b/src/main/resources/logback.xml @@ -0,0 +1,93 @@ + + + + + + + + + + + ${log.pattern} + + + + + + ${log.path}/sys-info.txt + + + + ${log.path}/sys-info.%d{yyyy-MM-dd}.txt + + 60 + + + ${log.pattern} + + + + INFO + + ACCEPT + + DENY + + + + + ${log.path}/sys-error.txt + + + + ${log.path}/sys-error.%d{yyyy-MM-dd}.txt + + 60 + + + ${log.pattern} + + + + ERROR + + ACCEPT + + DENY + + + + + + ${log.path}/sys-user.txt + + + ${log.path}/sys-user.%d{yyyy-MM-dd}.txt + + 60 + + + ${log.pattern} + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mybatis/location/LocationAlarmHistoryMapper.xml b/src/main/resources/mybatis/location/LocationAlarmHistoryMapper.xml new file mode 100644 index 0000000..f0e3eaa --- /dev/null +++ b/src/main/resources/mybatis/location/LocationAlarmHistoryMapper.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + id,card_id,beacon_id, + alarm_time,police_type,handle_status, + handle_measures,is_ignore,remark, + false_positives,dealing_with_people,processing_time, + grid_id,end_time,build_id, + floor_id,coor_info_sat_lon,coor_info_sat_lat, + is_report,dealing_with_people_id,is_report_yq, + rid + + diff --git a/src/main/resources/mybatis/location/LocationRealdataMapper.xml b/src/main/resources/mybatis/location/LocationRealdataMapper.xml new file mode 100644 index 0000000..0c2eb6b --- /dev/null +++ b/src/main/resources/mybatis/location/LocationRealdataMapper.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + id,card_id,is_alarm, + is_low_power,is_still,beacon_id, + distance,signal_time,pre_beacon_id, + pre_signal_time,create_time,update_time + + diff --git a/src/main/resources/mybatis/location/LocationUserMapper.xml b/src/main/resources/mybatis/location/LocationUserMapper.xml new file mode 100644 index 0000000..47c0deb --- /dev/null +++ b/src/main/resources/mybatis/location/LocationUserMapper.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ID,CARD_NO,CARD_NO_TYPE, + USER_NAME,WORK_NUMBER,USER_CARD_NO, + IMG_NAME,IMG_ID,IMG_PATH, + USER_PHONE,USER_EMAIL,USER_DEPT, + USER_POSITION,ROOM_NUMBER,ROOM_NAME, + GEO_X,GEO_Y,POLICE_TYPE, + USER_TYPE,IC_NUMBER,USER_SEX, + BIRTH_DATA,ENTRY_DATA,IS_TRAINING, + IS_CERTIFICATE,REMARKS,ELECTRICITY_TYPE, + USER_CARDNO_TYPE,CREATE_DATA,COMPANY_AFFILIATION_ID, + safety_hat,is_delete,origin_id, + origin_dept,is_report_yq,rid + + + +