FlowInstanceDao.xml 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.flow.dao.FlowInstanceDao">
  4. <resultMap id="BaseResultMap" type="com.flow.entity.FlowInstance">
  5. <result property="id" column="id" jdbcType="VARCHAR"/>
  6. <result property="name" column="NAME_" jdbcType="VARCHAR"/>
  7. <result property="definitionId" column="PROC_DEF_ID_" jdbcType="VARCHAR"/>
  8. <result property="version" column="VERSION_" jdbcType="INTEGER"/>
  9. <result property="startUserId" column="START_USER_ID_" jdbcType="VARCHAR"/>
  10. <result property="startTime" column="START_TIME_" jdbcType="TIMESTAMP"/>
  11. <result property="endTime" column="END_TIME_" jdbcType="TIMESTAMP"/>
  12. <result property="duration" column="DURATION_" jdbcType="INTEGER"/>
  13. <result property="status" column="status" jdbcType="INTEGER"/>
  14. <result property="cancelDays" column="cancel_days" jdbcType="INTEGER"/>
  15. <association property="currentNodes" column="id" select="getCurrentNodes"/>
  16. </resultMap>
  17. <sql id="instanceColumns">
  18. SELECT
  19. RE.id,
  20. HP.NAME_,
  21. HP.PROC_DEF_ID_,
  22. HP.START_USER_ID_,
  23. HP.START_TIME_,
  24. HP.END_TIME_,
  25. HP.DURATION_,
  26. RE.status,
  27. RE.cancel_days
  28. FROM
  29. ACT_HI_PROCINST HP
  30. LEFT JOIN flow_instance RE ON HP.ID_ = RE.id
  31. </sql>
  32. <select id="list" resultMap="BaseResultMap">
  33. <include refid="instanceColumns"></include>
  34. <where>
  35. <if test="query.startUserId != null and query.startUserId != ''">
  36. AND HP.START_USER_ID_ = #{query.startUserId}
  37. </if>
  38. <if test="query.status!= null">
  39. AND RE.status = #{query.status}
  40. </if>
  41. <if test="query.name!= null and query.name!= ''">
  42. AND HP.NAME_ like CONCAT('%',#{query.name},'%')
  43. </if>
  44. <if test="query.modelCode!= null and query.modelCode!= ''">
  45. AND HP.PROC_DEF_ID_ like CONCAT(#{query.modelCode},'%')
  46. </if>
  47. <if test="query.definitionId!= null and query.definitionId!= ''">
  48. AND HP.PROC_DEF_ID_ = #{query.definitionId}
  49. </if>
  50. <if test="query.startDates != null and query.startDates.size()>1">
  51. AND HP.START_TIME_ between #{query.startDates[0]} and #{query.startDates[1]}
  52. </if>
  53. <if test="query.endDates != null and query.endDates.size()>1">
  54. AND HP.END_TIME_ between #{query.endDates[0]} and #{query.endDates[1]}
  55. </if>
  56. </where>
  57. ORDER BY
  58. HP.ID_ DESC
  59. </select>
  60. <select id="getInstance" resultMap="BaseResultMap">
  61. <include refid="instanceColumns"></include>
  62. WHERE
  63. RE.id = #{id}
  64. </select>
  65. <select id="getCurrentNodes" resultType="java.lang.String">
  66. SELECT
  67. DISTINCT ACT_NAME_
  68. FROM
  69. ACT_RU_ACTINST
  70. WHERE
  71. END_TIME_ IS NULL AND PROC_INST_ID_ = #{id}
  72. </select>
  73. </mapper>