TWarehouseMapper.xml 36 KB

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