f2cae2d41c2efc95deb0b06690f40feafcc851da.svn-base 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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="cn.com.goldenwater.dcproj.dao.BisInspQaDao">
  4. <resultMap type="cn.com.goldenwater.dcproj.model.BisInspQa" id="bisInspQaResultMap">
  5. <result property="id" column="ID"/>
  6. <result property="objId" column="OBJ_ID"/>
  7. <result property="nm" column="NM"/>
  8. <result property="adCode" column="AD_CODE"/>
  9. <result property="adName" column="AD_NAME"/>
  10. <result property="state" column="STATE"/>
  11. <result property="qaState" column="QA_STATE"/>
  12. <result property="persId" column="PERS_ID"/>
  13. <result property="intm" column="INTM"/>
  14. <result property="uptm" column="UPTM"/>
  15. <result property="note" column="NOTE"/>
  16. <result property="dataStat" column="DATA_STAT"/>
  17. <result property="totalScore" column="TOTAL_SCORE"/>
  18. </resultMap>
  19. <sql id="table_columns">
  20. ID,
  21. OBJ_ID,
  22. NM,
  23. AD_CODE,
  24. AD_NAME,
  25. STATE,
  26. QA_STATE,
  27. PERS_ID,
  28. INTM,
  29. UPTM,
  30. NOTE,
  31. TOTAL_SCORE,
  32. DATA_STAT
  33. </sql>
  34. <sql id="entity_properties">
  35. #{id},
  36. #{objId},
  37. #{nm},
  38. #{adCode},
  39. #{adName},
  40. #{state},
  41. #{qaState},
  42. #{persId},
  43. #{intm},
  44. #{uptm},
  45. #{note},
  46. #{totalScore},
  47. #{dataStat}
  48. </sql>
  49. <!-- 使用like用法:columnName like concat('%',#columnName#,'%') -->
  50. <sql id="page_where">
  51. <trim prefix="where" prefixOverrides="and | or ">
  52. <if test="objId != null and objId != ''">and OBJ_ID = #{objId}</if>
  53. <if test="nm != null and nm != ''">and NM = #{nm}</if>
  54. <if test="adCode != null and adCode != ''">and AD_CODE = #{adCode}</if>
  55. <if test="adName != null and adName != ''">and AD_NAME = #{adName}</if>
  56. <if test="state != null and state != ''">and STATE = #{state}</if>
  57. <if test="qaState != null and qaState != ''">and QA_STATE = #{qaState}</if>
  58. <if test="persId != null and persId != ''">and PERS_ID = #{persId}</if>
  59. <if test="intm != null">and INTM = #{intm}</if>
  60. <if test="uptm != null">and UPTM = #{uptm}</if>
  61. <if test="note != null and note != ''">and NOTE = #{note}</if>
  62. <if test="dataStat != null and dataStat != ''">and DATA_STAT = #{dataStat}</if>
  63. <if test="totalScore != null and totalScore != ''">and TOTAL_SCORE = #{totalScore}</if>
  64. and DATA_STAT='0'
  65. </trim>
  66. </sql>
  67. <select id="get" resultMap="bisInspQaResultMap" parameterType="String">
  68. select
  69. <include refid="table_columns"/>
  70. from BIS_INSP_QA where ID = #{id}
  71. </select>
  72. <select id="getBy" resultMap="bisInspQaResultMap">
  73. select
  74. <include refid="table_columns"/>
  75. from BIS_INSP_QA
  76. <include refid="page_where"/>
  77. </select>
  78. <select id="findAll" resultMap="bisInspQaResultMap">
  79. select
  80. <include refid="table_columns"/>
  81. from BIS_INSP_QA
  82. </select>
  83. <select id="findList" resultMap="bisInspQaResultMap">
  84. select
  85. <include refid="table_columns"/>
  86. from BIS_INSP_QA
  87. <include refid="page_where"/>
  88. </select>
  89. <select id="selectCount" resultType="int">
  90. select count(ID) from BIS_INSP_QA
  91. <include refid="page_where"/>
  92. </select>
  93. <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.BisInspQa">
  94. insert into BIS_INSP_QA(
  95. <include refid="table_columns"/>
  96. )
  97. values (
  98. <include refid="entity_properties"/>
  99. )
  100. </insert>
  101. <delete id="delete" parameterType="java.lang.String">
  102. update BIS_INSP_QA
  103. set DATA_STAT='9'
  104. where ID = #{id}
  105. </delete>
  106. <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspQa">
  107. update BIS_INSP_QA set DATA_STAT='9'
  108. <include refid="page_where"/>
  109. </delete>
  110. <update id="deleteInFlag" parameterType="java.lang.String">
  111. update BIS_INSP_QA
  112. set DATA_STAT = '9'
  113. where ID = #{id}
  114. </update>
  115. <update id="update" parameterType="cn.com.goldenwater.dcproj.model.BisInspQa">
  116. update BIS_INSP_QA
  117. <trim prefix="set" suffixOverrides=",">
  118. <if test="objId != null and objId != ''">OBJ_ID = #{objId},</if>
  119. <if test="nm != null and nm != ''">NM = #{nm},</if>
  120. <if test="adCode != null and adCode != ''">AD_CODE = #{adCode},</if>
  121. <if test="adName != null and adName != ''">AD_NAME = #{adName},</if>
  122. <if test="state != null and state != ''">STATE = #{state},</if>
  123. <if test="qaState != null and qaState != ''">QA_STATE = #{qaState},</if>
  124. <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
  125. <if test="intm != null">INTM = #{intm},</if>
  126. <if test="uptm != null">UPTM = #{uptm},</if>
  127. <if test="note != null and note != ''">NOTE = #{note},</if>
  128. <if test="dataStat != null and dataStat != ''">DATA_STAT = #{dataStat},</if>
  129. <if test="totalScore != null and totalScore != ''">TOTAL_SCORE = #{totalScore},</if>
  130. </trim>
  131. <where>ID = #{id}</where>
  132. </update>
  133. <update id="updateBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspQa">
  134. update BIS_INSP_QA
  135. <trim prefix="set" suffixOverrides=",">
  136. <if test="objId != null and objId != ''">OBJ_ID = #{objId},</if>
  137. <if test="nm != null and nm != ''">NM = #{nm},</if>
  138. <if test="adCode != null and adCode != ''">AD_CODE = #{adCode},</if>
  139. <if test="adName != null and adName != ''">AD_NAME = #{adName},</if>
  140. <if test="state != null and state != ''">STATE = #{state},</if>
  141. <if test="qaState != null and qaState != ''">QA_STATE = #{qaState},</if>
  142. <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
  143. <if test="intm != null">INTM = #{intm},</if>
  144. <if test="uptm != null">UPTM = #{uptm},</if>
  145. <if test="note != null and note != ''">NOTE = #{note},</if>
  146. <if test="dataStat != null and dataStat != ''">DATA_STAT = #{dataStat},</if>
  147. <if test="totalScore != null and totalScore != ''">TOTAL_SCORE = #{totalScore},</if>
  148. </trim>
  149. <include refid="page_where"/>
  150. </update>
  151. <!-- 其他自定义SQL -->
  152. <select id="findQaPage" resultType="cn.com.goldenwater.dcproj.dto.BisInspQaDto">
  153. SELECT * FROM (
  154. select A.CODE,
  155. A.ID AS nodeId,
  156. A.NM,
  157. A.PTYPE,
  158. A.OBJ_ID,
  159. IA.PNM AS groupName,
  160. B.ID AS rgstrId,
  161. AW.AD_FULL_NAME,
  162. (CASE WHEN B.STATE IS NULL THEN '0' ELSE B.STATE END) AS STATE,
  163. B.ID,
  164. B.AD_CODE,
  165. B.AD_NAME,
  166. B.QA_STATE,
  167. B.PERS_ID,
  168. B.INTM,
  169. B.UPTM,
  170. B.NOTE,
  171. B.TOTAL_SCORE,
  172. B.DATA_STAT
  173. FROM BIS_INSP_ALL_OBJ A
  174. JOIN BIS_INSP_QA B ON A.OBJ_ID = B.OBJ_ID
  175. LEFT JOIN BIS_INSP_ALL IA ON A.ID = IA.ID
  176. LEFT JOIN ATT_AD_BASE AW ON B.AD_CODE = AW.AD_CODE
  177. <where>
  178. <if test="adCodes ==null or adCodes ==''">
  179. <choose>
  180. <when test='isAll =="1"'>
  181. </when>
  182. <otherwise>
  183. AND A.Id in (
  184. select distinct w.id from (
  185. SELECT P.id FROM BIS_INSP_ALL P
  186. WHERE FIND_IN_SET(P.id, getSubNodes_bis_insp_all( (SELECT group_concat(A.id) FROM BIS_INSP_ALL_RLATION A
  187. WHERE A.PERSID = #{presId} and A.TYPE = #{pType} and length(A.id) in (3,6,9) group by A.PERSID ),0,0) ) &gt; 0
  188. union all
  189. SELECT P.id FROM BIS_INSP_ALL P where p.id in (SELECT id FROM BIS_INSP_ALL_RLATION A
  190. WHERE A.PERSID =#{presId} and TYPE = #{pType} and length(id)=12 )
  191. )w
  192. )
  193. </otherwise>
  194. </choose>
  195. </if>
  196. <if test="adCodes !=null and adCodes !=''">
  197. and
  198. <foreach item="item" index="index" collection="adCodes.split(',')" open="(" separator="or" close=")">
  199. b.ad_code like concat('${item}','%')
  200. </foreach>
  201. </if>
  202. </where>
  203. ) A
  204. <where>
  205. <if test="id !=null and id !=''">and a.nodeId like '${id}%'</if>
  206. <if test="plnaId !=null and plnaId !=''">and a.nodeId like '${plnaId}%'</if>
  207. <if test="state !=null and state !=''">and STATE in (${state})</if>
  208. <if test="nm !=null and nm !=''">and a.nm like '%${nm}%'</if>
  209. <if test="code !=null and code !=''">and a.code = #{code}</if>
  210. <if test="adName != null and adName != ''">and a.AD_NAME like '%${adName}%'</if>
  211. <if test="sttm != null and sttm != ''">and a.INTM &gt;= STR_TO_DATE(#{sttm},'%Y-%m-%d')</if>
  212. <if test="entm != null and entm != ''">and a.INTM &lt; DATE_ADD(STR_TO_DATE(#{entm},'%Y-%m-%d') ,INTERVAL 1 DAY)</if>
  213. <if test="groupId != null and groupId != ''">and a.nodeId = #{groupId}</if>
  214. </where>
  215. order by nodeId asc
  216. <if test="orderBy != null and orderBy != ''">
  217. ,CONVERT( nm USING gbk ) COLLATE gbk_chinese_ci ASC
  218. </if>
  219. </select>
  220. </mapper>