StatisticsCQuery.xml 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  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.hz.employmentsite.mapper.cquery.StatisticsCQuery">
  4. <select id="findSystemDataCount" resultType="com.hz.employmentsite.vo.statistics.SystemDataCount">
  5. SELECT
  6. site.SiteID,
  7. site.RegionCode,
  8. site.SiteName,
  9. area.`name` AS regionName,
  10. -- 驿站人员数量
  11. (
  12. SELECT
  13. COUNT( 1 )
  14. FROM
  15. pc_site_user site_user
  16. LEFT JOIN sys_user sys_user ON site_user.UserID = sys_user.UserID
  17. WHERE
  18. site_user.SiteID = site.SiteID
  19. AND sys_user.RecordStatus = 1
  20. ) AS siteUserCount,
  21. -- 指定时间段的登记企业数量
  22. (
  23. SELECT
  24. COUNT( 1 )
  25. FROM
  26. pc_company
  27. WHERE
  28. SiteID = site.SiteID
  29. <if test="startDate != null">
  30. and DATE(CreateTime) <![CDATA[ >= ]]> DATE(#{startDate})
  31. </if>
  32. <if test="endDate != null ">
  33. and DATE(CreateTime) <![CDATA[ <= ]]> DATE(#{endDate})
  34. </if>
  35. ) AS companyCount,
  36. -- 指定时间段的登记岗位数量
  37. (
  38. SELECT
  39. COUNT( 1 )
  40. FROM
  41. pc_post post
  42. WHERE
  43. CompanyID IN ( SELECT company.CompanyID FROM pc_company company WHERE company.SiteID = site.SiteID )
  44. <if test="startDate != null">
  45. and DATE(CreateTime) <![CDATA[ >= ]]> DATE(#{startDate})
  46. </if>
  47. <if test="endDate != null ">
  48. and DATE(CreateTime) <![CDATA[ <= ]]> DATE(#{endDate})
  49. </if>
  50. ) AS postCount,
  51. -- 指定时间段的登记求职人员数量
  52. (
  53. SELECT
  54. COUNT( 1 )
  55. FROM
  56. pc_jobuser
  57. WHERE
  58. SiteID = site.SiteID
  59. <if test="startDate != null">
  60. and DATE(CreateTime) <![CDATA[ >= ]]> DATE(#{startDate})
  61. </if>
  62. <if test="endDate != null ">
  63. and DATE(CreateTime) <![CDATA[ <= ]]> DATE(#{endDate})
  64. </if>
  65. ) AS jobUserCount
  66. FROM
  67. pc_site site
  68. LEFT JOIN area_code area ON site.RegionCode = area.`code`
  69. ORDER BY site.RegionCode
  70. </select>
  71. <select id="findWeekSystemDataCount" resultType="com.hz.employmentsite.vo.statistics.RegionSystemDataCount">
  72. SELECT
  73. subquery.RegionCode,
  74. subquery.RegionName,
  75. SUM(subquery.companyCount) AS companyCount,
  76. SUM(subquery.postCount) AS postCount,
  77. SUM(subquery.jobUserCount) AS jobUserCount
  78. FROM
  79. (
  80. SELECT
  81. site.SiteID,
  82. site.RegionCode,
  83. area.`Name` AS RegionName,
  84. -- 指定时间段的登记企业数量
  85. (
  86. SELECT COUNT(1)
  87. FROM pc_company
  88. WHERE
  89. SiteID = site.SiteID
  90. <if test="startDate != null">
  91. and DATE(CreateTime) <![CDATA[ >= ]]> DATE(#{startDate})
  92. </if>
  93. <if test="endDate != null ">
  94. and DATE(CreateTime) <![CDATA[ <= ]]> DATE(#{endDate})
  95. </if>
  96. ) AS companyCount,
  97. -- 指定时间段的登记岗位数量
  98. (
  99. SELECT COUNT(1)
  100. FROM pc_post post
  101. WHERE
  102. CompanyID IN (SELECT company.CompanyID FROM pc_company company WHERE company.SiteID = site.SiteID)
  103. <if test="startDate != null">
  104. and DATE(CreateTime) <![CDATA[ >= ]]> DATE(#{startDate})
  105. </if>
  106. <if test="endDate != null ">
  107. and DATE(CreateTime) <![CDATA[ <= ]]> DATE(#{endDate})
  108. </if>
  109. ) AS postCount,
  110. -- 指定时间段的登记求职人员数量
  111. (
  112. SELECT COUNT(1)
  113. FROM pc_jobuser
  114. WHERE
  115. SiteID = site.SiteID
  116. <if test="startDate != null">
  117. and DATE(CreateTime) <![CDATA[ >= ]]> DATE(#{startDate})
  118. </if>
  119. <if test="endDate != null ">
  120. and DATE(CreateTime) <![CDATA[ <= ]]> DATE(#{endDate})
  121. </if>
  122. ) AS jobUserCount
  123. FROM
  124. pc_site site
  125. LEFT JOIN area_code area ON site.RegionCode = area.`code`
  126. LEFT JOIN pc_site_institution siteInst ON site.SiteID = siteInst.SiteID
  127. WHERE
  128. 1=1
  129. <if test="siteID!='' and siteID!=null">
  130. and site.siteID = #{siteID}
  131. </if>
  132. <if test="institutionID!='' and institutionID!=null">
  133. and siteInst.institutionID = #{institutionID}
  134. </if>
  135. <if test="regionCode!='' and regionCode!=null">
  136. and area.`code` = #{regionCode}
  137. </if>
  138. ) AS subquery
  139. GROUP BY
  140. subquery.RegionCode,
  141. subquery.RegionName
  142. ORDER BY
  143. subquery.RegionCode;
  144. </select>
  145. <select id="findRegionSiteUserCount" resultType="com.hz.employmentsite.vo.statistics.RegionSystemDataCount">
  146. SELECT
  147. area.`code` AS regionCode,
  148. area.`name` AS regionName,
  149. COUNT( sysUser.UserID ) AS siteUserCount
  150. FROM
  151. area_code area
  152. LEFT JOIN pc_site site ON site.RegionCode = area.`code`
  153. LEFT JOIN pc_site_user siteUser ON site.SiteID = siteUser.SiteID
  154. LEFT JOIN sys_user sysUser ON siteUser.UserID = sysUser.UserID AND sysUser.RecordStatus = 1
  155. LEFT JOIN pc_site_institution siteInst ON site.SiteID = siteInst.SiteID
  156. WHERE
  157. area.lv = 3
  158. <if test="siteID!='' and siteID!=null">
  159. and site.siteID = #{siteID}
  160. </if>
  161. <if test="institutionID!='' and institutionID!=null">
  162. and siteInst.institutionID = #{institutionID}
  163. </if>
  164. <if test="regionCode!='' and regionCode!=null">
  165. and area.`code` = #{regionCode}
  166. </if>
  167. GROUP BY
  168. area.`code`,
  169. area.`name`
  170. ORDER BY
  171. area.`code`
  172. </select>
  173. <select id="findJobUserCountByAgeRange" resultType="com.hz.employmentsite.vo.statistics.jobUser.AgeRangeJobUserCount">
  174. SELECT
  175. CASE
  176. WHEN TIMESTAMPDIFF(YEAR, BirthDay, CURDATE()) BETWEEN 16 AND 25 THEN '16-25岁'
  177. WHEN TIMESTAMPDIFF(YEAR, BirthDay, CURDATE()) BETWEEN 26 AND 35 THEN '26-35岁'
  178. WHEN TIMESTAMPDIFF(YEAR, BirthDay, CURDATE()) BETWEEN 36 AND 45 THEN '36-45岁'
  179. WHEN TIMESTAMPDIFF(YEAR, BirthDay, CURDATE()) BETWEEN 46 AND 55 THEN '46-55岁'
  180. ELSE '55岁以上'
  181. END AS AgeRange,
  182. Sex,
  183. COUNT(1) AS jobUserCount
  184. FROM
  185. pc_jobuser
  186. WHERE
  187. 1=1
  188. <if test="year!='' and year!=null">
  189. and YEAR(CreateTime) = #{year}
  190. </if>
  191. <if test="month!='' and month!=null">
  192. and MONTH(CreateTime) = #{month}
  193. </if>
  194. GROUP BY
  195. AgeRange,
  196. Sex
  197. ORDER BY
  198. AgeRange,
  199. Sex;
  200. </select>
  201. <select id="findJobUserCountByPersonType" resultType="com.hz.employmentsite.vo.statistics.jobUser.PersonTypeJobUserCount">
  202. SELECT
  203. jobuser.KeyPersonTypeID,
  204. keytype.`Name` AS KeyTypeName,
  205. jobuser.CultureRank,
  206. culture.`Name` AS CultureName,
  207. COUNT( 1 ) AS jobUserCount
  208. FROM
  209. `pc_jobuser` jobuser
  210. LEFT JOIN sys_dictionary_item keytype ON jobuser.KeyPersonTypeID = keytype.`Value`
  211. AND keytype.DictionaryCode = 'KeyPersonType'
  212. LEFT JOIN sys_dictionary_item culture ON jobuser.CultureRank = culture.`Value`
  213. AND culture.DictionaryCode = 'HighestDegree'
  214. WHERE
  215. CultureRank IS NOT NULL
  216. <if test="year!='' and year!=null">
  217. and YEAR(jobuser.CreateTime) = #{year}
  218. </if>
  219. <if test="month!='' and month!=null">
  220. and MONTH(jobuser.CreateTime) = #{month}
  221. </if>
  222. GROUP BY
  223. jobuser.KeyPersonTypeID,
  224. KeyTypeName,
  225. jobuser.CultureRank
  226. ORDER BY
  227. jobuser.KeyPersonTypeID,
  228. jobuser.CultureRank DESC
  229. </select>
  230. <select id="findJobUserByRegionAndStatus" resultType="com.hz.employmentsite.vo.statistics.jobUser.RegionJobUserCount">
  231. SELECT
  232. area.`code` AS regionCode,
  233. area.`name` AS regionName,
  234. COUNT( jobUser.JobuserID ) AS jobUserCount
  235. FROM
  236. area_code area
  237. LEFT JOIN pc_site site ON area.`code` = site.RegionCode
  238. LEFT JOIN pc_jobuser jobUser ON site.SiteID = jobUser.SiteID
  239. WHERE
  240. area.lv = 3
  241. <if test="year!='' and year!=null">
  242. and YEAR(jobUser.CreateTime) = #{year}
  243. </if>
  244. <if test="month!='' and month!=null">
  245. and MONTH(jobUser.CreateTime) = #{month}
  246. </if>
  247. GROUP BY
  248. site.RegionCode,
  249. RegionName
  250. ORDER BY
  251. site.RegionCode
  252. </select>
  253. <select id="findJobUserByRegionAndPersonType" resultType="com.hz.employmentsite.vo.statistics.jobUser.RegionJobUserCount">
  254. SELECT
  255. area.`code` AS regionCode,
  256. area.`name` AS regionName,
  257. COUNT( jobUser.JobuserID ) AS jobUserCount
  258. FROM
  259. area_code area
  260. LEFT JOIN pc_site site ON area.`code` = site.RegionCode
  261. LEFT JOIN pc_jobuser jobUser ON site.SiteID = jobUser.SiteID
  262. WHERE
  263. area.lv = 3
  264. AND jobUser.KeyPersonTypeID IN (13,14,15,16,17,18,19,20,21,22,23,24)
  265. <if test="year!='' and year!=null">
  266. and YEAR(jobUser.CreateTime) = #{year}
  267. </if>
  268. <if test="month!='' and month!=null">
  269. and MONTH(jobUser.CreateTime) = #{month}
  270. </if>
  271. GROUP BY
  272. site.RegionCode,
  273. RegionName
  274. ORDER BY
  275. site.RegionCode
  276. </select>
  277. <select id="findYearCompanyCount" resultType="com.hz.employmentsite.vo.statistics.RegionSystemDataCount">
  278. SELECT
  279. area.`code` AS RegionCode,
  280. area.`name` AS RegionName,
  281. DATE_FORMAT( company.CreateTime, '%m' ) AS `Month`,
  282. COUNT( 1 ) AS CompanyCount
  283. FROM
  284. pc_company company
  285. LEFT JOIN pc_site site ON company.SiteID = site.SiteID
  286. LEFT JOIN pc_site_institution siteInst ON site.SiteID = siteInst.SiteID
  287. LEFT JOIN area_code area ON area.`code` = site.RegionCode
  288. WHERE
  289. 1=1
  290. <if test="year!='' and year!=null">
  291. and YEAR(company.CreateTime) = #{year}
  292. </if>
  293. <if test="startDate != null">
  294. and DATE(company.CreateTime) <![CDATA[ >= ]]> DATE(#{startDate})
  295. </if>
  296. <if test="endDate != null ">
  297. and DATE(company.CreateTime) <![CDATA[ <= ]]> DATE(#{endDate})
  298. </if>
  299. <if test="siteID!='' and siteID!=null">
  300. and site.siteID = #{siteID}
  301. </if>
  302. <if test="institutionID!='' and institutionID!=null">
  303. and siteInst.institutionID = #{institutionID}
  304. </if>
  305. <if test="regionCode!='' and regionCode!=null">
  306. and area.`code` = #{regionCode}
  307. </if>
  308. GROUP BY
  309. area.`code`,
  310. area.`name`,
  311. `Month`
  312. ORDER BY
  313. area.`code`,
  314. `Month` ASC
  315. </select>
  316. <select id="findYearPostCount" resultType="com.hz.employmentsite.vo.statistics.RegionSystemDataCount">
  317. SELECT
  318. area.`code` AS RegionCode,
  319. area.`name` AS RegionName,
  320. DATE_FORMAT( post.CreateTime, '%m' ) AS `Month`,
  321. COUNT( 1 ) AS PostCount
  322. FROM
  323. pc_post post
  324. LEFT JOIN pc_company company ON post.CompanyID = company.CompanyID
  325. LEFT JOIN pc_site site ON company.SiteID = site.SiteID
  326. LEFT JOIN pc_site_institution siteInst ON site.SiteID = siteInst.SiteID
  327. LEFT JOIN area_code area ON area.`code` = site.RegionCode
  328. WHERE
  329. 1=1
  330. <if test="year!='' and year!=null">
  331. and YEAR(post.CreateTime) = #{year}
  332. </if>
  333. <if test="startDate != null">
  334. and DATE(post.CreateTime) <![CDATA[ >= ]]> DATE(#{startDate})
  335. </if>
  336. <if test="endDate != null ">
  337. and DATE(post.CreateTime) <![CDATA[ <= ]]> DATE(#{endDate})
  338. </if>
  339. <if test="siteID!='' and siteID!=null">
  340. and site.siteID = #{siteID}
  341. </if>
  342. <if test="institutionID!='' and institutionID!=null">
  343. and siteInst.institutionID = #{institutionID}
  344. </if>
  345. <if test="regionCode!='' and regionCode!=null">
  346. and area.`code` = #{regionCode}
  347. </if>
  348. GROUP BY
  349. area.`code`,
  350. area.`name`,
  351. `Month`
  352. ORDER BY
  353. area.`code`,
  354. `Month` ASC
  355. </select>
  356. <select id="findYearJobUserCount" resultType="com.hz.employmentsite.vo.statistics.RegionSystemDataCount">
  357. SELECT
  358. area.`code` AS RegionCode,
  359. area.`name` AS RegionName,
  360. DATE_FORMAT( jobUser.CreateTime, '%m' ) AS `Month`,
  361. COUNT( 1 ) AS JobUserCount
  362. FROM
  363. pc_jobuser jobUser
  364. LEFT JOIN pc_site site ON jobUser.SiteID = site.SiteID
  365. LEFT JOIN pc_site_institution siteInst ON site.SiteID = siteInst.SiteID
  366. LEFT JOIN area_code area ON area.`code` = site.RegionCode
  367. WHERE
  368. 1=1
  369. <if test="year!='' and year!=null">
  370. and YEAR(jobUser.CreateTime) = #{year}
  371. </if>
  372. <if test="startDate != null">
  373. and DATE(jobUser.CreateTime) <![CDATA[ >= ]]> DATE(#{startDate})
  374. </if>
  375. <if test="endDate != null ">
  376. and DATE(jobUser.CreateTime) <![CDATA[ <= ]]> DATE(#{endDate})
  377. </if>
  378. <if test="siteID!='' and siteID!=null">
  379. and site.siteID = #{siteID}
  380. </if>
  381. <if test="institutionID!='' and institutionID!=null">
  382. and siteInst.institutionID = #{institutionID}
  383. </if>
  384. <if test="regionCode!='' and regionCode!=null">
  385. and area.`code` = #{regionCode}
  386. </if>
  387. GROUP BY
  388. area.`code`,
  389. area.`name`,
  390. `Month`
  391. ORDER BY
  392. area.`code`,
  393. `Month` ASC
  394. </select>
  395. <select id="findMonthCompanyCount" resultType="com.hz.employmentsite.vo.statistics.RegionSystemDataCount">
  396. SELECT
  397. area.`code` AS RegionCode,
  398. area.`name` AS RegionName,
  399. WEEK ( company.CreateTime, 5 ) AS `Week`,
  400. COUNT( 1 ) AS CompanyCount
  401. FROM
  402. pc_company company
  403. LEFT JOIN pc_site site ON company.SiteID = site.SiteID
  404. LEFT JOIN pc_site_institution siteInst ON site.SiteID = siteInst.SiteID
  405. LEFT JOIN area_code area ON area.`code` = site.RegionCode
  406. WHERE
  407. YEAR ( company.CreateTime ) = #{year}
  408. AND MONTH ( company.CreateTime ) = #{month}
  409. <if test="siteID!='' and siteID!=null">
  410. and site.siteID = #{siteID}
  411. </if>
  412. <if test="institutionID!='' and institutionID!=null">
  413. and siteInst.institutionID = #{institutionID}
  414. </if>
  415. <if test="regionCode!='' and regionCode!=null">
  416. and area.`code` = #{regionCode}
  417. </if>
  418. GROUP BY
  419. area.`code`,
  420. area.`name`,
  421. `Week`
  422. ORDER BY
  423. area.`code`,
  424. `Week` ASC
  425. </select>
  426. <select id="findMonthPostCount" resultType="com.hz.employmentsite.vo.statistics.RegionSystemDataCount">
  427. SELECT
  428. area.`code` AS RegionCode,
  429. area.`name` AS RegionName,
  430. WEEK( post.CreateTime, 5 ) AS `Week`,
  431. COUNT( 1 ) AS PostCount
  432. FROM
  433. pc_post post
  434. LEFT JOIN pc_company company ON post.CompanyID = company.CompanyID
  435. LEFT JOIN pc_site site ON company.SiteID = site.SiteID
  436. LEFT JOIN pc_site_institution siteInst ON site.SiteID = siteInst.SiteID
  437. LEFT JOIN area_code area ON area.`code` = site.RegionCode
  438. WHERE
  439. YEAR ( post.CreateTime ) = #{year}
  440. AND MONTH ( post.CreateTime ) = #{month}
  441. <if test="siteID!='' and siteID!=null">
  442. and site.siteID = #{siteID}
  443. </if>
  444. <if test="institutionID!='' and institutionID!=null">
  445. and siteInst.institutionID = #{institutionID}
  446. </if>
  447. <if test="regionCode!='' and regionCode!=null">
  448. and area.`code` = #{regionCode}
  449. </if>
  450. GROUP BY
  451. area.`code`,
  452. area.`name`,
  453. `Week`
  454. ORDER BY
  455. area.`code`,
  456. `Week` ASC
  457. </select>
  458. <select id="findMonthJobUserCount" resultType="com.hz.employmentsite.vo.statistics.RegionSystemDataCount">
  459. SELECT
  460. area.`code` AS RegionCode,
  461. area.`name` AS RegionName,
  462. WEEK( jobUser.CreateTime, 5 ) AS `Week`,
  463. COUNT( 1 ) AS JobUserCount
  464. FROM
  465. pc_jobuser jobUser
  466. LEFT JOIN pc_site site ON jobUser.SiteID = site.SiteID
  467. LEFT JOIN pc_site_institution siteInst ON site.SiteID = siteInst.SiteID
  468. LEFT JOIN area_code area ON area.`code` = site.RegionCode
  469. WHERE
  470. YEAR ( jobUser.CreateTime ) = #{year}
  471. AND MONTH ( jobUser.CreateTime ) = #{month}
  472. <if test="siteID!='' and siteID!=null">
  473. and site.siteID = #{siteID}
  474. </if>
  475. <if test="institutionID!='' and institutionID!=null">
  476. and siteInst.institutionID = #{institutionID}
  477. </if>
  478. <if test="regionCode!='' and regionCode!=null">
  479. and area.`code` = #{regionCode}
  480. </if>
  481. GROUP BY
  482. area.`code`,
  483. area.`name`,
  484. `Week`
  485. ORDER BY
  486. area.`code`,
  487. `Week` ASC
  488. </select>
  489. <select id="findEmployedJobUserCount" resultType="com.hz.employmentsite.vo.statistics.jobUser.RegionJobUserCount">
  490. SELECT
  491. area.`code` AS regionCode,
  492. area.`name` AS regionName,
  493. COUNT( jobUser.JobuserID ) AS jobUserCount
  494. FROM
  495. area_code area
  496. LEFT JOIN pc_site site ON area.`code` = site.RegionCode
  497. LEFT JOIN pc_jobuser jobUser ON site.SiteID = jobUser.SiteID
  498. WHERE
  499. area.lv = 3
  500. AND jobUser.JobStatusID = 1
  501. GROUP BY
  502. area.`code`,
  503. area.`name`
  504. ORDER BY
  505. area.`code`
  506. </select>
  507. </mapper>