TdClRuleCollectSMapper.xml 7.42 KB
<?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.zteits.bill.mapper.smapper.TdClRuleCollectSMapper">
    <resultMap id="BaseResultMap" type="com.zteits.clouds.api.dto.bill.closecarpark.dto.ViewSegmentChargingDTO">
        <id column="id" jdbcType="BIGINT" property="id" />
        <result column="rule_collect_id" jdbcType="VARCHAR" property="ruleCollectId" />
        <result column="rule_collect_name" jdbcType="VARCHAR" property="ruleCollectName" />
        <result column="car_type_strategy" jdbcType="INTEGER" property="carTypeStrategy" />
        <result column="rule_desc" jdbcType="VARCHAR" property="ruleDesc" />
        <result column="data_flg" jdbcType="CHAR" property="dataFlg" />
        <collection property="detailList" ofType="com.zteits.clouds.api.dto.bill.closecarpark.dto.CarSegmentRulesDTO"
                    select="viewCarSegmentRules"
                    column="rule_collect_id">
        </collection>
    </resultMap>

    <resultMap id="BaseResultRuleDetailMap" type="com.zteits.clouds.api.dto.bill.closecarpark.dto.SegmentDetailRulesDTO">
        <id column="id" jdbcType="BIGINT" property="id" />
        <result column="start_time" jdbcType="TIMESTAMP" property="startTime" />
        <result column="rule_id" jdbcType="VARCHAR" property="ruleId" />
        <result column="end_time" jdbcType="TIMESTAMP" property="endTime" />
        <result column="rule_type" jdbcType="INTEGER" property="ruleType" />
        <result column="section_fee_limit" jdbcType="BIGINT" property="sectionFeeLimit" />
        <result column="free_time" jdbcType="BIGINT" property="freeTime" />
        <result column="first_time" jdbcType="BIGINT" property="firstTime" />
        <result column="first_fee" jdbcType="BIGINT" property="firstFee" />
        <result column="loop1_per_time" jdbcType="BIGINT" property="loop1PerTime" />
        <result column="loop1_per_fee" jdbcType="BIGINT" property="loop1PerFee" />
        <result column="loop2_start" jdbcType="BIGINT" property="loop2Start" />
        <result column="loop2_per_time" jdbcType="BIGINT" property="loop2PerTime" />
        <result column="loop2_per_fee" jdbcType="BIGINT" property="loop2PerFee" />
        <result column="dn_flag" jdbcType="INTEGER" property="dnFlag" />
        <result column="retention_time" jdbcType="INTEGER" property="retentionTime" />
    </resultMap>

    <resultMap id="BaseResultRuleMap" type="com.zteits.clouds.api.dto.bill.closecarpark.dto.CarSegmentRulesDTO">
        <id column="id" jdbcType="BIGINT" property="id" />
        <result column="rule_collect_id" jdbcType="VARCHAR" property="ruleCollectId" />
        <result column="rule_id" jdbcType="VARCHAR" property="ruleId" />
        <result column="fee_type" jdbcType="INTEGER" property="feeType" />
        <result column="car_type" jdbcType="INTEGER" property="carType" />
        <result column="loop_type" jdbcType="INTEGER" property="loopType" />
        <result column="rule_fee_limit" jdbcType="INTEGER" property="ruleFeeLimit" />
        <result column="cross_period_strategy" jdbcType="INTEGER" property="crossPeriodStrategy" />
        <collection property="segmentDetailList" ofType="com.zteits.clouds.api.dto.bill.closecarpark.dto.SegmentDetailRulesDTO"
                    select="viewSegmentDetailRules"
                    column="rule_id">
        </collection>
    </resultMap>
    <!-- 根据停车场编号以及区域ID获取计费规则合计 -->
    <select id="queryRuleCollectByPlnoAndAreaId"
            resultType="com.zteits.clouds.api.dto.bill.cloudbilling.dto.CloudRuleCollectDTO">

     SELECT
       c.id,
       r.pl_no as plNo,
       c.rule_collect_id as ruleCollectId,
       c.rule_collect_name as ruleCollectName,
       r.eff_date as effDate,
       c.car_type_strategy as carTypeStrategy
    FROM td_cl_park_rule_collect_rel r
    LEFT JOIN td_cl_rule_collect c on r.rule_collect_id = c.rule_collect_id
        WHERE r.pl_no = #{plNo}
        LIMIT 1

    </select>

    <select id="viewParkingChargingRules" parameterType="java.lang.String"
            resultType="com.zteits.clouds.api.dto.bill.closecarpark.dto.DetailRulesDTO">
        select
          r.id id,
          r.rule_collect_id ruleCollectId,
          r.rule_id ruleId,
          r.fee_type feeType,
          r.car_type carType,
          r.loop_type loopType,
          r.rule_fee_limit ruleFeeLimit,
          r.cross_period_strategy crossPeriodStrategy,
          d.id detailId,
          d.start_time startTime,
          d.end_time endTime,
          d.rule_type ruleType,
          d.section_fee_limit sectionFeeLimit,
          d.free_time freeTime,
          d.first_time firstTime,
          d.first_fee firstFee,
          d.loop1_per_time loop1PerTime,
          d.loop1_per_fee loop1PerFee,
          d.retention_time retentionTime,
          c.rule_collect_name ruleCollectName,
          c.car_type_strategy carTypeStrategy,
          c.rule_desc ruleDesc,
          d.loop2_per_fee loop2PerFee
        FROM
        td_cl_rule r
        LEFT JOIN td_cl_rule_detail d ON r.rule_id = d.rule_id
        LEFT JOIN td_cl_rule_collect c ON r.rule_collect_id = c.rule_collect_id
        where r.rule_collect_id = #{ruleCollectId,jdbcType=VARCHAR}
    </select>

    <!-- 根据计费规则id获取计费集合 -->
    <select id="viewParkingSegmentCharging" resultMap="BaseResultMap">

     SELECT
       c.id,
       c.rule_collect_id,
       c.rule_collect_name,
       c.car_type_strategy,
       c.rule_desc
    FROM td_cl_rule_collect c
    WHERE c.id = #{id}
        LIMIT 1

    </select>

    <!-- 根据计费规则id获取计费规则 -->
    <select id="viewCarSegmentRules" resultMap="BaseResultRuleMap">
     SELECT
       r.id,
       r.rule_collect_id,
       r.rule_id,
       r.fee_type,
       r.car_type,
       r.loop_type,
       r.rule_fee_limit,
       r.cross_period_strategy
    FROM td_cl_rule r
    WHERE r.rule_collect_id = #{ruleCollectId}
    group by r.id

    </select>

    <!-- 根据计费规则id获取计费规则详情 -->
    <select id="viewSegmentDetailRules" resultMap="BaseResultRuleDetailMap">
     SELECT
       d.id,
       d.rule_id,
       d.end_time,
       d.start_time,
       d.rule_type,
       d.section_fee_limit,
       d.free_time,
       d.first_time,
       d.first_fee,
       d.loop1_per_time,
       d.loop1_per_fee,
       d.loop2_start,
       d.loop2_per_time,
       d.loop2_per_fee,
       d.dn_flag,
       d.retention_time
    FROM td_cl_rule_detail d
    WHERE d.rule_id = #{ruleId}
    group by d.id

    </select>


    <!-- 根据计费规则id获取计费规则详情 -->
    <select id="queryParkingSegmentCharging" parameterType="com.zteits.clouds.api.dto.bill.closecarpark.param.QuerySegmentChargingRequest"
            resultType="com.zteits.clouds.api.dto.bill.closecarpark.dto.SegmentChargingDTO">
     SELECT
       c.id,
       c.rule_collect_id ruleCollectId,
       c.rule_collect_name ruleCollectName,
       c.car_type_strategy carTypeStrategy,
       c.rule_desc ruleDesc,
       c.data_flg dataFlg,
       c.fee_type feeType,
       c.org_id
    FROM td_cl_rule_collect c
    WHERE c.fee_type = 2
      and c.data_flg = 1
        <if test="ruleCollectName != null and ruleCollectName != ''">
            AND c.rule_collect_name like concat('%',#{ruleCollectName,jdbcType=VARCHAR},'%')
        </if>
        <if test="orgId != null and orgId != ''">
            AND c.org_id = #{orgId}
        </if>
    </select>
</mapper>