1.添加登录用户查询监测点,设备,电能质量用户公共接口
This commit is contained in:
@@ -23,9 +23,12 @@ public interface CsCommTerminalFeignClient {
|
|||||||
@GetMapping("lineUnitDetail")
|
@GetMapping("lineUnitDetail")
|
||||||
HttpResult<PqsDeviceUnit> lineUnitDetail(@RequestParam("lineId") String lineId);
|
HttpResult<PqsDeviceUnit> lineUnitDetail(@RequestParam("lineId") String lineId);
|
||||||
|
|
||||||
@PostMapping("getDevIdsByUser")
|
@GetMapping("getDevIdsByUser")
|
||||||
HttpResult<List<String>> getDevIdsByUser(@RequestBody String userId);
|
HttpResult<List<String>> getDevIdsByUser(@RequestParam("userId") String userId);
|
||||||
|
|
||||||
@PostMapping("getLineIdsByUser")
|
@GetMapping("getLineIdsByUser")
|
||||||
HttpResult<List<String>> getLineIdsByUser(@RequestBody String userId);
|
HttpResult<List<String>> getLineIdsByUser(@RequestParam("userId") String userId);
|
||||||
|
|
||||||
|
@GetMapping("getPqUserIdsByUser")
|
||||||
|
HttpResult<List<String>> getPqUserIdsByUser(@RequestParam("userId") String userId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,13 +36,19 @@ public class CsCommTerminalFeignClientFallbackFactory implements FallbackFactory
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HttpResult<List<String>> getDevIdsByUser(String userId) {
|
public HttpResult<List<String>> getDevIdsByUser(String userId) {
|
||||||
log.error("{}异常,降级处理,异常为:{}","查询分组",cause.toString());
|
log.error("{}异常,降级处理,异常为:{}","根据登录用户id获取用户所有设备id集合",cause.toString());
|
||||||
throw new BusinessException(finalExceptionEnum);
|
throw new BusinessException(finalExceptionEnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HttpResult<List<String>> getLineIdsByUser(String userId) {
|
public HttpResult<List<String>> getLineIdsByUser(String userId) {
|
||||||
log.error("{}异常,降级处理,异常为:{}","查询分组",cause.toString());
|
log.error("{}异常,降级处理,异常为:{}","根据登录用户id获取用户所有监测点id集合",cause.toString());
|
||||||
|
throw new BusinessException(finalExceptionEnum);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HttpResult<List<String>> getPqUserIdsByUser(String userId) {
|
||||||
|
log.error("{}异常,降级处理,异常为:{}","根据登录用户id获取电能质量用户id集合",cause.toString());
|
||||||
throw new BusinessException(finalExceptionEnum);
|
throw new BusinessException(finalExceptionEnum);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -52,10 +52,10 @@ public class CsCommTerminalController extends BaseController {
|
|||||||
* 根据用户获取设备信息
|
* 根据用户获取设备信息
|
||||||
*/
|
*/
|
||||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
@PostMapping("/getDevIdsByUser")
|
@GetMapping("/getDevIdsByUser")
|
||||||
@ApiOperation("根据监测点id获取数据单位")
|
@ApiOperation("根据登录用户id获取用户所有设备id集合")
|
||||||
@ApiImplicitParam(name = "lineId", value = "实体", required = true)
|
@ApiImplicitParam(name = "userId", value = "用户id", required = true)
|
||||||
public HttpResult<List<String>> getDevIdsByUser(@RequestBody String userId) {
|
public HttpResult<List<String>> getDevIdsByUser(@RequestParam("userId") String userId) {
|
||||||
String methodDescribe = getMethodDescribe("getDevIdsByUser");
|
String methodDescribe = getMethodDescribe("getDevIdsByUser");
|
||||||
List<String> result;
|
List<String> result;
|
||||||
List<CsDeviceUserPO> poList = csDeviceUserPOService.lambdaQuery().select(CsDeviceUserPO::getDeviceId)
|
List<CsDeviceUserPO> poList = csDeviceUserPOService.lambdaQuery().select(CsDeviceUserPO::getDeviceId)
|
||||||
@@ -73,10 +73,10 @@ public class CsCommTerminalController extends BaseController {
|
|||||||
* 根据用户获取设备信息
|
* 根据用户获取设备信息
|
||||||
*/
|
*/
|
||||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
@PostMapping("/getLineIdsByUser")
|
@GetMapping("/getLineIdsByUser")
|
||||||
@ApiOperation("根据监测点id获取数据单位")
|
@ApiOperation("根据登录用户id获取用户所有监测点id集合")
|
||||||
@ApiImplicitParam(name = "lineId", value = "实体", required = true)
|
@ApiImplicitParam(name = "userId", value = "用户id", required = true)
|
||||||
public HttpResult<List<String>> getLineIdsByUser(@RequestBody String userId) {
|
public HttpResult<List<String>> getLineIdsByUser(@RequestParam("userId") String userId) {
|
||||||
String methodDescribe = getMethodDescribe("getLineIdsByUser");
|
String methodDescribe = getMethodDescribe("getLineIdsByUser");
|
||||||
List<CsDeviceUserPO> devList = csDeviceUserPOService.lambdaQuery().select(CsDeviceUserPO::getDeviceId)
|
List<CsDeviceUserPO> devList = csDeviceUserPOService.lambdaQuery().select(CsDeviceUserPO::getDeviceId)
|
||||||
.and(w->w.eq(CsDeviceUserPO::getPrimaryUserId,userId).or().eq(CsDeviceUserPO::getSubUserId,userId))
|
.and(w->w.eq(CsDeviceUserPO::getPrimaryUserId,userId).or().eq(CsDeviceUserPO::getSubUserId,userId))
|
||||||
@@ -96,6 +96,34 @@ public class CsCommTerminalController extends BaseController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据用户获取设备信息
|
||||||
|
*/
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@GetMapping("/getPqUserIdsByUser")
|
||||||
|
@ApiOperation("根据登录用户id获取电能质量用户id集合")
|
||||||
|
@ApiImplicitParam(name = "userId", value = "用户id", required = true)
|
||||||
|
public HttpResult<List<String>> getPqUserIdsByUser(@RequestParam("userId") String userId) {
|
||||||
|
String methodDescribe = getMethodDescribe("getPqUserIdsByUser");
|
||||||
|
List<CsDeviceUserPO> devList = csDeviceUserPOService.lambdaQuery().select(CsDeviceUserPO::getDeviceId)
|
||||||
|
.and(w->w.eq(CsDeviceUserPO::getPrimaryUserId,userId).or().eq(CsDeviceUserPO::getSubUserId,userId))
|
||||||
|
.eq(CsDeviceUserPO::getStatus, DataStateEnum.ENABLE.getCode()).list();
|
||||||
|
if(CollUtil.isNotEmpty(devList)){
|
||||||
|
List<String> devIds = devList.stream().map(CsDeviceUserPO::getDeviceId).distinct().collect(Collectors.toList());
|
||||||
|
List<CsLinePO> poList = csLinePOService.lambdaQuery().select(CsLinePO::getLineId,CsLinePO::getMonitorUser).in(CsLinePO::getDeviceId,devIds)
|
||||||
|
.eq(CsLinePO::getStatus,DataStateEnum.ENABLE.getCode()).list();
|
||||||
|
if(CollUtil.isEmpty(poList)){
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, Collections.emptyList(), methodDescribe);
|
||||||
|
}else {
|
||||||
|
List<String> result = poList.stream().map(CsLinePO::getMonitorUser).distinct().collect(Collectors.toList());
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, Collections.emptyList(), methodDescribe);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过监测点获取监测点数据单位
|
* 通过监测点获取监测点数据单位
|
||||||
* @author cdf
|
* @author cdf
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||||
import com.njcn.common.pojo.exception.BusinessException;
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
|
import com.njcn.csdevice.api.CsCommTerminalFeignClient;
|
||||||
import com.njcn.csdevice.api.CsLineFeignClient;
|
import com.njcn.csdevice.api.CsLineFeignClient;
|
||||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||||
import com.njcn.csharmonic.enums.CsEventEnum;
|
import com.njcn.csharmonic.enums.CsEventEnum;
|
||||||
@@ -19,20 +20,12 @@ import com.njcn.csharmonic.pojo.vo.event.EventStatisticVO;
|
|||||||
import com.njcn.csharmonic.pojo.vo.event.F47Curve;
|
import com.njcn.csharmonic.pojo.vo.event.F47Curve;
|
||||||
import com.njcn.csharmonic.service.CsEventPOService;
|
import com.njcn.csharmonic.service.CsEventPOService;
|
||||||
import com.njcn.csharmonic.service.event.EventOverviewService;
|
import com.njcn.csharmonic.service.event.EventOverviewService;
|
||||||
import com.njcn.parser.component.WaveFileComponent;
|
import com.njcn.web.utils.RequestUtil;
|
||||||
import com.njcn.parser.pojo.dto.WaveDataDTO;
|
|
||||||
import com.njcn.parser.utils.WaveUtil;
|
|
||||||
import com.njcn.web.pojo.param.BaseParam;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.apache.commons.lang.StringUtils;
|
|
||||||
import org.checkerframework.checker.units.qual.A;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author: cdf
|
* @Author: cdf
|
||||||
@@ -50,12 +43,15 @@ public class EventOverviewServiceImpl implements EventOverviewService {
|
|||||||
|
|
||||||
private final CsEventPOService csEventPOService;
|
private final CsEventPOService csEventPOService;
|
||||||
private final CsLineFeignClient csLineFeignClient;
|
private final CsLineFeignClient csLineFeignClient;
|
||||||
|
private final CsCommTerminalFeignClient csCommTerminalFeignClient;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EventStatisticVO netEventEcharts(EventStatisticParam baseParam) {
|
public EventStatisticVO netEventEcharts(EventStatisticParam baseParam) {
|
||||||
DateTime start = DateUtil.beginOfDay(DateUtil.parse(baseParam.getSearchBeginTime()));
|
DateTime start = DateUtil.beginOfDay(DateUtil.parse(baseParam.getSearchBeginTime()));
|
||||||
DateTime end = DateUtil.endOfDay(DateUtil.parse(baseParam.getSearchEndTime()));
|
DateTime end = DateUtil.endOfDay(DateUtil.parse(baseParam.getSearchEndTime()));
|
||||||
|
|
||||||
|
List<String> ids = csCommTerminalFeignClient.getLineIdsByUser(RequestUtil.getUserIndex()).getData();
|
||||||
|
|
||||||
List<CsEventPO> csEventPOList = csEventPOService.lambdaQuery()
|
List<CsEventPO> csEventPOList = csEventPOService.lambdaQuery()
|
||||||
.between(CsEventPO::getStartTime, start, end)
|
.between(CsEventPO::getStartTime, start, end)
|
||||||
.eq(CsEventPO::getType, CsEventEnum.EVENT_TYPE.getCode())
|
.eq(CsEventPO::getType, CsEventEnum.EVENT_TYPE.getCode())
|
||||||
@@ -80,6 +76,9 @@ public class EventOverviewServiceImpl implements EventOverviewService {
|
|||||||
DateTime start = DateUtil.beginOfDay(DateUtil.parse(baseParam.getSearchBeginTime()));
|
DateTime start = DateUtil.beginOfDay(DateUtil.parse(baseParam.getSearchBeginTime()));
|
||||||
DateTime end = DateUtil.endOfDay(DateUtil.parse(baseParam.getSearchEndTime()));
|
DateTime end = DateUtil.endOfDay(DateUtil.parse(baseParam.getSearchEndTime()));
|
||||||
|
|
||||||
|
List<String> ids = csCommTerminalFeignClient.getLineIdsByUser(RequestUtil.getUserIndex()).getData();
|
||||||
|
|
||||||
|
|
||||||
List<String> lineIds = StrUtil.isBlank(baseParam.getSearchValue())
|
List<String> lineIds = StrUtil.isBlank(baseParam.getSearchValue())
|
||||||
? csLineFeignClient.getAllLine().getData()
|
? csLineFeignClient.getAllLine().getData()
|
||||||
: Collections.singletonList(baseParam.getSearchValue());
|
: Collections.singletonList(baseParam.getSearchValue());
|
||||||
@@ -142,6 +141,9 @@ public class EventOverviewServiceImpl implements EventOverviewService {
|
|||||||
DateTime start = DateUtil.beginOfDay(DateUtil.parse(baseParam.getSearchBeginTime()));
|
DateTime start = DateUtil.beginOfDay(DateUtil.parse(baseParam.getSearchBeginTime()));
|
||||||
DateTime end = DateUtil.endOfDay(DateUtil.parse(baseParam.getSearchEndTime()));
|
DateTime end = DateUtil.endOfDay(DateUtil.parse(baseParam.getSearchEndTime()));
|
||||||
|
|
||||||
|
List<String> ids = csCommTerminalFeignClient.getLineIdsByUser(RequestUtil.getUserIndex()).getData();
|
||||||
|
|
||||||
|
|
||||||
List<CsEventPO> csEventPOList = csEventPOService.lambdaQuery().select(CsEventPO::getId,CsEventPO::getTag,CsEventPO::getPersistTime,CsEventPO::getAmplitude)
|
List<CsEventPO> csEventPOList = csEventPOService.lambdaQuery().select(CsEventPO::getId,CsEventPO::getTag,CsEventPO::getPersistTime,CsEventPO::getAmplitude)
|
||||||
.between(CsEventPO::getStartTime, start, end)
|
.between(CsEventPO::getStartTime, start, end)
|
||||||
.eq(CsEventPO::getType, CsEventEnum.EVENT_TYPE.getCode())
|
.eq(CsEventPO::getType, CsEventEnum.EVENT_TYPE.getCode())
|
||||||
@@ -168,6 +170,10 @@ public class EventOverviewServiceImpl implements EventOverviewService {
|
|||||||
DateTime dateTime = DateUtil.parse(baseParam.getSearchBeginTime(), DatePattern.NORM_MONTH_PATTERN);
|
DateTime dateTime = DateUtil.parse(baseParam.getSearchBeginTime(), DatePattern.NORM_MONTH_PATTERN);
|
||||||
DateTime start = DateUtil.beginOfMonth(dateTime);
|
DateTime start = DateUtil.beginOfMonth(dateTime);
|
||||||
DateTime end = DateUtil.endOfMonth(dateTime);
|
DateTime end = DateUtil.endOfMonth(dateTime);
|
||||||
|
|
||||||
|
List<String> ids = csCommTerminalFeignClient.getLineIdsByUser(RequestUtil.getUserIndex()).getData();
|
||||||
|
|
||||||
|
|
||||||
List<DateTime> rangList = DateUtil.rangeToList(start,end, DateField.DAY_OF_MONTH);
|
List<DateTime> rangList = DateUtil.rangeToList(start,end, DateField.DAY_OF_MONTH);
|
||||||
|
|
||||||
|
|
||||||
@@ -206,7 +212,7 @@ public class EventOverviewServiceImpl implements EventOverviewService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<EventCoordsVO> getEventCoords(EventStatisticParam baseParam) {
|
public List<EventCoordsVO> getEventCoords(EventStatisticParam baseParam) {
|
||||||
// 初始化结果列表:10行 x 9列(根据原始代码的循环推断)
|
// 初始化结果列表
|
||||||
List<EventCoordsVO> result = new ArrayList<>(90);
|
List<EventCoordsVO> result = new ArrayList<>(90);
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
for (int j = 0; j < 9; j++) {
|
for (int j = 0; j < 9; j++) {
|
||||||
@@ -223,8 +229,7 @@ public class EventOverviewServiceImpl implements EventOverviewService {
|
|||||||
//TODO
|
//TODO
|
||||||
.list();
|
.list();
|
||||||
|
|
||||||
// 定义振幅和持续时间的分类规则
|
// 定义幅值和持续时间的分类规则
|
||||||
// 振幅分类规则
|
|
||||||
Map<Double, Integer> amplitudeRanges = ImmutableMap.<Double, Integer>builder()
|
Map<Double, Integer> amplitudeRanges = ImmutableMap.<Double, Integer>builder()
|
||||||
.put(0.0, 0)
|
.put(0.0, 0)
|
||||||
.put(0.1, 1)
|
.put(0.1, 1)
|
||||||
@@ -288,6 +293,7 @@ public class EventOverviewServiceImpl implements EventOverviewService {
|
|||||||
return entry.getValue();
|
return entry.getValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ranges.size() - 1; // 默认返回最大分组
|
// 默认返回最大分组
|
||||||
|
return ranges.size() - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user