InspectionTaskServiceDaoImplMapper.xml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  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. from inspection_task t,inspection_plan ip,t_dict td1,t_dict td2
  128. where 1 =1
  129. and t.sign_type = td1.status_cd
  130. and td1.table_name = 'inspection_task'
  131. and td1.table_columns = 'sign_type'
  132. and t.state = td2.status_cd
  133. and td2.table_name = 'inspection_task'
  134. and td2.table_columns = 'state'
  135. and ip.inspection_plan_id = t.inspection_plan_id
  136. and ip.status_cd = '0'
  137. <if test="planUserId !=null and planUserId != ''">
  138. and t.plan_user_id= #{planUserId}
  139. </if>
  140. <if test="startTime != null">
  141. and t.act_ins_time &gt;= #{startTime}
  142. </if>
  143. <if test="endTime != null">
  144. and t.act_ins_time &lt;= #{endTime}
  145. </if>
  146. <if test="planInsTime !=null ">
  147. and DATE_FORMAT(t.plan_ins_time,'%Y-%m-%d')= #{planInsTime}
  148. </if>
  149. <if test="planEndTime !=null ">
  150. and t.plan_end_time= #{planEndTime}
  151. </if>
  152. <if test="dayTask !=null ">
  153. and DateDiff(plan_ins_time,NOW())=0
  154. </if>
  155. <if test="todayPlanInsTime !=null ">
  156. and t.plan_ins_time &gt; #{todayPlanInsTime}
  157. </if>
  158. <if test="statusCd !=null and statusCd != ''">
  159. and t.status_cd= #{statusCd}
  160. </if>
  161. <if test="actUserName !=null and actUserName != ''">
  162. and t.act_user_name= #{actUserName}
  163. </if>
  164. <if test="signType !=null and signType != ''">
  165. and t.sign_type= #{signType}
  166. </if>
  167. <if test="inspectionPlanId !=null and inspectionPlanId != ''">
  168. and t.inspection_plan_id= #{inspectionPlanId}
  169. </if>
  170. <if test="inspectionPlanName != null and inspectionPlanName != ''">
  171. and ip.inspection_plan_name = #{inspectionPlanName}
  172. </if>
  173. <if test="planUserName !=null and planUserName != ''">
  174. and t.plan_user_name like '%${planUserName}%'
  175. </if>
  176. <if test="communityId !=null and communityId != ''">
  177. and t.community_id= #{communityId}
  178. </if>
  179. <if test="bId !=null and bId != ''">
  180. and t.b_id= #{bId}
  181. </if>
  182. <if test="actUserId !=null and actUserId != ''">
  183. and t.act_user_id= #{actUserId}
  184. </if>
  185. <if test="taskId !=null and taskId != ''">
  186. and t.task_id= #{taskId}
  187. </if>
  188. <if test="state !=null and state != ''">
  189. and t.state= #{state}
  190. </if>
  191. <if test="states !=null ">
  192. and t.state in
  193. <foreach collection="states" item="item" open="(" close=")" separator=",">
  194. #{item}
  195. </foreach>
  196. </if>
  197. <if test="scopeTime !=null ">
  198. and t.create_time &lt; #{scopeTime}
  199. and t.create_time &gt; #{createTime}
  200. </if>
  201. order by t.plan_ins_time
  202. <if test="page != -1 and page != null ">
  203. limit #{page}, #{row}
  204. </if>
  205. </select>
  206. <!-- 修改活动信息 add by wuxw 2018-07-03 -->
  207. <update id="updateInspectionTaskInfoInstance" parameterType="Map">
  208. update inspection_task t set t.status_cd = #{statusCd}
  209. <if test="newBId != null and newBId != ''">
  210. ,t.b_id = #{newBId}
  211. </if>
  212. <if test="planUserId !=null and planUserId != ''">
  213. , t.plan_user_id= #{planUserId}
  214. </if>
  215. <if test="state !=null and state != ''">
  216. , t.state= #{state}
  217. </if>
  218. <if test="actInsTime !=null ">
  219. , t.act_ins_time= #{actInsTime}
  220. </if>
  221. <if test="planInsTime !=null ">
  222. , t.plan_ins_time= #{planInsTime}
  223. </if>
  224. <if test="planEndTime !=null ">
  225. , t.plan_end_time= #{planEndTime}
  226. </if>
  227. <if test="actUserName !=null and actUserName != ''">
  228. , t.act_user_name= #{actUserName}
  229. </if>
  230. <if test="signType !=null and signType != ''">
  231. , t.sign_type= #{signType}
  232. </if>
  233. <if test="inspectionPlanId !=null and inspectionPlanId != ''">
  234. , t.inspection_plan_id= #{inspectionPlanId}
  235. </if>
  236. <if test="planUserName !=null and planUserName != ''">
  237. , t.plan_user_name= #{planUserName}
  238. </if>
  239. <if test="communityId !=null and communityId != ''">
  240. , t.community_id= #{communityId}
  241. </if>
  242. <if test="actUserId !=null and actUserId != ''">
  243. , t.act_user_id= #{actUserId}
  244. </if>
  245. <if test="originalPlanUserId !=null and originalPlanUserId != ''">
  246. , t.original_plan_user_id= #{originalPlanUserId}
  247. </if>
  248. <if test="originalPlanUserName !=null and originalPlanUserName != ''">
  249. , t.original_plan_user_name= #{original_plan_user_name}
  250. </if>
  251. <if test="transferDesc !=null and transferDesc != ''">
  252. , t.transfer_desc= #{transferDesc}
  253. </if>
  254. <if test="taskType !=null and taskType != ''">
  255. , t.task_type= #{taskType}
  256. </if>
  257. where 1=1
  258. <if test="bId !=null and bId != ''">
  259. and t.b_id= #{bId}
  260. </if>
  261. <if test="taskId !=null and taskId != ''">
  262. and t.task_id= #{taskId}
  263. </if>
  264. </update>
  265. <!-- 查询活动数量 add by wuxw 2018-07-03 -->
  266. <select id="queryInspectionTasksCount" parameterType="Map" resultType="Map">
  267. select count(1) count
  268. from inspection_task t,inspection_plan ip,t_dict td1,t_dict td2
  269. where 1 =1
  270. and t.sign_type = td1.status_cd
  271. and td1.table_name = 'inspection_task'
  272. and td1.table_columns = 'sign_type'
  273. and t.state = td2.status_cd
  274. and td2.table_name = 'inspection_task'
  275. and td2.table_columns = 'state'
  276. and ip.inspection_plan_id = t.inspection_plan_id
  277. and ip.status_cd = '0'
  278. <if test="planUserId !=null and planUserId != ''">
  279. and t.plan_user_id= #{planUserId}
  280. </if>
  281. <if test="startTime != null">
  282. and t.act_ins_time &gt;= #{startTime}
  283. </if>
  284. <if test="endTime != null">
  285. and t.act_ins_time &lt;= #{endTime}
  286. </if>
  287. <if test="planInsTime !=null ">
  288. and DATE_FORMAT(t.plan_ins_time,'%Y-%m-%d')= #{planInsTime}
  289. </if>
  290. <if test="planEndTime !=null ">
  291. and t.plan_end_time= #{planEndTime}
  292. </if>
  293. <if test="dayTask !=null ">
  294. and DateDiff(plan_ins_time,NOW())=0
  295. </if>
  296. <if test="statusCd !=null and statusCd != ''">
  297. and t.status_cd= #{statusCd}
  298. </if>
  299. <if test="actUserName !=null and actUserName != ''">
  300. and t.act_user_name= #{actUserName}
  301. </if>
  302. <if test="signType !=null and signType != ''">
  303. and t.sign_type= #{signType}
  304. </if>
  305. <if test="inspectionPlanId !=null and inspectionPlanId != ''">
  306. and t.inspection_plan_id= #{inspectionPlanId}
  307. </if>
  308. <if test="inspectionPlanName != null and inspectionPlanName != ''">
  309. and ip.inspection_plan_name = #{inspectionPlanName}
  310. </if>
  311. <if test="planUserName !=null and planUserName != ''">
  312. and t.plan_user_name like '%${planUserName}%'
  313. </if>
  314. <if test="communityId !=null and communityId != ''">
  315. and t.community_id= #{communityId}
  316. </if>
  317. <if test="bId !=null and bId != ''">
  318. and t.b_id= #{bId}
  319. </if>
  320. <if test="actUserId !=null and actUserId != ''">
  321. and t.act_user_id= #{actUserId}
  322. </if>
  323. <if test="taskId !=null and taskId != ''">
  324. and t.task_id= #{taskId}
  325. </if>
  326. <if test="state !=null and state != ''">
  327. and t.state= #{state}
  328. </if>
  329. <if test="states !=null ">
  330. and t.state in
  331. <foreach collection="states" item="item" open="(" close=")" separator=",">
  332. #{item}
  333. </foreach>
  334. </if>
  335. </select>
  336. <!-- 查询未安排的巡检计划 -->
  337. <select id="queryTodayInspectionPlan" parameterType="Map" resultType="Map">
  338. SELECT
  339. ip.inspection_plan_id inspectionPlanId,
  340. ip.inspection_plan_name inspectionPlanName,
  341. ip.inspection_plan_period inspectionPlanPeriod,
  342. ip.sign_type signType,
  343. ip.community_id communityId,
  344. ip.end_time endTime,
  345. ip.staff_id planUserId,
  346. ip.staff_name planUserName
  347. FROM
  348. inspection_plan ip
  349. inner join
  350. LEFT JOIN inspection_task it ON ip.inspection_plan_id = it.inspection_plan_id
  351. AND ip.staff_id = it.plan_user_id
  352. AND it.status_cd = '0'
  353. AND ip.community_id = it.community_id
  354. <if test="inspectionPlanPeriod !=null and inspectionPlanPeriod == '2020023'">
  355. and it.plan_ins_time &gt; DATE_SUB(curdate(),INTERVAL 7 DAY)
  356. </if>
  357. <if test="inspectionPlanPeriod !=null and inspectionPlanPeriod == '2020024'">
  358. and it.plan_ins_time &gt; DATE_SUB(curdate(),INTERVAL 30 DAY)
  359. </if>
  360. WHERE
  361. ip.status_cd = '0'
  362. and ip.end_time &gt; now()
  363. and ip.start_time &lt; now()
  364. and ip.state = '2020025'
  365. AND it.inspection_plan_id IS NOT NULL
  366. and ip.community_id = #{communityId}
  367. <if test="inspectionPlanPeriod !=null and inspectionPlanPeriod != ''">
  368. and ip.inspection_plan_period= #{inspectionPlanPeriod}
  369. </if>
  370. limit 1000
  371. </select>
  372. <!-- 保存活动信息 add by wuxw 2018-07-03 -->
  373. <insert id="insertInspectionTask" parameterType="Map">
  374. insert into inspection_task(
  375. 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
  376. ) values
  377. <foreach collection="tasks" item="task" separator=",">
  378. (#{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})
  379. </foreach>
  380. </insert>
  381. <!-- 保存活动信息 add by wuxw 2018-07-03 -->
  382. <insert id="insertInspectionTaskDetail" parameterType="Map">
  383. insert into inspection_task_detail(
  384. task_detail_id,b_id,community_id,task_id,inspection_id,inspection_name,state,point_start_time,point_end_time,sort_number
  385. ) values
  386. <foreach collection="tasks" item="task" separator=",">
  387. (#{task.taskDetailId},'-1',#{task.communityId},#{task.taskId},#{task.inspectionId},#{task.inspectionName},'20200405',#{task.pointStartTime},#{task.pointEndTime},#{task.sortNumber})
  388. </foreach>
  389. </insert>
  390. </mapper>