Commit 9472cf99 authored by huyuchen's avatar huyuchen

结算状态同步增加定时任务

parent d23f33b8
......@@ -2,6 +2,7 @@ package com.yifu.cloud.plus.v1.yifu.common.dapr.util;
import com.alibaba.fastjson.JSON;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.SecurityConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.dapr.config.DaprSalaryProperties;
import com.yifu.cloud.plus.v1.yifu.insurances.vo.EkpSocialViewVo;
import lombok.extern.log4j.Log4j2;
......@@ -29,7 +30,7 @@ public class SalaryDaprUtil {
* @Param
* @return
**/
public void updateSalarySettleStatus(List<EkpSocialViewVo> infoVo) {
HttpDaprUtil.invokeMethodPost(daprProperties.getAppUrl(),daprProperties.getAppId(),"/tincome/inner/updateSalarySettleStatus", JSON.toJSONString(infoVo), Object.class, SecurityConstants.FROM_IN);
public R<Boolean> updateSalarySettleStatus(List<EkpSocialViewVo> infoVo) {
return HttpDaprUtil.invokeMethodPost(daprProperties.getAppUrl(),daprProperties.getAppId(),"/tincome/inner/updateSalarySettleStatus", JSON.toJSONString(infoVo), Boolean.class, SecurityConstants.FROM_IN);
}
}
......@@ -143,8 +143,8 @@ public class SocialDaprUtils {
* @Param
* @return
**/
public void updateSocialSettleStatus(List<EkpSocialViewVo> infoVo) {
HttpDaprUtil.invokeMethodPost(daprProperties.getAppUrl(),daprProperties.getAppId(),"/tpaymentinfo/inner/updateSocialSettleStatus", JSON.toJSONString(infoVo), Object.class, SecurityConstants.FROM_IN);
public R<Boolean> updateSocialSettleStatus(List<EkpSocialViewVo> infoVo) {
return HttpDaprUtil.invokeMethodPost(daprProperties.getAppUrl(),daprProperties.getAppId(),"/tpaymentinfo/inner/updateSocialSettleStatus", JSON.toJSONString(infoVo), Boolean.class, SecurityConstants.FROM_IN);
}
/**
......@@ -154,7 +154,7 @@ public class SocialDaprUtils {
* @Param
* @return
**/
public void updateIncomeSettleStatus(List<EkpInsuranceViewVo> infoVo) {
HttpDaprUtil.invokeMethodPost(daprProperties.getAppUrl(),daprProperties.getAppId(),"/tincome/inner/updateIncomeSettleStatus", JSON.toJSONString(infoVo), Object.class, SecurityConstants.FROM_IN);
public R<Boolean> updateIncomeSettleStatus(List<EkpInsuranceViewVo> infoVo) {
return HttpDaprUtil.invokeMethodPost(daprProperties.getAppUrl(),daprProperties.getAppId(),"/tincome/inner/updateIncomeSettleStatus", JSON.toJSONString(infoVo), Boolean.class, SecurityConstants.FROM_IN);
}
}
......@@ -1291,4 +1291,9 @@ public class InsurancesConstants {
*/
public static final String HANDLE_PROVINCE_IS_NULL = "该记录的商险办理地为空";
/**
* 再次同步状态成功
*/
public static final String AGAIN_UPDATE_STATUS = "再次同步状态成功";
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.insurances.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* 同步结算状态的错误表
*
* @author huyc
* @date 2023-01-11 10:26:30
*/
@Data
@TableName("t_update_status_error")
@EqualsAndHashCode()
@Schema(description = "同步结算状态的错误表")
public class TUpdateStatusError {
/**
* 主键
*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description = "主键")
private String id;
/**
* 内容
*/
@Schema(description = "内容")
private String title;
/**
* 结算单号
*/
@Schema(description = "结算单号")
private String settleNo;
/**
* 结算单号类型 0 收入 1 支出
*/
@Schema(description = "结算单号类型 0 收入 1 支出")
private String settleType;
/**
* 结算单类型 0 社保 1公积金 2管理费 3风险金 4 商险 5 薪资
*/
@Schema(description = "结算单类型 0 社保 1公积金 2管理费 3风险金 4 商险 5 薪资")
private String typeFlag;
/**
* 创建人时间
*/
@Schema(description = "创建人时间")
private Date createTime;
/**
* 更新状态 0 未更新 1 已更新
*/
@Schema(description = "更新状态 0 未更新 1 已更新")
private Integer status;
}
......@@ -734,4 +734,18 @@ public class TInsuranceDetailController {
return tInsuranceDetailService.updateSalarySettleStatus(vo);
}
/**
* 重新更新结算状态同步失败的数据
*
* @author licancan
* @param
* @return void
*/
@SysLog("重新更新结算状态同步失败的数据")
@Inner
@PostMapping("/inner/updateSettleStatus")
public void updateSettleStatus() {
tInsuranceDetailService.updateSettleStatus();
}
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.insurances.mapper.insurances;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.insurances.entity.TUpdateStatusError;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* 同步结算状态的错误表
*
* @author huyc
* @date 2023-01-11 10:26:30
*/
@Mapper
public interface TUpdateStatusErrorMapper extends BaseMapper<TUpdateStatusError> {
/**
* 同步结算状态的错误表简单分页查询
* @param tUpdateStatusError 同步结算状态的错误表
* @return
*/
IPage<TUpdateStatusError> getTUpdateStatusErrorPage(Page<TUpdateStatusError> page, @Param("tUpdateStatusError") TUpdateStatusError tUpdateStatusError);
}
......@@ -501,4 +501,12 @@ public interface TInsuranceDetailService extends IService<TInsuranceDetail> {
* @return: R
**/
R updateSalarySettleStatus(EkpStatusParamVo vo);
/**
* @Description: 重新更新结算状态同步失败的数据
* @Author: huyc
* @Date: 2023/1/11 15:56
* @return:
**/
void updateSettleStatus();
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.insurances.service.insurance;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.yifu.insurances.entity.TUpdateStatusError;
/**
* 同步结算状态的错误表
*
* @author huyc
* @date 2023-01-11 10:26:30
*/
public interface TUpdateStatusErrorService extends IService<TUpdateStatusError> {
}
......@@ -28,6 +28,7 @@ import com.yifu.cloud.plus.v1.yifu.ekp.util.EkpInsuranceUtil;
import com.yifu.cloud.plus.v1.yifu.insurances.constants.InsurancesConstants;
import com.yifu.cloud.plus.v1.yifu.insurances.entity.*;
import com.yifu.cloud.plus.v1.yifu.insurances.mapper.insurances.TInsuranceDetailMapper;
import com.yifu.cloud.plus.v1.yifu.insurances.mapper.insurances.TUpdateStatusErrorMapper;
import com.yifu.cloud.plus.v1.yifu.insurances.service.TInsuranceAreaResService;
import com.yifu.cloud.plus.v1.yifu.insurances.service.ekp.EkpSettleService;
import com.yifu.cloud.plus.v1.yifu.insurances.service.insurance.*;
......@@ -123,6 +124,8 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
private TBusinessOperateService tBusinessOperateService;
@Resource
private TInsuranceAreaResService tInsuranceAreaResService;
@Resource
private TUpdateStatusErrorMapper updateStatusErrorMapper;
/***********************商险办理********************************/
/**
* 每日定时刷新商险到期数据
......@@ -7260,12 +7263,7 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
if (Common.isEmpty(vo)) {
return R.failed(CommonConstants.PARAM_IS_NOT_ERROR);
}
try {
doJointInsuranceTask.updateSocialSettleStatus(vo);
}catch (Exception e) {
log.error("社保结算状态更新异常", e);
return R.failed("社保结算状态更新异常");
}
doJointInsuranceTask.updateSocialSettleStatus(vo);
return R.ok(); }
@Override
......@@ -7273,12 +7271,7 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
if (Common.isEmpty(vo)) {
return R.failed(CommonConstants.PARAM_IS_NOT_ERROR);
}
try {
doJointInsuranceTask.updateIncomeSettleStatus(vo);
}catch (Exception e) {
log.error("收入结算状态更新异常", e);
return R.failed("收入结算状态更新异常");
}
doJointInsuranceTask.updateIncomeSettleStatus(vo);
return R.ok(); }
......@@ -7295,6 +7288,46 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
}
return R.ok(); }
@Override
public void updateSettleStatus() {
//获取所有结算状态同步失败的数据
long count = updateStatusErrorMapper.selectCount(Wrappers.<TUpdateStatusError>query().lambda()
.eq(TUpdateStatusError::getStatus,CommonConstants.ZERO_INT));
if (count > 0) {
List<TUpdateStatusError> list;
int i = (int) Math.ceil((double) count / CommonConstants.TEN_THOUSAND_INT);
for (int j = 0; j < i; j++) {
//判断缴费库中社保合计和本次导入合计相加是否为0,为0则不生成收入
list = updateStatusErrorMapper.selectList(Wrappers.<TUpdateStatusError>query().lambda()
.eq(TUpdateStatusError::getStatus,CommonConstants.ZERO_INT).last(" limit 0,10000"));
synchronized (this) {
if (Common.isNotNull(list)) {
for (TUpdateStatusError t: list) {
//更新商险结算状态
if (CommonConstants.FOUR_STRING.equals(t.getTypeFlag())) {
doJointInsuranceTask.aUpdateInsuranceSettleStatus(t);
}
//更新社保结算状态
if (CommonConstants.ONE_STRING.equals(t.getTypeFlag()) ||
CommonConstants.ZERO_STRING.equals(t.getTypeFlag())) {
doJointInsuranceTask.aUpdateSocialSettleStatus(t);
}
//更新收入结算状态
if (CommonConstants.TWO_STRING.equals(t.getTypeFlag()) ||
CommonConstants.THREE_STRING.equals(t.getTypeFlag())) {
doJointInsuranceTask.aUpdateIncomeSettleStatus(t);
}
//更新薪资结算状态
if (CommonConstants.FIVE_STRING.equals(t.getTypeFlag())) {
doJointInsuranceTask.aUpdateSalarySettleStatus(t);
}
}
}
}
}
}
}
private Map<String, TSettleDomainSelectVo> getSelectVoMap() {
R<TSettleDomainListVo> settleDomainR = archivesDaprUtil.selectAllSettleDomainSelectVos();
Map<String,TSettleDomainSelectVo> mapSelectVo = null;
......
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.insurances.service.insurance.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.yifu.insurances.entity.TUpdateStatusError;
import com.yifu.cloud.plus.v1.yifu.insurances.mapper.insurances.TUpdateStatusErrorMapper;
import com.yifu.cloud.plus.v1.yifu.insurances.service.insurance.TUpdateStatusErrorService;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service;
/**
* 同步结算状态的错误表
*
* @author huyc
* @date 2023-01-11 10:26:30
*/
@Log4j2
@Service
public class TUpdateStatusErrorServiceImpl extends ServiceImpl<TUpdateStatusErrorMapper, TUpdateStatusError> implements TUpdateStatusErrorService {
}
......@@ -2,6 +2,8 @@ package com.yifu.cloud.plus.v1.yifu.insurances.util;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
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.core.vo.YifuUser;
import com.yifu.cloud.plus.v1.yifu.common.dapr.util.SalaryDaprUtil;
import com.yifu.cloud.plus.v1.yifu.common.dapr.util.SocialDaprUtils;
......@@ -9,11 +11,9 @@ import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils;
import com.yifu.cloud.plus.v1.yifu.ekp.constant.EkpConstants;
import com.yifu.cloud.plus.v1.yifu.ekp.util.EkpInsuranceUtil;
import com.yifu.cloud.plus.v1.yifu.insurances.constants.InsurancesConstants;
import com.yifu.cloud.plus.v1.yifu.insurances.entity.TInsuranceDetail;
import com.yifu.cloud.plus.v1.yifu.insurances.entity.TInsuranceEkp;
import com.yifu.cloud.plus.v1.yifu.insurances.entity.TInsuranceSettle;
import com.yifu.cloud.plus.v1.yifu.insurances.entity.TInsuranceSettleCancel;
import com.yifu.cloud.plus.v1.yifu.insurances.entity.*;
import com.yifu.cloud.plus.v1.yifu.insurances.mapper.insurances.TInsuranceDetailMapper;
import com.yifu.cloud.plus.v1.yifu.insurances.mapper.insurances.TUpdateStatusErrorMapper;
import com.yifu.cloud.plus.v1.yifu.insurances.service.ekp.EkpSettleService;
import com.yifu.cloud.plus.v1.yifu.insurances.service.insurance.TInsuranceEkpService;
import com.yifu.cloud.plus.v1.yifu.insurances.service.insurance.TInsuranceSettleCancelService;
......@@ -66,6 +66,9 @@ public class DoJointInsuranceTask {
@Autowired
private SalaryDaprUtil salaryDaprUtil;
@Autowired
private TUpdateStatusErrorMapper updateStatusErrorMapper;
/**
* @Description: 商险明细推送
* @Author: huyc
......@@ -203,81 +206,268 @@ public class DoJointInsuranceTask {
@Async
public void updateInsuranceSettleStatus(EkpStatusParamVo vo) {
//根据结算单号获取明细id和结算状态
List<EkpInsuranceViewVo> viewVoList;
TInsuranceDetail detail;
viewVoList = ekpSettleService.selectViewBySettleNo(vo.getSettleNo(),vo.getPayFlag());
if (!viewVoList.isEmpty()) {
String insuranceId;
for (EkpInsuranceViewVo viewVo : viewVoList) {
//获取所有的明细id
insuranceId = viewVo.getId().substring(0,19);
detail = insuranceDetailMapper.selectById(insuranceId);
if (Common.isNotNull(detail)) {
//判断订单类型是预估还是实缴
if (InsurancesConstants.ACTUAL_SETTLE_BILL.equals(viewVo.getOrderType())) {
//判断是收入还是支出结算单号
if (CommonConstants.ZERO_STRING.equals(vo.getPayFlag())) {
detail.setSincomeSettleFlag(viewVo.getIncomeSettleFlag());
detail.setSincomeCollectFlag(viewVo.getIncomeCollectFlag());
} else {
detail.setSpaySettleFlag(viewVo.getPaySettleFlag());
detail.setSpayCollectFlag(viewVo.getPayCollectFlag());
}
} else {
if (CommonConstants.ZERO_STRING.equals(vo.getPayFlag())) {
detail.setIncomeSettleFlag(viewVo.getIncomeSettleFlag());
detail.setIncomeCollectFlag(viewVo.getIncomeCollectFlag());
try {
//根据结算单号获取明细id和结算状态
List<EkpInsuranceViewVo> viewVoList;
TInsuranceDetail detail;
viewVoList = ekpSettleService.selectViewBySettleNo(vo.getSettleNo(), vo.getPayFlag());
if (!viewVoList.isEmpty()) {
String insuranceId;
for (EkpInsuranceViewVo viewVo : viewVoList) {
//获取所有的明细id
insuranceId = viewVo.getId().substring(0, 19);
detail = insuranceDetailMapper.selectById(insuranceId);
if (Common.isNotNull(detail)) {
//判断订单类型是预估还是实缴
if (InsurancesConstants.ACTUAL_SETTLE_BILL.equals(viewVo.getOrderType())) {
//判断是收入还是支出结算单号
if (CommonConstants.ZERO_STRING.equals(vo.getPayFlag())) {
detail.setSincomeSettleFlag(viewVo.getIncomeSettleFlag());
detail.setSincomeCollectFlag(viewVo.getIncomeCollectFlag());
} else {
detail.setSpaySettleFlag(viewVo.getPaySettleFlag());
detail.setSpayCollectFlag(viewVo.getPayCollectFlag());
}
} else {
detail.setPaySettleFlag(viewVo.getPaySettleFlag());
detail.setPayCollectFlag(viewVo.getPayCollectFlag());
if (CommonConstants.ZERO_STRING.equals(vo.getPayFlag())) {
detail.setIncomeSettleFlag(viewVo.getIncomeSettleFlag());
detail.setIncomeCollectFlag(viewVo.getIncomeCollectFlag());
} else {
detail.setPaySettleFlag(viewVo.getPaySettleFlag());
detail.setPayCollectFlag(viewVo.getPayCollectFlag());
}
}
insuranceDetailMapper.updateById(detail);
}
insuranceDetailMapper.updateById(detail);
}
}
} catch (Exception e) {
TUpdateStatusError error = new TUpdateStatusError();
error.setSettleNo(vo.getSettleNo());
error.setStatus(CommonConstants.ZERO_INT);
error.setTitle(e.getMessage());
error.setTypeFlag(CommonConstants.FOUR_STRING);
error.setCreateTime(DateUtil.getCurrentDateTime());
error.setSettleType(vo.getPayFlag());
updateStatusErrorMapper.insert(error);
log.error("推送商险明细到EKP错误", e);
}
}
@Async
public void updateSocialSettleStatus(EkpStatusParamVo vo) {
List<EkpSocialViewVo> viewVo;
//根据结算单号获取明细id和结算状态
if (CommonConstants.ZERO_STRING.equals(vo.getTypeFlag())) {
viewVo = ekpSettleService.selectSocialViewBySettleNo(vo.getSettleNo(),vo.getPayFlag());
} else {
viewVo = ekpSettleService.selectFundViewBySettleNo(vo.getSettleNo(),vo.getPayFlag());
}
if (!viewVo.isEmpty()) {
viewVo.forEach(e -> e.setPayFlag(vo.getPayFlag()));
socialDaprUtils.updateSocialSettleStatus(viewVo);
try {
//根据结算单号获取明细id和结算状态
if (CommonConstants.ZERO_STRING.equals(vo.getTypeFlag())) {
viewVo = ekpSettleService.selectSocialViewBySettleNo(vo.getSettleNo(), vo.getPayFlag());
} else {
viewVo = ekpSettleService.selectFundViewBySettleNo(vo.getSettleNo(), vo.getPayFlag());
}
if (!viewVo.isEmpty()) {
viewVo.forEach(e -> e.setPayFlag(vo.getPayFlag()));
R<Boolean> flag = socialDaprUtils.updateSocialSettleStatus(viewVo);
if (Common.isEmpty(flag) || Boolean.TRUE.equals(!flag.getData())) {
TUpdateStatusError error = new TUpdateStatusError();
error.setSettleNo(vo.getSettleNo());
error.setStatus(CommonConstants.ZERO_INT);
error.setTitle("社保结算状态同步失败");
error.setTypeFlag(vo.getTypeFlag());
error.setCreateTime(DateUtil.getCurrentDateTime());
error.setSettleType(vo.getPayFlag());
updateStatusErrorMapper.insert(error);
}
}
} catch (Exception e) {
TUpdateStatusError error = new TUpdateStatusError();
error.setSettleNo(vo.getSettleNo());
error.setStatus(CommonConstants.ZERO_INT);
error.setTitle("社保结算状态同步失败");
error.setTypeFlag(vo.getTypeFlag());
error.setCreateTime(DateUtil.getCurrentDateTime());
error.setSettleType(vo.getPayFlag());
updateStatusErrorMapper.insert(error);
log.error("社保结算状态更新异常", e);
}
}
@Async
public void updateIncomeSettleStatus(EkpStatusParamVo vo) {
List<EkpInsuranceViewVo> viewVo;
//根据结算单号获取明细id和结算状态
//根据结算单号获取明细id和结算状态;判断是管理费还是风险金
if (CommonConstants.ZERO_STRING.equals(vo.getTypeFlag())) {
viewVo = ekpSettleService.selectIncomelViewBySettleNo(vo.getSettleNo());
}else {
viewVo = ekpSettleService.selectFIncomelViewBySettleNo(vo.getSettleNo());
}
if (!viewVo.isEmpty()) {
socialDaprUtils.updateIncomeSettleStatus(viewVo);
try {
//根据结算单号获取明细id和结算状态
//根据结算单号获取明细id和结算状态;判断是管理费还是风险金
if (CommonConstants.ZERO_STRING.equals(vo.getTypeFlag())) {
viewVo = ekpSettleService.selectIncomelViewBySettleNo(vo.getSettleNo());
} else {
viewVo = ekpSettleService.selectFIncomelViewBySettleNo(vo.getSettleNo());
}
if (!viewVo.isEmpty()) {
R<Boolean> flag = socialDaprUtils.updateIncomeSettleStatus(viewVo);
if (Common.isEmpty(flag) || Boolean.TRUE.equals(!flag.getData())) {
TUpdateStatusError error = new TUpdateStatusError();
error.setSettleNo(vo.getSettleNo());
error.setStatus(CommonConstants.ZERO_INT);
error.setTitle("收入结算状态同步失败");
error.setTypeFlag(CommonConstants.ZERO_STRING.equals(vo.getTypeFlag()) ? "2" : "3");
error.setCreateTime(DateUtil.getCurrentDateTime());
error.setSettleType(vo.getPayFlag());
updateStatusErrorMapper.insert(error);
}
}
} catch (Exception e) {
TUpdateStatusError error = new TUpdateStatusError();
error.setSettleNo(vo.getSettleNo());
error.setStatus(CommonConstants.ZERO_INT);
error.setTitle("收入结算状态同步失败");
error.setTypeFlag(CommonConstants.ZERO_STRING.equals(vo.getTypeFlag()) ? "2" : "3");
error.setCreateTime(DateUtil.getCurrentDateTime());
error.setSettleType(vo.getPayFlag());
updateStatusErrorMapper.insert(error);
log.error("收入结算状态更新异常", e);
}
}
@Async
public void updateSalarySettleStatus(EkpStatusParamVo vo) {
List<EkpSocialViewVo> viewVo;
//根据结算单号获取明细id和结算状态
viewVo = ekpSettleService.selectSalarylViewBySettleNo(vo.getSettleNo(),vo.getPayFlag());
if (!viewVo.isEmpty()) {
viewVo.forEach(e -> e.setPayFlag(vo.getPayFlag()));
salaryDaprUtil.updateSalarySettleStatus(viewVo);
try {
//根据结算单号获取明细id和结算状态
viewVo = ekpSettleService.selectSalarylViewBySettleNo(vo.getSettleNo(), vo.getPayFlag());
if (!viewVo.isEmpty()) {
viewVo.forEach(e -> e.setPayFlag(vo.getPayFlag()));
R<Boolean> flag = salaryDaprUtil.updateSalarySettleStatus(viewVo);
if (Common.isEmpty(flag) || Boolean.TRUE.equals(!flag.getData())) {
TUpdateStatusError error = new TUpdateStatusError();
error.setSettleNo(vo.getSettleNo());
error.setStatus(CommonConstants.ZERO_INT);
error.setTitle("薪资结算状态同步失败");
error.setTypeFlag(CommonConstants.FIVE_STRING);
error.setCreateTime(DateUtil.getCurrentDateTime());
error.setSettleType(vo.getPayFlag());
updateStatusErrorMapper.insert(error);
}
}
} catch (Exception e) {
TUpdateStatusError error = new TUpdateStatusError();
error.setSettleNo(vo.getSettleNo());
error.setStatus(CommonConstants.ZERO_INT);
error.setTitle("薪资结算状态同步失败");
error.setTypeFlag(CommonConstants.FIVE_STRING);
error.setCreateTime(DateUtil.getCurrentDateTime());
error.setSettleType(vo.getPayFlag());
updateStatusErrorMapper.insert(error);
log.error("薪资结算状态更新异常", e);
}
}
public void aUpdateInsuranceSettleStatus(TUpdateStatusError error) {
try {
//根据结算单号获取明细id和结算状态
List<EkpInsuranceViewVo> viewVoList;
TInsuranceDetail detail;
viewVoList = ekpSettleService.selectViewBySettleNo(error.getSettleNo(), error.getSettleType());
if (!viewVoList.isEmpty()) {
String insuranceId;
for (EkpInsuranceViewVo viewVo : viewVoList) {
//获取所有的明细id
insuranceId = viewVo.getId().substring(0, 19);
detail = insuranceDetailMapper.selectById(insuranceId);
if (Common.isNotNull(detail)) {
//判断订单类型是预估还是实缴
if (InsurancesConstants.ACTUAL_SETTLE_BILL.equals(viewVo.getOrderType())) {
//判断是收入还是支出结算单号
if (CommonConstants.ZERO_STRING.equals(error.getSettleType())) {
detail.setSincomeSettleFlag(viewVo.getIncomeSettleFlag());
detail.setSincomeCollectFlag(viewVo.getIncomeCollectFlag());
} else {
detail.setSpaySettleFlag(viewVo.getPaySettleFlag());
detail.setSpayCollectFlag(viewVo.getPayCollectFlag());
}
} else {
if (CommonConstants.ZERO_STRING.equals(error.getSettleType())) {
detail.setIncomeSettleFlag(viewVo.getIncomeSettleFlag());
detail.setIncomeCollectFlag(viewVo.getIncomeCollectFlag());
} else {
detail.setPaySettleFlag(viewVo.getPaySettleFlag());
detail.setPayCollectFlag(viewVo.getPayCollectFlag());
}
}
insuranceDetailMapper.updateById(detail);
}
}
error.setStatus(CommonConstants.ONE_INT);
error.setTitle(InsurancesConstants.AGAIN_UPDATE_STATUS);
updateStatusErrorMapper.updateById(error);
}
} catch (Exception e) {
log.error("更新商险结算状态错误", e);
}
}
public void aUpdateSocialSettleStatus(TUpdateStatusError error) {
List<EkpSocialViewVo> viewVo;
try {
//根据结算单号获取明细id和结算状态
if (CommonConstants.ZERO_STRING.equals(error.getTypeFlag())) {
viewVo = ekpSettleService.selectSocialViewBySettleNo(error.getSettleNo(), error.getSettleType());
} else {
viewVo = ekpSettleService.selectFundViewBySettleNo(error.getSettleNo(), error.getSettleType());
}
if (!viewVo.isEmpty()) {
viewVo.forEach(e -> e.setPayFlag(error.getSettleType()));
R<Boolean> flag = socialDaprUtils.updateSocialSettleStatus(viewVo);
if (!Common.isEmpty(flag) || Boolean.TRUE.equals(flag.getData())) {
error.setStatus(CommonConstants.ONE_INT);
error.setTitle(InsurancesConstants.AGAIN_UPDATE_STATUS);
updateStatusErrorMapper.updateById(error);
}
}
} catch (Exception e) {
log.error("社保结算状态更新异常", e);
}
}
public void aUpdateIncomeSettleStatus(TUpdateStatusError error) {
List<EkpInsuranceViewVo> viewVo;
try {
//根据结算单号获取明细id和结算状态
//根据结算单号获取明细id和结算状态;判断是管理费还是风险金
if (CommonConstants.TWO_STRING.equals(error.getTypeFlag())) {
viewVo = ekpSettleService.selectIncomelViewBySettleNo(error.getSettleNo());
} else {
viewVo = ekpSettleService.selectFIncomelViewBySettleNo(error.getSettleNo());
}
if (!viewVo.isEmpty()) {
R<Boolean> flag = socialDaprUtils.updateIncomeSettleStatus(viewVo);
if (!Common.isEmpty(flag) || Boolean.TRUE.equals(flag.getData())) {
error.setStatus(CommonConstants.ONE_INT);
error.setTitle(InsurancesConstants.AGAIN_UPDATE_STATUS);
updateStatusErrorMapper.updateById(error);
}
}
} catch (Exception e) {
log.error("收入结算状态更新异常", e);
}
}
public void aUpdateSalarySettleStatus(TUpdateStatusError error) {
List<EkpSocialViewVo> viewVo;
try {
//根据结算单号获取明细id和结算状态
viewVo = ekpSettleService.selectSalarylViewBySettleNo(error.getSettleNo(), error.getSettleType());
if (!viewVo.isEmpty()) {
viewVo.forEach(e -> e.setPayFlag(error.getSettleType()));
R<Boolean> flag = salaryDaprUtil.updateSalarySettleStatus(viewVo);
if (!Common.isEmpty(flag) && Boolean.TRUE.equals(flag.getData())) {
error.setStatus(CommonConstants.ONE_INT);
error.setTitle("再次同步状态成功");
error.setTypeFlag(CommonConstants.FIVE_STRING);
updateStatusErrorMapper.updateById(error);
}
}
} catch (Exception e) {
log.error("薪资结算状态更新异常", e);
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!--
~
~ Copyright (c) 2018-2025, lengleng All rights reserved.
~
~ Redistribution and use in source and binary forms, with or without
~ modification, are permitted provided that the following conditions are met:
~
~ Redistributions of source code must retain the above copyright notice,
~ this list of conditions and the following disclaimer.
~ Redistributions in binary form must reproduce the above copyright
~ notice, this list of conditions and the following disclaimer in the
~ documentation and/or other materials provided with the distribution.
~ Neither the name of the yifu4cloud.com developer nor the names of its
~ contributors may be used to endorse or promote products derived from
~ this software without specific prior written permission.
~ Author: lengleng (wangiegie@gmail.com)
~
-->
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yifu.cloud.plus.v1.yifu.insurances.mapper.insurances.TUpdateStatusErrorMapper">
<resultMap id="tUpdateStatusErrorMap" type="com.yifu.cloud.plus.v1.yifu.insurances.entity.TUpdateStatusError">
<id property="id" column="ID"/>
<result property="title" column="TITLE"/>
<result property="settleNo" column="SETTLE_NO"/>
<result property="settleType" column="SETTLE_TYPE"/>
<result property="typeFlag" column="TYPE_FLAG"/>
<result property="createTime" column="CREATE_TIME"/>
<result property="status" column="STATUS"/>
</resultMap>
<sql id="Base_Column_List">
a.ID,
a.TITLE,
a.SETTLE_NO,
a.SETTLE_TYPE,
a.TYPE_FLAG,
a.CREATE_TIME,
a.STATUS
</sql>
<sql id="tUpdateStatusError_where">
<if test="tUpdateStatusError != null">
<if test="tUpdateStatusError.id != null and tUpdateStatusError.id.trim() != ''">
AND a.ID = #{tUpdateStatusError.id}
</if>
<if test="tUpdateStatusError.title != null and tUpdateStatusError.title.trim() != ''">
AND a.TITLE = #{tUpdateStatusError.title}
</if>
<if test="tUpdateStatusError.settleNo != null and tUpdateStatusError.settleNo.trim() != ''">
AND a.SETTLE_NO = #{tUpdateStatusError.settleNo}
</if>
<if test="tUpdateStatusError.settleType != null and tUpdateStatusError.settleType.trim() != ''">
AND a.SETTLE_TYPE = #{tUpdateStatusError.settleType}
</if>
<if test="tUpdateStatusError.typeFlag != null and tUpdateStatusError.typeFlag.trim() != ''">
AND a.TYPE_FLAG = #{tUpdateStatusError.typeFlag}
</if>
<if test="tUpdateStatusError.createTime != null">
AND a.CREATE_TIME = #{tUpdateStatusError.createTime}
</if>
<if test="tUpdateStatusError.status != null">
AND a.STATUS = #{tUpdateStatusError.status}
</if>
</if>
</sql>
<!--tUpdateStatusError简单分页查询-->
<select id="getTUpdateStatusErrorPage" resultMap="tUpdateStatusErrorMap">
SELECT
<include refid="Base_Column_List"/>
FROM t_update_status_error a
<where>
1=1
<include refid="tUpdateStatusError_where"/>
</where>
</select>
</mapper>
......@@ -33,4 +33,17 @@ public class UpdateOverdueTask {
HttpDaprUtil.invokeMethodPost(daprInsurancesProperties.getAppUrl(),daprInsurancesProperties.getAppId(),"/insuranceDetail/inner/updateOverdueByTask","", Void.class, SecurityConstants.FROM_IN);
log.info("------------更新商险到期-定时任务结束------------");
}
/**
* 重新更新结算状态同步失败的数据
*
* @author huyc
* @param
* @return void
*/
public void updateSettleStatus() throws Exception {
log.info("-------------重新更新结算状态同步失败的数据-定时任务开始------------");
HttpDaprUtil.invokeMethodPost(daprInsurancesProperties.getAppUrl(),daprInsurancesProperties.getAppId(),"/insuranceDetail/inner/updateSettleStatus","", Void.class, SecurityConstants.FROM_IN);
log.info("------------重新更新结算状态同步失败的数据-定时任务结束------------");
}
}
......@@ -301,7 +301,7 @@ public class TSalaryAccountController {
**/
@Inner
@PostMapping("/inner/updateSalarySettleStatus")
public void updateSalarySettleStatus(@RequestBody List<EkpSocialViewVo> viewVo) {
tSalaryAccountService.updateSalarySettleStatus(viewVo);
public Boolean updateSalarySettleStatus(@RequestBody List<EkpSocialViewVo> viewVo) {
return tSalaryAccountService.updateSalarySettleStatus(viewVo);
}
}
......@@ -134,7 +134,7 @@ public interface TSalaryAccountService extends IService<TSalaryAccount> {
* @Date: 2022/12/26 17:56
* @return: R
**/
void updateSalarySettleStatus(List<EkpSocialViewVo> viewVo);
Boolean updateSalarySettleStatus(List<EkpSocialViewVo> viewVo);
/**
* @param page 分页
......
......@@ -237,24 +237,30 @@ public class TSalaryAccountServiceImpl extends ServiceImpl<TSalaryAccountMapper,
}
@Override
public void updateSalarySettleStatus(List<EkpSocialViewVo> viewVoList) {
public Boolean updateSalarySettleStatus(List<EkpSocialViewVo> viewVoList) {
TSalaryAccount account;
if (!viewVoList.isEmpty()) {
for (EkpSocialViewVo viewVo: viewVoList) {
//根据明细id更新结算状态
account = baseMapper.selectById(viewVo.getId());
if (Common.isNotNull(account)) {
if (CommonConstants.ZERO_STRING.equals(viewVo.getPayFlag())) {
account.setIncomeSettleFlag(viewVo.getIncomeSettleFlag());
account.setIncomeCollectFlag(viewVo.getIncomeCollectFlag());
} else {
account.setPaySettleFlag(viewVo.getPaySettleFlag());
account.setPayCollectFlag(viewVo.getPayCollectFlag());
try {
if (!viewVoList.isEmpty()) {
for (EkpSocialViewVo viewVo : viewVoList) {
//根据明细id更新结算状态
account = baseMapper.selectById(viewVo.getId());
if (Common.isNotNull(account)) {
if (CommonConstants.ZERO_STRING.equals(viewVo.getPayFlag())) {
account.setIncomeSettleFlag(viewVo.getIncomeSettleFlag());
account.setIncomeCollectFlag(viewVo.getIncomeCollectFlag());
} else {
account.setPaySettleFlag(viewVo.getPaySettleFlag());
account.setPayCollectFlag(viewVo.getPayCollectFlag());
}
baseMapper.updateById(account);
}
baseMapper.updateById(account);
}
}
} catch (Exception e) {
log.error("更新薪资结算状态失败", e);
return false;
}
return true;
}
/**
......
......@@ -231,7 +231,7 @@ public class TIncomeController {
**/
@Inner
@PostMapping("/inner/updateIncomeSettleStatus")
public void updateSocialSettleStatus(@RequestBody List<EkpInsuranceViewVo> viewVo) {
tIncomeService.updateIncomeSettleStatus(viewVo);
public Boolean updateSocialSettleStatus(@RequestBody List<EkpInsuranceViewVo> viewVo) {
return tIncomeService.updateIncomeSettleStatus(viewVo);
}
}
......@@ -456,7 +456,7 @@ public class TPaymentInfoController {
**/
@Inner
@PostMapping("/inner/updateSocialSettleStatus")
public void updateSocialSettleStatus(@RequestBody List<EkpSocialViewVo> viewVo) {
tPaymentInfoService.updateSocialSettleStatus(viewVo);
public Boolean updateSocialSettleStatus(@RequestBody List<EkpSocialViewVo> viewVo) {
return tPaymentInfoService.updateSocialSettleStatus(viewVo);
}
}
......@@ -98,6 +98,6 @@ public interface TIncomeService extends IService<TIncome> {
* @Date: 2022/12/26 17:56
* @return:
**/
void updateIncomeSettleStatus(List<EkpInsuranceViewVo> viewVo);
Boolean updateIncomeSettleStatus(List<EkpInsuranceViewVo> viewVo);
}
......@@ -167,7 +167,7 @@ public interface TPaymentInfoService extends IService<TPaymentInfo> {
**/
R<String> changeDeptByEkp(ChangeDeptVo changeDeptVo);
void updateSocialSettleStatus(List<EkpSocialViewVo> viewVo);
Boolean updateSocialSettleStatus(List<EkpSocialViewVo> viewVo);
// hgw2023-1-6 10:42:06:以下:B端相关接口:
/**
......
......@@ -802,19 +802,25 @@ public class TIncomeServiceImpl extends ServiceImpl<TIncomeMapper, TIncome> impl
}
@Override
public void updateIncomeSettleStatus(List<EkpInsuranceViewVo> viewVoList) {
if (!viewVoList.isEmpty()) {
TIncome income;
for (EkpInsuranceViewVo viewVo : viewVoList) {
//根据明细id更新结算状态
income = baseMapper.selectById(viewVo.getId());
if (Common.isNotNull(income)) {
income.setIncomeSettleFlag(viewVo.getIncomeSettleFlag());
income.setIncomeCollectFlag(viewVo.getIncomeCollectFlag());
baseMapper.updateById(income);
public Boolean updateIncomeSettleStatus(List<EkpInsuranceViewVo> viewVoList) {
try {
if (!viewVoList.isEmpty()) {
TIncome income;
for (EkpInsuranceViewVo viewVo : viewVoList) {
//根据明细id更新结算状态
income = baseMapper.selectById(viewVo.getId());
if (Common.isNotNull(income)) {
income.setIncomeSettleFlag(viewVo.getIncomeSettleFlag());
income.setIncomeCollectFlag(viewVo.getIncomeCollectFlag());
baseMapper.updateById(income);
}
}
}
} catch (Exception e) {
log.error("更新收入结算状态失败", e);
return false;
}
return true;
}
}
......@@ -3273,44 +3273,50 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
}
@Override
public void updateSocialSettleStatus(List<EkpSocialViewVo> viewVoList) {
public Boolean updateSocialSettleStatus(List<EkpSocialViewVo> viewVoList) {
if (!viewVoList.isEmpty()) {
TPaymentInfo paymentInfo;
TForecastLibrary library;
for (EkpSocialViewVo viewVo: viewVoList) {
//判断预估还是实缴
if (viewVo.getSettleFlag().contains(SocialConstants.DIFF_TYPE_THR)) {
//根据明细id更新结算状态
paymentInfo = baseMapper.selectById(viewVo.getId());
if (Common.isNotNull(paymentInfo)) {
//判断是收入还是支出结算单号
if (CommonConstants.ZERO_STRING.equals(viewVo.getPayFlag())) {
paymentInfo.setIncomeSettleFlag(viewVo.getIncomeSettleFlag());
paymentInfo.setIncomeCollectFlag(viewVo.getIncomeCollectFlag());
} else {
paymentInfo.setPaySettleFlag(viewVo.getPaySettleFlag());
paymentInfo.setPayCollectFlag(viewVo.getPayCollectFlag());
try {
for (EkpSocialViewVo viewVo : viewVoList) {
//判断预估还是实缴
if (viewVo.getSettleFlag().contains(SocialConstants.DIFF_TYPE_THR)) {
//根据明细id更新结算状态
paymentInfo = baseMapper.selectById(viewVo.getId());
if (Common.isNotNull(paymentInfo)) {
//判断是收入还是支出结算单号
if (CommonConstants.ZERO_STRING.equals(viewVo.getPayFlag())) {
paymentInfo.setIncomeSettleFlag(viewVo.getIncomeSettleFlag());
paymentInfo.setIncomeCollectFlag(viewVo.getIncomeCollectFlag());
} else {
paymentInfo.setPaySettleFlag(viewVo.getPaySettleFlag());
paymentInfo.setPayCollectFlag(viewVo.getPayCollectFlag());
}
baseMapper.updateStatusById(paymentInfo);
log.info("缴费库实缴费用状态更新");
}
baseMapper.updateStatusById(paymentInfo);
log.info("缴费库实缴费用状态更新");
}
} else if (viewVo.getSettleFlag().contains(SocialConstants.DIFF_TYPE_ONE)) {
//根据明细id更新结算状态
library = tForecastLibraryMapper.selectById(viewVo.getId());
if (Common.isNotNull(library)) {
//判断是收入还是支出结算单号
if (CommonConstants.ZERO_STRING.equals(viewVo.getPayFlag())) {
library.setIncomeSettleFlag(viewVo.getIncomeSettleFlag());
library.setIncomeCollectFlag(viewVo.getIncomeCollectFlag());
} else {
library.setPaySettleFlag(viewVo.getPaySettleFlag());
library.setPayCollectFlag(viewVo.getPayCollectFlag());
} else if (viewVo.getSettleFlag().contains(SocialConstants.DIFF_TYPE_ONE)) {
//根据明细id更新结算状态
library = tForecastLibraryMapper.selectById(viewVo.getId());
if (Common.isNotNull(library)) {
//判断是收入还是支出结算单号
if (CommonConstants.ZERO_STRING.equals(viewVo.getPayFlag())) {
library.setIncomeSettleFlag(viewVo.getIncomeSettleFlag());
library.setIncomeCollectFlag(viewVo.getIncomeCollectFlag());
} else {
library.setPaySettleFlag(viewVo.getPaySettleFlag());
library.setPayCollectFlag(viewVo.getPayCollectFlag());
}
tForecastLibraryMapper.updateById(library);
}
tForecastLibraryMapper.updateById(library);
}
}
} catch (Exception e) {
log.error("更新社保结算状态失败", e);
return false;
}
}
return true;
}
/**
......
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