BaseSafetyToolMapper.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  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.railway.business.safetool.mapper.BaseSafetyToolMapper">
  5. <resultMap id="BaseResultMap" type="com.railway.business.safetool.domain.BaseSafetyTool">
  6. <result column="tool_id" property="toolId"/>
  7. <result column="dept_id" property="deptId"/>
  8. <result column="dept_name" property="deptName"/>
  9. <result column="store_place" property="storePlace"/>
  10. <result column="tool_name" property="toolName"/>
  11. <result column="tool_type" property="toolType"/>
  12. <result column="tool_code" property="toolCode"/>
  13. <result column="tool_qcode" property="toolQcode"/>
  14. <result column="qcode_url" property="qcodeUrl"/>
  15. <result column="elec_level" property="elecLevel"/>
  16. <result column="unit" property="unit"/>
  17. <result column="test_cycle" property="testCycle"/>
  18. <result column="test_cycle_text" property="testCycleText"/>
  19. <result column="last_test_date" property="lastTestDate"/>
  20. <result column="next_test_date" property="nextTestDate"/>
  21. <result column="test_result" property="testResult"/>
  22. <result column="test_date" property="testDate"/>
  23. <result column="test_result_desc" property="testResultDesc"/>
  24. <result column="state" property="state"/>
  25. <result column="scrap_reason" property="scrapReason"/>
  26. <result column="scrap_date" property="scrapDate"/>
  27. <result column="scrap_user" property="scrapUser"/>
  28. <result column="replace_tool_id" property="replaceToolId"/>
  29. <result column="produce_factory" property="produceFactory"/>
  30. <result column="produce_date" property="produceDate"/>
  31. <result column="remark" property="remark"/>
  32. <result column="del_flag" property="delFlag"/>
  33. <result column="create_by" property="createBy"/>
  34. <result column="create_time" property="createTime"/>
  35. <result column="update_by" property="updateBy"/>
  36. <result column="update_time" property="updateTime"/>
  37. </resultMap>
  38. <sql id="Base_Column_List">
  39. t.tool_id,
  40. t.dept_id,
  41. t.store_place,
  42. t.tool_type,
  43. t.tool_code,
  44. t.tool_qcode,
  45. t.qcode_url,
  46. t.elec_level,
  47. t.test_cycle,
  48. t.unit,
  49. t.last_test_date,
  50. t.next_test_date,
  51. t.test_result,
  52. t.test_date,
  53. t.test_result_desc,
  54. t.state,
  55. t.scrap_reason,
  56. t.scrap_date,
  57. t.scrap_user,
  58. t.replace_tool_id,
  59. t.produce_factory,
  60. t.produce_date,
  61. t.remark,
  62. t.del_flag,
  63. t.create_by,
  64. t.create_time,
  65. t.update_by,
  66. t.update_time
  67. </sql>
  68. <insert id="insert" parameterType="com.railway.business.safetool.domain.BaseSafetyTool"
  69. useGeneratedKeys="true" keyProperty="toolId">
  70. INSERT INTO base_safety_tool
  71. <trim prefix="(" suffix=")" suffixOverrides=",">
  72. <if test='null != deptId'>
  73. dept_id,
  74. </if>
  75. <if test='null != storePlace'>
  76. store_place,
  77. </if>
  78. <if test='null != toolName'>
  79. tool_name,
  80. </if>
  81. <if test='null != toolType'>
  82. tool_type,
  83. </if>
  84. <if test='null != toolCode'>
  85. tool_code,
  86. </if>
  87. <if test='null != toolQcode'>
  88. tool_qcode,
  89. </if>
  90. <if test='null != qcodeUrl'>
  91. qcode_url,
  92. </if>
  93. <if test='null != elecLevel'>
  94. elec_level,
  95. </if>
  96. <if test='null != unit'>
  97. unit,
  98. </if>
  99. <if test='null != testCycle'>
  100. test_cycle,
  101. </if>
  102. <if test='null != lastTestDate'>
  103. last_test_date,
  104. </if>
  105. <if test='null != nextTestDate'>
  106. next_test_date,
  107. </if>
  108. <if test='null != testResult'>
  109. test_result,
  110. </if>
  111. <if test='null != testDate'>
  112. test_date,
  113. </if>
  114. <if test='null != testResultDesc'>
  115. test_result_desc,
  116. </if>
  117. <if test='null != state'>
  118. state,
  119. </if>
  120. <if test='null != scrapReason'>
  121. scrap_reason,
  122. </if>
  123. <if test='null != scrapDate'>
  124. scrap_date,
  125. </if>
  126. <if test='null != scrapUser'>
  127. scrap_user,
  128. </if>
  129. <if test='null != replaceToolId'>
  130. replace_tool_id,
  131. </if>
  132. <if test='null != produceFactory'>
  133. produce_factory,
  134. </if>
  135. <if test='null != produceDate'>
  136. produce_date,
  137. </if>
  138. <if test='null != remark'>
  139. remark,
  140. </if>
  141. <if test='null != delFlag'>
  142. del_flag,
  143. </if>
  144. <if test='null != createBy'>
  145. create_by,
  146. </if>
  147. <if test='null != createTime'>
  148. create_time,
  149. </if>
  150. <if test='null != updateBy'>
  151. update_by,
  152. </if>
  153. <if test='null != updateTime'>
  154. update_time
  155. </if>
  156. </trim>
  157. <trim prefix="values (" suffix=")" suffixOverrides=",">
  158. <if test='null != deptId'>
  159. #{deptId},
  160. </if>
  161. <if test='null != storePlace'>
  162. #{storePlace},
  163. </if>
  164. <if test='null != toolName'>
  165. #{toolName},
  166. </if>
  167. <if test='null != toolType'>
  168. #{toolType},
  169. </if>
  170. <if test='null != toolCode'>
  171. #{toolCode},
  172. </if>
  173. <if test='null != toolQcode'>
  174. #{toolQcode},
  175. </if>
  176. <if test='null != qcodeUrl'>
  177. #{qcodeUrl},
  178. </if>
  179. <if test='null != elecLevel'>
  180. #{elecLevel},
  181. </if>
  182. <if test='null != unit'>
  183. #{unit},
  184. </if>
  185. <if test='null != testCycle'>
  186. #{testCycle},
  187. </if>
  188. <if test='null != lastTestDate'>
  189. #{lastTestDate},
  190. </if>
  191. <if test='null != nextTestDate'>
  192. #{nextTestDate},
  193. </if>
  194. <if test='null != testResult'>
  195. #{testResult},
  196. </if>
  197. <if test='null != testDate'>
  198. #{testDate},
  199. </if>
  200. <if test='null != testResultDesc'>
  201. #{testResultDesc},
  202. </if>
  203. <if test='null != state'>
  204. #{state},
  205. </if>
  206. <if test='null != scrapReason'>
  207. #{scrapReason},
  208. </if>
  209. <if test='null != scrapDate'>
  210. #{scrapDate},
  211. </if>
  212. <if test='null != scrapUser'>
  213. #{scrapUser},
  214. </if>
  215. <if test='null != replaceToolId'>
  216. #{replaceToolId},
  217. </if>
  218. <if test='null != produceFactory'>
  219. #{produceFactory},
  220. </if>
  221. <if test='null != produceDate'>
  222. #{produceDate},
  223. </if>
  224. <if test='null != remark'>
  225. #{remark},
  226. </if>
  227. <if test='null != delFlag'>
  228. #{delFlag},
  229. </if>
  230. <if test='null != createBy'>
  231. #{createBy},
  232. </if>
  233. <if test='null != createTime'>
  234. #{createTime},
  235. </if>
  236. <if test='null != updateBy'>
  237. #{updateBy},
  238. </if>
  239. <if test='null != updateTime'>
  240. #{updateTime}
  241. </if>
  242. </trim>
  243. </insert>
  244. <delete id="delete">
  245. UPDATE base_safety_tool
  246. set del_flag='1'
  247. WHERE tool_id = #{toolId}
  248. </delete>
  249. <update id="update" parameterType="com.railway.business.safetool.domain.BaseSafetyTool">
  250. UPDATE base_safety_tool
  251. <set>
  252. <if test='null != deptId'>dept_id = #{deptId},</if>
  253. <if test='null != storePlace'>store_place = #{storePlace},</if>
  254. <if test='null != toolName'>tool_name = #{toolName},</if>
  255. <if test='null != toolType'>tool_type = #{toolType},</if>
  256. <if test='null != toolCode'>tool_code = #{toolCode},</if>
  257. <if test='null != toolQcode'>tool_qcode = #{toolQcode},</if>
  258. <if test='null != qcodeUrl'>qcode_url = #{qcodeUrl},</if>
  259. <if test='null != elecLevel'>elec_level = #{elecLevel},</if>
  260. <if test='null != unit'>unit = #{unit},</if>
  261. <if test='null != testCycle'>test_cycle = #{testCycle},</if>
  262. <if test='null != lastTestDate'>last_test_date = #{lastTestDate},</if>
  263. <if test='null != nextTestDate'>next_test_date = #{nextTestDate},</if>
  264. <if test='null != testResult'>test_result = #{testResult},</if>
  265. <if test='null != testDate'>test_date = #{testDate},</if>
  266. <if test='null != testResultDesc'>test_result_desc = #{testResultDesc},</if>
  267. <if test='null != state'>state = #{state},</if>
  268. <if test='null != scrapReason'>scrap_reason = #{scrapReason},</if>
  269. <if test='null != scrapDate'>scrap_date = #{scrapDate},</if>
  270. <if test='null != scrapUser'>scrap_user = #{scrapUser},</if>
  271. <if test='null != replaceToolId'>replace_tool_id = #{replaceToolId},</if>
  272. <if test='null != produceFactory'>produce_factory = #{produceFactory},</if>
  273. <if test='null != produceDate'>produce_date = #{produceDate},</if>
  274. <if test='null != remark'>remark = #{remark},</if>
  275. <if test='null != delFlag'>del_flag = #{delFlag},</if>
  276. <if test='null != createBy'>create_by = #{createBy},</if>
  277. <if test='null != createTime'>create_time = #{createTime},</if>
  278. <if test='null != updateBy'>update_by = #{updateBy},</if>
  279. <if test='null != updateTime'>update_time = #{updateTime}</if>
  280. </set>
  281. WHERE tool_id = #{toolId}
  282. </update>
  283. <select id="getInfo" resultMap="BaseResultMap">
  284. SELECT
  285. <include refid="Base_Column_List"/>,
  286. d.dept_name,
  287. dt1.dict_label as tool_name,
  288. dt2.dict_label as test_cycle_text
  289. FROM base_safety_tool t
  290. LEFT JOIN sys_dept d on t.dept_id = d.dept_id
  291. LEFT JOIN sys_dict_data dt1 ON (t.tool_type = dt1.dict_value AND dt1.dict_type = 'tool_type')
  292. LEFT JOIN sys_dict_data dt2 ON (t.test_cycle = dt2.dict_value AND dt2.dict_type = 'test_cycle')
  293. WHERE t.del_flag='0' and t.tool_id = #{toolId}
  294. </select>
  295. <select id="getInfoByQcode" resultMap="BaseResultMap">
  296. SELECT
  297. <include refid="Base_Column_List"/>,
  298. d.dept_name,
  299. dt1.dict_label as tool_name,
  300. dt2.dict_label as test_cycle_text
  301. FROM base_safety_tool t
  302. LEFT JOIN sys_dept d on t.dept_id = d.dept_id
  303. LEFT JOIN sys_dict_data dt1 ON (t.tool_type = dt1.dict_value AND dt1.dict_type = 'tool_type')
  304. LEFT JOIN sys_dict_data dt2 ON (t.test_cycle = dt2.dict_value AND dt2.dict_type = 'test_cycle')
  305. WHERE t.del_flag='0' and t.tool_qcode = #{qcode}
  306. </select>
  307. <select id="getList" resultMap="BaseResultMap">
  308. SELECT
  309. <include refid="Base_Column_List"/>,
  310. d.dept_name,
  311. dt1.dict_label as tool_name,
  312. dt2.dict_label as test_cycle_text
  313. FROM base_safety_tool t
  314. LEFT JOIN sys_dept d on t.dept_id = d.dept_id
  315. LEFT JOIN sys_dict_data dt1 ON (t.tool_type = dt1.dict_value AND dt1.dict_type = 'tool_type')
  316. LEFT JOIN sys_dict_data dt2 ON (t.test_cycle = dt2.dict_value AND dt2.dict_type = 'test_cycle')
  317. <where>
  318. t.del_flag='0'
  319. <if test="deptId!=null and deptId!=''">
  320. and t.dept_id=#{deptId}
  321. </if>
  322. <if test="storePlace!=null and storePlace!=''">
  323. and t.store_place=#{storePlace}
  324. </if>
  325. <if test="toolName!=null and toolName!=''">
  326. and t.tool_name=#{toolName}
  327. </if>
  328. <if test="toolType!=null and toolType!=''">
  329. and t.tool_type=#{toolType}
  330. </if>
  331. <if test="toolCode!=null and toolCode!=''">
  332. and t.tool_code=#{toolCode}
  333. </if>
  334. <if test="elecLevel!=null and elecLevel!=''">
  335. and t.elec_level=#{elecLevel}
  336. </if>
  337. <if test="searchValue != null and searchValue != ''">
  338. AND (
  339. t.tool_name like concat('%', #{searchValue}, '%')
  340. OR t.tool_code like concat('%', #{searchValue}, '%')
  341. OR d.dept_name like concat('%', #{searchValue}, '%')
  342. OR t.store_place like concat('%', #{searchValue}, '%')
  343. )
  344. </if>
  345. <if test="testCycle!=null and testCycle!=''">
  346. and t.test_cycle=#{testCycle}
  347. </if>
  348. <if test="lastTestDate!=null">
  349. and t.last_test_date=#{lastTestDate}
  350. </if>
  351. <if test="nextTestDate!=null">
  352. and t.next_test_date=#{nextTestDate}
  353. </if>
  354. <if test="testResult!=null and testResult!=''">
  355. and t.test_result=#{testResult}
  356. </if>
  357. <if test="testDate!=null">
  358. and t.test_date=#{testDate}
  359. </if>
  360. <if test="testResultDesc!=null and testResultDesc!=''">
  361. and t.test_result_desc=#{testResultDesc}
  362. </if>
  363. <if test="state!=null and state!=''">
  364. and t.state=#{state}
  365. </if>
  366. <if test="scrapReason!=null and scrapReason!=''">
  367. and t.scrap_reason=#{scrapReason}
  368. </if>
  369. <if test="scrapDate!=null and scrapDate!=''">
  370. and t.scrap_date=#{scrapDate}
  371. </if>
  372. <if test="scrapUser!=null and scrapUser!=''">
  373. and t.scrap_user=#{scrapUser}
  374. </if>
  375. <if test="replaceToolId!=null and replaceToolId!=''">
  376. and t.replace_tool_id=#{replaceToolId}
  377. </if>
  378. <if test="produceFactory!=null and produceFactory!=''">
  379. and t.produce_factory=#{produceFactory}
  380. </if>
  381. <if test="produceDate!=null">
  382. and t.produce_date=#{produceDate}
  383. </if>
  384. <if test="remark!=null and remark!=''">
  385. and t.remark=#{remark}
  386. </if>
  387. <if test="createBy!=null and createBy!=''">
  388. and t.create_by=#{createBy}
  389. </if>
  390. <if test="createTime!=null">
  391. and DATE_FORMAT(t.create_time, '%Y-%m-%d') = #{createTime}
  392. </if>
  393. <if test="updateBy!=null and updateBy!=''">
  394. and t.update_by=#{updateBy}
  395. </if>
  396. <if test="updateTime!=null">
  397. and DATE_FORMAT(t.update_time, '%Y-%m-%d') = #{updateTime}
  398. </if>
  399. </where>
  400. </select>
  401. <select id="getListByIds" resultMap="BaseResultMap">
  402. SELECT
  403. <include refid="Base_Column_List"/>,
  404. d.dept_name,
  405. dt1.dict_label as tool_name,
  406. dt2.dict_label as test_cycle_text
  407. FROM base_safety_tool t
  408. LEFT JOIN sys_dept d on t.dept_id = d.dept_id
  409. LEFT JOIN sys_dict_data dt1 ON (t.tool_type = dt1.dict_value AND dt1.dict_type = 'tool_type')
  410. LEFT JOIN sys_dict_data dt2 ON (t.test_cycle = dt2.dict_value AND dt2.dict_type = 'test_cycle')
  411. where t.tool_id in
  412. <foreach collection="array" item="id" open="(" separator="," close=")">
  413. #{id}
  414. </foreach>
  415. </select>
  416. <select id="listByExperimentId" resultMap="BaseResultMap">
  417. SELECT
  418. <include refid="Base_Column_List"/>
  419. FROM base_safety_tool t
  420. left join sec_experiment_tool t1 on t.tool_id = t1.tool_id
  421. where t1.exp_id=#{experimentId}
  422. </select>
  423. <select id="listByScheduledId" resultMap="BaseResultMap">
  424. SELECT
  425. <include refid="Base_Column_List"/>
  426. FROM base_safety_tool t
  427. left join sec_scheduled_tool t1 on t.tool_id = t1.tool_id
  428. where t1.scheduled_id=#{scheduledId}
  429. </select>
  430. <resultMap id="ExpResultMap" type="com.railway.business.safetool.domain.vo.ExpToolVo">
  431. <result column="tool_id" property="toolId"/>
  432. <result column="dept_id" property="deptId"/>
  433. <result column="dept_name" property="deptName"/>
  434. <result column="store_place" property="storePlace"/>
  435. <result column="tool_name" property="toolName"/>
  436. <result column="tool_type" property="toolType"/>
  437. <result column="tool_code" property="toolCode"/>
  438. <result column="last_test_date" property="lastTestDate"/>
  439. <result column="isok" property="isok"/>
  440. <result column="exp_id" property="experimentId"/>
  441. </resultMap>
  442. <select id="listExperimentTool" resultMap="ExpResultMap">
  443. SELECT
  444. <include refid="Base_Column_List"/>, t1.isok, #{experimentId} as exp_id
  445. FROM base_safety_tool t
  446. left join sec_experiment_tool t1 on t.tool_id = t1.tool_id
  447. <where>
  448. t.del_flag='0' and t1.exp_id=#{experimentId}
  449. <if test="deptId!=null and deptId!=''">
  450. and t.dept_id=#{deptId}
  451. </if>
  452. <if test="storePlace!=null and storePlace!=''">
  453. and t.store_place like concat(#{storePlace}, '%')
  454. </if>
  455. <if test="toolName!=null and toolName!=''">
  456. and t.tool_name like concat(#{toolName}, '%')
  457. </if>
  458. <if test="toolCode!=null and toolCode!=''">
  459. and t.tool_code=#{toolCode}
  460. </if>
  461. <if test="lastTestDateStart!=null">
  462. and t.last_test_date <![CDATA[ >= ]]> #{lastTestDateStart}
  463. </if>
  464. <if test="lastTestDateEnd!=null">
  465. and t.last_test_date <![CDATA[ <= ]]> #{lastTestDateEnd}
  466. </if>
  467. </where>
  468. </select>
  469. </mapper>