累计专项附加扣除模块

This commit is contained in:
钱涛 2024-09-20 15:58:05 +08:00
parent 63a9e9caf8
commit 7ea6278e4e
7 changed files with 48 additions and 62 deletions

View File

@ -96,7 +96,9 @@ public class AddUpDeductionBiz extends BaseBean {
try {
AddUpDeductionMapper mapper = sqlSession.getMapper(AddUpDeductionMapper.class);
List<AddUpDeductionRecordDTO> addUpDeductionRecordStrDTOS = mapper.recordList(param);
return encryptUtil.decryptList(addUpDeductionRecordStrDTOS, AddUpDeductionRecordDTO.class);
encryptUtil.decryptList(addUpDeductionRecordStrDTOS, AddUpDeductionRecordDTO.class);
SalaryI18nUtil.i18nList(addUpDeductionRecordStrDTOS);
return addUpDeductionRecordStrDTOS;
} finally {
sqlSession.close();
}

View File

@ -37,15 +37,15 @@ public class AuthRoleDTO {
*/
private List<SalarySobPO> sobIds;
@TableTitle(title = "资源", dataIndex = "resources", key = "resources")
private Integer resources;
@TableTitle(title = "成员", dataIndex = "members", key = "members")
private Integer members;
@TableTitle(title = "权限", dataIndex = "opts", key = "opts")
private Integer opts;
@TableTitle(title = "资源", dataIndex = "resources", key = "resources")
private Integer resources;
@TableTitle(title = "数据", dataIndex = "datas", key = "datas")
private Integer datas;

View File

@ -86,10 +86,9 @@ public interface AddUpDeductionService {
* 导出详情
*
* @param beLongEmployeeId
* @param isChief
* @param queryParam
*/
XSSFWorkbook exportDetail(Long beLongEmployeeId, boolean isChief, AddUpDeductionQueryParam queryParam);
XSSFWorkbook exportDetail(Long beLongEmployeeId, AddUpDeductionQueryParam queryParam);
/**
* 获取累计专项附加扣除数据
@ -155,5 +154,7 @@ public interface AddUpDeductionService {
* @return void
* @author lfc
*/
String autoAddAll(Date yearMonth, Boolean isAdmin, List<Long> taxAgentIds);
String autoAddAll(Date yearMonth, boolean isAdmin, List<Long> taxAgentIds);
List<AddUpDeductionDTO> listAuth(AddUpDeductionQueryParam param);
}

View File

@ -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<>();

View File

@ -6,6 +6,7 @@ import com.engine.salary.entity.salaryitem.dto.SalaryItemFormDTO;
import com.engine.salary.entity.salaryitem.dto.SalaryItemListDTO;
import com.engine.salary.entity.salaryitem.dto.SysSalaryItemListDTO;
import com.engine.salary.entity.salaryitem.param.*;
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
import com.engine.salary.exception.SalaryRunTimeException;
import com.engine.salary.util.ResponseResult;
import com.engine.salary.util.SalaryI18nUtil;
@ -72,7 +73,7 @@ public class SalaryItemController {
@Produces(MediaType.APPLICATION_JSON)
public String listAuth(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryItemSearchParam searchParam) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<SalaryItemSearchParam, List<SalaryItemListDTO>>(request, response, user).run(getSalaryItemWrapper(user)::listAuth, searchParam);
return new ResponseResult<SalaryItemSearchParam, List<SalaryItemPO>>(request, response, user).run(getSalaryItemWrapper(user)::listAuth, searchParam);
}

View File

@ -115,9 +115,8 @@ public class AddUpDeductionWrapper extends Service {
if (po == null) {
throw new SalaryRunTimeException(String.format(SalaryI18nUtil.getI18nLabel(100338, "累计专项附加扣除不存在") + "[id:%s]", id));
}
boolean isChief = getTaxAgentService(user).isChief((long) user.getUID());
return getAddUpDeductionService(user).exportDetail(po.getEmployeeId(), isChief, queryParam);
return getAddUpDeductionService(user).exportDetail(po.getEmployeeId(), queryParam);
}
/**
@ -168,12 +167,9 @@ public class AddUpDeductionWrapper extends Service {
public String autoAddAll(AddDeductionAutoAddParam param) {
Date yearMonth = param.getYearMonthDate();
if (isLog) {
log.info("一键累计, 操作人 「{}」", user.getUsername());
}
if (yearMonth == null) {
throw new SalaryRunTimeException("一键累计传入日期格式错误");
}
return getAddUpDeductionService(user).autoAddAll(yearMonth, null, param.getTaxAgentIds());
return getAddUpDeductionService(user).autoAddAll(yearMonth, false, param.getTaxAgentIds());
}
}

View File

@ -322,7 +322,7 @@ public class SalaryItemWrapper extends Service {
return getSalaryItemService(user).downloadTemplate(param);
}
public void listAuth(SalaryItemSearchParam param) {
getSalaryItemService(user).listByName(param.getName());
public List<SalaryItemPO> listAuth(SalaryItemSearchParam param) {
return getSalaryItemService(user).listByName(param.getName());
}
}