YZProjectCloud/yanzhu-common/yanzhu-common-mapper/src/main/resources/mapper/device/DevTowerDataRunMapper.xml

252 lines
14 KiB
XML

<?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.yanzhu.device.mapper.DevTowerDataRunMapper">
<resultMap type="DevTowerDataRun" id="DevTowerDataRunResult">
<result property="id" column="id" />
<result property="cfgId" column="cfg_id" />
<result property="projectId" column="project_id" />
<result property="projectName" column="projectName" />
<result property="comId" column="com_id" />
<result property="comName" column="com_name" />
<result property="deptId" column="dept_id" />
<result property="deptName" column="dept_name" />
<result property="deviceKey" column="device_key" />
<result property="deviceSource" column="device_source" />
<result property="height" column="height" />
<result property="range" column="range" />
<result property="rotation" column="rotation" />
<result property="load" column="load" />
<result property="windSpeed" column="wind_speed" />
<result property="leanAngleX" column="lean_angle_x" />
<result property="leanAngleY" column="lean_angle_y" />
<result property="loadPercent" column="load_percent" />
<result property="momentPercent" column="moment_percent" />
<result property="windSpeedPercent" column="wind_speed_percent" />
<result property="leanAnglePercent" column="lean_angle_percent" />
<result property="warnings" column="warnings" />
<result property="rate" column="rate" />
<result property="rotationSensorState" column="rotation_sensor_state" />
<result property="loadSensorState" column="load_sensor_state" />
<result property="windSpeedSensorState" column="wind_speed_sensor_state" />
<result property="leanAngleSensorState" column="lean_angle_sensor_state" />
<result property="rangeSensorState" column="range_sensor_state" />
<result property="heightSensorState" column="height_sensor_state" />
<result property="brakingStatus" column="braking_status" />
<result property="timeLongs" column="time_longs" />
<result property="isAlarm" column="is_alarm" />
<result property="isDel" column="is_del" />
<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" />
</resultMap>
<sql id="selectDevTowerDataRunVo">
select dtdr.id,
dtdr.cfg_id,
dtdr.project_id,
dtdr.com_id,
sp.project_name as projectName,
sd.dept_name as com_name, dtdr.dept_id,
dtdr.device_key,
dtdr.device_source,
dtdr.height,
dtdr.range,
dtdr.rotation,
dtdr.load,
dtdr.wind_speed,
dtdr.lean_angle_x,
dtdr.lean_angle_y,
dtdr.load_percent,
dtdr.moment_percent,
dtdr.wind_speed_percent,
dtdr.lean_angle_percent,
dtdr.warnings,
dtdr.rate,
dtdr.rotation_sensor_state,
dtdr.load_sensor_state,
dtdr.wind_speed_sensor_state,
dtdr.lean_angle_sensor_state,
dtdr.range_sensor_state,
dtdr.height_sensor_state,
dtdr.braking_status,
dtdr.time_longs,
dtdr.is_alarm,
dtdr.is_del,
dtdr.create_by,
dtdr.create_time,
dtdr.update_by,
dtdr.update_time,
dtdr.remark
from dev_tower_data_run dtdr
left join pro_project_info sp on sp.id = dtdr.project_id
left join sys_dept sd on sd.dept_id = dtdr.com_id
</sql>
<select id="selectDevTowerDataRunList" parameterType="DevTowerDataRun" resultMap="DevTowerDataRunResult">
<include refid="selectDevTowerDataRunVo"/>
<where>
<if test="cfgId != null">and dtdr.cfg_id = #{cfgId}</if>
<if test="projectId != null "> and dtdr.project_id = #{projectId}</if>
<if test="comId != null "> and dtdr.com_id = #{comId}</if>
<if test="deptId != null "> and dtdr.dept_id = #{deptId}</if>
<if test="activeComId != null "> and dtdr.com_id = #{activeComId}</if>
<if test="activeProjectId != null "> and dtdr.project_id = #{activeProjectId}</if>
<if test="projectName != null and projectName != ''"> and dtdr.project_id in (select spv.dept_id from sys_dept spv where spv.dept_name like concat('%', #{projectName}, '%'))</if>
<if test="comName != null and comName != ''"> and dtdr.dept_id in (select sdv.dept_id from sys_dept sdv where sdv.dept_name like concat('%', #{comName}, '%'))</if>
<if test="deviceKey != null and deviceKey != ''"> and dtdr.device_key = #{deviceKey}</if>
<if test="deviceSource != null and deviceSource != ''"> and dtdr.device_source = #{deviceSource}</if>
<if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''"> and dtdr.create_time between #{params.beginCreateTime} and #{params.endCreateTime}</if>
and dtdr.is_del=0
</where>
order by dtdr.id desc
</select>
<select id="selectDevTowerDataRunById" parameterType="Long" resultMap="DevTowerDataRunResult">
<include refid="selectDevTowerDataRunVo"/>
where dtdr.id = #{id} and dtdr.is_del=0
</select>
<insert id="insertDevTowerDataRun" parameterType="DevTowerDataRun" useGeneratedKeys="true" keyProperty="id">
insert into dev_tower_data_run
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="cfgId != null">cfg_id,</if>
<if test="projectId != null">project_id,</if>
<if test="comId != null">com_id,</if>
<if test="deptId != null">dept_id,</if>
<if test="deviceKey != null">device_key,</if>
<if test="deviceSource != null">device_source,</if>
<if test="height != null">height,</if>
<if test="range != null">`range`,</if>
<if test="rotation != null">rotation,</if>
<if test="load != null">`load`,</if>
<if test="windSpeed != null">wind_speed,</if>
<if test="leanAngleX != null">lean_angle_x,</if>
<if test="leanAngleY != null">lean_angle_y,</if>
<if test="loadPercent != null">load_percent,</if>
<if test="momentPercent != null">moment_percent,</if>
<if test="windSpeedPercent != null">wind_speed_percent,</if>
<if test="leanAnglePercent != null">lean_angle_percent,</if>
<if test="warnings != null">warnings,</if>
<if test="rate != null">rate,</if>
<if test="rotationSensorState != null">rotation_sensor_state,</if>
<if test="loadSensorState != null">load_sensor_state,</if>
<if test="windSpeedSensorState != null">wind_speed_sensor_state,</if>
<if test="leanAngleSensorState != null">lean_angle_sensor_state,</if>
<if test="rangeSensorState != null">range_sensor_state,</if>
<if test="heightSensorState != null">height_sensor_state,</if>
<if test="brakingStatus != null">braking_status,</if>
<if test="timeLongs != null">time_longs,</if>
<if test="isAlarm != null">is_alarm,</if>
<if test="isDel != null">is_del,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="cfgId != null">#{cfgId},</if>
<if test="projectId != null">#{projectId},</if>
<if test="comId != null">#{comId},</if>
<if test="deptId != null">#{deptId},</if>
<if test="deviceKey != null">#{deviceKey},</if>
<if test="deviceSource != null">#{deviceSource},</if>
<if test="height != null">#{height},</if>
<if test="range != null">#{range},</if>
<if test="rotation != null">#{rotation},</if>
<if test="load != null">#{load},</if>
<if test="windSpeed != null">#{windSpeed},</if>
<if test="leanAngleX != null">#{leanAngleX},</if>
<if test="leanAngleY != null">#{leanAngleY},</if>
<if test="loadPercent != null">#{loadPercent},</if>
<if test="momentPercent != null">#{momentPercent},</if>
<if test="windSpeedPercent != null">#{windSpeedPercent},</if>
<if test="leanAnglePercent != null">#{leanAnglePercent},</if>
<if test="warnings != null">#{warnings},</if>
<if test="rate != null">#{rate},</if>
<if test="rotationSensorState != null">#{rotationSensorState},</if>
<if test="loadSensorState != null">#{loadSensorState},</if>
<if test="windSpeedSensorState != null">#{windSpeedSensorState},</if>
<if test="leanAngleSensorState != null">#{leanAngleSensorState},</if>
<if test="rangeSensorState != null">#{rangeSensorState},</if>
<if test="heightSensorState != null">#{heightSensorState},</if>
<if test="brakingStatus != null">#{brakingStatus},</if>
<if test="timeLongs != null">#{timeLongs},</if>
<if test="isAlarm != null">#{isAlarm},</if>
<if test="isDel != null">#{isDel},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateDevTowerDataRun" parameterType="DevTowerDataRun">
update dev_tower_data_run
<trim prefix="SET" suffixOverrides=",">
<if test="cfgId != null">cfg_id = #{cfgId},</if>
<if test="projectId != null">project_id = #{projectId},</if>
<if test="comId != null">com_id = #{comId},</if>
<if test="deptId != null">dept_id = #{deptId},</if>
<if test="deviceKey != null">device_key = #{deviceKey},</if>
<if test="deviceSource != null">device_source = #{deviceSource},</if>
<if test="height != null">height = #{height},</if>
<if test="range != null">`range` = #{range},</if>
<if test="rotation != null">rotation = #{rotation},</if>
<if test="load != null">`load` = #{load},</if>
<if test="windSpeed != null">wind_speed = #{windSpeed},</if>
<if test="leanAngleX != null">lean_angle_x = #{leanAngleX},</if>
<if test="leanAngleY != null">lean_angle_y = #{leanAngleY},</if>
<if test="loadPercent != null">load_percent = #{loadPercent},</if>
<if test="momentPercent != null">moment_percent = #{momentPercent},</if>
<if test="windSpeedPercent != null">wind_speed_percent = #{windSpeedPercent},</if>
<if test="leanAnglePercent != null">lean_angle_percent = #{leanAnglePercent},</if>
<if test="warnings != null">warnings = #{warnings},</if>
<if test="rate != null">rate = #{rate},</if>
<if test="rotationSensorState != null">rotation_sensor_state = #{rotationSensorState},</if>
<if test="loadSensorState != null">load_sensor_state = #{loadSensorState},</if>
<if test="windSpeedSensorState != null">wind_speed_sensor_state = #{windSpeedSensorState},</if>
<if test="leanAngleSensorState != null">lean_angle_sensor_state = #{leanAngleSensorState},</if>
<if test="rangeSensorState != null">range_sensor_state = #{rangeSensorState},</if>
<if test="heightSensorState != null">height_sensor_state = #{heightSensorState},</if>
<if test="brakingStatus != null">braking_status = #{brakingStatus},</if>
<if test="timeLongs != null">time_longs = #{timeLongs},</if>
<if test="isAlarm != null">is_alarm = #{isAlarm},</if>
<if test="isDel != null">is_del = #{isDel},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteDevTowerDataRunById" parameterType="Long">
delete from dev_tower_data_run where id = #{id}
</delete>
<delete id="deleteDevTowerDataRunByIds" parameterType="String">
delete from dev_tower_data_run where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="findRunCountByDeviceKey" parameterType="DevTowerDataRound" resultType="Int">
select count(1) as total from dev_tower_data_run
<where>
<if test="deviceKey != null and deviceKey != ''">and cfg_id in (select dc.id from dev_tower_project_config dc where dc.device_sn=#{deviceKey}) and device_key = #{deviceKey}</if>
<if test='activeName == "gj"'> and is_alarm = 1 </if>
<if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''"> and date(create_time) between #{params.beginCreateTime} and #{params.endCreateTime}</if>
and is_del=0
</where>
</select>
</mapper>