TBillingParkRuleRelSMapper.xml 4.99 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.TBillingParkRuleRelSMapper">
    <resultMap id="BaseResultMap" type="com.zteits.bill.domain.TBillingParkRuleRel">
        <id column="id" property="id" jdbcType="BIGINT"/>
        <result column="pl_no" property="plNo" jdbcType="VARCHAR"/>
        <result column="rule_collect_no" property="ruleCollectNo" jdbcType="VARCHAR"/>
        <result column="data_state" property="dataState" jdbcType="INTEGER"/>
        <result column="effect_time" property="effectTime" jdbcType="TIMESTAMP"/>
        <result column="expire_time" property="expireTime" jdbcType="TIMESTAMP"/>
        <result column="check_state" property="checkState" jdbcType="INTEGER"/>
        <result column="create_op" property="createOp" jdbcType="BIGINT"/>
        <result column="create_op_name" property="createOpName" jdbcType="VARCHAR"/>
        <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
        <result column="modify_op" property="modifyOp" jdbcType="BIGINT"/>
        <result column="modify_op_name" property="modifyOpName" jdbcType="VARCHAR"/>
        <result column="modify_time" property="modifyTime" jdbcType="TIMESTAMP"/>
    </resultMap>
    <sql id="Base_Column_List">
    id, pl_no, rule_collect_no, data_state, effect_time, expire_time, check_state, create_op,
    create_op_name, create_time, modify_op, modify_op_name, modify_time
  </sql>

    <sql id="Base_Column_List_No_Id">
         pl_no, rule_collect_no, data_state, effect_time, expire_time, check_state, create_op,
        create_op_name, create_time, modify_op, modify_op_name, modify_time
    </sql>
    <update id="deleteBillingRuleCollectParkRel">
        UPDATE t_billing_park_rule_rel
        SET data_state = 0
        WHERE
            data_state = 1
          AND rule_collect_no =#{ruleCollectNo}

    </update>

    <!-- 分页查询计费规则与停车场管理关系表 langlw 2017-11-22 -->
    <select id="queryBillingParkRuleRelForPage"
            parameterType="com.zteits.clouds.api.dto.bill.billingrule.param.BillingParkRuleRelQueryForPageReq"
            resultType="com.zteits.clouds.api.dto.bill.billingrule.dto.BillingParkRuleRelDTO">
        SELECT

        DISTINCT a.rule_collect_no as ruleCollectNo,
        a.id as id,
        a.pl_no as plNo,
        a.effect_time as effectTime,
        a.expire_time as expireTime,
        b.rule_collect_name as ruleCollectName,
        a.create_time
        FROM
        t_billing_park_rule_rel a
        LEFT JOIN t_billing_rule_collect b
        ON a.rule_collect_no = b.rule_collect_no

        where a.data_state = 1
        AND b.data_state = 1

        <if test="ruleCollectName !=null ">
            AND b.rule_collect_name like CONCAT('%',#{ruleCollectName},'%')
        </if>

        <if test="effectTime !=null ">
            and DATE_FORMAT(a.effect_time ,'%Y-%m-%d') &gt;= DATE_FORMAT(#{effectTime} ,'%Y-%m-%d')
        </if>
        <if test="expireTime !=null ">
            AND DATE_FORMAT(a.expire_time ,'%Y-%m-%d') &lt;= DATE_FORMAT(#{expireTime} ,'%Y-%m-%d')
        </if>

        <!-- 生效中 -->
        <if test="isEff != null and isEff==1 ">
            <![CDATA[ and a.effect_time  <= now()  and  now() <= a.expire_time ]]>
        </if>
        <!-- 已失效 -->
        <if test="isEff != null and isEff==2 ">
            <![CDATA[ and  now()  >  a.expire_time  ]]>
        </if>
        <!-- 未生效 -->
        <if test="isEff != null and isEff==3 ">
            <![CDATA[ and a.effect_time  > now() AND   now() < a.expire_time and a.effect_time < a.expire_time   ]]>
        </if>
        <if test="plNos != null and plNos.size()>0">
            and a.pl_no IN
            <foreach collection="plNos" open="(" close=")" separator="," item="plNo">
                #{plNo}
            </foreach>
        </if>
        ORDER BY a.create_time DESC

    </select>


    <update id="updateBillingRuleCollectExpireTimeByPlNos">

        update t_billing_park_rule_rel SET expire_time =
        #{expireTime},modify_op=#{opId},modify_op_name=#{opName},modify_time=now()
        WHERE pl_no IN
        <foreach collection="plNos" index="index" item="plno" open="(" separator="," close=")">
            #{plno}
        </foreach>
        AND expire_time >= #{newEffectTime}
    </update>

    <insert id="batchSaveBillingRuleCollectParkRel">
        INSERT INTO t_billing_park_rule_rel(
        <include refid="Base_Column_List_No_Id"/>

        ) VALUES
        <foreach collection="plNos" separator="," item="plNo" index="index">
            (
            #{plNo},
            #{ruleCollectNo},
            1,
            #{effectTime},
            '2999-01-01 00:00:00',
            3,
            #{opId},
            #{opName},
            now(),
            #{opId},
            #{opName},
            now()
            )
        </foreach>

    </insert>

    <select id="queryBillingCollectionNoByPlNo" >



    </select>


</mapper>