增加福利数据供账套使用

This commit is contained in:
Chengliang 2022-04-27 14:36:05 +08:00
parent 52ae98df10
commit 7e28c952cc
4 changed files with 249 additions and 0 deletions

View File

@ -56,6 +56,8 @@ public interface InsuranceAccountDetailMapper {
*/
List<InsuranceAccountDetailPO> selectList(@Param("billMonth") String billMonth);
List<InsuranceAccountDetailPO> queryList(@Param("billMonth") String billMonth,@Param("employeeIds") Collection<Long> employeeIds);
/**
* 根据账单月份删除

View File

@ -155,6 +155,25 @@
AND t.bill_month = #{billMonth}
</select>
<select id="queryList" resultMap="BaseResultMap">
SELECT
t.employee_id,t.social_per_json,t.social_com_json,
t.fund_per_json,t.fund_com_json,t.other_per_json,
t.other_com_json,t.social_per_sum,t.social_com_sum,
t.fund_per_sum,t.fund_com_sum,t.other_per_sum,
t.other_com_sum,t.per_sum,t.com_sum
FROM
hrsa_bill_detail t
WHERE t.delete_type = 0
AND t.bill_month = #{billMonth}
<if test="employeeIds != null and employeeIds.size()>0">
AND employee_id IN
<foreach collection="employeeIds" open="(" item="employeeId" separator="," close=")">
#{employeeId}
</foreach>
</if>
</select>
<select id="selectAccountIds" resultType="java.lang.Long">
SELECT DISTINCT a.ID

View File

@ -177,6 +177,14 @@ public interface SIAccountService {
*/
PageInfo<InsuranceAccountViewListDTO> overView(InsuranceAccountDetailParam param);
/**
* 根据字段名提供对应的数据给账套使用
*
* @param billMonth
* @param employeeIds
* @return
*/
List<Map<String, Object>> welfareData(String billMonth, List<Long> employeeIds);
}

View File

