369 lines
10 KiB
XML
369 lines
10 KiB
XML
<?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.nis.web.dao.SchedulerDao" >
|
|
|
|
<resultMap type="com.nis.domain.ScheduleCfg" id="scheduleCfgMap">
|
|
<id property="id" column="id"/>
|
|
<result property="name" column="name"/>
|
|
<result property="cronValid" column="cron_valid"/>
|
|
<result property="cronInvalid" column="cron_invalid"/>
|
|
<result property="cfgId" column="cfg_id"/>
|
|
<result property="compileId" column="compile_id"/>
|
|
<result property="serviceId" column="service_id"/>
|
|
<result property="isValid" column="is_valid"/>
|
|
<result property="isAudit" column="is_audit"/>
|
|
<result property="functionId" column="function_id"/>
|
|
<result property="creatorId" column="creator_id"/>
|
|
<result property="createTime" column="create_time"/>
|
|
<result property="editorId" column="editor_id"/>
|
|
<result property="editTime" column="edit_time"/>
|
|
<result property="tableName" column="table_name"/>
|
|
<result property="userRegion1" column="user_region1"/>
|
|
<result property="userRegion2" column="user_region2"/>
|
|
<result property="userRegion3" column="user_region3"/>
|
|
<result property="userRegion4" column="user_region4"/>
|
|
<result property="userRegion5" column="user_region5"/>
|
|
<result property="delFlag" column="del_flag"/>
|
|
<result property="type" column="type"/>
|
|
</resultMap>
|
|
|
|
|
|
<resultMap type="com.nis.domain.ScheduleExceInfo" id="scheduleExceInfoMap">
|
|
<id property="id" column="id"/>
|
|
<result property="scheduleId" column="schedule_id"/>
|
|
<result property="exceTime" column="exce_time"/>
|
|
<result property="issueStatus" column="issue_status"/>
|
|
<result property="issueResult" column="issue_result"/>
|
|
<result property="errorInfo" column="error_info"/>
|
|
<result property="compileId" column="compile_id"/>
|
|
<result property="isIssue" column="is_issue"/>
|
|
</resultMap>
|
|
|
|
|
|
<resultMap id="baseCfgMap" type="com.nis.domain.configuration.BaseCfg" >
|
|
<id column="cfg_id" property="cfgId" jdbcType="BIGINT" />
|
|
<result column="cfg_desc" property="cfgDesc" jdbcType="VARCHAR" />
|
|
<result column="action" property="action" jdbcType="INTEGER" />
|
|
<result column="is_valid" property="isValid" jdbcType="INTEGER" />
|
|
<result column="is_audit" property="isAudit" jdbcType="INTEGER" />
|
|
<result column="creator_id" property="creatorId" jdbcType="INTEGER" />
|
|
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
|
|
<result column="editor_id" property="editorId" jdbcType="INTEGER" />
|
|
<result column="edit_time" property="editTime" jdbcType="TIMESTAMP" />
|
|
<result column="auditor_id" property="auditorId" jdbcType="INTEGER" />
|
|
<result column="audit_time" property="auditTime" jdbcType="TIMESTAMP" />
|
|
<result column="service_id" property="serviceId" jdbcType="INTEGER" />
|
|
<result column="request_id" property="requestId" jdbcType="INTEGER" />
|
|
<result column="compile_id" property="compileId" jdbcType="INTEGER" />
|
|
<result column="is_area_effective" property="isAreaEffective" jdbcType="INTEGER" />
|
|
<result column="classify" property="classify" jdbcType="VARCHAR" />
|
|
<result column="attribute" property="attribute" jdbcType="VARCHAR" />
|
|
<result column="lable" property="lable" jdbcType="VARCHAR" />
|
|
<result column="area_effective_ids" property="areaEffectiveIds" jdbcType="VARCHAR" />
|
|
<result column="function_id" property="functionId" jdbcType="INTEGER" />
|
|
<result column="do_log" property="doLog" jdbcType="INTEGER" />
|
|
<result column="do_blacklist" property="doBlackList" jdbcType="INTEGER" />
|
|
</resultMap>
|
|
|
|
|
|
<sql id="scheduleCfgColumns">
|
|
a.ID,
|
|
a.NAME,
|
|
a.cron_valid,
|
|
a.cron_invalid,
|
|
a.SERVICE_ID,
|
|
a.COMPILE_ID,
|
|
a.CFG_ID,
|
|
a.IS_VALID,
|
|
a.IS_AUDIT,
|
|
a.function_id,
|
|
a.CREATOR_ID,
|
|
a.CREATE_TIME,
|
|
a.EDITOR_ID,
|
|
a.EDIT_TIME,
|
|
a.table_name,
|
|
a.user_region1,
|
|
a.user_region2,
|
|
a.user_region3,
|
|
a.user_region4,
|
|
a.user_region5
|
|
</sql>
|
|
|
|
<select id="findScheduleList" resultMap="scheduleCfgMap">
|
|
select
|
|
<include refid="scheduleCfgColumns"/>
|
|
from schedule_cfg a
|
|
<where>
|
|
<if test="id != null">
|
|
and id = #{id}
|
|
</if>
|
|
<if test="compileId != null">
|
|
and compile_id = #{compileId}
|
|
</if>
|
|
<if test="isValid != null">
|
|
and IS_VALID = #{isValid}
|
|
</if>
|
|
<if test="isAudit != null">
|
|
and IS_AUDIT = #{isAudit}
|
|
</if>
|
|
<if test="compileId != null">
|
|
and CFG_ID = #{cfgId}
|
|
</if>
|
|
<if test="functionId != null">
|
|
and function_id = #{functionId}
|
|
</if>
|
|
<if test="tableName != null and tableName != ''">
|
|
and table_name = #{tableName}
|
|
</if>
|
|
and type = 1
|
|
<!-- del_Flag = #{DEL_FLAG_NORMAL} -->
|
|
and name is null
|
|
<!-- 动态where条件 -->
|
|
<if test=" whereStr != null and whereStr !=''">
|
|
${whereStr}
|
|
</if>
|
|
</where>
|
|
order by a.id desc
|
|
</select>
|
|
|
|
<!-- 查找最新的更新数据 -->
|
|
<select id="get" resultType="com.nis.domain.ScheduleCfg">
|
|
select
|
|
a.ID,
|
|
a.NAME,
|
|
a.cron_valid,
|
|
a.cron_invalid,
|
|
a.SERVICE_ID,
|
|
a.COMPILE_ID,
|
|
a.CFG_ID,
|
|
a.IS_VALID,
|
|
a.IS_AUDIT,
|
|
a.function_id,
|
|
a.CREATOR_ID,
|
|
a.CREATE_TIME,
|
|
a.EDITOR_ID,
|
|
a.EDIT_TIME,
|
|
a.table_name,
|
|
a.user_region1,
|
|
a.user_region2,
|
|
a.user_region3,
|
|
a.user_region4,
|
|
a.user_region5,
|
|
a.del_flag,
|
|
a.type
|
|
from schedule_cfg a
|
|
<where>
|
|
and id = #{id}
|
|
</where>
|
|
</select>
|
|
<!-- 查找最新的更新数据 -->
|
|
<select id="findNewlyCfg" resultMap="scheduleCfgMap">
|
|
select
|
|
a.ID,
|
|
a.NAME,
|
|
a.cron_valid,
|
|
a.cron_invalid,
|
|
a.SERVICE_ID,
|
|
a.COMPILE_ID,
|
|
a.CFG_ID,
|
|
a.IS_VALID,
|
|
a.IS_AUDIT,
|
|
a.function_id,
|
|
a.CREATOR_ID,
|
|
a.CREATE_TIME,
|
|
a.EDITOR_ID,
|
|
a.EDIT_TIME,
|
|
a.table_name,
|
|
a.user_region1,
|
|
a.user_region2,
|
|
a.user_region3,
|
|
a.user_region4,
|
|
a.user_region5,
|
|
a.del_flag,
|
|
a.type
|
|
from schedule_cfg a
|
|
<where>
|
|
and id > #{id}
|
|
and type=#{type}
|
|
<if test=" delFlag != null">
|
|
and del_flag = #{delFlag}
|
|
</if>
|
|
</where>
|
|
order by a.id
|
|
limit #{limit}
|
|
</select>
|
|
|
|
|
|
|
|
<insert id="insert" parameterType="com.nis.domain.ScheduleCfg" useGeneratedKeys="true" keyProperty="id" >
|
|
insert into schedule_cfg (
|
|
NAME,
|
|
cron_valid,
|
|
cron_invalid,
|
|
SERVICE_ID,
|
|
COMPILE_ID,
|
|
CFG_ID,
|
|
IS_VALID,
|
|
IS_AUDIT,
|
|
function_id,
|
|
CREATOR_ID,
|
|
CREATE_TIME,
|
|
EDITOR_ID,
|
|
EDIT_TIME,
|
|
table_name,
|
|
user_region1,
|
|
user_region2,
|
|
user_region3,
|
|
user_region4,
|
|
user_region5,
|
|
del_flag,
|
|
type
|
|
) values (
|
|
#{name,jdbcType=VARCHAR},
|
|
#{cronValid,jdbcType=VARCHAR},
|
|
#{cronInvalid,jdbcType=VARCHAR},
|
|
#{serviceId,jdbcType=INTEGER},
|
|
#{compileId,jdbcType=INTEGER},
|
|
#{cfgId,jdbcType=INTEGER},
|
|
#{isValid,jdbcType=INTEGER},
|
|
#{isAudit,jdbcType=INTEGER},
|
|
#{functionId,jdbcType=INTEGER},
|
|
#{creatorId,jdbcType=INTEGER},
|
|
#{createTime,jdbcType=TIMESTAMP},
|
|
#{editorId,jdbcType=INTEGER},
|
|
#{editTime,jdbcType=TIMESTAMP},
|
|
#{tableName,jdbcType=VARCHAR},
|
|
#{userRegion1,jdbcType=VARCHAR},
|
|
#{userRegion2,jdbcType=VARCHAR},
|
|
#{userRegion3,jdbcType=VARCHAR},
|
|
#{userRegion4,jdbcType=VARCHAR},
|
|
#{userRegion5,jdbcType=VARCHAR},
|
|
#{delFlag,jdbcType=INTEGER},
|
|
#{type,jdbcType=INTEGER}
|
|
)
|
|
</insert>
|
|
|
|
<!-- 根据 compileIds 将定时任务失效,定时任务的修改策略为:删除之前的所有配置,新增 -->
|
|
<update id="inValidByCompileIds" parameterType="com.nis.domain.ScheduleCfg">
|
|
update schedule_cfg
|
|
<set>
|
|
del_flag = 0
|
|
</set>
|
|
WHERE compile_Id in (${compileIds}) and del_flag =1
|
|
</update>
|
|
<!-- 根据 compileIds 将定时任务删除 -->
|
|
<update id="deleteByCompileIds">
|
|
delete from schedule_cfg
|
|
WHERE compile_Id in (${compileIds}) and type=#{type}
|
|
</update>
|
|
|
|
|
|
<!-- 查找 配置 下发 最新记录 -->
|
|
<select id="findScheduleExceNew" resultMap="scheduleExceInfoMap" >
|
|
SELECT
|
|
id,
|
|
schedule_id,
|
|
exce_time,
|
|
issue_status,
|
|
issue_result,
|
|
error_info,
|
|
compile_id,
|
|
is_issue
|
|
FROM
|
|
schedule_exce_new
|
|
WHERE
|
|
compile_id = #{compileId} and issue_status = #{isValid}
|
|
</select>
|
|
|
|
|
|
<!-- 修改配置表状态 -->
|
|
<update id="updateCfgTableStatus">
|
|
update ${tableName}
|
|
<set>
|
|
is_valid = #{isValid} ,
|
|
is_audit = 1,
|
|
<!-- <if test="isValid == 0 ">
|
|
is_audit = 3,
|
|
</if>
|
|
<if test="isValid == 1 ">
|
|
is_audit = 1,
|
|
</if> -->
|
|
audit_time=now(),
|
|
</set>
|
|
where compile_id = #{compileId}
|
|
</update>
|
|
|
|
<!-- 查询最新的配置状态 -->
|
|
<select id="getCfgTableInfo" resultMap="baseCfgMap">
|
|
select * from ${tableName} where compile_id = #{compileId};
|
|
</select>
|
|
|
|
<!-- 保存执行记录 -->
|
|
<insert id="insertScheduleExceLog" parameterType="com.nis.domain.ScheduleExceInfo">
|
|
INSERT INTO schedule_exce_log (
|
|
schedule_id,
|
|
exce_time,
|
|
issue_status,
|
|
issue_result,
|
|
error_info,
|
|
compile_id,
|
|
is_issue
|
|
) VALUES (
|
|
#{scheduleId},
|
|
#{exceTime},
|
|
#{issueStatus},
|
|
#{issueResult},
|
|
#{errorInfo},
|
|
#{compileId},
|
|
0
|
|
);
|
|
</insert>
|
|
|
|
<!-- 保存最新记录表 -->
|
|
<insert id="insertScheduleExceNew" parameterType="com.nis.domain.ScheduleExceInfo">
|
|
INSERT INTO schedule_exce_new (
|
|
schedule_id,
|
|
exce_time,
|
|
issue_status,
|
|
issue_result,
|
|
error_info,
|
|
compile_id,
|
|
is_issue
|
|
) VALUES (
|
|
#{scheduleId},
|
|
#{exceTime},
|
|
#{issueStatus},
|
|
#{issueResult},
|
|
#{errorInfo},
|
|
#{compileId},
|
|
0
|
|
);
|
|
</insert>
|
|
|
|
<!-- 更新最新记录表 -->
|
|
<update id="updateScheduleExceNew" parameterType="com.nis.domain.ScheduleExceInfo">
|
|
UPDATE schedule_exce_new
|
|
<set>
|
|
<if test="scheduleId != null">
|
|
schedule_id = #{scheduleId},
|
|
</if>
|
|
<if test=" exceTime != null">
|
|
exce_time = #{exceTime},
|
|
</if>
|
|
<if test=" issueResult != null">
|
|
issue_result = #{issueResult},
|
|
</if>
|
|
<if test=" errorInfo != null">
|
|
error_info = #{errorInfo},
|
|
</if>
|
|
<if test=" isIssue != null">
|
|
is_issue = #{isIssue},
|
|
</if>
|
|
</set>
|
|
WHERE
|
|
compile_Id = #{compileId} and issue_status = #{issueStatus}
|
|
</update>
|
|
|
|
|
|
|
|
</mapper> |