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;
|
2022-11-30 17:57:25 +08:00
|
|
|
|
import com.cloudstore.eccom.pc.table.WeaTable;
|
2022-11-29 15:33:57 +08:00
|
|
|
|
import com.cloudstore.eccom.pc.table.WeaTableColumn;
|
2022-11-23 14:49:44 +08:00
|
|
|
|
import com.engine.common.util.ServiceUtil;
|
|
|
|
|
|
import com.engine.core.impl.Service;
|
2022-11-24 09:17:08 +08:00
|
|
|
|
import com.engine.salary.constant.SalaryDefaultTenantConstant;
|
2022-11-23 14:49:44 +08:00
|
|
|
|
import com.engine.salary.encrypt.siaccount.InsuranceAccountDetailPOEncrypt;
|
2022-11-29 15:33:57 +08:00
|
|
|
|
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
|
2022-11-23 14:49:44 +08:00
|
|
|
|
import com.engine.salary.entity.hrm.dto.HrmInfoDTO;
|
|
|
|
|
|
import com.engine.salary.entity.hrm.param.HrmQueryParam;
|
2022-11-24 09:17:08 +08:00
|
|
|
|
import com.engine.salary.entity.siaccount.dto.InsuranceCompensationDTO;
|
2022-11-23 14:49:44 +08:00
|
|
|
|
import com.engine.salary.entity.siaccount.param.CompensationParam;
|
|
|
|
|
|
import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO;
|
2022-11-28 13:42:53 +08:00
|
|
|
|
import com.engine.salary.entity.siaccount.po.InsuranceCompensationConfigPO;
|
2022-11-24 09:17:08 +08:00
|
|
|
|
import com.engine.salary.entity.siaccount.po.InsuranceCompensationPO;
|
2022-11-29 15:33:57 +08:00
|
|
|
|
import com.engine.salary.entity.sicategory.po.ICategoryPO;
|
2022-11-28 14:57:29 +08:00
|
|
|
|
import com.engine.salary.enums.siaccount.PaymentStatusEnum;
|
2022-11-24 09:17:08 +08:00
|
|
|
|
import com.engine.salary.enums.sicategory.DeleteTypeEnum;
|
2022-11-29 15:33:57 +08:00
|
|
|
|
import com.engine.salary.exception.SalaryRunTimeException;
|
2022-11-23 14:49:44 +08:00
|
|
|
|
import com.engine.salary.mapper.datacollection.EmployMapper;
|
|
|
|
|
|
import com.engine.salary.mapper.siaccount.InsuranceAccountDetailMapper;
|
2022-11-28 13:42:53 +08:00
|
|
|
|
import com.engine.salary.mapper.siaccount.InsuranceCompensationConfigMapper;
|
2022-11-28 11:35:05 +08:00
|
|
|
|
import com.engine.salary.mapper.siaccount.InsuranceCompensationMapper;
|
2022-11-29 15:33:57 +08:00
|
|
|
|
import com.engine.salary.mapper.sicategory.ICategoryMapper;
|
|
|
|
|
|
import com.engine.salary.service.ColumnBuildService;
|
2022-11-24 13:29:40 +08:00
|
|
|
|
import com.engine.salary.service.SIAccountService;
|
2022-11-23 14:49:44 +08:00
|
|
|
|
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;
|
2022-11-30 17:57:25 +08:00
|
|
|
|
import com.engine.salary.util.page.Column;
|
2022-11-23 14:49:44 +08:00
|
|
|
|
import com.engine.salary.util.page.PageInfo;
|
|
|
|
|
|
import com.engine.salary.util.page.SalaryPageUtil;
|
|
|
|
|
|
import com.google.common.collect.Lists;
|
2022-11-24 09:17:08 +08:00
|
|
|
|
import dm.jdbc.util.IdGenerator;
|
2022-11-29 15:33:57 +08:00
|
|
|
|
import org.springframework.beans.BeanUtils;
|
2022-11-23 14:49:44 +08:00
|
|
|
|
import weaver.hrm.User;
|
|
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
|
import java.util.*;
|
2022-11-29 15:33:57 +08:00
|
|
|
|
import java.util.function.Function;
|
2022-11-23 14:49:44 +08:00
|
|
|
|
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);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-11-24 13:29:40 +08:00
|
|
|
|
private SIAccountService getSIAccountService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(SIAccountServiceImpl.class, user);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-11-28 11:35:05 +08:00
|
|
|
|
private InsuranceCompensationMapper getInsuranceCompensationMapper() {
|
|
|
|
|
|
return MapperProxyFactory.getProxy(InsuranceCompensationMapper.class);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-11-28 13:42:53 +08:00
|
|
|
|
private InsuranceCompensationConfigMapper getInsuranceCompensationConfigMapper() {
|
|
|
|
|
|
return MapperProxyFactory.getProxy(InsuranceCompensationConfigMapper.class);
|
|
|
|
|
|
}
|
2022-11-29 15:33:57 +08:00
|
|
|
|
|
|
|
|
|
|
public ColumnBuildService getColumnBuildService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(ColumnBuildServiceImpl.class, user);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-11-23 14:49:44 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 可调差人员
|
|
|
|
|
|
*/
|
|
|
|
|
|
@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
|
2022-11-29 17:36:18 +08:00
|
|
|
|
public List<Map<String, String>> compensationComTotal(List<CompensationParam> paramList) {
|
|
|
|
|
|
List<Map<String, String>> resultList = new ArrayList<>();
|
|
|
|
|
|
paramList.forEach(compensation -> {
|
|
|
|
|
|
Map<String, String> temp = new HashMap<>();
|
|
|
|
|
|
temp.put("employeeId", compensation.getEmployeeId());
|
|
|
|
|
|
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, "当前月在该缴纳组织下没有核算记录"));
|
2022-11-30 14:07:28 +08:00
|
|
|
|
temp.put("totalNum", "0");
|
|
|
|
|
|
} else {
|
|
|
|
|
|
InsuranceAccountDetailPOEncrypt.decryptItem(insuranceAccountDetailPO);
|
|
|
|
|
|
//判断是否已有调差数据(个税扣缴义务人+账单月份+人员id)
|
|
|
|
|
|
InsuranceCompensationPO nowCompensation = getInsuranceCompensationMapper().getOneByBillMonthPayOrgEmpId(InsuranceCompensationPO.builder()
|
|
|
|
|
|
.billMonth(insuranceAccountDetailPO.getBillMonth())
|
|
|
|
|
|
.paymentOrganization(insuranceAccountDetailPO.getPaymentOrganization())
|
|
|
|
|
|
.employeeId(insuranceAccountDetailPO.getEmployeeId())
|
|
|
|
|
|
.build());
|
|
|
|
|
|
if (nowCompensation != null) {
|
|
|
|
|
|
temp.put("error", SalaryI18nUtil.getI18nLabel(121039, "当前月在该缴纳组织下已存在调差数据"));
|
|
|
|
|
|
}
|
2022-11-29 17:36:18 +08:00
|
|
|
|
|
2022-11-30 14:07:28 +08:00
|
|
|
|
//处理调差数据
|
|
|
|
|
|
BigDecimal total = new BigDecimal("0");
|
|
|
|
|
|
List<String> categoryTypeList = Arrays.asList(compensation.getCategoryType().split(","));
|
|
|
|
|
|
|
|
|
|
|
|
if (nowCompensation == null && 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));
|
|
|
|
|
|
}
|
2022-11-23 14:49:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-11-30 14:07:28 +08:00
|
|
|
|
|
|
|
|
|
|
temp.put("totalNum", total.toPlainString());
|
2022-11-23 14:49:44 +08:00
|
|
|
|
}
|
2022-11-29 17:36:18 +08:00
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
resultList.add(temp);
|
2022-11-23 14:49:44 +08:00
|
|
|
|
});
|
2022-11-29 17:36:18 +08:00
|
|
|
|
// paramList.forEach((paymentOrganization, compensationList) -> {
|
|
|
|
|
|
// List<Map<String, String>> paymentList = new ArrayList<>();
|
|
|
|
|
|
// compensationList.forEach(compensation -> {
|
|
|
|
|
|
// Map<String, String> temp = new HashMap<>();
|
|
|
|
|
|
// temp.put("employeeId", compensation.getEmployeeId());
|
|
|
|
|
|
// 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(paymentOrganization, paymentList);
|
|
|
|
|
|
// });
|
|
|
|
|
|
return resultList;
|
2022-11-23 14:49:44 +08:00
|
|
|
|
}
|
2022-11-24 09:17:08 +08:00
|
|
|
|
|
|
|
|
|
|
@Override
|
2022-11-30 15:05:24 +08:00
|
|
|
|
public Map<String, Object> compensationAccount(List<InsuranceCompensationDTO> list) {
|
2022-11-24 09:17:08 +08:00
|
|
|
|
|
|
|
|
|
|
long currentEmployeeId = user.getUID();
|
2022-11-30 15:05:24 +08:00
|
|
|
|
List<DataCollectionEmployee> allEmployees = getEmployMapper().listAll();
|
|
|
|
|
|
Map<Long, String> usernameMap = SalaryEntityUtil.convert2Map(allEmployees, DataCollectionEmployee::getEmployeeId, DataCollectionEmployee::getUsername);
|
2022-11-24 09:17:08 +08:00
|
|
|
|
|
2022-11-30 15:05:24 +08:00
|
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
|
|
|
List<String> errorList = new ArrayList<>();
|
2022-11-24 09:17:08 +08:00
|
|
|
|
for (InsuranceCompensationDTO param : list) {
|
|
|
|
|
|
if (StringUtils.isBlank(param.getAdjustmentTotal()) || "0".equals(param.getAdjustmentTotal())) {
|
2022-11-30 15:05:24 +08:00
|
|
|
|
errorList.add(usernameMap.get(param.getEmployeeId()) + "-调差失败:调差数额不正确!");
|
2022-11-24 09:17:08 +08:00
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
InsuranceAccountDetailPO insuranceAccountDetailPO = getInsuranceAccountDetailMapper().getById(param.getTarget());
|
2022-11-30 15:05:24 +08:00
|
|
|
|
if (insuranceAccountDetailPO == null) {
|
|
|
|
|
|
errorList.add(usernameMap.get(param.getEmployeeId()) + "-调差失败:调差对象不存在!");
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-11-24 09:17:08 +08:00
|
|
|
|
InsuranceAccountDetailPOEncrypt.decryptItem(insuranceAccountDetailPO);
|
|
|
|
|
|
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 (Objects.equals(String.valueOf(param.getAdjustTo()), insuranceId)) {
|
|
|
|
|
|
BigDecimal adjustmentTo = new BigDecimal(param.getAdjustmentTotal());
|
|
|
|
|
|
// 调差单位缴纳明细
|
|
|
|
|
|
BigDecimal insuranceNum = new BigDecimal(num);
|
|
|
|
|
|
insuranceNum = insuranceNum.add(adjustmentTo);
|
|
|
|
|
|
socialJson.replace(insuranceId, insuranceNum.toPlainString());
|
|
|
|
|
|
insuranceAccountDetailPO.setSocialComJson(JSON.toJSONString(socialJson));
|
|
|
|
|
|
// 调差单位合计
|
|
|
|
|
|
BigDecimal comSum = new BigDecimal(insuranceAccountDetailPO.getComSum());
|
|
|
|
|
|
comSum = comSum.add(adjustmentTo);
|
|
|
|
|
|
insuranceAccountDetailPO.setComSum(comSum.toPlainString());
|
|
|
|
|
|
// 调差社保单位合计
|
|
|
|
|
|
BigDecimal socialComSum = new BigDecimal(insuranceAccountDetailPO.getSocialComSum());
|
|
|
|
|
|
socialComSum = socialComSum.add(adjustmentTo);
|
|
|
|
|
|
insuranceAccountDetailPO.setSocialComSum(socialComSum.toPlainString());
|
|
|
|
|
|
// 调差社保合计
|
|
|
|
|
|
BigDecimal socialSum = new BigDecimal(insuranceAccountDetailPO.getSocialSum());
|
|
|
|
|
|
socialSum = socialSum.add(adjustmentTo);
|
|
|
|
|
|
insuranceAccountDetailPO.setSocialSum(socialSum.toPlainString());
|
|
|
|
|
|
// 调差合计
|
|
|
|
|
|
BigDecimal totalSum = new BigDecimal(insuranceAccountDetailPO.getTotal());
|
|
|
|
|
|
totalSum = totalSum.add(adjustmentTo);
|
|
|
|
|
|
insuranceAccountDetailPO.setTotal(totalSum.toPlainString());
|
|
|
|
|
|
//更新社保调差后的明细
|
2022-11-30 14:07:28 +08:00
|
|
|
|
InsuranceAccountDetailPOEncrypt.encryptItem(insuranceAccountDetailPO);
|
2022-11-24 09:17:08 +08:00
|
|
|
|
getInsuranceAccountDetailMapper().updateById(insuranceAccountDetailPO);
|
|
|
|
|
|
//新建调差记录
|
|
|
|
|
|
InsuranceCompensationPO insuranceCompensationPO = new InsuranceCompensationPO();
|
|
|
|
|
|
insuranceCompensationPO.setId(IdGenerator.generate());
|
|
|
|
|
|
insuranceCompensationPO.setAdjustmentTotal(param.getAdjustmentTotal());
|
|
|
|
|
|
insuranceCompensationPO.setAdjustTo(param.getAdjustTo());
|
|
|
|
|
|
insuranceCompensationPO.setBillMonth(param.getBillMonth());
|
|
|
|
|
|
insuranceCompensationPO.setCompanyTotal(param.getCompanyTotal());
|
|
|
|
|
|
insuranceCompensationPO.setCreator(currentEmployeeId);
|
|
|
|
|
|
insuranceCompensationPO.setCategoryType(param.getCategoryType());
|
2022-11-28 11:35:05 +08:00
|
|
|
|
insuranceCompensationPO.setCreateTime(new Date());
|
2022-11-24 09:17:08 +08:00
|
|
|
|
insuranceCompensationPO.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue());
|
|
|
|
|
|
insuranceCompensationPO.setCountryTotal(param.getCountryTotal());
|
|
|
|
|
|
insuranceCompensationPO.setEmployeeId(insuranceAccountDetailPO.getEmployeeId());
|
2022-11-28 11:35:05 +08:00
|
|
|
|
|
2022-11-24 09:17:08 +08:00
|
|
|
|
insuranceCompensationPO.setPaymentOrganization(insuranceAccountDetailPO.getPaymentOrganization());
|
|
|
|
|
|
insuranceCompensationPO.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY);
|
2022-11-30 17:57:25 +08:00
|
|
|
|
insuranceCompensationPO.setWelfareType(param.getWelfareType());
|
2022-11-28 11:35:05 +08:00
|
|
|
|
insuranceCompensationPO.setUpdateTime(new Date());
|
|
|
|
|
|
getInsuranceCompensationMapper().insert(insuranceCompensationPO);
|
2022-11-24 13:29:40 +08:00
|
|
|
|
|
2022-11-30 15:05:24 +08:00
|
|
|
|
// result.put(param.getOriginId(), insuranceCompensationPO.getId().toString());
|
2022-11-24 09:17:08 +08:00
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-11-24 13:29:40 +08:00
|
|
|
|
//刷新bill_detail统计数据
|
|
|
|
|
|
getSIAccountService(user).refreshBillBatch(list.get(0).getPaymentOrganization(), list.get(0).getBillMonth());
|
2022-11-30 15:05:24 +08:00
|
|
|
|
if (errorList.size() == 0) {
|
|
|
|
|
|
result.put("data", "全部调差成功!");
|
|
|
|
|
|
} else {
|
|
|
|
|
|
result.put("data", "存在调差失败项!");
|
|
|
|
|
|
}
|
|
|
|
|
|
result.put("errorMessage", errorList);
|
2022-11-24 09:17:08 +08:00
|
|
|
|
return result;
|
|
|
|
|
|
}
|
2022-11-28 13:42:53 +08:00
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public String compensationConfigSave(List<InsuranceCompensationDTO> param) {
|
|
|
|
|
|
long currentEmployeeId = user.getUID();
|
|
|
|
|
|
|
|
|
|
|
|
SalaryAssert.notEmpty(param, SalaryI18nUtil.getI18nLabel(143746, "默认调差配置数据为空"));
|
|
|
|
|
|
// 清除历史默认配置
|
|
|
|
|
|
getInsuranceCompensationConfigMapper().deleteByPayOrg(param.get(0).getPaymentOrganization());
|
|
|
|
|
|
// 保存历史默认配置
|
|
|
|
|
|
List<InsuranceCompensationConfigPO> configList = param.stream().map(config -> {
|
|
|
|
|
|
InsuranceAccountDetailPO insuranceAccountDetailPO = getInsuranceAccountDetailMapper().getById(config.getTarget());
|
|
|
|
|
|
SalaryAssert.notNull(insuranceAccountDetailPO, SalaryI18nUtil.getI18nLabel(138849, "调差对象不存在"));
|
|
|
|
|
|
return InsuranceCompensationConfigPO.builder()
|
|
|
|
|
|
.id(IdGenerator.generate())
|
|
|
|
|
|
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
|
|
|
|
|
|
.employeeId(insuranceAccountDetailPO.getEmployeeId())
|
|
|
|
|
|
.adjustTo(config.getAdjustTo())
|
2022-11-28 16:25:52 +08:00
|
|
|
|
.createTime(new Date())
|
|
|
|
|
|
.updateTime(new Date())
|
2022-11-28 13:42:53 +08:00
|
|
|
|
.categoryType(config.getCategoryType())
|
|
|
|
|
|
.paymentOrganization(config.getPaymentOrganization())
|
2022-11-30 17:57:25 +08:00
|
|
|
|
.welfareType(config.getWelfareType())
|
2022-11-28 13:42:53 +08:00
|
|
|
|
.deleteType(DeleteTypeEnum.NOT_DELETED.getValue())
|
|
|
|
|
|
.creator(currentEmployeeId).build();
|
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
|
configList.forEach(config -> getInsuranceCompensationConfigMapper().insert(config));
|
|
|
|
|
|
|
|
|
|
|
|
return "配置成功";
|
|
|
|
|
|
}
|
2022-11-28 14:57:29 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 社保调差撤回
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public String compensationRevert(InsuranceCompensationDTO param) {
|
|
|
|
|
|
InsuranceCompensationPO insuranceCompensationPO = getInsuranceCompensationMapper().getById(param.getId());
|
|
|
|
|
|
SalaryAssert.notNull(insuranceCompensationPO, SalaryI18nUtil.getI18nLabel(121112, "当前补差记录不存在"));
|
|
|
|
|
|
InsuranceAccountDetailPO insuranceAccountDetailPO = getInsuranceAccountDetailMapper().getOneByBpep(InsuranceAccountDetailPO.builder()
|
|
|
|
|
|
.billMonth(insuranceCompensationPO.getBillMonth())
|
|
|
|
|
|
.paymentStatus(PaymentStatusEnum.COMMON.getValue())
|
|
|
|
|
|
.employeeId(insuranceCompensationPO.getEmployeeId())
|
|
|
|
|
|
.paymentOrganization(insuranceCompensationPO.getPaymentOrganization())
|
|
|
|
|
|
.build());
|
|
|
|
|
|
|
|
|
|
|
|
SalaryAssert.notNull(insuranceAccountDetailPO, SalaryI18nUtil.getI18nLabel(121108, "补差对象不存在"));
|
|
|
|
|
|
InsuranceAccountDetailPOEncrypt.decryptItem(insuranceAccountDetailPO);
|
|
|
|
|
|
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 (Objects.equals(String.valueOf(insuranceCompensationPO.getAdjustTo()), insuranceId)) {
|
|
|
|
|
|
BigDecimal adjustmentTo = new BigDecimal(insuranceCompensationPO.getAdjustmentTotal());
|
2022-11-29 15:33:57 +08:00
|
|
|
|
//回退调差单位缴纳明细
|
2022-11-28 14:57:29 +08:00
|
|
|
|
BigDecimal insuranceNum = new BigDecimal(num);
|
|
|
|
|
|
insuranceNum = insuranceNum.subtract(adjustmentTo);
|
|
|
|
|
|
socialJson.replace(insuranceId, insuranceNum.toPlainString());
|
|
|
|
|
|
insuranceAccountDetailPO.setSocialComJson(JSON.toJSONString(socialJson));
|
2022-11-29 15:33:57 +08:00
|
|
|
|
//回退调差单位合计
|
2022-11-28 14:57:29 +08:00
|
|
|
|
BigDecimal comSum = new BigDecimal(insuranceAccountDetailPO.getComSum());
|
|
|
|
|
|
comSum = comSum.subtract(adjustmentTo);
|
|
|
|
|
|
insuranceAccountDetailPO.setComSum(comSum.toPlainString());
|
2022-11-29 15:33:57 +08:00
|
|
|
|
//回退调差社保单位合计
|
2022-11-28 14:57:29 +08:00
|
|
|
|
BigDecimal socialComSum = new BigDecimal(insuranceAccountDetailPO.getSocialComSum());
|
|
|
|
|
|
socialComSum = socialComSum.subtract(adjustmentTo);
|
|
|
|
|
|
insuranceAccountDetailPO.setSocialComSum(socialComSum.toPlainString());
|
2022-11-29 15:33:57 +08:00
|
|
|
|
//回退调差社保合计
|
2022-11-28 14:57:29 +08:00
|
|
|
|
BigDecimal socialSum = new BigDecimal(insuranceAccountDetailPO.getSocialSum());
|
|
|
|
|
|
socialSum = socialSum.subtract(adjustmentTo);
|
|
|
|
|
|
insuranceAccountDetailPO.setSocialSum(socialSum.toPlainString());
|
2022-11-29 15:33:57 +08:00
|
|
|
|
//回退调差合计
|
2022-11-28 14:57:29 +08:00
|
|
|
|
BigDecimal totalSum = new BigDecimal(insuranceAccountDetailPO.getTotal());
|
|
|
|
|
|
totalSum = totalSum.subtract(adjustmentTo);
|
|
|
|
|
|
insuranceAccountDetailPO.setTotal(totalSum.toPlainString());
|
2022-11-29 15:33:57 +08:00
|
|
|
|
//更新社保调差后的明细
|
2022-12-01 11:50:37 +08:00
|
|
|
|
InsuranceAccountDetailPOEncrypt.encryptItem(insuranceAccountDetailPO);
|
2022-11-28 14:57:29 +08:00
|
|
|
|
getInsuranceAccountDetailMapper().updateById(insuranceAccountDetailPO);
|
2022-11-29 15:33:57 +08:00
|
|
|
|
//删除调差记录
|
2022-11-28 14:57:29 +08:00
|
|
|
|
getInsuranceCompensationMapper().deleteById(param.getId());
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
//刷新bill_detail统计数据
|
|
|
|
|
|
getSIAccountService(user).refreshBillBatch(param.getPaymentOrganization(), param.getBillMonth());
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
return "撤回成功";
|
|
|
|
|
|
}
|
2022-11-29 15:33:57 +08:00
|
|
|
|
|
|
|
|
|
|
@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();
|
2022-11-30 17:57:25 +08:00
|
|
|
|
WeaTable table = new WeaTable();
|
|
|
|
|
|
table.setPageUID(UUID.randomUUID().toString());
|
|
|
|
|
|
table.setColumns(weaTableColumn);
|
|
|
|
|
|
List<Column> columns = weaTableColumn.stream().map(v -> new Column(v.getText(), v.getColumn(), v.getColumn())).collect(Collectors.toList());
|
2022-11-29 15:33:57 +08:00
|
|
|
|
|
|
|
|
|
|
//处理调差数据
|
|
|
|
|
|
List<InsuranceCompensationDTO> compensationDTOList = dealCompensationData(billMonth, paymentOrganization);
|
|
|
|
|
|
|
2022-11-30 17:57:25 +08:00
|
|
|
|
datas.put("columns", columns);
|
2022-11-29 15:33:57 +08:00
|
|
|
|
datas.put("data", compensationDTOList);
|
|
|
|
|
|
|
|
|
|
|
|
return datas;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private List<InsuranceCompensationDTO> dealCompensationData(String billMonth, Long paymentOrganization) {
|
|
|
|
|
|
|
|
|
|
|
|
//获取调差历史记录数据
|
|
|
|
|
|
List<InsuranceCompensationPO> compensationPOList = getInsuranceCompensationMapper().queryByBillMonthAndPayOrg(billMonth, paymentOrganization);
|
|
|
|
|
|
//获取调差配置数据
|
2022-11-30 17:57:25 +08:00
|
|
|
|
List<InsuranceCompensationConfigPO> compensationConfigPOList = getInsuranceCompensationConfigMapper().queryByPayOrg(paymentOrganization);
|
2022-11-29 15:33:57 +08:00
|
|
|
|
|
|
|
|
|
|
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(","));
|
2022-11-30 17:57:25 +08:00
|
|
|
|
|
2022-11-29 15:33:57 +08:00
|
|
|
|
for (String categoryType : categoryTypeList) {
|
2022-11-30 17:57:25 +08:00
|
|
|
|
Map<String,String> categoryTypeMap = new HashMap<>();
|
2022-11-29 15:33:57 +08:00
|
|
|
|
categoryTypeMap.put("id", categoryType);
|
|
|
|
|
|
categoryTypeMap.put("content", categoryNameMap.get(Long.valueOf(categoryType)));
|
|
|
|
|
|
categoryTypeOptions.add(categoryTypeMap);
|
|
|
|
|
|
}
|
|
|
|
|
|
dto.setCategoryTypeOptions(categoryTypeOptions);
|
2022-11-30 17:57:25 +08:00
|
|
|
|
|
|
|
|
|
|
compensationDTOList.add(dto);
|
2022-11-29 15:33:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
//不存在调差历史记录时,输出调差配置数据
|
|
|
|
|
|
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(","));
|
2022-11-30 17:57:25 +08:00
|
|
|
|
|
2022-11-29 15:33:57 +08:00
|
|
|
|
for (String categoryType : categoryTypeList) {
|
2022-11-30 17:57:25 +08:00
|
|
|
|
Map<String,String> categoryTypeMap = new HashMap<>();
|
2022-11-29 15:33:57 +08:00
|
|
|
|
categoryTypeMap.put("id", categoryType);
|
|
|
|
|
|
categoryTypeMap.put("content", categoryNameMap.get(Long.valueOf(categoryType)));
|
|
|
|
|
|
categoryTypeOptions.add(categoryTypeMap);
|
|
|
|
|
|
}
|
|
|
|
|
|
dto.setCategoryTypeOptions(categoryTypeOptions);
|
2022-11-30 17:57:25 +08:00
|
|
|
|
|
|
|
|
|
|
compensationDTOList.add(dto);
|
2022-11-29 15:33:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return compensationDTOList;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-11-23 14:49:44 +08:00
|
|
|
|
}
|