Commit e77da2e7 by HlQ

[add]

1.添加指标批量关联 mall
2.指标添加 typeList 字段
1 parent e69cfbfe
......@@ -3,6 +3,7 @@ package vion.controller.monitor;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
import org.dromara.hutool.core.collection.CollUtil;
import org.dromara.hutool.core.data.id.IdUtil;
import org.springframework.web.bind.annotation.*;
import vion.dto.monitor.EventDTO;
......@@ -29,6 +30,7 @@ public class EventController {
@SaCheckPermission(value = "event:list", orRole = "admin")
public Page<Event> list(Event event) {
return eventService.lambdaQuery(event)
.in(CollUtil.isNotEmpty(event.getTypeList()), Event::getType, event.getTypeList())
.orderByDesc(Event::getCreateTime)
.page(Page.of(event.getPageNum(), event.getPageSize()));
}
......@@ -76,4 +78,10 @@ public class EventController {
public String unbind(@PathVariable String agentUid, @PathVariable String mallUid, List<Long> idList) {
return agentEventService.unbind(agentUid, mallUid, idList);
}
@PostMapping("/bind/batch/{agentUid}")
@SaCheckPermission(value = "event:bind:batch", orRole = "admin")
public String bindBatch(@PathVariable String agentUid, @RequestBody RAgentEvent dto) {
return agentEventService.bindBatch(agentUid, dto);
}
}
......@@ -10,6 +10,7 @@ import vion.dto.monitor.EventDTO;
import vion.vo.monitor.EventVO;
import java.time.LocalDateTime;
import java.util.List;
/**
* 监测事件
......@@ -109,4 +110,7 @@ public class Event extends BaseDTO {
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
private LocalDateTime updateTime;
@TableField(exist = false)
private List<Long> typeList;
}
\ No newline at end of file
......@@ -6,6 +6,7 @@ import lombok.Setter;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
/**
* 项目监测关联
......@@ -88,4 +89,7 @@ import java.time.LocalDateTime;
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
private LocalDateTime updateTime;
@TableField(exist = false)
private List<String> mallUidList;
}
\ No newline at end of file
......@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.base.MPJBaseService;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.RequestParam;
import vion.dto.StatusDTO;
import vion.dto.StoreDTO;
import vion.model.Store;
......@@ -27,7 +26,7 @@ public interface IStoreService extends MPJBaseService<Store> {
String addTag(Long id, List<Long> tagIdList);
List<Map<String, Number>> fileDetail(@RequestParam List<Long> storeIdList);
List<Map<String, Number>> fileDetail(List<Long> storeIdList);
Boolean logNotify(Long id, String[] userIdStr);
......
package vion.service.impl.monitor;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.yulichang.base.MPJBaseServiceImpl;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
......@@ -8,7 +9,9 @@ import net.dreamlu.iot.mqtt.spring.client.MqttClientTemplate;
import org.dromara.hutool.core.collection.CollUtil;
import org.dromara.hutool.core.text.StrUtil;
import org.springframework.stereotype.Service;
import vion.mapper.monitor.MallMapper;
import vion.mapper.monitor.RAgentEventMapper;
import vion.model.monitor.Mall;
import vion.model.monitor.RAgentEvent;
import vion.service.monitor.IRAgentEventService;
import vion.utils.JsonUtil;
......@@ -28,6 +31,7 @@ import java.util.stream.Collectors;
@Slf4j
public class RAgentEventServiceImpl extends MPJBaseServiceImpl<RAgentEventMapper, RAgentEvent> implements IRAgentEventService {
private final MallMapper mallMapper;
private final MqttClientTemplate client;
@Override
......@@ -77,4 +81,43 @@ public class RAgentEventServiceImpl extends MPJBaseServiceImpl<RAgentEventMapper
MqttQoS.QOS2));
return this.removeBatchByIds(idList) ? "解绑成功" : "解绑失败";
}
@Override
public String bindBatch(String agentUid, RAgentEvent dto) {
if (StrUtil.isNotBlank(dto.getAccountUid())) {
var accountUid = dto.getAccountUid();
var mallList = mallMapper.selectList(Wrappers.<Mall>lambdaQuery().eq(Mall::getAccountUid, accountUid));
var agentEventList = mallList.stream().map(m -> {
var rAgentEvent = new RAgentEvent();
rAgentEvent.setAgentUid(agentUid);
rAgentEvent.setAccountUid(accountUid);
rAgentEvent.setMallUid(m.getUid());
rAgentEvent.setEventUid(dto.getEventUid());
rAgentEvent.setEventType(dto.getEventType());
rAgentEvent.setCron(dto.getCron());
rAgentEvent.setThreshold(dto.getThreshold());
rAgentEvent.setControlSwitch((short) 1);
return rAgentEvent;
}).toList();
this.saveBatch(agentEventList);
}
if (CollUtil.isNotEmpty(dto.getMallUidList())) {
var mallUidList = dto.getMallUidList();
var mallList = mallMapper.selectList(Wrappers.<Mall>lambdaQuery().in(Mall::getUid, mallUidList));
var agentEventList = mallList.stream().map(m -> {
var rAgentEvent = new RAgentEvent();
rAgentEvent.setAgentUid(agentUid);
rAgentEvent.setAccountUid(m.getAccountUid());
rAgentEvent.setMallUid(m.getUid());
rAgentEvent.setEventUid(dto.getEventUid());
rAgentEvent.setEventType(dto.getEventType());
rAgentEvent.setCron(dto.getCron());
rAgentEvent.setThreshold(dto.getThreshold());
rAgentEvent.setControlSwitch((short) 1);
return rAgentEvent;
}).toList();
this.saveBatch(agentEventList);
}
return "批量绑定成功";
}
}
......@@ -15,4 +15,6 @@ public interface IRAgentEventService extends MPJBaseService<RAgentEvent> {
String unbind(String agentUid, String mallUid, List<Long> idList);
String bindBatch(String agentUid, RAgentEvent dto);
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!