SecExperimentMapper.xml 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  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.SecExperimentMapper">
  5. <insert id="insertExp" keyProperty="id"
  6. parameterType="com.railway.business.safetool.domain.vo.SecExpAddParmVo">
  7. INSERT INTO sec_experiment (lab_id,lab_name,scheduled_id,end_time,dept_id,dept_name,
  8. scheduled_time,state,del_flag,create_time,create_by)
  9. select lab_id,d2.dept_name lab_name,s.id scheduled_id,
  10. ADDDATE(now(),3) end_time ,s.dept_id,d.dept_name,
  11. now() scheduled_time,
  12. '0' state ,'0' del_flag, now() create_time , #{createby} create_by
  13. from sec_scheduled s
  14. left join sys_dept d on s.dept_id = d.dept_id
  15. left join sys_dept d2 on lab_id = d2.dept_id
  16. where s.id = #{secid}
  17. </insert>
  18. <insert id="insertTool">
  19. INSERT INTO sec_experiment_tool (tool_id,isok,exp_id,del_flag,create_time,create_by)
  20. select tool_id,'1' isok ,#{expid} exp_id ,'0' del_flag, now() create_time , #{createby}
  21. create_by
  22. from sec_scheduled_tool
  23. where scheduled_id = #{secid}
  24. </insert>
  25. <update id="update" parameterType="com.railway.business.safetool.domain.SecExperiment">
  26. UPDATE sec_experiment
  27. <set>
  28. <if test='null != labId'>lab_id = #{labId},</if>
  29. <if test='null != scheduledId'>scheduled_id = #{scheduledId},</if>
  30. <if test='null != endTime'>end_time = #{endTime},</if>
  31. <if test='null != deptName'>dept_name = #{deptName},</if>
  32. <if test='null != labName'>lab_name = #{labName},</if>
  33. <if test='null != scheduledTime'>scheduled_time = #{scheduledTime},</if>
  34. <if test='null != expDate'>exp_date = #{expDate},</if>
  35. <if test='null != expReport'>exp_report = #{expReport},</if>
  36. <if test='null != state'>state = #{state},</if>
  37. <if test='null != delFlag'>del_flag = #{delFlag},</if>
  38. <if test='null != createBy'>create_by = #{createBy},</if>
  39. <if test='null != createTime'>create_time = #{createTime},</if>
  40. <if test='null != updateBy'>update_by = #{updateBy},</if>
  41. <if test='null != updateTime'>update_time = #{updateTime}</if>
  42. </set>
  43. WHERE id = #{id}
  44. </update>
  45. <update id="updateScheduled">
  46. update sec_scheduled
  47. set state = #{state}
  48. where id = (
  49. select scheduled_id from sec_experiment where id = #{id}
  50. )
  51. </update>
  52. <resultMap id="ToolsResultMap" type="com.railway.business.safetool.domain.vo.SecExpToolsVo">
  53. <result column="tool_id" property="toolId"/>
  54. <result column="tool_code" property="toolCode"/>
  55. <result column="id" property="id"/>
  56. <result column="isok" property="isok"/>
  57. </resultMap>
  58. <select id="listSafetyTools" resultMap="ToolsResultMap">
  59. select d3.dict_label toolName, t.unit,t.tool_id, t.tool_code, r.id, r.isok
  60. FROM sec_experiment_tool r
  61. LEFT JOIN sec_experiment s ON r.exp_id = s.id
  62. LEFT JOIN base_safety_tool t ON t.tool_id = r.tool_id
  63. left join sys_dept d1 on s.dept_id = d1.dept_id
  64. left join sys_dept d2 on s.lab_id = d2.dept_id
  65. left join sys_dict_data d3 on d3.dict_type = 'tool_type' and d3.dict_value = t.tool_type
  66. WHERE s.del_flag = '0' and t.del_flag = '0'
  67. and s.id=#{id}
  68. </select>
  69. <resultMap id="BaseResultMap" type="com.railway.business.safetool.domain.SecExperiment">
  70. <result column="id" property="id"/>
  71. <result column="lab_id" property="labId"/>
  72. <result column="lab_name" property="labName"/>
  73. <result column="scheduled_id" property="scheduledId"/>
  74. <result column="end_time" property="endTime"/>
  75. <result column="dept_id" property="deptId"/>
  76. <result column="dept_name" property="deptName"/>
  77. <result column="scheduled_time" property="scheduledTime"/>
  78. <result column="state" property="state"/>
  79. <result column="exp_date" property="expDate"/>
  80. <result column="exp_by" property="expBy"/>
  81. <result column="exp_report" property="expReport"/>
  82. <result column="del_flag" property="delFlag"/>
  83. <result column="create_by" property="createBy"/>
  84. <result column="create_time" property="createTime"/>
  85. <result column="update_by" property="updateBy"/>
  86. <result column="update_time" property="updateTime"/>
  87. </resultMap>
  88. <sql id="Base_Column_List">
  89. id,
  90. lab_id,
  91. lab_name,
  92. scheduled_id,
  93. end_time,
  94. dept_id,
  95. dept_name,
  96. scheduled_time,
  97. state,
  98. exp_date,
  99. exp_by,
  100. exp_report,
  101. del_flag,
  102. create_by,
  103. create_time,
  104. update_by,
  105. update_time
  106. </sql>
  107. <select id="getInfo" resultMap="BaseResultMap">
  108. SELECT
  109. <include refid="Base_Column_List"/>
  110. FROM sec_experiment
  111. WHERE del_flag='0' and id = #{id}
  112. </select>
  113. <resultMap id="InfoResultMap" type="com.railway.business.safetool.domain.vo.SecExpInfoVo">
  114. <result column="id" property="id"/>
  115. <result column="state" property="state"/>
  116. <result column="end_time" property="endTime"/>
  117. <result column="exp_date" property="expDate"/>
  118. <result column="dept_name" property="deptName"/>
  119. <result column="lab_name" property="labName"/>
  120. <result column="sj_name" property="sjName"/>
  121. <result column="sy_name" property="syName"/>
  122. <result column="sjr_id" property="sjrId"/>
  123. <result column="syr_id" property="syrId"/>
  124. <result column="dept_id" property="deptId"/>
  125. <result column="lab_id" property="labId"/>
  126. <result column="scheduled_id" property="scheduledId"/>
  127. <result column="deptName" property="deptName"/>
  128. <result column="labName" property="labName"/>
  129. <result column="exp_report" property="expReport"/>
  130. </resultMap>
  131. <select id="getExpInfoVo" resultMap="InfoResultMap">
  132. select e.id,e.state,e.scheduled_time,e.end_time,e.exp_date,e.dept_name,e.lab_name,e.exp_report,
  133. u.real_name as sj_name, u1.real_name as sy_name, u.user_id as sjr_id, u1.user_id as syr_id
  134. from sec_experiment e
  135. left join sys_user u on e.create_by = u.user_name
  136. left join sys_user u1 on e.update_by = u1.user_name
  137. where e.id=#{id}
  138. </select>
  139. <resultMap id="listResultMap" type="com.railway.business.safetool.domain.vo.SecExpListVo">
  140. <result column="id" property="id"/>
  141. <result column="state" property="state"/>
  142. <result column="scheduled_time" property="scheduledTime"/>
  143. <result column="end_time" property="endTime"/>
  144. <result column="exp_date" property="expDate"/>
  145. <result column="dept_name" property="deptName"/>
  146. <result column="lab_name" property="labName"/>
  147. <result column="real_name" property="realName"/>
  148. <result column="c" property="c"/>
  149. </resultMap>
  150. <select id="getList" resultMap="listResultMap">
  151. select e.id,e.state,e.scheduled_time,e.end_time,e.exp_date,e.dept_name,e.lab_name,u.real_name, t.c
  152. from sec_experiment e
  153. left join sys_user u on e.create_by = u.user_name
  154. left join (select exp_id, count(*) as c from sec_experiment_tool where del_flag = '0' group by exp_id) t on t.exp_id = e.id
  155. <where>
  156. e.del_flag = '0'
  157. <if test="deptId!=null and deptId!=''">
  158. and (e.lab_id =#{deptId} or e.dept_id =#{deptId})
  159. </if>
  160. <if test="scheduledTime!=null and scheduledTime!=''">
  161. and e.scheduled_time =#{scheduledTime}
  162. </if>
  163. <if test="state!=null and state!=''">
  164. and e.state=#{state}
  165. </if>
  166. </where>
  167. order by e.end_time
  168. <choose>
  169. <when test="isAsc!=null and isAsc!=''">
  170. <if test="isAsc == '1'.toString()">
  171. asc
  172. </if>
  173. <if test="isAsc == '0'.toString()">
  174. desc
  175. </if>
  176. </when>
  177. <otherwise>
  178. desc
  179. </otherwise>
  180. </choose>
  181. </select>
  182. <resultMap id="listExperimentResultMap" type="com.railway.business.safetool.domain.SecExperiment">
  183. <result column="id" property="id"/>
  184. <result column="lab_id" property="labId"/>
  185. <result column="lab_name" property="labName"/>
  186. <result column="scheduled_id" property="scheduledId"/>
  187. <result column="end_time" property="endTime"/>
  188. <result column="dept_id" property="deptId"/>
  189. <result column="dept_name" property="deptName"/>
  190. <result column="scheduled_time" property="scheduledTime"/>
  191. <result column="state" property="state"/>
  192. <result column="exp_date" property="expDate"/>
  193. <result column="exp_by" property="expBy"/>
  194. <result column="exp_report" property="expReport"/>
  195. <result column="del_flag" property="delFlag"/>
  196. </resultMap>
  197. <sql id="list_Column_List">
  198. t.id,
  199. t.lab_id,
  200. t.lab_name,
  201. t.scheduled_id,
  202. t.end_time,
  203. t.dept_id,
  204. t.dept_name,
  205. t.scheduled_time,
  206. t.state,
  207. t.exp_date,
  208. t.exp_by,
  209. t.del_flag
  210. </sql>
  211. <!-- state='0' 待实验 -->
  212. <select id="listExperiment" resultMap="listExperimentResultMap">
  213. SELECT
  214. <include refid="list_Column_List"/>
  215. FROM sec_experiment t
  216. left join sec_experiment_tool t1 on t.id = t1.exp_id
  217. where t.del_flag='0' and t.state='0' and t1.tool_id=#{toolId}
  218. </select>
  219. </mapper>