CheckDefMapper.xml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  4. <mapper namespace="com.zhyc.xps.aqpt.mapper.CheckDefMapper">
  5. <resultMap id="CheckDefDtoMap" type="com.zhyc.xps.aqpt.dto.CheckDefDto">
  6. <result column="oc_id" property="ocId" jdbcType="BIGINT" /><!--ID-->
  7. <result column="oc_name" property="ocName" jdbcType="VARCHAR" />
  8. <result column="risk_point_id" property="riskPointId" jdbcType="BIGINT" /><!--risk point ID-->
  9. <result column="risk_point_title" property="riskPointTitle" jdbcType="VARCHAR" />
  10. <result column="check_def_id" property="checkDefId" jdbcType="BIGINT" /><!--ID-->
  11. <result column="check_cat_id" property="checkCatId" jdbcType="BIGINT" />
  12. <result column="check_cat_title" property="checkCatTitle" jdbcType="VARCHAR" />
  13. <result column="check_title" property="checkTitle" jdbcType="VARCHAR" />
  14. <result column="check_desc" property="checkDesc" jdbcType="VARCHAR" />
  15. <result column="checklist_id" property="checklistId" jdbcType="BIGINT" />
  16. <result column="checklist_title" property="checklistTitle" jdbcType="VARCHAR" />
  17. <result column="group_id" property="groupId" jdbcType="BIGINT" />
  18. <result column="group_name" property="groupName" jdbcType="VARCHAR" />
  19. <result column="position_id" property="positionId" jdbcType="BIGINT" />
  20. <result column="position_name" property="positionName" jdbcType="VARCHAR" />
  21. <result column="account_id" property="accountId" jdbcType="BIGINT" />
  22. <result column="account_name" property="accountName" jdbcType="VARCHAR" />
  23. <result column="check_count" property="checkCount" jdbcType="BIGINT" />
  24. <result column="def_start_date" property="defStartDate" jdbcType="DATE" />
  25. <result column="def_end_date" property="defEndDate" jdbcType="DATE" />
  26. <result column="is_shared" property="isShared" jdbcType="BIGINT" />
  27. <result column="status" property="status" jdbcType="BIGINT" />
  28. <result column="job_id" property="jobId" jdbcType="BIGINT" />
  29. <result column="cycle_title" property="cycleTitle" jdbcType="VARCHAR" />
  30. <result column="last_cycle_start_time" property="lastCycleStartTime" jdbcType="TIMESTAMP"/>
  31. <result column="last_cycle_end_time" property="lastCycleEndTime" jdbcType="TIMESTAMP"/>
  32. </resultMap>
  33. <sql id="CheckDefDto_Cols">
  34. A.oc_id,
  35. O.oc_name,
  36. A.risk_point_id,
  37. D.risk_point_title,
  38. A.check_def_id,
  39. A.check_cat_id,
  40. B.check_cat_title,
  41. A.check_desc,
  42. A.check_title,
  43. A.checklist_id,
  44. C.checklist_title,
  45. A.group_id,
  46. A.group_name,
  47. A.position_id,
  48. A.position_name,
  49. A.account_id,
  50. A.account_name,
  51. A.check_count,
  52. A.def_start_date,
  53. A.def_end_date,
  54. A.is_shared,
  55. A.status,
  56. A.job_id,
  57. J.cycle_title,
  58. A.last_cycle_start_time,
  59. A.last_cycle_end_time
  60. </sql>
  61. <!--基于ID查询-->
  62. <select id="getById" resultMap="CheckDefDtoMap">
  63. SELECT
  64. <include refid="CheckDefDto_Cols"/>
  65. FROM check_def AS A
  66. LEFT JOIN check_cat AS B ON (A.oc_id = B.oc_id AND A.check_cat_id = B.check_cat_id)
  67. LEFT JOIN checklist AS C ON (A.oc_id = C.oc_id AND A.checklist_id = C.checklist_id)
  68. LEFT JOIN ent_risk_point AS D ON (A.oc_id = D.oc_id AND A.risk_point_id = D.risk_point_id)
  69. LEFT JOIN job AS J ON (A.job_id = J.job_id)
  70. LEFT JOIN oc AS O ON (A.oc_id = O.oc_id)
  71. WHERE A.oc_id = #{ocId ,jdbcType=BIGINT}
  72. AND A.risk_point_id = #{riskPointId ,jdbcType=BIGINT}
  73. AND A.check_def_id = #{checkDefId ,jdbcType=BIGINT}
  74. </select>
  75. <!--列表查询-->
  76. <select id="getByList" parameterType="java.util.Map" resultMap="CheckDefDtoMap">
  77. SELECT
  78. <include refid="CheckDefDto_Cols"/>
  79. FROM check_def AS A
  80. LEFT JOIN check_cat AS B ON (A.oc_id = B.oc_id AND A.check_cat_id = B.check_cat_id)
  81. LEFT JOIN checklist AS C ON (A.oc_id = C.oc_id AND A.checklist_id = C.checklist_id)
  82. LEFT JOIN ent_risk_point AS D ON (A.oc_id = D.oc_id AND A.risk_point_id = D.risk_point_id)
  83. LEFT JOIN job AS J ON (A.job_id = J.job_id)
  84. LEFT JOIN oc AS O ON (A.oc_id = O.oc_id)
  85. WHERE A.deleted_flag = 0
  86. <if test="ocId != null">
  87. AND A.oc_id = #{ocId, jdbcType=BIGINT}
  88. </if>
  89. <if test="riskPointId !=null">
  90. AND A.risk_point_id = #{riskPointId ,jdbcType=BIGINT}
  91. </if>
  92. <if test="checkCatId != null">
  93. AND A.check_cat_id = #{checkCatId, jdbcType=BIGINT}
  94. </if>
  95. <if test="checklistId != null">
  96. AND A.checklist_id = #{checkListId, jdbcType=BIGINT}
  97. </if>
  98. <if test="keywords != null and keywords != ''">
  99. AND A.check_title like "%"#{keywords}"%"
  100. </if>
  101. <if test="checkTypeId != null">
  102. AND A.check_type_id = #{checkTypeId ,jdbcType=BIGINT}
  103. </if>
  104. <if test="jobId != null">
  105. AND A.job_id = #{jobId,jdbcType=BIGINT}
  106. </if>
  107. <if test="isShared != null">
  108. AND A.is_shared = #{isShared ,jdbcType=BIGINT}
  109. </if>
  110. <if test="status != null">
  111. AND A.status = #{status ,jdbcType=BIGINT}
  112. </if>
  113. ORDER BY A.created_at DESC
  114. </select>
  115. <!--分页查询-->
  116. <select id="getByPage" parameterType="java.util.Map" resultMap="CheckDefDtoMap">
  117. SELECT
  118. <include refid="CheckDefDto_Cols"/>
  119. FROM check_def AS A
  120. LEFT JOIN check_cat AS B ON (A.oc_id = B.oc_id AND A.check_cat_id = B.check_cat_id)
  121. LEFT JOIN checklist AS C ON (A.oc_id = C.oc_id AND A.checklist_id = C.checklist_id)
  122. LEFT JOIN ent_risk_point AS D ON (A.oc_id = D.oc_id AND A.risk_point_id = D.risk_point_id)
  123. LEFT JOIN job AS J ON (A.job_id = J.job_id)
  124. LEFT JOIN oc AS O ON (A.oc_id = O.oc_id)
  125. WHERE A.deleted_flag = 0
  126. <if test="ocId != null">
  127. AND A.oc_id = #{ocId, jdbcType=BIGINT}
  128. </if>
  129. <if test="riskPointId !=null">
  130. AND A.risk_point_id = #{riskPointId ,jdbcType=BIGINT}
  131. </if>
  132. <if test="checkCatId != null">
  133. AND A.check_cat_id = #{checkCatId, jdbcType=BIGINT}
  134. </if>
  135. <if test="keywords != null and keywords != ''">
  136. AND A.check_title like "%"#{keywords}"%"
  137. </if>
  138. <if test="checkTypeId != null">
  139. AND A.check_type_id = #{checkTypeId ,jdbcType=BIGINT}
  140. </if>
  141. <if test="checkLevelId != null">
  142. AND A.check_level_id = #{checkLevelId ,jdbcType=BIGINT}
  143. </if>
  144. <if test="checklistId != null">
  145. AND A.checklist_id = #{checkListId, jdbcType=BIGINT}
  146. </if>
  147. <if test="isShared != null">
  148. AND A.is_shared = #{isShared ,jdbcType=BIGINT}
  149. </if>
  150. <if test="jobId != null">
  151. AND A.job_id = #{jobId,jdbcType=BIGINT}
  152. </if>
  153. <if test="status != null">
  154. AND A.status = #{status ,jdbcType=BIGINT}
  155. </if>
  156. ORDER BY A.created_at DESC
  157. </select>
  158. <!--Create-->
  159. <insert id="create" parameterType="com.zhyc.xps.aqpt.entity.CheckDef">
  160. INSERT INTO check_def
  161. <trim prefix="(" suffix=")" suffixOverrides=",">
  162. <if test="ocId != null">
  163. oc_id,
  164. </if>
  165. <if test="riskPointId != null">
  166. risk_point_id,
  167. </if>
  168. <if test="checkDefId != null">
  169. check_def_id,
  170. </if>
  171. <if test="checkCatId != null">
  172. check_cat_id,
  173. </if>
  174. <if test="checkTitle != null and checkTitle!=''">
  175. check_title,
  176. </if>
  177. <if test="checkDesc != null and checkDesc != ''">
  178. check_desc,
  179. </if>
  180. <if test="checklistId != null">
  181. checklist_id,
  182. </if>
  183. <if test="groupId != null">
  184. group_id,
  185. </if>
  186. <if test="groupName != null and groupName!=''">
  187. group_name,
  188. </if>
  189. <if test="positionId != null">
  190. position_id,
  191. </if>
  192. <if test="positionName != null and positionName!=''">
  193. position_name,
  194. </if>
  195. <if test="accountId != null">
  196. account_id,
  197. </if>
  198. <if test="accountName != null and accountName!=''">
  199. account_name,
  200. </if>
  201. <if test="checkCount != null">
  202. check_count,
  203. </if>
  204. <if test="defStartDate != null">
  205. def_start_date,
  206. </if>
  207. <if test="defEndDate != null">
  208. def_end_date,
  209. </if>
  210. <if test="isShared != null">
  211. is_shared,
  212. </if>
  213. <if test="status != null">
  214. status,
  215. </if>
  216. <if test="jobId != null">
  217. job_id,
  218. </if>
  219. <if test="createdBy != null">
  220. created_by,
  221. </if>
  222. <if test="createdAt != null">
  223. created_at,
  224. </if>
  225. </trim>
  226. <trim prefix="values (" suffix=")" suffixOverrides=",">
  227. <if test="ocId != null">
  228. #{ocId ,jdbcType=BIGINT},
  229. </if>
  230. <if test="riskPointId != null">
  231. #{riskPointId ,jdbcType=BIGINT},
  232. </if>
  233. <if test="checkDefId != null">
  234. #{checkDefId ,jdbcType=BIGINT},
  235. </if>
  236. <if test="checkCatId != null">
  237. #{checkCatId ,jdbcType=BIGINT},
  238. </if>
  239. <if test="checkTitle != null and checkTitle!=''">
  240. #{checkTitle, jdbcType=VARCHAR},
  241. </if>
  242. <if test="checkDesc != null and checkDesc != ''">
  243. #{checkDesc, jdbcType=VARCHAR},
  244. </if>
  245. <if test="checklistId != null">
  246. #{checklistId, jdbcType=BIGINT},
  247. </if>
  248. <if test="groupId != null">
  249. #{groupId, jdbcType=BIGINT},
  250. </if>
  251. <if test="groupName != null and groupName!=''">
  252. #{groupName, jdbcType=VARCHAR},
  253. </if>
  254. <if test="positionId != null">
  255. #{positionId, jdbcType=BIGINT},
  256. </if>
  257. <if test="positionName != null and positionName!=''">
  258. #{positionName ,jdbcType=VARCHAR},
  259. </if>
  260. <if test="accountId != null">
  261. #{accountId, jdbcType=BIGINT},
  262. </if>
  263. <if test="accountName != null and accountName!=''">
  264. #{accountName, jdbcType=VARCHAR},
  265. </if>
  266. <if test="checkCount != null">
  267. #{checkCount ,jdbcType=INTEGER},
  268. </if>
  269. <if test="defStartDate != null">
  270. #{defStartDate ,jdbcType=DATE},
  271. </if>
  272. <if test="defEndDate != null">
  273. #{defEndDate ,jdbcType=DATE},
  274. </if>
  275. <if test="isShared != null">
  276. #{isShared ,jdbcType=BIGINT},
  277. </if>
  278. <if test="status != null">
  279. #{status ,jdbcType=BIGINT},
  280. </if>
  281. <if test="jobId != null">
  282. #{jobId ,jdbcType=BIGINT},
  283. </if>
  284. <if test="createdBy != null">
  285. #{createdBy ,jdbcType=BIGINT},
  286. </if>
  287. <if test="createdAt != null">
  288. #{createdAt ,jdbcType=TIMESTAMP},
  289. </if>
  290. </trim>
  291. </insert>
  292. <!--更新-->
  293. <update id="update" parameterType="com.zhyc.xps.aqpt.entity.CheckDef">
  294. UPDATE check_def
  295. <trim suffixOverrides=",">
  296. <set>
  297. <if test="checkCatId != null">
  298. check_cat_id = #{checkCatId ,jdbcType=BIGINT},
  299. </if>
  300. <if test="checkTitle != null">
  301. check_title =#{checkTitle ,jdbcType=VARCHAR},
  302. </if>
  303. <if test="checkDesc != null and checkDesc != ''">
  304. check_desc = #{checkDesc ,jdbcType=VARCHAR},
  305. </if>
  306. <if test="checklistId != null">
  307. checklist_id = #{checklistId ,jdbcType=BIGINT},
  308. </if>
  309. <if test="groupId != null">
  310. group_id = #{groupId ,jdbcType=BIGINT},
  311. </if>
  312. <if test="groupName != null and groupName!=''">
  313. group_name = #{groupName, jdbcType=VARCHAR},
  314. </if>
  315. <if test="positionId != null">
  316. position_id = #{positionId ,jdbcType=BIGINT},
  317. </if>
  318. <if test="positionName != null and positionName!=''">
  319. position_name = #{positionName ,jdbcType=VARCHAR},
  320. </if>
  321. <if test="accountId != null">
  322. account_id = #{accountId ,jdbcType=BIGINT},
  323. </if>
  324. <if test="accountName != null and accountName!=''">
  325. account_name = #{accountName, jdbcType=VARCHAR},
  326. </if>
  327. <if test="checkCount != null">
  328. check_count = #{checkCount ,jdbcType=INTEGER},
  329. </if>
  330. <if test="defStartDate != null">
  331. def_start_date = #{defStartDate ,jdbcType=DATE},
  332. </if>
  333. <if test="defEndDate != null">
  334. def_end_date = #{defEndDate ,jdbcType=DATE},
  335. </if>
  336. <if test="isShared != null">
  337. is_shared = #{isShared ,jdbcType=BIGINT},
  338. </if>
  339. <if test="status != null">
  340. status = #{status ,jdbcType=BIGINT},
  341. </if>
  342. <if test="jobId != null">
  343. job_id = #{jobId ,jdbcType=BIGINT},
  344. </if>
  345. <if test="lastCycleStartTime != null">
  346. last_cycle_start_time = #{lastCycleStartTime ,jdbcType=TIMESTAMP},
  347. </if>
  348. <if test="lastCycleEndTime != null">
  349. last_cycle_end_time = #{lastCycleEndTime ,jdbcType=TIMESTAMP},
  350. </if>
  351. <if test="updatedBy != null">
  352. updated_by = #{updatedBy ,jdbcType=BIGINT},
  353. </if>
  354. <if test="updatedAt != null">
  355. updated_at = #{updatedAt ,jdbcType=TIMESTAMP},
  356. </if>
  357. </set>
  358. </trim>
  359. WHERE oc_id = #{ocId ,jdbcType=BIGINT}
  360. AND risk_point_id = #{riskPointId ,jdbcType=BIGINT}
  361. AND check_def_id = #{checkDefId ,jdbcType=BIGINT}
  362. </update>
  363. <!--更新Last Cycle Time-->
  364. <update id="updateLastCycleTime">
  365. UPDATE check_def
  366. <trim suffixOverrides=",">
  367. <set>
  368. <if test="lastCycleStartTime != null">
  369. last_cycle_start_time = #{lastCycleStartTime ,jdbcType=TIMESTAMP},
  370. </if>
  371. <if test="lastCycleEndTime != null">
  372. last_cycle_end_time = #{lastCycleEndTime ,jdbcType=TIMESTAMP},
  373. </if>
  374. </set>
  375. </trim>
  376. WHERE deleted_flag = 0
  377. <if test="ocId != null">
  378. AND oc_id = #{ocId,jdbcType=BIGINT}
  379. </if>
  380. <if test="riskPointId != null">
  381. AND risk_point_id = #{riskPointId ,jdbcType=BIGINT}
  382. </if>
  383. <if test="checkDefId != null ">
  384. AND check_def_id = #{checkDefId ,jdbcType=BIGINT}
  385. </if>
  386. </update>
  387. <!--删除 -->
  388. <update id="delete" parameterType="java.util.Map">
  389. UPDATE check_def
  390. <trim suffixOverrides=",">
  391. <set>
  392. <if test="deletedBy != null">
  393. deleted_by = #{deletedBy ,jdbcType=BIGINT},
  394. </if>
  395. <if test="deletedAt != null">
  396. deleted_at = #{deletedAt ,jdbcType=DATE},
  397. </if>
  398. <if test="deletedFlag != null">
  399. deleted_flag = #{deletedFlag ,jdbcType=BIGINT},
  400. </if>
  401. </set>
  402. </trim>
  403. WHERE deleted_flag = 0
  404. <if test="ocId != null">
  405. AND oc_id = #{ocId,jdbcType=BIGINT}
  406. </if>
  407. <if test="riskPointId != null">
  408. AND risk_point_id = #{riskPointId ,jdbcType=BIGINT}
  409. </if>
  410. <if test="checkDefId != null ">
  411. AND check_def_id = #{checkDefId ,jdbcType=BIGINT}
  412. </if>
  413. </update>
  414. <!--列表查询-->
  415. <select id="getPendingByList" parameterType="java.util.Map" resultMap="CheckDefDtoMap">
  416. SELECT
  417. <include refid="CheckDefDto_Cols"/>
  418. FROM check_def AS A
  419. LEFT JOIN check_cat AS B ON (A.oc_id = B.oc_id AND A.check_cat_id = B.check_cat_id )
  420. LEFT JOIN checklist AS C ON (A.oc_id = C.oc_id AND A.checklist_id = C.checklist_id )
  421. LEFT JOIN ent_risk_point AS D ON (A.oc_id = D.oc_id AND A.risk_point_id = D.risk_point_id)
  422. LEFT JOIN job AS J ON (A.job_id = J.job_id)
  423. LEFT JOIN oc AS O ON (A.oc_id = O.oc_id)
  424. WHERE A.deleted_flag = 0 AND A.status = 1
  425. <![CDATA[
  426. AND (A.last_cycle_end_time <= now() OR A.last_cycle_end_time is null)
  427. AND (A.def_end_date >= DATE_FORMAT(NOW(),'%Y-%m-%d'))
  428. ]]>
  429. <if test="jobId != null">
  430. AND A.job_id = #{jobId,jdbcType=BIGINT}
  431. </if>
  432. ORDER BY A.check_def_id
  433. </select>
  434. </mapper>