From b40afe63ad506e158185bd110b32bee24932ecff Mon Sep 17 00:00:00 2001 From: lzz <xiguabobo_2020@qq.com> Date: 星期三, 06 十一月 2024 12:13:18 +0800 Subject: [PATCH] Merge branch 'master' of ssh://115.28.86.8:29418/~admin/昆仑_1025 --- Client/姜可庚/code/2024kunlun_project_permisson/2024kunlun_project_permisson.pro.user | 2 Client/姜可庚/log/姜可庚_1106.doc | 0 Client/姜可庚/code/服务端业务代码/common.h | 1064 +++++++++++++++++++++++++++ Client/姜可庚/code/2024kunlun_project_permisson/PmsClientSocket.cpp | 100 +- 表.docx | 0 Client/姜可庚/code/2024kunlun_project_permisson/PmsClientSocket.h | 71 + Client/姜可庚/code/2024kunlun_project_permisson/qcomboxdelegate.cpp | 16 Client/姜可庚/code/服务端业务代码/ServerSocket.cpp | 166 ++++ Client/姜可庚/code/2024kunlun_project_permisson/permissondialog.cpp | 31 Client/冀浩昶/log/日志_冀浩昶_1105.doc | 0 Client/姜可庚/code/2024kunlun_project_permisson/pmsqueryresult.h | 83 + Client/姜可庚/code/服务端业务代码/PermissonManage.h | 16 Client/姜可庚/code/2024kunlun_project_permisson/syncdatatodb.cpp | 52 Client/姜可庚/code/服务端业务代码/PermissonManage.cpp | 152 +++ Client/姜可庚/code/2024kunlun_project_permisson/pmsparam.h | 19 Client/姜可庚/document/权限管理需求分析.docx | 0 Client/姜可庚/code/2024kunlun_project_permisson/pmsplusparam.h | 62 + Client/姜可庚/code/2024kunlun_project_permisson/permissonwindow.h | 4 Client/姜可庚/code/2024kunlun_project_permisson/permissonwindow.cpp | 99 +- common.h | 142 ++- Client/姜可庚/code/2024kunlun_project_permisson/permissondialog.ui | 241 ++++- Client/姜可庚/code/2024kunlun_project_permisson/qcomboxdelegate.h | 6 22 files changed, 2,028 insertions(+), 298 deletions(-) diff --git "a/Client/\345\206\200\346\265\251\346\230\266/log/\346\227\245\345\277\227_\345\206\200\346\265\251\346\230\266_1105.doc" "b/Client/\345\206\200\346\265\251\346\230\266/log/\346\227\245\345\277\227_\345\206\200\346\265\251\346\230\266_1105.doc" new file mode 100644 index 0000000..eb6f7e2 --- /dev/null +++ "b/Client/\345\206\200\346\265\251\346\230\266/log/\346\227\245\345\277\227_\345\206\200\346\265\251\346\230\266_1105.doc" Binary files differ diff --git "a/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/2024kunlun_project_permisson.pro.user" "b/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/2024kunlun_project_permisson.pro.user" index afa3031..7049102 100644 --- "a/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/2024kunlun_project_permisson.pro.user" +++ "b/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/2024kunlun_project_permisson.pro.user" @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE QtCreatorProject> -<!-- Written by QtCreator 4.5.0, 2024-10-31T16:02:45. --> +<!-- Written by QtCreator 4.5.0, 2024-11-04T20:34:52. --> <qtcreator> <data> <variable>EnvironmentId</variable> diff --git "a/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/PmsClientSocket.cpp" "b/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/PmsClientSocket.cpp" index 8449947..aca2755 100644 --- "a/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/PmsClientSocket.cpp" +++ "b/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/PmsClientSocket.cpp" @@ -5,7 +5,7 @@ PmsClientSocket::PmsClientSocket(QWidget * parent):QWidget(parent) { client = new QTcpSocket(this); - + connect(client,SIGNAL(connected()),this,SLOT(connected_Slot())); client->connectToHost(targetIp,port); if(!client->waitForConnected(3000)){ @@ -14,14 +14,12 @@ } connectSuccess = true; qDebug()<< "QT缃戠粶閫氫俊鎴愬姛宸茶繛鎺ユ湇鍔″櫒锛�"; - connect(client,SIGNAL(connected()),this,SLOT(connected_Slot())); - } void PmsClientSocket::queryAllUserAboutUser() { if(connectSuccess){ - QueryPmsRequest req; + QueryPmsReq req; client->write((char *)&req,req.head.len); qDebug() << "鏌ヨ鍏ㄩ儴鏉冮檺璇锋眰鍙戦�佹垚鍔�"; } @@ -30,10 +28,10 @@ void PmsClientSocket::queryPmsByParam(PmsParam param) { if(connectSuccess){ - QueryPmsRequest req; - strcpy(req.name,param.getName().c_str()); - strcpy(req.permissonType,param.getPermissonType().c_str()); - strcpy(req.userNo,param.getUserNo().c_str()); + QueryPmsReq req; + strcpy(req.name,param.getName().toLocal8Bit().data()); + strcpy(req.permissonType,param.getPermissonType().toLocal8Bit().data()); + strcpy(req.userNo,param.getUserNo().toLocal8Bit().data()); client->write((char *)&req,req.head.len); qDebug() << "鏉′欢鏌ヨ鏉冮檺璇锋眰鍙戦�佹垚鍔�"; } @@ -41,12 +39,23 @@ void PmsClientSocket::updatePmsByParam(PmsPlusParma param) { - UpdatePmsRequest upReq; - upReq.devManage = param.getDevManage(); - upReq.loggerSearch = param.getLoggerSearch(); - upReq.mapMark = param.getMapMark(); - upReq.productPlan = param.getProductPlan(); - upReq.roleId = param.getRoleId(); + UpdatePmsReq upReq; + + upReq.id = param.getId(); + if(param.getPermissonType().isEmpty()){ + upReq.devManage = param.getDevManage(); + upReq.loggerSearch = param.getLoggerSearch(); + upReq.mapMark = param.getMapMark(); + upReq.productPlan = param.getProductPlan(); + upReq.warningManage = param.getWarninManage(); + upReq.versionManage = param.getVersionManage(); + upReq.admin = param.getAdmin(); + upReq.queryHistory = param.getQueryHistory(); + + memset(upReq.permissonType,0,32); + }else { + strcpy(upReq.permissonType,param.getPermissonType().toLocal8Bit().data()); + } client->write((char *)&upReq,upReq.head.len); qDebug() << "鏇存柊鏉冮檺璇锋眰鍙戦�佹垚鍔�"; } @@ -59,40 +68,45 @@ void PmsClientSocket::readyRead_Slot() { QByteArray buf = client->readAll(); - QString recvData = QString::fromLocal8Bit(buf); - qDebug()<< "client鏀跺埌鐨勬暟鎹�" << recvData; - QueryPmsResponse * res; - UpdatePmsResponse * upRes; - int type = *(int *)buf.data(); - if(type == QUERY_PMS_REQ){ - res = (QueryPmsResponse *)buf.data(); + qDebug()<< "client鏀跺埌浜嗙殑鏁版嵁"; + QueryPmsRes * res; + UpdatePmsRes * upRes; + Head head = *(Head *)buf.data(); + if(head.type == QUERY_PMS_RES){ + qDebug()<< "鏌ヨ鍝嶅簲"; + res = (QueryPmsRes *)buf.data(); if(res->success){ vector<PmsQueryResult> vecs; - int pmsLen = res->head.len-sizeof(QueryPmsResponse); - for(int i =0;i<pmsLen;i+=sizeof(PmsRes)){ - PmsRes structRes = *(PmsRes*)(res + sizeof(QueryPmsResponse) + i*sizeof(PmsRes)); - PmsQueryResult res; - res.setName(string(structRes.name)); - res.setUserNo(string(structRes.userNo)); - res.setRoleId(structRes.roleId); - res.setStartDateTime(string(structRes.startDateTime)); - res.setEndDateTime(string(structRes.endDateTime)); - res.setLoggerSearch(structRes.loggerSearch); - res.setMapMark(structRes.mapMark); - res.setDevManage(structRes.devManage); - res.setProductPlan(structRes.productPlan); - res.setQueryHistory(structRes.queryHistory); - res.setPermissonType(string(structRes.permissonType)); - vecs.push_back(res); + int pmsLen = (res->head.len-sizeof(QueryPmsRes))/sizeof(PmsRes); + for(int i =0;i<pmsLen;i++){ + PmsRes structRes = res->pmsList[i]; + PmsQueryResult qres; + qres.setName(QString::fromLocal8Bit(structRes.name)); + qres.setUserNo(QString::fromLocal8Bit(structRes.userNo)); + qres.setId(structRes.id); + qres.setLoginTime(string(structRes.loginTime)); + qres.setRegisterTime(string(structRes.registerTime)); + qres.setLoggerSearch(structRes.loggerSearch); + qres.setMapMark(structRes.mapMark); + qres.setDevManage(structRes.devManage); + qres.setProductPlan(structRes.productPlan); + qres.setQueryHistory(structRes.queryHistory); + qres.setPermissonType(QString::fromLocal8Bit(structRes.permissonType)); + qres.setWarninManage(structRes.warningManage); + qres.setVersionManage(structRes.versionManage); + qres.setAdmin(structRes.admin); + vecs.push_back(qres); } - if(!vecs.empty()){ - emit notifyDateChange(vecs); - } + emit notifyDateChange(vecs); + }else{ + // 鏌ヨ澶辫触鏁版嵁涓虹┖娓呴櫎琛ㄦ牸鏁版嵁 + emit notifyDateChange(vector<PmsQueryResult>()); } } - if(type == UPDATE_PMS_REQ){ - res = (QueryPmsResponse *)buf.data(); - if(res->success){ + if(head.type == UPDATE_PMS_RES){ + upRes = (UpdatePmsRes *)buf.data(); + qDebug()<< "鏇存柊鍝嶅簲"; + if(upRes->success){ QString dlgTitle = "鏇存柊缁撴灉"; QString strInfo = "鏉冮檺淇℃伅鏇存柊鎴愬姛"; QMessageBox::information(this,dlgTitle,strInfo, diff --git "a/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/PmsClientSocket.h" "b/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/PmsClientSocket.h" index 0a0e535..3a17733 100644 --- "a/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/PmsClientSocket.h" +++ "b/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/PmsClientSocket.h" @@ -16,7 +16,7 @@ }; enum option{ - QUERY_PMS_REQ, + QUERY_PMS_REQ=6, UPDATE_PMS_REQ, QUERY_PMS_RES, UPDATE_PMS_RES, @@ -24,73 +24,84 @@ // 鎸夊憳宸ョ紪鍙枫�佸悕瀛楁垨鑱屼綅鏌ヨ浜哄憳鏉冮檺淇℃伅璇锋眰 -typedef struct QueryPmsRequest{ +typedef struct QueryPmsReq{ Head head; char userNo[32]; char name[32]; char permissonType[32]; - QueryPmsRequest(){ + QueryPmsReq(){ head.type=QUERY_PMS_REQ; memset(userNo,0,32); memset(permissonType,0,32); memset(name,0,32); - head.len = sizeof(QueryPmsRequest); + head.len = sizeof(QueryPmsReq); } -} QueryPmsRequest; +} QueryPmsReq; // 鎸夎鑹瞚d鏇存柊鏉冮檺淇℃伅璇锋眰 -typedef struct UpdatePmsRequest{ +typedef struct UpdatePmsReq{ Head head; - int roleId; + // 浜哄憳琛ㄤ富閿甶d + int id; int queryHistory; int loggerSearch; int mapMark; int devManage; int productPlan; - UpdatePmsRequest(){ - head.type=QUERY_PMS_RES; - head.len = sizeof(UpdatePmsRequest); - } -} UpdatePmsRequest; + int warningManage; + int versionManage; //鐗堟湰绠$悊 + int admin; //绯荤粺绠$悊鍛� -// 鍗曚釜浜哄憳鏉冮檺缁撴瀯浣� -typedef struct UserAboutPms{ + char permissonType[32]; + UpdatePmsReq(){ + head.type=UPDATE_PMS_REQ; + head.len = sizeof(UpdatePmsReq); + } +} UpdatePmsReq; + +// 鍗曚釜浜哄憳鍜屾潈闄愯仈鍚堟煡璇㈢粨鏋勪綋 +typedef struct PmsRes{ int queryHistory; int loggerSearch; int mapMark; int devManage; int productPlan; - int roleId; + int versionManage; //鐗堟湰绠$悊 + int warningManage; + int admin; //绯荤粺绠$悊鍛� + + int id; + char userNo[32]; char name[32]; - char permissonType[32]; - char startDateTime[32]; - char endDateTime[32]; + + char permissonType[32]; // 瑙掕壊绫诲瀷 + + char department[32]; + char loginTime[32]; + char registerTime[32]; } PmsRes; // 鏌ヨ浜哄憳鍜岃鑹蹭俊鎭殑鍝嶅簲缁撴瀯浣� -typedef struct UserAboutPmsResponse{ +typedef struct QueryPmsRes{ Head head; int success; // 1涓烘垚鍔� ,0涓哄け璐� - //PmsRes pmsList[100]; - char pmsList[0]; - UserAboutPmsResponse(){ + PmsRes pmsList[0]; + QueryPmsRes(){ head.type=QUERY_PMS_RES; -// memset(pmsList,0,sizeof(PmsRes)); -// head.len = sizeof(UserAboutPmsResponse); } -} QueryPmsResponse; +} QueryPmsRes; // 鏉冮檺鏇存柊缁撴灉鍝嶅簲浣� -typedef struct UpdatePmsResponse{ +typedef struct UpdatePmsRes{ Head head; int success; // 1涓烘垚鍔� ,0涓哄け璐� - UpdatePmsResponse(){ + UpdatePmsRes(){ head.type = UPDATE_PMS_RES; - head.len = sizeof(UpdatePmsResponse); + head.len = sizeof(UpdatePmsRes); } -} UpdatePmsResponse ; +} UpdatePmsRes ; class PmsClientSocket : public QWidget @@ -99,7 +110,7 @@ QTcpSocket *client; - int port=88888; + int port=16888; QString targetIp = "127.0.0.1"; bool connectSuccess= false; diff --git "a/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/permissondialog.cpp" "b/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/permissondialog.cpp" index 98d0f81..ab7a404 100644 --- "a/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/permissondialog.cpp" +++ "b/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/permissondialog.cpp" @@ -34,11 +34,29 @@ map5[2]=ui->radioButton_15; + map<int,QRadioButton *> warningMap; + warningMap[0]=ui->radioButton_16; + warningMap[1]=ui->radioButton_17; + warningMap[2]=ui->radioButton_18; + + map<int,QRadioButton *> versionMap; + versionMap[0]=ui->radioButton_19; + versionMap[1]=ui->radioButton_20; + versionMap[2]=ui->radioButton_21; + + map<int,QRadioButton *> superManager; + // 1涓鸿秴绾х鐞嗗憳 + superManager[0]=ui->radioButton_23; + superManager[1]=ui->radioButton_22; + btnList.push_back(map1); btnList.push_back(map2); btnList.push_back(map3); btnList.push_back(map4); btnList.push_back(map5); + btnList.push_back(warningMap); + btnList.push_back(versionMap); + btnList.push_back(superManager); } @@ -50,7 +68,7 @@ int PermissonDialog::findBoxCheck(map<int, QRadioButton *> map) { for(int i =0;i<map.size();i++){ - if(btnList[0][i]->isChecked()){ + if(map[i]->isChecked()){ return i; } } @@ -65,6 +83,12 @@ btnList[2][res.getMapMark()]->setChecked(true); btnList[3][res.getDevManage()]->setChecked(true); btnList[4][res.getProductPlan()]->setChecked(true); + + btnList[5][res.getWarninManage()]->setChecked(true); + + btnList[6][res.getVersionManage()]->setChecked(true); + + btnList[7][res.getAdmin()]->setChecked(true); curRes = res; @@ -81,8 +105,11 @@ param.setMapMark(findBoxCheck(btnList[2])); param.setDevManage(findBoxCheck(btnList[3])); param.setProductPlan(findBoxCheck(btnList[4])); + param.setWarninManage(findBoxCheck(btnList[5])); + param.setVersionManage(findBoxCheck(btnList[6])); + param.setAdmin(findBoxCheck(btnList[7])); - param.setRoleId(curRes.getRoleId()); + param.setId(curRes.getId()); client->updatePmsByParam(param); } diff --git "a/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/permissondialog.ui" "b/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/permissondialog.ui" index 2701441..6599cc5 100644 --- "a/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/permissondialog.ui" +++ "b/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/permissondialog.ui" @@ -6,8 +6,8 @@ <rect> <x>0</x> <y>0</y> - <width>421</width> - <height>361</height> + <width>560</width> + <height>492</height> </rect> </property> <property name="windowTitle"> @@ -16,54 +16,18 @@ <layout class="QGridLayout" name="gridLayout_3"> <item row="0" column="0"> <layout class="QGridLayout" name="gridLayout_2"> + <item row="3" column="0"> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> <item row="0" column="0"> <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> - <widget class="QGroupBox" name="groupBox"> - <property name="title"> - <string>鍘嗘椂鏌ヨ</string> - </property> - <widget class="QRadioButton" name="radioButton"> - <property name="geometry"> - <rect> - <x>20</x> - <y>20</y> - <width>115</width> - <height>19</height> - </rect> - </property> - <property name="text"> - <string>鏃犳潈闄�</string> - </property> - </widget> - <widget class="QRadioButton" name="radioButton_2"> - <property name="geometry"> - <rect> - <x>150</x> - <y>20</y> - <width>115</width> - <height>19</height> - </rect> - </property> - <property name="text"> - <string>鍙煡鐪�</string> - </property> - </widget> - <widget class="QRadioButton" name="radioButton_3"> - <property name="geometry"> - <rect> - <x>280</x> - <y>20</y> - <width>115</width> - <height>19</height> - </rect> - </property> - <property name="text"> - <string>鍙慨鏀�</string> - </property> - </widget> - </widget> - </item> <item row="1" column="0"> <widget class="QGroupBox" name="groupBox_2"> <property name="title"> @@ -96,6 +60,52 @@ </property> </widget> <widget class="QRadioButton" name="radioButton_6"> + <property name="geometry"> + <rect> + <x>280</x> + <y>20</y> + <width>115</width> + <height>19</height> + </rect> + </property> + <property name="text"> + <string>鍙慨鏀�</string> + </property> + </widget> + </widget> + </item> + <item row="0" column="0"> + <widget class="QGroupBox" name="groupBox"> + <property name="title"> + <string>鍘嗘椂鏌ヨ</string> + </property> + <widget class="QRadioButton" name="radioButton"> + <property name="geometry"> + <rect> + <x>20</x> + <y>20</y> + <width>115</width> + <height>19</height> + </rect> + </property> + <property name="text"> + <string>鏃犳潈闄�</string> + </property> + </widget> + <widget class="QRadioButton" name="radioButton_2"> + <property name="geometry"> + <rect> + <x>150</x> + <y>20</y> + <width>115</width> + <height>19</height> + </rect> + </property> + <property name="text"> + <string>鍙煡鐪�</string> + </property> + </widget> + <widget class="QRadioButton" name="radioButton_3"> <property name="geometry"> <rect> <x>280</x> @@ -248,17 +258,132 @@ </widget> </widget> </item> + <item row="5" column="0"> + <widget class="QGroupBox" name="groupBox_6"> + <property name="title"> + <string>璀︽姤绠$悊</string> + </property> + <widget class="QRadioButton" name="radioButton_16"> + <property name="geometry"> + <rect> + <x>20</x> + <y>20</y> + <width>115</width> + <height>19</height> + </rect> + </property> + <property name="text"> + <string>鏃犳潈闄�</string> + </property> + </widget> + <widget class="QRadioButton" name="radioButton_17"> + <property name="geometry"> + <rect> + <x>150</x> + <y>20</y> + <width>115</width> + <height>19</height> + </rect> + </property> + <property name="text"> + <string>鍙煡鐪�</string> + </property> + </widget> + <widget class="QRadioButton" name="radioButton_18"> + <property name="geometry"> + <rect> + <x>280</x> + <y>20</y> + <width>115</width> + <height>19</height> + </rect> + </property> + <property name="text"> + <string>鍙慨鏀�</string> + </property> + </widget> + </widget> + </item> + <item row="6" column="0"> + <widget class="QGroupBox" name="groupBox_7"> + <property name="title"> + <string>鐗堟湰绠$悊</string> + </property> + <widget class="QRadioButton" name="radioButton_19"> + <property name="geometry"> + <rect> + <x>20</x> + <y>20</y> + <width>115</width> + <height>19</height> + </rect> + </property> + <property name="text"> + <string>鏃犳潈闄�</string> + </property> + </widget> + <widget class="QRadioButton" name="radioButton_20"> + <property name="geometry"> + <rect> + <x>150</x> + <y>20</y> + <width>115</width> + <height>19</height> + </rect> + </property> + <property name="text"> + <string>鍙煡鐪�</string> + </property> + </widget> + <widget class="QRadioButton" name="radioButton_21"> + <property name="geometry"> + <rect> + <x>280</x> + <y>20</y> + <width>115</width> + <height>19</height> + </rect> + </property> + <property name="text"> + <string>鍙慨鏀�</string> + </property> + </widget> + </widget> + </item> + <item row="7" column="0"> + <widget class="QGroupBox" name="groupBox_8"> + <property name="title"> + <string>瓒呯骇绠$悊鍛�</string> + </property> + <widget class="QRadioButton" name="radioButton_22"> + <property name="geometry"> + <rect> + <x>20</x> + <y>20</y> + <width>115</width> + <height>19</height> + </rect> + </property> + <property name="text"> + <string>鏄�</string> + </property> + </widget> + <widget class="QRadioButton" name="radioButton_23"> + <property name="geometry"> + <rect> + <x>150</x> + <y>20</y> + <width>115</width> + <height>19</height> + </rect> + </property> + <property name="text"> + <string>鍚�</string> + </property> + </widget> + </widget> + </item> </layout> - </item> - <item row="1" column="0"> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> </item> </layout> </item> diff --git "a/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/permissonwindow.cpp" "b/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/permissonwindow.cpp" index 71580ef..212aa8a 100644 --- "a/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/permissonwindow.cpp" +++ "b/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/permissonwindow.cpp" @@ -11,46 +11,20 @@ ui(new Ui::PermissonWindow) { ui->setupUi(this); - clientSocket = new PmsClientSocket(this); - - dia = new PermissonDialog(this,clientSocket); - - - - connect(this,SIGNAL(sendUserNo(PmsQueryResult)),dia,SLOT(recvUserNo(PmsQueryResult))); - connect(clientSocket,SIGNAL(notifyDateChange(vector<PmsQueryResult>)),this,SLOT(renderItemData(vector<PmsQueryResult>))); - - roleMap["鏅�氶噰鐭垮憳宸�"] = 1; - roleMap["鎶�鏈淮鎶や汉鍛�"] = 2; - roleMap["绯荤粺绠$悊鍛�"] = 3; - roleMap["瀹夊叏绠$悊浜哄憳"] = 4; - this->setWindowTitle("鏉冮檺绠$悊"); vector<QString> lableList; lableList.push_back("鍛樺伐缂栧彿"); lableList.push_back("濮撳悕"); - lableList.push_back("褰撳ぉ宸ヤ綔鏃堕棿"); - lableList.push_back("褰撳ぉ缁撴潫鏃堕棿"); + lableList.push_back("閮ㄩ棬"); + lableList.push_back("鐧诲綍鏃堕棿"); + lableList.push_back("娉ㄥ唽鏃堕棿"); + lableList.push_back("鑱屼綅"); + clientSocket = new PmsClientSocket(this); - + dia = new PermissonDialog(this,clientSocket); m_model = new QStandardItemModel(globalPms.size(),lableList.size(),this); - - ui->tableView->setModel(m_model); - - for(int i=0;i<m_model->rowCount();i++){ - PmsQueryResult curRes = globalPms[i]; - m_model->setItem(i,0,new QStandardItem(QString::fromStdString(curRes.getUserNo()))); - m_model->setItem(i,1,new QStandardItem(QString::fromLocal8Bit(curRes.getName().c_str()))); - m_model->setItem(i,2,new QStandardItem(QString::fromStdString(curRes.getStartDateTime()))); - m_model->setItem(i,3,new QStandardItem(QString::fromStdString(curRes.getEndDateTime()))); - m_model->setItem(i,4,new QStandardItem(QString::fromLocal8Bit(curRes.getPermissonType().c_str()))); - - } - - ui->tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); - ui->tableView->verticalHeader()->hide(); QStringList lable; @@ -60,11 +34,22 @@ m_model->setHorizontalHeaderLabels(lable); + ui->tableView->setModel(m_model); + ui->tableView->verticalHeader()->hide(); + + connect(this,SIGNAL(sendUserNo(PmsQueryResult)),dia,SLOT(recvUserNo(PmsQueryResult))); + connect(clientSocket,SIGNAL(notifyDateChange(vector<PmsQueryResult>)),this,SLOT(renderItemData(vector<PmsQueryResult>))); + connect(m_model,SIGNAL(itemChanged(QStandardItem*)),this,SLOT(listenItemChange(QStandardItem*))); + + + // 鍙戜竴娆℃煡璇㈠叏閮ㄦ暟鎹姹� + clientSocket->queryAllUserAboutUser(); + + + + QComBoxDelegate * qc = new QComBoxDelegate(this); - - - - ui->tableView->setItemDelegateForColumn(4,qc); + ui->tableView->setItemDelegateForColumn(5,qc); m = new QMenu(this); @@ -82,17 +67,13 @@ connect(ac1,&QAction::triggered,[=]{ int row = ui->tableView->currentIndex().row(); qDebug() << "鏇存柊褰撳墠鍛樺伐淇℃伅" - << QString::fromStdString( globalPms[row].getUserNo()); + << globalPms[row].getUserNo(); // 鍙戦�佸憳宸ョ紪鍙蜂俊鎭� emit sendUserNo(globalPms[row]); dia->setModal(true); dia->show(); }); - - - connect(m_model,SIGNAL(itemChanged(QStandardItem*)),this,SLOT(listenItemChange(QStandardItem*))); - } @@ -123,44 +104,50 @@ void PermissonWindow::on_pushButton_clicked() { - qDebug() << "鍙戦�佹煡璇㈣姹�"; + PmsParam pm; - pm.setName(ui->lineEdit->text().toStdString()); - pm.setPermissonType(ui->lineEdit_2->text().toStdString()); - pm.setUserNo(ui->lineEdit_3->text().toStdString()); + pm.setName(ui->lineEdit->text()); + pm.setPermissonType(ui->lineEdit_2->text()); + pm.setUserNo(ui->lineEdit_3->text()); clientSocket->queryPmsByParam(pm); - qDebug() << "鏌ヨ涓�"; } void PermissonWindow::listenItemChange(QStandardItem *item) { - QString localText = item->text(); - if(roleMap.count(localText.toStdString())){ - qDebug() << "鍙戣捣鑱屼綅鏇存柊璇锋眰"; + if(item->column()==m_model->columnCount()-1){ + QString localText = item->text(); + PmsPlusParma pm; - pm.setPermissonType(localText.toStdString()); - pm.setRoleId(roleMap[localText.toStdString()]); + pm.setPermissonType(localText); + + int id = globalPms[item->row()].getId(); + pm.setId(id); clientSocket->updatePmsByParam(pm); } } void PermissonWindow::renderItemData(vector<PmsQueryResult> res) { + globalPms = res; m_model->setRowCount(globalPms.size()); for(int i=0;i<m_model->rowCount();i++){ PmsQueryResult curRes = globalPms[i]; - m_model->setItem(i,0,new QStandardItem(QString::fromStdString(curRes.getUserNo()))); - m_model->setItem(i,1,new QStandardItem(QString::fromLocal8Bit(curRes.getName().c_str()))); - m_model->setItem(i,2,new QStandardItem(QString::fromStdString(curRes.getStartDateTime()))); - m_model->setItem(i,3,new QStandardItem(QString::fromStdString(curRes.getEndDateTime()))); - m_model->setItem(i,4,new QStandardItem(QString::fromLocal8Bit(curRes.getPermissonType().c_str()))); + m_model->setItem(i,0,new QStandardItem(curRes.getUserNo())); + m_model->setItem(i,1,new QStandardItem(curRes.getName())); + m_model->setItem(i,2,new QStandardItem(QString::fromStdString(curRes.getDepartment()))); + m_model->setItem(i,3,new QStandardItem(QString::fromStdString(curRes.getLoginTime()))); + m_model->setItem(i,4,new QStandardItem(QString::fromStdString(curRes.getRegisterTime()))); + m_model->blockSignals(true); + m_model->setItem(i,5,new QStandardItem(curRes.getPermissonType())); + m_model->blockSignals(false); } ui->tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); + qDebug() << "鏌ヨ鍒扮殑鏁伴噺 " << globalPms.size(); } diff --git "a/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/permissonwindow.h" "b/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/permissonwindow.h" index a9f57be..d0e8f30 100644 --- "a/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/permissonwindow.h" +++ "b/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/permissonwindow.h" @@ -46,11 +46,13 @@ QMenu * m; PermissonDialog *dia; SyncDataToDB * dbInfo; - map<string,int> roleMap; + vector<PmsQueryResult> globalPms; PmsClientSocket * clientSocket; + bool isRenderData; + }; diff --git "a/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/pmsparam.h" "b/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/pmsparam.h" index 0683706..a3ac943 100644 --- "a/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/pmsparam.h" +++ "b/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/pmsparam.h" @@ -1,32 +1,33 @@ 锘�#ifndef PMSPARAM_H #define PMSPARAM_H +#include <QString> #include <string> using namespace std; class PmsParam { protected: - string userNo; - string name; - string permissonType; + QString userNo; + QString name; + QString permissonType; public: - void setUserNo(string id){ + void setUserNo(QString id){ this->userNo = id; } - void setName(string name){ + void setName(QString name){ this->name = name; } - void setPermissonType(string permissonType){ + void setPermissonType(QString permissonType){ this->permissonType = permissonType; } - string getUserNo(){ + QString getUserNo(){ return userNo; } - string getName(){ + QString getName(){ return name; } - string getPermissonType(){ + QString getPermissonType(){ return permissonType; } diff --git "a/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/pmsplusparam.h" "b/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/pmsplusparam.h" index 23885dd..789bdc7 100644 --- "a/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/pmsplusparam.h" +++ "b/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/pmsplusparam.h" @@ -1,15 +1,19 @@ -#ifndef PMSPLUSPARAM_H +锘�#ifndef PMSPLUSPARAM_H #define PMSPLUSPARAM_H #include "pmsparam.h" class PmsPlusParma : public PmsParam{ - int roleId; + int id; int queryHistory; int loggerSearch; int mapMark; int devManage; int productPlan; + + int warninManage; + int versionManage; //鐗堟湰绠$悊 + int admin; //绯荤粺绠$悊鍛� public: void setQueryHistory(int val){ this->queryHistory = val; @@ -27,8 +31,8 @@ this->productPlan = val; } - void setRoleId(int val){ - this->roleId = val; + void setId(int val){ + this->id = val; } int getQueryHistory(){ @@ -47,19 +51,51 @@ return productPlan; } - int getRoleId(){ - return roleId; + int getId(){ + return id; + } + + PmsPlusParma(){ + id = 0; + queryHistory = 0; + loggerSearch = 0; + mapMark = 0; + devManage = 0; + productPlan = 0; } - PmsPlusParma(){ - roleId = -1; - queryHistory = -1; - loggerSearch = -1; - mapMark = -1; - devManage = -1; - productPlan = -1; + int getVersionManage() const + { + return versionManage; + } + + void setVersionManage(int value) + { + versionManage = value; + } + + int getAdmin() const + { + return admin; + } + + void setAdmin(int value) + { + admin = value; + } + + int getWarninManage() const + { + return warninManage; + } + + void setWarninManage(int value) + { + warninManage = value; } }; #endif // PMSPLUSPARAM_H + + diff --git "a/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/pmsqueryresult.h" "b/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/pmsqueryresult.h" index e35b54f..602a8ed 100644 --- "a/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/pmsqueryresult.h" +++ "b/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/pmsqueryresult.h" @@ -1,10 +1,8 @@ -#ifndef PMSQUERYRESULT_H +锘�#ifndef PMSQUERYRESULT_H #define PMSQUERYRESULT_H #include "pmsparam.h" class PmsQueryResult : public PmsParam{ - string startDateTime; - string endDateTime; int queryHistory; int loggerSearch; @@ -12,13 +10,22 @@ int devManage; int productPlan; + int warninManage; + int versionManage; //鐗堟湰绠$悊 + int admin; //绯荤粺绠$悊鍛� + + int id; int roleId; + + string department; + string loginTime; + string registerTime; public: - void setStartDateTime(string time){ - this->startDateTime = time; + void setLoginTime(string time){ + this->loginTime = time; } - void setEndDateTime(string time){ - this->endDateTime = time; + void setRegisterTime(string time){ + this->registerTime = time; } void setQueryHistory(int val){ @@ -36,16 +43,16 @@ void setProductPlan(int val){ this->productPlan = val; } - void setRoleId(int val){ - this->roleId = val; + void setId(int val){ + this->id = val; } - string getStartDateTime(){ - return startDateTime; + string getLoginTime(){ + return loginTime; } - string getEndDateTime(){ - return endDateTime; + string getRegisterTime(){ + return registerTime; } int getQueryHistory(){ return queryHistory; @@ -62,12 +69,58 @@ int getProductPlan(){ return productPlan; } - int getRoleId(){ - return roleId; + int getId(){ + return id; } + + + + int getVersionManage() const + { + return versionManage; + } + + void setVersionManage(int value) + { + versionManage = value; + } + + int getAdmin() const + { + return admin; + } + + void setAdmin(int value) + { + admin = value; + } + + int getWarninManage() const + { + return warninManage; + } + + void setWarninManage(int value) + { + warninManage = value; + } + + + + string getDepartment() const + { + return department; + } + + void setDepartment(const string &value) + { + department = value; + } }; #endif // PMSQUERYRESULT_H + + diff --git "a/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/qcomboxdelegate.cpp" "b/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/qcomboxdelegate.cpp" index 8eab6b3..01d0fde 100644 --- "a/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/qcomboxdelegate.cpp" +++ "b/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/qcomboxdelegate.cpp" @@ -16,7 +16,21 @@ { QComboBox * box = new QComboBox(parent); QStringList text; - text << "鏅�氶噰鐭垮憳宸�" << "鎶�鏈淮鎶や汉鍛�" << "绯荤粺绠$悊鍛�"<< "瀹夊叏绠$悊浜哄憳"; + + QString curText = qvariant_cast<QString>(index.data()); + + vector<QString> vecq; + vecq.push_back("鎶�鏈淮鎶や汉鍛�"); + vecq.push_back("绯荤粺绠$悊鍛�"); + vecq.push_back("瀹夊叏绠$悊浜哄憳"); + vecq.push_back("鏅�氶噰鐭垮憳宸�"); + + text << curText; + for(QString role : vecq){ + if(curText!=role){ + text << role; + } + } box->addItems(text); return box; diff --git "a/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/qcomboxdelegate.h" "b/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/qcomboxdelegate.h" index d9e575e..5e31c91 100644 --- "a/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/qcomboxdelegate.h" +++ "b/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/qcomboxdelegate.h" @@ -1,12 +1,14 @@ -#ifndef QCOMBOXDELEGATE_H +锘�#ifndef QCOMBOXDELEGATE_H #define QCOMBOXDELEGATE_H #include <QItemDelegate> #include <QComboBox> -#pragma execution_character_set("utf-8") +#include <vector> +using namespace std; class QComBoxDelegate : public QItemDelegate { + public: QComBoxDelegate(); QComBoxDelegate(QObject * p=0); diff --git "a/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/syncdatatodb.cpp" "b/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/syncdatatodb.cpp" index 96ca144..47d836c 100644 --- "a/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/syncdatatodb.cpp" +++ "b/Client/\345\247\234\345\217\257\345\272\232/code/2024kunlun_project_permisson/syncdatatodb.cpp" @@ -23,17 +23,17 @@ { string sql = "SELECT * FROM user_info AS u, employee_permisson AS e WHERE u.role_id=e.id"; - if(!param.getUserNo().empty()){ - sql += " and u.user_no='" + param.getUserNo() + "'"; - } +// if(!param.getUserNo().empty()){ +// sql += " and u.user_no='" + param.getUserNo() + "'"; +// } - if(!param.getName().empty()){ - sql += " and u.name='" + param.getName()+ "'"; - } +// if(!param.getName().empty()){ +// sql += " and u.name='" + param.getName()+ "'"; +// } - if(!param.getPermissonType().empty()){ - sql += " and e.permission_type='" + param.getPermissonType()+ "'"; - } +// if(!param.getPermissonType().empty()){ +// sql += " and e.permission_type='" + param.getPermissonType()+ "'"; +// } qDebug() << "sql璇彞" << QString::fromStdString(sql); @@ -56,16 +56,16 @@ string sql = "update employee_permisson"; // 鍙洿鏀硅亴浣� - if(!param.getPermissonType().empty()){ - sql.append(" set permission_type='" + param.getPermissonType())+ "'"; - }else{ - sql.append(" set query_history=") + to_string(param.getQueryHistory()); - sql.append(",logger_search=") + to_string(param.getLoggerSearch()); - sql.append(",map_mark=") + to_string(param.getMapMark()); - sql.append(",dev_manage=") + to_string(param.getDevManage()); - sql.append(",product_plan=") + to_string(param.getProductPlan()); - } - sql.append(" where e.id=" + param.getRoleId()); +// if(!param.getPermissonType().empty()){ +// sql.append(" set permission_type='" + param.getPermissonType())+ "'"; +// }else{ +// sql.append(" set query_history=") + to_string(param.getQueryHistory()); +// sql.append(",logger_search=") + to_string(param.getLoggerSearch()); +// sql.append(",map_mark=") + to_string(param.getMapMark()); +// sql.append(",dev_manage=") + to_string(param.getDevManage()); +// sql.append(",product_plan=") + to_string(param.getProductPlan()); +// } + //sql.append(" where e.id=" + param.getRoleId()); mysql_real_query(&mysql, sql.c_str(), sql.size()); mysql_store_result(&mysql); @@ -76,13 +76,13 @@ void SyncDataToDB::setPmsResult(PmsQueryResult &res, char **row) { - res.setName(string(row[1])); - res.setUserNo(string(row[5])); - res.setStartDateTime(string(row[2])); - res.setEndDateTime(string(row[3])); - res.setRoleId(stoi(string(row[4]))); +// res.setName(string(row[1])); +// res.setUserNo(string(row[5])); +// res.setStartDateTime(string(row[2])); +// res.setEndDateTime(string(row[3])); +// res.setRoleId(stoi(string(row[4]))); - res.setPermissonType(string(row[8])); + // res.setPermissonType(string(row[8])); res.setQueryHistory(stoi(string(row[9]))); res.setLoggerSearch(stoi(string(row[10]))); res.setMapMark(stoi(string(row[11]))); @@ -90,5 +90,5 @@ res.setProductPlan(stoi(string(row[13]))); - qDebug() << QString::fromStdString(res.getUserNo()); + //qDebug() << QString::fromStdString(res.getUserNo()); } diff --git "a/Client/\345\247\234\345\217\257\345\272\232/code/\346\234\215\345\212\241\347\253\257\344\270\232\345\212\241\344\273\243\347\240\201/PermissonManage.cpp" "b/Client/\345\247\234\345\217\257\345\272\232/code/\346\234\215\345\212\241\347\253\257\344\270\232\345\212\241\344\273\243\347\240\201/PermissonManage.cpp" new file mode 100644 index 0000000..45d78a0 --- /dev/null +++ "b/Client/\345\247\234\345\217\257\345\272\232/code/\346\234\215\345\212\241\347\253\257\344\270\232\345\212\241\344\273\243\347\240\201/PermissonManage.cpp" @@ -0,0 +1,152 @@ +#include "stdafx.h" +#include "PermissonManage.h" +#include <iostream> +#include "MysqlConn.h" +#include <string.h> +#include <vector> +using namespace std; + + +PermissonManage::PermissonManage() +{ +} + + +PermissonManage::~PermissonManage() +{ +} + +bool PermissonManage::queryPmsByParam(SOCKET client, QueryPmsReq * req) +{ + // 组装SQL语句 + string sql = "SELECT * FROM user_info AS u, role_info AS e WHERE u.role_id=e.id"; + + if (*(req->userNo)) { + sql += " and u.user_no='" + string(req->userNo) + "'"; + } + + if (*(req->name)) { + sql += " and u.name='" + string(req->name) + "'"; + } + + if (*(req->permissonType)) { + sql += " and e.permission_type='" + string(req->permissonType) + "'"; + } + + cout << "sql:" << sql << endl; + + // 调用MySQL API 执行SQL语句,根据返回值组装响应结构体 + MysqlConn conn; + conn.connect("127.0.0.1", "root", "root", "mydb"); + + + bool ret = conn.query (sql); + + vector<PmsRes> pmsTempList; + while (conn.getResult()){ + PmsRes pmsRes; + pmsRes.admin = stoi(conn.getField(22)); + strcpy_s(pmsRes.department, conn.getField(1).c_str()); + + pmsRes.devManage = stoi(conn.getField(18)); + pmsRes.id = stoi(conn.getField(0)); + pmsRes.loggerSearch = stoi(conn.getField(16)); + strcpy_s(pmsRes.loginTime, conn.getField(11).c_str()); + pmsRes.mapMark = stoi(conn.getField(17)); + + strcpy_s(pmsRes.name, conn.getField(2).c_str()); + strcpy_s(pmsRes.permissonType, conn.getField(14).c_str()); + pmsRes.productPlan = stoi(conn.getField(19)); + pmsRes.queryHistory = stoi(conn.getField(15)); + strcpy_s(pmsRes.registerTime, conn.getField(12).c_str()); + strcpy_s(pmsRes.userNo, conn.getField(4).c_str()); + pmsRes.versionManage = stoi(conn.getField(21)); + pmsRes.warningManage = stoi(conn.getField(20)); + pmsTempList.push_back(pmsRes); + + + cout << "获取结果集2" << conn.getField(0) << conn.getField(1) << conn.getField(2); + } + + QueryPmsRes *res; + int len = sizeof(QueryPmsRes) + pmsTempList.size() * sizeof(PmsRes); + res = (QueryPmsRes *)malloc(len); + + + PmsRes * pmArr = new PmsRes[pmsTempList.size()]; + for (int i = 0; i < pmsTempList.size();i++) { + pmArr[i] = pmsTempList[i]; + } + + memcpy(res->pmsList,pmArr, pmsTempList.size() * sizeof(PmsRes)); + + + res->head.type = QUERY_PMS_RES; + res->head.len = len; + + if (ret > 0) { + res->success = 1; // 成功 + } + else { + res->success = 0; // 失败 + } + cout << "id="<< res->pmsList[0].id << endl; + // 发送结构体给客户端 + cout << __FUNCTION__ << send(client, (char*)res, res->head.len, 0) << endl; + + delete[] pmArr; + delete res; + return true; +} + +bool PermissonManage::updatePms(SOCKET client, UpdatePmsReq * req) +{ + // 调用MySQL API 执行SQL语句,根据返回值组装响应结构体 + MysqlConn conn; + conn.connect("127.0.0.1", "root", "root", "mydb"); + + char sql[512] = { 0 }; + + UpdatePmsRes res; + if (*(req->permissonType)) { + + // 先用角色类型查一遍角色表id + sprintf(sql, "select id from role_info where permission_type='%s'", req->permissonType); + bool ret = conn.query(sql); + bool retRes = conn.getResult(); + if (!ret || !retRes) { + res.success = 0; + } + else { + int roleId = stoi(conn.getField(0)); + memset(sql, 0, 512); + sprintf(sql, "update user_info set role_id=%d where id=%d", roleId, req->id); + ret = conn.update(sql); + res.success = ret; + } + } + else { + // 先用id查一遍角色id + sprintf(sql,"select role_id from user_info where id=%d", req->id); + + bool ret = conn.query(sql); + bool retRes = conn.getResult(); + if (!ret || !retRes) { + res.success = 0; + }else { + int roleId = stoi(conn.getField(0)); + memset(sql, 0, 512); + sprintf(sql, "update role_info set query_history=%d,logger_search=%d,map_mark=%d,dev_manage=%d" + ",product_plan=%d,warning_manage=%d,version_manage=%d,role_info.admin=%d where id=%d",req->queryHistory,req->loggerSearch, + req->mapMark,req->devManage,req->productPlan,req->warningManage,req->versionManage,req->admin,roleId); + + cout << "更新权限sql:" << sql << endl; + ret = conn.update(sql); + res.success = ret; + } + } + // 发送结构体给客户端 + cout << __FUNCTION__ << send(client, (char*)&res, res.head.len, 0) << endl; + + return true; +} diff --git "a/Client/\345\247\234\345\217\257\345\272\232/code/\346\234\215\345\212\241\347\253\257\344\270\232\345\212\241\344\273\243\347\240\201/PermissonManage.h" "b/Client/\345\247\234\345\217\257\345\272\232/code/\346\234\215\345\212\241\347\253\257\344\270\232\345\212\241\344\273\243\347\240\201/PermissonManage.h" new file mode 100644 index 0000000..2c9335d --- /dev/null +++ "b/Client/\345\247\234\345\217\257\345\272\232/code/\346\234\215\345\212\241\347\253\257\344\270\232\345\212\241\344\273\243\347\240\201/PermissonManage.h" @@ -0,0 +1,16 @@ +#pragma once + +#include "common.h" +#include <WinSock2.h> +#include <string> +using namespace std; + +class PermissonManage +{ +public: + PermissonManage(); + ~PermissonManage(); + bool queryPmsByParam(SOCKET client, QueryPmsReq * req); + bool updatePms(SOCKET client, UpdatePmsReq * req); +}; + diff --git "a/Client/\345\247\234\345\217\257\345\272\232/code/\346\234\215\345\212\241\347\253\257\344\270\232\345\212\241\344\273\243\347\240\201/ServerSocket.cpp" "b/Client/\345\247\234\345\217\257\345\272\232/code/\346\234\215\345\212\241\347\253\257\344\270\232\345\212\241\344\273\243\347\240\201/ServerSocket.cpp" new file mode 100644 index 0000000..9b7c45a --- /dev/null +++ "b/Client/\345\247\234\345\217\257\345\272\232/code/\346\234\215\345\212\241\347\253\257\344\270\232\345\212\241\344\273\243\347\240\201/ServerSocket.cpp" @@ -0,0 +1,166 @@ +#include "stdafx.h" +#include "ServerSocket.h" +#include "common.h" +#include "DeviceManage.h" +#include "PermissonManage.h" + +#define HEART_CHECK_TIMES 60 // 心跳检测的次数 + +struct TestData +{ + int type; + int len; + char data[32]; +}; + +ServerSocket::ServerSocket(bool openHeartCheck):m_openHeartCheck(openHeartCheck) +{ + if (initSocket()) { + cout << "init socket ok" << endl; + } + else { + cout << "init socket fail" << endl; + } +} + + +ServerSocket::~ServerSocket() +{ + closesocket(m_server); // 关闭服务端套接字 + WSACleanup(); // 关闭网络环境 +} + +bool ServerSocket::initSocket() +{ + WSAData wsa = { 0 }; + WSAStartup(MAKEWORD(2, 2), &wsa); // 启动网络环境 + // SOCK_STREAM:TCP协议 + // SOCK_DGRAM:UDP协议 + m_server = socket(AF_INET, SOCK_STREAM, 0); + SOCKADDR_IN addr; + addr.sin_family = AF_INET; + addr.sin_port = htons(16888); + addr.sin_addr.S_un.S_addr = 0; + int ret_bind = ::bind(m_server, (sockaddr*)&addr, sizeof(addr)); + if (ret_bind) { + cout << "bind fail:" << WSAGetLastError() << endl; + return false; + } + int ret_listen = listen(m_server, 5); + if (ret_listen) { + cout << "listen fail:" << WSAGetLastError() << endl; + return false; + } + // 正常,成功初始化 + // 启动accept线程 + thread accept_thread(&ServerSocket::acceptThread, this); + accept_thread.detach(); // 剥离线程,防止异常结束 + // 启动心跳检测线程 + thread heart_check_thread(&ServerSocket::heartCheckThread, this); + heart_check_thread.detach(); + + return true; +} + +void ServerSocket::acceptThread() +{ + while (true) + { + SOCKADDR_IN addr; + SOCKET client; // 当前连接上的客户端套接字 + int len = sizeof(addr); + + cout << "wait for conn..." << endl; + client = accept(m_server, (sockaddr*)&addr, &len); + cout << "conn client:" << client << endl; + + if (client == SOCKET_ERROR) { + cout << "socket error:" << WSAGetLastError() << endl; + break; + } + else if (client == 0) { + cout << "socket close:" << WSAGetLastError() << endl; + break; + } + // 正常 + // 建立新的键值对 + m_clientsMap[client] = HEART_CHECK_TIMES; + // 创建长连接的线程 + thread recv_send_thread(&ServerSocket::recvAndSendThread, this, client); + recv_send_thread.detach(); + } +} +void ServerSocket::recvAndSendThread(SOCKET client) +{ + while (true) { + char buffer[1024] = { 0 }; + int len_recv = recv(client, buffer, sizeof(buffer), 0); + cout << "len_recv:" << len_recv << " client:" << client << endl; + if (len_recv <= 0) { + cout << "client socket 已关闭或异常结束:" << WSAGetLastError() << endl; + break; + } + // 正常 + // 重置心跳阈值 + m_clientsMap[client] = HEART_CHECK_TIMES; + // 解包处理 + cout << "buffer:" << buffer << endl; + + int type = *(int*)buffer; + if (type == 100) { + TestData* td = (TestData*)buffer; + cout << "收到结构体:" << td->len << " " << td->data << endl; + } + else if (type == AD_REQ) { + // 添加设备 + cout << "收到添加设备请求" << endl; + ADReq *req = (ADReq*)buffer; + cout << "设备名称" << req->devInfo[0].deviceName << endl; + + // 调用 添加设备 业务API + DeviceManage devMan; + devMan.addDeviceBusiness(client, req); + } + else if (type == QUERY_PMS_REQ) { + cout << "查询权限请求" << endl; + QueryPmsReq * req = (QueryPmsReq *)buffer; + PermissonManage pmsManage; + pmsManage.queryPmsByParam(client, req); + + } + else if (type == UPDATE_PMS_REQ) { + cout << "更新权限请求" << endl; + UpdatePmsReq * req = (UpdatePmsReq *)buffer; + PermissonManage pmsManage; + pmsManage.updatePms(client, req); + + } + + // 原封不动的回收到的内容给对应客户端 + //send(client, buffer, len_recv, 0); + } + closesocket(client); +} + +void ServerSocket::heartCheckThread() +{ + while (m_openHeartCheck) + { + // 轮询map + for (auto iter = m_clientsMap.begin();iter != m_clientsMap.end();) { + iter->second--; // 阈值递减 + cout << "client:" << iter->first << " 阈值:" << iter->second << endl; + if (iter->second == 0) { + // 连接无效了,关闭连接,再删除 + cout << "发现无效客户端连接:" << iter->first << endl; + closesocket(iter->first); + iter = m_clientsMap.erase(iter); // 接收返回值,防止迭代器失效 + } + else { + ++iter; + } + } + // 间隔5秒 + Sleep(5 * 1000); // 睡眠5000毫秒,就是5秒 + } +} diff --git "a/Client/\345\247\234\345\217\257\345\272\232/code/\346\234\215\345\212\241\347\253\257\344\270\232\345\212\241\344\273\243\347\240\201/common.h" "b/Client/\345\247\234\345\217\257\345\272\232/code/\346\234\215\345\212\241\347\253\257\344\270\232\345\212\241\344\273\243\347\240\201/common.h" new file mode 100644 index 0000000..bc4085c --- /dev/null +++ "b/Client/\345\247\234\345\217\257\345\272\232/code/\346\234\215\345\212\241\347\253\257\344\270\232\345\212\241\344\273\243\347\240\201/common.h" @@ -0,0 +1,1064 @@ +锘�#ifndef COMMON_H +#define COMMON_H + +#include <string.h> + +enum TypeInfo { + + //娉ㄥ唽鐧诲綍 + LOGIN_REQ, // 鐧诲綍璇锋眰 + LOGIN_RES, // 鐧诲綍鍝嶅簲 + REGISTER_REQ, //娉ㄥ唽璇锋眰 + REGISTER_RES, //娉ㄥ唽鍝嶅簲 + RESET_REQ, //閲嶇疆瀵嗙爜璇锋眰 + RESET_RES, //閲嶇疆瀵嗙爜鍝嶅簲 + + + //鏉冮檺绠$悊 + QUERY_PMS_REQ, // 鎸夊憳宸ョ紪鍙枫�佸悕瀛楁垨鑱屼綅鏌ヨ浜哄憳鏉冮檺淇℃伅璇锋眰 + UPDATE_PMS_REQ, // 鎸夎鑹瞚d鏇存柊鏉冮檺淇℃伅璇锋眰 + QUERY_PMS_RES, // 鏌ヨ浜哄憳鍜岃鑹蹭俊鎭殑鍝嶅簲缁撴瀯浣� + UPDATE_PMS_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,//鐓ょ熆浜ч噺鍝嶅簲 + + //璀︽姤绠$悊 + WARNING_REQ, // 璀︽姤璇锋眰 + WARNING_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,//鏃ュ織鏌ヨ鍝嶅簲 + +}; + +struct Head { + int type; + int len; +}; + +//娉ㄥ唽鐧诲綍 +//鐧诲綍璇锋眰 +struct LoginReq +{ + Head head; + char userName[32]; + char password[32]; + LoginReq() { + head.type = LOGIN_REQ; + head.len = sizeof(LoginReq); + } +}; + +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 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; + +// 鎸夎鑹瞚d鏇存柊鏉冮檺淇℃伅璇锋眰 +typedef struct UpdatePmsReq { + Head head; + // 浜哄憳琛ㄤ富閿甶d + int id; + int queryHistory; + int loggerSearch; + int mapMark; + int devManage; + int productPlan; + int warningManage; + int versionManage; //鐗堟湰绠$悊 + int admin; //绯荤粺绠$悊鍛� + + char permissonType[32]; + UpdatePmsReq() { + head.type = QUERY_PMS_RES; + head.len = sizeof(UpdatePmsReq); + } +} UpdatePmsReq; + +// 鍗曚釜浜哄憳鍜屾潈闄愯仈鍚堟煡璇㈢粨鏋勪綋 +typedef struct PmsRes { + int queryHistory; + int loggerSearch; + int mapMark; + int devManage; + int productPlan; + int versionManage; //鐗堟湰绠$悊 + int warningManage; + int admin; //绯荤粺绠$悊鍛� + + int id; + + char userNo[32]; + char name[32]; + + char permissonType[32]; // 瑙掕壊绫诲瀷 + + char department[32]; + char loginTime[32]; + char registerTime[32]; +} PmsRes; + +// 鏌ヨ浜哄憳鍜岃鑹蹭俊鎭殑鍝嶅簲缁撴瀯浣� +typedef struct QueryPmsRes { + Head head; + int success; // 1涓烘垚鍔� ,0涓哄け璐� + PmsRes pmsList[0]; + QueryPmsRes() { + head.type = QUERY_PMS_REQ; + } +} QueryPmsRes; + +// 鏉冮檺鏇存柊缁撴灉鍝嶅簲浣� +struct UpdatePmsRes { + Head head; + int success; // 1涓烘垚鍔� ,0涓哄け璐� + UpdatePmsRes() { + head.type = UPDATE_PMS_RES; + head.len = sizeof(UpdatePmsRes); + } + +}; + + + + +//璁惧绠$悊 +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; + 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 MDRes//淇敼鍝嶅簲 +{ + Head head; + DevicesInfo info; + MDRes() { + head.type = MD_RES; + head.len = sizeof(MDRes); + } +}; +struct MDReq//淇敼璇锋眰 +{ + Head head; + int type; + MDReq() { + head.type = MD_REQ; + head.len = sizeof(MDReq); + } +}; +//鏌ヨ璁惧 +struct QDReq//鏌ヨ璇锋眰 +{ + Head head; + DevicesInfo info; + QDReq() { + head.type = QD_REQ; + head.len = sizeof(QDReq); + } +}; +struct QDRes//鏌ヨ鍝嶅簲 +{ + Head head; + int type; + QDRes() { + head.type = QD_RES; + head.len = sizeof(QDRes); + } +}; + + +//鍦板浘鏍囨敞 +struct MarkInfo +{ + int markId;//鏍囨敞鐐筰d + 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; + 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; + 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; + 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; + 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 WarningReq { + Head head; + + float oxygenWarning; + float carbonWarning; + float tempWarning; + float humidityWarning; + + WarningReq() { + head.type = WARNING_REQ; + head.len = sizeof(WarningReq); + } +}; + + +struct DataThreshold { + //闃堝�� + float oxygenThreshold; + float carbonThreshold; + float tempThreshold; + float humidityThreshold; +}; + +struct Data { + float oxygen; // 姘ф皵娴撳害 + float carbon; // 涓�姘у寲纰虫祿搴� + float temp; // 娓╁害 + float humidity; // 婀垮害 +}; + +// 璀︽姤鍝嶅簲缁撴瀯浣� +struct WarningRes { + Head head; + int status; // 鍝嶅簲鐘舵�侊紙姣斿 0 琛ㄧず鎴愬姛锛�1 琛ㄧず澶辫触绛夛級 + const char* message; // 鍝嶅簲娑堟伅鎻忚堪 + + WarningRes(int stat, const char* msg) { + head.type = WARNING_RES; + head.len = sizeof(WarningRes); + status = stat; + message = msg; + } +}; + +//鐢熶骇璁″垝绠$悊 +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; + PdplanInfo info[0]; + AddPdplanReq() { + head.type = ADD_PDPLAN_REQ; + head.len = sizeof(AddPdplanReq); + } +}; + +//娣诲姞涓�鏉$敓浜ц鍒掔殑鍝嶅簲缁撴瀯浣� +struct AddPdplanRes +{ + Head head; + int status;//琛ㄧず鏄惁娣诲姞鎴愬姛锛�0鍚�1鏄� + AddPdplanRes() { + head.type = ADD_PDPLAN_RES; + head.len = sizeof(AddPdplanRes); + } +}; + +//鍒犻櫎涓�鏉$敓浜ц鍒掔殑璇锋眰缁撴瀯浣� +struct DelPdplanReq +{ + Head head; + 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 AddMonoutputReq +{ + Head head; + MonoutputInfo info[0]; + AddMonoutputReq() { + head.type = ADD_MONOUTPUT_REQ; + head.len = sizeof(AddMonoutputReq); + } +}; + +//娣诲姞鏈堜骇閲忕殑鍝嶅簲缁撴瀯浣� +struct AddMonoutputRes +{ + Head head; + 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 HistoryQueryReq { + Head head; + //鏍规嵁鏃堕棿鑼冨洿鏌ヨ + char startTime[32]; + char endTime[32]; + //鍏抽敭瀛楁煡璇� + char keyWord[32]; + HistoryQueryReq() { + // 鍒濆鍖栨暟鎹ご + head.type = QUERY_MONOUTPUT_REQ; + head.len = sizeof(HistoryQueryReq); + // 鍒濆鍖栨煡璇㈡潯浠跺瓧娈� + memset(startTime, 0, sizeof(startTime)); + memset(endTime, 0, sizeof(endTime)); + + } +}; + +// 鍘嗗彶鏌ヨ鍝嶅簲缁撴瀯浣� + +// 绯荤粺杩愯鐘舵�佽〃鐩稿叧淇℃伅 +struct HistroyInfo { + WarningRes warn;//璀︽姤鏌ヨ + QDRes dev;//璁惧鏌ヨ + QueryPdplanRes pro;//鐢熶骇璁″垝鏌ヨ +}; +struct HistoryQueryRes { + Head head; + //HistroyInfo sys[0]; + HistoryQueryRes() { + // 鍒濆鍖栨暟鎹ご + head.type = QUERY_MONOUTPUT_RES; + head.len = sizeof(HistoryQueryRes); + } +}; + + +//鑷姩鍗囩骇 +struct VersionNumReq // 鐗堟湰鍙疯姹� +{ + Head head; + VersionNumReq() { + head.type = VERSION_NUM_REQ; + head.len = sizeof(VersionNumReq); + } +}; + +struct VersionNumRes // 鐗堟湰鍙峰搷搴� +{ + Head head; + char versionId[64]; // 鐗堟湰鍙� + VersionNumRes() { + head.type = VERSION_NUM_RES; + head.len = sizeof(VersionNumRes); + } +}; + +// 鏂囦欢浼犺緭 +struct FileInfo +{ + char fileName[256]; + long long fileSize; + char s_filepath[128]; + char content[0]; +}; + +struct UploadFileReq // 涓婁紶鏂囦欢鐨勮姹� +{ + Head head; + FileInfo fileInfo; + UploadFileReq() { + head.type = UPLOAD_FILE_REQ; + head.len = sizeof(UploadFileReq); + } +}; + +struct 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 versionId[64]; // 鐗堟湰鍙� + char versionIdOld[64]; // 涓婁竴涓増鏈彿 + int fileNum; + char context[0]; //鍖呭惈涓嬭浇鏂囦欢淇℃伅 + + VersionInfoEntryReq() + { + head.type = VERSION_INFOENTRY_REQ; + head.len = sizeof(VersionInfoEntryReq); + } +}; + +// 鐗堟湰淇℃伅褰曞叆鍝嶅簲 +struct VersionInfoEntryRes { + Head head; + bool state = false; + VersionInfoEntryRes() + { + head.type = VERSION_INFOENTRY_RES; + head.len = sizeof(VersionInfoEntryRes); + } +}; + +// 鐗堟湰鏇存柊璇锋眰 +struct VersionUpdateReq { + Head head; + + char curVersionId[64]; // 鐗堟湰鍙� + VersionUpdateReq() + { + head.type = VERSION_UPDATE_REQ; + head.len = sizeof(VersionUpdateReq); + } +}; + +// 鐗堟湰鏇存柊鍝嶅簲 +struct VersionUpdateRes { + Head head; + bool state = false; + char versionId[64]; // 鐗堟湰鍙� + char updateDate[32]; // 鏇存柊鏃堕棿 + char versionDescription[1024]; //鏇存柊鎻忚堪 + + VersionUpdateRes() + { + head.type = VERSION_UPDATE_RES; + head.len = sizeof(VersionUpdateRes); + } +}; + +// 鐗堟湰鏇存柊鏂囦欢涓嬭浇璇锋眰 +struct FileDownloadsReq { + Head head; + char versionId[64]; // 鐗堟湰鍙� + FileDownloadsReq() + { + head.type = FILE_DOWNLOADS_REQ; + head.len = sizeof(FileDownloadsReq); + } +}; + +// 鐗堟湰鏇存柊鏂囦欢涓嬭浇鍝嶅簲 +struct 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 fileName[256]; + long long fileSize; + DownloadSuccessfullyRes() + { + head.type = DOWNLOAD_SUCCESSFULLY_RES; + head.len = sizeof(DownloadSuccessfullyRes); + } +}; + + +//鏃ュ織 +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 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 LogQueryRes { + Head head; + int status; // 鍝嶅簲鐘舵�� (濡� 0 琛ㄧず鎴愬姛锛岄潪 0 琛ㄧず澶辫触) + char errorMessage[256]; // 閿欒淇℃伅锛堝鏋滄湁锛� + + // 鏃犲弬鏋勯�犲嚱鏁� + LogQueryRes() { + head.type = LOGSEARCH_RES; + head.len = sizeof(LogQueryRes); + } +}; + + + + +#endif // COMMON_H diff --git "a/Client/\345\247\234\345\217\257\345\272\232/document/\346\235\203\351\231\220\347\256\241\347\220\206\351\234\200\346\261\202\345\210\206\346\236\220.docx" "b/Client/\345\247\234\345\217\257\345\272\232/document/\346\235\203\351\231\220\347\256\241\347\220\206\351\234\200\346\261\202\345\210\206\346\236\220.docx" index a879fd2..b53130b 100644 --- "a/Client/\345\247\234\345\217\257\345\272\232/document/\346\235\203\351\231\220\347\256\241\347\220\206\351\234\200\346\261\202\345\210\206\346\236\220.docx" +++ "b/Client/\345\247\234\345\217\257\345\272\232/document/\346\235\203\351\231\220\347\256\241\347\220\206\351\234\200\346\261\202\345\210\206\346\236\220.docx" Binary files differ diff --git "a/Client/\345\247\234\345\217\257\345\272\232/log/\345\247\234\345\217\257\345\272\232_1106.doc" "b/Client/\345\247\234\345\217\257\345\272\232/log/\345\247\234\345\217\257\345\272\232_1106.doc" new file mode 100644 index 0000000..ced568e --- /dev/null +++ "b/Client/\345\247\234\345\217\257\345\272\232/log/\345\247\234\345\217\257\345\272\232_1106.doc" Binary files differ diff --git a/common.h b/common.h index fb8ffa3..6d36e1f 100644 --- a/common.h +++ b/common.h @@ -90,6 +90,14 @@ //鏃ュ織 LOGSEARCH_REQ,//鏃ュ織鏌ヨ璇锋眰 LOGSEARCH_RES,//鏃ュ織鏌ヨ鍝嶅簲 + + //鍘嗗彶鏌ヨ鍒嗘瀽 + HISTORY_DEV_REQ, //鍘嗗彶鏌ヨ纭欢璇锋眰 + HISTORY_DEV_RES, //鍘嗗彶鏌ヨ纭欢鍝嶅簲 + HISTORY_PRODUCE_REQ, //鍘嗗彶鏌ヨ鐢熶骇璇锋眰 + HISTORY_PRODUCE_RES, //鍘嗗彶鏌ヨ鐢熶骇鍝嶅簲 + HISTORY_ENV_REQ, //鍘嗗彶鏌ヨ鐜璇锋眰 + HISTORY_ENV_RES, //鍘嗗彶鏌ヨ鐜鍝嶅簲 }; @@ -276,22 +284,22 @@ //璁惧绠$悊 struct DevicesInfo { - int deviceID; 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];//璁惧绫诲瀷 - double longitude;//缁忓害 - double latitude;//绾害 - char purchasingTime[15];//璐拱鏃堕棿 - char installTime[15];//瀹夎鏃堕棿 - char devicesSerialNumber[32];//璁惧缂栫爜 }; //娣诲姞璁惧 struct ADReq//娣诲姞璇锋眰 { Head head; - char deviceName[32]; + DevicesInfo devInfo[0]; ADReq() { head.type = AD_REQ; head.len = sizeof(ADReq); @@ -302,7 +310,7 @@ struct ADRes//娣诲姞鍝嶅簲 { Head head; - int type; + int status; ADRes() { head.type = AD_RES; head.len = sizeof(ADRes); @@ -310,22 +318,23 @@ }; //淇敼璁惧 -struct MDRes//淇敼璇锋眰 +struct MDReq//淇敼璇锋眰 { Head head; - DevicesInfo info; - MDRes() { - head.type = MD_RES; - head.len = sizeof(MDRes); - } -}; -struct MDReq//淇敼鍝嶅簲 -{ - Head head; - int type; + MDReq() { head.type = MD_REQ; head.len = sizeof(MDReq); + } +}; +struct MDRes//淇敼鍝嶅簲 +{ + Head head; + DevicesInfo info; + int status; + MDRes() { + head.type = MD_RES; + head.len = sizeof(MDRes); } }; //鏌ヨ璁惧 @@ -341,7 +350,7 @@ struct QDRes//鏌ヨ鍝嶅簲 { Head head; - int type; + int status; QDRes() { head.type = QD_RES; head.len = sizeof(QDRes); @@ -827,40 +836,91 @@ //鍘嗗彶鏌ヨ鍒嗘瀽 -// 鍘嗗彶鏌ヨ璇锋眰缁撴瀯浣� -struct HistoryQueryReq { + +//鍘嗗彶鏌ヨ鍒嗘瀽 + +struct warningInfo { + int device_id; + char des[32]; + char time[32]; + float data; + char type[16]; + char status[16]; +}; +// 鍘嗗彶鏌ヨ璁惧淇℃伅璇锋眰缁撴瀯浣� +struct HistoryDevReq { Head head; //鏍规嵁鏃堕棿鑼冨洿鏌ヨ char startTime[32]; char endTime[32]; //鍏抽敭瀛楁煡璇� char keyWord[32]; - HistoryQueryReq() { + HistoryDevReq() { // 鍒濆鍖栨暟鎹ご - head.type = QUERY_MONOUTPUT_REQ; - head.len = sizeof(HistoryQueryReq); + head.type = HISTORY_DEV_REQ; + head.len = sizeof(HISTORY_DEV_REQ); // 鍒濆鍖栨煡璇㈡潯浠跺瓧娈� - std::memset(startTime, 0, sizeof(startTime)); - std::memset(endTime, 0, sizeof(endTime)); - + } +}; +// 鍘嗗彶鏌ヨ鐢熶骇璁″垝璇锋眰缁撴瀯浣� +struct HistoryProReq { + Head head; + //鏍规嵁鏃堕棿鑼冨洿鏌ヨ + 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 HistroyInfo { - WarningRes warn;//璀︽姤鏌ヨ - QDRes dev;//璁惧鏌ヨ - QueryPdplanRes pro;//鐢熶骇璁″垝鏌ヨ -}; -struct HistoryQueryRes { +//鏌ヨ璁惧淇℃伅鍝嶅簲缁撴瀯浣� +struct HistoryDevRes { Head head; - HistroyInfo sys[0]; - HistoryQueryRes() { + DevicesInfo dev[0]; + HistoryDevRes() { // 鍒濆鍖栨暟鎹ご - head.type = QUERY_MONOUTPUT_RES; - head.len = sizeof(HistoryQueryRes); + 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); } }; diff --git "a/\350\241\250.docx" "b/\350\241\250.docx" index bb4ce96..02d41c8 100644 --- "a/\350\241\250.docx" +++ "b/\350\241\250.docx" Binary files differ -- Gitblit v1.8.0