<?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.uml.tech.njMapper.FarmWorkNjMapper">

    <select id="selectTotalStatus" resultType="com.uml.tech.bean.FarmBean">
        SELECT did, sum(jobArea) jobArea, sum(if(absoluteJobTime is null, jobTime, absoluteJobTime)) jobTime,
        sum(avgDepth * if(positionsSum is null, jobTime, positionsSum)) totalDepth,
        sum(avgPercentOfPass * if(positionsSum is null, jobTime, positionsSum)) totalPercentOfPass, sum(positionsSum) totalPositionsSum,
        sum(dryingWeight) totalDryingWeight,sum(bundleWeight) totalBundleWeight, sum(bundles) totalBundles, sum(totalDose) totalDose,
        sum(fertilizationTotal) totalFertilization,sum(totalPlotYield) totalPlotYield,sum(jobMileage) totalJobMileage,
        sum(IF(jobMileageType = 0, jobMileage, 0)) totalDidJobMileage from farm_work
        <where>
            <![CDATA[ jobEndTime > ${startDay} ]]>
            and <![CDATA[ jobEndTime < ${endDay} ]]>
        </where>
        group by did
    </select>
</mapper>
