其他扣除

This commit is contained in:
钱涛 2022-05-31 11:21:51 +08:00
parent 0898055d77
commit 019ad96871
4 changed files with 83 additions and 143 deletions

View File

@ -69,7 +69,7 @@ public interface OtherDeductionService {
/**
* 预览
*/
Map<String, Object> preview(Map<String, Object> params);
Map<String, Object> preview(OtherDeductionImportParam importParam);
/**
* 导入数据

View File

@ -1,5 +1,6 @@
package com.engine.salary.service.impl;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.salary.biz.EmployBiz;
import com.engine.salary.biz.OtherDeductionBiz;
@ -39,6 +40,7 @@ import org.apache.poi.util.IOUtils;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import weaver.file.ImageFileManager;
import weaver.general.Util;
import weaver.hrm.User;
import java.io.InputStream;
import java.text.SimpleDateFormat;
@ -53,11 +55,16 @@ public class OtherDeductionServiceImpl extends Service implements OtherDeduction
private OtherDeductionMapper getOtherDeductionMapper() {
return MapperProxyFactory.getProxy(OtherDeductionMapper.class);
}
private OtherDeductionMapper otherDeductionMapper;
private TaxAgentV2Service taxAgentService;
private AddUpDeductionService addUpDeductionService;
private SalaryEmployeeService salaryEmployeeService;
private TaxAgentV2Service getTaxAgentV2Service(User user) {
return ServiceUtil.getService(TaxAgentV2ServiceImpl.class, user);
}
private AddUpDeductionService getAddUpDeductionService(User user) {
return ServiceUtil.getService(AddUpDeductionServiceImpl.class, user);
}
private SalaryEmployeeService getSalaryEmployeeService(User user) {
return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user);
}
@Override
public OtherDeductionPO getById(Long id) {
@ -69,15 +76,15 @@ public class OtherDeductionServiceImpl extends Service implements OtherDeduction
public PageInfo<OtherDeductionListDTO> listPage(OtherDeductionQueryParam queryParam) {
long employeeId = user.getUID();
// 未开启分权或是薪酬模块总管理员
if (!taxAgentService.isOpenDevolution() || taxAgentService.isChief(employeeId)) {
if (!getTaxAgentV2Service(user).isOpenDevolution() || getTaxAgentV2Service(user).isChief(employeeId)) {
SalaryPageUtil.start(queryParam.getCurrent(), queryParam.getPageSize());
List<OtherDeductionListDTO> list = otherDeductionMapper.list(queryParam);
List<OtherDeductionListDTO> list = getOtherDeductionMapper().list(queryParam);
return new PageInfo<>(list, OtherDeductionListDTO.class);
} else {
List<TaxAgentEmployeeDTO> taxAgentEmployees = taxAgentService.listTaxAgentAndEmployee(employeeId);
List<Long> taxAgentIdsAsAdmin = taxAgentService.listAllTaxAgentsAsAdmin(employeeId).stream().map(TaxAgentPO::getId).collect(Collectors.toList());
List<TaxAgentEmployeeDTO> taxAgentEmployees = getTaxAgentV2Service(user).listTaxAgentAndEmployee(employeeId);
List<Long> taxAgentIdsAsAdmin = getTaxAgentV2Service(user).listAllTaxAgentsAsAdmin(employeeId).stream().map(TaxAgentPO::getId).collect(Collectors.toList());
// List<OtherDeductionPO> lastList = getLastListByModifier(employeeId, tenantKey);
List<OtherDeductionListDTO> list = otherDeductionMapper.list(queryParam);
List<OtherDeductionListDTO> list = getOtherDeductionMapper().list(queryParam);
list = list.stream().filter(f ->
// 作为管理员
@ -97,15 +104,15 @@ public class OtherDeductionServiceImpl extends Service implements OtherDeduction
public PageInfo<OtherDeductionRecordDTO> recordListPage(OtherDeductionQueryParam queryParam) {
long employeeId = user.getUID();
// 未开启分权或是薪酬模块总管理员
if (!taxAgentService.isOpenDevolution() || taxAgentService.isChief(employeeId)) {
if (!getTaxAgentV2Service(user).isOpenDevolution() || getTaxAgentV2Service(user).isChief(employeeId)) {
SalaryPageUtil.start(queryParam.getCurrent(), queryParam.getPageSize());
List<OtherDeductionRecordDTO> list = otherDeductionMapper.recordList(queryParam);
List<OtherDeductionRecordDTO> list = getOtherDeductionMapper().recordList(queryParam);
return new PageInfo<>(list, OtherDeductionRecordDTO.class);
} else {
List<TaxAgentEmployeeDTO> taxAgentEmployees = taxAgentService.listTaxAgentAndEmployee(employeeId);
List<Long> taxAgentIdsAsAdmin = taxAgentService.listAllTaxAgentsAsAdmin(employeeId).stream().map(TaxAgentPO::getId).collect(Collectors.toList());
List<TaxAgentEmployeeDTO> taxAgentEmployees = getTaxAgentV2Service(user).listTaxAgentAndEmployee(employeeId);
List<Long> taxAgentIdsAsAdmin = getTaxAgentV2Service(user).listAllTaxAgentsAsAdmin(employeeId).stream().map(TaxAgentPO::getId).collect(Collectors.toList());
// List<OtherDeductionPO> lastList = getLastListByModifier(employeeId, tenantKey);
List<OtherDeductionRecordDTO> list = otherDeductionMapper.recordList(queryParam);
List<OtherDeductionRecordDTO> list = getOtherDeductionMapper().recordList(queryParam);
list = list.stream().filter(f ->
// 作为管理员
@ -122,11 +129,9 @@ public class OtherDeductionServiceImpl extends Service implements OtherDeduction
@Override
public Map<String, Object> preview(Map<String, Object> params) {
public Map<String, Object> preview(OtherDeductionImportParam importParam) {
Map<String, Object> apidatas = new HashMap<String, Object>();
//导入参数
OtherDeductionImportParam importParam = (OtherDeductionImportParam) params.get("importParam");
//excel文件id
String imageId = Util.null2String(importParam.getImageId());
Validate.notBlank(imageId, "imageId为空");
@ -174,13 +179,13 @@ public class OtherDeductionServiceImpl extends Service implements OtherDeduction
List<DataCollectionEmployee> employees = employBiz.listEmployee();
List<TaxAgent> taxAgents = new TaxAgentBiz().listAll();
// 获取所有个税扣缴义务人
Collection<TaxAgentManageRangeEmployeeDTO> taxAgentList = taxAgentService.listTaxAgentAndEmployeeTree(currentEmployeeId);
Collection<TaxAgentManageRangeEmployeeDTO> taxAgentList = getTaxAgentV2Service(user).listTaxAgentAndEmployeeTree(currentEmployeeId);
//税款所属期
Date declareMonth = SalaryDateUtil.stringToDate(declareMonthStr + "-01");
// 获取已经核算的数据
List<SalaryAcctEmployeePO> salaryAcctEmployees = addUpDeductionService.getAccountedEmployeeData(declareMonthStr);
List<SalaryAcctEmployeePO> salaryAcctEmployees = getAddUpDeductionService(user).getAccountedEmployeeData(declareMonthStr);
// 查询已有数据
List<OtherDeductionPO> list = otherDeductionMapper.listSome(OtherDeductionPO.builder().declareMonth(declareMonth).build());
List<OtherDeductionPO> list = getOtherDeductionMapper().listSome(OtherDeductionPO.builder().declareMonth(declareMonth).build());
// 错误excel内容
List<Map> errorData = new ArrayList<>();
@ -359,6 +364,7 @@ public class OtherDeductionServiceImpl extends Service implements OtherDeduction
}
}
/**
* 导出
*
@ -387,9 +393,9 @@ public class OtherDeductionServiceImpl extends Service implements OtherDeduction
List<OtherDeductionListDTO> list = getOtherDeductionMapper().list(param);
// 开启分权并且不是薪酬模块总管理员
if (taxAgentService.isOpenDevolution() && !taxAgentService.isChief(employeeId)) {
// List<TaxAgentEmployeeDTO> taxAgentEmployees = taxAgentService.listTaxAgentAndEmployee(employeeId);
List<Long> taxAgentIdsAsAdmin = taxAgentService.listAllTaxAgentsAsAdmin(employeeId).stream().map(TaxAgentPO::getId).collect(Collectors.toList());
if (getTaxAgentV2Service(user).isOpenDevolution() && !getTaxAgentV2Service(user).isChief(employeeId)) {
// List<TaxAgentEmployeeDTO> taxAgentEmployees = getTaxAgentV2Service(user).listTaxAgentAndEmployee(employeeId);
List<Long> taxAgentIdsAsAdmin = getTaxAgentV2Service(user).listAllTaxAgentsAsAdmin(employeeId).stream().map(TaxAgentPO::getId).collect(Collectors.toList());
list = list.stream().filter(f ->
// 作为管理员
taxAgentIdsAsAdmin.contains(f.getTaxAgentId())

View File

@ -1,12 +1,13 @@
package com.engine.salary.web;
import com.engine.common.util.ParamUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.salary.entity.datacollection.dto.OtherDeductionListDTO;
import com.engine.salary.entity.datacollection.dto.OtherDeductionRecordDTO;
import com.engine.salary.entity.datacollection.param.OtherDeductionImportParam;
import com.engine.salary.entity.datacollection.param.OtherDeductionQueryParam;
import com.engine.salary.service.OtherDeductionService;
import com.engine.salary.service.impl.OtherDeductionServiceImpl;
import com.engine.salary.util.ResponseResult;
import com.engine.salary.util.page.PageInfo;
import com.engine.salary.wrapper.OtherDeductionWrapper;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
@ -47,8 +48,8 @@ import java.util.stream.Collectors;
@Slf4j
public class OtherDeductionController {
private OtherDeductionService getService(User user) {
return (OtherDeductionService) ServiceUtil.getService(OtherDeductionServiceImpl.class, user);
private OtherDeductionWrapper getOtherDeductionWrapper(User user) {
return ServiceUtil.getService(OtherDeductionWrapper.class, user);
}
/**
@ -61,7 +62,7 @@ public class OtherDeductionController {
@Produces(MediaType.APPLICATION_JSON)
public String getSearchCondition(@Context HttpServletRequest request, @Context HttpServletResponse response) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<Map<String, Object>, Map<String, Object>>(user).run(getService(user)::getSearchCondition, ParamUtil.request2Map(request));
return new ResponseResult<Map<String, Object>, Map<String, Object>>(user).run(getOtherDeductionWrapper(user)::getSearchCondition);
}
@ -70,9 +71,7 @@ public class OtherDeductionController {
@Produces(MediaType.APPLICATION_JSON)
public String list(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody OtherDeductionQueryParam queryParam) {
User user = HrmUserVarify.getUser(request, response);
Map<String, Object> map = ParamUtil.request2Map(request);
map.put("queryParam", queryParam);
return new ResponseResult<Map<String, Object>, Map<String, Object>>(user).run(getService(user)::list, map);
return new ResponseResult<OtherDeductionQueryParam, PageInfo<OtherDeductionListDTO>>(user).run(getOtherDeductionWrapper(user)::list, queryParam);
}
@ -81,9 +80,7 @@ public class OtherDeductionController {
@Produces(MediaType.APPLICATION_JSON)
public String getDetailList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody OtherDeductionQueryParam queryParam) {
User user = HrmUserVarify.getUser(request, response);
Map<String, Object> map = ParamUtil.request2Map(request);
map.put("queryParam", queryParam);
return new ResponseResult<Map<String, Object>, Map<String, Object>>(user).run(getService(user)::getDetailList, map);
return new ResponseResult<OtherDeductionQueryParam, PageInfo<OtherDeductionRecordDTO>>(user).run(getOtherDeductionWrapper(user)::getDetailList, queryParam);
}
@ -94,7 +91,7 @@ public class OtherDeductionController {
try {
User user = HrmUserVarify.getUser(request, response);
OtherDeductionQueryParam param = buildParam(request);
XSSFWorkbook workbook = getService(user).downloadTemplate(param);
XSSFWorkbook workbook = getOtherDeductionWrapper(user).downloadTemplate(param);
String fileName = "其他免税扣除导入模板" + LocalDate.now();
try {
fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8");
@ -131,10 +128,7 @@ public class OtherDeductionController {
OtherDeductionQueryParam param = buildParam(request);
Map<String, Object> map = ParamUtil.request2Map(request);
map.put("queryParam", param);
XSSFWorkbook workbook = getService(user).export(map);
XSSFWorkbook workbook = getOtherDeductionWrapper(user).export(param);
String fileName = null;
try {
@ -168,10 +162,7 @@ public class OtherDeductionController {
OtherDeductionQueryParam param = buildParam(request);
Map<String, Object> map = ParamUtil.request2Map(request);
map.put("queryParam", param);
XSSFWorkbook workbook = getService(user).exportDetail(map);
XSSFWorkbook workbook = getOtherDeductionWrapper(user).exportDetail(param);
String fileName = "其他免税扣除明细" + LocalDate.now();
try {
@ -269,9 +260,7 @@ public class OtherDeductionController {
@Produces(MediaType.APPLICATION_JSON)
public String preview(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody OtherDeductionImportParam importParam) {
User user = HrmUserVarify.getUser(request, response);
Map<String, Object> map = ParamUtil.request2Map(request);
map.put("importParam", importParam);
return new ResponseResult<Map<String, Object>, Map<String, Object>>(user).run(getService(user)::preview, map);
return new ResponseResult<OtherDeductionImportParam, Map<String, Object>>(user).run(getOtherDeductionWrapper(user)::preview, importParam);
}
@POST
@ -279,9 +268,7 @@ public class OtherDeductionController {
@Produces(MediaType.APPLICATION_JSON)
public String importAddUpDeduction(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody OtherDeductionImportParam importParam) {
User user = HrmUserVarify.getUser(request, response);
Map<String, Object> map = ParamUtil.request2Map(request);
map.put("importParam", importParam);
return new ResponseResult<Map<String, Object>, Map<String, Object>>(user).run(getService(user)::importData, map);
return new ResponseResult<OtherDeductionImportParam, Map<String, Object>>(user).run(getOtherDeductionWrapper(user)::importData, importParam);
}

View File

@ -5,47 +5,46 @@ import com.api.browser.bean.SearchConditionItem;
import com.api.browser.bean.SearchConditionOption;
import com.api.browser.util.ConditionFactory;
import com.api.browser.util.ConditionType;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.salary.entity.datacollection.dto.OtherDeductionListDTO;
import com.engine.salary.entity.datacollection.dto.OtherDeductionRecordDTO;
import com.engine.salary.entity.datacollection.param.OtherDeductionImportParam;
import com.engine.salary.entity.datacollection.param.OtherDeductionQueryParam;
import com.engine.salary.entity.datacollection.po.OtherDeductionPO;
import com.engine.salary.exception.SalaryRunTimeException;
import com.engine.salary.service.OtherDeductionService;
import com.engine.salary.service.SalaryEmployeeService;
import com.engine.salary.service.TaxAgentV2Service;
import com.engine.salary.service.impl.OtherDeductionServiceImpl;
import com.engine.salary.service.impl.SalaryEmployeeServiceImpl;
import com.engine.salary.service.impl.TaxAgentV2ServiceImpl;
import com.engine.salary.util.SalaryI18nUtil;
import com.engine.salary.util.page.PageInfo;
import com.weaver.common.authority.format.FormatManager;
import com.weaver.common.component.table.WeaTable;
import com.weaver.common.component.table.page.Page;
import com.weaver.datasecurity.interceptor.DSTenantKeyThreadVar;
import com.weaver.framework.rpc.context.impl.TenantRpcContext;
import com.weaver.hrm.salary.common.excel.ExcelImportParam;
import com.weaver.teams.security.context.TenantContext;
import com.weaver.teams.security.context.UserContext;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Component;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import weaver.hrm.User;
import weaver.systeminfo.SystemEnv;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @Description: 其他免税扣除
* @Author: wangxiangzhong
* @Date: 2022/3/14 16:09
*/
@Component
public class OtherDeductionWrapper extends Service {
private OtherDeductionService otherDeductionService;
private TaxAgentV2Service taxAgentService;
private SalaryEmployeeService salaryEmployeeService;
private OtherDeductionService getOtherDeductionService(User user) {
return ServiceUtil.getService(OtherDeductionServiceImpl.class, user);
}
private TaxAgentV2Service getTaxAgentV2Service(User user) {
return ServiceUtil.getService(TaxAgentV2ServiceImpl.class, user);
}
private SalaryEmployeeService getSalaryEmployeeService(User user) {
return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user);
}
/**
* 数据采集-其他免税扣除列表的高级搜索
*
@ -139,7 +138,7 @@ public class OtherDeductionWrapper extends Service {
public PageInfo<OtherDeductionListDTO> list(OtherDeductionQueryParam queryParam) {
// queryParam.setDeclareMonthDate(queryParam.getDeclareMonth().stream().map(e-> LocalDate.of(e.getYear(),e.getMonthValue(),1)).collect(Collectors.toList()));
return otherDeductionService.listPage(queryParam);
return getOtherDeductionService(user).listPage(queryParam);
}
@ -152,114 +151,62 @@ public class OtherDeductionWrapper extends Service {
public PageInfo<OtherDeductionRecordDTO> getDetailList(OtherDeductionQueryParam queryParam) {
Long id = queryParam.getOtherTaxExemptDeductionId();
OtherDeductionPO po = otherDeductionService.getById(id);
OtherDeductionPO po = getOtherDeductionService(user).getById(id);
if (po == null) {
throw new SalaryRunTimeException(String.format(SalaryI18nUtil.getI18nLabel(100415, "其他免税扣除不存在") + "[id:%s]", id));
}
queryParam.setDeclareMonthDate(queryParam.getDeclareMonth().stream().map(e -> LocalDate.of(e.getYear(), e.getMonthValue(), 1)).collect(Collectors.toList()));
// queryParam.setDeclareMonthDate(queryParam.getDeclareMonth().stream().map(e -> LocalDate.of(e.getYear(), e.getMonthValue(), 1)).collect(Collectors.toList()));
queryParam.setEmployeeId(po.getEmployeeId());
Page<OtherDeductionRecordDTO> page = new Page<>(queryParam.getCurrent(), queryParam.getPageSize(), true);
page = otherDeductionService.recordListPage(page, queryParam, currentEmployeeId, currentTenantKey);
// 记录表格
WeaTable<OtherDeductionRecordDTO> weaTable = FormatManager.<OtherDeductionRecordDTO>getInstance()
.genTable(OtherDeductionRecordDTO.class, page);
weaTable.setModule("hrmsalary");
return weaTable;
return getOtherDeductionService(user).recordListPage(queryParam);
}
/**
* 导出-其他免税扣除列表
*
* @param queryParam
* @param currentEmployeeId
* @param currentTenantKey
* @return
*/
public Map<String, Object> export(OtherDeductionQueryParam queryParam, Long currentEmployeeId, String currentTenantKey) {
// 构建异步导出参数
Map<String, Object> map = salaryBatchService.buildeExportParam("exportOtherDeduction");
String username = UserContext.getCurrentUser().getUsername();
String eteamsId = TenantRpcContext.getEteamsId();
boolean isChief = taxAgentService.isChief(currentEmployeeId, currentTenantKey);
taskExecutor.execute(() -> {
try {
DSTenantKeyThreadVar.tenantKey.set(currentTenantKey);
otherDeductionService.export(map, username, eteamsId, isChief, queryParam, currentEmployeeId, currentTenantKey);
} finally {
DSTenantKeyThreadVar.tenantKey.remove();
}
});
return map;
public XSSFWorkbook export(OtherDeductionQueryParam queryParam) {
return getOtherDeductionService(user).export(queryParam);
}
/**
* 导出-其他免税扣除详情列表
*
* @param queryParam
* @param currentEmployeeId
* @param currentTenantKey
* @return
*/
public Map<String, Object> exportDetail(OtherDeductionQueryParam queryParam, Long currentEmployeeId, String currentTenantKey) {
public XSSFWorkbook exportDetail(OtherDeductionQueryParam queryParam) {
Long id = queryParam.getOtherTaxExemptDeductionId();
OtherDeductionPO po = otherDeductionService.getById(id, currentTenantKey);
OtherDeductionPO po = getOtherDeductionService(user).getById(id);
if (po == null) {
throw new SalaryRunTimeException(String.format(SalaryI18nUtil.getI18nLabel(currentTenantKey, currentEmployeeId, 100415, "其他免税扣除不存在") + "[id:%s]", id));
throw new SalaryRunTimeException(String.format(SalaryI18nUtil.getI18nLabel( 100415, "其他免税扣除不存在") + "[id:%s]", id));
}
boolean isChief = taxAgentService.isChief(currentEmployeeId, currentTenantKey);
// 构建异步导出参数
Map<String, Object> map = salaryBatchService.buildeExportParam("exportOtherDeductionDetail");
String username = UserContext.getCurrentUser().getUsername();
String eteamsId = TenantRpcContext.getEteamsId();
taskExecutor.execute(() -> {
try {
DSTenantKeyThreadVar.tenantKey.set(currentTenantKey);
otherDeductionService.exportDetail(map, username, eteamsId, po.getEmployeeId(), isChief, queryParam, currentEmployeeId, currentTenantKey);
} finally {
DSTenantKeyThreadVar.tenantKey.remove();
}
});
return map;
return getOtherDeductionService(user).exportDetail(queryParam);
}
/**
* 下载导入模板
*
* @param queryParam
* @param currentEmployeeId
* @param currentTenantKey
* @return
*/
public Map<String, Object> downloadTemplate(OtherDeductionQueryParam queryParam, Long currentEmployeeId, String currentTenantKey) {
// 构建异步导出参数
Map<String, Object> map = salaryBatchService.buildeExportParam("exportOtherDeduction");
boolean isChief = taxAgentService.isChief(currentEmployeeId, currentTenantKey);
String username = UserContext.getCurrentUser().getUsername();
String eteamsId = TenantRpcContext.getEteamsId();
taskExecutor.execute(() -> {
try {
DSTenantKeyThreadVar.tenantKey.set(currentTenantKey);
otherDeductionService.export(map, username, eteamsId, isChief, queryParam, currentEmployeeId, currentTenantKey);
} finally {
DSTenantKeyThreadVar.tenantKey.remove();
}
});
return map;
public XSSFWorkbook downloadTemplate(OtherDeductionQueryParam queryParam) {
return getOtherDeductionService(user).export(queryParam);
}
/**
* 获取导入参数
*
* @return
* 预览
*/
public ExcelImportParam getImportParams() {
return salaryBatchService.buildImportParam("importOtherDeduction",
"importOtherDeduction",
SalaryI18nUtil.getI18nLabel(TenantContext.getCurrentTenantKey(), UserContext.getCurrentEmployeeId(), 93849, "其他免税扣除"),
null,
null);
public Map<String, Object> preview(OtherDeductionImportParam importParam){
return getOtherDeductionService(user).preview(importParam);
}
/**
* 导入数据
*/
public Map<String, Object> importData(OtherDeductionImportParam importParam){
return getOtherDeductionService(user).importData(importParam);
}
}