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

初始化

parent 7b817d2a
......@@ -14,4 +14,16 @@ public interface OperationJobService extends IService<OperationJob> {
* @return
*/
List<OperationJobVO> queryJobList(OperationJobDTO operationJobDTO);
/**
* 根据日期查询任务列表
* @param operationJobDTO
* @return
*/
List<OperationJobVO> queryJobListByDate(OperationJobDTO operationJobDTO);
/**
* 展示所有任务,告警优先展示,finish_status=1为告警,=0为维保
* @param operationJobDTO
* @return
*/
List<OperationJobVO> queryAllJobList(OperationJobDTO operationJobDTO);
}
......@@ -19,6 +19,12 @@ public interface TbOperationRecordService extends IService<TbOperationRecordEnti
* @param operationRecordDTO operationRecordDTO
* @return List<OperationRecordVO>
*/
List<OperationRecordVO> queryrecordListById(Long stationId,Long robotId);
List<OperationRecordVO> queryrecordListById(String stationId,Long robotId);
/*运行异常维保记录
* @param operationRecordDTO operationRecordDTO
* @return List<OperationRecordVO>
*/
List<OperationRecordVO> queryRunLogRecordList(OperationRecordDTO operationRecordDTO);
}
......@@ -24,8 +24,8 @@ public class MessageServiceImpl extends ServiceImpl<MessageMapper, MessageEntity
this.baseMapper.resetmessage(messageDTO);
}
@Override
public PeopleMessageVO queryPeople(Long stationId) {
return this.baseMapper.queryPeople(stationId);
public PeopleMessageVO queryPeople(MessageDTO messageDTO) {
return this.baseMapper.queryPeople(messageDTO);
}
@Override
public List<PeopleMessageVO> querymessageList(MessageDTO messageDTO) {
......@@ -42,4 +42,8 @@ public class MessageServiceImpl extends ServiceImpl<MessageMapper, MessageEntity
public List<RobotAndDrone> queryrobotBystationId(String stationId) {
return this.baseMapper.queryrobotBystationId(stationId);
}
@Override
public List<MessageVO> querystationByworker(String username) {
return this.baseMapper.querystationByworker(username);
}
}
......@@ -22,4 +22,10 @@ public class OperationItemServiceImpl extends ServiceImpl<OperationItemMapper, O
public List<OperationItem> queryByIdList(List<String> itemIdList) {
return baseMapper.queryByIdList(itemIdList);
}
@Override
public List<OperationItemVO> queryByItemId(String itemIdList) {
return baseMapper.queryByItemId(itemIdList);
}
}
......@@ -6,6 +6,7 @@ import com.example.operation_platform.model.dto.OperationJobDTO;
import com.example.operation_platform.model.entity.OperationJob;
import com.example.operation_platform.model.vo.OperationJobVO;
import com.example.operation_platform.service.OperationJobService;
import org.apache.xmlbeans.impl.xb.xsdschema.Public;
import org.springframework.stereotype.Service;
import java.util.List;
......@@ -17,4 +18,15 @@ public class OperationJobServiceImpl extends ServiceImpl<OperationJobMapper, Ope
List<OperationJobVO> operationJobVOS = baseMapper.queryJobList(operationJobDTO);
return operationJobVOS;
}
@Override
public List<OperationJobVO> queryJobListByDate(OperationJobDTO operationJobDTO) {
List<OperationJobVO> operationJobVOS = baseMapper.queryJobListByDate(operationJobDTO);
return operationJobVOS;
}
@Override
public List<OperationJobVO> queryAllJobList(OperationJobDTO operationJobDTO) {
List<OperationJobVO> operationJobVOS = baseMapper.queryAllJobList(operationJobDTO);
return operationJobVOS;
}
}
......@@ -19,8 +19,12 @@ public class TbOperationRecordServiceImpl extends ServiceImpl<TbOperationRecordM
return baseMapper.queryrecordList(operationRecordDTO);
}
@Override
public List<OperationRecordVO> queryrecordListById(Long stationId,Long robotId) {
public List<OperationRecordVO> queryrecordListById(String stationId,Long robotId) {
return baseMapper.queryrecordListById(stationId,robotId);
}
@Override
public List<OperationRecordVO> queryRunLogRecordList(OperationRecordDTO operationRecordDTO) {
return baseMapper.queryRunLogRecordList(operationRecordDTO);
}
}
......@@ -6,7 +6,12 @@ import com.platform.service.MongoService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class UavOperateLogServiceImpl implements OperateLogService {
......@@ -25,4 +30,43 @@ public class UavOperateLogServiceImpl implements OperateLogService {
values,
UavOperateLogEntity.class);
}
// @Override
// public void updateRunLogIdByDate(String originalRunLogId) {
// // 1. 查询原始数据
// List<UavOperateLogEntity> originalList = mongoService.findByMap(
// new String[]{"run_log_id"},
// new Object[]{originalRunLogId},
// UavOperateLogEntity.class
// );
//
// // 2. 按日期分组,并分配新编号(1, 2, 3...)
// Map<LocalDate, Integer> dateToNewIdMap = new HashMap<>();
// List<UavOperateLogEntity> updatedEntities = new ArrayList<>();
//
// for (UavOperateLogEntity entity : originalList) {
// LocalDate date = entity.getDataTime().toInstant()
// .atZone(ZoneId.systemDefault())
// .toLocalDate();
//
// // 如果该日期未分配编号,则分配新编号(从1开始)
// if (!dateToNewIdMap.containsKey(date)) {
// int newId = dateToNewIdMap.size() + 1; // 1, 2, 3...
// dateToNewIdMap.put(date, newId);
// }
//
// // 更新 run_log_id(直接使用 Integer)
// entity.setRunLogId(dateToNewIdMap.get(date));
// updatedEntities.add(entity);
// }
//
// // 3. 批量更新数据库(使用 updateById)
// for (UavOperateLogEntity entity : updatedEntities) {
// mongoService.updateById(
// new String[]{"run_log_id"}, // 要更新的字段
// new Object[]{entity.getRunLogId()}, // 新值(Integer)
// entity.getId(), // 主键ID
// UavOperateLogEntity.class
// );
// }
// }
}
......@@ -60,10 +60,17 @@
LEFT JOIN tb_worker tp ON tm.software_worker = tp.id
LEFT JOIN tb_worker ta ON tm.hardware_worker = ta.id
LEFT JOIN tb_worker tq ON tm.operation_worker = tq.id
where
<where>
<if test="stationId != null and stationId != ''">
tm.station_id = #{stationId}
</if>
<if test="robotId != null and robotId != ''">
and tm.robot_id = #{robotId}
</if>
<if test="droneId != null and droneId != ''">
and tm.drone_id = #{droneId}
</if>
</where>
</select>
<select id="querymessageList" resultType="com.example.operation_platform.model.vo.PeopleMessageVO">
SELECT
......@@ -166,4 +173,20 @@
where
tm.station_id = #{stationId}
</select>
<select id="querystationByworker" resultType="com.example.operation_platform.model.vo.MessageVO">
select
tm.id,
tm.station_id stationId,
bs.name stationName
from
tb_message tm
left join
tb_worker tw on tm.operation_worker = tw.id
left join
bs_station bs on tm.station_id = bs.id
where
tw.username = #{username}
</select>
</mapper>
\ No newline at end of file
......@@ -27,6 +27,17 @@
</if>
</where>
</select>
<select id="queryByItemId" resultType="com.example.operation_platform.model.vo.OperationItemVO">
select
tw.id id,
tw.operation_item operationItem,
tw.operation_guide operationGuide
from
tb_operation_item tw
<where>
FIND_IN_SET(tw.id, #{itemId})
</where>
</select>
</mapper>
......@@ -60,6 +60,9 @@
<if test="endTime != null">
AND top.start_time &lt;= #{endTime} <!-- 注意字段名是finish_time还是end_time -->
</if>
<if test="id != null and id != ''">
AND top.id = #{id}
</if>
</where>
ORDER BY top.start_time DESC
</select>
......@@ -83,8 +86,6 @@
top.id = #{id}
and top.runlog_or_operation = 0
and tb.start_time > CURRENT_TIMESTAMP
</select>
</mapper>
......@@ -48,19 +48,118 @@
<if test="status != null and status != ''">
and top.status like concat('%',#{status},'%')
</if>
<if test="startTime != null">
<if test="startTime != null ">
and top.start_time &gt;= #{startTime}
</if>
<if test="endTime != null">
<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>
<!-- 根据日期获取任务信息-->
<select id="queryJobListByDate" resultType="com.example.operation_platform.model.vo.OperationJobVO">
SELECT
top.id,
tp.operation_type AS operationType,
tp.operation_id AS operationId,
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 = 0
<if test="date != null">
AND #{date} BETWEEN top.start_time AND top.end_time
</if>
<if test="year != null and month != null">
AND
YEAR(top.start_time) = #{year} AND MONTH(top.start_time) = #{month}
</if>
<if test="username != null and username != ''">
and bw.username = #{username}
</if>
</where>
ORDER BY top.start_time DESC
</select>
<select id="queryAllJobList" resultType="com.example.operation_platform.model.vo.OperationJobVO">
SELECT
top.id,
tp.operation_type AS operationType,
top.operation_id AS operationId,
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, -- 保留操作人员名称
top.runlog_or_operation AS runlog_or_operation
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>
<if test="stationId != null and stationId != ''">
and top.station_id = #{stationId}
</if>
<if test="username != null and username != ''">
and bw.username = #{username}
</if>
<if test="finishStatus != null and finishStatus != ''">
and top.finish_status = #{finishStatus}
</if>
</where>
ORDER BY
top.runlog_or_operation DESC, -- 1在前,0在后
top.start_time DESC
</select>
</mapper>
<?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.example.operation_platform.mapper.TbOperationRecordMapper">
<!--维保记录查询-->
<select id="queryrecordList" resultType="com.example.operation_platform.model.vo.OperationRecordVO">
select
tor.id id,
br.name robotName,
tor.content content,
top.operation_type operationType,
tor.img img,
tk.worker_name workerName,
tor.operation_date operationDate,
bs.name stationName,
tor.note note
from
tb_operation_record tor
left join
tb_operation top
on
tor.operation_id = top.id
left join
tb_worker tk
on
tor.worker_id = tk.id
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_operation_job oj
on
tor.operation_job_id = oj.id
SELECT
tor.id id,
COALESCE ( br.NAME, dr.NAME ) robotName,
tor.content content,
top.operation_type operationType,
tor.img img,
tor.operation_date operationDate,
bs.NAME stationName,
tw.worker_name workerName,
tor.note note
FROM
tb_operation_record tor
LEFT JOIN tb_operation top ON tor.operation_id = top.id
LEFT JOIN bs_station bs ON top.station_id = bs.id
LEFT JOIN tb_operation_job oj ON tor.operation_job_id = oj.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 bs_robot br ON top.robot_id = br.id
LEFT JOIN uav_drone dr ON top.drone_id = dr.id
LEFT JOIN tb_worker tw ON tb.operation_worker=tw.id
<where>
tor.runlog_or_operation = 0
<if test="operationId != null and operationId != ''">
and tor.operation_id= #{operationId}
</if>
<if test="robotId != null and robotId != ''">
and top.robot_id= #{robotId}
</if>
<if test="droneId != null and droneId != ''">
and top.drone_id= #{droneId}
</if>
<if test="stationId != null and stationId != ''">
and top.station_id= #{stationId}
</if>
......@@ -58,7 +52,7 @@
tor.content content,
top.operation_type operationType,
tor.img img,
tk.worker_name workerName,
tw.worker_name workerName,
tor.operation_date operationDate,
bs.name stationName,
tor.note note
......@@ -68,10 +62,7 @@
tb_operation top
on
tor.operation_id = top.id
left join
tb_worker tk
on
tor.worker_id = tk.id
left join
bs_robot br
on
......@@ -84,8 +75,46 @@
tb_operation_job oj
on
tor.operation_job_id = oj.id
left join
uav_drone dr
on
top.drone_id = dr.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 tw ON tb.operation_worker=tw.id
where
top.robot_id= #{robotId}
tor.runlog_or_operation = 0
and top.robot_id= #{robotId} or top.drone_id= #{robotId}
and top.station_id= #{stationId}
</select>
<!-- 运行异常的维保记录查看-->
<select id="queryRunLogRecordList" resultType="com.example.operation_platform.model.vo.OperationRecordVO">
SELECT
tor.id id,
COALESCE ( br.NAME, dr.NAME ) robotName,
tor.content content,
top.operation_type operationType,
tor.img img,
tor.operation_date operationDate,
bs.NAME stationName,
tor.note note
FROM
tb_operation_record tor
LEFT JOIN tb_operation top ON tor.operation_id = top.id
LEFT JOIN bs_station bs ON top.station_id = bs.id
LEFT JOIN tb_operation_job oj ON tor.operation_job_id = oj.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 bs_robot br ON top.robot_id = br.id
LEFT JOIN uav_drone dr ON top.drone_id = dr.id
WHERE
tor.runlog_or_operation = 1
<if test="stationId != null and stationId != ''">
and top.station_id= #{stationId}
</if>
order by tor.operation_date desc
</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