删除薪资档案

This commit is contained in:
Harryxzy 2023-06-29 10:35:55 +08:00
parent 2bb5d18b90
commit 2735661b4a
23 changed files with 263 additions and 7 deletions

View File

@ -122,4 +122,6 @@ public interface SalaryArchiveMapper {
void deletePendingTodo(@Param("ids") Collection<Long> ids);
void deleteSuspendTodo(@Param("ids") Collection<Long> ids);
void deleteByIds(@Param("ids")Collection<Long> deleteIds);
}

View File

@ -467,6 +467,16 @@
</foreach>
</delete>
<delete id="deleteByIds">
UPDATE hrsa_salary_archive
SET delete_type=1
WHERE delete_type = 0
AND id IN
<foreach collection="ids" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="listSome" resultType="com.engine.salary.entity.salaryarchive.po.SalaryArchivePO">
SELECT
<include refid="baseColumns"/>

View File

@ -2,7 +2,6 @@ package com.engine.salary.mapper.siarchives;
import com.engine.salary.entity.siarchives.po.InsuranceArchivesEmployeePO;
import com.engine.salary.entity.siarchives.po.InsuranceArchivesFundSchemePO;
import com.engine.salary.entity.siarchives.po.InsuranceArchivesSocialSchemePO;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
@ -80,4 +79,10 @@ public interface FundSchemeMapper {
* @param ids
*/
void batchUpdateEndTimeToNull(@Param("ids")List<Long> ids);
/**
* 根据id删除
* @param fundArchiveDelIds
*/
void deleteByIds(@Param("ids")List<Long> fundArchiveDelIds);
}

View File

@ -105,6 +105,19 @@
</delete>
<delete id="deleteByIds">
UPDATE hrsa_fund_archives
SET delete_type = 1
WHERE delete_type = 0
<if test="ids != null and ids.size()>0">
AND id IN
<foreach collection="ids" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</if>
</delete>
<!-- 根据人员id和个税扣缴义务人删除档案 -->
<update id="deleteByEmployeeIdAndPayOrg" parameterType="com.engine.salary.entity.siarchives.po.InsuranceArchivesFundSchemePO">
UPDATE hrsa_fund_archives

View File

@ -1,9 +1,7 @@
package com.engine.salary.mapper.siarchives;
import com.engine.salary.entity.salarysob.po.SalarySobEmpFieldPO;
import com.engine.salary.entity.siarchives.param.InsuranceArchivesListParam;
import com.engine.salary.entity.siarchives.po.InsuranceArchivesBaseInfoPO;
import com.engine.salary.entity.siarchives.po.InsuranceArchivesOtherSchemePO;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
@ -109,4 +107,10 @@ public interface InsuranceBaseInfoMapper {
* @param insuranceArchivesBaseInfoPOS
*/
void batchUpdate(@Param("collection") Collection<InsuranceArchivesBaseInfoPO> insuranceArchivesBaseInfoPOS);
/**
* 根据id删除
* @param archiveDelIds
*/
void deleteByIds(@Param("ids")List<Long> archiveDelIds);
}

View File

@ -174,6 +174,18 @@
</if>
</delete>
<delete id="deleteByIds">
UPDATE hrsa_insurance_base_info
SET delete_type = 1
WHERE delete_type = 0
<if test="ids != null and ids.size()>0">
AND id IN
<foreach collection="ids" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</if>
</delete>
<!-- 根据人员id和个税扣缴义务人删除档案 -->
<update id="deleteByEmployeeIdAndPayOrg" parameterType="com.engine.salary.entity.siarchives.po.InsuranceArchivesBaseInfoPO">
UPDATE hrsa_insurance_base_info

View File

@ -1,9 +1,7 @@
package com.engine.salary.mapper.siarchives;
import com.engine.salary.entity.siarchives.po.InsuranceArchivesEmployeePO;
import com.engine.salary.entity.siarchives.po.InsuranceArchivesFundSchemePO;
import com.engine.salary.entity.siarchives.po.InsuranceArchivesOtherSchemePO;
import com.engine.salary.entity.siarchives.po.InsuranceArchivesSocialSchemePO;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
@ -73,4 +71,10 @@ public interface OtherSchemeMapper {
* @param ids
*/
void batchUpdateEndTimeToNull(@Param("ids")List<Long> ids);
/**
* 根据id删除
* @param otherArchiveDelIds
*/
void deleteByIds(@Param("ids") List<Long> otherArchiveDelIds);
}

View File

