<?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="vip.xiaonuo.production.mapper.ProductionWriteEnergyMapper">

    <select id="getListDetail" resultType="vip.xiaonuo.production.param.TargetListDetailVos">
     SELECT
 ROUND(IFNULL(SUM(actual_production), 0), 2)  actual_production ,  DATE_FORMAT(create_time, '%Y-%m') ymonth  ,
 ROUND(IFNULL(  (SELECT SUM(production_plan)  production_plan   FROM  `production_write_plan`
  WHERE DATE_FORMAT(create_time, '%Y-%m') = DATE_FORMAT(mb.create_time, '%Y-%m')) , 0), 2)   production_plan

  FROM  `production_workstop_plan` mb
        ${ew.customSqlSegment}
    </select>
    <select id="getCountDetaile" resultType="vip.xiaonuo.production.param.TargetListDetailVos">

           SELECT
 ROUND(IFNULL(SUM(actual_production), 0), 2)  actual_production ,
 ROUND(IFNULL(  (SELECT SUM(production_plan)  production_plan   FROM  `production_write_plan`     ${ew.customSqlSegment} ) , 0), 2)   production_plan
  FROM  `production_workstop_plan`
        ${ew.customSqlSegment}



    </select>
    <select id="selectYear" resultType="vip.xiaonuo.production.entity.vo.ProductionWriteEnergyVo">
        SELECT ROUND(IFNULL(SUM(electricity* ${electricity} ),0),2) electricity ,
        ROUND(IFNULL(SUM(zheng_qi* ${zhengQi}),0),2)zheng_qi   ,
        ROUND(IFNULL(SUM(dan_qi* ${danQi}),0),2)dan_qi ,
        ROUND(IFNULL(SUM(ya_suo* ${yaSuo}),0),2) ya_suo,
        ROUND(IFNULL(SUM(ro_water* ${roWater}),0),2)ro_water ,
        ROUND(IFNULL(SUM(zl_water* ${zlWater}),0),2) zl_water,
        ROUND(IFNULL(SUM(xh_water* ${xhWater}),0),2)xh_water ,
        ROUND(IFNULL(SUM(qd_water* ${qdWater}),0),2) qd_water,
        ROUND(IFNULL(SUM(swd_water* ${swdWater}),0),2)  swd_water,
        ROUND(IFNULL(SUM(eswd_water* ${eswdWater}),0),2) eswd_water ,

        ROUND(IFNULL(SUM(re_water* ${reWater}),0),2) re_water,

        ROUND(IFNULL(SUM(diwen_water* ${diwenWater}),0),2) diwen_water,
        ROUND(IFNULL(SUM(fu_swd_yierchun* ${fuSwdYierchun} ),0),2) fu_swd_yierchun ,
        ROUND(IFNULL(SUM(fu_eswd_yierchun* ${fuEswdYierchun}),0),2)  fu_eswd_yierchun,
        DATE_FORMAT(create_time, '%Y') ymonth

         FROM `production_write_energy`

         ${ew.customSqlSegment}


    </select>
    <select id="selectMonth" resultType="vip.xiaonuo.production.entity.vo.ProductionWriteEnergyVo">

          SELECT ROUND(IFNULL(SUM(electricity* ${electricity} ),0),2) electricity ,
        ROUND(IFNULL(SUM(zheng_qi* ${zhengQi}),0),2)zheng_qi   ,
        ROUND(IFNULL(SUM(dan_qi* ${danQi}),0),2)dan_qi ,
        ROUND(IFNULL(SUM(ya_suo* ${yaSuo}),0),2) ya_suo,
        ROUND(IFNULL(SUM(ro_water* ${roWater}),0),2)ro_water ,
        ROUND(IFNULL(SUM(zl_water* ${zlWater}),0),2) zl_water,
        ROUND(IFNULL(SUM(xh_water* ${xhWater}),0),2)xh_water ,
        ROUND(IFNULL(SUM(qd_water* ${qdWater}),0),2) qd_water,
        ROUND(IFNULL(SUM(swd_water* ${swdWater}),0),2)  swd_water,
        ROUND(IFNULL(SUM(eswd_water* ${eswdWater}),0),2) eswd_water ,

        ROUND(IFNULL(SUM(re_water* ${reWater}),0),2) re_water,

        ROUND(IFNULL(SUM(diwen_water* ${diwenWater}),0),2) diwen_water,
        ROUND(IFNULL(SUM(fu_swd_yierchun* ${fuSwdYierchun} ),0),2) fu_swd_yierchun ,
        ROUND(IFNULL(SUM(fu_eswd_yierchun* ${fuEswdYierchun}),0),2)  fu_eswd_yierchun,
        DATE_FORMAT(create_time, '%Y-%m') ymonth

         FROM `production_write_energy`

         ${ew.customSqlSegment}
    </select>
</mapper>
