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

移动端优化

parent 3aad554e
......@@ -53,8 +53,8 @@ public class OperationDoController extends BaseController {
return getDataTable(operationDoService.queryDoRunLog(operationDoDTO));
}
@GetMapping("/count")
public Result<AllCountVO> count() {
return Result.data(operationDoService.querycount());
public Result<AllCountVO> count(String username) {
return Result.data(operationDoService.querycount(username));
}
@GetMapping("/equipment")
public Result<List<OperationDoVO>> equipment() {
......
package com.example.operation_platform.controller;
import com.example.operation_platform.model.dto.MessageDTO;
import com.example.operation_platform.model.dto.OperationJobDTO;
import com.example.operation_platform.model.vo.OperationJobVO;
import com.example.operation_platform.service.OperationJobService;
......
......@@ -34,7 +34,7 @@ public interface OperationDoMapper extends BaseMapper<OperationDoEntity> {
List<OperationDoVO> queryDoRunLog(OperationDoDTO operationDoDTO);
List<Integer> queryRunLogIdList();
AllCountVO querycount();
AllCountVO querycount(String username);
List<RunLogWarnMessageVO> queryNeedMessageRunLog();
List<OperationDoVO> queryEquipment();//获取设备和id
}
......
......@@ -16,7 +16,6 @@ public class OperationJobDTO extends OperationJob {
private String workerName;
private Integer status;
private String operationType;
private Integer finishStatus;
private String username;
private LocalDate date;
private Integer year;
......
......@@ -17,4 +17,5 @@ public class OperationRecordDTO extends TbOperationRecordEntity {
private String username;
private String stationName;
private Integer run_log_id;
private Integer operation_job_id;
}
......@@ -30,6 +30,8 @@ public class TbOperationRecordEntity {
private Integer operationJobId;
@TableField("note")
private String note;
@TableField("runlog_or_operation")
private Integer runLogOrOperation;
}
......@@ -8,6 +8,7 @@ import java.util.Date;
@Data
public class OperationDoVO {
private Integer id;
private String operationJobId;
private String robotName;//设备名称
private String stationName;//泵站名称
private String operationType;//维保任务
......@@ -24,4 +25,6 @@ public class OperationDoVO {
private String droneId;//无人机id
private String lastTime;//最近维保时间
private String runLogId;//告警日志id
private String createTime;//计划创建时间
private String nearTime;//最近维保时间
}
......@@ -24,7 +24,7 @@ public class OperationJobVO extends OperationJob {
private String stationId;
private String itemId;
private String operationItems;
//经维度
private String lon;
private String lat;
......
......@@ -20,6 +20,7 @@ public class OperationRecordVO {
private String note;
private String warnMessage;
private Integer runLogId;
private Date nearTime;
}
......@@ -28,7 +28,7 @@ public interface OperationDoService extends IService<OperationDoEntity> {
List<OperationDoVO> queryDoRunLog(OperationDoDTO operationDoDTO);
List<Integer> queryRunLogIdList();
//首页统计
AllCountVO querycount();
AllCountVO querycount(String username);
List<RunLogWarnMessageVO> queryNeedMessageRunLog();
List<OperationDoVO> queryEquipment();//获取设备和id
......
......@@ -2,7 +2,6 @@ package com.example.operation_platform.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.operation_platform.mapper.GuideMapper;
import com.example.operation_platform.model.dto.GuideDTO;
import com.example.operation_platform.model.entity.GuideEntity;
import com.example.operation_platform.model.vo.GuideVO;
......@@ -10,7 +9,6 @@ import com.example.operation_platform.service.GuideService;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class GuideServiceImpl extends ServiceImpl<GuideMapper, GuideEntity> implements GuideService {
@Override
......@@ -25,4 +23,6 @@ public class GuideServiceImpl extends ServiceImpl<GuideMapper, GuideEntity> impl
public void updateall(GuideDTO guideDTO) {
baseMapper.updateall(guideDTO);
}
}
......@@ -29,38 +29,7 @@ public class OperationDoServiceImpl extends ServiceImpl<OperationDoMapper, Opera
@Override
public List<OperationDoVO> queryDoList(OperationDoDTO operationDoDTO) {
//查看机器人运维项目
List<OperationDoVO> operationVOList = baseMapper.queryDoList(operationDoDTO);
//处理items
Set<String> items = new HashSet<>();
operationVOList.forEach(operationDoVO -> {
if (StringUtils.isNotEmpty(operationDoVO.getItemId())) {
List<String> itemIdList = Arrays.asList(operationDoVO.getItemId().split(","));
itemIdList.forEach(itemId -> items.add(itemId));
}
});
//通过itemId数组查看item信息
List<OperationItem> operationItemList = operationItemService.queryByIdList(Lists.newArrayList(items));
operationVOList.forEach(operationDoVO -> {
if (StringUtils.isNotEmpty(operationDoVO.getItemId())) {
List<String> itemIdList = Arrays.asList(operationDoVO.getItemId().split(","));
itemIdList.forEach(itemId -> {
for (OperationItem operationItem : operationItemList) {
String itemName = null;
if (itemId.equals(operationItem.getId())) {
if (StringUtils.isEmpty(itemName)) {
itemName = operationItem.getOperationItem();
} else {
itemName = itemName + "," + operationItem.getOperationItem();
}
operationDoVO.setOperationItems(itemName);
}
}
});
}
});
return operationVOList;
return baseMapper.queryDoList(operationDoDTO);
}
@Override
......@@ -76,8 +45,8 @@ public class OperationDoServiceImpl extends ServiceImpl<OperationDoMapper, Opera
return this.baseMapper.queryRunLogIdList();
}
@Override
public AllCountVO querycount() {
return this.baseMapper.querycount();
public AllCountVO querycount(String username) {
return this.baseMapper.querycount(username);
}
@Override
public List<RunLogWarnMessageVO> queryNeedMessageRunLog() {
......
......@@ -4,13 +4,11 @@
<select id="queryByName" resultType="com.example.operation_platform.model.vo.GuideVO">
select
tg.id id,
tg.content content,
tg.img img
tg.robotcontent robotcontent,
tg.stationcontent stationcontent
from
tb_guide tg
where
tg.name = #{name}
</select>
<select id = "queryguidelist" resultType="com.example.operation_platform.model.vo.GuideVO">
select
......
......@@ -5,6 +5,7 @@
<select id="queryDoList" resultType="com.example.operation_platform.model.vo.OperationDoVO">
SELECT
top.id AS id,
tj.id AS operationJobId,
top.operation_cycle AS operationCycle,
top.start_time AS startTime,
COALESCE(br.name, dr.name) AS robotName,
......@@ -17,7 +18,9 @@
top.item_id AS itemId,
top.finish_time AS finishTime,
top.drone_id AS droneId,
latest_rd.operation_date AS lastTime,
top.create_time AS createTime,
latest_job.start_time AS lastTime,
latest_record.operation_date AS nearTime,
(
SELECT GROUP_CONCAT(DISTINCT bti.operation_item SEPARATOR ', ')
FROM tb_operation_item bti
......@@ -30,15 +33,21 @@
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 tb_operation_job tj ON top.id = tj.operation_id
LEFT JOIN (
SELECT rd1.*
SELECT operation_id, MAX(start_time) AS start_time
FROM tb_operation_job
GROUP BY operation_id
) latest_job ON top.id = latest_job.operation_id
LEFT JOIN (
SELECT rd1.operation_id, rd1.operation_date
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
) latest_record ON top.id = latest_record.operation_id
<where>
top.runlog_or_operation = 0
<if test="robotName != null and robotName != ''">
......@@ -51,7 +60,7 @@
<if test="workerName != null and workerName != ''">
AND bw.worker_name LIKE CONCAT('%', #{workerName}, '%')
</if>
<if test="status != null and status != ''">
<if test="status != null ">
AND top.status = #{status}
</if>
<if test="startTime != null">
......@@ -60,7 +69,7 @@
<if test="endTime != null">
AND top.start_time &lt;= #{endTime} <!-- 注意字段名是finish_time还是end_time -->
</if>
<if test="id != null and id != ''">
<if test="id != null ">
AND top.id = #{id}
</if>
<if test="username != null and username != ''">
......@@ -93,6 +102,7 @@
<select id="queryDoRunLog" resultType="com.example.operation_platform.model.vo.OperationDoVO">
SELECT
top.id AS id,
tj.id AS operationJobId,
top.operation_cycle AS operationCycle,
top.start_time AS startTime,
COALESCE(br.name, dr.name) AS robotName,
......@@ -105,7 +115,9 @@
top.item_id AS itemId,
top.finish_time AS finishTime,
top.drone_id AS droneId,
latest_rd.operation_date AS lastTime,
top.create_time AS createTime,
latest_job.start_time AS lastTime,
latest_record.operation_date AS nearTime,
(
SELECT GROUP_CONCAT(DISTINCT bti.operation_item SEPARATOR ', ')
FROM tb_operation_item bti
......@@ -118,15 +130,21 @@
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 tb_operation_job tj ON top.id = tj.operation_id
LEFT JOIN (
SELECT operation_id, MAX(start_time) AS start_time
FROM tb_operation_job
GROUP BY operation_id
) latest_job ON top.id = latest_job.operation_id
LEFT JOIN (
SELECT rd1.*
SELECT rd1.operation_id, rd1.operation_date
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
) latest_record ON top.id = latest_record.operation_id
<where>
top.runlog_or_operation = 1
<if test="robotName != null and robotName != ''">
......@@ -139,7 +157,7 @@
<if test="workerName != null and workerName != ''">
AND bw.worker_name LIKE CONCAT('%', #{workerName}, '%')
</if>
<if test="status != null and status != ''">
<if test="status != null ">
AND top.status = #{status}
</if>
<if test="startTime != null">
......@@ -148,7 +166,7 @@
<if test="endTime != null">
AND top.start_time &lt;= #{endTime} <!-- 注意字段名是finish_time还是end_time -->
</if>
<if test="id != null and id != ''">
<if test="id != null ">
AND top.id = #{id}
</if>
<if test="username != null and username != ''">
......@@ -165,11 +183,27 @@
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
(SELECT COUNT(*) FROM tb_operation top
INNER 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))
INNER JOIN tb_worker bw ON tb.operation_worker = bw.id
WHERE top.runlog_or_operation = 0 AND bw.username = #{username}) AS operationDoCount,
(SELECT COUNT(*) FROM tb_operation_job tp
INNER JOIN tb_operation top ON tp.operation_id = top.id
INNER 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))
INNER JOIN tb_worker bw ON tb.operation_worker = bw.id
WHERE tp.finish_status = 1 AND bw.username = #{username}) AS JobCount,
(SELECT COUNT(*) FROM tb_operation top
INNER 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))
INNER JOIN tb_worker bw ON tb.operation_worker = bw.id
WHERE top.runlog_or_operation = 1 AND bw.username = #{username}) AS warnCount
</select>
<!-- 查询运行告警信息,且在进行中的任务-->
<select id="queryNeedMessageRunLog" resultType="com.example.operation_platform.model.vo.RunLogWarnMessageVO">
......
......@@ -103,7 +103,7 @@
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
AND top.start_time like concat('%',#{date},'%')
</if>
<if test="year != null and month != null">
AND
......@@ -156,12 +156,12 @@
LEFT JOIN tb_worker bw ON tm.operation_worker = bw.id
<where>
<if test="stationId != null and stationId != ''">
and tp.station_id = #{stationId}
tp.station_id = #{stationId}
</if>
<if test="username != null and username != ''">
and bw.username = #{username}
</if>
<if test="finishStatus != null and finishStatus != ''">
<if test="finishStatus != null">
and top.finish_status = #{finishStatus}
</if>
</where>
......
......@@ -4,27 +4,35 @@
<!--维保记录查询-->
<select id="queryrecordList" 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,
tw.worker_name workerName,
tor.note note
tor.id AS id,
COALESCE(br.name, dr.name) AS robotName,
tor.content AS content,
top.operation_type AS operationType,
tor.img AS img,
tor.operation_date AS operationDate,
bs.name AS stationName,
tw.worker_name AS workerName,
tor.note AS note,
latest_job.start_time AS nearTime
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 ))
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
LEFT JOIN tb_worker tw ON tb.operation_worker = tw.id
LEFT JOIN (
SELECT
operation_id,
MAX(start_time) AS start_time
FROM
tb_operation_job
GROUP BY
operation_id
) latest_job ON top.id = latest_job.operation_id
<where>
tor.runlog_or_operation = 0
<if test="operationId != null and operationId != ''">
......@@ -111,7 +119,7 @@
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
<where>
tor.runlog_or_operation = 1
<if test="stationId != null and stationId != ''">
and top.station_id= #{stationId}
......@@ -119,6 +127,10 @@
<if test="stationName != null and stationName != ''">
and bs.name LIKE CONCAT('%', #{stationName}, '%')
</if>
<if test="operationJobId != null ">
and tor.operation_job_id= #{operationJobId}
</if>
</where>
order by tor.operation_date desc
</select>
<!-- 异常维保记录包含告警信息,可以根据泵站名或id查询-->
......
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