2022-03-03 13:50:03 +08:00
|
|
|
|
package com.engine.salary.service.impl;
|
|
|
|
|
|
|
2022-11-07 16:20:21 +08:00
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
2022-05-27 14:46:01 +08:00
|
|
|
|
import com.api.browser.bean.SearchConditionGroup;
|
|
|
|
|
|
import com.api.browser.bean.SearchConditionItem;
|
|
|
|
|
|
import com.api.browser.util.ConditionFactory;
|
|
|
|
|
|
import com.api.browser.util.ConditionType;
|
2022-09-19 11:01:17 +08:00
|
|
|
|
import com.api.formmode.mybatis.util.SqlProxyHandle;
|
2022-05-25 16:51:43 +08:00
|
|
|
|
import com.engine.common.util.ServiceUtil;
|
2022-03-03 13:50:03 +08:00
|
|
|
|
import com.engine.core.impl.Service;
|
2022-04-11 20:17:47 +08:00
|
|
|
|
import com.engine.salary.biz.AddUpDeductionBiz;
|
2022-05-09 14:11:07 +08:00
|
|
|
|
import com.engine.salary.biz.EmployBiz;
|
2022-05-25 16:51:43 +08:00
|
|
|
|
import com.engine.salary.common.LocalDateRange;
|
2022-11-07 16:20:21 +08:00
|
|
|
|
import com.engine.salary.encrypt.datacollection.AddUpDeductionEncrypt;
|
2022-06-10 16:43:38 +08:00
|
|
|
|
import com.engine.salary.encrypt.datacollection.AddUpDeductionRecordStrDTOEncrypt;
|
2022-05-24 09:23:17 +08:00
|
|
|
|
import com.engine.salary.encrypt.datacollection.AddUpDeductionStrDTOEncrypt;
|
2022-04-11 20:17:47 +08:00
|
|
|
|
import com.engine.salary.entity.datacollection.AddUpDeduction;
|
2022-05-09 14:11:07 +08:00
|
|
|
|
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
|
2022-04-28 17:44:26 +08:00
|
|
|
|
import com.engine.salary.entity.datacollection.dto.AddUpDeductionDTO;
|
2022-05-25 13:10:03 +08:00
|
|
|
|
import com.engine.salary.entity.datacollection.dto.AddUpDeductionRecordDTO;
|
2022-05-27 14:46:01 +08:00
|
|
|
|
import com.engine.salary.entity.datacollection.param.AddUpDeductionImportParam;
|
2022-04-28 17:44:26 +08:00
|
|
|
|
import com.engine.salary.entity.datacollection.param.AddUpDeductionQueryParam;
|
2022-10-26 18:35:23 +08:00
|
|
|
|
import com.engine.salary.entity.datacollection.param.AddUpDeductionRecordDeleteParam;
|
|
|
|
|
|
import com.engine.salary.entity.datacollection.param.AddUpDeductionRecordParam;
|
2022-11-04 15:16:27 +08:00
|
|
|
|
import com.engine.salary.entity.datacollection.po.SpecialAddDeductionPO;
|
2022-05-25 16:51:43 +08:00
|
|
|
|
import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO;
|
|
|
|
|
|
import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO;
|
2022-05-24 15:20:12 +08:00
|
|
|
|
import com.engine.salary.entity.taxagent.bo.TaxAgentBO;
|
|
|
|
|
|
import com.engine.salary.entity.taxagent.dto.TaxAgentEmployeeDTO;
|
2022-05-27 15:43:38 +08:00
|
|
|
|
import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeEmployeeDTO;
|
2022-05-24 15:20:12 +08:00
|
|
|
|
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
|
2022-06-13 17:05:36 +08:00
|
|
|
|
import com.engine.salary.enums.UserStatusEnum;
|
2022-05-25 16:51:43 +08:00
|
|
|
|
import com.engine.salary.enums.salaryaccounting.SalaryAcctRecordStatusEnum;
|
2022-04-11 20:17:47 +08:00
|
|
|
|
import com.engine.salary.exception.SalaryRunTimeException;
|
2022-04-28 17:44:26 +08:00
|
|
|
|
import com.engine.salary.mapper.datacollection.AddUpDeductionMapper;
|
2022-09-19 11:01:17 +08:00
|
|
|
|
import com.engine.salary.mapper.sys.SalarySysConfMapper;
|
2022-05-24 15:20:12 +08:00
|
|
|
|
import com.engine.salary.service.*;
|
2022-09-19 11:01:17 +08:00
|
|
|
|
import com.engine.salary.sys.entity.po.SalarySysConfPO;
|
2022-09-26 18:51:17 +08:00
|
|
|
|
import com.engine.salary.sys.entity.vo.OrderRuleVO;
|
|
|
|
|
|
import com.engine.salary.sys.service.SalarySysConfService;
|
|
|
|
|
|
import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl;
|
2022-04-11 20:17:47 +08:00
|
|
|
|
import com.engine.salary.util.SalaryDateUtil;
|
2022-10-28 16:35:51 +08:00
|
|
|
|
import com.engine.salary.util.SalaryEntityUtil;
|
2022-04-11 20:17:47 +08:00
|
|
|
|
import com.engine.salary.util.SalaryI18nUtil;
|
2022-04-28 17:44:26 +08:00
|
|
|
|
import com.engine.salary.util.db.MapperProxyFactory;
|
|
|
|
|
|
import com.engine.salary.util.excel.ExcelComment;
|
2022-05-27 14:46:01 +08:00
|
|
|
|
import com.engine.salary.util.excel.ExcelParseHelper;
|
2022-04-28 17:44:26 +08:00
|
|
|
|
import com.engine.salary.util.excel.ExcelUtil;
|
2022-05-24 15:20:12 +08:00
|
|
|
|
import com.engine.salary.util.page.PageInfo;
|
2022-05-25 13:10:03 +08:00
|
|
|
|
import com.engine.salary.util.page.SalaryPageUtil;
|
2022-04-28 17:44:26 +08:00
|
|
|
|
import com.google.common.collect.Lists;
|
2022-05-27 14:51:53 +08:00
|
|
|
|
import com.google.common.collect.Maps;
|
2022-05-09 14:11:07 +08:00
|
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
2022-05-27 14:51:53 +08:00
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
2022-05-27 14:46:01 +08:00
|
|
|
|
import org.apache.commons.lang3.Validate;
|
|
|
|
|
|
import org.apache.poi.util.IOUtils;
|
2022-03-10 11:09:08 +08:00
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
2022-05-27 14:46:01 +08:00
|
|
|
|
import weaver.file.ImageFileManager;
|
2022-05-20 14:41:42 +08:00
|
|
|
|
import weaver.general.Util;
|
2022-05-25 16:51:43 +08:00
|
|
|
|
import weaver.hrm.User;
|
2022-03-03 13:50:03 +08:00
|
|
|
|
|
2022-05-27 14:46:01 +08:00
|
|
|
|
import java.io.InputStream;
|
2022-11-07 16:20:21 +08:00
|
|
|
|
import java.math.BigDecimal;
|
2022-05-25 13:10:03 +08:00
|
|
|
|
import java.text.SimpleDateFormat;
|
2022-05-25 16:51:43 +08:00
|
|
|
|
import java.time.LocalDate;
|
2022-11-04 15:16:27 +08:00
|
|
|
|
import java.time.LocalDateTime;
|
2022-04-11 20:17:47 +08:00
|
|
|
|
import java.time.YearMonth;
|
2022-05-09 14:11:07 +08:00
|
|
|
|
import java.util.*;
|
2022-04-28 17:44:26 +08:00
|
|
|
|
import java.util.stream.Collectors;
|
2022-03-03 13:50:03 +08:00
|
|
|
|
|
2022-05-27 14:51:53 +08:00
|
|
|
|
import static com.engine.salary.constant.SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY;
|
2022-11-07 16:20:21 +08:00
|
|
|
|
|
2022-08-26 14:06:21 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 累计专项
|
|
|
|
|
|
* <p>Copyright: Copyright (c) 2022</p>
|
|
|
|
|
|
* <p>Company: 泛微软件</p>
|
|
|
|
|
|
*
|
|
|
|
|
|
* @author qiantao
|
|
|
|
|
|
* @version 1.0
|
|
|
|
|
|
**/
|
2022-03-03 13:50:03 +08:00
|
|
|
|
public class AddUpDeductionServiceImpl extends Service implements AddUpDeductionService {
|
|
|
|
|
|
|
2022-04-28 17:44:26 +08:00
|
|
|
|
private AddUpDeductionMapper getAddUpDeductionMapper() {
|
|
|
|
|
|
return MapperProxyFactory.getProxy(AddUpDeductionMapper.class);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-06-09 17:45:28 +08:00
|
|
|
|
private TaxAgentService getTaxAgentService(User user) {
|
2022-05-31 21:05:59 +08:00
|
|
|
|
return ServiceUtil.getService(TaxAgentServiceImpl.class, user);
|
2022-05-25 16:51:43 +08:00
|
|
|
|
}
|
2022-06-09 17:45:28 +08:00
|
|
|
|
|
2022-05-25 16:51:43 +08:00
|
|
|
|
private SalaryAcctRecordService getSalaryAcctRecordService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user);
|
|
|
|
|
|
}
|
2022-05-24 15:20:12 +08:00
|
|
|
|
|
2022-05-25 16:51:43 +08:00
|
|
|
|
private SalaryAcctEmployeeService getSalaryAcctEmployeeService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(SalaryAcctEmployeeServiceImpl.class, user);
|
|
|
|
|
|
}
|
2022-05-24 15:20:12 +08:00
|
|
|
|
|
2022-05-25 16:51:43 +08:00
|
|
|
|
private SalaryEmployeeService getSalaryEmployeeService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user);
|
2022-03-03 13:50:03 +08:00
|
|
|
|
}
|
2022-03-04 10:10:38 +08:00
|
|
|
|
|
2022-09-19 11:01:17 +08:00
|
|
|
|
private SalarySysConfMapper getSalarySysConfMapper() {
|
|
|
|
|
|
return SqlProxyHandle.getProxy(SalarySysConfMapper.class);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-09-26 18:51:17 +08:00
|
|
|
|
private SalarySysConfService getSalarySysConfService(User user) {
|
2022-11-07 16:20:21 +08:00
|
|
|
|
return ServiceUtil.getService(SalarySysConfServiceImpl.class, user);
|
2022-09-26 18:51:17 +08:00
|
|
|
|
}
|
2022-05-27 14:46:01 +08:00
|
|
|
|
|
2022-11-04 15:16:27 +08:00
|
|
|
|
private SpecialAddDeductionService getSpecialAddDeductionService(User user) {
|
2022-11-07 16:20:21 +08:00
|
|
|
|
return ServiceUtil.getService(SpecialAddDeductionServiceImpl.class, user);
|
2022-11-04 15:16:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-03-04 10:10:38 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public Map<String, Object> getSearchCondition(Map<String, Object> params) {
|
2022-05-27 14:46:01 +08:00
|
|
|
|
Map<String, Object> apidatas = new HashMap<String, Object>();
|
|
|
|
|
|
ConditionFactory conditionFactory = new ConditionFactory(user);
|
|
|
|
|
|
|
|
|
|
|
|
//条件组
|
|
|
|
|
|
List<SearchConditionGroup> addGroups = new ArrayList<SearchConditionGroup>();
|
|
|
|
|
|
|
|
|
|
|
|
List<SearchConditionItem> conditionItems = new ArrayList<SearchConditionItem>();
|
|
|
|
|
|
|
|
|
|
|
|
//文本输入框
|
2022-06-09 17:45:28 +08:00
|
|
|
|
SearchConditionItem username = conditionFactory.createCondition(ConditionType.INPUT, 25034, "username");
|
2022-05-27 14:46:01 +08:00
|
|
|
|
username.setInputType("input");
|
2022-08-26 14:06:21 +08:00
|
|
|
|
username.setColSpan(2);
|
|
|
|
|
|
username.setFieldcol(16);
|
2022-05-27 14:46:01 +08:00
|
|
|
|
username.setLabelcol(8);
|
2022-08-26 14:06:21 +08:00
|
|
|
|
username.setViewAttr(2);
|
|
|
|
|
|
username.setLabel("姓名");
|
2022-05-27 14:46:01 +08:00
|
|
|
|
conditionItems.add(username);
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-06-09 17:45:28 +08:00
|
|
|
|
SearchConditionItem departmentName = conditionFactory.createCondition(ConditionType.BROWSER, 502227, "departmentIds", "4");
|
2022-05-27 14:46:01 +08:00
|
|
|
|
departmentName.setInputType("browser");
|
|
|
|
|
|
departmentName.setColSpan(2);
|
|
|
|
|
|
departmentName.setFieldcol(16);
|
|
|
|
|
|
departmentName.setLabelcol(8);
|
|
|
|
|
|
departmentName.setViewAttr(2);
|
|
|
|
|
|
departmentName.setIsQuickSearch(false);
|
|
|
|
|
|
departmentName.setLabel("部门");
|
|
|
|
|
|
conditionItems.add(departmentName);
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-06-09 17:45:28 +08:00
|
|
|
|
SearchConditionItem jobNum = conditionFactory.createCondition(ConditionType.INPUT, 25034, "jobNum");
|
2022-05-27 14:46:01 +08:00
|
|
|
|
jobNum.setInputType("input");
|
|
|
|
|
|
jobNum.setColSpan(2);
|
|
|
|
|
|
jobNum.setFieldcol(16);
|
|
|
|
|
|
jobNum.setLabelcol(8);
|
|
|
|
|
|
jobNum.setViewAttr(2);
|
|
|
|
|
|
jobNum.setLabel("工号");
|
|
|
|
|
|
conditionItems.add(jobNum);
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-09-29 10:03:51 +08:00
|
|
|
|
// SearchConditionItem idNo = conditionFactory.createCondition(ConditionType.INPUT, 25034, "idNo");
|
|
|
|
|
|
// idNo.setInputType("input");
|
|
|
|
|
|
// idNo.setColSpan(2);
|
|
|
|
|
|
// idNo.setFieldcol(16);
|
|
|
|
|
|
// idNo.setLabelcol(8);
|
|
|
|
|
|
// idNo.setViewAttr(2);
|
|
|
|
|
|
// idNo.setLabel("证件号码");
|
|
|
|
|
|
// conditionItems.add(idNo);
|
2022-05-27 14:46:01 +08:00
|
|
|
|
|
|
|
|
|
|
//日期范围选项
|
2022-09-29 10:03:51 +08:00
|
|
|
|
// List<SearchConditionOption> dateOptions = new ArrayList<SearchConditionOption>();
|
|
|
|
|
|
// dateOptions.add(new SearchConditionOption("6", SystemEnv.getHtmlLabelName(32530, user.getLanguage()), true));//指定日期范围(必须为6)
|
|
|
|
|
|
// SearchConditionItem hiredate = conditionFactory.createCondition(ConditionType.RANGEPICKER, 18648, new String[]{"hiredate", "hiredate"});
|
|
|
|
|
|
// hiredate.setInputType("rangepicker");
|
|
|
|
|
|
// hiredate.setFormat("yyyy-MM-dd");
|
|
|
|
|
|
// hiredate.setFieldcol(16);
|
|
|
|
|
|
// hiredate.setLabelcol(8);
|
|
|
|
|
|
// hiredate.setViewAttr(2);
|
|
|
|
|
|
// hiredate.setLabel("入职日期");
|
|
|
|
|
|
// hiredate.setOptions(dateOptions);
|
|
|
|
|
|
// conditionItems.add(hiredate);
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
// SearchConditionItem mobile = conditionFactory.createCondition(ConditionType.INPUT, 25034, "mobile");
|
|
|
|
|
|
// mobile.setInputType("input");
|
|
|
|
|
|
// mobile.setColSpan(2);
|
|
|
|
|
|
// mobile.setFieldcol(16);
|
|
|
|
|
|
// mobile.setLabelcol(8);
|
|
|
|
|
|
// mobile.setViewAttr(2);
|
|
|
|
|
|
// mobile.setLabel("手机号");
|
|
|
|
|
|
// conditionItems.add(mobile);
|
2022-05-27 14:46:01 +08:00
|
|
|
|
|
2022-06-09 17:45:28 +08:00
|
|
|
|
addGroups.add(new SearchConditionGroup("常用条件", true, conditionItems));
|
2022-05-27 14:46:01 +08:00
|
|
|
|
|
2022-06-09 17:45:28 +08:00
|
|
|
|
apidatas.put("condition", addGroups);
|
2022-05-27 14:46:01 +08:00
|
|
|
|
return apidatas;
|
2022-03-07 15:08:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-05-27 14:46:01 +08:00
|
|
|
|
|
2022-03-07 15:08:56 +08:00
|
|
|
|
@Override
|
2022-05-27 14:51:53 +08:00
|
|
|
|
public Map<String, Object> importAddUpDeduction(AddUpDeductionImportParam importParam) {
|
2022-05-27 15:43:38 +08:00
|
|
|
|
long currentEmployeeId = user.getUID();
|
2022-06-09 17:45:28 +08:00
|
|
|
|
Boolean openDevolution = getTaxAgentService(user).isOpenDevolution();
|
2022-05-27 15:43:38 +08:00
|
|
|
|
|
2022-05-27 14:51:53 +08:00
|
|
|
|
Map<String, Object> apidatas = new HashMap<String, Object>();
|
|
|
|
|
|
EmployBiz employBiz = new EmployBiz();
|
|
|
|
|
|
AddUpDeductionBiz addUpDeductionBiz = new AddUpDeductionBiz();
|
|
|
|
|
|
|
|
|
|
|
|
//检验参数
|
|
|
|
|
|
checkImportParam(importParam);
|
|
|
|
|
|
|
2022-05-27 15:43:38 +08:00
|
|
|
|
//税款所属期
|
|
|
|
|
|
String declareMonthStr = importParam.getDeclareMonth();
|
2022-05-27 14:51:53 +08:00
|
|
|
|
//excel文件id
|
|
|
|
|
|
String imageId = Util.null2String(importParam.getImageId());
|
|
|
|
|
|
Validate.notBlank(imageId, "imageId为空");
|
2022-05-27 15:43:38 +08:00
|
|
|
|
// 获取所有个税扣缴义务人
|
2022-06-09 17:45:28 +08:00
|
|
|
|
Collection<TaxAgentManageRangeEmployeeDTO> taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId);
|
2022-05-27 14:51:53 +08:00
|
|
|
|
//个税扣缴义务人
|
|
|
|
|
|
String taxAgentId = Util.null2String(importParam.getTaxAgentId());
|
|
|
|
|
|
// 获取租户下所有的人员
|
2022-05-27 15:43:38 +08:00
|
|
|
|
List<DataCollectionEmployee> employees = employBiz.listEmployee();
|
2022-05-27 14:51:53 +08:00
|
|
|
|
// 已经核算过的不可操作
|
|
|
|
|
|
// 获取已经核算的数据
|
2022-05-27 15:43:38 +08:00
|
|
|
|
List<SalaryAcctEmployeePO> salaryAcctEmployees = getAccountedEmployeeData(declareMonthStr);
|
2022-05-27 14:51:53 +08:00
|
|
|
|
// 查询已有数据
|
2022-05-27 15:43:38 +08:00
|
|
|
|
Date declareMonth = SalaryDateUtil.localDateToDate(LocalDate.parse(declareMonthStr + "-01", SalaryDateUtil.DATE_FORMATTER));
|
|
|
|
|
|
List<AddUpDeduction> list = getAddUpDeductionMapper().listSome(AddUpDeduction.builder().declareMonth(declareMonth).build());
|
2022-05-27 14:51:53 +08:00
|
|
|
|
|
2022-09-19 11:01:17 +08:00
|
|
|
|
//查询对于人员信息导入筛选的全局配置
|
|
|
|
|
|
SalarySysConfPO salarySysConfPO = getSalarySysConfMapper().getOneByCode("matchEmployeeMode");
|
2022-09-19 15:11:27 +08:00
|
|
|
|
String confValue = (salarySysConfPO != null && salarySysConfPO.getConfValue() != null && !"".equals(salarySysConfPO.getConfValue())) ? salarySysConfPO.getConfValue() : "0";
|
2022-09-19 11:01:17 +08:00
|
|
|
|
|
2022-05-27 14:51:53 +08:00
|
|
|
|
InputStream fileInputStream = null;
|
|
|
|
|
|
try {
|
|
|
|
|
|
fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(imageId));
|
|
|
|
|
|
List<AddUpDeductionDTO> addUpDeductions = ExcelParseHelper.parse2Map(fileInputStream, AddUpDeductionDTO.class, 0, 1, 14, "addUpDeductionTemplate.xlsx");
|
|
|
|
|
|
|
|
|
|
|
|
int total = addUpDeductions.size();
|
|
|
|
|
|
int index = 0;
|
|
|
|
|
|
int successCount = 0;
|
|
|
|
|
|
int errorCount = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// 错误excel内容
|
|
|
|
|
|
List<Map> errorData = new ArrayList<>();
|
|
|
|
|
|
//合规数据
|
|
|
|
|
|
List<AddUpDeduction> eligibleData = new ArrayList<>();
|
|
|
|
|
|
|
2022-05-27 15:43:38 +08:00
|
|
|
|
List<TaxAgentManageRangeEmployeeDTO.TaxAgentEmployee> taxAgentEmployees = Lists.newArrayList();
|
2022-05-27 14:51:53 +08:00
|
|
|
|
for (int i = 0; i < addUpDeductions.size(); i++) {
|
|
|
|
|
|
|
|
|
|
|
|
AddUpDeductionDTO dto = addUpDeductions.get(i);
|
|
|
|
|
|
|
|
|
|
|
|
Date now = new Date();
|
|
|
|
|
|
//待插入数据库对象
|
|
|
|
|
|
AddUpDeduction addUpDeduction = AddUpDeduction.builder()
|
|
|
|
|
|
.tenantKey(DEFAULT_TENANT_KEY)
|
|
|
|
|
|
.createTime(now)
|
|
|
|
|
|
.updateTime(now)
|
|
|
|
|
|
.creator((long) user.getUID())
|
|
|
|
|
|
.declareMonth(declareMonth).build();
|
|
|
|
|
|
|
|
|
|
|
|
//异常点数量
|
|
|
|
|
|
int errorSum = 0;
|
|
|
|
|
|
|
|
|
|
|
|
//行号
|
|
|
|
|
|
String rowIndex = String.format("第%s行", i + 2);
|
|
|
|
|
|
|
|
|
|
|
|
//相同的姓名
|
|
|
|
|
|
String userName = dto.getUsername();
|
|
|
|
|
|
String deparmentName = dto.getDepartmentName();
|
2022-08-25 11:43:52 +08:00
|
|
|
|
String mobile = dto.getMobile();
|
2022-09-19 11:01:17 +08:00
|
|
|
|
String workcode = dto.getJobNum();
|
|
|
|
|
|
|
|
|
|
|
|
//筛选导入人员信息可以在人力资源池中匹配到的人员信息
|
2022-09-21 15:49:55 +08:00
|
|
|
|
List<DataCollectionEmployee> employeeSameIds = getSalaryEmployeeService(user).matchImportEmployee(employees, userName, deparmentName, mobile, workcode, null);
|
2022-09-19 11:01:17 +08:00
|
|
|
|
|
2022-09-19 15:11:27 +08:00
|
|
|
|
if (StringUtils.isBlank(userName) && "0".equals(confValue)) {
|
2022-05-27 14:51:53 +08:00
|
|
|
|
//姓名 不能为空
|
|
|
|
|
|
//错误消息对象
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "姓名不能为空");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
2022-06-13 17:05:36 +08:00
|
|
|
|
} else if (CollectionUtils.isEmpty(employeeSameIds)) {
|
2022-05-27 14:51:53 +08:00
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
2022-06-13 17:05:36 +08:00
|
|
|
|
errorMessageMap.put("message", rowIndex + "员工信息不存在");
|
2022-05-27 14:51:53 +08:00
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
2022-06-13 17:05:36 +08:00
|
|
|
|
} else if (employeeSameIds.size() > 1) {
|
|
|
|
|
|
//存在离职和在职状态取在职状态
|
|
|
|
|
|
employeeSameIds = employeeSameIds.stream()
|
|
|
|
|
|
.filter(e -> UserStatusEnum.getNormalStatus().contains(e.getStatus()))
|
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
if (employeeSameIds.size() != 1) {
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
2022-09-16 15:03:48 +08:00
|
|
|
|
errorMessageMap.put("message", rowIndex + "员工信息不存在或者存在多个员工");
|
2022-06-13 17:05:36 +08:00
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
2022-11-07 16:20:21 +08:00
|
|
|
|
} else {
|
2022-08-16 10:39:45 +08:00
|
|
|
|
Long employeeId = CollectionUtils.isNotEmpty(employeeSameIds) && employeeSameIds.size() == 1 ? employeeSameIds.get(0).getEmployeeId() : null;
|
|
|
|
|
|
addUpDeduction.setEmployeeId(employeeId);
|
2022-06-13 17:05:36 +08:00
|
|
|
|
}
|
2022-05-27 14:51:53 +08:00
|
|
|
|
} else {
|
2022-06-13 17:05:36 +08:00
|
|
|
|
Long employeeId = CollectionUtils.isNotEmpty(employeeSameIds) && employeeSameIds.size() == 1 ? employeeSameIds.get(0).getEmployeeId() : null;
|
2022-05-27 14:51:53 +08:00
|
|
|
|
if (employeeId != null && employeeId > 0) {
|
|
|
|
|
|
addUpDeduction.setEmployeeId(employeeId);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
//姓名错误,系统内不存在该姓名
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "姓名错误,系统内不存在该姓名");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String taxAgentName = dto.getTaxAgentName();
|
|
|
|
|
|
if (StringUtils.isBlank(taxAgentName)) {
|
|
|
|
|
|
//个税扣缴义务人不能为空
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "个税扣缴义务人不能为空");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
} else {
|
2022-05-27 15:43:38 +08:00
|
|
|
|
Optional<TaxAgentManageRangeEmployeeDTO> optionalTemp = taxAgentList.stream().filter(m -> m.getTaxAgentName().equals(taxAgentName)).findFirst();
|
2022-05-27 14:51:53 +08:00
|
|
|
|
if (optionalTemp.isPresent()) {
|
2022-05-27 15:43:38 +08:00
|
|
|
|
if (StringUtils.isNotEmpty(taxAgentId) && !optionalTemp.get().getTaxAgentId().equals(Long.valueOf(taxAgentId))) {
|
2022-05-27 14:51:53 +08:00
|
|
|
|
//个税扣缴义务人与导入时选择的不一致
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "个税扣缴义务人与导入时选择的不一致");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
} else {
|
2022-05-27 15:43:38 +08:00
|
|
|
|
addUpDeduction.setTaxAgentId(optionalTemp.get().getTaxAgentId());
|
|
|
|
|
|
taxAgentEmployees = optionalTemp.get().getEmployeeList();
|
2022-05-27 14:51:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
//个税扣缴义务人不存在
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
2022-06-21 22:37:22 +08:00
|
|
|
|
errorMessageMap.put("message", rowIndex + "个税扣缴义务人不存在或不在权限范围内");
|
2022-05-27 14:51:53 +08:00
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-08-25 16:46:12 +08:00
|
|
|
|
//fixme 分权判断
|
|
|
|
|
|
// if (openDevolution) {
|
|
|
|
|
|
// Optional<TaxAgentManageRangeEmployeeDTO.TaxAgentEmployee> optionalTaxAgentEmp = taxAgentEmployees.stream().filter(f -> f.getEmployeeId().equals(addUpDeduction.getEmployeeId())).findFirst();
|
|
|
|
|
|
// if (!optionalTaxAgentEmp.isPresent()) {
|
|
|
|
|
|
// Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
// errorMessageMap.put("message", rowIndex + "该条数据不在个税扣缴义务人人员范围内,不可导入");
|
|
|
|
|
|
// errorData.add(errorMessageMap);
|
|
|
|
|
|
// errorSum += 1;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
2022-06-09 17:45:28 +08:00
|
|
|
|
|
2022-05-27 15:43:38 +08:00
|
|
|
|
// 判断是否有核算过
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(salaryAcctEmployees)) {
|
|
|
|
|
|
Optional<SalaryAcctEmployeePO> optionalAcctEmp = salaryAcctEmployees.stream().filter(f -> f.getEmployeeId().equals(addUpDeduction.getEmployeeId()) && f.getTaxAgentId().equals(addUpDeduction.getTaxAgentId())).findFirst();
|
|
|
|
|
|
boolean isExist = list.stream().anyMatch(f -> f.getEmployeeId().equals(addUpDeduction.getEmployeeId()) && f.getTaxAgentId().equals(addUpDeduction.getTaxAgentId()));
|
|
|
|
|
|
if (optionalAcctEmp.isPresent() && isExist) {
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "该年月这条数据已经核算过,不可导入");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-05-27 14:51:53 +08:00
|
|
|
|
//累计子女教育
|
2022-05-30 18:59:48 +08:00
|
|
|
|
String addUpChildEducation = dto.getAddUpChildEducation();
|
2022-05-27 14:51:53 +08:00
|
|
|
|
addUpDeduction.setAddUpChildEducation(Util.null2String(addUpChildEducation));
|
|
|
|
|
|
//累计继续教育
|
2022-05-30 18:59:48 +08:00
|
|
|
|
String addUpContinuingEducation = dto.getAddUpContinuingEducation();
|
2022-05-27 14:51:53 +08:00
|
|
|
|
addUpDeduction.setAddUpContinuingEducation(Util.null2String(addUpContinuingEducation));
|
|
|
|
|
|
//累计住房贷款利息
|
2022-05-30 18:59:48 +08:00
|
|
|
|
String addUpHousingLoanInterest = dto.getAddUpHousingLoanInterest();
|
2022-05-27 14:51:53 +08:00
|
|
|
|
addUpDeduction.setAddUpHousingLoanInterest(Util.null2String(addUpHousingLoanInterest));
|
|
|
|
|
|
//累计住房租金
|
2022-05-30 18:59:48 +08:00
|
|
|
|
String addUpHousingRent = dto.getAddUpHousingRent();
|
2022-05-27 14:51:53 +08:00
|
|
|
|
addUpDeduction.setAddUpHousingRent(Util.null2String(addUpHousingRent));
|
|
|
|
|
|
//累计赡养老人
|
2022-05-30 18:59:48 +08:00
|
|
|
|
String addUpSupportElderly = dto.getAddUpSupportElderly();
|
2022-05-27 14:51:53 +08:00
|
|
|
|
addUpDeduction.setAddUpSupportElderly(Util.null2String(addUpSupportElderly));
|
|
|
|
|
|
addUpDeduction.setAddUpIllnessMedical(Util.null2String(dto.getAddUpIllnessMedical()));
|
|
|
|
|
|
addUpDeduction.setAddUpInfantCare(Util.null2String(dto.getAddUpInfantCare()));
|
|
|
|
|
|
if (errorSum == 0) {
|
|
|
|
|
|
successCount += 1;
|
|
|
|
|
|
// 合格数据
|
|
|
|
|
|
eligibleData.add(addUpDeduction);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
errorCount += 1;
|
|
|
|
|
|
// 添加错误数据
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
//入库
|
|
|
|
|
|
addUpDeductionBiz.handleImportData(eligibleData);
|
|
|
|
|
|
apidatas.put("successCount", successCount);
|
|
|
|
|
|
apidatas.put("errorCount", errorCount);
|
|
|
|
|
|
apidatas.put("errorData", errorData);
|
|
|
|
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
IOUtils.closeQuietly(fileInputStream);
|
|
|
|
|
|
}
|
|
|
|
|
|
return apidatas;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-10-26 18:35:23 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public void editAddUpDeduction(AddUpDeductionRecordParam addUpDeduction) {
|
|
|
|
|
|
AddUpDeductionBiz addUpDeductionBiz = new AddUpDeductionBiz();
|
|
|
|
|
|
String declareMonthStr = addUpDeduction.getDeclareMonth();
|
2022-10-28 14:08:27 +08:00
|
|
|
|
|
|
|
|
|
|
Long currentEmployeeId = (long) user.getUID();
|
|
|
|
|
|
// 获取所有个税扣缴义务人
|
|
|
|
|
|
Collection<TaxAgentManageRangeEmployeeDTO> taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId);
|
|
|
|
|
|
AddUpDeduction byId = addUpDeductionBiz.getById(addUpDeduction.getId());
|
2022-11-07 16:20:21 +08:00
|
|
|
|
if (byId == null) {
|
2022-10-28 14:08:27 +08:00
|
|
|
|
throw new SalaryRunTimeException("该数据不存在!");
|
|
|
|
|
|
}
|
|
|
|
|
|
Long taxAgentId = byId.getTaxAgentId();
|
|
|
|
|
|
boolean canEdit = taxAgentList.stream().anyMatch(t -> t.getTaxAgentId() == taxAgentId);
|
2022-11-07 16:20:21 +08:00
|
|
|
|
if (!canEdit) {
|
2022-10-28 14:08:27 +08:00
|
|
|
|
//没有编辑权限
|
|
|
|
|
|
throw new SalaryRunTimeException("该个税扣缴义务人无权限编辑此数据!");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-10-26 18:35:23 +08:00
|
|
|
|
// 已经核算过的不可操作
|
|
|
|
|
|
// 获取已经核算的数据
|
|
|
|
|
|
List<SalaryAcctEmployeePO> salaryAcctEmployees = getAccountedEmployeeData(declareMonthStr);
|
|
|
|
|
|
// 判断是否有核算过
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(salaryAcctEmployees)) {
|
|
|
|
|
|
Optional<SalaryAcctEmployeePO> optionalAcctEmp = salaryAcctEmployees.stream().filter(f -> f.getEmployeeId().equals(addUpDeduction.getEmployeeId()) && f.getTaxAgentId().equals(addUpDeduction.getTaxAgentId())).findFirst();
|
|
|
|
|
|
if (optionalAcctEmp.isPresent()) {
|
|
|
|
|
|
throw new SalaryRunTimeException("该年月这条数据已经核算过,不可进行编辑!");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-10-28 14:08:27 +08:00
|
|
|
|
ArrayList<AddUpDeduction> updateList = new ArrayList<>();
|
|
|
|
|
|
AddUpDeduction build = AddUpDeduction.builder().id(addUpDeduction.getId()).addUpChildEducation(addUpDeduction.getAddUpChildEducation()).addUpContinuingEducation(addUpDeduction.getAddUpContinuingEducation()).addUpHousingLoanInterest(addUpDeduction.getAddUpHousingLoanInterest()).addUpHousingRent(addUpDeduction.getAddUpHousingRent()).addUpSupportElderly(addUpDeduction.getAddUpSupportElderly()).addUpIllnessMedical(addUpDeduction.getAddUpIllnessMedical()).addUpInfantCare(addUpDeduction.getAddUpInfantCare()).build();
|
|
|
|
|
|
updateList.add(build);
|
|
|
|
|
|
addUpDeductionBiz.batchUpdate(updateList);
|
2022-10-26 18:35:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void createAddUpDeduction(AddUpDeductionRecordParam addUpDeductionRecordParam) {
|
|
|
|
|
|
long currentEmployeeId = user.getUID();
|
|
|
|
|
|
Boolean openDevolution = getTaxAgentService(user).isOpenDevolution();
|
|
|
|
|
|
EmployBiz employBiz = new EmployBiz();
|
|
|
|
|
|
AddUpDeductionBiz addUpDeductionBiz = new AddUpDeductionBiz();
|
|
|
|
|
|
|
|
|
|
|
|
//税款所属期
|
|
|
|
|
|
String declareMonthStr = addUpDeductionRecordParam.getDeclareMonth();
|
2022-11-07 16:20:21 +08:00
|
|
|
|
if (declareMonthStr == "") {
|
2022-10-26 18:35:23 +08:00
|
|
|
|
throw new SalaryRunTimeException("税款所属期不能为空!");
|
|
|
|
|
|
}
|
|
|
|
|
|
// 获取所有个税扣缴义务人
|
|
|
|
|
|
Collection<TaxAgentManageRangeEmployeeDTO> taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId);
|
|
|
|
|
|
//个税扣缴义务人
|
|
|
|
|
|
String taxAgentId = Util.null2String(addUpDeductionRecordParam.getTaxAgentId());
|
|
|
|
|
|
// 获取租户下所有的人员
|
|
|
|
|
|
List<DataCollectionEmployee> employees = employBiz.listEmployee();
|
|
|
|
|
|
// 已经核算过的不可操作
|
|
|
|
|
|
// 获取已经核算的数据
|
|
|
|
|
|
List<SalaryAcctEmployeePO> salaryAcctEmployees = getAccountedEmployeeData(declareMonthStr);
|
|
|
|
|
|
// 查询已有数据
|
|
|
|
|
|
Date declareMonth = SalaryDateUtil.localDateToDate(LocalDate.parse(declareMonthStr + "-01", SalaryDateUtil.DATE_FORMATTER));
|
|
|
|
|
|
List<AddUpDeduction> list = getAddUpDeductionMapper().listSome(AddUpDeduction.builder().declareMonth(declareMonth).build());
|
|
|
|
|
|
|
|
|
|
|
|
//查询对于人员信息导入筛选的全局配置
|
|
|
|
|
|
SalarySysConfPO salarySysConfPO = getSalarySysConfMapper().getOneByCode("matchEmployeeMode");
|
|
|
|
|
|
List<AddUpDeduction> insertData = new ArrayList<>();
|
|
|
|
|
|
List<TaxAgentManageRangeEmployeeDTO.TaxAgentEmployee> taxAgentEmployees = Lists.newArrayList();
|
|
|
|
|
|
Date now = new Date();
|
|
|
|
|
|
//待插入数据库对象
|
|
|
|
|
|
AddUpDeduction addUpDeduction = AddUpDeduction.builder()
|
|
|
|
|
|
.tenantKey(DEFAULT_TENANT_KEY)
|
|
|
|
|
|
.createTime(now)
|
|
|
|
|
|
.updateTime(now)
|
|
|
|
|
|
.creator((long) user.getUID())
|
|
|
|
|
|
.declareMonth(declareMonth).build();
|
|
|
|
|
|
boolean employeeSameId = employees.stream().anyMatch(e -> e.getEmployeeId() == addUpDeductionRecordParam.getEmployeeId());
|
|
|
|
|
|
if (!employeeSameId) {
|
|
|
|
|
|
throw new SalaryRunTimeException("员工信息不存在");
|
|
|
|
|
|
}
|
|
|
|
|
|
addUpDeduction.setEmployeeId(addUpDeductionRecordParam.getEmployeeId());
|
|
|
|
|
|
|
|
|
|
|
|
String taxAgentName = addUpDeductionRecordParam.getTaxAgentName();
|
|
|
|
|
|
if (StringUtils.isBlank(taxAgentName)) {
|
|
|
|
|
|
//个税扣缴义务人不能为空
|
|
|
|
|
|
throw new SalaryRunTimeException("个税扣缴义务人不能为空");
|
|
|
|
|
|
} else {
|
|
|
|
|
|
Optional<TaxAgentManageRangeEmployeeDTO> optionalTemp = taxAgentList.stream().filter(m -> m.getTaxAgentName().equals(taxAgentName)).findFirst();
|
|
|
|
|
|
if (optionalTemp.isPresent()) {
|
|
|
|
|
|
addUpDeduction.setTaxAgentId(optionalTemp.get().getTaxAgentId());
|
|
|
|
|
|
taxAgentEmployees = optionalTemp.get().getEmployeeList();
|
|
|
|
|
|
} else {
|
|
|
|
|
|
//个税扣缴义务人不存在或不在权限范围内
|
|
|
|
|
|
throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-11-07 16:20:21 +08:00
|
|
|
|
//fixme 分权判断
|
2022-10-26 18:35:23 +08:00
|
|
|
|
// if (openDevolution) {
|
|
|
|
|
|
// Optional<TaxAgentManageRangeEmployeeDTO.TaxAgentEmployee> optionalTaxAgentEmp = taxAgentEmployees.stream().filter(f -> f.getEmployeeId().equals(addUpDeduction.getEmployeeId())).findFirst();
|
|
|
|
|
|
// if (!optionalTaxAgentEmp.isPresent()) {
|
|
|
|
|
|
// Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
// errorMessageMap.put("message", rowIndex + "该条数据不在个税扣缴义务人人员范围内,不可导入");
|
|
|
|
|
|
// errorData.add(errorMessageMap);
|
|
|
|
|
|
// errorSum += 1;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// 判断是否有核算过
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(salaryAcctEmployees)) {
|
|
|
|
|
|
Optional<SalaryAcctEmployeePO> optionalAcctEmp = salaryAcctEmployees.stream().filter(f -> f.getEmployeeId().equals(addUpDeduction.getEmployeeId()) && f.getTaxAgentId().equals(addUpDeduction.getTaxAgentId())).findFirst();
|
|
|
|
|
|
boolean isExist = list.stream().anyMatch(f -> f.getEmployeeId().equals(addUpDeduction.getEmployeeId()) && f.getTaxAgentId().equals(addUpDeduction.getTaxAgentId()));
|
|
|
|
|
|
if (optionalAcctEmp.isPresent() && isExist) {
|
|
|
|
|
|
throw new SalaryRunTimeException("该年月这条数据已经核算过,不可导入");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//累计子女教育
|
|
|
|
|
|
String addUpChildEducation = addUpDeductionRecordParam.getAddUpChildEducation();
|
|
|
|
|
|
addUpDeduction.setAddUpChildEducation(Util.null2String(addUpChildEducation));
|
|
|
|
|
|
//累计继续教育
|
|
|
|
|
|
String addUpContinuingEducation = addUpDeductionRecordParam.getAddUpContinuingEducation();
|
|
|
|
|
|
addUpDeduction.setAddUpContinuingEducation(Util.null2String(addUpContinuingEducation));
|
|
|
|
|
|
//累计住房贷款利息
|
|
|
|
|
|
String addUpHousingLoanInterest = addUpDeductionRecordParam.getAddUpHousingLoanInterest();
|
|
|
|
|
|
addUpDeduction.setAddUpHousingLoanInterest(Util.null2String(addUpHousingLoanInterest));
|
|
|
|
|
|
//累计住房租金
|
|
|
|
|
|
String addUpHousingRent = addUpDeductionRecordParam.getAddUpHousingRent();
|
|
|
|
|
|
addUpDeduction.setAddUpHousingRent(Util.null2String(addUpHousingRent));
|
|
|
|
|
|
//累计赡养老人
|
|
|
|
|
|
String addUpSupportElderly = addUpDeductionRecordParam.getAddUpSupportElderly();
|
|
|
|
|
|
addUpDeduction.setAddUpSupportElderly(Util.null2String(addUpSupportElderly));
|
|
|
|
|
|
|
|
|
|
|
|
addUpDeduction.setAddUpIllnessMedical(Util.null2String(addUpDeductionRecordParam.getAddUpIllnessMedical()));
|
|
|
|
|
|
addUpDeduction.setAddUpInfantCare(Util.null2String(addUpDeductionRecordParam.getAddUpInfantCare()));
|
|
|
|
|
|
insertData.add(addUpDeduction);
|
|
|
|
|
|
//入库
|
|
|
|
|
|
addUpDeductionBiz.handleImportData(insertData);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void deleteSelectAddUpDeduction(AddUpDeductionRecordDeleteParam deleteParam) {
|
2022-10-27 13:59:11 +08:00
|
|
|
|
long currentEmployeeId = user.getUID();
|
|
|
|
|
|
// 获取所有个税扣缴义务人
|
|
|
|
|
|
Collection<TaxAgentManageRangeEmployeeDTO> taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId);
|
|
|
|
|
|
AddUpDeductionBiz addUpDeductionBiz = new AddUpDeductionBiz();
|
|
|
|
|
|
String declareMonthStr = deleteParam.getDeclareMonth();
|
|
|
|
|
|
List<Long> deleteIds = deleteParam.getIds();
|
|
|
|
|
|
// 已经核算过的不可操作
|
|
|
|
|
|
// 获取已经核算的数据
|
|
|
|
|
|
List<SalaryAcctEmployeePO> salaryAcctEmployees = getAccountedEmployeeData(declareMonthStr);
|
|
|
|
|
|
// 判断是否有核算过
|
|
|
|
|
|
List<Long> deleteList = new ArrayList<>();
|
2022-11-07 16:20:21 +08:00
|
|
|
|
for (int i = 0; i < deleteIds.size(); i++) {
|
2022-10-27 13:59:11 +08:00
|
|
|
|
Long id = deleteIds.get(i);
|
|
|
|
|
|
AddUpDeduction byId = addUpDeductionBiz.getById(id);
|
2022-11-07 16:20:21 +08:00
|
|
|
|
if (byId == null) {
|
2022-10-28 14:08:27 +08:00
|
|
|
|
throw new SalaryRunTimeException("数据不存在或已被删除!");
|
|
|
|
|
|
}
|
2022-10-27 13:59:11 +08:00
|
|
|
|
// 判断是否在个税扣缴义务人范围内
|
|
|
|
|
|
Optional<TaxAgentManageRangeEmployeeDTO> first = taxAgentList.stream().filter(m -> m.getTaxAgentId() == byId.getTaxAgentId()).findFirst();
|
2022-11-07 16:20:21 +08:00
|
|
|
|
if (!first.isPresent()) {
|
2022-10-27 13:59:11 +08:00
|
|
|
|
throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内");
|
|
|
|
|
|
}
|
|
|
|
|
|
// 判断用户是否存在
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(salaryAcctEmployees)) {
|
|
|
|
|
|
Optional<SalaryAcctEmployeePO> optionalAcctEmp = salaryAcctEmployees.stream().filter(f -> f.getEmployeeId().equals(byId.getEmployeeId()) && f.getTaxAgentId().equals(byId.getTaxAgentId())).findFirst();
|
|
|
|
|
|
if (optionalAcctEmp.isPresent()) {
|
2022-10-27 18:02:05 +08:00
|
|
|
|
throw new SalaryRunTimeException("所选数据在该年月中已完成核算并归档,不可进行删除!");
|
2022-10-27 13:59:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
deleteList.add(byId.getId());
|
|
|
|
|
|
}
|
|
|
|
|
|
addUpDeductionBiz.batchDeleteByIDS(deleteList);
|
2022-10-26 18:35:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
2022-10-27 13:59:11 +08:00
|
|
|
|
public void deleteAllAddUpDeduction(AddUpDeductionRecordDeleteParam deleteParam) {
|
|
|
|
|
|
String declareMonthStr = deleteParam.getDeclareMonth();
|
|
|
|
|
|
long currentEmployeeId = user.getUID();
|
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
|
// 获取所有个税扣缴义务人
|
|
|
|
|
|
Collection<TaxAgentManageRangeEmployeeDTO> taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId);
|
2022-10-27 18:02:05 +08:00
|
|
|
|
List<Long> taxAgentIds = taxAgentList.stream().map(TaxAgentManageRangeEmployeeDTO::getTaxAgentId).collect(Collectors.toList());
|
2022-10-27 13:59:11 +08:00
|
|
|
|
AddUpDeductionBiz addUpDeductionBiz = new AddUpDeductionBiz();
|
|
|
|
|
|
ArrayList<Date> declareMonthDate = new ArrayList<>();
|
|
|
|
|
|
try {
|
2022-11-07 16:20:21 +08:00
|
|
|
|
declareMonthDate.add(sdf.parse(declareMonthStr + "-01"));
|
|
|
|
|
|
} catch (Exception e) {
|
2022-10-27 13:59:11 +08:00
|
|
|
|
throw new SalaryRunTimeException("日期异常");
|
|
|
|
|
|
}
|
2022-10-28 16:35:51 +08:00
|
|
|
|
AddUpDeductionQueryParam queryParam = null;
|
2022-11-07 16:20:21 +08:00
|
|
|
|
if (deleteParam.getTaxAgentId() != null && (!deleteParam.getTaxAgentId().equals(""))) {
|
2022-10-28 16:35:51 +08:00
|
|
|
|
// 设置了个税扣缴义务人
|
|
|
|
|
|
Long taxAgentId = SalaryEntityUtil.string2Long(deleteParam.getTaxAgentId());
|
|
|
|
|
|
boolean canDelete = taxAgentIds.stream().anyMatch(t -> t == taxAgentId);
|
2022-11-07 16:20:21 +08:00
|
|
|
|
if (!canDelete) {
|
2022-10-28 16:35:51 +08:00
|
|
|
|
throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内!");
|
|
|
|
|
|
}
|
|
|
|
|
|
ArrayList<Long> tai = new ArrayList<>();
|
|
|
|
|
|
tai.add(taxAgentId);
|
2022-11-07 16:20:21 +08:00
|
|
|
|
queryParam = AddUpDeductionQueryParam.builder().declareMonthDate(declareMonthDate).taxAgentIds(tai).build();
|
|
|
|
|
|
} else {
|
2022-10-28 16:35:51 +08:00
|
|
|
|
queryParam = AddUpDeductionQueryParam.builder().declareMonthDate(declareMonthDate).taxAgentIds(taxAgentIds).build();
|
|
|
|
|
|
}
|
2022-10-27 13:59:11 +08:00
|
|
|
|
// 获取所有想要删除的数据
|
|
|
|
|
|
List<AddUpDeductionDTO> list = addUpDeductionBiz.list(queryParam);
|
|
|
|
|
|
// 获取已经核算的数据
|
|
|
|
|
|
List<SalaryAcctEmployeePO> salaryAcctEmployees = getAccountedEmployeeData(declareMonthStr);
|
2022-11-07 16:20:21 +08:00
|
|
|
|
for (AddUpDeductionDTO item : list) {
|
2022-10-27 13:59:11 +08:00
|
|
|
|
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()) {
|
2022-11-07 16:20:21 +08:00
|
|
|
|
throw new SalaryRunTimeException("员工:" + item.getUsername() + ",在该年月中已完成核算并归档,不能进行一键清空!");
|
2022-10-27 13:59:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
List<Long> deleteIds = list.stream().map(AddUpDeductionDTO::getId).collect(Collectors.toList());
|
|
|
|
|
|
addUpDeductionBiz.batchDeleteByIDS(deleteIds);
|
2022-10-26 18:35:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-10-31 14:50:54 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public AddUpDeductionRecordDTO getAddUpDeduction(AddUpDeductionQueryParam param) {
|
|
|
|
|
|
long uid = user.getUID();
|
|
|
|
|
|
// 获取所有个税扣缴义务人
|
|
|
|
|
|
Collection<TaxAgentManageRangeEmployeeDTO> taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(uid);
|
|
|
|
|
|
List<String> taxAgentNames = taxAgentList.stream().map(TaxAgentManageRangeEmployeeDTO::getTaxAgentName).collect(Collectors.toList());
|
|
|
|
|
|
ArrayList<Long> ids = new ArrayList<>();
|
|
|
|
|
|
ids.add(param.getId());
|
|
|
|
|
|
AddUpDeductionQueryParam build = AddUpDeductionQueryParam.builder().ids(ids).build();
|
|
|
|
|
|
List<AddUpDeductionRecordDTO> addUpDeductionRecordDTOS = new AddUpDeductionBiz().recordList(build);
|
2022-11-07 16:20:21 +08:00
|
|
|
|
if (addUpDeductionRecordDTOS == null || addUpDeductionRecordDTOS.size() == 0) {
|
2022-10-31 14:50:54 +08:00
|
|
|
|
throw new SalaryRunTimeException("该数据不存在!");
|
|
|
|
|
|
}
|
|
|
|
|
|
String taxAgentName = addUpDeductionRecordDTOS.get(0).getTaxAgentName();
|
2022-11-07 16:20:21 +08:00
|
|
|
|
if (!taxAgentNames.contains(taxAgentName)) {
|
2022-10-31 14:50:54 +08:00
|
|
|
|
throw new SalaryRunTimeException("您无权查看该数据!");
|
|
|
|
|
|
}
|
|
|
|
|
|
return addUpDeductionRecordDTOS.get(0);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-11-04 15:16:27 +08:00
|
|
|
|
@Override
|
2022-11-07 16:20:21 +08:00
|
|
|
|
public void autoAddAll(Date operateTime) {
|
2022-11-04 15:16:27 +08:00
|
|
|
|
int uid = user.getUID();
|
2022-11-07 16:20:21 +08:00
|
|
|
|
Boolean isChief = getTaxAgentService(user).isChief((long) uid);
|
|
|
|
|
|
Collection<TaxAgentPO> taxAgents;
|
|
|
|
|
|
if (isChief) {
|
|
|
|
|
|
taxAgents = getTaxAgentService(user).listAll();
|
|
|
|
|
|
} else {
|
|
|
|
|
|
taxAgents = getTaxAgentService(user).listAllTaxAgentsAsAdmin((long) uid);
|
|
|
|
|
|
}
|
2022-11-08 10:49:14 +08:00
|
|
|
|
List<AddUpDeduction> updateList = new ArrayList<>();
|
|
|
|
|
|
List<AddUpDeduction> insertList = new ArrayList<>();
|
2022-11-04 15:16:27 +08:00
|
|
|
|
for (TaxAgentPO taxAgent : taxAgents) {
|
|
|
|
|
|
Collection<Long> employeeIds = getTaxAgentService(user)
|
|
|
|
|
|
.listEmployeeIdsInTaxAgent(taxAgent.getId());
|
|
|
|
|
|
List<SpecialAddDeductionPO> employeePOs = getSpecialAddDeductionService(user)
|
2022-11-08 13:46:56 +08:00
|
|
|
|
.getSpecialAddDeductionPOByEmployee(null, taxAgent.getId());
|
2022-11-04 15:16:27 +08:00
|
|
|
|
|
2022-11-07 16:20:21 +08:00
|
|
|
|
//获取上月员工数据,用于累加
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
|
|
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));
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2022-11-08 10:49:14 +08:00
|
|
|
|
Lists.partition(insertList, 100)
|
|
|
|
|
|
.forEach(l -> getAddUpDeductionMapper().insertData((List<AddUpDeduction>) l));
|
|
|
|
|
|
Lists.partition(updateList, 100)
|
|
|
|
|
|
.forEach(l -> getAddUpDeductionMapper().updateData((List<AddUpDeduction>) l));
|
2022-11-07 16:20:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 对每个扣除项做加法
|
|
|
|
|
|
*
|
|
|
|
|
|
* @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";
|
2022-11-04 15:16:27 +08:00
|
|
|
|
}
|
2022-11-07 16:20:21 +08:00
|
|
|
|
return new BigDecimal(var0)
|
|
|
|
|
|
.add(new BigDecimal(var1))
|
|
|
|
|
|
.toString();
|
2022-11-04 15:16:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-11-07 16:20:21 +08:00
|
|
|
|
private Map<Long, List<AddUpDeduction>> getEmpInfoByYearMonth(TaxAgentPO taxAgent, List<SpecialAddDeductionPO> employeePOs, YearMonth lastMonth) {
|
2022-11-04 15:16:27 +08:00
|
|
|
|
List<AddUpDeduction> addUpDeductionList = getAddUpDeductionList(lastMonth,
|
|
|
|
|
|
employeePOs.stream().map(SpecialAddDeductionPO::getEmployeeId).collect(Collectors.toList()),
|
|
|
|
|
|
taxAgent.getId());
|
2022-11-08 10:49:14 +08:00
|
|
|
|
return addUpDeductionList.stream()
|
|
|
|
|
|
.filter(addUpDeduction -> taxAgent.getId().equals(addUpDeduction.getTaxAgentId()))
|
|
|
|
|
|
.collect(Collectors.groupingBy(AddUpDeduction::getEmployeeId));
|
2022-11-04 15:16:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-10-26 18:35:23 +08:00
|
|
|
|
|
2022-05-27 14:51:53 +08:00
|
|
|
|
private void checkImportParam(AddUpDeductionImportParam importParam) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//excel文件id
|
|
|
|
|
|
String imageId = Util.null2String(importParam.getImageId());
|
|
|
|
|
|
//税款所属期
|
|
|
|
|
|
String declareMonthStr = Util.null2String(importParam.getDeclareMonth());
|
|
|
|
|
|
//个税扣缴义务人
|
|
|
|
|
|
String taxAgentId = Util.null2String(importParam.getTaxAgentId());
|
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isBlank(imageId)) {
|
|
|
|
|
|
throw new SalaryRunTimeException("文件不存在");
|
|
|
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isBlank(declareMonthStr)) {
|
|
|
|
|
|
throw new SalaryRunTimeException("税款所属期为空");
|
|
|
|
|
|
}
|
2022-03-04 10:10:38 +08:00
|
|
|
|
}
|
2022-03-08 15:40:26 +08:00
|
|
|
|
|
2022-03-09 16:40:14 +08:00
|
|
|
|
|
|
|
|
|
|
@Override
|
2022-06-09 17:45:28 +08:00
|
|
|
|
public Map<String, Object> preview(AddUpDeductionImportParam importParam) {
|
2022-05-27 14:46:01 +08:00
|
|
|
|
Map<String, Object> apidatas = new HashMap<String, Object>();
|
|
|
|
|
|
//excel文件id
|
|
|
|
|
|
String imageId = Util.null2String(importParam.getImageId());
|
|
|
|
|
|
Validate.notBlank(imageId, "imageId为空");
|
|
|
|
|
|
|
|
|
|
|
|
InputStream fileInputStream = null;
|
|
|
|
|
|
try {
|
|
|
|
|
|
fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(imageId));
|
|
|
|
|
|
List<AddUpDeductionDTO> addUpDeductions = ExcelParseHelper.parse2Map(fileInputStream, AddUpDeductionDTO.class, 0, 1, 14, "addUpDeductionTemplate.xlsx");
|
|
|
|
|
|
apidatas.put("preview", addUpDeductions);
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
IOUtils.closeQuietly(fileInputStream);
|
|
|
|
|
|
}
|
|
|
|
|
|
return apidatas;
|
2022-03-09 16:40:14 +08:00
|
|
|
|
}
|
2022-03-10 11:09:08 +08:00
|
|
|
|
|
2022-05-25 13:49:25 +08:00
|
|
|
|
|
2022-05-26 11:02:55 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public AddUpDeduction getById(Long id) {
|
|
|
|
|
|
return getAddUpDeductionMapper().getById(id);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public PageInfo<AddUpDeductionDTO> listPage(AddUpDeductionQueryParam queryParam) {
|
2022-06-07 19:10:40 +08:00
|
|
|
|
//申报月份
|
|
|
|
|
|
List<String> declareMonth = queryParam.getDeclareMonth();
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(declareMonth)) {
|
|
|
|
|
|
queryParam.setDeclareMonth(declareMonth.stream().map(e -> e + "-01 00:00:00").collect(Collectors.toList()));
|
2022-06-24 18:05:08 +08:00
|
|
|
|
queryParam.setDeclareMonthDate(declareMonth.stream().map(e -> e + "-01 00:00:00").map(SalaryDateUtil::dateStrToLocalTime).collect(Collectors.toList()));
|
2022-06-07 19:10:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-06-09 17:45:28 +08:00
|
|
|
|
long employeeId = user.getUID();
|
2022-05-26 11:02:55 +08:00
|
|
|
|
|
2022-06-09 17:45:28 +08:00
|
|
|
|
Boolean needAuth = getTaxAgentService(user).isNeedAuth(employeeId);
|
|
|
|
|
|
if (needAuth) {
|
|
|
|
|
|
List<Long> taxAgentIdsAsAdmin = getTaxAgentService(user).listAllTaxAgentsAsAdmin(employeeId).stream().map(TaxAgentPO::getId).collect(Collectors.toList());
|
|
|
|
|
|
if (CollectionUtils.isEmpty(taxAgentIdsAsAdmin)) {
|
|
|
|
|
|
return new PageInfo<>(AddUpDeductionDTO.class);
|
|
|
|
|
|
}
|
|
|
|
|
|
queryParam.setTaxAgentIds(taxAgentIdsAsAdmin);
|
2022-05-26 11:02:55 +08:00
|
|
|
|
}
|
2022-06-09 17:45:28 +08:00
|
|
|
|
|
2022-09-26 18:51:17 +08:00
|
|
|
|
//排序配置
|
|
|
|
|
|
OrderRuleVO orderRule = getSalarySysConfService(user).orderRule();
|
|
|
|
|
|
queryParam.setOrderRule(orderRule);
|
|
|
|
|
|
|
2022-06-09 17:45:28 +08:00
|
|
|
|
SalaryPageUtil.start(queryParam.getCurrent(), queryParam.getPageSize());
|
|
|
|
|
|
List<AddUpDeductionDTO> list = getAddUpDeductionMapper().list(queryParam);
|
2022-06-23 14:08:55 +08:00
|
|
|
|
AddUpDeductionStrDTOEncrypt.decryptAddUpDeductionList(list);
|
|
|
|
|
|
return new PageInfo<>(list, AddUpDeductionDTO.class);
|
2022-05-26 11:02:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public PageInfo<AddUpDeductionRecordDTO> recordListPage(AddUpDeductionQueryParam queryParam) {
|
|
|
|
|
|
long employeeId = (long) user.getUID();
|
2022-06-09 17:45:28 +08:00
|
|
|
|
|
|
|
|
|
|
Boolean needAuth = getTaxAgentService(user).isNeedAuth(employeeId);
|
2022-06-13 17:05:36 +08:00
|
|
|
|
if (needAuth) {
|
2022-06-09 17:45:28 +08:00
|
|
|
|
List<Long> taxAgentIdsAsAdmin = getTaxAgentService(user).listAllTaxAgentsAsAdmin(employeeId).stream().map(TaxAgentPO::getId).collect(Collectors.toList());
|
|
|
|
|
|
if (CollectionUtils.isEmpty(taxAgentIdsAsAdmin)) {
|
|
|
|
|
|
return new PageInfo<>(AddUpDeductionRecordDTO.class);
|
|
|
|
|
|
}
|
|
|
|
|
|
queryParam.setTaxAgentIds(taxAgentIdsAsAdmin);
|
2022-05-26 11:02:55 +08:00
|
|
|
|
}
|
2022-06-09 17:45:28 +08:00
|
|
|
|
|
|
|
|
|
|
SalaryPageUtil.start(queryParam.getCurrent(), queryParam.getPageSize());
|
|
|
|
|
|
List<AddUpDeductionRecordDTO> list = getAddUpDeductionMapper().recordList(queryParam);
|
2022-06-23 14:08:55 +08:00
|
|
|
|
AddUpDeductionRecordStrDTOEncrypt.decryptAddUpDeductionRecordDTO(list);
|
|
|
|
|
|
return new PageInfo<>(list, AddUpDeductionRecordDTO.class);
|
2022-05-26 11:02:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-05-25 13:49:25 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 导出详情列表
|
|
|
|
|
|
*
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2022-08-26 14:06:21 +08:00
|
|
|
|
@Override
|
2022-05-25 13:49:25 +08:00
|
|
|
|
public XSSFWorkbook exportDetail(Long beLongEmployeeId, boolean isChief, AddUpDeductionQueryParam queryParam) {
|
2022-05-25 16:51:43 +08:00
|
|
|
|
queryParam.setEmployeeId(beLongEmployeeId);
|
|
|
|
|
|
|
2022-05-09 14:11:07 +08:00
|
|
|
|
EmployBiz employBiz = new EmployBiz();
|
|
|
|
|
|
AddUpDeductionBiz biz = new AddUpDeductionBiz();
|
|
|
|
|
|
|
|
|
|
|
|
Long id = queryParam.getAccumulatedSpecialAdditionalDeductionId();
|
|
|
|
|
|
if (id == null) {
|
|
|
|
|
|
throw new SalaryRunTimeException("id不能为空");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AddUpDeduction po = biz.getById(id);
|
|
|
|
|
|
if (po == null) {
|
2022-05-24 15:20:12 +08:00
|
|
|
|
throw new SalaryRunTimeException(String.format("累计专项附加扣除不存在" + "[id:%s]", id));
|
2022-05-09 14:11:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
List<DataCollectionEmployee> employeeList = employBiz.getEmployeeByIds(Collections.singletonList(po.getEmployeeId()));
|
|
|
|
|
|
if (CollectionUtils.isEmpty(employeeList)) {
|
|
|
|
|
|
throw new SalaryRunTimeException("员工信息不存在");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//查询参数
|
|
|
|
|
|
queryParam.setEmployeeId(po.getEmployeeId());
|
|
|
|
|
|
//申报月份
|
|
|
|
|
|
List<String> declareMonth = queryParam.getDeclareMonth();
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(declareMonth)) {
|
|
|
|
|
|
queryParam.setDeclareMonth(declareMonth.stream().map(e -> e + "-01 00:00:00").collect(Collectors.toList()));
|
2022-06-24 18:05:08 +08:00
|
|
|
|
queryParam.setDeclareMonthDate(declareMonth.stream().map(e -> e + "-01 00:00:00").map(SalaryDateUtil::dateStrToLocalTime).collect(Collectors.toList()));
|
2022-05-09 14:11:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-05-25 13:49:25 +08:00
|
|
|
|
//获取操作按钮资源
|
|
|
|
|
|
List<List<String>> rowList = getExcelRowDetailList(isChief, queryParam);
|
|
|
|
|
|
|
|
|
|
|
|
//获取excel
|
|
|
|
|
|
return ExcelUtil.genWorkbook(rowList, "累计专项附加扣除明细");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 导出详情
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param param
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
private List<List<String>> getExcelRowDetailList(boolean isChief, AddUpDeductionQueryParam param) {
|
|
|
|
|
|
long employeeId = user.getUID();
|
|
|
|
|
|
|
|
|
|
|
|
//excel标题
|
|
|
|
|
|
List<String> title = Arrays.asList("姓名", "申报月份", "个税扣缴义务人", "部门", "工号", "累计子女教育", "累计继续教育", "累计住房贷款利息", "累计住房租金", "累计赡养老人", "累计大病医疗", "累计婴幼儿照护");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM");
|
|
|
|
|
|
//查询详细信息
|
|
|
|
|
|
List<AddUpDeductionRecordDTO> list = new AddUpDeductionBiz().recordList(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.getDeclareMonth() == null ? "" : formatter.format(dto.getDeclareMonth())));
|
|
|
|
|
|
cellList.add(Util.null2String(dto.getTaxAgentName()));
|
|
|
|
|
|
cellList.add(Util.null2String(dto.getDepartmentName()));
|
|
|
|
|
|
cellList.add(Util.null2String(dto.getJobNum()));
|
|
|
|
|
|
cellList.add(Util.null2String(dto.getAddUpChildEducation()));
|
|
|
|
|
|
cellList.add(Util.null2String(dto.getAddUpContinuingEducation()));
|
|
|
|
|
|
cellList.add(Util.null2String(dto.getAddUpHousingLoanInterest()));
|
|
|
|
|
|
cellList.add(Util.null2String(dto.getAddUpHousingRent()));
|
|
|
|
|
|
cellList.add(Util.null2String(dto.getAddUpSupportElderly()));
|
|
|
|
|
|
cellList.add(Util.null2String(dto.getAddUpIllnessMedical()));
|
|
|
|
|
|
cellList.add(Util.null2String(dto.getAddUpInfantCare()));
|
|
|
|
|
|
return cellList;
|
|
|
|
|
|
}).collect(Collectors.toList()))
|
|
|
|
|
|
.orElse(Collections.emptyList());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 开启分权并且不是薪酬模块总管理员
|
2022-06-09 17:45:28 +08:00
|
|
|
|
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());
|
2022-05-25 13:49:25 +08:00
|
|
|
|
// List<AddUpDeduction> lastList = getLastListByModifier(employeeId, tenantKey);
|
|
|
|
|
|
list = list.stream().filter(f ->
|
2022-06-13 17:05:36 +08:00
|
|
|
|
// 作为管理员
|
|
|
|
|
|
taxAgentIdsAsAdmin.contains(f.getTaxAgentId())
|
|
|
|
|
|
// 作为分管理员
|
|
|
|
|
|
|| TaxAgentBO.checkTaxAgentAndEmployee(taxAgentEmployees, f.getTaxAgentId(), f.getEmployeeId())
|
2022-05-25 13:49:25 +08:00
|
|
|
|
).collect(Collectors.toList());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<List<String>> rowList = new ArrayList<>();
|
|
|
|
|
|
rowList.add(title);
|
|
|
|
|
|
rowList.addAll(dataRowList);
|
|
|
|
|
|
return rowList;
|
2022-03-10 11:09:08 +08:00
|
|
|
|
}
|
2022-04-11 20:17:47 +08:00
|
|
|
|
|
2022-05-25 13:49:25 +08:00
|
|
|
|
|
2022-04-11 20:17:47 +08:00
|
|
|
|
@Override
|
2022-06-29 17:38:00 +08:00
|
|
|
|
public List<AddUpDeduction> getAddUpDeductionList(YearMonth declareMonth, List<Long> employeeIds, Long taxAgentId) {
|
2022-04-11 20:17:47 +08:00
|
|
|
|
AddUpDeductionBiz addUpDeductionBiz = new AddUpDeductionBiz();
|
|
|
|
|
|
if (declareMonth == null) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100342, "参数有误:申报月份、租户key必传"));
|
|
|
|
|
|
}
|
2022-06-29 17:38:00 +08:00
|
|
|
|
return addUpDeductionBiz.listSome(AddUpDeduction.builder().declareMonth(SalaryDateUtil.toDateStartOfMonth(declareMonth)).employeeIds(employeeIds).taxAgentId(taxAgentId).build());
|
2022-04-11 20:17:47 +08:00
|
|
|
|
}
|
2022-04-28 17:44:26 +08:00
|
|
|
|
|
|
|
|
|
|
@Override
|
2022-05-26 11:02:55 +08:00
|
|
|
|
public XSSFWorkbook downloadTemplate(boolean isChief, AddUpDeductionQueryParam queryParam) {
|
2022-04-28 17:44:26 +08:00
|
|
|
|
|
|
|
|
|
|
String sheetName = SalaryI18nUtil.getI18nLabel(101603, "累计专项附加扣除导入模板");
|
|
|
|
|
|
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(86321, "累计子女教育"),
|
|
|
|
|
|
SalaryI18nUtil.getI18nLabel(86323, "累计继续教育"),
|
|
|
|
|
|
SalaryI18nUtil.getI18nLabel(86324, "累计住房贷款利息"),
|
|
|
|
|
|
SalaryI18nUtil.getI18nLabel(86325, "累计住房租金"),
|
|
|
|
|
|
SalaryI18nUtil.getI18nLabel(86326, "累计赡养老人"),
|
2022-05-20 14:41:42 +08:00
|
|
|
|
SalaryI18nUtil.getI18nLabel(105142, "累计大病医疗"),
|
|
|
|
|
|
SalaryI18nUtil.getI18nLabel(105142, "累计婴幼儿照护")
|
2022-04-28 17:44:26 +08:00
|
|
|
|
};
|
2022-09-26 13:46:43 +08:00
|
|
|
|
|
|
|
|
|
|
List<String> dataIndexList = Lists.newArrayList("username", "taxAgentName", "departmentName", "mobile", "workcode", "idNo", "hiredate", "billMonth", "supplementaryMonth");
|
2022-04-28 17:44:26 +08:00
|
|
|
|
List<Object> headerList = Arrays.asList(header);
|
2022-09-26 13:46:43 +08:00
|
|
|
|
|
|
|
|
|
|
//查询当前申报月份和个税扣缴义务人的累计专项附加扣除表数据
|
|
|
|
|
|
List<Map<String, Object>> resultMapList = getAddUpDeductionDate(queryParam);
|
|
|
|
|
|
// excel导出的数据
|
|
|
|
|
|
List<List<Object>> rows = Lists.newArrayListWithExpectedSize(resultMapList.size());
|
|
|
|
|
|
|
2022-04-28 17:44:26 +08:00
|
|
|
|
rows.add(headerList);
|
2022-09-26 13:46:43 +08:00
|
|
|
|
for (Map<String, Object> map : resultMapList) {
|
|
|
|
|
|
List<Object> row = Lists.newArrayListWithExpectedSize(headerList.size());
|
|
|
|
|
|
for (String dataIndex : dataIndexList) {
|
|
|
|
|
|
row.add(map.getOrDefault(dataIndex, StringUtils.EMPTY));
|
|
|
|
|
|
}
|
|
|
|
|
|
rows.add(row);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-05-26 11:02:55 +08:00
|
|
|
|
|
2022-04-28 17:44:26 +08:00
|
|
|
|
// 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, "输入数字")));
|
|
|
|
|
|
excelComments.add(new ExcelComment(11, 0, 14, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字")));
|
|
|
|
|
|
excelComments.add(new ExcelComment(12, 0, 15, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字")));
|
2022-05-20 14:41:42 +08:00
|
|
|
|
excelComments.add(new ExcelComment(13, 0, 16, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字")));
|
2022-04-28 17:44:26 +08:00
|
|
|
|
|
|
|
|
|
|
XSSFWorkbook book = ExcelUtil.genWorkbookV2(rows, sheetName, excelComments);
|
|
|
|
|
|
|
|
|
|
|
|
return book;
|
|
|
|
|
|
}
|
2022-05-24 15:20:12 +08:00
|
|
|
|
|
2022-09-26 13:46:43 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 查询当前申报月份和个税扣缴义务人的累计专项附加扣除表数据
|
|
|
|
|
|
*/
|
|
|
|
|
|
private List<Map<String, Object>> getAddUpDeductionDate(AddUpDeductionQueryParam queryParam) {
|
|
|
|
|
|
|
|
|
|
|
|
List<Map<String, Object>> resultList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
//申报月份
|
|
|
|
|
|
List<String> declareMonth = queryParam.getDeclareMonth();
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(declareMonth)) {
|
|
|
|
|
|
queryParam.setDeclareMonth(declareMonth.stream().map(e -> e + "-01 00:00:00").collect(Collectors.toList()));
|
|
|
|
|
|
queryParam.setDeclareMonthDate(declareMonth.stream().map(e -> e + "-01 00:00:00").map(SalaryDateUtil::dateStrToLocalTime).collect(Collectors.toList()));
|
|
|
|
|
|
}
|
|
|
|
|
|
List<AddUpDeductionDTO> list = new AddUpDeductionBiz().list(queryParam);
|
|
|
|
|
|
|
2022-11-07 16:20:21 +08:00
|
|
|
|
for (AddUpDeductionDTO dto : list) {
|
2022-09-26 13:46:43 +08:00
|
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
2022-09-29 10:28:46 +08:00
|
|
|
|
resultMap.put("username", Util.null2String(dto.getUsername()));
|
|
|
|
|
|
resultMap.put("departmentName", Util.null2String(dto.getDepartmentName()));
|
|
|
|
|
|
resultMap.put("mobile", Util.null2String(dto.getMobile()));
|
|
|
|
|
|
resultMap.put("workcode", Util.null2String(dto.getJobNum()));
|
|
|
|
|
|
resultMap.put("taxAgentName", Util.null2String(dto.getTaxAgentName()));
|
2022-09-26 13:46:43 +08:00
|
|
|
|
if (dto.getIdNo() != null) {
|
2022-09-29 10:28:46 +08:00
|
|
|
|
resultMap.put("idNo", Util.null2String(dto.getIdNo()));
|
2022-09-26 13:46:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (dto.getHiredate() != null) {
|
2022-09-29 10:28:46 +08:00
|
|
|
|
resultMap.put("hiredate", Util.null2String(dto.getHiredate()));
|
2022-09-26 13:46:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
resultList.add(resultMap);
|
|
|
|
|
|
}
|
|
|
|
|
|
return resultList;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-05-24 15:20:12 +08:00
|
|
|
|
|
2022-05-25 13:10:03 +08:00
|
|
|
|
@Override
|
2022-05-25 13:49:25 +08:00
|
|
|
|
public XSSFWorkbook export(boolean isChief, AddUpDeductionQueryParam queryParam) {
|
2022-05-25 13:10:03 +08:00
|
|
|
|
|
|
|
|
|
|
//获取操作按钮资源
|
2022-05-25 13:49:25 +08:00
|
|
|
|
List<List<String>> rowList = getExcelRowList(isChief, queryParam);
|
2022-05-25 13:10:03 +08:00
|
|
|
|
|
|
|
|
|
|
//获取excel
|
|
|
|
|
|
return ExcelUtil.genWorkbook(rowList, "累计专项附加扣除");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 获取excel数据行
|
|
|
|
|
|
*
|
|
|
|
|
|
* @return 导出数据行集合
|
|
|
|
|
|
*/
|
2022-05-25 13:49:25 +08:00
|
|
|
|
private List<List<String>> getExcelRowList(boolean isChief, AddUpDeductionQueryParam param) {
|
|
|
|
|
|
Long employeeId = (long) user.getUID();
|
|
|
|
|
|
|
2022-05-25 13:10:03 +08:00
|
|
|
|
//excel标题
|
|
|
|
|
|
List<String> title = Arrays.asList("姓名", "个税扣缴义务人", "部门", "手机号", "工号", "证件号码", "入职日期", "累计子女教育", "累计继续教育", "累计住房贷款利息", "累计住房租金", "累计赡养老人", "累计大病医疗", "累计婴幼儿照护");
|
|
|
|
|
|
|
2022-09-26 18:51:17 +08:00
|
|
|
|
|
|
|
|
|
|
//排序配置
|
|
|
|
|
|
OrderRuleVO orderRule = getSalarySysConfService(user).orderRule();
|
|
|
|
|
|
param.setOrderRule(orderRule);
|
|
|
|
|
|
|
2022-05-25 13:49:25 +08:00
|
|
|
|
List<AddUpDeductionDTO> list = new AddUpDeductionBiz().list(param);
|
|
|
|
|
|
|
|
|
|
|
|
// 开启分权并且不是薪酬模块总管理员
|
2022-06-09 17:45:28 +08:00
|
|
|
|
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());
|
2022-05-25 13:49:25 +08:00
|
|
|
|
list = list.stream().filter(f ->
|
2022-06-13 17:05:36 +08:00
|
|
|
|
// 作为管理员
|
|
|
|
|
|
taxAgentIdsAsAdmin.contains(f.getTaxAgentId())
|
|
|
|
|
|
// 作为分管理员
|
|
|
|
|
|
|| TaxAgentBO.checkTaxAgentAndEmployee(taxAgentEmployees, f.getTaxAgentId(), f.getEmployeeId())
|
2022-05-25 13:49:25 +08:00
|
|
|
|
).collect(Collectors.toList());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-05-25 13:10:03 +08:00
|
|
|
|
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.getAddUpChildEducation()));
|
|
|
|
|
|
cellList.add(Util.null2String(dto.getAddUpContinuingEducation()));
|
|
|
|
|
|
cellList.add(Util.null2String(dto.getAddUpHousingLoanInterest()));
|
|
|
|
|
|
cellList.add(Util.null2String(dto.getAddUpHousingRent()));
|
|
|
|
|
|
cellList.add(Util.null2String(dto.getAddUpSupportElderly()));
|
|
|
|
|
|
cellList.add(Util.null2String(dto.getAddUpIllnessMedical()));
|
|
|
|
|
|
cellList.add(Util.null2String(dto.getAddUpInfantCare()));
|
|
|
|
|
|
return cellList;
|
|
|
|
|
|
}).collect(Collectors.toList()))
|
|
|
|
|
|
.orElse(Collections.emptyList());
|
|
|
|
|
|
|
|
|
|
|
|
List<List<String>> rowList = new ArrayList<>();
|
|
|
|
|
|
rowList.add(title);
|
|
|
|
|
|
rowList.addAll(dataRowList);
|
|
|
|
|
|
return rowList;
|
2022-05-24 15:20:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-05-25 16:51:43 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 根据年月获取已核算数据
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param yearMonth
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public List<SalaryAcctEmployeePO> getAccountedEmployeeData(String yearMonth) {
|
|
|
|
|
|
List<SalaryAcctEmployeePO> list = Lists.newArrayList();
|
2022-05-26 11:02:55 +08:00
|
|
|
|
LocalDate salaryMonthDate = LocalDate.parse(yearMonth + "-01", SalaryDateUtil.DATE_FORMATTER);
|
2022-05-25 16:51:43 +08:00
|
|
|
|
List<SalaryAcctRecordPO> salaryAcctRecords = getSalaryAcctRecordService(user).listBySalaryMonth(LocalDateRange.builder().fromDate(SalaryDateUtil.localDateToDate(salaryMonthDate)).endDate(SalaryDateUtil.localDateToDate(salaryMonthDate)).build());
|
2022-05-26 11:02:55 +08:00
|
|
|
|
salaryAcctRecords.forEach(e -> {
|
2022-05-25 16:51:43 +08:00
|
|
|
|
boolean isAccounted = e.getStatus() > SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue();
|
|
|
|
|
|
if (isAccounted) {
|
2022-10-28 14:08:27 +08:00
|
|
|
|
// list.addAll(getSalaryAcctEmployeeService(user).listBySalaryAcctRecordIds(Collections.singleton(salaryAcctRecords.get(0).getId())));
|
|
|
|
|
|
list.addAll(getSalaryAcctEmployeeService(user).listBySalaryAcctRecordIds(Collections.singleton(e.getId())));
|
2022-05-25 16:51:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-03-03 13:50:03 +08:00
|
|
|
|
}
|