InspectionTaskServiceDaoImplMapper.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  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,act_user_name,operate,sign_type,inspection_plan_id,plan_user_name,community_id,b_id,act_user_id,task_id,state
  10. ) values (
  11. #{planUserId},#{actInsTime},#{planInsTime},#{actUserName},#{operate},#{signType},#{inspectionPlanId},#{planUserName},#{communityId},#{bId},#{actUserId},#{taskId},#{state}
  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.act_user_name,t.act_user_name
  18. actUserName,t.operate,t.sign_type,t.sign_type signType,t.inspection_plan_id,t.inspection_plan_id
  19. inspectionPlanId,t.plan_user_name,t.plan_user_name planUserName,t.community_id,t.community_id
  20. communityId,t.b_id,t.b_id bId,t.act_user_id,t.act_user_id actUserId,t.task_id,t.task_id taskId,t.state
  21. from business_inspection_task t
  22. where 1 =1
  23. <if test="planUserId !=null and planUserId != ''">
  24. and t.plan_user_id= #{planUserId}
  25. </if>
  26. <if test="actInsTime !=null ">
  27. and t.act_ins_time= #{actInsTime}
  28. </if>
  29. <if test="planInsTime !=null ">
  30. and t.plan_ins_time= #{planInsTime}
  31. </if>
  32. <if test="actUserName !=null and actUserName != ''">
  33. and t.act_user_name= #{actUserName}
  34. </if>
  35. <if test="operate !=null and operate != ''">
  36. and t.operate= #{operate}
  37. </if>
  38. <if test="signType !=null and signType != ''">
  39. and t.sign_type= #{signType}
  40. </if>
  41. <if test="inspectionPlanId !=null and inspectionPlanId != ''">
  42. and t.inspection_plan_id= #{inspectionPlanId}
  43. </if>
  44. <if test="planUserName !=null and planUserName != ''">
  45. and t.plan_user_name= #{planUserName}
  46. </if>
  47. <if test="communityId !=null and communityId != ''">
  48. and t.community_id= #{communityId}
  49. </if>
  50. <if test="bId !=null and bId != ''">
  51. and t.b_id= #{bId}
  52. </if>
  53. <if test="actUserId !=null and actUserId != ''">
  54. and t.act_user_id= #{actUserId}
  55. </if>
  56. <if test="taskId !=null and taskId != ''">
  57. and t.task_id= #{taskId}
  58. </if>
  59. <if test="state !=null and state != ''">
  60. and t.state= #{state}
  61. </if>
  62. </select>
  63. <!-- 保存活动信息至 instance表中 add by wuxw 2018-07-03 -->
  64. <insert id="saveInspectionTaskInfoInstance" parameterType="Map">
  65. insert into inspection_task(
  66. plan_user_id,act_ins_time,plan_ins_time,status_cd,act_user_name,sign_type,inspection_plan_id,plan_user_name,community_id,b_id,act_user_id,task_id,state
  67. ) select
  68. t.plan_user_id,t.act_ins_time,t.plan_ins_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
  69. from business_inspection_task t where 1=1
  70. <if test="planUserId !=null and planUserId != ''">
  71. and t.plan_user_id= #{planUserId}
  72. </if>
  73. <if test="actInsTime !=null">
  74. and t.act_ins_time= #{actInsTime}
  75. </if>
  76. <if test="planInsTime !=null ">
  77. and t.plan_ins_time= #{planInsTime}
  78. </if>
  79. <if test="actUserName !=null and actUserName != ''">
  80. and t.act_user_name= #{actUserName}
  81. </if>
  82. and t.operate= 'ADD'
  83. <if test="signType !=null and signType != ''">
  84. and t.sign_type= #{signType}
  85. </if>
  86. <if test="inspectionPlanId !=null and inspectionPlanId != ''">
  87. and t.inspection_plan_id= #{inspectionPlanId}
  88. </if>
  89. <if test="planUserName !=null and planUserName != ''">
  90. and t.plan_user_name= #{planUserName}
  91. </if>
  92. <if test="communityId !=null and communityId != ''">
  93. and t.community_id= #{communityId}
  94. </if>
  95. <if test="bId !=null and bId != ''">
  96. and t.b_id= #{bId}
  97. </if>
  98. <if test="actUserId !=null and actUserId != ''">
  99. and t.act_user_id= #{actUserId}
  100. </if>
  101. <if test="taskId !=null and taskId != ''">
  102. and t.task_id= #{taskId}
  103. </if>
  104. <if test="state !=null and state != ''">
  105. and t.state= #{state}
  106. </if>
  107. </insert>
  108. <!-- 查询活动信息 add by wuxw 2018-07-03 -->
  109. <select id="getInspectionTaskInfo" parameterType="Map" resultType="Map">
  110. select t.plan_user_id,t.plan_user_id planUserId,t.act_ins_time,t.act_ins_time
  111. actInsTime,t.plan_ins_time,t.plan_ins_time planInsTime,t.status_cd,t.status_cd
  112. statusCd,t.act_user_name,t.act_user_name actUserName,t.sign_type,t.sign_type
  113. signType,t.inspection_plan_id,t.inspection_plan_id inspectionPlanId,t.plan_user_name,t.plan_user_name
  114. planUserName,t.community_id,t.community_id communityId,t.b_id,t.b_id bId,t.act_user_id,t.act_user_id
  115. actUserId,t.task_id,t.task_id taskId,t.state,td1.name signTypeName,td2.name stateName,ip.inspection_plan_name inspectionPlanName
  116. from inspection_task t,inspection_plan ip,t_dict td1,t_dict td2
  117. where 1 =1
  118. and t.sign_type = td1.status_cd
  119. and td1.table_name = 'inspection_task'
  120. and td1.table_columns = 'sign_type'
  121. and t.state = td2.status_cd
  122. and td2.table_name = 'inspection_task'
  123. and td2.table_columns = 'state'
  124. and ip.inspection_plan_id = t.inspection_plan_id
  125. and ip.status_cd = '0'
  126. <if test="planUserId !=null and planUserId != ''">
  127. and t.plan_user_id= #{planUserId}
  128. </if>
  129. <if test="actInsTime !=null ">
  130. and t.act_ins_time= #{actInsTime}
  131. </if>
  132. <if test="planInsTime !=null ">
  133. and t.plan_ins_time= #{planInsTime}
  134. </if>
  135. <if test="statusCd !=null and statusCd != ''">
  136. and t.status_cd= #{statusCd}
  137. </if>
  138. <if test="actUserName !=null and actUserName != ''">
  139. and t.act_user_name= #{actUserName}
  140. </if>
  141. <if test="signType !=null and signType != ''">
  142. and t.sign_type= #{signType}
  143. </if>
  144. <if test="inspectionPlanId !=null and inspectionPlanId != ''">
  145. and t.inspection_plan_id= #{inspectionPlanId}
  146. </if>
  147. <if test="planUserName !=null and planUserName != ''">
  148. and t.plan_user_name= #{planUserName}
  149. </if>
  150. <if test="communityId !=null and communityId != ''">
  151. and t.community_id= #{communityId}
  152. </if>
  153. <if test="bId !=null and bId != ''">
  154. and t.b_id= #{bId}
  155. </if>
  156. <if test="actUserId !=null and actUserId != ''">
  157. and t.act_user_id= #{actUserId}
  158. </if>
  159. <if test="taskId !=null and taskId != ''">
  160. and t.task_id= #{taskId}
  161. </if>
  162. <if test="state !=null and state != ''">
  163. and t.state= #{state}
  164. </if>
  165. <if test="scopeTime !=null ">
  166. and t.create_time &lt; #{scopeTime}
  167. and t.create_time &gt; #{createTime}
  168. </if>
  169. order by t.create_time desc
  170. <if test="page != -1 and page != null ">
  171. limit #{page}, #{row}
  172. </if>
  173. </select>
  174. <!-- 修改活动信息 add by wuxw 2018-07-03 -->
  175. <update id="updateInspectionTaskInfoInstance" parameterType="Map">
  176. update inspection_task t set t.status_cd = #{statusCd}
  177. <if test="newBId != null and newBId != ''">
  178. ,t.b_id = #{newBId}
  179. </if>
  180. <if test="planUserId !=null and planUserId != ''">
  181. , t.plan_user_id= #{planUserId}
  182. </if>
  183. <if test="state !=null and state != ''">
  184. , t.state= #{state}
  185. </if>
  186. <if test="actInsTime !=null ">
  187. , t.act_ins_time= #{actInsTime}
  188. </if>
  189. <if test="planInsTime !=null ">
  190. , t.plan_ins_time= #{planInsTime}
  191. </if>
  192. <if test="actUserName !=null and actUserName != ''">
  193. , t.act_user_name= #{actUserName}
  194. </if>
  195. <if test="signType !=null and signType != ''">
  196. , t.sign_type= #{signType}
  197. </if>
  198. <if test="inspectionPlanId !=null and inspectionPlanId != ''">
  199. , t.inspection_plan_id= #{inspectionPlanId}
  200. </if>
  201. <if test="planUserName !=null and planUserName != ''">
  202. , t.plan_user_name= #{planUserName}
  203. </if>
  204. <if test="communityId !=null and communityId != ''">
  205. , t.community_id= #{communityId}
  206. </if>
  207. <if test="actUserId !=null and actUserId != ''">
  208. , t.act_user_id= #{actUserId}
  209. </if>
  210. where 1=1
  211. <if test="bId !=null and bId != ''">
  212. and t.b_id= #{bId}
  213. </if>
  214. <if test="taskId !=null and taskId != ''">
  215. and t.task_id= #{taskId}
  216. </if>
  217. </update>
  218. <!-- 查询活动数量 add by wuxw 2018-07-03 -->
  219. <select id="queryInspectionTasksCount" parameterType="Map" resultType="Map">
  220. select count(1) count
  221. from inspection_task t,inspection_plan ip,t_dict td1,t_dict td2
  222. where 1 =1
  223. and t.sign_type = td1.status_cd
  224. and td1.table_name = 'inspection_task'
  225. and td1.table_columns = 'sign_type'
  226. and t.state = td2.status_cd
  227. and td2.table_name = 'inspection_task'
  228. and td2.table_columns = 'state'
  229. and ip.inspection_plan_id = t.inspection_plan_id
  230. and ip.status_cd = '0'
  231. <if test="planUserId !=null and planUserId != ''">
  232. and t.plan_user_id= #{planUserId}
  233. </if>
  234. <if test="actInsTime !=null ">
  235. and t.act_ins_time= #{actInsTime}
  236. </if>
  237. <if test="planInsTime !=null ">
  238. and t.plan_ins_time= #{planInsTime}
  239. </if>
  240. <if test="statusCd !=null and statusCd != ''">
  241. and t.status_cd= #{statusCd}
  242. </if>
  243. <if test="actUserName !=null and actUserName != ''">
  244. and t.act_user_name= #{actUserName}
  245. </if>
  246. <if test="signType !=null and signType != ''">
  247. and t.sign_type= #{signType}
  248. </if>
  249. <if test="inspectionPlanId !=null and inspectionPlanId != ''">
  250. and t.inspection_plan_id= #{inspectionPlanId}
  251. </if>
  252. <if test="planUserName !=null and planUserName != ''">
  253. and t.plan_user_name= #{planUserName}
  254. </if>
  255. <if test="communityId !=null and communityId != ''">
  256. and t.community_id= #{communityId}
  257. </if>
  258. <if test="bId !=null and bId != ''">
  259. and t.b_id= #{bId}
  260. </if>
  261. <if test="actUserId !=null and actUserId != ''">
  262. and t.act_user_id= #{actUserId}
  263. </if>
  264. <if test="taskId !=null and taskId != ''">
  265. and t.task_id= #{taskId}
  266. </if>
  267. </select>
  268. <!-- 查询未安排的巡检计划 -->
  269. <select id="queryTodayInspectionPlan" parameterType="Map" resultType="Map">
  270. SELECT
  271. ip.inspection_plan_id inspectionPlanId,
  272. ip.inspection_plan_name inspectionPlanName,
  273. ip.inspection_plan_period inspectionPlanPeriod,
  274. ip.sign_type signType,
  275. ip.community_id communityId,
  276. ip.end_time endTime,
  277. ip.staff_id planUserId,
  278. ip.staff_name planUserName
  279. FROM
  280. inspection_plan ip
  281. inner join
  282. LEFT JOIN inspection_task it ON ip.inspection_plan_id = it.inspection_plan_id
  283. AND ip.staff_id = it.plan_user_id
  284. AND it.status_cd = '0'
  285. AND ip.community_id = it.community_id
  286. <if test="inspectionPlanPeriod !=null and inspectionPlanPeriod == '2020023'">
  287. and it.plan_ins_time &gt; DATE_SUB(curdate(),INTERVAL 7 DAY)
  288. </if>
  289. <if test="inspectionPlanPeriod !=null and inspectionPlanPeriod == '2020024'">
  290. and it.plan_ins_time &gt; DATE_SUB(curdate(),INTERVAL 30 DAY)
  291. </if>
  292. WHERE
  293. ip.status_cd = '0'
  294. and ip.end_time &gt; now()
  295. and ip.start_time &lt; now()
  296. and ip.state = '2020025'
  297. AND it.inspection_plan_id IS NOT NULL
  298. and ip.community_id = #{communityId}
  299. <if test="inspectionPlanPeriod !=null and inspectionPlanPeriod != ''">
  300. and ip.inspection_plan_period= #{inspectionPlanPeriod}
  301. </if>
  302. limit 1000
  303. </select>
  304. <!-- 保存活动信息 add by wuxw 2018-07-03 -->
  305. <insert id="insertInspectionTask" parameterType="Map">
  306. insert into inspection_task(
  307. plan_user_id,plan_ins_time,sign_type,inspection_plan_id,plan_user_name,community_id,b_id,task_id,state,ip_staff_id
  308. )
  309. <foreach collection="tasks" item="task" separator=",">
  310. (#{task.planUserId},#{task.planInsTime},#{task.signType},#{task.inspectionPlanId},#{task.planUserName},#{task.communityId},'-1',#{task.taskId},'20200405',#{task.ipStaffId})
  311. </foreach>
  312. </insert>
  313. <!-- 保存活动信息 add by wuxw 2018-07-03 -->
  314. <insert id="insertInspectionTaskDetail" parameterType="Map">
  315. insert into inspection_task_detail(
  316. task_detail_id,b_id,community_id,task_id,inspection_id,inspection_name,state
  317. )
  318. <foreach collection="tasks" item="task" separator=",">
  319. (#{task.taskDetailId},'-1',#{task.communityId},#{task.taskId},#{task.inspectionId},#{task.inspectionName},'20200405')
  320. </foreach>
  321. </insert>
  322. </mapper>