App事件一键已读功能调整
This commit is contained in:
@@ -6,7 +6,6 @@ import com.njcn.csdevice.api.fallback.CsDeviceUserClientFallbackFactory;
|
||||
import com.njcn.csdevice.pojo.param.UserDevParam;
|
||||
import com.njcn.csdevice.pojo.po.CsDeviceUserPO;
|
||||
import com.njcn.csdevice.pojo.vo.DevUserVO;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
@@ -36,6 +35,8 @@ public interface CsDeviceUserFeignClient {
|
||||
HttpResult<DevUserVO> queryUserById(@RequestParam("devId") String devId);
|
||||
|
||||
@PostMapping("/getList")
|
||||
@ApiOperation("根据设备集合获取数据")
|
||||
HttpResult<List<CsDeviceUserPO>> getList(@RequestBody UserDevParam param);
|
||||
|
||||
@PostMapping("/getIdList")
|
||||
HttpResult<List<String>> getIdList(@RequestParam("param") String param);
|
||||
}
|
||||
|
||||
@@ -64,6 +64,12 @@ public class CsDeviceUserClientFallbackFactory implements FallbackFactory<CsDevi
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<String>> getIdList(String param) {
|
||||
log.error("{}异常,降级处理,异常为:{}","获取事件id集合数据异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.csdevice.enums.DeviceOperate;
|
||||
import com.njcn.csdevice.mapper.CsDeviceUserPOMapper;
|
||||
import com.njcn.csdevice.pojo.param.UserDevParam;
|
||||
import com.njcn.csdevice.pojo.po.CsDeviceUserPO;
|
||||
import com.njcn.csdevice.pojo.vo.DevCountVO;
|
||||
@@ -13,6 +14,7 @@ import com.njcn.csdevice.pojo.vo.DevUserVO;
|
||||
import com.njcn.csdevice.service.CsDeviceUserPOService;
|
||||
import com.njcn.web.advice.DeviceLog;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
@@ -21,7 +23,9 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
/**
|
||||
@@ -37,6 +41,8 @@ import java.util.List;
|
||||
public class DeviceUserController extends BaseController {
|
||||
|
||||
private final CsDeviceUserPOService csDeviceUserPOService;
|
||||
private final CsDeviceUserPOMapper csDeviceUserPOMapper;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/add")
|
||||
@ApiOperation("新增设备扫码设备用户绑定")
|
||||
@@ -174,4 +180,19 @@ public class DeviceUserController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getIdList")
|
||||
@ApiOperation("获取事件id集合")
|
||||
@ApiImplicitParam(name = "param", value = "参数", required = true)
|
||||
public HttpResult<List<String>> getIdList(@RequestParam("param") String param){
|
||||
String methodDescribe = getMethodDescribe("getIdList");
|
||||
List<String> list = new ArrayList<>();
|
||||
if (Objects.equals(param, "1")) {
|
||||
list = csDeviceUserPOMapper.queryTempHarmonic(RequestUtil.getUserIndex(),null,null,null);
|
||||
} else if (Objects.equals(param, "3")) {
|
||||
list = csDeviceUserPOMapper.queryAlarmEvent(RequestUtil.getUserIndex(),null,null,null);
|
||||
}
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,15 +17,15 @@ import java.util.List;
|
||||
public interface CsDeviceUserPOMapper extends BaseMapper<CsDeviceUserPO> {
|
||||
|
||||
//查询暂态事件(未读)
|
||||
int queryTempEvent(@Param("userId") String userId, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("ids") List<String> ids);
|
||||
List<String> queryTempEvent(@Param("userId") String userId, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("ids") List<String> ids);
|
||||
|
||||
//查询稳态事件(未读)
|
||||
int queryTempHarmonic(@Param("userId") String userId, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("ids") List<String> ids);
|
||||
List<String> queryTempHarmonic(@Param("userId") String userId, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("ids") List<String> ids);
|
||||
|
||||
//查询告警事件(未读)
|
||||
int queryAlarmEvent(@Param("userId") String userId, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("ids") List<String> ids);
|
||||
List<String> queryAlarmEvent(@Param("userId") String userId, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("ids") List<String> ids);
|
||||
|
||||
//查询运行事件(未读)
|
||||
int queryRunEvent(@Param("userId") String userId, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("ids") List<String> ids);
|
||||
List<String> queryRunEvent(@Param("userId") String userId, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("ids") List<String> ids);
|
||||
|
||||
}
|
||||
@@ -18,9 +18,9 @@
|
||||
</sql>
|
||||
|
||||
|
||||
<select id="queryTempEvent" resultType="java.lang.Integer">
|
||||
<select id="queryTempEvent" resultType="java.lang.String">
|
||||
SELECT
|
||||
COUNT(1)
|
||||
t1.event_id
|
||||
FROM
|
||||
cs_event_user t1 right join cs_event t2 on t1.event_id = t2.id
|
||||
WHERE
|
||||
@@ -35,9 +35,9 @@
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="queryAlarmEvent" resultType="java.lang.Integer">
|
||||
<select id="queryAlarmEvent" resultType="java.lang.String">
|
||||
SELECT
|
||||
COUNT(1)
|
||||
t1.event_id
|
||||
FROM
|
||||
cs_event_user t1 right join cs_alarm t2 on t1.event_id = t2.id
|
||||
WHERE
|
||||
@@ -52,9 +52,9 @@
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="queryRunEvent" resultType="java.lang.Integer">
|
||||
<select id="queryRunEvent" resultType="java.lang.String">
|
||||
SELECT
|
||||
COUNT(1)
|
||||
t1.event_id
|
||||
FROM
|
||||
cs_event_user t1 right join cs_event t2 on t1.event_id = t2.id
|
||||
WHERE
|
||||
@@ -69,9 +69,9 @@
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="queryTempHarmonic" resultType="java.lang.Integer">
|
||||
<select id="queryTempHarmonic" resultType="java.lang.String">
|
||||
SELECT
|
||||
COUNT(1)
|
||||
t1.event_id
|
||||
FROM
|
||||
cs_event_user t1 right join cs_harmonic t2 on t1.event_id = t2.id
|
||||
WHERE
|
||||
|
||||
@@ -163,17 +163,17 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
|
||||
return vo;
|
||||
}
|
||||
//获取未读事件数量
|
||||
int eventCount = this.baseMapper.queryTempEvent(RequestUtil.getUserIndex(),PublicDataUtils.calculateMonthStart(time),PublicDataUtils.calculateMonthEnd(time),null);
|
||||
vo.setEventCount(eventCount);
|
||||
List<String> eventCount = this.baseMapper.queryTempEvent(RequestUtil.getUserIndex(),PublicDataUtils.calculateMonthStart(time),PublicDataUtils.calculateMonthEnd(time),null);
|
||||
vo.setEventCount(CollectionUtil.isNotEmpty(eventCount)?eventCount.size():0);
|
||||
|
||||
int harmonicCount = this.baseMapper.queryTempHarmonic(RequestUtil.getUserIndex(),PublicDataUtils.calculateMonthStart(time),PublicDataUtils.calculateMonthEnd(time),null);
|
||||
vo.setHarmonicCount(harmonicCount);
|
||||
List<String> harmonicCount = this.baseMapper.queryTempHarmonic(RequestUtil.getUserIndex(),PublicDataUtils.calculateMonthStart(time),PublicDataUtils.calculateMonthEnd(time),null);
|
||||
vo.setHarmonicCount(CollectionUtil.isNotEmpty(harmonicCount)?harmonicCount.size():0);
|
||||
|
||||
int alarmCount = this.baseMapper.queryAlarmEvent(RequestUtil.getUserIndex(),PublicDataUtils.calculateMonthStart(time),PublicDataUtils.calculateMonthEnd(time),null);
|
||||
vo.setAlarmCount(alarmCount);
|
||||
List<String> alarmCount = this.baseMapper.queryAlarmEvent(RequestUtil.getUserIndex(),PublicDataUtils.calculateMonthStart(time),PublicDataUtils.calculateMonthEnd(time),null);
|
||||
vo.setAlarmCount(CollectionUtil.isNotEmpty(alarmCount)?alarmCount.size():0);
|
||||
|
||||
int runCount = this.baseMapper.queryRunEvent(RequestUtil.getUserIndex(),PublicDataUtils.calculateMonthStart(time),PublicDataUtils.calculateMonthEnd(time),null);
|
||||
vo.setRunCount(runCount);
|
||||
List<String> runCount = this.baseMapper.queryRunEvent(RequestUtil.getUserIndex(),PublicDataUtils.calculateMonthStart(time),PublicDataUtils.calculateMonthEnd(time),null);
|
||||
vo.setRunCount(CollectionUtil.isNotEmpty(runCount)?runCount.size():0);
|
||||
|
||||
//note 当前工程数据
|
||||
//当前工程id
|
||||
@@ -228,18 +228,18 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
|
||||
}
|
||||
//获取未读事件数量
|
||||
if (CollectionUtil.isNotEmpty(currentLineIds)) {
|
||||
int eventCount2 = this.baseMapper.queryTempEvent(RequestUtil.getUserIndex(),PublicDataUtils.calculateMonthStart(time),PublicDataUtils.calculateMonthEnd(time),currentLineIds);
|
||||
vo.setCurrentEventCount(eventCount2);
|
||||
List<String> eventCount2 = this.baseMapper.queryTempEvent(RequestUtil.getUserIndex(),PublicDataUtils.calculateMonthStart(time),PublicDataUtils.calculateMonthEnd(time),currentLineIds);
|
||||
vo.setCurrentEventCount(CollectionUtil.isNotEmpty(eventCount2)?eventCount2.size():0);
|
||||
|
||||
int harmonicCount2 = this.baseMapper.queryTempHarmonic(RequestUtil.getUserIndex(),PublicDataUtils.calculateMonthStart(time),PublicDataUtils.calculateMonthEnd(time),currentLineIds);
|
||||
vo.setCurrentHarmonicCount(harmonicCount2);
|
||||
List<String> harmonicCount2 = this.baseMapper.queryTempHarmonic(RequestUtil.getUserIndex(),PublicDataUtils.calculateMonthStart(time),PublicDataUtils.calculateMonthEnd(time),currentLineIds);
|
||||
vo.setCurrentHarmonicCount(CollectionUtil.isNotEmpty(harmonicCount2)?harmonicCount2.size():0);
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(currentDevIds)) {
|
||||
int alarmCount2 = this.baseMapper.queryAlarmEvent(RequestUtil.getUserIndex(),PublicDataUtils.calculateMonthStart(time),PublicDataUtils.calculateMonthEnd(time),currentDevIds);
|
||||
vo.setCurrentAlarmCount(alarmCount2);
|
||||
List<String> alarmCount2 = this.baseMapper.queryAlarmEvent(RequestUtil.getUserIndex(),PublicDataUtils.calculateMonthStart(time),PublicDataUtils.calculateMonthEnd(time),currentDevIds);
|
||||
vo.setCurrentAlarmCount(CollectionUtil.isNotEmpty(alarmCount2)?alarmCount2.size():0);
|
||||
|
||||
int runCount2 = this.baseMapper.queryRunEvent(RequestUtil.getUserIndex(),PublicDataUtils.calculateMonthStart(time),PublicDataUtils.calculateMonthEnd(time),currentDevIds);
|
||||
vo.setCurrentRunCount(runCount2);
|
||||
List<String> runCount2 = this.baseMapper.queryRunEvent(RequestUtil.getUserIndex(),PublicDataUtils.calculateMonthStart(time),PublicDataUtils.calculateMonthEnd(time),currentDevIds);
|
||||
vo.setCurrentRunCount(CollectionUtil.isNotEmpty(runCount2)?runCount2.size():0);
|
||||
}
|
||||
}
|
||||
return vo;
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.njcn.csharmonic.param;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -37,6 +35,9 @@ public class CsEventUserQueryParam {
|
||||
*/
|
||||
private List<String> target;
|
||||
|
||||
/**
|
||||
* '暂态事件'0 '稳态事件'1 '运行告警'3 '运行事件'2
|
||||
*/
|
||||
private String type;
|
||||
/**
|
||||
* 状态(0:未读取 1:已读取)
|
||||
|
||||
@@ -7,9 +7,11 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.csp.sentinel.util.StringUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.constant.LogInfo;
|
||||
import com.njcn.csdevice.api.CsDeviceUserFeignClient;
|
||||
import com.njcn.csdevice.api.CsLedgerFeignClient;
|
||||
import com.njcn.csdevice.api.NodeFeignClient;
|
||||
import com.njcn.csdevice.constant.DataParam;
|
||||
@@ -26,6 +28,7 @@ import com.njcn.csharmonic.pojo.po.CsEventPO;
|
||||
import com.njcn.csharmonic.pojo.po.CsEventUserPO;
|
||||
import com.njcn.csharmonic.pojo.vo.EventDetailVO;
|
||||
import com.njcn.csharmonic.service.CsEventUserPOService;
|
||||
import com.njcn.harmonic.utils.PublicDataUtils;
|
||||
import com.njcn.influx.pojo.dto.EventDataSetDTO;
|
||||
import com.njcn.influx.service.EvtDataService;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
@@ -64,6 +67,7 @@ public class CsEventUserPOServiceImpl extends ServiceImpl<CsEventUserPOMapper, C
|
||||
private final EleEvtFeignClient eleEvtFeignClient;
|
||||
private final CsEventPOMapper csEventPOMapper;
|
||||
private final NodeFeignClient nodeFeignClient;
|
||||
private final CsDeviceUserFeignClient csDeviceUserFeignClient;
|
||||
|
||||
@Override
|
||||
public Integer queryEventCount(CsEventUserQueryParam csEventUserQueryParam) {
|
||||
@@ -207,21 +211,39 @@ public class CsEventUserPOServiceImpl extends ServiceImpl<CsEventUserPOMapper, C
|
||||
csEventUserQueryParam.setUserId(RequestUtil.getUserIndex());
|
||||
//getEventIds传空一键已读
|
||||
if(CollectionUtil.isEmpty(csEventUserQueryParam.getEventIds())){
|
||||
List<EventDetailVO> list = this.queryUserEventList(csEventUserQueryParam);
|
||||
if(!CollectionUtils.isEmpty(list)){
|
||||
List<String> collect = list.stream().map(EventDetailVO::getId).collect(Collectors.toList());
|
||||
|
||||
this.lambdaUpdate().in(CsEventUserPO::getEventId,collect).
|
||||
eq(CsEventUserPO::getUserId,csEventUserQueryParam.getUserId()).
|
||||
set(CsEventUserPO::getStatus,1).update();
|
||||
//暂态数据和运行事件和之前一样逻辑
|
||||
if (Objects.equals(csEventUserQueryParam.getType(), "0") || Objects.equals(csEventUserQueryParam.getType(), "2")) {
|
||||
List<EventDetailVO> list = this.queryUserEventList(csEventUserQueryParam);
|
||||
if(!CollectionUtils.isEmpty(list)){
|
||||
List<String> collect = list.stream().map(EventDetailVO::getId).collect(Collectors.toList());
|
||||
this.lambdaUpdate().in(CsEventUserPO::getEventId,collect).
|
||||
eq(CsEventUserPO::getUserId,csEventUserQueryParam.getUserId()).
|
||||
set(CsEventUserPO::getStatus,1).update();
|
||||
}
|
||||
}
|
||||
|
||||
}else {
|
||||
//稳态
|
||||
else if (Objects.equals(csEventUserQueryParam.getType(), "1")) {
|
||||
List<String> harmonicList = csDeviceUserFeignClient.getIdList("1").getData();
|
||||
if (CollectionUtil.isNotEmpty(harmonicList)) {
|
||||
this.lambdaUpdate().in(CsEventUserPO::getEventId,harmonicList).
|
||||
eq(CsEventUserPO::getUserId,RequestUtil.getUserIndex()).
|
||||
set(CsEventUserPO::getStatus,1).update();
|
||||
}
|
||||
}
|
||||
//运行告警
|
||||
else if (Objects.equals(csEventUserQueryParam.getType(), "3")) {
|
||||
List<String> alarmList = csDeviceUserFeignClient.getIdList("3").getData();
|
||||
if (CollectionUtil.isNotEmpty(alarmList)) {
|
||||
this.lambdaUpdate().in(CsEventUserPO::getEventId,alarmList).
|
||||
eq(CsEventUserPO::getUserId,RequestUtil.getUserIndex()).
|
||||
set(CsEventUserPO::getStatus,1).update();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.lambdaUpdate().in(CsEventUserPO::getEventId,csEventUserQueryParam.getEventIds()).
|
||||
eq(CsEventUserPO::getUserId,csEventUserQueryParam.getUserId()).
|
||||
set(CsEventUserPO::getStatus,1).update();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user