2022-11-23 14:49:44 +08:00
|
|
|
package com.engine.salary.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.alipay.oceanbase.jdbc.StringUtils;
|
|
|
|
|
import com.engine.common.util.ServiceUtil;
|
|
|
|
|
import com.engine.core.impl.Service;
|
|
|
|
|
import com.engine.salary.encrypt.siaccount.InsuranceAccountDetailPOEncrypt;
|
|
|
|
|
import com.engine.salary.entity.hrm.dto.HrmInfoDTO;
|
|
|
|
|
import com.engine.salary.entity.hrm.param.HrmQueryParam;
|
|
|
|
|
import com.engine.salary.entity.siaccount.param.CompensationParam;
|
|
|
|
|
import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO;
|
|
|
|
|
import com.engine.salary.entity.taxagent.dto.TaxAgentEmployeeDTO;
|
|
|
|
|
import com.engine.salary.mapper.datacollection.EmployMapper;
|
|
|
|
|
import com.engine.salary.mapper.siaccount.InsuranceAccountDetailMapper;
|
|
|
|
|
import com.engine.salary.service.SICategoryService;
|
|
|
|
|
import com.engine.salary.service.SICompensationService;
|
|
|
|
|
import com.engine.salary.util.SalaryAssert;
|
|
|
|
|
import com.engine.salary.util.SalaryEntityUtil;
|
|
|
|
|
import com.engine.salary.util.SalaryI18nUtil;
|
|
|
|
|
import com.engine.salary.util.db.MapperProxyFactory;
|
|
|
|
|
import com.engine.salary.util.page.PageInfo;
|
|
|
|
|
import com.engine.salary.util.page.SalaryPageUtil;
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
|
|
import weaver.hrm.User;
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @Author: sy
|
|
|
|
|
* @Description: 福利台账-调差实现类
|
|
|
|
|
* @Date: 2022/11/23
|
|
|
|
|
**/
|
|
|
|
|
public class SICompensationServiceImpl extends Service implements SICompensationService {
|
|
|
|
|
|
|
|
|
|
private InsuranceAccountDetailMapper getInsuranceAccountDetailMapper() {
|
|
|
|
|
return MapperProxyFactory.getProxy(InsuranceAccountDetailMapper.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private EmployMapper getEmployMapper() {
|
|
|
|
|
return MapperProxyFactory.getProxy(EmployMapper.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public SICategoryService getSICategoryService(User user) {
|
|
|
|
|
return ServiceUtil.getService(SICategoryServiceImpl.class, user);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 可调差人员
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public PageInfo<HrmInfoDTO> getEmployeeListToCompensation(HrmQueryParam param) {
|
|
|
|
|
// 当前登录人员
|
|
|
|
|
Long currentEmployeeId = (long) user.getUID();
|
|
|
|
|
|
|
|
|
|
//查询账单月份+个税扣缴义务人下的社保福利正常缴纳人员列表
|
|
|
|
|
List<InsuranceAccountDetailPO> normalDataList = getInsuranceAccountDetailMapper().queryNormalListByBillMonth(param.getBillMonth(), param.getPaymentOrganization());
|
|
|
|
|
List<Long> empIds = normalDataList.stream().map(InsuranceAccountDetailPO::getEmployeeId).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
List<HrmInfoDTO> resultData = new ArrayList<>();
|
|
|
|
|
if (empIds.size() > 0) {
|
|
|
|
|
List<List<Long>> partition = Lists.partition(empIds, 1000);
|
|
|
|
|
partition.forEach(p -> {
|
|
|
|
|
param.setIds(p);
|
|
|
|
|
resultData.addAll(getEmployMapper().listHrmInfoByIdAndName(param));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 分页
|
|
|
|
|
PageInfo<HrmInfoDTO> page = new PageInfo<>();
|
2022-11-23 15:39:42 +08:00
|
|
|
if (resultData.size() == 0) {
|
2022-11-23 14:49:44 +08:00
|
|
|
return page;
|
|
|
|
|
}
|
|
|
|
|
page.setTotal(resultData.size());
|
|
|
|
|
|
|
|
|
|
page.setList(SalaryPageUtil.subList(param.getPageNum(), param.getPageSize(), resultData));
|
|
|
|
|
page.setPageSize(param.getPageSize());
|
|
|
|
|
page.setPageNum(param.getPageNum());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return page;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 调差福利项
|
|
|
|
|
* @param id InsuranceAccountDetailPO.id
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<Map<String, String>> compensationCategoryType(Long id) {
|
|
|
|
|
SalaryAssert.notNull(id, SalaryI18nUtil.getI18nLabel(120999, "调差对象必选"));
|
|
|
|
|
InsuranceAccountDetailPO insuranceAccountDetailPO = getInsuranceAccountDetailMapper().getById(id);
|
|
|
|
|
if (insuranceAccountDetailPO == null) {
|
|
|
|
|
return Lists.newArrayList();
|
|
|
|
|
}
|
|
|
|
|
InsuranceAccountDetailPOEncrypt.decryptItem(insuranceAccountDetailPO);
|
|
|
|
|
List<Map<String, String>> result = new ArrayList<>();
|
|
|
|
|
String socialComJson = insuranceAccountDetailPO.getSocialComJson();
|
|
|
|
|
if (StringUtils.isNotBlank(socialComJson)) {
|
|
|
|
|
Map<String, String> categoryIdNameMap = getSICategoryService(user).categoryIdNameMap();
|
|
|
|
|
Map<String, String> socialJson = JSON.parseObject(socialComJson, new HashMap<String, String>().getClass());
|
|
|
|
|
for (Map.Entry<String, String> entry : socialJson.entrySet()) {
|
|
|
|
|
Map<String, String> temp = new HashMap<>();
|
|
|
|
|
String insuranceId = entry.getKey();
|
|
|
|
|
if (StringUtils.isNotBlank(categoryIdNameMap.get(insuranceId))) {
|
|
|
|
|
temp.put("id", insuranceId);
|
|
|
|
|
temp.put("content", categoryIdNameMap.get(insuranceId));
|
|
|
|
|
result.add(temp);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取当前调差福利类型-公司方支出总计
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public Map<Long, List<Map<String, String>>> compensationComTotal(Map<Long, List<CompensationParam>> param) {
|
|
|
|
|
Map<Long, List<Map<String, String>>> result = new HashMap<>();
|
|
|
|
|
param.forEach((paymentAgencyId, compensationList) -> {
|
|
|
|
|
List<Map<String, String>> paymentList = new ArrayList<>();
|
|
|
|
|
compensationList.forEach(compensation -> {
|
|
|
|
|
Map<String, String> temp = new HashMap<>();
|
|
|
|
|
temp.put("rowId", compensation.getRowId());
|
|
|
|
|
if (StringUtils.isBlank(compensation.getCategoryType()) || compensation.getTarget() == null) {
|
|
|
|
|
temp.put("error", SalaryI18nUtil.getI18nLabel(84026, "参数错误"));
|
|
|
|
|
temp.put("totalNum", "0");
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
InsuranceAccountDetailPO insuranceAccountDetailPO = getInsuranceAccountDetailMapper().getById(compensation.getTarget());
|
|
|
|
|
if (insuranceAccountDetailPO == null) {
|
|
|
|
|
temp.put("error", SalaryI18nUtil.getI18nLabel(121038, "当前月在该缴纳组织下没有核算记录"));
|
|
|
|
|
}
|
|
|
|
|
InsuranceAccountDetailPOEncrypt.decryptItem(insuranceAccountDetailPO);
|
|
|
|
|
BigDecimal total = new BigDecimal("0");
|
|
|
|
|
List<String> categoryTypeList = Arrays.asList(compensation.getCategoryType().split(","));
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(insuranceAccountDetailPO.getSocialComJson())) {
|
|
|
|
|
Map<String, String> socialJson = JSON.parseObject(insuranceAccountDetailPO.getSocialComJson(), new HashMap<String, String>().getClass());
|
|
|
|
|
for (Map.Entry<String, String> entry : socialJson.entrySet()) {
|
|
|
|
|
String insuranceId = entry.getKey();
|
|
|
|
|
String num = entry.getValue();
|
|
|
|
|
if (categoryTypeList.contains(insuranceId)) {
|
|
|
|
|
total = total.add(new BigDecimal(num));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
temp.put("totalNum", total.toPlainString());
|
|
|
|
|
}
|
|
|
|
|
paymentList.add(temp);
|
|
|
|
|
});
|
|
|
|
|
result.put(paymentAgencyId, paymentList);
|
|
|
|
|
});
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|