@ -1,5 +1,6 @@
package com.engine.salary.service.impl;
import com.alibaba.fastjson.JSON;
import com.api.browser.bean.SearchConditionGroup;
import com.api.browser.bean.SearchConditionItem;
import com.api.browser.bean.SearchConditionOption;
@ -33,6 +34,7 @@ import com.engine.salary.service.ColumnBuildService;
import com.engine.salary.service.RecordsBuildService;
import com.engine.salary.service.SIAccountService;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
@ -44,6 +46,7 @@ import com.engine.salary.util.page.Column;
import com.engine.salary.util.page.PageInfo;
import com.engine.salary.util.page.PageUtil;
import com.engine.salary.util.valid.ValidUtil;
import com.google.common.collect.Lists;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import weaver.hrm.User;
@ -582,6 +585,65 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
return pageInfos;
}
@Override
public List<Map<String, Object>> welfareData(String billMonth, List<Long> employeeIds) {
InsuranceAccountBatchPO insuranceAccountBatchPO = MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class).getByBillMonth(billMonth);
if (insuranceAccountBatchPO == null || Objects.equals(BillStatusEnum.NOT_ARCHIVED.getValue(), insuranceAccountBatchPO.getBillStatus())) {
return Lists.newArrayList();
}
List<InsuranceAccountDetailPO> list = queryList(billMonth, employeeIds);
List<Map<String, Object>> result = new ArrayList<>();
list.stream().forEach(item -> {
Map<String, Object> record = new HashMap<>();
record.put("employeeId", item.getEmployeeId());
if (StringUtils.isNotEmpty(item.getSocialPerJson())) {
Map<String, Object> socialJson = JSON.parseObject(item.getSocialPerJson(), new HashMap<String, Object>().getClass());
socialJson.forEach((k, v) -> {
record.put(k + "socialPer", v);
});
}
if (StringUtils.isNotEmpty(item.getSocialComJson())) {
Map<String, Object> socialJson = JSON.parseObject(item.getSocialComJson(), new HashMap<String, Object>().getClass());
socialJson.forEach((k, v) -> {
record.put(k + "socialCom", v);
});
}
record.put("socialPerSum", item.getSocialPerSum());
record.put("socialComSum", item.getSocialComSum());
if (StringUtils.isNotEmpty(item.getFundPerJson())) {
Map<String, Object> fundPerJson = JSON.parseObject(item.getFundPerJson(), new HashMap<String, Object>().getClass());
fundPerJson.forEach((k, v) -> {
record.put(k + "fundPer", v);
});
}
if (StringUtils.isNotEmpty(item.getFundComJson())) {
Map<String, Object> fundPerJson = JSON.parseObject(item.getFundComJson(), new HashMap<String, Object>().getClass());
fundPerJson.forEach((k, v) -> {
record.put(k + "fundCom", v);
});
}
record.put("fundPerSum", item.getFundPerSum());
record.put("fundComSum", item.getFundComSum());
if (StringUtils.isNotEmpty(item.getOtherPerJson())) {
Map<String, Object> fundPerJson = JSON.parseObject(item.getOtherPerJson(), new HashMap<String, Object>().getClass());
fundPerJson.forEach((k, v) -> {
record.put(k + "otherPer", v);
});
}
if (StringUtils.isNotEmpty(item.getOtherComJson())) {
Map<String, Object> fundComJson = JSON.parseObject(item.getOtherComJson(), new HashMap<String, Object>().getClass());
fundComJson.forEach((k, v) -> {
record.put(k + "otherCom", v);
});
}
record.put("otherPerSum", item.getOtherPerSum());
record.put("otherComSum", item.getOtherComSum());
record.put("perSum", item.getPerSum());
record.put("comSum", item.getComSum());
result.add(record);
});
return result;
}
@ -603,6 +665,164 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
}
public List<InsuranceAccountDetailPO> queryList(String billMonth, List<Long> employeeIds) {
List<InsuranceAccountDetailPO> list = buildNewInsuranceDetailPOS(MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class).queryList(billMonth,employeeIds));
return list;
}
public List<InsuranceAccountDetailPO> buildNewInsuranceDetailPOS(List<InsuranceAccountDetailPO> list) {
List<InsuranceAccountDetailPO> newList = new ArrayList<>();
if (CollectionUtils.isEmpty(list)) {
return newList;
}
Map<Long, List<InsuranceAccountDetailPO>> employeeMap = list.stream().filter(item -> item.getEmployeeId() != null)
.collect(Collectors.groupingBy(InsuranceAccountDetailPO::getEmployeeId));
for (Map.Entry<Long, List<InsuranceAccountDetailPO>> entry : employeeMap.entrySet()) {
Long k = entry.getKey();
List<InsuranceAccountDetailPO> v = entry.getValue();
InsuranceAccountDetailPO insuranceAccountDetailPO = new InsuranceAccountDetailPO();
insuranceAccountDetailPO.setEmployeeId(k);
Map<String, String> socialPerMap = new HashMap<>();
Map<String, String> fundPerMap = new HashMap<>();
Map<String, String> otherPerMap = new HashMap<>();
Map<String, String> socialComMap = new HashMap<>();
Map<String, String> fundComMap = new HashMap<>();
Map<String, String> otherComMap = new HashMap<>();
BigDecimal socialPer = new BigDecimal("0");
BigDecimal socialCom = new BigDecimal("0");
BigDecimal fundPer = new BigDecimal("0");
BigDecimal fundCom = new BigDecimal("0");
BigDecimal otherPer = new BigDecimal("0");
BigDecimal otherCom = new BigDecimal("0");
BigDecimal perSum = new BigDecimal("0");
BigDecimal comSum = new BigDecimal("0");
for (InsuranceAccountDetailPO item : v) {
BigDecimal socialPerSum = StringUtils.isBlank(item.getSocialPerSum()) ? new BigDecimal("0") : new BigDecimal(item.getSocialPerSum());
BigDecimal socialComSum = StringUtils.isBlank(item.getSocialComSum()) ? new BigDecimal("0") : new BigDecimal(item.getSocialComSum());
BigDecimal fundPerSum = StringUtils.isBlank(item.getFundPerSum()) ? new BigDecimal("0") : new BigDecimal(item.getFundPerSum());
BigDecimal fundComSum = StringUtils.isBlank(item.getFundComSum()) ? new BigDecimal("0") : new BigDecimal(item.getFundComSum());
BigDecimal otherPerSum = StringUtils.isBlank(item.getOtherPerSum()) ? new BigDecimal("0") : new BigDecimal(item.getOtherPerSum());
BigDecimal otherComSum = StringUtils.isBlank(item.getOtherComSum()) ? new BigDecimal("0") : new BigDecimal(item.getOtherComSum());
BigDecimal perSumItem = StringUtils.isBlank(item.getPerSum()) ? new BigDecimal("0") : new BigDecimal(item.getPerSum());
BigDecimal comSumItem = StringUtils.isBlank(item.getComSum()) ? new BigDecimal("0") : new BigDecimal(item.getComSum());
socialPer = socialPer.add(socialPerSum);
socialCom = socialCom.add(socialComSum);
fundPer = fundPer.add(fundPerSum);
fundCom = fundCom.add(fundComSum);
otherPer = otherPer.add(otherPerSum);
otherCom = otherCom.add(otherComSum);
perSum = perSum.add(perSumItem);
comSum = comSum.add(comSumItem);
if (StringUtils.isNotBlank(item.getSocialPerJson())) {
Map<String, String> socialJson = JSON.parseObject(item.getSocialPerJson(), new HashMap<String, String>().getClass());
socialJson.forEach((insuranceId, num) -> {
if (socialPerMap.get(insuranceId) == null) {
socialPerMap.put(insuranceId, num);
} else {
String oldNum = socialPerMap.get(insuranceId);
BigDecimal insuanceNum = new BigDecimal("0");
BigDecimal oldDecimal = new BigDecimal(oldNum);
BigDecimal numDecimal = num == null ? new BigDecimal("0") : new BigDecimal(num);
insuanceNum = insuanceNum.add(numDecimal).add(oldDecimal);
socialPerMap.put(insuranceId, insuanceNum.toPlainString());
}
});
}
if (StringUtils.isNotBlank(item.getSocialComJson())) {
Map<String, String> socialJson = JSON.parseObject(item.getSocialComJson(), new HashMap<String, String>().getClass());
socialJson.forEach((insuranceId, num) -> {
if (socialComMap.get(insuranceId) == null) {
socialComMap.put(insuranceId, num);
} else {
String oldNum = socialComMap.get(insuranceId);
BigDecimal insuanceNum = new BigDecimal("0");
BigDecimal oldDecimal = new BigDecimal(oldNum);
BigDecimal numDecimal = num == null ? new BigDecimal("0") : new BigDecimal(num);
insuanceNum = insuanceNum.add(numDecimal).add(oldDecimal);
socialComMap.put(insuranceId, insuanceNum.toPlainString());
}
});
}
if (StringUtils.isNotBlank(item.getFundPerJson())) {
Map<String, String> fundJson = JSON.parseObject(item.getFundPerJson(), new HashMap<String, String>().getClass());
fundJson.forEach((insuranceId, num) -> {
if (fundPerMap.get(insuranceId) == null) {
fundPerMap.put(insuranceId, num);
} else {
String oldNum = fundPerMap.get(insuranceId);
BigDecimal insuanceNum = new BigDecimal("0");
BigDecimal oldDecimal = new BigDecimal(oldNum);
BigDecimal numDecimal = num == null ? new BigDecimal("0") : new BigDecimal(num);
insuanceNum = insuanceNum.add(numDecimal).add(oldDecimal);
fundPerMap.put(insuranceId, insuanceNum.toPlainString());
}
});
}
if (StringUtils.isNotBlank(item.getFundComJson())) {
Map<String, String> fundJson = JSON.parseObject(item.getFundComJson(), new HashMap<String, String>().getClass());
fundJson.forEach((insuranceId, num) -> {
if (fundComMap.get(insuranceId) == null) {
fundComMap.put(insuranceId, num);
} else {
String oldNum = fundComMap.get(insuranceId);
BigDecimal insuanceNum = new BigDecimal("0");
BigDecimal oldDecimal = new BigDecimal(oldNum);
BigDecimal numDecimal = num == null ? new BigDecimal("0") : new BigDecimal(num);
insuanceNum = insuanceNum.add(numDecimal).add(oldDecimal);
fundComMap.put(insuranceId, insuanceNum.toPlainString());
}
});
}
if (StringUtils.isNotBlank(item.getOtherPerJson())) {
Map<String, String> otherJson = JSON.parseObject(item.getOtherPerJson(), new HashMap<String, String>().getClass());
otherJson.forEach((insuranceId, num) -> {
if (otherPerMap.get(insuranceId) == null) {
otherPerMap.put(insuranceId, num);
} else {
String oldNum = otherPerMap.get(insuranceId);
BigDecimal insuanceNum = new BigDecimal("0");
BigDecimal oldDecimal = new BigDecimal(oldNum);
BigDecimal numDecimal = num == null ? new BigDecimal("0") : new BigDecimal(num);
insuanceNum = insuanceNum.add(numDecimal).add(oldDecimal);
otherPerMap.put(insuranceId, insuanceNum.toPlainString());
}
});
}
if (StringUtils.isNotBlank(item.getOtherComJson())) {
Map<String, String> otherJson = JSON.parseObject(item.getOtherComJson(), new HashMap<String, String>().getClass());
otherJson.forEach((insuranceId, num) -> {
if (otherComMap.get(insuranceId) == null) {
otherComMap.put(insuranceId, num);
} else {
String oldNum = otherComMap.get(insuranceId);
BigDecimal insuanceNum = new BigDecimal("0");
BigDecimal oldDecimal = new BigDecimal(oldNum);
BigDecimal numDecimal = num == null ? new BigDecimal("0") : new BigDecimal(num);
insuanceNum = insuanceNum.add(numDecimal).add(oldDecimal);
otherComMap.put(insuranceId, insuanceNum.toPlainString());
}
});
}
}
insuranceAccountDetailPO.setSocialPerJson(JSON.toJSONString(socialPerMap));
insuranceAccountDetailPO.setSocialComJson(JSON.toJSONString(socialComMap));
insuranceAccountDetailPO.setFundPerJson(JSON.toJSONString(fundPerMap));
insuranceAccountDetailPO.setFundComJson(JSON.toJSONString(fundComMap));
insuranceAccountDetailPO.setOtherPerJson(JSON.toJSONString(otherPerMap));
insuranceAccountDetailPO.setOtherComJson(JSON.toJSONString(otherComMap));
insuranceAccountDetailPO.setSocialPerSum(socialPer.toPlainString());
insuranceAccountDetailPO.setSocialComSum(socialCom.toPlainString());
insuranceAccountDetailPO.setFundPerSum(fundPer.toPlainString());
insuranceAccountDetailPO.setFundComSum(fundCom.toPlainString());
insuranceAccountDetailPO.setOtherPerSum(otherPer.toPlainString());
insuranceAccountDetailPO.setOtherComSum(otherCom.toPlainString());
insuranceAccountDetailPO.setPerSum(perSum.toPlainString());
insuranceAccountDetailPO.setComSum(comSum.toPlainString());
newList.add(insuranceAccountDetailPO);
}
return newList;
}