313 lines
16 KiB
Java
313 lines
16 KiB
Java
|
|
package com.engine.salary.wrapper;
|
|||
|
|
|
|||
|
|
import com.api.browser.bean.SearchConditionGroup;
|
|||
|
|
import com.api.browser.bean.SearchConditionItem;
|
|||
|
|
import com.api.browser.bean.SearchConditionOption;
|
|||
|
|
import com.api.browser.util.ConditionFactory;
|
|||
|
|
import com.api.browser.util.ConditionType;
|
|||
|
|
import com.engine.core.impl.Service;
|
|||
|
|
import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveTaxAgentFormDTO;
|
|||
|
|
import com.engine.salary.entity.salaryarchive.param.SalaryArchiveTaxAgentSaveParam;
|
|||
|
|
import com.engine.salary.entity.salaryarchive.po.SalaryArchiveTaxAgentPO;
|
|||
|
|
import com.engine.salary.entity.taxrate.TaxAgent;
|
|||
|
|
import com.engine.salary.enums.salaryarchive.SalaryArchiveTaxAgentAdjustReasonEnum;
|
|||
|
|
import com.engine.salary.exception.SalaryRunTimeException;
|
|||
|
|
import com.engine.salary.service.SalaryArchiveTaxAgentService;
|
|||
|
|
import com.engine.salary.service.TaxAgentService;
|
|||
|
|
import com.engine.salary.util.SalaryI18nUtil;
|
|||
|
|
|
|||
|
|
import java.util.*;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 薪资档案-个税扣缴义务人
|
|||
|
|
* <p>Copyright: Copyright (c) 2022</p>
|
|||
|
|
* <p>Company: 泛微软件</p>
|
|||
|
|
*
|
|||
|
|
* @author qiantao
|
|||
|
|
* @version 1.0
|
|||
|
|
**/
|
|||
|
|
public class SalaryArchiveTaxAgentWrapper extends Service {
|
|||
|
|
private SalaryArchiveTaxAgentService salaryArchiveTaxAgentService;
|
|||
|
|
private TaxAgentService taxAgentService;
|
|||
|
|
// @Resource
|
|||
|
|
// private SalaryBatchService salaryBatchService;
|
|||
|
|
// @Autowired
|
|||
|
|
// private ExecutorService taskExecutor;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 获取个税扣缴义务人调整表单
|
|||
|
|
* 获取调整原因和扣税义务人列表
|
|||
|
|
*
|
|||
|
|
* @param salaryArchiveId
|
|||
|
|
* @return
|
|||
|
|
*/
|
|||
|
|
public SalaryArchiveTaxAgentFormDTO getTaxAgentForm(Long salaryArchiveId) {
|
|||
|
|
if (salaryArchiveId == null) {
|
|||
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100425, "薪资档案id不能为空"));
|
|||
|
|
}
|
|||
|
|
// 个税扣缴义务人下拉列表
|
|||
|
|
Collection<TaxAgent> taxAgentList = taxAgentService.findAll();
|
|||
|
|
// 构建表单
|
|||
|
|
Map<String, Object> form = buildTaxAgentForm(taxAgentList, null, "", "", null);
|
|||
|
|
|
|||
|
|
return SalaryArchiveTaxAgentFormDTO.builder()
|
|||
|
|
.salaryArchiveId(salaryArchiveId)
|
|||
|
|
.salaryArchiveTaxAgentForm(form)
|
|||
|
|
.build();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private Map<String, Object> buildTaxAgentForm(Collection<TaxAgent> taxAgentList, Date effectiveTime, String adjustReason, String adjustBefore, Long adjustAfter) {
|
|||
|
|
// 个税扣缴义务人调整原因下拉列表
|
|||
|
|
List<SalaryArchiveTaxAgentAdjustReasonEnum> salaryArchiveTaxAgentAdjustReasonEnums = Arrays.asList(SalaryArchiveTaxAgentAdjustReasonEnum.values());
|
|||
|
|
|
|||
|
|
ConditionFactory conditionFactory = new ConditionFactory(user);
|
|||
|
|
|
|||
|
|
//条件组
|
|||
|
|
List<SearchConditionGroup> addGroups = new ArrayList<SearchConditionGroup>();
|
|||
|
|
List<SearchConditionItem> items = new ArrayList<SearchConditionItem>();
|
|||
|
|
|
|||
|
|
SearchConditionItem effectiveTimeItem = conditionFactory.createCondition(ConditionType.DATEPICKER, 502327, "effectiveTime");
|
|||
|
|
effectiveTimeItem.setColSpan(1);//定义一行显示条件数,默认值为2,当值为1时标识该条件单独占一行
|
|||
|
|
effectiveTimeItem.setFieldcol(12); //条件输入框所占宽度,默认值18
|
|||
|
|
effectiveTimeItem.setViewAttr(3); // 编辑权限 1:只读,2:可编辑, 3:必填 默认2
|
|||
|
|
effectiveTimeItem.setLength(10); // 设置输入长度
|
|||
|
|
effectiveTimeItem.setLabel("生效时间"); //设置文本值 这个将覆盖多语言标签的值
|
|||
|
|
effectiveTimeItem.setRules("required"); //设置字段填入规则
|
|||
|
|
items.add(effectiveTimeItem);
|
|||
|
|
|
|||
|
|
SearchConditionItem adjustReasonItem = conditionFactory.createCondition(ConditionType.SELECT, 502227, "adjustReason");
|
|||
|
|
List<SearchConditionOption> selectOptions = new ArrayList<>(); //设置选项值
|
|||
|
|
Arrays.stream(SalaryArchiveTaxAgentAdjustReasonEnum.values()).forEach(r -> {
|
|||
|
|
if (r.getValue().equals(adjustReason)) {
|
|||
|
|
selectOptions.add(new SearchConditionOption(r.getValue(), r.getDefaultLabel(), true));
|
|||
|
|
}
|
|||
|
|
selectOptions.add(new SearchConditionOption(r.getValue(), r.getDefaultLabel()));
|
|||
|
|
});
|
|||
|
|
adjustReasonItem.setOptions(selectOptions);
|
|||
|
|
effectiveTimeItem.setColSpan(1);
|
|||
|
|
effectiveTimeItem.setFieldcol(12);
|
|||
|
|
effectiveTimeItem.setViewAttr(3);
|
|||
|
|
effectiveTimeItem.setLength(10);
|
|||
|
|
adjustReasonItem.setLabel("调整原因");
|
|||
|
|
effectiveTimeItem.setRules("required"); //设置字段填入规则
|
|||
|
|
items.add(adjustReasonItem);
|
|||
|
|
|
|||
|
|
SearchConditionItem adjustBeforeItem = conditionFactory.createCondition(ConditionType.INPUT, 502327, "adjustBefore");
|
|||
|
|
adjustBeforeItem.setColSpan(1);//定义一行显示条件数,默认值为2,当值为1时标识该条件单独占一行
|
|||
|
|
adjustBeforeItem.setFieldcol(12); //条件输入框所占宽度,默认值18
|
|||
|
|
adjustBeforeItem.setViewAttr(1); // 编辑权限 1:只读,2:可编辑, 3:必填 默认2
|
|||
|
|
adjustBeforeItem.setLength(10); // 设置输入长度
|
|||
|
|
adjustBeforeItem.setLabel("调整前"); //设置文本值 这个将覆盖多语言标签的值
|
|||
|
|
adjustBeforeItem.setRules("required"); //设置字段填入规则
|
|||
|
|
adjustBeforeItem.setValue(adjustBefore);
|
|||
|
|
items.add(adjustBeforeItem);
|
|||
|
|
|
|||
|
|
|
|||
|
|
SearchConditionItem taxAgentItem = conditionFactory.createCondition(ConditionType.SELECT, 502227, "taxAgentId");
|
|||
|
|
List<SearchConditionOption> taxAgentOptions = new ArrayList<>(); //设置选项值
|
|||
|
|
taxAgentList.forEach(t -> {
|
|||
|
|
if (t.getId().equals(adjustAfter)) {
|
|||
|
|
taxAgentOptions.add(new SearchConditionOption(t.getId().toString(), t.getName(), true));
|
|||
|
|
}
|
|||
|
|
taxAgentOptions.add(new SearchConditionOption(t.getId().toString(), t.getName()));
|
|||
|
|
});
|
|||
|
|
adjustReasonItem.setOptions(selectOptions);
|
|||
|
|
effectiveTimeItem.setColSpan(1);
|
|||
|
|
effectiveTimeItem.setFieldcol(12);
|
|||
|
|
effectiveTimeItem.setViewAttr(3);
|
|||
|
|
effectiveTimeItem.setLength(10);
|
|||
|
|
adjustReasonItem.setLabel("调整后");
|
|||
|
|
effectiveTimeItem.setRules("required"); //设置字段填入规则
|
|||
|
|
items.add(taxAgentItem);
|
|||
|
|
|
|||
|
|
addGroups.add(new SearchConditionGroup("表单", true, items));
|
|||
|
|
|
|||
|
|
Map<String, Object> map = new HashMap<>();
|
|||
|
|
map.put("form", addGroups);
|
|||
|
|
return map;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 通过薪资档案的个税扣缴义务人id获取个税扣缴义务人调整表单
|
|||
|
|
*
|
|||
|
|
* @param salaryArchiveTaxAgentId
|
|||
|
|
* @return
|
|||
|
|
*/
|
|||
|
|
public SalaryArchiveTaxAgentFormDTO getTaxAgentFormBySalaryArchiveTaxAgentId(Long salaryArchiveTaxAgentId) {
|
|||
|
|
if (salaryArchiveTaxAgentId == null) {
|
|||
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100489, "薪资档案的个税扣缴义务人id不能为空"));
|
|||
|
|
}
|
|||
|
|
SalaryArchiveTaxAgentPO salaryArchiveTaxAgent = salaryArchiveTaxAgentService.getById(salaryArchiveTaxAgentId);
|
|||
|
|
if (salaryArchiveTaxAgent == null) {
|
|||
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100484, "该薪资档案的个税扣缴义务人的调整记录不存在"));
|
|||
|
|
}
|
|||
|
|
// 个税扣缴义务人下拉列表
|
|||
|
|
Collection<TaxAgent> taxAgentList = taxAgentService.findAll();
|
|||
|
|
// 调整前
|
|||
|
|
String adjustBefore = "";
|
|||
|
|
SalaryArchiveTaxAgentPO adjustBeforePo = salaryArchiveTaxAgentService.getAdjustBeforeTaxAgent(salaryArchiveTaxAgent);
|
|||
|
|
|
|||
|
|
if (adjustBeforePo != null) {
|
|||
|
|
Optional<TaxAgent> optional = taxAgentList.stream().filter(f -> f.getId().equals(adjustBeforePo.getTaxAgentId())).findFirst();
|
|||
|
|
adjustBefore = optional.isPresent() ? optional.get().getName() : "";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
Date effectiveTime = salaryArchiveTaxAgent.getEffectiveTime();
|
|||
|
|
String adjustReason = salaryArchiveTaxAgent.getAdjustReason();
|
|||
|
|
Long adjustAfter = salaryArchiveTaxAgent.getTaxAgentId();
|
|||
|
|
|
|||
|
|
// 构建表单
|
|||
|
|
Map<String, Object> taxAgentForm = buildTaxAgentForm(taxAgentList, effectiveTime, adjustReason, adjustBefore, adjustAfter);
|
|||
|
|
|
|||
|
|
return SalaryArchiveTaxAgentFormDTO.builder()
|
|||
|
|
.salaryArchiveId(salaryArchiveTaxAgent.getSalaryArchiveId())
|
|||
|
|
.salaryArchiveTaxAgentForm(taxAgentForm)
|
|||
|
|
.build();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 保存个税扣缴义务人调整
|
|||
|
|
*
|
|||
|
|
* @param saveParam
|
|||
|
|
* @return
|
|||
|
|
*/
|
|||
|
|
public String saveTaxAgent(SalaryArchiveTaxAgentSaveParam saveParam) {
|
|||
|
|
return salaryArchiveTaxAgentService.saveTaxAgent(saveParam);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 删除个税扣缴义务人调整
|
|||
|
|
*
|
|||
|
|
* @param salaryArchiveTaxAgentId
|
|||
|
|
* @return
|
|||
|
|
*/
|
|||
|
|
public String deleteTaxAgent(Long salaryArchiveTaxAgentId) {
|
|||
|
|
return salaryArchiveTaxAgentService.deleteTaxAgent(salaryArchiveTaxAgentId);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 个税扣缴义务人调整记录列表
|
|||
|
|
*
|
|||
|
|
* @param queryParam
|
|||
|
|
* @return
|
|||
|
|
*/
|
|||
|
|
// public Map<String,Object> adjustRecordList(TaxAgentAdjustRecordQueryParam queryParam) {
|
|||
|
|
// Page<TaxAgentAdjustRecordListDTO> page = new Page<>(queryParam.getCurrent(), queryParam.getPageSize(), true);
|
|||
|
|
// page = salaryArchiveTaxAgentService.taxAgentAdjustRecordListPage(page, queryParam, tenantKey);
|
|||
|
|
//
|
|||
|
|
// Page<TaxAgentAdjustRecordListDTO> listPage = new Page<>(page.getCurrent(), page.getSize(), page.getTotal(), page.isSearchCount());
|
|||
|
|
// // 个税扣缴义务人
|
|||
|
|
// Collection<TaxAgentListDTO> taxAgentList = taxAgentService.findAll(tenantKey);
|
|||
|
|
// List<TaxAgentAdjustRecordListDTO> listAll = salaryArchiveTaxAgentService.taxAgentAdjustRecordList(TaxAgentAdjustRecordQueryParam.builder().build());
|
|||
|
|
// List<TaxAgentAdjustRecordListDTO> list = page.getRecords();
|
|||
|
|
// list.stream().forEach(m -> {
|
|||
|
|
// if (!org.springframework.util.CollectionUtils.isEmpty(listAll)) {
|
|||
|
|
// listAll.removeIf(a -> a.getId().equals(m.getId()));
|
|||
|
|
// }
|
|||
|
|
// Optional<TaxAgentAdjustRecordListDTO> optional = listAll.stream().filter(f -> f.getSalaryArchiveId().equals(m.getSalaryArchiveId())).findFirst();
|
|||
|
|
// m.setAdjustBefore(optional.isPresent() ? optional.get().getAdjustAfter() : "");
|
|||
|
|
// Optional<TaxAgentListDTO> optionalBefore = taxAgentList.stream().filter(t -> t.getId().toString().equals(m.getAdjustBefore())).findFirst();
|
|||
|
|
// m.setAdjustBefore(optionalBefore.isPresent() ? optionalBefore.get().getName() : "");
|
|||
|
|
// Optional<TaxAgentListDTO> optionalAfter = taxAgentList.stream().filter(t -> t.getId().toString().equals(m.getAdjustAfter())).findFirst();
|
|||
|
|
// m.setAdjustAfter(optionalAfter.isPresent() ? optionalAfter.get().getName() : "");
|
|||
|
|
//
|
|||
|
|
// m.setEmployeeStatus(SalaryUserStatusEnum.getDefaultLabelByValue(m.getEmployeeStatus()));
|
|||
|
|
//
|
|||
|
|
// m.setAdjustReason(SalaryArchiveTaxAgentAdjustReasonEnum.getDefaultLabelByValue(m.getAdjustReason()));
|
|||
|
|
// });
|
|||
|
|
// listPage.setRecords(list);
|
|||
|
|
// WeaTable<TaxAgentAdjustRecordListDTO> weaTable = FormatManager.<TaxAgentAdjustRecordListDTO>getInstance()
|
|||
|
|
// .genTable(TaxAgentAdjustRecordListDTO.class, listPage);
|
|||
|
|
// weaTable.setModule("hrmsalary");
|
|||
|
|
// return weaTable;
|
|||
|
|
// }
|
|||
|
|
//
|
|||
|
|
// /**
|
|||
|
|
// * 单个档案的个税扣缴义务人调整记录列表
|
|||
|
|
// *
|
|||
|
|
// * @param queryParam
|
|||
|
|
// * @param employeeId
|
|||
|
|
// * @param tenantKey
|
|||
|
|
// * @return
|
|||
|
|
// */
|
|||
|
|
// public WeaTable<SingleTaxAgentAdjustRecordListDTO> singleTaxAgentAdjustRecordList(SingleTaxAgentAdjustRecordQueryParam queryParam) {
|
|||
|
|
// if (queryParam.getSalaryArchiveId() == null) {
|
|||
|
|
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100425, "薪资档案id不能为空"));
|
|||
|
|
// }
|
|||
|
|
//
|
|||
|
|
// Page<TaxAgentAdjustRecordListDTO> page = new Page<>(queryParam.getCurrent(), queryParam.getPageSize(), true);
|
|||
|
|
// TaxAgentAdjustRecordQueryParam adjustRecordQueryParam = new TaxAgentAdjustRecordQueryParam();
|
|||
|
|
// BeanUtils.copyProperties(queryParam, adjustRecordQueryParam);
|
|||
|
|
// page = salaryArchiveTaxAgentService.taxAgentAdjustRecordListPage(page, adjustRecordQueryParam, tenantKey);
|
|||
|
|
//
|
|||
|
|
// Page<SingleTaxAgentAdjustRecordListDTO> listPage = new Page<>(page.getCurrent(), page.getSize(), page.getTotal(), page.isSearchCount());
|
|||
|
|
// // 个税扣缴义务人
|
|||
|
|
// Collection<TaxAgentListDTO> taxAgentList = taxAgentService.findAll(tenantKey);
|
|||
|
|
// List<TaxAgentAdjustRecordListDTO> listAll = salaryArchiveTaxAgentService.taxAgentAdjustRecordList(TaxAgentAdjustRecordQueryParam.builder().build(), tenantKey);
|
|||
|
|
// List<TaxAgentAdjustRecordListDTO> list = page.getRecords();
|
|||
|
|
// List<SingleTaxAgentAdjustRecordListDTO> resultList = Lists.newArrayList();
|
|||
|
|
// list.forEach(m -> {
|
|||
|
|
// if (!org.springframework.util.CollectionUtils.isEmpty(listAll)) {
|
|||
|
|
// listAll.removeIf(a -> a.getId().equals(m.getId()));
|
|||
|
|
// }
|
|||
|
|
// Optional<TaxAgentAdjustRecordListDTO> optional = listAll.stream().filter(f -> f.getSalaryArchiveId().equals(m.getSalaryArchiveId())).findFirst();
|
|||
|
|
// m.setAdjustBefore(optional.isPresent() ? optional.get().getAdjustAfter() : "");
|
|||
|
|
// Optional<TaxAgentListDTO> optionalBefore = taxAgentList.stream().filter(t -> t.getId().toString().equals(m.getAdjustBefore())).findFirst();
|
|||
|
|
// m.setAdjustBefore(optionalBefore.isPresent() ? optionalBefore.get().getName() : "");
|
|||
|
|
// Optional<TaxAgentListDTO> optionalAfter = taxAgentList.stream().filter(t -> t.getId().toString().equals(m.getAdjustAfter())).findFirst();
|
|||
|
|
// m.setAdjustAfter(optionalAfter.isPresent() ? optionalAfter.get().getName() : "");
|
|||
|
|
//
|
|||
|
|
// m.setAdjustReason(SalaryArchiveTaxAgentAdjustReasonEnum.getDefaultLabelByValue(m.getAdjustReason()));
|
|||
|
|
//
|
|||
|
|
//
|
|||
|
|
// SingleTaxAgentAdjustRecordListDTO singleTaxAgentAdjustRecordList = new SingleTaxAgentAdjustRecordListDTO();
|
|||
|
|
// BeanUtils.copyProperties(m, singleTaxAgentAdjustRecordList);
|
|||
|
|
// resultList.add(singleTaxAgentAdjustRecordList);
|
|||
|
|
// });
|
|||
|
|
// listPage.setRecords(resultList);
|
|||
|
|
// WeaTable<SingleTaxAgentAdjustRecordListDTO> weaTable = FormatManager.<SingleTaxAgentAdjustRecordListDTO>getInstance()
|
|||
|
|
// .genTable(SingleTaxAgentAdjustRecordListDTO.class, listPage);
|
|||
|
|
// weaTable.setModule("hrmsalary");
|
|||
|
|
// // 获取当前已生效
|
|||
|
|
// SalaryArchiveTaxAgentPO salaryArchiveTaxAgent = salaryArchiveTaxAgentService.getEffectiveTaxAgent(queryParam.getSalaryArchiveId(), tenantKey);
|
|||
|
|
// LocalDate effectiveDate = (salaryArchiveTaxAgent == null ? null : salaryArchiveTaxAgent.getEffectiveTime());
|
|||
|
|
//
|
|||
|
|
// // 行记录按钮权限控制
|
|||
|
|
// for (int i = 0; i < listPage.getRecords().size(); i++) {
|
|||
|
|
// SingleTaxAgentAdjustRecordListDTO singleTaxAgentAdjustRecord = listPage.getRecords().get(i);
|
|||
|
|
// List<Permission> permissions = weaTable.getOperatesPermission().get(i);
|
|||
|
|
// for (int j = 0; j < permissions.size(); j++) {
|
|||
|
|
// Permission permission = permissions.get(j);
|
|||
|
|
// if (effectiveDate != null && singleTaxAgentAdjustRecord.getEffectiveTime().isBefore(effectiveDate)) {
|
|||
|
|
// permission.setVisible(false);
|
|||
|
|
// permission.setDisabled(true);
|
|||
|
|
// }
|
|||
|
|
// if (j > 0 && singleTaxAgentAdjustRecord.getEffectiveTime().equals(effectiveDate)) {
|
|||
|
|
// permission.setVisible(false);
|
|||
|
|
// permission.setDisabled(false);
|
|||
|
|
// }
|
|||
|
|
// }
|
|||
|
|
// }
|
|||
|
|
// // 在外展示操作按钮
|
|||
|
|
// weaTable.getOperates().get(0).setOuter(Boolean.TRUE);
|
|||
|
|
// return weaTable;
|
|||
|
|
// }
|
|||
|
|
//
|
|||
|
|
// /**
|
|||
|
|
// * 导出个税扣缴义务人调整记录列表
|
|||
|
|
// *
|
|||
|
|
// * @param queryParam
|
|||
|
|
// * @return
|
|||
|
|
// */
|
|||
|
|
// public Map<String, Object> exportAdjustRecordList(TaxAgentAdjustRecordQueryParam queryParam) {
|
|||
|
|
// // 构建异步导出参数
|
|||
|
|
// Map<String, Object> map = salaryBatchService.buildeExportParam("exportSalaryArchiveTaxAgentAdjustRecord");
|
|||
|
|
//
|
|||
|
|
// String username = UserContext.getCurrentUser().getUsername();
|
|||
|
|
// String eteamsId = TenantRpcContext.getEteamsId();
|
|||
|
|
// salaryArchiveTaxAgentService.exportAdjustRecordList(map, username, eteamsId, queryParam);
|
|||
|
|
// return map;
|
|||
|
|
// }
|
|||
|
|
}
|