| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- #include "packinfo.h"
- #include "globalinfo.h"
- #include <QDateTime>
- int PackInfo::lastMin = 0;
- int PackInfo::lastNum = 1;
- PackInfo::PackInfo(const ProjectInfo & info) : _info(info)
- {
- code_single = buildPackId();
- }
- BoxInfo::BoxInfo(QSharedPointer<PackInfo> pack,QString code):case_number(code),parent(pack)
- {}
- QString PackInfo::buildPackId()
- {
- QDateTime now = QDateTime::currentDateTime();
- int min = now.time().minute();
- if(min != lastMin) lastNum = 1;
- else lastNum ++;
- QString packId = GlobalInfo::this_()->packNum() + now.toString("yyMMddhhmm") + QString::asprintf("%03d",lastNum);
- if(lastNum > 999) return QString();
- return packId;
- }
- QString PackInfo::buildBoxId()
- {
- int nowNum = boxes().size() + 1;
- QDateTime now = QDateTime::currentDateTime();
- QString id = now.toString("yyMMdd") + GlobalInfo::this_()->packNum() + QString::asprintf("%03d",nowNum);
- return id;
- }
- int PackInfo::tube_number()
- {
- int ret = 0;
- for(int i = 0; i < _boxes.size();++i){
- ret += _boxes.at(i)->tube_number;
- }
- return ret;
- }
- int PackInfo::gross_weight()
- {
- int ret = 0;
- for(int i = 0; i < _boxes.size();++i){
- ret += _boxes.at(i)->gross_weight;
- }
- return ret;
- }
- int PackInfo::net_weight()
- {
- int ret = 0;
- for(int i = 0; i < _boxes.size();++i){
- ret += _boxes.at(i)->net_weight;
- }
- return ret;
- }
- QSharedPointer<BoxInfo> PackInfo::addBoxInfo()
- {
- QSharedPointer<BoxInfo> ret(new BoxInfo(sharedFromThis(),buildBoxId()));
- return ret;
- }
- void PackInfo::addBoxInfoList(QSharedPointer<BoxInfo> boxes)
- {
- _boxes.append(boxes);
- }
|