| | |
| | | <?xml version="1.0" encoding="UTF-8" ?> |
| | | <!DOCTYPE mapper |
| | | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.ruoyi.system.mapper.TDetectionCabinetMapper"> |
| | | |
| | | <resultMap type="TDetectionCabinet" id="TDetectionCabinetResult"> |
| | | <id property="cabinetId" column="cabinet_id" /> |
| | | <result property="adapterId" column="adapter_id" /> |
| | | <result property="adapterCode" column="adapter_code" /> |
| | | <result property="cabinetCode" column="cabinet_code" /> |
| | | <result property="cabinetName" column="cabinet_name" /> |
| | | <result property="ipAddress" column="ip_address" /> |
| | |
| | | <result property="registrationStatus" column="registration_status" /> |
| | | </resultMap> |
| | | |
| | | <resultMap type="TDetectionCabinet" id="DiscoveredCabinetResult"> |
| | | <id property="cabinetId" column="cabinet_id" /> |
| | | <result property="cabinetCode" column="cabinet_code" /> |
| | | <result property="ipAddress" column="ip_address" /> |
| | | <result property="macAddress" column="mac_address" /> |
| | | <result property="cabinetName" column="cabinet_name" /> |
| | | <result property="manufacturer" column="manufacturer" /> |
| | | <result property="model" column="model" /> |
| | | <result property="channelCount" column="channel_count" /> |
| | | <result property="onlineStatus" column="online_status" /> |
| | | <result property="observedWorkStatus" column="observed_work_status" /> |
| | | </resultMap> |
| | | |
| | | <sql id="activeCabinetChannelExists"> |
| | | <sql id="activeCabinetTestExists"> |
| | | exists ( |
| | | select 1 from t_detection_channel channel_fact |
| | | where channel_fact.cabinet_id = cabinet.cabinet_id |
| | | and channel_fact.del_flag = 0 |
| | | and channel_fact.work_status in ( |
| | | 'WORKING', 'PAUSED', 'PROTECTED', 'SYNCHRONIZING', 'LIT', |
| | | 'WAITING_TIMEOUT', 'WAITING_START', 'LOCKED' |
| | | ) |
| | | select 1 from t_test_channel_binding binding |
| | | join t_detection_channel channel_fact on channel_fact.channel_id = binding.channel_id |
| | | join t_test test_fact on test_fact.test_id = binding.test_id |
| | | where channel_fact.cabinet_id = t_detection_cabinet.cabinet_id |
| | | and channel_fact.del_flag = 0 and test_fact.del_flag = 0 |
| | | and test_fact.test_status in ('RUNNING', 'PAUSED', 'RUNNING_ABNORMAL') |
| | | ) |
| | | </sql> |
| | | |
| | | <sql id="selectDetectionCabinetVo"> |
| | | select cabinet_id, cabinet_code, cabinet_name, ip_address, mac_address, |
| | | select cabinet_id, adapter_id, adapter_code, cabinet_code, cabinet_name, ip_address, mac_address, |
| | | manufacturer, model, capacity, channel_count, |
| | | case when upper(online_status) = 'ONLINE' or online_status = '0' then '0' else '1' end as online_status, |
| | | case when <include refid="activeCabinetChannelExists"/> then '1' else '0' end as test_status, |
| | | case when <include refid="activeCabinetChannelExists"/> then '待确认' else null end as current_test, |
| | | case when <include refid="activeCabinetTestExists"/> then '1' else '0' end as test_status, |
| | | case when <include refid="activeCabinetTestExists"/> then '待确认' else null end as current_test, |
| | | status, create_by, create_time, update_by, update_time, remark, del_flag, registration_status |
| | | from t_detection_cabinet cabinet |
| | | from t_detection_cabinet |
| | | </sql> |
| | | |
| | | <select id="selectDetectionCabinetList" parameterType="TDetectionCabinet" resultMap="TDetectionCabinetResult"> |
| | | <include refid="selectDetectionCabinetVo"/> |
| | | <where> |
| | | del_flag = '0' |
| | | and registration_status = 'REGISTERED' |
| | | del_flag = 0 and registration_status = 'REGISTERED' |
| | | <if test="device != null and device != ''"> |
| | | and ( |
| | | ip_address like concat('%', #{device}, '%') |
| | | and (ip_address like concat('%', #{device}, '%') |
| | | or cabinet_code like concat('%', #{device}, '%') |
| | | or mac_address like concat('%', #{device}, '%') |
| | | or cabinet_name like concat('%', #{device}, '%') |
| | | ) |
| | | or cabinet_name like concat('%', #{device}, '%')) |
| | | </if> |
| | | <if test="beginCreateTime != null"> |
| | | and create_time >= #{beginCreateTime} |
| | | </if> |
| | | <if test="endCreateTime != null"> |
| | | and create_time <= #{endCreateTime} |
| | | </if> |
| | | <if test="cabinetCode != null and cabinetCode != ''"> |
| | | and cabinet_code like concat('%', #{cabinetCode}, '%') |
| | | </if> |
| | | <if test="cabinetName != null and cabinetName != ''"> |
| | | and cabinet_name like concat('%', #{cabinetName}, '%') |
| | | </if> |
| | | <if test="ipAddress != null and ipAddress != ''"> |
| | | and ip_address = #{ipAddress} |
| | | </if> |
| | | <if test="macAddress != null and macAddress != ''"> |
| | | and mac_address = #{macAddress} |
| | | </if> |
| | | <if test="onlineStatus != null and onlineStatus != ''"> |
| | | and (case when upper(online_status) = 'ONLINE' or online_status = '0' then '0' else '1' end) = #{onlineStatus} |
| | | </if> |
| | | <if test="testStatus != null and testStatus != ''"> |
| | | <choose> |
| | | <when test='testStatus.equals("1")'> |
| | | and <include refid="activeCabinetChannelExists"/> |
| | | </when> |
| | | <otherwise> |
| | | and not <include refid="activeCabinetChannelExists"/> |
| | | </otherwise> |
| | | </choose> |
| | | </if> |
| | | <if test="status != null and status != ''"> |
| | | and status = #{status} |
| | | </if> |
| | | <if test="beginCreateTime != null">and create_time >= #{beginCreateTime}</if> |
| | | <if test="endCreateTime != null">and create_time <= #{endCreateTime}</if> |
| | | <if test="cabinetCode != null and cabinetCode != ''">and cabinet_code like concat('%', #{cabinetCode}, '%')</if> |
| | | <if test="cabinetName != null and cabinetName != ''">and cabinet_name like concat('%', #{cabinetName}, '%')</if> |
| | | <if test="ipAddress != null and ipAddress != ''">and ip_address = #{ipAddress}</if> |
| | | <if test="macAddress != null and macAddress != ''">and mac_address = #{macAddress}</if> |
| | | <if test="status != null and status != ''">and status = #{status}</if> |
| | | </where> |
| | | order by create_time desc, cabinet_id desc |
| | | </select> |
| | | |
| | | <select id="selectDiscoveredCabinetList" resultMap="DiscoveredCabinetResult"> |
| | | select cabinet.cabinet_id, cabinet.cabinet_code, cabinet.cabinet_name, cabinet.ip_address, |
| | | cabinet.mac_address, cabinet.manufacturer, cabinet.model, cabinet.channel_count, |
| | | cabinet.online_status, |
| | | case when <include refid="activeCabinetChannelExists"/> |
| | | then 'ACTIVE' else 'IDLE' end as observed_work_status |
| | | from t_detection_cabinet cabinet |
| | | where cabinet.del_flag = 0 and cabinet.registration_status = 'DISCOVERED' |
| | | order by cabinet.last_seen_at_utc desc, cabinet.cabinet_id desc |
| | | <select id="selectRegisteredCabinetCodes" resultType="String"> |
| | | select cabinet_code from t_detection_cabinet where del_flag = 0 |
| | | </select> |
| | | |
| | | <select id="selectDetectionCabinetById" parameterType="Long" resultMap="TDetectionCabinetResult"> |
| | | <include refid="selectDetectionCabinetVo"/> |
| | | where cabinet_id = #{cabinetId} and del_flag = '0' and registration_status = 'REGISTERED' |
| | | where cabinet_id = #{cabinetId} and del_flag = 0 and registration_status = 'REGISTERED' |
| | | </select> |
| | | |
| | | <select id="selectByCabinetCode" parameterType="String" resultMap="TDetectionCabinetResult"> |
| | | <include refid="selectDetectionCabinetVo"/> |
| | | where cabinet_code = #{cabinetCode} and del_flag = '0' limit 1 |
| | | where cabinet_code = #{cabinetCode} and del_flag = 0 limit 1 |
| | | </select> |
| | | |
| | | <select id="selectByMacAddress" parameterType="String" resultMap="TDetectionCabinetResult"> |
| | | <include refid="selectDetectionCabinetVo"/> |
| | | where mac_address = #{macAddress} and del_flag = '0' limit 1 |
| | | where mac_address = #{macAddress} and del_flag = 0 limit 1 |
| | | </select> |
| | | |
| | | <update id="registerDiscoveredCabinet" parameterType="TDetectionCabinet"> |
| | | update t_detection_cabinet |
| | | set cabinet_name = #{cabinetName}, ip_address = #{ipAddress}, mac_address = #{macAddress}, |
| | | manufacturer = #{manufacturer}, model = #{model}, capacity = #{capacity}, |
| | | channel_count = #{channelCount}, status = #{status}, registration_status = 'REGISTERED', |
| | | create_by = #{createBy}, create_time = sysdate(), update_by = #{createBy}, |
| | | update_time = sysdate(), remark = #{remark} |
| | | where cabinet_id = #{cabinetId} and del_flag = '0' and registration_status = 'DISCOVERED' |
| | | </update> |
| | | <insert id="insertDetectionCabinet" parameterType="TDetectionCabinet" useGeneratedKeys="true" keyProperty="cabinetId"> |
| | | insert into t_detection_cabinet |
| | | (adapter_id, adapter_code, cabinet_code, cabinet_name, manufacturer, model, capacity, channel_count, |
| | | vendor_device_type, vendor_device_id, ip_address, mac_address, online_status, last_seen_at_utc, |
| | | registration_status, status, create_by, create_time, remark, del_flag) |
| | | values |
| | | (#{adapterId}, #{adapterCode}, #{cabinetCode}, #{cabinetName}, #{manufacturer}, #{model}, #{capacity}, |
| | | #{channelCount}, #{vendorDeviceType}, #{vendorDeviceId}, #{ipAddress}, #{macAddress}, #{onlineStatus}, |
| | | #{lastSeenAtUtc}, 'REGISTERED', #{status}, #{createBy}, sysdate(), #{remark}, 0) |
| | | </insert> |
| | | |
| | | <insert id="insertDetectionChannel" parameterType="TDetectionChannel" useGeneratedKeys="true" keyProperty="channelId"> |
| | | insert into t_detection_channel |
| | | (adapter_id, adapter_code, cabinet_id, devtype, devid, subdevid, chlid, display_no, |
| | | online_status, work_status, last_seen_at_utc, status, create_time, del_flag) |
| | | values |
| | | (#{adapterId}, #{adapterCode}, #{cabinetId}, #{devtype}, #{devid}, #{subdevid}, #{chlid}, #{displayNo}, |
| | | #{onlineStatus}, #{workStatus}, #{lastSeenAtUtc}, '0', sysdate(), 0) |
| | | </insert> |
| | | |
| | | <update id="updateDetectionCabinet" parameterType="TDetectionCabinet"> |
| | | update t_detection_cabinet |
| | |
| | | <if test="capacity != null">capacity = #{capacity},</if> |
| | | <if test="channelCount != null">channel_count = #{channelCount},</if> |
| | | <if test="remark != null">remark = #{remark},</if> |
| | | update_by = #{updateBy}, |
| | | update_time = sysdate() |
| | | update_by = #{updateBy}, update_time = sysdate() |
| | | </set> |
| | | where cabinet_id = #{cabinetId} and del_flag = '0' and registration_status = 'REGISTERED' |
| | | where cabinet_id = #{cabinetId} and del_flag = 0 and registration_status = 'REGISTERED' |
| | | </update> |
| | | |
| | | <update id="updateDetectionCabinetStatus" parameterType="TDetectionCabinet"> |
| | | update t_detection_cabinet |
| | | set status = #{status}, update_by = #{updateBy}, update_time = sysdate() |
| | | where cabinet_id = #{cabinetId} and del_flag = '0' and registration_status = 'REGISTERED' |
| | | update t_detection_cabinet set status = #{status}, update_by = #{updateBy}, update_time = sysdate() |
| | | where cabinet_id = #{cabinetId} and del_flag = 0 and registration_status = 'REGISTERED' |
| | | </update> |
| | | |
| | | <update id="deleteDetectionChannelsByCabinetId"> |
| | | update t_detection_channel set del_flag = channel_id, update_time = sysdate() |
| | | where cabinet_id = #{cabinetId} and del_flag = 0 |
| | | </update> |
| | | |
| | | <update id="deleteDetectionCabinetById"> |
| | | update t_detection_cabinet |
| | | set del_flag = cast(cabinet_id as char), update_by = #{updateBy}, update_time = sysdate() |
| | | where cabinet_id = #{cabinetId} and del_flag = '0' and registration_status = 'REGISTERED' |
| | | set del_flag = cabinet_id, update_by = #{updateBy}, update_time = sysdate() |
| | | where cabinet_id = #{cabinetId} and del_flag = 0 and registration_status = 'REGISTERED' |
| | | </update> |
| | | |
| | | </mapper> |