暫無描述

TWoWorkorderbaseMapper.xml 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  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.yt.zhylplat.dao.TWoWorkorderbaseMapper">
  4. <select id="selectWorkOrderPage" resultType="com.yt.zhylplat.vo.TWoWorkOrderBaseVO">
  5. select
  6. wob.F_WorkOrderId as workOrderId,
  7. wob.F_YHDeptName as yhDeptName,
  8. wob.F_WorkOrderType as workOrderType,
  9. '绿化' as workOrderLine,
  10. wob.F_Code as code,
  11. wob.F_CategoryName1 as categoryName1,
  12. wob.F_CategoryName2 as categoryName2,
  13. wob.F_CreateDate as createDate,
  14. wob.pushtime as pushTime,
  15. wob.checktime as checkTime,
  16. wot.F_CreateDate as finishTime,
  17. wob.F_Content as content,
  18. wob.F_Address as address,
  19. wob.checkdept as checkDept,
  20. wob.checkusername as checkUserName,
  21. wob.disposeresultdesc as disposeResultDesc,
  22. pre.file_url as preDisposeUrl,
  23. after.file_url as afterDisposeUrl,
  24. wob.F_State as state,
  25. wob.F_X as longitude,
  26. wob.F_Y as latitude
  27. from
  28. T_WO_WorkOrderBase wob
  29. left join
  30. (
  31. select
  32. F_WorkOrderId,
  33. F_CreateDate
  34. from
  35. T_WO_WorkOrderTask
  36. where
  37. F_StateId = 4
  38. limit 1
  39. ) wot ON wot.F_WorkOrderId = wob.F_WorkOrderId
  40. left join (
  41. select
  42. F_WorkOrderId,
  43. GROUP_CONCAT(F_FileUrl SEPARATOR ',') as file_url
  44. from
  45. T_WO_FileInfo
  46. where
  47. F_StateId = 1
  48. group by
  49. F_WorkOrderId
  50. ) pre on pre.F_WorkOrderId = wob.F_WorkOrderId
  51. left join (
  52. select
  53. F_WorkOrderId,
  54. GROUP_CONCAT(F_FileUrl SEPARATOR ',') as file_url
  55. from
  56. T_WO_FileInfo
  57. where
  58. F_StateId = 4
  59. group by
  60. F_WorkOrderId
  61. ) after on after.F_WorkOrderId = wob.F_WorkOrderId
  62. where
  63. wob.F_DeleteFlag = 0
  64. and
  65. wob.F_StateId = 4
  66. <if test="workOrderBaseVO.yhDeptName != null and workOrderBaseVO.yhDeptName != ''">
  67. and wob.F_YHDeptName like concat('%', #{workOrderBaseVO.yhDeptName}, '%')
  68. </if>
  69. <if test="workOrderBaseVO.code != null and workOrderBaseVO.code != ''">
  70. and wob.F_Code like concat('%', #{workOrderBaseVO.code}, '%')
  71. </if>
  72. order by wob.F_CreateDate desc
  73. </select>
  74. <select id="getWorkOrderBaseComplaintCount"
  75. resultType="com.yt.zhylplat.moduleLhgy.dto.LhzxWorkOrderBaseDto">
  76. select
  77. count(1) as complaintCount
  78. from
  79. T_WO_WorkOrderBase
  80. where
  81. F_YHDeptId = #{yhCompanyId}
  82. and
  83. section_id = #{sectionId}
  84. and
  85. DATE_FORMAT(F_CreateDate, '%Y-%m-%d') <![CDATA[ >= ]]> DATE_FORMAT(#{lastMonthStartDate}, '%Y-%m-%d')
  86. and
  87. DATE_FORMAT(F_CreateDate, '%Y-%m-%d') <![CDATA[ <= ]]> DATE_FORMAT(#{lastMonthEndDate}, '%Y-%m-%d')
  88. and
  89. F_WorkOrderTypeId = 5
  90. and
  91. F_DeleteFlag = 0
  92. </select>
  93. <select id="getWorkOrderBaseMaintenanceCount"
  94. resultType="com.yt.zhylplat.moduleLhgy.dto.LhzxWorkOrderBaseDto">
  95. select
  96. count(1) as dailyMaintenanceCount,
  97. sum(IF(wob.patrol_type = 1, 1, 0)) as streetTreeCount,
  98. sum(IF(wob.patrol_type = 2, 1, 0)) as greenSpaceCount,
  99. sum(IF(wob.patrol_type = 3, 1, 0)) as flowersCount,
  100. sum(IF(wob.patrol_type = 4, 1, 0)) as pestCount,
  101. sum(IF(wob.patrol_type is null, 1, 0)) as otherCount
  102. from
  103. T_WO_WorkOrderBase wob
  104. left join
  105. (
  106. select
  107. id,
  108. object_id
  109. from
  110. T_Lhgy_Patrol_Track
  111. where
  112. delete_flag = 0
  113. ) pt on wob.patrol_id = pt.id
  114. where
  115. wob.F_YHDeptId = #{yhCompanyId}
  116. and
  117. pt.object_id = #{sectionId}
  118. and
  119. DATE_FORMAT(wob.F_CreateDate, '%Y-%m-%d') <![CDATA[ >= ]]> DATE_FORMAT(#{currentMonthStartDate}, '%Y-%m-%d')
  120. and
  121. DATE_FORMAT(wob.F_CreateDate, '%Y-%m-%d') <![CDATA[ <= ]]> DATE_FORMAT(#{currentMonthEndDate}, '%Y-%m-%d')
  122. and
  123. wob.F_WorkOrderTypeId = 3
  124. and
  125. wob.F_DeleteFlag = 0
  126. </select>
  127. <select id="selectWorkOrderBasePageBySection"
  128. resultType="com.yt.zhylplat.moduleLhgy.vo.LhzxWorkOrderBaseVO">
  129. SELECT
  130. temp.*
  131. FROM
  132. (<include refid="WorkOrderBasePageBySectionSql"/>) temp
  133. </select>
  134. <select id="getWorkOrderBaseCountBySection" resultType="com.yt.zhylplat.moduleLhgy.vo.LhzxWorkOrderBaseVO">
  135. SELECT
  136. sum(if(temp.dailyMaintenanceCount is null, 0, temp.dailyMaintenanceCount)) as dailyMaintenanceCount,
  137. sum(if(temp.streetTreeCount is null, 0, temp.streetTreeCount)) as streetTreeCount,
  138. sum(if(temp.greenSpaceCount is null, 0, temp.greenSpaceCount)) as greenSpaceCount,
  139. sum(if(temp.flowersCount is null, 0, temp.flowersCount)) as flowersCount,
  140. sum(if(temp.pestCount is null, 0, temp.pestCount)) as pestCount,
  141. sum(if(temp.otherCount is null, 0, temp.otherCount)) as otherCount,
  142. sum(if(temp.complaintCount is null, 0, temp.complaintCount)) as complaintCount
  143. FROM
  144. (<include refid="WorkOrderBasePageBySectionSql"/>) temp
  145. </select>
  146. <select id="selectWorkOrderBaseListBySection"
  147. resultType="com.yt.zhylplat.moduleLhgy.vo.LhzxWorkOrderBaseVO">
  148. select
  149. temp.*
  150. from
  151. (<include refid="workOrderBaseListSql"/>) temp
  152. </select>
  153. <select id="getWorkOrderBaseSumCount" resultType="com.yt.zhylplat.moduleLhgy.vo.LhzxWorkOrderBaseVO">
  154. select
  155. sum(if(temp.workOrderCount is null, 0, temp.workOrderCount)) as workOrderCount,
  156. sum(if(temp.untreatedCount is null, 0, temp.untreatedCount)) as untreatedCount,
  157. sum(if(temp.untreatedCount is null, 0, temp.untreatedCount)) as untreatedCount,
  158. sum(if(temp.processingCount is null, 0, temp.processingCount)) as processingCount,
  159. sum(if(temp.withdrawnCount is null, 0, temp.withdrawnCount)) as withdrawnCount
  160. from
  161. (<include refid="workOrderBaseListSql"/>) temp
  162. </select>
  163. <sql id="WorkOrderBasePageBySectionSql">
  164. SELECT
  165. rsmc.maintenance_company_id,
  166. mc.old_maintenance_company_id,
  167. mc.maintenance_company_name,
  168. rsmc.section_id,
  169. s.old_section_id,
  170. s.section_name,
  171. IF(wo.dailyMaintenanceCount is null, 0, wo.dailyMaintenanceCount) as dailyMaintenanceCount,
  172. IF(wo.streetTreeCount is null, 0, wo.streetTreeCount) as streetTreeCount,
  173. IF(wo.greenSpaceCount is null, 0, wo.greenSpaceCount) as greenSpaceCount,
  174. IF(wo.flowersCount is null, 0, wo.flowersCount) as flowersCount,
  175. IF(wo.pestCount is null, 0, wo.pestCount) as pestCount,
  176. IF(wo.otherCount is null, 0, wo.otherCount) as otherCount,
  177. IF(com.complaintCount is null, 0, com.complaintCount) as complaintCount
  178. /*15 as complaintCount*/
  179. FROM
  180. (
  181. select DISTINCT
  182. maintenance_company_id,
  183. section_id,
  184. del_flg
  185. from
  186. T_Lhzx_Road_Section_Maintenance_Company
  187. WHERE
  188. del_flg = 0
  189. ) rsmc
  190. LEFT JOIN
  191. T_Lhzx_Maintenance_Company mc on mc.id = rsmc.maintenance_company_id
  192. LEFT JOIN
  193. T_Lhzx_Section s on s.id = rsmc.section_id
  194. LEFT JOIN
  195. (
  196. select
  197. wob.F_YHDeptId,
  198. wob.F_SGUserId,
  199. count(1) as dailyMaintenanceCount,
  200. sum(IF(wob.patrol_type = 1, 1, 0)) as streetTreeCount,
  201. sum(IF(wob.patrol_type = 2, 1, 0)) as greenSpaceCount,
  202. sum(IF(wob.patrol_type = 3, 1, 0)) as flowersCount,
  203. sum(IF(wob.patrol_type = 4, 1, 0)) as pestCount,
  204. sum(IF(wob.patrol_type is null, 1, 0)) as otherCount
  205. from
  206. T_WO_WorkOrderBase wob
  207. where
  208. wob.F_WorkOrderTypeId = 3
  209. and
  210. wob.F_DeleteFlag = 0
  211. and
  212. DATE_FORMAT(wob.F_CreateDate, '%Y-%m') = #{workOrderBaseVO.currentMonth}
  213. and
  214. wob.dept_type = 2
  215. GROUP BY
  216. wob.F_YHDeptId,
  217. wob.F_SGUserId
  218. ) wo on wo.F_YHDeptId = mc.old_maintenance_company_id and wo.F_SGUserId = s.old_section_id
  219. LEFT JOIN (
  220. select
  221. F_YHDeptId,
  222. F_SGUserId,
  223. count(1) as complaintCount
  224. from
  225. T_WO_WorkOrderBase
  226. where
  227. F_WorkOrderTypeId = 5
  228. and
  229. F_DeleteFlag = 0
  230. and
  231. DATE_FORMAT(F_CreateDate, '%Y-%m') = #{workOrderBaseVO.lastMonth}
  232. and
  233. dept_type = 2
  234. group by
  235. F_YHDeptId,
  236. F_SGUserId
  237. ) com on com.F_YHDeptId = mc.old_maintenance_company_id and com.F_SGUserId = s.old_section_id
  238. WHERE
  239. rsmc.del_flg = 0
  240. <if test="workOrderBaseVO.sectionId != null">
  241. and rsmc.section_id = #{workOrderBaseVO.sectionId}
  242. </if>
  243. <if test="workOrderBaseVO.maintenanceCompanyId != null">
  244. and rsmc.maintenance_company_id = #{workOrderBaseVO.maintenanceCompanyId}
  245. </if>
  246. ORDER BY
  247. rsmc.section_id, rsmc.maintenance_company_id
  248. </sql>
  249. <sql id="workOrderBaseListSql">
  250. select
  251. rsmc.maintenance_company_id,
  252. mc.old_maintenance_company_id,
  253. mc.maintenance_company_name,
  254. rsmc.section_id,
  255. s.old_section_id,
  256. s.section_name,
  257. wo.workOrderCount,
  258. wo.untreatedCount,
  259. wo.processingCount,
  260. wo.finishedCount,
  261. wo.withdrawnCount
  262. from (
  263. select DISTINCT
  264. maintenance_company_id,
  265. section_id,
  266. del_flg
  267. from
  268. T_Lhzx_Road_Section_Maintenance_Company
  269. WHERE
  270. del_flg = 0
  271. ) rsmc
  272. LEFT JOIN
  273. T_Lhzx_Maintenance_Company mc on mc.id = rsmc.maintenance_company_id
  274. LEFT JOIN
  275. T_Lhzx_Section s on s.id = rsmc.section_id
  276. LEFT JOIN
  277. (
  278. select
  279. wob.F_YHDeptId,
  280. wob.F_SGUserId,
  281. count(1) as workOrderCount,
  282. sum(IF(wob.F_StateId = 2, 1, 0)) as untreatedCount,
  283. sum(IF(wob.F_StateId = 3, 1, 0)) as processingCount,
  284. sum(IF(wob.F_StateId = 4, 1, 0)) as finishedCount,
  285. sum(IF(wob.F_StateId = 5, 1, 0)) as withdrawnCount
  286. from
  287. T_WO_WorkOrderBase wob
  288. where
  289. wob.is_center = 1
  290. and
  291. wob.F_DeleteFlag = 0
  292. and
  293. wob.dept_type = 2
  294. <if test="currentMonth != null and currentMonth != ''">
  295. and DATE_FORMAT(wob.F_CreateDate, '%Y-%m') = #{currentMonth}
  296. </if>
  297. GROUP BY
  298. wob.F_YHDeptId,
  299. wob.F_SGUserId
  300. ) wo on wo.F_YHDeptId = mc.old_maintenance_company_id and wo.F_SGUserId = s.old_section_id
  301. WHERE
  302. rsmc.del_flg = 0
  303. <if test="sectionId != null">
  304. and rsmc.section_id = #{sectionId}
  305. </if>
  306. <if test="maintenanceCompanyId != null">
  307. and rsmc.maintenance_company_id = #{maintenanceCompanyId}
  308. </if>
  309. ORDER BY
  310. rsmc.section_id,
  311. rsmc.maintenance_company_id
  312. </sql>
  313. </mapper>