<?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="cn.timer.api.dao.kqmk.KqglAssoDkmxMapper">

    <resultMap id="BaseResultMap" type="cn.timer.api.bean.kqmk.KqglAssoDkmx" >
                <id column="id" property="id" />
                <result column="userid" property="userid" />
                <result column="data" property="data" />
                <result column="sbdk1" property="sbdk1" />
                <result column="sbdk1jg" property="sbdk1jg" />
                <result column="xbdk1" property="xbdk1" />
                <result column="xbdk1jg" property="xbdk1jg" />
                <result column="sbdk2" property="sbdk2" />
                <result column="sbdk2jg" property="sbdk2jg" />
                <result column="xbdk2" property="xbdk2" />
                <result column="xbdk2jg" property="xbdk2jg" />
                <result column="sbdk3" property="sbdk3" />
                <result column="sbdk3jg" property="sbdk3jg" />
                <result column="xbdk3" property="xbdk3" />
                <result column="xbdk3jg" property="xbdk3jg" />
                <result column="ydkcs" property="ydkcs" />
                <result column="gzsc" property="gzsc" />
                <result column="qyid" property="qyid" />
                <result column="dksj" property="dksj" />
                <result column="yzcdcs" property="yzcdcs" />
                <result column="yzcdsc" property="yzcdsc" />
                <result column="kgcdfzs" property="kgcdfzs" />
    </resultMap>
    
    <resultMap id="AttSubsidiary" type="cn.timer.api.dto.kqmk.AttSubsidiaryDto" >
                <result column="gzsctotalgzsc" property="gzsctotalgzsc" />
                <result column="yzcdcstotal" property="yzcdcstotal" />
                <result column="yzcdsctotal" property="yzcdsctotal" />
                <result column="kgcdfzstotal" property="kgcdfzstotal" />
    </resultMap>

    <sql id="Base_Column_List">
                id,
                userid,
                data,
                sbdk1,
                sbdk1jg,
                xbdk1,
                xbdk1jg,
                sbdk2,
                sbdk2jg,
                xbdk2,
                xbdk2jg,
                sbdk3,
                sbdk3jg,
                xbdk3,
                xbdk3jg,
                ydkcs,
                gzsc,
                qyid,
                dksj,
                yzcdcs,
                yzcdsc,
                kgcdfzs
    </sql>
    
    <sql id="Base_Column_List_Alias">
                id KqglAssoDkmx_id,
                userid KqglAssoDkmx_userid,
                data KqglAssoDkmx_data,
                sbdk1 KqglAssoDkmx_sbdk1,
                sbdk1jg KqglAssoDkmx_sbdk1jg,
                xbdk1 KqglAssoDkmx_xbdk1,
                xbdk1jg KqglAssoDkmx_xbdk1jg,
                sbdk2 KqglAssoDkmx_sbdk2,
                sbdk2jg KqglAssoDkmx_sbdk2jg,
                xbdk2 KqglAssoDkmx_xbdk2,
                xbdk2jg KqglAssoDkmx_xbdk2jg,
                sbdk3 KqglAssoDkmx_sbdk3,
                sbdk3jg KqglAssoDkmx_sbdk3jg,
                xbdk3 KqglAssoDkmx_xbdk3,
                xbdk3jg KqglAssoDkmx_xbdk3jg,
                ydkcs KqglAssoDkmx_ydkcs,
                gzsc KqglAssoDkmx_gzsc,
                qyid KqglAssoDkmx_qyid,
                dksj KqglAssoDkmx_dksj,
                yzcdcs KqglAssoDkmx_yzcdcs,
                yzcdsc KqglAssoDkmx_yzcdsc,
                kgcdfzs KqglAssoDkmx_kgcdfzs
    </sql>

	<select id="subsidiary" resultMap="AttSubsidiary">
		select  SUM(dk.gzsc) as gzsctotalgzsc,
			SUM(dk.yzcdcs) as yzcdcstotal,
			SUM(dk.yzcdsc) as yzcdsctotal,
			SUM(dk.kgcdfzs) as kgcdfzstotal
				from kqgl_asso_dkmx dk 
		where dk.userid = #{userid}
		and SUBSTR(dk.`data`,1,7) = #{data} 
		GROUP BY dk.userid
	</select>
	
	<update id="updateByPrimaryKeySelective" parameterType="cn.timer.api.bean.kqmk.KqglAssoDkmx">
        UPDATE kqgl_asso_dkmx
        <set>
                    <if test ='null != userid'>userid = #{userid},</if>
                    <if test ='null != data'>data = #{data},</if>
                    <if test ='null != sbdk1'>sbdk1 = #{sbdk1},</if>
                    <if test ='null != sbdk1jg'>sbdk1jg = #{sbdk1jg},</if>
                    <if test ='null != xbdk1'>xbdk1 = #{xbdk1},</if>
                    <if test ='null != xbdk1jg'>xbdk1jg = #{xbdk1jg},</if>
                    <if test ='null != sbdk2'>sbdk2 = #{sbdk2},</if>
                    <if test ='null != sbdk2jg'>sbdk2jg = #{sbdk2jg},</if>
                    <if test ='null != xbdk2'>xbdk2 = #{xbdk2},</if>
                    <if test ='null != xbdk2jg'>xbdk2jg = #{xbdk2jg},</if>
                    <if test ='null != sbdk3'>sbdk3 = #{sbdk3},</if>
                    <if test ='null != sbdk3jg'>sbdk3jg = #{sbdk3jg},</if>
                    <if test ='null != xbdk3'>xbdk3 = #{xbdk3},</if>
                    <if test ='null != xbdk3jg'>xbdk3jg = #{xbdk3jg},</if>
                    <if test ='null != ydkcs'>ydkcs = #{ydkcs},</if>
                    <if test ='null != gzsc'>gzsc = #{gzsc},</if>
                    <if test ='null != qyid'>qyid = #{qyid},</if>
                    <if test ='null != dksj'>dksj = #{dksj},</if>
                    <if test ='null != yzcdcs'>yzcdcs = #{yzcdcs},</if>
                    <if test ='null != yzcdsc'>yzcdsc = #{yzcdsc},</if>
                    <if test ='null != kgcdfzs'>kgcdfzs = #{kgcdfzs}</if>
        </set>
        WHERE id = #{id}
    </update>

	<!-- 

    <insert id="insert" useGeneratedKeys="true" keyColumn="id" parameterType="cn.timer.api.bean.kqmk.KqglAssoDkmx">
        INSERT INTO kqgl_asso_dkmx
        <trim prefix="(" suffix=")" suffixOverrides=",">
                        <if test ='null != userid'>
                        userid,
                        </if>
                        <if test ='null != data'>
                        data,
                        </if>
                        <if test ='null != sbdk1'>
                        sbdk1,
                        </if>
                        <if test ='null != sbdk1jg'>
                        sbdk1jg,
                        </if>
                        <if test ='null != xbdk1'>
                        xbdk1,
                        </if>
                        <if test ='null != xbdk1jg'>
                        xbdk1jg,
                        </if>
                        <if test ='null != sbdk2'>
                        sbdk2,
                        </if>
                        <if test ='null != sbdk2jg'>
                        sbdk2jg,
                        </if>
                        <if test ='null != xbdk2'>
                        xbdk2,
                        </if>
                        <if test ='null != xbdk2jg'>
                        xbdk2jg,
                        </if>
                        <if test ='null != sbdk3'>
                        sbdk3,
                        </if>
                        <if test ='null != sbdk3jg'>
                        sbdk3jg,
                        </if>
                        <if test ='null != xbdk3'>
                        xbdk3,
                        </if>
                        <if test ='null != xbdk3jg'>
                        xbdk3jg,
                        </if>
                        <if test ='null != ydkcs'>
                        ydkcs,
                        </if>
                        <if test ='null != gzsc'>
                        gzsc,
                        </if>
                        <if test ='null != qyid'>
                        qyid,
                        </if>
                        <if test ='null != dksj'>
                        dksj,
                        </if>
                        <if test ='null != yzcdcs'>
                        yzcdcs,
                        </if>
                        <if test ='null != yzcdsc'>
                        yzcdsc,
                        </if>
                        <if test ='null != kgcdfzs'>
                        kgcdfzs
                        </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                        <if test ='null != userid'>
                        #{userid},
                        </if>
                        <if test ='null != data'>
                        #{data},
                        </if>
                        <if test ='null != sbdk1'>
                        #{sbdk1},
                        </if>
                        <if test ='null != sbdk1jg'>
                        #{sbdk1jg},
                        </if>
                        <if test ='null != xbdk1'>
                        #{xbdk1},
                        </if>
                        <if test ='null != xbdk1jg'>
                        #{xbdk1jg},
                        </if>
                        <if test ='null != sbdk2'>
                        #{sbdk2},
                        </if>
                        <if test ='null != sbdk2jg'>
                        #{sbdk2jg},
                        </if>
                        <if test ='null != xbdk2'>
                        #{xbdk2},
                        </if>
                        <if test ='null != xbdk2jg'>
                        #{xbdk2jg},
                        </if>
                        <if test ='null != sbdk3'>
                        #{sbdk3},
                        </if>
                        <if test ='null != sbdk3jg'>
                        #{sbdk3jg},
                        </if>
                        <if test ='null != xbdk3'>
                        #{xbdk3},
                        </if>
                        <if test ='null != xbdk3jg'>
                        #{xbdk3jg},
                        </if>
                        <if test ='null != ydkcs'>
                        #{ydkcs},
                        </if>
                        <if test ='null != gzsc'>
                        #{gzsc},
                        </if>
                        <if test ='null != qyid'>
                        #{qyid},
                        </if>
                        <if test ='null != dksj'>
                        #{dksj},
                        </if>
                        <if test ='null != yzcdcs'>
                        #{yzcdcs},
                        </if>
                        <if test ='null != yzcdsc'>
                        #{yzcdsc},
                        </if>
                        <if test ='null != kgcdfzs'>
                        #{kgcdfzs}
                        </if>
        </trim>
    </insert>

    <delete id="delete" >
        DELETE FROM kqgl_asso_dkmx
        WHERE id = #{id}
    </delete>


    <select id="load" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List" />
        FROM kqgl_asso_dkmx
        WHERE id = #{id}
    </select>

    <select id="pageList" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List" />
        FROM kqgl_asso_dkmx
        LIMIT #{offset}, #{pageSize}
    </select>

    <select id="pageListCount" resultType="java.lang.Integer">
        SELECT count(1)
        FROM kqgl_asso_dkmx
    </select>

	 -->

</mapper>