Preperationf for Zone3.

This commit is contained in:
Gerhard Hoffmann 2024-07-29 17:26:53 +02:00
parent ca3c3921d4
commit 14fd7ddd39

View File

@ -2258,121 +2258,82 @@ QList<int> &Calculator::GetTimeSteps(Configuration *cfg, int paymentOptionIndex,
if (w.has_value()) { if (w.has_value()) {
QVector<ATBWeekDaysWorktime> const &vec = w.value(); QVector<ATBWeekDaysWorktime> const &vec = w.value();
if (pop_carry_over) { if (pop_carry_over == false) {
for (int i = 0; i < vec.size(); ++i) { for (int i = 1; i <= vec.size(); ++i) {
QTime const &from = QTime::fromString(QString::fromStdString(vec[i].pwd_time_from), Qt::ISODate); QTime const &from = QTime::fromString(QString::fromStdString(vec[i-1].pwd_time_from), Qt::ISODate);
QString const &toStr = QString::fromStdString(vec[i].pwd_time_to); QString const &toStr = QString::fromStdString(vec[i-1].pwd_time_to);
QTime const &to = QTime::fromString(toStr, Qt::ISODate); QTime const &to = QTime::fromString(toStr, Qt::ISODate);
int weekDayId = vec[i].pwd_period_day_in_week_id; int weekDayId = vec[i-1].pwd_period_day_in_week_id;
if (start.date().dayOfWeek() == weekDayId) { if (start.date().dayOfWeek() == weekDayId) {
//qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << weekDayId; qCritical() << "(" << __func__ << ":" << __LINE__ << ")" << weekDayId;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") from" << from.toString(Qt::ISODate); qCritical() << "(" << __func__ << ":" << __LINE__ << ") from" << from.toString(Qt::ISODate);
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") to" << to.toString(Qt::ISODate); qCritical() << "(" << __func__ << ":" << __LINE__ << ") to" << to.toString(Qt::ISODate);
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") start" << start.toString(Qt::ISODate); qCritical() << "(" << __func__ << ":" << __LINE__ << ") start" << start.toString(Qt::ISODate);
if (start.time() >= from) { if (start.time() >= from && start.time() < to) {
qCritical() << "(" << __func__ << ":" << __LINE__ << ") from" << from.toString(Qt::ISODate); int runtimeInMinutes = (start.time().secsTo(to) / 60);
if (start.time() < to) { if (to.hour() == 23 && to.minute() == 59) {
qCritical() << "(" << __func__ << ":" << __LINE__ << ") start" << start.toString(Qt::ISODate); runtimeInMinutes += 1;
int runtimeInMinutes = (start.time().secsTo(to) / 60);
qCritical() << "(" << __func__ << ":" << __LINE__ << ") runTimeInMinutes" << runtimeInMinutes;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") index" << paymentOptionIndex;
m_timeSteps[paymentOptionIndex] << runtimeInMinutes;
cfg->getPaymentOptions(paymentOptionIndex).pop_min_time = runtimeInMinutes;
int pop_id = vec[i].pwd_pop_id;
int pwd_id = vec[i].pwd_id;
int pop_next_id = vec[i].pwd_next_id;
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
int const durationId = itr->second.pra_payment_unit_id;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") durationId" << durationId;
// int const price = itr->second.pra_price;
auto search = cfg->Duration.find(durationId);
if (search != cfg->Duration.end()) {
ATBDuration duration = search->second;
duration.pun_duration = runtimeInMinutes;
search->second = duration;
}
}
if (weekDayId == vec[pop_next_id].pwd_period_day_in_week_id) {
// on the same day
start.setTime(to);
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") next start" << start.toString(Qt::ISODate);
} else {
// on the next day
start.setTime(QTime::fromString(QString::fromStdString(vec[pop_next_id].pwd_time_from), Qt::ISODate));
start = start.addDays(1);
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") next start" << start.toString(Qt::ISODate);
}
while ((s.secsTo(start) / 60) < 5000) {
qCritical() << "(" << __func__ << ":" << __LINE__ << ") next start" << start.toString(Qt::ISODate);
pop_id = vec[i].pwd_pop_id;
pwd_id = vec[i].pwd_id;
pop_next_id = vec[i].pwd_next_id;
runtimeInMinutes += (start.time().secsTo(to) / 60);
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pwd_id " << pwd_id;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pop_id " << pop_id;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") pop_next_id " << pop_next_id;
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") nextTimeStep" << nextTimeStep;
// ATBPaymentOption o = cfg->getPaymentOptionForId();
m_timeSteps[paymentOptionIndex] << runtimeInMinutes;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") XXXXXX pop" << pop_id;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") XXXXXX index" << paymentOptionIndex;
#if 0
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
int const durationId = itr->second.pra_payment_unit_id;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") XXXXXX durationId" << durationId;
// int const price = itr->second.pra_price;
auto search = cfg->Duration.find(durationId);
if (search != cfg->Duration.end()) {
ATBDuration duration = search->second;
duration.pun_duration = runtimeInMinutes;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") XXXXXX durationId" << runtimeInMinutes;
search->second = duration;
}
}
#endif
if (weekDayId == vec[pop_next_id].pwd_period_day_in_week_id) {
// on the same day
start.setTime(to);
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") next start" << start.toString(Qt::ISODate);
} else {
// on the next day
start.setTime(QTime::fromString(QString::fromStdString(vec[pop_next_id].pwd_time_from), Qt::ISODate));
start = start.addDays(1);
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") next start" << start.toString(Qt::ISODate);
}
//qCritical() << "(" << __func__ << ":" << __LINE__ << ") until" << s.secsTo(start) / 60;
}
break;
} }
} qCritical() << "(" << __func__ << ":" << __LINE__ << ") runTimeInMinutes" << runtimeInMinutes;
} qCritical() << "(" << __func__ << ":" << __LINE__ << ") index" << paymentOptionIndex;
}
}
}
m_timeSteps[paymentOptionIndex] << runtimeInMinutes;
cfg->getPaymentOptions(paymentOptionIndex).pop_min_time = runtimeInMinutes;
int pop_id = vec[i-1].pwd_pop_id;
// int pwd_id = vec[i-1].pwd_id;
// int pwd_next_id = vec[i-1].pwd_next_id;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") pop_id" << pop_id;
int price = -1;
int durationId = -1;
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
durationId = itr->second.pra_payment_unit_id;
price = itr->second.pra_price;
auto search = cfg->Duration.find(durationId);
if (search != cfg->Duration.end()) {
ATBDuration duration = search->second;
duration.pun_duration = runtimeInMinutes;
search->second = duration;
break;
}
}
if (price >= 0 && durationId >= 0) {
qCritical() << "(" << __func__ << ":" << __LINE__ << ") durationId" << durationId;
qCritical() << "(" << __func__ << ":" << __LINE__ << ") price" << price;
pop_id = cfg->getPaymentOptions(paymentOptionIndex).pop_id;
for (auto[itr, rangeEnd] = cfg->PaymentRate.equal_range(pop_id); itr != rangeEnd; ++itr) {
if (durationId == itr->second.pra_payment_unit_id) {
itr->second.pra_price = price;
break;
}
}
}
break;
} // if (start.time() >= from && start.time() < to) {
} // if (start.date().dayOfWeek() == weekDayId) {
} // for (int i = 1; i <= vec.size(); ++i) {
// show content:
for (Configuration::TariffDurationType::const_iterator it = cfg->Duration.cbegin();
it != cfg->Duration.cend();
++it) {
qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
<< (*it).first << " => " << (*it).second;
}
} // if (pop_carry_over == false) {
} // if (w.has_value()) {
} else { } else {
uint16_t timeStepCompensation = 0; uint16_t timeStepCompensation = 0;