TWarehouseMapper.xml 15 KB

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