InspectionTaskServiceDaoImplMapper.xml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="inspectionTaskServiceDaoImpl">
  6. <!-- 保存活动信息 add by wuxw 2018-07-03 -->
  7. <insert id="saveBusinessInspectionTaskInfo" parameterType="Map">
  8. insert into business_inspection_task(
  9. plan_user_id,act_ins_time,plan_ins_time,plan_end_time,act_user_name,operate,sign_type,inspection_plan_id,plan_user_name,community_id,b_id,act_user_id,task_id,state,original_plan_user_id,original_plan_user_name,transfer_desc,task_type
  10. ) values (
  11. #{planUserId},#{actInsTime},#{planInsTime},#{planEndTime},#{actUserName},#{operate},#{signType},#{inspectionPlanId},#{planUserName},#{communityId},#{bId},#{actUserId},#{taskId},#{state},#{originalPlanUserId},#{originalPlanUserName},#{transferDesc},#{taskType}
  12. )
  13. </insert>
  14. <!-- 查询活动信息(Business) add by wuxw 2018-07-03 -->
  15. <select id="getBusinessInspectionTaskInfo" parameterType="Map" resultType="Map">
  16. select t.plan_user_id,t.plan_user_id planUserId,t.act_ins_time,t.act_ins_time
  17. actInsTime,t.plan_ins_time,t.plan_ins_time planInsTime,t.plan_end_time,t.plan_end_time planEndTime,
  18. t.act_user_name,t.act_user_name actUserName,t.operate,t.sign_type,t.sign_type signType,
  19. t.inspection_plan_id,t.inspection_plan_id inspectionPlanId,t.plan_user_name,t.plan_user_name planUserName,
  20. t.community_id,t.community_id communityId,t.b_id,t.b_id bId,t.act_user_id,t.act_user_id actUserId,t.task_id,
  21. t.task_id taskId,t.state,t.original_plan_user_id,t.original_plan_user_id
  22. originalPlanUserId,t.original_plan_user_name,t.original_plan_user_name originalPlanUserName,
  23. t.transfer_desc,t.transfer_desc transferDesc,t.task_type,t.task_type taskType from business_inspection_task t
  24. where 1 =1
  25. <if test="planUserId !=null and planUserId != ''">
  26. and t.plan_user_id= #{planUserId}
  27. </if>
  28. <if test="actInsTime !=null ">
  29. and t.act_ins_time= #{actInsTime}
  30. </if>
  31. <if test="planInsTime !=null ">
  32. and t.plan_ins_time= #{planInsTime}
  33. </if>
  34. <if test="planEndTime !=null ">
  35. and t.plan_end_time= #{planEndTime}
  36. </if>
  37. <if test="actUserName !=null and actUserName != ''">
  38. and t.act_user_name= #{actUserName}
  39. </if>
  40. <if test="operate !=null and operate != ''">
  41. and t.operate= #{operate}
  42. </if>
  43. <if test="signType !=null and signType != ''">
  44. and t.sign_type= #{signType}
  45. </if>
  46. <if test="inspectionPlanId !=null and inspectionPlanId != ''">
  47. and t.inspection_plan_id= #{inspectionPlanId}
  48. </if>
  49. <if test="planUserName !=null and planUserName != ''">
  50. and t.plan_user_name= #{planUserName}
  51. </if>
  52. <if test="communityId !=null and communityId != ''">
  53. and t.community_id= #{communityId}
  54. </if>
  55. <if test="bId !=null and bId != ''">
  56. and t.b_id= #{bId}
  57. </if>
  58. <if test="actUserId !=null and actUserId != ''">
  59. and t.act_user_id= #{actUserId}
  60. </if>
  61. <if test="taskId !=null and taskId != ''">
  62. and t.task_id= #{taskId}
  63. </if>
  64. <if test="state !=null and state != ''">
  65. and t.state= #{state}
  66. </if>
  67. </select>
  68. <!-- 保存活动信息至 instance表中 add by wuxw 2018-07-03 -->
  69. <insert id="saveInspectionTaskInfoInstance" parameterType="Map">
  70. insert into inspection_task(
  71. plan_user_id,act_ins_time,plan_ins_time,plan_end_time,status_cd,act_user_name,sign_type,inspection_plan_id,plan_user_name,community_id,b_id,act_user_id,task_id,state,original_plan_user_id,original_plan_user_name,transfer_desc,task_type
  72. ) select
  73. t.plan_user_id,t.act_ins_time,t.plan_ins_time,t.plan_end_time,'0',t.act_user_name,t.sign_type,t.inspection_plan_id,t.plan_user_name,t.community_id,t.b_id,t.act_user_id,t.task_id,t.state,t.original_plan_user_id,t.original_plan_user_name,t.transfer_desc,t.task_type
  74. from business_inspection_task t where 1=1
  75. <if test="planUserId !=null and planUserId != ''">
  76. and t.plan_user_id= #{planUserId}
  77. </if>
  78. <if test="actInsTime !=null">
  79. and t.act_ins_time= #{actInsTime}
  80. </if>
  81. <if test="planInsTime !=null ">
  82. and t.plan_ins_time= #{planInsTime}
  83. </if>
  84. <if test="planEndTime !=null ">
  85. and t.plan_end_time= #{planEndTime}
  86. </if>
  87. <if test="actUserName !=null and actUserName != ''">
  88. and t.act_user_name= #{actUserName}
  89. </if>
  90. and t.operate= 'ADD'
  91. <if test="signType !=null and signType != ''">
  92. and t.sign_type= #{signType}
  93. </if>
  94. <if test="inspectionPlanId !=null and inspectionPlanId != ''">
  95. and t.inspection_plan_id= #{inspectionPlanId}
  96. </if>
  97. <if test="planUserName !=null and planUserName != ''">
  98. and t.plan_user_name= #{planUserName}
  99. </if>
  100. <if test="communityId !=null and communityId != ''">
  101. and t.community_id= #{communityId}
  102. </if>
  103. <if test="bId !=null and bId != ''">
  104. and t.b_id= #{bId}
  105. </if>
  106. <if test="actUserId !=null and actUserId != ''">
  107. and t.act_user_id= #{actUserId}
  108. </if>
  109. <if test="taskId !=null and taskId != ''">
  110. and t.task_id= #{taskId}
  111. </if>
  112. <if test="state !=null and state != ''">
  113. and t.state= #{state}
  114. </if>
  115. </insert>
  116. <!-- 查询活动信息 add by wuxw 2018-07-03 -->
  117. <select id="getInspectionTaskInfo" parameterType="Map" resultType="Map">
  118. select t.plan_user_id,t.plan_user_id planUserId,t.act_ins_time,t.act_ins_time
  119. actInsTime,t.plan_ins_time,t.plan_ins_time planInsTime,t.plan_end_time,t.plan_end_time planEndTime,
  120. t.status_cd,t.status_cd statusCd,t.act_user_name,t.act_user_name actUserName,t.sign_type,t.sign_type
  121. signType,t.inspection_plan_id,t.inspection_plan_id inspectionPlanId,t.plan_user_name,t.plan_user_name
  122. planUserName,t.community_id,t.community_id communityId,t.b_id,t.b_id bId,t.act_user_id,t.act_user_id
  123. actUserId,t.task_id,t.task_id taskId,t.state,td1.name signTypeName,td2.name stateName,ip.inspection_plan_name
  124. inspectionPlanName,t.original_plan_user_id,t.original_plan_user_id
  125. originalPlanUserId,t.original_plan_user_name,t.original_plan_user_name originalPlanUserName,
  126. t.transfer_desc,t.transfer_desc transferDesc,t.task_type,t.task_type taskType,
  127. ip.inspection_route_id inspectionRouteId
  128. from inspection_task t,inspection_plan ip,t_dict td1,t_dict td2
  129. where 1 =1
  130. and t.sign_type = td1.status_cd
  131. and td1.table_name = 'inspection_task'
  132. and td1.table_columns = 'sign_type'
  133. and t.state = td2.status_cd
  134. and td2.table_name = 'inspection_task'
  135. and td2.table_columns = 'state'
  136. and ip.inspection_plan_id = t.inspection_plan_id
  137. and ip.status_cd = '0'
  138. <if test="planUserId !=null and planUserId != ''">
  139. and t.plan_user_id= #{planUserId}
  140. </if>
  141. <if test="originalPlanUserId !=null and originalPlanUserId != ''">
  142. and t.original_plan_user_id= #{originalPlanUserId}
  143. </if>
  144. <if test="startTime != null and startTime != ''">
  145. and t.act_ins_time &gt;= #{startTime}
  146. </if>
  147. <if test="endTime != null and endTime != ''">
  148. and t.act_ins_time &lt;= #{endTime}
  149. </if>
  150. <if test="planInsTime !=null ">
  151. and DATE_FORMAT(t.plan_ins_time,'%Y-%m-%d')= #{planInsTime}
  152. </if>
  153. <if test="planEndTime !=null ">
  154. and t.plan_end_time= #{planEndTime}
  155. </if>
  156. <if test="dayTask !=null ">
  157. and DateDiff(plan_ins_time,NOW())=0
  158. </if>
  159. <if test="todayPlanInsTime !=null ">
  160. and t.plan_ins_time &gt; #{todayPlanInsTime}
  161. </if>
  162. <if test="statusCd !=null and statusCd != ''">
  163. and t.status_cd= #{statusCd}
  164. </if>
  165. <if test="actUserName !=null and actUserName != ''">
  166. and t.act_user_name= #{actUserName}
  167. </if>
  168. <if test="signType !=null and signType != ''">
  169. and t.sign_type= #{signType}
  170. </if>
  171. <if test="inspectionPlanId !=null and inspectionPlanId != ''">
  172. and t.inspection_plan_id= #{inspectionPlanId}
  173. </if>
  174. <if test="inspectionPlanName != null and inspectionPlanName != ''">
  175. and ip.inspection_plan_name = #{inspectionPlanName}
  176. </if>
  177. <if test="planUserName !=null and planUserName != ''">
  178. and t.plan_user_name like '%${planUserName}%'
  179. </if>
  180. <if test="communityId !=null and communityId != ''">
  181. and t.community_id= #{communityId}
  182. </if>
  183. <if test="bId !=null and bId != ''">
  184. and t.b_id= #{bId}
  185. </if>
  186. <if test="actUserId !=null and actUserId != ''">
  187. and t.act_user_id= #{actUserId}
  188. </if>
  189. <if test="taskId !=null and taskId != ''">
  190. and t.task_id= #{taskId}
  191. </if>
  192. <if test="state !=null and state != ''">
  193. and t.state= #{state}
  194. </if>
  195. <if test="states !=null ">
  196. and t.state in
  197. <foreach collection="states" item="item" open="(" close=")" separator=",">
  198. #{item}
  199. </foreach>
  200. </if>
  201. <if test="scopeTime !=null and scopeTime != ''">
  202. and t.create_time &lt; #{scopeTime}
  203. and t.create_time &gt; #{createTime}
  204. </if>
  205. order by t.plan_ins_time
  206. <if test="orderByDesc != null and orderByDesc != ''">
  207. desc
  208. </if>
  209. <if test="page != -1 and page != null ">
  210. limit #{page}, #{row}
  211. </if>
  212. </select>
  213. <!-- 修改活动信息 add by wuxw 2018-07-03 -->
  214. <update id="updateInspectionTaskInfoInstance" parameterType="Map">
  215. update inspection_task t set t.status_cd = #{statusCd}
  216. <if test="newBId != null and newBId != ''">
  217. ,t.b_id = #{newBId}
  218. </if>
  219. <if test="planUserId !=null and planUserId != ''">
  220. , t.plan_user_id= #{planUserId}
  221. </if>
  222. <if test="state !=null and state != ''">
  223. , t.state= #{state}
  224. </if>
  225. <if test="actInsTime !=null ">
  226. , t.act_ins_time= #{actInsTime}
  227. </if>
  228. <if test="planInsTime !=null ">
  229. , t.plan_ins_time= #{planInsTime}
  230. </if>
  231. <if test="planEndTime !=null ">
  232. , t.plan_end_time= #{planEndTime}
  233. </if>
  234. <if test="actUserName !=null and actUserName != ''">
  235. , t.act_user_name= #{actUserName}
  236. </if>
  237. <if test="signType !=null and signType != ''">
  238. , t.sign_type= #{signType}
  239. </if>
  240. <if test="inspectionPlanId !=null and inspectionPlanId != ''">
  241. , t.inspection_plan_id= #{inspectionPlanId}
  242. </if>
  243. <if test="planUserName !=null and planUserName != ''">
  244. , t.plan_user_name= #{planUserName}
  245. </if>
  246. <if test="communityId !=null and communityId != ''">
  247. , t.community_id= #{communityId}
  248. </if>
  249. <if test="actUserId !=null and actUserId != ''">
  250. , t.act_user_id= #{actUserId}
  251. </if>
  252. <if test="originalPlanUserId !=null and originalPlanUserId != ''">
  253. , t.original_plan_user_id= #{originalPlanUserId}
  254. </if>
  255. <if test="originalPlanUserName !=null and originalPlanUserName != ''">
  256. , t.original_plan_user_name= #{original_plan_user_name}
  257. </if>
  258. <if test="transferDesc !=null and transferDesc != ''">
  259. , t.transfer_desc= #{transferDesc}
  260. </if>
  261. <if test="taskType !=null and taskType != ''">
  262. , t.task_type= #{taskType}
  263. </if>
  264. where 1=1
  265. <if test="bId !=null and bId != ''">
  266. and t.b_id= #{bId}
  267. </if>
  268. <if test="taskId !=null and taskId != ''">
  269. and t.task_id= #{taskId}
  270. </if>
  271. </update>
  272. <!-- 查询活动数量 add by wuxw 2018-07-03 -->
  273. <select id="queryInspectionTasksCount" parameterType="Map" resultType="Map">
  274. select count(1) count
  275. from inspection_task t,inspection_plan ip,t_dict td1,t_dict td2
  276. where 1 =1
  277. and t.sign_type = td1.status_cd
  278. and td1.table_name = 'inspection_task'
  279. and td1.table_columns = 'sign_type'
  280. and t.state = td2.status_cd
  281. and td2.table_name = 'inspection_task'
  282. and td2.table_columns = 'state'
  283. and ip.inspection_plan_id = t.inspection_plan_id
  284. and ip.status_cd = '0'
  285. <if test="planUserId !=null and planUserId != ''">
  286. and t.plan_user_id= #{planUserId}
  287. </if>
  288. <if test="originalPlanUserId !=null and originalPlanUserId != ''">
  289. and t.original_plan_user_id= #{originalPlanUserId}
  290. </if>
  291. <if test="startTime != null and startTime != ''">
  292. and t.act_ins_time &gt;= #{startTime}
  293. </if>
  294. <if test="endTime != null and endTime != ''">
  295. and t.act_ins_time &lt;= #{endTime}
  296. </if>
  297. <if test="planInsTime !=null ">
  298. and DATE_FORMAT(t.plan_ins_time,'%Y-%m-%d')= #{planInsTime}
  299. </if>
  300. <if test="planEndTime !=null ">
  301. and t.plan_end_time= #{planEndTime}
  302. </if>
  303. <if test="dayTask !=null ">
  304. and DateDiff(plan_ins_time,NOW())=0
  305. </if>
  306. <if test="statusCd !=null and statusCd != ''">
  307. and t.status_cd= #{statusCd}
  308. </if>
  309. <if test="actUserName !=null and actUserName != ''">
  310. and t.act_user_name= #{actUserName}
  311. </if>
  312. <if test="signType !=null and signType != ''">
  313. and t.sign_type= #{signType}
  314. </if>
  315. <if test="inspectionPlanId !=null and inspectionPlanId != ''">
  316. and t.inspection_plan_id= #{inspectionPlanId}
  317. </if>
  318. <if test="inspectionPlanName != null and inspectionPlanName != ''">
  319. and ip.inspection_plan_name = #{inspectionPlanName}
  320. </if>
  321. <if test="planUserName !=null and planUserName != ''">
  322. and t.plan_user_name like '%${planUserName}%'
  323. </if>
  324. <if test="communityId !=null and communityId != ''">
  325. and t.community_id= #{communityId}
  326. </if>
  327. <if test="bId !=null and bId != ''">
  328. and t.b_id= #{bId}
  329. </if>
  330. <if test="actUserId !=null and actUserId != ''">
  331. and t.act_user_id= #{actUserId}
  332. </if>
  333. <if test="taskId !=null and taskId != ''">
  334. and t.task_id= #{taskId}
  335. </if>
  336. <if test="state !=null and state != ''">
  337. and t.state= #{state}
  338. </if>
  339. <if test="states !=null ">
  340. and t.state in
  341. <foreach collection="states" item="item" open="(" close=")" separator=",">
  342. #{item}
  343. </foreach>
  344. </if>
  345. </select>
  346. <!-- 查询未安排的巡检计划 -->
  347. <select id="queryTodayInspectionPlan" parameterType="Map" resultType="Map">
  348. SELECT
  349. ip.inspection_plan_id inspectionPlanId,
  350. ip.inspection_plan_name inspectionPlanName,
  351. ip.inspection_plan_period inspectionPlanPeriod,
  352. ip.sign_type signType,
  353. ip.community_id communityId,
  354. ip.end_time endTime,
  355. ip.staff_id planUserId,
  356. ip.staff_name planUserName
  357. FROM
  358. inspection_plan ip
  359. inner join
  360. LEFT JOIN inspection_task it ON ip.inspection_plan_id = it.inspection_plan_id
  361. AND ip.staff_id = it.plan_user_id
  362. AND it.status_cd = '0'
  363. AND ip.community_id = it.community_id
  364. <if test="inspectionPlanPeriod !=null and inspectionPlanPeriod == '2020023'">
  365. and it.plan_ins_time &gt; DATE_SUB(curdate(),INTERVAL 7 DAY)
  366. </if>
  367. <if test="inspectionPlanPeriod !=null and inspectionPlanPeriod == '2020024'">
  368. and it.plan_ins_time &gt; DATE_SUB(curdate(),INTERVAL 30 DAY)
  369. </if>
  370. WHERE
  371. ip.status_cd = '0'
  372. and ip.end_time &gt; now()
  373. and ip.start_time &lt; now()
  374. and ip.state = '2020025'
  375. AND it.inspection_plan_id IS NOT NULL
  376. and ip.community_id = #{communityId}
  377. <if test="inspectionPlanPeriod !=null and inspectionPlanPeriod != ''">
  378. and ip.inspection_plan_period= #{inspectionPlanPeriod}
  379. </if>
  380. limit 1000
  381. </select>
  382. <!-- 保存活动信息 add by wuxw 2018-07-03 -->
  383. <insert id="insertInspectionTask" parameterType="Map">
  384. insert into inspection_task(
  385. plan_user_id,plan_ins_time,plan_end_time,sign_type,inspection_plan_id,plan_user_name,community_id,b_id,task_id,state,ip_staff_id,original_plan_user_id,original_plan_user_name,transfer_desc,task_type
  386. ) values
  387. <foreach collection="tasks" item="task" separator=",">
  388. (#{task.planUserId},#{task.planInsTime},#{task.planEndTime},#{task.signType},#{task.inspectionPlanId},#{task.planUserName},#{task.communityId},'-1',#{task.taskId},'20200405',#{task.ipStaffId},#{task.originalPlanUserId},#{task.originalPlanUserName},#{task.transferDesc},#{task.taskType})
  389. </foreach>
  390. </insert>
  391. <!-- 保存活动信息 add by wuxw 2018-07-03 -->
  392. <insert id="insertInspectionTaskDetail" parameterType="Map">
  393. insert into inspection_task_detail(
  394. task_detail_id,b_id,community_id,task_id,inspection_id,inspection_name,state,point_start_time,point_end_time,sort_number
  395. ) values
  396. <foreach collection="tasks" item="task" separator=",">
  397. (#{task.taskDetailId},'-1',#{task.communityId},#{task.taskId},#{task.inspectionId},#{task.inspectionName},'20200405',#{task.pointStartTime},#{task.pointEndTime},#{task.sortNumber})
  398. </foreach>
  399. </insert>
  400. </mapper>