This commit is contained in:
钱涛 2022-04-07 16:54:10 +08:00
parent caf83c6386
commit 0dedda4dbd
22 changed files with 2938 additions and 305 deletions

View File

@ -2,6 +2,7 @@ package com.engine.salary.biz;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.hrm.PositionInfo;
import com.engine.salary.entity.salarysob.param.SalarySobRangeEmpQueryParam;
import com.engine.salary.mapper.datacollection.EmployMapper;
import org.apache.ibatis.session.SqlSession;
import weaver.conn.mybatis.MyBatisFactory;
@ -72,4 +73,14 @@ public class EmployBiz extends BaseBean {
sqlSession.close();
}
}
public List<DataCollectionEmployee> listByParams(List<SalarySobRangeEmpQueryParam> includeQueryParams) {
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
EmployMapper mapper = sqlSession.getMapper(EmployMapper.class);
return mapper.listByParams(includeQueryParams);
} finally {
sqlSession.close();
}
}
}

View File

@ -1,6 +1,7 @@
package com.engine.salary.biz;
import com.engine.salary.entity.taxrate.TaxAgent;
import com.engine.salary.entity.taxrate.param.TaxAgentQueryParam;
import com.engine.salary.mapper.TaxAgentMapper;
import org.apache.ibatis.session.SqlSession;
import weaver.conn.mybatis.MyBatisFactory;
@ -18,4 +19,14 @@ public class TaxAgentBiz {
sqlSession.close();
}
}
public List<TaxAgent> listByIds(List<Long> taxAgentIds) {
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
TaxAgentMapper taxAgentMapper = sqlSession.getMapper(TaxAgentMapper.class);
return taxAgentMapper.listBySome(TaxAgentQueryParam.builder().ids(taxAgentIds).build());
} finally {
sqlSession.close();
}
}
}

View File

