TWarehouseMapper.xml 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690
  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.f_id AS ownerCode,
  339. TC.f_name AS ownerName,
  340. TG.f_name AS goodsName,
  341. TG.f_packagespecs AS specifications,
  342. '' AS producing,
  343. TWG.f_marks AS materialQuality,
  344. '' AS LEVEL,
  345. SUM(TWG.f_qtyD) AS totalQuantity,
  346. SUM(TWG.f_qtyblc) AS availableQuantity,
  347. '袋' AS quantityUnit,
  348. IFNULL( ROUND( SUM(TWG.f_netweightD) / 1000, 2 ), 0 ) AS totalNetWeight,
  349. IFNULL( ROUND( SUM(TWG.f_netweightblc) / 1000, 2 ), 0 ) AS availableWeight,
  350. '吨' AS weightUnit,
  351. CONCAT_WS('-',IFNULL( TG.f_name, '' ),CONCAT_WS( IFNULL( TG.f_packagespecs, '' ), '/袋' ),IFNULL( TWG.f_marks, '' )) AS spu
  352. FROM t_warehouse TW
  353. LEFT JOIN t_whgenleg TWG ON TWG.f_warehouseid = TW.f_id
  354. LEFT JOIN t_corps TC ON TC.f_id = TWG.f_corpid
  355. LEFT JOIN t_goods TG ON TG.f_id = TWG.f_goodsid
  356. <where>
  357. TW.del_flag = '0'
  358. AND TW.f_id = #{warehouseCode}
  359. <if test="ownerName != null and ownerName != ''"> and TC.f_name like concat('%', #{ownerName}, '%')</if>
  360. <if test="goodsName != null and goodsName != ''"> and TG.f_name like concat('%', #{goodsName}, '%')</if>
  361. <if test="specifications != null and specifications != ''"> and TG.f_packagespecs like concat('%', #{specifications}, '%')</if>
  362. <if test="materialQuality != null and materialQuality != ''"> and TWG.f_marks like concat('%', #{materialQuality}, '%')</if>
  363. </where>
  364. GROUP BY
  365. TW.f_id,TC.f_no,TG.f_name,TG.f_packagespecs,TWG.f_marks
  366. </select>
  367. <select id="queryGoodsAccountDetailByPageV1" resultType="map">
  368. SELECT
  369. DISTINCT
  370. TWG.f_id AS id,
  371. TW.f_id AS warehouseCode,
  372. TW.f_name AS warehouseName,
  373. ware.f_name AS areaName,
  374. ware.f_id AS areaCode,
  375. ware.f_name AS slotName,
  376. ware.f_id AS slotCode,
  377. TWG.f_originalbillno AS receiptDoc,
  378. TWG.f_mblno AS billOfLading,
  379. TC.f_id AS ownerCode,
  380. TC.f_name AS ownerName,
  381. TG.f_name AS goodsName,
  382. TG.f_packagespecs AS specifications,
  383. '' AS producing,
  384. TWG.f_marks AS materialQuality,
  385. '' AS LEVEL,
  386. TWG.f_qtyD AS totalQuantity,
  387. TWG.f_qtyblc AS availableQuantity,
  388. '袋' AS quantityUnit,
  389. IFNULL( ROUND( TWG.f_netweightD / 1000, 2 ), 0 ) AS totalNetWeight,
  390. IFNULL( ROUND( TWG.f_netweightblc / 1000, 2 ), 0 ) AS availableWeight,
  391. '吨' AS weightUnit,
  392. TWG.f_originalbilldate AS storesTime,
  393. '' AS productionTime,
  394. TWB.f_truckno AS plateNumber,
  395. '' AS batchNo,
  396. '' AS warehouseReceiptNo
  397. FROM
  398. t_whgenleg TWG
  399. LEFT JOIN t_warehouse TW ON TWG.f_warehouseid = TW.f_id
  400. LEFT JOIN t_warehouse ware ON ware.f_id = TWG.f_warehouse_locationid
  401. LEFT JOIN t_corps TC ON TC.f_id = TWG.f_corpid
  402. LEFT JOIN t_goods TG ON TG.f_id = TWG.f_goodsid
  403. LEFT JOIN t_warehousebills TWB ON TWG.f_originalbillno = TWB.f_billno
  404. <where>
  405. TW.del_flag = '0'
  406. and TWG.f_warehouseid = #{warehouseCode}
  407. AND TW.del_flag = '0'
  408. <if test="ownerName != null and ownerName != ''"> and TC.f_name like concat('%', #{ownerName}, '%')</if>
  409. <if test="ownerCode != null and ownerCode != ''"> and TC.f_id = #{ownerCode}</if>
  410. <if test="goodsName != null and goodsName != ''"> and TG.f_name like concat('%', #{goodsName}, '%')</if>
  411. <if test="specifications != null and specifications != ''"> and TG.f_packagespecs like concat('%', #{specifications}, '%')</if>
  412. <if test="materialQuality != null and materialQuality != ''"> and TWG.f_marks like concat('%', #{materialQuality}, '%')</if>
  413. <if test="receiptDoc != null and receiptDoc != ''"> and TWG.f_originalbillno like concat('%', #{receiptDoc}, '%')</if>
  414. <if test="billOfLading != null and billOfLading != ''"> and TWG.f_mblno like concat('%', #{billOfLading}, '%')</if>
  415. <if test="areaName != null and areaName != ''"> and ware.f_name like concat('%', #{areaName}, '%')</if>
  416. <if test="areaCode != null and areaCode != ''"> and ware.f_id = #{areaCode}</if>
  417. <if test="slotName != null and slotName != ''"> and ware.f_name like concat('%', #{slotName}, '%')</if>
  418. <if test="slotCode != null and slotCode != ''"> and ware.f_id = #{slotCode}</if>
  419. </where>
  420. </select>
  421. <select id="getWareHouseInfo" parameterType="String" resultMap="TWarehouseResult">
  422. <include refid="selectTWarehouseVo"/>
  423. <where>
  424. f_id = #{wareHouseId} and del_flag = '0' limit 1
  425. </where>
  426. </select>
  427. <select id="getStorageInfo" resultType="map">
  428. SELECT
  429. IFNULL( ROUND( TW.f_totalgross / 1000, 2 ), 0 ) AS capacity,
  430. IFNULL( ROUND( TWB.f_netweight / 1000, 2 ), 0 ) AS storage,
  431. '' AS throughput,
  432. '' AS customers
  433. FROM
  434. t_warehouse TW
  435. LEFT JOIN t_warehousebills TWB ON TW.f_id = TWB.f_warehouseid
  436. <where>
  437. TW.del_flag = '0'
  438. AND TW.f_id = #{wareHouseId}
  439. </where>
  440. GROUP BY
  441. TW.f_id
  442. </select>
  443. <select id="getTimeStorageInfo" resultType="map">
  444. SELECT
  445. f_bsdate as time,
  446. ROUND( SUM(f_grossweight) / 1000, 2 ) as value
  447. FROM t_warehousebills
  448. <where>
  449. del_flag = '0'
  450. AND f_warehouseid = #{wareHouseId}
  451. <if test="startTime != null and startTime != ''">
  452. and f_bsdate >= #{startTime}
  453. </if>
  454. <if test="endTime != null and endTime != ''">
  455. and f_bsdate &lt;= #{endTime}
  456. </if>
  457. <if test="startTime == null and endTime == null and startTime == '' and endTime == ''">
  458. and f_bsdate>=date(now()) and f_bsdate &lt; DATE_ADD(date(now()),INTERVAL 1 DAY)
  459. </if>
  460. </where>
  461. </select>
  462. <select id="getTimeThroughputInfo" resultType="map">
  463. SELECT
  464. f_bsdate as time,
  465. ROUND( SUM(f_grossweight) / 1000, 2 ) as value
  466. FROM t_warehousebills
  467. <where>
  468. del_flag = '0'
  469. AND f_warehouseid = #{wareHouseId}
  470. and f_billtype in ('SJRK','SJCK')
  471. <if test="startTime != null and startTime != ''">
  472. and f_bsdate >= #{startTime}
  473. </if>
  474. <if test="endTime != null and endTime != ''">
  475. and f_bsdate &lt;= #{endTime}
  476. </if>
  477. <if test="startTime == null and endTime == null and startTime == '' and endTime == ''">
  478. and f_bsdate>=date(now()) and f_bsdate &lt; DATE_ADD(date(now()),INTERVAL 1 DAY)
  479. </if>
  480. </where>
  481. </select>
  482. <select id="getCargoInfo" resultType="map">
  483. SELECT
  484. ROUND( SUM(f_grossweight) / 1000, 2 ) as FGrossweight
  485. FROM t_warehousebills
  486. <where>
  487. f_warehouseid = #{wareHouseId}
  488. <if test="isPledge != null and isPledge != ''">
  489. and is_pledge = #{isPledge}
  490. </if>
  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 DATE_SUB( CURDATE(), INTERVAL 7 DAY ) &lt;= date(f_bsdate)
  499. </if>
  500. </where>
  501. </select>
  502. <select id="getGoodsList" resultType="map">
  503. SELECT
  504. SDD.dict_label AS goodsType,
  505. ROUND( SUM(TW.f_grossweight) / 1000, 2 ) as count,
  506. round(
  507. SUM(TW.f_grossweight) * 100 /(
  508. SELECT
  509. SUM(f_grossweight) as total
  510. FROM
  511. t_warehousebills
  512. ),
  513. 2
  514. ) as rate
  515. FROM
  516. t_warehousebills TW
  517. LEFT JOIN sys_dict_data SDD ON SDD.dict_type = 'data_trademodes' AND SDD.dict_value = TW.f_trademodeid
  518. <where>
  519. TW.f_warehouseid = #{wareHouseId}
  520. <if test="startTime != null and startTime != ''">
  521. and TW.f_bsdate >= #{startTime}
  522. </if>
  523. <if test="endTime != null and endTime != ''">
  524. and TW.f_bsdate &lt;= #{endTime}
  525. </if>
  526. <if test="startTime == null and endTime == null and startTime == '' and endTime == ''">
  527. and DATE_SUB( CURDATE(), INTERVAL 7 DAY ) &lt;= date(TW.f_bsdate)
  528. </if>
  529. </where>
  530. GROUP BY
  531. SDD.dict_label
  532. </select>
  533. <select id="getCargoInfoTrend" resultType="map">
  534. SELECT
  535. f_bsdate as time,
  536. ROUND( SUM(TW.f_grossweight) / 1000, 2 ) as value
  537. FROM
  538. t_warehousebills TW
  539. LEFT JOIN sys_dict_data SDD ON SDD.dict_type = 'data_trademodes' AND SDD.dict_value = TW.f_trademodeid
  540. <where>
  541. TW.del_flag = '0'
  542. AND TW.f_warehouseid = #{wareHouseId}
  543. AND SDD.dict_value = #{FTradeModeId}
  544. <if test="startTime != null and startTime != ''">
  545. and TW.f_bsdate >= #{startTime}
  546. </if>
  547. <if test="endTime != null and endTime != ''">
  548. and TW.f_bsdate &lt;= #{endTime}
  549. </if>
  550. <if test="startTime == null and endTime == null and startTime == '' and endTime == ''">
  551. and DATE_SUB( CURDATE(), INTERVAL 7 DAY ) &lt;= date(TW.f_bsdate)
  552. </if>
  553. </where>
  554. GROUP BY
  555. SDD.dict_label
  556. </select>
  557. <select id="getStorageTop" resultType="map">
  558. SELECT
  559. TG.f_name AS goodsName,
  560. ROUND( SUM(TW.f_grossweight) / 1000, 2 ) as normalCnt,
  561. '' AS receiptCnt
  562. FROM
  563. t_warehousebills TW
  564. LEFT JOIN t_goods TG ON TG.f_id = TW.f_goodsid
  565. <where>
  566. TW.del_flag = '0'
  567. AND TW.f_warehouseid = #{wareHouseId}
  568. <if test="countType != null and countType != '' and countType == 2">
  569. and TW.f_billtype in ('SJRK','SJCK')
  570. </if>
  571. </where>
  572. GROUP BY TW.f_goodsid
  573. ORDER BY IFNULL( ROUND( SUM(TW.f_grossweight) / 1000, 2 ), 0 ) DESC
  574. LIMIT #{topCnt}
  575. </select>
  576. <select id="getGoodsTop" resultType="map">
  577. SELECT
  578. TC.f_name AS ownerName,
  579. ROUND( SUM(TW.f_grossweight) / 1000, 2 ) as count
  580. FROM
  581. t_warehousebills TW
  582. LEFT JOIN t_corps TC ON TC.f_id = TW.f_corpid
  583. <where>
  584. TW.del_flag = '0'
  585. AND TW.f_warehouseid = #{wareHouseId}
  586. <if test="countType != null and countType != '' and countType == 2">
  587. and TW.f_billtype in ('SJRK','SJCK')
  588. </if>
  589. </where>
  590. GROUP BY TW.f_corpid
  591. ORDER BY IFNULL( ROUND( SUM(TW.f_grossweight) / 1000, 2 ), 0 ) DESC
  592. LIMIT #{topCnt}
  593. </select>
  594. <select id="getTransferTransaction" resultType="map">
  595. SELECT
  596. f_bsdate as time,
  597. ROUND( SUM(f_grossweight) / 1000, 2 ) as value
  598. FROM
  599. t_warehousebills
  600. <where>
  601. del_flag = '0'
  602. AND f_warehouseid = #{wareHouseId}
  603. <if test="startTime != null and startTime != ''">
  604. and f_bsdate >= #{startTime}
  605. </if>
  606. <if test="endTime != null and endTime != ''">
  607. and f_bsdate &lt;= #{endTime}
  608. </if>
  609. <if test="startTime == null and endTime == null and startTime == '' and endTime == ''">
  610. and DATE_SUB( CURDATE(), INTERVAL 7 DAY ) &lt;= date(f_bsdate)
  611. </if>
  612. </where>
  613. </select>
  614. <select id="getWorkInfo" resultType="map">
  615. SELECT
  616. IFNULL( ROUND( SUM( TW.f_grossweight ) / 1000, 2 ),0) AS Fgrossweight,
  617. COUNT(f_id) AS count
  618. FROM
  619. t_warehousebills TW
  620. <where>
  621. TW.del_flag = '0'
  622. AND TW.f_warehouseid = #{wareHouseId}
  623. <if test="countType != null and countType != '' and countType == 'SJRK'">
  624. and TW.f_billtype = #{countType}
  625. </if>
  626. </where>
  627. </select>
  628. <select id="getWorkTrend" resultType="map">
  629. SELECT
  630. f_bsdate as time,
  631. ROUND( SUM( TW.f_grossweight ) / 1000, 2 ) AS value
  632. FROM
  633. t_warehousebills TW
  634. <where>
  635. TW.del_flag = '0'
  636. AND TW.f_warehouseid = #{wareHouseId}
  637. <if test="countType != null and countType != ''">
  638. and TW.f_billtype = #{countType}
  639. </if>
  640. <if test="startTime != null and startTime != ''">
  641. and TW.f_bsdate >= #{startTime}
  642. </if>
  643. <if test="endTime != null and endTime != ''">
  644. and TW.f_bsdate &lt;= #{endTime}
  645. </if>
  646. <if test="startTime == null and endTime == null and startTime == '' and endTime == ''">
  647. and DATE_SUB( CURDATE(), INTERVAL 7 DAY ) &lt;= date(TW.f_bsdate)
  648. </if>
  649. </where>
  650. </select>
  651. </mapper>