@ -92,6 +92,18 @@
</delete>
<delete id="deleteByIds">
UPDATE hrsa_other_archives
SET delete_type = 1
WHERE delete_type = 0
AND id IN
<if test="ids != null and ids.size()>0">
<foreach collection="ids" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</if>
</delete>
<!-- 根据人员id和个税扣缴义务人删除档案 -->
<update id="deleteByEmployeeIdAndPayOrg" parameterType="com.engine.salary.entity.siarchives.po.InsuranceArchivesOtherSchemePO">
UPDATE hrsa_other_archives

View File

@ -3,7 +3,6 @@ package com.engine.salary.mapper.siarchives;
import com.engine.salary.entity.siarchives.param.InsuranceArchivesListParam;
import com.engine.salary.entity.siarchives.po.InsuranceArchivesEmployeePO;
import com.engine.salary.entity.siarchives.po.InsuranceArchivesSocialSchemePO;
import com.engine.salary.entity.sischeme.po.InsuranceSchemeDetailPO;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
@ -108,4 +107,10 @@ public interface SocialSchemeMapper {
* @param ids
*/
void batchUpdateEndTimeToNull(@Param("ids")List<Long> ids);
/**
* 根据id删除
* @param socialArchiveDelIds
*/
void deleteByIds(@Param("ids")List<Long> socialArchiveDelIds);
}

View File

@ -101,6 +101,18 @@
</if>
</delete>
<delete id="deleteByIds">
UPDATE hrsa_social_archives
SET delete_type = 1
WHERE delete_type = 0
<if test="ids != null and ids.size()>0">
AND id IN
<foreach collection="ids" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</if>
</delete>
<!-- 根据人员id和个税扣缴义务人删除档案 -->
<update id="deleteByEmployeeIdAndPayOrg" parameterType="com.engine.salary.entity.siarchives.po.InsuranceArchivesSocialSchemePO">
UPDATE hrsa_social_archives

View File

@ -95,4 +95,10 @@ public interface SIArchivesService {
* 处理福利档案增量数据
*/
void handleChangeData(long currentEmployeeId);
/**
* 删除档案
* @param longs
*/
void deleteArchive(Collection<Long> longs);
}

View File

@ -225,4 +225,10 @@ public interface SalaryArchiveService {
* @param currentEmployeeId
*/
void handleChangeData(Long currentEmployeeId);
/**
* 删除薪资档案
* @param salaryArchiveIds
*/
void deleteSalaryArchive(Collection<Long> salaryArchiveIds);
}

View File

