Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
王蔡翾
operation_platform
Commits
7b817d2a
Commit
7b817d2a
authored
Mar 28, 2025
by
王蔡翾
Browse files
初始化
parent
42848b59
Changes
43
Hide whitespace changes
Inline
Side-by-side
src/main/resources/mapper/OperationDoMapper.xml
View file @
7b817d2a
...
@@ -3,63 +3,88 @@
...
@@ -3,63 +3,88 @@
<mapper
namespace=
"com.example.operation_platform.mapper.OperationDoMapper"
>
<mapper
namespace=
"com.example.operation_platform.mapper.OperationDoMapper"
>
<select
id=
"queryDoList"
resultType=
"com.example.operation_platform.model.vo.OperationDoVO"
>
<select
id=
"queryDoList"
resultType=
"com.example.operation_platform.model.vo.OperationDoVO"
>
select
SELECT
top.id as id,
top.id AS id,
top.operation_cycle as operationCycle,
top.operation_cycle AS operationCycle,
top.start_time as startTime,
top.start_time AS startTime,
br.name as robotName,
COALESCE(br.name, dr.name) AS robotName,
bs.name as stationName,
bs.name AS stationName,
bw.worker_name as workerName,
bw.worker_name AS workerName,
top.operation_type as operationType,
top.operation_type AS operationType,
top.status
top.status AS status,
top.robot_id AS robotId,
from tb_operation top
top.station_id AS stationId,
left join bs_robot br on top.robot_id = br.id
top.item_id AS itemId,
left join bs_station bs on top.station_id = bs.id
top.finish_time AS finishTime,
left join tb_worker bw on top.worker_id = bw.id
top.drone_id AS droneId,
latest_rd.operation_date AS lastTime,
(
SELECT GROUP_CONCAT(DISTINCT bti.operation_item SEPARATOR ', ')
FROM tb_operation_item bti
WHERE FIND_IN_SET(bti.id, top.item_id) > 0
) AS operationItems
FROM tb_operation top
LEFT JOIN bs_robot br ON top.robot_id = br.id
LEFT JOIN bs_station bs ON top.station_id = bs.id
LEFT JOIN tb_message tb ON top.station_id = tb.station_id
AND (top.robot_id = tb.robot_id OR (top.robot_id IS NULL AND top.drone_id = tb.drone_id))
LEFT JOIN tb_worker bw ON tb.operation_worker = bw.id
LEFT JOIN uav_drone dr ON top.drone_id = dr.id
LEFT JOIN (
SELECT rd1.*
FROM tb_operation_record rd1
INNER JOIN (
SELECT operation_id, MAX(operation_date) AS max_date
FROM tb_operation_record
GROUP BY operation_id
) rd2 ON rd1.operation_id = rd2.operation_id AND rd1.operation_date = rd2.max_date
) latest_rd ON top.id = latest_rd.operation_id
<where>
<where>
top.runlog_or_operation = 0
<if
test=
"robotName != null and robotName != ''"
>
<if
test=
"robotName != null and robotName != ''"
>
br.name like concat('%',#{robotName},'%')
and br.name LIKE CONCAT('%', #{robotName}, '%')
or dr.name LIKE CONCAT('%', #{robotName}, '%')
</if>
</if>
<if
test=
"stationName != null and stationName != ''"
>
<if
test=
"stationName != null and stationName != ''"
>
and
bs.name
like concat
('%',#{stationName},'%')
AND
bs.name
LIKE CONCAT
('%',
#{stationName},
'%')
</if>
</if>
<if
test=
"workerName != null and workerName != ''"
>
<if
test=
"workerName != null and workerName != ''"
>
and
bw.worker_name
like concat
('%',#{workerName},'%')
AND
bw.worker_name
LIKE CONCAT
('%',
#{workerName},
'%')
</if>
</if>
<if
test=
"status != null and status != ''"
>
<if
test=
"status != null and status != ''"
>
and
top.status
like concat('%',
#{status}
,'%')
AND
top.status
=
#{status}
</if>
</if>
<if
test=
"startTime != null"
>
<if
test=
"startTime != null"
>
and
top.start_time
>
= #{startTime}
AND
top.start_time
>
= #{startTime}
</if>
</if>
<if
test=
"endTime != null"
>
<if
test=
"endTime != null"
>
and
top.
end
_time
<
= #{endTime}
AND
top.
start
_time
<
= #{endTime}
<!-- 注意字段名是finish_time还是end_time -->
</if>
</if>
</where>
</where>
ORDER BY top.start_time DESC
</select>
</select>
<update
id=
"stopDo"
parameterType=
"com.example.operation_platform.model.vo.OperationDoVO"
>
<update
id=
"stopDo"
parameterType=
"com.example.operation_platform.model.vo.OperationDoVO"
>
UPDATE tb_operation
UPDATE tb_operation
SET status = #{status}
SET status = #{status}
WHERE id = #{id}
WHERE id = #{id}
</update>
</update>
<select
id=
"querymoreDoList"
resultType=
"com.example.operation_platform.model.vo.OperationDoVO"
>
<select
id=
"querymessage"
resultType=
"com.example.operation_platform.model.vo.MessageNeedDataVo"
>
SELECT
select
info.*
top.start_time AS startTime,
FROM
COALESCE(br.name, dr.name) AS robotName,
tb_operation info
bs.name AS stationName,
JOIN (
top.operation_type AS operationType
-- 拆分后的ID子查询
from tb_operation top
SELECT
LEFT JOIN bs_robot br ON top.robot_id = br.id
SUBSTRING_INDEX(SUBSTRING_INDEX(item_id, ',', numbers.n), ',', -1) AS split_id
LEFT JOIN bs_station bs ON top.station_id = bs.id
FROM
LEFT JOIN tb_operation_job tb ON top.id = tb.operation_id
tb_operation_item
LEFT JOIN uav_drone dr ON top.drone_id = dr.id
CROSS JOIN
where
(SELECT 1 AS n UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) numbers
top.id = #{id}
WHERE
and top.runlog_or_operation = 0
CHAR_LENGTH(item_id) - CHAR_LENGTH(REPLACE(item_id, ',', '')) >= numbers.n - 1
and tb.start_time > CURRENT_TIMESTAMP
) split_data ON info.item_id = split_data.split_id;
</select>
</select>
</mapper>
</mapper>
src/main/resources/mapper/OperationJobMapper.xml
View file @
7b817d2a
...
@@ -3,22 +3,41 @@
...
@@ -3,22 +3,41 @@
<mapper
namespace=
"com.example.operation_platform.mapper.OperationJobMapper"
>
<mapper
namespace=
"com.example.operation_platform.mapper.OperationJobMapper"
>
<select
id=
"queryJobList"
resultType=
"com.example.operation_platform.model.vo.OperationJobVO"
>
<select
id=
"queryJobList"
resultType=
"com.example.operation_platform.model.vo.OperationJobVO"
>
select
SELECT
top.id,
top.id,
tp.operation_type as operationType,
tp.operation_type AS operationType,
bs.name as stationName,
bs.name AS stationName,
bw.worker_name as workerName,
-- 合并 robot 和 drone 的 name 到 robotName(优先取 robot)
br.name as robotName,
COALESCE(
top.start_time as startTime,
br.name, -- 来自 bs_robot 的机器人名称
top.finish_status
ud.name, -- 来自 uav_drone 的无人机名称
from tb_operation_job top
'未知设备' -- 默认值
left join tb_operation tp on top.operation_id = tp.id
) AS robotName,
left join bs_station bs on tp.station_id = bs.id
top.start_time AS startTime,
left join bs_robot br on tp.robot_id = br.id
top.end_time AS endTime,
left join tb_worker bw on tp.worker_id = bw.id
top.finish_status AS finishStatus,
tp.robot_id AS robotId,
tp.drone_id AS droneId,
bw.worker_name AS workerName -- 保留操作人员名称
FROM
tb_operation_job top
LEFT JOIN tb_operation tp ON top.operation_id = tp.id
LEFT JOIN bs_station bs ON tp.station_id = bs.id
-- 关联 tb_message 表(保持您的原始关联条件)
LEFT JOIN tb_message tm ON
tp.station_id = tm.station_id
AND (tp.robot_id = tm.robot_id OR (tp.robot_id IS NULL AND tp.drone_id = tm.drone_id))
-- 关联 robot 表(通过 tb_message)
LEFT JOIN bs_robot br ON tm.robot_id = br.id
-- 关联 drone 表(通过 tb_message)
LEFT JOIN uav_drone ud ON tm.drone_id = ud.id
-- 关联 worker 表
LEFT JOIN tb_worker bw ON tm.operation_worker = bw.id
<where>
<where>
top.runlog_or_operation = 0
<if
test=
"robotName != null and robotName != ''"
>
<if
test=
"robotName != null and robotName != ''"
>
br.name like concat('%',#{robotName},'%')
and br.name like concat('%',#{robotName},'%')
or ud.name like concat('%',#{robotName},'%')
</if>
</if>
<if
test=
"stationName != null and stationName != ''"
>
<if
test=
"stationName != null and stationName != ''"
>
and bs.name like concat('%',#{stationName},'%')
and bs.name like concat('%',#{stationName},'%')
...
@@ -33,9 +52,13 @@
...
@@ -33,9 +52,13 @@
and top.start_time
>
= #{startTime}
and top.start_time
>
= #{startTime}
</if>
</if>
<if
test=
"endTime != null"
>
<if
test=
"endTime != null"
>
and top.end
_t
ime
<
= #{endTime}
and top.end
T
ime
<
= #{endTime}
</if>
</if>
<if
test=
"operationType != null and operationType != ''"
>
and tp.operation_type like concat('%',#{operationType},'%')
</if>
</where>
</where>
ORDER BY top.start_time DESC
</select>
</select>
...
...
src/main/resources/mapper/WorkerMapper.xml
View file @
7b817d2a
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
tw.worker_name workerName,
tw.worker_name workerName,
tw.phone_number phoneNumber,
tw.phone_number phoneNumber,
typ.worker_type type,
typ.worker_type type,
tw.type typeId,
tw.company company
tw.company company
from
from
...
...
Prev
1
2
3
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment