2022-03-22 21:01:38 +08:00
|
|
|
|
package com.engine.salary.wrapper;
|
|
|
|
|
|
|
|
|
|
|
|
import com.engine.common.util.ServiceUtil;
|
|
|
|
|
|
import com.engine.core.impl.Service;
|
|
|
|
|
|
import com.engine.salary.entity.salarysob.bo.SalarySobBO;
|
|
|
|
|
|
import com.engine.salary.entity.salarysob.dto.SalarySobBasicFormDTO;
|
2022-05-31 21:05:59 +08:00
|
|
|
|
import com.engine.salary.entity.salarysob.dto.SalarySobListDTO;
|
2022-03-22 21:01:38 +08:00
|
|
|
|
import com.engine.salary.entity.salarysob.param.SalarySobBasicSaveParam;
|
|
|
|
|
|
import com.engine.salary.entity.salarysob.param.SalarySobDisableParam;
|
|
|
|
|
|
import com.engine.salary.entity.salarysob.param.SalarySobDuplicateParam;
|
|
|
|
|
|
import com.engine.salary.entity.salarysob.param.SalarySobListQueryParam;
|
|
|
|
|
|
import com.engine.salary.entity.salarysob.po.SalarySobPO;
|
2022-05-31 21:05:59 +08:00
|
|
|
|
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
|
2022-03-22 21:01:38 +08:00
|
|
|
|
import com.engine.salary.enums.salarysob.IncomeCategoryEnum;
|
|
|
|
|
|
import com.engine.salary.exception.SalaryRunTimeException;
|
|
|
|
|
|
import com.engine.salary.service.SalarySobService;
|
2022-05-31 21:05:59 +08:00
|
|
|
|
import com.engine.salary.service.TaxAgentService;
|
2022-03-22 21:01:38 +08:00
|
|
|
|
import com.engine.salary.service.impl.SalarySobServiceImpl;
|
2022-06-02 17:10:54 +08:00
|
|
|
|
import com.engine.salary.service.impl.TaxAgentServiceImpl;
|
2022-05-31 21:05:59 +08:00
|
|
|
|
import com.engine.salary.util.SalaryEntityUtil;
|
2022-03-22 21:01:38 +08:00
|
|
|
|
import com.engine.salary.util.SalaryI18nUtil;
|
2022-05-31 21:05:59 +08:00
|
|
|
|
import com.engine.salary.util.page.PageInfo;
|
2022-03-22 21:01:38 +08:00
|
|
|
|
import weaver.hrm.User;
|
|
|
|
|
|
|
2022-05-31 21:05:59 +08:00
|
|
|
|
import java.util.*;
|
2022-03-22 21:01:38 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 薪资账套
|
|
|
|
|
|
* <p>Copyright: Copyright (c) 2022</p>
|
|
|
|
|
|
* <p>Company: 泛微软件</p>
|
|
|
|
|
|
*
|
|
|
|
|
|
* @author qiantao
|
|
|
|
|
|
* @version 1.0
|
|
|
|
|
|
**/
|
|
|
|
|
|
public class SalarySobWrapper extends Service {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private SalarySobService getSalarySobService(User user) {
|
2022-06-06 16:55:02 +08:00
|
|
|
|
return ServiceUtil.getService(SalarySobServiceImpl.class, user);
|
2022-03-22 21:01:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-06-02 17:10:54 +08:00
|
|
|
|
private TaxAgentService getTaxAgentService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(TaxAgentServiceImpl.class, user);
|
|
|
|
|
|
}
|
2022-03-22 21:01:38 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 薪资账套列表
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param queryParam 列表查询参数
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2022-05-31 21:05:59 +08:00
|
|
|
|
public PageInfo<SalarySobListDTO> listPage(SalarySobListQueryParam queryParam) {
|
|
|
|
|
|
|
|
|
|
|
|
// 查询薪资账套
|
|
|
|
|
|
PageInfo<SalarySobPO> page = getSalarySobService(user).listPageByParam(queryParam);
|
|
|
|
|
|
// 薪资账套po转换成薪资账套列表dto
|
2022-06-07 15:43:22 +08:00
|
|
|
|
|
|
|
|
|
|
List<TaxAgentPO> taxAgentPOS = getTaxAgentService(user).listAll();
|
|
|
|
|
|
Map<Long, String> taxAgentIdTONameMap = SalaryEntityUtil.convert2Map(taxAgentPOS, TaxAgentPO::getId, TaxAgentPO::getName);
|
|
|
|
|
|
|
|
|
|
|
|
List<SalarySobListDTO> salarySobListDTOS = SalarySobBO.convert2ListDTO(page.getList(),taxAgentIdTONameMap);
|
2022-05-31 21:05:59 +08:00
|
|
|
|
PageInfo<SalarySobListDTO> dtoPage = new PageInfo<>(salarySobListDTOS, SalarySobListDTO.class);
|
|
|
|
|
|
dtoPage.setTotal(page.getTotal());
|
|
|
|
|
|
dtoPage.setPageNum(page.getPageNum());
|
|
|
|
|
|
dtoPage.setPageSize(page.getPageSize());
|
|
|
|
|
|
// 转换成前端所需的数据格式
|
|
|
|
|
|
return dtoPage;
|
2022-03-22 21:01:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 薪资账套详情
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param id 薪资账套id
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
public Map<String, Object> getForm(Long id) {
|
2022-05-31 21:05:59 +08:00
|
|
|
|
long employeeId = user.getUID();
|
2022-03-22 21:01:38 +08:00
|
|
|
|
Map<String, Object> data = new HashMap<>(16);
|
2022-05-31 21:05:59 +08:00
|
|
|
|
|
|
|
|
|
|
// 是否可以编辑(分权后,总管理员不可以编辑管理员新建的账套)
|
|
|
|
|
|
boolean canEdit = Objects.isNull(id) || canEdit(id, employeeId);
|
|
|
|
|
|
|
2022-03-22 21:01:38 +08:00
|
|
|
|
// 薪资账套基础设置详情(目前核算人员范围的值固定为"1")
|
|
|
|
|
|
SalarySobBasicFormDTO basicForm = new SalarySobBasicFormDTO()
|
|
|
|
|
|
.setEmployeeRange("1")
|
2022-05-31 21:05:59 +08:00
|
|
|
|
.setTaxableItems(IncomeCategoryEnum.WAGES_AND_SALARIES.getValue())
|
|
|
|
|
|
.setCanEdit(canEdit);
|
2022-03-22 21:01:38 +08:00
|
|
|
|
if (!Objects.isNull(id)) {
|
|
|
|
|
|
// 查询薪资账套
|
|
|
|
|
|
SalarySobPO salarySobPO = getSalarySobService(user).getById(id);
|
|
|
|
|
|
if (Objects.isNull(salarySobPO)) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98379, "参数错误,薪资账套不存在或者已被删除"));
|
|
|
|
|
|
}
|
|
|
|
|
|
// 薪资装套po转换成薪资账套详情dto
|
2022-06-02 17:10:54 +08:00
|
|
|
|
basicForm = SalarySobBO.convert2FormDTO(basicForm,salarySobPO);
|
2022-03-22 21:01:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
// 转换成前端所需的数据格式
|
|
|
|
|
|
data.put("basicForm", basicForm);
|
|
|
|
|
|
return data;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 保存
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param saveParam 保存参数
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
public Long save(SalarySobBasicSaveParam saveParam) {
|
|
|
|
|
|
return getSalarySobService(user).save(saveParam);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 更新薪资账套的基础设置
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param saveParam 更新参数
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
public Long update(SalarySobBasicSaveParam saveParam) {
|
|
|
|
|
|
return getSalarySobService(user).update(saveParam);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 启用/禁用薪资账套
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param disableParam 更新参数
|
|
|
|
|
|
*/
|
|
|
|
|
|
public void updateDisable(SalarySobDisableParam disableParam) {
|
|
|
|
|
|
getSalarySobService(user).updateDisable(disableParam);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 删除薪资账套
|
|
|
|
|
|
*
|
2022-05-31 21:05:59 +08:00
|
|
|
|
* @param ids 薪资账套的id
|
2022-03-22 21:01:38 +08:00
|
|
|
|
*/
|
|
|
|
|
|
public void delete(Collection<Long> ids) {
|
|
|
|
|
|
getSalarySobService(user).deleteByIds(ids);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 复制
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param duplicateParam 复制参数
|
|
|
|
|
|
*/
|
|
|
|
|
|
public void duplicate(SalarySobDuplicateParam duplicateParam) {
|
|
|
|
|
|
getSalarySobService(user).duplicate(duplicateParam);
|
|
|
|
|
|
}
|
2022-05-31 21:05:59 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 判断是否可以编辑薪资账套
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param id
|
|
|
|
|
|
* @param employeeId
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
public boolean canEdit(Long id, Long employeeId) {
|
|
|
|
|
|
// 查询薪资账套
|
|
|
|
|
|
SalarySobPO salarySobPO = getSalarySobService(user).getById(id);
|
|
|
|
|
|
if (Objects.isNull(salarySobPO)) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98379, "参数错误,薪资账套不存在或者已被删除"));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 判断是否开启了分权
|
2022-06-02 17:10:54 +08:00
|
|
|
|
Boolean openDevolution = getTaxAgentService(user).isOpenDevolution();
|
2022-05-31 21:05:59 +08:00
|
|
|
|
if (!openDevolution) {
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
2022-06-02 17:10:54 +08:00
|
|
|
|
Collection<TaxAgentPO> taxAgentPOS = getTaxAgentService(user).listAllTaxAgentsAsAdmin(employeeId);
|
2022-05-31 21:05:59 +08:00
|
|
|
|
Set<Long> taxAgentIds = SalaryEntityUtil.properties(taxAgentPOS, TaxAgentPO::getId);
|
|
|
|
|
|
|
|
|
|
|
|
return taxAgentIds.contains(salarySobPO.getTaxAgentId());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-03-22 21:01:38 +08:00
|
|
|
|
}
|