This commit is contained in:
高云鹏 2024-11-04 17:53:27 +08:00
commit f64b357a1a
24 changed files with 574 additions and 49 deletions

View File

@ -140,7 +140,7 @@ public class GlobalExceptionHandler {
@ResponseStatus(HttpStatus.BAD_REQUEST)
public R handlerNullPointException(NullPointerException exception) {
String message = exception.getMessage();
log.error("全局捕获null错误信息: {}", exception, exception);
log.error("全局捕获null错误信息", exception);
return R.fail(message);
}
@ -164,7 +164,7 @@ public class GlobalExceptionHandler {
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public R handlerBindException(Exception exception) {
String message = exception.getMessage();
log.error("全局捕获错误信息: {}", exception, exception);
log.error("全局捕获错误信息", exception);
return R.fail(message);
}
}

View File

@ -6,6 +6,7 @@ import cn.hutool.core.lang.Validator;
import cn.hutool.core.util.StrUtil;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.springframework.boot.configurationprocessor.json.JSONTokener;
import org.springframework.util.AntPathMatcher;
import java.util.*;
@ -347,4 +348,18 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
return str.matches("[a-zA-Z]+");
}
/**
* 判断是否为JSON
* @param jsonString
* @return
*/
public static boolean isJsonString(String jsonString) {
try {
new JSONTokener(jsonString).nextValue();
return true;
} catch (Exception e) {
return false;
}
}
}

View File

@ -13,7 +13,24 @@ public interface EquipmentCache {
* @return List<DeviceInfoCache>
*/
public List<DeviceInfoCache> getDevicesCache();
/**
* 刷新指定设备缓存
* @param deviceId
*/
public void refreshDeviceCache(Long deviceId);
DeviceInfoCache getDeviceInfoCache(String deviceCode);
DeviceInfoCache getDeviceInfoCache(Long deviceId);
/**
* 通过设备Code获取设备缓存信息
* @param deviceCode
* @return
*/
DeviceInfoCache getDeviceInfoCacheByCode(String deviceCode);
/**
* 通过设备ID获取设备缓存信息
* @param deviceId
* @return
*/
DeviceInfoCache getDeviceInfoCacheById(Long deviceId);
}

View File

