能源管理
1、计量设备数据库表结构变回跟之前一样,还是用buildid字符串类型,可以存放多个建筑类型ID
2、创建计量设备时在TDengine的子表tag内容修改
3、tdengine超级表结构修改
4、电历史数据查询修改
5、修改计量设备编号、设备名称、建筑类型时,对应修改tdengine子表的tag值
TdEngine:
1、增加获取超级表历史数据接口和获取超级表历史数据数量接口
2、增加批量修改tag值接口
master
xins 2 years ago
parent 7ae4eb5d16
commit d61dedd495

@ -6,6 +6,7 @@ import com.hw.common.core.domain.R;
import com.hw.common.core.validated.tdengine.AddTdSTableColumn;
import com.hw.common.core.validated.tdengine.InsertTdTable;
import com.hw.tdengine.api.domain.*;
import com.hw.tdengine.api.domain.ems.TdSuperTableEmsSelectVo;
import com.hw.tdengine.api.factory.RemoteTdEngineFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
@ -63,4 +64,11 @@ public interface RemoteTdEngineService {
@PostMapping("/tdengine/getDeviceStatusList")
R<List<Map<String, Object>>> getDeviceStatusList(@Validated @RequestBody DeviceStatus queryDeviceStatus, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
@PostMapping("/tdengine/getSuperTableHistoryData")
R<TdReturnDataVo> getSuperTableHistoryData(@Validated @RequestBody TdSuperTableEmsSelectVo tdSuperTableEmsSelectVo, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
@PostMapping("/tdengine/alterTableTags")
public R<?> alterTableTags(@Validated @RequestBody List<AlterTagVo> alterTagVos, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
}

@ -0,0 +1,31 @@
package com.hw.tdengine.api.domain;
import com.hw.common.core.enums.DataTypeEnums;
import org.apache.commons.lang3.StringUtils;
import org.springframework.validation.annotation.Validated;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
/**
* @Description: @Description: Tdengine
* @ClassName: TdSearchFieldVo
* @Author : xins
* @Date :2023-12-29 22:34
* @Version :1.0
*/
public class TdSearchFieldVo {
private static final long serialVersionUID = 1L;
private String fieldName;
private Object fieldValue;
public TdSearchFieldVo(String fieldName, Object fieldValue) {
this.fieldName = fieldName;
this.fieldValue = fieldValue;
}
}

@ -0,0 +1,49 @@
package com.hw.tdengine.api.domain.ems;
import com.hw.tdengine.api.domain.TdSearchFieldVo;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.util.List;
/**
* @Description:
* @ClassName: TdSuperTableEmsSelectVo
* @Author : xins
* @Date :2023-12-29 22:23
* @Version :1.0
*/
@Data
public class TdSuperTableEmsSelectVo {
//数据库名称
@NotBlank(message="databaseName cannot be empty")
private String databaseName;
//超级表名称
@NotBlank(message="superTableName cannot be empty")
private String superTableName;
//控制输出条数
private int limit;
//指定从第几条之后输出例如limit 2,5输出第3行到第7行的数据
private int offset;
/**
* timestamp
*/
private String firstFieldName;
//过滤条件:开始时间
private long startTime;
//过滤条件:结束时间
private long endTime;
private Long monitorObjid;
private String orderByFieldName;
private String sort;
}

@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSONObject;
import com.hw.common.core.domain.R;
import com.hw.tdengine.api.RemoteTdEngineService;
import com.hw.tdengine.api.domain.*;
import com.hw.tdengine.api.domain.ems.TdSuperTableEmsSelectVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
@ -102,6 +103,16 @@ public class RemoteTdEngineFallbackFactory implements FallbackFactory<RemoteTdEn
return R.fail("获取设备状态信息失败:" + throwable.getMessage());
}
@Override
public R<TdReturnDataVo> getSuperTableHistoryData(TdSuperTableEmsSelectVo tdSuperTableEmsSelectVo, String source) {
return R.fail("获取超级表历史数据失败:" + throwable.getMessage());
}
@Override
public R<?> alterTableTags(List<AlterTagVo> alterTagVos, String source) {
return R.fail("批量修改子表tag值失败:" + throwable.getMessage());
}
};
}
}

