<?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.fuxi.ws.data.dao.WReportactiveMapper">
	<resultMap id="BaseResultMap" type="com.fuxi.ws.data.entity.WReportactive">
		<!-- WARNING - @mbggenerated This element is automatically generated by 
			MyBatis Generator, do not modify. This element was generated on Wed Apr 06 
			15:49:27 CST 2016. -->
		<id column="ReportDate" property="reportdate" jdbcType="TIMESTAMP" />
		<id column="GoodsID" property="goodsid" jdbcType="VARCHAR" />
		<result column="DZNum" property="dznum" jdbcType="INTEGER" />
		<result column="FXNum" property="fxnum" jdbcType="INTEGER" />
		<result column="YYNum" property="yynum" jdbcType="INTEGER" />
		<result column="SCNum" property="scnum" jdbcType="INTEGER" />
		<result column="ZXNum" property="zxnum" jdbcType="INTEGER" />
		<result column="GWCNum" property="gwcnum" jdbcType="INTEGER" />
		<result column="GMNum" property="gmnum" jdbcType="INTEGER" />
		<result column="PVUum" property="pvuum" jdbcType="INTEGER" />
		<result column="UVUum" property="uvuum" jdbcType="INTEGER" />
	</resultMap>
	<sql id="Example_Where_Clause">
		<!-- WARNING - @mbggenerated This element is automatically generated by 
			MyBatis Generator, do not modify. This element was generated on Wed Apr 06 
			15:49:27 CST 2016. -->
		<where>
			<foreach collection="oredCriteria" item="criteria" separator="or">
				<if test="criteria.valid">
					<trim prefix="(" suffix=")" prefixOverrides="and">
						<foreach collection="criteria.criteria" item="criterion">
							<choose>
								<when test="criterion.noValue">
									and ${criterion.condition}
								</when>
								<when test="criterion.singleValue">
									and ${criterion.condition} #{criterion.value}
								</when>
								<when test="criterion.betweenValue">
									and ${criterion.condition} #{criterion.value}
									and
									#{criterion.secondValue}
								</when>
								<when test="criterion.listValue">
									and ${criterion.condition}
									<foreach collection="criterion.value" item="listItem"
										open="(" close=")" separator=",">
										#{listItem}
									</foreach>
								</when>
							</choose>
						</foreach>
					</trim>
				</if>
			</foreach>
		</where>
	</sql>
	<sql id="Base_Column_List">
		<!-- WARNING - @mbggenerated This element is automatically generated by 
			MyBatis Generator, do not modify. This element was generated on Wed Apr 06 
			15:49:27 CST 2016. -->
		ReportDate, GoodsID, DZNum, FXNum, YYNum, SCNum, ZXNum, GWCNum, GMNum,
		PVUum, UVUum
	</sql>
	<select id="selectByExample" resultMap="BaseResultMap"
		parameterType="com.fuxi.ws.data.entity.WReportactiveExample">
		<!-- WARNING - @mbggenerated This element is automatically generated by 
			MyBatis Generator, do not modify. This element was generated on Wed Apr 06 
			15:49:27 CST 2016. -->
		select
		<if test="distinct">
			distinct
		</if>
		'false' as QUERYID,
		<include refid="Base_Column_List" />
		from W_ReportActive
		<if test="_parameter != null">
			<include refid="Example_Where_Clause" />
		</if>
		<if test="orderByClause != null">
			order by ${orderByClause}
		</if>
	</select>
	<select id="selectByPrimaryKey" resultMap="BaseResultMap"
		parameterType="com.fuxi.ws.data.entity.WReportactiveKey">
		<!-- WARNING - @mbggenerated This element is automatically generated by 
			MyBatis Generator, do not modify. This element was generated on Wed Apr 06 
			15:49:27 CST 2016. -->
		select
		<include refid="Base_Column_List" />
		from W_ReportActive
		where ReportDate = #{reportdate,jdbcType=TIMESTAMP}
		and GoodsID = #{goodsid,jdbcType=VARCHAR}
	</select>
	<delete id="deleteByPrimaryKey" parameterType="com.fuxi.ws.data.entity.WReportactiveKey">
		<!-- WARNING - @mbggenerated This element is automatically generated by 
			MyBatis Generator, do not modify. This element was generated on Wed Apr 06 
			15:49:27 CST 2016. -->
		delete from W_ReportActive
		where ReportDate =
		#{reportdate,jdbcType=TIMESTAMP}
		and GoodsID =
		#{goodsid,jdbcType=VARCHAR}
	</delete>
	<insert id="insert" parameterType="com.fuxi.ws.data.entity.WReportactive">
		<!-- WARNING - @mbggenerated This element is automatically generated by 
			MyBatis Generator, do not modify. This element was generated on Wed Apr 06 
			15:49:27 CST 2016. -->
		insert into W_ReportActive (ReportDate, GoodsID, DZNum,
		FXNum, YYNum,
		SCNum,
		ZXNum, GWCNum, GMNum,
		PVUum, UVUum)
		values
		(#{reportdate,jdbcType=TIMESTAMP}, #{goodsid,jdbcType=VARCHAR},
		#{dznum,jdbcType=INTEGER},
		#{fxnum,jdbcType=INTEGER},
		#{yynum,jdbcType=INTEGER}, #{scnum,jdbcType=INTEGER},
		#{zxnum,jdbcType=INTEGER}, #{gwcnum,jdbcType=INTEGER},
		#{gmnum,jdbcType=INTEGER},
		#{pvuum,jdbcType=INTEGER},
		#{uvuum,jdbcType=INTEGER})
	</insert>
	<insert id="insertSelective" parameterType="com.fuxi.ws.data.entity.WReportactive">
		<!-- WARNING - @mbggenerated This element is automatically generated by 
			MyBatis Generator, do not modify. This element was generated on Wed Apr 06 
			15:49:27 CST 2016. -->
		insert into W_ReportActive
		<trim prefix="(" suffix=")" suffixOverrides=",">
			<if test="reportdate != null">
				ReportDate,
			</if>
			<if test="goodsid != null">
				GoodsID,
			</if>
			<if test="dznum != null">
				DZNum,
			</if>
			<if test="fxnum != null">
				FXNum,
			</if>
			<if test="yynum != null">
				YYNum,
			</if>
			<if test="scnum != null">
				SCNum,
			</if>
			<if test="zxnum != null">
				ZXNum,
			</if>
			<if test="gwcnum != null">
				GWCNum,
			</if>
			<if test="gmnum != null">
				GMNum,
			</if>
			<if test="pvuum != null">
				PVUum,
			</if>
			<if test="uvuum != null">
				UVUum,
			</if>
		</trim>
		<trim prefix="values (" suffix=")" suffixOverrides=",">
			<if test="reportdate != null">
				#{reportdate,jdbcType=TIMESTAMP},
			</if>
			<if test="goodsid != null">
				#{goodsid,jdbcType=VARCHAR},
			</if>
			<if test="dznum != null">
				#{dznum,jdbcType=INTEGER},
			</if>
			<if test="fxnum != null">
				#{fxnum,jdbcType=INTEGER},
			</if>
			<if test="yynum != null">
				#{yynum,jdbcType=INTEGER},
			</if>
			<if test="scnum != null">
				#{scnum,jdbcType=INTEGER},
			</if>
			<if test="zxnum != null">
				#{zxnum,jdbcType=INTEGER},
			</if>
			<if test="gwcnum != null">
				#{gwcnum,jdbcType=INTEGER},
			</if>
			<if test="gmnum != null">
				#{gmnum,jdbcType=INTEGER},
			</if>
			<if test="pvuum != null">
				#{pvuum,jdbcType=INTEGER},
			</if>
			<if test="uvuum != null">
				#{uvuum,jdbcType=INTEGER},
			</if>
		</trim>
	</insert>
	<select id="countByExample" parameterType="com.fuxi.ws.data.entity.WReportactiveExample"
		resultType="java.lang.Integer">
		<!-- WARNING - @mbggenerated This element is automatically generated by 
			MyBatis Generator, do not modify. This element was generated on Wed Apr 06 
			15:49:27 CST 2016. -->
		select count(*) from W_ReportActive
		<if test="_parameter != null">
			<include refid="Example_Where_Clause" />
		</if>
	</select>
	<update id="updateByPrimaryKeySelective" parameterType="com.fuxi.ws.data.entity.WReportactive">
		<!-- WARNING - @mbggenerated This element is automatically generated by 
			MyBatis Generator, do not modify. This element was generated on Wed Apr 06 
			15:49:27 CST 2016. -->
		update W_ReportActive
		<set>
			<if test="dznum != null">
				DZNum = #{dznum,jdbcType=INTEGER},
			</if>
			<if test="fxnum != null">
				FXNum = #{fxnum,jdbcType=INTEGER},
			</if>
			<if test="yynum != null">
				YYNum = #{yynum,jdbcType=INTEGER},
			</if>
			<if test="scnum != null">
				SCNum = #{scnum,jdbcType=INTEGER},
			</if>
			<if test="zxnum != null">
				ZXNum = #{zxnum,jdbcType=INTEGER},
			</if>
			<if test="gwcnum != null">
				GWCNum = #{gwcnum,jdbcType=INTEGER},
			</if>
			<if test="gmnum != null">
				GMNum = #{gmnum,jdbcType=INTEGER},
			</if>
			<if test="pvuum != null">
				PVUum = #{pvuum,jdbcType=INTEGER},
			</if>
			<if test="uvuum != null">
				UVUum = #{uvuum,jdbcType=INTEGER},
			</if>
		</set>
		where ReportDate = #{reportdate,jdbcType=TIMESTAMP}
		and GoodsID =
		#{goodsid,jdbcType=VARCHAR}
	</update>
	<update id="updateByPrimaryKey" parameterType="com.fuxi.ws.data.entity.WReportactive">
		<!-- WARNING - @mbggenerated This element is automatically generated by 
			MyBatis Generator, do not modify. This element was generated on Wed Apr 06 
			15:49:27 CST 2016. -->
		update W_ReportActive
		set DZNum = #{dznum,jdbcType=INTEGER},
		FXNum =
		#{fxnum,jdbcType=INTEGER},
		YYNum = #{yynum,jdbcType=INTEGER},
		SCNum =
		#{scnum,jdbcType=INTEGER},
		ZXNum = #{zxnum,jdbcType=INTEGER},
		GWCNum =
		#{gwcnum,jdbcType=INTEGER},
		GMNum = #{gmnum,jdbcType=INTEGER},
		PVUum =
		#{pvuum,jdbcType=INTEGER},
		UVUum = #{uvuum,jdbcType=INTEGER}
		where
		ReportDate = #{reportdate,jdbcType=TIMESTAMP}
		and GoodsID =
		#{goodsid,jdbcType=VARCHAR}
	</update>

	<!-- 数据图表 -->
	<select id="getCharts" resultType="java.util.LinkedHashMap">
		select top 10
		a.GoodsID,a.GoodName,b.count from W_Goods a
		join (
		select SUM(t.${ field })
		count,t.GoodsID from (
		select CONVERT(varchar(10),ReportDate,121)
		ReportDate,${ field },GoodsID from
		W_ReportActive where ReportDate
		between #{d1} and #{d2})t group by t.GoodsID)
		b on a.GoodsID=b.GoodsID
		order by b.count desc
	</select>
</mapper>