TPssrMaterialRawMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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.ruoyi.project.pssr.mapper.TPssrMaterialRawMapper">
  6. <resultMap type="TPssrMaterialRaw" id="TPssrMaterialRawResult">
  7. <result property="id" column="id" />
  8. <result property="subId" column="sub_id" />
  9. <result property="approveId" column="approve_id" />
  10. <result property="rawMaterial" column="raw_material" />
  11. <result property="quantity" column="quantity" />
  12. <result property="unit" column="unit" />
  13. <result property="note" column="note" />
  14. <result property="confirm1" column="confirm1" />
  15. <result property="confirm2" column="confirm2" />
  16. <result property="confirmationDate" column="confirmation_date" />
  17. <result property="delFlag" column="del_flag" />
  18. <result property="createrCode" column="creater_code" />
  19. <result property="createdate" column="createdate" />
  20. <result property="updaterCode" column="updater_code" />
  21. <result property="updatedate" column="updatedate" />
  22. <result property="deptId" column="dept_id" />
  23. <result property="remarks" column="remarks" />
  24. <result property="approveStatus" column="approve_status" />
  25. <result property="deptName" column="dept_name" />
  26. <result property="confirm1Name" column="confirm1_name" />
  27. <result property="confirm2Name" column="confirm2_name" />
  28. </resultMap>
  29. <sql id="selectTPssrMaterialRawVo">
  30. select d.id, u1.nick_name confirm1_name, u2.nick_name confirm2_name, d.sub_id, d.approve_id, d.raw_material, d.quantity, d.unit, d.note, d.confirm1, d.confirm2, d.confirmation_date, d.del_flag, d.creater_code, d.createdate, d.updater_code, d.updatedate, d.dept_id, d.remarks, d.approve_status ,s.dept_name from t_pssr_material_raw d
  31. left join sys_dept s on s.dept_id = d.dept_id
  32. left join sys_user u1 on u1.user_id = d.CONFIRM1
  33. left join sys_user u2 on u2.user_id = d.CONFIRM2
  34. </sql>
  35. <select id="selectNoConfirmCount" parameterType="Long" resultType="int">
  36. select count(1) from t_pssr_Material_Raw d where sub_id = #{subId} and (confirm1 is null) and d.del_flag = 0
  37. </select>
  38. <select id="selectTPssrMaterialRawList" parameterType="TPssrMaterialRaw" resultMap="TPssrMaterialRawResult">
  39. <include refid="selectTPssrMaterialRawVo"/>
  40. <where>
  41. <if test="subId != null "> and sub_id = #{subId}</if>
  42. <if test="approveId != null "> and approve_id = #{approveId}</if>
  43. <if test="rawMaterial != null and rawMaterial != ''"> and raw_material = #{rawMaterial}</if>
  44. <if test="quantity != null and quantity != ''"> and quantity = #{quantity}</if>
  45. <if test="unit != null and unit != ''"> and unit = #{unit}</if>
  46. <if test="note != null and note != ''"> and note = #{note}</if>
  47. <if test="confirm1 != null and confirm1 != ''"> and confirm1 = #{confirm1}</if>
  48. <if test="confirm2 != null and confirm2 != ''"> and confirm2 = #{confirm2}</if>
  49. <if test="confirmationDate != null "> and confirmation_date = #{confirmationDate}</if>
  50. <if test="createrCode != null and createrCode != ''"> and creater_code = #{createrCode}</if>
  51. <if test="createdate != null "> and createdate = #{createdate}</if>
  52. <if test="updaterCode != null and updaterCode != ''"> and updater_code = #{updaterCode}</if>
  53. <if test="updatedate != null "> and updatedate = #{updatedate}</if>
  54. <if test="deptId != null "> and dept_id = #{deptId}</if>
  55. <if test="remarks != null"> and remarks = #{remarks}</if>
  56. <if test="approveStatus != null "> and approve_status = #{approveStatus}</if>
  57. and d.del_flag = 0
  58. </where>
  59. <!-- 数据范围过滤 -->
  60. ${params.dataScope}
  61. order by
  62. CASE
  63. WHEN confirm1 IS NULL AND confirm2 IS NULL THEN 0
  64. WHEN confirm1 IS NULL OR confirm2 IS NULL THEN 1
  65. ELSE 2
  66. END,id desc
  67. </select>
  68. <select id="selectTPssrMaterialRawById" parameterType="Long" resultMap="TPssrMaterialRawResult">
  69. <include refid="selectTPssrMaterialRawVo"/>
  70. where id = #{id}
  71. </select>
  72. <select id="selectAllConfirmedPersonBySubId" parameterType="TPssrMaterialRaw" resultMap="TPssrMaterialRawResult">
  73. SELECT
  74. LISTAGG(CONFIRM1, ',') WITHIN GROUP (ORDER BY CONFIRM1) AS CONFIRM1,
  75. LISTAGG(CONFIRM2, ',') WITHIN GROUP (ORDER BY CONFIRM2) AS CONFIRM2
  76. FROM (
  77. SELECT DISTINCT CONFIRM1, CONFIRM2 FROM t_pssr_material_raw WHERE sub_id = #{subId}
  78. <if test="approveStatus != null ">AND approve_status = #{approveStatus}</if>
  79. and del_flag = 0
  80. UNION
  81. SELECT DISTINCT CONFIRM1, CONFIRM2 FROM t_pssr_material WHERE sub_id = #{subId}
  82. <if test="approveStatus != null "> AND approve_status = #{approveStatus}</if>
  83. and del_flag = 0
  84. )
  85. </select>
  86. <insert id="insertTPssrMaterialRaw" parameterType="TPssrMaterialRaw">
  87. <selectKey keyProperty="id" resultType="long" order="BEFORE">
  88. SELECT seq_t_pssr_material_raw.NEXTVAL as id FROM DUAL
  89. </selectKey>
  90. insert into t_pssr_material_raw
  91. <trim prefix="(" suffix=")" suffixOverrides=",">
  92. <if test="id != null">id,</if>
  93. <if test="subId != null">sub_id,</if>
  94. <if test="approveId != null">approve_id,</if>
  95. <if test="rawMaterial != null">raw_material,</if>
  96. <if test="quantity != null">quantity,</if>
  97. <if test="unit != null">unit,</if>
  98. <if test="note != null">note,</if>
  99. <if test="confirm1 != null">confirm1,</if>
  100. <if test="confirm2 != null">confirm2,</if>
  101. <if test="confirmationDate != null">confirmation_date,</if>
  102. <if test="delFlag != null">del_flag,</if>
  103. <if test="createrCode != null">creater_code,</if>
  104. <if test="createdate != null">createdate,</if>
  105. <if test="updaterCode != null">updater_code,</if>
  106. <if test="updatedate != null">updatedate,</if>
  107. <if test="deptId != null">dept_id,</if>
  108. <if test="remarks != null">remarks,</if>
  109. <if test="approveStatus != null">approve_status,</if>
  110. </trim>
  111. <trim prefix="values (" suffix=")" suffixOverrides=",">
  112. <if test="id != null">#{id},</if>
  113. <if test="subId != null">#{subId},</if>
  114. <if test="approveId != null">#{approveId},</if>
  115. <if test="rawMaterial != null">#{rawMaterial},</if>
  116. <if test="quantity != null">#{quantity},</if>
  117. <if test="unit != null">#{unit},</if>
  118. <if test="note != null">#{note},</if>
  119. <if test="confirm1 != null">#{confirm1},</if>
  120. <if test="confirm2 != null">#{confirm2},</if>
  121. <if test="confirmationDate != null">#{confirmationDate},</if>
  122. <if test="delFlag != null">#{delFlag},</if>
  123. <if test="createrCode != null">#{createrCode},</if>
  124. <if test="createdate != null">#{createdate},</if>
  125. <if test="updaterCode != null">#{updaterCode},</if>
  126. <if test="updatedate != null">#{updatedate},</if>
  127. <if test="deptId != null">#{deptId},</if>
  128. <if test="remarks != null">#{remarks},</if>
  129. <if test="approveStatus != null">#{approveStatus},</if>
  130. </trim>
  131. </insert>
  132. <update id="updateAllBySubId" parameterType="TPssrMaterialRaw">
  133. update t_pssr_material_raw
  134. <trim prefix="SET" suffixOverrides=",">
  135. <if test="approveStatus != null">approve_status = #{approveStatus},</if>
  136. <if test="updaterCode != null">updater_code = #{updaterCode},</if>
  137. <if test="updatedate != null">updatedate = #{updatedate},</if>
  138. </trim>
  139. where sub_id= #{subId} and APPROVE_STATUS=0
  140. </update>
  141. <update id="updateTPssrMaterialRaw" parameterType="TPssrMaterialRaw">
  142. update t_pssr_material_raw
  143. <trim prefix="SET" suffixOverrides=",">
  144. <if test="subId != null">sub_id = #{subId},</if>
  145. <if test="approveId != null">approve_id = #{approveId},</if>
  146. <if test="rawMaterial != null">raw_material = #{rawMaterial},</if>
  147. <if test="quantity != null">quantity = #{quantity},</if>
  148. <if test="unit != null">unit = #{unit},</if>
  149. <if test="note != null">note = #{note},</if>
  150. <if test="confirm1 != null">confirm1 = #{confirm1},</if>
  151. <if test="confirm2 != null">confirm2 = #{confirm2},</if>
  152. <if test="confirmationDate != null">confirmation_date = #{confirmationDate},</if>
  153. <if test="delFlag != null">del_flag = #{delFlag},</if>
  154. <if test="createrCode != null">creater_code = #{createrCode},</if>
  155. <if test="createdate != null">createdate = #{createdate},</if>
  156. <if test="updaterCode != null">updater_code = #{updaterCode},</if>
  157. <if test="updatedate != null">updatedate = #{updatedate},</if>
  158. <if test="deptId != null">dept_id = #{deptId},</if>
  159. <if test="remarks != null ">remarks = #{remarks},</if>
  160. <if test="approveStatus != null">approve_status = #{approveStatus},</if>
  161. </trim>
  162. where id = #{id}
  163. </update>
  164. <update id="updateTPssrMaterialRawByIds" parameterType="TPssrMaterialRaw">
  165. update t_pssr_material_raw
  166. <trim prefix="SET" suffixOverrides=",">
  167. <if test="confirm1 != null">confirm1 = #{confirm1},</if>
  168. <if test="confirm2 != null">confirm2 = #{confirm2},</if>
  169. <if test="confirmationDate != null">confirmation_date = #{confirmationDate},</if>
  170. <if test="createrCode != null">creater_code = #{createrCode},</if>
  171. <if test="createdate != null">createdate = #{createdate},</if>
  172. <if test="updaterCode != null">updater_code = #{updaterCode},</if>
  173. <if test="updatedate != null">updatedate = #{updatedate},</if>
  174. <if test="remarks != null ">remarks = #{remarks},</if>
  175. </trim>
  176. where id in
  177. <foreach item="id" collection="ids" open="(" separator="," close=")">
  178. #{id}
  179. </foreach>
  180. </update>
  181. <update id="deleteTPssrMaterialRawById" parameterType="Long">
  182. update t_pssr_material_raw set del_flag = 2 where id = #{id}
  183. </update>
  184. <update id="deleteTPssrMaterialRawByIds" parameterType="String">
  185. update t_pssr_material_raw set del_flag = 2 where id in
  186. <foreach item="id" collection="array" open="(" separator="," close=")">
  187. #{id}
  188. </foreach>
  189. </update>
  190. </mapper>