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
d7c66356
Commit
d7c66356
authored
Apr 03, 2025
by
王蔡翾
Browse files
更新
parent
df0b20b6
Changes
11
Show whitespace changes
Inline
Side-by-side
src/main/java/com/example/operation_platform/controller/OperationJobController.java
View file @
d7c66356
...
@@ -52,5 +52,9 @@ public class OperationJobController extends BaseController {
...
@@ -52,5 +52,9 @@ public class OperationJobController extends BaseController {
public
Result
<
List
<
OperationJobVO
>>
queryWarn
()
{
public
Result
<
List
<
OperationJobVO
>>
queryWarn
()
{
return
Result
.
data
(
operationJobService
.
queryWarn
());
return
Result
.
data
(
operationJobService
.
queryWarn
());
}
}
@PostMapping
(
"/page/operation"
)
public
TableDataInfo
pageOperation
(
@RequestBody
OperationJobDTO
operationJobDTO
)
{
startPage
(
operationJobDTO
.
getPageNum
(),
operationJobDTO
.
getPageSize
());
return
getDataTable
(
operationJobService
.
queryJobAndOperationTypeList
(
operationJobDTO
));
}
}
}
src/main/java/com/example/operation_platform/controller/OperationRecordController.java
View file @
d7c66356
...
@@ -55,9 +55,10 @@ public class OperationRecordController extends BaseController {
...
@@ -55,9 +55,10 @@ public class OperationRecordController extends BaseController {
startPage
(
operationRecordDTO
.
getPageNum
(),
operationRecordDTO
.
getPageSize
());
startPage
(
operationRecordDTO
.
getPageNum
(),
operationRecordDTO
.
getPageSize
());
return
getDataTable
(
tbOperationRecordService
.
queryRunLogRecordList
(
operationRecordDTO
));
return
getDataTable
(
tbOperationRecordService
.
queryRunLogRecordList
(
operationRecordDTO
));
}
}
@PostMapping
(
"/warn/run"
)
@PostMapping
(
"/page/warn/run"
)
public
Result
<
List
<
OperationRecordVO
>>
pageWarnRun
(
@RequestBody
OperationRecordDTO
operationRecordDTO
)
{
public
TableDataInfo
pageWarnRun
(
@RequestBody
OperationRecordDTO
operationRecordDTO
)
{
return
Result
.
data
(
tbOperationRecordService
.
queryRunLogRecordListAndWarnMessage
(
operationRecordDTO
));
startPage
(
operationRecordDTO
.
getPageNum
(),
operationRecordDTO
.
getPageSize
());
return
getDataTable
(
tbOperationRecordService
.
queryRunLogRecordListAndWarnMessage
(
operationRecordDTO
));
}
}
}
}
src/main/java/com/example/operation_platform/controller/TaskController.java
View file @
d7c66356
package
com.example.operation_platform.controller
;
package
com.example.operation_platform.controller
;
import
com.example.operation_platform.task.OperationDoTask
;
import
com.example.operation_platform.task.OperationDoTask
;
import
com.example.operation_platform.task.RunLogTask
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
...
@@ -12,11 +13,19 @@ public class TaskController {
...
@@ -12,11 +13,19 @@ public class TaskController {
@Autowired
@Autowired
private
OperationDoTask
operationDoTask
;
private
OperationDoTask
operationDoTask
;
@Autowired
private
RunLogTask
runLogTask
;
@GetMapping
(
"/run-task"
)
@GetMapping
(
"/run-task"
)
public
String
runTask
()
{
public
String
runTask
()
{
operationDoTask
.
runScheduleOperationJobsNow
();
operationDoTask
.
runScheduleOperationJobsNow
();
return
"定时任务已手动触发"
;
return
"维保定时任务已手动触发"
;
}
@GetMapping
(
"/run-log-task"
)
public
String
runLogTask
()
{
runLogTask
.
processRealTimeAlerts
();
return
"告警定时任务已手动触发"
;
}
}
}
}
src/main/java/com/example/operation_platform/mapper/OperationJobMapper.java
View file @
d7c66356
...
@@ -55,5 +55,7 @@ public interface OperationJobMapper extends BaseMapper<OperationJob> {
...
@@ -55,5 +55,7 @@ public interface OperationJobMapper extends BaseMapper<OperationJob> {
// 定时任务所需信息
// 定时任务所需信息
List
<
OperationJobVO
>
queryRunJobList
(
OperationJobDTO
operationJobDTO
);
List
<
OperationJobVO
>
queryRunJobList
(
OperationJobDTO
operationJobDTO
);
//维保任务详情页面的第一个接口
List
<
OperationJobVO
>
queryJobAndOperationTypeList
(
OperationJobDTO
operationJobDTO
);
}
}
src/main/java/com/example/operation_platform/model/dto/OperationJobDTO.java
View file @
d7c66356
...
@@ -21,7 +21,7 @@ public class OperationJobDTO extends OperationJob {
...
@@ -21,7 +21,7 @@ public class OperationJobDTO extends OperationJob {
private
LocalDate
date
;
private
LocalDate
date
;
private
Integer
year
;
private
Integer
year
;
private
Integer
month
;
private
Integer
month
;
private
Integer
stationId
;
private
String
stationId
;
private
Integer
robotId
;
private
Integer
robotId
;
private
Integer
droneId
;
private
Integer
droneId
;
...
...
src/main/java/com/example/operation_platform/model/vo/OperationJobVO.java
View file @
d7c66356
...
@@ -20,5 +20,7 @@ public class OperationJobVO extends OperationJob {
...
@@ -20,5 +20,7 @@ public class OperationJobVO extends OperationJob {
private
String
warnMessage
;
private
String
warnMessage
;
private
Integer
runLogId
;
private
Integer
runLogId
;
private
String
stationId
;
private
String
stationId
;
private
Integer
operationId
;
private
String
itemId
;
private
String
operationItems
;
}
}
src/main/java/com/example/operation_platform/service/OperationJobService.java
View file @
d7c66356
...
@@ -52,4 +52,6 @@ public interface OperationJobService extends IService<OperationJob> {
...
@@ -52,4 +52,6 @@ public interface OperationJobService extends IService<OperationJob> {
void
updateRunLogStatus
(
Integer
id
);
void
updateRunLogStatus
(
Integer
id
);
//首页轮播告警信息
//首页轮播告警信息
List
<
OperationJobVO
>
queryWarn
();
List
<
OperationJobVO
>
queryWarn
();
//维保任务详情页面的第一个接口
List
<
OperationJobVO
>
queryJobAndOperationTypeList
(
OperationJobDTO
operationJobDTO
);
}
}
src/main/java/com/example/operation_platform/service/impl/OperationJobServiceImpl.java
View file @
d7c66356
...
@@ -51,5 +51,10 @@ public class OperationJobServiceImpl extends ServiceImpl<OperationJobMapper, Ope
...
@@ -51,5 +51,10 @@ public class OperationJobServiceImpl extends ServiceImpl<OperationJobMapper, Ope
List
<
OperationJobVO
>
operationJobVO
=
baseMapper
.
queryWarn
();
List
<
OperationJobVO
>
operationJobVO
=
baseMapper
.
queryWarn
();
return
operationJobVO
;
return
operationJobVO
;
}
}
@Override
public
List
<
OperationJobVO
>
queryJobAndOperationTypeList
(
OperationJobDTO
operationJobDTO
)
{
List
<
OperationJobVO
>
operationJobVO
=
baseMapper
.
queryJobAndOperationTypeList
(
operationJobDTO
);
return
operationJobVO
;
}
}
}
src/main/java/com/example/operation_platform/task/RunLogTask.java
View file @
d7c66356
package
com.example.operation_platform.task
;
package
com.example.operation_platform.task
;
import
cn.hutool.core.bean.BeanUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.example.operation_platform.mapper.MessageMapper
;
import
com.example.operation_platform.mapper.MessageMapper
;
import
com.example.operation_platform.mapper.OperationDoMapper
;
import
com.example.operation_platform.mapper.OperationDoMapper
;
...
@@ -17,9 +18,12 @@ import org.json.JSONObject;
...
@@ -17,9 +18,12 @@ import org.json.JSONObject;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
java.time.LocalDateTime
;
import
java.util.*
;
import
java.util.*
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
@Component
@Component
...
@@ -39,95 +43,108 @@ public class RunLogTask {
...
@@ -39,95 +43,108 @@ public class RunLogTask {
@Autowired
@Autowired
private
OperationJobMapper
operationJobMapper
;
private
OperationJobMapper
operationJobMapper
;
private
final
Map
<
Integer
,
OperationJobVO
>
alertTrackingMap
=
new
ConcurrentHashMap
<>();
/**
/**
* 处理带有告警信息的操作任务
* 实时告警任务(每5分钟执行)
* @param operationJobVOList 操作任务列表
*/
*/
public
void
processOperationsWithWarnings
(
List
<
OperationJobVO
>
operationJobVOList
)
{
@Scheduled
(
cron
=
"0 */5 * * * ?"
)
// 1. 首先为列表中的任务添加告警信息
public
void
processRealTimeAlerts
()
{
List
<
OperationJobVO
>
enrichedList
=
enrichOperationJobListWithWarnMessages
(
operationJobVOList
);
// 1. 获取需要发送短信的完整数据列表
List
<
OperationJobVO
>
alertJobs
=
enrichOperationJobListWithWarnMessages
(
getBaseOperationList
());
// 2. 对每个带有告警信息的任务进行处理
// 2. 直接发送短信(列表已包含所有需要的信息)
for
(
OperationJobVO
job
:
enrichedList
)
{
alertJobs
.
forEach
(
this
::
sendAlertSms
);
if
(
job
.
getWarnMessage
()
!=
null
&&
!
job
.
getWarnMessage
().
isEmpty
())
{
handleOperationWithWarning
(
job
);
}
}
}
}
/**
/**
* 处理单个带有告警信息的操作任务
* 每日状态检查(每天0点执行)
* @param job 操作任务
*/
*/
private
void
handleOperationWithWarning
(
OperationJobVO
job
)
{
@Scheduled
(
cron
=
"0 0 0 * * ?"
)
Integer
operationId
=
job
.
getOperationId
();
public
void
dailyStatusCheck
()
{
boolean
shouldContinue
=
true
;
// 1. 获取需要检查的完整数据列表
List
<
OperationJobVO
>
alertJobs
=
enrichOperationJobListWithWarnMessages
(
getBaseOperationList
());
while
(
shouldContinue
)
{
// 2. 检查状态并发送提醒
try
{
alertJobs
.
forEach
(
job
->
{
// 1. 检查操作的当前状态
OperationJob
current
=
operationJobMapper
.
selectById
(
job
.
getOperationId
());
OperationJob
operationjob
=
operationJobMapper
.
selectById
(
operationId
);
if
(
current
!=
null
&&
current
.
getFinishStatus
()
!=
4
)
{
if
(
operationjob
==
null
)
{
sendAlertSms
(
job
);
// 使用列表中原有的完整信息
logger
.
error
(
"未找到ID为{}的操作记录"
,
operationId
);
shouldContinue
=
false
;
continue
;
}
}
});
// 2. 如果状态为4,停止处理该任务
if
(
operationjob
.
getFinishStatus
()
==
4
)
{
logger
.
info
(
"操作ID {} 已完成(状态4),停止发送通知"
,
operationId
);
shouldContinue
=
false
;
continue
;
}
}
// 3. 发送短信通知
/**
sendAlertSms
(
job
);
* 发送短信(完全使用OperationJobVO中的数据)
*/
// 4. 等待5分钟后再次检查(可根据需要调整时间间隔)
private
void
sendAlertSms
(
OperationJobVO
job
)
{
Thread
.
sleep
(
300000
);
// 5分钟(300000毫秒)
List
<
String
>
phones
=
getPhoneByOperation
(
job
.
getOperationId
());
phones
.
forEach
(
phone
->
{
}
catch
(
InterruptedException
e
)
{
try
{
logger
.
error
(
"处理操作ID {} 时线程被中断"
,
operationId
,
e
);
JSONObject
params
=
new
JSONObject
();
Thread
.
currentThread
().
interrupt
();
// 直接使用VO中的完整数据
shouldContinue
=
false
;
params
.
put
(
"stationName"
,
job
.
getStationName
());
params
.
put
(
"device"
,
job
.
getRobotName
());
params
.
put
(
"alert"
,
job
.
getWarnMessage
());
params
.
put
(
"time"
,
job
.
getStartTime
());
aliSmsUtil
.
sendSms
(
phone
,
params
,
"SMS_481615406"
);
logger
.
info
(
"已发送短信至 {} | 操作ID: {} | 设备: {} | 告警: {}"
,
phone
,
job
.
getOperationId
(),
job
.
getRobotName
(),
job
.
getWarnMessage
());
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"处理操作ID {} 时发生错误"
,
operationId
,
e
);
logger
.
error
(
"发送失败: {} | 错误: {}"
,
phone
,
e
.
getMessage
());
shouldContinue
=
false
;
}
}
}
});
}
}
/**
/**
* 发送告警短信
* 获取基础操作列表(仅获取operationId用于查询)
* @param job 操作任务
*/
*/
private
void
sendAlertSms
(
OperationJobVO
job
)
{
private
List
<
OperationJobVO
>
getBaseOperationList
()
{
List
<
String
>
phones
=
getPhoneByOperation
(
job
.
getOperationId
());
// 只需要查询operationId用于关联数据
if
(
phones
.
isEmpty
())
{
// List<OperationJob> operationJobs = operationJobMapper.selectList(
logger
.
warn
(
"操作ID {} 没有关联的手机号码"
,
job
.
getOperationId
());
// new LambdaQueryWrapper<OperationJob>()
return
;
// .select(OperationJob::getId)
// );
List
<
OperationJob
>
operationJobs
=
operationJobMapper
.
selectList
(
new
LambdaQueryWrapper
<>());
return
operationJobs
.
stream
()
.
map
(
job
->
{
OperationJobVO
vo
=
new
OperationJobVO
();
BeanUtil
.
copyProperties
(
job
,
vo
);
return
vo
;
})
.
collect
(
Collectors
.
toList
());
}
}
for
(
String
phone
:
phones
)
{
/**
* 发送每日提醒短信
*/
private
void
sendDailyReminder
(
OperationJobVO
job
)
{
List
<
String
>
phones
=
getPhoneByOperation
(
job
.
getOperationId
());
phones
.
forEach
(
phone
->
{
try
{
try
{
// 构建短信模板参数
JSONObject
params
=
new
JSONObject
();
JSONObject
jsonObject
=
new
JSONObject
();
params
.
put
(
"stationName"
,
job
.
getStationName
());
jsonObject
.
put
(
"stationName"
,
job
.
getStationName
());
// 站点名称
params
.
put
(
"device"
,
job
.
getRobotName
());
jsonObject
.
put
(
"device"
,
job
.
getRobotName
());
// 设备名称
params
.
put
(
"alert"
,
job
.
getWarnMessage
());
jsonObject
.
put
(
"alert"
,
job
.
getWarnMessage
());
// 告警类型
params
.
put
(
"time"
,
job
.
getStartTime
());
jsonObject
.
put
(
"time"
,
job
.
getStartTime
());
// 开始时间
aliSmsUtil
.
sendSms
(
phone
,
params
,
"SMS_481615406"
);
// 发送短信
logger
.
info
(
"已发送每日提醒至:{},任务ID:{}"
,
phone
,
job
.
getOperationId
());
aliSmsUtil
.
sendSms
(
phone
,
jsonObject
,
"SMS_481615406"
);
logger
.
info
(
"已向 {} 发送操作ID {} 的告警短信"
,
phone
,
job
.
getOperationId
());
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"向 {} 发送操作ID {} 的告警短信失败"
,
phone
,
job
.
getOperationId
(),
e
);
logger
.
error
(
"发送每日提醒失败,手机号:{}"
,
phone
,
e
);
}
}
}
});
}
}
/**
/**
* 为操作任务列表添加告警信息
* 为操作任务列表添加告警信息
*
* @param operationJobVOList 原始操作任务列表
* @param operationJobVOList 原始操作任务列表
* @return 带有告警信息的操作任务列表
* @return 带有告警信息的操作任务列表
*/
*/
...
@@ -156,8 +173,10 @@ public class RunLogTask {
...
@@ -156,8 +173,10 @@ public class RunLogTask {
return
operationJobVOList
;
return
operationJobVOList
;
}
}
/**
/**
* 获取操作关联的手机号列表
* 获取操作关联的手机号列表
*
* @param operationId 操作ID
* @param operationId 操作ID
* @return 手机号列表
* @return 手机号列表
*/
*/
...
@@ -216,4 +235,5 @@ public class RunLogTask {
...
@@ -216,4 +235,5 @@ public class RunLogTask {
.
distinct
()
.
distinct
()
.
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
}
}
}
}
\ No newline at end of file
src/main/resources/mapper/OperationDoMapper.xml
View file @
d7c66356
...
@@ -175,9 +175,11 @@
...
@@ -175,9 +175,11 @@
select
select
top.tb_run_log_id AS runLogId
top.tb_run_log_id AS runLogId
from tb_operation top
from tb_operation top
left join
tb_operation_job tp on top.id = tp.operation_id
where
where
top.runlog_or_operation = 1
top.runlog_or_operation = 1
AND t
o
p.finish_status NOT IN (2, 4)
AND tp.finish_status NOT IN (2, 4)
</select>
</select>
<select
id=
"queryEquipment"
resultType=
"com.example.operation_platform.model.vo.OperationDoVO"
>
<select
id=
"queryEquipment"
resultType=
"com.example.operation_platform.model.vo.OperationDoVO"
>
select DISTINCT
select DISTINCT
...
...
src/main/resources/mapper/OperationJobMapper.xml
View file @
d7c66356
...
@@ -58,7 +58,7 @@
...
@@ -58,7 +58,7 @@
and tp.operation_type like concat('%',#{operationType},'%')
and tp.operation_type like concat('%',#{operationType},'%')
</if>
</if>
<if
test=
"stationId != null and stationId != ''"
>
<if
test=
"stationId != null and stationId != ''"
>
and t
o
p.station_id = #{stationId}
and tp.station_id = #{stationId}
</if>
</if>
<if
test=
"username != null and username != ''"
>
<if
test=
"username != null and username != ''"
>
and bw.username = #{username}
and bw.username = #{username}
...
@@ -137,7 +137,9 @@
...
@@ -137,7 +137,9 @@
tp.robot_id AS robotId,
tp.robot_id AS robotId,
tp.drone_id AS droneId,
tp.drone_id AS droneId,
bw.worker_name AS workerName, -- 保留操作人员名称
bw.worker_name AS workerName, -- 保留操作人员名称
top.runlog_or_operation AS runlog_or_operation
top.runlog_or_operation AS runlog_or_operation,
tp.tb_run_log_id AS runLogId,
tp.station_id AS stationId
FROM
FROM
tb_operation_job top
tb_operation_job top
LEFT JOIN tb_operation tp ON top.operation_id = tp.id
LEFT JOIN tb_operation tp ON top.operation_id = tp.id
...
@@ -154,7 +156,7 @@
...
@@ -154,7 +156,7 @@
LEFT JOIN tb_worker bw ON tm.operation_worker = bw.id
LEFT JOIN tb_worker bw ON tm.operation_worker = bw.id
<where>
<where>
<if
test=
"stationId != null and stationId != ''"
>
<if
test=
"stationId != null and stationId != ''"
>
and t
o
p.station_id = #{stationId}
and tp.station_id = #{stationId}
</if>
</if>
<if
test=
"username != null and username != ''"
>
<if
test=
"username != null and username != ''"
>
and bw.username = #{username}
and bw.username = #{username}
...
@@ -184,7 +186,10 @@
...
@@ -184,7 +186,10 @@
top.finish_status AS finishStatus,
top.finish_status AS finishStatus,
tp.robot_id AS robotId,
tp.robot_id AS robotId,
tp.drone_id AS droneId,
tp.drone_id AS droneId,
bw.worker_name AS workerName -- 保留操作人员名称
bw.worker_name AS workerName,
tp.tb_run_log_id AS runLogId,
tp.station_id AS stationId
-- 保留操作人员名称
FROM
FROM
tb_operation_job top
tb_operation_job top
LEFT JOIN tb_operation tp ON top.operation_id = tp.id
LEFT JOIN tb_operation tp ON top.operation_id = tp.id
...
@@ -224,7 +229,7 @@
...
@@ -224,7 +229,7 @@
and tp.operation_type like concat('%',#{operationType},'%')
and tp.operation_type like concat('%',#{operationType},'%')
</if>
</if>
<if
test=
"stationId != null and stationId != ''"
>
<if
test=
"stationId != null and stationId != ''"
>
and t
o
p.station_id = #{stationId}
and tp.station_id = #{stationId}
</if>
</if>
<if
test=
"finishStatus != null and finishStatus != ''"
>
<if
test=
"finishStatus != null and finishStatus != ''"
>
and top.finish_status = #{finishStatus}
and top.finish_status = #{finishStatus}
...
@@ -235,6 +240,9 @@
...
@@ -235,6 +240,9 @@
<if
test=
"droneId != null and droneId != ''"
>
<if
test=
"droneId != null and droneId != ''"
>
and tp.drone_id = #{droneId}
and tp.drone_id = #{droneId}
</if>
</if>
<if
test=
"id != null and id != ''"
>
and top.id = #{id}
</if>
</where>
</where>
ORDER BY top.start_time DESC
ORDER BY top.start_time DESC
</select>
</select>
...
@@ -280,18 +288,89 @@
...
@@ -280,18 +288,89 @@
tp.operation_type AS operationType,
tp.operation_type AS operationType,
bs.name AS stationName,
bs.name AS stationName,
COALESCE(br.name, dr.name) AS robotName,
COALESCE(br.name, dr.name) AS robotName,
tp.run_log_id AS runLogId,
tp.
tb_
run_log_id AS runLogId,
top.start_time AS startTime,
top.start_time AS startTime,
tp.station_id AS stationId,
tp.station_id AS stationId,
top.operation_id AS operationId
,
top.operation_id AS operationId
from
from
tb_operation_job top
tb_operation_job top
LEFT JOIN tb_operation tp ON top.operation_id = tp.id
LEFT JOIN tb_operation tp ON top.operation_id = tp.id
LEFT JOIN bs_station bs ON tp.station_id = bs.id
LEFT JOIN bs_station bs ON tp.station_id = bs.id
LEFT JOIN bs_robot br ON tp.robot_id = br.id
LEFT JOIN bs_robot br ON tp.robot_id = br.id
LEFT JOIN uav_drone dr ON tp.drone_id = dr.id
LEFT JOIN uav_drone dr ON tp.drone_id = dr.id
WHERE
tp.runlog_or_operation=1
AND tp.finish_status NOT 4
</select>
<!-- 维保详情页面的第一个模块信息-->
<select
id=
"queryJobAndOperationTypeList"
resultType=
"com.example.operation_platform.model.vo.OperationJobVO"
>
SELECT
top.id,
tp.operation_type AS operationType,
bs.name AS stationName,
-- 合并 robot 和 drone 的 name 到 robotName(优先取 robot)
COALESCE(
br.name, -- 来自 bs_robot 的机器人名称
ud.name, -- 来自 uav_drone 的无人机名称
'未知设备' -- 默认值
) AS robotName,
top.start_time AS startTime,
top.end_time AS endTime,
top.finish_status AS finishStatus,
tp.robot_id AS robotId,
tp.drone_id AS droneId,
(
SELECT GROUP_CONCAT(DISTINCT bti.operation_item SEPARATOR ', ')
FROM tb_operation_item bti
WHERE FIND_IN_SET(bti.id, tp.item_id) > 0
) AS operationItems,
tp.item_id AS itemId,
tp.station_id AS stationId
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
-- 关联 robot 表(通过 tb_message)
LEFT JOIN bs_robot br ON tp.robot_id = br.id
-- 关联 drone 表(通过 tb_message)
LEFT JOIN uav_drone ud ON tp.drone_id = ud.id
LEFT JOIN tb_operation_item bti ON tp.item_id = bti.id
<where>
top.runlog_or_operation = 0
<if
test=
"robotName != null and robotName != ''"
>
and br.name like concat('%',#{robotName},'%')
or ud.name like concat('%',#{robotName},'%')
</if>
<if
test=
"stationName != null and stationName != ''"
>
and bs.name like concat('%',#{stationName},'%')
</if>
<if
test=
"workerName != null and workerName != ''"
>
and bw.worker_name like concat('%',#{workerName},'%')
</if>
<if
test=
"status != null and status != ''"
>
and top.status like concat('%',#{status},'%')
</if>
<if
test=
"startTime != null "
>
and top.start_time
>
= #{startTime}
</if>
<if
test=
"endTime != null "
>
and top.endTime
<
= #{endTime}
</if>
<if
test=
"operationType != null and operationType != ''"
>
and tp.operation_type like concat('%',#{operationType},'%')
</if>
<if
test=
"stationId != null and stationId != ''"
>
and tp.station_id = #{stationId}
</if>
<if
test=
"username != null and username != ''"
>
and bw.username = #{username}
</if>
<if
test=
"id != null and id != ''"
>
and top.id = #{id}
</if>
</where>
ORDER BY top.start_time DESC
</select>
</select>
</mapper>
</mapper>
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