TWarehouseMapper.xml 37 KB

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