weaver-hrm-salary/src/com/engine/salary/service/impl/ColumnBuildServiceImpl.java

389 lines
22 KiB
Java
Raw Normal View History

2022-04-12 19:29:19 +08:00
package com.engine.salary.service.impl;
import com.alibaba.fastjson.JSON;
import com.cloudstore.eccom.constant.WeaBoolAttr;
import com.cloudstore.eccom.pc.table.WeaTableColumn;
import com.engine.core.impl.Service;
2022-04-16 16:43:33 +08:00
import com.engine.salary.biz.SIArchivesBiz;
2022-04-12 19:29:19 +08:00
import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO;
import com.engine.salary.entity.siaccount.po.InsuranceAccountInspectPO;
2022-04-16 16:43:33 +08:00
import com.engine.salary.entity.siarchives.po.InsuranceArchivesAccountPO;
import com.engine.salary.entity.siarchives.po.InsuranceArchivesFundSchemePO;
import com.engine.salary.entity.siarchives.po.InsuranceArchivesOtherSchemePO;
import com.engine.salary.entity.siarchives.po.InsuranceArchivesSocialSchemePO;
2022-04-12 19:29:19 +08:00
import com.engine.salary.entity.sicategory.po.ICategoryPO;
import com.engine.salary.enums.sicategory.WelfareTypeEnum;
import com.engine.salary.mapper.sicategory.ICategoryMapper;
import com.engine.salary.service.ColumnBuildService;
import com.engine.salary.util.SalaryI18nUtil;
import com.engine.salary.util.db.MapperProxyFactory;
import org.apache.commons.lang3.StringUtils;
import java.util.*;
import java.util.stream.Collectors;
/**
* @Author weaver_cl
2022-07-13 11:45:16 +08:00
* @Description:
2022-04-12 19:29:19 +08:00
* @Date 2022/4/12
* @Version V1.0
**/
public class ColumnBuildServiceImpl extends Service implements ColumnBuildService {
@Override
public List<WeaTableColumn> buildCommonColumnsWithStyle(List<InsuranceAccountDetailPO> pos, Long employeeId, String tenantKey, boolean flag) {
List<WeaTableColumn> list = new ArrayList<>();
Map<String, String> categoryIdNameMap = MapperProxyFactory.getProxy(ICategoryMapper.class).listAll().stream().collect(Collectors.toMap(ICategoryPO -> String.valueOf(ICategoryPO.getId()), ICategoryPO::getInsuranceName));
Map<Integer, Map<String, String>> columns = buildPaymentTitle(pos, categoryIdNameMap, employeeId, tenantKey);
Map<Integer, Map<String, String>> personColumns = buildPersonalTitle(pos, categoryIdNameMap, employeeId, tenantKey);
Map<Integer, Map<String, String>> comColumns = buildComTitle(pos, categoryIdNameMap, employeeId, tenantKey);
WeaTableColumn weaTableNameColumn = new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 85429, "姓名"), "userName");
weaTableNameColumn.setFixed("left");
WeaTableColumn idColumn = new WeaTableColumn("150px", "id", "id");
idColumn.setIsPrimarykey(WeaBoolAttr.TRUE);
idColumn.setDisplay(WeaBoolAttr.FALSE);
list.add(idColumn);
WeaTableColumn employeeIdColumn = new WeaTableColumn("150px", "人员信息表的主键id", "employeeId");
employeeIdColumn.setDisplay(WeaBoolAttr.FALSE);
list.add(employeeIdColumn);
list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 86185, "部门"), "department"));
list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 86186, "手机号"), "mobile"));
list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 86187, "员工状态"), "employeeStatus"));
list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 100377, "数据来源"), "sourceFrom"));
if (flag) {
list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 100379, "补缴月份"), "supplementaryMonth"));
}
list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 91325, "个税扣缴义务人"), "socialPayOrg"));
2022-04-12 19:29:19 +08:00
list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 91324, "社保账号"), "socialAccount"));
list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 91323, "社保方案名称"), "socialSchemeName"));
//组装社保基数
columns.get(WelfareTypeEnum.SOCIAL_SECURITY.getValue()).forEach((k, v) -> {
list.add(new WeaTableColumn("150px",k, v));
});
// list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 91488, "公积金缴纳组织"), "fundPayOrg"));
2022-04-12 19:29:19 +08:00
list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 91486, "公积金账号"), "fundAccount"));
list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 91485, "公积金方案名称"), "fundSchemeName"));
//组装公积金基数
columns.get(WelfareTypeEnum.ACCUMULATION_FUND.getValue()).forEach((k, v) -> {
list.add(new WeaTableColumn("150px",k, v));
});
list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 91487, "补充公积金账号"), "supplementFundAccount"));
// list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 91497, "其他福利缴纳组织"), "otherPayOrg"));
2022-04-12 19:29:19 +08:00
list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel(91496, "其他福利方案名称"), "otherSchemeName"));
columns.get(WelfareTypeEnum.OTHER.getValue()).forEach((k, v) -> {
list.add(new WeaTableColumn("150px",k, v));
});
personColumns.get(WelfareTypeEnum.SOCIAL_SECURITY.getValue()).forEach((k, v) -> {
list.add(new WeaTableColumn("150px",k, v));
});
list.add(new WeaTableColumn("150px","<span style=\"color:blue\">" + SalaryI18nUtil.getI18nLabel( 100388, "社保个人合计") + "</span>", "socialPerSum"));
personColumns.get(WelfareTypeEnum.ACCUMULATION_FUND.getValue()).forEach((k, v) -> {
list.add(new WeaTableColumn("150px",k, v));
});
list.add(new WeaTableColumn("150px","<span style=\"color:blue\">" + SalaryI18nUtil.getI18nLabel( 100390, "公积金个人合计") + "</span>", "fundPerSum"));
personColumns.get(WelfareTypeEnum.OTHER.getValue()).forEach((k, v) -> {
list.add(new WeaTableColumn("150px",k, v));
});
list.add(new WeaTableColumn("150px","<span style=\"color:blue\">" + SalaryI18nUtil.getI18nLabel( 100392, "其他福利个人合计") + "</span>", "otherPerSum"));
list.add(new WeaTableColumn("150px","<span style=\"color:blue\">" + SalaryI18nUtil.getI18nLabel( 100393, "个人合计") + "</span>", "perSum"));
comColumns.get(WelfareTypeEnum.SOCIAL_SECURITY.getValue()).forEach((k, v) -> {
list.add(new WeaTableColumn("150px",k, v));
});
list.add(new WeaTableColumn("150px","<span style=\"color:blue\">" + SalaryI18nUtil.getI18nLabel( 100394, "社保单位合计") + "</span>", "socialComSum"));
comColumns.get(WelfareTypeEnum.ACCUMULATION_FUND.getValue()).forEach((k, v) -> {
list.add(new WeaTableColumn("150px",k, v));
});
list.add(new WeaTableColumn("150px","<span style=\"color:blue\">" + SalaryI18nUtil.getI18nLabel( 100395, "公积金单位合计") + "</span>", "fundComSum"));
comColumns.get(WelfareTypeEnum.OTHER.getValue()).forEach((k, v) -> {
list.add(new WeaTableColumn("150px",k, v));
});
list.add(new WeaTableColumn("150px","<span style=\"color:blue\">" + SalaryI18nUtil.getI18nLabel( 100396, "其他福利单位合计") + "</span>", "otherComSum"));
list.add(new WeaTableColumn("150px","<span style=\"color:blue\">" + SalaryI18nUtil.getI18nLabel( 100397, "单位合计") + "</span>", "comSum"));
list.add(new WeaTableColumn("150px","<span style=\"color:blue\">" + SalaryI18nUtil.getI18nLabel( 100398, "社保合计") + "</span>", "socialSum"));
list.add(new WeaTableColumn("150px","<span style=\"color:blue\">" + SalaryI18nUtil.getI18nLabel( 100399, "公积金合计") + "</span>", "fundSum"));
list.add(new WeaTableColumn("150px","<span style=\"color:blue\">" + SalaryI18nUtil.getI18nLabel( 100400, "其他福利合计") + "</span>", "otherSum"));
list.add(new WeaTableColumn("150px","<span style=\"color:blue\">" + SalaryI18nUtil.getI18nLabel( 93278, "合计") + "</span>", "total"));
return list;
}
private Map<Integer, Map<String, String>> buildPaymentTitle(List<InsuranceAccountDetailPO> pos, Map<String, String> categoryIdNameMap, Long employeeId, String tenantKey) {
Set<String> socailIds = new HashSet<>();
Set<String> fundIds = new HashSet<>();
Set<String> otherIds = new HashSet<>();
Map<Integer, Map<String, String>> result = new HashMap<>();
pos.stream().forEach(item -> {
if (StringUtils.isNotBlank(item.getSocialPaymentBaseString())) {
Map<String, String> socialJson = JSON.parseObject(item.getSocialPaymentBaseString(), new HashMap<String, String>().getClass());
2022-07-21 17:28:47 +08:00
if(socialJson!=null){
socialJson.forEach((k, v) -> {
socailIds.add(k);
});
}
2022-04-12 19:29:19 +08:00
}
if (StringUtils.isNotBlank(item.getFundPaymentBaseString())) {
Map<String, String> fundJson = JSON.parseObject(item.getFundPaymentBaseString(), new HashMap<String, String>().getClass());
2022-07-21 17:28:47 +08:00
if(fundJson!=null){
fundJson.forEach((k, v) -> {
fundIds.add(k);
});
}
2022-04-12 19:29:19 +08:00
}
if (StringUtils.isNotBlank(item.getOtherPaymentBaseString())) {
Map<String, String> otherJson = JSON.parseObject(item.getOtherPaymentBaseString(), new HashMap<String, String>().getClass());
2022-07-21 17:28:47 +08:00
if(otherJson!=null){
otherJson.forEach((k, v) -> {
otherIds.add(k);
});
}
2022-04-12 19:29:19 +08:00
}
});
Map<String, String> socialColumns = new HashMap<>();
Map<String, String> fundColumns = new HashMap<>();
Map<String, String> otherColumns = new HashMap<>();
socailIds.stream().forEach(social -> {
if (categoryIdNameMap.containsKey(social)) {
socialColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel(100293, "申报基数"), social + "socialBase");
}
});
fundIds.stream().forEach(social -> {
if (categoryIdNameMap.containsKey(social)) {
fundColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel( 100293, "申报基数"), social + "fundBase");
}
});
otherIds.stream().forEach(social -> {
if (categoryIdNameMap.containsKey(social)) {
otherColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel( 100293, "申报基数"), social + "otherBase");
}
});
result.put(WelfareTypeEnum.SOCIAL_SECURITY.getValue(), socialColumns);
result.put(WelfareTypeEnum.ACCUMULATION_FUND.getValue(), fundColumns);
result.put(WelfareTypeEnum.OTHER.getValue(), otherColumns);
return result;
}
private Map<Integer, Map<String, String>> buildPersonalTitle(List<InsuranceAccountDetailPO> pos, Map<String, String> categoryIdNameMap, Long employeeId, String tenantKey) {
Set<String> socailIds = new HashSet<>();
Set<String> fundIds = new HashSet<>();
Set<String> otherIds = new HashSet<>();
Map<Integer, Map<String, String>> result = new HashMap<>();
pos.stream().forEach(item -> {
if (StringUtils.isNotBlank(item.getSocialPerJson())) {
Map<String, String> socialJson = JSON.parseObject(item.getSocialPerJson(), new HashMap<String, String>().getClass());
2022-07-21 17:28:47 +08:00
if(socialJson!=null){
socialJson.forEach((k, v) -> {
socailIds.add(k);
});
}
2022-04-12 19:29:19 +08:00
}
if (StringUtils.isNotBlank(item.getFundPerJson())) {
Map<String, String> fundJson = JSON.parseObject(item.getFundPerJson(), new HashMap<String, String>().getClass());
2022-07-21 17:28:47 +08:00
if(fundJson!=null){
fundJson.forEach((k, v) -> {
fundIds.add(k);
});
}
2022-04-12 19:29:19 +08:00
}
if (StringUtils.isNotBlank(item.getOtherPerJson())) {
Map<String, String> otherJson = JSON.parseObject(item.getOtherPerJson(), new HashMap<String, String>().getClass());
2022-07-21 17:28:47 +08:00
if(otherJson!=null){
otherJson.forEach((k, v) -> {
otherIds.add(k);
});
}
2022-04-12 19:29:19 +08:00
}
});
Map<String, String> socialColumns = new HashMap<>();
Map<String, String> fundColumns = new HashMap<>();
Map<String, String> otherColumns = new HashMap<>();
socailIds.stream().forEach(social -> {
if (categoryIdNameMap.containsKey(social)) {
socialColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel( 87159, "个人"), social + "socialPer");
}
});
fundIds.stream().forEach(social -> {
if (categoryIdNameMap.containsKey(social)) {
fundColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel( 87159, "个人"), social + "fundPer");
}
});
otherIds.stream().forEach(social -> {
if (categoryIdNameMap.containsKey(social)) {
otherColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel( 87159, "个人"), social + "otherPer");
}
});
result.put(WelfareTypeEnum.SOCIAL_SECURITY.getValue(), socialColumns);
result.put(WelfareTypeEnum.ACCUMULATION_FUND.getValue(), fundColumns);
result.put(WelfareTypeEnum.OTHER.getValue(), otherColumns);
return result;
}
private Map<Integer, Map<String, String>> buildComTitle(List<InsuranceAccountDetailPO> pos, Map<String, String> categoryIdNameMap, Long employeeId, String tenantKey) {
Set<String> socailIds = new HashSet<>();
Set<String> fundIds = new HashSet<>();
Set<String> otherIds = new HashSet<>();
Map<Integer, Map<String, String>> result = new HashMap<>();
pos.stream().forEach(item -> {
if (StringUtils.isNotBlank(item.getSocialComJson())) {
Map<String, String> socialJson = JSON.parseObject(item.getSocialComJson(), new HashMap<String, String>().getClass());
2022-07-21 17:28:47 +08:00
if(socialJson!=null){
socialJson.forEach((k, v) -> {
socailIds.add(k);
});
}
2022-04-12 19:29:19 +08:00
}
if (StringUtils.isNotBlank(item.getFundComJson())) {
Map<String, String> fundJson = JSON.parseObject(item.getFundComJson(), new HashMap<String, String>().getClass());
2022-07-21 17:28:47 +08:00
if(fundJson!=null){
fundJson.forEach((k, v) -> {
fundIds.add(k);
});
}
2022-04-12 19:29:19 +08:00
}
if (StringUtils.isNotBlank(item.getOtherComJson())) {
Map<String, String> otherJson = JSON.parseObject(item.getOtherComJson(), new HashMap<String, String>().getClass());
2022-07-21 17:28:47 +08:00
if(otherJson!=null){
otherJson.forEach((k, v) -> {
otherIds.add(k);
});
}
2022-04-12 19:29:19 +08:00
}
});
Map<String, String> socialColumns = new HashMap<>();
Map<String, String> fundColumns = new HashMap<>();
Map<String, String> otherColumns = new HashMap<>();
socailIds.stream().forEach(social -> {
if (categoryIdNameMap.containsKey(social)) {
socialColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel( 100289, "单位"), social + "socialCom");
}
});
fundIds.stream().forEach(social -> {
if (categoryIdNameMap.containsKey(social)) {
fundColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel( 100289, "单位"), social + "fundCom");
}
});
otherIds.stream().forEach(social -> {
if (categoryIdNameMap.containsKey(social)) {
otherColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel( 100289, "单位"), social + "otherCom");
}
});
result.put(WelfareTypeEnum.SOCIAL_SECURITY.getValue(), socialColumns);
result.put(WelfareTypeEnum.ACCUMULATION_FUND.getValue(), fundColumns);
result.put(WelfareTypeEnum.OTHER.getValue(), otherColumns);
return result;
}
@Override
2022-04-16 16:43:33 +08:00
public List<WeaTableColumn> buildCommonColumns(List<InsuranceAccountDetailPO> pos) {
2022-04-12 19:29:19 +08:00
return null;
}
@Override
2022-04-16 16:43:33 +08:00
public List<WeaTableColumn> buildInspectColumns(List<InsuranceAccountInspectPO> pos) {
List<WeaTableColumn> list = new ArrayList<>();
SIArchivesBiz siArchivesBiz = new SIArchivesBiz();
List<Long> employeeIds = pos.stream().map(InsuranceAccountInspectPO::getEmployeeId).collect(Collectors.toList());
Map<Long, InsuranceArchivesAccountPO> insuranceArchivesAccountPOMap = siArchivesBiz.buildBatchAccount(employeeIds);
2022-04-16 16:43:33 +08:00
Map<String, String> categoryIdNameMap = MapperProxyFactory.getProxy(ICategoryMapper.class).listAll().stream().collect(Collectors.toMap(ICategoryPO -> String.valueOf(ICategoryPO.getId()), ICategoryPO::getInsuranceName));
Map<Integer, Map<String, String>> columns = buildInspectTableTitle(new ArrayList<>(insuranceArchivesAccountPOMap.values()), categoryIdNameMap);
WeaTableColumn weaTableNameColumn = new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 85429, "姓名"), "userName");
weaTableNameColumn.setFixed("left");
WeaTableColumn idColumn = new WeaTableColumn("150px", "id", "id");
idColumn.setIsPrimarykey(WeaBoolAttr.TRUE);
idColumn.setDisplay(WeaBoolAttr.FALSE);
list.add(idColumn);
list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 86185, "部门"), "department"));
list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(86186, "手机号"), "mobile"));
list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(86187, "员工状态"), "employeeStatus"));
list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 100544, "缴纳情况"), "supplementaryMonth"));
list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 91323, "社保方案名称"), "socialSchemeName"));
//组装社保基数
columns.get(WelfareTypeEnum.SOCIAL_SECURITY.getValue()).forEach((k, v) -> {
list.add(new WeaTableColumn("150px",k, v));
});
list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 91485, "公积金方案名称"), "fundSchemeName"));
//组装公积金基数
columns.get(WelfareTypeEnum.ACCUMULATION_FUND.getValue()).forEach((k, v) -> {
list.add(new WeaTableColumn("150px",k, v));
});
list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 91496, "其他福利方案名称"), "otherSchemeName"));
columns.get(WelfareTypeEnum.OTHER.getValue()).forEach((k, v) -> {
list.add(new WeaTableColumn("150px",k, v));
});
return list;
}
private Map<Integer, Map<String, String>> buildInspectTableTitle(List<InsuranceArchivesAccountPO> pos, Map<String, String> categoryIdNameMap
) {
Set<String> socailIds = new HashSet<>();
Set<String> fundIds = new HashSet<>();
Set<String> otherIds = new HashSet<>();
Map<Integer, Map<String, String>> result = new HashMap<>();
pos.stream().forEach(item -> {
InsuranceArchivesSocialSchemePO social = item.getSocial();
if (social != null && StringUtils.isNotBlank(social.getSocialPaymentBaseString())) {
Map<String, String> socialJson = JSON.parseObject(social.getSocialPaymentBaseString(), new HashMap<String, String>().getClass());
2022-07-21 17:28:47 +08:00
if(socialJson!=null){
socialJson.forEach((k, v) -> {
socailIds.add(k);
});
}
2022-04-16 16:43:33 +08:00
}
InsuranceArchivesFundSchemePO fund = item.getFund();
if (fund != null && StringUtils.isNotBlank(fund.getFundPaymentBaseString())) {
Map<String, String> fundJson = JSON.parseObject(fund.getFundPaymentBaseString(), new HashMap<String, String>().getClass());
2022-07-21 17:28:47 +08:00
if(fundJson!=null){
fundJson.forEach((k, v) -> {
fundIds.add(k);
});
}
2022-04-16 16:43:33 +08:00
}
InsuranceArchivesOtherSchemePO other = item.getOther();
if (other != null && StringUtils.isNotBlank(other.getOtherPaymentBaseString())) {
Map<String, String> otherJson = JSON.parseObject(other.getOtherPaymentBaseString(), new HashMap<String, String>().getClass());
2022-07-21 17:28:47 +08:00
if(otherJson!=null){
otherJson.forEach((k, v) -> {
otherIds.add(k);
});
}
2022-04-16 16:43:33 +08:00
}
});
Map<String, String> socialColumns = new HashMap<>();
Map<String, String> fundColumns = new HashMap<>();
Map<String, String> otherColumns = new HashMap<>();
socailIds.stream().forEach(social -> {
if (categoryIdNameMap.containsKey(social)) {
socialColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel( 100293, "申报基数"), social + "socialBase");
}
});
fundIds.stream().forEach(social -> {
if (categoryIdNameMap.containsKey(social)) {
fundColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel( 100293, "申报基数"), social + "fundBase");
}
});
otherIds.stream().forEach(social -> {
if (categoryIdNameMap.containsKey(social)) {
otherColumns.put(categoryIdNameMap.get(social) + SalaryI18nUtil.getI18nLabel( 100293, "申报基数"), social + "otherBase");
}
});
result.put(WelfareTypeEnum.SOCIAL_SECURITY.getValue(), socialColumns);
result.put(WelfareTypeEnum.ACCUMULATION_FUND.getValue(), fundColumns);
result.put(WelfareTypeEnum.OTHER.getValue(), otherColumns);
return result;
2022-04-12 19:29:19 +08:00
}
}