ActHxpapplyDetailMapper.xml 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.zd.chemical.mapper.ActHxpapplyDetailMapper">
  6. <resultMap type="com.zd.chemical.domain.ActHxpapplyDetail" id="ActHxpapplyDetailResult">
  7. <result property="id" column="id"/>
  8. <result property="hxpapplyId" column="hxpapply_id"/>
  9. <result property="chemicalId" column="chemical_id"/>
  10. <result property="chemicalName" column="chemical_name"/>
  11. <result property="cabinetId" column="cabinet_id"/>
  12. <result property="applyNum" column="apply_num"/>
  13. <result property="tickStatus" column="tick_status"/>
  14. </resultMap>
  15. <sql id="selectActHxpapplyDetailVo">
  16. select id, hxpapply_id, chemical_id, chemical_name, cabinet_id, apply_num,tick_status from act_hxpapply_detail
  17. </sql>
  18. <sql id="selectActHxpapplyDetailListVo">
  19. select t.id, t.hxpapply_id, t.chemical_id, t.chemical_name, t.cabinet_id, t.apply_num, t.tick_status from act_hxpapply_detail as t
  20. </sql>
  21. <select id="selectActHxpapplyDetailList" parameterType="com.zd.chemical.domain.ActHxpapplyDetail" resultMap="ActHxpapplyDetailResult">
  22. <include refid="selectActHxpapplyDetailVo"/>
  23. <where>
  24. <if test="hxpapplyId != null "> and hxpapply_id = #{hxpapplyId}</if>
  25. <if test="chemicalId != null "> and chemical_id = #{chemicalId}</if>
  26. <if test="chemicalName != null and chemicalName != ''"> and chemical_name like concat('%', #{chemicalName}, '%')</if>
  27. <if test="cabinetId != null "> and cabinet_id = #{cabinetId}</if>
  28. <if test="applyNum != null "> and apply_num = #{applyNum}</if>
  29. </where>
  30. </select>
  31. <select id="selectApplyDetailList" parameterType="com.zd.chemical.domain.ActHxpapplyDetail" resultType="com.zd.chemical.domain.vo.ActHxpapplyDetailVo">
  32. SELECT hd.id, hd.chemical_id chemicalId, hd.chemical_name chemicalName,
  33. hd.`cabinet_id` cabinetId,ct.cabinet_name cabinetName,
  34. CONCAT((SELECT st.name FROM lab_subject st WHERE st.id = hy.sub_id),'-',(SELECT dt.dept_name FROM sys_dept
  35. dt,lab_subject st WHERE dt.dept_id = st.build_id AND st.id = hy.sub_id),
  36. '-',(SELECT bg.name FROM lab_building bg,lab_subject st WHERE bg.id = st.floor_id AND st.id = hy.sub_id),
  37. ifnull(CONCAT('-',(SELECT slt.room_num room FROM lab_build_floor_layout slt,lab_subject st WHERE slt.sub_id = st.id AND st.id = ct.`sub_id`)),'')) posi,
  38. CONCAT(0,cl.`chemical_unit`) collegeInventory,
  39. CONCAT(0,cl.`chemical_unit`) subInventory,
  40. CONCAT(0,cl.`chemical_unit`) cabinetStorage,
  41. hd.remaining_storage remainingStorage,
  42. hd.apply_num applyNum,cl.`chemical_unit` applyUnit,
  43. hd.tick_status tickStatus,
  44. (SELECT GROUP_CONCAT(ur.nick_name) FROM sys_user ur WHERE FIND_IN_SET(ur.user_id, s.`safe_user_id`)) AS safeUserNames
  45. FROM act_hxpapply_detail hd
  46. LEFT JOIN act_hxpapply hy on hy.id = hd.hxpapply_id
  47. LEFT JOIN hxp_cabinet ct ON hd.`cabinet_id` = ct.`id`
  48. LEFT JOIN hxp_chemical cl ON hd.`chemical_id` = cl.`id`
  49. LEFT JOIN lab_subject s ON hy.`sub_id` = s.`id`
  50. <where>
  51. <if test="tickStatus == 1 "> and hd.tick_status in(0,1)</if>
  52. <if test="hxpapplyId != null "> and hd.hxpapply_id = #{hxpapplyId}</if>
  53. <if test="chemicalId != null "> and hd.chemical_id = #{chemicalId}</if>
  54. <if test="chemicalName != null and chemicalName != ''"> and hd.chemical_name like concat('%', #{chemicalName}, '%')</if>
  55. <if test="cabinetId != null "> and hd.cabinet_id = #{cabinetId}</if>
  56. <if test="applyNum != null "> and hd.apply_num = #{applyNum}</if>
  57. </where>
  58. </select>
  59. <select id="getListByIds" resultMap="ActHxpapplyDetailResult">
  60. <include refid="selectActHxpapplyDetailVo"/>
  61. <where>
  62. id in
  63. <foreach item="id" collection="list" open="(" separator="," close=")">
  64. #{id}
  65. </foreach>
  66. </where>
  67. </select>
  68. <select id="selectActHxpapplyDetailById" resultMap="ActHxpapplyDetailResult">
  69. <include refid="selectActHxpapplyDetailVo"/>
  70. where id = #{id}
  71. </select>
  72. <insert id="insertActHxpapplyDetail" parameterType="com.zd.chemical.domain.ActHxpapplyDetail" useGeneratedKeys="true" keyProperty="id">
  73. insert into act_hxpapply_detail
  74. <trim prefix="(" suffix=")" suffixOverrides=",">
  75. <if test="hxpapplyId != null">hxpapply_id,</if>
  76. <if test="chemicalId != null">chemical_id,</if>
  77. <if test="chemicalName != null">chemical_name,</if>
  78. <if test="cabinetId != null">cabinet_id,</if>
  79. <if test="applyNum != null">apply_num,</if>
  80. <if test="remainingStorage != null">remaining_storage,</if>
  81. <if test="tickStatus != null">tick_status,</if>
  82. </trim>
  83. <trim prefix="values (" suffix=")" suffixOverrides=",">
  84. <if test="hxpapplyId != null">#{hxpapplyId},</if>
  85. <if test="chemicalId != null">#{chemicalId},</if>
  86. <if test="chemicalName != null">#{chemicalName},</if>
  87. <if test="cabinetId != null">#{cabinetId},</if>
  88. <if test="applyNum != null">#{applyNum},</if>
  89. <if test="remainingStorage != null">#{remainingStorage},</if>
  90. <if test="tickStatus != null">#{tickStatus},</if>
  91. </trim>
  92. </insert>
  93. <update id="updateActHxpapplyDetail" parameterType="com.zd.chemical.domain.ActHxpapplyDetail">
  94. update act_hxpapply_detail
  95. <trim prefix="SET" suffixOverrides=",">
  96. <if test="hxpapplyId != null">hxpapply_id = #{hxpapplyId},</if>
  97. <if test="chemicalId != null">chemical_id = #{chemicalId},</if>
  98. <if test="chemicalName != null">chemical_name = #{chemicalName},</if>
  99. <if test="cabinetId != null">cabinet_id = #{cabinetId},</if>
  100. <if test="applyNum != null">apply_num = #{applyNum},</if>
  101. <if test="remainingStorage != null">remaining_storage = #{remainingStorage},</if>
  102. <if test="tickStatus != null">tick_status = #{tickStatus},</if>
  103. </trim>
  104. where id = #{id}
  105. </update>
  106. <update id="updateActHxpapplyDetailByPass" parameterType="com.zd.chemical.domain.ActHxpapplyDetail">
  107. update act_hxpapply_detail
  108. set tick_status=1
  109. where hxpapply_id = #{hxpapplyId}
  110. </update>
  111. <delete id="deleteActHxpapplyDetailById">
  112. delete from act_hxpapply_detail where id = #{id}
  113. </delete>
  114. <delete id="deleteActHxpapplyDetailByApplyId">
  115. delete from act_hxpapply_detail where hxpapply_id = #{id}
  116. </delete>
  117. <delete id="deleteActHxpapplyDetailByIds">
  118. delete from act_hxpapply_detail where id in
  119. <foreach item="id" collection="array" open="(" separator="," close=")">
  120. #{id}
  121. </foreach>
  122. </delete>
  123. </mapper>