@ -5,6 +5,7 @@ import com.das.modules.cache.service.EquipmentCache;
import com.das.modules.equipment.entity.SysEquipment;
import com.das.modules.equipment.mapper.SysEquipmentMapper;
import jakarta.annotation.PostConstruct;
import jakarta.annotation.PreDestroy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -51,13 +52,17 @@ public class EquipmentCacheImpl implements EquipmentCache {
/**
* 释放设备缓存信息
*/
@PreDestroy
private void freeDeviceInfoCaches() {
deviceInfoCaches.clear();
deviceCodeIndex.clear();
}
/**
* 获取设备缓存列表
* @return List<DeviceInfoCache>
*/
@Override
public List<DeviceInfoCache> getDevicesCache() {
return Collections.unmodifiableList(deviceInfoCaches);
@ -89,7 +94,7 @@ public class EquipmentCacheImpl implements EquipmentCache {
}
@Override
public DeviceInfoCache getDeviceInfoCache(String deviceCode) {
public DeviceInfoCache getDeviceInfoCacheByCode(String deviceCode) {
Integer index = deviceCodeIndex.get(deviceCode);
if (index != null) {
return deviceInfoCaches.get(index);
@ -98,7 +103,7 @@ public class EquipmentCacheImpl implements EquipmentCache {
}
@Override
public DeviceInfoCache getDeviceInfoCache(Long deviceId) {
public DeviceInfoCache getDeviceInfoCacheById(Long deviceId) {
Integer index = deviceIdIndex.get(deviceId);
if (index != null) {
return deviceInfoCaches.get(index);

View File

@ -37,7 +37,7 @@ public class FunctionRealData extends AbstractFunction {
public AviatorObject call(Map<String, Object> env, AviatorObject deviceCode, AviatorObject attributes) {
//设备Code
String code = (String)deviceCode.getValue(env);
DeviceInfoCache deviceInfoCache = cacheService.getEquipmentCache().getDeviceInfoCache(code);
DeviceInfoCache deviceInfoCache = cacheService.getEquipmentCache().getDeviceInfoCacheByCode(code);
//属性列表
List<String> list = (List<String>)attributes.getValue(env);
List<String> attrs = list.stream().map(String::toLowerCase).toList();

View File

@ -62,7 +62,7 @@ public class FunctionSaveCalcData extends AbstractVariadicFunction {
if ( (args.length - 1) % 3 != 0) { return AviatorRuntimeJavaType.valueOf(1);}
//deviceCode
String code = (String)args[0].getValue(env);
DeviceInfoCache deviceInfoCache = cacheService.getEquipmentCache().getDeviceInfoCache(code);
DeviceInfoCache deviceInfoCache = cacheService.getEquipmentCache().getDeviceInfoCacheByCode(code);
List<CalculateRTData> dataList = new ArrayList<>();
for (int i = 1; i < args.length; i+=3) {
Date date = (Date)FunctionUtils.getJavaObject(args[i], env);

View File

@ -385,19 +385,19 @@ public class TDEngineService {
for (DeviceEventInfo dv : list) {
sb.append("E_");
sb.append(dv.getDeviceId());
sb.append(" using event_info tags (");
sb.append(" using event_info tags ('");
sb.append(dv.getDeviceCode());
sb.append(",");
sb.append("','");
sb.append(dv.getDeviceName());
sb.append(") values (");
sb.append("') values (");
sb.append(dv.getUpdateTime());
sb.append(",");
sb.append(dv.getEventId());
sb.append(",");
sb.append(dv.getEventLevel());
sb.append(",");
sb.append(",'");
sb.append(dv.getEventText());
sb.append(",");
sb.append("',");
sb.append(dv.getConfirmed());
sb.append(",");
sb.append(dv.getConfirmAccount());

View File

@ -299,7 +299,7 @@ public class NodeMessageServiceImpl implements NodeMessageService {
});
log.info("消息data转化deviceVo,{}",list);
for (DeviceEventVo item : list){
DeviceInfoCache deviceInfoCache = cacheService.getEquipmentCache().getDeviceInfoCache(Long.valueOf(item.getDeviceId()));
DeviceInfoCache deviceInfoCache = cacheService.getEquipmentCache().getDeviceInfoCacheById(Long.valueOf(item.getDeviceId()));
DeviceEventInfo deviceEventInfo = new DeviceEventInfo();
deviceEventInfo.setUpdateTime(item.getEventTime());
deviceEventInfo.setEventId(IdWorker.getId());
@ -317,11 +317,15 @@ public class NodeMessageServiceImpl implements NodeMessageService {
}
deviceEventInfo.setEventLevel(0);
deviceEventInfo.setConfirmed(0);
if (!StringUtils.isEmpty(fieldName) && fieldName.equals("遥信变位")){
deviceEventInfo.setEventText(fieldName + eventType + "负归");
if (!StringUtils.isEmpty(eventType) && eventType.equals("遥信变位")){
if (item.getAttrValue().equals(0)){
deviceEventInfo.setEventText(fieldName + " 复归");
}else {
deviceEventInfo.setEventText(fieldName + " 动作");
}
}
else{
deviceEventInfo.setEventText(fieldName + eventType + "属性值为:"+item.getAttrValue()+",越限值为:"+item.getLimitValue());
deviceEventInfo.setEventText(fieldName + eventType + ",属性值为:"+item.getAttrValue()+",越限值为:"+item.getLimitValue());
}
valueList.add(deviceEventInfo);
}

View File

@ -0,0 +1,81 @@
package com.das.modules.page.controller;
import cn.dev33.satoken.stp.StpUtil;
import com.das.common.constant.SysAuthorityIds;
import com.das.common.exceptions.ServiceException;
import com.das.common.result.R;
import com.das.common.utils.PageDataInfo;
import com.das.modules.page.domian.dto.SysReportTemplateDto;
import com.das.modules.page.domian.vo.SysReportTemplateVo;
import com.das.modules.page.service.ReportTemplateService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
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.RestController;
/**
* 报表相关Controller
*/
@Slf4j
@RequestMapping("/api/report/template")
@RestController
public class ReportTemplateController {
@Autowired
private ReportTemplateService reportTemplateService;
/**
* 根据模板分类查询模板列表
* @return 模板列表
*/
@PostMapping("/getList")
public R<PageDataInfo<SysReportTemplateVo>> getReportTemplateList(@RequestBody SysReportTemplateDto sysReportTemplateDto) {
if (sysReportTemplateDto.getPageNum() == null) {
sysReportTemplateDto.setPageNum(1);
}
if (sysReportTemplateDto.getPageSize() == null) {
sysReportTemplateDto.setPageSize(30);
}
PageDataInfo<SysReportTemplateVo> reportTemplateList = reportTemplateService.getReportTemplateList(sysReportTemplateDto);
return R.success(reportTemplateList);
}
/**
* 新增报表模板;
*/
@PostMapping("/add")
public R<SysReportTemplateVo> addReportTemplate(@RequestBody SysReportTemplateDto sysReportTemplateDto) {
//判断是否有权限
boolean hasPermission = StpUtil.hasPermission(SysAuthorityIds.SYS_AUTHORITY_ID_DEVICE_CTRL.toString());
if(!hasPermission){
return R.fail("没有控制权限");
}
if (StringUtils.isBlank(sysReportTemplateDto.getTemplate()) || StringUtils.isBlank(sysReportTemplateDto.getCategory())){
throw new ServiceException("参数缺失");
}
SysReportTemplateVo sysReportTemplateVo = reportTemplateService.addReportTemplate(sysReportTemplateDto);
return R.success(sysReportTemplateVo);
}
/**
* 新增报表模板;
*/
@PostMapping("/del")
public R<Void> delReportTemplate(@RequestBody SysReportTemplateDto sysReportTemplateDto) {
//判断是否有权限
boolean hasPermission = StpUtil.hasPermission(SysAuthorityIds.SYS_AUTHORITY_ID_DEVICE_CTRL.toString());
if(!hasPermission){
return R.fail("没有控制权限");
}
if (sysReportTemplateDto.getId() ==null){
throw new ServiceException("参数缺失");
}
reportTemplateService.delReportTemplate(sysReportTemplateDto);
return R.success();
}
}

View File

@ -0,0 +1,40 @@
package com.das.modules.page.domian.dto;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import java.io.Serializable;
@Data
public class SysReportTemplateDto implements Serializable {
/**
* id
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long id;
/**
*报表分类:单机报表多机报表
*/
private String category;
/**
* 模板内容
*/
private String template;
/**
* 分页大小
*/
private Integer pageSize;
/**
* 当前页数
*/
private Integer pageNum;
}

View File

@ -0,0 +1,29 @@
package com.das.modules.page.domian.vo;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import java.io.Serial;
@Data
public class SysReportTemplateVo {
/**
* id
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long id;
/**
*报表分类:单机报表多机报表
*/
private String category;
/**
* 模板内容
*/
private String template;
}

View File

@ -0,0 +1,39 @@
package com.das.modules.page.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.das.common.constant.BaseEntity;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import java.io.Serial;
@TableName("sys_report_template")
@Data
public class SysReportTemplate extends BaseEntity {
@Serial
private static final long serialVersionUID = 1L;
/**
* id
*/
@TableId(value = "id", type = IdType.ASSIGN_ID)
@JsonSerialize(using = ToStringSerializer.class)
private Long id;
/**
*报表分类:单机报表多机报表
*/
@TableField("category")
private String category;
/**
* 模板内容
*/
@TableField("template")
private String template;
}

View File

@ -0,0 +1,15 @@
package com.das.modules.page.mapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.das.modules.auth.mapper.BaseMapperPlus;
import com.das.modules.page.domian.dto.SysReportTemplateDto;
import com.das.modules.page.domian.vo.SysReportTemplateVo;
import com.das.modules.page.entity.SysReportTemplate;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface SysReportTemplateMapper extends BaseMapperPlus<SysReportTemplate,SysReportTemplate> {
IPage<SysReportTemplateVo> queryReportTemplateListInPage(IPage<SysReportTemplateVo> page, @Param("info") SysReportTemplateDto sysReportTemplateDto);
}

View File

@ -0,0 +1,27 @@
package com.das.modules.page.service;
import com.das.common.utils.PageDataInfo;
import com.das.modules.page.domian.dto.SysReportTemplateDto;
import com.das.modules.page.domian.vo.SysReportTemplateVo;
public interface ReportTemplateService {
/**
* 根据模板分类查询模板列表
* @return 模板列表
*/
PageDataInfo<SysReportTemplateVo> getReportTemplateList( SysReportTemplateDto sysReportTemplateDto);
/**
* 新增报表模板
* @param sysReportTemplateDto
* @return报表模板
*/
SysReportTemplateVo addReportTemplate(SysReportTemplateDto sysReportTemplateDto);
/**
* 删除模板
* @param sysReportTemplateDto
*/
void delReportTemplate(SysReportTemplateDto sysReportTemplateDto);
}

View File

@ -0,0 +1,61 @@
package com.das.modules.page.service.impl;
import cn.dev33.satoken.stp.StpUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.das.common.config.SessionUtil;
import com.das.common.exceptions.ServiceException;
import com.das.common.utils.BeanCopyUtils;
import com.das.common.utils.PageDataInfo;
import com.das.common.utils.PageQuery;
import com.das.common.utils.StringUtils;
import com.das.modules.auth.domain.vo.SysUserVo;
import com.das.modules.page.domian.dto.SysReportTemplateDto;
import com.das.modules.page.domian.vo.SysReportTemplateVo;
import com.das.modules.page.entity.SysReportTemplate;
import com.das.modules.page.mapper.SysReportTemplateMapper;
import com.das.modules.page.service.ReportTemplateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
@Service
public class ReportTemplateServiceImpl implements ReportTemplateService {
@Autowired
private SysReportTemplateMapper sysReportTemplateMapper;
@Override
public PageDataInfo<SysReportTemplateVo> getReportTemplateList(SysReportTemplateDto sysReportTemplateDto) {
PageQuery pageQuery = new PageQuery();
pageQuery.setPageNum(sysReportTemplateDto.getPageNum());
pageQuery.setPageSize(sysReportTemplateDto.getPageSize());
IPage<SysReportTemplateVo> iPage = sysReportTemplateMapper.queryReportTemplateListInPage(pageQuery.build(), sysReportTemplateDto);
return PageDataInfo.build(iPage.getRecords(), iPage.getTotal());
}
@Override
public SysReportTemplateVo addReportTemplate(SysReportTemplateDto sysReportTemplateDto) {
if (!StringUtils.isJsonString(sysReportTemplateDto.getTemplate())){
throw new ServiceException("模板内容格式错误");
}
SysReportTemplate sysReportTemplate = new SysReportTemplate();
BeanCopyUtils.copy(sysReportTemplateDto, sysReportTemplate);
SysUserVo sysUserVo = (SysUserVo) StpUtil.getTokenSession().get(SessionUtil.SESSION_USER_KEY);
sysReportTemplate.setCreatedBy(sysUserVo.getAccount());
sysReportTemplate.setUpdatedBy(sysUserVo.getAccount());
sysReportTemplate.setCreatedTime(new Date());
sysReportTemplate.setUpdatedTime(new Date());
sysReportTemplate.setRevision(1);
sysReportTemplateMapper.insert(sysReportTemplate);
SysReportTemplateVo sysReportTemplateVo = new SysReportTemplateVo();
BeanCopyUtils.copy(sysReportTemplate, sysReportTemplateVo);
return sysReportTemplateVo;
}
@Override
public void delReportTemplate(SysReportTemplateDto sysReportTemplateDto) {
sysReportTemplateMapper.deleteById(sysReportTemplateDto.getId());
}
}

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.das.modules.page.mapper.SysReportTemplateMapper">
<resultMap type="com.das.modules.page.domian.vo.SysReportTemplateVo" id="ReportValuesMap">
<result property="id" column="id" jdbcType="BIGINT"/>
<result property="category" column="category" jdbcType="VARCHAR"/>
<result property="template" column="template" jdbcType="VARCHAR"/>
</resultMap>
<select id="queryReportTemplateListInPage" resultMap="ReportValuesMap">
select e.* from sys_report_template e
<where>
<if test="info.category != null and info.category != ''">
and e.category =#{info.category}
</if>
</where>
</select>
</mapper>

141
docs/api/pages/report.md Normal file
View File

@ -0,0 +1,141 @@
# 首页
## API接口-报表模板
| 接口分类 | 接口描述 | API接口 | 权限 |
|----------|--------------------|------------------------------| ---------------------------- |
| 2.1 报表模板 | 2.1.1 新增报表模板 | /api/report/template/add | SYS_AUTHORITY_ID_DEVICE_CTRL |
| | 2.1.2 根据模板分类查询模板列表 | /api/report/template/getList | |
| | 2.1.3 删除报表模板 | /api/report/template/del | SYS_AUTHORITY_ID_DEVICE_CTRL|
## 2.1 报表模板相关接口
### 2.1.1 新增报表模板
POST 请求接口
> /api/report/template/add
请求参数
```json
{
"category": "单机报表",
"template": "{\"name\":\"测试模板1\",\"startTime\":\"2024-11-04 14:15:00\"}"
}
```
入参描述
| 参数名 | 参数类型 | 可选 | 描述 |
| ------------ |--------|----|------------------|
| category | String | NO | 报表分类;如:单机报表;多机报表 |
| template | String | NO | 模板内容(必须为:JSON格式) |
返回报文
```json
{
"code": 200,
"success": true,
"data": {
"id": "1853330292178747393",
"category": "单机报表",
"template": "{\"name\":\"测试模板1\",\"startTime\":\"2024-11-04 14:15:00\"}"
},
"msg": "操作成功"
}
```
返参描述
| 参数名 | 参数类型 | 可选 | 描述 |
| ------------ |--------| ---- |--------|
| category | String | 否 | 报表分类 |
| template | String | 否 | 模板内容 |
### 2.1.2 根据模板分类查询模板列表
POST 请求接口
> /api/report/template/getList
请求参数
```json
{
"category": "单机报表",
"pageNum":1,
"pageSize":2
}
```
入参描述
| 参数名 | 参数类型 | 可选 | 描述 |
| ------------ |---------|-----|------------------|
| category | String | YES | 报表分类;如:单机报表;多机报表 |
| pageNum | Integer | NO | 当前页 |
| pageSize | Integer | NO | 每页显示大小|
返回报文
```json
{
"code": 200,
"success": true,
"data": {
"total": 3,
"rows": [
{
"id": "1853320886498217986",
"category": "单机报表",
"template": "{\"name\":\"测试模板2\",\"startTime\":\"2024-11-04 14:15:00\"}"
},
{
"id": "1853328049337548801",
"category": "单机报表",
"template": "{\"name\":\"测试模板3\",\"startTime\":\"2024-11-04 14:15:00\"}"
}
],
"code": 200,
"msg": "查询成功"
},
"msg": "操作成功"
}
```
返参描述
| 参数名 | 参数类型 | 可选 | 描述 |
| ------------ |--------| ---- |--------|
| category | String | 否 | 报表分类 |
| template | String | 否 | 模板内容 |
### 2.1.3 删除报表模板
POST 请求接口
> /api/report/template/del
请求参数
```json
{
"id": "1853320886498217986"
}
```
入参描述
| 参数名 | 参数类型 | 可选 | 描述 |
| ------------ | -------- | ---- |------------------------------------------------------------------|
| id | String | no | 报表模板id |
返回报文
```json
{
"code": 200,
"success": true,
"msg": "操作成功"
}
```

View File

@ -12,7 +12,9 @@
<template v-else>
<el-menu-item :index="menu.path" :key="menu.path" @click="onClickMenu(menu)">
<Icon :color="config.getColorVal('menuColor')" :name="menu.meta?.icon ? menu.meta?.icon : config.layout.menuDefaultIcon" />
<span>{{ menu.meta?.menuDesc ? menu.meta?.menuDesc : $t('noTitle') }}</span>
<!-- <span>{{ menu.meta?.menuDesc ? menu.meta?.menuDesc : $t('noTitle') }}</span> -->
<template #title>{{ menu.meta?.menuDesc ? menu.meta?.menuDesc : $t('noTitle') }}</template>
</el-menu-item>
</template>
</template>
@ -89,6 +91,15 @@ const onClickSubMenu = (menu: RouteRecordRaw) => {
}
}
}
.el-menu--collapse {
.is-active {
:deep(div) {
> .icon {
color: #ffffff !important;
}
}
}
}
.el-menu-item.is-active {
background-color: #0064aa;
}

View File

@ -484,6 +484,7 @@ const StatusListData = () => {
igenpower: item.attributeMap.igenpower,
ikwhthisday: item.attributeMap.ikwhthisday,
iturbineoperationmode: state,
locked: item.attributeMap.locked,
}
}
});
@ -515,18 +516,6 @@ const powerChartData: { time: any; values: any } = {
time: {},
values: {},
}
/*const powerChartData = {
time: {
iGenPower:['00:00','00:05','00:10','00:15'],
iTheoreticalPower:['00:00','00:05','00:10','00:15'],
iWindSpeed:['00:00','00:05','00:10','00:15']
},
values: {
iGenPower:[0,5,2,7],
iTheoreticalPower:[0,0,0,0],
iWindSpeed:[3,8,9,1]
},
}*/
const initpowerChart = () => {
const powerChart = state.charts.powerChart ?? echarts.init(powerChartRef.value as unknown as HTMLElement)
const option = {
@ -1127,10 +1116,9 @@ const tabhandleClick = () => {
inittrendChart(trendChartType.value)
})
}
onMounted(() => {
getAllChartData()
//inittrendChart(trendChartType.value)
//initpowerChart()
createScroll()
overviewList()
StatusListData()

View File

@ -56,6 +56,9 @@
</el-col>
</el-row>
</div>
<div class="fanlist-bottom">
<el-tag v-if="item.attributeMap.locked === 1" class="tag-panel is-danger">已锁定</el-tag>
</div>
</div>
</div>
@ -183,7 +186,8 @@ const animationDuration=reactive({
.fanlist-main{
width: 100%;
display: flex;
padding: 10px;
/*padding: 10px;*/
padding: 10px 10px 0 10px;
text-align: center;
.fanlist-pic{
display: flex;
@ -241,7 +245,7 @@ const animationDuration=reactive({
}
}
.fanlist-text{
margin-top:30px;
margin-top:20px;
display: flex;
flex-direction: column;
.content-number{
@ -255,5 +259,14 @@ const animationDuration=reactive({
}
}
.fanlist-bottom{
display: flex;
justify-content: end;
height: 24px;
.tag-panel{
border-radius: 0 0 8px 0;
line-height: 20px;
}
}
}
</style>

View File

@ -200,7 +200,7 @@ const pageSetting = reactive({
current: 1,
pageSize: 20,
total: 0,
pageSizes: [10, 20, 30],
pageSizes: [20, 50, 100],
})
const getcurrentPage = () => {

View File

@ -25,6 +25,7 @@
v-model="statAnalysisTime"
:type="statAnalysisInterval == '1d' ? 'daterange' : 'datetimerange'"
:value-format="statAnalysisInterval == '1d' ? 'YYYY-MM-DD' : 'YYYY-MM-DD HH:mm:ss'"
:default-time="[new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 2, 1, 23, 59, 59)]"
:teleported="false"
:shortcuts="shortcuts"
/>
@ -140,7 +141,6 @@ const queryWindTurbines = () => {
iotModelId: item.modelId,
}
})
// console.log(statAnalysisSelectOptions.deviceId)
}
})
}
@ -228,7 +228,7 @@ const statAnalysisOperate = () => {
attributes: ['iGenPower', 'iWindSpeed'],
},
],
interval: statAnalysisInterval.value,
interval: statAnalysisInterval.value || '5m',
startTime: new Date(statAnalysisTime.value[0]).getTime(),
endTime: new Date(statAnalysisTime.value[1]).getTime(),
}
@ -238,7 +238,6 @@ const historyDataReq = (data: any) => {
historyReq(data).then((res) => {
if (res.code == 200) {
const resData = res.data[statAnalysisDeviceId.value]
console.log(resData)
if (resData) {
const iGenPower = resData['iGenPower']['values']
const iWindSpeed = resData['iWindSpeed']['values']
@ -250,7 +249,6 @@ const historyDataReq = (data: any) => {
data: seriesData,
}
option.series.push(series)
console.log('🚀 ~ historyReq ~ option:', option)
chart.value.setOption(option)
}

View File

@ -48,6 +48,7 @@
:value-format="statAnalysisSelect.interval == '1d' ? 'YYYY-MM-DD' : 'YYYY-MM-DD HH:mm:ss'"
:teleported="false"
:shortcuts="shortcuts"
:default-time="[new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 2, 1, 23, 59, 59)]"
@change="timechange(index)"
/>
</div>
@ -98,7 +99,7 @@
</div>
</template>
<script setup lang="ts">
import { reactive, ref, onMounted } from 'vue'
import { reactive, ref, onMounted, markRaw } from 'vue'
import { useI18n } from 'vue-i18n'
import { queryWindTurbinesPages, historyReq } from '/@/api/backend/statAnalysis/request'
import { ElMessage } from 'element-plus'
@ -214,7 +215,7 @@ const chart: any = ref(null)
onMounted(() => {
if (chartContainer.value) {
chart.value = echarts.init(chartContainer.value)
chart.value = markRaw(echarts.init(chartContainer.value))
chart.value.setOption({
xAxis: {
type: 'category',
@ -363,7 +364,7 @@ const statAnalysisOperate = () => {
attributes: [statAnalysisSelect.attributeCode],
},
],
interval: statAnalysisSelect.interval,
interval: statAnalysisSelect.interval || '5m',
startTime: new Date(time[0]).getTime(),
endTime: new Date(time[1]).getTime(),
}
@ -388,10 +389,15 @@ const historyDataReq = (data: any, index: number) => {
})
option.tooltip = {
show: true,
trigger: 'axis',
formatter: function (params: any) {
const matchData = xDatas.filter((x: any) => x.series == params.seriesName)
const x = timestampToTime(matchData[0]['data'][params.dataIndex])
return `${params.marker} ${params.seriesName} <br/> ${x} <b>${params.data}</b>`
return params
.map((item: any) => {
const matchData = xDatas.filter((x: any) => x.series == item.seriesName)
const x = timestampToTime(matchData[0]['data'][item.dataIndex])
return `${item.marker}${item.seriesName} (${x}): ${item.data}`
})
.join('<br/>')
},
}
option.xAxis.data = Array.from({ length: xData.length }, (_, index) => index)

View File

@ -9,6 +9,7 @@
v-model="statAnalysisTime"
:type="statAnalysisInterval == '1d' ? 'daterange' : 'datetimerange'"
:value-format="statAnalysisInterval == '1d' ? 'YYYY-MM-DD' : 'YYYY-MM-DD HH:mm:ss'"
:default-time="[new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 2, 1, 23, 59, 59)]"
:teleported="false"
:shortcuts="shortcuts"
/>
@ -104,7 +105,7 @@
</div>
</template>
<script setup lang="ts">
import { onUnmounted, reactive, ref, watch, nextTick, onMounted, computed } from 'vue'
import { markRaw, reactive, ref, watch, nextTick, onMounted, computed } from 'vue'
import { useI18n } from 'vue-i18n'
import { queryWindTurbinesPages, historyReq } from '/@/api/backend/statAnalysis/request'
import { ElMessage, ElMenu } from 'element-plus'
@ -216,7 +217,7 @@ const customName = reactive(['1'])
const chart: any = ref(null)
onMounted(() => {
if (chartContainer.value) {
chart.value = echarts.init(chartContainer.value)
chart.value = markRaw(echarts.init(chartContainer.value))
chart.value.setOption({
xAxis: {
type: 'category',
@ -338,10 +339,11 @@ const statAnalysisOperate = () => {
}, [])
const requestData = {
devices: devices,
interval: statAnalysisInterval.value,
interval: statAnalysisInterval.value || '5m',
startTime: new Date(statAnalysisTime.value[0]).getTime(),
endTime: new Date(statAnalysisTime.value[1]).getTime(),
}
historyDataReq(requestData)
}
const calculate: any = reactive([{ max: '', min: '', average: '' }])
@ -366,6 +368,17 @@ const historyDataReq = (data: any) => {
data: yData,
}
calculate[dataIndex] = calculateStats(yData)
option.tooltip = {
show: true,
trigger: 'axis',
formatter: function (params: any) {
return params
.map((item: any) => {
return `${item.marker} ${item.seriesName} (${timestampToTime(xData[item.dataIndex])}): ${item.data}`
})
.join('<br/>')
},
}
option.legend.data.push(customName[dataIndex])
option.xAxis.data = xData.map((item: any) => timestampToTime(item))
option.series.push(seriesData)