240717班级,工业化控制系统,煤矿相关行业,昆仑系统
gong
2024-11-07 181a105d2f9688e50d75e7137f1ac6d276558325
common.h
@@ -1,11 +1,11 @@
#ifndef COMMON_H
#define COMMON_H
#include  <string.h>
#include <vector>
enum TypeInfo{
#include <string.h>
    //注册登录
enum TypeInfo {
   //注册登录
   LOGIN_REQ, // 登录请求
   LOGIN_RES, // 登录响应
   REGISTER_REQ, //注册请求
@@ -13,506 +13,977 @@
   RESET_REQ, //重置密码请求
   RESET_RES, //重置密码响应
    //历史查询分析
    HISTORY_QUERY_REQ, // 历史查询请求
    HISTORY_QUERY_RES, // 历史查询响应
    //权限管理
    QUERY_PMS_REQ,      // 按员工编号、名字或职位查询人员权限信息请求
    UPDATE_PMS_REQ,     // 按角色id更新权限信息请求
    QUERY_PMS_RES,      // 查询人员和角色信息的响应结构体
    UPDATE_PMS_RES,     // 权限更新结果响应体
   //权限管理
   QUERY_PMS_REQ,      // 按员工编号、名字或职位查询人员权限信息请求
   UPDATE_PMS_REQ,     // 按角色id更新权限信息请求
   QUERY_PMS_RES,      // 查询人员和角色信息的响应结构体
   UPDATE_PMS_RES,     // 权限更新结果响应体
    //地图标注
    MAPMARK_REQ,//地图标注请求
   MAPMARK_RES//地图标注响应
   //设备管理
   AD_REQ,//添加设备请求
   AD_RES,//添加设备响应
   MD_REQ,//修改设备请求
   MD_RES,//修改设备响应
   QD_REQ,//查询设备请求
   QD_RES,//查询设备响应
   //地图标注
   MML_REQ,//地图标注加载请求
   MML_RES,//地图标注加载响应
   MMI_REQ,//地图标注插入请求
   MMI_RES,//地图标注插入响应
   MMD_REQ,//地图标注删除请求
   MMD_RES,//地图标注删除响应
   //大屏显示
   ENVIRONMENT_REQ,//环境数据请求
    ENVIRONMENT_RES,//环境数据响应
    DEVICESTATUS_REQ,//设备状态请求
    DEVICESTATUS_RES,//设备状态响应
    MOVEMENTRECORD_REQ,//操作日志请求
    MOVEMENTRECORD_RES,//操作日志响应
    ALARMRECORD_REQ,//警报记录请求
    ALARMRECORD_RES,//警报记录响应
    YIELD_REQ,//煤矿产量请求
    YIELD_RES,//煤矿产量响应
   ENVIRONMENT_RES,//环境数据响应
   DEVICESTATUS_REQ,//设备状态请求
   DEVICESTATUS_RES,//设备状态响应
   MOVEMENTRECORD_REQ,//操作日志请求
   MOVEMENTRECORD_RES,//操作日志响应
   ALARMRECORD_REQ,//警报记录请求
   ALARMRECORD_RES,//警报记录响应
   YIELD_REQ,//煤矿产量请求
   YIELD_RES,//煤矿产量响应
    //生产计划管理
    ADDPRODUCTIONPLAN_REQ,//添加一行数据的请求结构体
   ADDPRODUCTIONPLAN_RES,//添加一行数据的响应结构体
   UPDATEPRODUCTIONPLANQUANTITY_REQ,// 更新生产计划(计划生产量)的请求结构体
   UPDATEPRODUCTIONPLANQUANTITY_RES,// 更新生产计划(计划生产量)的响应结构体
   UPDATEPRODUCTIONPLANLOG_REQ,//更新生产计划(日志)的请求结构体
   UPDATEPRODUCTIONPLANLOG_RES,//更新生产计划(日志)的响应结构体
   PRODUCTIONPLAN_REQ,// 查询生产计划信息的请求结构体
   PRODUCTIONPLAN_RES,// 查询生产计划信息的响应结构体
   FORRECENTFOURTEENPRODUCTIONPLANS_REQ,//查询近十四条的请求结构体
   FORRECENTFOURTEENPRODUCTIONPLANS_RES //查询近十四条的响应结构体
   //警报管理
   WARNING_REQ, // 警报请求
    WARNING_RES, // 警报响应
    DATA_REQ,  // 数据请求
    DATA_RES,  // 数据响应
    THRESHOLD_REQ, //阈值请求
    THRESHOLD_RES, //阈值响应
    //自动升级&版本管理
    VERSIONNUM_REQ,  // 版本号请求
    VERSIONNUM_RES,   // 版本号响应
    UPLOAD_FILE_REQ, // 上传文件的请求
    UPLOAD_FILE_RES, // 上传文件的响应
    VERSIONINFOENTRY_REQ,       // 版本信息录入请求
    VERSIONINFOENTRY_RES,       //版本信息录入响应
    VERSIONUPDATE_REQ, // 版本更新请求
    VERSIONUPDATE_RES, // 版本更新响应
    FILEDOWNLOADS_REQ, // 版本更新文件下载请求
    FILEDOWNLOADS_RES, // 版本更新文件下载响应
    DOWNLOADSUCCESSFULLY_RES        // 更新文件下载成功的响应
    //日志
    LOGSEARCH_REQ;//日志查询请求
   LOGSEARCH_RES;//日志查询响应
   //生产计划管理
   ADD_PDPLAN_REQ,//添加一条生产计划的请求结构体
   ADD_PDPLAN_RES,//添加一条生产计划的响应结构体
   DEL_PDPLAN_REQ,//删除一条生产计划的请求结构体
   DEL_PDPLAN_RES,//删除一条生产计划的响应结构体
   UPDATE_PDPLAN_REQ,//更改一条生产计划的请求结构体
   UPDATE_PDPLAN_RES,//更改一条生产计划的响应结构体
   QUERY_PDPLAN_REQ,//查询一条生产计划的请求结构体
   QUERY_PDPLAN_RES,//查询一条生产计划的响应结构体
   ADD_MONOUTPUT_REQ,//添加月产量的请求结构体
   ADD_MONOUTPUT_RES,//添加月产量的响应结构体
   DEL_MONOUTPUT_REQ,//删除月产量的请求结构体
   DEL_MONOUTPUT_RES,//删除月产量的响应结构体
   UPDATE_MONOUTPUT_REQ,//更新月产量的请求结构体
   UPDATE_MONOUTPUT_RES,//更新月产量的响应结构体
   QUERY_MONOUTPUT_REQ,//查询月产量的请求结构体
   QUERY_MONOUTPUT_RES,//查询月产量的响应结构体
   //自动升级
   VERSION_NUM_REQ,  // 版本号请求
   VERSION_NUM_RES,   // 版本号响应
   UPLOAD_FILE_REQ, // 上传文件的请求
   UPLOAD_FILE_RES, // 上传文件的响应
   VERSION_INFOENTRY_REQ,       // 版本信息录入请求
   VERSION_INFOENTRY_RES,       //版本信息录入响应
   VERSION_UPDATE_REQ, // 版本更新请求
   VERSION_UPDATE_RES, // 版本更新响应
   FILE_DOWNLOADS_REQ, // 版本更新文件下载请求
   FILE_DOWNLOADS_RES, // 版本更新文件下载响应
   DOWNLOAD_SUCCESSFULLY_RES,       // 更新文件下载成功的响应
   //日志
   LOGSEARCH_REQ,//日志查询请求
   LOGSEARCH_RES,//日志查询响应
   //历史查询分析
   HISTORY_DEV_REQ,        //历史查询硬件请求
   HISTORY_DEV_RES,        //历史查询硬件响应
   HISTORY_PRODUCE_REQ,    //历史查询生产请求
   HISTORY_PRODUCE_RES,    //历史查询生产响应
   HISTORY_ENV_REQ,    //历史查询环境请求
   HISTORY_ENV_RES,    //历史查询环境响应
};
struct Head{
    int type;
    int len;
struct Head {
   int type;
   int len;
};
//注册登录
//登录请求 
   struct LoginReq
   {
      Head head;
      char user_name[32];
      char password[32];
      LoginReq(){
         head.type = LOGIN_REQ;
         head.len = sizeof(LoginReq);
      }
   };
   struct Permission
   {
      int admin;
      int log_search; //日志查询
      int history; //历史记录
      int map_change;//地图
      int version_manage; // 版本管理
      int warning; //警报
      int device_manage; //设备管理
      int pro_plan;//生产计划
      char role_name[32]; // 角色名
   };
   //登录响应
   struct LoginRes
   {
      Head head;
      char user_name[32];
      int status; // 登录状态
      // 登录成功时,该账号对应的权限组合
      Permission per;
      LoginRes()
      {
         head.type = LOGIN_RES;
         head.len = sizeof(LoginRes);
      };
   };
   //注册请求
   struct RegisterReq
   {
      Head head;
      char user_name[32];
      char password[32];
      char email[50];
      int telephone;
      RegisterReq(){
         head.type = REGISTER_REQ;
         head.len = sizeof(RegisterReq);
      }
   };
   //注册响应
   struct RegisterRes
   {
      Head head;
      char user_name[32];
      int status; // 注册状态
      //注册成功,默认最小权限组合
      Permission per;
      RegisterRes()
      {
         head.type = REGISTER_RES;
         head.len = sizeof(RegisterRes);
      };
   };
   //重置密码请求
   struct ResetReq
   {
      Head head;
      char email[50];
      char password[32];
      ResetReq(){
         head.type = RESET_REQ;
         head.len = sizeof(ResetReq);
      }
   };
   //重置密码响应
   struct ResetRes
   {
      Head head;
      char user_name[32];
      int status; // 重置密码状态
      ResetRes()
      {
         head.type = RESET_RES;
         head.len = sizeof(ResetRes);
      };
   };
// 历史查询请求结构体
struct HistoryQueryReq {
    Head head;
    //根据时间范围查询
    char start_time[32];
    char end_time[32];
    HistoryQueryReq() {
        // 初始化数据头
        head.type = HISTORY_QUERY_REQ;
        head.len = sizeof(HistoryQueryReq);
        // 初始化查询条件字段
        std::memset(start_time, 0, sizeof(start_time));
        std::memset(end_time, 0, sizeof(end_time));
    }
struct LoginReq
{
   Head head;
   char userName[32];
   char password[32];
   LoginReq() {
      head.type = LOGIN_REQ;
      head.len = sizeof(LoginReq);
   }
};
// 历史查询响应结构体
struct HistoryQueryRes {
    Head head;
    char results[1024][32];
    int result_count;
    HistoryQueryRes() {
        // 初始化数据头
        head.type = HISTORY_QUERY_RES;
        head.len = sizeof(HistoryQueryRes);
        // 初始化结果相关字段
        result_count = 0;
        std::memset(results, 0, sizeof(results));
    }
struct Permission
{
   int admin;//超级管理员
   int loggerSearch; //日志查询
   int queryHistory; //历史记录
   int mapMark;//地图
   int versionManage; // 版本管理
   int warning; //警报
   int devManage; //设备管理
   int productPlan;//生产计划
   char roleName[32]; // 角色名
};
//登录响应
struct LoginRes
{
   Head head;
   char userName[32];
   int status; // 登录状态
   // 登录成功时,该账号对应的权限组合
   Permission per;
   LoginRes()
   {
      head.type = LOGIN_RES;
      head.len = sizeof(LoginRes);
   }
};
//注册请求
struct RegisterReq
{
   Head head;
   char userName[32];
   char password[32];
   char email[50];
   char capcha[10];//验证码
   char telephone[32];
   RegisterReq() {
      head.type = REGISTER_REQ;
      head.len = sizeof(RegisterReq);
   }
};
//注册响应
struct RegisterRes
{
   Head head;
   char userName[32];
   int status; // 注册状态
   RegisterRes()
   {
      head.type = REGISTER_RES;
      head.len = sizeof(RegisterRes);
   }
};
//重置密码请求
struct ResetReq
{
   Head head;
   char email[50];
   char capcha[10];//验证码
   char password[32];//新密码
   char confirmPassword[32];//确认密码
   ResetReq() {
      head.type = RESET_REQ;
      head.len = sizeof(ResetReq);
   }
};
//重置密码响应
struct ResetRes
{
   Head head;
   char user_name[32];
   int status; // 重置密码状态
   ResetRes()
   {
      head.type = RESET_RES;
      head.len = sizeof(ResetRes);
   }
};
//权限管理
// 按员工编号、名字或职位查询人员权限信息请求
typedef struct QueryPmsRequest{
    Head head;
    char userNo[32];
    char name[32];
    char permissonType[32];
    QueryPmsRequest(){
        head.type=QUERY_PMS_REQ;
        userNo[32] = {0};
        name[32] = {0};
        permissonType[32] = {0};
        head.len = sizeof(QueryPmsRequest);
    }
} QueryPmsRequest;
typedef struct QueryPmsReq {
   Head head;
   char userNo[32];
   char name[32];
   char permissonType[32];
   QueryPmsReq() {
      head.type = QUERY_PMS_REQ;
      memset(userNo, 0, 32);
      memset(permissonType, 0, 32);
      memset(name, 0, 32);
      head.len = sizeof(QueryPmsReq);
   }
} QueryPmsReq;
// 按角色id更新权限信息请求
typedef struct UpdatePmsRequest{
    Head head;
    int roleId;
    int queryHistory;
    int loggerSearch;
    int mapMark;
    int devManage;
    int productPlan;
    UpdatePmsRequest(){
        head.type=QUERY_PMS_RES;
        head.len = sizeof(UpdatePmsRequest);
    }
} UpdatePmsRequest;
typedef struct UpdatePmsReq {
   Head head;
   // 人员表主键id
   int id;
   int queryHistory;
   int loggerSearch;
   int mapMark;
   int devManage;
   int productPlan;
   int warningManage;
   int versionManage; //版本管理
   int admin; //系统管理员
   UpdatePmsReq() {
      head.type = QUERY_PMS_RES;
      head.len = sizeof(UpdatePmsReq);
   }
} UpdatePmsReq;
// 单个人员权限结构体
typedef struct UserAboutPms{
// 单个人员和权限联合查询结构体
typedef struct PmsRes {
   int queryHistory;
   int loggerSearch;
   int mapMark;
   int devManage;
   int productPlan;
   int id;
    int queryHistory;
    int loggerSearch;
    int mapMark;
    int devManage;
    int productPlan;
    int roleId;
    char userNo[32];
    char name[32];
    char permissonType[32];
    char startDateTime[32];
    char endDateTime[32];
   char userNo[32];
   char name[32];
   char permissonType[32];  // 角色类型
   int versionManage; //版本管理
   int admin; //系统管理员
   char department[32];
   char loginTime[32];
   char registerTime[32];
} PmsRes;
// 查询人员和角色信息的响应结构体
typedef struct UserAboutPmsResponse{
    Head head;
    int success; // 1为成功 ,0为失败
    PmsRes pmsList[100];
    UserAboutPmsResponse(){
        head.type=QUERY_PMS_RES;
        head.len = sizeof(UserAboutPmsResponse);
    }
} QueryPmsResponse;
typedef struct QueryPmsRes {
   Head head;
   int success; // 1为成功 ,0为失败
   PmsRes pmsList[0];
   QueryPmsRes() {
      head.type = QUERY_PMS_REQ;
   }
} QueryPmsRes;
// 权限更新结果响应体
typedef struct UpdatePmsResponse{
    Head head;
    int success; // 1为成功 ,0为失败
    UpdatePmsResponse(){
        head.type = UPDATE_PMS_RES;
        head.len = sizeof(UpdatePmsResponse);
    }
struct UpdatePmsRes {
   Head head;
   int success; // 1为成功 ,0为失败
   UpdatePmsRes() {
      head.type = UPDATE_PMS_RES;
      head.len = sizeof(UpdatePmsRes);
   }
} UpdatePmsResponse ;
} UpdatePmsRes;
//地图标注请求
struct MapMarkReq
//设备管理
struct DevicesInfo
{
   char deviceName[32];//设备名称
   char deviceStatus[32];//设备状态
    char area[32]; // 地区
    double longitude;//经度
    double latitude;//纬度
    char purchasingTime[15];//购买时间
    char installTime[15];//安装时间
   char manufacturer[100];//厂家
    char devicesSerialNumber[32];//设备编码
   char devicesType[32];//设备类型
};
//添加设备
struct ADReq//添加请求
{
   Head head;
   int marktype;//插入、删除、
   char msg[0];//柔性数组
      LoginReq(){
      head.type = MAPMARK_REQ;
      head.len = sizeof(MapMarkReq);
   DevicesInfo devInfo[0];
   ADReq() {
      head.type = AD_REQ;
      head.len = sizeof(ADReq);
   }
};
struct ADRes//添加响应
{
   Head head;
   int status;
   ADRes() {
      head.type = AD_RES;
      head.len = sizeof(ADRes);
   }
};
//修改设备
struct MDReq//修改请求
{
   Head head;
   DevicesInfo info;
   MDReq() {
      head.type = MD_REQ;
      head.len = sizeof(MDReq);
   }
};
//地图响应:
struct MarkInfo
{
   int mark_id;//标注点id
   string latitude;//纬度
   string longitude;//经度
   int device_id;//设备ID
   int device_status;//设备状态
   string device_name;//设备名称
};
struct MapMarkRes  ////地图标注响应
struct MDRes//修改响应
{
   Head head;
   int marktype;//插入还是删除
   int status; // 操作状态_成功/失败
   MaskInfo info[0];//柔性数组
   MapMarkRes()
   {
      head.type = MAPMARK_RES;
      head.len = sizeof(MapMarkRes);
   };
   DevicesInfo info;
   int status;
   MDRes() {
      head.type = MD_RES;
      head.len = sizeof(MDRes);
   }
};
//查询设备
struct QDReq//查询请求
{
   Head head;
   DevicesInfo info;
   QDReq() {
      head.type = QD_REQ;
      head.len = sizeof(QDReq);
   }
};
struct QDRes//查询响应
{
   Head head;
   int status;
   DevicesInfo info[0];
   QDRes() {
      head.type = QD_RES;
      head.len = sizeof(QDRes);
   }
};
//地图标注
struct MarkInfo
{
   int markId;//标注点id
   double latitude;//纬度
   double longitude;//经度
   int deviceId;//设备ID
   int deviceStatus;//设备状态
   char deviceName[32];//设备名称
};
//地图标注加载请求
struct MMLReq//地图
{
   Head head;
   MMLReq() {
      head.type = MML_REQ;
      head.len = sizeof(MMLReq);
   }
};
//地图标注加载响应:
struct MMLRes
{
   Head head;
   int status;//操作状态
   MarkInfo info[0];
   MMLRes() {
      head.type = MML_RES;
      head.len = sizeof(MMLRes);
   }
};
//地图标注插入请求
struct MMIReq//地图
{
   Head head;
   MarkInfo info[0];
   MMIReq() {
      head.type = MMI_REQ;
      head.len = sizeof(MMIReq);
   }
};
//地图标注插入响应:
struct MMIRes
{
   Head head;
   int status;//操作状态
   MarkInfo info[0];
   MMIRes() {
      head.type = MMI_RES;
      head.len = sizeof(MMIRes);
   }
};
//地图标注删除请求
struct MMDReq//地图
{
   Head head;
   MarkInfo info[0];
   MMDReq() {
      head.type = MMD_REQ;
      head.len = sizeof(MMDReq);
   }
};
//地图标注删除响应:
struct MMDRes
{
   Head head;
   int status;//操作状态
   MarkInfo info[0];
   MMDRes() {
      head.type = MMD_RES;
      head.len = sizeof(MMDRes);
   }
};
//大屏显示
//环境数据请求
struct EnvironmentReq
{
    Head head;
    float temp;//温度
    float humidity;//湿度
    float oxygen;//氧气浓度
    float carbon;//一氧化碳浓度
        EnvironmentReq(){
        head.type = ENVIRONMENT_REQ;
        head.len = sizeof(EnvironmentReq);
    }
   Head head;
   EnvironmentReq() {
      head.type = ENVIRONMENT_REQ;
      head.len = sizeof(EnvironmentReq);
   }
};
//环境数据响应
struct Environment
{
   double longitude;//经度
   double latitude;//纬度
   float temp;//温度
   float humidity;//湿度
   float oxygen;//氧气浓度
   float carbon;//一氧化碳浓度
};
struct EnvironmentRes
{
   Head head;
   int status;
   Environment environment[0];
   EnvironmentRes() {
      head.type = ENVIRONMENT_RES;
      head.len = sizeof(EnvironmentRes);
   }
};
//设备状态请求
struct DeviceStatusReq
{
    Head head;
    int device_ID;//设备编号
    char device_Name[32];//设备名称
    char device_Status[32];//设备状态
        DeviceStatusReq(){
        head.type = DEVICESTATUS_REQ;
        head.len = sizeof(DeviceStatusReq);
    }
   Head head;
   DeviceStatusReq() {
      head.type = DEVICESTATUS_REQ;
      head.len = sizeof(DeviceStatusReq);
   }
};
//设备状态响应
struct DeviceStatus
{
   double longitude;//经度
   double latitude;//纬度
   int deviceID;//设备编号
   char deviceName[32];//设备名称
   char deviceStatus[32];//设备状态
};
struct DeviceStatusRes
{
   Head head;
   int status;
   DeviceStatus deviceStatus[0];
   DeviceStatusRes() {
      head.type = DEVICESTATUS_RES;
      head.len = sizeof(DeviceStatusRes);
   }
};
//操作日志请求
struct MovementRecordReq
{
    Head head;
    char user_Name;//操作用户名
    char alarm_Time[32];//操作时间
    char device_Name[32];//操作设备
    char movement[256];//操作描述
        MovementRecordReq(){
        head.type = MOVEMENTRECORD_REQ;
        head.len = sizeof(MovementRecordReq);
    }
   Head head;
   MovementRecordReq() {
      head.type = MOVEMENTRECORD_REQ;
      head.len = sizeof(MovementRecordReq);
   }
};
//操作日志响应
struct MovementRecord
{
   double longitude;//经度
   double latitude;//纬度
   char userName;//操作用户名
   char operateTime[32];//操作时间
   char deviceName[32];//操作设备
   char movement[256];//操作描述
};
struct MovementRecordRes
{
   Head head;
   int status;
   MovementRecord movementRecord[0];
   MovementRecordRes() {
      head.type = MOVEMENTRECORD_RES;
      head.len = sizeof(MovementRecordRes);
   }
};
//警报记录请求
struct AlarmRecordReq
{
    Head head;
    char alarm_Time[32];//警报时间
    char alarm_type[32];//解决时间
    char alarm_Content[256];//警报内容
        AlarmRecordReq(){
        head.type = ALARMRECORD_REQ;
        head.len = sizeof(AlarmRecordReq);
    }
   Head head;
   AlarmRecordReq() {
      head.type = ALARMRECORD_REQ;
      head.len = sizeof(AlarmRecordReq);
   }
};
//警报记录响应
struct AlarmRecord
{
   double longitude;//经度
   double latitude;//纬度
   char alarmTime[32];//警报时间
   char alarmtype[32];//处理时间
   char alarmContent[256];//警报内容
};
struct AlarmRecordRes
{
   Head head;
   int status;
   AlarmRecord alarmRecord[0];
   AlarmRecordRes() {
      head.type = ALARMRECORD_RES;
      head.len = sizeof(AlarmRecordRes);
   }
};
//煤矿产量请求
struct YieldReq
{
   Head head;
   YieldReq() {
      head.type = YIELD_REQ;
      head.len = sizeof(YieldReq);
   }
};
//煤矿产量响应
struct Yield
{
   int month;//月份
   int output;//产量
};
struct YieldRes
{
   Head head;
   int status;
   Yield yield[0];
   YieldRes() {
      head.type = YIELD_RES;
      head.len = sizeof(YieldRes);
   }
};
//警报管理
struct warningInfo {
    char device_name[32];//设备名称
    char des[32];//警报描述
    char time[32];//警报时间
    float warningdata;//警报数据
    char type[16];//警报类型
    char status[16];//警报状态
};
struct dataInfo {
    char device_name[32];
    char type[16];//环境数据类型
    float data;
    char time[32];//上传数据时间
};
struct threshInfo {
    char device_name[32];
    char type[16];//环境类型
    float min;//最小阈值
    float max;//最大阈值
    char time[32];//阈值修改时间
};
//警报请求结构体
struct WarningReq {
    Head head;
    int month;//月份
    int yield;//产量
        YieldReq(){
        head.type = YIELD_REQ;
        head.len = sizeof(YieldReq);
    warningInfo info[0];
    WarningReq() {
        head.type = WARNING_REQ;
        head.len = sizeof(WarningReq);
    }
};
//添加一行数据的请求结构体
struct AddProductionPlanReq {
   Head head;
   int type;
   char productionDate[32];
   int productionQuantity;
   int plannedProductionQuantity;
   int predictedProductionQuantity;
   char logText[256];
   AddProductionPlanReq() {
      head.type = ADDPRODUCTIONPLAN_REQ;
      head.len = sizeof(AddProductionPlanReq);
   }
//数据请求结构体
struct DataReq {
    Head head;
    dataInfo Info[0];
    DataReq() {
        head.type = DATA_REQ;
        head.len = sizeof(DataReq);
    }
};
//添加一行数据的响应结构体
struct AddProductionPlanRes {
//阈值请求结构体
struct ThresholdReq {
    Head head;
    threshInfo threInfo[0];
    ThresholdReq() {
        head.type = THRESHOLD_REQ;
        head.len = sizeof(ThresholdReq);
    }
};
//警报响应结构体
struct WarningRes {
    Head head;
    int status;// 响应状态
    warningInfo warninginfo[0];
    WarningRes() {
        head.type = WARNING_RES;
        head.len = sizeof(WarningRes);
    }
};
struct DataRes {
    Head head;
    int status;// 响应状态
    dataInfo datainfo[0];
    DataRes() {
        head.type = DATA_RES;
        head.len = sizeof(DataRes);
    }
};
struct ThresholdRes {
    Head head;
    int status;// 响应状态
    threshInfo threInfo[0];
    ThresholdRes() {
        head.type = THRESHOLD_RES;
        head.len = sizeof(ThresholdRes);
    }
};
//生产计划管理
struct PdplanInfo
{
   int planId;//订单编号
   char planName[32];//订单名字
   char startDate[32];//起始日期
   char closingDate[32];//交付日期
   char pdName[8];//产品名
   double plannedPd;//计划生产量
   double actualPd;//实际生产量
   double progress;//生产进度
   int finishOntime;//是否按期完成
};
struct MonoutputInfo
{
   int month;//月份
   double aOutput;//a产品月产量
   double bOutput;//b产品月产量
   double cOutput;//c产品月产量
};
//添加一条生产计划的请求结构体
struct AddPdplanReq
{
   Head head;
   int type;
   int status; // 可以表示添加是否成功, 0 表示失败,1 表示成功
   AddProductionPlanRes() {
      head.type = ADDPRODUCTIONPLAN_RES;
      head.len = sizeof(AddProductionPlanRes);
   PdplanInfo info[0];
   AddPdplanReq() {
      head.type = ADD_PDPLAN_REQ;
      head.len = sizeof(AddPdplanReq);
   }
};
// 更新生产计划(计划生产量)的请求结构体
struct UpdateProductionPlanQuantityReq {
//添加一条生产计划的响应结构体
struct AddPdplanRes
{
   Head head;
   int type;
   int plannedProductionQuantity;
   char productionDate[32];
   UpdateProductionPlanQuantityReq() {
      head.type = UPDATEPRODUCTIONPLANQUANTITY_REQ;
      head.len = sizeof(UpdateProductionPlanQuantityReq);
   int status;//表示是否添加成功,0否1是
   AddPdplanRes() {
      head.type = ADD_PDPLAN_RES;
      head.len = sizeof(AddPdplanRes);
   }
};
// 更新生产计划(计划生产量)的响应结构体
struct UpdateProductionPlanQuantityRes {
//删除一条生产计划的请求结构体
struct DelPdplanReq
{
   Head head;
   int type;
   int status; // 可以表示更新是否成功,例如 0 表示失败,1 表示成功
   UpdateProductionPlanQuantityRes() {
      head.type = UPDATEPRODUCTIONPLANQUANTITY_RES;
      head.len = sizeof(UpdateProductionPlanQuantityRes);
   PdplanInfo info[0];
   DelPdplanReq() {
      head.type = DEL_PDPLAN_REQ;
      head.len = sizeof(DelPdplanReq);
   }
};
//删除一条生产计划的响应结构体
struct DelPdplanRes
{
   Head head;
   int status;//表示是否删除成功,0否1是
   DelPdplanRes() {
      head.type = DEL_PDPLAN_RES;
      head.len = sizeof(DelPdplanRes);
   }
};
//更改一条生产计划的请求结构体.
struct UpdatePdplanReq
{
   Head head;
   PdplanInfo info[0];
   UpdatePdplanReq() {
      head.type = UPDATE_PDPLAN_REQ;
      head.len = sizeof(UpdatePdplanReq);
   }
};
//更改一条生产计划的响应结构体
struct UpdatePdplanRes
{
   Head head;
   int status;//表示是否更新成功,0否1是
   PdplanInfo info[0];
   UpdatePdplanRes() {
      head.type = UPDATE_PDPLAN_RES;
      head.len = sizeof(UpdatePdplanRes);
   }
};
//查询一条生产计划的请求结构体
struct QueryPdplanReq
{
   Head head;
   int planId;//订单编号
   char planName[32];//订单划名字
   char startDate[32];//起始日期
   char closingDate[32];//交付日期
   char pdName[8];//产品名
   double plannedPd;//计划生产量
   double actualPd;//实际生产量
   double progress;//生产进度
   int finishOntime;//是否按期完成
   QueryPdplanReq() {
      head.type = QUERY_PDPLAN_REQ;
      head.len = sizeof(QueryPdplanReq);
   }
};
//查询一条生产计划的响应结构体
struct QueryPdplanRes
{
   Head head;
   int status;//表示是否添加成功,0否1是
   PdplanInfo info[0];
   QueryPdplanRes() {
      head.type = QUERY_PDPLAN_RES;
      head.len = sizeof(QueryPdplanRes);
   }
};
// 更新生产计划(日志)的请求结构体
struct UpdateProductionPlanLogReq {
//添加月产量的请求结构体
struct AddMonoutputReq
{
   Head head;
   int type;
   char logText[256];
   char productionDate[32];
   UpdateProductionPlanLogReq() {
      head.type = UPDATEPRODUCTIONPLANLOG_REQ;
      head.len = sizeof(UpdateProductionPlanLogReq);
   MonoutputInfo info[0];
   AddMonoutputReq() {
      head.type = ADD_MONOUTPUT_REQ;
      head.len = sizeof(AddMonoutputReq);
   }
};
// 更新生产计划请求(日志)的响应结构体
struct UpdateProductionPlanLogRes {
//添加月产量的响应结构体
struct AddMonoutputRes
{
   Head head;
   int type;
   int status; // 可以表示更新是否成功,例如 0 表示失败,1 表示成功
   UpdateProductionPlanLogRes() {
      head.type = UPDATEPRODUCTIONPLANLOG_RES;
      head.len = sizeof(UpdateProductionPlanLogRes);
   int status;//表示是否添加成功,0否1是
   AddMonoutputRes() {
      head.type = ADD_MONOUTPUT_RES;
      head.len = sizeof(AddMonoutputRes);
   }
};
//删除月产量的请求结构体
struct DelMonoutputReq
{
   Head head;
   MonoutputInfo info[0];
   DelMonoutputReq() {
      head.type = DEL_MONOUTPUT_REQ;
      head.len = sizeof(DelMonoutputReq);
   }
};
//删除月产量的响应结构体
struct DelMonoutputRes
{
   Head head;
   int status;//表示是否删除成功,0否1是
   DelMonoutputRes() {
      head.type = DEL_MONOUTPUT_RES;
      head.len = sizeof(DelMonoutputRes);
   }
};
//更改月产量的请求结构体.
struct UpdateMonoutputReq
{
   Head head;
   MonoutputInfo info[0];
   UpdateMonoutputReq() {
      head.type = UPDATE_MONOUTPUT_REQ;
      head.len = sizeof(UpdateMonoutputReq);
   }
};
//更改月产量的响应结构体
struct UpdateMonoutputRes
{
   Head head;
   int status;//表示是否更新成功,0否1是
   MonoutputInfo info[0];
   UpdateMonoutputRes() {
      head.type = UPDATE_MONOUTPUT_RES;
      head.len = sizeof(UpdateMonoutputRes);
   }
};
//查询月产量的请求结构体
struct QueryMonoutputReq
{
   Head head;
   int month;//月份
   double aOutput;//a产品月产量
   double bOutput;//b产品月产量
   double cOutput;//c产品月产量
   QueryMonoutputReq() {
      head.type = QUERY_MONOUTPUT_REQ;
      head.len = sizeof(QueryMonoutputReq);
   }
};
//查询月产量的响应结构体
struct QueryMonoutputRes
{
   Head head;
   int status;//表示是否添加成功,0否1是
   MonoutputInfo info[0];
   QueryMonoutputRes() {
      head.type = QUERY_MONOUTPUT_RES;
      head.len = sizeof(QueryMonoutputRes);
   }
};
// 查询生产计划信息请求
struct ProductionPlanReq {
//历史查询分析
//历史查询分析
struct warningInfo {
   int device_id;
   char des[32];
   char time[32];
   float data;
   char type[16];
   char status[16];
};
// 历史查询设备信息请求结构体
struct HistoryDevReq {
   Head head;
   int type;
   int len;
   char productionDate[32];
   int productionQuantity;
   int plannedProductionQuantity;
   int predictedProductionQuantity;
   char logText[256];
   ProductionPlanReq() {
      head.type = PRODUCTIONPLAN_REQ;
      head.len = sizeof(ProductionPlanReq);
   //根据时间范围查询
   char startTime[32];
   char endTime[32];
   //关键字查询
   char keyWord[32];
   HistoryDevReq() {
      // 初始化数据头
      head.type = HISTORY_DEV_REQ;
      head.len = sizeof(HISTORY_DEV_REQ);
      // 初始化查询条件字段
   }
};
// 查询生产计划信息的响应结构体
struct ProductionPlanRes {
// 历史查询生产计划请求结构体
struct HistoryProReq {
   Head head;
   int type;
   int len;
   int productionQuantity;
   int plannedProductionQuantity;
   int predictedProductionQuantity;
   int roleId;
   char productionDate[32];
   char logText[256];
   ProductionPlanRes() {
      head.type = PRODUCTIONPLAN_REQ;
      head.len = sizeof(ProductionPlanRes);
   //根据时间范围查询
   char startTime[32];
   char endTime[32];
   //关键字查询
   char keyWord[32];
   HistoryProReq() {
      // 初始化数据头
      head.type = HISTORY_PRODUCE_REQ;
      head.len = sizeof(HistoryProReq);
      // 初始化查询条件字段
   }
};
// 历史查询环境信息请求结构体
struct HistoryEnvReq {
   Head head;
   //根据时间范围查询
   char startTime[32];
   char endTime[32];
   //关键字查询
   char keyWord[32];
   HistoryEnvReq() {
      // 初始化数据头
      head.type = HISTORY_ENV_REQ;
      head.len = sizeof(HistoryEnvReq);
      // 初始化查询条件字段
   }
};
//查询设备信息响应结构体
struct HistoryDevRes {
   Head head;
   DevicesInfo dev[0];
   HistoryDevRes() {
      // 初始化数据头
      head.type = HISTORY_DEV_RES;
      head.len = sizeof(HistoryDevRes);
   }
};
//查询生产计划响应结构体
struct HistoryProRes {
   Head head;
   PdplanInfo pro[0];
   HistoryProRes() {
      // 初始化数据头
      head.type = HISTORY_PRODUCE_RES;
      head.len = sizeof(HistoryProRes);
   }
};
//查询环境信息响应结构体
struct HistoryEnvRes {
   Head head;
   warningInfo env[0];
   HistoryEnvRes() {
      // 初始化数据头
      head.type = HISTORY_ENV_RES;
      head.len = sizeof(HistoryEnvRes);
   }
};
//查询近十四条的请求结构体
struct RecentFourteenProductionPlansReq {
   Head head;
   int requestType;
   RecentFourteenProductionPlansReq() {
      head.type = RECENTFOURTEENPRODUCTIONPLANS_REQ;
      head.len = sizeof(RecentFourteenProductionPlansReq);
   }
};
//查询近十四条的响应结构体
struct RecentFourteenProductionPlansRes {
   Head head;
   int responseType;
   int responseLength;
   int productionQuantities[14];
   int plannedProductionQuantities[14];
   int predictedProductionQuantities[14];
   int roleIds[14];
   char productionDates[14][32];
   char logTexts[14][256];
   RecentFourteenProductionPlansRes() {
      head.type = UPDATEPRODUCTIONPLANQUANTITY_REQ;
      head.len = sizeof(RecentFourteenProductionPlansRes);
   }
};
//自动升级
struct VersionNumReq        // 版本号请求
{
   Head head;
   VersionNumReq() {
      head.type = VERSIONNUM_REQ;
      head.type = VERSION_NUM_REQ;
      head.len = sizeof(VersionNumReq);
   }
};
@@ -520,9 +991,9 @@
struct VersionNumRes        // 版本号响应
{
   Head head;
   char version_id[64]; // 版本号
   char versionId[64]; // 版本号
   VersionNumRes() {
      head.type = VERSIONNUM_RES;
      head.type = VERSION_NUM_RES;
      head.len = sizeof(VersionNumRes);
   }
};
@@ -530,9 +1001,9 @@
// 文件传输
struct FileInfo
{
   char file_name[256];
   long long file_size;
    char s_filepath[128];
   char fileName[256];
   long long fileSize;
   char s_filepath[128];
   char content[0];
};
@@ -547,165 +1018,151 @@
};
struct UploadFileRes {      // 上传文件的响应
    Head head;
    bool state = false;
    char file_name[256];
    long long file_size;
    UploadFileRes()
    {
        head.type = UPLOAD_FILE_RES;
        head.len = sizeof(UploadFileRes);
    }
   Head head;
   bool state = false;
   char fileName[256];
   long long file_size;
   UploadFileRes()
   {
      head.type = UPLOAD_FILE_RES;
      head.len = sizeof(UploadFileRes);
   }
};
// 版本信息录入
// 请求
struct VersionInfoEntryReq {
    Head head;
    char version_id[64]; // 版本号
    char version_id_old[64]; // 上一个版本号
    char s_filepath[16][128];   //服务器放最新版本的路径
    char version_description[256]; //更新内容
    char version_creattime[32]; // 更新时间
    char filename[16][128];
    long long filesize[16];
    char c_filepath[16][128];
    int fileNum;
   Head head;
   char versionId[64]; // 版本号
   char versionIdOld[64]; // 上一个版本号
   int fileNum;
   char context[0];      //包含下载文件信息
    VersionInfoEntryReq()
    {
        head.type = VERSIONINFOENTRY_REQ;
        head.len = sizeof(VersionInfoEntryReq);
    }
   VersionInfoEntryReq()
   {
      head.type = VERSION_INFOENTRY_REQ;
      head.len = sizeof(VersionInfoEntryReq);
   }
};
// 版本信息录入响应
struct VersionInfoEntryRes {
    Head head;
    bool state = false;
    VersionInfoEntryRes()
    {
        head.type = VERSIONINFOENTRY_RES;
        head.len = sizeof(VersionInfoEntryRes);
    }
   Head head;
   bool state = false;
   VersionInfoEntryRes()
   {
      head.type = VERSION_INFOENTRY_RES;
      head.len = sizeof(VersionInfoEntryRes);
   }
};
// 版本更新请求
struct VersionUpdateReq {
    Head head;
   Head head;
    char cur_version_id[64]; // 版本号
    VersionUpdateReq()
    {
        head.type = VERSIONUPDATE_REQ;
        head.len = sizeof(VersionUpdateReq);
    }
   char curVersionId[64]; // 版本号
   VersionUpdateReq()
   {
      head.type = VERSION_UPDATE_REQ;
      head.len = sizeof(VersionUpdateReq);
   }
};
// 版本更新响应
struct VersionUpdateRes {
    Head head;
    bool state = false;
    char version_id[64]; // 版本号
    char update_date[32]; // 更新时间
    char version_description[1024]; //更新描述
   Head head;
   bool state = false;
   char versionId[64]; // 版本号
   char updateDate[32]; // 更新时间
   char versionDescription[1024]; //更新描述
    VersionUpdateRes()
    {
        head.type = VERSIONUPDATE_RES;
        head.len = sizeof(VersionUpdateRes);
    }
   VersionUpdateRes()
   {
      head.type = VERSION_UPDATE_RES;
      head.len = sizeof(VersionUpdateRes);
   }
};
// 版本更新文件下载请求
struct FileDownloadsReq {
    Head head;
    char version_id[64]; // 版本号
    FileDownloadsReq()
    {
        head.type = FILEDOWNLOADS_REQ;
        head.len = sizeof(FileDownloadsReq);
    }
   Head head;
   char versionId[64]; // 版本号
   FileDownloadsReq()
   {
      head.type = FILE_DOWNLOADS_REQ;
      head.len = sizeof(FileDownloadsReq);
   }
};
// 版本更新文件下载响应
struct FileDownloadsRes {
    Head head;
    char version_id[64]; // 版本号
    char filename[128]; //文件名
    long long filesize; //文件大小
    char c_filepath[128];   //客户端放最新版本的本地路径
    int fileNum; // 文件数量
    long long all_fileSize; // 文件总大小
    char content[0];
    FileDownloadsRes()
    {
        head.type = FILEDOWNLOADS_RES;
        head.len = sizeof(FileDownloadsRes);
    }
   Head head;
   char versionId[64]; // 版本号
   char filename[128]; //文件名
   long long filesize; //文件大小
   char c_filepath[128];   //客户端放最新版本的本地路径
   int fileNum; // 文件数量
   long long allFileSize; // 文件总大小
   char content[0];
   FileDownloadsRes()
   {
      head.type = FILE_DOWNLOADS_RES;
      head.len = sizeof(FileDownloadsRes);
   }
};
// 更新文件下载成功的响应
struct DownloadSuccessfullyRes{
    Head head;
    bool state = false;
    char file_name[256];
    long long file_size;
    DownloadSuccessfullyRes()
    {
        head.type = DOWNLOADSUCCESSFULLY_RES;
        head.len = sizeof(DownloadSuccessfullyRes);
    }
struct DownloadSuccessfullyRes {
   Head head;
   bool state = false;
   char fileName[256];
   long long fileSize;
   DownloadSuccessfullyRes()
   {
      head.type = DOWNLOAD_SUCCESSFULLY_RES;
      head.len = sizeof(DownloadSuccessfullyRes);
   }
};
struct LogQueryRequest {
    Head header;                // 数据头
    std::string* keywords;      // 存储多个关键字的柔性数组
    size_t keywordCount;         // 关键字数量
    std::string startDate;       // 开始日期 (格式: YYYY-MM-DD)
    std::string endDate;         // 结束日期 (格式: YYYY-MM-DD)
    int pageNumber;              // 当前页码
    int pageSize;                // 每页条目数
    // 构造函数
    LogQueryRequest(int type, int len, std::string* keywords, size_t keywordCount, const std::string& startDate, const std::string& endDate, int pageNumber, int pageSize)
        : header{type, len}, keywords(keywords), keywordCount(keywordCount), startDate(startDate), endDate(endDate), pageNumber(pageNumber), pageSize(pageSize) {}
    // 析构函数
    ~LogQueryRequest() {
        delete[] keywords; // 释放动态分配的内存
    }
//日志
struct ParsedLog {
   char timeStamp[64]; // 时间戳
   char deviceId[64]; // 设备ID
   char level[16];    // 日志级别
   char content[256];  // 日志内容
   char userId[64];    // 用户ID
   char fileName[32];   //文件名
   char functionName[32];  //函数名
   int problemLine;    //产生错误行号
};
//日志查询响应
// 定义日志条目结构体
struct LogEntry {
    int id;                  // 日志条目 ID
    string entryTime;       // 下井时间
    string name;            // 姓名
    string exitTime;        // 升井时间
    string department;       // 部门
    string position;        // 岗位
    //string workingTime;     // 工作时间 数据库自动生成
      // 构造函数
    LogEntry(int id, const string& entryTime, const string& name,
              const string& exitTime, const string& department,
              const string& position)
        : id(id), entryTime(entryTime), name(name),
          exitTime(exitTime), department(department), position(position) {}
// 日志查询请求结构体
// 日志查询请求结构体
struct LogQueryReq {
   Head head;                      // 数据头
   char timeStamp[64];             // 时间戳
   char content[256];           // 日志内容
   char level[16];                 //日志级别
   char deviceId[64];             // 设备ID
   // 无参构造函数
   LogQueryReq() {
      head.type = LOGSEARCH_REQ;
      head.len = sizeof(LogQueryReq);
   }
};
// 定义日志查询响应结构体
struct LogQueryResponse {
    int status;                    // 响应状态 (如 0 表示成功,非 0 表示失败)
    string errorMessage;           // 错误信息(如果有)
    vector<LogEntry> logEntries;   // 日志条目
// 日志查询响应结构体
struct LogQueryRes {
   Head head;
   int status;                    // 响应状态 (如 0 表示成功,非 0 表示失败)
   char errorMessage[256];        // 错误信息(如果有)
    // 构造函数
    LogQueryResponse(int status, const string& errorMessage, const vector<LogEntry>& logEntries)
        : status(status), errorMessage(errorMessage), logEntries(logEntries) {}
   // 无参构造函数
   LogQueryRes() {
      head.type = LOGSEARCH_RES;
      head.len = sizeof(LogQueryRes);
   }
};