#ifndef PACKINFOSEED2SERVER_H
#define PACKINFOSEED2SERVER_H

#include <QObject>
#include "httprequest.h"
#include "struct_/packinfo.h"
#include <QQueue>
#include "packinfomanger.h"
#include <pqQtlib/log/pqlog.h>
// 码单的上传
class PackInfoSeed2Server : public QObject
{
    Q_OBJECT
public:
    explicit PackInfoSeed2Server(PackInfoManger * manger,QObject *parent = nullptr,bool autoSync = false);

signals:
    void syncEnd();
public slots:
    void send(QSharedPointer<PackInfo> & info);
    void sendList(QList<QSharedPointer<PackInfo>> & infos);

private slots:
    void doSend();
    void result(int code, const QJsonObject & body);
private:
    uint _netErrorCount;
    QQueue<QSharedPointer<PackInfo>> _queue;
    QQueue<RuKuInfo> _rukuQueue;
    QSharedPointer<PackInfo> _current;
    RuKuInfo _rukuCurrent;
    PackInfoManger * _manger;
    HttpRequest _requst;
    HttpRequest _rukuRequest;//获取最近一次产品入库里的product_details_id
    HttpRequest _rukurequest;//把产品入库
    bool _autoSync;
    uint _oneSyncError;
    PQ::PQLog * log;
    bool isRuKu;
};

#endif // PACKINFOSEED2SERVER_H
