TWarehouseMapper.xml 28 KB

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