OptInfoMapper.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.diagbot.mapper.OptInfoMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.diagbot.entity.OptInfo">
  6. <id column="id" property="id" />
  7. <result column="is_deleted" property="isDeleted" />
  8. <result column="gmt_create" property="gmtCreate" />
  9. <result column="gmt_modified" property="gmtModified" />
  10. <result column="creator" property="creator" />
  11. <result column="modifier" property="modifier" />
  12. <result column="sys_type" property="sysType" />
  13. <result column="hospital_code" property="hospitalCode" />
  14. <result column="ip" property="ip" />
  15. <result column="opt_type" property="optType" />
  16. <result column="remark" property="remark" />
  17. </resultMap>
  18. <select id="getPV" parameterType="com.diagbot.vo.OptVO" resultType="com.diagbot.dto.PVDTO">
  19. SELECT
  20. DATE_FORMAT(gmt_create, '%Y-%m-%d') AS days,
  21. count(1) AS pvCnt
  22. FROM
  23. xlcs_opt_info
  24. WHERE
  25. opt_type = 1
  26. <if test="hospitalCode != null and hospitalCode != ''">
  27. AND hospital_code = #{hospitalCode}
  28. </if>
  29. <if test="startDate!=null">
  30. AND gmt_create &gt;= #{startDate}
  31. </if>
  32. <if test="endDate!=null">
  33. AND gmt_create &lt;= #{endDate}
  34. </if>
  35. <if test="sysType!=null">
  36. AND sys_type &lt;= #{sysType}
  37. </if>
  38. GROUP BY
  39. DATE_FORMAT(gmt_create, '%Y-%m-%d')
  40. ORDER BY
  41. DATE_FORMAT(gmt_create, '%Y-%m-%d');
  42. </select>
  43. <select id="getPVSum" parameterType="com.diagbot.vo.OptVO" resultType="java.lang.Long">
  44. SELECT
  45. count(1) AS pvSum
  46. FROM
  47. xlcs_opt_info
  48. WHERE
  49. opt_type = 1
  50. <if test="hospitalCode != null and hospitalCode != ''">
  51. AND hospital_code = #{hospitalCode}
  52. </if>
  53. <if test="sysType!=null">
  54. AND sys_type &lt;= #{sysType}
  55. </if>
  56. <if test="startDate!=null">
  57. AND gmt_create &gt;= #{startDate}
  58. </if>
  59. <if test="endDate!=null">
  60. AND gmt_create &lt;= #{endDate}
  61. </if>
  62. </select>
  63. <select id="getUV" parameterType="com.diagbot.vo.OptVO" resultType="com.diagbot.dto.UVDTO">
  64. SELECT
  65. t.days AS days,
  66. count(ip) AS uvCnt
  67. FROM
  68. (
  69. SELECT DISTINCT
  70. DATE_FORMAT(gmt_create, '%Y-%m-%d') AS days,
  71. ip
  72. FROM
  73. xlcs_opt_info
  74. WHERE
  75. opt_type = 1
  76. <if test="hospitalCode != null and hospitalCode != ''">
  77. AND hospital_code = #{hospitalCode}
  78. </if>
  79. <if test="sysType!=null">
  80. AND sys_type &lt;= #{sysType}
  81. </if>
  82. <if test="startDate!=null">
  83. AND gmt_create &gt;= #{startDate}
  84. </if>
  85. <if test="endDate!=null">
  86. AND gmt_create &lt;= #{endDate}
  87. </if>
  88. ) t
  89. GROUP BY
  90. days
  91. ORDER BY
  92. days;
  93. </select>
  94. <select id="getUVSum" parameterType="com.diagbot.vo.OptVO" resultType="java.lang.Long">
  95. SELECT
  96. count(ip) AS uvSum
  97. FROM
  98. (
  99. SELECT DISTINCT
  100. DATE_FORMAT(gmt_create, '%Y-%m-%d') AS days,
  101. ip
  102. FROM
  103. xlcs_opt_info
  104. WHERE
  105. opt_type = 1
  106. <if test="hospitalCode != null and hospitalCode != ''">
  107. AND hospital_code = #{hospitalCode}
  108. </if>
  109. <if test="sysType!=null">
  110. AND sys_type &lt;= #{sysType}
  111. </if>
  112. <if test="startDate!=null">
  113. AND gmt_create &gt;= #{startDate}
  114. </if>
  115. <if test="endDate!=null">
  116. AND gmt_create &lt;= #{endDate}
  117. </if>
  118. ) t;
  119. </select>
  120. <select id="getZZ" parameterType="com.diagbot.vo.OptVO" resultType="com.diagbot.dto.ZZDTO">
  121. SELECT
  122. t.days AS days,
  123. count(ip) AS zzCnt
  124. FROM
  125. (
  126. SELECT DISTINCT
  127. DATE_FORMAT(gmt_create, '%Y-%m-%d') AS days,
  128. ip
  129. FROM
  130. xlcs_opt_info
  131. WHERE
  132. opt_type = 2
  133. <if test="hospitalCode != null and hospitalCode != ''">
  134. AND hospital_code = #{hospitalCode}
  135. </if>
  136. <if test="sysType!=null">
  137. AND sys_type &lt;= #{sysType}
  138. </if>
  139. <if test="startDate!=null">
  140. AND gmt_create &gt;= #{startDate}
  141. </if>
  142. <if test="endDate!=null">
  143. AND gmt_create &lt;= #{endDate}
  144. </if>
  145. ) t
  146. GROUP BY
  147. days
  148. ORDER BY
  149. days;
  150. </select>
  151. <select id="getZZSum" parameterType="com.diagbot.vo.OptVO" resultType="java.lang.Long">
  152. SELECT
  153. count(ip) AS zzSum
  154. FROM
  155. (
  156. SELECT DISTINCT
  157. DATE_FORMAT(gmt_create, '%Y-%m-%d') AS days,
  158. ip
  159. FROM
  160. xlcs_opt_info
  161. WHERE
  162. opt_type = 2
  163. <if test="hospitalCode != null and hospitalCode != ''">
  164. AND hospital_code = #{hospitalCode}
  165. </if>
  166. <if test="sysType!=null">
  167. AND sys_type &lt;= #{sysType}
  168. </if>
  169. <if test="startDate!=null">
  170. AND gmt_create &gt;= #{startDate}
  171. </if>
  172. <if test="endDate!=null">
  173. AND gmt_create &lt;= #{endDate}
  174. </if>
  175. ) t;
  176. </select>
  177. <!--按照医院合计-->
  178. <select id="getPVHosp" parameterType="com.diagbot.vo.OptVO" resultType="com.diagbot.dto.PVHospDTO">
  179. SELECT
  180. hospital_code AS hospitalCode,
  181. DATE_FORMAT(gmt_create, '%Y-%m-%d') AS days,
  182. count(1) AS pvCnt
  183. FROM
  184. xlcs_opt_info
  185. WHERE
  186. opt_type = 1
  187. <if test="hospitalCode != null and hospitalCode != ''">
  188. AND hospital_code = #{hospitalCode}
  189. </if>
  190. <if test="sysType!=null">
  191. AND sys_type &lt;= #{sysType}
  192. </if>
  193. <if test="startDate!=null">
  194. AND gmt_create &gt;= #{startDate}
  195. </if>
  196. <if test="endDate!=null">
  197. AND gmt_create &lt;= #{endDate}
  198. </if>
  199. -- AND hospital_code !='朗通通用'
  200. GROUP BY
  201. hospital_code,
  202. DATE_FORMAT(gmt_create, '%Y-%m-%d')
  203. ORDER BY
  204. hospital_code,
  205. DATE_FORMAT(gmt_create, '%Y-%m-%d');
  206. </select>
  207. <select id="getPVSumHosp" parameterType="com.diagbot.vo.OptVO" resultType="com.diagbot.dto.PVHospSumDTO">
  208. SELECT
  209. hospital_code AS hospitalCode,
  210. count(1) AS pvSum
  211. FROM
  212. xlcs_opt_info
  213. WHERE
  214. opt_type = 1
  215. <if test="hospitalCode != null and hospitalCode != ''">
  216. AND hospital_code = #{hospitalCode}
  217. </if>
  218. <if test="sysType!=null">
  219. AND sys_type &lt;= #{sysType}
  220. </if>
  221. <if test="startDate!=null">
  222. AND gmt_create &gt;= #{startDate}
  223. </if>
  224. <if test="endDate!=null">
  225. AND gmt_create &lt;= #{endDate}
  226. </if>
  227. -- AND hospital_code !='朗通通用'
  228. GROUP BY
  229. hospital_code
  230. ORDER BY
  231. pvSum desc;
  232. </select>
  233. <select id="getUVHosp" parameterType="com.diagbot.vo.OptVO" resultType="com.diagbot.dto.UVHospDTO">
  234. SELECT
  235. t.hospitalCode AS hospitalCode,
  236. t.days AS days,
  237. count(ip) AS uvCnt
  238. FROM
  239. (
  240. SELECT DISTINCT
  241. hospital_code AS hospitalCode,
  242. DATE_FORMAT(gmt_create, '%Y-%m-%d') AS days,
  243. ip
  244. FROM
  245. xlcs_opt_info
  246. WHERE
  247. opt_type = 1
  248. <if test="hospitalCode != null and hospitalCode != ''">
  249. AND hospital_code = #{hospitalCode}
  250. </if>
  251. <if test="sysType!=null">
  252. AND sys_type &lt;= #{sysType}
  253. </if>
  254. <if test="startDate!=null">
  255. AND gmt_create &gt;= #{startDate}
  256. </if>
  257. <if test="endDate!=null">
  258. AND gmt_create &lt;= #{endDate}
  259. </if>
  260. -- AND hospital_code !='朗通通用'
  261. ) t
  262. GROUP BY
  263. hospitalCode,
  264. days
  265. ORDER BY
  266. hospitalCode,
  267. days;
  268. </select>
  269. <select id="getUVSumHosp" parameterType="com.diagbot.vo.OptVO" resultType="com.diagbot.dto.UVHospSumDTO">
  270. SELECT
  271. t.hospitalCode AS hospitalCode,
  272. count(ip) AS uvSum
  273. FROM
  274. (
  275. SELECT DISTINCT
  276. hospital_code AS hospitalCode,
  277. DATE_FORMAT(gmt_create, '%Y-%m-%d') AS days,
  278. ip
  279. FROM
  280. xlcs_opt_info
  281. WHERE
  282. opt_type = 1
  283. <if test="hospitalCode != null and hospitalCode != ''">
  284. AND hospital_code = #{hospitalCode}
  285. </if>
  286. <if test="sysType!=null">
  287. AND sys_type &lt;= #{sysType}
  288. </if>
  289. <if test="startDate!=null">
  290. AND gmt_create &gt;= #{startDate}
  291. </if>
  292. <if test="endDate!=null">
  293. AND gmt_create &lt;= #{endDate}
  294. </if>
  295. -- AND hospital_code !='朗通通用'
  296. ) t
  297. GROUP BY
  298. hospitalCode
  299. ORDER BY
  300. uvSum desc;
  301. </select>
  302. <select id="getZZHosp" parameterType="com.diagbot.vo.OptVO" resultType="com.diagbot.dto.ZZHospDTO">
  303. SELECT
  304. t.hospitalCode AS hospitalCode,
  305. t.days AS days,
  306. count(ip) AS zzCnt
  307. FROM
  308. (
  309. SELECT DISTINCT
  310. hospital_code AS hospitalCode,
  311. DATE_FORMAT(gmt_create, '%Y-%m-%d') AS days,
  312. ip
  313. FROM
  314. xlcs_opt_info
  315. WHERE
  316. opt_type = 2
  317. <if test="hospitalCode != null and hospitalCode != ''">
  318. AND hospital_code = #{hospitalCode}
  319. </if>
  320. <if test="sysType!=null">
  321. AND sys_type &lt;= #{sysType}
  322. </if>
  323. <if test="startDate!=null">
  324. AND gmt_create &gt;= #{startDate}
  325. </if>
  326. <if test="endDate!=null">
  327. AND gmt_create &lt;= #{endDate}
  328. </if>
  329. -- AND hospital_code !='朗通通用'
  330. ) t
  331. GROUP BY
  332. hospitalCode,
  333. days
  334. ORDER BY
  335. hospitalCode,
  336. days;
  337. </select>
  338. <select id="getZZSumHosp" parameterType="com.diagbot.vo.OptVO" resultType="com.diagbot.dto.ZZHospSumDTO">
  339. SELECT
  340. t.hospitalCode AS hospitalCode,
  341. count(ip) AS zzSum
  342. FROM
  343. (
  344. SELECT DISTINCT
  345. hospital_code AS hospitalCode,
  346. DATE_FORMAT(gmt_create, '%Y-%m-%d') AS days,
  347. ip
  348. FROM
  349. xlcs_opt_info
  350. WHERE
  351. opt_type = 2
  352. <if test="hospitalCode != null and hospitalCode != ''">
  353. AND hospital_code = #{hospitalCode}
  354. </if>
  355. <if test="sysType!=null">
  356. AND sys_type &lt;= #{sysType}
  357. </if>
  358. <if test="startDate!=null">
  359. AND gmt_create &gt;= #{startDate}
  360. </if>
  361. <if test="endDate!=null">
  362. AND gmt_create &lt;= #{endDate}
  363. </if>
  364. -- AND hospital_code !='朗通通用'
  365. ) t
  366. GROUP BY
  367. hospitalCode
  368. ORDER BY
  369. zzSum desc;
  370. </select>
  371. <select id="getAllHospital" resultType="java.lang.String">
  372. SELECT DISTINCT(hospital_code) AS hospitalCode FROM `xlcs_opt_info` order by hospital_code
  373. </select>
  374. <select id="getHospitalPUZ" resultType="com.diagbot.dto.HospItemDTO">
  375. select tt.hospitalCode, IFNULL(tt.pvSum, 0) pvSum , iFNULL(tt.uvSum, 0) uvSum, iFNULL(tt.zzSum, 0) zzSum from (
  376. select a.*,
  377. (SELECT
  378. count(ip)
  379. FROM
  380. (
  381. SELECT DISTINCT
  382. hospital_code AS hospitalCode,
  383. DATE_FORMAT(gmt_create, '%Y-%m-%d') AS days,
  384. ip
  385. FROM
  386. xlcs_opt_info
  387. WHERE
  388. opt_type = 1
  389. <if test="startDate!=null">
  390. AND gmt_create &gt;= #{startDate}
  391. </if>
  392. <if test="endDate!=null">
  393. AND gmt_create &lt;= #{endDate}
  394. </if>
  395. -- AND hospital_code !='朗通通用'
  396. ) t1 where t1.hospitalCode = a.hospitalCode
  397. GROUP BY
  398. hospitalCode
  399. ) AS uvSum,
  400. (
  401. SELECT
  402. count(ip)
  403. FROM
  404. (
  405. SELECT DISTINCT
  406. hospital_code AS hospitalCode,
  407. DATE_FORMAT(gmt_create, '%Y-%m-%d') AS days,
  408. ip
  409. FROM
  410. xlcs_opt_info
  411. WHERE
  412. opt_type = 2
  413. <if test="startDate!=null">
  414. AND gmt_create &gt;= #{startDate}
  415. </if>
  416. <if test="endDate!=null">
  417. AND gmt_create &lt;= #{endDate}
  418. </if>
  419. ) t2 where t2.hospitalCode = a.hospitalCode
  420. GROUP BY
  421. hospitalCode
  422. ) AS zzSum
  423. from
  424. (
  425. SELECT
  426. hospital_code AS hospitalCode,
  427. count(1) AS pvSum
  428. FROM
  429. xlcs_opt_info
  430. WHERE
  431. opt_type = 1
  432. <if test="hospitalCodeList != null and hospitalCodeList.size > 0">
  433. AND hospital_code in
  434. <foreach collection="hospitalCodeList" item="item" separator="," open="(" close=")">
  435. #{item}
  436. </foreach>
  437. </if>
  438. <if test="sysType!=null">
  439. AND sys_type &lt;= #{sysType}
  440. </if>
  441. <if test="startDate!=null">
  442. AND gmt_create &gt;= #{startDate}
  443. </if>
  444. <if test="endDate!=null">
  445. AND gmt_create &lt;= #{endDate}
  446. </if>
  447. -- AND hospital_code !='朗通通用'
  448. GROUP BY
  449. hospital_code
  450. ORDER BY
  451. hospital_code
  452. ) a
  453. ) tt
  454. </select>
  455. <select id="getPageHospitalPUZ" resultType="com.diagbot.dto.HospItemDTO">
  456. select tt.hospitalCode, IFNULL(tt.pvSum, 0) pvSum , iFNULL(tt.uvSum, 0) uvSum, iFNULL(tt.zzSum, 0) zzSum from (
  457. select a.*,
  458. <choose>
  459. <when test='typeList != null and typeList.contains("uvSum")'>
  460. (SELECT
  461. count(ip)
  462. FROM
  463. (
  464. SELECT DISTINCT
  465. hospital_code AS hospitalCode,
  466. DATE_FORMAT(gmt_create, '%Y-%m-%d') AS days,
  467. ip
  468. FROM
  469. xlcs_opt_info
  470. WHERE
  471. opt_type = 1
  472. <if test="startDate!=null">
  473. AND gmt_create &gt;= #{startDate}
  474. </if>
  475. <if test="endDate!=null">
  476. AND gmt_create &lt;= #{endDate}
  477. </if>
  478. -- AND hospital_code !='朗通通用'
  479. ) t1 where t1.hospitalCode = a.hospitalCode
  480. GROUP BY
  481. hospitalCode
  482. ) AS uvSum
  483. </when>
  484. <otherwise>
  485. 0 AS uvSum
  486. </otherwise>
  487. </choose>
  488. ,
  489. <choose>
  490. <when test='typeList != null and typeList.contains("zzSum")'>
  491. (
  492. SELECT
  493. count(ip)
  494. FROM
  495. (
  496. SELECT DISTINCT
  497. hospital_code AS hospitalCode,
  498. DATE_FORMAT(gmt_create, '%Y-%m-%d') AS days,
  499. ip
  500. FROM
  501. xlcs_opt_info
  502. WHERE
  503. opt_type = 2
  504. <if test="startDate!=null">
  505. AND gmt_create &gt;= #{startDate}
  506. </if>
  507. <if test="endDate!=null">
  508. AND gmt_create &lt;= #{endDate}
  509. </if>
  510. ) t2 where t2.hospitalCode = a.hospitalCode
  511. GROUP BY
  512. hospitalCode
  513. ) AS zzSum
  514. </when>
  515. <otherwise>
  516. 0 AS zzSum
  517. </otherwise>
  518. </choose>
  519. from
  520. (
  521. SELECT
  522. hospital_code AS hospitalCode,
  523. count(1) AS pvSum
  524. FROM
  525. xlcs_opt_info
  526. WHERE
  527. opt_type = 1
  528. <if test="hospitalCodeList != null and hospitalCodeList.size > 0">
  529. AND hospital_code in
  530. <foreach collection="hospitalCodeList" item="item" separator="," open="(" close=")">
  531. #{item}
  532. </foreach>
  533. </if>
  534. <if test="sysType!=null">
  535. AND sys_type &lt;= #{sysType}
  536. </if>
  537. <if test="startDate!=null">
  538. AND gmt_create &gt;= #{startDate}
  539. </if>
  540. <if test="endDate!=null">
  541. AND gmt_create &lt;= #{endDate}
  542. </if>
  543. -- AND hospital_code !='朗通通用'
  544. GROUP BY
  545. hospital_code
  546. ) a
  547. ) tt
  548. </select>
  549. </mapper>