| | |
| | | import com.iailab.module.data.api.dto.IndexQueryDTO; |
| | | import com.iailab.module.data.api.dto.echarts.BarLineDTO; |
| | | import com.iailab.module.data.api.dto.echarts.SeriesItem; |
| | | import com.iailab.module.data.channel.kio.entity.ChannelKioDeviceEntity; |
| | | import com.iailab.module.data.common.utils.Constant; |
| | | import com.iailab.module.data.common.utils.R; |
| | | import com.iailab.module.data.api.dto.ApiPointValueQueryDTO; |
| | | import com.iailab.module.data.point.collection.PointCollector; |
| | |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.iailab.framework.common.pojo.CommonResult.success; |
| | | import static com.iailab.framework.common.pojo.CommonResult.error; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | |
| | | |
| | | @PostMapping("/point/history") |
| | | @Operation(summary = "point历史数据") |
| | | public R pointHistory(HttpServletResponse response, HttpServletRequest |
| | | public CommonResult<Map<String, List<Map<String, Object>>>> pointHistory(HttpServletResponse response, HttpServletRequest |
| | | request, @RequestBody ApiPointValueQueryDTO queryDto) { |
| | | try { |
| | | apiSecurityUtils.validate(request); |
| | | Map<String, List<Map<String, Object>>> data = new HashMap<>(); |
| | | if (CollectionUtils.isEmpty(queryDto.getPointNos())) { |
| | | return R.ok().put("data", data); |
| | | return success(data); |
| | | } |
| | | if (queryDto.getStart() == null) { |
| | | queryDto.setStart(new Date()); |
| | |
| | | params.put("pointNos", queryDto.getPointNos()); |
| | | List<DaPointDTO> pointList = daPointService.list(params); |
| | | if (CollectionUtils.isEmpty(pointList)) { |
| | | return R.ok().put("data", data); |
| | | return success(data); |
| | | } |
| | | List<InfluxPointValuePOJO> influxParams = pointList.stream().map(item -> { |
| | | InfluxPointValuePOJO pojo = new InfluxPointValuePOJO(); |
| | |
| | | return pojo; |
| | | }).collect(Collectors.toList()); |
| | | data = influxDBService.queryPointsValues(influxParams, queryDto.getStart(), queryDto.getEnd()); |
| | | return R.ok().put("data", data); |
| | | return success(data); |
| | | |
| | | } catch (Exception ex) { |
| | | return R.error(ex.getMessage()); |
| | | return new CommonResult<Map<String, List<Map<String, Object>>>>().setMsg(ex.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @PostMapping("/point/current") |
| | | @Operation(summary = "point当前实时数据") |
| | | public R pointCurrent(HttpServletResponse response, HttpServletRequest |
| | | public CommonResult<Map<String, Object>> pointCurrent(HttpServletResponse response, HttpServletRequest |
| | | request, @RequestBody List<String> pointNos) { |
| | | try { |
| | | // apiSecurityUtils.validate(request); |
| | | Map<String, Object> data = pointCollector.getCurrentValue(pointNos); |
| | | return R.ok().put("data", data); |
| | | return success(data); |
| | | } catch (Exception ex) { |
| | | return R.error(ex.getMessage()); |
| | | return new CommonResult<Map<String, Object>>().setMsg(ex.getMessage()); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | @PostMapping("/pointRelation/history") |
| | | @Operation(summary = "pointRelation历史数据") |
| | | public R pointRelationHistory(HttpServletResponse response, HttpServletRequest |
| | | public CommonResult<Map<String, List<Map<String, Object>>>> pointRelationHistory(HttpServletResponse response, HttpServletRequest |
| | | request, @RequestBody ApiPointValueQueryDTO queryDto) { |
| | | try { |
| | | Map<String, List<Map<String, Object>>> data = new HashMap<>(); |
| | | if (CollectionUtils.isEmpty(queryDto.getPointNos())) { |
| | | return R.ok().put("data", data); |
| | | return success(data); |
| | | } |
| | | if (queryDto.getStart() == null) { |
| | | queryDto.setStart(new Date()); |
| | |
| | | } |
| | | data = daPointValueService.getHistoryList(queryDto); |
| | | if (CollectionUtils.isEmpty(data)) { |
| | | return R.ok().put("data", data); |
| | | return success(data); |
| | | } |
| | | return R.ok().put("data", data); |
| | | return success(data); |
| | | } catch (Exception ex) { |
| | | return R.error(ex.getMessage()); |
| | | return new CommonResult<Map<String, List<Map<String, Object>>>>().setMsg(ex.getMessage()); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | @PostMapping("/ind-item/values") |
| | | @Operation(summary = "point当前实时数据") |
| | | public R indItemValues(HttpServletResponse response, HttpServletRequest |
| | | public CommonResult<Map<String, List<IndItemValueDTO>>> indItemValues(HttpServletResponse response, HttpServletRequest |
| | | request, @RequestBody List<String> itemNos) { |
| | | try { |
| | | // apiSecurityUtils.validate(request); |
| | | Map<String, List<IndItemValueDTO>> data = indItemCollector.getValueList(itemNos); |
| | | return R.ok().put("data", data); |
| | | return success(data); |
| | | } catch (Exception ex) { |
| | | return R.error(ex.getMessage()); |
| | | return new CommonResult<Map<String, List<IndItemValueDTO>>>().setMsg(ex.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @PostMapping("/ind-item/current-value") |
| | | @Operation(summary = "point当前实时数据") |
| | | public R indItemCurrentValue(HttpServletResponse response, HttpServletRequest |
| | | public CommonResult<Map<String, BigDecimal>> indItemCurrentValue(HttpServletResponse response, HttpServletRequest |
| | | request, @RequestBody List<String> itemNos) { |
| | | try { |
| | | Map<String, BigDecimal> data = new HashMap<>(); |
| | |
| | | dataList.forEach((k, v) -> { |
| | | data.put(k, CollectionUtils.isEmpty(v) ? null : v.get(0).getDataValue()); |
| | | }); |
| | | return R.ok().put("data", data); |
| | | return success(data); |
| | | } catch (Exception ex) { |
| | | return R.error(ex.getMessage()); |
| | | return new CommonResult<Map<String, BigDecimal>>().setMsg(ex.getMessage()); |
| | | } |
| | | } |
| | | } |