薪酬系统-福利台账,社保调差列表v1

This commit is contained in:
sy 2022-11-29 15:33:57 +08:00
parent f68219ff87
commit 2ceeeb165f
11 changed files with 194 additions and 11 deletions

View File

@ -30,7 +30,7 @@ public class InsuranceCompensationDTO {
private String originId;
/**
* 只读
* 只读true为实际调差记录false为调差配置数据非实际调差记录
*
*/
private Boolean status;
@ -88,7 +88,7 @@ public class InsuranceCompensationDTO {
/**
* 对象选项
*/
private List<Map<String,String>> targetOptions;
private Map<String,String> targetOptions;
/**
* 账单月份

View File

@ -4,6 +4,7 @@ import com.engine.salary.entity.siaccount.po.InsuranceCompensationConfigPO;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
import java.util.List;
public interface InsuranceCompensationConfigMapper {
@ -12,4 +13,7 @@ public interface InsuranceCompensationConfigMapper {
void insert(InsuranceCompensationConfigPO compensationConfigPO);
void deleteByPayOrg(Long paymentOrganization);
List<InsuranceCompensationConfigPO> queryByBillMonthAndPayOrg(String billMonth, Long paymentOrganization);
}

View File

@ -159,4 +159,13 @@
WHERE payment_organization = #{paymentOrganization}
AND delete_type = 0
</delete>
<select id="queryByBillMonthAndPayOrg" resultMap="BaseResultMap" parameterType="Long">
SELECT
<include refid="baseColumns"/>
FROM hrsa_compensation_config t
WHERE t.bill_month = #{billMonth}
AND t.payment_organization = #{paymentOrganization}
AND t.delete_type = 0
</select>
</mapper>

View File

@ -4,6 +4,7 @@ import com.engine.salary.entity.siaccount.po.InsuranceCompensationPO;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
import java.util.List;
public interface InsuranceCompensationMapper {
@ -13,5 +14,7 @@ public interface InsuranceCompensationMapper {
InsuranceCompensationPO getById(Long id);
List<InsuranceCompensationPO> queryByBillMonthAndPayOrg(String billMonth, Long paymentOrganization);
void deleteById(Long id);
}

View File

@ -201,6 +201,15 @@
WHERE t.id = #{id} AND t.delete_type = 0
</select>
<select id="queryByBillMonthAndPayOrg" resultMap="BaseResultMap" parameterType="Long">
SELECT
<include refid="baseColumns"/>
FROM hrsa_compensation_log t
WHERE t.bill_month = #{billMonth}
AND t.payment_organization = #{paymentOrganization}
AND t.delete_type = 0
</select>
<delete id="deleteById">
UPDATE hrsa_compensation_log
SET delete_type = 1

View File

@ -3,6 +3,7 @@ package com.engine.salary.service;
import com.cloudstore.eccom.pc.table.WeaTableColumn;
import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO;
import com.engine.salary.entity.siaccount.po.InsuranceAccountInspectPO;
import com.engine.salary.entity.siaccount.po.InsuranceCompensationPO;
import java.util.List;
@ -26,5 +27,10 @@ public interface ColumnBuildService {
List<WeaTableColumn> buildCommonColumns(List<InsuranceAccountDetailPO> pos);
List<WeaTableColumn> buildInspectColumns(List<InsuranceAccountInspectPO> pos, Long paymentOrganization);
/**
* 调差详情表头元素
*/
List<WeaTableColumn> buildCompensationColumns();
}

View File

@ -28,4 +28,9 @@ public interface SICompensationService {
* 社保调差撤回
*/
String compensationRevert(InsuranceCompensationDTO param);
/**
* 社保调差历史记录列表
*/
Map<String, Object> compensationList(String billMonth, Long paymentOrganization);
}

View File

@ -388,4 +388,23 @@ public class ColumnBuildServiceImpl extends Service implements ColumnBuildServic
result.put(WelfareTypeEnum.OTHER.getValue(), otherColumns);
return result;
}
@Override
public List<WeaTableColumn> buildCompensationColumns() {
List<WeaTableColumn> list = new ArrayList<>();
WeaTableColumn weaTableNameColumn = new WeaTableColumn("300px",SalaryI18nUtil.getI18nLabel( 87000, "调差对象"), "target");
weaTableNameColumn.setFixed("left");
list.add(new WeaTableColumn("100px",SalaryI18nUtil.getI18nLabel( 87001, "统计调差福利"), "welfareType"));
list.add(new WeaTableColumn("200px",SalaryI18nUtil.getI18nLabel( 87001, "统计调差福利类型(单位)"), "categoryType"));
list.add(new WeaTableColumn("200px",SalaryI18nUtil.getI18nLabel( 87002, "国家核算金额(单位)"), "countryTotal"));
list.add(new WeaTableColumn("200px",SalaryI18nUtil.getI18nLabel( 87003, "公司核算金额(单位)"), "companyTotal"));
list.add(new WeaTableColumn("100px",SalaryI18nUtil.getI18nLabel( 87004, "应调差金额"), "adjustmentTotal"));
list.add(new WeaTableColumn("200px",SalaryI18nUtil.getI18nLabel( 87005, "调差到(单位)"), "adjustTo"));
return list;
}
}

