宣城汇聚0703改动
parent
69900614a5
commit
9b87b40361
|
|
@ -37,6 +37,7 @@ public class RemoteGpsInfo implements Serializable {
|
|||
private String policeNo;
|
||||
private String policeName;
|
||||
private String phoneNum;
|
||||
private String deviceName;
|
||||
private String carNum;
|
||||
|
||||
private Integer online;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
package org.dromara.data2es.config;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.annotation.SchedulingConfigurer;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
||||
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
|
||||
|
||||
@Configuration
|
||||
public class SchedulerConfig implements SchedulingConfigurer {
|
||||
|
||||
@Override
|
||||
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
|
||||
ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
|
||||
taskScheduler.setPoolSize(5); // 设置线程池大小
|
||||
taskScheduler.setThreadNamePrefix("scheduled-task-");
|
||||
taskScheduler.setErrorHandler(throwable -> {
|
||||
// 统一处理未捕获异常
|
||||
System.err.println("定时任务异常: " + throwable.getMessage());
|
||||
});
|
||||
taskScheduler.initialize();
|
||||
taskRegistrar.setTaskScheduler(taskScheduler);
|
||||
}
|
||||
}
|
||||
|
|
@ -18,4 +18,5 @@ public class EsGpsInfoVO2 extends EsGpsInfo {
|
|||
private String policeName;
|
||||
private String phoneNum;
|
||||
private String carNum;
|
||||
private String deviceName;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,4 +16,6 @@ public interface DeviceGpsMapper {
|
|||
|
||||
EsGpsInfo selectBDGCMaxTime();
|
||||
|
||||
List<EsGpsInfo> selectDjjGPS(EsGpsInfo esGpsInfo);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,55 @@
|
|||
package org.dromara.extract.schedule;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.date.DateUnit;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.dromara.data2es.api.RemoteDataToEsService;
|
||||
import org.dromara.data2es.api.domain.RemoteGpsInfo;
|
||||
import org.dromara.extract.domain.EsGpsInfo;
|
||||
import org.dromara.extract.service.ITDeviceGpsService;
|
||||
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 java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/*
|
||||
* 4G对讲机定位抽取
|
||||
* */
|
||||
@Configuration
|
||||
@Slf4j
|
||||
public class DjjSchedule {
|
||||
|
||||
@Value("${ruansi.djj_extract_time}")
|
||||
private String djjExtractTime;
|
||||
|
||||
@Autowired
|
||||
ITDeviceGpsService gpsService;
|
||||
|
||||
@DubboReference
|
||||
RemoteDataToEsService dataToEsService;
|
||||
|
||||
|
||||
@Scheduled(cron = "0/10 * * * * ?")
|
||||
public void djjExtract(){
|
||||
EsGpsInfo gpsInfo = new EsGpsInfo();
|
||||
gpsInfo.setGpsTime(DateUtil.parseDateTime(djjExtractTime));
|
||||
List<EsGpsInfo> list = gpsService.selectDjjGPS(gpsInfo);
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
EsGpsInfo info = list.get(i);
|
||||
if(i == 0){
|
||||
djjExtractTime = DateUtil.formatDateTime(info.getGpsTime());
|
||||
}
|
||||
if (DateUtil.between(new Date(),info.getGpsTime(), DateUnit.MINUTE) > 10){
|
||||
info.setOnline("0");
|
||||
}else {
|
||||
info.setOnline("1");
|
||||
}
|
||||
}
|
||||
dataToEsService.saveDataBatch(BeanUtil.copyToList(list, RemoteGpsInfo.class));
|
||||
}
|
||||
}
|
||||
|
|
@ -12,4 +12,6 @@ public interface ITDeviceGpsService {
|
|||
|
||||
EsGpsInfo selectBDGCMaxTime();
|
||||
|
||||
List<EsGpsInfo> selectDjjGPS(EsGpsInfo esGpsInfo);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package org.dromara.extract.service.impl;
|
|||
|
||||
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import org.dromara.extract.domain.EsGpsInfo;
|
||||
import org.dromara.extract.mapper.DeviceGpsMapper;
|
||||
import org.dromara.extract.service.ITDeviceGpsService;
|
||||
|
|
@ -26,4 +27,10 @@ public class TDeviceGpsServiceImpl implements ITDeviceGpsService {
|
|||
public EsGpsInfo selectBDGCMaxTime() {
|
||||
return deviceMapper.selectBDGCMaxTime();
|
||||
}
|
||||
|
||||
@Override
|
||||
@DS("slave")
|
||||
public List<EsGpsInfo> selectDjjGPS(EsGpsInfo esGpsInfo) {
|
||||
return deviceMapper.selectDjjGPS(esGpsInfo);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,4 +66,13 @@
|
|||
order by ztgxsj desc
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectDjjGPS" parameterType="org.dromara.extract.domain.EsGpsInfo" resultMap="DeviceResult">
|
||||
select id deviceCode,'1' deviceType, lng, lat,time gpsTime from t_tyqx_zd
|
||||
<where>
|
||||
<if test="gpsTime != null "> and time >= #{gpsTime}</if>
|
||||
</where>
|
||||
order by time desc
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
package org.dromara.system.config;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.annotation.SchedulingConfigurer;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
||||
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
|
||||
|
||||
@Configuration
|
||||
public class SchedulerConfig implements SchedulingConfigurer {
|
||||
|
||||
@Override
|
||||
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
|
||||
ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
|
||||
taskScheduler.setPoolSize(5); // 设置线程池大小
|
||||
taskScheduler.setThreadNamePrefix("scheduled-task-");
|
||||
taskScheduler.setErrorHandler(throwable -> {
|
||||
// 统一处理未捕获异常
|
||||
System.err.println("定时任务异常: " + throwable.getMessage());
|
||||
});
|
||||
taskScheduler.initialize();
|
||||
taskRegistrar.setTaskScheduler(taskScheduler);
|
||||
}
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@ package org.dromara.system.controller.system;
|
|||
import cn.hutool.core.date.DateUtil;
|
||||
import jdk.dynalink.linker.LinkerServices;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.redis.utils.RedisUtils;
|
||||
|
|
@ -27,6 +28,7 @@ import java.util.*;
|
|||
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@Slf4j
|
||||
public class IndexStaticsController extends BaseController {
|
||||
|
||||
private final ISysDeptService deptService;
|
||||
|
|
@ -131,32 +133,27 @@ public class IndexStaticsController extends BaseController {
|
|||
* 各地市总数和在线数
|
||||
* */
|
||||
@PostMapping("/onLineBar")
|
||||
public R onLineBar(){
|
||||
List<SysDeptVo> deptVoList = deptService.getDsList();
|
||||
List<DeviceStaticsVo> staticsVoList = deviceService.countByDs();
|
||||
public R onLineBar(@RequestBody TDeviceBo bo){
|
||||
SysDeptBo deptBo = new SysDeptBo();
|
||||
deptBo.setIsVisible("1");
|
||||
deptBo.setParentId(bo.getZzjgdm());
|
||||
List<SysDeptVo> deptVoList = deptService.selectDeptList(deptBo);
|
||||
log.error("单位集合={}",deptVoList.toString());
|
||||
List<DeviceStaticsVo> list = new ArrayList<>(); //用来接收处理后的统计结果
|
||||
for (SysDeptVo deptVo : deptVoList) {
|
||||
boolean bl = false; //用来统计结果是否有当前这个机构
|
||||
for (DeviceStaticsVo staticsVo : staticsVoList) {
|
||||
String deptId = staticsVo.getZzjgdm()+"00000000";
|
||||
if (deptId.equals(deptVo.getDeptId())){
|
||||
staticsVo.setZzjgdm(deptId);
|
||||
staticsVo.setZzjgmc(deptVo.getDeptName().replaceAll("公安局",""));
|
||||
int onlineCo = RedisUtils.searchKeys("org_code:"+staticsVo.getZzjgdm()+"*");
|
||||
staticsVo.setOnlineCo(onlineCo);
|
||||
list.add(staticsVo);
|
||||
bl = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!bl){
|
||||
DeviceStaticsVo staticsVo = new DeviceStaticsVo();
|
||||
staticsVo.setZzjgdm(deptVo.getDeptId());
|
||||
staticsVo.setZzjgmc(deptVo.getDeptName().replaceAll("公安局",""));
|
||||
staticsVo.setCo(0);
|
||||
staticsVo.setOnlineCo(0);
|
||||
list.add(staticsVo);
|
||||
}
|
||||
DeviceStaticsVo staticsVo = new DeviceStaticsVo();
|
||||
TDeviceBo deviceBo = new TDeviceBo();
|
||||
deviceBo.setZzjgdm(deptVo.getDeptId());
|
||||
deviceBo.setValid(1);
|
||||
DeviceRedis redis = new DeviceRedis();
|
||||
redis.setZzjgdm(deptVo.getDeptId());
|
||||
Long co = deviceService.countByCondition(deviceBo);
|
||||
Long online = redisService.countByZzjgdm(redis);
|
||||
staticsVo.setZzjgdm(deptVo.getDeptId());
|
||||
staticsVo.setZzjgmc(deptVo.getShortName());
|
||||
staticsVo.setCo(co);
|
||||
staticsVo.setOnlineCo(online);
|
||||
list.add(staticsVo);
|
||||
}
|
||||
return R.ok(list);
|
||||
}
|
||||
|
|
@ -229,7 +226,7 @@ public class IndexStaticsController extends BaseController {
|
|||
* 终端种类占比
|
||||
* */
|
||||
@PostMapping("/deviceTypePen")
|
||||
public R deviceTypePen(TDeviceBo deviceInfo){
|
||||
public R deviceTypePen(@RequestBody TDeviceBo deviceInfo){
|
||||
List<SysDictDataVo> dataList = dictTypeService.selectDictDataByType("zd_device_type");
|
||||
List<HashMap> list = new ArrayList<>();
|
||||
for (SysDictDataVo data : dataList) {
|
||||
|
|
@ -247,7 +244,7 @@ public class IndexStaticsController extends BaseController {
|
|||
*终端单位分布
|
||||
* */
|
||||
@PostMapping("/deviceBar")
|
||||
public R deviceBar(TDeviceBo deviceInfo){
|
||||
public R deviceBar(@RequestBody TDeviceBo deviceInfo){
|
||||
|
||||
SysDeptBo dept = new SysDeptBo();
|
||||
dept.setParentId(deviceInfo.getZzjgdm());
|
||||
|
|
|
|||
|
|
@ -70,6 +70,8 @@ public class TDevice {
|
|||
|
||||
private String cardNum;
|
||||
|
||||
private String deviceName;
|
||||
|
||||
/**
|
||||
* 0无效,1有效
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -77,6 +77,8 @@ public class TDeviceBo extends BaseEntity {
|
|||
|
||||
private String cardNum;
|
||||
|
||||
private String deviceName;
|
||||
|
||||
/**
|
||||
* 0无效,1有效
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ public class DeviceStaticsVo implements Serializable {
|
|||
|
||||
private String zzjgdm;
|
||||
|
||||
private Integer co;
|
||||
private Long co;
|
||||
|
||||
private Integer onlineCo;
|
||||
private Long onlineCo;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,6 +41,8 @@ public class TDeviceVo implements Serializable {
|
|||
private String deviceCode;
|
||||
|
||||
// 警号、姓名、车牌号组合字段
|
||||
|
||||
@ExcelProperty(value = "设备名称")
|
||||
private String deviceName;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
package org.dromara.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
import org.dromara.system.domain.DeviceRedis;
|
||||
import org.dromara.system.domain.vo.DeviceRedisVo;
|
||||
|
|
@ -11,4 +14,6 @@ public interface DeviceRedisMapper extends BaseMapperPlus<DeviceRedis,DeviceRedi
|
|||
int insertBatch(List<DeviceRedis> list);
|
||||
|
||||
List<DeviceRedisVo> countByCondition(DeviceRedis redis);
|
||||
|
||||
Long countByzzjgdm(@Param(Constants.WRAPPER) Wrapper<DeviceRedis> queryWrapper);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ public class DeviceRedisSchedule {
|
|||
/*
|
||||
* 把Redis中 online_user数据存入t_device_redis表中
|
||||
* */
|
||||
// @Scheduled(cron = "0/30 * * * * ?")
|
||||
@Scheduled(cron = "0/30 * * * * ?")
|
||||
public void handleDeviceRedis(){
|
||||
List<JSONObject> jlist = RedisUtils.searchAndGetKeysValues("online_users:*");
|
||||
redisService.insertBatch(BeanUtil.copyToList(jlist, DeviceRedis.class));
|
||||
|
|
@ -69,4 +69,21 @@ public class DeviceRedisSchedule {
|
|||
RedisUtils.batchInsert(deviceInfoDataMap,-1);
|
||||
}
|
||||
|
||||
/*
|
||||
* 定时处理记录仪基本数据 10天没有更新的设备设置为删除状态
|
||||
* */
|
||||
@Scheduled(cron = "0 0 0/1 * * ?")
|
||||
public void deleteZfjly(){
|
||||
deviceService.deleteZfjly();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 定时删除设备状态为删除的定位信息和在线表
|
||||
* */
|
||||
@Scheduled(cron = "0 0 0/1 * * ?")
|
||||
public void removeRedis(){
|
||||
deviceService.deleteRedis();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,4 +9,6 @@ public interface IDeviceRedisService {
|
|||
int insertBatch(List<DeviceRedis> list);
|
||||
|
||||
List<DeviceRedisVo> countByCondition(DeviceRedis redis);
|
||||
|
||||
Long countByZzjgdm(DeviceRedis deviceRedis);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,4 +85,8 @@ public interface ITDeviceService {
|
|||
TDeviceVo queryByDeviceCode(String deviceCode);
|
||||
|
||||
List<TDeviceExportVo> selectDeviceExportList(TDeviceBo bo);
|
||||
|
||||
int deleteZfjly();
|
||||
|
||||
int deleteRedis();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,20 @@
|
|||
package org.dromara.system.service.impl;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.apache.ibatis.session.ExecutorType;
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.dromara.system.api.RemoteDataScopeService;
|
||||
import org.dromara.system.domain.DeviceRedis;
|
||||
import org.dromara.system.domain.TDevice;
|
||||
import org.dromara.system.domain.vo.DeviceRedisVo;
|
||||
import org.dromara.system.mapper.DeviceRedisMapper;
|
||||
import org.dromara.system.service.IDeviceRedisService;
|
||||
import org.dromara.system.service.ISysDeptService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
|
@ -23,6 +28,9 @@ public class DeviceRedisServiceImpl implements IDeviceRedisService {
|
|||
|
||||
private final DeviceRedisMapper baseMapper;
|
||||
|
||||
@DubboReference
|
||||
private RemoteDataScopeService remoteDataScopeService;
|
||||
|
||||
@Autowired
|
||||
SqlSessionFactory sqlSessionFactory;
|
||||
|
||||
|
|
@ -61,4 +69,13 @@ public class DeviceRedisServiceImpl implements IDeviceRedisService {
|
|||
public List<DeviceRedisVo> countByCondition(DeviceRedis redis) {
|
||||
return baseMapper.countByCondition(redis);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countByZzjgdm(DeviceRedis deviceRedis) {
|
||||
LambdaQueryWrapper<DeviceRedis> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.ne(DeviceRedis::getDeviceType,"9");
|
||||
String depts = remoteDataScopeService.getDeptAndChild(deviceRedis.getZzjgdm());
|
||||
lqw.inSql(DeviceRedis::getZzjgdm,depts);
|
||||
return baseMapper.countByzzjgdm(lqw);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,6 +83,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
|||
lqw.like(StringUtils.isNotBlank(bo.getDeptName()), SysDept::getDeptName, bo.getDeptName());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getStatus()), SysDept::getStatus, bo.getStatus());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getFullName()), SysDept::getFullName, bo.getFullName());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getIsVisible()),SysDept::getIsVisible,bo.getIsVisible());
|
||||
lqw.orderByAsc(SysDept::getAncestors);
|
||||
lqw.orderByAsc(SysDept::getParentId);
|
||||
lqw.orderByAsc(SysDept::getOrderNum);
|
||||
|
|
@ -104,7 +105,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
|||
return TreeBuildUtils.build(depts, (dept, tree) ->
|
||||
tree.setId(dept.getDeptId())
|
||||
.setParentId(dept.getParentId())
|
||||
.setName(dept.getDeptName())
|
||||
.setName(dept.getShortName())
|
||||
.setWeight(dept.getOrderNum()));
|
||||
}
|
||||
|
||||
|
|
@ -289,6 +290,10 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
|||
// 如果该部门是启用状态,则启用该部门的所有上级部门
|
||||
updateParentDeptStatusNormal(dept);
|
||||
}
|
||||
if ("0".equals(dept.getIsVisible())){ //如果隐藏该部门则其子部门全部隐藏
|
||||
updateDeptChildrenVisiable(dept.getDeptId(),"0");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -305,6 +310,19 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
|||
.in(SysDept::getDeptId, Arrays.asList(deptIds)));
|
||||
}
|
||||
|
||||
/*
|
||||
* 修改子部门为隐藏
|
||||
*
|
||||
* */
|
||||
private void updateDeptChildrenVisiable(String deptId,String visible){
|
||||
List<SysDept> children = baseMapper.selectList(new LambdaQueryWrapper<SysDept>()
|
||||
.apply(DataBaseHelper.findInSet(deptId, "ancestors")));
|
||||
for (SysDept child : children) {
|
||||
child.setIsVisible(visible);
|
||||
baseMapper.updateById(child);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改子元素关系
|
||||
*
|
||||
|
|
|
|||
|
|
@ -14,12 +14,17 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.redis.utils.RedisUtils;
|
||||
import org.dromara.system.api.RemoteDataScopeService;
|
||||
import org.dromara.system.domain.DeviceRedis;
|
||||
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.DeviceRedisMapper;
|
||||
import org.dromara.system.mapper.SysConfigMapper;
|
||||
import org.dromara.system.mapper.SysDeptJlyMapper;
|
||||
import org.dromara.system.service.ISysConfigService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.dromara.system.domain.bo.TDeviceBo;
|
||||
import org.dromara.system.domain.vo.TDeviceVo;
|
||||
|
|
@ -47,6 +52,12 @@ public class TDeviceServiceImpl implements ITDeviceService {
|
|||
|
||||
private final SysDeptJlyMapper deptJlyMapper;
|
||||
|
||||
private final ISysConfigService configService;
|
||||
|
||||
private final DeviceRedisMapper redisMapper;
|
||||
|
||||
private String lastRemoveTime;
|
||||
|
||||
@DubboReference
|
||||
private RemoteDataScopeService remoteDataScopeService;
|
||||
|
||||
|
|
@ -124,6 +135,53 @@ public class TDeviceServiceImpl implements ITDeviceService {
|
|||
return baseMapper.selectDeviceExportList(lqw);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 删除长时间未更新的执法记录仪
|
||||
* */
|
||||
@Override
|
||||
public int deleteZfjly() {
|
||||
String day = configService.selectConfigByKey("device.remove.day");
|
||||
LambdaQueryWrapper<TDevice> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.inSql(TDevice::getDeviceType,"'5','7','8'");
|
||||
lqw.eq(TDevice::getValid,"1");
|
||||
lqw.le(TDevice::getUpdateTime,DateUtil.offsetDay(new Date(),Integer.getInteger(day)));
|
||||
List<TDevice> list = baseMapper.selectList(lqw);
|
||||
for (TDevice device : list) {
|
||||
device.setValid(0);
|
||||
device.setUpdateTime(DateUtil.now());
|
||||
baseMapper.updateById(device);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* 删除状态为删除的设备定位信息和存在t_device_redis的数据
|
||||
* */
|
||||
|
||||
@Override
|
||||
public int deleteRedis() {
|
||||
LambdaQueryWrapper<TDevice> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.gt(StringUtils.isNotBlank(lastRemoveTime),TDevice::getUpdateTime,lastRemoveTime);
|
||||
lqw.eq(TDevice::getValid,0);
|
||||
lqw.orderByDesc(TDevice::getUpdateTime);
|
||||
List<TDeviceVo> list = baseMapper.selectVoList(lqw);
|
||||
try {
|
||||
if (list.size()>0){
|
||||
lastRemoveTime = list.get(0).getUpdateTime();
|
||||
for (TDeviceVo deviceVo : list) {
|
||||
RedisUtils.del("online_users:"+deviceVo.getDeviceType()+":"+deviceVo.getDeviceCode());
|
||||
LambdaQueryWrapper<DeviceRedis> dqw = new LambdaQueryWrapper<>();
|
||||
dqw.eq(DeviceRedis::getDeviceCode,deviceVo.getDeviceCode());
|
||||
redisMapper.delete(dqw);
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TDeviceVo queryOne(TDeviceBo bo) {
|
||||
LambdaQueryWrapper<TDevice> lqw = buildQueryWrapper(bo);
|
||||
|
|
@ -235,22 +293,20 @@ public class TDeviceServiceImpl implements ITDeviceService {
|
|||
@Override
|
||||
public Boolean batchSaveOrUpdate(List<TDevice> list) {
|
||||
boolean flag = true;
|
||||
// 先根据 field1 和 field2 查询出已存在的记录
|
||||
/*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;
|
||||
if (entity.getDeviceType().equals("5") || entity.getDeviceType().equals("8")
|
||||
|| entity.getDeviceType().equals("7")){ // 记录仪、5G车载、布控球 处理机构
|
||||
LambdaQueryWrapper<SysdeptJly> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.eq(SysdeptJly::getQyCode,entity.getZzjgdm());
|
||||
SysdeptJlyVo jlyVo = deptJlyMapper.selectVoOne(lqw);
|
||||
entity.setZzjgdm("341800000000");
|
||||
entity.setZzjgmc("宣城市公安局");
|
||||
if (null != jlyVo){
|
||||
entity.setZzjgdm(jlyVo.getDeptId());
|
||||
entity.setZzjgmc(jlyVo.getDeptName());
|
||||
|
|
@ -258,28 +314,8 @@ public class TDeviceServiceImpl implements ITDeviceService {
|
|||
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);
|
||||
exists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!exists) {
|
||||
toInsert.add(entity);
|
||||
}*/
|
||||
}
|
||||
|
||||
// 批量更新
|
||||
/*if (!toUpdate.isEmpty()) {
|
||||
flag = baseMapper.updateBatchById(toUpdate);
|
||||
}
|
||||
|
||||
// 批量插入
|
||||
if (!toInsert.isEmpty()) {
|
||||
flag = baseMapper.insertBatch(toInsert); // insertBatchSomeColumn 是 MyBatis-Plus 提供的批量插入方法
|
||||
}*/
|
||||
return flag;
|
||||
// return baseMapper.insertOrUpdateBatch(List);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,4 +46,9 @@
|
|||
WHERE d.dict_type = 'zd_device_type'
|
||||
</select>
|
||||
|
||||
<select id="countByzzjgdm" resultType="Long">
|
||||
select count(*) from t_device_redis
|
||||
${ew.getCustomSqlSegment}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
|
|||
|
|
@ -49,8 +49,8 @@
|
|||
#{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()
|
||||
car_num = values(car_num),valid = '1',remark1 = values(remark1),remark2 = values(remark2),card_num = values(card_num),
|
||||
update_time = values(update_time)
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
|
|
|
|||
|
|
@ -1,23 +0,0 @@
|
|||
package org.dromara.webscoket.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
|
||||
/**
|
||||
* <p>description: </p>
|
||||
*
|
||||
* @author chenle
|
||||
* @date 2022-03-15 10:11
|
||||
*/
|
||||
@Configuration
|
||||
@EnableScheduling
|
||||
public class ThreadConfig {
|
||||
@Bean
|
||||
public ScheduledThreadPoolExecutor scheduledExecutorService() {
|
||||
ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(8);
|
||||
return executor;
|
||||
}
|
||||
}
|
||||
|
|
@ -75,6 +75,7 @@ public class DeviceSchedule {
|
|||
newDevice.setDeviceCode(deviceCode);
|
||||
if (originDevice.getNickname().contains("皖")){
|
||||
newDevice.setDeviceType("8");
|
||||
newDevice.setCarNum(originDevice.getNickname());
|
||||
}else if(originDevice.getNickname().contains("布控球")) {
|
||||
newDevice.setDeviceType("7");
|
||||
}else {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ server:
|
|||
spring:
|
||||
application:
|
||||
# 应用名称
|
||||
name: wzhj-webscoket
|
||||
name: wzhj-websocket
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: @profiles.active@
|
||||
|
|
|
|||
|
|
@ -0,0 +1,49 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||
<!-- 日志存放路径 -->
|
||||
<property name="log.path" value="logs" />
|
||||
<property name="log.file" value="websocket" />
|
||||
<property name="MAX_FILE_SIZE" value="10MB" />
|
||||
<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>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 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>
|
||||
|
||||
<!-- 根Logger配置(禁用控制台输出) -->
|
||||
<root level="INFO">
|
||||
<appender-ref ref="FILE_INFO" />
|
||||
<appender-ref ref="FILE_ERROR" />
|
||||
</root>
|
||||
|
||||
</configuration>
|
||||
Loading…
Reference in New Issue