Bläddra i källkod

chore(api): 接口更新

wangshun 3 månader sedan
förälder
incheckning
cf1db992e7
2 ändrade filer med 631 tillägg och 2 borttagningar
  1. 181 2
      src/api/index.ts
  2. 450 0
      src/types/index.ts

+ 181 - 2
src/api/index.ts

@@ -1,5 +1,32 @@
 import qs from 'qs';
 
+import type {
+  VerificationEquipment,
+  GatewayInformation,
+  GatewayModelInfo,
+  GatewayInterface,
+  AddInterface,
+  InterfaceData,
+  ListInfo,
+  EquipmentInformationForm,
+  ProtocolList,
+  ProtocolItemData,
+  DeviceGroupItem,
+  EquipmentTypeItem,
+  ProtocolReset,
+  AgreementUpdate,
+  VerificationAgreement,
+  ProtocolListItem,
+  ProtocolListPageItem,
+  ProtocolListPageItemData,
+  SerialNumberItemData,
+  EquipmentUpdateForm,
+  PostProtocolPage,
+  PostProtocolPageItemData,
+  ListEquipmentParametersItemData,
+  ProtocolGatewayListListItem,
+} from '@/types';
+
 import { request } from '@/utils';
 
 import type {
@@ -71,10 +98,32 @@ export const getDictTypeData = async (params: DictTypeDataParams) => {
 
 // ----- 业务服务 -----
 
+// 设备组列表
+
+export const getPageList = async () => {
+  const data = await request<DeviceGroupItem[]>(apiBiz('/deviceGroup/getList'), {
+    method: 'POST',
+  });
+  return data;
+};
+
 // 设备列表
 
-export const addDevice = async () => {
-  await request(apiBiz('/device/add'));
+export const deviceAdd = async (equipmentInformationForm: EquipmentInformationForm) => {
+  const data = await request<number>(apiBiz('/device/add'), {
+    method: 'POST',
+    body: JSON.stringify(equipmentInformationForm),
+  });
+  return data;
+};
+
+// 设备网关
+
+export const deviceGatewayUpdate = async (equipmentUpdateForm: EquipmentUpdateForm[]) => {
+  await request(apiBiz('/deviceGateway/update'), {
+    method: 'POST',
+    body: JSON.stringify(equipmentUpdateForm),
+  });
 };
 
 // 网关基本信息
@@ -83,6 +132,108 @@ export const addGateway = async () => {
   await request(apiBiz('/gateway/add'));
 };
 
+export const validateGatewayInfo = async (registerGatewayForm: VerificationEquipment) => {
+  const data = await request<GatewayInformation>(apiBiz('/gateway/validate', registerGatewayForm), {
+    method: 'POST',
+  });
+  return data;
+};
+
+// 网关通讯
+
+export const gatewayLinkAdd = async (addInterface: AddInterface) => {
+  await request(apiBiz('/gatewayLink/add'), {
+    method: 'POST',
+    body: JSON.stringify(addInterface),
+  });
+};
+
+export const gatewayLinkDelete = async (id: number) => {
+  await request(apiBiz(`${'/gatewayLink/delete/'}${id}`), {
+    method: 'POST',
+  });
+};
+
+export const gatewayLinkGetList = async (gatewayId: number) => {
+  const data = await request<InterfaceData[]>(apiBiz(`${'/gatewayLink/getList/'}${gatewayId}`), {
+    method: 'POST',
+  });
+  return data;
+};
+
+export const gatewayLinkUpdate = async (agreementUpdate: AgreementUpdate) => {
+  await request(apiBiz('/gatewayLink/update'), {
+    method: 'POST',
+    body: JSON.stringify(agreementUpdate),
+  });
+};
+
+// 网关型号
+
+export const getGatewayModelInfo = async (id: number) => {
+  const data = await request<GatewayModelInfo>(apiBiz(`${'/gatewayModel/info/'}${id}`));
+  return data;
+};
+
+export const getGatewayModelInterfaces = async (id: number) => {
+  const data = await request<GatewayInterface[]>(apiBiz(`${'/gatewayModel/interfaces/'}${id}`), {
+    method: 'POST',
+  });
+  return data;
+};
+
+// 网关接口协议
+
+export const gatewayLinkProtocolList = async <T>(protocolListItem: ProtocolListItem) => {
+  const data = await request<T>(apiBiz('/gatewayLinkProtocol/getParamPageList'), {
+    method: 'POST',
+    body: JSON.stringify(protocolListItem),
+  });
+  return data;
+};
+
+export const gatewayLinkProtocolGatewayList = async (protocolGatewayListListItem: ProtocolGatewayListListItem) => {
+  const data = await request<ListEquipmentParametersItemData>(
+    apiBiz('/gatewayLinkProtocol/getParamPageListByGateway'),
+    {
+      method: 'POST',
+      body: JSON.stringify(protocolGatewayListListItem),
+    },
+  );
+  return data;
+};
+
+export const gatewayLinkList = async (id: number) => {
+  const data = await request<VerificationAgreement[]>(apiBiz(`${'/gatewayLinkProtocol/getProtocolInfoList/'}${id}`), {
+    method: 'POST',
+  });
+  return data;
+};
+
+export const gatewayLinkProtocolReset = async (protocolReset: ProtocolReset) => {
+  await request(apiBiz('/gatewayLinkProtocol/reset'), {
+    method: 'POST',
+    body: JSON.stringify(protocolReset),
+  });
+};
+
+// 组织网关
+
+export const orgGatewayRegister = async (gatewayId: number) => {
+  await request(apiBiz('/orgGateway/register'), {
+    method: 'POST',
+    body: JSON.stringify({ gatewayId }),
+  });
+};
+
+export const orgGatewaySerialNumber = async (protocolList: ProtocolList) => {
+  const data = await request<SerialNumberItemData>(apiBiz('/orgGateway/getGatewayPageList'), {
+    method: 'POST',
+    body: JSON.stringify(protocolList),
+  });
+  return data;
+};
+
 // 协议参数
 
 export const getProtocolParamList = async (params: ProtocolParamSearchParams) => {
@@ -155,3 +306,31 @@ export const updateProtocolBaseInfo = async (params: ProtocolBaseInfo) => {
     body: JSON.stringify(params),
   });
 };
+
+export const postProtocolList = async (protocolList: ProtocolList) => {
+  const data = await request<ProtocolItemData>(apiBiz('/protocolBaseInfo/getPageList'), {
+    method: 'POST',
+    body: JSON.stringify(protocolList),
+  });
+  return data;
+};
+
+// 协议参数表
+
+export const postProtocolPageList = async (postProtocolPage: PostProtocolPage) => {
+  const data = await request<PostProtocolPageItemData>(apiBiz('/protocolParamInfo/page/list'), {
+    method: 'POST',
+    body: JSON.stringify(postProtocolPage),
+  });
+  return data;
+};
+
+// 全局参数
+
+export const groupList = async (listInfo: ListInfo) => {
+  const data = await request<EquipmentTypeItem[]>(apiBiz('/deviceGlobalData/getList'), {
+    method: 'POST',
+    body: JSON.stringify(listInfo),
+  });
+  return data;
+};

+ 450 - 0
src/types/index.ts

@@ -184,3 +184,453 @@ export interface ProtocolParamSearchParams extends PageParams {
   paramCode?: string;
   paramName?: string;
 }
+export interface RegisterGatewayForm {
+  snCode: string;
+  password: string;
+  modelId: number;
+  linkType: string;
+}
+
+export interface VerificationEquipment {
+  snCode: string;
+  password: string;
+}
+
+export interface GatewayInformation {
+  createTime: string;
+  createUserId: string;
+  deleted: number;
+  id: number;
+  isRegister: number;
+  modelId: number;
+  password: string;
+  snCode: string;
+  state: number;
+  updateTime: string;
+  updateUserId: number;
+}
+
+export interface GatewayModelInfo {
+  createTime: string;
+  createUserId: string;
+  deleted: number;
+  docUrl: string;
+  iconUrl: string;
+  id: number;
+  interfaceId: string;
+  interfaceNum: string;
+  modelName: string;
+  surfMode: string;
+  surfModeEn: string;
+  updateTime: string;
+  updateUserId: string;
+}
+
+export interface InterfaceNum {
+  COM: number;
+  DI: number;
+  DO: number;
+  LAN: number;
+  WAN: number;
+}
+
+export interface EquipmentInformation {
+  id: number;
+  state: number;
+  modelId: number;
+  docUrl: string;
+  iconUrl: string;
+  interfaceNum: string;
+  modelName: string;
+  surfMode: string | string[];
+  surfModeEn: string | string[];
+}
+
+export interface GatewayInterface {
+  comment: string;
+  createTime: string;
+  createUserId: string;
+  deleted: number;
+  dictCode: string;
+  dictEngValue: string;
+  dictValue: string;
+  enabled: number;
+  id: number;
+  isDefault: string;
+  orderNum: number;
+  tag: string;
+  updateTime: string;
+  updateUserId: string;
+}
+
+export interface AddInterface {
+  linkName: string;
+  gatewayId: number;
+  linkTypeId: number;
+}
+
+export interface InterfaceList {
+  value: string;
+  label: string;
+}
+
+export interface InterfaceData {
+  id: number;
+  createTime: string;
+  updateTime: string;
+  createUserId: number;
+  updateUserId: number;
+  linkName: string;
+  gatewayId: number;
+  linkTypeId: number;
+  protocolType: string;
+  bindState: number;
+  dataBit: number;
+  parityBit: string;
+  stopBit: string;
+  baudRate: number;
+  readTimeout: number;
+  nextDataReadDelay: number;
+  nextRoundDataReadDelay: number;
+  valueType: string;
+}
+
+export interface AgreementUpdate {
+  id: number;
+  linkName: string;
+  gatewayId: number;
+  linkTypeId: number;
+  bindState: number;
+  dataBit: string;
+  parityBit: string;
+  stopBit: string;
+  baudRate: number;
+  readTimeout: number;
+  nextDataReadDelay: number;
+  nextRoundDataReadDelay: number;
+}
+
+export interface AgreementData {
+  protocolType: string;
+  station: string;
+  name: string;
+  protocolName: string;
+  dev: string;
+  dataSendInterval: number;
+  highFreqSendInterval: number;
+  protocolId: number;
+  isStandard: string;
+}
+
+export interface AgreementForm {
+  baudRate: number;
+  dataBit: string;
+  parityBit: string;
+  stopBit: string;
+  readTimeout: number;
+  nextDataReadDelay: number;
+  nextRoundDataReadDelay: number;
+}
+
+export interface EquipmentGroup {
+  pageIndex: number;
+  pageSize: number;
+  content: string;
+}
+
+export interface DeviceGroupItem {
+  id: number;
+  createTime: Date | null;
+  updateTime: Date | null;
+  createUserId: number | null;
+  updateUserId: number | null;
+  groupName: string;
+  comment: string | null;
+  parentId: number;
+  userId: number;
+  deleted: boolean | null;
+  deviceGroupChilds: DeviceGroupChild[];
+}
+
+export interface DeviceGroupChild {
+  id: number;
+  groupName: string;
+  comment: string | null;
+  parentId: number;
+  userId: number;
+}
+
+export interface ListInfo {
+  dataType: number;
+}
+
+export interface ProtocolList {
+  pageIndex: number;
+  pageSize: number;
+}
+
+export interface EquipmentInformationForm {
+  groupId: number;
+  deviceData: number[];
+  deviceType: string;
+  deviceName: string;
+  brand: number;
+  model: number;
+  modelType: number;
+  controlType: number;
+  compressionLevel: number;
+  voltageLevel: number;
+  powerRating: string;
+  powerUnload: string;
+  maximumFlow: string;
+  pressure: string;
+  pressureMax: string;
+  productionDate: string;
+  productionNum: string;
+  deviceNum: string;
+  mainTechData: string;
+  mountedPosition: string;
+  department: string;
+  respPerson: string;
+  phone: string;
+  serviceLife: number;
+  status: string;
+  remarks: string;
+  devId: number;
+}
+
+export interface EquipmentTypeItem {
+  id: number;
+  createTime: string;
+  updateTime: string;
+  createUserId: number;
+  updateUserId: number;
+  dataType: number;
+  dataName: string;
+}
+
+export type ProtocolItemData = PageData<ProtocolItem>;
+export interface ProtocolItem {
+  id: number;
+  createTime: string;
+  updateTime: string;
+  createUserId: number;
+  updateUserId: number;
+  protocolName: string;
+  protocolType: string;
+  deviceTypeId: number | null;
+  deviceType: string;
+  dataBit: number;
+  parityBit: string;
+  stopBit: string;
+  baudRate: number;
+  dataSendInterval: number;
+  highFreqSendInterval: number;
+  readTimeout: number | null;
+  nextDataReadDelay: number;
+  nextRoundDataReadDelay: number;
+  addrOrder: string;
+  addrOrderCode: string;
+  byteOrder: string;
+  byteOrderCode: string;
+  attachment: string;
+  readContinuousAddr: string;
+  readContinuousAddrCode: number;
+  readContinuousAddrLength: number;
+}
+
+export interface ProtocolsItem {
+  /*协议ID */
+  protocolId: number;
+
+  /*从站号 */
+  station: string;
+
+  /*是否平台标准协议 */
+  isStandard: string;
+
+  /*普通数据上报频率 */
+  dataSendInterval: number;
+
+  /*高频发送间隔 */
+  highFreqSendInterval: number;
+}
+export interface ProtocolReset {
+  linkId: number;
+  protocols: ProtocolsItem[];
+}
+
+export interface VerificationAgreement {
+  id: number;
+  createTime: string;
+  updateTime: string;
+  createUserId: number;
+  updateUserId: number;
+  linkId: number;
+  protocolId: number;
+  station: number;
+  isStandard: number;
+  dataSendInterval: number;
+  highFreqSendInterval: number;
+  protocolName: string;
+  protocolType: string;
+}
+
+export interface ProtocolListItem {
+  pageIndex: number;
+  pageSize: number;
+  id?: number;
+  linkId?: number;
+  readWriteTypeCode?: string;
+}
+
+export type ProtocolListPageItemData = PageData<ProtocolListPageItem>;
+export interface ProtocolListPageItem {
+  id: number;
+  createTime: string | null;
+  updateTime: string | null;
+  createUserId: number | null;
+  updateUserId: number | null;
+  baseInfoId: number | null;
+  platformParamCode: string | null;
+  platformParamName: string | null;
+  gatewayParamCode: string;
+  gatewayParamName: string;
+  paramCode: string;
+  paramName: string;
+  unit: string | null;
+  module: any | null;
+  readWriteType: string | null;
+  readWriteTypeCode: string | null;
+  readFuncCode: string | null;
+  writeFuncCode: string | null;
+  registerAddr: string | null;
+  addrNumber: number | null;
+  registerType: string | null;
+  registerTypeCode: string | null;
+  parsingType: string | null;
+  parsingTypeCode: string | null;
+  addrLength: number | null;
+  wordLength: number | null;
+  wordLengthCode: string | null;
+  quantity: number | null;
+  coefficient: number;
+  isHighFreqParam: boolean | null;
+  isHighFreqParamCode: string | null;
+  readCalcFormula: string | null;
+  writeCalcFormula: string | null;
+  decimalPlace: number | null;
+}
+
+export type SerialNumberItemData = PageData<SerialNumberItem>;
+export interface SerialNumberItem {
+  id: number;
+  createTime: string;
+  updateTime: string;
+  createUserId: number | null;
+  updateUserId: number | null;
+  snCode: string;
+  password: string;
+  modelId: number;
+  isRegister: number;
+  state: number;
+  deleted: number;
+  modelName: string;
+}
+
+export type ListEquipmentParametersItemData = PageData<ListEquipmentParametersItem>;
+
+export interface ListEquipmentParametersItem {
+  id: number;
+  createTime: string;
+  updateTime: string;
+  createUserId: number;
+  updateUserId: number;
+  baseInfoId: number;
+  platformParamCode: string | null; // 由于值为空字符串,但根据业务逻辑可能需要区分空字符串和null,这里使用string | null。如果不需要区分,可以仅使用string。
+  platformParamName: string | null; // 同上
+  gatewayParamCode: string | null; // 同上
+  gatewayParamName: string | null; // 同上
+  paramCode: string;
+  paramName: string;
+  unit: string | null;
+  module: string;
+  readWriteType: string;
+  readWriteTypeCode: string;
+  readFuncCode: string;
+  writeFuncCode: string | null; // 由于值为空字符串,但根据业务逻辑,这里使用string | null表示可能未设置写入功能码。
+  registerAddr: string; // 假设寄存器地址为字符串类型,如果应为数字类型则改为number。
+  addrNumber: string | null; // 由于值为空字符串,但可能表示未设置或未知地址编号,这里使用string | null。
+  registerType: string | null;
+  registerTypeCode: string | null;
+  parsingType: string;
+  parsingTypeCode: string;
+  addrLength: number;
+  wordLength: number | null;
+  wordLengthCode: string | null;
+  quantity: number | null;
+  coefficient: number;
+  isHighFreqParam: string; // 根据业务逻辑,这个字段表示是否高频参数,使用字符串"是"/"否"表示,也可以考虑使用boolean类型并转换值。
+  isHighFreqParamCode: string; // 使用字符串"1"/"0"表示,也可以考虑使用boolean类型并转换值。
+  readCalcFormula: string | null;
+  writeCalcFormula: string | null;
+  decimalPlace: number | null;
+}
+
+export interface EquipmentUpdateForm {
+  deviceId: number;
+  gatewayId: number;
+  gatewayProtocolId: number;
+}
+
+export interface PostProtocolPage {
+  pageIndex: number;
+  pageSize: number;
+  deviceIds: number[];
+  gatewayIds: number[];
+}
+
+export type PostProtocolPageItemData = PageData<PostProtocolPageItem>;
+export interface PostProtocolPageItem {
+  id: number;
+  createTime: string;
+  updateTime: string;
+  createUserId: number;
+  updateUserId: number;
+  baseInfoId: number;
+  platformParamCode?: string; // 使用 ? 表示该属性可能是 undefined
+  platformParamName?: string; // 使用 ? 表示该属性可能是 undefined
+  gatewayParamCode?: string; // 使用 ? 表示该属性可能是 undefined
+  gatewayParamName?: string; // 使用 ? 表示该属性可能是 undefined
+  paramCode: string;
+  paramName: string;
+  unit?: string; // 使用 ? 表示该属性可能是 undefined
+  module: string;
+  readWriteType: string;
+  readWriteTypeCode: string;
+  readFuncCode: string;
+  writeFuncCode?: string; // 使用 ? 表示该属性可能是 undefined
+  registerAddr: string;
+  addrNumber?: string; // 使用 ? 表示该属性可能是 undefined
+  registerType?: any; // 使用 any 表示该属性类型未知,null 也是可能的值
+  registerTypeCode?: any; // 使用 any 表示该属性类型未知,null 也是可能的值
+  parsingType: string;
+  parsingTypeCode: string;
+  addrLength: number;
+  wordLength?: any; // 使用 any 表示该属性类型未知,null 也是可能的值
+  wordLengthCode?: any; // 使用 any 表示该属性类型未知,null 也是可能的值
+  quantity?: any; // 使用 any 表示该属性类型未知,null 也是可能的值
+  coefficient: number;
+  isHighFreqParam: string; // "是" 或 "否" 可以进一步定义为枚举类型
+  isHighFreqParamCode: string; // "1" 或 "0" 可以进一步定义为枚举类型
+  readCalcFormula?: string; // 使用 ? 表示该属性可能是 undefined
+  writeCalcFormula?: string; // 使用 ? 表示该属性可能是 undefined
+  decimalPlace?: any; // 使用 any 表示该属性类型未知,null 也是可能的值
+}
+
+export interface ProtocolGatewayListListItem {
+  pageIndex: number;
+  pageSize: number;
+  snCode?: number;
+  gatewayId?: number;
+}