InspectionMapper.xml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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.ym.mec.biz.dal.dao.InspectionDao">
  4. <resultMap id="Inspection" type="com.ym.mec.biz.dal.entity.Inspection">
  5. <!--@mbg.generated-->
  6. <!--@Table inspection-->
  7. <id column="id_" property="id"/>
  8. <result column="organ_id_" property="organId"/>
  9. <result column="user_id_" property="userId"/>
  10. <result column="month_" property="month"/>
  11. <result column="memo_" property="memo"/>
  12. <result column="operation_" property="operation"/>
  13. <result column="create_time_" property="createTime"/>
  14. <result column="update_time_" property="updateTime"/>
  15. <result column="organName" property="organName"/>
  16. <result column="userName" property="userName"/>
  17. <result column="tenant_id_" property="tenantId" />
  18. <collection property="inspectionItems" columnPrefix="ie_" ofType="com.ym.mec.biz.dal.entity.InspectionItem"
  19. resultMap="com.ym.mec.biz.dal.dao.InspectionItemDao.InspectionItem"/>
  20. </resultMap>
  21. <sql id="Base_Column_List">
  22. <!--@mbg.generated-->
  23. id_, organ_id_, user_id_, month_, memo_, operation_, create_time_, update_time_,tenant_id_
  24. </sql>
  25. <select id="get" parameterType="java.lang.Long" resultMap="Inspection">
  26. <!--@mbg.generated-->
  27. select
  28. <include refid="Base_Column_List"/>
  29. from inspection
  30. where id_ = #{id}
  31. </select>
  32. <delete id="delete" parameterType="java.lang.Long">
  33. delete
  34. from inspection
  35. where id_ = #{id}
  36. </delete>
  37. <insert id="insert" keyColumn="id_" keyProperty="id" parameterType="com.ym.mec.biz.dal.entity.Inspection"
  38. useGeneratedKeys="true">
  39. insert into inspection (organ_id_, user_id_, month_, operation_, create_time_, update_time_,tenant_id_)
  40. values (#{organId}, #{userId}, #{month}, #{operation}, #{createTime}, #{updateTime}, #{tenantId})
  41. </insert>
  42. <update id="update" parameterType="com.ym.mec.biz.dal.entity.Inspection">
  43. <!--@mbg.generated-->
  44. update inspection
  45. <set>
  46. <if test="organId != null">
  47. organ_id_ = #{organId},
  48. </if>
  49. <if test="userId != null">
  50. user_id_ = #{userId},
  51. </if>
  52. <if test="month != null">
  53. month_ = #{month},
  54. </if>
  55. <if test="memo != null">
  56. memo_ = #{memo},
  57. </if>
  58. <if test="operation != null">
  59. operation_ = #{operation},
  60. </if>
  61. <if test="createTime != null">
  62. create_time_ = #{createTime},
  63. </if>
  64. <if test="updateTime != null">
  65. update_time_ = #{updateTime},
  66. </if>
  67. </set>
  68. where id_ = #{id} and tenant_id_ = #{tenantId}
  69. </update>
  70. <!-- 分页查询 -->
  71. <select id="queryPage" resultMap="Inspection" parameterType="map">
  72. SELECT i.*,o.name_ organName,su.real_name_ userName FROM inspection i
  73. LEFT JOIN organization o ON o.id_=i.organ_id_
  74. LEFT JOIN sys_user su ON su.id_ = i.user_id_
  75. <include refid="queryPageSql"/>
  76. ORDER BY i.month_ DESC, i.id_ DESC
  77. <include refid="global.limit"/>
  78. </select>
  79. <!-- 查询当前表的总记录数 -->
  80. <select id="queryCount" resultType="int">
  81. SELECT COUNT(*) FROM inspection i
  82. <include refid="queryPageSql"/>
  83. </select>
  84. <sql id="queryPageSql">
  85. <where>
  86. i.tenant_id_ = #{tenantId}
  87. <if test="organId != null">
  88. AND FIND_IN_SET(i.organ_id_,#{organId})
  89. </if>
  90. <if test="userId != null">
  91. AND i.user_id_ = #{userId}
  92. </if>
  93. <if test="operation != null">
  94. AND i.operation_ = #{operation}
  95. </if>
  96. <if test="startTime != null">
  97. AND i.month_ >= #{startTime}
  98. </if>
  99. <if test="endTime != null">
  100. <![CDATA[AND i.month_ <= #{endTime}]]>
  101. </if>
  102. </where>
  103. </sql>
  104. <select id="getInfo" resultMap="Inspection">
  105. SELECT i.*,
  106. ii.id_ ie_id_,
  107. ii.inspection_id_ ie_inspection_id_,
  108. ii.organ_id_ ie_organ_id_,
  109. ii.user_id_ ie_user_id_,
  110. ii.item_ ie_item_,
  111. ii.times_ ie_times_,
  112. ii.planned_times_ ie_planned_times_,
  113. ii.submitted_times_ ie_submitted_times_,
  114. ii.memo_ ie_memo_,
  115. ii.operation_ ie_operation_,
  116. ii.create_time_ ie_create_time_,
  117. ii.update_time_ ie_update_time_,
  118. o.name_ organName,
  119. su.real_name_ userName
  120. FROM inspection i
  121. LEFT JOIN organization o ON o.id_ = i.organ_id_
  122. LEFT JOIN sys_user su ON su.id_ = i.user_id_
  123. LEFT JOIN inspection_item ii ON ii.inspection_id_ = i.id_
  124. WHERE i.id_ = #{id}
  125. </select>
  126. </mapper>