<?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.steerinfo.meterwork.meterworkoldandnew.mapper.MeterWorkOldAndNewMapper">

    <select id="doQueryNew" parameterType="java.util.HashMap" resultType="HashMap">
        select ACTUAL_NO,
        prediction_no,
        CAR_NO,
        GROSS_WEIGHT,
        BASE_SPOT1_NAME,
        GROSS_TIME,
        TARE_WEIGHT,
        BASE_SPOT2_NAME,
        TARE_TIME,
        NET_WEIGHT,
        net_spot3_no,
        NET_SPOT3_NAME,
        NET_TIME,
        forwarding_unit_no,
        FORWARDING_UNIT_NAME,
        receiving_uint_no,
        RECEIVING_UINT_NAME,
        matter_no,
        MATTER_NAME,
        sender_remark,
        '新系统' as REMARK
        from METER_WORK_CAR_ACTUAL
        where VALUE_FLAG in ('1', '2')
        and UPLOAD_FLAG='2'
        <if test="remark != null and remark != ''">
            and '新系统' LIKE '%${remark}%'
        </if>
        <if test="predictionNo != null and predictionNo != ''">
            and prediction_no LIKE '%${predictionNo}%'
        </if>
        <if test="senderRemark != null and senderRemark != ''">
            and sender_remark LIKE '%${senderRemark}%'
        </if>
        <if test="startTime != null and endTime != null and startTime != '' and endTime != ''">
            and  net_time  >= TO_DATE(#{startTime}, 'yyyy-MM-dd HH24:mi:ss') and net_time  &lt;=  TO_DATE(#{endTime}, 'yyyy-MM-dd HH24:mi:ss')
        </if>
        <if test="carNo != null and carNo != ''">
            and car_no like '%${carNo}%'
        </if>
        <if test="netSpot3No != null and netSpot3No != ''">
            and net_spot3_no like '%${netSpot3No}%'
        </if>
        <if test="netSpot3Name != null and netSpot3Name != ''">
            and net_spot3_name like '%${netSpot3Name}%'
        </if>
        <if test="forwardingUnitNo != null and forwardingUnitNo != ''">
            and FORWARDING_UNIT_NO LIKE '%${forwardingUnitNo}%'
        </if>
        <if test="forwardingUnitName != null and forwardingUnitName != ''">
            and FORWARDING_UNIT_NAME LIKE '%${forwardingUnitName}%'
        </if>
        <if test="receivingUintNo != null and receivingUintNo != ''">
            and RECEIVING_UINT_NO LIKE '%${receivingUintNo}%'
        </if>
        <if test="receivingUintName != null and receivingUintName != ''">
            and RECEIVING_UINT_NAME LIKE '%${receivingUintName}%'
        </if>
        <if test="matterNo != null and matterNo != ''">
            and matter_no LIKE '%${matterNo}%'
        </if>
        <if test="matterName != null and matterName != ''">
            and matter_name LIKE '%${matterName}%'
        </if>
    </select>

    <select id="doQueryOld" parameterType="java.util.HashMap" resultType="HashMap">
        select FS_WEIGHTNO as ACTUAL_NO,
        fs_noticeId as prediction_no,
        REPLACE(FS_CARNO,'-','') as CAR_NO,
        FS_GROSSWEIGHT * 1000 as GROSS_WEIGHT,
        FS_GROSSPOINTNAME as BASE_SPOT1_NAME,
        FS_GROSSWEIGHTTIME as GROSS_TIME,
        FS_TAREWEIGHT * 1000 as TARE_WEIGHT,
        FS_TAREPOINTNAME as BASE_SPOT2_NAME,
        FS_TAREWEIGHTTIME as TARE_TIME,
        FS_NETWEIGHT * 1000 as NET_WEIGHT,
        fs_netPointId as net_spot3_no,
        FS_NETPOINTNAME as NET_SPOT3_NAME,
        FS_NETWEIGHTTIME as NET_TIME,
        fs_sender as FORWARDING_UNIT_No,
        FS_SENDERNAME as FORWARDING_UNIT_NAME,
        fs_receiver as RECEIVING_UINT_No,
        FS_RECEIVERNAME as RECEIVING_UINT_NAME,
        fs_material as matter_no,
        FS_MATERIALNAME as MATTER_NAME,
        fs_senderRemark sender_remark,
        '老系统' as REMARK
        from jgweight.view_car_net
        where FS_NETWEIGHTTIME > to_date('2022-07-21','YYYY-MM-DD') AND FS_DELETEDTAG='N'
        and fs_noticeId is not null
        <if test="remark != null and remark != ''">
            and '老系统' LIKE '%${remark}%'
        </if>
        <if test="predictionNo != null and predictionNo != ''">
            and fs_noticeId LIKE '%${predictionNo}%'
        </if>
        <if test="senderRemark != null and senderRemark != ''">
            and fs_senderRemark LIKE '%${senderRemark}%'
        </if>
        <if test="startTime != null and endTime != null and startTime != '' and endTime != ''">
            and FS_NETWEIGHTTIME  >= TO_DATE(#{startTime}, 'yyyy-MM-dd HH24:mi:ss') and FS_NETWEIGHTTIME  &lt;=  TO_DATE(#{endTime}, 'yyyy-MM-dd HH24:mi:ss')
        </if>
        <if test="carNo != null and carNo != ''">
            and REPLACE(FS_CARNO,'-','') like '%${carNo}%'
        </if>
        <if test="netSpot3No != null and netSpot3No != ''">
            and fs_netPointId like '%${netSpot3No}%'
        </if>
        <if test="netSpot3Name != null and netSpot3Name != ''">
            and FS_NETPOINTNAME like '%${netSpot3Name}%'
        </if>
        <if test="forwardingUnitNo != null and forwardingUnitNo != ''">
            and fs_sender LIKE '%${forwardingUnitNo}%'
        </if>
        <if test="forwardingUnitName != null and forwardingUnitName != ''">
            and FS_SENDERNAME LIKE '%${forwardingUnitName}%'
        </if>
        <if test="receivingUintNo != null and receivingUintNo != ''">
            and fs_receiver LIKE '%${receivingUintNo}%'
        </if>
        <if test="receivingUintName != null and receivingUintName != ''">
            and FS_RECEIVERNAME LIKE '%${receivingUintName}%'
        </if>
        <if test="matterNo != null and matterNo != ''">
            and fs_material LIKE '%${matterNo}%'
        </if>
        <if test="matterName != null and matterName != ''">
            and FS_MATERIALNAME LIKE '%${matterName}%'
        </if>
    </select>

    <select id="doQueryFirstNew" parameterType="java.util.HashMap" resultType="HashMap">
        select actual_first_no,
        prediction_no,
        car_no,
        meter_weight,
        create_time,
        base_spot_no,
        base_spot_name,
        forwarding_unit_no,
        forwarding_unit_name,
        receiving_uint_no,
        receiving_uint_name,
        matter_no,
        matter_name,
        sender_remark,
        '新系统' remark
        from meter_work_car_actual_first
        where is_pre_scale = '1'
        and value_flag in  ('1', '2')
        <if test="remark != null and remark != ''">
            and '新系统' LIKE '%${remark}%'
        </if>
        <if test="predictionNo != null and predictionNo != ''">
            and prediction_no LIKE '%${predictionNo}%'
        </if>
        <if test="startTime != null and endTime != null and startTime != '' and endTime != ''">
            and  create_time  >= TO_DATE(#{startTime}, 'yyyy-MM-dd HH24:mi:ss') and create_time  &lt;=  TO_DATE(#{endTime}, 'yyyy-MM-dd HH24:mi:ss')
        </if>
        <if test="senderRemark != null and senderRemark != ''">
            and sender_remark LIKE '%${senderRemark}%'
        </if>
        <if test="carNo != null and carNo != ''">
            and car_no like '%${carNo}%'
        </if>
        <if test="baseSpotNo != null and baseSpotNo != ''">
            and base_spot_no like '%${baseSpotNo}%'
        </if>
        <if test="baseSpotName != null and baseSpotName != ''">
            and base_spot_name like '%${baseSpotName}%'
        </if>
        <if test="forwardingUnitNo != null and forwardingUnitNo != ''">
            and FORWARDING_UNIT_NO LIKE '%${forwardingUnitNo}%'
        </if>
        <if test="forwardingUnitName != null and forwardingUnitName != ''">
            and FORWARDING_UNIT_NAME LIKE '%${forwardingUnitName}%'
        </if>
        <if test="receivingUintNo != null and receivingUintNo != ''">
            and RECEIVING_UINT_NO LIKE '%${receivingUintNo}%'
        </if>
        <if test="receivingUintName != null and receivingUintName != ''">
            and RECEIVING_UINT_NAME LIKE '%${receivingUintName}%'
        </if>
        <if test="matterNo != null and matterNo != ''">
            and matter_no LIKE '%${matterNo}%'
        </if>
        <if test="matterName != null and matterName != ''">
            and matter_name LIKE '%${matterName}%'
        </if>
    </select>

    <select id="doQueryFirstOld" parameterType="java.util.HashMap" resultType="HashMap">
        select weightNo actual_first_no,
        noticeId prediction_no,
        replace(carNo, '-', '') car_no,
        weight*1000 meter_weight,
        weightTime create_time,
        fs_pointId base_spot_no,
        pointName base_spot_name,
        sender forwarding_unit_no,
        senderName forwarding_unit_name,
        receiver receiving_uint_no,
        receiverName receiving_uint_name,
        material matter_no,
        materialName matter_name,
        senderRemark sender_remark,
        '老系统' remark
        from jgweight.VIEW_CAR_FIRST
        where FS_DELETEDTAG='N'
        <if test="remark != null and remark != ''">
            and '老系统' LIKE '%${remark}%'
        </if>
        <if test="predictionNo != null and predictionNo != ''">
            and noticeId LIKE '%${predictionNo}%'
        </if>
        <if test="startTime != null and endTime != null and startTime != '' and endTime != ''">
            and  weightTime  >= TO_DATE(#{startTime}, 'yyyy-MM-dd HH24:mi:ss') and weightTime  &lt;=  TO_DATE(#{endTime}, 'yyyy-MM-dd HH24:mi:ss')
        </if>
        <if test="senderRemark != null and senderRemark != ''">
            and senderRemark LIKE '%${senderRemark}%'
        </if>
        <if test="carNo != null and carNo != ''">
            and replace(carNo, '-', '') like '%${carNo}%'
        </if>
        <if test="baseSpotNo != null and baseSpotNo != ''">
            and fs_pointId like '%${baseSpotNo}%'
        </if>
        <if test="baseSpotName != null and baseSpotName != ''">
            and pointName like '%${baseSpotName}%'
        </if>
        <if test="forwardingUnitNo != null and forwardingUnitNo != ''">
            and sender LIKE '%${forwardingUnitNo}%'
        </if>
        <if test="forwardingUnitName != null and forwardingUnitName != ''">
            and senderName LIKE '%${forwardingUnitName}%'
        </if>
        <if test="receivingUintNo != null and receivingUintNo != ''">
            and receiver LIKE '%${receivingUintNo}%'
        </if>
        <if test="receivingUintName != null and receivingUintName != ''">
            and receiverName LIKE '%${receivingUintName}%'
        </if>
        <if test="matterNo != null and matterNo != ''">
            and material LIKE '%${matterNo}%'
        </if>
        <if test="matterName != null and matterName != ''">
            and materialName LIKE '%${matterName}%'
        </if>
    </select>

    <select id="countNew" parameterType="java.util.HashMap" resultType="HashMap">
        select * from
        (
        select matter_no,
        matter_name,
        count(1) countSum,
        sum(net_weight) net_weight,
        sum(gross_weight) gross_weight,
        sum(tare_weight) tare_weight,
        forwarding_unit_no,
        forwarding_unit_name,
        receiving_uint_no,
        receiving_uint_name,
        '新系统' remark
        from meter_work_car_actual
        where 1= 1
        and IS_PRE_SCALE='1'
        and VALUE_FLAG in ('1', '2')
        and UPLOAD_FLAG='2'
        <if test="startTime != null and endTime != null and startTime != '' and endTime != ''">
            and  net_time  >= TO_DATE(#{startTime}, 'yyyy-MM-dd HH24:mi:ss') and net_time  &lt;=  TO_DATE(#{endTime}, 'yyyy-MM-dd HH24:mi:ss')
        </if>
        <if test="netSpot3No != null and netSpot3No != ''">
            and net_spot3_no like '%${netSpot3No}%'
        </if>
        <if test="netSpot3Name != null and netSpot3Name != ''">
            and net_spot3_name like '%${netSpot3Name}%'
        </if>
        <if test="senderRemark != null and senderRemark != ''">
            and sender_remark LIKE '%${senderRemark}%'
        </if>
        <if test="carNo != null and carNo != ''">
            and car_no LIKE '%${carNo}%'
        </if>
        group by matter_no, matter_name, forwarding_unit_no, forwarding_unit_name, receiving_uint_no, receiving_uint_name
        )
        where 1=1
        <if test="remark != null and remark != ''">
            and remark LIKE '%${remark}%'
        </if>
        <if test="forwardingUnitNo != null and forwardingUnitNo != ''">
            and FORWARDING_UNIT_NO LIKE '%${forwardingUnitNo}%'
        </if>
        <if test="forwardingUnitName != null and forwardingUnitName != ''">
            and FORWARDING_UNIT_NAME LIKE '%${forwardingUnitName}%'
        </if>
        <if test="receivingUintNo != null and receivingUintNo != ''">
            and RECEIVING_UINT_NO LIKE '%${receivingUintNo}%'
        </if>
        <if test="receivingUintName != null and receivingUintName != ''">
            and RECEIVING_UINT_NAME LIKE '%${receivingUintName}%'
        </if>
        <if test="matterNo != null and matterNo != ''">
            and matter_no LIKE '%${matterNo}%'
        </if>
        <if test="matterName != null and matterName != ''">
            and matter_name LIKE '%${matterName}%'
        </if>
    </select>

    <select id="countOld" parameterType="java.util.HashMap" resultType="HashMap">
        select * from
        (
        select fs_material matter_no,
        fs_materialName matter_name,
        count(1) countSum,
        sum(fs_netWeight*1000) net_weight,
        sum(fs_grossWeight*1000) gross_weight,
        sum(fs_tareWeight*1000) tare_weight,
        fs_sender forwarding_unit_no,
        fs_senderName forwarding_unit_name,
        fs_receiver receiving_uint_no,
        fs_receiverName receiving_uint_name,
        '老系统' remark
        from jgweight.view_car_net
        where 1 = 1
        and fs_noticeId is not null
        and FS_DELETEDTAG='N'
        <if test="startTime != null and endTime != null and startTime != '' and endTime != ''">
            and  fs_netweightTime  >= TO_DATE(#{startTime}, 'yyyy-MM-dd HH24:mi:ss') and fs_netweightTime  &lt;=  TO_DATE(#{endTime}, 'yyyy-MM-dd HH24:mi:ss')
        </if>
        <if test="netSpot3No != null and netSpot3No != ''">
            and fs_netPointId like '%${netSpot3No}%'
        </if>
        <if test="netSpot3Name != null and netSpot3Name != ''">
            and fs_netPointName like '%${netSpot3Name}%'
        </if>
        <if test="senderRemark != null and senderRemark != ''">
            and fs_senderRemark LIKE '%${senderRemark}%'
        </if>
        <if test="carNo != null and carNo != ''">
            and FS_CARNO LIKE '%${carNo}%'
        </if>
        group by fs_material, fs_materialName, fs_sender , fs_senderName , fs_receiver , fs_receiverName
        )
        where 1=1
        <if test="remark != null and remark != ''">
            and remark LIKE '%${remark}%'
        </if>
        <if test="forwardingUnitNo != null and forwardingUnitNo != ''">
            and FORWARDING_UNIT_NO LIKE '%${forwardingUnitNo}%'
        </if>
        <if test="forwardingUnitName != null and forwardingUnitName != ''">
            and FORWARDING_UNIT_NAME LIKE '%${forwardingUnitName}%'
        </if>
        <if test="receivingUintNo != null and receivingUintNo != ''">
            and RECEIVING_UINT_NO LIKE '%${receivingUintNo}%'
        </if>
        <if test="receivingUintName != null and receivingUintName != ''">
            and RECEIVING_UINT_NAME LIKE '%${receivingUintName}%'
        </if>
        <if test="matterNo != null and matterNo != ''">
            and matter_no LIKE '%${matterNo}%'
        </if>
        <if test="matterName != null and matterName != ''">
            and matter_name LIKE '%${matterName}%'
        </if>
    </select>

    <select id="doQueryRailwayNew" parameterType="java.util.HashMap" resultType="HashMap">
        select RAILWAY_NO,
        PREDICTION_NO,
        GROSS_WEIGHT,
        TARE_WEIGHT,
        NET_WEIGHT,
        NET_TIME,
        GROSS_TIME,
        TARE_TIME,
        BASE_SPOT1_NAME,
        BASE_SPOT2_NAME,
        NET_SPOT3_NAME,
        RAILWAY_TYPE_NAME,
        VALUE_FLAG,
        FORWARDING_UNIT_NAME,
        SENDER_REMARK,
        RECEIVING_UINT_NAME,
        RECEIVER_REMARK,
        MATTER_NAME,
        '新系统' as remark
        from METER_WORK_RAILWAY_ACTUAL
        where VALUE_FLAG in ('2') and RAILWAY_TYPE_NO = '001019001'
        <if test="remark != null and remark != ''">
            and '新系统' LIKE '%${remark}%'
        </if>
        <if test="predictionNo != null and predictionNo != ''">
            and PREDICTION_NO LIKE '%${predictionNo}%'
        </if>
        <if test="minWeight != null and minWeight != ''">
            and NET_WEIGHT &gt; '%${minWeight}%'
        </if>
        <if test="maxWeight != null and maxWeight != ''">
            and NET_WEIGHT &lt; '%${maxWeight}%'
        </if>
        <if test="netSpot3No != null and netSpot3No != ''">
            and BASE_SPOT1_NO like '%${netSpot3No}%'
        </if>
        <if test="netSpot3Name != null and netSpot3Name != ''">
            and BASE_SPOT1_NAME like '%${netSpot3Name}%'
        </if>
        <if test="startTime != null and endTime != null and startTime != '' and endTime != ''">
            and NET_TIME  >= TO_DATE(#{startTime}, 'yyyy-MM-dd HH24:mi:ss') and NET_TIME  &lt;=  TO_DATE(#{endTime}, 'yyyy-MM-dd HH24:mi:ss')
        </if>
        <if test="forwardingUnitNo != null and forwardingUnitNo != ''">
            and FORWARDING_UNIT_NO LIKE '%${forwardingUnitNo}%'
        </if>
        <if test="forwardingUnitName != null and forwardingUnitName != ''">
            and FORWARDING_UNIT_NAME LIKE '%${forwardingUnitName}%'
        </if>
        <if test="receivingUintNo != null and receivingUintNo != ''">
            and RECEIVING_UINT_NO LIKE '%${receivingUintNo}%'
        </if>
        <if test="receivingUintName != null and receivingUintName != ''">
            and RECEIVING_UINT_NAME LIKE '%${receivingUintName}%'
        </if>
        <if test="railwayNo != null and railwayNo != ''">
            and RAILWAY_NO like '%${railwayNo}%'
        </if>
        <if test="matterNo != null and matterNo != ''">
            and MATTER_NO LIKE '%${matterNo}%'
        </if>
        <if test="matterName != null and matterName != ''">
            and materialName LIKE '%${matterName}%'
        </if>
        <if test="senderRemark != null and senderRemark != ''">
            and RECEIVER_REMARK LIKE '%${senderRemark}%'
        </if>
    </select>

    <select id="doQueryRailwayOld" parameterType="java.util.HashMap" resultType="HashMap">
    select FS_TRAINNO RAILWAY_NO,
FS_NOTICENO PREDICTION_NO,
FN_GROSSWEIGHT*1000 GROSS_WEIGHT,
FN_TAREWEIGHT*1000 TARE_WEIGHT,
FN_NETWEIGHT*1000 NET_WEIGHT,
FD_NETWEIGHTTIME NET_TIME,
FD_GROSSWEIGHTTIME GROSS_TIME,
FD_TAREWEIGHTTIME TARE_TIME,
FS_GROSSWEIGHTPOINTNAME BASE_SPOT1_NAME,
FS_TAREWEIGHTPOINTNAME BASE_SPOT2_NAME,
FS_NETPOINTNAME NET_SPOT3_NAME,
FS_BALANCETYPE RAILWAY_TYPE_NAME,
FS_ISVALID VALUE_FLAG,
FS_SENDERNAME FORWARDING_UNIT_NAME,
FS_SENDERREMARK SENDER_REMARK,
FS_RECEIVERNAME RECEIVING_UINT_NAME,
FS_RECEIVERREMARK RECEIVER_REMARK,
FS_MATERIALNAME MATTER_NAME,
'老系统' as remark
from JGWEIGHT.VIEW_TRAIN_NET
where FS_ISVALID = '1' and FS_DELETEDTAG = 'N' and (FS_BALANCETYPE='静态' or FS_BALANCETYPE='铁水轨道衡')
        <if test="remark != null and remark != ''">
            and '老系统' LIKE '%${remark}%'
        </if>
        <if test="predictionNo != null and predictionNo != ''">
            and FS_NOTICENO LIKE '%${predictionNo}%'
        </if>
        <if test="minWeight != null and minWeight != ''">
            and FN_NETWEIGHT &gt; '%${minWeight}%'
        </if>
        <if test="maxWeight != null and maxWeight != ''">
            and FN_NETWEIGHT &lt; '%${maxWeight}%'
        </if>
        <if test="netSpot3No != null and netSpot3No != ''">
            and fs_netPointId like '%${netSpot3No}%'
        </if>
        <if test="netSpot3Name != null and netSpot3Name != ''">
            and FS_NETPOINTNAME like '%${netSpot3Name}%'
        </if>
        <if test="startTime != null and endTime != null and startTime != '' and endTime != ''">
            and FD_NETWEIGHTTIME >= TO_DATE(#{startTime}, 'yyyy-MM-dd HH24:mi:ss') and FD_NETWEIGHTTIME  &lt;=  TO_DATE(#{endTime}, 'yyyy-MM-dd HH24:mi:ss')
        </if>
        <if test="forwardingUnitNo != null and forwardingUnitNo != ''">
            and FS_SENDER LIKE '%${forwardingUnitNo}%'
        </if>
        <if test="forwardingUnitName != null and forwardingUnitName != ''">
            and FS_SENDERNAME LIKE '%${forwardingUnitName}%'
        </if>
        <if test="receivingUintNo != null and receivingUintNo != ''">
            and fs_receiver LIKE '%${receivingUintNo}%'
        </if>
        <if test="receivingUintName != null and receivingUintName != ''">
            and FS_RECEIVERNAME LIKE '%${receivingUintName}%'
        </if>
        <if test="railwayNo != null and railwayNo != ''">
            and FS_TRAINNO like '%${railwayNo}%'
        </if>
        <if test="matterNo != null and matterNo != ''">
            and fs_material LIKE '%${matterNo}%'
        </if>
        <if test="matterName != null and matterName != ''">
            and FS_MATERIALNAME LIKE '%${matterName}%'
        </if>
        <if test="senderRemark != null and senderRemark != ''">
            and fs_senderRemark LIKE '%${senderRemark}%'
        </if>
    </select>

    <select id="doQueryRailwayFirstNew" parameterType="java.util.HashMap" resultType="HashMap">
        select actual_first_no,
        prediction_no,
        RAILWAY_NO,
        meter_weight,
        create_time,
        base_spot_no,
        base_spot_name,
        forwarding_unit_no,
        forwarding_unit_name,
        receiving_uint_no,
        receiving_uint_name,
        matter_no,
        matter_name,
        sender_remark,
        '新系统' remark
        from meter_work_railway_act_first
        where VALUE_FLAG in ('2') and RAILWAY_TYPE_NO = '001019001'
        <if test="remark != null and remark != ''">
            and '新系统' LIKE '%${remark}%'
        </if>
        <if test="predictionNo != null and predictionNo != ''">
            and prediction_no LIKE '%${predictionNo}%'
        </if>
        <if test="startTime != null and endTime != null and startTime != '' and endTime != ''">
            and  create_time  >= TO_DATE(#{startTime}, 'yyyy-MM-dd HH24:mi:ss') and create_time  &lt;=  TO_DATE(#{endTime}, 'yyyy-MM-dd HH24:mi:ss')
        </if>
        <if test="senderRemark != null and senderRemark != ''">
            and sender_remark LIKE '%${senderRemark}%'
        </if>
        <if test="railwayNo != null and railwayNo != ''">
            and RAILWAY_NO like '%${railwayNo}%'
        </if>
        <if test="baseSpotNo != null and baseSpotNo != ''">
            and base_spot_no like '%${baseSpotNo}%'
        </if>
        <if test="baseSpotName != null and baseSpotName != ''">
            and base_spot_name like '%${baseSpotName}%'
        </if>
        <if test="forwardingUnitNo != null and forwardingUnitNo != ''">
            and FORWARDING_UNIT_NO LIKE '%${forwardingUnitNo}%'
        </if>
        <if test="forwardingUnitName != null and forwardingUnitName != ''">
            and FORWARDING_UNIT_NAME LIKE '%${forwardingUnitName}%'
        </if>
        <if test="receivingUintNo != null and receivingUintNo != ''">
            and RECEIVING_UINT_NO LIKE '%${receivingUintNo}%'
        </if>
        <if test="receivingUintName != null and receivingUintName != ''">
            and RECEIVING_UINT_NAME LIKE '%${receivingUintName}%'
        </if>
        <if test="matterNo != null and matterNo != ''">
            and matter_no LIKE '%${matterNo}%'
        </if>
        <if test="matterName != null and matterName != ''">
            and matter_name LIKE '%${matterName}%'
        </if>
    </select>

    <select id="doQueryRailwayFirstOld" parameterType="java.util.HashMap" resultType="HashMap">
        select FS_WEIGHTNO actual_first_no,
        FS_noticeNO prediction_no,
        FS_TRAINNO RAILWAY_NO,
        FN_weight*1000 meter_weight,
        FD_weightTime create_time,
        fs_pointId base_spot_no,
        FS_pointName base_spot_name,
        FS_sender forwarding_unit_no,
        FS_senderName forwarding_unit_name,
        FS_receiver receiving_uint_no,
        FS_receiverName receiving_uint_name,
        FS_material matter_no,
        FS_materialName matter_name,
        FS_SENDERREMARK sender_remark,
        '老系统' remark
        from jgweight.VIEW_TRAIN_FIRST
        where FS_DELETEDTAG='N' and FS_BALANCETYPE='静态'
        <if test="remark != null and remark != ''">
            and '老系统' LIKE '%${remark}%'
        </if>
        <if test="predictionNo != null and predictionNo != ''">
            and FS_noticeNO LIKE '%${predictionNo}%'
        </if>
        <if test="startTime != null and endTime != null and startTime != '' and endTime != ''">
            and FD_weightTime >= TO_DATE(#{startTime}, 'yyyy-MM-dd HH24:mi:ss') and FD_weightTime  &lt;=  TO_DATE(#{endTime}, 'yyyy-MM-dd HH24:mi:ss')
        </if>
        <if test="senderRemark != null and senderRemark != ''">
            and FS_SENDERREMARK LIKE '%${senderRemark}%'
        </if>
        <if test="railwayNo != null and railwayNo != ''">
            and FS_TRAINNO like '%${railwayNo}%'
        </if>
        <if test="baseSpotNo != null and baseSpotNo != ''">
            and fs_pointId like '%${baseSpotNo}%'
        </if>
        <if test="baseSpotName != null and baseSpotName != ''">
            and FS_pointName like '%${baseSpotName}%'
        </if>
        <if test="forwardingUnitNo != null and forwardingUnitNo != ''">
            and FS_sender LIKE '%${forwardingUnitNo}%'
        </if>
        <if test="forwardingUnitName != null and forwardingUnitName != ''">
            and FS_senderName LIKE '%${forwardingUnitName}%'
        </if>
        <if test="receivingUintNo != null and receivingUintNo != ''">
            and FS_receiver LIKE '%${receivingUintNo}%'
        </if>
        <if test="receivingUintName != null and receivingUintName != ''">
            and FS_receiverName LIKE '%${receivingUintName}%'
        </if>
        <if test="matterNo != null and matterNo != ''">
            and FS_material LIKE '%${matterNo}%'
        </if>
        <if test="matterName != null and matterName != ''">
            and FS_materialName LIKE '%${matterName}%'
        </if>
    </select>

    <select id="countRailwayNew" parameterType="java.util.HashMap" resultType="HashMap">
        select * from
        (
        select matter_no,
        matter_name,
        count(1) countSum,
        sum(net_weight) net_weight,
        sum(gross_weight) gross_weight,
        sum(tare_weight) tare_weight,
        forwarding_unit_no,
        forwarding_unit_name,
        receiving_uint_no,
        receiving_uint_name,
        '新系统' remark
        from METER_WORK_RAILWAY_ACTUAL
        where 1= 1
        and VALUE_FLAG in ('2') and RAILWAY_TYPE_NO = '001019001'
        <if test="startTime != null and endTime != null and startTime != '' and endTime != ''">
            and net_time  >= TO_DATE(#{startTime}, 'yyyy-MM-dd HH24:mi:ss') and net_time  &lt;=  TO_DATE(#{endTime}, 'yyyy-MM-dd HH24:mi:ss')
        </if>
        <if test="netSpot3No != null and netSpot3No != ''">
            and net_spot3_no like '%${netSpot3No}%'
        </if>
        <if test="netSpot3Name != null and netSpot3Name != ''">
            and net_spot3_name like '%${netSpot3Name}%'
        </if>
        <if test="senderRemark != null and senderRemark != ''">
            and sender_remark LIKE '%${senderRemark}%'
        </if>
        <if test="railwayNo != null and railwayNo != ''">
            and RAILWAY_NO like '%${railwayNo}%'
        </if>
        group by matter_no, matter_name, forwarding_unit_no, forwarding_unit_name, receiving_uint_no, receiving_uint_name
        )
        where 1=1
        <if test="remark != null and remark != ''">
            and remark LIKE '%${remark}%'
        </if>
        <if test="forwardingUnitNo != null and forwardingUnitNo != ''">
            and FORWARDING_UNIT_NO LIKE '%${forwardingUnitNo}%'
        </if>
        <if test="forwardingUnitName != null and forwardingUnitName != ''">
            and FORWARDING_UNIT_NAME LIKE '%${forwardingUnitName}%'
        </if>
        <if test="receivingUintNo != null and receivingUintNo != ''">
            and RECEIVING_UINT_NO LIKE '%${receivingUintNo}%'
        </if>
        <if test="receivingUintName != null and receivingUintName != ''">
            and RECEIVING_UINT_NAME LIKE '%${receivingUintName}%'
        </if>
        <if test="matterNo != null and matterNo != ''">
            and matter_no LIKE '%${matterNo}%'
        </if>
        <if test="matterName != null and matterName != ''">
            and matter_name LIKE '%${matterName}%'
        </if>
    </select>

    <select id="countRailwayOld" parameterType="java.util.HashMap" resultType="HashMap">
        select * from
        (
        select fs_material matter_no,
        fs_materialName matter_name,
        count(1) countSum,
        sum(fn_netWeight*1000) net_weight,
        sum(fn_grossWeight*1000) gross_weight,
        sum(fn_tareWeight*1000) tare_weight,
        fs_sender forwarding_unit_no,
        fs_senderName forwarding_unit_name,
        fs_receiver receiving_uint_no,
        fs_receiverName receiving_uint_name,
        '老系统' remark
        from JGWEIGHT.VIEW_TRAIN_NET
        where 1 = 1
        and FS_TRAINNO is not null
        and FS_DELETEDTAG='N'
        <if test="startTime != null and endTime != null and startTime != '' and endTime != ''">
            and Fd_NETWEIGHTTIME  >= TO_DATE(#{startTime}, 'yyyy-MM-dd HH24:mi:ss') and Fd_NETWEIGHTTIME  &lt;=  TO_DATE(#{endTime}, 'yyyy-MM-dd HH24:mi:ss')
        </if>
        <if test="netSpot3No != null and netSpot3No != ''">
            and fs_netPointId like '%${netSpot3No}%'
        </if>
        <if test="netSpot3Name != null and netSpot3Name != ''">
            and fs_netPointName like '%${netSpot3Name}%'
        </if>
        <if test="senderRemark != null and senderRemark != ''">
            and fs_senderRemark LIKE '%${senderRemark}%'
        </if>
        <if test="railwayNo != null and railwayNo != ''">
            and FS_TRAINNO LIKE '%${railwayNo}%'
        </if>
        group by fs_material, fs_materialName, fs_sender , fs_senderName , fs_receiver , fs_receiverName
        )
        where 1=1
        <if test="remark != null and remark != ''">
            and remark LIKE '%${remark}%'
        </if>
        <if test="forwardingUnitNo != null and forwardingUnitNo != ''">
            and FORWARDING_UNIT_NO LIKE '%${forwardingUnitNo}%'
        </if>
        <if test="forwardingUnitName != null and forwardingUnitName != ''">
            and FORWARDING_UNIT_NAME LIKE '%${forwardingUnitName}%'
        </if>
        <if test="receivingUintNo != null and receivingUintNo != ''">
            and RECEIVING_UINT_NO LIKE '%${receivingUintNo}%'
        </if>
        <if test="receivingUintName != null and receivingUintName != ''">
            and RECEIVING_UINT_NAME LIKE '%${receivingUintName}%'
        </if>
        <if test="matterNo != null and matterNo != ''">
            and matter_no LIKE '%${matterNo}%'
        </if>
        <if test="matterName != null and matterName != ''">
            and matter_name LIKE '%${matterName}%'
        </if>
    </select>
</mapper>