wms-acq-inventory-info.xml 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.emato.cus.supervise.mapper.WmsAcqInventoryInfoMapper">
  4. <!-- 企业库存信息查询 -->
  5. <select id="getWmsAcqInventoryInfo" parameterType="java.util.Map"
  6. resultType="com.emato.cus.supervise.domain.WmsAcqInventoryInfo">
  7. SELECT
  8. merchSn,
  9. goodsName,
  10. codeTs,
  11. gUnit,
  12. SUM( gQty ) AS gQty,
  13. goodsModel
  14. FROM
  15. (SELECT DISTINCT
  16. th.companyCode AS merchSn,
  17. th.locationCode AS seatNo,
  18. th.itemName AS goodsName,
  19. th.itemCode AS codeTs,
  20. th.itemCode AS skuNo,
  21. th.itemCode AS goodsId,
  22. i.unitDesc AS gUnit,
  23. ( case when (li.qty is null and th.afterOnHandQty = 0) or (li.qty is not null and th.afterOnHandQty = li.qty) then th.afterOnHandQty
  24. else li.qty end) AS gQty,
  25. th.warehouseCode AS storeCode,
  26. CONCAT( i.itemSize, '-', i.itemColor, '-', i.itemStyle ) AS goodsModel
  27. FROM
  28. transaction_history th
  29. LEFT JOIN ( SELECT itemCode, locationCode, SUM( onHandQty ) AS qty FROM location_inventory GROUP BY itemCode, locationCode ) AS li ON
  30. th.itemCode = li.itemCode AND th.locationCode = li.locationCode
  31. LEFT JOIN item i ON th.itemCode = i.CODE
  32. WHERE
  33. 1 = 1
  34. AND th.zone IN ( 'A区', 'B区', 'C区', 'GQ区', 'F区', 'P区', 'Y区' )
  35. AND th.created >= '2018-01-01'
  36. ORDER BY
  37. th.created DESC
  38. ) AS a
  39. GROUP BY
  40. codeTs
  41. </select>
  42. </mapper>