|
|
@ -1,24 +1,22 @@
|
|
|
|
package com.ssf.mysqloracletest.task;
|
|
|
|
package com.ssf.mysqloracletest.task;
|
|
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
import com.ssf.mysqloracletest.domain.JcjJjxxViewMysql;
|
|
|
|
import com.ssf.mysqloracletest.domain.JcjJjxxViewMysql;
|
|
|
|
import com.ssf.mysqloracletest.domain.MetaAlarmInfo;
|
|
|
|
import com.ssf.mysqloracletest.domain.MetaAlarmInfo;
|
|
|
|
import com.ssf.mysqloracletest.service.JcjJjxxViewMysqlService;
|
|
|
|
import com.ssf.mysqloracletest.service.JcjJjxxViewMysqlService;
|
|
|
|
import com.ssf.mysqloracletest.service.MetaAlarmInfoService;
|
|
|
|
import com.ssf.mysqloracletest.service.MetaAlarmInfoService;
|
|
|
|
import com.ssf.mysqloracletest.utils.ConfigParam;
|
|
|
|
import com.ssf.mysqloracletest.utils.ConfigParam;
|
|
|
|
import com.ssf.mysqloracletest.utils.NumKit;
|
|
|
|
|
|
|
|
import com.ssf.mysqloracletest.utils.StringKit;
|
|
|
|
import com.ssf.mysqloracletest.utils.StringKit;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
import java.util.concurrent.CountDownLatch;
|
|
|
|
import java.util.concurrent.CountDownLatch;
|
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
|
import java.util.concurrent.Executors;
|
|
|
|
import java.util.concurrent.Executors;
|
|
|
@ -37,9 +35,6 @@ public class AlarmInfoTask {
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private MetaAlarmInfoService alarmInfoService;
|
|
|
|
private MetaAlarmInfoService alarmInfoService;
|
|
|
|
|
|
|
|
|
|
|
|
final int oncesCounts = NumKit.checkInt(ConfigParam.oncesCounts) == 0 ? 10000 : NumKit.checkInt(ConfigParam.oncesCounts);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean NjjxxTag = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 连云港 对接海康平台获取人员基础数据
|
|
|
|
* 连云港 对接海康平台获取人员基础数据
|
|
|
@ -48,104 +43,99 @@ public class AlarmInfoTask {
|
|
|
|
@Scheduled(initialDelay = 100, fixedDelay = 3000)
|
|
|
|
@Scheduled(initialDelay = 100, fixedDelay = 3000)
|
|
|
|
public void transNjjxx() {
|
|
|
|
public void transNjjxx() {
|
|
|
|
|
|
|
|
|
|
|
|
if (NjjxxTag) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!"true".equals(ConfigParam.NewNalarminfoSwitch)) {
|
|
|
|
if (!"true".equals(ConfigParam.NewNalarminfoSwitch)) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
int countNjjxx = jjxxViewMysqlService.count();
|
|
|
|
QueryWrapper<JcjJjxxViewMysql> queryWrapper = new QueryWrapper<>();
|
|
|
|
logger.info("countNjjxx:" + countNjjxx);
|
|
|
|
queryWrapper.isNull("STATUS");
|
|
|
|
|
|
|
|
Page<JcjJjxxViewMysql> page = new Page<>(1, 1000);
|
|
|
|
if (countNjjxx > 0) {
|
|
|
|
List<JcjJjxxViewMysql> resultList = jjxxViewMysqlService.page(page, queryWrapper).getRecords();
|
|
|
|
|
|
|
|
|
|
|
|
NjjxxTag = true;
|
|
|
|
CountDownLatch latch = new CountDownLatch(resultList.size());
|
|
|
|
|
|
|
|
ExecutorService JjxxPool = Executors.newFixedThreadPool(5);
|
|
|
|
int count = countNjjxx / oncesCounts;
|
|
|
|
for (JcjJjxxViewMysql bean : resultList) {
|
|
|
|
CountDownLatch latch = new CountDownLatch(count);
|
|
|
|
JjxxPool.submit(() -> {
|
|
|
|
ExecutorService NjjxxPool = Executors.newFixedThreadPool(50);
|
|
|
|
cleanJjxx(bean);
|
|
|
|
|
|
|
|
logger.info("清洗完成");
|
|
|
|
for (int i = 0; i <= count; i++) {
|
|
|
|
latch.countDown();
|
|
|
|
Map NjjxxMap = new HashMap();
|
|
|
|
});
|
|
|
|
NjjxxMap.put("rowStart", i * oncesCounts);
|
|
|
|
|
|
|
|
NjjxxMap.put("rowEnd", (i + 1) * oncesCounts);
|
|
|
|
|
|
|
|
NjjxxPool.submit(() -> {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
List<JcjJjxxViewMysql> Njjxxs = jjxxViewMysqlService.lambdaQuery().list();
|
|
|
|
|
|
|
|
for (JcjJjxxViewMysql Njjxx : Njjxxs) {
|
|
|
|
|
|
|
|
MetaAlarmInfo alarmInfo = new MetaAlarmInfo();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//设置目标字段的值
|
|
|
|
|
|
|
|
//alarm_code<-----JJBH 接警编号
|
|
|
|
|
|
|
|
alarmInfo.setAlarmCode(Njjxx.getJJBH());
|
|
|
|
|
|
|
|
//police_receiver_name<-----JJRXM接警人姓名
|
|
|
|
|
|
|
|
alarmInfo.setPoliceReceiverName(Njjxx.getJJRXM());
|
|
|
|
|
|
|
|
//alarm_response_time<-----JJRQSJ接警日期时间
|
|
|
|
|
|
|
|
alarmInfo.setAlarmResponseTime(Njjxx.getJJRQSJ());
|
|
|
|
|
|
|
|
//alarm_response_content<-----BJNR接警报警内容
|
|
|
|
|
|
|
|
alarmInfo.setAlarmResponseContent(Njjxx.getBJNR());
|
|
|
|
|
|
|
|
//informant_name<-----BJR接警报警人
|
|
|
|
|
|
|
|
alarmInfo.setInformantName(Njjxx.getBJR());
|
|
|
|
|
|
|
|
//informant_time<-----BJDHSJ接警报警时间
|
|
|
|
|
|
|
|
alarmInfo.setInformantTime(Njjxx.getBJDHSJ());
|
|
|
|
|
|
|
|
//informant_phone<-----LXDH接警报警人联系电话
|
|
|
|
|
|
|
|
alarmInfo.setInformantPhone(Njjxx.getLXDH());
|
|
|
|
|
|
|
|
//alarm_response_type<-----BJLXMC报警类型名称
|
|
|
|
|
|
|
|
alarmInfo.setAlarmResponseTypeName(Njjxx.getBJLXMC());
|
|
|
|
|
|
|
|
//alarm_address<-----SFDD接警事发地址
|
|
|
|
|
|
|
|
alarmInfo.setAlarmAddress(Njjxx.getSFDD());
|
|
|
|
|
|
|
|
//alarm_response_unit<-----JJDWMC接警单位名称
|
|
|
|
|
|
|
|
alarmInfo.setAlarmResponseUnit(Njjxx.getJJDWMC());
|
|
|
|
|
|
|
|
if (Njjxx != null && Njjxx.getWDZB() != null && Njjxx.getJDZB() != null) {
|
|
|
|
|
|
|
|
//转换类型
|
|
|
|
|
|
|
|
BigDecimal WDZBDecimal = new BigDecimal(Njjxx.getWDZB());
|
|
|
|
|
|
|
|
BigDecimal JDZBDecimal = new BigDecimal(Njjxx.getJDZB());
|
|
|
|
|
|
|
|
//longitude(经度)<-----JDZB经度坐标
|
|
|
|
|
|
|
|
alarmInfo.setLongitude(JDZBDecimal);
|
|
|
|
|
|
|
|
//latitude(纬度)<-----WDZB纬度坐标
|
|
|
|
|
|
|
|
alarmInfo.setLatitude(WDZBDecimal);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
//longitude(经度)<-----JDZB经度坐标
|
|
|
|
|
|
|
|
alarmInfo.setLongitude(null);
|
|
|
|
|
|
|
|
//latitude(纬度)<-----WDZB纬度坐标
|
|
|
|
|
|
|
|
alarmInfo.setLatitude(null);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//确定一个数据是否唯一
|
|
|
|
|
|
|
|
MetaAlarmInfo one = alarmInfoService.lambdaQuery().eq(MetaAlarmInfo::getAlarmCode, Njjxx.getJJBH()).one();
|
|
|
|
|
|
|
|
if (one == null) {
|
|
|
|
|
|
|
|
alarmInfoService.save(alarmInfo);
|
|
|
|
|
|
|
|
logger.info("Njjxx-" + Njjxx.getJJBH() + ":插入成功");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
alarmInfoService.update(alarmInfo,new UpdateWrapper<>(alarmInfo));
|
|
|
|
|
|
|
|
logger.info("Njjxx-" + Njjxx.getJJBH() + ":更新成功");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
logger.info("Njjxxs:" + StringKit.getTrace(e));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
latch.countDown();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
logger.info("NjjxxMap数据总量:" + countNjjxx + "," + "当前处理下标:" + NjjxxMap.get("rowStart") + "/" + NjjxxMap.get("rowEnd"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
// Wait for all threads to complete
|
|
|
|
|
|
|
|
latch.await();
|
|
|
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 关闭线程池
|
|
|
|
|
|
|
|
NjjxxPool.shutdown();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
// Wait for all threads to complete
|
|
|
|
|
|
|
|
latch.await();
|
|
|
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 关闭线程池
|
|
|
|
|
|
|
|
JjxxPool.shutdown();
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
logger.info(StringKit.getTrace(e));
|
|
|
|
logger.info(StringKit.getTrace(e));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void cleanJjxx(JcjJjxxViewMysql bean) {
|
|
|
|
|
|
|
|
JcjJjxxViewMysql jjxxViewMysqlCp = new JcjJjxxViewMysql();
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
BeanUtils.copyProperties(bean, jjxxViewMysqlCp);
|
|
|
|
|
|
|
|
MetaAlarmInfo alarmInfo = new MetaAlarmInfo();
|
|
|
|
|
|
|
|
//设置目标字段的值
|
|
|
|
|
|
|
|
//alarm_code<-----JJBH 接警编号
|
|
|
|
|
|
|
|
alarmInfo.setAlarmCode(jjxxViewMysqlCp.getJJBH());
|
|
|
|
|
|
|
|
//police_receiver_name<-----JJRXM接警人姓名
|
|
|
|
|
|
|
|
alarmInfo.setPoliceReceiverName(jjxxViewMysqlCp.getJJRXM());
|
|
|
|
|
|
|
|
//alarm_response_time<-----JJRQSJ接警日期时间
|
|
|
|
|
|
|
|
alarmInfo.setAlarmResponseTime(jjxxViewMysqlCp.getJJRQSJ());
|
|
|
|
|
|
|
|
//alarm_response_content<-----BJNR接警报警内容
|
|
|
|
|
|
|
|
alarmInfo.setAlarmResponseContent(jjxxViewMysqlCp.getBJNR());
|
|
|
|
|
|
|
|
//informant_name<-----BJR接警报警人
|
|
|
|
|
|
|
|
alarmInfo.setInformantName(jjxxViewMysqlCp.getBJR());
|
|
|
|
|
|
|
|
//informant_time<-----BJDHSJ接警报警时间
|
|
|
|
|
|
|
|
alarmInfo.setInformantTime(jjxxViewMysqlCp.getBJDHSJ());
|
|
|
|
|
|
|
|
//informant_phone<-----LXDH接警报警人联系电话
|
|
|
|
|
|
|
|
alarmInfo.setInformantPhone(jjxxViewMysqlCp.getLXDH());
|
|
|
|
|
|
|
|
//alarm_response_type<-----BJLXMC报警类型名称
|
|
|
|
|
|
|
|
alarmInfo.setAlarmResponseTypeName(jjxxViewMysqlCp.getBJLXMC());
|
|
|
|
|
|
|
|
//alarm_address<-----SFDD接警事发地址
|
|
|
|
|
|
|
|
alarmInfo.setAlarmAddress(jjxxViewMysqlCp.getSFDD());
|
|
|
|
|
|
|
|
//alarm_response_unit<-----JJDWMC接警单位名称
|
|
|
|
|
|
|
|
alarmInfo.setAlarmResponseUnit(jjxxViewMysqlCp.getJJDWMC());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (jjxxViewMysqlCp.getWDZB() != null) {
|
|
|
|
|
|
|
|
//转换类型
|
|
|
|
|
|
|
|
BigDecimal WDZBDecimal = new BigDecimal(jjxxViewMysqlCp.getWDZB());
|
|
|
|
|
|
|
|
//latitude(纬度)<-----WDZB纬度坐标
|
|
|
|
|
|
|
|
alarmInfo.setLatitude(WDZBDecimal);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
//latitude(纬度)<-----WDZB纬度坐标
|
|
|
|
|
|
|
|
alarmInfo.setLatitude(null);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (jjxxViewMysqlCp.getJDZB() != null) {
|
|
|
|
|
|
|
|
BigDecimal JDZBDecimal = new BigDecimal(jjxxViewMysqlCp.getJDZB());
|
|
|
|
|
|
|
|
//longitude(经度)<-----JDZB经度坐标
|
|
|
|
|
|
|
|
alarmInfo.setLatitude(JDZBDecimal);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
//longitude(经度)<-----JDZB经度坐标
|
|
|
|
|
|
|
|
alarmInfo.setLongitude(null);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boolean b = alarmInfoService.save(alarmInfo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (b) {
|
|
|
|
|
|
|
|
jjxxViewMysqlCp.setSTATUS("1");
|
|
|
|
|
|
|
|
jjxxViewMysqlService.updateJjxxByJJBH(jjxxViewMysqlCp);
|
|
|
|
|
|
|
|
logger.info("状态修改为:1");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
logger.info(StringKit.getTrace(e));
|
|
|
|
|
|
|
|
jjxxViewMysqlCp.setSTATUS("2");
|
|
|
|
|
|
|
|
jjxxViewMysqlService.updateJjxxByJJBH(jjxxViewMysqlCp);
|
|
|
|
|
|
|
|
logger.info("状态修改为:2");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|