<?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="org.springblade.workorder.deviceorder.mapper.DeviceOrderMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="deviceOrderResultMap" type="org.springblade.workorder.deviceorder.entity.DeviceOrder">
        <result column="id" property="id"/>
        <result column="create_user" property="createUser"/>
        <result column="create_dept" property="createDept"/>
        <result column="create_time" property="createTime"/>
        <result column="update_user" property="updateUser"/>
        <result column="update_time" property="updateTime"/>
        <result column="status" property="status"/>
        <result column="is_deleted" property="isDeleted"/>
        <result column="device_id" property="deviceId"/>
        <result column="alarm_time" property="alarmTime"/>
        <result column="device_type" property="deviceType"/>
        <result column="alarm_position" property="alarmPosition"/>
        <result column="alarm_type" property="alarmType"/>
        <result column="alarm_reason" property="alarmReason"/>
        <result column="handle_person" property="handlePerson"/>
        <result column="handle_phone" property="handlePhone"/>
        <result column="job_status" property="jobStatus"/>
        <result column="device_name" property="deviceName"/>
        <result column="alarm_content" property="alarmContent"/>
        <result column="org_position" property="orgPosition"/>
        <result column="remark" property="remark"/>
        <result column="device_usage" property="deviceUsage"/>
        <result column="process_definition_id" property="processDefinitionId"/>
        <result column="process_instance_id" property="processInstanceId"/>
        <result column="current_step" property="currentStep"/>
        <result column="flag" property="flag"/>
        <result column="tenant_id" property="tenantId"/>
    </resultMap>


<!--    <select id="selectDeviceOrderPage" resultMap="deviceOrderResultMap">-->
<!--        select * from cy_device_order where is_deleted = 0-->
<!--    </select>-->

    <select id="selectDeviceOrderPage" resultMap="deviceOrderResultMap">
        select * from cy_device_order where is_deleted = 0
        <if test="deviceOrder!=null">
            <if test="deviceOrder.deviceId != null and deviceOrder.deviceId.trim() != ''">
                and device_id like '%${deviceOrder.deviceId}%'
            </if>
            <if test="deviceOrder.deviceType != null">
                and device_type = ${deviceOrder.deviceType}
            </if>
            <if test="deviceOrder.jobStatus!=null">
                and job_status = ${deviceOrder.jobStatus}
            </if>
        </if>
    </select>

    <select id="getUntreatedCount" resultType="java.lang.Integer">
        select COUNT(*) from cy_device_order where is_deleted = 0 AND job_status = 1
    </select>

</mapper>
