|
|
|
@ -1,24 +1,22 @@
|
|
|
|
|
package com.ssf.mysqloracletest.task;
|
|
|
|
|
|
|
|
|
|
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.MetaActualUnitInfo;
|
|
|
|
|
import com.ssf.mysqloracletest.domain.VSySydwmMysql;
|
|
|
|
|
import com.ssf.mysqloracletest.service.MetaActualUnitInfoService;
|
|
|
|
|
import com.ssf.mysqloracletest.service.VSySydwMysqlService;
|
|
|
|
|
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.beans.BeanUtils;
|
|
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
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;
|
|
|
|
@ -37,10 +35,6 @@ public class UnitInfoTask {
|
|
|
|
|
@Resource
|
|
|
|
|
private MetaActualUnitInfoService metaActualUnitInfoService;
|
|
|
|
|
|
|
|
|
|
final int oncesCounts = NumKit.checkInt(ConfigParam.oncesCounts) == 0 ? 10000 : NumKit.checkInt(ConfigParam.oncesCounts);
|
|
|
|
|
|
|
|
|
|
private boolean NsydwTag = false;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 连云港 对接海康平台获取人员基础数据
|
|
|
|
|
* //
|
|
|
|
@ -48,104 +42,89 @@ public class UnitInfoTask {
|
|
|
|
|
@Scheduled(initialDelay = 100, fixedDelay = 3000)
|
|
|
|
|
public void transNsydw() {
|
|
|
|
|
|
|
|
|
|
if (NsydwTag) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!"true".equals(ConfigParam.NewNsydwSwitch)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
int countNsydw = vSySydwMysqlService.count();
|
|
|
|
|
logger.info("countNsydw:" + countNsydw);
|
|
|
|
|
|
|
|
|
|
if (countNsydw > 0) {
|
|
|
|
|
|
|
|
|
|
NsydwTag = true;
|
|
|
|
|
QueryWrapper<VSySydwmMysql> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
queryWrapper.isNull("STATUS");
|
|
|
|
|
Page<VSySydwmMysql> page = new Page<>(1, 1000);
|
|
|
|
|
List<VSySydwmMysql> resultList = vSySydwMysqlService.page(page, queryWrapper).getRecords();
|
|
|
|
|
|
|
|
|
|
CountDownLatch latch = new CountDownLatch(resultList.size());
|
|
|
|
|
ExecutorService NsydwPool = Executors.newFixedThreadPool(5);
|
|
|
|
|
for (VSySydwmMysql bean : resultList) {
|
|
|
|
|
NsydwPool.submit(() -> {
|
|
|
|
|
cleanSydw(bean);
|
|
|
|
|
logger.info("清洗完成");
|
|
|
|
|
latch.countDown();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int count = countNsydw / oncesCounts;
|
|
|
|
|
CountDownLatch latch = new CountDownLatch(count);
|
|
|
|
|
ExecutorService NsydwPool = Executors.newFixedThreadPool(50);
|
|
|
|
|
try {
|
|
|
|
|
// Wait for all threads to complete
|
|
|
|
|
latch.await();
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
// 关闭线程池
|
|
|
|
|
NsydwPool.shutdown();
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.info(StringKit.getTrace(e));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i <= count; i++) {
|
|
|
|
|
Map NsydwMap = new HashMap();
|
|
|
|
|
NsydwMap.put("rowStart", i * oncesCounts);
|
|
|
|
|
NsydwMap.put("rowEnd", (i + 1) * oncesCounts);
|
|
|
|
|
NsydwPool.submit(() -> {
|
|
|
|
|
private void cleanSydw(VSySydwmMysql bean) {
|
|
|
|
|
VSySydwmMysql sydwMysqlCp = new VSySydwmMysql();
|
|
|
|
|
try {
|
|
|
|
|
List<VSySydwmMysql> Nsydws = vSySydwMysqlService.lambdaQuery().list();
|
|
|
|
|
for (VSySydwmMysql Nsydw : Nsydws) {
|
|
|
|
|
BeanUtils.copyProperties(bean, sydwMysqlCp);
|
|
|
|
|
MetaActualUnitInfo unitInfo = new MetaActualUnitInfo();
|
|
|
|
|
int unit = Integer.parseInt(Nsydw.getDWZT());
|
|
|
|
|
BigDecimal XDecimal = new BigDecimal(Nsydw.getX());
|
|
|
|
|
BigDecimal YDecimal = new BigDecimal(Nsydw.getY());
|
|
|
|
|
//设置目标字段的值
|
|
|
|
|
//ID(id)----->unit_id(单位ID)
|
|
|
|
|
unitInfo.setUnitId(Nsydw.getID());
|
|
|
|
|
unitInfo.setUnitId(sydwMysqlCp.getID());
|
|
|
|
|
//DWMC(单位名称)----->unit_name(单位名称)
|
|
|
|
|
unitInfo.setUintName(Nsydw.getDWMC());
|
|
|
|
|
unitInfo.setUintName(sydwMysqlCp.getDWMC());
|
|
|
|
|
//DZ(地址)----->unit_address(单位地址)
|
|
|
|
|
unitInfo.setUintAddress(Nsydw.getDZ());
|
|
|
|
|
unitInfo.setUintAddress(sydwMysqlCp.getDZ());
|
|
|
|
|
//LXDH(联系电话)----->phone(联系电话)
|
|
|
|
|
unitInfo.setPhone(Nsydw.getLXDH());
|
|
|
|
|
unitInfo.setPhone(sydwMysqlCp.getLXDH());
|
|
|
|
|
//PCSBM(派出所编码)----->police_station_code(派出所代码)
|
|
|
|
|
unitInfo.setPoliceStationCode(Nsydw.getPCSBM());
|
|
|
|
|
unitInfo.setPoliceStationCode(sydwMysqlCp.getPCSBM());
|
|
|
|
|
//PCSMC(派出所名称)----->police_station_name(派出所名称)
|
|
|
|
|
unitInfo.setPoliceStationName(Nsydw.getPCSMC());
|
|
|
|
|
unitInfo.setPoliceStationName(sydwMysqlCp.getPCSMC());
|
|
|
|
|
//JWQBM(警务区编码)----->police_district_code(警务区编码)
|
|
|
|
|
unitInfo.setPoliceDistrictCode(Nsydw.getJWQBM());
|
|
|
|
|
//JWQMC(警务区名称)----->police_district_code(警务区名称)
|
|
|
|
|
unitInfo.setPoliceDistrictCode(Nsydw.getDWMC());
|
|
|
|
|
unitInfo.setPoliceDistrictCode(sydwMysqlCp.getJWQBM());
|
|
|
|
|
//JWQMC(警务区名称)----->police_district_name(警务区名称)
|
|
|
|
|
unitInfo.setPoliceDistrictName(sydwMysqlCp.getJWQMC());
|
|
|
|
|
//DWZT(单位状态 1有效)----->unit_state(单位状态 1有效)
|
|
|
|
|
unitInfo.setUnitState(unit);
|
|
|
|
|
unitInfo.setUnitState(Integer.parseInt(sydwMysqlCp.getDWZT()));
|
|
|
|
|
//X(经度)----->longitude(经度)
|
|
|
|
|
unitInfo.setLongitude(XDecimal);
|
|
|
|
|
unitInfo.setLongitude(new BigDecimal(sydwMysqlCp.getX()));
|
|
|
|
|
//Y(纬度)----->latitude(纬度)
|
|
|
|
|
unitInfo.setLatitude(YDecimal);
|
|
|
|
|
unitInfo.setLatitude(new BigDecimal(sydwMysqlCp.getY()));
|
|
|
|
|
//DWLXMC(单位类型名称)----->unit_type_name(单位类型名称)
|
|
|
|
|
unitInfo.setUnitTypeName(Nsydw.getDWLXMC());
|
|
|
|
|
unitInfo.setUnitTypeName(sydwMysqlCp.getDWLXMC());
|
|
|
|
|
//FRZJHM(法人证件号码)----->legal_person_id_card
|
|
|
|
|
unitInfo.setLegalPersonIdCard(Nsydw.getFRZJHM());
|
|
|
|
|
unitInfo.setLegalPersonIdCard(sydwMysqlCp.getFRZJHM());
|
|
|
|
|
//FRXM(法人姓名)----->legal_person(企业法定代表人)
|
|
|
|
|
unitInfo.setLegalPerson(Nsydw.getFRXM());
|
|
|
|
|
unitInfo.setLegalPerson(sydwMysqlCp.getFRXM());
|
|
|
|
|
//YSBZK_RKSJ(入库时间)----->meta_create_time(元数据创建时间)
|
|
|
|
|
unitInfo.setMetaCreateTime(Nsydw.getYSBZK_RKSJ());
|
|
|
|
|
unitInfo.setMetaCreateTime(sydwMysqlCp.getYSBZK_RKSJ());
|
|
|
|
|
//YSBZK_GXSJ(更新时间)----->meta_update_time(元数据更新时间)
|
|
|
|
|
unitInfo.setMetaUpdateTime(Nsydw.getYSBZK_GXSJ());
|
|
|
|
|
//确定一个数据是否唯一
|
|
|
|
|
MetaActualUnitInfo one = metaActualUnitInfoService.lambdaQuery().eq(MetaActualUnitInfo::getUnitId,Nsydw.getID()).one();
|
|
|
|
|
if (one == null) {
|
|
|
|
|
metaActualUnitInfoService.save(unitInfo);
|
|
|
|
|
logger.info("Nsydw-" + Nsydw.getID() + ":插入成功");
|
|
|
|
|
} else {
|
|
|
|
|
metaActualUnitInfoService.update(unitInfo,new UpdateWrapper<>(unitInfo));
|
|
|
|
|
logger.info("Nsydw-" + Nsydw.getID() + ":更新成功");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.info("Nsydws:" + StringKit.getTrace(e));
|
|
|
|
|
}
|
|
|
|
|
latch.countDown();
|
|
|
|
|
});
|
|
|
|
|
logger.info("NsydwMap数据总量:" + countNsydw + "," + "当前处理下标:" + NsydwMap.get("rowStart") + "/" + NsydwMap.get("rowEnd"));
|
|
|
|
|
}
|
|
|
|
|
unitInfo.setMetaUpdateTime(sydwMysqlCp.getYSBZK_GXSJ());
|
|
|
|
|
boolean b = metaActualUnitInfoService.save(unitInfo);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
// Wait for all threads to complete
|
|
|
|
|
latch.await();
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
if (b) {
|
|
|
|
|
sydwMysqlCp.setSTATUS("1");
|
|
|
|
|
vSySydwMysqlService.updateVSySydwById(sydwMysqlCp);
|
|
|
|
|
logger.info("状态修改为:1");
|
|
|
|
|
}
|
|
|
|
|
// 关闭线程池
|
|
|
|
|
NsydwPool.shutdown();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.info(StringKit.getTrace(e));
|
|
|
|
|
sydwMysqlCp.setSTATUS("2");
|
|
|
|
|
vSySydwMysqlService.updateVSySydwById(sydwMysqlCp);
|
|
|
|
|
logger.info("状态修改为:2");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|