把在宿州分支改的宣城变动同步到宣城

ds-xuancheng
luyya 2025-06-27 10:24:12 +08:00
parent 2c65144b04
commit 86bf08da8c
52 changed files with 464 additions and 202 deletions

View File

@ -89,12 +89,12 @@
<id>prod</id>
<properties>
<profiles.active>prod</profiles.active>
<nacos.server>53.16.17.13:8848</nacos.server>
<nacos.server>53.238.79.33:8848</nacos.server>
<nacos.discovery.group>DEFAULT_GROUP</nacos.discovery.group>
<nacos.config.group>DEFAULT_GROUP</nacos.config.group>
<nacos.username>nacos</nacos.username>
<nacos.password>nacos</nacos.password>
<logstash.address>53.16.17.13:4560</logstash.address>
<nacos.password>Ycgis!2509</nacos.password>
<logstash.address>53.238.79.33:4560</logstash.address>
</properties>
</profile>
</profiles>

View File

@ -1,28 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<!-- 日志存放路径 -->
<property name="log.path" value="logs/${project.artifactId}"/>
<property name="log.path" value="logs" />
<property name="log.file" value="auth" />
<property name="MAX_FILE_SIZE" value="30MB" />
<property name="MAX_HISTORY" value="30" />
<!-- 日志输出格式 -->
<property name="console.log.pattern"
value="%red(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta(%logger{36}%n) - %msg%n"/>
<!-- 控制台输出 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<!-- INFO日志Appender -->
<appender name="FILE_INFO" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/info.${log.file}.log</file>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>INFO</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${log.path}/info/info.${log.file}.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<maxFileSize>${MAX_FILE_SIZE}</maxFileSize>
<maxHistory>${MAX_HISTORY}</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${console.log.pattern}</pattern>
<charset>utf-8</charset>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<include resource="logback-common.xml" />
<!-- ERROR日志Appender -->
<appender name="FILE_ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/error.${log.file}.log</file>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>ERROR</level>
</filter>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${log.path}/error/error.${log.file}.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<maxFileSize>${MAX_FILE_SIZE}</maxFileSize>
<maxHistory>${MAX_HISTORY}</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<include resource="logback-logstash.xml" />
<!-- 开启 skywalking 日志收集 -->
<include resource="logback-skylog.xml" />
<!--系统操作日志-->
<root level="info">
<appender-ref ref="console"/>
<!-- 根Logger配置禁用控制台输出 -->
<root level="INFO">
<appender-ref ref="FILE_INFO" />
<appender-ref ref="FILE_ERROR" />
</root>
</configuration>

View File

@ -25,12 +25,12 @@ dubbo:
username: dubbo
password: ruoyi123
# 集群开关
sentinel: false
sentinel: true
parameters:
namespace: ${spring.profiles.active}
database: ${spring.data.redis.database}
timeout: ${spring.data.redis.timeout}
backup: 10.129.128.116:26380,10.129.128.115:26380,10.129.128.114:26380
backup: 53.238.79.33:26380,53.238.79.34:26380,53.238.79.35:26380
# metadata-report:
# address: redis://${spring.data.redis.host}:${spring.data.redis.port}
# group: DUBBO_GROUP

View File

@ -19,7 +19,7 @@
<module>wzhj-consumer</module>
<module>wzhj-location</module>
<module>stwzhj-dataToGas</module>
<module>wzhj-webscoket</module>
<module>wzhj-websocket</module>
<module>wzhj-extract</module>
<module>wzhj-udp</module>
</modules>

View File

