同步人员范围

This commit is contained in:
钱涛 2022-11-22 15:37:07 +08:00
parent 9a9a9cdaf3
commit 264edf1bf2
7 changed files with 173 additions and 154 deletions

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_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

@ -50,4 +50,7 @@ public interface EmployMapper {
List<DeptInfo> getDeptInfoList(@Param("departmentIds") List<Long> departmentIds);
List<SubCompanyInfo> getSubCompanyInfoList(@Param("subDepartmentIds") List<Long> subDepartmentIds);
List<DataCollectionEmployee> listAll();
}

View File

@ -232,6 +232,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,

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删除管理范围
@ -116,4 +74,6 @@ public interface TaxAgentManageRangeService {
* @param subAdminIds 分管理员列表
*/
void deleteBySubAdmins(Collection<Long> subAdminIds);
void syncManageRange(List<Long> taxAgentIds);
}

View File

@ -1,34 +1,37 @@
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;
import com.engine.salary.cache.SalaryCacheKey;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.hrm.DeptInfo;
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 +83,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 +91,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 +111,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 +120,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 +137,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 +314,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 +354,6 @@ public class TaxAgentManageRangeServiceImpl extends Service implements TaxAgentM
}
/**
* 根据分管理员id获取管理范围列表
*
@ -449,9 +388,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()));
});
@ -484,52 +425,41 @@ public class TaxAgentManageRangeServiceImpl extends Service implements TaxAgentM
// 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 +481,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 +522,29 @@ public class TaxAgentManageRangeServiceImpl extends Service implements TaxAgentM
log.error("同步个税扣缴人员范围异常", e);
}
}
/**
* 同步人员范围
*
* @param taxAgentIds
*/
@Override
public void syncManageRange(List<Long> taxAgentIds) {
String index = SalaryCacheKey.TAX_AGENT_MANAGE_RANGE_SYNC + user.getUID();
// 开始同步
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,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

@ -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,9 +24,11 @@ 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.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
@ -350,10 +354,36 @@ 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);
try {
TimeUnit.SECONDS.sleep(2);
} catch (InterruptedException e) {
}
} else {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(135788, "人员范围同步过于频繁,请稍后再试"));
}
return SalaryI18nUtil.getI18nLabel(93945, "同步成功");
}
}