<?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.mapper.FarmWorkMapper">
	<insert id="saveCalcAreaLog" parameterType="com.uml.tech.bean.CalcAreaLog">
        insert into farm_calc_area_log(did,jobStartTime,jobEndTime,step,param,result,insertTime)
        value(#{did},#{jobStartTime},#{jobEndTime},#{step},#{param},#{result},NOW())
    </insert>
	<delete id="deleteReport">
		delete from ${tb_name} where did = #{did}
	</delete>

	<select id="isTableExist" resultType="java.lang.String">
		select TABLE_NAME from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='bigdata' and TABLE_NAME=#{tb_name}
	</select>
	<select id="selectReportCount" resultType="java.lang.Integer">
		select count(1) from ${tb_name} where  did = #{did} for update
	</select>

	<insert id="insertReport">
		replace into  ${tb_name}
		<trim prefix="(" suffix=")">
			<if test="updateBean.jobArea !=null">
				jobArea,
			</if>

			<if test="updateBean.jobTime !=null">
				jobTime,
			</if>

			<if test="updateBean.totalDepth !=null">
				totalDepth,
			</if>

			<if test="updateBean.totalPercentOfPass !=null">
				totalPercentOfPass,
			</if>

			<if test="updateBean.totalPositionsSum !=null">
				totalPositionsSum,
			</if>

			<if test="updateBean.totalDryingWeight !=null">
				totalDryingWeight,
			</if>

			<if test="updateBean.totalBundleWeight !=null">
				totalBundleWeight,
			</if>

			<if test="updateBean.totalBundles !=null">
				totalBundles,
			</if>

			<if test="updateBean.totalDose !=null">
				totalDose,
			</if>

			<if test="updateBean.totalFertilization !=null">
				totalFertilization,
			</if>

			<if test="updateBean.totalPlotYield !=null">
				totalPlotYield,
			</if>
			did,runState
		</trim>
		values
		<trim prefix="(" suffix=")">
			<if test="updateBean.jobArea !=null">
				#{updateBean.jobArea},
			</if>

			<if test="updateBean.jobTime !=null">
				#{updateBean.jobTime},
			</if>

			<if test="updateBean.totalDepth !=null">
				#{updateBean.totalDepth},
			</if>

			<if test="updateBean.totalPercentOfPass !=null">
				#{updateBean.totalPercentOfPass},
			</if>

			<if test="updateBean.totalPositionsSum !=null">
				#{updateBean.totalPositionsSum},
			</if>

			<if test="updateBean.totalDryingWeight !=null">
				#{updateBean.totalDryingWeight},
			</if>

			<if test="updateBean.totalBundleWeight !=null">
				#{updateBean.totalBundleWeight},
			</if>

			<if test="updateBean.totalBundles !=null">
				#{updateBean.totalBundles},
			</if>

			<if test="updateBean.totalDose !=null">
				#{updateBean.totalDose},
			</if>

			<if test="updateBean.totalFertilization !=null">
				#{updateBean.totalFertilization},
			</if>

			<if test="updateBean.totalPlotYield !=null">
				#{updateBean.totalPlotYield},
			</if>
			#{updateBean.did},1
		</trim>

	</insert>

	<update id="updateStat">
		update ${tb_name}
		<set>
			<if test="updateBean.jobArea !=null">
				jobArea = #{updateBean.jobArea},
			</if>

			<if test="updateBean.jobTime !=null">
				jobTime = #{updateBean.jobTime},
			</if>

			<if test="updateBean.totalDepth !=null">
				totalDepth = #{updateBean.totalDepth},
			</if>

			<if test="updateBean.totalPercentOfPass !=null">
				totalPercentOfPass = #{updateBean.totalPercentOfPass},
			</if>

			<if test="updateBean.totalPositionsSum !=null">
				totalPositionsSum = #{updateBean.totalPositionsSum},
			</if>

			<if test="updateBean.totalDryingWeight !=null">
				totalDryingWeight = #{updateBean.totalDryingWeight},
			</if>

			<if test="updateBean.totalBundleWeight !=null">
				totalBundleWeight = #{updateBean.totalBundleWeight},
			</if>

			<if test="updateBean.totalBundles !=null">
				totalBundles = #{updateBean.totalBundles},
			</if>

			<if test="updateBean.totalDose !=null">
				totalDose = #{updateBean.totalDose},
			</if>

			<if test="updateBean.totalFertilization !=null">
				totalFertilization = #{updateBean.totalFertilization},
			</if>

			<if test="updateBean.totalPlotYield !=null">
				totalPlotYield = #{updateBean.totalPlotYield},
			</if>

			<if test="updateBean.totalJobMileage !=null">
				totalJobMileage = #{updateBean.totalJobMileage},
			</if>

		</set>
		where did = #{updateBean.did}
	</update>


</mapper>
