commit
5b2ab89a06
@ -0,0 +1,17 @@
|
||||
package com.engine.organization.mapper.common;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* @description: TODO
|
||||
* @author:dxfeng
|
||||
* @createTime: 2022/06/01
|
||||
* @version: 1.0
|
||||
*/
|
||||
public interface RefreshUseMapper {
|
||||
int updateIsUsedByIds(@Param("tableName") String tableName, @Param("ids") Collection<String> ids, @Param("isUsed") int isUsed);
|
||||
|
||||
int initIsUseStatus(@Param("tableName") String tableName);
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.engine.organization.mapper.common.RefreshUseMapper">
|
||||
|
||||
<update id="updateIsUsedByIds">
|
||||
update ${tableName} set is_used = #{isUsed} where delete_type = 0 and id
|
||||
<if test=" isUsed == 0 ">
|
||||
not
|
||||
</if>
|
||||
in
|
||||
<foreach collection="ids" open="(" item="id" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</update>
|
||||
<update id="initIsUseStatus">
|
||||
update ${tableName}
|
||||
set is_used = 0
|
||||
where delete_type = 0
|
||||
</update>
|
||||
</mapper>
|
@ -0,0 +1,115 @@
|
||||
package com.engine.organization.util;
|
||||
|
||||
import com.engine.organization.mapper.common.RefreshUseMapper;
|
||||
import com.engine.organization.mapper.scheme.GradeMapper;
|
||||
import com.engine.organization.mapper.scheme.LevelMapper;
|
||||
import com.engine.organization.mapper.scheme.SchemeMapper;
|
||||
import com.engine.organization.mapper.sequence.SequenceMapper;
|
||||
import com.engine.organization.mapper.staff.StaffMapper;
|
||||
import com.engine.organization.mapper.staff.StaffPlanMapper;
|
||||
import com.engine.organization.util.db.MapperProxyFactory;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @description: TODO
|
||||
* @author:dxfeng
|
||||
* @createTime: 2022/06/01
|
||||
* @version: 1.0
|
||||
*/
|
||||
public class RefreshIsUsedUtil {
|
||||
|
||||
private static RefreshUseMapper getRefreshUseMapper() {
|
||||
return MapperProxyFactory.getProxy(RefreshUseMapper.class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 刷新等级方案表 引用状态
|
||||
* <p>
|
||||
* JCL_ORG_LEVEL,JCL_ORG_GRADE,JCL_ORG_SEQUENCE,JCL_ORG_JOB
|
||||
*/
|
||||
public static void RefreshScheme(String tableName) {
|
||||
List<String> usedIds = MapperProxyFactory.getProxy(SchemeMapper.class).listUsedId();
|
||||
usedIds.removeIf(Objects::isNull);
|
||||
RefreshIsUsedStatus(tableName, usedIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新职等表 引用状态
|
||||
* <p>
|
||||
* JCL_ORG_GRADE,JCL_ORG_JOBDT
|
||||
*/
|
||||
public static void RefreshLevel(String tableName) {
|
||||
List<String> usedIds = MapperProxyFactory.getProxy(LevelMapper.class).listUsedId();
|
||||
usedIds.removeIf(Objects::isNull);
|
||||
RefreshIsUsedStatus(tableName, usedIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新职级表 引用状态
|
||||
* <p>
|
||||
* JCL_ORG_JOBDT
|
||||
*/
|
||||
public static void RefreshGrade(String tableName) {
|
||||
List<String> usedIds = MapperProxyFactory.getProxy(GradeMapper.class).listUsedId();
|
||||
usedIds.removeIf(Objects::isNull);
|
||||
RefreshIsUsedStatus(tableName, usedIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新岗位序列表 引用状态
|
||||
* <p>
|
||||
* JCL_ORG_JOB
|
||||
*/
|
||||
public static void RefreshSequence(String tableName) {
|
||||
List<String> usedIds = MapperProxyFactory.getProxy(SequenceMapper.class).listUsedId();
|
||||
usedIds.removeIf(Objects::isNull);
|
||||
RefreshIsUsedStatus(tableName, usedIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新编制方案列表 引用状态
|
||||
* <p>
|
||||
* JCL_ORG_JOB
|
||||
*/
|
||||
public static void RefreshStaffPlan(String tableName) {
|
||||
List<String> usedIds = MapperProxyFactory.getProxy(StaffPlanMapper.class).listUsedId();
|
||||
usedIds.removeIf(Objects::isNull);
|
||||
RefreshIsUsedStatus(tableName, usedIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新编制表列表 引用状态
|
||||
* <p>
|
||||
* JCL_ORG_JOB
|
||||
*/
|
||||
public static void RefreshStaff(String tableName) {
|
||||
List<String> usedIds = MapperProxyFactory.getProxy(StaffMapper.class).listUsedId();
|
||||
usedIds.removeIf(Objects::isNull);
|
||||
RefreshIsUsedStatus(tableName, usedIds);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 更新指定表的引用状态
|
||||
*
|
||||
* @param tableName
|
||||
* @param usedIds
|
||||
*/
|
||||
private static void RefreshIsUsedStatus(String tableName, List<String> usedIds) {
|
||||
if (CollectionUtils.isNotEmpty(usedIds)) {
|
||||
List<String> collect = Arrays.stream(String.join(",", usedIds).split(",")).collect(Collectors.toList());
|
||||
getRefreshUseMapper().updateIsUsedByIds(tableName, collect, 0);
|
||||
getRefreshUseMapper().updateIsUsedByIds(tableName, collect, 1);
|
||||
}else{
|
||||
getRefreshUseMapper().initIsUseStatus(tableName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue