TWarehouseMapper.xml 14 KB

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