省厅位置汇聚数据上传到讯飞高斯库
parent
13f46756c8
commit
7cb4a65d27
|
|
@ -577,23 +577,55 @@ public class RedisUtils {
|
|||
* 模糊查询
|
||||
* */
|
||||
public static List<JSONObject> searchAndGetKeysValues(String pattern) {
|
||||
final int BATCH_SIZE = 1000; // 每批处理1000个key,可根据实际情况调整
|
||||
|
||||
RKeys keys = CLIENT.getKeys();
|
||||
// 模糊查询获取匹配的key
|
||||
Iterable<String> keysIterable = keys.getKeysByPattern(pattern);
|
||||
List<JSONObject> list = new ArrayList<>();
|
||||
// RBatch batch = CLIENT.createBatch();
|
||||
// 批量获取这些key的值
|
||||
for (String key : keysIterable) {
|
||||
RBucket<Object> bucket = CLIENT.getBucket(key);
|
||||
Object value = bucket.get();
|
||||
JSONObject jsonObject = JSONUtil.parseObj(value.toString());
|
||||
list.add(jsonObject);
|
||||
|
||||
// 收集所有匹配的 key 到 list(SCAN 是惰性的,必须遍历完才能拿到全部)
|
||||
List<String> allKeys = new ArrayList<>();
|
||||
keysIterable.forEach(allKeys::add);
|
||||
|
||||
if (allKeys.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
// 执行批量获取
|
||||
// BatchResult result = batch.execute();
|
||||
// 输出结果
|
||||
return list;
|
||||
List<JSONObject> result = new ArrayList<>(allKeys.size());
|
||||
|
||||
// 分批处理
|
||||
for (int i = 0; i < allKeys.size(); i += BATCH_SIZE) {
|
||||
int end = Math.min(i + BATCH_SIZE, allKeys.size());
|
||||
List<String> batchKeys = allKeys.subList(i, end);
|
||||
|
||||
RBatch batch = CLIENT.createBatch();
|
||||
Map<String, RFuture<Object>> futureMap = new HashMap<>();
|
||||
|
||||
// 添加异步 get 请求
|
||||
for (String key : batchKeys) {
|
||||
RFuture<Object> future = batch.getBucket(key).getAsync();
|
||||
futureMap.put(key, future);
|
||||
}
|
||||
|
||||
// 执行批量命令(一次网络往返)
|
||||
batch.execute();
|
||||
|
||||
// 收集结果
|
||||
for (String key : batchKeys) {
|
||||
try {
|
||||
Object value = futureMap.get(key).getNow(); // 已执行完毕,无需阻塞
|
||||
if (value != null) {
|
||||
JSONObject jsonObject = JSONUtil.parseObj(value.toString());
|
||||
result.add(jsonObject);
|
||||
}
|
||||
// 可选:记录缺失 key(用于 debug)
|
||||
} catch (Exception e) {
|
||||
// 日志记录异常,避免一个 key 失败导致整体失败
|
||||
// log.warn("Failed to get value for key: {}", key, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -0,0 +1,58 @@
|
|||
package org.dromara.data2gs.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>description: </p>
|
||||
* gps定位信息(es表)
|
||||
* @author chenle
|
||||
* @date 2021-05-14 9:39
|
||||
*/
|
||||
@Data
|
||||
public class EsGpsInfo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 7455495841680488351L;
|
||||
/**
|
||||
* 唯一码(外部系统)合肥版本不需要 21位id,
|
||||
* 到时候上传省厅的时候 需要在kafka发送端处理,生成一个省厅需要的21位id
|
||||
*/
|
||||
private String deviceCode;
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private String deviceType;
|
||||
private String lat;
|
||||
private String lng;
|
||||
//方向
|
||||
private String orientation;
|
||||
//高程
|
||||
private String height;
|
||||
//高程差
|
||||
private String deltaH;
|
||||
private String speed;
|
||||
|
||||
|
||||
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date gpsTime;
|
||||
// 1 在线 0 离线
|
||||
private int online;
|
||||
|
||||
private String zzjgdm;
|
||||
|
||||
private String zzjgmc;
|
||||
|
||||
private String infoSource;
|
||||
|
||||
private String policeNo;
|
||||
|
||||
private String policeName;
|
||||
|
||||
private String phoneNum;
|
||||
|
||||
private String carNum;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,155 @@
|
|||
package org.dromara.data2gs.domain;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
/**
|
||||
* 警用设备基本信息对象 jysb_sbxx_001
|
||||
*
|
||||
* @author luuy
|
||||
* @date 2024-12-07
|
||||
*/
|
||||
@Data
|
||||
@TableName("jysb_sbxx_001")
|
||||
public class JysbSbxx001 {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 设备编号
|
||||
*/
|
||||
private String sbbh;
|
||||
|
||||
/**
|
||||
* 设备品牌
|
||||
*/
|
||||
private String sbpp;
|
||||
|
||||
/**
|
||||
* 设备型号
|
||||
*/
|
||||
private String sbxh;
|
||||
|
||||
/**
|
||||
* 装备类型
|
||||
*/
|
||||
private String zblx;
|
||||
|
||||
/**
|
||||
* 所属公安机关机构代码
|
||||
*/
|
||||
private String ssgajgjgdm;
|
||||
|
||||
/**
|
||||
* 车牌号码
|
||||
*/
|
||||
private String cphm;
|
||||
|
||||
/**
|
||||
* 警员编号
|
||||
*/
|
||||
private String jybh;
|
||||
|
||||
/**
|
||||
* 警员姓名
|
||||
*/
|
||||
private String jyxm;
|
||||
|
||||
private String jysfz;
|
||||
|
||||
/**
|
||||
* 户号
|
||||
*/
|
||||
private String hh;
|
||||
|
||||
/**
|
||||
* 联系电话
|
||||
*/
|
||||
private String lxdh;
|
||||
|
||||
/**
|
||||
* 设备使用状态代码
|
||||
*/
|
||||
private String sbsyzt;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String bz;
|
||||
|
||||
/**
|
||||
* 数据操作类型代码
|
||||
*/
|
||||
private String sjczlxdm;
|
||||
|
||||
/**
|
||||
* 数据来源
|
||||
*/
|
||||
private String sjly;
|
||||
|
||||
/**
|
||||
* 录入时间
|
||||
*/
|
||||
private String lrsj;
|
||||
|
||||
/**
|
||||
* 录入单位代码
|
||||
*/
|
||||
private String lrdwdm;
|
||||
|
||||
/**
|
||||
* 录入单位名称
|
||||
*/
|
||||
private String lrdwmc;
|
||||
|
||||
/**
|
||||
* 录入人姓名
|
||||
*/
|
||||
private String lrrxm;
|
||||
|
||||
/**
|
||||
* 录入人身份证号码
|
||||
*/
|
||||
private String lrrsfzh;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private String xgsj;
|
||||
|
||||
/**
|
||||
* 修改单位代码
|
||||
*/
|
||||
private String xgdwdm;
|
||||
|
||||
/**
|
||||
* 修改单位名称
|
||||
*/
|
||||
private String xgdwmc;
|
||||
|
||||
/**
|
||||
* 修改人姓名
|
||||
*/
|
||||
private String xgrxm;
|
||||
|
||||
/**
|
||||
* 修改人身份证号
|
||||
*/
|
||||
private String xgrsfzh;
|
||||
|
||||
private String gbbm;
|
||||
|
||||
private String tdbm;
|
||||
|
||||
/**
|
||||
* 信息主键编号
|
||||
*/
|
||||
@TableId(type = IdType.INPUT)
|
||||
private String xxzjbh;
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,141 @@
|
|||
package org.dromara.data2gs.domain;
|
||||
|
||||
|
||||
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;
|
||||
|
||||
|
||||
/**
|
||||
* 警用设备定位信息对象 jysb_sbxx_002
|
||||
*
|
||||
* @author luuy
|
||||
* @date 2024-12-07
|
||||
*/
|
||||
@Data
|
||||
@TableName("jysb_sbxx_002")
|
||||
public class JysbSbxx002 {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 设备编号
|
||||
*/
|
||||
private String sbbh;
|
||||
|
||||
/**
|
||||
* 经度
|
||||
*/
|
||||
private String jd;
|
||||
|
||||
/**
|
||||
* 维度
|
||||
*/
|
||||
private String wd;
|
||||
|
||||
/**
|
||||
* 水平速度
|
||||
*/
|
||||
private String spsd;
|
||||
|
||||
/**
|
||||
* 垂直速度
|
||||
*/
|
||||
private String czsd;
|
||||
|
||||
/**
|
||||
* 航迹角
|
||||
*/
|
||||
private String hjj;
|
||||
|
||||
/**
|
||||
* 高程
|
||||
*/
|
||||
private String gc;
|
||||
|
||||
/**
|
||||
* 精度
|
||||
*/
|
||||
@TableField("jd_01")
|
||||
private String jd01;
|
||||
|
||||
/**
|
||||
* 设备使用开始时间
|
||||
*/
|
||||
private String sbsykssj;
|
||||
|
||||
/**
|
||||
* 设备使用结束时间
|
||||
*/
|
||||
private String sbsyjssj;
|
||||
|
||||
/**
|
||||
* 数据操作类型代码
|
||||
*/
|
||||
private String sjczlxdm;
|
||||
|
||||
/**
|
||||
* 数据来源
|
||||
*/
|
||||
private String sjly;
|
||||
|
||||
/**
|
||||
* 录入时间
|
||||
*/
|
||||
private String lrsj;
|
||||
|
||||
/**
|
||||
* 录入单位代码
|
||||
*/
|
||||
private String lrdwdm;
|
||||
|
||||
/**
|
||||
* 录入单位名称
|
||||
*/
|
||||
private String lrdwmc;
|
||||
|
||||
/**
|
||||
* 录入人姓名
|
||||
*/
|
||||
private String lrrxm;
|
||||
|
||||
/**
|
||||
* 录入人身份证号
|
||||
*/
|
||||
private String lrrsfzh;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private String xgsj;
|
||||
|
||||
/**
|
||||
* 修改单位代码
|
||||
*/
|
||||
private String xgdwdm;
|
||||
|
||||
/**
|
||||
* 修改单位名称
|
||||
*/
|
||||
private String xgdwmc;
|
||||
|
||||
/**
|
||||
* 修改人姓名
|
||||
*/
|
||||
private String xgrxm;
|
||||
|
||||
/**
|
||||
* 修改人身份证号
|
||||
*/
|
||||
private String xgrsfzh;
|
||||
|
||||
/**
|
||||
* 信息主键编号
|
||||
*/
|
||||
@TableId(type = IdType.INPUT)
|
||||
private String xxzjbh;
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
package org.dromara.data2gs.domain;
|
||||
|
||||
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 com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>description: </p>
|
||||
*
|
||||
* @author chenle
|
||||
* @date 2022-03-17 16:39
|
||||
*/
|
||||
@Data
|
||||
@TableName("t_device")
|
||||
public class NewDevice {
|
||||
private static final long serialVersionUID = 4483817283384658970L;
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@TableField(value = "device_code")
|
||||
private String deviceCode;
|
||||
@TableField(value = "device_type")
|
||||
private String deviceType;
|
||||
|
||||
//地市代码 3401
|
||||
@TableField(value = "info_source")
|
||||
private String infoSource;
|
||||
|
||||
@TableField(value = "zzjgdm")
|
||||
private String zzjgdm;
|
||||
@TableField(value = "zzjgmc")
|
||||
private String zzjgmc;
|
||||
|
||||
@TableField(value = "police_no")
|
||||
private String policeNo;
|
||||
|
||||
@TableField(value = "police_name")
|
||||
private String policeName;
|
||||
|
||||
@TableField(value = "phone_num")
|
||||
private String phoneNum;
|
||||
|
||||
@TableField(value = "card_num")
|
||||
private String cardNum;
|
||||
|
||||
@TableField(value = "car_num")
|
||||
private String carNum;
|
||||
|
||||
@TableField(value = "gbbm")
|
||||
private String gbbm;
|
||||
|
||||
@TableField(value = "tdbm")
|
||||
private String tdbm;
|
||||
|
||||
@TableField(value = "remark")
|
||||
private String remark;
|
||||
|
||||
@TableField(value = "remark1")
|
||||
private String remark1;
|
||||
|
||||
@TableField(value = "remark2")
|
||||
private String remark2;
|
||||
|
||||
private Integer valid;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date createTime;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date updateTime;
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
package org.dromara.data2gs.mapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.dromara.data2gs.domain.JysbSbxx001;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 警用设备基本信息Mapper接口
|
||||
*
|
||||
* @author luuy
|
||||
* @date 2024-12-07
|
||||
*/
|
||||
@Mapper
|
||||
public interface JysbSbxx001Mapper extends BaseMapper<JysbSbxx001> {
|
||||
|
||||
@Insert("<script> " +
|
||||
"insert into \"JYSB_SBXX_001\" (\"SBBH\",\"SBPP\",\"SBXH\",\"ZBLX\",\"SSGAJGJGDM\",\"CPHM\",\"JYBH\",\"JYXM\",\"JYSFZ\",\"HH\"," +
|
||||
" \"LXDH\",\"SBSYZT\",\"BZ\",\"SJCZLXDM\",\"SJLY\",\"LRSJ\",\"LRDWDM\",\"LRDWMC\",\"LRRXM\",\"LRRSFZH\"," +
|
||||
" \"XGSJ\",\"XGDWDM\",\"XGDWMC\",\"XGRXM\",\"XGRSFZH\",\"XXZJBH\",\"GBBM\",\"TDBM\")" +
|
||||
" values" +
|
||||
" <foreach collection=\"list\" item=\"i\" separator=\",\"> " +
|
||||
" ( " +
|
||||
" #{i.sbbh},#{i.sbpp},#{i.sbxh},#{i.zblx},#{i.ssgajgjgdm},#{i.cphm},#{i.jybh},#{i.jyxm},#{i.jysfz},#{i.hh},#{i.lxdh},#{i.sbsyzt},#{i.bz},#{i.sjczlxdm},#{i.sjly} " +
|
||||
" ,#{i.lrsj},#{i.lrdwdm},#{i.lrdwmc},#{i.lrrxm},#{i.lrrsfzh},#{i.xgsj},#{i.xgdwdm},#{i.xgdwmc},#{i.xgrxm},#{i.xgrsfzh},#{i.xxzjbh},#{i.gbbm},#{i.tdbm} " +
|
||||
" ) " +
|
||||
" </foreach> " +
|
||||
" ON conflict(\"XXZJBH\") do update set " +
|
||||
" (\"SSGAJGJGDM\",\"CPHM\",\"JYBH\",\"JYXM\",\"JYSFZ\",\"SBSYZT\",\"SJCZLXDM\",\"XGSJ\") = " +
|
||||
" (EXCLUDED.\"SSGAJGJGDM\",EXCLUDED.\"CPHM\",EXCLUDED.\"JYBH\",EXCLUDED.\"JYXM\",EXCLUDED.\"JYSFZ\",EXCLUDED.\"SBSYZT\",'2',EXCLUDED.\"XGSJ\")" +
|
||||
"</script>")
|
||||
int insertManyJbxx(@Param("list") List<JysbSbxx001> list);
|
||||
|
||||
@Insert(
|
||||
"insert into \"JYSB_SBXX_001\" (\"SBBH\",\"SBPP\",\"SBXH\",\"ZBLX\",\"SSGAJGJGDM\",\"CPHM\",\"JYBH\",\"JYXM\",\"JYSFZ\",\"HH\"," +
|
||||
" \"LXDH\",\"SBSYZT\",\"BZ\",\"SJCZLXDM\",\"SJLY\",\"LRSJ\",\"LRDWDM\",\"LRDWMC\",\"LRRXM\",\"LRRSFZH\"," +
|
||||
" \"XGSJ\",\"XGDWDM\",\"XGDWMC\",\"XGRXM\",\"XGRSFZH\",\"XXZJBH\",\"GBBM\",\"TDBM\")" +
|
||||
" values" +
|
||||
" ( " +
|
||||
" #{sbbh},#{sbpp},#{sbxh},#{zblx},#{ssgajgjgdm},#{cphm},#{jybh},#{jyxm},#{jysfz},#{hh},#{lxdh},#{sbsyzt},#{bz},#{sjczlxdm},#{sjly} " +
|
||||
" ,#{lrsj},#{lrdwdm},#{lrdwmc},#{lrrxm},#{lrrsfzh},#{xgsj},#{xgdwdm},#{xgdwmc},#{xgrxm},#{xgrsfzh},#{xxzjbh},#{gbbm},#{tdbm} " +
|
||||
" ) " +
|
||||
" ON conflict(\"XXZJBH\") do update set " +
|
||||
" (\"SSGAJGJGDM\",\"CPHM\",\"JYBH\",\"JYXM\",\"JYSFZ\",\"SBSYZT\",\"SJCZLXDM\",\"XGSJ\") = " +
|
||||
" (EXCLUDED.\"SSGAJGJGDM\",EXCLUDED.\"CPHM\",EXCLUDED.\"JYBH\",EXCLUDED.\"JYXM\",EXCLUDED.\"JYSFZ\",EXCLUDED.\"SBSYZT\",'2',EXCLUDED.\"XGSJ\")"
|
||||
)
|
||||
int insertJbxx(JysbSbxx001 sbxx);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
package org.dromara.data2gs.mapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.dromara.data2gs.domain.JysbSbxx002;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 警用设备基本信息Mapper接口
|
||||
*
|
||||
* @author luuy
|
||||
* @date 2024-12-07
|
||||
*/
|
||||
public interface JysbSbxx002Mapper extends BaseMapper<JysbSbxx002> {
|
||||
|
||||
@Insert("<script> " +
|
||||
"insert into \"JYSB_SBXX_002\" (\"SBBH\",\"JD\",\"WD\",\"SPSD\",\"CZSD\",\"HJJ\",\"GC\",\"JD_01\",\"SBSYKSSJ\",\"SBSYJSSJ\",\"SJCZLXDM\",\"SJLY\"," +
|
||||
" \"LRSJ\",\"LRDWDM\",\"LRDWMC\",\"LRRXM\",\"LRRSFZH\",\"XGSJ\",\"XGDWDM\",\"XGDWMC\",\"XGRXM\",\"XGRSFZH\",\"XXZJBH\")" +
|
||||
" values" +
|
||||
" <foreach collection=\"list\" item=\"i\" separator=\",\"> " +
|
||||
" ( " +
|
||||
" #{i.sbbh},#{i.jd},#{i.wd},#{i.spsd},#{i.czsd},#{i.hjj},#{i.gc},#{i.jd01},#{i.sbsykssj},#{i.sbsyjssj},#{i.sjczlxdm},#{i.sjly},#{i.lrsj},#{i.lrdwdm},#{i.lrdwmc},#{i.lrrxm} " +
|
||||
" ,#{i.lrrsfzh},#{i.xgsj},#{i.xgdwdm},#{i.xgdwmc},#{i.xgrxm},#{i.xgrsfzh},#{i.xxzjbh} " +
|
||||
" ) " +
|
||||
" </foreach> " +
|
||||
" ON conflict(\"XXZJBH\") do update set " +
|
||||
" (\"JD\",\"WD\",\"SBSYKSSJ\",\"SBSYJSSJ\",\"SJCZLXDM\",\"XGSJ\") = " +
|
||||
" (EXCLUDED.\"JD\",EXCLUDED.\"WD\",EXCLUDED.\"SBSYKSSJ\",EXCLUDED.\"SBSYJSSJ\",'2',EXCLUDED.\"XGSJ\")" +
|
||||
"</script>")
|
||||
int insertManyPoint(@Param("list") List<JysbSbxx002> list);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
package org.dromara.data2gs.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.dromara.data2gs.domain.NewDevice;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>description: </p>
|
||||
*
|
||||
* @author chenle
|
||||
* @date 2022-03-18 10:24
|
||||
*/
|
||||
|
||||
public interface NewDeviceMapper extends BaseMapper<NewDevice> {
|
||||
|
||||
@Delete("delete from t_device \n" +
|
||||
"where device_type = 5 and id not in (\n" +
|
||||
"\n" +
|
||||
"\tselect dd.maxId from (\n" +
|
||||
"\t\tselect max(id) as maxId from t_device where device_type = 5 group by policeName \n" +
|
||||
"\t\t) as dd\n" +
|
||||
")")
|
||||
int deleteDevice();
|
||||
|
||||
@Select("select * from t_device order by id desc limit #{begin} , #{size}")
|
||||
List<NewDevice> selectsdList(@Param("begin") int begin,@Param("size") int size);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,298 @@
|
|||
package org.dromara.data2gs.schedule;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.core.utils.RedisConstants;
|
||||
import org.dromara.common.redis.utils.RedisUtils;
|
||||
import org.dromara.data2gs.domain.JysbSbxx001;
|
||||
import org.dromara.data2gs.domain.NewDevice;
|
||||
import org.dromara.data2gs.service.IJysbSbxx001Service;
|
||||
import org.dromara.data2gs.service.NewDeviceService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>description: </p>
|
||||
*
|
||||
* @author chenle
|
||||
* @date 2022-03-17 16:49
|
||||
*/
|
||||
//@Configuration
|
||||
@Slf4j
|
||||
@RestController
|
||||
public class BaseData2GasSchedule {
|
||||
|
||||
|
||||
|
||||
@Autowired
|
||||
IJysbSbxx001Service jysbSbxx001Service;
|
||||
|
||||
|
||||
@Autowired
|
||||
NewDeviceService newDeviceService;
|
||||
|
||||
|
||||
@Scheduled( cron = "0 0 */1 * * ?") //每隔一小时执行一次
|
||||
// @Scheduled( cron = "0 */10 * * * ?")
|
||||
public void deviceTrans(){
|
||||
Date date = new Date();
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
String format = simpleDateFormat.format(date);
|
||||
int count = 0;
|
||||
Long total = newDeviceService.count();
|
||||
BigDecimal totalBig = new BigDecimal(total);
|
||||
BigDecimal sizeBig = new BigDecimal(500);
|
||||
int ceilNum = (int)Math.ceil(totalBig.divide(sizeBig).doubleValue());
|
||||
for (int j = 0; j < ceilNum; j++) {
|
||||
List<NewDevice> list = newDeviceService.querylist(j,500);
|
||||
if(CollectionUtils.isEmpty(list)){
|
||||
log.info("没有可更新的设备");
|
||||
return;
|
||||
}
|
||||
List<JysbSbxx001> jylist = new ArrayList<>();
|
||||
for (NewDevice device : list) {
|
||||
JysbSbxx001 sbxx001 = new JysbSbxx001();
|
||||
sbxx001.setSbbh(strSub(device.getDeviceCode(),20) );
|
||||
if (null == device.getGbbm() || "".equals(device.getGbbm())){
|
||||
sbxx001.setGbbm(strSub(device.getDeviceCode(),20) );
|
||||
}else {
|
||||
sbxx001.setGbbm(strSub(device.getGbbm(),20) ); // 2025-05-12 新添国标编码字段
|
||||
}
|
||||
sbxx001.setTdbm(device.getTdbm());
|
||||
sbxx001.setSbxh("警用设备");
|
||||
if (null != device.getDeviceType()){
|
||||
String zblx = getDeviceType(device.getDeviceType());
|
||||
sbxx001.setZblx(zblx);
|
||||
}else {
|
||||
sbxx001.setZblx("99");
|
||||
}
|
||||
sbxx001.setSsgajgjgdm(device.getZzjgdm());
|
||||
sbxx001.setCphm(strSub(device.getCarNum(),20));
|
||||
if (null != device.getPoliceNo() && !"".equals(device.getPoliceNo())){
|
||||
sbxx001.setJybh(device.getPoliceNo());
|
||||
}else{
|
||||
sbxx001.setJybh("000150");
|
||||
}
|
||||
if (null != device.getPoliceName() && !"".equals(device.getPoliceName())){
|
||||
sbxx001.setJyxm(strSub(device.getPoliceName(),20));
|
||||
}else {
|
||||
sbxx001.setJyxm("韦炜");
|
||||
}
|
||||
if (null != device.getPhoneNum() && !"".equals(device.getPhoneNum())){
|
||||
sbxx001.setLxdh(device.getPhoneNum());
|
||||
}else {
|
||||
sbxx001.setLxdh("15395136292");
|
||||
}
|
||||
if (null != device.getCardNum() && !"".equals(device.getCardNum())){
|
||||
sbxx001.setJysfz(device.getCardNum());
|
||||
}else {
|
||||
sbxx001.setJysfz("341125198507120019"); //没有使用韦科身份证代替
|
||||
}
|
||||
String onlineUsersKey = RedisConstants.ONLINE_USERS + format + ":" +
|
||||
device.getZzjgdm() + ":" + device.getDeviceType() +
|
||||
":" + device.getDeviceCode();
|
||||
Object obj = RedisUtils.getBucket(onlineUsersKey);
|
||||
if (null == obj){
|
||||
sbxx001.setSbsyzt("02");
|
||||
}else {
|
||||
JSONObject job = JSONUtil.parseObj(obj);
|
||||
String online = job.getStr("online");
|
||||
if ("1".equals(online)){
|
||||
sbxx001.setSbsyzt("01");
|
||||
}else {
|
||||
sbxx001.setSbsyzt("02");
|
||||
}
|
||||
}
|
||||
sbxx001.setSbsyzt("01");
|
||||
int valid = device.getValid();
|
||||
if (0 == valid){
|
||||
valid = 3;
|
||||
}else {
|
||||
valid = 2;
|
||||
}
|
||||
sbxx001.setSjczlxdm(valid+"");
|
||||
sbxx001.setSjly(device.getInfoSource()+"00");
|
||||
sbxx001.setLrsj(DateUtil.format(DateUtil.date(),"yyyyMMddHHmmss"));
|
||||
sbxx001.setLrdwdm(device.getZzjgdm());
|
||||
sbxx001.setLrdwmc(device.getZzjgmc());
|
||||
sbxx001.setLrrxm("");
|
||||
sbxx001.setLrrsfzh("");
|
||||
sbxx001.setXgsj(DateUtil.format(DateUtil.date(),"yyyyMMddHHmmss"));
|
||||
sbxx001.setXgdwdm(device.getZzjgdm());
|
||||
sbxx001.setXgdwmc(device.getZzjgmc());
|
||||
sbxx001.setXgrxm("");
|
||||
sbxx001.setXgrsfzh("");
|
||||
sbxx001.setXxzjbh(device.getId()+"");
|
||||
jylist.add(sbxx001);
|
||||
}
|
||||
|
||||
count+= jysbSbxx001Service.insertManyJbxx(jylist);
|
||||
}
|
||||
|
||||
|
||||
log.info("更新的count={}",count);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@RequestMapping("/sbxx")
|
||||
public void deviceTransSd(){
|
||||
Date date = new Date();
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
String format = simpleDateFormat.format(date);
|
||||
int count = 0;
|
||||
Long total = newDeviceService.count();
|
||||
BigDecimal totalBig = new BigDecimal(total);
|
||||
BigDecimal sizeBig = new BigDecimal(500);
|
||||
int ceilNum = (int)Math.ceil(totalBig.divide(sizeBig).doubleValue());
|
||||
for (int j = 0; j < ceilNum; j++) {
|
||||
List<NewDevice> list = newDeviceService.querylist(j,500);
|
||||
if(CollectionUtils.isEmpty(list)){
|
||||
log.info("没有可更新的设备");
|
||||
return;
|
||||
}
|
||||
List<JysbSbxx001> jylist = new ArrayList<>();
|
||||
for (NewDevice device : list) {
|
||||
JysbSbxx001 sbxx001 = new JysbSbxx001();
|
||||
sbxx001.setSbbh(strSub(device.getDeviceCode(),20) );
|
||||
if (null == device.getGbbm() || "".equals(device.getGbbm())){
|
||||
sbxx001.setGbbm(strSub(device.getDeviceCode(),20) );
|
||||
}else {
|
||||
sbxx001.setGbbm(strSub(device.getGbbm(),20) ); // 2025-05-12 新添国标编码字段
|
||||
}
|
||||
sbxx001.setTdbm(device.getTdbm());
|
||||
sbxx001.setSbxh("警用设备");
|
||||
if (null != device.getDeviceType()){
|
||||
String zblx = getDeviceType(device.getDeviceType());
|
||||
sbxx001.setZblx(zblx);
|
||||
}else {
|
||||
sbxx001.setZblx("99");
|
||||
}
|
||||
sbxx001.setSsgajgjgdm(device.getZzjgdm());
|
||||
sbxx001.setCphm(strSub(device.getCarNum(),20));
|
||||
if (null != device.getPoliceNo() && !"".equals(device.getPoliceNo())){
|
||||
sbxx001.setJybh(device.getPoliceNo());
|
||||
}else{
|
||||
sbxx001.setJybh("000150");
|
||||
}
|
||||
if (null != device.getPoliceName() && !"".equals(device.getPoliceName())){
|
||||
sbxx001.setJyxm(strSub(device.getPoliceName(),20));
|
||||
}else {
|
||||
sbxx001.setJyxm("韦炜");
|
||||
}
|
||||
if (null != device.getPhoneNum() && !"".equals(device.getPhoneNum())){
|
||||
sbxx001.setLxdh(device.getPhoneNum());
|
||||
}else {
|
||||
sbxx001.setLxdh("15395136292");
|
||||
}
|
||||
if (null != device.getCardNum() && !"".equals(device.getCardNum())){
|
||||
sbxx001.setJysfz(device.getCardNum());
|
||||
}else {
|
||||
sbxx001.setJysfz("341125198507120019"); //没有使用韦科身份证代替
|
||||
}
|
||||
String onlineUsersKey = RedisConstants.ONLINE_USERS + format + ":" +
|
||||
device.getZzjgdm() + ":" + device.getDeviceType() +
|
||||
":" + device.getDeviceCode();
|
||||
Object obj = RedisUtils.getBucket(onlineUsersKey);
|
||||
if (null == obj){
|
||||
sbxx001.setSbsyzt("02");
|
||||
}else {
|
||||
JSONObject job = JSONUtil.parseObj(obj);
|
||||
String online = job.getStr("online");
|
||||
if ("1".equals(online)){
|
||||
sbxx001.setSbsyzt("01");
|
||||
}else {
|
||||
sbxx001.setSbsyzt("02");
|
||||
}
|
||||
}
|
||||
sbxx001.setSbsyzt("01");
|
||||
int valid = device.getValid();
|
||||
if (0 == valid){
|
||||
valid = 3;
|
||||
}else {
|
||||
valid = 2;
|
||||
}
|
||||
sbxx001.setSjczlxdm(valid+"");
|
||||
sbxx001.setSjly(device.getInfoSource()+"00");
|
||||
sbxx001.setLrsj(DateUtil.format(DateUtil.date(),"yyyyMMddHHmmss"));
|
||||
sbxx001.setLrdwdm(device.getZzjgdm());
|
||||
sbxx001.setLrdwmc(device.getZzjgmc());
|
||||
sbxx001.setLrrxm("");
|
||||
sbxx001.setLrrsfzh("");
|
||||
sbxx001.setXgsj(DateUtil.format(DateUtil.date(),"yyyyMMddHHmmss"));
|
||||
sbxx001.setXgdwdm(device.getZzjgdm());
|
||||
sbxx001.setXgdwmc(device.getZzjgmc());
|
||||
sbxx001.setXgrxm("");
|
||||
sbxx001.setXgrsfzh("");
|
||||
sbxx001.setXxzjbh(device.getId()+"");
|
||||
jylist.add(sbxx001);
|
||||
// jysbSbxx001Service.insertJbxx(sbxx001);
|
||||
}
|
||||
|
||||
count+= jysbSbxx001Service.insertManyJbxx(jylist);
|
||||
}
|
||||
log.info("更新的count={}",count);
|
||||
|
||||
}
|
||||
|
||||
public String getDeviceType(String deviceType){
|
||||
switch (deviceType){
|
||||
case "01" :
|
||||
deviceType = "01";
|
||||
break;
|
||||
case "02" :
|
||||
deviceType = "01";
|
||||
break;
|
||||
case "03" :
|
||||
deviceType = "06";
|
||||
break;
|
||||
case "04" :
|
||||
deviceType = "07";
|
||||
break;
|
||||
case "05" :
|
||||
deviceType = "08";
|
||||
break;
|
||||
case "06" :
|
||||
deviceType = "03";
|
||||
break;
|
||||
case "07" :
|
||||
deviceType = "10";
|
||||
break;
|
||||
case "08" :
|
||||
deviceType = "04";
|
||||
break;
|
||||
case "09" :
|
||||
deviceType = "09";
|
||||
break;
|
||||
default:
|
||||
deviceType = "99";
|
||||
}
|
||||
|
||||
return deviceType;
|
||||
}
|
||||
|
||||
public String strSub(String str,int le){
|
||||
if (null != str){
|
||||
if (str.length() > le){
|
||||
return str.substring(0,le);
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,135 @@
|
|||
package org.dromara.data2gs.schedule;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.dromara.common.redis.utils.RedisUtils;
|
||||
import org.dromara.data2gs.domain.EsGpsInfo;
|
||||
import org.dromara.data2gs.domain.JysbSbxx002;
|
||||
import org.dromara.data2gs.service.IJysbSbxx002Service;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
//@Configuration
|
||||
@Slf4j
|
||||
@RestController
|
||||
public class BasePoint2GasSchedule {
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(BasePoint2GasSchedule.class);
|
||||
|
||||
@Autowired
|
||||
IJysbSbxx002Service jysbSbxx002Service;
|
||||
|
||||
|
||||
|
||||
|
||||
@Scheduled( cron = "0 */15 * * * ?")
|
||||
public void deviceStatus(){
|
||||
String keys = "online_users:"+"*";
|
||||
// String keys = "online_users:*";
|
||||
List<JSONObject> list = RedisUtils.searchAndGetKeysValues(keys);
|
||||
List<JysbSbxx002> jlist = new ArrayList<>();
|
||||
for (JSONObject o : list) {
|
||||
EsGpsInfo info = BeanUtil.toBean(o, EsGpsInfo.class);
|
||||
if (!DateUtil.isSameDay(new Date(),info.getGpsTime())){
|
||||
continue;
|
||||
}
|
||||
JysbSbxx002 sbxx002 = new JysbSbxx002();
|
||||
sbxx002.setSbbh(strSub(info.getDeviceCode(),20) );
|
||||
sbxx002.setJd(info.getLng());
|
||||
sbxx002.setWd(info.getLat());
|
||||
sbxx002.setSpsd(info.getSpeed());
|
||||
sbxx002.setHjj("999");
|
||||
sbxx002.setGc(info.getHeight());
|
||||
sbxx002.setSbsykssj(DateUtil.format(DateUtil.beginOfDay(new Date()),"yyyyMMddHHmmss"));
|
||||
sbxx002.setSbsyjssj(DateUtil.format(DateUtil.endOfDay(new Date()),"yyyyMMddHHmmss"));
|
||||
sbxx002.setSjczlxdm("2");
|
||||
sbxx002.setSjly(info.getInfoSource()+"00");
|
||||
sbxx002.setLrsj(DateUtil.format(DateUtil.date(),"yyyyMMddHHmmss"));
|
||||
sbxx002.setLrdwdm(info.getZzjgdm());
|
||||
sbxx002.setLrdwmc(info.getZzjgmc());
|
||||
sbxx002.setLrrsfzh("");
|
||||
sbxx002.setXgsj(DateUtil.format(info.getGpsTime(),"yyyyMMddHHmmss"));
|
||||
sbxx002.setXgrsfzh("");
|
||||
if (info.getDeviceCode().length() == 20){
|
||||
sbxx002.setXxzjbh(info.getDeviceCode());
|
||||
}else {
|
||||
sbxx002.setXxzjbh(strSub(info.getDeviceCode(),16)+info.getInfoSource());
|
||||
}
|
||||
|
||||
jlist.add(sbxx002);
|
||||
}
|
||||
int flag = jysbSbxx002Service.insertManyPoint(distinctByKey(jlist));
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/point")
|
||||
public void pointSd(){
|
||||
String keys = "online_users:"+"*";
|
||||
// String keys = "online_users:*";
|
||||
List<JSONObject> list = RedisUtils.searchAndGetKeysValues(keys);
|
||||
List<JysbSbxx002> jlist = new ArrayList<>();
|
||||
for (JSONObject job : list) {
|
||||
EsGpsInfo info = BeanUtil.toBean(job, EsGpsInfo.class);
|
||||
JysbSbxx002 sbxx002 = new JysbSbxx002();
|
||||
sbxx002.setSbbh(strSub(info.getDeviceCode(),20) );
|
||||
sbxx002.setJd(strSub(info.getLng(),20) );
|
||||
sbxx002.setWd(strSub(info.getLat(),20) );
|
||||
sbxx002.setXgsj(DateUtil.format(info.getGpsTime(),"yyyyMMddHHmmss"));
|
||||
sbxx002.setXgrsfzh("");
|
||||
if (null !=info.getDeviceCode() && !"".equals(info.getDeviceCode())){
|
||||
if (info.getDeviceCode().length() == 20){
|
||||
sbxx002.setXxzjbh(info.getDeviceCode());
|
||||
}else {
|
||||
sbxx002.setXxzjbh(strSub(info.getDeviceCode(),16)+info.getInfoSource());
|
||||
}
|
||||
jlist.add(sbxx002);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int flag = jysbSbxx002Service.insertManyPoint(distinctByKey(jlist));
|
||||
// boolean flag = jysbSbxx002Service.saveOrUpdateBatch(jlist,500);
|
||||
log.info("插入结果={}",flag);
|
||||
}
|
||||
|
||||
public String strSub(String str,int le){
|
||||
if (null != str){
|
||||
if (str.length() > le){
|
||||
return str.substring(0,le);
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public List<JysbSbxx002> distinctByKey(List<JysbSbxx002> list){
|
||||
List<JysbSbxx002> newList = new ArrayList<JysbSbxx002>();
|
||||
|
||||
HashMap<String, String> map = new HashMap<String, String>();
|
||||
for (JysbSbxx002 user : list) {
|
||||
String deviceCode = user.getXxzjbh();
|
||||
String value = map.get(deviceCode);
|
||||
if (StringUtils.isBlank(value)) { //如果value是空的 说明取到的这个name是第一次取到
|
||||
map.put(deviceCode, deviceCode);
|
||||
newList.add(user); //newList就是我们想要的去重之后的结果
|
||||
}
|
||||
}
|
||||
|
||||
return newList;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
package org.dromara.data2gs.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.dromara.data2gs.domain.JysbSbxx001;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 警用设备基本信息Service接口
|
||||
*
|
||||
* @author luuy
|
||||
* @date 2024-12-07
|
||||
*/
|
||||
public interface IJysbSbxx001Service extends IService<JysbSbxx001> {
|
||||
|
||||
|
||||
int insertJbxx(JysbSbxx001 sbxx);
|
||||
|
||||
int insertManyJbxx(List<JysbSbxx001> list);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package org.dromara.data2gs.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.dromara.data2gs.domain.JysbSbxx002;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 警用设备基本信息Service接口
|
||||
*
|
||||
* @author luuy
|
||||
* @date 2024-12-07
|
||||
*/
|
||||
public interface IJysbSbxx002Service extends IService<JysbSbxx002> {
|
||||
|
||||
int insertManyPoint(List<JysbSbxx002> list);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package org.dromara.data2gs.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.dromara.data2gs.domain.NewDevice;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>description: </p>
|
||||
*
|
||||
* @author chenle
|
||||
* @date 2022-03-18 11:05
|
||||
*/
|
||||
public interface NewDeviceService extends IService<NewDevice> {
|
||||
|
||||
List<NewDevice> querylist(int pageNum,int pageSize);
|
||||
|
||||
List<NewDevice> pageList();
|
||||
}
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
package org.dromara.data2gs.service.impl;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import org.apache.ibatis.session.ExecutorType;
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.dromara.data2gs.domain.JysbSbxx001;
|
||||
import org.dromara.data2gs.mapper.JysbSbxx001Mapper;
|
||||
import org.dromara.data2gs.service.IJysbSbxx001Service;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@DS("slave")
|
||||
public class JysbSbxx001ServiceImpl extends ServiceImpl<JysbSbxx001Mapper, JysbSbxx001> implements IJysbSbxx001Service {
|
||||
|
||||
@Autowired
|
||||
JysbSbxx001Mapper baseMapper;
|
||||
|
||||
@Autowired
|
||||
SqlSessionFactory sqlSessionFactory;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean saveOrUpdateBatch(Collection<JysbSbxx001> entityList, int batchSize) {
|
||||
return super.saveOrUpdateBatch(entityList, batchSize);
|
||||
}
|
||||
|
||||
|
||||
public int insertJbxx(JysbSbxx001 jysbSbxx001) {
|
||||
return baseMapper.insertJbxx(jysbSbxx001);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertManyJbxx(List<JysbSbxx001> list) {
|
||||
int groupSize = 1000;
|
||||
int groupNo = list.size() / groupSize;
|
||||
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
|
||||
int num = 0;
|
||||
try {
|
||||
if (list.size() <= groupSize) {
|
||||
num += baseMapper.insertManyJbxx(list);
|
||||
} else {
|
||||
List<JysbSbxx001> subList=null;
|
||||
for (int i = 0; i < groupNo; i++) {
|
||||
subList = list.subList(0, groupSize);
|
||||
num += baseMapper.insertManyJbxx(subList);
|
||||
list.subList(0, groupSize).clear();
|
||||
}
|
||||
if (list.size() > 0) {
|
||||
num += baseMapper.insertManyJbxx(list);
|
||||
}
|
||||
}
|
||||
sqlSession.flushStatements();
|
||||
return num;
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
sqlSession.close();
|
||||
return num;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
package org.dromara.data2gs.service.impl;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.apache.ibatis.session.ExecutorType;
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.dromara.data2gs.domain.JysbSbxx002;
|
||||
import org.dromara.data2gs.mapper.JysbSbxx002Mapper;
|
||||
import org.dromara.data2gs.service.IJysbSbxx002Service;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@DS("slave")
|
||||
public class JysbSbxx002ServiceImpl extends ServiceImpl<JysbSbxx002Mapper, JysbSbxx002> implements IJysbSbxx002Service {
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(JysbSbxx002ServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
JysbSbxx002Mapper baseMapper;
|
||||
|
||||
@Autowired
|
||||
SqlSessionFactory sqlSessionFactory;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean saveOrUpdateBatch(Collection<JysbSbxx002> entityList, int batchSize) {
|
||||
return super.saveOrUpdateBatch(entityList, batchSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertManyPoint(List<JysbSbxx002> list) {
|
||||
int groupSize = 200;
|
||||
int groupNo = list.size() / groupSize;
|
||||
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
|
||||
int num = 0;
|
||||
try {
|
||||
if (list.size() <= groupSize) {
|
||||
num += baseMapper.insertManyPoint(list);
|
||||
} else {
|
||||
List<JysbSbxx002> subList=null;
|
||||
for (int i = 0; i < groupNo; i++) {
|
||||
subList = list.subList(0, groupSize);
|
||||
num += baseMapper.insertManyPoint(subList);
|
||||
list.subList(0, groupSize).clear();
|
||||
}
|
||||
if (list.size() > 0) {
|
||||
num += baseMapper.insertManyPoint(list);
|
||||
}
|
||||
}
|
||||
sqlSession.flushStatements();
|
||||
return num;
|
||||
}catch (Exception e){
|
||||
logger.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
sqlSession.close();
|
||||
return num;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
package org.dromara.data2gs.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.dromara.data2gs.domain.NewDevice;
|
||||
import org.dromara.data2gs.mapper.NewDeviceMapper;
|
||||
import org.dromara.data2gs.service.NewDeviceService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>description: </p>
|
||||
*
|
||||
* @author chenle
|
||||
* @date 2022-03-18 11:05
|
||||
*/
|
||||
@Service
|
||||
|
||||
public class NewDeviceServiceImpl extends ServiceImpl<NewDeviceMapper, NewDevice> implements NewDeviceService {
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(NewDeviceServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
NewDeviceMapper newDeviceMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public List<NewDevice> querylist(int pageNum,int pageSize) {
|
||||
// 计算开始索引
|
||||
int begin = pageNum * pageSize;
|
||||
// 计算查询条目数
|
||||
int size = pageSize;
|
||||
List<NewDevice> list = newDeviceMapper.selectsdList(begin,size);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NewDevice> pageList() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean save(NewDevice entity) {
|
||||
return super.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(NewDevice entity, Wrapper<NewDevice> updateWrapper) {
|
||||
return super.update(entity, updateWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Wrapper<NewDevice> wrapper) {
|
||||
return super.remove(wrapper);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
<?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.data2gs.mapper.JysbSbxx001Mapper">
|
||||
|
||||
<insert id="insertManyJbxx">
|
||||
insert into jysb_sbxx_001 (sbbh,sbpp,sbxh,zblx,ssgajgjgdm,cphm,jybh,jyxm,hh,lxdh,sbsyzt,bz,sjczlxdm,sjly,lrsj,lrdwdm,lrdwmc,lrrxm,lrrsfzh,
|
||||
xgsj,xgdwdm,xgdwmc,xgrxm,xgrsfzh,xxzjbh,gbbm,tdbm)
|
||||
values
|
||||
<foreach collection="list" item="i" separator=",">
|
||||
(
|
||||
#{i.sbbh},#{i.sbpp},#{i.sbxh},#{i.zblx},#{i.sbxh},#{i.ssgajgjgdm},#{i.jybh},#{i.jyxm},#{i.hh},#{i.sbxh},#{i.lxdh},#{i.sbsyzt},#{i.sjczlxdm},#{i.sjly}
|
||||
,#{i.lrsj},#{i.lrdwdm},#{i.lrdwmc},#{i.lrrxm},#{i.lrrsfzh},#{i.xgsj},#{i.xgdwdm},#{i.xgdwmc},#{i.xgrxm},#{i.xgrsfzh},#{i.xxzjbh},#{i.gbbm},#{i.tdbm}
|
||||
)
|
||||
</foreach>
|
||||
ON conflict(sbbh,zblx,sjly) do update set
|
||||
(ssgajgjgdm,cphm,jybh,jyxm,sbsyzt,sjczlxdm,xgsj) =
|
||||
(EXCLUDED.ssgajgjgdm,EXCLUDED.cphm,EXCLUDED.jybh,EXCLUDED.jyxm,EXCLUDED.sbsyzt,'2',EXCLUDED.xgsj)
|
||||
</insert>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<?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.data2gs.mapper.JysbSbxx002Mapper">
|
||||
|
||||
|
||||
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue