478 lines
17 KiB
XML
478 lines
17 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="cn.iocoder.yudao.module.system.dal.mysql.robot.RobotTaskDetailMapper">
|
|
|
|
<resultMap id="BaseResultMap" type="cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotTaskDetailDO">
|
|
<!--@Table robot_task_detail-->
|
|
<result property="id" column="id" jdbcType="INTEGER"/>
|
|
<result property="robotTaskId" column="robot_task_id" jdbcType="INTEGER"/>
|
|
<result property="taskType" column="task_type" jdbcType="INTEGER"/>
|
|
<result property="releaseType" column="release_type" jdbcType="INTEGER"/>
|
|
<result property="takeType" column="take_type" jdbcType="INTEGER"/>
|
|
<result property="releaseId" column="release_id" jdbcType="INTEGER"/>
|
|
<result property="takeId" column="take_id" jdbcType="INTEGER"/>
|
|
<result property="fromLocationNo" column="from_location_no" jdbcType="VARCHAR"/>
|
|
<result property="fromLocationId" column="from_location_id" jdbcType="INTEGER"/>
|
|
<result property="fromLaneId" column="from_lane_id" jdbcType="INTEGER"/>
|
|
<result property="toLaneId" column="to_lane_id" jdbcType="INTEGER"/>
|
|
<result property="fromLocationNumber" column="from_location_number" jdbcType="INTEGER"/>
|
|
<result property="toLocationNumber" column="to_location_number" jdbcType="INTEGER"/>
|
|
<result property="fromMapItemId" column="from_map_item_id" jdbcType="INTEGER"/>
|
|
<result property="toMapItemId" column="to_map_item_id" jdbcType="INTEGER"/>
|
|
<result property="toLocationNo" column="to_location_no" jdbcType="VARCHAR"/>
|
|
<result property="toLocationId" column="to_location_id" jdbcType="INTEGER"/>
|
|
<result property="fromLocationStorey" column="from_location_storey" jdbcType="INTEGER"/>
|
|
<result property="toLocationStorey" column="to_location_storey" jdbcType="INTEGER"/>
|
|
<result property="priority" column="priority" jdbcType="INTEGER"/>
|
|
<result property="robotNo" column="robot_no" jdbcType="VARCHAR"/>
|
|
<result property="robotAction" column="robot_action" jdbcType="VARCHAR"/>
|
|
<result property="taskStatus" column="task_status" jdbcType="INTEGER"/>
|
|
<result property="taskStage" column="task_stage" jdbcType="INTEGER"/>
|
|
<result property="needLock" column="need_lock" jdbcType="INTEGER"/>
|
|
<result property="startTime" column="start_time" jdbcType="TIMESTAMP"/>
|
|
<result property="endTime" column="end_time" jdbcType="TIMESTAMP"/>
|
|
<result property="creator" column="creator" jdbcType="VARCHAR"/>
|
|
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
|
|
<result property="updater" column="updater" jdbcType="VARCHAR"/>
|
|
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
|
|
<result property="deleted" column="deleted" jdbcType="INTEGER"/>
|
|
</resultMap>
|
|
|
|
<!--查询单个-->
|
|
<sql id="base_sql">
|
|
id,
|
|
robot_task_id,
|
|
task_type,
|
|
release_type,
|
|
take_type,
|
|
release_id,
|
|
take_id,
|
|
from_location_no,
|
|
from_location_id,
|
|
from_lane_id,
|
|
to_lane_id,
|
|
to_location_no,
|
|
to_location_id,
|
|
robot_no,
|
|
robot_action,
|
|
task_status,
|
|
task_stage,
|
|
start_time,
|
|
end_time,
|
|
creator,
|
|
create_time,
|
|
updater,
|
|
update_time,
|
|
deleted,
|
|
tenant_id,
|
|
from_location_storey,
|
|
to_location_storey,
|
|
priority,
|
|
from_location_number,
|
|
to_location_number,
|
|
from_map_item_id,
|
|
need_lock,
|
|
to_map_item_id
|
|
</sql>
|
|
|
|
|
|
|
|
<select id="queryDoingTaskByIds" resultMap="BaseResultMap">
|
|
select
|
|
<include refid="base_sql"></include>
|
|
from
|
|
robot_task_detail
|
|
where
|
|
from_location_id in
|
|
<foreach collection="locationIds" item="id" index="index" open="(" close=")"
|
|
separator=",">
|
|
#{id}
|
|
</foreach>
|
|
and deleted = '0'
|
|
and task_status in ('0','1')
|
|
</select>
|
|
|
|
<select id="getSingleUnDoTask" resultMap="BaseResultMap">
|
|
select
|
|
<include refid="base_sql"></include>
|
|
from
|
|
robot_task_detail
|
|
where
|
|
task_status = '0'
|
|
and deleted = '0'
|
|
<if test="taskIds != null and taskIds.size() > 0">
|
|
and robot_task_id in
|
|
<foreach collection="taskIds" item="taskId" index="index" open="(" close=")"
|
|
separator=",">
|
|
#{taskId}
|
|
</foreach>
|
|
</if>
|
|
order by priority desc, create_time asc ,robot_no desc
|
|
</select>
|
|
|
|
|
|
<select id="queryByTaskId" resultMap="BaseResultMap">
|
|
select
|
|
<include refid="base_sql"></include>
|
|
from
|
|
robot_task_detail
|
|
where
|
|
robot_task_id = #{robotTaskId}
|
|
and deleted = '0'
|
|
</select>
|
|
|
|
<select id="getUnDoTaskDetail" resultMap="BaseResultMap">
|
|
SELECT
|
|
*
|
|
FROM (
|
|
SELECT *,
|
|
ROW_NUMBER() OVER (PARTITION BY robot_task_id order by priority desc, create_time asc ,robot_no desc) AS rn
|
|
FROM
|
|
robot_task_detail
|
|
where
|
|
task_status = '0'
|
|
and deleted = '0'
|
|
<if test="montageTaskIds != null and montageTaskIds.size() > 0">
|
|
and robot_task_id in
|
|
<foreach collection="montageTaskIds" item="taskId" index="index" open="(" close=")"
|
|
separator=",">
|
|
#{taskId}
|
|
</foreach>
|
|
</if>
|
|
) AS user
|
|
WHERE rn = 1
|
|
union
|
|
select
|
|
*, tenant_id as rn
|
|
from
|
|
robot_task_detail
|
|
where
|
|
task_status = '0'
|
|
and deleted = '0'
|
|
<if test="singleTaskIds != null and singleTaskIds.size() > 0">
|
|
and robot_task_id in
|
|
<foreach collection="singleTaskIds" item="taskId" index="index" open="(" close=")"
|
|
separator=",">
|
|
#{taskId}
|
|
</foreach>
|
|
</if>
|
|
order by priority desc, create_time asc ,robot_no desc
|
|
</select>
|
|
|
|
|
|
<select id="getMontageUnDoTask" resultMap="BaseResultMap">
|
|
SELECT
|
|
*
|
|
FROM (
|
|
SELECT *,
|
|
ROW_NUMBER() OVER (PARTITION BY robot_task_id order by id asc ) AS rn
|
|
FROM robot_task_detail
|
|
where
|
|
task_status = '0'
|
|
and deleted = '0'
|
|
<if test="montageTaskIds != null and montageTaskIds.size() > 0">
|
|
and robot_task_id in
|
|
<foreach collection="montageTaskIds" item="taskId" index="index" open="(" close=")"
|
|
separator=",">
|
|
#{taskId}
|
|
</foreach>
|
|
</if>
|
|
) AS user
|
|
WHERE rn = 1
|
|
order by priority desc, create_time asc ,robot_no desc
|
|
</select>
|
|
|
|
|
|
<select id="getChargeTaskDetail"
|
|
resultType="cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotTaskDetailDO">
|
|
SELECT
|
|
t2.id,
|
|
t2.robot_task_id as robotTaskId,
|
|
t2.robot_no as robotNo,
|
|
t2.priority
|
|
from
|
|
robot_task t1, robot_task_detail t2
|
|
where
|
|
t1.task_status in('0','1')
|
|
and t1.id = t2.robot_task_id
|
|
and t2.task_status = '0'
|
|
and t2.task_type = '3'
|
|
</select>
|
|
|
|
<select id="selectTakeMapItemIds" resultType="java.lang.Long">
|
|
select
|
|
t2.map_item_id
|
|
from
|
|
robot_task_detail t1, ware_house_location t2
|
|
where
|
|
t1.from_location_id = t2.id
|
|
and t1.task_status in ('0','1')
|
|
</select>
|
|
|
|
<select id="selectReleaseMapItemIds" resultType="java.lang.Long">
|
|
select
|
|
t2.map_item_id
|
|
from
|
|
robot_task_detail t1, ware_house_location t2
|
|
where
|
|
t1.to_location_id = t2.id
|
|
and t1.task_status in ('0','1')
|
|
</select>
|
|
|
|
<select id="selectAutoCreateCycleTask"
|
|
resultType="cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotTaskDetailDO">
|
|
select
|
|
t1.*
|
|
from
|
|
robot_task_detail t1, robot_task t2
|
|
where
|
|
t2.id = t1.robot_task_id
|
|
and t2.remaining_cycle_number > 1
|
|
and t2.task_status = '2'
|
|
and t1.task_status = '2'
|
|
and t1.deleted = '0'
|
|
and t2.deleted = '0'
|
|
</select>
|
|
<select id="getLastTaskGroupByRobotNo"
|
|
resultType="cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotTaskDetailDO">
|
|
SELECT
|
|
t1.*
|
|
FROM
|
|
robot_task_detail t1
|
|
INNER JOIN ( SELECT MAX( update_time ) AS update_time, robot_no FROM robot_task_detail WHERE task_status = '2' GROUP BY robot_no ) t2
|
|
ON t1.update_time = t2.update_time
|
|
AND t1.robot_no = t2.robot_no
|
|
WHERE
|
|
t1.task_type = '5'
|
|
and t1.task_status = '2'
|
|
</select>
|
|
<select id="getDoingTaskDetailByLocationIds"
|
|
resultType="cn.iocoder.yudao.module.system.dal.dataobject.robot.RobotTaskDetailDO">
|
|
select
|
|
t2.*
|
|
from
|
|
robot_task t1 left join robot_task_detail t2
|
|
on t1.id = t2.robot_task_id
|
|
where
|
|
t1.deleted = '0'
|
|
and t2.deleted = '0'
|
|
and t2.task_status in('0','1')
|
|
and t1.task_status in('0','1')
|
|
and (t2.to_location_id in
|
|
<foreach collection="ids" item="locationId" index="index" open="(" close=")"
|
|
separator=",">
|
|
#{locationId}
|
|
</foreach> or
|
|
t2.from_location_id in
|
|
<foreach collection="ids" item="locationId" index="index" open="(" close=")"
|
|
separator=",">
|
|
#{locationId}
|
|
</foreach>
|
|
)
|
|
</select>
|
|
|
|
|
|
<select id="getTaskNoByDetailId" resultType="java.lang.String">
|
|
select
|
|
distinct
|
|
t1.task_no
|
|
from
|
|
robot_task t1 left join robot_task_detail t2
|
|
on t1.id = t2.robot_task_id
|
|
where
|
|
t2.id = #{taskDetailId}
|
|
and t1.deleted = '0'
|
|
and t2.deleted = '0'
|
|
</select>
|
|
|
|
<select id="getDoIngTaskItemIdsByItemIds" resultType="java.lang.Long">
|
|
select
|
|
distinct
|
|
t2.release_id
|
|
from
|
|
robot_task t1 left join robot_task_detail t2
|
|
on t1.id = t2.robot_task_id
|
|
where
|
|
t2.release_id in
|
|
<foreach collection="itemIds" item="itemId" index="index" open="(" close=")"
|
|
separator=",">
|
|
#{itemId}
|
|
</foreach>
|
|
and t1.deleted = '0'
|
|
and t2.deleted = '0'
|
|
and t1.task_status in ('0','1')
|
|
and t2.task_status in ('0','1')
|
|
and t2.task_type = '9'
|
|
</select>
|
|
|
|
|
|
<select id="getRobotDoingTaskNo"
|
|
resultType="cn.iocoder.yudao.module.system.controller.admin.robot.detail.RobotDoingTaskDTO">
|
|
select
|
|
distinct
|
|
t2.robot_no as robotNo,
|
|
t2.id as id,
|
|
t2.task_stage as taskStage,
|
|
t2.task_status as taskStatus,
|
|
t2.task_type as taskType,
|
|
t1.task_no as taskNo
|
|
from
|
|
robot_task t1 left join robot_task_detail t2
|
|
on t1.id = t2.robot_task_id
|
|
where
|
|
t1.deleted = '0'
|
|
and t2.deleted = '0'
|
|
and t1.task_status = '1'
|
|
and t2.task_status ='1'
|
|
<if test="robotNo != null and robotNo != ''">
|
|
and t2.robot_no = #{robotNo}
|
|
</if>
|
|
</select>
|
|
|
|
|
|
<select id="getExceptionTaskDetail"
|
|
resultType="cn.iocoder.yudao.module.system.api.remote.dto.RemoteExceptionTaskDetailDTO">
|
|
select
|
|
t2.id,
|
|
t2.robot_no as robotNo,
|
|
t1.task_no as taskNo,
|
|
t2.from_location_no as fromLocationNo,
|
|
t2.to_location_no as toLocationNo,
|
|
t2.task_stage as taskStage
|
|
from
|
|
robot_task t1 inner join robot_task_detail t2
|
|
on t1.id = t2.robot_task_id
|
|
<where>
|
|
t1.deleted = '0'
|
|
and t2.deleted = '0'
|
|
and t2.occur_error = '1'
|
|
and ((t2.task_type = '1' and t2.task_stage in ('1','2','3','4')) or (t2.task_type = '6') or (t2.task_type = '5' and t2.task_stage = '2'))
|
|
and t2.task_status = '1'
|
|
and t1.task_status = '1'
|
|
<if test="pageReqVO.robotNo != null and pageReqVO.robotNo != ''">
|
|
and t2.robot_no = #{pageReqVO.robotNo}
|
|
</if>
|
|
<if test="pageReqVO.taskNo != null and pageReqVO.taskNo != ''">
|
|
and t1.task_no = #{pageReqVO.taskNo}
|
|
</if>
|
|
</where>
|
|
order by t1.create_time desc
|
|
</select>
|
|
<select id="getRobotTaskAutomaticArtificial"
|
|
resultType="cn.iocoder.yudao.module.system.controller.admin.statistics.dto.RobotTaskManualInterventionDTO">
|
|
SELECT
|
|
sum(case manual_intervention when '0' then 1 else 0 end ) as automaticDoneNum,
|
|
sum(case when manual_intervention > '0' then 1 else 0 end ) as artificialDoneNum
|
|
from
|
|
robot_task_detail
|
|
<where>
|
|
deleted = '0'
|
|
and task_status > '0'
|
|
<choose>
|
|
<when test="type == 1">
|
|
AND DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(create_time)
|
|
</when>
|
|
<when test="type == 2">
|
|
AND DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date(create_time)
|
|
</when>
|
|
<when test="type == 3">
|
|
AND DATE_SUB(CURDATE(), INTERVAL 90 DAY) <= date(create_time)
|
|
</when>
|
|
</choose>
|
|
</where>
|
|
</select>
|
|
|
|
|
|
<!--通过主键修改数据-->
|
|
<update id="updateRobotDetailById">
|
|
update robot_task_detail
|
|
<set>
|
|
<if test="robotTaskId != null">
|
|
robot_task_id = #{robotTaskId},
|
|
</if>
|
|
<if test="taskType != null">
|
|
task_type = #{taskType},
|
|
</if>
|
|
<if test="releaseType != null">
|
|
release_type = #{releaseType},
|
|
</if>
|
|
<if test="takeType != null">
|
|
take_type = #{takeType},
|
|
</if>
|
|
<if test="releaseId != null">
|
|
release_id = #{releaseId},
|
|
</if>
|
|
<if test="takeId != null">
|
|
take_id = #{takeId},
|
|
</if>
|
|
<if test="fromLocationNo != null and fromLocationNo != ''">
|
|
from_location_no = #{fromLocationNo},
|
|
</if>
|
|
<if test="fromLocationId != null">
|
|
from_location_id = #{fromLocationId},
|
|
</if>
|
|
<if test="toLocationNo != null and toLocationNo != ''">
|
|
to_location_no = #{toLocationNo},
|
|
</if>
|
|
<if test="toLocationId != null">
|
|
to_location_id = #{toLocationId},
|
|
</if>
|
|
<if test="robotNo != null and robotNo != ''">
|
|
robot_no = #{robotNo},
|
|
</if>
|
|
<if test="robotAction != null and robotAction != ''">
|
|
robot_action = #{robotAction},
|
|
</if>
|
|
<if test="taskStatus != null">
|
|
task_status = #{taskStatus},
|
|
</if>
|
|
<if test="taskStage != null">
|
|
task_stage = #{taskStage},
|
|
</if>
|
|
<if test="startTime != null">
|
|
start_time = #{startTime},
|
|
</if>
|
|
<if test="endTime != null">
|
|
end_time = #{endTime},
|
|
</if>
|
|
<if test="creator != null and creator != ''">
|
|
creator = #{creator},
|
|
</if>
|
|
<if test="createTime != null">
|
|
create_time = #{createTime},
|
|
</if>
|
|
<if test="updater != null and updater != ''">
|
|
updater = #{updater},
|
|
</if>
|
|
<if test="updateTime != null">
|
|
update_time = #{updateTime},
|
|
</if>
|
|
<if test="deleted != null">
|
|
deleted = #{deleted},
|
|
</if>
|
|
</set>
|
|
where id = #{id}
|
|
</update>
|
|
<update id="updateDoneByIds">
|
|
update
|
|
robot_task_detail
|
|
set
|
|
task_status = '2',
|
|
task_stage = '5'
|
|
where
|
|
id in
|
|
<foreach collection="ids" item="id" index="index" open="(" close=")"
|
|
separator=",">
|
|
#{id}
|
|
</foreach>
|
|
</update>
|
|
|
|
<!--通过主键删除-->
|
|
<delete id="deleteById">
|
|
delete
|
|
from robot_task_detail
|
|
where id = #{id}
|
|
</delete>
|
|
|
|
|
|
</mapper> |