BisInspQaSdDao.xml 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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.BisInspQaSdDao">
  4. <resultMap type="cn.com.goldenwater.dcproj.model.BisInspQaSd" id="bisInspQaSdResultMap">
  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="bisInspQaSdResultMap" parameterType="String" >
  68. select <include refid="table_columns" /> from BIS_INSP_QA_SD where ID = #{id}
  69. </select>
  70. <select id="getBy" resultMap="bisInspQaSdResultMap">
  71. select <include refid="table_columns" /> from BIS_INSP_QA_SD <include refid="page_where" />
  72. </select>
  73. <select id="findAll" resultMap="bisInspQaSdResultMap">
  74. select <include refid="table_columns" /> from BIS_INSP_QA_SD
  75. </select>
  76. <select id="findList" resultMap="bisInspQaSdResultMap">
  77. select <include refid="table_columns" /> from BIS_INSP_QA_SD <include refid="page_where" />
  78. </select>
  79. <select id="selectCount" resultType="int" >
  80. select count(ID) from BIS_INSP_QA_SD <include refid="page_where" />
  81. </select>
  82. <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.BisInspQaSd">
  83. insert into BIS_INSP_QA_SD( <include refid="table_columns" /> )
  84. values ( <include refid="entity_properties" /> )
  85. </insert>
  86. <delete id="delete" parameterType="java.lang.String">
  87. update BIS_INSP_QA_SD set DATA_STAT='9' where ID = #{id}
  88. </delete>
  89. <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspQaSd">
  90. delete from BIS_INSP_QA_SD <include refid="page_where" />
  91. </delete>
  92. <update id="deleteInFlag" parameterType="java.lang.String">
  93. update BIS_INSP_QA_SD set flag_valid = 0 where ID = #{id}
  94. </update>
  95. <update id="update" parameterType="cn.com.goldenwater.dcproj.model.BisInspQaSd">
  96. update BIS_INSP_QA_SD
  97. <trim prefix="set" suffixOverrides=",">
  98. <if test="objId != null and objId != ''">OBJ_ID = #{objId},</if>
  99. <if test="nm != null and nm != ''">NM = #{nm},</if>
  100. <if test="adCode != null and adCode != ''">AD_CODE = #{adCode},</if>
  101. <if test="adName != null and adName != ''">AD_NAME = #{adName},</if>
  102. <if test="state != null and state != ''">STATE = #{state},</if>
  103. <if test="qaState != null and qaState != ''">QA_STATE = #{qaState},</if>
  104. <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
  105. <if test="intm != null">INTM = #{intm},</if>
  106. <if test="uptm != null">UPTM = #{uptm},</if>
  107. <if test="note != null and note != ''">NOTE = #{note},</if>
  108. <if test="dataStat != null and dataStat != ''">DATA_STAT = #{dataStat},</if>
  109. <if test="totalScore != null and totalScore != ''">TOTAL_SCORE = #{totalScore},</if>
  110. </trim>
  111. <where>ID = #{id}</where>
  112. </update>
  113. <update id="updateBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspQaSd">
  114. update BIS_INSP_QA_SD
  115. <trim prefix="set" suffixOverrides=",">
  116. <if test="objId != null and objId != ''">OBJ_ID = #{objId},</if>
  117. <if test="nm != null and nm != ''">NM = #{nm},</if>
  118. <if test="adCode != null and adCode != ''">AD_CODE = #{adCode},</if>
  119. <if test="adName != null and adName != ''">AD_NAME = #{adName},</if>
  120. <if test="state != null and state != ''">STATE = #{state},</if>
  121. <if test="qaState != null and qaState != ''">QA_STATE = #{qaState},</if>
  122. <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
  123. <if test="intm != null">INTM = #{intm},</if>
  124. <if test="uptm != null">UPTM = #{uptm},</if>
  125. <if test="note != null and note != ''">NOTE = #{note},</if>
  126. <if test="dataStat != null and dataStat != ''">DATA_STAT = #{dataStat},</if>
  127. </trim>
  128. <include refid="page_where" />
  129. </update>
  130. <!-- 其他自定义SQL -->
  131. <select id="findQaSdPage" resultType="cn.com.goldenwater.dcproj.dto.BisInspQaSdDto">
  132. SELECT * FROM (
  133. select A.CODE,
  134. A.ID AS nodeId,
  135. A.NM,
  136. A.PTYPE,
  137. A.OBJ_ID,
  138. IA.PNM AS groupName,
  139. B.ID AS rgstrId,
  140. AW.AD_FULL_NAME,
  141. (CASE WHEN B.STATE IS NULL THEN '0' ELSE B.STATE END) AS STATE,
  142. B.ID,
  143. B.AD_CODE,
  144. B.AD_NAME,
  145. B.QA_STATE,
  146. B.PERS_ID,
  147. B.INTM,
  148. B.UPTM,
  149. B.NOTE,
  150. B.TOTAL_SCORE,
  151. B.DATA_STAT
  152. FROM BIS_INSP_ALL_OBJ A
  153. JOIN BIS_INSP_QA_SD B ON A.OBJ_ID = B.OBJ_ID
  154. LEFT JOIN BIS_INSP_ALL IA ON A.ID = IA.ID
  155. LEFT JOIN ATT_AD_BASE AW ON B.AD_CODE = AW.AD_CODE
  156. <where>
  157. <if test="adCodes ==null or adCodes ==''">
  158. <choose>
  159. <when test='isAll =="1"'>
  160. </when>
  161. <otherwise>
  162. AND A.Id in (
  163. select distinct id from (
  164. SELECT P.id FROM BIS_INSP_ALL P START WITH P.PID IN (SELECT id FROM BIS_INSP_ALL_RLATION A
  165. WHERE A.PERSID = #{presId} and TYPE = #{pType} and length(id) in (3,6,9))
  166. CONNECT BY P.PID = PRIOR P.ID
  167. union all
  168. SELECT P.id FROM BIS_INSP_ALL P where p.id in (SELECT id FROM BIS_INSP_ALL_RLATION A
  169. WHERE A.PERSID =#{presId} and TYPE = #{pType} and length(id)=12 )
  170. )
  171. )
  172. </otherwise>
  173. </choose>
  174. </if>
  175. <if test="adCodes !=null and adCodes !=''">
  176. and
  177. <foreach item="item" index="index" collection="adCodes.split(',')" open="(" separator="or" close=")">
  178. b.ad_code like concat('${item}','%')
  179. </foreach>
  180. </if>
  181. <if test="tabType =='2'.toString()">
  182. AND IA.ENTM &lt; TO_DATE(#{nowTime},'yyyy-MM-dd')+1
  183. </if>
  184. <if test="tabType =='1'.toString()">
  185. AND IA.ENTM &gt;= TO_DATE(#{nowTime},'yyyy-MM-dd')
  186. </if>
  187. </where>
  188. ) A
  189. <where>
  190. <if test="id !=null and id !=''">and a.nodeId like '${id}%'</if>
  191. <if test="plnaId !=null and plnaId !=''">and a.nodeId like '${plnaId}%'</if>
  192. <if test="state !=null and state !=''">and STATE in (${state})</if>
  193. <if test="nm !=null and nm !=''">and a.nm like '%${nm}%'</if>
  194. <if test="code !=null and code !=''">and a.code = #{code}</if>
  195. <if test="adName != null and adName != ''">and a.AD_NAME like '%${adName}%'</if>
  196. <if test="sttm != null and sttm != ''">and a.INTM &gt;= TO_DATE(#{sttm},'YYYY-MM-DD')</if>
  197. <if test="entm != null and entm != ''">and a.INTM &lt; To_DATE(#{entm},'yyyy-MM-dd') + 1</if>
  198. <if test="groupId != null and groupId != ''">and a.nodeId = #{groupId}</if>
  199. </where>
  200. order by nodeId asc
  201. <if test="orderBy != null and orderBy != ''">
  202. ,nlssort(nm,'NLS_SORT=SCHINESE_PINYIN_M')
  203. </if>
  204. </select>
  205. </mapper>