diff --git a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/vo/CsEventSendMsgVO.java b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/vo/CsEventSendMsgVO.java new file mode 100644 index 0000000..f736781 --- /dev/null +++ b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/vo/CsEventSendMsgVO.java @@ -0,0 +1,58 @@ +package com.njcn.csdevice.pojo.vo; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.time.LocalDateTime; + +/** + *

+ * 事件推送日志表 + *

+ * + * @author xuyang + * @since 2023-09-18 + */ +@Data +public class CsEventSendMsgVO { + + + /** + * 用户id + */ + private String userId; + + /** + * 事件id + */ + private String eventId; + + /** + * 推送事件时用户的devCode + */ + private String devCode; + + private String devName; + + /** + * 推送时间 + */ + @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") + private LocalDateTime sendTime; + + /** + * 推送状态 + */ + private Integer status; + + /** + * 备注 + */ + private String remark; + + +} diff --git a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/vo/DevCountVO.java b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/vo/DevCountVO.java index f4b544a..91e3741 100644 --- a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/vo/DevCountVO.java +++ b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/vo/DevCountVO.java @@ -29,9 +29,13 @@ public class DevCountVO { private Integer alarmCount; @ApiModelProperty(value = "事件数") private Integer eventCount; - @ApiModelProperty(value = "项目数") - private Integer projectCount; + @ApiModelProperty(value = "工程个数") + private Integer eningerCount; + @ApiModelProperty(value = "运行事件数") + private Integer runCount; + @ApiModelProperty(value = "稳态件数") + private Integer harmonicCount; @ApiModelProperty(value = "当前工程id") private String currentId; @@ -39,17 +43,27 @@ public class DevCountVO { private Integer currentOnLineDevCount; private List currentOnLineDevs; - @ApiModelProperty(value = "当前工程设备在线总数") + @ApiModelProperty(value = "当前工程设备离线总数") private Integer currentOffLineDevCount; private List currentOffLineDevs; - @ApiModelProperty(value = "警告数") + @ApiModelProperty(value = "设备警告数") private Integer currentAlarmCount; - @ApiModelProperty(value = "事件数") + @ApiModelProperty(value = "暂态事件数") private Integer currentEventCount; + @ApiModelProperty(value = "运行事件数") + private Integer currentRunCount; + @ApiModelProperty(value = "稳态件数") + private Integer currentHarmonicCount; + @ApiModelProperty(value = "项目数") private Integer currentProjectCount; + @ApiModelProperty(value = "项目数") + private Long feedBackCount; + + + } diff --git a/cs-device/cs-device-boot/pom.xml b/cs-device/cs-device-boot/pom.xml index ee38bc6..110ca75 100644 --- a/cs-device/cs-device-boot/pom.xml +++ b/cs-device/cs-device-boot/pom.xml @@ -140,8 +140,20 @@ com.njcn cs-harmonic-api 1.0.0 - runtime + compile + + + com.njcn + cs-device-api + + + + com.njcn + cs-system-api + 1.0.0 + compile + diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/equipment/CsEventSendMsgController.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/equipment/CsEventSendMsgController.java index ae497c0..6072c97 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/equipment/CsEventSendMsgController.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/equipment/CsEventSendMsgController.java @@ -1,6 +1,7 @@ package com.njcn.csdevice.controller.equipment; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.njcn.common.pojo.annotation.OperateInfo; import com.njcn.common.pojo.constant.OperateType; import com.njcn.common.pojo.enums.common.LogEnum; @@ -8,8 +9,11 @@ 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.pojo.po.CsEventSendMsg; +import com.njcn.csdevice.pojo.po.CsLogsPO; +import com.njcn.csdevice.pojo.vo.CsEventSendMsgVO; import com.njcn.csdevice.service.ICsEventSendMsgService; import com.njcn.web.controller.BaseController; +import com.njcn.web.pojo.param.BaseParam; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiOperation; @@ -49,5 +53,16 @@ public class CsEventSendMsgController extends BaseController { return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); } + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/queryLog") + @ApiOperation("查询推送日志") + @ApiImplicitParam(name = "baseParam", value = "查询日志参数", required = true) + public HttpResult> queryLog(@RequestBody BaseParam baseParam){ + String methodDescribe = getMethodDescribe("queryLog"); + IPage list = csEventSendMsgService.queryPage(baseParam); + + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe); + } + } diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/equipment/EquipmentDeliveryController.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/equipment/EquipmentDeliveryController.java index caa4600..c84190f 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/equipment/EquipmentDeliveryController.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/equipment/EquipmentDeliveryController.java @@ -222,7 +222,7 @@ public class EquipmentDeliveryController extends BaseController { @ResponseBody @ApiOperation("联调完成") @PostMapping(value = "testcompletion") - public HttpResult testCompletion(@RequestParam("deviceId") String deviceId,@RequestParam("type") String type,@RequestParam("remark") String remark){ + public HttpResult testCompletion(@RequestParam("deviceId") String deviceId,@RequestParam("type") Integer type,@RequestParam("remark") String remark){ String methodDescribe = getMethodDescribe("testCompletion"); csEquipmentDeliveryService.testCompletion(deviceId,type, remark); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); @@ -231,8 +231,8 @@ public class EquipmentDeliveryController extends BaseController { @ResponseBody @ApiOperation("取消联调") @PostMapping(value = "deleteTest") - public HttpResult deleteTest(@RequestParam("deviceId") String deviceId,@RequestParam("type") String type,@RequestParam("remark") String remark){ - String methodDescribe = getMethodDescribe("testCompletion"); + public HttpResult deleteTest(@RequestParam("deviceId") String deviceId,@RequestParam("type") Integer type,@RequestParam("remark") String remark){ + String methodDescribe = getMethodDescribe("deleteTest"); csEquipmentDeliveryService.deleteTest(deviceId,type, remark); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); } diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/mapper/CsEventSendMsgMapper.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/mapper/CsEventSendMsgMapper.java index 4709f9d..0af22de 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/mapper/CsEventSendMsgMapper.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/mapper/CsEventSendMsgMapper.java @@ -1,7 +1,13 @@ package com.njcn.csdevice.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.njcn.csdevice.pojo.po.CsEventSendMsg; +import com.njcn.csdevice.pojo.po.CsLogsPO; +import com.njcn.csdevice.pojo.vo.CsEventSendMsgVO; +import com.njcn.web.pojo.param.BaseParam; +import org.apache.ibatis.annotations.Param; /** *

@@ -13,4 +19,5 @@ import com.njcn.csdevice.pojo.po.CsEventSendMsg; */ public interface CsEventSendMsgMapper extends BaseMapper { + Page selectPages(Page returnpage,@Param("baseParam") BaseParam baseParam); } diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/mapper/mapping/CsEventSendMsgMapper.xml b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/mapper/mapping/CsEventSendMsgMapper.xml new file mode 100644 index 0000000..f96d8ca --- /dev/null +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/mapper/mapping/CsEventSendMsgMapper.xml @@ -0,0 +1,8 @@ + + + + + + \ No newline at end of file diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/CsEquipmentDeliveryService.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/CsEquipmentDeliveryService.java index d998b41..5583171 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/CsEquipmentDeliveryService.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/CsEquipmentDeliveryService.java @@ -97,7 +97,7 @@ public interface CsEquipmentDeliveryService extends IService @@ -13,4 +16,5 @@ import com.njcn.csdevice.pojo.po.CsEventSendMsg; */ public interface ICsEventSendMsgService extends IService { + IPage queryPage(BaseParam baseParam); } diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsDeviceUserPOServiceImpl.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsDeviceUserPOServiceImpl.java index 38f1eb2..7510bcd 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsDeviceUserPOServiceImpl.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsDeviceUserPOServiceImpl.java @@ -3,6 +3,8 @@ package com.njcn.csdevice.service.impl; import cn.hutool.core.collection.CollectionUtil; import com.alibaba.fastjson.JSONArray; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.njcn.common.pojo.exception.BusinessException; import com.njcn.csdevice.enums.AlgorithmResponseEnum; @@ -14,6 +16,12 @@ import com.njcn.csdevice.pojo.vo.CsLedgerVO; import com.njcn.csdevice.pojo.vo.DevCountVO; import com.njcn.csdevice.pojo.vo.DevUserVO; import com.njcn.csdevice.service.*; +import com.njcn.csharmonic.api.EventUserFeignClient; +import com.njcn.csharmonic.param.CsEventUserQueryParam; +import com.njcn.csharmonic.pojo.vo.EventDetailVO; +import com.njcn.cssystem.api.FeedBackFeignClient; +import com.njcn.cssystem.pojo.param.CsFeedbackQueryParm; +import com.njcn.cssystem.pojo.vo.CsFeedbackVO; import com.njcn.user.api.UserFeignClient; import com.njcn.user.enums.AppRoleEnum; import com.njcn.user.pojo.po.User; @@ -55,9 +63,11 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl roleProject = roleEngineerDevService.getRoleProject(); - devCountVO.setProjectCount(roleProject.size()); + List roleengineer = roleEngineerDevService.getRoleengineer(); + devCountVO.setEningerCount(roleengineer.size()); } List deviceTree = iCsLedgerService.getDeviceTree(); @@ -151,7 +161,6 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl()); devCountVO.setCurrentProjectCount(0); - devCountVO.setCurrentProjectCount(0); }else { queryWrapper.clear(); @@ -167,27 +176,34 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl list = iCsLedgerService.lambdaQuery().eq(CsLedger::getPid, id).eq(CsLedger::getState, 1).list(); devCountVO.setCurrentProjectCount(list.size()); } - - - + CsEventUserQueryParam csEventUserQueryParam = new CsEventUserQueryParam(); + csEventUserQueryParam.setStatus("0"); + List data = eventUserFeignClient.queryEventList(csEventUserQueryParam).getData(); + List event = data.stream().filter(temp -> temp.getType() == 0).collect(Collectors.toList()); + List harmonic = data.stream().filter(temp -> temp.getType() == 1).collect(Collectors.toList()); + List alarm = data.stream().filter(temp -> temp.getType() == 3).collect(Collectors.toList()); + List run = data.stream().filter(temp -> temp.getType() == 2).collect(Collectors.toList()); + CsFeedbackQueryParm csFeedbackQueryParm = new CsFeedbackQueryParm(); + csFeedbackQueryParm.setPageNum(1); + csFeedbackQueryParm.setPageSize(10); + csFeedbackQueryParm.setStatus("1"); + Page data1 = feedBackFeignClient.queryFeedBackPage(csFeedbackQueryParm).getData(); + long total = data1.getTotal(); + devCountVO.setFeedBackCount(total); //todo 后续添加警告数,事件数 - devCountVO.setEventCount(0); - devCountVO.setAlarmCount(0); - devCountVO.setCurrentEventCount(0); - devCountVO.setCurrentAlarmCount(0); - -// csEquipmentAlarmPageParm.setStartTime(); -// csEquipmentAlarmPageParam.setEndTime(); -// List data = csEquipmentAlarmFeignClient.queryList(csEquipmentAlarmPageParm).getData(); -// List devIds = data.stream().map(CsEquipmentAlarmVO::getEquipmentId).distinct().collect(Collectors.toList()); -// queryWrapper.clear(); -// queryWrapper.in("id",devIds); -// -// List csEquipmentDeliveryPOS = csEquipmentDeliveryMapper.selectList(queryWrapper); -// -// devCountVO.setAlarmLineDevs(csEquipmentDeliveryPOS); -// devCountVO.setAlarmEventCount(devIds.size()); + devCountVO.setEventCount(event.size()); + devCountVO.setAlarmCount(harmonic.size()); + devCountVO.setRunCount(run.size()); + devCountVO.setHarmonicCount(alarm.size()); + List curEvent = event.stream().filter(temp -> Objects.equals(temp.getEngineeringid(), id)).collect(Collectors.toList()); + List curHarmonic = harmonic.stream().filter(temp -> Objects.equals(temp.getEngineeringid(), id)).collect(Collectors.toList()); + List curAlarm = alarm.stream().filter(temp -> Objects.equals(temp.getEngineeringid(), id)).collect(Collectors.toList()); + List curRun = run.stream().filter(temp -> Objects.equals(temp.getEngineeringid(), id)).collect(Collectors.toList()); + devCountVO.setCurrentEventCount(curEvent.size()); + devCountVO.setCurrentAlarmCount(curAlarm.size()); + devCountVO.setCurrentRunCount(curRun.size()); + devCountVO.setCurrentHarmonicCount(curHarmonic.size()); return devCountVO; diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsEquipmentDeliveryServiceImpl.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsEquipmentDeliveryServiceImpl.java index 642289f..51796fe 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsEquipmentDeliveryServiceImpl.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsEquipmentDeliveryServiceImpl.java @@ -443,12 +443,12 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl list = csLedgerService.list(csLedgerQueryWrapper); List collect = list.stream().map(CsLedger::getId).collect(Collectors.toList()); - csLedgerService.removeById(csLedgerQueryWrapper); + csLedgerService.remove(csLedgerQueryWrapper); QueryWrapper csDevModelRelationPOQueryWrapper = new QueryWrapper<>(); csDevModelRelationPOQueryWrapper.clear(); csDevModelRelationPOQueryWrapper.eq("dev_id",devId); @@ -471,10 +471,10 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl implements ICsEventSendMsgService { + @Override + public IPage queryPage(BaseParam baseParam) { + Page returnpage = new Page<> (baseParam.getPageNum ( ), baseParam.getPageSize ( )); + + Page result = this.getBaseMapper().selectPages(returnpage,baseParam); + return result; + } } diff --git a/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/api/EventUserFeignClient.java b/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/api/EventUserFeignClient.java new file mode 100644 index 0000000..48a63eb --- /dev/null +++ b/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/api/EventUserFeignClient.java @@ -0,0 +1,23 @@ +package com.njcn.csharmonic.api; + +import com.njcn.common.pojo.constant.ServerInfo; +import com.njcn.common.pojo.response.HttpResult; +import com.njcn.csharmonic.api.fallback.EventUserFeignClientFallbackFactory; +import com.njcn.csharmonic.param.CsEventUserQueryParam; +import com.njcn.csharmonic.pojo.vo.EventDetailVO; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +import java.util.List; + +/** + * @author xy + */ +@FeignClient(value = ServerInfo.CS_HARMONIC_BOOT, path = "/eventUser", fallbackFactory = EventUserFeignClientFallbackFactory.class,contextId = "eventUser") +public interface EventUserFeignClient { + + + @PostMapping("/queryEventList") + HttpResult> queryEventList(@RequestBody CsEventUserQueryParam csEventUserQueryParam) ; +} diff --git a/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/api/fallback/EventUserFeignClientFallbackFactory.java b/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/api/fallback/EventUserFeignClientFallbackFactory.java new file mode 100644 index 0000000..9cc80c5 --- /dev/null +++ b/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/api/fallback/EventUserFeignClientFallbackFactory.java @@ -0,0 +1,42 @@ +package com.njcn.csharmonic.api.fallback; + +import com.njcn.common.pojo.enums.response.CommonResponseEnum; +import com.njcn.common.pojo.exception.BusinessException; +import com.njcn.common.pojo.response.HttpResult; +import com.njcn.csdevice.pojo.po.AppProjectPO; +import com.njcn.csharmonic.api.EventUserFeignClient; +import com.njcn.csharmonic.param.CsEventUserQueryParam; +import com.njcn.csharmonic.pojo.vo.EventDetailVO; +import feign.hystrix.FallbackFactory; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.PostMapping; + +import java.util.List; + +/** + * @author xy + */ +@Slf4j +@Component +public class EventUserFeignClientFallbackFactory implements FallbackFactory { + @Override + public EventUserFeignClient create(Throwable cause) { + //判断抛出异常是否为解码器抛出的业务异常 + Enum exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK; + if (cause.getCause() instanceof BusinessException) { + BusinessException businessException = (BusinessException) cause.getCause(); + } + Enum finalExceptionEnum = exceptionEnum; + return new EventUserFeignClient() { + + + @PostMapping("/queryEventList") + @Override + public HttpResult> queryEventList(CsEventUserQueryParam csEventUserQueryParam) { + log.error("{}异常,降级处理,异常为:{}","获取当天事件未读消息未读消息",cause.toString()); + throw new BusinessException(finalExceptionEnum); + } + }; + } +} diff --git a/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/param/CommonStatisticalQueryParam.java b/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/param/CommonStatisticalQueryParam.java index 4baf4e7..f01340f 100644 --- a/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/param/CommonStatisticalQueryParam.java +++ b/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/param/CommonStatisticalQueryParam.java @@ -19,8 +19,8 @@ public class CommonStatisticalQueryParam { private List lineList; @ApiModelProperty(value = "设备id") private String DevId; - @ApiModelProperty(value = "指标id") - @NotBlank(message="指标id不能为空") + @ApiModelProperty(value = "指标组id") + @NotBlank(message="指标组id不能为空") private String statisticalId; @ApiModelProperty(value = "取值类型(Max,Min,cp95,avg)") private String valueType; diff --git a/cs-harmonic/cs-harmonic-boot/pom.xml b/cs-harmonic/cs-harmonic-boot/pom.xml index ecea26b..e64cf10 100644 --- a/cs-harmonic/cs-harmonic-boot/pom.xml +++ b/cs-harmonic/cs-harmonic-boot/pom.xml @@ -67,6 +67,12 @@ cs-device-api 1.0.0 compile + + + com.njcn + cs-harmonic-api + + com.njcn diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/controller/EventController.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/controller/EventController.java index 142e53e..7012381 100644 --- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/controller/EventController.java +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/controller/EventController.java @@ -7,9 +7,7 @@ import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.utils.HttpResultUtil; import com.njcn.csharmonic.param.CsEventUserQueryParam; import com.njcn.csharmonic.pojo.vo.EventDetailVO; -import com.njcn.csharmonic.service.EventService; -import com.njcn.influx.pojo.dto.EventQueryDTO; -import com.njcn.influx.pojo.po.cs.EntData; +import com.njcn.csharmonic.service.CsEventPOService; import com.njcn.web.controller.BaseController; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; @@ -33,17 +31,8 @@ import java.util.List; @Api(tags = "暂降事件") @AllArgsConstructor public class EventController extends BaseController { - private final EventService eventService; - @OperateInfo(info = LogEnum.BUSINESS_COMMON) - @PostMapping("/queryEvent") - @ApiOperation("暂降事件查询") - @ApiImplicitParam(name = "eventQueryDTO", value = "暂降事件查询参数", required = true) - @Deprecated - public HttpResult> queryEvent(@RequestBody EventQueryDTO eventQueryDTO) { - String methodDescribe = getMethodDescribe("queryEvent"); - List list = eventService.queryEvent(eventQueryDTO); - return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe); - } + private final CsEventPOService eventService; + @OperateInfo(info = LogEnum.BUSINESS_COMMON) @PostMapping("/queryEventList") diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/controller/EventUserController.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/controller/EventUserController.java index b4b8844..6b31624 100644 --- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/controller/EventUserController.java +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/controller/EventUserController.java @@ -47,7 +47,7 @@ public class EventUserController extends BaseController { @OperateInfo(info = LogEnum.BUSINESS_COMMON) @PostMapping("/queryEventList") - @ApiOperation("当天暂降事件未读消息") + @ApiOperation("当天事件未读消息") @ApiImplicitParam(name = "csEventUserQueryParam", value = "暂降事件查询参数", required = true) public HttpResult> queryEventList(@RequestBody CsEventUserQueryParam csEventUserQueryParam) { String methodDescribe = getMethodDescribe("queryEventList"); diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/handler/MqttMessageHandler.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/handler/MqttMessageHandler.java index da49456..da3d751 100644 --- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/handler/MqttMessageHandler.java +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/handler/MqttMessageHandler.java @@ -97,7 +97,7 @@ public class MqttMessageHandler { // List>> resultList = new ArrayList< Future>>(); //1.查询拓扑图配置的指标:拓扑图扑图配置:7677f94c749dedaff30f911949cbd724 - List data = csStatisticalSetFeignClient.queryStatisticalSelect("7677f94c749dedaff30f911949cbd724").getData(); + List data = csStatisticalSetFeignClient.queryStatisticalSelect("b934664f9592d1c5e92caa90695b7103").getData(); data.forEach(temp->{ if(Objects.nonNull(temp.getHarmStart())&&Objects.nonNull(temp.getHarmEnd())){ diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/CsEventPOService.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/CsEventPOService.java index 2cd08b5..628abb2 100644 --- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/CsEventPOService.java +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/CsEventPOService.java @@ -1,8 +1,13 @@ package com.njcn.csharmonic.service; +import com.njcn.csharmonic.param.CsEventUserQueryParam; import com.njcn.csharmonic.pojo.po.CsEventPO; import com.baomidou.mybatisplus.extension.service.IService; - /** +import com.njcn.csharmonic.pojo.vo.EventDetailVO; + +import java.util.List; + +/** * * Description: * Date: 2023/9/4 15:15【需求编号】 @@ -12,5 +17,5 @@ import com.baomidou.mybatisplus.extension.service.IService; */ public interface CsEventPOService extends IService{ - + List queryEventList(CsEventUserQueryParam csEventUserQueryParam); } diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/EventService.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/EventService.java deleted file mode 100644 index ba4a090..0000000 --- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/EventService.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.njcn.csharmonic.service; - -import com.njcn.csharmonic.param.CsEventUserQueryParam; -import com.njcn.csharmonic.pojo.vo.EventDetailVO; -import com.njcn.influx.pojo.dto.EventQueryDTO; -import com.njcn.influx.pojo.dto.StatisticalDataDTO; -import com.njcn.influx.pojo.po.cs.EntData; - -import java.util.List; - -/** - * Description: - * Date: 2023/8/30 8:46【需求编号】 - * - * @author clam - * @version V1.0.0 - */ -public interface EventService { - - List queryEvent(EventQueryDTO eventQueryDTO); - - - List queryEventList(CsEventUserQueryParam csEventUserQueryParam); -} diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/CsEventPOServiceImpl.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/CsEventPOServiceImpl.java index 6980e11..cc2aec8 100644 --- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/CsEventPOServiceImpl.java +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/CsEventPOServiceImpl.java @@ -1,10 +1,29 @@ package com.njcn.csharmonic.service.impl; +import com.njcn.csdevice.api.CsLedgerFeignClient; +import com.njcn.csdevice.api.CsLineFeignClient; +import com.njcn.csdevice.pojo.dto.DevDetailDTO; +import com.njcn.csharmonic.param.CsEventUserQueryParam; +import com.njcn.csharmonic.pojo.vo.EventDetailVO; +import com.njcn.csharmonic.service.CsEventUserPOService; +import com.njcn.influx.pojo.dto.EventDataSetDTO; +import com.njcn.influx.service.EvtDataService; +import com.njcn.system.api.EleEvtFeignClient; +import com.njcn.system.api.EpdFeignClient; +import com.njcn.system.pojo.po.EleEpdPqd; +import com.njcn.system.pojo.po.EleEvtParm; +import lombok.RequiredArgsConstructor; +import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.njcn.csharmonic.mapper.CsEventPOMapper; import com.njcn.csharmonic.pojo.po.CsEventPO; import com.njcn.csharmonic.service.CsEventPOService; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + /** * * Description: @@ -14,6 +33,47 @@ import com.njcn.csharmonic.service.CsEventPOService; * @version V1.0.0 */ @Service +@RequiredArgsConstructor public class CsEventPOServiceImpl extends ServiceImpl implements CsEventPOService{ + private final EvtDataService evtDataService; + + private final CsLedgerFeignClient csLedgerFeignClient; + + private final EpdFeignClient epdFeignClient; + private final CsEventUserPOService csEventUserPOService; + private final EleEvtFeignClient eleEvtFeignClient; + + @Override + public List queryEventList(CsEventUserQueryParam csEventUserQueryParam) { + + List list = csEventUserPOService.queryUserEventList(csEventUserQueryParam); + list.forEach(temp->{ + DevDetailDTO devDetail = csLedgerFeignClient.queryDevDetail(temp.getDeviceId()).getData(); + temp.setEquipmentName(devDetail.getEquipmentName()); + temp.setProjectId(devDetail.getProjectId()); + temp.setProjectName(devDetail.getProjectName()); + temp.setEngineeringid(devDetail.getEngineeringid()); + temp.setEngineeringName(devDetail.getEngineeringName()); + EleEpdPqd data = epdFeignClient.findByName(temp.getTag()).getData(); + List data1 = eleEvtFeignClient.queryByPid(data.getId()).getData(); + List eventDataSetDTOS = new ArrayList<>(); + for (EleEvtParm eleEvtParm : data1) { + EventDataSetDTO eventDataSetDTO = new EventDataSetDTO(); + BeanUtils.copyProperties(eleEvtParm,eventDataSetDTO); + EventDataSetDTO evtData = evtDataService.getEventDataSet("evt_data", temp.getId(), eleEvtParm.getName()); + if (evtData == null) { + eventDataSetDTO.setValue("3.1415926"); + }else { + eventDataSetDTO.setValue(Optional.ofNullable(evtData.getValue()).orElse("3.1415926")); + + } + + eventDataSetDTOS.add(eventDataSetDTO); + } + temp.setDataSet(eventDataSetDTOS); + }); + + return list; + } } diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/CsEventUserPOServiceImpl.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/CsEventUserPOServiceImpl.java index 41b8540..6dc8e0a 100644 --- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/CsEventUserPOServiceImpl.java +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/CsEventUserPOServiceImpl.java @@ -2,19 +2,26 @@ package com.njcn.csharmonic.service.impl; import cn.hutool.core.collection.CollectionUtil; import com.alibaba.fastjson.JSONArray; +import com.njcn.csdevice.api.CsLedgerFeignClient; +import com.njcn.csdevice.pojo.dto.DevDetailDTO; import com.njcn.csharmonic.param.CsEventUserQueryParam; import com.njcn.csharmonic.pojo.vo.EventDetailVO; +import com.njcn.influx.pojo.dto.EventDataSetDTO; import com.njcn.system.api.DicDataFeignClient; import com.njcn.system.enums.DicDataTypeEnum; import com.njcn.system.pojo.po.DictData; +import com.njcn.system.pojo.po.EleEpdPqd; +import com.njcn.system.pojo.po.EleEvtParm; import com.njcn.user.enums.AppRoleEnum; import com.njcn.web.utils.RequestUtil; import lombok.RequiredArgsConstructor; +import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.List; import java.util.Objects; +import java.util.Optional; import java.util.stream.Collectors; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -36,6 +43,8 @@ import org.springframework.util.CollectionUtils; public class CsEventUserPOServiceImpl extends ServiceImpl implements CsEventUserPOService{ private final DicDataFeignClient dicDataFeignClient; + private final CsLedgerFeignClient csLedgerFeignClient; + @Override public Integer queryEventCount(CsEventUserQueryParam csEventUserQueryParam) { csEventUserQueryParam.setUserId(RequestUtil.getUserIndex()); @@ -62,6 +71,17 @@ public class CsEventUserPOServiceImpl extends ServiceImpl list = this.getBaseMapper().queryUserEventList(csEventUserQueryParam); + + list.forEach(temp->{ + DevDetailDTO devDetail = csLedgerFeignClient.queryDevDetail(temp.getDeviceId()).getData(); + temp.setEquipmentName(devDetail.getEquipmentName()); + temp.setProjectId(devDetail.getProjectId()); + temp.setProjectName(devDetail.getProjectName()); + temp.setEngineeringid(devDetail.getEngineeringid()); + temp.setEngineeringName(devDetail.getEngineeringName()); + + }); + return list; } diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/EventServiceImpl.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/EventServiceImpl.java deleted file mode 100644 index 97056da..0000000 --- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/EventServiceImpl.java +++ /dev/null @@ -1,96 +0,0 @@ -package com.njcn.csharmonic.service.impl; - -import cn.hutool.core.collection.CollectionUtil; -import com.njcn.common.pojo.exception.BusinessException; -import com.njcn.common.utils.NjcnBeanUtil; -import com.njcn.csdevice.api.CsLedgerFeignClient; -import com.njcn.csdevice.api.CsLineFeignClient; -import com.njcn.csdevice.enums.AlgorithmResponseEnum; -import com.njcn.csdevice.pojo.dto.DevDetailDTO; -import com.njcn.csdevice.pojo.po.CsLedger; -import com.njcn.csdevice.pojo.po.CsLinePO; -import com.njcn.csharmonic.param.CsEventUserQueryParam; -import com.njcn.csharmonic.pojo.vo.EventDetailVO; -import com.njcn.csharmonic.service.CsEventUserPOService; -import com.njcn.csharmonic.service.EventService; -import com.njcn.influx.pojo.dto.EventDataSetDTO; -import com.njcn.influx.pojo.dto.EventQueryDTO; -import com.njcn.influx.pojo.po.cs.EntData; -import com.njcn.influx.service.EvtDataService; -import com.njcn.system.api.EleEvtFeignClient; -import com.njcn.system.api.EpdFeignClient; -import com.njcn.system.pojo.po.EleEpdPqd; -import com.njcn.system.pojo.po.EleEvtParm; -import lombok.RequiredArgsConstructor; -import org.springframework.beans.BeanUtils; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; - -/** - * Description: - * Date: 2023/8/30 19:41【需求编号】 - * - * @author clam - * @version V1.0.0 - */ -@Service -@RequiredArgsConstructor -public class EventServiceImpl implements EventService { - private final EvtDataService evtDataService; - private final CsLineFeignClient csLineFeignClient; - private final CsLedgerFeignClient csLedgerFeignClient; - - private final EpdFeignClient epdFeignClient; - private final CsEventUserPOService csEventUserPOService; - private final EleEvtFeignClient eleEvtFeignClient; - - @Override - public List queryEvent(EventQueryDTO eventQueryDTO) { - List csLinePOList = csLineFeignClient.queryLineByDevId(eventQueryDTO.getDevId()).getData(); - if(CollectionUtil.isEmpty(csLinePOList)){ - throw new BusinessException(AlgorithmResponseEnum.LINE_DATA_ERROR); - } - List collect = csLinePOList.stream().map(CsLinePO::getLineId).collect(Collectors.toList()); - eventQueryDTO.setLineIds(collect); - List data = epdFeignClient.selectByIds(eventQueryDTO.getTarget()).getData(); - if(CollectionUtil.isEmpty(data)){ - new BusinessException(AlgorithmResponseEnum.ELEEPDPQD_DATA_ERROR); - } - List collect1 = data.stream().map(EleEpdPqd::getName).collect(Collectors.toList()); - eventQueryDTO.setTarget(collect1); - List eventData = evtDataService.getEventData(eventQueryDTO); - return eventData; - } - - @Override - public List queryEventList(CsEventUserQueryParam csEventUserQueryParam) { - - List list = csEventUserPOService.queryUserEventList(csEventUserQueryParam); - list.forEach(temp->{ - DevDetailDTO devDetail = csLedgerFeignClient.queryDevDetail(temp.getDeviceId()).getData(); - temp.setEquipmentName(devDetail.getEquipmentName()); - temp.setProjectId(devDetail.getProjectId()); - temp.setProjectName(devDetail.getProjectName()); - temp.setEngineeringid(devDetail.getEngineeringid()); - temp.setEngineeringName(devDetail.getEngineeringName()); - EleEpdPqd data = epdFeignClient.findByName(temp.getTag()).getData(); - List data1 = eleEvtFeignClient.queryByPid(data.getId()).getData(); - List eventDataSetDTOS = new ArrayList<>(); - for (EleEvtParm eleEvtParm : data1) { - EventDataSetDTO eventDataSetDTO = new EventDataSetDTO(); - BeanUtils.copyProperties(eleEvtParm,eventDataSetDTO); - EventDataSetDTO evtData = evtDataService.getEventDataSet("evt_data", temp.getId(), eleEvtParm.getName()); - eventDataSetDTO.setValue(evtData.getValue()); - eventDataSetDTOS.add(eventDataSetDTO); - } - temp.setDataSet(eventDataSetDTOS); - }); - - return list; - } - - -} diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/StableDataServiceImpl.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/StableDataServiceImpl.java index cb18228..687ecf4 100644 --- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/StableDataServiceImpl.java +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/StableDataServiceImpl.java @@ -20,6 +20,7 @@ import com.njcn.influx.service.HaronicRatioService; import com.njcn.influx.service.PowerQualityService; import com.njcn.influxdb.param.InfluxDBPublicParam; import com.njcn.influxdb.utils.InfluxDbUtils; +import com.njcn.system.api.CsStatisticalSetFeignClient; import com.njcn.system.api.DicDataFeignClient; import com.njcn.system.api.EpdFeignClient; import com.njcn.system.enums.DicDataEnum; @@ -60,6 +61,7 @@ public class StableDataServiceImpl implements StableDataService { private final DecimalFormat df = new DecimalFormat("#0.0000"); private final DicDataFeignClient dicDataFeignClient; private final InfluxDbUtils influxDbUtils; + private final CsStatisticalSetFeignClient csStatisticalSetFeignClient; @Override @@ -224,6 +226,9 @@ public class StableDataServiceImpl implements StableDataService { @Override public List queryCommonStatisticalByTime(CommonStatisticalQueryParam commonStatisticalQueryParam) { + + List result = new ArrayList(); + Optional.ofNullable(commonStatisticalQueryParam.getDevId()).orElseThrow(()-> new BusinessException(AlgorithmResponseEnum.DEVICE_LOSE)); List csLinePOList = csLineFeignClient.queryLineByDevId(commonStatisticalQueryParam.getDevId()).getData(); @@ -232,40 +237,42 @@ public class StableDataServiceImpl implements StableDataService { } List collect = csLinePOList.stream().map(CsLinePO::getLineId).collect(Collectors.toList()); + List data = csStatisticalSetFeignClient.queryStatisticalSelect(commonStatisticalQueryParam.getStatisticalId()).getData(); - EleEpdPqd data = epdFeignClient.selectById(commonStatisticalQueryParam.getStatisticalId()).getData(); - Optional.ofNullable(data).orElseThrow(()-> new BusinessException(AlgorithmResponseEnum.ELEEPDPQD_DATA_ERROR)); +// EleEpdPqd data = epdFeignClient.selectById(commonStatisticalQueryParam.getStatisticalId()).getData(); +// Optional.ofNullable(data).orElseThrow(()-> new BusinessException(AlgorithmResponseEnum.ELEEPDPQD_DATA_ERROR)); + if(CollectionUtil.isNotEmpty(data)){ + data.forEach(epdPqd->{ + String frequency = Optional.ofNullable(commonStatisticalQueryParam.getFrequency()).orElse(""); + List deviceRtData = commonService.getDeviceRtDataByTime(collect, epdPqd.getClassId(), epdPqd.getName()+frequency, epdPqd.getPhase(), commonStatisticalQueryParam.getValueType(),commonStatisticalQueryParam.getStartTime(),commonStatisticalQueryParam.getEndTime()); - String frequency = Optional.ofNullable(commonStatisticalQueryParam.getFrequency()).orElse(""); - List deviceRtData = commonService.getDeviceRtDataByTime(collect, data.getClassId(), data.getName()+frequency, data.getPhase(), commonStatisticalQueryParam.getValueType(),commonStatisticalQueryParam.getStartTime(),commonStatisticalQueryParam.getEndTime()); - //获取对应的治理后的指标 - if(data.getName().equals("Pq_ThdI")){ - EleEpdPqd data1 = epdFeignClient.selectById("1a4c5741bd57bd815b361c53d627a891").getData(); - List deviceRtData2 = commonService.getDeviceRtDataByTime(collect, data1.getClassId(), data1.getName()+frequency, data.getPhase(), commonStatisticalQueryParam.getValueType(),commonStatisticalQueryParam.getStartTime(),commonStatisticalQueryParam.getEndTime()); - deviceRtData.addAll(deviceRtData2); + + List collect1 = deviceRtData.stream().map(temp -> { + ThdDataVO vo = new ThdDataVO(); + vo.setLineId(temp.getLineId()); + vo.setPhase(temp.getPhaseType()); + String position = csLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition(); + vo.setPosition(position); + vo.setTime(temp.getTime().atZone(ZoneId.systemDefault()).toLocalDateTime()); + vo.setStatMethod(temp.getValueType()); + vo.setStatisticalData(Double.valueOf(df.format(temp.getValue()))); + vo.setStatisticalIndex(epdPqd.getId()); + vo.setUnit(epdPqd.getUnit()); + vo.setStatisticalName(epdPqd.getName()); + vo.setAnotherName(epdPqd.getShowName()); + return vo; + }).collect(Collectors.toList()); + result.addAll(collect1); + }); } - List collect1 = deviceRtData.stream().map(temp -> { - ThdDataVO vo = new ThdDataVO(); - vo.setLineId(temp.getLineId()); - vo.setPhase(temp.getPhaseType()); - String position = csLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition(); - vo.setPosition(position); - vo.setTime(temp.getTime().atZone(ZoneId.systemDefault()).toLocalDateTime()); - vo.setStatMethod(temp.getValueType()); - vo.setStatisticalData(Double.valueOf(df.format(temp.getValue()))); - vo.setStatisticalIndex(data.getId()); - vo.setUnit(data.getUnit()); - return vo; - }).collect(Collectors.toList()); - - return collect1; + return result; } @Override public List queryLineCommonStatistical(CommonStatisticalQueryParam commonStatisticalQueryParam) { - + List result = new ArrayList(); if(CollectionUtil.isEmpty(commonStatisticalQueryParam.getLineList())){ throw new BusinessException(AlgorithmResponseEnum.LINE_DATA_ERROR); } @@ -275,37 +282,41 @@ public class StableDataServiceImpl implements StableDataService { } List collect = csLinePOList.stream().map(CsLinePO::getLineId).collect(Collectors.toList()); + List data = csStatisticalSetFeignClient.queryStatisticalSelect(commonStatisticalQueryParam.getStatisticalId()).getData(); - EleEpdPqd data = epdFeignClient.selectById(commonStatisticalQueryParam.getStatisticalId()).getData(); +// EleEpdPqd data = epdFeignClient.selectById(commonStatisticalQueryParam.getStatisticalId()).getData(); Optional.ofNullable(data).orElseThrow(()-> new BusinessException(AlgorithmResponseEnum.ELEEPDPQD_DATA_ERROR)); String frequency = Optional.ofNullable(commonStatisticalQueryParam.getFrequency()).orElse(""); - List deviceRtData = commonService.getDeviceRtDataByTime(collect, data.getClassId(), data.getName()+frequency, data.getPhase(), commonStatisticalQueryParam.getValueType(),commonStatisticalQueryParam.getStartTime(),commonStatisticalQueryParam.getEndTime()); - //获取对应的治理后的指标 - if(data.getName().equals("Pq_ThdI")){ - EleEpdPqd data1 = epdFeignClient.selectById("1a4c5741bd57bd815b361c53d627a891").getData(); - List deviceRtData2 = commonService.getDeviceRtDataByTime(collect, data1.getClassId(), data1.getName()+frequency, data.getPhase(), commonStatisticalQueryParam.getValueType(),commonStatisticalQueryParam.getStartTime(),commonStatisticalQueryParam.getEndTime()); - deviceRtData.addAll(deviceRtData2); + if(CollectionUtil.isNotEmpty(data)){ + data.forEach(epdPqd->{ + List deviceRtData = commonService.getDeviceRtDataByTime(collect, epdPqd.getClassId(), epdPqd.getName()+frequency, epdPqd.getPhase(), commonStatisticalQueryParam.getValueType(),commonStatisticalQueryParam.getStartTime(),commonStatisticalQueryParam.getEndTime()); + + + List collect1 = deviceRtData.stream().map(temp -> { + ThdDataVO vo = new ThdDataVO(); + vo.setLineId(temp.getLineId()); + vo.setPhase(temp.getPhaseType()); + String position = csLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition(); + String lineName = csLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getName(); + + vo.setLineName(lineName); + vo.setPosition(position); + vo.setTime(temp.getTime().atZone(ZoneId.systemDefault()).toLocalDateTime()); + vo.setStatMethod(temp.getValueType()); + vo.setStatisticalData(Double.valueOf(df.format(temp.getValue()))); + vo.setStatisticalIndex(epdPqd.getId()); + vo.setUnit(epdPqd.getUnit()); + vo.setStatisticalName(epdPqd.getName()); + vo.setAnotherName(epdPqd.getShowName()); + return vo; + }).collect(Collectors.toList()); + collect1 = collect1.stream().distinct().collect(Collectors.toList()); + result.addAll(collect1); + }); } - List collect1 = deviceRtData.stream().map(temp -> { - ThdDataVO vo = new ThdDataVO(); - vo.setLineId(temp.getLineId()); - vo.setPhase(temp.getPhaseType()); - String position = csLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition(); - String lineName = csLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getName(); - - vo.setLineName(lineName); - vo.setPosition(position); - vo.setTime(temp.getTime().atZone(ZoneId.systemDefault()).toLocalDateTime()); - vo.setStatMethod(temp.getValueType()); - vo.setStatisticalData(Double.valueOf(df.format(temp.getValue()))); - vo.setStatisticalIndex(data.getId()); - vo.setUnit(data.getUnit()); - return vo; - }).collect(Collectors.toList()); - collect1 = collect1.stream().distinct().collect(Collectors.toList()); - return collect1; + return result; } private String phaseReflection(String phase){ diff --git a/cs-system/cs-system-api/src/main/java/com/njcn/cssystem/api/FeedBackFeignClient.java b/cs-system/cs-system-api/src/main/java/com/njcn/cssystem/api/FeedBackFeignClient.java new file mode 100644 index 0000000..aa3581a --- /dev/null +++ b/cs-system/cs-system-api/src/main/java/com/njcn/cssystem/api/FeedBackFeignClient.java @@ -0,0 +1,26 @@ +package com.njcn.cssystem.api; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.njcn.common.pojo.constant.ServerInfo; +import com.njcn.common.pojo.response.HttpResult; +import com.njcn.cssystem.api.fallback.FeedBackFeignClientFallbackFactory; +import com.njcn.cssystem.pojo.param.CsFeedbackQueryParm; +import com.njcn.cssystem.pojo.vo.CsFeedbackVO; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +import java.util.List; + +/** + * @author xy + */ +@FeignClient(value = ServerInfo.CS_SYSTEM_BOOT, path = "/feedback", fallbackFactory = FeedBackFeignClientFallbackFactory.class,contextId = "feedback") +public interface FeedBackFeignClient { + + + @PostMapping("/queryFeedBackPage") + HttpResult> queryFeedBackPage(@Validated @RequestBody CsFeedbackQueryParm csFeedbackQueryParm); +} diff --git a/cs-system/cs-system-api/src/main/java/com/njcn/cssystem/api/fallback/FeedBackFeignClientFallbackFactory.java b/cs-system/cs-system-api/src/main/java/com/njcn/cssystem/api/fallback/FeedBackFeignClientFallbackFactory.java new file mode 100644 index 0000000..84a4dc9 --- /dev/null +++ b/cs-system/cs-system-api/src/main/java/com/njcn/cssystem/api/fallback/FeedBackFeignClientFallbackFactory.java @@ -0,0 +1,41 @@ +package com.njcn.cssystem.api.fallback; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.njcn.common.pojo.enums.response.CommonResponseEnum; +import com.njcn.common.pojo.exception.BusinessException; +import com.njcn.common.pojo.response.HttpResult; + +import com.njcn.cssystem.api.FeedBackFeignClient; +import com.njcn.cssystem.pojo.param.CsFeedbackQueryParm; +import com.njcn.cssystem.pojo.vo.CsFeedbackVO; +import feign.hystrix.FallbackFactory; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.List; + +/** + * @author xy + */ +@Slf4j +@Component +public class FeedBackFeignClientFallbackFactory implements FallbackFactory { + @Override + public FeedBackFeignClient create(Throwable cause) { + //判断抛出异常是否为解码器抛出的业务异常 + Enum exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK; + if (cause.getCause() instanceof BusinessException) { + BusinessException businessException = (BusinessException) cause.getCause(); + } + Enum finalExceptionEnum = exceptionEnum; + return new FeedBackFeignClient() { + + @Override + public HttpResult> queryFeedBackPage(CsFeedbackQueryParm csFeedbackQueryParm) { + log.error("{}异常,降级处理,异常为:{}","获取反馈接口异常",cause.toString()); + throw new BusinessException(finalExceptionEnum); + } + }; + } +} diff --git a/cs-system/cs-system-boot/src/main/java/com/njcn/cssystem/controller/feedback/FeedBackController.java b/cs-system/cs-system-boot/src/main/java/com/njcn/cssystem/controller/feedback/FeedBackController.java index 6cac724..bef1f9f 100644 --- a/cs-system/cs-system-boot/src/main/java/com/njcn/cssystem/controller/feedback/FeedBackController.java +++ b/cs-system/cs-system-boot/src/main/java/com/njcn/cssystem/controller/feedback/FeedBackController.java @@ -2,6 +2,7 @@ package com.njcn.cssystem.controller.feedback; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.njcn.common.pojo.annotation.OperateInfo; import com.njcn.common.pojo.enums.common.LogEnum; import com.njcn.common.pojo.enums.response.CommonResponseEnum; @@ -65,10 +66,10 @@ public class FeedBackController extends BaseController { @PostMapping("/queryFeedBackPage") @ApiOperation("查询反馈列表") @ApiImplicitParam(name = "csFeedbackQueryParm", value = "新增反馈聊天参数", required = true) - public HttpResult> queryFeedBackPage(@Validated @RequestBody CsFeedbackQueryParm csFeedbackQueryParm){ + public HttpResult> queryFeedBackPage(@Validated @RequestBody CsFeedbackQueryParm csFeedbackQueryParm){ String methodDescribe = getMethodDescribe("queryFeedBackPage"); - IPage csFeedbackVOIPage = csFeedbackService.queryFeedBackPage(csFeedbackQueryParm); + Page csFeedbackVOIPage = csFeedbackService.queryFeedBackPage(csFeedbackQueryParm); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, csFeedbackVOIPage, methodDescribe); } diff --git a/cs-system/cs-system-boot/src/main/java/com/njcn/cssystem/service/CsFeedbackService.java b/cs-system/cs-system-boot/src/main/java/com/njcn/cssystem/service/CsFeedbackService.java index 72ca0e2..ab78379 100644 --- a/cs-system/cs-system-boot/src/main/java/com/njcn/cssystem/service/CsFeedbackService.java +++ b/cs-system/cs-system-boot/src/main/java/com/njcn/cssystem/service/CsFeedbackService.java @@ -1,6 +1,7 @@ package com.njcn.cssystem.service; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; import com.njcn.cssystem.pojo.param.CsFeedbackAddParm; import com.njcn.cssystem.pojo.param.CsFeedbackAuditParm; @@ -36,7 +37,7 @@ public interface CsFeedbackService extends IService{ * @Author: clam * @Date: 2023/4/6 */ - IPage queryFeedBackPage(CsFeedbackQueryParm csFeedbackQueryParm); + Page queryFeedBackPage(CsFeedbackQueryParm csFeedbackQueryParm); /** * @Description: queryFeedBackDetail * @Param: [id] diff --git a/cs-system/cs-system-boot/src/main/java/com/njcn/cssystem/service/impl/CsFeedbackServiceImpl.java b/cs-system/cs-system-boot/src/main/java/com/njcn/cssystem/service/impl/CsFeedbackServiceImpl.java index 6e884ea..dc2dd9e 100644 --- a/cs-system/cs-system-boot/src/main/java/com/njcn/cssystem/service/impl/CsFeedbackServiceImpl.java +++ b/cs-system/cs-system-boot/src/main/java/com/njcn/cssystem/service/impl/CsFeedbackServiceImpl.java @@ -80,7 +80,7 @@ public class CsFeedbackServiceImpl extends ServiceImpl queryFeedBackPage(CsFeedbackQueryParm csFeedbackQueryParm) { + public Page queryFeedBackPage(CsFeedbackQueryParm csFeedbackQueryParm) { Page page = new Page<> (csFeedbackQueryParm.getPageNum ( ), csFeedbackQueryParm.getPageSize ( )); Page returnpage = new Page<> (csFeedbackQueryParm.getPageNum ( ), csFeedbackQueryParm.getPageSize ( )); List data = roleEngineerDevFeignClient.getRoleengineer().getData();