TGasBottleInfoMapper.xml 14.2 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 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256
<?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.TGasBottleInfoMapper">

    <resultMap type="TGasBottleInfo" id="TGasBottleInfoResult">
        <result property="bottleId"    column="bottle_id"    />
        <result property="stationId"    column="station_id"    />
        <result property="bottleCode"    column="bottle_code"    />
        <result property="myselfNum"    column="myself_num"    />
        <result property="produceUnit"    column="produce_unit"    />
        <result property="produceDate"    column="produce_date"    />
        <result property="produceCode"    column="produce_code"    />
        <result property="bottleStatus"    column="bottle_status"    />
        <result property="lastChargeDate"    column="last_charge_date"    />
        <result property="longitude"    column="longitude"    />
        <result property="latitude"    column="latitude"    />
        <result property="chargeMedium"    column="charge_medium"    />
        <result property="bottleSpecs"    column="bottle_specs"    />
        <result property="ratedPresure"    column="rated_presure"    />
        <result property="bottleCapacity"    column="bottle_capacity"    />
        <result property="wallThickness"    column="wall_thickness"    />
        <result property="tare"    column="tare"    />
        <result property="useRegisterCode"    column="use_register_code"    />
        <result property="registerDate"    column="register_date"    />
        <result property="lastCheckDate"    column="last_check_date"    />
        <result property="nextCheckDate"    column="next_check_date"    />
        <result property="scrapDate"    column="scrap_date"    />
        <result property="currentStatus"    column="current_status"    />
        <result property="emptyType"    column="empty_type"    />
        <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"/>
    </resultMap>

    <sql id="selectTGasBottleInfoVo">

        SELECT
            bottle.bottle_id,
            bottle.station_id,
            bottle.bottle_code,
            bottle.myself_num,
            bottle.produce_unit,
            bottle.produce_date,
            bottle.produce_code,
            bottle.bottle_status,
            bottle.last_charge_date,
            bottle.longitude,
            bottle.latitude,
            bottle.charge_medium,
            bottle.bottle_specs,
            bottle.rated_presure,
            bottle_capacity,
            bottle.wall_thickness,
            bottle.tare,
            bottle.use_register_code,
            bottle.register_date,
            bottle.last_check_date,
            bottle.next_check_date,
            bottle.scrap_date,
            bottle.current_status,
            bottle.empty_type,
            bottle.create_time,
            bottle.update_time,
            bottle.is_del,
            bottle.remark,
           (SELECT station_name FROM t_gas_storage_station_info info WHERE info.station_id = bottle.station_id) as station_name
        FROM
            t_gas_bottle_info bottle
    </sql>

    <select id="selectTGasBottleInfoList" parameterType="TGasBottleInfo" resultMap="TGasBottleInfoResult">
        <include refid="selectTGasBottleInfoVo"/>
        <where>
            <if test="stationId != null "> and station_id = #{stationId}</if>
            <if test="bottleCode != null  and bottleCode != ''"> and bottle.bottle_code = #{bottleCode}</if>
            <if test="myselfNum != null  and myselfNum != ''"> and bottle.myself_num = #{myselfNum}</if>
            <if test="produceUnit != null  and produceUnit != ''"> and bottle.produce_unit = #{produceUnit}</if>
            <if test="produceDate != null "> and bottle.produce_date = #{produceDate}</if>
            <if test="produceBeginTime != null and produceEndTime">and bottle.produce_date between #{produceBeginTime} and #{produceEndTime}</if>
            <if test="produceCode != null  and produceCode != ''"> and bottle.produce_code = #{produceCode}</if>
            <if test="bottleStatus != null  and bottleStatus != ''"> and bottle.bottle_status = #{bottleStatus}</if>
            <if test="lastChargeDate != null "> and bottle.last_charge_date = #{lastChargeDate}</if>
            <if test="longitude != null "> and bottle.longitude = #{longitude}</if>
            <if test="latitude != null "> and bottle.latitude = #{latitude}</if>
            <if test="chargeMedium != null  and chargeMedium != ''"> and bottle.charge_medium = #{chargeMedium}</if>
            <if test="bottleSpecs != null  and bottleSpecs != ''"> and bottle.bottle_specs = #{bottleSpecs}</if>
            <if test="ratedPresure != null  and ratedPresure != ''"> and bottle.rated_presure = #{ratedPresure}</if>
            <if test="bottleCapacity != null  and bottleCapacity != ''"> and bottle.bottle_capacity = #{bottleCapacity}</if>
            <if test="wallThickness != null  and wallThickness != ''"> and bottle.wall_thickness = #{wallThickness}</if>
            <if test="tare != null  and tare != ''"> and bottle.tare = #{tare}</if>
            <if test="useRegisterCode != null  and useRegisterCode != ''"> and bottle.use_register_code = #{useRegisterCode}</if>
            <if test="registerDate != null "> and bottle.register_date = #{registerDate}</if>
            <if test="lastCheckDate != null "> and bottle.last_check_date = #{lastCheckDate}</if>
            <if test="nextCheckDate != null "> and bottle.next_check_date = #{nextCheckDate}</if>
            <if test="scrapDate != null "> and bottle.scrap_date = #{scrapDate}</if>
            <if test="currentStatus != null  and currentStatus != ''"> and bottle.current_status = #{currentStatus}</if>
            <if test="emptyType != null  and emptyType != ''"> and bottle.empty_type = #{emptyType}</if>
            <if test="isDel != null  and isDel != ''"> and bottle.is_del = #{isDel}</if>
        </where>
        order by bottle.bottle_id desc
    </select>

    <select id="selectTGasBottleInfoById" parameterType="Long" resultMap="TGasBottleInfoResult">
        <include refid="selectTGasBottleInfoVo"/>
        where bottle.bottle_id = #{bottleId}
    </select>

    <insert id="insertTGasBottleInfo" parameterType="TGasBottleInfo" useGeneratedKeys="true" keyProperty="bottleId">
        insert into t_gas_bottle_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="stationId != null">station_id,</if>
            <if test="bottleCode != null">bottle_code,</if>
            <if test="myselfNum != null">myself_num,</if>
            <if test="produceUnit != null">produce_unit,</if>
            <if test="produceDate != null">produce_date,</if>
            <if test="produceCode != null">produce_code,</if>
            <if test="bottleStatus != null">bottle_status,</if>
            <if test="lastChargeDate != null">last_charge_date,</if>
            <if test="longitude != null">longitude,</if>
            <if test="latitude != null">latitude,</if>
            <if test="chargeMedium != null">charge_medium,</if>
            <if test="bottleSpecs != null">bottle_specs,</if>
            <if test="ratedPresure != null">rated_presure,</if>
            <if test="bottleCapacity != null">bottle_capacity,</if>
            <if test="wallThickness != null">wall_thickness,</if>
            <if test="tare != null">tare,</if>
            <if test="useRegisterCode != null">use_register_code,</if>
            <if test="registerDate != null">register_date,</if>
            <if test="lastCheckDate != null">last_check_date,</if>
            <if test="nextCheckDate != null">next_check_date,</if>
            <if test="scrapDate != null">scrap_date,</if>
            <if test="currentStatus != null">current_status,</if>
            <if test="emptyType != null">empty_type,</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="bottleCode != null">#{bottleCode},</if>
            <if test="myselfNum != null">#{myselfNum},</if>
            <if test="produceUnit != null">#{produceUnit},</if>
            <if test="produceDate != null">#{produceDate},</if>
            <if test="produceCode != null">#{produceCode},</if>
            <if test="bottleStatus != null">#{bottleStatus},</if>
            <if test="lastChargeDate != null">#{lastChargeDate},</if>
            <if test="longitude != null">#{longitude},</if>
            <if test="latitude != null">#{latitude},</if>
            <if test="chargeMedium != null">#{chargeMedium},</if>
            <if test="bottleSpecs != null">#{bottleSpecs},</if>
            <if test="ratedPresure != null">#{ratedPresure},</if>
            <if test="bottleCapacity != null">#{bottleCapacity},</if>
            <if test="wallThickness != null">#{wallThickness},</if>
            <if test="tare != null">#{tare},</if>
            <if test="useRegisterCode != null">#{useRegisterCode},</if>
            <if test="registerDate != null">#{registerDate},</if>
            <if test="lastCheckDate != null">#{lastCheckDate},</if>
            <if test="nextCheckDate != null">#{nextCheckDate},</if>
            <if test="scrapDate != null">#{scrapDate},</if>
            <if test="currentStatus != null">#{currentStatus},</if>
            <if test="emptyType != null">#{emptyType},</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="updateTGasBottleInfo" parameterType="TGasBottleInfo">
        update t_gas_bottle_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="stationId != null">station_id = #{stationId},</if>
            <if test="bottleCode != null">bottle_code = #{bottleCode},</if>
            <if test="myselfNum != null">myself_num = #{myselfNum},</if>
            <if test="produceUnit != null">produce_unit = #{produceUnit},</if>
            <if test="produceDate != null">produce_date = #{produceDate},</if>
            <if test="produceCode != null">produce_code = #{produceCode},</if>
            <if test="bottleStatus != null">bottle_status = #{bottleStatus},</if>
            <if test="lastChargeDate != null">last_charge_date = #{lastChargeDate},</if>
            <if test="longitude != null">longitude = #{longitude},</if>
            <if test="latitude != null">latitude = #{latitude},</if>
            <if test="chargeMedium != null">charge_medium = #{chargeMedium},</if>
            <if test="bottleSpecs != null">bottle_specs = #{bottleSpecs},</if>
            <if test="ratedPresure != null">rated_presure = #{ratedPresure},</if>
            <if test="bottleCapacity != null">bottle_capacity = #{bottleCapacity},</if>
            <if test="wallThickness != null">wall_thickness = #{wallThickness},</if>
            <if test="tare != null">tare = #{tare},</if>
            <if test="useRegisterCode != null">use_register_code = #{useRegisterCode},</if>
            <if test="registerDate != null">register_date = #{registerDate},</if>
            <if test="lastCheckDate != null">last_check_date = #{lastCheckDate},</if>
            <if test="nextCheckDate != null">next_check_date = #{nextCheckDate},</if>
            <if test="scrapDate != null">scrap_date = #{scrapDate},</if>
            <if test="currentStatus != null">current_status = #{currentStatus},</if>
            <if test="emptyType != null">empty_type = #{emptyType},</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 bottle_id = #{bottleId}
    </update>

    <delete id="deleteTGasBottleInfoById" parameterType="Long">
        delete from t_gas_bottle_info where bottle_id = #{bottleId}
    </delete>

    <delete id="deleteTGasBottleInfoByIds" parameterType="String">
        delete from t_gas_bottle_info where bottle_id in
        <foreach item="bottleId" collection="array" open="(" separator="," close=")">
            #{bottleId}
        </foreach>
    </delete>

    <select id="bottleStatistics" parameterType="java.lang.Long" resultType="com.zehong.system.domain.BottleStatistics">
        select
          (select station_name from t_gas_storage_station_info info where info.station_id = final.station_id) as stationName,
          sum(final.totalNum) as totalNum,
          sum(final.normalNum) as normalNum,
          sum(final.overNum) as overNum,
          sum(final.junkNum) as junkNum
        from(
            select
                base.station_id,
            count(1) as totalNum,
                case bottle_status when '1' then count(1) else 0 end as normalNum,
                case bottle_status when '2' then count(1) else 0 end as overNum,
                case bottle_status when '3' then count(1) else 0 end as junkNum
            from
                t_gas_bottle_info base
            <where>
                <if test="stationId != null">
                    base.station_id = #{stationId}
                </if>
            </where>
            group by
                base.station_id,base.bottle_status
        )final
        group by final.station_id
    </select>

    <!--查询气瓶详细信息-->
    <select id="getInf" resultMap="TGasBottleInfoResult"  parameterType="java.lang.String">
        <include refid="selectTGasBottleInfoVo"/>
        where bottle.bottle_id = #{bottleId}
    </select>

    <select id="getInfn" resultMap="TGasBottleInfoResult"  parameterType="java.lang.String">
        <include refid="selectTGasBottleInfoVo"/>
        where bottle.bottle_code = #{bottleId}
    </select>
</mapper>