@ -27,7 +27,7 @@ public class KafkaConfig {
// private String kafkaServers = "140.168.2.31:21007,140.168.2.32:21007,140.168.2.33:21007";
// private String kafkaServers = "53.208.61.105:6667,53.208.61.106:6667,53.208.61.107:6667";//六安GA网
// private String kafkaServers = "34.72.62.93:9092";//六安视频网
private String kafkaServers = "127.0.0.1:9092";//本地
private String kafkaServers = "53.238.79.33:9092,53.238.79.34:9092,53.238.79.35:9092";//本地
// private String kafkaServers = "53.238.79.4:9092,53.238.79.5:9092,53.238.79.6:9092";//省厅 马伟提供
private String groupId = "ruansiProducer";

View File

@ -0,0 +1,21 @@
package org.dromara.data2es.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Configuration;
@Data
@Configuration
@RefreshScope
@ConfigurationProperties(prefix = "ruansi")
public class RuansiConfiguration {
private boolean sendToThirdEnabled;
private String startUpdateTime;
private String dsPreurl;
}

View File

@ -3,14 +3,17 @@ package org.dromara.data2es.schedule;
import cn.hutool.core.date.DateUtil;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.dromara.data2es.config.RuansiConfiguration;
import org.dromara.data2es.domain.DSQinwuEntity;
import org.dromara.data2es.domain.vo.DSResponse;
import org.dromara.data2es.service.DSQinwuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.util.CollectionUtils;
import java.util.*;
@ -23,28 +26,23 @@ import java.util.*;
*/
@Configuration
@Slf4j
@RequiredArgsConstructor
public class BaseDataSchedule {
private String lastUpdateTime;
private String preUrl = "http://53.238.84.10:28080/ds-portal-web";
// private String preUrl = "http://53.238.84.10:28080/ds-portal-web";
@Autowired
DSQinwuService dsQinwuService;
@Value("${ruansi.ruansi-kafka.send-to-third-enabled}")
private boolean sendToThirdEnabled;
private final RuansiConfiguration ruansiConfiguration;
@Value("${ruansi.ruansi-kafka.start-update-time}")
private String startUpdateTime;
@Value("${ruansi.ruansi-kafka.ds-preurl}")
private String dsPreurl;
/**
*
*/
// @Scheduled(cron = "0/30 * * * * ?")
@Scheduled(cron = "0/30 * * * * ?")
public void updateDsQw(){
if(StringUtils.isBlank(lastUpdateTime)){
DSQinwuEntity qinwu = dsQinwuService.lastOne();
@ -152,7 +150,7 @@ public class BaseDataSchedule {
private DSResponse requestList(String updateTime, String suffixUrl) {
Map<String,Object> map = new HashMap<>();
map.put("updateTime",updateTime);
String content = HttpUtil.get(dsPreurl + suffixUrl, map);
String content = HttpUtil.get(ruansiConfiguration.getDsPreurl() + suffixUrl, map);
DSResponse dsResponse = JSONUtil.toBean(content, DSResponse.class);
return dsResponse;
}

View File

@ -30,7 +30,7 @@ public class DSQinwuServiceImpl implements DSQinwuService {
public DSQinwuEntity checkExist(DSQinwuEntity dsQinwuEntity) {
LambdaQueryWrapper<DSQinwuEntity> lqw = new LambdaQueryWrapper<>();
lqw.eq(DSQinwuEntity::getImei, dsQinwuEntity.getImei());
lqw.eq(DSQinwuEntity::getType, dsQinwuEntity.getType());
// lqw.eq(DSQinwuEntity::getType, dsQinwuEntity.getType());
DSQinwuEntity entity = dsQinwuMapper.selectOne(lqw);
return entity;
}

View File

@ -4,9 +4,8 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang.StringUtils;
import org.apache.dubbo.config.annotation.DubboReference;
@ -173,14 +172,12 @@ public class GpsServiceImpl implements IGpsService {
String deviceCode = originEsGpsInfo.getDeviceCode();
String deviceType = originEsGpsInfo.getDeviceType();
// DeviceEntityV2 de = deviceService.checkDeviceExists(info);
Object o = RedisUtils.getBucket(RedisConstants.ONLINE_USERS + deviceType+":" + deviceCode);
JSONObject o = RedisUtils.getBucket(RedisConstants.ONLINE_USERS + deviceType+":" + deviceCode);
if (Objects.isNull(o)) {
logger.error("redis中的Object=nulldeviceType={},deviceCode={}",deviceType,deviceCode);
continue;
}
JSONObject o1 = (JSONObject) o;
String json = o1.toJSONString();
EsGpsInfoVO2 esGpsInfoVO2 = JSON.parseObject(json, EsGpsInfoVO2.class);
EsGpsInfoVO2 esGpsInfoVO2 = JSONUtil.toBean(o, EsGpsInfoVO2.class);
//更新在线状态和时间,经纬度不变
esGpsInfoVO2.setOnline(originEsGpsInfo.getOnline());
@ -219,14 +216,13 @@ public class GpsServiceImpl implements IGpsService {
String deviceCode = gpsInfoVO2.getDeviceCode();
String deviceType = gpsInfoVO2.getDeviceType();
// DeviceEntityV2 de = deviceService.checkDeviceExists(info);
Object o = RedisUtils.getBucket(RedisConstants.ONLINE_USERS + deviceType + ":" + deviceCode);
JSONObject o = RedisUtils.getBucket(RedisConstants.ONLINE_USERS + deviceType + ":" + deviceCode);
if (Objects.isNull(o)) {
logger.error("redis中的Object=nulldeviceType={},deviceCode={}", deviceType, deviceCode);
return null;
}
JSONObject o1 = (JSONObject) o;
String json = o1.toJSONString();
EsGpsInfoVO2 esGpsInfoVO2 = JSON.parseObject(json, EsGpsInfoVO2.class);
EsGpsInfoVO2 esGpsInfoVO2 = JSONUtil.toBean(o, EsGpsInfoVO2.class);
//更新在线状态和时间,经纬度不变
esGpsInfoVO2.setOnline(gpsInfoVO2.getOnline());
@ -412,7 +408,19 @@ public class GpsServiceImpl implements IGpsService {
}*/
deviceEntityV2.setDeviceCode(deviceCode);
deviceEntityV2.setDeviceType(deviceType);
RemoteDeviceVo deviceEntityV21 = BeanUtil.toBean(RedisUtils.getBucket("deviceInfo:" + deviceType+":"+deviceCode), RemoteDeviceVo.class) ;
RemoteDeviceVo deviceEntityV21 = new RemoteDeviceVo();
if ("5".equals(deviceType)){
deviceEntityV21 = BeanUtil.toBean(RedisUtils.getBucket("deviceInfo:" + deviceType+":"+deviceCode), RemoteDeviceVo.class) ;
if (null == deviceEntityV21){
deviceEntityV21 = BeanUtil.toBean(RedisUtils.getBucket("deviceInfo:8" +":"+deviceCode), RemoteDeviceVo.class) ;
if (null == deviceEntityV21){
deviceEntityV21 = BeanUtil.toBean(RedisUtils.getBucket("deviceInfo:7" +":"+deviceCode), RemoteDeviceVo.class) ;
}
}
}else {
deviceEntityV21 = BeanUtil.toBean(RedisUtils.getBucket("deviceInfo:" + deviceType+":"+deviceCode), RemoteDeviceVo.class) ;
}
if(Objects.isNull(deviceEntityV21)){
logger.error("库里没有这个数据,deviceCode={}",deviceCode);
return null;
@ -435,11 +443,10 @@ public class GpsServiceImpl implements IGpsService {
//如果定位是0的话 ,则上传最后一次有定位的坐标如果最后一次是0的话那就上传0
boolean nonLatLng = isNonLatLng(lat, lng);
if(nonLatLng){
Object o = RedisUtils.getBucket(RedisConstants.ONLINE_USERS + deviceType + ":" + deviceCode);
JSONObject o = RedisUtils.getBucket(RedisConstants.ONLINE_USERS + deviceType + ":" + deviceCode);
if(!Objects.isNull(o)) {
com.alibaba.fastjson.JSONObject o1 = (JSONObject) o;
String json = o1.toJSONString();
EsGpsInfoVO2 esGpsInfoVO3 = JSON.parseObject(json, EsGpsInfoVO2.class);
EsGpsInfoVO2 esGpsInfoVO3 = JSONUtil.toBean(o, EsGpsInfoVO2.class);
String lat1 = esGpsInfoVO3.getLat();
String lng1 = esGpsInfoVO3.getLng();
esGpsInfoVO2.setLat(lat1);

View File

@ -15,6 +15,7 @@ import org.dromara.extract.util.PathUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
@ -39,8 +40,8 @@ public class DeviceGPSController {
RemoteDataToEsService dataToEsService;
private String lastUpdateTime = "2024-06-05 11:40:00";
@Value("${ruansi.last_update_time}")
private String lastUpdateTime;
@RequestMapping("/maxId")
public String getMaxId(){
@ -55,7 +56,7 @@ public class DeviceGPSController {
return DateUtil.formatDateTime(info.getGpsTime());
}
@Scheduled(cron = "0/30 * * * * ?")
@Scheduled(cron = "0/10 * * * * ?")
@Async
public void bdgcGps(){
if(StringUtils.isBlank(lastUpdateTime)){
@ -70,11 +71,13 @@ public class DeviceGPSController {
gpsInfo.setGpsTime(DateUtil.parseDateTime(lastUpdateTime));
Instant start = Instant.now();
// some code
logger.info("进入公车定时任务");
List<EsGpsInfo> list = deviceGpsService.selectBDGCGPS(gpsInfo);
logger.info("查询结束");
Instant finish = Instant.now();
long timeElapsed = Duration.between(start, finish).toMillis();
logger.info("查询耗时:"+timeElapsed);
logger.info("数据大小size"+list.size());
logger.info("公车查询耗时:"+timeElapsed);
logger.info("公车数据大小size"+list.size());
Date nowDate = new Date();
for (int i = 0; i < list.size(); i++) {
@ -83,7 +86,7 @@ public class DeviceGPSController {
lastUpdateTime = DateUtil.formatDateTime(info.getGpsTime());
// resetUpdateTime(info.getId()+"");
}
if (DateUtil.between(nowDate,info.getGpsTime(),DateUnit.MINUTE) > 30){
if (DateUtil.between(new Date(),info.getGpsTime(),DateUnit.MINUTE) > 10){
info.setOnline("0");
}else {
info.setOnline("1");
@ -93,9 +96,7 @@ public class DeviceGPSController {
}
ArrayList<EsGpsInfo> collect = list.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() ->
new TreeSet<>(Comparator.comparing(EsGpsInfo::getDeviceCode))), ArrayList::new));
logger.info("去重前size={},去重后size={}",list.size(),collect.size());
// List<RemoteGpsInfo> remoteGpsInfos = new ArrayList<>();
// remoteGpsInfos.add()
logger.info("公车去重前size={},公车去重后size={}",list.size(),collect.size());
dataToEsService.saveDataBatch(BeanUtil.copyToList(collect,RemoteGpsInfo.class));
Instant end = Instant.now();
long timeEnd = Duration.between(finish, end).toMillis();
@ -104,6 +105,7 @@ public class DeviceGPSController {
}
private void resetUpdateTime(String lastUpdateTime) {
try {
// lastUpdateTime = DateUtil.format(gpsTime,"yyyy-MM-dd HH:mm:ss");

View File

@ -41,7 +41,7 @@
<where>
<if test="gpsTime != null "> and time > #{gpsTime}</if>
</where>
) a group by deviceCode
) a group by deviceCode
order by gpsTime desc limit 100
</select>
@ -50,6 +50,20 @@
order by time desc limit 1
</select>
<select id="selectJlyGPS" parameterType="org.dromara.extract.domain.EsGpsInfo" resultMap="DeviceResult">
select zdbh deviceCode,'5' deviceType, longitude lng, latitude lat,gpstime gpsTime,speed from bas_police_gps
<where>
<if test="gpsTime != null "> and gpstime >= #{gpsTime}</if>
</where>
order by gpstime desc
</select>
<select id="selectJlyStatus" parameterType="org.dromara.extract.domain.EsGpsInfo" resultMap="DeviceResult">
select zdbh deviceCode,'5' deviceType,ifnull(zt,0) is_online,ztgxsj gpsTime from bas_device
<where>
<if test="gpsTime != null "> and ztgxsj >= #{gpsTime}</if>
</where>
order by ztgxsj desc
</select>
</mapper>

View File

@ -185,6 +185,9 @@ public class SearchServiceImpl implements ISearchService {
List<RemoteDictDataVo> list = dictService.selectDictDataByType("zd_device_type");
List<String> maps = new ArrayList<>();
for (RemoteDictDataVo dataVo : list) {
if (null != dataVo.getRemark() && dataVo.getRemark().contains("无短信")){
continue;
}
try {
BoolQueryBuilder boolBuilder = QueryBuilders.boolQuery();
// 匹配第二个

View File

@ -0,0 +1,24 @@
package org.dromara.system.config;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
@Data
@Configuration
@RefreshScope
@ConfigurationProperties(prefix = "ywry")
public class YwryProperties {
private String phone1;
//运维人员2手机号
private String phone2;
private Boolean isSend; // 自动匹配 is_send/is-send/isSend
}

View File

@ -9,7 +9,9 @@ import org.dromara.common.core.domain.R;
import org.dromara.common.redis.utils.RedisUtils;
import org.dromara.common.web.core.BaseController;
import org.dromara.location.api.RemoteElasticSearchService;
import org.dromara.system.config.YwryProperties;
import org.dromara.system.domain.DeviceRedis;
import org.dromara.system.domain.SysMessageMas;
import org.dromara.system.domain.SysNotice;
import org.dromara.system.domain.bo.SysDeptBo;
import org.dromara.system.domain.bo.SysNoticeBo;
@ -17,6 +19,7 @@ import org.dromara.system.domain.bo.TDeviceBo;
import org.dromara.system.domain.vo.*;
import org.dromara.system.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.*;
@ -36,6 +39,10 @@ public class IndexStaticsController extends BaseController {
private final ISysNoticeService noticeService;
private final ISysMessageMasService masService;
private final YwryProperties ywryProperties;
@DubboReference
RemoteElasticSearchService elasticSearchService;
@ -93,19 +100,30 @@ public class IndexStaticsController extends BaseController {
@Scheduled(cron = "0 */30 * * * ?")
public void listen(){
List<String> strs = elasticSearchService.linstenDataStatus();
if (strs.size() >0){
List<SysNoticeVo> nlist = noticeService.selectTodayNoticeList();
if (nlist.size() <=2){
// -- todo 发送短信
SysNoticeBo noticeBo = new SysNoticeBo();
noticeBo.setNoticeTitle("手机号码");
if (ywryProperties.getIsSend()){
if (strs.size() >0){
List<SysNoticeVo> nlist = noticeService.selectTodayNoticeList();
if (nlist.size() <=2){
// -- todo 发送短信
SysNoticeBo noticeBo = new SysNoticeBo();
noticeBo.setNoticeTitle(ywryProperties.getPhone1());
noticeBo.setNoticeType("3");
noticeBo.setNoticeContent(strs.toString()+"数据不正常,请检查服务是否正常");
noticeBo.setCreateTime(DateUtil.date());
noticeService.insertNotice(noticeBo);
noticeBo.setNoticeTitle(ywryProperties.getPhone2());
noticeService.insertNotice(noticeBo);
SysMessageMas mas = new SysMessageMas();
mas.setContent(strs.toString()+"数据不正常,请检查服务是否正常");
mas.setMobiles(ywryProperties.getPhone1());
mas.setAddserial("1234");
masService.insertMessage(mas);
mas.setMobiles(ywryProperties.getPhone2());
masService.insertMessage(mas);
}
noticeBo.setNoticeType("3");
noticeBo.setNoticeContent(strs.toString()+"数据不正常,请检查服务是否正常");
noticeBo.setCreateTime(DateUtil.date());
noticeService.insertNotice(noticeBo);
}
}
}

View File

@ -0,0 +1,20 @@
package org.dromara.system.domain;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
/*
*
* */
@Data
@TableName("sys_message_mas")
public class SysMessageMas {
private String content;
private String mobiles;
private String status;
private String addserial;
}

View File

@ -0,0 +1,19 @@
package org.dromara.system.domain;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
@Data
@TableName("sys_dept_jly")
public class SysdeptJly {
private String qymc;
private String fqylj;
private String qyCode;
private String deptId;
private String deptName;
}

View File

@ -0,0 +1,28 @@
package org.dromara.system.domain.bo;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;
import org.dromara.system.domain.SysDept;
import java.io.Serial;
import java.io.Serializable;
@Data
@ExcelIgnoreUnannotated
@AutoMapper(target = SysDept.class, reverseConvertGenerate = false)
public class SysdeptJlyBo implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
private String qymc;
private String fqylj;
private String qyCode;
private String deptId;
private String deptName;
}

View File

@ -0,0 +1,30 @@
package org.dromara.system.domain.vo;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.baomidou.mybatisplus.annotation.TableName;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;
import org.dromara.system.domain.SysDept;
import org.dromara.system.domain.SysdeptJly;
import java.io.Serial;
import java.io.Serializable;
@Data
@ExcelIgnoreUnannotated
@AutoMapper(target = SysdeptJly.class)
public class SysdeptJlyVo implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
private String qymc;
private String fqylj;
private String qyCode;
private String deptId;
private String deptName;
}

View File

@ -0,0 +1,9 @@
package org.dromara.system.mapper;
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
import org.dromara.system.domain.SysdeptJly;
import org.dromara.system.domain.vo.SysdeptJlyVo;
public interface SysDeptJlyMapper extends BaseMapperPlus<SysdeptJly, SysdeptJlyVo> {
}

View File

@ -0,0 +1,8 @@
package org.dromara.system.mapper;
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
import org.dromara.system.domain.SysMessageMas;
public interface SysMessageMasMapper extends BaseMapperPlus<SysMessageMas,SysMessageMas> {
}

View File

@ -38,4 +38,6 @@ public interface TDeviceMapper extends BaseMapperPlus<TDevice, TDeviceVo> {
int updateBatch(HashMap<String,Object> map);
int insertOrUpdateByCodeAndType(TDevice device);
}

View File

@ -0,0 +1,8 @@
package org.dromara.system.service;
import org.dromara.system.domain.SysMessageMas;
public interface ISysMessageMasService {
int insertMessage(SysMessageMas mas);
}

View File

@ -0,0 +1,21 @@
package org.dromara.system.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import lombok.RequiredArgsConstructor;
import org.dromara.system.domain.SysMessageMas;
import org.dromara.system.mapper.SysMessageMasMapper;
import org.dromara.system.service.ISysMessageMasService;
import org.springframework.stereotype.Service;
@RequiredArgsConstructor
@Service
@DS("slave")
public class SysMessageMasServiceImpl implements ISysMessageMasService {
private final SysMessageMasMapper baseMapper;
@Override
public int insertMessage(SysMessageMas mas) {
return baseMapper.insert(mas);
}
}

View File

@ -15,8 +15,11 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import org.dromara.system.api.RemoteDataScopeService;
import org.dromara.system.domain.SysdeptJly;
import org.dromara.system.domain.vo.DeviceStaticsVo;
import org.dromara.system.domain.vo.SysdeptJlyVo;
import org.dromara.system.domain.vo.TDeviceExportVo;
import org.dromara.system.mapper.SysDeptJlyMapper;
import org.springframework.stereotype.Service;
import org.dromara.system.domain.bo.TDeviceBo;
import org.dromara.system.domain.vo.TDeviceVo;
@ -42,6 +45,8 @@ public class TDeviceServiceImpl implements ITDeviceService {
private final TDeviceMapper baseMapper;
private final SysDeptJlyMapper deptJlyMapper;
@DubboReference
private RemoteDataScopeService remoteDataScopeService;
@ -231,18 +236,29 @@ public class TDeviceServiceImpl implements ITDeviceService {
public Boolean batchSaveOrUpdate(List<TDevice> list) {
boolean flag = true;
// 先根据 field1 和 field2 查询出已存在的记录
List<TDevice> existingEntities = baseMapper.selectList(new QueryWrapper<TDevice>()
/*List<TDevice> existingEntities = baseMapper.selectList(new QueryWrapper<TDevice>()
.in("device_code", list.stream().map(TDevice::getDeviceCode).collect(Collectors.toList()))
.in("device_type", list.stream().map(TDevice::getDeviceType).collect(Collectors.toList())));
*/
// 找到需要更新的记录
List<TDevice> toUpdate = new ArrayList<>();
// 找到需要插入的记录
List<TDevice> toInsert = new ArrayList<>();
LambdaQueryWrapper<SysdeptJly> lqw = new LambdaQueryWrapper<>();
for (TDevice entity : list) {
boolean exists = false;
for (TDevice existingEntity : existingEntities) {
// boolean exists = false;
if (entity.getDeviceType().equals("5") || entity.getDeviceType().equals("8")
|| entity.getDeviceType().equals("7")){ // 记录仪、5G车载、布控球 处理机构
lqw.eq(SysdeptJly::getQyCode,entity.getZzjgdm());
SysdeptJlyVo jlyVo = deptJlyMapper.selectVoOne(lqw);
if (null != jlyVo){
entity.setZzjgdm(jlyVo.getDeptId());
entity.setZzjgmc(jlyVo.getDeptName());
}
baseMapper.insertOrUpdateByCodeAndType(entity);
}
/*for (TDevice existingEntity : existingEntities) {
if (entity.getDeviceCode().equals(existingEntity.getDeviceCode()) && entity.getDeviceType().equals(existingEntity.getDeviceType())) {
entity.setId(existingEntity.getId()); // 设置 ID 以便更新
toUpdate.add(entity);
@ -252,18 +268,18 @@ public class TDeviceServiceImpl implements ITDeviceService {
}
if (!exists) {
toInsert.add(entity);
}
}*/
}
// 批量更新
if (!toUpdate.isEmpty()) {
/*if (!toUpdate.isEmpty()) {
flag = baseMapper.updateBatchById(toUpdate);
}
// 批量插入
if (!toInsert.isEmpty()) {
flag = baseMapper.insertBatch(toInsert); // insertBatchSomeColumn 是 MyBatis-Plus 提供的批量插入方法
}
}*/
return flag;
// return baseMapper.insertOrUpdateBatch(List);
}

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.dromara.system.mapper.SysDeptJlyMapper">
<resultMap type="org.dromara.system.domain.vo.SysdeptJlyVo" id="SysDeptJlyResult">
</resultMap>
</mapper>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.dromara.system.mapper.SysMessageMasMapper">
<resultMap type="org.dromara.system.domain.SysMessageMas" id="SysMessageMasResult">
</resultMap>
</mapper>

View File

@ -42,4 +42,15 @@
</foreach>
</update>
<insert id="insertOrUpdateByCodeAndType">
insert into t_device (device_code, device_type, zzjgdm, zzjgmc, police_no, police_name, phone_num, car_num, valid,
remark1, remark2, card_num, create_time, update_time)
values (#{deviceCode},#{deviceType},#{zzjgdm},#{zzjgmc},#{policeNo},#{policeName},#{phoneNum},#{carNum},#{valid},
#{remark1},#{remark2},#{cardNum},#{createTime},#{updateTime})
ON DUPLICATE KEY UPDATE
zzjgdm = values(zzjgdm),zzjgmc = values(zzjgmc),police_no = values(police_no),police_name = values(police_name),phone_num = values(phone_num),
car_num = values(car_num),valid = values(valid),remark1 = values(remark1),remark2 = values(remark2),card_num = values(card_num),
update_time = now()
</insert>
</mapper>

View File

@ -9,10 +9,10 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>wzhj-webscoket</artifactId>
<artifactId>wzhj-websocket</artifactId>
<description>
wzhj-webscoket记录仪数据接收
wzhj-websocket记录仪数据接收
</description>
<dependencies>

View File

@ -49,7 +49,7 @@ public class DeviceSchedule {
RemoteDeviceService deviceService;
@Scheduled( cron = "0 */3 * * * ?")
@Scheduled( cron = "0 */10 * * * ?")
public void deviceTrans(){
if(StringUtils.isBlank(lastUpdateTime)){
lastUpdateTime = startUpdateTime;
@ -85,7 +85,8 @@ public class DeviceSchedule {
Timestamp updateTime = originDevice.getUpdateTime();
// DateTime dateTime = DateUtil.offsetHour(updateTime, 13);
newDevice.setUpdateTime(DateUtil.formatDateTime(updateTime) );
setZzjgdm(newDevice,originDevice);
newDevice.setZzjgdm(originDevice.getParentId());
// setZzjgdm(newDevice,originDevice);
}
if(StringUtils.isBlank(newDevice.getZzjgdm())){

View File

@ -1,28 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<!-- 日志存放路径 -->
<property name="log.path" value="logs/${project.artifactId}" />
<!-- 日志输出格式 -->
<property name="console.log.pattern"
value="%red(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta(%logger{36}%n) - %msg%n"/>
<!-- 控制台输出 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<property name="log.path" value="logs" />
<property name="log.file" value="monitor" />
<property name="MAX_FILE_SIZE" value="30MB" />
<property name="MAX_HISTORY" value="30" />
<!-- 日志输出格式 -->
<!-- INFO日志Appender -->
<appender name="FILE_INFO" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/info.${log.file}.log</file>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>INFO</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${log.path}/info/info.${log.file}.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<maxFileSize>${MAX_FILE_SIZE}</maxFileSize>
<maxHistory>${MAX_HISTORY}</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${console.log.pattern}</pattern>
<charset>utf-8</charset>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<include resource="logback-common.xml" />
<!-- ERROR日志Appender -->
<appender name="FILE_ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/error.${log.file}.log</file>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>ERROR</level>
</filter>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${log.path}/error/error.${log.file}.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<maxFileSize>${MAX_FILE_SIZE}</maxFileSize>
<maxHistory>${MAX_HISTORY}</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<include resource="logback-logstash.xml" />
<!-- 开启 skywalking 日志收集 -->
<include resource="logback-skylog.xml" />
<!--系统操作日志-->
<root level="info">
<appender-ref ref="console" />
<!-- 根Logger配置禁用控制台输出 -->
<root level="INFO">
<appender-ref ref="FILE_INFO" />
<appender-ref ref="FILE_ERROR" />
</root>
</configuration>

View File

@ -40,9 +40,10 @@ spring.sql.init.platform=mysql
db.num=1
### Connect URL of DB:
db.url.0=jdbc:mysql://127.0.0.1:3306/ry-config?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true
#db.url.0=jdbc:mysql://127.0.0.1:3306/ry-config?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true
db.url.0=jdbc:mysql://53.238.79.3:3306/wzhj-config?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true
db.user.0=root
db.password.0=root
db.password.0=ycgis
### the maximum retry times for push
nacos.config.push.maxRetryTime=50

View File

@ -1,114 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<!-- 日志存放路径 -->
<property name="log.path" value="logs/${project.artifactId}"/>
<property name="log.path" value="logs" />
<property name="log.file" value="gateway" />
<property name="MAX_FILE_SIZE" value="10MB" />
<property name="MAX_HISTORY" value="30" />
<!-- 日志输出格式 -->
<property name="console.log.pattern"
value="%red(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta(%logger{36}%n) - %msg%n"/>
<property name="log.pattern" value="%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n"/>
<!-- 控制台输出 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<!-- INFO日志Appender -->
<appender name="FILE_INFO" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/info.${log.file}.log</file>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>INFO</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${log.path}/info/info.${log.file}.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<maxFileSize>${MAX_FILE_SIZE}</maxFileSize>
<maxHistory>${MAX_HISTORY}</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${console.log.pattern}</pattern>
<charset>utf-8</charset>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<!-- 控制台输出 -->
<appender name="file_console" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/console.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/console.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大 1天 -->
<maxHistory>1</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
<charset>utf-8</charset>
</encoder>
<!-- ERROR日志Appender -->
<appender name="FILE_ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/error.${log.file}.log</file>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<!-- 过滤的级别 -->
<level>INFO</level>
</filter>
</appender>
<!-- 系统日志输出 -->
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/info.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>INFO</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/error.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>ERROR</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${log.path}/error/error.${log.file}.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<maxFileSize>${MAX_FILE_SIZE}</maxFileSize>
<maxHistory>${MAX_HISTORY}</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<!-- info异步输出 -->
<appender name="async_info" class="ch.qos.logback.classic.AsyncAppender">
<!-- 不丢失日志.默认的,如果队列的80%已满,则会丢弃TRACT、DEBUG、INFO级别的日志 -->
<discardingThreshold>0</discardingThreshold>
<!-- 更改默认的队列的深度,该值会影响性能.默认值为256 -->
<queueSize>512</queueSize>
<!-- 添加附加的appender,最多只能添加一个 -->
<appender-ref ref="file_info"/>
</appender>
<!-- error异步输出 -->
<appender name="async_error" class="ch.qos.logback.classic.AsyncAppender">
<!-- 不丢失日志.默认的,如果队列的80%已满,则会丢弃TRACT、DEBUG、INFO级别的日志 -->
<discardingThreshold>0</discardingThreshold>
<!-- 更改默认的队列的深度,该值会影响性能.默认值为256 -->
<queueSize>512</queueSize>
<!-- 添加附加的appender,最多只能添加一个 -->
<appender-ref ref="file_error"/>
</appender>
<include resource="logback-logstash.xml" />
<!-- 开启 skywalking 日志收集 -->
<include resource="logback-skylog.xml" />
<!--系统操作日志-->
<root level="info">
<appender-ref ref="console"/>
<appender-ref ref="async_info"/>
<appender-ref ref="async_error"/>
<appender-ref ref="file_console"/>
<!-- 根Logger配置禁用控制台输出 -->
<root level="INFO">
<appender-ref ref="FILE_INFO" />
<appender-ref ref="FILE_ERROR" />
</root>
</configuration>