diff --git a/src/com/engine/salary/biz/EmployBiz.java b/src/com/engine/salary/biz/EmployBiz.java index 59b3c0581..d34379412 100644 --- a/src/com/engine/salary/biz/EmployBiz.java +++ b/src/com/engine/salary/biz/EmployBiz.java @@ -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 listByParams(List includeQueryParams) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + EmployMapper mapper = sqlSession.getMapper(EmployMapper.class); + return mapper.listByParams(includeQueryParams); + } finally { + sqlSession.close(); + } + } } diff --git a/src/com/engine/salary/biz/TaxAgentBiz.java b/src/com/engine/salary/biz/TaxAgentBiz.java index e4d089c78..70f07eed6 100644 --- a/src/com/engine/salary/biz/TaxAgentBiz.java +++ b/src/com/engine/salary/biz/TaxAgentBiz.java @@ -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 listByIds(List taxAgentIds) { + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + TaxAgentMapper taxAgentMapper = sqlSession.getMapper(TaxAgentMapper.class); + return taxAgentMapper.listBySome(TaxAgentQueryParam.builder().ids(taxAgentIds).build()); + } finally { + sqlSession.close(); + } + } } diff --git a/src/com/engine/salary/biz/TaxRateBiz.java b/src/com/engine/salary/biz/TaxRateBiz.java index d8d567e5b..0c7a75b60 100644 --- a/src/com/engine/salary/biz/TaxRateBiz.java +++ b/src/com/engine/salary/biz/TaxRateBiz.java @@ -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 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 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 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()); diff --git a/src/com/engine/salary/entity/datacollection/DataCollectionEmployee.java b/src/com/engine/salary/entity/datacollection/DataCollectionEmployee.java index d352b3ed8..58d0b28ed 100644 --- a/src/com/engine/salary/entity/datacollection/DataCollectionEmployee.java +++ b/src/com/engine/salary/entity/datacollection/DataCollectionEmployee.java @@ -6,6 +6,7 @@ import lombok.Data; import lombok.NoArgsConstructor; import java.util.Date; + /** * 员工基本信息 *

Copyright: Copyright (c) 2022

@@ -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; + } diff --git a/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctEmployeeBO.java b/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctEmployeeBO.java index 62d6e9e3f..561f6bb81 100644 --- a/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctEmployeeBO.java +++ b/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctEmployeeBO.java @@ -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 convert2EmployeeListDTO(List salaryAccountingEmployees, -// List taxAgents, -// List simpleEmployees) { -// if (CollectionUtils.isEmpty(salaryAccountingEmployees)) { -// return Collections.emptyList(); -// } -// Map taxAgentNameMap = SalaryEntityUtil.convert2Map(taxAgents, TaxAgentPO::getId, TaxAgentPO::getName); -// Map 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 convert2EmployeePO(Collection employeeIds, -// SalaryAcctRecordPO salaryAcctRecord, -// List salaryArchiveTaxAgentData, -// Long employeeId, String tenantKey) { -// if (CollectionUtils.isEmpty(employeeIds)) { -// return Collections.emptyList(); -// } -// List resultList = Lists.newArrayList(); -// Map>> empIdKeyTaxAgentMap = SalaryEntityUtil.group2Map(salaryArchiveTaxAgentData, SalaryArchiveDataDTO::getEmployeeId, SalaryArchiveDataDTO::getTaxAgents); -// LocalDateTime now = LocalDateTime.now(); -// for (Long id : employeeIds) { -// Set taxAgentIds = Sets.newHashSet(); -// Set> taxAgentSet = empIdKeyTaxAgentMap.getOrDefault(id, Collections.emptySet()); -// for (List 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; + +/** + * 薪资核算人员 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public class SalaryAcctEmployeeBO { + + /** + * 将薪资核算人员po转换成薪资核算人员列表dto + * + * @param salaryAccountingEmployees + * @param taxAgents + * @param simpleEmployees + * @return + */ + public static List convert2EmployeeListDTO(List salaryAccountingEmployees, + List taxAgents, + List simpleEmployees) { + if (CollectionUtils.isEmpty(salaryAccountingEmployees)) { + return Collections.emptyList(); + } + Map taxAgentNameMap = SalaryEntityUtil.convert2Map(taxAgents, TaxAgent::getId, TaxAgent::getName); + Map 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 convert2EmployeePO(Collection employeeIds, + SalaryAcctRecordPO salaryAcctRecord, + List salaryArchiveTaxAgentData, + Long employeeId) { + if (CollectionUtils.isEmpty(employeeIds)) { + return Collections.emptyList(); + } + List resultList = Lists.newArrayList(); + Map>> empIdKeyTaxAgentMap = SalaryEntityUtil.group2Map(salaryArchiveTaxAgentData, SalaryArchiveDataDTO::getEmployeeId, SalaryArchiveDataDTO::getTaxAgents); + Date now = new Date(); + for (Long id : employeeIds) { + Set taxAgentIds = Sets.newHashSet(); + Set> taxAgentSet = empIdKeyTaxAgentMap.getOrDefault(id, Collections.emptySet()); + for (List 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; + } +} diff --git a/src/com/engine/salary/entity/salaryacct/dto/SalaryAccEmployeeListDTO.java b/src/com/engine/salary/entity/salaryacct/dto/SalaryAccEmployeeListDTO.java index 15d41ea9f..5dca30019 100644 --- a/src/com/engine/salary/entity/salaryacct/dto/SalaryAccEmployeeListDTO.java +++ b/src/com/engine/salary/entity/salaryacct/dto/SalaryAccEmployeeListDTO.java @@ -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; + +/** + * 薪资核算人员列表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @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; +} diff --git a/src/com/engine/salary/entity/salaryacct/param/SalaryAcctRecordReAccountParam.java b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctRecordReAccountParam.java index c21faabaa..a73565f02 100644 --- a/src/com/engine/salary/entity/salaryacct/param/SalaryAcctRecordReAccountParam.java +++ b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctRecordReAccountParam.java @@ -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; + +/** + * 重新核算 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +public class SalaryAcctRecordReAccountParam { + + @DataCheck(require = true, message = "参数错误,薪资核算记录ID不能为空") + private Long salaryAcctRecordId; +} diff --git a/src/com/engine/salary/entity/salaryacct/po/SalaryAcctEmployeePO.java b/src/com/engine/salary/entity/salaryacct/po/SalaryAcctEmployeePO.java index 1ae56ced2..85647ff0b 100644 --- a/src/com/engine/salary/entity/salaryacct/po/SalaryAcctEmployeePO.java +++ b/src/com/engine/salary/entity/salaryacct/po/SalaryAcctEmployeePO.java @@ -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 - */ + * 薪资核算人员 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @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 ids; + + private Collection salaryAcctRecordIds; + + private Collection employeeIds; } diff --git a/src/com/engine/salary/mapper/TaxAgentMapper.java b/src/com/engine/salary/mapper/TaxAgentMapper.java index 47027e3b8..03f3c0bdd 100644 --- a/src/com/engine/salary/mapper/TaxAgentMapper.java +++ b/src/com/engine/salary/mapper/TaxAgentMapper.java @@ -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 ids); - } \ No newline at end of file diff --git a/src/com/engine/salary/mapper/datacollection/EmployMapper.java b/src/com/engine/salary/mapper/datacollection/EmployMapper.java index f94c82ed6..3a09369b8 100644 --- a/src/com/engine/salary/mapper/datacollection/EmployMapper.java +++ b/src/com/engine/salary/mapper/datacollection/EmployMapper.java @@ -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 listPositionInfo(@Param("collection") List ids); List getAdminEmployeeByIds(@Param("collection") List list); + + /** + * 根据薪资账套的人员范围转换而成的查询参数查询人员 + * + * @param queryParams 薪资账套的人员范围转换而成的查询参数 + * @return + */ + List listByParams(@Param("params") Collection queryParams); } \ No newline at end of file diff --git a/src/com/engine/salary/mapper/datacollection/EmployMapper.xml b/src/com/engine/salary/mapper/datacollection/EmployMapper.xml index 967ea7f1b..63c283972 100644 --- a/src/com/engine/salary/mapper/datacollection/EmployMapper.xml +++ b/src/com/engine/salary/mapper/datacollection/EmployMapper.xml @@ -28,7 +28,10 @@ + + \ No newline at end of file diff --git a/src/com/engine/salary/mapper/salaryacct/SalaryAcctEmployeeMapper.java b/src/com/engine/salary/mapper/salaryacct/SalaryAcctEmployeeMapper.java new file mode 100644 index 000000000..c27b10ac8 --- /dev/null +++ b/src/com/engine/salary/mapper/salaryacct/SalaryAcctEmployeeMapper.java @@ -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; + +/** + * 薪资核算人员 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface SalaryAcctEmployeeMapper { + + /** + * 批量插入 + * + * @param salaryAccountingEmployees + */ + void batchInsert(@Param("collection") Collection salaryAccountingEmployees); + + /** + * 统计薪资核算记录的人数 + * + * @param salaryAcctRecordIds + * @return + */ + List countGroupBySalaryAcctRecordId(@Param("salaryAcctRecordIds") Collection salaryAcctRecordIds); + + /** + * 查询合并计税的人员(分页) + * + * @param otherSalaryAcctRecordIds 相同税款所属期内的其他工资薪金类型的薪资账套的薪资核算记录id + * @param param 人员查询参数 + * @return + */ + List listPage4ConsolidatedTax(@Param("otherSalaryAcctRecordIds") Collection otherSalaryAcctRecordIds, + @Param("param") SalaryAcctEmployeeQueryParam param); + + /** + * 查询合并计税的人员 + * + * @param otherSalaryAcctRecordIds 相同税款所属期内的其他工资薪金类型的薪资账套的薪资核算记录id + * @param param 人员查询参数 + * @return + */ + List list4ConsolidatedTax(@Param("otherSalaryAcctRecordIds") Collection otherSalaryAcctRecordIds, + @Param("param") SalaryAcctEmployeeQueryParam param); + + /** + * 分页查询薪资核算人员 + * + * @param param + * @return + */ + List listPage(@Param("param") SalaryAcctEmployeeQueryParam param); + + /** + * 查询薪资核算人员 + * + * @param param + * @return + */ + List list(@Param("param") SalaryAcctEmployeeQueryParam param); + + /** + * 分页查询薪资核算人员环比减少的人员 + * + * @param lastMonSalaryAcctRecordIds + * @param param + * @return + */ + List listPage4Reduce(@Param("lastMonSalaryAcctRecordIds") Collection lastMonSalaryAcctRecordIds, + @Param("param") SalaryAcctEmployeeQueryParam param); + + /** + * 查询薪资核算人员环比减少的人员 + * + * @param lastMonSalaryAcctRecordIds + * @param param + * @return + */ + List list4Reduce(@Param("lastMonSalaryAcctRecordIds") Collection lastMonSalaryAcctRecordIds, + @Param("param") SalaryAcctEmployeeQueryParam param); + + /** + * 根据主键id删除 + * + * @param ids + */ + void deleteByIds(@Param("ids") Collection ids); + + /** + * 根据薪资核算记录id删除 + * + * @param salaryAcctRecordIds + */ + void deleteBySalaryAcctRecordIds(@Param("salaryAcctRecordIds") Collection salaryAcctRecordIds); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + List listSome(SalaryAcctEmployeePO salaryAcctEmp); + + /** + * 根据主键查询 + * + * @param id 主键 + * @return 返回记录,没有返回null + */ + SalaryAcctEmployeePO getById(Long id); +} diff --git a/src/com/engine/salary/mapper/salaryacct/SalaryAcctEmployeeMapper.xml b/src/com/engine/salary/mapper/salaryacct/SalaryAcctEmployeeMapper.xml new file mode 100644 index 000000000..644bd344c --- /dev/null +++ b/src/com/engine/salary/mapper/salaryacct/SalaryAcctEmployeeMapper.xml @@ -0,0 +1,1175 @@ + + + + + + + + + + + + + + + + + + + + + + + + id + , salary_acct_record_id, salary_sob_id, employee_id, tax_agent_id, salary_month, + creator, create_time, update_time, delete_type, tenant_key + + + + emp1 + . + id + , emp1.salary_acct_record_id, emp1.salary_sob_id, emp1.employee_id, emp1.tax_agent_id, emp1.salary_month, + emp1.creator, emp1.create_time, emp1.update_time, emp1.delete_type, emp1.tenant_key + + + + INSERT INTO hrsa_salary_acct_emp( + salary_acct_record_id, salary_sob_id, employee_id, tax_agent_id, salary_month, + creator, create_time, update_time, delete_type, tenant_key) + VALUES + + ( + #{emp.salaryAcctRecordId}, + #{emp.salarySobId}, + #{emp.employeeId}, + #{emp.taxAgentId}, + #{emp.salaryMonth}, + #{emp.creator}, + #{emp.createTime}, + #{emp.updateTime}, + #{emp.deleteType}, + #{emp.tenantKey} + ) + + + + INSERT INTO hrsa_salary_acct_emp( + salary_acct_record_id, salary_sob_id, employee_id, tax_agent_id, salary_month, + creator, create_time, update_time, delete_type, tenant_key) + + + select + #{emp.salaryAcctRecordId}, + #{emp.salarySobId}, + #{emp.employeeId}, + #{emp.taxAgentId}, + #{emp.salaryMonth}, + #{emp.creator}, + #{emp.createTime}, + #{emp.updateTime}, + #{emp.deleteType}, + #{emp.tenantKey} + from dual + + + + INSERT INTO hrsa_salary_acct_emp( + salary_acct_record_id, salary_sob_id, employee_id, tax_agent_id, salary_month, + creator, create_time, update_time, delete_type, tenant_key) + VALUES + + ( + #{emp.salaryAcctRecordId}, + #{emp.salarySobId}, + #{emp.employeeId}, + #{emp.taxAgentId}, + #{emp.salaryMonth}, + #{emp.creator}, + #{emp.createTime}, + #{emp.updateTime}, + #{emp.deleteType}, + #{emp.tenantKey} + ) + + + + + + + + + + + + + + + + + + + + + + + + AND id IN + + #{id} + + + + AND tax_agent_id = #{param.taxAgentId} + + + AND employee_id IN + ( + SELECT id FROM {$publicdb}.employee em WHERE 1=1 + + AND em.username LIKE CONCAT('%',#{param.employeeName},'%') + + + AND em.department IN + + #{departmentId} + + + + AND em.position IN + + #{positionId} + + + + AND em.status = #{param.status} + + ) + + + + + AND id IN + + #{id} + + + + AND tax_agent_id = #{param.taxAgentId} + + + AND employee_id IN + ( + SELECT id FROM {$publicdb}.employee em WHERE 1=1 + + AND em.username LIKE '%'||#{param.employeeName}||'%' + + + AND em.department IN + + #{departmentId} + + + + AND em.position IN + + #{positionId} + + + + AND em.status = #{param.status} + + ) + + + + + AND id IN + + #{id} + + + + AND tax_agent_id = #{param.taxAgentId} + + + AND employee_id IN + ( + SELECT id FROM {$publicdb}.employee em WHERE 1=1 + + AND em.username LIKE '%'+#{param.employeeName}+'%' + + + AND em.department IN + + #{departmentId} + + + + AND em.position IN + + #{positionId} + + + + AND em.status = #{param.status} + + ) + + + + + + + + + + + + + UPDATE hrsa_salary_acct_emp + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + + + DELETE FROM hrsa_salary_acct_emp + WHERE delete_type = 0 + AND salary_acct_record_id IN + + #{salaryAcctRecordId} + + + + + + + + + + + + + + + + + + + + + t + . + id + , t.salary_acct_record_id + , t.salary_sob_id + , t.employee_id + , t.tax_agent_id + , t.salary_month + , t.creator + , t.create_time + , t.update_time + , t.delete_type + , t.tenant_key + + + + + + + + + + diff --git a/src/com/engine/salary/service/SalaryAcctEmployeeService.java b/src/com/engine/salary/service/SalaryAcctEmployeeService.java index b73a20967..7f805762a 100644 --- a/src/com/engine/salary/service/SalaryAcctEmployeeService.java +++ b/src/com/engine/salary/service/SalaryAcctEmployeeService.java @@ -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 listPageByParam(SalaryAcctEmployeeQueryParam queryParam); + PageInfo listPageByParam(SalaryAcctEmployeeQueryParam queryParam); /** * 根据列表查询条件查询薪资核算人员 @@ -126,7 +127,7 @@ public interface SalaryAcctEmployeeService { * @param queryParam 薪资核算结果列表的列表查询条件 * @return */ -// Page listPageByResultQueryParam(SalaryAcctResultQueryParam queryParam); + PageInfo listPageByResultQueryParam(SalaryAcctResultQueryParam queryParam); /** * 根据薪资核算结果列表的列表查询条件查询薪资核算人员 @@ -142,7 +143,7 @@ public interface SalaryAcctEmployeeService { * @param queryParam 列表查询条件 * @return */ -// Page listPageByParam4Reduce(SalaryAcctEmployeeQueryParam queryParam); + PageInfo listPageByParam4Reduce(SalaryAcctEmployeeQueryParam queryParam); /** * 根据列表查询条件查询同比减少的薪资核算人员 @@ -158,7 +159,7 @@ public interface SalaryAcctEmployeeService { * @param queryParam 列表查询条件 * @return */ -// Page listPageByParam4ConsolidatedTax(SalaryAcctEmployeeQueryParam queryParam); + PageInfo 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); } diff --git a/src/com/engine/salary/service/SalaryEmployeeService.java b/src/com/engine/salary/service/SalaryEmployeeService.java new file mode 100644 index 000000000..07d0ff67c --- /dev/null +++ b/src/com/engine/salary/service/SalaryEmployeeService.java @@ -0,0 +1,40 @@ +package com.engine.salary.service; + +import com.engine.salary.entity.datacollection.DataCollectionEmployee; + +import java.util.List; + +/** + * 人员信息 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +public interface SalaryEmployeeService { + + /** + * 获取租户下的所有人员 + * + * @return + */ + List listAll(); + + /** + * 根据薪资账套id查询人员 + * + * @param salarySobId 薪资账套id + * @return + */ + List listBySalarySobId(Long salarySobId); + + /** + * 根据薪资账套id查询人员 + * + * @param ids + * @return + */ + List listByIds(List ids); + +} diff --git a/src/com/engine/salary/service/impl/SalaryAcctEmployeeServiceImpl.java b/src/com/engine/salary/service/impl/SalaryAcctEmployeeServiceImpl.java new file mode 100644 index 000000000..32b4703d4 --- /dev/null +++ b/src/com/engine/salary/service/impl/SalaryAcctEmployeeServiceImpl.java @@ -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; + +/** + * 薪资核算人员 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @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 countBySalaryAcctRecordId(Collection 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 listByIds(Collection ids) { + return getSalaryAcctEmployeeMapper().listSome(SalaryAcctEmployeePO.builder().ids(ids).build()); + } + + @Override + public List listBySalaryAcctRecordId(Long salaryAcctRecordId) { + return getSalaryAcctEmployeeMapper().listSome(SalaryAcctEmployeePO.builder().salaryAcctRecordId(salaryAcctRecordId).build()); + } + + @Override + public List listBySalaryAcctRecordIds(Collection salaryAcctRecordIds) { + return getSalaryAcctEmployeeMapper().listSome(SalaryAcctEmployeePO.builder().salaryAcctRecordIds(salaryAcctRecordIds).build()); + } + + @Override + public List 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 salaryAcctEmployeePOS = listByIds(addParam.getIds()); + if (CollectionUtils.isEmpty(salaryAcctEmployeePOS)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98830, "薪资核算人员不存在或已被删除")); + } + // 添加薪资核算人员 + Date now = new Date(); + List 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 listBySalaryAcctRecordIdAndIds(Long salaryAcctRecordId, Collection ids) { + return getSalaryAcctEmployeeMapper().listSome(SalaryAcctEmployeePO.builder().salaryAcctRecordId(salaryAcctRecordId).ids(ids).build()); + } + + @Override + public List listBySalaryAcctRecordIdAndEmployeeIds(Long salaryAcctRecordId, Collection employeeIds) { + if (CollectionUtils.isEmpty(employeeIds)) { + return Collections.emptyList(); + } + return getSalaryAcctEmployeeMapper().listSome(SalaryAcctEmployeePO.builder().salaryAcctRecordId(salaryAcctRecordId).employeeIds(employeeIds).build()); + } + + @Override + public List listBySalaryAcctRecordIdsAndEmployeeIds(Collection salaryAcctRecordIds, Collection employeeIds) { + if (CollectionUtils.isEmpty(salaryAcctRecordIds) || CollectionUtils.isEmpty(employeeIds)) { + return Collections.emptyList(); + } + return getSalaryAcctEmployeeMapper().listSome(SalaryAcctEmployeePO.builder().salaryAcctRecordIds(salaryAcctRecordIds).employeeIds(employeeIds).build()); + } + + @Override + public List listByRecordIdsAndEmpIdAndTaxAgentId(Collection 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 listPageByParam(SalaryAcctEmployeeQueryParam queryParam) { + ValidUtil.doValidator(queryParam); + // 分页参数 + PageUtil.start(queryParam.getCurrent(), queryParam.getPageSize()); + // 查询薪资核算人员 + List salaryAcctEmployeePOS = getSalaryAcctEmployeeMapper().listPage(queryParam); + return new PageInfo<>(salaryAcctEmployeePOS); + } + + @Override + public List listByParam(SalaryAcctEmployeeQueryParam queryParam) { + ValidUtil.doValidator(queryParam); + return getSalaryAcctEmployeeMapper().list(queryParam); + } + + @Override + public PageInfo 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 listByResultQueryParam(SalaryAcctResultQueryParam queryParam) { + // 薪资核算人员的查询参数 + SalaryAcctEmployeeQueryParam salaryAcctEmployeeQueryParam = new SalaryAcctEmployeeQueryParam(); + BeanUtils.copyProperties(queryParam, salaryAcctEmployeeQueryParam); + // 查询薪资核算人员 + List salaryAcctEmployeePOS; + // 如果需要筛选是否合并计税 + if (StringUtils.isNotEmpty(queryParam.getConsolidatedTaxation())) { + salaryAcctEmployeePOS = listByParam4ConsolidatedTax(salaryAcctEmployeeQueryParam); + } else { + salaryAcctEmployeePOS = listByParam(salaryAcctEmployeeQueryParam); + } + return salaryAcctEmployeePOS; + } + + @Override + public PageInfo listPageByParam4Reduce(SalaryAcctEmployeeQueryParam queryParam) { + // 查询上个月的薪资核算记录(同一个薪资账套) + List salaryAcctRecordPOS = getSalaryAcctRecordService(user).listById4LastSalaryMonth(queryParam.getSalaryAcctRecordId()); + if (CollectionUtils.isEmpty(salaryAcctRecordPOS)) { + return new PageInfo<>(); + } + Set lastMonthSalaryAcctRecordIds = SalaryEntityUtil.properties(salaryAcctRecordPOS, SalaryAcctRecordPO::getId); + // 查询环比减少人员 + // 分页参数 + PageUtil.start(queryParam.getCurrent(), queryParam.getPageSize()); + List salaryAcctEmployeePOS = getSalaryAcctEmployeeMapper().listPage4Reduce(lastMonthSalaryAcctRecordIds, queryParam); + PageInfo salaryAcctEmployeePOPageInfo = new PageInfo<>(salaryAcctEmployeePOS); + return salaryAcctEmployeePOPageInfo; + } + + @Override + public List listByParam4Reduce(SalaryAcctEmployeeQueryParam queryParam) { + // 查询上个月的薪资核算记录(同一个薪资账套) + List salaryAcctRecordPOS = getSalaryAcctRecordService(user).listById4LastSalaryMonth(queryParam.getSalaryAcctRecordId()); + if (CollectionUtils.isEmpty(salaryAcctRecordPOS)) { + return Collections.emptyList(); + } + Set lastMonthSalaryAcctRecordIds = SalaryEntityUtil.properties(salaryAcctRecordPOS, SalaryAcctRecordPO::getId); + // 查询环比减少人员 + return getSalaryAcctEmployeeMapper().list4Reduce(lastMonthSalaryAcctRecordIds, queryParam); + } + + @Override + public PageInfo listPageByParam4ConsolidatedTax(SalaryAcctEmployeeQueryParam queryParam) { + + // 查询合并计税的其他薪资核算记录 + List otherSalaryAcctRecordPOS = getSalaryAcctRecordService(user).listById4OtherConsolidatedTax(queryParam.getSalaryAcctRecordId()); + if (CollectionUtils.isEmpty(otherSalaryAcctRecordPOS)) { + return new PageInfo<>(); + } + // 查询合并计税的薪资核算人员 + Set otherSalaryAcctRecordIds = SalaryEntityUtil.properties(otherSalaryAcctRecordPOS, SalaryAcctRecordPO::getId); + // 分页参数 + PageUtil.start(queryParam.getCurrent(), queryParam.getPageSize()); + List salaryAcctEmployeePOS = getSalaryAcctEmployeeMapper().listPage4ConsolidatedTax(otherSalaryAcctRecordIds, queryParam); + PageInfo salaryAcctEmployeePOPageInfo = new PageInfo<>(salaryAcctEmployeePOS); + return salaryAcctEmployeePOPageInfo; + } + + @Override + public List listByParam4ConsolidatedTax(SalaryAcctEmployeeQueryParam queryParam) { + // 查询合并计税的其他薪资核算记录 + List otherSalaryAcctRecordPOS = getSalaryAcctRecordService(user).listById4OtherConsolidatedTax(queryParam.getSalaryAcctRecordId()); + if (CollectionUtils.isEmpty(otherSalaryAcctRecordPOS)) { + return Collections.emptyList(); + } + // 查询合并计税的薪资核算人员 + Set 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 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 salaryArchiveDataDTOS = salaryArchiveService.getSalaryArchiveTaxAgentData(salarySobCycleDTO.getSalaryCycle(), saveParam.getEmployeeIds()); + // 转换成薪资核算人员po + List 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 salaryAcctEmployeePOS) { + getSalaryAcctEmployeeMapper().batchInsert(salaryAcctEmployeePOS); + } + + @Override + public void deleteByIds(Collection 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 salaryAcctEmployeePOS = listBySalaryAcctRecordIdAndIds(deleteParam.getSalaryAcctRecordId(), deleteParam.getIds()); + if (CollectionUtils.isEmpty(salaryAcctEmployeePOS)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98830, "薪资核算人员不存在或已被删除")); + } + // 删除薪资核算人员 + Set 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 salaryAcctRecordIds) { + getSalaryAcctEmployeeMapper().deleteBySalaryAcctRecordIds(salaryAcctRecordIds); + } + + @Override + public void initBySalaryAcctRecord(SalaryAcctRecordPO salaryAcctRecordPO) { + // 根据薪资账套查询人员 + List 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 employeeIds = SalaryEntityUtil.properties(salaryEmployees, DataCollectionEmployee::getEmployeeId); + List salaryArchiveDataDTOS = salaryArchiveService.getSalaryArchiveTaxAgentData(salarySobCycleDTO.getSalaryCycle(), employeeIds); + // 转换成薪资核算人员po + List salaryAcctEmployeePOS = SalaryAcctEmployeeBO.convert2EmployeePO(employeeIds, salaryAcctRecordPO, salaryArchiveDataDTOS, (long) user.getUID()); + // 保存薪资核算人员 + if (CollectionUtils.isNotEmpty(salaryAcctEmployeePOS)) { + getSalaryAcctEmployeeMapper().batchInsert(salaryAcctEmployeePOS); + } + } + + @Override + public void refresh(Long salaryAcctRecordId) { + // 查询薪资核算人员 + List salaryAcctEmployeePOS = listBySalaryAcctRecordId(salaryAcctRecordId); + if (CollectionUtils.isEmpty(salaryAcctEmployeePOS)) { + return; + } + Set 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 salaryArchiveDataDTOS = salaryArchiveService.getSalaryArchiveTaxAgentData(salarySobCycleDTO.getSalaryCycle(), employeeIds); + // 转换成薪资核算人员po + List newSalaryAcctEmployeePOS = SalaryAcctEmployeeBO.convert2EmployeePO(employeeIds, salaryAcctRecordPO, salaryArchiveDataDTOS, (long) user.getUID()); + // 删除以前的薪资核算人员 + getSalaryAcctEmployeeMapper().deleteBySalaryAcctRecordIds(Collections.singleton(salaryAcctRecordId)); + // 插入新的薪资核算人员 + if (CollectionUtils.isNotEmpty(newSalaryAcctEmployeePOS)) { + getSalaryAcctEmployeeMapper().batchInsert(newSalaryAcctEmployeePOS); + } + } +} diff --git a/src/com/engine/salary/service/impl/SalaryAcctResultServiceImpl.java b/src/com/engine/salary/service/impl/SalaryAcctResultServiceImpl.java new file mode 100644 index 000000000..b2a69eb67 --- /dev/null +++ b/src/com/engine/salary/service/impl/SalaryAcctResultServiceImpl.java @@ -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; +// +///** +// * 薪资核算结果 +// *

Copyright: Copyright (c) 2022

+// *

Company: 泛微软件

+// * +// * @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 listBySalaryAcctRecordIds(Collection 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 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 listBySalaryAcctEmployeeIds(Collection 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 listBySalaryAcctRecordIdsAndEmployeeIds(Collection salaryAcctRecordIds, Collection 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 salarySobItemPOS = salarySobItemService.listBySalarySobId(salaryAcctEmployeePO.getSalarySobId(), tenantKey); +// // 查询薪资项目 +// Set salaryItemIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getSalaryItemId); +// List salaryItemPOS = salaryItemService.listByIds(salaryItemIds, tenantKey); +// // 查询薪资核算所用薪资账套的人员信息字段 +// List salarySobEmpFieldPOS = salarySobEmpFieldService.listBySalarySobId(salaryAcctEmployeePO.getSalarySobId(), tenantKey); +// // 查询人员信息 +// SimpleEmployee simpleEmployee = hrmCommonEmployeeService.getEmployeeById(salaryAcctEmployeePO.getEmployeeId(), tenantKey); +// // 查询薪资核算结果 +// List 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> listPageByParam(SalaryAcctResultQueryParam queryParam, String tenantKey) { +// // 查询薪资核算人员(分页) +// Page page = salaryAcctEmployeeService.listPageByResultQueryParam(queryParam, tenantKey); +// // 查询薪资核算结果 +// List> data = listBySalaryAcctEmployees(page.getRecords(), queryParam, tenantKey); +// // 薪资核算结果的分页结果 +// Page> resultPage = new Page<>(page.getCurrent(), page.getSize(), page.getTotal(), page.isSearchCount()); +// resultPage.setRecords(data); +// return resultPage; +// } +// +// @Override +// public List> listByParam(SalaryAcctResultQueryParam queryParam, String tenantKey) { +// // 查询薪资核算人员 +// List salaryAcctEmployeePOS = salaryAcctEmployeeService.listByResultQueryParam(queryParam, tenantKey); +// // 查询薪资核算结果 +// return listBySalaryAcctEmployees(salaryAcctEmployeePOS, queryParam, tenantKey); +// } +// +// /** +// * 根据薪资核算人员查询薪资核算结果 +// * +// * @param salaryAcctEmployeePOS 薪资核算人员 +// * @param queryParam 列表查询条件 +// * @param tenantKey 租户key +// * @return +// */ +// private List> listBySalaryAcctEmployees(List 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 salarySobEmpFieldPOS = salarySobEmpFieldService.listBySalarySobId(salaryAcctRecordPO.getSalarySobId(), tenantKey); +// // 查询薪资核算所用薪资账套的薪资项目 +// List salarySobItemPOS = salarySobItemService.listBySalarySobId(salaryAcctRecordPO.getSalarySobId(), tenantKey); +// Set salaryItemIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getSalaryItemId); +// List salaryItemPOS = salaryItemService.listByIds(salaryItemIds, tenantKey); +// // 查询薪资核算结果 +// Set salaryAcctEmployeeIds = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getId); +// List salaryAcctResultPOS = listBySalaryAcctEmployeeIds(salaryAcctEmployeeIds, tenantKey); +// // 查询人员信息 +// List employeeIds = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getEmployeeId, Collectors.toList()); +// List simpleEmployees = hrmCommonEmployeeService.getEmployeeByIds(employeeIds, tenantKey); +// // 查询个税扣缴义务人 +// Set taxAgentIds = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getTaxAgentId); +// List taxAgentPOS = taxAgentService.listByIds(taxAgentIds, tenantKey); +// // 判断是否存在合并计税 +// Set 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 salaryAcctEmployeePOS4ConsolidatedTax = salaryAcctEmployeeService.listByParam4ConsolidatedTax(accEmployeeQueryParam, tenantKey); +// salaryAcctEmployeeIds4ConsolidatedTax = SalaryEntityUtil.properties(salaryAcctEmployeePOS4ConsolidatedTax, SalaryAcctEmployeePO::getId); +// } +// // 查询公式详情 +// Set formulaIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getFormulaId); +// List expressFormulas = salaryFormulaService.listExpressFormula(formulaIds, tenantKey); +// Map expressFormulaMap = SalaryEntityUtil.convert2Map(expressFormulas, ExpressFormula::getId, ExpressFormula::getFormula); +// Map 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 salarySobEmpFieldPOS = salarySobEmpFieldService.listBySalarySobId(salarySobPO.getId(), tenantKey); +// +// List salaryAcctRecordPOS = Collections.singletonList(salaryAcctRecordPO); +// List salaryAcctEmployeePOS = Collections.singletonList(salaryAcctEmployeePO); +// +// // 如果当前薪资核算记录所用的薪资账套的薪资类型是工资薪金,代表可能存在合并计税 +// if (Objects.equals(salarySobPO.getIncomeCategory(), IncomeCategoryEnum.WAGES_AND_SALARIES.getValue())) { +// // 查询所有薪资类型为工资薪金的账套 +// List salarySobPOS = salarySobService.listByIncomeCategory(IncomeCategoryEnum.WAGES_AND_SALARIES, tenantKey); +// // 查询相同税款所属期内的薪资类型为工资薪金的账套的所有核算记录 +// Set salarySobIds = SalaryEntityUtil.properties(salarySobPOS, SalarySobPO::getId); +// LocalDateRange taxCycleDateRange = SalaryDateUtil.localDate2Range(salaryAcctRecordPO.getTaxCycle()); +// salaryAcctRecordPOS = salaryAcctRecordService.listBySalarySobIdsAndSalaryMonth(salarySobIds, taxCycleDateRange, tenantKey); +// // 查询当前薪资核算人员所涉及的合并计税的所有薪资核算人员 +// Set salaryAcctRecordIds = SalaryEntityUtil.properties(salaryAcctRecordPOS, SalaryAcctRecordPO::getId); +// salaryAcctEmployeePOS = salaryAcctEmployeeService.listByRecordIdsAndEmpIdAndTaxAgentId(salaryAcctRecordIds, +// salaryAcctEmployeePO.getEmployeeId(), salaryAcctEmployeePO.getTaxAgentId(), tenantKey); +// } +// // 查询薪资核算人员的薪资核算结果 +// Set salaryAcctEmployeeIds = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getId); +// List salaryAcctResultPOS = listBySalaryAcctEmployeeIds(salaryAcctEmployeeIds, tenantKey); +// // 查询薪资核算人员所有合并计税的薪资核算记录所用的账套 +// Set salarySobIds = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getSalarySobId); +// List salarySobPOS = salarySobService.listByIds(salarySobIds, tenantKey); +// // 查询薪资项目所引用的薪资项目 +// List salarySobItemPOS = salarySobItemService.listBySalarySobIds(salarySobIds, tenantKey); +// // 查询薪资项目 +// Set salaryItemIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getSalaryItemId); +// List 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 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 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 salaryAcctResultPOS) { +// if (CollectionUtils.isNotEmpty(salaryAcctResultPOS)) { +// salaryAcctResultMapper.batchInsert(salaryAcctResultPOS); +// } +// } +// +// @Override +// public void deleteBySalaryAcctEmployeeIds(Collection salaryAcctEmployeeIds, String tenantKey) { +// salaryAcctResultMapper.deleteBySalaryAcctEmpIds(salaryAcctEmployeeIds, tenantKey); +// } +// +// @Override +// public void deleteByAcctEmployeeIdsAndSalaryItemIds(Collection salaryAcctEmployeeIds, Collection salaryItemIds, String tenantKey) { +// salaryAcctResultMapper.deleteByAcctEmpIdsAndSalaryItemIds(salaryAcctEmployeeIds, salaryItemIds, tenantKey); +// } +// +// @Override +// public void deleteBySalaryAcctRecordIds(Collection 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 salarySobItemPOS = salarySobItemService.listBySalarySobId(salaryAcctRecordPO.getSalarySobId(), tenantKey); +// if (CollectionUtils.isEmpty(salarySobItemPOS)) { +// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(99151, "当前所用的薪资账套未选择任何薪资项目,无法核算")); +// } +// // 4、查询当前租户的所有薪资项目 +// List salaryItemPOS = salaryItemService.listAll(tenantKey); +// // 5、查询薪资核算记录所用薪资账套的调薪计薪规则 +// List salarySobAdjustRulePOS = salarySobAdjustRuleService.listBySalarySobId(salaryAcctRecordPO.getSalarySobId(), tenantKey); +// // 6、查询社保福利的所有字段 +// Map welfareColumns = siAccountService.welfareColumns(tenantKey); +// // 7、查询考勤引用的所有字段 +// List attendQuoteFieldListDTOS = attendQuoteFieldService.listAll(tenantKey); +// // 8、查询公式详情 +// Set formulaIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getFormulaId); +// formulaIds.addAll(SalaryEntityUtil.properties(salaryItemPOS, SalaryItemPO::getFormulaId)); +// List expressFormulas = salaryFormulaService.listExpressFormula(formulaIds, tenantKey); +// // 9、计算薪资项目的运算优先级 +// List> salarySobItemsWithPriority = SalaryAcctCalculatePriorityBO.calculatePriority(salarySobItemPOS, salaryItemPOS, expressFormulas); +// // 10、根据id查询其他合并计税的薪资核算记录 +// List otherSalaryAcctRecordPOS = salaryAcctRecordService.listById4OtherConsolidatedTax(salaryAcctRecordPO.getId(), tenantKey); +// // 11、查询本次核算人员 +// List 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> partition = Lists.partition(salaryAcctEmployeePOS, 100); +// // 12.1、监控子线程的任务执行 +// CountDownLatch childMonitor = new CountDownLatch(partition.size()); +// // 12.2、记录子线程的执行结果 +// BlockingDeque calculateResults = new LinkedBlockingDeque<>(partition.size()); +// // 12.3、生成本次运算的key +// String calculateKey = UUID.randomUUID().toString(); +// // 12.4、多线程运算,运算结果存放在临时表中 +// for (List 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 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 salaryAcctResultTempPOS = salaryAcctResultTempService.listByCalculateKey(calculateKey, tenantKey); +// // 删除原来的薪资核算结果 +// if (CollectionUtils.isNotEmpty(calculateParam.getIds())) { +// salaryAcctResultMapper.deleteBySalaryAcctEmpIds(calculateParam.getIds(), tenantKey); +// } else { +// salaryAcctResultMapper.deleteBySalaryAcctRecordIds(Collections.singleton(calculateParam.getSalaryAcctRecordId()), tenantKey); +// } +// // 保存薪资的薪资核算结果 +// List salaryAcctResultPOS = SalaryAcctResultBO.convert2ResultPO(salaryAcctResultTempPOS); +// batchSave(salaryAcctResultPOS); +// // 删除薪资核算临时存储表中的数据 +// salaryAcctResultTempService.deleteByCalculateKey(calculateKey, tenantKey); +// // 提交事务 +// dataSourceTransactionManager.commit(status); +// } catch (Exception e) { +// dataSourceTransactionManager.rollback(status); +// throw e; +// } +// } +//} diff --git a/src/com/engine/salary/service/impl/SalaryEmployeeServiceImpl.java b/src/com/engine/salary/service/impl/SalaryEmployeeServiceImpl.java new file mode 100644 index 000000000..3e1091044 --- /dev/null +++ b/src/com/engine/salary/service/impl/SalaryEmployeeServiceImpl.java @@ -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; + +/** + * 人员信息 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @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 listAll() { + return employBiz.listEmployee(); + } + + @Override + public List listBySalarySobId(Long salarySobId) { + // 查询薪资账套的人员范围 + List includeSalarySobRangePOS = getSalarySobRangeService(user).listBySalarySobIdAndIncludeType(salarySobId, NumberUtils.INTEGER_ONE); + if (CollectionUtils.isEmpty(includeSalarySobRangePOS)) { + return Collections.emptyList(); + } + // 将薪资账套的人员范围转换成人员查询参数 + List includeQueryParams = SalarySobRangeBO.convert2EmployeeQueryParam(includeSalarySobRangePOS); + // 根据上一步的查询参数查询人员 + List includeSalaryEmployees = employBiz.listByParams(includeQueryParams); + if (CollectionUtils.isEmpty(includeSalaryEmployees)) { + return Collections.emptyList(); + } + // 查询薪资账套的人员范围(从范围中排除) + List excludeSalarySobRangePOS = getSalarySobRangeService(user).listBySalarySobIdAndIncludeType(salarySobId, NumberUtils.INTEGER_ZERO); + if (CollectionUtils.isNotEmpty(excludeSalarySobRangePOS)) { + // 将薪资账套的人员范围转换成人员查询参数 + List excludeQueryParams = SalarySobRangeBO.convert2EmployeeQueryParam(excludeSalarySobRangePOS); + // 根据上一步的查询参数查询人员 + List excludeSalaryEmployees = employBiz.listByParams(excludeQueryParams); + // 需要排除的人员范围 + Set excludeEmployeeIds = SalaryEntityUtil.properties(excludeSalaryEmployees, DataCollectionEmployee::getEmployeeId); + // 过滤人员 + includeSalaryEmployees = includeSalaryEmployees.stream() + .filter(salaryEmployee -> !excludeEmployeeIds.contains(salaryEmployee.getEmployeeId())) + .collect(Collectors.toList()); + } + return includeSalaryEmployees; + } + + @Override + public List listByIds(List ids) { + return employBiz.getEmployeeByIdsAll(ids); + } +} diff --git a/src/com/engine/salary/util/page/PageInfo.java b/src/com/engine/salary/util/page/PageInfo.java index 55735520a..00943aed6 100644 --- a/src/com/engine/salary/util/page/PageInfo.java +++ b/src/com/engine/salary/util/page/PageInfo.java @@ -18,6 +18,10 @@ public class PageInfo extends com.github.pagehelper.PageInfo { public PageInfo() { } + public PageInfo(Class clazz) { + this.clazz = clazz; + } + public PageInfo(List list) { super(list); } diff --git a/src/com/engine/salary/web/SalaryAcctController.java b/src/com/engine/salary/web/SalaryAcctController.java index 952053ec4..53d6efee5 100644 --- a/src/com/engine/salary/web/SalaryAcctController.java +++ b/src/com/engine/salary/web/SalaryAcctController.java @@ -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().run(getSalaryAcctRecordWrapper(user)::getForm, id); } -// -// @GetMapping("/getSalarySobCycle") -// @ApiOperation(("获取薪资核算的薪资周期、考勤周期等")) -// @WeaPermission -// public WeaResult getSalarySobCycle(@RequestParam(value = "salaryAcctRecordId") Long salaryAcctRecordId) { -// SalarySobCycleDTO salarySobCycle = salaryAcctRecordWrapper.getSalarySobCycleById(salaryAcctRecordId, TenantContext.getCurrentTenantKey()); -// return WeaResult.success(salarySobCycle); -// } -// -// @PostMapping("/basic/save") -// @ApiOperation("保存薪资核算的基本信息") -// @WeaPermission -// public WeaResult saveBasic(@RequestBody @Validated SalaryAcctRecordSaveParam saveParam) { -// Long salaryAcctRecordId = salaryAcctRecordWrapper.save(saveParam, UserContext.getCurrentEmployeeId(), TenantContext.getCurrentTenantKey()); -// return WeaResult.success(salaryAcctRecordId); -// } -// -// @PostMapping("/delete") -// @ApiOperation("删除薪资核算记录") -// @WeaPermission -// public WeaResult deleteSalaryAcctRecord(@RequestBody Collection ids) { -// salaryAcctRecordWrapper.delete(ids, TenantContext.getCurrentTenantKey()); -// return WeaResult.success(null); -// } -// -// @PostMapping("/file") -// @ApiOperation("归档薪资核算记录") -// @WeaPermission -// public WeaResult fileSalaryAcctRecord(@RequestParam(value = "id") Long id) { -// salaryAcctRecordWrapper.file(id, UserContext.getCurrentEmployeeId(), TenantContext.getCurrentTenantKey()); -// return WeaResult.success(null); -// } -// -// @PostMapping("/reAccounting") -// @ApiOperation("重新核算") -// @WeaPermission -// public WeaResult reAccounting(@RequestBody @Validated SalaryAcctRecordReAccountParam param) { -// salaryAcctRecordWrapper.reCalculate(param.getSalaryAcctRecordId(), UserContext.getCurrentEmployeeId(), TenantContext.getCurrentTenantKey()); -// return WeaResult.success(null); -// } -// -// @GetMapping("/hasConsolidatedTax") -// @ApiOperation("判断是否存在合并计税") -// @WeaPermission -// public WeaResult 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().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().run(getSalaryAcctRecordWrapper(user)::save, param); + } + + //删除薪资核算记录 + @POST + @Path("/delete") + @Produces(MediaType.APPLICATION_JSON) + public String deleteSalaryAcctRecord(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Collection ids) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult, 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().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().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().run(getSalaryAcctRecordWrapper(user)::hasConsolidatedTax, id); + } + // /**********************************薪资核算记录相关 end*********************************/ // // diff --git a/src/com/engine/salary/wrapper/SalaryAcctEmployeeWrapper.java b/src/com/engine/salary/wrapper/SalaryAcctEmployeeWrapper.java new file mode 100644 index 000000000..50b069c5b --- /dev/null +++ b/src/com/engine/salary/wrapper/SalaryAcctEmployeeWrapper.java @@ -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; + +/** + * 薪资核算人员 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @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 listPage(SalaryAcctEmployeeQueryParam queryParam) { + // 查询薪资核算人员(人员) + PageInfo page = getSalaryAcctEmployeeService(user).listPageByParam(queryParam); + // 转换成列表dto + PageInfo dtoPage = convert2ListDTO(page); + + return dtoPage; + } + + /** + * 同比减少的薪资核算人员列表 + * + * @param queryParam 列表查询参数 + * @return + */ + public PageInfo listPage4Reduce(SalaryAcctEmployeeQueryParam queryParam) { + // 查询同比减少的薪资核算人员(分页) + PageInfo page = getSalaryAcctEmployeeService(user).listPageByParam4Reduce(queryParam); + // 转换成列表dto + PageInfo dtoPage = convert2ListDTO(page); + + return dtoPage; + } + + /** + * 转换成列表dto + * + * @param page 薪资核算人员po + * @return + */ + private PageInfo convert2ListDTO(PageInfo page) { + List list = page.getList(); + if (CollectionUtils.isEmpty(list)) { + return new PageInfo<>(SalaryAccEmployeeListDTO.class); + } + // 查询人员信息 + List employeeIds = list.stream().map(SalaryAcctEmployeePO::getEmployeeId).collect(Collectors.toList()); + List simpleEmployees = getSalaryEmployeeService(user).listByIds(employeeIds); + // 查询个税扣缴义务人 + List taxAgentIds = list.stream().map(SalaryAcctEmployeePO::getTaxAgentId).collect(Collectors.toList()); + List taxAgentPOS = taxAgentService.listByIds(taxAgentIds); + // 转换成列表dto + List salaryAccEmployeeListDTOS = SalaryAcctEmployeeBO.convert2EmployeeListDTO(list, taxAgentPOS, simpleEmployees); + PageInfo pageInfo = new PageInfo(salaryAccEmployeeListDTOS, SalaryAccEmployeeListDTO.class); + return pageInfo; + } + +// /** +// * 获取高级搜索表单 +// * +// * @return +// */ +// public WeaSearchCondition getCondition(String tenantKey) { +// SalaryAcctEmpSearchConditionDTO searchConditionDTO = new SalaryAcctEmpSearchConditionDTO(); +// WeaSearchCondition searchCondition = SalaryFormatUtil.getInstance().buildCondition(SalaryAcctEmpSearchConditionDTO.class, +// searchConditionDTO, "SalaryAcctEmpCondition"); +// // 查询个税扣缴义务人 +// List taxAgentPOS = taxAgentService.listAll(tenantKey); +// List 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 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); + } +} diff --git a/src/com/engine/salary/wrapper/SalaryAcctRecordWrapper.java b/src/com/engine/salary/wrapper/SalaryAcctRecordWrapper.java index 645682160..68bf4116c 100644 --- a/src/com/engine/salary/wrapper/SalaryAcctRecordWrapper.java +++ b/src/com/engine/salary/wrapper/SalaryAcctRecordWrapper.java @@ -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); }