MCzglMapper.xml 6.57 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.hotent.lpg.manage.dao.MCzglDao">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.hotent.lpg.common.model.WCzgl">
        <id column="ID_" property="id"/>
        <result column="REF_ID_" property="refId"/>
        <result column="F_czsj" property="fCzsj"/>
        <result column="F_czqzmc" property="fCzqzmc"/>
        <result column="F_czxkzbh" property="fCzxkzbh"/>
        <result column="F_czqz" property="fCzqz"/>
        <result column="F_czhz" property="fCzhz"/>
        <result column="F_czqwgjc" property="fCzqwgjc"/>
        <result column="F_czqpfjc" property="fCzqpfjc"/>
        <result column="F_czqfzjc" property="fCzqfzjc"/>
        <result column="F_czqhjjc" property="fCzqhjjc"/>
        <result column="F_czqjcxm" property="fCzqjcxm"/>
        <result column="F_czqjcgh" property="fCzqjcgh"/>
        <result column="F_czqczxm" property="fCzqczxm"/>
        <result column="F_czqczgh" property="fCzqczgh"/>
        <result column="F_czqjcsj" property="fCzqjcsj"/>
        <result column="F_czhxljc" property="fCzhxljc"/>
        <result column="F_czhpkjc" property="fCzhpkjc"/>
        <result column="F_czhsjczl" property="fCzhsjczl"/>
        <result column="F_czhfjjc" property="fCzhfjjc"/>
        <result column="F_czhjsbq" property="fCzhjsbq"/>
        <result column="F_czhxxbq" property="fCzhxxbq"/>
        <result column="F_fcsj" property="fFcsj"/>
        <result column="F_qplzID" property="fQplzid"/>
        <result column="F_qptm" property="fQptm"/>
        <result column="F_qpID" property="fQpid"/>
        <result column="F_ssczmc" property="fSsczmc"/>
        <result column="F_ssczID" property="fSsczid"/>
        <result column="F_ssqymc" property="fSsqymc"/>
        <result column="F_ssqyID" property="fSsqyid"/>
        <result column="F_form_data_rev_" property="fFormDataRev"/>
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
       ID_,
       REF_ID_,
       F_czsj,
       F_czqzmc,
       F_czxkzbh,
       F_czqz,
       F_czhz,
       F_czqwgjc,
       F_czqpfjc,
       F_czqfzjc,
       F_czqhjjc,
       F_czqjcxm,
       F_czqjcgh,
       F_czqczxm,
       F_czqczgh,
       F_czqjcsj,
       F_czhxljc,
       F_czhpkjc,
       F_czhsjczl,
       F_czhfjjc,
       F_czhjsbq,
       F_czhxxbq,
       F_fcsj,
       F_qplzID,
       F_qptm,
       F_qpID,
       F_ssczmc,
       F_ssczID,
       F_ssqymc,
       F_ssqyID,
       F_form_data_rev_
    </sql>

    <select id="selectPage" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from
        w_czgl
        ${ew.customSqlSegment}
    </select>

    <select id="selectList" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from
        w_czgl
        ${ew.customSqlSegment}
    </select>

    <select id="selectById" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from
        w_czgl
        where
        ID_ = #{id}
    </select>

    <select id="page1" resultMap="BaseResultMap">
        SELECT
        *
        FROM
        w_czgl w_czgl
        <where>
            <if test="qptm != null and qptm != ''">
                AND w_czgl.F_qptm = #{qptm}
            </if>
        </where>
        ORDER BY w_czgl.F_czsj DESC
    </select>

    <select id="cpczPage" resultType="java.util.HashMap">
        SELECT
        w_qpxx.F_qpbh,
        w_qpxx.F_ssczmc,
        temp1.cs
        FROM
        (
        SELECT
        w_czgl.F_qpbh,
        count(w_czgl.F_qpbh) AS cs
        FROM w_czgl w_czgl
        INNER JOIN w_qpxx w_qpxx ON w_qpxx.id_ = w_czgl.F_qpID
        WHERE DATE_FORMAT(w_czgl.F_czsj,'%Y-%m-%d') BETWEEN #{query.startDate} AND #{query.endDate}
        <if test="query.fSsczid != null and query.fSsczid != ''">
            AND w_czgl.F_ssczID = #{query.fSsczid}
        </if>
        <if test="query.fQpbh != null and query.fQpbh != ''">
            AND w_czgl.F_qpbh = #{query.fQpbh}
        </if>
        <if test="list != null and list.size() > 0">
            AND w_czgl.F_ssczID IN
            <foreach collection="list" separator="," item="czId" open="(" close=")">
                #{czId}
            </foreach>
        </if>
        GROUP BY w_czgl.F_qpbh
        HAVING cs
        <if test="query.operator == '1'.toString">
            &gt;=
        </if>
        <if test="query.operator == '2'.toString">
            &lt;=
        </if>
        <if test="query.operator == '3'.toString">
            =
        </if>
        #{query.times}
        ) temp1
        INNER JOIN w_qpxx w_qpxx ON temp1.F_qpbh = w_qpxx.F_qpbh
    </select>

    <select id="cpczmxPage" resultMap="BaseResultMap">
        SELECT
        *
        FROM
        w_czgl
        WHERE
        DATE_FORMAT( w_czgl.F_czsj, '%Y-%m-%d' ) BETWEEN #{query.startDate} AND #{query.endDate}
        <if test="query.fQpbh != null and query.fQpbh != ''">
            AND w_czgl.F_qpbh = #{query.fQpbh}
        </if>
        ORDER BY
        w_czgl.F_czsj DESC

    </select>

    <select id="yearFilling" resultType="java.lang.Double">
        select Round(ifnull(sum(F_czhsjczl),0.00),2) from w_czgl where F_ssczID = #{czId} and YEAR(F_czsj) = YEAR(SYSDATE())
    </select>

    <select id="monthFilling" resultType="java.lang.Double">
        select Round(ifnull(sum(F_czhsjczl),0.00),2) from w_czgl where F_ssczID = #{czId} and MONTH(F_czsj) = MONTH(SYSDATE())
    </select>

    <select id="monthFillingOnMonth" resultType="java.lang.Double">
            select
        ROUND(ifnull(
        ifnull(sum(case when MONTH(F_czsj) = MONTH(SYSDATE()) and year(F_czsj) = year(SYSDATE()) then F_czhsjczl else 0 end ),0.00)
        /
        ifnull(sum(case when MONTH(F_czsj) = MONTH(SYSDATE())-1 and year(F_czsj) = year(SYSDATE()) then F_czhsjczl else 0 end ),0.00)
        ,0),2)
        from w_czgl where  F_ssczID = #{czId}
    </select>

    <select id="allMonthFilling" resultType="java.util.HashMap">
        SELECT
        monthStr,
        ROUND(ifnull((select sum(F_czhsjczl) from w_czgl where F_ssczID = #{czId} and YEAR(F_czsj) = YEAR(SYSDATE()) and MONTH(F_czsj) = monthStr),0.00),2) as monthFilling
        FROM
        (SELECT 1 monthStr UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9 UNION ALL SELECT 10 UNION ALL SELECT 11 UNION ALL SELECT 12) t1
        WHERE
        monthStr &lt;= MONTH(SYSDATE())
    </select>
</mapper>