SopInstMapper.xml 3.83 KB
<?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="cn.com.glsx.process.modules.mapper.SopInstMapper">
  <resultMap id="BaseResultMap" type="cn.com.glsx.process.modules.entity.SopInst">
    <!--
      WARNING - @mbg.generated
    -->
    <id column="inst_id" jdbcType="VARCHAR" property="instId" />
    <result column="grant_id" jdbcType="INTEGER" property="grantId" />
    <result column="inst_name" jdbcType="VARCHAR" property="instName" />
    <result column="inst_cron" jdbcType="VARCHAR" property="instCron" />
    <result column="inst_remark" jdbcType="VARCHAR" property="instRemark" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
    <result column="inst_status" jdbcType="TINYINT" property="instStatus" />
    <result column="inst_param" jdbcType="VARCHAR" property="instParam" />
    <result column="inst_snapshot" jdbcType="VARCHAR" property="instSnapshot" />
    <result column="expire_time" jdbcType="TIMESTAMP" property="expireTime" />
    <result column="batch_no" jdbcType="VARCHAR" property="batchNo" />
  </resultMap>
  <resultMap id="BaseResultDTOMap" extends="BaseResultMap" type="cn.com.glsx.process.modules.model.SopInstDTO">
    <association column="grant_id" property="sopTplGrant" select="cn.com.glsx.process.modules.mapper.SopTplGrantMapper.selectByPrimaryKey" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--
      WARNING - @mbg.generated
    -->
    inst_id, grant_id, inst_name, inst_cron, inst_remark, create_time, update_time, inst_status, 
    inst_param, inst_snapshot, expire_time, batch_no
  </sql>

  <update id="updateInstParamCustomData">
    UPDATE sop_inst SET inst_param=json_set(inst_param,'$.customData',CAST(#{customData,typeHandler=cn.com.glsx.process.modules.handler.JsonTypeHandler} AS JSON)) WHERE inst_id = #{instId}
  </update>

  <update id="updateInstParamStageData">
    UPDATE sop_inst SET inst_param=json_set(inst_param,'$.stages',CAST(#{stageData,typeHandler=cn.com.glsx.process.modules.handler.JsonTypeHandler} AS JSON)) WHERE inst_id = #{instId}
  </update>

  <update id="updateInstStatus">
    UPDATE sop_inst SET inst_status = #{status} WHERE inst_id = #{instId}
  </update>

  <update id="updateInstBatchNo">
    UPDATE sop_inst SET batch_no = #{batchNo}, inst_snapshot=#{snapshot} WHERE inst_id = #{instId}
  </update>

  <select id="selectByGroupId" resultMap="BaseResultMap">
    SELECT si.inst_id, si.grant_id, si.inst_name, si.inst_cron, si.inst_remark, si.create_time, si.update_time, si.inst_status,
    si.inst_param, si.expire_time, si.batch_no
    FROM sop_inst AS si
           INNER JOIN sop_tpl_grant AS stg ON si.grant_id = stg.grant_id
    WHERE stg.group_id = #{groupId}
      <if test="instStatuses != null and instStatuses.size() > 0">
        AND si.inst_status IN
          <foreach collection="instStatuses" open="(" separator="," close=")" item="status">
            #{status}
          </foreach>
      </if>
    ORDER BY si.inst_status DESC, si.create_time DESC
  </select>

  <select id="selectByCustomData" resultMap="BaseResultMap">
    SELECT
        <include refid="Base_Column_List"/>
    FROM sop_inst
    WHERE JSON_CONTAINS(inst_param, CAST(#{customData,typeHandler=cn.com.glsx.process.modules.handler.JsonTypeHandler} AS JSON),'$.customData') AND inst_status != -1;
  </select>

  <select id="page" resultMap="BaseResultDTOMap">
    SELECT
        <include refid="Base_Column_List"/>
    FROM sop_inst
    <where>
      <if test="instId != null and instId != ''">
        and inst_id = #{instId}
      </if>
      <if test="instName != null and instName != ''">
        and inst_name like CONCAT('%',#{instName},'%')
      </if>
    </where>
    ORDER BY create_time DESC
  </select>
</mapper>