TWarehouseMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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.basicData.mapper.TWarehouseMapper">
  6. <resultMap type="TWarehouse" id="TWarehouseResult">
  7. <result property="fId" column="f_id" />
  8. <result property="parentId" column="parent_id"/>
  9. <result property="ancestors" column="ancestors"/>
  10. <result property="orderNum" column="order_num"/>
  11. <result property="fNo" column="f_no" />
  12. <result property="fName" column="f_name" />
  13. <result property="fAddr" column="f_addr" />
  14. <result property="fTotalgross" column="f_totalgross" />
  15. <result property="fContacts" column="f_contacts" />
  16. <result property="fTel" column="f_tel" />
  17. <result property="fCharg" column="f_charg" />
  18. <result property="fStatus" column="f_status" />
  19. <result property="delFlag" column="del_flag" />
  20. <result property="createBy" column="create_by" />
  21. <result property="createTime" column="create_time" />
  22. <result property="updateBy" column="update_by" />
  23. <result property="updateTime" column="update_time" />
  24. <result property="remark" column="remark" />
  25. <result property="fLocation" column="f_location" />
  26. <result property="fWarehouseInformation" column="f_warehouse_information" />
  27. </resultMap>
  28. <sql id="selectTWarehouseVo">
  29. select f_id, parent_id, ancestors, order_num, f_no, f_name, f_addr, f_totalgross,f_contacts, f_tel, f_charg, f_status, del_flag, create_by, create_time, update_by, update_time, remark,f_location, f_warehouse_information from t_warehouse
  30. </sql>
  31. <select id="selectTWarehouseList" parameterType="TWarehouse" resultMap="TWarehouseResult">
  32. <include refid="selectTWarehouseVo"/>
  33. <where>
  34. <if test="parentId != null and parentId != ''"> and parent_id = #{parentId} </if>
  35. <if test="ancestors != null and ancestors != ''"> and ancestors like concat('%', #{ancestors}, '%')</if>
  36. <if test="fNo != null and fNo != ''"> and f_no like concat('%', #{fNo}, '%')</if>
  37. <if test="fName != null and fName != ''"> and f_name like concat('%', #{fName}, '%')</if>
  38. <if test="fAddr != null and fAddr != ''"> and f_addr like concat('%', #{fAddr}, '%')</if>
  39. <if test="fTotalgross != null "> and f_totalgross like concat('%', #{fTotalgross}, '%')</if>
  40. <if test="fContacts != null and fContacts != ''"> and f_contacts = #{fContacts}</if>
  41. <if test="fTel != null and fTel != ''"> and f_tel = #{fTel}</if>
  42. <if test="fCharg != null "> and f_charg = #{fCharg}</if>
  43. <if test="fStatus != null and fStatus != ''"> and f_status = #{fStatus}</if>
  44. </where>
  45. <!-- 数据范围过滤 -->
  46. ${params.dataScope}
  47. order by parent_id, order_num
  48. </select>
  49. <select id="selectTWarehouseLists" parameterType="TWarehouse" resultMap="TWarehouseResult">
  50. <include refid="selectTWarehouseVo"/>
  51. <where>
  52. parent_id = 100
  53. </where>
  54. </select>
  55. <select id="selectTWarehouseById" parameterType="Long" resultMap="TWarehouseResult">
  56. <include refid="selectTWarehouseVo"/>
  57. where f_id = #{fId}
  58. </select>
  59. <insert id="insertTWarehouse" parameterType="TWarehouse" useGeneratedKeys="true" keyProperty="fId">
  60. insert into t_warehouse
  61. <trim prefix="(" suffix=")" suffixOverrides=",">
  62. <if test="parentId != null and parentId != 0">parent_id,</if>
  63. <if test="ancestors != null and ancestors != ''">ancestors,</if>
  64. <if test="orderNum != null and orderNum != ''">order_num,</if>
  65. <if test="fNo != null and fNo != ''">f_no,</if>
  66. <if test="fName != null and fName != ''">f_name,</if>
  67. <if test="fAddr != null and fAddr != ''">f_addr,</if>
  68. <if test="fTotalgross != null">f_totalgross,</if>
  69. <if test="fContacts != null">f_contacts,</if>
  70. <if test="fTel != null">f_tel,</if>
  71. <if test="fCharg != null">f_charg,</if>
  72. <if test="fStatus != null">f_status,</if>
  73. <if test="delFlag != null">del_flag,</if>
  74. <if test="createBy != null">create_by,</if>
  75. <if test="createTime != null">create_time,</if>
  76. <if test="updateBy != null">update_by,</if>
  77. <if test="updateTime != null">update_time,</if>
  78. <if test="remark != null">remark,</if>
  79. <if test="fLocation != null">f_location,</if>
  80. <if test="fWarehouseInformation != null">f_warehouse_information,</if>
  81. </trim>
  82. <trim prefix="values (" suffix=")" suffixOverrides=",">
  83. <if test="parentId != null and parentId != 0">#{parentId},</if>
  84. <if test="ancestors != null and ancestors != ''">#{ancestors},</if>
  85. <if test="orderNum != null and orderNum != ''">#{orderNum},</if>
  86. <if test="fNo != null and fNo != ''">#{fNo},</if>
  87. <if test="fName != null and fName != ''">#{fName},</if>
  88. <if test="fAddr != null and fAddr != ''">#{fAddr},</if>
  89. <if test="fTotalgross != null">#{fTotalgross},</if>
  90. <if test="fContacts != null">#{fContacts},</if>
  91. <if test="fTel != null">#{fTel},</if>
  92. <if test="fCharg != null">#{fCharg},</if>
  93. <if test="fStatus != null">#{fStatus},</if>
  94. <if test="delFlag != null">#{delFlag},</if>
  95. <if test="createBy != null">#{createBy},</if>
  96. <if test="createTime != null">#{createTime},</if>
  97. <if test="updateBy != null">#{updateBy},</if>
  98. <if test="updateTime != null">#{updateTime},</if>
  99. <if test="remark != null">#{remark},</if>
  100. <if test="fLocation != null">#{fLocation},</if>
  101. <if test="fWarehouseInformation != null">#{fWarehouseInformation},</if>
  102. </trim>
  103. </insert>
  104. <update id="updateTWarehouse" parameterType="TWarehouse">
  105. update t_warehouse
  106. <trim prefix="SET" suffixOverrides=",">
  107. <if test="parentId != null and parentId != 0">parent_id = #{parentId},</if>
  108. <if test="ancestors != null and ancestors != ''">ancestors = #{ancestors},</if>
  109. <if test="orderNum != null and orderNum != ''">order_num = #{orderNum},</if>
  110. <if test="fNo != null and fNo != ''">f_no = #{fNo},</if>
  111. <if test="fName != null and fName != ''">f_name = #{fName},</if>
  112. <if test="fAddr != null and fAddr != ''">f_addr = #{fAddr},</if>
  113. <if test="fTotalgross != null">f_totalgross = #{fTotalgross},</if>
  114. <if test="fContacts != null">f_contacts = #{fContacts},</if>
  115. <if test="fTel != null">f_tel = #{fTel},</if>
  116. <if test="fCharg != null">f_charg = #{fCharg},</if>
  117. <if test="fStatus != null">f_status = #{fStatus},</if>
  118. <if test="delFlag != null">del_flag = #{delFlag},</if>
  119. <if test="createBy != null">create_by = #{createBy},</if>
  120. <if test="createTime != null">create_time = #{createTime},</if>
  121. <if test="updateBy != null">update_by = #{updateBy},</if>
  122. <if test="updateTime != null">update_time = #{updateTime},</if>
  123. <if test="remark != null">remark = #{remark},</if>
  124. <if test="fLocation != null">f_location = #{fLocation},</if>
  125. <if test="fWarehouseInformation != null">f_warehouse_information = #{fWarehouseInformation},</if>
  126. </trim>
  127. where f_id = #{fId}
  128. </update>
  129. <delete id="deleteTWarehouseById" parameterType="Long">
  130. delete from t_warehouse where f_id = #{fId}
  131. </delete>
  132. <delete id="deleteTWarehouseByIds" parameterType="String">
  133. delete from t_warehouse where f_id in
  134. <foreach item="fId" collection="array" open="(" separator="," close=")">
  135. #{fId}
  136. </foreach>
  137. </delete>
  138. <select id="checkFNoUnique" parameterType="String" resultMap="TWarehouseResult">
  139. select f_id,f_no from t_warehouse where f_no = #{fNo} limit 1
  140. </select>
  141. <select id="checkUFNnameUnique" parameterType="String" resultMap="TWarehouseResult">
  142. select f_id,f_name from t_warehouse where f_name = #{fAame} limit 1
  143. </select>
  144. <select id="checkUFAaddrUnique" parameterType="String" resultMap="TWarehouseResult">
  145. select f_id,f_addr from t_warehouse where f_addr = #{fAddr} limit 1
  146. </select>
  147. <select id="selectNormalChildrenDeptById" parameterType="Long" resultType="int">
  148. select count(*) from t_warehouse where f_status = 0 and del_flag = '0' and find_in_set(#{fId}, ancestors)
  149. </select>
  150. <select id="selectChildrenDeptById" parameterType="Long" resultMap="TWarehouseResult">
  151. select * from t_warehouse where find_in_set(#{fId}, ancestors)
  152. </select>
  153. <select id="selectTWarehousById" resultMap="TWarehouseResult">
  154. select f_id from t_warehouse where parent_id = #{fId} limit 1
  155. </select>
  156. <update id="updateDeptChildren" parameterType="java.util.List">
  157. update t_warehouse set ancestors =
  158. <foreach collection="depts" item="item" index="index"
  159. separator=" " open="case f_id" close="end">
  160. when #{item.fId} then #{item.ancestors}
  161. </foreach>
  162. where f_id in
  163. <foreach collection="depts" item="item" index="index"
  164. separator="," open="(" close=")">
  165. #{item.fId}
  166. </foreach>
  167. </update>
  168. <update id="updateDeptStatus" parameterType="TWarehouse">
  169. update t_warehouse
  170. <set>
  171. <if test="fStatus != null and fStatus != ''">f_status = #{fStatus},</if>
  172. <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
  173. update_time = sysdate()
  174. </set>
  175. where f_id in (${ancestors})
  176. </update>
  177. <update id="updatefTotalgross">
  178. update t_warehouse
  179. <set>
  180. <if test="fTotalgross != null and fTotalgross != ''">f_totalgross = #{fTotalgross},</if>
  181. update_time = sysdate()
  182. </set>
  183. where f_id = #{fId}
  184. </update>
  185. <select id="selectTWarehouseFTotalgross" resultType="java.math.BigDecimal">
  186. SELECT
  187. sum( f_totalgross ) AS fTotalgross
  188. FROM
  189. t_warehouse
  190. WHERE
  191. ancestors LIKE concat('%',#{fId}, '%')
  192. </select>
  193. <select id="checkDeptNameUnique" resultMap="TWarehouseResult">
  194. <include refid="selectTWarehouseVo"/>
  195. where f_name=#{fName} and parent_id = #{parentId} limit 1
  196. </select>
  197. <select id="hasChildByfId" parameterType="Long" resultType="int">
  198. select count(1) from t_warehouse
  199. where del_flag = '0' and parent_id = #{fId} limit 1
  200. </select>
  201. <select id="checkDeptExistarehouse" parameterType="Long" resultType="int">
  202. select count(1) from t_warehousebills where f_warehouseid = #{fId} and del_flag = '0'
  203. </select>
  204. <select id="checkDeptExistWarehouseItems" parameterType="Long" resultType="int">
  205. select count(1) from t_warehousebillsitems where f_warehouselocid = #{fId} and del_flag = '0'
  206. </select>
  207. </mapper>