<?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.station.mapper.MjOrderDetailMapper">
|
|
<resultMap type="MjOrderDetail" id="MjOrderDetailResult">
|
<result property="id" column="id" />
|
<result property="orderId" column="order_id" />
|
<result property="userId" column="user_id" />
|
<result property="userName" column="user_name" />
|
<result property="doorId" column="door_id" />
|
<result property="doorName" column="door_name" />
|
<result property="areaId" column="area_id" />
|
<result property="areaName" column="area_name" />
|
<result property="authorizeType" column="authorize_type" />
|
<result property="authorizeResult" column="authorize_result" />
|
<result property="organizationId" column="organization_id" />
|
<result property="organizationName" column="organization_name" />
|
<result property="createTime" column="create_time" />
|
<result property="updateTime" column="update_time" />
|
<result property="createBy" column="create_by" />
|
<result property="updateBy" column="update_by" />
|
<result property="delFlag" column="del_flag" />
|
<result property="mainUser" column="main_user" />
|
</resultMap>
|
|
<sql id="selectMjOrderDetailVo">
|
select id, order_id, user_id, user_name, door_id, door_name, area_id, area_name, authorize_type, authorize_result, organization_id, organization_name, create_time, update_time, create_by, update_by, del_flag, main_user from mj_order_detail
|
</sql>
|
|
<select id="selectMjOrderDetailList" parameterType="MjOrderDetail" resultMap="MjOrderDetailResult">
|
<include refid="selectMjOrderDetailVo"/>
|
<where>
|
<if test="orderId != null and orderId != ''"> and order_id = #{orderId}</if>
|
<if test="userId != null "> and user_id = #{userId}</if>
|
<if test="userName != null and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
|
<if test="doorId != null and doorId != ''"> and door_id = #{doorId}</if>
|
<if test="doorName != null and doorName != ''"> and door_name like concat('%', #{doorName}, '%')</if>
|
<if test="areaId != null and areaId != ''"> and area_id = #{areaId}</if>
|
<if test="areaName != null and areaName != ''"> and area_name like concat('%', #{areaName}, '%')</if>
|
<if test="authorizeType != null and authorizeType != ''"> and authorize_type = #{authorizeType}</if>
|
<if test="authorizeResult != null and authorizeResult != ''"> and authorize_result = #{authorizeResult}</if>
|
<if test="organizationId != null and organizationId != ''"> and organization_id = #{organizationId}</if>
|
<if test="organizationName != null and organizationName != ''"> and organization_name like concat('%', #{organizationName}, '%')</if>
|
</where>
|
order by create_time asc
|
</select>
|
|
<select id="selectMjOrderDetailById" parameterType="String" resultMap="MjOrderDetailResult">
|
<include refid="selectMjOrderDetailVo"/>
|
where id = #{id}
|
</select>
|
|
<insert id="insertMjOrderDetail" parameterType="MjOrderDetail">
|
insert into mj_order_detail
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="id != null">id,</if>
|
<if test="orderId != null">order_id,</if>
|
<if test="userId != null">user_id,</if>
|
<if test="userName != null">user_name,</if>
|
<if test="doorId != null">door_id,</if>
|
<if test="doorName != null">door_name,</if>
|
<if test="areaId != null">area_id,</if>
|
<if test="areaName != null">area_name,</if>
|
<if test="authorizeType != null">authorize_type,</if>
|
<if test="authorizeResult != null">authorize_result,</if>
|
<if test="organizationId != null">organization_id,</if>
|
<if test="organizationName != null">organization_name,</if>
|
<if test="createTime != null">create_time,</if>
|
<if test="updateTime != null">update_time,</if>
|
<if test="createBy != null">create_by,</if>
|
<if test="updateBy != null">update_by,</if>
|
<if test="delFlag != null">del_flag,</if>
|
<if test="mainUser != null">main_user,</if>
|
</trim>
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<if test="id != null">#{id},</if>
|
<if test="orderId != null">#{orderId},</if>
|
<if test="userId != null">#{userId},</if>
|
<if test="userName != null">#{userName},</if>
|
<if test="doorId != null">#{doorId},</if>
|
<if test="doorName != null">#{doorName},</if>
|
<if test="areaId != null">#{areaId},</if>
|
<if test="areaName != null">#{areaName},</if>
|
<if test="authorizeType != null">#{authorizeType},</if>
|
<if test="authorizeResult != null">#{authorizeResult},</if>
|
<if test="organizationId != null">#{organizationId},</if>
|
<if test="organizationName != null">#{organizationName},</if>
|
<if test="createTime != null">#{createTime},</if>
|
<if test="updateTime != null">#{updateTime},</if>
|
<if test="createBy != null">#{createBy},</if>
|
<if test="updateBy != null">#{updateBy},</if>
|
<if test="delFlag != null">#{delFlag},</if>
|
<if test="mainUser != null">#{mainUser},</if>
|
</trim>
|
</insert>
|
|
<update id="updateMjOrderDetail" parameterType="MjOrderDetail">
|
update mj_order_detail
|
<trim prefix="SET" suffixOverrides=",">
|
<if test="orderId != null">order_id = #{orderId},</if>
|
<if test="userId != null">user_id = #{userId},</if>
|
<if test="userName != null">user_name = #{userName},</if>
|
<if test="doorId != null">door_id = #{doorId},</if>
|
<if test="doorName != null">door_name = #{doorName},</if>
|
<if test="areaId != null">area_id = #{areaId},</if>
|
<if test="areaName != null">area_name = #{areaName},</if>
|
<if test="authorizeType != null">authorize_type = #{authorizeType},</if>
|
<if test="authorizeResult != null">authorize_result = #{authorizeResult},</if>
|
<if test="organizationId != null">organization_id = #{organizationId},</if>
|
<if test="organizationName != null">organization_name = #{organizationName},</if>
|
<if test="createTime != null">create_time = #{createTime},</if>
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
<if test="createBy != null">create_by = #{createBy},</if>
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
<if test="mainUser != null">main_user = #{mainUser},</if>
|
</trim>
|
where id = #{id}
|
</update>
|
|
<delete id="deleteMjOrderDetailById" parameterType="String">
|
delete from mj_order_detail where id = #{id}
|
</delete>
|
|
<delete id="deleteMjOrderDetailByIds" parameterType="String">
|
delete from mj_order_detail where id in
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</delete>
|
|
<select id="selectOrderInfoByUserId" parameterType="Long" resultType="com.ruoyi.station.domain.MjVisitLog">
|
select detail.order_id workOrderId,workOrder.task_name workOrderName, detail.door_id doorId, detail.door_name doorName from mj_order_detail detail
|
LEFT JOIN mj_work_order workOrder on detail.order_id = workOrder.id
|
where detail.user_id = #{userId} and workOrder.valid_flag = 1 and workOrder.del_flag = 0
|
</select>
|
|
<select id="selectOrderDetailCountByUserId" parameterType="com.ruoyi.station.model.CheckUserModel" resultType="Integer">
|
select count(1) from mj_order_detail detail
|
left join mj_work_order wOrder on wOrder.id = detail.order_id
|
where detail.user_id = #{userId}
|
|
and
|
(
|
(date_format(wOrder.start_time,'%y%m%d %H%i%s') >= date_format(#{startTime},'%y%m%d %H%i%s')
|
and
|
date_format(wOrder.end_time,'%y%m%d %H%i%s') <= date_format(#{endTime},'%y%m%d %H%i%s')
|
)
|
|
or ((date_format(#{startTime},'%y%m%d %H%i%s') <= date_format(wOrder.start_time,'%y%m%d %H%i%s')
|
and date_format(#{endTime},'%y%m%d %H%i%s') >= date_format(wOrder.start_time,'%y%m%d %H%i%s'))
|
or (date_format(#{startTime},'%y%m%d %H%i%s') <= date_format(wOrder.end_time,'%y%m%d %H%i%s')
|
and date_format(#{endTime},'%y%m%d %H%i%s') >= date_format(wOrder.end_time,'%y%m%d %H%i%s')))
|
|
or (date_format(wOrder.start_time,'%y%m%d %H%i%s') <= date_format(#{startTime},'%y%m%d %H%i%s')
|
and
|
date_format(wOrder.end_time,'%y%m%d %H%i%s') >= date_format(#{endTime},'%y%m%d %H%i%s')
|
)
|
)
|
|
and wOrder.valid_flag = 1
|
</select>
|
|
<select id="selectOrderDetailByUserId" parameterType="String" resultType="Integer">
|
select count(1) from mj_order_detail detail
|
left join mj_work_order wOrder on wOrder.id = detail.order_id
|
where detail.user_id = #{userId}
|
and wOrder.valid_flag = 1
|
and wOrder.id != #{orderId}
|
and detail.area_id like concat('%', #{areaId}, '%')
|
</select>
|
|
<select id="getUser" resultMap="MjOrderDetailResult">
|
SELECT user_name,main_user FROM mj_order_detail WHERE order_id = #{orderId}
|
</select>
|
|
<select id="countManUser" parameterType="String" resultType="Integer">
|
select count(1) from mj_order_detail detail
|
left join mj_work_order wOrder on wOrder.id = detail.order_id
|
where detail.user_id = #{userId}
|
and detail.main_user = 1
|
and DATE_FORMAT(wOrder.end_time,'%y%m%d %H%i%s') > DATE_FORMAT(NOW(),'%y%m%d %H%i%s')
|
</select>
|
|
</mapper>
|