Commit 957fa46a authored by fangxinjiang's avatar fangxinjiang

Merge remote-tracking branch 'origin/develop' into develop

parents b7b41633 e0e49f95
......@@ -275,7 +275,8 @@ public class TEmployeeInfo extends BaseEntity {
/**
* 员工合同状态(字典)
*/
@Schema(description = "员工合同状态(字典)0初始状态")
@Schema(description = "员工合同状态(字典)0初始状态 personnel_state")
@ExcelAttribute(name = "员工合同状态", isDataId = true, dataType = ExcelAttributeConstants.PERSONNEL_STATE)
private Integer contractStatus;
/**
......
......@@ -17,6 +17,8 @@
package com.yifu.cloud.plus.v1.yifu.archives.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttributeConstants;
import com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
......@@ -341,6 +343,7 @@ public class TEmployeeProject extends BaseEntity {
* 员工合同状态(字典)
*/
@Schema(description = "员工合同状态(字典)0初始状态")
@ExcelAttribute(name = "合同状态", isDataId = true,dataType = ExcelAttributeConstants.PERSONNEL_STATE)
private Integer contractStatus;
}
......@@ -58,7 +58,6 @@ public class EmployeeContractUpdateVO extends RowIndex implements Serializable {
/**
* 合同编号
*/
@NotBlank(message = "合同编号不能为空")
@Length(max = 50, message = "合同编号不能超过50个字符")
@ExcelAttribute(name = "合同编号", maxLength = 50)
@Schema(description = "合同编号", name = "contractNo")
......
......@@ -2,6 +2,7 @@ package com.yifu.cloud.plus.v1.yifu.archives.constants;
public class EmployeeContractConstants {
public static final String NO_CONTRACT_FILE_CABINET = "合同编号、档案柜号不可同时为空";
public static final String NO_INFO = "未找到记录";
public static final String NOT_CREATE_USER = "不是创建人,无法删除";
......
......@@ -223,30 +223,35 @@ public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContr
tEmployeeContractInfo.setIsObsolete(CommonConstants.ZERO_STRING);
tEmployeeContractInfo.setDeleteFlag(CommonConstants.ZERO_INT);
if (Common.isEmpty(tEmployeeContractInfo.getApplyNo())) {
tEmployeeContractInfo.setApplyNo(this.getCode());
tEmployeeContractInfo.setApplyNo(this.getCode(false));
}
}
/**
* @param
* @param isNew true:取数据库最新的
* @Description: 获取 申请编码
* @Author: hgw
* @Date: 2022/6/22 17:52
* @return: java.lang.String
**/
private synchronized String getCode() {
private synchronized String getCode(boolean isNew) {
String nowDay = DateUtil.getThisDay();
int nowNums;
String empCode = null;
Cache cache = cacheManager.getCache(CacheConstants.EVERYDAY_EMP_CONTRACT_CODE);
Object nowNumObj = cache.get(nowDay);
int nowNums = 1;
if (Common.isNotNull(nowNumObj)) {
SimpleValueWrapper value = (SimpleValueWrapper) nowNumObj;
nowNums = (Integer) value.get() + 1;
if (isNew) {
empCode = baseMapper.getMaxContractCode();
nowNums = Integer.parseInt(empCode) + 1;
} else {
String empCode = null;
try {
empCode = baseMapper.getMaxContractCode();
nowNums = Integer.parseInt(empCode) + 1;
Object nowNumObj = cache.get(nowDay);
if (Common.isNotNull(nowNumObj)) {
SimpleValueWrapper value = (SimpleValueWrapper) nowNumObj;
nowNums = (Integer) value.get() + 1;
} else {
empCode = baseMapper.getMaxContractCode();
nowNums = Integer.parseInt(empCode) + 1;
}
} catch (NumberFormatException e) {
log.error("获取人员合同当日最大编码时出错:" + empCode);
nowNums = 1;
......@@ -307,11 +312,7 @@ public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContr
// 针对编码再做一次重复性校验
String isCur = baseMapper.getContractByApplyNo(tEmployeeContractInfo.getApplyNo());
if (Common.isNotNull(isCur)) {
String code = this.getCode();
isCur = baseMapper.getContractByApplyNo(tEmployeeContractInfo.getApplyNo());
if (Common.isNotNull(isCur)) {
return R.failed("编码已被占用,请稍后再新增:" + code);
}
String code = this.getCode(true);
tEmployeeContractInfo.setApplyNo(code);
}
baseMapper.insert(tEmployeeContractInfo);
......@@ -414,17 +415,65 @@ public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContr
return R.failed("不是待审核状态!");
}
if (tEmployeeContractInfo.getAuditStatus() == CommonConstants.dingleDigitIntArray[2]) {
//先停用项目内的其他的员工合同
baseMapper.updateInUseStatusById(contractInfo.getEmpId(), contractInfo.getSettleDomain()
, contractInfo.getId(), CommonConstants.ONE_STRING);
// 作废、终止,不变为在用
if (Common.isEmpty(contractInfo.getSituation())
|| (!EmployeeConstants.SITUATION_SIX.equals(contractInfo.getSituation())
&& !EmployeeConstants.SITUATION_SEVEN.equals(contractInfo.getSituation()))) {
tEmployeeContractInfo.setInUse(CommonConstants.ZERO_STRING);
// 更新档案、项目合同状态为(1可用)
TEmployeeProject tEmployeeProject = tEmployeeProjectService.getOne(Wrappers.<TEmployeeProject>query()
.lambda().eq(TEmployeeProject::getEmpId, contractInfo.getEmpId())
.eq(TEmployeeProject::getDeptId, contractInfo.getSettleDomain())
.eq(TEmployeeProject::getProjectStatus, CommonConstants.ZERO_INT)
.eq(TEmployeeProject::getDeleteFlag, CommonConstants.STATUS_NORMAL)
.last(CommonConstants.LAST_ONE_SQL));
if (tEmployeeProject != null) {
tEmployeeProject.setContractStatus(CommonConstants.ONE_INT);
tEmployeeProjectService.updateById(tEmployeeProject);
}
// 更新档案、项目合同状态为(1在用)
TEmployeeInfo tEmployeeInfo = tEmployeeInfoService.getById(tEmployeeContractInfo.getEmpId());
if (tEmployeeInfo != null) {
tEmployeeInfo.setContractStatus(CommonConstants.ONE_INT);
tEmployeeInfoService.updateById(tEmployeeInfo);
}
} else {
// 作废、终止审核通过:
// 更新项目合同状态为(2不在用),档案状态要判断
TEmployeeProject tEmployeeProject = tEmployeeProjectService.getOne(Wrappers.<TEmployeeProject>query()
.lambda().eq(TEmployeeProject::getEmpId, contractInfo.getEmpId())
.eq(TEmployeeProject::getDeptId, contractInfo.getSettleDomain())
.eq(TEmployeeProject::getProjectStatus, CommonConstants.ZERO_INT)
.eq(TEmployeeProject::getDeleteFlag, CommonConstants.STATUS_NORMAL)
.last(CommonConstants.LAST_ONE_SQL));
if (tEmployeeProject != null) {
tEmployeeProject.setContractStatus(CommonConstants.TWO_INT);
tEmployeeProjectService.updateById(tEmployeeProject);
}
// 更新档案、项目合同状态为(0无合同 1在用 2不在用)
TEmployeeInfo tEmployeeInfo = tEmployeeInfoService.getById(tEmployeeContractInfo.getEmpId());
if (tEmployeeInfo != null) {
// 判断人员有无审核通过的其他合同
TEmployeeContractInfo contractInfoInUse = this.getOne(Wrappers.<TEmployeeContractInfo>query()
.lambda().eq(TEmployeeContractInfo::getEmpId, contractInfo.getEmpId())
.eq(TEmployeeContractInfo::getInUse, CommonConstants.ZERO_INT)
.eq(TEmployeeContractInfo::getDeleteFlag, CommonConstants.ZERO_INT)
.last(CommonConstants.LAST_ONE_SQL));
if (contractInfoInUse != null) {
tEmployeeInfo.setContractStatus(CommonConstants.ONE_INT);
} else {
tEmployeeInfo.setContractStatus(CommonConstants.TWO_INT);
}
tEmployeeInfoService.updateById(tEmployeeInfo);
}
}
tEmployeeContractInfo.setAuditTimeLast(LocalDateTime.now());
//先停用项目内的其他的员工合同
baseMapper.updateInUseStatusById(contractInfo.getEmpId(), contractInfo.getSettleDomain()
, contractInfo.getId(), CommonConstants.ONE_STRING);
}
// 不是待提交,记录审核记录
this.setAuditInfo(tEmployeeContractInfo);
......@@ -617,7 +666,7 @@ public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContr
}
}
} else {
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), EmployeeContractConstants.NO_INFO));
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), EmployeeContractConstants.NO_CONTRACT_FILE_CABINET));
}
} else {
errorMessageList.add(new ErrorMessage(CommonConstants.ZERO_INT, EmployeeContractConstants.NO_INFO));
......
......@@ -170,6 +170,7 @@ public interface CommonConstants {
* @author fxj
*/
int ONE_INT = 1;
int TWO_INT = 2;
/**
* 个位数字(阿里编码规约不允许直接使用‘魔法值’)
......@@ -226,6 +227,8 @@ public interface CommonConstants {
char ADD_CHAR = '+';
//int 4
int FOUR_INT = 4;
//int 5
int FIVE_INT = 5;
String TEN_STRING = "10";
public static final String SPOT = ".";
......
......@@ -11,10 +11,50 @@ public class InsurancesConstants {
* 新增投保成功
*/
public static final String ADD_SUCCESS = "新增投保成功";
/**
* 批增投保成功
*/
public static final String BATCH_SUCCESS = "批增投保成功";
/**
* 替换成功
*/
public static final String REPLACE_SUCCESS = "替换成功";
/**
* 操作成功
*/
public static final String OPERATE_SUCCESS = "操作成功";
/**
* 非投保退回状态,无法删除
*/
public static final String DELETE_ERROR = "非投保退回状态,无法删除";
/**
* 投保信息已存在
*/
public static final String DATA_IS_EXIST = "投保信息已存在";
/**
* 投保信息不存在
*/
public static final String DATA_IS_NOT_EXIST = "投保信息不存在";
/**
* 被替换信息不存在
*/
public static final String REPLACE_IS_NOT_EXIST = "被替换信息不存在";
/**
* 项目编码不存在
*/
public static final String DEPT_NO_IS_NOT_EXIST = "项目编码不存在";
/**
* 未找到结算主体的结算方式
*/
public static final String PROJECT_NOT_FIND_SETTLE_TYPE = "未找到结算主体的结算方式";
/**
* 替换者信息已存在
*/
public static final String REPLACE_IS_EXIST = "替换者信息已存在";
/**
* 无效、已过期、已出险、已减员的 不能替换
*/
public static final String REPLACE_IS_NOT_ALLOW = "无效、已过期、已出险、已减员的 不能替换";
/**
* 订单编号不能为空
*/
......@@ -23,18 +63,34 @@ public class InsurancesConstants {
* 员工姓名不能为空
*/
public static final String EMP_NAME_NOT_EMPTY = "员工姓名不能为空";
/**
* 替换员工姓名不能为空
*/
public static final String REPLACE_EMP_NAME_NOT_EMPTY = "替换员工姓名不能为空";
/**
* 员工身份证号不能为空
*/
public static final String EMP_IDCARD_NO_NOT_EMPTY = "员工身份证号不能为空";
/**
* 替换员工身份证号不能为空
*/
public static final String REPLACE_EMP_IDCARD_NO_NOT_EMPTY = "替换员工身份证号不能为空";
/**
* 员工身份证号格式有误
*/
public static final String EMP_IDCARD_NO_NOT_LEGITIMATE = "员工身份证号格式有误";
/**
* 替换员工身份证号格式有误
*/
public static final String REPLACE_EMP_IDCARD_NO_NOT_LEGITIMATE = "替换员工身份证号格式有误";
/**
* 项目编码不能为空
*/
public static final String DEPT_NO_NOT_EMPTY = "项目编码不能为空";
/**
* 替换项目编码不能为空
*/
public static final String REPLACE_DEPT_NO_NOT_EMPTY = "替换项目编码不能为空";
/**
* 保险公司名称不能为空
*/
......
......@@ -30,12 +30,6 @@ public class TInsuranceDetail extends BaseEntity {
@Schema(description = "主键")
private String id;
/**
* 员工档案id
*/
@Schema(description = "员工档案id")
private String empId;
/**
* 员工姓名
*/
......@@ -199,9 +193,9 @@ public class TInsuranceDetail extends BaseEntity {
private String insuranceHandleCityName;
/**
* 结算类型 (1、单独结算 2、合并结算-和工资一起结算)
* 结算类型 (0、预估 1、实缴)
*/
@Schema(description = "结算类型 (1、单独结算 2、合并结算-和工资一起结算)")
@Schema(description = "结算类型 (0、预估 1、实缴)")
private Integer settleType;
/**
......@@ -228,11 +222,11 @@ public class TInsuranceDetail extends BaseEntity {
@Schema(description = "投保办理状态 1待投保 2投保中 3已投保 4投保退回 5 已减员")
private Integer buyHandleStatus;
/**
* 结算办理状态 1待结算 2结算中 3已结算
*/
@Schema(description = "结算办理状态 1待结算 2结算中 3已结算")
private Integer settleHandleStatus;
/**
* 默认结算信息id
*/
@Schema(description = "默认结算信息id")
private Integer defaultSettleId;
/**
* 减员状态 1待减员 2减员中3减员退回
......
package com.yifu.cloud.plus.v1.yifu.insurances.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* @author licancan
* @description 商险替换表 t_insurance_replace
* @date 2022-07-20 14:20:16
*/
@Data
@TableName("t_insurance_replace")
@Tag(name = "商险替换表")
public class TInsuranceReplace implements Serializable {
private static final long serialVersionUID = -8528017421473755436L;
/**
* 主键
*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description = "主键")
private String id;
/**
* 被替换人明细id
*/
@Schema(description = "被替换人明细id")
private String fromInsuranceDetailId;
/**
* 替换人明细ID
*/
@Schema(description = "替换人明细ID")
private String toInsuranceDetailId;
/**
* 原始明细id
*/
@Schema(description = "原始明细id")
private String originInsuranceDetailId;
/**
* 0失败 1成功
*/
@Schema(description = "0失败 1成功")
private Integer replaceStatus;
/**
* 替换成功时间
*/
@Schema(description = "替换成功时间")
private LocalDateTime replaceTime;
/**
* 创建人
*/
@Schema(description = "创建人")
private String createBy;
/**
* 创建人姓名
*/
@Schema(description = "创建人-姓名")
private String createName;
/**
* 创建时间
*/
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss")
@Schema(description = "创建时间")
@TableField(fill = FieldFill.INSERT)
private LocalDateTime createTime;
}
\ No newline at end of file
......@@ -112,6 +112,7 @@ public class InsuranceAddParam implements Serializable {
/**
* 错误信息
*/
@Schema(description = "错误信息")
private String errorMessage;
/***********************************以下字段由系统算出,前端不用传,是为了方便入库***********************************/
......
......@@ -108,6 +108,7 @@ public class InsuranceBatchParam implements Serializable {
/**
* 错误信息
*/
@Schema(description = "错误信息")
private String errorMessage;
/***********************************以下字段由系统算出,前端不用传,是为了方便入库***********************************/
......
package com.yifu.cloud.plus.v1.yifu.insurances.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
/**
* @author licancan
* @description 投保详情VO
* @date 2022-07-20 19:23:17
*/
@Data
@Tag(name = "投保详情VO")
public class InsuranceDetailVO implements Serializable {
private static final long serialVersionUID = 628032758008497542L;
/**
* 员工姓名
*/
@Schema(description = "员工姓名")
private String empName;
/**
* 员工身份证号
*/
@Schema(description = "员工身份证号")
private String empIdcardNo;
/**
* 投保类型, 1新增、3批增、4替换
*/
@Schema(description = " 投保类型, 1新增、3批增、4替换")
private Integer buyType;
/**
* 项目名称
*/
@Schema(description = "项目名称")
private String projectName;
/**
* 项目编码
*/
@JsonIgnore
private String deptNo;
/**
* 投保岗位
*/
@Schema(description = "投保岗位")
private String post;
/**
* 保单开始时间
*/
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd")
@Schema(description = "保单开始时间")
private LocalDate policyStart;
/**
* 保单结束时间
*/
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd")
@Schema(description = "保单结束时间")
private LocalDate policyEnd;
/**
* 保单生效日期
*/
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd")
@Schema(description = "保单生效日期")
private LocalDate policyEffect;
/**
* 保单编号
*/
@Schema(description = "保单编号")
private String policyNo;
/**
* 险种名称
*/
@Schema(description = "险种名称")
private String insuranceTypeName;
/**
* 购买标准
*/
@Schema(description = "购买标准")
private String buyStandard;
/**
* 医疗额度
*/
@Schema(description = "医疗额度")
private String medicalQuota;
/**
* 身故或残疾额度
*/
@Schema(description = "身故或残疾额度")
private String dieDisableQuota;
/**
* 保险公司名称
*/
@Schema(description = "保险公司名称")
private String insuranceCompanyName;
/**
* 费用类型
*/
@Schema(description = "费用类型 0、预估 1、实缴")
private Integer premiumType;
/**
* 预估保费
*/
@Schema(description = "预估保费")
private BigDecimal estimatePremium;
/**
* 实际保费
*/
@Schema(description = "实际保费")
private BigDecimal actualPremium;
/**
* 发票号
*/
@Schema(description = "发票号")
private String invoiceNo;
/**
* 结算类型 (0、与薪资结算 1、单独结算)
*/
@Schema(description = "结算类型 (0、与薪资结算 1、单独结算)")
private Integer settleType;
/**
* 结算月
*/
@Schema(description = "结算月")
private String settleMonth;
/**
* 投保办理状态 1待投保 2投保中 3已投保 4投保退回 5 已减员
*/
@Schema(description = "投保办理状态 1待投保 2投保中 3已投保 4投保退回 5 已减员")
private Integer buyHandleStatus;
/**
* 减员状态 1待减员 2减员中3减员退回
*/
@Schema(description = "减员状态 1待减员 2减员中3减员退回")
private Integer reduceHandleStatus;
/**
* 结算办理状态 1待结算 2结算中 3已结算
*/
@Schema(description = "结算办理状态 1待结算 2结算中 3已结算")
private Integer settleHandleStatus;
/**
* 是否出险 0未出险 1已出险
*/
@Schema(description = "是否出险 0未出险 1已出险")
private Integer isUse;
/**
* 是否有效 0有效 1无效
*/
@Schema(description = "是否有效 0有效 1无效")
private Integer isEffect;
/**
* 是否过期 0未过期 1已过期
*/
@Schema(description = "是否过期 0未过期 1已过期")
private Integer isOverdue;
/**
* 商险购买地省
*/
@Schema(description = "商险购买地省")
private String insuranceProvinceName;
/**
* 商险购买地市
*/
@Schema(description = "商险购买地市")
private String insuranceCityName;
/**
* 商险办理省
*/
@Schema(description = "商险办理省")
private String insuranceHandleProvinceName;
/**
* 商险办理城市
*/
@Schema(description = "商险办理城市")
private String insuranceHandleCityName;
/**
* 创建人姓名
*/
@Schema(description = "创建人(派单人)")
private String createName;
/**
* 创建时间
*/
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss")
@Schema(description = "创建时间")
private LocalDateTime createTime;
}
package com.yifu.cloud.plus.v1.yifu.insurances.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.Data;
import java.io.Serializable;
/**
* @author licancan
* @description 投保列表请求参数
* @date 2022-07-20 16:14:19
*/
@Data
@Tag(name = "投保列表请求参数")
public class InsuranceListParam implements Serializable {
private static final long serialVersionUID = -4692341622141432288L;
/**
* 项目编码
*/
@Schema(description = "项目编码")
private String deptNo;
/**
* 投保状态 1待投保 2投保中 3已投保 4投保退回 5 已减员
*/
@Schema(description = "投保状态 1待投保 2投保中 3已投保 4投保退回 5 已减员")
private Integer buyHandleStatus;
/**
* 员工姓名
*/
@Schema(description = "员工姓名")
private String empName;
/**
* 员工身份证号
*/
@Schema(description = "员工身份证号")
private String empIdcardNo;
/**
* 保险公司名称
*/
@Schema(description = "保险公司名称")
private String insuranceCompanyName;
}
package com.yifu.cloud.plus.v1.yifu.insurances.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDate;
/**
* @author licancan
* @description 投保列表VO
* @date 2022-07-20 16:18:41
*/
@Data
@Tag(name = "投保列表VO")
public class InsuranceListVO implements Serializable {
private static final long serialVersionUID = -6673220061558171816L;
/**
* 主键
*/
@Schema(description = "主键")
private String id;
/**
* 订单编号
*/
@Schema(description = "订单编号")
private String orderNo;
/**
* 员工姓名
*/
@Schema(description = "员工姓名")
private String empName;
/**
* 员工身份证号
*/
@Schema(description = "员工身份证号")
private String empIdcardNo;
/**
* 投保类型, 1新增、3批增、4替换
*/
@Schema(description = " 投保类型, 1新增、3批增、4替换")
private Integer buyType;
/**
* 项目名称
*/
@Schema(description = "项目名称")
private String projectName;
/**
* 项目编码
*/
@JsonIgnore
private String deptNo;
/**
* 投保岗位
*/
@Schema(description = "投保岗位")
private String post;
/**
* 保单开始时间
*/
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd")
@Schema(description = "保单开始时间")
private LocalDate policyStart;
/**
* 保单结束时间
*/
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd")
@Schema(description = "保单结束时间")
private LocalDate policyEnd;
/**
* 保险公司名称
*/
@Schema(description = "保险公司名称")
private String insuranceCompanyName;
/**
* 险种名称
*/
@Schema(description = "险种名称")
private String insuranceTypeName;
/**
* 购买标准
*/
@Schema(description = "购买标准")
private String buyStandard;
/**
* 创建人姓名
*/
@Schema(description = "创建人(派单人)")
private String createName;
/**
* 投保状态 1待投保 2投保中 3已投保 4投保退回 5 已减员
*/
@Schema(description = "投保状态 1待投保 2投保中 3已投保 4投保退回 5 已减员")
private Integer buyHandleStatus;
/**
* 结算类型 (0、预估 1、实缴)
*/
@Schema(description = "结算类型 (0、预估 1、实缴)")
private Integer settleType;
/**
* 结算月
*/
@Schema(description = "结算月")
private String settleMonth;
}
package com.yifu.cloud.plus.v1.yifu.insurances.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDate;
/**
* @author licancan
* @description 商险办理替换入参
* @date 2022-07-20 08:43:31
*/
@Data
@Tag(name = "商险办理替换入参")
public class InsuranceReplaceParam implements Serializable {
private static final long serialVersionUID = -2689686777914935788L;
/**
* 员工姓名
*/
@Schema(description = "员工姓名")
private String empName;
/**
* 员工身份证号
*/
@Schema(description = "员工身份证号")
private String empIdcardNo;
/**
* 项目编码
*/
@Schema(description = "项目编码")
private String deptNo;
/**
* 保险公司名称
*/
@Schema(description = "保险公司名称")
private String insuranceCompanyName;
/**
* 险种名称
*/
@Schema(description = "险种名称")
private String insuranceTypeName;
/**
* 保单开始时间
*/
@Schema(description = "保单开始时间")
private String policyStart;
/**
* 保单结束时间
*/
@Schema(description = "保单结束时间")
private String policyEnd;
/**
* 替换员工姓名
*/
@Schema(description = "替换员工姓名")
private String replaceEmpName;
/**
* 替换员工身份证号
*/
@Schema(description = "替换员工身份证号")
private String replaceEmpIdcardNo;
/**
* 替换员工项目编码
*/
@Schema(description = "替换员工项目编码")
private String replaceDeptNo;
/**
* 订单编号
*/
@Schema(description = "订单编号")
private String orderNo;
/**
* 岗位
*/
@Schema(description = "岗位")
private String post;
/**
* 错误信息
*/
@Schema(description = "错误信息")
private String errorMessage;
}
package com.yifu.cloud.plus.v1.yifu.insurances.controller;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.insurances.entity.InsuranceRefundCheck;
import com.yifu.cloud.plus.v1.yifu.insurances.service.TInsuranceDetailService;
import com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceAddParam;
import com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceBatchParam;
import com.yifu.cloud.plus.v1.yifu.insurances.vo.*;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpHeaders;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import javax.validation.constraints.Size;
import java.util.List;
import java.util.List;
/**
* @author licancan
......@@ -40,6 +36,33 @@ public class TInsuranceDetailController {
private TInsuranceDetailService tInsuranceDetailService;
/***********************商险办理********************************/
/**
* 投保办理分页查询
*
* @author licancan
* @param page
* @param param
* @return {@link R<IPage<InsuranceListVO>>}
*/
@Operation(summary = "投保办理分页查询", description = "投保办理分页查询")
@PostMapping("/getInsuranceListPage")
public R<IPage<InsuranceListVO>> getInsuranceListPage(Page<InsuranceListVO> page, @RequestBody InsuranceListParam param) {
return R.ok(tInsuranceDetailService.getInsuranceListPage(page, param));
}
/**
* 投保办理不分页查询
*
* @author licancan
* @param param
* @return {@link R<List<InsuranceListVO>>}
*/
@Operation(summary = "投保办理不分页查询", description = "投保办理不分页查询")
@PostMapping("/getInsuranceList")
public R<List<InsuranceListVO>> getInsuranceList(@RequestBody InsuranceListParam param) {
return R.ok(tInsuranceDetailService.getInsuranceList(param));
}
/**
* 商险新增
*
......@@ -47,6 +70,7 @@ public class TInsuranceDetailController {
* @param paramList
* @return {@link R<List<InsuranceAddParam>>}
*/
@Operation(summary = "投保新增", description = "投保新增")
@PostMapping("/addInsurance")
public R<List<InsuranceAddParam>> addInsurance(@RequestBody @Valid @Size(min = 1,message = "集合不能为空") List<InsuranceAddParam> paramList){
return tInsuranceDetailService.addInsurance(paramList);
......@@ -59,13 +83,53 @@ public class TInsuranceDetailController {
* @param paramList
* @return {@link R<List<InsuranceBatchParam>>}
*/
@Operation(summary = "投保批增", description = "投保批增")
@PostMapping("/batchInsurance")
public R<List<InsuranceBatchParam>> batchInsurance(@RequestBody @Valid @Size(min = 1,message = "集合不能为空") List<InsuranceBatchParam> paramList){
return tInsuranceDetailService.batchInsurance(paramList);
}
/***********************减员办理********************************/
/**
* 商险替换
*
* @author licancan
* @param paramList
* @return {@link R<List<InsuranceReplaceParam>>}
*/
@Operation(summary = "投保替换", description = "投保替换")
@PostMapping("/replaceInsurance")
public R<List<InsuranceReplaceParam>> replaceInsurance(@RequestBody @Valid @Size(min = 1,message = "集合不能为空") List<InsuranceReplaceParam> paramList){
return tInsuranceDetailService.replaceInsurance(paramList);
}
/**
* 通过id删除
*
* @author licancan
* @param id
* @return {@link R<String>}
*/
@GetMapping("/deleteInsurance")
@Operation(summary = "通过id删除", description = "通过id删除")
//@PreAuthorize("@pms.hasPermission('temployeeinfo_del')")
public R<String> deleteInsurance(@RequestParam String id) {
return tInsuranceDetailService.deleteInsurance(id);
}
/**
* 通过id查询
*
* @author licancan
* @param id
* @return {@link R<InsuranceDetailVO>}
*/
@Operation(summary = "通过id查询", description = "通过id查询")
@GetMapping("/{id}")
public R<InsuranceDetailVO> getInsuranceDetailById(@PathVariable("id") String id) {
return R.ok(tInsuranceDetailService.getInsuranceDetailById(id));
}
/***********************减员办理********************************/
/**
* 导入减员校验
* @param insuranceRefundCheckList 导入减员校验
......
package com.yifu.cloud.plus.v1.yifu.insurances.mapper;
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.TInsuranceDetail;
import com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceDetailVO;
import com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceListParam;
import com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceListVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author licancan
......@@ -11,5 +19,34 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public interface TInsuranceDetailMapper extends BaseMapper<TInsuranceDetail> {
/***********************商险办理********************************/
/**
* 投保办理分页查询
*
* @author licancan
* @param page
* @param param
* @return {@link IPage< InsuranceListVO>}
*/
IPage<InsuranceListVO> getInsuranceListPage(Page<InsuranceListVO> page, @Param("param") InsuranceListParam param);
/**
* 投保办理不分页查询
*
* @author licancan
* @param param
* @return {@link List<InsuranceListVO>}
*/
List<InsuranceListVO> getInsuranceList(@Param("param") InsuranceListParam param);
/**
* 通过id查询
*
* @author licancan
* @param id
* @return {@link InsuranceDetailVO}
*/
InsuranceDetailVO getInsuranceDetailById(@Param("id") String id);
/***********************减员办理********************************/
}
package com.yifu.cloud.plus.v1.yifu.insurances.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yifu.cloud.plus.v1.yifu.insurances.entity.TInsuranceReplace;
import org.apache.ibatis.annotations.Mapper;
/**
* @author licancan
* @description 针对表【t_insurance_replace(商险替换表)】的数据库操作Mapper
* @date 2022-07-20 14:20:16
*/
@Mapper
public interface TInsuranceReplaceMapper extends BaseMapper<TInsuranceReplace> {
}
package com.yifu.cloud.plus.v1.yifu.insurances.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.insurances.entity.InsuranceRefundCheck;
import com.yifu.cloud.plus.v1.yifu.insurances.entity.TInsuranceDetail;
import com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceAddParam;
import com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceBatchParam;
import java.util.List;
import com.yifu.cloud.plus.v1.yifu.insurances.vo.*;
import java.util.List;
......@@ -21,6 +19,25 @@ import java.util.List;
public interface TInsuranceDetailService extends IService<TInsuranceDetail> {
/***********************商险办理********************************/
/**
* 投保办理分页查询
*
* @author licancan
* @param page
* @param param
* @return {@link IPage<InsuranceListVO>}
*/
IPage<InsuranceListVO> getInsuranceListPage(Page<InsuranceListVO> page, InsuranceListParam param);
/**
* 投保办理不分页查询
*
* @author licancan
* @param param
* @return {@link List<InsuranceListVO>}
*/
List<InsuranceListVO> getInsuranceList(InsuranceListParam param);
/**
* 商险新增
*
......@@ -38,6 +55,32 @@ public interface TInsuranceDetailService extends IService<TInsuranceDetail> {
* @return {@link R<List<InsuranceBatchParam>>}
*/
R<List<InsuranceBatchParam>> batchInsurance(List<InsuranceBatchParam> paramList);
/**
* 商险替换
*
* @author licancan
* @param paramList
* @return {@link R<List<InsuranceReplaceParam>>}
*/
R<List<InsuranceReplaceParam>> replaceInsurance(List<InsuranceReplaceParam> paramList);
/**
* 通过id删除
*
* @author licancan
* @param id
* @return {@link R<String>}
*/
R<String> deleteInsurance(String id);
/**
* 通过id查询
*
* @author licancan
* @param id
* @return {@link InsuranceDetailVO}
*/
InsuranceDetailVO getInsuranceDetailById(String id);
/***********************减员办理********************************/
/**
......@@ -48,4 +91,5 @@ public interface TInsuranceDetailService extends IService<TInsuranceDetail> {
* @return {@link R}
*/
R checkInsuranceRefundList(List<InsuranceRefundCheck> insuranceRefundCheckList);
}
package com.yifu.cloud.plus.v1.yifu.insurances.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.yifu.insurances.entity.TInsuranceReplace;
/**
* @author licancan
* @description 针对表【t_insurance_replace(商险替换表)】的数据库操作Service
* @date 2022-07-20 14:20:16
*/
public interface TInsuranceReplaceService extends IService<TInsuranceReplace> {
}
package com.yifu.cloud.plus.v1.yifu.insurances.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Sets;
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.R;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
import com.yifu.cloud.plus.v1.yifu.common.dapr.util.ArchivesDaprUtil;
import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils;
import com.yifu.cloud.plus.v1.yifu.insurances.constants.InsurancesConstants;
import com.yifu.cloud.plus.v1.yifu.insurances.entity.TInsuranceCompany;
import com.yifu.cloud.plus.v1.yifu.insurances.entity.InsuranceRefundCheck;
import com.yifu.cloud.plus.v1.yifu.insurances.entity.TInsuranceDetail;
import com.yifu.cloud.plus.v1.yifu.insurances.entity.TInsuranceType;
import com.yifu.cloud.plus.v1.yifu.insurances.entity.TInsuranceTypeStandard;
import com.yifu.cloud.plus.v1.yifu.insurances.entity.*;
import com.yifu.cloud.plus.v1.yifu.insurances.mapper.TInsuranceDetailMapper;
import com.yifu.cloud.plus.v1.yifu.insurances.service.TInsuranceCompanyService;
import com.yifu.cloud.plus.v1.yifu.insurances.service.TInsuranceDetailService;
import com.yifu.cloud.plus.v1.yifu.insurances.service.TInsuranceTypeService;
import com.yifu.cloud.plus.v1.yifu.insurances.service.TInsuranceTypeStandardService;
import com.yifu.cloud.plus.v1.yifu.insurances.service.*;
import com.yifu.cloud.plus.v1.yifu.insurances.util.BeanCopyUtils;
import com.yifu.cloud.plus.v1.yifu.insurances.util.LocalDateUtil;
import com.yifu.cloud.plus.v1.yifu.insurances.util.ValidityUtil;
import com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceAddParam;
import com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceBatchParam;
import com.yifu.cloud.plus.v1.yifu.insurances.vo.*;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.*;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author licancan
......@@ -52,8 +51,69 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
@Resource
@Lazy
private TInsuranceTypeStandardService tInsuranceTypeStandardService;
@Resource
private TInsuranceReplaceService tInsuranceReplaceService;
@Resource
private ArchivesDaprUtil archivesDaprUtil;
/***********************商险办理********************************/
/**
* 投保办理分页查询
*
* @param page
* @param param
* @return {@link IPage < InsuranceListVO >}
* @author licancan
*/
@Override
public IPage<InsuranceListVO> getInsuranceListPage(Page<InsuranceListVO> page, InsuranceListParam param) {
//todo 根据登录人获取数据权限
IPage<InsuranceListVO> insuranceList = baseMapper.getInsuranceListPage(page,param);
if (CollectionUtils.isNotEmpty(insuranceList.getRecords())){
//根据项目编码获取项目名称
List<String> collect = insuranceList.getRecords().stream().map(e -> e.getDeptNo()).distinct().collect(Collectors.toList());
R<Map> setInfoByCodes = archivesDaprUtil.getSetInfoByCodes(collect);
if (null != setInfoByCodes && setInfoByCodes.getCode() != CommonConstants.SUCCESS && MapUtils.isNotEmpty(setInfoByCodes.getData())) {
Map data = setInfoByCodes.getData();
for (InsuranceListVO record : insuranceList.getRecords()) {
JSONObject jsonObject = (JSONObject) data.get(record.getDeptNo());
if (null != jsonObject){
record.setProjectName(Optional.ofNullable(jsonObject.getString("departName")).orElse(""));
}
}
}
}
return insuranceList;
}
/**
* 投保办理不分页查询
*
* @param param
* @return {@link List<InsuranceListVO>}
* @author licancan
*/
@Override
public List<InsuranceListVO> getInsuranceList(InsuranceListParam param) {
//todo 根据登录人获取数据权限
List<InsuranceListVO> insuranceList = baseMapper.getInsuranceList(param);
if (CollectionUtils.isNotEmpty(insuranceList)){
//根据项目编码获取项目名称
List<String> collect = insuranceList.stream().map(e -> e.getDeptNo()).distinct().collect(Collectors.toList());
R<Map> setInfoByCodes = archivesDaprUtil.getSetInfoByCodes(collect);
if (null != setInfoByCodes && setInfoByCodes.getCode() != CommonConstants.SUCCESS && MapUtils.isNotEmpty(setInfoByCodes.getData())) {
Map data = setInfoByCodes.getData();
for (InsuranceListVO record : insuranceList) {
JSONObject jsonObject = (JSONObject) data.get(record.getDeptNo());
if (null != jsonObject){
record.setProjectName(Optional.ofNullable(jsonObject.getString("departName")).orElse(""));
}
}
}
}
return insuranceList;
}
/**
* 商险新增
*
......@@ -135,7 +195,118 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
this.saveBatch(detailList);
}
//todo 操作记录
return R.ok(listResult,InsurancesConstants.ADD_SUCCESS);
return R.ok(listResult,InsurancesConstants.BATCH_SUCCESS);
}
/**
* 商险替换
*
* @param paramList
* @return {@link R<List<InsuranceReplaceParam>>}
* @author licancan
*/
@Override
@Transactional(rollbackFor = {Exception.class})
public R<List<InsuranceReplaceParam>> replaceInsurance(List<InsuranceReplaceParam> paramList) {
if (CollectionUtils.isEmpty(paramList)){
return R.failed(CommonConstants.DATA_CAN_NOT_EMPTY);
}
YifuUser user = SecurityUtils.getUser();
if (user == null || Common.isEmpty(user.getId())) {
return R.failed(CommonConstants.PLEASE_LOG_IN);
}
Map<String, List<InsuranceReplaceParam>> map = replaceInsuranceCheck(paramList);
//返回给前端的结果
List<InsuranceReplaceParam> listResult = map.get("listResult");
//保存到数据库中的结果
List<InsuranceReplaceParam> listSuccess = map.get("listSuccess");
if (CollectionUtils.isNotEmpty(listSuccess)){
for (InsuranceReplaceParam success : listSuccess) {
//替换
TInsuranceDetail newDetail = new TInsuranceDetail();
//原数据置为无效:姓名 + 身份证号 + 项目编码 + 保险公司 + 险种名称 + 保单开始时间 + 保单结束时间
TInsuranceDetail detail = this.baseMapper.selectOne(Wrappers.<TInsuranceDetail>query().lambda()
.eq(TInsuranceDetail::getEmpName, success.getEmpName())
.eq(TInsuranceDetail::getEmpIdcardNo, success.getEmpIdcardNo())
.eq(TInsuranceDetail::getDeptNo, success.getDeptNo())
.eq(TInsuranceDetail::getInsuranceCompanyName, success.getInsuranceCompanyName())
.eq(TInsuranceDetail::getInsuranceTypeName, success.getInsuranceTypeName())
.eq(TInsuranceDetail::getPolicyStart, LocalDateUtil.parseLocalDate(success.getPolicyStart()))
.eq(TInsuranceDetail::getPolicyEnd, LocalDateUtil.parseLocalDate(success.getPolicyEnd()))
.eq(TInsuranceDetail::getDeleteFlag, CommonConstants.ZERO_INT)
);
BeanCopyUtils.copyProperties(detail,newDetail);
detail.setIsEffect(CommonConstants.ONE_INT);
this.updateById(detail);
//新数据置为待办理
newDetail.setId(null);
newDetail.setBuyHandleStatus(CommonConstants.ONE_INT);
newDetail.setBuyType(CommonConstants.FOUR_INT);
newDetail.setEmpName(success.getReplaceEmpName());
newDetail.setEmpIdcardNo(success.getReplaceEmpIdcardNo());
newDetail.setDeptNo(success.getReplaceDeptNo());
newDetail.setOrderNo(success.getOrderNo());
newDetail.setPost(success.getPost());
Boolean insert = this.save(newDetail);
//替换记录
if (insert){
TInsuranceReplace replace = new TInsuranceReplace();
replace.setFromInsuranceDetailId(detail.getId());
replace.setToInsuranceDetailId(newDetail.getId());
TInsuranceReplace one = tInsuranceReplaceService.getOne(Wrappers.<TInsuranceReplace>query().lambda()
.eq(TInsuranceReplace::getToInsuranceDetailId, detail.getId())
.last(CommonConstants.LAST_ONE_SQL)
);
if (Optional.ofNullable(one).isPresent()){
replace.setOriginInsuranceDetailId(one.getOriginInsuranceDetailId());
}else {
replace.setOriginInsuranceDetailId(detail.getId());
}
replace.setReplaceStatus(CommonConstants.ONE_INT);
replace.setReplaceTime(LocalDateTime.now());
replace.setCreateBy(user.getId());
replace.setCreateName(user.getNickname());
replace.setCreateTime(LocalDateTime.now());
tInsuranceReplaceService.save(replace);
}
}
}
//todo 操作记录
return R.ok(listResult,InsurancesConstants.REPLACE_SUCCESS);
}
/**
* 通过id删除
*
* @param id
* @return {@link R<String>}
* @author licancan
*/
@Override
public R<String> deleteInsurance(String id) {
TInsuranceDetail byId = this.getById(id);
if (null == byId){
return R.failed(InsurancesConstants.DATA_IS_NOT_EXIST);
}
if (byId.getBuyHandleStatus() != CommonConstants.FOUR_INT){
return R.failed(InsurancesConstants.DELETE_ERROR);
}
byId.setDeleteFlag(CommonConstants.ONE_INT);
this.updateById(byId);
return R.ok(InsurancesConstants.OPERATE_SUCCESS);
}
/**
* 通过id查询
*
* @param id
* @return {@link InsuranceDetailVO}
* @author licancan
*/
@Override
public InsuranceDetailVO getInsuranceDetailById(String id) {
InsuranceDetailVO insuranceDetailVO = this.baseMapper.getInsuranceDetailById(id);
return insuranceDetailVO;
}
/**
......@@ -232,10 +403,33 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
listResult.add(param);
continue;
}
//todo 实名校验合法
//todo 根据项目编码和订单编号查询项目是否存在
//todo 结算类型,根据项目编码获取,并冗余到明细记录中
//param.setSettleType(CommonConstants.ONE_INT);
//根据项目编码查询项目是否存在
R<Map> setInfoByCodes = archivesDaprUtil.getSetInfoByCodes(Arrays.asList(param.getDeptNo()));
if (null != setInfoByCodes && setInfoByCodes.getCode() != CommonConstants.SUCCESS) {
Map data = setInfoByCodes.getData();
if (MapUtils.isEmpty(data)){
param.setErrorMessage(InsurancesConstants.DEPT_NO_IS_NOT_EXIST);
listResult.add(param);
continue;
}else {
JSONObject jsonObject = (JSONObject) data.get(param.getDeptNo());
if (null == jsonObject){
param.setErrorMessage(InsurancesConstants.DEPT_NO_IS_NOT_EXIST);
listResult.add(param);
continue;
}else {
//结算类型,根据项目编码获取,并冗余到明细记录中
String settleType = jsonObject.getString("insuranceSettleType");
if (StringUtils.isEmpty(settleType)){
param.setErrorMessage(InsurancesConstants.PROJECT_NOT_FIND_SETTLE_TYPE);
listResult.add(param);
continue;
}else {
param.setSettleType(Integer.parseInt(settleType));
}
}
}
}
//todo 省市校验是否正确并设置对应code
//param.setInsuranceProvince();
//param.setInsuranceCity();
......@@ -297,6 +491,7 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
}
}
//记录查重校验:姓名 + 身份证号 + 保险公司 + 险种 + 保单开始日期~保单结束日期区间 是唯一(剔除退回、过期状态的记录)
//todo 时间区间
Set<Integer> setRStatus = Sets.newHashSet();
setRStatus.add(CommonConstants.FOUR_INT);
TInsuranceDetail insuranceDetail = this.baseMapper.selectOne(Wrappers.<TInsuranceDetail>query().lambda()
......@@ -422,10 +617,33 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
listResult.add(param);
continue;
}
//todo 实名校验合法
//todo 根据项目编码和订单编号查询项目是否存在
//todo 结算类型,根据项目编码获取,并冗余到明细记录中
//param.setSettleType(CommonConstants.ONE_INT);
//根据项目编码查询项目是否存在
R<Map> setInfoByCodes = archivesDaprUtil.getSetInfoByCodes(Arrays.asList(param.getDeptNo()));
if (null != setInfoByCodes && setInfoByCodes.getCode() != CommonConstants.SUCCESS) {
Map data = setInfoByCodes.getData();
if (MapUtils.isEmpty(data)){
param.setErrorMessage(InsurancesConstants.DEPT_NO_IS_NOT_EXIST);
listResult.add(param);
continue;
}else {
JSONObject jsonObject = (JSONObject) data.get(param.getDeptNo());
if (null == jsonObject){
param.setErrorMessage(InsurancesConstants.DEPT_NO_IS_NOT_EXIST);
listResult.add(param);
continue;
}else {
//结算类型,根据项目编码获取,并冗余到明细记录中
String settleType = jsonObject.getString("insuranceSettleType");
if (StringUtils.isEmpty(settleType)){
param.setErrorMessage(InsurancesConstants.PROJECT_NOT_FIND_SETTLE_TYPE);
listResult.add(param);
continue;
}else {
param.setSettleType(Integer.parseInt(settleType));
}
}
}
}
//todo 省市校验是否正确并设置对应code
//param.setInsuranceProvince();
//param.setInsuranceCity();
......@@ -518,6 +736,149 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
return map;
}
/**
* 商险替换校验
*
* @author licancan
* @param paramList
* @return {@link Map< String, List<InsuranceReplaceParam>>}
*/
private Map<String,List<InsuranceReplaceParam>> replaceInsuranceCheck(List<InsuranceReplaceParam> paramList){
Map<String,List<InsuranceReplaceParam>> map = new HashMap<>();
List<InsuranceReplaceParam> listResult = new ArrayList<>();
List<InsuranceReplaceParam> listSuccess = new ArrayList<>();
for (InsuranceReplaceParam param : paramList) {
// 必填校验
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.getDeptNo())){
param.setErrorMessage(InsurancesConstants.DEPT_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 (StringUtils.isBlank(param.getReplaceEmpName())){
param.setErrorMessage(InsurancesConstants.REPLACE_EMP_NAME_NOT_EMPTY);
listResult.add(param);
continue;
}
if (StringUtils.isBlank(param.getReplaceEmpIdcardNo())){
param.setErrorMessage(InsurancesConstants.REPLACE_EMP_IDCARD_NO_NOT_EMPTY);
listResult.add(param);
continue;
}
if (StringUtils.isBlank(param.getReplaceDeptNo())){
param.setErrorMessage(InsurancesConstants.REPLACE_DEPT_NO_NOT_EMPTY);
listResult.add(param);
continue;
}
if (StringUtils.isBlank(param.getOrderNo())){
param.setErrorMessage(InsurancesConstants.ORDER_NO_NOT_EMPTY);
listResult.add(param);
continue;
}
if (StringUtils.isBlank(param.getPost())){
param.setErrorMessage(InsurancesConstants.POST_NOT_EMPTY);
listResult.add(param);
continue;
}
// 身份证号位数校验(18 位合法)
if (ValidityUtil.validateIDCard(param.getEmpIdcardNo())){
param.setErrorMessage(InsurancesConstants.EMP_IDCARD_NO_NOT_LEGITIMATE);
listResult.add(param);
continue;
}
if (ValidityUtil.validateIDCard(param.getReplaceEmpIdcardNo())){
param.setErrorMessage(InsurancesConstants.REPLACE_EMP_IDCARD_NO_NOT_LEGITIMATE);
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;
}
//原数据查重校验:姓名 + 身份证号 + 项目编码 + 保险公司 + 险种名称 + 保单开始时间 + 保单结束时间
TInsuranceDetail detail = this.baseMapper.selectOne(Wrappers.<TInsuranceDetail>query().lambda()
.eq(TInsuranceDetail::getEmpName, param.getEmpName())
.eq(TInsuranceDetail::getEmpIdcardNo, param.getEmpIdcardNo())
.eq(TInsuranceDetail::getDeptNo, param.getDeptNo())
.eq(TInsuranceDetail::getInsuranceCompanyName, param.getInsuranceCompanyName())
.eq(TInsuranceDetail::getInsuranceTypeName, param.getInsuranceTypeName())
.eq(TInsuranceDetail::getPolicyStart, LocalDateUtil.parseLocalDate(param.getPolicyStart()))
.eq(TInsuranceDetail::getPolicyEnd, LocalDateUtil.parseLocalDate(param.getPolicyEnd()))
.eq(TInsuranceDetail::getDeleteFlag, CommonConstants.ZERO_INT)
);
if (!Optional.ofNullable(detail).isPresent()){
param.setErrorMessage(InsurancesConstants.REPLACE_IS_NOT_EXIST);
listResult.add(param);
continue;
}else {
// 无效、已过期、已出险、已减员的 不能替换
if (detail.getBuyHandleStatus() == CommonConstants.FIVE_INT
|| detail.getIsUse() == CommonConstants.ONE_INT
|| detail.getIsOverdue() == CommonConstants.ONE_INT
|| detail.getIsEffect() == CommonConstants.ONE_INT){
param.setErrorMessage(InsurancesConstants.REPLACE_IS_NOT_ALLOW);
listResult.add(param);
continue;
}
}
//替换者数据查重校验:替换姓名 + 替换身份证号 + 替换项目编码 + 保险公司 + 险种名称
TInsuranceDetail replace = this.baseMapper.selectOne(Wrappers.<TInsuranceDetail>query().lambda()
.eq(TInsuranceDetail::getEmpName, param.getReplaceEmpName())
.eq(TInsuranceDetail::getEmpIdcardNo, param.getReplaceEmpIdcardNo())
.eq(TInsuranceDetail::getDeptNo, param.getReplaceDeptNo())
.eq(TInsuranceDetail::getInsuranceCompanyName, param.getInsuranceCompanyName())
.eq(TInsuranceDetail::getInsuranceTypeName, param.getInsuranceTypeName())
//加状态??
.eq(TInsuranceDetail::getDeleteFlag, CommonConstants.ZERO_INT)
);
if (Optional.ofNullable(replace).isPresent()){
param.setErrorMessage(InsurancesConstants.REPLACE_IS_EXIST);
listResult.add(param);
continue;
}
listSuccess.add(param);
}
map.put("listResult",listResult);
map.put("listSuccess",listSuccess);
return map;
}
/***********************减员办理********************************/
@Override
public R checkInsuranceRefundList(List<InsuranceRefundCheck> insuranceRefundCheckList) {
......
package com.yifu.cloud.plus.v1.yifu.insurances.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.yifu.insurances.entity.TInsuranceReplace;
import com.yifu.cloud.plus.v1.yifu.insurances.mapper.TInsuranceReplaceMapper;
import com.yifu.cloud.plus.v1.yifu.insurances.service.TInsuranceReplaceService;
import org.springframework.stereotype.Service;
/**
* @author licancan
* @description 针对表【t_insurance_replace(商险替换表)】的数据库操作Service实现
* @date 2022-07-20 14:20:16
*/
@Service
public class TInsuranceReplaceServiceImpl extends ServiceImpl<TInsuranceReplaceMapper, TInsuranceReplace> implements TInsuranceReplaceService {
}
......@@ -6,7 +6,6 @@
<resultMap id="BaseResultMap" type="com.yifu.cloud.plus.v1.yifu.insurances.entity.TInsuranceDetail">
<id property="id" column="ID" jdbcType="VARCHAR"/>
<result property="empId" column="EMP_ID" jdbcType="VARCHAR"/>
<result property="empName" column="EMP_NAME" jdbcType="VARCHAR"/>
<result property="empIdcardNo" column="EMP_IDCARD_NO" jdbcType="VARCHAR"/>
<result property="orderNo" column="ORDER_NO" jdbcType="VARCHAR"/>
......@@ -39,7 +38,7 @@
<result property="estimatePremium" column="ESTIMATE_PREMIUM" jdbcType="DECIMAL"/>
<result property="settleBalance" column="SETTLE_BALANCE" jdbcType="DECIMAL"/>
<result property="buyHandleStatus" column="BUY_HANDLE_STATUS" jdbcType="TINYINT"/>
<result property="settleHandleStatus" column="SETTLE_HANDLE_STATUS" jdbcType="TINYINT"/>
<result property="defaultSettleId" column="DEFAULT_SETTLE_ID" jdbcType="VARCHAR"/>
<result property="reduceHandleStatus" column="REDUCE_HANDLE_STATUS" jdbcType="TINYINT"/>
<result property="isUse" column="IS_USE" jdbcType="TINYINT"/>
<result property="isEffect" column="IS_EFFECT" jdbcType="TINYINT"/>
......@@ -54,7 +53,7 @@
</resultMap>
<sql id="Base_Column_List">
ID,EMP_ID,EMP_NAME,
ID,EMP_NAME,
EMP_IDCARD_NO,ORDER_NO,DEPT_NO,POST,INSURANCE_COMPANY_NAME,INSURANCE_TYPE_NAME,
INSURANCE_TYPE_ID,BUY_STANDARD,MEDICAL_QUOTA,DIE_DISABLE_QUOTA,POLICY_NO,
POLICY_START,POLICY_END,POLICY_EFFECT,
......@@ -62,9 +61,121 @@
BUY_TYPE,INSURANCE_PROVINCE,INSURANCE_PROVINCE_NAME,INSURANCE_CITY,INSURANCE_CITY_NAME,
INSURANCE_HANDLE_PROVINCE,INSURANCE_HANDLE_PROVINCE_NAME,INSURANCE_HANDLE_CITY,INSURANCE_HANDLE_CITY_NAME,SETTLE_TYPE,
ACTUAL_PREMIUM,ESTIMATE_PREMIUM,SETTLE_BALANCE,
BUY_HANDLE_STATUS,SETTLE_HANDLE_STATUS,REDUCE_HANDLE_STATUS,
BUY_HANDLE_STATUS,DEFAULT_SETTLE_ID,REDUCE_HANDLE_STATUS,
IS_USE,IS_EFFECT,IS_OVERDUE,REMARK,
CREATE_BY,CREATE_NAME,CREATE_TIME,
UPDATE_BY,UPDATE_TIME,DELETE_FLAG
</sql>
<select id="getInsuranceListPage" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceListVO">
select detail.id as id,
detail.ORDER_NO as orderNo,
detail.EMP_NAME as empName,
detail.EMP_IDCARD_NO as empIdcardNo,
detail.BUY_TYPE as buyType,
detail.POST as post,
detail.DEPT_NO as deptNo,
detail.POLICY_START as policyStart,
detail.POLICY_END as policyEnd,
detail.INSURANCE_COMPANY_NAME as insuranceCompanyName,
detail.INSURANCE_TYPE_NAME as insuranceTypeName,
detail.BUY_STANDARD as buyStandard,
detail.CREATE_NAME as createName,
detail.BUY_HANDLE_STATUS as buyHandleStatus,
detail.SETTLE_TYPE as settleType,
detail.SETTLE_MONTH as settleMonth
from t_insurance_detail detail
where detail.DELETE_FLAG = 0
<if test="param.deptNo != null and param.deptNo.trim() != ''">
and detail.DEPT_NO like concat('%',replace(replace(#{deptNo},'_','\_'),'%','\%'),'%')
</if>
<if test="param.buyHandleStatus != null">
and detail.BUY_HANDLE_STATUS = #{param.buyHandleStatus}
</if>
<if test="param.empName != null and param.empName.trim() != ''">
and detail.EMP_NAME like concat('%',replace(replace(#{param.empName},'_','\_'),'%','\%'),'%')
</if>
<if test="param.empIdcardNo != null and param.empIdcardNo.trim() != ''">
and detail.EMP_IDCARD_NO like concat('%',replace(replace(#{param.empIdcardNo},'_','\_'),'%','\%'),'%')
</if>
<if test="param.insuranceCompanyName != null and param.insuranceCompanyName.trim() != ''">
and detail.INSURANCE_COMPANY_NAME like concat('%',replace(replace(#{param.insuranceCompanyName},'_','\_'),'%','\%'),'%')
</if>
ORDER BY detail.CREATE_TIME DESC
</select>
<select id="getInsuranceList" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceListVO">
select detail.id as id,
detail.ORDER_NO as orderNo,
detail.EMP_NAME as empName,
detail.EMP_IDCARD_NO as empIdcardNo,
detail.BUY_TYPE as buyType,
detail.POST as post,
detail.DEPT_NO as deptNo,
detail.POLICY_START as policyStart,
detail.POLICY_END as policyEnd,
detail.INSURANCE_COMPANY_NAME as insuranceCompanyName,
detail.INSURANCE_TYPE_NAME as insuranceTypeName,
detail.BUY_STANDARD as buyStandard,
detail.CREATE_NAME as createName,
detail.BUY_HANDLE_STATUS as buyHandleStatus,
detail.SETTLE_TYPE as settleType,
detail.SETTLE_MONTH as settleMonth
from t_insurance_detail detail
where detail.DELETE_FLAG = 0
<if test="param.deptNo != null and param.deptNo.trim() != ''">
and detail.DEPT_NO like concat('%',replace(replace(#{deptNo},'_','\_'),'%','\%'),'%')
</if>
<if test="param.buyHandleStatus != null">
and detail.BUY_HANDLE_STATUS = #{param.buyHandleStatus}
</if>
<if test="param.empName != null and param.empName.trim() != ''">
and detail.EMP_NAME like concat('%',replace(replace(#{param.empName},'_','\_'),'%','\%'),'%')
</if>
<if test="param.empIdcardNo != null and param.empIdcardNo.trim() != ''">
and detail.EMP_IDCARD_NO like concat('%',replace(replace(#{param.empIdcardNo},'_','\_'),'%','\%'),'%')
</if>
<if test="param.insuranceCompanyName != null and param.insuranceCompanyName.trim() != ''">
and detail.INSURANCE_COMPANY_NAME like concat('%',replace(replace(#{param.insuranceCompanyName},'_','\_'),'%','\%'),'%')
</if>
ORDER BY detail.CREATE_TIME DESC
</select>
<select id="getInsuranceDetailById" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceDetailVO">
select
detail.EMP_NAME as empName,
detail.EMP_IDCARD_NO as empIdcardNo,
detail.BUY_TYPE as buyType,
detail.DEPT_NO as deptNo,
detail.POST as post,
detail.POLICY_START as policyStart,
detail.POLICY_END as policyEnd,
detail.POLICY_EFFECT as policyEffect,
detail.POLICY_NO as policyNo,
detail.INSURANCE_TYPE_NAME as insuranceTypeName,
detail.BUY_STANDARD as buyStandard,
detail.MEDICAL_QUOTA as medicalQuota,
detail.DIE_DISABLE_QUOTA as dieDisableQuota,
detail.INSURANCE_COMPANY_NAME as insuranceCompanyName,
detail.SETTLE_TYPE as premiumType,
detail.ESTIMATE_PREMIUM as estimatePremium,
detail.ACTUAL_PREMIUM as actualPremium,
detail.INVOICE_NO as invoiceNo,
detail.SETTLE_TYPE as settleType,
detail.SETTLE_MONTH as settleMonth,
detail.BUY_HANDLE_STATUS as buyHandleStatus,
detail.REDUCE_HANDLE_STATUS as reduceHandleStatus,
tis.SETTLE_HANDLE_STATUS as settleHandleStatus,
detail.IS_USE as isUse,
detail.IS_EFFECT as isEffect,
detail.IS_OVERDUE as isOverdue,
detail.INSURANCE_PROVINCE_NAME as insuranceProvinceName,
detail.INSURANCE_CITY_NAME as insuranceCityName,
detail.INSURANCE_HANDLE_PROVINCE_NAME as insuranceHandleProvinceName,
detail.INSURANCE_HANDLE_CITY_NAME as insuranceHandleCityName,
detail.CREATE_NAME as createName,
detail.CREATE_TIME as createTime
from t_insurance_detail detail
left join t_insurance_settle tis on detail.DEFAULT_SETTLE_ID = tis.ID
where detail.ID = #{id}
</select>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!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.TInsuranceReplaceMapper">
<resultMap id="BaseResultMap" type="com.yifu.cloud.plus.v1.yifu.insurances.entity.TInsuranceReplace">
<id property="id" column="ID" jdbcType="VARCHAR"/>
<result property="fromInsuranceDetailId" column="FROM_INSURANCE_DETAIL_ID" jdbcType="VARCHAR"/>
<result property="toInsuranceDetailId" column="TO_INSURANCE_DETAIL_ID" jdbcType="VARCHAR"/>
<result property="originInsuranceDetailId" column="ORIGIN_INSURANCE_DETAIL_ID" jdbcType="VARCHAR"/>
<result property="replaceStatus" column="REPLACE_STATUS" jdbcType="TINYINT"/>
<result property="replaceTime" column="REPLACE_TIME" jdbcType="TIMESTAMP"/>
<result property="createBy" column="CREATE_BY" jdbcType="VARCHAR"/>
<result property="createName" column="CREATE_NAME" jdbcType="VARCHAR"/>
<result property="createTime" column="CREATE_TIME" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
ID,FROM_INSURANCE_DETAIL_ID,TO_INSURANCE_DETAIL_ID,
ORIGIN_INSURANCE_DETAIL_ID,REPLACE_STATUS,REPLACE_TIME,
CREATE_BY,CREATE_NAME,CREATE_TIME
</sql>
</mapper>
......@@ -494,6 +494,12 @@ public class TForecastLibrary extends BaseEntity {
@ExcelAttribute(name = "数据同步:0未同步;1已同步")
@ExcelProperty("数据同步:0未同步;1已同步")
private Integer dataPush;
/**
* 类型:0社保;1公积金
*/
@ExcelAttribute(name = "类型:0社保;1公积金")
@ExcelProperty("类型:0社保;1公积金")
private Integer dataType;
@TableField(exist = false)
private List<String> idList;
......
package com.yifu.cloud.plus.v1.yifu.social.constants;
/**
* @author hgw2
* @description 社保固定文字
* @date 2022/7/19
*/
public class SocialConstants {
// 社保补缴配置有误!
public static final String SOCIAL_SET_ERROR = "社保补缴配置有误!";
}
......@@ -19,7 +19,7 @@ package com.yifu.cloud.plus.v1.yifu.social.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage;
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.log.annotation.SysLog;
import com.yifu.cloud.plus.v1.yifu.social.entity.TForecastLibrary;
......@@ -28,11 +28,9 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import org.springframework.http.HttpHeaders;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
......@@ -147,4 +145,27 @@ public class TForecastLibraryController {
public void export(HttpServletResponse response, @RequestBody TForecastLibrary searchVo) {
tForecastLibraryService.listExport(response, searchVo);
}
/**
* @param payMonths 缴纳月
* @param empIdCard 身份证
* @param settleDomainIds 项目ids
* @Description: 按缴纳月重新生成
* @Author: hgw
* @Date: 2022/7/18 17:12
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.Boolean>
**/
@Operation(summary = "按缴纳月重新生成", description = "按缴纳月重新生成:hasPermission('social_tforecastlibrary_create')")
@SysLog("按缴纳月重新生成")
@PostMapping("/createForecastlibary")
@PreAuthorize("@pms.hasPermission('social_tforecastlibrary_create')")
public R<Boolean> createForecastlibary(@RequestParam String payMonths,
@RequestParam(value = "empIdCard", required = false) String empIdCard,
@RequestParam(value = "settleDomainIds", required = false) String settleDomainIds) {
if (Common.isEmpty(empIdCard) && Common.isEmpty(settleDomainIds)) {
return R.failed("参数有误:身份证或项目ID不可为空!");
}
return tForecastLibraryService.createForecastlibary(payMonths, empIdCard, settleDomainIds);
}
}
......@@ -44,6 +44,16 @@ public interface SysBaseSetInfoMapper extends BaseMapper<SysBaseSetInfo> {
List<SysBaseSetInfo> getAllByEntity(@Param("sysBaseSetInfo")SysBaseSetInfo sysBaseSetInfo);
/**
* 获取基数配置
* @Author fxj
* @Date 2019-10-08
* @param sysBaseSetInfo
* @return
**/
List<SysBaseSetInfo> getSysBaseSetInfoNoPage(@Param("sysBaseSetInfo")SysBaseSetInfo sysBaseSetInfo);
/**
* @Author fxj
* @Description 获取对应户名称的公积金基数信息
......
......@@ -23,6 +23,9 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.social.entity.TSocialFundInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 社保公积金查询表
*
......@@ -37,4 +40,21 @@ public interface TSocialFundInfoMapper extends BaseMapper<TSocialFundInfo> {
* @return
*/
IPage<TSocialFundInfo> getTSocialFundInfoPage(Page<TSocialFundInfo> page, @Param("tSocialFundInfo") TSocialFundInfo tSocialFundInfo);
/**
* @Description: 获取可生成预估的社保
* @Author: hgw
* @Date: 2022/7/19 19:09
* @return: java.util.List<com.yifu.cloud.plus.v1.yifu.social.entity.TSocialFundInfo>
**/
List<TSocialFundInfo> getSocialList(@Param("empIdCard") String empIdCard, @Param("settleDomainIds") List<String> settleDomainIds);
/**
* @Description: 获取可生成预估的公积金
* @Author: hgw
* @Date: 2022/7/19 19:09
* @return: java.util.List<com.yifu.cloud.plus.v1.yifu.social.entity.TSocialFundInfo>
**/
List<TSocialFundInfo> getFundList(@Param("empIdCard") String empIdCard, @Param("settleDomainIds") List<String> settleDomainIds);
}
......@@ -20,12 +20,13 @@ package com.yifu.cloud.plus.v1.yifu.social.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.social.entity.TAgentConfig;
import com.yifu.cloud.plus.v1.yifu.social.entity.TForecastLibrary;
import com.yifu.cloud.plus.v1.yifu.social.entity.TSocialFundInfo;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.util.HashMap;
import java.util.List;
/**
......@@ -46,4 +47,26 @@ public interface TForecastLibraryService extends IService<TForecastLibrary> {
void listExport(HttpServletResponse response, TForecastLibrary searchVo);
List<TForecastLibrary> noPageDiy(TForecastLibrary searchVo);
/**
* @param payMonths 缴纳月
* @param empIdCard 身份证
* @param settleDomainIds 项目id
* @Description: 按缴纳月重新生成
* @Author: hgw
* @Date: 2022/7/18 17:11
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.Boolean>
**/
R<Boolean> createForecastlibary(String payMonths, String empIdCard, String settleDomainIds);
/**
* @Description: 填充预估实际金额
* @Author: hgw
* @Date: 2020/10/10 16:45
* @return: com.yifu.cloud.v1.hrms.api.entity.TForecastLibrary
**/
TForecastLibrary initForecastLibrary(TForecastLibrary library
, TSocialFundInfo socialInfo, TSocialFundInfo fund, Integer month, boolean isReduceFund
, boolean isReduceSocial, HashMap<String, TAgentConfig> agentConfigMap);
}
......@@ -25,22 +25,30 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
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.ExcelUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.util.*;
import com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity;
import com.yifu.cloud.plus.v1.yifu.social.constants.SocialConstants;
import com.yifu.cloud.plus.v1.yifu.social.entity.SysBaseSetInfo;
import com.yifu.cloud.plus.v1.yifu.social.entity.TAgentConfig;
import com.yifu.cloud.plus.v1.yifu.social.entity.TForecastLibrary;
import com.yifu.cloud.plus.v1.yifu.social.entity.TSocialFundInfo;
import com.yifu.cloud.plus.v1.yifu.social.mapper.SysBaseSetInfoMapper;
import com.yifu.cloud.plus.v1.yifu.social.mapper.TAgentConfigMapper;
import com.yifu.cloud.plus.v1.yifu.social.mapper.TForecastLibraryMapper;
import com.yifu.cloud.plus.v1.yifu.social.mapper.TSocialFundInfoMapper;
import com.yifu.cloud.plus.v1.yifu.social.service.TForecastLibraryService;
import com.yifu.cloud.plus.v1.yifu.social.util.ServiceUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
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.ArrayList;
import java.util.List;
import java.time.LocalDateTime;
import java.util.*;
/**
* 预估费用
......@@ -50,7 +58,15 @@ import java.util.List;
*/
@Log4j2
@Service
@RequiredArgsConstructor
public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMapper, TForecastLibrary> implements TForecastLibraryService {
private final TAgentConfigMapper agentConfigMapper;
private final TSocialFundInfoMapper socialFundInfoMapper;
private final SysBaseSetInfoMapper sysBaseSetInfoMapper;
/**
* 预估费用简单分页查询
*
......@@ -162,4 +178,1011 @@ public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMap
}
return wrapper;
}
/**
* @param payMonths 缴纳月
* @param empIdCard 身份证
* @param settleDomainIds
* @Description: 按缴纳月生成
* @Author: hgw
* @Date: 2022/7/19 18:58
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.Boolean>
**/
@Override
public R<Boolean> createForecastlibary(String payMonths, String empIdCard, String settleDomainIds) {
//定义未推送的按条件查询得到的预估数据
List<TForecastLibrary> librarySocialList = null;
//定义已推送的按条件查询得到的预估数据
List<TForecastLibrary> librarySocialListTemp = null;
//定义未推送的按条件查询得到的预估数据
List<TForecastLibrary> libraryFundList = null;
//定义已推送的按条件查询得到的预估数据
List<TForecastLibrary> libraryFundListTemp = null;
List<String> settleDomainIdList = Common.initStrToList(settleDomainIds, CommonConstants.COMMA_STRING);
List<String> payMonthList = Common.initStrToList(payMonths, CommonConstants.COMMA_STRING);
if (Common.isEmpty(payMonths) || payMonthList == null) {
return R.failed("月份必填!");
}
//查询出所有符合条件的社保数据
List<TSocialFundInfo> socialInfoList = null;
List<TSocialFundInfo> fundList = null;
// 查询当年所有的社保临时政策用于生成预估数据
List<TAgentConfig> configList = agentConfigMapper.selectList(Wrappers.<TAgentConfig>query().lambda()
.eq(TAgentConfig::getOpenFlag, CommonConstants.ZERO_INT));
HashMap<String, TAgentConfig> agentConfigHashMap = new HashMap<>();
if (Common.isNotNull(configList) && Common.isNotNull(payMonthList)) {
initConfigByPayMonths(configList, payMonthList, agentConfigHashMap);
}
//查询出所有对应条件的预估数、社保数据、公积金数据据用于重新生成
if (Common.isNotNull(empIdCard)) {
librarySocialList = baseMapper.selectList(Wrappers.<TForecastLibrary>query().lambda()
.eq(TForecastLibrary::getEmpIdcard, empIdCard)
.eq(TForecastLibrary::getDataType, CommonConstants.ZERO_INT)
.in(TForecastLibrary::getSocialPayMonth, payMonthList)
.eq(TForecastLibrary::getDataPush, CommonConstants.ZERO_INT));
librarySocialListTemp = baseMapper.selectList(Wrappers.<TForecastLibrary>query().lambda()
.eq(TForecastLibrary::getEmpIdcard, empIdCard)
.eq(TForecastLibrary::getDataType, CommonConstants.ZERO_INT)
.in(TForecastLibrary::getSocialPayMonth, payMonthList)
.eq(TForecastLibrary::getDataPush, CommonConstants.ONE_INT));
libraryFundList = baseMapper.selectList(Wrappers.<TForecastLibrary>query().lambda()
.eq(TForecastLibrary::getEmpIdcard, empIdCard)
.eq(TForecastLibrary::getDataType, CommonConstants.ONE_INT)
.in(TForecastLibrary::getProvidentPayMonth, payMonthList)
.eq(TForecastLibrary::getDataPush, CommonConstants.ZERO_INT));
libraryFundListTemp = baseMapper.selectList(Wrappers.<TForecastLibrary>query().lambda()
.eq(TForecastLibrary::getEmpIdcard, empIdCard)
.eq(TForecastLibrary::getDataType, CommonConstants.ONE_INT)
.in(TForecastLibrary::getProvidentPayMonth, payMonthList)
.eq(TForecastLibrary::getDataPush, CommonConstants.ONE_INT));
socialInfoList = socialFundInfoMapper.getSocialList(empIdCard, null);
fundList = socialFundInfoMapper.getFundList(empIdCard, null);
} else {
librarySocialList = baseMapper.selectList(Wrappers.<TForecastLibrary>query().lambda()
.in(TForecastLibrary::getSettleDomainId, settleDomainIdList)
.eq(TForecastLibrary::getDataType, CommonConstants.ZERO_INT)
.in(TForecastLibrary::getSocialPayMonth, payMonthList)
.eq(TForecastLibrary::getDataPush, CommonConstants.ZERO_INT));
librarySocialListTemp = baseMapper.selectList(Wrappers.<TForecastLibrary>query().lambda()
.in(TForecastLibrary::getSettleDomainId, settleDomainIdList)
.eq(TForecastLibrary::getDataType, CommonConstants.ZERO_INT)
.in(TForecastLibrary::getSocialPayMonth, payMonthList)
.eq(TForecastLibrary::getDataPush, CommonConstants.ONE_INT));
libraryFundList = baseMapper.selectList(Wrappers.<TForecastLibrary>query().lambda()
.in(TForecastLibrary::getSettleDomainId, settleDomainIdList)
.eq(TForecastLibrary::getDataType, CommonConstants.ONE_INT)
.in(TForecastLibrary::getProvidentPayMonth, payMonthList)
.eq(TForecastLibrary::getDataPush, CommonConstants.ZERO_INT));
libraryFundListTemp = baseMapper.selectList(Wrappers.<TForecastLibrary>query().lambda()
.in(TForecastLibrary::getSettleDomainId, settleDomainIdList)
.eq(TForecastLibrary::getDataType, CommonConstants.ONE_INT)
.in(TForecastLibrary::getProvidentPayMonth, payMonthList)
.eq(TForecastLibrary::getDataPush, CommonConstants.ONE_INT));
socialInfoList = socialFundInfoMapper.getSocialList(null, settleDomainIdList);
fundList = socialFundInfoMapper.getFundList(null, settleDomainIdList);
}
if (Common.isEmpty(socialInfoList)
&& Common.isEmpty(fundList)) {
return R.failed("无需要重新生成的数据(无数据或数据已结算不可重新生成!)");
}
//先删除然后重新生成
if (Common.isNotNull(librarySocialList)) {
baseMapper.deleteBatchIds(librarySocialList);
}
if (Common.isNotNull(libraryFundList)) {
baseMapper.deleteBatchIds(libraryFundList);
}
boolean flag;
// 已推送的预估明细Map
HashMap<String, TForecastLibrary> socialPushMap = new HashMap<>();
HashMap<String, TForecastLibrary> fundPushMap = new HashMap<>();
// Map的key
String sfMapKey;
if (Common.isNotNull(librarySocialListTemp)) {
TForecastLibrary libraryOld;
for (TForecastLibrary library : librarySocialListTemp) {
sfMapKey = this.getMapKey(library.getEmpIdcard(), library.getSettleDomainId(), library.getSocialPayMonth(), library.getSocialCreateMonth());
libraryOld = socialPushMap.get(sfMapKey);
if (libraryOld != null) {
this.getChangeAddData(libraryOld, library);
}
socialPushMap.put(sfMapKey, library);
}
}
if (Common.isNotNull(libraryFundListTemp)) {
TForecastLibrary libraryOld;
for (TForecastLibrary library : libraryFundListTemp) {
sfMapKey = this.getMapKey(library.getEmpIdcard(), library.getSettleDomainId(), library.getProvidentPayMonth(), library.getProvidentCreateMonth());
libraryOld = fundPushMap.get(sfMapKey);
if (libraryOld != null) {
this.getChangeAddData(libraryOld, library);
}
fundPushMap.put(sfMapKey, library);
}
}
Map<String, TForecastLibrary> saveLibraryMap = new HashMap<>();
TForecastLibrary tForecastLibrary;
String createMonth;
boolean isReduceSocial = false;
boolean isReduceFund = false;
for (String payMonth : payMonthList) {
//封装社保预估数据
if (Common.isNotNull(socialInfoList)) {
for (TSocialFundInfo tSocialInfo : socialInfoList) {
createMonth = ServiceUtil.initCreateMonth(tSocialInfo.getCreateTime(), payMonth);
sfMapKey = this.getMapKey(tSocialInfo.getEmpIdcard(), tSocialInfo.getSettleDomain(), payMonth, createMonth);
// 变更:已推送的,计算变更值
tForecastLibrary = socialPushMap.get(sfMapKey);
if (null != tForecastLibrary) {
this.getChangeReduceData(tSocialInfo, tForecastLibrary);
}
//起缴月份在要生成的月份前不处理
if (Integer.parseInt(payMonth) < DateUtil.formatDateInt(tSocialInfo.getSocialStartDate())) {
continue;
}
flag = CommonConstants.ZERO_STRING.equals(tSocialInfo.getCanOverpay()) && (null == tSocialInfo.getOverpayNumber() || null == tSocialInfo.getHaveThisMonth() || null == tSocialInfo.getSocialStartDate());
if (flag) {
return R.failed("员工" + tSocialInfo.getEmpName() + ":" + tSocialInfo.getEmpIdcard() + SocialConstants.SOCIAL_SET_ERROR);
}
// 初始化社保
initSocialLibary(payMonth, saveLibraryMap, tSocialInfo, isReduceFund, agentConfigHashMap, tForecastLibrary, sfMapKey);
}
}
//封装公积金预估数据
if (Common.isNotNull(fundList)) {
for (TSocialFundInfo providentFund : fundList) {
createMonth = ServiceUtil.initCreateMonth(providentFund.getCreateTime(), payMonth);
sfMapKey = this.getMapKey(providentFund.getEmpIdcard(), providentFund.getSettleDomain(), payMonth, createMonth);
// 变更:已推送的,计算变更值
tForecastLibrary = fundPushMap.get(sfMapKey);
if (null != tForecastLibrary) {
this.getChangeReduceData(providentFund, tForecastLibrary);
}
//起缴月份在要生成的月份后不处理
if (Integer.parseInt(payMonth) < DateUtil.formatDateInt(providentFund.getProvidentStart())) {
continue;
}
flag = CommonConstants.ZERO_STRING.equals(providentFund.getCanOverpay()) && (null == providentFund.getOverpayNumber() || null == providentFund.getHaveThisMonth() || null == providentFund.getProvidentStart());
if (flag) {
return R.failed("员工" + providentFund.getEmpName() + ":" + providentFund.getEmpIdcard() + SocialConstants.SOCIAL_SET_ERROR);
}
// 初始化公积金
initFundLibary(payMonth, saveLibraryMap, providentFund, isReduceSocial, tForecastLibrary, sfMapKey);
}
}
}
boolean isSaveAndUpdate = false;
for (TForecastLibrary library : saveLibraryMap.values()) {
if (Common.isEmpty(library.getSocialId()) && Common.isEmpty(library.getProvidentId())) {
continue;
}
if (Common.isNotNull(library.getId())) {
baseMapper.updateById(library);
} else {
library.setCreateTime(LocalDateTime.now());
baseMapper.insert(library);
}
isSaveAndUpdate = true;
}
if (isSaveAndUpdate) {
return R.ok(null, "执行成功!");
} else {
return R.failed("执行失败!无需更新的数据!");
}
}
private String getMapKey(String empIdcard, String settleDomainId
, String socialPayMonth, String socialCreateMonth) {
StringBuilder sfMapKey;
sfMapKey = new StringBuilder(empIdcard);
// 获取key
sfMapKey.append(CommonConstants.DOWN_LINE_STRING).append(settleDomainId);
sfMapKey.append(CommonConstants.DOWN_LINE_STRING).append(socialPayMonth);
sfMapKey.append(CommonConstants.DOWN_LINE_STRING).append(socialCreateMonth);
return sfMapKey.toString();
}
/**
* @param libraryOld
* @param library
* @Description: 已推送的数据,社保公积金金额累加
* @Author: hgw
* @Date: 2022/7/20 11:16
* @return: void
**/
private void getChangeAddData(TForecastLibrary libraryOld, TForecastLibrary library) {
//单位社保
library.setUnitPensionFee(BigDecimalUtils.safeAdd(libraryOld.getUnitPensionFee(), library.getUnitPensionFee()));
library.setUnitMedicalFee(BigDecimalUtils.safeAdd(libraryOld.getUnitMedicalFee(), library.getUnitMedicalFee()));
library.setUnitBirthFee(BigDecimalUtils.safeAdd(libraryOld.getUnitBirthFee(), library.getUnitBirthFee()));
library.setUnitWorkInjuryFee(BigDecimalUtils.safeAdd(libraryOld.getUnitWorkInjuryFee(), library.getUnitWorkInjuryFee()));
library.setUnitUnemploymentFee(BigDecimalUtils.safeAdd(libraryOld.getUnitUnemploymentFee(), library.getUnitUnemploymentFee()));
library.setUnitBitailmentFee(BigDecimalUtils.safeAdd(libraryOld.getUnitBitailmentFee(), library.getUnitBitailmentFee()));
library.setUnitInterestFee(BigDecimalUtils.safeAdd(libraryOld.getUnitInterestFee(), library.getUnitInterestFee()));
library.setUnitSocialSum(BigDecimalUtils.safeAdd(libraryOld.getUnitSocialSum(), library.getUnitSocialSum()));
// 个人社保
library.setPersonalPensionFee(BigDecimalUtils.safeAdd(libraryOld.getPersonalPensionFee(), library.getPersonalPensionFee()));
library.setPersonalMedicalFee(BigDecimalUtils.safeAdd(libraryOld.getPersonalMedicalFee(), library.getPersonalMedicalFee()));
library.setPersonalUnemploymentFee(BigDecimalUtils.safeAdd(libraryOld.getPersonalUnemploymentFee(), library.getPersonalUnemploymentFee()));
library.setPersonalInterestFee(BigDecimalUtils.safeAdd(libraryOld.getPersonalUnemploymentFee(), library.getPersonalUnemploymentFee()));
library.setPersonalBigailmentFee(BigDecimalUtils.safeAdd(libraryOld.getPersonalBigailmentFee(), library.getPersonalBigailmentFee()));
library.setPersonalSocialSum(BigDecimalUtils.safeAdd(libraryOld.getPersonalSocialSum(), library.getPersonalSocialSum()));
// 单位公积金
library.setUnitFundSum(BigDecimalUtils.safeAdd(libraryOld.getUnitFundSum(), library.getUnitFundSum()));
// 个人公积金
library.setPersonalFundSum(BigDecimalUtils.safeAdd(libraryOld.getPersonalFundSum(), library.getPersonalFundSum()));
}
/**
* @param socialFund
* @param libraryOld
* @Description: 获取变更的部分
* @Author: hgw
* @Date: 2022/7/20 11:29
* @return: void
**/
private void getChangeReduceData(TSocialFundInfo socialFund, TForecastLibrary libraryOld) {
//单位社保
libraryOld.setUnitPensionFee(BigDecimalUtils.safeSubtract(libraryOld.getUnitPensionFee(), socialFund.getUnitPersionMoney()));
libraryOld.setUnitMedicalFee(BigDecimalUtils.safeSubtract(libraryOld.getUnitMedicalFee(), socialFund.getUnitMedicalMoney()));
libraryOld.setUnitBirthFee(BigDecimalUtils.safeSubtract(libraryOld.getUnitBirthFee(), socialFund.getUnitBirthMoney()));
libraryOld.setUnitWorkInjuryFee(BigDecimalUtils.safeSubtract(libraryOld.getUnitWorkInjuryFee(), socialFund.getUnitInjuryMoney()));
libraryOld.setUnitUnemploymentFee(BigDecimalUtils.safeSubtract(libraryOld.getUnitUnemploymentFee(), socialFund.getUnitUnemploymentMoney()));
libraryOld.setUnitBitailmentFee(BigDecimalUtils.safeSubtract(libraryOld.getUnitBitailmentFee(), socialFund.getUnitBigailmentMoney()));
libraryOld.setUnitInterestFee(BigDecimalUtils.safeSubtract(libraryOld.getUnitInterestFee(), socialFund.getUnitInterestFee()));
libraryOld.setUnitSocialSum(BigDecimalUtils.safeSubtract(libraryOld.getUnitSocialSum(), socialFund.getUnitSocialSum()));
// 个人社保
libraryOld.setPersonalPensionFee(BigDecimalUtils.safeSubtract(libraryOld.getPersonalPensionFee(), socialFund.getPersonalPersionMoney()));
libraryOld.setPersonalMedicalFee(BigDecimalUtils.safeSubtract(libraryOld.getPersonalMedicalFee(), socialFund.getPersonalMedicalMoney()));
libraryOld.setPersonalUnemploymentFee(BigDecimalUtils.safeSubtract(libraryOld.getPersonalUnemploymentFee(), socialFund.getPersonalUnemploymentMoney()));
libraryOld.setPersonalInterestFee(BigDecimalUtils.safeSubtract(libraryOld.getPersonalUnemploymentFee(), socialFund.getPersonalUnemploymentMoney()));
libraryOld.setPersonalBigailmentFee(BigDecimalUtils.safeSubtract(libraryOld.getPersonalBigailmentFee(), socialFund.getPersonalBigailmentMoney()));
libraryOld.setPersonalSocialSum(BigDecimalUtils.safeSubtract(libraryOld.getPersonalSocialSum(), socialFund.getPersonalSocialSum()));
// 单位公积金
libraryOld.setUnitFundSum(BigDecimalUtils.safeSubtract(libraryOld.getUnitFundSum(), socialFund.getUnitFundSum()));
// 个人公积金
libraryOld.setPersonalFundSum(BigDecimalUtils.safeSubtract(libraryOld.getPersonalFundSum(), socialFund.getPersonalFundSum()));
}
private void initConfigByPayMonths(List<TAgentConfig> configList, Collection<String> payMonths, HashMap<String, TAgentConfig> agentConfigHashMap) {
for (TAgentConfig config : configList) {
for (String payMonth : payMonths) {
if (ServiceUtil.convertStringToInt(config.getStartMonth()) <= ServiceUtil.convertStringToInt(payMonth)
&& ServiceUtil.convertStringToInt(config.getEndMonth()) >= ServiceUtil.convertStringToInt(payMonth)) {
if (Common.isNotNull(config.getCity())) {
agentConfigHashMap.put(config.getProvince() + CommonConstants.DOWN_LINE_STRING + config.getCity() + CommonConstants.DOWN_LINE_STRING + payMonth + CommonConstants.DOWN_LINE_STRING + config.getTarget(), config);
} else {
agentConfigHashMap.put(config.getProvince() + CommonConstants.DOWN_LINE_STRING + "null" + CommonConstants.DOWN_LINE_STRING + payMonth + CommonConstants.DOWN_LINE_STRING + config.getTarget(), config);
}
}
}
}
}
/**
* @Description: 填充key的基本信息
* @Author: hgw
* @Date: 2022-7-19 15:30:45
* @return: void
**/
private void getMapKey(StringBuilder mapKeyBuilder, String socialProvince, String socialCity, String socialTown) {
if (Common.isNotNull(socialProvince)) {
mapKeyBuilder.append(CommonConstants.DOWN_LINE_STRING).append(socialProvince);
}
if (Common.isNotNull(socialCity)) {
mapKeyBuilder.append(CommonConstants.DOWN_LINE_STRING).append(socialCity);
} else if (Common.isNotNull(socialProvince) && "12".equals(socialProvince)) {
mapKeyBuilder.append(CommonConstants.DOWN_LINE_STRING).append("135");
}
if (Common.isNotNull(socialTown)) {
mapKeyBuilder.append(CommonConstants.DOWN_LINE_STRING).append(socialTown);
}
}
private void initSocialLibary(String payMonth, Map<String, TForecastLibrary> saveLibraryMap
, TSocialFundInfo tSocialInfo, boolean isReduceFund, HashMap<String, TAgentConfig> agentConfigMap
, TForecastLibrary lib, String sfMapKey) {
if (null == lib) {
lib = new TForecastLibrary();
}
lib.setDataType(CommonConstants.ZERO_INT);
lib.setEmpId(tSocialInfo.getEmpId());
lib.setEmpIdcard(tSocialInfo.getEmpIdcard());
lib.setEmpName(tSocialInfo.getEmpName());
lib.setEmpNo(tSocialInfo.getEmpNo());
lib.setSocialCreateMonth(ServiceUtil.initCreateMonth(tSocialInfo.getCreateTime(), payMonth));
lib.setProvidentCreateMonth(lib.getSocialCreateMonth());
lib.setSocialPayMonth(payMonth);
//同时处理公积金日期
lib.setProvidentPayMonth(payMonth);
lib.setSocialProvince(tSocialInfo.getSocialProvince());
lib.setSocialCity(tSocialInfo.getSocialCity());
lib.setSocialTown(tSocialInfo.getSocialTown());
lib.setSocialId(tSocialInfo.getId());
lib.setUnitId(tSocialInfo.getUnitId());
lib.setSettleDomainId(tSocialInfo.getSettleDomain());
//判断是否允许补缴 是否可补缴 0:是
Integer monthT = this.getOverpayMonth(tSocialInfo);
//初始化社保派减状态 按派减时间派单对应缴纳月是否已派减社保
boolean isReduceSocial;
if (null != tSocialInfo.getSocialReduceDate()) {
isReduceSocial = Integer.parseInt(payMonth) >= DateUtil.formatDateInt(tSocialInfo.getSocialReduceDate());
} else {
isReduceSocial = false;
}
lib = initForecastLibrary(lib, tSocialInfo, null, monthT, isReduceFund, isReduceSocial, agentConfigMap);
saveLibraryMap.put(sfMapKey, lib);
}
/**
* @Description: 获取可补缴的最大月份
* @Author: hgw
* @Date: 2020/10/10 15:26
* @return: java.lang.Integer
**/
private Integer getOverpayMonth(TSocialFundInfo tSocialInfo) {
Integer overpayMonth = null;
if (CommonConstants.ZERO_STRING.equals(tSocialInfo.getCanOverpay())) {
//补缴是否含当月: 含当月
if (CommonConstants.ZERO_STRING.equals(tSocialInfo.getHaveThisMonth())) {
overpayMonth = Integer.parseInt(DateUtil.getYearAndMonth(tSocialInfo.getCreateTime(), 0));
//补缴是否含当月: 不含含当月
} else {
overpayMonth = Integer.parseInt(DateUtil.getYearAndMonth(tSocialInfo.getCreateTime(), CommonConstants.ONE_INT_NEGATE));
}
}
return overpayMonth;
}
@Override
public TForecastLibrary initForecastLibrary(TForecastLibrary library
, TSocialFundInfo socialInfo, TSocialFundInfo fund, Integer month, boolean isReduceFund
, boolean isReduceSocial, HashMap<String, TAgentConfig> agentConfigMap) {
if (null != socialInfo && !isReduceSocial) {
library.setSocialId(socialInfo.getId());
library.setUnitBitailmentFee(BigDecimal.ZERO);
library.setPersonalBigailmentFee(BigDecimal.ZERO);
// 处理大病以外的金额 临时政策影响生成的预估数据(2020-08-03新增逻辑)
// 获取省市临时政策 0 单位 1 个人 2 全部
TAgentConfig configAll = getAgentConfig(agentConfigMap, socialInfo, library.getSocialPayMonth(), CommonConstants.TWO_STRING);
TAgentConfig configUnit = getAgentConfig(agentConfigMap, socialInfo, library.getSocialPayMonth(), CommonConstants.ZERO_STRING);
TAgentConfig configPersonal = getAgentConfig(agentConfigMap, socialInfo, library.getSocialPayMonth(), CommonConstants.ONE_STRING);
// 基数配置
SysBaseSetInfo sysBaseSetInfo = this.getSysBaseSetInfo(CommonConstants.ZERO_STRING, socialInfo.getSocialHousehold()
, library.getSocialPayMonth(), socialInfo.getSocialProvince(), socialInfo.getSocialCity(), socialInfo.getSocialTown());
// 初始化大病:
this.initLibraryBigMoneyBySocial(library, socialInfo, sysBaseSetInfo);
initUnitAndPersonalLibrary(library, socialInfo, sysBaseSetInfo);
if (null != configAll || null != configUnit || null != configPersonal) {
if (null != configPersonal) {
initPersonalLibByConfig(library, configPersonal);
} else if (null != configAll) {
initPersonalLibByConfig(library, configAll);
}
if (null != configUnit) {
initUnitLibByConfig(library, configUnit);
} else if (null != configAll) {
initUnitLibByConfig(library, configAll);
}
}
// 补缴处理 不需要补缴的险种置为零
if (null != month && Integer.parseInt(library.getSocialPayMonth()) <= month) {
// 是否补缴大病:0是 1否
if (CommonConstants.ONE_STRING.equals(socialInfo.getInsuranceBigailment())) {
library.setUnitBitailmentFee(BigDecimal.ZERO);
library.setPersonalBigailmentFee(BigDecimal.ZERO);
}
// 是否补缴养老:0是1 否
if (CommonConstants.ONE_STRING.equals(socialInfo.getInsurancePension())) {
library.setUnitPensionFee(BigDecimal.ZERO);
library.setPersonalPensionFee(BigDecimal.ZERO);
}
// 是否补缴医疗:0是1否
if (CommonConstants.ONE_STRING.equals(socialInfo.getInsuranceMedical())) {
library.setUnitMedicalFee(BigDecimal.ZERO);
library.setPersonalMedicalFee(BigDecimal.ZERO);
}
// 是否补缴生育
if (CommonConstants.ONE_STRING.equals(socialInfo.getInsuranceBirth())) {
library.setUnitBirthFee(BigDecimal.ZERO);
}
// 是否补缴工伤
if (CommonConstants.ONE_STRING.equals(socialInfo.getInsuranceInjury())) {
library.setUnitWorkInjuryFee(BigDecimal.ZERO);
}
// 是否补缴失业
if (CommonConstants.ONE_STRING.equals(socialInfo.getInsuranceUnemployment())) {
library.setUnitUnemploymentFee(BigDecimal.ZERO);
library.setPersonalUnemploymentFee(BigDecimal.ZERO);
}
}
library.setPersonalSocialSum(BigDecimalUtils.safeAdd(
library.getPersonalBigailmentFee(),
library.getPersonalPensionFee(),
library.getPersonalMedicalFee(),
library.getPersonalInterestFee(),
library.getPersonalUnemploymentFee()));
library.setUnitSocialSum(BigDecimalUtils.safeAdd(
library.getUnitPensionFee(),
library.getUnitMedicalFee(),
library.getUnitBirthFee(),
library.getUnitWorkInjuryFee(),
library.getUnitUnemploymentFee(),
library.getUnitInterestFee(),
library.getUnitBitailmentFee()));
} else if (isReduceSocial) {
library.setUnitSocialSum(BigDecimal.ZERO);
library.setPersonalSocialSum(BigDecimal.ZERO);
library.setUnitPensionFee(BigDecimal.ZERO);
library.setUnitMedicalFee(BigDecimal.ZERO);
library.setUnitBirthFee(BigDecimal.ZERO);
library.setUnitWorkInjuryFee(BigDecimal.ZERO);
library.setUnitUnemploymentFee(BigDecimal.ZERO);
library.setUnitBitailmentFee(BigDecimal.ZERO);
library.setPersonalPensionFee(BigDecimal.ZERO);
library.setPersonalMedicalFee(BigDecimal.ZERO);
library.setPersonalUnemploymentFee(BigDecimal.ZERO);
library.setPersonalBigailmentFee(BigDecimal.ZERO);
library.setSocialId(null);
library.setSocialProvince(null);
library.setSocialCity(null);
library.setSocialTown(null);
}
if (null != fund && !isReduceFund) {
library.setProvidentId(fund.getId());
library.setUnitFundBase(fund.getUnitProvidengCardinal());
library.setPersonalFundBase(fund.getPersonalProvidentCardinal());
library.setUnitFundProp(fund.getUnitProvidentPer());
library.setPersonalFundProp(fund.getPersonalProvidentPer());
library.setPersonalFundSum(fund.getPersonalFundSum());
library.setUnitFundSum(fund.getUnitFundSum());
} else if (isReduceFund) {
library.setProvidentId(null);
library.setUnitFundSum(BigDecimal.ZERO);
library.setPersonalFundSum(BigDecimal.ZERO);
library.setFundProvince(null);
library.setFundCity(null);
library.setFundTown(null);
}
return library;
}
/**
* 获取社保临时政策 优先地市政策 无地市政策 按省政策,即无省也无市的政策 正常生成
*
* @param agentConfigList
* @param tSocialInfo
* @return
* @Author fxj
* @Date 2020-08-03
**/
private TAgentConfig getAgentConfig(HashMap<String, TAgentConfig> agentConfigList
, TSocialFundInfo tSocialInfo, String payMonth, String target) {
if (Common.isNotNull(agentConfigList) && null != tSocialInfo && Common.isNotNull(payMonth)) {
TAgentConfig temp = agentConfigList.get(tSocialInfo.getSocialProvince()
+ CommonConstants.DOWN_LINE_STRING
+ tSocialInfo.getSocialCity()
+ CommonConstants.DOWN_LINE_STRING
+ payMonth
+ CommonConstants.DOWN_LINE_STRING
+ target);
if (null != temp) {
return temp;
} else {
return agentConfigList.get(tSocialInfo.getSocialProvince()
+ CommonConstants.DOWN_LINE_STRING
+ "null"
+ CommonConstants.DOWN_LINE_STRING
+ payMonth
+ CommonConstants.DOWN_LINE_STRING
+ target);
}
}
return null;
}
/**
* @param baseType 0.社保 1.公积金
* @param household (社保、公积金)户
* @param payMonth
* @param province
* @param city
* @param town
* @Description: 查找基数配置
* @Author: hgw
* @Date: 2021/1/4 15:58
* @return: com.yifu.cloud.v1.hrms.api.entity.SysBaseSetInfo
**/
private SysBaseSetInfo getSysBaseSetInfo(String baseType, String household, String payMonth, String province, String city, String town) {
// 基数配置
SysBaseSetInfo sysBaseSetInfo = new SysBaseSetInfo();
sysBaseSetInfo.setBaseType(baseType);
sysBaseSetInfo.setDeleteFlag(CommonConstants.ZERO_STRING);
sysBaseSetInfo.setStatus(CommonConstants.ZERO_INT);
sysBaseSetInfo.setDepartId(household);
if (Common.isNotNull(payMonth)
&& payMonth.length() > 5) {
// 社保缴纳月
String payMonthStr = payMonth.substring(0, 4).concat("-").concat(payMonth.substring(4, 6)).concat("-01 00:00:00");
sysBaseSetInfo.setApplyStartDate(DateUtil.stringToDateByPatten(payMonthStr, DateUtil.DATETIME_PATTERN_SECOND));
} else {
sysBaseSetInfo.setApplyStartDate(new Date());
}
sysBaseSetInfo.setProvince(Integer.parseInt(province));
if (city != null) {
sysBaseSetInfo.setCity(Integer.parseInt(city));
} else {
sysBaseSetInfo.setCity(-1);
}
if (town != null) {
sysBaseSetInfo.setTown(Integer.parseInt(town));
} else {
sysBaseSetInfo.setTown(-1);
}
// 查询符合条件的基数列表
List<SysBaseSetInfo> sysBaseSetInfoList = sysBaseSetInfoMapper.getSysBaseSetInfoNoPage(sysBaseSetInfo);
if (sysBaseSetInfoList != null && !sysBaseSetInfoList.isEmpty()) {
sysBaseSetInfo = sysBaseSetInfoList.get(0);
} else {
// 如果没找到配置,取最新的一条:
sysBaseSetInfo.setApplyStartDate(null);
sysBaseSetInfoList = sysBaseSetInfoMapper.getSysBaseSetInfoNoPage(sysBaseSetInfo);
if (sysBaseSetInfoList != null && !sysBaseSetInfoList.isEmpty()) {
sysBaseSetInfo = sysBaseSetInfoList.get(0);
}
}
return sysBaseSetInfo;
}
/**
* @param library 预估库
* @param socialInfo 社保
* @param sysBaseSetInfo 基数配置
* @Description: 从社保获取大病
* @Author: hgw
* @Date: 2020/11/25 15:51
* @return: void
**/
private void initLibraryBigMoneyBySocial(TForecastLibrary library, TSocialFundInfo socialInfo
, SysBaseSetInfo sysBaseSetInfo) {
if (CommonConstants.ONE_STRING.equals(socialInfo.getPaymentType())) {
// 自定义类型大病随基数配置变化:0不随配置 1随配置 2.单位大病随配置 3个人大病随配置
// 2022-7-20 11:46:32 与房工沟通,派单没这个逻辑,所以都是随配置直接计算
// 直接计算单位大病
this.setBigMoneyBySelfForUnit(library, socialInfo, sysBaseSetInfo);
// 直接计算个人大病
this.setBigMoneyBySelfForPerson(library, socialInfo, sysBaseSetInfo);
// 非自定义,从社保基数配置取信息
} else {
// 大病处理: 0 收取 按派单的社保里的基数和比例来
if (CommonConstants.ZERO_STRING.equals(sysBaseSetInfo.getIsIllness())) {
// 大病收取方式 0.按年 判断当前月份是否收取大病 按年收大病起缴月份收取一次,非当年的 大病 按实际收取月份收取大病金额
this.setBigMoney(library, socialInfo, sysBaseSetInfo, socialInfo.getPaymentType());
// 大病处理: 1 不收取
} else {
library.setUnitBitailmentFee(BigDecimal.ZERO);
library.setPersonalBigailmentFee(BigDecimal.ZERO);
}
}
}
/**
* 初始化单位和个人的预估数据
*
* @param library
* @param socialInfo
* @return
* @Author fxj
* @Date 2020-08-03
**/
private void initUnitAndPersonalLibrary(TForecastLibrary library, TSocialFundInfo socialInfo
, SysBaseSetInfo sysBaseSetInfo) {
initLibrayOfPersonal(library, socialInfo, sysBaseSetInfo);
initLibraryOfUnit(library, socialInfo, sysBaseSetInfo);
}
private void initLibrayOfPersonal(TForecastLibrary library, TSocialFundInfo socialInfo
, SysBaseSetInfo sysBaseSetInfo) {
// 个人养老基数
BigDecimal personalPersionBase = BigDecimal.ZERO;
// 个人医疗基数
BigDecimal personalMedicalBase = BigDecimal.ZERO;
// 个人失业基数
BigDecimal personalUnemploymentBase = BigDecimal.ZERO;
// 个人养老比例
BigDecimal personalPersionPro = BigDecimal.ZERO;
// 个人医疗比例
BigDecimal personalMedicalPro = BigDecimal.ZERO;
// 个人失业比例
BigDecimal personalUnemploymentPro = BigDecimal.ZERO;
// 个人养老金额
BigDecimal personalPersionMoney;
// 个人医疗金额
BigDecimal personalMedicalMoney;
// 个人失业金额
BigDecimal personalUnemploymentMoney;
// 存储基数(最低或最高)
BigDecimal baseLimit;
if (socialInfo != null) {
if (Common.isNotNull(socialInfo.getPaymentType()) && !CommonConstants.ONE_STRING.equals(socialInfo.getPaymentType())) {
if (CommonConstants.ZERO_STRING.equals(socialInfo.getPaymentType())) {
baseLimit = sysBaseSetInfo.getLowerLimit();
} else {
baseLimit = sysBaseSetInfo.getUpperLimit();
}
personalPersionBase = baseLimit;
personalMedicalBase = baseLimit;
personalUnemploymentBase = baseLimit;
personalPersionPro = sysBaseSetInfo.getPersonalPersionPro();
personalMedicalPro = sysBaseSetInfo.getPersonalMedicalPro();
personalUnemploymentPro = sysBaseSetInfo.getPersonalUnemploymentPro();
} else {
personalPersionBase = socialInfo.getPersonalPensionCardinal();
personalMedicalBase = socialInfo.getPersonalMedicalCardinal();
personalUnemploymentBase = socialInfo.getPersonalUnemploymentCardinal();
personalPersionPro = socialInfo.getPersonalPensionPer();
personalMedicalPro = socialInfo.getPersonalMedicalPer();
personalUnemploymentPro = socialInfo.getPersonalUnemploymentPer();
}
}
personalPersionMoney = BigDecimalUtils.safeMultiply(personalPersionBase, personalPersionPro,
CommonConstants.ONE_OF_PERCENT);
personalMedicalMoney = BigDecimalUtils.safeMultiply(personalMedicalBase, personalMedicalPro,
CommonConstants.ONE_OF_PERCENT);
personalUnemploymentMoney = BigDecimalUtils.safeMultiply(personalUnemploymentBase, personalUnemploymentPro,
CommonConstants.ONE_OF_PERCENT);
library.setPersonalPensionBase(personalPersionBase);
library.setPersonalMedicalBase(personalMedicalBase);
library.setPersonalUnemploymentBase(personalUnemploymentBase);
library.setPersonalPersionPro(personalPersionPro);
library.setPersonalMedicalPro(personalMedicalPro);
library.setPersonalUnemploymentPro(personalUnemploymentPro);
library.setPersonalMedicalFee(personalMedicalMoney);
library.setPersonalPensionFee(personalPersionMoney);
library.setPersonalUnemploymentFee(personalUnemploymentMoney);
}
private void initLibraryOfUnit(TForecastLibrary library, TSocialFundInfo socialInfo
, SysBaseSetInfo sysBaseSetInfo) {
// 单位养老基数
BigDecimal unitPersionBase = BigDecimal.ZERO;
// 单位医疗基数
BigDecimal unitMedicalBase = BigDecimal.ZERO;
// 单位失业基数
BigDecimal unitUnemploymentBase = BigDecimal.ZERO;
// 单位工伤基数
BigDecimal unitInjuryBase = BigDecimal.ZERO;
// 单位生育基数
BigDecimal unitBirthBase = BigDecimal.ZERO;
// 单位养老比例
BigDecimal unitPersionPro = BigDecimal.ZERO;
// 单位医疗比例
BigDecimal unitMedicalPro = BigDecimal.ZERO;
// 单位失业比例
BigDecimal unitUnemploymentPro = BigDecimal.ZERO;
// 单位工伤比例
BigDecimal unitInjuryPro = BigDecimal.ZERO;
// 单位生育比例
BigDecimal unitBirthPro = BigDecimal.ZERO;
// 单位养老金额
BigDecimal unitPersionMoney;
// 单位医疗金额
BigDecimal unitMedicalMoney;
// 单位失业金额
BigDecimal unitUnemploymentMoney;
// 单位工伤金额
BigDecimal unitInjuryMoney;
// 单位生育金额
BigDecimal unitBirthMoney;
// 存储基数(最低或最高)
BigDecimal baseLimit;
if (socialInfo != null) {
// 需要从基数配置取数据:
if (Common.isNotNull(socialInfo.getPaymentType()) && !CommonConstants.ONE_STRING.equals(socialInfo.getPaymentType())) {
if (CommonConstants.ZERO_STRING.equals(socialInfo.getPaymentType())) {
baseLimit = sysBaseSetInfo.getLowerLimit();
} else {
baseLimit = sysBaseSetInfo.getUpperLimit();
}
unitPersionBase = baseLimit;
unitMedicalBase = baseLimit;
unitUnemploymentBase = baseLimit;
unitInjuryBase = baseLimit;
unitBirthBase = baseLimit;
unitPersionPro = sysBaseSetInfo.getUnitPersionPro();
unitMedicalPro = sysBaseSetInfo.getUnitMedicalPro();
unitUnemploymentPro = sysBaseSetInfo.getUnitUnemploymentPro();
unitInjuryPro = sysBaseSetInfo.getUnitInjuryPro();
unitBirthPro = sysBaseSetInfo.getUnitBirthPro();
} else {
unitPersionBase = socialInfo.getUnitPensionCardinal();
unitMedicalBase = socialInfo.getUnitMedicalCardinal();
unitUnemploymentBase = socialInfo.getUnitUnemploymentCardinal();
unitInjuryBase = socialInfo.getUnitWorkInjuryCardinal();
unitBirthBase = socialInfo.getUnitBirthCardinal();
unitPersionPro = socialInfo.getUnitPensionPer();
unitMedicalPro = socialInfo.getUnitMedicalPer();
unitUnemploymentPro = socialInfo.getUnitUnemploymentPer();
unitInjuryPro = socialInfo.getUnitWorkUnjuryPer();
unitBirthPro = socialInfo.getUnitBirthPer();
}
}
unitPersionMoney = BigDecimalUtils.safeMultiply(unitPersionBase, unitPersionPro,
CommonConstants.ONE_OF_PERCENT);
unitMedicalMoney = BigDecimalUtils.safeMultiply(unitMedicalBase, unitMedicalPro,
CommonConstants.ONE_OF_PERCENT);
unitUnemploymentMoney = BigDecimalUtils.safeMultiply(unitUnemploymentBase, unitUnemploymentPro,
CommonConstants.ONE_OF_PERCENT);
unitInjuryMoney = BigDecimalUtils.safeMultiply(unitInjuryBase, unitInjuryPro,
CommonConstants.ONE_OF_PERCENT);
unitBirthMoney = BigDecimalUtils.safeMultiply(unitBirthBase, unitBirthPro,
CommonConstants.ONE_OF_PERCENT);
library.setUnitPensionBase(unitPersionBase);
library.setUnitMedicalBase(unitMedicalBase);
library.setUnitUnemploymentBase(unitUnemploymentBase);
library.setUnitInjuryBase(unitInjuryBase);
library.setUnitBirthBase(unitBirthBase);
library.setUnitPersionPro(unitPersionPro);
library.setUnitMedicalPro(unitMedicalPro);
library.setUnitUnemploymentPro(unitUnemploymentPro);
library.setUnitInjuryPro(unitInjuryPro);
library.setUnitBirthPro(unitBirthPro);
library.setUnitPensionFee(unitPersionMoney);
library.setUnitMedicalFee(unitMedicalMoney);
library.setUnitUnemploymentFee(unitUnemploymentMoney);
library.setUnitBirthFee(unitBirthMoney);
library.setUnitWorkInjuryFee(unitInjuryMoney);
}
/**
* 按临时政策初始化个人预估数据
*
* @param library
* @param agentConfig
* @return
* @Author fxj
* @Date 2020-08-03
**/
private void initPersonalLibByConfig(TForecastLibrary library, TAgentConfig agentConfig) {
// 0 全额 1 减半 2 不收
if (CommonConstants.ONE_STRING.equals(agentConfig.getMedical())) {
library.setPersonalMedicalFee(BigDecimalUtils.safeMultiply(library.getPersonalMedicalFee()
, CommonConstants.HALF_OF_ONE, CommonConstants.TWO_BIG));
} else if (CommonConstants.TWO_STRING.equals(agentConfig.getMedical())) {
library.setPersonalMedicalFee(BigDecimal.ZERO);
}
// 0 全额 1 减半 2 不收
if (CommonConstants.ONE_STRING.equals(agentConfig.getUnemployed())) {
library.setPersonalUnemploymentFee(BigDecimalUtils.safeMultiply(library.getPersonalUnemploymentFee()
, CommonConstants.HALF_OF_ONE, CommonConstants.TWO_BIG));
} else if (CommonConstants.TWO_STRING.equals(agentConfig.getUnemployed())) {
library.setPersonalUnemploymentFee(BigDecimal.ZERO);
}
// 0 全额 1 减半 2 不收
if (CommonConstants.ONE_STRING.equals(agentConfig.getPension())) {
library.setPersonalPensionFee(BigDecimalUtils.safeMultiply(library.getPersonalPensionFee()
, CommonConstants.HALF_OF_ONE, CommonConstants.TWO_BIG));
} else if (CommonConstants.TWO_STRING.equals(agentConfig.getPension())) {
library.setPersonalPensionFee(BigDecimal.ZERO);
}
}
/**
* 按临时政策初始化单位社保预估数据
*
* @param library
* @param agentConfig
* @return
* @Author fxj
* @Date 2020-08-03
**/
private void initUnitLibByConfig(TForecastLibrary library, TAgentConfig agentConfig) {
// 0 全额 1 减半 2 不收
if (CommonConstants.ONE_STRING.equals(agentConfig.getPension())) {
library.setUnitPensionFee(BigDecimalUtils.safeMultiply(library.getUnitPensionFee()
, CommonConstants.HALF_OF_ONE, CommonConstants.TWO_BIG));
} else if (CommonConstants.TWO_STRING.equals(agentConfig.getPension())) {
library.setUnitPensionFee(BigDecimal.ZERO);
}
// 0 全额 1 减半 2 不收
if (CommonConstants.ONE_STRING.equals(agentConfig.getMedical())) {
library.setUnitMedicalFee(BigDecimalUtils.safeMultiply(library.getUnitMedicalFee()
, CommonConstants.HALF_OF_ONE, CommonConstants.TWO_BIG));
} else if (CommonConstants.TWO_STRING.equals(agentConfig.getMedical())) {
library.setUnitMedicalFee(BigDecimal.ZERO);
}
// 0 全额 1 减半 2 不收
if (CommonConstants.ONE_STRING.equals(agentConfig.getBear())) {
library.setUnitBirthFee(BigDecimalUtils.safeMultiply(library.getUnitBirthFee()
, CommonConstants.HALF_OF_ONE, CommonConstants.TWO_BIG));
} else if (CommonConstants.TWO_STRING.equals(agentConfig.getBear())) {
library.setUnitBirthFee(BigDecimal.ZERO);
}
// 0 全额 1 减半 2 不收
if (CommonConstants.ONE_STRING.equals(agentConfig.getInjury())) {
library.setUnitWorkInjuryFee(BigDecimalUtils.safeMultiply(library.getUnitWorkInjuryFee()
, CommonConstants.HALF_OF_ONE, CommonConstants.TWO_BIG));
} else if (CommonConstants.TWO_STRING.equals(agentConfig.getInjury())) {
library.setUnitWorkInjuryFee(BigDecimal.ZERO);
}
// 0 全额 1 减半 2 不收
if (CommonConstants.ONE_STRING.equals(agentConfig.getUnemployed())) {
library.setUnitUnemploymentFee(BigDecimalUtils.safeMultiply(library.getUnitUnemploymentFee()
, CommonConstants.HALF_OF_ONE, CommonConstants.TWO_BIG));
} else if (CommonConstants.TWO_STRING.equals(agentConfig.getUnemployed())) {
library.setUnitUnemploymentFee(BigDecimal.ZERO);
}
}
/**
* @param library 预估主表
* @param socialInfo 社保
* @param sysBaseSetInfo 基数配置
* @Description: 直接计算单位大病
* @Author: hgw
* @Date: 2020/12/2 14:31
* @return: void
**/
private void setBigMoneyBySelfForUnit(TForecastLibrary library, TSocialFundInfo socialInfo, SysBaseSetInfo sysBaseSetInfo) {
if (socialInfo.getUnitBigailmentMoney() != null) {
library.setUnitBitailmentFee(socialInfo.getUnitBigailmentMoney());
} else if (socialInfo.getUnitBigailmentCardinal() != null && sysBaseSetInfo.getPayCompanyPro() != null) {
library.setUnitBitailmentFee(BigDecimalUtils.safeMultiply(
socialInfo.getUnitBigailmentCardinal(),
sysBaseSetInfo.getPayCompanyPro(),
CommonConstants.ONE_OF_PERCENT));
}
}
/**
* @param library 预估主表
* @param socialInfo 社保
* @param sysBaseSetInfo 基数配置
* @Description: 直接计算个人大病
* @Author: hgw
* @Date: 2020/12/2 14:31
* @return: void
**/
private void setBigMoneyBySelfForPerson(TForecastLibrary library, TSocialFundInfo socialInfo, SysBaseSetInfo sysBaseSetInfo) {
if (socialInfo.getPersonalBigailmentMoney() != null) {
library.setPersonalBigailmentFee(socialInfo.getPersonalBigailmentMoney());
} else if (socialInfo.getPersonalBigailmentCardinal() != null && sysBaseSetInfo.getPayPersonalPro() != null) {
library.setPersonalBigailmentFee(BigDecimalUtils.safeMultiply(
socialInfo.getPersonalBigailmentCardinal(),
sysBaseSetInfo.getPayPersonalPro(),
CommonConstants.ONE_OF_PERCENT));
}
}
/**
* @param library 预估库
* @param socialInfo 社保
* @param sysBaseSetInfo 基数配置
* @param paymentType 0最低缴纳、1自定义缴纳、2最高缴纳
* @Description: 塞大病金额
* @Author: hgw
* @Date: 2020/11/25 15:51
* @return: void
**/
private void setBigMoney(TForecastLibrary library, TSocialFundInfo socialInfo, SysBaseSetInfo sysBaseSetInfo
, String paymentType) {
if (CommonConstants.ZERO_STRING.equals(sysBaseSetInfo.getCollectType())) {
if ((null != sysBaseSetInfo.getCollectMoth()
&& Integer.parseInt(library.getSocialPayMonth().substring(4, 6)) == sysBaseSetInfo.getCollectMoth()
&& Integer.parseInt(library.getSocialPayMonth().substring(0, 4)) != socialInfo.getSocialStartDate().getYear())
|| library.getSocialPayMonth().equals(DateUtil.formatDatePatten(socialInfo.getSocialStartDate(), null))) {
// 大病取值方式:0按定值
library.setUnitBitailmentFee(BigDecimalUtils.isNullToZero(sysBaseSetInfo.getPayCompany()));
library.setPersonalBigailmentFee(BigDecimalUtils.isNullToZero(sysBaseSetInfo.getPayPersonal()));
//第一次收取费用逻辑:新员工入职是否收费处理逻辑:先按第一次不收取费用 (只针对按年收)
if (library.getSocialPayMonth().equals(DateUtil.formatDatePatten(socialInfo.getSocialStartDate(), null))
&& CommonConstants.ONE_STRING.equals(socialInfo.getIsChargePersonal())) {
library.setPersonalBigailmentFee(BigDecimal.ZERO);
}
}
//大病收取方式 : 1.按月
} else if (CommonConstants.ONE_STRING.equals(sysBaseSetInfo.getCollectType())) {
// 存储基数(最低或最高)
BigDecimal baseLimit = sysBaseSetInfo.getLowerLimit();
if (CommonConstants.TWO_STRING.equals(paymentType)) {
baseLimit = sysBaseSetInfo.getUpperLimit();
}
// 大病取值方式:1 按比例 按派单的基数和比例来
if (CommonConstants.ONE_STRING.equals(sysBaseSetInfo.getValueType())) {
library.setPersonalBigailmentFee(BigDecimalUtils.safeMultiply(
baseLimit,
sysBaseSetInfo.getPayPersonalPro(),
CommonConstants.ONE_OF_PERCENT));
library.setUnitBitailmentFee(BigDecimalUtils.safeMultiply(
baseLimit,
sysBaseSetInfo.getPayCompanyPro(),
CommonConstants.ONE_OF_PERCENT));
} else {
// 大病取值方式:0按定值
library.setUnitBitailmentFee(BigDecimalUtils.isNullToZero(sysBaseSetInfo.getPayCompany()));
library.setPersonalBigailmentFee(BigDecimalUtils.isNullToZero(sysBaseSetInfo.getPayPersonal()));
}
}
}
/**
* 初始化公积金预估信息
*
* @param payMonth
* @param saveLibraryMap
* @param providentFund
* @param isReduceSocial
* @return
* @Author fxj
* @Date 2020-07-21
**/
private void initFundLibary(String payMonth, Map<String, TForecastLibrary> saveLibraryMap
, TSocialFundInfo providentFund, boolean isReduceSocial, TForecastLibrary lib, String mapKeyStr) {
if (lib == null) {
lib = new TForecastLibrary();
}
lib.setDataType(CommonConstants.ONE_INT);
lib.setEmpId(providentFund.getEmpId());
lib.setEmpIdcard(providentFund.getEmpIdcard());
lib.setEmpName(providentFund.getEmpName());
lib.setEmpNo(providentFund.getEmpNo());
lib.setProvidentCreateMonth(ServiceUtil.initCreateMonth(providentFund.getCreateTime(), payMonth));
lib.setSocialCreateMonth(lib.getProvidentCreateMonth());
//同时处理社保日期
lib.setSocialPayMonth(payMonth);
lib.setProvidentPayMonth(payMonth);
lib.setFundProvince(providentFund.getFundProvince());
lib.setFundCity(providentFund.getFundCity());
lib.setFundTown(providentFund.getFundTown());
lib.setProvidentId(providentFund.getId());
lib.setUnitId(providentFund.getUnitId());
lib.setSettleDomainId(providentFund.getSettleDomain());
//判断是否允许补缴 是否可补缴 0:是
Integer monthT = null;
if (CommonConstants.ZERO_STRING.equals(providentFund.getCanOverpay())) {
//补缴是否含当月: 含当月
if (CommonConstants.ZERO_STRING.equals(providentFund.getHaveThisMonth())) {
monthT = Integer.parseInt(DateUtil.getYearAndMonth(LocalDateTimeUtils.formatTime(providentFund.getCreateTime(), DateUtil.DATETIME_YYYYMM), 0));
//补缴是否含当月: 不含含当月
} else {
monthT = Integer.parseInt(DateUtil.getYearAndMonth(LocalDateTimeUtils.formatTime(providentFund.getCreateTime(), DateUtil.DATETIME_YYYYMM), -CommonConstants.ONE_INT));
}
}
// 判断公积金对应缴纳月份是否派减了
boolean isReduceFund;
if (null != providentFund.getFundReduceDate()) {
isReduceFund = Integer.parseInt(payMonth) >= DateUtil.formatDateInt(providentFund.getFundReduceDate());
} else {
isReduceFund = false;
}
lib = initForecastLibrary(lib, null, providentFund, monthT, isReduceFund, isReduceSocial, null);
saveLibraryMap.put(mapKeyStr, lib);
}
}
package com.yifu.cloud.plus.v1.yifu.social.util;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.DateUtil;
import lombok.extern.slf4j.Slf4j;
import java.time.LocalDateTime;
/**
* 公用方法提取
*
* @author fxj
* @date 2019-09-29
**/
@Slf4j
public class ServiceUtil {
private ServiceUtil() {
throw new IllegalStateException("ServiceUtil class");
}
/**
* @Description: 返回字符串对应的int值
* @Author: hgw
* @Date: 2022/7/18 17:29
* @return: int
**/
public static int convertStringToInt(String num1) {
if (Common.isEmpty(num1) || !Common.isNumber(num1)) {
return -1;
}
return Integer.parseInt(num1);
}
/**
* 按派单日期生成生成月份
* @Author fxj
* @Date 2020-03-25
* @param createDate
* @return
**/
public static String initCreateMonth(LocalDateTime createDate, String payMonth){
if (null == createDate || Common.isEmpty(payMonth) || payMonth.length() != 6){
return DateUtil.getYearAndMonth(LocalDateTime.now(), 1);
}
if (createDate.getYear() < Integer.parseInt(payMonth.substring(0,4))){
return payMonth;
}
if (createDate.getYear() > Integer.parseInt(payMonth.substring(0,4))){
return DateUtil.getYearAndMonth(createDate, 1);
}
if (createDate.getYear() == Integer.parseInt(payMonth.substring(0,4))){
if (createDate.getMonthValue() < Integer.parseInt(payMonth.substring(4,6))){
return payMonth;
}
if (createDate.getMonthValue() >= Integer.parseInt(payMonth.substring(4,6))){
return DateUtil.getYearAndMonth(createDate, 1);
}
}
return null;
}
}
......@@ -368,4 +368,15 @@
and a.BASE_TYPE = '1'
</where>
</select>
<!--sysBaseSetInfo不分页查询-->
<select id="getSysBaseSetInfoNoPage" resultMap="sysBaseSetInfoMap">
<include refid="base_column_list"/>
FROM sys_base_set_info a
<where>
1=1
<include refid="sysBaseSetInfo_where"/>
</where>
ORDER BY a.apply_start_date desc
</select>
</mapper>
......@@ -94,6 +94,7 @@
<result property="providentHouseholdName" column="PROVIDENT_HOUSEHOLD_NAME"/>
<result property="providentNo" column="PROVIDENT_NO"/>
<result property="dataPush" column="DATA_PUSH"/>
<result property="dataType" column="DATA_TYPE"/>
<result property="createBy" column="CREATE_BY"/>
<result property="createName" column="CREATE_NAME"/>
<result property="createTime" column="CREATE_TIME"/>
......@@ -101,84 +102,82 @@
<result property="updateTime" column="UPDATE_TIME"/>
</resultMap>
<sql id="Base_Column_List">
a
.
ID
,
a.EMP_ID,
a.EMP_NO,
a.EMP_NAME,
a.EMP_IDCARD,
a.SOCIAL_ID,
a.SETTLE_DOMAIN_ID,
a.UNIT_ID,
a.PROVIDENT_ID,
a.UNIT_PENSION_FEE,
a.UNIT_MEDICAL_FEE,
a.UNIT_UNEMPLOYMENT_FEE,
a.UNIT_WORK_INJURY_FEE,
a.UNIT_BIRTH_FEE,
a.UNIT_BITAILMENT_FEE,
a.PERSONAL_PENSION_FEE,
a.PERSONAL_MEDICAL_FEE,
a.PERSONAL_UNEMPLOYMENT_FEE,
a.PERSONAL_BIGAILMENT_FEE,
a.SOCIAL_PAY_MONTH,
a.SOCIAL_CREATE_MONTH,
a.PROVIDENT_PAY_MONTH,
a.PROVIDENT_CREATE_MONTH,
a.UNIT_SOCIAL_SUM,
a.UNIT_FUND_SUM,
a.PERSONAL_SOCIAL_SUM,
a.PERSONAL_FUND_SUM,
a.FUND_PROVINCE,
a.FUND_CITY,
a.FUND_TOWN,
a.SOCIAL_PROVINCE,
a.SOCIAL_CITY,
a.SOCIAL_TOWN,
a.UNIT_PENSION_BASE,
a.UNIT_MEDICAL_BASE,
a.UNIT_UNEMPLOYMENT_BASE,
a.UNIT_INJURY_BASE,
a.UNIT_BIRTH_BASE,
a.UNIT_BIGAILMENT_BASE,
a.PERSONAL_PENSION_BASE,
a.PERSONAL_MEDICAL_BASE,
a.PERSONAL_UNEMPLOYMENT_BASE,
a.PERSONAL_BIGAILMENT_BASE,
a.UNIT_PERSION_PRO,
a.UNIT_MEDICAL_PRO,
a.UNIT_UNEMPLOYMENT_PRO,
a.UNIT_INJURY_PRO,
a.UNIT_BIRTH_PRO,
a.UNIT_BIGAILMENT_PRO,
a.PERSONAL_PERSION_PRO,
a.PERSONAL_MEDICAL_PRO,
a.PERSONAL_UNEMPLOYMENT_PRO,
a.PERSONAL_BIGAILMENT_PRO,
a.UNIT_FUND_BASE,
a.PERSONAL_FUND_BASE,
a.UNIT_FUND_PROP,
a.PERSONAL_FUND_PROP,
a.REMARK,
a.PROJECT_ID,
a.UNIT_NAME,
a.DEPT_NAME,
a.EMP_NATRUE,
a.UNIT_INTEREST_FEE,
a.PERSONAL_INTEREST_FEE,
a.SOCIAL_HOUSEHOLD,
a.SOCIAL_HOUSEHOLD_NAME,
a.PROVIDENT_HOUSEHOLD,
a.PROVIDENT_HOUSEHOLD_NAME,
a.PROVIDENT_NO,
a.DATA_PUSH,
a.CREATE_BY,
a.CREATE_NAME,
a.CREATE_TIME,
a.UPDATE_BY,
a.UPDATE_TIME
a.ID,
a.EMP_ID,
a.EMP_NO,
a.EMP_NAME,
a.EMP_IDCARD,
a.SOCIAL_ID,
a.SETTLE_DOMAIN_ID,
a.UNIT_ID,
a.PROVIDENT_ID,
a.UNIT_PENSION_FEE,
a.UNIT_MEDICAL_FEE,
a.UNIT_UNEMPLOYMENT_FEE,
a.UNIT_WORK_INJURY_FEE,
a.UNIT_BIRTH_FEE,
a.UNIT_BITAILMENT_FEE,
a.PERSONAL_PENSION_FEE,
a.PERSONAL_MEDICAL_FEE,
a.PERSONAL_UNEMPLOYMENT_FEE,
a.PERSONAL_BIGAILMENT_FEE,
a.SOCIAL_PAY_MONTH,
a.SOCIAL_CREATE_MONTH,
a.PROVIDENT_PAY_MONTH,
a.PROVIDENT_CREATE_MONTH,
a.UNIT_SOCIAL_SUM,
a.UNIT_FUND_SUM,
a.PERSONAL_SOCIAL_SUM,
a.PERSONAL_FUND_SUM,
a.FUND_PROVINCE,
a.FUND_CITY,
a.FUND_TOWN,
a.SOCIAL_PROVINCE,
a.SOCIAL_CITY,
a.SOCIAL_TOWN,
a.UNIT_PENSION_BASE,
a.UNIT_MEDICAL_BASE,
a.UNIT_UNEMPLOYMENT_BASE,
a.UNIT_INJURY_BASE,
a.UNIT_BIRTH_BASE,
a.UNIT_BIGAILMENT_BASE,
a.PERSONAL_PENSION_BASE,
a.PERSONAL_MEDICAL_BASE,
a.PERSONAL_UNEMPLOYMENT_BASE,
a.PERSONAL_BIGAILMENT_BASE,
a.UNIT_PERSION_PRO,
a.UNIT_MEDICAL_PRO,
a.UNIT_UNEMPLOYMENT_PRO,
a.UNIT_INJURY_PRO,
a.UNIT_BIRTH_PRO,
a.UNIT_BIGAILMENT_PRO,
a.PERSONAL_PERSION_PRO,
a.PERSONAL_MEDICAL_PRO,
a.PERSONAL_UNEMPLOYMENT_PRO,
a.PERSONAL_BIGAILMENT_PRO,
a.UNIT_FUND_BASE,
a.PERSONAL_FUND_BASE,
a.UNIT_FUND_PROP,
a.PERSONAL_FUND_PROP,
a.REMARK,
a.PROJECT_ID,
a.UNIT_NAME,
a.DEPT_NAME,
a.EMP_NATRUE,
a.UNIT_INTEREST_FEE,
a.PERSONAL_INTEREST_FEE,
a.SOCIAL_HOUSEHOLD,
a.SOCIAL_HOUSEHOLD_NAME,
a.PROVIDENT_HOUSEHOLD,
a.PROVIDENT_HOUSEHOLD_NAME,
a.PROVIDENT_NO,
a.DATA_PUSH,
a.DATA_TYPE,
a.CREATE_BY,
a.CREATE_NAME,
a.CREATE_TIME,
a.UPDATE_BY,
a.UPDATE_TIME
</sql>
<sql id="tForecastLibrary_where">
<if test="tForecastLibrary != null">
......@@ -398,6 +397,9 @@
<if test="tForecastLibrary.dataPush != null">
AND a.DATA_PUSH = #{tForecastLibrary.dataPush}
</if>
<if test="tForecastLibrary.dataType != null">
AND a.DATA_TYPE = #{tForecastLibrary.dataType}
</if>
<if test="tForecastLibrary.createBy != null and tForecastLibrary.createBy.trim() != ''">
AND a.CREATE_BY = #{tForecastLibrary.createBy}
</if>
......
......@@ -637,4 +637,41 @@
<include refid="tSocialFundInfo_where"/>
</where>
</select>
<!--获取在用社保-->
<select id="getSocialList" resultMap="tSocialFundInfoMap">
SELECT
<include refid="Base_Column_List"/>
FROM t_social_fund_info a
<where>
a.SOCIAL_ADD_STATUS != '4' and a.SOCIAL_REDUCE_STATUS != '2'
<if test="empIdCard != null">
and a.EMP_IDCARD = #{empIdCard}
</if>
<if test="settleDomainIds != null">
AND a.SETTLE_DOMAIN in
<foreach item="item" index="index" collection="settleDomainIds" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</where>
</select>
<!--获取在用公积金-->
<select id="getFundList" resultMap="tSocialFundInfoMap">
SELECT
<include refid="Base_Column_List"/>
FROM t_social_fund_info a
<where>
a.FUND_ADD_STATUS != '4' and a.FUND_REDUCE_STATUS != '2'
<if test="empIdCard != null">
and a.EMP_IDCARD = #{empIdCard}
</if>
<if test="settleDomainIds != null">
AND a.SETTLE_DOMAIN in
<foreach item="item" index="index" collection="settleDomainIds" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</where>
</select>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment