Commit c7f2ac89 authored by 王蔡翾's avatar 王蔡翾
Browse files

移动端维保待办

parent e48b4c7f
......@@ -38,5 +38,14 @@ public class OperationJobController extends BaseController {
startPage(operationJobDTO.getPageNum(), operationJobDTO.getPageSize());
return getDataTable(operationJobService.queryAllJobList(operationJobDTO));
}
@PostMapping("page/run/log")
public TableDataInfo pageRunLog(@RequestBody OperationJobDTO operationJobDTO) {
startPage(operationJobDTO.getPageNum(), operationJobDTO.getPageSize());
return getDataTable(operationJobService.queryRunLogJobList(operationJobDTO));
}
@PostMapping("/lastTime")//最近任务时间
public Result queryLastTime() {
return Result.data(operationJobService.queryLastTime());
}
}
......@@ -2,6 +2,7 @@ package com.example.operation_platform.controller;
import com.example.operation_platform.model.dto.OperationRecordDTO;
import com.example.operation_platform.model.vo.OperationRecordVO;
import com.example.operation_platform.service.OperationJobService;
import com.example.operation_platform.service.TbOperationRecordService;
import com.platform.controller.BaseController;
import com.platform.model.resp.Result;
......@@ -17,6 +18,8 @@ public class OperationRecordController extends BaseController {
@Resource
private TbOperationRecordService tbOperationRecordService;
@Resource
private OperationJobService operationJobService;
@PostMapping("/page")
public TableDataInfo page(@RequestBody OperationRecordDTO operationRecordDTO) {
......@@ -24,8 +27,15 @@ public class OperationRecordController extends BaseController {
return getDataTable(tbOperationRecordService.queryrecordList(operationRecordDTO));
}
@PostMapping("/save")
@PostMapping("/save")//部分完成,任务还在进行中
public Result save(@RequestBody OperationRecordDTO operationRecordDTO) {
return toAjax(tbOperationRecordService.save(operationRecordDTO));
}
@PostMapping("/save/status")//全部完成
public Result saveStatus(@RequestBody OperationRecordDTO operationRecordDTO) {
Integer id = operationRecordDTO.getOperationJobId();
operationJobService.updateStatusById(id);
return toAjax(tbOperationRecordService.save(operationRecordDTO));
}
@GetMapping()//没用到,不必理会
......
......@@ -26,4 +26,23 @@ public interface OperationJobMapper extends BaseMapper<OperationJob> {
* @return
*/
List<OperationJobVO> queryAllJobList(OperationJobDTO operationJobDTO);
/**
* 展示运行异常任务列表
* @param operationJobDTO
* @return
*/
List<OperationJobVO> queryRunLogJobList(OperationJobDTO operationJobDTO);
/**
* 根据id更新任务状态
* @param id
* @return
*/
void updateStatusById(Integer id);
/**
* 查找最近的任务时间
* @param
* @return
*/
OperationJobVO queryLastTime();
}
......@@ -12,5 +12,6 @@ public class OperationJobVO extends OperationJob {
private String operationType;
private String workerName;
private Integer id;
private String robotId;
private Integer robotId;
private Integer droneId;
}
......@@ -26,4 +26,22 @@ public interface OperationJobService extends IService<OperationJob> {
* @return
*/
List<OperationJobVO> queryAllJobList(OperationJobDTO operationJobDTO);
/**
* 展示运行异常任务列表
* @param operationJobDTO
* @return
*/
List<OperationJobVO> queryRunLogJobList(OperationJobDTO operationJobDTO);
/**
* 根据id更新任务状态
* @param id
* @return
*/
void updateStatusById(Integer id);
/**
* 查找最近的任务时间
* @param
* @return
*/
OperationJobVO queryLastTime();
}
......@@ -28,5 +28,18 @@ public class OperationJobServiceImpl extends ServiceImpl<OperationJobMapper, Ope
List<OperationJobVO> operationJobVOS = baseMapper.queryAllJobList(operationJobDTO);
return operationJobVOS;
}
@Override
public List<OperationJobVO> queryRunLogJobList(OperationJobDTO operationJobDTO) {
List<OperationJobVO> operationJobVOS = baseMapper.queryRunLogJobList(operationJobDTO);
return operationJobVOS;
}
@Override
public void updateStatusById(Integer id) {
baseMapper.updateStatusById(id);
}
@Override
public OperationJobVO queryLastTime() {
OperationJobVO operationJobVO = baseMapper.queryLastTime();
return operationJobVO;
}
}
......@@ -26,5 +26,4 @@ public class TbOperationRecordServiceImpl extends ServiceImpl<TbOperationRecordM
public List<OperationRecordVO> queryRunLogRecordList(OperationRecordDTO operationRecordDTO) {
return baseMapper.queryRunLogRecordList(operationRecordDTO);
}
}
......@@ -160,6 +160,84 @@
top.runlog_or_operation DESC, -- 1在前,0在后
top.start_time DESC
</select>
<!-- 查询告警日志列表-->
<select id="queryRunLogJobList" 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,
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>
top.runlog_or_operation = 1
<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 &gt;= #{startTime}
</if>
<if test="endTime != null ">
and top.endTime &lt;= #{endTime}
</if>
<if test="operationType != null and operationType != ''">
and tp.operation_type like concat('%',#{operationType},'%')
</if>
<if test="stationId != null and stationId != ''">
and top.station_id = #{stationId}
</if>
</where>
ORDER BY top.start_time DESC
</select>
<update id="updateStatusById" parameterType="com.example.operation_platform.model.vo.OperationJobVO">
UPDATE tb_operation_job
SET finish_status = CASE
WHEN CURRENT_TIMESTAMP > end_time THEN 2
ELSE 4
END
WHERE id = #{id};
</update>
<select id="queryLastTime" resultType="com.example.operation_platform.model.vo.OperationJobVO">
SELECT *
FROM tb_operation_job
WHERE start_time > CURRENT_TIMESTAMP
ORDER BY start_time ASC
LIMIT 1;
</select>
</mapper>
......@@ -29,4 +29,5 @@
</if>
</where>
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment