Commit 1d3f1149 by HlQ

[add]

1.添加异常 mall 列表接口
2.字段补充
1 parent 2b9ddb87
......@@ -45,6 +45,12 @@ public class MallController {
return mallService.listAttention(dto);
}
@GetMapping("/errorAttention")
@SaCheckPermission(value = "mall:attention:listError", orRole = "admin")
public Page<MallVO> listErrorAttention(MallDTO dto) {
return mallService.listErrorAttention(dto);
}
@PostMapping("/attention")
@SaCheckPermission(value = "mall:attention:edit", orRole = "admin")
public String attention(@RequestBody List<MallDTO> dtoList) {
......
......@@ -24,6 +24,12 @@ public class EventRecord {
private String agentUid;
/**
* agent类型 1:store,2:mall
*/
@TableField(value = "agent_type")
private Short agentType;
/**
* 所属集团uid
*/
@TableField(value = "account_uid")
......
......@@ -9,6 +9,7 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.dreamlu.iot.mqtt.codec.MqttQoS;
import net.dreamlu.iot.mqtt.spring.client.MqttClientTemplate;
import org.dromara.hutool.core.collection.CollUtil;
import org.dromara.hutool.core.lang.Assert;
import org.dromara.hutool.core.lang.Opt;
import org.dromara.hutool.core.text.StrUtil;
......@@ -16,10 +17,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import vion.dto.monitor.MallDTO;
import vion.mapper.monitor.MallMapper;
import vion.model.monitor.EventRecord;
import vion.model.monitor.MAccount;
import vion.model.monitor.Mall;
import vion.model.monitor.RAgentEvent;
import vion.model.monitor.*;
import vion.service.monitor.IEventRecordService;
import vion.service.monitor.IMAccountService;
import vion.service.monitor.IMallService;
......@@ -78,9 +76,11 @@ public class MallServiceImpl extends MPJBaseServiceImpl<MallMapper, Mall> implem
var wrapper = new MPJLambdaWrapper<>(converter.convert(dto, Mall.class))
.selectAll(Mall.class)
.selectAs(MAccount::getName, MallVO::getAccountName)
.selectAs(Agent::getHostname, MallVO::getHostname)
.leftJoin(MAccount.class, MAccount::getUid, Mall::getAccountUid)
.leftJoin(Agent.class, Agent::getUid, Mall::getAgentUid)
.eq(Mall::getAttention, 1)
.orderByDesc(Mall::getUpdateTime);
.orderByDesc(Mall::getUid, Mall::getUpdateTime);
var mallVOPage = this.selectJoinListPage(Page.of(dto.getPageNum(), dto.getPageSize()), MallVO.class, wrapper);
Opt.ofEmptyAble(mallVOPage.getRecords())
.ifPresent(r -> {
......@@ -91,8 +91,44 @@ public class MallServiceImpl extends MPJBaseServiceImpl<MallMapper, Mall> implem
.in("mall_uid", mallUidList)
.orderByDesc("mall_uid", "create_time");
var eventRecordList = eventRecordService.list(eventRecWrapper);
var mallUid2SelfMap = eventRecordList.stream().collect(Collectors.groupingBy(EventRecord::getMallUid));
var mallUid2RecMap = eventRecordList.stream().collect(Collectors.groupingBy(EventRecord::getMallUid));
var agentEventList = agentEventService.lambdaQuery().in(RAgentEvent::getMallUid, mallUidList).list();
var mallUid2AgentEventMap = agentEventList.stream().collect(Collectors.groupingBy(RAgentEvent::getMallUid));
r.forEach(tmp -> {
tmp.setEventRecordList(mallUid2RecMap.getOrDefault(tmp.getUid(), List.of()));
tmp.setAgentEventList(mallUid2AgentEventMap.getOrDefault(tmp.getUid(), List.of()));
});
});
return mallVOPage;
}
@Override
public Page<MallVO> listErrorAttention(MallDTO dto) {
var eventRecWrapper = Wrappers.<EventRecord>query()
.select("DISTINCT on (mall_uid) *")
.eq("agent_type", dto.getAgentType())
.ne("status", 1)
.orderByDesc("mall_uid", "create_time");
var eventRecordList = eventRecordService.list(eventRecWrapper);
if (CollUtil.isEmpty(eventRecordList)) {
return null;
}
var mallUidList = eventRecordList.stream().map(EventRecord::getMallUid).toList();
var wrapper = new MPJLambdaWrapper<>(converter.convert(dto, Mall.class))
.selectAll(Mall.class)
.selectAs(MAccount::getName, MallVO::getAccountName)
.selectAs(Agent::getHostname, MallVO::getHostname)
.leftJoin(MAccount.class, MAccount::getUid, Mall::getAccountUid)
.leftJoin(Agent.class, Agent::getUid, Mall::getAgentUid)
.in(Mall::getUid, mallUidList)
.orderByDesc(Mall::getUid, Mall::getUpdateTime);
var mallVOPage = this.selectJoinListPage(Page.of(dto.getPageNum(), dto.getPageSize()), MallVO.class, wrapper);
Opt.ofEmptyAble(mallVOPage.getRecords())
.ifPresent(r -> {
var mallUid2SelfMap = eventRecordList.stream().collect(Collectors.groupingBy(EventRecord::getMallUid));
r.forEach(tmp -> tmp.setEventRecordList(mallUid2SelfMap.get(tmp.getUid())));
});
return mallVOPage;
......
......@@ -23,6 +23,8 @@ public interface IMallService extends MPJBaseService<Mall> {
Page<MallVO> listAttention(MallDTO dto);
Page<MallVO> listErrorAttention(MallDTO dto);
String attention(List<MallDTO> dtoList);
String attentionByAccount(String accountUid);
......
......@@ -3,6 +3,7 @@ package vion.vo.monitor;
import lombok.Getter;
import lombok.Setter;
import vion.model.monitor.EventRecord;
import vion.model.monitor.RAgentEvent;
import java.time.LocalDateTime;
import java.util.List;
......@@ -76,4 +77,10 @@ public class MallVO {
private LocalDateTime updateTime;
private List<EventRecord> eventRecordList;
private List<RAgentEvent> agentEventList;
/**
* 主机名
*/
private String hostname;
}
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!