TWarehouseMapper.xml 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833
  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. <result property="supervise" column="supervise"/>
  31. </resultMap>
  32. <sql id="selectTWarehouseVo">
  33. select f_id,
  34. parent_id,
  35. ancestors,
  36. order_num,
  37. f_no,
  38. f_is_bonded,
  39. f_name,
  40. f_cname,
  41. f_addr,
  42. f_totalgross,
  43. f_contacts,
  44. f_tel,
  45. f_charg,
  46. f_status,
  47. del_flag,
  48. create_by,
  49. create_time,
  50. update_by,
  51. update_time,
  52. remark,
  53. f_location,
  54. f_warehouse_information,
  55. supervise
  56. from t_warehouse
  57. </sql>
  58. <select id="selectTWarehouseList" parameterType="TWarehouse" resultMap="TWarehouseResult">
  59. <include refid="selectTWarehouseVo"/>
  60. <where>
  61. <if test="parentId != null and parentId != ''">and parent_id = #{parentId}</if>
  62. <if test="fIsBonded != null and fIsBonded != ''">and f_is_bonded = #{fIsBonded}</if>
  63. <if test="ancestors != null and ancestors != ''">and ancestors like concat('%', #{ancestors}, '%')</if>
  64. <if test="fNo != null and fNo != ''">and f_no like concat('%', #{fNo}, '%')</if>
  65. <if test="fName != null and fName != ''">and f_name like concat('%', #{fName}, '%')</if>
  66. <if test="fCname != null and fCname != ''">and f_cname like concat('%', #{fCname}, '%')</if>
  67. <if test="fAddr != null and fAddr != ''">and f_addr like concat('%', #{fAddr}, '%')</if>
  68. <if test="fTotalgross != null ">and f_totalgross like concat('%', #{fTotalgross}, '%')</if>
  69. <if test="fContacts != null and fContacts != ''">and f_contacts = #{fContacts}</if>
  70. <if test="fTel != null and fTel != ''">and f_tel = #{fTel}</if>
  71. <if test="fCharg != null ">and f_charg = #{fCharg}</if>
  72. <if test="fStatus != null and fStatus != ''">and f_status = #{fStatus}</if>
  73. <if test="supervise != null and supervise != ''">and supervise = #{supervise}</if>
  74. </where>
  75. <!-- 数据范围过滤 -->
  76. ${params.dataScope}
  77. order by parent_id, order_num, convert(f_name using gbk)
  78. </select>
  79. <select id="lazyList" parameterType="TWarehouse" resultMap="TWarehouseResult">
  80. select
  81. 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,
  82. ware.f_addr, ware.f_contacts, ware.f_tel, ware.f_charg, ware.f_is_bonded, ware.remark, ware.supervise, ware.f_status,
  83. (
  84. SELECT
  85. CASE WHEN count( 1 ) > 0 THEN 1 ELSE 0 END
  86. FROM
  87. t_warehouse
  88. WHERE
  89. parent_id = ware.f_id AND del_flag = '0'
  90. ) AS "has_children"
  91. from t_warehouse ware
  92. <where>
  93. <if test="parentId != null">and ware.parent_id = #{parentId}</if>
  94. <if test="fNo != null and fNo != ''">and ware.f_no like concat('%', #{fNo}, '%')</if>
  95. <if test="fName != null and fName != ''">and ware.f_name like concat('%', #{fName}, '%')</if>
  96. <if test="fCname != null and fCname != ''">and ware.f_cname like concat('%', #{fCname}, '%')</if>
  97. <if test="fStatus != null and fStatus != ''">and ware.f_status = #{fStatus}</if>
  98. <if test="supervise != null and supervise != ''">and ware.supervise = #{supervise}</if>
  99. </where>
  100. <!-- 数据范围过滤 -->
  101. ${params.dataScope}
  102. order by ware.parent_id, ware.order_num, convert(ware.f_name using gbk)
  103. </select>
  104. <select id="selectTWarehouseLists" parameterType="TWarehouse" resultMap="TWarehouseResult">
  105. <include refid="selectTWarehouseVo"/>
  106. <where>
  107. parent_id = 100
  108. </where>
  109. </select>
  110. <select id="appGetWarehouseList" resultType="map">
  111. SELECT
  112. f_id AS fId,
  113. f_name AS fName
  114. FROM t_warehouse
  115. WHERE parent_id = 100
  116. <if test="corpId != null and corpId != ''">
  117. AND f_id IN (SELECT DISTINCT f_warehouseid FROM t_whgenleg WHERE f_corpid = #{corpId})
  118. </if>
  119. </select>
  120. <select id="selectTWarehouseById" parameterType="Long" resultMap="TWarehouseResult">
  121. <include refid="selectTWarehouseVo"/>
  122. where f_id = #{fId}
  123. </select>
  124. <insert id="insertTWarehouse" parameterType="TWarehouse" useGeneratedKeys="true" keyProperty="fId">
  125. insert into t_warehouse
  126. <trim prefix="(" suffix=")" suffixOverrides=",">
  127. <if test="parentId != null and parentId != 0">parent_id,</if>
  128. <if test="ancestors != null and ancestors != ''">ancestors,</if>
  129. <if test="orderNum != null and orderNum != ''">order_num,</if>
  130. <if test="fNo != null and fNo != ''">f_no,</if>
  131. <if test="fIsBonded != null and fIsBonded != ''">f_is_bonded,</if>
  132. <if test="fName != null and fName != ''">f_name,</if>
  133. <if test="fCname != null and fCname != ''">f_cname,</if>
  134. <if test="fAddr != null and fAddr != ''">f_addr,</if>
  135. <if test="fTotalgross != null">f_totalgross,</if>
  136. <if test="fContacts != null">f_contacts,</if>
  137. <if test="fTel != null">f_tel,</if>
  138. <if test="fCharg != null">f_charg,</if>
  139. <if test="fStatus != null">f_status,</if>
  140. <if test="delFlag != null">del_flag,</if>
  141. <if test="createBy != null">create_by,</if>
  142. <if test="createTime != null">create_time,</if>
  143. <if test="updateBy != null">update_by,</if>
  144. <if test="updateTime != null">update_time,</if>
  145. <if test="remark != null">remark,</if>
  146. <if test="fLocation != null">f_location,</if>
  147. <if test="fWarehouseInformation != null">f_warehouse_information,</if>
  148. <if test="supervise != null">supervise,</if>
  149. </trim>
  150. <trim prefix="values (" suffix=")" suffixOverrides=",">
  151. <if test="parentId != null and parentId != 0">#{parentId},</if>
  152. <if test="ancestors != null and ancestors != ''">#{ancestors},</if>
  153. <if test="orderNum != null and orderNum != ''">#{orderNum},</if>
  154. <if test="fNo != null and fNo != ''">#{fNo},</if>
  155. <if test="fIsBonded != null and fIsBonded != ''">#{fIsBonded},</if>
  156. <if test="fName != null and fName != ''">#{fName},</if>
  157. <if test="fCname != null and fCname != ''">#{fCname},</if>
  158. <if test="fAddr != null and fAddr != ''">#{fAddr},</if>
  159. <if test="fTotalgross != null">#{fTotalgross},</if>
  160. <if test="fContacts != null">#{fContacts},</if>
  161. <if test="fTel != null">#{fTel},</if>
  162. <if test="fCharg != null">#{fCharg},</if>
  163. <if test="fStatus != null">#{fStatus},</if>
  164. <if test="delFlag != null">#{delFlag},</if>
  165. <if test="createBy != null">#{createBy},</if>
  166. <if test="createTime != null">#{createTime},</if>
  167. <if test="updateBy != null">#{updateBy},</if>
  168. <if test="updateTime != null">#{updateTime},</if>
  169. <if test="remark != null">#{remark},</if>
  170. <if test="fLocation != null">#{fLocation},</if>
  171. <if test="fWarehouseInformation != null">#{fWarehouseInformation},</if>
  172. <if test="supervise != null">#{supervise},</if>
  173. </trim>
  174. </insert>
  175. <update id="updateTWarehouse" parameterType="TWarehouse">
  176. update t_warehouse
  177. <trim prefix="SET" suffixOverrides=",">
  178. <if test="parentId != null and parentId != 0">parent_id = #{parentId},</if>
  179. <if test="ancestors != null and ancestors != ''">ancestors = #{ancestors},</if>
  180. <if test="orderNum != null and orderNum != ''">order_num = #{orderNum},</if>
  181. <if test="fNo != null and fNo != ''">f_no = #{fNo},</if>
  182. <if test="fIsBonded != null and fIsBonded != ''">f_is_bonded = #{fIsBonded},</if>
  183. <if test="fName != null and fName != ''">f_name = #{fName},</if>
  184. <if test="fCname != null and fCname != ''">f_cname = #{fCname},</if>
  185. <if test="fAddr != null and fAddr != ''">f_addr = #{fAddr},</if>
  186. <if test="fTotalgross != null">f_totalgross = #{fTotalgross},</if>
  187. <if test="fContacts != null">f_contacts = #{fContacts},</if>
  188. <if test="fTel != null">f_tel = #{fTel},</if>
  189. <if test="fCharg != null">f_charg = #{fCharg},</if>
  190. <if test="fStatus != null">f_status = #{fStatus},</if>
  191. <if test="delFlag != null">del_flag = #{delFlag},</if>
  192. <if test="createBy != null">create_by = #{createBy},</if>
  193. <if test="createTime != null">create_time = #{createTime},</if>
  194. <if test="updateBy != null">update_by = #{updateBy},</if>
  195. <if test="updateTime != null">update_time = #{updateTime},</if>
  196. <if test="remark != null">remark = #{remark},</if>
  197. <if test="fLocation != null">f_location = #{fLocation},</if>
  198. <if test="fWarehouseInformation != null">f_warehouse_information = #{fWarehouseInformation},</if>
  199. <if test="supervise != null">supervise = #{supervise},</if>
  200. </trim>
  201. where f_id = #{fId}
  202. </update>
  203. <delete id="deleteTWarehouseById" parameterType="Long">
  204. delete
  205. from t_warehouse
  206. where f_id = #{fId}
  207. </delete>
  208. <delete id="deleteTWarehouseByIds" parameterType="String">
  209. delete from t_warehouse where f_id in
  210. <foreach item="fId" collection="array" open="(" separator="," close=")">
  211. #{fId}
  212. </foreach>
  213. </delete>
  214. <select id="checkFNoUnique" parameterType="String" resultMap="TWarehouseResult">
  215. select f_id, f_no
  216. from t_warehouse
  217. where f_no = #{fNo}
  218. limit 1
  219. </select>
  220. <select id="checkUFNnameUnique" parameterType="String" resultMap="TWarehouseResult">
  221. select f_id, f_name
  222. from t_warehouse
  223. where f_name = #{fAame}
  224. limit 1
  225. </select>
  226. <select id="checkUFAaddrUnique" parameterType="String" resultMap="TWarehouseResult">
  227. select f_id, f_addr
  228. from t_warehouse
  229. where f_addr = #{fAddr}
  230. limit 1
  231. </select>
  232. <select id="selectNormalChildrenDeptById" parameterType="Long" resultType="int">
  233. select count(*)
  234. from t_warehouse
  235. where f_status = 0
  236. and del_flag = '0'
  237. and find_in_set(#{fId}, ancestors)
  238. </select>
  239. <select id="selectChildrenDeptById" parameterType="Long" resultMap="TWarehouseResult">
  240. select *
  241. from t_warehouse
  242. where find_in_set(#{fId}, ancestors)
  243. </select>
  244. <select id="selectTWarehousById" resultMap="TWarehouseResult">
  245. select f_id
  246. from t_warehouse
  247. where parent_id = #{fId}
  248. limit 1
  249. </select>
  250. <update id="updateDeptChildren" parameterType="java.util.List">
  251. update t_warehouse set ancestors =
  252. <foreach collection="depts" item="item" index="index"
  253. separator=" " open="case f_id" close="end">
  254. when #{item.fId} then #{item.ancestors}
  255. </foreach>
  256. where f_id in
  257. <foreach collection="depts" item="item" index="index"
  258. separator="," open="(" close=")">
  259. #{item.fId}
  260. </foreach>
  261. </update>
  262. <update id="updateDeptStatus" parameterType="TWarehouse">
  263. update t_warehouse
  264. <set>
  265. <if test="fStatus != null and fStatus != ''">f_status = #{fStatus},</if>
  266. <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
  267. update_time = sysdate()
  268. </set>
  269. where f_id in (${ancestors})
  270. </update>
  271. <update id="updatefTotalgross">
  272. update t_warehouse
  273. <set>
  274. <if test="fTotalgross != null and fTotalgross != ''">f_totalgross = #{fTotalgross},</if>
  275. update_time = sysdate()
  276. </set>
  277. where f_id = #{fId}
  278. </update>
  279. <select id="selectTWarehouseFTotalgross" resultType="java.math.BigDecimal">
  280. SELECT sum(f_totalgross) AS fTotalgross
  281. FROM t_warehouse
  282. WHERE ancestors LIKE concat('%', #{fId}, '%')
  283. </select>
  284. <select id="checkDeptNameUnique" resultMap="TWarehouseResult">
  285. <include refid="selectTWarehouseVo"/>
  286. where f_name=#{fName} and parent_id = #{parentId} limit 1
  287. </select>
  288. <select id="hasChildByfId" parameterType="Long" resultType="int">
  289. select count(1)
  290. from t_warehouse
  291. where del_flag = '0'
  292. and parent_id = #{fId}
  293. limit 1
  294. </select>
  295. <select id="checkDeptExistarehouse" parameterType="Long" resultType="int">
  296. select count(1)
  297. from t_warehousebills
  298. where f_warehouseid = #{fId}
  299. and del_flag = '0'
  300. </select>
  301. <select id="checkDeptExistWarehouseItems" parameterType="Long" resultType="int">
  302. select count(1)
  303. from t_warehousebillsitems
  304. where f_warehouselocid = #{fId}
  305. and del_flag = '0'
  306. </select>
  307. <select id="selectByIds" resultMap="TWarehouseResult">
  308. <include refid="selectTWarehouseVo"/>
  309. where f_id in
  310. <foreach item="id" collection="ids" open="(" separator="," close=")">
  311. #{id}
  312. </foreach>
  313. </select>
  314. <select id="biWarehouseList" resultType="map">
  315. select
  316. f_id as warehouseId,
  317. f_name as warehouseName
  318. from t_warehouse
  319. where parent_id = 100
  320. <if test="external != null and external != ''">
  321. and f_id in (
  322. select distinct f_warehouseid
  323. from t_customer_contact t1 left join t_whgenleg t2 on t1.f_pid = t2.f_corpid
  324. where f_tel = #{external})
  325. </if>
  326. order by convert(f_name using gbk)
  327. </select>
  328. <select id="getWarehouseByNo" parameterType="String" resultMap="TWarehouseResult">
  329. <include refid="selectTWarehouseVo"/>
  330. <where>
  331. f_id = #{fNo} and del_flag = '0' limit 1
  332. </where>
  333. </select>
  334. <select id="queryGoodsAccountByPageV1" resultType="map">
  335. SELECT
  336. TW.f_id AS warehouseCode,
  337. TW.f_name AS warehouseName,
  338. TC.uscc AS ownerSocialIdentifier,
  339. TC.f_id AS ownerCode,
  340. TC.f_name AS ownerName,
  341. TG.f_name AS goodsName,
  342. TG.f_packagespecs AS specifications,
  343. '' AS producing,
  344. TWG.f_marks AS materialQuality,
  345. '' AS LEVEL,
  346. SUM(TWG.f_qtyD) AS totalQuantity,
  347. SUM(TWG.f_qtyblc) AS availableQuantity,
  348. '袋' AS quantityUnit,
  349. IFNULL( ROUND( SUM(TWG.f_netweightD) / 1000, 2 ), 0 ) AS totalNetWeight,
  350. IFNULL( ROUND( SUM(TWG.f_netweightblc) / 1000, 2 ), 0 ) AS availableWeight,
  351. '吨' AS weightUnit,
  352. CONCAT_WS('-',IFNULL( TG.f_name, '' ),CONCAT_WS( IFNULL( TG.f_packagespecs, '' ), '/袋' ),IFNULL( TWG.f_marks, '' )) AS spu
  353. FROM t_warehouse TW
  354. LEFT JOIN t_whgenleg TWG ON TWG.f_warehouseid = TW.f_id
  355. LEFT JOIN t_corps TC ON TC.f_id = TWG.f_corpid
  356. LEFT JOIN t_goods TG ON TG.f_id = TWG.f_goodsid
  357. <where>
  358. TW.del_flag = '0'
  359. and TWG.f_qtyblc > 0
  360. <if test="warehouseCode != null and warehouseCode != ''"> and TW.f_id = #{warehouseCode}</if>
  361. <if test="ownerName != null and ownerName != ''"> and TC.f_name like concat('%', #{ownerName}, '%')</if>
  362. <if test="goodsName != null and goodsName != ''"> and TG.f_name like concat('%', #{goodsName}, '%')</if>
  363. <if test="specifications != null and specifications != ''"> and TG.f_packagespecs like concat('%', #{specifications}, '%')</if>
  364. <if test="materialQuality != null and materialQuality != ''"> and TWG.f_marks like concat('%', #{materialQuality}, '%')</if>
  365. <if test="ownerSocialIdentifier != null and ownerSocialIdentifier != ''"> and TC.uscc = #{ownerSocialIdentifier}</if>
  366. <if test="ownerCode != null and ownerCode != ''"> and TC.f_id = #{ownerCode}</if>
  367. </where>
  368. GROUP BY
  369. TW.f_id,TC.f_no,TG.f_name,TG.f_packagespecs,TWG.f_marks
  370. </select>
  371. <select id="queryGoodsAccountDetailByPageV1" resultType="map">
  372. SELECT
  373. DISTINCT
  374. TWG.f_id AS id,
  375. TW.f_id AS warehouseCode,
  376. TW.f_name AS warehouseName,
  377. ware.f_name AS areaName,
  378. ware.f_id AS areaCode,
  379. ware.f_name AS slotName,
  380. ware.f_id AS slotCode,
  381. TWG.f_originalbillno AS receiptDoc,
  382. TWG.f_mblno AS billOfLading,
  383. TC.f_id AS ownerCode,
  384. TC.f_name AS ownerName,
  385. TC.uscc AS ownerSocialIdentifier,
  386. TG.f_name AS goodsName,
  387. TG.f_packagespecs AS specifications,
  388. '' AS producing,
  389. TWG.f_marks AS materialQuality,
  390. '' AS LEVEL,
  391. TWG.f_qtyD AS totalQuantity,
  392. TWG.f_qtyblc AS availableQuantity,
  393. '袋' AS quantityUnit,
  394. IFNULL( ROUND( TWG.f_netweightD / 1000, 2 ), 0 ) AS totalNetWeight,
  395. IFNULL( ROUND( TWG.f_netweightblc / 1000, 2 ), 0 ) AS availableWeight,
  396. '吨' AS weightUnit,
  397. TWG.f_originalbilldate AS storesTime,
  398. '' AS productionTime,
  399. TWB.f_truckno AS plateNumber,
  400. '' AS batchNo,
  401. '' AS warehouseReceiptNo
  402. FROM
  403. t_whgenleg TWG
  404. LEFT JOIN t_warehouse TW ON TWG.f_warehouseid = TW.f_id
  405. LEFT JOIN t_warehouse ware ON ware.f_id = TWG.f_warehouse_locationid
  406. LEFT JOIN t_corps TC ON TC.f_id = TWG.f_corpid
  407. LEFT JOIN t_goods TG ON TG.f_id = TWG.f_goodsid
  408. LEFT JOIN t_warehousebills TWB ON TWG.f_originalbillno = TWB.f_billno
  409. <where>
  410. TW.del_flag = '0'
  411. and TWG.f_qtyblc > 0
  412. <if test="warehouseCode != null and warehouseCode != ''"> and TWG.f_warehouseid = #{warehouseCode}</if>
  413. <if test="ownerName != null and ownerName != ''"> and TC.f_name like concat('%', #{ownerName}, '%')</if>
  414. <if test="ownerCode != null and ownerCode != ''"> and TC.f_id = #{ownerCode}</if>
  415. <if test="ownerSocialIdentifier != null and ownerSocialIdentifier != ''"> and TC.uscc = #{ownerSocialIdentifier}</if>
  416. <if test="goodsName != null and goodsName != ''"> and TG.f_name like concat('%', #{goodsName}, '%')</if>
  417. <if test="specifications != null and specifications != ''"> and TG.f_packagespecs like concat('%', #{specifications}, '%')</if>
  418. <if test="materialQuality != null and materialQuality != ''"> and TWG.f_marks like concat('%', #{materialQuality}, '%')</if>
  419. <if test="receiptDoc != null and receiptDoc != ''"> and TWG.f_originalbillno like concat('%', #{receiptDoc}, '%')</if>
  420. <if test="billOfLading != null and billOfLading != ''"> and TWG.f_mblno like concat('%', #{billOfLading}, '%')</if>
  421. <if test="areaName != null and areaName != ''"> and ware.f_name like concat('%', #{areaName}, '%')</if>
  422. <if test="areaCode != null and areaCode != ''"> and ware.f_id = #{areaCode}</if>
  423. <if test="slotName != null and slotName != ''"> and ware.f_name like concat('%', #{slotName}, '%')</if>
  424. <if test="slotCode != null and slotCode != ''"> and ware.f_id = #{slotCode}</if>
  425. </where>
  426. </select>
  427. <select id="getWareHouseInfo" parameterType="String" resultMap="TWarehouseResult">
  428. <include refid="selectTWarehouseVo"/>
  429. <where>
  430. f_id = #{wareHouseId} and del_flag = '0' limit 1
  431. </where>
  432. </select>
  433. <select id="getStorageInfo" resultType="map">
  434. SELECT
  435. cast(IFNULL( ROUND( TW.f_totalgross / 1000, 2 ), 0 ) as DECIMAL(20,2)) AS capacity,
  436. IFNULL( ROUND( TWB.f_netweight / 1000, 2 ), 0 ) AS storage,
  437. TTL.value AS throughput,
  438. count(distinct(TWB.f_corpid)) AS customers
  439. FROM
  440. t_warehouse TW
  441. LEFT JOIN t_warehousebills TWB ON TW.f_id = TWB.f_warehouseid
  442. LEFT JOIN (
  443. SELECT
  444. f_warehouseid,
  445. ROUND( SUM(f_grossweight) / 1000, 2 ) as value
  446. FROM t_warehousebills
  447. where
  448. del_flag = '0'
  449. and f_billtype in ('SJCK')
  450. GROUP BY
  451. f_id
  452. ) TTL ON TTL.f_warehouseid = TW.f_id
  453. <where>
  454. TW.del_flag = '0'
  455. AND TW.f_id = #{wareHouseId}
  456. </where>
  457. GROUP BY
  458. TW.f_id
  459. </select>
  460. <select id="getTimeStorageInfo" resultType="map">
  461. SELECT
  462. f_bsdate as time,
  463. ROUND( SUM(f_grossweight) / 1000, 2 ) as value
  464. FROM t_warehousebills
  465. <where>
  466. del_flag = '0'
  467. AND f_warehouseid = #{wareHouseId}
  468. <if test="startTime != null and startTime != ''">
  469. and f_bsdate >= #{startTime}
  470. </if>
  471. <if test="endTime != null and endTime != ''">
  472. and f_bsdate &lt;= #{endTime}
  473. </if>
  474. <if test="startTime == null and endTime == null and startTime == '' and endTime == ''">
  475. and f_bsdate>=date(now()) and f_bsdate &lt; DATE_ADD(date(now()),INTERVAL 1 DAY)
  476. </if>
  477. </where>
  478. </select>
  479. <select id="getTimeThroughputInfo" resultType="map">
  480. SELECT
  481. f_bsdate as time,
  482. ROUND( SUM(f_grossweight) / 1000, 2 ) as value
  483. FROM t_warehousebills
  484. <where>
  485. del_flag = '0'
  486. AND f_warehouseid = #{wareHouseId}
  487. and f_billtype in ('SJRK','SJCK')
  488. <if test="startTime != null and startTime != ''">
  489. and f_bsdate >= #{startTime}
  490. </if>
  491. <if test="endTime != null and endTime != ''">
  492. and f_bsdate &lt;= #{endTime}
  493. </if>
  494. <if test="startTime == null and endTime == null and startTime == '' and endTime == ''">
  495. and f_bsdate>=date(now()) and f_bsdate &lt; DATE_ADD(date(now()),INTERVAL 1 DAY)
  496. </if>
  497. </where>
  498. </select>
  499. <select id="getCargoInfo" resultType="map">
  500. SELECT
  501. ROUND( SUM(f_grossweight) / 1000, 2 ) as FGrossweight
  502. FROM t_warehousebills
  503. <where>
  504. f_warehouseid = #{wareHouseId}
  505. <if test="isPledge != null and isPledge != ''">
  506. and is_pledge = #{isPledge}
  507. </if>
  508. <if test="startTime != null and startTime != ''">
  509. and f_bsdate >= #{startTime}
  510. </if>
  511. <if test="endTime != null and endTime != ''">
  512. and f_bsdate &lt;= #{endTime}
  513. </if>
  514. <if test="startTime == null and endTime == null and startTime == '' and endTime == ''">
  515. and DATE_SUB( CURDATE(), INTERVAL 7 DAY ) &lt;= date(f_bsdate)
  516. </if>
  517. </where>
  518. </select>
  519. <select id="getGoodsList" resultType="map">
  520. SELECT
  521. SDD.dict_label AS goodsType,
  522. ROUND( SUM(TW.f_grossweight) / 1000, 2 ) as count,
  523. round(
  524. SUM(TW.f_grossweight) * 100 /(
  525. SELECT
  526. SUM(f_grossweight) as total
  527. FROM
  528. t_warehousebills
  529. ),
  530. 2
  531. ) as rate
  532. FROM
  533. t_warehousebills TW
  534. LEFT JOIN sys_dict_data SDD ON SDD.dict_type = 'data_trademodes' AND SDD.dict_value = TW.f_trademodeid
  535. <where>
  536. TW.f_warehouseid = #{wareHouseId}
  537. <if test="startTime != null and startTime != ''">
  538. and TW.f_bsdate >= #{startTime}
  539. </if>
  540. <if test="endTime != null and endTime != ''">
  541. and TW.f_bsdate &lt;= #{endTime}
  542. </if>
  543. <if test="startTime == null and endTime == null and startTime == '' and endTime == ''">
  544. and DATE_SUB( CURDATE(), INTERVAL 7 DAY ) &lt;= date(TW.f_bsdate)
  545. </if>
  546. </where>
  547. GROUP BY
  548. SDD.dict_label
  549. </select>
  550. <select id="getCargoInfoTrend" resultType="map">
  551. SELECT
  552. f_bsdate as time,
  553. ROUND( SUM(TW.f_grossweight) / 1000, 2 ) as value
  554. FROM
  555. t_warehousebills TW
  556. LEFT JOIN sys_dict_data SDD ON SDD.dict_type = 'data_trademodes' AND SDD.dict_value = TW.f_trademodeid
  557. <where>
  558. TW.del_flag = '0'
  559. AND TW.f_warehouseid = #{wareHouseId}
  560. AND SDD.dict_value = #{FTradeModeId}
  561. <if test="startTime != null and startTime != ''">
  562. and TW.f_bsdate >= #{startTime}
  563. </if>
  564. <if test="endTime != null and endTime != ''">
  565. and TW.f_bsdate &lt;= #{endTime}
  566. </if>
  567. <if test="startTime == null and endTime == null and startTime == '' and endTime == ''">
  568. and DATE_SUB( CURDATE(), INTERVAL 7 DAY ) &lt;= date(TW.f_bsdate)
  569. </if>
  570. </where>
  571. GROUP BY
  572. SDD.dict_label
  573. </select>
  574. <select id="getStorageTop" resultType="map">
  575. SELECT
  576. TG.f_name AS goodsName,
  577. ROUND( SUM(TW.f_grossweight) / 1000, 2 ) as normalCnt,
  578. '' AS receiptCnt
  579. FROM
  580. t_warehousebills TW
  581. LEFT JOIN t_goods TG ON TG.f_id = TW.f_goodsid
  582. <where>
  583. TW.del_flag = '0'
  584. AND TW.f_warehouseid = #{wareHouseId}
  585. <if test="countType != null and countType != '' and countType == 2">
  586. and TW.f_billtype in ('SJRK','SJCK')
  587. </if>
  588. </where>
  589. GROUP BY TW.f_goodsid
  590. ORDER BY IFNULL( ROUND( SUM(TW.f_grossweight) / 1000, 2 ), 0 ) DESC
  591. LIMIT #{topCnt}
  592. </select>
  593. <select id="getGoodsTop" resultType="map">
  594. SELECT
  595. TC.f_name AS ownerName,
  596. ROUND( SUM(TW.f_grossweight) / 1000, 2 ) as count
  597. FROM
  598. t_warehousebills TW
  599. LEFT JOIN t_corps TC ON TC.f_id = TW.f_corpid
  600. <where>
  601. TW.del_flag = '0'
  602. AND TW.f_warehouseid = #{wareHouseId}
  603. <if test="countType != null and countType != '' and countType == 2">
  604. and TW.f_billtype in ('SJRK','SJCK')
  605. </if>
  606. </where>
  607. GROUP BY TW.f_corpid
  608. ORDER BY IFNULL( ROUND( SUM(TW.f_grossweight) / 1000, 2 ), 0 ) DESC
  609. LIMIT #{topCnt}
  610. </select>
  611. <select id="getTransferTransaction" resultType="map">
  612. SELECT
  613. f_bsdate as time,
  614. ROUND( SUM(f_grossweight) / 1000, 2 ) as value
  615. FROM
  616. t_warehousebills
  617. <where>
  618. del_flag = '0'
  619. AND f_warehouseid = #{wareHouseId}
  620. <if test="startTime != null and startTime != ''">
  621. and f_bsdate >= #{startTime}
  622. </if>
  623. <if test="endTime != null and endTime != ''">
  624. and f_bsdate &lt;= #{endTime}
  625. </if>
  626. <if test="startTime == null and endTime == null and startTime == '' and endTime == ''">
  627. and DATE_SUB( CURDATE(), INTERVAL 7 DAY ) &lt;= date(f_bsdate)
  628. </if>
  629. </where>
  630. </select>
  631. <select id="getWorkInfo" resultType="map">
  632. SELECT
  633. IFNULL( ROUND( SUM( TW.f_grossweight ) / 1000, 2 ),0) AS Fgrossweight,
  634. COUNT(f_id) AS count
  635. FROM
  636. t_warehousebills TW
  637. <where>
  638. TW.del_flag = '0'
  639. AND TW.f_warehouseid = #{wareHouseId}
  640. <if test="countType != null and countType != '' and countType == 'SJRK'">
  641. and TW.f_billtype = #{countType}
  642. </if>
  643. </where>
  644. </select>
  645. <select id="getWorkTrend" resultType="map">
  646. SELECT
  647. f_bsdate as time,
  648. ROUND( SUM( TW.f_grossweight ) / 1000, 2 ) AS value
  649. FROM
  650. t_warehousebills TW
  651. <where>
  652. TW.del_flag = '0'
  653. AND TW.f_warehouseid = #{wareHouseId}
  654. <if test="countType != null and countType != ''">
  655. and TW.f_billtype = #{countType}
  656. </if>
  657. <if test="startTime != null and startTime != ''">
  658. and TW.f_bsdate >= #{startTime}
  659. </if>
  660. <if test="endTime != null and endTime != ''">
  661. and TW.f_bsdate &lt;= #{endTime}
  662. </if>
  663. <if test="startTime == null and endTime == null and startTime == '' and endTime == ''">
  664. and DATE_SUB( CURDATE(), INTERVAL 7 DAY ) &lt;= date(TW.f_bsdate)
  665. </if>
  666. </where>
  667. </select>
  668. <select id="inventoryQueries" resultType="com.ruoyi.warehouseBusiness.response.InventoryQueryResponse">
  669. SELECT
  670. TWBI.f_business_type,
  671. TW.f_mblno AS warehouseSerialNumber,
  672. TW.f_originalbilldate AS originalWarehousingDate,
  673. TG.f_name AS cargoName,
  674. TW.f_marks AS cargoModel,
  675. (
  676. CASE
  677. TWBI.f_business_type
  678. WHEN '2' THEN
  679. TWBI.f_marks
  680. ELSE '' END
  681. ) AS cargoSpec,
  682. SUM( TW.f_qtyblc ) AS cargoQuantity,
  683. IFNULL( ROUND( SUM( TW.f_netweightblc ) / 1000, 2 ), 0 ) AS netWeight,
  684. IFNULL( ROUND( SUM( TW.f_grossweightblc ) / 1000, 2 ), 0 ) AS grossWeight,
  685. TWH.f_addr AS warehouseAddress,
  686. TC.f_name AS sourceOwnerName,
  687. TC.uscc AS sourceOwnerSocialIdentifier,
  688. TC.f_name AS currentOwnerName,
  689. TC.uscc AS currentOwnerSocialIdentifier,
  690. TW.f_originalbilldate AS rentBeginDate,
  691. '' AS storageRate,
  692. TW.f_marks AS mark,
  693. SUM( TW.f_qtyblc ) AS number,
  694. (CASE
  695. TWBI.f_business_type
  696. WHEN '3' THEN
  697. TWBI.f_marks ELSE ''
  698. END) AS manufacturer,
  699. '' AS trademark,
  700. '' AS grade,
  701. TG.f_packagespecs AS packing,
  702. '' AS country,
  703. '' AS process,
  704. TWBI.f_warehouse_information AS location
  705. FROM t_whgenleg TW
  706. LEFT JOIN t_goods TG ON TG.f_id = TW.f_goodsid
  707. LEFT JOIN t_warehouse TWH ON TW.f_warehouseid = TWH.f_id
  708. LEFT JOIN t_corps TC ON TC.f_id = TW.f_corpid
  709. LEFT JOIN (
  710. SELECT DISTINCT
  711. TWB.f_ifpledge,
  712. TWB.f_mblno,
  713. bi.f_business_type,
  714. bi.f_marks,
  715. bi.f_warehouse_information,
  716. bi.f_warehouselocid
  717. FROM
  718. t_warehousebills TWB
  719. LEFT JOIN t_warehousebillsitems bi ON bi.f_pid = TWB.f_id
  720. WHERE
  721. TWB.del_flag = '0'
  722. <if test="numbersList != null and numbersList != ''">
  723. and TWB.f_mblno IN
  724. <foreach item="number" collection="numbersList" open="(" separator="," close=")">
  725. #{number}
  726. </foreach>
  727. </if>
  728. ) TWBI ON TWBI.f_mblno = TW.f_mblno
  729. AND TWBI.f_warehouselocid = TW.f_warehouseid
  730. <where>
  731. TW.del_flag = '0'
  732. and TW.f_netweightblc != 0
  733. AND (TWBI.f_ifpledge != 0 or TWBI.f_ifpledge IS NULL)
  734. <if test="ownerName != null and ownerName != ''">
  735. and TC.f_name = #{ownerName}
  736. </if>
  737. <if test="identifier != null and identifier != ''">
  738. and TC.uscc = #{identifier}
  739. </if>
  740. <if test="numbersList != null and numbersList != ''">
  741. and TW.f_mblno in
  742. <foreach item="number" collection="numbersList" open="(" separator="," close=")">
  743. #{number}
  744. </foreach>
  745. </if>
  746. </where>
  747. GROUP BY
  748. TW.f_originalbillno
  749. </select>
  750. <update id="receiptRegister">
  751. update t_warehousebills TW
  752. LEFT JOIN t_corps TC ON TC.f_id = TW.f_corpid
  753. SET TW.f_ifpledge = '0'
  754. <where>
  755. TW.del_flag = '0'
  756. <if test="ownerName != null and ownerName != ''">
  757. and TC.f_name = #{ownerName}
  758. </if>
  759. <if test="identifier != null and identifier != ''">
  760. and TC.uscc = #{identifier}
  761. </if>
  762. <if test="numbers != null and numbers != ''">
  763. and TW.f_mblno = #{numbers}
  764. </if>
  765. </where>
  766. </update>
  767. <update id="receiptCancel">
  768. update t_warehousebills TW
  769. LEFT JOIN t_corps TC ON TC.f_id = TW.f_corpid
  770. SET TW.f_ifpledge = '1'
  771. <where>
  772. TW.del_flag = '0'
  773. <if test="ownerName != null and ownerName != ''">
  774. and TC.f_name = #{ownerName}
  775. </if>
  776. <if test="identifier != null and identifier != ''">
  777. and TC.uscc = #{identifier}
  778. </if>
  779. <if test="numbers != null and numbers != ''">
  780. and TW.f_mblno = #{numbers}
  781. </if>
  782. </where>
  783. </update>
  784. <select id="selectByPidANDName" resultMap="TWarehouseResult">
  785. <include refid="selectTWarehouseVo"/>
  786. <where>
  787. parent_id = #{fWarehouseid} and del_flag = '0' and f_name =#{stringCellValue}
  788. </where>
  789. </select>
  790. </mapper>