SecExperimentMapper.xml 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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 != state'>state = #{state},</if>
  36. <if test='null != delFlag'>del_flag = #{delFlag},</if>
  37. <if test='null != createBy'>create_by = #{createBy},</if>
  38. <if test='null != createTime'>create_time = #{createTime},</if>
  39. <if test='null != updateBy'>update_by = #{updateBy},</if>
  40. <if test='null != updateTime'>update_time = #{updateTime}</if>
  41. </set>
  42. WHERE id = #{id}
  43. </update>
  44. <update id="updateScheduled">
  45. update sec_scheduled
  46. set state = #{state}
  47. where id = (
  48. select scheduled_id from sec_experiment where id = #{id}
  49. )
  50. </update>
  51. <resultMap id="ToolsResultMap" type="com.railway.business.safetool.domain.vo.SecExpToolsVo">
  52. <result column="tool_id" property="toolId"/>
  53. <result column="tool_code" property="toolCode"/>
  54. <result column="id" property="id"/>
  55. <result column="isok" property="isok"/>
  56. </resultMap>
  57. <select id="listSafetyTools" resultMap="ToolsResultMap">
  58. select d3.dict_label toolName, t.unit,t.tool_id, t.tool_code, r.id, r.isok
  59. FROM sec_experiment_tool r
  60. LEFT JOIN sec_experiment s ON r.exp_id = s.id
  61. LEFT JOIN base_safety_tool t ON t.tool_id = r.tool_id
  62. left join sys_dept d1 on s.dept_id = d1.dept_id
  63. left join sys_dept d2 on s.lab_id = d2.dept_id
  64. left join sys_dict_data d3 on d3.dict_type = 'tool_type' and d3.dict_value = t.tool_type
  65. WHERE s.del_flag = '0' and t.del_flag = '0' and t.state = '1'
  66. and s.id=#{id}
  67. </select>
  68. <resultMap id="InfoResultMap" type="com.railway.business.safetool.domain.vo.SecExpInfoVo">
  69. <result column="id" property="id"/>
  70. <result column="state" property="state"/>
  71. <result column="end_time" property="endTime"/>
  72. <result column="exp_date" property="expDate"/>
  73. <result column="dept_name" property="deptName"/>
  74. <result column="lab_name" property="labName"/>
  75. <result column="sj_name" property="sjName"/>
  76. <result column="sy_name" property="syName"/>
  77. <result column="sjr_id" property="sjrId"/>
  78. <result column="syr_id" property="syrId"/>
  79. <result column="dept_id" property="deptId"/>
  80. <result column="lab_id" property="labId"/>
  81. <result column="scheduled_id" property="scheduledId"/>
  82. <result column="deptName" property="deptName"/>
  83. <result column="labName" property="labName"/>
  84. </resultMap>
  85. <select id="getInfo" resultMap="InfoResultMap">
  86. select e.id,e.state,e.scheduled_time,e.end_time,e.exp_date,e.dept_name,e.lab_name,
  87. u.real_name as sj_name, u1.real_name as sy_name, u.user_id as sjr_id, u1.user_id as syr_id
  88. from sec_experiment e
  89. left join sys_user u on e.create_by = u.user_name
  90. left join sys_user u1 on e.update_by = u1.user_name
  91. where e.id=#{id}
  92. </select>
  93. <resultMap id="listResultMap" type="com.railway.business.safetool.domain.vo.SecExpListVo">
  94. <result column="id" property="id"/>
  95. <result column="state" property="state"/>
  96. <result column="scheduled_time" property="scheduledTime"/>
  97. <result column="end_time" property="endTime"/>
  98. <result column="exp_date" property="expDate"/>
  99. <result column="dept_name" property="deptName"/>
  100. <result column="lab_name" property="labName"/>
  101. <result column="real_name" property="realName"/>
  102. <result column="c" property="c"/>
  103. </resultMap>
  104. <select id="getList" resultMap="listResultMap">
  105. select e.id,e.state,e.scheduled_time,e.end_time,e.exp_date,e.dept_name,e.lab_name,u.real_name
  106. from sec_experiment e
  107. left join sys_user u on e.create_by = u.user_name
  108. <where>
  109. e.del_flag = '0'
  110. <if test="deptId!=null and deptId!=''">
  111. and (e.lab_id =#{deptId} or e.dept_id =#{deptId})
  112. </if>
  113. <if test="scheduledTime!=null and scheduledTime!=''">
  114. and e.scheduled_time =#{scheduledTime}
  115. </if>
  116. </where>
  117. <if test="orderby!=null and orderby!=''">
  118. order by end_time ${orderby}
  119. </if>
  120. </select>
  121. <resultMap id="listExperimentResultMap" type="com.railway.business.safetool.domain.SecExperiment">
  122. <result column="id" property="id"/>
  123. <result column="lab_id" property="labId"/>
  124. <result column="lab_name" property="labName"/>
  125. <result column="scheduled_id" property="scheduledId"/>
  126. <result column="end_time" property="endTime"/>
  127. <result column="dept_id" property="deptId"/>
  128. <result column="dept_name" property="deptName"/>
  129. <result column="scheduled_time" property="scheduledTime"/>
  130. <result column="state" property="state"/>
  131. <result column="exp_date" property="expDate"/>
  132. <result column="exp_by" property="expBy"/>
  133. <result column="exp_report" property="expReport"/>
  134. <result column="del_flag" property="delFlag"/>
  135. </resultMap>
  136. <sql id="list_Column_List">
  137. t.id,
  138. t.lab_id,
  139. t.lab_name,
  140. t.scheduled_id,
  141. t.end_time,
  142. t.dept_id,
  143. t.dept_name,
  144. t.scheduled_time,
  145. t.state,
  146. t.exp_date,
  147. t.exp_by,
  148. t.del_flag
  149. </sql>
  150. <!-- state='0' 待实验 -->
  151. <select id="listExperiment" resultMap="listExperimentResultMap">
  152. SELECT
  153. <include refid="list_Column_List"/>
  154. FROM sec_experiment t
  155. left join sec_experiment_tool t1 on t.id = t1.exp_id
  156. where t.del_flag='0' and t.state='0' and t1.tool_id=#{toolId}
  157. </select>
  158. </mapper>