|
|
@@ -12,26 +12,30 @@ AutoPackUtils::AutoPackUtils()
|
|
|
* @brief 把打包数据存入本地数据库后,上传服务器打包数据
|
|
|
* @param info
|
|
|
*/
|
|
|
-void AutoPackUtils::doSend(QSharedPointer<PackInfo> &info)
|
|
|
+void AutoPackUtils::doSend(QJsonObject json)
|
|
|
{
|
|
|
- if(info.isNull()) return;
|
|
|
- //TODO:发送码单 packinfo 数据, 转换为 json数据发送
|
|
|
- QJsonObject json = toJson(info);
|
|
|
+ if(json.isEmpty()) return;
|
|
|
+ //保存码单,上传服务器成功后,以codeSingle为条件更改同步字段;
|
|
|
+ this->codeSingle = json["code_single"].toString();
|
|
|
+// qDebug()<<codeSingle;
|
|
|
+
|
|
|
_request.setUserToken(QString::number(GlobalInfo::this_()->user().accountId),GlobalInfo::this_()->user().acessToken);
|
|
|
// qDebug()<<QString::number(GlobalInfo::this_()->user().accountId);
|
|
|
// qDebug()<<GlobalInfo::this_()->user().acessToken;
|
|
|
+// _request.post(GlobalInfo::this_()->config().baseUrl+"/v1/product/pending",json);
|
|
|
|
|
|
-// _request.post(GlobalInfo::this_()->config().autoPackUrl,json);
|
|
|
-
|
|
|
-// qDebug()<<json;
|
|
|
-} // http://doc.vanlai.net:3001/web/#/1?page_id=64
|
|
|
+}
|
|
|
|
|
|
void AutoPackUtils::httpResult(int emitcode, const QJsonObject body)
|
|
|
{
|
|
|
qDebug()<<emitcode;
|
|
|
qDebug()<<body;
|
|
|
- if(emitcode==200&&body["product_id"].toInt()!=0){
|
|
|
- database.changeState(codeSingle);
|
|
|
+ if(emitcode==200&&body["message"].toString() == ""){
|
|
|
+ if(database.changeState(codeSingle)){
|
|
|
+ qDebug()<<"同步成功";
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ qDebug()<<"同步失败";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -61,8 +65,6 @@ void AutoPackUtils::insertDetailsSQL(QSharedPointer<BoxInfo> boxes,QString codeS
|
|
|
void AutoPackUtils::insertProductSQL(QSharedPointer<PackInfo> packes)
|
|
|
{
|
|
|
if(packes.isNull()) return;
|
|
|
- //保存码单,上传服务器成功后,以codeSingle为条件更改同步字段;
|
|
|
- this->codeSingle = packes->codeSingle();
|
|
|
|
|
|
productData.goods_id = packes->goodsID();
|
|
|
productData.code_single = packes->codeSingle();
|
|
|
@@ -92,9 +94,12 @@ void AutoPackUtils::insertProductSQL(QSharedPointer<PackInfo> packes)
|
|
|
//将打包数据转换为json数据
|
|
|
QJsonObject AutoPackUtils::toJson(QSharedPointer<PackInfo> &info)
|
|
|
{
|
|
|
+
|
|
|
QJsonObject json;
|
|
|
QJsonObject detailsjson;
|
|
|
QJsonArray jsonarray;
|
|
|
+ if(info.isNull()) return json;
|
|
|
+
|
|
|
for(int i = 0;i<info->boxes().size();i++){
|
|
|
detailsjson.insert("case_number",info->boxes().at(i)->caseNumber());
|
|
|
detailsjson.insert("box_weight",info->boxes().at(i)->box_weight);
|
|
|
@@ -123,5 +128,53 @@ QJsonObject AutoPackUtils::toJson(QSharedPointer<PackInfo> &info)
|
|
|
json.insert("remark",info->remark);
|
|
|
|
|
|
|
|
|
+ return json;
|
|
|
+}
|
|
|
+
|
|
|
+QJsonObject AutoPackUtils::toJsonMap(QMap<QString,QString> product,QList<QMap<QString,QString>> details)
|
|
|
+{
|
|
|
+// qDebug()<<"自动打包测试";
|
|
|
+// qDebug()<<details.at(0).value("code_single");
|
|
|
+ QJsonObject json;
|
|
|
+ QJsonObject detailsjson;
|
|
|
+ QJsonArray jsonarray;
|
|
|
+
|
|
|
+ if(product.isEmpty()){
|
|
|
+ qDebug()<<"product数据为空";
|
|
|
+ return json;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(details.isEmpty()){
|
|
|
+ qDebug()<<"details数据为空";
|
|
|
+ return json;
|
|
|
+ }
|
|
|
+
|
|
|
+ for(int i = 0;i<details.length();i++){
|
|
|
+ detailsjson.insert("case_number",details.at(i).value("case_number"));
|
|
|
+ detailsjson.insert("box_weight",details.at(i).value("box_weight"));
|
|
|
+ detailsjson.insert("tube_number",details.at(i).value("tube_number"));
|
|
|
+ detailsjson.insert("bucket_weight",details.at(i).value("bucket_weight"));
|
|
|
+ detailsjson.insert("gross_weight",details.at(i).value("gross_weight"));
|
|
|
+ detailsjson.insert("net_weight",details.at(i).value("net_weight"));
|
|
|
+ detailsjson.insert("box_weight",details.at(i).value("box_weight"));
|
|
|
+ detailsjson.insert("sort",details.at(i).value("sort"));
|
|
|
+ detailsjson.insert("remark",details.at(i).value("remark"));
|
|
|
+ jsonarray.append(detailsjson);
|
|
|
+ }
|
|
|
+ json.insert("goods_id",product.value("goods_id"));
|
|
|
+ json.insert("code_single",product.value("code_single"));
|
|
|
+ json.insert("quantity",product.value("quantity"));
|
|
|
+ json.insert("level_id",product.value("level_id"));
|
|
|
+ json.insert("tube_number",product.value("tube_number"));
|
|
|
+ json.insert("gross_weight",product.value("gross_weight"));
|
|
|
+ json.insert("net_weight",product.value("net_weight"));
|
|
|
+ json.insert("machine_no",product.value("machine_no"));
|
|
|
+ json.insert("packing_time",product.value("packing_time"));
|
|
|
+ json.insert("packing_type",product.value("packing_type"));
|
|
|
+ json.insert("carton_type",product.value("carton_type"));
|
|
|
+ json.insert("operator",product.value("operator_id"));
|
|
|
+ json.insert("details",jsonarray);
|
|
|
+ json.insert("remark",product.value("remark"));
|
|
|
+
|
|
|
return json;
|
|
|
}
|