diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/vo/FdpFaultRealDataVO.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/vo/FdpFaultRealDataVO.java new file mode 100644 index 0000000..af45be3 --- /dev/null +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/vo/FdpFaultRealDataVO.java @@ -0,0 +1,47 @@ +package com.hnac.hzims.fdp.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; +import java.util.List; + +/** + * 模型VO + * + * @author tangyu + * @created 2023-07-03 17:38 + **/ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class FdpFaultRealDataVO { + + private static final long serialVersionUID = 1L; + + /** + * 监测点ID + */ + @ApiModelProperty("监测点ID") + private String monitorId; + + @ApiModelProperty("监测点名称") + private String name; + @ApiModelProperty("位置") + private String ord; + @ApiModelProperty("单代表对应一个实时数据,多代表对应一组实时数据") + private String multi; + @ApiModelProperty("数据的物模型id") + private String instance; + @ApiModelProperty("数据的物模型属性:如果multi是“多”,则包含该字符串起始的所有属性") + private String identifier; + @ApiModelProperty("物模型是否开机:无法获取当作开机处理") + private Boolean powerOn; + + @ApiModelProperty("获取的实时数据如果MULTI是“单”则为数值,MULTI是“多”则为数组") + private List real; + @ApiModelProperty("实时数据时间,如果MULTI是“单”则为数值,MULTI是“多”则为数组") + private List realTime; +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/controller/FdpMonitorController.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/controller/FdpMonitorController.java index 18fe5f4..c43348a 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/controller/FdpMonitorController.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/controller/FdpMonitorController.java @@ -194,7 +194,8 @@ public class FdpMonitorController extends BladeController { @ApiOperationSupport(order = 160) @ApiOperation(value = "数据追溯") public R dataBack(@RequestBody DataBackVo vo) { - return R.data(service.dataBack(vo.getFaultId())); + service.dataBackV2(vo.getFaultId()); + return service.dataBackV2(vo.getFaultId()); } @PostMapping("/monthly/report/dataBack") diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/IFdpMonitorService.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/IFdpMonitorService.java index e36e698..d8f16cf 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/IFdpMonitorService.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/IFdpMonitorService.java @@ -97,7 +97,7 @@ public interface IFdpMonitorService extends BaseService { Map dataBack(String faultId); - + R dataBackV2(String faultId); Map monthlyDataBack(DataBackVo vo); /** diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpMonitorServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpMonitorServiceImpl.java index 80df684..c1bb70a 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpMonitorServiceImpl.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpMonitorServiceImpl.java @@ -40,10 +40,10 @@ import com.hnac.hzims.fdp.vo.*; import com.hnac.hzims.fdp.wrapper.FdpMonitorWrapper; import com.hnac.hzims.monitor.dto.FdpMonitorBindingDTO; import com.hnac.hzims.monitor.utils.DateUtils; -import com.hnac.hzims.util.HttpClientUtils; -import com.hnac.hzims.util.pojo.HttpResponse; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.feign.IStationClient; +import com.hnac.hzims.util.HttpClientUtils; +import com.hnac.hzims.util.pojo.HttpResponse; import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient; import com.hnac.hzinfo.datasearch.analyse.IAnalyseInstanceClient; import com.hnac.hzinfo.datasearch.analyse.domain.FieldsData; @@ -54,7 +54,6 @@ import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeDataConditionVO; import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeInstanceFieldVO; import com.hnac.hzinfo.datasearch.real.IRealDataSearchClient; import com.hnac.hzinfo.datasearch.real.po.RealDataSearchPO; - import com.xxl.job.core.log.XxlJobLogger; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -66,6 +65,7 @@ import org.springblade.core.mp.support.Query; import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.*; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; @@ -113,6 +113,9 @@ public class FdpMonitorServiceImpl extends BaseServiceImpl resultMap = new HashMap<>(); + resultMap.put("faultId", faultId); + String post = HttpRequestUtil.postCallObjectParam(resultMap, getRealByFault, "POST"); + FdpHttpResponseVo fdpHttpResponseVo = JSONObject.parseObject(post, new TypeReference() {}); + if (1==fdpHttpResponseVo.getSuccess()) { + if (Func.isNotEmpty(fdpHttpResponseVo.getData())) { + List list = JSONObject.parseObject(fdpHttpResponseVo.getData(), new TypeReference>() {}); + if (CollectionUtil.isEmpty(list)){ + return R.success("暂无数据,请稍后重试"); + } + List res =new ArrayList<>(); + for (FdpFaultRealDataVO fdpFaultRealDataVO : list) { + if (null!=fdpFaultRealDataVO.getReal()){ + for (int i = 0; i < fdpFaultRealDataVO.getReal().size(); i++ ) { + FdpFaultRealDataVO dataVO=new FdpFaultRealDataVO(); + BeanUtils.copyProperties(fdpFaultRealDataVO,dataVO); + String real = fdpFaultRealDataVO.getReal().get(i); + Date time = fdpFaultRealDataVO.getRealTime().get(i); + dataVO.setReal(Arrays.asList(real)); + dataVO.setRealTime(Arrays.asList(time)); + res.add(dataVO); + } + }else { + res.add(fdpFaultRealDataVO); + } + } +// JSONObject jsonParams = JSONObject.parseObject(fdpHttpResponseVo.getData()); +// list=list.stream().map(s -> { +// if ("单".equals(s.getMulti())) { +// if (null == s.getReal()) { +// s.setReal(new ArrayList<>().toString()); +// } else { +// String real = jsonParams.get("real").toString(); +// s.setReal(Arrays.asList(Double.valueOf(real)).toString()); +// } +// } +// return s; +// }).collect(Collectors.toList()); + return R.data(res); + } + return R.success("暂无数据,请稍后重试"); + } + return R.fail("智能诊断接口异常,请联系管理员"); + } + //此接口已经弃用20230628 + @Deprecated @Override public Map dataBack(String faultId) { //根据故障ID查询监测点列表 diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/DeviceDataController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/DeviceDataController.java index 34bfe68..a448691 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/DeviceDataController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/DeviceDataController.java @@ -2,16 +2,21 @@ package com.hnac.hzims.operational.census.controller; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzims.operational.census.service.DeviceDataService; -import com.hnac.hzims.operational.census.vo.RealVo; +import com.hnac.hzinfo.datasearch.analyse.domain.AnalyzeDataCondition; +import com.hnac.hzinfo.datasearch.analyse.domain.AnalyzeDataList; +import com.hnac.hzinfo.datasearch.analyse.domain.FieldsData; +import com.hnac.hzinfo.datasearch.real.po.RealDataSearchPO; +import com.hnac.hzinfo.sdk.core.response.HzPage; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; import org.springblade.core.tool.api.R; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import java.util.List; /** * @author ysj @@ -27,16 +32,14 @@ public class DeviceDataController { @ApiOperation("实时数据查询") @PostMapping("/real") @ApiOperationSupport(order = 1) - public R real(@RequestParam(value = "code") String code, - @RequestParam(value = "signages") String signages) { - return R.data(service.real(code,signages)); + public R> real(@RequestBody RealDataSearchPO search) { + return service.real(search); } - @ApiOperation("实时数据查询") + @ApiOperation("历史数据查询") @PostMapping("/history") @ApiOperationSupport(order = 1) - public R history(@RequestParam(value = "code") String code, - @RequestParam(value = "signages") String signages) { - return R.data(service.real(code,signages)); + public R> history(AnalyzeDataCondition analyzeDataCondition) { + return service.history(analyzeDataCondition); } } \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/DeviceDataService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/DeviceDataService.java index f9aaa2d..6726c14 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/DeviceDataService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/DeviceDataService.java @@ -2,11 +2,21 @@ package com.hnac.hzims.operational.census.service; import com.hnac.hzims.operational.census.vo.RealVo; +import com.hnac.hzinfo.datasearch.analyse.domain.AnalyzeDataCondition; +import com.hnac.hzinfo.datasearch.analyse.domain.AnalyzeDataList; +import com.hnac.hzinfo.datasearch.analyse.domain.FieldsData; +import com.hnac.hzinfo.datasearch.real.po.RealDataSearchPO; +import com.hnac.hzinfo.sdk.core.response.HzPage; +import org.springblade.core.tool.api.R; + +import java.util.List; /** * @author ysj */ public interface DeviceDataService { - RealVo real(String code, String signages); + R> real(RealDataSearchPO search); + + R> history(AnalyzeDataCondition analyzeDataCondition); } \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/DeviceDataServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/DeviceDataServiceImpl.java index 6f284f5..91ca62c 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/DeviceDataServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/DeviceDataServiceImpl.java @@ -2,12 +2,24 @@ package com.hnac.hzims.operational.census.service.impl; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; +import com.esotericsoftware.minlog.Log; import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; import com.hnac.hzims.operational.census.service.DeviceDataService; import com.hnac.hzims.operational.census.vo.RealVo; +import com.hnac.hzinfo.datasearch.PointData; +import com.hnac.hzinfo.datasearch.analyse.domain.AnalyzeDataCondition; +import com.hnac.hzinfo.datasearch.analyse.domain.AnalyzeDataList; +import com.hnac.hzinfo.datasearch.analyse.domain.FieldsData; +import com.hnac.hzinfo.datasearch.real.IRealDataSearchClient; +import com.hnac.hzinfo.datasearch.real.po.RealDataSearchPO; +import com.hnac.hzinfo.sdk.analyse.AnalyseDataSearchClient; +import com.hnac.hzinfo.sdk.core.response.HzPage; +import com.hnac.hzinfo.sdk.core.response.Result; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.MapUtils; import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.StringUtil; import org.springframework.beans.factory.annotation.Value; @@ -21,55 +33,37 @@ import java.util.stream.Collectors; /** * @author ysj */ +@Slf4j @Service @RequiredArgsConstructor public class DeviceDataServiceImpl implements DeviceDataService { - private final RedisTemplate redisTemplate; + private final IRealDataSearchClient realDataSearchClient; - @Value("${hzims.operation.realIdKey}") - public String real_id_cofig_final; - - public String device_cache_cofig_final = "hzims:equipment:emInfo:deviceCode.emInfoList"; + private final AnalyseDataSearchClient analyseDataSearchClient; + /** + * 实时数据 + * @param search + * @return + */ @Override - public RealVo real(String code, String signages) { - // 缓存设备数据 - List devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_cofig_final).toString(), new TypeReference>() { - }); - if(CollectionUtil.isEmpty(devices)){ - throw new ServiceException("不存在设备!"); - } - List filters = devices.stream().filter(device->device.getEmCode().equals(code)).collect(Collectors.toList()); - if(CollectionUtil.isEmpty(filters)){ - throw new ServiceException("不存在设备!"); + public R> real(RealDataSearchPO search) { + try{ + return realDataSearchClient.getRealDataByAnalyzeCode(search); + }catch (Exception exception){ + throw new ServiceException("系统异常!"); } - // 设备标识 - Map point = filters.get(0).getPoint(); - if(MapUtils.isEmpty(point)){ - throw new ServiceException("设备未绑定模型实列监测点位!"); - } - if(!point.containsKey(signages)){ - throw new ServiceException("设备未绑定模型实列监测点位!"); - } - // 查找realId数据 - RealVo real = new RealVo(); - real.setRealId(point.get(signages)); - real.setValue(this.getRealMap().get(real.getRealId())); - real.setQuality("0"); - return real; } - /** - * 获取实时数据 + * 历史数据 + * @param analyzeDataCondition * @return */ - private Map getRealMap() { - String json = (String) redisTemplate.opsForValue().get(real_id_cofig_final); - if(StringUtil.isBlank(json)){ - return null; - } - return JSONObject.parseObject(json, new TypeReference>() {}); + @Override + public R> history(AnalyzeDataCondition analyzeDataCondition) { + Result> result = analyseDataSearchClient.getAnalyzeDataByAnalyzeCode(analyzeDataCondition); + return R.data(result.getData()); } } \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/controller/ImsDutyMainController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/controller/ImsDutyMainController.java index 7ec8515..5382e24 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/controller/ImsDutyMainController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/controller/ImsDutyMainController.java @@ -1,7 +1,6 @@ package com.hnac.hzims.operational.duty.controller; import com.alibaba.excel.EasyExcel; -import com.alibaba.excel.util.DateUtils; import com.baomidou.mybatisplus.core.metadata.IPage; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzims.common.logs.annotation.OperationAnnotation; @@ -32,7 +31,6 @@ import javax.validation.Valid; import java.io.IOException; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; -import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -220,10 +218,21 @@ public class ImsDutyMainController extends BladeController { @GetMapping("/exportDuty") @ApiOperation(value = "导出排班计划") - public void exportTemplate(HttpServletResponse response, Integer year, Integer month, Long deptId) throws IOException { + public void exportTemplate(HttpServletResponse response, String time, Long deptId) throws IOException { + Integer year; + Integer month; if (Func.isEmpty(deptId)) { deptId = Long.valueOf(AuthUtil.getDeptId()); } + if (Func.isEmpty(time)) { + Date date = new Date(); + year = date.getYear(); + month = date.getMonth()+1; + }else { + String[] split = time.split("-"); + year=Integer.valueOf(split[0]); + month=Integer.valueOf(split[1]); + } List list = imsDutyMainService.getExcelDutyData(year, month, deptId); String deptName = sysClient.getDeptName(deptId).getData();