|
|
|
@ -1,40 +1,44 @@
|
|
|
|
|
package com.ssf.mysqloracletest.task;
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
|
|
import com.ssf.mysqloracletest.domain.MetaImpUserInfo;
|
|
|
|
|
import com.ssf.mysqloracletest.domain.ZhxfZdrygkRyjbxxViewMysql;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
import com.ssf.mysqloracletest.domain.*;
|
|
|
|
|
import com.ssf.mysqloracletest.service.MetaImpUserInfoService;
|
|
|
|
|
import com.ssf.mysqloracletest.service.VillageActualUserInfoService;
|
|
|
|
|
import com.ssf.mysqloracletest.service.ZhxfZdrygkRyjbxxViewMysqlService;
|
|
|
|
|
import com.ssf.mysqloracletest.utils.ConfigParam;
|
|
|
|
|
import com.ssf.mysqloracletest.utils.NumKit;
|
|
|
|
|
import com.ssf.mysqloracletest.utils.StringKit;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
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.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
|
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
|
public class MetaImpUserInfoTask {
|
|
|
|
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(MetaImpUserInfoTask.class);
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private ZhxfZdrygkRyjbxxViewMysqlService zdryMysqlService;
|
|
|
|
|
private final ZhxfZdrygkRyjbxxViewMysqlService zdryMysqlService;
|
|
|
|
|
private final MetaImpUserInfoService metaImpUserInfoService;
|
|
|
|
|
private final VillageActualUserInfoService actualUserInfoService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private MetaImpUserInfoService metaImpUserInfoService;
|
|
|
|
|
|
|
|
|
|
final int oncesCounts = NumKit.checkInt(ConfigParam.oncesCounts) == 0 ? 1000 : NumKit.checkInt(ConfigParam.oncesCounts);
|
|
|
|
|
|
|
|
|
|
private boolean zdryTag = false;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 连云港 对接海康平台获取人员基础数据
|
|
|
|
@ -46,70 +50,76 @@ public class MetaImpUserInfoTask {
|
|
|
|
|
if (!"true".equals(ConfigParam.metaImpUserSwitch)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
QueryWrapper<ZhxfZdrygkRyjbxxViewMysql> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
queryWrapper.isNull("status");
|
|
|
|
|
Page<ZhxfZdrygkRyjbxxViewMysql> page = new Page<>(1, 1000);
|
|
|
|
|
List<ZhxfZdrygkRyjbxxViewMysql> resultList = zdryMysqlService.page(page, queryWrapper).getRecords();
|
|
|
|
|
|
|
|
|
|
CountDownLatch latch = new CountDownLatch(resultList.size());
|
|
|
|
|
ExecutorService impUserPool = Executors.newFixedThreadPool(5);
|
|
|
|
|
|
|
|
|
|
for (ZhxfZdrygkRyjbxxViewMysql bean : resultList) {
|
|
|
|
|
impUserPool.submit(() -> {
|
|
|
|
|
cleanImpUser(bean);
|
|
|
|
|
latch.countDown();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
// Wait for all threads to complete
|
|
|
|
|
latch.await();
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
// 关闭线程池
|
|
|
|
|
impUserPool.shutdown();
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.info(StringKit.getTrace(e));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void cleanImpUser(ZhxfZdrygkRyjbxxViewMysql bean) {
|
|
|
|
|
ZhxfZdrygkRyjbxxViewMysql beanCp = new ZhxfZdrygkRyjbxxViewMysql();
|
|
|
|
|
try {
|
|
|
|
|
int countzdry = zdryMysqlService.count();
|
|
|
|
|
logger.info("countzdry:" + countzdry);
|
|
|
|
|
|
|
|
|
|
if (countzdry > 0) {
|
|
|
|
|
|
|
|
|
|
int count = countzdry / oncesCounts;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i <= count; i++) {
|
|
|
|
|
Map zdryMap = new HashMap();
|
|
|
|
|
zdryMap.put("rowStart", i * oncesCounts);
|
|
|
|
|
zdryMap.put("rowEnd", (i + 1) * oncesCounts);
|
|
|
|
|
try {
|
|
|
|
|
List<ZhxfZdrygkRyjbxxViewMysql> list = zdryMysqlService.lambdaQuery().list();
|
|
|
|
|
for (ZhxfZdrygkRyjbxxViewMysql zdry : list) {
|
|
|
|
|
MetaImpUserInfo metaImpUserInfo = new MetaImpUserInfo();
|
|
|
|
|
metaImpUserInfo.setUserName(zdry.getXM());
|
|
|
|
|
metaImpUserInfo.setIdCard(zdry.getZJHM());
|
|
|
|
|
if (zdry.getXB() != null) {
|
|
|
|
|
metaImpUserInfo.setSex(Integer.parseInt(zdry.getXB()));
|
|
|
|
|
}
|
|
|
|
|
metaImpUserInfo.setPhone(zdry.getSJHM());
|
|
|
|
|
String s = "000000";
|
|
|
|
|
if (zdry.getZDRYXL() != null && !zdry.getZDRYXL().contains(",")) {
|
|
|
|
|
String substring = zdry.getZDRYXL().substring(0, 4);
|
|
|
|
|
substring = substring + s;
|
|
|
|
|
metaImpUserInfo.setImpUserType(substring);
|
|
|
|
|
} else if (zdry.getZDRYXL().contains(",")) {
|
|
|
|
|
String[] split = zdry.getZDRYXL().split(",");
|
|
|
|
|
String substring = split[0].substring(0, 4);
|
|
|
|
|
String substring1 = split[1].substring(0, 4);
|
|
|
|
|
substring = substring + s + "," + substring1 + s;
|
|
|
|
|
metaImpUserInfo.setImpUserType(substring);
|
|
|
|
|
}
|
|
|
|
|
metaImpUserInfo.setImpUserSubType(zdry.getZDRYXL());
|
|
|
|
|
metaImpUserInfo.setHouseHoldRegister(zdry.getHJDQH());
|
|
|
|
|
metaImpUserInfo.setHouseHoldAddress(zdry.getHJDXZ());
|
|
|
|
|
metaImpUserInfo.setHabitationRegister(zdry.getXZDHQ());
|
|
|
|
|
metaImpUserInfo.setHabitationAddress(zdry.getXZDXZ());
|
|
|
|
|
metaImpUserInfo.setRegisterUnitCode(zdry.getDJRDWDM());
|
|
|
|
|
metaImpUserInfo.setRegisterUnitName(zdry.getDJRDWMC());
|
|
|
|
|
//确定一个数据是否唯一
|
|
|
|
|
MetaImpUserInfo one = metaImpUserInfoService.lambdaQuery().eq(MetaImpUserInfo::getIdCard, zdry.getZJHM()).one();
|
|
|
|
|
if (one == null) {
|
|
|
|
|
metaImpUserInfoService.save(metaImpUserInfo);
|
|
|
|
|
logger.info("zdry-" + zdry.getZJHM() + ":插入成功");
|
|
|
|
|
} else {
|
|
|
|
|
UpdateWrapper<MetaImpUserInfo> metaImpUserInfoUpdateWrapper = new UpdateWrapper<>();
|
|
|
|
|
metaImpUserInfoUpdateWrapper.eq("id_card", zdry.getZJHM());
|
|
|
|
|
metaImpUserInfoService.update(metaImpUserInfo, metaImpUserInfoUpdateWrapper);
|
|
|
|
|
logger.info("zdry-" + zdry.getZJHM() + ":更新成功");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.info("zdrys:" + e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
logger.info("zdryMap数据总量:" + countzdry + "," + "当前处理下标:" + zdryMap.get("rowStart") + "/" + zdryMap.get("rowEnd"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
VillageActualUserInfo userInfoPara = new VillageActualUserInfo();
|
|
|
|
|
userInfoPara.setIdcard(StringKit.toString(beanCp.getZJHM()));
|
|
|
|
|
List<VillageActualUserInfo> actualUserInfos = actualUserInfoService.selectVillageActualUserInfoListLimit1(userInfoPara);
|
|
|
|
|
String userPic = "";
|
|
|
|
|
if (actualUserInfos != null && actualUserInfos.size() > 0) {
|
|
|
|
|
userPic = StringKit.toString(actualUserInfos.get(0).getUserPic());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BeanUtils.copyProperties(bean, beanCp);
|
|
|
|
|
MetaImpUserInfo userInfo = new MetaImpUserInfo();
|
|
|
|
|
userInfo.setUserPic(userPic);
|
|
|
|
|
userInfo.setUserName(StringKit.toString(beanCp.getXM()));
|
|
|
|
|
userInfo.setIdCard(StringKit.toString(beanCp.getZJHM()));
|
|
|
|
|
userInfo.setSex( "".equals(StringKit.toString(beanCp.getXB()))? 0: NumKit.checkInt(beanCp.getXB()));
|
|
|
|
|
userInfo.setPhone(StringKit.toString(beanCp.getSJHM()));
|
|
|
|
|
|
|
|
|
|
String zdrlx = StringKit.toString(beanCp.getZDRYXL());
|
|
|
|
|
if("".equals(zdrlx)){
|
|
|
|
|
userInfo.setImpUserType(zdrlx.substring(0,4) + "000000");
|
|
|
|
|
userInfo.setImpUserSubType(beanCp.getZDRYXL());
|
|
|
|
|
}
|
|
|
|
|
userInfo.setHouseHoldRegister(beanCp.getHJDQH());
|
|
|
|
|
userInfo.setHouseHoldAddress(beanCp.getHJDXZ());
|
|
|
|
|
userInfo.setHabitationRegister(beanCp.getXZDHQ());
|
|
|
|
|
userInfo.setHabitationAddress(beanCp.getXZDXZ());
|
|
|
|
|
userInfo.setRegisterUnitCode(beanCp.getDJRDWDM());
|
|
|
|
|
userInfo.setRegisterUnitName(beanCp.getDJRDWMC());
|
|
|
|
|
|
|
|
|
|
boolean b = metaImpUserInfoService.save(userInfo);
|
|
|
|
|
|
|
|
|
|
if (b) {
|
|
|
|
|
beanCp.setStatus("1");
|
|
|
|
|
zdryMysqlService.updateZdryjbxxById(beanCp);
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.info(StringKit.getTrace(e));
|
|
|
|
|
beanCp.setStatus("2");
|
|
|
|
|
zdryMysqlService.updateZdryjbxxById(beanCp);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|