@ -27,6 +27,8 @@ import com.engine.salary.mapper.siarchives.SocialSchemeMapper;
import com.engine.salary.service.SIArchivesService;
import com.engine.salary.service.TaxAgentEmpChangeService;
import com.engine.salary.service.TaxAgentService;
import com.engine.salary.sys.constant.SalarySysConstant;
import com.engine.salary.sys.entity.po.SalarySysConfPO;
import com.engine.salary.sys.entity.vo.OrderRuleVO;
import com.engine.salary.sys.service.SalarySysConfService;
import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl;
@ -349,6 +351,56 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService
log.info("各操作计时 {}", sw.prettyPrint());
Util_DataCache.setObjVal("welfareChangeSign", "0");
}
/**
* 删除档案
* @param archiveIds
*/
@Override
public void deleteArchive(Collection<Long> archiveIds) {
if(CollectionUtils.isEmpty(archiveIds)){
throw new SalaryRunTimeException("社保福利档案参数为空!");
}
SalarySysConfPO canDelete = getSalarySysConfService(user).getOneByCode(SalarySysConstant.SALARY_ARCHIVE_DELETE);
if(Objects.isNull(canDelete) || StringUtils.equals(canDelete.getConfValue(),"0") ){
throw new SalaryRunTimeException("不允许删除社保福利档案,请先开启删除档案规则配置!");
}
List<InsuranceArchivesBaseInfoPO> insuranceArchivesList = getInsuranceBaseInfoMapper().listByIds(archiveIds);
//查询当前登录人员管理的个税扣缴义务人
List<Long> canDeleteTaxAgentIds = getTaxAgentService(user).listAllTaxAgentsAsAdmin((long) user.getUID())
.stream().map(TaxAgentPO::getId).collect(Collectors.toList());
boolean err = insuranceArchivesList.stream().anyMatch(po -> !canDeleteTaxAgentIds.contains(po.getPaymentOrganization()));
if (CollectionUtils.isEmpty(insuranceArchivesList) || err) {
throw new SalaryRunTimeException("社保档案不存在,或没有权限删除该社保案!");
}
Optional<InsuranceArchivesBaseInfoPO> fixedList = insuranceArchivesList.stream().filter(archive -> !StringUtils.equals(archive.getRunStatus(), EmployeeStatusEnum.STAY_ADD.getValue())
&& !StringUtils.equals(archive.getRunStatus(), EmployeeStatusEnum.STOP_PAYMENT_FROM_ADD.getValue())).findFirst();
if(fixedList.isPresent()){
throw new SalaryRunTimeException("在缴员工、待减员、停止缴纳-来自待减员,无法删除薪资档案!");
}
List<Long> archiveDelIds = insuranceArchivesList.stream().map(InsuranceArchivesBaseInfoPO::getId).collect(Collectors.toList());
List<Long> socialArchiveDelIds = insuranceArchivesList.stream().map(InsuranceArchivesBaseInfoPO::getSocialArchivesId).collect(Collectors.toList());
List<Long> fundArchiveDelIds = insuranceArchivesList.stream().map(InsuranceArchivesBaseInfoPO::getFundArchivesId).collect(Collectors.toList());
List<Long> otherArchiveDelIds = insuranceArchivesList.stream().map(InsuranceArchivesBaseInfoPO::getOtherArchivesId).collect(Collectors.toList());
// 删除社保档案主表及3张明细表数据
if(CollectionUtils.isNotEmpty(archiveDelIds)){
getInsuranceBaseInfoMapper().deleteByIds(archiveDelIds);
}
if(CollectionUtils.isNotEmpty(socialArchiveDelIds)){
getSocialSchemeMapper().deleteByIds(socialArchiveDelIds);
}
if(CollectionUtils.isNotEmpty(fundArchiveDelIds)){
getFundSchemeMapper().deleteByIds(fundArchiveDelIds);
}
if(CollectionUtils.isNotEmpty(otherArchiveDelIds)){
getOtherSchemeMapper().deleteByIds(otherArchiveDelIds);
}
}
//新增社保公积金其他福利档案福利档案基础信息
private List<InsuranceArchivesBaseInfoPO> addNewInsuranceBaseInfo(List<InsuranceArchivesBaseInfoPO> baseInfoPOList, Long currentEmployeeId) {
List<InsuranceArchivesSocialSchemePO> socialList = new ArrayList<>();

View File

@ -307,6 +307,37 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe
}
@Override
public void deleteSalaryArchive(Collection<Long> salaryArchiveIds) {
if(CollectionUtils.isEmpty(salaryArchiveIds)){
throw new SalaryRunTimeException("薪资档案参数为空!");
}
SalarySysConfPO canDelete = getSalarySysConfService(user).getOneByCode(SalarySysConstant.SALARY_ARCHIVE_DELETE);
// if(Objects.isNull(canDelete) || StringUtils.equals(canDelete.getConfValue(),"0") ){
// throw new SalaryRunTimeException("不允许删除薪资档案,请先开启删除档案规则配置!");
// }
List<SalaryArchivePO> salaryArchiveList = getSalaryArchiveMapper().listSome(SalaryArchivePO.builder().ids(salaryArchiveIds).build());
//查询当前登录人员管理的个税扣缴义务人
List<Long> canDeleteTaxAgentIds = getTaxAgentService(user).listAllTaxAgentsAsAdmin((long) user.getUID())
.stream().map(TaxAgentPO::getId).collect(Collectors.toList());
boolean err = salaryArchiveList.stream().anyMatch(po -> !canDeleteTaxAgentIds.contains(po.getTaxAgentId()));
if(CollectionUtils.isEmpty(salaryArchiveList) || err){
throw new SalaryRunTimeException("薪资档案不存在,或没有权限删除该薪资档案!");
}
Optional<SalaryArchivePO> fixedList = salaryArchiveList.stream().filter(archive -> !StringUtils.equals(archive.getRunStatus(), SalaryArchiveStatusEnum.PENDING.getValue())
&& !StringUtils.equals(archive.getRunStatus(), SalaryArchiveStatusEnum.STOP_FROM_PENDING.getValue())).findFirst();
if(fixedList.isPresent()){
throw new SalaryRunTimeException("发薪员工、待停薪员工、停薪_来自待停薪无法删除薪资档案");
}
List<Long> deleteIds = salaryArchiveList.stream().map(SalaryArchivePO::getId).collect(Collectors.toList());
// 删除薪资档案及档案项目
if(CollectionUtils.isNotEmpty(deleteIds)){
getSalaryArchiveMapper().deleteByIds(deleteIds);
getSalaryArchiveItemMapper().deleteBySalaryArchiveId(deleteIds);
}
}
@Override
public List<SalaryArchiveListDTO> list(SalaryArchiveQueryParam queryParam) {

View File

@ -71,4 +71,8 @@ public class SalarySysConstant {
*/
public static final String SALARY_PAYROLL_CHECK_TYPE = "SALARY_PAYROLL_CHECK_TYPE";
/**
* 删除薪资档案
*/
public static final String SALARY_ARCHIVE_DELETE = "salaryArchiveDelete";
}

View File

@ -70,4 +70,9 @@ public class AppSettingVO {
*/
private String salaryAcctEmployeeRule;
/**
* 薪资档案删除
*/
private String salaryArchiveDelete;
}

View File

@ -96,4 +96,10 @@ public interface SalarySysConfService {
* @param rule
*/
void saveSalaryAcctEmployeeRule(String rule);
/**
* 保存档案删除规则
* @param setting
*/
void saveArchiveDelete(String setting);
}

View File

@ -416,6 +416,14 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe
saveSettingByType(rule, SALARY_ACCT_EMPLOYEE_RULE, "薪资、社保福利核算包含人员规则", "basic");
}
@Override
public void saveArchiveDelete(String setting) {
if (StringUtils.isBlank(setting)) {
throw new SalaryRunTimeException("无效规则!");
}
saveSettingByType(setting, SALARY_ARCHIVE_DELETE, "薪资、社保福利档案删除规则", "basic");
}
/**
* 保存或者修改应用设置
*
@ -488,6 +496,14 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe
appSettingVO.setSalaryAcctEmployeeRule( SalaryAcctEmployeeRuleEnum.parseByValue(salaryAcctEmployeeRule.getConfValue()).getValue() );
}
SalarySysConfPO salaryArchiveDeletePO = salarySysConfMap.get(SALARY_ARCHIVE_DELETE);
if (salaryArchiveDeletePO == null ) {
// 是否允许删除薪资社保档案默认不允许删除
appSettingVO.setSalaryArchiveDelete("0");
} else {
appSettingVO.setSalaryArchiveDelete(salaryAcctEmployeeRule.getConfValue());
}
//默认加密开启
if (StringUtils.isEmpty(appSettingVO.getIsOpenEncrypt())) {
appSettingVO.setIsOpenEncrypt(OpenEnum.OPEN.getValue());

View File

@ -19,7 +19,6 @@ import javax.ws.rs.*;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import java.util.Collection;
import java.util.List;
import java.util.Map;
/**
@ -223,4 +222,15 @@ public class SIArchivesController {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<String, Map<String, Object>>(user).run(getService(user)::allStayAddToPay);
}
/**
* 删除档案
*/
@POST
@Path("/deleteArchive")
@Produces(MediaType.APPLICATION_JSON)
public String deleteArchive(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Collection<Long> ids) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<Collection<Long>, Map<String, Object>>(user).run(getService(user)::deleteArchive, ids);
}
}

