62 prod->eq_tun_height = query.value("eq_tun_height").toDouble(); |
62 prod->eq_tun_height = query.value("eq_tun_height").toDouble(); |
63 prod->eq_top_up_water = query.value("eq_top_up_water").toDouble(); |
63 prod->eq_top_up_water = query.value("eq_top_up_water").toDouble(); |
64 prod->eq_trub_loss = query.value("eq_trub_loss").toDouble(); |
64 prod->eq_trub_loss = query.value("eq_trub_loss").toDouble(); |
65 prod->eq_evap_rate = query.value("eq_evap_rate").toDouble(); |
65 prod->eq_evap_rate = query.value("eq_evap_rate").toDouble(); |
66 prod->eq_boil_time = query.value("eq_boil_time").toDouble(); |
66 prod->eq_boil_time = query.value("eq_boil_time").toDouble(); |
67 // prod->eq_calc_boil_volume = query.value("eq_calc_boil_volume").toInt() ? true:false; |
|
68 prod->eq_top_up_kettle = query.value("eq_top_up_kettle").toDouble(); |
67 prod->eq_top_up_kettle = query.value("eq_top_up_kettle").toDouble(); |
69 // prod->eq_hop_utilization = query.value("eq_hop_utilization").toDouble(); |
|
70 // prod->eq_lauter_volume = query.value("eq_lauter_volume").toDouble(); |
|
71 // prod->eq_lauter_height = query.value("eq_lauter_height").toDouble(); |
|
72 prod->eq_lauter_deadspace = query.value("eq_lauter_deadspace").toDouble(); |
68 prod->eq_lauter_deadspace = query.value("eq_lauter_deadspace").toDouble(); |
73 prod->eq_kettle_volume = query.value("eq_kettle_volume").toDouble(); |
69 prod->eq_kettle_volume = query.value("eq_kettle_volume").toDouble(); |
74 prod->eq_kettle_height = query.value("eq_kettle_height").toDouble(); |
70 prod->eq_kettle_height = query.value("eq_kettle_height").toDouble(); |
75 prod->eq_mash_volume = query.value("eq_mash_volume").toDouble(); |
71 prod->eq_mash_volume = query.value("eq_mash_volume").toDouble(); |
76 prod->eq_mash_max = query.value("eq_mash_max").toDouble(); |
72 prod->eq_mash_max = query.value("eq_mash_max").toDouble(); |
436 if (parseError.error != QJsonParseError::NoError) { |
432 if (parseError.error != QJsonParseError::NoError) { |
437 qWarning() << "Parse error: " << parseError.errorString() << "at" << parseError.offset ; |
433 qWarning() << "Parse error: " << parseError.errorString() << "at" << parseError.offset ; |
438 } else if (yeasts.isArray()) { |
434 } else if (yeasts.isArray()) { |
439 for (int i = 0; i < yeasts.array().size(); i++) { |
435 for (int i = 0; i < yeasts.array().size(); i++) { |
440 QJsonObject obj = yeasts.array().at(i).toObject(); |
436 QJsonObject obj = yeasts.array().at(i).toObject(); |
|
437 qDebug() << "yeasts_Json" << i << obj; |
441 Yeasts y; |
438 Yeasts y; |
442 /* First some defaults for newer fields. */ |
439 /* First some defaults for newer fields. */ |
443 y.tolerance = y.harvest_time = y.pitch_temperature = y.zymocide = 0; |
440 y.tolerance = y.harvest_time = y.pitch_temperature = y.zymocide = 0; |
444 y.avail = y.sta1 = y.bacteria = y.harvest_top = y.pofpos = false; |
441 y.avail = y.sta1 = y.bacteria = y.harvest_top = y.pofpos = false; |
445 y.gr_hl_lo = 50; |
442 y.gr_hl_lo = 50; |
446 y.sg_lo = 1.04; |
443 y.sg_lo = 1.04; |
447 y.gr_hl_hi = 80; |
444 y.gr_hl_hi = 80; |
448 y.sg_hi = 1.08; |
445 y.sg_hi = 1.08; |
|
446 /* Clear Yeast Package data */ |
|
447 y.yp_uuid = QString(); |
|
448 y.yp_package = QString(); |
|
449 y.yp_cells = obj["y_cells"].toDouble(); |
|
450 y.yp_viability = 0.99; |
|
451 y.yp_max = 100; |
|
452 y.yp_size = 0.01; |
449 /* Now get what we have got */ |
453 /* Now get what we have got */ |
450 y.name = obj["y_name"].toString(); |
454 y.name = obj["y_name"].toString(); |
451 y.laboratory = obj["y_laboratory"].toString(); |
455 y.laboratory = obj["y_laboratory"].toString(); |
452 y.product_id = obj["y_product_id"].toString(); |
456 y.product_id = obj["y_product_id"].toString(); |
453 y.amount = obj["y_amount"].toDouble(); |
457 y.amount = obj["y_amount"].toDouble(); |
483 yquery.bindValue(":laboratory", y.laboratory); |
487 yquery.bindValue(":laboratory", y.laboratory); |
484 yquery.bindValue(":product_id", y.product_id); |
488 yquery.bindValue(":product_id", y.product_id); |
485 yquery.exec(); |
489 yquery.exec(); |
486 if (yquery.first()) { |
490 if (yquery.first()) { |
487 if (y.tolerance == 0 || y.cells == 0) { |
491 if (y.tolerance == 0 || y.cells == 0) { |
488 y.tolerance = yquery.value(0).toDouble(); |
492 y.tolerance = yquery.value("tolerance").toDouble(); |
489 y.cells = yquery.value(1).toDouble(); |
493 y.cells = yquery.value("cells").toDouble(); |
490 } |
494 } |
491 y.sta1 = yquery.value(2).toInt() ? true:false; |
495 y.sta1 = yquery.value("sta1").toInt() ? true:false; |
492 y.bacteria = yquery.value(3).toInt() ? true:false; |
496 y.bacteria = yquery.value("bacteria").toInt() ? true:false; |
493 y.harvest_top = yquery.value(4).toInt() ? true:false; |
497 y.harvest_top = yquery.value("harvest_top").toInt() ? true:false; |
494 y.harvest_time = yquery.value(5).toInt(); |
498 y.harvest_time = yquery.value("harvest_time").toInt(); |
495 y.pitch_temperature = yquery.value(6).toDouble(); |
499 y.pitch_temperature = yquery.value("pitch_temperature").toDouble(); |
496 y.pofpos = yquery.value(7).toInt() ? true:false; |
500 y.pofpos = yquery.value("pofpos").toInt() ? true:false; |
497 y.zymocide = yquery.value(8).toInt(); |
501 y.zymocide = yquery.value("zymocide").toInt(); |
498 y.gr_hl_lo = yquery.value(9).toInt(); |
502 y.gr_hl_lo = yquery.value("gr_hl_lo").toInt(); |
499 y.sg_lo = yquery.value(10).toDouble(); |
503 y.sg_lo = yquery.value("sg_lo").toDouble(); |
500 y.gr_hl_hi = yquery.value(11).toInt(); |
504 y.gr_hl_hi = yquery.value("gr_hl_hi").toInt(); |
501 y.sg_hi = yquery.value(12).toDouble(); |
505 y.sg_hi = yquery.value("sg_hi").toDouble(); |
502 y.inventory = yquery.value(13).toDouble(); |
506 y.inventory = yquery.value("inventory").toDouble(); |
503 y.avail = true; |
507 y.avail = true; |
504 } else { |
508 } else { |
505 qDebug() << y.name << y.product_id << "not found for upgrade"; |
509 qDebug() << y.name << y.product_id << "not found for upgrade"; |
506 } |
510 } |
|
511 /* |
|
512 * Yeast Pack. |
|
513 */ |
|
514 if (obj.contains("y_package") && obj["y_package"].isObject()) { |
|
515 qDebug() << "y_package object present"; |
|
516 QJsonObject package = obj.value("y_package").toObject(); |
|
517 qDebug() << "yeasts_Json package" << i << package; |
|
518 y.yp_uuid = package["uuid"].toString(); |
|
519 y.yp_package = package["package"].toString(); |
|
520 y.yp_cells = package["cells"].toDouble(); |
|
521 y.yp_viability = package["viability"].toDouble(); |
|
522 y.yp_max = package["max"].toInt(); |
|
523 y.yp_size = package["size"].toDouble(); |
|
524 } else { |
|
525 qDebug() << "y_package not present"; |
|
526 } |
|
527 |
507 prod->yeasts.append(y); |
528 prod->yeasts.append(y); |
508 } |
529 } |
509 // qDebug() << "yeasts" << prod->yeasts.size(); |
530 // qDebug() << "yeasts" << prod->yeasts.size(); |
510 } |
531 } |
511 } else { |
532 } else { |
971 obj.insert("y_gr_hl_lo", prod->yeasts.at(i).gr_hl_lo); |
992 obj.insert("y_gr_hl_lo", prod->yeasts.at(i).gr_hl_lo); |
972 obj.insert("y_sg_lo", round(prod->yeasts.at(i).sg_lo * 1000) / 1000); |
993 obj.insert("y_sg_lo", round(prod->yeasts.at(i).sg_lo * 1000) / 1000); |
973 obj.insert("y_gr_hl_hi", prod->yeasts.at(i).gr_hl_hi); |
994 obj.insert("y_gr_hl_hi", prod->yeasts.at(i).gr_hl_hi); |
974 obj.insert("y_sg_hi", round(prod->yeasts.at(i).sg_hi * 1000) / 1000); |
995 obj.insert("y_sg_hi", round(prod->yeasts.at(i).sg_hi * 1000) / 1000); |
975 obj.insert("y_cost", round(prod->yeasts.at(i).cost * 1000) / 1000); |
996 obj.insert("y_cost", round(prod->yeasts.at(i).cost * 1000) / 1000); |
976 // qDebug() << "yeasts_Json" << i << obj; |
997 if (! product->yeasts.at(i).yp_uuid.isNull() && (product->yeasts.at(i).yp_uuid.length() == 36)) { |
|
998 qDebug() << "yeasts_Json append package"; |
|
999 QJsonObject package; |
|
1000 package.insert("uuid", prod->yeasts.at(i).yp_uuid); |
|
1001 package.insert("package", prod->yeasts.at(i).yp_package); |
|
1002 package.insert("cells", prod->yeasts.at(i).yp_cells); |
|
1003 package.insert("viability", round(prod->yeasts.at(i).yp_viability * 10000) / 10000); |
|
1004 package.insert("max", prod->yeasts.at(i).yp_max); |
|
1005 package.insert("size", round(prod->yeasts.at(i).yp_size * 100000) / 100000); |
|
1006 obj.insert("y_package", package); |
|
1007 } |
|
1008 qDebug() << "yeasts_Json" << i << obj; |
977 array.append(obj); /* Append this object */ |
1009 array.append(obj); /* Append this object */ |
978 } |
1010 } |
979 QJsonDocument doc; |
1011 QJsonDocument doc; |
980 doc.setArray(array); |
1012 doc.setArray(array); |
981 query.bindValue(":json_yeasts", doc.toJson(QJsonDocument::Compact)); |
1013 query.bindValue(":json_yeasts", doc.toJson(QJsonDocument::Compact)); |