Commit a951fb43 authored by huyuchen's avatar huyuchen

明细接口改造

parent a487c444
...@@ -299,7 +299,6 @@ public class TIncomeServiceImpl extends ServiceImpl<TIncomeMapper, TIncome> impl ...@@ -299,7 +299,6 @@ public class TIncomeServiceImpl extends ServiceImpl<TIncomeMapper, TIncome> impl
TIncome income = new TIncome(); TIncome income = new TIncome();
income.setEmpIdcard(tIncomeDetail.getEmpIdcard()); income.setEmpIdcard(tIncomeDetail.getEmpIdcard());
income.setDeptId(tIncomeDetail.getDeptId()); income.setDeptId(tIncomeDetail.getDeptId());
synchronized (this) {
List<TIncome> incomeList = baseMapper.getTIncomeList(income); List<TIncome> incomeList = baseMapper.getTIncomeList(income);
TIncomeDetail detail = new TIncomeDetail(); TIncomeDetail detail = new TIncomeDetail();
detail.setEmpIdcard(tIncomeDetail.getEmpIdcard()); detail.setEmpIdcard(tIncomeDetail.getEmpIdcard());
...@@ -310,11 +309,10 @@ public class TIncomeServiceImpl extends ServiceImpl<TIncomeMapper, TIncome> impl ...@@ -310,11 +309,10 @@ public class TIncomeServiceImpl extends ServiceImpl<TIncomeMapper, TIncome> impl
tIncomeDetailService.save(tIncomeDetail); tIncomeDetailService.save(tIncomeDetail);
// 不存在,直接新增 // 不存在,直接新增
if (incomeList == null || incomeList.isEmpty()) { if (incomeList == null || incomeList.isEmpty()) {
return this.savePaymentIncome(tIncomeDetail, paymentId); return this.savePaymentIncomeNew(tIncomeDetail, paymentId);
} else { } else {
// 核心判断 // 核心判断
return this.copyCore(tIncomeDetail, incomeList, detailList, paymentId, true); return this.copyCoreNew(tIncomeDetail, incomeList, detailList, paymentId, false);
}
} }
} }
...@@ -439,6 +437,19 @@ public class TIncomeServiceImpl extends ServiceImpl<TIncomeMapper, TIncome> impl ...@@ -439,6 +437,19 @@ public class TIncomeServiceImpl extends ServiceImpl<TIncomeMapper, TIncome> impl
return true; return true;
} }
// 复制并保存
private boolean savePaymentIncomeNew(TIncomeDetail tIncomeDetail, String paymentId) {
TIncome income = new TIncome();
BeanUtil.copyProperties(tIncomeDetail, income);
income.setSendStatus(CommonConstants.ZERO_STRING);
income.setApplyNo(tIncomeDetail.getApplyNo());
this.save(income);
long start = System.currentTimeMillis();
income.setSourceId(paymentId);
doJointSocialTask.asynchronousEkpIncomePaymentNew(income,paymentId);
return true;
}
/** /**
* @param income 收入 * @param income 收入
* @param sendParam 目标格式 * @param sendParam 目标格式
...@@ -713,6 +724,138 @@ public class TIncomeServiceImpl extends ServiceImpl<TIncomeMapper, TIncome> impl ...@@ -713,6 +724,138 @@ public class TIncomeServiceImpl extends ServiceImpl<TIncomeMapper, TIncome> impl
return true; return true;
} }
/**
* @Description: 明细转统计核心逻辑
* @Author: hgw
* @Date: 2022/9/2 10:22
* @return: boolean
**/
private boolean copyCoreNew(TIncomeDetail tIncomeDetail, List<TIncome> incomeList, List<TIncomeDetail> detailList,
String paymentId,boolean synFlag) {
if (Common.isNotNull(tIncomeDetail.getSourceId())) {
// 如果该id、该类型的金额已存在,则不允许重复生成推送
TIncomeDetail a = new TIncomeDetail();
a.setId(tIncomeDetail.getId());
a.setSourceId(tIncomeDetail.getSourceId());
a.setMoney(tIncomeDetail.getMoney());
a.setRedData(tIncomeDetail.getRedData());
a.setFeeType(tIncomeDetail.getFeeType());
int repeatNums = tIncomeDetailService.getTIncomeDetailRepeat(a);
if (repeatNums > CommonConstants.ZERO_INT) {
return true;
}
}
// 判断,比例,直接加
if (CommonConstants.ONE_STRING.equals(tIncomeDetail.getFeeMode())) {
if (Common.isNotNull(paymentId)) {
return this.savePaymentIncomeNew(tIncomeDetail,paymentId);
} else {
return this.saveIncome(tIncomeDetail,synFlag);
}
} else {
Map<String, Integer> numMap = new HashMap<>();
Map<String, Integer> incomeMap = new HashMap<>();
// 商险Map
Map<String, Integer> insureMap = new HashMap<>();
Integer nums;
Integer insureNums;
for (TIncomeDetail detail : detailList) {
nums = numMap.get(detail.getPayMonth() + CommonConstants.DOWN_LINE_STRING + detail.getSourceType()
+ CommonConstants.DOWN_LINE_STRING + detail.getFeeType());
if (Common.isEmpty(nums)) {
nums = CommonConstants.ZERO_INT;
}
if (CommonConstants.ONE_STRING.equals(detail.getRedData())) {
nums--;
} else {
nums++;
}
numMap.put(detail.getPayMonth() + CommonConstants.DOWN_LINE_STRING + detail.getSourceType()
+ CommonConstants.DOWN_LINE_STRING + detail.getFeeType(), nums);
}
for (TIncome income : incomeList) {
nums = incomeMap.get(income.getPayMonth() + CommonConstants.DOWN_LINE_STRING + income.getFeeType());
if (Common.isEmpty(nums)) {
nums = CommonConstants.ZERO_INT;
}
if (CommonConstants.ONE_STRING.equals(income.getRedData())) {
nums--;
} else {
nums++;
}
incomeMap.put(income.getPayMonth() + CommonConstants.DOWN_LINE_STRING + income.getFeeType(), nums);
insureNums = insureMap.get(income.getDataCreateMonth() + CommonConstants.DOWN_LINE_STRING + income.getFeeType());
if (Common.isEmpty(insureNums)) {
insureNums = CommonConstants.ZERO_INT;
}
if (CommonConstants.ONE_STRING.equals(income.getRedData())) {
insureNums--;
} else {
insureNums++;
}
insureMap.put(income.getDataCreateMonth() + CommonConstants.DOWN_LINE_STRING + income.getFeeType(), insureNums);
}
// 金额人数、人次,需要判重
// 社保、公积金(收入来源:1社保2公积金3商险4薪资)
if (CommonConstants.ONE_STRING.equals(tIncomeDetail.getSourceType())
|| CommonConstants.TWO_STRING.equals(tIncomeDetail.getSourceType())) {
if (CommonConstants.ZERO_STRING.equals(tIncomeDetail.getRedData())) {
if (incomeMap.get(tIncomeDetail.getPayMonth() + CommonConstants.DOWN_LINE_STRING + tIncomeDetail.getFeeType()) == null
|| incomeMap.get(tIncomeDetail.getPayMonth() + CommonConstants.DOWN_LINE_STRING + tIncomeDetail.getFeeType()) <= CommonConstants.ZERO_INT) {
if (Common.isNotNull(paymentId)) {
return this.savePaymentIncomeNew(tIncomeDetail,paymentId);
} else {
return this.saveIncome(tIncomeDetail,synFlag);
}
}
} else {
// 红冲判断:当本类型是最大值,才可以红冲
if (this.redDateJudge(tIncomeDetail, numMap)) {
if (Common.isNotNull(paymentId)) {
return this.savePaymentIncomeNew(tIncomeDetail,paymentId);
} else {
return this.saveIncome(tIncomeDetail,synFlag);
}
}
}
} else if (CommonConstants.THREE_STRING.equals(tIncomeDetail.getSourceType())) {
// 商险。收费方式:2金额-人数
if (CommonConstants.TWO_STRING.equals(tIncomeDetail.getFeeMode())) {
if (CommonConstants.ZERO_STRING.equals(tIncomeDetail.getRedData())) {
if (insureMap.get(tIncomeDetail.getDataCreateMonth() + CommonConstants.DOWN_LINE_STRING + tIncomeDetail.getFeeType()) == null
|| insureMap.get(tIncomeDetail.getDataCreateMonth() + CommonConstants.DOWN_LINE_STRING + tIncomeDetail.getFeeType()) <= CommonConstants.ZERO_INT) {
return this.saveIncome(tIncomeDetail,synFlag);
}
} else {
if (this.redDateJudge(tIncomeDetail, numMap)) {
return this.saveIncome(tIncomeDetail,synFlag);
}
}
} else {
// 各个模式累加逻辑:
return this.judgeMixModel(tIncomeDetail, numMap, incomeMap,synFlag);
}
} else {
// 薪资。收费方式:2金额-人数
if (CommonConstants.TWO_STRING.equals(tIncomeDetail.getFeeMode())) {
if (incomeMap.get(tIncomeDetail.getPayMonth() + CommonConstants.DOWN_LINE_STRING + tIncomeDetail.getFeeType()) == null
|| incomeMap.get(tIncomeDetail.getPayMonth() + CommonConstants.DOWN_LINE_STRING + tIncomeDetail.getFeeType()) <= CommonConstants.ZERO_INT) {
return this.saveIncome(tIncomeDetail,synFlag);
}
} else {
// 3金额-人次
// 各个模式累加逻辑:
return this.judgeMixModel(tIncomeDetail, numMap, incomeMap,synFlag);
}
}
}
if (Common.isNotNull(paymentId)) {
tPaymentInfoMapper.updateBySocialIncomeFlag(paymentId);
}
return true;
}
/** /**
* @Description: 红冲判断 * @Description: 红冲判断
* @Author: hgw * @Author: hgw
......
...@@ -224,6 +224,53 @@ public class DoJointSocialTask { ...@@ -224,6 +224,53 @@ public class DoJointSocialTask {
log.info("推送收入到EKP结束"); log.info("推送收入到EKP结束");
} }
public void asynchronousEkpIncomePaymentNew(TIncome income,String paymentId) {
log.info("推送收入到EKP-线程开始");
try {
String sendBack = this.getSendBack(income);
if ((Common.isEmpty(sendBack) || sendBack.length() != 19) && Common.isNotNull(income.getRedisKey())) {
List<TIncome> list;
if (Common.isNotNull(redisUtil.get(income.getRedisKey()))) {
list = (List<TIncome>) redisUtil.get(income.getRedisKey());
} else {
list = new ArrayList<>();
}
list.add(income);
redisUtil.set(income.getRedisKey(),list);
}
income.setSendTime(new Date());
if (Common.isNotNull(sendBack) && sendBack.length() == 19) {
income.setSendStatus(CommonConstants.ONE_STRING);
income.setSendMonth(DateUtil.addMonth(0));
income.setEkpId(sendBack);
incomeMapper.updateById(income);
paymentInfoMapper.updateBySocialIncomePayment(paymentId);
} else {
TSendEkpError error = new TSendEkpError();
error.setCreateTime(new Date());
error.setCreateDay(DateUtil.getThisDay());
error.setType(CommonConstants.FOUR_STRING);
error.setCreateUserName("收入表推送");
error.setLinkId(income.getId());
error.setTitle(sendBack);
error.setNums(CommonConstants.ONE_INT);
tSendEkpErrorService.saveError(error);
}
} catch (Exception e) {
TSendEkpError error = new TSendEkpError();
error.setCreateTime(new Date());
error.setCreateDay(DateUtil.getThisDay());
error.setType(CommonConstants.FOUR_STRING);
error.setCreateUserName("收入表推送");
error.setLinkId(income.getId());
error.setTitle(e.getMessage());
error.setNums(CommonConstants.ONE_INT);
tSendEkpErrorService.saveError(error);
log.error("推送收入到EKP错误", e);
}
log.info("推送收入到EKP结束");
}
/** /**
* @Description: 合同-批量更换负责人 * @Description: 合同-批量更换负责人
* @Author: huyc * @Author: huyc
......
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