diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/AttributeVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/AttributeVo.java deleted file mode 100644 index e1f653d..0000000 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/AttributeVo.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.hnac.hzims.operational.report.vo; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -/** - * @author ysj - */ -@Data -@ApiModel("曲线对象") -public class AttributeVo { - - @ApiModelProperty("设备编码") - private String deviceCode; - - @ApiModelProperty("属性") - private String signage; - - @ApiModelProperty("属性名称") - private String signageName; -} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/CurveDataVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/CurveEchartVo.java similarity index 74% rename from hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/CurveDataVo.java rename to hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/CurveEchartVo.java index 17d80d6..3e60f8c 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/CurveDataVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/CurveEchartVo.java @@ -11,7 +11,7 @@ import java.util.List; */ @Data @ApiModel("运行数据对象") -public class CurveDataVo { +public class CurveEchartVo { @ApiModelProperty("设备编码") private String deviceCode; @@ -20,11 +20,11 @@ public class CurveDataVo { private String deviceName; @ApiModelProperty("负荷曲线") - private List loadCurve; + private List loadCurve; @ApiModelProperty("轴承温度曲线") - private List bearingTempCurve; + private List bearingTempCurve; @ApiModelProperty("定子温度曲线") - private List statorTempCurve; + private List statorTempCurve; } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/CurveAttributeVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/EchartValueVo.java similarity index 68% rename from hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/CurveAttributeVo.java rename to hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/EchartValueVo.java index 1d060e3..3723afe 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/CurveAttributeVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/EchartValueVo.java @@ -4,15 +4,12 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; -import java.util.List; - /** * @author ysj */ @Data -@ApiModel("曲线对象") -public class CurveAttributeVo { - +@ApiModel("运行数据对象") +public class EchartValueVo { @ApiModelProperty("属性标识") private String attribute; @@ -20,6 +17,7 @@ public class CurveAttributeVo { @ApiModelProperty("属性名称") private String attributeName; - @ApiModelProperty("曲线") - private List Curves; -} + @ApiModelProperty("值") + private Double value; + +} \ No newline at end of file diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/CurveVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/EchartVo.java similarity index 62% rename from hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/CurveVo.java rename to hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/EchartVo.java index 18299e7..4dfdfda 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/CurveVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/EchartVo.java @@ -4,17 +4,18 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import java.util.List; + /** * @author ysj */ @Data -@ApiModel("曲线对象") -public class CurveVo { - +@ApiModel("运行数据对象") +public class EchartVo { @ApiModelProperty("时间:day") private String time; - @ApiModelProperty("值") - private Double value; + @ApiModelProperty("数据值对象") + List values; } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/RunDataShowVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/RunDataShowVo.java index 557ed07..49daf8c 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/RunDataShowVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/RunDataShowVo.java @@ -5,6 +5,8 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import java.util.List; + /** * @author ysj */ @@ -29,4 +31,7 @@ public class RunDataShowVo extends RunMonthEntity { @ApiModelProperty("年计划完成率") private Double yearRate; + + @ApiModelProperty("曲线转换对象") + private List curveEcharts; } diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/plate/DataService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/plate/DataService.java index b92f9b8..8f42cc0 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/plate/DataService.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/plate/DataService.java @@ -3,6 +3,7 @@ package com.hnac.hzims.scheduled.service.operation.plate; import com.hnac.hzinfo.datasearch.analyse.domain.FieldsData; import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO; import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeCodeBySignagesVO; +import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeDataConditionVO; import com.hnac.hzinfo.sdk.analyse.po.MultiAnalyzeCodePO; import org.springblade.core.tool.api.R; @@ -23,5 +24,7 @@ public interface DataService { List periodTargetData(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, String signages); + List periodTargetSignages(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, List signages); + Float periodTargetFloat(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, Integer ride ,String signages); } diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/plate/impl/DataServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/plate/impl/DataServiceImpl.java index 8deff01..02cb9a6 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/plate/impl/DataServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/plate/impl/DataServiceImpl.java @@ -113,6 +113,44 @@ public class DataServiceImpl implements DataService { * @param accessRules 取数规则 : 0=最早值 1=最大值 2=最小值 3=平均值 4=和值 5=差值 6=最新值 * @param cycleType 间隔周期 : 0-> 秒 1-> 分 2-> 小时 3->天 4-> 周 5-> 月 6-> 年 * @param deviceCode 设备编号 + * @param signages 指标集合 + * @return + */ + @Override + public List periodTargetSignages(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, List signages) { + AnalyseCodeByAnalyseDataPO po = new AnalyseCodeByAnalyseDataPO(); + List signboardConditions = new ArrayList<>(); + signages.forEach(signage->{ + AnalyzeDataConditionPO analyzeDataConditionPO = new AnalyzeDataConditionPO(); + analyzeDataConditionPO.setFull(1); + po.setDeviceCode(deviceCode); + analyzeDataConditionPO.setKeepFigures(2); + analyzeDataConditionPO.setAccessRules(accessRules); + analyzeDataConditionPO.setSaveTimeType(cycleType); + analyzeDataConditionPO.setSignages(signage); + // 间隔 + analyzeDataConditionPO.setTimeInterval(1); + analyzeDataConditionPO.setBeginTime(LocalDateTime.parse(DateUtil.format(new Date(), startTime), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME))); + analyzeDataConditionPO.setEndTime(LocalDateTime.parse(DateUtil.format(new Date(), endTime), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME))); + signboardConditions.add(analyzeDataConditionPO); + }); + po.setSignboardConditions(signboardConditions); + log.error("period_targets_data_request {}",po); + R> result = analyseDataSearchClient.getAnalyzeDataByAnalyzeCodeAndSignages(po); + if (!result.isSuccess() || CollectionUtil.isEmpty(result.getData())) { + return new ArrayList<>(); + } + log.error("period_targets_data_resp {}",result); + return result.getData(); + } + + /*** + * 指标数据列表查询 + * @param startTime 开始时间 + * @param endTime 结束时间 + * @param accessRules 取数规则 : 0=最早值 1=最大值 2=最小值 3=平均值 4=和值 5=差值 6=最新值 + * @param cycleType 间隔周期 : 0-> 秒 1-> 分 2-> 小时 3->天 4-> 周 5-> 月 6-> 年 + * @param deviceCode 设备编号 * @param ride 配电比 * @param signages 指标 * @return diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/report/impl/ReportServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/report/impl/ReportServiceImpl.java index f0cb559..fc589d6 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/report/impl/ReportServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/report/impl/ReportServiceImpl.java @@ -36,6 +36,7 @@ import com.hnac.hzims.ticket.workTicket.vo.TicketMonthVO; import com.hnac.hzinfo.datasearch.PointData; import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO; import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeCodeBySignagesVO; +import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeDataConditionVO; import com.hnac.hzinfo.datasearch.history.IHistoryDataSearchClient; import com.hnac.hzinfo.datasearch.history.OriginalDataQuery; import com.hnac.hzinfo.datasearch.soe.ISoeClient; @@ -640,6 +641,7 @@ public class ReportServiceImpl implements ReportService { stations.forEach(station->{ RunMonthEntity run = new RunMonthEntity(); run.setStationCode(station.getCode()); + run.setStationName(station.getName()); Calendar calendar = Calendar.getInstance(); //calendar.setTime(new Date()); calendar.setTime(DateUtil.parse("2024-01-01 00:00:00",DateUtil.PATTERN_DATETIME)); @@ -885,6 +887,7 @@ public class ReportServiceImpl implements ReportService { alarm.setDeviceName(entry.getValue().get(0).getDeviceName()); alarm.setContent(entry.getKey()); alarm.setType(String.valueOf(AlarmConstants.FAULT)); + alarm.setTypeName("故障"); alarm.setCount(Math.max(entry.getValue().stream().filter(o->StringUtil.isNotBlank(o.getTraceCount())).mapToInt(soe->Integer.parseInt(soe.getTraceCount())).sum(), 1)); return alarm; }).collect(Collectors.toList()); @@ -908,12 +911,15 @@ public class ReportServiceImpl implements ReportService { if(!result.isSuccess() || ObjectUtil.isEmpty(result.getData()) || CollectionUtil.isEmpty(result.getData().getRecords())){ return new ArrayList<>(); } - return result.getData().getRecords().stream().collect(Collectors.groupingBy(StbAnalysisVO::getContent)).entrySet().stream().map(entry->{ + return result.getData().getRecords().stream().collect(Collectors.groupingBy(StbAnalysisVO::getName)).entrySet().stream().map(entry->{ RunAlarmVo alarm = new RunAlarmVo(); alarm.setAlarmTime(entry.getValue().stream().sorted(Comparator.comparing(StbAnalysisVO::getTs)).collect(Collectors.toList()).get(0).getTs()); alarm.setDeviceName(entry.getValue().get(0).getDevicename()); alarm.setContent(entry.getKey()); alarm.setType(String.valueOf(AlarmConstants.EARLY)); + alarm.setTypeName("智能预警"); + alarm.setReason(entry.getValue().get(0).getFinfo()); + alarm.setMemo(entry.getValue().get(0).getInfo()); alarm.setCount(entry.getValue().size()); return alarm; }).collect(Collectors.toList()); @@ -925,8 +931,8 @@ public class ReportServiceImpl implements ReportService { * @return */ private String curveData(List devices) { - List curveDatas = devices.stream().map(device->{ - CurveDataVo curveData = new CurveDataVo(); + List curveDatas = devices.stream().map(device->{ + CurveEchartVo curveData = new CurveEchartVo(); curveData.setDeviceCode(device.getNumber()); curveData.setDeviceName(device.getName()); // 负荷曲线 @@ -945,8 +951,10 @@ public class ReportServiceImpl implements ReportService { * @param attributes * @param deviceCode * @return + * + * */ - private List curve(List attributes, String deviceCode) { + private List curve(List attributes, String deviceCode) { Calendar calendar = Calendar.getInstance(); //calendar.setTime(new Date()); calendar.setTime(DateUtil.parse("2024-01-01 00:00:00",DateUtil.PATTERN_DATETIME)); @@ -958,33 +966,47 @@ public class ReportServiceImpl implements ReportService { calendar.add(Calendar.MINUTE, -calendar.get(Calendar.MINUTE)); calendar.add(Calendar.SECOND, -calendar.get(Calendar.SECOND)); String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); - List curveAttributes = new ArrayList<>(); - attributes.forEach(attribute -> { - CurveAttributeVo signage = new CurveAttributeVo(); - signage.setAttribute(attribute.getSignage()); - signage.setAttributeName(attribute.getSignageName()); - List records = dataService.periodTargetData(start,end,3,3,deviceCode,attribute.getSignage()); - if(CollectionUtil.isEmpty(records)){ + List datas = dataService.periodTargetSignages(start,end,3,3,deviceCode,attributes.stream().map(AttributeVo::getSignage).collect(Collectors.toList())); + if(CollectionUtil.isEmpty(datas)){ + return new ArrayList<>(); + } + List analyseDatas = new ArrayList<>(); + Calendar day = Calendar.getInstance(); + datas.forEach(data->{ + if(CollectionUtil.isEmpty(data.getList())){ return; } - signage.setCurves(records.stream().map(record -> { - CurveVo curve = new CurveVo(); - Date date = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s"); - if(date.getDate() > 9){ - curve.setTime("0" + date.getDay()); + analyseDatas.addAll(data.getList().stream().peek(item->{ + item.setSignage(data.getSignage()); + Date date = DateUtil.parse(item.getTs(), "yyyy-MM-dd HH:mm:ss.s"); + day.setTime(date); + if(day.get(Calendar.DAY_OF_MONTH) <= 9){ + item.setTs("0" + day.get(Calendar.DAY_OF_MONTH)); }else{ - curve.setTime(date.getDay() + ""); + item.setTs(day.get(Calendar.DAY_OF_MONTH) + ""); } - if(StringUtil.isEmpty(record.getVal())){ - curve.setValue(0.0); + }).collect(Collectors.toList())); + }); + if(CollectionUtil.isEmpty(analyseDatas)){ + return new ArrayList<>(); + } + Map> map = analyseDatas.stream().collect(Collectors.groupingBy(AnalyseDataTaosVO::getTs)); + return map.entrySet().stream().map(entry->{ + EchartVo echart = new EchartVo(); + echart.setTime(entry.getKey()); + echart.setValues(entry.getValue().stream().map(value->{ + EchartValueVo echartValue = new EchartValueVo(); + echartValue.setAttribute(value.getSignage()); + echartValue.setAttributeName(attributes.stream().filter(o->o.getSignage().equals(value.getSignage())).collect(Collectors.toList()).get(0).getSignageName()); + if(StringUtil.isEmpty(value.getVal())){ + echartValue.setValue(0.0); }else{ - curve.setValue(Double.valueOf(record.getVal())); + echartValue.setValue(Double.parseDouble(value.getVal())); } - return curve; + return echartValue; }).collect(Collectors.toList())); - curveAttributes.add(signage); - }); - return curveAttributes; + return echart; + }).sorted(Comparator.comparing(EchartVo::getTime)).collect(Collectors.toList()); } /** diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonthServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonthServiceImpl.java index f8909b0..e44e5bf 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonthServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonthServiceImpl.java @@ -6,9 +6,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.hnac.hzims.operational.report.entity.RunMonthEntity; import com.hnac.hzims.operational.report.mapper.RunMonthMapper; import com.hnac.hzims.operational.report.service.RunMonthService; -import com.hnac.hzims.operational.report.vo.RunAlarmVo; -import com.hnac.hzims.operational.report.vo.RunDataShowVo; -import com.hnac.hzims.operational.report.vo.RunDataVo; +import com.hnac.hzims.operational.report.vo.*; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.poi.hssf.usermodel.*; @@ -33,7 +31,10 @@ import java.io.IOException; import java.math.BigDecimal; import java.math.RoundingMode; import java.net.URLEncoder; +import java.util.ArrayList; +import java.util.Collections; import java.util.List; +import java.util.stream.Collectors; /** * @author ysj @@ -81,6 +82,7 @@ public class RunMonthServiceImpl extends BaseServiceImpl runData = JSONObject.parseObject(entity.getRunData(),new TypeReference>(){}); row = this.runDataFill(hssWB,sheet,row,runData); // 二、表头格式设置 this.titleHeader(hssWB, sheet,"2、告警报表",row); - row =+ 1; + row += 1; // 告警数据表头 this.alarmHeader(hssWB,sheet,row); - row =+ 1; + row += 1; // 告警数据填充 List runAlarm = JSONObject.parseObject(entity.getAlarmData(),new TypeReference>(){}); row = this.alarmDataFill(hssWB,sheet,row,runAlarm); // 三、表头格式设置 this.titleHeader(hssWB, sheet,"3、机组负荷、温度曲线",row); - row =+ 1; + row += 1; // 四、表头格式设置 this.titleHeader(hssWB, sheet,"4、运行数据分析",row); - row =+ 1; + row += 1; // 五、表头格式设置 this.titleHeader(hssWB, sheet,"5、运行建议及其他",row); - row =+ 1; + row += 1; return hssWB; } @@ -180,12 +182,12 @@ public class RunMonthServiceImpl extends BaseServiceImpl detail(@RequestParam Long id) { + return R.data(workTaskService.getById(id)); + } + + @GetMapping("/preview") + @ApiOperationSupport(order = 3) @ApiOperation(value = "工作任务单预览", notes = "工作任务单预览") public void preview(@RequestParam @ApiParam("工作任务单预览主键ID") @NotNull @Valid Long id) { workTaskService.preview(id); } @GetMapping("/workTicketList") - @ApiOperationSupport(order = 3) + @ApiOperationSupport(order = 4) @ApiOperation(value = "查询工作票") public R> workTicketList(@RequestParam(value = "ticketCode",required = false) String ticketCode) { return R.data(workTaskService.workTicketList(ticketCode)); } @PostMapping("/startProcess") - @ApiOperationSupport(order = 4) + @ApiOperationSupport(order = 5) @ApiOperation(value = "工作任务单") public R startV4(@RequestBody WorkTaskVO workTask) { return R.status(workTaskService.start(workTask));