View File

@ -2,10 +2,12 @@ package com.engine.salary.service.impl;
import com.alibaba.fastjson.JSON;
import com.alipay.oceanbase.jdbc.StringUtils;
import com.cloudstore.eccom.pc.table.WeaTableColumn;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.salary.constant.SalaryDefaultTenantConstant;
import com.engine.salary.encrypt.siaccount.InsuranceAccountDetailPOEncrypt;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.hrm.dto.HrmInfoDTO;
import com.engine.salary.entity.hrm.param.HrmQueryParam;
import com.engine.salary.entity.siaccount.dto.InsuranceCompensationDTO;
@ -13,13 +15,16 @@ import com.engine.salary.entity.siaccount.param.CompensationParam;
import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO;
import com.engine.salary.entity.siaccount.po.InsuranceCompensationConfigPO;
import com.engine.salary.entity.siaccount.po.InsuranceCompensationPO;
import com.engine.salary.entity.taxagent.dto.TaxAgentEmployeeDTO;
import com.engine.salary.entity.sicategory.po.ICategoryPO;
import com.engine.salary.enums.siaccount.PaymentStatusEnum;
import com.engine.salary.enums.sicategory.DeleteTypeEnum;
import com.engine.salary.exception.SalaryRunTimeException;
import com.engine.salary.mapper.datacollection.EmployMapper;
import com.engine.salary.mapper.siaccount.InsuranceAccountDetailMapper;
import com.engine.salary.mapper.siaccount.InsuranceCompensationConfigMapper;
import com.engine.salary.mapper.siaccount.InsuranceCompensationMapper;
import com.engine.salary.mapper.sicategory.ICategoryMapper;
import com.engine.salary.service.ColumnBuildService;
import com.engine.salary.service.SIAccountService;
import com.engine.salary.service.SICategoryService;
import com.engine.salary.service.SICompensationService;
@ -31,11 +36,12 @@ import com.engine.salary.util.page.PageInfo;
import com.engine.salary.util.page.SalaryPageUtil;
import com.google.common.collect.Lists;
import dm.jdbc.util.IdGenerator;
import org.springframework.beans.BeanUtils;
import weaver.hrm.User;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
@ -68,6 +74,11 @@ public class SICompensationServiceImpl extends Service implements SICompensation
private InsuranceCompensationConfigMapper getInsuranceCompensationConfigMapper() {
return MapperProxyFactory.getProxy(InsuranceCompensationConfigMapper.class);
}
public ColumnBuildService getColumnBuildService(User user) {
return ServiceUtil.getService(ColumnBuildServiceImpl.class, user);
}
/**
* 可调差人员
*/
@ -306,30 +317,30 @@ public class SICompensationServiceImpl extends Service implements SICompensation
String num = entry.getValue();
if (Objects.equals(String.valueOf(insuranceCompensationPO.getAdjustTo()), insuranceId)) {
BigDecimal adjustmentTo = new BigDecimal(insuranceCompensationPO.getAdjustmentTotal());
//回退单位缴纳明细
//回退调差单位缴纳明细
BigDecimal insuranceNum = new BigDecimal(num);
insuranceNum = insuranceNum.subtract(adjustmentTo);
socialJson.replace(insuranceId, insuranceNum.toPlainString());
insuranceAccountDetailPO.setSocialComJson(JSON.toJSONString(socialJson));
//回退差单位合计
//回退差单位合计
BigDecimal comSum = new BigDecimal(insuranceAccountDetailPO.getComSum());
comSum = comSum.subtract(adjustmentTo);
insuranceAccountDetailPO.setComSum(comSum.toPlainString());
//回退差社保单位合计
//回退差社保单位合计
BigDecimal socialComSum = new BigDecimal(insuranceAccountDetailPO.getSocialComSum());
socialComSum = socialComSum.subtract(adjustmentTo);
insuranceAccountDetailPO.setSocialComSum(socialComSum.toPlainString());
//回退差社保合计
//回退差社保合计
BigDecimal socialSum = new BigDecimal(insuranceAccountDetailPO.getSocialSum());
socialSum = socialSum.subtract(adjustmentTo);
insuranceAccountDetailPO.setSocialSum(socialSum.toPlainString());
//回退差合计
//回退差合计
BigDecimal totalSum = new BigDecimal(insuranceAccountDetailPO.getTotal());
totalSum = totalSum.subtract(adjustmentTo);
insuranceAccountDetailPO.setTotal(totalSum.toPlainString());
//更新社保差后的明细
//更新社保差后的明细
getInsuranceAccountDetailMapper().updateById(insuranceAccountDetailPO);
//删除差记录
//删除差记录
getInsuranceCompensationMapper().deleteById(param.getId());
}
@ -340,4 +351,102 @@ public class SICompensationServiceImpl extends Service implements SICompensation
}
return "撤回成功";
}
@Override
public Map<String, Object> compensationList(String billMonth, Long paymentOrganization) {
Map<String, Object> datas = new HashMap<>();
//入参判断
if (paymentOrganization == null || StringUtils.isBlank(billMonth)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误"));
}
//设置调差详情列表头
List<WeaTableColumn> weaTableColumn = getColumnBuildService(user).buildCompensationColumns();
//处理调差数据
List<InsuranceCompensationDTO> compensationDTOList = dealCompensationData(billMonth, paymentOrganization);
datas.put("columns", weaTableColumn);
datas.put("data", compensationDTOList);
return datas;
}
private List<InsuranceCompensationDTO> dealCompensationData(String billMonth, Long paymentOrganization) {
//获取调差历史记录数据
List<InsuranceCompensationPO> compensationPOList = getInsuranceCompensationMapper().queryByBillMonthAndPayOrg(billMonth, paymentOrganization);
//获取调差配置数据
List<InsuranceCompensationConfigPO> compensationConfigPOList = getInsuranceCompensationConfigMapper().queryByBillMonthAndPayOrg(billMonth, paymentOrganization);
List<InsuranceCompensationDTO> compensationDTOList = new ArrayList<>();
List<InsuranceAccountDetailPO> detailPOList = getInsuranceAccountDetailMapper().queryNormalListByBillMonth(billMonth, paymentOrganization);
Map<Long, InsuranceAccountDetailPO> detailPOMap = detailPOList.stream().collect(Collectors.toMap(InsuranceAccountDetailPO::getEmployeeId, Function.identity()));
List<DataCollectionEmployee> allEmployees = getEmployMapper().listAll();
Map<Long, String> usernameMap = SalaryEntityUtil.convert2Map(allEmployees, DataCollectionEmployee::getEmployeeId, DataCollectionEmployee::getUsername);
List<ICategoryPO> allCategoryList = MapperProxyFactory.getProxy(ICategoryMapper.class).listAll();
Map<Long, String> categoryNameMap = SalaryEntityUtil.convert2Map(allCategoryList, ICategoryPO::getId, ICategoryPO::getInsuranceName);
boolean haveCompensation = compensationPOList != null && compensationPOList.size() > 0;
//存在调差历史记录时输出记录数据
if (haveCompensation) {
for (InsuranceCompensationPO po : compensationPOList) {
InsuranceCompensationDTO dto = new InsuranceCompensationDTO();
BeanUtils.copyProperties(po, dto);
dto.setStatus(true);
//设置targetOptions
Map<String,String> targetOptions = new HashMap<>();
targetOptions.put("name", usernameMap.get(po.getEmployeeId()));
targetOptions.put("id", detailPOMap.get(po.getEmployeeId()).getId().toString());
dto.setTargetOptions(targetOptions);
//设置categoryTypeOptions
List<Map<String,String>> categoryTypeOptions = new ArrayList<>();
List<String> categoryTypeList = Arrays.asList(po.getCategoryType().split(","));
Map<String,String> categoryTypeMap = new HashMap<>();
for (String categoryType : categoryTypeList) {
categoryTypeMap.put("id", categoryType);
categoryTypeMap.put("content", categoryNameMap.get(Long.valueOf(categoryType)));
categoryTypeOptions.add(categoryTypeMap);
}
dto.setCategoryTypeOptions(categoryTypeOptions);
}
}
//不存在调差历史记录时输出调差配置数据
if (!haveCompensation && compensationConfigPOList.size() > 0) {
for (InsuranceCompensationConfigPO configPO : compensationConfigPOList) {
InsuranceCompensationDTO dto = new InsuranceCompensationDTO();
BeanUtils.copyProperties(configPO, dto);
dto.setStatus(false);
//设置targetOptions
Map<String,String> targetOptions = new HashMap<>();
targetOptions.put("name", usernameMap.get(configPO.getEmployeeId()));
targetOptions.put("id", detailPOMap.get(configPO.getEmployeeId()).getId().toString());
dto.setTargetOptions(targetOptions);
//设置categoryTypeOptions
List<Map<String,String>> categoryTypeOptions = new ArrayList<>();
List<String> categoryTypeList = Arrays.asList(configPO.getCategoryType().split(","));
Map<String,String> categoryTypeMap = new HashMap<>();
for (String categoryType : categoryTypeList) {
categoryTypeMap.put("id", categoryType);
categoryTypeMap.put("content", categoryNameMap.get(Long.valueOf(categoryType)));
categoryTypeOptions.add(categoryTypeMap);
}
dto.setCategoryTypeOptions(categoryTypeOptions);
}
}
return compensationDTOList;
}
}

View File

@ -773,5 +773,17 @@ public class SIAccountController {
return new ResponseResult<InsuranceCompensationDTO, String>(user).run(getSIAccountWrapper(user)::compensationBack, param);
}
/**
* 社保调差列表
*/
@POST
@Path("/compensationList")
@Produces(MediaType.APPLICATION_JSON)
public String compensationList(@Context HttpServletRequest request, @Context HttpServletResponse response,
@RequestBody InsuranceCompensationDTO param) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<InsuranceCompensationDTO, Map<String, Object>>(user).run(getSIAccountWrapper(user)::compensationList, param);
}
// **********************************调差 end*********************************/
}

View File

@ -107,4 +107,11 @@ public class SIAccountWrapper extends Service {
return getSICompensationService(user).compensationRevert(param);
}
/**
* 社保调差列表
*/
public Map<String, Object> compensationList(InsuranceCompensationDTO param) {
return getSICompensationService(user).compensationList(param.getBillMonth(), param.getPaymentOrganization());
}
}