TWarehouseMapper.xml 12 KB

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