BisInspAllObjDao.xml 66 KB

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