InspectionServiceDaoImplMapper.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  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. from inspection_point t
  182. 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}
  183. where 1 =1
  184. <if test="relationship != null and relationship == 1">
  185. and c.inspection_id is not null
  186. </if>
  187. <if test="relationship != null and relationship == 0">
  188. and c.inspection_id is null
  189. </if>
  190. <if test="inspectionId !=null and inspectionId != ''">
  191. and t.inspection_id= #{inspectionId}
  192. </if>
  193. <if test="pointObjType !=null and pointObjType != ''">
  194. and t.point_obj_type= #{pointObjType}
  195. </if>
  196. <if test="remark !=null and remark != ''">
  197. and t.remark= #{remark}
  198. </if>
  199. <if test="statusCd !=null and statusCd != ''">
  200. and t.status_cd= #{statusCd}
  201. </if>
  202. <if test="inspectionName !=null and inspectionName != ''">
  203. and t.inspection_name like concat('%',#{inspectionName},'%')
  204. </if>
  205. <if test="communityId !=null and communityId != ''">
  206. and t.community_id= #{communityId}
  207. </if>
  208. <if test="bId !=null and bId != ''">
  209. and t.b_id= #{bId}
  210. </if>
  211. order by t.create_time desc
  212. <if test="page != -1 and page != null ">
  213. limit #{page}, #{row}
  214. </if>
  215. </select>
  216. <!-- 查询巡检点数量 add by wuxw 2018-07-03 -->
  217. <select id="queryInspectionsRelationShipCount" parameterType="Map" resultType="Map">
  218. select count(1) count
  219. from inspection_point t
  220. 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}
  221. where 1 =1
  222. <if test="relationship != null and relationship == 1">
  223. and c.inspection_id is not null
  224. </if>
  225. <if test="relationship != null and relationship == 0">
  226. and c.inspection_id is null
  227. </if>
  228. <if test="inspectionId !=null and inspectionId != ''">
  229. and t.inspection_id= #{inspectionId}
  230. </if>
  231. <if test="pointObjType !=null and pointObjType != ''">
  232. and t.point_obj_type= #{pointObjType}
  233. </if>
  234. <if test="remark !=null and remark != ''">
  235. and t.remark= #{remark}
  236. </if>
  237. <if test="statusCd !=null and statusCd != ''">
  238. and t.status_cd= #{statusCd}
  239. </if>
  240. <if test="inspectionName !=null and inspectionName != ''">
  241. and t.inspection_name like concat('%',#{inspectionName},'%')
  242. </if>
  243. <if test="communityId !=null and communityId != ''">
  244. and t.community_id= #{communityId}
  245. </if>
  246. <if test="bId !=null and bId != ''">
  247. and t.b_id= #{bId}
  248. </if>
  249. </select>
  250. <!-- 查询巡检点信息 add by wuxw 2018-07-03 -->
  251. <select id="queryInspectionsByPlan" parameterType="Map" resultType="Map">
  252. select
  253. t.inspection_id,t.inspection_id inspectionId,t.machine_id,
  254. t.machine_id machineId,t.remark,t.status_cd,t.status_cd statusCd,
  255. t.inspection_name,t.inspection_name inspectionName,t.community_id,
  256. t.community_id communityId,t.b_id,t.b_id bId,
  257. m.machine_code machineCode,m.machine_name machineName,location_type_cd locationTypeCd,location_obj_id
  258. locationObjId,m.machine_id machineId,
  259. d.name locationTypeName
  260. from inspection_point t,machine m,t_dict d,inspection_route_point_rel c,inspection_plan ip
  261. where 1 =1
  262. and t.machine_id = m.machine_id
  263. and m.status_cd = 0
  264. and d.status_cd = m.location_type_cd
  265. and d.table_name = 'machine'
  266. and d.table_columns = 'location_type_cd'
  267. and t.inspection_id = c.inspection_id
  268. and c.status_cd = '0'
  269. and c.inspection_route_id = ip.inspection_route_id
  270. and ip.inspection_plan_id = #{inspectionPlanId}
  271. <if test="inspectionId !=null and inspectionId != ''">
  272. and t.inspection_id= #{inspectionId}
  273. </if>
  274. <if test="machineCode !=null and machineCode != ''">
  275. and m.machine_code= #{machineCode}
  276. </if>
  277. <if test="remark !=null and remark != ''">
  278. and t.remark= #{remark}
  279. </if>
  280. <if test="statusCd !=null and statusCd != ''">
  281. and t.status_cd= #{statusCd}
  282. </if>
  283. <if test="inspectionName !=null and inspectionName != ''">
  284. and t.inspection_name like concat('%',#{inspectionName},'%')
  285. </if>
  286. <if test="communityId !=null and communityId != ''">
  287. and t.community_id= #{communityId}
  288. </if>
  289. <if test="bId !=null and bId != ''">
  290. and t.b_id= #{bId}
  291. </if>
  292. group by t.inspection_id
  293. order by t.create_time desc
  294. </select>
  295. </mapper>