weaver-hrm-salary/src/com/engine/salary/wrapper/OtherDeductionWrapper.java

375 lines
14 KiB
Java
Raw Normal View History

2022-05-31 09:58:35 +08:00
package com.engine.salary.wrapper;
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-05-31 11:21:51 +08:00
import com.engine.common.util.ServiceUtil;
2022-05-31 09:58:35 +08:00
import com.engine.core.impl.Service;
2024-12-25 10:36:37 +08:00
import com.engine.salary.entity.datacollection.dto.*;
import com.engine.salary.entity.datacollection.param.*;
2022-05-31 10:29:18 +08:00
import com.engine.salary.entity.datacollection.po.OtherDeductionPO;
import com.engine.salary.exception.SalaryRunTimeException;
2022-05-31 09:58:35 +08:00
import com.engine.salary.service.OtherDeductionService;
import com.engine.salary.service.SalaryEmployeeService;
2022-05-31 21:05:59 +08:00
import com.engine.salary.service.TaxAgentService;
2024-12-19 09:53:56 +08:00
import com.engine.salary.service.TaxDeclarationApiConfigService;
2022-05-31 11:21:51 +08:00
import com.engine.salary.service.impl.OtherDeductionServiceImpl;
import com.engine.salary.service.impl.SalaryEmployeeServiceImpl;
2022-05-31 21:05:59 +08:00
import com.engine.salary.service.impl.TaxAgentServiceImpl;
2024-12-19 09:53:56 +08:00
import com.engine.salary.service.impl.TaxDeclarationApiConfigServiceImpl;
2022-05-31 10:29:18 +08:00
import com.engine.salary.util.SalaryI18nUtil;
2022-05-31 09:58:35 +08:00
import com.engine.salary.util.page.PageInfo;
import lombok.extern.slf4j.Slf4j;
2022-05-31 11:21:51 +08:00
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import weaver.hrm.User;
2022-05-31 09:58:35 +08:00
import java.time.LocalDate;
import java.time.LocalDateTime;
2022-11-17 14:54:13 +08:00
import java.time.Month;
import java.time.format.DateTimeFormatter;
2022-05-31 09:58:35 +08:00
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Description: 其他免税扣除
* @Author: wangxiangzhong
* @Date: 2022/3/14 16:09
*/
@Slf4j
2022-05-31 09:58:35 +08:00
public class OtherDeductionWrapper extends Service {
2022-05-31 11:21:51 +08:00
private OtherDeductionService getOtherDeductionService(User user) {
return ServiceUtil.getService(OtherDeductionServiceImpl.class, user);
}
2024-12-19 09:53:56 +08:00
private TaxDeclarationApiConfigService getTaxDeclarationApiConfigService(User user) {
return ServiceUtil.getService(TaxDeclarationApiConfigServiceImpl.class, user);
}
2022-05-31 21:05:59 +08:00
private TaxAgentService getTaxAgentV2Service(User user) {
return ServiceUtil.getService(TaxAgentServiceImpl.class, user);
2022-05-31 11:21:51 +08:00
}
2022-05-31 11:21:51 +08:00
private SalaryEmployeeService getSalaryEmployeeService(User user) {
return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user);
}
2022-05-31 09:58:35 +08:00
/**
* 数据采集-其他免税扣除列表的高级搜索
*
* @return
*/
public Map<String, Object> getSearchCondition() {
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-05-31 10:29:18 +08:00
SearchConditionItem username = conditionFactory.createCondition(ConditionType.INPUT, 25034, "username");
2022-05-31 09:58:35 +08:00
username.setInputType("input");
username.setColSpan(2);//定义一行显示条件数默认值为2,当值为1时标识该条件单独占一行
2022-05-31 10:29:18 +08:00
username.setFieldcol(16); //条件输入框所占宽度默认值18
2022-05-31 09:58:35 +08:00
username.setLabelcol(8);
username.setViewAttr(2); // 编辑权限 1只读2可编辑 3必填 默认2
username.setLabel("姓名"); //设置文本值 这个将覆盖多语言标签的值
conditionItems.add(username);
2024-03-14 11:19:02 +08:00
SearchConditionItem departmentName = conditionFactory.createCondition(ConditionType.BROWSER, 502227, "departmentIds", "57");
2022-05-31 09:58:35 +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-05-31 10:29:18 +08:00
SearchConditionItem jobNum = conditionFactory.createCondition(ConditionType.INPUT, 25034, "jobNum");
2022-05-31 09:58:35 +08:00
jobNum.setInputType("input");
jobNum.setColSpan(2);
jobNum.setFieldcol(16);
jobNum.setLabelcol(8);
jobNum.setViewAttr(2);
jobNum.setLabel("工号");
conditionItems.add(jobNum);
// 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);
//
// //日期范围选项
// List<SearchConditionOption> dateOptions = new ArrayList<SearchConditionOption>();
2023-04-19 10:15:01 +08:00
// dateOptions.add(new SearchConditionOption("6", SalaryI18nUtil.getI18nLabel(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-31 09:58:35 +08:00
2022-05-31 10:29:18 +08:00
addGroups.add(new SearchConditionGroup("常用条件", true, conditionItems));
2022-05-31 09:58:35 +08:00
2022-05-31 10:29:18 +08:00
apidatas.put("condition", addGroups);
2022-05-31 09:58:35 +08:00
return apidatas;
}
/**
* 数据采集-其他免税扣除列表(分页)
*
* @param queryParam
* @return
*/
public PageInfo<OtherDeductionListDTO> list(OtherDeductionQueryParam queryParam) {
2022-05-31 11:21:51 +08:00
return getOtherDeductionService(user).listPage(queryParam);
2022-05-31 09:58:35 +08:00
}
/**
* 数据采集-其他免税扣除详情列表(分页)
*
* @param queryParam
* @return
*/
2022-05-31 10:29:18 +08:00
public PageInfo<OtherDeductionRecordDTO> getDetailList(OtherDeductionQueryParam queryParam) {
2022-05-31 09:58:35 +08:00
Long id = queryParam.getOtherTaxExemptDeductionId();
2022-05-31 11:21:51 +08:00
OtherDeductionPO po = getOtherDeductionService(user).getById(id);
2022-05-31 09:58:35 +08:00
if (po == null) {
2022-05-31 10:29:18 +08:00
throw new SalaryRunTimeException(String.format(SalaryI18nUtil.getI18nLabel(100415, "其他免税扣除不存在") + "[id:%s]", id));
2022-05-31 09:58:35 +08:00
}
queryParam.setEmployeeId(po.getEmployeeId());
2022-05-31 11:21:51 +08:00
return getOtherDeductionService(user).recordListPage(queryParam);
2022-05-31 09:58:35 +08:00
}
/**
* 导出-其他免税扣除列表
*
* @param queryParam
* @return
*/
2022-05-31 11:21:51 +08:00
public XSSFWorkbook export(OtherDeductionQueryParam queryParam) {
return getOtherDeductionService(user).export(queryParam);
2022-05-31 09:58:35 +08:00
}
/**
* 导出-其他免税扣除详情列表
*
* @param queryParam
* @return
*/
2022-05-31 11:21:51 +08:00
public XSSFWorkbook exportDetail(OtherDeductionQueryParam queryParam) {
2022-05-31 09:58:35 +08:00
Long id = queryParam.getOtherTaxExemptDeductionId();
2022-05-31 11:21:51 +08:00
OtherDeductionPO po = getOtherDeductionService(user).getById(id);
2022-05-31 09:58:35 +08:00
if (po == null) {
throw new SalaryRunTimeException(String.format(SalaryI18nUtil.getI18nLabel(100415, "其他免税扣除不存在") + "[id:%s]", id));
2022-05-31 09:58:35 +08:00
}
2022-05-31 11:21:51 +08:00
return getOtherDeductionService(user).exportDetail(queryParam);
2022-05-31 09:58:35 +08:00
}
/**
* 下载导入模板
*
* @param queryParam
* @return
*/
2022-05-31 11:21:51 +08:00
public XSSFWorkbook downloadTemplate(OtherDeductionQueryParam queryParam) {
2024-12-19 09:53:56 +08:00
//是否开启了智能算薪
boolean enableUse = getTaxDeclarationApiConfigService(user).enableUse();
2024-12-25 10:36:37 +08:00
if (enableUse) {
2024-12-19 09:53:56 +08:00
return getOtherDeductionService(user).downloadDetailTemplate(queryParam);
2024-12-25 10:36:37 +08:00
} else {
2024-12-19 09:53:56 +08:00
return getOtherDeductionService(user).downloadTemplate(queryParam);
}
2022-05-31 09:58:35 +08:00
}
/**
2022-05-31 11:21:51 +08:00
* 预览
*/
public Map<String, Object> preview(OtherDeductionImportParam importParam) {
2022-05-31 11:21:51 +08:00
return getOtherDeductionService(user).preview(importParam);
}
/**
* 导入数据
2022-05-31 09:58:35 +08:00
*/
public Map<String, Object> importData(OtherDeductionImportParam importParam) {
2024-12-19 09:53:56 +08:00
//是否开启了智能算薪
boolean enableUse = getTaxDeclarationApiConfigService(user).enableUse();
2024-12-25 10:36:37 +08:00
if (enableUse) {
2024-12-19 09:53:56 +08:00
return getOtherDeductionService(user).importDetailData(importParam);
2024-12-25 10:36:37 +08:00
} else {
2024-12-19 09:53:56 +08:00
return getOtherDeductionService(user).importData(importParam);
}
2022-05-31 09:58:35 +08:00
}
2022-10-26 18:35:23 +08:00
/**
* 编辑数据
*/
public void editData(OtherDeductionParam otherDeductionParam) {
getOtherDeductionService(user).editData(otherDeductionParam);
}
/**
* 新增数据
*/
public void createData(OtherDeductionParam otherDeductionParam) {
getOtherDeductionService(user).createData(otherDeductionParam);
}
/**
* 删除所选数据
*/
public void deleteSelectData(AddUpDeductionRecordDeleteParam deleteParam) {
getOtherDeductionService(user).deleteSelectData(deleteParam);
}
/**
* 一键清空所有数据
*/
public void deleteAllData(AddUpDeductionRecordDeleteParam deleteParam) {
getOtherDeductionService(user).deleteAllData(deleteParam);
}
2022-10-31 14:50:54 +08:00
/**
* 获取数据
*/
public OtherDeductionRecordDTO getOtherDeduction(OtherDeductionParam otherDeductionParam) {
return getOtherDeductionService(user).getOtherDeduction(otherDeductionParam);
}
public String extendToLastMonth(OtherDeductionExtendLastParam param) {
LocalDateTime localDate = null;
try {
localDate = LocalDate.parse(param.getDeclareMonth() + "-01",
DateTimeFormatter.ofPattern("yyyy-MM-dd")).atStartOfDay();
param.setYearMonthTime(localDate);
} catch (Exception e) {
log.error("", e);
}
2022-11-17 14:54:13 +08:00
if (null == param.getDeclareMonth() || null == localDate || null == param.getYearMonthTime()) {
throw new SalaryRunTimeException("当前年月不合法");
}
2022-11-17 14:54:13 +08:00
if (Month.JANUARY.equals(localDate.getMonth())) {
2022-11-17 15:13:24 +08:00
throw new SalaryRunTimeException("操作失败,每年度内首月无法沿用上月");
2022-11-17 14:54:13 +08:00
}
param.setYearMonthTime(localDate);
return getOtherDeductionService(user).extendToLastMonth(param);
}
2024-12-24 10:54:57 +08:00
public PageInfo<FreeIncomeListDTO> freeIncomeList(OtherDeductionDetailQueryParam param) {
2024-12-25 10:36:37 +08:00
return getOtherDeductionService(user).freeIncomeList(param);
}
public PageInfo<DerateDeductionListDTO> derateDeductionList(OtherDeductionDetailQueryParam param) {
return getOtherDeductionService(user).derateDeductionList(param);
}
public PageInfo<EndowmentInsuranceListDTO> endowmentInsuranceList(OtherDeductionDetailQueryParam param) {
return getOtherDeductionService(user).endowmentInsuranceList(param);
}
public PageInfo<GrantDonationListDTO> grantDonationList(OtherDeductionDetailQueryParam param) {
return getOtherDeductionService(user).grantDonationList(param);
}
public PageInfo<HealthInsuranceListDTO> healthInsuranceList(OtherDeductionDetailQueryParam param) {
return getOtherDeductionService(user).healthInsuranceList(param);
}
public PageInfo<OtherDerateDeductionListDTO> otherDerateDeductionList(OtherDeductionDetailQueryParam param) {
return getOtherDeductionService(user).otherDerateDeductionList(param);
}
public PageInfo<PersonalPensionListDTO> personalPensionList(OtherDeductionDetailQueryParam param) {
return getOtherDeductionService(user).personalPensionList(param);
2024-12-24 10:54:57 +08:00
}
public void saveFreeIncome(FreeIncomeSaveParam param) {
getOtherDeductionService(user).saveFreeIncome(param);
}
2024-12-25 10:36:37 +08:00
public void saveEndowmentInsurance(EndowmentInsuranceSaveParam param) {
getOtherDeductionService(user).saveEndowmentInsurance(param);
}
public void saveGrantDonation(GrantDonationSaveParam param) {
getOtherDeductionService(user).saveGrantDonation(param);
}
public void saveHealthInsurance(HealthInsuranceSaveParam param) {
getOtherDeductionService(user).saveHealthInsurance(param);
}
public void saveOtherDerateDeduction(OtherDerateDeductionSaveParam param) {
getOtherDeductionService(user).saveOtherDerateDeduction(param);
}
public void saveDerateDeduction(DerateDeductionSaveParam param) {
getOtherDeductionService(user).saveDerateDeduction(param);
}
public void savePersonalPension(PersonalPensionSaveParam param) {
getOtherDeductionService(user).savePersonalPension(param);
}
public void deleteFreeIncome(OtherDeductionDetailDeleteParam param) {
getOtherDeductionService(user).deleteFreeIncome(param);
}
public void deleteEndowmentInsurance(OtherDeductionDetailDeleteParam param) {
getOtherDeductionService(user).deleteEndowmentInsurance(param);
}
public void deleteGrantDonation(OtherDeductionDetailDeleteParam param) {
getOtherDeductionService(user).deleteGrantDonation(param);
}
public void deleteHealthInsurance(OtherDeductionDetailDeleteParam param) {
getOtherDeductionService(user).deleteHealthInsurance(param);
}
public void deleteOtherDerateDeduction(OtherDeductionDetailDeleteParam param) {
getOtherDeductionService(user).deleteOtherDerateDeduction(param);
}
public void deleteDerateDeduction(OtherDeductionDetailDeleteParam param) {
getOtherDeductionService(user).deleteDerateDeduction(param);
}
public void deletePersonalPension(OtherDeductionDetailDeleteParam param) {
getOtherDeductionService(user).deletePersonalPension(param);
}
}