亳州移动警务新对接
parent
d667538721
commit
7aca2c9649
|
|
@ -0,0 +1,85 @@
|
|||
package org.dromara.extract.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.dromara.common.tenant.core.TenantEntity;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
|
||||
/**
|
||||
* 部门表 sys_dept
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
|
||||
@Data
|
||||
@TableName("sys_dept")
|
||||
public class Dept {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 部门ID
|
||||
*/
|
||||
@TableId(value = "dept_id")
|
||||
private String deptId;
|
||||
|
||||
/**
|
||||
* 父部门ID
|
||||
*/
|
||||
private String parentId;
|
||||
|
||||
/**
|
||||
* 部门名称
|
||||
*/
|
||||
private String deptName;
|
||||
|
||||
private String shortName;
|
||||
|
||||
|
||||
/**
|
||||
* 显示顺序
|
||||
*/
|
||||
private Integer orderNum;
|
||||
|
||||
/**
|
||||
* 负责人
|
||||
*/
|
||||
private Long leader;
|
||||
|
||||
/**
|
||||
* 联系电话
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 部门状态:0正常,1停用
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 删除标志(0代表存在 2代表删除)
|
||||
*/
|
||||
@TableLogic
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 祖级列表
|
||||
*/
|
||||
private String ancestors;
|
||||
|
||||
private String fullName;
|
||||
|
||||
private String isVisible;
|
||||
|
||||
}
|
||||
|
|
@ -24,6 +24,9 @@ public class Device implements Serializable {
|
|||
private String carNum;
|
||||
private String remark1;
|
||||
private String remark2;
|
||||
|
||||
private String cardNum;
|
||||
|
||||
private int valid;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
|
|
@ -141,4 +144,12 @@ public class Device implements Serializable {
|
|||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
public String getCardNum() {
|
||||
return cardNum;
|
||||
}
|
||||
|
||||
public void setCardNum(String cardNum) {
|
||||
this.cardNum = cardNum;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
package org.dromara.extract.mapper;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
import org.dromara.extract.domain.Dept;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 部门管理 数据层
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@DS("wzhj")
|
||||
public interface DeptMapper extends BaseMapper<Dept> {
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@ package org.dromara.extract.mapper;
|
|||
|
||||
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import org.dromara.extract.domain.EsGpsInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -10,6 +11,7 @@ public interface DeviceGpsMapper {
|
|||
|
||||
List<EsGpsInfo> selectPDTGPS(EsGpsInfo esGpsInfo);
|
||||
|
||||
@DS("ydjw")
|
||||
List<EsGpsInfo> selectYDJWGPS(EsGpsInfo esGpsInfo);
|
||||
|
||||
List<EsGpsInfo> selectBDGCGPS(EsGpsInfo esGpsInfo);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package org.dromara.extract.mapper;
|
||||
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.dromara.extract.domain.Device;
|
||||
|
||||
|
|
@ -19,4 +20,7 @@ public interface DeviceMapper {
|
|||
|
||||
Device deviceByCode(String deviceCode);
|
||||
|
||||
@DS("wzhj")
|
||||
int insertOrUpdateByCodeAndType(Device device);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,92 @@
|
|||
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.Device;
|
||||
import org.dromara.extract.domain.EsGpsInfo;
|
||||
import org.dromara.extract.mapper.DeviceGpsMapper;
|
||||
import org.dromara.extract.mapper.DeviceMapper;
|
||||
import org.dromara.extract.service.IDeviceService;
|
||||
import org.dromara.system.api.RemoteDeviceService;
|
||||
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.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/*
|
||||
* @Author: luya
|
||||
* @Date: 2023/3/20 15:43
|
||||
* 警务通定位数据和基础数据
|
||||
* */
|
||||
@Slf4j
|
||||
@Configuration
|
||||
public class JwtDeviceSchedule {
|
||||
|
||||
@Autowired
|
||||
IDeviceService deviceService;
|
||||
|
||||
@Autowired
|
||||
DeviceGpsMapper gpsMapper;
|
||||
|
||||
@DubboReference
|
||||
RemoteDataToEsService dataToEsService;
|
||||
|
||||
|
||||
@Value("${ruansi.jwt-gps-update-time}")
|
||||
private String gpsUpdateTime;
|
||||
|
||||
@Value("${ruansi.jwt-base-update-time}")
|
||||
private String baseUpdateTime;
|
||||
|
||||
/*
|
||||
* 10S执行一次
|
||||
* */
|
||||
@Scheduled(cron = "0/10 * * * * ?")
|
||||
public void jwtGpsSchedule(){
|
||||
EsGpsInfo gpsInfo = new EsGpsInfo();
|
||||
gpsInfo.setGpsTime(DateUtil.parse(gpsUpdateTime));
|
||||
log.info("警务通GPS更新时间:"+gpsUpdateTime);
|
||||
List<EsGpsInfo> list = gpsMapper.selectYDJWGPS(gpsInfo);
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
EsGpsInfo info = list.get(i);
|
||||
if(i == 0){
|
||||
gpsUpdateTime = DateUtil.format(info.getGpsTime(),"yyyy-MM-dd HH:mm:ss") ;
|
||||
}
|
||||
if (DateUtil.between(new Date(),info.getGpsTime(), DateUnit.MINUTE) > 5){
|
||||
info.setOnline("0");
|
||||
}else {
|
||||
info.setOnline("1");
|
||||
}
|
||||
}
|
||||
ArrayList<EsGpsInfo> collect = list.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() ->
|
||||
new TreeSet<>(Comparator.comparing(EsGpsInfo::getDeviceCode))), ArrayList::new));
|
||||
dataToEsService.saveDataBatch(BeanUtil.copyToList(collect, RemoteGpsInfo.class));
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* 十分钟执行一次
|
||||
* */
|
||||
@Scheduled(cron = "0 0/10 * * * ?")
|
||||
public void jwtDeviceSchedule(){
|
||||
Device d = new Device();
|
||||
d.setUpdateTime(DateUtil.parse(baseUpdateTime));
|
||||
List<Device> list = deviceService.selectYDJW(d);
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Device device = list.get(i);
|
||||
if(i == 0)
|
||||
baseUpdateTime = DateUtil.format(device.getUpdateTime(),"yyyy-MM-dd HH:mm:ss") ;
|
||||
}
|
||||
deviceService.batchSaveOrUpdate(list);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -19,5 +19,7 @@ public interface IDeviceService {
|
|||
|
||||
Device deviceByCode(String deviceCode);
|
||||
|
||||
Boolean batchSaveOrUpdate(List<Device> list);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,10 @@ package org.dromara.extract.service.impl;
|
|||
|
||||
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import org.dromara.extract.domain.Dept;
|
||||
import org.dromara.extract.domain.Device;
|
||||
import org.dromara.extract.mapper.DeptMapper;
|
||||
import org.dromara.extract.mapper.DeviceMapper;
|
||||
import org.dromara.extract.service.IDeviceService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -16,6 +19,9 @@ public class DeviceServiceImpl implements IDeviceService {
|
|||
@Autowired
|
||||
DeviceMapper deviceMapper;
|
||||
|
||||
@Autowired
|
||||
DeptMapper deptMapper;
|
||||
|
||||
@Override
|
||||
public List<Device> selectPDT(Device device) {
|
||||
List<Device> list = deviceMapper.selectPDT(device);
|
||||
|
|
@ -23,6 +29,7 @@ public class DeviceServiceImpl implements IDeviceService {
|
|||
}
|
||||
|
||||
@Override
|
||||
@DS("ydjw")
|
||||
public List<Device> selectYDJW(Device tDevice) {
|
||||
return deviceMapper.selectYDJW(tDevice);
|
||||
}
|
||||
|
|
@ -41,4 +48,17 @@ public class DeviceServiceImpl implements IDeviceService {
|
|||
public Device deviceByCode(String deviceCode) {
|
||||
return deviceMapper.deviceByCode(deviceCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean batchSaveOrUpdate(List<Device> list) {
|
||||
for (Device entity : list) {
|
||||
Dept dept = deptMapper.selectById(entity.getZzjgdm());
|
||||
if (dept != null) {
|
||||
entity.setZzjgmc(dept.getShortName());
|
||||
}
|
||||
deviceMapper.insertOrUpdateByCodeAndType(entity);
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
<?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.extract.mapper.DeptMapper">
|
||||
|
||||
<resultMap type="org.dromara.extract.domain.Dept" id="SysDeptResult">
|
||||
</resultMap>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -29,10 +29,11 @@
|
|||
</select>
|
||||
|
||||
<select id="selectYDJWGPS" parameterType="org.dromara.extract.domain.EsGpsInfo" resultMap="DeviceResult">
|
||||
select userid deviceCode,'4' deviceType, lng lng, lat lat, gpstime gpsTime from v_device_status
|
||||
select zdid deviceCode,'4' deviceType, jd lng, wd lat, gxsj gpsTime from v_jwt
|
||||
<where>
|
||||
<if test="gpsTime != null "> and to_date(gpstime,'yyyy-mm-dd,hh24:mi:ss') >= #{gpsTime}</if>
|
||||
<if test="gpsTime != null "> and gxsj > #{gpsTime}</if>
|
||||
</where>
|
||||
order by gxsj desc
|
||||
</select>
|
||||
|
||||
<select id="selectBDGCGPS" parameterType="org.dromara.extract.domain.EsGpsInfo" resultMap="DeviceResult">
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<result property="id" column="id" />
|
||||
<result property="deviceCode" column="device_code" />
|
||||
<result property="deviceType" column="device_type" />
|
||||
<result property="policeNo" column="policeNo" />
|
||||
<result property="policeName" column="policeName" />
|
||||
<result property="phoneNum" column="phoneNum" />
|
||||
<result property="policeNo" column="police_no" />
|
||||
<result property="policeName" column="police_name" />
|
||||
<result property="phoneNum" column="phone_num" />
|
||||
<result property="carNum" column="car_num" />
|
||||
<result property="zzjgdm" column="zzjgdm" />
|
||||
<result property="zzjgmc" column="zzjgmc" />
|
||||
|
|
@ -30,11 +30,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</select>
|
||||
|
||||
<select id="selectYDJW" parameterType="org.dromara.extract.domain.Device" resultMap="DeviceRes">
|
||||
select pnum device_code,'4' device_type, dept_code zzjgdm, department_detail zzjgmc, zhgxsj create_time, pname policeName,
|
||||
pnum policeNo, phonenum phoneNum from v_user
|
||||
select zdid device_code,'4' device_type, ssdw zzjgdm, to_timestamp(zdcjsj / 1000)::timestamp create_time,
|
||||
jyxm police_name, jyjh police_no, jylxfs phone_num,to_char(gxsj,'yyyy-MM-dd HH24:mi:ss') update_time,sfyx as valid from v_jwt
|
||||
<where>
|
||||
<if test="createTime != null "> and zhgxsj >= #{createTime}</if>
|
||||
ssdw != '' and ssdw != '341600000000'
|
||||
<if test="updateTime != null "> and gxsj > #{updateTime}</if>
|
||||
</where>
|
||||
order by gxsj desc
|
||||
</select>
|
||||
|
||||
<select id="selectBDGC" parameterType="org.dromara.extract.domain.Device" resultMap="DeviceRes">
|
||||
|
|
@ -57,5 +59,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
select * from t_device where device_code = #{deviceCode}
|
||||
</select>
|
||||
|
||||
<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
|
||||
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 = values(update_time)
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
|
|
|
|||
|
|
@ -290,11 +290,6 @@ 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<>();
|
||||
// 找到需要插入的记录
|
||||
|
|
@ -302,28 +297,8 @@ public class TDeviceServiceImpl implements ITDeviceService {
|
|||
for (TDevice entity : list) {
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue