SecScheduledMapper.xml 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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. <resultMap id="BaseResultMap" type="com.railway.business.safetool.domain.vo.SecScheduledDetailVo">
  6. <result column="toolName" property="toolName"/>
  7. <result column="unit" property="unit"/>
  8. <collection property="baseSafetyTools" ofType="com.railway.business.safetool.domain.vo.SecScheduledToolsVo">
  9. <result column="tool_id" property="toolId"/>
  10. <result column="tool_code" property="toolCode"/>
  11. <result column="id" property="id"/>
  12. </collection>
  13. </resultMap>
  14. <resultMap id="BaseResultMap2" type="com.railway.business.safetool.domain.vo.SecScheduledListVo2">
  15. <result column="id" property="id"/>
  16. <result column="dept_id" property="deptId"/>
  17. <result column="lab_id" property="labId"/>
  18. <result column="scheduled_time" property="scheduledTime"/>
  19. <result column="deptName" property="deptName"/>
  20. <result column="labName" property="labName"/>
  21. <result column="c" property="c"/>
  22. </resultMap>
  23. <sql id="Base_Column_List">
  24. id,
  25. dept_id,
  26. store_place,
  27. lab_id,
  28. scheduled_time,
  29. state,
  30. del_flag,
  31. create_by,
  32. create_time,
  33. update_by,
  34. update_time
  35. </sql>
  36. <insert id="insert" parameterType="com.railway.business.safetool.domain.SecScheduled">
  37. <selectKey keyProperty="id" order="AFTER" resultType="Long">
  38. select @@IDENTITY as id
  39. </selectKey>
  40. INSERT INTO sec_scheduled
  41. <trim prefix="(" suffix=")" suffixOverrides=",">
  42. <if test ='null != deptId'>
  43. dept_id,
  44. </if>
  45. <if test ='null != labId'>
  46. lab_id,
  47. </if>
  48. <if test ='null != scheduledTime'>
  49. scheduled_time,
  50. </if>
  51. <if test ='null != state'>
  52. state,
  53. </if>
  54. <if test ='null != delFlag'>
  55. del_flag,
  56. </if>
  57. <if test ='null != createBy'>
  58. create_by,
  59. </if>
  60. <if test ='null != createTime'>
  61. create_time,
  62. </if>
  63. <if test ='null != updateBy'>
  64. update_by,
  65. </if>
  66. <if test ='null != updateTime'>
  67. update_time
  68. </if>
  69. </trim>
  70. <trim prefix="values (" suffix=")" suffixOverrides=",">
  71. <if test ='null != deptId'>
  72. #{deptId},
  73. </if>
  74. <if test ='null != labId'>
  75. #{labId},
  76. </if>
  77. <if test ='null != scheduledTime'>
  78. #{scheduledTime},
  79. </if>
  80. <if test ='null != state'>
  81. #{state},
  82. </if>
  83. <if test ='null != delFlag'>
  84. #{delFlag},
  85. </if>
  86. <if test ='null != createBy'>
  87. #{createBy},
  88. </if>
  89. <if test ='null != createTime'>
  90. #{createTime},
  91. </if>
  92. <if test ='null != updateBy'>
  93. #{updateBy},
  94. </if>
  95. <if test ='null != updateTime'>
  96. #{updateTime}
  97. </if>
  98. </trim>
  99. </insert>
  100. <delete id="delete">
  101. UPDATE sec_scheduled
  102. set del_flag='1'
  103. WHERE id = #{id}
  104. </delete>
  105. <update id="update" parameterType="com.railway.business.safetool.domain.SecScheduled">
  106. UPDATE sec_scheduled
  107. <set>
  108. <if test ='null != deptId'>dept_id = #{deptId},</if>
  109. <if test ='null != labId'>lab_id = #{labId},</if>
  110. <if test ='null != scheduledTime'>scheduled_time = #{scheduledTime},</if>
  111. <if test ='null != state'>state = #{state},</if>
  112. <if test ='null != delFlag'>del_flag = #{delFlag},</if>
  113. <if test ='null != createBy'>create_by = #{createBy},</if>
  114. <if test ='null != createTime'>create_time = #{createTime},</if>
  115. <if test ='null != updateBy'>update_by = #{updateBy},</if>
  116. <if test ='null != updateTime'>update_time = #{updateTime}</if>
  117. </set>
  118. WHERE id = #{id}
  119. </update>
  120. <select id="getInfo" resultMap="BaseResultMap">
  121. select d3.dict_label toolName ,t.unit,t.tool_id,t.tool_code,r.id
  122. FROM sec_scheduled s
  123. LEFT JOIN sec_scheduled_tool r
  124. ON r.scheduled_id = s.id
  125. INNER JOIN base_safety_tool t
  126. ON t.tool_id = r.tool_id
  127. left join sys_dept d1 on s.dept_id = d1.dept_id
  128. left join sys_dept d2 on s.lab_id = d2.dept_id
  129. left join sys_dict_data d3 on d3.dict_type = 'tool_type' and d3.dict_value = t.tool_type
  130. WHERE s.del_flag = '0' and s.state = 0 and t.del_flag = '0' and t.state = '1'
  131. and s.id=#{id}
  132. </select>
  133. <select id="getList" resultMap="BaseResultMap2">
  134. select s.id,s.dept_id,s.lab_id,s.scheduled_time ,d1.dept_name deptName,d2.dept_name labName,concat(count(1),'件') c
  135. from
  136. sec_scheduled s
  137. left join sec_scheduled_tool r
  138. on r.scheduled_id = s.id
  139. inner join base_safety_tool t
  140. on t.tool_id = r.tool_id
  141. left join sys_dept d1 on s.dept_id = d1.dept_id
  142. left join sys_dept d2 on s.lab_id = d2.dept_id
  143. where s.del_flag = '0' and s.state = 0 and t.del_flag = '0' and t.state = '1'
  144. and s.dept_id=#{deptId}
  145. <if test="labId!=null and labId!=''">
  146. and s.lab_id=#{labId}
  147. </if>
  148. <if test="orderby!=null and orderby!=''">
  149. order by scheduled_time ${orderby}
  150. </if>
  151. </select>
  152. </mapper>