Merge remote-tracking branch 'remotes/origin/feature/230901-社保福利方案搜索功能' into release/2.9.5.2309.01

This commit is contained in:
sy 2023-09-21 14:10:06 +08:00
commit f4883ad87c
7 changed files with 326 additions and 11 deletions

View File

@ -0,0 +1,250 @@
package com.engine.salary.action;
import com.engine.salary.encrypt.EncryptUtil;
import com.engine.salary.entity.sicategory.po.ICategoryPO;
import com.engine.salary.entity.sischeme.po.InsuranceSchemeDetailPO;
import com.engine.salary.entity.sischeme.po.InsuranceSchemePO;
import com.engine.salary.enums.sicategory.IsUseEnum;
import com.engine.salary.mapper.sicategory.ICategoryMapper;
import com.engine.salary.mapper.sischeme.InsuranceSchemeDetailMapper;
import com.engine.salary.mapper.sischeme.InsuranceSchemeMapper;
import com.engine.salary.util.SalaryEntityUtil;
import com.engine.salary.util.db.MapperProxyFactory;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.*;
import weaver.workflow.request.RequestManager;
import java.util.*;
import java.util.stream.Collectors;
/**
* @Author: sy
* @Description: 更新福利方案明细信息action
* @Date: 2023/9/18
**/
@Slf4j
public class UpdateSISchemeDetailAction implements Action {
private EncryptUtil encryptUtil = new EncryptUtil();
private InsuranceSchemeMapper getInsuranceSchemeMapper() {
return MapperProxyFactory.getProxy(InsuranceSchemeMapper.class);
}
private InsuranceSchemeDetailMapper getInsuranceSchemeDetailMapper() {
return MapperProxyFactory.getProxy(InsuranceSchemeDetailMapper.class);
}
private ICategoryMapper getICategoryMapper() {
return MapperProxyFactory.getProxy(ICategoryMapper.class);
}
private String tableName;
public String getTableName() {
return tableName;
}
public void setTableName(String tableName) {
this.tableName = tableName;
}
@Override
public String execute(RequestInfo requestInfo) {
try {
RequestManager requestManager = requestInfo.getRequestManager();
User user = requestManager.getUser();
DetailTable[] detailTables = requestInfo.getDetailTableInfo().getDetailTable();
List<Map<String, String>> detailList = new ArrayList<>();
if (detailTables.length > 0) {
for(DetailTable dt : detailTables) {
Row[] s = dt.getRow();
for (Row r : s) {
Cell[] c = r.getCell();
Map<String, String> detailMap = Arrays.stream(c).collect(Collectors.toMap(Cell::getName,
property -> Util.null2String(property.getValue())));
detailList.add(detailMap);
}
}
}
RecordSet rs = new RecordSet();
String queryImageId = "select salaryname,processfield from " + tableName + " where workflowid = ?";
rs.executeQuery(queryImageId, requestInfo.getWorkflowid());
//遍历取出明细表中对应数据
int detailNo = 0;
List<ICategoryPO> listAll = getICategoryMapper().listAll().stream().filter(f -> f.getIsUse().equals(IsUseEnum.START.getValue())).collect(Collectors.toList());
List<InsuranceSchemePO> schemeList = getInsuranceSchemeMapper().listAll();
List<InsuranceSchemeDetailPO> updateSchemeDetails = new ArrayList<>();
for (Map<String, String> map : detailList) {
detailNo++;
List<UpdateSISchemeDetailAction.SalaryField> list = new ArrayList<>();
while (rs.next()) {
String processField = rs.getString("processfield");
String salaryName = rs.getString("salaryname");
String value = map.get(processField);
list.add(new UpdateSISchemeDetailAction.SalaryField(processField, salaryName, value));
}
rs.beforFirst();
// 流程数据
Map<String, Object> importDataMap = SalaryEntityUtil.convert2Map(list, UpdateSISchemeDetailAction.SalaryField::getSalaryName, UpdateSISchemeDetailAction.SalaryField::getValue);
//设置更新对象元素
String schemeId = importDataMap.getOrDefault("福利方案id", "").toString();
String schemeName = importDataMap.getOrDefault("福利方案名称", "").toString();
//查询福利方案
InsuranceSchemePO targetSchemePO = new InsuranceSchemePO();
if (StringUtils.isNotBlank(schemeId)) {
targetSchemePO = schemeList.stream().filter(f -> f.getId().equals(Long.valueOf(schemeId))).findFirst().orElse(null);
} else if (StringUtils.isNotBlank(schemeName)) {
targetSchemePO = schemeList.stream().filter(f -> f.getSchemeName().equals(schemeName)).findFirst().orElse(null);
} else {
requestInfo.getRequestManager().setMessage("错误行" + detailNo + ":" + "福利方案id和福利方案名称至少填写一个");
return FAILURE_AND_CONTINUE;
}
if (targetSchemePO == null) {
requestInfo.getRequestManager().setMessage("错误行" + detailNo + ":" + "福利方案id和福利方案名称信息有误无法匹配到已有福利方案");
return FAILURE_AND_CONTINUE;
}
//查询福利方案下的福利项明细
List<InsuranceSchemeDetailPO> insuranceSchemeDetailPOS = getInsuranceSchemeDetailMapper().queryListBySchemeId(targetSchemePO.getId());
if (insuranceSchemeDetailPOS.size() > 0) {
encryptUtil.decryptList(insuranceSchemeDetailPOS, InsuranceSchemeDetailPO.class);
} else {
requestInfo.getRequestManager().setMessage("错误行" + detailNo + ":" + "该福利方案不存在福利项明细,无法进行修改!");
return FAILURE_AND_CONTINUE;
}
String paymentScope = importDataMap.getOrDefault("缴纳对象", "").toString();
if (StringUtils.isBlank(paymentScope)) {
requestInfo.getRequestManager().setMessage("错误行" + detailNo + ":" + "缴纳对象必填!");
return FAILURE_AND_CONTINUE;
}
String insuranceId = importDataMap.getOrDefault("福利项id", "").toString();
String insuranceName = importDataMap.getOrDefault("福利项名称", "").toString();
InsuranceSchemeDetailPO targetSchemeDetailPO = new InsuranceSchemeDetailPO();
if (StringUtils.isNotBlank(insuranceId)) {
targetSchemeDetailPO = insuranceSchemeDetailPOS.stream()
.filter(f -> f.getInsuranceId().equals(Long.valueOf(insuranceId)) && f.getPaymentScope().equals(Integer.valueOf(paymentScope)))
.findFirst().orElse(null);
} else if (StringUtils.isNotBlank(insuranceName)) {
List<ICategoryPO> targetCategoryPOs = listAll.stream().filter(f -> f.getInsuranceName().equals(insuranceName)).collect(Collectors.toList());
if (targetCategoryPOs .size() == 1) {
targetSchemeDetailPO = insuranceSchemeDetailPOS.stream()
.filter(f -> f.getInsuranceId().equals(targetCategoryPOs.get(0).getId()) && f.getPaymentScope().equals(Integer.valueOf(paymentScope)))
.findFirst().orElse(null);
} else if (targetCategoryPOs.size() > 1) {
requestInfo.getRequestManager().setMessage("错误行" + detailNo + ":" + "福利项名称匹配到多个福利项!");
return FAILURE_AND_CONTINUE;
}
} else {
requestInfo.getRequestManager().setMessage("错误行" + detailNo + ":" + "福利项id和福利项名称至少填写一个");
return FAILURE_AND_CONTINUE;
}
if (targetSchemeDetailPO == null) {
requestInfo.getRequestManager().setMessage("错误行" + detailNo + ":" + "福利项id和福利项名称信息有误无法匹配到方案已有福利项");
return FAILURE_AND_CONTINUE;
}
String isPayment = importDataMap.getOrDefault("是否缴费", "").toString();
if (StringUtils.isNotBlank(isPayment)) {
targetSchemeDetailPO.setIsPayment(Integer.valueOf(isPayment));
}
String upperLimit = importDataMap.getOrDefault("基数上限", "").toString();
if (StringUtils.isNotBlank(upperLimit)) {
targetSchemeDetailPO.setUpperLimit(upperLimit);
}
String lowerLimit = importDataMap.getOrDefault("基数下限", "").toString();
if (StringUtils.isNotBlank(lowerLimit)) {
targetSchemeDetailPO.setLowerLimit(lowerLimit);
}
String paymentProportion = importDataMap.getOrDefault("缴纳比例", "").toString();
if (StringUtils.isNotBlank(paymentProportion)) {
targetSchemeDetailPO.setPaymentProportion(paymentProportion);
}
String fixedCost = importDataMap.getOrDefault("固定费用", "").toString();
if (StringUtils.isNotBlank(fixedCost)) {
targetSchemeDetailPO.setFixedCost(fixedCost);
}
String validNum = importDataMap.getOrDefault("有效小数位", "").toString();
if (StringUtils.isNotBlank(validNum)) {
targetSchemeDetailPO.setValidNum(Integer.valueOf(validNum));
}
String rententionRule = importDataMap.getOrDefault("进位规则", "").toString();
if (StringUtils.isNotBlank(rententionRule)) {
targetSchemeDetailPO.setRententionRule(Integer.valueOf(rententionRule));
}
targetSchemeDetailPO.setUpdateTime(new Date());
updateSchemeDetails.add(targetSchemeDetailPO);
}
//更新方案明细
if (updateSchemeDetails.size() > 0) {
encryptUtil.encryptList(updateSchemeDetails, InsuranceSchemeDetailPO.class);
updateSchemeDetails.forEach(getInsuranceSchemeDetailMapper()::updateAll);
}
} catch (Exception e) {
log.error("福利方案更新异常", e);
requestInfo.getRequestManager().setMessage(e.getMessage());
return FAILURE_AND_CONTINUE;
}
return SUCCESS;
}
class SalaryField {
private String processField;
private String salaryName;
private String value;
public String getProcessField() {
return processField;
}
public void setProcessField(String processField) {
this.processField = processField;
}
public String getSalaryName() {
return salaryName;
}
public void setSalaryName(String salaryName) {
this.salaryName = salaryName;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public SalaryField(String processField, String salaryName, String value) {
this.processField = processField;
this.salaryName = salaryName;
this.value = value;
}
}
}

View File

@ -1,6 +1,7 @@
package com.engine.salary.entity.sischeme.param;
import com.engine.salary.common.BaseQueryParam;
import com.engine.salary.enums.sicategory.PaymentTypeEnum;
import com.engine.salary.enums.sicategory.WelfareTypeEnum;
import lombok.AllArgsConstructor;
import lombok.Builder;
@ -24,5 +25,22 @@ public class InsuranceSchemeParam extends BaseQueryParam {
private WelfareTypeEnum welfareTypeEnum;
/**
* 缴纳类型
*/
private PaymentTypeEnum paymentTypeEnum;
/**
* 方案名称
*/
private String schemeName;
/**
* 缴纳类型
*/
private Integer paymentType;
/**
* 福利类型
*/
private Integer welfareType;
}

View File

@ -336,6 +336,12 @@
<if test="fixedCost != null" >
fixed_cost=#{fixedCost},
</if>
<if test="validNum != null" >
valid_num=#{validNum},
</if>
<if test="rententionRule != null" >
rentention_rule=#{rententionRule},
</if>
</set>
WHERE id = #{id} AND delete_type = 0
</update>

View File

@ -1,5 +1,6 @@
package com.engine.salary.mapper.sischeme;
import com.engine.salary.entity.sischeme.param.InsuranceSchemeParam;
import com.engine.salary.entity.sischeme.po.InsuranceSchemePO;
import org.apache.ibatis.annotations.Param;
@ -61,6 +62,8 @@ public interface InsuranceSchemeMapper {
List<InsuranceSchemePO> listByWelfareType(@Param("welfareType")Integer welfareType);
List<InsuranceSchemePO> list(InsuranceSchemeParam param);
void deleteByIds(@Param("ids")Collection<Long> ids);
}

View File

@ -36,6 +36,22 @@
, t.tax_agent_ids
</sql>
<sql id="paramSql">
<!-- 关键字(方案名称) -->
<if test="schemeName != null and schemeName != ''">
AND scheme_name like CONCAT('%',#{schemeName},'%')
</if>
</sql>
<sql id="paramSql" databaseId="oracle">
<if test="schemeName != null and schemeName != ''">
AND scheme_name like '%'||#{schemeName}||'%'
</if>
</sql>
<sql id="paramSql" databaseId="sqlserver">
<if test="schemeName != null and schemeName != ''">
AND scheme_name like '%'+#{schemeName}+'%'
</if>
</sql>
<!-- 根据主键获取单条记录 -->
<select id="getById" resultMap="BaseResultMap" parameterType="Long">
@ -175,6 +191,22 @@
order by id desc
</select>
<select id="list" resultMap="BaseResultMap">
SELECT
<include refid="baseColumns"/>
FROM hrsa_social_security_scheme t
WHERE t.delete_type = 0
<include refid="paramSql"/>
<if test="welfareType != null and welfareType != ''">
AND
t.welfare_type = #{welfareType}
</if>
<if test="paymentType != null">
AND
t.payment_type = #{paymentType}
</if>
order by id desc
</select>
<update id="deleteByIds">
UPDATE hrsa_social_security_scheme

View File

@ -966,32 +966,32 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
InsuranceAccountDetailPO repairSiAcct = siAcctResultWithEmpAndPayStatus.get(item.getEmployeeId() + "_" + PaymentStatusEnum.REPAIR.getValue());
InsuranceAccountDetailPO balanceSiAcct = siAcctResultWithEmpAndPayStatus.get(item.getEmployeeId() + "_" + PaymentStatusEnum.BALANCE.getValue());
//取正常缴纳的福利基数信息
if (StringUtils.isNotEmpty(commonSiAcct.getSocialPaymentBaseString())) {
if (commonSiAcct != null && StringUtils.isNotEmpty(commonSiAcct.getSocialPaymentBaseString())) {
Map<String, Object> socialBaseJson = JSON.parseObject(commonSiAcct.getSocialPaymentBaseString(), new HashMap<String, Object>().getClass());
socialBaseJson.forEach((k, v) -> {
record.put(k + "socialBase", v);
});
}
if (StringUtils.isNotEmpty(commonSiAcct.getFundPaymentBaseString())) {
if (commonSiAcct != null && StringUtils.isNotEmpty(commonSiAcct.getFundPaymentBaseString())) {
Map<String, Object> fundBaseJson = JSON.parseObject(commonSiAcct.getFundPaymentBaseString(), new HashMap<String, Object>().getClass());
fundBaseJson.forEach((k, v) -> {
record.put(k + "fundBase", v);
});
}
if (StringUtils.isNotEmpty(commonSiAcct.getOtherPaymentBaseString())) {
if (commonSiAcct != null && StringUtils.isNotEmpty(commonSiAcct.getOtherPaymentBaseString())) {
Map<String, Object> otherBaseJson = JSON.parseObject(commonSiAcct.getOtherPaymentBaseString(), new HashMap<String, Object>().getClass());
otherBaseJson.forEach((k, v) -> {
record.put(k + "otherBase", v);
});
}
//社保-正常缴纳
if (StringUtils.isNotEmpty(commonSiAcct.getSocialPerJson())) {
if (commonSiAcct != null && StringUtils.isNotEmpty(commonSiAcct.getSocialPerJson())) {
Map<String, Object> socialJson = JSON.parseObject(commonSiAcct.getSocialPerJson(), new HashMap<String, Object>().getClass());
socialJson.forEach((k, v) -> {
record.put(k + "socialCommonPer", v);
});
}
if (StringUtils.isNotEmpty(commonSiAcct.getSocialComJson())) {
if (commonSiAcct != null && StringUtils.isNotEmpty(commonSiAcct.getSocialComJson())) {
Map<String, Object> socialJson = JSON.parseObject(commonSiAcct.getSocialComJson(), new HashMap<String, Object>().getClass());
socialJson.forEach((k, v) -> {
record.put(k + "socialCommonCom", v);
@ -1031,13 +1031,13 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
record.put("socialComBalanceSum", balanceSiAcct != null ? balanceSiAcct.getSocialComSum() : new BigDecimal("0"));
//公积金-正常缴纳
if (StringUtils.isNotEmpty(commonSiAcct.getFundPerJson())) {
if (commonSiAcct != null && StringUtils.isNotEmpty(commonSiAcct.getFundPerJson())) {
Map<String, Object> socialJson = JSON.parseObject(commonSiAcct.getFundPerJson(), new HashMap<String, Object>().getClass());
socialJson.forEach((k, v) -> {
record.put(k + "fundCommonPer", v);
});
}
if (StringUtils.isNotEmpty(commonSiAcct.getFundComJson())) {
if (commonSiAcct != null && StringUtils.isNotEmpty(commonSiAcct.getFundComJson())) {
Map<String, Object> socialJson = JSON.parseObject(commonSiAcct.getFundComJson(), new HashMap<String, Object>().getClass());
socialJson.forEach((k, v) -> {
record.put(k + "fundCommonCom", v);
@ -1077,13 +1077,13 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
record.put("fundComBalanceSum", balanceSiAcct != null ? balanceSiAcct.getFundComSum() : new BigDecimal("0"));
//其他福利-正常缴纳
if (StringUtils.isNotEmpty(commonSiAcct.getOtherPerJson())) {
if (commonSiAcct != null && StringUtils.isNotEmpty(commonSiAcct.getOtherPerJson())) {
Map<String, Object> otherJson = JSON.parseObject(commonSiAcct.getOtherPerJson(), new HashMap<String, Object>().getClass());
otherJson.forEach((k, v) -> {
record.put(k + "otherCommonPer", v);
});
}
if (StringUtils.isNotEmpty(commonSiAcct.getOtherComJson())) {
if (commonSiAcct != null && StringUtils.isNotEmpty(commonSiAcct.getOtherComJson())) {
Map<String, Object> otherJson = JSON.parseObject(commonSiAcct.getOtherComJson(), new HashMap<String, Object>().getClass());
otherJson.forEach((k, v) -> {
record.put(k + "otherCommonCom", v);

View File

@ -197,11 +197,16 @@ public class SISchemeServiceImpl extends Service implements SISchemeService {
@Override
public PageInfo<InsuranceSchemeListDTO> list(InsuranceSchemeParam queryParam) {
SalaryAssert.notNull(queryParam.getWelfareTypeEnum(), SalaryI18nUtil.getI18nLabel(84026, "参数错误"));
queryParam.setWelfareType(queryParam.getWelfareTypeEnum().getValue());
if (queryParam.getPaymentTypeEnum() != null) {
queryParam.setPaymentType(queryParam.getPaymentTypeEnum().getValue());
}
Long currentEmployeeId = (long) user.getUID();
List<InsuranceSchemePO> insuranceSchemePOS;
Boolean needAuth = getTaxAgentService().isNeedAuth(currentEmployeeId);
if (needAuth) {
insuranceSchemePOS = getInsuranceSchemeMapper().listByWelfareType(queryParam.getWelfareTypeEnum().getValue());
// insuranceSchemePOS = getInsuranceSchemeMapper().listByWelfareType(queryParam.getWelfareTypeEnum().getValue());
insuranceSchemePOS = getInsuranceSchemeMapper().list(queryParam);
Boolean isAdminEnable = getTaxAgentService().isAdminEnable((long) user.getUID());
if (isAdminEnable) {
//管理员
@ -220,7 +225,8 @@ public class SISchemeServiceImpl extends Service implements SISchemeService {
insuranceSchemePOS = new ArrayList<>();
}
} else {
insuranceSchemePOS = getInsuranceSchemeMapper().listByWelfareType(queryParam.getWelfareTypeEnum().getValue());
// insuranceSchemePOS = getInsuranceSchemeMapper().listByWelfareType(queryParam.getWelfareTypeEnum().getValue());
insuranceSchemePOS = getInsuranceSchemeMapper().list(queryParam);
}
PageInfo<InsuranceSchemeListDTO> dtoPage = new PageInfo<>(InsuranceSchemeListDTO.class);