-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmaininclude.h
233 lines (216 loc) · 5.09 KB
/
maininclude.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
#ifndef MAININCLUDE_H
#define MAININCLUDE_H
/*-----宏定义-------*/
#define MaxIDLength 30
#define ONDealOrder 11
#define ONNowOrder 12
#define ONHistory 13
#define ONNEWITEMS 15
#define ONADDNEWORDER 21
#define ONCHANGEORDER 22
#define ONSHOWORDER 23
/*-----宏定义结束---*/
/*----头文件-------*/
#include "QDBC.h"
#include <QApplication>
#include <QByteArray>
#include <QCloseEvent>
#include <QComboBox>
#include <QCompleter>
#include <QDebug>
#include <QDialog>
#include <QDir>
#include <QEvent>
#include <QFile>
#include <QFileDialog>
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonParseError>
#include <QJsonValue>
#include <QLabel>
#include <QLineEdit>
#include <QListWidget>
#include <QMessageBox>
#include <QMouseEvent>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QNetworkRequest>
#include <QPushButton>
#include <QRegExp>
#include <QRegExpValidator>
#include <QSet>
#include <QSettings>
#include <QStyle>
#include <QTableWidget>
#include <QTableWidgetItem>
#include <QToolButton>
#include <QVector>
#include <QtAlgorithms>
#include <QtPrintSupport>
#include <qmath.h>
#include <stack>
#include <unordered_map>
#include <xlsxdocument.h>
/*----头文件结束---*/
/*----结构声明-----*/
class Config {
public:
QString ip;
int serverPort;
int dataPort;
int MaxHistoryOrders;
int MaxItemMoreSize,MaxOrderMoreSize;
QString UserAgent;
QString basename;
QString softName;
QStringList statusList;
QStringList itemsList;
QStringList userIdentityList;
QStringList userCNIdentityList;
QString nowClientVersion;
char itemStartWith[5];
QDate orderStartDay;
int TableOnePageRows;
Config(QString file);
};
struct OneResItem {
public:
int pid;
int nodeid;
double cnt;
QString res;
QString name;
QString type;
QString units;
int padding;
QHash<QString, int> mp;
bool operator<(const OneResItem a) const
{
return pid < a.pid;
}
bool operator==(const OneResItem a) const
{
return pid == a.pid;
}
};
uint qHash(const OneResItem key);
class ResItemsTrie {
int itemsSum;
QHash<int, int> pidToNode;
public:
QVector<OneResItem> nodes;
ResItemsTrie();
void clear();
bool insert(OneResItem item);
OneResItem find(int pid);
OneResItem find(QString res, QString name, QString type);
};
struct OneItem {
public:
int pid;
double number;
QString status;
QString more;
};
struct OneNewItem {
public:
int pid;
double number;
bool isNew;
QString status;
QString more;
QString res;
QString name;
QString type;
QString units;
};
struct OneOrder {
public:
int id;
QVector<OneItem> items;
QVector<OneNewItem> newItems;
QString workshop;
QString useclass;
QString more;
QString teacher;
QString header;
QString admin;
QString keeper;
QString accountant;
QString status;
QDate starttime;
QDateTime outtime;
bool operator<(const OneOrder a) const
{
return id < a.id;
}
};
typedef OneOrder OneResOrder;
struct User {
public:
int id;
QString username;
QString password;
QString truename;
QString workshop;
QString storehouse;
QString useName;
QString usePassword;
QString identity;
QString trueIdentity;
bool isUseful;
char m_padding[3];
bool operator<(const User a) const
{
return id < a.id;
}
};
/*--结构声明结束---*/
/*--全局变量声明---*/
#ifndef ISMAINCPP
extern QVector<OneOrder> dealorders;
extern QVector<OneOrder> noworders;
extern QVector<OneOrder> historys;
extern QVector<OneResOrder> dealResOrders;
//extern QSet<OneResItem> allResItem;
extern User thisUser;
extern Config config;
extern ResItemsTrie resItemsTrie;
extern Database *useBase;
#endif
/*全局变量声明结束*/
/*函数定义*/
bool initDealOrders();
bool initNowOrders();
bool initNewItems();
bool initSatus();
bool flushDealOrders(QDate start, QDate end);
bool flushDealResOrders(QDate start, QDate end);
bool flushNowOrders(QDate start, QDate end);
bool flushHistoryOrders(QDate start, QDate end);
OneOrder* getOrder(int id, QVector<OneOrder>& orders);
bool getAllUsers(QVector<User>& users);
User* getUserByID(int userID,QVector<User> *users);
bool initResItems();
void addResItem(OneResItem atype, bool forCheck);
bool hasResItem(QString res, QString name, QString type);
//const OneResItem* getResItem(int pid);
OneResItem getResItem(int pid);
int getResItemPid(QString res, QString name, QString type);
QString getUnits(QString res, QString name, QString type);
QStringList getResList();
QStringList getNameList(QString res);
QStringList getTypeList(QString res, QString name);
QSet<OneResItem> getResItemsByRes(QString res);
bool userCheck(User user);
bool workshopCheck(QString wkname);
bool truenameCheck(QString name);
bool usernameCheck(QString username);
bool passwordCheck(QString password);
bool regCheck(QString reg, QString s);
bool orderCheck(OneOrder order);
QString toSHA256(QString s);
bool askForConferm(QString text);
/*函数定义结束*/
#endif // MAININCLUDE_H