Commit 6b021b40 authored by fangxinjiang's avatar fangxinjiang

项目配置删除:新增预检接口,增强删除(级联子规则 + 清除续签待办)

Co-authored-by: 's avatarCursor <cursoragent@cursor.com>
parent ab18b0c4
package com.yifu.cloud.plus.v1.yifu.archives.constant;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/**
* 项目配置删除 — 在职续签待办预检/清除状态口径(TODO-02 / TODO-05 确认后仅改此处)
*/
public final class AutoMainRelDeleteTodoStatus {
private AutoMainRelDeleteTodoStatus() {
}
/** 商险续保状态:待确认、待派单 */
public static final List<String> INSURANCE_PROCESS_STATUS =
Collections.unmodifiableList(Arrays.asList("0", "1"));
/** 合同续签状态:待确认、待发起 */
public static final List<String> CONTRACT_PROCESS_STATUS =
Collections.unmodifiableList(Arrays.asList("0", "1"));
}
package com.yifu.cloud.plus.v1.yifu.archives.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
/**
* 项目配置删除预检结果
*/
@Data
@Schema(description = "项目配置删除预检结果")
public class AutoMainRelDeletePrecheckVo implements Serializable {
private static final long serialVersionUID = 1L;
@Schema(description = "商险续签待办条数")
private int insuranceCount;
@Schema(description = "合同续签待办条数")
private int contractCount;
@Schema(description = "项目编码")
private String deptNo;
@Schema(description = "项目名称")
private String departName;
}
......@@ -22,6 +22,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TAutoContractScheme;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TAutoMainRel;
import com.yifu.cloud.plus.v1.yifu.archives.service.TAutoMainRelService;
import com.yifu.cloud.plus.v1.yifu.archives.vo.AutoMainRelDeletePrecheckVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TAutoMainRelAddVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TAutoMainRelDetailVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TAutoMainRelExportVo;
......@@ -159,6 +160,18 @@ public class TAutoMainRelController {
return tAutoMainRelService.updateAsso(entity);
}
/**
* 删除预检:统计在职续签待办条数
* @param id 项目配置ID
* @return R
*/
@Operation(summary = "删除预检", description = "删除前统计商险/合同续签待办条数:hasPermission('demo_tautomainrel_del')")
@GetMapping("/deletePrecheck/{id}")
@PreAuthorize("@pms.hasPermission('demo_tautomainrel_del')")
public R<AutoMainRelDeletePrecheckVo> deletePrecheck(@PathVariable String id) {
return tAutoMainRelService.deletePrecheck(id);
}
/**
* 通过id删除项目配置表主表
* @param id id
......@@ -169,7 +182,7 @@ public class TAutoMainRelController {
@DeleteMapping("/{id}" )
@PreAuthorize("@pms.hasPermission('demo_tautomainrel_del')" )
public R<Boolean> removeById(@PathVariable String id) {
return R.ok(tAutoMainRelService.removeById(id));
return tAutoMainRelService.removeByIdAsso(id);
}
/**
......
......@@ -65,4 +65,22 @@ public interface TEmpContractAlertMapper extends BaseMapper<TEmpContractAlert> {
List<ContractAlertConfirmVo> getAutoRenewForConfirm(@Param("tEmpContractAlert")ContractAlertSearchVo tEmpContractAlert);
List<ContractAlertAutoVo> getPushWxConfrimInfos();
/**
* 项目配置删除预检:合同续签待办条数
*/
int countForProjectConfigRemove(@Param("deptNo") String deptNo,
@Param("processStatusList") List<String> processStatusList);
/**
* 项目配置删除:清除口径内合同续签办理数据
*/
int deleteContractPreNewForProjectConfigRemove(@Param("deptNo") String deptNo,
@Param("processStatusList") List<String> processStatusList);
/**
* 项目配置删除:清除口径内合同续签提醒
*/
int deleteContractAlertForProjectConfigRemove(@Param("deptNo") String deptNo,
@Param("processStatusList") List<String> processStatusList);
}
......@@ -102,4 +102,16 @@ public interface TAutoMainRelService extends IService<TAutoMainRel> {
* @param tAutoMainRel 项目配置对象
*/
void asyncRefreshRenewalDataAfterSave(TAutoMainRel tAutoMainRel);
/**
* 删除预检:统计在职续签待办条数
* @param id 项目配置ID
*/
R<AutoMainRelDeletePrecheckVo> deletePrecheck(String id);
/**
* 删除项目配置及关联子规则,并清除口径内续签待办
* @param id 项目配置ID
*/
R<Boolean> removeByIdAsso(String id);
}
......@@ -29,6 +29,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.yifu.archives.constant.AutoMainRelDeleteTodoStatus;
import com.yifu.cloud.plus.v1.yifu.archives.entity.*;
import com.yifu.cloud.plus.v1.yifu.archives.mapper.*;
import com.yifu.cloud.plus.v1.yifu.archives.service.TAutoMainRelService;
......@@ -141,6 +142,9 @@ public class TAutoMainRelServiceImpl extends ServiceImpl<TAutoMainRelMapper, TAu
@Autowired
private TSettleDomainMapper settleDomainMapper;
@Autowired
private TEmpContractAlertMapper empContractAlertMapper;
public static final String itemsLabel = "label,description,disable";
public static final String itemsLabelRepeat = "同一项目岗位名称不可重复";
......@@ -2596,4 +2600,112 @@ private R<Boolean> checkItemRepeat(List<SysAutoDictItem> autoDictItems, Map<Stri
}
return null;
}
@Override
public R<AutoMainRelDeletePrecheckVo> deletePrecheck(String id) {
if (Common.isEmpty(id)) {
return R.failed(CommonConstants.PARAM_IS_NOT_ERROR);
}
TAutoMainRel mainRel = baseMapper.selectById(id);
if (Common.isEmpty(mainRel)) {
return R.failed("项目配置不存在");
}
String deptNo = mainRel.getDeptNo();
AutoMainRelDeletePrecheckVo vo = new AutoMainRelDeletePrecheckVo();
vo.setDeptNo(deptNo);
TSettleDomain settleDomain = settleDomainMapper.selectOne(Wrappers.<TSettleDomain>query().lambda()
.eq(TSettleDomain::getDepartNo, deptNo)
.eq(TSettleDomain::getDeleteFlag, CommonConstants.ZERO_STRING)
.last(CommonConstants.LAST_ONE_SQL));
if (Common.isNotNull(settleDomain)) {
vo.setDepartName(settleDomain.getDepartName());
}
R<Integer> insuranceCountRes = insuranceDaprUtil.countRenewTodoByDeptNo(deptNo);
if (!R.isSuccess(insuranceCountRes) || insuranceCountRes.getData() == null) {
return R.failed("统计商险续签待办失败:" + (insuranceCountRes != null ? insuranceCountRes.getMsg() : ""));
}
vo.setInsuranceCount(insuranceCountRes.getData());
vo.setContractCount(empContractAlertMapper.countForProjectConfigRemove(
deptNo, AutoMainRelDeleteTodoStatus.CONTRACT_PROCESS_STATUS));
return R.ok(vo);
}
@Override
@Transactional(rollbackFor = Exception.class)
public R<Boolean> removeByIdAsso(String id) {
if (Common.isEmpty(id)) {
return R.failed(CommonConstants.PARAM_IS_NOT_ERROR);
}
TAutoMainRel mainRel = baseMapper.selectById(id);
if (Common.isEmpty(mainRel)) {
return R.failed("项目配置不存在");
}
String deptNo = mainRel.getDeptNo();
log.info("开始删除项目配置,id={}, deptNo={}", id, deptNo);
R<Boolean> insuranceClearRes = insuranceDaprUtil.clearRenewTodoByDeptNo(deptNo);
if (!R.isSuccess(insuranceClearRes)
|| insuranceClearRes.getData() == null
|| !insuranceClearRes.getData()) {
return R.failed("清除商险续签待办失败:" + (insuranceClearRes != null ? insuranceClearRes.getMsg() : ""));
}
int contractPreDeleted = empContractAlertMapper.deleteContractPreNewForProjectConfigRemove(
deptNo, AutoMainRelDeleteTodoStatus.CONTRACT_PROCESS_STATUS);
int contractAlertDeleted = empContractAlertMapper.deleteContractAlertForProjectConfigRemove(
deptNo, AutoMainRelDeleteTodoStatus.CONTRACT_PROCESS_STATUS);
log.info("清除合同续签待办,deptNo={}, preNew={}, alert={}", deptNo, contractPreDeleted, contractAlertDeleted);
cascadeDeleteConfig(mainRel);
return R.ok(true);
}
private void cascadeDeleteConfig(TAutoMainRel mainRel) {
String mainId = mainRel.getId();
String deptNo = mainRel.getDeptNo();
String deptId = mainRel.getDeptId();
TAutoInsurRuleInfo insurRule = autoInsurRuleInfoMapper.selectOne(Wrappers.<TAutoInsurRuleInfo>query().lambda()
.eq(TAutoInsurRuleInfo::getMainId, mainId).last(CommonConstants.LAST_ONE_SQL));
if (Common.isNotNull(insurRule)) {
List<TAutoInsurStandard> standards = autoInsurStandardMapper.selectList(Wrappers.<TAutoInsurStandard>query()
.lambda().eq(TAutoInsurStandard::getMainId, insurRule.getId()));
if (Common.isNotNull(standards)) {
for (TAutoInsurStandard standard : standards) {
autoStandardInfoMapper.delete(Wrappers.<TAutoStandardInfo>query().lambda()
.eq(TAutoStandardInfo::getMainId, standard.getId()));
}
}
autoInsurStandardMapper.delete(Wrappers.<TAutoInsurStandard>query().lambda()
.eq(TAutoInsurStandard::getMainId, insurRule.getId()));
autoInsurRuleInfoMapper.deleteById(insurRule.getId());
}
TAutoContractRuleInfo contractRule = autoContractRuleInfoMapper.selectOne(Wrappers.<TAutoContractRuleInfo>query().lambda()
.eq(TAutoContractRuleInfo::getMainId, mainId).last(CommonConstants.LAST_ONE_SQL));
if (Common.isNotNull(contractRule)) {
contractSchemeMapper.delete(Wrappers.<TAutoContractScheme>query().lambda()
.eq(TAutoContractScheme::getMainId, contractRule.getId()));
autoContractRuleInfoMapper.deleteById(contractRule.getId());
}
if (Common.isNotNull(deptId)) {
autoSocialRuleRelMapper.delete(Wrappers.<TAutoSocialRuleRel>query().lambda()
.eq(TAutoSocialRuleRel::getDeptId, deptId));
autoFundRuleRelMapper.delete(Wrappers.<TAutoFundRuleRel>query().lambda()
.eq(TAutoFundRuleRel::getDeptId, deptId));
}
autoSocialRuleInfoMapper.delete(Wrappers.<TAutoSocialRuleInfo>query().lambda()
.eq(TAutoSocialRuleInfo::getMainId, mainId));
autoFundRuleInfoMapper.delete(Wrappers.<TAutoFundRuleInfo>query().lambda()
.eq(TAutoFundRuleInfo::getMainId, mainId));
autoEmpRuleInfoMapper.delete(Wrappers.<TAutoEmpRuleInfo>query().lambda()
.eq(TAutoEmpRuleInfo::getMainId, mainId));
autoDictItemMapper.delete(Wrappers.<SysAutoDictItem>query().lambda()
.eq(SysAutoDictItem::getDeptNo, deptNo));
baseMapper.deleteById(mainId);
}
}
\ No newline at end of file
......@@ -469,4 +469,39 @@
WHERE b.contract_id = a.CONTRACT_ID
)
</select>
<!-- 项目配置删除:合同续签待办 count/clear(口径见 AutoMainRelDeleteTodoStatus) -->
<select id="countForProjectConfigRemove" resultType="int">
SELECT count(1)
FROM t_emp_contract_alert a
LEFT JOIN t_employee_contract_pre_new b ON a.CONTRACT_ID = b.contract_id
WHERE a.PROJECT_NO = #{deptNo}
AND a.AUTO_FLAG = '0'
AND IFNULL(b.PROCESS_STATUS, '0') IN
<foreach collection="processStatusList" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<delete id="deleteContractPreNewForProjectConfigRemove">
DELETE b FROM t_employee_contract_pre_new b
INNER JOIN t_emp_contract_alert a ON a.CONTRACT_ID = b.contract_id
WHERE a.PROJECT_NO = #{deptNo}
AND a.AUTO_FLAG = '0'
AND b.PROCESS_STATUS IN
<foreach collection="processStatusList" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</delete>
<delete id="deleteContractAlertForProjectConfigRemove">
DELETE a FROM t_emp_contract_alert a
LEFT JOIN t_employee_contract_pre_new b ON a.CONTRACT_ID = b.contract_id
WHERE a.PROJECT_NO = #{deptNo}
AND a.AUTO_FLAG = '0'
AND IFNULL(b.PROCESS_STATUS, '0') IN
<foreach collection="processStatusList" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</delete>
</mapper>
......@@ -314,4 +314,44 @@ public class InsuranceDaprUtil {
return res;
}
/**
* 项目配置删除预检:统计商险续签待办条数
*/
public R<Integer> countRenewTodoByDeptNo(String deptNo) {
BaseSearchVO paramVo = new BaseSearchVO();
paramVo.setDeptNo(deptNo);
R<Integer> res = HttpDaprUtil.invokeMethodPost(
daprInsurancesProperties.getAppUrl(),
daprInsurancesProperties.getAppId(),
"/insuranceWarn/inner/countRenewTodoByDeptNo",
paramVo,
Integer.class,
SecurityConstants.FROM_IN
);
if (Common.isEmpty(res)) {
return R.failed("统计商险续签待办失败!");
}
return res;
}
/**
* 项目配置删除:清除口径内商险续签待办
*/
public R<Boolean> clearRenewTodoByDeptNo(String deptNo) {
BaseSearchVO paramVo = new BaseSearchVO();
paramVo.setDeptNo(deptNo);
R<Boolean> res = HttpDaprUtil.invokeMethodPost(
daprInsurancesProperties.getAppUrl(),
daprInsurancesProperties.getAppId(),
"/insuranceWarn/inner/clearRenewTodoByDeptNo",
paramVo,
Boolean.class,
SecurityConstants.FROM_IN
);
if (Common.isEmpty(res)) {
return R.failed("清除商险续签待办失败!");
}
return res;
}
}
......@@ -220,6 +220,27 @@ public class TInsurancesWarnController {
}
}
@Operation(description = "项目配置删除预检:统计商险续签待办条数")
@Inner
@PostMapping("/inner/countRenewTodoByDeptNo")
public Integer countRenewTodoByDeptNo(@RequestBody(required = false) BaseSearchVO paramVo) {
String deptNo = Common.isNotNull(paramVo) ? paramVo.getDeptNo() : null;
return insuranceWarnService.countRenewTodoByDeptNo(deptNo);
}
@Operation(description = "项目配置删除:清除口径内商险续签待办")
@Inner
@PostMapping("/inner/clearRenewTodoByDeptNo")
public Boolean clearRenewTodoByDeptNo(@RequestBody(required = false) BaseSearchVO paramVo) {
try {
String deptNo = Common.isNotNull(paramVo) ? paramVo.getDeptNo() : null;
insuranceWarnService.clearRenewTodoByDeptNo(deptNo);
return true;
} catch (Exception e) {
return false;
}
}
/**
* @Author fxj
* @Description 每日09:00推送一条整合的待办数据——只推送前端客服,详情去HRO处理——消息待定:项目名称-项目编码、商险临期人数:**;商险过期人数:**;
......
......@@ -63,4 +63,13 @@ public interface TInsuranceWarnMapper extends BaseMapper<TInsuranceAlert> {
List<TInsuranceAlert> selectInsuranceAlertListBySure(@Param("idList") List<String> idList);
TInsuranceAlert selectInsuranceAlertOne(@Param("id") String id);
int countRenewTodoByDeptNo(@Param("deptNo") String deptNo,
@Param("processStatusList") List<String> processStatusList);
int deleteRenewDetailByDeptNo(@Param("deptNo") String deptNo,
@Param("processStatusList") List<String> processStatusList);
int deleteAlertForRenewTodoByDeptNo(@Param("deptNo") String deptNo,
@Param("processStatusList") List<String> processStatusList);
}
......@@ -31,4 +31,8 @@ public interface TInsuranceWarnService extends IService<TInsuranceAlert> {
void pushInsuranceAlertToWx();
int countRenewTodoByDeptNo(String deptNo);
void clearRenewTodoByDeptNo(String deptNo);
}
......@@ -39,6 +39,7 @@ import com.yifu.cloud.plus.v1.yifu.insurances.util.LocalDateUtil;
import com.yifu.cloud.plus.v1.yifu.insurances.vo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestTemplate;
import javax.servlet.ServletOutputStream;
......@@ -808,4 +809,24 @@ public class TInsuranceWarnServiceImpl extends ServiceImpl<TInsuranceWarnMapper,
}
}
}
private static final List<String> RENEW_TODO_PROCESS_STATUS = Arrays.asList("0", "1");
@Override
public int countRenewTodoByDeptNo(String deptNo) {
if (Common.isEmpty(deptNo)) {
return 0;
}
return baseMapper.countRenewTodoByDeptNo(deptNo, RENEW_TODO_PROCESS_STATUS);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void clearRenewTodoByDeptNo(String deptNo) {
if (Common.isEmpty(deptNo)) {
return;
}
baseMapper.deleteRenewDetailByDeptNo(deptNo, RENEW_TODO_PROCESS_STATUS);
baseMapper.deleteAlertForRenewTodoByDeptNo(deptNo, RENEW_TODO_PROCESS_STATUS);
}
}
\ No newline at end of file
......@@ -773,4 +773,40 @@
AND b.id = #{id}
limit 1
</select>
<!-- 项目配置删除:商险续签待办 count/clear(process_status 口径由调用方传入,默认 0/1) -->
<sql id="renewTodoByDeptNoWhere">
a.DEPT_NO = #{deptNo}
AND a.EXPIRE_IGNORE_FLAG = '1'
AND a.DELETE_FLAG = 0
AND b.is_leave = '0'
AND a.IS_OVERDUE = 0
AND (a.REPLACE_TAG IS NULL OR a.REPLACE_TAG != '可替换')
AND b.PROCESS_STATUS IN
<foreach collection="processStatusList" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</sql>
<select id="countRenewTodoByDeptNo" resultType="int">
SELECT count(1)
FROM t_insurance_alert a
JOIN t_insurance_pre_renew_detail b ON a.INSURANCES_PRE_RENEW_DETAIL_ID = b.ID
WHERE
<include refid="renewTodoByDeptNoWhere"/>
</select>
<delete id="deleteRenewDetailByDeptNo">
DELETE b FROM t_insurance_pre_renew_detail b
INNER JOIN t_insurance_alert a ON a.INSURANCES_PRE_RENEW_DETAIL_ID = b.ID
WHERE
<include refid="renewTodoByDeptNoWhere"/>
</delete>
<delete id="deleteAlertForRenewTodoByDeptNo">
DELETE a FROM t_insurance_alert a
INNER JOIN t_insurance_pre_renew_detail b ON a.INSURANCES_PRE_RENEW_DETAIL_ID = b.ID
WHERE
<include refid="renewTodoByDeptNoWhere"/>
</delete>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment