| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.unis.vis.mapper.InboundMaterialInfoMapper">
- <!--应急物资大类 -->
- <select id="getEmergencySuppliesCategory" resultType="com.unis.vis.model.InboundMaterialInfo">
- select dic.NAME_ as material_type,SUM(iif.quantity)as quantity,SUM(iif.total_price)as total_price
- from inbound_material_info iif
- left JOIN SYS_TREE_DICT dic on iif.material_type=DIC.ID
- left join inbound_info b ON iif."inbound_id"=B."inbound_id"
- where b."status"=5
- GROUP BY dic.NAME_
- </select>
- <!-- 物资情况 -->
- <select id="getMaterialSituation" resultType="com.unis.vis.model.InboundMaterialInfo">
- SELECT dic.NAME_ as material_type,
- SUM(CASE WHEN iif.is_available = 0 THEN iif.quantity ELSE 0 END) AS yes_quantity,
- SUM(CASE WHEN iif.is_available = 1 THEN iif.quantity ELSE 0 END) AS no_quantity
- from inbound_material_info iif
- left JOIN SYS_TREE_DICT dic on iif.material_type=DIC.ID
- left join inbound_info b ON iif."inbound_id"=B."inbound_id"
- where b."status"=5
- GROUP BY dic.NAME_
- </select>
- <!-- 应用物资大类 -->
- <select id="getWzsyqkpm" resultType="com.unis.vis.model.InboundMaterialInfo">
- select dic.NAME_ as material_type,SUM(iif.quantity)as quantity,SUM(iif.total_price)as total_price
- from outbound_material_info iif
- left JOIN SYS_TREE_DICT dic on iif.material_type=dic.ID
- left join outbound_info b ON iif."outbound_id"=B."outbound_id"
- where b."status"=5 and dic.DIFFERENCE_=2
- GROUP BY dic.NAME_
- </select>
- <!-- 物资入库情况 -->
- <select id="getInventoryReceiptStatus" resultType="com.unis.vis.model.InboundMaterialInfo">
- SELECT std.NAME_ as material_type,
- SUM(imi.quantity) as quantity,
- SUM(imi.total_price) as total_price
- FROM "inbound_material_info" imi
- LEFT JOIN "inbound_info" ii ON imi."inbound_id" = ii."inbound_id"
- INNER JOIN "SYS_TREE_DICT" std ON std."id" = ii."material_type" AND std.DIFFERENCE_ = 2
- WHERE ii."status" = 5
- AND ii."is_available" = 0
- GROUP BY std.NAME_
- </select>
- <!-- 出入库记录 -->
- <select id="getEnterExitRecords" parameterType="integer" resultType="com.unis.vis.model.OutAndInboundRecord">
- SELECT record.type,
- record.shengName,
- record.material_name as materialName,
- record.quantity,
- record.specs,
- record.bound_time as boundTime
- FROM (
- SELECT
- 1 AS type,
- null as shengName,
- std.NAME_ as material_name,
- ruku.quantity,
- ruku.specs,
- ruku.inbound_time AS bound_time
- FROM "inbound_status" flow
- LEFT JOIN "inbound_material_info" ruku ON ruku."inbound_id" = flow."inbound_id"
- LEFT JOIN SYS_TREE_DICT std ON std.id = ruku.material_name
- LEFT JOIN inbound_info ii ON ii.inbound_id = ruku.inbound_id
- WHERE
- flow.is_invalid = 0
- AND ruku.is_available = 0
- <!-- 审核通过的 -->
- AND flow."status" = 5
- <if test="type != null">
- AND ii.name = #{name}
- </if>
- UNION ALL
- SELECT
- 2 AS type,
- dict.DESCRIPTION as shengName,
- std.NAME_ as material_name,
- chuku.quantity,
- chuku.specs,
- chuku.outbound_time AS bound_time
- FROM "outbound_status" flow
- LEFT JOIN "outbound_material_info" chuku ON chuku."outbound_id" = flow."outbound_id"
- LEFT JOIN SYS_DICT_ITEM dict ON dict.ITEM_VALUE = chuku."province"
- LEFT JOIN SYS_TREE_DICT std ON std.id = chuku.material_name
- LEFT JOIN inbound_info ii ON ii.outbound_id = chuku.outbound_id
- WHERE
- flow.is_invalid = 0
- AND chuku.is_available = 0
- <!-- 审核通过的 -->
- AND flow."status" = 5
- AND dict.DICT_TYPE = 'province_ch'
- <if test="name != null">
- AND ii.name = #{name}
- </if>
- ) record
- <where>
- <if test="type != null and type > 0">
- AND record.type = #{type}
- </if>
- </where>
- ORDER BY record.bound_time desc
- </select>
- <select id="selectWarehouseForMaterialType" resultType="com.unis.vis.controller.vo.MaterialReserveSituationVO">
- SELECT c.NAME_ as materialTypeZn,d.NAME_ as materialNameZn,a.specs as specs
- ,concat(TO_CHAR(sum(to_number(a.quantity))),e.NAME_) as quantityAll ,sum(TO_NUMBER(a.total_price)) as totalPriceAll
- from inbound_material_info a
- left join inbound_info b ON a.inbound_id=b.inbound_id
- left JOIN SYS_TREE_DICT c on a.material_type=c.ID
- left JOIN SYS_TREE_DICT d on a.material_name=d.ID
- left JOIN SYS_TREE_DICT e on a.unit=e.ID
- where b.status=5 AND b.is_available=0 AND a.is_available=0
- <if test="warehouse!=null and warehouse!=''">
- AND b.warehouse =#{warehouse}
- </if>
- group by a.material_type,a.material_name,a.specs
- </select>
- </mapper>
|