<?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">
<!-- 命名空间的值为dao层接口的权限定名 -->
<mapper namespace="com.bawei.dao.GdpDao" >
<select id="findAll" resultMap="maps">
select g.*,p.name as name,p.pnum as pnum,(g.industryIncome-g.industryInvest) as industryProfits,
((g.industryIncome-g.industryInvest)/g.industryIncome*100) as industryProfitsMargin,
(g.agIncome-g.agInvest) as agProfits,
((g.agIncome-g.agInvest)/g.agIncome*100) as agProfitsMargin,
(g.industryIncome/(g.industryIncome+g.agIncome)*100) as industryBiZhong
from tb_gdp g LEFT JOIN tb_province p ON g.provinceId=p.id
<where>
<if test="provinceId!=null and provinceId!=0 ">
and provinceId=#{provinceId}
</if>
<if test="pnumMin!=null ">
and pnum >= #{pnumMin}
</if>
<if test="pnumMax!=null ">
and pnum <= #{pnumMax}
</if>
<if test="profitsMin!=null ">
and ((g.agIncome+g.industryIncome-g.agInvest-g.industryInvest)/(g.agIncome+g.industryIncome)*100) >= #{profitsMin}
</if>
<if test="profitsMax!=null ">
and ((g.agIncome+g.industryIncome-g.agInvest-g.industryInvest)/(g.agIncome+g.industryIncome)*100) >= #{profitsMax}
</if>
<if test="industryInvestMin!=null ">
and g.industryInvest >= #{industryInvestMin}
</if>
<if test="industryInvestMax!=null ">
and g.industryInvest <= #{industryInvestMax}
</if>
<if test="agIncomeMin!=null ">
and g.agIncome >= #{agIncomeMin}
</if>
<if test="agIncomeMax!=null ">
and g.agIncome <= #{agIncomeMax}
</if>
<if test="monthMin!=null ">
and g.month >= #{monthMin}
</if>
<if test="monthMax!=null ">
and g.month <= #{monthMax}
</if>
</where>
GROUP BY g.id
<trim prefix="having" prefixOverrides="and" >
<if test="yearMin!=null ">
and SUM(g.agIncome+g.industryIncome) >= #{yearMin}
</if>
<if test="yearMax!=null ">
and SUM(g.agIncome+g.industryIncome) <= #{yearMax}
</if>
</trim>
</select>
<resultMap type="Gdp" id="maps">
<id property="id" column="id" />
<result property="provinceId" column="provinceId" />
<result property="month" column="month" />
<result property="industryInvest" column="industryInvest" />
<result property="industryIncome" column="industryIncome" />
<result property="eConsumer" column="eConsumer" />
<result property="agInvest" column="agInvest" />
<result property="agIncome" column="agIncome" />
<result property="industryProfits" column="industryProfits" />
<result property="industryProfitsMargin" column="industryProfitsMargin" />
<result property="agProfits" column="agProfits" />
<result property="agProfitsMargin" column="agProfitsMargin" />
<result property="industryBiZhong" column="industryBiZhong" />
<!-- <association property="pro" javaType="Province">
<id property="pid" column="pid" />
<result property="name" column="name" />
<result property="pnum" column="pnum" />
</association> -->
</resultMap>
</mapper>