commit
a3cbb726f1
@ -0,0 +1,90 @@
|
||||
package com.ssf.mysqloracletest.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 java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 处警信息表
|
||||
* @TableName meta_handle_alarm_info
|
||||
*/
|
||||
@TableName(value ="meta_handle_alarm_info")
|
||||
@Data
|
||||
public class MetaHandleAlarmInfo implements Serializable {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 警情编码
|
||||
*/
|
||||
private String alarmCode;
|
||||
/**
|
||||
* 处警单位名称
|
||||
*/
|
||||
private String handleAlarmUnit;
|
||||
|
||||
/**
|
||||
* 处警时间
|
||||
*/
|
||||
private String handleAlarmTime;
|
||||
|
||||
/**
|
||||
* 处警简要警情
|
||||
*/
|
||||
private String handleAlarmContent;
|
||||
|
||||
/**
|
||||
* 处警详细地点
|
||||
*/
|
||||
private String handleAlarmAddress;
|
||||
|
||||
/**
|
||||
* 处警人姓名
|
||||
*/
|
||||
private String handleAlarmUser;
|
||||
|
||||
/**
|
||||
* 处境人姓名和编码
|
||||
*/
|
||||
private String handleAlarmUserCode;
|
||||
|
||||
/**
|
||||
* 处警结果
|
||||
*/
|
||||
private String handleAlarmResult;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 创建者
|
||||
*/
|
||||
private Integer createBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 更新者
|
||||
*/
|
||||
private Integer updateBy;
|
||||
|
||||
/**
|
||||
* 0:不活跃,1:活跃
|
||||
*/
|
||||
private Integer isActive;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.ssf.mysqloracletest.mapper;
|
||||
|
||||
import com.ssf.mysqloracletest.domain.MetaHandleAlarmInfo;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @author 28758
|
||||
* @description 针对表【meta_handle_alarm_info(处警信息表)】的数据库操作Mapper
|
||||
* @createDate 2023-12-01 19:02:18
|
||||
* @Entity com.ssf.mysqloracletest.domain.MetaHandleAlarmInfo
|
||||
*/
|
||||
public interface MetaHandleAlarmInfoMapper extends BaseMapper<MetaHandleAlarmInfo> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,13 @@
|
||||
package com.ssf.mysqloracletest.service;
|
||||
|
||||
import com.ssf.mysqloracletest.domain.MetaHandleAlarmInfo;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @author 28758
|
||||
* @description 针对表【meta_handle_alarm_info(处警信息表)】的数据库操作Service
|
||||
* @createDate 2023-12-01 19:02:18
|
||||
*/
|
||||
public interface MetaHandleAlarmInfoService extends IService<MetaHandleAlarmInfo> {
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.ssf.mysqloracletest.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ssf.mysqloracletest.domain.MetaHandleAlarmInfo;
|
||||
import com.ssf.mysqloracletest.service.MetaHandleAlarmInfoService;
|
||||
import com.ssf.mysqloracletest.mapper.MetaHandleAlarmInfoMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author 28758
|
||||
* @description 针对表【meta_handle_alarm_info(处警信息表)】的数据库操作Service实现
|
||||
* @createDate 2023-12-01 19:02:18
|
||||
*/
|
||||
@Service
|
||||
public class MetaHandleAlarmInfoServiceImpl extends ServiceImpl<MetaHandleAlarmInfoMapper, MetaHandleAlarmInfo>
|
||||
implements MetaHandleAlarmInfoService{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,122 @@
|
||||
package com.ssf.mysqloracletest.task;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.ssf.mysqloracletest.domain.JcjCjxxViewMysql;
|
||||
import com.ssf.mysqloracletest.domain.MetaHandleAlarmInfo;
|
||||
import com.ssf.mysqloracletest.service.JcjCjxxViewMysqlService;
|
||||
import com.ssf.mysqloracletest.service.MetaHandleAlarmInfoService;
|
||||
import com.ssf.mysqloracletest.service.MetaImpUserInfoService;
|
||||
import com.ssf.mysqloracletest.utils.ConfigParam;
|
||||
import com.ssf.mysqloracletest.utils.NumKit;
|
||||
import com.ssf.mysqloracletest.utils.StringKit;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
/**
|
||||
* 用户数据接入
|
||||
*/
|
||||
@Component
|
||||
public class MetaHandleAlarmTask {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(MetaHandleAlarmTask.class);
|
||||
|
||||
@Resource
|
||||
private MetaHandleAlarmInfoService metaHandleAlarmInfoService;
|
||||
|
||||
@Resource
|
||||
private JcjCjxxViewMysqlService jcjCjxxViewMysqlService;
|
||||
|
||||
final int oncesCounts = NumKit.checkInt(ConfigParam.oncesCounts) == 0 ? 1000 : NumKit.checkInt(ConfigParam.oncesCounts);
|
||||
|
||||
private boolean cjxxTag = false;
|
||||
|
||||
/**
|
||||
* 连云港 对接海康平台获取人员基础数据
|
||||
* //
|
||||
*/
|
||||
@Scheduled(initialDelay = 100, fixedDelay = 3000)
|
||||
public void transcjxx() {
|
||||
|
||||
if (cjxxTag) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!"true".equals(ConfigParam.metaHandleAlarmSwitch)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
int countcjxx = jcjCjxxViewMysqlService.count();
|
||||
logger.info("countcjxx:" + countcjxx);
|
||||
|
||||
if (countcjxx > 0) {
|
||||
|
||||
cjxxTag = true;
|
||||
|
||||
int count = countcjxx / oncesCounts;
|
||||
CountDownLatch latch = new CountDownLatch(count);
|
||||
ExecutorService cjxxPool = Executors.newFixedThreadPool(50);
|
||||
|
||||
for (int i = 0; i <= count; i++) {
|
||||
Map cjxxMap = new HashMap();
|
||||
cjxxMap.put("rowStart", i * oncesCounts);
|
||||
cjxxMap.put("rowEnd", (i + 1) * oncesCounts);
|
||||
cjxxPool.submit(() -> {
|
||||
try {
|
||||
List<JcjCjxxViewMysql> list = jcjCjxxViewMysqlService.lambdaQuery().list();
|
||||
for (JcjCjxxViewMysql cjxx : list) {
|
||||
MetaHandleAlarmInfo metaHandleAlarmInfo = new MetaHandleAlarmInfo();
|
||||
metaHandleAlarmInfo.setAlarmCode(cjxx.getCJBH());
|
||||
metaHandleAlarmInfo.setHandleAlarmUnit(cjxx.getCJDWMC());
|
||||
metaHandleAlarmInfo.setHandleAlarmTime(cjxx.getCJSJ());
|
||||
metaHandleAlarmInfo.setHandleAlarmContent(cjxx.getCLJGNR());
|
||||
metaHandleAlarmInfo.setHandleAlarmAddress(cjxx.getCJXXDD());
|
||||
metaHandleAlarmInfo.setHandleAlarmUser(cjxx.getCJRHZXS());
|
||||
metaHandleAlarmInfo.setHandleAlarmUserCode(cjxx.getCJR());
|
||||
metaHandleAlarmInfo.setHandleAlarmResult(cjxx.getCJJGMC());
|
||||
//确定一个数据是否唯一
|
||||
MetaHandleAlarmInfo one = metaHandleAlarmInfoService.lambdaQuery().eq(MetaHandleAlarmInfo::getAlarmCode, cjxx.getCJBH()).one();
|
||||
if (one == null) {
|
||||
metaHandleAlarmInfoService.save(metaHandleAlarmInfo);
|
||||
logger.info("cjxx-" + cjxx.getCJBH() + ":插入成功");
|
||||
} else {
|
||||
metaHandleAlarmInfoService.update(metaHandleAlarmInfo,new UpdateWrapper<>(metaHandleAlarmInfo));
|
||||
logger.info("cjxx-" + cjxx.getCJBH() + ":更新成功");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.info("cjxxs:" + e.getMessage());
|
||||
}
|
||||
latch.countDown();
|
||||
});
|
||||
logger.info("cjxxMap数据总量:" + countcjxx + "," + "当前处理下标:" + cjxxMap.get("rowStart") + "/" + cjxxMap.get("rowEnd"));
|
||||
}
|
||||
|
||||
try {
|
||||
// Wait for all threads to complete
|
||||
latch.await();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// 关闭线程池
|
||||
cjxxPool.shutdown();
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.info(StringKit.getTrace(e));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in new issue