846 lines
17 KiB
C++
846 lines
17 KiB
C++
#include "Utils.h"
|
|||
|
|
|
||
|
|
Utils::Utils()
|
||
|
|
{
|
||
|
|
}
|
||
|
|
|
||
|
|
Utils::~Utils()
|
||
|
|
{
|
||
|
|
}
|
||
|
|
|
||
|
|
Utils& Utils::instance()
|
||
|
|
{
|
||
|
|
static Utils m_instance;
|
||
|
|
return m_instance;
|
||
|
|
}
|
||
|
|
|
||
|
|
// 函数用于在model中查找特定文本,并返回找到的第一个项的索引
|
||
|
|
QModelIndex Utils::findItem(QStandardItemModel *model, const QString &text) {
|
||
|
|
for (int row = 0; row < model->rowCount(); ++row) {
|
||
|
|
for (int column = 0; column < model->columnCount(); ++column) {
|
||
|
|
QModelIndex index = model->index(row, column);
|
||
|
|
QStandardItem *item = model->itemFromIndex(index);
|
||
|
|
if (item && item->text() == text) {
|
||
|
|
return index;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return QModelIndex(); // 如果没有找到,返回一个无效的QModelIndex
|
||
|
|
}
|
||
|
|
|
||
|
|
QString Utils::convertToBase(const QString& input) {
|
||
|
|
// 假设输入字符串的格式是 "前缀_数字"
|
||
|
|
// 使用'_'作为分隔符来分割字符串
|
||
|
|
QStringList parts = input.split('_');
|
||
|
|
|
||
|
|
// 检查是否成功分割出至少两部分
|
||
|
|
if (parts.size() > 0) {
|
||
|
|
// 返回第一部分,即前缀
|
||
|
|
return parts.first();
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
// 如果没有'_'或者输入为空,则直接返回原字符串
|
||
|
|
return input;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
QString Utils::getTypeName(QString rtype)
|
||
|
|
{
|
||
|
|
// 让球
|
||
|
|
if (rtype == "REH" || rtype == "RH" || rtype == "HREH" || rtype == "HRH")
|
||
|
|
{
|
||
|
|
return "让球";
|
||
|
|
}
|
||
|
|
|
||
|
|
// 受让
|
||
|
|
if (rtype == "REC" || rtype == "RC" || rtype == "HREC" || rtype == "HRC")
|
||
|
|
{
|
||
|
|
return "受让";
|
||
|
|
}
|
||
|
|
// 大
|
||
|
|
if (rtype == "ROUC" || rtype == "OUC" || rtype == "HROUC" || rtype == "HOUC")
|
||
|
|
{
|
||
|
|
return "大";
|
||
|
|
}
|
||
|
|
// 小
|
||
|
|
if (rtype == "ROUH" || rtype == "OUH" || rtype == "HROUH" || rtype == "HOUH")
|
||
|
|
{
|
||
|
|
return "小";
|
||
|
|
}
|
||
|
|
// 独赢主
|
||
|
|
if (rtype == "RMH" || rtype == "MH" || rtype == "HRMH" || rtype == "HMH")
|
||
|
|
{
|
||
|
|
return "独赢主";
|
||
|
|
}
|
||
|
|
// 独赢客
|
||
|
|
if (rtype == "RMC" || rtype == "MC" || rtype == "HRMC" || rtype == "HMC")
|
||
|
|
{
|
||
|
|
return "独赢客";
|
||
|
|
}
|
||
|
|
// 独赢和
|
||
|
|
if (rtype == "RMN" || rtype == "MN" || rtype == "HRMN" || rtype == "HMN")
|
||
|
|
{
|
||
|
|
return "独赢和";
|
||
|
|
}
|
||
|
|
// 单
|
||
|
|
if (rtype == "REOO" || rtype == "EOO" || rtype == "HREOO" || rtype == "HEOO")
|
||
|
|
{
|
||
|
|
return "单";
|
||
|
|
}
|
||
|
|
// 双
|
||
|
|
if (rtype == "REOE" || rtype == "EOE" || rtype == "HREOE" || rtype == "HEOE")
|
||
|
|
{
|
||
|
|
return "双";
|
||
|
|
}
|
||
|
|
|
||
|
|
// 改
|
||
|
|
//// 单
|
||
|
|
//if (rtype == "RODD" || rtype == "ODD" || rtype == "HRODD" || rtype == "HODD")
|
||
|
|
//{
|
||
|
|
// return "单";
|
||
|
|
//}
|
||
|
|
//// 双
|
||
|
|
//if (rtype == "REVEN" || rtype == "EVEN" || rtype == "HREVEN" || rtype == "HEVEN")
|
||
|
|
//{
|
||
|
|
// return "双";
|
||
|
|
//}
|
||
|
|
|
||
|
|
// 主队大
|
||
|
|
if (rtype == "ROUHO" || rtype == "OUHO" || rtype == "HROUHO" || rtype == "HOUHO")
|
||
|
|
{
|
||
|
|
return "主队大";
|
||
|
|
}
|
||
|
|
// 主队小
|
||
|
|
if (rtype == "ROUHU" || rtype == "OUHU" || rtype == "HROUHU" || rtype == "HOUHU")
|
||
|
|
{
|
||
|
|
return "主队小";
|
||
|
|
}
|
||
|
|
// 客队大
|
||
|
|
if (rtype == "ROUCO" || rtype == "OUCO" || rtype == "HROUCO" || rtype == "HOUCO")
|
||
|
|
{
|
||
|
|
return "客队大";
|
||
|
|
}
|
||
|
|
// 客队小
|
||
|
|
if (rtype == "ROUCU" || rtype == "OUCU" || rtype == "HROUCU" || rtype == "HOUCU")
|
||
|
|
{
|
||
|
|
return "客队小";
|
||
|
|
}
|
||
|
|
return QString();
|
||
|
|
}
|
||
|
|
|
||
|
|
QString Utils::get_wagers_wtype_name(QString wtype)
|
||
|
|
{
|
||
|
|
// 滚球 RE 让球 ROU大小 RM独赢 HRE 让球上半 HROU 大小上半 HRM 独赢上半 RG下个进球 RTS双方球队进球
|
||
|
|
// 滚球全场 REO单双
|
||
|
|
|
||
|
|
if (wtype == "R" || wtype == "RE" || wtype == "HR" || wtype == "HRE")
|
||
|
|
{
|
||
|
|
return "让球";
|
||
|
|
}
|
||
|
|
if (wtype == "OU" || wtype == "ROU" || wtype == "HOU" || wtype == "HROU")
|
||
|
|
{
|
||
|
|
return "大小";
|
||
|
|
}
|
||
|
|
if (wtype == "M" || wtype == "RM" || wtype == "HM" || wtype == "HRM")
|
||
|
|
{
|
||
|
|
return "独赢";
|
||
|
|
}
|
||
|
|
if (wtype == "G" || wtype == "RG" || wtype == "HG" || wtype == "HRG")
|
||
|
|
{
|
||
|
|
return "下个进球";
|
||
|
|
}
|
||
|
|
if (wtype == "TS" || wtype == "RTS" || wtype == "HTS" || wtype == "HRTS")
|
||
|
|
{
|
||
|
|
return "双方球队进球";
|
||
|
|
}
|
||
|
|
if (wtype == "EO" || wtype == "REO" || wtype == "HEO" || wtype == "HREO") // RT 滚球单双 EO 早盘单双
|
||
|
|
{
|
||
|
|
return "单双"; // ODD / EVEN ?
|
||
|
|
}
|
||
|
|
if (wtype == "OUH" || wtype == "ROUH" || wtype == "HOUH" || wtype == "HROUH")
|
||
|
|
{
|
||
|
|
return "队伍1进球";
|
||
|
|
}
|
||
|
|
if (wtype == "OUC" || wtype == "ROUC" || wtype == "HOUC" || wtype == "HROUC")
|
||
|
|
{
|
||
|
|
return "队伍2进球";
|
||
|
|
}
|
||
|
|
if (wtype == "SH" || wtype == "RSH" || wtype == "HSH" || wtype == "HRSH")
|
||
|
|
{
|
||
|
|
return "下个点球";
|
||
|
|
}
|
||
|
|
|
||
|
|
return "";
|
||
|
|
// R 让球
|
||
|
|
// OU 大小
|
||
|
|
// M 独赢
|
||
|
|
// HR 让球上半场
|
||
|
|
// HOU 大小上半场
|
||
|
|
// HM 独赢上半场
|
||
|
|
|
||
|
|
// TS 双方进球 TSY 是/ TSN 否
|
||
|
|
// EO 单双
|
||
|
|
}
|
||
|
|
|
||
|
|
//QMap<QString, QString> Utils::type(QString projcet, QString type)
|
||
|
|
//{
|
||
|
|
// QMap<QString, QString> map;
|
||
|
|
// map["projcet"] = projcet;
|
||
|
|
// map["type"] = type;
|
||
|
|
// if (projcet == "足球滚球全场")
|
||
|
|
// {
|
||
|
|
// map["gtype"] = "FT";
|
||
|
|
// map["session"] = "RB";
|
||
|
|
// if (type == "让球")
|
||
|
|
// {
|
||
|
|
// map["wtype"] = "RE";
|
||
|
|
// map["rtype"] = "REH";
|
||
|
|
// }
|
||
|
|
// else if (type == "受让")
|
||
|
|
// {
|
||
|
|
// map["wtype"] = "RE";
|
||
|
|
// map["rtype"] = "REC";
|
||
|
|
// }
|
||
|
|
// else if (type == "大")
|
||
|
|
// {
|
||
|
|
// map["wtype"] = "ROU";
|
||
|
|
// map["rtype"] = "ROUC";
|
||
|
|
// }
|
||
|
|
// else if (type == "小")
|
||
|
|
// {
|
||
|
|
// map["wtype"] = "ROU";
|
||
|
|
// map["rtype"] = "ROUH";
|
||
|
|
// }
|
||
|
|
// else if (type == "独赢主")
|
||
|
|
// {
|
||
|
|
// map["wtype"] = "RM";
|
||
|
|
// map["rtype"] = "RMH";
|
||
|
|
// }
|
||
|
|
// else if (type == "独赢客")
|
||
|
|
// {
|
||
|
|
// map["wtype"] = "RM";
|
||
|
|
// map["rtype"] = "RMC";
|
||
|
|
// }
|
||
|
|
// else if (type == "独赢和")
|
||
|
|
// {
|
||
|
|
// map["wtype"] = "RM";
|
||
|
|
// map["rtype"] = "RMN";
|
||
|
|
// }
|
||
|
|
// else if (type == "单")
|
||
|
|
// {
|
||
|
|
// map["wtype"] = "REO";
|
||
|
|
// map["rtype"] = "REOO";
|
||
|
|
// }
|
||
|
|
// else if (type == "双")
|
||
|
|
// {
|
||
|
|
// map["wtype"] = "REO";
|
||
|
|
// map["rtype"] = "REOE";
|
||
|
|
// }
|
||
|
|
// else if (type == "主队大")
|
||
|
|
// {
|
||
|
|
// map["wtype"] = "ROUH";
|
||
|
|
// map["rtype"] = "ROUHO";
|
||
|
|
// }
|
||
|
|
// else if (type == "主队小")
|
||
|
|
// {
|
||
|
|
// map["wtype"] = "ROUH";
|
||
|
|
// map["rtype"] = "ROUHU";
|
||
|
|
// }
|
||
|
|
// else if (type == "客队大")
|
||
|
|
// {
|
||
|
|
// map["wtype"] = "ROUC";
|
||
|
|
// map["rtype"] = "ROUCO";
|
||
|
|
// }
|
||
|
|
// else if (type == "客队小")
|
||
|
|
// {
|
||
|
|
// map["wtype"] = "ROUC";
|
||
|
|
// map["rtype"] = "ROUCU";
|
||
|
|
// }
|
||
|
|
// }
|
||
|
|
// else if (projcet == "足球滚球上半场")
|
||
|
|
// {
|
||
|
|
// map["gtype"] = "FT";
|
||
|
|
// map["session"] = "RB";
|
||
|
|
// if (type == "让球")
|
||
|
|
// {
|
||
|
|
// map["wtype"] = "HRE";
|
||
|
|
// map["rtype"] = "HREH";
|
||
|
|
// }
|
||
|
|
// else if (type == "受让")
|
||
|
|
// {
|
||
|
|
// map["wtype"] = "HRE";
|
||
|
|
// map["rtype"] = "HREC";
|
||
|
|
// }
|
||
|
|
// else if (type == "大")
|
||
|
|
// {
|
||
|
|
// map["wtype"] = "HROU";
|
||
|
|
// map["rtype"] = "HROUC";
|
||
|
|
// }
|
||
|
|
// else if (type == "小")
|
||
|
|
// {
|
||
|
|
// map["wtype"] = "HROU";
|
||
|
|
// map["rtype"] = "HROUH";
|
||
|
|
// }
|
||
|
|
// else if (type == "独赢主")
|
||
|
|
// {
|
||
|
|
// map["wtype"] = "HRM";
|
||
|
|
// map["rtype"] = "HRMH";
|
||
|
|
// }
|
||
|
|
// else if (type == "独赢客")
|
||
|
|
// {
|
||
|
|
// map["wtype"] = "HRM";
|
||
|
|
// map["rtype"] = "HRMC";
|
||
|
|
// }
|
||
|
|
// else if (type == "独赢和")
|
||
|
|
// {
|
||
|
|
// map["wtype"] = "HRM";
|
||
|
|
// map["rtype"] = "HRMN";
|
||
|
|
// }
|
||
|
|
// else if (type == "单")
|
||
|
|
// {
|
||
|
|
// map["wtype"] = "HREO";
|
||
|
|
// map["rtype"] = "HREOO";
|
||
|
|
// }
|
||
|
|
// else if (type == "双")
|
||
|
|
// {
|
||
|
|
// map["wtype"] = "HREO";
|
||
|
|
// map["rtype"] = "HREOE";
|
||
|
|
// }
|
||
|
|
// else if (type == "主队大")
|
||
|
|
// {
|
||
|
|
// map["wtype"] = "HROUH";
|
||
|
|
// map["rtype"] = "HROUHO";
|
||
|
|
// }
|
||
|
|
// else if (type == "主队小")
|
||
|
|
// {
|
||
|
|
// map["wtype"] = "HROUH";
|
||
|
|
// map["rtype"] = "HROUHU";
|
||
|
|
// }
|
||
|
|
// else if (type == "客队大")
|
||
|
|
// {
|
||
|
|
// map["wtype"] = "HROUC";
|
||
|
|
// map["rtype"] = "HROUCO";
|
||
|
|
// }
|
||
|
|
// else if (type == "客队小")
|
||
|
|
// {
|
||
|
|
// map["wtype"] = "HROUC";
|
||
|
|
// map["rtype"] = "HROUCU";
|
||
|
|
// }
|
||
|
|
// }
|
||
|
|
// else if (projcet == "足球今日全场")
|
||
|
|
// {
|
||
|
|
// map["gtype"] = "FT";
|
||
|
|
// map["session"] = "FT";
|
||
|
|
// if (type == "让球")
|
||
|
|
// {
|
||
|
|
// map["wtype"] = "R";
|
||
|
|
// map["rtype"] = "RH";
|
||
|
|
// }
|
||
|
|
// else if (type == "受让")
|
||
|
|
// {
|
||
|
|
// map["wtype"] = "R";
|
||
|
|
// map["rtype"] = "RC";
|
||
|
|
// }
|
||
|
|
// else if (type == "大")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "OUC";
|
||
|
|
// }
|
||
|
|
// else if (type == "小")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "OUH";
|
||
|
|
// }
|
||
|
|
// else if (type == "独赢主")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "MH";
|
||
|
|
// }
|
||
|
|
// else if (type == "独赢客")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "MC";
|
||
|
|
// }
|
||
|
|
// else if (type == "独赢和")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "MN";
|
||
|
|
// }
|
||
|
|
// else if (type == "单")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "EOO";
|
||
|
|
// }
|
||
|
|
// else if (type == "双")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "EOE";
|
||
|
|
// }
|
||
|
|
// else if (type == "主队大")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "OUHO";
|
||
|
|
// }
|
||
|
|
// else if (type == "主队小")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "OUHU";
|
||
|
|
// }
|
||
|
|
// else if (type == "客队大")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "OUCO";
|
||
|
|
// }
|
||
|
|
// else if (type == "客队小")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "OUCU";
|
||
|
|
// }
|
||
|
|
// }
|
||
|
|
// else if (projcet == "足球今日上半场")
|
||
|
|
// {
|
||
|
|
// map["gtype"] = "FT";
|
||
|
|
// map["session"] = "FT";
|
||
|
|
// if (type == "让球")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "HRH";
|
||
|
|
// }
|
||
|
|
// else if (type == "受让")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "HRC";
|
||
|
|
// }
|
||
|
|
// else if (type == "大")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "HOUC";
|
||
|
|
// }
|
||
|
|
// else if (type == "小")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "HOUH";
|
||
|
|
// }
|
||
|
|
// else if (type == "独赢主")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "HMH";
|
||
|
|
// }
|
||
|
|
// else if (type == "独赢客")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "HMC";
|
||
|
|
// }
|
||
|
|
// else if (type == "独赢和")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "HMN";
|
||
|
|
// }
|
||
|
|
// else if (type == "单")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "HEOO";
|
||
|
|
// }
|
||
|
|
// else if (type == "双")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "HEOE";
|
||
|
|
// }
|
||
|
|
// else if (type == "主队大")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "HOUHO";
|
||
|
|
// }
|
||
|
|
// else if (type == "主队小")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "HOUHU";
|
||
|
|
// }
|
||
|
|
// else if (type == "客队大")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "HOUCO";
|
||
|
|
// }
|
||
|
|
// else if (type == "客队小")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "HOUCU";
|
||
|
|
// }
|
||
|
|
// }
|
||
|
|
// else if (projcet == "足球早盘全场")
|
||
|
|
// {
|
||
|
|
// map["gtype"] = "FT";
|
||
|
|
// map["session"] = "FU";
|
||
|
|
// if (type == "让球")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "RH";
|
||
|
|
// }
|
||
|
|
// else if (type == "受让")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "RC";
|
||
|
|
// }
|
||
|
|
// else if (type == "大")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "OUC";
|
||
|
|
// }
|
||
|
|
// else if (type == "小")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "OUH";
|
||
|
|
// }
|
||
|
|
// else if (type == "独赢主")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "MH";
|
||
|
|
// }
|
||
|
|
// else if (type == "独赢客")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "MC";
|
||
|
|
// }
|
||
|
|
// else if (type == "独赢和")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "MN";
|
||
|
|
// }
|
||
|
|
// else if (type == "单")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "EOO";
|
||
|
|
// }
|
||
|
|
// else if (type == "双")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "EOE";
|
||
|
|
// }
|
||
|
|
// else if (type == "主队大")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "OUHO";
|
||
|
|
// }
|
||
|
|
// else if (type == "主队小")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "OUHU";
|
||
|
|
// }
|
||
|
|
// else if (type == "客队大")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "OUCO";
|
||
|
|
// }
|
||
|
|
// else if (type == "客队小")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "OUCU";
|
||
|
|
// }
|
||
|
|
// }
|
||
|
|
// else if (projcet == "足球早盘上半场")
|
||
|
|
// {
|
||
|
|
// map["gtype"] = "FT";
|
||
|
|
// map["session"] = "FU";
|
||
|
|
// if (type == "让球")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "HRH";
|
||
|
|
// }
|
||
|
|
// else if (type == "受让")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "HRC";
|
||
|
|
// }
|
||
|
|
// else if (type == "大")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "HOUC";
|
||
|
|
// }
|
||
|
|
// else if (type == "小")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "HOUH";
|
||
|
|
// }
|
||
|
|
// else if (type == "独赢主")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "HMH";
|
||
|
|
// }
|
||
|
|
// else if (type == "独赢客")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "HMC";
|
||
|
|
// }
|
||
|
|
// else if (type == "独赢和")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "HMN";
|
||
|
|
// }
|
||
|
|
// else if (type == "单")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "HEOO";
|
||
|
|
// }
|
||
|
|
// else if (type == "双")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "HEOE";
|
||
|
|
// }
|
||
|
|
// else if (type == "主队大")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "HOUHO";
|
||
|
|
// }
|
||
|
|
// else if (type == "主队小")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "HOUHU";
|
||
|
|
// }
|
||
|
|
// else if (type == "客队大")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "HOUCO";
|
||
|
|
// }
|
||
|
|
// else if (type == "客队小")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "HOUCU";
|
||
|
|
// }
|
||
|
|
// }
|
||
|
|
// else if (projcet == "篮球滚球全场")
|
||
|
|
// {
|
||
|
|
// map["gtype"] = "BK";
|
||
|
|
// map["session"] = "RB";
|
||
|
|
// if (type == "让球")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "REH";
|
||
|
|
// }
|
||
|
|
// else if (type == "受让")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "REC";
|
||
|
|
// }
|
||
|
|
// else if (type == "大")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "ROUC";
|
||
|
|
// }
|
||
|
|
// else if (type == "小")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "ROUH";
|
||
|
|
// }
|
||
|
|
// else if (type == "独赢主")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "RMH";
|
||
|
|
// }
|
||
|
|
// else if (type == "独赢客")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "RMC";
|
||
|
|
// }
|
||
|
|
// else if (type == "独赢和")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "RMN";
|
||
|
|
// }
|
||
|
|
// else if (type == "单")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "REOO";
|
||
|
|
// }
|
||
|
|
// else if (type == "双")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "REOE";
|
||
|
|
// }
|
||
|
|
// else if (type == "主队大")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "ROUHO";
|
||
|
|
// }
|
||
|
|
// else if (type == "主队小")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "ROUHU";
|
||
|
|
// }
|
||
|
|
// else if (type == "客队大")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "ROUCO";
|
||
|
|
// }
|
||
|
|
// else if (type == "客队小")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "ROUCU";
|
||
|
|
// }
|
||
|
|
// }
|
||
|
|
// else if (projcet == "篮球今日全场")
|
||
|
|
// {
|
||
|
|
// map["gtype"] = "BK";
|
||
|
|
// map["session"] = "FT";
|
||
|
|
// if (type == "让球")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "RH";
|
||
|
|
// }
|
||
|
|
// else if (type == "受让")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "RC";
|
||
|
|
// }
|
||
|
|
// else if (type == "大")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "OUC";
|
||
|
|
// }
|
||
|
|
// else if (type == "小")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "OUH";
|
||
|
|
// }
|
||
|
|
// else if (type == "独赢主")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "MH";
|
||
|
|
// }
|
||
|
|
// else if (type == "独赢客")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "MC";
|
||
|
|
// }
|
||
|
|
// else if (type == "独赢和")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "MN";
|
||
|
|
// }
|
||
|
|
// else if (type == "单")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "EOO";
|
||
|
|
// }
|
||
|
|
// else if (type == "双")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "EOE";
|
||
|
|
// }
|
||
|
|
// else if (type == "主队大")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "OUHO";
|
||
|
|
// }
|
||
|
|
// else if (type == "主队小")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "OUHU";
|
||
|
|
// }
|
||
|
|
// else if (type == "客队大")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "OUCO";
|
||
|
|
// }
|
||
|
|
// else if (type == "客队小")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "OUCU";
|
||
|
|
// }
|
||
|
|
// }
|
||
|
|
// else if (projcet == "篮球早盘全场")
|
||
|
|
// {
|
||
|
|
// map["gtype"] = "BK";
|
||
|
|
// map["session"] = "FU";
|
||
|
|
// if (type == "让球")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "RH";
|
||
|
|
// }
|
||
|
|
// else if (type == "受让")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "RC";
|
||
|
|
// }
|
||
|
|
// else if (type == "大")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "OUC";
|
||
|
|
// }
|
||
|
|
// else if (type == "小")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "OUH";
|
||
|
|
// }
|
||
|
|
// else if (type == "独赢主")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "MH";
|
||
|
|
// }
|
||
|
|
// else if (type == "独赢客")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "MC";
|
||
|
|
// }
|
||
|
|
// else if (type == "独赢和")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "MN";
|
||
|
|
// }
|
||
|
|
// else if (type == "单")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "EOO";
|
||
|
|
// }
|
||
|
|
// else if (type == "双")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "EOE";
|
||
|
|
// }
|
||
|
|
// else if (type == "主队大")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "OUHO";
|
||
|
|
// }
|
||
|
|
// else if (type == "主队小")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "OUHU";
|
||
|
|
// }
|
||
|
|
// else if (type == "客队大")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "OUCO";
|
||
|
|
// }
|
||
|
|
// else if (type == "客队小")
|
||
|
|
// {
|
||
|
|
// map["rtype"] = "OUCU";
|
||
|
|
// }
|
||
|
|
// }
|
||
|
|
// return map;
|
||
|
|
//}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
#include <string>
|
||
|
|
#include <cctype>
|
||
|
|
|
||
|
|
#ifdef _WIN32
|
||
|
|
#include <windows.h>
|
||
|
|
#else
|
||
|
|
#include <unistd.h>
|
||
|
|
#include <limits.h>
|
||
|
|
#endif
|
||
|
|
|
||
|
|
int Utils::get_number_of_application_name() {
|
||
|
|
std::string filepath;
|
||
|
|
|
||
|
|
// 获取可执行文件完整路径
|
||
|
|
#ifdef _WIN32
|
||
|
|
char buffer[MAX_PATH];
|
||
|
|
GetModuleFileNameA(nullptr, buffer, MAX_PATH);
|
||
|
|
filepath = buffer;
|
||
|
|
#else
|
||
|
|
char buffer[PATH_MAX];
|
||
|
|
ssize_t len = readlink("/proc/self/exe", buffer, sizeof(buffer) - 1);
|
||
|
|
if (len != -1) {
|
||
|
|
buffer[len] = '\0';
|
||
|
|
filepath = buffer;
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
|
// 从完整路径中提取文件名
|
||
|
|
std::string filename;
|
||
|
|
size_t lastSlash = filepath.find_last_of("/\\");
|
||
|
|
if (lastSlash != std::string::npos) {
|
||
|
|
filename = filepath.substr(lastSlash + 1);
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
filename = filepath;
|
||
|
|
}
|
||
|
|
|
||
|
|
// 提取文件名中的数字
|
||
|
|
std::string numberStr;
|
||
|
|
bool foundDigit = false;
|
||
|
|
|
||
|
|
for (char c : filename) {
|
||
|
|
if (std::isdigit(c)) {
|
||
|
|
numberStr += c;
|
||
|
|
foundDigit = true;
|
||
|
|
}
|
||
|
|
else if (foundDigit) {
|
||
|
|
// 遇到非数字字符且已经找到过数字,停止提取
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// 如果找到数字,转换为整数
|
||
|
|
if (!numberStr.empty()) {
|
||
|
|
try {
|
||
|
|
// 数字范围超过5,返回默认值1
|
||
|
|
if (std::stoi(numberStr) < 1 || std::stoi(numberStr) > 5)
|
||
|
|
{
|
||
|
|
return 1; //返回默认值1
|
||
|
|
}
|
||
|
|
return std::stoi(numberStr);
|
||
|
|
}
|
||
|
|
catch (const std::exception&) {
|
||
|
|
return 1; // 转换失败,返回默认值1
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
return 1; // 未找到数字,返回默认值1
|
||
|
|
}
|
||
|
|
|
||
|
|
#include <QDateTime>
|
||
|
|
QString Utils::get_report_date() {
|
||
|
|
// 获取当前中国本地时间,皇冠时间比中国时间慢12小时
|
||
|
|
QDateTime currentChinaTime = QDateTime::currentDateTime();
|
||
|
|
QDateTime crownTime = currentChinaTime.addSecs(-12 * 3600);
|
||
|
|
QDate currentDate = crownTime.date();
|
||
|
|
|
||
|
|
int year = currentDate.year();
|
||
|
|
int month = currentDate.month();
|
||
|
|
int day = currentDate.day();
|
||
|
|
|
||
|
|
// 计算当前周期开始日期(每月8日开始新周期)
|
||
|
|
QDate currentPeriodStart;
|
||
|
|
if (day >= 8) {
|
||
|
|
currentPeriodStart = QDate(year, month, 8);
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
if (month == 1) {
|
||
|
|
currentPeriodStart = QDate(year - 1, 12, 8);
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
currentPeriodStart = QDate(year, month - 1, 8);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// 计算上一周期开始日期(当前周期开始前1天)
|
||
|
|
QDate previousPeriodStart = currentPeriodStart.addDays(-1);
|
||
|
|
|
||
|
|
// 默认周期长度为28天(基于您的数据,大部分周期都是28天)
|
||
|
|
int previousPeriodLength = 28;
|
||
|
|
|
||
|
|
// 计算上一周期结束日期
|
||
|
|
QDate previousPeriodEnd = previousPeriodStart.addDays(previousPeriodLength - 1);
|
||
|
|
|
||
|
|
return previousPeriodEnd.toString("yyyy-MM-dd");
|
||
|
|
}
|