InboundMaterialInfoMapper.xml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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.unis.vis.mapper.InboundMaterialInfoMapper">
  4. <!--应急物资大类 -->
  5. <select id="getEmergencySuppliesCategory" resultType="com.unis.vis.model.InboundMaterialInfo">
  6. select dic.NAME_ as material_type,SUM(iif.quantity)as quantity,SUM(iif.total_price)as total_price
  7. from inbound_material_info iif
  8. left JOIN SYS_TREE_DICT dic on iif.material_type=DIC.ID
  9. left join inbound_info b ON iif."inbound_id"=B."inbound_id"
  10. where b."status"=5
  11. GROUP BY dic.NAME_
  12. </select>
  13. <!-- 物资情况 -->
  14. <select id="getMaterialSituation" resultType="com.unis.vis.model.InboundMaterialInfo">
  15. SELECT dic.NAME_ as material_type,
  16. SUM(CASE WHEN iif.is_available = 0 THEN iif.quantity ELSE 0 END) AS yes_quantity,
  17. SUM(CASE WHEN iif.is_available = 1 THEN iif.quantity ELSE 0 END) AS no_quantity
  18. from inbound_material_info iif
  19. left JOIN SYS_TREE_DICT dic on iif.material_type=DIC.ID
  20. left join inbound_info b ON iif."inbound_id"=B."inbound_id"
  21. where b."status"=5
  22. GROUP BY dic.NAME_
  23. </select>
  24. <!-- 应用物资大类 -->
  25. <select id="getWzsyqkpm" resultType="com.unis.vis.model.InboundMaterialInfo">
  26. select dic.NAME_ as material_type,SUM(iif.quantity)as quantity,SUM(iif.total_price)as total_price
  27. from outbound_material_info iif
  28. left JOIN SYS_TREE_DICT dic on iif.material_type=dic.ID
  29. left join outbound_info b ON iif."outbound_id"=B."outbound_id"
  30. where b."status"=5 and dic.DIFFERENCE_=2
  31. GROUP BY dic.NAME_
  32. </select>
  33. <!-- 物资入库情况 -->
  34. <select id="getInventoryReceiptStatus" resultType="com.unis.vis.model.InboundMaterialInfo">
  35. SELECT std.NAME_ as material_type,
  36. SUM(imi.quantity) as quantity,
  37. SUM(imi.total_price) as total_price
  38. FROM "inbound_material_info" imi
  39. LEFT JOIN "inbound_info" ii ON imi."inbound_id" = ii."inbound_id"
  40. INNER JOIN "SYS_TREE_DICT" std ON std."id" = ii."material_type" AND std.DIFFERENCE_ = 2
  41. WHERE ii."status" = 5
  42. AND ii."is_available" = 0
  43. GROUP BY std.NAME_
  44. </select>
  45. <!-- 出入库记录 -->
  46. <select id="getEnterExitRecords" parameterType="integer" resultType="com.unis.vis.model.OutAndInboundRecord">
  47. SELECT record.type,
  48. record.shengName,
  49. record.material_name as materialName,
  50. record.quantity,
  51. record.specs,
  52. record.bound_time as boundTime
  53. FROM (
  54. SELECT
  55. 1 AS type,
  56. null as shengName,
  57. std.NAME_ as material_name,
  58. ruku.quantity,
  59. ruku.specs,
  60. ruku.inbound_time AS bound_time
  61. FROM "inbound_status" flow
  62. LEFT JOIN "inbound_material_info" ruku ON ruku."inbound_id" = flow."inbound_id"
  63. LEFT JOIN SYS_TREE_DICT std ON std.id = ruku.material_name
  64. LEFT JOIN inbound_info ii ON ii.inbound_id = ruku.inbound_id
  65. WHERE
  66. flow.is_invalid = 0
  67. AND ruku.is_available = 0
  68. <!-- 审核通过的 -->
  69. AND flow."status" = 5
  70. <if test="type != null">
  71. AND ii.name = #{name}
  72. </if>
  73. UNION ALL
  74. SELECT
  75. 2 AS type,
  76. dict.DESCRIPTION as shengName,
  77. std.NAME_ as material_name,
  78. chuku.quantity,
  79. chuku.specs,
  80. chuku.outbound_time AS bound_time
  81. FROM "outbound_status" flow
  82. LEFT JOIN "outbound_material_info" chuku ON chuku."outbound_id" = flow."outbound_id"
  83. LEFT JOIN SYS_DICT_ITEM dict ON dict.ITEM_VALUE = chuku."province"
  84. LEFT JOIN SYS_TREE_DICT std ON std.id = chuku.material_name
  85. LEFT JOIN inbound_info ii ON ii.outbound_id = chuku.outbound_id
  86. WHERE
  87. flow.is_invalid = 0
  88. AND chuku.is_available = 0
  89. <!-- 审核通过的 -->
  90. AND flow."status" = 5
  91. AND dict.DICT_TYPE = 'province_ch'
  92. <if test="name != null">
  93. AND ii.name = #{name}
  94. </if>
  95. ) record
  96. <where>
  97. <if test="type != null and type > 0">
  98. AND record.type = #{type}
  99. </if>
  100. </where>
  101. ORDER BY record.bound_time desc
  102. </select>
  103. <select id="selectWarehouseForMaterialType" resultType="com.unis.vis.controller.vo.MaterialReserveSituationVO">
  104. SELECT c.NAME_ as materialTypeZn,d.NAME_ as materialNameZn,a.specs as specs
  105. ,concat(TO_CHAR(sum(to_number(a.quantity))),e.NAME_) as quantityAll ,sum(TO_NUMBER(a.total_price)) as totalPriceAll
  106. from inbound_material_info a
  107. left join inbound_info b ON a.inbound_id=b.inbound_id
  108. left JOIN SYS_TREE_DICT c on a.material_type=c.ID
  109. left JOIN SYS_TREE_DICT d on a.material_name=d.ID
  110. left JOIN SYS_TREE_DICT e on a.unit=e.ID
  111. where b.status=5 AND b.is_available=0 AND a.is_available=0
  112. <if test="warehouse!=null and warehouse!=''">
  113. AND b.warehouse =#{warehouse}
  114. </if>
  115. group by a.material_type,a.material_name,a.specs
  116. </select>
  117. </mapper>