@ -44,10 +44,11 @@ public class TaxRateBiz extends BaseBean {
// 如果自定义税率表中没有再查询系统默认的税率表
if (Objects.isNull(taxRateBase)) {
SysTaxRateBase sysTaxRateBase = sysTaxRateBaseMapper.getById(id);
taxRateBase = new TaxRateBase();
if (sysTaxRateBase != null) {
BeanUtils.copyProperties(sysTaxRateBase, taxRateBase);
if (sysTaxRateBase == null) {
return null;
}
taxRateBase = new TaxRateBase();
BeanUtils.copyProperties(sysTaxRateBase, taxRateBase);
}
return taxRateBase;
} finally {
@ -162,7 +163,7 @@ public class TaxRateBiz extends BaseBean {
throw new SalaryRunTimeException("系统默认的税率表不允许删除");
}
ids = SalaryEntityUtil.properties(TaxRateBaseS, TaxRateBase::getId);
// todo 记录日志
// todo 记录日志
// TaxRateBaseS.forEach(taxRateBatchPO -> {
// LoggerContext<TaxRateBase> loggerContext = new LoggerContext<>();
// loggerContext.setTargetId(String.valueOf(taxRateBatchPO.getId()));
@ -205,7 +206,7 @@ public class TaxRateBiz extends BaseBean {
// 保存个税税率表主表
TaxRateBase TaxRateBase = TaxRateBO.convert2BatchPO(saveParam.getTaxRateBatch(), employeeId);
taxRateBaseMapper.insertIgnoreNull(TaxRateBase);
// todo 记录日志
// todo 记录日志
// LoggerContext loggerContext = new LoggerContext<>();
// loggerContext.setTargetId(String.valueOf(TaxRateBase.getId()));
// loggerContext.setTargetName(TaxRateBase.getName());
@ -217,7 +218,7 @@ public class TaxRateBiz extends BaseBean {
// 保存个税税率表明细表
List<TaxRateDetail> taxRateDetailPOS = TaxRateBO.convert2RecordPO(TaxRateBase.getId(), saveParam.getTaxRateRecords(), employeeId);
new TaxRateDetailBiz().saveBatch(taxRateDetailPOS);
// todo 记录日志
// todo 记录日志
// LoggerContext detailLoggerContext = new LoggerContext<>();
// detailLoggerContext.setTargetId(String.valueOf(TaxRateBase.getId()));
// detailLoggerContext.setTargetName(TaxRateBase.getName());
@ -267,7 +268,7 @@ public class TaxRateBiz extends BaseBean {
newTaxRateBase.setName(updateParam.getTaxRateBatch().getName());
newTaxRateBase.setDescription(updateParam.getTaxRateBatch().getDescription());
taxRateBaseMapper.updateIgnoreNull(newTaxRateBase);
// todo 记录日志
// todo 记录日志
// LoggerContext loggerContext = new LoggerContext<>();
// loggerContext.setTargetId(String.valueOf(taxRateBase.getId()));
// loggerContext.setTargetName(taxRateBase.getName());
@ -282,7 +283,7 @@ public class TaxRateBiz extends BaseBean {
taxRateDetailMapper.deleteByBatchIds(Collections.singleton(taxRateBase.getId()));
List<TaxRateDetail> newTaxRateDetailPOS = TaxRateBO.convert2RecordPO(taxRateBase.getId(), updateParam.getTaxRateRecords(), employeeId);
new TaxRateDetailBiz().saveBatch(newTaxRateDetailPOS);
// todo 记录日志
// todo 记录日志
// LoggerContext detailLoggerContext = new LoggerContext<>();
// detailLoggerContext.setTargetId(String.valueOf(taxRateBase.getId()));
// detailLoggerContext.setTargetName(taxRateBase.getName());

View File

@ -6,6 +6,7 @@ import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
/**
* 员工基本信息
* <p>Copyright: Copyright (c) 2022</p>
@ -28,6 +29,7 @@ public class DataCollectionEmployee {
//部门
private String departmentName;
private Long departmentId;
//岗位
private String jobtitleName;
@ -41,4 +43,10 @@ public class DataCollectionEmployee {
//离职日期
private Date dissmissdate;
//状态
private String status;
//工号
private String workcode;
}

View File

@ -1,123 +1,122 @@
//package com.engine.salary.entity.salaryacct.bo;
//
//import com.google.common.collect.Lists;
//import com.google.common.collect.Sets;
//import com.weaver.common.distribution.genid.IdGenerator;
//import com.weaver.hrm.salary.entity.salaryacct.dto.SalaryAccEmployeeListDTO;
//import com.weaver.hrm.salary.entity.salaryacct.po.SalaryAcctEmployeePO;
//import com.weaver.hrm.salary.entity.salaryacct.po.SalaryAcctRecordPO;
//import com.weaver.hrm.salary.entity.salaryarchive.dto.SalaryArchiveDataDTO;
//import com.weaver.hrm.salary.entity.salaryarchive.dto.SalaryArchiveTaxAgentDataDTO;
//import com.weaver.hrm.salary.entity.salaryarchive.po.TaxAgentPO;
//import com.weaver.hrm.salary.util.SalaryDateUtil;
//import com.weaver.hrm.salary.util.SalaryEntityUtil;
//import com.weaver.teams.domain.user.SimpleEmployee;
//import org.apache.commons.collections4.CollectionUtils;
//import org.apache.commons.lang3.StringUtils;
//
//import java.time.LocalDateTime;
//import java.util.*;
//import java.util.stream.Collectors;
//
///**
// * @description: 薪资核算人员
// * @author: xiajun
// * @modified By: xiajun
// * @date: Created in 1/21/22 4:20 PM
// * @version:v1.0
// */
//public class SalaryAcctEmployeeBO {
//
// /**
// * 将薪资核算人员po转换成薪资核算人员列表dto
// *
// * @param salaryAccountingEmployees
// * @param taxAgents
// * @param simpleEmployees
// * @return
// */
// public static List<SalaryAccEmployeeListDTO> convert2EmployeeListDTO(List<SalaryAcctEmployeePO> salaryAccountingEmployees,
// List<TaxAgentPO> taxAgents,
// List<SimpleEmployee> simpleEmployees) {
// if (CollectionUtils.isEmpty(salaryAccountingEmployees)) {
// return Collections.emptyList();
// }
// Map<Long, String> taxAgentNameMap = SalaryEntityUtil.convert2Map(taxAgents, TaxAgentPO::getId, TaxAgentPO::getName);
// Map<Long, SimpleEmployee> simpleEmployeeMap = SalaryEntityUtil.convert2Map(simpleEmployees, SimpleEmployee::getId);
// return salaryAccountingEmployees.stream()
// .map(e -> {
// SimpleEmployee simpleEmployee = simpleEmployeeMap.get(e.getEmployeeId());
// if (simpleEmployee == null) {
// return SalaryAccEmployeeListDTO.builder()
// .id(e.getId())
// .employeeId(e.getId())
// .taxAgentId(e.getTaxAgentId())
// .taxAgentName(taxAgentNameMap.getOrDefault(e.getTaxAgentId(), StringUtils.EMPTY))
// .build();
// }
// return SalaryAccEmployeeListDTO.builder()
// .id(e.getId())
// .employeeId(simpleEmployee.getEmployeeId())
// .employeeName(simpleEmployee.getUsername())
// .taxAgentId(e.getTaxAgentId())
// .taxAgentName(taxAgentNameMap.getOrDefault(e.getTaxAgentId(), StringUtils.EMPTY))
// .departmentId(simpleEmployee.getDepartment().getId())
// .departmentName(simpleEmployee.getDepartment().getName())
// .status(simpleEmployee.getStatus().getDescription())
// .mobile(simpleEmployee.getMobile())
// .jobNum(simpleEmployee.getJobNum())
// .hireDate(SalaryDateUtil.getFormatLocalDate(simpleEmployee.getHiredate()))
// .dismissDate("")
// .build();
// }).collect(Collectors.toList());
// }
//
// /**
// * 转换成薪资核算人员的po
// *
// * @param employeeIds
// * @param salaryAcctRecord
// * @param salaryArchiveTaxAgentData
// * @param employeeId
// * @param tenantKey
// * @return
// */
// public static List<SalaryAcctEmployeePO> convert2EmployeePO(Collection<Long> employeeIds,
// SalaryAcctRecordPO salaryAcctRecord,
// List<SalaryArchiveDataDTO> salaryArchiveTaxAgentData,
// Long employeeId, String tenantKey) {
// if (CollectionUtils.isEmpty(employeeIds)) {
// return Collections.emptyList();
// }
// List<SalaryAcctEmployeePO> resultList = Lists.newArrayList();
// Map<Long, Set<List<SalaryArchiveTaxAgentDataDTO>>> empIdKeyTaxAgentMap = SalaryEntityUtil.group2Map(salaryArchiveTaxAgentData, SalaryArchiveDataDTO::getEmployeeId, SalaryArchiveDataDTO::getTaxAgents);
// LocalDateTime now = LocalDateTime.now();
// for (Long id : employeeIds) {
// Set<Long> taxAgentIds = Sets.newHashSet();
// Set<List<SalaryArchiveTaxAgentDataDTO>> taxAgentSet = empIdKeyTaxAgentMap.getOrDefault(id, Collections.emptySet());
// for (List<SalaryArchiveTaxAgentDataDTO> taxAgents : taxAgentSet) {
// taxAgentIds.addAll(SalaryEntityUtil.properties(taxAgents, SalaryArchiveTaxAgentDataDTO::getTaxAgentId));
// }
// if (CollectionUtils.isEmpty(taxAgentIds)) {
// taxAgentIds.add(0L);
// }
// for (Long taxAgentId : taxAgentIds) {
// SalaryAcctEmployeePO salaryAcctEmployee = SalaryAcctEmployeePO.builder()
package com.engine.salary.entity.salaryacct.bo;
import com.engine.salary.constant.SalaryDefaultTenantConstant;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.salaryacct.dto.SalaryAccEmployeeListDTO;
import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO;
import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO;
import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveDataDTO;
import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveTaxAgentDataDTO;
import com.engine.salary.entity.taxrate.TaxAgent;
import com.engine.salary.util.SalaryDateUtil;
import com.engine.salary.util.SalaryEntityUtil;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import java.util.*;
import java.util.stream.Collectors;
/**
* 薪资核算人员
* <p>Copyright: Copyright (c) 2022</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
public class SalaryAcctEmployeeBO {
/**
* 将薪资核算人员po转换成薪资核算人员列表dto
*
* @param salaryAccountingEmployees
* @param taxAgents
* @param simpleEmployees
* @return
*/
public static List<SalaryAccEmployeeListDTO> convert2EmployeeListDTO(List<SalaryAcctEmployeePO> salaryAccountingEmployees,
List<TaxAgent> taxAgents,
List<DataCollectionEmployee> simpleEmployees) {
if (CollectionUtils.isEmpty(salaryAccountingEmployees)) {
return Collections.emptyList();
}
Map<Long, String> taxAgentNameMap = SalaryEntityUtil.convert2Map(taxAgents, TaxAgent::getId, TaxAgent::getName);
Map<Long, DataCollectionEmployee> simpleEmployeeMap = SalaryEntityUtil.convert2Map(simpleEmployees, DataCollectionEmployee::getEmployeeId);
return salaryAccountingEmployees.stream()
.map(e -> {
DataCollectionEmployee simpleEmployee = simpleEmployeeMap.get(e.getEmployeeId());
if (simpleEmployee == null) {
return SalaryAccEmployeeListDTO.builder()
.id(e.getId())
.employeeId(e.getId())
.taxAgentId(e.getTaxAgentId())
.taxAgentName(taxAgentNameMap.getOrDefault(e.getTaxAgentId(), StringUtils.EMPTY))
.build();
}
return SalaryAccEmployeeListDTO.builder()
.id(e.getId())
.employeeId(simpleEmployee.getEmployeeId())
.employeeName(simpleEmployee.getUsername())
.taxAgentId(e.getTaxAgentId())
.taxAgentName(taxAgentNameMap.getOrDefault(e.getTaxAgentId(), StringUtils.EMPTY))
.departmentId(simpleEmployee.getDepartmentId())
.departmentName(simpleEmployee.getDepartmentName())
.status(simpleEmployee.getStatus())
.mobile(simpleEmployee.getMobile())
.jobNum(simpleEmployee.getWorkcode())
.hireDate(SalaryDateUtil.getFormatLocalDate(simpleEmployee.getCompanystartdate()))
.dismissDate("")
.build();
}).collect(Collectors.toList());
}
/**
* 转换成薪资核算人员的po
*
* @param employeeIds
* @param salaryAcctRecord
* @param salaryArchiveTaxAgentData
* @param employeeId
* @return
*/
public static List<SalaryAcctEmployeePO> convert2EmployeePO(Collection<Long> employeeIds,
SalaryAcctRecordPO salaryAcctRecord,
List<SalaryArchiveDataDTO> salaryArchiveTaxAgentData,
Long employeeId) {
if (CollectionUtils.isEmpty(employeeIds)) {
return Collections.emptyList();
}
List<SalaryAcctEmployeePO> resultList = Lists.newArrayList();
Map<Long, Set<List<SalaryArchiveTaxAgentDataDTO>>> empIdKeyTaxAgentMap = SalaryEntityUtil.group2Map(salaryArchiveTaxAgentData, SalaryArchiveDataDTO::getEmployeeId, SalaryArchiveDataDTO::getTaxAgents);
Date now = new Date();
for (Long id : employeeIds) {
Set<Long> taxAgentIds = Sets.newHashSet();
Set<List<SalaryArchiveTaxAgentDataDTO>> taxAgentSet = empIdKeyTaxAgentMap.getOrDefault(id, Collections.emptySet());
for (List<SalaryArchiveTaxAgentDataDTO> taxAgents : taxAgentSet) {
taxAgentIds.addAll(SalaryEntityUtil.properties(taxAgents, SalaryArchiveTaxAgentDataDTO::getTaxAgentId));
}
if (CollectionUtils.isEmpty(taxAgentIds)) {
taxAgentIds.add(0L);
}
for (Long taxAgentId : taxAgentIds) {
SalaryAcctEmployeePO salaryAcctEmployee = SalaryAcctEmployeePO.builder()
// .id(IdGenerator.generate())
// .salaryAcctRecordId(salaryAcctRecord.getId())
// .salarySobId(salaryAcctRecord.getSalarySobId())
// .salaryMonth(salaryAcctRecord.getSalaryMonth())
// .employeeId(id)
// .taxAgentId(taxAgentId)
// .creator(employeeId)
// .createTime(now)
// .updateTime(now)
// .deleteType(0)
// .tenantKey(tenantKey)
// .build();
// resultList.add(salaryAcctEmployee);
// }
// }
// return resultList;
// }
//}
.salaryAcctRecordId(salaryAcctRecord.getId())
.salarySobId(salaryAcctRecord.getSalarySobId())
.salaryMonth(salaryAcctRecord.getSalaryMonth())
.employeeId(id)
.taxAgentId(taxAgentId)
.creator(employeeId)
.createTime(now)
.updateTime(now)
.deleteType(0)
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
.build();
resultList.add(salaryAcctEmployee);
}
}
return resultList;
}
}

View File

@ -1,109 +1,97 @@
//package com.engine.salary.entity.salaryacct.dto;
//
//import com.weaver.common.component.table.type.WeaTableTypeEnum;
//import com.weaver.hrm.salary.annotation.SalaryTable;
//import com.weaver.hrm.salary.annotation.SalaryTableColumn;
//import com.weaver.hrm.salary.annotation.SalaryTableOperate;
//import io.swagger.annotations.ApiModel;
//import io.swagger.annotations.ApiModelProperty;
//import lombok.AllArgsConstructor;
//import lombok.Builder;
//import lombok.Data;
//import lombok.NoArgsConstructor;
//
///**
// * @description: 薪资核算人员列表
// * @author: xiajun
// * @modified By: xiajun
// * @date: Created in 12/3/21 3:30 PM
// * @version:v1.0
// */
//@Data
//@Builder
//@NoArgsConstructor
//@AllArgsConstructor
//@SalaryTable(
// value = {
// @SalaryTableOperate(index = 0, text = "删除", labelId = 87061)
// },
// tableType = WeaTableTypeEnum.CHECKBOX, pageUid = "salaryAccEmployeeList"
//)
//@ApiModel("薪资核算人员列表")
//public class SalaryAccEmployeeListDTO {
//
// @ApiModelProperty("主键id")
// private Long id;
//
// @ApiModelProperty("人员id")
// private Long employeeId;
//
package com.engine.salary.entity.salaryacct.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 薪资核算人员列表
* <p>Copyright: Copyright (c) 2022</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class SalaryAccEmployeeListDTO {
//主键id")
private Long id;
//人员id")
private Long employeeId;
// @SalaryTableColumn(
// label = "姓名",
// labelId = 85429,
// width = "10%"
// )
// @ApiModelProperty("姓名")
// private String employeeName;
//
// @ApiModelProperty("个税扣缴义务人id")
// private Long taxAgentId;
//
//姓名")
private String employeeName;
//个税扣缴义务人id")
private Long taxAgentId;
// @SalaryTableColumn(
// label = "个税扣缴义务人",
// labelId = 86184,
// width = "20%"
// )
// @ApiModelProperty("个税扣缴义务人")
// private String taxAgentName;
//
// @ApiModelProperty("部门id")
// private Long departmentId;
//
//个税扣缴义务人")
private String taxAgentName;
//部门id")
private Long departmentId;
// @SalaryTableColumn(
// label = "部门",
// labelId = 86185,
// width = "20%"
// )
// @ApiModelProperty("部门")
// private String departmentName;
//
//部门")
private String departmentName;
// @SalaryTableColumn(
// label = "手机号",
// labelId = 86186,
// width = "10%"
// )
// @ApiModelProperty("手机号")
// private String mobile;
//
//手机号")
private String mobile;
// @SalaryTableColumn(
// label = "工号",
// labelId = 86317,
// width = "10%"
// )
// @ApiModelProperty("工号")
// private String jobNum;
//
//工号")
private String jobNum;
// @SalaryTableColumn(
// label = "员工状态",
// labelId = 86187,
// width = "10%"
// )
// @ApiModelProperty("员工状态")
// private String status;
//
//员工状态")
private String status;
// @SalaryTableColumn(
// label = "入职日期",
// labelId = 86319,
// width = "10%"
// )
// @ApiModelProperty("入职日期")
// private String hireDate;
//
//// @SalaryTableColumn(
//// label = "离职日期",
//// labelId = 95228,
//// width = "10%"
//// )
//// @ApiModelProperty("离职日期")
// private String dismissDate;
//}
//入职日期")
private String hireDate;
// @SalaryTableColumn(
// label = "离职日期",
// labelId = 95228,
// width = "10%"
// )
// //离职日期")
private String dismissDate;
}

View File

@ -1,24 +1,19 @@
//package com.engine.salary.entity.salaryacct.param;
//
//import io.swagger.annotations.ApiModelProperty;
//import lombok.Data;
//
//import javax.validation.constraints.NotNull;
//
///**
// * @description: 重新核算
// * @author: xiajun
// * @modified By: xiajun
// * @date: Created in 1/13/22 4:08 PM
// * @version:v1.0
// */
//@Data
//public class SalaryAcctRecordReAccountParam {
//
// /**
// * 参数错误薪资核算记录ID不能为空
// */
// @NotNull(message = "LABEL:99845")
// @ApiModelProperty("薪资核算记录id")
// private Long salaryAcctRecordId;
//}
package com.engine.salary.entity.salaryacct.param;
import com.engine.salary.util.valid.DataCheck;
import lombok.Data;
/**
* 重新核算
* <p>Copyright: Copyright (c) 2022</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
@Data
public class SalaryAcctRecordReAccountParam {
@DataCheck(require = true, message = "参数错误薪资核算记录ID不能为空")
private Long salaryAcctRecordId;
}

View File

@ -6,22 +6,23 @@ import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Collection;
import java.util.Date;
/**
* @description: 薪资核算人员
* @author: xiajun
* @modified By: xiajun
* @date: Created in 12/3/21 3:22 PM
* @version:v1.0
*/
* 薪资核算人员
* <p>Copyright: Copyright (c) 2022</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
@Data
@Builder
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
//hrsa_salary_acct_emp")
//hrsa_salary_acct_emp
public class SalaryAcctEmployeePO {
/**
@ -52,7 +53,7 @@ public class SalaryAcctEmployeePO {
/**
* 薪资所属月
*/
private LocalDate salaryMonth;
private Date salaryMonth;
/**
* 租户key
@ -72,10 +73,18 @@ public class SalaryAcctEmployeePO {
/**
* 创建时间
*/
private LocalDateTime createTime;
private Date createTime;
/**
* 更新时间
*/
private LocalDateTime updateTime;
private Date updateTime;
//--------条件----------
//主键id集合
private Collection<Long> ids;
private Collection<Long> salaryAcctRecordIds;
private Collection<Long> employeeIds;
}

View File

@ -1,13 +1,13 @@
package com.engine.salary.mapper;
import java.util.Collection;
import java.util.List;
import com.engine.salary.entity.taxrate.TaxAgent;
import com.engine.salary.entity.taxrate.param.TaxAgentQueryParam;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.Collection;
import java.util.List;
public interface TaxAgentMapper {
/**
@ -90,5 +90,4 @@ public interface TaxAgentMapper {
*/
void deleteByIds(@Param("ids") Collection<Long> ids);
}

View File

@ -2,9 +2,11 @@ package com.engine.salary.mapper.datacollection;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.hrm.PositionInfo;
import com.engine.salary.entity.salarysob.param.SalarySobRangeEmpQueryParam;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
import java.util.List;
@Mapper
@ -22,4 +24,12 @@ public interface EmployMapper {
List<PositionInfo> listPositionInfo(@Param("collection") List<Long> ids);
List<DataCollectionEmployee> getAdminEmployeeByIds(@Param("collection") List<Long> list);
/**
* 根据薪资账套的人员范围转换而成的查询参数查询人员
*
* @param queryParams 薪资账套的人员范围转换而成的查询参数
* @return
*/
List<DataCollectionEmployee> listByParams(@Param("params") Collection<SalarySobRangeEmpQueryParam> queryParams);
}

View File

@ -28,7 +28,10 @@
<select id="getEmployeeByIdsAll" resultType="com.engine.salary.entity.datacollection.DataCollectionEmployee">
select e.id as employeeId,
e.lastname as username,
e.status as status,
e.workcode as workcode,
d.departmentname as departmentName,
d.id as departmentId,
c.jobtitlename as jobtitleName,
e.companystartdate as companystartdate,
e.mobile as mobile,
@ -73,5 +76,47 @@
</if>
</select>
<select id="listByParams" resultType="com.engine.salary.entity.datacollection.DataCollectionEmployee">
SELECT id, username, hiredate
from hrmresource e
left join hrmdepartment d on e.departmentid = d.id
left join hrmjobtitles c on e.jobtitle = c.id
left join bill_hrmdismiss b on e.id = b.resource_n
WHERE e.status not in (7)
<if test="params != null and params.size() > 0">
AND ( 1=2
<foreach collection="params" item="param">
OR
(
<if test="param.targetType == 'EMPLOYEE'">
e.id IN
<foreach collection="param.targetIds" open="(" item="targetId" separator="," close=")">
#{targetId}
</foreach>
</if>
<if test="param.targetType == 'DEPT'">
d.id IN
<foreach collection="param.targetIds" open="(" item="targetId" separator="," close=")">
#{targetId}
</foreach>
</if>
<if test="param.targetType == 'POSITION'">
c.id IN
<foreach collection="param.targetIds" open="(" item="targetId" separator="," close=")">
#{targetId}
</foreach>
</if>
<if test="param.employeeStatus != null and param.employeeStatus.size() > 0">
AND e.status IN
<foreach collection="param.employeeStatus" open="(" item="status" separator="," close=")">
#{status}
</foreach>
</if>
)
</foreach>
)
</if>
</select>
</mapper>

View File

@ -0,0 +1,120 @@
package com.engine.salary.mapper.salaryacct;
import com.engine.salary.entity.salaryacct.dto.SalaryAcctEmployeeCountDTO;
import com.engine.salary.entity.salaryacct.param.SalaryAcctEmployeeQueryParam;
import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
import java.util.List;
/**
* 薪资核算人员
* <p>Copyright: Copyright (c) 2022</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
public interface SalaryAcctEmployeeMapper {
/**
* 批量插入
*
* @param salaryAccountingEmployees
*/
void batchInsert(@Param("collection") Collection<SalaryAcctEmployeePO> salaryAccountingEmployees);
/**
* 统计薪资核算记录的人数
*
* @param salaryAcctRecordIds
* @return
*/
List<SalaryAcctEmployeeCountDTO> countGroupBySalaryAcctRecordId(@Param("salaryAcctRecordIds") Collection<Long> salaryAcctRecordIds);
/**
* 查询合并计税的人员分页
*
* @param otherSalaryAcctRecordIds 相同税款所属期内的其他工资薪金类型的薪资账套的薪资核算记录id
* @param param 人员查询参数
* @return
*/
List<SalaryAcctEmployeePO> listPage4ConsolidatedTax(@Param("otherSalaryAcctRecordIds") Collection<Long> otherSalaryAcctRecordIds,
@Param("param") SalaryAcctEmployeeQueryParam param);
/**
* 查询合并计税的人员
*
* @param otherSalaryAcctRecordIds 相同税款所属期内的其他工资薪金类型的薪资账套的薪资核算记录id
* @param param 人员查询参数
* @return
*/
List<SalaryAcctEmployeePO> list4ConsolidatedTax(@Param("otherSalaryAcctRecordIds") Collection<Long> otherSalaryAcctRecordIds,
@Param("param") SalaryAcctEmployeeQueryParam param);
/**
* 分页查询薪资核算人员
*
* @param param
* @return
*/
List<SalaryAcctEmployeePO> listPage(@Param("param") SalaryAcctEmployeeQueryParam param);
/**
* 查询薪资核算人员
*
* @param param
* @return
*/
List<SalaryAcctEmployeePO> list(@Param("param") SalaryAcctEmployeeQueryParam param);
/**
* 分页查询薪资核算人员环比减少的人员
*
* @param lastMonSalaryAcctRecordIds
* @param param
* @return
*/
List<SalaryAcctEmployeePO> listPage4Reduce(@Param("lastMonSalaryAcctRecordIds") Collection<Long> lastMonSalaryAcctRecordIds,
@Param("param") SalaryAcctEmployeeQueryParam param);
/**
* 查询薪资核算人员环比减少的人员
*
* @param lastMonSalaryAcctRecordIds
* @param param
* @return
*/
List<SalaryAcctEmployeePO> list4Reduce(@Param("lastMonSalaryAcctRecordIds") Collection<Long> lastMonSalaryAcctRecordIds,
@Param("param") SalaryAcctEmployeeQueryParam param);
/**
* 根据主键id删除
*
* @param ids
*/
void deleteByIds(@Param("ids") Collection<Long> ids);
/**
* 根据薪资核算记录id删除
*
* @param salaryAcctRecordIds
*/
void deleteBySalaryAcctRecordIds(@Param("salaryAcctRecordIds") Collection<Long> salaryAcctRecordIds);
/**
* 条件查询
*
* @return 返回集合没有返回空List
*/
List<SalaryAcctEmployeePO> listSome(SalaryAcctEmployeePO salaryAcctEmp);
/**
* 根据主键查询
*
* @param id 主键
* @return 返回记录没有返回null
*/
SalaryAcctEmployeePO getById(Long id);
}

File diff suppressed because it is too large Load Diff

View File

@ -4,6 +4,7 @@ import com.engine.salary.entity.salaryacct.dto.SalaryAcctEmployeeCountDTO;
import com.engine.salary.entity.salaryacct.param.*;
import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO;
import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO;
import com.engine.salary.util.page.PageInfo;
import java.util.Collection;
import java.util.List;
@ -110,7 +111,7 @@ public interface SalaryAcctEmployeeService {
* @param queryParam 列表查询条件
* @return
*/
// Page<SalaryAcctEmployeePO> listPageByParam(SalaryAcctEmployeeQueryParam queryParam);
PageInfo<SalaryAcctEmployeePO> listPageByParam(SalaryAcctEmployeeQueryParam queryParam);
/**
* 根据列表查询条件查询薪资核算人员
@ -126,7 +127,7 @@ public interface SalaryAcctEmployeeService {
* @param queryParam 薪资核算结果列表的列表查询条件
* @return
*/
// Page<SalaryAcctEmployeePO> listPageByResultQueryParam(SalaryAcctResultQueryParam queryParam);
PageInfo<SalaryAcctEmployeePO> listPageByResultQueryParam(SalaryAcctResultQueryParam queryParam);
/**
* 根据薪资核算结果列表的列表查询条件查询薪资核算人员
@ -142,7 +143,7 @@ public interface SalaryAcctEmployeeService {
* @param queryParam 列表查询条件
* @return
*/
// Page<SalaryAcctEmployeePO> listPageByParam4Reduce(SalaryAcctEmployeeQueryParam queryParam);
PageInfo<SalaryAcctEmployeePO> listPageByParam4Reduce(SalaryAcctEmployeeQueryParam queryParam);
/**
* 根据列表查询条件查询同比减少的薪资核算人员
@ -158,7 +159,7 @@ public interface SalaryAcctEmployeeService {
* @param queryParam 列表查询条件
* @return
*/
// Page<SalaryAcctEmployeePO> listPageByParam4ConsolidatedTax(SalaryAcctEmployeeQueryParam queryParam);
PageInfo<SalaryAcctEmployeePO> listPageByParam4ConsolidatedTax(SalaryAcctEmployeeQueryParam queryParam);
/**
* 根据列表查询条件查询合并计税的薪资核算人员
@ -172,17 +173,15 @@ public interface SalaryAcctEmployeeService {
* 添加薪资核算人员
*
* @param saveParam 保存参数
* @param employeeId 人员id
*/
void save(SalaryAcctEmployeeSaveParam saveParam, Long employeeId);
void save(SalaryAcctEmployeeSaveParam saveParam);
/**
* 从环比上月减少添加薪资核算人员
*
* @param param
* @param employeeId
*/
void addFromReduce(SalaryAcctEmployeeAddParam param, Long employeeId);
void addFromReduce(SalaryAcctEmployeeAddParam param);
/**
* 批量保存
@ -223,7 +222,6 @@ public interface SalaryAcctEmployeeService {
* 刷新薪资核算人员的个税扣缴义务人
*
* @param salaryAcctRecordId 薪资核算记录
* @param employeeId 人员id
*/
void refresh(Long salaryAcctRecordId, Long employeeId);
void refresh(Long salaryAcctRecordId);
}

View File

@ -0,0 +1,40 @@
package com.engine.salary.service;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import java.util.List;
/**
* 人员信息
* <p>Copyright: Copyright (c) 2022</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
public interface SalaryEmployeeService {
/**
* 获取租户下的所有人员
*
* @return
*/
List<DataCollectionEmployee> listAll();
/**
* 根据薪资账套id查询人员
*
* @param salarySobId 薪资账套id
* @return
*/
List<DataCollectionEmployee> listBySalarySobId(Long salarySobId);
/**
* 根据薪资账套id查询人员
*
* @param ids
* @return
*/
List<DataCollectionEmployee> listByIds(List<Long> ids);
}

View File

@ -0,0 +1,426 @@
package com.engine.salary.service.impl;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.salary.constant.SalaryDefaultTenantConstant;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.salaryacct.bo.SalaryAcctEmployeeBO;
import com.engine.salary.entity.salaryacct.dto.SalaryAcctEmployeeCountDTO;
import com.engine.salary.entity.salaryacct.param.*;
import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO;
import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO;
import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveDataDTO;
import com.engine.salary.entity.salarysob.dto.SalarySobCycleDTO;
import com.engine.salary.entity.salarysob.po.SalarySobPO;
import com.engine.salary.enums.salaryaccounting.SalaryAcctRecordStatusEnum;
import com.engine.salary.exception.SalaryRunTimeException;
import com.engine.salary.mapper.salaryacct.SalaryAcctEmployeeMapper;
import com.engine.salary.service.*;
import com.engine.salary.util.SalaryDateUtil;
import com.engine.salary.util.SalaryEntityUtil;
import com.engine.salary.util.SalaryI18nUtil;
import com.engine.salary.util.db.SqlProxyHandle;
import com.engine.salary.util.page.PageInfo;
import com.engine.salary.util.page.PageUtil;
import com.engine.salary.util.valid.ValidUtil;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import weaver.hrm.User;
import java.util.*;
import java.util.stream.Collectors;
/**
* 薪资核算人员
* <p>Copyright: Copyright (c) 2022</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
public class SalaryAcctEmployeeServiceImpl extends Service implements SalaryAcctEmployeeService {
private SalaryAcctEmployeeMapper salaryAcctEmployeeMapper;
private SalaryAcctEmployeeMapper getSalaryAcctEmployeeMapper() {
return SqlProxyHandle.getProxy(SalaryAcctEmployeeMapper.class);
}
private SalaryAcctRecordService getSalaryAcctRecordService(User user) {
return (SalaryAcctRecordService) ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user);
}
private SalaryAcctResultService salaryAcctResultService;
// private SalaryAcctResultService getSalaryAcctResultService(User user) {
// return (SalaryAcctResultService) ServiceUtil.getService(SalaryAcctResultServiceImpl.class, user);
// }
// private SalaryCheckResultDetailService salaryCheckResultDetailService;
// private SalaryComparisonResultService salaryComparisonResultService;
private SalarySobService salarySobService;
private SalaryEmployeeService salaryEmployeeService;
private SalaryArchiveService salaryArchiveService;
// private LoggerTemplate salaryAcctRecordLoggerTemplate;
@Override
public List<SalaryAcctEmployeeCountDTO> countBySalaryAcctRecordId(Collection<Long> salaryAcctRecordIds) {
if (CollectionUtils.isEmpty(salaryAcctRecordIds)) {
return Collections.emptyList();
}
return getSalaryAcctEmployeeMapper().countGroupBySalaryAcctRecordId(salaryAcctRecordIds);
}
@Override
public SalaryAcctEmployeePO getById(Long id) {
return getSalaryAcctEmployeeMapper().getById(id);
}
@Override
public List<SalaryAcctEmployeePO> listByIds(Collection<Long> ids) {
return getSalaryAcctEmployeeMapper().listSome(SalaryAcctEmployeePO.builder().ids(ids).build());
}
@Override
public List<SalaryAcctEmployeePO> listBySalaryAcctRecordId(Long salaryAcctRecordId) {
return getSalaryAcctEmployeeMapper().listSome(SalaryAcctEmployeePO.builder().salaryAcctRecordId(salaryAcctRecordId).build());
}
@Override
public List<SalaryAcctEmployeePO> listBySalaryAcctRecordIds(Collection<Long> salaryAcctRecordIds) {
return getSalaryAcctEmployeeMapper().listSome(SalaryAcctEmployeePO.builder().salaryAcctRecordIds(salaryAcctRecordIds).build());
}
@Override
public List<SalaryAcctEmployeePO> listBySalaryAcctRecordIdAndTaxAgentId(Long salaryAcctRecordId, Long taxAgentId) {
return getSalaryAcctEmployeeMapper().listSome(SalaryAcctEmployeePO.builder().salaryAcctRecordId(salaryAcctRecordId).taxAgentId(taxAgentId).build());
}
@Override
public void addFromReduce(SalaryAcctEmployeeAddParam addParam) {
ValidUtil.doValidator(addParam);
// 查询薪资核算记录
SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(addParam.getSalaryAcctRecordId());
if (Objects.isNull(salaryAcctRecordPO)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除"));
}
// 查询环比减少的薪资核算人员
List<SalaryAcctEmployeePO> salaryAcctEmployeePOS = listByIds(addParam.getIds());
if (CollectionUtils.isEmpty(salaryAcctEmployeePOS)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98830, "薪资核算人员不存在或已被删除"));
}
// 添加薪资核算人员
Date now = new Date();
List<SalaryAcctEmployeePO> newSalaryAcctEmployeePOS = salaryAcctEmployeePOS.stream()
.map(salaryAcctEmployeePO -> new SalaryAcctEmployeePO()
// .setId(IdGenerator.generate())
.setSalaryAcctRecordId(salaryAcctRecordPO.getId())
.setSalarySobId(salaryAcctRecordPO.getSalarySobId())
.setSalaryMonth(salaryAcctRecordPO.getSalaryMonth())
.setEmployeeId(salaryAcctEmployeePO.getEmployeeId())
.setTaxAgentId(salaryAcctEmployeePO.getTaxAgentId())
.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
.setCreateTime(now)
.setUpdateTime(now)
.setCreator((long) user.getUID())
.setDeleteType(0))
.collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(newSalaryAcctEmployeePOS)) {
getSalaryAcctEmployeeMapper().batchInsert(newSalaryAcctEmployeePOS);
}
}
@Override
public List<SalaryAcctEmployeePO> listBySalaryAcctRecordIdAndIds(Long salaryAcctRecordId, Collection<Long> ids) {
return getSalaryAcctEmployeeMapper().listSome(SalaryAcctEmployeePO.builder().salaryAcctRecordId(salaryAcctRecordId).ids(ids).build());
}
@Override
public List<SalaryAcctEmployeePO> listBySalaryAcctRecordIdAndEmployeeIds(Long salaryAcctRecordId, Collection<Long> employeeIds) {
if (CollectionUtils.isEmpty(employeeIds)) {
return Collections.emptyList();
}
return getSalaryAcctEmployeeMapper().listSome(SalaryAcctEmployeePO.builder().salaryAcctRecordId(salaryAcctRecordId).employeeIds(employeeIds).build());
}
@Override
public List<SalaryAcctEmployeePO> listBySalaryAcctRecordIdsAndEmployeeIds(Collection<Long> salaryAcctRecordIds, Collection<Long> employeeIds) {
if (CollectionUtils.isEmpty(salaryAcctRecordIds) || CollectionUtils.isEmpty(employeeIds)) {
return Collections.emptyList();
}
return getSalaryAcctEmployeeMapper().listSome(SalaryAcctEmployeePO.builder().salaryAcctRecordIds(salaryAcctRecordIds).employeeIds(employeeIds).build());
}
@Override
public List<SalaryAcctEmployeePO> listByRecordIdsAndEmpIdAndTaxAgentId(Collection<Long> salaryAcctRecordIds, Long employeeId, Long taxAgentId) {
if (CollectionUtils.isEmpty(salaryAcctRecordIds)) {
return Collections.emptyList();
}
return getSalaryAcctEmployeeMapper().listSome(SalaryAcctEmployeePO.builder().salaryAcctRecordIds(salaryAcctRecordIds).employeeId(employeeId).taxAgentId(taxAgentId).build());
}
@Override
public PageInfo<SalaryAcctEmployeePO> listPageByParam(SalaryAcctEmployeeQueryParam queryParam) {
ValidUtil.doValidator(queryParam);
// 分页参数
PageUtil.start(queryParam.getCurrent(), queryParam.getPageSize());
// 查询薪资核算人员
List<SalaryAcctEmployeePO> salaryAcctEmployeePOS = getSalaryAcctEmployeeMapper().listPage(queryParam);
return new PageInfo<>(salaryAcctEmployeePOS);
}
@Override
public List<SalaryAcctEmployeePO> listByParam(SalaryAcctEmployeeQueryParam queryParam) {
ValidUtil.doValidator(queryParam);
return getSalaryAcctEmployeeMapper().list(queryParam);
}
@Override
public PageInfo<SalaryAcctEmployeePO> listPageByResultQueryParam(SalaryAcctResultQueryParam queryParam) {
ValidUtil.doValidator(queryParam);
// 薪资核算人员的查询参数
SalaryAcctEmployeeQueryParam salaryAcctEmployeeQueryParam = new SalaryAcctEmployeeQueryParam();
BeanUtils.copyProperties(queryParam, salaryAcctEmployeeQueryParam);
// 查询薪资核算人员分页
// 如果需要筛选是否合并计税
if (StringUtils.isNotEmpty(queryParam.getConsolidatedTaxation())) {
return listPageByParam4ConsolidatedTax(salaryAcctEmployeeQueryParam);
} else {
return listPageByParam(salaryAcctEmployeeQueryParam);
}
}
@Override
public List<SalaryAcctEmployeePO> listByResultQueryParam(SalaryAcctResultQueryParam queryParam) {
// 薪资核算人员的查询参数
SalaryAcctEmployeeQueryParam salaryAcctEmployeeQueryParam = new SalaryAcctEmployeeQueryParam();
BeanUtils.copyProperties(queryParam, salaryAcctEmployeeQueryParam);
// 查询薪资核算人员
List<SalaryAcctEmployeePO> salaryAcctEmployeePOS;
// 如果需要筛选是否合并计税
if (StringUtils.isNotEmpty(queryParam.getConsolidatedTaxation())) {
salaryAcctEmployeePOS = listByParam4ConsolidatedTax(salaryAcctEmployeeQueryParam);
} else {
salaryAcctEmployeePOS = listByParam(salaryAcctEmployeeQueryParam);
}
return salaryAcctEmployeePOS;
}
@Override
public PageInfo<SalaryAcctEmployeePO> listPageByParam4Reduce(SalaryAcctEmployeeQueryParam queryParam) {
// 查询上个月的薪资核算记录同一个薪资账套
List<SalaryAcctRecordPO> salaryAcctRecordPOS = getSalaryAcctRecordService(user).listById4LastSalaryMonth(queryParam.getSalaryAcctRecordId());
if (CollectionUtils.isEmpty(salaryAcctRecordPOS)) {
return new PageInfo<>();
}
Set<Long> lastMonthSalaryAcctRecordIds = SalaryEntityUtil.properties(salaryAcctRecordPOS, SalaryAcctRecordPO::getId);
// 查询环比减少人员
// 分页参数
PageUtil.start(queryParam.getCurrent(), queryParam.getPageSize());
List<SalaryAcctEmployeePO> salaryAcctEmployeePOS = getSalaryAcctEmployeeMapper().listPage4Reduce(lastMonthSalaryAcctRecordIds, queryParam);
PageInfo<SalaryAcctEmployeePO> salaryAcctEmployeePOPageInfo = new PageInfo<>(salaryAcctEmployeePOS);
return salaryAcctEmployeePOPageInfo;
}
@Override
public List<SalaryAcctEmployeePO> listByParam4Reduce(SalaryAcctEmployeeQueryParam queryParam) {
// 查询上个月的薪资核算记录同一个薪资账套
List<SalaryAcctRecordPO> salaryAcctRecordPOS = getSalaryAcctRecordService(user).listById4LastSalaryMonth(queryParam.getSalaryAcctRecordId());
if (CollectionUtils.isEmpty(salaryAcctRecordPOS)) {
return Collections.emptyList();
}
Set<Long> lastMonthSalaryAcctRecordIds = SalaryEntityUtil.properties(salaryAcctRecordPOS, SalaryAcctRecordPO::getId);
// 查询环比减少人员
return getSalaryAcctEmployeeMapper().list4Reduce(lastMonthSalaryAcctRecordIds, queryParam);
}
@Override
public PageInfo<SalaryAcctEmployeePO> listPageByParam4ConsolidatedTax(SalaryAcctEmployeeQueryParam queryParam) {
// 查询合并计税的其他薪资核算记录
List<SalaryAcctRecordPO> otherSalaryAcctRecordPOS = getSalaryAcctRecordService(user).listById4OtherConsolidatedTax(queryParam.getSalaryAcctRecordId());
if (CollectionUtils.isEmpty(otherSalaryAcctRecordPOS)) {
return new PageInfo<>();
}
// 查询合并计税的薪资核算人员
Set<Long> otherSalaryAcctRecordIds = SalaryEntityUtil.properties(otherSalaryAcctRecordPOS, SalaryAcctRecordPO::getId);
// 分页参数
PageUtil.start(queryParam.getCurrent(), queryParam.getPageSize());
List<SalaryAcctEmployeePO> salaryAcctEmployeePOS = getSalaryAcctEmployeeMapper().listPage4ConsolidatedTax(otherSalaryAcctRecordIds, queryParam);
PageInfo<SalaryAcctEmployeePO> salaryAcctEmployeePOPageInfo = new PageInfo<>(salaryAcctEmployeePOS);
return salaryAcctEmployeePOPageInfo;
}
@Override
public List<SalaryAcctEmployeePO> listByParam4ConsolidatedTax(SalaryAcctEmployeeQueryParam queryParam) {
// 查询合并计税的其他薪资核算记录
List<SalaryAcctRecordPO> otherSalaryAcctRecordPOS = getSalaryAcctRecordService(user).listById4OtherConsolidatedTax(queryParam.getSalaryAcctRecordId());
if (CollectionUtils.isEmpty(otherSalaryAcctRecordPOS)) {
return Collections.emptyList();
}
// 查询合并计税的薪资核算人员
Set<Long> otherSalaryAcctRecordIds = SalaryEntityUtil.properties(otherSalaryAcctRecordPOS, SalaryAcctRecordPO::getId);
return getSalaryAcctEmployeeMapper().list4ConsolidatedTax(otherSalaryAcctRecordIds, queryParam);
}
@Override
public void save(SalaryAcctEmployeeSaveParam saveParam) {
// 查询薪资核算记录
SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(saveParam.getSalaryAcctRecordId());
if (Objects.isNull(salaryAcctRecordPO)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除"));
}
// 查询薪资核算人员
List<SalaryAcctEmployeePO> existSalaryAcctEmployeePOS = listBySalaryAcctRecordIdAndEmployeeIds(saveParam.getSalaryAcctRecordId(), saveParam.getEmployeeIds());
if (CollectionUtils.isNotEmpty(existSalaryAcctEmployeePOS)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(101581, "人员已存在,请勿重复添加"));
}
// 根据薪资账套查询薪资周期
SalarySobCycleDTO salarySobCycleDTO = salarySobService.getSalarySobCycle(salaryAcctRecordPO.getSalarySobId(), SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getSalaryMonth()));
// 查询薪资档案获取人员的个税扣缴义务人
List<SalaryArchiveDataDTO> salaryArchiveDataDTOS = salaryArchiveService.getSalaryArchiveTaxAgentData(salarySobCycleDTO.getSalaryCycle(), saveParam.getEmployeeIds());
// 转换成薪资核算人员po
List<SalaryAcctEmployeePO> salaryAcctEmployeePOS = SalaryAcctEmployeeBO.convert2EmployeePO(saveParam.getEmployeeIds(), salaryAcctRecordPO, salaryArchiveDataDTOS, (long)user.getUID());
// 保存薪资核算人员
if (CollectionUtils.isNotEmpty(salaryAcctEmployeePOS)) {
getSalaryAcctEmployeeMapper().batchInsert(salaryAcctEmployeePOS);
}
// 查询薪资账套记录日志用
SalarySobPO salarySobPO = salarySobService.getById(salaryAcctRecordPO.getSalarySobId());
if (Objects.isNull(salarySobPO)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98769, "薪资账套不存在或已被删除"));
}
// 记录日志
// String targetName = salarySobPO.getName() + ":" + SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getSalaryMonth());
// LoggerContext loggerContext = new LoggerContext<>();
// loggerContext.setTargetId("" + salaryAcctRecordPO.getId());
// loggerContext.setTargetName(targetName);
// loggerContext.setOperateType(OperateTypeEnum.ADD.getValue());
// loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(98837, "添加薪资核算人员"));
// loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(98837, "添加薪资核算人员") + ":" + targetName);
// loggerContext.setNewValueList(salaryAcctEmployeePOS);
// salaryAcctRecordLoggerTemplate.write(loggerContext);
}
@Override
public void batchSave(Collection<SalaryAcctEmployeePO> salaryAcctEmployeePOS) {
getSalaryAcctEmployeeMapper().batchInsert(salaryAcctEmployeePOS);
}
@Override
public void deleteByIds(Collection<Long> ids) {
// 删除薪资核算人员
getSalaryAcctEmployeeMapper().deleteByIds(ids);
// // 删除薪资核算人员对应的薪资核算结果
// salaryAcctResultService.deleteBySalaryAcctEmployeeIds(ids);
// // 删除薪资核算人员对应的校验异常明细
// salaryCheckResultDetailService.deleteBySalaryAcctEmployeeIds(ids);
// // 删除薪资核算人员对应的线下对比结果
// salaryComparisonResultService.deleteBySalaryAcctRecordIds(ids);
}
@Override
public void deleteByParam(SalaryAcctEmployeeDeleteParam deleteParam) {
// 查询薪资核算记录
SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(deleteParam.getSalaryAcctRecordId());
if (Objects.isNull(salaryAcctRecordPO)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除"));
}
// 只有未归档时才能删除薪资核算人员
if (!Objects.equals(salaryAcctRecordPO.getStatus(), SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue())) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98830, "薪资核算已归档或已申报,不允许再删除薪资核算人员"));
}
// 查询薪资核算人员
List<SalaryAcctEmployeePO> salaryAcctEmployeePOS = listBySalaryAcctRecordIdAndIds(deleteParam.getSalaryAcctRecordId(), deleteParam.getIds());
if (CollectionUtils.isEmpty(salaryAcctEmployeePOS)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98830, "薪资核算人员不存在或已被删除"));
}
// 删除薪资核算人员
Set<Long> ids = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getId);
deleteByIds(ids);
// 查询薪资账套记录日志用
SalarySobPO salarySobPO = salarySobService.getById(salaryAcctRecordPO.getSalarySobId());
if (Objects.isNull(salarySobPO)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98769, "薪资账套不存在或已被删除"));
}
// 记录日志
// String targetName = salarySobPO.getName() + ":" + SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getSalaryMonth());
// LoggerContext loggerContext = new LoggerContext<>();
// loggerContext.setTargetId("" + salaryAcctRecordPO.getId());
// loggerContext.setTargetName(targetName);
// loggerContext.setOperateType(OperateTypeEnum.DELETE.getValue());
// loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(98835, "删除薪资核算人员"));
// loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(98835, "删除薪资核算人员") + ":" + targetName);
// loggerContext.setOldValueList(salaryAcctEmployeePOS);
// salaryAcctRecordLoggerTemplate.write(loggerContext);
}
@Override
public void deleteBySalaryAcctRecordIds(Collection<Long> salaryAcctRecordIds) {
getSalaryAcctEmployeeMapper().deleteBySalaryAcctRecordIds(salaryAcctRecordIds);
}
@Override
public void initBySalaryAcctRecord(SalaryAcctRecordPO salaryAcctRecordPO) {
// 根据薪资账套查询人员
List<DataCollectionEmployee> salaryEmployees = salaryEmployeeService.listBySalarySobId(salaryAcctRecordPO.getSalarySobId());
if (CollectionUtils.isEmpty(salaryEmployees)) {
return;
}
// 根据薪资账套查询薪资周期
SalarySobCycleDTO salarySobCycleDTO = salarySobService.getSalarySobCycle(salaryAcctRecordPO.getSalarySobId(), SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getSalaryMonth()));
// 根据薪资账套的"核算人员范围"过滤入职日期大于薪资周期止的人员
salaryEmployees = salaryEmployees.stream()
.filter(salaryEmployee -> Objects.isNull(salaryEmployee.getCompanystartdate())
|| salaryEmployee.getCompanystartdate().compareTo(salarySobCycleDTO.getSalaryCycle().getEndDate()) <= 0)
.collect(Collectors.toList());
// 根据薪资账套的"核算人员范围"过滤离职日期小于薪资周期起的人员
// TODO: 2/9/22 过滤离职人员
// 查询薪资档案获取人员的个税扣缴义务人
Set<Long> employeeIds = SalaryEntityUtil.properties(salaryEmployees, DataCollectionEmployee::getEmployeeId);
List<SalaryArchiveDataDTO> salaryArchiveDataDTOS = salaryArchiveService.getSalaryArchiveTaxAgentData(salarySobCycleDTO.getSalaryCycle(), employeeIds);
// 转换成薪资核算人员po
List<SalaryAcctEmployeePO> salaryAcctEmployeePOS = SalaryAcctEmployeeBO.convert2EmployeePO(employeeIds, salaryAcctRecordPO, salaryArchiveDataDTOS, (long) user.getUID());
// 保存薪资核算人员
if (CollectionUtils.isNotEmpty(salaryAcctEmployeePOS)) {
getSalaryAcctEmployeeMapper().batchInsert(salaryAcctEmployeePOS);
}
}
@Override
public void refresh(Long salaryAcctRecordId) {
// 查询薪资核算人员
List<SalaryAcctEmployeePO> salaryAcctEmployeePOS = listBySalaryAcctRecordId(salaryAcctRecordId);
if (CollectionUtils.isEmpty(salaryAcctEmployeePOS)) {
return;
}
Set<Long> employeeIds = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getEmployeeId);
// 查询薪资核算记录
SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(salaryAcctRecordId);
if (Objects.isNull(salaryAcctRecordPO)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除"));
}
// 查询薪资核算记录所用的帐套的薪资周期
SalarySobCycleDTO salarySobCycleDTO = salarySobService.getSalarySobCycle(salaryAcctRecordPO.getSalarySobId(),
SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getSalaryMonth()));
// 查询薪资档案获取人员的个税扣缴义务人
List<SalaryArchiveDataDTO> salaryArchiveDataDTOS = salaryArchiveService.getSalaryArchiveTaxAgentData(salarySobCycleDTO.getSalaryCycle(), employeeIds);
// 转换成薪资核算人员po
List<SalaryAcctEmployeePO> newSalaryAcctEmployeePOS = SalaryAcctEmployeeBO.convert2EmployeePO(employeeIds, salaryAcctRecordPO, salaryArchiveDataDTOS, (long) user.getUID());
// 删除以前的薪资核算人员
getSalaryAcctEmployeeMapper().deleteBySalaryAcctRecordIds(Collections.singleton(salaryAcctRecordId));
// 插入新的薪资核算人员
if (CollectionUtils.isNotEmpty(newSalaryAcctEmployeePOS)) {
getSalaryAcctEmployeeMapper().batchInsert(newSalaryAcctEmployeePOS);
}
}
}

View File

@ -0,0 +1,527 @@
//package com.engine.salary.service.impl;
//
//import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
//import com.engine.core.impl.Service;
//import com.engine.salary.service.SalaryAcctResultService;
//import com.google.common.collect.Lists;
//import com.weaver.common.component.table.page.Page;
//import com.weaver.common.elog.dto.LoggerContext;
//import com.weaver.common.elog.util.LoggerTemplate;
//import com.weaver.common.hrm.service.HrmCommonEmployeeService;
//import com.weaver.common.threadPool.ThreadPoolUtil;
//import com.weaver.common.threadPool.constant.ModulePoolEnum;
//import com.weaver.common.threadPool.entity.LocalRunnable;
//import com.weaver.datasecurity.interceptor.DSTenantKeyThreadVar;
//import com.weaver.excel.formula.api.entity.ExpressFormula;
//import com.weaver.hrm.salary.common.LocalDateRange;
//import com.weaver.hrm.salary.dao.SalaryAcctResultMapper;
//import com.weaver.hrm.salary.entity.datacollection.dto.AttendQuoteFieldListDTO;
//import com.weaver.hrm.salary.entity.salaryacct.bo.SalaryAcctCalculateBO;
//import com.weaver.hrm.salary.entity.salaryacct.bo.SalaryAcctCalculatePriorityBO;
//import com.weaver.hrm.salary.entity.salaryacct.bo.SalaryAcctResultBO;
//import com.weaver.hrm.salary.entity.salaryacct.dto.ConsolidatedTaxDetailDTO;
//import com.weaver.hrm.salary.entity.salaryacct.dto.SalaryAcctProgressDTO;
//import com.weaver.hrm.salary.entity.salaryacct.dto.SalaryAcctResultDetailDTO;
//import com.weaver.hrm.salary.entity.salaryacct.param.*;
//import com.weaver.hrm.salary.entity.salaryacct.po.*;
//import com.weaver.hrm.salary.entity.salaryarchive.po.TaxAgentPO;
//import com.weaver.hrm.salary.entity.salaryitem.po.SalaryItemPO;
//import com.weaver.hrm.salary.entity.salarysob.dto.SalarySobCycleDTO;
//import com.weaver.hrm.salary.entity.salarysob.po.SalarySobAdjustRulePO;
//import com.weaver.hrm.salary.entity.salarysob.po.SalarySobEmpFieldPO;
//import com.weaver.hrm.salary.entity.salarysob.po.SalarySobItemPO;
//import com.weaver.hrm.salary.entity.salarysob.po.SalarySobPO;
//import com.weaver.hrm.salary.enums.OperateTypeEnum;
//import com.weaver.hrm.salary.enums.salaryaccounting.SalaryAcctRecordStatusEnum;
//import com.weaver.hrm.salary.enums.salarysob.IncomeCategoryEnum;
//import com.weaver.hrm.salary.exception.SalaryRunTimeException;
//import com.weaver.hrm.salary.service.*;
//import com.weaver.hrm.salary.util.SalaryDateUtil;
//import com.weaver.hrm.salary.util.SalaryEntityUtil;
//import com.weaver.hrm.salary.util.SalaryI18nUtil;
//import com.weaver.teams.domain.user.SimpleEmployee;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.commons.collections4.CollectionUtils;
//import org.apache.commons.collections4.MapUtils;
//import org.apache.commons.lang3.StringUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.jdbc.datasource.DataSourceTransactionManager;
//import org.springframework.transaction.TransactionStatus;
//import org.springframework.transaction.support.DefaultTransactionDefinition;
//
//import java.math.BigDecimal;
//import java.util.*;
//import java.util.concurrent.BlockingDeque;
//import java.util.concurrent.CountDownLatch;
//import java.util.concurrent.LinkedBlockingDeque;
//import java.util.stream.Collectors;
//
///**
// * 薪资核算结果
// * <p>Copyright: Copyright (c) 2022</p>
// * <p>Company: 泛微软件</p>
// *
// * @author qiantao
// * @version 1.0
// **/
//@Slf4j
//public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctResultService {
//
// @Autowired
// private SalaryAcctResultMapper salaryAcctResultMapper;
// @Autowired
// private SalaryAcctEmployeeService salaryAcctEmployeeService;
// @Autowired
// private SalarySobItemService salarySobItemService;
// @Autowired
// private SalaryItemService salaryItemService;
// @Autowired
// private SalarySobEmpFieldService salarySobEmpFieldService;
// @Autowired
// private SalarySobService salarySobService;
// @Autowired
// private SalaryAcctRecordService salaryAcctRecordService;
// @Autowired
// private TaxAgentService taxAgentService;
// @Autowired
// private HrmCommonEmployeeService hrmCommonEmployeeService;
// @Autowired
// private SalaryFormulaService salaryFormulaService;
// @Autowired
// private SalarySobAdjustRuleService salarySobAdjustRuleService;
// @Autowired
// private SalaryAcctCalculateService salaryAcctCalculateService;
// @Autowired
// private SalaryAcctProgressService salaryAcctProgressService;
// @Autowired
// private DataSourceTransactionManager dataSourceTransactionManager;
// @Autowired
// private SalaryAcctResultTempService salaryAcctResultTempService;
// @Autowired
// private LoggerTemplate salaryAcctRecordLoggerTemplate;
// @Autowired
// private SIAccountService siAccountService;
// @Autowired
// private AttendQuoteFieldService attendQuoteFieldService;
// @Autowired
// private SalaryCheckResultService salaryCheckResultService;
//
// @Override
// public List<SalaryAcctResultPO> listBySalaryAcctRecordIds(Collection<Long> salaryAcctRecordIds, String tenantKey) {
// if (CollectionUtils.isEmpty(salaryAcctRecordIds)) {
// return Collections.emptyList();
// }
// return new LambdaQueryChainWrapper<>(salaryAcctResultMapper)
// .eq(SalaryAcctResultPO::getTenantKey, tenantKey)
// .eq(SalaryAcctResultPO::getDeleteType, 0)
// .in(SalaryAcctResultPO::getSalaryAcctRecordId, salaryAcctRecordIds)
// .list();
// }
//
// @Override
// public List<SalaryAcctResultPO> listBySalaryAcctEmployeeId(Long salaryAcctEmployeeId, String tenantKey) {
// return new LambdaQueryChainWrapper<>(salaryAcctResultMapper)
// .eq(SalaryAcctResultPO::getTenantKey, tenantKey)
// .eq(SalaryAcctResultPO::getDeleteType, 0)
// .eq(SalaryAcctResultPO::getSalaryAcctEmpId, salaryAcctEmployeeId)
// .list();
// }
//
// @Override
// public List<SalaryAcctResultPO> listBySalaryAcctEmployeeIds(Collection<Long> salaryAcctEmployeeIds, String tenantKey) {
// if (CollectionUtils.isEmpty(salaryAcctEmployeeIds)) {
// return Collections.emptyList();
// }
// return new LambdaQueryChainWrapper<>(salaryAcctResultMapper)
// .eq(SalaryAcctResultPO::getTenantKey, tenantKey)
// .eq(SalaryAcctResultPO::getDeleteType, 0)
// .in(SalaryAcctResultPO::getSalaryAcctEmpId, salaryAcctEmployeeIds)
// .list();
// }
//
// @Override
// public List<SalaryAcctResultPO> listBySalaryAcctRecordIdsAndEmployeeIds(Collection<Long> salaryAcctRecordIds, Collection<Long> employeeIds, String tenantKey) {
// if (CollectionUtils.isEmpty(salaryAcctRecordIds) || CollectionUtils.isEmpty(employeeIds)) {
// return Collections.emptyList();
// }
// return new LambdaQueryChainWrapper<>(salaryAcctResultMapper)
// .eq(SalaryAcctResultPO::getTenantKey, tenantKey)
// .eq(SalaryAcctResultPO::getDeleteType, 0)
// .in(SalaryAcctResultPO::getSalaryAcctRecordId, salaryAcctRecordIds)
// .in(SalaryAcctResultPO::getEmployeeId, employeeIds)
// .list();
// }
//
// @Override
// public SalaryAcctResultDetailDTO getBySalaryAcctEmployeeId(Long salaryAcctEmployeeId, String tenantKey) {
// // 查询薪资核算人员
// SalaryAcctEmployeePO salaryAcctEmployeePO = salaryAcctEmployeeService.getById(salaryAcctEmployeeId, tenantKey);
// if (Objects.isNull(salaryAcctEmployeePO)) {
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98831, "薪资核算人员不存在或已被删除"));
// }
// // 查询薪资核算所用薪资账套的薪资项目副本
// List<SalarySobItemPO> salarySobItemPOS = salarySobItemService.listBySalarySobId(salaryAcctEmployeePO.getSalarySobId(), tenantKey);
// // 查询薪资项目
// Set<Long> salaryItemIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getSalaryItemId);
// List<SalaryItemPO> salaryItemPOS = salaryItemService.listByIds(salaryItemIds, tenantKey);
// // 查询薪资核算所用薪资账套的人员信息字段
// List<SalarySobEmpFieldPO> salarySobEmpFieldPOS = salarySobEmpFieldService.listBySalarySobId(salaryAcctEmployeePO.getSalarySobId(), tenantKey);
// // 查询人员信息
// SimpleEmployee simpleEmployee = hrmCommonEmployeeService.getEmployeeById(salaryAcctEmployeePO.getEmployeeId(), tenantKey);
// // 查询薪资核算结果
// List<SalaryAcctResultPO> salaryAcctResultPOS = listBySalaryAcctEmployeeId(salaryAcctEmployeeId, tenantKey);
// // 查询个税扣缴义务人
// TaxAgentPO taxAgentPO = taxAgentService.getById(salaryAcctEmployeePO.getTaxAgentId(), tenantKey);
// // 转换成薪资核算结果详情dto
// return SalaryAcctResultBO.convert2DetailDTO(simpleEmployee, taxAgentPO, salaryAcctEmployeePO, salarySobEmpFieldPOS, salarySobItemPOS, salaryItemPOS, salaryAcctResultPOS);
// }
//
// @Override
// public Page<Map<String, Object>> listPageByParam(SalaryAcctResultQueryParam queryParam, String tenantKey) {
// // 查询薪资核算人员分页
// Page<SalaryAcctEmployeePO> page = salaryAcctEmployeeService.listPageByResultQueryParam(queryParam, tenantKey);
// // 查询薪资核算结果
// List<Map<String, Object>> data = listBySalaryAcctEmployees(page.getRecords(), queryParam, tenantKey);
// // 薪资核算结果的分页结果
// Page<Map<String, Object>> resultPage = new Page<>(page.getCurrent(), page.getSize(), page.getTotal(), page.isSearchCount());
// resultPage.setRecords(data);
// return resultPage;
// }
//
// @Override
// public List<Map<String, Object>> listByParam(SalaryAcctResultQueryParam queryParam, String tenantKey) {
// // 查询薪资核算人员
// List<SalaryAcctEmployeePO> salaryAcctEmployeePOS = salaryAcctEmployeeService.listByResultQueryParam(queryParam, tenantKey);
// // 查询薪资核算结果
// return listBySalaryAcctEmployees(salaryAcctEmployeePOS, queryParam, tenantKey);
// }
//
// /**
// * 根据薪资核算人员查询薪资核算结果
// *
// * @param salaryAcctEmployeePOS 薪资核算人员
// * @param queryParam 列表查询条件
// * @param tenantKey 租户key
// * @return
// */
// private List<Map<String, Object>> listBySalaryAcctEmployees(List<SalaryAcctEmployeePO> salaryAcctEmployeePOS,
// SalaryAcctResultQueryParam queryParam,
// String tenantKey) {
// if (CollectionUtils.isEmpty(salaryAcctEmployeePOS)) {
// return Collections.emptyList();
// }
// // 查询薪资核算记录
// SalaryAcctRecordPO salaryAcctRecordPO = salaryAcctRecordService.getById(queryParam.getSalaryAcctRecordId(), tenantKey);
// if (Objects.isNull(salaryAcctRecordPO)) {
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除"));
// }
// // 查询薪资核算所用的薪资账套的员工信息字段
// List<SalarySobEmpFieldPO> salarySobEmpFieldPOS = salarySobEmpFieldService.listBySalarySobId(salaryAcctRecordPO.getSalarySobId(), tenantKey);
// // 查询薪资核算所用薪资账套的薪资项目
// List<SalarySobItemPO> salarySobItemPOS = salarySobItemService.listBySalarySobId(salaryAcctRecordPO.getSalarySobId(), tenantKey);
// Set<Long> salaryItemIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getSalaryItemId);
// List<SalaryItemPO> salaryItemPOS = salaryItemService.listByIds(salaryItemIds, tenantKey);
// // 查询薪资核算结果
// Set<Long> salaryAcctEmployeeIds = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getId);
// List<SalaryAcctResultPO> salaryAcctResultPOS = listBySalaryAcctEmployeeIds(salaryAcctEmployeeIds, tenantKey);
// // 查询人员信息
// List<Long> employeeIds = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getEmployeeId, Collectors.toList());
// List<SimpleEmployee> simpleEmployees = hrmCommonEmployeeService.getEmployeeByIds(employeeIds, tenantKey);
// // 查询个税扣缴义务人
// Set<Long> taxAgentIds = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getTaxAgentId);
// List<TaxAgentPO> taxAgentPOS = taxAgentService.listByIds(taxAgentIds, tenantKey);
// // 判断是否存在合并计税
// Set<Long> salaryAcctEmployeeIds4ConsolidatedTax;
// if (StringUtils.isNotEmpty(queryParam.getConsolidatedTaxation())) {
// // 如果查询条件中含有"合并计税"那么在入参中的salaryAcctEmployeePOS就已经全部都是存在合并计税的人员了前面已经过滤了无需再次查询合并计税的人员
// salaryAcctEmployeeIds4ConsolidatedTax = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getId);
// } else {
// // 如果查询条件中没有包含"合并计税"那么就需要查询出存在合并计税的人标记给前端
// SalaryAcctEmployeeQueryParam accEmployeeQueryParam = new SalaryAcctEmployeeQueryParam()
// .setSalaryAcctRecordId(queryParam.getSalaryAcctRecordId())
// .setIds(SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getId));
// List<SalaryAcctEmployeePO> salaryAcctEmployeePOS4ConsolidatedTax = salaryAcctEmployeeService.listByParam4ConsolidatedTax(accEmployeeQueryParam, tenantKey);
// salaryAcctEmployeeIds4ConsolidatedTax = SalaryEntityUtil.properties(salaryAcctEmployeePOS4ConsolidatedTax, SalaryAcctEmployeePO::getId);
// }
// // 查询公式详情
// Set<Long> formulaIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getFormulaId);
// List<ExpressFormula> expressFormulas = salaryFormulaService.listExpressFormula(formulaIds, tenantKey);
// Map<Long, String> expressFormulaMap = SalaryEntityUtil.convert2Map(expressFormulas, ExpressFormula::getId, ExpressFormula::getFormula);
// Map<Long, String> customParameters = SalaryEntityUtil.convert2Map(salarySobItemPOS, SalarySobItemPO::getSalaryItemId, salarySobItemPO -> {
// if (salarySobItemPO.getFormulaId() <= 0) {
// return SalaryI18nUtil.getI18nLabel(92004, "输入/导入");
// }
// return expressFormulaMap.getOrDefault(salarySobItemPO.getFormulaId(), StringUtils.EMPTY);
// });
// // 转换成薪资核算结果列表
// return SalaryAcctResultBO
// .buildTableData(salaryItemPOS, salarySobEmpFieldPOS, simpleEmployees, salaryAcctEmployeePOS, salaryAcctResultPOS, taxAgentPOS, salaryAcctEmployeeIds4ConsolidatedTax, customParameters);
//
// }
//
// @Override
// public ConsolidatedTaxDetailDTO getConsolidatedTaxDetail(Long salaryAcctEmployeeId, String tenantKey) {
// // 查询当前的薪资核算人员
// SalaryAcctEmployeePO salaryAcctEmployeePO = salaryAcctEmployeeService.getById(salaryAcctEmployeeId, tenantKey);
// if (Objects.isNull(salaryAcctEmployeePO)) {
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98831, "薪资核算人员不存在或已被删除"));
// }
// // 查询当前的薪资核算人员的个税扣缴义务人
// TaxAgentPO taxAgentPO = taxAgentService.getById(salaryAcctEmployeePO.getTaxAgentId(), tenantKey);
// // 查询当前的薪资核算人员的人员信息
// SimpleEmployee simpleEmployee = hrmCommonEmployeeService.getEmployeeById(salaryAcctEmployeePO.getEmployeeId(), tenantKey);
// // 查询当前的薪资核算记录
// SalaryAcctRecordPO salaryAcctRecordPO = salaryAcctRecordService.getById(salaryAcctEmployeePO.getSalaryAcctRecordId(), tenantKey);
// // 查询当前薪资核算记录所用的薪资账套
// SalarySobPO salarySobPO = salarySobService.getById(salaryAcctRecordPO.getSalarySobId(), tenantKey);
// // 当前薪资核算记录所用的薪资账套的员工信息字段
// List<SalarySobEmpFieldPO> salarySobEmpFieldPOS = salarySobEmpFieldService.listBySalarySobId(salarySobPO.getId(), tenantKey);
//
// List<SalaryAcctRecordPO> salaryAcctRecordPOS = Collections.singletonList(salaryAcctRecordPO);
// List<SalaryAcctEmployeePO> salaryAcctEmployeePOS = Collections.singletonList(salaryAcctEmployeePO);
//
// // 如果当前薪资核算记录所用的薪资账套的薪资类型是工资薪金代表可能存在合并计税
// if (Objects.equals(salarySobPO.getIncomeCategory(), IncomeCategoryEnum.WAGES_AND_SALARIES.getValue())) {
// // 查询所有薪资类型为工资薪金的账套
// List<SalarySobPO> salarySobPOS = salarySobService.listByIncomeCategory(IncomeCategoryEnum.WAGES_AND_SALARIES, tenantKey);
// // 查询相同税款所属期内的薪资类型为工资薪金的账套的所有核算记录
// Set<Long> salarySobIds = SalaryEntityUtil.properties(salarySobPOS, SalarySobPO::getId);
// LocalDateRange taxCycleDateRange = SalaryDateUtil.localDate2Range(salaryAcctRecordPO.getTaxCycle());
// salaryAcctRecordPOS = salaryAcctRecordService.listBySalarySobIdsAndSalaryMonth(salarySobIds, taxCycleDateRange, tenantKey);
// // 查询当前薪资核算人员所涉及的合并计税的所有薪资核算人员
// Set<Long> salaryAcctRecordIds = SalaryEntityUtil.properties(salaryAcctRecordPOS, SalaryAcctRecordPO::getId);
// salaryAcctEmployeePOS = salaryAcctEmployeeService.listByRecordIdsAndEmpIdAndTaxAgentId(salaryAcctRecordIds,
// salaryAcctEmployeePO.getEmployeeId(), salaryAcctEmployeePO.getTaxAgentId(), tenantKey);
// }
// // 查询薪资核算人员的薪资核算结果
// Set<Long> salaryAcctEmployeeIds = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getId);
// List<SalaryAcctResultPO> salaryAcctResultPOS = listBySalaryAcctEmployeeIds(salaryAcctEmployeeIds, tenantKey);
// // 查询薪资核算人员所有合并计税的薪资核算记录所用的账套
// Set<Long> salarySobIds = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getSalarySobId);
// List<SalarySobPO> salarySobPOS = salarySobService.listByIds(salarySobIds, tenantKey);
// // 查询薪资项目所引用的薪资项目
// List<SalarySobItemPO> salarySobItemPOS = salarySobItemService.listBySalarySobIds(salarySobIds, tenantKey);
// // 查询薪资项目
// Set<Long> salaryItemIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getSalaryItemId);
// List<SalaryItemPO> salaryItemPOS = salaryItemService.listByIds(salaryItemIds, tenantKey);
// // 转换成合并计税详情dto
// return SalaryAcctResultBO.convert2ConsolidatedTaxDetailDTO(simpleEmployee, taxAgentPO, salarySobEmpFieldPOS, salaryItemPOS,
// salaryAcctEmployeePOS, salarySobPOS, salaryAcctRecordPOS, salaryAcctResultPOS);
// }
//
// @Override
// public void save(SalaryAcctResultSaveParam saveParam, Long employeeId, String tenantKey) {
// // 查询薪资核算人员
// SalaryAcctEmployeePO salaryAcctEmployeePO = salaryAcctEmployeeService.getById(saveParam.getSalaryAcctEmpId(), tenantKey);
// if (Objects.isNull(salaryAcctEmployeePO)) {
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98831, "薪资核算人员不存在或已被删除"));
// }
// // 保存参数转换成薪资核算结果po
// List<SalaryAcctResultPO> salaryAcctResultPOS = SalaryAcctResultBO.convert2PO(saveParam, salaryAcctEmployeePO, employeeId, tenantKey);
// // 删除原来的薪资核算结果
// deleteBySalaryAcctEmployeeIds(Collections.singleton(saveParam.getSalaryAcctEmpId()), tenantKey);
// // 保存薪资核算结果
// if (CollectionUtils.isNotEmpty(salaryAcctResultPOS)) {
// salaryAcctResultMapper.batchInsert(salaryAcctResultPOS);
// }
// // 查询操作日志的targetName
// String targetName = salaryAcctRecordService.getLogTargetNameById(salaryAcctEmployeePO.getSalaryAcctRecordId(), tenantKey);
// // 查询人员信息
// SimpleEmployee simpleEmployee = hrmCommonEmployeeService.getEmployeeById(salaryAcctEmployeePO.getEmployeeId(), tenantKey);
// // 查询个税扣缴义务人
// TaxAgentPO taxAgentPO = taxAgentService.getById(salaryAcctEmployeePO.getTaxAgentId(), tenantKey);
// // 记录日志
// String operateDesc = simpleEmployee.getUsername() + "(" + Optional.ofNullable(taxAgentPO).map(TaxAgentPO::getName).orElse(StringUtils.EMPTY) + ")";
// LoggerContext<SalaryCheckResultPO> loggerContext = new LoggerContext<>();
// loggerContext.setTargetId(String.valueOf(salaryAcctEmployeePO.getSalaryAcctRecordId()));
// loggerContext.setTargetName(targetName);
// loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue());
// loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(95783, "编辑薪资核算结果") + ": " + operateDesc);
// loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(95783, "编辑薪资核算结果") + ": " + operateDesc);
// loggerContext.setNewValueList(Lists.newArrayList(salaryAcctResultPOS));
// salaryAcctRecordLoggerTemplate.write(loggerContext);
// }
//
// @Override
// public void batchSave(Collection<SalaryAcctResultPO> salaryAcctResultPOS) {
// if (CollectionUtils.isNotEmpty(salaryAcctResultPOS)) {
// salaryAcctResultMapper.batchInsert(salaryAcctResultPOS);
// }
// }
//
// @Override
// public void deleteBySalaryAcctEmployeeIds(Collection<Long> salaryAcctEmployeeIds, String tenantKey) {
// salaryAcctResultMapper.deleteBySalaryAcctEmpIds(salaryAcctEmployeeIds, tenantKey);
// }
//
// @Override
// public void deleteByAcctEmployeeIdsAndSalaryItemIds(Collection<Long> salaryAcctEmployeeIds, Collection<Long> salaryItemIds, String tenantKey) {
// salaryAcctResultMapper.deleteByAcctEmpIdsAndSalaryItemIds(salaryAcctEmployeeIds, salaryItemIds, tenantKey);
// }
//
// @Override
// public void deleteBySalaryAcctRecordIds(Collection<Long> salaryAcctRecordIds, String tenantKey) {
// salaryAcctResultMapper.deleteBySalaryAcctRecordIds(salaryAcctRecordIds, tenantKey);
// }
//
// @Override
// public void calculate(SalaryAcctCalculateParam calculateParam, SimpleEmployee simpleEmployee, String tenantKey) {
// try {
// // 数据库字段加密用
// DSTenantKeyThreadVar.tenantKey.set(tenantKey);
// // 1查询薪资核算记录
// SalaryAcctRecordPO salaryAcctRecordPO = salaryAcctRecordService.getById(calculateParam.getSalaryAcctRecordId(), tenantKey);
// if (Objects.isNull(salaryAcctRecordPO)) {
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除"));
// }
// // 1.1如果薪资核算记录已经归档了就不能继续核算
// if (!Objects.equals(salaryAcctRecordPO.getStatus(), SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue())) {
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(99148, "当前薪资核算记录已归档,请重新打开后再进行核算"));
// }
// // 2查询薪资核算记录的薪资周期考勤周期等
// SalarySobCycleDTO salarySobCycleDTO = salaryAcctRecordService.getSalarySobCycleById(calculateParam.getSalaryAcctRecordId(), tenantKey);
// // 3查询薪资核算记录所用薪资账套的薪资项目副本
// List<SalarySobItemPO> salarySobItemPOS = salarySobItemService.listBySalarySobId(salaryAcctRecordPO.getSalarySobId(), tenantKey);
// if (CollectionUtils.isEmpty(salarySobItemPOS)) {
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(99151, "当前所用的薪资账套未选择任何薪资项目,无法核算"));
// }
// // 4查询当前租户的所有薪资项目
// List<SalaryItemPO> salaryItemPOS = salaryItemService.listAll(tenantKey);
// // 5查询薪资核算记录所用薪资账套的调薪计薪规则
// List<SalarySobAdjustRulePO> salarySobAdjustRulePOS = salarySobAdjustRuleService.listBySalarySobId(salaryAcctRecordPO.getSalarySobId(), tenantKey);
// // 6查询社保福利的所有字段
// Map<String, String> welfareColumns = siAccountService.welfareColumns(tenantKey);
// // 7查询考勤引用的所有字段
// List<AttendQuoteFieldListDTO> attendQuoteFieldListDTOS = attendQuoteFieldService.listAll(tenantKey);
// // 8查询公式详情
// Set<Long> formulaIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getFormulaId);
// formulaIds.addAll(SalaryEntityUtil.properties(salaryItemPOS, SalaryItemPO::getFormulaId));
// List<ExpressFormula> expressFormulas = salaryFormulaService.listExpressFormula(formulaIds, tenantKey);
// // 9计算薪资项目的运算优先级
// List<List<Long>> salarySobItemsWithPriority = SalaryAcctCalculatePriorityBO.calculatePriority(salarySobItemPOS, salaryItemPOS, expressFormulas);
// // 10根据id查询其他合并计税的薪资核算记录
// List<SalaryAcctRecordPO> otherSalaryAcctRecordPOS = salaryAcctRecordService.listById4OtherConsolidatedTax(salaryAcctRecordPO.getId(), tenantKey);
// // 11查询本次核算人员
// List<SalaryAcctEmployeePO> salaryAcctEmployeePOS;
// if (CollectionUtils.isEmpty(calculateParam.getIds())) {
// salaryAcctEmployeePOS = salaryAcctEmployeeService.listBySalaryAcctRecordId(salaryAcctRecordPO.getId(), tenantKey);
// } else {
// salaryAcctEmployeePOS = salaryAcctEmployeeService.listByIds(calculateParam.getIds(), tenantKey);
// }
// if (CollectionUtils.isEmpty(salaryAcctEmployeePOS)) {
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(103378, "薪资核算人员不能为空"));
// }
// // 11.1初始化进度
// SalaryAcctProgressDTO initProgress = new SalaryAcctProgressDTO()
// .setTitle(SalaryI18nUtil.getI18nLabel(97515, "核算中"))
// .setTitleLabelId(97515L)
// .setTotalQuantity(salaryAcctEmployeePOS.size() * 2 + 1)
// .setCalculatedQuantity(0)
// .setProgress(BigDecimal.ZERO)
// .setStatus(true)
// .setMessage(StringUtils.EMPTY);
// salaryAcctProgressService.initProgress("" + calculateParam.getSalaryAcctRecordId(), initProgress, simpleEmployee.getEmployeeId(), tenantKey);
// // 12对薪资核算人员进行拆分
// List<List<SalaryAcctEmployeePO>> partition = Lists.partition(salaryAcctEmployeePOS, 100);
// // 12.1监控子线程的任务执行
// CountDownLatch childMonitor = new CountDownLatch(partition.size());
// // 12.2记录子线程的执行结果
// BlockingDeque<SalaryAcctCalculateBO.Result> calculateResults = new LinkedBlockingDeque<>(partition.size());
// // 12.3生成本次运算的key
// String calculateKey = UUID.randomUUID().toString();
// // 12.4多线程运算运算结果存放在临时表中
// for (List<SalaryAcctEmployeePO> acctEmployeePOS : partition) {
// SalaryAcctCalculateBO salaryAcctCalculateBO = new SalaryAcctCalculateBO()
// .setSalaryAcctRecordPO(salaryAcctRecordPO)
// .setSalarySobCycleDTO(salarySobCycleDTO)
// .setOtherSalaryAcctRecordPOS(otherSalaryAcctRecordPOS)
// .setSalarySobItemPOS(salarySobItemPOS)
// .setSalaryItemIdWithPriorityList(salarySobItemsWithPriority)
// .setExpressFormulas(expressFormulas)
// .setSalaryItemPOS(salaryItemPOS)
// .setSalarySobAdjustRulePOS(salarySobAdjustRulePOS)
// .setWelfareColumns(MapUtils.emptyIfNull(welfareColumns))
// .setAttendQuoteFieldListDTOS(attendQuoteFieldListDTOS)
// .setSalaryAcctEmployeePOS(acctEmployeePOS)
// .setChildMonitor(childMonitor)
// .setResults(calculateResults)
// .setCalculateKey(calculateKey);
// LocalRunnable localRunnable = new LocalRunnable() {
// @Override
// public void execute() {
// salaryAcctCalculateService.calculate(salaryAcctCalculateBO, simpleEmployee, tenantKey);
// }
// };
// ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.OTHER, "salaryAcctCalculate", localRunnable);
// }
// // 13等待所有子线程执行完毕
// childMonitor.await();
// // 14判断子线程执行结果
// boolean allSuccess = calculateResults.stream().allMatch(SalaryAcctCalculateBO.Result::isStatus);
// if (!allSuccess) {
// // 薪资核算实现的线程的错误信息
// String errorMsg = calculateResults.stream()
// .filter(result -> !result.isStatus())
// .map(SalaryAcctCalculateBO.Result::getErrMsg)
// .collect(Collectors.joining("|"));
// salaryAcctProgressService.fail("" + calculateParam.getSalaryAcctRecordId(), errorMsg);
// // 删除薪资核算临时存储表中的数据
// salaryAcctResultTempService.deleteByCalculateKey(calculateKey, tenantKey);
// return;
// }
// // 15处理核算结果临时表数据
// handleSalaryAcctResultTemp(calculateParam, calculateKey, tenantKey);
// // 16开始运行校验规则
// SalaryAcctCheckParam salaryAcctCheckParam = new SalaryAcctCheckParam()
// .setSalaryAcctRecordId(calculateParam.getSalaryAcctRecordId())
// .setIds(calculateParam.getIds());
// salaryCheckResultService.check(salaryAcctCheckParam, true, simpleEmployee, tenantKey);
// // 记录日志
// // 查询操作日志的targetName
// String targetName = salaryAcctRecordService.getLogTargetNameById(calculateParam.getSalaryAcctRecordId(), tenantKey);
// LoggerContext<SalaryCheckResultPO> loggerContext = new LoggerContext<>();
// loggerContext.setTargetId(String.valueOf(calculateParam.getSalaryAcctRecordId()));
// loggerContext.setTargetName(targetName);
// loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue());
// loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(95783, "薪资核算"));
// loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(95783, "薪资核算"));
// salaryAcctRecordLoggerTemplate.write(loggerContext);
// } catch (Exception e) {
// log.info("薪资核算出错:{}", e.getMessage(), e);
// salaryAcctProgressService.fail("" + calculateParam.getSalaryAcctRecordId(), SalaryI18nUtil.getI18nLabel(99642, "薪资核算出错") + ": " + e.getMessage());
// } finally {
// // 数据库字段加密用
// DSTenantKeyThreadVar.tenantKey.remove();
// }
// }
//
// /**
// * 处理薪资核算临时存储表中的数据
// *
// * @param calculateParam
// * @param calculateKey
// */
// private void handleSalaryAcctResultTemp(SalaryAcctCalculateParam calculateParam, String calculateKey, String tenantKey) {
// TransactionStatus status = dataSourceTransactionManager.getTransaction(new DefaultTransactionDefinition());
// try {
// // 查询薪资核算结果的临时存储
// List<SalaryAcctResultTempPO> salaryAcctResultTempPOS = salaryAcctResultTempService.listByCalculateKey(calculateKey, tenantKey);
// // 删除原来的薪资核算结果
// if (CollectionUtils.isNotEmpty(calculateParam.getIds())) {
// salaryAcctResultMapper.deleteBySalaryAcctEmpIds(calculateParam.getIds(), tenantKey);
// } else {
// salaryAcctResultMapper.deleteBySalaryAcctRecordIds(Collections.singleton(calculateParam.getSalaryAcctRecordId()), tenantKey);
// }
// // 保存薪资的薪资核算结果
// List<SalaryAcctResultPO> salaryAcctResultPOS = SalaryAcctResultBO.convert2ResultPO(salaryAcctResultTempPOS);
// batchSave(salaryAcctResultPOS);
// // 删除薪资核算临时存储表中的数据
// salaryAcctResultTempService.deleteByCalculateKey(calculateKey, tenantKey);
// // 提交事务
// dataSourceTransactionManager.commit(status);
// } catch (Exception e) {
// dataSourceTransactionManager.rollback(status);
// throw e;
// }
// }
//}

View File

@ -0,0 +1,79 @@
package com.engine.salary.service.impl;
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;
import com.engine.salary.entity.salarysob.bo.SalarySobRangeBO;
import com.engine.salary.entity.salarysob.param.SalarySobRangeEmpQueryParam;
import com.engine.salary.entity.salarysob.po.SalarySobRangePO;
import com.engine.salary.service.SalaryEmployeeService;
import com.engine.salary.service.SalarySobRangeService;
import com.engine.salary.util.SalaryEntityUtil;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.math.NumberUtils;
import weaver.hrm.User;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
* 人员信息
* <p>Copyright: Copyright (c) 2022</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
public class SalaryEmployeeServiceImpl extends Service implements SalaryEmployeeService {
private EmployBiz employBiz = new EmployBiz();
private SalarySobRangeService getSalarySobRangeService(User user) {
return (SalarySobRangeService) ServiceUtil.getService(SalarySobRangeServiceImpl.class, user);
}
@Override
public List<DataCollectionEmployee> listAll() {
return employBiz.listEmployee();
}
@Override
public List<DataCollectionEmployee> listBySalarySobId(Long salarySobId) {
// 查询薪资账套的人员范围
List<SalarySobRangePO> includeSalarySobRangePOS = getSalarySobRangeService(user).listBySalarySobIdAndIncludeType(salarySobId, NumberUtils.INTEGER_ONE);
if (CollectionUtils.isEmpty(includeSalarySobRangePOS)) {
return Collections.emptyList();
}
// 将薪资账套的人员范围转换成人员查询参数
List<SalarySobRangeEmpQueryParam> includeQueryParams = SalarySobRangeBO.convert2EmployeeQueryParam(includeSalarySobRangePOS);
// 根据上一步的查询参数查询人员
List<DataCollectionEmployee> includeSalaryEmployees = employBiz.listByParams(includeQueryParams);
if (CollectionUtils.isEmpty(includeSalaryEmployees)) {
return Collections.emptyList();
}
// 查询薪资账套的人员范围从范围中排除
List<SalarySobRangePO> excludeSalarySobRangePOS = getSalarySobRangeService(user).listBySalarySobIdAndIncludeType(salarySobId, NumberUtils.INTEGER_ZERO);
if (CollectionUtils.isNotEmpty(excludeSalarySobRangePOS)) {
// 将薪资账套的人员范围转换成人员查询参数
List<SalarySobRangeEmpQueryParam> excludeQueryParams = SalarySobRangeBO.convert2EmployeeQueryParam(excludeSalarySobRangePOS);
// 根据上一步的查询参数查询人员
List<DataCollectionEmployee> excludeSalaryEmployees = employBiz.listByParams(excludeQueryParams);
// 需要排除的人员范围
Set<Long> excludeEmployeeIds = SalaryEntityUtil.properties(excludeSalaryEmployees, DataCollectionEmployee::getEmployeeId);
// 过滤人员
includeSalaryEmployees = includeSalaryEmployees.stream()
.filter(salaryEmployee -> !excludeEmployeeIds.contains(salaryEmployee.getEmployeeId()))
.collect(Collectors.toList());
}
return includeSalaryEmployees;
}
@Override
public List<DataCollectionEmployee> listByIds(List<Long> ids) {
return employBiz.getEmployeeByIdsAll(ids);
}
}

View File

@ -18,6 +18,10 @@ public class PageInfo<T> extends com.github.pagehelper.PageInfo<T> {
public PageInfo() {
}
public PageInfo(Class<T> clazz) {
this.clazz = clazz;
}
public PageInfo(List<T> list) {
super(list);
}

View File

@ -3,8 +3,12 @@ package com.engine.salary.web;
import com.engine.common.util.ServiceUtil;
import com.engine.salary.entity.salaryacct.dto.SalaryAcctRecordFormDTO;
import com.engine.salary.entity.salaryacct.param.SalaryAcctRecordQueryParam;
import com.engine.salary.entity.salaryacct.param.SalaryAcctRecordReAccountParam;
import com.engine.salary.entity.salaryacct.param.SalaryAcctRecordSaveParam;
import com.engine.salary.entity.salarysob.dto.SalarySobCycleDTO;
import com.engine.salary.util.ResponseResult;
import com.engine.salary.util.page.PageInfo;
import com.engine.salary.wrapper.SalaryAcctEmployeeWrapper;
import com.engine.salary.wrapper.SalaryAcctRecordWrapper;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import weaver.hrm.HrmUserVarify;
@ -15,6 +19,7 @@ import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.*;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import java.util.Collection;
/**
* 薪资核算
@ -31,7 +36,9 @@ public class SalaryAcctController {
private SalaryAcctRecordWrapper getSalaryAcctRecordWrapper(User user) {
return (SalaryAcctRecordWrapper) ServiceUtil.getService(SalaryAcctRecordWrapper.class, user);
}
// private SalaryAcctEmployeeWrapper salaryAcctEmployeeWrapper;
private SalaryAcctEmployeeWrapper getSalaryAcctEmployeeWrapper(User user) {
return (SalaryAcctEmployeeWrapper) ServiceUtil.getService(SalaryAcctEmployeeWrapper.class, user);
}
// private SalaryAcctResultWrapper salaryAcctResultWrapper;
// private SalaryAcctCheckResultWrapper salaryAcctCheckResultWrapper;
// private SalaryComparisonResultWrapper salaryComparisonResultWrapper;
@ -59,55 +66,61 @@ public class SalaryAcctController {
return new ResponseResult<Long, SalaryAcctRecordFormDTO>().run(getSalaryAcctRecordWrapper(user)::getForm, id);
}
//
// @GetMapping("/getSalarySobCycle")
// @ApiOperation(("获取薪资核算的薪资周期、考勤周期等"))
// @WeaPermission
// public WeaResult<SalarySobCycleDTO> getSalarySobCycle(@RequestParam(value = "salaryAcctRecordId") Long salaryAcctRecordId) {
// SalarySobCycleDTO salarySobCycle = salaryAcctRecordWrapper.getSalarySobCycleById(salaryAcctRecordId, TenantContext.getCurrentTenantKey());
// return WeaResult.success(salarySobCycle);
// }
//
// @PostMapping("/basic/save")
// @ApiOperation("保存薪资核算的基本信息")
// @WeaPermission
// public WeaResult<Long> saveBasic(@RequestBody @Validated SalaryAcctRecordSaveParam saveParam) {
// Long salaryAcctRecordId = salaryAcctRecordWrapper.save(saveParam, UserContext.getCurrentEmployeeId(), TenantContext.getCurrentTenantKey());
// return WeaResult.success(salaryAcctRecordId);
// }
//
// @PostMapping("/delete")
// @ApiOperation("删除薪资核算记录")
// @WeaPermission
// public WeaResult<Object> deleteSalaryAcctRecord(@RequestBody Collection<Long> ids) {
// salaryAcctRecordWrapper.delete(ids, TenantContext.getCurrentTenantKey());
// return WeaResult.success(null);
// }
//
// @PostMapping("/file")
// @ApiOperation("归档薪资核算记录")
// @WeaPermission
// public WeaResult<Object> fileSalaryAcctRecord(@RequestParam(value = "id") Long id) {
// salaryAcctRecordWrapper.file(id, UserContext.getCurrentEmployeeId(), TenantContext.getCurrentTenantKey());
// return WeaResult.success(null);
// }
//
// @PostMapping("/reAccounting")
// @ApiOperation("重新核算")
// @WeaPermission
// public WeaResult<Object> reAccounting(@RequestBody @Validated SalaryAcctRecordReAccountParam param) {
// salaryAcctRecordWrapper.reCalculate(param.getSalaryAcctRecordId(), UserContext.getCurrentEmployeeId(), TenantContext.getCurrentTenantKey());
// return WeaResult.success(null);
// }
//
// @GetMapping("/hasConsolidatedTax")
// @ApiOperation("判断是否存在合并计税")
// @WeaPermission
// public WeaResult<Integer> hasConsolidatedTax(@RequestParam(value = "id") Long id) {
// Integer result = salaryAcctRecordWrapper.hasConsolidatedTax(id, TenantContext.getCurrentTenantKey());
// return WeaResult.success(result);
// }
//
//获取薪资核算的薪资周期考勤周期等
@GET
@Path("/getSalarySobCycle")
@Produces(MediaType.APPLICATION_JSON)
public String getSalarySobCycle(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "salaryAcctRecordId") Long salaryAcctRecordId) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<Long, SalarySobCycleDTO>().run(getSalaryAcctRecordWrapper(user)::getSalarySobCycleById, salaryAcctRecordId);
}
//保存薪资核算的基本信息
@POST
@Path("/basic/save")
@Produces(MediaType.APPLICATION_JSON)
public String save(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryAcctRecordSaveParam param) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<SalaryAcctRecordSaveParam, Long>().run(getSalaryAcctRecordWrapper(user)::save, param);
}
//删除薪资核算记录
@POST
@Path("/delete")
@Produces(MediaType.APPLICATION_JSON)
public String deleteSalaryAcctRecord(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Collection<Long> ids) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<Collection<Long>, Long>().run(getSalaryAcctRecordWrapper(user)::delete, ids);
}
//归档薪资核算记录
@GET
@Path("/file")
@Produces(MediaType.APPLICATION_JSON)
public String fileSalaryAcctRecord(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "id") Long id) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<Long, Long>().run(getSalaryAcctRecordWrapper(user)::file, id);
}
//重新核算
@POST
@Path("/reAccounting")
@Produces(MediaType.APPLICATION_JSON)
public String reAccounting(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryAcctRecordReAccountParam param) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<Long, Long>().run(getSalaryAcctRecordWrapper(user)::reCalculate, param.getSalaryAcctRecordId());
}
//判断是否存在合并计税
@GET
@Path("/hasConsolidatedTax")
@Produces(MediaType.APPLICATION_JSON)
public String hasConsolidatedTax(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "id") Long id) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<Long, Integer>().run(getSalaryAcctRecordWrapper(user)::hasConsolidatedTax, id);
}
// /**********************************薪资核算记录相关 end*********************************/
//
//

View File

@ -0,0 +1,175 @@
package com.engine.salary.wrapper;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.salary.biz.TaxAgentBiz;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.salaryacct.bo.SalaryAcctEmployeeBO;
import com.engine.salary.entity.salaryacct.dto.SalaryAccEmployeeListDTO;
import com.engine.salary.entity.salaryacct.param.SalaryAcctEmployeeAddParam;
import com.engine.salary.entity.salaryacct.param.SalaryAcctEmployeeDeleteParam;
import com.engine.salary.entity.salaryacct.param.SalaryAcctEmployeeQueryParam;
import com.engine.salary.entity.salaryacct.param.SalaryAcctEmployeeSaveParam;
import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO;
import com.engine.salary.entity.taxrate.TaxAgent;
import com.engine.salary.exception.SalaryRunTimeException;
import com.engine.salary.service.SalaryAcctEmployeeService;
import com.engine.salary.service.SalaryEmployeeService;
import com.engine.salary.service.impl.SalaryAcctEmployeeServiceImpl;
import com.engine.salary.service.impl.SalaryEmployeeServiceImpl;
import com.engine.salary.util.SalaryI18nUtil;
import com.engine.salary.util.page.PageInfo;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.math.NumberUtils;
import weaver.hrm.User;
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 SalaryAcctEmployeeWrapper extends Service {
private SalaryAcctEmployeeService getSalaryAcctEmployeeService(User user) {
return (SalaryAcctEmployeeService) ServiceUtil.getService(SalaryAcctEmployeeServiceImpl.class, user);
}
private SalaryEmployeeService getSalaryEmployeeService(User user) {
return (SalaryEmployeeService) ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user);
}
private TaxAgentBiz taxAgentService = new TaxAgentBiz();
/**
* 薪资核算人员列表
*
* @param queryParam 列表查询参数
* @return
*/
public PageInfo<SalaryAccEmployeeListDTO> listPage(SalaryAcctEmployeeQueryParam queryParam) {
// 查询薪资核算人员人员
PageInfo<SalaryAcctEmployeePO> page = getSalaryAcctEmployeeService(user).listPageByParam(queryParam);
// 转换成列表dto
PageInfo<SalaryAccEmployeeListDTO> dtoPage = convert2ListDTO(page);
return dtoPage;
}
/**
* 同比减少的薪资核算人员列表
*
* @param queryParam 列表查询参数
* @return
*/
public PageInfo<SalaryAccEmployeeListDTO> listPage4Reduce(SalaryAcctEmployeeQueryParam queryParam) {
// 查询同比减少的薪资核算人员分页
PageInfo<SalaryAcctEmployeePO> page = getSalaryAcctEmployeeService(user).listPageByParam4Reduce(queryParam);
// 转换成列表dto
PageInfo<SalaryAccEmployeeListDTO> dtoPage = convert2ListDTO(page);
return dtoPage;
}
/**
* 转换成列表dto
*
* @param page 薪资核算人员po
* @return
*/
private PageInfo<SalaryAccEmployeeListDTO> convert2ListDTO(PageInfo<SalaryAcctEmployeePO> page) {
List<SalaryAcctEmployeePO> list = page.getList();
if (CollectionUtils.isEmpty(list)) {
return new PageInfo<>(SalaryAccEmployeeListDTO.class);
}
// 查询人员信息
List<Long> employeeIds = list.stream().map(SalaryAcctEmployeePO::getEmployeeId).collect(Collectors.toList());
List<DataCollectionEmployee> simpleEmployees = getSalaryEmployeeService(user).listByIds(employeeIds);
// 查询个税扣缴义务人
List<Long> taxAgentIds = list.stream().map(SalaryAcctEmployeePO::getTaxAgentId).collect(Collectors.toList());
List<TaxAgent> taxAgentPOS = taxAgentService.listByIds(taxAgentIds);
// 转换成列表dto
List<SalaryAccEmployeeListDTO> salaryAccEmployeeListDTOS = SalaryAcctEmployeeBO.convert2EmployeeListDTO(list, taxAgentPOS, simpleEmployees);
PageInfo<SalaryAccEmployeeListDTO> pageInfo = new PageInfo<SalaryAccEmployeeListDTO>(salaryAccEmployeeListDTOS, SalaryAccEmployeeListDTO.class);
return pageInfo;
}
// /**
// * 获取高级搜索表单
// *
// * @return
// */
// public WeaSearchCondition getCondition(String tenantKey) {
// SalaryAcctEmpSearchConditionDTO searchConditionDTO = new SalaryAcctEmpSearchConditionDTO();
// WeaSearchCondition searchCondition = SalaryFormatUtil.<SalaryAcctEmpSearchConditionDTO>getInstance().buildCondition(SalaryAcctEmpSearchConditionDTO.class,
// searchConditionDTO, "SalaryAcctEmpCondition");
// // 查询个税扣缴义务人
// List<TaxAgentPO> taxAgentPOS = taxAgentService.listAll(tenantKey);
// List<WeaSearchConditionOption> weaSearchConditionOptions = taxAgentPOS.stream()
// .map(taxAgentPO -> new WeaSearchConditionOption(String.valueOf(taxAgentPO.getId()), taxAgentPO.getName()))
// .collect(Collectors.toList());
// // 给查询条件中的个税扣缴义务人填充下拉项
// searchCondition.getItems().forEach((k, v) -> {
// if (StringUtils.equals("taxAgentId", k)) {
// v.setOptions(weaSearchConditionOptions);
// }
// });
// // 其他条件不要
// searchCondition.getGroups().remove(1);
// return searchCondition;
// }
/**
* 添加薪资核算人员
*
* @param saveParam 保存参数
*/
public void save(SalaryAcctEmployeeSaveParam saveParam) {
getSalaryAcctEmployeeService(user).save(saveParam);
}
/**
* 从环比上月减少添加薪资核算人员
*
* @param addParam
*/
public void addFromReduce(SalaryAcctEmployeeAddParam addParam) {
getSalaryAcctEmployeeService(user).addFromReduce(addParam);
}
/**
* 删除薪资核算人员
*
* @param deleteParam 删除参数
*/
public void delete(SalaryAcctEmployeeDeleteParam deleteParam) {
getSalaryAcctEmployeeService(user).deleteByParam(deleteParam);
}
/**
* 检查个税扣缴义务人
*
* @param salaryAcctRecordId 薪资核算记录的id
*/
public void checkTaxAgent(Long salaryAcctRecordId) {
List<SalaryAcctEmployeePO> salaryAcctEmployeePOS = getSalaryAcctEmployeeService(user)
.listBySalaryAcctRecordIdAndTaxAgentId(salaryAcctRecordId, NumberUtils.LONG_ZERO);
if (CollectionUtils.isNotEmpty(salaryAcctEmployeePOS)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98871, "有{0}个人无个税扣缴义务人,请先去薪资档案里维护员工档案,再点击当前页面的刷新按钮")
.replace("{0}", "" + salaryAcctEmployeePOS.size()));
}
}
/**
* 刷新个税扣缴义务人
*
* @param salaryAcctRecordId 薪资核算记录的id
*/
public void refreshTaxAgent(Long salaryAcctRecordId) {
getSalaryAcctEmployeeService(user).refresh(salaryAcctRecordId);
}
}

View File

@ -163,7 +163,7 @@ public class SalaryAcctRecordWrapper extends Service {
*
* @param id 薪资核算记录的id
*/
public void file(Long id, Long employeeId) {
public void file(Long id) {
getSalaryAcctRecordService(user).file(id);
}