InspectionTaskServiceDaoImplMapper.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  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. order by t.create_time desc
  166. <if test="page != -1 and page != null ">
  167. limit #{page}, #{row}
  168. </if>
  169. </select>
  170. <!-- 修改活动信息 add by wuxw 2018-07-03 -->
  171. <update id="updateInspectionTaskInfoInstance" parameterType="Map">
  172. update inspection_task t set t.status_cd = #{statusCd}
  173. <if test="newBId != null and newBId != ''">
  174. ,t.b_id = #{newBId}
  175. </if>
  176. <if test="planUserId !=null and planUserId != ''">
  177. , t.plan_user_id= #{planUserId}
  178. </if>
  179. <if test="state !=null and state != ''">
  180. , t.state= #{state}
  181. </if>
  182. <if test="actInsTime !=null ">
  183. , t.act_ins_time= #{actInsTime}
  184. </if>
  185. <if test="planInsTime !=null ">
  186. , t.plan_ins_time= #{planInsTime}
  187. </if>
  188. <if test="actUserName !=null and actUserName != ''">
  189. , t.act_user_name= #{actUserName}
  190. </if>
  191. <if test="signType !=null and signType != ''">
  192. , t.sign_type= #{signType}
  193. </if>
  194. <if test="inspectionPlanId !=null and inspectionPlanId != ''">
  195. , t.inspection_plan_id= #{inspectionPlanId}
  196. </if>
  197. <if test="planUserName !=null and planUserName != ''">
  198. , t.plan_user_name= #{planUserName}
  199. </if>
  200. <if test="communityId !=null and communityId != ''">
  201. , t.community_id= #{communityId}
  202. </if>
  203. <if test="actUserId !=null and actUserId != ''">
  204. , t.act_user_id= #{actUserId}
  205. </if>
  206. where 1=1
  207. <if test="bId !=null and bId != ''">
  208. and t.b_id= #{bId}
  209. </if>
  210. <if test="taskId !=null and taskId != ''">
  211. and t.task_id= #{taskId}
  212. </if>
  213. </update>
  214. <!-- 查询活动数量 add by wuxw 2018-07-03 -->
  215. <select id="queryInspectionTasksCount" parameterType="Map" resultType="Map">
  216. select count(1) count
  217. from inspection_task t,inspection_plan ip,t_dict td1,t_dict td2
  218. where 1 =1
  219. and t.sign_type = td1.status_cd
  220. and td1.table_name = 'inspection_task'
  221. and td1.table_columns = 'sign_type'
  222. and t.state = td2.status_cd
  223. and td2.table_name = 'inspection_task'
  224. and td2.table_columns = 'state'
  225. and ip.inspection_plan_id = t.inspection_plan_id
  226. and ip.status_cd = '0'
  227. <if test="planUserId !=null and planUserId != ''">
  228. and t.plan_user_id= #{planUserId}
  229. </if>
  230. <if test="actInsTime !=null ">
  231. and t.act_ins_time= #{actInsTime}
  232. </if>
  233. <if test="planInsTime !=null ">
  234. and t.plan_ins_time= #{planInsTime}
  235. </if>
  236. <if test="statusCd !=null and statusCd != ''">
  237. and t.status_cd= #{statusCd}
  238. </if>
  239. <if test="actUserName !=null and actUserName != ''">
  240. and t.act_user_name= #{actUserName}
  241. </if>
  242. <if test="signType !=null and signType != ''">
  243. and t.sign_type= #{signType}
  244. </if>
  245. <if test="inspectionPlanId !=null and inspectionPlanId != ''">
  246. and t.inspection_plan_id= #{inspectionPlanId}
  247. </if>
  248. <if test="planUserName !=null and planUserName != ''">
  249. and t.plan_user_name= #{planUserName}
  250. </if>
  251. <if test="communityId !=null and communityId != ''">
  252. and t.community_id= #{communityId}
  253. </if>
  254. <if test="bId !=null and bId != ''">
  255. and t.b_id= #{bId}
  256. </if>
  257. <if test="actUserId !=null and actUserId != ''">
  258. and t.act_user_id= #{actUserId}
  259. </if>
  260. <if test="taskId !=null and taskId != ''">
  261. and t.task_id= #{taskId}
  262. </if>
  263. </select>
  264. <!-- 查询未安排的巡检计划 -->
  265. <select id="queryTodayInspectionPlan" parameterType="Map" resultType="Map">
  266. SELECT
  267. ip.inspection_plan_id inspectionPlanId,
  268. ip.inspection_plan_name inspectionPlanName,
  269. ip.inspection_plan_period inspectionPlanPeriod,
  270. ip.sign_type signType,
  271. ip.community_id communityId,
  272. ip.end_time endTime,
  273. ip.staff_id planUserId,
  274. ip.staff_name planUserName
  275. FROM
  276. inspection_plan ip
  277. inner join
  278. LEFT JOIN inspection_task it ON ip.inspection_plan_id = it.inspection_plan_id
  279. AND ip.staff_id = it.plan_user_id
  280. AND it.status_cd = '0'
  281. AND ip.community_id = it.community_id
  282. <if test="inspectionPlanPeriod !=null and inspectionPlanPeriod == '2020023'">
  283. and it.plan_ins_time &gt; DATE_SUB(curdate(),INTERVAL 7 DAY)
  284. </if>
  285. <if test="inspectionPlanPeriod !=null and inspectionPlanPeriod == '2020024'">
  286. and it.plan_ins_time &gt; DATE_SUB(curdate(),INTERVAL 30 DAY)
  287. </if>
  288. WHERE
  289. ip.status_cd = '0'
  290. and ip.end_time &gt; now()
  291. and ip.start_time &lt; now()
  292. and ip.state = '2020025'
  293. AND it.inspection_plan_id IS NOT NULL
  294. and ip.community_id = #{communityId}
  295. <if test="inspectionPlanPeriod !=null and inspectionPlanPeriod != ''">
  296. and ip.inspection_plan_period= #{inspectionPlanPeriod}
  297. </if>
  298. limit 1000
  299. </select>
  300. <!-- 保存活动信息 add by wuxw 2018-07-03 -->
  301. <insert id="insertInspectionTask" parameterType="Map">
  302. insert into inspection_task(
  303. plan_user_id,plan_ins_time,sign_type,inspection_plan_id,plan_user_name,community_id,b_id,task_id,state
  304. )
  305. <foreach collection="tasks" item="task" separator=",">
  306. (#{task.planUserId},#{task.planInsTime},#{task.signType},#{task.inspectionPlanId},#{task.planUserName},#{task.communityId},'-1',#{task.taskId},'20200405')
  307. </foreach>
  308. </insert>
  309. <!-- 保存活动信息 add by wuxw 2018-07-03 -->
  310. <insert id="insertInspectionTaskDetail" parameterType="Map">
  311. insert into inspection_task_detail(
  312. task_detail_id,b_id,community_id,task_id,inspection_id,inspection_name,state
  313. )
  314. <foreach collection="tasks" item="task" separator=",">
  315. (#{task.taskDetailId},'-1',#{task.communityId},#{task.taskId},#{task.inspectionId},#{task.inspectionName},'20200405')
  316. </foreach>
  317. </insert>
  318. </mapper>