2022-04-07 11:39:22 +08:00
|
|
|
package com.engine.salary.wrapper;
|
|
|
|
|
|
|
|
|
|
import com.engine.common.util.ServiceUtil;
|
|
|
|
|
import com.engine.core.impl.Service;
|
|
|
|
|
import com.engine.salary.biz.EmployBiz;
|
|
|
|
|
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
|
2022-12-02 17:35:14 +08:00
|
|
|
import com.engine.salary.entity.salaryBill.dto.SalarySendCheckDTO;
|
2022-04-07 11:39:22 +08:00
|
|
|
import com.engine.salary.entity.salaryacct.bo.SalaryAcctRecordBO;
|
|
|
|
|
import com.engine.salary.entity.salaryacct.dto.SalaryAcctEmployeeCountDTO;
|
|
|
|
|
import com.engine.salary.entity.salaryacct.dto.SalaryAcctRecordFormDTO;
|
|
|
|
|
import com.engine.salary.entity.salaryacct.dto.SalaryAcctRecordListDTO;
|
|
|
|
|
import com.engine.salary.entity.salaryacct.param.SalaryAcctRecordQueryParam;
|
|
|
|
|
import com.engine.salary.entity.salaryacct.param.SalaryAcctRecordSaveParam;
|
|
|
|
|
import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO;
|
|
|
|
|
import com.engine.salary.entity.salarysob.dto.SalarySobCycleDTO;
|
|
|
|
|
import com.engine.salary.entity.salarysob.po.SalarySobPO;
|
|
|
|
|
import com.engine.salary.exception.SalaryRunTimeException;
|
2023-04-12 15:27:35 +08:00
|
|
|
import com.engine.salary.service.*;
|
|
|
|
|
import com.engine.salary.service.impl.*;
|
2022-04-07 11:39:22 +08:00
|
|
|
import com.engine.salary.util.SalaryDateUtil;
|
|
|
|
|
import com.engine.salary.util.SalaryEntityUtil;
|
|
|
|
|
import com.engine.salary.util.SalaryI18nUtil;
|
2022-10-08 17:21:38 +08:00
|
|
|
import com.engine.salary.util.SalarySobUtil;
|
2022-04-07 11:39:22 +08:00
|
|
|
import com.engine.salary.util.page.PageInfo;
|
2022-08-01 14:15:09 +08:00
|
|
|
import com.engine.salary.wrapper.proxy.SalaryAcctRecordWrapperProxy;
|
2022-04-07 11:39:22 +08:00
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
|
|
import org.apache.commons.lang3.math.NumberUtils;
|
|
|
|
|
import weaver.hrm.User;
|
|
|
|
|
|
2022-04-18 17:28:34 +08:00
|
|
|
import java.util.*;
|
2022-04-07 11:39:22 +08:00
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 薪资核算记录
|
|
|
|
|
* <p>Copyright: Copyright (c) 2022</p>
|
|
|
|
|
* <p>Company: 泛微软件</p>
|
|
|
|
|
*
|
|
|
|
|
* @author qiantao
|
|
|
|
|
* @version 1.0
|
|
|
|
|
**/
|
2022-08-01 14:15:09 +08:00
|
|
|
public class SalaryAcctRecordWrapper extends Service implements SalaryAcctRecordWrapperProxy {
|
2022-04-07 11:39:22 +08:00
|
|
|
|
|
|
|
|
private SalaryAcctRecordService getSalaryAcctRecordService(User user) {
|
2022-08-01 14:15:09 +08:00
|
|
|
return ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user);
|
2022-04-07 11:39:22 +08:00
|
|
|
}
|
2022-04-18 17:28:34 +08:00
|
|
|
|
2022-04-07 11:39:22 +08:00
|
|
|
private SalarySobService getSalarySobService(User user) {
|
2022-08-01 14:15:09 +08:00
|
|
|
return ServiceUtil.getService(SalarySobServiceImpl.class, user);
|
2022-04-07 11:39:22 +08:00
|
|
|
}
|
2022-04-18 17:28:34 +08:00
|
|
|
|
2022-04-08 16:30:10 +08:00
|
|
|
private SalaryAcctEmployeeService getSalaryAcctEmployeeService(User user) {
|
2022-08-01 14:15:09 +08:00
|
|
|
return ServiceUtil.getService(SalaryAcctEmployeeServiceImpl.class, user);
|
2022-04-08 16:30:10 +08:00
|
|
|
}
|
2022-12-02 17:35:14 +08:00
|
|
|
|
|
|
|
|
private SalarySendService getSalarySendService(User user) {
|
|
|
|
|
return ServiceUtil.getService(SalarySendServiceImpl.class, user);
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-12 15:27:35 +08:00
|
|
|
private SalaryEmployeeService getSalaryEmployeeService(User user) {
|
|
|
|
|
return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user);
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-07 11:39:22 +08:00
|
|
|
// private ComInfoCache comInfoCache;
|
|
|
|
|
|
2022-08-01 14:15:09 +08:00
|
|
|
public PageInfo<SalaryAcctRecordListDTO> listPage(SalaryAcctRecordQueryParam queryParam) {
|
2022-10-08 17:21:38 +08:00
|
|
|
|
|
|
|
|
// 处理历史数据将薪资账套中将关联人员状态转换为List
|
|
|
|
|
SalarySobUtil.handleEmployeeStatusHistory();
|
2023-02-09 19:43:43 +08:00
|
|
|
// 处理工资单发放历史数据
|
|
|
|
|
getSalarySendService(user).handleHistory();
|
2022-04-07 11:39:22 +08:00
|
|
|
// 查询薪资核算记录(分页)
|
|
|
|
|
PageInfo<SalaryAcctRecordPO> page = getSalaryAcctRecordService(user).listPageByParam(queryParam);
|
2022-04-08 16:30:10 +08:00
|
|
|
PageInfo<SalaryAcctRecordListDTO> dtoPage = new PageInfo<SalaryAcctRecordListDTO>(SalaryAcctRecordListDTO.class);
|
2022-04-07 11:39:22 +08:00
|
|
|
dtoPage.setPageNum(queryParam.getCurrent());
|
|
|
|
|
dtoPage.setPageSize(queryParam.getPageSize());
|
2022-09-13 16:03:55 +08:00
|
|
|
dtoPage.setTotal(page.getTotal());
|
2022-04-07 11:39:22 +08:00
|
|
|
List<SalaryAcctRecordPO> list = page.getList();
|
|
|
|
|
if (CollectionUtils.isNotEmpty(list)) {
|
|
|
|
|
// 查询薪资账套
|
|
|
|
|
Set<Long> salarySobIds = SalaryEntityUtil.properties(list, SalaryAcctRecordPO::getSalarySobId);
|
|
|
|
|
List<SalarySobPO> salarySobPOS = getSalarySobService(user).listByIds(salarySobIds);
|
|
|
|
|
// 查询薪资核算记录的创建人员的人员信息
|
|
|
|
|
List<Long> employeeIds = SalaryEntityUtil.properties(list, SalaryAcctRecordPO::getCreator, Collectors.toList());
|
2023-04-12 15:27:35 +08:00
|
|
|
List<DataCollectionEmployee> employeeComInfos = getSalaryEmployeeService(user).getEmployeeByIdsAll(employeeIds);
|
2022-04-07 11:39:22 +08:00
|
|
|
// 查询薪资核算人数的数量
|
|
|
|
|
Set<Long> salaryAcctRecordIds = SalaryEntityUtil.properties(list, SalaryAcctRecordPO::getId);
|
2022-04-08 16:30:10 +08:00
|
|
|
List<SalaryAcctEmployeeCountDTO> salaryAcctEmployeeCountDTOS = getSalaryAcctEmployeeService(user).countBySalaryAcctRecordId(salaryAcctRecordIds);
|
2022-12-02 17:35:14 +08:00
|
|
|
// 查询工资单的查询情况
|
|
|
|
|
List<SalarySendCheckDTO> salarySendCheckResult = getSalarySendService(user).getSalarySendCheckResult(salaryAcctRecordIds);
|
|
|
|
|
|
2022-04-07 11:39:22 +08:00
|
|
|
// 转换成列表dto
|
2022-12-02 17:35:14 +08:00
|
|
|
List<SalaryAcctRecordListDTO> salaryAcctRecordListDTOS = SalaryAcctRecordBO.convert2ListDTO(list, salarySobPOS, employeeComInfos, salaryAcctEmployeeCountDTOS, salarySendCheckResult);
|
2022-04-07 11:39:22 +08:00
|
|
|
dtoPage.setList(salaryAcctRecordListDTOS);
|
|
|
|
|
}
|
2022-04-06 20:01:00 +08:00
|
|
|
// WeaTable<SalaryAcctRecordListDTO> weaTable = SalaryFormatUtil.<SalaryAcctRecordListDTO>getInstance().buildTable(SalaryAcctRecordListDTO.class, dtoPage);
|
2022-04-07 11:39:22 +08:00
|
|
|
// 只有未归档时可以"核算"、"删除"、"归档"
|
|
|
|
|
// 归档后、申报后可以"查看"、"重新核算"
|
2022-04-06 20:01:00 +08:00
|
|
|
// for (int i = 0; i < page.getRecords().size(); i++) {
|
|
|
|
|
// SalaryAcctRecordPO salaryAcctRecord = page.getRecords().get(i);
|
|
|
|
|
// List<Permission> permissions = weaTable.getOperatesPermission().get(i);
|
|
|
|
|
// for (int j = 0; j < permissions.size(); j++) {
|
|
|
|
|
// Permission permission = permissions.get(j);
|
|
|
|
|
// if ((j == 0 || j == 1 || j == 3) && !Objects.equals(salaryAcctRecord.getStatus(), SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue())) {
|
|
|
|
|
// permission.setVisible(false);
|
|
|
|
|
// permission.setDisabled(false);
|
|
|
|
|
// }
|
|
|
|
|
// if ((j == 2 || j == 5) && Objects.equals(salaryAcctRecord.getStatus(), SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue())) {
|
|
|
|
|
// permission.setVisible(false);
|
|
|
|
|
// permission.setDisabled(false);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
2022-04-07 11:39:22 +08:00
|
|
|
return dtoPage;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 薪资核算记录详情
|
|
|
|
|
*
|
2022-04-18 17:28:34 +08:00
|
|
|
* @param id 薪资核算记录id
|
2022-04-07 11:39:22 +08:00
|
|
|
* @return
|
|
|
|
|
*/
|
2022-08-01 14:15:09 +08:00
|
|
|
public Map<String, Object> getForm(Long id) {
|
2022-04-07 11:39:22 +08:00
|
|
|
SalaryAcctRecordFormDTO formDTO = new SalaryAcctRecordFormDTO();
|
|
|
|
|
// 查询所有启用的薪资账套
|
|
|
|
|
List<SalarySobPO> salarySobPOS = getSalarySobService(user).listByDisable(NumberUtils.INTEGER_ZERO);
|
|
|
|
|
// 薪资核算详情表单中"薪资账套"的下拉选择项
|
2022-04-18 17:28:34 +08:00
|
|
|
List<Map<String, Object>> salarySobs = salarySobPOS.stream()
|
|
|
|
|
.map(salarySobPO -> {
|
2022-08-01 14:15:09 +08:00
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
|
|
map.put("id", salarySobPO.getId());
|
|
|
|
|
map.put("name", salarySobPO.getName());
|
2022-04-18 17:28:34 +08:00
|
|
|
return map;
|
|
|
|
|
})
|
|
|
|
|
.collect(Collectors.toList());
|
2022-04-07 11:39:22 +08:00
|
|
|
|
|
|
|
|
if (Objects.nonNull(id)) {
|
|
|
|
|
// 查询薪资核算
|
|
|
|
|
SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(id);
|
|
|
|
|
if (Objects.isNull(salaryAcctRecordPO)) {
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除"));
|
|
|
|
|
}
|
|
|
|
|
// 查询薪资账套
|
|
|
|
|
SalarySobPO salarySobPO = getSalarySobService(user).getById(salaryAcctRecordPO.getSalarySobId());
|
|
|
|
|
if (Objects.isNull(salarySobPO)) {
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98769, "薪资账套不存在或已被删除"));
|
|
|
|
|
}
|
|
|
|
|
// 转换成薪资核算记录详情dto
|
|
|
|
|
formDTO.setId(salaryAcctRecordPO.getId())
|
|
|
|
|
.setSalarySobId(salarySobPO.getId())
|
|
|
|
|
.setSalarySobName(salarySobPO.getName())
|
|
|
|
|
.setSalaryMonth(SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getSalaryMonth()).toString())
|
|
|
|
|
.setDescription(salaryAcctRecordPO.getDescription());
|
|
|
|
|
}
|
|
|
|
|
// 转换成前端所需的数据格式
|
2022-08-01 14:15:09 +08:00
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
|
|
result.put("formDTO", formDTO);
|
|
|
|
|
result.put("salarySobs", salarySobs);
|
2022-04-18 17:28:34 +08:00
|
|
|
return result;
|
2022-04-07 11:39:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 薪资核算记录所用的薪资账套薪资周期、考勤周期……
|
|
|
|
|
*
|
2022-04-18 17:28:34 +08:00
|
|
|
* @param id 薪资核算记录的id
|
2022-04-07 11:39:22 +08:00
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public SalarySobCycleDTO getSalarySobCycleById(Long id) {
|
|
|
|
|
return getSalaryAcctRecordService(user).getSalarySobCycleById(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 保存
|
|
|
|
|
*
|
2022-04-18 17:28:34 +08:00
|
|
|
* @param saveParam 保存参数
|
2022-04-07 11:39:22 +08:00
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public Long save(SalaryAcctRecordSaveParam saveParam) {
|
|
|
|
|
return getSalaryAcctRecordService(user).save(saveParam);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 删除
|
|
|
|
|
*
|
2022-04-18 17:28:34 +08:00
|
|
|
* @param ids 薪资核算记录的id
|
2022-04-07 11:39:22 +08:00
|
|
|
*/
|
|
|
|
|
public void delete(Collection<Long> ids) {
|
|
|
|
|
getSalaryAcctRecordService(user).deleteByIds(ids);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 归档
|
|
|
|
|
*
|
2022-04-18 17:28:34 +08:00
|
|
|
* @param id 薪资核算记录的id
|
2022-04-07 11:39:22 +08:00
|
|
|
*/
|
2022-04-07 16:54:10 +08:00
|
|
|
public void file(Long id) {
|
2022-04-07 11:39:22 +08:00
|
|
|
getSalaryAcctRecordService(user).file(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2022-06-07 19:10:40 +08:00
|
|
|
* 重新核算
|
2022-04-07 11:39:22 +08:00
|
|
|
*
|
2022-04-18 17:28:34 +08:00
|
|
|
* @param id 薪资核算记录的id
|
2022-04-07 11:39:22 +08:00
|
|
|
*/
|
|
|
|
|
public void reCalculate(Long id) {
|
|
|
|
|
getSalaryAcctRecordService(user).reCalculate(id);
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-02 17:35:14 +08:00
|
|
|
|
|
|
|
|
|
2022-04-07 11:39:22 +08:00
|
|
|
/**
|
|
|
|
|
* 判断是否存在合并计税
|
|
|
|
|
*
|
2022-04-18 17:28:34 +08:00
|
|
|
* @param id 主键id
|
2022-04-07 11:39:22 +08:00
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public Integer hasConsolidatedTax(Long id) {
|
|
|
|
|
return getSalaryAcctRecordService(user).hasConsolidatedTax(id);
|
|
|
|
|
}
|
2022-12-02 17:35:14 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @description 回算
|
|
|
|
|
* @return void
|
|
|
|
|
* @author Harryxzy
|
|
|
|
|
* @date 2022/11/24 15:52
|
|
|
|
|
*/
|
|
|
|
|
public void backCalculate(Long salaryAcctRecordId){
|
|
|
|
|
getSalaryAcctRecordService(user).backCalculate(salaryAcctRecordId);
|
|
|
|
|
}
|
2022-04-07 11:39:22 +08:00
|
|
|
}
|