Commit 3aaf5093 authored by huyuchen's avatar huyuchen

缴费库 代码修改

parent f9cd21b5
package com.yifu.cloud.plus.v1.yifu.common.ldap.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
@Data
@Component
@PropertySource("classpath:ldapConfig.properties")
@ConfigurationProperties(value = "ldap", ignoreInvalidFields = false)
public class LdapProperties {
String url;
String dn;
String password;
Integer port;
String userName;
String baseDn;
}
...@@ -56,13 +56,13 @@ public class PersonVo { ...@@ -56,13 +56,13 @@ public class PersonVo {
private String homeDirectory; private String homeDirectory;
/** /**
* 主键 * 部门名称
*/ */
@Attribute(name = "ou") @Attribute(name = "ou")
private String deptName; private String deptName;
/** /**
* 主键 * 用户密码
*/ */
@Attribute(name = "userPassword") @Attribute(name = "userPassword")
private String password; private String password;
......
package com.yifu.cloud.plus.v1.yifu.common.ldap.util;
import javax.naming.AuthenticationException;
import javax.naming.Context;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import javax.naming.directory.SearchControls;
import javax.naming.directory.SearchResult;
import javax.naming.ldap.Control;
import javax.naming.ldap.InitialLdapContext;
import javax.naming.ldap.LdapContext;
import java.util.Hashtable;
/**
* 用户登陆认证,LDAP跨域认证,通过LDAP对用户进行更新
*
*/
public class LdapCheck {
private static LdapContext ctx = null;
private static Control[] connCtls = null;
/**** 定义LDAP的基本连接信息 ******/
// LDAP的连接地址(ldap://ip:port/)port默认为389
private static String URL = "192.168.1.65";
//port
private static String port = "389";
// LDAP的根DN
private static String BASEDN = "dc=worfu,dc=com";
// LDAP的连接账号(身份认证管理平台添加的应用账号,应用账号格式:uid=?,ou=?,dc=????)
private static String PRINCIPAL = "cn=admin,dc=worfu,dc=com";
// LDAP的连接账号的密码(身份认证管理平台添加的应用账号的密码)
private static String PASSWORD = "yifu123456!";
// 校验用户名密码的方法
public static boolean authenticate(String usr, String pwd) {
boolean valide = false;
if (pwd == null || pwd == "")
return false;
if (ctx == null) {
getCtx();
}
String userDN = getUserDN(usr);
if ("".equals(userDN) || userDN == null) {
return false;
}
try {
ctx.addToEnvironment(Context.SECURITY_PRINCIPAL, userDN);
ctx.addToEnvironment(Context.SECURITY_CREDENTIALS, pwd);
ctx.reconnect(connCtls);
valide = true;
closeCtx();
} catch (AuthenticationException e) {
System.out.println(userDN + " is not authenticated");
System.out.println(e.toString());
valide = false;
} catch (NamingException e) {
System.out.println(userDN + " is not authenticated");
valide = false;
}
return valide;
}
public static void getCtx() {
if (ctx != null) {
return;
}
Hashtable<String, String> env = new Hashtable<String, String>();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, URL + ":" + port + BASEDN);
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL, PRINCIPAL);
env.put(Context.SECURITY_CREDENTIALS, PASSWORD);
try {
// 链接ldap
ctx = new InitialLdapContext(env, connCtls);
} catch (AuthenticationException e) {
System.out.println("Authentication faild: " + e.toString());
} catch (Exception e) {
System.out.println("Something wrong while authenticating: " + e.toString());
}
}
public static void closeCtx() {
try {
if (ctx != null)
ctx.close();
} catch (NamingException ex) {
}
}
public static String getUserDN(String uid) {
String userDN = "";
try {
SearchControls constraints = new SearchControls();
constraints.setSearchScope(SearchControls.SUBTREE_SCOPE);
NamingEnumeration<?> en = ctx.search("", "uid=" + uid, constraints);
if (en == null) {
System.out.println("Have no NamingEnumeration.");
}
if (!en.hasMoreElements()) {
System.out.println("Have no element.");
}
while (en != null && en.hasMoreElements()) {
Object obj = en.nextElement();
if (obj instanceof SearchResult) {
SearchResult si = (SearchResult) obj;
userDN += si.getName();
userDN += "," + BASEDN;
} else {
System.out.println(obj);
}
System.out.println();
}
} catch (Exception e) {
System.out.println("Exception in search():" + e);
}
return userDN;
}
}
\ No newline at end of file
...@@ -2,10 +2,12 @@ package com.yifu.cloud.plus.v1.yifu.common.ldap.util; ...@@ -2,10 +2,12 @@ package com.yifu.cloud.plus.v1.yifu.common.ldap.util;
import com.unboundid.ldap.sdk.*; import com.unboundid.ldap.sdk.*;
import com.unboundid.ldap.sdk.controls.SubentriesRequestControl; import com.unboundid.ldap.sdk.controls.SubentriesRequestControl;
import com.yifu.cloud.plus.v1.yifu.common.ldap.config.LdapProperties;
import com.yifu.cloud.plus.v1.yifu.common.ldap.entity.PersonVo; import com.yifu.cloud.plus.v1.yifu.common.ldap.entity.PersonVo;
import com.yifu.cloud.plus.v1.yifu.common.ldap.mapper.PersonAttributesMapper; import com.yifu.cloud.plus.v1.yifu.common.ldap.mapper.PersonAttributesMapper;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.ldap.core.LdapTemplate; import org.springframework.ldap.core.LdapTemplate;
import javax.naming.AuthenticationException; import javax.naming.AuthenticationException;
...@@ -23,26 +25,19 @@ import java.util.List; ...@@ -23,26 +25,19 @@ import java.util.List;
import static org.springframework.ldap.query.LdapQueryBuilder.query; import static org.springframework.ldap.query.LdapQueryBuilder.query;
@Log4j2 @Log4j2
@EnableConfigurationProperties(LdapProperties.class)
public class LdapUtil { public class LdapUtil {
@Autowired @Autowired
private LdapTemplate ldapTemplate; private LdapTemplate ldapTemplate;
@Autowired
private LdapProperties ldapProperties;
private static LdapContext ctx = null; private static LdapContext ctx = null;
private static Control[] connCtls = null; private static Control[] connCtls = null;
/**** 定义LDAP的基本连接信息 ******/
// LDAP的连接地址(ldap://ip:port/)port默认为389
private static String URL = "ldap://192.168.1.65:389/";
// LDAP的根DN
private static String BASEDN = "dc=worfu,dc=com";
// LDAP的连接账号(身份认证管理平台添加的应用账号,应用账号格式:uid=?,ou=?,dc=????)
private static String PRINCIPAL = "cn=admin,dc=worfu,dc=com";
// LDAP的连接账号的密码(身份认证管理平台添加的应用账号的密码)
private static String PASSWORD = "yifu123456!";
/** /**
* @return List<SearchResultEntry> * @return List<SearchResultEntry>
* @author huyc * @author huyc
...@@ -52,8 +47,9 @@ public class LdapUtil { ...@@ -52,8 +47,9 @@ public class LdapUtil {
public List<SearchResultEntry> getAllPersonNamesWithTraditionalWay() { public List<SearchResultEntry> getAllPersonNamesWithTraditionalWay() {
List<SearchResultEntry> result = new ArrayList<SearchResultEntry>(); List<SearchResultEntry> result = new ArrayList<SearchResultEntry>();
try { try {
LDAPConnection connection = new LDAPConnection("192.168.1.65", 389, "cn=admin,dc=worfu,dc=com", "yifu123456!"); LDAPConnection connection = new LDAPConnection(ldapProperties.getUrl(), ldapProperties.getPort(),
SearchRequest searchRequest = new SearchRequest("ou=安徽皖信人力资源管理有限公司,ou=wanxin,dc=worfu,dc=com", SearchScope.SUB, "(objectclass=*)"); ldapProperties.getUserName(), ldapProperties.getPassword());
SearchRequest searchRequest = new SearchRequest(ldapProperties.getBaseDn(), SearchScope.SUB, "(objectclass=*)");
searchRequest.addControl(new SubentriesRequestControl()); searchRequest.addControl(new SubentriesRequestControl());
SearchResult searchResult = connection.search(searchRequest); SearchResult searchResult = connection.search(searchRequest);
for (SearchResultEntry entry : searchResult.getSearchEntries()) { for (SearchResultEntry entry : searchResult.getSearchEntries()) {
...@@ -99,16 +95,17 @@ public class LdapUtil { ...@@ -99,16 +95,17 @@ public class LdapUtil {
return valide; return valide;
} }
public static void getCtx() { public void getCtx() {
if (ctx != null) { if (ctx != null) {
return; return;
} }
Hashtable<String, String> env = new Hashtable<String, String>(); Hashtable<String, String> env = new Hashtable<String, String>();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, URL + BASEDN); env.put(Context.PROVIDER_URL, "ldap://" + ldapProperties.getUrl() + ":" + ldapProperties.getPort() +
"/" + ldapProperties.getDn());
env.put(Context.SECURITY_AUTHENTICATION, "simple"); env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL, PRINCIPAL); env.put(Context.SECURITY_PRINCIPAL, ldapProperties.getUserName());
env.put(Context.SECURITY_CREDENTIALS, PASSWORD); env.put(Context.SECURITY_CREDENTIALS, ldapProperties.getPassword());
try { try {
// 链接ldap // 链接ldap
ctx = new InitialLdapContext(env, connCtls); ctx = new InitialLdapContext(env, connCtls);
...@@ -117,12 +114,12 @@ public class LdapUtil { ...@@ -117,12 +114,12 @@ public class LdapUtil {
} }
} }
public static void closeCtx() throws NamingException { public void closeCtx() throws NamingException {
if (ctx != null) if (ctx != null)
ctx.close(); ctx.close();
} }
public static String getUserDN(String uid) { public String getUserDN(String uid) {
String userDN = ""; String userDN = "";
try { try {
SearchControls constraints = new SearchControls(); SearchControls constraints = new SearchControls();
...@@ -133,7 +130,7 @@ public class LdapUtil { ...@@ -133,7 +130,7 @@ public class LdapUtil {
if (obj instanceof javax.naming.directory.SearchResult) { if (obj instanceof javax.naming.directory.SearchResult) {
javax.naming.directory.SearchResult si = (javax.naming.directory.SearchResult) obj; javax.naming.directory.SearchResult si = (javax.naming.directory.SearchResult) obj;
userDN += si.getName(); userDN += si.getName();
userDN += "," + BASEDN; userDN += "," + ldapProperties.getDn();
} }
} }
} catch (Exception e) { } catch (Exception e) {
......
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.yifu.cloud.plus.v1.yifu.common.ldap.config.LdapAutoConfigue\ com.yifu.cloud.plus.v1.yifu.common.ldap.util.LdapUtil\
ldap.url=192.168.1.65
ldap.port=389
ldap.userName=cn=admin,dc=worfu,dc=com
ldap.password=yifu123456!
ldap.dn=dc=worfu,dc=com
ldap.baseDn=ou=\u5B89\u5FBD\u7696\u4FE1\u4EBA\u529B\u8D44\u6E90\u7BA1\u7406\u6709\u9650\u516C\u53F8,ou=wanxin,dc=worfu,dc=com
\ No newline at end of file
...@@ -30,7 +30,6 @@ import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser; ...@@ -30,7 +30,6 @@ import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
import com.yifu.cloud.plus.v1.yifu.common.dapr.util.ArchivesDaprUtil; import com.yifu.cloud.plus.v1.yifu.common.dapr.util.ArchivesDaprUtil;
import com.yifu.cloud.plus.v1.yifu.common.dapr.util.UpmsDaprUtils; import com.yifu.cloud.plus.v1.yifu.common.dapr.util.UpmsDaprUtils;
import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils; import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils;
import com.yifu.cloud.plus.v1.yifu.insurances.vo.Dept;
import com.yifu.cloud.plus.v1.yifu.social.concurrent.threadpool.YFSocialImportThreadPoolExecutor; import com.yifu.cloud.plus.v1.yifu.social.concurrent.threadpool.YFSocialImportThreadPoolExecutor;
import com.yifu.cloud.plus.v1.yifu.social.constants.PaymentConstants; import com.yifu.cloud.plus.v1.yifu.social.constants.PaymentConstants;
import com.yifu.cloud.plus.v1.yifu.social.constants.SocialConstants; import com.yifu.cloud.plus.v1.yifu.social.constants.SocialConstants;
...@@ -369,13 +368,6 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -369,13 +368,6 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
} else { } else {
redisUtil.set(key, user.getId(), 1800L); redisUtil.set(key, user.getId(), 1800L);
Map<String, TPaymentInfoVo> listMap = new HashMap<>();
initListToMap(list, listMap);
// 把初步校验的内容返回给前端
if (Common.isNotNull(errorMessageList)) {
getIntegerErrorMessageHashMap(user, errorMessageList, key, random, listMap);
}
// 导入前做队列空闲判断,防止队列不足出现数据丢失的场景 // 导入前做队列空闲判断,防止队列不足出现数据丢失的场景
if (CollUtil.isNotEmpty(list)) { if (CollUtil.isNotEmpty(list)) {
int taskSize = list.size() / partSize + CommonConstants.ONE_INT; int taskSize = list.size() / partSize + CommonConstants.ONE_INT;
...@@ -383,7 +375,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -383,7 +375,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
if (taskSize > residualCapacity) { if (taskSize > residualCapacity) {
errorMessageList.add(new ErrorMessage(-1, MsgUtils.getMessage(ErrorCodes.SOCIALINFO_LIST_NUM_LARGE))); errorMessageList.add(new ErrorMessage(-1, MsgUtils.getMessage(ErrorCodes.SOCIALINFO_LIST_NUM_LARGE)));
} }
} else { }else {
// -----------------------------生成paymentInfoMap本段开始-------------------------------- // -----------------------------生成paymentInfoMap本段开始--------------------------------
//已存在的档案数据 //已存在的档案数据
List<String> monthList = Common.listObjectToStrList(list, ExcelAttributeConstants.SOCIAL_PAY_MONTH).stream().distinct().collect(Collectors.toList()); List<String> monthList = Common.listObjectToStrList(list, ExcelAttributeConstants.SOCIAL_PAY_MONTH).stream().distinct().collect(Collectors.toList());
...@@ -490,22 +482,14 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -490,22 +482,14 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
// -----------------------------线程池处理list,批量保存社保信息开始-------------------------------- // -----------------------------线程池处理list,批量保存社保信息开始--------------------------------
List<TPaymentInfoVo> tempList = new ArrayList<>(); List<TPaymentInfoVo> tempList = new ArrayList<>();
AtomicInteger atomicLine = new AtomicInteger(CommonConstants.ZERO_INT); AtomicInteger atomicLine = new AtomicInteger(CommonConstants.ZERO_INT);
List<CompletableFuture<List<TPaymentInfoImportLog>>> completableFutureList = new ArrayList<>();
try { try {
// 1.list.size()不足partSize,直接执行 // 1.list.size()不足partSize,直接执行
if (list.size() < partSize) { if (list.size() < partSize) {
CompletableFuture<List<TPaymentInfoImportLog>> listCompletableFuture = CompletableFuture.supplyAsync(() -> CompletableFuture.supplyAsync(() ->
executeImportSocialList(user, atomicLine, random, list, areaMap, areaMap2, executeImportSocialList(user, atomicLine, random, list, areaMap, areaMap2,
paymentInfoPensionMap, paymentInfoBigMap, paymentInfoBirMap, paymentInfoPensionMap, paymentInfoBigMap, paymentInfoBirMap,
paymentInfoMedicalMap, paymentInfoUnEmpMap, paymentInfoInjuryMap, paymentInfoMedicalMap, paymentInfoUnEmpMap, paymentInfoInjuryMap,
CommonConstants.ONE_INT), yfSocialImportThreadPoolExecutor) CommonConstants.ONE_INT, errorMessageList), yfSocialImportThreadPoolExecutor);
.whenComplete((result, e) -> {
if (CollectionUtils.isNotEmpty(result)) {
this.tPaymentInfoImportLogService.saveBatch(result);
}
// ServiceUtil.initErrorMessage(atomicLine.get(), remotePushService, pushParam);
});
completableFutureList.add(listCompletableFuture);
} }
// 2.list.size()大于partSize,循环分批执行 // 2.list.size()大于partSize,循环分批执行
...@@ -513,19 +497,12 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -513,19 +497,12 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
if (partSize <= list.size()) { if (partSize <= list.size()) {
// 处理第一个0位元素 // 处理第一个0位元素
final List<TPaymentInfoVo> finalList = list.subList(0, 1); final List<TPaymentInfoVo> finalList = list.subList(0, 1);
CompletableFuture<List<TPaymentInfoImportLog>> oneCompletableFuture = CompletableFuture.supplyAsync(() -> CompletableFuture.supplyAsync(() ->
executeImportSocialList(user, atomicLine, random, list, areaMap, areaMap2, executeImportSocialList(user, atomicLine, random, list, areaMap, areaMap2,
paymentInfoPensionMap, paymentInfoBigMap, paymentInfoBirMap, paymentInfoPensionMap, paymentInfoBigMap, paymentInfoBirMap,
paymentInfoMedicalMap, paymentInfoUnEmpMap, paymentInfoInjuryMap, paymentInfoMedicalMap, paymentInfoUnEmpMap, paymentInfoInjuryMap,
CommonConstants.ONE_INT), yfSocialImportThreadPoolExecutor) CommonConstants.ONE_INT, errorMessageList), yfSocialImportThreadPoolExecutor);
.whenComplete((result, e) -> {
if (CollectionUtils.isNotEmpty(result)) {
this.tPaymentInfoImportLogService.saveBatch(result);
}
// ServiceUtil.initErrorMessage(atomicLine.get(), remotePushService, pushParam);
});
lastIdx = 1; lastIdx = 1;
completableFutureList.add(oneCompletableFuture);
for (int i = 1; i < list.size(); i++) { for (int i = 1; i < list.size(); i++) {
// partSize数量的list为一个执行单元 // partSize数量的list为一个执行单元
tempList.add(list.get(i)); tempList.add(list.get(i));
...@@ -533,19 +510,11 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -533,19 +510,11 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
lastIdx = i; lastIdx = i;
List<TPaymentInfoVo> finalTempList = tempList; List<TPaymentInfoVo> finalTempList = tempList;
final int idx = i - partSize + 2; final int idx = i - partSize + 2;
CompletableFuture<List<TPaymentInfoImportLog>> listCompletableFuture = CompletableFuture.supplyAsync(() -> CompletableFuture.supplyAsync(() ->
executeImportSocialList(user, atomicLine, random, list, areaMap, areaMap2, executeImportSocialList(user, atomicLine, random, list, areaMap, areaMap2,
paymentInfoPensionMap, paymentInfoBigMap, paymentInfoBirMap, paymentInfoPensionMap, paymentInfoBigMap, paymentInfoBirMap,
paymentInfoMedicalMap, paymentInfoUnEmpMap, paymentInfoInjuryMap, paymentInfoMedicalMap, paymentInfoUnEmpMap, paymentInfoInjuryMap,
idx), yfSocialImportThreadPoolExecutor) idx, errorMessageList), yfSocialImportThreadPoolExecutor);
.whenComplete((result, e) -> {
if (CollectionUtils.isNotEmpty(result)) {
this.tPaymentInfoImportLogService.saveBatch(result);
}
//todo
// ServiceUtil.initErrorMessage(atomicLine.get(), remotePushService, pushParam);
});
completableFutureList.add(listCompletableFuture);
tempList = new ArrayList<>(); tempList = new ArrayList<>();
} }
} }
...@@ -567,40 +536,19 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -567,40 +536,19 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
List<TPaymentInfoVo> finalTempList = tempList; List<TPaymentInfoVo> finalTempList = tempList;
int finalLastIdx = lastIdx + 1; int finalLastIdx = lastIdx + 1;
CompletableFuture<List<TPaymentInfoImportLog>> listCompletableFuture = CompletableFuture.supplyAsync(() -> CompletableFuture.supplyAsync(() ->
executeImportSocialList(user, atomicLine, random, list, areaMap, areaMap2, executeImportSocialList(user, atomicLine, random, list, areaMap, areaMap2,
paymentInfoPensionMap, paymentInfoBigMap, paymentInfoBirMap, paymentInfoPensionMap, paymentInfoBigMap, paymentInfoBirMap,
paymentInfoMedicalMap, paymentInfoUnEmpMap, paymentInfoInjuryMap, paymentInfoMedicalMap, paymentInfoUnEmpMap, paymentInfoInjuryMap,
finalLastIdx), yfSocialImportThreadPoolExecutor) finalLastIdx, errorMessageList), yfSocialImportThreadPoolExecutor);
.whenComplete((result, e) -> {
if (CollectionUtils.isNotEmpty(result)) {
this.tPaymentInfoImportLogService.saveBatch(result);
}
// ServiceUtil.initErrorMessage(atomicLine.get(), remotePushService, pushParam);
});
completableFutureList.add(listCompletableFuture);
} }
// 阻塞当前线程,等待所有的线程执行完毕
boolean computeFlag;
do {
computeFlag = false;
for (CompletableFuture<List<TPaymentInfoImportLog>> listCompletableFuture : completableFutureList) {
if (!listCompletableFuture.isDone()) {
computeFlag = true;
}
}
} while (computeFlag);
String importSuccessKey = user.getId() + CommonConstants.DOWN_LINE_STRING + CommonConstants.PAYMENT_SOCIAL_WAIT_EXPORT; String importSuccessKey = user.getId() + CommonConstants.DOWN_LINE_STRING + CommonConstants.PAYMENT_SOCIAL_WAIT_EXPORT;
redisUtil.set(importSuccessKey, random, 1800L); redisUtil.set(importSuccessKey, random, 1800L);
} catch (Exception e) { } catch (Exception e) {
log.error("社保缴费库数据批量导入异常:" + e); log.error("社保缴费库数据批量导入异常:" + e);
redisUtil.remove(key); redisUtil.remove(key);
errorMessageList.add(new ErrorMessage(-1, "数据批量导入异常:" + e));
// errorMessageHashMap = ServiceUtil.initErrorMessage(
// errorMessageHashMap, new ErrorMessage(-1, "数据批量导入异常:" + e), remotePushService, pushParam);
} finally { } finally {
paymentInfoPensionMap.clear(); paymentInfoPensionMap.clear();
paymentInfoBigMap.clear(); paymentInfoBigMap.clear();
...@@ -612,37 +560,38 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -612,37 +560,38 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
// -----------------------------线程池处理list,批量保存社保信息结束-------------------------------- // -----------------------------线程池处理list,批量保存社保信息结束--------------------------------
//最后一个推送 //最后一个推送
log.info("社保批量导入耗时:{}", (System.currentTimeMillis() - start) + ""); log.info("社保批量导入耗时:{}", (System.currentTimeMillis() - start) + "");
// pushParam.setTips(null == errorMessageHashMap.get(list.size()) ? "导入完成!" :
// errorMessageHashMap.get(list.size()).getMessage());
// ServiceUtil.initErrorMessage(list.size(), remotePushService, pushParam);
redisUtil.remove(key); redisUtil.remove(key);
} }
} }
} }
private void initListToMap(List<TPaymentInfoVo> list, Map<String, TPaymentInfoVo> listMap) { /**
if (Common.isNotNull(list)) { * 转换缴纳地址为省市县ID
for (TPaymentInfoVo vo : list) { **/
listMap.put(String.valueOf(list.indexOf(vo) + 2), vo); private TPaymentInfoVo initAddress(String[] areaArray, HashMap<String, String> areaMap2, TPaymentInfoVo s) {
} if (null == areaArray || null == areaMap2 || null == s) {
} return s;
}
private void getIntegerErrorMessageHashMap(YifuUser user, List<ErrorMessage> errorInfo, String key,
String random, Map<String, TPaymentInfoVo> listMap) {
List<TPaymentInfoImportLog> logList = new ArrayList<>();
TPaymentInfoVo vo = null;
for (ErrorMessage error : errorInfo) {
vo = listMap.get(error.getLineNum().toString());
logList.add(new TPaymentInfoImportLog(null, null == vo ? "" : vo.getEmpName(),
null == vo ? "" : vo.getEmpIdcard(), error.getMessage(), vo.getRowIndex(), random));
} }
if (Common.isNotNull(logList)) { String temp = null;
this.tPaymentInfoImportLogService.saveBatch(logList); if (areaArray.length >= CommonConstants.TWO_INT) {
temp = areaMap2.get(areaArray[0] + CommonConstants.DOWN_LINE_STRING + "null");
if (Common.isNotNull(temp)) {
s.setSocialProvince(temp);
}
temp = areaMap2.get(areaArray[1] + CommonConstants.DOWN_LINE_STRING + (null == s.getSocialProvince()
? "null" : s.getSocialProvince()));
if (Common.isNotNull(temp)) {
s.setSocialCity(temp);
}
if (areaArray.length >= CommonConstants.THREE_INT) {
temp = areaMap2.get(areaArray[2] + CommonConstants.DOWN_LINE_STRING + (null == s.getSocialCity()
? "null" : s.getSocialCity()));
if (Common.isNotNull(temp)) {
s.setSocialTown(temp);
}
}
} }
redisUtil.set(user.getId() + CommonConstants.DOWN_LINE_STRING + CommonConstants.PAYMENT_SOCIAL_WAIT_EXPORT return s;
, random, 1800L);
redisUtil.remove(key);
} }
/** /**
...@@ -656,23 +605,22 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -656,23 +605,22 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
* @description: * @description:
* @author: huyc * @author: huyc
* @date: 2022/7/25 * @date: 2022/7/25
* @return: List<TPaymentInfoImportLog> * @return:
*/ */
private List<TPaymentInfoImportLog> executeImportSocialList(YifuUser user, private List<ErrorMessage> executeImportSocialList(YifuUser user,
AtomicInteger atomicLine, AtomicInteger atomicLine,
String random, String random,
List<TPaymentInfoVo> list, List<TPaymentInfoVo> list,
HashMap<String, String> areaMap, HashMap<String, String> areaMap,
HashMap<String, String> areaMap2, HashMap<String, String> areaMap2,
ConcurrentHashMap<String, TPaymentInfo> paymentInfoPensionMap, ConcurrentHashMap<String, TPaymentInfo> paymentInfoPensionMap,
ConcurrentHashMap<String, TPaymentInfo> paymentInfoBigMap, ConcurrentHashMap<String, TPaymentInfo> paymentInfoBigMap,
ConcurrentHashMap<String, TPaymentInfo> paymentInfoBirMap, ConcurrentHashMap<String, TPaymentInfo> paymentInfoBirMap,
ConcurrentHashMap<String, TPaymentInfo> paymentInfoMedicalMap, ConcurrentHashMap<String, TPaymentInfo> paymentInfoMedicalMap,
ConcurrentHashMap<String, TPaymentInfo> paymentInfoUnEmpMap, ConcurrentHashMap<String, TPaymentInfo> paymentInfoUnEmpMap,
ConcurrentHashMap<String, TPaymentInfo> paymentInfoInjuryMap, ConcurrentHashMap<String, TPaymentInfo> paymentInfoInjuryMap,
int idx) { int idx, List<ErrorMessage> errorMessageList) {
int i = idx; int i = idx;
List<TPaymentInfoImportLog> logList = new ArrayList<>();
if (Common.isNotNull(list)) { if (Common.isNotNull(list)) {
TPaymentInfo paymentInfo = null; TPaymentInfo paymentInfo = null;
TSocialInfo socialInfo = null; TSocialInfo socialInfo = null;
...@@ -741,18 +689,15 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -741,18 +689,15 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
} }
//导入校验 //导入校验
if (!Common.isNotNull(infoVo.getSocialPayMonth())) { if (!Common.isNotNull(infoVo.getSocialPayMonth())) {
logList.add(new TPaymentInfoImportLog(null, infoVo.getEmpName(), infoVo.getEmpIdcard() errorMessageList.add(new ErrorMessage(infoVo.getRowIndex(), "社保缴纳月份不可为空!"));
, CommonConstants.ERROR_MSG_PRFIX + "社保缴纳月份不可为空!", i, random));
continue; continue;
} }
if (!Common.isNotNull(infoVo.getSocialCreateMonth())) { if (!Common.isNotNull(infoVo.getSocialCreateMonth())) {
logList.add(new TPaymentInfoImportLog(null, infoVo.getEmpName(), infoVo.getEmpIdcard() errorMessageList.add(new ErrorMessage(infoVo.getRowIndex(), "社保生成月份不可为空!"));
, CommonConstants.ERROR_MSG_PRFIX + "社保生成月份不可为空!", i, random));
continue; continue;
} }
if (!Common.isNotNull(infoVo.getSocialPayAddr())) { if (!Common.isNotNull(infoVo.getSocialPayAddr())) {
logList.add(new TPaymentInfoImportLog(null, infoVo.getEmpName(), infoVo.getEmpIdcard() errorMessageList.add(new ErrorMessage(infoVo.getRowIndex(), "社保缴纳地不可为空!"));
, CommonConstants.ERROR_MSG_PRFIX + "社保缴纳地不可为空!", i, random));
continue; continue;
} }
//无对应员工的社保数据 //无对应员工的社保数据
...@@ -769,13 +714,11 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -769,13 +714,11 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
} }
//对身份证与人员姓名的对应关系进行校验 //对身份证与人员姓名的对应关系进行校验
if (socialInfo != null && !socialInfo.getEmpName().equals(infoVo.getEmpName())) { if (socialInfo != null && !socialInfo.getEmpName().equals(infoVo.getEmpName())) {
logList.add(new TPaymentInfoImportLog(null, infoVo.getEmpName(), infoVo.getEmpIdcard() errorMessageList.add(new ErrorMessage(infoVo.getRowIndex(), "姓名与身份证信息不一致,请核实后再次尝试!"));
, CommonConstants.ERROR_MSG_PRFIX + "姓名与身份证信息不一致,请核实后再次尝试!", i, random));
continue; continue;
} }
if (socialInfo != null && socialInfo.getSocialStartDate() == null) { if (socialInfo != null && socialInfo.getSocialStartDate() == null) {
logList.add(new TPaymentInfoImportLog(null, infoVo.getEmpName(), infoVo.getEmpIdcard() errorMessageList.add(new ErrorMessage(infoVo.getRowIndex(), infoVo.getEmpIdcard() + "的社保起缴日期为空!"));
, CommonConstants.ERROR_MSG_PRFIX + infoVo.getEmpIdcard() + "的社保起缴日期为空!", i, random));
continue; continue;
} }
if (null == socialInfo || (null != socialInfo && !ServiceUtil.checkMothForPaymentImport( if (null == socialInfo || (null != socialInfo && !ServiceUtil.checkMothForPaymentImport(
...@@ -788,8 +731,8 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -788,8 +731,8 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
? "null" : infoVo.getSocialTown())); ? "null" : infoVo.getSocialTown()));
//对身份证与人员姓名的对应关系进行校验 //对身份证与人员姓名的对应关系进行校验
if (socialInfo != null && !socialInfo.getEmpName().equals(infoVo.getEmpName())) { if (socialInfo != null && !socialInfo.getEmpName().equals(infoVo.getEmpName())) {
logList.add(new TPaymentInfoImportLog(null, infoVo.getEmpName(), infoVo.getEmpIdcard() errorMessageList.add(new ErrorMessage(infoVo.getRowIndex(), infoVo.getEmpIdcard() +
, CommonConstants.ERROR_MSG_PRFIX + "姓名与身份证信息不一致,请核实后再次尝试!", i, random)); "姓名与身份证信息不一致,请核实后再次尝试!"));
continue; continue;
} }
if (null != socialInfo && !ServiceUtil.checkMothForPaymentImport(socialInfo.getSocialStartDate() if (null != socialInfo && !ServiceUtil.checkMothForPaymentImport(socialInfo.getSocialStartDate()
...@@ -809,23 +752,20 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -809,23 +752,20 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
} }
} }
if (null == socialInfo) { if (null == socialInfo) {
logList.add(new TPaymentInfoImportLog(null, infoVo.getEmpName(), infoVo.getEmpIdcard() errorMessageList.add(new ErrorMessage(infoVo.getRowIndex(), infoVo.getEmpIdcard() +
, CommonConstants.ERROR_MSG_PRFIX + "无对应员工" + infoVo.getEmpIdcard() "无对应员工" + infoVo.getEmpIdcard() + "的社保数据(请查验社保办理状态|缴纳地|起缴月份|停缴月份)"));
+ "的社保数据(请查验社保办理状态|缴纳地|起缴月份|停缴月份)", i, random));
continue; continue;
} }
//如果导入项目数大于办理成功项目数给提示,少于给进,有问题自行删除后导入 //如果导入项目数大于办理成功项目数给提示,少于给进,有问题自行删除后导入
checkRes = checkRepeatInfo(socialInfo, infoVo); checkRes = checkRepeatInfo(socialInfo, infoVo);
if (null != checkRes) { if (null != checkRes) {
logList.add(new TPaymentInfoImportLog(null, infoVo.getEmpName(), infoVo.getEmpIdcard() errorMessageList.add(new ErrorMessage(infoVo.getRowIndex(), checkRes));
, CommonConstants.ERROR_MSG_PRFIX + checkRes, i, random));
continue; continue;
} }
//查看缴纳月是否为空 //查看缴纳月是否为空
if (!Common.isNotNull(infoVo.getSocialPayMonth())) { if (!Common.isNotNull(infoVo.getSocialPayMonth())) {
logList.add(new TPaymentInfoImportLog(null, infoVo.getEmpName(), infoVo.getEmpIdcard() errorMessageList.add(new ErrorMessage(infoVo.getRowIndex(), "必填项校验失败:社保缴纳月份不可为空!"));
, CommonConstants.ERROR_MSG_PRFIX + "必填项校验失败:社保缴纳月份不可为空!", i, random));
continue; continue;
} }
...@@ -848,9 +788,8 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -848,9 +788,8 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
BigDecimalUtils.isNullToZero(infoVo.getPersonalPensionMoney())), BigDecimalUtils.safeAdd( BigDecimalUtils.isNullToZero(infoVo.getPersonalPensionMoney())), BigDecimalUtils.safeAdd(
BigDecimalUtils.isNullToZero(paymentInfo.getUnitPensionMoney()), BigDecimalUtils.isNullToZero(paymentInfo.getUnitPensionMoney()),
BigDecimalUtils.isNullToZero(paymentInfo.getPersonalPensionMoney()))).compareTo(BigDecimal.ZERO) > 0) { BigDecimalUtils.isNullToZero(paymentInfo.getPersonalPensionMoney()))).compareTo(BigDecimal.ZERO) > 0) {
logList.add(new TPaymentInfoImportLog(null, infoVo.getEmpName(), infoVo.getEmpIdcard() errorMessageList.add(new ErrorMessage(infoVo.getRowIndex(), "已存在对应员工身份证" + infoVo.getEmpIdcard()
, CommonConstants.ERROR_MSG_PRFIX + "已存在对应员工身份证" + infoVo.getEmpIdcard() + "的养老缴费数据,请勿重复导入!"));
+ "的养老缴费数据,请勿重复导入!", i, random));
continue; continue;
} else { } else {
paymentInfo = null; paymentInfo = null;
...@@ -875,9 +814,8 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -875,9 +814,8 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
BigDecimalUtils.isNullToZero(infoVo.getPersonalUnemploymentMoney())), BigDecimalUtils.safeAdd( BigDecimalUtils.isNullToZero(infoVo.getPersonalUnemploymentMoney())), BigDecimalUtils.safeAdd(
BigDecimalUtils.isNullToZero(paymentInfo.getUnitUnemploymentMoney()), BigDecimalUtils.isNullToZero(paymentInfo.getUnitUnemploymentMoney()),
BigDecimalUtils.isNullToZero(paymentInfo.getPersonalUnemploymentMoney()))).compareTo(BigDecimal.ZERO) > 0) { BigDecimalUtils.isNullToZero(paymentInfo.getPersonalUnemploymentMoney()))).compareTo(BigDecimal.ZERO) > 0) {
logList.add(new TPaymentInfoImportLog(null, infoVo.getEmpName(), infoVo.getEmpIdcard() errorMessageList.add(new ErrorMessage(infoVo.getRowIndex(), "已存在对应员工身份证" + infoVo.getEmpIdcard()
, CommonConstants.ERROR_MSG_PRFIX + "已存在对应员工身份证" + infoVo.getEmpIdcard() + "的失业缴费数据,请勿重复导入!"));
+ "的失业缴费数据,请勿重复导入!", i, random));
continue; continue;
} else { } else {
paymentInfo = null; paymentInfo = null;
...@@ -902,9 +840,8 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -902,9 +840,8 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
BigDecimalUtils.isNullToZero(infoVo.getPersonalMedicalMoney())), BigDecimalUtils.safeAdd( BigDecimalUtils.isNullToZero(infoVo.getPersonalMedicalMoney())), BigDecimalUtils.safeAdd(
BigDecimalUtils.isNullToZero(paymentInfo.getUnitMedicalMoney()), BigDecimalUtils.isNullToZero(paymentInfo.getUnitMedicalMoney()),
BigDecimalUtils.isNullToZero(paymentInfo.getPersonalMedicalMoney()))).compareTo(BigDecimal.ZERO) > 0) { BigDecimalUtils.isNullToZero(paymentInfo.getPersonalMedicalMoney()))).compareTo(BigDecimal.ZERO) > 0) {
logList.add(new TPaymentInfoImportLog(null, infoVo.getEmpName(), infoVo.getEmpIdcard() errorMessageList.add(new ErrorMessage(infoVo.getRowIndex(), "已存在对应员工身份证" + infoVo.getEmpIdcard()
, CommonConstants.ERROR_MSG_PRFIX + "已存在对应员工身份证" + infoVo.getEmpIdcard() + "的医保缴费数据,请勿重复导入!"));
+ "的医保缴费数据,请勿重复导入!", i, random));
continue; continue;
} else { } else {
paymentInfo = null; paymentInfo = null;
...@@ -929,9 +866,8 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -929,9 +866,8 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
BigDecimalUtils.isNullToZero(infoVo.getPersonalBigmailmentMoney())), BigDecimalUtils.safeAdd( BigDecimalUtils.isNullToZero(infoVo.getPersonalBigmailmentMoney())), BigDecimalUtils.safeAdd(
BigDecimalUtils.isNullToZero(paymentInfo.getUnitBigmailmentMoney()), BigDecimalUtils.isNullToZero(paymentInfo.getUnitBigmailmentMoney()),
BigDecimalUtils.isNullToZero(paymentInfo.getPersonalBigmailmentMoney()))).compareTo(BigDecimal.ZERO) > 0) { BigDecimalUtils.isNullToZero(paymentInfo.getPersonalBigmailmentMoney()))).compareTo(BigDecimal.ZERO) > 0) {
logList.add(new TPaymentInfoImportLog(null, infoVo.getEmpName(), infoVo.getEmpIdcard() errorMessageList.add(new ErrorMessage(infoVo.getRowIndex(), "已存在对应员工身份证" + infoVo.getEmpIdcard()
, CommonConstants.ERROR_MSG_PRFIX + "已存在对应员工身份证" + infoVo.getEmpIdcard() + "的医疗救助金缴费数据,请勿重复导入!"));
+ "的医疗救助金缴费数据,请勿重复导入!", i, random));
continue; continue;
} else { } else {
paymentInfo = null; paymentInfo = null;
...@@ -952,9 +888,8 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -952,9 +888,8 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
//存在社保缴费数据 //存在社保缴费数据
if (null != paymentInfo && BigDecimalUtils.safeMultiply(BigDecimalUtils.isNullToZero(infoVo.getUnitInjuryMoney()), if (null != paymentInfo && BigDecimalUtils.safeMultiply(BigDecimalUtils.isNullToZero(infoVo.getUnitInjuryMoney()),
BigDecimalUtils.isNullToZero(paymentInfo.getUnitInjuryMoney())).compareTo(BigDecimal.ZERO) > 0) { BigDecimalUtils.isNullToZero(paymentInfo.getUnitInjuryMoney())).compareTo(BigDecimal.ZERO) > 0) {
logList.add(new TPaymentInfoImportLog(null, infoVo.getEmpName(), infoVo.getEmpIdcard() errorMessageList.add(new ErrorMessage(infoVo.getRowIndex(), "已存在对应员工身份证" + infoVo.getEmpIdcard()
, CommonConstants.ERROR_MSG_PRFIX + "已存在对应员工身份证" + infoVo.getEmpIdcard() + "的单位工伤缴费数据,请勿重复导入!"));
+ "的单位工伤缴费数据,请勿重复导入!", i, random));
continue; continue;
} else { } else {
paymentInfo = null; paymentInfo = null;
...@@ -975,9 +910,8 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -975,9 +910,8 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
//存在社保缴费数据 //存在社保缴费数据
if (null != paymentInfo && BigDecimalUtils.safeMultiply(BigDecimalUtils.isNullToZero(infoVo.getUnitBirthMoney()), if (null != paymentInfo && BigDecimalUtils.safeMultiply(BigDecimalUtils.isNullToZero(infoVo.getUnitBirthMoney()),
BigDecimalUtils.isNullToZero(paymentInfo.getUnitBirthMoney())).compareTo(BigDecimal.ZERO) > 0) { BigDecimalUtils.isNullToZero(paymentInfo.getUnitBirthMoney())).compareTo(BigDecimal.ZERO) > 0) {
logList.add(new TPaymentInfoImportLog(null, infoVo.getEmpName(), infoVo.getEmpIdcard() errorMessageList.add(new ErrorMessage(infoVo.getRowIndex(), "已存在对应员工身份证" + infoVo.getEmpIdcard()
, CommonConstants.ERROR_MSG_PRFIX + "已存在对应员工身份证" + infoVo.getEmpIdcard() + "的单位生育缴费数据,请勿重复导入!"));
+ "的单位生育缴费数据,请勿重复导入!", i, random));
continue; continue;
} else { } else {
paymentInfo = null; paymentInfo = null;
...@@ -1080,60 +1014,21 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -1080,60 +1014,21 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
if (null != paymentInfo && Common.isNotNull(paymentInfo.getId())) { if (null != paymentInfo && Common.isNotNull(paymentInfo.getId())) {
res = baseMapper.updateById(paymentInfo); res = baseMapper.updateById(paymentInfo);
if (res < 0) { if (res < 0) {
logList.add(new TPaymentInfoImportLog(null, infoVo.getEmpName(), infoVo.getEmpIdcard() errorMessageList.add(new ErrorMessage(infoVo.getRowIndex(), infoVo.getEmpName() + "_缴费库更新失败!"));
, CommonConstants.ERROR_MSG_PRFIX + infoVo.getEmpName() + "_缴费库更新失败!", i, random));
continue;
} else {
logList.add(new TPaymentInfoImportLog(null, infoVo.getEmpName(), infoVo.getEmpIdcard()
, CommonConstants.ERROR_MSG_PRFIX + infoVo.getEmpName() + "_缴费库更新成功!", i, random));
continue; continue;
} }
} else { } else {
res = insertAndSTimestamp(paymentInfo); res = insertAndSTimestamp(paymentInfo);
if (res < 0) { if (res < 0) {
logList.add(new TPaymentInfoImportLog(null, infoVo.getEmpName(), infoVo.getEmpIdcard() errorMessageList.add(new ErrorMessage(infoVo.getRowIndex(), infoVo.getEmpName() + "_缴费库保存失败!"));
, CommonConstants.ERROR_MSG_PRFIX + infoVo.getEmpName() + "_缴费库保存失败!", i, random));
continue; continue;
} }
} }
logList.add(new TPaymentInfoImportLog(null, infoVo.getEmpName(), infoVo.getEmpIdcard()
, CommonConstants.SUCCESS_MSG_PREFIX + "保存成功!", i, random));
} }
itemMap.clear(); itemMap.clear();
cusMap.clear(); cusMap.clear();
} else {
return null;
} }
return logList; return errorMessageList;
}
/**
* 转换缴纳地址为省市县ID
**/
private TPaymentInfoVo initAddress(String[] areaArray, HashMap<String, String> areaMap2, TPaymentInfoVo s) {
if (null == areaArray || null == areaMap2 || null == s) {
return s;
}
String temp = null;
if (areaArray.length >= CommonConstants.TWO_INT) {
temp = areaMap2.get(areaArray[0] + CommonConstants.DOWN_LINE_STRING + "null");
if (Common.isNotNull(temp)) {
s.setSocialProvince(temp);
}
temp = areaMap2.get(areaArray[1] + CommonConstants.DOWN_LINE_STRING + (null == s.getSocialProvince()
? "null" : s.getSocialProvince()));
if (Common.isNotNull(temp)) {
s.setSocialCity(temp);
}
if (areaArray.length >= CommonConstants.THREE_INT) {
temp = areaMap2.get(areaArray[2] + CommonConstants.DOWN_LINE_STRING + (null == s.getSocialCity()
? "null" : s.getSocialCity()));
if (Common.isNotNull(temp)) {
s.setSocialTown(temp);
}
}
}
return s;
} }
//比对缴纳地是否一致 //比对缴纳地是否一致
...@@ -1245,7 +1140,6 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -1245,7 +1140,6 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
YifuUser user = SecurityUtils.getUser(); YifuUser user = SecurityUtils.getUser();
List<ErrorMessage> errorMessageList = new ArrayList<>(); List<ErrorMessage> errorMessageList = new ArrayList<>();
ExcelUtil<TPaymentHeFeiVo> util1 = new ExcelUtil<>(TPaymentHeFeiVo.class); ExcelUtil<TPaymentHeFeiVo> util1 = new ExcelUtil<>(TPaymentHeFeiVo.class);
;
// 写法2: // 写法2:
// 匿名内部类 不用额外写一个DemoDataListener // 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭 // 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
...@@ -1304,7 +1198,6 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -1304,7 +1198,6 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
YifuUser user = SecurityUtils.getUser(); YifuUser user = SecurityUtils.getUser();
List<ErrorMessage> errorMessageList = new ArrayList<>(); List<ErrorMessage> errorMessageList = new ArrayList<>();
ExcelUtil<TPaymentInfoVo> util1 = new ExcelUtil<>(TPaymentInfoVo.class); ExcelUtil<TPaymentInfoVo> util1 = new ExcelUtil<>(TPaymentInfoVo.class);
;
// 写法2: // 写法2:
// 匿名内部类 不用额外写一个DemoDataListener // 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭 // 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
...@@ -1646,7 +1539,6 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -1646,7 +1539,6 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
private void importTPaymentSocialHeFei(List<TPaymentHeFeiVo> list, List<ErrorMessage> errorMessageList, private void importTPaymentSocialHeFei(List<TPaymentHeFeiVo> list, List<ErrorMessage> errorMessageList,
String random, YifuUser user, String type) { String random, YifuUser user, String type) {
long start = System.currentTimeMillis();
HashMap<String, String> areaMap = new HashMap<String, String>(); HashMap<String, String> areaMap = new HashMap<String, String>();
HashMap<String, String> areaMap2 = new HashMap<String, String>(); HashMap<String, String> areaMap2 = new HashMap<String, String>();
...@@ -1666,13 +1558,6 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -1666,13 +1558,6 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
// 判断是否有相同的用户在导入社保费用 存在提示稍后重试 // 判断是否有相同的用户在导入社保费用 存在提示稍后重试
String key = user.getId() + CommonConstants.DOWN_LINE_STRING + CommonConstants.PAYMENT_SOCIAL_IMPORT; String key = user.getId() + CommonConstants.DOWN_LINE_STRING + CommonConstants.PAYMENT_SOCIAL_IMPORT;
Map<String, TPaymentHeFeiVo> listMap = new HashMap<>();
initListToMapThree(list, listMap);
// 把初步校验的内容返回给前端
if (Common.isNotNull(errorMessageList)) {
getErrorMessageHashMapThree(user, random, errorMessageList, key, listMap);
}
// 将以下代码提取出来,使用paymentInfoMap提升性能,避免list多次循环查询数据库浪费性能 // 将以下代码提取出来,使用paymentInfoMap提升性能,避免list多次循环查询数据库浪费性能
// 导入前做队列空闲判断,防止队列不足出现数据丢失的场景 // 导入前做队列空闲判断,防止队列不足出现数据丢失的场景
if (CollUtil.isNotEmpty(list)) { if (CollUtil.isNotEmpty(list)) {
...@@ -1680,248 +1565,177 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -1680,248 +1565,177 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
int residualCapacity = yfSocialImportThreadPoolExecutor.getResidualCapacity(); int residualCapacity = yfSocialImportThreadPoolExecutor.getResidualCapacity();
if (taskSize > residualCapacity) { if (taskSize > residualCapacity) {
errorMessageList.add(new ErrorMessage(-1, MsgUtils.getMessage(ErrorCodes.SOCIALINFO_LIST_NUM_LARGE))); errorMessageList.add(new ErrorMessage(-1, MsgUtils.getMessage(ErrorCodes.SOCIALINFO_LIST_NUM_LARGE)));
} } else {
} // -----------------------------生成paymentInfoMap本段开始--------------------------------
//已存在的档案数据
List<String> monthList = Common.listObjectToStrList(list, ExcelAttributeConstants.SOCIAL_PAY_MONTH).stream().distinct().collect(Collectors.toList());
//已存在社保缴费库数据 非删除状态
List<TPaymentInfo> paymentInfos = baseMapper.selectListForPaymentImport(monthList,
Common.listObjectToStrList(list, ExcelAttributeConstants.EMPIDCARD));
//养老
ConcurrentHashMap<String, TPaymentInfo> paymentInfoPensionMap = new ConcurrentHashMap<>();
//大病救助金
ConcurrentHashMap<String, TPaymentInfo> paymentInfoBigMap = new ConcurrentHashMap<>();
//失业
ConcurrentHashMap<String, TPaymentInfo> paymentInfoUnEmpMap = new ConcurrentHashMap<>();
//工伤
ConcurrentHashMap<String, TPaymentInfo> paymentInfoInjuryMap = new ConcurrentHashMap<>();
//医保
ConcurrentHashMap<String, TPaymentInfo> paymentInfoMedicalMap = new ConcurrentHashMap<>();
if (Common.isNotNull(paymentInfos)) {
for (TPaymentInfo info : paymentInfos) {
// -----------------------------生成paymentInfoMap本段开始-------------------------------- if (BigDecimalUtils.safeAdd(BigDecimalUtils.isNullToZero(info.getUnitPensionMoney()),
//已存在的档案数据 BigDecimalUtils.isNullToZero(info.getPersonalPensionMoney())).compareTo(BigDecimal.ZERO) != 0) {
List<String> monthList = Common.listObjectToStrList(list, ExcelAttributeConstants.SOCIAL_PAY_MONTH).stream().distinct().collect(Collectors.toList()); paymentInfoPensionMap.put(info.getSocialPayAddr()
//已存在社保缴费库数据 非删除状态 + CommonConstants.DOWN_LINE_STRING
List<TPaymentInfo> paymentInfos = baseMapper.selectListForPaymentImport(monthList, + info.getEmpIdcard()
Common.listObjectToStrList(list, ExcelAttributeConstants.EMPIDCARD)); + CommonConstants.DOWN_LINE_STRING
//养老 + info.getSocialPayMonth()
ConcurrentHashMap<String, TPaymentInfo> paymentInfoPensionMap = new ConcurrentHashMap<>(); + CommonConstants.DOWN_LINE_STRING
//大病救助金 + info.getSocialCreateMonth()
ConcurrentHashMap<String, TPaymentInfo> paymentInfoBigMap = new ConcurrentHashMap<>(); + CommonConstants.DOWN_LINE_STRING
//失业 + PaymentConstants.PENSION_RISK
ConcurrentHashMap<String, TPaymentInfo> paymentInfoUnEmpMap = new ConcurrentHashMap<>(); , info);
//工伤 }
ConcurrentHashMap<String, TPaymentInfo> paymentInfoInjuryMap = new ConcurrentHashMap<>(); if (BigDecimalUtils.safeAdd(BigDecimalUtils.isNullToZero(info.getUnitUnemploymentMoney()),
//医保 BigDecimalUtils.isNullToZero(info.getPersonalUnemploymentMoney())).compareTo(BigDecimal.ZERO) != 0) {
ConcurrentHashMap<String, TPaymentInfo> paymentInfoMedicalMap = new ConcurrentHashMap<>(); paymentInfoUnEmpMap.put(info.getSocialPayAddr()
if (Common.isNotNull(paymentInfos)) { + CommonConstants.DOWN_LINE_STRING
for (TPaymentInfo info : paymentInfos) { + info.getEmpIdcard()
+ CommonConstants.DOWN_LINE_STRING
if (BigDecimalUtils.safeAdd(BigDecimalUtils.isNullToZero(info.getUnitPensionMoney()), + info.getSocialPayMonth()
BigDecimalUtils.isNullToZero(info.getPersonalPensionMoney())).compareTo(BigDecimal.ZERO) != 0) { + CommonConstants.DOWN_LINE_STRING
paymentInfoPensionMap.put(info.getSocialPayAddr() + info.getSocialCreateMonth()
+ CommonConstants.DOWN_LINE_STRING + CommonConstants.DOWN_LINE_STRING
+ info.getEmpIdcard() + PaymentConstants.UNEMPLOYEEMENT_RISK
+ CommonConstants.DOWN_LINE_STRING , info);
+ info.getSocialPayMonth() }
+ CommonConstants.DOWN_LINE_STRING if (BigDecimalUtils.isNullToZero(info.getUnitInjuryMoney()).compareTo(BigDecimal.ZERO) != 0) {
+ info.getSocialCreateMonth() paymentInfoInjuryMap.put(info.getSocialPayAddr()
+ CommonConstants.DOWN_LINE_STRING + CommonConstants.DOWN_LINE_STRING
+ PaymentConstants.PENSION_RISK + info.getEmpIdcard()
, info); + CommonConstants.DOWN_LINE_STRING
} + info.getSocialPayMonth()
if (BigDecimalUtils.safeAdd(BigDecimalUtils.isNullToZero(info.getUnitUnemploymentMoney()), + CommonConstants.DOWN_LINE_STRING
BigDecimalUtils.isNullToZero(info.getPersonalUnemploymentMoney())).compareTo(BigDecimal.ZERO) != 0) { + info.getSocialCreateMonth()
paymentInfoUnEmpMap.put(info.getSocialPayAddr() + CommonConstants.DOWN_LINE_STRING
+ CommonConstants.DOWN_LINE_STRING + PaymentConstants.INJURY_RISK
+ info.getEmpIdcard() , info);
+ CommonConstants.DOWN_LINE_STRING }
+ info.getSocialPayMonth() if (BigDecimalUtils.safeAdd(BigDecimalUtils.isNullToZero(info.getUnitMedicalMoney()),
+ CommonConstants.DOWN_LINE_STRING BigDecimalUtils.isNullToZero(info.getPersonalMedicalMoney())).compareTo(BigDecimal.ZERO) != 0) {
+ info.getSocialCreateMonth() paymentInfoMedicalMap.put(info.getSocialPayAddr()
+ CommonConstants.DOWN_LINE_STRING + CommonConstants.DOWN_LINE_STRING
+ PaymentConstants.UNEMPLOYEEMENT_RISK + info.getEmpIdcard()
, info); + CommonConstants.DOWN_LINE_STRING
} + info.getSocialPayMonth()
if (BigDecimalUtils.isNullToZero(info.getUnitInjuryMoney()).compareTo(BigDecimal.ZERO) != 0) { + CommonConstants.DOWN_LINE_STRING
paymentInfoInjuryMap.put(info.getSocialPayAddr() + info.getSocialCreateMonth()
+ CommonConstants.DOWN_LINE_STRING + CommonConstants.DOWN_LINE_STRING
+ info.getEmpIdcard() + PaymentConstants.MEDICAL
+ CommonConstants.DOWN_LINE_STRING , info);
+ info.getSocialPayMonth() }
+ CommonConstants.DOWN_LINE_STRING }
+ info.getSocialCreateMonth()
+ CommonConstants.DOWN_LINE_STRING
+ PaymentConstants.INJURY_RISK
, info);
}
if (BigDecimalUtils.safeAdd(BigDecimalUtils.isNullToZero(info.getUnitMedicalMoney()),
BigDecimalUtils.isNullToZero(info.getPersonalMedicalMoney())).compareTo(BigDecimal.ZERO) != 0) {
paymentInfoMedicalMap.put(info.getSocialPayAddr()
+ CommonConstants.DOWN_LINE_STRING
+ info.getEmpIdcard()
+ CommonConstants.DOWN_LINE_STRING
+ info.getSocialPayMonth()
+ CommonConstants.DOWN_LINE_STRING
+ info.getSocialCreateMonth()
+ CommonConstants.DOWN_LINE_STRING
+ PaymentConstants.MEDICAL
, info);
} }
} // -----------------------------生成paymentInfoMap本段结束--------------------------------
}
// -----------------------------生成paymentInfoMap本段结束--------------------------------
/** /**
* 修改批量导入社保为线程池的方式。逻辑分析,根据前端传入的list,将list分成每份partSize个。 * 修改批量导入社保为线程池的方式。逻辑分析,根据前端传入的list,将list分成每份partSize个。
* 有以下3种情况。1.list数量不足partSize,直接进行处理;2.list数量正好可以根据partSize等分,循环处理;3.不能等分有剩余的情况 * 有以下3种情况。1.list数量不足partSize,直接进行处理;2.list数量正好可以根据partSize等分,循环处理;3.不能等分有剩余的情况
*/ */
// -----------------------------线程池处理list,批量保存社保信息开始-------------------------------- // -----------------------------线程池处理list,批量保存社保信息开始--------------------------------
List<TPaymentHeFeiVo> tempList = new ArrayList<>(); List<TPaymentHeFeiVo> tempList = new ArrayList<>();
AtomicInteger atomicLine = new AtomicInteger(CommonConstants.ZERO_INT); AtomicInteger atomicLine = new AtomicInteger(CommonConstants.ZERO_INT);
List<CompletableFuture<List<TPaymentInfoImportLog>>> completableFutureList = new ArrayList<>(); try {
try { // 1.list.size()不足partSize,直接执行
// 1.list.size()不足partSize,直接执行 if (list.size() < partSize) {
if (list.size() < partSize) { CompletableFuture.supplyAsync(() -> executeImportSocialListThree(
CompletableFuture<List<TPaymentInfoImportLog>> listCompletableFuture = CompletableFuture.supplyAsync(() user, atomicLine, random, list, areaMap, areaMap2, paymentInfoPensionMap,
-> executeImportSocialListThree(user, atomicLine, random, list, areaMap, areaMap2, paymentInfoMedicalMap, paymentInfoUnEmpMap, paymentInfoInjuryMap,
paymentInfoPensionMap, paymentInfoMedicalMap, paymentInfoUnEmpMap, CommonConstants.ONE_INT, type, errorMessageList), yfSocialImportThreadPoolExecutor);
paymentInfoInjuryMap, CommonConstants.ONE_INT, type), yfSocialImportThreadPoolExecutor) }
.whenComplete((result, e) -> {
if (CollectionUtils.isNotEmpty(result)) {
this.tPaymentInfoImportLogService.saveBatch(result);
}
//todo
// ServiceUtil.initErrorMessage(atomicLine.get(), remotePushService, pushParam);
});
completableFutureList.add(listCompletableFuture);
}
// 2.list.size()大于partSize,循环分批执行 // 2.list.size()大于partSize,循环分批执行
int lastIdx = 0; int lastIdx = 0;
if (partSize <= list.size()) { if (partSize <= list.size()) {
// 处理第一个0位元素 // 处理第一个0位元素
final List<TPaymentHeFeiVo> finalList = list.subList(0, 1); final List<TPaymentHeFeiVo> finalList = list.subList(0, 1);
CompletableFuture<List<TPaymentInfoImportLog>> oneCompletableFuture = CompletableFuture.supplyAsync(() CompletableFuture.supplyAsync(() -> executeImportSocialListThree(
-> executeImportSocialListThree(user, atomicLine, random, finalList, areaMap, areaMap2, user, atomicLine, random, finalList, areaMap, areaMap2,
paymentInfoPensionMap, paymentInfoMedicalMap, paymentInfoUnEmpMap, paymentInfoPensionMap, paymentInfoMedicalMap, paymentInfoUnEmpMap,
paymentInfoInjuryMap, CommonConstants.ONE_INT, type), yfSocialImportThreadPoolExecutor) paymentInfoInjuryMap, CommonConstants.ONE_INT, type, errorMessageList)
.whenComplete((result, e) -> { , yfSocialImportThreadPoolExecutor);
if (CollectionUtils.isNotEmpty(result)) { lastIdx = 1;
this.tPaymentInfoImportLogService.saveBatch(result); for (int i = 1; i < list.size(); i++) {
} // partSize数量的list为一个执行单元
// ServiceUtil.initErrorMessage(atomicLine.get(), remotePushService, pushParam); tempList.add(list.get(i));
}); if (i % partSize == 0) {
lastIdx = 1; lastIdx = i;
completableFutureList.add(oneCompletableFuture); final int idx = i - partSize + 2;
for (int i = 1; i < list.size(); i++) { List<TPaymentHeFeiVo> finalTempList1 = tempList;
// partSize数量的list为一个执行单元 CompletableFuture.supplyAsync(() -> executeImportSocialListThree(user
tempList.add(list.get(i)); , atomicLine, random, finalTempList1, areaMap,
if (i % partSize == 0) {
lastIdx = i;
final int idx = i - partSize + 2;
List<TPaymentHeFeiVo> finalTempList1 = tempList;
CompletableFuture<List<TPaymentInfoImportLog>> listCompletableFuture = CompletableFuture.supplyAsync(()
-> executeImportSocialListThree(user, atomicLine, random, finalTempList1, areaMap,
areaMap2, paymentInfoPensionMap, paymentInfoMedicalMap, paymentInfoUnEmpMap, areaMap2, paymentInfoPensionMap, paymentInfoMedicalMap, paymentInfoUnEmpMap,
paymentInfoInjuryMap, idx, type), yfSocialImportThreadPoolExecutor) paymentInfoInjuryMap, idx, type, errorMessageList)
.whenComplete((result, e) -> { , yfSocialImportThreadPoolExecutor);
if (CollectionUtils.isNotEmpty(result)) { tempList = new ArrayList<>();
this.tPaymentInfoImportLogService.saveBatch(result); }
} }
// ServiceUtil.initErrorMessage(atomicLine.get(), remotePushService, pushParam);
});
completableFutureList.add(listCompletableFuture);
tempList = new ArrayList<>();
}
}
}
// 3.第2种方式执行完后,有余数的情况下,执行3
if (lastIdx != 0) {
tempList = new ArrayList<>();
if (lastIdx == 1) {
for (int i = lastIdx; i < list.size(); i++) {
tempList.add(list.get(i));
}
} else {
for (int i = lastIdx + 1; i < list.size(); i++) {
tempList.add(list.get(i));
} }
lastIdx += 1;
}
List<TPaymentHeFeiVo> finalTempList = tempList; // 3.第2种方式执行完后,有余数的情况下,执行3
int finalLastIdx = lastIdx + 1; if (lastIdx != 0) {
CompletableFuture<List<TPaymentInfoImportLog>> listCompletableFuture = CompletableFuture.supplyAsync(() tempList = new ArrayList<>();
-> executeImportSocialListThree(user, atomicLine, random, finalTempList, areaMap, if (lastIdx == 1) {
areaMap2, paymentInfoPensionMap, paymentInfoMedicalMap, paymentInfoUnEmpMap, for (int i = lastIdx; i < list.size(); i++) {
paymentInfoInjuryMap, finalLastIdx, type), yfSocialImportThreadPoolExecutor) tempList.add(list.get(i));
.whenComplete((result, e) -> {
if (CollectionUtils.isNotEmpty(result)) {
this.tPaymentInfoImportLogService.saveBatch(result);
} }
// ServiceUtil.initErrorMessage(atomicLine.get(), remotePushService, pushParam); } else {
}); for (int i = lastIdx + 1; i < list.size(); i++) {
completableFutureList.add(listCompletableFuture); tempList.add(list.get(i));
} }
lastIdx += 1;
}
// 阻塞当前线程,等待所有的线程执行完毕 List<TPaymentHeFeiVo> finalTempList = tempList;
boolean computeFlag; int finalLastIdx = lastIdx + 1;
do { CompletableFuture.supplyAsync(() -> executeImportSocialListThree(
computeFlag = false; user, atomicLine, random, finalTempList, areaMap,
for (CompletableFuture<List<TPaymentInfoImportLog>> listCompletableFuture : completableFutureList) { areaMap2, paymentInfoPensionMap, paymentInfoMedicalMap, paymentInfoUnEmpMap,
if (!listCompletableFuture.isDone()) { paymentInfoInjuryMap, finalLastIdx, type, errorMessageList)
computeFlag = true; , yfSocialImportThreadPoolExecutor);
} }
}
} while (computeFlag);
String importSuccessKey = user.getId() + CommonConstants.DOWN_LINE_STRING + CommonConstants.PAYMENT_SOCIAL_WAIT_EXPORT; String importSuccessKey = user.getId() + CommonConstants.DOWN_LINE_STRING + CommonConstants.PAYMENT_SOCIAL_WAIT_EXPORT;
redisUtil.set(importSuccessKey, random, 1800L); redisUtil.set(importSuccessKey, random, 1800L);
} catch (Exception e) {
log.error("社保缴费库数据批量导入异常:" + e);
redisUtil.remove(key);
errorMessageList.add(new ErrorMessage(-1, "数据批量导入异常:" + e));
} finally {
paymentInfoPensionMap.clear();
paymentInfoBigMap.clear();
paymentInfoMedicalMap.clear();
paymentInfoUnEmpMap.clear();
paymentInfoInjuryMap.clear();
}
}
private void initListToMapThree(List<TPaymentHeFeiVo> list, Map<String, TPaymentHeFeiVo> listMap) { } catch (Exception e) {
if (Common.isNotNull(list)) { log.error("社保缴费库数据批量导入异常:" + e);
for (TPaymentHeFeiVo vo : list) { redisUtil.remove(key);
listMap.put(String.valueOf(list.indexOf(vo) + 2), vo); } finally {
paymentInfoPensionMap.clear();
paymentInfoBigMap.clear();
paymentInfoMedicalMap.clear();
paymentInfoUnEmpMap.clear();
paymentInfoInjuryMap.clear();
}
} }
} }
} }
/* private List<ErrorMessage> executeImportSocialListThree(YifuUser user, AtomicInteger atomicLine,
* 保存初步校验 String random,
* */ List<TPaymentHeFeiVo> list,
private void getErrorMessageHashMapThree(YifuUser user, HashMap<String, String> areaMap,
String random, HashMap<String, String> areaMap2,
List<ErrorMessage> errorInfo, ConcurrentHashMap<String, TPaymentInfo> paymentInfoPensionMap,
String key, Map<String, TPaymentHeFeiVo> listMap) { ConcurrentHashMap<String, TPaymentInfo> paymentInfoMedicalMap,
List<TPaymentInfoImportLog> logList = new ArrayList<>(); ConcurrentHashMap<String, TPaymentInfo> paymentInfoUnEmpMap,
TPaymentHeFeiVo vo = null; ConcurrentHashMap<String, TPaymentInfo> paymentInfoInjuryMap,
for (ErrorMessage error : errorInfo) { int idx, String type,List<ErrorMessage> errorMessageList) {
vo = listMap.get(error.getLineNum().toString());
logList.add(new TPaymentInfoImportLog(null, null == vo ? "" : vo.getEmpName(),
null == vo ? "" : vo.getEmpIdcard(), error.getMessage(), vo.getRowIndex(), random));
}
if (Common.isNotNull(logList)) {
this.tPaymentInfoImportLogService.saveBatch(logList);
}
redisUtil.set(user.getId() + CommonConstants.DOWN_LINE_STRING +
CommonConstants.PAYMENT_SOCIAL_WAIT_EXPORT, random, 1800L);
redisUtil.remove(key);
}
private List<TPaymentInfoImportLog> executeImportSocialListThree(YifuUser user, AtomicInteger atomicLine,
String random,
List<TPaymentHeFeiVo> list,
HashMap<String, String> areaMap,
HashMap<String, String> areaMap2,
ConcurrentHashMap<String, TPaymentInfo> paymentInfoPensionMap,
ConcurrentHashMap<String, TPaymentInfo> paymentInfoMedicalMap,
ConcurrentHashMap<String, TPaymentInfo> paymentInfoUnEmpMap,
ConcurrentHashMap<String, TPaymentInfo> paymentInfoInjuryMap,
int idx,
String type) {
int i = idx; int i = idx;
List<TPaymentInfoImportLog> logList = new ArrayList<>();
if (Common.isNotNull(list)) { if (Common.isNotNull(list)) {
TPaymentInfo payExists = null; TPaymentInfo payExists = null;
TSocialInfo socialInfo = null; TSocialInfo socialInfo = null;
...@@ -1989,7 +1803,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -1989,7 +1803,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
infoVo.setEmpIdcard(infoVo.getEmpIdcard().replace("x", "X")); infoVo.setEmpIdcard(infoVo.getEmpIdcard().replace("x", "X"));
} }
//导入校验 //导入校验
if (socialThreeCheckBase(random, i, logList, infoVo, type)) { if (socialThreeCheckBase(random, i, errorMessageList, infoVo, type)) {
continue; continue;
} }
//无对应员工的社保数据 //无对应员工的社保数据
...@@ -2005,13 +1819,10 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -2005,13 +1819,10 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
} }
//对身份证与人员姓名的对应关系进行校验 //对身份证与人员姓名的对应关系进行校验
if (socialInfo != null && !socialInfo.getEmpName().equals(infoVo.getEmpName())) { if (socialInfo != null && !socialInfo.getEmpName().equals(infoVo.getEmpName())) {
logList.add(new TPaymentInfoImportLog(null, infoVo.getEmpName(), infoVo.getEmpIdcard() errorMessageList.add(new ErrorMessage(infoVo.getRowIndex(), "姓名与身份证信息不一致,请核实后再次尝试!"));
, CommonConstants.ERROR_MSG_PRFIX + "姓名与身份证信息不一致,请核实后再次尝试!", i, random));
continue;
} }
if (socialInfo != null && socialInfo.getSocialStartDate() == null) { if (socialInfo != null && socialInfo.getSocialStartDate() == null) {
logList.add(new TPaymentInfoImportLog(null, infoVo.getEmpName(), infoVo.getEmpIdcard() errorMessageList.add(new ErrorMessage(infoVo.getRowIndex(), infoVo.getEmpIdcard() + "的社保起缴日期为空!"));
, CommonConstants.ERROR_MSG_PRFIX + infoVo.getEmpIdcard() + "的社保起缴日期为空!", i, random));
continue; continue;
} }
if (null == socialInfo || (null != socialInfo && !ServiceUtil.checkMothForPaymentImport( if (null == socialInfo || (null != socialInfo && !ServiceUtil.checkMothForPaymentImport(
...@@ -2023,8 +1834,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -2023,8 +1834,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
+ CommonConstants.DOWN_LINE_STRING + (null == infoVo.getSocialTown() ? "null" : infoVo.getSocialTown())); + CommonConstants.DOWN_LINE_STRING + (null == infoVo.getSocialTown() ? "null" : infoVo.getSocialTown()));
//对身份证与人员姓名的对应关系进行校验 //对身份证与人员姓名的对应关系进行校验
if (socialInfo != null && !socialInfo.getEmpName().equals(infoVo.getEmpName())) { if (socialInfo != null && !socialInfo.getEmpName().equals(infoVo.getEmpName())) {
logList.add(new TPaymentInfoImportLog(null, infoVo.getEmpName(), infoVo.getEmpIdcard() errorMessageList.add(new ErrorMessage(infoVo.getRowIndex(), "姓名与身份证信息不一致,请核实后再次尝试!"));
, CommonConstants.ERROR_MSG_PRFIX + "姓名与身份证信息不一致,请核实后再次尝试!", i, random));
continue; continue;
} }
if (null != socialInfo && !ServiceUtil.checkMothForPaymentImport(socialInfo.getSocialStartDate() if (null != socialInfo && !ServiceUtil.checkMothForPaymentImport(socialInfo.getSocialStartDate()
...@@ -2044,23 +1854,20 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -2044,23 +1854,20 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
} }
} }
if (null == socialInfo) { if (null == socialInfo) {
logList.add(new TPaymentInfoImportLog(null, infoVo.getEmpName(), infoVo.getEmpIdcard() errorMessageList.add(new ErrorMessage(infoVo.getRowIndex(), "无对应员工" + infoVo.getEmpIdcard() +
, CommonConstants.ERROR_MSG_PRFIX + "无对应员工" + infoVo.getEmpIdcard() + "的社保数据(请查验社保办理状态|缴纳地|起缴月份|停缴月份)"));
"的社保数据(请查验社保办理状态|缴纳地|起缴月份|停缴月份)", i, random));
continue; continue;
} }
//如果导入项目数大于办理成功项目数给提示,少于给进,有问题自行删除后导入 //如果导入项目数大于办理成功项目数给提示,少于给进,有问题自行删除后导入
checkRes = checkRepeatInfoThree(socialInfo, infoVo, type); checkRes = checkRepeatInfoThree(socialInfo, infoVo, type);
if (null != checkRes) { if (null != checkRes) {
logList.add(new TPaymentInfoImportLog(null, infoVo.getEmpName(), infoVo.getEmpIdcard() errorMessageList.add(new ErrorMessage(infoVo.getRowIndex(), checkRes));
, CommonConstants.ERROR_MSG_PRFIX + checkRes, i, random));
continue; continue;
} }
//查看缴纳月是否为空 //查看缴纳月是否为空
if (!Common.isNotNull(infoVo.getSocialPayMonth())) { if (!Common.isNotNull(infoVo.getSocialPayMonth())) {
logList.add(new TPaymentInfoImportLog(null, infoVo.getEmpName(), infoVo.getEmpIdcard() errorMessageList.add(new ErrorMessage(infoVo.getRowIndex(), "必填项校验失败:社保缴纳月份不可为空!"));
, CommonConstants.ERROR_MSG_PRFIX + "必填项校验失败:社保缴纳月份不可为空!", i, random));
continue; continue;
} }
...@@ -2081,9 +1888,8 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -2081,9 +1888,8 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
BigDecimalUtils.isNullToZero(infoVo.getUnitSet())), BigDecimalUtils.safeAdd( BigDecimalUtils.isNullToZero(infoVo.getUnitSet())), BigDecimalUtils.safeAdd(
BigDecimalUtils.isNullToZero(payExists.getUnitPensionMoney()), BigDecimalUtils.isNullToZero(payExists.getUnitPensionMoney()),
BigDecimalUtils.isNullToZero(payExists.getPersonalPensionMoney()))).compareTo(BigDecimal.ZERO) > 0) { BigDecimalUtils.isNullToZero(payExists.getPersonalPensionMoney()))).compareTo(BigDecimal.ZERO) > 0) {
logList.add(new TPaymentInfoImportLog(null, infoVo.getEmpName(), infoVo.getEmpIdcard() errorMessageList.add(new ErrorMessage(infoVo.getRowIndex(), "已存在对应员工身份证" + infoVo.getEmpIdcard()
, CommonConstants.ERROR_MSG_PRFIX + "已存在对应员工身份证" + infoVo.getEmpIdcard() + "的养老缴费数据,请勿重复导入!"));
+ "的养老缴费数据,请勿重复导入!", i, random));
continue; continue;
} else { } else {
payExists = null; payExists = null;
...@@ -2107,9 +1913,8 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -2107,9 +1913,8 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
BigDecimalUtils.isNullToZero(infoVo.getUnitSet())), BigDecimalUtils.safeAdd( BigDecimalUtils.isNullToZero(infoVo.getUnitSet())), BigDecimalUtils.safeAdd(
BigDecimalUtils.isNullToZero(payExists.getUnitUnemploymentMoney()), BigDecimalUtils.isNullToZero(payExists.getUnitUnemploymentMoney()),
BigDecimalUtils.isNullToZero(payExists.getPersonalUnemploymentMoney()))).compareTo(BigDecimal.ZERO) > 0) { BigDecimalUtils.isNullToZero(payExists.getPersonalUnemploymentMoney()))).compareTo(BigDecimal.ZERO) > 0) {
logList.add(new TPaymentInfoImportLog(null, infoVo.getEmpName(), infoVo.getEmpIdcard() errorMessageList.add(new ErrorMessage(infoVo.getRowIndex(), "已存在对应员工身份证" + infoVo.getEmpIdcard()
, CommonConstants.ERROR_MSG_PRFIX + "已存在对应员工身份证" + infoVo.getEmpIdcard() + "的失业缴费数据,请勿重复导入!"));
+ "的失业缴费数据,请勿重复导入!", i, random));
continue; continue;
} else { } else {
payExists = null; payExists = null;
...@@ -2134,9 +1939,8 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -2134,9 +1939,8 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
BigDecimalUtils.isNullToZero(infoVo.getPersonalMedicalMoney())), BigDecimalUtils.safeAdd( BigDecimalUtils.isNullToZero(infoVo.getPersonalMedicalMoney())), BigDecimalUtils.safeAdd(
BigDecimalUtils.isNullToZero(payExists.getUnitMedicalMoney()), BigDecimalUtils.isNullToZero(payExists.getUnitMedicalMoney()),
BigDecimalUtils.isNullToZero(payExists.getPersonalMedicalMoney()))).compareTo(BigDecimal.ZERO) > 0) { BigDecimalUtils.isNullToZero(payExists.getPersonalMedicalMoney()))).compareTo(BigDecimal.ZERO) > 0) {
logList.add(new TPaymentInfoImportLog(null, infoVo.getEmpName(), infoVo.getEmpIdcard() errorMessageList.add(new ErrorMessage(infoVo.getRowIndex(), "已存在对应员工身份证" + infoVo.getEmpIdcard()
, CommonConstants.ERROR_MSG_PRFIX + "已存在对应员工身份证" + infoVo.getEmpIdcard() + "的医保缴费数据,请勿重复导入!"));
+ "的医保缴费数据,请勿重复导入!", i, random));
continue; continue;
} else { } else {
payExists = null; payExists = null;
...@@ -2160,9 +1964,8 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -2160,9 +1964,8 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
BigDecimalUtils.isNullToZero(infoVo.getUnitMedicalMoney()), BigDecimalUtils.isNullToZero(infoVo.getUnitMedicalMoney()),
BigDecimalUtils.isNullToZero(infoVo.getPersonalMedicalMoney())), BigDecimalUtils.isNullToZero(infoVo.getPersonalMedicalMoney())),
BigDecimalUtils.isNullToZero(payExists.getUnitInjuryMoney())).compareTo(BigDecimal.ZERO) > 0) { BigDecimalUtils.isNullToZero(payExists.getUnitInjuryMoney())).compareTo(BigDecimal.ZERO) > 0) {
logList.add(new TPaymentInfoImportLog(null, infoVo.getEmpName(), infoVo.getEmpIdcard() errorMessageList.add(new ErrorMessage(infoVo.getRowIndex(), "已存在对应员工身份证" + infoVo.getEmpIdcard()
, CommonConstants.ERROR_MSG_PRFIX + "已存在对应员工身份证" + infoVo.getEmpIdcard() + "的单位工伤缴费数据,请勿重复导入!"));
+ "的单位工伤缴费数据,请勿重复导入!", i, random));
continue; continue;
} else { } else {
payExists = null; payExists = null;
...@@ -2278,58 +2081,44 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -2278,58 +2081,44 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
if (null != payExists && Common.isNotNull(payExists.getId())) { if (null != payExists && Common.isNotNull(payExists.getId())) {
res = baseMapper.updateById(payExists); res = baseMapper.updateById(payExists);
if (res < 0) { if (res < 0) {
logList.add(new TPaymentInfoImportLog(null, infoVo.getEmpName(), infoVo.getEmpIdcard() errorMessageList.add(new ErrorMessage(infoVo.getRowIndex(), infoVo.getEmpIdcard() + "_缴费库更新失败!"));
, CommonConstants.ERROR_MSG_PRFIX + infoVo.getEmpIdcard() + "_缴费库更新失败!", i, random));
continue;
} else {
logList.add(new TPaymentInfoImportLog(null, infoVo.getEmpName(), infoVo.getEmpIdcard()
, CommonConstants.SUCCESS_MSG_PREFIX + infoVo.getEmpIdcard() + "_缴费库更新成功!", i, random));
continue; continue;
} }
} else { } else {
res = insertAndSTimestamp(payExists); res = insertAndSTimestamp(payExists);
if (res < 0) { if (res < 0) {
logList.add(new TPaymentInfoImportLog(null, infoVo.getEmpName(), infoVo.getEmpIdcard() errorMessageList.add(new ErrorMessage(infoVo.getRowIndex(), infoVo.getEmpIdcard() + "_缴费库保存失败!"));
, CommonConstants.ERROR_MSG_PRFIX + infoVo.getEmpIdcard() + "_缴费库保存失败!", i, random));
continue; continue;
} }
} }
logList.add(new TPaymentInfoImportLog(null, infoVo.getEmpName(), infoVo.getEmpIdcard()
, CommonConstants.SUCCESS_MSG_PREFIX + "保存成功!", i, random));
} }
itemMap.clear(); itemMap.clear();
cusMap.clear(); cusMap.clear();
} else {
return null;
} }
return logList; return errorMessageList;
} }
/** /**
* 导入校验 * 导入校验
**/ **/
private boolean socialThreeCheckBase(String random, int i, List<TPaymentInfoImportLog> logList, TPaymentHeFeiVo private boolean socialThreeCheckBase(String random, int i, List<ErrorMessage> errorMessageList, TPaymentHeFeiVo
infoVo, String type) { infoVo, String type) {
if (!Common.isNotNull(infoVo.getSocialPayMonth())) { if (!Common.isNotNull(infoVo.getSocialPayMonth())) {
logList.add(new TPaymentInfoImportLog(null, infoVo.getEmpName(), infoVo.getEmpIdcard() errorMessageList.add(new ErrorMessage(infoVo.getRowIndex(), "社保缴纳月份不可为空!"));
, CommonConstants.ERROR_MSG_PRFIX + "社保缴纳月份不可为空!", i, random));
return true; return true;
} }
if (!Common.isNotNull(infoVo.getSocialCreateMonth())) { if (!Common.isNotNull(infoVo.getSocialCreateMonth())) {
logList.add(new TPaymentInfoImportLog(null, infoVo.getEmpName(), infoVo.getEmpIdcard() errorMessageList.add(new ErrorMessage(infoVo.getRowIndex(), "社保生成月份不可为空!"));
, CommonConstants.ERROR_MSG_PRFIX + "社保生成月份不可为空!", i, random));
return true; return true;
} }
if (!Common.isNotNull(infoVo.getSocialPayAddr())) { if (!Common.isNotNull(infoVo.getSocialPayAddr())) {
logList.add(new TPaymentInfoImportLog(null, infoVo.getEmpName(), infoVo.getEmpIdcard() errorMessageList.add(new ErrorMessage(infoVo.getRowIndex(), "社保缴纳地不可为空!"));
, CommonConstants.ERROR_MSG_PRFIX + "社保缴纳地不可为空!", i, random));
return true; return true;
} }
if (CommonConstants.ZERO_STRING.equals(type) && !PaymentConstants.PENSION_RISK.equals(infoVo.getRiskType()) if (CommonConstants.ZERO_STRING.equals(type) && !PaymentConstants.PENSION_RISK.equals(infoVo.getRiskType())
&& !PaymentConstants.UNEMPLOYEEMENT_RISK.equals(infoVo.getRiskType()) && !PaymentConstants.UNEMPLOYEEMENT_RISK.equals(infoVo.getRiskType())
&& !PaymentConstants.INJURY_RISK.equals(infoVo.getRiskType())) { && !PaymentConstants.INJURY_RISK.equals(infoVo.getRiskType())) {
logList.add(new TPaymentInfoImportLog(null, infoVo.getEmpName(), infoVo.getEmpIdcard() errorMessageList.add(new ErrorMessage(infoVo.getRowIndex(), "无相关险种!"));
, CommonConstants.ERROR_MSG_PRFIX + "无相关险种!", i, random));
return true; return true;
} }
return false; return false;
...@@ -2365,64 +2154,6 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -2365,64 +2154,6 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
return s; return s;
} }
/**
* 检验每个险种是否可以导入
*
* @param random String
* @param i int
* @param logList List<TPaymentInfoImportLog>
* @param payExists TPaymentInfoVo
* @param infoVo TPaymentHeFeiVo
* @param type String
* @return
* @Author huyc
* @Date 2022-07-27
**/
private boolean checkImportInfo(String random, int i, List<TPaymentInfoImportLog> logList, TPaymentInfoVo
payExists
, TPaymentHeFeiVo infoVo, String type) {
boolean flag;
if (CommonConstants.ZERO_STRING.equals(type)) {
// 对应养老险种已经存在金额 不合并
flag = BigDecimalUtils.safeAdd(BigDecimalUtils.isNullToZero(payExists.getUnitPensionMoney())
, BigDecimalUtils.isNullToZero(payExists.getPersonalPensionMoney())).compareTo(BigDecimal.ZERO) == 0;
if (PaymentConstants.PENSION_RISK.equals(infoVo.getRiskType()) && !flag) {
logList.add(new TPaymentInfoImportLog(null, infoVo.getEmpName(), infoVo.getEmpIdcard()
, CommonConstants.ERROR_MSG_PRFIX + "对应员工身份证" + infoVo.getEmpIdcard()
+ "养老数据已存在,请勿重复导入!", i, random));
return true;
}
// 对应失业险种已经存在金额 不合并
flag = BigDecimalUtils.safeAdd(BigDecimalUtils.isNullToZero(payExists.getUnitUnemploymentMoney())
, BigDecimalUtils.isNullToZero(payExists.getPersonalUnemploymentMoney())).compareTo(BigDecimal.ZERO) == 0;
if (PaymentConstants.UNEMPLOYEEMENT_RISK.equals(infoVo.getRiskType()) && !flag) {
logList.add(new TPaymentInfoImportLog(null, infoVo.getEmpName(), infoVo.getEmpIdcard()
, CommonConstants.ERROR_MSG_PRFIX + "对应员工身份证" + infoVo.getEmpIdcard()
+ "失业数据已存在,请勿重复导入!", i, random));
return true;
}
// 对应工伤险种已经存在金额 不合并
flag = BigDecimalUtils.isNullToZero(payExists.getUnitInjuryMoney()).compareTo(BigDecimal.ZERO) == 0;
if (PaymentConstants.INJURY_RISK.equals(infoVo.getRiskType()) && !flag) {
logList.add(new TPaymentInfoImportLog(null, infoVo.getEmpName(), infoVo.getEmpIdcard()
, CommonConstants.ERROR_MSG_PRFIX + "对应员工身份证" + infoVo.getEmpIdcard()
+ "工伤数据已存在,请勿重复导入!", i, random));
return true;
}
}
if (CommonConstants.ONE_STRING.equals(type)) {
flag = BigDecimalUtils.safeAdd(BigDecimalUtils.isNullToZero(payExists.getUnitMedicalMoney())
, BigDecimalUtils.isNullToZero(payExists.getPersonalMedicalMoney())).compareTo(BigDecimal.ZERO) == 0;
if (!flag) {
logList.add(new TPaymentInfoImportLog(null, infoVo.getEmpName(), infoVo.getEmpIdcard()
, CommonConstants.ERROR_MSG_PRFIX + "对应员工身份证" + infoVo.getEmpIdcard()
+ "医疗数据已存在,请勿重复导入!", i, random));
return true;
}
}
return false;
}
/** /**
* 验证部分办理失败的导入是否有超出部分的数据导入 * 验证部分办理失败的导入是否有超出部分的数据导入
* *
......
...@@ -26,13 +26,11 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; ...@@ -26,13 +26,11 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.unboundid.ldap.sdk.SearchResultEntry; import com.unboundid.ldap.sdk.SearchResultEntry;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDept; import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDept;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDeptRelation; import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDeptRelation;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysUser;
import com.yifu.cloud.plus.v1.yifu.admin.mapper.SysDeptMapper; import com.yifu.cloud.plus.v1.yifu.admin.mapper.SysDeptMapper;
import com.yifu.cloud.plus.v1.yifu.admin.mapper.SysUserMapper; import com.yifu.cloud.plus.v1.yifu.admin.mapper.SysUserMapper;
import com.yifu.cloud.plus.v1.yifu.admin.service.SysDeptRelationService; import com.yifu.cloud.plus.v1.yifu.admin.service.SysDeptRelationService;
import com.yifu.cloud.plus.v1.yifu.admin.service.SysDeptService; import com.yifu.cloud.plus.v1.yifu.admin.service.SysDeptService;
import com.yifu.cloud.plus.v1.yifu.admin.service.SysUserService; import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R; import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.ldap.util.LdapUtil; import com.yifu.cloud.plus.v1.yifu.common.ldap.util.LdapUtil;
import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils; import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils;
...@@ -44,7 +42,6 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -44,7 +42,6 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream;
/** /**
* <p> * <p>
...@@ -214,6 +211,9 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl ...@@ -214,6 +211,9 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
SysDept insertSysDept = new SysDept(); SysDept insertSysDept = new SysDept();
insertSysDept.setName(deptName); insertSysDept.setName(deptName);
insertSysDept.setParentId(0L); insertSysDept.setParentId(0L);
if (Common.isNotNull(entry.getAttributeValue("x-ouid"))) {
insertSysDept.setDeptId(Long.valueOf(entry.getAttributeValue("x-ouid")));
}
insertSysDept.setDeptDn(dn); insertSysDept.setDeptDn(dn);
this.save(insertSysDept); this.save(insertSysDept);
} else { } else {
...@@ -231,6 +231,9 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl ...@@ -231,6 +231,9 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
insertSysDept.setName(deptName); insertSysDept.setName(deptName);
insertSysDept.setParentId(sysDept.getDeptId()); insertSysDept.setParentId(sysDept.getDeptId());
insertSysDept.setDeptDn(dn); insertSysDept.setDeptDn(dn);
if (Common.isNotNull(entry.getAttributeValue("x-ouid"))) {
insertSysDept.setDeptId(Long.valueOf(entry.getAttributeValue("x-ouid")));
}
this.save(insertSysDept); this.save(insertSysDept);
} }
} else { } else {
......
...@@ -424,7 +424,6 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl ...@@ -424,7 +424,6 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
if (null != list) { if (null != list) {
List<SysUser> listUser = this.list(Wrappers.<SysUser>query().lambda().eq(SysUser::getDelFlag, CommonConstants.STATUS_NORMAL)); List<SysUser> listUser = this.list(Wrappers.<SysUser>query().lambda().eq(SysUser::getDelFlag, CommonConstants.STATUS_NORMAL));
List<String> list1 = listUser.stream().map(SysUser::getUsername).collect(Collectors.toList()); List<String> list1 = listUser.stream().map(SysUser::getUsername).collect(Collectors.toList());
Map<String, String> map = listUser.stream().collect(HashMap::new, (m, v) -> m.put(v.getUsername(), v.getUserId()), HashMap::putAll);
List<PersonVo> updateList = new ArrayList<>(); List<PersonVo> updateList = new ArrayList<>();
List<PersonVo> insertList = new ArrayList<>(); List<PersonVo> insertList = new ArrayList<>();
for (PersonVo personVo : list) { for (PersonVo personVo : list) {
...@@ -469,6 +468,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl ...@@ -469,6 +468,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
insertSysDept.setName(deptName); insertSysDept.setName(deptName);
insertSysDept.setParentId(0L); insertSysDept.setParentId(0L);
insertSysDept.setDeptDn(dn); insertSysDept.setDeptDn(dn);
if (Common.isNotNull(entry.getAttributeValue("x-ouid"))) {
insertSysDept.setDeptId(Long.valueOf(entry.getAttributeValue("x-ouid")));
}
sysDeptMapper.insert(insertSysDept); sysDeptMapper.insert(insertSysDept);
} else { } else {
sysDept.setName(deptName); sysDept.setName(deptName);
...@@ -484,6 +486,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl ...@@ -484,6 +486,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
insertSysDept.setName(deptName); insertSysDept.setName(deptName);
insertSysDept.setParentId(sysDept.getDeptId()); insertSysDept.setParentId(sysDept.getDeptId());
insertSysDept.setDeptDn(dn); insertSysDept.setDeptDn(dn);
if (Common.isNotNull(entry.getAttributeValue("x-ouid"))) {
insertSysDept.setDeptId(Long.valueOf(entry.getAttributeValue("x-ouid")));
}
sysDeptMapper.insert(insertSysDept); sysDeptMapper.insert(insertSysDept);
} }
} else { } else {
......
...@@ -210,7 +210,7 @@ ...@@ -210,7 +210,7 @@
<insert id="batchInsertUser" parameterType="java.util.List"> <insert id="batchInsertUser" parameterType="java.util.List">
insert into sys_user insert into sys_user
(user_id,username,phone,email,password,nickname,create_time) (user_id,username,phone,email,password,nickname,deptId,create_time)
VALUES VALUES
<foreach collection="list" item="item" index="index" separator=","> <foreach collection="list" item="item" index="index" separator=",">
( (
...@@ -220,6 +220,7 @@ ...@@ -220,6 +220,7 @@
#{item.email,jdbcType=VARCHAR}, #{item.email,jdbcType=VARCHAR},
#{item.password,jdbcType=VARCHAR}, #{item.password,jdbcType=VARCHAR},
#{item.personName,jdbcType=VARCHAR}, #{item.personName,jdbcType=VARCHAR},
#{item.deptId,jdbcType=VARCHAR},
now() now()
) )
</foreach> </foreach>
...@@ -256,6 +257,13 @@ ...@@ -256,6 +257,13 @@
</if> </if>
</foreach> </foreach>
</trim> </trim>
<trim prefix="deptId =case" suffix="end," >
<foreach collection="list" item="i" index="index">
<if test="i.deptId!=null">
when username=#{i.uid} then #{i.deptId}
</if>
</foreach>
</trim>
<trim prefix="update_time =case" suffix="end,"> <trim prefix="update_time =case" suffix="end,">
<foreach collection="list" item="i" index="index"> <foreach collection="list" item="i" index="index">
when username=#{i.uid} then now() when username=#{i.uid} then now()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment