Merge branch 'master' into feature/V3-backItem-1215

This commit is contained in:
Harryxzy 2022-11-28 09:26:59 +08:00
commit 85fef5c5f8
63 changed files with 3317 additions and 505 deletions

View File

@ -0,0 +1,14 @@
package com.api.salary.web;
import com.engine.salary.process.siArchives.SIArchiveActionAPI;
import javax.ws.rs.Path;
/**
* @Author: sy
* @Description:
* @Date: 2022/11/11
**/
@Path("/bs/hrmsalary/siArchiveAction")
public class SIArchiveActionAPIController extends SIArchiveActionAPI {
}

View File

@ -140,7 +140,7 @@ public class SIAccountBiz extends Service {
return pageInfo;
}
public void save(boolean flag, AccountParam param, Long employeeId, String currentUserName) {
public String save(boolean flag, AccountParam param, Long employeeId, String currentUserName) {
if (flag) {
InsuranceAccountBatchPO insuranceAccountBatchPO = getInsuranceAccountBatchMapper().getByBillMonth(param.getBillMonth(), param.getPaymentOrganization());
insuranceAccountBatchPO = SiAccountEncrypt.decryptInsuranceAccountBatch(insuranceAccountBatchPO);
@ -184,7 +184,7 @@ public class SIAccountBiz extends Service {
}
throw new SalaryRunTimeException(e.getMessage());
}
return employeeId.toString();
}
public void account(AccountParam param, Long employeeId, String tenantKey, String currentUserName) {
@ -230,6 +230,7 @@ public class SIAccountBiz extends Service {
public void doAccounting(AccountParam param, Long employeeId, String tenantKey, String currentUserName) {
log.info("核算时间:{}, 核算月份:{}, 个税扣缴义务人:{}, 是否首次核算:{}", new Date(), param.getBillMonth(), param.getPaymentOrganization(), param.isFlag());
try {
List<Long> ids;
List<Long> validIds = new ArrayList<>();
@ -405,13 +406,20 @@ public class SIAccountBiz extends Service {
List<InsuranceAccountDetailTempPO> list = MapperProxyFactory.getProxy(SIAccountDetailTempMapper.class).getListByEmployeeIdsAndBillMonth(ids, billMonth, param.getPaymentOrganization());
InsuranceAccountDetailTempPOEncrypt.decryptInsuranceAccountDetailTempPOList(list);
Integer paymentStatus = 0;
getInsuranceAccountDetailMapper().batchDelAccountDetails(ids, billMonth, param.getPaymentOrganization(), paymentStatus);
log.info("核算明细临时表 hrsa_bill_detail_temp待处理数量{}", list.size());
List<List<Long>> partitionIds = Lists.partition((List<Long>) ids, 100);
log.info("bill_detail入库前删除数据数量{}", ids.size());
for (List<Long> part : partitionIds) {
getInsuranceAccountDetailMapper().batchDelAccountDetails(part, billMonth, param.getPaymentOrganization(), paymentStatus);
}
List<InsuranceAccountDetailPO> collect = list.stream().map(item -> {
InsuranceAccountDetailPO insuranceAccountDetailPO = new InsuranceAccountDetailPO();
BeanUtils.copyProperties(item, insuranceAccountDetailPO);
return insuranceAccountDetailPO;
}).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(collect)) {
log.info("bill_detail入库数据数量{}", collect.size());
batchSaveAccountInspectDetail(collect, billMonth, tenantKey);
InsuranceAccountDetailPOEncrypt.encryptInsuranceAccountDetailPOList(collect);
List<List<InsuranceAccountDetailPO>> lists = splitDetailList(collect, 20);

View File

@ -1069,36 +1069,47 @@ public class SIArchivesBiz {
Set<String> socialSet = new HashSet<>();
Set<String> fundSet = new HashSet<>();
Set<String> otherSet = new HashSet<>();
insuranceArchivesEmployeePOS.forEach(item -> {
List<InsuranceArchivesSocialSchemePO> socialList = socialSchemeMapper.getSocialByEmployeeId(Collections.singletonList(item.getEmployeeId()));
InsuranceArchivesSocialSchemePOEncrypt.decryptList(socialList);
InsuranceArchivesSocialSchemePO socialItem = socialList.size() != 0 ? socialList.get(0) : null;
// InsuranceArchivesSocialSchemePO socialItem = socialList.size() != 0 ? socialList.get(0) : null;
List<InsuranceArchivesFundSchemePO> fundList = fundSchemeMapper.getFundByEmployeeId(Collections.singletonList(item.getEmployeeId()));
InsuranceArchivesFundSchemePOEncrypt.decryptList(fundList);
InsuranceArchivesFundSchemePO fundItem = fundList.size() != 0 ? fundList.get(0) : null;
// InsuranceArchivesFundSchemePO fundItem = fundList.size() != 0 ? fundList.get(0) : null;
List<InsuranceArchivesOtherSchemePO> otherList = otherSchemeMapper.getOtherByEmployeeId(Collections.singletonList(item.getEmployeeId()));
InsuranceArchivesOtherSchemePOEncrypt.decryptList(otherList);
InsuranceArchivesOtherSchemePO otherItem = otherList.size() != 0 ? otherList.get(0) : null;
if (socialItem != null) {
Map<String, Object> socialJson = JSON.parseObject(socialItem.getSocialPaymentBaseString(), new TypeReference<Map<String, Object>>() {
});
if (socialJson != null) {
socialJson.forEach((k, v) -> socialSet.add(k));
// InsuranceArchivesOtherSchemePO otherItem = otherList.size() != 0 ? otherList.get(0) : null;
if (socialList.size() > 0) {
for (InsuranceArchivesSocialSchemePO socialSchemePO : socialList) {
Map<String, Object> socialJson = JSON.parseObject(socialSchemePO.getSocialPaymentBaseString(), new TypeReference<Map<String, Object>>() {
});
if (socialJson != null) {
socialJson.forEach((k, v) -> socialSet.add(k));
}
}
}
if (fundItem != null) {
Map<String, Object> fundJson = JSON.parseObject(fundItem.getFundPaymentBaseString(), new TypeReference<Map<String, Object>>() {
});
if (fundJson != null) {
fundJson.forEach((k, v) -> fundSet.add(k));
if (fundList.size() > 0) {
for (InsuranceArchivesFundSchemePO fundSchemePO : fundList) {
Map<String, Object> fundJson = JSON.parseObject(fundSchemePO.getFundPaymentBaseString(), new TypeReference<Map<String, Object>>() {
});
if (fundJson != null) {
fundJson.forEach((k, v) -> fundSet.add(k));
}
}
}
if (otherItem != null) {
Map<String, Object> otherJson = JSON.parseObject(otherItem.getOtherPaymentBaseString(), new TypeReference<Map<String, Object>>() {
});
if (otherJson != null) {
otherJson.forEach((k, v) -> otherSet.add(k));
if (otherList.size() > 0) {
for (InsuranceArchivesOtherSchemePO otherSchemePO : otherList) {
Map<String, Object> otherJson = JSON.parseObject(otherSchemePO.getOtherPaymentBaseString(), new TypeReference<Map<String, Object>>() {
});
if (otherJson != null) {
otherJson.forEach((k, v) -> otherSet.add(k));
}
}
}
});
Map<String, String> socialMap = new HashMap<>();

View File

@ -9,15 +9,55 @@ package com.engine.salary.cache;
*/
public class SalaryCacheKey {
/**
* 人员范围同步
*/
public final static String TAX_AGENT_MANAGE_RANGE_SYNC = "TAX_AGENT_MANAGE_RANGE_SYNC";
/**
* 核算进度
*/
public final static String ACCT_PROGRESS = "ACCT_PROGRESS_";
/**
* 薪资核算的账套配置
*/
public final static String ACCT_SOB_CONFIG = "ACCT_SOB_CONFIG";
/**
* 考勤进度
*/
public final static String ATTEND_PROGRESS = "ATTEND_PROGRESS_";
public final static String ATTEND_PROGRESS = "ATTEND_PROGRESS";
/**
* 工资单发放进度
*/
public final static String SALARY_GRANT_PROGRESS = "SALARY_GRANT_PROGRESS";
/**
* 工资单撤回进度
*/
public final static String SALARY_WITHDRAW_PROGRESS = "SALARY_WITHDRAW_PROGRESS";
/**
* ecology系统的token
*/
public final static String ECOLOGY_TOKEN = "ECOLOGY_TOKEN";
/**
* 个税申报表
*/
public final static String TAX_DECLARATION = "TAX_DECLARATION";
/**
* 人员报送
*/
public final static String EMPLOYEE_DECLARE = "EMPLOYEE_DECLARE";
/**
* 自定义业务数据
*/
public final static String CUSTOM_DATA = "CUSTOM_DATA";
}

View File

@ -107,5 +107,29 @@ public class InsuranceAccountDetailPOEncrypt {
return item;
}
public static InsuranceAccountDetailPO encryptItem(InsuranceAccountDetailPO item) {
if(item == null) {
return item;
}
item.setSocialPaymentBaseString(AESEncryptUtil.encrypt(item.getSocialPaymentBaseString()));
item.setFundPaymentBaseString(AESEncryptUtil.encrypt(item.getFundPaymentBaseString()));
item.setOtherPaymentBaseString(AESEncryptUtil.encrypt(item.getOtherPaymentBaseString()));
item.setSocialPerJson(AESEncryptUtil.encrypt(item.getSocialPerJson()));
item.setSocialPerSum(AESEncryptUtil.encrypt(item.getSocialPerSum()));
item.setFundPerJson(AESEncryptUtil.encrypt(item.getFundPerJson()));
item.setFundPerSum(AESEncryptUtil.encrypt(item.getFundPerSum()));
item.setOtherPerJson(AESEncryptUtil.encrypt(item.getOtherPerJson()));
item.setOtherPerSum(AESEncryptUtil.encrypt(item.getOtherPerSum()));
item.setPerSum(AESEncryptUtil.encrypt(item.getPerSum()));
item.setSocialComJson(AESEncryptUtil.encrypt(item.getSocialComJson()));
item.setSocialComSum(AESEncryptUtil.encrypt(item.getSocialComSum()));
item.setComSum(AESEncryptUtil.encrypt(item.getComSum()));
item.setSocialSum(AESEncryptUtil.encrypt(item.getSocialSum()));
item.setFundSum(AESEncryptUtil.encrypt(item.getFundSum()));
item.setOtherSum(AESEncryptUtil.encrypt(item.getOtherSum()));
item.setTotal(AESEncryptUtil.encrypt(item.getTotal()));
return item;
}
}

View File

@ -0,0 +1,23 @@
package com.engine.salary.entity.hrm.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author: sy
* @Description: 人员信息列表
* @Date: 2022/11/21
**/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class HrmInfoDTO {
//员工id
private Long employeeId;
//姓名
private String username;
}

View File

@ -0,0 +1,27 @@
package com.engine.salary.entity.hrm.param;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Collection;
/**
* @Author: sy
* @Description: 人员查询
* @Date: 2022/11/21
**/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class HrmQueryParam {
String userName;
private int pageNum;
private int pageSize;
private Collection<Long> ids;
}

View File

@ -16,6 +16,7 @@ import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveDataDTO;
import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveItemDataDTO;
import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveTaxAgentDataDTO;
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
import com.engine.salary.entity.salarysob.dto.SalarySobCycleDTO;
import com.engine.salary.entity.salarysob.po.SalarySobAdjustRulePO;
import com.engine.salary.enums.salaryformula.SalaryFormulaReferenceEnum;
import com.engine.salary.enums.salaryformula.SalarySQLReferenceEnum;
@ -136,6 +137,39 @@ public class CalculateFormulaVarBO {
return resultMap;
}
/**
* 处理核算日期相关信息
*/
private List<FormulaVarValue> handleSalarySobCycleDTO(SalaryAcctCalculateBO salaryAcctCalculateBO) {
SalarySobCycleDTO salarySobCycleDTO = salaryAcctCalculateBO.getSalarySobCycleDTO();
salarySobCycleDTO.setSalaryDate(SalaryDateUtil.toDate(salarySobCycleDTO.getSalaryMonth(), 1));
salarySobCycleDTO.setTaxDate(SalaryDateUtil.toDate(salarySobCycleDTO.getTaxCycle(), 1));
salarySobCycleDTO.setSocialSecurityDate(SalaryDateUtil.toDate(salarySobCycleDTO.getSocialSecurityCycle(), 1));
LocalDateRange salaryCycle = salarySobCycleDTO.getSalaryCycle();
salarySobCycleDTO.setSalaryCycleFromDate(salaryCycle.getFromDate());
salarySobCycleDTO.setSalaryCycleEndDate(salaryCycle.getEndDate());
LocalDateRange attendCycle = salarySobCycleDTO.getAttendCycle();
salarySobCycleDTO.setAttendCycleFromDate(attendCycle.getFromDate());
salarySobCycleDTO.setAttendCycleEndDate(attendCycle.getEndDate());
Map<String, String> map = JsonUtil.parseMap(salarySobCycleDTO, String.class);
List<FormulaVarValue> formulaVarValues = Lists.newArrayList();
Field[] declaredFields = SalarySobCycleDTO.class.getDeclaredFields();
for (Field declaredField : declaredFields) {
if (declaredField.isAnnotationPresent(SalaryFormulaVar.class)) {
String fieldName = declaredField.getName();
String fieldId = SalarySQLReferenceEnum.SALARY_CYCLE.getValue()
+ SalaryFormulaFieldConstant.FIELD_ID_SEPARATOR
+ fieldName;
formulaVarValues.add(new FormulaVarValue().setFieldId(fieldId).setFieldValue(map.getOrDefault(fieldName, StringUtils.EMPTY)));
}
}
return formulaVarValues;
}
/**
* 处理薪资核算结果
@ -164,7 +198,7 @@ public class CalculateFormulaVarBO {
}
/**
* 处理薪资档案会涉及调薪计薪规则
* 处理薪资档案会涉及调薪计薪规则+处理核算日期
*
* @param salaryAcctCalculateBO 薪资核算参数
* @param resultMap 返回结果集
@ -179,6 +213,7 @@ public class CalculateFormulaVarBO {
List<FormulaVarValue> formulaVarValues = resultMap.computeIfAbsent(key, k -> Lists.newArrayList());
// 将薪资档案的值转换成公式中的变量填充到返回结果集中
formulaVarValues.addAll(handleSalaryArchiveItemVal(salaryAcctCalculateBO, salaryArchiveTaxAgentDataDTO.getSalaryItemValues(), salarySobAdjustRulePOMap));
formulaVarValues.addAll(handleSalarySobCycleDTO(salaryAcctCalculateBO));
}
}
}

View File

@ -119,4 +119,28 @@ public class SalaryAcctEmployeeBO {
}
return resultList;
}
public static List<List<SalaryAcctEmployeePO>> partitionByEmployeeId(List<SalaryAcctEmployeePO> salaryAcctEmployees) {
if (CollectionUtils.isEmpty(salaryAcctEmployees)) {
return Collections.emptyList();
}
List<Long> employeeIdList = salaryAcctEmployees.stream()
.map(SalaryAcctEmployeePO::getEmployeeId)
.distinct()
.collect(Collectors.toList());
// 每个线程处理多少个人员一个线程最多处理10个人员
int size = 100;
List<List<Long>> partition = Lists.partition(employeeIdList, size);
List<List<SalaryAcctEmployeePO>> resultList = new ArrayList<>();
Map<Long, List<SalaryAcctEmployeePO>> salaryAcctEmployeeMap = SalaryEntityUtil.group2Map(salaryAcctEmployees, SalaryAcctEmployeePO::getEmployeeId);
for (List<Long> employeeIds : partition) {
List<SalaryAcctEmployeePO> temp = new ArrayList<>();
for (Long employeeId : employeeIds) {
temp.addAll(salaryAcctEmployeeMap.getOrDefault(employeeId, Collections.emptyList()));
}
resultList.add(temp);
}
return resultList;
}
}

View File

@ -0,0 +1,46 @@
package com.engine.salary.entity.salaryacct.bo;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO;
import com.engine.salary.entity.salarysob.dto.SalarySobCycleDTO;
import com.engine.salary.entity.salarysob.po.SalarySobAdjustRulePO;
import lombok.Data;
import java.util.List;
import java.util.Map;
/**
* @description: 薪资核算上下文
* @author: xiajun
* @modified By: xiajun
* @date: Created in 8/22/22 3:26 PM
* @version:v1.0
*/
@Data
public class SalaryCalcContext {
/**
* 当前核算人员
*/
private DataCollectionEmployee simpleEmployee;
/**
* 员工状态
*/
private Map<String, String> hrmStatusMap;
/**
* 薪资核算记录
*/
private SalaryAcctRecordPO salaryAcctRecord;
/**
* 考勤周期薪资周期税款所属期社保福利台账月份
*/
private SalarySobCycleDTO salarySobCycle;
/**
* 调薪计薪规则
*/
private List<SalarySobAdjustRulePO> salaryAdjustmentRules;
/**
* 本次薪资核算所涉及的公式
*/
private SalaryCalcFormulaContext salaryCalcFormulaContext;
}

View File

@ -0,0 +1,41 @@
package com.engine.salary.entity.salaryacct.bo;
import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO;
import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO;
import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO;
import lombok.Data;
import java.util.List;
import java.util.Map;
/**
* @description:
* @author: xiajun
* @modified By: xiajun
* @date: Created in 8/23/22 3:45 PM
* @version:v1.0
*/
@Data
public class SalaryCalcEmployeeContext {
/**
* keyformulaIdvalue公式变量的值
*/
private Map<Long, Map<String, String>> formulaVarValueMap;
/**
* keysalaryAcctEmployeeIdvalue薪资核算结果
*/
private Map<Long, SalaryAcctResultPO> noDecryptAcctResultValueMap;
/**
* keysalaryAcctRecordIdvalue薪资核算记录
*/
private Map<Long, SalaryAcctRecordPO> sameTaxCycleRecordMap;
/**
* keyemployee-taxAgentIdvalue薪资核算人员
*/
private Map<String, List<SalaryAcctEmployeePO>> sameTaxCycleEmployeeMap;
/**
* keysalaryAcctEmployeeIdvalue薪资核算结果
*/
private Map<Long, SalaryAcctResultPO> sameTaxCycleResultValueMap;
}

View File

@ -0,0 +1,53 @@
package com.engine.salary.entity.salaryacct.bo;
import com.engine.salary.enums.SalaryRoundingModeEnum;
import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* @description: 薪资核算计算优先级
* @author: xiajun
* @modified By: xiajun
* @date: Created in 8/23/22 11:52 AM
* @version:v1.0
*/
@Data
@Accessors(chain = true)
public class SalaryCalcFormula {
/**
* 薪资项目id
*/
private Long salaryItemId;
/**
* 薪资项目的code
*/
private String salaryItemCode;
/**
* 薪资类型
*/
private String incomeCategory;
/**
* 薪资档案引用0薪资档案未引用1薪资档案引用
* 为处理历史数据而留不再使用
*/
@Deprecated
private Integer useInEmployeeSalary;
/**
* 字段类型
*/
private SalaryDataTypeEnum dataType;
/**
* 舍入规则
*/
private SalaryRoundingModeEnum roundingMode;
/**
* 小数位数
*/
private Integer pattern;
/**
* 公式id
*/
private Long formulaId;
}

View File

@ -0,0 +1,105 @@
package com.engine.salary.entity.salaryacct.bo;
import com.engine.salary.entity.salaryformula.ExpressFormula;
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
import com.googlecode.aviator.Expression;
import lombok.Data;
import java.util.*;
/**
* @description: 薪资核算公式
* @author: xiajun
* @modified By: xiajun
* @date: Created in 8/22/22 3:33 PM
* @version:v1.0
*/
@Data
public class SalaryCalcFormulaContext {
/**
* 薪资核算所包含的薪资项目
*/
private Map<Long, SalaryItemPO> salaryItemMap;
/**
* 本次薪资核算所涉及的公式编译后的对象
*/
private Map<Long, Expression> expressionMap;
/**
* 薪资核算所包含的公式
*/
private Map<Long, ExpressFormula> expressFormulaMap;
/**
* 薪资核算所包含的薪资项目id按计算顺序排序好了
*/
private List<List<SalaryCalcFormula>> salaryCalcFormulas;
/**
* 所有公式中是否包含薪资档案
*/
private Set<String> salaryArchiveFieldIds;
/**
* 所有公式中是否包含其他扣除
*/
private Set<String> otherDeductionFieldIds;
/**
* 所有公式中是否包含专项附加扣除
*/
private Set<String> addUpDeductionFieldIds;
/**
* 所有公式中是否包含往期累计情况
*/
private Set<String> addUpSituationFieldIds;
/**
* 所有公式中是否包含考勤
*/
private Set<String> attendFieldIds;
/**
* 所有公式中是否包含社保福利
*/
private Set<String> welfareFieldIds;
/**
* 所有公式中是否包含人员信息
*/
private Set<String> employeeInfoFieldIds;
/**
* 所有公式中是否包含外部人员
*/
private Set<String> extEmployeeFieldIds;
/**
* 所有公式中包含的自定义业务数据表
*/
private Map<Long, Set<String>> customDataFieldIdMap;
/**
* 所有公式中包含的已发
*/
private Set<String> issuedFieldIds;
public SalaryCalcFormulaContext() {
this.salaryItemMap = new HashMap<>();
this.expressFormulaMap = new HashMap<>();
this.salaryCalcFormulas = new ArrayList<>();
this.salaryArchiveFieldIds = new HashSet<>();
this.otherDeductionFieldIds = new HashSet<>();
this.addUpDeductionFieldIds = new HashSet<>();
this.addUpSituationFieldIds = new HashSet<>();
this.attendFieldIds = new HashSet<>();
this.welfareFieldIds = new HashSet<>();
this.employeeInfoFieldIds = new HashSet<>();
this.extEmployeeFieldIds = new HashSet<>();
this.customDataFieldIdMap = new HashMap<>();
this.issuedFieldIds = new HashSet<>();
}
}

View File

@ -0,0 +1,34 @@
package com.engine.salary.entity.salaryacct.bo;
import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.util.List;
/**
* @description:
* @author: xiajun
* @modified By: xiajun
* @date: 2022/8/22 20:45
* @version:v1.0
*/
@Data
@AllArgsConstructor
public class SalaryCalcResult {
/**
* 子线程是否运算成功
*/
private boolean status;
/**
* 子线程元算失败的错误信息
*/
private String errMsg;
/**
* 计算结果
*/
private List<SalaryAcctResultPO> salaryAcctResultValues;
}

View File

@ -0,0 +1,41 @@
package com.engine.salary.entity.salaryacct.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.experimental.Accessors;
import java.math.BigDecimal;
@Data
@Accessors(chain = true)
@AllArgsConstructor
public class SalaryAcctRateDTO {
//"缓存索引")
private String index;
//"提示信息")
private String msg;
//"状态")
private boolean status;
//"是否已经完成")
private boolean finish;
//"总数")
private Integer totalQty;
//"已经计算的数量")
private Integer calcQty;
//"进度")
private BigDecimal rate;
//"校验异常")
private boolean checkStatus;
public SalaryAcctRateDTO(String index) {
this.index = index;
this.msg = "";
this.status = true;
this.finish = false;
this.totalQty = 1;
this.calcQty = 0;
this.rate = BigDecimal.ZERO;
this.checkStatus = true;
}
}

View File

@ -372,6 +372,7 @@ public class SalaryArchiveExcelBO extends Service {
//员工id 流程定薪使用
String empId = Optional.ofNullable(map.get("员工id")).orElse("").toString();
if (StringUtils.isNotBlank(empId)) {
employeeSameIds.clear();
employeeSameIds.add(Long.valueOf(empId));
employeeId = Long.valueOf(empId);
}

View File

@ -1,5 +1,6 @@
package com.engine.salary.entity.salarysob.dto;
import com.engine.salary.annotation.SalaryFormulaVar;
import com.engine.salary.common.LocalDateRange;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
@ -9,6 +10,7 @@ import lombok.Data;
import lombok.NoArgsConstructor;
import java.time.YearMonth;
import java.util.Date;
/**
* 薪资账套的周期
@ -24,24 +26,43 @@ import java.time.YearMonth;
@AllArgsConstructor
public class SalarySobCycleDTO {
//薪资账套id
//薪资账套id
private Long salarySobId;
//薪资所属月
//薪资所属月
@JsonSerialize(using = ToStringSerializer.class)
private YearMonth salaryMonth;
//税款所属期
//税款所属期
@JsonSerialize(using = ToStringSerializer.class)
private YearMonth taxCycle;
//社保福利所属期
//社保福利所属期
@JsonSerialize(using = ToStringSerializer.class)
private YearMonth socialSecurityCycle;
//薪资周期")
//薪资周期")
private LocalDateRange salaryCycle;
//考勤周期")
//考勤周期")
private LocalDateRange attendCycle;
/**
* 公式变量
*/
@SalaryFormulaVar(defaultLabel = "薪资所属月", labelId = 86321, dataType = "string")
private Date salaryDate;
@SalaryFormulaVar(defaultLabel = "税款所属期", labelId = 86321, dataType = "string")
private Date taxDate;
@SalaryFormulaVar(defaultLabel = "社保福利所属期", labelId = 86321, dataType = "string")
private Date socialSecurityDate;
@SalaryFormulaVar(defaultLabel = "薪资周期起始日期", labelId = 86321, dataType = "string")
private Date salaryCycleFromDate;
@SalaryFormulaVar(defaultLabel = "薪资周期结束日期", labelId = 86321, dataType = "string")
private Date salaryCycleEndDate;
@SalaryFormulaVar(defaultLabel = "考勤周期起始日期", labelId = 86321, dataType = "string")
private Date attendCycleFromDate;
@SalaryFormulaVar(defaultLabel = "考勤周期结束日期", labelId = 86321, dataType = "string")
private Date attendCycleEndDate;
}

View File

@ -65,6 +65,7 @@ public class InsuranceAccountBO {
.socialPay(SalaryEntityUtil.thousandthConvert(e.getSocialPay()))
.paymentOrganization(e.getPaymentOrganization() != null ? MapperProxyFactory.getProxy(TaxAgentMapper.class).getById(e.getPaymentOrganization()).getName() : "")
.paymentOrganizationId(e.getPaymentOrganization())
.creator(e.getCreator())
.build()
).collect(Collectors.toList());
}

View File

@ -94,6 +94,11 @@ public class InsuranceAccountBatchListDTO {
@TableTitle(title = "核算人", dataIndex = "accountant", key = "accountant")
private String accountant;
/**
* 创建核算人id
*/
private Long creator;
/**
* 最后操作时间
*/

View File

@ -0,0 +1,32 @@
package com.engine.salary.entity.siaccount.param;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author: sy
* @Description: 编辑福利报表
* @Date: 2022/11/18
**/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class EditAccountDetailParam {
private Long id;
private String socialPerJson;
private String socialComJson;
private String fundPerJson;
private String fundComJson;
private String otherPerJson;
private String otherComJson;
}

View File

@ -2,6 +2,7 @@ package com.engine.salary.entity.siaccount.param;
import com.engine.salary.common.BaseQueryParam;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@ -14,6 +15,7 @@ import java.util.List;
* @Version V1.0
**/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class InsuranceAccountDetailParam extends BaseQueryParam {
@ -27,4 +29,15 @@ public class InsuranceAccountDetailParam extends BaseQueryParam {
private String userName;
private String paymentOrganization;
/**
* 退差月份
*/
private List<String> recessionMonthList;
private List<Long> taxAgents;
/**
* 核算创建人
*/
private Long creator;
}

View File

@ -0,0 +1,47 @@
package com.engine.salary.entity.siaccount.param;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* @Author: sy
* @Description: 社保福利台账-退差请求体
* @Date: 2022/11/15
**/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class RecessionParam {
/**
* 退差月份
*/
private List<String> recessionMonthList;
/**
* 退差项目
*/
private List<Integer> projects;
/**
* 包含人员
*/
private List<Long> includes;
/**
* 排除人员
*/
private List<Long> excludes;
/**
* 账单月份
*/
private String billMonth;
private String paymentOrganization;
}

View File

@ -50,7 +50,7 @@ public class InsuranceAccountDetailPO {
private Integer paymentStatus;
/**
* 补缴月份
* 补缴月份/退差月份
*/
private String supplementaryMonth;

View File

@ -0,0 +1,39 @@
package com.engine.salary.entity.siarchives.param;
import com.engine.salary.enums.salaryarchive.SalaryArchiveImportTypeEnum;
import com.engine.salary.enums.siaccount.EmployeeStatusEnum;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
import java.util.Map;
/**
* @Author: sy
* @Description: 社保福利档案导入处理参数action使用
* @Date: 2022/11/10
**/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class SIArchiveImportActionParam {
/**
* 导入类型
*
* @see EmployeeStatusEnum
*/
String runStatus;
/**
* 导入数据
*
*/
List<Map<String,Object>> importDatas;
private boolean addData;
}

View File

@ -25,4 +25,6 @@ public class InsuranceExportParam extends BaseQueryParam {
private String billMonth;
private String paymentOrganization;
private Long creator;
}

View File

@ -16,7 +16,8 @@ import java.util.Objects;
public enum SalarySQLReferenceEnum implements BaseEnum<String> {
EMPLOYEE_INFO("employeeInfo", "员工基本信息", 85366),
SALARY_ACCT_EMPLOYEE("salaryAcctEmployee", "核算基本信息", 85368);
SALARY_ACCT_EMPLOYEE("salaryAcctEmployee", "核算基本信息", 85368),
SALARY_CYCLE("SalaryCycle", "核算日期", 85368);
private String value;
private String defaultLabel;

View File

@ -12,7 +12,10 @@ import com.engine.salary.enums.BaseEnum;
public enum PaymentStatusEnum implements BaseEnum<Integer> {
COMMON(0, "正常缴纳", 92265),
REPAIR(1, "补缴", 92266);
REPAIR(1, "补缴", 92266),
PAYMENT(2,"代缴",121755),
RECESSION(3,"退差",134057),
BALANCE(4,"补差",139823);
private Integer value;

View File

@ -20,4 +20,5 @@ public interface InsuranceExportMapper {
List<AccountExportPO> exportAccount(@Param("paymentStatus") Integer paymentStatus, @Param("param") InsuranceExportParam param);
List<AccountExportPO> exportRecessionAccount(@Param("paymentStatus") Integer paymentStatus, @Param("param") InsuranceExportParam param);
}

View File

@ -113,4 +113,84 @@
where e.status not in (7)
and (e.accounttype is null or e.accounttype = 0)
</select>
<select id="exportRecessionAccount" resultType="com.engine.salary.entity.siexport.po.AccountExportPO">
SELECT a.*,
e.lastname AS userName,
e.MOBILE AS telephone,
d.departmentname AS departmentName,
e.STATUS AS userStatus,
e.workcode AS workcode
FROM (
SELECT *
from hrsa_bill_detail
WHERE delete_type = 0
AND bill_month = #{param.billMonth}
AND payment_status = #{paymentStatus}
AND creator = #{param.creator}
AND payment_organization = #{param.paymentOrganization}
) a
LEFT JOIN hrmresource e ON e.ID = a.employee_id
LEFT JOIN hrmdepartment d ON d.id = e.departmentid
LEFT JOIN hrmsubcompany c ON c.id = e.subcompanyid1
where e.status not in (7)
and (e.accounttype is null or e.accounttype = 0)
<!-- 排序 -->
<if test="param.orderRule != null">
ORDER BY ${param.orderRule.orderRule} ${param.orderRule.ascOrDesc}
</if>
</select>
<select id="exportRecessionAccount" resultType="com.engine.salary.entity.siexport.po.AccountExportPO" databaseId="oracle">
SELECT a.*,
e.lastname AS userName,
e.MOBILE AS telephone,
d.departmentname AS departmentName,
e.STATUS AS userStatus,
e.workcode AS workcode
FROM (
SELECT *
from hrsa_bill_detail
WHERE delete_type = 0
AND bill_month = #{param.billMonth}
AND payment_status = #{paymentStatus}
AND creator = #{param.creator}
AND payment_organization = #{param.paymentOrganization}
) a
LEFT JOIN hrmresource e ON e.ID = a.employee_id
LEFT JOIN hrmdepartment d ON d.id = e.departmentid
LEFT JOIN hrmsubcompany c ON c.id = e.subcompanyid1
where e.status not in (7)
and (e.accounttype is null or e.accounttype = 0)
<!-- 排序 -->
<if test="param.orderRule != null">
ORDER BY ${param.orderRule.orderRule} ${param.orderRule.ascOrDesc}
</if>
</select>
<select id="exportRecessionAccount" resultType="com.engine.salary.entity.siexport.po.AccountExportPO" databaseId="sqlserver">
SELECT a.*,
e.lastname AS userName,
e.MOBILE AS telephone,
d.departmentname AS departmentName,
e.STATUS AS userStatus,
e.workcode AS workcode
FROM (
SELECT *
from hrsa_bill_detail
WHERE delete_type = 0
AND bill_month = #{param.billMonth}
AND payment_status = #{paymentStatus}
AND creator = #{param.creator}
AND payment_organization = #{param.paymentOrganization}
) a
LEFT JOIN hrmresource e ON e.ID = a.employee_id
LEFT JOIN hrmdepartment d ON d.id = e.departmentid
LEFT JOIN hrmsubcompany c ON c.id = e.subcompanyid1
where e.status not in (7)
and (e.accounttype is null or e.accounttype = 0)
<!-- 排序 -->
<if test="param.orderRule != null">
ORDER BY ${param.orderRule.orderRule} ${param.orderRule.ascOrDesc}
</if>
</select>
</mapper>

View File

@ -4,6 +4,8 @@ import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.hrm.DeptInfo;
import com.engine.salary.entity.hrm.PositionInfo;
import com.engine.salary.entity.hrm.SubCompanyInfo;
import com.engine.salary.entity.hrm.dto.HrmInfoDTO;
import com.engine.salary.entity.hrm.param.HrmQueryParam;
import com.engine.salary.entity.salarysob.param.SalarySobRangeEmpQueryParam;
import org.apache.ibatis.annotations.Param;
@ -50,4 +52,9 @@ public interface EmployMapper {
List<DeptInfo> getDeptInfoList(@Param("departmentIds") List<Long> departmentIds);
List<SubCompanyInfo> getSubCompanyInfoList(@Param("subDepartmentIds") List<Long> subDepartmentIds);
List<DataCollectionEmployee> listAll();
List<HrmInfoDTO> listHrmInfoByIdAndName(@Param("param") HrmQueryParam param);
}

View File

@ -37,17 +37,23 @@
<select id="getEmployeeByIdsAll" resultType="com.engine.salary.entity.datacollection.DataCollectionEmployee">
select e.id as employeeId,
e.lastname as username,
e.status as status,
e.workcode as workcode,
e.certificatenum as idNo,
d.departmentname as departmentName,
d.id as departmentId,
sc.SUBCOMPANYNAME as subcompanyName,
c.jobtitlename as jobtitleName,
c.id as jobtitleId,
e.companystartdate as companystartdate,
e.mobile as mobile,
e.enddate as dismissdate,
sc.SUBCOMPANYNAME as subcompanyName
e.status as status,
e.workcode as workcode,
e.sex as sex,
e.email as email,
e.telephone as telephone,
e.jobcall as jobcall,
e.birthday as birthday,
e.certificatenum as idNo,
c.id as jobtitleId,
e.enddate as dismissdate
from hrmresource e
left join hrmdepartment d on e.departmentid = d.id
left join hrmjobtitles c on e.jobtitle = c.id
@ -232,6 +238,22 @@
and (e.accounttype is null or e.accounttype = 0)
</select>
<select id="listAll" resultType="com.engine.salary.entity.datacollection.DataCollectionEmployee">
select e.id as employeeId,
e.lastname as username,
e.status as status,
e.workcode as workcode,
e.certificatenum as idNo,
e.companystartdate as companystartdate,
e.mobile as mobile,
e.subcompanyid1 as subcompanyid,
e.departmentid as departmentId,
e.jobtitle as jobtitleId
from hrmresource e
where e.status not in (7)
and (e.accounttype is null or e.accounttype = 0)
</select>
<select id="listAllForReport" resultType="com.engine.salary.entity.datacollection.DataCollectionEmployee">
select e.id as employeeId,
@ -281,5 +303,64 @@
</if>
</select>
<select id="listHrmInfoByIdAndName" resultType="com.engine.salary.entity.hrm.dto.HrmInfoDTO">
select e.id as employeeId,
e.lastname as username
from hrmresource e
where 1=1
<if test="param.ids != null and param.ids.size()>0">
AND e.id IN
<foreach collection="param.ids" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</if>
<if test="param.userName != null and param.userName != ''">
AND
(
e.lastname like CONCAT('%',#{param.userName},'%')
)
</if>
</select>
<select id="listHrmInfoByIdAndName" resultType="com.engine.salary.entity.hrm.dto.HrmInfoDTO" databaseId="sqlserver">
select e.id as employeeId,
e.lastname as username
from hrmresource e
where 1=1
<if test="param.ids != null and param.ids.size()>0">
AND e.id IN
<foreach collection="param.ids" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</if>
<if test="param.userName != null and param.userName != ''">
AND
(
e.lastname like '%'+#{param.userName}+'%'
)
</if>
</select>
<select id="listHrmInfoByIdAndName" resultType="com.engine.salary.entity.hrm.dto.HrmInfoDTO" databaseId="oracle">
select e.id as employeeId,
e.lastname as username
from hrmresource e
where 1=1
<if test="param.ids != null and param.ids.size()>0">
AND e.id IN
<foreach collection="param.ids" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</if>
<if test="param.userName != null and param.userName != ''">
AND
(
e.lastname like '%'||#{param.userName}||'%'
)
</if>
</select>
</mapper>

View File

@ -26,6 +26,11 @@ public interface InsuranceAccountDetailMapper {
*/
List<InsuranceAccountDetailPO> list(@Param("param") InsuranceAccountDetailParam queryParam);
/**
* 通过id查询
*/
InsuranceAccountDetailPO getById(@Param("id") Long id);
/**
* 根据账单月份获取所有员工
*
@ -152,4 +157,15 @@ public interface InsuranceAccountDetailMapper {
List<InsuranceAccountDetailPO> listAll();
int batchUpdate(@Param("collection") List<InsuranceAccountDetailPO> pos);
/**
* 根据id更新数据
*/
void updateById(InsuranceAccountDetailPO po);
/**
* 删除退差数据(账单月份+退差月份+缴纳状态+人员id+个税扣缴义务人)
*/
void deleteRecessionData(InsuranceAccountDetailPO po);
}

View File

@ -160,6 +160,10 @@
AND
t.payment_organization = #{param.paymentOrganization}
</if>
<if test="param.creator != null">
AND
t.creator = #{param.creator}
</if>
</sql>
<sql id="paramSql">
@ -175,6 +179,18 @@
#{employeeId}
</foreach>
</if>
<if test="param.recessionMonthList != null and param.recessionMonthList.size()>0">
AND t.bill_month IN
<foreach collection="param.recessionMonthList" open="(" item="recessionMonth" separator="," close=")">
#{recessionMonth}
</foreach>
</if>
<if test="param.taxAgents != null and param.taxAgents.size()>0">
AND t.payment_organization IN
<foreach collection="param.taxAgents" open="(" item="taxAgent" separator="," close=")">
#{taxAgent}
</foreach>
</if>
</sql>
<sql id="paramSql" databaseId="oracle">
<if test="param.userName != null and param.userName != ''">
@ -189,6 +205,18 @@
#{employeeId}
</foreach>
</if>
<if test="param.recessionMonthList != null and param.recessionMonthList.size()>0">
AND t.bill_month IN
<foreach collection="param.recessionMonthList" open="(" item="recessionMonth" separator="," close=")">
#{recessionMonth}
</foreach>
</if>
<if test="param.taxAgents != null and param.taxAgents.size()>0">
AND t.payment_organization IN
<foreach collection="param.taxAgents" open="(" item="taxAgent" separator="," close=")">
#{taxAgent}
</foreach>
</if>
</sql>
<sql id="paramSql" databaseId="sqlserver">
<if test="param.userName != null and param.userName != ''">
@ -203,6 +231,18 @@
#{employeeId}
</foreach>
</if>
<if test="param.recessionMonthList != null and param.recessionMonthList.size()>0">
AND t.bill_month IN
<foreach collection="param.recessionMonthList" open="(" item="recessionMonth" separator="," close=")">
#{recessionMonth}
</foreach>
</if>
<if test="param.taxAgents != null and param.taxAgents.size()>0">
AND t.payment_organization IN
<foreach collection="param.taxAgents" open="(" item="taxAgent" separator="," close=")">
#{taxAgent}
</foreach>
</if>
</sql>
@ -244,7 +284,7 @@
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
t.other_com_sum,t.per_sum,t.com_sum,t.payment_status
FROM
hrsa_bill_detail t
WHERE t.delete_type = 0
@ -265,7 +305,7 @@
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
t.other_com_sum,t.per_sum,t.com_sum,t.payment_organization
FROM
hrsa_bill_detail t
WHERE t.delete_type = 0
@ -280,7 +320,7 @@
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
t.other_com_sum,t.per_sum,t.com_sum,t.payment_organization
FROM
hrsa_bill_detail t
WHERE t.delete_type = 0
@ -1104,4 +1144,55 @@
</foreach>
</update>
<select id="getById" resultMap="BaseResultMap">
SELECT
<include refid="baseColumns"/>
FROM
hrsa_bill_detail t
left join hrmresource e on e.ID = t.employee_id
WHERE t.delete_type = 0
and t.id = #{id}
</select>
<update id="updateById" parameterType="com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO">
UPDATE hrsa_bill_detail
<set>
<if test="null != socialPerJson and '' != socialPerJson">social_per_json = #{socialPerJson},</if>
<if test="null != socialPerSum and '' != socialPerSum">social_per_sum = #{socialPerSum},</if>
<if test="null != fundPerJson and '' != fundPerJson">fund_per_json = #{fundPerJson},</if>
<if test="null != fundPerSum and '' != fundPerSum">fund_per_sum = #{fundPerSum},</if>
<if test="null != otherPerJson and '' != otherPerJson">other_per_json = #{otherPerJson},</if>
<if test="null != otherPerSum and '' != otherPerSum">other_per_sum = #{otherPerSum},</if>
<if test="null != perSum and '' != perSum">per_sum = #{perSum},</if>
<if test="null != comSum and '' != comSum">com_sum = #{comSum},</if>
<if test="null != socialComJson and '' != socialComJson">social_com_json = #{socialComJson},</if>
<if test="null != socialComSum and '' != socialComSum">social_com_sum = #{socialComSum},</if>
<if test="null != fundComJson and '' != fundComJson">fund_com_json = #{fundComJson},</if>
<if test="null != fundComSum and '' != fundComSum">fund_com_sum = #{fundComSum},</if>
<if test="null != otherComJson and '' != otherComJson">other_com_json = #{otherComJson},</if>
<if test="null != otherComSum and '' != otherComSum">other_com_sum = #{otherComSum},</if>
<if test="null != socialSum and '' != socialSum">social_sum = #{socialSum},</if>
<if test="null != fundSum and '' != fundSum">fund_sum = #{fundSum},</if>
<if test="null != otherSum and '' != otherSum">other_sum = #{otherSum},</if>
<if test="null != total and '' != total">total = #{total},</if>
<if test="null != updateTime">update_time = #{updateTime},</if>
<if test="null != supplementaryMonth and '' != supplementaryMonth">supplementary_month =
#{supplementaryMonth},
</if>
</set>
WHERE id = #{id}
</update>
<delete id="deleteRecessionData" parameterType="com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO">
UPDATE hrsa_bill_detail
SET delete_type = 1
WHERE delete_type = 0
AND bill_month = #{billMonth}
AND payment_status = #{paymentStatus}
AND payment_organization = #{paymentOrganization}
AND supplementary_month = #{supplementaryMonth}
AND employee_id = #{employeeId}
</delete>
</mapper>

View File

@ -0,0 +1,64 @@
package com.engine.salary.process.siArchives;
import com.engine.common.util.ServiceUtil;
import com.engine.salary.entity.siarchives.param.SIArchiveImportActionParam;
import com.engine.salary.enums.siaccount.EmployeeStatusEnum;
import com.engine.salary.service.SISchemeService;
import com.engine.salary.service.impl.SISchemeServiceImpl;
import com.engine.salary.util.ResponseResult;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import lombok.extern.slf4j.Slf4j;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import java.util.Map;
/**
* @Author: sy
* @Description: 社保福利档案流程使用
* @Date: 2022/11/10
**/
@Slf4j
public class SIArchiveActionAPI {
private SISchemeService getService(User user) {
return ServiceUtil.getService(SISchemeServiceImpl.class,user);
}
/**
* 前置校验列表添加接口
* @param importData
* @return
*/
@POST
@Path("/checkImportSIArchiveListAdd")
@Produces(MediaType.APPLICATION_JSON)
public String checkImportSIArchiveListAdd(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SIArchiveImportActionParam importData) {
User user = HrmUserVarify.getUser(request, response);
importData.setRunStatus(EmployeeStatusEnum.STAY_ADD.getValue());
importData.setAddData(false);
return new ResponseResult<SIArchiveImportActionParam, Map<String, Object>>(user).run(getService(user)::checkSIArchiveAdd, importData);
}
/**
* 新增社保福利档案
* @param importData
* @return
*/
@POST
@Path("/addSIArchive")
@Produces(MediaType.APPLICATION_JSON)
public String addSIArchive(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SIArchiveImportActionParam importData) {
User user = HrmUserVarify.getUser(request, response);
importData.setRunStatus(EmployeeStatusEnum.STAY_ADD.getValue());
importData.setAddData(true);
return new ResponseResult<SIArchiveImportActionParam, Map<String, Object>>(user).run(getService(user)::addSIArchive, importData);
}
}

View File

@ -18,10 +18,10 @@ public interface ColumnBuildService {
*
* @param pos pos
* @param tenantKey 租户key
* @param flag
* @param paymentStatus 缴纳状态
* @return
*/
List<WeaTableColumn> buildCommonColumnsWithStyle(List<InsuranceAccountDetailPO> pos, Long employeeId, String tenantKey, boolean flag);
List<WeaTableColumn> buildCommonColumnsWithStyle(List<InsuranceAccountDetailPO> pos, Long employeeId, String tenantKey, Integer paymentStatus);
List<WeaTableColumn> buildCommonColumns(List<InsuranceAccountDetailPO> pos);

View File

@ -49,6 +49,13 @@ public interface SIAccountService {
*/
Map<String,Object> listSupplementaryPage(InsuranceAccountDetailParam insuranceAccountDetailParam);
/**
* 获取退差列表
* @param insuranceAccountDetailParam
* @return
*/
Map<String,Object> listRecessionPage(InsuranceAccountDetailParam insuranceAccountDetailParam);
/**
* 根据姓名获取补缴缴纳列表
* @param insuranceAccountDetailParam
@ -67,7 +74,7 @@ public interface SIAccountService {
* 保存并进入核算
* @param param
*/
void save(AccountParam param);
String save(AccountParam param);
/**
* 正常缴纳页核算
@ -238,5 +245,20 @@ public interface SIAccountService {
*/
Map<String, Object> importExcelInsuranceDetail(ExcelInsuranceImportParam excelInsuranceImportParam);
/**
* 刷新_bill_batch表中的统计信息
*/
void refreshBillBatch(Long paymentOrganization, String billMonth);
/**
* 将通过id获取InsuranceAccountDetailPO中的社保公积金其他福利个人和公司缴纳数据
*/
Map<String, Object> getPaymentById(Long id);
/**
* 编辑InsuranceAccountDetailPO中的社保公积金其他福利个人和公司缴纳数据
*/
void editAccount(EditAccountDetailParam param);
}

View File

@ -19,7 +19,7 @@ public interface SIExportService {
XSSFWorkbook exportOverView(InsuranceExportParam param);
/**
* 补缴核算导出
* 福利核算导出
* @param paymentStatus
* @param param
* @return

View File

@ -0,0 +1,17 @@
package com.engine.salary.service;
import com.engine.salary.entity.hrm.dto.HrmInfoDTO;
import com.engine.salary.entity.hrm.param.HrmQueryParam;
import com.engine.salary.entity.siaccount.param.RecessionParam;
import com.engine.salary.util.page.PageInfo;
import java.util.Collection;
public interface SIRecessionService {
void save(RecessionParam param, Long employeeId);
void del(Collection<Long> ids, Long employeeId);
PageInfo<HrmInfoDTO> getEmployeeListByTaxAgent(HrmQueryParam param);
}

View File

@ -2,6 +2,7 @@ package com.engine.salary.service;
import com.cloudstore.eccom.pc.table.WeaTableColumn;
import com.engine.salary.entity.siarchives.param.InsuranceArchivesListParam;
import com.engine.salary.entity.siarchives.param.SIArchiveImportActionParam;
import com.engine.salary.entity.siarchives.po.InsuranceArchivesEmployeePO;
import com.engine.salary.entity.sischeme.dto.InsuranceSchemeListDTO;
import com.engine.salary.entity.sischeme.param.InsuranceSchemeParam;
@ -69,4 +70,8 @@ public interface SISchemeService {
Map<String, Object> batchImportEbatch(SISchemaImportParam param);
XSSFWorkbook exportTemplate(InsuranceArchivesListParam param);
Map<String, Object> checkSIArchiveAdd(SIArchiveImportActionParam siArchiveImportActionParam);
Map<String, Object> addSIArchive(SIArchiveImportActionParam siArchiveImportActionParam);
}

View File

@ -0,0 +1,31 @@
//package com.engine.salary.service;
//
//import com.engine.salary.entity.datacollection.DataCollectionEmployee;
//
//import java.util.Collection;
//
///**
// * @description: 薪资核算
// * @author: xiajun
// * @modified By: xiajun
// * @date: Created in 8/22/22 3:15 PM
// * @version:v1.0
// */
//public interface SalaryAcctCalcService {
//
// /**
// * 按薪资核算记录id进行核算
// *
// * @param salaryAcctRecordId
// * @param simpleEmployee
// */
// void calcByRecordId(Long salaryAcctRecordId, DataCollectionEmployee simpleEmployee) throws Exception;
//
// /**
// * 按薪资核算人员id进行核算
// *
// * @param salaryAcctEmployeeIds
// * @param simpleEmployee
// */
// void calcByEmployeeIds(Long salaryAcctRecordId, Collection<Long> salaryAcctEmployeeIds, DataCollectionEmployee simpleEmployee) throws Exception;
//}

View File

@ -1,6 +1,5 @@
package com.engine.salary.service;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.salaryacct.dto.SalaryAcctEmployeeCountDTO;
import com.engine.salary.entity.salaryacct.param.*;
import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO;

View File

@ -0,0 +1,69 @@
package com.engine.salary.service;
public interface SalaryCacheService {
/**
* 添加缓存
*
* @param key
* @param value
* @param <T>
* @return
*/
<T> void set(String key, T value);
/**
* 添加缓存有过期时间
*
* @param key
* @param value
* @param time
* @return
*/
<T> void set(String key, T value, int time);
/**
* 将对象转为json字符串缓存
* @param key
* @param value
* @param <T>
*/
<T> void setJson(String key, T value);
/**
* 将对象转为json字符串缓存有过期时间
* @param key
* @param value
* @param time
* @param <T>
*/
<T> void setJson(String key, T value, int time);
/**
* 获取缓存
* @param key
* @param <T>
* @return
*/
<T> T get(String key);
/**
* 获取缓存对象
* @param key
* @param clazz
* @param <T>
* @return
*/
<T> T getJson(String key, Class<T> clazz);
/**
* 清除缓存
*
* @param key
*/
void remove(String key);
}

View File

@ -72,5 +72,5 @@ public interface SalaryEmployeeService {
* @param workcode 工号
* @param uid 人员id
*/
List<DataCollectionEmployee> matchImportEmployee(List<DataCollectionEmployee> employeeList, String userName, String deparmentName, String mobile, String workcode,Long uid);
List<DataCollectionEmployee> matchImportEmployee(List<DataCollectionEmployee> employeeList, String userName, String deparmentName, String mobile, String workcode, Long uid);
}

View File

@ -36,4 +36,10 @@ public interface SalaryFormulaService {
FormulaPO save(SalaryFormulaSaveParam salaryFormulaSaveParam);
FormulaPO update(SalaryFormulaSaveParam salaryFormulaSaveParam);
/**
* 初始化函数
*/
void initFunction();
}

View File

@ -1,12 +1,10 @@
package com.engine.salary.service;
import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeEmployeeDTO;
import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeListDTO;
import com.engine.salary.entity.taxagent.param.TaxAgentRangeQueryParam;
import com.engine.salary.entity.taxagent.param.TaxAgentRangeSaveParam;
import com.engine.salary.entity.taxagent.param.TaxAgentSubAdminRangeQueryParam;
import com.engine.salary.entity.taxagent.po.TaxAgentManageRangePO;
import com.engine.salary.enums.salarysob.SalaryEmployeeStatusEnum;
import com.engine.salary.util.page.PageInfo;
import java.util.Collection;
@ -22,40 +20,6 @@ import java.util.List;
**/
public interface TaxAgentManageRangeService {
/**
* 根据个税扣缴义务人ID和当前账户查询人员
*
* @param taxAgentIds
* @return
*/
List<TaxAgentManageRangeEmployeeDTO> listSalaryEmployeeByTaxAgentIds(List<Long> taxAgentIds);
/**
* 根据人员状态个税扣缴义务人ID和当前账户查询人员
*
* @param employeeStatus
* @param taxAgentIds
* @return
*/
List<TaxAgentManageRangeEmployeeDTO> listSalaryEmployeeByTaxAgentIds(SalaryEmployeeStatusEnum employeeStatus, List<Long> taxAgentIds);
/**
* 根据分管理员ID和当前账户查询人员
*
* @param taxAgentSubAdminIds
* @return
*/
List<TaxAgentManageRangeEmployeeDTO> listSalaryEmployeeBySubAdminIds(List<Long> taxAgentSubAdminIds);
/**
* 根据人员状态分管理员ID和当前账户查询人员
*
* @param employeeStatus
* @param taxAgentSubAdminIds
* @return
*/
List<TaxAgentManageRangeEmployeeDTO> listSalaryEmployeeBySubAdminIds(SalaryEmployeeStatusEnum employeeStatus, List<Long> taxAgentSubAdminIds);
/**
* 根据查询条件查询分管理员的人员范围
*
@ -89,12 +53,6 @@ public interface TaxAgentManageRangeService {
*/
void save(TaxAgentRangeSaveParam saveParam);
/**
* 保存分管理员的管理范围
*
* @param saveParam
*/
// void save4SubAdmin(TaxAgentSubAdminRangeSaveParam saveParam);
/**
* 根据主键id删除管理范围
@ -110,10 +68,5 @@ public interface TaxAgentManageRangeService {
*/
void deleteByTaxAgentIds(Collection<Long> taxAgentIds);
/**
* 根据分管理员的id删除管理范围
*
* @param subAdminIds 分管理员列表
*/
void deleteBySubAdmins(Collection<Long> subAdminIds);
void syncManageRange(List<Long> taxAgentIds,String index);
}

View File

@ -12,6 +12,7 @@ import com.engine.salary.entity.siarchives.po.InsuranceArchivesFundSchemePO;
import com.engine.salary.entity.siarchives.po.InsuranceArchivesOtherSchemePO;
import com.engine.salary.entity.siarchives.po.InsuranceArchivesSocialSchemePO;
import com.engine.salary.entity.sicategory.po.ICategoryPO;
import com.engine.salary.enums.siaccount.PaymentStatusEnum;
import com.engine.salary.enums.sicategory.WelfareTypeEnum;
import com.engine.salary.mapper.sicategory.ICategoryMapper;
import com.engine.salary.service.ColumnBuildService;
@ -30,7 +31,7 @@ import java.util.stream.Collectors;
**/
public class ColumnBuildServiceImpl extends Service implements ColumnBuildService {
@Override
public List<WeaTableColumn> buildCommonColumnsWithStyle(List<InsuranceAccountDetailPO> pos, Long employeeId, String tenantKey, boolean flag) {
public List<WeaTableColumn> buildCommonColumnsWithStyle(List<InsuranceAccountDetailPO> pos, Long employeeId, String tenantKey, Integer paymentStatus) {
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);
@ -49,8 +50,10 @@ public class ColumnBuildServiceImpl extends Service implements ColumnBuildServic
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) {
if (paymentStatus.equals(PaymentStatusEnum.REPAIR.getValue())) {
list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 100379, "补缴月份"), "supplementaryMonth"));
} else if (paymentStatus.equals(PaymentStatusEnum.RECESSION.getValue())) {
list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 100379, "退差月份"), "supplementaryMonth"));
}
list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 91325, "个税扣缴义务人"), "socialPayOrg"));
list.add(new WeaTableColumn("150px",SalaryI18nUtil.getI18nLabel( 91324, "社保账号"), "socialAccount"));

View File

@ -14,6 +14,7 @@ import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO;
import com.engine.salary.entity.salaryformula.dto.SalaryFormulaTaxRateDTO;
import com.engine.salary.entity.salaryformula.po.FormulaVar;
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
import com.engine.salary.entity.salarysob.dto.SalarySobCycleDTO;
import com.engine.salary.entity.salarysob.po.SalarySobItemPO;
import com.engine.salary.entity.taxrate.TaxRateBase;
import com.engine.salary.enums.salaryformula.ReferenceTypeEnum;
@ -111,6 +112,9 @@ public class RemoteExcelServiceImpl extends Service implements RemoteExcelServic
case SALARY_ACCT_EMPLOYEE:
vars = convert2FormulaVar(SalaryAcctEmployeePO.class, referenceEnum.getValue() + "");
break;
case SALARY_CYCLE:
vars = convert2FormulaVar(SalarySobCycleDTO.class, referenceEnum.getValue() + "");
break;
default:
break;
}
@ -124,9 +128,11 @@ public class RemoteExcelServiceImpl extends Service implements RemoteExcelServic
if (referenceEnum != null) {
switch (referenceEnum) {
case SALARY_ITEM:
case SALARY_ARCHIVES:
vars = salaryItem2FormulaVar(referenceEnum, extendParam);
break;
case SALARY_ARCHIVES:
vars = salaryArchives2FormulaVar(referenceEnum, extendParam);
break;
case ADD_UP_SITUATION:
vars = convert2FormulaVar(AddUpSituation.class, referenceEnum.getValue() + "");
break;
@ -279,6 +285,7 @@ public class RemoteExcelServiceImpl extends Service implements RemoteExcelServic
salaryItems = getSalaryItemService(user).listByIds(salaryItemIds);
}
return salaryItems.stream()
.filter(e -> e.getUseInEmployeeSalary() == 0)
.map(e -> {
FormulaVar formulaVar = new FormulaVar();
formulaVar.setFieldId(referenceEnum.getValue() + SalaryFormulaFieldConstant.FIELD_ID_SEPARATOR + e.getCode());
@ -290,6 +297,32 @@ public class RemoteExcelServiceImpl extends Service implements RemoteExcelServic
}
private List<FormulaVar> salaryArchives2FormulaVar(SalaryFormulaReferenceEnum referenceEnum, Map<String, Object> extendParam) {
Set<Long> salaryItemIds = Collections.emptySet();
Object salarySobId = extendParam == null ? null : extendParam.get("salarySobId");
if (Objects.nonNull(salarySobId)) {
List<SalarySobItemPO> salarySobItems = getSalarySobItemService(user).listBySalarySobId(Long.valueOf(String.valueOf(salarySobId)));
salaryItemIds = SalaryEntityUtil.properties(salarySobItems, SalarySobItemPO::getSalaryItemId);
}
List<SalaryItemPO> salaryItems;
if (CollectionUtils.isEmpty(salaryItemIds)) {
salaryItems = getSalaryItemService(user).listAll();
} else {
salaryItems = getSalaryItemService(user).listByIds(salaryItemIds);
}
return salaryItems.stream()
.filter(e -> e.getUseInEmployeeSalary() == 1)
.map(e -> {
FormulaVar formulaVar = new FormulaVar();
formulaVar.setFieldId(referenceEnum.getValue() + SalaryFormulaFieldConstant.FIELD_ID_SEPARATOR + e.getCode());
formulaVar.setName(e.getName());
formulaVar.setSource("" + referenceEnum.getValue());
formulaVar.setFieldType(e.getDataType());
return formulaVar;
}).collect(Collectors.toList());
}
private <T> List<FormulaVar> convert2FormulaVar(Class<T> clazz, String formId) {
Field[] declaredFields = clazz.getDeclaredFields();
List<FormulaVar> formulaVars = Lists.newArrayListWithExpectedSize(declaredFields.length);

View File

@ -74,6 +74,8 @@ import weaver.hrm.User;
import java.io.InputStream;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@ -259,7 +261,7 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
//动态列组装
List<WeaTableColumn> weaTableColumn = getColumnBuildService(user).buildCommonColumnsWithStyle(insuranceAccountDetailPOS, employeeId, SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY, false);
List<WeaTableColumn> weaTableColumn = getColumnBuildService(user).buildCommonColumnsWithStyle(insuranceAccountDetailPOS, employeeId, SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY, queryParam.getPaymentStatus());
WeaTable table = new WeaTable();
table.setPageUID(UUID.randomUUID().toString());
@ -322,7 +324,7 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
//动态列组装
List<WeaTableColumn> weaTableColumn = getColumnBuildService(user).buildCommonColumnsWithStyle(insuranceAccountDetailPOS, employeeId, SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY, true);
List<WeaTableColumn> weaTableColumn = getColumnBuildService(user).buildCommonColumnsWithStyle(insuranceAccountDetailPOS, employeeId, SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY, queryParam.getPaymentStatus());
SalaryWeaTable<InsuranceAccountDetailPO> table = new SalaryWeaTable<>(user, InsuranceAccountDetailPO.class);
table.setColumns(weaTableColumn);
@ -349,6 +351,62 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
return listSupplementaryPage(queryParam);
}
@Override
public Map<String, Object> listRecessionPage(InsuranceAccountDetailParam queryParam) {
Long employeeId = (long) user.getUID();
Map<String, Object> datas = new HashMap<>();
// 分权逻辑
Boolean needAuth = getTaxAgentService(user).isNeedAuth((long) user.getUID());
if (needAuth) {
Collection<TaxAgentPO> taxAgentPOS = getTaxAgentService(user).listAllTaxAgents((long) user.getUID());
List<Long> taxAgents = taxAgentPOS.stream().map(TaxAgentPO::getId).collect(Collectors.toList());
if (CollectionUtils.isEmpty(taxAgents)) {
//防止普通用户查询
queryParam.setTaxAgents(Collections.singletonList(-1L));
} else {
queryParam.setTaxAgents(taxAgents);
}
}
//退差列表
queryParam.setPaymentStatus(PaymentStatusEnum.RECESSION.getValue());
//排序配置
OrderRuleVO orderRule = getSalarySysConfService(user).orderRule();
queryParam.setOrderRule(orderRule);
SalaryPageUtil.start(queryParam.getCurrent(), queryParam.getPageSize());
List<InsuranceAccountDetailPO> list = getInsuranceAccountDetailMapper().list(queryParam);
PageInfo<InsuranceAccountDetailPO> pageInfo = new PageInfo<>(list, InsuranceAccountDetailPO.class);
List<InsuranceAccountDetailPO> insuranceAccountDetailPOS = pageInfo.getList();
InsuranceAccountDetailPOEncrypt.decryptInsuranceAccountDetailPOList(insuranceAccountDetailPOS);
//数据组装
List<Map<String, Object>> records = getService(user).buildCommonRecords(insuranceAccountDetailPOS, employeeId);
PageInfo<Map<String, Object>> pageInfos = new PageInfo<>(records);
pageInfos.setTotal(pageInfo.getTotal());
pageInfos.setPageNum(queryParam.getCurrent());
pageInfos.setPageSize(queryParam.getPageSize());
//动态列组装
List<WeaTableColumn> weaTableColumn = getColumnBuildService(user).buildCommonColumnsWithStyle(insuranceAccountDetailPOS, employeeId, SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY, queryParam.getPaymentStatus());
SalaryWeaTable<InsuranceAccountDetailPO> table = new SalaryWeaTable<>(user, InsuranceAccountDetailPO.class);
table.setColumns(weaTableColumn);
List<Column> columns = weaTableColumn.stream().map(v -> new Column(v.getText(), v.getColumn(), v.getColumn())).collect(Collectors.toList());
pageInfos.setColumns(columns);
WeaResultMsg result = new WeaResultMsg(false);
result.putAll(table.makeDataResult());
result.success();
datas.put("pageInfo", pageInfos);
//datas.put("dataKey",result.getResultMap());
return datas;
}
@Override
public Map<String, Object> getForm(Map<String, Object> params) {
Map<String, Object> apidatas = new HashMap<>();
@ -387,12 +445,12 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
}
@Override
public void save(AccountParam param) {
public String save(AccountParam param) {
ValidUtil.doValidator(param);
Long employeeId = (long) user.getUID();
String lastName = user.getLastname();
getSiAccountBiz(user).save(param.isFlag(), param, employeeId, lastName);
return getSiAccountBiz(user).save(param.isFlag(), param, employeeId, lastName);
}
@Override
@ -511,6 +569,12 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
overView.put("id", "4");
overView.put("content", SalaryI18nUtil.getI18nLabel(99927, "总览"));
tabList.add(overView);
Map<String, Object> recession = new HashMap<>();
recession.put("id", "5");
recession.put("content", SalaryI18nUtil.getI18nLabel(92270, "退差"));
tabList.add(recession);
insuranceAccountTabDTO.setTabList(tabList);
insuranceAccountTabDTO.setShow(isShow);
insuranceAccountTabDTO.setBillMonth(build.getBillMonth());
@ -833,6 +897,8 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
public List<InsuranceAccountDetailPO> queryList(String billMonth, Long taxAgentId, List<Long> employeeIds) {
List<InsuranceAccountDetailPO> insuranceAccountDetailPOS = getInsuranceAccountDetailMapper().queryList(billMonth, taxAgentId, employeeIds);
//退差数据不参与薪资核算
insuranceAccountDetailPOS = insuranceAccountDetailPOS.stream().filter(f -> f.getPaymentStatus().equals(PaymentStatusEnum.COMMON.getValue()) || f.getPaymentStatus().equals(PaymentStatusEnum.REPAIR.getValue())).collect(Collectors.toList());
List<InsuranceAccountDetailPO> list = buildNewInsuranceDetailPOS(insuranceAccountDetailPOS);
// InsuranceAccountDetailPOEncrypt.decryptInsuranceAccountDetailPOList(list);
return list;
@ -1128,10 +1194,10 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
// 处理数值
List<Map<String, Object>> data = ExcelParseHelper.parse2Map(sheet, 1);
if (CollectionUtils.isEmpty(headers)) {
throw new RuntimeException("表头为空");
throw new SalaryRunTimeException("表头为空");
}
if (CollectionUtils.isEmpty(data)) {
throw new RuntimeException("无数据");
throw new SalaryRunTimeException("无数据");
}
//存储待更新的InsuranceAccountDetailPO数据
List<InsuranceAccountDetailPO> updateInsuranceAccountDetailList = new ArrayList<>();
@ -1267,6 +1333,45 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
getSiAccountBiz(user).updateByEmployeeIdAndBillMonth(po);
}
//刷新hrsa_bill_batch中数据统计信息
if (updateInsuranceAccountDetailList.size() > 0) {
ExecutorService taskExecutor = Executors.newCachedThreadPool();
taskExecutor.execute(() -> {
Long paymentOrganization = updateInsuranceAccountDetailList.get(0).getPaymentOrganization();
String billMonth = updateInsuranceAccountDetailList.get(0).getBillMonth();
if (paymentOrganization != null && billMonth != null) {
InsuranceAccountDetailParam refreshParam =new InsuranceAccountDetailParam();
refreshParam.setBillMonth(billMonth);
refreshParam.setPaymentOrganization(paymentOrganization.toString());
PageInfo<InsuranceAccountViewListDTO> pageInfos = overView(refreshParam);
TaxAgentPO taxAgentPo = getTaxAgentMapper().getById(paymentOrganization);
if (taxAgentPo != null) {
List<InsuranceAccountViewListDTO> viewListDTOList = pageInfos.getList();
viewListDTOList.stream().filter(f -> f.getPayOrg().equals(taxAgentPo.getName())).collect(Collectors.toList());
InsuranceAccountBatchPO batchPO = getInsuranceAccountBatchMapper().getByBillMonth(billMonth, paymentOrganization);
batchPO = SiAccountEncrypt.decryptInsuranceAccountBatch(batchPO);
//更新
if (viewListDTOList.size() > 0 && batchPO != null) {
InsuranceAccountViewListDTO viewListDTO = viewListDTOList.get(0);
batchPO.setSocialNum(viewListDTO.getSocialNum());
batchPO.setFundNum(viewListDTO.getFundNum());
batchPO.setOtherNum(viewListDTO.getOtherNum());
batchPO.setSocialPay(viewListDTO.getSocialPaySum().replace(",", ""));
batchPO.setFundPay(viewListDTO.getFundPaySum().replace(",", ""));
batchPO.setOtherPay(viewListDTO.getOtherPaySum().replace(",", ""));
batchPO.setUpdateTime(new Date());
batchPO = SiAccountEncrypt.encryptInsuranceAccountBatch(batchPO);
getInsuranceAccountBatchMapper().updateById(batchPO);
}
}
}
});
}
apidatas.put("successCount", successCount);
apidatas.put("errorCount", failCount);
apidatas.put("errorData", excelComments);
@ -1778,10 +1883,10 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
// 处理数值
List<Map<String, Object>> data = ExcelParseHelper.parse2Map(sheet, 1);
if (CollectionUtils.isEmpty(headers)) {
throw new RuntimeException("表头为空");
throw new SalaryRunTimeException("表头为空");
}
if (CollectionUtils.isEmpty(data)) {
throw new RuntimeException("无数据");
throw new SalaryRunTimeException("无数据");
}
String billMonth = importParam.getBillMonth();
@ -2084,5 +2189,290 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
return excelInsuranceDetailPO;
}
/**
* 刷新_bill_batch表中的统计信息
*/
@Override
public void refreshBillBatch(Long paymentOrganization, String billMonth) {
ExecutorService taskExecutor = Executors.newCachedThreadPool();
taskExecutor.execute(() -> {
if (paymentOrganization != null && billMonth != null) {
InsuranceAccountDetailParam refreshParam =new InsuranceAccountDetailParam();
refreshParam.setBillMonth(billMonth);
refreshParam.setPaymentOrganization(paymentOrganization.toString());
PageInfo<InsuranceAccountViewListDTO> pageInfos = overView(refreshParam);
TaxAgentPO taxAgentPo = getTaxAgentMapper().getById(paymentOrganization);
if (taxAgentPo != null) {
List<InsuranceAccountViewListDTO> viewListDTOList = pageInfos.getList();
viewListDTOList.stream().filter(f -> f.getPayOrg().equals(taxAgentPo.getName())).collect(Collectors.toList());
InsuranceAccountBatchPO batchPO = getInsuranceAccountBatchMapper().getByBillMonth(billMonth, paymentOrganization);
batchPO = SiAccountEncrypt.decryptInsuranceAccountBatch(batchPO);
//更新
if (viewListDTOList.size() > 0 && batchPO != null) {
InsuranceAccountViewListDTO viewListDTO = viewListDTOList.get(0);
batchPO.setSocialNum(viewListDTO.getSocialNum());
batchPO.setFundNum(viewListDTO.getFundNum());
batchPO.setOtherNum(viewListDTO.getOtherNum());
batchPO.setSocialPay(viewListDTO.getSocialPaySum().replace(",", ""));
batchPO.setFundPay(viewListDTO.getFundPaySum().replace(",", ""));
batchPO.setOtherPay(viewListDTO.getOtherPaySum().replace(",", ""));
batchPO.setUpdateTime(new Date());
batchPO = SiAccountEncrypt.encryptInsuranceAccountBatch(batchPO);
getInsuranceAccountBatchMapper().updateById(batchPO);
}
}
}
});
}
/**
* 将通过id获取InsuranceAccountDetailPO中的社保公积金其他福利个人和公司缴纳数据
*/
@Override
public Map<String, Object> getPaymentById(Long id) {
InsuranceAccountDetailPO insuranceAccountDetailPO = getInsuranceAccountDetailMapper().getById(id);
if (insuranceAccountDetailPO == null) {
throw new SalaryRunTimeException("该条核算数据不存在!");
}
InsuranceAccountDetailPOEncrypt.decryptItem(insuranceAccountDetailPO);
String socialPerJson = insuranceAccountDetailPO.getSocialPerJson();
String socialComJson = insuranceAccountDetailPO.getSocialComJson();
String fundPerJson = insuranceAccountDetailPO.getFundPerJson();
String fundComJson = insuranceAccountDetailPO.getFundComJson();
String otherPerJson = insuranceAccountDetailPO.getOtherPerJson();
String otherComJson = insuranceAccountDetailPO.getOtherComJson();
Map<String, String> dataMap = new HashMap<>();
List<SearchConditionGroup> addGroups = new ArrayList<>();
getPaymentGroup(socialPerJson, "个人", "社保", dataMap, addGroups);
getPaymentGroup(socialComJson, "公司", "社保", dataMap, addGroups);
getPaymentGroup(fundPerJson, "个人", "公积金", dataMap, addGroups);
getPaymentGroup(fundComJson, "公司", "公积金", dataMap, addGroups);
getPaymentGroup(otherPerJson, "个人", "其他福利", dataMap, addGroups);
getPaymentGroup(otherComJson, "公司", "其他福利", dataMap, addGroups);
Map<String, Object> resultMap = new HashMap<>();
// resultMap.put("data", dataMap);
// resultMap.put("items", addGroups);
List<Map<String, String>> perList = new ArrayList<>();
List<Map<String, String>> comList = new ArrayList<>();
for (SearchConditionGroup group : addGroups) {
if (group.getItems() != null && group.getItems().size() > 0) {
for (SearchConditionItem item : group.getItems()) {
Map<String, String> map = new HashMap<>();
String[] domkey = item.getDomkey();
String insuranceId = domkey[0].substring(3);
if (group.getTitle().contains("个人")) {
map.put("title", group.getTitle());
map.put("paymentScope", "个人");
map.put("insuranceName", item.getLabel());
map.put("insuranceId", insuranceId);
map.put("insuranceValue", dataMap.get(domkey[0]));
perList.add(map);
} else if (group.getTitle().contains("公司")) {
map.put("title", group.getTitle());
map.put("paymentScope", "公司");
map.put("insuranceName", item.getLabel());
map.put("insuranceId", insuranceId);
map.put("insuranceValue", dataMap.get(domkey[0]));
comList.add(map);
}
}
}
}
List<Map<String, String>> resultList = new ArrayList<>();
resultList.addAll(perList);
resultList.addAll(comList);
resultMap.put("data", resultList);
return resultMap;
}
public void getPaymentGroup(String baseJson, String groupType, String welfareType, Map<String, String> dataMap, List<SearchConditionGroup> addGroups) {
if (StringUtils.isBlank(baseJson)) {
addGroups.add(new SearchConditionGroup(welfareType + groupType +"缴纳", true, null));
return;
}
String groupPrefix = "个人".equals(groupType) ? "per" : "com";
Map<String, String> toDealMap = JSON.parseObject(baseJson, new HashMap<String, String>().getClass());
Map<String, String> baseJsonMap = new HashMap<>();
List<SearchConditionItem> inputItems = new ArrayList<>();
for (Map.Entry<String, String> entry : toDealMap.entrySet()) {
//获取福利项信息
ICategoryPO iCategoryPO = siCategoryBiz.getByID(Long.valueOf(entry.getKey()));
if (iCategoryPO != null) {
String name = groupPrefix + iCategoryPO.getId().toString();
String label = iCategoryPO.getInsuranceName();
inputItems.add(SalaryFormItemUtil.inputNumberItem(user, "precision:2", 2, 12, 2, label, name));
}
baseJsonMap.put(groupPrefix + entry.getKey(), entry.getValue());
}
dataMap.putAll(baseJsonMap);
addGroups.add(new SearchConditionGroup(welfareType + groupType +"缴纳", true, inputItems));
}
/**
* 编辑InsuranceAccountDetailPO中的社保公积金其他福利个人和公司缴纳数据
*/
@Override
public void editAccount(EditAccountDetailParam param) {
InsuranceAccountDetailPO insuranceAccountDetailPO = getInsuranceAccountDetailMapper().getById(param.getId());
if (insuranceAccountDetailPO == null) {
throw new SalaryRunTimeException("该条核算数据不存在!");
}
InsuranceAccountDetailPOEncrypt.decryptItem(insuranceAccountDetailPO);
accountSocialByData(insuranceAccountDetailPO, param);
accountFundByData(insuranceAccountDetailPO, param);
accountOtherByData(insuranceAccountDetailPO, param);
account(insuranceAccountDetailPO);
InsuranceAccountDetailPOEncrypt.encryptItem(insuranceAccountDetailPO);
getInsuranceAccountDetailMapper().updateById(insuranceAccountDetailPO);
//刷新_bill_batch表中的统计信息
refreshBillBatch(insuranceAccountDetailPO.getPaymentOrganization(), insuranceAccountDetailPO.getBillMonth());
}
public void accountFundByData(InsuranceAccountDetailPO insuranceAccountDetailPO, EditAccountDetailParam baseParam) {
//公积金个人
if (StringUtils.isNotBlank(baseParam.getFundPerJson())) {
List<BigDecimal> fundPer = new ArrayList<>();
HashMap<String, String> fundPerson = JSON.parseObject(baseParam.getFundPerJson(), new HashMap<String, String>().getClass());
fundPerson.forEach((k, v) -> {
BigDecimal result = new BigDecimal(v);
fundPer.add(result);
});
insuranceAccountDetailPO.setFundPerJson(baseParam.getFundPerJson());
BigDecimal fundPerSum = new BigDecimal("0");
for (BigDecimal bigDecimal : fundPer) {
fundPerSum = fundPerSum.add(bigDecimal);
}
insuranceAccountDetailPO.setFundPerSum(fundPerSum.toPlainString());
}
//公积金单位
if (StringUtils.isNotBlank(baseParam.getFundComJson())) {
List<BigDecimal> fundCom = new ArrayList<>();
HashMap<String, String> fundComMap = JSON.parseObject(baseParam.getFundComJson(), new HashMap<String, String>().getClass());
fundComMap.forEach((k, v) -> {
BigDecimal result = new BigDecimal(v);
fundCom.add(result);
});
insuranceAccountDetailPO.setFundComJson(baseParam.getFundComJson());
BigDecimal fundComSum = new BigDecimal("0");
for (BigDecimal bigDecimal : fundCom) {
fundComSum = fundComSum.add(bigDecimal);
}
insuranceAccountDetailPO.setFundComSum(fundComSum.toPlainString());
}
}
public void accountOtherByData(InsuranceAccountDetailPO insuranceAccountDetailPO, EditAccountDetailParam baseParam) {
//其他福利个人
if (StringUtils.isNotBlank(baseParam.getOtherPerJson())) {
List<BigDecimal> otherPer = new ArrayList<>();
HashMap<String, String> otherPerMap = JSON.parseObject(baseParam.getOtherPerJson(), new HashMap<String, String>().getClass());
otherPerMap.forEach((k, v) -> {
BigDecimal result = new BigDecimal(v);
otherPer.add(result);
});
insuranceAccountDetailPO.setOtherPerJson(baseParam.getOtherPerJson());
BigDecimal otherPerSum = new BigDecimal("0");
for (BigDecimal bigDecimal : otherPer) {
otherPerSum = otherPerSum.add(bigDecimal);
}
insuranceAccountDetailPO.setOtherPerSum(otherPerSum.toPlainString());
}
//其他福利单位
if (StringUtils.isNotBlank(baseParam.getOtherComJson())) {
List<BigDecimal> otherCom = new ArrayList<>();
HashMap<String, String> otherComMap = JSON.parseObject(baseParam.getOtherComJson(), new HashMap<String, String>().getClass());
otherComMap.forEach((k, v) -> {
BigDecimal result = new BigDecimal(v);
otherCom.add(result);
});
insuranceAccountDetailPO.setOtherComJson(baseParam.getOtherComJson());
BigDecimal otherComSum = new BigDecimal("0");
for (BigDecimal bigDecimal : otherCom) {
otherComSum = otherComSum.add(bigDecimal);
}
insuranceAccountDetailPO.setOtherComSum(otherComSum.toPlainString());
}
}
public void accountSocialByData(InsuranceAccountDetailPO insuranceAccountDetailPO, EditAccountDetailParam baseParam) {
//社保个人
if (StringUtils.isNotBlank(baseParam.getSocialPerJson())) {
List<BigDecimal> socialPer = new ArrayList<>();
HashMap<String, String> archivesPerson = JSON.parseObject(baseParam.getSocialPerJson(), new HashMap<String, String>().getClass());
archivesPerson.forEach((k, v) -> {
BigDecimal result = new BigDecimal(v);
socialPer.add(result);
});
insuranceAccountDetailPO.setSocialPerJson(baseParam.getSocialPerJson());
BigDecimal socialPerSum = new BigDecimal("0");
for (BigDecimal bigDecimal : socialPer) {
socialPerSum = socialPerSum.add(bigDecimal);
}
insuranceAccountDetailPO.setSocialPerSum(socialPerSum.toPlainString());
}
//社保单位
if (StringUtils.isNotBlank(baseParam.getSocialComJson())) {
List<BigDecimal> socialCom = new ArrayList<>();
HashMap<String, String> archivesCom = JSON.parseObject(baseParam.getSocialComJson(), new HashMap<String, String>().getClass());
archivesCom.forEach((k, v) -> {
BigDecimal result = new BigDecimal(v);
socialCom.add(result);
});
insuranceAccountDetailPO.setSocialComJson(baseParam.getSocialComJson());
BigDecimal socialComSum = new BigDecimal("0");
for (BigDecimal bigDecimal : socialCom) {
socialComSum = socialComSum.add(bigDecimal);
}
insuranceAccountDetailPO.setSocialComSum(socialComSum.toPlainString());
}
}
public InsuranceAccountDetailPO account(InsuranceAccountDetailPO insuranceAccountDetailPO) {
//个人合计
BigDecimal socialPerson =
StringUtils.isBlank(insuranceAccountDetailPO.getSocialPerSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getSocialPerSum());
BigDecimal fundPerson =
StringUtils.isBlank(insuranceAccountDetailPO.getFundPerSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getFundPerSum());
BigDecimal otherPerson =
StringUtils.isBlank(insuranceAccountDetailPO.getOtherPerSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getOtherPerSum());
BigDecimal perSum = socialPerson.add(fundPerson).add(otherPerson);
insuranceAccountDetailPO.setPerSum(perSum.toPlainString());
//单位合计
BigDecimal socialCom =
StringUtils.isBlank(insuranceAccountDetailPO.getSocialComSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getSocialComSum());
BigDecimal fundCom = StringUtils.isBlank(insuranceAccountDetailPO.getFundComSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getFundComSum());
BigDecimal otherCom =
StringUtils.isBlank(insuranceAccountDetailPO.getOtherComSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getOtherComSum());
BigDecimal comSum = socialCom.add(fundCom).add(otherCom);
insuranceAccountDetailPO.setComSum(comSum.toPlainString());
//社保合计
insuranceAccountDetailPO.setSocialSum(socialPerson.add(socialCom).toPlainString());
//公积金合计
insuranceAccountDetailPO.setFundSum(fundPerson.add(fundCom).toPlainString());
//其他福利合计
insuranceAccountDetailPO.setOtherSum(otherPerson.add(otherCom).toPlainString());
//合计
insuranceAccountDetailPO.setTotal(perSum.add(comSum).toPlainString());
return insuranceAccountDetailPO;
}
}

View File

@ -28,6 +28,7 @@ import com.engine.salary.mapper.sicategory.ICategoryMapper;
import com.engine.salary.mapper.taxagent.TaxAgentMapper;
import com.engine.salary.service.SIExportService;
import com.engine.salary.service.SISchemeService;
import com.engine.salary.service.TaxAgentService;
import com.engine.salary.sys.entity.vo.OrderRuleVO;
import com.engine.salary.sys.service.SalarySysConfService;
import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl;
@ -36,6 +37,7 @@ import com.engine.salary.util.SalaryEnumUtil;
import com.engine.salary.util.SalaryI18nUtil;
import com.engine.salary.util.db.MapperProxyFactory;
import com.engine.salary.util.excel.ExcelUtil;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
@ -84,6 +86,10 @@ public class SIExportServiceImpl extends Service implements SIExportService {
return MapperProxyFactory.getProxy(InsuranceBaseInfoMapper.class);
}
private TaxAgentService getTaxAgentService(User user) {
return ServiceUtil.getService(TaxAgentServiceImpl.class, user);
}
@Override
public XSSFWorkbook exportOverView(InsuranceExportParam queryParam) {
List<InsuranceAccountDetailPO> insuranceAccountDetailPOS = getInsuranceAccountDetailMapper().selectList(queryParam.getBillMonth(), StringUtils.isBlank(queryParam.getPaymentOrganization()) ? null : Long.valueOf(queryParam.getPaymentOrganization()));
@ -137,26 +143,47 @@ public class SIExportServiceImpl extends Service implements SIExportService {
OrderRuleVO orderRule = getSalarySysConfService(user).orderRule();
param.setOrderRule(orderRule);
List<AccountExportPO> accountExportPOS = getInsuranceExportMapper().exportAccount(paymentStatus, param);
List<AccountExportPO> accountExportPOS = new ArrayList<>();
if (paymentStatus.equals(PaymentStatusEnum.RECESSION.getValue())) {
accountExportPOS = getInsuranceExportMapper().exportRecessionAccount(paymentStatus, param);
// 分权逻辑
Boolean needAuth = getTaxAgentService(user).isNeedAuth((long) user.getUID());
if (needAuth) {
Collection<TaxAgentPO> taxAgentPOS = getTaxAgentService(user).listAllTaxAgents((long) user.getUID());
List<Long> taxAgents = taxAgentPOS.stream().map(TaxAgentPO::getId).collect(Collectors.toList());
if (CollectionUtils.isEmpty(taxAgents)) {
//防止普通用户查询
accountExportPOS = new ArrayList<>();
} else {
accountExportPOS.stream().filter(f -> taxAgents.contains(f.getPaymentOrganization())).collect(Collectors.toList());
}
}
} else {
accountExportPOS = getInsuranceExportMapper().exportAccount(paymentStatus, param);
}
//过滤出福利档案基础信息表中runStatus为正在缴纳和待减员的人员
List<InsuranceArchivesBaseInfoPO> baseInfoPOList = getInsuranceBaseInfoMapper().listAll();
List<Long> canAccountIds = baseInfoPOList.stream()
.filter(f->f.getPaymentOrganization().toString().equals(param.getPaymentOrganization())
&& (f.getRunStatus().equals(EmployeeStatusEnum.PAYING.getValue()) || f.getRunStatus().equals(EmployeeStatusEnum.STAY_DEL.getValue())))
.map(InsuranceArchivesBaseInfoPO::getEmployeeId)
.collect(Collectors.toList());
accountExportPOS = accountExportPOS.stream().filter(f -> canAccountIds.contains(f.getEmployeeId())).collect(Collectors.toList());
if (!paymentStatus.equals(PaymentStatusEnum.RECESSION.getValue())) {
List<InsuranceArchivesBaseInfoPO> baseInfoPOList = getInsuranceBaseInfoMapper().listAll();
List<Long> canAccountIds = baseInfoPOList.stream()
.filter(f->f.getPaymentOrganization().toString().equals(param.getPaymentOrganization())
&& (f.getRunStatus().equals(EmployeeStatusEnum.PAYING.getValue()) || f.getRunStatus().equals(EmployeeStatusEnum.STAY_DEL.getValue())))
.map(InsuranceArchivesBaseInfoPO::getEmployeeId)
.collect(Collectors.toList());
accountExportPOS = accountExportPOS.stream().filter(f -> canAccountIds.contains(f.getEmployeeId())).collect(Collectors.toList());
}
AccountExportPOEncrypt.decryptAccountExportPOList(accountExportPOS);
List<WeaTableColumn> columns = new ArrayList<>();
List<Map<String, Object>> records = new ArrayList<>();
if (Objects.equals(PaymentStatusEnum.COMMON.getValue(), paymentStatus)) {
columns = buildCommonColumns(accountExportPOS, false);
}
if (Objects.equals(PaymentStatusEnum.REPAIR.getValue(), paymentStatus)) {
columns = buildCommonColumns(accountExportPOS, true);
}
// if (Objects.equals(PaymentStatusEnum.COMMON.getValue(), paymentStatus)) {
// columns = buildCommonColumns(accountExportPOS, false);
// }
// if (Objects.equals(PaymentStatusEnum.REPAIR.getValue(), paymentStatus)) {
// columns = buildCommonColumns(accountExportPOS, true);
// }
columns = buildCommonColumns(accountExportPOS, paymentStatus);
records = buildCommonRecords(accountExportPOS);
List<List<Object>> excelSheetData = new ArrayList<>();
//工作簿名称
@ -195,7 +222,9 @@ public class SIExportServiceImpl extends Service implements SIExportService {
record.put("employeeStatus", item.getUserStatus() == null ? "" : getDefaultLabelByValue(item.getUserStatus()));
ResourceFromEnum from = SalaryEnumUtil.enumMatchByValue(item.getResourceFrom(), ResourceFromEnum.values(), ResourceFromEnum.class);
record.put("sourceFrom", SalaryI18nUtil.getI18nLabel(from.getLabelId(), from.getDefaultLabel()));
record.put("socialPayOrg", paymentMap.get(item.getSocialPayOrg()) == null ? "" : paymentMap.get(item.getSocialPayOrg()).getName());
record.put("socialPayOrg", paymentMap.get(item.getPaymentOrganization()) == null ? "" : paymentMap.get(item.getPaymentOrganization()).getName());
record.put("socialAccount", item.getSocialAccount());
record.put("socialSchemeName", schemeIdNameMap.get(item.getSocialSchemeId()));
if (StringUtils.isNotEmpty(item.getSocialPaymentBaseString())) {
@ -428,7 +457,7 @@ public class SIExportServiceImpl extends Service implements SIExportService {
}
private List<WeaTableColumn> buildCommonColumns(List<AccountExportPO> pos, boolean flag) {
private List<WeaTableColumn> buildCommonColumns(List<AccountExportPO> pos, Integer paymentStatus) {
List<WeaTableColumn> list = new ArrayList<>();
Map<String, String> categoryIdNameMap = categoryIdNameMap();
Map<Integer, Map<String, String>> columns = buildPaymentTitle(pos, categoryIdNameMap);
@ -440,8 +469,10 @@ public class SIExportServiceImpl extends Service implements SIExportService {
list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(86317, "工号"), "workcode"));
list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(86187, "员工状态"), "employeeStatus"));
list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(100377, "数据来源"), "sourceFrom"));
if (flag) {
if (paymentStatus.equals(PaymentStatusEnum.REPAIR.getValue())) {
list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(100379, "补缴月份"), "supplementaryMonth"));
} else if (paymentStatus.equals(PaymentStatusEnum.RECESSION.getValue())) {
list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(100379, "退差月份"), "supplementaryMonth"));
}
list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(91325, "个税扣缴义务人"), "socialPayOrg"));
list.add(new WeaTableColumn("150px", SalaryI18nUtil.getI18nLabel(91324, "社保账号"), "socialAccount"));

View File

@ -0,0 +1,372 @@
package com.engine.salary.service.impl;
import com.alibaba.fastjson.JSON;
import com.api.formmode.mybatis.util.SqlProxyHandle;
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.InsuranceAccountDetailParam;
import com.engine.salary.entity.siaccount.param.RecessionParam;
import com.engine.salary.entity.siaccount.po.InsuranceAccountBatchPO;
import com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO;
import com.engine.salary.entity.taxagent.dto.TaxAgentEmployeeDTO;
import com.engine.salary.enums.siaccount.BillStatusEnum;
import com.engine.salary.enums.siaccount.PaymentStatusEnum;
import com.engine.salary.enums.siaccount.ProjectTypeEnum;
import com.engine.salary.enums.sicategory.DeleteTypeEnum;
import com.engine.salary.mapper.datacollection.EmployMapper;
import com.engine.salary.mapper.siaccount.InsuranceAccountBatchMapper;
import com.engine.salary.mapper.siaccount.InsuranceAccountDetailMapper;
import com.engine.salary.service.SIAccountService;
import com.engine.salary.service.SIRecessionService;
import com.engine.salary.service.TaxAgentService;
import com.engine.salary.util.SalaryEntityUtil;
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 org.apache.commons.lang3.StringUtils;
import org.apache.commons.collections4.CollectionUtils;
import com.engine.salary.exception.SalaryRunTimeException;
import com.engine.salary.util.SalaryI18nUtil;
import com.engine.salary.util.SalaryAssert;
import weaver.hrm.User;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
/**
* @Author: sy
* @Description: 社保福利台账-退差实现类
* @Date: 2022/11/15
**/
public class SIRecessionServiceImpl extends Service implements SIRecessionService {
private InsuranceAccountDetailMapper getInsuranceAccountDetailMapper() {
return SqlProxyHandle.getProxy(InsuranceAccountDetailMapper.class);
}
private TaxAgentService getTaxAgentService(User user) {
return ServiceUtil.getService(TaxAgentServiceImpl.class, user);
}
private EmployMapper getEmployMapper() {
return MapperProxyFactory.getProxy(EmployMapper.class);
}
private SIAccountService getSIAccountService(User user) {
return ServiceUtil.getService(SIAccountServiceImpl.class, user);
}
private InsuranceAccountBatchMapper getInsuranceAccountBatchMapper() {
return MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class);
}
@Override
public void save(RecessionParam param, Long employeeId) {
//入参判断
if (StringUtils.isBlank(param.getPaymentOrganization()) || StringUtils.isBlank(param.getBillMonth()) || CollectionUtils.isEmpty(param.getRecessionMonthList())
|| CollectionUtils.isEmpty(param.getIncludes()) || CollectionUtils.isEmpty(param.getProjects())) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误"));
}
//需要退差的员工
List<Long> employeeIds = param.getIncludes();
if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(param.getExcludes())) {
employeeIds = employeeIds.stream().filter(item -> !param.getExcludes().contains(item)).collect(Collectors.toList());
}
SalaryAssert.notEmpty(employeeIds, SalaryI18nUtil.getI18nLabel(133967, "无退差人员"));
//查询退差员工对应的退差月份的正常缴纳的福利台账数据
List<InsuranceAccountDetailPO> detailPOS = new ArrayList<>();
List<List<Long>> partitionEmpIds = Lists.partition((List<Long>) employeeIds, 100);
partitionEmpIds.forEach(p -> {
detailPOS.addAll(
getInsuranceAccountDetailMapper().list(InsuranceAccountDetailParam.builder()
.paymentStatus(PaymentStatusEnum.COMMON.getValue())
.recessionMonthList(param.getRecessionMonthList())
.employeeIds(p)
.paymentOrganization(param.getPaymentOrganization())
.build())
);
});
InsuranceAccountDetailPOEncrypt.decryptInsuranceAccountDetailPOList(detailPOS);
//处理数据
List<InsuranceAccountDetailPO> finalDetailPOS = detailPOS;
List<InsuranceAccountDetailPO> finalRecessionDetails = new ArrayList<>();
employeeIds.forEach(id -> {
param.getRecessionMonthList().forEach(billMonth -> {
Optional<InsuranceAccountDetailPO> detailPOOptional = finalDetailPOS.stream().filter(
detail -> Objects.equals(billMonth, detail.getBillMonth())
&& Objects.equals(id, detail.getEmployeeId())).findFirst();
detailPOOptional.ifPresent(insuranceAccountDetailPO -> recessionAccount(param, insuranceAccountDetailPO, finalRecessionDetails));
});
});
//退差数据入库
if (CollectionUtils.isNotEmpty(finalRecessionDetails)) {
InsuranceAccountDetailPOEncrypt.encryptInsuranceAccountDetailPOList(finalRecessionDetails);
//删除已有退差记录
finalRecessionDetails.forEach(getInsuranceAccountDetailMapper()::deleteRecessionData);
//入库新数据
List<List<InsuranceAccountDetailPO>> partition = Lists.partition((List<InsuranceAccountDetailPO>) finalRecessionDetails, 20);
partition.forEach(getInsuranceAccountDetailMapper()::batchSaveAccountDetails);
//刷新bill_batch表中统计信息
getSIAccountService(user).refreshBillBatch(Long.valueOf(param.getPaymentOrganization()), param.getBillMonth());
}
}
@Override
public void del(Collection<Long> ids, Long employeeId) {
//入参判断
if (CollectionUtils.isEmpty(ids)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误"));
}
InsuranceAccountDetailPO refreshTargetPO = getInsuranceAccountDetailMapper().getById(((List<Long>) ids).get(0));
//根据id删除
List<List<Long>> partition = Lists.partition((List<Long>) ids, 100);
partition.forEach(getInsuranceAccountDetailMapper()::batchDelAccountDetailsByIds);
//刷新bill_batch表中统计信息
getSIAccountService(user).refreshBillBatch(refreshTargetPO.getPaymentOrganization(), refreshTargetPO.getBillMonth());
}
private void recessionAccount(RecessionParam param, InsuranceAccountDetailPO insuranceAccountDetailPO, List<InsuranceAccountDetailPO> recessionDetails) {
List<Integer> projects = param.getProjects();
InsuranceAccountDetailPO temp = new InsuranceAccountDetailPO();
recessionBaseBuild(param, temp, insuranceAccountDetailPO);
if (projects.contains(ProjectTypeEnum.ALL.getValue())) {
recessionSocial(param, temp, insuranceAccountDetailPO);
recessionFund(param, temp, insuranceAccountDetailPO);
recessionOther(param, temp, insuranceAccountDetailPO);
}
if (projects.contains(ProjectTypeEnum.SOCIAL.getValue())) {
recessionSocial(param, temp, insuranceAccountDetailPO);
}
if (projects.contains(ProjectTypeEnum.FUND.getValue())) {
recessionFund(param, temp, insuranceAccountDetailPO);
}
if (projects.contains(ProjectTypeEnum.OTHER.getValue())) {
recessionOther(param, temp, insuranceAccountDetailPO);
}
account(temp);
recessionDetails.add(temp);
}
private void recessionBaseBuild(RecessionParam param, InsuranceAccountDetailPO temp, InsuranceAccountDetailPO insuranceAccountDetailPO) {
InsuranceAccountBatchPO insuranceAccountBatchPO = getInsuranceAccountBatchMapper().getByBillMonth(param.getBillMonth(), Long.valueOf(param.getPaymentOrganization()));
temp.setPaymentStatus(PaymentStatusEnum.RECESSION.getValue());
// temp.setId(IdGenerator.generate());
temp.setCreateTime(new Date());
temp.setUpdateTime(new Date());
temp.setCreator(insuranceAccountBatchPO.getCreator());
temp.setSocialPayOrg(insuranceAccountDetailPO.getPaymentOrganization());
temp.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue());
temp.setTenantKey(insuranceAccountDetailPO.getTenantKey());
temp.setEmployeeId(insuranceAccountDetailPO.getEmployeeId());
temp.setBillMonth(param.getBillMonth());
temp.setBillStatus(BillStatusEnum.NOT_ARCHIVED.getValue());
temp.setSupplementaryMonth(insuranceAccountDetailPO.getBillMonth());
temp.setSupplementaryProjects(String.join(",",
param.getProjects() == null ? new ArrayList<>() : param.getProjects().stream().map(String::valueOf).collect(Collectors.toList())));
temp.setResourceFrom(insuranceAccountDetailPO.getResourceFrom());
temp.setSocialAccount(insuranceAccountDetailPO.getSocialAccount());
temp.setSocialSchemeId(insuranceAccountDetailPO.getSocialSchemeId());
temp.setSocialPaymentBaseString(insuranceAccountDetailPO.getSocialPaymentBaseString());
temp.setFundAccount(insuranceAccountDetailPO.getFundAccount());
temp.setSupplementFundAccount(insuranceAccountDetailPO.getSupplementFundAccount());
temp.setFundSchemeId(insuranceAccountDetailPO.getFundSchemeId());
temp.setFundPaymentBaseString(insuranceAccountDetailPO.getFundPaymentBaseString());
temp.setOtherSchemeId(insuranceAccountDetailPO.getOtherSchemeId());
temp.setOtherPaymentBaseString(insuranceAccountDetailPO.getOtherPaymentBaseString());
// temp.setExternalFlag(insuranceAccountDetailPO.getExternalFlag());
temp.setPaymentOrganization(insuranceAccountDetailPO.getPaymentOrganization());
// temp.setPaymentAgency(insuranceAccountDetailPO.getPaymentAgency());
}
private void recessionSocial(RecessionParam param, InsuranceAccountDetailPO temp, InsuranceAccountDetailPO insuranceAccountDetailPO) {
//退差社保个人缴费
String socialPerJson = insuranceAccountDetailPO.getSocialPerJson();
if (StringUtils.isNotBlank(socialPerJson)) {
HashMap<String, String> jsonMap = new HashMap<>();
HashMap<String, String> hashMap = JSON.parseObject(socialPerJson, new HashMap<String, String>().getClass());
hashMap.forEach((k, v) -> {
if (StringUtils.isNotBlank(v)) {
v = new BigDecimal(v).negate().toPlainString();
jsonMap.put(k, v);
}
});
temp.setSocialPerJson(JSON.toJSONString(jsonMap));
}
if (StringUtils.isNotBlank(insuranceAccountDetailPO.getSocialPerSum())) {
temp.setSocialPerSum(new BigDecimal(insuranceAccountDetailPO.getSocialPerSum()).negate().toPlainString());
}
//退差社保单位缴费
String socialComJson = insuranceAccountDetailPO.getSocialComJson();
if (StringUtils.isNotBlank(socialComJson)) {
HashMap<String, String> jsonMap = new HashMap<>();
HashMap<String, String> hashMap = JSON.parseObject(socialPerJson, new HashMap<String, String>().getClass());
hashMap.forEach((k, v) -> {
if (StringUtils.isNotBlank(v)) {
v = new BigDecimal(v).negate().toPlainString();
jsonMap.put(k, v);
}
});
temp.setSocialComJson(JSON.toJSONString(jsonMap));
}
if (StringUtils.isNotBlank(insuranceAccountDetailPO.getSocialComSum())) {
temp.setSocialComSum(new BigDecimal(insuranceAccountDetailPO.getSocialComSum()).negate().toPlainString());
}
}
private void recessionFund(RecessionParam param, InsuranceAccountDetailPO temp, InsuranceAccountDetailPO insuranceAccountDetailPO) {
//退差公积金个人缴费
String fundPerJson = insuranceAccountDetailPO.getFundPerJson();
if (StringUtils.isNotBlank(fundPerJson)) {
HashMap<String, String> jsonMap = new HashMap<>();
HashMap<String, String> hashMap = JSON.parseObject(fundPerJson, new HashMap<String, String>().getClass());
hashMap.forEach((k, v) -> {
if (StringUtils.isNotBlank(v)) {
v = new BigDecimal(v).negate().toPlainString();
jsonMap.put(k, v);
}
});
temp.setFundPerJson(JSON.toJSONString(jsonMap));
}
if (StringUtils.isNotBlank(insuranceAccountDetailPO.getFundPerSum())) {
temp.setFundPerSum(new BigDecimal(insuranceAccountDetailPO.getFundPerSum()).negate().toPlainString());
}
//退差公积金单位缴费
String fundComJson = insuranceAccountDetailPO.getFundComJson();
if (StringUtils.isNotBlank(fundComJson)) {
HashMap<String, String> jsonMap = new HashMap<>();
HashMap<String, String> hashMap = JSON.parseObject(fundPerJson, new HashMap<String, String>().getClass());
hashMap.forEach((k, v) -> {
if (StringUtils.isNotBlank(v)) {
v = new BigDecimal(v).negate().toPlainString();
jsonMap.put(k, v);
}
});
temp.setFundComJson(JSON.toJSONString(jsonMap));
}
if (StringUtils.isNotBlank(insuranceAccountDetailPO.getFundComSum())) {
temp.setFundComSum(new BigDecimal(insuranceAccountDetailPO.getFundComSum()).negate().toPlainString());
}
}
private void recessionOther(RecessionParam param, InsuranceAccountDetailPO temp, InsuranceAccountDetailPO insuranceAccountDetailPO) {
//退差其他福利个人缴费
String otherPerJson = insuranceAccountDetailPO.getOtherPerJson();
if (StringUtils.isNotBlank(otherPerJson)) {
HashMap<String, String> jsonMap = new HashMap<>();
HashMap<String, String> hashMap = JSON.parseObject(otherPerJson, new HashMap<String, String>().getClass());
hashMap.forEach((k, v) -> {
if (StringUtils.isNotBlank(v)) {
v = new BigDecimal(v).negate().toPlainString();
jsonMap.put(k, v);
}
});
temp.setOtherPerJson(JSON.toJSONString(jsonMap));
}
if (StringUtils.isNotBlank(insuranceAccountDetailPO.getOtherPerSum())) {
temp.setOtherPerSum(new BigDecimal(insuranceAccountDetailPO.getOtherPerSum()).negate().toPlainString());
}
//退差其他福利单位缴费
String otherComJson = insuranceAccountDetailPO.getOtherComJson();
if (StringUtils.isNotBlank(otherComJson)) {
HashMap<String, String> jsonMap = new HashMap<>();
HashMap<String, String> hashMap = JSON.parseObject(otherPerJson, new HashMap<String, String>().getClass());
hashMap.forEach((k, v) -> {
if (StringUtils.isNotBlank(v)) {
v = new BigDecimal(v).negate().toPlainString();
jsonMap.put(k, v);
}
});
temp.setOtherComJson(JSON.toJSONString(jsonMap));
}
if (StringUtils.isNotBlank(insuranceAccountDetailPO.getOtherComSum())) {
temp.setOtherComSum(new BigDecimal(insuranceAccountDetailPO.getOtherComSum()).negate().toPlainString());
}
}
private void account(InsuranceAccountDetailPO insuranceAccountDetailPO) {
//个人合计
BigDecimal socialPerson =
StringUtils.isBlank(insuranceAccountDetailPO.getSocialPerSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getSocialPerSum());
BigDecimal fundPerson =
StringUtils.isBlank(insuranceAccountDetailPO.getFundPerSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getFundPerSum());
BigDecimal otherPerson =
StringUtils.isBlank(insuranceAccountDetailPO.getOtherPerSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getOtherPerSum());
BigDecimal perSum = socialPerson.add(fundPerson).add(otherPerson);
insuranceAccountDetailPO.setPerSum(perSum.toPlainString());
//单位合计
BigDecimal socialCom =
StringUtils.isBlank(insuranceAccountDetailPO.getSocialComSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getSocialComSum());
BigDecimal fundCom = StringUtils.isBlank(insuranceAccountDetailPO.getFundComSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getFundComSum());
BigDecimal otherCom =
StringUtils.isBlank(insuranceAccountDetailPO.getOtherComSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getOtherComSum());
BigDecimal comSum = socialCom.add(fundCom).add(otherCom);
insuranceAccountDetailPO.setComSum(comSum.toPlainString());
//社保合计
insuranceAccountDetailPO.setSocialSum(socialPerson.add(socialCom).toPlainString());
//公积金合计
insuranceAccountDetailPO.setFundSum(fundPerson.add(fundCom).toPlainString());
//其他福利合计
insuranceAccountDetailPO.setOtherSum(otherPerson.add(otherCom).toPlainString());
//合计
insuranceAccountDetailPO.setTotal(perSum.add(comSum).toPlainString());
}
/**
* 获取当前登录人所控制的个税扣缴义务人的人员范围
*/
@Override
public PageInfo<HrmInfoDTO> getEmployeeListByTaxAgent(HrmQueryParam param) {
// 当前登录人员
Long currentEmployeeId = (long) user.getUID();
List<TaxAgentEmployeeDTO> taxAgentEmployeeDTOS = getTaxAgentService(user).listTaxAgentAndEmployee(currentEmployeeId);
Set<Long> employeeIds = SalaryEntityUtil.properties(taxAgentEmployeeDTOS, TaxAgentEmployeeDTO::getEmployeeId);
List<Long> empIds = new ArrayList<Long>(employeeIds);
List<HrmInfoDTO> resultData = new ArrayList<>();
if (employeeIds.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<>();
if (null == resultData) {
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;
}
}

View File

@ -17,8 +17,8 @@ import com.engine.salary.encrypt.siarchives.InsuranceArchivesOtherSchemePOEncryp
import com.engine.salary.encrypt.siarchives.InsuranceArchivesSocialSchemePOEncrypt;
import com.engine.salary.encrypt.sischeme.InsuranceSchemeDetailPOEncrypt;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.salaryarchive.po.SalaryArchivePO;
import com.engine.salary.entity.siarchives.param.InsuranceArchivesListParam;
import com.engine.salary.entity.siarchives.param.SIArchiveImportActionParam;
import com.engine.salary.entity.siarchives.po.*;
import com.engine.salary.entity.sicategory.po.ICategoryPO;
import com.engine.salary.entity.sischeme.dto.InsuranceSchemeListDTO;
@ -64,11 +64,11 @@ import org.apache.commons.lang3.math.NumberUtils;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.util.IOUtils;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.xpath.operations.Bool;
import weaver.file.ImageFileManager;
import weaver.hrm.User;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
@ -713,26 +713,55 @@ public class SISchemeServiceImpl extends Service implements SISchemeService {
public boolean singleAccountCheck(List<Map<String, Object>> singleAccount, Map<Long, String> welfareMap, List<InsuranceArchivesAccountPO> insuranceArchivesAccountPOS, List<DataCollectionEmployee> employeeByIds, List<Map<String, String>> excelComments, int i, Map<String, Long> schemeNameIdMap, Map<String, Long> paymentNameIdMap, Long creator, int index, Boolean openDevolution, List<TaxAgentManageRangeEmployeeDTO> taxAgentManageRangeEmployeeTree, String runStatus) {
boolean isError = false;
String userName = (String) singleAccount.get(0).get(SalaryI18nUtil.getI18nLabel(85429, "姓名"));
String deparmentName = (String) singleAccount.get(1).get(SalaryI18nUtil.getI18nLabel(86185, "部门"));
String mobile = (String) singleAccount.get(2).get(SalaryI18nUtil.getI18nLabel(86186, "手机号"));
String userStatus = (String) singleAccount.get(3).get(SalaryI18nUtil.getI18nLabel(86187, "员工状态"));
String workcode = (String) singleAccount.get(4).get(SalaryI18nUtil.getI18nLabel(86317, "工号"));
// String userName = (String) singleAccount.get(0).get(SalaryI18nUtil.getI18nLabel(85429, "姓名"));
// String deparmentName = (String) singleAccount.get(1).get(SalaryI18nUtil.getI18nLabel(86185, "部门"));
// String mobile = (String) singleAccount.get(2).get(SalaryI18nUtil.getI18nLabel(86186, "手机号"));
// String userStatus = (String) singleAccount.get(3).get(SalaryI18nUtil.getI18nLabel(86187, "员工状态"));
// String workcode = (String) singleAccount.get(4).get(SalaryI18nUtil.getI18nLabel(86317, "工号"));
Map<String, Object> userNameMap = findElement(singleAccount, SalaryI18nUtil.getI18nLabel(85429, "姓名"));
Map<String, Object> deparmentNameMap = findElement(singleAccount, SalaryI18nUtil.getI18nLabel(86185, "部门"));
Map<String, Object> mobileMap = findElement(singleAccount, SalaryI18nUtil.getI18nLabel(86186, "手机号"));
Map<String, Object> userStatusMap = findElement(singleAccount, SalaryI18nUtil.getI18nLabel(86187, "员工状态"));
Map<String, Object> workcodeMap = findElement(singleAccount, SalaryI18nUtil.getI18nLabel(86317, "工号"));
Map<String, Object> employeeIdMap = findElement(singleAccount, SalaryI18nUtil.getI18nLabel(86187, "员工id"));
String userName = (String) userNameMap.get(SalaryI18nUtil.getI18nLabel(85429, "姓名"));
String deparmentName = (String) deparmentNameMap.get(SalaryI18nUtil.getI18nLabel(86185, "部门"));
String mobile = (String) mobileMap.get(SalaryI18nUtil.getI18nLabel(86186, "手机号"));
String userStatus = (String) userStatusMap.get(SalaryI18nUtil.getI18nLabel(86187, "员工状态"));
String workcode = (String) workcodeMap.get(SalaryI18nUtil.getI18nLabel(86317, "工号"));
String toAddEmployeeId;
if (employeeIdMap.isEmpty()) {
toAddEmployeeId = null;
} else {
toAddEmployeeId = employeeIdMap.get(SalaryI18nUtil.getI18nLabel(86187, "员工id")).toString();
}
Long addEmployeeId = StringUtils.isNotBlank(toAddEmployeeId) ? Long.valueOf(toAddEmployeeId) : null;
//查询对于人员信息导入筛选的全局配置
SalarySysConfPO salarySysConfPO = getSalarySysConfMapper().getOneByCode("matchEmployeeMode");
String confValue = (salarySysConfPO != null && salarySysConfPO.getConfValue() != null && !"".equals(salarySysConfPO.getConfValue())) ? salarySysConfPO.getConfValue() : "0";
String rowIndex = "" + index + "";
//仅在全局人员筛选配置为0才对用户名部门名称手机号有要求
if (StringUtils.isBlank(userName) && StringUtils.isBlank(deparmentName) && StringUtils.isBlank(mobile) && "0".equals(confValue)) {
Map<String, String> errorMessageMap = Maps.newHashMap();
errorMessageMap.put("message", rowIndex + " 用户名、部门名称、手机号" + SalaryI18nUtil.getI18nLabel(100303, "不能同时为空"));
excelComments.add(errorMessageMap);
isError = true;
List<DataCollectionEmployee> employees = new ArrayList<>();
//当新增数据中包含员工id信息时直接根据员工id获取员工信息
if (addEmployeeId == null) {
//仅在全局人员筛选配置为0才对用户名部门名称手机号有要求
if (StringUtils.isBlank(userName) && StringUtils.isBlank(deparmentName) && StringUtils.isBlank(mobile) && "0".equals(confValue)) {
Map<String, String> errorMessageMap = Maps.newHashMap();
errorMessageMap.put("message", rowIndex + " 用户名、部门名称、手机号" + SalaryI18nUtil.getI18nLabel(100303, "不能同时为空"));
excelComments.add(errorMessageMap);
isError = true;
}
//筛选导入人员信息可以在人力资源池中匹配到的人员信息
employees = getSalaryEmployeeService(user).matchImportEmployee(employeeByIds, userName, deparmentName, mobile, workcode, null);
} else {
employees = employeeByIds.stream().filter(f -> f.getEmployeeId().equals(addEmployeeId)).collect(Collectors.toList());
}
//筛选导入人员信息可以在人力资源池中匹配到的人员信息
List<DataCollectionEmployee> employees = getSalaryEmployeeService(user).matchImportEmployee(employeeByIds, userName, deparmentName, mobile, workcode, null);
if (CollectionUtils.isEmpty(employees)) {
Map<String, String> errorMessageMap = Maps.newHashMap();
@ -830,67 +859,67 @@ public class SISchemeServiceImpl extends Service implements SISchemeService {
String socialStartMonth = (String) socialStartTimeMap.get(SalaryI18nUtil.getI18nLabel(91319, "社保起始缴纳月"));
// if (StringUtils.isNotBlank(socialStartMonth) && socialStartMonth.length() > 7) {
// socialStartMonth = socialStartMonth.substring(0, 7);
// }
if (StringUtils.isNotBlank(socialStartMonth) && (!SalaryDateUtil.checkYearMonth(socialStartMonth) || socialStartMonth.length() != 7)) {
if (StringUtils.isNotBlank(socialStartMonth) && socialStartMonth.length() > 7) {
socialStartMonth = socialStartMonth.substring(0, 7);
}
if (StringUtils.isNotBlank(socialStartMonth) && !SalaryDateUtil.checkYearMonth(socialStartMonth)) {
Map<String, String> errorMessageMap = Maps.newHashMap();
errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100315, "社保起始缴纳时间格式错误,正确格式为YYYY-MM"));
errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100315, "社保起始缴纳时间格式错误,正确格式为YYYY-MM或者yyyy-MM-dd"));
excelComments.add(errorMessageMap);
isError = true;
}
String socialEndMonth = (String) socialEndTimeMap.get(SalaryI18nUtil.getI18nLabel(91320, "社保最后缴纳月"));
// if (StringUtils.isNotBlank(socialEndMonth) && socialEndMonth.length() > 7) {
// socialEndMonth = socialEndMonth.substring(0, 7);
// }
if (StringUtils.isNotBlank(socialEndMonth) && (!SalaryDateUtil.checkYearMonth(socialEndMonth) || socialEndMonth.length() != 7)) {
if (StringUtils.isNotBlank(socialEndMonth) && socialEndMonth.length() > 7) {
socialEndMonth = socialEndMonth.substring(0, 7);
}
if (StringUtils.isNotBlank(socialEndMonth) && !SalaryDateUtil.checkYearMonth(socialEndMonth)) {
Map<String, String> errorMessageMap = Maps.newHashMap();
errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100316, "社保最后缴纳时间格式错误,正确格式为YYYY-MM"));
errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100316, "社保最后缴纳时间格式错误,正确格式为YYYY-MM或者yyyy-MM-dd"));
excelComments.add(errorMessageMap);
isError = true;
}
String fundStartMonth = (String) fundStartTimeMap.get(SalaryI18nUtil.getI18nLabel(91483, "公积金起始缴纳月"));
// if (StringUtils.isNotBlank(fundStartMonth) && fundStartMonth.length() > 7) {
// fundStartMonth = fundStartMonth.substring(0, 7);
// }
if (StringUtils.isNotBlank(fundStartMonth) && (!SalaryDateUtil.checkYearMonth(fundStartMonth) || fundStartMonth.length() != 7)) {
if (StringUtils.isNotBlank(fundStartMonth) && fundStartMonth.length() > 7) {
fundStartMonth = fundStartMonth.substring(0, 7);
}
if (StringUtils.isNotBlank(fundStartMonth) && !SalaryDateUtil.checkYearMonth(fundStartMonth)) {
Map<String, String> errorMessageMap = Maps.newHashMap();
errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100317, "公积金起始缴纳时间格式错误,正确格式为YYYY-MM"));
errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100317, "公积金起始缴纳时间格式错误,正确格式为YYYY-MM或者yyyy-MM-dd"));
excelComments.add(errorMessageMap);
isError = true;
}
String fundEndMonth = (String) fundEndTimeMap.get(SalaryI18nUtil.getI18nLabel(91484, "公积金最后缴纳月"));
// if (StringUtils.isNotBlank(fundEndMonth) && fundEndMonth.length() > 7) {
// fundEndMonth = fundEndMonth.substring(0, 7);
// }
if (StringUtils.isNotBlank(fundEndMonth) && (!SalaryDateUtil.checkYearMonth(fundEndMonth) || fundEndMonth.length() != 7)) {
if (StringUtils.isNotBlank(fundEndMonth) && fundEndMonth.length() > 7) {
fundEndMonth = fundEndMonth.substring(0, 7);
}
if (StringUtils.isNotBlank(fundEndMonth) && !SalaryDateUtil.checkYearMonth(fundEndMonth)) {
Map<String, String> errorMessageMap = Maps.newHashMap();
errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100319, "公积金最后缴纳时间格式错误,正确格式为YYYY-MM"));
errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100319, "公积金最后缴纳时间格式错误,正确格式为YYYY-MM或者yyyy-MM-dd"));
excelComments.add(errorMessageMap);
isError = true;
}
String otherStartMonth = (String) otherStartTimeMap.get(SalaryI18nUtil.getI18nLabel(91490, "其他福利起始缴纳月"));
// if (StringUtils.isNotBlank(otherStartMonth) && otherStartMonth.length() > 7) {
// otherStartMonth = otherStartMonth.substring(0, 7);
// }
if (StringUtils.isNotBlank(otherStartMonth) && (!SalaryDateUtil.checkYearMonth(otherStartMonth) || otherStartMonth.length() != 7)) {
if (StringUtils.isNotBlank(otherStartMonth) && otherStartMonth.length() > 7) {
otherStartMonth = otherStartMonth.substring(0, 7);
}
if (StringUtils.isNotBlank(otherStartMonth) && !SalaryDateUtil.checkYearMonth(otherStartMonth)) {
Map<String, String> errorMessageMap = Maps.newHashMap();
errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100320, "其他福利起始缴纳时间格式错误,正确格式为YYYY-MM"));
errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100320, "其他福利起始缴纳时间格式错误,正确格式为YYYY-MM或者yyyy-MM-dd"));
excelComments.add(errorMessageMap);
isError = true;
}
String otherEndMonth = (String) otherEndTimeMap.get(SalaryI18nUtil.getI18nLabel(91494, "其他福利最后缴纳月"));
// if (StringUtils.isNotBlank(otherEndMonth) && otherEndMonth.length() > 7) {
// otherEndMonth = otherEndMonth.substring(0, 7);
// }
if (StringUtils.isNotBlank(otherEndMonth) && (!SalaryDateUtil.checkYearMonth(otherEndMonth) || otherEndMonth.length() != 7)) {
if (StringUtils.isNotBlank(otherEndMonth) && otherEndMonth.length() > 7) {
otherEndMonth = otherEndMonth.substring(0, 7);
}
if (StringUtils.isNotBlank(otherEndMonth) && !SalaryDateUtil.checkYearMonth(otherEndMonth)) {
Map<String, String> errorMessageMap = Maps.newHashMap();
errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100321, "其他福利最后缴纳时间格式错误,正确格式为YYYY-MM"));
errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100321, "其他福利最后缴纳时间格式错误,正确格式为YYYY-MM或者yyyy-MM-dd"));
excelComments.add(errorMessageMap);
isError = true;
}
@ -908,7 +937,12 @@ public class SISchemeServiceImpl extends Service implements SISchemeService {
excelComments.add(errorMessageMap);
isError = true;
} else {
} else if (StringUtils.isNotBlank((String) socialMap.get(SalaryI18nUtil.getI18nLabel(91323, "社保方案名称"))) && StringUtils.isBlank(socialStartMonth)) {
Map<String, String> errorMessageMap = Maps.newHashMap();
errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100322, "社保方案已设置,但未设置社保起始缴纳时间!"));
excelComments.add(errorMessageMap);
isError = true;
}else {
insuranceArchivesSocialSchemePO = buildSocialPO(employeeId, welfareMap, singleAccount, schemeNameIdMap, paymentNameIdMap, creator);
}
if (StringUtils.isNotBlank((String) fundMap.get(SalaryI18nUtil.getI18nLabel(91485, "公积金方案名称"))) && schemeNameIdMap.get((String) fundMap.get(SalaryI18nUtil.getI18nLabel(91485, "公积金方案名称"))) == null) {
@ -925,7 +959,12 @@ public class SISchemeServiceImpl extends Service implements SISchemeService {
excelComments.add(errorMessageMap);
isError = true;
}else {
} else if (StringUtils.isNotBlank((String) fundMap.get(SalaryI18nUtil.getI18nLabel(91485, "公积金方案名称"))) && StringUtils.isBlank(fundStartMonth)) {
Map<String, String> errorMessageMap = Maps.newHashMap();
errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100322, "公积金方案已设置,但未设置公积金起始缴纳时间!"));
excelComments.add(errorMessageMap);
isError = true;
} else {
insuranceArchivesFundSchemePO = buildFundPO(employeeId, welfareMap, singleAccount, schemeNameIdMap, paymentNameIdMap, creator);
}
if (StringUtils.isNotBlank((String) otherMap.get(SalaryI18nUtil.getI18nLabel(91496, "其他福利方案名称"))) && schemeNameIdMap.get((String) otherMap.get(SalaryI18nUtil.getI18nLabel(91496, "其他福利方案名称"))) == null) {
@ -941,7 +980,12 @@ public class SISchemeServiceImpl extends Service implements SISchemeService {
errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100322, "其他福利方案不属于其他福利类型"));
excelComments.add(errorMessageMap);
isError = true;
}else {
} else if (StringUtils.isNotBlank((String) otherMap.get(SalaryI18nUtil.getI18nLabel(91496, "其他福利方案名称"))) && StringUtils.isBlank(otherStartMonth)) {
Map<String, String> errorMessageMap = Maps.newHashMap();
errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100322, "其他福利方案已设置,但未设置其他福利起始缴纳时间!"));
excelComments.add(errorMessageMap);
isError = true;
} else {
insuranceArchivesOtherSchemePO = buildOtherPO(employeeId, welfareMap, singleAccount, schemeNameIdMap, paymentNameIdMap, creator);
}
/**************校验申报基数**************/
@ -1045,7 +1089,8 @@ public class SISchemeServiceImpl extends Service implements SISchemeService {
continue;
}
if (findElement(singleAccount, welfareMap.get(insuranceId) + SalaryI18nUtil.getI18nLabel(100293, "申报基数")) != null) {
socialPaymentBase.put(String.valueOf(insuranceId), (String) findElement(singleAccount, welfareMap.get(insuranceId) + SalaryI18nUtil.getI18nLabel(100293, "申报基数")).get(welfareMap.get(insuranceId) + SalaryI18nUtil.getI18nLabel(100293, "申报基数")));
String itemValue = (String) findElement(singleAccount, welfareMap.get(insuranceId) + SalaryI18nUtil.getI18nLabel(100293, "申报基数")).get(welfareMap.get(insuranceId) + SalaryI18nUtil.getI18nLabel(100293, "申报基数"));
socialPaymentBase.put(String.valueOf(insuranceId), StringUtils.isBlank(itemValue) ? "0" : itemValue);
}
}
insuranceArchivesSocialSchemePO.setSocialPaymentBaseString(JSON.toJSONString(socialPaymentBase));
@ -1096,7 +1141,8 @@ public class SISchemeServiceImpl extends Service implements SISchemeService {
continue;
}
if (findElement(singleAccount, welfareMap.get(insuranceId) + SalaryI18nUtil.getI18nLabel(100293, "申报基数")) != null) {
socialPaymentBase.put(String.valueOf(insuranceId), (String) findElement(singleAccount, welfareMap.get(insuranceId) + SalaryI18nUtil.getI18nLabel(100293, "申报基数")).get(welfareMap.get(insuranceId) + SalaryI18nUtil.getI18nLabel(100293, "申报基数")));
String itemValue = (String) findElement(singleAccount, welfareMap.get(insuranceId) + SalaryI18nUtil.getI18nLabel(100293, "申报基数")).get(welfareMap.get(insuranceId) + SalaryI18nUtil.getI18nLabel(100293, "申报基数"));
socialPaymentBase.put(String.valueOf(insuranceId), StringUtils.isBlank(itemValue) ? "0" : itemValue);
}
}
insuranceArchivesFundSchemePO.setFundPaymentBaseString(JSON.toJSONString(socialPaymentBase));
@ -1143,7 +1189,8 @@ public class SISchemeServiceImpl extends Service implements SISchemeService {
continue;
}
if (findElement(singleAccount, welfareMap.get(insuranceId) + SalaryI18nUtil.getI18nLabel(100293, "申报基数")) != null) {
socialPaymentBase.put(String.valueOf(insuranceId), (String) findElement(singleAccount, welfareMap.get(insuranceId) + SalaryI18nUtil.getI18nLabel(100293, "申报基数")).get(welfareMap.get(insuranceId) + SalaryI18nUtil.getI18nLabel(100293, "申报基数")));
String itemValue = (String) findElement(singleAccount, welfareMap.get(insuranceId) + SalaryI18nUtil.getI18nLabel(100293, "申报基数")).get(welfareMap.get(insuranceId) + SalaryI18nUtil.getI18nLabel(100293, "申报基数"));
socialPaymentBase.put(String.valueOf(insuranceId), StringUtils.isBlank(itemValue) ? "0" : itemValue);
}
}
insuranceArchivesOtherSchemePO.setOtherPaymentBaseString(JSON.toJSONString(socialPaymentBase));
@ -1258,4 +1305,140 @@ public class SISchemeServiceImpl extends Service implements SISchemeService {
}
/**
* 校验待新增的社保福利档案数据
* @param siArchiveImportActionParam
* @return
*/
@Override
public Map<String, Object> checkSIArchiveAdd(SIArchiveImportActionParam siArchiveImportActionParam) {
siArchiveImportActionParam.setAddData(false);
return processAddSIArchive(siArchiveImportActionParam);
}
/**
* 新增社保福利档案
* @param siArchiveImportActionParam
* @return
*/
@Override
public Map<String, Object> addSIArchive(SIArchiveImportActionParam siArchiveImportActionParam) {
siArchiveImportActionParam.setAddData(true);
return processAddSIArchive(siArchiveImportActionParam);
}
private Map<String, Object> processAddSIArchive(SIArchiveImportActionParam param) {
ValidUtil.doValidator(param);
if (StringUtils.isBlank(param.getRunStatus())) {
throw new SalaryRunTimeException("福利档案执行状态未在导入条件设置中添加!");
}
// List<ExcelSheet> excelSheets = message.getBatchFile().getExcelSheets();
// 租户key
// String tenantKey = message.getTenantKey().toLowerCase();
//操作员id
Long creator = (long) user.getUID();
//获取所有福利类型的id-name结合
Map<String, Long> schemeNameIdMap = schemeNameIdMap();
Map<Long, String> welfareMap = welfareMap();
// 获取所有个税扣缴义务人的名称和id的map
Map<String, Long> paymentNameIdMap;
//分权
Boolean openDevolution = getTaxAgentService().isOpenDevolution();
if (openDevolution) {
paymentNameIdMap = getTaxAgentService().listAllTaxAgentsAsAdmin((long) user.getUID()).stream().collect(Collectors.toMap(TaxAgentPO::getName, TaxAgentPO::getId));
} else {
paymentNameIdMap = getTaxAgentService().listAll().stream().collect(Collectors.toMap(TaxAgentPO::getName, TaxAgentPO::getId));
}
//获取所以个税扣缴义务人树型
List<TaxAgentManageRangeEmployeeDTO> taxAgentManageRangeEmployeeTree = getTaxAgentService().listTaxAgentAndEmployeeTree();
// 获取所有人员信息
List<DataCollectionEmployee> employeeByIds = employeeBiz.listEmployee();
int total = 0;
int index = 0;
int successCount = 0;
int errorCount = 0;
// 待导入数据
List<InsuranceArchivesAccountPO> insuranceArchivesAccountPOS = new ArrayList<>();
// 待导入数据
InputStream fileInputStream = null;
try {
// 表头
List<String> headers = new ArrayList<>();
if (param.getImportDatas().size() > 0) {
Map<String,Object> getHeadersMap = param.getImportDatas().get(0);
for (Map.Entry<String,Object> entry : getHeadersMap.entrySet()){
headers.add(entry.getKey());
}
} else {
throw new SalaryRunTimeException("新增福利档案数据为空!");
}
// 错误sheet数据
List<Map<String, Object>> errorData = new LinkedList<>();
// 错误提示
List<Map<String, String>> excelComments = new LinkedList<>();
// 处理数值
List<Map<String, Object>> data = param.getImportDatas();
total = data.size();
//当前sheel的单行记录
Map<String, Object> map;
for (int i = 0; i < data.size(); i++) {
index += 1;
map = data.get(i);
boolean isError;
List<Map<String, Object>> singleAccount = new ArrayList<>();
for (int j = 0; j < headers.size(); j++) {
//组装单条数据基础数据
String key = headers.get(j);
if (key == null) {
continue;
}
Map<String, Object> cellData = new HashMap<>();
cellData.put(key.toString(), Optional.ofNullable(map.get(key.toString())).orElse("").toString());
cellData.put("index", j);
singleAccount.add(cellData);
}
isError = singleAccountCheck(singleAccount, welfareMap, insuranceArchivesAccountPOS, employeeByIds, excelComments, errorCount + 1, schemeNameIdMap, paymentNameIdMap, creator, i + 2, openDevolution, taxAgentManageRangeEmployeeTree, param.getRunStatus());
if (isError) {
errorCount += 1;
// 添加错误数据
errorData.add(map);
} else {
successCount += 1;
}
// salaryBatchService.sendImportRate(message.getBizId(), total, index);
}
// 如果sheet包含错误数据
// if (CollectionUtils.isNotEmpty(errorData)) {
// salaryBatchService.createErrorExcelSheet(headers, errorData, excelSheet.getName(), excelComments, errorExcelSheets);
// }
// 数据入库处理
if (param.isAddData()) {
handleImportData(insuranceArchivesAccountPOS);
}
// 发送导入回调信息
// salaryBatchService.sendImportCallBackInfo(message, successCount, errorCount, errorExcelSheets);
Map<String, Object> apidatas = new HashMap<String, Object>();
apidatas.put("successCount", successCount);
apidatas.put("errorCount", errorCount);
apidatas.put("errorData", excelComments);
return apidatas;
} finally {
IOUtils.closeQuietly(fileInputStream);
}
}
}

View File

@ -0,0 +1,648 @@
//package com.engine.salary.service.impl;
//
//import com.engine.salary.cache.SalaryCacheKey;
//import com.engine.salary.constant.SalaryDefaultTenantConstant;
//import com.engine.salary.entity.datacollection.DataCollectionEmployee;
//import com.engine.salary.entity.salaryacct.bo.*;
//import com.engine.salary.entity.salaryacct.dto.SalaryAcctRateDTO;
//import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO;
//import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO;
//import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO;
//import com.engine.salary.entity.salaryformula.ExpressFormula;
//import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
//import com.engine.salary.service.*;
//import com.engine.salary.util.SalaryEntityUtil;
//import com.google.common.collect.Lists;
//import com.google.common.collect.Maps;
//import com.googlecode.aviator.Expression;
//import com.weaver.common.distribution.genid.IdGenerator;
//import com.weaver.common.elog.dto.LoggerContext;
//import com.weaver.common.elog.util.Util;
//import com.weaver.common.hrm.domain.employee.HrmStatus;
//import com.weaver.datasecurity.interceptor.DSTenantKeyThreadVar;
//import com.weaver.excel.formula.api.entity.FormulaVar;
//import com.weaver.excel.formula.entity.parameter.standard.ExcelResult;
//import com.weaver.framework.util.JsonUtil;
//import com.weaver.hrm.salary.common.LocalDateRange;
//import com.weaver.hrm.salary.constant.SalaryFormulaFieldConstant;
//import com.weaver.hrm.salary.entity.customdata.param.CustomDataEmployeeQueryParam;
//import com.weaver.hrm.salary.entity.customdata.po.CustomDataEmployeePO;
//import com.weaver.hrm.salary.entity.customdata.po.CustomDataRecordPO;
//import com.weaver.hrm.salary.entity.datacollection.dto.AttendQuoteDataDTO;
//import com.weaver.hrm.salary.entity.datacollection.po.AddUpDeductionPO;
//import com.weaver.hrm.salary.entity.datacollection.po.AddUpSituationPO;
//import com.weaver.hrm.salary.entity.datacollection.po.OtherDeductionPO;
//import com.weaver.hrm.salary.entity.extemployee.po.ExtEmployeePO;
//import com.weaver.hrm.salary.entity.salaryacct.bo.*;
//import com.weaver.hrm.salary.entity.salaryacct.po.*;
//import com.weaver.hrm.salary.entity.salaryarchive.dto.SalaryArchiveDataDTO;
//import com.weaver.hrm.salary.entity.salarysob.dto.SalarySobCycleDTO;
//import com.weaver.hrm.salary.entity.salarysob.po.SalarySobAdjustRulePO;
//import com.weaver.hrm.salary.entity.salarysob.po.SalarySobBackItemPO;
//import com.weaver.hrm.salary.entity.salarysob.po.SalarySobItemPO;
//import com.weaver.hrm.salary.entity.salarysob.po.SalarySobPO;
//import com.weaver.hrm.salary.enums.OperateTypeEnum;
//import com.weaver.hrm.salary.enums.salaryaccounting.EmployeeTypeEnum;
//import com.weaver.hrm.salary.enums.salaryaccounting.SalaryAcctRecordStatusEnum;
//import com.weaver.hrm.salary.enums.salaryitem.SalaryDataTypeEnum;
//import com.weaver.hrm.salary.enums.salaryitem.SalaryFormulaReferenceEnum;
//import com.weaver.hrm.salary.enums.salaryitem.SalaryRoundingModeEnum;
//import com.weaver.hrm.salary.enums.salarysob.IncomeCategoryEnum;
//import com.weaver.hrm.salary.enums.sicategory.DeleteTypeEnum;
//import com.weaver.hrm.salary.exception.SalaryRunTimeException;
//import com.weaver.hrm.salary.service.*;
//import com.weaver.hrm.salary.util.SalaryI18nUtil;
//import com.weaver.util.threadPool.ThreadPoolUtil;
//import com.weaver.util.threadPool.constant.ModulePoolEnum;
//import com.weaver.util.threadPool.entity.LocalRunnable;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.commons.collections4.CollectionUtils;
//import org.apache.commons.collections4.MapUtils;
//import org.apache.commons.lang3.StringUtils;
//import org.apache.commons.lang3.math.NumberUtils;
//import org.springframework.transaction.annotation.Transactional;
//
//import java.math.BigDecimal;
//import java.math.RoundingMode;
//import java.time.LocalDateTime;
//import java.time.Month;
//import java.util.*;
//import java.util.concurrent.BlockingDeque;
//import java.util.concurrent.CountDownLatch;
//import java.util.concurrent.LinkedBlockingDeque;
//import java.util.stream.Collectors;
//
///**
// * 薪资核算
// *
// * <p>Copyright: Copyright (c) 2022</p>
// * <p>Company: 泛微软件</p>
// *
// * @author qiantao
// * @version 1.0
// **/
//@Slf4j
//public class SalaryAcctCalcServiceImpl implements SalaryAcctCalcService {
//
//
// private SalaryAcctRecordService salaryAcctRecordService;
//
// private SalarySobItemService salarySobItemService;
//
//// private SalarySobBackItemService salarySobBackItemService;
//
// private SalarySobAdjustRuleService salarySobAdjustRuleService;
//
// private SalaryFormulaService salaryFormulaService;
//
// private SalaryItemService salaryItemService;
//
// private SalaryAcctEmployeeService salaryAcctEmployeeService;
//
// private SalaryArchiveService salaryArchiveService;
//
// private AddUpSituationService addUpSituationService;
//
// private AddUpDeductionService addUpDeductionService;
//
// private OtherDeductionService otherDeductionService;
//
// private AttendQuoteDataService attendQuoteDataService;
//
// private SIAccountService siAccountService;
//
// private SalaryCacheService salaryCacheService;
//
//// private CustomDataRecordService customDataRecordService;
//
//// private CustomDataEmployeeService customDataEmployeeService;
//
//// private HrmCommonEmployeeService hrmCommonEmployeeService;
//
//// private ExtEmployeeService extEmployeeService;
//
//// private SalaryAcctResultValueService salaryAcctResultValueService;
//
//
// private SalarySobService salarySobService;
//
//// private SalaryAcctSobConfigService salaryAcctSobConfigService;
//
//
// @Override
// public void calcByRecordId(Long salaryAcctRecordId, DataCollectionEmployee simpleEmployee) throws Exception {
// calcByEmployeeIds(salaryAcctRecordId, Collections.emptyList(), simpleEmployee);
// }
//
// @Override
// @Transactional(rollbackFor = Exception.class)
// public void calcByEmployeeIds(Long salaryAcctRecordId, Collection<Long> salaryAcctEmployeeIds, DataCollectionEmployee simpleEmployee) throws Exception {
// SalaryAcctRateDTO salaryAcctRate = new SalaryAcctRateDTO("" + salaryAcctRecordId);
// try {
// String tenantKey = SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY;
// // 查询本次核算的薪资核算人员
// List<SalaryAcctEmployeePO> salaryAcctEmployees;
// if (CollectionUtils.isEmpty(salaryAcctEmployeeIds)) {
// salaryAcctEmployees = salaryAcctEmployeeService.listBySalaryAcctRecordId(salaryAcctRecordId);
// } else {
// salaryAcctEmployees = salaryAcctEmployeeService.listByIds(salaryAcctEmployeeIds);
// }
// // 初始化核算进度(总数+1是因为所有人员核算完成后数据保存入库还需要一定的时间)
// salaryAcctRate.setTotalQty(salaryAcctEmployees.size() + 1);
// salaryCacheService.set(SalaryCacheKey.ACCT_PROGRESS + salaryAcctRate.getIndex(), salaryAcctRate);
// // 查询薪资核算记录
// SalaryAcctRecordPO salaryAcctRecord = salaryAcctRecordService.getById(salaryAcctRecordId);
// // 检查是否能够核算
// checkBeforeCalc(salaryAcctRecord, salaryAcctEmployees);
// // 加载函数
//// salaryFormulaService.initFunction();
// // 构建核算上下文
// SalaryCalcContext salaryCalcContext = loadContext(salaryAcctRecord, simpleEmployee);
// // 分批核算
// List<List<SalaryAcctEmployeePO>> salaryAcctEmployeePartition = SalaryAcctEmployeeBO.partitionByEmployeeId(salaryAcctEmployees);
// // 监控子线程的任务执行
// CountDownLatch childMonitor = new CountDownLatch(salaryAcctEmployeePartition.size());
// // 记录子线程的执行结果
// BlockingDeque<SalaryCalcResult> blockingDeque = new LinkedBlockingDeque<>(salaryAcctEmployeePartition.size());
// for (List<SalaryAcctEmployeePO> partSalaryAcctEmployees : salaryAcctEmployeePartition) {
// LocalRunnable localRunnable = new LocalRunnable() {
// @Override
// public void execute() {
// calc(salaryCalcContext, partSalaryAcctEmployees, childMonitor, blockingDeque, simpleEmployee);
// }
// };
// ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.OTHER, "salaryAcctCalculate", localRunnable);
// }
// // 等待核算结束
// childMonitor.await();
// // 处理核算结果
// handleCalcResult(blockingDeque, salaryAcctRecordId, salaryAcctEmployeeIds, tenantKey);
// // 记录日志
// writeLog(salaryAcctRecordId, tenantKey);
// // 核算结束更新进度
// salaryAcctRate.setFinish(true).setCalcQty(salaryAcctEmployees.size()).setRate(BigDecimal.ONE);
// } finally {
// // 更新进度
// salaryCacheService.set(SalaryCacheKey.ACCT_PROGRESS + salaryAcctRate.getIndex(), salaryAcctRate);
// }
// }
//
// private void calc(SalaryCalcContext salaryCalcContext,
// List<SalaryAcctEmployeePO> salaryAcctEmployees,
// CountDownLatch childMonitor,
// BlockingDeque<SalaryCalcResult> blockingDeque,
// DataCollectionEmployee simpleEmployee) {
// try {
// // 数据库字段加密用
// LocalDateTime now = LocalDateTime.now();
// // 加载公式计算时所需要的变量
// SalaryCalcEmployeeContext salaryCalcEmployeeContext = loadEmployeeContext(salaryCalcContext, salaryAcctEmployees, simpleEmployee.getTenantKey());
// // 对薪资核算人员进行分组如果是合并计算(工资薪金劳务一起计算)的话会存在工资薪金和劳务费用的项目存在相互引用所以相关联的人员要在同一组进行核算
// Map<Long, List<SalaryAcctEmployeePO>> salaryAcctEmployeeMap = SalaryEntityUtil.group2Map(salaryAcctEmployees, SalaryAcctEmployeePO::getId);
//// if (salaryCalcContext.getSalarySobCycle().getIncomeCategories().size() > 1) {
//// salaryAcctEmployeeMap = SalaryEntityUtil.group2Map(salaryAcctEmployees, SalaryAcctEmployeePO::getEmployeeId);
//// }
// // 计算公式
// int calcQty = 0;
// List<SalaryAcctResultPO> newSalaryAcctResultValues = Lists.newArrayListWithExpectedSize(salaryAcctEmployees.size());
// for (Map.Entry<Long, List<SalaryAcctEmployeePO>> entry : salaryAcctEmployeeMap.entrySet()) {
// // 获取锁定的薪资项目
// Set<Long> lockSalaryItemIds = new HashSet<>(Collections.emptySet());
// for (SalaryAcctEmployeePO salaryAcctEmployee : entry.getValue()) {
// SalaryAcctResultPO noDecryptSalaryAcctResultValue = salaryCalcEmployeeContext.getNoDecryptAcctResultValueMap().get(salaryAcctEmployee.getId());
//// if (noDecryptSalaryAcctResultValue != null) {
//// lockSalaryItemIds.addAll(noDecryptSalaryAcctResultValue.getLockSalaryItemIds());
//// }
// }
// Map<String, Map<String, String>> incomeCategoryResultValueMap = Maps.newHashMap();
// Map<String, SalaryAcctEmployeePO> incomeCategoryAcctEmployeeMap = SalaryEntityUtil.convert2Map(entry.getValue(), SalaryAcctEmployeePO::getIncomeCategory);
// // 根据解析好的公式计算优先级计算公式
// for (List<SalaryCalcFormula> formulaPriority : salaryCalcContext.getSalaryCalcFormulaContext().getSalaryCalcFormulas()) {
// for (SalaryCalcFormula salaryCalcFormula : formulaPriority) {
// SalaryAcctEmployeePO salaryAcctEmployee;
// if (Objects.equals(salaryCalcFormula.getIncomeCategory(), "0")) {
// salaryAcctEmployee = SalaryEntityUtil.findFirst(entry.getValue());
// } else {
// salaryAcctEmployee = incomeCategoryAcctEmployeeMap.get(salaryCalcFormula.getIncomeCategory());
// }
// if (salaryAcctEmployee == null) {
// continue;
// }
// // 找出需要计算的公式
// SalaryItemPO salaryItem = salaryCalcContext.getSalaryCalcFormulaContext().getSalaryItemMap().get(salaryCalcFormula.getSalaryItemId());
// ExpressFormula expressFormula = salaryCalcContext.getSalaryCalcFormulaContext().getExpressFormulaMap().get(salaryCalcFormula.getFormulaId());
// Expression expression = salaryCalcContext.getSalaryCalcFormulaContext().getExpressionMap().get(salaryCalcFormula.getFormulaId());
// // 获取变量的值
// Map<String, String> formulaVarValueMap = salaryCalcEmployeeContext.getFormulaVarValueMap().computeIfAbsent(salaryAcctEmployee.getId(), k -> new HashMap<>());
// // 运行公式获取结果
// String resultValue = calcResultValue(salaryCalcFormula, expressFormula, expression, formulaVarValueMap, lockSalaryItemIds, salaryCalcContext.getSimpleEmployee());
// // 处理合并计税
// resultValue = handleConsolidatedTax(salaryCalcContext, salaryCalcEmployeeContext, salaryAcctEmployee, resultValue, salaryItem);
// // 处理小数位数
// resultValue = roundResultValue(resultValue, salaryCalcFormula);
// // 将公式计算结果回填到变量map中
// formulaVarValueMap.put(SalaryFormulaReferenceEnum.SALARY_ITEM.getValue()
// + SalaryFormulaFieldConstant.FIELD_ID_SEPARATOR + salaryItem.getCode(), resultValue);
// // 合并计算时工资薪金和劳务费用的项目存在相互引用所以需要将公式计算结果回填到另一个相关联的薪资核算人员的变量map中
// for (SalaryAcctEmployeePO relationSalaryAcctEmployee : entry.getValue()) {
// if (!Objects.equals(relationSalaryAcctEmployee.getId(), salaryAcctEmployee.getId())) {
// Map<String, String> relationFormulaVarValueMap = salaryCalcEmployeeContext.getFormulaVarValueMap().computeIfAbsent(relationSalaryAcctEmployee.getId(), k -> new HashMap<>());
// relationFormulaVarValueMap.put(SalaryFormulaReferenceEnum.SALARY_ITEM.getValue()
// + SalaryFormulaFieldConstant.FIELD_ID_SEPARATOR + salaryItem.getCode(), resultValue);
// }
// }
// // 计算结果
// Map<String, String> resultValueMap = incomeCategoryResultValueMap.computeIfAbsent(salaryCalcFormula.getIncomeCategory(), k -> Maps.newHashMap());
// resultValueMap.put("" + salaryCalcFormula.getSalaryItemId(), resultValue);
// }
// }
// for (SalaryAcctEmployeePO salaryAcctEmployee : entry.getValue()) {
// Map<String, String> resultValueMap = Maps.newHashMap();
// // 根据薪资核算人员的收入所得项目(工资薪金或者劳务)获取对应的薪资核算结果
// resultValueMap.putAll(incomeCategoryResultValueMap.getOrDefault(salaryAcctEmployee.getIncomeCategory(), Collections.emptyMap()));
// // 回算薪资项目既不属于工资薪金也不属于劳务但是也要保存到人员的薪资核算结果中
// resultValueMap.putAll(incomeCategoryResultValueMap.getOrDefault("0", Collections.emptyMap()));
// SalaryAcctResultValuePO noDecryptSalaryAcctResultValue = salaryCalcEmployeeContext.getNoDecryptAcctResultValueMap().get(salaryAcctEmployee.getId());
// SalaryAcctResultValuePO newSalaryAcctResultValue = new SalaryAcctResultValuePO()
// .setId(IdGenerator.generate())
// .setSalaryAcctRecordId(salaryAcctEmployee.getSalaryAcctRecordId())
// .setSalaryAcctEmployeeId(salaryAcctEmployee.getId())
// .setResultValue(resultValueMap)
// .setOriginResultValueJson(noDecryptSalaryAcctResultValue == null
// ? StringUtils.EMPTY : noDecryptSalaryAcctResultValue.getOriginResultValueJson())
// .setLockSalaryItemIds(lockSalaryItemIds)
// .setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue())
// .setTenantKey(simpleEmployee.getTenantKey())
// .setCreator(simpleEmployee.getEmployeeId())
// .setCreateTime(now)
// .setUpdateTime(now);
// newSalaryAcctResultValues.add(newSalaryAcctResultValue);
// // 更新计算进度
// updateRate(salaryCalcContext.getSalaryAcctRecord().getId(), ++calcQty, salaryAcctEmployees.size());
// }
// }
// blockingDeque.add(new SalaryCalcResult(true, "", newSalaryAcctResultValues));
// } catch (Exception e) {
// log.info("薪资核算失败:{}", e.getMessage(), e);
// blockingDeque.add(new SalaryCalcResult(false, e.getMessage(), Collections.emptyList()));
// } finally {
// // 子线程执行完毕
// childMonitor.countDown();
// // 数据库字段加密用
// DSTenantKeyThreadVar.tenantKey.remove();
// }
// }
//
// private void checkBeforeCalc(SalaryAcctRecordPO salaryAcctRecordPO, List<SalaryAcctEmployeePO> salaryAcctEmployees) {
// if (Objects.isNull(salaryAcctRecordPO)) {
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(145221, "薪资核算记录不存在或已被删除"));
// }
// // 归档状态或已申报状态下不能核算
// if (!Objects.equals(salaryAcctRecordPO.getStatus(), SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue())) {
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(145222, "薪资核算记录已经归档,不能再核算"));
// }
// // 没有薪资核算人员不能核算
// if (CollectionUtils.isEmpty(salaryAcctEmployees)) {
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "当前核算人员为空,请先确认要核算的人员"));
// }
// }
//
// private SalaryCalcContext loadContext(SalaryAcctRecordPO salaryAcctRecord, DataCollectionEmployee simpleEmployee) {
// String tenantKey = simpleEmployee.getTenantKey();
// // 查询考勤周期薪资周期税款所属期社保福利台账月份
// SalarySobCycleDTO salarySobCycle = salaryAcctRecordService.getSalarySobCycleById(salaryAcctRecord.getId(), tenantKey);
// // 查询薪资核算记录的账套配置
// SalaryAcctSobConfigPO salaryAcctSobConfig = salaryAcctSobConfigService.getBySalaryAcctRecordId(salaryAcctRecord.getId(), tenantKey);
// // 薪资项目
// List<SalarySobItemPO> salarySobItems = JsonUtil.parseList(salaryAcctSobConfig.getItemConfig(), SalarySobItemPO.class);
// // 回算薪资项目
// List<SalarySobBackItemPO> salarySobBackItems = !Objects.equals(salaryAcctRecord.getBackCalcStatus(), 1) ? Collections.emptyList()
// : JsonUtil.parseList(salaryAcctSobConfig.getBackItemConfig(), SalarySobBackItemPO.class);
// // 查询薪资项目所用的公式id
// Set<Long> formulaIds = new HashSet<>();
// formulaIds.addAll(SalaryEntityUtil.properties(salarySobItems, SalarySobItemPO::getFormulaId));
// formulaIds.addAll(SalaryEntityUtil.properties(salarySobBackItems, SalarySobBackItemPO::getFormulaId));
// List<ExpressFormula> expressFormulas = salaryFormulaService.listOriginExpressFormula(formulaIds, tenantKey);
// // 查询薪资项目
// Set<Long> salaryItemIds = new HashSet<>();
// salaryItemIds.addAll(SalaryEntityUtil.properties(salarySobItems, SalarySobItemPO::getSalaryItemId));
// salaryItemIds.addAll(SalaryEntityUtil.properties(salarySobBackItems, SalarySobBackItemPO::getSalaryItemId));
// List<SalaryItemPO> salaryItems = salaryItemService.listByIds(salaryItemIds, tenantKey);
// // 计算薪资项目的计算优先级
// SalaryCalcPriority salaryCalcPriority = new SalaryCalcPriority(salaryItems, salarySobItems, salarySobBackItems, expressFormulas);
// SalaryCalcFormulaContext salaryCalcFormulaContext = salaryCalcPriority.calc();
// // 查询薪资核算所用的调薪计薪规则
// List<SalarySobAdjustRulePO> salarySobAdjustRules = salarySobAdjustRuleService.listBySalarySobId(salaryAcctRecord.getSalarySobId(), tenantKey);
// // 查询员工状态
// List<HrmStatus> hrmStatusList = hrmCommonHrmStatusService.list(tenantKey);
// Map<String, String> hrmStatusMap = SalaryEntityUtil.convert2Map(hrmStatusList, hrmStatus -> "" + hrmStatus.getCodeId(), HrmStatus::getName);
//
// // 构建上下文
// SalaryCalcContext salaryCalcContext = new SalaryCalcContext();
// salaryCalcContext.setSimpleEmployee(simpleEmployee);
// salaryCalcContext.setHrmStatusMap(hrmStatusMap);
// salaryCalcContext.setSalaryAcctRecord(salaryAcctRecord);
// salaryCalcContext.setSalarySobCycle(salarySobCycle);
// salaryCalcContext.setSalaryAdjustmentRules(salarySobAdjustRules);
// salaryCalcContext.setSalaryCalcFormulaContext(salaryCalcFormulaContext);
// return salaryCalcContext;
// }
//
// private SalaryCalcEmployeeContext loadEmployeeContext(SalaryCalcContext salaryCalcContext, List<SalaryAcctEmployeePO> salaryAcctEmployees, String tenantKey) {
// // 查询合并计税的薪资核算记录
// LocalDateRange localDateRange = LocalDateRange.builder()
// .fromDate(salaryCalcContext.getSalarySobCycle().getTaxCycle().atDay(1))
// .endDate(salaryCalcContext.getSalarySobCycle().getTaxCycle().atEndOfMonth())
// .build();
// List<SalaryAcctRecordPO> salaryAcctRecords = salaryAcctRecordService.listByTaxCycle(localDateRange, tenantKey);
// Map<Long, SalaryAcctRecordPO> salaryAcctRecordMap = SalaryEntityUtil.convert2Map(salaryAcctRecords, SalaryAcctRecordPO::getId);
// // 查询合并计税的薪资核算人员
// List<SalaryAcctEmployeePO> sameTaxCycleSalaryAcctEmployees = salaryAcctEmployeeService.listSameTaxCycle(salaryAcctEmployees, salaryCalcContext.getSalarySobCycle().getTaxCycle().toString(), tenantKey);
// Map<String, List<SalaryAcctEmployeePO>> sameTaxCycleEmployeeMap = SalaryEntityUtil.group2Map(sameTaxCycleSalaryAcctEmployees, o -> o.getEmployeeId() + "-" + o.getTaxAgentId());
// Set<Long> sameTaxCycleSalaryAcctEmployeeIds = SalaryEntityUtil.properties(sameTaxCycleSalaryAcctEmployees, SalaryAcctEmployeePO::getId);
// List<SalaryAcctResultValuePO> sameTaxCycleResultValues = salaryAcctResultValueService
// .listBySalaryAcctEmployeeIds(sameTaxCycleSalaryAcctEmployeeIds, tenantKey);
// Map<Long, SalaryAcctResultValuePO> sameTaxCycleResultValueMap = SalaryEntityUtil.convert2Map(sameTaxCycleResultValues, SalaryAcctResultValuePO::getSalaryAcctEmployeeId);
//
// SalaryCalcEmployeeContext salaryCalcEmployeeContext = new SalaryCalcEmployeeContext();
// salaryCalcEmployeeContext.setSameTaxCycleRecordMap(salaryAcctRecordMap);
// salaryCalcEmployeeContext.setSameTaxCycleEmployeeMap(sameTaxCycleEmployeeMap);
// salaryCalcEmployeeContext.setSameTaxCycleResultValueMap(sameTaxCycleResultValueMap);
// // 加载公式变量
// loadFormulaVar(salaryCalcContext, salaryCalcEmployeeContext, salaryAcctEmployees);
// return salaryCalcEmployeeContext;
// }
//
// private void loadFormulaVar(SalaryCalcContext salaryCalcContext, SalaryCalcEmployeeContext salaryCalcEmployeeContext, List<SalaryAcctEmployeePO> salaryAcctEmployees) {
// String tenantKey = salaryCalcContext.getSimpleEmployee().getTenantKey();
// // 薪资核算人员中的组织架构人员
// List<Long> employeeIds = SalaryEntityUtil.properties(salaryAcctEmployees, SalaryAcctEmployeePO::getEmployeeId, Collectors.toList());
// // 查询薪资档案
// List<SalaryArchiveDataDTO> salaryArchiveDataList = Collections.emptyList();
// if (CollectionUtils.isNotEmpty(salaryCalcContext.getSalaryCalcFormulaContext().getSalaryArchiveFieldIds())
// && CollectionUtils.isNotEmpty(employeeIds)) {
// salaryArchiveDataList = salaryArchiveService.getSalaryArchiveData(salaryCalcContext.getSalarySobCycle().getSalaryCycle(), employeeIds, tenantKey);
// }
// // 查询往期累计情况
// List<AddUpSituationPO> addUpSituations = Collections.emptyList();
// if (CollectionUtils.isNotEmpty(salaryCalcContext.getSalaryCalcFormulaContext().getAddUpSituationFieldIds())
// && salaryCalcContext.getSalarySobCycle().getTaxCycle().getMonth() != Month.JANUARY
// && CollectionUtils.isNotEmpty(employeeIds)) {
// addUpSituations = addUpSituationService.getAddUpSituationList(salaryCalcContext.getSalarySobCycle().getTaxCycle().plusMonths(-1), employeeIds, tenantKey);
// }
// // 查询累计专项附加扣除
// List<AddUpDeductionPO> addUpDeductions = Collections.emptyList();
// if (CollectionUtils.isNotEmpty(salaryCalcContext.getSalaryCalcFormulaContext().getAddUpDeductionFieldIds())
// && CollectionUtils.isNotEmpty(employeeIds)) {
// addUpDeductions = addUpDeductionService.getAddUpDeductionList(salaryCalcContext.getSalarySobCycle().getTaxCycle(), employeeIds, tenantKey);
// }
// // 查询其他扣除
// List<OtherDeductionPO> otherDeductions = Collections.emptyList();
// if (CollectionUtils.isNotEmpty(salaryCalcContext.getSalaryCalcFormulaContext().getOtherDeductionFieldIds())
// && CollectionUtils.isNotEmpty(employeeIds)) {
// otherDeductions = otherDeductionService.getOtherDeductionList(salaryCalcContext.getSalarySobCycle().getTaxCycle(), employeeIds, tenantKey);
// }
// // 查询考勤
// List<AttendQuoteDataDTO> attendQuoteDataList = Collections.emptyList();
// if (CollectionUtils.isNotEmpty(salaryCalcContext.getSalaryCalcFormulaContext().getAttendFieldIds())
// && CollectionUtils.isNotEmpty(employeeIds)) {
// SalarySobPO salarySob = salarySobService.getById(salaryCalcContext.getSalaryAcctRecord().getSalarySobId(), tenantKey);
// attendQuoteDataList = attendQuoteDataService.getAttendQuoteData(salaryCalcContext.getSalarySobCycle().getSalaryMonth(), salarySob.getOriginSalarySobId(), employeeIds, tenantKey);
// }
// // 查询社保福利
// List<Map<String, Object>> welfareMapList = Collections.emptyList();
// if (CollectionUtils.isNotEmpty(salaryCalcContext.getSalaryCalcFormulaContext().getWelfareFieldIds())
// && CollectionUtils.isNotEmpty(employeeIds)) {
// welfareMapList = siAccountService.welfareData(salaryCalcContext.getSalarySobCycle().getSocialSecurityCycle().toString(), employeeIds, tenantKey);
// }
// // 查询自定义业务数据
// List<CustomDataEmployeePO> customDataEmployees = Collections.emptyList();
// if (MapUtils.isNotEmpty(salaryCalcContext.getSalaryCalcFormulaContext().getCustomDataFieldIdMap())
// && CollectionUtils.isNotEmpty(employeeIds)) {
// Set<Long> customFieldIds = salaryCalcContext.getSalaryCalcFormulaContext().getCustomDataFieldIdMap().values().stream()
// .flatMap(Collection::stream)
// .map(fieldId -> Util.getLongValue(fieldId, 0L))
// .collect(Collectors.toSet());
// List<CustomDataRecordPO> customDataRecords = customDataRecordService.listByCustomFormIdsAndSalaryMonth(
// salaryCalcContext.getSalaryCalcFormulaContext().getCustomDataFieldIdMap().keySet(),
// salaryCalcContext.getSalarySobCycle().getSalaryMonth(),
// salaryCalcContext.getSimpleEmployee().getEmployeeId(), tenantKey);
// CustomDataEmployeeQueryParam param = new CustomDataEmployeeQueryParam()
// .setCustomDataRecordIds(SalaryEntityUtil.properties(customDataRecords, CustomDataRecordPO::getId))
// .setEmployeeIds(employeeIds)
// .setCustomFieldIds(customFieldIds);
// customDataEmployees = customDataEmployeeService.listByParam(param, tenantKey);
// }
// // 查询人员信息
// List<DataCollectionEmployee> simpleEmployees = Collections.emptyList();
// if (CollectionUtils.isNotEmpty(salaryCalcContext.getSalaryCalcFormulaContext().getEmployeeInfoFieldIds())
// && CollectionUtils.isNotEmpty(employeeIds)) {
// simpleEmployees = hrmCommonEmployeeService.getEmployeeByIds(employeeIds, tenantKey);
// }
// // 查询外部人员
// List<Long> extEmployeeIds = salaryAcctEmployees.stream()
// .filter(salaryAcctEmployee -> Objects.equals(salaryAcctEmployee.getEmployeeType(), EmployeeTypeEnum.EXT_EMPLOYEE.getValue()))
// .map(SalaryAcctEmployeePO::getEmployeeId)
// .distinct()
// .collect(Collectors.toList());
// List<ExtEmployeePO> extEmployees = Collections.emptyList();
// if (CollectionUtils.isNotEmpty(salaryCalcContext.getSalaryCalcFormulaContext().getExtEmployeeFieldIds())
// && CollectionUtils.isNotEmpty(extEmployeeIds)) {
// extEmployees = extEmployeeService.listByIdsWithDeleted(extEmployeeIds, tenantKey);
// }
// // 查询薪资核算结果(不解密)
// Set<Long> salaryAcctEmployeeIds = SalaryEntityUtil.properties(salaryAcctEmployees, SalaryAcctEmployeePO::getId);
// List<SalaryAcctResultValuePO> noDecryptSalaryAcctResultValues = salaryAcctResultValueService.listNoDecryptBySalaryAcctEmployeeIds(salaryAcctEmployeeIds, tenantKey);
// Map<Long, SalaryAcctResultValuePO> noDecryptSalaryAcctResultValueMap = SalaryEntityUtil.convert2Map(noDecryptSalaryAcctResultValues, SalaryAcctResultValuePO::getSalaryAcctEmployeeId);
// salaryCalcEmployeeContext.setNoDecryptAcctResultValueMap(noDecryptSalaryAcctResultValueMap);
// // 查询薪资核算结果(解密)
// List<SalaryAcctResultValuePO> salaryAcctResultValues = salaryAcctResultValueService.listBySalaryAcctEmployeeIds(salaryAcctEmployeeIds, tenantKey);
//
// SalaryCalcFormulaVar salaryCalcFormulaVar = new SalaryCalcFormulaVar(salaryArchiveDataList, addUpSituations,
// addUpDeductions, otherDeductions, attendQuoteDataList, welfareMapList, customDataEmployees, simpleEmployees, extEmployees, salaryAcctResultValues);
// Map<Long, List<SalaryCalcFormulaVarValue>> resultMap = salaryCalcFormulaVar.handleSalaryCalcFormulaVar(salaryCalcContext, salaryAcctEmployees);
// Map<Long, Map<String, String>> formulaVarValueMap = Maps.newHashMapWithExpectedSize(resultMap.size());
// resultMap.forEach((k, v) -> {
// Map<String, String> map = SalaryEntityUtil.convert2Map(v, SalaryCalcFormulaVarValue::getFieldId, SalaryCalcFormulaVarValue::getFieldValue);
// formulaVarValueMap.put(k, map);
// });
// salaryCalcEmployeeContext.setFormulaVarValueMap(formulaVarValueMap);
// }
//
// private String calcResultValue(SalaryCalcFormula salaryCalcFormula,
// ExpressFormula expressFormula,
// Expression expression,
// Map<String, String> formulaVarValueMap,
// Set<Long> lockSalaryItemIds,
// DataCollectionEmployee simpleEmployee) {
// String originValue = formulaVarValueMap.getOrDefault(SalaryFormulaReferenceEnum.SALARY_ITEM.getValue()
// + SalaryFormulaFieldConstant.FIELD_ID_SEPARATOR + salaryCalcFormula.getSalaryItemCode(), "");
// if (Objects.isNull(expressFormula) || lockSalaryItemIds.contains(salaryCalcFormula.getSalaryItemId())) {
// if (Objects.equals(salaryCalcFormula.getUseInEmployeeSalary(), NumberUtils.INTEGER_ONE) && !lockSalaryItemIds.contains(salaryCalcFormula.getSalaryItemId())) {
// return formulaVarValueMap.getOrDefault(SalaryFormulaReferenceEnum.SALARY_ARCHIVES.getValue()
// + SalaryFormulaFieldConstant.FIELD_ID_SEPARATOR + salaryCalcFormula.getSalaryItemId(), "");
// }
// return originValue;
// }
// // 如果只包含了优化的函数走本模块的计算否则走公式模块提供的公共方法计算
// if (expression != null) {
// try {
// // 填充变量的值
// Map<String, Object> envMap = ExpressFormulaBO.fillExpressionEnvMap(expressFormula, formulaVarValueMap);
// // 运行公式
// return Util.null2String(expression.execute(envMap));
// } catch (Exception e) {
// log.info("公式计算错误:{}", expressFormula.getFormula(), e);
// return StringUtils.EMPTY;
// }
// }
// // 填充变量的值
// List<FormulaVar> formulaVars = ExpressFormulaBO.fillFormulaVarContent(expressFormula, formulaVarValueMap);
// // 运行公式
// ExcelResult excelResult = excelRunService.run(expressFormula, formulaVars, simpleEmployee);
// if (excelResult.isStatus()) {
// return excelResult.getStringData();
// } else {
// log.info("公式计算错误:{}, 错误原因:{}", expressFormula.getFormula(), excelResult.getErrorMsg());
// return StringUtils.EMPTY;
// }
// }
//
// private String handleConsolidatedTax(SalaryCalcContext salaryCalcContext,
// SalaryCalcEmployeeContext salaryCalcEmployeeContext,
// SalaryAcctEmployeePO salaryAcctEmployee,
// String resultValue,
// SalaryItemPO salaryItem) {
// // 只有正常工资薪金所得才需要合并计税处理
// if (!Objects.equals(salaryAcctEmployee.getIncomeCategory(), "" + IncomeCategoryEnum.WAGES_AND_SALARIES.getValue())) {
// return resultValue;
// }
// List<SalaryAcctEmployeePO> sameTaxCycleSalaryAcctEmployees = salaryCalcEmployeeContext.getSameTaxCycleEmployeeMap()
// .get(salaryAcctEmployee.getEmployeeId() + "-" + salaryAcctEmployee.getTaxAgentId());
// if (CollectionUtils.isEmpty(sameTaxCycleSalaryAcctEmployees)) {
// return resultValue;
// }
// // 第一次计算时不需要合并计税处理
// boolean needConsolidatedTax = needConsolidatedTax(salaryCalcEmployeeContext, salaryAcctEmployee, sameTaxCycleSalaryAcctEmployees);
// if (!needConsolidatedTax) {
// return resultValue;
// }
// List<SalaryAcctResultValuePO> salaryAcctResultValues = Lists.newArrayList();
// for (SalaryAcctEmployeePO sameTaxCycleSalaryAcctEmployee : sameTaxCycleSalaryAcctEmployees) {
// SalaryAcctResultValuePO salaryAcctResultValue = salaryCalcEmployeeContext.getSameTaxCycleResultValueMap().get(sameTaxCycleSalaryAcctEmployee.getId());
// if (salaryAcctResultValue != null) {
// salaryAcctResultValues.add(salaryAcctResultValue);
// }
// }
// List<SalaryItemPO> salaryItems = Lists.newArrayList(salaryCalcContext.getSalaryCalcFormulaContext().getSalaryItemMap().values());
// return SalaryAcctConsolidatedTax.handleConsolidatedTaxValue(resultValue, salaryItem, salaryItems, salaryAcctResultValues);
// }
//
// /**
// * 判断是否需要进行合并计税
// *
// * @param salaryCalcEmployeeContext
// * @param salaryAcctEmployee
// * @param sameTaxCycleSalaryAcctEmployees
// * @return
// */
// private boolean needConsolidatedTax(SalaryCalcEmployeeContext salaryCalcEmployeeContext,
// SalaryAcctEmployeePO salaryAcctEmployee,
// List<SalaryAcctEmployeePO> sameTaxCycleSalaryAcctEmployees) {
// SalaryAcctRecordPO salaryAcctRecord = salaryCalcEmployeeContext.getSameTaxCycleRecordMap().get(salaryAcctEmployee.getSalaryAcctRecordId());
// if (salaryAcctRecord == null) {
// return false;
// }
// for (SalaryAcctEmployeePO sameTaxCycleSalaryAcctEmployee : sameTaxCycleSalaryAcctEmployees) {
// SalaryAcctRecordPO otherSalaryAcctRecord = salaryCalcEmployeeContext.getSameTaxCycleRecordMap()
// .get(sameTaxCycleSalaryAcctEmployee.getSalaryAcctRecordId());
// if (otherSalaryAcctRecord == null) {
// continue;
// }
// if (otherSalaryAcctRecord.getCreateTime().compareTo(salaryAcctRecord.getCreateTime()) < 0) {
// return true;
// }
// }
// return false;
// }
//
// private String roundResultValue(String resultValue, SalaryCalcFormula salaryCalcFormula) {
// // 值为空不需要四舍五入
// if (StringUtils.isEmpty(resultValue)) {
// return StringUtils.EMPTY;
// }
// // 薪资项目字段类型为string无需四舍五入
// SalaryDataTypeEnum dataTypeEnum = salaryCalcFormula.getDataType();
// if (dataTypeEnum == SalaryDataTypeEnum.STRING) {
// return resultValue;
// }
// BigDecimal bigDecimalValue = SalaryEntityUtil.empty2Zero(resultValue);
// RoundingMode roundingMode = RoundingMode.HALF_UP;
// if (salaryCalcFormula.getRoundingMode() == SalaryRoundingModeEnum.ROUND_UP) {
// roundingMode = RoundingMode.UP;
// }
// if (salaryCalcFormula.getRoundingMode() == SalaryRoundingModeEnum.ROUND_DOWN) {
// roundingMode = RoundingMode.DOWN;
// }
// return bigDecimalValue.setScale(salaryCalcFormula.getPattern(), roundingMode).toPlainString();
// }
//
// /**
// * 更新核算进度
// *
// * @param salaryAcctRecordId
// * @param calcQty
// */
// private synchronized void updateRate(Long salaryAcctRecordId, int calcQty, int salaryAcctEmployeeSize) {
// int addQty = 0;
// if (calcQty % 10 == 0) {
// addQty = 10;
// } else if (Objects.equals(calcQty, salaryAcctEmployeeSize)) {
// addQty = calcQty % 10;
// }
// if (addQty > 0) {
// SalaryAcctRateDTO salaryAcctRate = salaryCacheService
// .get(SalaryCacheKey.ACCT_PROGRESS, "" + salaryAcctRecordId, SalaryAcctRateDTO.class);
// salaryAcctRate.setCalcQty(salaryAcctRate.getCalcQty() + addQty);
// salaryCacheService.set(SalaryCacheKey.ACCT_PROGRESS, "" + salaryAcctRecordId, salaryAcctRate);
// }
// }
//
// private void handleCalcResult(BlockingDeque<SalaryCalcResult> blockingDeque,
// Long salaryAcctRecordId, Collection<Long> salaryAcctEmployeeIds,
// String tenantKey) {
// boolean allSuccess = blockingDeque.stream().allMatch(SalaryCalcResult::isStatus);
// if (!allSuccess) {
// // 薪资核算实现的线程的错误信息
// String errorMsg = blockingDeque.stream()
// .filter(result -> !result.isStatus())
// .map(SalaryCalcResult::getErrMsg)
// .collect(Collectors.joining("|"));
// // 返回错误信息
// throw new SalaryRunTimeException("薪资核算失败:" + errorMsg);
// }
// // 删除历史数据
// if (CollectionUtils.isNotEmpty(salaryAcctEmployeeIds)) {
// salaryAcctResultValueService.deleteBySalaryAcctEmployeeIds(salaryAcctEmployeeIds, tenantKey);
// } else {
// salaryAcctResultValueService.deleteBySalaryAcctRecordIds(Collections.singleton(salaryAcctRecordId), tenantKey);
// }
// // 保存新数据
// List<SalaryAcctResultValuePO> salaryAcctResultValues = Lists.newArrayList();
// for (SalaryCalcResult salaryCalcResult : blockingDeque) {
// salaryAcctResultValues.addAll(salaryCalcResult.getSalaryAcctResultValues());
// }
// salaryAcctResultValueService.batchSave(salaryAcctResultValues, tenantKey);
// }
//
// private void writeLog(Long salaryAcctRecordId, String tenantKey) {
// String targetName = salaryAcctRecordService.getLogTargetNameById(salaryAcctRecordId, tenantKey);
// LoggerContext<SalaryCheckResultPO> loggerContext = new LoggerContext<>();
// loggerContext.setTargetId(String.valueOf(salaryAcctRecordId));
// loggerContext.setTargetName(targetName);
// loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue());
// loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(95783, "薪资核算"));
// loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(95783, "薪资核算"));
// salaryAcctRecordLoggerTemplate.write(loggerContext);
// }
//}

View File

@ -0,0 +1,51 @@
package com.engine.salary.service.impl;
import com.cloudstore.dev.api.util.Util_DataCache;
import com.engine.core.impl.Service;
import com.engine.salary.service.SalaryCacheService;
import com.engine.salary.util.JsonUtil;
import org.apache.commons.lang3.StringUtils;
import weaver.general.Util;
public class SalaryCacheServiceImpl extends Service implements SalaryCacheService {
@Override
public <T> void set(String key, T value) {
Util_DataCache.setObjVal(key, value);
}
@Override
public <T> void set(String key, T value, int time) {
Util_DataCache.setObjVal(key, value, time);
}
@Override
public <T> void setJson(String key, T value) {
Util_DataCache.setObjVal(key, JsonUtil.toJsonString(value));
}
@Override
public <T> void setJson(String key, T value, int time) {
Util_DataCache.setObjVal(key, JsonUtil.toJsonString(value), time);
}
@Override
public <T> T get(String key) {
return (T) Util_DataCache.getObjVal(key);
}
@Override
public <T> T getJson(String key, Class<T> clazz) {
String value = Util.null2String(Util_DataCache.getObjVal(key));
if (StringUtils.isEmpty(value)) {
return null;
}
return JsonUtil.parseObject(value, clazz);
}
@Override
public void remove(String key) {
Util_DataCache.clearVal(key);
}
}

View File

@ -292,4 +292,9 @@ public class SalaryFormulaServiceImpl extends Service implements SalaryFormulaSe
return formulaPO;
}
@Override
public void initFunction() {
}
}

View File

@ -1,5 +1,6 @@
package com.engine.salary.service.impl;
import com.cloudstore.dev.api.util.Util_DataCache;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.salary.biz.EmployBiz;
@ -9,26 +10,27 @@ import com.engine.salary.entity.hrm.HrmStatus;
import com.engine.salary.entity.hrm.PositionInfo;
import com.engine.salary.entity.hrm.SubCompanyInfo;
import com.engine.salary.entity.taxagent.bo.TaxAgentBO;
import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeEmployeeDTO;
import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeListDTO;
import com.engine.salary.entity.taxagent.param.*;
import com.engine.salary.entity.taxagent.po.TaxAgentManageRangePO;
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
import com.engine.salary.enums.UserStatusEnum;
import com.engine.salary.enums.salarysob.SalaryEmployeeStatusEnum;
import com.engine.salary.enums.salarysob.TargetTypeEnum;
import com.engine.salary.enums.taxagent.TaxAgentRangeTypeEnum;
import com.engine.salary.exception.SalaryRunTimeException;
import com.engine.salary.mapper.datacollection.EmployMapper;
import com.engine.salary.mapper.taxagent.TaxAgentManageRangeMapper;
import com.engine.salary.service.*;
import com.engine.salary.util.JsonUtil;
import com.engine.salary.service.TaxAgentEmpService;
import com.engine.salary.service.TaxAgentManageRangeService;
import com.engine.salary.service.TaxAgentService;
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 com.weaver.util.threadPool.ThreadPoolUtil;
import com.weaver.util.threadPool.entity.LocalRunnable;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
@ -80,17 +82,6 @@ public class TaxAgentManageRangeServiceImpl extends Service implements TaxAgentM
return getTaxAgentManageRangeMapper().listSome(TaxAgentManageRangePO.builder().rangeType(TaxAgentRangeTypeEnum.TAXAGENT.getValue()).taxAgentIds(taxAgentIds).build());
}
@Override
public List<TaxAgentManageRangeEmployeeDTO> listSalaryEmployeeByTaxAgentIds(List<Long> taxAgentIds) {
return listSalaryEmployeeByTaxAgentIds(null, taxAgentIds);
}
@Override
public List<TaxAgentManageRangeEmployeeDTO> listSalaryEmployeeByTaxAgentIds(SalaryEmployeeStatusEnum employeeStatus, List<Long> taxAgentIds) {
List<TaxAgentManageRangePO> allTaxAgentManageRanges = this.listByTaxAgentIds(taxAgentIds);
return convertTaxAgentEmployee(employeeStatus, taxAgentIds, allTaxAgentManageRanges);
}
@Override
public List<TaxAgentManageRangePO> listBySubAdminIds(Collection<Long> taxAgentSubAdminIds) {
if (CollectionUtils.isEmpty(taxAgentSubAdminIds)) {
@ -99,51 +90,15 @@ public class TaxAgentManageRangeServiceImpl extends Service implements TaxAgentM
return getTaxAgentManageRangeMapper().listSome(TaxAgentManageRangePO.builder().rangeType(TaxAgentRangeTypeEnum.SUBADMIN.getValue()).taxAgentSubAdminIds(taxAgentSubAdminIds).build());
}
@Override
public List<TaxAgentManageRangeEmployeeDTO> listSalaryEmployeeBySubAdminIds(List<Long> taxAgentIds) {
return listSalaryEmployeeBySubAdminIds(null, taxAgentIds);
}
@Override
public List<TaxAgentManageRangeEmployeeDTO> listSalaryEmployeeBySubAdminIds(SalaryEmployeeStatusEnum employeeStatus, List<Long> taxAgentSubAdminIds) {
List<TaxAgentManageRangePO> allTaxAgentManageRanges = this.listBySubAdminIds(taxAgentSubAdminIds);
List<Long> taxAgentIds = allTaxAgentManageRanges.stream().map(TaxAgentManageRangePO::getTaxAgentId).distinct().collect(Collectors.toList());
return convertTaxAgentEmployee(employeeStatus, taxAgentIds, allTaxAgentManageRanges);
}
private List<TaxAgentManageRangeEmployeeDTO> convertTaxAgentEmployee(SalaryEmployeeStatusEnum employeeStatus, List<Long> taxAgentIds, List<TaxAgentManageRangePO> allTaxAgentManageRanges) {
return taxAgentIds.stream().distinct().map(e -> {
// 获取范围下的人员
List<DataCollectionEmployee> salaryEmployees = getManageRangeSalaryEmployees(employeeStatus, e, allTaxAgentManageRanges);
if (CollectionUtils.isEmpty(salaryEmployees)) {
return null;
}
List<TaxAgentManageRangeEmployeeDTO.TaxAgentEmployee> taxAgentEmployees = salaryEmployees.stream().map(m -> {
TaxAgentManageRangeEmployeeDTO.TaxAgentEmployee taxAgentEmployee = new TaxAgentManageRangeEmployeeDTO.TaxAgentEmployee();
taxAgentEmployee.setEmployeeId(m.getEmployeeId());
taxAgentEmployee.setUsername(m.getUsername());
return taxAgentEmployee;
}).collect(Collectors.toList());
return TaxAgentManageRangeEmployeeDTO.builder()
.taxAgentId(e)
.taxAgentName("")
.employeeList(taxAgentEmployees)
.build();
}).filter(Objects::nonNull).collect(Collectors.toList());
}
/**
* 获取范围下的人员
*
* @param employeeStatus
* @param taxAgentId
* @param allTaxAgentManageRanges
* @param salaryEmployees
* @return
*/
private List<DataCollectionEmployee> getManageRangeSalaryEmployees(SalaryEmployeeStatusEnum employeeStatus, Long taxAgentId,
List<TaxAgentManageRangePO> allTaxAgentManageRanges) {
private List<DataCollectionEmployee> getManageRangeSalaryEmployees(Long taxAgentId, List<TaxAgentManageRangePO> allTaxAgentManageRanges, List<DataCollectionEmployee> salaryEmployees) {
List<TaxAgentManageRangePO> includeAllTaxAgentManageRanges = allTaxAgentManageRanges.stream().filter(f -> f.getIncludeType().equals(NumberUtils.INTEGER_ONE)).collect(Collectors.toList());
if (CollectionUtils.isEmpty(includeAllTaxAgentManageRanges)) {
return Collections.emptyList();
@ -155,19 +110,8 @@ public class TaxAgentManageRangeServiceImpl extends Service implements TaxAgentM
if (CollectionUtils.isEmpty(includeTaxAgentManageRanges)) {
return includeSalaryEmployees;
}
// 如果需要状态过滤
List<String> personnelStatuss = Lists.newArrayList();
if (employeeStatus != null) {
// 查询人员状态
// if (employeeStatus.equals(SalaryEmployeeStatusEnum.NORMAL)) {
// personnelStatuss = UserStatusEnum.getNormalStatus();
// } else if (employeeStatus.equals(SalaryEmployeeStatusEnum.UNAVAILABLE)) {
// personnelStatuss = UserStatusEnum.getUnavailableStatus();
// }
personnelStatuss.add(employeeStatus.getValue().toString());
}
// 根据上一步的查询参数查询人员
includeSalaryEmployees = listSalaryEmployeeByManageRange(includeTaxAgentManageRanges, personnelStatuss);
includeSalaryEmployees = listSalaryEmployeeByManageRange(includeTaxAgentManageRanges, salaryEmployees);
if (CollectionUtils.isEmpty(includeSalaryEmployees)) {
return includeSalaryEmployees;
}
@ -175,7 +119,7 @@ public class TaxAgentManageRangeServiceImpl extends Service implements TaxAgentM
List<TaxAgentManageRangePO> excludeTaxAgentManageRanges = excludeAllTaxAgentManageRanges.stream().filter(f -> f.getTaxAgentId().equals(taxAgentId)).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(excludeTaxAgentManageRanges)) {
// 根据上一步的查询参数查询人员
List<DataCollectionEmployee> excludeSalaryEmployees = listSalaryEmployeeByManageRange(excludeTaxAgentManageRanges, personnelStatuss);
List<DataCollectionEmployee> excludeSalaryEmployees = listSalaryEmployeeByManageRange(excludeTaxAgentManageRanges, salaryEmployees);
// 需要排除的人员范围
Set<Long> excludeEmployeeIds = SalaryEntityUtil.properties(excludeSalaryEmployees, DataCollectionEmployee::getEmployeeId);
// 过滤人员
@ -192,22 +136,15 @@ public class TaxAgentManageRangeServiceImpl extends Service implements TaxAgentM
* @param taxAgentManageRanges
* @return
*/
private List<DataCollectionEmployee> listSalaryEmployeeByManageRange(List<TaxAgentManageRangePO> taxAgentManageRanges, List<String> personnelStatuss) {
if (CollectionUtils.isEmpty(taxAgentManageRanges)) {
private List<DataCollectionEmployee> listSalaryEmployeeByManageRange(List<TaxAgentManageRangePO> taxAgentManageRanges, List<DataCollectionEmployee> salaryEmployees) {
if (CollectionUtils.isEmpty(taxAgentManageRanges) || CollectionUtils.isEmpty(salaryEmployees)) {
return Collections.emptyList();
}
List<DataCollectionEmployee> salaryEmployees = getEmployMapper().listAllFields();
List<DataCollectionEmployee> salaryEmployeeList = Lists.newArrayList();
for (TaxAgentManageRangePO manageRange : taxAgentManageRanges) {
salaryEmployeeList.addAll(salaryEmployees.stream()
.filter(salaryEmployee -> {
// 判断人员状态
List<String> hrmStatusList = JsonUtil.parseList(manageRange.getEmployeeStatus(), String.class);
// 有状态过滤则取交集
if (CollectionUtils.isNotEmpty(personnelStatuss)) {
hrmStatusList = hrmStatusList.stream().filter(personnelStatuss::contains).collect(Collectors.toList());
}
if (CollectionUtils.isNotEmpty(hrmStatusList) && !hrmStatusList.contains(salaryEmployee.getStatus())) {
if (StringUtils.isEmpty(manageRange.getEmployeeStatus()) || !manageRange.getEmployeeStatus().contains("\"" + salaryEmployee.getStatus() + "\"")) {
return false;
}
if (Objects.equals(manageRange.getTargetType(), TargetTypeEnum.ALL.getValue())) {
@ -376,7 +313,9 @@ public class TaxAgentManageRangeServiceImpl extends Service implements TaxAgentM
allRanges = allRanges.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(
Comparator.comparing(f -> f.getTaxAgentId() + "." + f.getRangeType() + "." + f.getTargetType() + "." + f.getTargetId() + "." + f.getEmployeeStatus() + "." + f.getIncludeType()))
), ArrayList::new));
List<DataCollectionEmployee> allSalaryEmployees = this.getManageRangeSalaryEmployees(null, saveParam.getTaxAgentId(), allRanges);
List<DataCollectionEmployee> salaryEmployees = getEmployMapper().listAll();
List<DataCollectionEmployee> allSalaryEmployees = this.getManageRangeSalaryEmployees(saveParam.getTaxAgentId(), allRanges, salaryEmployees);
/* 检查当前个税扣缴义务人的所有人员范围与所有分管理员的管理范围===========================end */
if (CollectionUtils.isNotEmpty(result.getNeedInsertTaxAgentManageRanges())) {
@ -414,7 +353,6 @@ public class TaxAgentManageRangeServiceImpl extends Service implements TaxAgentM
}
/**
* 根据分管理员id获取管理范围列表
*
@ -449,9 +387,11 @@ public class TaxAgentManageRangeServiceImpl extends Service implements TaxAgentM
List<TaxAgentManageRangePO> allRanges = allManageRanges.stream().filter(f -> f.getRangeType().equals(TaxAgentRangeTypeEnum.TAXAGENT.getValue())).collect(Collectors.toList());
List<TaxAgentManageRangePO> allSubAdminRanges = allManageRanges.stream().filter(f -> f.getRangeType().equals(TaxAgentRangeTypeEnum.SUBADMIN.getValue())).collect(Collectors.toList());
Long taxAgentId = taxAgentIds.get(0);
List<DataCollectionEmployee> allSalaryEmployees = this.getManageRangeSalaryEmployees(null, taxAgentId, allRanges);
List<DataCollectionEmployee> allSubAdminSalaryEmployees = this.getManageRangeSalaryEmployees(null, taxAgentId, allSubAdminRanges);
List<DataCollectionEmployee> salaryEmployees = getEmployMapper().listAll();
List<DataCollectionEmployee> allSalaryEmployees = this.getManageRangeSalaryEmployees(taxAgentId, allRanges, salaryEmployees);
List<DataCollectionEmployee> allSubAdminSalaryEmployees = this.getManageRangeSalaryEmployees(taxAgentId, allSubAdminRanges, salaryEmployees);
allSalaryEmployees.forEach(f -> {
allSubAdminSalaryEmployees.removeIf(a -> a.getEmployeeId().equals(f.getEmployeeId()));
});
@ -474,62 +414,41 @@ public class TaxAgentManageRangeServiceImpl extends Service implements TaxAgentM
getTaxAgentEmpService(user).deleteByTaxAgentIds(taxAgentIds);
}
@Override
public void deleteBySubAdmins(Collection<Long> subAdminIds) {
if (CollectionUtils.isEmpty(subAdminIds)) {
return;
}
getTaxAgentManageRangeMapper().deleteBySubAdminIds(subAdminIds);
// 删除管理范围下的所有人员
// taxAgentSubAdminEmployeeService.deleteBySubAdminIds(subAdminIds);
}
//fixme
// @AsyncListener(topic = "hrm_resource_queue")
// public void receiveHrmResourceQueue(AsyncBean<HrmCommonQueue> asyncBean) {
// log.info("接受到人员变动的结果:{}", JSONObject.toJSONString(asyncBean));
// // todo 过滤必要性事件类型进行处理,后续加上时间间隔避免人事批量操作时监听事件过多
// if (asyncBean == null || asyncBean.getMessage() == null) {
// log.error("接受到人员变动的结果失败");
// }
// String tenantKey = asyncBean.getMessage().getTenantKey();
// // 开始同步
// taskExecutor.execute(() -> {
// try {
// handleSyncTaxAgentEmpData();
// } finally {
// }
// });
// }
/**
* 同步处理所有人员范围
*
* @param
* @param taxAgentIds 为空代表所有个税扣缴义务人
*/
private void handleSyncTaxAgentEmpData() {
List<TaxAgentManageRangePO> allManageRanges = getTaxAgentManageRangeMapper().listAll();
private void handleSyncTaxAgentEmpData(List<Long> taxAgentIds) {
List<TaxAgentManageRangePO> allManageRanges = getTaxAgentManageRangeMapper().listSome(TaxAgentManageRangePO.builder().taxAgentIds(taxAgentIds).build());
if (CollectionUtils.isEmpty(allManageRanges)) {
return;
}
List<Long> taxAgentIds = allManageRanges.stream().map(m -> m.getTaxAgentId()).distinct().collect(Collectors.toList());
taxAgentIds = allManageRanges.stream().map(TaxAgentManageRangePO::getTaxAgentId).distinct().collect(Collectors.toList());
// 获取所有人员
List<DataCollectionEmployee> salaryEmployees = getEmployMapper().listAll();
List<TaxAgentEmpSaveParam> taxAgentEmpSaveParamList = Lists.newArrayList();
List<TaxAgentSubAdminEmpSaveParam> subAdminEmpSaveParamList = Lists.newArrayList();
Map<String, List<TaxAgentManageRangePO>> allRangeMap = SalaryEntityUtil.group2Map(allManageRanges, k -> k.getTaxAgentId() + "-" + k.getRangeType());
taxAgentIds.forEach(taxAgentId -> {
// 当前个税扣缴义务人的所有范围
List<TaxAgentManageRangePO> allRanges = allManageRanges.stream().filter(f -> f.getTaxAgentId().equals(taxAgentId) && f.getRangeType().equals(TaxAgentRangeTypeEnum.TAXAGENT.getValue())).collect(Collectors.toList());
List<DataCollectionEmployee> allSalaryEmployees = this.getManageRangeSalaryEmployees(null, taxAgentId, allRanges);
List<TaxAgentManageRangePO> allRanges = Optional.ofNullable(allRangeMap.get(taxAgentId + "-" + TaxAgentRangeTypeEnum.TAXAGENT.getValue())).orElse(Collections.emptyList());
List<DataCollectionEmployee> allSalaryEmployees = this.getManageRangeSalaryEmployees(taxAgentId, allRanges, salaryEmployees);
taxAgentEmpSaveParamList.add(getTaxAgentEmpSyncParam(taxAgentId, allSalaryEmployees));
List<TaxAgentManageRangePO> allSubAdminRanges = allManageRanges.stream().filter(f -> f.getTaxAgentId().equals(taxAgentId) && f.getRangeType().equals(TaxAgentRangeTypeEnum.SUBADMIN.getValue())).collect(Collectors.toList());
subAdminEmpSaveParamList.addAll(getTaxAgentSubAdminEmpSyncParam(taxAgentId, allSubAdminRanges));
List<TaxAgentManageRangePO> allSubAdminRanges = Optional.ofNullable(allRangeMap.get(taxAgentId + "-" + TaxAgentRangeTypeEnum.SUBADMIN.getValue())).orElse(Collections.emptyList());
subAdminEmpSaveParamList.addAll(getTaxAgentSubAdminEmpSyncParam(taxAgentId, allSubAdminRanges, salaryEmployees));
});
Long employeeId = 0L;
// 同步管理员的人员
getTaxAgentEmpService(user).syncTaxAgentEmployee(taxAgentEmpSaveParamList, employeeId);
// 同步分管理员的人员
// taxAgentSubAdminEmployeeService.syncTaxAgentSubAdminEmployee(subAdminEmpSaveParamList, employeeId);
// taxAgentSubAdminEmployeeService.syncTaxAgentSubAdminEmployee(subAdminEmpSaveParamList, employeeId, tenantKey);
}
/**
@ -551,14 +470,15 @@ public class TaxAgentManageRangeServiceImpl extends Service implements TaxAgentM
*
* @param taxAgentId
* @param allSubAdminRanges
* @param salaryEmployees
* @return
*/
private List<TaxAgentSubAdminEmpSaveParam> getTaxAgentSubAdminEmpSyncParam(Long taxAgentId, List<TaxAgentManageRangePO> allSubAdminRanges) {
private List<TaxAgentSubAdminEmpSaveParam> getTaxAgentSubAdminEmpSyncParam(Long taxAgentId, List<TaxAgentManageRangePO> allSubAdminRanges, List<DataCollectionEmployee> salaryEmployees) {
List<Long> allSubAdminIds = allSubAdminRanges.stream().map(TaxAgentManageRangePO::getTaxAgentSubAdminId).distinct().collect(Collectors.toList());
List<TaxAgentSubAdminEmpSaveParam> subAdminEmpSaveParamList = Lists.newArrayList();
allSubAdminIds.forEach(e -> {
List<TaxAgentManageRangePO> singSubAdminRanges = allSubAdminRanges.stream().filter(r -> e.equals(r.getTaxAgentSubAdminId())).collect(Collectors.toList());
List<DataCollectionEmployee> subAdminSalaryEmployees = this.getManageRangeSalaryEmployees(null, taxAgentId, singSubAdminRanges);
List<DataCollectionEmployee> subAdminSalaryEmployees = this.getManageRangeSalaryEmployees(taxAgentId, singSubAdminRanges, salaryEmployees);
subAdminEmpSaveParamList.add(TaxAgentSubAdminEmpSaveParam.builder()
.taxAgentId(taxAgentId)
@ -591,4 +511,28 @@ public class TaxAgentManageRangeServiceImpl extends Service implements TaxAgentM
log.error("同步个税扣缴人员范围异常", e);
}
}
/**
* 同步人员范围
*
* @param taxAgentIds
*/
@Override
public void syncManageRange(List<Long> taxAgentIds,String index) {
// 开始同步
LocalRunnable localRunnable = new LocalRunnable() {
@Override
public void execute() {
try {
Util_DataCache.setObjVal(index, "1");
handleSyncTaxAgentEmpData(taxAgentIds);
} finally {
Util_DataCache.clearVal(index);
}
}
};
ThreadPoolUtil.execute(localRunnable);
}
}

View File

@ -1,56 +1,26 @@
package com.engine.salary.timer;
import com.engine.common.util.ServiceUtil;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.taxagent.param.TaxAgentEmpSaveParam;
import com.engine.salary.entity.taxagent.po.TaxAgentManageRangePO;
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
import com.engine.salary.enums.salarysob.SalaryEmployeeStatusEnum;
import com.engine.salary.enums.salarysob.TargetTypeEnum;
import com.engine.salary.enums.taxagent.TaxAgentRangeTypeEnum;
import com.engine.salary.mapper.datacollection.EmployMapper;
import com.engine.salary.mapper.taxagent.TaxAgentManageRangeMapper;
import com.engine.salary.mapper.taxagent.TaxAgentMapper;
import com.engine.salary.service.TaxAgentEmpService;
import com.engine.salary.service.impl.TaxAgentEmpServiceImpl;
import com.engine.salary.util.JsonUtil;
import com.engine.salary.util.SalaryEntityUtil;
import com.engine.salary.util.db.MapperProxyFactory;
import com.google.common.collect.Lists;
import com.engine.salary.wrapper.TaxAgentWrapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.springframework.util.StopWatch;
import weaver.hrm.User;
import weaver.interfaces.schedule.BaseCronJob;
import java.util.*;
import java.util.stream.Collectors;
@Slf4j
public class SyncTaxAgentEmpJob extends BaseCronJob {
private TaxAgentMapper getTaxAgentMapper() {
return MapperProxyFactory.getProxy(TaxAgentMapper.class);
}
private TaxAgentManageRangeMapper getTaxAgentManageRangeMapper() {
return MapperProxyFactory.getProxy(TaxAgentManageRangeMapper.class);
}
private EmployMapper getEmployMapper() {
return MapperProxyFactory.getProxy(EmployMapper.class);
}
private TaxAgentEmpService getTaxAgentEmpService(User user) {
return ServiceUtil.getService(TaxAgentEmpServiceImpl.class, user);
private TaxAgentWrapper getTaxAgentWrapper(User user) {
return ServiceUtil.getService(TaxAgentWrapper.class, user);
}
@Override
public void execute() {
long time = System.currentTimeMillis();
log.info("计划任务【SyncTaxAgentEmpJob】开始执行");
StopWatch stopWatch = new StopWatch();
stopWatch.start("计划任务【SyncTaxAgentEmpJob】");
start();
log.info("计划任务【SyncTaxAgentEmpJob】执行结束用时" + (System.currentTimeMillis() - time));
stopWatch.stop();
log.info(stopWatch.prettyPrint());
}
@ -59,174 +29,9 @@ public class SyncTaxAgentEmpJob extends BaseCronJob {
*/
private void start() {
try {
//获取所以个税扣缴义务人
List<TaxAgentPO> taxAgentPOS = getTaxAgentMapper().listAll();
//执行同步
taxAgentPOS.forEach(taxAgent -> {
Long taxAgentId = taxAgent.getId();
// 查询已有的管理范围
List<TaxAgentManageRangePO> taxAgentManageAllRanges = getTaxAgentManageRangeMapper().listSome(TaxAgentManageRangePO.builder()
.taxAgentId(taxAgentId).rangeType(TaxAgentRangeTypeEnum.TAXAGENT.getValue()).build());
/* 检查当前个税扣缴义务人的所有人员范围与所有分管理员的管理范围===========================start */
List<TaxAgentManageRangePO> allRanges = Lists.newArrayList(taxAgentManageAllRanges);
// 去重
allRanges = allRanges.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(
Comparator.comparing(f -> f.getTaxAgentId() + "." + f.getRangeType() + "." + f.getTargetType() + "." + f.getTargetId() + "." + f.getEmployeeStatus() + "." + f.getIncludeType()))
), ArrayList::new));
List<DataCollectionEmployee> allSalaryEmployees = this.getManageRangeSalaryEmployees(null, taxAgentId, allRanges);
/* 同步本地人员范围的关联人员=========================== */
syncLocalEmp(taxAgentId, allSalaryEmployees, 0L);
});
getTaxAgentWrapper(null).syncAllRange();
} catch (Exception e) {
log.error("计划任务【SyncTaxAgentEmpJob】执行异常" + e);
}
}
/**
* 同步本地范围关联人员
*
* @param taxAgentId
* @param allSalaryEmployees 个税扣缴义务人下的所有人员
* @param employeeId
*/
private void syncLocalEmp(Long taxAgentId, List<DataCollectionEmployee> allSalaryEmployees, Long employeeId) {
try {
List<TaxAgentEmpSaveParam> taxAgentEmpSaveParamList = Collections.singletonList(getTaxAgentEmpSyncParam(taxAgentId, allSalaryEmployees));
// 同步个税扣缴义务人的人员
getTaxAgentEmpService(null).syncTaxAgentEmployee(taxAgentEmpSaveParamList, employeeId);
} catch (Exception e) {
log.error("同步个税扣缴人员范围异常", e);
}
}
/**
* 获取个税扣缴义务人的同步参数
*
* @param taxAgentId
* @param allSalaryEmployees
* @return
*/
private TaxAgentEmpSaveParam getTaxAgentEmpSyncParam(Long taxAgentId, List<DataCollectionEmployee> allSalaryEmployees) {
return TaxAgentEmpSaveParam.builder()
.taxAgentId(taxAgentId)
.salaryEmployeeList(allSalaryEmployees)
.build();
}
/**
* 获取范围下的人员
*
* @param employeeStatus
* @param taxAgentId
* @param allTaxAgentManageRanges
* @return
*/
private List<DataCollectionEmployee> getManageRangeSalaryEmployees(SalaryEmployeeStatusEnum employeeStatus, Long taxAgentId,
List<TaxAgentManageRangePO> allTaxAgentManageRanges) {
List<TaxAgentManageRangePO> includeAllTaxAgentManageRanges = allTaxAgentManageRanges.stream().filter(f -> f.getIncludeType().equals(NumberUtils.INTEGER_ONE)).collect(Collectors.toList());
if (CollectionUtils.isEmpty(includeAllTaxAgentManageRanges)) {
return Collections.emptyList();
}
List<TaxAgentManageRangePO> excludeAllTaxAgentManageRanges = allTaxAgentManageRanges.stream().filter(f -> f.getIncludeType().equals(NumberUtils.INTEGER_ZERO)).collect(Collectors.toList());
List<DataCollectionEmployee> includeSalaryEmployees = Lists.newArrayList();
List<TaxAgentManageRangePO> includeTaxAgentManageRanges = includeAllTaxAgentManageRanges.stream().filter(f -> f.getTaxAgentId().equals(taxAgentId)).collect(Collectors.toList());
if (CollectionUtils.isEmpty(includeTaxAgentManageRanges)) {
return includeSalaryEmployees;
}
// 如果需要状态过滤
List<String> personnelStatuss = Lists.newArrayList();
if (employeeStatus != null) {
// 查询人员状态
// if (employeeStatus.equals(SalaryEmployeeStatusEnum.NORMAL)) {
// personnelStatuss = UserStatusEnum.getNormalStatus();
// } else if (employeeStatus.equals(SalaryEmployeeStatusEnum.UNAVAILABLE)) {
// personnelStatuss = UserStatusEnum.getUnavailableStatus();
// }
personnelStatuss.add(employeeStatus.getValue().toString());
}
// 根据上一步的查询参数查询人员
includeSalaryEmployees = listSalaryEmployeeByManageRange(includeTaxAgentManageRanges, personnelStatuss);
if (CollectionUtils.isEmpty(includeSalaryEmployees)) {
return includeSalaryEmployees;
}
// 查询管理范围从范围中排除
List<TaxAgentManageRangePO> excludeTaxAgentManageRanges = excludeAllTaxAgentManageRanges.stream().filter(f -> f.getTaxAgentId().equals(taxAgentId)).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(excludeTaxAgentManageRanges)) {
// 根据上一步的查询参数查询人员
List<DataCollectionEmployee> excludeSalaryEmployees = listSalaryEmployeeByManageRange(excludeTaxAgentManageRanges, personnelStatuss);
// 需要排除的人员范围
Set<Long> excludeEmployeeIds = SalaryEntityUtil.properties(excludeSalaryEmployees, DataCollectionEmployee::getEmployeeId);
// 过滤人员
includeSalaryEmployees = includeSalaryEmployees.stream()
.filter(salaryEmployee -> !excludeEmployeeIds.contains(salaryEmployee.getEmployeeId()))
.collect(Collectors.toList());
}
return includeSalaryEmployees;
}
/**
* 根据范围加载人员
*
* @param taxAgentManageRanges
* @return
*/
private List<DataCollectionEmployee> listSalaryEmployeeByManageRange(List<TaxAgentManageRangePO> taxAgentManageRanges, List<String> personnelStatuss) {
if (CollectionUtils.isEmpty(taxAgentManageRanges)) {
return Collections.emptyList();
}
List<DataCollectionEmployee> salaryEmployees = getEmployMapper().listAllFields();
List<DataCollectionEmployee> salaryEmployeeList = Lists.newArrayList();
for (TaxAgentManageRangePO manageRange : taxAgentManageRanges) {
salaryEmployeeList.addAll(salaryEmployees.stream()
.filter(salaryEmployee -> {
// 判断人员状态
List<String> hrmStatusList = JsonUtil.parseList(manageRange.getEmployeeStatus(), String.class);
// 有状态过滤则取交集
if (CollectionUtils.isNotEmpty(personnelStatuss)) {
hrmStatusList = hrmStatusList.stream().filter(personnelStatuss::contains).collect(Collectors.toList());
}
if (CollectionUtils.isNotEmpty(hrmStatusList) && !hrmStatusList.contains(salaryEmployee.getStatus())) {
return false;
}
if (Objects.equals(manageRange.getTargetType(), TargetTypeEnum.ALL.getValue())) {
return true;
}
if (Objects.equals(manageRange.getTargetType(), TargetTypeEnum.EMPLOYEE.getValue())
&& Objects.equals(manageRange.getTargetId(), salaryEmployee.getEmployeeId())) {
return true;
}
if (Objects.equals(manageRange.getTargetType(), TargetTypeEnum.DEPT.getValue())
&& Objects.equals(manageRange.getTargetId(), salaryEmployee.getDepartmentId())) {
return true;
}
if (Objects.equals(manageRange.getTargetType(), TargetTypeEnum.SUBCOMPANY.getValue())
&& Objects.equals(manageRange.getTargetId(), salaryEmployee.getSubcompanyid())) {
return true;
}
if (Objects.equals(manageRange.getTargetType(), TargetTypeEnum.POSITION.getValue())
&& Objects.equals(manageRange.getTargetId(), salaryEmployee.getJobtitleId())) {
return true;
}
return false;
}).collect(Collectors.toList()));
}
// 去重
salaryEmployeeList = salaryEmployeeList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(DataCollectionEmployee::getEmployeeId))), ArrayList::new));
return salaryEmployeeList;
}
}

View File

@ -115,6 +115,19 @@ public class SalaryDateUtil {
}
}
public static String getFormatDate(Date localDate) {
if (localDate == null) {
return StringUtils.EMPTY;
}
try {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DATE_FORMATTER_PATTERN);
return simpleDateFormat.format(localDate);
} catch (Exception e) {
log.warn("格式化日期错误", e);
return StringUtils.EMPTY;
}
}
public static String getFormatLocalDate(LocalDateTime localDateTime) {
if (localDateTime == null) {
return StringUtils.EMPTY;

View File

@ -2,6 +2,8 @@ package com.engine.salary.web;
import com.engine.common.util.ParamUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.salary.entity.hrm.dto.HrmInfoDTO;
import com.engine.salary.entity.hrm.param.HrmQueryParam;
import com.engine.salary.entity.siaccount.dto.InsuranceAccountTabDTO;
import com.engine.salary.entity.siaccount.dto.InsuranceAccountViewListDTO;
import com.engine.salary.entity.siaccount.dto.InsuranceAcctDetailImportFieldDTO;
@ -612,4 +614,88 @@ public class SIAccountController {
}
// **********************************线下对比 end*********************************/
// **********************************退差 start*********************************/
/**
* 保存退差新增
*/
@POST
@Path("/saveRecession")
@Produces(MediaType.APPLICATION_JSON)
public String saveRecession(@Context HttpServletRequest request, @Context HttpServletResponse response,
@RequestBody RecessionParam param) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<RecessionParam, String>(user).run(getSIAccountWrapper(user)::saveRecession, param);
}
/**
* 删除退差
*/
@POST
@Path("/delRecession")
@Produces(MediaType.APPLICATION_JSON)
public String delRecession(@Context HttpServletRequest request, @Context HttpServletResponse response,
@RequestBody Collection<Long> ids) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<Collection<Long>, String>(user).run(getSIAccountWrapper(user)::delRecession, ids);
}
/**
* 获取退差列表
*
* @param request
* @param response
* @param insuranceAccountDetailParam
* @return
*/
@POST
@Path("/detail/recession/list")
@Produces(MediaType.APPLICATION_JSON)
public String listRecessionPage(@Context HttpServletRequest request, @Context HttpServletResponse response,
@RequestBody InsuranceAccountDetailParam insuranceAccountDetailParam) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<InsuranceAccountDetailParam, Map<String, Object>>(user).run(getService(user)::listRecessionPage, insuranceAccountDetailParam);
}
/**
* 通过id获取InsuranceAccountDetailPO中的社保公积金其他福利个人和公司缴纳数据
* @param request
* @param response
* @param id
* @return
*/
@GET
@Path("/getPaymentById")
@Produces(MediaType.APPLICATION_JSON)
public String getPaymentById(@Context HttpServletRequest request, @Context HttpServletResponse response,
@QueryParam("id") Long id) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<Long, Map<String, Object>>(user).run(getService(user)::getPaymentById, id);
}
/**
* 编辑InsuranceAccountDetailPO中的社保公积金其他福利个人和公司缴纳数据
*/
@POST
@Path("/editAccount")
@Produces(MediaType.APPLICATION_JSON)
public String editAccount(@Context HttpServletRequest request, @Context HttpServletResponse response,
@RequestBody EditAccountDetailParam param) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<EditAccountDetailParam, String>(user).run(getService(user)::editAccount, param);
}
/**
* 获取当前登录人所控制的人员范围
*/
@POST
@Path("/getEmployeeListByTaxAgent")
@Produces(MediaType.APPLICATION_JSON)
public String getEmployeeListByTaxAgent(@Context HttpServletRequest request, @Context HttpServletResponse response,
@RequestBody HrmQueryParam param) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<HrmQueryParam, PageInfo<HrmInfoDTO>>(user).run(getSIAccountWrapper(user)::getEmployeeListByTaxAgent, param);
}
// **********************************退差 end*********************************/
}

View File

@ -155,6 +155,32 @@ public class SIExportController {
return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build();
}
/**
* 福利台账-退差核算数据导出
*/
@GET
@Path("/recession/export")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response exportRecession(@Context HttpServletRequest request, @Context HttpServletResponse response,
@QueryParam("billMonth") String billMonth,@QueryParam("creator") Long creator,@QueryParam("paymentOrganization") String paymentOrganization) {
InsuranceExportParam param = InsuranceExportParam.builder().billMonth(billMonth).creator(creator).paymentOrganization(paymentOrganization).build();
User user = HrmUserVarify.getUser(request, response);
XSSFWorkbook workbook = getSIExportWrapper(user).exportAccount(PaymentStatusEnum.RECESSION.getValue(),param);
String time = LocalDate.now().toString();
String fileName = "退差核算报表" + time;
try {
fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
StreamingOutput output = outputStream -> {
workbook.write(outputStream);
outputStream.flush();
};
response.setContentType("application/octet-stream");
return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build();
}
@GET
@Path("/overView/export")
@Produces(MediaType.APPLICATION_OCTET_STREAM)

View File

@ -1,7 +1,10 @@
package com.engine.salary.web;
import com.engine.common.util.ServiceUtil;
import com.engine.salary.entity.taxagent.dto.*;
import com.engine.salary.entity.taxagent.dto.TaxAgentFormDTO;
import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeEmployeeDTO;
import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeFormDTO;
import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeListDTO;
import com.engine.salary.entity.taxagent.param.*;
import com.engine.salary.entity.taxagent.po.TaxAgentBasePO;
import com.engine.salary.util.ResponseResult;
@ -32,7 +35,7 @@ public class TaxAgentController {
private TaxAgentSubAdminWrapper getTaxAgentSubAdminWrapper(User user) {
return ServiceUtil.getService(TaxAgentSubAdminWrapper.class, user);
}
private TaxAgentWrapper getTaxAgentWrapper(User user) {
return ServiceUtil.getService(TaxAgentWrapper.class, user);
}
@ -50,6 +53,7 @@ public class TaxAgentController {
/**
* 权限信息
*
* @param request
* @param response
* @return
@ -284,6 +288,16 @@ public class TaxAgentController {
return new ResponseResult<Long, List<TaxAgentManageRangeEmployeeDTO>>(user).run(getTaxAgentWrapper(user)::getEmpListInTaxAgent, id);
}
//同步人员范围
@POST
@Path("/range/sync")
@Produces(MediaType.APPLICATION_JSON)
public String syncRange(@Context HttpServletRequest request, @Context HttpServletResponse response) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<Long, String>(user).run(getTaxAgentWrapper(user)::syncRange);
}
/* ******* 个税扣缴义务人 end ***********************************************************************************************/
/* ******* 分管理员 start ***********************************************************************************************/

View File

@ -2,12 +2,17 @@ package com.engine.salary.wrapper;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.salary.entity.siexport.param.InsuranceExportParam;
import com.engine.salary.service.SIExportService;
import com.engine.salary.service.impl.SIExportServiceImpl;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import com.engine.salary.entity.hrm.dto.HrmInfoDTO;
import com.engine.salary.entity.hrm.param.HrmQueryParam;
import com.engine.salary.entity.siaccount.param.RecessionParam;
import com.engine.salary.service.SIRecessionService;
import com.engine.salary.service.impl.SIRecessionServiceImpl;
import com.engine.salary.util.page.PageInfo;
import weaver.hrm.User;
import java.util.Collection;
/**
* @Author weaver_cl
* @Description: TODO
@ -15,6 +20,30 @@ import weaver.hrm.User;
* @Version V1.0
**/
public class SIAccountWrapper extends Service {
private SIRecessionService getSIRecessionService(User user) {
return (SIRecessionService) ServiceUtil.getService(SIRecessionServiceImpl.class, user);
}
/**
* 新增退差数据
* @param param 退差请求体
*/
public void saveRecession(RecessionParam param) {
long currentEmployeeId = user.getUID();
getSIRecessionService(user).save(param, currentEmployeeId);
}
/**
* 删除退差数据
* @param ids 表数据id集合
*/
public void delRecession(Collection<Long> ids) {
long currentEmployeeId = user.getUID();
getSIRecessionService(user).del(ids, currentEmployeeId);
}
public PageInfo<HrmInfoDTO> getEmployeeListByTaxAgent(HrmQueryParam param) {
return getSIRecessionService(user).getEmployeeListByTaxAgent(param);
}
}

View File

@ -1,7 +1,9 @@
package com.engine.salary.wrapper;
import com.cloudstore.dev.api.util.Util_DataCache;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.salary.cache.SalaryCacheKey;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.hrm.HrmStatus;
import com.engine.salary.entity.taxagent.bo.TaxAgentBO;
@ -22,6 +24,7 @@ import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.springframework.beans.BeanUtils;
import weaver.general.Util;
import weaver.hrm.User;
import java.util.*;
@ -350,10 +353,57 @@ public class TaxAgentWrapper extends Service {
/**
* 获取个税管理的人员情况
*
* @param id
* @return
*/
public List<TaxAgentManageRangeEmployeeDTO> getEmpListInTaxAgent(Long id) {
return getTaxAgentService(user).listTaxAgentAndEmployeeTree((long) user.getUID());
}
/**
* 同步当前人员管理的个税扣缴义务人人员范围
*
* @return
*/
public String syncRange() {
long currentEmployeeId = (long) user.getUID();
List<Long> taxAgentIds = this.getTaxAgentService(user).listAllTaxAgents(currentEmployeeId).stream().map(TaxAgentPO::getId).collect(Collectors.toList());
String index = SalaryCacheKey.TAX_AGENT_MANAGE_RANGE_SYNC + "-" + currentEmployeeId;
String syncRange = Util.null2String(Util_DataCache.getObjVal(index));
if (StringUtils.isEmpty(syncRange)) {
getTaxAgentManageRangeService(user).syncManageRange(taxAgentIds, index);
// try {
// TimeUnit.SECONDS.sleep(2);
// } catch (InterruptedException e) {
//
// }
} else {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(135788, "人员范围同步过于频繁,请稍后再试"));
}
return SalaryI18nUtil.getI18nLabel(93945, "同步成功");
}
/**
* 同步所有个税扣缴义务人的人员范围
*
* @return
*/
public String syncAllRange() {
String syncRange = Util.null2String(Util_DataCache.getObjVal(SalaryCacheKey.TAX_AGENT_MANAGE_RANGE_SYNC));
if (StringUtils.isEmpty(syncRange)) {
getTaxAgentManageRangeService(user).syncManageRange(null, SalaryCacheKey.TAX_AGENT_MANAGE_RANGE_SYNC);
// try {
// TimeUnit.SECONDS.sleep(2);
// } catch (InterruptedException e) {
//
// }
} else {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(135788, "人员范围同步过于频繁,请稍后再试"));
}
return SalaryI18nUtil.getI18nLabel(93945, "同步成功");
}
}

View File

@ -4,9 +4,6 @@ import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.salary.biz.EmployBiz;
import com.engine.salary.component.WeaFormOption;
import com.engine.salary.encrypt.datacollection.AddUpSituationEncrypt;
import com.engine.salary.encrypt.taxdeclaration.TaxDeclarationDetailPOEncrypt;
import com.engine.salary.entity.datacollection.AddUpSituation;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
import com.engine.salary.entity.taxdeclaration.bo.TaxDeclarationBO;
@ -15,7 +12,6 @@ import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationInfoDTO;
import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationListDTO;
import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationListQueryParam;
import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationSaveParam;
import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationDetailPO;
import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationPO;
import com.engine.salary.exception.SalaryRunTimeException;
import com.engine.salary.service.TaxAgentService;