SecScheduledMapper.xml 6.9 KB

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