BaseSafetyToolMapper.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  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="elec_level" property="elecLevel"/>
  14. <result column="unit" property="unit"/>
  15. <result column="test_cycle" property="testCycle"/>
  16. <result column="test_cycle_text" property="testCycleText"/>
  17. <result column="last_test_date" property="lastTestDate"/>
  18. <result column="next_test_date" property="nextTestDate"/>
  19. <result column="test_result" property="testResult"/>
  20. <result column="test_date" property="testDate"/>
  21. <result column="test_result_desc" property="testResultDesc"/>
  22. <result column="state" property="state"/>
  23. <result column="scrap_reason" property="scrapReason"/>
  24. <result column="scrap_date" property="scrapDate"/>
  25. <result column="scrap_user" property="scrapUser"/>
  26. <result column="replace_tool_id" property="replaceToolId"/>
  27. <result column="produce_factory" property="produceFactory"/>
  28. <result column="produce_date" property="produceDate"/>
  29. <result column="remark" property="remark"/>
  30. <result column="del_flag" property="delFlag"/>
  31. <result column="create_by" property="createBy"/>
  32. <result column="create_time" property="createTime"/>
  33. <result column="update_by" property="updateBy"/>
  34. <result column="update_time" property="updateTime"/>
  35. </resultMap>
  36. <sql id="Base_Column_List">
  37. t.tool_id,
  38. t.dept_id,
  39. dept.dept_name,
  40. t.store_place,
  41. dict1.dict_label as tool_name,
  42. t.tool_type,
  43. t.tool_code,
  44. t.elec_level,
  45. dict1.remark unit,
  46. t.test_cycle,
  47. dict2.dict_label as test_cycle_text,
  48. t.last_test_date,
  49. t.next_test_date,
  50. t.test_result,
  51. t.test_date,
  52. t.test_result_desc,
  53. t.state,
  54. t.scrap_reason,
  55. t.scrap_date,
  56. t.scrap_user,
  57. t.replace_tool_id,
  58. t.produce_factory,
  59. t.produce_date,
  60. t.remark,
  61. t.del_flag,
  62. t.create_by,
  63. t.create_time,
  64. t.update_by,
  65. t.update_time
  66. </sql>
  67. <insert id="insert" parameterType="com.railway.business.safetool.domain.BaseSafetyTool" useGeneratedKeys="true" keyProperty="toolId">
  68. INSERT INTO base_safety_tool
  69. <trim prefix="(" suffix=")" suffixOverrides=",">
  70. <if test ='null != deptId'>
  71. dept_id,
  72. </if>
  73. <if test ='null != storePlace'>
  74. store_place,
  75. </if>
  76. <if test ='null != toolName'>
  77. tool_name,
  78. </if>
  79. <if test ='null != toolType'>
  80. tool_type,
  81. </if>
  82. <if test ='null != toolCode'>
  83. tool_code,
  84. </if>
  85. <if test ='null != elecLevel'>
  86. elec_level,
  87. </if>
  88. <if test ='null != unit'>
  89. unit,
  90. </if>
  91. <if test ='null != testCycle'>
  92. test_cycle,
  93. </if>
  94. <if test ='null != lastTestDate'>
  95. last_test_date,
  96. </if>
  97. <if test ='null != nextTestDate'>
  98. next_test_date,
  99. </if>
  100. <if test ='null != testResult'>
  101. test_result,
  102. </if>
  103. <if test ='null != testDate'>
  104. test_date,
  105. </if>
  106. <if test ='null != testResultDesc'>
  107. test_result_desc,
  108. </if>
  109. <if test ='null != state'>
  110. state,
  111. </if>
  112. <if test ='null != scrapReason'>
  113. scrap_reason,
  114. </if>
  115. <if test ='null != scrapDate'>
  116. scrap_date,
  117. </if>
  118. <if test ='null != scrapUser'>
  119. scrap_user,
  120. </if>
  121. <if test ='null != replaceToolId'>
  122. replace_tool_id,
  123. </if>
  124. <if test ='null != produceFactory'>
  125. produce_factory,
  126. </if>
  127. <if test ='null != produceDate'>
  128. produce_date,
  129. </if>
  130. <if test ='null != remark'>
  131. remark,
  132. </if>
  133. <if test ='null != delFlag'>
  134. del_flag,
  135. </if>
  136. <if test ='null != createBy'>
  137. create_by,
  138. </if>
  139. <if test ='null != createTime'>
  140. create_time,
  141. </if>
  142. <if test ='null != updateBy'>
  143. update_by,
  144. </if>
  145. <if test ='null != updateTime'>
  146. update_time
  147. </if>
  148. </trim>
  149. <trim prefix="values (" suffix=")" suffixOverrides=",">
  150. <if test ='null != deptId'>
  151. #{deptId},
  152. </if>
  153. <if test ='null != storePlace'>
  154. #{storePlace},
  155. </if>
  156. <if test ='null != toolName'>
  157. #{toolName},
  158. </if>
  159. <if test ='null != toolType'>
  160. #{toolType},
  161. </if>
  162. <if test ='null != toolCode'>
  163. #{toolCode},
  164. </if>
  165. <if test ='null != elecLevel'>
  166. #{elecLevel},
  167. </if>
  168. <if test ='null != unit'>
  169. #{unit},
  170. </if>
  171. <if test ='null != testCycle'>
  172. #{testCycle},
  173. </if>
  174. <if test ='null != lastTestDate'>
  175. #{lastTestDate},
  176. </if>
  177. <if test ='null != nextTestDate'>
  178. #{nextTestDate},
  179. </if>
  180. <if test ='null != testResult'>
  181. #{testResult},
  182. </if>
  183. <if test ='null != testDate'>
  184. #{testDate},
  185. </if>
  186. <if test ='null != testResultDesc'>
  187. #{testResultDesc},
  188. </if>
  189. <if test ='null != state'>
  190. #{state},
  191. </if>
  192. <if test ='null != scrapReason'>
  193. #{scrapReason},
  194. </if>
  195. <if test ='null != scrapDate'>
  196. #{scrapDate},
  197. </if>
  198. <if test ='null != scrapUser'>
  199. #{scrapUser},
  200. </if>
  201. <if test ='null != replaceToolId'>
  202. #{replaceToolId},
  203. </if>
  204. <if test ='null != produceFactory'>
  205. #{produceFactory},
  206. </if>
  207. <if test ='null != produceDate'>
  208. #{produceDate},
  209. </if>
  210. <if test ='null != remark'>
  211. #{remark},
  212. </if>
  213. <if test ='null != delFlag'>
  214. #{delFlag},
  215. </if>
  216. <if test ='null != createBy'>
  217. #{createBy},
  218. </if>
  219. <if test ='null != createTime'>
  220. #{createTime},
  221. </if>
  222. <if test ='null != updateBy'>
  223. #{updateBy},
  224. </if>
  225. <if test ='null != updateTime'>
  226. #{updateTime}
  227. </if>
  228. </trim>
  229. </insert>
  230. <delete id="delete">
  231. UPDATE base_safety_tool
  232. set del_flag='1'
  233. WHERE tool_id = #{toolId}
  234. </delete>
  235. <update id="update" parameterType="com.railway.business.safetool.domain.BaseSafetyTool">
  236. UPDATE base_safety_tool
  237. <set>
  238. <if test ='null != deptId'>dept_id = #{deptId},</if>
  239. <if test ='null != storePlace'>store_place = #{storePlace},</if>
  240. <if test ='null != toolName'>tool_name = #{toolName},</if>
  241. <if test ='null != toolType'>tool_type = #{toolType},</if>
  242. <if test ='null != toolCode'>tool_code = #{toolCode},</if>
  243. <if test ='null != elecLevel'>elec_level = #{elecLevel},</if>
  244. <if test ='null != unit'>unit = #{unit},</if>
  245. <if test ='null != testCycle'>test_cycle = #{testCycle},</if>
  246. <if test ='null != lastTestDate'>last_test_date = #{lastTestDate},</if>
  247. <if test ='null != nextTestDate'>next_test_date = #{nextTestDate},</if>
  248. <if test ='null != testResult'>test_result = #{testResult},</if>
  249. <if test ='null != testDate'>test_date = #{testDate},</if>
  250. <if test ='null != testResultDesc'>test_result_desc = #{testResultDesc},</if>
  251. <if test ='null != state'>state = #{state},</if>
  252. <if test ='null != scrapReason'>scrap_reason = #{scrapReason},</if>
  253. <if test ='null != scrapDate'>scrap_date = #{scrapDate},</if>
  254. <if test ='null != scrapUser'>scrap_user = #{scrapUser},</if>
  255. <if test ='null != replaceToolId'>replace_tool_id = #{replaceToolId},</if>
  256. <if test ='null != produceFactory'>produce_factory = #{produceFactory},</if>
  257. <if test ='null != produceDate'>produce_date = #{produceDate},</if>
  258. <if test ='null != remark'>remark = #{remark},</if>
  259. <if test ='null != delFlag'>del_flag = #{delFlag},</if>
  260. <if test ='null != createBy'>create_by = #{createBy},</if>
  261. <if test ='null != createTime'>create_time = #{createTime},</if>
  262. <if test ='null != updateBy'>update_by = #{updateBy},</if>
  263. <if test ='null != updateTime'>update_time = #{updateTime}</if>
  264. </set>
  265. WHERE tool_id = #{toolId}
  266. </update>
  267. <select id="getInfo" resultMap="BaseResultMap">
  268. SELECT
  269. <include refid="Base_Column_List"/>
  270. FROM base_safety_tool t
  271. LEFT JOIN sys_dept dept on t.dept_id = dept.dept_id
  272. LEFT JOIN sys_dict_data dict1 ON (t.tool_type = dict1.dict_value AND dict1.dict_type = 'tool_type')
  273. LEFT JOIN sys_dict_data dict2 ON (t.test_cycle = dict2.dict_value AND dict2.dict_type = 'test_cycle')
  274. WHERE t.del_flag='0' and t.tool_id = #{toolId}
  275. </select>
  276. <select id="getList" resultMap="BaseResultMap">
  277. SELECT
  278. <include refid="Base_Column_List"/>
  279. FROM base_safety_tool t
  280. LEFT JOIN sys_dept dept on t.dept_id = dept.dept_id
  281. LEFT JOIN sys_dict_data dict1 ON (t.tool_type = dict1.dict_value AND dict1.dict_type = 'tool_type')
  282. LEFT JOIN sys_dict_data dict2 ON (t.test_cycle = dict2.dict_value AND dict2.dict_type = 'test_cycle')
  283. <where>
  284. t.del_flag='0'
  285. <if test="deptId!=null and deptId!=''">
  286. and t.dept_id=#{deptId}
  287. </if>
  288. <if test="storePlace!=null and storePlace!=''">
  289. and t.store_place=#{storePlace}
  290. </if>
  291. <if test="toolName!=null and toolName!=''">
  292. and t.tool_name=#{toolName}
  293. </if>
  294. <if test="toolType!=null and toolType!=''">
  295. and t.tool_type=#{toolType}
  296. </if>
  297. <if test="toolCode!=null and toolCode!=''">
  298. and t.tool_code=#{toolCode}
  299. </if>
  300. <if test="elecLevel!=null and elecLevel!=''">
  301. and t.elec_level=#{elecLevel}
  302. </if>
  303. <if test="unit!=null and unit!=''">
  304. and t.unit=#{unit}
  305. </if>
  306. <if test="testCycle!=null and testCycle!=''">
  307. and t.test_cycle=#{testCycle}
  308. </if>
  309. <if test="lastTestDate!=null">
  310. and t.last_test_date=#{lastTestDate}
  311. </if>
  312. <if test="nextTestDate!=null">
  313. and t.next_test_date=#{nextTestDate}
  314. </if>
  315. <if test="testResult!=null and testResult!=''">
  316. and t.test_result=#{testResult}
  317. </if>
  318. <if test="testDate!=null">
  319. and t.test_date=#{testDate}
  320. </if>
  321. <if test="testResultDesc!=null and testResultDesc!=''">
  322. and t.test_result_desc=#{testResultDesc}
  323. </if>
  324. <if test="state!=null and state!=''">
  325. and t.state=#{state}
  326. </if>
  327. <if test="scrapReason!=null and scrapReason!=''">
  328. and t.scrap_reason=#{scrapReason}
  329. </if>
  330. <if test="scrapDate!=null and scrapDate!=''">
  331. and t.scrap_date=#{scrapDate}
  332. </if>
  333. <if test="scrapUser!=null and scrapUser!=''">
  334. and t.scrap_user=#{scrapUser}
  335. </if>
  336. <if test="replaceToolId!=null and replaceToolId!=''">
  337. and t.replace_tool_id=#{replaceToolId}
  338. </if>
  339. <if test="produceFactory!=null and produceFactory!=''">
  340. and t.produce_factory=#{produceFactory}
  341. </if>
  342. <if test="produceDate!=null">
  343. and t.produce_date=#{produceDate}
  344. </if>
  345. <if test="remark!=null and remark!=''">
  346. and t.remark=#{remark}
  347. </if>
  348. <if test="createBy!=null and createBy!=''">
  349. and t.create_by=#{createBy}
  350. </if>
  351. <if test="createTime!=null">
  352. and DATE_FORMAT(t.create_time, '%Y-%m-%d') = #{createTime}
  353. </if>
  354. <if test="updateBy!=null and updateBy!=''">
  355. and t.update_by=#{updateBy}
  356. </if>
  357. <if test="updateTime!=null">
  358. and DATE_FORMAT(t.update_time, '%Y-%m-%d') = #{updateTime}
  359. </if>
  360. </where>
  361. </select>
  362. </mapper>