Commit 314150dc authored by huyuchen's avatar huyuchen

Merge branch 'develop'

# Conflicts:
#	yifu-common/yifu-common-core/src/main/java/com/yifu/cloud/plus/v1/yifu/common/core/config/AsyncConfig.java
#	yifu-common/yifu-common-core/src/main/java/com/yifu/cloud/plus/v1/yifu/common/core/util/ExcelUtil.java
parents 99e50344 b035c2eb
......@@ -200,7 +200,7 @@ public interface CommonConstants {
* @Author pwang
* @Date 2019-08-02 16:39
**/
int[] dingleDigitIntArray = {0,1,2,3,4,5,6,7,8,9};
int[] dingleDigitIntArray = {0,1,2,3,4,5,6,7,8,9,10,11,12};
/**
* 个位数字串(阿里编码规约不允许直接使用‘魔法值’)
* @Author pwang
......
......@@ -731,7 +731,7 @@ public class ExcelUtil <T> implements Serializable {
}
}
}
}*/
}
}
return null;
}
......
......@@ -1320,11 +1320,9 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
@Override
@Transactional(value = "insurancesTransactionManager" ,rollbackFor = {Exception.class})
public R<List<InsuranceHandleImportParam>> insuranceHandleImport(YifuUser user, List<InsuranceHandleImportParam> param) {
Map<String, List<InsuranceHandleImportParam>> map = insuranceChangeCheck(param, user,false);
List<InsuranceHandleImportParam> operateList = insuranceChangeCheck(param,false);
//检验成功的数据
List<InsuranceHandleImportParam> successList = map.get(InsurancesConstants.SUCCESS_LIST);
//校验失败的数据
List<InsuranceHandleImportParam> errorList = map.get(InsurancesConstants.ERROR_LIST);
List<InsuranceHandleImportParam> successList = operateList.stream().filter(e-> e.getErrorMessage().equals(CommonConstants.RESULT_DATA_SUCESS)).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(successList)){
//投保成功的数据
List<InsuranceHandleImportParam> collectSuccess = successList.stream().filter(e -> InsurancesConstants.SUCCESS.equals(e.getHandType())).collect(Collectors.toList());
......@@ -1357,7 +1355,10 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
this.rollBackInsurance(user,list);
}
}
return R.ok(errorList,InsurancesConstants.IMPORT_SUCCESS);
if (operateList.stream().allMatch(e->e.getErrorMessage().equals(CommonConstants.RESULT_DATA_SUCESS))) {
operateList = null;
}
return R.ok(operateList,InsurancesConstants.IMPORT_SUCCESS);
}
/**
......@@ -1571,7 +1572,10 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
* @return: void
**/
private void doFailInfo(List<TInsuranceDetail> sourceList, List<String> sourceIdCardList, List<String> replaceIdList, String toStatus) {
List<TInsuranceDetail> sourceEmpList = baseMapper.selectByIdCardList(sourceIdCardList, replaceIdList);
List<TInsuranceDetail> sourceEmpList = null;
if (sourceIdCardList != null && !sourceIdCardList.isEmpty()) {
sourceEmpList = baseMapper.selectByIdCardList(sourceIdCardList, replaceIdList);
}
if (sourceEmpList != null && !sourceEmpList.isEmpty()) {
// 项目档案状态
Map<String , Integer> proStatusMap = new HashMap<>();
......@@ -1721,11 +1725,9 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
if (user == null || Common.isEmpty(user.getId())) {
return R.failed(CommonConstants.PLEASE_LOG_IN);
}
Map<String, List<InsuranceRegisterParam>> map = registeredPolicyPremiumCheck(paramList,user);
//返回给前端的结果
List<InsuranceRegisterParam> listResult = map.get("listResult");
List<InsuranceRegisterParam> operatList = registeredPolicyPremiumCheck(paramList);
//保存到数据库中的结果
List<InsuranceRegisterParam> listSuccess = map.get("listSuccess");
List<InsuranceRegisterParam> listSuccess = operatList.stream().filter(e-> e.getErrorMessage().equals(CommonConstants.RESULT_DATA_SUCESS)).collect(Collectors.toList());
List<TInsuranceDetail> detailList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(listSuccess)){
for (InsuranceRegisterParam success : listSuccess) {
......@@ -2043,7 +2045,10 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
}
//操作记录
addOperate(detailList,user,InsurancesConstants.REGISTERED,null,CommonConstants.ONE_INT);
return R.ok(listResult,InsurancesConstants.OPERATE_SUCCESS);
if (operatList.stream().allMatch(e->e.getErrorMessage().equals(CommonConstants.RESULT_DATA_SUCESS))) {
operatList = null;
}
return R.ok(operatList,InsurancesConstants.OPERATE_SUCCESS);
}
/*
......@@ -3156,75 +3161,60 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
* @param paramList
* @return {@link Map<String, List<InsuranceRegisterParam>>}
*/
private Map<String,List<InsuranceRegisterParam>> registeredPolicyPremiumCheck(List<InsuranceRegisterParam> paramList,YifuUser user){
Map<String,List<InsuranceRegisterParam>> map = new HashMap<>();
List<InsuranceRegisterParam> listResult = new ArrayList<>();
List<InsuranceRegisterParam> listSuccess = new ArrayList<>();
private List<InsuranceRegisterParam> registeredPolicyPremiumCheck(List<InsuranceRegisterParam> paramList){
for (InsuranceRegisterParam param : paramList.stream().distinct().collect(Collectors.toList())) {
// 必填校验
if (StringUtils.isBlank(param.getEmpName())){
param.setErrorMessage(InsurancesConstants.EMP_NAME_NOT_EMPTY);
listResult.add(param);
continue;
}
if (StringUtils.isBlank(param.getEmpIdcardNo())){
param.setErrorMessage(InsurancesConstants.EMP_IDCARD_NO_NOT_EMPTY);
listResult.add(param);
continue;
}
if (StringUtils.isBlank(param.getInsuranceCompanyName())){
param.setErrorMessage(InsurancesConstants.INSURANCE_COMPANY_NAME_NOT_EMPTY);
listResult.add(param);
continue;
}
if (StringUtils.isBlank(param.getInsuranceTypeName())){
param.setErrorMessage(InsurancesConstants.INSURANCE_TYPE_NAME_NOT_EMPTY);
listResult.add(param);
continue;
}
if (StringUtils.isBlank(param.getPolicyStart())){
param.setErrorMessage(InsurancesConstants.POLICY_START_NOT_EMPTY);
listResult.add(param);
continue;
}
if (StringUtils.isBlank(param.getPolicyEnd())){
param.setErrorMessage(InsurancesConstants.POLICY_END_NOT_EMPTY);
listResult.add(param);
continue;
}
if(!LocalDateUtil.isDate(param.getPolicyStart(),LocalDateUtil.NORM_DATE_PATTERN)){
param.setErrorMessage(InsurancesConstants.POLICY_START_PARSE_ERROR);
listResult.add(param);
continue;
}
if(!LocalDateUtil.isDate(param.getPolicyEnd(),LocalDateUtil.NORM_DATE_PATTERN)){
param.setErrorMessage(InsurancesConstants.POLICY_END_PARSE_ERROR);
listResult.add(param);
continue;
}
if (StringUtils.isBlank(param.getBuyStandard())){
param.setErrorMessage(InsurancesConstants.BUY_STANDARD_NOT_EMPTY);
listResult.add(param);
continue;
}
if (StringUtils.isNotBlank(param.getPolicyNo())){
if (!ValidityUtil.validate50(param.getPolicyNo())){
param.setErrorMessage(InsurancesConstants.POLICY_NO_MORE_THAN_50);
listResult.add(param);
continue;
}
}
if (StringUtils.isNotBlank(param.getActualPremium())){
if(!ValidityUtil.validateMoney(param.getActualPremium())){
param.setErrorMessage(InsurancesConstants.ACTUAL_PREMIUM_PARSE_ERROR);
listResult.add(param);
continue;
}
}
if (StringUtils.isNotBlank(param.getInvoiceNo())){
if (!ValidityUtil.validate50(param.getInvoiceNo())){
param.setErrorMessage(InsurancesConstants.INVOICE_NO_MORE_THAN_50);
listResult.add(param);
continue;
}
}
......@@ -3243,7 +3233,6 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
);
if (!Optional.ofNullable(detail).isPresent()){
param.setErrorMessage(InsurancesConstants.DATA_IS_NOT_EXIST);
listResult.add(param);
continue;
}else {
LambdaQueryWrapper<TInsuranceEkp> ekpLambdaQueryWrapper = new LambdaQueryWrapper<>();
......@@ -3251,19 +3240,16 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
List<TInsuranceEkp> ekpList = tInsuranceEkpService.list(ekpLambdaQueryWrapper);
if(CollectionUtils.isNotEmpty(ekpList)){
param.setErrorMessage(InsurancesConstants.EKP_SEND_ERROR);
listResult.add(param);
continue;
}
// 如果保费不存在,保单号、保费必填
if (detail.getActualPremium() == null){
if (StringUtils.isBlank(param.getPolicyNo())){
param.setErrorMessage(InsurancesConstants.POLICY_NO_EMPTY);
listResult.add(param);
continue;
}
if (StringUtils.isBlank(param.getActualPremium())){
param.setErrorMessage(InsurancesConstants.ACTUAL_PREMIUM_EMPTY);
listResult.add(param);
continue;
}
}
......@@ -3279,13 +3265,11 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
);
if (!Optional.ofNullable(batchPolicyNo).isPresent()){
param.setErrorMessage(InsurancesConstants.POLICY_NO_NOT_EXIST);
listResult.add(param);
continue;
}else {
//批增类型,保单号已存在但是和派单时填写的不一致
if (!detail.getPolicyNo().equals(param.getPolicyNo())){
param.setErrorMessage(InsurancesConstants.POLICY_NO_ERROR);
listResult.add(param);
continue;
}
}
......@@ -3304,12 +3288,10 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
if (Optional.ofNullable(addPolicyNo).isPresent()){
if (!addPolicyNo.getInsuranceCompanyName().equals(param.getInsuranceCompanyName())){
param.setErrorMessage(InsurancesConstants.POLICY_NO_COMPANY_NAME_NOT_SAME);
listResult.add(param);
continue;
}
if (!addPolicyNo.getInsuranceTypeName().equals(param.getInsuranceTypeName())){
param.setErrorMessage(InsurancesConstants.POLICY_NO_TYPE_NAME_NOT_SAME);
listResult.add(param);
continue;
}
}
......@@ -3318,22 +3300,18 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
if (detail.getBuyType() == CommonConstants.FOUR_INT){
param.setErrorMessage(InsurancesConstants.BUY_TYPE_FOUR_NOT_REGISTERED);
listResult.add(param);
continue;
}
if (detail.getBuyHandleStatus() == CommonConstants.ONE_INT){
param.setErrorMessage(InsurancesConstants.BUY_HANDLE_ONE_NOT_REGISTERED);
listResult.add(param);
continue;
}
if (detail.getBuyHandleStatus() == CommonConstants.TWO_INT){
param.setErrorMessage(InsurancesConstants.BUY_HANDLE_TWO_NOT_REGISTERED);
listResult.add(param);
continue;
}
if (detail.getBuyHandleStatus() == CommonConstants.FOUR_INT){
param.setErrorMessage(InsurancesConstants.BUY_HANDLE_FOUR_NOT_REGISTERED);
listResult.add(param);
continue;
}
//保单号是否更新
......@@ -3357,12 +3335,10 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
if(booleanActualPremium && !booleanPolicyNo && !booleanInvoiceNo){
if ( InsurancesConstants.SETTLE_TWO.equals(actualStatus)){
param.setErrorMessage(InsurancesConstants.SETTLE_HANDLE_THREE_NOT_REGISTERED);
listResult.add(param);
continue;
}
if (InsurancesConstants.SETTLE_ONE.equals(actualStatus)){
param.setErrorMessage(InsurancesConstants.SETTLE_HANDLE_TWO_NOT_REGISTERED);
listResult.add(param);
continue;
}
}
......@@ -3370,12 +3346,10 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
if(!booleanPolicyNo || !booleanInvoiceNo){
if (InsurancesConstants.SETTLE_TWO.equals(estimateStatus) || InsurancesConstants.SETTLE_TWO.equals(actualStatus)){
param.setErrorMessage(InsurancesConstants.SETTLE_HANDLE_THREE_NOT_REGISTERED);
listResult.add(param);
continue;
}
if (InsurancesConstants.SETTLE_ONE.equals(estimateStatus) || InsurancesConstants.SETTLE_ONE.equals(actualStatus)){
param.setErrorMessage(InsurancesConstants.SETTLE_HANDLE_TWO_NOT_REGISTERED);
listResult.add(param);
continue;
}
}
......@@ -3394,25 +3368,20 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
if(booleanActualPremium && !booleanPolicyNo && !booleanInvoiceNo){
if ( InsurancesConstants.SETTLE_TWO.equals(actualStatus)){
param.setErrorMessage(InsurancesConstants.SETTLE_HANDLE_THREE_NOT_REGISTERED);
listResult.add(param);
continue;
}
if (InsurancesConstants.SETTLE_ONE.equals(actualStatus)){
param.setErrorMessage(InsurancesConstants.SETTLE_HANDLE_TWO_NOT_REGISTERED);
listResult.add(param);
continue;
}
}
}
}
}
}
listSuccess.add(param);
param.setErrorMessage(CommonConstants.RESULT_DATA_SUCESS);
}
map.put("listResult",listResult);
map.put("listSuccess",listSuccess);
return map;
return paramList;
}
/**
......@@ -4047,9 +4016,9 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
if(insuranceRefundImportList.size() > CommonConstants.IMPORT_TWENTY_THOUSAND){
return R.failed(InsurancesConstants.IMPORT_TOO_LONG);
}
Map<String, List<InsuranceHandleImportParam>> map = insuranceChangeCheck(insuranceRefundImportList, user,true);
List<InsuranceHandleImportParam> successList = map.get(InsurancesConstants.SUCCESS_LIST);
List<InsuranceHandleImportParam> errorList = map.get(InsurancesConstants.ERROR_LIST);
List<InsuranceHandleImportParam> list = insuranceChangeCheck(insuranceRefundImportList,true);
//检验成功的数据
List<InsuranceHandleImportParam> successList = list.stream().filter(e-> e.getErrorMessage().equals(CommonConstants.RESULT_DATA_SUCESS)).collect(Collectors.toList());
//减员退回
List<TInsuranceOperate> operateList =new ArrayList<>(16);
List<TInsuranceDetail> sourceList = new ArrayList<>();
......@@ -4100,7 +4069,10 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
tInsuranceOperateService.saveBatch(operateList);
// 减员失效
this.doFailInfo(sourceList, sourceIdCardList, replaceIdList, CommonConstants.THREE_STRING);
return R.ok(errorList, InsurancesConstants.IMPORT_SUCCESS);
if (list.stream().allMatch(e->e.getErrorMessage().equals(CommonConstants.RESULT_DATA_SUCESS))) {
list = null;
}
return R.ok(list, InsurancesConstants.IMPORT_SUCCESS);
}
/**
......@@ -5516,14 +5488,10 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
*
* @author zhaji
* @param checkList 投保成功/退回/减员办理校验
* @param user
* @param flag true 减员 false 投保成功/退回
* @return {@link Map<String, List<InsuranceHandleImportParam>}
*/
private Map<String,List<InsuranceHandleImportParam>> insuranceChangeCheck(List<InsuranceHandleImportParam> checkList, YifuUser user,Boolean flag) {
Map<String,List<InsuranceHandleImportParam>> map = new HashMap<>(16);
List<InsuranceHandleImportParam> errorList = new ArrayList<>();
List<InsuranceHandleImportParam> successList = new ArrayList<>();
private List<InsuranceHandleImportParam> insuranceChangeCheck(List<InsuranceHandleImportParam> checkList, boolean flag) {
List<InsuranceHandleImportParam> distinctList = checkList.stream().distinct().collect(Collectors.toList());
//定义外层循环标识,方便去重的时候跳出
outer:
......@@ -5533,91 +5501,77 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
String handType = param.getHandType();
if(StringUtils.isBlank(handType)){
param.setErrorMessage(InsurancesConstants.HAND_RESULT_IS_EMPTY);
errorList.add(param);
continue;
}
if(!InsurancesConstants.SUCCESS.equals(handType) && !InsurancesConstants.FAILED.equals(handType)){
param.setErrorMessage(InsurancesConstants.HAND_RESULT_ERROR);
errorList.add(param);
continue;
}
//办理意见
String remark = param.getRemark();
if(InsurancesConstants.FAILED.equals(handType) && StringUtils.isBlank(remark)){
param.setErrorMessage(InsurancesConstants.ROLLBACK_MESSAGE_IS_EMPTY);
errorList.add(param);
continue;
}
if(StringUtils.isNotBlank(remark) && !ValidityUtil.validate50(remark)){
param.setErrorMessage(InsurancesConstants.HAND_REMARK_NOT_MORE_THAN_50);
errorList.add(param);
continue;
}
//员工姓名
String empName = param.getEmpName();
if(StringUtils.isBlank(empName)){
param.setErrorMessage(InsurancesConstants.EMP_NAME_NOT_EMPTY);
errorList.add(param);
continue;
}
//员工身份证
String empIdCardNo = param.getEmpIdcardNo();
if(StringUtils.isBlank(empIdCardNo)){
param.setErrorMessage(InsurancesConstants.EMP_IDCARD_NO_NOT_EMPTY);
errorList.add(param);
continue;
}
//保险公司名称
String insuranceCompanyName = param.getInsuranceCompanyName();
if(StringUtils.isBlank(insuranceCompanyName)){
param.setErrorMessage(InsurancesConstants.INSURANCE_COMPANY_NAME_NOT_EMPTY);
errorList.add(param);
continue;
}
//险种名称
String insuranceTypeName = param.getInsuranceTypeName();
if(StringUtils.isBlank(insuranceTypeName)){
param.setErrorMessage(InsurancesConstants.INSURANCE_TYPE_NAME_NOT_EMPTY);
errorList.add(param);
continue;
}
//购买标准
String buyStandard = param.getBuyStandard();
if(StringUtils.isBlank(buyStandard)){
param.setErrorMessage(InsurancesConstants.BUY_STANDARD_NOT_EMPTY);
errorList.add(param);
continue;
}
//保单开始日期
String policyStart = param.getPolicyStart();
if(StringUtils.isBlank(policyStart)){
param.setErrorMessage(InsurancesConstants.POLICY_START_NOT_EMPTY);
errorList.add(param);
continue;
}
//保单结束日期
String policyEnd = param.getPolicyEnd();
if(StringUtils.isBlank(policyEnd)){
param.setErrorMessage(InsurancesConstants.POLICY_END_NOT_EMPTY);
errorList.add(param);
continue;
}
// 身份证号位数校验(18 位合法)
if (!ValidityUtil.validateIDCard(param.getEmpIdcardNo())){
param.setErrorMessage(InsurancesConstants.EMP_IDCARD_NO_NOT_LEGITIMATE);
errorList.add(param);
continue;
}
// 保单开始日期格式校验
if(!LocalDateUtil.isDate(policyStart,LocalDateUtil.NORM_DATE_PATTERN)){
param.setErrorMessage(InsurancesConstants.POLICY_START_PARSE_ERROR);
errorList.add(param);
continue;
}
// 保单结束日期格式校验
if(!LocalDateUtil.isDate(policyEnd,LocalDateUtil.NORM_DATE_PATTERN)){
param.setErrorMessage(InsurancesConstants.POLICY_END_PARSE_ERROR);
errorList.add(param);
continue;
}
......@@ -5633,7 +5587,6 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
&& param.getBuyStandard().equals(repeat.getBuyStandard())
&& i != j){
param.setErrorMessage(InsurancesConstants.DUPLICATE_DATA_ERROR);
errorList.add(param);
continue outer;
}
}
......@@ -5653,7 +5606,6 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
//如果保单信息为空
if (Common.isEmpty(insuranceDetail)){
param.setErrorMessage(InsurancesConstants.USER_DATA_IS_NOT_EXIST);
errorList.add(param);
continue;
}
String detailId = insuranceDetail.getId();
......@@ -5666,44 +5618,37 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
//商险待投保,无法办理
if (CommonConstants.ONE_INT == buyHandleStatus){
param.setErrorMessage(InsurancesConstants.BUY_HANDLE_STATUS_ONE_HANDLE_ERROR);
errorList.add(param);
continue;
}
//商险投保中,无法办理
if (CommonConstants.TWO_INT == buyHandleStatus){
param.setErrorMessage(InsurancesConstants.BUY_HANDLE_STATUS_TWO_HANDLE_ERROR);
errorList.add(param);
continue;
}
//商险投保成功,无法办理
if (CommonConstants.THREE_INT == buyHandleStatus && null == reduceHandleStatus){
param.setErrorMessage(InsurancesConstants.BUY_HANDLE_STATUS_THREE_HANDLE_ERROR);
errorList.add(param);
continue;
}
//商险投保退回,无法办理
if (CommonConstants.FOUR_INT == buyHandleStatus){
param.setErrorMessage(InsurancesConstants.BUY_HANDLE_STATUS_FOUR_HANDLE_ERROR);
errorList.add(param);
continue;
}
if ( null != reduceHandleStatus){
//待减员
if(CommonConstants.ONE_INT == reduceHandleStatus ){
param.setErrorMessage(InsurancesConstants.REFUND_STATUS_ONE_HANDLE_ERROR);
errorList.add(param);
continue;
}
//减员退回
if(CommonConstants.THREE_INT == reduceHandleStatus ){
param.setErrorMessage(InsurancesConstants.REFUND_STATUS_FOUR_HANDLE_ERROR);
errorList.add(param);
continue;
}
//已减员
if(CommonConstants.FOUR_INT== reduceHandleStatus ){
param.setErrorMessage(InsurancesConstants.REFUND_STATUS_THREE_HANDLE_ERROR);
errorList.add(param);
continue;
}
}
......@@ -5713,16 +5658,13 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
if (CommonConstants.TWO_INT != insuranceDetail.getBuyHandleStatus()){
String buyHandleStatus = getBuyHandleStatus(insuranceDetail.getBuyHandleStatus());
param.setErrorMessage("当前为"+buyHandleStatus+"状态,不可办理");
errorList.add(param);
continue;
}
}
param.setId(detailId);
successList.add(param);
param.setErrorMessage(CommonConstants.RESULT_DATA_SUCESS);
}
map.put(InsurancesConstants.SUCCESS_LIST,successList);
map.put(InsurancesConstants.ERROR_LIST,errorList);
return map;
return distinctList;
}
/**
......
......@@ -148,12 +148,12 @@ public class TSalaryStandard extends BaseEntity {
@ExcelProperty("款项来源(0客户到款/1垫付)")
private Integer moneyFrom;
/**
* 状态(0待提交1待审核2:待推送3已推送待发放4已发放5审核不通过6确认不通过7财务退回8:结算单调整待审核 9: 结算单调整待打印)
* 状态(0待提交1待审核2:待推送3已推送待发放4已发放5审核不通过6确认不通过7财务退回8:结算单调整待审核 9: 结算单调整待打印 10 推送失败 11 推送收入中12推送收入失败
*/
@ExcelAttribute(name = "状态(0待提交1待审核2:待推送3已推送待发放4已发放5审核不通过6确认不通过7财务退回8:结算单调整待审核 9: 结算单调整待打印10 推送失败)", isNotEmpty = true, errorInfo = "状态(0待提交1待审核2:待推送3已推送待发放4已发放5审核不通过6确认不通过7财务退回8:结算单调整待审核 9: 结算单调整待打印)不能为空")
@NotBlank(message = "状态(0待提交1待审核2:待推送3已推送待发放4已发放5审核不通过6确认不通过7财务退回8:结算单调整待审核 9: 结算单调整待打印10 推送失败)不能为空")
@ExcelAttribute(name = "状态(0待提交1待审核2:待推送明细3已推送待发放4已发放5审核不通过6确认不通过7财务退回8:结算单调整待审核 9: 结算单调整待打印10 推送失败 11 已审核生成收入中12已审核生成收入失败)", isNotEmpty = true, errorInfo = "状态(0待提交1待审核2:待推送3已推送待发放4已发放5审核不通过6确认不通过7财务退回8:结算单调整待审核 9: 结算单调整待打印)不能为空")
@NotBlank(message = "状态(0待提交1待审核2:待推送明细3已推送待发放4已发放5审核不通过6确认不通过7财务退回8:结算单调整待审核 9: 结算单调整待打印10 推送失败 11 已审核生成收入中12已审核生成收入失败)不能为空")
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("状态(0待提交1待审核2:待推送3已推送待发放4已发放5审核不通过6确认不通过7财务退回8:结算单调整待审核 9: 结算单调整待打印 10 推送失败)")
@ExcelProperty("状态(0待提交1待审核2:待推送明细3已推送待发放4已发放5审核不通过6确认不通过7财务退回8:结算单调整待审核 9: 结算单调整待打印 10 推送失败 11 已审核生成收入中12已审核生成收入失败)")
private Integer status;
/**
* 提交时间
......@@ -415,6 +415,22 @@ public class TSalaryStandard extends BaseEntity {
@ExcelIgnore
private String bpoFlag;
/**
* 生成、推送收入的开始时间
*/
@ExcelAttribute(name = "生成、推送收入的开始时间", isDate = true)
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("生成、推送收入的开始时间")
private Date incomeStartTime;
/**
* 生成、推送收入的完成时间
*/
@ExcelAttribute(name = "生成、推送收入的完成时间", isDate = true)
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("生成、推送收入的完成时间")
private Date incomeEndTime;
/**
* 工资月份-起
*/
......
......@@ -26,7 +26,7 @@ public class TSalaryStandardExportVo implements Serializable {
/**
* 状态0待提交 1待审核 2审核通过 3发送成功 5审核不通过 10 发送失败
*/
@ExcelAttribute(name = "状态", isDataId = true, readConverterExp = "0=待提交,1=待审核,2=审核通过,3=发送成功,5=审核不通过,6=确认不通过,10=发送失败")
@ExcelAttribute(name = "状态", isDataId = true, readConverterExp = "0=待提交,1=待审核,2=待推送明细,3=发送成功,5=审核不通过,6=确认不通过,10=发送失败,11=已审核生成收入中,12=已审核生成收入失败")
@NotBlank(message = "状态(0待提交 1待审核 2审核通过 3发送成功 5审核不通过 10 发送失败)不能为空")
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("薪酬状态")
......
......@@ -229,4 +229,14 @@ public class TSalaryStandardController {
public R<String> backSalaryByApplyNo(@RequestParam String applyNo) {
return tSalaryStandardService.backSalaryByApplyNo(applyNo);
}
/**
* @param id
* @return
*/
@Operation(description = "重新生成收入")
@GetMapping("/salaryDoIncome")
public R<String> salaryDoIncome(@RequestParam String id) {
return tSalaryStandardService.salaryDoIncome(id);
}
}
......@@ -63,6 +63,15 @@ public interface TSalaryStandardService extends IService<TSalaryStandard> {
*/
R<String> salaryStandardAudit(String auditFlag, String auditRemark,String id);
/**
* @param id 工资表id
* @Description: 重新生成收入
* @Author: hgw
* @Date: 2022/11/29 17:49
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.String>
**/
R<String> salaryDoIncome(String id);
/**
* @Description: 删除工资表
* @Author: hgw
......
......@@ -31,7 +31,10 @@ import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpStatusVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TSettleDomainSelectVo;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.SecurityConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.*;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.DateUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ExcelUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
import com.yifu.cloud.plus.v1.yifu.common.dapr.config.DaprArchivesProperties;
import com.yifu.cloud.plus.v1.yifu.common.dapr.config.DaprSocialProperties;
......@@ -50,25 +53,26 @@ import com.yifu.cloud.plus.v1.yifu.salary.service.MSalaryEstimateService;
import com.yifu.cloud.plus.v1.yifu.salary.service.TApprovalRecordService;
import com.yifu.cloud.plus.v1.yifu.salary.service.TSalaryAccountService;
import com.yifu.cloud.plus.v1.yifu.salary.service.TSalaryStandardService;
import com.yifu.cloud.plus.v1.yifu.salary.util.DoJointSalaryAsyncTask;
import com.yifu.cloud.plus.v1.yifu.salary.util.SalaryConstants;
import com.yifu.cloud.plus.v1.yifu.salary.vo.TSalaryStandardExportVo;
import com.yifu.cloud.plus.v1.yifu.salary.vo.TSalaryStandardSearchVo;
import com.yifu.cloud.plus.v1.yifu.social.entity.TIncome;
import com.yifu.cloud.plus.v1.yifu.social.entity.TIncomeDetail;
import com.yifu.cloud.plus.v1.yifu.social.entity.TSendEkpError;
import com.yifu.cloud.plus.v1.yifu.social.vo.TIncomeDetailReturnVo;
import lombok.AllArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.util.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* 标准薪酬工资表
......@@ -78,32 +82,21 @@ import java.util.*;
*/
@Log4j2
@Service
@AllArgsConstructor
@EnableConfigurationProperties({DaprArchivesProperties.class, DaprSocialProperties.class})
public class TSalaryStandardServiceImpl extends ServiceImpl<TSalaryStandardMapper, TSalaryStandard> implements TSalaryStandardService {
@Autowired
private TApprovalRecordService approvalRecordService;
@Autowired
private TSalaryAccountService salaryAccountService;
@Autowired
private MSalaryEstimateService mSalaryEstimateService;
@Autowired
private DaprSocialProperties socialProperties;
@Autowired
private DaprArchivesProperties archivesProperties;
@Autowired
private EkpSalaryUtil ekpSalaryUtil;
@Autowired
private EkpSocialUtil ekpSocialUtil;
@Autowired
private EkpFundUtil ekpFundUtil;
@Autowired
private TApprovalRecordService auditLogService;
private final TApprovalRecordService approvalRecordService;
private final TSalaryAccountService salaryAccountService;
private final MSalaryEstimateService mSalaryEstimateService;
private final DaprSocialProperties socialProperties;
private final DaprArchivesProperties archivesProperties;
private final EkpSalaryUtil ekpSalaryUtil;
private final EkpSocialUtil ekpSocialUtil;
private final EkpFundUtil ekpFundUtil;
private final TApprovalRecordService auditLogService;
@Lazy
private final DoJointSalaryAsyncTask doSalaryAsync;
/**
* 标准薪酬工资表简单分页查询
......@@ -213,12 +206,30 @@ public class TSalaryStandardServiceImpl extends ServiceImpl<TSalaryStandardMappe
TApprovalRecord tApprovalRecord = new TApprovalRecord();
if (CommonConstants.ZERO_STRING.equals(auditFlag)) {
tSalaryStandard.setStatus(CommonConstants.TWO_INT);
tApprovalRecord.setApprovalResult(CommonConstants.ZERO_STRING);
tApprovalRecord.setNodeId("审核通过");
// 收入相关
R<String> failed = doIncomeDetail(id, tSalaryStandard);
if (failed != null) return failed;
R<TSettleDomainSelectVo> sdr = HttpDaprUtil.invokeMethodPost(archivesProperties.getAppUrl(), archivesProperties.getAppId()
, "/tsettledomain/inner/getSettleDomainVoById", tSalaryStandard.getDeptId()
, TSettleDomainSelectVo.class, SecurityConstants.FROM_IN);
// 结算主体
TSettleDomainSelectVo dept;
if (sdr != null && sdr.getData() != null) {
dept = sdr.getData();
} else {
return R.failed("获取项目信息失败,请联管理员!");
}
List<TSalaryAccount> salaryAccountList = salaryAccountService.getListByIncome(id);
if (salaryAccountList != null && !salaryAccountList.isEmpty()) {
// 将审核状态变为中间态
tSalaryStandard.setStatus(CommonConstants.dingleDigitIntArray[11]);
tSalaryStandard.setIncomeStartTime(new Date());
baseMapper.updateById(tSalaryStandard);
// 异步-收入相关
doSalaryAsync.doIncomeDetail(dept, salaryAccountList, id, tSalaryStandard);
}
} else {
tSalaryStandard.setStatus(CommonConstants.FIVE_INT);
tApprovalRecord.setApprovalResult(CommonConstants.ONE_STRING);
......@@ -242,170 +253,6 @@ public class TSalaryStandardServiceImpl extends ServiceImpl<TSalaryStandardMappe
}
/**
* @param id
* @param tSalaryStandard
* @Description: 处理收入明细
* @Author: hgw
* @Date: 2022/9/2 17:35
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.String>
**/
private R<String> doIncomeDetail(String id, TSalaryStandard tSalaryStandard) {
R<TSettleDomainSelectVo> sdr = HttpDaprUtil.invokeMethodPost(archivesProperties.getAppUrl(), archivesProperties.getAppId()
, "/tsettledomain/inner/getSettleDomainVoById", tSalaryStandard.getDeptId()
, TSettleDomainSelectVo.class, SecurityConstants.FROM_IN);
// 结算主体
TSettleDomainSelectVo dept;
if (sdr != null && sdr.getData() != null) {
dept = sdr.getData();
} else {
return R.failed("获取项目信息失败,请联管理员!");
}
List<TSalaryAccount> salaryAccountList = salaryAccountService.getListByIncome(id);
if (salaryAccountList != null && !salaryAccountList.isEmpty()) {
List<String> idCardList = new ArrayList<>();
for (TSalaryAccount account : salaryAccountList) {
idCardList.add(account.getEmpIdcard());
}
Map<String, Integer> detailMap = new HashMap<>();
// 收入相关
R<String> failed1 = getIncomeDetailMap(tSalaryStandard, dept, idCardList, detailMap);
if (failed1 != null) return failed1;
// 含有薪资,则计算收入
// 管理费
if (Common.isNotNull(dept.getManageServerItem()) && dept.getManageServerItem().contains(CommonConstants.FOUR_STRING)
&& CommonConstants.ZERO_STRING.equals(dept.getManagementTag())) {
// 金额-人数
if (CommonConstants.TWO_STRING.equals(dept.getManagementType())) {
// 保存明细
R<String> failed = saveIncomeDetail(salaryAccountList, tSalaryStandard, dept, detailMap, dept.getManagementType(), CommonConstants.ONE_STRING);
if (failed != null) return failed;
} else {
// 保存明细
R<String> failed = saveIncomeDetail(salaryAccountList, tSalaryStandard, dept, new HashMap<>(), dept.getManagementType(), CommonConstants.ONE_STRING);
if (failed != null) return failed;
}
}
// 风险金
if (Common.isNotNull(dept.getRiskServerItem()) && dept.getRiskServerItem().contains(CommonConstants.FOUR_STRING)
&& CommonConstants.ZERO_STRING.equals(dept.getRiskFundTag())) {
// 金额-人数
if (CommonConstants.TWO_STRING.equals(dept.getRiskFundType())) {
// 保存明细
R<String> failed = saveIncomeDetail(salaryAccountList, tSalaryStandard, dept, detailMap, dept.getRiskFundType(), CommonConstants.TWO_STRING);
if (failed != null) return failed;
} else {
// 保存明细
R<String> failed = saveIncomeDetail(salaryAccountList, tSalaryStandard, dept, new HashMap<>(), dept.getRiskFundType(), CommonConstants.TWO_STRING);
if (failed != null) return failed;
}
}
}
return null;
}
/**
* @Description: 获取收入信息
* @Author: hgw
* @Date: 2022/9/6 10:39
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.String>
**/
private R<String> getIncomeDetailMap(TSalaryStandard tSalaryStandard, TSettleDomainSelectVo dept, List<String> idCardList, Map<String, Integer> detailMap) {
TIncomeDetail detail = new TIncomeDetail();
detail.setApplyNo(tSalaryStandard.getApplyNo());
detail.setPayMonth(tSalaryStandard.getSalaryMonth());
detail.setIdCardList(idCardList);
detail.setDeptId(dept.getId());
R<TIncomeDetailReturnVo> detailR = HttpDaprUtil.invokeMethodPost(socialProperties.getAppUrl(), socialProperties.getAppId()
, "/tincomedetail/inner/getTIncomeDetailList", detail
, TIncomeDetailReturnVo.class, SecurityConstants.FROM_IN);
Integer value;
if (detailR != null) {
if (detailR.getData() != null && detailR.getData().getDetailList() != null && !detailR.getData().getDetailList().isEmpty()) {
TIncomeDetailReturnVo vo = detailR.getData();
List<TIncomeDetail> detailList = vo.getDetailList();
for (TIncomeDetail incomeDetail : detailList) {
value = detailMap.get(incomeDetail.getEmpIdcard() + CommonConstants.DOWN_LINE_STRING
+ incomeDetail.getDeptId() + CommonConstants.DOWN_LINE_STRING + incomeDetail.getFeeType()
+ CommonConstants.DOWN_LINE_STRING + incomeDetail.getSourceType());
if (Common.isEmpty(value)) {
value = CommonConstants.ZERO_INT;
}
if (CommonConstants.ZERO_STRING.equals(incomeDetail.getRedData())) {
value++;
} else {
value--;
}
detailMap.put(incomeDetail.getEmpIdcard() + CommonConstants.DOWN_LINE_STRING
+ incomeDetail.getDeptId() + CommonConstants.DOWN_LINE_STRING
+ incomeDetail.getFeeType() + CommonConstants.DOWN_LINE_STRING
+ incomeDetail.getSourceType(), value);
}
}
} else {
return R.failed("获取收入明细的详情出错,请联系管理员!");
}
return null;
}
/**
* @param feeType 1按比例2金额-人数3金额-人次
* @param isManage 1 管理费2 风险金
* @Description: 保存明细
* @Author: hgw
* @Date: 2022/9/2 17:25
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.String>
**/
private R<String> saveIncomeDetail(List<TSalaryAccount> salaryAccountList, TSalaryStandard tSalaryStandard
, TSettleDomainSelectVo dept, Map<String, Integer> detailMap, String feeType, String isManage) {
TIncomeDetail detail;
Integer value;
BigDecimal money;
for (TSalaryAccount account : salaryAccountList) {
value = detailMap.get(account.getEmpIdcard() + CommonConstants.DOWN_LINE_STRING
+ account.getDeptId() + CommonConstants.DOWN_LINE_STRING + isManage
+ CommonConstants.DOWN_LINE_STRING
+ CommonConstants.FOUR_STRING);
if (Common.isEmpty(value) || value == 0) {
detail = new TIncomeDetail();
detail.setPayMonth(account.getSalaryMonth());
detail.setDeptId(account.getDeptId());
detail.setDeptName(account.getDeptName());
detail.setDeptNo(account.getDeptNo());
detail.setUnitId(tSalaryStandard.getUnitId());
detail.setUnitName(tSalaryStandard.getUnitName());
detail.setUnitNo(tSalaryStandard.getUnitNo());
detail.setCreateMonth(account.getSalaryMonth());
detail.setEmpIdcard(account.getEmpIdcard());
detail.setEmpName(account.getEmpName());
detail.setFeeMode(dept.getManagementType());
detail.setFeeType(isManage);
detail.setCharges(String.valueOf(dept.getManagementFee()));
money = dept.getManagementFee();
if (CommonConstants.TWO_STRING.equals(isManage)) {
money = dept.getRiskFundFee();
detail.setCharges(String.valueOf(dept.getRiskFundFee()));
detail.setFeeMode(dept.getRiskFundType());
}
if (CommonConstants.ONE_STRING.equals(feeType)) {
money = BigDecimalUtils.safeMultiply(account.getRelaySalary(), money, CommonConstants.ONE_OF_PERCENT);
}
detail.setMoney(money);
detail.setMrSettleType(dept.getMrSettleType());
detail.setRedData(CommonConstants.ZERO_STRING);
detail.setSourceId(account.getId());
detail.setSourceType(CommonConstants.FOUR_STRING);
detail.setApplyNo(tSalaryStandard.getApplyNo());
R<Boolean> saveR = HttpDaprUtil.invokeMethodPost(socialProperties.getAppUrl(), socialProperties.getAppId()
, "/tincome/inner/saveDetail", detail, Boolean.class, SecurityConstants.FROM_IN);
if (saveR == null || saveR.getCode() == CommonConstants.ONE_INT || Boolean.FALSE.equals(saveR.getData())) {
return R.failed("保存收入明细以及统计出错!");
}
}
}
return null;
}
/**
* @Description: 删除
* @Author: hgw
......@@ -973,7 +820,52 @@ public class TSalaryStandardServiceImpl extends ServiceImpl<TSalaryStandardMappe
}
}
return R.failed("未找到工资表");
}
/**
* @param id
* @Description: 重新生成收入
* @Author: hgw
* @Date: 2022/11/29 17:58
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.String>
**/
@Override
public R<String> salaryDoIncome(String id) {
TSalaryStandard tSalaryStandard = this.getById(id);
if (tSalaryStandard != null
&& (tSalaryStandard.getStatus() == CommonConstants.dingleDigitIntArray[11]
|| tSalaryStandard.getStatus() == CommonConstants.dingleDigitIntArray[12])
&& tSalaryStandard.getIncomeStartTime() != null) {
if (tSalaryStandard.getStatus() == CommonConstants.dingleDigitIntArray[11]) {
long start = tSalaryStandard.getIncomeStartTime().getTime() + 1800000;
long end = new Date().getTime();
if (start > end) {
return R.failed("上次生成时间:" + tSalaryStandard.getIncomeStartTime() + ",请稍等30分钟");
}
}
R<TSettleDomainSelectVo> sdr = HttpDaprUtil.invokeMethodPost(archivesProperties.getAppUrl(), archivesProperties.getAppId()
, "/tsettledomain/inner/getSettleDomainVoById", tSalaryStandard.getDeptId()
, TSettleDomainSelectVo.class, SecurityConstants.FROM_IN);
// 结算主体
TSettleDomainSelectVo dept;
if (sdr != null && sdr.getData() != null) {
dept = sdr.getData();
} else {
return R.failed("获取项目信息失败,请联管理员!");
}
List<TSalaryAccount> salaryAccountList = salaryAccountService.getListByIncome(id);
if (salaryAccountList != null && !salaryAccountList.isEmpty()) {
// 将重置生成推送时间
tSalaryStandard.setIncomeStartTime(new Date());
tSalaryStandard.setIncomeEndTime(null);
this.updateById(tSalaryStandard);
// 异步-收入相关
doSalaryAsync.doIncomeDetail(dept, salaryAccountList, id, tSalaryStandard);
return R.ok("生成收入并推送中,请耐心等待30分钟!");
}
return R.failed("未获取到报账明细,请重试");
} else {
return R.failed("请耐心等待!");
}
}
}
package com.yifu.cloud.plus.v1.yifu.salary.util;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TSettleDomainSelectVo;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.SecurityConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.BigDecimalUtils;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.dapr.config.DaprSocialProperties;
import com.yifu.cloud.plus.v1.yifu.common.dapr.util.HttpDaprUtil;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryAccount;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryStandard;
import com.yifu.cloud.plus.v1.yifu.salary.mapper.TSalaryStandardMapper;
import com.yifu.cloud.plus.v1.yifu.salary.service.TSalaryStandardService;
import com.yifu.cloud.plus.v1.yifu.social.entity.TIncomeDetail;
import com.yifu.cloud.plus.v1.yifu.social.vo.TIncomeDetailReturnVo;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.util.*;
/**
* @author hgw
* @Date 2022-11-29 16:31:09
* @Description 异步执行薪资
*/
@Slf4j
@Component
@AllArgsConstructor
@EnableConfigurationProperties({DaprSocialProperties.class})
public class DoJointSalaryAsyncTask {
private final DaprSocialProperties socialProperties;
private final TSalaryStandardMapper salaryStandardMapper;
/**
* @Description: 收入
* @Author: hgw
* @Date: 2022-11-29 17:28:494
**/
@Async
public void doIncomeDetail(TSettleDomainSelectVo dept, List<TSalaryAccount> salaryAccountList, String id, TSalaryStandard tSalaryStandard) {
log.info("推送收入到EKP-线程开始");
if (salaryAccountList != null && !salaryAccountList.isEmpty()) {
List<String> idCardList = new ArrayList<>();
for (TSalaryAccount account : salaryAccountList) {
idCardList.add(account.getEmpIdcard());
}
Map<String, Integer> detailMap = new HashMap<>();
boolean isTrue = true;
TSalaryStandard s = salaryStandardMapper.selectById(id);
try {
// 收入相关
R<String> failed1 = getIncomeDetailMap(tSalaryStandard, dept, idCardList, detailMap);
if (failed1 != null) {
isTrue = false;
} else {
// 含有薪资,则计算收入
// 管理费
if (Common.isNotNull(dept.getManageServerItem()) && dept.getManageServerItem().contains(CommonConstants.FOUR_STRING)
&& CommonConstants.ZERO_STRING.equals(dept.getManagementTag())) {
// 金额-人数
if (CommonConstants.TWO_STRING.equals(dept.getManagementType())) {
// 保存明细
isTrue = saveIncomeDetail(salaryAccountList, tSalaryStandard, dept, detailMap, dept.getManagementType(), CommonConstants.ONE_STRING);
} else {
// 保存明细
isTrue = saveIncomeDetail(salaryAccountList, tSalaryStandard, dept, new HashMap<>(), dept.getManagementType(), CommonConstants.ONE_STRING);
}
}
// 风险金
if (isTrue && Common.isNotNull(dept.getRiskServerItem()) && dept.getRiskServerItem().contains(CommonConstants.FOUR_STRING)
&& CommonConstants.ZERO_STRING.equals(dept.getRiskFundTag())) {
// 金额-人数
if (CommonConstants.TWO_STRING.equals(dept.getRiskFundType())) {
// 保存明细
isTrue = saveIncomeDetail(salaryAccountList, tSalaryStandard, dept, detailMap, dept.getRiskFundType(), CommonConstants.TWO_STRING);
} else {
// 保存明细
isTrue = saveIncomeDetail(salaryAccountList, tSalaryStandard, dept, new HashMap<>(), dept.getRiskFundType(), CommonConstants.TWO_STRING);
}
}
}
} catch (Exception e) {
isTrue = false;
log.error(e.getMessage());
}
if (s != null
&& (s.getStatus() == CommonConstants.dingleDigitIntArray[11]
|| s.getStatus() == CommonConstants.dingleDigitIntArray[12])) {
tSalaryStandard.setIncomeEndTime(new Date());
if (isTrue) {
s.setStatus(CommonConstants.TWO_INT);
salaryStandardMapper.updateById(s);
} else {
s.setStatus(CommonConstants.dingleDigitIntArray[12]);
salaryStandardMapper.updateById(s);
}
}
}
log.info("推送收入到EKP结束");
}
/**
* @Description: 获取收入信息
* @Author: hgw
* @Date: 2022/9/6 10:39
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.String>
**/
private R<String> getIncomeDetailMap(TSalaryStandard tSalaryStandard, TSettleDomainSelectVo dept, List<String> idCardList, Map<String, Integer> detailMap) {
TIncomeDetail detail = new TIncomeDetail();
detail.setApplyNo(tSalaryStandard.getApplyNo());
detail.setPayMonth(tSalaryStandard.getSalaryMonth());
detail.setIdCardList(idCardList);
detail.setDeptId(dept.getId());
R<TIncomeDetailReturnVo> detailR = HttpDaprUtil.invokeMethodPost(socialProperties.getAppUrl(), socialProperties.getAppId()
, "/tincomedetail/inner/getTIncomeDetailList", detail
, TIncomeDetailReturnVo.class, SecurityConstants.FROM_IN);
Integer value;
if (detailR != null) {
if (detailR.getData() != null && detailR.getData().getDetailList() != null && !detailR.getData().getDetailList().isEmpty()) {
TIncomeDetailReturnVo vo = detailR.getData();
List<TIncomeDetail> detailList = vo.getDetailList();
for (TIncomeDetail incomeDetail : detailList) {
value = detailMap.get(incomeDetail.getEmpIdcard() + CommonConstants.DOWN_LINE_STRING
+ incomeDetail.getDeptId() + CommonConstants.DOWN_LINE_STRING + incomeDetail.getFeeType()
+ CommonConstants.DOWN_LINE_STRING + incomeDetail.getSourceType());
if (Common.isEmpty(value)) {
value = CommonConstants.ZERO_INT;
}
if (CommonConstants.ZERO_STRING.equals(incomeDetail.getRedData())) {
value++;
} else {
value--;
}
detailMap.put(incomeDetail.getEmpIdcard() + CommonConstants.DOWN_LINE_STRING
+ incomeDetail.getDeptId() + CommonConstants.DOWN_LINE_STRING
+ incomeDetail.getFeeType() + CommonConstants.DOWN_LINE_STRING
+ incomeDetail.getSourceType(), value);
}
}
} else {
return R.failed("获取收入明细的详情出错,请联系管理员!");
}
return null;
}
/**
* @param feeType 1按比例2金额-人数3金额-人次
* @param isManage 1 管理费2 风险金
* @Description: 保存明细
* @Author: hgw
* @Date: 2022/9/2 17:25
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.String>
**/
private boolean saveIncomeDetail(List<TSalaryAccount> salaryAccountList, TSalaryStandard tSalaryStandard
, TSettleDomainSelectVo dept, Map<String, Integer> detailMap, String feeType, String isManage) {
TIncomeDetail detail;
Integer value;
BigDecimal money;
for (TSalaryAccount account : salaryAccountList) {
value = detailMap.get(account.getEmpIdcard() + CommonConstants.DOWN_LINE_STRING
+ account.getDeptId() + CommonConstants.DOWN_LINE_STRING + isManage
+ CommonConstants.DOWN_LINE_STRING
+ CommonConstants.FOUR_STRING);
if (Common.isEmpty(value) || value == 0) {
detail = new TIncomeDetail();
detail.setPayMonth(account.getSalaryMonth());
detail.setDeptId(account.getDeptId());
detail.setDeptName(account.getDeptName());
detail.setDeptNo(account.getDeptNo());
detail.setUnitId(tSalaryStandard.getUnitId());
detail.setUnitName(tSalaryStandard.getUnitName());
detail.setUnitNo(tSalaryStandard.getUnitNo());
detail.setCreateMonth(account.getSalaryMonth());
detail.setEmpIdcard(account.getEmpIdcard());
detail.setEmpName(account.getEmpName());
detail.setFeeMode(dept.getManagementType());
detail.setFeeType(isManage);
detail.setCharges(String.valueOf(dept.getManagementFee()));
money = dept.getManagementFee();
if (CommonConstants.TWO_STRING.equals(isManage)) {
money = dept.getRiskFundFee();
detail.setCharges(String.valueOf(dept.getRiskFundFee()));
detail.setFeeMode(dept.getRiskFundType());
}
if (CommonConstants.ONE_STRING.equals(feeType)) {
money = BigDecimalUtils.safeMultiply(account.getRelaySalary(), money, CommonConstants.ONE_OF_PERCENT);
}
detail.setMoney(money);
detail.setMrSettleType(dept.getMrSettleType());
detail.setRedData(CommonConstants.ZERO_STRING);
detail.setSourceId(account.getId());
detail.setSourceType(CommonConstants.FOUR_STRING);
detail.setApplyNo(tSalaryStandard.getApplyNo());
R<Boolean> saveR = HttpDaprUtil.invokeMethodPost(socialProperties.getAppUrl(), socialProperties.getAppId()
, "/tincome/inner/saveSalaryDetail", detail, Boolean.class, SecurityConstants.FROM_IN);
if (saveR == null || saveR.getCode() == CommonConstants.ONE_INT || Boolean.FALSE.equals(saveR.getData())) {
return false;
}
}
}
return true;
}
}
......@@ -75,6 +75,8 @@
<result property="orderId" column="ORDER_ID"/>
<result property="bpoFlag" column="BPO_FLAG"/>
<result property="applyNo" column="APPLY_NO"/>
<result property="incomeStartTime" column="INCOME_START_TIME"/>
<result property="incomeEndTime" column="INCOME_END_TIME"/>
</resultMap>
<sql id="Base_Column_List">
a.ID,
......@@ -128,7 +130,9 @@
a.INVOICE_TITLE,
a.ORDER_ID,
a.BPO_FLAG,
a.APPLY_NO
a.APPLY_NO,
a.INCOME_START_TIME,
a.INCOME_END_TIME
</sql>
<sql id="tSalaryStandard_where">
<if test="tSalaryStandard != null">
......
......@@ -168,7 +168,19 @@ public class TIncomeController {
@Inner
@PostMapping("/inner/saveDetail")
public Boolean saveDetail(@RequestBody TIncomeDetail tIncomeDetail) {
return tIncomeService.saveDetail(tIncomeDetail);
return tIncomeService.saveDetail(tIncomeDetail,true);
}
/**
* @Description: 薪资新增收入明细-详情表,同时统计;采用同步操作,因为薪资本身就是异步
* @Author: hgw
* @Date: 2022-11-29 17:29:29
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.Boolean>
**/
@Inner
@PostMapping("/inner/saveSalaryDetail")
public Boolean saveSalaryDetail(@RequestBody TIncomeDetail tIncomeDetail) {
return tIncomeService.saveDetail(tIncomeDetail,false);
}
/**
......
......@@ -128,8 +128,8 @@ public interface TForecastLibraryService extends IService<TForecastLibrary> {
void createForecastInfo();
void createForecastFundInfo();
void pushForecastInfo(List<TForecastLibrary> library);
void pushForecastInfo(List<TForecastLibrary> library, boolean synFlag);
void pushForecastFundInfo(List<TForecastLibrary> library);
void pushForecastFundInfo(List<TForecastLibrary> library, boolean synFlag);
}
......@@ -58,7 +58,7 @@ public interface TIncomeService extends IService<TIncome> {
* @Date: 2022/8/31 16:31
* @return: boolean
**/
boolean saveDetail(TIncomeDetail tIncomeDetail);
boolean saveDetail(TIncomeDetail tIncomeDetail,boolean synFlag);
/**
* @Description: 新增收入明细-详情表,同时统计;
......
......@@ -53,6 +53,7 @@ import com.yifu.cloud.plus.v1.yifu.social.service.TDispatchInfoService;
import com.yifu.cloud.plus.v1.yifu.social.service.TForecastLibraryService;
import com.yifu.cloud.plus.v1.yifu.social.service.TIncomeDetailService;
import com.yifu.cloud.plus.v1.yifu.social.service.TIncomeService;
import com.yifu.cloud.plus.v1.yifu.social.util.DoSocialTask;
import com.yifu.cloud.plus.v1.yifu.social.util.ServiceUtil;
import com.yifu.cloud.plus.v1.yifu.social.vo.*;
import lombok.RequiredArgsConstructor;
......@@ -64,6 +65,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.cache.support.SimpleValueWrapper;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -117,6 +119,10 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
ExcelUtil<Object> excelUtil = new ExcelUtil<>(Object.class);
@Autowired
private DoSocialTask socialTask;
/**
* 派单信息记录表简单分页查询
*
......@@ -679,7 +685,7 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
}
// 生成预付数据
if (Common.isNotNull(socialFund) && Common.isNotNull(socialFund.getId())){
forecastLibraryService.updateForecastLibaryByDispatch(socialFund);
socialTask.asynchronousDisPatchHandle(socialFund, 0,null,null,CommonConstants.ONE_INT);
}
// 同步更新人员档案和项目档案的社保公积金状态
updateDocSocialFund(social, fund, socialFund,excel);
......@@ -3126,7 +3132,7 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
&& CommonConstants.ONE_INT == flag){
// 更新预估数据 -- 失败项重新派单审核不通过不处理预估
if (!flagTemp){
forecastLibraryService.updateForecastLibaryByDispatchReduce(sf, forecastFlag);
socialTask.asynchronousDisPatchHandle(sf, forecastFlag,null,null,CommonConstants.ZERO_INT);
}
// 更新人员档案和项目档案的社保公积金状态
UpProjectSocialFundVo vo = new UpProjectSocialFundVo();
......@@ -3386,13 +3392,13 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
if (Common.isNotNull(libraryFundInfoList)) {
for (TForecastLibrary library :libraryFundInfoList) {
//办理成功生成收入
createIncomeInfo(library);
socialTask.asynchronousDisPatchHandle(null,0,null,library,CommonConstants.THREE_INT);
if (CommonConstants.ZERO_INT == library.getDataPush()) {
libraryFundInfoList1.add(library);
}
}
if (Common.isNotNull(libraryFundInfoList1)) {
forecastLibraryService.pushForecastFundInfo(libraryFundInfoList1);
socialTask.asynchronousDisPatchHandle(null,0,libraryFundInfoList1,null,CommonConstants.TWO_INT);
}
}
}
......@@ -3571,21 +3577,21 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
&& (CommonConstants.FIVE_STRING.equals(sf.getSocialStatus())
|| CommonConstants.FOUR_STRING.equals(sf.getFundStatus()))){
// 派增办理,全部失败 同步预估库数据
forecastLibraryService.updateForecastLibaryByDispatchReduce(sf, forecastFlag);
socialTask.asynchronousDisPatchHandle(sf, forecastFlag,null,null,CommonConstants.ZERO_INT);
}
// 社保办理只要办理成功就刷新预估数据 公积金办理不用处理
if (Common.isNotNull(dis.getSocialId())
&& CommonConstants.FOUR_STRING.equals(sf.getSocialStatus())
|| CommonConstants.TWO_STRING.equals(sf.getSocialStatus())
|| CommonConstants.THREE_STRING.equals(sf.getSocialStatus())){
forecastLibraryService.updateForecastLibaryByDispatch(sf);
socialTask.asynchronousDisPatchHandle(sf, 0,null,null,CommonConstants.ONE_INT);
}
}
// 2.派减办理成功 处理预估 (不管社保还是公积金办理失败)
if (CommonConstants.ONE_STRING.equals(dis.getType())
&& CommonConstants.ZERO_INT == flag){
// 同步预估库数据
forecastLibraryService.updateForecastLibaryByDispatchReduce(sf, forecastFlag);
socialTask.asynchronousDisPatchHandle(sf, forecastFlag,null,null,CommonConstants.ZERO_INT);
}
// 派减办理失败不同步档案的相关字段信息
if (!(CommonConstants.ONE_STRING.equals(dis.getType()) && CommonConstants.ONE_INT == flag)){
......@@ -4251,90 +4257,4 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
}
return minStartDate;
}
public void createIncomeInfo(TForecastLibrary library) {
//获取项目信息
TSettleDomain settleDomain = new TSettleDomain();
List<TSettleDomainSelectVo> settleDomainR = null;
R<TSettleDomainListVo> listVo = null;
listVo = archivesDaprUtil.selectSettleDomainSelectVoById(library.getSettleDomainId());
if (Common.isNotNull(listVo)) {
TSettleDomainListVo tSettleDomainListVo = listVo.getData();
if (Common.isNotNull(tSettleDomainListVo) && Common.isNotEmpty(tSettleDomainListVo.getListSelectVO())) {
settleDomainR = tSettleDomainListVo.getListSelectVO();
for (TSettleDomainSelectVo vo :settleDomainR) {
BeanUtils.copyProperties(vo,settleDomain);
}
}
}
//判断是否存在当月的公积金收入数据
boolean isExist = false;
TIncomeDetail incomeDetail = new TIncomeDetail();
incomeDetail.setEmpIdcard(library.getEmpIdcard());
incomeDetail.setPayMonth(library.getProvidentPayMonth());
incomeDetail.setDeptNo(library.getDeptNo());
incomeDetail.setSourceType(CommonConstants.TWO_STRING);
List<TIncomeDetail> detailList = detailService.getTIncomeDetailList(incomeDetail);
if (Common.isNotNull(detailList)) {
BigDecimal sumMoney = BigDecimal.ZERO;
for (TIncomeDetail income : detailList) {
sumMoney = BigDecimalUtils.safeAdd(income.getMoney(),sumMoney);
}
if (sumMoney.compareTo(BigDecimal.ZERO) > 0) {
isExist = true;
}
}
if (Common.isNotNull(settleDomain)) {
// 含有社保,则计算收入
if (Common.isNotNull(settleDomain.getManageServerItem()) && settleDomain.getManageServerItem()
.contains(CommonConstants.TWO_STRING) && !isExist &&
CommonConstants.ZERO_STRING.equals(settleDomain.getManagementTag()) &&
CommonConstants.ONE_STRING.equals(settleDomain.getMrSettleType())) {
//预估模式
//预估模式只有按人次和人数收费
createIncomeInsurance(library, settleDomain, CommonConstants.ONE_STRING,
settleDomain.getManagementFee().toString(), settleDomain.getManagementType(),
settleDomain.getManagementFee());
}
if (Common.isNotNull(settleDomain.getRiskServerItem()) && settleDomain.getRiskServerItem()
.contains(CommonConstants.TWO_STRING) && !isExist &&
CommonConstants.ZERO_STRING.equals(settleDomain.getRiskFundTag()) &&
CommonConstants.ONE_STRING.equals(settleDomain.getMrSettleType())) {
//预估模式
createIncomeInsurance(library, settleDomain, CommonConstants.TWO_STRING,
settleDomain.getRiskFundFee().toString(), settleDomain.getRiskFundType(),
settleDomain.getRiskFundFee());
}
}
}
public void createIncomeInsurance(TForecastLibrary library, TSettleDomain settleDomain, String feeType,
String charges, String feeMode, BigDecimal money) {
//生成收入数据
TIncomeDetail detail = new TIncomeDetail();
detail.setCreateTime(DateUtil.getCurrentDateTime());
detail.setDeptName(settleDomain.getDepartName());
detail.setDeptNo(settleDomain.getDepartNo());
detail.setDeptId(settleDomain.getId());
detail.setEmpIdcard(library.getEmpIdcard());
detail.setEmpName(library.getEmpName());
detail.setUnitNo(settleDomain.getCustomerNo());
detail.setUnitId(settleDomain.getCustomerId());
detail.setUnitName(settleDomain.getCustomerName());
detail.setDataCreateMonth(DateUtil.addMonth(0));
detail.setSourceId(library.getId());
detail.setSourceType(CommonConstants.TWO_STRING);
detail.setCreateMonth(library.getProvidentCreateMonth());
detail.setPayMonth(library.getProvidentPayMonth());
detail.setMoney(money);
detail.setFeeType(feeType);
detail.setFeeMode(feeMode);
detail.setCharges(charges);
detail.setMrSettleType(settleDomain.getMrSettleType());
detail.setRedData(CommonConstants.ZERO_STRING);
detail.setId(CommonConstants.NULL);
incomeService.saveDetail(detail);
}
}
......@@ -352,7 +352,7 @@ public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMap
&& CommonConstants.FOUR_STRING.equals(socialFundInfo.getSocialStatus())
|| CommonConstants.THREE_STRING.equals(socialFundInfo.getSocialStatus()))) {
//办理成功生成收入
createIncomeInfo(library);
createIncomeInfo(library,true);
if (CommonConstants.ZERO_INT == library.getDataPush()) {
libraryFundInfoListSocial.add(library);
}
......@@ -365,7 +365,7 @@ public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMap
if (Common.isNotNull(socialFundInfoF) && (Common.isNotNull(socialFundInfoF.getFundId())
&& CommonConstants.THREE_STRING.equals(socialFundInfoF.getFundStatus()))) {
//办理成功生成收入
createIncomeInfo(library);
createIncomeInfo(library,true);
if (CommonConstants.ZERO_INT == library.getDataPush()) {
libraryFundInfoListFund.add(library);
}
......@@ -373,11 +373,11 @@ public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMap
}
//推送社保明细
if (Common.isNotNull(libraryFundInfoListSocial)) {
pushForecastInfo(libraryFundInfoListSocial);
pushForecastInfo(libraryFundInfoListSocial,true);
}
//推送公积金明细
if (Common.isNotNull(libraryFundInfoListFund)) {
pushForecastFundInfo(libraryFundInfoListFund);
pushForecastFundInfo(libraryFundInfoListFund,true);
}
if (isSaveAndUpdate) {
return R.ok(null, "执行成功!");
......@@ -1482,7 +1482,7 @@ public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMap
sysBaseSetInfoMapper.updateById(sysBaseSetInfo);
}
for (TSocialFundInfo socialFundInfo : socialFundInfoMap.values()) {
this.updateForecastLibaryCore(socialFundInfo, socialFundInfo.getDoMonth(), true, false);
this.updateForecastLibaryCore(socialFundInfo, socialFundInfo.getDoMonth(), true, false,true);
socialFundInfoMapper.updateById(socialFundInfo);
}
}
......@@ -1497,7 +1497,7 @@ public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMap
**/
@Override
public R<String> updateToneForecastLibary(TSocialFundInfo socialFundInfo, String doMonth) {
return this.updateForecastLibaryCore(socialFundInfo, doMonth, false, false);
return this.updateForecastLibaryCore(socialFundInfo, doMonth, false, false,true);
}
/**
......@@ -1509,7 +1509,7 @@ public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMap
**/
@Override
public R<String> updateForecastLibaryByDispatch(TSocialFundInfo socialFundInfo) {
return this.updateForecastLibaryCore(socialFundInfo, null, false, true);
return this.updateForecastLibaryCore(socialFundInfo, null, false, true,false);
}
/**
......@@ -1577,11 +1577,11 @@ public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMap
}
//推送社保明细
if (Common.isNotNull(libraryFundInfoListSocial)) {
pushForecastInfo(libraryFundInfoListSocial);
pushForecastInfo(libraryFundInfoListSocial,false);
}
//推送公积金明细
if (Common.isNotNull(libraryFundInfoListFund)) {
pushForecastFundInfo(libraryFundInfoListFund);
pushForecastFundInfo(libraryFundInfoListFund,false);
}
}
return R.ok();
......@@ -1632,7 +1632,7 @@ public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMap
detail.setId(CommonConstants.NULL);
detail.setRedData(CommonConstants.ONE_STRING);
detail.setMoney(detail.getMoney().negate());
incomeService.saveDetail(detail);
incomeService.saveDetail(detail,false);
}
}
}
......@@ -1672,7 +1672,7 @@ public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMap
detail.setId(CommonConstants.NULL);
detail.setRedData(CommonConstants.ONE_STRING);
detail.setMoney(detail.getMoney().negate());
incomeService.saveDetail(detail);
incomeService.saveDetail(detail,false);
}
}
}
......@@ -1686,7 +1686,7 @@ public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMap
* @Date: 2022/7/26 19:01
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.String>
**/
private R<String> updateForecastLibaryCore(TSocialFundInfo socialFundInfo, String doMonth, boolean isOnly, boolean isDispatch) {
private R<String> updateForecastLibaryCore(TSocialFundInfo socialFundInfo, String doMonth, boolean isOnly, boolean isDispatch,boolean synFlag) {
String empIdCard = socialFundInfo.getEmpIdcard();
//定义未推送的按条件查询得到的预估数据
List<TForecastLibrary> librarySocialList = null;
......@@ -1899,13 +1899,13 @@ public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMap
if (Common.isNotNull(librarySocialInfoList)) {
for (TForecastLibrary library : librarySocialInfoList) {
//办理成功生成收入
createIncomeInfo(library);
createIncomeInfo(library,synFlag);
if (CommonConstants.ZERO_INT == library.getDataPush()) {
librarySocialInfoList1.add(library);
}
}
if (Common.isNotNull(librarySocialInfoList1)) {
this.pushForecastInfo(librarySocialInfoList1);
this.pushForecastInfo(librarySocialInfoList1,synFlag);
}
}
}
......@@ -2244,7 +2244,7 @@ public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMap
if (Common.isNotNull(librarySocialInfoList)) {
for (TForecastLibrary library : librarySocialInfoList) {
//办理成功生成收入
createIncomeInfo(library);
createIncomeInfo(library,true);
if (CommonConstants.ZERO_INT == library.getDataPush()) {
libraryFundInfoListSocial.add(library);
}
......@@ -2266,7 +2266,7 @@ public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMap
if (Common.isNotNull(libraryFundInfoList)) {
for (TForecastLibrary library : libraryFundInfoList) {
//办理成功生成收入
createIncomeInfo(library);
createIncomeInfo(library,true);
if (CommonConstants.ZERO_INT == library.getDataPush()) {
libraryFundInfoListFund.add(library);
}
......@@ -2275,11 +2275,11 @@ public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMap
}
//推送社保明细
if (Common.isNotNull(libraryFundInfoListSocial)) {
pushForecastInfo(libraryFundInfoListSocial);
pushForecastInfo(libraryFundInfoListSocial,true);
}
//推送公积金明细
if (Common.isNotNull(libraryFundInfoListFund)) {
pushForecastFundInfo(libraryFundInfoListFund);
pushForecastFundInfo(libraryFundInfoListFund,true);
}
if (isSaveAndUpdate) {
return R.ok(null, "执行成功!");
......@@ -2343,7 +2343,7 @@ public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMap
.eq(TForecastLibrary::getDataType, CommonConstants.ZERO_INT));
if (Common.isNotNull(unPushInfo)) {
//推送数据封装并推送
initEkpPushSocialParam(unPushInfo);
initEkpPushSocialParam(unPushInfo,true);
}
}
......@@ -2355,27 +2355,27 @@ public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMap
.eq(TForecastLibrary::getDataType, CommonConstants.ONE_INT));
if (Common.isNotNull(unPushInfo)) {
//推送数据封装并推送
initEkpPushFundParam(unPushInfo);
initEkpPushFundParam(unPushInfo,true);
}
}
@Override
public void pushForecastInfo(List<TForecastLibrary> library) {
public void pushForecastInfo(List<TForecastLibrary> library, boolean synFlag) {
if (Common.isNotNull(library)) {
//推送数据封装并推送
initEkpPushSocialParam(library);
initEkpPushSocialParam(library,synFlag);
}
}
@Override
public void pushForecastFundInfo(List<TForecastLibrary> library) {
public void pushForecastFundInfo(List<TForecastLibrary> library,boolean synFlag) {
if (Common.isNotNull(library)) {
//推送数据封装并推送
initEkpPushFundParam(library);
initEkpPushFundParam(library,synFlag);
}
}
public void initEkpPushSocialParam(List<TForecastLibrary> unPushInfo) {
public void initEkpPushSocialParam(List<TForecastLibrary> unPushInfo, boolean synFlag) {
R<TSettleDomainListVo> listVo;
List<TSettleDomainSelectVo> settleDomainR;
for (TForecastLibrary library : unPushInfo) {
......@@ -2391,6 +2391,9 @@ public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMap
}
}
}
if (Common.isEmpty(listVo) || CommonConstants.SUCCESS != listVo.getCode()){
ServiceUtil.runTimeExceptionDiy("获取结算主体异常,请检查传参和档案服务状态!");
}
if (CommonConstants.ZERO_STRING.equals(settleDomain.getSocialType())) {
continue;
}
......@@ -2607,11 +2610,16 @@ public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMap
socialParam.setFd_3b0afbe1f94a08(library.getId());
// 薪酬申请编号
socialParam.setFd_3b3cab77923f44(CommonConstants.EMPTY_STRING);
doJointSocialTask.asynchronousEkpForecastSocial(socialParam, library);
// synFlag=true 异步推送 synFlag=false 非异步推送 兼容批量办理处理 fxj
if (synFlag){
doJointSocialTask.asynchronousEkpForecastSocial(socialParam, library);
}else {
doJointSocialTask.asynchronousEkpForecastSocialAsso(socialParam, library);
}
}
}
public void initEkpPushFundParam(List<TForecastLibrary> unPushInfo) {
public void initEkpPushFundParam(List<TForecastLibrary> unPushInfo,boolean synFlag) {
R<TSettleDomainListVo> listVo;
List<TSettleDomainSelectVo> settleDomainR;
for (TForecastLibrary library : unPushInfo) {
......@@ -2741,11 +2749,15 @@ public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMap
fundParam.setFd_3b0afbaf10df2c(library.getId());
// 薪酬申请编号
fundParam.setFd_3b3cabde83d1d0(CommonConstants.EMPTY_STRING);
doJointSocialTask.asynchronousEkpForecastFund(fundParam, library);
if (synFlag){
doJointSocialTask.asynchronousEkpForecastFund(fundParam, library);
}else {
doJointSocialTask.asynchronousEkpForecastFundAsso(fundParam, library);
}
}
}
public void createIncomeInfo(TForecastLibrary library) {
public void createIncomeInfo(TForecastLibrary library,boolean synFlag) {
//获取项目信息
TSettleDomain settleDomain = new TSettleDomain();
List<TSettleDomainSelectVo> settleDomainR;
......@@ -2800,7 +2812,7 @@ public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMap
CommonConstants.ONE_STRING.equals(settleDomain.getMrSettleType()) && !isExist) {
createIncomeInsurance(library, settleDomain, CommonConstants.ONE_STRING,
settleDomain.getManagementFee().toString(), settleDomain.getManagementType(),
settleDomain.getManagementFee(), sourceType);
settleDomain.getManagementFee(), sourceType,synFlag);
}
}
if (Common.isNotNull(settleDomain.getRiskServerItem()) && ((settleDomain.getRiskServerItem().contains(CommonConstants.ONE_STRING)
......@@ -2811,14 +2823,15 @@ public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMap
CommonConstants.ONE_STRING.equals(settleDomain.getMrSettleType()) && !isExist) {
createIncomeInsurance(library, settleDomain, CommonConstants.TWO_STRING,
settleDomain.getRiskFundFee().toString(), settleDomain.getRiskFundType(),
settleDomain.getRiskFundFee(), sourceType);
settleDomain.getRiskFundFee(), sourceType,synFlag);
}
}
}
}
public void createIncomeInsurance(TForecastLibrary library, TSettleDomain settleDomain, String feeType,
String charges, String feeMode, BigDecimal money, String sourceType) {
String charges, String feeMode, BigDecimal money, String sourceType
,boolean synFlag) {
//生成收入数据
TIncomeDetail detail = new TIncomeDetail();
detail.setCreateTime(DateUtil.getCurrentDateTime());
......@@ -2847,7 +2860,7 @@ public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMap
detail.setMrSettleType(settleDomain.getMrSettleType());
detail.setRedData(CommonConstants.ZERO_STRING);
detail.setId(CommonConstants.NULL);
incomeService.saveDetail(detail);
incomeService.saveDetail(detail,synFlag);
}
public String dateStringInsert(String month) {
......
......@@ -251,8 +251,7 @@ public class TIncomeServiceImpl extends ServiceImpl<TIncomeMapper, TIncome> impl
* @Date: 2022/8/31 16:34
* @return: boolean
**/
@Override
public boolean saveDetail(TIncomeDetail tIncomeDetail) {
public boolean saveDetail(TIncomeDetail tIncomeDetail,boolean synFlag) {
if (Common.isEmpty(tIncomeDetail.getEmpIdcard())
|| Common.isEmpty(tIncomeDetail.getDeptId())
|| Common.isEmpty(tIncomeDetail.getPayMonth())) {
......@@ -274,10 +273,10 @@ public class TIncomeServiceImpl extends ServiceImpl<TIncomeMapper, TIncome> impl
tIncomeDetailService.save(tIncomeDetail);
// 不存在,直接新增
if (incomeList == null || incomeList.isEmpty()) {
return this.saveIncome(tIncomeDetail);
return this.saveIncome(tIncomeDetail,synFlag);
} else {
// 核心判断
return this.copyCore(tIncomeDetail, incomeList, detailList,null);
return this.copyCore(tIncomeDetail, incomeList, detailList,null,synFlag);
}
}
......@@ -313,7 +312,7 @@ public class TIncomeServiceImpl extends ServiceImpl<TIncomeMapper, TIncome> impl
return this.savePaymentIncome(tIncomeDetail,paymentInfo);
} else {
// 核心判断
return this.copyCore(tIncomeDetail, incomeList, detailList,paymentInfo);
return this.copyCore(tIncomeDetail, incomeList, detailList,paymentInfo,true);
}
}
......@@ -401,14 +400,18 @@ public class TIncomeServiceImpl extends ServiceImpl<TIncomeMapper, TIncome> impl
}
// 复制并保存
private boolean saveIncome(TIncomeDetail tIncomeDetail) {
private boolean saveIncome(TIncomeDetail tIncomeDetail,boolean synFlag) {
TIncome income = new TIncome();
BeanUtil.copyProperties(tIncomeDetail, income);
income.setSendStatus(CommonConstants.ZERO_STRING);
income.setApplyNo(tIncomeDetail.getApplyNo());
this.save(income);
long start = System.currentTimeMillis();
doJointSocialTask.asynchronousEkpIncome(income);
if (synFlag){
doJointSocialTask.asynchronousEkpIncome(income);
}else {
doJointSocialTask.asynchronousEkpIncomeAsso(income);
}
log.error("线程执行耗时:"+ (System.currentTimeMillis()-start));
return true;
}
......@@ -571,13 +574,24 @@ public class TIncomeServiceImpl extends ServiceImpl<TIncomeMapper, TIncome> impl
* @return: boolean
**/
private boolean copyCore(TIncomeDetail tIncomeDetail, List<TIncome> incomeList, List<TIncomeDetail> detailList,
TPaymentInfo paymentInfo) {
TPaymentInfo paymentInfo,boolean synFlag) {
if (Common.isNotNull(tIncomeDetail.getSourceId())) {
// 如果该id、该类型的金额已存在,则不允许重复生成推送
TIncomeDetail a = new TIncomeDetail();
a.setSourceId(tIncomeDetail.getSourceId());
a.setMoney(tIncomeDetail.getMoney());
a.setRedData(tIncomeDetail.getRedData());
List<TIncomeDetail> aList = tIncomeDetailService.getTIncomeDetailList(a);
if (aList != null && !aList.isEmpty()) {
return true;
}
}
// 判断,比例,直接加
if (CommonConstants.ONE_STRING.equals(tIncomeDetail.getFeeMode())) {
if (Common.isNotNull(paymentInfo)) {
return this.savePaymentIncome(tIncomeDetail,paymentInfo);
} else {
return this.saveIncome(tIncomeDetail);
return this.saveIncome(tIncomeDetail,synFlag);
}
} else {
Map<String, Integer> numMap = new HashMap<>();
......@@ -633,7 +647,7 @@ public class TIncomeServiceImpl extends ServiceImpl<TIncomeMapper, TIncome> impl
if (Common.isNotNull(paymentInfo)) {
return this.savePaymentIncome(tIncomeDetail,paymentInfo);
} else {
return this.saveIncome(tIncomeDetail);
return this.saveIncome(tIncomeDetail,synFlag);
}
}
} else {
......@@ -642,7 +656,7 @@ public class TIncomeServiceImpl extends ServiceImpl<TIncomeMapper, TIncome> impl
if (Common.isNotNull(paymentInfo)) {
return this.savePaymentIncome(tIncomeDetail,paymentInfo);
} else {
return this.saveIncome(tIncomeDetail);
return this.saveIncome(tIncomeDetail,synFlag);
}
}
}
......@@ -655,7 +669,7 @@ public class TIncomeServiceImpl extends ServiceImpl<TIncomeMapper, TIncome> impl
if (Common.isNotNull(paymentInfo)) {
return this.savePaymentIncome(tIncomeDetail,paymentInfo);
} else {
return this.saveIncome(tIncomeDetail);
return this.saveIncome(tIncomeDetail,synFlag);
}
}
} else {
......@@ -663,13 +677,13 @@ public class TIncomeServiceImpl extends ServiceImpl<TIncomeMapper, TIncome> impl
if (Common.isNotNull(paymentInfo)) {
return this.savePaymentIncome(tIncomeDetail,paymentInfo);
} else {
return this.saveIncome(tIncomeDetail);
return this.saveIncome(tIncomeDetail,synFlag);
}
}
}
} else {
// 各个模式累加逻辑:
return this.judgeMixModel(tIncomeDetail, numMap, incomeMap);
return this.judgeMixModel(tIncomeDetail, numMap, incomeMap,synFlag);
}
} else {
// 薪资。收费方式:2金额-人数
......@@ -679,13 +693,13 @@ public class TIncomeServiceImpl extends ServiceImpl<TIncomeMapper, TIncome> impl
if (Common.isNotNull(paymentInfo)) {
return this.savePaymentIncome(tIncomeDetail,paymentInfo);
} else {
return this.saveIncome(tIncomeDetail);
return this.saveIncome(tIncomeDetail,synFlag);
}
}
} else {
// 3金额-人次
// 各个模式累加逻辑:
return this.judgeMixModel(tIncomeDetail, numMap, incomeMap);
return this.judgeMixModel(tIncomeDetail, numMap, incomeMap,synFlag);
}
}
}
......@@ -742,7 +756,7 @@ public class TIncomeServiceImpl extends ServiceImpl<TIncomeMapper, TIncome> impl
* @Date: 2022/9/1 18:17
* @return: boolean
**/
private boolean judgeMixModel(TIncomeDetail tIncomeDetail, Map<String, Integer> numMap, Map<String, Integer> incomeMap) {
private boolean judgeMixModel(TIncomeDetail tIncomeDetail, Map<String, Integer> numMap, Map<String, Integer> incomeMap,boolean synFlag) {
String month = tIncomeDetail.getPayMonth();
if (CommonConstants.THREE_STRING.equals(tIncomeDetail.getSourceType())) {
month = tIncomeDetail.getDataCreateMonth();
......@@ -753,11 +767,11 @@ public class TIncomeServiceImpl extends ServiceImpl<TIncomeMapper, TIncome> impl
Integer maxNum = incomeMap.get(month + CommonConstants.DOWN_LINE_STRING + tIncomeDetail.getFeeType());
// 当明细的次数大于总次数,才可以新增统计
if (Common.isEmpty(maxNum) || ifNullToZero(nums) >= maxNum) {
return this.saveIncome(tIncomeDetail);
return this.saveIncome(tIncomeDetail,synFlag);
}
} else {
// 红冲判断:当本类型是最大值,才可以红冲
if (this.redDateJudge(tIncomeDetail, numMap)) return this.saveIncome(tIncomeDetail);
if (this.redDateJudge(tIncomeDetail, numMap)) return this.saveIncome(tIncomeDetail,synFlag);
}
return true;
}
......
......@@ -102,6 +102,44 @@ public class DoJointSocialTask {
}
log.info("推送收入到EKP结束");
}
public void asynchronousEkpIncomeAsso(TIncome income) {
log.info("推送收入到EKP-线程开始");
try {
String sendBack = this.getSendBack(income);
if (Common.isEmpty(sendBack) || sendBack.length() != 32) {
sendBack = this.getSendBack(income);
}
income.setSendTime(new Date());
if (Common.isNotNull(sendBack) && sendBack.length() == 32) {
income.setSendStatus(CommonConstants.ONE_STRING);
income.setSendMonth(DateUtil.addMonth(0));
income.setEkpId(sendBack);
incomeMapper.updateById(income);
} 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: 合同-批量更换负责人
......@@ -401,6 +439,13 @@ public class DoJointSocialTask {
**/
@Async
public void asynchronousEkpForecastSocial(EkpPushSocialParam socialParam, TForecastLibrary library) {
ekpForecastSocial(socialParam, library);
}
public void asynchronousEkpForecastSocialAsso(EkpPushSocialParam socialParam, TForecastLibrary library) {
ekpForecastSocial(socialParam, library);
}
private void ekpForecastSocial(EkpPushSocialParam socialParam, TForecastLibrary library) {
log.info("推送社保预估费用到EKP-线程开始");
try {
String body = ekpSocialUtil.sendToEKP(socialParam);
......@@ -444,6 +489,11 @@ public class DoJointSocialTask {
**/
@Async
public void asynchronousEkpForecastFund(EkpPushFundParam fundParam, TForecastLibrary library) {
initEkpForecastFund(fundParam, library);
}
private void initEkpForecastFund(EkpPushFundParam fundParam, TForecastLibrary library) {
initEkpForecastFund(fundParam, library);
log.info("推送公积金预估费用到EKP-线程开始");
try {
String body = ekpFundUtil.sendToEKP(fundParam);
......@@ -478,4 +528,8 @@ public class DoJointSocialTask {
}
log.info("推送公积金预估费用到EKP结束");
}
public void asynchronousEkpForecastFundAsso(EkpPushFundParam fundParam, TForecastLibrary library) {
initEkpForecastFund(fundParam, library);
}
}
package com.yifu.cloud.plus.v1.yifu.social.util;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TSettleDomain;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TSettleDomainListVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TSettleDomainSelectVo;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.BigDecimalUtils;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.DateUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.dapr.util.ArchivesDaprUtil;
import com.yifu.cloud.plus.v1.yifu.social.entity.TForecastLibrary;
import com.yifu.cloud.plus.v1.yifu.social.entity.TIncomeDetail;
import com.yifu.cloud.plus.v1.yifu.social.entity.TSendEkpError;
import com.yifu.cloud.plus.v1.yifu.social.entity.TSocialFundInfo;
import com.yifu.cloud.plus.v1.yifu.social.mapper.TSendEkpErrorMapper;
import com.yifu.cloud.plus.v1.yifu.social.service.TForecastLibraryService;
import com.yifu.cloud.plus.v1.yifu.social.service.TIncomeDetailService;
import com.yifu.cloud.plus.v1.yifu.social.service.TIncomeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* @Author fxj
* @Date 2022/11/28
* @Description 批量办理异步处理
* @Version 1.0
*/
@Slf4j
@Component
public class DoSocialTask {
@Autowired
private TForecastLibraryService forecastLibraryService;
@Autowired
private TIncomeDetailService detailService;
@Autowired
private ArchivesDaprUtil archivesDaprUtil;
@Autowired
private TIncomeService incomeService;
@Autowired
private TSendEkpErrorMapper sendEkpErrorMapper;
/**
* @Author fxj
* @Description 异步处理相关信息
* @Date 11:23 2022/11/28
* @param type=0 updateForecastLibaryByDispatchReduce type=1 updateForecastLibaryByDispatch type=2 pushForecastFundInfo createIncomeInfo(library);
**/
@Async
public void asynchronousDisPatchHandle(TSocialFundInfo sf, int forecastFlag,List< TForecastLibrary > libs,TForecastLibrary library,int type) {
synchronized (this){
R<String> res;
String linkId = null;
try {
// 派单减少变更预估库-派减
if (type == CommonConstants.ZERO_INT){
linkId = sf.getId();
res = forecastLibraryService.updateForecastLibaryByDispatchReduce(sf, forecastFlag);
if (Common.isEmpty(res) || CommonConstants.SUCCESS != res.getCode()){
initSendError(library.getId(), res.getMsg(),"updateForecastLibaryByDispatchReduce:");
}
}
// 派单变更预估库
if (type == CommonConstants.ONE_INT){
linkId = sf.getId();
res = forecastLibraryService.updateForecastLibaryByDispatch(sf);
if (Common.isEmpty(res) || CommonConstants.SUCCESS != res.getCode()){
initSendError(sf.getId(), res.getMsg(),"updateForecastLibaryByDispatch:");
}
}
// 获取预估库数据并推送
if (type == CommonConstants.TWO_INT){
if (Common.isNotNull(libs)){
for (TForecastLibrary lib:libs){
if (Common.isEmpty(linkId)){
linkId = lib.getId();
}else {
linkId = linkId + CommonConstants.COMMA_CHAR + lib.getId();
}
}
}
forecastLibraryService.pushForecastFundInfo(libs,false);
}
// 获取预估库数据并推送
if (type == CommonConstants.THREE_INT){
linkId = library.getId();
createIncomeInfo(library);
}
}catch (Exception e){
initSendError(linkId, e.getMessage(),"asynchronousDisPatchHandle:");
}
}
}
private void initSendError(String linkId, String msg,String title) {
TSendEkpError error = new TSendEkpError();
error.setCreateTime(new Date());
error.setCreateDay(DateUtil.getThisDay());
error.setType(CommonConstants.TWO_STRING);
error.setCreateUserName("社保预估费用推送");
error.setLinkId(linkId);
error.setTitle(title+ msg);
error.setNums(CommonConstants.ONE_INT);
this.saveError(error);
log.error("推送社保预估费用到EKP错误", msg);
}
private boolean saveError(TSendEkpError tSendEkpError) {
// 类型、创建日不可为空
if (Common.isEmpty(tSendEkpError.getType()) || Common.isEmpty(tSendEkpError.getCreateDay())) {
return false;
}
TSendEkpError error = sendEkpErrorMapper.getByTitleTypeDay(tSendEkpError);
if (error == null) {
return sendEkpErrorMapper.insert(tSendEkpError) > 0;
} else {
if (Common.isEmpty(tSendEkpError.getNums())) {
tSendEkpError.setNums(CommonConstants.ONE_INT);
}
error.setNums(error.getNums() + tSendEkpError.getNums());
return sendEkpErrorMapper.updateById(error) >= 0;
}
}
public void createIncomeInfo(TForecastLibrary library) {
//获取项目信息
TSettleDomain settleDomain = new TSettleDomain();
List<TSettleDomainSelectVo> settleDomainR = null;
R<TSettleDomainListVo> listVo = null;
listVo = archivesDaprUtil.selectSettleDomainSelectVoById(library.getSettleDomainId());
if (Common.isNotNull(listVo)) {
TSettleDomainListVo tSettleDomainListVo = listVo.getData();
if (Common.isNotNull(tSettleDomainListVo) && Common.isNotEmpty(tSettleDomainListVo.getListSelectVO())) {
settleDomainR = tSettleDomainListVo.getListSelectVO();
for (TSettleDomainSelectVo vo :settleDomainR) {
BeanUtils.copyProperties(vo,settleDomain);
}
}
}
//判断是否存在当月的公积金收入数据
boolean isExist = false;
TIncomeDetail incomeDetail = new TIncomeDetail();
incomeDetail.setEmpIdcard(library.getEmpIdcard());
incomeDetail.setPayMonth(library.getProvidentPayMonth());
incomeDetail.setDeptNo(library.getDeptNo());
incomeDetail.setSourceType(CommonConstants.TWO_STRING);
List<TIncomeDetail> detailList = detailService.getTIncomeDetailList(incomeDetail);
if (Common.isNotNull(detailList)) {
BigDecimal sumMoney = BigDecimal.ZERO;
for (TIncomeDetail income : detailList) {
sumMoney = BigDecimalUtils.safeAdd(income.getMoney(),sumMoney);
}
if (sumMoney.compareTo(BigDecimal.ZERO) > 0) {
isExist = true;
}
}
if (Common.isNotNull(settleDomain)) {
// 含有社保,则计算收入
if (Common.isNotNull(settleDomain.getManageServerItem()) && settleDomain.getManageServerItem()
.contains(CommonConstants.TWO_STRING) && !isExist &&
CommonConstants.ZERO_STRING.equals(settleDomain.getManagementTag()) &&
CommonConstants.ONE_STRING.equals(settleDomain.getMrSettleType())) {
//预估模式
//预估模式只有按人次和人数收费
createIncomeInsurance(library, settleDomain, CommonConstants.ONE_STRING,
settleDomain.getManagementFee().toString(), settleDomain.getManagementType(),
settleDomain.getManagementFee());
}
if (Common.isNotNull(settleDomain.getRiskServerItem()) && settleDomain.getRiskServerItem()
.contains(CommonConstants.TWO_STRING) && !isExist &&
CommonConstants.ZERO_STRING.equals(settleDomain.getRiskFundTag()) &&
CommonConstants.ONE_STRING.equals(settleDomain.getMrSettleType())) {
//预估模式
createIncomeInsurance(library, settleDomain, CommonConstants.TWO_STRING,
settleDomain.getRiskFundFee().toString(), settleDomain.getRiskFundType(),
settleDomain.getRiskFundFee());
}
}
}
public void createIncomeInsurance(TForecastLibrary library, TSettleDomain settleDomain, String feeType,
String charges, String feeMode, BigDecimal money) {
//生成收入数据
TIncomeDetail detail = new TIncomeDetail();
detail.setCreateTime(DateUtil.getCurrentDateTime());
detail.setDeptName(settleDomain.getDepartName());
detail.setDeptNo(settleDomain.getDepartNo());
detail.setDeptId(settleDomain.getId());
detail.setEmpIdcard(library.getEmpIdcard());
detail.setEmpName(library.getEmpName());
detail.setUnitNo(settleDomain.getCustomerNo());
detail.setUnitId(settleDomain.getCustomerId());
detail.setUnitName(settleDomain.getCustomerName());
detail.setDataCreateMonth(DateUtil.addMonth(0));
detail.setSourceId(library.getId());
detail.setSourceType(CommonConstants.TWO_STRING);
detail.setCreateMonth(library.getProvidentCreateMonth());
detail.setPayMonth(library.getProvidentPayMonth());
detail.setMoney(money);
detail.setFeeType(feeType);
detail.setFeeMode(feeMode);
detail.setCharges(charges);
detail.setMrSettleType(settleDomain.getMrSettleType());
detail.setRedData(CommonConstants.ZERO_STRING);
detail.setId(CommonConstants.NULL);
// 批量办理成功 收入不异步推送
incomeService.saveDetail(detail,false);
}
}
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