InspectionServiceDaoImplMapper.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  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="inspectionServiceDaoImpl">
  6. <!-- 保存巡检点信息 add by wuxw 2018-07-03
  7. -->
  8. <insert id="saveBusinessInspectionInfo" parameterType="Map">
  9. insert into business_inspection_point
  10. (inspection_id,operate,remark,inspection_name,community_id,b_id,point_obj_type,point_obj_id,point_obj_name)
  11. values
  12. (#{inspectionId},#{operate},#{remark},#{inspectionName},#{communityId},#{bId},#{pointObjType},#{pointObjId},#{pointObjName})
  13. </insert>
  14. <!-- 查询巡检点信息(Business) add by wuxw 2018-07-03 -->
  15. <select id="getBusinessInspectionInfo" parameterType="Map" resultType="Map">
  16. select t.inspection_id,t.inspection_id inspectionId,t.operate,t.remark,t.inspection_name,t.inspection_name inspectionName,
  17. t.community_id,t.community_id communityId,t.b_id,t.b_id bId,t.point_obj_type,t.point_obj_id,t.point_obj_name,
  18. t.point_obj_type pointObjType,t.point_obj_id pointObjId,t.point_obj_name pointObjName
  19. from business_inspection_point t
  20. where 1 =1
  21. <if test="inspectionId !=null and inspectionId != ''">
  22. and t.inspection_id= #{inspectionId}
  23. </if>
  24. <if test="operate !=null and operate != ''">
  25. and t.operate= #{operate}
  26. </if>
  27. <if test="remark !=null and remark != ''">
  28. and t.remark= #{remark}
  29. </if>
  30. <if test="inspectionName !=null and inspectionName != ''">
  31. and t.inspection_name like concat('%',#{inspectionName},'%')
  32. </if>
  33. <if test="communityId !=null and communityId != ''">
  34. and t.community_id= #{communityId}
  35. </if>
  36. <if test="bId !=null and bId != ''">
  37. and t.b_id= #{bId}
  38. </if>
  39. </select>
  40. <!-- 保存巡检点信息至 instance表中 add by wuxw 2018-07-03 -->
  41. <insert id="saveInspectionInfoInstance" parameterType="Map">
  42. insert into
  43. inspection_point(
  44. inspection_id,remark,status_cd,inspection_name,community_id,b_id,
  45. point_obj_type,point_obj_id,point_obj_name
  46. ) select t.inspection_id,t.remark,'0',t.inspection_name,t.community_id,t.b_id,
  47. t.point_obj_type,t.point_obj_id,t.point_obj_name
  48. from
  49. business_inspection_point t where 1=1
  50. <if test="inspectionId !=null and inspectionId != ''">
  51. and t.inspection_id= #{inspectionId}
  52. </if>
  53. and t.operate= 'ADD'
  54. <if test="remark !=null and remark != ''">
  55. and t.remark= #{remark}
  56. </if>
  57. <if test="inspectionName !=null and inspectionName != ''">
  58. and t.inspection_name= #{inspectionName}
  59. </if>
  60. <if test="communityId !=null and communityId != ''">
  61. and t.community_id= #{communityId}
  62. </if>
  63. <if test="bId !=null and bId != ''">
  64. and t.b_id= #{bId}
  65. </if>
  66. </insert>
  67. <!-- 查询巡检点信息 add by wuxw 2018-07-03 -->
  68. <select id="getInspectionInfo" parameterType="Map" resultType="Map">
  69. select
  70. t.inspection_id,t.inspection_id inspectionId,t.remark,t.status_cd,t.status_cd statusCd,
  71. t.inspection_name,t.inspection_name inspectionName,t.community_id,
  72. t.community_id communityId,t.b_id,t.b_id bId,
  73. t.point_obj_type,t.point_obj_id,t.point_obj_name,
  74. t.point_obj_type pointObjType,t.point_obj_id pointObjId,t.point_obj_name pointObjName
  75. from inspection_point t
  76. <if test="inspectionRouteId != null and inspectionRouteId != ''">
  77. left join inspection_route_point_rel c on t.inspection_id = c.inspection_id
  78. and c.status_cd = '0'
  79. and c.inspection_route_id is null
  80. </if>
  81. where 1 =1
  82. <if test="inspectionId !=null and inspectionId != ''">
  83. and t.inspection_id= #{inspectionId}
  84. </if>
  85. <if test="pointObjType !=null and pointObjType != ''">
  86. and t.point_obj_type= #{pointObjType}
  87. </if>
  88. <if test="remark !=null and remark != ''">
  89. and t.remark= #{remark}
  90. </if>
  91. <if test="statusCd !=null and statusCd != ''">
  92. and t.status_cd= #{statusCd}
  93. </if>
  94. <if test="inspectionName !=null and inspectionName != ''">
  95. and t.inspection_name like concat('%',#{inspectionName},'%')
  96. </if>
  97. <if test="communityId !=null and communityId != ''">
  98. and t.community_id= #{communityId}
  99. </if>
  100. <if test="bId !=null and bId != ''">
  101. and t.b_id= #{bId}
  102. </if>
  103. group by t.inspection_id
  104. order by t.create_time desc
  105. <if test="page != -1 and page != null ">
  106. limit #{page}, #{row}
  107. </if>
  108. </select>
  109. <!-- 修改巡检点信息 add by wuxw 2018-07-03 -->
  110. <update id="updateInspectionInfoInstance" parameterType="Map">
  111. update inspection_point t set t.status_cd = #{statusCd}
  112. <if test="newBId != null and newBId != ''">
  113. ,t.b_id = #{newBId}
  114. </if>
  115. <if test="pointObjType !=null and pointObjType != ''">
  116. , t.point_obj_type= #{pointObjType}
  117. </if>
  118. <if test="pointObjId !=null and pointObjId != ''">
  119. , t.point_obj_id= #{pointObjId}
  120. </if>
  121. <if test="pointObjName !=null and pointObjName != ''">
  122. , t.point_obj_name= #{pointObjName}
  123. </if>
  124. <if test="remark !=null and remark != ''">
  125. , t.remark= #{remark}
  126. </if>
  127. <if test="inspectionName !=null and inspectionName != ''">
  128. , t.inspection_name= #{inspectionName}
  129. </if>
  130. <if test="communityId !=null and communityId != ''">
  131. , t.community_id= #{communityId}
  132. </if>
  133. where 1=1
  134. <if test="inspectionId !=null and inspectionId != ''">
  135. and t.inspection_id= #{inspectionId}
  136. </if>
  137. <if test="bId !=null and bId != ''">
  138. and t.b_id= #{bId}
  139. </if>
  140. </update>
  141. <!-- 查询巡检点数量 add by wuxw 2018-07-03 -->
  142. <select id="queryInspectionsCount" parameterType="Map" resultType="Map">
  143. select count(1) count
  144. from inspection_point t
  145. <if test="inspectionRouteId != null and inspectionRouteId != ''">
  146. left join inspection_route_point_rel c on t.inspection_id = c.inspection_id
  147. and c.status_cd = '0'
  148. and c.inspection_route_id is null
  149. </if>
  150. where 1 =1
  151. <if test="inspectionId !=null and inspectionId != ''">
  152. and t.inspection_id= #{inspectionId}
  153. </if>
  154. <if test="pointObjType !=null and pointObjType != ''">
  155. and t.point_obj_type= #{pointObjType}
  156. </if>
  157. <if test="remark !=null and remark != ''">
  158. and t.remark= #{remark}
  159. </if>
  160. <if test="statusCd !=null and statusCd != ''">
  161. and t.status_cd= #{statusCd}
  162. </if>
  163. <if test="inspectionName !=null and inspectionName != ''">
  164. and t.inspection_name like concat('%',#{inspectionName},'%')
  165. </if>
  166. <if test="communityId !=null and communityId != ''">
  167. and t.community_id= #{communityId}
  168. </if>
  169. <if test="bId !=null and bId != ''">
  170. and t.b_id= #{bId}
  171. </if>
  172. </select>
  173. <!-- 查询巡检点信息 add by wuxw 2018-07-03 -->
  174. <select id="getInspectionRelationShipInfo" parameterType="Map" resultType="Map">
  175. select
  176. t.inspection_id,t.inspection_id inspectionId,t.remark,t.status_cd,t.status_cd statusCd,
  177. t.inspection_name,t.inspection_name inspectionName,t.community_id,
  178. t.community_id communityId,t.b_id,t.b_id bId,
  179. t.point_obj_type,t.point_obj_id,t.point_obj_name,
  180. t.point_obj_type pointObjType,t.point_obj_id pointObjId,t.point_obj_name pointObjName
  181. d.name locationTypeName
  182. from inspection_point t
  183. left join inspection_route_point_rel c on t.inspection_id = c.inspection_id and c.status_cd = '0' and c.inspection_route_id = #{inspectionRouteId}
  184. where 1 =1
  185. <if test="relationship != null and relationship == 1">
  186. and c.inspection_id is not null
  187. </if>
  188. <if test="relationship != null and relationship == 0">
  189. and c.inspection_id is null
  190. </if>
  191. <if test="inspectionId !=null and inspectionId != ''">
  192. and t.inspection_id= #{inspectionId}
  193. </if>
  194. <if test="pointObjType !=null and pointObjType != ''">
  195. and t.point_obj_type= #{pointObjType}
  196. </if>
  197. <if test="remark !=null and remark != ''">
  198. and t.remark= #{remark}
  199. </if>
  200. <if test="statusCd !=null and statusCd != ''">
  201. and t.status_cd= #{statusCd}
  202. </if>
  203. <if test="inspectionName !=null and inspectionName != ''">
  204. and t.inspection_name like concat('%',#{inspectionName},'%')
  205. </if>
  206. <if test="communityId !=null and communityId != ''">
  207. and t.community_id= #{communityId}
  208. </if>
  209. <if test="bId !=null and bId != ''">
  210. and t.b_id= #{bId}
  211. </if>
  212. order by t.create_time desc
  213. <if test="page != -1 and page != null ">
  214. limit #{page}, #{row}
  215. </if>
  216. </select>
  217. <!-- 查询巡检点数量 add by wuxw 2018-07-03 -->
  218. <select id="queryInspectionsRelationShipCount" parameterType="Map" resultType="Map">
  219. select count(1) count
  220. from inspection_point t
  221. left join inspection_route_point_rel c on t.inspection_id = c.inspection_id and c.status_cd = '0' and c.inspection_route_id = #{inspectionRouteId}
  222. where 1 =1
  223. <if test="relationship != null and relationship == 1">
  224. and c.inspection_id is not null
  225. </if>
  226. <if test="relationship != null and relationship == 0">
  227. and c.inspection_id is null
  228. </if>
  229. <if test="inspectionId !=null and inspectionId != ''">
  230. and t.inspection_id= #{inspectionId}
  231. </if>
  232. <if test="pointObjType !=null and pointObjType != ''">
  233. and t.point_obj_type= #{pointObjType}
  234. </if>
  235. <if test="remark !=null and remark != ''">
  236. and t.remark= #{remark}
  237. </if>
  238. <if test="statusCd !=null and statusCd != ''">
  239. and t.status_cd= #{statusCd}
  240. </if>
  241. <if test="inspectionName !=null and inspectionName != ''">
  242. and t.inspection_name like concat('%',#{inspectionName},'%')
  243. </if>
  244. <if test="communityId !=null and communityId != ''">
  245. and t.community_id= #{communityId}
  246. </if>
  247. <if test="bId !=null and bId != ''">
  248. and t.b_id= #{bId}
  249. </if>
  250. </select>
  251. <!-- 查询巡检点信息 add by wuxw 2018-07-03 -->
  252. <select id="queryInspectionsByPlan" parameterType="Map" resultType="Map">
  253. select
  254. t.inspection_id,t.inspection_id inspectionId,t.machine_id,
  255. t.machine_id machineId,t.remark,t.status_cd,t.status_cd statusCd,
  256. t.inspection_name,t.inspection_name inspectionName,t.community_id,
  257. t.community_id communityId,t.b_id,t.b_id bId,
  258. m.machine_code machineCode,m.machine_name machineName,location_type_cd locationTypeCd,location_obj_id
  259. locationObjId,m.machine_id machineId,
  260. d.name locationTypeName
  261. from inspection_point t,machine m,t_dict d,inspection_route_point_rel c,inspection_plan ip
  262. where 1 =1
  263. and t.machine_id = m.machine_id
  264. and m.status_cd = 0
  265. and d.status_cd = m.location_type_cd
  266. and d.table_name = 'machine'
  267. and d.table_columns = 'location_type_cd'
  268. and t.inspection_id = c.inspection_id
  269. and c.status_cd = '0'
  270. and c.inspection_route_id = ip.inspection_route_id
  271. and ip.inspection_plan_id = #{inspectionPlanId}
  272. <if test="inspectionId !=null and inspectionId != ''">
  273. and t.inspection_id= #{inspectionId}
  274. </if>
  275. <if test="machineCode !=null and machineCode != ''">
  276. and m.machine_code= #{machineCode}
  277. </if>
  278. <if test="remark !=null and remark != ''">
  279. and t.remark= #{remark}
  280. </if>
  281. <if test="statusCd !=null and statusCd != ''">
  282. and t.status_cd= #{statusCd}
  283. </if>
  284. <if test="inspectionName !=null and inspectionName != ''">
  285. and t.inspection_name like concat('%',#{inspectionName},'%')
  286. </if>
  287. <if test="communityId !=null and communityId != ''">
  288. and t.community_id= #{communityId}
  289. </if>
  290. <if test="bId !=null and bId != ''">
  291. and t.b_id= #{bId}
  292. </if>
  293. group by t.inspection_id
  294. order by t.create_time desc
  295. </select>
  296. </mapper>