<?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.gkhy.safePlatform.specialWork.repository.ApprovalRuleUnitItemRepository" >
|
<resultMap id="BaseResultMap" type="com.gkhy.safePlatform.specialWork.entity.ApprovalRuleUnitItem" >
|
<id column="id" property="id" jdbcType="BIGINT" />
|
<result column="rule_id" property="ruleId" jdbcType="BIGINT"/>
|
<result column="item_name" property="itemName" jdbcType="VARCHAR"/>
|
<result column="step_id" property="stepId" jdbcType="BIGINT"/>
|
<result column="unit_id" property="unitId" jdbcType="BIGINT"/>
|
<result column="type" property="type" jdbcType="TINYINT"/>
|
<result column="stand_id" property="standId" jdbcType="BIGINT"/>
|
<result column="measure_id" property="measureId" jdbcType="BIGINT"/>
|
<result column="status" property="status" jdbcType="TINYINT"/>
|
<result column="gmt_create" property="gmtCreate" jdbcType="TIMESTAMP"/>
|
<result column="create_uname" property="createUname" jdbcType="VARCHAR"/>
|
<result column="create_uid" property="createUid" jdbcType="BIGINT"/>
|
<result column="gmt_modified" property="gmtModified" jdbcType="TIMESTAMP"/>
|
<result column="modified_uname" property="modifiedUname" jdbcType="VARCHAR"/>
|
<result column="modified_uid" property="modifiedUid" jdbcType="BIGINT"/>
|
</resultMap>
|
|
<resultMap id="ApprovalRuleUnitItemDO" type="com.gkhy.safePlatform.specialWork.entity.ApprovalRuleUnitItemDO" >
|
<id column="id" property="id" jdbcType="BIGINT" />
|
<result column="rule_id" property="ruleId" jdbcType="BIGINT"/>
|
<result column="item_name" property="itemName" jdbcType="VARCHAR"/>
|
<result column="step_id" property="stepId" jdbcType="BIGINT"/>
|
<result column="unit_id" property="unitId" jdbcType="BIGINT"/>
|
<result column="type" property="type" jdbcType="TINYINT"/>
|
<result column="measure_id" property="measureId" jdbcType="BIGINT"/>
|
<result column="stand_id" property="standId" jdbcType="BIGINT"/>
|
<result column="status" property="status" jdbcType="TINYINT"/>
|
</resultMap>
|
|
<resultMap id="ApprovalRuleUnitItem" type="com.gkhy.safePlatform.specialWork.entity.ApprovalRuleUnitItem" >
|
<id column="id" property="id" jdbcType="BIGINT" />
|
<result column="rule_id" property="ruleId" jdbcType="BIGINT"/>
|
<result column="item_name" property="itemName" jdbcType="VARCHAR"/>
|
<result column="step_id" property="stepId" jdbcType="BIGINT"/>
|
<result column="unit_id" property="unitId" jdbcType="BIGINT"/>
|
<result column="type" property="type" jdbcType="TINYINT"/>
|
<result column="stand_id" property="standId" jdbcType="BIGINT"/>
|
<result column="measure_id" property="measureId" jdbcType="BIGINT"/>
|
<result column="status" property="status" jdbcType="TINYINT"/>
|
<result column="gmt_create" property="gmtCreate" jdbcType="TIMESTAMP"/>
|
<result column="create_uname" property="createUname" jdbcType="VARCHAR"/>
|
<result column="create_uid" property="createUid" jdbcType="BIGINT"/>
|
<result column="gmt_modified" property="gmtModified" jdbcType="TIMESTAMP"/>
|
<result column="modified_uname" property="modifiedUname" jdbcType="VARCHAR"/>
|
<result column="modified_uid" property="modifiedUid" jdbcType="BIGINT"/>
|
</resultMap>
|
|
<sql id="all_Column_List" >
|
<!-- -->
|
id,item_name,rule_id,step_id,unit_id,type,stand_id,measure_id,status,gmt_create,create_uname,create_uid,gmt_modified,modified_uname,modified_uid
|
</sql>
|
<sql id="insert_columns" >
|
<!-- -->
|
(id,rule_id,item_name,step_id,unit_id,type,stand_id,measure_id,status,gmt_create,create_uname,create_uid,gmt_modified,modified_uname,modified_uid)
|
</sql>
|
<sql id="base_table_name">approval_rule_item</sql>
|
|
<insert id="batchInsert">
|
insert into approval_rule_item <include refid="insert_columns"></include> values
|
<foreach collection="itemList" item="item" index="index" separator=",">
|
(#{item.id},#{item.ruleId},#{item.itemName},#{item.stepId},#{item.unitId},#{item.type},#{item.standId},#{item.measureId},#{item.status},#{item.gmtCreate},#{item.createUname},#{item.createUid},#{item.gmtModified},#{item.modifiedUname},#{item.modifiedUid})
|
</foreach>
|
</insert>
|
<insert id="insertRuleItem"
|
parameterType="com.gkhy.safePlatform.specialWork.entity.ApprovalRuleUnitItem" >
|
insert
|
into approval_rule_item
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="itemName != null and itemName != ''">
|
item_name,
|
</if>
|
<if test="type != null">
|
type,
|
</if>
|
<if test="standId != null">
|
stand_id,
|
</if>
|
<if test="measureId != null">
|
measure_id,
|
</if>
|
<if test="status != null">
|
status,
|
</if>
|
<if test="gmtCreate != null">
|
gmt_create,
|
</if>
|
<if test="createUname != null">
|
create_uname,
|
</if>
|
<if test="createUid != null">
|
create_uid,
|
</if>
|
</trim>
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<if test="itemName != null and itemName != ''">
|
#{itemName},
|
</if>
|
<if test="type != null">
|
#{type},
|
</if>
|
<if test="standId != null">
|
#{standId},
|
</if>
|
<if test="measureId != null">
|
#{measureId},
|
</if>
|
<if test="status != null">
|
#{status},
|
</if>
|
<if test="gmtCreate != null">
|
#{gmtCreate},
|
</if>
|
<if test="createUname != null">
|
#{createUname},
|
</if>
|
<if test="createUid != null">
|
#{createUid},
|
</if>
|
</trim>
|
|
|
|
</insert>
|
|
|
<select id="listActiveByRuleId" resultMap="BaseResultMap">
|
select id,item_name,rule_id,step_id,unit_id,type,stand_id,measure_id from <include refid="base_table_name"></include>
|
where
|
rule_id = #{ruleId} and status = #{status}
|
</select>
|
|
<select id="listActiveByRuleStepId" resultMap="BaseResultMap">
|
select <include refid="all_Column_List"></include> from <include refid="base_table_name"></include>
|
where
|
step_id = #{stepId} and status = #{status}
|
</select>
|
|
<!--根据standIds查询-->
|
<select id="listActiveByRuleStandId" resultMap="BaseResultMap">
|
select <include refid="all_Column_List"></include>
|
from <include refid="base_table_name"></include>
|
<where>
|
status = #{status}
|
and stand_id in
|
<foreach collection="standIdList" item="standId" open="(" close=")" separator=",">
|
#{standId}
|
</foreach>
|
</where>
|
</select>
|
<select id="getApprovalRuleUnitItemDOById"
|
parameterType="long"
|
resultMap="ApprovalRuleUnitItemDO">
|
select
|
ruleItem.id,
|
ruleItem.item_name,
|
ruleItem.rule_id,
|
ruleItem.step_id,
|
ruleItem.unit_id,
|
ruleItem.type,
|
ruleItem.stand_id,
|
ruleItem.status
|
from approval_rule_item as ruleItem
|
where ruleItem.id = #{ruleItemId}
|
|
</select>
|
<select id="listRuleItemByPage"
|
parameterType="com.gkhy.safePlatform.specialWork.model.query.db.ApprovalRuleItemPageDBQuery"
|
resultMap="ApprovalRuleUnitItem">
|
|
select
|
ruleItem.id,
|
ruleItem.item_name,
|
ruleItem.rule_id,
|
ruleItem.step_id,
|
ruleItem.unit_id,
|
ruleItem.type,
|
ruleItem.stand_id,
|
ruleItem.status,
|
ruleItem.create_uid,
|
ruleItem.create_uname,
|
ruleItem.gmt_create,
|
ruleItem.modified_uid,
|
ruleItem.modified_uname,
|
ruleItem.gmt_modified
|
from approval_rule_item as ruleItem
|
<where>
|
<if test="query.status != null">
|
ruleItem.status = #{query.status}
|
</if>
|
<if test="query.itemName != null and query.itemName != ''">
|
ruleItem.item_name like concat("%",#{query.itemName},"%")
|
</if>
|
<if test="query.type != null">
|
ruleItem.type = #{type}
|
</if>
|
</where>
|
|
|
</select>
|
<select id="listRuleItemDO"
|
|
resultMap="ApprovalRuleUnitItemDO">
|
select
|
ruleItem.id,
|
ruleItem.item_name,
|
ruleItem.rule_id,
|
ruleItem.step_id,
|
ruleItem.unit_id,
|
ruleItem.type,
|
ruleItem.stand_id,
|
ruleItem.status
|
from approval_rule_item as ruleItem
|
<where>
|
<if test="query.status != null">
|
ruleItem.status = #{query.status}
|
</if>
|
<if test="query.itemName != null and query.itemName != ''">
|
ruleItem.item_name like concat("%",#{query.itemName},"%")
|
</if>
|
<if test="query.type != null">
|
ruleItem.type = #{type}
|
</if>
|
</where>
|
</select>
|
|
<!--根据审批项itemIds 批量删除-->
|
<update id="updateStatusByIds">
|
update <include refid="base_table_name"></include>
|
set status = #{status}
|
where
|
id in
|
<foreach collection="ids" item="id" open="(" close=")" separator=",">
|
#{id}
|
</foreach>
|
</update>
|
<!--根据审批项itemId 删除-->
|
<update id="updateStatusById">
|
update <include refid="base_table_name"></include>
|
set status = #{status}
|
where
|
id = #{id}
|
</update>
|
|
<!--根据层级stepIds 批量删除-->
|
<update id="updateStatusByStepIds">
|
update <include refid="base_table_name"></include>
|
set status = #{status}
|
where
|
step_id in
|
<foreach collection="stepIds" item="stepId" open="(" close=")" separator=",">
|
#{stepId}
|
</foreach>
|
</update>
|
<!--根据单元层级stepId 删除-->
|
<update id="updateStatusByStepId">
|
update <include refid="base_table_name"></include>
|
set status = #{status}
|
where
|
stand_id = #{stepId}
|
</update>
|
|
<!--根据规则ids 批量删除-->
|
<update id="updateStatusByRuleIds">
|
update <include refid="base_table_name"></include>
|
set status = #{status}
|
where
|
rule_id in
|
<foreach collection="ruleIds" item="ruleId" open="(" close=")" separator=",">
|
#{ruleId}
|
</foreach>
|
</update>
|
|
<!--根据规则id 删除-->
|
<update id="updateStatusByRuleId">
|
update <include refid="base_table_name"></include>
|
set status = #{status}
|
where
|
rule_id = #{ruleId}
|
</update>
|
<update id="updateRuleItem"
|
parameterType="com.gkhy.safePlatform.specialWork.entity.ApprovalRuleUnitItem" >
|
update approval_rule_item
|
<set>
|
<if test="itemName != null and itemName != ''">
|
item_name = #{itemName},
|
</if>
|
<if test="type != null">
|
type = #{type},
|
</if>
|
<if test="standId != null">
|
stand_id = #{standId},
|
</if>
|
<if test="status != null">
|
status = #{status},
|
</if>
|
<if test="gmtModified != null">
|
gmt_modified = #{gmtModified},
|
</if>
|
<if test="modifiedUname != null">
|
modified_uname = #{modifiedUname},
|
</if>
|
<if test="modifiedUid != null">
|
modified_uid = #{modifiedUid},
|
</if>
|
</set>
|
where id = #{id}
|
|
</update>
|
<update id="updateStatusBatch"
|
parameterType="com.gkhy.safePlatform.specialWork.model.update.EntityStatusBatchUO">
|
update approval_rule_item
|
<set>
|
status = #{status},
|
modified_uname = #{modifiedUname},
|
modified_uid = #{modifiedUid},
|
gmt_modified = #{gmtModified},
|
</set>
|
where id in
|
<foreach collection="ids" item="id" open="(" close=")" separator=",">
|
#{id}
|
</foreach>
|
</update>
|
|
<select id="countByMeasureIds" resultType="java.lang.Integer">
|
select count(1) from approval_rule_item where status = #{status} and measure_id in
|
<foreach collection="measureIds" item="measureId" open="(" close=")" separator=",">
|
#{measureId}
|
</foreach>
|
</select>
|
<!--批量更新-->
|
<update id="updateItemBatch" parameterType="java.util.List">
|
<foreach collection="itemList" item="item" index="index" open="" close="" separator=";">
|
update approval_rule_item
|
<set>
|
<if test="item.ruleId != null">
|
rule_id = #{item.ruleId},
|
</if>
|
<if test="item.stepId != null">
|
step_id = #{item.stepId},
|
</if>
|
<if test="item.itemName != null and item.itemName != ''">
|
item_name = #{item.itemName},
|
</if>
|
<if test="item.type != null">
|
type = #{item.type},
|
</if>
|
<if test="item.standId != null">
|
stand_id = #{item.standId},
|
</if>
|
<if test="item.standId == null">
|
stand_id = null,
|
</if>
|
<if test="item.measureId != null">
|
measure_id = #{item.measureId},
|
</if>
|
<if test="item.measureId == null">
|
measure_id = null,
|
</if>
|
<if test="item.status != null">
|
status = #{item.status},
|
</if>
|
<if test="item.gmtModified != null">
|
gmt_modified = #{item.gmtModified},
|
</if>
|
<if test="item.modifiedUname != null">
|
modified_uname = #{item.modifiedUname},
|
</if>
|
<if test="item.modifiedUid != null">
|
modified_uid = #{item.modifiedUid},
|
</if>
|
|
</set>
|
where id = #{item.id}
|
</foreach>
|
</update>
|
</mapper>
|