SecScheduledMapper.xml 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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.SecScheduledMapper">
  5. <sql id="Base_Column_List">
  6. id,
  7. dept_id,
  8. lab_id,
  9. scheduled_time,
  10. state,
  11. del_flag,
  12. create_by,
  13. create_time,
  14. update_by,
  15. update_time
  16. </sql>
  17. <insert id="insert" parameterType="com.railway.business.safetool.domain.SecScheduled">
  18. <selectKey keyProperty="id" order="AFTER" resultType="Long">
  19. select @@IDENTITY as id
  20. </selectKey>
  21. INSERT INTO sec_scheduled
  22. <trim prefix="(" suffix=")" suffixOverrides=",">
  23. <if test='null != deptId'>
  24. dept_id,
  25. </if>
  26. <if test='null != labId'>
  27. lab_id,
  28. </if>
  29. <if test='null != scheduledTime'>
  30. scheduled_time,
  31. </if>
  32. <if test='null != state'>
  33. state,
  34. </if>
  35. <if test='null != delFlag'>
  36. del_flag,
  37. </if>
  38. <if test='null != createBy'>
  39. create_by,
  40. </if>
  41. <if test='null != createTime'>
  42. create_time,
  43. </if>
  44. <if test='null != updateBy'>
  45. update_by,
  46. </if>
  47. <if test='null != updateTime'>
  48. update_time
  49. </if>
  50. </trim>
  51. <trim prefix="values (" suffix=")" suffixOverrides=",">
  52. <if test='null != deptId'>
  53. #{deptId},
  54. </if>
  55. <if test='null != labId'>
  56. #{labId},
  57. </if>
  58. <if test='null != scheduledTime'>
  59. #{scheduledTime},
  60. </if>
  61. <if test='null != state'>
  62. #{state},
  63. </if>
  64. <if test='null != delFlag'>
  65. #{delFlag},
  66. </if>
  67. <if test='null != createBy'>
  68. #{createBy},
  69. </if>
  70. <if test='null != createTime'>
  71. #{createTime},
  72. </if>
  73. <if test='null != updateBy'>
  74. #{updateBy},
  75. </if>
  76. <if test='null != updateTime'>
  77. #{updateTime}
  78. </if>
  79. </trim>
  80. </insert>
  81. <delete id="delete">
  82. UPDATE sec_scheduled
  83. set del_flag='1'
  84. WHERE id = #{id}
  85. </delete>
  86. <update id="update" parameterType="com.railway.business.safetool.domain.SecScheduled">
  87. UPDATE sec_scheduled
  88. <set>
  89. <if test='null != deptId'>dept_id = #{deptId},</if>
  90. <if test='null != labId'>lab_id = #{labId},</if>
  91. <if test='null != scheduledTime'>scheduled_time = #{scheduledTime},</if>
  92. <if test='null != state'>state = #{state},</if>
  93. <if test='null != delFlag'>del_flag = #{delFlag},</if>
  94. <if test='null != createBy'>create_by = #{createBy},</if>
  95. <if test='null != createTime'>create_time = #{createTime},</if>
  96. <if test='null != updateBy'>update_by = #{updateBy},</if>
  97. <if test='null != updateTime'>update_time = #{updateTime}</if>
  98. </set>
  99. WHERE id = #{id}
  100. </update>
  101. <update id="updateScheduled">
  102. update sec_scheduled
  103. set state = #{state}
  104. where id = #{secid}
  105. </update>
  106. <select id="getInfo" resultMap="BaseResultMap">
  107. SELECT
  108. <include refid="Base_Column_List"/>
  109. FROM sec_scheduled
  110. WHERE del_flag='0' and id = #{id}
  111. </select>
  112. <select id="getInfoByExpId" resultMap="BaseResultMap">
  113. SELECT
  114. <include refid="Base_Column_List"/>
  115. FROM sec_scheduled
  116. where id = (
  117. select scheduled_id from sec_experiment where id = #{expId}
  118. )
  119. </select>
  120. <resultMap id="BaseResultMap2" type="com.railway.business.safetool.domain.vo.SecScheduledCountVo">
  121. <result column="id" property="id"/>
  122. <result column="dept_id" property="deptId"/>
  123. <result column="lab_id" property="labId"/>
  124. <result column="scheduled_time" property="scheduledTime"/>
  125. <result column="deptName" property="deptName"/>
  126. <result column="labName" property="labName"/>
  127. <result column="c" property="c"/>
  128. </resultMap>
  129. <select id="getList" resultMap="BaseResultMap2">
  130. select s.id,s.dept_id,s.lab_id,s.scheduled_time ,d1.dept_name deptName,d2.dept_name labName
  131. ,concat(count(1),'件') c
  132. from sec_scheduled s
  133. left join sec_scheduled_tool r on r.scheduled_id = s.id
  134. inner join base_safety_tool t on t.tool_id = r.tool_id
  135. left join sys_dept d1 on s.dept_id = d1.dept_id
  136. left join sys_dept d2 on s.lab_id = d2.dept_id
  137. <where>
  138. s.del_flag = '0' and s.state = 0 and t.del_flag = '0' and t.state = '1'
  139. <if test="deptId!=null and deptId!=''">
  140. and s.dept_id=#{deptId}
  141. </if>
  142. <if test="labId!=null and labId!=''">
  143. and s.lab_id=#{labId}
  144. </if>
  145. </where>
  146. group by s.id
  147. order by s.scheduled_time
  148. <if test="isAsc!=null and isAsc!=''">
  149. <if test="isAsc == '1'.toString()">
  150. asc
  151. </if>
  152. <if test="isAsc == '0'.toString()">
  153. desc
  154. </if>
  155. </if>
  156. </select>
  157. <resultMap id="BaseResultMap"
  158. type="com.railway.business.safetool.domain.vo.SecScheduledToolListVo">
  159. <result column="id" property="id"/>
  160. <result column="dept_id" property="deptId"/>
  161. <result column="lab_id" property="labId"/>
  162. <result column="scheduled_time" property="scheduledTime"/>
  163. <result column="deptName" property="deptName"/>
  164. <result column="labName" property="labName"/>
  165. <collection property="baseSafetyTools"
  166. ofType="com.railway.business.safetool.domain.vo.SecScheduledToolVo">
  167. <result column="tool_id" property="toolId"/>
  168. <result column="tool_code" property="toolCode"/>
  169. <result column="scheduled_tool_id" property="id"/>
  170. <result column="unit" property="unit"/>
  171. <result column="toolName" property="toolName"/>
  172. </collection>
  173. </resultMap>
  174. <select id="getDetail" resultMap="BaseResultMap">
  175. select s.id, s.dept_id, s.lab_id, s.scheduled_time,
  176. d1.dept_name deptName, d2.dept_name labName,
  177. d3.dict_label toolName ,t.unit,t.tool_id,t.tool_code, r.id as scheduled_tool_id
  178. FROM sec_scheduled s
  179. LEFT JOIN sec_scheduled_tool r ON r.scheduled_id = s.id
  180. INNER JOIN base_safety_tool t ON t.tool_id = r.tool_id
  181. left join sys_dept d1 on s.dept_id = d1.dept_id
  182. left join sys_dept d2 on s.lab_id = d2.dept_id
  183. left join sys_dict_data d3 on d3.dict_type = 'tool_type' and d3.dict_value = t.tool_type
  184. WHERE s.del_flag = '0' and s.state = 0 and t.del_flag = '0' and t.state = '1'
  185. and s.id=#{id}
  186. </select>
  187. <resultMap id="listResultMap" type="com.railway.business.safetool.domain.SecScheduled">
  188. <result column="id" property="id"/>
  189. <result column="dept_id" property="deptId"/>
  190. <result column="lab_id" property="labId"/>
  191. <result column="scheduled_time" property="scheduledTime"/>
  192. <result column="state" property="state"/>
  193. <result column="del_flag" property="delFlag"/>
  194. </resultMap>
  195. <sql id="list_Column_List">
  196. t.id,
  197. t.dept_id,
  198. t.lab_id,
  199. t.scheduled_time,
  200. t.state,
  201. t.del_flag
  202. </sql>
  203. <!-- state='0' 待送检 -->
  204. <select id="listScheduled" resultMap="listResultMap">
  205. SELECT
  206. <include refid="list_Column_List"/>
  207. FROM sec_scheduled t
  208. left join sec_scheduled_tool t1 on t.id = t1.scheduled_id
  209. where t.del_flag='0' and t.state='0' and t1.tool_id=#{toolId}
  210. </select>
  211. </mapper>