<?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.huatek.busi.mapper.ParameterMakeMapper">


	<select id="findTransformerParameterMakeMax" parameterType="java.lang.String" resultType="com.huatek.busi.entity.ParameterMake">
	SELECT
		x.id,
		x.ref_id AS refId,
		x.report_id AS reportId,
		f.file_name AS fileName,
		t.test_item AS testItem,
		x.mark,
		x.e_param AS eParam,
		x.equ_type_rule AS equTypeRule,
		x.main_equipment_id AS mainEquipmentId,
		x.create_time AS createTime,
		x.test_date AS testDate,
		max(
			cast(
				current_value AS DECIMAL (10, 2)
			)
		) AS currentValue
	FROM
		x_lab_report_mark_statistic x
	LEFT JOIN sys_file f on x.ref_id = f.business_id
	LEFT JOIN x_lab_report_basis_data t on x.report_id=t.id
	WHERE
		x.equ_type_rule = 'T'
	AND x.deleted = '0'
	AND x.ref_id = #{lastId}
	AND x.e_calculate_rule = '001'
	GROUP BY
		x.e_param
    </select>
	<select id="findTransformerParameterMakeMin" parameterType="java.lang.String" resultType="com.huatek.busi.entity.ParameterMake">
	SELECT
		x.id,
		x.ref_id AS refId,
		x.report_id AS reportId,
		f.file_name AS fileName,
		t.test_item AS testItem,
		x.mark,
		x.e_param AS eParam,
		x.equ_type_rule AS equTypeRule,
		x.main_equipment_id AS mainEquipmentId,
		x.create_time AS createTime,
		x.test_date AS testDate,
		min(
			cast(
				current_value AS DECIMAL (10, 2)
			)
		) AS currentValue
	FROM
		x_lab_report_mark_statistic x
	LEFT JOIN sys_file f on x.ref_id = f.business_id
	LEFT JOIN x_lab_report_basis_data t on x.report_id=t.id
	WHERE
		x.equ_type_rule = 'T'
	AND x.deleted = '0'
	AND x.ref_id = #{lastId}
	AND x.e_calculate_rule = '002'
	GROUP BY
		x.e_param
    </select>

	<select id="findTransformerParameterMakeAvg" parameterType="java.lang.String" resultType="com.huatek.busi.entity.ParameterMake">
	SELECT
		x.id,
		x.ref_id AS refId,
		x.report_id AS reportId,
		f.file_name AS fileName,
		t.test_item AS testItem,
		x.mark,
		x.e_param AS eParam,
		x.equ_type_rule AS equTypeRule,
		x.main_equipment_id AS mainEquipmentId,
		x.create_time AS createTime,
		x.test_date AS testDate,
		avg(
			cast(
				current_value AS DECIMAL (10, 2)
			)
		) AS currentValue
	FROM
		x_lab_report_mark_statistic x
	LEFT JOIN sys_file f on x.ref_id = f.business_id
	LEFT JOIN x_lab_report_basis_data t on x.report_id=t.id
	WHERE
		x.equ_type_rule = 'T'
	AND x.deleted = '0'
	AND x.ref_id = #{lastId}
	AND x.e_calculate_rule = '003'
	GROUP BY
		x.e_param
    </select>

	<select id="findTransformerSecondParameterMakeMax" parameterType="java.lang.String" resultType="com.huatek.busi.entity.ParameterMake">
	SELECT
		x.id,
		x.ref_id AS refId,
		x.report_id AS reportId,
		f.file_name AS fileName,
		t.test_item AS testItem,
		x.mark,
		x.e_param AS eParam,
		x.equ_type_rule AS equTypeRule,
		x.main_equipment_id AS mainEquipmentId,
		x.create_time AS createTime,
		x.test_date AS testDate,
		max(
			cast(
				current_value AS DECIMAL (10, 2)
			)
		) AS currentValue
	FROM
		x_lab_report_mark_statistic x
	LEFT JOIN sys_file f on x.ref_id = f.business_id
	LEFT JOIN x_lab_report_basis_data t on x.report_id=t.id
	WHERE
		x.equ_type_rule = 'T'
	AND x.deleted = '0'
	AND x.ref_id = #{nextId}
	AND x.e_calculate_rule = '001'
	GROUP BY
		x.e_param
    </select>
	<select id="findGisSecondMakeMax" parameterType="java.lang.String" resultType="com.huatek.busi.entity.ParameterMake">
	SELECT
		x.id,
		x.ref_id AS refId,
		x.report_id AS reportId,
		f.file_name AS fileName,
		t.test_item AS testItem,
		x.mark,
		x.e_param AS eParam,
		x.equ_type_rule AS equTypeRule,
		x.main_equipment_id AS mainEquipmentId,
		x.create_time AS createTime,
		x.test_date AS testDate,
		max(
			cast(
				current_value AS DECIMAL (10, 2)
			)
		) AS currentValue
	FROM
		x_lab_report_mark_statistic x
	LEFT JOIN sys_file f on x.ref_id = f.business_id
	LEFT JOIN x_lab_report_basis_data t on x.report_id=t.id
	WHERE
		x.equ_type_rule = 'G'
	AND x.deleted = '0'
	AND x.ref_id = #{nextId}
	AND x.e_calculate_rule = '001'
	GROUP BY
		x.e_param
    </select>

	<select id="findTransformerSecondParameterMakeMin" parameterType="java.lang.String" resultType="com.huatek.busi.entity.ParameterMake">
	SELECT
		x.id,
		x.ref_id AS refId,
		x.report_id AS reportId,
		f.file_name AS fileName,
		t.test_item AS testItem,
		x.mark,
		x.e_param AS eParam,
		x.equ_type_rule AS equTypeRule,
		x.main_equipment_id AS mainEquipmentId,
		x.create_time AS createTime,
		x.test_date AS testDate,
		min(
			cast(
				current_value AS DECIMAL (10, 2)
			)
		) AS currentValue
	FROM
		x_lab_report_mark_statistic x
	LEFT JOIN sys_file f on x.ref_id = f.business_id
	LEFT JOIN x_lab_report_basis_data t on x.report_id=t.id
	WHERE
		x.equ_type_rule = 'T'
	AND x.deleted = '0'
	AND x.ref_id = #{nextId}
	AND x.e_calculate_rule = '002'
	GROUP BY
		x.e_param
    </select>

	<select id="findGisSecondMakeMin" parameterType="java.lang.String" resultType="com.huatek.busi.entity.ParameterMake">
	SELECT
		x.id,
		x.ref_id AS refId,
		x.report_id AS reportId,
		f.file_name AS fileName,
		t.test_item AS testItem,
		x.mark,
		x.e_param AS eParam,
		x.equ_type_rule AS equTypeRule,
		x.main_equipment_id AS mainEquipmentId,
		x.create_time AS createTime,
		x.test_date AS testDate,
		min(
			cast(
				current_value AS DECIMAL (10, 2)
			)
		) AS currentValue
	FROM
		x_lab_report_mark_statistic x
	LEFT JOIN sys_file f on x.ref_id = f.business_id
	LEFT JOIN x_lab_report_basis_data t on x.report_id=t.id
	WHERE
		x.equ_type_rule = 'G'
	AND x.deleted = '0'
	AND x.ref_id = #{nextId}
	AND x.e_calculate_rule = '002'
	GROUP BY
		x.e_param
    </select>

	<select id="findGisSecondMakeAvg" parameterType="java.lang.String" resultType="com.huatek.busi.entity.ParameterMake">
	SELECT
		x.id,
		x.ref_id AS refId,
		x.report_id AS reportId,
		f.file_name AS fileName,
		t.test_item AS testItem,
		x.mark,
		x.e_param AS eParam,
		x.equ_type_rule AS equTypeRule,
		x.main_equipment_id AS mainEquipmentId,
		x.create_time AS createTime,
		x.test_date AS testDate,
		avg(
			cast(
				current_value AS DECIMAL (10, 2)
			)
		) AS currentValue
	FROM
		x_lab_report_mark_statistic x
	LEFT JOIN sys_file f on x.ref_id = f.business_id
	LEFT JOIN x_lab_report_basis_data t on x.report_id=t.id
	WHERE
		x.equ_type_rule = 'G'
	AND x.deleted = '0'
	AND x.ref_id = #{nextId}
	AND x.e_calculate_rule = '003'
	GROUP BY
		x.e_param
    </select>

	<select id="findTransformerSecondParameterMakeAvg" parameterType="java.lang.String" resultType="com.huatek.busi.entity.ParameterMake">
	SELECT
		x.id,
		x.ref_id AS refId,
		x.report_id AS reportId,
		f.file_name AS fileName,
		t.test_item AS testItem,
		x.mark,
		x.e_param AS eParam,
		x.equ_type_rule AS equTypeRule,
		x.main_equipment_id AS mainEquipmentId,
		x.create_time AS createTime,
		x.test_date AS testDate,
		avg(
			cast(
				current_value AS DECIMAL (10, 2)
			)
		) AS currentValue
	FROM
		x_lab_report_mark_statistic x
	LEFT JOIN sys_file f on x.ref_id = f.business_id
	LEFT JOIN x_lab_report_basis_data t on x.report_id=t.id
	WHERE
		x.equ_type_rule = 'T'
	AND x.deleted = '0'
	AND x.ref_id = #{nextId}
	AND x.e_calculate_rule = '003'
	GROUP BY
		x.e_param
    </select>


	<select id="findTransformerFirstParameterMakeMax" parameterType="java.lang.String" resultType="com.huatek.busi.entity.ParameterMake">
	SELECT
		x.id,
		x.ref_id AS refId,
		x.report_id AS reportId,
		f.file_name AS fileName,
		t.test_item AS testItem,
		x.mark,
		x.e_param AS eParam,
		x.equ_type_rule AS equTypeRule,
		x.main_equipment_id AS mainEquipmentId,
		x.create_time AS createTime,
		x.test_date AS testDate,
		max(
			cast(
				current_value AS DECIMAL (10, 2)
			)
		) AS currentValue
	FROM
		x_lab_report_mark_statistic x
	LEFT JOIN sys_file f on x.ref_id = f.business_id
	LEFT JOIN x_lab_report_basis_data t on x.report_id=t.id
	WHERE
		x.equ_type_rule = 'T'
	AND x.deleted = '0'
	AND x.ref_id = #{oldId}
	AND x.e_calculate_rule = '001'
	GROUP BY
		x.e_param
    </select>

	<select id="findGisFirstMakeMax" parameterType="java.lang.String" resultType="com.huatek.busi.entity.ParameterMake">
	SELECT
		x.id,
		x.ref_id AS refId,
		x.report_id AS reportId,
		f.file_name AS fileName,
		t.test_item AS testItem,
		x.mark,
		x.e_param AS eParam,
		x.equ_type_rule AS equTypeRule,
		x.main_equipment_id AS mainEquipmentId,
		x.create_time AS createTime,
		x.test_date AS testDate,
		max(
			cast(
				current_value AS DECIMAL (10, 2)
			)
		) AS currentValue
	FROM
		x_lab_report_mark_statistic x
	LEFT JOIN sys_file f on x.ref_id = f.business_id
	LEFT JOIN x_lab_report_basis_data t on x.report_id=t.id
	WHERE
		x.equ_type_rule = 'G'
	AND x.deleted = '0'
	AND x.ref_id = #{oldId}
	AND x.e_calculate_rule = '001'
	GROUP BY
		x.e_param
    </select>

	<select id="findTransformerFirstParameterMakeMin" parameterType="java.lang.String" resultType="com.huatek.busi.entity.ParameterMake">
	SELECT
		x.id,
		x.ref_id AS refId,
		x.report_id AS reportId,
		f.file_name AS fileName,
		t.test_item AS testItem,
		x.mark,
		x.e_param AS eParam,
		x.equ_type_rule AS equTypeRule,
		x.main_equipment_id AS mainEquipmentId,
		x.create_time AS createTime,
		x.test_date AS testDate,
		min(
			cast(
				current_value AS DECIMAL (10, 2)
			)
		) AS currentValue
	FROM
		x_lab_report_mark_statistic x
	LEFT JOIN sys_file f on x.ref_id = f.business_id
	LEFT JOIN x_lab_report_basis_data t on x.report_id=t.id
	WHERE
		x.equ_type_rule = 'T'
	AND x.deleted = '0'
	AND x.ref_id = #{oldId}
	AND x.e_calculate_rule = '002'
	GROUP BY
		x.e_param
    </select>

	<select id="findGisFirstMakeMin" parameterType="java.lang.String" resultType="com.huatek.busi.entity.ParameterMake">
	SELECT
		x.id,
		x.ref_id AS refId,
		x.report_id AS reportId,
		f.file_name AS fileName,
		t.test_item AS testItem,
		x.mark,
		x.e_param AS eParam,
		x.equ_type_rule AS equTypeRule,
		x.main_equipment_id AS mainEquipmentId,
		x.create_time AS createTime,
		x.test_date AS testDate,
		min(
			cast(
				current_value AS DECIMAL (10, 2)
			)
		) AS currentValue
	FROM
		x_lab_report_mark_statistic x
	LEFT JOIN sys_file f on x.ref_id = f.business_id
	LEFT JOIN x_lab_report_basis_data t on x.report_id=t.id
	WHERE
		x.equ_type_rule = 'G'
	AND x.deleted = '0'
	AND x.ref_id = #{oldId}
	AND x.e_calculate_rule = '002'
	GROUP BY
		x.e_param
    </select>

	<select id="findTransformerFirstParameterMakeAvg" parameterType="java.lang.String" resultType="com.huatek.busi.entity.ParameterMake">
	SELECT
		x.id,
		x.ref_id AS refId,
		x.report_id AS reportId,
		f.file_name AS fileName,
		t.test_item AS testItem,
		x.mark,
		x.e_param AS eParam,
		x.equ_type_rule AS equTypeRule,
		x.main_equipment_id AS mainEquipmentId,
		x.create_time AS createTime,
		x.test_date AS testDate,
		avg(
			cast(
				current_value AS DECIMAL (10, 2)
			)
		) AS currentValue
	FROM
		x_lab_report_mark_statistic x
	LEFT JOIN sys_file f on x.ref_id = f.business_id
	LEFT JOIN x_lab_report_basis_data t on x.report_id=t.id
	WHERE
		x.equ_type_rule = 'T'
	AND x.deleted = '0'
	AND x.ref_id = #{oldId}
	AND x.e_calculate_rule = '003'
	GROUP BY
		x.e_param
    </select>
	<select id="findGisFirstMakeAvg" parameterType="java.lang.String" resultType="com.huatek.busi.entity.ParameterMake">
	SELECT
		x.id,
		x.ref_id AS refId,
		x.report_id AS reportId,
		f.file_name AS fileName,
		t.test_item AS testItem,
		x.mark,
		x.e_param AS eParam,
		x.equ_type_rule AS equTypeRule,
		x.main_equipment_id AS mainEquipmentId,
		x.create_time AS createTime,
		x.test_date AS testDate,
		avg(
			cast(
				current_value AS DECIMAL (10, 2)
			)
		) AS currentValue
	FROM
		x_lab_report_mark_statistic x
	LEFT JOIN sys_file f on x.ref_id = f.business_id
	LEFT JOIN x_lab_report_basis_data t on x.report_id=t.id
	WHERE
		x.equ_type_rule = 'G'
	AND x.deleted = '0'
	AND x.ref_id = #{oldId}
	AND x.e_calculate_rule = '003'
	GROUP BY
		x.e_param
    </select>
	<select id="finRefNewId" resultType="com.huatek.busi.vo.ParameterVo">
		SELECT
				id,
				ref_id as refId,
				create_time as createTime,
				test_date as testDate
				FROM
					x_lab_report_mark_statistic
			WHERE
				equ_type_rule = 'T'
			AND deleted = '0'
			GROUP BY
				ref_id
		ORDER BY create_time desc
		LIMIT 1

	</select>
	<select id="finGisNewId" resultType="com.huatek.busi.vo.ParameterVo">
		SELECT
				id,
				ref_id as refId,
				create_time as createTime,
				test_date as testDate
				FROM
					x_lab_report_mark_statistic
			WHERE
				equ_type_rule = 'G'
			AND deleted = '0'
			GROUP BY
				ref_id
		ORDER BY create_time desc
		LIMIT 1

	</select>
	<select id="finRefSecondId" resultType="com.huatek.busi.vo.ParameterVo">
		SELECT
				id,
				ref_id as refId,
				create_time as createTime,
				test_date as testDate
				FROM
					x_lab_report_mark_statistic
			WHERE
				equ_type_rule = 'T'
			AND deleted = '0'
			GROUP BY
				ref_id
		ORDER BY create_time desc
		LIMIT 1,1

	</select>

	<select id="finGisSecondId" resultType="com.huatek.busi.vo.ParameterVo">
		SELECT
				id,
				ref_id as refId,
				create_time as createTime,
				test_date as testDate
				FROM
					x_lab_report_mark_statistic
			WHERE
				equ_type_rule = 'G'
			AND deleted = '0'
			GROUP BY
				ref_id
		ORDER BY create_time desc
		LIMIT 1,1

	</select>
	<select id="finRefFirstId" resultType="com.huatek.busi.vo.ParameterVo">
		SELECT
				id,
				ref_id as refId,
				create_time as createTime,
				test_date as testDate
				FROM
					x_lab_report_mark_statistic
			WHERE
				equ_type_rule = 'T'
			AND deleted = '0'
			GROUP BY
				ref_id
		ORDER BY create_time asc
		LIMIT 1

	</select>

	<select id="finGisFirstId" resultType="com.huatek.busi.vo.ParameterVo">
		SELECT
				id,
				ref_id as refId,
				create_time as createTime,
				test_date as testDate
				FROM
					x_lab_report_mark_statistic
			WHERE
				equ_type_rule = 'G'
			AND deleted = '0'
			GROUP BY
				ref_id
		ORDER BY create_time asc
		LIMIT 1

	</select>

	<select id="findAllReport" resultType="com.huatek.busi.vo.ParameterVo">
	SELECT
		id,
		ref_id AS refId,
		create_time AS createTime,
		test_date AS testDate
	FROM
		x_lab_report_mark_statistic
	WHERE
		equ_type_rule = 'T'
	AND deleted = '0'
	GROUP BY
		ref_id
	ORDER BY
		create_time DESC
	</select>

	<select id="findGisAllReport" resultType="com.huatek.busi.vo.ParameterVo">
	SELECT
		id,
		ref_id AS refId,
		create_time AS createTime,
		test_date AS testDate
	FROM
		x_lab_report_mark_statistic
	WHERE
		equ_type_rule = 'G'
	AND deleted = '0'
	GROUP BY
		ref_id
	ORDER BY
		create_time DESC
	</select>
	<select id="findGisMakeMax" parameterType="java.lang.String" resultType="com.huatek.busi.entity.ParameterMake">
		SELECT
		x.id,
		x.ref_id AS refId,
		x.report_id AS reportId,
		f.file_name AS fileName,
		t.test_item AS testItem,
		x.mark,
		x.e_rule AS eRule,
		x.e_param AS eParam,
		x.equ_type_rule AS equTypeRule,
		x.main_equipment_id AS mainEquipmentId,
		x.create_time AS createTime,
		x.test_date AS testDate,
		max(
			cast(
				current_value AS DECIMAL (10, 2)
			)
		) AS currentValue
	FROM
		x_lab_report_mark_statistic x
	LEFT JOIN sys_file f on x.ref_id = f.business_id
	LEFT JOIN x_lab_report_basis_data t on x.report_id=t.id
	WHERE
		x.equ_type_rule = 'G'
	AND x.deleted = '0'
	AND x.ref_id = #{lastId}
	AND x.e_calculate_rule = '001'
	AND x.e_rule not BETWEEN '0046' AND '0057'
	AND x.e_rule not BETWEEN '0086' AND '0097'
	GROUP BY
		x.e_param
	</select>
	<select id="findGisMakeMin" parameterType="java.lang.String" resultType="com.huatek.busi.entity.ParameterMake">
		SELECT
		x.id,
		x.ref_id AS refId,
		x.report_id AS reportId,
		f.file_name AS fileName,
		t.test_item AS testItem,
		x.mark,
		x.e_rule AS eRule,
		x.e_param AS eParam,
		x.equ_type_rule AS equTypeRule,
		x.main_equipment_id AS mainEquipmentId,
		x.create_time AS createTime,
		x.test_date AS testDate,
		min(
			cast(
				current_value AS DECIMAL (10, 2)
			)
		) AS currentValue
	FROM
		x_lab_report_mark_statistic x
	LEFT JOIN sys_file f on x.ref_id = f.business_id
	LEFT JOIN x_lab_report_basis_data t on x.report_id=t.id
	WHERE
		x.equ_type_rule = 'G'
	AND x.deleted = '0'
	AND x.ref_id = #{lastId}
	AND x.e_calculate_rule = '002'
	AND x.e_rule not BETWEEN '0046' AND '0057'
	AND x.e_rule not BETWEEN '0086' AND '0097'
	GROUP BY
		x.e_param
	</select>
	<select id="findGisMakeAvg" parameterType="java.lang.String" resultType="com.huatek.busi.entity.ParameterMake">
	SELECT
			x.id,
			x.ref_id AS refId,
			x.report_id AS reportId,
			f.file_name AS fileName,
			t.test_item AS testItem,
			x.mark,
			x.e_rule AS eRule,
			x.e_param AS eParam,
			x.equ_type_rule AS equTypeRule,
			x.main_equipment_id AS mainEquipmentId,
			x.create_time AS createTime,
			x.test_date AS testDate,
			avg (
				cast(
					current_value AS DECIMAL (10, 2)
				)
			) AS currentValue
		FROM
			x_lab_report_mark_statistic x
		LEFT JOIN sys_file f on x.ref_id = f.business_id
		LEFT JOIN x_lab_report_basis_data t on x.report_id=t.id
		WHERE
			x.equ_type_rule = 'G'
		AND x.deleted = '0'
		AND x.ref_id = #{lastId}
		AND x.e_calculate_rule = '003'
		AND x.e_rule not BETWEEN '0046' AND '0057'
		AND x.e_rule not BETWEEN '0086' AND '0097'
		GROUP BY
		x.e_param
	</select>
	<insert id="addParamValue" parameterType="com.huatek.busi.vo.ParameterResultVo"  >
		INSERT INTO x_param_mark
		(
		 `id`,
		  `ref_id`,
		  `report_id`,
		  `file_name`,
		  `test_item`,
		  `mark`,
		  `equ_type_rule`,
		  `create_time`,
		  `e_param`,
		  `test_date`,
		  `deviate_value`,
		  `absolute_rate`,
		  `relative_rate`,
		  `main_equipment_id`
		)
		values
		(
				#{id},
				#{refId},
				#{reportId},
				#{fileName},
				#{testItem},
				#{mark},
				#{equTypeRule},
				#{createTime},
				#{eParam},
				#{testDate},
				#{deviateValue},
				#{absoluteRate},
				#{relativeRate},
				#{mainEquipmentId}
		)
	</insert>

	<select id="findTransformerRate" parameterType="java.lang.String" resultType="com.huatek.busi.vo.ParameterResultVo">
			SELECT
		`id` as id,
		`ref_id` as refId ,
		`report_id` as reportId,
		`file_name` as fileName ,
		`test_item` as test_item ,
		`mark`,
		`equ_type_rule` as equTypeRule,
		`create_time` as createTime,
		`e_param` as eParam,
		`test_date` as testDate,
		`deviate_value` as deviateValue ,
		`absolute_rate` as absoluteRate,
		`relative_rate` as relativeRate ,
		`main_equipment_id` as mainEquipmentId
		FROM
		x_param_mark
		where ref_id = #{refId}
		AND equ_type_rule = 'T'
	</select>

	<select id="findAllTransformerRecently" parameterType="java.lang.String" resultType="com.huatek.busi.vo.ParameterMakeVo">
		SELECT
			x.id,
			x.ref_id AS refId,
			x.mark_id AS markId,
			x.report_id AS reportId,
			f.file_name AS fileName,
			t.test_item AS testItem,
			x.mark,
			x.e_param AS eParam,
			x.equ_type_rule AS equTypeRule,
			x.main_equipment_id AS mainEquipmentId,
			x.create_time AS createTime,
			x.test_date AS testDate,
			x.current_value AS currentValue
		FROM
			x_lab_report_mark_statistic x
			LEFT JOIN sys_file f on x.ref_id = f.business_id
			LEFT JOIN x_lab_report_basis_data t on x.report_id=t.id
		where
			x.mark_id = #{makeId}
		And f.file_type = 'R_TEMPLATE'
		ORDER BY x.test_date DESC
		LIMIT 1
	</select>


	<select id="findRTransformerMax" parameterType="java.lang.String" resultType="com.huatek.busi.vo.ParameterMakeVo">

			SELECT
				x.id,
				x.ref_id AS refId,
				x.mark_id AS markId,
				x.report_id AS reportId,
				f.file_name AS fileName,
				t.test_item AS testItem,
				x.mark,
				x.e_param AS eParam,
				x.equ_type_rule AS equTypeRule,
				x.main_equipment_id AS mainEquipmentId,
				x.create_time AS createTime,
				x.test_date AS testDate,
				max(
					cast(
						current_value AS DECIMAL (10, 2)
					)
				) AS currentValue

		FROM
			x_lab_report_mark_statistic x
			LEFT JOIN sys_file f on x.ref_id = f.business_id
			LEFT JOIN x_lab_report_basis_data t on x.report_id=t.id
		where
			x.e_param = #{eParam}
		AND x.test_date = #{dateRStr}
	</select>
	<select id="findAllTransformerMake" resultType="com.huatek.busi.vo.ParameterMakeVo">
	SELECT
		x.id,
		x.ref_id AS refId,
		x.mark_id AS markId,
		x.report_id AS reportId,
		f.file_name AS fileName,
 		t.test_item AS testItem,
		x.mark,
		x.e_param AS eParam,
		x.equ_type_rule AS equTypeRule,
		x.main_equipment_id AS mainEquipmentId,
		x.create_time AS createTime,
		x.test_date AS testDate,
		x.current_value AS currentValue
	FROM
		x_lab_report_mark_statistic x
		LEFT JOIN sys_file f on x.ref_id = f.business_id
		LEFT JOIN x_lab_report_basis_data t on x.report_id=t.id
	where
		x.equ_type_rule = 'T'
	AND x.deleted ='0'
	AND f.file_type = 'R_TEMPLATE'
	AND x.e_rule not BETWEEN '0032' AND '0045'
	GROUP BY x.mark_id
	</select>
	<select id="findAllTransformerLast" parameterType="java.lang.String" resultType="com.huatek.busi.vo.ParameterMakeVo">
		SELECT
				x.id,
				x.ref_id AS refId,
				x.mark_id AS markId,
				x.report_id AS reportId,
				f.file_name AS fileName,
				t.test_item AS testItem,
				x.mark,
				x.e_param AS eParam,
				x.equ_type_rule AS equTypeRule,
				x.main_equipment_id AS mainEquipmentId,
				x.create_time AS createTime,
				x.test_date AS testDate,
				x.current_value AS currentValue
		FROM
			x_lab_report_mark_statistic x
			LEFT JOIN sys_file f on x.ref_id = f.business_id
			LEFT JOIN x_lab_report_basis_data t on x.report_id=t.id
		where
			x.mark_id = #{makeId}
		And f.file_type = 'R_TEMPLATE'
		ORDER BY x.test_date DESC
			LIMIT 1,1
	</select>
	<select id="findAllTransformerFirst" parameterType="java.lang.String" resultType="com.huatek.busi.vo.ParameterMakeVo">
		SELECT
				x.id,
				x.ref_id AS refId,
				x.mark_id AS markId,
				x.report_id AS reportId,
				f.file_name AS fileName,
				t.test_item AS testItem,
				x.mark,
				x.e_param AS eParam,
				x.equ_type_rule AS equTypeRule,
				x.main_equipment_id AS mainEquipmentId,
				x.create_time AS createTime,
				x.test_date AS testDate,
				x.current_value AS currentValue
		FROM
			x_lab_report_mark_statistic x
			LEFT JOIN sys_file f on x.ref_id = f.business_id
			LEFT JOIN x_lab_report_basis_data t on x.report_id=t.id
		where
			x.mark_id = #{makeId}
		And f.file_type = 'R_TEMPLATE'
		ORDER BY x.test_date ASC
			LIMIT 1
	</select>
	<select id="findLTransformerMax" parameterType="java.lang.String" resultType="com.huatek.busi.vo.ParameterMakeVo">
		SELECT
				x.id,
				x.ref_id AS refId,
				x.mark_id AS markId,
				x.report_id AS reportId,
				f.file_name AS fileName,
				t.test_item AS testItem,
				x.mark,
				x.e_param AS eParam,
				x.equ_type_rule AS equTypeRule,
				x.main_equipment_id AS mainEquipmentId,
				x.create_time AS createTime,
				x.test_date AS testDate,
				max(
					cast(
						current_value AS DECIMAL (10, 2)
					)
				) AS currentValue

		FROM
			x_lab_report_mark_statistic x
			LEFT JOIN sys_file f on x.ref_id = f.business_id
			LEFT JOIN x_lab_report_basis_data t on x.report_id=t.id
		where
			x.e_param = #{eParam}
		AND x.test_date = #{dateLStr}
	</select>
	<select id="findFTransformerMax" parameterType="java.lang.String" resultType="com.huatek.busi.vo.ParameterMakeVo">
		SELECT
				x.id,
				x.ref_id AS refId,
				x.mark_id AS markId,
				x.report_id AS reportId,
				f.file_name AS fileName,
				t.test_item AS testItem,
				x.mark,
				x.e_param AS eParam,
				x.equ_type_rule AS equTypeRule,
				x.main_equipment_id AS mainEquipmentId,
				x.create_time AS createTime,
				x.test_date AS testDate,
				max(
					cast(
						current_value AS DECIMAL (10, 2)
					)
				) AS currentValue

		FROM
			x_lab_report_mark_statistic x
			LEFT JOIN sys_file f on x.ref_id = f.business_id
			LEFT JOIN x_lab_report_basis_data t on x.report_id=t.id
		where
			x.e_param = #{eParam}
		AND x.test_date = #{dateFStr}
	</select>
	<select id="findRTransformerMin" parameterType="java.lang.String" resultType="com.huatek.busi.vo.ParameterMakeVo">
		SELECT
				x.id,
				x.ref_id AS refId,
				x.mark_id AS markId,
				x.report_id AS reportId,
				f.file_name AS fileName,
				t.test_item AS testItem,
				x.mark,
				x.e_param AS eParam,
				x.equ_type_rule AS equTypeRule,
				x.main_equipment_id AS mainEquipmentId,
				x.create_time AS createTime,
				x.test_date AS testDate,
				min(
					cast(
						current_value AS DECIMAL (10, 2)
					)
				) AS currentValue

		FROM
			x_lab_report_mark_statistic x
			LEFT JOIN sys_file f on x.ref_id = f.business_id
			LEFT JOIN x_lab_report_basis_data t on x.report_id=t.id
		where
			x.e_param = #{eParam}
		AND x.test_date = #{dateRStr}
	</select>
	<select id="findLTransformerMin" parameterType="java.lang.String" resultType="com.huatek.busi.vo.ParameterMakeVo">
		SELECT
				x.id,
				x.ref_id AS refId,
				x.mark_id AS markId,
				x.report_id AS reportId,
				f.file_name AS fileName,
				t.test_item AS testItem,
				x.mark,
				x.e_param AS eParam,
				x.equ_type_rule AS equTypeRule,
				x.main_equipment_id AS mainEquipmentId,
				x.create_time AS createTime,
				x.test_date AS testDate,
				min(
					cast(
						current_value AS DECIMAL (10, 2)
					)
				) AS currentValue

		FROM
			x_lab_report_mark_statistic x
			LEFT JOIN sys_file f on x.ref_id = f.business_id
			LEFT JOIN x_lab_report_basis_data t on x.report_id=t.id
		where
			x.e_param = #{eParam}
		AND x.test_date = #{dateLStr}
	</select>
	<select id="findFTransformerMin" parameterType="java.lang.String" resultType="com.huatek.busi.vo.ParameterMakeVo">
		SELECT
				x.id,
				x.ref_id AS refId,
				x.mark_id AS markId,
				x.report_id AS reportId,
				f.file_name AS fileName,
				t.test_item AS testItem,
				x.mark,
				x.e_param AS eParam,
				x.equ_type_rule AS equTypeRule,
				x.main_equipment_id AS mainEquipmentId,
				x.create_time AS createTime,
				x.test_date AS testDate,
				min(
					cast(
						current_value AS DECIMAL (10, 2)
					)
				) AS currentValue

		FROM
			x_lab_report_mark_statistic x
			LEFT JOIN sys_file f on x.ref_id = f.business_id
			LEFT JOIN x_lab_report_basis_data t on x.report_id=t.id
		where
			x.e_param = #{eParam}
		AND x.test_date = #{dateFStr}
	</select>
	<select id="findRTransformerAvg" parameterType="java.lang.String" resultType="com.huatek.busi.vo.ParameterMakeVo">
		SELECT
				x.id,
				x.ref_id AS refId,
				x.mark_id AS markId,
				x.report_id AS reportId,
				f.file_name AS fileName,
				t.test_item AS testItem,
				x.mark,
				x.e_param AS eParam,
				x.equ_type_rule AS equTypeRule,
				x.main_equipment_id AS mainEquipmentId,
				x.create_time AS createTime,
				x.test_date AS testDate,
				avg(
					cast(
						current_value AS DECIMAL (10, 2)
					)
				) AS currentValue

		FROM
			x_lab_report_mark_statistic x
			LEFT JOIN sys_file f on x.ref_id = f.business_id
			LEFT JOIN x_lab_report_basis_data t on x.report_id=t.id
		where
			x.mark_id = #{makeId}
		AND x.test_date = #{dateRStr}
	</select>
	<select id="findLTransformerAvg" parameterType="java.lang.String" resultType="com.huatek.busi.vo.ParameterMakeVo">
		SELECT
				x.id,
				x.ref_id AS refId,
				x.mark_id AS markId,
				x.report_id AS reportId,
				f.file_name AS fileName,
				t.test_item AS testItem,
				x.mark,
				x.e_param AS eParam,
				x.equ_type_rule AS equTypeRule,
				x.main_equipment_id AS mainEquipmentId,
				x.create_time AS createTime,
				x.test_date AS testDate,
				avg(
					cast(
						current_value AS DECIMAL (10, 2)
					)
				) AS currentValue

		FROM
			x_lab_report_mark_statistic x
			LEFT JOIN sys_file f on x.ref_id = f.business_id
			LEFT JOIN x_lab_report_basis_data t on x.report_id=t.id
		where
			x.mark_id = #{makeId}
		AND x.test_date = #{dateLStr}
	</select>
	<select id="findFTransformerAvg" parameterType="java.lang.String" resultType="com.huatek.busi.vo.ParameterMakeVo">
		SELECT
				x.id,
				x.ref_id AS refId,
				x.mark_id AS markId,
				x.report_id AS reportId,
				f.file_name AS fileName,
				t.test_item AS testItem,
				x.mark,
				x.e_param AS eParam,
				x.equ_type_rule AS equTypeRule,
				x.main_equipment_id AS mainEquipmentId,
				x.create_time AS createTime,
				x.test_date AS testDate,
				avg(
					cast(
						current_value AS DECIMAL (10, 2)
					)
				) AS currentValue

		FROM
			x_lab_report_mark_statistic x
			LEFT JOIN sys_file f on x.ref_id = f.business_id
			LEFT JOIN x_lab_report_basis_data t on x.report_id=t.id
		where
			x.mark_id = #{makeId}
		AND x.test_date = #{dateFStr}
	</select>
	<select id="findXParamMake" resultType="com.huatek.busi.entity.XParamMark">
		SELECT
			id,
			ref_id as refId,
			report_id as reportId,
			mark_id as markId,
			file_name as fileName,
			test_item as testItem,
			mark,
			equ_type_rule as equTypeRule,
			e_param as eParam,
			test_date as testDate,
			absolute_rate as absoluteRate,
			relative_rate as relativeRate,
			main_equipment_id as mainEquipmentId,
			create_time as createTime
		FROM
		x_param_mark
		WHERE equ_type_rule = 'T'
	</select>
	<select id="findTransformerParameterRate" parameterType="java.lang.String" resultType="com.huatek.busi.vo.ParameterMakeVo">
		select
			id,
			ref_id as refId,
			mark_id as markId,
			file_name as fileName,
			test_item as testItem,
			mark,
			e_param as eParam,
			test_date as testDate,
			absolute_rate as absoluteRate,
			relative_rate as relativeRate,
			main_equipment_id as mainEquipmentId
			FROM
			x_param_mark
		WHERE
		mark_id=#{markId}
	</select>
	<select id="findAllGisMake" resultType="com.huatek.busi.vo.ParameterMakeVo">
		SELECT
			x.id,
			x.ref_id AS refId,
			x.mark_id AS markId,
			x.report_id AS reportId,
			f.file_name AS fileName,
			t.test_item AS testItem,
			x.mark,
			x.e_param AS eParam,
			x.equ_type_rule AS equTypeRule,
			x.main_equipment_id AS mainEquipmentId,
			x.create_time AS createTime,
			x.test_date AS testDate,
			x.current_value AS currentValue
		FROM
			x_lab_report_mark_statistic x
			LEFT JOIN sys_file f on x.ref_id = f.business_id
			LEFT JOIN x_lab_report_basis_data t on x.report_id=t.id
		where
			x.equ_type_rule = 'G'
		AND x.deleted ='0'
		AND f.file_type = 'R_TEMPLATE'
		AND x.e_rule not BETWEEN '0046' AND '0057'
		AND x.e_rule not BETWEEN '0086' AND '0097'
	GROUP BY x.mark_id
	</select>
	<select id="findAllGisRecently" parameterType="java.lang.String" resultType="com.huatek.busi.vo.ParameterMakeVo">
		SELECT
			x.id,
			x.ref_id AS refId,
			x.mark_id AS markId,
			x.report_id AS reportId,
			f.file_name AS fileName,
			t.test_item AS testItem,
			x.mark,
			x.e_param AS eParam,
			x.equ_type_rule AS equTypeRule,
			x.main_equipment_id AS mainEquipmentId,
			x.create_time AS createTime,
			x.test_date AS testDate,
			x.current_value AS currentValue
		FROM
			x_lab_report_mark_statistic x
			LEFT JOIN sys_file f on x.ref_id = f.business_id
			LEFT JOIN x_lab_report_basis_data t on x.report_id=t.id
		where
			x.mark_id = #{makeId}
		And f.file_type = 'R_TEMPLATE'
		ORDER BY x.test_date DESC
		LIMIT 1
	</select>
	<select id="findAllGisLast" parameterType="java.lang.String" resultType="com.huatek.busi.vo.ParameterMakeVo">
		SELECT
			x.id,
			x.ref_id AS refId,
			x.mark_id AS markId,
			x.report_id AS reportId,
			f.file_name AS fileName,
			t.test_item AS testItem,
			x.mark,
			x.e_param AS eParam,
			x.equ_type_rule AS equTypeRule,
			x.main_equipment_id AS mainEquipmentId,
			x.create_time AS createTime,
			x.test_date AS testDate,
			x.current_value AS currentValue
		FROM
			x_lab_report_mark_statistic x
			LEFT JOIN sys_file f on x.ref_id = f.business_id
			LEFT JOIN x_lab_report_basis_data t on x.report_id=t.id
		where
			x.mark_id = #{makeId}
		And f.file_type = 'R_TEMPLATE'
		ORDER BY x.test_date DESC
		LIMIT 1,1
	</select>
	<select id="findAllGisFirst" parameterType="java.lang.String" resultType="com.huatek.busi.vo.ParameterMakeVo">
		SELECT
			x.id,
			x.ref_id AS refId,
			x.mark_id AS markId,
			x.report_id AS reportId,
			f.file_name AS fileName,
			t.test_item AS testItem,
			x.mark,
			x.e_param AS eParam,
			x.equ_type_rule AS equTypeRule,
			x.main_equipment_id AS mainEquipmentId,
			x.create_time AS createTime,
			x.test_date AS testDate,
			x.current_value AS currentValue
		FROM
			x_lab_report_mark_statistic x
			LEFT JOIN sys_file f on x.ref_id = f.business_id
			LEFT JOIN x_lab_report_basis_data t on x.report_id=t.id
		where
			x.mark_id = #{makeId}
		And f.file_type = 'R_TEMPLATE'
		ORDER BY x.test_date ASC
		LIMIT 1
	</select>
	<select id="findRGisAvg" parameterType="java.lang.String" resultType="com.huatek.busi.vo.ParameterMakeVo">

	SELECT
				x.id,
				x.ref_id AS refId,
				x.mark_id AS markId,
				x.report_id AS reportId,
				f.file_name AS fileName,
				t.test_item AS testItem,
				x.mark,
				x.e_param AS eParam,
				x.equ_type_rule AS equTypeRule,
				x.main_equipment_id AS mainEquipmentId,
				x.create_time AS createTime,
				x.test_date AS testDate,
				avg(
					cast(
						current_value AS DECIMAL (10, 2)
					)
				) AS currentValue

		FROM
			x_lab_report_mark_statistic x
			LEFT JOIN sys_file f on x.ref_id = f.business_id
			LEFT JOIN x_lab_report_basis_data t on x.report_id=t.id
		where
			x.mark_id = #{makeId}
		AND x.test_date = #{dateRStr}
	</select>
	<select id="findLGisAvg" parameterType="java.lang.String" resultType="com.huatek.busi.vo.ParameterMakeVo">
		SELECT
				x.id,
				x.ref_id AS refId,
				x.mark_id AS markId,
				x.report_id AS reportId,
				f.file_name AS fileName,
				t.test_item AS testItem,
				x.mark,
				x.e_param AS eParam,
				x.equ_type_rule AS equTypeRule,
				x.main_equipment_id AS mainEquipmentId,
				x.create_time AS createTime,
				x.test_date AS testDate,
				avg(
					cast(
						current_value AS DECIMAL (10, 2)
					)
				) AS currentValue

		FROM
			x_lab_report_mark_statistic x
			LEFT JOIN sys_file f on x.ref_id = f.business_id
			LEFT JOIN x_lab_report_basis_data t on x.report_id=t.id
		where
			x.mark_id = #{makeId}
		AND x.test_date = #{dateLStr}
	</select>
	<select id="findFGisAvg" parameterType="java.lang.String" resultType="com.huatek.busi.vo.ParameterMakeVo">
		SELECT
				x.id,
				x.ref_id AS refId,
				x.mark_id AS markId,
				x.report_id AS reportId,
				f.file_name AS fileName,
				t.test_item AS testItem,
				x.mark,
				x.e_param AS eParam,
				x.equ_type_rule AS equTypeRule,
				x.main_equipment_id AS mainEquipmentId,
				x.create_time AS createTime,
				x.test_date AS testDate,
				avg(
					cast(
						current_value AS DECIMAL (10, 2)
					)
				) AS currentValue

		FROM
			x_lab_report_mark_statistic x
			LEFT JOIN sys_file f on x.ref_id = f.business_id
			LEFT JOIN x_lab_report_basis_data t on x.report_id=t.id
		where
			x.mark_id = #{makeId}
		AND x.test_date = #{dateFStr}

	</select>
	<select id="findGisXParamMake" parameterType="java.lang.String" resultType="com.huatek.busi.entity.XParamMark">
		SELECT
			id,
			ref_id as refId,
			report_id as reportId,
			mark_id as markId,
			file_name as fileName,
			test_item as testItem,
			mark,
			equ_type_rule as equTypeRule,
			e_param as eParam,
			test_date as testDate,
			absolute_rate as absoluteRate,
			relative_rate as relativeRate,
			main_equipment_id as mainEquipmentId,
			create_time as createTime
		FROM
		x_param_mark
	WHERE equ_type_rule = 'G'
	</select>
	<select id="findAllArresterMake" resultType="com.huatek.busi.vo.ParameterMakeVo">
	SELECT
		x.id,
		x.ref_id AS refId,
		x.mark_id AS markId,
		x.report_id AS reportId,
		f.file_name AS fileName,
 		t.test_item AS testItem,
		x.mark,
		x.e_param AS eParam,
		x.equ_type_rule AS equTypeRule,
		x.main_equipment_id AS mainEquipmentId,
		x.create_time AS createTime,
		x.test_date AS testDate,
		x.current_value AS currentValue
	FROM
		x_lab_arrester_report_mark_statistic x
		LEFT JOIN sys_file f on x.ref_id = f.business_id
		LEFT JOIN x_lab_arrester_report_basis_data t on x.report_id=t.id
	where
			x.equ_type_rule = 'B'
		AND x.deleted ='0'
		AND f.file_type = 'R_TEMPLATE'
	</select>
	<select id="findAllArresterRecently" parameterType="java.lang.String" resultType="com.huatek.busi.vo.ParameterMakeVo">
	SELECT
			x.id,
			x.ref_id AS refId,
			x.mark_id AS markId,
			x.report_id AS reportId,
			f.file_name AS fileName,
			t.test_item AS testItem,
			x.mark,
			x.e_param AS eParam,
			x.equ_type_rule AS equTypeRule,
			x.main_equipment_id AS mainEquipmentId,
			x.create_time AS createTime,
			x.test_date AS testDate,
			x.current_value AS currentValue
	FROM
		x_lab_arrester_report_mark_statistic x
		LEFT JOIN sys_file f on x.ref_id = f.business_id
		LEFT JOIN x_lab_arrester_report_basis_data t on x.report_id=t.id
		where
			x.mark_id = #{makeId}
		And f.file_type = 'R_TEMPLATE'
		ORDER BY x.test_date DESC
		LIMIT 1
	</select>
	<select id="findAllArresterLast" parameterType="java.lang.String" resultType="com.huatek.busi.vo.ParameterMakeVo">
		SELECT
			x.id,
			x.ref_id AS refId,
			x.mark_id AS markId,
			x.report_id AS reportId,
			f.file_name AS fileName,
			t.test_item AS testItem,
			x.mark,
			x.e_param AS eParam,
			x.equ_type_rule AS equTypeRule,
			x.main_equipment_id AS mainEquipmentId,
			x.create_time AS createTime,
			x.test_date AS testDate,
			x.current_value AS currentValue
	FROM
		x_lab_arrester_report_mark_statistic x
		LEFT JOIN sys_file f on x.ref_id = f.business_id
		LEFT JOIN x_lab_arrester_report_basis_data t on x.report_id=t.id
		where
			x.mark_id = #{makeId}
		And f.file_type = 'R_TEMPLATE'
		ORDER BY x.test_date DESC
		LIMIT 1,1
	</select>
	<select id="findAllArresterFirst" parameterType="java.lang.String" resultType="com.huatek.busi.vo.ParameterMakeVo">
		SELECT
			x.id,
			x.ref_id AS refId,
			x.mark_id AS markId,
			x.report_id AS reportId,
			f.file_name AS fileName,
			t.test_item AS testItem,
			x.mark,
			x.e_param AS eParam,
			x.equ_type_rule AS equTypeRule,
			x.main_equipment_id AS mainEquipmentId,
			x.create_time AS createTime,
			x.test_date AS testDate,
			x.current_value AS currentValue
	FROM
		x_lab_arrester_report_mark_statistic x
		LEFT JOIN sys_file f on x.ref_id = f.business_id
		LEFT JOIN x_lab_arrester_report_basis_data t on x.report_id=t.id
		where
			x.mark_id = #{makeId}
		And f.file_type = 'R_TEMPLATE'
		ORDER BY x.test_date ASC
		LIMIT 1
	</select>
	<select id="findRArresterAvg" parameterType="java.lang.String" resultType="com.huatek.busi.vo.ParameterMakeVo">
		SELECT
				x.id,
				x.ref_id AS refId,
				x.mark_id AS markId,
				x.report_id AS reportId,
				f.file_name AS fileName,
				t.test_item AS testItem,
				x.mark,
				x.e_param AS eParam,
				x.equ_type_rule AS equTypeRule,
				x.main_equipment_id AS mainEquipmentId,
				x.create_time AS createTime,
				x.test_date AS testDate,
				avg(
					cast(
						current_value AS DECIMAL (10, 2)
					)
				) AS currentValue

		FROM
			x_lab_arrester_report_mark_statistic x
			LEFT JOIN sys_file f on x.ref_id = f.business_id
			LEFT JOIN x_lab_arrester_report_basis_data t on x.report_id=t.id
		where
			x.mark_id = #{makeId}
		AND x.test_date = #{dateRStr}
	</select>
	<select id="findLArresterAvg" parameterType="java.lang.String" resultType="com.huatek.busi.vo.ParameterMakeVo">
		SELECT
				x.id,
				x.ref_id AS refId,
				x.mark_id AS markId,
				x.report_id AS reportId,
				f.file_name AS fileName,
				t.test_item AS testItem,
				x.mark,
				x.e_param AS eParam,
				x.equ_type_rule AS equTypeRule,
				x.main_equipment_id AS mainEquipmentId,
				x.create_time AS createTime,
				x.test_date AS testDate,
				avg(
					cast(
						current_value AS DECIMAL (10, 2)
					)
				) AS currentValue

		FROM
			x_lab_arrester_report_mark_statistic x
			LEFT JOIN sys_file f on x.ref_id = f.business_id
			LEFT JOIN x_lab_arrester_report_basis_data t on x.report_id=t.id
		where
			x.mark_id = #{makeId}
		AND x.test_date = #{dateLStr}
	</select>
	<select id="findFArresterAvg" parameterType="java.lang.String" resultType="com.huatek.busi.vo.ParameterMakeVo">
		SELECT
				x.id,
				x.ref_id AS refId,
				x.mark_id AS markId,
				x.report_id AS reportId,
				f.file_name AS fileName,
				t.test_item AS testItem,
				x.mark,
				x.e_param AS eParam,
				x.equ_type_rule AS equTypeRule,
				x.main_equipment_id AS mainEquipmentId,
				x.create_time AS createTime,
				x.test_date AS testDate,
				avg(
					cast(
						current_value AS DECIMAL (10, 2)
					)
				) AS currentValue

		FROM
			x_lab_arrester_report_mark_statistic x
			LEFT JOIN sys_file f on x.ref_id = f.business_id
			LEFT JOIN x_lab_arrester_report_basis_data t on x.report_id=t.id
		where
			x.mark_id = #{makeId}
		AND x.test_date = #{dateFStr}
	</select>
	<select id="findAllSwitchgearMake" resultType="com.huatek.busi.vo.ParameterMakeVo">
		SELECT
			x.id,
			x.ref_id AS refId,
			x.mark_id AS markId,
			x.report_id AS reportId,
			f.file_name AS fileName,
			t.test_item AS testItem,
			x.mark,
			x.e_param AS eParam,
			x.equ_type_rule AS equTypeRule,
			x.main_equipment_id AS mainEquipmentId,
			x.create_time AS createTime,
			x.test_date AS testDate,
			x.current_value AS currentValue
		FROM
			x_lab_switchgear_report_mark_statistic x
			LEFT JOIN sys_file f on x.ref_id = f.business_id
			LEFT JOIN x_lab_switchgear_report_basis_data t on x.report_id=t.id
		where
			x.equ_type_rule = 'D'
		AND x.deleted ='0'
		AND f.file_type = 'R_TEMPLATE'
	GROUP BY x.mark_id
	</select>
	<select id="findAllSwitchgearRecently" parameterType="java.lang.String" resultType="com.huatek.busi.vo.ParameterMakeVo">
		SELECT
			x.id,
			x.ref_id AS refId,
			x.mark_id AS markId,
			x.report_id AS reportId,
			f.file_name AS fileName,
			t.test_item AS testItem,
			x.mark,
			x.e_param AS eParam,
			x.equ_type_rule AS equTypeRule,
			x.main_equipment_id AS mainEquipmentId,
			x.create_time AS createTime,
			x.test_date AS testDate,
			x.current_value AS currentValue
		FROM
			x_lab_switchgear_report_mark_statistic x
		LEFT JOIN sys_file f ON x.ref_id = f.business_id
		LEFT JOIN x_lab_switchgear_report_basis_data t ON x.report_id = t.id
		WHERE
			x.mark_id = #{makeId}
		AND f.file_type = 'R_TEMPLATE'
		ORDER BY
			x.test_date DESC
		LIMIT 1
	</select>
	<select id="findAllSwitchgearLast" parameterType="java.lang.String" resultType="com.huatek.busi.vo.ParameterMakeVo">
		SELECT
			x.id,
			x.ref_id AS refId,
			x.mark_id AS markId,
			x.report_id AS reportId,
			f.file_name AS fileName,
			t.test_item AS testItem,
			x.mark,
			x.e_param AS eParam,
			x.equ_type_rule AS equTypeRule,
			x.main_equipment_id AS mainEquipmentId,
			x.create_time AS createTime,
			x.test_date AS testDate,
			x.current_value AS currentValue
		FROM
			x_lab_switchgear_report_mark_statistic x
		LEFT JOIN sys_file f ON x.ref_id = f.business_id
		LEFT JOIN x_lab_switchgear_report_basis_data t ON x.report_id = t.id
		WHERE
			x.mark_id = #{makeId}
		AND f.file_type = 'R_TEMPLATE'
		ORDER BY
			x.test_date DESC
		LIMIT 1,1
	</select>
	<select id="findAllSwitchgearFirst" parameterType="java.lang.String" resultType="com.huatek.busi.vo.ParameterMakeVo">
		SELECT
			x.id,
			x.ref_id AS refId,
			x.mark_id AS markId,
			x.report_id AS reportId,
			f.file_name AS fileName,
			t.test_item AS testItem,
			x.mark,
			x.e_param AS eParam,
			x.equ_type_rule AS equTypeRule,
			x.main_equipment_id AS mainEquipmentId,
			x.create_time AS createTime,
			x.test_date AS testDate,
			x.current_value AS currentValue
		FROM
			x_lab_switchgear_report_mark_statistic x
		LEFT JOIN sys_file f ON x.ref_id = f.business_id
		LEFT JOIN x_lab_switchgear_report_basis_data t ON x.report_id = t.id
		WHERE
			x.mark_id = #{makeId}
		AND f.file_type = 'R_TEMPLATE'
		ORDER BY
			x.test_date ASC
		LIMIT 1
	</select>
	<select id="findRSwitchgearAvg" parameterType="java.lang.String" resultType="com.huatek.busi.vo.ParameterMakeVo">
				SELECT
					x.id,
					x.ref_id AS refId,
					x.mark_id AS markId,
					x.report_id AS reportId,
					f.file_name AS fileName,
					t.test_item AS testItem,
					x.mark,
					x.e_param AS eParam,
					x.equ_type_rule AS equTypeRule,
					x.main_equipment_id AS mainEquipmentId,
					x.create_time AS createTime,
					x.test_date AS testDate,
					avg(
						cast(
							current_value AS DECIMAL (10, 2)
						)
					) AS currentValue
				FROM
					x_lab_switchgear_report_mark_statistic x
				LEFT JOIN sys_file f ON x.ref_id = f.business_id
				LEFT JOIN x_lab_switchgear_report_basis_data t ON x.report_id = t.id
				WHERE
					x.mark_id = #{makeId}
				AND x.test_date = #{dateRStr}
	</select>
	<select id="findLSwitchgearAvg" parameterType="java.lang.String" resultType="com.huatek.busi.vo.ParameterMakeVo">
		SELECT
			x.id,
			x.ref_id AS refId,
			x.mark_id AS markId,
			x.report_id AS reportId,
			f.file_name AS fileName,
			t.test_item AS testItem,
			x.mark,
			x.e_param AS eParam,
			x.equ_type_rule AS equTypeRule,
			x.main_equipment_id AS mainEquipmentId,
			x.create_time AS createTime,
			x.test_date AS testDate,
			avg(
				cast(
					current_value AS DECIMAL (10, 2)
				)
			) AS currentValue
		FROM
			x_lab_switchgear_report_mark_statistic x
		LEFT JOIN sys_file f ON x.ref_id = f.business_id
		LEFT JOIN x_lab_switchgear_report_basis_data t ON x.report_id = t.id
		WHERE
			x.mark_id = #{makeId}
		AND x.test_date = #{dateLStr}
	</select>
	<select id="findFSwitchgearAvg" parameterType="java.lang.String" resultType="com.huatek.busi.vo.ParameterMakeVo">
		SELECT
			x.id,
			x.ref_id AS refId,
			x.mark_id AS markId,
			x.report_id AS reportId,
			f.file_name AS fileName,
			t.test_item AS testItem,
			x.mark,
			x.e_param AS eParam,
			x.equ_type_rule AS equTypeRule,
			x.main_equipment_id AS mainEquipmentId,
			x.create_time AS createTime,
			x.test_date AS testDate,
			avg(
				cast(
					current_value AS DECIMAL (10, 2)
				)
			) AS currentValue
		FROM
			x_lab_switchgear_report_mark_statistic x
		LEFT JOIN sys_file f ON x.ref_id = f.business_id
		LEFT JOIN x_lab_switchgear_report_basis_data t ON x.report_id = t.id
		WHERE
			x.mark_id = #{makeId}
		AND x.test_date = #{dateFStr}
	</select>
	<select id="findAllCableMake" resultType="com.huatek.busi.vo.ParameterMakeVo">
		SELECT
			x.id,
			x.ref_id AS refId,
			x.mark_id AS markId,
			x.report_id AS reportId,
			f.file_name AS fileName,
			t.test_item AS testItem,
			x.mark,
			x.e_param AS eParam,
			x.equ_type_rule AS equTypeRule,
			x.main_equipment_id AS mainEquipmentId,
			x.create_time AS createTime,
			x.test_date AS testDate,
			x.current_value AS currentValue
		FROM
			x_lab_cable_report_mark_statistic x
			LEFT JOIN sys_file f on x.ref_id = f.business_id
			LEFT JOIN x_lab_cable_report_basis_data t on x.report_id=t.id
		where
			x.equ_type_rule = 'E'
		AND x.deleted ='0'
		AND f.file_type = 'R_TEMPLATE'
	GROUP BY x.mark_id
	</select>
	<select id="findAllCableRecently" parameterType="java.lang.String" resultType="com.huatek.busi.vo.ParameterMakeVo">
		SELECT
			x.id,
			x.ref_id AS refId,
			x.mark_id AS markId,
			x.report_id AS reportId,
			f.file_name AS fileName,
			t.test_item AS testItem,
			x.mark,
			x.e_param AS eParam,
			x.equ_type_rule AS equTypeRule,
			x.main_equipment_id AS mainEquipmentId,
			x.create_time AS createTime,
			x.test_date AS testDate,
			x.current_value AS currentValue
		FROM
			x_lab_cable_report_mark_statistic x
			LEFT JOIN sys_file f on x.ref_id = f.business_id
			LEFT JOIN x_lab_cable_report_basis_data t on x.report_id=t.id
		where
			x.mark_id = #{makeId}
		And f.file_type = 'R_TEMPLATE'
		ORDER BY x.test_date DESC
		LIMIT 1
	</select>
	<select id="findAllCableLast" parameterType="java.lang.String" resultType="com.huatek.busi.vo.ParameterMakeVo">
		SELECT
			x.id,
			x.ref_id AS refId,
			x.mark_id AS markId,
			x.report_id AS reportId,
			f.file_name AS fileName,
			t.test_item AS testItem,
			x.mark,
			x.e_param AS eParam,
			x.equ_type_rule AS equTypeRule,
			x.main_equipment_id AS mainEquipmentId,
			x.create_time AS createTime,
			x.test_date AS testDate,
			x.current_value AS currentValue
	FROM
			x_lab_cable_report_mark_statistic x
			LEFT JOIN sys_file f on x.ref_id = f.business_id
			LEFT JOIN x_lab_cable_report_basis_data t on x.report_id=t.id
		where
			x.mark_id = #{makeId}
		And f.file_type = 'R_TEMPLATE'
		ORDER BY x.test_date DESC
		LIMIT 1,1
	</select>
	<select id="findAllCableFirst" parameterType="java.lang.String" resultType="com.huatek.busi.vo.ParameterMakeVo">
		SELECT
			x.id,
			x.ref_id AS refId,
			x.mark_id AS markId,
			x.report_id AS reportId,
			f.file_name AS fileName,
			t.test_item AS testItem,
			x.mark,
			x.e_param AS eParam,
			x.equ_type_rule AS equTypeRule,
			x.main_equipment_id AS mainEquipmentId,
			x.create_time AS createTime,
			x.test_date AS testDate,
			x.current_value AS currentValue
	FROM
			x_lab_cable_report_mark_statistic x
			LEFT JOIN sys_file f on x.ref_id = f.business_id
			LEFT JOIN x_lab_cable_report_basis_data t on x.report_id=t.id
		where
			x.mark_id = #{makeId}
		And f.file_type = 'R_TEMPLATE'
		ORDER BY x.test_date ASC
		LIMIT 1
	</select>
	<select id="findRCableAvg" parameterType="java.lang.String" resultType="com.huatek.busi.vo.ParameterMakeVo">
			SELECT
		x.id,
		x.ref_id AS refId,
		x.mark_id AS markId,
		x.report_id AS reportId,
		f.file_name AS fileName,
		t.test_item AS testItem,
		x.mark,
		x.e_param AS eParam,
		x.equ_type_rule AS equTypeRule,
		x.main_equipment_id AS mainEquipmentId,
		x.create_time AS createTime,
		x.test_date AS testDate,
		avg(
			cast(
				current_value AS DECIMAL (10, 2)
			)
		) AS currentValue
	FROM
		x_lab_cable_report_mark_statistic x
	LEFT JOIN sys_file f ON x.ref_id = f.business_id
	LEFT JOIN x_lab_cable_report_basis_data t ON x.report_id = t.id
	WHERE
		x.mark_id = #{makeId}
	AND x.test_date = #{dateRStr}
	</select>
	<select id="findLCableAvg" parameterType="java.lang.String" resultType="com.huatek.busi.vo.ParameterMakeVo">
	SELECT
		x.id,
		x.ref_id AS refId,
		x.mark_id AS markId,
		x.report_id AS reportId,
		f.file_name AS fileName,
		t.test_item AS testItem,
		x.mark,
		x.e_param AS eParam,
		x.equ_type_rule AS equTypeRule,
		x.main_equipment_id AS mainEquipmentId,
		x.create_time AS createTime,
		x.test_date AS testDate,
		avg(
			cast(
				current_value AS DECIMAL (10, 2)
			)
		) AS currentValue
	FROM
		x_lab_cable_report_mark_statistic x
	LEFT JOIN sys_file f ON x.ref_id = f.business_id
	LEFT JOIN x_lab_cable_report_basis_data t ON x.report_id = t.id
	WHERE
		x.mark_id = #{makeId}
	AND x.test_date = #{dateLStr}
	</select>
	<select id="findFCableAvg" parameterType="java.lang.String" resultType="com.huatek.busi.vo.ParameterMakeVo">
	SELECT
		x.id,
		x.ref_id AS refId,
		x.mark_id AS markId,
		x.report_id AS reportId,
		f.file_name AS fileName,
		t.test_item AS testItem,
		x.mark,
		x.e_param AS eParam,
		x.equ_type_rule AS equTypeRule,
		x.main_equipment_id AS mainEquipmentId,
		x.create_time AS createTime,
		x.test_date AS testDate,
		avg(
			cast(
				current_value AS DECIMAL (10, 2)
			)
		) AS currentValue
	FROM
		x_lab_cable_report_mark_statistic x
	LEFT JOIN sys_file f ON x.ref_id = f.business_id
	LEFT JOIN x_lab_cable_report_basis_data t ON x.report_id = t.id
	WHERE
		x.mark_id = #{makeId}
	AND x.test_date = #{dateFStr}
	</select>
	<select id="findAllGeneratorMake" resultType="com.huatek.busi.vo.ParameterMakeVo">
		SELECT
			x.id,
			x.ref_id AS refId,
			x.mark_id AS markId,
			x.report_id AS reportId,
			f.file_name AS fileName,
			t.test_item AS testItem,
			x.mark,
			x.e_param AS eParam,
			x.equ_type_rule AS equTypeRule,
			x.main_equipment_id AS mainEquipmentId,
			x.create_time AS createTime,
			x.test_date AS testDate,
			x.current_value AS currentValue
		FROM
			x_lab_generator_report_mark_statistic x
			LEFT JOIN sys_file f on x.ref_id = f.business_id
			LEFT JOIN x_lab_generator_report_basis_data t on x.report_id=t.id
		where
			x.equ_type_rule = 'F'
		AND x.deleted ='0'
		AND f.file_type = 'R_TEMPLATE'
	GROUP BY x.mark_id
	</select>
	<select id="findAllGeneratorRecently" parameterType="java.lang.String" resultType="com.huatek.busi.vo.ParameterMakeVo">
		SELECT
			x.id,
			x.ref_id AS refId,
			x.mark_id AS markId,
			x.report_id AS reportId,
			f.file_name AS fileName,
			t.test_item AS testItem,
			x.mark,
			x.e_param AS eParam,
			x.equ_type_rule AS equTypeRule,
			x.main_equipment_id AS mainEquipmentId,
			x.create_time AS createTime,
			x.test_date AS testDate,
			x.current_value AS currentValue
		FROM
			x_lab_generator_report_mark_statistic x
			LEFT JOIN sys_file f on x.ref_id = f.business_id
			LEFT JOIN x_lab_generator_report_basis_data t on x.report_id=t.id
		where
			x.mark_id = #{makeId}
		And f.file_type = 'R_TEMPLATE'
		ORDER BY x.test_date DESC
		LIMIT 1
	</select>
	<select id="findAllGeneratorLast" parameterType="java.lang.String" resultType="com.huatek.busi.vo.ParameterMakeVo">
		SELECT
			x.id,
			x.ref_id AS refId,
			x.mark_id AS markId,
			x.report_id AS reportId,
			f.file_name AS fileName,
			t.test_item AS testItem,
			x.mark,
			x.e_param AS eParam,
			x.equ_type_rule AS equTypeRule,
			x.main_equipment_id AS mainEquipmentId,
			x.create_time AS createTime,
			x.test_date AS testDate,
			x.current_value AS currentValue
		FROM
			x_lab_generator_report_mark_statistic x
			LEFT JOIN sys_file f on x.ref_id = f.business_id
			LEFT JOIN x_lab_generator_report_basis_data t on x.report_id=t.id
		where
			x.mark_id = #{makeId}
		And f.file_type = 'R_TEMPLATE'
		ORDER BY x.test_date DESC
		LIMIT 1,1
	</select>
	<select id="findAllGeneratorFirst" parameterType="java.lang.String" resultType="com.huatek.busi.vo.ParameterMakeVo">
		SELECT
			x.id,
			x.ref_id AS refId,
			x.mark_id AS markId,
			x.report_id AS reportId,
			f.file_name AS fileName,
			t.test_item AS testItem,
			x.mark,
			x.e_param AS eParam,
			x.equ_type_rule AS equTypeRule,
			x.main_equipment_id AS mainEquipmentId,
			x.create_time AS createTime,
			x.test_date AS testDate,
			x.current_value AS currentValue
		FROM
			x_lab_generator_report_mark_statistic x
			LEFT JOIN sys_file f on x.ref_id = f.business_id
			LEFT JOIN x_lab_generator_report_basis_data t on x.report_id=t.id
		where
			x.mark_id = #{makeId}
		And f.file_type = 'R_TEMPLATE'
		ORDER BY x.test_date ASC
		LIMIT 1
	</select>
	<select id="findRGeneratorAvg" parameterType="java.lang.String" resultType="com.huatek.busi.vo.ParameterMakeVo">
		SELECT
		x.id,
		x.ref_id AS refId,
		x.mark_id AS markId,
		x.report_id AS reportId,
		f.file_name AS fileName,
		t.test_item AS testItem,
		x.mark,
		x.e_param AS eParam,
		x.equ_type_rule AS equTypeRule,
		x.main_equipment_id AS mainEquipmentId,
		x.create_time AS createTime,
		x.test_date AS testDate,
		avg(
			cast(
				current_value AS DECIMAL (10, 2)
			)
		) AS currentValue
	FROM
			x_lab_generator_report_mark_statistic x
			LEFT JOIN sys_file f on x.ref_id = f.business_id
			LEFT JOIN x_lab_generator_report_basis_data t on x.report_id=t.id
	where
		x.mark_id = #{makeId}
	AND x.test_date = #{dateRStr}

	</select>
	<select id="findLGeneratorAvg" parameterType="java.lang.String" resultType="com.huatek.busi.vo.ParameterMakeVo">
		SELECT
		x.id,
		x.ref_id AS refId,
		x.mark_id AS markId,
		x.report_id AS reportId,
		f.file_name AS fileName,
		t.test_item AS testItem,
		x.mark,
		x.e_param AS eParam,
		x.equ_type_rule AS equTypeRule,
		x.main_equipment_id AS mainEquipmentId,
		x.create_time AS createTime,
		x.test_date AS testDate,
		avg(
			cast(
				current_value AS DECIMAL (10, 2)
			)
		) AS currentValue
	FROM
			x_lab_generator_report_mark_statistic x
			LEFT JOIN sys_file f on x.ref_id = f.business_id
			LEFT JOIN x_lab_generator_report_basis_data t on x.report_id=t.id
	where
		x.mark_id = #{makeId}
	AND x.test_date = #{dateLStr}
	</select>
	<select id="findFGeneratorAvg" parameterType="java.lang.String" resultType="com.huatek.busi.vo.ParameterMakeVo">
		SELECT
		x.id,
		x.ref_id AS refId,
		x.mark_id AS markId,
		x.report_id AS reportId,
		f.file_name AS fileName,
		t.test_item AS testItem,
		x.mark,
		x.e_param AS eParam,
		x.equ_type_rule AS equTypeRule,
		x.main_equipment_id AS mainEquipmentId,
		x.create_time AS createTime,
		x.test_date AS testDate,
		avg(
			cast(
				current_value AS DECIMAL (10, 2)
			)
		) AS currentValue
	FROM
			x_lab_generator_report_mark_statistic x
			LEFT JOIN sys_file f on x.ref_id = f.business_id
			LEFT JOIN x_lab_generator_report_basis_data t on x.report_id=t.id
	where
		x.mark_id = #{makeId}
	AND x.test_date = #{dateFStr}
	</select>


	<insert id="addXparamMake" parameterType="com.huatek.busi.entity.XParamMark">
 	insert into
         x_param_mark
        (
          `id` ,
          `ref_id`,
          `report_id` ,
          `mark_id` ,
          `file_name` ,
          `test_item`,
           `mark` ,
          `relative_rate`,
          `absolute_rate` ,
          `e_param`,
          `equ_type_rule`,
          `main_equipment_id`,
          `create_time`,
          `test_date`
        )
        VALUES
        (
        #{id},
        #{refId},
        #{reportId},
        #{markId},
        #{fileName},
        #{testItem},
        #{mark},
        #{relativeRate},
        #{absoluteRate},
        #{eParam},
        #{equTypeRule},
        #{mainEquipmentId},
        #{createTime},
        #{testDate}
        )
	</insert>
</mapper>