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

初始化

parent 7b817d2a
...@@ -14,4 +14,16 @@ public interface OperationJobService extends IService<OperationJob> { ...@@ -14,4 +14,16 @@ public interface OperationJobService extends IService<OperationJob> {
* @return * @return
*/ */
List<OperationJobVO> queryJobList(OperationJobDTO operationJobDTO); 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 ...@@ -19,6 +19,12 @@ public interface TbOperationRecordService extends IService<TbOperationRecordEnti
* @param operationRecordDTO operationRecordDTO * @param operationRecordDTO operationRecordDTO
* @return List<OperationRecordVO> * @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 ...@@ -24,8 +24,8 @@ public class MessageServiceImpl extends ServiceImpl<MessageMapper, MessageEntity
this.baseMapper.resetmessage(messageDTO); this.baseMapper.resetmessage(messageDTO);
} }
@Override @Override
public PeopleMessageVO queryPeople(Long stationId) { public PeopleMessageVO queryPeople(MessageDTO messageDTO) {
return this.baseMapper.queryPeople(stationId); return this.baseMapper.queryPeople(messageDTO);
} }
@Override @Override
public List<PeopleMessageVO> querymessageList(MessageDTO messageDTO) { public List<PeopleMessageVO> querymessageList(MessageDTO messageDTO) {
...@@ -42,4 +42,8 @@ public class MessageServiceImpl extends ServiceImpl<MessageMapper, MessageEntity ...@@ -42,4 +42,8 @@ public class MessageServiceImpl extends ServiceImpl<MessageMapper, MessageEntity
public List<RobotAndDrone> queryrobotBystationId(String stationId) { public List<RobotAndDrone> queryrobotBystationId(String stationId) {
return this.baseMapper.queryrobotBystationId(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 ...@@ -22,4 +22,10 @@ public class OperationItemServiceImpl extends ServiceImpl<OperationItemMapper, O
public List<OperationItem> queryByIdList(List<String> itemIdList) { public List<OperationItem> queryByIdList(List<String> itemIdList) {
return baseMapper.queryByIdList(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; ...@@ -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.entity.OperationJob;
import com.example.operation_platform.model.vo.OperationJobVO; import com.example.operation_platform.model.vo.OperationJobVO;
import com.example.operation_platform.service.OperationJobService; import com.example.operation_platform.service.OperationJobService;
import org.apache.xmlbeans.impl.xb.xsdschema.Public;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
...@@ -17,4 +18,15 @@ public class OperationJobServiceImpl extends ServiceImpl<OperationJobMapper, Ope ...@@ -17,4 +18,15 @@ public class OperationJobServiceImpl extends ServiceImpl<OperationJobMapper, Ope
List<OperationJobVO> operationJobVOS = baseMapper.queryJobList(operationJobDTO); List<OperationJobVO> operationJobVOS = baseMapper.queryJobList(operationJobDTO);
return operationJobVOS; 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 ...@@ -19,8 +19,12 @@ public class TbOperationRecordServiceImpl extends ServiceImpl<TbOperationRecordM
return baseMapper.queryrecordList(operationRecordDTO); return baseMapper.queryrecordList(operationRecordDTO);
} }
@Override @Override
public List<OperationRecordVO> queryrecordListById(Long stationId,Long robotId) { public List<OperationRecordVO> queryrecordListById(String stationId,Long robotId) {
return baseMapper.queryrecordListById(stationId,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; ...@@ -6,7 +6,12 @@ import com.platform.service.MongoService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; 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.List;
import java.util.Map;
@Service @Service
public class UavOperateLogServiceImpl implements OperateLogService { public class UavOperateLogServiceImpl implements OperateLogService {
...@@ -25,4 +30,43 @@ public class UavOperateLogServiceImpl implements OperateLogService { ...@@ -25,4 +30,43 @@ public class UavOperateLogServiceImpl implements OperateLogService {
values, values,
UavOperateLogEntity.class); 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 @@ ...@@ -60,10 +60,17 @@
LEFT JOIN tb_worker tp ON tm.software_worker = tp.id 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 ta ON tm.hardware_worker = ta.id
LEFT JOIN tb_worker tq ON tm.operation_worker = tq.id LEFT JOIN tb_worker tq ON tm.operation_worker = tq.id
where <where>
<if test="stationId != null and stationId != ''"> <if test="stationId != null and stationId != ''">
tm.station_id = #{stationId} tm.station_id = #{stationId}
</if> </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>
<select id="querymessageList" resultType="com.example.operation_platform.model.vo.PeopleMessageVO"> <select id="querymessageList" resultType="com.example.operation_platform.model.vo.PeopleMessageVO">
SELECT SELECT
...@@ -166,4 +173,20 @@ ...@@ -166,4 +173,20 @@
where where
tm.station_id = #{stationId} tm.station_id = #{stationId}
</select> </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> </mapper>
\ No newline at end of file
...@@ -27,6 +27,17 @@ ...@@ -27,6 +27,17 @@
</if> </if>
</where> </where>
</select> </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> </mapper>
...@@ -60,6 +60,9 @@ ...@@ -60,6 +60,9 @@
<if test="endTime != null"> <if test="endTime != null">
AND top.start_time &lt;= #{endTime} <!-- 注意字段名是finish_time还是end_time --> AND top.start_time &lt;= #{endTime} <!-- 注意字段名是finish_time还是end_time -->
</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>
...@@ -83,8 +86,6 @@ ...@@ -83,8 +86,6 @@
top.id = #{id} top.id = #{id}
and top.runlog_or_operation = 0 and top.runlog_or_operation = 0
and tb.start_time > CURRENT_TIMESTAMP and tb.start_time > CURRENT_TIMESTAMP
</select> </select>
</mapper> </mapper>
...@@ -48,19 +48,118 @@ ...@@ -48,19 +48,118 @@
<if test="status != null and status != ''"> <if test="status != null and status != ''">
and top.status like concat('%',#{status},'%') and top.status like concat('%',#{status},'%')
</if> </if>
<if test="startTime != null"> <if test="startTime != null ">
and top.start_time &gt;= #{startTime} and top.start_time &gt;= #{startTime}
</if> </if>
<if test="endTime != null"> <if test="endTime != null ">
and top.endTime &lt;= #{endTime} and top.endTime &lt;= #{endTime}
</if> </if>
<if test="operationType != null and operationType != ''"> <if test="operationType != null and operationType != ''">
and tp.operation_type like concat('%',#{operationType},'%') and tp.operation_type like concat('%',#{operationType},'%')
</if> </if>
<if test="stationId != null and stationId != ''">
and top.station_id = #{stationId}
</if>
</where> </where>
ORDER BY top.start_time DESC ORDER BY top.start_time DESC
</select> </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> </mapper>
<?xml version="1.0" encoding="utf-8" ?> <?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" > <!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"> <mapper namespace="com.example.operation_platform.mapper.TbOperationRecordMapper">
<!--维保记录查询-->
<select id="queryrecordList" resultType="com.example.operation_platform.model.vo.OperationRecordVO"> <select id="queryrecordList" resultType="com.example.operation_platform.model.vo.OperationRecordVO">
select SELECT
tor.id id, tor.id id,
br.name robotName, COALESCE ( br.NAME, dr.NAME ) robotName,
tor.content content, tor.content content,
top.operation_type operationType, top.operation_type operationType,
tor.img img, tor.img img,
tk.worker_name workerName,
tor.operation_date operationDate, tor.operation_date operationDate,
bs.name stationName, bs.NAME stationName,
tw.worker_name workerName,
tor.note note tor.note note
from FROM
tb_operation_record tor tb_operation_record tor
left join LEFT JOIN tb_operation top ON tor.operation_id = top.id
tb_operation top LEFT JOIN bs_station bs ON top.station_id = bs.id
on LEFT JOIN tb_operation_job oj ON tor.operation_job_id = oj.id
tor.operation_id = top.id LEFT JOIN tb_message tb ON top.station_id = tb.station_id
left join AND (
tb_worker tk top.robot_id = tb.robot_id
on OR ( top.robot_id IS NULL AND top.drone_id = tb.drone_id ))
tor.worker_id = tk.id LEFT JOIN bs_robot br ON top.robot_id = br.id
left join LEFT JOIN uav_drone dr ON top.drone_id = dr.id
bs_robot br LEFT JOIN tb_worker tw ON tb.operation_worker=tw.id
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
<where> <where>
tor.runlog_or_operation = 0
<if test="operationId != null and operationId != ''"> <if test="operationId != null and operationId != ''">
and tor.operation_id= #{operationId} and tor.operation_id= #{operationId}
</if> </if>
<if test="robotId != null and robotId != ''"> <if test="robotId != null and robotId != ''">
and top.robot_id= #{robotId} and top.robot_id= #{robotId}
</if> </if>
<if test="droneId != null and droneId != ''">
and top.drone_id= #{droneId}
</if>
<if test="stationId != null and stationId != ''"> <if test="stationId != null and stationId != ''">
and top.station_id= #{stationId} and top.station_id= #{stationId}
</if> </if>
...@@ -58,7 +52,7 @@ ...@@ -58,7 +52,7 @@
tor.content content, tor.content content,
top.operation_type operationType, top.operation_type operationType,
tor.img img, tor.img img,
tk.worker_name workerName, tw.worker_name workerName,
tor.operation_date operationDate, tor.operation_date operationDate,
bs.name stationName, bs.name stationName,
tor.note note tor.note note
...@@ -68,10 +62,7 @@ ...@@ -68,10 +62,7 @@
tb_operation top tb_operation top
on on
tor.operation_id = top.id tor.operation_id = top.id
left join
tb_worker tk
on
tor.worker_id = tk.id
left join left join
bs_robot br bs_robot br
on on
...@@ -84,8 +75,46 @@ ...@@ -84,8 +75,46 @@
tb_operation_job oj tb_operation_job oj
on on
tor.operation_job_id = oj.id 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 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} and top.station_id= #{stationId}
</if>
order by tor.operation_date desc
</select> </select>
</mapper> </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