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

172 lines
6.1 KiB
Java
Raw Normal View History

2022-05-24 09:14:26 +08:00
package com.engine.salary.wrapper;
import com.engine.core.impl.Service;
import com.engine.salary.biz.EmployBiz;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.taxagent.bo.TaxAgentBO;
import com.engine.salary.entity.taxagent.dto.*;
import com.engine.salary.entity.taxagent.param.*;
import com.engine.salary.entity.taxagent.po.TaxAgentSubAdminPO;
import com.engine.salary.enums.UserStatusEnum;
import com.engine.salary.exception.SalaryRunTimeException;
import com.engine.salary.service.TaxAgentManageRangeService;
import com.engine.salary.service.TaxAgentSubAdminService;
import com.engine.salary.util.SalaryI18nUtil;
import com.engine.salary.util.page.PageInfo;
2022-05-25 13:10:03 +08:00
import com.engine.salary.util.page.SalaryPageUtil;
2022-05-24 09:14:26 +08:00
import com.engine.salary.util.valid.ValidUtil;
import com.google.common.collect.Lists;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
/**
* 个税义务人分管理员
* <p>Copyright: Copyright (c) 2022</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
public class TaxAgentSubAdminWrapper extends Service {
private TaxAgentSubAdminService taxAgentSubAdminService;
private TaxAgentManageRangeService taxAgentManageRangeService;
// private HrmCommonEmployeeService hrmCommonEmployeeService;
private EmployBiz employBiz = new EmployBiz();
/**
* 获取分管理员列表
*
* @param queryParam
* @return
*/
public PageInfo<TaxAgentSubAdminListDTO> list(TaxAgentSubAdminQueryParam queryParam) {
ValidUtil.doValidator(queryParam);
List<TaxAgentSubAdminPO> list = taxAgentSubAdminService.listByTaxAgentIds(Collections.singletonList(queryParam.getTaxAgentId()));
String range = SalaryI18nUtil.getI18nLabel(106290, "详情");
List<DataCollectionEmployee> subAdminList = employBiz.getEmployeeByIds(list.stream().map(TaxAgentSubAdminPO::getEmployeeId).distinct().collect(Collectors.toList()));
List<TaxAgentSubAdminListDTO> records = TaxAgentBO.convertToSubAdminListDTO(list, range, subAdminList);
2022-05-25 13:10:03 +08:00
PageInfo<TaxAgentSubAdminListDTO> listPage = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), TaxAgentSubAdminListDTO.class);
2022-05-24 09:14:26 +08:00
// 填充总数和当页数据
listPage.setTotal(records.size());
2022-06-02 17:10:54 +08:00
listPage.setList(SalaryPageUtil.subList(listPage.getPageNum(), listPage.getPageSize(), records));
2022-05-24 09:14:26 +08:00
return listPage;
}
/**
* 删除分管理员
*
* @param ids
* @return
*/
public String delete(Collection<Long> ids) {
return taxAgentSubAdminService.deleteByIds(ids);
}
/**
* 获取基础设置表单
*
* @param baseFormParam
* @return
*/
public TaxAgentSubAdminBaseFormDTO getBaseFrom(TaxAgentSubAdminBaseFormParam baseFormParam) {
ValidUtil.doValidator(baseFormParam);
TaxAgentSubAdminBaseFormDTO taxAgentSubAdminBaseFormDTO = new TaxAgentSubAdminBaseFormDTO();
Long id = baseFormParam.getId();
if (id != null) {
TaxAgentSubAdminPO taxAgentSubAdmin = taxAgentSubAdminService.getById(id);
if (taxAgentSubAdmin == null) {
throw new SalaryRunTimeException(String.format(SalaryI18nUtil.getI18nLabel(106466, "分管理员不存在") + "[id:%s]", id));
}
if (!baseFormParam.getTaxAgentId().equals(taxAgentSubAdmin.getTaxAgentId())) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(106685, "分管理员与所属个税扣缴义务人不匹配"));
}
taxAgentSubAdminBaseFormDTO.setId(taxAgentSubAdmin.getId());
taxAgentSubAdminBaseFormDTO.setDescription(taxAgentSubAdmin.getRemark());
TaxAgentEmployeeOptionDTO taxAgentEmployee = new TaxAgentEmployeeOptionDTO();
taxAgentEmployee.setId(taxAgentSubAdmin.getEmployeeId());
DataCollectionEmployee employee = employBiz.getEmployeeById(taxAgentEmployee.getId());
taxAgentEmployee.setContent(employee == null ? "" : employee.getUsername());
taxAgentSubAdminBaseFormDTO.setSubAdminUser(Collections.singletonList(taxAgentEmployee));
} else {
taxAgentSubAdminBaseFormDTO.setSubAdminUser(Lists.newArrayList());
}
return taxAgentSubAdminBaseFormDTO;
}
/**
* 保存分管理员基础设置
*
* @param saveParam
* @return
*/
public String saveBase(TaxAgentSubAdminBaseSaveParam saveParam) {
return taxAgentSubAdminService.saveBase(saveParam);
}
/**
* 范围列表
*
* @param queryParam
* @return
*/
public PageInfo<TaxAgentManageRangeListDTO> listRangeInclude(TaxAgentSubAdminRangeQueryParam queryParam) {
PageInfo<TaxAgentManageRangeListDTO> listPage = taxAgentManageRangeService.listPageByParamAndIncludeType(queryParam, NumberUtils.INTEGER_ONE);
return listPage;
}
/**
* 范围排除列表
*
* @param queryParam
* @return
*/
public PageInfo<TaxAgentManageRangeListDTO> listRangeExclude(TaxAgentSubAdminRangeQueryParam queryParam) {
PageInfo<TaxAgentManageRangeListDTO> listPage = taxAgentManageRangeService.listPageByParamAndIncludeType(queryParam, NumberUtils.INTEGER_ZERO);
return listPage;
}
/**
* 获取管理范围表单
*
* @return
*/
public TaxAgentManageRangeFormDTO getRangeFrom() {
return TaxAgentManageRangeFormDTO.builder().employeeStatus(UserStatusEnum.getHrmStatusList()).build();
}
/**
* 保存管理范围
*
* @param saveParam
* @return
*/
public String saveRange(TaxAgentSubAdminRangeSaveParam saveParam) {
taxAgentManageRangeService.save4SubAdmin(saveParam);
return StringUtils.EMPTY;
}
/**
* 删除管理范围
*
* @param ids
* @return
*/
public String deleteRange(Collection<Long> ids) {
taxAgentManageRangeService.deleteByIds(ids);
return StringUtils.EMPTY;
}
}