BisInspAllObjDao.xml 70 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433
  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.BisInspAllObjDao">
  4. <resultMap type="cn.com.goldenwater.dcproj.model.BisInspAllObj" id="bisInspAllObjResultMap">
  5. <result property="code" column="CODE"/>
  6. <result property="id" column="ID"/>
  7. <result property="nm" column="NM"/>
  8. <result property="provincial" column="PROVINCIAL"/>
  9. <result property="ptype" column="PTYPE"/>
  10. <result property="lgtd" column="LGTD"/>
  11. <result property="lttd" column="LTTD"/>
  12. <result property="objId" column="OBJ_ID"/>
  13. <result property="lgtdpc" column="LGTDPC"/>
  14. <result property="lttdpc" column="LTTDPC"/>
  15. <result property="orgId" column="ORG_ID"/>
  16. <result property="adCode" column="AD_CODE"/>
  17. <result property="objAdCode" column="OBJ_AD_CODE"/>
  18. </resultMap>
  19. <sql id="table_columns">
  20. CODE,
  21. ID,
  22. NM,
  23. PROVINCIAL,
  24. PTYPE,
  25. LGTD,
  26. LTTD,
  27. LGTDPC,
  28. LTTDPC,
  29. OBJ_ID,ORG_ID,AD_CODE,OBJ_AD_CODE
  30. </sql>
  31. <sql id="entity_properties">
  32. #{code},
  33. #{id},
  34. #{nm},
  35. #{provincial},
  36. #{ptype},
  37. #{lgtd},
  38. #{lttd},
  39. #{lgtdpc},
  40. #{lttdpc},
  41. #{objId},#{orgId},#{adCode},#{objAdCode}
  42. </sql>
  43. <!-- 使用like用法:columnName like concat('%',#columnName#,'%') -->
  44. <sql id="page_where">
  45. <trim prefix="where" prefixOverrides="and | or ">
  46. <if test="id != null and id != ''">and ID = #{id}</if>
  47. <if test="nm != null and nm != ''">and NM = #{nm}</if>
  48. <if test="provincial != null and provincial != ''">and PROVINCIAL = #{provincial}</if>
  49. <if test="adCode != null and adCode != ''">and AD_CODE = #{adCode}</if>
  50. <if test="orgId != null and orgId != ''">and ORG_ID = #{orgId}</if>
  51. <if test="ptype != null and ptype != ''">and PTYPE = #{ptype}</if>
  52. <if test="lgtd != null and lgtd != ''">and LGTD = #{lgtd}</if>
  53. <if test="lttd != null and lttd != ''">and LTTD = #{lttd}</if>
  54. <if test="objId != null and objId != ''">and OBJ_ID = #{objId}</if>
  55. <if test="code != null and code != ''">and CODE = #{code}</if>
  56. <if test="lgtdpc != null and lgtdpc != ''">and LGTDPC = #{lgtdpc}</if>
  57. <if test="lttdpc != null and lttdpc != ''">and LTTDPC = #{lttdpc}</if>
  58. <if test="objAdCode != null and objAdCode != ''">and OBJ_AD_CODE = #{objAdCode}</if>
  59. </trim>
  60. </sql>
  61. <select id="get" resultMap="bisInspAllObjResultMap" parameterType="String">
  62. select
  63. <include refid="table_columns"/>
  64. from BIS_INSP_ALL_OBJ where obj_id = #{id}
  65. </select>
  66. <select id="getBy" resultMap="bisInspAllObjResultMap">
  67. select
  68. <include refid="table_columns"/>
  69. from BIS_INSP_ALL_OBJ
  70. <include refid="page_where"/>
  71. </select>
  72. <select id="findAll" resultMap="bisInspAllObjResultMap">
  73. select
  74. <include refid="table_columns"/>
  75. from BIS_INSP_ALL_OBJ
  76. </select>
  77. <select id="findList" resultMap="bisInspAllObjResultMap">
  78. select
  79. <include refid="table_columns"/>
  80. from BIS_INSP_ALL_OBJ
  81. <trim prefix="where" prefixOverrides="and | or ">
  82. <if test="id != null and id != ''">and ID = #{id}</if>
  83. <if test="ids != null and ids != ''">and ID in (${ids})</if>
  84. <if test="nm != null and nm != ''">and NM = #{nm}</if>
  85. <if test="provincial != null and provincial != ''">and PROVINCIAL = #{provincial}</if>
  86. <if test="adCode != null and adCode != ''">and AD_CODE = #{adCode}</if>
  87. <if test="orgId != null and orgId != ''">and ORG_ID = #{orgId}</if>
  88. <if test="ptype != null and ptype != ''">and PTYPE = #{ptype}</if>
  89. <if test="lgtd != null and lgtd != ''">and LGTD = #{lgtd}</if>
  90. <if test="lttd != null and lttd != ''">and LTTD = #{lttd}</if>
  91. <if test="objId != null and objId != ''">and OBJ_ID = #{objId}</if>
  92. <if test="code != null and code != ''">and CODE = #{code}</if>
  93. <if test="lgtdpc != null and lgtdpc != ''">and LGTDPC = #{lgtdpc}</if>
  94. <if test="lttdpc != null and lttdpc != ''">and LTTDPC = #{lttdpc}</if>
  95. <if test="objAdCode != null and objAdCode != ''">and OBJ_AD_CODE = #{objAdCode}</if>
  96. </trim>
  97. </select>
  98. <select id="selectCount" resultType="int">
  99. select count(ID) from BIS_INSP_ALL_OBJ
  100. <include refid="page_where"/>
  101. </select>
  102. <!--督查办-->
  103. <sql id="commonSql">
  104. <include refid="selSql"/>
  105. </sql>
  106. <sql id="commonChose">
  107. <include refid="commonSql"/>
  108. </sql>
  109. <!--督查问题-->
  110. <select id="findPblmByAdCode" resultType="cn.com.goldenwater.dcproj.model.BisInspPblm"
  111. parameterType="cn.com.goldenwater.dcproj.param.IndexParamPage">
  112. select w.nm,m.* from bis_insp_pblm m, (
  113. <include refid="commonChose"/>
  114. ) W where w.obj_id=m.obj_id and w.ad_code=#{adCode}
  115. <if test="startTime != null and startTime != ''">and w.obj_intm&gt;= TO_DATE(#{startTime},'YYYY-MM-DD')</if>
  116. <if test="endTime != null and endTime != ''">and w.obj_intm &lt; TO_DATE(#{endTime},'YYYY-MM-DD')+1</if>
  117. <if test="pTypes != null and pTypes != ''">
  118. and w.pType in (${pTypes})
  119. </if>
  120. <if test="orgIds != null and orgIds != ''">
  121. and substr(w.id,4,3) in (${orgIds})
  122. </if>
  123. </select>
  124. <sql id="selAdCode">
  125. <include refid="selSql"/>
  126. </sql>
  127. <!--查找督查对象-->
  128. <select id="findObjByAdCode" resultType="cn.com.goldenwater.dcproj.model.DuchaObj"
  129. parameterType="cn.com.goldenwater.dcproj.param.IndexParamPage">
  130. select * from (
  131. <include refid="selAdCode"/>
  132. ) W where w.ad_code=#{adCode}
  133. <if test="startTime != null and startTime != ''">and w.obj_intm&gt;= TO_DATE(#{startTime},'YYYY-MM-DD')</if>
  134. <if test="endTime != null and endTime != ''">and w.obj_intm &lt; TO_DATE(#{endTime},'YYYY-MM-DD')+1</if>
  135. <if test="pTypes != null and pTypes != ''">
  136. and w.pType in (${pTypes})
  137. </if>
  138. <if test="orgIds != null and orgIds != ''">
  139. and substr(w.id,4,3) in (${orgIds})
  140. </if>
  141. </select>
  142. <select id="findPerByAdCode" resultType="cn.com.goldenwater.dcproj.model.ObjPerson"
  143. parameterType="cn.com.goldenwater.dcproj.param.IndexParamPage">
  144. select D.ptype,e.name as
  145. name,D.id,p.pers_name,p.org_nm,p.org_id,p.dpnm,p.mobilenumb,p.dppost,p.guid,p.email,a.pnm from
  146. bis_insp_all_rlation l ,bis_insp_all_rlation_pers p,bis_insp_all a,(
  147. select distinct * from (
  148. select ptype, ID from (
  149. <include refid="commonChose"/>
  150. ) W where w.ad_code=#{adCode}
  151. <if test="startTime != null and startTime != ''">and w.obj_intm&gt;= TO_DATE(#{startTime},'YYYY-MM-DD')</if>
  152. <if test="endTime != null and endTime != ''">and w.obj_intm &lt; TO_DATE(#{endTime},'YYYY-MM-DD')+1</if>
  153. <if test="pTypes != null and pTypes != ''">
  154. and w.pType in (${pTypes})
  155. </if>
  156. <if test="orgIds != null and orgIds != ''">
  157. and substr(w.id,4,3) in (${orgIds})
  158. </if>
  159. ) S ) D,att_insp_type e where l.id=d.id and l.persid=p.guid and a.id=d.id and e.ptype=D.ptype
  160. </select>
  161. <select id="countGroupByAdCode" resultType="cn.com.goldenwater.dcproj.dto.ObjGroup"
  162. parameterType="cn.com.goldenwater.dcproj.param.IndexParamPage">
  163. select D.ptype,e.name as name,l.* from bis_insp_all l ,(
  164. select distinct * from (
  165. select ptype, ID from (
  166. <include refid="commonChose"/>
  167. ) W where w.ad_code=#{adCode}
  168. <if test="startTime != null and startTime != ''">and w.obj_intm&gt;= TO_DATE(#{startTime},'YYYY-MM-DD')</if>
  169. <if test="endTime != null and endTime != ''">and w.obj_intm &lt; TO_DATE(#{endTime},'YYYY-MM-DD')+1</if>
  170. <if test="pTypes != null and pTypes != ''">
  171. and w.pType in (${pTypes})
  172. </if>
  173. <if test="orgIds != null and orgIds != ''">
  174. and substr(w.id,4,3) in (${orgIds})
  175. </if>
  176. ) S ) D,att_insp_type e where l.id=d.id and e.ptype=D.ptype
  177. </select>
  178. <!--根据对象类型统计分组数量-->
  179. <select id="countGroup" resultType="cn.com.goldenwater.dcproj.dto.DcTypeDto"
  180. parameterType="cn.com.goldenwater.dcproj.param.IndexParam">
  181. select ss.total,f.name as name,ss.obj_type from (
  182. select count(w.obj_type) as total,w.obj_type from (
  183. select f.obj_type,f.pnm from (
  184. select
  185. ( case
  186. when t.sttm is null AND t.insp_year IS NOT NULL AND t.insp_mnth IS NOT NULL
  187. then to_date(t.insp_year ||'-'|| t.insp_mnth || '-01','yyyy-MM-dd')
  188. else t.sttm end ) as sttm,
  189. ( case when t.entm is null AND t.insp_year IS NOT NULL AND t.insp_mnth IS NOT NULL
  190. then to_date(t.insp_year ||'-'|| t.insp_mnth || '-01','yyyy-MM-dd')
  191. else t.entm end ) as entm,
  192. ltrim(substr(t.id,0,3),'0') as obj_type,
  193. t.pnm
  194. FROM (SELECT * FROM BIS_INSP_ALL WHERE LENGTH(ID) = 12) T
  195. WHERE 1 = 1
  196. <if test="orgIds != null and orgIds != ''">
  197. and substr(t.id,4,3) in (${orgIds})
  198. </if>
  199. <choose>
  200. <when test="province != null and province !=''">
  201. and t.PROVINCE = #{province}
  202. </when>
  203. <otherwise>
  204. and t.PROVINCE is null
  205. </otherwise>
  206. </choose>
  207. ) f where 1=1
  208. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  209. and ((f.sttm &gt;= to_date(#{startTime},'yyyy-MM-dd') and f.sttm &lt;= to_date(#{endTime},'yyyy-MM-dd'))
  210. or ( f.entm &gt;= to_date(#{startTime},'yyyy-MM-dd') and f.entm &lt;= to_date(#{endTime},'yyyy-MM-dd'))
  211. or( f.sttm &gt;= to_date(#{startTime},'yyyy-MM-dd') and f.entm &lt;= to_date(#{endTime}, 'yyyy-MM-dd'))
  212. or( f.sttm &lt;= to_date(#{startTime},'yyyy-MM-dd') and f.entm &gt;= to_date(#{endTime}, 'yyyy-MM-dd')))
  213. </if>
  214. <if test="startTime != null and endTime == null">
  215. and f.sttm &lt;= to_date(#{startTime},'yyyy-MM-dd')
  216. and f.entm &gt;= to_date(#{startTime},'yyyy-MM-dd')
  217. or f.sttm &gt;= to_date(#{startTime},'yyyy-MM-dd')
  218. </if>
  219. <if test="endTime != null and startTime == null">
  220. and f.sttm &gt;= to_date(#{endTime},'yyyy-MM-dd')
  221. and f.entm &lt;= to_date(#{endTime},'yyyy-MM-dd')
  222. or f.entm &lt;= to_date(#{endTime},'yyyy-MM-dd')
  223. </if>
  224. ) w where w.obj_type != '8'
  225. <if test="pTypes != null and pTypes != ''">
  226. and w.obj_type in (${pTypes})
  227. </if>
  228. group by w.obj_type)
  229. ss LEFT JOIN (
  230. select ltrim(t.code,'0') as code,t.name from ATT_INSP_TYPE t
  231. ) f on ss.obj_type = f.code order by to_number(ss.obj_type)
  232. </select>
  233. <!--根据对象类型统计督查人员-->
  234. <select id="countPerson" resultType="cn.com.goldenwater.dcproj.dto.DcTypeDto"
  235. parameterType="cn.com.goldenwater.dcproj.param.IndexParam">
  236. select ss.total,e.name as name,ss.obj_type from (
  237. select count(w.pType) as total,w.pType as obj_type from (
  238. select a.id, to_number(substr(a.id,0,3)) as ptype from bis_insp_all_rlation a where length(a.id)=12
  239. <choose>
  240. <when test="province != null and province !=''">
  241. and a.ad_code = #{province}
  242. </when>
  243. <otherwise>
  244. and a.ad_code is null
  245. </otherwise>
  246. </choose>
  247. and a.id in (
  248. select j.id from bis_insp_all_obj j where
  249. j.pType != '8'
  250. <if test="startTime != null and startTime != ''">and j.obj_intm &gt;= TO_DATE(#{startTime},'YYYY-MM-DD')</if>
  251. <if test="endTime != null and endTime != ''">and j.obj_intm &lt; TO_DATE(#{endTime},'YYYY-MM-DD')+1</if>
  252. <if test="pTypes != null and pTypes != ''">
  253. and j.pType in (${pTypes})
  254. </if>
  255. <if test="orgIds != null and orgIds != ''">
  256. and substr(j.id,4,3) in (${orgIds})
  257. </if>
  258. <choose>
  259. <when test="province != null and province !=''">
  260. and j.ad_code = #{province}
  261. </when>
  262. <otherwise>
  263. and j.ad_code is null
  264. </otherwise>
  265. </choose>
  266. )
  267. ) w group by w.pType ) ss,att_insp_type e where ss.obj_type=e.ptype and obj_type is not null order by
  268. ss.obj_type
  269. </select>
  270. <!--按省份统计督查人员-->
  271. <select id="countPersonByPro" resultType="cn.com.goldenwater.dcproj.dto.DcTypeDto"
  272. parameterType="cn.com.goldenwater.dcproj.param.IndexParam">
  273. select * from (
  274. select count(aa.ad_name) as total,aa.ad_name as name,aa.ad_code from (
  275. select distinct id,persid,ba.ad_name,ss.ad_code from (
  276. select a.persid,a.id,w.ad_code from bis_insp_all_rlation a left join (
  277. <include refid="commonChose"/>
  278. ) w on a.id=w.id where length(w.ad_code)=12
  279. <choose>
  280. <when test="province !=null and province !=''">
  281. and a.ad_code=#{province}
  282. </when>
  283. <otherwise>
  284. and a.ad_code is null
  285. </otherwise>
  286. </choose>
  287. <if test="startTime != null and startTime != ''">and w.obj_intm&gt;= TO_DATE(#{startTime},'YYYY-MM-DD')</if>
  288. <if test="endTime != null and endTime != ''">and w.obj_intm &lt; TO_DATE(#{endTime},'YYYY-MM-DD')+1</if>
  289. <if test="pTypes != null and pTypes != ''">
  290. and w.pType in (${pTypes})
  291. </if>
  292. <if test="orgIds != null and orgIds != ''">
  293. and substr(w.id,4,3) in (${orgIds})
  294. </if>
  295. ) ss,att_ad_x_base ba where ss.ad_code=ba.ad_code
  296. and ss.ad_code is not null) aa group by aa.ad_name,aa.ad_code ) p order by p.ad_code
  297. </select>
  298. <!--根据省份统计分组-->
  299. <select id="countGroupByPro" resultType="cn.com.goldenwater.dcproj.dto.DcTypeDto"
  300. parameterType="cn.com.goldenwater.dcproj.param.IndexParam">
  301. select
  302. ss.ad_Code,ba.ad_name as name,ss.total from (
  303. select c.adCode||'00000000' as ad_Code,c.total from (
  304. select count(w.adCode) as total,w.adCode from (
  305. select f.adCode,f.id from (
  306. select ( case when t.sttm is null AND t.insp_year IS NOT NULL AND t.insp_mnth IS NOT NULL then
  307. to_date(t.insp_year ||'-'|| t.insp_mnth || '-01','yyyy-MM-dd') else
  308. t.sttm end ) as sttm,
  309. ( case when t.entm is null AND t.insp_year IS NOT NULL AND t.insp_mnth IS NOT NULL then to_date(t.insp_year
  310. ||'-'|| t.insp_mnth || '-01','yyyy-MM-dd') else t.entm end )
  311. as entm,t.id,substr(a.ad_code,1,4) as adCode from bis_insp_all t left join BIS_INSP_SEL_AREA a on t.id = a.id
  312. where length (t.id) = 12 and a.ad_code is not null
  313. <if test="orgIds != null and orgIds != ''">
  314. and substr(t.id,4,3) in (${orgIds})
  315. </if>
  316. <if test="pTypes != null and pTypes != ''">
  317. and ltrim(substr(t.id,0,3),'0') in (${pTypes})
  318. </if>
  319. <choose>
  320. <when test="province != null and province !=''">
  321. and t.PROVINCE = #{province}
  322. </when>
  323. <otherwise>
  324. and t.PROVINCE is null
  325. </otherwise>
  326. </choose>
  327. ) f where 1=1
  328. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  329. and ((f.sttm &gt;= to_date(#{startTime},'yyyy-MM-dd') and f.sttm &lt;= to_date(#{endTime},'yyyy-MM-dd'))
  330. or ( f.entm &gt;= to_date(#{startTime},'yyyy-MM-dd') and f.entm &lt;= to_date(#{endTime},'yyyy-MM-dd'))
  331. or( f.sttm &gt;= to_date(#{startTime},'yyyy-MM-dd') and f.entm &lt;= to_date(#{endTime}, 'yyyy-MM-dd'))
  332. or( f.sttm &lt;= to_date(#{startTime},'yyyy-MM-dd') and f.entm &gt;= to_date(#{endTime}, 'yyyy-MM-dd')))
  333. </if>
  334. <if test="startTime != null and endTime == null">
  335. and f.sttm &lt;= to_date(#{startTime},'yyyy-MM-dd')
  336. and f.entm &gt;= to_date(#{startTime},'yyyy-MM-dd')
  337. or f.sttm &gt;= to_date(#{startTime},'yyyy-MM-dd')
  338. </if>
  339. <if test="endTime != null and startTime == null">
  340. and f.sttm &gt;= to_date(#{endTime},'yyyy-MM-dd')
  341. and f.entm &lt;= to_date(#{endTime},'yyyy-MM-dd')
  342. or f.entm &lt;= to_date(#{endTime},'yyyy-MM-dd')
  343. </if>
  344. ) w group by w.adCode) c
  345. ) ss left join att_ad_x_base ba on ss.ad_Code=ba.ad_code and ba.ad_grad = '3'
  346. </select>
  347. <!--根据省统计问题分类-->
  348. <select id="countPblmbyPro" resultType="cn.com.goldenwater.dcproj.dto.DcPblmDto"
  349. parameterType="cn.com.goldenwater.dcproj.param.IndexParam">
  350. select ss.*,ba.ad_name as name from (
  351. select count(m.insp_pblm_cate) as total,m.insp_pblm_cate,w.ad_code from (select * from bis_insp_pblm p where 1=1
  352. <if test="pTypes != null and pTypes != ''">
  353. and p.obj_type in (${pTypes})
  354. </if>
  355. ) m left join (
  356. <include refid="commonChose"/>
  357. ) w on m.obj_id=w.obj_id and length(w.ad_code)=12
  358. <if test="startTime != null and startTime != ''">and m.coll_time&gt;= TO_DATE(#{startTime},'YYYY-MM-DD')</if>
  359. <if test="endTime != null and endTime != ''">and m.coll_time &lt; TO_DATE(#{endTime},'YYYY-MM-DD')+1</if>
  360. <if test="orgIds != null and orgIds != ''">
  361. and substr(w.id,4,3) in (${orgIds})
  362. </if>
  363. group by m.insp_pblm_cate,w.ad_code
  364. ) ss ,att_ad_x_base ba where ss.ad_code=ba.ad_code order by ss.ad_code
  365. </select>
  366. <sql id="selPlan">
  367. select to_char(substr(e.adm_div,0,${length})||'${otherLength}') as ad_code,o.ptype,o.id,o.obj_id,r.uptm as
  368. obj_intm,o.nm,r.hyst_site as ad_name
  369. from bis_insp_all_obj o inner join bis_insp_rsvr_rgstr r on o.obj_id=r.obj_id left join att_rs_base e on
  370. o.code=e.rs_code where o.ptype in (1,36) and r.state='2'
  371. <include refid="choseSql"/>
  372. union all
  373. select substr(o.code,0,${length})||'${otherLength}' as ad_code,o.ptype,o.id,o.obj_id,r.uptm as
  374. obj_intm,o.nm,b.ad_full_name as ad_name from bis_insp_all_obj o
  375. ,BIS_INSP_VILL_RGSTR r,att_ad_x_base b where r.obj_id = o.obj_id and o.code=b.ad_code and r.state = '2' and
  376. o.ptype=2
  377. <include refid="choseSql"/>
  378. union all
  379. select substr(ob.loc_ad,0,${length})||'${otherLength}' as ad_code,o.ptype,o.id,o.obj_id,t.uptm as
  380. obj_intm,o.nm,t.loac as ad_name from bis_insp_all_obj o
  381. inner join bis_insp_wtdst_track t on o.obj_id=t.obj_id left join BIS_INSP_WTDST OB ON o.CODE = OB.WTDST_ID where
  382. o.ptype=3 and t.state='2'
  383. <include refid="choseSql"/>
  384. union all
  385. select substr(ke.ad_code,0,${length})||'${otherLength}' as ad_code,o.ptype,o.id,o.obj_id,t.uptm as
  386. obj_intm,o.nm,t.nm as ad_name
  387. from bis_insp_all_obj o inner join bis_insp_key_register t on o.obj_id=t.obj_id left join ATT_EMPWTPRJ_BASE ke
  388. ON o.code = ke.id
  389. where o.ptype in (4,7) and t.state='2'
  390. <include refid="choseSql"/>
  391. union all
  392. select substr(ob.adcd,0,${length})||'${otherLength}' as ad_code,o.ptype,o.id,o.obj_id,w.uptm as
  393. obj_intm,o.nm,ob.stlc as ad_name from bis_insp_all_obj o
  394. inner join BIS_INSP_GRW w on o.obj_id=w.obj_id left join ATT_GRW_BASE OB ON o.CODE = OB.stcd where o.ptype=5 and
  395. w.insp_state='2'
  396. <include refid="choseSql"/>
  397. union all
  398. select substr(ob.ad_code,0,${length})||'${otherLength}' as ad_code,o.ptype,o.id,o.obj_id,g.uptm as
  399. obj_intm,o.nm,ob.location_xiang as ad_name from bis_insp_all_obj o
  400. inner join att_waga_rgstr g on o.obj_id=g.obj_id left join ATT_WAGA_BASE OB ON o.CODE = OB.obj_code where
  401. o.ptype=6 and g.state='2'
  402. <include refid="choseSql"/>
  403. union all
  404. select substr(ob.ad_code,0,${length})||'${otherLength}' as
  405. ad_code,o.ptype,o.id,o.obj_id,o.obj_intm,o.nm,ob.location as ad_name from bis_insp_all_obj o
  406. inner join bis_insp_fsc_rgstr g on o.obj_id=g.obj_id left join att_fsc_base OB ON o.CODE = OB.id where o.ptype=9
  407. and g.state='2'
  408. <include refid="choseSql"/>
  409. union all
  410. select substr(ob.ad_code,0,${length})||'${otherLength}' as
  411. ad_code,o.ptype,o.id,o.obj_id,o.obj_intm,o.nm,ob.location as ad_name from bis_insp_all_obj o
  412. inner join bis_insp_other_rgstr g on o.obj_id=g.obj_id left join att_other_base OB ON o.CODE = OB.id where
  413. o.ptype=10 and g.state='2'
  414. <include refid="choseSql"/>
  415. union all
  416. select substr(ob.ad_code,0,${length})||'${otherLength}' as ad_code,o.ptype,o.id,o.obj_id,o.obj_intm,o.nm,OB.note
  417. as ad_name from bis_insp_all_obj o
  418. inner join bis_insp_sd_rgstr g on o.obj_id=g.obj_id left join att_sd_base OB ON o.CODE = OB.SD_CODE where
  419. o.ptype=11 and g.state='2'
  420. <include refid="choseSql"/>
  421. union all
  422. select substr(ob.ad_code,0,${length})||'${otherLength}' as
  423. ad_code,o.ptype,o.id,o.obj_id,o.obj_intm,o.nm,OB.WINT_POS as ad_name from bis_insp_all_obj o
  424. inner join bis_insp_wiu_rgstr g on o.obj_id=g.obj_id left join att_wain_base OB ON o.CODE = OB.OBJ_CODE where
  425. o.ptype=12 and g.state='2'
  426. <include refid="choseSql"/>
  427. union all
  428. select substr(ob.ad_code,0,${length})||'${otherLength}' as
  429. ad_code,o.ptype,o.id,o.obj_id,o.obj_intm,o.nm,OB.SWHS_LOC as ad_name from bis_insp_all_obj o
  430. inner join BIS_INSP_SWHS_RGSTR g on o.obj_id=g.obj_id left join ATT_SWHS_BASE OB ON o.CODE = OB.id where
  431. o.ptype=13 and g.state='2'
  432. <include refid="choseSql"/>
  433. union all
  434. select substr(ob.ad_code,0,${length})||'${otherLength}' as
  435. ad_code,o.ptype,o.id,o.obj_id,o.obj_intm,o.nm,OB.AD_FULL_NAME as ad_name from bis_insp_all_obj o
  436. inner join bis_insp_wint_rgstr g on o.obj_id=g.obj_id left join ATT_AD_X_BASE OB ON o.CODE = OB.AD_CODE where
  437. o.ptype=14 and g.state='2'
  438. <include refid="choseSql"/>
  439. union all
  440. select substr(ob.ad_code,0,${length})||'${otherLength}' as
  441. ad_code,o.ptype,o.id,o.obj_id,o.obj_intm,o.nm,OB.AD_FULL_NAME as ad_name from bis_insp_all_obj o
  442. inner join bis_insp_svwt_area_rgstr g on o.obj_id=g.obj_id left join ATT_AD_X_BASE OB ON o.CODE = OB.AD_CODE
  443. where o.ptype=15 and g.state='2'
  444. <include refid="choseSql"/>
  445. union all
  446. select substr(ob.ad_code,0,${length})||'${otherLength}' as
  447. ad_code,o.ptype,o.id,o.obj_id,o.obj_intm,o.nm,OB.ad_name from bis_insp_all_obj o
  448. inner join bis_insp_svwt_wunt_rgstr g on o.obj_id=g.obj_id left join att_wunt_base OB ON o.CODE = OB.ID where
  449. o.ptype=16 and g.state='2'
  450. <include refid="choseSql"/>
  451. union all
  452. select substr(ob.ad_code,0,${length})||'${otherLength}' as
  453. ad_code,o.ptype,o.id,o.obj_id,o.obj_intm,o.nm,OB.ad_name from bis_insp_all_obj o
  454. inner join BIS_INSP_OPRD_CSTR_PROJ_RGSTR g on o.obj_id=g.obj_id left join ATT_PRD_CSTR_PROJ_BASE OB ON o.CODE =
  455. OB.ID where o.ptype=17 and g.state='2'
  456. <include refid="choseSql"/>
  457. union all
  458. select substr(ob.ad_code,0,${length})||'${otherLength}' as
  459. ad_code,o.ptype,o.id,o.obj_id,o.obj_intm,o.nm,OB.ad_name from bis_insp_all_obj o
  460. inner join ATT_JSKEJIAN_FLKDIS_RGSTR g on o.obj_id=g.obj_id left join ATT_JSKEJIAN_FLKDIS_BASE OB ON o.CODE =
  461. OB.ID where o.ptype=18 and g.state='2'
  462. <include refid="choseSql"/>
  463. union all
  464. select substr(ob.ad_code,0,${length})||'${otherLength}' as
  465. ad_code,o.ptype,o.id,o.obj_id,o.obj_intm,o.nm,OB.ad_name from bis_insp_all_obj o
  466. inner join ATT_JSKEJIAN_WATER_RGSTR g on o.obj_id=g.obj_id left join ATT_JSKEJIAN_WATER_BASE OB ON o.CODE =
  467. OB.ID where o.ptype=19 and g.state='2'
  468. <include refid="choseSql"/>
  469. union all
  470. select substr(ob.ad_code,0,${length})||'${otherLength}' as
  471. ad_code,o.ptype,o.id,o.obj_id,o.obj_intm,o.nm,OB.ad_name from bis_insp_all_obj o
  472. inner join ATT_JSKEJIAN_ECOFRD_RGSTR g on o.obj_id=g.obj_id left join ATT_JSKEJIAN_ECOFRD_BASE OB ON o.CODE =
  473. OB.ID where o.ptype=20 and g.state='2'
  474. <include refid="choseSql"/>
  475. union all
  476. select to_char(substr(e.adm_div,0,${length})||'${otherLength}') as ad_code,o.ptype,o.id,o.obj_id,r.uptm as
  477. obj_intm,o.nm,r.hyst_site as ad_name
  478. from bis_insp_all_obj o inner join bis_insp_RSML_rgstr r on o.obj_id=r.obj_id left join att_rs_base e on
  479. o.code=e.rs_code where o.ptype = 22 and r.state='2'
  480. <include refid="choseSql"/>
  481. </sql>
  482. <!--根据省统计督查对象个数-->
  483. <select id="countPlanByPro" resultType="cn.com.goldenwater.dcproj.dto.DcTypeDto"
  484. parameterType="cn.com.goldenwater.dcproj.param.IndexParam">
  485. select c.total,c.ad_name as name,c.ad_code from (
  486. select count(ba.ad_name) as total,ba.ad_name,ba.ad_code from (
  487. <include refid="selPlan"/>
  488. ) w,att_ad_x_base ba where w.ad_code=ba.ad_code and length(w.ad_code)=12
  489. <if test="startTime != null and startTime != ''">and w.obj_intm&gt;= TO_DATE(#{startTime},'YYYY-MM-DD')</if>
  490. <if test="endTime != null and endTime != ''">and w.obj_intm &lt; TO_DATE(#{endTime},'YYYY-MM-DD')+1</if>
  491. <if test="pTypes != null and pTypes != ''">
  492. and w.pType in (${pTypes})
  493. </if>
  494. <if test="orgIds != null and orgIds != ''">
  495. and substr(w.id,4,3) in (${orgIds})
  496. </if>
  497. group by ba.ad_name,ba.ad_code ) c order by c.ad_code
  498. </select>
  499. <!--根据对象类型按按照分类统计-->
  500. <select id="countPblmByObjType" resultType="cn.com.goldenwater.dcproj.dto.DcPblmDto"
  501. parameterType="cn.com.goldenwater.dcproj.param.IndexParam">
  502. select w.total,(case when w.insp_pblm_cate ='0' then '一般' when w.insp_pblm_cate ='1' then '较重'
  503. when w.insp_pblm_cate ='2' then '严重' when w.insp_pblm_cate ='3' then '特别严重' else '' end ) as name,
  504. w.insp_pblm_cate from (
  505. select count(m.insp_pblm_cate) as total,m.insp_pblm_cate from bis_insp_pblm m
  506. left join bis_insp_all_obj j on m.obj_id=j.obj_id
  507. left join (select * from bis_insp_org where 1=1
  508. <if test="orgIds != null and orgIds != ''">
  509. and id in (${orgIds})
  510. </if>
  511. ) g on substr(j.id,4,3)=g.org_id
  512. <if test="pTypes != null and pTypes != ''">
  513. and m.obj_type=#{pTypes}
  514. </if>
  515. <choose>
  516. <when test="province != null and province !=''">
  517. and j.ad_code = '${province}'
  518. </when>
  519. <otherwise>
  520. and j.ad_code is null
  521. </otherwise>
  522. </choose>
  523. <if test="startTime != null and startTime != ''">and m.coll_time &gt;= TO_DATE(#{startTime},'YYYY-MM-DD')</if>
  524. <if test="endTime != null and endTime != ''">and m.coll_time &lt; TO_DATE(#{endTime},'YYYY-MM-DD')+1</if>
  525. group by m.insp_pblm_cate
  526. ) w order by w.insp_pblm_cate
  527. </select>
  528. <!--根据时间,机构,类型统计问题个数-->
  529. <select id="countPblmbyParam" resultType="cn.com.goldenwater.dcproj.dto.DcTypeDto"
  530. parameterType="cn.com.goldenwater.dcproj.param.IndexParam">
  531. select ss.total,e.name as name,ss.obj_type from (
  532. select count(m.obj_type) as total ,m.obj_type as obj_type from bis_insp_pblm m
  533. left join bis_insp_all_obj j on m.obj_id=j.obj_id
  534. left join (select * from bis_insp_org where 1=1
  535. <if test="orgIds != null and orgIds != ''">
  536. and id in (${orgIds})
  537. </if>
  538. ) g on substr(j.id,4,3)=g.org_id
  539. <if test="pTypes != null and pTypes != ''">
  540. and m.obj_type in (${pTypes})
  541. </if>
  542. <choose>
  543. <when test="province != null and province !=''">
  544. and j.ad_code = '${province}'
  545. </when>
  546. <otherwise>
  547. and j.ad_code is null
  548. </otherwise>
  549. </choose>
  550. <if test="startTime != null and startTime != ''">and m.coll_time &gt;= TO_DATE(#{startTime},'YYYY-MM-DD')</if>
  551. <if test="endTime != null and endTime != ''">and m.coll_time &lt; TO_DATE(#{endTime},'YYYY-MM-DD')+1</if>
  552. group by m.obj_type
  553. ) ss,att_insp_type e where ss.obj_type=e.ptype order by ss.obj_type
  554. </select>
  555. <!--根据时间,机构,类型统计督查对象个数-->
  556. <select id="countObjbyParam" resultType="cn.com.goldenwater.dcproj.dto.DcTypeDto"
  557. parameterType="cn.com.goldenwater.dcproj.param.IndexParam">
  558. select ss.total,e.name as name,ss.obj_type from (
  559. select
  560. count(j.ptype) as total ,j.ptype as obj_type
  561. from bis_insp_all_obj j,bis_insp_org g
  562. where substr(j.id,4,3)=g.org_id
  563. <if test="orgIds != null and orgIds != ''">
  564. and g.org_id in (${orgIds})
  565. </if>
  566. <if test="pTypes != null and pTypes != ''">
  567. and j.ptype in (${pTypes})
  568. </if>
  569. <choose>
  570. <when test="province != null and province !=''">
  571. and j.ad_code = '${province}'
  572. </when>
  573. <otherwise>
  574. and j.ad_code is null
  575. </otherwise>
  576. </choose>
  577. <if test="startTime != null and startTime != ''">and j.obj_intm&gt;= TO_DATE(#{startTime},'YYYY-MM-DD')</if>
  578. <if test="endTime != null and endTime != ''">and j.obj_intm &lt; TO_DATE(#{endTime},'YYYY-MM-DD')+1</if>
  579. group by j.ptype
  580. ) ss,att_insp_type e where ss.obj_type=e.ptype order by ss.obj_type
  581. </select>
  582. <!--根据类型统计督查个数-->
  583. <select id="countObjByType" resultType="cn.com.goldenwater.dcproj.dto.DcTypeDto"
  584. parameterType="cn.com.goldenwater.dcproj.param.IndexParam">
  585. select ss.total,e.name as name,ss.obj_type from (
  586. select count(j.ptype) as total,j.ptype as obj_type from bis_insp_all_obj j
  587. where 1=1
  588. <if test="orgIds != null and orgIds != ''">
  589. and substr(j.id,4,3) in (${orgIds})
  590. </if>
  591. <choose>
  592. <when test="province != null and province !=''">
  593. and j.ad_code = '${province}'
  594. </when>
  595. <otherwise>
  596. and j.ad_code is null
  597. </otherwise>
  598. </choose>
  599. group by j.ptype
  600. ) ss,att_insp_type e where ss.obj_type=e.ptype order by ss.obj_type
  601. </select>
  602. <!--根据机构统计督查个数-->
  603. <select id="countObjByOrg" resultType="cn.com.goldenwater.dcproj.dto.DcTypeDto"
  604. parameterType="cn.com.goldenwater.dcproj.param.IndexParam">
  605. select count(w.org_nm) as total,w.org_nm as name from (
  606. select o.org_nm,b.ptype,o.org_id from bis_insp_org o,bis_insp_all_obj b where o.org_id=substr(b.id,4,3)
  607. <if test="orgIds != null and orgIds != ''">
  608. and o.id in (${orgIds})
  609. </if>
  610. <if test="pTypes != null and pTypes != ''">
  611. and b.ptype in (${pTypes})
  612. </if>
  613. <choose>
  614. <when test="province != null and province !=''">
  615. and b.ad_code = '${province}'
  616. </when>
  617. <otherwise>
  618. and b.ad_code is null
  619. </otherwise>
  620. </choose>
  621. order by o.org_id
  622. ) w group by w.org_nm
  623. </select>
  624. <!--根据类型获取督查问题统计-->
  625. <select id="countPblmByType" resultType="cn.com.goldenwater.dcproj.dto.DcTypeDto"
  626. parameterType="cn.com.goldenwater.dcproj.param.IndexParam">
  627. select ss.total,e.name as name,ss.obj_type from (
  628. select count(p.obj_type) as total,p.obj_type from bis_insp_all_obj o ,bis_insp_pblm p where o.obj_id=p.obj_id
  629. <if test="startTime != null and startTime != ''">and p.coll_time &gt;= TO_DATE(#{startTime},'YYYY-MM-DD')</if>
  630. <if test="endTime != null and endTime != ''">and p.coll_time &lt; TO_DATE(#{endTime},'YYYY-MM-DD')+1</if>
  631. <if test="orgIds != null and orgIds != ''">
  632. and substr(o.id,4,3) in (${orgIds})
  633. </if>
  634. <if test="pTypes != null and pTypes != ''">
  635. and o.ptype in (${pTypes})
  636. </if>
  637. <include refid="choseSql"/>
  638. group by p.obj_type
  639. ) ss,att_insp_type e where ss.obj_type=e.ptype order by ss.obj_type
  640. </select>
  641. <sql id="choseSql">
  642. <choose>
  643. <when test="province != null and province !=''">
  644. and o.ad_code = '${province}'
  645. </when>
  646. <otherwise>
  647. and o.ad_code is null
  648. </otherwise>
  649. </choose>
  650. </sql>
  651. <!--督查对象(已督查)统计-->
  652. <select id="countDcByType" resultType="cn.com.goldenwater.dcproj.dto.DcTypeDto"
  653. parameterType="cn.com.goldenwater.dcproj.param.IndexParam">
  654. select e.ptype as objType,e.name as name,count(o.id) as total from bis_insp_all_obj o,
  655. bis_insp_rsvr_rgstr r,att_insp_type e
  656. where o.obj_id=r.obj_id and o.ptype=e.ptype and o.ptype in (1,36) and r.state='2'
  657. <if test="startTime != null and startTime != ''">and r.intm &gt;= TO_DATE(#{startTime},'YYYY-MM-DD')</if>
  658. <if test="endTime != null and endTime != ''">and r.intm &lt; TO_DATE(#{endTime},'YYYY-MM-DD')+1</if>
  659. <if test="orgIds != null and orgIds != ''">
  660. and substr(o.id,4,3) in (${orgIds})
  661. </if>
  662. <if test="pTypes != null and pTypes != ''">
  663. and o.ptype in (${pTypes})
  664. </if>
  665. <include refid="choseSql"/>
  666. group by e.name,e.ptype
  667. union all
  668. select e.ptype as objType,e.name as name,count(o.id) as total from bis_insp_all_obj o,BIS_INSP_VILL_RGSTR
  669. v,att_insp_type e
  670. where o.obj_id=v.obj_id and o.ptype=e.ptype and v.state='2'
  671. <if test="startTime != null and startTime != ''">and v.uptm &gt;= TO_DATE(#{startTime},'YYYY-MM-DD')</if>
  672. <if test="endTime != null and endTime != ''">and v.uptm &lt; TO_DATE(#{endTime},'YYYY-MM-DD')+1</if>
  673. <if test="orgIds != null and orgIds != ''">
  674. and substr(o.id,4,3) in (${orgIds})
  675. </if>
  676. <if test="pTypes != null and pTypes != ''">
  677. and o.ptype in (${pTypes})
  678. </if>
  679. <include refid="choseSql"/>
  680. group by e.name,e.ptype
  681. union all
  682. select e.ptype as objType,e.name as name,count(o.id) as total from bis_insp_all_obj o,bis_insp_wtdst_track
  683. t,att_insp_type e
  684. where o.obj_id=t.obj_id and o.ptype=e.ptype and t.state='2'
  685. <if test="startTime != null and startTime != ''">and t.uptm &gt;= TO_DATE(#{startTime},'YYYY-MM-DD')</if>
  686. <if test="endTime != null and endTime != ''">and t.uptm &lt; TO_DATE(#{endTime},'YYYY-MM-DD')+1</if>
  687. <if test="orgIds != null and orgIds != ''">
  688. and substr(o.id,4,3) in (${orgIds})
  689. </if>
  690. <if test="pTypes != null and pTypes != ''">
  691. and o.ptype in (${pTypes})
  692. </if>
  693. <include refid="choseSql"/>
  694. group by e.name,e.ptype
  695. union all
  696. select e.ptype as objType,e.name as name,count(o.id) as total from bis_insp_all_obj o,bis_insp_key_register t
  697. ,att_insp_type e
  698. where o.obj_id=t.obj_id and o.ptype=e.ptype and t.state='2' and o.ptype in (4,7)
  699. <if test="startTime != null and startTime != ''">and t.uptm &gt;= TO_DATE(#{startTime},'YYYY-MM-DD')</if>
  700. <if test="endTime != null and endTime != ''">and t.uptm &lt; TO_DATE(#{endTime},'YYYY-MM-DD')+1</if>
  701. <if test="orgIds != null and orgIds != ''">
  702. and substr(o.id,4,3) in (${orgIds})
  703. </if>
  704. <if test="pTypes != null and pTypes != ''">
  705. and o.ptype in (${pTypes})
  706. </if>
  707. <include refid="choseSql"/>
  708. group by e.name,e.ptype
  709. union all
  710. select e.ptype as objType,e.name as name,count(o.id) as total from bis_insp_all_obj o,BIS_INSP_GRW
  711. w,att_insp_type e
  712. where o.obj_id=w.obj_id and o.ptype=e.ptype and w.insp_state='2'
  713. <if test="startTime != null and startTime != ''">and w.uptm &gt;= TO_DATE(#{startTime},'YYYY-MM-DD')</if>
  714. <if test="endTime != null and endTime != ''">and w.uptm &lt; TO_DATE(#{endTime},'YYYY-MM-DD')+1</if>
  715. <if test="orgIds != null and orgIds != ''">
  716. and substr(o.id,4,3) in (${orgIds})
  717. </if>
  718. <if test="pTypes != null and pTypes != ''">
  719. and o.ptype in (${pTypes})
  720. </if>
  721. <include refid="choseSql"/>
  722. group by e.name,e.ptype
  723. union all
  724. select e.ptype as objType,e.name as name,count(o.id) as total from bis_insp_all_obj o,att_waga_rgstr
  725. g,att_insp_type e
  726. where o.obj_id=g.obj_id and o.ptype=e.ptype and g.state='2'
  727. <if test="startTime != null and startTime != ''">and g.uptm &gt;= TO_DATE(#{startTime},'YYYY-MM-DD')</if>
  728. <if test="endTime != null and endTime != ''">and g.uptm &lt; TO_DATE(#{endTime},'YYYY-MM-DD')+1</if>
  729. <if test="orgIds != null and orgIds != ''">
  730. and substr(o.id,4,3) in (${orgIds})
  731. </if>
  732. <if test="pTypes != null and pTypes != ''">
  733. and o.ptype in (${pTypes})
  734. </if>
  735. <include refid="choseSql"/>
  736. group by e.name,e.ptype
  737. union all
  738. select e.ptype as objType,e.name as name,count(o.id) as total from bis_insp_all_obj o,bis_insp_fsc_rgstr
  739. g,att_insp_type e
  740. where o.obj_id=g.obj_id and o.ptype=e.ptype and g.state='2'
  741. <if test="startTime != null and startTime != ''">and g.up_tm &gt;= TO_DATE(#{startTime},'YYYY-MM-DD')</if>
  742. <if test="endTime != null and endTime != ''">and g.up_tm &lt; TO_DATE(#{endTime},'YYYY-MM-DD')+1</if>
  743. <if test="orgIds != null and orgIds != ''">
  744. and substr(o.id,4,3) in (${orgIds})
  745. </if>
  746. <if test="pTypes != null and pTypes != ''">
  747. and o.ptype in (${pTypes})
  748. </if>
  749. <include refid="choseSql"/>
  750. group by e.name,e.ptype
  751. union all
  752. select e.ptype as objType,e.name as name,count(o.id) as total from bis_insp_all_obj o,bis_insp_other_rgstr g
  753. ,att_insp_type e
  754. where o.obj_id=g.obj_id and o.ptype=e.ptype and g.state='2'
  755. <if test="startTime != null and startTime != ''">and g.up_tm &gt;= TO_DATE(#{startTime},'YYYY-MM-DD')</if>
  756. <if test="endTime != null and endTime != ''">and g.up_tm &lt; TO_DATE(#{endTime},'YYYY-MM-DD')+1</if>
  757. <if test="orgIds != null and orgIds != ''">
  758. and substr(o.id,4,3) in (${orgIds})
  759. </if>
  760. <if test="pTypes != null and pTypes != ''">
  761. and o.ptype in (${pTypes})
  762. </if>
  763. <include refid="choseSql"/>
  764. group by e.name,e.ptype
  765. union all
  766. select e.ptype as objType,e.name as name,count(o.id) as total from bis_insp_all_obj o,bis_insp_sd_rgstr g
  767. ,att_insp_type e
  768. where o.obj_id=g.obj_id and o.ptype=e.ptype and g.state='2'
  769. <if test="startTime != null and startTime != ''">and g.up_tm &gt;= TO_DATE(#{startTime},'YYYY-MM-DD')</if>
  770. <if test="endTime != null and endTime != ''">and g.up_tm &lt; TO_DATE(#{endTime},'YYYY-MM-DD')+1</if>
  771. <if test="orgIds != null and orgIds != ''">
  772. and substr(o.id,4,3) in (${orgIds})
  773. </if>
  774. <if test="pTypes != null and pTypes != ''">
  775. and o.ptype in (${pTypes})
  776. </if>
  777. <include refid="choseSql"/>
  778. group by e.name,e.ptype
  779. union all
  780. select e.ptype as objType,e.name as name,count(o.id) as total from bis_insp_all_obj o,bis_insp_wiu_rgstr g
  781. ,att_insp_type e
  782. where o.obj_id=g.obj_id and o.ptype=e.ptype and g.state='2'
  783. <if test="startTime != null and startTime != ''">and g.up_tm &gt;= TO_DATE(#{startTime},'YYYY-MM-DD')</if>
  784. <if test="endTime != null and endTime != ''">and g.up_tm &lt; TO_DATE(#{endTime},'YYYY-MM-DD')+1</if>
  785. <if test="orgIds != null and orgIds != ''">
  786. and substr(o.id,4,3) in (${orgIds})
  787. </if>
  788. <if test="pTypes != null and pTypes != ''">
  789. and o.ptype in (${pTypes})
  790. </if>
  791. <include refid="choseSql"/>
  792. group by e.name,e.ptype
  793. union all
  794. select e.ptype as objType,e.name as name,count(o.id) as total from bis_insp_all_obj o,bis_insp_swhs_rgstr g
  795. ,att_insp_type e
  796. where o.obj_id=g.obj_id and o.ptype=e.ptype and g.state='2'
  797. <if test="startTime != null and startTime != ''">and g.up_tm &gt;= TO_DATE(#{startTime},'YYYY-MM-DD')</if>
  798. <if test="endTime != null and endTime != ''">and g.up_tm &lt; TO_DATE(#{endTime},'YYYY-MM-DD')+1</if>
  799. <if test="orgIds != null and orgIds != ''">
  800. and substr(o.id,4,3) in (${orgIds})
  801. </if>
  802. <if test="pTypes != null and pTypes != ''">
  803. and o.ptype in (${pTypes})
  804. </if>
  805. <include refid="choseSql"/>
  806. group by e.name,e.ptype
  807. union all
  808. select e.ptype as objType,e.name as name,count(o.id) as total from bis_insp_all_obj o,bis_insp_wint_rgstr g
  809. ,att_insp_type e
  810. where o.obj_id=g.obj_id and o.ptype=e.ptype and g.state='2'
  811. <if test="startTime != null and startTime != ''">and g.up_tm &gt;= TO_DATE(#{startTime},'YYYY-MM-DD')</if>
  812. <if test="endTime != null and endTime != ''">and g.up_tm &lt; TO_DATE(#{endTime},'YYYY-MM-DD')+1</if>
  813. <if test="orgIds != null and orgIds != ''">
  814. and substr(o.id,4,3) in (${orgIds})
  815. </if>
  816. <if test="pTypes != null and pTypes != ''">
  817. and o.ptype in (${pTypes})
  818. </if>
  819. <include refid="choseSql"/>
  820. group by e.name,e.ptype
  821. union all
  822. select e.ptype as objType,e.name as name,count(o.id) as total from bis_insp_all_obj o,bis_insp_svwt_area_rgstr g
  823. ,att_insp_type e
  824. where o.obj_id=g.obj_id and o.ptype=e.ptype and g.state='2'
  825. <if test="startTime != null and startTime != ''">and g.up_tm &gt;= TO_DATE(#{startTime},'YYYY-MM-DD')</if>
  826. <if test="endTime != null and endTime != ''">and g.up_tm &lt; TO_DATE(#{endTime},'YYYY-MM-DD')+1</if>
  827. <if test="orgIds != null and orgIds != ''">
  828. and substr(o.id,4,3) in (${orgIds})
  829. </if>
  830. <if test="pTypes != null and pTypes != ''">
  831. and o.ptype in (${pTypes})
  832. </if>
  833. <include refid="choseSql"/>
  834. group by e.name,e.ptype
  835. union all
  836. select e.ptype as objType,e.name as name,count(o.id) as total from bis_insp_all_obj o,bis_insp_svwt_wunt_rgstr
  837. g,att_insp_type e
  838. where o.obj_id=g.obj_id and o.ptype=e.ptype and g.state='2'
  839. <if test="startTime != null and startTime != ''">and g.up_tm &gt;= TO_DATE(#{startTime},'YYYY-MM-DD')</if>
  840. <if test="endTime != null and endTime != ''">and g.up_tm &lt; TO_DATE(#{endTime},'YYYY-MM-DD')+1</if>
  841. <if test="orgIds != null and orgIds != ''">
  842. and substr(o.id,4,3) in (${orgIds})
  843. </if>
  844. <if test="pTypes != null and pTypes != ''">
  845. and o.ptype in (${pTypes})
  846. </if>
  847. <include refid="choseSql"/>
  848. group by e.name,e.ptype
  849. union all
  850. select e.ptype as objType,e.name as name,count(o.id) as total from bis_insp_all_obj
  851. o,BIS_INSP_OPRD_CSTR_PROJ_RGSTR g,att_insp_type e
  852. where o.obj_id=g.obj_id and o.ptype=e.ptype and g.state='2'
  853. <if test="startTime != null and startTime != ''">and g.up_tm &gt;= TO_DATE(#{startTime},'YYYY-MM-DD')</if>
  854. <if test="endTime != null and endTime != ''">and g.up_tm &lt; TO_DATE(#{endTime},'YYYY-MM-DD')+1</if>
  855. <if test="orgIds != null and orgIds != ''">
  856. and substr(o.id,4,3) in (${orgIds})
  857. </if>
  858. <if test="pTypes != null and pTypes != ''">
  859. and o.ptype in (${pTypes})
  860. </if>
  861. <include refid="choseSql"/>
  862. group by e.name,e.ptype
  863. union all
  864. select e.ptype as objType,e.name as name,count(o.id) as total from bis_insp_all_obj o,ATT_JSKEJIAN_FLKDIS_RGSTR
  865. g ,att_insp_type e
  866. where o.obj_id=g.obj_id and o.ptype=e.ptype and g.state='2'
  867. <if test="startTime != null and startTime != ''">and g.uptm &gt;= TO_DATE(#{startTime},'YYYY-MM-DD')</if>
  868. <if test="endTime != null and endTime != ''">and g.uptm &lt; TO_DATE(#{endTime},'YYYY-MM-DD')+1</if>
  869. <if test="orgIds != null and orgIds != ''">
  870. and substr(o.id,4,3) in (${orgIds})
  871. </if>
  872. <if test="pTypes != null and pTypes != ''">
  873. and o.ptype in (${pTypes})
  874. </if>
  875. <include refid="choseSql"/>
  876. group by e.name,e.ptype
  877. union all
  878. select e.ptype as objType,e.name as name,count(o.id) as total from bis_insp_all_obj o,ATT_JSKEJIAN_WATER_RGSTR g
  879. ,att_insp_type e
  880. where o.obj_id=g.obj_id and o.ptype=e.ptype and g.state='2'
  881. <if test="startTime != null and startTime != ''">and g.uptm &gt;= TO_DATE(#{startTime},'YYYY-MM-DD')</if>
  882. <if test="endTime != null and endTime != ''">and g.uptm &lt; TO_DATE(#{endTime},'YYYY-MM-DD')+1</if>
  883. <if test="orgIds != null and orgIds != ''">
  884. and substr(o.id,4,3) in (${orgIds})
  885. </if>
  886. <if test="pTypes != null and pTypes != ''">
  887. and o.ptype in (${pTypes})
  888. </if>
  889. <include refid="choseSql"/>
  890. group by e.name,e.ptype
  891. union all
  892. select e.ptype as objType,e.name as name,count(o.id) as total from bis_insp_all_obj o,ATT_JSKEJIAN_ECOFRD_RGSTR
  893. g ,att_insp_type e
  894. where o.obj_id=g.obj_id and o.ptype=e.ptype and g.state='2'
  895. <if test="startTime != null and startTime != ''">and g.uptm &gt;= TO_DATE(#{startTime},'YYYY-MM-DD')</if>
  896. <if test="endTime != null and endTime != ''">and g.uptm &lt; TO_DATE(#{endTime},'YYYY-MM-DD')+1</if>
  897. <if test="orgIds != null and orgIds != ''">
  898. and substr(o.id,4,3) in (${orgIds})
  899. </if>
  900. <if test="pTypes != null and pTypes != ''">
  901. and o.ptype in (${pTypes})
  902. </if>
  903. <include refid="choseSql"/>
  904. group by e.name,e.ptype
  905. union ALL
  906. select e.ptype as objType,e.name as name,count(o.id) as total from bis_insp_all_obj o,BIS_INSP_RSML_RGSTR g
  907. ,att_insp_type e
  908. where o.obj_id=g.obj_id and o.ptype=e.ptype and g.state='2'
  909. <if test="startTime != null and startTime != ''">and g.uptm &gt;= TO_DATE(#{startTime},'YYYY-MM-DD')</if>
  910. <if test="endTime != null and endTime != ''">and g.uptm &lt; TO_DATE(#{endTime},'YYYY-MM-DD')+1</if>
  911. <if test="orgIds != null and orgIds != ''">
  912. and substr(o.id,4,3) in (${orgIds})
  913. </if>
  914. <if test="pTypes != null and pTypes != ''">
  915. and o.ptype in (${pTypes})
  916. </if>
  917. <include refid="choseSql"/>
  918. group by e.name,e.ptype
  919. </select>
  920. <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.BisInspAllObj">
  921. insert into BIS_INSP_ALL_OBJ(
  922. <include refid="table_columns"/>
  923. )
  924. values (
  925. <include refid="entity_properties"/>
  926. )
  927. </insert>
  928. <insert id="insertObj" parameterType="cn.com.goldenwater.dcproj.dto.BisInspAllObjDto">
  929. insert into BIS_INSP_ALL_OBJ(
  930. <include refid="table_columns"/>
  931. )
  932. values (
  933. <include refid="entity_properties"/>
  934. )
  935. </insert>
  936. <delete id="delete" parameterType="java.lang.String">
  937. delete from BIS_INSP_ALL_OBJ where ID = #{id}
  938. </delete>
  939. <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspAllObj">
  940. delete from BIS_INSP_ALL_OBJ
  941. <include refid="page_where"/>
  942. </delete>
  943. <update id="deleteInFlag" parameterType="java.lang.String">
  944. update BIS_INSP_ALL_OBJ set flag_valid = 0 where ID = #{id}
  945. </update>
  946. <update id="update" parameterType="cn.com.goldenwater.dcproj.model.BisInspAllObj">
  947. update BIS_INSP_ALL_OBJ
  948. <trim prefix="set" suffixOverrides=",">
  949. <if test="id != null and id != ''">ID = #{id},</if>
  950. <if test="nm != null and nm != ''">NM = #{nm},</if>
  951. <if test="ptype != null and ptype != ''">PTYPE = #{ptype},</if>
  952. <if test="lgtd != null and lgtd != ''">LGTD = #{lgtd},</if>
  953. <if test="lttd != null and lttd != ''">LTTD = #{lttd},</if>
  954. <if test="objId != null and objId != ''">OBJ_ID = #{objId},</if>
  955. <if test="lgtdpc != null and lgtdpc != ''">LGTDPC = #{lgtdpc},</if>
  956. <if test="lttdpc != null and lttdpc != ''">LTTDPC = #{lttdpc},</if>
  957. <if test="adCode != null and adCode != ''">AD_CODE = #{adCode},</if>
  958. <if test="orgId != null and orgId != ''">ORG_ID = #{orgId},</if>
  959. <if test="objAdCode != null and objAdCode != ''">OBJ_AD_CODE = #{objAdCode},</if>
  960. </trim>
  961. <where>obj_id = #{objId}</where>
  962. </update>
  963. <update id="updateBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspAllObj">
  964. update BIS_INSP_ALL_OBJ
  965. <trim prefix="set" suffixOverrides=",">
  966. <if test="id != null and id != ''">ID = #{id},</if>
  967. <if test="nm != null and nm != ''">NM = #{nm},</if>
  968. <if test="ptype != null and ptype != ''">PTYPE = #{ptype},</if>
  969. <if test="lgtd != null and lgtd != ''">LGTD = #{lgtd},</if>
  970. <if test="lttd != null and lttd != ''">LTTD = #{lttd},</if>
  971. <if test="objId != null and objId != ''">OBJ_ID = #{objId},</if>
  972. <if test="lgtdpc != null and lgtdpc != ''">LGTDPC = #{lgtdpc},</if>
  973. <if test="lttdpc != null and lttdpc != ''">LTTDPC = #{lttdpc},</if>
  974. <if test="objAdCode != null and objAdCode != ''">OBJ_AD_CODE = #{objAdCode},</if>
  975. </trim>
  976. <include refid="page_where"/>
  977. </update>
  978. <!-- 其他自定义SQL -->
  979. <select id="getIdByUserId" resultType="cn.com.goldenwater.dcproj.model.BisInspAllRlation">
  980. SELECT * FROM BIS_INSP_ALL_RLATION T where persid=#{userid} and id like concat( #{ptype},'%')
  981. <choose>
  982. <when test="adCode != null and adCode !=''">
  983. and t.ad_code = #{adCode}
  984. </when>
  985. <otherwise>
  986. and t.ad_code is null
  987. </otherwise>
  988. </choose>
  989. </select>
  990. <select id="getObj" parameterType="cn.com.goldenwater.dcproj.model.BisInspAllObj"
  991. resultType="cn.com.goldenwater.dcproj.dto.BisInspAllObjDto">
  992. SELECT * FROM BIS_INSP_ALL_OBJ WHERE ID = #{id} AND CODE = #{code} AND ptype = #{ptype}
  993. <choose>
  994. <when test="province !=null and province !=''">
  995. and ad_code=#{province}
  996. </when>
  997. <otherwise>
  998. and ad_code is null
  999. </otherwise>
  1000. </choose>
  1001. </select>
  1002. <select id="getGroup" parameterType="String" resultType="cn.com.goldenwater.dcproj.dto.ObjectNameDto">
  1003. SELECT ID,PNM name FROM BIS_INSP_ALL WHERE ID = #{id}
  1004. </select>
  1005. <!--查询督查范围内的稽察对象-->
  1006. <select id="getListByInspGroupIdObjType" resultType="cn.com.goldenwater.dcproj.model.TacAttPawpBase">
  1007. select t.*,C.id AS GROUPID,C.PNM,o.OBJ_ID
  1008. from TAC_ATT_PAWP_BASE t
  1009. left join BIS_INSP_ALL_OBJ o
  1010. on o.CODE = t.id
  1011. LEFT JOIN BIS_INSP_ALL C ON o.ID = C.ID
  1012. and o.ptype = #{objType}
  1013. where 1 = 1
  1014. <if test='isAll == "0"'>and o.ID = #{inspGroupId}</if>
  1015. <if test='isAll == "1"'>and o.ID LIKE '${inspGroupId}%'</if>
  1016. <if test="wtdstNm != null and wtdstNm != ''">and t.NAME LIKE '%${wtdstNm}%'</if>
  1017. <if test="wtdstType != null and wtdstType != ''">and t.TYPE LIKE '%${wtdstType}%'</if>
  1018. <if test="adCode != null and adCode != ''">and t.AD_CODE LIKE '${adCode}%'</if>
  1019. <include refid="choseProvinceSql"/>
  1020. </select>
  1021. <sql id="choseProvinceSql">
  1022. <choose>
  1023. <when test="province !=null and province !=''">
  1024. AND o.ad_code=#{province}
  1025. </when>
  1026. <otherwise>
  1027. AND o.ad_code is null
  1028. </otherwise>
  1029. </choose>
  1030. </sql>
  1031. <select id="findGroupCountByAdCode" resultType="cn.com.goldenwater.dcproj.dto.DcTypeDto">
  1032. select LTRIM(t.code,'00') as OBJTYPE,t.name,nvl(d.total,0) AS TOTAL from ATT_INSP_TYPE t left join (
  1033. select f.ptype,count(1) AS TOTAL from (
  1034. select D.ptype,l.* from bis_insp_all l ,(
  1035. select distinct * from (
  1036. select ptype, ID from (
  1037. <include refid="commonChose"/>
  1038. ) W where w.ad_code=#{adCode}
  1039. <if test="startTime != null and startTime != ''">and w.obj_intm&gt;= TO_DATE(#{startTime},'YYYY-MM-DD')</if>
  1040. <if test="endTime != null and endTime != ''">and w.obj_intm &lt; TO_DATE(#{endTime},'YYYY-MM-DD')+1</if>
  1041. <if test="pTypes != null and pTypes != ''">
  1042. and w.pType in (${pTypes})
  1043. </if>
  1044. <if test="orgIds != null and orgIds != ''">
  1045. and substr(w.id,4,3) in (${orgIds})
  1046. </if>
  1047. ) S ) D where l.id=d.id
  1048. ) F GROUP BY F.ptype
  1049. ) D on LTRIM(t.code,'0') = d.ptype
  1050. order by t.code
  1051. </select>
  1052. <select id="findPerCountByAdCode" resultType="cn.com.goldenwater.dcproj.dto.DcTypeDto"
  1053. parameterType="cn.com.goldenwater.dcproj.param.IndexParamPage">
  1054. select LTRIM(t.code,'00') as OBJTYPE,t.name,nvl(d.total,0) AS TOTAL from ATT_INSP_TYPE t left join (
  1055. select f.ptype,count(1) AS TOTAL from (
  1056. select D.ptype,D.id,p.pers_name,p.org_nm,p.org_id,p.dpnm,p.mobilenumb,p.dppost,p.guid,p.email,a.pnm from
  1057. bis_insp_all_rlation l ,bis_insp_all_rlation_pers p,bis_insp_all a,(
  1058. select distinct * from (
  1059. select ptype, ID from (
  1060. <include refid="commonChose"/>
  1061. ) W where w.ad_code=#{adCode}
  1062. <if test="startTime != null and startTime != ''">and w.obj_intm&gt;= TO_DATE(#{startTime},'YYYY-MM-DD')</if>
  1063. <if test="endTime != null and endTime != ''">and w.obj_intm &lt; TO_DATE(#{endTime},'YYYY-MM-DD')+1</if>
  1064. <if test="pTypes != null and pTypes != ''">
  1065. and w.pType in (${pTypes})
  1066. </if>
  1067. <if test="orgIds != null and orgIds != ''">
  1068. and substr(w.id,4,3) in (${orgIds})
  1069. </if>
  1070. ) S ) D where l.id=d.id and l.persid=p.guid and a.id=d.id
  1071. ) F GROUP BY F.ptype
  1072. ) D on LTRIM(t.code,'0') = d.ptype
  1073. order by t.code
  1074. </select>
  1075. <sql id="selSql">
  1076. select to_char(substr(e.adm_div,0,${length})||'${otherLength}') as
  1077. ad_code,o.code,o.ptype,o.id,o.obj_id,o.obj_intm,o.nm,to_char(e.location) as ad_name
  1078. from bis_insp_all_obj o left join att_rs_base e on o.code=e.rs_code where o.ptype in (1,36,22)
  1079. <include refid="choseSql"/>
  1080. union all
  1081. select substr(o.code,0,${length})||'${otherLength}' as
  1082. ad_code,o.code,o.ptype,o.id,o.obj_id,o.obj_intm,o.nm,s.ad_full_name as ad_name from bis_insp_all_obj
  1083. o,att_ad_x_base s where o.code=s.ad_code and o.ptype=2
  1084. <include refid="choseSql"/>
  1085. union all
  1086. select substr(ob.loc_ad,0,${length})||'${otherLength}' as
  1087. ad_code,o.code,o.ptype,o.id,o.obj_id,o.obj_intm,o.nm,ob.loc_nm as ad_name from bis_insp_all_obj o left join
  1088. BIS_INSP_WTDST OB ON o.CODE = OB.WTDST_ID where o.ptype=3
  1089. <include refid="choseSql"/>
  1090. union all
  1091. select substr(ke.ad_code,0,${length})||'${otherLength}' as
  1092. ad_code,o.code,o.ptype,o.id,o.obj_id,o.obj_intm,o.nm,ba.ad_full_name as ad_name from bis_insp_all_obj o
  1093. left join ATT_EMPWTPRJ_BASE ke ON o.code = ke.id
  1094. left join att_ad_x_base ba on ke.ad_code=ba.ad_code
  1095. where o.ptype in (4,7)
  1096. <include refid="choseSql"/>
  1097. union all
  1098. select substr(ob.adcd,0,${length})||'${otherLength}' as
  1099. ad_code,o.code,o.ptype,o.id,o.obj_id,o.obj_intm,o.nm,ob.adnm as ad_name from bis_insp_all_obj o left join
  1100. ATT_GRW_BASE OB ON o.CODE = OB.stcd where o.ptype=5
  1101. <include refid="choseSql"/>
  1102. union all
  1103. select substr(ob.ad_code,0,${length})||'${otherLength}' as
  1104. ad_code,o.code,o.ptype,o.id,o.obj_id,o.obj_intm,o.nm,ob.location_xiang as ad_name from bis_insp_all_obj o left
  1105. join ATT_WAGA_BASE OB ON o.CODE = OB.obj_code where o.ptype=6
  1106. <include refid="choseSql"/>
  1107. union all
  1108. select substr(ob.ad_code,0,${length})||'${otherLength}' as
  1109. ad_code,o.code,o.ptype,o.id,o.obj_id,o.obj_intm,o.nm,ob.location as ad_name from bis_insp_all_obj o
  1110. left join att_fsc_base OB ON o.CODE = OB.id where o.ptype=9
  1111. <include refid="choseSql"/>
  1112. union all
  1113. select substr(ob.ad_code,0,${length})||'${otherLength}' as
  1114. ad_code,o.code,o.ptype,o.id,o.obj_id,o.obj_intm,o.nm,ob.location as ad_name from bis_insp_all_obj o
  1115. left join att_other_base OB ON o.CODE = OB.id where o.ptype=10
  1116. <include refid="choseSql"/>
  1117. union all
  1118. select substr(ob.ad_code,0,${length})||'${otherLength}' as
  1119. ad_code,o.code,o.ptype,o.id,o.obj_id,o.obj_intm,o.nm,OB.note as ad_name from bis_insp_all_obj o
  1120. left join att_sd_base OB ON o.CODE = OB.SD_CODE where o.ptype=11
  1121. <include refid="choseSql"/>
  1122. union all
  1123. select substr(ob.ad_code,0,${length})||'${otherLength}' as
  1124. ad_code,o.code,o.ptype,o.id,o.obj_id,o.obj_intm,o.nm,OB.WINT_POS as ad_name from bis_insp_all_obj o
  1125. left join att_wain_base OB ON o.CODE = OB.OBJ_CODE where o.ptype=12
  1126. <include refid="choseSql"/>
  1127. union all
  1128. select substr(ob.ad_code,0,${length})||'${otherLength}' as
  1129. ad_code,o.code,o.ptype,o.id,o.obj_id,o.obj_intm,o.nm,OB.SWHS_LOC as ad_name from bis_insp_all_obj o
  1130. left join ATT_SWHS_BASE OB ON o.CODE = OB.id where o.ptype=13
  1131. <include refid="choseSql"/>
  1132. union all
  1133. select substr(ob.ad_code,0,${length})||'${otherLength}' as
  1134. ad_code,o.code,o.ptype,o.id,o.obj_id,o.obj_intm,o.nm,OB.AD_FULL_NAME as ad_name from bis_insp_all_obj o
  1135. left join ATT_AD_X_BASE OB ON o.CODE = OB.AD_CODE where o.ptype=14
  1136. <include refid="choseSql"/>
  1137. union all
  1138. select substr(ob.ad_code,0,${length})||'${otherLength}' as
  1139. ad_code,o.code,o.ptype,o.id,o.obj_id,o.obj_intm,o.nm,OB.AD_FULL_NAME as ad_name from bis_insp_all_obj o
  1140. left join ATT_AD_X_BASE OB ON o.CODE = OB.AD_CODE where o.ptype=15
  1141. <include refid="choseSql"/>
  1142. union all
  1143. select substr(ob.ad_code,0,${length})||'${otherLength}' as
  1144. ad_code,o.code,o.ptype,o.id,o.obj_id,o.obj_intm,o.nm,OB.ad_name from bis_insp_all_obj o
  1145. left join att_wunt_base OB ON o.CODE = OB.ID where o.ptype=16
  1146. <include refid="choseSql"/>
  1147. union all
  1148. select substr(ob.ad_code,0,${length})||'${otherLength}' as
  1149. ad_code,o.code,o.ptype,o.id,o.obj_id,o.obj_intm,o.nm,OB.ad_name from bis_insp_all_obj o
  1150. left join ATT_PRD_CSTR_PROJ_BASE OB ON o.CODE = OB.ID where o.ptype=17
  1151. <include refid="choseSql"/>
  1152. union all
  1153. select substr(ob.ad_code,0,${length})||'${otherLength}' as
  1154. ad_code,o.code,o.ptype,o.id,o.obj_id,o.obj_intm,o.nm,OB.ad_name from bis_insp_all_obj o
  1155. left join ATT_JSKEJIAN_FLKDIS_BASE OB ON o.CODE = OB.ID where o.ptype=18
  1156. <include refid="choseSql"/>
  1157. union all
  1158. select substr(ob.ad_code,0,${length})||'${otherLength}' as
  1159. ad_code,o.code,o.ptype,o.id,o.obj_id,o.obj_intm,o.nm,OB.ad_name from bis_insp_all_obj o
  1160. left join ATT_JSKEJIAN_WATER_BASE OB ON o.CODE = OB.ID where o.ptype=19
  1161. <include refid="choseSql"/>
  1162. union all
  1163. select substr(ob.ad_code,0,${length})||'${otherLength}' as
  1164. ad_code,o.code,o.ptype,o.id,o.obj_id,o.obj_intm,o.nm,OB.ad_name from bis_insp_all_obj o
  1165. left join ATT_JSKEJIAN_Ecofrd_BASE OB ON o.CODE = OB.ID where o.ptype=20
  1166. <include refid="choseSql"/>
  1167. </sql>
  1168. <select id="findObjCountByAdCode" resultType="cn.com.goldenwater.dcproj.dto.DcTypeDto"
  1169. parameterType="cn.com.goldenwater.dcproj.param.IndexParamPage">
  1170. select LTRIM(t.code,'00') as OBJTYPE,t.name,nvl(d.total,0) AS TOTAL from ATT_INSP_TYPE t left join (
  1171. select f.ptype,count(1) AS TOTAL from (
  1172. select W.* from (
  1173. <include refid="selSql"/>
  1174. ) W where w.ad_code=#{adCode}
  1175. <if test="startTime != null and startTime != ''">and w.obj_intm&gt;= TO_DATE(#{startTime},'YYYY-MM-DD')</if>
  1176. <if test="endTime != null and endTime != ''">and w.obj_intm &lt; TO_DATE(#{endTime},'YYYY-MM-DD')+1</if>
  1177. <if test="pTypes != null and pTypes != ''">
  1178. and w.pType in (${pTypes})
  1179. </if>
  1180. <if test="orgIds != null and orgIds != ''">
  1181. and substr(w.id,4,3) in (${orgIds})
  1182. </if>
  1183. ) F GROUP BY F.ptype
  1184. ) D ON LTRIM(t.code,'0') = d.ptype
  1185. order by t.code
  1186. </select>
  1187. <!--督查问题-->
  1188. <select id="findPblmCountByAdCode" resultType="cn.com.goldenwater.dcproj.dto.DcTypeDto"
  1189. parameterType="cn.com.goldenwater.dcproj.param.IndexParamPage">
  1190. select LTRIM(t.code,'00') as OBJTYPE,t.name,nvl(d.total,0) AS TOTAL from ATT_INSP_TYPE t left join (
  1191. select f.PTYPE,count(1) AS TOTAL from (
  1192. select w.ptype,w.nm,m.* from bis_insp_pblm m, (
  1193. <include refid="commonChose"/>
  1194. ) W where w.obj_id=m.obj_id and w.ad_code=#{adCode}
  1195. <if test="startTime != null and startTime != ''">and w.obj_intm&gt;= TO_DATE(#{startTime},'YYYY-MM-DD')</if>
  1196. <if test="endTime != null and endTime != ''">and w.obj_intm &lt; TO_DATE(#{endTime},'YYYY-MM-DD')+1</if>
  1197. <if test="pTypes != null and pTypes != ''">
  1198. and w.pType in (${pTypes})
  1199. </if>
  1200. <if test="orgIds != null and orgIds != ''">
  1201. and substr(w.id,4,3) in (${orgIds})
  1202. </if>
  1203. ) F GROUP BY F.ptype
  1204. ) D on LTRIM(t.code,'0') = d.ptype
  1205. order by t.code
  1206. </select>
  1207. <select id="listByMap" resultType="cn.com.goldenwater.dcproj.dto.BisInspAllObjDto">
  1208. SELECT O.*, A.NAME AS OBJ_TYPE_NAME, AB.AD_FULL_NAME, AL.PNM
  1209. FROM BIS_INSP_ALL_OBJ O
  1210. JOIN (select * FROM ATT_INSP_TYPE where code IN (select INSP_TYPE FROM REL_ORG_INSP_TYPE
  1211. <where>
  1212. <if test="orgId != null and orgId != '' ">
  1213. AND ORG_ID = #{orgId}
  1214. </if>
  1215. </where>
  1216. )) A ON O.PTYPE = A.PTYPE
  1217. JOIN BIS_INSP_ALL AL ON O.ID = AL.ID
  1218. LEFT JOIN ATT_AD_BASE AB ON O.OBJ_AD_CODE = AB.AD_CODE
  1219. <where>
  1220. <if test="depm != null and depm.size() > 0 ">
  1221. AND A.CODE IN (SELECT PTYPE FROM ATT_INSP_TYPE_DUTY where DUTY_DEP IN
  1222. <foreach item="item" index="index" collection="depm" open="(" separator="," close=")">
  1223. '${item}'
  1224. </foreach>
  1225. )
  1226. </if>
  1227. <if test="id != null and id != ''">and O.ID like '%${id}%'</if>
  1228. <if test="orgId != null and orgId != '' ">AND O.ID LIKE '___${orgId}%'</if>
  1229. <if test="objType != null and objType != ''">and O.PTYPE = #{objType}</if>
  1230. <if test="objTypeName != null and objTypeName != ''">and A.NAME LIKE '%${objTypeName}%'</if>
  1231. <if test="nm != null and nm != ''">and O.nm like '%${nm}%'</if>
  1232. <if test="adCode != null and adCode != ''">and O.OBJ_AD_CODE like '${adCode}%'</if>
  1233. <!-- 福建省 福州市排除 平潭县 把平潭县 归属到 平潭综合实验区-->
  1234. <if test='adCode != null and adCode == "3501" '>AND SUBSTR(O.OBJ_AD_CODE, 0, 6) !='350128'</if>
  1235. <if test='adCode != null and adCode == "3510" '>AND SUBSTR(O.OBJ_AD_CODE, 0, 6) ='350128'</if>
  1236. <if test="pnm != null and pnm != ''">and AL.PNM like '%${pnm}%'</if>
  1237. <if test="adFullName != null and adFullName != ''">and AB.AD_FULL_NAME like '%${adFullName}%'</if>
  1238. <if test="sttm != null and sttm != '' and entm != null and entm != '' ">
  1239. AND O.OBJ_INTM &gt;= TO_DATE(#{sttm}, 'YYYY-MM-DD')
  1240. AND O.OBJ_INTM &lt; TO_DATE(#{entm}, 'YYYY-MM-DD') + 1
  1241. </if>
  1242. <if test='null !=isRepeat and "" != isRepeat and "1" == isRepeat.toString() '>
  1243. AND O.code in ( select biaoin.code from BIS_INSP_ALL_OBJ biaoin
  1244. <where>
  1245. <if test='orgId != null and orgId != "" '>
  1246. AND biaoin.ORG_ID = #{orgId}
  1247. </if>
  1248. <if test='adCode != null and adCode != "" '>AND biaoin.OBJ_AD_CODE like '${adCode}%'</if>
  1249. </where>
  1250. group by biaoin.code having count(biaoin.code) &gt; 1
  1251. )
  1252. </if>
  1253. <if test='null !=isRepeat and "" != isRepeat and "1" != isRepeat.toString() '>
  1254. AND O.code in ( select biaoin.code from BIS_INSP_ALL_OBJ biaoin
  1255. <where>
  1256. <if test="orgId != null and orgId != '' ">
  1257. AND biaoin.ORG_ID = #{orgId}
  1258. </if>
  1259. <if test='adCode != null and adCode != "" '> AND biaoin.OBJ_AD_CODE like '${adCode}%'</if>
  1260. </where>
  1261. group by biaoin.code having count(biaoin.code) = 1
  1262. )
  1263. </if>
  1264. </where>
  1265. order by O.PTYPE, O.OBJ_AD_CODE, O.OBJ_ID
  1266. </select>
  1267. <select id="getTableName" resultType="String">
  1268. SELECT RGSTR_TABLE_NAME
  1269. FROM ATT_INSP_TYPE where PTYPE = #{ptype}
  1270. </select>
  1271. <select id="getRgstrIdAndState" resultType="cn.com.goldenwater.dcproj.dto.BisInspAllObjDto">
  1272. SELECT ${idName},STATE
  1273. FROM ${tableName} where OBJ_ID = #{objId}
  1274. </select>
  1275. <select id="listOfRgstr" resultType="java.util.Map">
  1276. select
  1277. O.ID AS "groupId", SUBSTR(O.ID, 4, 3) AS "orgId",
  1278. O.CODE AS "code", O.NM AS "nm", O.OBJ_AD_CODE AS "adCode",
  1279. R.OBJ_ID AS "objId", R.${stateName} AS "state"
  1280. FROM ${tableName} R
  1281. JOIN BIS_INSP_ALL_OBJ O ON O.OBJ_ID = R.OBJ_ID
  1282. JOIN BIS_INSP_ALL G ON G.ID = O.ID
  1283. <where>
  1284. <if test="adCode != null and adCode != ''">
  1285. O.OBJ_AD_CODE LIKE CONCAT(#{adCode}, '%')
  1286. </if>
  1287. <if test="groupIds != null and groupIds != ''">
  1288. O.ID IN (${groupIds})
  1289. </if>
  1290. <if test="objId != null and objId != ''">
  1291. AND O.OBJ_ID = #{objId}
  1292. </if>
  1293. <if test="objType != null and objType != ''">
  1294. AND O.PTYPE = #{objType}
  1295. </if>
  1296. <if test="orgIds != null and orgIds != ''">
  1297. AND O.ORG_ID IN (${orgIds})
  1298. </if>
  1299. <if test="orgId != null and orgId != ''">
  1300. AND O.ORG_ID = #{orgId}
  1301. </if>
  1302. <if test="state != null and state != ''">
  1303. AND R.${stateName} = #{state}
  1304. </if>
  1305. <if test="nm != null and nm != ''">
  1306. AND O.NM like '%${nm}%'
  1307. </if>
  1308. <if test="chkType != null and chkType != ''">
  1309. AND G.CHK_TYPE = #{chkType}
  1310. </if>
  1311. </where>
  1312. </select>
  1313. <select id="listOfGenrl" resultType="cn.com.goldenwater.dcproj.model.BisInspAllObj">
  1314. SELECT
  1315. O.CODE, O.ID, O.NM, O.LGTD, O.LTTD, O.OBJ_ID, O.ORG_ID, O.OBJ_AD_CODE, BN.OBJ_TYPE PTYPE
  1316. FROM
  1317. BIS_INSP_ALL_OBJ O
  1318. LEFT JOIN BIS_INSP_BASE_NEW BN ON BN.ID = O.CODE
  1319. WHERE O.PTYPE = '128'
  1320. <if test="id != null and id != ''">and O.ID = #{id}</if>
  1321. <if test="ids != null and ids != ''">and O.ID in (${ids})</if>
  1322. <if test="nm != null and nm != ''">and O.NM = #{nm}</if>
  1323. <if test="provincial != null and provincial != ''">and O.PROVINCIAL = #{provincial}</if>
  1324. <if test="adCode != null and adCode != ''">and O.AD_CODE = #{adCode}</if>
  1325. <if test="orgId != null and orgId != ''">and O.ORG_ID = #{orgId}</if>
  1326. <if test="ptype != null and ptype != ''">and O.PTYPE = #{ptype}</if>
  1327. <if test="lgtd != null and lgtd != ''">and O.LGTD = #{lgtd}</if>
  1328. <if test="lttd != null and lttd != ''">and O.LTTD = #{lttd}</if>
  1329. <if test="objId != null and objId != ''">and O.OBJ_ID = #{objId}</if>
  1330. <if test="code != null and code != ''">and O.CODE = #{code}</if>
  1331. <if test="lgtdpc != null and lgtdpc != ''">and O.LGTDPC = #{lgtdpc}</if>
  1332. <if test="lttdpc != null and lttdpc != ''">and O.LTTDPC = #{lttdpc}</if>
  1333. <if test="objAdCode != null and objAdCode != ''">and O.OBJ_AD_CODE = #{objAdCode}</if>
  1334. </select>
  1335. <select id="listOfGenrlBase" resultType="cn.com.goldenwater.dcproj.model.BisInspBaseNew">
  1336. SELECT
  1337. distinct BN.*
  1338. FROM
  1339. BIS_INSP_ALL_OBJ O
  1340. LEFT JOIN BIS_INSP_BASE_NEW BN ON BN.ID = O.CODE
  1341. LEFT JOIN BIS_INSP_GENRL_RGSTR R ON R.OBJ_ID = O.OBJ_ID
  1342. WHERE O.PTYPE = '128' AND R.STATE IN ('1', '2')
  1343. <if test="id != null and id != ''">and O.ID = #{id}</if>
  1344. <if test="ids != null and ids != ''">and O.ID in (${ids})</if>
  1345. <if test="nm != null and nm != ''">and O.NM = #{nm}</if>
  1346. <if test="provincial != null and provincial != ''">and O.PROVINCIAL = #{provincial}</if>
  1347. <if test="adCode != null and adCode != ''">and O.AD_CODE = #{adCode}</if>
  1348. <if test="orgId != null and orgId != ''">and O.ORG_ID = #{orgId}</if>
  1349. <if test="ptype != null and ptype != ''">and O.PTYPE = #{ptype}</if>
  1350. <if test="lgtd != null and lgtd != ''">and O.LGTD = #{lgtd}</if>
  1351. <if test="lttd != null and lttd != ''">and O.LTTD = #{lttd}</if>
  1352. <if test="objId != null and objId != ''">and O.OBJ_ID = #{objId}</if>
  1353. <if test="code != null and code != ''">and O.CODE = #{code}</if>
  1354. <if test="lgtdpc != null and lgtdpc != ''">and O.LGTDPC = #{lgtdpc}</if>
  1355. <if test="lttdpc != null and lttdpc != ''">and O.LTTDPC = #{lttdpc}</if>
  1356. <if test="objAdCode != null and objAdCode != ''">and O.OBJ_AD_CODE = #{objAdCode}</if>
  1357. </select>
  1358. <update id="updateRgstrState">
  1359. update ${tableName} SET ${stateName} = ${state}
  1360. WHERE
  1361. <choose>
  1362. <when test="objIdList != null and objIdList.size() > 0">
  1363. OBJ_ID IN
  1364. <foreach item="objIds" index="index" collection="objIdList" open="(" separator=") OR OBJ_ID IN ("
  1365. close=")">
  1366. ${objIds}
  1367. </foreach>
  1368. </when>
  1369. <otherwise>
  1370. OBJ_ID = #{objId}
  1371. </otherwise>
  1372. </choose>
  1373. </update>
  1374. </mapper>