|
|
|
|
@ -10,10 +10,10 @@ import com.api.formmode.mybatis.util.SqlProxyHandle;
|
|
|
|
|
import com.cloudstore.dev.api.util.Util_DataCache;
|
|
|
|
|
import com.engine.common.util.ServiceUtil;
|
|
|
|
|
import com.engine.core.impl.Service;
|
|
|
|
|
import com.engine.hrmelog.entity.dto.LoggerContext;
|
|
|
|
|
import com.engine.salary.biz.AddUpDeductionBiz;
|
|
|
|
|
import com.engine.salary.common.LocalDateRange;
|
|
|
|
|
import com.engine.salary.config.SalaryElogConfig;
|
|
|
|
|
import com.engine.hrmelog.entity.dto.LoggerContext;
|
|
|
|
|
import com.engine.salary.encrypt.EncryptUtil;
|
|
|
|
|
import com.engine.salary.entity.datacollection.AddUpDeduction;
|
|
|
|
|
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
|
|
|
|
|
@ -26,8 +26,6 @@ import com.engine.salary.entity.datacollection.param.AddUpDeductionRecordParam;
|
|
|
|
|
import com.engine.salary.entity.datacollection.po.SpecialAddDeductionPO;
|
|
|
|
|
import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO;
|
|
|
|
|
import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO;
|
|
|
|
|
import com.engine.salary.entity.taxagent.bo.TaxAgentBO;
|
|
|
|
|
import com.engine.salary.entity.taxagent.dto.TaxAgentEmployeeDTO;
|
|
|
|
|
import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeEmployeeDTO;
|
|
|
|
|
import com.engine.salary.entity.taxagent.param.TaxAgentQueryParam;
|
|
|
|
|
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
|
|
|
|
|
@ -646,8 +644,10 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
|
|
|
|
|
long currentEmployeeId = user.getUID();
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
// 获取所有个税扣缴义务人
|
|
|
|
|
Collection<TaxAgentManageRangeEmployeeDTO> taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId);
|
|
|
|
|
List<Long> taxAgentIds = taxAgentList.stream().map(TaxAgentManageRangeEmployeeDTO::getTaxAgentId).collect(Collectors.toList());
|
|
|
|
|
TaxAgentQueryParam param = TaxAgentQueryParam.builder().build();
|
|
|
|
|
param.setFilterType(AuthFilterTypeEnum.ADMIN_DATA);
|
|
|
|
|
Collection<TaxAgentPO> taxAgentList = getTaxAgentService(user).listAuth(param);
|
|
|
|
|
List<Long> taxAgentIds = SalaryEntityUtil.properties(taxAgentList, TaxAgentPO::getId, Collectors.toList());
|
|
|
|
|
AddUpDeductionBiz addUpDeductionBiz = new AddUpDeductionBiz();
|
|
|
|
|
ArrayList<Date> declareMonthDate = new ArrayList<>();
|
|
|
|
|
try {
|
|
|
|
|
@ -659,10 +659,6 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
|
|
|
|
|
if (deleteParam.getTaxAgentId() != null && (!deleteParam.getTaxAgentId().equals(""))) {
|
|
|
|
|
// 设置了个税扣缴义务人
|
|
|
|
|
Long taxAgentId = SalaryEntityUtil.string2Long(deleteParam.getTaxAgentId());
|
|
|
|
|
boolean canDelete = taxAgentIds.stream().anyMatch(t -> Objects.equals(t, taxAgentId));
|
|
|
|
|
if (!canDelete) {
|
|
|
|
|
throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内!");
|
|
|
|
|
}
|
|
|
|
|
ArrayList<Long> tai = new ArrayList<>();
|
|
|
|
|
tai.add(taxAgentId);
|
|
|
|
|
queryParam = AddUpDeductionQueryParam.builder().declareMonthDate(declareMonthDate).taxAgentIds(tai).build();
|
|
|
|
|
@ -670,7 +666,9 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
|
|
|
|
|
queryParam = AddUpDeductionQueryParam.builder().declareMonthDate(declareMonthDate).taxAgentIds(taxAgentIds).build();
|
|
|
|
|
}
|
|
|
|
|
// 获取所有想要删除的数据
|
|
|
|
|
List<AddUpDeductionDTO> list = addUpDeductionBiz.list(queryParam);
|
|
|
|
|
queryParam.setFilterType(AuthFilterTypeEnum.ADMIN_DATA);
|
|
|
|
|
List<AddUpDeductionDTO> list = listAuth(queryParam);
|
|
|
|
|
|
|
|
|
|
// 获取已经核算的数据
|
|
|
|
|
List<SalaryAcctEmployeePO> salaryAcctEmployees = getAccountedEmployeeDataByTaxYearMonth(declareMonthStr);
|
|
|
|
|
for (AddUpDeductionDTO item : list) {
|
|
|
|
|
@ -686,7 +684,7 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
|
|
|
|
|
|
|
|
|
|
// 记录日志
|
|
|
|
|
Collection<Long> finalTaxAgentIds = queryParam.getTaxAgentIds();
|
|
|
|
|
List<String> taxAgentNames = taxAgentList.stream().filter(t -> finalTaxAgentIds.contains(t.getTaxAgentId())).map(TaxAgentManageRangeEmployeeDTO::getTaxAgentName).collect(Collectors.toList());
|
|
|
|
|
List<String> taxAgentNames = taxAgentList.stream().filter(t -> finalTaxAgentIds.contains(t.getId())).map(TaxAgentPO::getName).collect(Collectors.toList());
|
|
|
|
|
String name = declareMonthStr + " " + StringUtils.join(taxAgentNames, ",");
|
|
|
|
|
LoggerContext<AddUpDeduction> loggerContext = new LoggerContext<>();
|
|
|
|
|
loggerContext.setUser(user);
|
|
|
|
|
@ -710,7 +708,7 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String autoAddAll(Date yearMonth, Boolean isAdmin, List<Long> taxAgentIds) {
|
|
|
|
|
public String autoAddAll(Date yearMonth, boolean isAdmin, List<Long> taxAgentIds) {
|
|
|
|
|
String cacheKey = "addUpDeduction_autoAddAll_processing";
|
|
|
|
|
Object objVal = Util_DataCache.getObjVal(cacheKey);
|
|
|
|
|
if (objVal != null) {
|
|
|
|
|
@ -719,12 +717,13 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
|
|
|
|
|
try {
|
|
|
|
|
Util_DataCache.setObjVal(cacheKey, true);
|
|
|
|
|
//如果是定时任务直接查询所有,isAdmin传true
|
|
|
|
|
boolean isChief = Boolean.TRUE.equals(isAdmin) || getTaxAgentService(user).isChief((long) user.getUID());
|
|
|
|
|
Collection<TaxAgentPO> taxAgents;
|
|
|
|
|
if (isChief) {
|
|
|
|
|
if (isAdmin) {
|
|
|
|
|
taxAgents = getTaxAgentService(user).listAll();
|
|
|
|
|
} else {
|
|
|
|
|
taxAgents = getTaxAgentService(user).listAllTaxAgentsAsAdmin((long) user.getUID());
|
|
|
|
|
TaxAgentQueryParam param = TaxAgentQueryParam.builder().build();
|
|
|
|
|
param.setFilterType(AuthFilterTypeEnum.ADMIN_DATA);
|
|
|
|
|
taxAgents = getTaxAgentService(user).listAuth(param);
|
|
|
|
|
}
|
|
|
|
|
// 过滤个税扣缴义务人选择框
|
|
|
|
|
if (CollectionUtils.isNotEmpty(taxAgentIds)) {
|
|
|
|
|
@ -829,6 +828,15 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<AddUpDeductionDTO> listAuth(AddUpDeductionQueryParam param) {
|
|
|
|
|
List<AddUpDeductionDTO> list = getAddUpDeductionMapper().list(param);
|
|
|
|
|
list = getAuthService(user).auth(list, param.getFilterType(), AddUpDeductionDTO.class);
|
|
|
|
|
encryptUtil.decryptList(list, AddUpDeductionDTO.class);
|
|
|
|
|
SalaryI18nUtil.i18nList(list);
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 对每个扣除项做加法
|
|
|
|
|
*
|
|
|
|
|
@ -928,8 +936,9 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
|
|
|
|
|
OrderRuleVO orderRule = getSalarySysConfService(user).orderRule();
|
|
|
|
|
queryParam.setOrderRule(orderRule);
|
|
|
|
|
|
|
|
|
|
List<AddUpDeductionDTO> list = getAddUpDeductionMapper().list(queryParam);
|
|
|
|
|
list = getAuthService(user).auth(list, AuthFilterTypeEnum.DATA_OPT, AddUpDeductionDTO.class);
|
|
|
|
|
queryParam.setFilterType(AuthFilterTypeEnum.DATA_OPT);
|
|
|
|
|
List<AddUpDeductionDTO> list = listAuth(queryParam);
|
|
|
|
|
|
|
|
|
|
PageInfo<AddUpDeductionDTO> pageInfo = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), list, AddUpDeductionDTO.class);
|
|
|
|
|
encryptUtil.decryptList(pageInfo.getList(), AddUpDeductionDTO.class);
|
|
|
|
|
return pageInfo;
|
|
|
|
|
@ -961,7 +970,7 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public XSSFWorkbook exportDetail(Long beLongEmployeeId, boolean isChief, AddUpDeductionQueryParam queryParam) {
|
|
|
|
|
public XSSFWorkbook exportDetail(Long beLongEmployeeId, AddUpDeductionQueryParam queryParam) {
|
|
|
|
|
queryParam.setEmployeeId(beLongEmployeeId);
|
|
|
|
|
AddUpDeductionBiz biz = new AddUpDeductionBiz();
|
|
|
|
|
|
|
|
|
|
@ -991,7 +1000,7 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获取操作按钮资源
|
|
|
|
|
List<List<Object>> rowList = getExcelRowDetailList(isChief, queryParam);
|
|
|
|
|
List<List<Object>> rowList = getExcelRowDetailList(queryParam);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获取excel
|
|
|
|
|
@ -1005,8 +1014,7 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
|
|
|
|
|
* @param param
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private List<List<Object>> getExcelRowDetailList(boolean isChief, AddUpDeductionQueryParam param) {
|
|
|
|
|
long employeeId = user.getUID();
|
|
|
|
|
private List<List<Object>> getExcelRowDetailList(AddUpDeductionQueryParam param) {
|
|
|
|
|
|
|
|
|
|
//excel标题
|
|
|
|
|
List<Object> title = Arrays.asList("姓名", "申报月份", "个税扣缴义务人", "部门", "工号", "累计子女教育", "累计继续教育", "累计住房贷款利息", "累计住房租金", "累计赡养老人", "累计大病医疗", "累计婴幼儿照护");
|
|
|
|
|
@ -1034,19 +1042,6 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
|
|
|
|
|
}).collect(Collectors.toList())).orElse(Collections.emptyList());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 开启分权并且不是薪酬模块总管理员
|
|
|
|
|
if (getTaxAgentService(user).isOpenDevolution() && !isChief) {
|
|
|
|
|
List<TaxAgentEmployeeDTO> taxAgentEmployees = getTaxAgentService(user).listTaxAgentAndEmployee(employeeId);
|
|
|
|
|
List<Long> taxAgentIdsAsAdmin = getTaxAgentService(user).listAllTaxAgentsAsAdmin(employeeId).stream().map(TaxAgentPO::getId).collect(Collectors.toList());
|
|
|
|
|
// List<AddUpDeduction> lastList = getLastListByModifier(employeeId, tenantKey);
|
|
|
|
|
list = list.stream().filter(f ->
|
|
|
|
|
// 作为管理员
|
|
|
|
|
taxAgentIdsAsAdmin.contains(f.getTaxAgentId())
|
|
|
|
|
// 作为分管理员
|
|
|
|
|
|| TaxAgentBO.checkTaxAgentAndEmployee(taxAgentEmployees, f.getTaxAgentId(), f.getEmployeeId())).collect(Collectors.toList());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<List<Object>> rowList = new ArrayList<>();
|
|
|
|
|
rowList.add(title);
|
|
|
|
|
rowList.addAll(dataRowList);
|
|
|
|
|
@ -1075,6 +1070,7 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
|
|
|
|
|
List<List<Object>> rows = new ArrayList<>();
|
|
|
|
|
rows.add(headerList);
|
|
|
|
|
if (queryParam.isHasData()) {
|
|
|
|
|
queryParam.setFilterType(AuthFilterTypeEnum.ADMIN_DATA);
|
|
|
|
|
List<List<Object>> datas = getLists(queryParam);
|
|
|
|
|
rows.addAll(datas);
|
|
|
|
|
}
|
|
|
|
|
@ -1102,6 +1098,7 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
|
|
|
|
|
//excel标题
|
|
|
|
|
List<Object> title = Arrays.asList("姓名", "个税扣缴义务人", "部门", "手机号", "工号", "证件号码", "入职日期", "累计子女教育", "累计继续教育", "累计住房贷款利息", "累计住房租金", "累计赡养老人", "累计大病医疗", "累计婴幼儿照护");
|
|
|
|
|
|
|
|
|
|
queryParam.setFilterType(AuthFilterTypeEnum.QUERY_DATA);
|
|
|
|
|
List<List<Object>> dataRowList = getLists(queryParam);
|
|
|
|
|
|
|
|
|
|
List<List<Object>> rowList = new ArrayList<>();
|
|
|
|
|
@ -1130,18 +1127,7 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
|
|
|
|
|
OrderRuleVO orderRule = getSalarySysConfService(user).orderRule();
|
|
|
|
|
param.setOrderRule(orderRule);
|
|
|
|
|
|
|
|
|
|
List<AddUpDeductionDTO> list = new AddUpDeductionBiz().list(param);
|
|
|
|
|
|
|
|
|
|
// 开启分权并且不是薪酬模块总管理员
|
|
|
|
|
if (getTaxAgentService(user).isNeedAuth(uid)) {
|
|
|
|
|
List<TaxAgentEmployeeDTO> taxAgentEmployees = getTaxAgentService(user).listTaxAgentAndEmployee(uid);
|
|
|
|
|
List<Long> taxAgentIdsAsAdmin = getTaxAgentService(user).listAllTaxAgentsAsAdmin(uid).stream().map(TaxAgentPO::getId).collect(Collectors.toList());
|
|
|
|
|
list = list.stream().filter(f ->
|
|
|
|
|
// 作为管理员
|
|
|
|
|
taxAgentIdsAsAdmin.contains(f.getTaxAgentId())
|
|
|
|
|
// 作为分管理员
|
|
|
|
|
|| TaxAgentBO.checkTaxAgentAndEmployee(taxAgentEmployees, f.getTaxAgentId(), f.getEmployeeId())).collect(Collectors.toList());
|
|
|
|
|
}
|
|
|
|
|
List<AddUpDeductionDTO> list = listAuth(param);
|
|
|
|
|
|
|
|
|
|
List<List<Object>> dataRowList = Optional.ofNullable(list).map(List::stream).map(operatorStream -> operatorStream.map(dto -> {
|
|
|
|
|
List<Object> cellList = new ArrayList<>();
|
|
|
|
|
|