packinfo.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. #ifndef PACKINFO_H
  2. #define PACKINFO_H
  3. #include "QJsonArray"
  4. #include "projectinfo.h"
  5. #include <QSharedPointer>
  6. #include <QString>
  7. QString getDecimalbit(double v, int i = 2);
  8. class PackInfo;
  9. struct RuKuInfo
  10. {
  11. int warehouse_id;
  12. int way;
  13. QJsonArray product_details;
  14. int product_id;
  15. QString remark;
  16. QJsonObject toObject();
  17. };
  18. struct BoxInfo
  19. {
  20. inline QSharedPointer<PackInfo> parentPack() { return parent.toStrongRef(); }
  21. inline QString caseNumber() { return case_number; }
  22. int box_weight = 0; // 是 int 皮重 单位:克
  23. int tube_number = 0; // 是 int 筒数
  24. int bucket_weight = 0; // 是 int 总筒重 单位:克
  25. int gross_weight = 0; // 是 int 毛重 单位:克
  26. int net_weight = 0; // 是 int 净重 单位:克
  27. QString Level; //等级;
  28. QString twist_type; // string 捻向
  29. QString bucket_color; // string 管色
  30. QString sort; // 是 string 排序
  31. QString remark; // 否 string 备注
  32. QJsonObject toObject();
  33. static QSharedPointer<BoxInfo> fromObject(QSharedPointer<PackInfo> &pack, QJsonObject &obj);
  34. BoxInfo(QSharedPointer<PackInfo> pack, QString code);
  35. private:
  36. QString case_number; // 是 string 箱号
  37. QWeakPointer<PackInfo> parent;
  38. friend class PackInfo;
  39. };
  40. Q_DECLARE_METATYPE(QSharedPointer<BoxInfo>);
  41. class PackInfo : public QEnableSharedFromThis<PackInfo>
  42. {
  43. public:
  44. PackInfo(const QSharedPointer<ProjectInfo> &info);
  45. int quantity = 0; // 是 int 箱数
  46. int level_id = 0; // 是 int 等级ID
  47. QString level;
  48. QString machine_no; // 是 string 机台
  49. QString packing_time; // 是 string 打包时间
  50. QString packing_type; // 是 string 打包类型
  51. QString carton_type; // 是 string 纸箱
  52. QString operator_id; // 是 int 操作员ID
  53. QString batch_no; //批号
  54. bool autoRuku; // 打包及入库是否点击
  55. int warehouse_id = 0; //仓库id
  56. QString remark; // 否 string
  57. QString telephone; // 公司
  58. QString customer; // 抬头
  59. QString address;
  60. int packType; // 0 定重,1 不定重
  61. inline const QList<QSharedPointer<BoxInfo>> &boxes() const { return _boxes; } // array 成品详情
  62. inline const QSharedPointer<ProjectInfo> &info() const { return _info; }
  63. inline QString codeSingle() const { return code_single; } // string 码单
  64. int tube_number(); // int 筒数
  65. int gross_weight(); // 毛重 单位:克
  66. int net_weight(); //单位:克
  67. int goodsID() { return goods_id; }
  68. inline qint64 time() { return _time; }
  69. QSharedPointer<BoxInfo> addBoxInfo();
  70. void addBoxInfoList(QSharedPointer<BoxInfo> boxes);
  71. void delBoxInfoAt(int num);
  72. QSharedPointer<BoxInfo> boxInfoAt(int num);
  73. int boxInfoSize();
  74. void upInfo(const QSharedPointer<ProjectInfo> &info)
  75. {
  76. _info = info;
  77. if (!info.isNull())
  78. goods_id = info->goods_id;
  79. }
  80. QJsonObject toObject();
  81. static QSharedPointer<PackInfo> fromObject(QJsonObject &obj);
  82. private:
  83. QString buildPackId();
  84. QString buildBoxId();
  85. private:
  86. QList<QSharedPointer<BoxInfo>> _boxes;
  87. QSharedPointer<ProjectInfo> _info;
  88. QString code_single;
  89. int goods_id;
  90. qint64 _time;
  91. int _boxIndex;
  92. static int lastMin;
  93. static int lastNum;
  94. };
  95. Q_DECLARE_METATYPE(QSharedPointer<PackInfo>);
  96. #endif // PACKINFO_H