projectinfomanger.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. public slots:
  27. bool loadServerList(bool local);
  28. bool syncLocalList();
  29. void setStatus();
  30. private slots:
  31. void doSendLoad();
  32. void doSendCreate();
  33. void handleList();
  34. void result(int code, const QJsonObject & body);
  35. void handlSync(int code, const QJsonObject & body);
  36. void handleGetList(int code, const QJsonObject & body);
  37. void hanldeServerList(QJsonArray & ary,bool inServer = true);
  38. private:
  39. ReqStatus _status;
  40. QQueue<QSharedPointer<ProjectInfo>> _pushQueue;
  41. PackInfoManger * _manger;
  42. HttpRequest _requst;
  43. //saveed;
  44. QList<QSharedPointer<ProjectInfo>> _serverInfo;
  45. QList<QSharedPointer<ProjectInfo>> _cacheInfo;
  46. uint _oneSyncError;
  47. uint _netErrorCount;
  48. int _nowJob;
  49. };
  50. #endif // PROJECTINFOMANGER_H