<?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">
|
<!--namespace = 所需实现的接口全限定名-->
|
<!-- package com.ruoyi.iot.mapper;-->
|
<mapper namespace="com.ruoyi.iot.mapper.DeviceOrderMapper">
|
<sql id="selectDeviceOrderVo">
|
select d.id,
|
d.user_id,
|
d.erecto_id,
|
d.erecto_name,
|
d.user_name,
|
d.user_phone,
|
d.address,
|
d.order_type,
|
d.appointment_time,
|
d.evaluate,
|
d.device_id,
|
d.remark,
|
d.description,
|
u.user_id,
|
u.user_name,
|
u.is_authentication,
|
d.score,
|
d.state,
|
d.createuser_id,
|
d.imgurl,
|
de.device_id,
|
de.device_name
|
from iot_device_order as d
|
left join sys_user as u on d.erecto_id = u.user_id
|
left join iot_device as de on d.device_id = de.device_id
|
where d.createuser_id = #{createUserId}
|
and d.order_type = #{orderType}
|
</sql>
|
|
<resultMap id="DeviceOrderResult" type="DeviceOrder">
|
<id property="id" column="id"/>
|
<result property="erectoId" column="erecto_id"/>
|
<result property="deviceId" column="d_deviceid"/>
|
<result property="userId" column="did"/>
|
<result property="createUserId" column="createuser_id"/>
|
<result property="updateUserId" column="updateuser_id"/>
|
<result property="erectoName" column="erecto_name"/>
|
<result property="erectoPhone" column="erecto_phone"/>
|
<result property="userName" column="dusername"/>
|
<result property="userPhone" column="user_phone"/>
|
<result property="address" column="address"/>
|
<result property="orderType" column="order_type"/>
|
<result property="remark" column="remark"/>
|
<result property="description" column="description"/>
|
<result property="appointmentTime" column="appointment_time"/>
|
<result property="score" column="score"/>
|
<result property="evaluate" column="evaluate"/>
|
<result property="isRate" column="is_rate"/>
|
<result property="createTime" column="create_time"/>
|
<result property="assginTime" column="assgin_time"/>
|
<result property="receiveTime" column="receive_time"/>
|
<result property="finishTime" column="finish_time"/>
|
<result property="state" column="state"/>
|
<result property="imgUrl" column="imgurl"/>
|
<result property="receiveTimeoutFlag" column="receive_timeout_flag"/>
|
<result property="finishTimeoutFlag" column="finish_timeout_flag"/>
|
<result property="customFlag" column="custom_flag"/>
|
<association property="device" javaType="Device" resultMap="DeviceResult"/>
|
<collection property="sysuser" ofType="SysUser" resultMap="UserResult"/>
|
</resultMap>
|
|
<resultMap id="UserResult" type="SysUser">
|
<id property="userId" column="uid"/>
|
<result property="userName" column="uusername"/>
|
<result property="isAuthentication" column="is_authentication"/>
|
</resultMap>
|
<resultMap id="DeviceResult" type="Device">
|
<id property="deviceId" column="de_deviceid"/>
|
<result property="deviceName" column="device_name"/>
|
</resultMap>
|
<!--id = 所需重写的接口抽象方法,resultType = 查询后所需返回的对象类型-->
|
<select id="selectDeviceOrderList" resultMap="DeviceOrderResult">
|
select
|
d.id,
|
d.erecto_id,
|
d.device_id as d_deviceid,
|
d.user_id as did,
|
d.createuser_id,
|
d.updateuser_id,
|
d.erecto_name,
|
d.erecto_phone,
|
d.user_name as dusername,
|
d.user_phone,
|
d.address,
|
d.order_type,
|
d.remark,
|
d.description,
|
d.appointment_time,
|
d.score,
|
d.evaluate,
|
d.is_rate,
|
d.create_time,
|
d.assgin_time,
|
d.receive_time,
|
d.finish_time,
|
d.state,
|
d.imgurl,
|
d.receive_timeout_flag,
|
d.finish_timeout_flag,
|
d.custom_flag,
|
de.device_id as de_deviceid,
|
de.device_name,
|
u.user_id as uid,
|
u.user_name as uusername,
|
u.is_authentication
|
from iot_device_order as d
|
left join sys_user as u on d.erecto_id = u.user_id
|
left join iot_device as de on d.device_id = de.device_id
|
where d.order_type = #{orderType}
|
<if test=" createUserId != null and createUserId != 0 ">
|
and (d.createuser_id= #{createUserId} or d.erecto_id = #{createUserId})
|
</if>
|
<if test=" erectoId != null and erectoId > 0">
|
and d.erecto_id= #{erectoId}
|
</if>
|
<if test=" state != null and state >= 0">
|
and d.state = #{state}
|
</if>
|
<if test="userId != null and userId > 0">
|
and d.user_id = #{userId}
|
</if>
|
order by d.create_time desc
|
${params.dataScope}
|
</select>
|
<select id="selectDeviceOrderById" resultMap="DeviceOrderResult">
|
select d.id,
|
d.user_id as did,
|
d.erecto_id,
|
d.erecto_name,
|
d.erecto_phone,
|
d.user_name as dusername,
|
d.user_phone,
|
d.address,
|
d.order_type,
|
d.appointment_time,
|
d.evaluate,
|
d.device_id as d_deviceid,
|
d.remark,
|
d.description,
|
d.score,
|
d.is_rate,
|
d.state,
|
d.createuser_id,
|
d.imgurl,
|
d.custom_flag,
|
de.device_id as de_deviceid,
|
de.device_name,
|
u.user_id as uid,
|
u.user_name as uusername,
|
u.is_authentication
|
from iot_device_order as d
|
left join sys_user as u on d.erecto_id = u.user_id
|
left join iot_device as de on d.device_id = de.device_id
|
where d.id = #{id}
|
</select>
|
<!-- 根据登录的用户来查询自己未派单的安装单/维修单数量 -->
|
<select id="selectDeviceOrderCountByUndeliveredorders" resultType="java.lang.Integer">
|
select count(*)
|
from iot_device_order d where d.state = '0'
|
<if test=" orderType != null and orderType != 0 ">
|
AND d.order_type = #{orderType}
|
</if>
|
<if test=" createUserId != null and createUserId != 0 ">
|
and (d.createuser_id= #{createUserId} or d.erecto_id = #{createUserId})
|
</if>
|
<if test=" erectoId != null and erectoId != 0">
|
AND d.erecto_id = #{erectoId}
|
</if>
|
<if test="userId != null and userId != 0">
|
AND d.user_id = #{userId}
|
</if>
|
</select>
|
<!-- 根据登录的用户来查询自己已派单的安装单/维修单数量-->
|
<select id="selectDeviceOrderCountByDispatchedorders" resultType="java.lang.Integer">
|
select count(*)
|
from iot_device_order d where d.state = '1'
|
<if test=" createUserId != null and createUserId != 0 ">
|
and (d.createuser_id= #{createUserId} or d.erecto_id = #{createUserId})
|
</if>
|
<if test=" orderType != null and orderType != 0 ">
|
AND d.order_type = #{orderType}
|
</if>
|
<if test=" erectoId != null and erectoId != 0 ">
|
AND d.erecto_id = #{erectoId}
|
</if>
|
<if test="userId != null and userId != 0">
|
AND d.user_id = #{userId}
|
</if>
|
</select>
|
<!-- 根据登录的用户来查询自己已接单的安装单/维修单数量-->
|
<select id="selectDeviceOrderCountByReceivedorders" resultType="java.lang.Integer">
|
select count(*)
|
from iot_device_order d where d.state = '2'
|
<if test=" createUserId != null and createUserId != 0 ">
|
and (d.createuser_id= #{createUserId} or d.erecto_id = #{createUserId})
|
</if>
|
<if test=" orderType != null and orderType != 0 ">
|
AND d.order_type = #{orderType}
|
</if>
|
<if test=" erectoId != null and erectoId != 0 ">
|
AND d.erecto_id = #{erectoId}
|
</if>
|
<if test="userId != null and userId != 0">
|
AND d.user_id = #{userId}
|
</if>
|
</select>
|
<!-- 根据登录的用户来查询自己已完成的安装单/维修单数量-->
|
<select id="selectDeviceOrderCountByCompleted" resultType="java.lang.Integer">
|
select count(*)
|
from iot_device_order d where d.state = '3'
|
<if test=" createUserId != null and createUserId != 0 ">
|
and (d.createuser_id= #{createUserId} or d.erecto_id = #{createUserId})
|
</if>
|
<if test=" orderType != null and orderType != 0">
|
AND d.order_type = #{orderType}
|
</if>
|
<if test=" erectoId != null and erectoId != 0">
|
AND d.erecto_id = #{erectoId}
|
</if>
|
<if test="userId != null and userId != 0">
|
AND d.user_id = #{userId}
|
</if>
|
</select>
|
<select id="selectDeviceOrderByIdAndErectoName" resultMap="DeviceOrderResult">
|
select d.id,
|
d.user_id as did,
|
d.erecto_id,
|
d.erecto_name,
|
d.erecto_phone,
|
d.user_name as dusername,
|
d.user_phone,
|
d.address,
|
d.order_type,
|
d.appointment_time,
|
d.evaluate,
|
d.score,
|
d.is_rate,
|
d.device_id as d_deviceid,
|
d.remark,
|
d.description,
|
d.state,
|
d.createuser_id,
|
d.imgurl,
|
d.custom_flag,
|
de.device_id as de_deviceid,
|
de.device_name,
|
u.user_id as uid,
|
u.user_name as uusername,
|
u.is_authentication
|
from iot_device_order as d
|
left join sys_user as u on d.erecto_id = u.user_id
|
left join iot_device as de on d.device_id = de.device_id
|
where d.id = #{id}
|
AND d.erecto_name = #{erectoName}
|
</select>
|
<select id="selectDeviceOrderAll" resultMap="DeviceOrderResult">
|
select d.id,
|
d.user_id as did,
|
d.createuser_id,
|
d.erecto_id,
|
d.erecto_name,
|
d.erecto_phone,
|
d.user_name as dusername,
|
d.user_phone,
|
d.address,
|
d.order_type,
|
d.appointment_time,
|
d.evaluate,
|
d.device_id as d_deviceid,
|
d.remark,
|
d.description,
|
d.score,
|
d.is_rate,
|
d.create_time,
|
d.assgin_time,
|
d.receive_time,
|
d.finish_time,
|
d.state,
|
d.imgurl,
|
d.custom_flag,
|
d.receive_timeout_flag,
|
d.finish_timeout_flag,
|
u.user_id as uid,
|
u.user_name as uusername,
|
u.is_authentication,
|
de.device_id as de_deviceid,
|
de.device_name
|
from iot_device_order as d
|
left join sys_user as u on d.erecto_id = u.user_id
|
left join iot_device as de on d.device_id = de.device_id
|
where d.state in (1, 2)
|
</select>
|
|
<insert id="insertDeviceOrder" parameterType="DeviceOrder" useGeneratedKeys="true" keyProperty="id">
|
insert into iot_device_order(
|
<if test="id != null and id != 0">id,</if>
|
<if test="erectoId != null">erecto_id,</if>
|
<if test="deviceId != null and deviceId != 0">device_id,</if>
|
<if test="userId != null and userId != 0">user_id,</if>
|
<if test="erectoName != null and erectoName != ''">erecto_name,</if>
|
<if test="erectoPhone != null and erectoPhone != ''">erecto_phone,</if>
|
<if test="userName != null and userName != ''">user_name,</if>
|
<if test="userPhone != null and userPhone != ''">user_phone,</if>
|
<if test="address != null and address != ''">address,</if>
|
<if test="orderType != null and orderType != ''">order_type,</if>
|
<if test="remark != null and remark != ''">remark,</if>
|
<if test="description != null and description != ''">description,</if>
|
<if test="appointmentTime != null">appointment_time,</if>
|
<if test="score != null and score != ''">score,</if>
|
<if test="evaluate != null and evaluate != ''">evaluate,</if>
|
<if test="assginTime != null">assgin_time,</if>
|
<if test="receiveTime != null">receive_time,</if>
|
<if test="finishTime != null">finish_time,</if>
|
<if test="state != null and state != ''">state,</if>
|
<if test="createUserId != null and createUserId != 0">createuser_id,</if>
|
<if test="imgUrl != null and imgUrl != ''">imgurl,</if>
|
<if test="customFlag != null and customFlag !=''">custom_flag,</if>
|
create_time)
|
values (
|
<if test="id != null and id != ''">#{id},</if>
|
<if test="erectoId != null">#{erectoId},</if>
|
<if test="deviceId != null and deviceId != ''">#{deviceId},</if>
|
<if test="userId != null">#{userId},</if>
|
<if test="erectoName!=null">#{erectoName},</if>
|
<if test="erectoPhone != null and erectoPhone != ''">#{erectoPhone},</if>
|
<if test="userName != null">#{userName},</if>
|
<if test="userPhone != null">#{userPhone},</if>
|
<if test="address != null">#{address},</if>
|
<if test="orderType != null and orderType != ''">#{orderType},</if>
|
<if test="remark != null and remark != ''">#{remark},</if>
|
<if test="description != null and description != ''">#{description},</if>
|
<if test="appointmentTime != null">#{appointmentTime},</if>
|
<if test="score != null and score != ''">#{score},</if>
|
<if test="evaluate != null and evaluate != ''">#{evaluate},</if>
|
<if test="assginTime != null">#{assginTime},</if>
|
<if test="receiveTime != null">#{receiveTime},</if>
|
<if test="finishTime != null">#{finishTime},</if>
|
<if test="state != null and state != ''">#{state},</if>
|
<if test="createUserId != null and createUserId != 0">#{createUserId},</if>
|
<if test="imgUrl != null and imgUrl != ''">#{imgUrl},</if>
|
<if test="customFlag != null and customFlag !=''">#{customFlag},</if>
|
sysdate())
|
</insert>
|
<update id="updateDeviceOrder" parameterType="DeviceOrder">
|
update iot_device_order
|
<set>
|
<if test="id != null and id != 0">
|
id = #{id},
|
</if>
|
<if test=" erectoId!= null and erectoId != 0">
|
erecto_id = #{erectoId},
|
</if>
|
<if test="deviceId != null and deviceId != 0">
|
device_id = #{deviceId},
|
</if>
|
<if test="userId != null and userId != 0">
|
user_id = #{userId},
|
</if>
|
<if test="erectoName!=null and erectoName != ''">
|
erecto_name = #{erectoName},
|
</if>
|
<if test="erectoPhone != null and erectoPhone != ''">
|
erecto_phone = #{erectoPhone},
|
</if>
|
<if test="userName != null and userName != ''">
|
user_name = #{userName},
|
</if>
|
<if test="userPhone != null and userPhone != ''">
|
user_phone = #{userPhone},
|
</if>
|
<if test="address != null and address != ''">
|
address = #{address},
|
</if>
|
<if test="orderType != null and orderType != ''">
|
order_type = #{orderType},
|
</if>
|
<if test="remark != null">
|
remark = #{remark},
|
</if>
|
<if test="description != null">
|
description = #{description},
|
</if>
|
appointment_time = #{appointmentTime},
|
<if test="score != null and score != ''">score = #{score},</if>
|
<if test="evaluate != null">evaluate = #{evaluate},</if>
|
<if test="assginTime!= null">assgin_time = #{assginTime},</if>
|
<if test="receiveTime != null">receive_time = #{receiveTime},</if>
|
<if test="finishTime != null">finish_time = #{finishTime},</if>
|
<if test="state != null">state = #{state},</if>
|
<if test="isRate != null">is_rate= #{isRate},</if>
|
<if test="updateUserId != null and updateUserId != 0">updateuser_id = #{updateUserId},</if>
|
<if test="imgUrl != null and imgUrl != ''">imgurl = #{imgUrl},</if>
|
<if test="receiveTimeoutFlag != null and receiveTimeoutFlag != ''">receive_timeout_flag =
|
#{receiveTimeoutFlag},
|
</if>
|
<if test="finishTimeoutFlag != null and finishTimeoutFlag != ''">finish_timeout_flag =
|
#{finishTimeoutFlag},
|
</if>
|
<if test="customFlag != null and customFlag !=''">custom_flag = #{customFlag},</if>
|
</set>
|
where id = #{id}
|
</update>
|
<update id="updateDeviceOrderScoreAndComment" parameterType="DeviceOrder">
|
update iot_device_order
|
<set>
|
<if test="id != null and id != 0">
|
id = #{id},
|
</if>
|
<if test=" erectoId!= null and erectoId != 0">
|
erecto_id = #{erectoId},
|
</if>
|
<if test="deviceId != null and deviceId != 0">
|
device_id = #{deviceId},
|
</if>
|
<if test="userId != null and userId != 0">
|
user_id = #{userId},
|
</if>
|
<if test="erectoName!=null and erectoName != ''">
|
erecto_name = #{erectoName},
|
</if>
|
<if test="erectoPhone != null and erectoPhone != ''">
|
erecto_phone = #{erectoPhone},
|
</if>
|
<if test="userName != null and userName != ''">
|
user_name = #{userName},
|
</if>
|
<if test="score != null and score != ''">
|
score = #{score},
|
</if>
|
<if test="evaluate != null">
|
evaluate = #{evaluate},
|
</if>
|
<if test="isRate != null">
|
is_rate = #{isRate},
|
</if>
|
</set>
|
where id = #{id}
|
</update>
|
<delete id="deleteDeviceOrderById">
|
delete
|
from iot_device_order
|
where id = #{id}
|
</delete>
|
<delete id="deleteDeviceOrder">
|
delete iot_device_order where id in
|
<foreach collection="idss" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</delete>
|
</mapper>
|