SecScheduledMapper.xml 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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. <resultMap id="BaseResultMap2" type="com.railway.business.safetool.domain.vo.SecScheduledCountVo">
  108. <result column="id" property="id"/>
  109. <result column="dept_id" property="deptId"/>
  110. <result column="lab_id" property="labId"/>
  111. <result column="scheduled_time" property="scheduledTime"/>
  112. <result column="deptName" property="deptName"/>
  113. <result column="labName" property="labName"/>
  114. <result column="c" property="c"/>
  115. </resultMap>
  116. <select id="getList" resultMap="BaseResultMap2">
  117. select s.id,s.dept_id,s.lab_id,s.scheduled_time ,d1.dept_name deptName,d2.dept_name labName
  118. ,concat(count(1),'件') c
  119. from sec_scheduled s
  120. left join sec_scheduled_tool r on r.scheduled_id = s.id
  121. inner join base_safety_tool t on t.tool_id = r.tool_id
  122. left join sys_dept d1 on s.dept_id = d1.dept_id
  123. left join sys_dept d2 on s.lab_id = d2.dept_id
  124. where s.del_flag = '0' and s.state = 0 and t.del_flag = '0' and t.state = '1'
  125. and s.dept_id=#{deptId}
  126. <if test="labId!=null and labId!=''">
  127. and s.lab_id=#{labId}
  128. </if>
  129. group by s.id
  130. <if test="orderby!=null and orderby!=''">
  131. order by scheduled_time ${orderby}
  132. </if>
  133. </select>
  134. <resultMap id="BaseResultMap"
  135. type="com.railway.business.safetool.domain.vo.SecScheduledToolListVo">
  136. <result column="id" property="id"/>
  137. <result column="dept_id" property="deptId"/>
  138. <result column="lab_id" property="labId"/>
  139. <result column="scheduled_time" property="scheduledTime"/>
  140. <result column="deptName" property="deptName"/>
  141. <result column="labName" property="labName"/>
  142. <collection property="baseSafetyTools"
  143. ofType="com.railway.business.safetool.domain.vo.SecScheduledToolVo">
  144. <result column="tool_id" property="toolId"/>
  145. <result column="tool_code" property="toolCode"/>
  146. <result column="scheduled_tool_id" property="id"/>
  147. <result column="unit" property="unit"/>
  148. <result column="toolName" property="toolName"/>
  149. </collection>
  150. </resultMap>
  151. <select id="getInfo" resultMap="BaseResultMap">
  152. select s.id, s.dept_id, s.lab_id, s.scheduled_time,
  153. d1.dept_name deptName, d2.dept_name labName,
  154. d3.dict_label toolName ,t.unit,t.tool_id,t.tool_code, r.id as scheduled_tool_id
  155. FROM sec_scheduled s
  156. LEFT JOIN sec_scheduled_tool r ON r.scheduled_id = s.id
  157. INNER JOIN base_safety_tool t ON t.tool_id = r.tool_id
  158. left join sys_dept d1 on s.dept_id = d1.dept_id
  159. left join sys_dept d2 on s.lab_id = d2.dept_id
  160. left join sys_dict_data d3 on d3.dict_type = 'tool_type' and d3.dict_value = t.tool_type
  161. WHERE s.del_flag = '0' and s.state = 0 and t.del_flag = '0' and t.state = '1'
  162. and s.id=#{id}
  163. </select>
  164. <resultMap id="listResultMap" type="com.railway.business.safetool.domain.SecScheduled">
  165. <result column="id" property="id"/>
  166. <result column="dept_id" property="deptId"/>
  167. <result column="lab_id" property="labId"/>
  168. <result column="scheduled_time" property="scheduledTime"/>
  169. <result column="state" property="state"/>
  170. <result column="del_flag" property="delFlag"/>
  171. </resultMap>
  172. <sql id="list_Column_List">
  173. t.id,
  174. t.dept_id,
  175. t.lab_id,
  176. t.scheduled_time,
  177. t.state,
  178. t.del_flag
  179. </sql>
  180. <select id="listScheduled" resultMap="listResultMap">
  181. SELECT
  182. <include refid="list_Column_List"/>
  183. FROM sec_scheduled t
  184. left join sec_scheduled_tool t1 on t.id = t1.scheduled_id
  185. where t.del_flag='0' and t.state='0' and t1.tool_id=#{toolId}
  186. </select>
  187. </mapper>