|
|
|
@ -1,11 +1,11 @@
|
|
|
|
|
package com.ssf.mysqloracletest.task;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
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.MetaImpUserInfo;
|
|
|
|
|
import com.ssf.mysqloracletest.domain.ZhxfZdrygkRyjbxxViewMysql;
|
|
|
|
|
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;
|
|
|
|
@ -13,13 +13,12 @@ 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;
|
|
|
|
@ -32,8 +31,13 @@ import java.util.concurrent.Executors;
|
|
|
|
|
public class MetaImpUserInfoTask {
|
|
|
|
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(MetaImpUserInfoTask.class);
|
|
|
|
|
|
|
|
|
|
private final ZhxfZdrygkRyjbxxViewMysqlService zdryMysqlService;
|
|
|
|
|
private final MetaImpUserInfoService metaImpUserInfoService;
|
|
|
|
|
private final VillageActualUserInfoService actualUserInfoService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -46,47 +50,20 @@ public class MetaImpUserInfoTask {
|
|
|
|
|
if (!"true".equals(ConfigParam.metaImpUserSwitch)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
QueryWrapper<ZhxfZdrygkRyjbxxViewMysql> wrapper = new QueryWrapper<>();
|
|
|
|
|
wrapper.isNull("status");
|
|
|
|
|
QueryWrapper<ZhxfZdrygkRyjbxxViewMysql> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
queryWrapper.isNull("status");
|
|
|
|
|
Page<ZhxfZdrygkRyjbxxViewMysql> page = new Page<>(1, 1000);
|
|
|
|
|
List<ZhxfZdrygkRyjbxxViewMysql> list = zdryMysqlService.page(page,wrapper).getRecords();
|
|
|
|
|
CountDownLatch latch = new CountDownLatch(list.size());
|
|
|
|
|
ExecutorService zdryPool = Executors.newFixedThreadPool(5);
|
|
|
|
|
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.setHouseHoldAddress(zdry.getHJDXZ());
|
|
|
|
|
metaImpUserInfo.setHabitationRegister(zdry.getXZDHQ());
|
|
|
|
|
metaImpUserInfo.setHabitationAddress(zdry.getXZDXZ());
|
|
|
|
|
metaImpUserInfo.setRegisterUnitCode(zdry.getDJRDWDM());
|
|
|
|
|
metaImpUserInfo.setRegisterUnitName(zdry.getDJRDWMC());
|
|
|
|
|
boolean save = metaImpUserInfoService.save(metaImpUserInfo);
|
|
|
|
|
if (save){
|
|
|
|
|
zdry.setStatus("1");
|
|
|
|
|
zdryMysqlService.updateZdryjbxxById(zdry);
|
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
@ -94,9 +71,55 @@ public class MetaImpUserInfoTask {
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
zdryPool.shutdown();
|
|
|
|
|
// 关闭线程池
|
|
|
|
|
impUserPool.shutdown();
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.info(StringKit.getTrace(e));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void cleanImpUser(ZhxfZdrygkRyjbxxViewMysql bean) {
|
|
|
|
|
ZhxfZdrygkRyjbxxViewMysql beanCp = new ZhxfZdrygkRyjbxxViewMysql();
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
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("zdrys:" + e.getMessage());
|
|
|
|
|
logger.info(StringKit.getTrace(e));
|
|
|
|
|
beanCp.setStatus("2");
|
|
|
|
|
zdryMysqlService.updateZdryjbxxById(beanCp);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|