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

更新

parent c7f2ac89
......@@ -26,5 +26,6 @@ public interface TbOperationRecordService extends IService<TbOperationRecordEnti
* @return List<OperationRecordVO>
*/
List<OperationRecordVO> queryRunLogRecordList(OperationRecordDTO operationRecordDTO);
List<OperationRecordVO> queryRunLogRecordListAndWarnMessage(OperationRecordDTO operationRecordDTO);
}
......@@ -24,7 +24,7 @@ public interface WorkerService extends IService<WorkerEntity> {
* @param
* @return WorkerEntity
*/
WorkerVO queryById(Integer id);
WorkerVO queryMyMessage(String username);
/*
* 登录验证
* @param WorkerDTO WorkerDTO
......
......@@ -7,6 +7,7 @@ import com.example.operation_platform.mapper.OperationDoMapper;
import com.example.operation_platform.model.dto.OperationDoDTO;
import com.example.operation_platform.model.entity.OperationDoEntity;
import com.example.operation_platform.model.entity.OperationItem;
import com.example.operation_platform.model.vo.AllCountVO;
import com.example.operation_platform.model.vo.OperationDoVO;
import com.example.operation_platform.service.OperationDoService;
import com.example.operation_platform.service.OperationItemService;
......@@ -65,4 +66,16 @@ public class OperationDoServiceImpl extends ServiceImpl<OperationDoMapper, Opera
public void stopDo(OperationDoDTO operationDoDTO) {
this.baseMapper.stopDo(operationDoDTO);
}
@Override
public List<OperationDoVO> queryDoRunLog(OperationDoDTO operationDoDTO) {
return this.baseMapper.queryDoRunLog(operationDoDTO);
}
@Override
public List<Integer> queryRunLogIdList() {
return this.baseMapper.queryRunLogIdList();
}
@Override
public AllCountVO querycount() {
return this.baseMapper.querycount();
}
}
\ No newline at end of file
......@@ -42,4 +42,13 @@ public class OperationJobServiceImpl extends ServiceImpl<OperationJobMapper, Ope
OperationJobVO operationJobVO = baseMapper.queryLastTime();
return operationJobVO;
}
@Override
public void updateRunLogStatus(Integer id) {
baseMapper.updateRunLogStatus(id);
}
@Override
public OperationJobVO queryWarn() {
OperationJobVO operationJobVO = baseMapper.queryWarn();
return operationJobVO;
}
}
......@@ -7,6 +7,7 @@ import com.example.operation_platform.model.entity.RunLogEntity;
import com.example.operation_platform.model.entity.UavOperateLogEntity;
import com.example.operation_platform.model.vo.RunLogVO;
import com.example.operation_platform.service.OperateLogService;
import com.example.operation_platform.service.OperationDoService;
import com.example.operation_platform.service.RunLogService;
import com.google.common.collect.Lists;
import com.platform.utils.ExcelUtil;
......@@ -15,9 +16,11 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
......@@ -32,7 +35,8 @@ public class RunLogServiceImpl extends ServiceImpl<RunLogMapper, RunLogEntity> i
public List<RunLogVO> queryLogList(RunLogDTO runLogDTO) {
return baseMapper.queryLogList(runLogDTO);
}
@Resource
private OperationDoService operationDoService;
@Override
public List<UavOperateLogEntity> getInfoById(String id) {
RunLogEntity runLogEntity = getById(id);
......@@ -83,4 +87,31 @@ public class RunLogServiceImpl extends ServiceImpl<RunLogMapper, RunLogEntity> i
"机器人运行日志.xlsx",
ServletUtils.getResponse());
}
@Override
public List<Map<String, Object>> getAlertAndFailureLogs() {
List<Map<String, Object>> result = new ArrayList<>();
List<Integer> runLogIds = operationDoService.queryRunLogIdList();
for (Integer runLogId : runLogIds) {
List<UavOperateLogEntity> logs = getInfoById(runLogId.toString());
for (UavOperateLogEntity log : logs) {
if (log.getContent().contains("告警") || log.getContent().contains("失败")) {
Map<String, Object> entry = new HashMap<>();
entry.put("content", log.getContent());
entry.put("dateTime", log.getDataTime());
result.add(entry);
}
}
}
return result;
}
@Override
public String getMergedContentForRunLogId(String id) {
List<UavOperateLogEntity> logs = getInfoById(id);
return logs.stream()
.limit(5)
.map(UavOperateLogEntity::getContent)
.collect(Collectors.joining(", "));
}
}
......@@ -7,12 +7,18 @@ import com.example.operation_platform.model.entity.TbOperationRecordEntity;
import com.example.operation_platform.model.vo.OperationRecordVO;
import com.example.operation_platform.service.TbOperationRecordService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class TbOperationRecordServiceImpl extends ServiceImpl<TbOperationRecordMapper, TbOperationRecordEntity> implements TbOperationRecordService {
@Resource
private RunLogServiceImpl runLogService;
@Override
public List<OperationRecordVO> queryrecordList(OperationRecordDTO operationRecordDTO) {
......@@ -26,4 +32,30 @@ public class TbOperationRecordServiceImpl extends ServiceImpl<TbOperationRecordM
public List<OperationRecordVO> queryRunLogRecordList(OperationRecordDTO operationRecordDTO) {
return baseMapper.queryRunLogRecordList(operationRecordDTO);
}
@Override
public List<OperationRecordVO> queryRunLogRecordListAndWarnMessage(OperationRecordDTO operationRecordDTO) {
List<OperationRecordVO> operationRecordVOList = baseMapper.queryRunLogRecordList(operationRecordDTO);
List<Map<String, Object>> alertAndFailureLogs = runLogService.getAlertAndFailureLogs();
// 由于getAlertAndFailureLogs()返回的Map中没有runLogId,我们需要调整匹配逻辑
// 这里假设OperationRecordVO中的tb_run_log_id对应的是日志的ID
for (OperationRecordVO operationRecordVO : operationRecordVOList) {
StringBuilder warnMessage = new StringBuilder();
// 遍历所有告警和失败日志
for (Map<String, Object> log : alertAndFailureLogs) {
String content = (String) log.get("content");
if (content != null && !content.isEmpty()) {
if (warnMessage.length() > 0) {
warnMessage.append("\n");
}
warnMessage.append(content);
}
}
operationRecordVO.setWarnMessage(warnMessage.toString());
}
return operationRecordVOList;
}
}
......@@ -4,14 +4,10 @@ import com.example.operation_platform.model.entity.UavOperateLogEntity;
import com.example.operation_platform.service.OperateLogService;
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 {
......@@ -29,44 +25,6 @@ public class UavOperateLogServiceImpl implements OperateLogService {
return mongoService.findByMap(keys,
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
// );
// }
// }
}
......@@ -20,8 +20,8 @@ public class WorkerServiceImpl extends ServiceImpl<WorkerMapper, WorkerEntity> i
return this.baseMapper.queryList(workerDTO);
}
@Override
public WorkerVO queryById(Integer id) {
return this.baseMapper.queryById(id);
public WorkerVO queryMyMessage(String username) {
return this.baseMapper.queryMyMessage(username);
}
@Override
public WorkerVO queryByUsername(WorkerDTO WorkerDTO) {
......
......@@ -268,7 +268,7 @@ public class OperationDoTask {
jsonObject.put("device", messageNeedDataVo.getRobotName());
jsonObject.put("alert", messageNeedDataVo.getOperationType());
jsonObject.put("time", messageNeedDataVo.getStartTime());
aliSmsUtil.sendSms(phone, jsonObject, "SMS_481685150");
aliSmsUtil.sendSms(phone, jsonObject, "SMS_481630372");
}
......
package com.example.operation_platform.task;
public class RunLogTask {
// public static void main(String[] args) {
// while (true) {
// try {
// checkStatusAndSendSMS();
// Thread.sleep(60000); // 每分钟检查一次
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// }
// }
}
......@@ -46,6 +46,8 @@
<select id="queryPeople" resultType="com.example.operation_platform.model.vo.PeopleMessageVO">
SELECT
tm.id id,
tor.name stationName,
COALESCE(br.name, dr.name) robotName,
tor.contact_phone phoneNumber,
tp.worker_name softwareWorker,
ta.worker_name hardwareWorker,
......@@ -60,6 +62,9 @@
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
LEFT JOIN uav_drone dr ON tm.drone_id = dr.id
LEFT JOIN bs_robot br ON tm.robot_id = br.id
<where>
<if test="stationId != null and stationId != ''">
tm.station_id = #{stationId}
......@@ -76,34 +81,30 @@
SELECT
tm.id id,
tor.name stationName,
tw.worker_name peopleName,
COALESCE(br.name, dr.name) robotName,
tor.contact_phone phoneNumber,
tp.worker_name softwareWorker,
ta.worker_name hardwareWorker,
tq.worker_name operationWorker,
tw.phone_number peopleNumber,
tor.contact peopleName,
tp.phone_number softwareNumber,
ta.phone_number hardwareNumber,
tq.phone_number operationNumber
FROM
tb_message tm
LEFT JOIN bs_station tor ON tm.station_id = tor.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 tq ON tm.operation_worker = tq.id
LEFT JOIN bs_station tor ON tm.station_id = tor.id
LEFT JOIN uav_drone dr ON tm.drone_id = dr.id
LEFT JOIN bs_robot br ON tm.robot_id = br.id
<where>
<if test="username != null and username != ''">
tq.username = #{username}
</if>
</where>
</select>
<!-- <select id="queryByworkerid" resultType="com.example.operation_platform.model.vo.PeopleMessageVO">-->
<!-- SELECT-->
<!-- o.id id,-->
<!-- FROM tb_operation o-->
<!-- LEFT JOIN tb_message m-->
<!-- ON m.station_id = o.station_id-->
<!-- AND m.robot_id = o.robot_id-->
<!-- WHERE m.people_id = #{worker_id}-->
<!-- OR m.software_worker = #{worker_id}-->
<!-- OR m.hardware_worker = #{worker_id}-->
<!-- OR m.operation_worker = #{worker_id};-->
<!-- </select>-->
<select id="querypeopleId" resultType="com.example.operation_platform.model.vo.MessageVO">
SELECT
tm.id,
......@@ -174,8 +175,7 @@
tm.station_id = #{stationId}
</select>
<select id="querystationByworker" resultType="com.example.operation_platform.model.vo.MessageVO">
select
tm.id,
select DISTINCT
tm.station_id stationId,
bs.name stationName
from
......
......@@ -63,6 +63,9 @@
<if test="id != null and id != ''">
AND top.id = #{id}
</if>
<if test="username != null and username != ''">
and bw.username = #{username}
</if>
</where>
ORDER BY top.start_time DESC
</select>
......@@ -87,5 +90,86 @@
and top.runlog_or_operation = 0
and tb.start_time > CURRENT_TIMESTAMP
</select>
<select id="queryDoRunLog" resultType="com.example.operation_platform.model.vo.OperationDoVO">
SELECT
top.id AS id,
top.operation_cycle AS operationCycle,
top.start_time AS startTime,
COALESCE(br.name, dr.name) AS robotName,
bs.name AS stationName,
bw.worker_name AS workerName,
top.operation_type AS operationType,
top.status AS status,
top.robot_id AS robotId,
top.station_id AS stationId,
top.item_id AS itemId,
top.finish_time AS finishTime,
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>
top.runlog_or_operation = 1
<if test="robotName != null and robotName != ''">
and br.name LIKE CONCAT('%', #{robotName}, '%')
or dr.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 = #{status}
</if>
<if test="startTime != null">
AND top.start_time &gt;= #{startTime}
</if>
<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>
<if test="username != null and username != ''">
and bw.username = #{username}
</if>
</where>
ORDER BY top.start_time DESC
</select>
<select id="queryRunLogIdList" resultType="java.lang.Integer">
select
top.tb_run_log_id AS runLogId
from tb_operation top
where
top.runlog_or_operation = 1
</select>
<select id="querycount" resultType="com.example.operation_platform.model.vo.AllCountVO">
select
(select count(*) from tb_operation top where top.runlog_or_operation = 0) as operationDoCount,
(select count(*) from tb_operation_job tp where tp.runlog_or_operation = 0) as JobCount,
(select count(*) from tb_operation top where top.runlog_or_operation = 1) as warnCount
</select>
</mapper>
......@@ -60,6 +60,9 @@
<if test="stationId != null and stationId != ''">
and top.station_id = #{stationId}
</if>
<if test="username != null and username != ''">
and bw.username = #{username}
</if>
</where>
ORDER BY top.start_time DESC
</select>
......@@ -68,7 +71,7 @@
SELECT
top.id,
tp.operation_type AS operationType,
tp.operation_id AS operationId,
top.operation_id AS operationId,
bs.name AS stationName,
-- 合并 robot 和 drone 的 name 到 robotName(优先取 robot)
COALESCE(
......@@ -98,6 +101,7 @@
LEFT JOIN tb_worker bw ON tm.operation_worker = bw.id
<where>
top.runlog_or_operation = 0
AND top.finish_status NOT IN (2, 4)
<if test="date != null">
AND #{date} BETWEEN top.start_time AND top.end_time
</if>
......@@ -109,6 +113,9 @@
<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.start_time DESC
</select>
......@@ -238,6 +245,25 @@
ORDER BY start_time ASC
LIMIT 1;
</select>
<update id="updateRunLogStatus" parameterType="com.example.operation_platform.model.vo.OperationJobVO">
UPDATE tb_operation_job
SET finish_status = 4
WHERE id = #{id};
</update>
<!-- 首页轮播展示-->
<select id="queryWarn" resultType="com.example.operation_platform.model.vo.OperationJobVO">
select
COALESCE(br.name, dr.name) AS robotName,
bs.name AS stationName,
tp.operation_type AS operationType
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
LEFT JOIN bs_robot br ON tp.robot_id = br.id
LEFT JOIN uav_drone dr ON tp.drone_id = dr.id
where
top.runlog_or_operation = 1
and top.finish_status = 1
</select>
</mapper>
......@@ -115,6 +115,42 @@
<if test="stationId != null and stationId != ''">
and top.station_id= #{stationId}
</if>
<if test="stationName != null and stationName != ''">
and bs.name LIKE CONCAT('%', #{stationName}, '%')
</if>
order by tor.operation_date desc
</select>
<!-- 异常维保记录包含告警信息,可以根据泵站名或id查询-->
<select id="queryRunLogRecordListAndWarnMessage" resultType="com.example.operation_platform.model.vo.OperationRecordVO">
SELECT
tor.id id,
tor.content content,
tor.img img,
tor.operation_date operationDate,
tor.note note,
top.tb_run_log_id tb_run_log_id
FROM
tb_operation_record tor
LEFT JOIN
tb_operation top ON tor.operation_id = top.id
LEFT JOIN
tb_message tm ON top.station_id = tm.station_id
LEFT JOIN
bs_station bs ON tm.station_id = bs.id
LEFT JOIN
tb_worker tw ON tm.operation_worker=tw.id
<where>
top.runlog_or_operation = 1
<if test="username != null and username != ''">
and bw.username = #{username}
</if>
<if test="stationId != null and stationId != ''">
and top.station_id= #{stationId}
</if>
<if test="stationName != null and stationName != ''">
and bs.name LIKE CONCAT('%', #{stationName}, '%')
</if>
</where>
order by tor.operation_date desc
</select>
</mapper>
\ No newline at end of file
......@@ -19,18 +19,24 @@
on
tw.type = typ.id
</select>
<select id="queryById" resultType="com.example.operation_platform.model.vo.WorkerVO">
<select id="queryMyMessage" resultType="com.example.operation_platform.model.vo.WorkerVO">
select
tw.id id,
tw.worker_name workerName,
tw.img img,
tw.phone_number phoneNumber,
tw.company company,
tw.password password
tw.password password,
typ.worker_type type,
tw.type typeId
from
tb_worker tw
left join
tb_workertype typ
on
tw.type = typ.id
where
tw.id = #{id}
tw.username = #{username}
</select>
<select id="queryByUsername" resultType="com.example.operation_platform.model.vo.WorkerVO">
select
......
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