View File

@ -135,6 +135,20 @@ public class SalaryArchiveController {
return new ResponseResult<Collection<Long>, String>(user).run(getSalaryArchiveWrapper(user)::deletePendingTodo, ids);
}
/**
* 删除薪资档案待定薪停薪来自待定薪
*
* @param ids
* @return
*/
@POST
@Path("/deleteSalaryArchive")
@Produces(MediaType.APPLICATION_JSON)
public String deleteSalaryArchive(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Collection<Long> ids) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<Collection<Long>, String>(user).run(getSalaryArchiveWrapper(user)::deleteSalaryArchive, ids);
}
/**
* 发薪列表

View File

@ -188,6 +188,20 @@ public class SalarySystemConfigController {
return new ResponseResult<String, String>(user).run(getSalarySystemConfigWrapper(user)::saveSalaryAcctEmployeeRule, param.getRule());
}
/**
* 删除档案
* @param request
* @param response
* @param param
* @return
*/
@POST
@Path("/saveArchiveDelete")
@Produces(MediaType.APPLICATION_JSON)
public String saveArchiveDelete(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalarySysConfPO param) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<String, String>(user).run(getSalarySystemConfigWrapper(user)::saveArchiveDelete, param.getConfValue());
}
/**
* 应用设置

View File

@ -571,4 +571,13 @@ public class SalaryArchiveWrapper extends Service {
}
return list.get(0);
}
/**
* 删除薪资档案
* @param salaryArchiveIds
*/
public void deleteSalaryArchive(Collection<Long> salaryArchiveIds) {
getSalaryArchiveService(user).deleteSalaryArchive(salaryArchiveIds);
}
}

View File

@ -143,4 +143,8 @@ public class SalarySystemConfigWrapper extends Service {
public void saveSalaryAcctEmployeeRule(String rule) {
getSalarySysConfService(user).saveSalaryAcctEmployeeRule(rule);
}
public void saveArchiveDelete(String setting) {
getSalarySysConfService(user).saveArchiveDelete(setting);
}
}