projectinfomanger.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #ifndef PROJECTINFOMANGER_H
  2. #define PROJECTINFOMANGER_H
  3. #include <QObject>
  4. #include "httprequest.h"
  5. #include <QQueue>
  6. #include "struct_/projectinfo.h"
  7. #include "packinfomanger.h"
  8. #include <QJsonArray>
  9. // 处理批号的管理和同步
  10. class ProjectInfoManger : public QObject
  11. {
  12. Q_OBJECT
  13. public:
  14. explicit ProjectInfoManger(PackInfoManger *manger, QObject *parent = nullptr);
  15. enum ReqStatus
  16. {
  17. IDIL = 0,
  18. Load_Server_List = 1,
  19. Sync_Local_List = 2
  20. };
  21. inline QList<QSharedPointer<ProjectInfo>> serverInfo() {return _serverInfo;}
  22. inline QList<QSharedPointer<ProjectInfo>> cacheInfo() {return _cacheInfo;}
  23. signals:
  24. void inited(ProjectInfoManger * manger, bool inited);
  25. void synced(ProjectInfoManger * manger, bool inited);
  26. void sync();
  27. public slots:
  28. bool loadServerList(bool local);
  29. bool syncLocalList();
  30. void setStatus();
  31. void addNewProject(QSharedPointer<ProjectInfo> pro);
  32. private slots:
  33. void doSendLoad();
  34. void doSendCreate();
  35. void handleList();
  36. void result(int code, const QJsonObject & body);
  37. void handlSync(int code, const QJsonObject & body);
  38. void handleGetList(int code, const QJsonObject & body);
  39. void hanldeServerList(QJsonArray & ary,bool inServer = true);
  40. private:
  41. ReqStatus _status;
  42. QQueue<QSharedPointer<ProjectInfo>> _pushQueue;
  43. PackInfoManger * _manger;
  44. HttpRequest _requst;
  45. //saveed;
  46. QList<QSharedPointer<ProjectInfo>> _serverInfo;
  47. QList<QSharedPointer<ProjectInfo>> _cacheInfo;
  48. uint _oneSyncError;
  49. uint _netErrorCount;
  50. int _nowJob;
  51. };
  52. #endif // PROJECTINFOMANGER_H