feat: 专项附加扣除模块, 权限限制,导入导出优化,添加一键累计

This commit is contained in:
fcli 2022-11-07 16:20:21 +08:00
parent 9b77bf7139
commit 07a07d2be8
10 changed files with 207 additions and 138 deletions

View File

@ -166,6 +166,7 @@ public class SpecialAddDeductionBiz extends BaseBean {
.stream()
.filter(Objects::nonNull)
.filter(s -> s.getEmployeeId() != null)
.map(SpecialAddDeductionEncrypt::decrypt)
.collect(Collectors.toList());
}
}

View File

@ -84,19 +84,19 @@ public class SpecialAddDeductionListDTO {
private String hiredate;
//子女教育
@ExcelProperty(index = 10)
@ExcelProperty(index = 7)
@SalaryTableColumn(text = "子女教育", width = "10%", column = "childrenEducation")
@TableTitle(title = "子女教育", dataIndex = "childrenEducation", key = "childrenEducation")
private String childrenEducation;
//继续教育
@ExcelProperty(index = 10)
@ExcelProperty(index = 8)
@SalaryTableColumn(text = "继续教育", width = "10%", column = "continuingEducation")
@TableTitle(title = "继续教育", dataIndex = "continuingEducation", key = "continuingEducation")
private String continuingEducation;
//住房贷款利息
@ExcelProperty(index = 10)
@ExcelProperty(index = 9)
@SalaryTableColumn(text = "住房贷款利息", width = "10%", column = "housingLoanInterest")
@TableTitle(title = "住房贷款利息", dataIndex = "housingLoanInterest", key = "housingLoanInterest")
private String housingLoanInterest;
@ -108,19 +108,19 @@ public class SpecialAddDeductionListDTO {
private String housingRent;
//赡养老人
@ExcelProperty(index = 10)
@ExcelProperty(index = 11)
@SalaryTableColumn(text = "赡养老人", width = "10%", column = "supportingElder")
@TableTitle(title = "赡养老人", dataIndex = "supportingElder", key = "supportingElder")
private String supportingElder;
//大病医疗
@ExcelProperty(index = 10)
@ExcelProperty(index = 12)
@SalaryTableColumn(text = "大病医疗", width = "10%", column = "seriousIllnessTreatment")
@TableTitle(title = "大病医疗", dataIndex = "seriousIllnessTreatment", key = "seriousIllnessTreatment")
private String seriousIllnessTreatment;
//婴幼儿照护
@ExcelProperty(index = 10)
@ExcelProperty(index = 13)
@SalaryTableColumn(text = "婴幼儿照护", width = "10%", column = "infantCare")
@TableTitle(title = "婴幼儿照护", dataIndex = "infantCare", key = "infantCare")
private String infantCare;

View File

@ -564,7 +564,7 @@
<select id="getByEmployeeIds" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from hrsa_special_add_deduction
from hrsa_special_add_deduction t1
where
<if test="employeeIds == null or employeeIds.size() == 0">
1 = 2

View File

@ -12,6 +12,7 @@ import com.engine.salary.util.page.PageInfo;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.time.YearMonth;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -153,5 +154,5 @@ public interface AddUpDeductionService {
* @return void
* @author lfc
*/
void autoAddAll();
void autoAddAll(Date operateTime);
}

View File

@ -49,7 +49,7 @@ public interface SpecialAddDeductionService {
* 导出
*
*/
XSSFWorkbook export(SpecialAddDeductionQueryParam queryParam);
XSSFWorkbook export(SpecialAddDeductionQueryParam queryParam, boolean isTemplate);
/**
* 导出详情
@ -57,14 +57,6 @@ public interface SpecialAddDeductionService {
*/
XSSFWorkbook exportDetail(SpecialAddDeductionQueryParam queryParam);
/**
* 下载导入模板
*
* @param param
* @return
*/
XSSFWorkbook downloadTemplate(SpecialAddDeductionQueryParam param);
/**
* 预览
*/

View File

@ -1,5 +1,7 @@
package com.engine.salary.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.api.browser.bean.SearchConditionGroup;
import com.api.browser.bean.SearchConditionItem;
import com.api.browser.util.ConditionFactory;
@ -10,6 +12,7 @@ import com.engine.core.impl.Service;
import com.engine.salary.biz.AddUpDeductionBiz;
import com.engine.salary.biz.EmployBiz;
import com.engine.salary.common.LocalDateRange;
import com.engine.salary.encrypt.datacollection.AddUpDeductionEncrypt;
import com.engine.salary.encrypt.datacollection.AddUpDeductionRecordStrDTOEncrypt;
import com.engine.salary.encrypt.datacollection.AddUpDeductionStrDTOEncrypt;
import com.engine.salary.entity.datacollection.AddUpDeduction;
@ -58,6 +61,7 @@ import weaver.general.Util;
import weaver.hrm.User;
import java.io.InputStream;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
@ -66,6 +70,7 @@ import java.util.*;
import java.util.stream.Collectors;
import static com.engine.salary.constant.SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY;
/**
* 累计专项
* <p>Copyright: Copyright (c) 2022</p>
@ -101,11 +106,11 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
}
private SalarySysConfService getSalarySysConfService(User user) {
return ServiceUtil.getService(SalarySysConfServiceImpl.class, user);
return ServiceUtil.getService(SalarySysConfServiceImpl.class, user);
}
private SpecialAddDeductionService getSpecialAddDeductionService(User user) {
return ServiceUtil.getService(SpecialAddDeductionServiceImpl.class, user);
return ServiceUtil.getService(SpecialAddDeductionServiceImpl.class, user);
}
@Override
@ -289,7 +294,7 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
errorMessageMap.put("message", rowIndex + "员工信息不存在或者存在多个员工");
errorData.add(errorMessageMap);
errorSum += 1;
}else{
} else {
Long employeeId = CollectionUtils.isNotEmpty(employeeSameIds) && employeeSameIds.size() == 1 ? employeeSameIds.get(0).getEmployeeId() : null;
addUpDeduction.setEmployeeId(employeeId);
}
@ -407,12 +412,12 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
// 获取所有个税扣缴义务人
Collection<TaxAgentManageRangeEmployeeDTO> taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId);
AddUpDeduction byId = addUpDeductionBiz.getById(addUpDeduction.getId());
if(byId == null){
if (byId == null) {
throw new SalaryRunTimeException("该数据不存在!");
}
Long taxAgentId = byId.getTaxAgentId();
boolean canEdit = taxAgentList.stream().anyMatch(t -> t.getTaxAgentId() == taxAgentId);
if(!canEdit){
if (!canEdit) {
//没有编辑权限
throw new SalaryRunTimeException("该个税扣缴义务人无权限编辑此数据!");
}
@ -442,7 +447,7 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
//税款所属期
String declareMonthStr = addUpDeductionRecordParam.getDeclareMonth();
if(declareMonthStr == ""){
if (declareMonthStr == "") {
throw new SalaryRunTimeException("税款所属期不能为空!");
}
// 获取所有个税扣缴义务人
@ -491,7 +496,7 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
}
}
//fixme 分权判断
//fixme 分权判断
// if (openDevolution) {
// Optional<TaxAgentManageRangeEmployeeDTO.TaxAgentEmployee> optionalTaxAgentEmp = taxAgentEmployees.stream().filter(f -> f.getEmployeeId().equals(addUpDeduction.getEmployeeId())).findFirst();
// if (!optionalTaxAgentEmp.isPresent()) {
@ -547,15 +552,15 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
List<SalaryAcctEmployeePO> salaryAcctEmployees = getAccountedEmployeeData(declareMonthStr);
// 判断是否有核算过
List<Long> deleteList = new ArrayList<>();
for(int i=0; i<deleteIds.size(); i++){
for (int i = 0; i < deleteIds.size(); i++) {
Long id = deleteIds.get(i);
AddUpDeduction byId = addUpDeductionBiz.getById(id);
if(byId == null){
if (byId == null) {
throw new SalaryRunTimeException("数据不存在或已被删除!");
}
// 判断是否在个税扣缴义务人范围内
Optional<TaxAgentManageRangeEmployeeDTO> first = taxAgentList.stream().filter(m -> m.getTaxAgentId() == byId.getTaxAgentId()).findFirst();
if(!first.isPresent()){
if (!first.isPresent()) {
throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内");
}
// 判断用户是否存在
@ -581,33 +586,33 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
AddUpDeductionBiz addUpDeductionBiz = new AddUpDeductionBiz();
ArrayList<Date> declareMonthDate = new ArrayList<>();
try {
declareMonthDate.add(sdf.parse(declareMonthStr+"-01"));
}catch (Exception e){
declareMonthDate.add(sdf.parse(declareMonthStr + "-01"));
} catch (Exception e) {
throw new SalaryRunTimeException("日期异常");
}
AddUpDeductionQueryParam queryParam = null;
if(deleteParam.getTaxAgentId() != null && (!deleteParam.getTaxAgentId().equals(""))){
if (deleteParam.getTaxAgentId() != null && (!deleteParam.getTaxAgentId().equals(""))) {
// 设置了个税扣缴义务人
Long taxAgentId = SalaryEntityUtil.string2Long(deleteParam.getTaxAgentId());
boolean canDelete = taxAgentIds.stream().anyMatch(t -> t == taxAgentId);
if(!canDelete){
if (!canDelete) {
throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内!");
}
ArrayList<Long> tai = new ArrayList<>();
tai.add(taxAgentId);
queryParam = AddUpDeductionQueryParam.builder().declareMonthDate(declareMonthDate).taxAgentIds(tai).build();
}else {
queryParam = AddUpDeductionQueryParam.builder().declareMonthDate(declareMonthDate).taxAgentIds(tai).build();
} else {
queryParam = AddUpDeductionQueryParam.builder().declareMonthDate(declareMonthDate).taxAgentIds(taxAgentIds).build();
}
// 获取所有想要删除的数据
List<AddUpDeductionDTO> list = addUpDeductionBiz.list(queryParam);
// 获取已经核算的数据
List<SalaryAcctEmployeePO> salaryAcctEmployees = getAccountedEmployeeData(declareMonthStr);
for(AddUpDeductionDTO item : list){
for (AddUpDeductionDTO item : list) {
if (CollectionUtils.isNotEmpty(salaryAcctEmployees)) {
Optional<SalaryAcctEmployeePO> optionalAcctEmp = salaryAcctEmployees.stream().filter(f -> f.getEmployeeId().equals(item.getEmployeeId()) && f.getTaxAgentId().equals(item.getTaxAgentId())).findFirst();
if (optionalAcctEmp.isPresent()) {
throw new SalaryRunTimeException("员工:"+item.getUsername()+",在该年月中已完成核算并归档,不能进行一键清空!");
throw new SalaryRunTimeException("员工:" + item.getUsername() + ",在该年月中已完成核算并归档,不能进行一键清空!");
}
}
}
@ -625,33 +630,123 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
ids.add(param.getId());
AddUpDeductionQueryParam build = AddUpDeductionQueryParam.builder().ids(ids).build();
List<AddUpDeductionRecordDTO> addUpDeductionRecordDTOS = new AddUpDeductionBiz().recordList(build);
if(addUpDeductionRecordDTOS==null || addUpDeductionRecordDTOS.size()==0){
if (addUpDeductionRecordDTOS == null || addUpDeductionRecordDTOS.size() == 0) {
throw new SalaryRunTimeException("该数据不存在!");
}
String taxAgentName = addUpDeductionRecordDTOS.get(0).getTaxAgentName();
if(!taxAgentNames.contains(taxAgentName)){
if (!taxAgentNames.contains(taxAgentName)) {
throw new SalaryRunTimeException("您无权查看该数据!");
}
return addUpDeductionRecordDTOS.get(0);
}
@Override
public void autoAddAll() {
public void autoAddAll(Date operateTime) {
int uid = user.getUID();
Collection<TaxAgentPO> taxAgents = getTaxAgentService(user).listAllTaxAgentsAsAdmin((long) uid);
Boolean isChief = getTaxAgentService(user).isChief((long) uid);
Collection<TaxAgentPO> taxAgents;
if (isChief) {
taxAgents = getTaxAgentService(user).listAll();
} else {
taxAgents = getTaxAgentService(user).listAllTaxAgentsAsAdmin((long) uid);
}
for (TaxAgentPO taxAgent : taxAgents) {
Collection<Long> employeeIds = getTaxAgentService(user)
.listEmployeeIdsInTaxAgent(taxAgent.getId());
List<SpecialAddDeductionPO> employeePOs = getSpecialAddDeductionService(user)
.getSpecialAddDeductionPOByEmployee(new ArrayList<>(employeeIds), taxAgent.getId());
Map<Long, List<AddUpDeduction>> lastEmpInfo = getLastEmpInfo(taxAgent, employeePOs);
//获取上月员工数据用于累加
LocalDateTime lastMonthDateTime = LocalDateTime.now().minusMonths(1);
YearMonth lastMonth = YearMonth.of(lastMonthDateTime.getYear(), lastMonthDateTime.getMonth());
Map<Long, List<AddUpDeduction>> lastEmpInfo = getEmpInfoByYearMonth(taxAgent, employeePOs, lastMonth);
//获取当月员工数据用于更新
LocalDateTime currentMonthDateTime = LocalDateTime.now();
YearMonth currentMonth = YearMonth.of(currentMonthDateTime.getYear(), currentMonthDateTime.getMonth());
Map<Long, List<AddUpDeduction>> currentEmpInfo = getEmpInfoByYearMonth(taxAgent, employeePOs, currentMonth);
List<AddUpDeduction> updateList = new ArrayList<>();
List<AddUpDeduction> insertList = new ArrayList<>();
employeePOs.forEach(employeePO -> {
Long employeeId = employeePO.getEmployeeId();
AddUpDeduction addUpDeduction = Optional.ofNullable(lastEmpInfo.get(employeeId))
.flatMap(list -> list.stream().findFirst())
.orElseGet(AddUpDeduction::new);
this.combine(addUpDeduction, employeePO);
addUpDeduction.setEmployeeId(employeeId);
addUpDeduction.setTaxAgentId(taxAgent.getId());
addUpDeduction.setDeclareMonth(DateUtil.beginOfMonth(operateTime));
addUpDeduction.setCreator((long) user.getUID());
addUpDeduction.setTenantKey(DEFAULT_TENANT_KEY);
//确认当期是否有已经累计的记录
AddUpDeduction oldInfo = Optional.ofNullable(currentEmpInfo.get(employeeId))
.flatMap(c -> c.stream().findFirst())
.orElse(null);
if (oldInfo == null) {
addUpDeduction.setCreateTime(operateTime);
addUpDeduction.setUpdateTime(operateTime);
insertList.add(AddUpDeductionEncrypt.encryptAddUpDeduction(addUpDeduction));
} else {
addUpDeduction.setId(oldInfo.getId());
addUpDeduction.setCreateTime(oldInfo.getCreateTime());
addUpDeduction.setUpdateTime(operateTime);
updateList.add(AddUpDeductionEncrypt.encryptAddUpDeduction(addUpDeduction));
}
});
Lists.partition(insertList, 100)
.forEach(l -> getAddUpDeductionMapper().insertData((List<AddUpDeduction>) l));
Lists.partition(updateList, 100)
.forEach(l -> getAddUpDeductionMapper().updateData((List<AddUpDeduction>) l));
}
}
private Map<Long, List<AddUpDeduction>> getLastEmpInfo(TaxAgentPO taxAgent, List<SpecialAddDeductionPO> employeePOs) {
LocalDateTime lastMonthDateTime = LocalDateTime.now().minusMonths(1);
YearMonth lastMonth = YearMonth.of(lastMonthDateTime.getYear(), lastMonthDateTime.getMonth());
/**
* 对每个扣除项做加法
*
* @param addUpDeduction 上次记录
* @param employeePO 专项附加扣除值
*/
private void combine(AddUpDeduction addUpDeduction, SpecialAddDeductionPO employeePO) {
final String zero = "0";
String childEducation = Optional.ofNullable(addUpDeduction.getAddUpChildEducation()).orElse(zero);
addUpDeduction.setAddUpChildEducation(plus(childEducation, employeePO.getChildrenEducation()));
String continuingEducation = Optional.ofNullable(addUpDeduction.getAddUpContinuingEducation()).orElse(zero);
addUpDeduction.setAddUpContinuingEducation(plus(continuingEducation, employeePO.getContinuingEducation()));
String housingLoanInterest = Optional.ofNullable(addUpDeduction.getAddUpHousingLoanInterest()).orElse(zero);
addUpDeduction.setAddUpHousingLoanInterest(plus(housingLoanInterest, employeePO.getHousingLoanInterest()));
String housingRent = Optional.ofNullable(addUpDeduction.getAddUpHousingRent()).orElse(zero);
addUpDeduction.setAddUpHousingRent(plus(housingRent, employeePO.getHousingRent()));
String supportElderly = Optional.ofNullable(addUpDeduction.getAddUpSupportElderly()).orElse(zero);
addUpDeduction.setAddUpSupportElderly(plus(supportElderly, employeePO.getSupportingElder()));
String illnessMedical = Optional.ofNullable(addUpDeduction.getAddUpIllnessMedical()).orElse(zero);
addUpDeduction.setAddUpIllnessMedical(plus(illnessMedical, employeePO.getSeriousIllnessTreatment()));
String infantCare = Optional.ofNullable(addUpDeduction.getAddUpInfantCare()).orElse(zero);
addUpDeduction.setAddUpInfantCare(plus(infantCare, employeePO.getInfantCare()));
}
private String plus(String var0, String var1) {
if (StrUtil.isEmpty(var0)) {
var0 = "0";
}
if (StrUtil.isEmpty(var1)) {
var1 = "0";
}
return new BigDecimal(var0)
.add(new BigDecimal(var1))
.toString();
}
private Map<Long, List<AddUpDeduction>> getEmpInfoByYearMonth(TaxAgentPO taxAgent, List<SpecialAddDeductionPO> employeePOs, YearMonth lastMonth) {
List<AddUpDeduction> addUpDeductionList = getAddUpDeductionList(lastMonth,
employeePOs.stream().map(SpecialAddDeductionPO::getEmployeeId).collect(Collectors.toList()),
taxAgent.getId());
@ -935,7 +1030,7 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
}
List<AddUpDeductionDTO> list = new AddUpDeductionBiz().list(queryParam);
for(AddUpDeductionDTO dto : list) {
for (AddUpDeductionDTO dto : list) {
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("username", Util.null2String(dto.getUsername()));
resultMap.put("departmentName", Util.null2String(dto.getDepartmentName()));

View File

@ -29,12 +29,10 @@ import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl;
import com.engine.salary.util.SalaryEntityUtil;
import com.engine.salary.util.SalaryI18nUtil;
import com.engine.salary.util.db.MapperProxyFactory;
import com.engine.salary.util.excel.ExcelComment;
import com.engine.salary.util.excel.ExcelParseHelper;
import com.engine.salary.util.excel.ExcelUtil;
import com.engine.salary.util.page.PageInfo;
import com.engine.salary.util.page.SalaryPageUtil;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
@ -99,7 +97,7 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd
Boolean needAuth = getTaxAgentService(user).isNeedAuth(employeeId);
if (needAuth) {
putQueryRange(queryParam, employeeId);
putQueryRange(queryParam);
}
SalaryPageUtil.start(queryParam.getCurrent(), queryParam.getPageSize());
List<SpecialAddDeductionListDTO> list = getSpecialAddDeductionMapper().listByParam(queryParam);
@ -113,7 +111,7 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd
Boolean needAuth = getTaxAgentService(user).isNeedAuth(employeeId);
if (needAuth) {
putQueryRange(queryParam, employeeId);
putQueryRange(queryParam);
}
SalaryPageUtil.start(queryParam.getCurrent(), queryParam.getPageSize());
List<SpecialAddDeductionRecordDTO> list = getSpecialAddDeductionMapper().listDtoByParam(queryParam);
@ -122,7 +120,8 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd
return new PageInfo<>(list, SpecialAddDeductionRecordDTO.class);
}
private void putQueryRange(SpecialAddDeductionQueryParam queryParam, long employeeId) {
private void putQueryRange(SpecialAddDeductionQueryParam queryParam) {
Long employeeId = (long) user.getUID();
List<Long> taxAgentIdsAsAdmin = getTaxAgentService(user)
.listAllTaxAgentsAsAdmin(employeeId).stream().map(TaxAgentPO::getId)
.collect(Collectors.toList());
@ -155,7 +154,7 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd
try {
fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(imageId));
List<SpecialAddDeductionListDTO> SpecialAddDeductions =
ExcelParseHelper.parse2Map(fileInputStream, SpecialAddDeductionListDTO.class, 0, 1, 11,
ExcelParseHelper.parse2Map(fileInputStream, SpecialAddDeductionListDTO.class, 0, 1, 14,
"SpecialAddDeductionTemplate.xlsx");
apidatas.put("preview", SpecialAddDeductions);
} finally {
@ -306,14 +305,14 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd
}
}
// 核心字段
po.setInfantCare(dto.getInfantCare())
.setSeriousIllnessTreatment(dto.getSeriousIllnessTreatment())
.setSupportingElder(dto.getSupportingElder())
.setHousingRent(dto.getHousingRent())
.setHousingLoanInterest(dto.getHousingLoanInterest())
.setContinuingEducation(dto.getContinuingEducation())
.setChildrenEducation(dto.getChildrenEducation());
// 核心字段, 前端没有传入的项目用空值覆盖
po.setInfantCare(dto.getInfantCare() == null ? "" : dto.getInfantCare())
.setSeriousIllnessTreatment(dto.getSeriousIllnessTreatment() == null ? "" : dto.getSeriousIllnessTreatment())
.setSupportingElder(dto.getSupportingElder() == null ? "" : dto.getSupportingElder())
.setHousingRent(dto.getHousingRent() == null ? "" : dto.getHousingRent())
.setHousingLoanInterest(dto.getHousingLoanInterest() == null ? "" : dto.getHousingLoanInterest())
.setContinuingEducation(dto.getContinuingEducation() == null ? "" : dto.getContinuingEducation())
.setChildrenEducation(dto.getChildrenEducation() == null ? "" : dto.getChildrenEducation());
//fixme 分权判断
@ -355,15 +354,16 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd
* 导出
*
* @param param
* @param isTemplate
* @return
*/
public XSSFWorkbook export(SpecialAddDeductionQueryParam param) {
public XSSFWorkbook export(SpecialAddDeductionQueryParam param, boolean isTemplate) {
//获取操作按钮资源
List<List<String>> rowList = getExcelRowList(param);
List<List<String>> rowList = getExcelRowList(param, isTemplate);
//获取excel
return ExcelUtil.genWorkbook(rowList, "其他免税扣除");
return ExcelUtil.genWorkbook(rowList, "专项附加免税扣除");
}
@ -372,50 +372,18 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd
*
* @return 导出数据行集合
*/
private List<List<String>> getExcelRowList(SpecialAddDeductionQueryParam param) {
private List<List<String>> getExcelRowList(SpecialAddDeductionQueryParam param, boolean isTemplate) {
long employeeId = user.getUID();
//excel标题
List<String> title = Arrays.asList("姓名", "个税扣缴义务人", "部门", "手机号", "工号", "证件号码", "入职日期", "子女教育", "继续教育", "住房贷款利息", "住房租金", "赡养老人", "大病医疗", "婴幼儿照护");
//排序配置
OrderRuleVO orderRule = getSalarySysConfService(user).orderRule();
param.setOrderRule(orderRule);
List<SpecialAddDeductionListDTO> list = getSpecialAddDeductionBiz().listByParam(param);
// 开启分权并且不是薪酬模块总管理员
if (getTaxAgentService(user).isOpenDevolution() && !getTaxAgentService(user).isChief(employeeId)) {
List<Long> taxAgentIdsAsAdmin = getTaxAgentService(user).listAllTaxAgentsAsAdmin(employeeId).stream().map(TaxAgentPO::getId).collect(Collectors.toList());
list = list.stream().filter(f ->
// 作为管理员
taxAgentIdsAsAdmin.contains(f.getTaxAgentId())
).collect(Collectors.toList());
}
final List<List<String>> dataRowList = Optional.ofNullable(list)
.map(List::stream)
.map(operatorStream -> operatorStream.map(dto -> {
List<String> cellList = new ArrayList<>();
cellList.add(Util.null2String(dto.getUsername()));
cellList.add(Util.null2String(dto.getTaxAgentName()));
cellList.add(Util.null2String(dto.getDepartmentName()));
cellList.add(Util.null2String(dto.getMobile()));
cellList.add(Util.null2String(dto.getJobNum()));
cellList.add(Util.null2String(dto.getIdNo()));
cellList.add(Util.null2String(dto.getHiredate()));
cellList.add(Util.null2String(dto.getChildrenEducation()));
cellList.add(Util.null2String(dto.getContinuingEducation()));
cellList.add(Util.null2String(dto.getHousingLoanInterest()));
cellList.add(Util.null2String(dto.getHousingRent()));
cellList.add(Util.null2String(dto.getSupportingElder()));
cellList.add(Util.null2String(dto.getSeriousIllnessTreatment()));
cellList.add(Util.null2String(dto.getInfantCare()));
return cellList;
}).collect(Collectors.toList()))
.orElse(Collections.emptyList());
List<List<String>> rowList = new ArrayList<>();
rowList.add(title);
rowList.addAll(dataRowList);
if (!isTemplate) {
// 非下载导入模版查询数据填充
List<List<String>> dataRowList = queryInfoForExcel(param, rowList);
rowList.addAll(dataRowList);
}
return rowList;
}
@ -533,6 +501,9 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd
.continuingEducation(specialAddDeductionParam.getContinuingEducation())
.housingLoanInterest(specialAddDeductionParam.getHousingLoanInterest())
.housingRent(specialAddDeductionParam.getHousingRent())
.infantCare(specialAddDeductionParam.getInfantCare())
.supportingElder(specialAddDeductionParam.getSupportingElder())
.seriousIllnessTreatment(specialAddDeductionParam.getSeriousIllnessTreatment())
.build();
updateList.add(build);
SpecialAddDeductionBiz.batchUpdate(updateList);
@ -664,39 +635,36 @@ public class SpecialAddDeductionServiceImpl extends Service implements SpecialAd
.stream().findFirst().orElse(null);
}
@Override
public XSSFWorkbook downloadTemplate(SpecialAddDeductionQueryParam param) {
// 1.工作簿名称
String sheetName = SalaryI18nUtil.getI18nLabel(101604, "其他免税扣除导入模板");
String[] header = {
SalaryI18nUtil.getI18nLabel(85429, "姓名"),
SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人"),
SalaryI18nUtil.getI18nLabel(86185, "部门"),
SalaryI18nUtil.getI18nLabel(86186, "手机号"),
SalaryI18nUtil.getI18nLabel(86317, "工号"),
SalaryI18nUtil.getI18nLabel(86318, "证件号码"),
SalaryI18nUtil.getI18nLabel(86319, "入职日期"),
SalaryI18nUtil.getI18nLabel(91238, "商业健康保险"),
SalaryI18nUtil.getI18nLabel(91239, "税延养老保险"),
SalaryI18nUtil.getI18nLabel(84500, "其他"),
SalaryI18nUtil.getI18nLabel(91240, "准予扣除的捐赠额")
};
// 2.表头
List<List<Object>> rows = new ArrayList<>();
List<Object> headerList = Arrays.asList(header);
rows.add(headerList);
private List<List<String>> queryInfoForExcel(SpecialAddDeductionQueryParam param, List<List<String>> rowList) {
//排序配置
OrderRuleVO orderRule = getSalarySysConfService(user).orderRule();
param.setOrderRule(orderRule);
// 4.注释
List<ExcelComment> excelComments = Lists.newArrayList();
excelComments.add(new ExcelComment(0, 0, 3, 2, SalaryI18nUtil.getI18nLabel(100344, "必填")));
excelComments.add(new ExcelComment(1, 0, 4, 2, SalaryI18nUtil.getI18nLabel(100344, "必填")));
excelComments.add(new ExcelComment(7, 0, 10, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字")));
excelComments.add(new ExcelComment(8, 0, 11, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字")));
excelComments.add(new ExcelComment(9, 0, 12, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字")));
excelComments.add(new ExcelComment(10, 0, 13, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字")));
XSSFWorkbook book = ExcelUtil.genWorkbookV2(rows, sheetName, excelComments);
return book;
if (getTaxAgentService(user).isOpenDevolution()) {
putQueryRange(param);
}
List<SpecialAddDeductionListDTO> list = getSpecialAddDeductionBiz().listByParam(param);
final List<List<String>> dataRowList = Optional.ofNullable(list)
.map(List::stream)
.map(operatorStream -> operatorStream.map(dto -> {
List<String> cellList = new ArrayList<>();
cellList.add(Util.null2String(dto.getUsername()));
cellList.add(Util.null2String(dto.getTaxAgentName()));
cellList.add(Util.null2String(dto.getDepartmentName()));
cellList.add(Util.null2String(dto.getMobile()));
cellList.add(Util.null2String(dto.getJobNum()));
cellList.add(Util.null2String(dto.getIdNo()));
cellList.add(Util.null2String(dto.getHiredate()));
cellList.add(Util.null2String(dto.getChildrenEducation()));
cellList.add(Util.null2String(dto.getContinuingEducation()));
cellList.add(Util.null2String(dto.getHousingLoanInterest()));
cellList.add(Util.null2String(dto.getHousingRent()));
cellList.add(Util.null2String(dto.getSupportingElder()));
cellList.add(Util.null2String(dto.getSeriousIllnessTreatment()));
cellList.add(Util.null2String(dto.getInfantCare()));
return cellList;
}).collect(Collectors.toList()))
.orElse(Collections.emptyList());
return dataRowList;
}
}

View File

@ -4,6 +4,7 @@ import com.engine.common.util.ServiceUtil;
import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionListDTO;
import com.engine.salary.entity.datacollection.dto.SpecialAddDeductionRecordDTO;
import com.engine.salary.entity.datacollection.param.*;
import com.engine.salary.exception.SalaryRunTimeException;
import com.engine.salary.util.ResponseResult;
import com.engine.salary.util.page.PageInfo;
import com.engine.salary.wrapper.SpecialAddDeductionWrapper;
@ -15,6 +16,7 @@ import org.jetbrains.annotations.Nullable;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import javax.security.sasl.SaslException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.GET;

View File

@ -22,8 +22,11 @@ import com.engine.salary.util.page.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import weaver.general.BaseBean;
import weaver.hrm.User;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@ -39,6 +42,9 @@ import java.util.stream.Collectors;
@Slf4j
public class AddUpDeductionWrapper extends Service {
private final BaseBean baseBean = new BaseBean();
private final Boolean isLog = "true".equals(baseBean.getPropValue("hrmSalary", "log"));
private AddUpDeductionService getAddUpDeductionService(User user) {
return ServiceUtil.getService(AddUpDeductionServiceImpl.class, user);
}
@ -150,7 +156,7 @@ public class AddUpDeductionWrapper extends Service {
}
public void createAddUpDeduction(AddUpDeductionRecordParam addUpDeductionRecordParam) {
getAddUpDeductionService(user).createAddUpDeduction(addUpDeductionRecordParam);
getAddUpDeductionService(user).createAddUpDeduction(addUpDeductionRecordParam);
}
public void deleteSelectAddUpDeduction(AddUpDeductionRecordDeleteParam deleteParam) {
@ -166,7 +172,9 @@ public class AddUpDeductionWrapper extends Service {
}
public void autoAddAll(User opt) {
log.info("一键累计, 操作人 「{}」", opt.getUsername());
getAddUpDeductionService(user).autoAddAll();
if (isLog) {
log.info("一键累计, 操作人 「{}」", opt.getUsername());
}
getAddUpDeductionService(user).autoAddAll(new Date());
}
}

View File

@ -19,7 +19,6 @@ import com.engine.salary.service.impl.SpecialAddDeductionServiceImpl;
import com.engine.salary.service.impl.TaxAgentServiceImpl;
import com.engine.salary.util.SalaryI18nUtil;
import com.engine.salary.util.page.PageInfo;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import weaver.hrm.User;
@ -124,7 +123,7 @@ public class SpecialAddDeductionWrapper extends Service {
* @return
*/
public XSSFWorkbook export(SpecialAddDeductionQueryParam queryParam) {
return getSpecialAddDeductionService(user).export(queryParam);
return getSpecialAddDeductionService(user).export(queryParam, false);
}
/**
@ -149,7 +148,7 @@ public class SpecialAddDeductionWrapper extends Service {
* @return
*/
public XSSFWorkbook downloadTemplate(SpecialAddDeductionQueryParam queryParam) {
return getSpecialAddDeductionService(user).export(queryParam);
return getSpecialAddDeductionService(user).export(queryParam, true);
}
/**
@ -196,6 +195,9 @@ public class SpecialAddDeductionWrapper extends Service {
}
public SpecialAddDeductionRecordDTO getRecordById(Long id) {
if (id == null) {
throw new SalaryRunTimeException("专项附加扣除主键[id]必传");
}
return getSpecialAddDeductionService(user).getRecordById(id);
}
}