OptInfoMapper.xml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  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="hospital_code" property="hospitalCode" />
  13. <result column="ip" property="ip" />
  14. <result column="opt_type" property="optType" />
  15. <result column="remark" property="remark" />
  16. </resultMap>
  17. <select id="getPV" parameterType="com.diagbot.vo.OptVO" resultType="com.diagbot.dto.PVDTO">
  18. SELECT
  19. DATE_FORMAT(gmt_create, '%Y-%m-%d') AS days,
  20. count(1) AS pvCnt
  21. FROM
  22. zzcx_opt_info
  23. WHERE
  24. opt_type = 1
  25. <if test="hospitalCode != null and hospitalCode != ''">
  26. AND hospital_code = #{hospitalCode}
  27. </if>
  28. <if test="startDate!=null">
  29. AND gmt_create &gt;= #{startDate}
  30. </if>
  31. <if test="endDate!=null">
  32. AND gmt_create &lt;= #{endDate}
  33. </if>
  34. GROUP BY
  35. DATE_FORMAT(gmt_create, '%Y-%m-%d')
  36. ORDER BY
  37. DATE_FORMAT(gmt_create, '%Y-%m-%d');
  38. </select>
  39. <select id="getPVSum" parameterType="com.diagbot.vo.OptVO" resultType="java.lang.Long">
  40. SELECT
  41. count(1) AS pvSum
  42. FROM
  43. zzcx_opt_info
  44. WHERE
  45. opt_type = 1
  46. <if test="hospitalCode != null and hospitalCode != ''">
  47. AND hospital_code = #{hospitalCode}
  48. </if>
  49. <if test="startDate!=null">
  50. AND gmt_create &gt;= #{startDate}
  51. </if>
  52. <if test="endDate!=null">
  53. AND gmt_create &lt;= #{endDate}
  54. </if>
  55. </select>
  56. <select id="getUV" parameterType="com.diagbot.vo.OptVO" resultType="com.diagbot.dto.UVDTO">
  57. SELECT
  58. t.days AS days,
  59. count(ip) AS uvCnt
  60. FROM
  61. (
  62. SELECT DISTINCT
  63. DATE_FORMAT(gmt_create, '%Y-%m-%d') AS days,
  64. ip
  65. FROM
  66. zzcx_opt_info
  67. WHERE
  68. opt_type = 1
  69. <if test="hospitalCode != null and hospitalCode != ''">
  70. AND hospital_code = #{hospitalCode}
  71. </if>
  72. <if test="startDate!=null">
  73. AND gmt_create &gt;= #{startDate}
  74. </if>
  75. <if test="endDate!=null">
  76. AND gmt_create &lt;= #{endDate}
  77. </if>
  78. ) t
  79. GROUP BY
  80. days
  81. ORDER BY
  82. days;
  83. </select>
  84. <select id="getUVSum" parameterType="com.diagbot.vo.OptVO" resultType="java.lang.Long">
  85. SELECT
  86. count(ip) AS uvSum
  87. FROM
  88. (
  89. SELECT DISTINCT
  90. DATE_FORMAT(gmt_create, '%Y-%m-%d') AS days,
  91. ip
  92. FROM
  93. zzcx_opt_info
  94. WHERE
  95. opt_type = 1
  96. <if test="hospitalCode != null and hospitalCode != ''">
  97. AND hospital_code = #{hospitalCode}
  98. </if>
  99. <if test="startDate!=null">
  100. AND gmt_create &gt;= #{startDate}
  101. </if>
  102. <if test="endDate!=null">
  103. AND gmt_create &lt;= #{endDate}
  104. </if>
  105. ) t;
  106. </select>
  107. <select id="getZZ" parameterType="com.diagbot.vo.OptVO" resultType="com.diagbot.dto.ZZDTO">
  108. SELECT
  109. t.days AS days,
  110. count(ip) AS zzCnt
  111. FROM
  112. (
  113. SELECT DISTINCT
  114. DATE_FORMAT(gmt_create, '%Y-%m-%d') AS days,
  115. ip
  116. FROM
  117. zzcx_opt_info
  118. WHERE
  119. opt_type = 2
  120. <if test="hospitalCode != null and hospitalCode != ''">
  121. AND hospital_code = #{hospitalCode}
  122. </if>
  123. <if test="startDate!=null">
  124. AND gmt_create &gt;= #{startDate}
  125. </if>
  126. <if test="endDate!=null">
  127. AND gmt_create &lt;= #{endDate}
  128. </if>
  129. ) t
  130. GROUP BY
  131. days
  132. ORDER BY
  133. days;
  134. </select>
  135. <select id="getZZSum" parameterType="com.diagbot.vo.OptVO" resultType="java.lang.Long">
  136. SELECT
  137. count(ip) AS zzSum
  138. FROM
  139. (
  140. SELECT DISTINCT
  141. DATE_FORMAT(gmt_create, '%Y-%m-%d') AS days,
  142. ip
  143. FROM
  144. zzcx_opt_info
  145. WHERE
  146. opt_type = 2
  147. <if test="hospitalCode != null and hospitalCode != ''">
  148. AND hospital_code = #{hospitalCode}
  149. </if>
  150. <if test="startDate!=null">
  151. AND gmt_create &gt;= #{startDate}
  152. </if>
  153. <if test="endDate!=null">
  154. AND gmt_create &lt;= #{endDate}
  155. </if>
  156. ) t;
  157. </select>
  158. <!--按照医院合计-->
  159. <select id="getPVHosp" parameterType="com.diagbot.vo.OptVO" resultType="com.diagbot.dto.PVHospDTO">
  160. SELECT
  161. hospital_code AS hospitalCode,
  162. DATE_FORMAT(gmt_create, '%Y-%m-%d') AS days,
  163. count(1) AS pvCnt
  164. FROM
  165. zzcx_opt_info
  166. WHERE
  167. opt_type = 1
  168. <if test="hospitalCode != null and hospitalCode != ''">
  169. AND hospital_code = #{hospitalCode}
  170. </if>
  171. <if test="startDate!=null">
  172. AND gmt_create &gt;= #{startDate}
  173. </if>
  174. <if test="endDate!=null">
  175. AND gmt_create &lt;= #{endDate}
  176. </if>
  177. -- AND hospital_code !='朗通通用'
  178. GROUP BY
  179. hospital_code,
  180. DATE_FORMAT(gmt_create, '%Y-%m-%d')
  181. ORDER BY
  182. hospital_code,
  183. DATE_FORMAT(gmt_create, '%Y-%m-%d');
  184. </select>
  185. <select id="getPVSumHosp" parameterType="com.diagbot.vo.OptVO" resultType="com.diagbot.dto.PVHospSumDTO">
  186. SELECT
  187. hospital_code AS hospitalCode,
  188. count(1) AS pvSum
  189. FROM
  190. zzcx_opt_info
  191. WHERE
  192. opt_type = 1
  193. <if test="hospitalCode != null and hospitalCode != ''">
  194. AND hospital_code = #{hospitalCode}
  195. </if>
  196. <if test="startDate!=null">
  197. AND gmt_create &gt;= #{startDate}
  198. </if>
  199. <if test="endDate!=null">
  200. AND gmt_create &lt;= #{endDate}
  201. </if>
  202. -- AND hospital_code !='朗通通用'
  203. GROUP BY
  204. hospital_code
  205. ORDER BY
  206. pvSum desc;
  207. </select>
  208. <select id="getUVHosp" parameterType="com.diagbot.vo.OptVO" resultType="com.diagbot.dto.UVHospDTO">
  209. SELECT
  210. t.hospitalCode AS hospitalCode,
  211. t.days AS days,
  212. count(ip) AS uvCnt
  213. FROM
  214. (
  215. SELECT DISTINCT
  216. hospital_code AS hospitalCode,
  217. DATE_FORMAT(gmt_create, '%Y-%m-%d') AS days,
  218. ip
  219. FROM
  220. zzcx_opt_info
  221. WHERE
  222. opt_type = 1
  223. <if test="hospitalCode != null and hospitalCode != ''">
  224. AND hospital_code = #{hospitalCode}
  225. </if>
  226. <if test="startDate!=null">
  227. AND gmt_create &gt;= #{startDate}
  228. </if>
  229. <if test="endDate!=null">
  230. AND gmt_create &lt;= #{endDate}
  231. </if>
  232. -- AND hospital_code !='朗通通用'
  233. ) t
  234. GROUP BY
  235. hospitalCode,
  236. days
  237. ORDER BY
  238. hospitalCode,
  239. days;
  240. </select>
  241. <select id="getUVSumHosp" parameterType="com.diagbot.vo.OptVO" resultType="com.diagbot.dto.UVHospSumDTO">
  242. SELECT
  243. t.hospitalCode AS hospitalCode,
  244. count(ip) AS uvSum
  245. FROM
  246. (
  247. SELECT DISTINCT
  248. hospital_code AS hospitalCode,
  249. DATE_FORMAT(gmt_create, '%Y-%m-%d') AS days,
  250. ip
  251. FROM
  252. zzcx_opt_info
  253. WHERE
  254. opt_type = 1
  255. <if test="hospitalCode != null and hospitalCode != ''">
  256. AND hospital_code = #{hospitalCode}
  257. </if>
  258. <if test="startDate!=null">
  259. AND gmt_create &gt;= #{startDate}
  260. </if>
  261. <if test="endDate!=null">
  262. AND gmt_create &lt;= #{endDate}
  263. </if>
  264. -- AND hospital_code !='朗通通用'
  265. ) t
  266. GROUP BY
  267. hospitalCode
  268. ORDER BY
  269. uvSum desc;
  270. </select>
  271. <select id="getZZHosp" parameterType="com.diagbot.vo.OptVO" resultType="com.diagbot.dto.ZZHospDTO">
  272. SELECT
  273. t.hospitalCode AS hospitalCode,
  274. t.days AS days,
  275. count(ip) AS zzCnt
  276. FROM
  277. (
  278. SELECT DISTINCT
  279. hospital_code AS hospitalCode,
  280. DATE_FORMAT(gmt_create, '%Y-%m-%d') AS days,
  281. ip
  282. FROM
  283. zzcx_opt_info
  284. WHERE
  285. opt_type = 2
  286. <if test="hospitalCode != null and hospitalCode != ''">
  287. AND hospital_code = #{hospitalCode}
  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. days
  300. ORDER BY
  301. hospitalCode,
  302. days;
  303. </select>
  304. <select id="getZZSumHosp" parameterType="com.diagbot.vo.OptVO" resultType="com.diagbot.dto.ZZHospSumDTO">
  305. SELECT
  306. t.hospitalCode AS hospitalCode,
  307. count(ip) AS zzSum
  308. FROM
  309. (
  310. SELECT DISTINCT
  311. hospital_code AS hospitalCode,
  312. DATE_FORMAT(gmt_create, '%Y-%m-%d') AS days,
  313. ip
  314. FROM
  315. zzcx_opt_info
  316. WHERE
  317. opt_type = 2
  318. <if test="hospitalCode != null and hospitalCode != ''">
  319. AND hospital_code = #{hospitalCode}
  320. </if>
  321. <if test="startDate!=null">
  322. AND gmt_create &gt;= #{startDate}
  323. </if>
  324. <if test="endDate!=null">
  325. AND gmt_create &lt;= #{endDate}
  326. </if>
  327. -- AND hospital_code !='朗通通用'
  328. ) t
  329. GROUP BY
  330. hospitalCode
  331. ORDER BY
  332. zzSum desc;
  333. </select>
  334. <select id="getAllHospital" resultType="java.lang.String">
  335. SELECT DISTINCT(hospital_code) AS hospitalCode FROM `zzcx_opt_info`;
  336. </select>
  337. </mapper>