@ -70,6 +70,11 @@ public class TdEngineConstants {
public static final String EMS_DATABASE_NAME = "db_hwmes";
public static final String EMS_TABLE_NAME_PREFIX = "t_e_";
public static final String ST_TAG_EMS_MONITOROBJID = "monitorobjid";//计量设备编号
public static final String ST_TAG_EMS_MONITORID = "monitorid";//计量设备主键
public static final String ST_TAG_EMS_MONITORNAME = "monitorname";//计量设备名称
public static final String ST_TAG_EMS_BUILDID = "buildid";//建筑类型ID多个以,隔开)
/**
* key
*/
@ -141,7 +146,7 @@ public class TdEngineConstants {
* @param monitorId
* @return String
*/
public static String getEmsTableName(String monitorId){
public static String getEmsTableName(Long monitorId){
return EMS_TABLE_NAME_PREFIX + monitorId;
}

@ -1,5 +1,8 @@
package com.hw.common.core.constant;
import java.util.HashMap;
import java.util.Map;
/**
* @Description:
* @ClassName: WmsConstants
@ -9,11 +12,11 @@ package com.hw.common.core.constant;
*/
public class WmsConstants {
/*原材料入库记录操作类型*/
public static final String RAW_INSTOCK_OPERATION_TYPE_AUTO = "0";//自动
public static final String RAW_INSTOCK_OPERATION_TYPE_MANUAL = "1";//手动
public static final String RAW_INSTOCK_OPERATION_TYPE_FORCE = "2";//强制
public static final String RAW_INSTOCK_OPERATION_TYPE_DISPATCH = "3";//调度
/*操作类型,适合原材料和成品的出入库以及原材料的退库*/
public static final String WMS_OPERATION_TYPE_AUTO = "0";//agv自动
public static final String WMS_OPERATION_TYPE_MANUAL = "1";//人工
public static final String WMS_OPERATION_TYPE_FORCED = "2";//强制
public static final String MWS_OPERATION_TYPE_DISPATCHD = "3";//调度
/*原材料入库记录入库类型*/
@ -22,19 +25,10 @@ public class WmsConstants {
public static final String RAW_INSTOCK_INSTOCK_TYPE_MERGE = "3";//合库入库
public static final String RAW_INSTOCK_INSTOCK_TYPE_OTHER = "9";//其他入库
/*原材料入库记录审核状态*/
public static final String RAW_INSTOCK_AUDIT_STATUS_TOAUDIT = "0";//待审核
public static final String RAW_INSTOCK_AUDIT_STATUS_PASS = "1";//审核通过
public static final String RAW_INSTOCK_AUDIT_STATUS_FAIL = "2";//审核不通过
/*原材料入库记录(明细)执行状态*/
public static final String RAW_INSTOCK_EXECUTE_STATUS_TOEXECUTE = "0";//待执行
public static final String RAW_INSTOCK_EXECUTE_STATUS_EXECUTING = "1";//执行中
public static final String RAW_INSTOCK_EXECUTE_STATUS_FINISH = "2";//执完成行
/*原材料入库记录明细入库方式*/
public static final String RWA_INSTOCK_DETAIL_INSTOCK_WAY_PC = "0";//PC入库
public static final String RWA_INSTOCK_DETAIL_INSTOCK_WAY_MOBILE = "1";//移动手持入库
public static final String RWA_INSTOCK_DETAIL_INSTOCK_WAY_MOBILE = "1";//人工入库
public static final String RWA_INSTOCK_DETAIL_INSTOCK_WAY_AGV = "2";//AGV入库
/*原材料入库记录明细质检状态*/
@ -46,51 +40,135 @@ public class WmsConstants {
public static final String RWA_STOCK_STOCK_TYPE_RAW = "1";//原材料
public static final String RWA_STOCK_STOCK_TYPE_PRODUCT = "2";//半成品
/*原材料库存记录质检状态*/
public static final String RWA_STOCK_QUALITY_STATUS_TO_INSPECT = "0";//待质检
public static final String RWA_STOCK_QUALITY_STATUS_PASS = "1";//质检通过
public static final String RWA_STOCK_QUALITY_STATUS_NG = "2";//NG质检不合格
/*原材料出库记录审核状态*/
public static final String RAW_OUTSTOCK_AUDIT_STATUS_TOAUDIT = "0";//待审核
public static final String RAW_OUTSTOCK_AUDIT_STATUS_PASS = "1";//审核通过
public static final String RAW_OUTSTOCK_AUDIT_STATUS_FAIL = "2";//审核不通过
/*原材料出库记录执行状态*/
public static final String RAW_OUTSTOCK_EXECUTE_STATUS_TO_EXECUTUTE = "0";//待执行
public static final String RAW_OUTSTOCK_EXECUTE_STATUS_EXECUTUTING = "1";//执行中
public static final String RAW_OUTSTOCK_EXECUTE_STATUS_FINISH = "2";//执行完成
/*原材料出库记录明细出库方式*/
public static final String RAW_OUTSTOCK_OUTSTOCK_WAY_MANUAL = "1";//人工出库
public static final String RAW_OUTSTOCK_OUTSTOCK_WAY_AGV = "2";//AGV出库
/*原材料出库记录明细质检状态*/
public static final String RAW_OUTSTOCK_DETAIL_QUALITY_STATUS_TO_INSPECT = "0";//待质检
public static final String RAW_OUTSTOCK_DETAIL_QUALITY_STATUS_PASS = "1";//合格
public static final String RAW_OUTSTOCK_DETAIL_QUALITY_STATUS_NG = "2";//不合格
/*原材料退库记录审核状态*/
public static final String RAW_RETURN_AUDIT_STATUS_TOAUDIT = "0";//待审核
public static final String RAW_RETURN_AUDIT_STATUS_PASS = "1";//审核通过
public static final String RAW_RETURN_AUDIT_STATUS_FAIL = "2";//审核不通过
/*出入库退库记录明细方式*/
public static final String WMS_STOCK_WAY_MANUAL = "1";//人工
public static final String WMS_STOCK_WAY_AGV = "2";//AGV
/*原材料退库记录明细质检状态*/
public static final String RAW_RETURN_DETAIL_QUALITY_STATUS_TO_INSPECT = "0";//待质检
public static final String RAW_RETURN_DETAIL_QUALITY_STATUS_PASS = "1";//质检通过
public static final String RAW_RETURN_DETAIL_QUALITY_STATUS_NG = "2";//NG质检不合格
/*原材料退库记录(明细)执行状态*/
public static final String RAW_RETURN_EXECUTE_STATUS_TOEXECUTE = "0";//待执行
public static final String RAW_RETURN_EXECUTE_STATUS_EXECUTING = "1";//执行中
public static final String RAW_RETURN_EXECUTE_STATUS_FINISH = "2";//执完成行
/*质检状态*/
public static final String WMS_QUALITY_STATUS_TO_INSPECT = "0";//待质检
public static final String WMS_QUALITY_STATUS_PASS = "1";//合格
public static final String WMS_QUALITY_STATUS_NG = "2";//不合格
/*审核状态*/
public static final String WMS_AUDIT_STATUS_TOAUDIT = "0";//待审核
public static final String WMS_AUDIT_STATUS_PASS = "1";//审核通过
public static final String WMS_AUDIT_STATUS_FAIL = "2";//审核不通过
/*原材料退库记录(明细)退库方式*/
public static final String RAW_RETURN_RETURN_WAY_MANUAL = "1";//人工
public static final String RAW_RETURN_RETURN_WAY_AGV = "2";//AGV
/*出入库退库记录(明细)执行状态*/
public static final String WMS_EXECUTE_STATUS_TOEXECUTE = "0";//待执行
public static final String WMS_EXECUTE_STATUS_EXECUTING = "1";//执行中
public static final String WMS_EXECUTE_STATUS_FINISH = "2";//执完成行
/*成品入库记录明细入库方式*/
public static final String PRODUCT_INSTOCK_DETAIL_INSTOCK_WAY_MANUAL = "1";//人工入库
public static final String PRODUCT_INSTOCK_DETAIL_INSTOCK_WAY_AGV = "2";//AGV入库
/*成品入库记录库存类型*/
public static final String PRODUCT_INSTOCK_STOCK_TYPE_SEMI = "2";//半成品
public static final String PRODUCT_INSTOCK_STOCK_TYPE_PRODUCT = "3";//成品
/*成品入库记录入库类型*/
public static final String PRODUCT_INSTOCK_INSTOCK_TYPE_PRODUCT = "1";//生产入库
public static final String PRODUCT_INSTOCK_INSTOCK_TYPE_MOVE = "2";//移库入库
public static final String PRODUCT_INSTOCK_INSTOCK_TYPE_MERGE = "3";//合库入库
public static final String PRODUCT_INSTOCK_INSTOCK_TYPE_OUT_SEMI = "4";//出半成品库
public static final String PRODUCT_INSTOCK_INSTOCK_TYPE_OTHER = "9";//其他入库
/*成品库存库存类型*/
public static final String PRODUCT_STOCK_STOCK_TYPE_SEMI = "2";//半成品
public static final String PRODUCT_STOCK_STOCK_TYPE_PRODUCT = "3";//成品
/*原材料退库记录(明细)退库方式*/
public static final String PRODUCT_INSTOCK_INSTOCK_WAY_MANUAL = "1";//人工
public static final String PRODUCT_INSTOCK_INSTOCK_WAY_AGV = "2";//AGV
/*仓库存放类型*/
public static final String WAREHOUSE_INSTOCK_TYPE_RAW = "1";//原材料
public static final String WAREHOUSE_INSTOCK_TYPE_SEMI = "2";//半成品
public static final String WAREHOUSE_INSTOCK_TYPE_PRODUCT = "3";//成品
public static final String WMS_MOVEMERGE_TYPE_MOVE = "1"; //移库
public static final String WMS_MOVEMERGE_TYPE_MERGE = "2";//合库
public static final String WMS_WAREHOUSE_TYPE_NORMAL = "0";//普通仓库
public static final String WMS_WAREHOUSE_TYPE_AGV = "1";//AGV仓库
public static final String WMS_WAREHOUSE_TYPE_WORKBIN_AGV = "2";//料箱AGV仓库
public static final Map<String, String> OPERATION_TYPE_MAP = new HashMap<String, String>();
static {
OPERATION_TYPE_MAP.put(WMS_WAREHOUSE_TYPE_NORMAL, WMS_OPERATION_TYPE_MANUAL);
OPERATION_TYPE_MAP.put(WMS_WAREHOUSE_TYPE_AGV, WMS_OPERATION_TYPE_AUTO);
OPERATION_TYPE_MAP.put(WMS_WAREHOUSE_TYPE_WORKBIN_AGV, WMS_OPERATION_TYPE_MANUAL);
}
public static final Map<String, String> OUTSTOCK_WAY_MAP = new HashMap<String, String>();
static {
OPERATION_TYPE_MAP.put(WMS_WAREHOUSE_TYPE_NORMAL, WMS_STOCK_WAY_MANUAL);
OPERATION_TYPE_MAP.put(WMS_WAREHOUSE_TYPE_AGV, WMS_STOCK_WAY_AGV);
OPERATION_TYPE_MAP.put(WMS_WAREHOUSE_TYPE_WORKBIN_AGV, WMS_STOCK_WAY_MANUAL);
}
/**
*
* */
public static final String WMS_BASE_LOCATION_STATUS_NORMAL = "1";//正常
public static final String WMS_BASE_LOCATION_STATUS_AUTO_LOCK = "2";//自动锁定
public static final String WMS_BASE_LOCATION_STATUS_MANUAL_LOCK = "3";//人工锁定
public static final String WMS_BASE_LOCATION_STATUS_MOVE_LOCK = "4";//移库锁定
public static final String WMS_BASE_LOCATION_STATUS_MERGE_LOCK = "5";//合库锁定
/**
*
* */
public static final String WMS_BASE_LOCATION_INSTOCK_FLAG_YES = "1";//是
public static final String WMS_BASE_LOCATION_INSTOCK_FLAG_NO = "0";//否
/**
*
* */
public static final String WMS_BASE_LOCATION_OUTSTOCK_FLAG_YES = "1";//是
public static final String WMS_BASE_LOCATION_OUTSTOCK_FLAG_NO = "0";//否
/*原材料出库任务类型*/
public static final String WMS_RAW_OUTSTOCK_TASK_TYPE_PRODUCTION_PICKING = "1";//生产领料
public static final String WMS_RAW_OUTSTOCK_TASK_TYPE_MOVE = "2";//移库出库
public static final String WMS_RAW_OUTSTOCK_TASK_TYPE_MERGE = "3";//合库出库
public static final String WMS_RAW_OUTSTOCK_TASK_TYPE_OTHER = "9";//其他
/*原材料库存完整标识*/
public static final String WMS_RAW_STOCK_COMPLETE_FLAG_YES = "1";//是
public static final String WMS_RAW_STOCK_COMPLETE_FLAG_NO = "0";//否
}

@ -16,7 +16,7 @@ import com.hw.common.core.web.page.TableDataInfo;
/**
* web
*
*
* @author ruoyi
*/
public class BaseController
@ -120,7 +120,7 @@ public class BaseController
/**
*
*
*
* @param rows
* @return
*/
@ -131,7 +131,7 @@ public class BaseController
/**
*
*
*
* @param result
* @return
*/
@ -139,4 +139,16 @@ public class BaseController
{
return result ? success() : error();
}
protected TableDataInfo getDataTable(List<?> list,long total)
{
TableDataInfo rspData = new TableDataInfo();
rspData.setCode(HttpStatus.SUCCESS);
rspData.setRows(list);
rspData.setMsg("查询成功");
rspData.setTotal(total);
return rspData;
}
}

@ -77,7 +77,7 @@ public class BaseMonitorInfo extends BaseEntity
/** 建筑类型 */
@Excel(name = "建筑类型")
private String buildObjid;
private String buildId;
/** 分项类型 */
@Excel(name = "分项类型")
@ -276,14 +276,14 @@ public class BaseMonitorInfo extends BaseEntity
{
return grade;
}
public void setBuildId(String buildObjid)
public void setBuildId(String buildId)
{
this.buildObjid = buildObjid;
this.buildId = buildId;
}
public String getBuildId()
{
return buildObjid;
return buildId;
}
public void setSubentryId(String subentryId)
{

@ -5,7 +5,10 @@ import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import com.hw.common.core.constant.Constants;
import com.hw.common.core.constant.SecurityConstants;
import com.hw.common.core.constant.TdEngineConstants;
import com.hw.common.core.domain.R;
import com.hw.common.core.exception.ServiceException;
import com.hw.common.core.utils.DateUtils;
import com.hw.common.core.utils.StringUtils;
@ -18,6 +21,8 @@ import com.hw.tdengine.api.domain.TdField;
import com.hw.tdengine.api.domain.TdTableVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.hw.tdengine.api.domain.AlterTagVo;
/**
@ -79,6 +84,7 @@ public class BaseMonitorInfo1ServiceImpl implements IBaseMonitorInfo1Service {
* @param baseMonitorInfo
* @return
*/
@Transactional(rollbackFor = Exception.class)
@Override
//@DS("#header.poolName")
public int insertBaseMonitorInfo(BaseMonitorInfo baseMonitorInfo) {
@ -89,60 +95,64 @@ public class BaseMonitorInfo1ServiceImpl implements IBaseMonitorInfo1Service {
//todo 新增父级为空判断,父级为空时会导致创建子表与创建计量设备与类型的对应对象失效
try {
BaseMonitorInfo monitor = baseMonitorInfoMapper.selectBaseMonitorInfoByObjid(baseMonitorInfo.getParentId());
//创建子表
this.createEmsTbale(baseMonitorInfo.getMonitorId(), baseMonitorInfo.getBuildId(),baseMonitorInfo.getMonitorName(),baseMonitorInfo.getObjid());
if (monitor != null){
monitor.setAncestors(monitor.getAncestors() + "," + monitor.getMonitorId());
String[] split = monitor.getAncestors().split(",");
monitor.setGrade(split.length);
}
if (monitor != null) {
monitor.setAncestors(monitor.getAncestors() + "," + monitor.getMonitorId());
String[] split = monitor.getAncestors().split(",");
monitor.setGrade(split.length);
}
this.insertOrUpdateBaseTypeRelation(baseMonitorInfo.getMonitorId(), baseMonitorInfo.getBuildId(),
baseMonitorInfo.getBusinessId(), baseMonitorInfo.getSubentryId());
List<BaseMonitorInfo> subsetList = this.selectMonitorSubsetList(new BaseMonitorInfo());
// 添加线损对象
this.insertLineLossList(subsetList);
baseMonitorInfo.setCreateTime(DateUtils.getNowDate());
baseMonitorInfo.setCreateBy(SecurityUtils.getUsername());
int result = baseMonitorInfoMapper.insertBaseMonitorInfo(baseMonitorInfo);
//创建TDEngine子表
this.createEmsTbale(baseMonitorInfo.getMonitorId(), baseMonitorInfo.getBuildId(), baseMonitorInfo.getMonitorName(), baseMonitorInfo.getObjid());
return result;
} catch (Exception e) {
System.out.println("新增计量设备信息异常1111:" + e.getMessage());
}
return 0;
baseMonitorInfo.setCreateTime(DateUtils.getNowDate());
baseMonitorInfo.setCreateBy(SecurityUtils.getUsername());
return baseMonitorInfoMapper.insertBaseMonitorInfo(baseMonitorInfo);
}
/**
*
*/
//todo 调用tde 在创建计量设备时创建子表
public void createEmsTbale(String monitorId,String buildobjid,String monitorName,Long objid){
//调用tde创建一个子表
TdTableVo tableVo = new TdTableVo();
tableVo.setDatabaseName("db_hwmes");
tableVo.setSuperTableName("st_electricity");
tableVo.setTableName("t_e_"+monitorId);
List<TdField> fields = new ArrayList<TdField>();
List<TdField> field2s = new ArrayList<TdField>();
TdField field = new TdField();
TdField field2 = new TdField();
TdField field3 = new TdField();
TdField field4 = new TdField();
field.setFieldName("buildobjid");
field.setFieldValue(buildobjid);
field.setDataType("int");
field2.setFieldName("monitorname");
field2.setFieldValue(monitorName);
field2.setDataType("nchar");
field3.setFieldName("monitorobjid");
field3.setDataType("int");
field3.setFieldValue(objid);
fields.add(field);
fields.add(field2);
fields.add(field3);
field2s.add(field4);
tableVo.setSchemaFields(field2s);
tableVo.setTagsFieldValues(fields);
remoteTdEngineService.createTable(tableVo, SecurityConstants.INNER);
public void createEmsTbale(String monitorId, String buildid, String monitorName, Long objid) {
//调用tde创建一个子表
TdTableVo tableVo = new TdTableVo();
tableVo.setDatabaseName("db_hwmes");
tableVo.setSuperTableName("st_electricity");
tableVo.setTableName(TdEngineConstants.getEmsTableName(objid));
List<TdField> fields = new ArrayList<TdField>();
TdField field = new TdField();
TdField field2 = new TdField();
TdField field3 = new TdField();
TdField field4 = new TdField();
field.setFieldName(TdEngineConstants.ST_TAG_EMS_BUILDID);
field.setFieldValue(buildid);
field2.setFieldName(TdEngineConstants.ST_TAG_EMS_MONITORNAME);
field2.setFieldValue(monitorName);
field3.setFieldName(TdEngineConstants.ST_TAG_EMS_MONITOROBJID);
field3.setFieldValue(objid);
field4.setFieldName(TdEngineConstants.ST_TAG_EMS_MONITORID);
field4.setFieldValue(monitorId);
fields.add(field);
fields.add(field2);
fields.add(field3);
fields.add(field4);
tableVo.setTagsFieldValues(fields);
remoteTdEngineService.createTable(tableVo, SecurityConstants.INNER);
}
}
/**
* 线
*
@ -191,18 +201,18 @@ public class BaseMonitorInfo1ServiceImpl implements IBaseMonitorInfo1Service {
* @param baseMonitorInfo
* @return
*/
@Transactional(rollbackFor = Exception.class)
@Override
//@DS("#header.poolName")
public int updateBaseMonitorInfo(BaseMonitorInfo baseMonitorInfo) {
List<BaseMonitorInfo> baseMonitorInfos = baseMonitorInfoMapper.checkMonitorIdLegal(baseMonitorInfo);
if (baseMonitorInfos.size() > 1){
throw new ServiceException("计量设备编号重复:" + baseMonitorInfo.getMonitorId());
if (baseMonitorInfos.size() > 1) {
throw new ServiceException("计量设备编号重复:" + baseMonitorInfo.getMonitorId());
}
try {
BaseMonitorInfo newParenMonitorInfo = baseMonitorInfoMapper.selectBaseMonitorInfoByObjid(baseMonitorInfo.getParentId());
BaseMonitorInfo oldDeptMonitorInfo = selectBaseMonitorInfoByObjid(baseMonitorInfo.getObjid());
if (StringUtils.isNotNull(newParenMonitorInfo) && StringUtils.isNotNull(oldDeptMonitorInfo))
{
if (StringUtils.isNotNull(newParenMonitorInfo) && StringUtils.isNotNull(oldDeptMonitorInfo)) {
String newAncestors = newParenMonitorInfo.getAncestors() + "," + oldDeptMonitorInfo.getMonitorId();
String oldAncestors = oldDeptMonitorInfo.getAncestors();
baseMonitorInfo.setAncestors(newAncestors);
@ -212,33 +222,87 @@ public class BaseMonitorInfo1ServiceImpl implements IBaseMonitorInfo1Service {
updateMonitorChildren(baseMonitorInfo.getMonitorId(), newAncestors, oldAncestors);
}
this.insertOrUpdateBaseTypeRelation(baseMonitorInfo.getMonitorId(),baseMonitorInfo.getBuildId(),
baseMonitorInfo.getBusinessId(),baseMonitorInfo.getSubentryId());
this.insertOrUpdateBaseTypeRelation(baseMonitorInfo.getMonitorId(), baseMonitorInfo.getBuildId(),
baseMonitorInfo.getBusinessId(), baseMonitorInfo.getSubentryId());
baseMonitorInfo.setUpdateTime(DateUtils.getNowDate());
baseMonitorInfo.setUpdateBy(SecurityUtils.getUsername());
int result = baseMonitorInfoMapper.updateBaseMonitorInfo(baseMonitorInfo);
this.updateTdEngineTable(baseMonitorInfo, oldDeptMonitorInfo);
return result;
} catch (Exception e) {
e.printStackTrace();
}
baseMonitorInfo.setUpdateTime(DateUtils.getNowDate());
baseMonitorInfo.setUpdateBy(SecurityUtils.getUsername());
return baseMonitorInfoMapper.updateBaseMonitorInfo(baseMonitorInfo);
return 0;
}
/**
*
* @param monitorId ID
*
* @param monitorId ID
* @param newAncestors ID
* @param oldAncestors ID
*/
private void updateMonitorChildren(String monitorId, String newAncestors, String oldAncestors) {
List<BaseMonitorInfo> children = baseMonitorInfoMapper.selectChildrenMonitorById(monitorId);
for (BaseMonitorInfo child : children)
{
for (BaseMonitorInfo child : children) {
child.setAncestors(child.getAncestors().replaceFirst(oldAncestors, newAncestors));
}
if (children.size() > 0)
{
if (children.size() > 0) {
baseMonitorInfoMapper.updateMonitorChildren(children);
}
}
/**
* @param: baseMonitorInfo
* @param: dbBaseMonitorInfo
* @description TdEnginetag
* @author xins
* @date 2023-12-30 16:50
*/
private void updateTdEngineTable(BaseMonitorInfo baseMonitorInfo, BaseMonitorInfo dbBaseMonitorInfo) {
String databaseName = TdEngineConstants.EMS_DATABASE_NAME;
String tableName = TdEngineConstants.getEmsTableName(baseMonitorInfo.getObjid());
List<AlterTagVo> alterTagVos = new ArrayList<AlterTagVo>();
R<?> tdReturnMsg;
if (!baseMonitorInfo.getMonitorId().equals(dbBaseMonitorInfo.getMonitorId())) {
AlterTagVo alterTagVo = new AlterTagVo();
alterTagVo.setDatabaseName(databaseName);
alterTagVo.setTableName(tableName);
alterTagVo.setTagName(TdEngineConstants.ST_TAG_EMS_MONITORID);
alterTagVo.setTagValue("'" + baseMonitorInfo.getMonitorId() + "'");
alterTagVos.add(alterTagVo);
}
if (!baseMonitorInfo.getMonitorName().equals(dbBaseMonitorInfo.getMonitorName())) {
AlterTagVo alterTagVo = new AlterTagVo();
alterTagVo.setDatabaseName(databaseName);
alterTagVo.setTableName(tableName);
alterTagVo.setTagName(TdEngineConstants.ST_TAG_EMS_MONITORNAME);
alterTagVo.setTagValue("'" + baseMonitorInfo.getMonitorName() + "'");
alterTagVos.add(alterTagVo);
}
if (!baseMonitorInfo.getBuildId().equals(dbBaseMonitorInfo.getBuildId())) {
AlterTagVo alterTagVo = new AlterTagVo();
alterTagVo.setDatabaseName(databaseName);
alterTagVo.setTableName(tableName);
alterTagVo.setTagName(TdEngineConstants.ST_TAG_EMS_BUILDID);
alterTagVo.setTagValue("'" +baseMonitorInfo.getBuildId()+ "'");
alterTagVos.add(alterTagVo);
}
if (!alterTagVos.isEmpty()) {
tdReturnMsg = this.remoteTdEngineService.alterTableTags(alterTagVos, SecurityConstants.INNER);
if (tdReturnMsg.getCode() != Constants.SUCCESS) {//抛出异常,回滚事务
throw new RuntimeException(tdReturnMsg.getMsg());
}
}
}
/**
*
*
@ -387,5 +451,4 @@ public class BaseMonitorInfo1ServiceImpl implements IBaseMonitorInfo1Service {
}
}

@ -8,6 +8,7 @@ import com.hw.common.log.annotation.Log;
import com.hw.common.log.enums.BusinessType;
import com.hw.common.security.annotation.RequiresPermissions;
import com.hw.ems.record.domain.RecordDnbInstant;
import com.hw.ems.record.domain.vo.RecordDnbInstantDataVo;
import com.hw.ems.record.service.IRecordDnbInstantService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
@ -76,16 +77,15 @@ public class RecordDnbInstantController extends BaseController {
*
*/
@RequiresPermissions("record:dnbInstant:list")
@PostMapping("/list")
@GetMapping("/list")
@ResponseBody
public TableDataInfo list(@RequestBody RecordDnbInstant recordDnbInstant)
public TableDataInfo list(RecordDnbInstant recordDnbInstant)
{
startPage();
List<RecordDnbInstant> list = recordDnbInstantService.selectRecordDnbInstantList(recordDnbInstant);
if (list == null){
return null;
}
return getDataTable(list);
RecordDnbInstantDataVo recordDnbInstantDataVo = recordDnbInstantService.selectRecordDnbInstantList(recordDnbInstant);
List<RecordDnbInstant> records = recordDnbInstantDataVo.getRecordDnbInstants();
int count = recordDnbInstantDataVo.getCount();
return getDataTable(records,count);
}
/**
@ -122,7 +122,8 @@ public class RecordDnbInstantController extends BaseController {
@ResponseBody
public void export(HttpServletResponse response,RecordDnbInstant recordDnbInstant)
{
List<RecordDnbInstant> list = recordDnbInstantService.selectRecordDnbInstantList(recordDnbInstant);
RecordDnbInstantDataVo recordDnbInstantDataVo = recordDnbInstantService.selectRecordDnbInstantList(recordDnbInstant);
List<RecordDnbInstant> list = recordDnbInstantDataVo.getRecordDnbInstants();
ExcelUtil<RecordDnbInstant> util = new ExcelUtil<>(RecordDnbInstant.class);
util.exportExcel(response,list, "电实时数据数据");
}

@ -0,0 +1,21 @@
package com.hw.ems.record.domain.vo;
import com.hw.ems.record.domain.RecordDnbInstant;
import lombok.Data;
import java.util.List;
/**
* @Description: VO
* @ClassName: RecordDnbInstantDataVo
* @Author : xins
* @Date :2023-12-30 15:35
* @Version :1.0
*/
@Data
public class RecordDnbInstantDataVo {
private int count;
private List<RecordDnbInstant> recordDnbInstants;
}

@ -1,7 +1,9 @@
package com.hw.ems.record.service;
import com.alibaba.fastjson2.JSONObject;
import com.hw.ems.record.domain.RecordDnbInstant;
import com.hw.ems.record.domain.vo.RecordDnbInstantDataVo;
import java.util.List;
import java.util.Map;
@ -27,7 +29,7 @@ public interface IRecordDnbInstantService {
* @param recordDnbInstant
* @return
*/
public List<RecordDnbInstant> selectRecordDnbInstantList(RecordDnbInstant recordDnbInstant);
public RecordDnbInstantDataVo selectRecordDnbInstantList(RecordDnbInstant recordDnbInstant);
/**
*

@ -363,7 +363,7 @@ public class RecordAlarmDataServiceImpl implements IRecordAlarmDataService {
tdSelectDto.setSchemaFieldValues(listTdfields);
List<BaseMonitorInfo> baseMonitorInfos = baseMonitorInfo1Service.selectBaseMonitorInfoList(new BaseMonitorInfo());
for (BaseMonitorInfo baseMonitorInfo : baseMonitorInfos){
tdSelectDto.setTableName(TdEngineConstants.getEmsTableName(baseMonitorInfo.getMonitorId()));
tdSelectDto.setTableName(TdEngineConstants.getEmsTableName(baseMonitorInfo.getObjid()));
// tdSelectDto.setTableName(TdEngineConstants.getEmsTableName("ceshi7"));
tdSelectDto.setTagsName("monitorobjid");
//查出每个计量设备最新的一条实时数据

@ -8,6 +8,7 @@ import java.time.format.DateTimeFormatter;
import java.util.*;
import com.alibaba.fastjson2.JSONObject;
import com.hw.common.core.constant.SecurityConstants;
import com.hw.common.core.constant.TdEngineConstants;
import com.hw.common.core.domain.R;
@ -19,14 +20,14 @@ import com.hw.ems.base.domain.BaseMonitorInfo;
import com.hw.ems.base.service.IBaseEnergyTypeService;
import com.hw.ems.base.service.IBaseMonitorInfoService;
import com.hw.ems.record.domain.RecordDnbInstant;
import com.hw.ems.record.domain.vo.RecordDnbInstantDataVo;
import com.hw.ems.record.mapper.RecordDnbInstantMapper;
import com.hw.ems.record.service.IRecordDnbInstantService;
import com.hw.ems.report.domain.ReportPointDnb;
import com.hw.ems.report.service.IReportPointDnbService;
import com.hw.tdengine.api.RemoteTdEngineService;
import com.hw.tdengine.api.domain.TdHistorySelectDto;
import com.hw.tdengine.api.domain.TdReturnDataVo;
import com.hw.tdengine.api.domain.TdSuperTableSelectVo;
import com.hw.tdengine.api.domain.*;
import com.hw.tdengine.api.domain.ems.TdSuperTableEmsSelectVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -81,70 +82,73 @@ public class RecordDnbInstantServiceImpl implements IRecordDnbInstantService {
@Override
//@DS("#header.poolName")
// @DataScope(deptAlias = "null")
public List<RecordDnbInstant> selectRecordDnbInstantList(RecordDnbInstant recordDnbInstant) {
// todo 调用tde引擎查询实时数据
public RecordDnbInstantDataVo selectRecordDnbInstantList(RecordDnbInstant recordDnbInstant) {
RecordDnbInstantDataVo recordDnbInstantDataVo = new RecordDnbInstantDataVo();
try {
List<Map<String,Object>> list = new ArrayList<Map<String,Object>>();
Integer pageNum = Integer.valueOf((String) recordDnbInstant.getParams().get("pageNum"));
Integer pageSize = Integer.valueOf((String) recordDnbInstant.getParams().get("pageSize"));
Integer offset = (pageNum - 1) * pageSize;
List<RecordDnbInstant> records = new ArrayList<RecordDnbInstant>();
List<BaseMonitorInfo> baseMonitorInfos = baseMonitorInfoService.selectBaseMonitorInfoList(new BaseMonitorInfo());
String stratTime = (String)recordDnbInstant.getParams().get("beginCollectTime");
String endTime = (String)recordDnbInstant.getParams().get("endCollectTime");
BaseMonitorInfo queryMonitorInfo = new BaseMonitorInfo();
queryMonitorInfo.setMonitorId(recordDnbInstant.getMonitorId());
// List<BaseMonitorInfo> baseMonitorInfos = baseMonitorInfoService.selectBaseMonitorInfoList(queryMonitorInfo);
String stratTime = (String) recordDnbInstant.getParams().get("beginTime");
String endTime = (String) recordDnbInstant.getParams().get("endTime");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date dateStrat = sdf.parse(stratTime);
Date dateEnd = sdf.parse(endTime);
TdHistorySelectDto tdHistorySelectDto = new TdHistorySelectDto();
tdHistorySelectDto.setDatabaseName("db_hwmes");
/**
*
* */
// if (recordDnbInstant.getMonitorId()==""||recordDnbInstant.getMonitorId()==null) {
// TdSuperTableSelectVo tdSuperTableSelectVo = new TdSuperTableSelectVo();
// tdSuperTableSelectVo.setDatabaseName("db_hwmes");
// tdSuperTableSelectVo.setSuperTableName("st_electricity");
// //获取13位的时间戳
// tdSuperTableSelectVo.setStartTime(dateStrat.getTime());
// tdSuperTableSelectVo.setEndTime(dateEnd.getTime());
//// R<List<Map<String, Object>>> latestDataByTags = remoteTdEngineService.getLatestDataByTags(tdSuperTableSelectVo, SecurityConstants.INNER);
//// List<Map<String, Object>> data = latestDataByTags.getData();
// return remoteTdEngineService.getLatestDataByTags(tdSuperTableSelectVo, SecurityConstants.INNER).getData();
// }
for (BaseMonitorInfo baseMonitorInfo:baseMonitorInfos){
tdHistorySelectDto.setTableName(TdEngineConstants.getEmsTableName(baseMonitorInfo.getMonitorId()));
tdHistorySelectDto.setStartTime(dateStrat.getTime());
tdHistorySelectDto.setEndTime(dateEnd.getTime());
tdHistorySelectDto.setFirstFieldName("ts");
// list = (List<Map<String,Object>>)remoteTdEngineService.getHistoryData(tdHistorySelectDto, SecurityConstants.INNER);
// list.addAll((List<Map<String,Object>>)remoteTdEngineService.getHistoryData(tdHistorySelectDto, SecurityConstants.INNER));
List<Map<String, Object>> dataList = remoteTdEngineService.getHistoryData(tdHistorySelectDto, SecurityConstants.INNER).getData().getDataList();
for (Map<String, Object> data : dataList){
RecordDnbInstant recordDnbInstant1 = new RecordDnbInstant();
recordDnbInstant1.setObjid(baseMonitorInfo.getObjid());
recordDnbInstant1.setMonitorId(baseMonitorInfo.getMonitorId());
recordDnbInstant1.setMonitorName(baseMonitorInfo.getMonitorName());
recordDnbInstant1.setVA(BigDecimal.valueOf(Double.valueOf(String.valueOf(data.get("volatagea")))));
recordDnbInstant1.setVB(BigDecimal.valueOf(Double.valueOf(String.valueOf(data.get("volatageb")))));
recordDnbInstant1.setVC(BigDecimal.valueOf(Double.valueOf(String.valueOf(data.get("volatagec")))));
recordDnbInstant1.setIA(BigDecimal.valueOf(Double.valueOf(String.valueOf(data.get("currenta")))));
recordDnbInstant1.setIB(BigDecimal.valueOf(Double.valueOf(String.valueOf(data.get("currentb")))));
recordDnbInstant1.setIC(BigDecimal.valueOf(Double.valueOf(String.valueOf(data.get("currentc")))));
recordDnbInstant1.setGlys(BigDecimal.valueOf(Double.valueOf(String.valueOf(data.get("glys")))));
recordDnbInstant1.setZxyg(BigDecimal.valueOf(Double.valueOf(String.valueOf(data.get("zxyg")))));
recordDnbInstant1.setActivePower(BigDecimal.valueOf(Double.valueOf(String.valueOf(data.get("activepower")))));
recordDnbInstant1.setReactivePower(BigDecimal.valueOf(Double.valueOf(String.valueOf(data.get("reactivepower")))));
//调整时间格式
String substring = String.valueOf(data.get("ts")).replaceAll("T", " ").substring(0, 19);
recordDnbInstant1.setCollectTime(sdf.parse(substring));
// recordDnbInstant.setConsumption(BigDecimal.valueOf(Double.valueOf(String.valueOf(data.get(0).get("consuption")))));
recordDnbInstant1.setCollectType(Long.valueOf(String.valueOf(data.get("collecttype"))));
records.add(recordDnbInstant1);
}
TdSuperTableEmsSelectVo tdSuperTableCommonSelectVo = new TdSuperTableEmsSelectVo();
tdSuperTableCommonSelectVo.setDatabaseName("db_hwmes");
tdSuperTableCommonSelectVo.setSuperTableName("st_electricity");
tdSuperTableCommonSelectVo.setStartTime(dateStrat.getTime());
tdSuperTableCommonSelectVo.setEndTime(dateEnd.getTime());
tdSuperTableCommonSelectVo.setFirstFieldName("ts");
tdSuperTableCommonSelectVo.setOrderByFieldName("ts");
tdSuperTableCommonSelectVo.setSort("desc");
tdSuperTableCommonSelectVo.setOffset(offset);
tdSuperTableCommonSelectVo.setLimit(pageSize);
Object monitorObjidValue = recordDnbInstant.getParams().get("monitorObjid");
if (monitorObjidValue != null) {
tdSuperTableCommonSelectVo.setMonitorObjid(Long.valueOf(String.valueOf(monitorObjidValue)));
}
return records;
TdReturnDataVo tdReturnDataVo = remoteTdEngineService.getSuperTableHistoryData(tdSuperTableCommonSelectVo, SecurityConstants.INNER).getData();
if (tdReturnDataVo == null) {
return recordDnbInstantDataVo;
}
List<Map<String, Object>> dataList = tdReturnDataVo.getDataList();
for (Map<String, Object> data : dataList) {
RecordDnbInstant recordDnbInstant1 = new RecordDnbInstant();
recordDnbInstant1.setObjid(Long.valueOf(String.valueOf(data.get(TdEngineConstants.ST_TAG_EMS_MONITOROBJID))));
recordDnbInstant1.setMonitorId(String.valueOf(data.get(TdEngineConstants.ST_TAG_EMS_MONITORID)));
recordDnbInstant1.setMonitorName(String.valueOf(data.get(TdEngineConstants.ST_TAG_EMS_MONITORNAME)));
recordDnbInstant1.setVA(BigDecimal.valueOf(Double.valueOf(String.valueOf(data.get("volatagea")))));
recordDnbInstant1.setVB(BigDecimal.valueOf(Double.valueOf(String.valueOf(data.get("volatageb")))));
recordDnbInstant1.setVC(BigDecimal.valueOf(Double.valueOf(String.valueOf(data.get("volatagec")))));
recordDnbInstant1.setIA(BigDecimal.valueOf(Double.valueOf(String.valueOf(data.get("currenta")))));
recordDnbInstant1.setIB(BigDecimal.valueOf(Double.valueOf(String.valueOf(data.get("currentb")))));
recordDnbInstant1.setIC(BigDecimal.valueOf(Double.valueOf(String.valueOf(data.get("currentc")))));
recordDnbInstant1.setGlys(BigDecimal.valueOf(Double.valueOf(String.valueOf(data.get("glys")))));
recordDnbInstant1.setZxyg(BigDecimal.valueOf(Double.valueOf(String.valueOf(data.get("zxyg")))));
recordDnbInstant1.setActivePower(BigDecimal.valueOf(Double.valueOf(String.valueOf(data.get("activepower")))));
recordDnbInstant1.setReactivePower(BigDecimal.valueOf(Double.valueOf(String.valueOf(data.get("reactivepower")))));
//调整时间格式
String substring = String.valueOf(data.get("ts")).replaceAll("T", " ").substring(0, 19);
recordDnbInstant1.setCollectTime(sdf.parse(substring));
// recordDnbInstant.setConsumption(BigDecimal.valueOf(Double.valueOf(String.valueOf(data.get("consumption")))));
recordDnbInstant1.setCollectType(Long.valueOf(String.valueOf(data.get("collecttype"))));
records.add(recordDnbInstant1);
}
recordDnbInstantDataVo.setCount(tdReturnDataVo.getCount());
recordDnbInstantDataVo.setRecordDnbInstants(records);
return recordDnbInstantDataVo;
} catch (ParseException e) {
e.printStackTrace();
}
List<RecordDnbInstant> lists = new ArrayList<>();
return lists;
return recordDnbInstantDataVo;
}
/**
@ -251,7 +255,8 @@ public class RecordDnbInstantServiceImpl implements IRecordDnbInstantService {
/**
*
*
*
*
* @param baseDnbInstant
* @return
*/
@ -315,10 +320,10 @@ public class RecordDnbInstantServiceImpl implements IRecordDnbInstantService {
@Override
//@DS("#header.poolName")
public List<RecordDnbInstant> voltageCurrentCurve(RecordDnbInstant dnbInstant) {
if (StringUtils.isEmpty(dnbInstant.getMonitorId())){
if (StringUtils.isEmpty(dnbInstant.getMonitorId())) {
return null;
}
if (StringUtils.isEmpty(dnbInstant.getStartTime()) || StringUtils.isEmpty(dnbInstant.getEndTime())){
if (StringUtils.isEmpty(dnbInstant.getStartTime()) || StringUtils.isEmpty(dnbInstant.getEndTime())) {
String nowTime = DateUtils.getTime();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime modifiedDateTime = LocalDateTime.parse(nowTime, formatter).minusMinutes(30);
@ -331,7 +336,7 @@ public class RecordDnbInstantServiceImpl implements IRecordDnbInstantService {
/**
*
* */
*/
//todo 通过tde 将电实时数据存入到电整点数据中
@Override
public void getDnbInstantByJob() {
@ -341,9 +346,9 @@ public class RecordDnbInstantServiceImpl implements IRecordDnbInstantService {
List<BaseEnergyType> baseEnergyTypes = baseEnergyTypeService.selectBaseEnergyTypeList(new BaseEnergyType());
//获取当前时间与一小时前时间
long endTime= System.currentTimeMillis();
//从一小时前开始,十点的话就是从九点开始,不是九点零一,开始就
long startTime = System.currentTimeMillis()-60*60*1000-10;
long endTime = System.currentTimeMillis();
//从一小时前开始,十点的话就是从九点开始,不是九点零一,开始就
long startTime = System.currentTimeMillis() - 60 * 60 * 1000 - 10;
tdHistorySelectDto.setStartTime(startTime);
tdHistorySelectDto.setEndTime(endTime);
Date date = new Date();
@ -353,45 +358,46 @@ public class RecordDnbInstantServiceImpl implements IRecordDnbInstantService {
List<BaseMonitorInfo> baseMonitorInfos = baseMonitorInfoService.selectBaseMonitorInfoList(new BaseMonitorInfo());
List<ReportPointDnb> reportPoints = new ArrayList<ReportPointDnb>();
//根据计量设备id获取能源表名称
if (!baseMonitorInfos.isEmpty()){
for (BaseMonitorInfo baseMonitorInfo : baseMonitorInfos) {
try {
String emsTableName = TdEngineConstants.getEmsTableName(baseMonitorInfo.getMonitorId());
//获取当前数据以及一小时前的数据
tdHistorySelectDto.setTableName(emsTableName);
if (!baseMonitorInfos.isEmpty()) {
for (BaseMonitorInfo baseMonitorInfo : baseMonitorInfos) {
try {
String emsTableName = TdEngineConstants.getEmsTableName(baseMonitorInfo.getObjid());
//获取当前数据以及一小时前的数据
tdHistorySelectDto.setTableName(emsTableName);
// tdHistorySelectDto.setTableName("t_e_ceshi7");
List<Map<String, Object>> dnbInstant =remoteTdEngineService.getHistoryData(tdHistorySelectDto, SecurityConstants.INNER).getData().getDataList();
R<TdReturnDataVo> historyData = remoteTdEngineService.getHistoryData(tdHistorySelectDto, SecurityConstants.INNER);
ReportPointDnb report = new ReportPointDnb();
report.setMonitorId(baseMonitorInfo.getMonitorId());
report.setMonitorName(baseMonitorInfo.getMonitorName());
report.setpMonitorId(String.valueOf(baseMonitorInfo.getParentId()));
report.setAddress(baseMonitorInfo.getMonitorAddr());
BigDecimal MaxZXYG= BigDecimal.valueOf(Double.valueOf(String.valueOf(dnbInstant.get(dnbInstant.size()-1).get("zxyg"))));
BigDecimal MinZXYG = BigDecimal.valueOf(Double.valueOf(String.valueOf(dnbInstant.get(0).get("zxyg"))));
//pt ct值暂时无用默认为1 需要时从计量设备信息中根据id获取
int pt = 1;
int ct = 1;
//乘ct值和pt值
/**
* (MAX(ifnull(t1.zxyg,0)) - MIN(ifnull(t1.zxyg,0))) * ifnull(t2.pt,1) * ifnull(t2.ct,1)as expend,
* 0 as price,
* hour(date_sub(@nowDate, interval 1 hour)) as point_time,
* DATE_FORMAT(date_sub(@nowDate, interval 1 hour),'%Y-%m-%d %H:00:00') as begin_time,
* DATE_FORMAT(@nowDate,'%Y-%m-%d %H:00:00') as end_time,
* DATE_FORMAT(date_sub(@nowDate,interval 1 hour),'%Y-%m-%d %H:00:00') as record_time*/
report.setExpend(MaxZXYG.subtract(MinZXYG).multiply(new BigDecimal(pt)).multiply(new BigDecimal(ct)));
report.setPrice(new BigDecimal(0));
report.setPointTime(String.valueOf(hours-1));
report.setMeterValue(MaxZXYG.subtract(MinZXYG));
report.setRecordTime(sdf.parse(sdf.format(startTime)));
report.setBeginTime(sdf.parse(sdf.format(startTime)));
report.setEndTime(sdf.parse(sdf.format(endTime)));
reportPoints.add(report);
} catch (ParseException e) {
e.printStackTrace();
List<Map<String, Object>> dnbInstant = remoteTdEngineService.getHistoryData(tdHistorySelectDto, SecurityConstants.INNER).getData().getDataList();
R<TdReturnDataVo> historyData = remoteTdEngineService.getHistoryData(tdHistorySelectDto, SecurityConstants.INNER);
ReportPointDnb report = new ReportPointDnb();
report.setMonitorId(baseMonitorInfo.getMonitorId());
report.setMonitorName(baseMonitorInfo.getMonitorName());
report.setpMonitorId(String.valueOf(baseMonitorInfo.getParentId()));
report.setAddress(baseMonitorInfo.getMonitorAddr());
BigDecimal MaxZXYG = BigDecimal.valueOf(Double.valueOf(String.valueOf(dnbInstant.get(dnbInstant.size() - 1).get("zxyg"))));
BigDecimal MinZXYG = BigDecimal.valueOf(Double.valueOf(String.valueOf(dnbInstant.get(0).get("zxyg"))));
//pt ct值暂时无用默认为1 需要时从计量设备信息中根据id获取
int pt = 1;
int ct = 1;
//乘ct值和pt值
/**
* (MAX(ifnull(t1.zxyg,0)) - MIN(ifnull(t1.zxyg,0))) * ifnull(t2.pt,1) * ifnull(t2.ct,1)as expend,
* 0 as price,
* hour(date_sub(@nowDate, interval 1 hour)) as point_time,
* DATE_FORMAT(date_sub(@nowDate, interval 1 hour),'%Y-%m-%d %H:00:00') as begin_time,
* DATE_FORMAT(@nowDate,'%Y-%m-%d %H:00:00') as end_time,
* DATE_FORMAT(date_sub(@nowDate,interval 1 hour),'%Y-%m-%d %H:00:00') as record_time*/
report.setExpend(MaxZXYG.subtract(MinZXYG).multiply(new BigDecimal(pt)).multiply(new BigDecimal(ct)));
report.setPrice(new BigDecimal(0));
report.setPointTime(String.valueOf(hours - 1));
report.setMeterValue(MaxZXYG.subtract(MinZXYG));
report.setRecordTime(sdf.parse(sdf.format(startTime)));
report.setBeginTime(sdf.parse(sdf.format(startTime)));
report.setEndTime(sdf.parse(sdf.format(endTime)));
reportPoints.add(report);
} catch (ParseException e) {
e.printStackTrace();
}
}
}}
}
//将获取到的数据存入到实时数据中
for (ReportPointDnb p : reportPoints) {
reportPointDnbService.insertReportPointDnb(p);

@ -15,7 +15,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="collectDeviceId" column="collect_device_id" />
<result property="ancestors" column="ancestors" />
<result property="grade" column="grade" />
<result property="buildObjid" column="build_objid" />
<result property="buildId" column="build_id" />
<result property="subentryId" column="subentry_id" />
<result property="businessId" column="business_id" />
<result property="meterTypeId" column="meter_type_id" />
@ -41,7 +41,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectBaseMonitorInfoVo">
select objid, parent_id, monitor_id, monitor_name, monitor_addr, monitor_type, monitor_status,
collect_device_id, ancestors, grade, build_objid, subentry_id, business_id, meter_type_id,
collect_device_id, ancestors, grade, build_id, subentry_id, business_id, meter_type_id,
meter_id, correct_value, pt, ct, is_ammeter, is_key_monitor, is_circuit, dept_id, user_id,
create_by, create_time, update_by, update_time, public_share_type,monitor_hierarchy,room_code,room_name,physical_code from base_monitor_info
</sql>
@ -57,7 +57,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="collectDeviceId != null and collectDeviceId != ''"> and collect_device_id = #{collectDeviceId}</if>
<if test="ancestors != null and ancestors != ''"> and ancestors = #{ancestors}</if>
<if test="grade != null "> and grade = #{grade}</if>
<if test="buildObjid != null and buildObjid != ''"> and build_objid = #{buildObjid}</if>
<if test="buildId != null and buildId != ''"> and build_id = #{buildId}</if>
<if test="subentryId != null and subentryId != ''"> and subentry_id = #{subentryId}</if>
<if test="businessId != null and businessId != ''"> and business_id = #{businessId}</if>
<if test="meterTypeId != null and meterTypeId != ''"> and meter_type_id = #{meterTypeId}</if>
@ -118,7 +118,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="collectDeviceId != null">collect_device_id,</if>
<if test="ancestors != null">ancestors,</if>
<if test="grade != null">grade,</if>
<if test="buildObjid != null">build_objid,</if>
<if test="buildId != null">build_id,</if>
<if test="subentryId != null">subentry_id,</if>
<if test="businessId != null">business_id,</if>
<if test="meterTypeId != null">meter_type_id,</if>
@ -151,7 +151,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="collectDeviceId != null">#{collectDeviceId},</if>
<if test="ancestors != null">#{ancestors},</if>
<if test="grade != null">#{grade},</if>
<if test="buildObjid != null">#{buildObjid},</if>
<if test="buildId != null">#{buildId},</if>
<if test="subentryId != null">#{subentryId},</if>
<if test="businessId != null">#{businessId},</if>
<if test="meterTypeId != null">#{meterTypeId},</if>
@ -188,7 +188,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="collectDeviceId != null">collect_device_id = #{collectDeviceId},</if>
<if test="ancestors != null">ancestors = #{ancestors},</if>
<if test="grade != null">grade = #{grade},</if>
<if test="buildObjid != null">build_objid = #{buildObjid},</if>
<if test="buildId != null">build_id = #{buildId},</if>
<if test="subentryId != null">subentry_id = #{subentryId},</if>
<if test="businessId != null">business_id = #{businessId},</if>
<if test="meterTypeId != null">meter_type_id = #{meterTypeId},</if>

@ -15,7 +15,7 @@
<result property="collectDeviceId" column="collect_device_id" />
<result property="ancestors" column="ancestors" />
<result property="grade" column="grade" />
<result property="buildObjid" column="build_objid" />
<result property="buildId" column="build_id" />
<result property="subentryId" column="subentry_id" />
<result property="businessId" column="business_id" />
<result property="meterTypeId" column="meter_type_id" />
@ -37,7 +37,7 @@
<sql id="selectBaseMonitorInfoVo">
select objid, parent_id, monitor_id, monitor_name, monitor_addr, monitor_type,
monitor_status, collect_device_id, ancestors, grade, build_objid, subentry_id,
monitor_status, collect_device_id, ancestors, grade, build_id, subentry_id,
business_id, meter_type_id, meter_id, correct_value, pt, ct, is_ammeter,
is_key_monitor, is_circuit, dept_id, user_id, create_by, create_time, update_by, update_time from base_monitor_info
</sql>
@ -54,7 +54,7 @@
<if test="collectDeviceId != null and collectDeviceId != ''"> and collect_device_id = #{collectDeviceId}</if>
<if test="ancestors != null and ancestors != ''"> and ancestors = #{ancestors}</if>
<if test="grade != null "> and grade = #{grade}</if>
<if test="buildObjid != null and buildObjid != ''"> and build_objid = #{buildObjid}</if>
<if test="buildId != null and buildId != ''"> and build_id = #{buildId}</if>
<if test="subentryId != null and subentryId != ''"> and subentry_id = #{subentryId}</if>
<if test="businessId != null and businessId != ''"> and business_id = #{businessId}</if>
<if test="meterTypeId != null and meterTypeId != ''"> and meter_type_id = #{meterTypeId}</if>
@ -70,7 +70,7 @@
</select>
<select id="selectBaseMonitorInfoByObjid" parameterType="Long" resultMap="BaseMonitorInfoResult">
select t.objid, t.parent_id, t.monitor_id, t.monitor_name, t.monitor_addr, t.monitor_type, t.monitor_status, t.collect_device_id, t.ancestors, t.grade, t.build_objid, t.subentry_id, t.business_id, t.meter_type_id, t.meter_id, t.correct_value, t.pt, t.ct, t.is_ammeter, t.is_key_monitor, t.is_circuit, t.dept_id, t.user_id, t.create_by, t.create_time, t.update_by, t.update_time, p.monitor_name as parent_name
select t.objid, t.parent_id, t.monitor_id, t.monitor_name, t.monitor_addr, t.monitor_type, t.monitor_status, t.collect_device_id, t.ancestors, t.grade, t.build_id, t.subentry_id, t.business_id, t.meter_type_id, t.meter_id, t.correct_value, t.pt, t.ct, t.is_ammeter, t.is_key_monitor, t.is_circuit, t.dept_id, t.user_id, t.create_by, t.create_time, t.update_by, t.update_time, p.monitor_name as parent_name
from base_monitor_info t
left join base_monitor_info p on p.objid = t.parent_id
where t.objid = #{objid}
@ -114,7 +114,7 @@
<if test="collectDeviceId != null">collect_device_id,</if>
<if test="ancestors != null">ancestors,</if>
<if test="grade != null">grade,</if>
<if test="buildObjid != null">build_objid,</if>
<if test="buildId != null">build_id,</if>
<if test="subentryId != null">subentry_id,</if>
<if test="businessId != null">business_id,</if>
<if test="meterTypeId != null">meter_type_id,</if>
@ -142,7 +142,7 @@
<if test="collectDeviceId != null">#{collectDeviceId},</if>
<if test="ancestors != null">#{ancestors},</if>
<if test="grade != null">#{grade},</if>
<if test="buildObjid != null">#{buildObjid},</if>
<if test="buildId != null">#{buildId},</if>
<if test="subentryId != null">#{subentryId},</if>
<if test="businessId != null">#{businessId},</if>
<if test="meterTypeId != null">#{meterTypeId},</if>
@ -174,7 +174,7 @@
<if test="collectDeviceId != null">collect_device_id = #{collectDeviceId},</if>
<if test="ancestors != null">ancestors = #{ancestors},</if>
<if test="grade != null">grade = #{grade},</if>
<if test="buildObjid != null">build_objid = #{buildObjid},</if>
<if test="buildId != null">build_id = #{buildId},</if>
<if test="subentryId != null">subentry_id = #{subentryId},</if>
<if test="businessId != null">business_id = #{businessId},</if>
<if test="meterTypeId != null">meter_type_id = #{meterTypeId},</if>
@ -232,7 +232,7 @@
<select id="monitorLedgerList" parameterType="BaseMonitorInfo" resultMap="BaseMonitorInfoResult">
select objid,is_key_monitor parent_id, monitor_id, monitor_name, monitor_addr, monitor_type,
monitor_status, collect_device_id, ancestors, grade, build_objid, subentry_id,
monitor_status, collect_device_id, ancestors, grade, build_id, subentry_id,
business_id, meter_type_id, meter_id, correct_value, pt, ct, is_ammeter,
is_key_monitor, is_circuit, dept_id, user_id, create_by, create_time, update_by, update_time from base_monitor_info
<where>
@ -245,7 +245,7 @@
<if test="collectDeviceId != null and collectDeviceId != ''"> and collect_device_id = #{collectDeviceId}</if>
<if test="ancestors != null and ancestors != ''"> and ancestors = #{ancestors}</if>
<if test="grade != null "> and grade = #{grade}</if>
<if test="buildObjid != null and buildObjid != ''"> and build_objid = #{buildObjid}</if>
<if test="buildId != null and buildId != ''"> and build_id = #{buildId}</if>
<if test="subentryId != null and subentryId != ''"> and subentry_id = #{subentryId}</if>
<if test="businessId != null and businessId != ''"> and business_id = #{businessId}</if>
<if test="meterTypeId != null and meterTypeId != ''"> and meter_type_id = #{meterTypeId}</if>

@ -5,6 +5,7 @@ import com.hw.common.core.validated.tdengine.AddTdSTableColumn;
import com.hw.common.core.validated.tdengine.InsertTdTable;
import com.hw.common.security.annotation.InnerAuth;
import com.hw.tdengine.api.domain.*;
import com.hw.tdengine.api.domain.ems.TdSuperTableEmsSelectVo;
import com.hw.tdengine.service.IDeviceStatusService;
import com.hw.tdengine.service.ITdEngineService;
import org.slf4j.Logger;
@ -188,7 +189,7 @@ public class TdEngineController {
try {
TdFieldVo modifyTdFieldVo = TdFieldVo.convertField(modifyTdField);
this.tdEngineService.modifySuperTableColumn(databaseName, superTableName, modifyTdFieldVo);
log.info("successfully modified column for superTable {} " , superTableName);
log.info("successfully modified column for superTable {} ", superTableName);
return R.ok("successfully modified column for superTable " + superTableName);
} catch (UncategorizedSQLException e) {
String message = e.getCause().getMessage();
@ -395,6 +396,31 @@ public class TdEngineController {
}
}
@InnerAuth
@PostMapping("/getSuperTableHistoryData")
public R<TdReturnDataVo> getSuperTableHistoryData(@Validated @RequestBody TdSuperTableEmsSelectVo tdSuperTableEmsSelectVo) {
try {
int count = this.tdEngineService.getCountOfSuperTableHistoryData(tdSuperTableEmsSelectVo);
TdReturnDataVo returnDataVo = new TdReturnDataVo();
returnDataVo.setCount(count);
returnDataVo.setDataList(this.tdEngineService.getSuperTableHistoryData(tdSuperTableEmsSelectVo));
return R.ok(returnDataVo);
} catch (UncategorizedSQLException e) {
String message = e.getCause().getMessage();
try {
message = message.substring(message.lastIndexOf("invalid operation"));
} catch (Exception ex) {
}
log.error(message);
return R.fail(message);
} catch (Exception e) {
log.error(e.getMessage());
return R.fail(e.getMessage());
}
}
/**
* @return R<?>
* @param: queryDeviceStatus
@ -436,7 +462,7 @@ public class TdEngineController {
@PostMapping("/getLastOnlineDevices")
public R<?> getLastOnlineDevices(@RequestBody DeviceStatus queryDeviceStatus) {
try {
List<Map<String,Object>> deviceStatusMapList = this.deviceStatusService.getLastOnlineDevices(queryDeviceStatus);
List<Map<String, Object>> deviceStatusMapList = this.deviceStatusService.getLastOnlineDevices(queryDeviceStatus);
return R.ok(deviceStatusMapList);
} catch (UncategorizedSQLException e) {
String message = e.getCause().getMessage();
@ -464,7 +490,7 @@ public class TdEngineController {
@PostMapping("/getDeviceStatusList")
public R<List<Map<String, Object>>> getDeviceStatusList(@RequestBody DeviceStatus queryDeviceStatus) {
try {
List<Map<String,Object>> deviceStatusMapList = this.deviceStatusService.getDeviceStatusList(queryDeviceStatus);
List<Map<String, Object>> deviceStatusMapList = this.deviceStatusService.getDeviceStatusList(queryDeviceStatus);
return R.ok(deviceStatusMapList);
} catch (UncategorizedSQLException e) {
String message = e.getCause().getMessage();
@ -480,4 +506,36 @@ public class TdEngineController {
}
}
/**
* @return R<?>
* @param: alterTagVos
* @description tag
* @author xins
* @date 2023-08-30 11:17
*/
@InnerAuth
@PostMapping("/alterTableTags")
public R<?> alterTableTags(@Validated @RequestBody List<AlterTagVo> alterTagVos) {
try {
this.tdEngineService.alterTableTags(alterTagVos);
log.info("successfully altered tag " + alterTagVos.toString());
return R.ok("successfully altered tag " + alterTagVos.toString());
} catch (UncategorizedSQLException e) {
String message = e.getCause().getMessage();
try {
message = message.substring(message.lastIndexOf("invalid operation"));
} catch (Exception ex) {
}
log.error(message);
return R.fail(message);
} catch (Exception e) {
log.error(e.getMessage());
return R.fail(e.getMessage());
}
}
}

@ -1,6 +1,7 @@
package com.hw.tdengine.mapper;
import com.hw.tdengine.api.domain.*;
import com.hw.tdengine.api.domain.ems.TdSuperTableEmsSelectVo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -143,7 +144,7 @@ public interface TdEngineMapper {
/**
* @return List<Map < Object>>
* @return List<Map <String,Object>>
* @param: tdSelectDto
* @description
* @author xins
@ -153,6 +154,19 @@ public interface TdEngineMapper {
int getCountOfHistoryData(TdHistorySelectDto tdHistorySelectDto);
/**
* @return List<Map <String,Object>>
* @param: tdSelectDto
* @description
* @author xins
* @date 2023-08-29 15:50
*/
List<Map<String, Object>> getSuperTableHistoryData(TdSuperTableEmsSelectVo tdSuperTableEmsSelectVo);
int getCountOfSuperTableHistoryData(TdSuperTableEmsSelectVo tdSuperTableEmsSelectVo);
// /**
// * 检查表是否存在
// * @param dataBaseName

@ -1,6 +1,7 @@
package com.hw.tdengine.service;
import com.hw.tdengine.api.domain.*;
import com.hw.tdengine.api.domain.ems.TdSuperTableEmsSelectVo;
import java.util.List;
import java.util.Map;
@ -134,6 +135,29 @@ public interface ITdEngineService {
public int getCountOfHistoryData(TdHistorySelectDto tdHistorySelectDto);
/**
* @return List<Map <String,Object>>
* @param: tdSuperTableEmsSelectVo
* @description
* @author xins
* @date 2023-12-29 22:40
*/
public List<Map<String, Object>> getSuperTableHistoryData(TdSuperTableEmsSelectVo tdSuperTableEmsSelectVo);
/**
* @param: tdSuperTableEmsSelectVo
* @description
* @author xins
* @date 2023-12-29 22:40
* @return int
*/
public int getCountOfSuperTableHistoryData(TdSuperTableEmsSelectVo tdSuperTableEmsSelectVo);
/**
* tag
* @param alterTagVos
*/
public void alterTableTags(List<AlterTagVo> alterTagVos);
// void initSTableFrame(String msg) throws Exception;
// List<Map<String, Object>> getRealtimeData(SelectVisualDto selectVisualDto);

@ -1,6 +1,7 @@
package com.hw.tdengine.service.impl;
import com.hw.tdengine.api.domain.*;
import com.hw.tdengine.api.domain.ems.TdSuperTableEmsSelectVo;
import com.hw.tdengine.mapper.TdEngineMapper;
import com.hw.tdengine.service.ITdEngineService;
import org.apache.commons.lang3.StringUtils;
@ -238,6 +239,49 @@ public class TdEngineServiceImpl implements ITdEngineService {
int count = this.tdEngineMapper.getCountOfHistoryData(tdHistorySelectDto);
return count;
}
/**
* @return List<Map <String,Object>>
* @param: tdSuperTableCommonSelectVo
* @description
* @author xins
* @date 2023-12-29 22:40
*/
@Override
public List<Map<String, Object>> getSuperTableHistoryData(TdSuperTableEmsSelectVo tdSuperTableEmsSelectVo) {
List<Map<String, Object>> historyDataMaps = this.tdEngineMapper.getSuperTableHistoryData(tdSuperTableEmsSelectVo);
return historyDataMaps;
}
/**
* @param: tdSuperTableEmsSelectVo
* @description
* @author xins
* @date 2023-12-29 22:40
* @return int
*/
@Override
public int getCountOfSuperTableHistoryData(TdSuperTableEmsSelectVo tdSuperTableEmsSelectVo){
int count = this.tdEngineMapper.getCountOfSuperTableHistoryData(tdSuperTableEmsSelectVo);
return count;
}
/**
* tag
* @param alterTagVos
*/
@Override
public void alterTableTags(List<AlterTagVo> alterTagVos) {
alterTagVos.forEach(alterTagVo -> {
this.tdEngineMapper.alterTableTag(alterTagVo.getDatabaseName(), alterTagVo.getTableName(), alterTagVo.getTagName(), alterTagVo.getTagValue());
});
}
//
// /**
// * 检查数据库表是否存在

@ -313,6 +313,55 @@
<select id="getSuperTableHistoryData" parameterType="com.hw.tdengine.api.domain.ems.TdSuperTableEmsSelectVo" resultType="java.util.Map" >
SELECT * FROM #{databaseName}.#{superTableName}
<where>
<if test="#{firstFieldName} != null and #{firstFieldName} != '' and
startTime!= 0 ">
and ${firstFieldName} &gt;= #{startTime}
</if>
<if test="#{firstFieldName} != null and #{firstFieldName} != '' and
endTime != 0">
and ${firstFieldName} &lt;= #{endTime}
</if>
<if test="monitorObjid != null and monitorObjid != '' and monitorObjid != 0">
and monitorobjid = #{monitorObjid}
</if>
</where>
<!--由于此处orderby是用${orderByFieldName},而不是用#${orderByFieldName}这样就会用sql注入风险所以加上choose和判断条件-->
<choose>
<when test="(orderByFieldName=='ts') and (sort=='desc' or sort=='asc')">
order by ${orderByFieldName} ${sort}
</when>
</choose>
<if test="offset != null and limit != 0 ">
LIMIT #{offset},#{limit}
</if>
</select>
<select id="getCountOfSuperTableHistoryData" parameterType="com.hw.tdengine.api.domain.ems.TdSuperTableEmsSelectVo" resultType="int" >
SELECT count(*) FROM #{databaseName}.#{superTableName}
<where>
<if test="#{firstFieldName} != null and #{firstFieldName} != '' and
startTime!= 0 ">
and ${firstFieldName} &gt;= #{startTime}
</if>
<if test="#{firstFieldName} != null and #{firstFieldName} != '' and
endTime != 0">
and ${firstFieldName} &lt;= #{endTime}
</if>
<if test="monitorObjid != null and monitorObjid != '' and monitorObjid != 0">
and monitorobjid = #{monitorObjid}
</if>
</where>
</select>
<!--
<select id="checkTableExists" resultType="java.lang.Integer">
SELECT COUNT(0) FROM #{dataBaseName}.#{tableName}

@ -1,11 +1,11 @@
import request from '@/utils/request'
import { parseStrEmpty } from "@/utils/ruoyi";
import qs from 'qs';
// 查询用户列表1
export function listUser(data) {
export function listE(data) {
console.log("ele:"+data)
return request({
url: '/ems/record/dnbInstant/list',
method: 'post',
url: '/ems/record/test/list',
method: 'get',
data: data,
// data: qs.stringify(data),
// contentType:'application/x-www-form-urlencoded',

@ -0,0 +1,20 @@
import request from '@/utils/request'
import { parseStrEmpty } from "@/utils/ruoyi";
// 查询历史列表
export function listHistory(query) {
console.log("listUser1:", query);
return request({
url: '/ems/record/dnbInstant/list',
method: 'get',
params: query
})
}
// 查询部门下拉树结构
export function treeDat() {
return request({
url: '/ems/base/monitorInfo/treeData/2',
method: 'get'
})
}

@ -5,25 +5,25 @@
<el-col :span="6" :xs="24">
<div class="head-container">
<el-input
v-model="deptName"
placeholder="请输入计量设备名称"
clearable
size="small"
prefix-icon="el-icon-search"
style="margin-bottom: 20px"
v-model="deptName"
placeholder="请输入计量设备名称"
clearable
size="small"
prefix-icon="el-icon-search"
style="margin-bottom: 20px"
/>
</div>
<div class="head-container tree">
<el-tree
:data="deptOptions"
:props="defaultProps"
:expand-on-click-node="false"
:filter-node-method="filterNode"
ref="tree"
node-key="id"
default-expand-all
highlight-current
@node-click="handleNodeClick"
:data="deptOptions"
:props="defaultProps"
:expand-on-click-node="false"
:filter-node-method="filterNode"
ref="tree"
node-key="id"
default-expand-all
highlight-current
@node-click="handleNodeClick"
/>
</div>
</el-col>
@ -33,11 +33,12 @@
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="采集时间">
<el-date-picker
v-model="dateRangeone"
style="width: 240px"
type="datetime"
placeholder="选择日期时间"
value-format="yyyy-MM-dd HH:mm:ss"
v-model="dateRangeone"
style="width: 240px"
type="datetime"
placeholder="选择日期时间"
value-format="yyyy-MM-dd HH:mm:ss"
:clearable="false"
></el-date-picker>
</el-form-item>
<el-form-item><div>-</div></el-form-item>
@ -47,37 +48,39 @@
style="width: 240px"
type="datetime"
placeholder="选择日期时间"
></el-date-picker></el-form-item>
<el-form-item label="采集方式" prop="status">
:clearable="false"
></el-date-picker></el-form-item>
<!--el-form-item label="采集方式" prop="status">
<el-select
v-model="queryParams.collectType"
placeholder="请选择"
clearable
style="width: 240px"
v-model="queryParams.collectType"
placeholder="请选择"
clearable
style="width: 240px"
>
<el-option
v-for="dict in dict"
:key="dict.value"
:label="dict.label"
:value="dict.value"
v-for="dict in dict"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
</el-form-item-->
<!-- 搜索重置按钮 -->
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"></el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"></el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
>重置</el-button>
</el-form-item>
</el-form>
<!-- 新增等功能按钮 -->
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
@ -97,19 +100,19 @@
<el-table-column label="功率因数" align="center" key="glys" prop="glys" v-if="columns[9].visible" />
<el-table-column label="仪表值(kW·h)" align="center" key="zxyg" prop="zxyg" v-if="columns[10].visible" />
<el-table-column label="采集方式" align="center" key="collectType" prop="collectType" v-if="columns[11].visible" :show-overflow-tooltip="true" >
<template slot-scope="scope1">
<div>{{scope1.row.collectType==0?'手动':(scope1.row.collectType==1?'自动':'抄表') }}</div>
</template>
<template slot-scope="scope1">
<div>{{scope1.row.collectType==0?'手动':(scope1.row.collectType==1?'自动':'抄表') }}</div>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
v-show="total>0"
:total="total"
:page.sync="queryParams.params.pageNum"
:limit.sync="queryParams.params.pageSize"
@pagination="getList"
/>
</el-col>
</el-row>
@ -117,11 +120,10 @@
</template>
<script>
import { listUser, treeDat,dnbCountingData,deptTreeSelect } from "@/api/ems/base/HistoryElectricity";
import {listHistory,treeDat} from "@/api/ems/base/emsRecord";
import { getToken } from "@/utils/auth";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import * as echarts from 'echarts';
@ -186,15 +188,11 @@ export default {
},
//
queryParams: {
pageNum: 1,
pageSize: 10,
orderByColumn: 'collectTime',
collectType: '',
isAsc: 'asc',
monitorSubset:'',
params:{
beginCollectTime:'',
endCollectTime:''
monitorObjid:'',
pageNum: 1,
pageSize: 10,
}
},
//
@ -243,7 +241,6 @@ export default {
},
//
dict:[
{label:'手动',value:'0'},
{label:'自动',value:'1'},
{label:'抄表',value:'2'},
],
@ -256,85 +253,89 @@ export default {
}
},
created() {
this.dateRangeone=new Date(new Date().setHours(0, 0, 0, 0));
var d = new Date(this.dateRangeone);
let m = ('0'+(d.getMonth()+1)).slice(-2);;
let tian = ('0'+d.getDate()).slice(-2);
let h = ('0'+d.getHours()).slice(-2);
let M = ('0'+d.getMinutes()).slice(-2);
let s = ('0'+d.getSeconds()).slice(-2);
console.log('d',d)
this.dateRangeone = d.getFullYear()+ '-'+m+ '-'+tian+ ' '+ h+ ':'+M+':'+s;
this.dateRangetwo=new Date(new Date().setHours(0, 0, 0, 0) + 24 * 60 * 60 * 1000 - 1);
var d1 = new Date(this.dateRangetwo);
let m1 = ('0'+(d1.getMonth()+1)).slice(-2);
let tian1 = ('0'+d1.getDate()).slice(-2);
let h1 = ('0'+d1.getHours()).slice(-2);
let M1 = ('0'+d1.getMinutes()).slice(-2);
let s1 = ('0'+d1.getSeconds()).slice(-2);
console.log('tian1.length',tian1)
this.dateRangetwo = d1.getFullYear()+ '-'+m1+ '-'+tian1+ ' '+ h1+ ':'+M1+':'+s1;
//this.dateRangetwo = d1.getFullYear()+ '-'+m1+ '-'+tian1+ ' '+ h1+ ':'+M1+':'+s1;
this.setDataRange();
this.getList();
this.getDeptTree();
},
mounted() {
},
methods: {
setDataRange(){
this.dateRangeone=new Date(new Date().setHours(0, 0, 0, 0));
var d = new Date(this.dateRangeone);
let m = ('0'+(d.getMonth()+1)).slice(-2);;
let tian = ('0'+d.getDate()).slice(-2);
let h = ('0'+d.getHours()).slice(-2);
let M = ('0'+d.getMinutes()).slice(-2);
let s = ('0'+d.getSeconds()).slice(-2);
console.log('d',d)
this.dateRangeone = d.getFullYear()+ '-'+m+ '-'+tian+ ' '+ h+ ':'+M+':'+s;
this.dateRangetwo=new Date(new Date().setHours(0, 0, 0, 0) + 24 * 60 * 60 * 1000 - 1);
var d1 = new Date(this.dateRangetwo);
let m1 = ('0'+(d1.getMonth()+1)).slice(-2);
let tian1 = ('0'+d1.getDate()).slice(-2);
let h1 = ('0'+d1.getHours()).slice(-2);
let M1 = ('0'+d1.getMinutes()).slice(-2);
let s1 = ('0'+d1.getSeconds()).slice(-2);
console.log('tian1.length',tian1)
this.dateRangetwo = d1.getFullYear()+ '-'+m1+ '-'+tian1+ ' '+ h1+ ':'+M1+':'+s1;
//this.dateRangetwo = d1.getFullYear()+ '-'+m1+ '-'+tian1+ ' '+ h1+ ':'+M1+':'+s1;
},
/** 查询用户列表 */
getList() {
this.loading = true;
this.queryParams.params.beginCollectTime = this.dateRangeone;
this.queryParams.params.endCollectTime = this.dateRangetwo;
console.log('this.datatimeone',this.queryParams)
listUser(this.queryParams).then(response => {
this.userList = response.rows;
this.total = response.total;
this.loading = false;
}
//this.queryParams.params.beginCollectTime = this.dateRangeone;
// this.queryParams.params.endCollectTime = this.dateRangetwo;
this.dateRange[0] = this.dateRangeone;
this.dateRange[1] = this.dateRangetwo;
listHistory(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
this.userList = response.rows;
this.total = response.total;
this.loading = false;
}
);
},
//
tranListToTreeData(list) {
//
const treeList = []
// 使
const map = {}
//
const treeList = []
// 使
const map = {}
// id
list.forEach(item => {
if (!item.children) {
item.children = []
}
map[item.id] = item
})
// id
list.forEach(item => {
if (!item.children) {
item.children = []
}
map[item.id] = item
})
list.forEach(item => {
//
// children
// treeList
const parent = map[item.pId]
// item
if (parent) {
parent.children.push(item)
} else {
//
treeList.push(item)
}
})
//
return treeList
},
list.forEach(item => {
//
// children
// treeList
const parent = map[item.pId]
// item
if (parent) {
parent.children.push(item)
} else {
//
treeList.push(item)
}
})
//
return treeList
},
/** 真查询部门下拉树结构 */
getDeptTree() {
treeDat().then(response => {
response.map((item,index)=>{
item,
item.oid=item.id,
item.lable = item.name
item.oid=item.id,
item.lable = item.name
})
this.deptOptions = this.tranListToTreeData(response);
console.log(this.deptOptions)
@ -348,7 +349,7 @@ export default {
},
//
handleNodeClick(data) {
this.queryParams.monitorSubset = data.monitorId;
this.queryParams.params.monitorObjid = data.id;
this.getList();
},
//
@ -376,18 +377,25 @@ export default {
},
/** 搜索按钮操作 */
handleQuery() {
if(this.dateRangeone == null || this.dateRangeone == undefined || this.dateRange == ''){
this.$modal.msgWarning("请选择采集开始时间");
return;
}
if(this.dateRangetwo == null || this.dateRangetwo == undefined || this.dateRangetwo == ''){
this.$modal.msgWarning("请选择采集结束时间");
return;
}
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
//this.dateRange = [];
this.queryParams.collectType = '';
this.queryParams.params.monitorObjid = '';
this.dateRangeone = '';
this.dateRangetwo = '';
this.setDataRange();
this.resetForm("queryForm");
//this.queryParams.deptId = undefined;
//this.$refs.tree.setCurrentKey(null);
this.handleQuery();
},
//
@ -410,22 +418,31 @@ export default {
}
},
/** 导出按钮操作 */
handleExport() {
let paramsexport = JSON.parse(JSON.stringify(this.queryParams));
delete paramsexport.pageSize;
delete paramsexport.pageNum;
this.download('/energy/record/dnbInstant/export', {
...paramsexport
this.download('ems/record/dnbInstant/export', {
...this.queryParams
}, `user_${new Date().getTime()}.xlsx`)
},
/** 导出按钮操作 */
// handleExport() {
// let paramsexport = JSON.parse(JSON.stringify(this.queryParams));
// delete paramsexport.pageSize;
// delete paramsexport.pageNum;
// this.download('/energy/record/dnbInstant/export', {
// ...paramsexport
// }, `user_${new Date().getTime()}.xlsx`)
// },
}
};
</script>
<style lang="scss" scoped>
.tree {
width:220px;
::v-deep .el-tree-node {
width:220px;
::v-deep .el-tree-node {
white-space: normal;//!!!!!!!!!
.el-tree-node__content {
height: 100%;

Loading…
Cancel
Save