TWarehouseMapper.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  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="selectTWarehouseById" parameterType="Long" resultMap="TWarehouseResult">
  103. <include refid="selectTWarehouseVo"/>
  104. where f_id = #{fId}
  105. </select>
  106. <insert id="insertTWarehouse" parameterType="TWarehouse" useGeneratedKeys="true" keyProperty="fId">
  107. insert into t_warehouse
  108. <trim prefix="(" suffix=")" suffixOverrides=",">
  109. <if test="parentId != null and parentId != 0">parent_id,</if>
  110. <if test="ancestors != null and ancestors != ''">ancestors,</if>
  111. <if test="orderNum != null and orderNum != ''">order_num,</if>
  112. <if test="fNo != null and fNo != ''">f_no,</if>
  113. <if test="fIsBonded != null and fIsBonded != ''">f_is_bonded,</if>
  114. <if test="fName != null and fName != ''">f_name,</if>
  115. <if test="fAddr != null and fAddr != ''">f_addr,</if>
  116. <if test="fTotalgross != null">f_totalgross,</if>
  117. <if test="fContacts != null">f_contacts,</if>
  118. <if test="fTel != null">f_tel,</if>
  119. <if test="fCharg != null">f_charg,</if>
  120. <if test="fStatus != null">f_status,</if>
  121. <if test="delFlag != null">del_flag,</if>
  122. <if test="createBy != null">create_by,</if>
  123. <if test="createTime != null">create_time,</if>
  124. <if test="updateBy != null">update_by,</if>
  125. <if test="updateTime != null">update_time,</if>
  126. <if test="remark != null">remark,</if>
  127. <if test="fLocation != null">f_location,</if>
  128. <if test="fWarehouseInformation != null">f_warehouse_information,</if>
  129. </trim>
  130. <trim prefix="values (" suffix=")" suffixOverrides=",">
  131. <if test="parentId != null and parentId != 0">#{parentId},</if>
  132. <if test="ancestors != null and ancestors != ''">#{ancestors},</if>
  133. <if test="orderNum != null and orderNum != ''">#{orderNum},</if>
  134. <if test="fNo != null and fNo != ''">#{fNo},</if>
  135. <if test="fIsBonded != null and fIsBonded != ''">#{fIsBonded},</if>
  136. <if test="fName != null and fName != ''">#{fName},</if>
  137. <if test="fAddr != null and fAddr != ''">#{fAddr},</if>
  138. <if test="fTotalgross != null">#{fTotalgross},</if>
  139. <if test="fContacts != null">#{fContacts},</if>
  140. <if test="fTel != null">#{fTel},</if>
  141. <if test="fCharg != null">#{fCharg},</if>
  142. <if test="fStatus != null">#{fStatus},</if>
  143. <if test="delFlag != null">#{delFlag},</if>
  144. <if test="createBy != null">#{createBy},</if>
  145. <if test="createTime != null">#{createTime},</if>
  146. <if test="updateBy != null">#{updateBy},</if>
  147. <if test="updateTime != null">#{updateTime},</if>
  148. <if test="remark != null">#{remark},</if>
  149. <if test="fLocation != null">#{fLocation},</if>
  150. <if test="fWarehouseInformation != null">#{fWarehouseInformation},</if>
  151. </trim>
  152. </insert>
  153. <update id="updateTWarehouse" parameterType="TWarehouse">
  154. update t_warehouse
  155. <trim prefix="SET" suffixOverrides=",">
  156. <if test="parentId != null and parentId != 0">parent_id = #{parentId},</if>
  157. <if test="ancestors != null and ancestors != ''">ancestors = #{ancestors},</if>
  158. <if test="orderNum != null and orderNum != ''">order_num = #{orderNum},</if>
  159. <if test="fNo != null and fNo != ''">f_no = #{fNo},</if>
  160. <if test="fIsBonded != null and fIsBonded != ''">f_is_bonded = #{fIsBonded},</if>
  161. <if test="fName != null and fName != ''">f_name = #{fName},</if>
  162. <if test="fAddr != null and fAddr != ''">f_addr = #{fAddr},</if>
  163. <if test="fTotalgross != null">f_totalgross = #{fTotalgross},</if>
  164. <if test="fContacts != null">f_contacts = #{fContacts},</if>
  165. <if test="fTel != null">f_tel = #{fTel},</if>
  166. <if test="fCharg != null">f_charg = #{fCharg},</if>
  167. <if test="fStatus != null">f_status = #{fStatus},</if>
  168. <if test="delFlag != null">del_flag = #{delFlag},</if>
  169. <if test="createBy != null">create_by = #{createBy},</if>
  170. <if test="createTime != null">create_time = #{createTime},</if>
  171. <if test="updateBy != null">update_by = #{updateBy},</if>
  172. <if test="updateTime != null">update_time = #{updateTime},</if>
  173. <if test="remark != null">remark = #{remark},</if>
  174. <if test="fLocation != null">f_location = #{fLocation},</if>
  175. <if test="fWarehouseInformation != null">f_warehouse_information = #{fWarehouseInformation},</if>
  176. </trim>
  177. where f_id = #{fId}
  178. </update>
  179. <delete id="deleteTWarehouseById" parameterType="Long">
  180. delete
  181. from t_warehouse
  182. where f_id = #{fId}
  183. </delete>
  184. <delete id="deleteTWarehouseByIds" parameterType="String">
  185. delete from t_warehouse where f_id in
  186. <foreach item="fId" collection="array" open="(" separator="," close=")">
  187. #{fId}
  188. </foreach>
  189. </delete>
  190. <select id="checkFNoUnique" parameterType="String" resultMap="TWarehouseResult">
  191. select f_id, f_no
  192. from t_warehouse
  193. where f_no = #{fNo}
  194. limit 1
  195. </select>
  196. <select id="checkUFNnameUnique" parameterType="String" resultMap="TWarehouseResult">
  197. select f_id, f_name
  198. from t_warehouse
  199. where f_name = #{fAame}
  200. limit 1
  201. </select>
  202. <select id="checkUFAaddrUnique" parameterType="String" resultMap="TWarehouseResult">
  203. select f_id, f_addr
  204. from t_warehouse
  205. where f_addr = #{fAddr}
  206. limit 1
  207. </select>
  208. <select id="selectNormalChildrenDeptById" parameterType="Long" resultType="int">
  209. select count(*)
  210. from t_warehouse
  211. where f_status = 0
  212. and del_flag = '0'
  213. and find_in_set(#{fId}, ancestors)
  214. </select>
  215. <select id="selectChildrenDeptById" parameterType="Long" resultMap="TWarehouseResult">
  216. select *
  217. from t_warehouse
  218. where find_in_set(#{fId}, ancestors)
  219. </select>
  220. <select id="selectTWarehousById" resultMap="TWarehouseResult">
  221. select f_id
  222. from t_warehouse
  223. where parent_id = #{fId}
  224. limit 1
  225. </select>
  226. <update id="updateDeptChildren" parameterType="java.util.List">
  227. update t_warehouse set ancestors =
  228. <foreach collection="depts" item="item" index="index"
  229. separator=" " open="case f_id" close="end">
  230. when #{item.fId} then #{item.ancestors}
  231. </foreach>
  232. where f_id in
  233. <foreach collection="depts" item="item" index="index"
  234. separator="," open="(" close=")">
  235. #{item.fId}
  236. </foreach>
  237. </update>
  238. <update id="updateDeptStatus" parameterType="TWarehouse">
  239. update t_warehouse
  240. <set>
  241. <if test="fStatus != null and fStatus != ''">f_status = #{fStatus},</if>
  242. <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
  243. update_time = sysdate()
  244. </set>
  245. where f_id in (${ancestors})
  246. </update>
  247. <update id="updatefTotalgross">
  248. update t_warehouse
  249. <set>
  250. <if test="fTotalgross != null and fTotalgross != ''">f_totalgross = #{fTotalgross},</if>
  251. update_time = sysdate()
  252. </set>
  253. where f_id = #{fId}
  254. </update>
  255. <select id="selectTWarehouseFTotalgross" resultType="java.math.BigDecimal">
  256. SELECT sum(f_totalgross) AS fTotalgross
  257. FROM t_warehouse
  258. WHERE ancestors LIKE concat('%', #{fId}, '%')
  259. </select>
  260. <select id="checkDeptNameUnique" resultMap="TWarehouseResult">
  261. <include refid="selectTWarehouseVo"/>
  262. where f_name=#{fName} and parent_id = #{parentId} limit 1
  263. </select>
  264. <select id="hasChildByfId" parameterType="Long" resultType="int">
  265. select count(1)
  266. from t_warehouse
  267. where del_flag = '0'
  268. and parent_id = #{fId}
  269. limit 1
  270. </select>
  271. <select id="checkDeptExistarehouse" parameterType="Long" resultType="int">
  272. select count(1)
  273. from t_warehousebills
  274. where f_warehouseid = #{fId}
  275. and del_flag = '0'
  276. </select>
  277. <select id="checkDeptExistWarehouseItems" parameterType="Long" resultType="int">
  278. select count(1)
  279. from t_warehousebillsitems
  280. where f_warehouselocid = #{fId}
  281. and del_flag = '0'
  282. </select>
  283. <select id="selectByIds" resultMap="TWarehouseResult">
  284. <include refid="selectTWarehouseVo"/>
  285. where f_id in
  286. <foreach item="id" collection="ids" open="(" separator="," close=")">
  287. #{id}
  288. </foreach>
  289. </select>
  290. </mapper>