Commit a3ab7bc5 authored by hongguangwu's avatar hongguangwu

Merge remote-tracking branch 'origin/MVP1.6.4' into MVP1.6.4

parents d0da3162 196babd1
......@@ -347,6 +347,7 @@ public interface CommonConstants {
public static final String JAR_TYPE = "jar";
int BATCH_COUNT = 100;
int BATCH_COUNT_TAX = 400;
int BATCH_COUNT1 = 2000;
String IMPORT_DATA_ANALYSIS_ERROR = "数据导入解析异常,请检查表数据格式(常见错误:1.日期格式:yyyy-MM-dd,2.比例为整数且不含%)";
......
......@@ -1317,6 +1317,15 @@ public class DateUtil {
return cal.getTime();
}
public static Date getDateOfThisMonth(Date date){
Calendar cal = Calendar.getInstance();
if (date != null) {
cal.setTime(date);
}
cal.set(Calendar.MONTH,Integer.valueOf(DateUtil.getMonth(new Date()))-1);
return cal.getTime();
}
/**
* @Description: 增减(日)
* @Author: hgw
......
......@@ -393,13 +393,6 @@ public class TPaymentInfo extends BaseEntity {
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("单位养老基数")
private BigDecimal unitPensionSet;
/**
* 单位医疗基数
*/
@ExcelAttribute(name = "单位医疗基数", isFloat = true,max = "999999999.99")
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("单位医疗基数")
private BigDecimal unitMedicalSet;
/**
* 单位失业基数
*/
......@@ -407,6 +400,13 @@ public class TPaymentInfo extends BaseEntity {
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("单位失业基数")
private BigDecimal unitUnemploymentSet;
/**
* 单位医疗基数
*/
@ExcelAttribute(name = "单位医疗基数", isFloat = true,max = "999999999.99")
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("单位医疗基数")
private BigDecimal unitMedicalSet;
/**
* 工伤基数
*/
......@@ -547,13 +547,6 @@ public class TPaymentInfo extends BaseEntity {
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("个人医疗金额")
private BigDecimal personalMedicalMoney;
/**
* 个人失业金额
*/
@ExcelAttribute(name = "个人失业金额")
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("个人失业金额")
private BigDecimal personalUnemploymentMoney;
/**
* 个人大病金额
*/
......@@ -561,6 +554,13 @@ public class TPaymentInfo extends BaseEntity {
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("个人大病金额")
private BigDecimal personalBigmailmentMoney;
/**
* 个人失业金额
*/
@ExcelAttribute(name = "个人失业金额")
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("个人失业金额")
private BigDecimal personalUnemploymentMoney;
/**
* 公积金编号
*/
......
package com.yifu.cloud.plus.v1.yifu.social.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.HeadFontStyle;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.RowIndex;
import com.yifu.cloud.plus.v1.yifu.social.util.BigDecimalConverter;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @ClassName TPaymentHeFeiVo
* @Description 税务社保明细
* @author huyc
* @date 2024-5-9 10:35:22
*/
@Data
public class TPaymentTaxSocialVo extends RowIndex implements Serializable {
/**
* 员工姓名
*/
@Length(max = 20, message = "姓名不能超过20个字符")
@ExcelAttribute(name = "姓名", maxLength = 20,isNotEmpty = true)
@Schema(description = "姓名")
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty(value = "姓名")
private String empName;
/**
* 证件类型
*/
@Length(max = 30, message = "证件类型不能超过30个字符")
@ExcelAttribute(name = "证件类型", maxLength = 30)
@Schema(description = "证件类型")
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty(value = "证件类型")
private String cardType;
/**
* 证件号码
*/
@Length(max = 50, message = "不能超过50个字符")
@ExcelAttribute(name = "证件号码", isNotEmpty = true, maxLength = 50,errorInfo = "证件号码字段不可为空!")
@Schema(description = "证件号码")
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty(value = "证件号码")
private String empIdcard;
/**
* 缴费工资
*/
@ExcelAttribute(name = "缴费工资", isFloat = true,max = "999999999.99", min= -999999999)
@Schema(description = "缴费工资")
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty(value = "缴费工资", converter = BigDecimalConverter.class)
private BigDecimal paymentSalary;
/**
* 缴费基数
*/
@ExcelAttribute(name = "缴费基数", isFloat = true,max = "999999999.99")
@Schema(description = "缴费基数")
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty(value = "缴费基数", converter = BigDecimalConverter.class)
private BigDecimal paymentSet;
/**
* 费率
*/
@ExcelAttribute(name = "费率")
@Schema(description = "费率")
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty(value = "费率")
private String paymentPer;
/**
* 应缴费额
*/
@ExcelAttribute(name = "应缴费额", isFloat = true,max = "999999999.99", min= -999999999)
@Schema(description = "应缴费额")
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty(value = "应缴费额", converter = BigDecimalConverter.class)
private BigDecimal paymentMoney;
/**
* 人员编号
*/
@ExcelAttribute(name = "人员编号")
@Schema(description = "人员编号")
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty(value = "人员编号")
private String empNo;
/**
* 险种
*/
@ExcelAttribute(name = "险种")
@Schema(description = "险种")
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty(value = "险种")
private String riskType;
/**
* 社保缴纳地
*/
@Length(max = 50, message = "社保缴纳地不能超过50个字符")
@ExcelAttribute(name = "社保缴纳地", isNotEmpty = true, errorInfo = "社保缴纳地不可为空", maxLength = 50)
@Schema(description = "社保缴纳地")
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty(value = "社保缴纳地")
private String socialPayAddr;
/**
* 社保缴纳地-省
*/
@Length(max = 32, message = "不能超过32个字符")
@ExcelAttribute(name = "社保缴纳地-省", maxLength = 32, isDataId = true, isArea = true, parentField = "")
@Schema(description = "社保缴纳地-省")
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty(value = "社保缴纳地-省")
private Integer socialProvince;
/**
* 社保缴纳地-市
*/
@Length(max = 32, message = "不能超过32个字符")
@ExcelAttribute(name = "社保缴纳地-市", maxLength = 32, isDataId = true, isArea = true, parentField = "socialProvince")
@Schema(description = "社保缴纳地-市")
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty(value = "社保缴纳地-市")
private Integer socialCity;
/**
* 社保缴纳地-县
*/
@Length(max = 32, message = "不能超过32个字符")
@ExcelAttribute(name = "社保缴纳地-县", maxLength = 32, isDataId = true, isArea = true, parentField = "socialCity")
@Schema(description = "社保缴纳地-县")
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty(value = "社保缴纳地-县")
private Integer socialTown;
/**
* 社保缴纳月份
*/
@ExcelAttribute(name = "社保缴纳月份", isNotEmpty = true, errorInfo = "社保缴纳月份不可为空", maxLength = 6, min = 6, isInteger = true)
@Schema(description = "社保缴纳月份")
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty(value = "社保缴纳月份")
private String socialPayMonth;
/**
* 社保生成月份
*/
@Length(max = 6, message = "社保生成月份不能超过6个字符")
@ExcelAttribute(name = "社保生成月份", isNotEmpty = true, errorInfo = "社保生成月份不可为空", maxLength = 6, min = 6,isInteger = true)
@Schema(description = "社保生成月份")
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty(value = "社保生成月份")
private String socialCreateMonth;
/**
* 社保户
*/
@Length(max = 32, message = "社保户不能超过32个字符")
@ExcelAttribute(name = "社保户", maxLength = 32)
@Schema(description = "社保户")
private String socialHousehold;
}
......@@ -11,7 +11,20 @@ public class PaymentConstants {
public static final String UNEMPLOYEEMENT_RISK = "失业保险";
public static final String INJURY_RISK = "工伤保险";
public static final String MEDICAL = "医疗";
public static final String BIG = "大病";
public static final String BIRTH = "生育";
public static final String EXPORT = "缴费库合并导出";
public static final String SEARCH_EXPORT = "缴费库查询合并导出";
public static final String PAYMENT_SEARCH_EXPORT = "实缴查询批量导出";
public static final String COMPANY_YL = "单位养老";
public static final String PENSION_YL = "个人养老";
public static final String COMPANY_MEDICAL = "单位医疗";
public static final String PENSION_MEDICAL = "个人医疗";
public static final String COMPANY_UNEMPLOYEEMENT = "单位失业";
public static final String PENSION_UNEMPLOYEEMENT = "个人失业";
public static final String COMPANY_INJURY_RISK = "单位工伤";
public static final String COMPANY_BIG = "单位大病救助金";
public static final String PENSION_BIG = "个人大病救助金";
public static final String COMPANY_BIRTH = "单位生育";
public static final String PENSION_BIRTH = "个人生育";
}
......@@ -86,6 +86,13 @@ public class FailReasonConfigController {
@SysLog("修改失败原因配置" )
@PutMapping
public R<Boolean> updateById(@RequestBody FailReasonConfig failReasonConfig) {
FailReasonConfig failReasonCount = failReasonConfigService.getOne(Wrappers.<FailReasonConfig>query().lambda()
.eq(FailReasonConfig::getReasonKey,failReasonConfig.getReasonKey())
.ne(FailReasonConfig::getId,failReasonConfig.getId())
.last(CommonConstants.LAST_ONE_SQL));
if(Optional.ofNullable(failReasonCount).isPresent()) {
return R.failed("已存在对应的关键字的失败原因配置!");
}
YifuUser user = SecurityUtils.getUser();
if (Common.isNotNull(user)) {
failReasonConfig.setUpdateName(user.getNickname());
......
......@@ -603,4 +603,40 @@ public class TPaymentInfoController {
public Boolean updateSocialSettleStatus(@RequestBody List<EkpSocialViewVo> viewVo) {
return tPaymentInfoService.updateSocialSettleStatus(viewVo);
}
/**
* 税务社保明细导入
*
* @author huyc
* @date 2024-5-9
**/
@SneakyThrows
@Operation(description = "税务社保明细导入")
@SysLog("税务社保明细导入")
@PostMapping("/importTaxSocialInfoList")
public R<List<ErrorDetailVO>> importTaxSocialInfoList(@RequestBody MultipartFile file) {
YifuUser user = SecurityUtils.getUser();
if (Common.isEmpty(user)){
return R.failed(CommonConstants.USER_FAIL);
}
// 获取redis分布式事务锁
String key = CacheConstants.PAYMENT_SOCIAL_THREE_IMPORT + CommonConstants.DOWN_LINE_STRING + user.getId();
String requestId;
try {
requestId = RedisDistributedLock.getLock(key,"10");
} catch (Exception e) {
throw new RuntimeException(ResultConstants.NO_GETLOCK_DATA+CommonConstants.DOWN_LINE_STRING+e.getMessage());
}
try {
if (Common.isNotNull(requestId)) {
return tPaymentInfoService.importTaxSocialInfoDiy(file.getInputStream());
} else {
return R.failed(ResultConstants.NO_GETLOCK_DATA);
}
}finally {
//主动释放锁
RedisDistributedLock.unlock(key, requestId);
}
}
}
......@@ -74,6 +74,13 @@ public interface TPaymentInfoService extends IService<TPaymentInfo> {
*/
R<List<ErrorDetailVO>> importSocialHeFeiDiy(InputStream inputStream, String random, String type);
/**
* 税务社保明细导入
* @param inputStream
* @return
*/
R<List<ErrorDetailVO>> importTaxSocialInfoDiy(InputStream inputStream);
/**
* 批量导入公积金
* @param inputStream
......
......@@ -1688,6 +1688,170 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
return this.judgeAllMessage(errorMessageList);
}
@Override
public R<List<ErrorDetailVO>> importTaxSocialInfoDiy(InputStream inputStream) {
YifuUser user = SecurityUtils.getUser();
String sumNumKey = user.getId() + CommonConstants.DOWN_LINE_STRING + "sum_key";
if (Common.isNotNull(redisUtil.get(sumNumKey))) {
redisUtil.remove(sumNumKey);
}
String importSuccessKey = user.getId() + CommonConstants.DOWN_LINE_STRING + CommonConstants.PAYMENT_SOCIAL_WAIT_EXPORT;
if (Common.isNotNull(redisUtil.get(importSuccessKey))) {
redisUtil.remove(importSuccessKey);
}
//养老插入的集合
ConcurrentHashMap<String,TPaymentInfo> batchYlInsertList = new ConcurrentHashMap<>();
//工伤插入的集合
ConcurrentHashMap<String,TPaymentInfo> batchGsInsertList = new ConcurrentHashMap<>();
//失业插入的集合
ConcurrentHashMap<String,TPaymentInfo> batchSyInsertList = new ConcurrentHashMap<>();
//医疗插入的集合
ConcurrentHashMap<String,TPaymentInfo> batchYyInsertList = new ConcurrentHashMap<>();
//大病插入的集合
ConcurrentHashMap<String,TPaymentInfo> batchBigInsertList = new ConcurrentHashMap<>();
//生育插入的集合
ConcurrentHashMap<String,TPaymentInfo> batchBirthInsertList = new ConcurrentHashMap<>();
//获取所有项目信息
Map<String, TSettleDomainSelectVo> domainMap = this.getSelectVoMap();
//地区数据
HashMap<String, String> areaMap = new HashMap<>();
HashMap<String, String> areaMap2 = new HashMap<>();
R<AreaVo> areaListR = upmsDaprUtils.getAreaListR();
if (Common.isNotNull(areaListR)) {
AreaVo areaList = areaListR.getData();
if (null != areaList && !areaList.getSysAreaList().isEmpty()) {
for (SysArea area : areaList.getSysAreaList()) {
areaMap.put(Integer.toString(area.getId()), area.getAreaName());
areaMap2.put(area.getAreaName() + CommonConstants.DOWN_LINE_STRING + (
null == area.getParentId() ? "null" : (0 == area.getParentId() ? "null" : Integer.toString(
area.getParentId()))), Integer.toString(area.getId()));
}
}
}
ConcurrentHashMap<String, ErrorDetailVO> errorMessageMap = new ConcurrentHashMap<>();
ExcelUtil<TPaymentTaxSocialVo> util1 = new ExcelUtil<>(TPaymentTaxSocialVo.class);
ConcurrentHashMap<String, BigDecimal> pensionMoneyMap = new ConcurrentHashMap<>();
ConcurrentHashMap<String, BigDecimal> bigMoneyMap = new ConcurrentHashMap<>();
ConcurrentHashMap<String, BigDecimal> unEmpMoneyMap = new ConcurrentHashMap<>();
ConcurrentHashMap<String, BigDecimal> injuryMoneyMap = new ConcurrentHashMap<>();
ConcurrentHashMap<String, BigDecimal> medicalMoneyMap = new ConcurrentHashMap<>();
ConcurrentHashMap<String, BigDecimal> birthMoneyMap = new ConcurrentHashMap<>();
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try {
EasyExcel.read(inputStream, TPaymentTaxSocialVo.class, new ReadListener<TPaymentTaxSocialVo>() {
/**
* 单次缓存的数据量
*/
public static final int BATCH_COUNT = CommonConstants.BATCH_COUNT_TAX;
Integer rowNumber;
/**
*临时存储
*/
private List<TPaymentTaxSocialVo> cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
@Override
public void invoke(TPaymentTaxSocialVo data, AnalysisContext context) {
// 获取总行数(含表头)
rowNumber = context.readSheetHolder().getApproximateTotalRowNumber();
ReadRowHolder readRowHolder = context.readRowHolder();
Integer rowIndex = readRowHolder.getRowIndex();
data.setRowIndex(rowIndex + 1);
ErrorMessage errorMessage = util1.checkEntity(data, data.getRowIndex());
if (Common.isNotNull(errorMessage)) {
errorMessageMap.put(UUID.randomUUID().toString(),new ErrorDetailVO(errorMessage.getLineNum(), errorMessage.getMessage()));
} else {
cachedDataList.add(data);
}
if (cachedDataList.size() >= BATCH_COUNT) {
saveData();
// 存储完成清理 list
cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
}
}
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
saveData();
}
/**
* 加上存储数据库
*/
private void saveData() {
log.info("{}条数据,开始存储数据库!", cachedDataList.size());
importTPaymentSocialTax(cachedDataList, errorMessageMap, rowNumber, pensionMoneyMap,birthMoneyMap,
bigMoneyMap, unEmpMoneyMap, injuryMoneyMap, medicalMoneyMap, sumNumKey, importSuccessKey
, batchGsInsertList,batchSyInsertList,batchYlInsertList,batchYyInsertList,
batchBigInsertList, batchBirthInsertList,areaMap,
areaMap2,domainMap);
log.info("存储数据库成功!");
}
}).sheet().doRead();
pensionMoneyMap.clear();
bigMoneyMap.clear();
unEmpMoneyMap.clear();
injuryMoneyMap.clear();
medicalMoneyMap.clear();
birthMoneyMap.clear();
areaMap.clear();
areaMap2.clear();
domainMap.clear();
//批量插入数据
//养老
List<TPaymentInfo> list;
if (!batchYlInsertList.isEmpty()) {
list = new ArrayList<>(batchYlInsertList.values());
this.saveBatch(list);
batchYlInsertList.clear();
list.clear();
}
//工伤
if (!batchGsInsertList.isEmpty()) {
list = new ArrayList<>(batchGsInsertList.values());
this.saveBatch(list);
batchGsInsertList.clear();
list.clear();
}
//医疗
if (!batchYyInsertList.isEmpty()) {
list = new ArrayList<>(batchYyInsertList.values());
this.saveBatch(list);
batchYyInsertList.clear();
list.clear();
}
//失业
if (!batchSyInsertList.isEmpty()) {
list = new ArrayList<>(batchSyInsertList.values());
this.saveBatch(list);
batchSyInsertList.clear();
list.clear();
}
//大病
if (!batchBigInsertList.isEmpty()) {
list = new ArrayList<>(batchBigInsertList.values());
this.saveBatch(list);
batchBigInsertList.clear();
list.clear();
}
//生育
if (!batchBirthInsertList.isEmpty()) {
list = new ArrayList<>(batchBirthInsertList.values());
this.saveBatch(list);
batchBirthInsertList.clear();
list.clear();
}
} catch (Exception e) {
log.error(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR, e);
return R.failed(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR);
}
List<ErrorDetailVO> errorMessageList = new ArrayList<>(errorMessageMap.values());
errorMessageMap.clear();
return this.judgeAllMessage(errorMessageList);
}
@Override
public R<List<ErrorDetailVO>> batchImportPaymentFundInfo(InputStream inputStream) {
List<ErrorDetailVO> errorMessageList = new ArrayList<>();
......@@ -2044,10 +2208,11 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
}
}
private void importTPaymentSocialHeFei(List<TPaymentHeFeiVo> list,
private void importTPaymentSocialTax(List<TPaymentTaxSocialVo> list,
ConcurrentHashMap<String, ErrorDetailVO> errorMessageList,
String type, Integer rowNumber,
Integer rowNumber,
ConcurrentHashMap<String, BigDecimal> pensionMoneyMap,
ConcurrentHashMap<String, BigDecimal> birthMoneyMap,
ConcurrentHashMap<String, BigDecimal> bigMoneyMap,
ConcurrentHashMap<String, BigDecimal> unEmpMoneyMap,
ConcurrentHashMap<String, BigDecimal> injuryMoneyMap,
......@@ -2057,19 +2222,20 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
ConcurrentHashMap<String,TPaymentInfo> batchSyInsertList,
ConcurrentHashMap<String,TPaymentInfo> batchYlInsertList,
ConcurrentHashMap<String,TPaymentInfo> batchYyInsertList,
ConcurrentHashMap<String, TPaymentInfo> batchBigInsertList,
ConcurrentHashMap<String, TPaymentInfo> batchBirthInsertList,
HashMap<String, String> areaMap,
HashMap<String, String> areaMap2,Map<String,TSettleDomainSelectVo> domainMap) {
// 将以下代码提取出来,使用paymentInfoMap提升性能,避免list多次循环查询数据库浪费性能
// 导入前做队列空闲判断,防止队列不足出现数据丢失的场景
if (CollUtil.isNotEmpty(list)) {
int taskSize = list.size() / partSize + CommonConstants.ONE_INT;
int residualCapacity = yfSocialImportThreadPoolExecutor.getResidualCapacity();
if (taskSize > residualCapacity) {
errorMessageList.put(UUID.randomUUID().toString(),new ErrorDetailVO(-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());
//已存在社保缴费库数据 非删除状态
......@@ -2085,9 +2251,10 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
ConcurrentHashMap<String, TPaymentInfo> paymentInfoInjuryMap = new ConcurrentHashMap<>();
//医保
ConcurrentHashMap<String, TPaymentInfo> paymentInfoMedicalMap = new ConcurrentHashMap<>();
//生育
ConcurrentHashMap<String, TPaymentInfo> paymentInfoBirthMap = new ConcurrentHashMap<>();
if (Common.isNotNull(paymentInfos)) {
for (TPaymentInfo info : paymentInfos) {
if (BigDecimalUtils.safeAdd(BigDecimalUtils.isNullToZero(info.getUnitPensionMoney()),
BigDecimalUtils.isNullToZero(info.getPersonalPensionMoney())).compareTo(BigDecimal.ZERO) != 0) {
if (null != paymentInfoPensionMap.get(info.getSocialPayAddr()
......@@ -2207,9 +2374,31 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
+ SocialConstants.DB
, info);
}
if (BigDecimalUtils.isNullToZero(info.getUnitBirthMoney()).compareTo(BigDecimal.ZERO) != 0) {
if (null != paymentInfoBirthMap.get(info.getSocialPayAddr()
+ CommonConstants.DOWN_LINE_STRING
+ info.getEmpIdcard()
+ CommonConstants.DOWN_LINE_STRING
+ info.getSocialPayMonth()
+ CommonConstants.DOWN_LINE_STRING
+ info.getSocialCreateMonth()
+ CommonConstants.DOWN_LINE_STRING
+ SocialConstants.BIR)) {
info.setBrSameFlg("1");
}
paymentInfoBirthMap.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
+ SocialConstants.BIR
, info);
}
}
}
// -----------------------------生成paymentInfoMap本段结束--------------------------------
// -----------------------------线程池处理list,批量保存社保信息开始--------------------------------
List<CompletableFuture<ConcurrentHashMap<String, ErrorDetailVO>>> completableFutureList = new ArrayList<>();
......@@ -2243,25 +2432,25 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
// 1.list.size()不足100时直接执行
if (list.size() < 100) {
CompletableFuture<ConcurrentHashMap<String, ErrorDetailVO>> listCompletableFuture = CompletableFuture.supplyAsync(()
-> executeImportSocialListThree(list, areaMap, areaMap2,
-> executeImportSocialListTax(list, areaMap, areaMap2,
paymentInfoPensionMap, paymentInfoMedicalMap, paymentInfoUnEmpMap, paymentInfoInjuryMap,
paymentInfoBigMap, type, errorMessageList, pensionMoneyMap, bigMoneyMap,
paymentInfoBigMap, errorMessageList, pensionMoneyMap, birthMoneyMap,bigMoneyMap,
unEmpMoneyMap, injuryMoneyMap, medicalMoneyMap, batchGsInsertList,
batchSyInsertList, batchYlInsertList, batchYyInsertList,domainMap),
batchSyInsertList, batchYlInsertList, batchYyInsertList, batchBigInsertList, batchBirthInsertList,domainMap),
yfSocialImportThreadPoolExecutor);
completableFutureList.add(listCompletableFuture);
} else {
int j = 25;
for (int i = 0; i < 100; i = i + 25) {
// 单个线程每次执行25条
List<TPaymentHeFeiVo> finalTempList1 = list.subList(i,i+j);
List<TPaymentTaxSocialVo> finalTempList1 = list.subList(i,i+j);
CompletableFuture<ConcurrentHashMap<String, ErrorDetailVO>> listCompletableFuture = CompletableFuture.supplyAsync(()
-> executeImportSocialListThree(finalTempList1
-> executeImportSocialListTax(finalTempList1
, areaMap, areaMap2, paymentInfoPensionMap, paymentInfoMedicalMap,
paymentInfoUnEmpMap, paymentInfoInjuryMap, paymentInfoBigMap, type,
errorMessageList, pensionMoneyMap, bigMoneyMap, unEmpMoneyMap,
paymentInfoUnEmpMap, paymentInfoInjuryMap, paymentInfoBigMap,
errorMessageList, pensionMoneyMap, birthMoneyMap, bigMoneyMap, unEmpMoneyMap,
injuryMoneyMap, medicalMoneyMap, batchGsInsertList, batchSyInsertList,
batchYlInsertList, batchYyInsertList, domainMap),
batchYlInsertList, batchYyInsertList, batchBigInsertList, batchBirthInsertList, domainMap),
yfSocialImportThreadPoolExecutor);
completableFutureList.add(listCompletableFuture);
}
......@@ -2295,50 +2484,301 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
}
}
private ConcurrentHashMap<String, ErrorDetailVO> executeImportSocialListThree(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,
ConcurrentHashMap<String, TPaymentInfo> paymentInfoBigMap,
String type, ConcurrentHashMap<String, ErrorDetailVO> errorMessageList,
ConcurrentHashMap<String, BigDecimal> pensionMoneyMap,
ConcurrentHashMap<String, BigDecimal> bigMoneyMap,
ConcurrentHashMap<String, BigDecimal> unEmpMoneyMap,
ConcurrentHashMap<String, BigDecimal> injuryMoneyMap,
ConcurrentHashMap<String, BigDecimal> medicalMoneyMap,
ConcurrentHashMap<String, TPaymentInfo> batchGsInsertList,
ConcurrentHashMap<String, TPaymentInfo> batchSyInsertList,
ConcurrentHashMap<String, TPaymentInfo> batchYlInsertList,
ConcurrentHashMap<String, TPaymentInfo> batchYyInsertList,
Map<String,TSettleDomainSelectVo> domainMap) {
if (Common.isNotNull(list)) {
TPaymentInfo payExists;
TSocialFundInfo socialInfo = null;
TSocialInfo tSocialInfo = null;
String temp;
List<TSocialInfo> socialist;
TSettleDomain domain;
private void importTPaymentSocialHeFei(List<TPaymentHeFeiVo> list,
ConcurrentHashMap<String, ErrorDetailVO> errorMessageList,
String type, Integer rowNumber,
ConcurrentHashMap<String, BigDecimal> pensionMoneyMap,
ConcurrentHashMap<String, BigDecimal> bigMoneyMap,
ConcurrentHashMap<String, BigDecimal> unEmpMoneyMap,
ConcurrentHashMap<String, BigDecimal> injuryMoneyMap,
ConcurrentHashMap<String, BigDecimal> medicalMoneyMap,
String sumNumKey, String importSuccessKey,
ConcurrentHashMap<String,TPaymentInfo> batchGsInsertList,
ConcurrentHashMap<String,TPaymentInfo> batchSyInsertList,
ConcurrentHashMap<String,TPaymentInfo> batchYlInsertList,
ConcurrentHashMap<String,TPaymentInfo> batchYyInsertList,
HashMap<String, String> areaMap,
HashMap<String, String> areaMap2,Map<String,TSettleDomainSelectVo> domainMap) {
List<TSocialFundInfo> socialInfoList = socialFundInfoMapper.selectList(Wrappers.<TSocialFundInfo>query().lambda()
.in(TSocialFundInfo::getEmpIdcard, Common.listObjectToStrList(list, ExcelAttributeConstants.EMPIDCARD)));
// 将以下代码提取出来,使用paymentInfoMap提升性能,避免list多次循环查询数据库浪费性能
// 导入前做队列空闲判断,防止队列不足出现数据丢失的场景
if (CollUtil.isNotEmpty(list)) {
int taskSize = list.size() / partSize + CommonConstants.ONE_INT;
int residualCapacity = yfSocialImportThreadPoolExecutor.getResidualCapacity();
if (taskSize > residualCapacity) {
errorMessageList.put(UUID.randomUUID().toString(),new ErrorDetailVO(-1, MsgUtils.getMessage(ErrorCodes.SOCIALINFO_LIST_NUM_LARGE)));
} else {
//已存在的社保数据
HashMap<String, TSocialFundInfo> socialMap = new HashMap<>();
if (Common.isNotNull(socialInfoList)) {
for (TSocialFundInfo tSocialInfo1 : socialInfoList) {
socialMap.put(tSocialInfo1.getEmpIdcard()
+ CommonConstants.DOWN_LINE_STRING + tSocialInfo1.getSocialProvince()
+ CommonConstants.DOWN_LINE_STRING + tSocialInfo1.getSocialCity()
+ CommonConstants.DOWN_LINE_STRING + (null == tSocialInfo1.getSocialTown()
? "null" : tSocialInfo1.getSocialTown()), tSocialInfo1);
}
}
// -----------------------------生成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) {
String[] areaArray;
String exitMoney;
if (BigDecimalUtils.safeAdd(BigDecimalUtils.isNullToZero(info.getUnitPensionMoney()),
BigDecimalUtils.isNullToZero(info.getPersonalPensionMoney())).compareTo(BigDecimal.ZERO) != 0) {
if (null != paymentInfoPensionMap.get(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.PENSION_RISK)) {
info.setYbSameFlg("1");
}
paymentInfoPensionMap.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.PENSION_RISK
, info);
}
if (BigDecimalUtils.safeAdd(BigDecimalUtils.isNullToZero(info.getUnitUnemploymentMoney()),
BigDecimalUtils.isNullToZero(info.getPersonalUnemploymentMoney())).compareTo(BigDecimal.ZERO) != 0) {
if (null != paymentInfoUnEmpMap.get(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.UNEMPLOYEEMENT_RISK)) {
info.setSySameFlg("1");
}
paymentInfoUnEmpMap.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.UNEMPLOYEEMENT_RISK
, info);
}
if (BigDecimalUtils.isNullToZero(info.getUnitInjuryMoney()).compareTo(BigDecimal.ZERO) != 0) {
if (null != paymentInfoInjuryMap.get(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.INJURY_RISK)) {
info.setGsSameFlg("1");
}
paymentInfoInjuryMap.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.INJURY_RISK
, info);
}
if (BigDecimalUtils.safeAdd(BigDecimalUtils.isNullToZero(info.getUnitMedicalMoney()),
BigDecimalUtils.isNullToZero(info.getPersonalMedicalMoney())).compareTo(BigDecimal.ZERO) != 0) {
if (null != paymentInfoMedicalMap.get(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.setYlSameFlg("1");
}
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);
}
if (BigDecimalUtils.safeAdd(BigDecimalUtils.isNullToZero(info.getPersonalBigmailmentMoney()),
BigDecimalUtils.isNullToZero(info.getUnitBigmailmentMoney())).compareTo(BigDecimal.ZERO) != 0) {
if (null != paymentInfoBigMap.get(info.getSocialPayAddr()
+ CommonConstants.DOWN_LINE_STRING
+ info.getEmpIdcard()
+ CommonConstants.DOWN_LINE_STRING
+ info.getSocialPayMonth()
+ CommonConstants.DOWN_LINE_STRING
+ info.getSocialCreateMonth()
+ CommonConstants.DOWN_LINE_STRING
+ SocialConstants.DB)) {
info.setDbSameFlg("1");
}
paymentInfoBigMap.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
+ SocialConstants.DB
, info);
}
}
}
// -----------------------------生成paymentInfoMap本段结束--------------------------------
// -----------------------------线程池处理list,批量保存社保信息开始--------------------------------
List<CompletableFuture<ConcurrentHashMap<String, ErrorDetailVO>>> completableFutureList = new ArrayList<>();
// 创建一个数值格式化对象
NumberFormat numberFormat = NumberFormat.getInstance();
// 设置精确到小数点后2位
numberFormat.setMaximumFractionDigits(2);
String maerialRatio = "";
Integer bfInt = (Integer) redisUtil.get(sumNumKey);
if (Common.isNotNull(bfInt)) {
if (rowNumber > bfInt + 1) {
maerialRatio = numberFormat.format(((float) bfInt / (float) rowNumber) * 100);
bfInt = bfInt + 100;
redisUtil.set(sumNumKey, bfInt, 360L);
} else {
maerialRatio = "100";
}
} else {
if (rowNumber >= 100) {
maerialRatio = numberFormat.format(((float) 100 / (float) rowNumber) * 100);
bfInt = 100;
redisUtil.set(sumNumKey, bfInt, 360L);
} else {
maerialRatio = "100";
}
}
redisUtil.set(importSuccessKey, maerialRatio, 360L);
try {
// 1.list.size()不足100时直接执行
if (list.size() < 100) {
CompletableFuture<ConcurrentHashMap<String, ErrorDetailVO>> listCompletableFuture = CompletableFuture.supplyAsync(()
-> executeImportSocialListThree(list, areaMap, areaMap2,
paymentInfoPensionMap, paymentInfoMedicalMap, paymentInfoUnEmpMap, paymentInfoInjuryMap,
paymentInfoBigMap, type, errorMessageList, pensionMoneyMap, bigMoneyMap,
unEmpMoneyMap, injuryMoneyMap, medicalMoneyMap, batchGsInsertList,
batchSyInsertList, batchYlInsertList, batchYyInsertList,domainMap),
yfSocialImportThreadPoolExecutor);
completableFutureList.add(listCompletableFuture);
} else {
int j = 25;
for (int i = 0; i < 100; i = i + 25) {
// 单个线程每次执行25条
List<TPaymentHeFeiVo> finalTempList1 = list.subList(i,i+j);
CompletableFuture<ConcurrentHashMap<String, ErrorDetailVO>> listCompletableFuture = CompletableFuture.supplyAsync(()
-> executeImportSocialListThree(finalTempList1
, areaMap, areaMap2, paymentInfoPensionMap, paymentInfoMedicalMap,
paymentInfoUnEmpMap, paymentInfoInjuryMap, paymentInfoBigMap, type,
errorMessageList, pensionMoneyMap, bigMoneyMap, unEmpMoneyMap,
injuryMoneyMap, medicalMoneyMap, batchGsInsertList, batchSyInsertList,
batchYlInsertList, batchYyInsertList, domainMap),
yfSocialImportThreadPoolExecutor);
completableFutureList.add(listCompletableFuture);
}
}
// 阻塞当前线程,等待所有的线程执行完毕
boolean computeFlag;
do {
computeFlag = false;
for (CompletableFuture<ConcurrentHashMap<String, ErrorDetailVO>> listCompletableFuture : completableFutureList) {
if (!listCompletableFuture.isDone()) {
computeFlag = true;
}
}
} while (computeFlag);
paymentInfoBigMap.clear();
paymentInfoInjuryMap.clear();
paymentInfoUnEmpMap.clear();
paymentInfoPensionMap.clear();
paymentInfoMedicalMap.clear();
} catch (Exception e) {
log.error("社保缴费库数据批量导入异常:" + e);
paymentInfoBigMap.clear();
paymentInfoInjuryMap.clear();
paymentInfoUnEmpMap.clear();
paymentInfoPensionMap.clear();
paymentInfoMedicalMap.clear();
}
}
}
}
private ConcurrentHashMap<String, ErrorDetailVO> executeImportSocialListThree(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,
ConcurrentHashMap<String, TPaymentInfo> paymentInfoBigMap,
String type, ConcurrentHashMap<String, ErrorDetailVO> errorMessageList,
ConcurrentHashMap<String, BigDecimal> pensionMoneyMap,
ConcurrentHashMap<String, BigDecimal> bigMoneyMap,
ConcurrentHashMap<String, BigDecimal> unEmpMoneyMap,
ConcurrentHashMap<String, BigDecimal> injuryMoneyMap,
ConcurrentHashMap<String, BigDecimal> medicalMoneyMap,
ConcurrentHashMap<String, TPaymentInfo> batchGsInsertList,
ConcurrentHashMap<String, TPaymentInfo> batchSyInsertList,
ConcurrentHashMap<String, TPaymentInfo> batchYlInsertList,
ConcurrentHashMap<String, TPaymentInfo> batchYyInsertList,
Map<String,TSettleDomainSelectVo> domainMap) {
if (Common.isNotNull(list)) {
TPaymentInfo payExists;
TSocialFundInfo socialInfo = null;
TSocialInfo tSocialInfo = null;
String temp;
List<TSocialInfo> socialist;
TSettleDomain domain;
List<TSocialFundInfo> socialInfoList = socialFundInfoMapper.selectList(Wrappers.<TSocialFundInfo>query().lambda()
.in(TSocialFundInfo::getEmpIdcard, Common.listObjectToStrList(list, ExcelAttributeConstants.EMPIDCARD)));
//已存在的社保数据
HashMap<String, TSocialFundInfo> socialMap = new HashMap<>();
if (Common.isNotNull(socialInfoList)) {
for (TSocialFundInfo tSocialInfo1 : socialInfoList) {
socialMap.put(tSocialInfo1.getEmpIdcard()
+ CommonConstants.DOWN_LINE_STRING + tSocialInfo1.getSocialProvince()
+ CommonConstants.DOWN_LINE_STRING + tSocialInfo1.getSocialCity()
+ CommonConstants.DOWN_LINE_STRING + (null == tSocialInfo1.getSocialTown()
? "null" : tSocialInfo1.getSocialTown()), tSocialInfo1);
}
}
String[] areaArray;
String exitMoney;
String errorInfo;
for (TPaymentHeFeiVo infoVo : list) {
if (Common.isNotNull(infoVo.getEmpIdcard())) {
......@@ -2756,11 +3196,562 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
return errorMessageList;
}
/**
* 导入校验
**/
private boolean socialThreeCheckBase(ConcurrentHashMap<String, ErrorDetailVO> errorMessageList,
TPaymentHeFeiVo infoVo, String type) {
private ConcurrentHashMap<String, ErrorDetailVO> executeImportSocialListTax(List<TPaymentTaxSocialVo> 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,
ConcurrentHashMap<String, TPaymentInfo> paymentInfoBigMap,
ConcurrentHashMap<String, ErrorDetailVO> errorMessageList,
ConcurrentHashMap<String, BigDecimal> pensionMoneyMap,
ConcurrentHashMap<String, BigDecimal> birthMoneyMap,
ConcurrentHashMap<String, BigDecimal> bigMoneyMap,
ConcurrentHashMap<String, BigDecimal> unEmpMoneyMap,
ConcurrentHashMap<String, BigDecimal> injuryMoneyMap,
ConcurrentHashMap<String, BigDecimal> medicalMoneyMap,
ConcurrentHashMap<String, TPaymentInfo> batchGsInsertList,
ConcurrentHashMap<String, TPaymentInfo> batchSyInsertList,
ConcurrentHashMap<String, TPaymentInfo> batchYlInsertList,
ConcurrentHashMap<String, TPaymentInfo> batchYyInsertList,
ConcurrentHashMap<String, TPaymentInfo> batchBigInsertList,
ConcurrentHashMap<String, TPaymentInfo> batchBirthInsertList,
Map<String,TSettleDomainSelectVo> domainMap) {
if (Common.isNotNull(list)) {
TPaymentInfo payExists;
TPaymentInfo payInsert;
TSocialFundInfo socialInfo = null;
TSocialInfo tSocialInfo = null;
String temp;
List<TSocialInfo> socialist;
TSettleDomain domain;
List<TSocialFundInfo> socialInfoList = socialFundInfoMapper.selectList(Wrappers.<TSocialFundInfo>query().lambda()
.in(TSocialFundInfo::getEmpIdcard, Common.listObjectToStrList(list, ExcelAttributeConstants.EMPIDCARD)));
//已存在的社保数据
HashMap<String, TSocialFundInfo> socialMap = new HashMap<>();
if (Common.isNotNull(socialInfoList)) {
for (TSocialFundInfo tSocialInfo1 : socialInfoList) {
socialMap.put(tSocialInfo1.getEmpIdcard()
+ CommonConstants.DOWN_LINE_STRING + tSocialInfo1.getSocialProvince()
+ CommonConstants.DOWN_LINE_STRING + tSocialInfo1.getSocialCity()
+ CommonConstants.DOWN_LINE_STRING + (null == tSocialInfo1.getSocialTown()
? "null" : tSocialInfo1.getSocialTown()), tSocialInfo1);
}
}
String[] areaArray;
String exitMoneyPer;
String exitMoneyCon;
String exitInsertPaymnet;
String errorInfo;
for (TPaymentTaxSocialVo infoVo : list) {
if (Common.isNotNull(infoVo.getEmpIdcard())) {
infoVo.setEmpIdcard(infoVo.getEmpIdcard().replace("x", "X"));
}
//导入校验
if (socialThreeCheckBaseTax(errorMessageList, infoVo)) {
continue;
}
//采用客服导入的地址
areaArray = infoVo.getSocialPayAddr().split(CommonConstants.CENTER_SPLIT_LINE_STRING);
infoVo = initAddressThreeTax(areaArray, areaMap2, infoVo);
//无对应员工的社保数据
if (socialMap.size() > CommonConstants.ZERO_INT) {
if (null == infoVo.getSocialProvince() || null == infoVo.getSocialCity()) {
errorMessageList.put(UUID.randomUUID().toString(),new ErrorDetailVO(infoVo.getRowIndex(), CommonConstants.ZERO_INT, infoVo.getEmpIdcard(), "", "", infoVo.getEmpName(), "社保缴纳地填写错误,请核实后再次尝试!"));
continue;
}
socialInfo = socialMap.get(infoVo.getEmpIdcard()
+ CommonConstants.DOWN_LINE_STRING + infoVo.getSocialProvince()
+ CommonConstants.DOWN_LINE_STRING + infoVo.getSocialCity()
+ CommonConstants.DOWN_LINE_STRING + (null == infoVo.getSocialTown() ? "null" : infoVo.getSocialTown()));
//对身份证与人员姓名的对应关系进行校验
if (socialInfo != null && !socialInfo.getEmpName().equals(infoVo.getEmpName())) {
errorMessageList.put(UUID.randomUUID().toString(),new ErrorDetailVO(infoVo.getRowIndex(), CommonConstants.ZERO_INT, infoVo.getEmpIdcard(), "", "", infoVo.getEmpName(), "姓名与身份证信息不一致,请核实后再次尝试!"));
continue;
}
if (socialInfo != null && socialInfo.getSocialStartDate() == null) {
errorMessageList.put(UUID.randomUUID().toString(),new ErrorDetailVO(infoVo.getRowIndex(), CommonConstants.ZERO_INT, infoVo.getEmpIdcard(), "", "", infoVo.getEmpName(), SocialConstants.ERROR_TEMPLATE + "的社保起缴日期为空!"));
continue;
}
}
if (null == socialInfo) {
boolean isTrueAdder = false;
socialist = socialInfoMapper.selectList(Wrappers.<TSocialInfo>query().lambda()
.eq(TSocialInfo::getEmpIdcard, infoVo.getEmpIdcard())
.eq(TSocialInfo::getSocialProvince, infoVo.getSocialProvince().toString())
.eq(TSocialInfo::getSocialCity, infoVo.getSocialCity().toString()));
if (CollectionUtils.isNotEmpty(socialist)) {
for (TSocialInfo socialInfo1 : socialist) {
if ((Common.isEmpty(infoVo.getSocialTown()) || (Common.isNotNull(infoVo.getSocialTown()) &&
infoVo.getSocialTown().toString().equals(socialInfo1.getSocialTown()))) &&
DateUtil.dateToString(socialInfo1.getSocialStartDate(), "yyyyMM").compareTo(infoVo.getSocialPayMonth()) <= 0 &&
(Common.isEmpty(socialInfo1.getSocialReduceDate()) || (Common.isNotNull(socialInfo1.getSocialReduceDate()) &&
DateUtil.dateToString(socialInfo1.getSocialReduceDate(), "yyyyMM").compareTo(infoVo.getSocialPayMonth()) >= 0))) {
isTrueAdder = true;
tSocialInfo = socialInfo1;
break;
}
}
}
if (!isTrueAdder) {
errorMessageList.put(UUID.randomUUID().toString(),new ErrorDetailVO(infoVo.getRowIndex(), CommonConstants.ZERO_INT, infoVo.getEmpIdcard(), "", "", infoVo.getEmpName(),
"无对应员工(身份证:" + infoVo.getEmpIdcard() + ")" + "的社保数据(请查验社保缴纳地)"));
continue;
}
} else {
tSocialInfo = null;
}
payExists = new TPaymentInfo();
if (Common.isEmpty(tSocialInfo)) {
tSocialInfo = socialInfoMapper.selectOne(Wrappers.<TSocialInfo>query().lambda()
.eq(TSocialInfo::getEmpIdcard, infoVo.getEmpIdcard()).groupBy(TSocialInfo::getCreateTime)
.last(CommonConstants.LAST_ONE_SQL));
}
payExists.setLockStatus(CommonConstants.ZERO_STRING);
if (Common.isNotNull(socialInfo)) {
payExists.setEmpId(socialInfo.getEmpId());
payExists.setEmpIdcard(socialInfo.getEmpIdcard());
payExists.setEmpName(socialInfo.getEmpName());
if (Common.isNotNull(domainMap)) {
domain = domainMap.get(socialInfo.getSettleDomainCode());
} else {
domain = null;
}
if (Common.isEmpty(domain)) {
errorMessageList.put(UUID.randomUUID().toString(), new ErrorDetailVO(infoVo.getRowIndex(),
CommonConstants.ZERO_INT, infoVo.getEmpIdcard(), payExists.getSocialHousehold(),
payExists.getProvidentHousehold(), infoVo.getEmpName(), SocialConstants.NOT_EXIT_SETTLEiNFO));
continue;
}
payExists.setBpoFlag(domain.getBpoFlag());
payExists.setSecondIndicatorBelong(domain.getSecondIndicatorBelong());
payExists.setSettleDomainId(socialInfo.getSettleDomain());
payExists.setSettleDomainCode(Common.isNotNull(socialInfo.getSettleDomainCode()) ? socialInfo.getSettleDomainCode(): "");
payExists.setUnitId(Common.isNotNull(socialInfo.getUnitId()) ? socialInfo.getUnitId(): "");
payExists.setSettleDomainName(Common.isNotNull(socialInfo.getSettleDomainName()) ? socialInfo.getSettleDomainName(): "");
payExists.setUnitName(Common.isNotNull(socialInfo.getUnitName()) ? socialInfo.getUnitName(): "");
payExists.setSocialProvince(socialInfo.getSocialProvince());
payExists.setSocialCity(socialInfo.getSocialCity());
payExists.setSocialTown(Common.isNotNull(socialInfo.getSocialTown()) ? socialInfo.getSocialTown(): "");
payExists.setSocialHousehold(socialInfo.getSocialHouseholdName());
} else if (Common.isNotNull(tSocialInfo)) {
payExists.setEmpId(tSocialInfo.getEmpId());
payExists.setEmpIdcard(tSocialInfo.getEmpIdcard());
payExists.setEmpName(tSocialInfo.getEmpName());
if (Common.isNotNull(domainMap)) {
domain = domainMap.get(tSocialInfo.getSettleDomainCode());
} else {
domain = null;
}
if (Common.isEmpty(domain)) {
errorMessageList.put(UUID.randomUUID().toString(), new ErrorDetailVO(infoVo.getRowIndex(),
CommonConstants.ZERO_INT, infoVo.getEmpIdcard(), payExists.getSocialHousehold(),
payExists.getProvidentHousehold(), infoVo.getEmpName(), SocialConstants.NOT_EXIT_SETTLEiNFO));
continue;
}
payExists.setSettleDomainId(tSocialInfo.getSettleDomain());
payExists.setSettleDomainCode(tSocialInfo.getSettleDomainCode());
payExists.setSecondIndicatorBelong(domain.getSecondIndicatorBelong());
payExists.setSettleDomainName(domain.getDepartName());
payExists.setUnitId(domain.getCustomerId());
payExists.setUnitName(domain.getCustomerName());
payExists.setBpoFlag(domain.getBpoFlag());
payExists.setSocialProvince(tSocialInfo.getSocialProvince());
payExists.setSocialCity(tSocialInfo.getSocialCity());
payExists.setSocialTown(Common.isNotNull(tSocialInfo.getSocialTown()) ? tSocialInfo.getSocialTown(): "");
payExists.setSocialHousehold(tSocialInfo.getSocialHouseholdName());
}
// 项目信息校验
errorInfo = settleInfoCheck(payExists);
if (!Common.isEmpty(errorInfo)){
errorMessageList.put(UUID.randomUUID().toString(), new ErrorDetailVO(infoVo.getRowIndex(),
CommonConstants.ZERO_INT, infoVo.getEmpIdcard(), payExists.getSocialHousehold(),
payExists.getProvidentHousehold(), infoVo.getEmpName(), SocialConstants.ERROR_PRI
+ errorInfo + SocialConstants.ERROR_END));
continue;
}
if (Common.isNotNull(tSocialInfo)) {
payExists.setInauguralTeam(Common.isNotNull(tSocialInfo.getInauguralTeam()) ? tSocialInfo.getInauguralTeam(): "");
payExists.setEmpNo(Common.isNotNull(tSocialInfo.getEmpNo()) ? tSocialInfo.getEmpNo(): "");
} else {
payExists.setInauguralTeam("");
payExists.setEmpNo("");
}
payExists.setSocialPayMonth(infoVo.getSocialPayMonth());
if (null != payExists.getSocialProvince()) {
temp = areaMap.get(payExists.getSocialProvince());
if (Common.isNotNull(temp)) {
payExists.setSocialPayAddr(temp);
}
}
if (null != payExists.getSocialCity()) {
temp = areaMap.get(payExists.getSocialCity());
if (Common.isNotNull(temp)) {
payExists.setSocialPayAddr(payExists.getSocialPayAddr() + CommonConstants.CENTER_SPLIT_LINE_STRING + temp);
}
}
if (null != payExists.getSocialTown()) {
temp = areaMap.get(payExists.getSocialTown());
if (Common.isNotNull(temp)) {
payExists.setSocialPayAddr(payExists.getSocialPayAddr() + CommonConstants.CENTER_SPLIT_LINE_STRING + temp);
}
} else {
payExists.setSocialTown("");
}
payExists.setSocialSecurityNo(CommonConstants.EMPTY_STRING);
payExists.setSocialCreateMonth(infoVo.getSocialCreateMonth());
payExists.setCreateTime(LocalDateTime.now());
payExists.setSocialId(UUID.randomUUID().toString());
//判断是否存在养老数据
if (PaymentConstants.COMPANY_YL.equals(infoVo.getRiskType()) || PaymentConstants.PENSION_YL.equals(infoVo.getRiskType())) {
//导入模板判重 养老
exitMoneyPer = infoVo.getEmpIdcard().concat(infoVo.getSocialPayMonth().concat(infoVo.getSocialCreateMonth()).concat(PaymentConstants.COMPANY_YL));
exitMoneyCon = infoVo.getEmpIdcard().concat(infoVo.getSocialPayMonth().concat(infoVo.getSocialCreateMonth()).concat(PaymentConstants.PENSION_YL));
exitInsertPaymnet = infoVo.getEmpIdcard().concat(infoVo.getSocialPayMonth().concat(infoVo.getSocialCreateMonth()).concat(PaymentConstants.PENSION_RISK));
if (PaymentConstants.COMPANY_YL.equals(infoVo.getRiskType())) {
if (pensionMoneyMap.get(exitMoneyCon) != null && BigDecimalUtils.safeMultiply(
BigDecimalUtils.isNullToZero(infoVo.getPaymentMoney())
, pensionMoneyMap.get(exitMoneyCon)).compareTo(BigDecimal.ZERO) > 0) {
errorMessageList.put(UUID.randomUUID().toString(), new ErrorDetailVO(infoVo.getRowIndex(), CommonConstants.ZERO_INT, infoVo.getEmpIdcard(), "", "",
infoVo.getEmpName(), SocialConstants.ERROR_TEMPLATE + "的单位养老缴费数据"));
continue;
} else {
if (Common.isNotNull(pensionMoneyMap.get(exitMoneyPer))) {
payExists.setPersonalPensionMoney(pensionMoneyMap.get(exitMoneyPer));
}
payExists.setUnitPensionMoney(infoVo.getPaymentMoney());
pensionMoneyMap.put(exitMoneyCon, BigDecimalUtils.isNullToZero(infoVo.getPaymentMoney()));
}
} else {
if (pensionMoneyMap.get(exitMoneyPer) != null && BigDecimalUtils.safeMultiply(
BigDecimalUtils.isNullToZero(infoVo.getPaymentMoney())
, pensionMoneyMap.get(exitMoneyPer)).compareTo(BigDecimal.ZERO) > 0) {
errorMessageList.put(UUID.randomUUID().toString(), new ErrorDetailVO(infoVo.getRowIndex(), CommonConstants.ZERO_INT, infoVo.getEmpIdcard(), "", "",
infoVo.getEmpName(), SocialConstants.ERROR_TEMPLATE + "的个人养老缴费数据"));
continue;
} else {
if (Common.isNotNull(pensionMoneyMap.get(exitMoneyCon))) {
payExists.setUnitPensionMoney(pensionMoneyMap.get(exitMoneyCon));
}
payExists.setPersonalPensionMoney(infoVo.getPaymentMoney());
pensionMoneyMap.put(exitMoneyPer, BigDecimalUtils.isNullToZero(infoVo.getPaymentMoney()));
}
}
payExists.setUnitPensionSet(infoVo.getPaymentSet());
payExists.setUnitSocialSum(payExists.getUnitPensionMoney());
payExists.setSocialSecurityPersonalSum(payExists.getPersonalPensionMoney());
payExists.setSocialSum(BigDecimalUtils.safeAdd(payExists.getUnitSocialSum(), payExists.getSocialSecurityPersonalSum()));
payExists.setSumAll(payExists.getSocialSum());
payInsert = paymentInfoPensionMap.get(infoVo.getSocialPayAddr()
+ CommonConstants.DOWN_LINE_STRING
+ infoVo.getEmpIdcard().trim()
+ CommonConstants.DOWN_LINE_STRING
+ infoVo.getSocialPayMonth().trim()
+ CommonConstants.DOWN_LINE_STRING
+ infoVo.getSocialCreateMonth().trim()
+ CommonConstants.DOWN_LINE_STRING
+ PaymentConstants.PENSION_RISK);
//存在社保缴费数据
if (null != payInsert && ((null != payInsert.getYbSameFlg() && CommonConstants.ONE_STRING.equals(payInsert.getYbSameFlg()))
|| (BigDecimalUtils.safeMultiply(payExists.getSocialSum(), BigDecimalUtils.safeAdd(
BigDecimalUtils.isNullToZero(payInsert.getUnitPensionMoney()),
BigDecimalUtils.isNullToZero(payInsert.getPersonalPensionMoney()))).compareTo(BigDecimal.ZERO) > 0))) {
errorMessageList.put(UUID.randomUUID().toString(),new ErrorDetailVO(infoVo.getRowIndex(), CommonConstants.ZERO_INT, infoVo.getEmpIdcard(), payInsert.getSocialHousehold(), payInsert.getProvidentHousehold(), infoVo.getEmpName(), "已存在对应员工身份证" + infoVo.getEmpIdcard()
+ "的养老缴费数据,请勿重复导入!"));
continue;
}
batchYlInsertList.put(exitInsertPaymnet, payExists);
}
//判断是否存在失业缴费数据
if (PaymentConstants.COMPANY_UNEMPLOYEEMENT.equals(infoVo.getRiskType()) || PaymentConstants.PENSION_UNEMPLOYEEMENT.equals(infoVo.getRiskType())) {
//导入模板判重 失业
exitMoneyPer = infoVo.getEmpIdcard().concat(infoVo.getSocialPayMonth().concat(infoVo.getSocialCreateMonth()).concat(PaymentConstants.PENSION_UNEMPLOYEEMENT));
exitMoneyCon = infoVo.getEmpIdcard().concat(infoVo.getSocialPayMonth().concat(infoVo.getSocialCreateMonth()).concat(PaymentConstants.COMPANY_UNEMPLOYEEMENT));
exitInsertPaymnet = infoVo.getEmpIdcard().concat(infoVo.getSocialPayMonth().concat(infoVo.getSocialCreateMonth()).concat(PaymentConstants.UNEMPLOYEEMENT_RISK));
if (PaymentConstants.COMPANY_UNEMPLOYEEMENT.equals(infoVo.getRiskType())) {
if (unEmpMoneyMap.get(exitMoneyCon) != null && BigDecimalUtils.safeMultiply(
BigDecimalUtils.isNullToZero(infoVo.getPaymentMoney())
, unEmpMoneyMap.get(exitMoneyCon)).compareTo(BigDecimal.ZERO) > 0) {
errorMessageList.put(UUID.randomUUID().toString(), new ErrorDetailVO(infoVo.getRowIndex(), CommonConstants.ZERO_INT, infoVo.getEmpIdcard(), "", "",
infoVo.getEmpName(), SocialConstants.ERROR_TEMPLATE + "的单位失业缴费数据"));
continue;
} else {
if (Common.isNotNull(unEmpMoneyMap.get(exitMoneyPer))) {
payExists.setPersonalUnemploymentMoney(unEmpMoneyMap.get(exitMoneyPer));
}
payExists.setUnitUnemploymentMoney(infoVo.getPaymentMoney());
unEmpMoneyMap.put(exitMoneyCon, BigDecimalUtils.isNullToZero(infoVo.getPaymentMoney()));
}
} else {
if (unEmpMoneyMap.get(exitMoneyPer) != null && BigDecimalUtils.safeMultiply(
BigDecimalUtils.isNullToZero(infoVo.getPaymentMoney())
, unEmpMoneyMap.get(exitMoneyPer)).compareTo(BigDecimal.ZERO) > 0) {
errorMessageList.put(UUID.randomUUID().toString(), new ErrorDetailVO(infoVo.getRowIndex(), CommonConstants.ZERO_INT, infoVo.getEmpIdcard(), "", "",
infoVo.getEmpName(), SocialConstants.ERROR_TEMPLATE + "的个人失业缴费数据"));
continue;
} else {
if (Common.isNotNull(unEmpMoneyMap.get(exitMoneyCon))) {
payExists.setUnitUnemploymentMoney(unEmpMoneyMap.get(exitMoneyCon));
}
payExists.setPersonalUnemploymentMoney(infoVo.getPaymentMoney());
unEmpMoneyMap.put(exitMoneyPer, BigDecimalUtils.isNullToZero(infoVo.getPaymentMoney()));
}
}
payExists.setUnitUnemploymentSet(infoVo.getPaymentSet());
payExists.setUnitSocialSum(payExists.getUnitUnemploymentMoney());
payExists.setSocialSecurityPersonalSum(payExists.getPersonalUnemploymentMoney());
payExists.setSocialSum(BigDecimalUtils.safeAdd(payExists.getUnitSocialSum(), payExists.getPersonalUnemploymentMoney()));
payExists.setSumAll(payExists.getSocialSum());
payInsert = paymentInfoUnEmpMap.get(infoVo.getSocialPayAddr()
+ CommonConstants.DOWN_LINE_STRING
+ infoVo.getEmpIdcard().trim()
+ CommonConstants.DOWN_LINE_STRING
+ infoVo.getSocialPayMonth().trim()
+ CommonConstants.DOWN_LINE_STRING
+ infoVo.getSocialCreateMonth().trim()
+ CommonConstants.DOWN_LINE_STRING
+ PaymentConstants.UNEMPLOYEEMENT_RISK);
//存在社保缴费数据
if (null != payInsert && ((null != payInsert.getSySameFlg() && CommonConstants.ONE_STRING.equals(payInsert.getSySameFlg()))
|| (BigDecimalUtils.safeMultiply(payExists.getSocialSum(), BigDecimalUtils.safeAdd(
BigDecimalUtils.isNullToZero(payInsert.getUnitUnemploymentMoney()),
BigDecimalUtils.isNullToZero(payInsert.getPersonalUnemploymentMoney()))).compareTo(BigDecimal.ZERO) > 0))) {
errorMessageList.put(UUID.randomUUID().toString(),new ErrorDetailVO(infoVo.getRowIndex(), CommonConstants.ZERO_INT, infoVo.getEmpIdcard(), payExists.getSocialHousehold(), payExists.getProvidentHousehold(), infoVo.getEmpName(), "已存在对应员工身份证" + infoVo.getEmpIdcard()
+ "的失业缴费数据,请勿重复导入!"));
continue;
}
batchSyInsertList.put(exitInsertPaymnet, payExists);
}
//判断是否存在医疗缴费数据
if (PaymentConstants.COMPANY_MEDICAL.equals(infoVo.getRiskType()) || PaymentConstants.PENSION_MEDICAL.equals(infoVo.getRiskType())) {
//导入模板判重医疗
exitMoneyPer = infoVo.getEmpIdcard().concat(infoVo.getSocialPayMonth().concat(infoVo.getSocialCreateMonth()).concat(PaymentConstants.PENSION_MEDICAL));
exitMoneyCon = infoVo.getEmpIdcard().concat(infoVo.getSocialPayMonth().concat(infoVo.getSocialCreateMonth()).concat(PaymentConstants.COMPANY_MEDICAL));
exitInsertPaymnet = infoVo.getEmpIdcard().concat(infoVo.getSocialPayMonth().concat(infoVo.getSocialCreateMonth()).concat(PaymentConstants.MEDICAL));
if (PaymentConstants.COMPANY_UNEMPLOYEEMENT.equals(infoVo.getRiskType())) {
if (medicalMoneyMap.get(exitMoneyCon) != null && BigDecimalUtils.safeMultiply(
BigDecimalUtils.isNullToZero(infoVo.getPaymentMoney())
, medicalMoneyMap.get(exitMoneyCon)).compareTo(BigDecimal.ZERO) > 0) {
errorMessageList.put(UUID.randomUUID().toString(), new ErrorDetailVO(infoVo.getRowIndex(), CommonConstants.ZERO_INT, infoVo.getEmpIdcard(), "", "",
infoVo.getEmpName(), SocialConstants.ERROR_TEMPLATE + "的单位医疗缴费数据"));
continue;
} else {
if (Common.isNotNull(medicalMoneyMap.get(exitMoneyPer))) {
payExists.setPersonalMedicalMoney(medicalMoneyMap.get(exitMoneyPer));
}
payExists.setUnitMedicalMoney(infoVo.getPaymentMoney());
medicalMoneyMap.put(exitMoneyCon, BigDecimalUtils.isNullToZero(infoVo.getPaymentMoney()));
}
} else {
if (medicalMoneyMap.get(exitMoneyPer) != null && BigDecimalUtils.safeMultiply(
BigDecimalUtils.isNullToZero(infoVo.getPaymentMoney())
, medicalMoneyMap.get(exitMoneyPer)).compareTo(BigDecimal.ZERO) > 0) {
errorMessageList.put(UUID.randomUUID().toString(), new ErrorDetailVO(infoVo.getRowIndex(), CommonConstants.ZERO_INT, infoVo.getEmpIdcard(), "", "",
infoVo.getEmpName(), SocialConstants.ERROR_TEMPLATE + "的个人医疗缴费数据"));
continue;
} else {
if (Common.isNotNull(medicalMoneyMap.get(exitMoneyCon))) {
payExists.setUnitMedicalMoney(medicalMoneyMap.get(exitMoneyCon));
}
payExists.setPersonalMedicalMoney(infoVo.getPaymentMoney());
medicalMoneyMap.put(exitMoneyPer, BigDecimalUtils.isNullToZero(infoVo.getPaymentMoney()));
}
}
payExists.setUnitMedicalSet(infoVo.getPaymentSet());
payExists.setUnitSocialSum(payExists.getUnitMedicalMoney());
payExists.setSocialSecurityPersonalSum(payExists.getPersonalMedicalMoney());
payExists.setSocialSum(BigDecimalUtils.safeAdd(payExists.getUnitSocialSum(), payExists.getSocialSecurityPersonalSum()));
payExists.setSumAll(payExists.getSocialSum());
payInsert = paymentInfoMedicalMap.get(infoVo.getSocialPayAddr()
+ CommonConstants.DOWN_LINE_STRING
+ infoVo.getEmpIdcard().trim()
+ CommonConstants.DOWN_LINE_STRING
+ infoVo.getSocialPayMonth().trim()
+ CommonConstants.DOWN_LINE_STRING
+ infoVo.getSocialCreateMonth().trim()
+ CommonConstants.DOWN_LINE_STRING
+ PaymentConstants.MEDICAL);
//存在社保缴费数据
if (null != payInsert && ((null != payInsert.getYlSameFlg() && CommonConstants.ONE_STRING.equals(payInsert.getYlSameFlg()))
|| (BigDecimalUtils.safeMultiply(payExists.getSocialSum(), BigDecimalUtils.safeAdd(
BigDecimalUtils.isNullToZero(payInsert.getUnitPensionMoney()),
BigDecimalUtils.isNullToZero(payInsert.getPersonalPensionMoney()))).compareTo(BigDecimal.ZERO) > 0))) {
errorMessageList.put(UUID.randomUUID().toString(),new ErrorDetailVO(infoVo.getRowIndex(), CommonConstants.ZERO_INT, infoVo.getEmpIdcard(), payExists.getSocialHousehold(), payExists.getProvidentHousehold(), infoVo.getEmpName(), "已存在对应员工身份证" + infoVo.getEmpIdcard()
+ "的医疗缴费数据,请勿重复导入!"));
continue;
}
batchYyInsertList.put(exitInsertPaymnet, payExists);
}
//判断是否存在工伤缴费数据
if (PaymentConstants.COMPANY_INJURY_RISK.equals(infoVo.getRiskType())) {
//导入模板判重工伤
exitMoneyCon = infoVo.getEmpIdcard().concat(infoVo.getSocialPayMonth().concat(infoVo.getSocialCreateMonth()).concat(PaymentConstants.COMPANY_INJURY_RISK));
exitInsertPaymnet = infoVo.getEmpIdcard().concat(infoVo.getSocialPayMonth().concat(infoVo.getSocialCreateMonth()).concat(PaymentConstants.INJURY_RISK));
if (injuryMoneyMap.get(exitMoneyCon) != null && BigDecimalUtils.safeMultiply(
BigDecimalUtils.isNullToZero(infoVo.getPaymentMoney())
, injuryMoneyMap.get(exitMoneyCon)).compareTo(BigDecimal.ZERO) > 0) {
errorMessageList.put(UUID.randomUUID().toString(), new ErrorDetailVO(infoVo.getRowIndex(), CommonConstants.ZERO_INT, infoVo.getEmpIdcard(), "", "",
infoVo.getEmpName(), SocialConstants.ERROR_TEMPLATE + "的单位工伤缴费数据"));
continue;
} else {
payExists.setUnitInjuryMoney(infoVo.getPaymentMoney());
injuryMoneyMap.put(exitMoneyCon, BigDecimalUtils.isNullToZero(infoVo.getPaymentMoney()));
}
payExists.setUnitInjurySet(infoVo.getPaymentSet());
payExists.setUnitSocialSum(payExists.getUnitInjuryMoney());
payExists.setSocialSum(BigDecimalUtils.safeAdd(payExists.getUnitSocialSum()));
payExists.setSumAll(payExists.getSocialSum());
payInsert = paymentInfoInjuryMap.get(infoVo.getSocialPayAddr()
+ CommonConstants.DOWN_LINE_STRING
+ infoVo.getEmpIdcard().trim()
+ CommonConstants.DOWN_LINE_STRING
+ infoVo.getSocialPayMonth().trim()
+ CommonConstants.DOWN_LINE_STRING
+ infoVo.getSocialCreateMonth().trim()
+ CommonConstants.DOWN_LINE_STRING
+ PaymentConstants.INJURY_RISK);
//存在社保缴费数据
if (null != payInsert && ((null != payInsert.getGsSameFlg() && CommonConstants.ONE_STRING.equals(payInsert.getGsSameFlg()))
|| (BigDecimalUtils.safeMultiply(infoVo.getPaymentMoney(),
BigDecimalUtils.isNullToZero(payInsert.getUnitInjuryMoney())).compareTo(BigDecimal.ZERO) > 0))) {
errorMessageList.put(UUID.randomUUID().toString(),new ErrorDetailVO(infoVo.getRowIndex(), CommonConstants.ZERO_INT, infoVo.getEmpIdcard(), payExists.getSocialHousehold(), payExists.getProvidentHousehold(), infoVo.getEmpName(), "已存在对应员工身份证" + infoVo.getEmpIdcard()
+ "的单位工伤缴费数据,请勿重复导入!"));
continue;
}
batchGsInsertList.put(exitInsertPaymnet, payExists);
}
//判断是否存在大病救助金缴费数据
if (PaymentConstants.COMPANY_BIG.equals(infoVo.getRiskType()) || PaymentConstants.PENSION_BIG.equals(infoVo.getRiskType())) {
//导入模板判重大病救助金
exitMoneyPer = infoVo.getEmpIdcard().concat(infoVo.getSocialPayMonth().concat(infoVo.getSocialCreateMonth()).concat(PaymentConstants.PENSION_BIG));
exitMoneyCon = infoVo.getEmpIdcard().concat(infoVo.getSocialPayMonth().concat(infoVo.getSocialCreateMonth()).concat(PaymentConstants.COMPANY_BIG));
exitInsertPaymnet = infoVo.getEmpIdcard().concat(infoVo.getSocialPayMonth().concat(infoVo.getSocialCreateMonth()).concat(PaymentConstants.BIG));
if (PaymentConstants.COMPANY_UNEMPLOYEEMENT.equals(infoVo.getRiskType())) {
exitMoneyCon = infoVo.getEmpIdcard().concat(infoVo.getSocialPayMonth().concat(infoVo.getSocialCreateMonth()).concat(PaymentConstants.COMPANY_YL));
if (bigMoneyMap.get(exitMoneyCon) != null && BigDecimalUtils.safeMultiply(
BigDecimalUtils.isNullToZero(infoVo.getPaymentMoney())
, bigMoneyMap.get(exitMoneyCon)).compareTo(BigDecimal.ZERO) > 0) {
errorMessageList.put(UUID.randomUUID().toString(), new ErrorDetailVO(infoVo.getRowIndex(), CommonConstants.ZERO_INT, infoVo.getEmpIdcard(), "", "",
infoVo.getEmpName(), SocialConstants.ERROR_TEMPLATE + "的单位大病救助金缴费数据"));
continue;
} else {
if (Common.isNotNull(bigMoneyMap.get(exitMoneyPer))) {
payExists.setPersonalBigmailmentMoney(bigMoneyMap.get(exitMoneyPer));
}
payExists.setUnitBigmailmentMoney(infoVo.getPaymentMoney());
bigMoneyMap.put(exitMoneyCon, BigDecimalUtils.isNullToZero(infoVo.getPaymentMoney()));
}
} else {
if (bigMoneyMap.get(exitMoneyPer) != null && BigDecimalUtils.safeMultiply(
BigDecimalUtils.isNullToZero(infoVo.getPaymentMoney())
, bigMoneyMap.get(exitMoneyPer)).compareTo(BigDecimal.ZERO) > 0) {
errorMessageList.put(UUID.randomUUID().toString(), new ErrorDetailVO(infoVo.getRowIndex(), CommonConstants.ZERO_INT, infoVo.getEmpIdcard(), "", "",
infoVo.getEmpName(), SocialConstants.ERROR_TEMPLATE + "的个人大病救助金缴费数据"));
continue;
} else {
if (Common.isNotNull(bigMoneyMap.get(exitMoneyCon))) {
payExists.setUnitBigmailmentMoney(bigMoneyMap.get(exitMoneyCon));
}
payExists.setPersonalBigmailmentMoney(infoVo.getPaymentMoney());
bigMoneyMap.put(exitMoneyPer, BigDecimalUtils.isNullToZero(infoVo.getPaymentMoney()));
}
}
payExists.setUnitSocialSum(payExists.getUnitBigmailmentMoney());
payExists.setSocialSecurityPersonalSum(payExists.getPersonalBigmailmentMoney());
payExists.setSocialSum(BigDecimalUtils.safeAdd(payExists.getUnitSocialSum(), payExists.getSocialSecurityPersonalSum()));
payExists.setSumAll(payExists.getSocialSum());
payInsert = paymentInfoBigMap.get(infoVo.getSocialPayAddr()
+ CommonConstants.DOWN_LINE_STRING
+ infoVo.getEmpIdcard().trim()
+ CommonConstants.DOWN_LINE_STRING
+ infoVo.getSocialPayMonth().trim()
+ CommonConstants.DOWN_LINE_STRING
+ infoVo.getSocialCreateMonth().trim()
+ CommonConstants.DOWN_LINE_STRING
+ PaymentConstants.BIG);
//存在社保缴费数据
if (null != payInsert && ((null != payInsert.getDbSameFlg() && CommonConstants.ONE_STRING.equals(payInsert.getDbSameFlg()))
|| (BigDecimalUtils.safeMultiply(payExists.getSocialSum(), BigDecimalUtils.safeAdd(
BigDecimalUtils.isNullToZero(payInsert.getUnitBigmailmentMoney()),
BigDecimalUtils.isNullToZero(payInsert.getPersonalBigmailmentMoney()))).compareTo(BigDecimal.ZERO) > 0))) {
errorMessageList.put(UUID.randomUUID().toString(),new ErrorDetailVO(infoVo.getRowIndex(), CommonConstants.ZERO_INT, infoVo.getEmpIdcard(), payExists.getSocialHousehold(), payExists.getProvidentHousehold(), infoVo.getEmpName(), "已存在对应员工身份证" + infoVo.getEmpIdcard()
+ "的大病救助金缴费数据,请勿重复导入!"));
continue;
}
batchBigInsertList.put(exitInsertPaymnet, payExists);
}
//判断是否存在生育缴费数据
if (PaymentConstants.COMPANY_BIRTH.equals(infoVo.getRiskType())) {
//导入模板判重生育
exitMoneyCon = infoVo.getEmpIdcard().concat(infoVo.getSocialPayMonth().concat(infoVo.getSocialCreateMonth()).concat(PaymentConstants.COMPANY_BIRTH));
exitInsertPaymnet = infoVo.getEmpIdcard().concat(infoVo.getSocialPayMonth().concat(infoVo.getSocialCreateMonth()).concat(PaymentConstants.BIRTH));
if (birthMoneyMap.get(exitMoneyCon) != null && BigDecimalUtils.safeMultiply(
BigDecimalUtils.isNullToZero(infoVo.getPaymentMoney())
, birthMoneyMap.get(exitMoneyCon)).compareTo(BigDecimal.ZERO) > 0) {
errorMessageList.put(UUID.randomUUID().toString(), new ErrorDetailVO(infoVo.getRowIndex(), CommonConstants.ZERO_INT, infoVo.getEmpIdcard(), "", "",
infoVo.getEmpName(), SocialConstants.ERROR_TEMPLATE + "的单位生育缴费数据"));
continue;
} else {
payExists.setUnitBirthMoney(infoVo.getPaymentMoney());
birthMoneyMap.put(exitMoneyCon, BigDecimalUtils.isNullToZero(infoVo.getPaymentMoney()));
}
payExists.setUnitBirthSet(infoVo.getPaymentSet());
payExists.setUnitSocialSum(payExists.getUnitBirthMoney());
payExists.setSocialSum(BigDecimalUtils.safeAdd(payExists.getUnitSocialSum()));
payExists.setSumAll(payExists.getSocialSum());
payInsert = paymentInfoInjuryMap.get(infoVo.getSocialPayAddr()
+ CommonConstants.DOWN_LINE_STRING
+ infoVo.getEmpIdcard().trim()
+ CommonConstants.DOWN_LINE_STRING
+ infoVo.getSocialPayMonth().trim()
+ CommonConstants.DOWN_LINE_STRING
+ infoVo.getSocialCreateMonth().trim()
+ CommonConstants.DOWN_LINE_STRING
+ PaymentConstants.BIRTH);
//存在社保缴费数据
if (null != payInsert && ((null != payInsert.getBrSameFlg() && CommonConstants.ONE_STRING.equals(payInsert.getBrSameFlg()))
|| (BigDecimalUtils.safeMultiply(infoVo.getPaymentMoney(),
BigDecimalUtils.isNullToZero(payInsert.getUnitBirthMoney())).compareTo(BigDecimal.ZERO) > 0))) {
errorMessageList.put(UUID.randomUUID().toString(),new ErrorDetailVO(infoVo.getRowIndex(), CommonConstants.ZERO_INT, infoVo.getEmpIdcard(), payExists.getSocialHousehold(), payExists.getProvidentHousehold(), infoVo.getEmpName(), "已存在对应员工身份证" + infoVo.getEmpIdcard()
+ "的单位生育缴费数据,请勿重复导入!"));
continue;
}
batchBirthInsertList.put(exitInsertPaymnet, payExists);
}
errorMessageList.put(UUID.randomUUID().toString(),new ErrorDetailVO(infoVo.getRowIndex(), CommonConstants.ONE_INT,
infoVo.getEmpIdcard(),
payExists.getSocialHousehold(),
payExists.getProvidentHousehold(), infoVo.getEmpName(),
"对应员工身份证" + infoVo.getEmpIdcard() + CommonConstants.SAVE_SUCCESS,CommonConstants.GREEN));
}
}
return errorMessageList;
}
/**
* 导入校验
**/
private boolean socialThreeCheckBase(ConcurrentHashMap<String, ErrorDetailVO> errorMessageList,
TPaymentHeFeiVo infoVo, String type) {
if (!Common.isNotNull(infoVo.getSocialPayMonth())) {
errorMessageList.put(UUID.randomUUID().toString(),new ErrorDetailVO(infoVo.getRowIndex(), CommonConstants.ZERO_INT, infoVo.getEmpIdcard(), "", "", infoVo.getEmpName(), "社保缴纳月份不可为空!"));
return true;
......@@ -2782,6 +3773,27 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
return false;
}
/**
* 导入校验
**/
private boolean socialThreeCheckBaseTax(ConcurrentHashMap<String, ErrorDetailVO> errorMessageList,
TPaymentTaxSocialVo infoVo) {
if (!Common.isNotNull(infoVo.getSocialPayMonth())) {
errorMessageList.put(UUID.randomUUID().toString(),new ErrorDetailVO(infoVo.getRowIndex(), CommonConstants.ZERO_INT, infoVo.getEmpIdcard(), "", "", infoVo.getEmpName(), "社保缴纳月份不可为空!"));
return true;
}
if (!Common.isNotNull(infoVo.getSocialCreateMonth())) {
errorMessageList.put(UUID.randomUUID().toString(),new ErrorDetailVO(infoVo.getRowIndex(), CommonConstants.ZERO_INT, infoVo.getEmpIdcard(), "", "", infoVo.getEmpName(), "社保生成月份不可为空!"));
return true;
}
if (!Common.isNotNull(infoVo.getSocialPayAddr())) {
errorMessageList.put(UUID.randomUUID().toString(),new ErrorDetailVO(infoVo.getRowIndex(), CommonConstants.ZERO_INT, infoVo.getEmpIdcard(), "", "", infoVo.getEmpName(), "社保缴纳地不可为空!"));
return true;
}
return false;
}
/**
* 转换缴纳地址为省市县ID
**/
......@@ -2811,6 +3823,35 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
return s;
}
/**
* 转换缴纳地址为省市县ID
**/
private TPaymentTaxSocialVo initAddressThreeTax(String[] areaArray, HashMap<String, String> areaMap2, TPaymentTaxSocialVo s) {
if (null == areaArray || null == areaMap2 || null == s) {
return s;
}
String temp;
if (areaArray.length >= CommonConstants.TWO_INT) {
temp = areaMap2.get(areaArray[0] + CommonConstants.DOWN_LINE_STRING + "null");
if (Common.isNotNull(temp)) {
s.setSocialProvince(Integer.valueOf(temp));
}
temp = areaMap2.get(areaArray[1] + CommonConstants.DOWN_LINE_STRING + (null == s.getSocialProvince()
? "null" : Integer.toString(s.getSocialProvince())));
if (Common.isNotNull(temp)) {
s.setSocialCity(Integer.valueOf(temp));
}
if (areaArray.length >= CommonConstants.THREE_INT) {
temp = areaMap2.get(areaArray[2] + CommonConstants.DOWN_LINE_STRING + (null == s.getSocialCity()
? "null" : Integer.toString(s.getSocialCity())));
if (Common.isNotNull(temp)) {
s.setSocialTown(Integer.valueOf(temp));
}
}
}
return s;
}
//比对缴纳地是否一致
private TSocialFundInfo checkAddress(String[] areaArray, HashMap<String, String> areaMap, TSocialFundInfo s,
HashMap<String, String> areaMap2, TPaymentInfoVo infoVo) {
......
......@@ -288,14 +288,22 @@ public class TSocialDeadlineInfoServiceImpl extends ServiceImpl<TSocialDeadlineI
}
}
TSocialDeadlineInfo save;
LambdaQueryWrapper<TSocialDeadlineInfo> queryWrapper;
for (TSocialDeadlineInfo sd:baseLists){
queryWrapper= null;
save = new TSocialDeadlineInfo();
BeanUtil.copyProperties(sd,save);
save.setId(null);
save.setMonth(Integer.parseInt(DateUtil.getThisMonth()));
save.setType(CommonConstants.ZERO_STRING);
save.setSocialEndDate(DateUtil.getDateOfThisMonth(save.getSocialEndDate()));
save.setMedicalEndDate(DateUtil.getDateOfThisMonth(save.getMedicalEndDate()));
initSocialEndDate(holidayMap, save);
initMedicalEndDate(holidayMap, save);
queryWrapper = initCountQuery(save,queryWrapper);
if (baseMapper.selectCount(queryWrapper) > 0){
continue;
}
saveList.add(save);
}
if (Common.isNotNull(saveList)){
......@@ -303,6 +311,24 @@ public class TSocialDeadlineInfoServiceImpl extends ServiceImpl<TSocialDeadlineI
}
}
}
private LambdaQueryWrapper<TSocialDeadlineInfo> initCountQuery(TSocialDeadlineInfo save,LambdaQueryWrapper<TSocialDeadlineInfo> queryWrapper) {
queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(TSocialDeadlineInfo::getMonth, save.getMonth());
queryWrapper.eq(TSocialDeadlineInfo::getProvince, save.getProvince());
if (Common.isNotNull(save.getCity())){
queryWrapper.eq(TSocialDeadlineInfo::getCity, save.getCity());
if (Common.isNotNull(save.getTown())){
queryWrapper.eq(TSocialDeadlineInfo::getTown, save.getTown());
}else {
queryWrapper.isNull(TSocialDeadlineInfo::getTown);
}
}else {
queryWrapper.isNull(TSocialDeadlineInfo::getCity);
}
return queryWrapper;
}
@Transactional
@Override
public R<Boolean> updateByIdAsso(TSocialDeadlineInfo tSocialDeadlineInfo) {
......@@ -375,9 +401,8 @@ public class TSocialDeadlineInfoServiceImpl extends ServiceImpl<TSocialDeadlineI
private void initMedicalEndDate(Map<String, String> holidayMap, TSocialDeadlineInfo save) {
// type 0 休假 1 补班
String type;
type = holidayMap.get(DateUtil.getDay(save.getMedicalEndDate()));
if (Common.isNotNull(type) && CommonConstants.ZERO_STRING.equals(type)){
String day = holidayMap.get(DateUtil.getDay(save.getMedicalEndDate()));
if (Common.isNotNull(day)){
save.setMedicalEndDate(DateUtil.addDayByDate(save.getMedicalEndDate(),CommonConstants.ONE_INT_NEGATE));
}else {
return;
......@@ -387,9 +412,8 @@ public class TSocialDeadlineInfoServiceImpl extends ServiceImpl<TSocialDeadlineI
private void initSocialEndDate(Map<String, String> holidayMap, TSocialDeadlineInfo save) {
// type 0 休假 1 补班
String type;
type = holidayMap.get(DateUtil.getDay(save.getSocialEndDate()));
if (Common.isNotNull(type)&& CommonConstants.ZERO_STRING.equals(type)){
String day= holidayMap.get(DateUtil.getDay(save.getSocialEndDate()));
if (Common.isNotNull(day)){
save.setSocialEndDate(DateUtil.addDayByDate(save.getSocialEndDate(),CommonConstants.ONE_INT_NEGATE));
}else {
return;
......
......@@ -120,5 +120,6 @@
1=1
<include refid="tSocialDeadlineInfo_where"/>
</where>
order by a.month DESC
</select>
</mapper>
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