TAirChargeRecordMapper.xml 8.53 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
<?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.zehong.system.mapper.TAirChargeRecordMapper">

    <resultMap type="TAirChargeRecord" id="TAirChargeRecordResult">
        <result property="chargeRecordId"    column="charge_record_id"    />
        <result property="stationId"    column="station_id"    />
        <result property="bottleId"    column="bottle_id"    />
        <result property="chargeOperator"    column="charge_operator"    />
        <result property="chargeMeasure"    column="charge_measure"    />
        <result property="chargeDate"    column="charge_date"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="isDel"    column="is_del"    />
        <result property="remark"    column="remark"    />
        <result property="stationName" column="station_name"/>
        <result property="bottleCode" column="bottle_code"/>
        <result property="bottleCapacity" column="bottle_capacity"/>
        <result property="bottleStatus" column="bottle_status"/>
        <result property="chargeOperatorName" column="charge_operator_name"/>
    </resultMap>

    <sql id="selectTAirChargeRecordVo">
        SELECT
            charge.charge_record_id,
            charge.station_id,
            charge.bottle_id,
            charge.charge_operator,
            charge.charge_measure,
            charge.charge_date,
            charge.create_time,
            charge.update_time,
            charge.is_del,
            charge.remark,
            station.station_name,
            bottle.bottle_code,
            bottle.bottle_capacity,
            bottle.bottle_status,
            pr.name AS charge_operator_name
        FROM
            t_air_charge_record charge
        LEFT JOIN t_gas_storage_station_info station ON station.station_id = charge.station_id
        LEFT JOIN t_gas_bottle_info bottle ON bottle.bottle_id = charge.bottle_id
        LEFT JOIN t_practitioner_info pr ON pr.practitioner_id = charge.charge_operator
    </sql>

    <select id="selectTAirChargeRecordList" parameterType="TAirChargeRecord" resultMap="TAirChargeRecordResult">
        <include refid="selectTAirChargeRecordVo"/>
        <where>
            <if test="stationId != null "> and charge.station_id = #{stationId}</if>
            <if test="bottleId != null "> and charge.bottle_id = #{bottleId}</if>
            <if test="chargeOperator != null "> and charge.charge_operator = #{chargeOperator}</if>
            <if test="chargeMeasure != null  and chargeMeasure != ''"> and charge.charge_measure = #{chargeMeasure}</if>
            <if test="chargeDate != null "> and charge.charge_date = #{chargeDate}</if>
            <if test="isDel != null  and isDel != ''"> and charge.is_del = #{isDel}</if>
            <if test="chargeBeginTime != null and chargeEndTime != null">and charge.charge_date BETWEEN #{chargeBeginTime} and #{chargeEndTime}</if>
            <if test="bottleCode != null">and bottle.bottle_code like concat('%', #{bottleCode}, '%')</if>
            <if test="stationName != null">and station.station_name like concat('%', #{stationName}, '%')</if>
        </where>
        order by   charge.charge_record_id desc
    </select>

    <select id="selectTAirChargeRecordById" parameterType="Long" resultMap="TAirChargeRecordResult">
        <include refid="selectTAirChargeRecordVo"/>
        where charge.charge_record_id = #{chargeRecordId}
    </select>

    <insert id="insertTAirChargeRecord" parameterType="TAirChargeRecord" useGeneratedKeys="true" keyProperty="chargeRecordId">
        insert into t_air_charge_record
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="stationId != null">station_id,</if>
            <if test="bottleId != null">bottle_id,</if>
            <if test="chargeOperator != null">charge_operator,</if>
            <if test="chargeMeasure != null">charge_measure,</if>
            <if test="chargeDate != null">charge_date,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="isDel != null">is_del,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="stationId != null">#{stationId},</if>
            <if test="bottleId != null">#{bottleId},</if>
            <if test="chargeOperator != null">#{chargeOperator},</if>
            <if test="chargeMeasure != null">#{chargeMeasure},</if>
            <if test="chargeDate != null">#{chargeDate},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="isDel != null">#{isDel},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateTAirChargeRecord" parameterType="TAirChargeRecord">
        update t_air_charge_record
        <trim prefix="SET" suffixOverrides=",">
            <if test="stationId != null">station_id = #{stationId},</if>
            <if test="bottleId != null">bottle_id = #{bottleId},</if>
            <if test="chargeOperator != null">charge_operator = #{chargeOperator},</if>
            <if test="chargeMeasure != null">charge_measure = #{chargeMeasure},</if>
            <if test="chargeDate != null">charge_date = #{chargeDate},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="isDel != null">is_del = #{isDel},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where charge_record_id = #{chargeRecordId}
    </update>

    <delete id="deleteTAirChargeRecordById" parameterType="Long">
        delete from t_air_charge_record where charge_record_id = #{chargeRecordId}
    </delete>

    <delete id="deleteTAirChargeRecordByIds" parameterType="String">
        delete from t_air_charge_record where charge_record_id in
        <foreach item="chargeRecordId" collection="array" open="(" separator="," close=")">
            #{chargeRecordId}
        </foreach>
    </delete>


    <select id="airChargeStationStatistics" parameterType="com.zehong.system.domain.vo.AirChargeStatisticsVo" resultType="com.zehong.system.domain.AirChargeStationStatistics">
        select
          station.station_name as stationName,
          count(air.charge_record_id)as bottleNum,
          sum(air.charge_measure) as chargeMeasure
        from
            t_air_charge_record air
        left join t_gas_storage_station_info station on station.station_id = air.station_id
        left join t_gas_bottle_info bottle on bottle.bottle_id = air.bottle_id
        left join t_practitioner_info pr ON pr.practitioner_id = air.charge_operator
        <where>
            <if test="stationId != null">
                and air.station_id = #{stationId}
            </if>
            <if test="operator != null">
                and pr.name like concat('%', #{operator}, '%')
            </if>
            <if test="operateBeginTime != null and operateEndTime != null" >
                and air.charge_date between #{operateBeginTime} and #{operateEndTime}
            </if>
        </where>
        group by air.station_id
    </select>

    <select id="airChargeOperatorStatistics" parameterType="com.zehong.system.domain.vo.AirChargeStatisticsVo" resultType="com.zehong.system.domain.AirChargeOperatorStatistics">
        select
          station.station_name as stationName,
          count(air.charge_record_id)as bottleNum,
          sum(air.charge_measure) as chargeMeasure,
          pr.name as operator
        from
            t_air_charge_record air
        left join t_gas_storage_station_info station on station.station_id = air.station_id
        left join t_gas_bottle_info bottle on bottle.bottle_id = air.bottle_id
        left join t_practitioner_info pr ON pr.practitioner_id = air.charge_operator
        <where>
            <if test="stationId != null">
                and air.station_id = #{stationId}
            </if>
            <if test="operator != null">
                and pr.name like concat('%', #{operator}, '%')
            </if>
            <if test="operateBeginTime != null and operateEndTime != null" >
                and air.charge_date between #{operateBeginTime} and #{operateEndTime}
            </if>
        </where>
        group by air.station_id,air.charge_operator
    </select>
</mapper>