初始化静态数据

parent 4ae28400
/**
* 迪勤云平台 API 客户端
*/
import * as crypto from 'crypto';
import { post } from '../util/request';
import { BizError } from '../util/bizError';
import { ERRORENUM } from '../config/errorEnum';
/**
* 获取网关设备列表(分页)
* @param page 当前页码,默认 1
* @param limit 每页条数,默认 10
* @returns 网关设备数据,包含 rows、total 等
*/
export async function processDeviceData(page: number = 1, limit: number = 10): Promise<any> {
const path = '';
const body = { page, limit };
const result = {data: {}};
return result.data;
}
export async function getToken() {
}
\ No newline at end of file
/**
* 区域位置业务
*/
import * as crypto from 'crypto';
import { post } from '../util/request';
/**
* 区域位置
* @returns 区域位置数据
*/
export async function getRegionLocation(gatewayPage: number) {
const result = [{"regionKey":"32","regionName":"三十二位","xz":1587,"yz":487,"qualityIndex":"优","gatewayPage":gatewayPage}];
return result;
}
\ No newline at end of file
// 请求第三方客户端接口枚举
export enum FEIYI {
获取Token = '/oauth2/openapi/token',
网关设备列表 = '/openApi/gw/page',
内机列表 = '/openApi/indoorUnit/list',
内机控制 = '/openApi/indoorUnit/control',
建筑物树结构 = '/openApi/building/tree',
电表列表 = '/openApi/electricMeter/getAll',
抄表记录 = '/openApi/electricMeterState/list',
内机开关机记录 = '/openApi/indoorUnit/event/switch',
}
export enum DIQIN {
获取Token = '/v2/tokens/access_token',
获取区域信息 = '/v2/locations',
获取区域明细信息 = '/v2/locations/', // {location_id}
获取环境设备信息 = '/v2/devices/', // {device_id}
获取环境设备数据信息 = '/v2/data_sources/' // {data_source_id}
}
\ No newline at end of file
......@@ -44,7 +44,9 @@ export enum ERRORENUM {
空文件失败,
文件上传失败,
只能上传docdocxexcelpngjpg图片,
该时间段已有预约
该时间段已有预约,
网络错误,
第三方接口错误
}
/**
......
......@@ -79,6 +79,17 @@ export const TablesConfig = [
defaultValue: null,
comment: '父级区域ID,null表示顶级区域,用于层级关系'
},
parent_key: {
type: Sequelize.STRING(100),
allowNull: true,
defaultValue: null,
comment: '父级区域key,作为parent_id补充'
},
region_param: {
type: DataTypes.JSON,
allowNull: true,
comment: '区域参数定义,包含坐标等'
},
sort_order: {
type: DataTypes.INTEGER,
allowNull: false,
......@@ -418,14 +429,24 @@ export const TablesConfig = [
allowNull: false,
comment: '设备标识'
},
fault_type: {
fault_origin_id: {
type: Sequelize.STRING(100),
allowNull: false,
comment: '原始故障id'
},
fault_code: {
type: DataTypes.STRING(50),
allowNull: true,
comment: '故障代码'
},
fault_type: {
type: Sequelize.STRING(100),
allowNull: true,
comment: '故障类型'
},
fault_level: {
type: Sequelize.ENUM('一级', '二级', '三级'),
allowNull: false,
allowNull: true,
comment: '故障等级'
},
fault_info: {
......
......@@ -17,3 +17,16 @@ export async function addData(tableName:string, data:any) {
return { isSuccess:true };
}
/**
* 插入单条数据并返回完整记录(含自增ID)
* 使用 create 替代 bulkCreate,确保返回值包含自增主键
* @param tableName 表名
* @param data 单条数据对象
* @returns { isSuccess, data: 插入后的完整记录 }
*/
export async function insertOne(tableName: string, data: any) {
let tableModel = mysqlModelMap[tableName];
const result = await tableModel.create(data);
return { isSuccess: true, data: result };
}
\ No newline at end of file
/**
* 访问迪勤客户端API接口
*/
import asyncHandler from 'express-async-handler';
import * as diqinClientBiz from '../biz/diqinClient';
import { eccReqParamater } from '../util/verificationParam';
export function setRouter(httpServer) {
/** 获取环境监测数据 */
httpServer.post('/api/dq/diqin/getProcessDevices', asyncHandler(getProcessDevices));
}
/**
* 获取环境监测数据
* @param page 当前页码,默认 1
* @param limit 每页条数,默认 10
*/
async function getProcessDevices(req, res) {
let reqConf = {page:'Number', limit:'Number', roomId: 'String', indoorUnitAddressFull: 'String'};
const NotMustHaveKeys = [ "page", "limit", "roomId", "indoorUnitAddressFull" ];
let params = eccReqParamater(reqConf, req.body, NotMustHaveKeys);
const result = await diqinClientBiz.processDeviceData(params);
res.success(result);
}
\ No newline at end of file
/**
* 访问飞翼客户端API接口
*/
import asyncHandler from 'express-async-handler';
import * as feiyiClientBiz from '../biz/feiyiClient';
import { eccReqParamater } from '../util/verificationParam';
export function setRouter(httpServer) {
/** 网关设备列表 */
httpServer.post('/api/dq/feiyi/gateway/list', asyncHandler(getFeiyiGatewayList));
/** 空调内机列表 */
httpServer.post('/api/dq/feiyi/indoorUnit/list', asyncHandler(getFeiyiIndoorUnitList));
/** 空调内机控制 */
httpServer.post('/api/dq/feiyi/indoorUnit/control', asyncHandler(getFeiyiIndoorUnitControl));
}
/**
* 网关设备列表
*/
async function getFeiyiGatewayList(req, res) {
let reqConf = {page:'Number', limit:'Number'};
const NotMustHaveKeys = [ "page", "limit" ];
let { page, limit } = eccReqParamater(reqConf, req.body, NotMustHaveKeys);
const result = await feiyiClientBiz.getGatewayDeviceList(page, limit);
res.success(result);
}
/**
* 空调内机列表
* @param page 当前页码,默认 1
* @param limit 每页条数,默认 10
* @param buildingId 楼栋ID(可选)
* @param floorId 楼层ID(可选)
* @param roomId 区域ID(可选)
* @param gatewayCode 网关设备ID(可选)
*/
async function getFeiyiIndoorUnitList(req, res) {
let reqConf = {page:'Number', limit:'Number', roomId: 'String', indoorUnitAddressFull: 'String'};
const NotMustHaveKeys = [ "page", "limit", "roomId", "indoorUnitAddressFull" ];
let params = eccReqParamater(reqConf, req.body, NotMustHaveKeys);
const result = await feiyiClientBiz.getIndoorUnitList(params);
res.success(result);
}
/**
* 空调内机控制
* @param indoorUnitAddressFull 要控制的内机地址集合
* @param workMode 1 制冷 2 制热 3 送风 4 除湿
* @param openApiAction control 控制指令 / lock 锁定指令
*/
async function getFeiyiIndoorUnitControl(req, res) {
let reqConf = { indoorUnitAddressFull: 'Array', workMode: 'Number', openApiAction: 'String' };
const NotMustHaveKeys = [ "workMode", "openApiAction" ];
let params = eccReqParamater(reqConf, req.body, NotMustHaveKeys);
const result = await feiyiClientBiz.controlIndoorUnit(params);
res.success(result);
}
/**
* 区域位置路由
*/
import asyncHandler from 'express-async-handler';
import * as regionBiz from '../biz/region';
import { eccReqParamater } from '../util/verificationParam';
export function setRouter(httpServer) {
/** 区域位置 */
httpServer.post('/api/dq/region/location', asyncHandler(getRegionLocation));
}
/**
* 区域位置
*/
async function getRegionLocation(req, res) {
let reqConf = {gatewayPage:'Number'};
const NotMustHaveKeys = [];
let { gatewayPage } = eccReqParamater(reqConf, req.body, NotMustHaveKeys);
const result = await regionBiz.getRegionLocation(gatewayPage);
res.success(result);
}
\ No newline at end of file
/**
* 总路由入口
*/
import * as feiyiClientRouter from './feiyiClient';
import * as diqinClientRouter from './diqinClient';
import * as regionRouter from './region';
import * as runningRouter from './running';
export function setRouter(httpServer) {
feiyiClientRouter.setRouter(httpServer);
diqinClientRouter.setRouter(httpServer);
regionRouter.setRouter(httpServer);
runningRouter.setRouter(httpServer);
}
......
/**
* 运行分析路由
*/
import asyncHandler from 'express-async-handler';
import * as runningBiz from '../biz/running';
import { eccReqParamater } from '../util/verificationParam';
export function setRouter(httpServer) {
/** 运行分析 */
httpServer.post('/api/dq/run/analysis', asyncHandler(getRunAnalysis));
/** 运行分析弹窗 */
httpServer.post('/api/dq/run/analysis/popup', asyncHandler(getAnalysisPopup));
/** 智能监控 */
httpServer.post('/api/dq/run/monitoring', asyncHandler(getRunMonitoring));
/** 智能监控弹窗 */
httpServer.post('/api/dq/run/monitor/popup', asyncHandler(getMonitorPopup));
/** 控制设备运行 */
httpServer.post('/api/dq/run/device/running', asyncHandler(controlDeviceRunning));
}
/**
* 运行分析
*/
async function getRunAnalysis(req, res) {
const { } = req.body;
const result = await runningBiz.getRunAnalysis();
res.success(result);
}
/**
* 运行分析弹窗
*/
async function getAnalysisPopup(req, res) {
const { } = req.body;
const result = await runningBiz.getAnalysisPopup();
res.success(result);
}
/**
* 智能监控
*/
async function getRunMonitoring(req, res) {
const { } = req.body;
const result = await runningBiz.getRunMonitoring();
res.success(result);
}
/**
* 智能监控弹窗
*/
async function getMonitorPopup(req, res) {
const { } = req.body;
const result = await runningBiz.getMonitorPopup();
res.success(result);
}
/**
* 控制设备运行
* @param req
* @param res
*/
async function controlDeviceRunning(req, res) {
let reqConf = {deviceId:'String', deviceType:'String', status:'Number'};
const NotMustHaveKeys = [ "deviceType" ];
let params = eccReqParamater(reqConf, req.body, NotMustHaveKeys);
const result = await runningBiz.controlDeviceRunning(params);
res.success(result);
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment