<?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.ruoyi.system.mapper.TTestMapper">
|
<resultMap id="TTestResultMap" type="TTest">
|
<id property="testId" column="test_id" />
|
<result property="testName" column="test_name" />
|
<result property="principalId" column="principal_id" />
|
<result property="principalName" column="principal_name" />
|
<result property="testTypeId" column="test_type_id" />
|
<result property="testTypeName" column="test_type_name" />
|
<result property="testPurpose" column="test_purpose" />
|
<result property="status" column="status" />
|
<result property="delFlag" column="del_flag" />
|
<result property="createBy" column="create_by" />
|
<result property="createTime" column="create_time" />
|
<result property="updateBy" column="update_by" />
|
<result property="updateTime" column="update_time" />
|
<result property="remark" column="remark" />
|
<result property="batteryCount" column="battery_count" />
|
</resultMap>
|
<resultMap id="TTestBatteryResultMap" type="TTestBattery">
|
<id property="relationId" column="relation_id" />
|
<result property="testId" column="test_id" />
|
<result property="groupId" column="group_id" />
|
<result property="batteryNo" column="battery_no" />
|
<result property="cabinetId" column="cabinet_id" />
|
<result property="testChannelNo" column="test_channel_no" />
|
<result property="collectorId" column="collector_id" />
|
<result property="temperatureChannelNo" column="temperature_channel_no" />
|
<result property="positiveChannelNo" column="positive_channel_no" />
|
<result property="negativeChannelNo" column="negative_channel_no" />
|
<result property="delFlag" column="del_flag" />
|
</resultMap>
|
<resultMap id="TTestBatteryFieldResultMap" type="TTestBatteryField">
|
<id property="fieldId" column="field_id" />
|
<result property="relationId" column="relation_id" />
|
<result property="fieldName" column="field_name" />
|
<result property="fieldValue" column="field_value" />
|
<result property="delFlag" column="del_flag" />
|
</resultMap>
|
<resultMap id="TTestThresholdResultMap" type="TTestWarningThreshold">
|
<id property="thresholdId" column="threshold_id" />
|
<result property="testId" column="test_id" />
|
<result property="thresholdType" column="threshold_type" />
|
<result property="minValue" column="min_value" />
|
<result property="maxValue" column="max_value" />
|
<result property="delFlag" column="del_flag" />
|
</resultMap>
|
<resultMap id="TTestResultResultMap" type="TTestResult">
|
<id property="resultId" column="result_id" />
|
<result property="relationId" column="relation_id" />
|
<result property="testId" column="test_id" />
|
<result property="channelNo" column="channel_no" />
|
<result property="resultValue" column="result_value" />
|
<result property="resultTime" column="result_time" />
|
<result property="exceptionInfo" column="exception_info" />
|
<result property="delFlag" column="del_flag" />
|
</resultMap>
|
<select id="selectTestList" parameterType="TTest" resultMap="TTestResultMap">
|
select t.test_id, t.test_name, t.principal_id, u.user_name principal_name,
|
t.test_type_id, ty.test_type_name, t.test_purpose, t.status, t.del_flag,
|
t.create_by, t.create_time, t.update_by, t.update_time, t.remark,
|
(select count(1) from t_test_battery b where b.test_id = t.test_id and b.del_flag = '0') battery_count
|
from t_test t
|
left join sys_user u on u.user_id = t.principal_id and u.del_flag = '0'
|
left join t_test_type ty on ty.test_type_id = t.test_type_id and ty.del_flag = '0'
|
<where>
|
t.del_flag = '0'
|
<if test="testId != null">and t.test_id = #{testId}</if>
|
<if test="testName != null and testName != ''">and t.test_name like concat('%', #{testName}, '%')</if>
|
<if test="testTypeId != null">and t.test_type_id = #{testTypeId}</if>
|
<if test="batteryNo != null and batteryNo != ''">and exists (select 1 from t_test_battery fb where fb.test_id = t.test_id and fb.battery_no = #{batteryNo} and fb.del_flag = '0')</if>
|
<if test="status != null and status != ''">and t.status = #{status}</if>
|
<if test="beginCreateTime != null">and t.create_time >= #{beginCreateTime}</if>
|
<if test="endCreateTime != null">and t.create_time <= #{endCreateTime}</if>
|
</where>
|
order by t.create_time desc, t.test_id desc
|
</select>
|
<select id="selectTestById" parameterType="Long" resultMap="TTestResultMap">
|
select t.test_id, t.test_name, t.principal_id, u.user_name principal_name,
|
t.test_type_id, ty.test_type_name, t.test_purpose, t.status, t.del_flag,
|
t.create_by, t.create_time, t.update_by, t.update_time, t.remark,
|
(select count(1) from t_test_battery b where b.test_id = t.test_id and b.del_flag = '0') battery_count
|
from t_test t left join sys_user u on u.user_id = t.principal_id and u.del_flag = '0'
|
left join t_test_type ty on ty.test_type_id = t.test_type_id and ty.del_flag = '0'
|
where t.test_id = #{testId} and t.del_flag = '0'
|
</select>
|
<select id="selectTestByName" parameterType="String" resultMap="TTestResultMap">select * from t_test where test_name = #{testName} and del_flag = '0' limit 1</select>
|
<insert id="insertTest" parameterType="TTest" useGeneratedKeys="true" keyProperty="testId">insert into t_test(test_name, principal_id, test_type_id, test_purpose, status, del_flag, create_by, create_time, remark) values(#{testName}, #{principalId}, #{testTypeId}, #{testPurpose}, #{status}, #{delFlag}, #{createBy}, #{createTime}, #{remark})</insert>
|
<update id="updateTest" parameterType="TTest">update t_test set test_name=#{testName}, principal_id=#{principalId}, test_type_id=#{testTypeId}, test_purpose=#{testPurpose}, remark=#{remark}, update_by=#{updateBy}, update_time=#{updateTime} where test_id=#{testId} and del_flag='0'</update>
|
<update id="updateTestStatus">update t_test set status=#{status}, update_by=#{updateBy}, update_time=sysdate() where test_id=#{testId} and status='0' and del_flag='0'</update>
|
<update id="deleteTestById">update t_test set del_flag=cast(test_id as char), update_by=#{updateBy}, update_time=sysdate() where test_id=#{testId} and del_flag='0'</update>
|
<update id="deleteTestBatteriesByTestId">update t_test_battery set del_flag=cast(relation_id as char) where test_id=#{testId} and del_flag='0'</update>
|
<update id="deleteTestFieldsByTestId">update t_test_battery_field f join t_test_battery b on b.relation_id=f.relation_id set f.del_flag=cast(f.field_id as char) where b.test_id=#{testId} and f.del_flag='0'</update>
|
<update id="deleteTestThresholdsByTestId">update t_test_warning_threshold set del_flag=cast(threshold_id as char) where test_id=#{testId} and del_flag='0'</update>
|
<insert id="insertTestBattery" parameterType="TTestBattery" useGeneratedKeys="true" keyProperty="relationId">insert into t_test_battery(test_id, group_id, battery_no, cabinet_id, test_channel_no, collector_id, temperature_channel_no, positive_channel_no, negative_channel_no, del_flag) values(#{testId}, #{groupId}, #{batteryNo}, #{cabinetId}, #{testChannelNo}, #{collectorId}, #{temperatureChannelNo}, #{positiveChannelNo}, #{negativeChannelNo}, '0')</insert>
|
<insert id="insertTestBatteryField" parameterType="TTestBatteryField" useGeneratedKeys="true" keyProperty="fieldId">insert into t_test_battery_field(relation_id, field_name, field_value, del_flag) values(#{relationId}, #{fieldName}, #{fieldValue}, '0')</insert>
|
<insert id="insertTestThreshold" parameterType="TTestWarningThreshold" useGeneratedKeys="true" keyProperty="thresholdId">insert into t_test_warning_threshold(test_id, threshold_type, min_value, max_value, del_flag) values(#{testId}, #{thresholdType}, #{minValue}, #{maxValue}, '0')</insert>
|
<select id="selectTestBatteries" parameterType="Long" resultMap="TTestBatteryResultMap">select * from t_test_battery where test_id=#{testId} and del_flag='0' order by relation_id</select>
|
<select id="selectTestBatteryFields" parameterType="Long" resultMap="TTestBatteryFieldResultMap">select f.* from t_test_battery_field f join t_test_battery b on b.relation_id=f.relation_id where b.test_id=#{testId} and f.del_flag='0' order by f.field_id</select>
|
<select id="selectTestThresholds" parameterType="Long" resultMap="TTestThresholdResultMap">select * from t_test_warning_threshold where test_id=#{testId} and del_flag='0' order by threshold_id</select>
|
<select id="selectTestResults" parameterType="TTestResult" resultMap="TTestResultResultMap">select r.*, b.test_id from t_test_result r join t_test_battery b on b.relation_id=r.relation_id where b.test_id=#{testId} and r.del_flag='0' <if test="relationId != null">and r.relation_id=#{relationId}</if><if test="channelNo != null">and r.channel_no=#{channelNo}</if><if test="beginResultTime != null">and r.result_time >= #{beginResultTime}</if><if test="endResultTime != null">and r.result_time <= #{endResultTime}</if> order by r.result_time asc, r.result_id asc</select>
|
<select id="countTestingByBatteryNo" resultType="int">select count(1) from t_test_battery b join t_test t on t.test_id=b.test_id where b.battery_no=#{batteryNo} and b.del_flag='0' and t.status='1' and t.del_flag='0' <if test="testId != null">and t.test_id != #{testId}</if></select>
|
<select id="countTestingByCabinetChannel" resultType="int">select count(1) from t_test_battery b join t_test t on t.test_id=b.test_id where b.cabinet_id=#{cabinetId} and b.test_channel_no=#{channelNo} and b.del_flag='0' and t.status='1' and t.del_flag='0' <if test="testId != null">and t.test_id != #{testId}</if></select>
|
<select id="countTestBatteryRelation" resultType="int">select count(1) from t_test_battery where test_id=#{testId} and relation_id=#{relationId} and del_flag='0'</select>
|
<select id="countTestBatteryFields" resultType="int">select count(1) from t_test_battery_field f join t_test_battery b on b.relation_id=f.relation_id where b.test_id=#{testId} and f.relation_id=#{relationId} and f.field_name=#{fieldName} and f.del_flag='0'</select>
|
<select id="countTestThreshold" resultType="int">select count(1) from t_test_warning_threshold where test_id=#{testId} and threshold_type=#{thresholdType} and del_flag='0' <if test="thresholdId != null">and threshold_id != #{thresholdId}</if></select>
|
<select id="countTestTypeEnabled" resultType="int">select count(1) from t_test_type where test_type_id=#{testTypeId} and status='0' and del_flag='0'</select>
|
<select id="countUserEnabled" resultType="int">select count(1) from sys_user where user_id=#{userId} and status='0' and del_flag='0'</select>
|
<select id="countBatteryInEnabledGroup" resultType="int">select count(1) from t_battery_group_battery b inner join t_battery_group g on g.group_id=b.group_id and g.status='0' and g.del_flag='0' where b.group_id=#{groupId} and b.battery_no=#{batteryNo} and b.del_flag='0'</select>
|
<select id="countCabinetEnabled" resultType="int">select count(1) from t_detection_cabinet where cabinet_id=#{cabinetId} and status='0' and del_flag='0'</select>
|
<select id="countCollectorEnabled" resultType="int">select count(1) from t_collector where collector_id=#{collectorId} and cabinet_id=#{cabinetId} and status='0' and del_flag='0'</select>
|
</mapper>
|