#include "widget.h" #include "ui_widget.h" Widget::Widget(QWidget *parent) : QWidget(parent) , ui(new Ui::Widget) { getWeather = new GetWeather(this); logThread = new LogThread(this); dbThread = new DBThread(this); connect(dbThread,&DBThread::getParam,this,&Widget::getParam); deviceList.clear(); alarmList.clear(); firstTime = true; weekday.clear(); weekday<<"日"<<"一"<<"二"<<"三"<<"四"<<"五"<<"六"; weatherstring.clear(); weatherstring<<"晴"<<"多云"<<"阴"<<"阵雨"<<"雷阵雨"<<"雷阵雨伴有冰雹" <<"雨夹雪"<<"小雨"<<"中雨"<<"大雨"<<"暴雨"<<"大暴雨"<<"特大暴雨" <<"阵雪"<<"小雪"<<"中雪"<<"大雪"<<"暴雪"<<"雾"<<"冻雨"<<"沙尘暴" <<"小雨-中雨"<<"中雨-大雨"<<"大雨-暴雨"<<"暴雨-大暴雨"<<"大暴雨-特大暴雨" <<"小雪-中雪"<<"中雪-大雪"<<"大雪-暴雪"<<"浮尘"<<"扬沙"<<"强沙尘暴"<<"霾"; dayWeather = ""; dayWeatherCode = "99"; nightWeather = ""; nightWeatherCode = "99"; dayTemperature = ""; nightTemperature = ""; sunBegin = "06:00"; sunEnd = "17:00"; TermId = "";//博华 TermKey = ""; Loginname = ""; Password = ""; CompanyId = "10122"; AppUrl = "https://fire.usky.cn:8443"; dbThread->initdb(); for(int i=0;i<5;i++) { AlarmCount[i] = 0; AlarmConfrmCount[i] = 0; } frontpage = new getFrontPage(this,Loginname,Password,CompanyId,AppUrl); speechThread = new SpeechThread(this); ui->setupUi(this); setAttribute(Qt::WA_TranslucentBackground,true); this->activateWindow(); count = 0; day = 0; hour = 255; timer = new QTimer(this); a_timer = new QTimer(this); showFullScreen(); QSize size = this->size(); setBackground(size); setPieView(size); setWeatherLabel(size); setOperationBtn(size); setDateLabel(size); setTimeLabel(size); setAlarmBarLabels(size); setDevLabels(size); setDevInfoLabels(size); setAlarmInfoLabels(size); setNoteLabels(size); logThread->start(); connect(getWeather,&GetWeather::get_weather,this,&Widget::get_weather); connect(frontpage,&getFrontPage::getFrontpage,this,&Widget::getFrontpage); connect(timer,&QTimer::timeout,this,&Widget::timeout); connect(a_timer,&QTimer::timeout,this,&Widget::closeAlarmBar); this->start(); } Widget::~Widget() { logThread->stop(); delete ui; } void Widget::start() { timer->start(500); hour = QDateTime::currentDateTime().time().hour()/3; getWeather->sendRequest(); frontpage->sendRequest(); dbThread->start(); speechThread->start(); connectDC(); } void Widget::getParam(QString appid, QString key, QString name, QString pass, QString comid, QString url) { TermId = appid; TermKey = key; Loginname = name; Password = pass; CompanyId = comid; AppUrl = url; CompanyIdList.clear(); if(CompanyId.indexOf(",")>0) CompanyIdList = CompanyId.split(","); else CompanyIdList.append(CompanyId); } void Widget::connectDC() { //wsc = new WebsocketClient(this,"47.98.201.73",55128,TermId,TermKey); wsc = new WebsocketClient(this,"wss://iot.usky.cn",55120,TermId,TermKey); connect(wsc,&WebsocketClient::getData,this,&Widget::getDcData); connect(wsc,&WebsocketClient::SoClosed,this,&Widget::DcSoClosed); } void Widget::setPieVlue(QGraphicsView *view, int value) { QColor color; if(value<60) color = QColor(255,0,0,255); else if(value<75) color = QColor(0,0,255,255); else color = QColor(0,255,0,255); for(int i=0;i<5;i++){ if(pieView[i]==view){ series[i]->slices().at(0)->setValue(value); series[i]->slices().at(0)->setColor(color); series[i]->slices().at(1)->setValue(100-value); } } } void Widget::setDevInfo() { if(devPage>0) prevPageBtn->setEnabled(true); else prevPageBtn->setEnabled(false); if(deviceList.length()>((devPage+1)*13)) nextPageBtn->setEnabled(true); else nextPageBtn->setEnabled(false); for(int i=0;i<39;i++) DevInfoLabel[i]->setText(""); for(int i=0;i<13;i++){ if((devPage*13+i)>=deviceList.length()) break; DevInfo *info = deviceList.at(devPage*13+i); DevInfoLabel[i*3+0]->setText(info->DevName); DevInfoLabel[i*3+1]->setText(info->DevType); DevInfoLabel[i*3+2]->setText(info->DeviceInfo); } } void Widget::setAlarmInfo() { for(int i=0;i<18;i++) AlarmInfoLabel[i]->setText(""); for(int i=0;i<9;i++){ if(i>=(alarmList.length())) break; AlarmInfo info = alarmList.at(i); AlarmInfoLabel[i*2+0]->setText(info.DevType); AlarmInfoLabel[i*2+1]->setText(QString::fromUtf8("%1,%2,%3") .arg(info.Alarminfo) .arg(info.DevName) .arg(info.AlarmTime.toString("yyyy-MM-dd HH:mm:ss"))); } } void Widget::setDevData(QString devCode, QJsonObject data) { for(int i=0;iDevCode)==0){ info->appendData(data); break; } } } void Widget::getFrontpage(QString data) { logThread->appendLog(QString("[ %1 frontpage ] get data: %2") .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss.zzz")) .arg(data.trimmed())); QSize size = this->size(); QJsonParseError json_error; QJsonDocument jsonDoc(QJsonDocument::fromJson(data.trimmed().toUtf8(),&json_error)); if(json_error.error==QJsonParseError::NoError){ QJsonObject root = jsonDoc.object(); if((!root.value("action").isUndefined())&&(!root.value("action").isNull())){ QString jAction = root.value("action").toString(); // qDebug()<t){ setDevData(devCode,jPoint); } } } } } } }else if(QString::compare(jAction,"getFrontpageQuery")==0){ if(!firstTime){ if((!root.value("ALARM").isUndefined())&&(!root.value("ALARM").isNull())){ QJsonArray jList = root.value("ALARM").toArray(); for(int i=(jList.size()-1);i>=0;i--){ QJsonObject obj = jList.at(i).toObject(); if((!obj.value("name").isUndefined())&&(!obj.value("name").isNull()) &&(!obj.value("dwtype").isUndefined())&&(!obj.value("dwtype").isNull()) &&(!obj.value("data").isUndefined())&&(!obj.value("data").isNull()) &&(!obj.value("time").isUndefined())&&(!obj.value("time").isNull())){ // QString devName = root.value("name").toString(); // QString alarm_info = root.value("data").toString(); QString alarm_time = root.value("time").toString(); QDateTime dt = QDateTime::fromString(alarm_time,"yyyy-MM-dd HH:mm:ss"); if((dt.toTime_t()>alarmList.first().AlarmTime.toTime_t())){ AlarmInfo info; switch (obj.value("dwtype").toString().toInt()) { case 1: case 3: info = AlarmInfo(obj.value("name").toString(), QString::fromUtf8("火灾监控"), obj.value("data").toString(), obj.value("time").toString()); break; case 2: case 4: case 5: info = AlarmInfo(obj.value("name").toString(), QString::fromUtf8("水系统"), obj.value("data").toString(), obj.value("time").toString()); break; case 6: info = AlarmInfo(obj.value("name").toString(), QString::fromUtf8("RTU"), obj.value("data").toString(), obj.value("time").toString()); break; case 7: info = AlarmInfo(obj.value("name").toString(), QString::fromUtf8("电气火灾"), obj.value("data").toString(), obj.value("time").toString()); break; case 16: info = AlarmInfo(obj.value("name").toString(), QString::fromUtf8("视频告警"), obj.value("data").toString(), obj.value("time").toString()); break; default: info = AlarmInfo(obj.value("name").toString(), QString::fromUtf8("通用"), obj.value("data").toString(), obj.value("time").toString()); break; } if(isNewAlarm(info)){ alarmList.insert(0,info); if(alarmList.length()>10) alarmList.removeLast(); speechThread->append(QString::fromUtf8("%1报告,%2,%3").arg(info.DevType).arg(info.DevName).arg(info.Alarminfo)); setAlarmInfo(); } } } } } return; } firstTime = false; QString COMPANYCODE=""; if((!root.value("LIST").isUndefined())&&(!root.value("LIST").isNull())){ CompanyName.clear(); Address.clear(); CompanyGPS.clear(); userName.clear(); Phone.clear(); CompanyCode.clear(); QJsonArray jList = root.value("LIST").toArray(); for(int i=0;i tmpList; for(int i=0;i=0;i--){ AlarmInfo info = tmpList.at(i); if(isNewAlarm(info)){ speechThread->append(QString::fromUtf8("%1报告,%2,%3,%4") .arg(info.DevType) .arg(info.DevName) .arg(info.Alarminfo) .arg(info.AlarmTime.toString("HH:mm:ss"))); } } alarmList.clear(); alarmList.append(tmpList); // speechThread->append(QString::fromUtf8("%1报告,%2,%3").arg(alarmList.first().DevType).arg(alarmList.first().DevName).arg(alarmList.first().Alarminfo)); setAlarmInfo(); } }else if(QString::compare(jAction,"getCurrentObjectListByCompanyId")==0){ QString COMPANYCODE = ""; if((!root.value("COMPANY").isUndefined())&&(!root.value("COMPANY").isNull())){ QJsonObject jCompany = root.value("COMPANY").toObject(); if((!jCompany.value("company_code").isUndefined())&&(!jCompany.value("company_code").isNull())) COMPANYCODE = jCompany.value("company_code").toString(); if(COMPANYCODE.compare(CompanyIdList.at(0))==0){ for(int i=0;i<5;i++){ DevCountLabelValue[i] = 0; OutCountLabelValue[i] = 0; AlarmCountLabelValue[i] = 0; AlarmUncomCountLabelValue[i] = 0; AlarmComCountLabelValue[i] = 0; AlarmUncomPLabelValue[i] = 0; AlarmComPLabelValue[i] = 0; AlarmPLabelValue[i] = 0; AlarmCount[i] = 0; AlarmConfrmCount[i] = 0; } } if((!jCompany.value("d7").isUndefined())&&(!jCompany.value("d7").isNull())) DevCountLabelValue[0] += jCompany.value("d7").toInt(); if((!jCompany.value("d7o").isUndefined())&&(!jCompany.value("d7o").isNull())) OutCountLabelValue[0] += jCompany.value("d7o").toInt(); if((!jCompany.value("d7a").isUndefined())&&(!jCompany.value("d7a").isNull())) AlarmCount[0] += jCompany.value("d7a").toInt(); if((!jCompany.value("d7ac").isUndefined())&&(!jCompany.value("d7ac").isNull())) AlarmConfrmCount[0] += jCompany.value("d7ac").toInt(); if(COMPANYCODE.compare(CompanyIdList.at(CompanyIdList.length()-1))==0){ DevCountLabel[0]->setText(QString("%1").arg(DevCountLabelValue[0])); OutCountLabel[0]->setText(QString("%1").arg(OutCountLabelValue[0])); AlarmCountLabel[0]->setText(QString("%1").arg(AlarmCount[0])); AlarmUncomCountLabel[0]->setText(QString("%1").arg(AlarmCount[0]-AlarmConfrmCount[0])); AlarmComCountLabel[0]->setText(QString("%1").arg(AlarmConfrmCount[0])); if(AlarmCount[0]==0){ AlarmComPLabel[0]->setText("100.00%"); AlarmUncomPLabel[0]->setText("0.00%"); AlarmPLabel[0]->setText("100%"); AlarmBarValueLabel[0]->resize(0,size.height()*32/2160); AlarmBarValueLabel[1]->resize(size.width()*755/3840,size.height()*32/2160); setPieVlue(pieView[0],100); }else{ AlarmComPLabel[0]->setText(QString("%1%").arg(QString::number((AlarmConfrmCount[0]*100.0/(AlarmCount[0]*1.0)),'f',2))); AlarmUncomPLabel[0]->setText(QString("%1%").arg(QString::number(((AlarmCount[0]*100.0-AlarmConfrmCount[0]*100.0)/(AlarmCount[0]*1.0)),'f',2))); AlarmPLabel[0]->setText(QString("%1%").arg(AlarmConfrmCount[0]*100/AlarmCount[0])); AlarmBarValueLabel[0]->resize((AlarmCount[0]-AlarmConfrmCount[0])*755/(AlarmCount[0]*3840/size.width()),size.height()*32/2160); AlarmBarValueLabel[1]->resize(AlarmConfrmCount[0]*755/(AlarmCount[0]*3840/size.width()),size.height()*32/2160); setPieVlue(pieView[0],AlarmConfrmCount[0]*100/AlarmCount[0]); } } // if((!jCompany.value("d7").isUndefined())&&(!jCompany.value("d7").isNull())) // DevCountLabel[0]->setText(QString("%1").arg(jCompany.value("d7").toInt())); // else // DevCountLabel[0]->setText("0"); // if((!jCompany.value("d7o").isUndefined())&&(!jCompany.value("d7o").isNull())) // OutCountLabel[0]->setText(QString("%1").arg(jCompany.value("d7o").toInt())); // else // OutCountLabel[0]->setText("0"); // if((!jCompany.value("d7a").isUndefined())&&(!jCompany.value("d7a").isNull())) // AlarmCount[0] = jCompany.value("d7a").toInt(); // else // AlarmCount[0] = 0; // if((!jCompany.value("d7ac").isUndefined())&&(!jCompany.value("d7ac").isNull())) // AlarmConfrmCount[0] = jCompany.value("d7ac").toInt(); // else // AlarmConfrmCount[0] = 0; // AlarmCountLabel[0]->setText(QString("%1").arg(AlarmCount[0])); // AlarmUncomCountLabel[0]->setText(QString("%1").arg(AlarmCount[0]-AlarmConfrmCount[0])); // AlarmComCountLabel[0]->setText(QString("%1").arg(AlarmConfrmCount[0])); // if(AlarmCount[0]==0){ // AlarmComPLabel[0]->setText("100.00%"); // AlarmUncomPLabel[0]->setText("0.00%"); // AlarmPLabel[0]->setText("100%"); // AlarmBarValueLabel[0]->resize(0,size.height()*32/2160); // AlarmBarValueLabel[1]->resize(size.width()*755/3840,size.height()*32/2160); // setPieVlue(pieView[0],100); // }else{ // AlarmComPLabel[0]->setText(QString("%1%").arg(QString::number((AlarmConfrmCount[0]*100.0/(AlarmCount[0]*1.0)),'f',2))); // AlarmUncomPLabel[0]->setText(QString("%1%").arg(QString::number(((AlarmCount[0]*100.0-AlarmConfrmCount[0]*100.0)/(AlarmCount[0]*1.0)),'f',2))); // AlarmPLabel[0]->setText(QString("%1%").arg(AlarmConfrmCount[0]*100/AlarmCount[0])); // AlarmBarValueLabel[0]->resize((AlarmCount[0]-AlarmConfrmCount[0])*755/(AlarmCount[0]*3840/size.width()),size.height()*32/2160); // AlarmBarValueLabel[1]->resize(AlarmConfrmCount[0]*755/(AlarmCount[0]*3840/size.width()),size.height()*32/2160); // setPieVlue(pieView[0],AlarmConfrmCount[0]*100/AlarmCount[0]); // } if(((!jCompany.value("d0").isUndefined())&&(!jCompany.value("d0").isNull()))&&((!jCompany.value("d2").isUndefined())&&(!jCompany.value("d2").isNull()))){ DevCountLabelValue[1] += jCompany.value("d0").toInt(); //液位 DevCountLabelValue[1] += jCompany.value("d2").toInt(); //水表 } if(((!jCompany.value("d0o").isUndefined())&&(!jCompany.value("d0o").isNull()))&&((!jCompany.value("d2o").isUndefined())&&(!jCompany.value("d2o").isNull()))){ OutCountLabelValue[1] += jCompany.value("d0o").toInt(); OutCountLabelValue[1] += jCompany.value("d2o").toInt(); } if(((!jCompany.value("d0a").isUndefined())&&(!jCompany.value("d0a").isNull()))&&((!jCompany.value("d2a").isUndefined())&&(!jCompany.value("d2a").isNull()))){ AlarmCount[1] += jCompany.value("d0a").toInt(); AlarmCount[1] += jCompany.value("d2a").toInt(); } if(((!jCompany.value("d0ac").isUndefined())&&(!jCompany.value("d0ac").isNull()))&&((!jCompany.value("d2ac").isUndefined())&&(!jCompany.value("d2ac").isNull()))){ AlarmConfrmCount[1] += jCompany.value("d0ac").toInt(); AlarmConfrmCount[1] += jCompany.value("d2ac").toInt(); } if(COMPANYCODE.compare(CompanyIdList.at(CompanyIdList.length()-1))==0){ DevCountLabel[1]->setText(QString("%1").arg(DevCountLabelValue[1])); OutCountLabel[1]->setText(QString("%1").arg(OutCountLabelValue[1])); AlarmCountLabel[1]->setText(QString("%1").arg(AlarmCount[1])); AlarmUncomCountLabel[1]->setText(QString("%1").arg(AlarmCount[1]-AlarmConfrmCount[1])); AlarmComCountLabel[1]->setText(QString("%1").arg(AlarmConfrmCount[1])); if(AlarmCount[1]==0){ AlarmComPLabel[1]->setText("100.00%"); AlarmUncomPLabel[1]->setText("0.00%"); AlarmPLabel[1]->setText("100%"); AlarmBarValueLabel[2]->resize(0,size.height()*32/2160); AlarmBarValueLabel[3]->resize(size.width()*755/3840,size.height()*32/2160); setPieVlue(pieView[1],100); }else{ AlarmComPLabel[1]->setText(QString("%1%").arg(QString::number((AlarmConfrmCount[1]*100.0/(AlarmCount[1]*1.0)),'f',2))); AlarmUncomPLabel[1]->setText(QString("%1%").arg(QString::number(((AlarmCount[1]*100.0-AlarmConfrmCount[1]*100.0)/(AlarmCount[1]*1.0)),'f',2))); AlarmPLabel[1]->setText(QString("%1%").arg(AlarmConfrmCount[1]*100/AlarmCount[1])); AlarmBarValueLabel[2]->resize((AlarmCount[1]-AlarmConfrmCount[1])*755/(AlarmCount[1]*3840/size.width()),size.height()*32/2160); AlarmBarValueLabel[3]->resize(AlarmConfrmCount[1]*755/(AlarmCount[1]*3840/size.width()),size.height()*32/2160); setPieVlue(pieView[1],AlarmConfrmCount[1]*100/AlarmCount[1]); } } // if((!jCompany.value("d2").isUndefined())&&(!jCompany.value("d2").isNull())) // DevCountLabel[1]->setText(QString("%1").arg(jCompany.value("d2").toInt())); // else // DevCountLabel[1]->setText("0"); // if((!jCompany.value("d2o").isUndefined())&&(!jCompany.value("d2o").isNull())) // OutCountLabel[1]->setText(QString("%1").arg(jCompany.value("d2o").toInt())); // else // OutCountLabel[1]->setText("0"); // if((!jCompany.value("d2a").isUndefined())&&(!jCompany.value("d2a").isNull())) // AlarmCount[1] = jCompany.value("d2a").toInt(); // else // AlarmCount[1] = 0; // if((!jCompany.value("d2ac").isUndefined())&&(!jCompany.value("d2ac").isNull())) // AlarmConfrmCount[1] = jCompany.value("d2ac").toInt(); // else // AlarmConfrmCount[1] = 0; // AlarmCountLabel[1]->setText(QString("%1").arg(AlarmCount[1])); // AlarmUncomCountLabel[1]->setText(QString("%1").arg(AlarmCount[1]-AlarmConfrmCount[1])); // AlarmComCountLabel[1]->setText(QString("%1").arg(AlarmConfrmCount[1])); // if(AlarmCount[1]==0){ // AlarmComPLabel[1]->setText("100.00%"); // AlarmUncomPLabel[1]->setText("0.00%"); // AlarmPLabel[1]->setText("100%"); // AlarmBarValueLabel[2]->resize(0,size.height()*32/2160); // AlarmBarValueLabel[3]->resize(size.width()*755/3840,size.height()*32/2160); // setPieVlue(pieView[1],100); // }else{ // AlarmComPLabel[1]->setText(QString("%1%").arg(QString::number((AlarmConfrmCount[1]*100.0/(AlarmCount[1]*1.0)),'f',2))); // AlarmUncomPLabel[1]->setText(QString("%1%").arg(QString::number(((AlarmCount[1]*100.0-AlarmConfrmCount[1]*100.0)/(AlarmCount[1]*1.0)),'f',2))); // AlarmPLabel[1]->setText(QString("%1%").arg(AlarmConfrmCount[1]*100/AlarmCount[1])); // AlarmBarValueLabel[2]->resize((AlarmCount[1]-AlarmConfrmCount[1])*755/(AlarmCount[1]*3840/size.width()),size.height()*32/2160); // AlarmBarValueLabel[3]->resize(AlarmConfrmCount[1]*755/(AlarmCount[1]*3840/size.width()),size.height()*32/2160); // setPieVlue(pieView[1],AlarmConfrmCount[1]*100/AlarmCount[1]); // } if((!jCompany.value("d6").isUndefined())&&(!jCompany.value("d6").isNull())) DevCountLabelValue[2] += jCompany.value("d6").toInt(); if((!jCompany.value("d6o").isUndefined())&&(!jCompany.value("d6o").isNull())) OutCountLabelValue[2] += jCompany.value("d6o").toInt(); if((!jCompany.value("d6a").isUndefined())&&(!jCompany.value("d6a").isNull())) AlarmCount[2] += jCompany.value("d6a").toInt(); if((!jCompany.value("d6ac").isUndefined())&&(!jCompany.value("d6ac").isNull())) AlarmConfrmCount[2] += jCompany.value("d6ac").toInt(); if(COMPANYCODE.compare(CompanyIdList.at(CompanyIdList.length()-1))==0){ DevCountLabel[2]->setText(QString("%1").arg(DevCountLabelValue[2])); OutCountLabel[2]->setText(QString("%1").arg(OutCountLabelValue[2])); AlarmCountLabel[2]->setText(QString("%1").arg(AlarmCount[2])); AlarmUncomCountLabel[2]->setText(QString("%1").arg(AlarmCount[2]-AlarmConfrmCount[2])); AlarmComCountLabel[2]->setText(QString("%1").arg(AlarmConfrmCount[2])); if(AlarmCount[2]==0){ AlarmComPLabel[2]->setText("100.00%"); AlarmUncomPLabel[2]->setText("0.00%"); AlarmPLabel[2]->setText("100%"); AlarmBarValueLabel[4]->resize(0,size.height()*32/2160); AlarmBarValueLabel[5]->resize(size.width()*755/3840,size.height()*32/2160); setPieVlue(pieView[2],100); }else{ AlarmComPLabel[2]->setText(QString("%1%").arg(QString::number((AlarmConfrmCount[2]*100.0/(AlarmCount[2]*1.0)),'f',2))); AlarmUncomPLabel[2]->setText(QString("%1%").arg(QString::number(((AlarmCount[2]*100.0-AlarmConfrmCount[2]*100.0)/(AlarmCount[2]*1.0)),'f',2))); AlarmPLabel[2]->setText(QString("%1%").arg(AlarmConfrmCount[2]*100/AlarmCount[2])); AlarmBarValueLabel[4]->resize((AlarmCount[2]-AlarmConfrmCount[2])*755/(AlarmCount[2]*3840/size.width()),size.height()*32/2160); AlarmBarValueLabel[5]->resize(AlarmConfrmCount[2]*755/(AlarmCount[2]*3840/size.width()),size.height()*32/2160); setPieVlue(pieView[2],AlarmConfrmCount[2]*100/AlarmCount[2]); } } // if((!jCompany.value("d6").isUndefined())&&(!jCompany.value("d6").isNull())) // DevCountLabel[2]->setText(QString("%1").arg(jCompany.value("d6").toInt())); // else // DevCountLabel[2]->setText("0"); // if((!jCompany.value("d6o").isUndefined())&&(!jCompany.value("d6o").isNull())) // OutCountLabel[2]->setText(QString("%1").arg(jCompany.value("d6o").toInt())); // else // OutCountLabel[2]->setText("0"); // if((!jCompany.value("d6a").isUndefined())&&(!jCompany.value("d6a").isNull())) // AlarmCount[2] = jCompany.value("d6a").toInt(); // else // AlarmCount[2] = 0; // if((!jCompany.value("d6ac").isUndefined())&&(!jCompany.value("d6ac").isNull())) // AlarmConfrmCount[2] = jCompany.value("d6ac").toInt(); // else // AlarmConfrmCount[2] = 0; // AlarmCountLabel[2]->setText(QString("%1").arg(AlarmCount[2])); // AlarmUncomCountLabel[2]->setText(QString("%1").arg(AlarmCount[2]-AlarmConfrmCount[2])); // AlarmComCountLabel[2]->setText(QString("%1").arg(AlarmConfrmCount[2])); // if(AlarmCount[2]==0){ // AlarmComPLabel[2]->setText("100.00%"); // AlarmUncomPLabel[2]->setText("0.00%"); // AlarmPLabel[2]->setText("100%"); // AlarmBarValueLabel[4]->resize(0,size.height()*32/2160); // AlarmBarValueLabel[5]->resize(size.width()*755/3840,size.height()*32/2160); // setPieVlue(pieView[2],100); // }else{ // AlarmComPLabel[2]->setText(QString("%1%").arg(QString::number((AlarmConfrmCount[2]*100.0/(AlarmCount[2]*1.0)),'f',2))); // AlarmUncomPLabel[2]->setText(QString("%1%").arg(QString::number(((AlarmCount[2]*100.0-AlarmConfrmCount[2]*100.0)/(AlarmCount[2]*1.0)),'f',2))); // AlarmPLabel[2]->setText(QString("%1%").arg(AlarmConfrmCount[2]*100/AlarmCount[2])); // AlarmBarValueLabel[4]->resize((AlarmCount[2]-AlarmConfrmCount[2])*755/(AlarmCount[2]*3840/size.width()),size.height()*32/2160); // AlarmBarValueLabel[5]->resize(AlarmConfrmCount[2]*755/(AlarmCount[2]*3840/size.width()),size.height()*32/2160); // setPieVlue(pieView[2],AlarmConfrmCount[2]*100/AlarmCount[2]); // } if((!jCompany.value("d1").isUndefined())&&(!jCompany.value("d1").isNull())) DevCountLabelValue[3] += jCompany.value("d1").toInt(); if((!jCompany.value("d1o").isUndefined())&&(!jCompany.value("d1o").isNull())) OutCountLabelValue[3] += jCompany.value("d1o").toInt(); if((!jCompany.value("d1a").isUndefined())&&(!jCompany.value("d1a").isNull())) AlarmCount[3] += jCompany.value("d1a").toInt(); if((!jCompany.value("d1ac").isUndefined())&&(!jCompany.value("d1ac").isNull())) AlarmConfrmCount[3] += jCompany.value("d1ac").toInt(); if(COMPANYCODE.compare(CompanyIdList.at(CompanyIdList.length()-1))==0){ DevCountLabel[3]->setText(QString("%1").arg(DevCountLabelValue[3])); OutCountLabel[3]->setText(QString("%1").arg(OutCountLabelValue[3])); AlarmCountLabel[3]->setText(QString("%1").arg(AlarmCount[3])); AlarmUncomCountLabel[3]->setText(QString("%1").arg(AlarmCount[3]-AlarmConfrmCount[3])); AlarmComCountLabel[3]->setText(QString("%1").arg(AlarmConfrmCount[3])); if(AlarmCount[3]==0){ AlarmComPLabel[3]->setText("100.00%"); AlarmUncomPLabel[3]->setText("0.00%"); AlarmPLabel[3]->setText("100%"); AlarmBarValueLabel[6]->resize(0,size.height()*32/2160); AlarmBarValueLabel[7]->resize(size.width()*755/3840,size.height()*32/2160); setPieVlue(pieView[3],100); }else{ AlarmComPLabel[3]->setText(QString("%1%").arg(QString::number((AlarmConfrmCount[3]*100.0/(AlarmCount[3]*1.0)),'f',2))); AlarmUncomPLabel[3]->setText(QString("%1%").arg(QString::number(((AlarmCount[3]*100.0-AlarmConfrmCount[3]*100.0)/(AlarmCount[3]*1.0)),'f',2))); AlarmPLabel[3]->setText(QString("%1%").arg(AlarmConfrmCount[3]*100/AlarmCount[3])); AlarmBarValueLabel[6]->resize((AlarmCount[3]-AlarmConfrmCount[3])*755/(AlarmCount[3]*3840/size.width()),size.height()*32/2160); AlarmBarValueLabel[7]->resize(AlarmConfrmCount[3]*755/(AlarmCount[3]*3840/size.width()),size.height()*32/2160); setPieVlue(pieView[3],AlarmConfrmCount[3]*100/AlarmCount[3]); } } // if((!jCompany.value("d1").isUndefined())&&(!jCompany.value("d1").isNull())) // DevCountLabel[3]->setText(QString("%1").arg(jCompany.value("d1").toInt())); // else // DevCountLabel[3]->setText("0"); // if((!jCompany.value("d1o").isUndefined())&&(!jCompany.value("d1o").isNull())) // OutCountLabel[3]->setText(QString("%1").arg(jCompany.value("d1o").toInt())); // else // OutCountLabel[3]->setText("0"); // if((!jCompany.value("d1a").isUndefined())&&(!jCompany.value("d1a").isNull())) // AlarmCount[3] = jCompany.value("d1a").toInt(); // else // AlarmCount[3] = 0; // if((!jCompany.value("d1ac").isUndefined())&&(!jCompany.value("d1ac").isNull())) // AlarmConfrmCount[3] = jCompany.value("d1ac").toInt(); // else // AlarmConfrmCount[3] = 0; // AlarmCountLabel[3]->setText(QString("%1").arg(AlarmCount[3])); // AlarmUncomCountLabel[3]->setText(QString("%1").arg(AlarmCount[3]-AlarmConfrmCount[3])); // AlarmComCountLabel[3]->setText(QString("%1").arg(AlarmConfrmCount[3])); // if(AlarmCount[3]==0){ // AlarmComPLabel[3]->setText("100.00%"); // AlarmUncomPLabel[3]->setText("0.00%"); // AlarmPLabel[3]->setText("100%"); // AlarmBarValueLabel[6]->resize(0,size.height()*32/2160); // AlarmBarValueLabel[7]->resize(size.width()*755/3840,size.height()*32/2160); // setPieVlue(pieView[3],100); // }else{ // AlarmComPLabel[3]->setText(QString("%1%").arg(QString::number((AlarmConfrmCount[3]*100.0/(AlarmCount[3]*1.0)),'f',2))); // AlarmUncomPLabel[3]->setText(QString("%1%").arg(QString::number(((AlarmCount[3]*100.0-AlarmConfrmCount[3]*100.0)/(AlarmCount[3]*1.0)),'f',2))); // AlarmPLabel[3]->setText(QString("%1%").arg(AlarmConfrmCount[3]*100/AlarmCount[3])); // AlarmBarValueLabel[6]->resize((AlarmCount[3]-AlarmConfrmCount[3])*755/(AlarmCount[3]*3840/size.width()),size.height()*32/2160); // AlarmBarValueLabel[7]->resize(AlarmConfrmCount[3]*755/(AlarmCount[3]*3840/size.width()),size.height()*32/2160); // setPieVlue(pieView[3],AlarmConfrmCount[3]*100/AlarmCount[3]); // } if((!jCompany.value("d16").isUndefined())&&(!jCompany.value("d16").isNull())) DevCountLabelValue[4] += jCompany.value("d16").toInt(); if((!jCompany.value("d16o").isUndefined())&&(!jCompany.value("d16o").isNull())) OutCountLabelValue[4] += jCompany.value("d16o").toInt(); if((!jCompany.value("d16a").isUndefined())&&(!jCompany.value("d16a").isNull())) AlarmCount[4] += jCompany.value("d16a").toInt(); if((!jCompany.value("d16ac").isUndefined())&&(!jCompany.value("d16ac").isNull())) AlarmConfrmCount[4] += jCompany.value("d16ac").toInt(); if(COMPANYCODE.compare(CompanyIdList.at(CompanyIdList.length()-1))==0){ DevCountLabel[4]->setText(QString("%1").arg(DevCountLabelValue[4])); OutCountLabel[4]->setText(QString("%1").arg(OutCountLabelValue[4])); AlarmCountLabel[4]->setText(QString("%1").arg(AlarmCount[4])); AlarmUncomCountLabel[4]->setText(QString("%1").arg(AlarmCount[4]-AlarmConfrmCount[4])); AlarmComCountLabel[4]->setText(QString("%1").arg(AlarmConfrmCount[4])); if(AlarmCount[4]==0){ AlarmComPLabel[4]->setText("100.00%"); AlarmUncomPLabel[4]->setText("0.00%"); AlarmPLabel[4]->setText("100%"); AlarmBarValueLabel[8]->resize(0,size.height()*32/2160); AlarmBarValueLabel[9]->resize(size.width()*755/3840,size.height()*32/2160); setPieVlue(pieView[4],100); }else{ AlarmComPLabel[4]->setText(QString("%1%").arg(QString::number((AlarmConfrmCount[4]*100.0/(AlarmCount[4]*1.0)),'f',2))); AlarmUncomPLabel[4]->setText(QString("%1%").arg(QString::number(((AlarmCount[4]*100.0-AlarmConfrmCount[4]*100.0)/(AlarmCount[4]*1.0)),'f',2))); AlarmPLabel[4]->setText(QString("%1%").arg(AlarmConfrmCount[4]*100/AlarmCount[4])); AlarmBarValueLabel[8]->resize((AlarmCount[4]-AlarmConfrmCount[4])*755/(AlarmCount[4]*3840/size.width()),size.height()*32/2160); AlarmBarValueLabel[9]->resize(AlarmConfrmCount[4]*755/(AlarmCount[4]*3840/size.width()),size.height()*32/2160); setPieVlue(pieView[4],AlarmConfrmCount[4]*100/AlarmCount[4]); } } // if((!jCompany.value("d16").isUndefined())&&(!jCompany.value("d16").isNull())) // DevCountLabel[4]->setText(QString("%1").arg(jCompany.value("d16").toInt())); // else // DevCountLabel[4]->setText("0"); // if((!jCompany.value("d16o").isUndefined())&&(!jCompany.value("d16o").isNull())) // OutCountLabel[4]->setText(QString("%1").arg(jCompany.value("d16o").toInt())); // else // OutCountLabel[4]->setText("0"); // if((!jCompany.value("d16a").isUndefined())&&(!jCompany.value("d16a").isNull())) // AlarmCount[4] = jCompany.value("d16a").toInt(); // else // AlarmCount[4] = 0; // if((!jCompany.value("d16ac").isUndefined())&&(!jCompany.value("d16ac").isNull())) // AlarmConfrmCount[4] = jCompany.value("d16ac").toInt(); // else // AlarmConfrmCount[4] = 0; // AlarmCountLabel[4]->setText(QString("%1").arg(AlarmCount[4])); // AlarmUncomCountLabel[4]->setText(QString("%1").arg(AlarmCount[4]-AlarmConfrmCount[4])); // AlarmComCountLabel[4]->setText(QString("%1").arg(AlarmConfrmCount[4])); // if(AlarmCount[4]==0){ // AlarmComPLabel[4]->setText("100.00%"); // AlarmUncomPLabel[4]->setText("0.00%"); // AlarmPLabel[4]->setText("100%"); // AlarmBarValueLabel[8]->resize(0,size.height()*32/2160); // AlarmBarValueLabel[9]->resize(size.width()*755/3840,size.height()*32/2160); // setPieVlue(pieView[4],100); // }else{ // AlarmComPLabel[4]->setText(QString("%1%").arg(QString::number((AlarmConfrmCount[4]*100.0/(AlarmCount[4]*1.0)),'f',2))); // AlarmUncomPLabel[4]->setText(QString("%1%").arg(QString::number(((AlarmCount[4]*100.0-AlarmConfrmCount[4]*100.0)/(AlarmCount[4]*1.0)),'f',2))); // AlarmPLabel[4]->setText(QString("%1%").arg(AlarmConfrmCount[4]*100/AlarmCount[4])); // AlarmBarValueLabel[8]->resize((AlarmCount[4]-AlarmConfrmCount[4])*755/(AlarmCount[4]*3840/size.width()),size.height()*32/2160); // AlarmBarValueLabel[9]->resize(AlarmConfrmCount[4]*755/(AlarmCount[4]*3840/size.width()),size.height()*32/2160); // setPieVlue(pieView[4],AlarmConfrmCount[4]*100/AlarmCount[4]); // } } // if((!root.value("LIST").isUndefined())&&(!root.value("LIST").isNull())){ QJsonArray jList = root.value("LIST").toArray(); QList tmpList; for(int i=0;iappendLog(QString("[ %1 datacenter ] get data: %2") .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss.zzz")) .arg(data)); QJsonParseError json_error; QJsonDocument jsonDoc(QJsonDocument::fromJson(data.trimmed().toUtf8(),&json_error)); if(json_error.error==QJsonParseError::NoError){ QJsonObject root = jsonDoc.object(); if((!root.value("dwtype").isUndefined())&&(!root.value("dwtype").isNull()) &&(!root.value("deviceid").isUndefined())&&(!root.value("deviceid").isNull()) &&(!root.value("devicename").isUndefined())&&(!root.value("devicename").isNull()) &&(!root.value("evtname").isUndefined())&&(!root.value("evtname").isNull()) &&(!root.value("time").isUndefined())&&(!root.value("time").isNull())){ QString devCode = root.value("deviceid").toString(); QString devName = root.value("devicename").toString(); QString alarm_info = root.value("evtname").toString(); QString alarm_time = root.value("time").toString(); switch (root.value("dwtype").toInt()) { case 1: case 3: { AlarmInfo Info = AlarmInfo(devName, QString::fromUtf8("火灾监控"), alarm_info, alarm_time); if(isNewAlarm(Info)){ alarmList.insert(0,Info); speechThread->append(QString::fromUtf8("%1报告,%2,%3,%4") .arg(Info.DevType) .arg(Info.DevName) .arg(Info.Alarminfo) .arg(Info.AlarmTime.toString("HH:mm:ss"))); if(alarmList.length()>10) alarmList.removeLast(); } } break; case 2: case 4: case 5: { AlarmInfo Info = AlarmInfo(devName, QString::fromUtf8("水系统"), alarm_info, alarm_time); if(isNewAlarm(Info)){ alarmList.insert(0,Info); speechThread->append(QString::fromUtf8("%1报告,%2,%3,%4") .arg(Info.DevType) .arg(Info.DevName) .arg(Info.Alarminfo) .arg(Info.AlarmTime.toString("HH:mm:ss"))); if(alarmList.length()>10) alarmList.removeLast(); } } break; case 6: { AlarmInfo Info = AlarmInfo(devName, QString::fromUtf8("RTU"), alarm_info, alarm_time); if(isNewAlarm(Info)){ alarmList.insert(0,Info); speechThread->append(QString::fromUtf8("%1报告,%2,%3,%4") .arg(Info.DevType) .arg(Info.DevName) .arg(Info.Alarminfo) .arg(Info.AlarmTime.toString("HH:mm:ss"))); if(alarmList.length()>10) alarmList.removeLast(); } } break; case 7: { AlarmInfo Info = AlarmInfo(devName, QString::fromUtf8("电气火灾"), alarm_info, alarm_time); if(isNewAlarm(Info)){ alarmList.insert(0,Info); speechThread->append(QString::fromUtf8("%1报告,%2,%3,%4") .arg(Info.DevType) .arg(Info.DevName) .arg(Info.Alarminfo) .arg(Info.AlarmTime.toString("HH:mm:ss"))); if(alarmList.length()>10) alarmList.removeLast(); } } break; case 16: { AlarmInfo Info = AlarmInfo(devName, QString::fromUtf8("视频告警"), alarm_info, alarm_time); if(isNewAlarm(Info)){ alarmList.insert(0,Info); speechThread->append(QString::fromUtf8("%1报告,%2,%3,%4") .arg(Info.DevType) .arg(Info.DevName) .arg(Info.Alarminfo) .arg(Info.AlarmTime.toString("HH:mm:ss"))); if(alarmList.length()>10) alarmList.removeLast(); } } break; default: { AlarmInfo Info = AlarmInfo(devName, QString::fromUtf8("通用"), alarm_info, alarm_time); if(isNewAlarm(Info)){ alarmList.insert(0,Info); speechThread->append(QString::fromUtf8("%1报告,%2,%3,%4") .arg(Info.DevType) .arg(Info.DevName) .arg(Info.Alarminfo) .arg(Info.AlarmTime.toString("HH:mm:ss"))); if(alarmList.length()>10) alarmList.removeLast(); } } break; } setAlarmInfo(); } } } void Widget::DcSoClosed() { WebsocketClient *ws = (WebsocketClient *)sender(); ws->deleteLater(); connectDC(); } void Widget::get_weather(QString day_weather, QString day_weather_code, QString night_weather, QString night_weather_code, QString sun_begin, QString sun_end, QString day_air_temperature, QString night_air_temperature){ dayWeather = day_weather; nightWeather = night_weather; dayWeatherCode = day_weather_code; nightWeatherCode = night_weather_code; sunBegin = sun_begin; sunEnd = sun_end; dayTemperature = day_air_temperature; nightTemperature = night_air_temperature; logThread->appendLog(QString("[ %1 weather ] get data: %2 %3 %4 %5 %6 %7 %8 %9") .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss.zzz")) .arg(day_weather).arg(day_weather_code).arg(day_air_temperature) .arg(night_weather).arg(night_weather_code).arg(night_air_temperature) .arg(sun_begin).arg(sun_end)); setWeatherInfo(); } void Widget::setWeatherInfo() { bool isday=false; QSize size = this->size(); QTime dt = QTime::currentTime(); QTime begin = QTime::fromString(sunBegin,"HH:mm"); QTime end = QTime::fromString(sunEnd,"HH:mm"); int dtt = dt.hour()*60+dt.minute(); int btt = begin.hour()*60+begin.minute(); int ett = end.hour()*60+end.minute(); if((dtt>=btt)&&(dtt=0)&&(weatherCode<32)){ imgname = QString(":/img/pics/weather/day/%1.png").arg(weatherCode,2,10,QChar('0')); } temperatureLabel->setText(QString::fromUtf8("%1°C").arg(dayTemperature)); }else{ int weatherCode = nightWeatherCode.toInt(); if((weatherCode>=0)&&(weatherCode<32)){ imgname = QString(":/img/pics/weather/night/%1.png").arg(weatherCode,2,10,QChar('0')); } temperatureLabel->setText(QString::fromUtf8("%1°C").arg(nightTemperature)); } image.load(imgname); weatherIconLabel->setPixmap(QPixmap::fromImage(image)); weatherIconLabel->setScaledContents(true); weatherIconLabel->resize(size.width()*80/3840,size.height()*80/2160); } void Widget::timeout() { QDateTime dt = QDateTime::currentDateTime(); count++; TimeLabel->setText(QString::fromUtf8("%1:%2:%3").arg(dt.time().hour(),2,10,QChar('0')).arg(dt.time().minute(),2,10,QChar('0')).arg(dt.time().second(),2,10,QChar('0'))); if(day!=dt.date().dayOfYear()){ day = dt.date().dayOfYear(); DateLabel->setText(QString::fromUtf8("%1年%2月%3日 星期%4").arg(dt.date().year(),4,10,QChar('0')).arg(dt.date().month(),2,10,QChar('0')).arg(dt.date().day(),2,10,QChar('0')).arg(weekday.at(dt.date().dayOfWeek()))); } if(hour!=dt.time().hour()/3){ hour = dt.time().hour()/3; getWeather->sendRequest(); } if((count%600)==0){ setWeatherInfo(); // frontpage->sendRequest(); count=0; } if(count>1199) count=0; if(count==0){ this->activateWindow(); frontpage->sendRequest(); } } void Widget::setDevLabels(QSize size) { for(int i=0;i<5;i++){ QFont font("Agency FB"); font.setFamily("Agency FB"); font.setBold(true); font.setPointSize(size.width()*48/3840); QFont font2("Agency FB"); font2.setFamily("Agency FB"); font2.setPointSize(size.width()*32/3840); DevCountLabel[i] = new QLabel(this); DevCountLabel[i]->setStyleSheet("color: rgba(65, 249, 40,255);"); DevCountLabel[i]->setFont(font); DevCountLabel[i]->setGeometry(size.width()*171/3840,size.height()*525/2160+(size.height()*376*i/2160),size.width()*160/3840,size.height()*50/2160); DevCountLabel[i]->setText("0"); DevCountLabel[i]->show(); OutCountLabel[i] = new QLabel(this); OutCountLabel[i]->setStyleSheet("color: rgba(255, 97, 2, 255);"); OutCountLabel[i]->setFont(font); OutCountLabel[i]->setGeometry(size.width()*438/3840,size.height()*525/2160+(size.height()*376*i/2160),size.width()*160/3840,size.height()*50/2160); OutCountLabel[i]->setText("0"); OutCountLabel[i]->show(); font.setPointSize(size.width()*54/3840); AlarmCountLabel[i] = new QLabel(this); AlarmCountLabel[i]->setStyleSheet("color: rgba(255, 170, 35, 255);"); AlarmCountLabel[i]->setFont(font); AlarmCountLabel[i]->setGeometry(size.width()*1200/3840,size.height()*456/2160+(size.height()*376*i/2160),size.width()*160/3840,size.height()*60/2160); AlarmCountLabel[i]->show(); AlarmUncomCountLabel[i] = new QLabel(this); AlarmUncomCountLabel[i]->setStyleSheet("color: rgba(52, 236, 255, 255);"); AlarmUncomCountLabel[i]->setFont(font2); AlarmUncomCountLabel[i]->setGeometry(size.width()*2335/3840,size.height()*381/2160+(size.height()*376*i/2160),size.width()*90/3840,size.height()*40/2160); AlarmUncomCountLabel[i]->setText("0"); AlarmUncomCountLabel[i]->show(); AlarmComPLabel[i] = new QLabel(this); AlarmComPLabel[i]->setStyleSheet("color: rgba(0, 255, 168, 255);"); AlarmComPLabel[i]->setFont(font2); AlarmComPLabel[i]->setGeometry(size.width()*2450/3840,size.height()*513/2160+(size.height()*376*i/2160),size.width()*120/3840,size.height()*40/2160); AlarmComPLabel[i]->setText("0.00%"); AlarmComPLabel[i]->show(); AlarmComCountLabel[i] = new QLabel(this); AlarmComCountLabel[i]->setStyleSheet("color: rgba(52, 236, 255, 255);"); AlarmComCountLabel[i]->setFont(font2); AlarmComCountLabel[i]->setGeometry(size.width()*2335/3840,size.height()*513/2160+(size.height()*376*i/2160),size.width()*90/3840,size.height()*40/2160); AlarmComCountLabel[i]->setText("0"); AlarmComCountLabel[i]->show(); AlarmUncomPLabel[i] = new QLabel(this); AlarmUncomPLabel[i]->setStyleSheet("color: rgba(251, 56, 54, 255);"); AlarmUncomPLabel[i]->setFont(font2); AlarmUncomPLabel[i]->setGeometry(size.width()*2450/3840,size.height()*381/2160+(size.height()*376*i/2160),size.width()*120/3840,size.height()*40/2160); AlarmUncomPLabel[i]->setText("0.00%"); AlarmUncomPLabel[i]->show(); AlarmPLabel[i] = new QLabel(this); AlarmPLabel[i]->setStyleSheet("color: rgba(255, 138,0, 255);"); font2.setPointSize(size.width()*32/3840); font2.setBold(true); AlarmPLabel[i]->setFont(font2); AlarmPLabel[i]->setAlignment(Qt::AlignRight|Qt::AlignVCenter); AlarmPLabel[i]->setGeometry(size.width()*2830/3840,size.height()*402/2160+(size.height()*376*i/2160),size.width()*72/3840,size.height()*60/2160); AlarmPLabel[i]->setText("100%"); AlarmPLabel[i]->show(); } } void Widget::closeAlarmBar() { currentAlarmNote->setText(""); currentAlarmBG->hide(); a_start = false; } void Widget::setAlarmBarLabels(QSize size) { QImage image; image.load(":/img/pics/cover.png"); for(int i=0;i<5;i++){ QRect rect(size.width()*1540/3840,size.height()*385/2160+(size.height()*376*i/2160),size.width()*755/3840,size.height()*32/2160); QRect rect2(size.width()*1540/3840,size.height()*517/2160+(size.height()*376*i/2160),size.width()*755/3840,size.height()*32/2160); AlarmBarBGLabel[i*2+0] = new QLabel(this); AlarmBarBGLabel[i*2+0]->setGeometry(rect); AlarmBarBGLabel[i*2+0]->setStyleSheet("background-color: rgba(52, 89, 126, 255);"); AlarmBarBGLabel[i*2+0]->show(); AlarmBarValueLabel[i*2+0] = new QLabel(this); AlarmBarValueLabel[i*2+0]->setGeometry(rect); AlarmBarValueLabel[i*2+0]->setStyleSheet("background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(255, 225, 127, 255), stop:1 rgba(255, 123, 75, 255));"); AlarmBarValueLabel[i*2+0]->show(); AlarmBarCoverLabel[i*2+0] = new QLabel(this); AlarmBarCoverLabel[i*2+0]->setGeometry(rect); AlarmBarCoverLabel[i*2+0]->setPixmap(QPixmap::fromImage(image)); AlarmBarCoverLabel[i*2+0]->setScaledContents(true); AlarmBarCoverLabel[i*2+0]->resize(rect.size()); AlarmBarCoverLabel[i*2+0]->show(); AlarmBarBGLabel[i*2+1] = new QLabel(this); AlarmBarBGLabel[i*2+1]->setGeometry(rect2); AlarmBarBGLabel[i*2+1]->setStyleSheet("background-color: rgba(52, 89, 126, 255);"); AlarmBarBGLabel[i*2+1]->show(); AlarmBarValueLabel[i*2+1] = new QLabel(this); AlarmBarValueLabel[i*2+1]->setGeometry(rect2); AlarmBarValueLabel[i*2+1]->setStyleSheet("background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(53, 236, 255, 255), stop:1 rgba(67, 145, 250, 255));"); AlarmBarValueLabel[i*2+1]->show(); AlarmBarCoverLabel[i*2+1] = new QLabel(this); AlarmBarCoverLabel[i*2+1]->setGeometry(rect2); AlarmBarCoverLabel[i*2+1]->setPixmap(QPixmap::fromImage(image)); AlarmBarCoverLabel[i*2+1]->setScaledContents(true); AlarmBarCoverLabel[i*2+1]->resize(rect2.size()); AlarmBarCoverLabel[i*2+1]->show(); } } void Widget::setCurrentAlarmNote(AlarmInfo info) { if(a_start) a_timer->stop(); currentAlarmBG->show(); currentAlarmNote->setText(QString::fromUtf8("项目名称:%1\n项目地址:%2\n项目坐标:%3\n联 系 人:%4\n报告来源:%5\n报告时间:%6") .arg(CompanyName.at(0)).arg(Address.at(0)).arg(CompanyGPS.at(0)).arg(userName.at(0)).arg(info.DevType).arg(info.AlarmTime.toString("yyyy-MM-dd HH:mm:ss"))); a_start = true; a_timer->start(30000); } void Widget::setAlarmNote(QSize size) { QImage image; QFont font("Microsoft YaHei"); font.setFamily("Microsoft YaHei"); font.setBold(false); font.setPointSize(size.width()*28/3840); image.load(":/img/pics/alarm_bg.png"); currentAlarmBG = new QLabel(this); currentAlarmBG->setGeometry(size.width()*(3840-1334)/2/3840, size.height()*847/2160, size.width()*1334/3840, size.height()*466/2160); currentAlarmBG->setPixmap(QPixmap::fromImage(image)); currentAlarmBG->setScaledContents(true); currentAlarmBG->resize(size.width()*1334/3840, size.height()*466/2160); currentAlarmNote = new QLabel(currentAlarmBG); currentAlarmNote->setGeometry(size.width()*450/3840, size.height()*50/2160, size.width()*800/3840, size.height()*360/2160); currentAlarmNote->setFont(font); currentAlarmNote->setStyleSheet("color: rgba(255, 255, 255, 255)"); currentAlarmNote->setText(""); currentAlarmBG->hide(); } void Widget::setWeatherLabel(QSize size) { QFont font("Impact"); font.setFamily("Impact"); font.setPointSize(size.width()*40/3840); weatherIconLabel = new QLabel(this); weatherIconLabel->setGeometry(size.width()*3446/3840,size.height()*80/2160,size.width()*72/3840,size.height()*72/2160); weatherIconLabel->show(); temperatureLabel = new QLabel(this); temperatureLabel->setGeometry(size.width()*3572/3840,size.height()*72/2160,size.width()-(size.width()*96/3840+size.width()*8/3840)-size.width()*3552/3840,size.height()*80/2160); temperatureLabel->setFont(font); temperatureLabel->setStyleSheet("color: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(255, 255, 255, 255),stop:0.45 rgba(255, 255, 255, 255), stop:0.6 rgba(64, 64, 64, 255), stop:0.65 rgba(255, 255, 255, 255));"); temperatureLabel->show(); } bool Widget::isNewAlarm(AlarmInfo info) { for(int i=0;i=info.AlarmTime.toTime_t()) return false; } return true; } void Widget::setDateLabel(QSize size) { QDateTime dt = QDateTime::currentDateTime(); day = dt.date().dayOfYear(); QFont font("Microsoft YaHei"); font.setFamily("Microsoft YaHei"); font.setBold(true); font.setPointSize(size.width()*24/3840); DateLabel = new QLabel(this); DateLabel->setGeometry(size.width()*72/3840,size.height()*96/2160,size.width()*396/3840,size.height()*36/2160); DateLabel->setAlignment(Qt::AlignTop|Qt::AlignLeft); DateLabel->setStyleSheet("color: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(255, 255, 255, 255),stop:0.45 rgba(255, 255, 255, 255), stop:0.6 rgba(64, 64, 64, 255), stop:0.65 rgba(255, 255, 255, 255));"); DateLabel->setFont(font); DateLabel->setText(QString::fromUtf8("%1年%2月%3日 星期%4").arg(dt.date().year(),4,10,QChar('0')).arg(dt.date().month(),2,10,QChar('0')).arg(dt.date().day(),2,10,QChar('0')).arg(weekday.at(dt.date().dayOfWeek()))); DateLabel->show(); } void Widget::setTimeLabel(QSize size) { QDateTime dt = QDateTime::currentDateTime(); QFont font("Impact"); font.setFamily("Impact"); font.setPointSize(size.width()*40/3840); TimeLabel = new QLabel(this); TimeLabel->setStyleSheet("color: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(255, 255, 255, 255),stop:0.45 rgba(255, 255, 255, 255), stop:0.6 rgba(64, 64, 64, 255), stop:0.65 rgba(255, 255, 255, 255));"); TimeLabel->setFont(font); TimeLabel->setAlignment(Qt::AlignTop|Qt::AlignLeft); TimeLabel->setGeometry(size.width()*468/3840,size.height()*80/2160,size.width()*240/3840,size.height()*80/2160); TimeLabel->setText(QString::fromUtf8("%1:%2:%3").arg(dt.time().hour(),2,10,QChar('0')).arg(dt.time().minute(),2,10,QChar('0')).arg(dt.time().second(),2,10,QChar('0'))); TimeLabel->show(); } void Widget::setBackground(QSize size) { QImage image; image.load(":/img/pics/background.png"); ui->background->setPixmap(QPixmap::fromImage(image)); ui->background->setScaledContents(true); ui->background->resize(size); } void Widget::pageClick() { QToolButton *btn = (QToolButton *)sender(); if(btn==prevPageBtn){ devPage--; setDevInfo(); }else if(btn==nextPageBtn){ devPage++; setDevInfo(); } } void Widget::cancel() { NoteBgLabel->hide(); NoteLabel->hide(); } void Widget::save(QString appid, QString key, QString name, QString pass, QString comid, QString url) { TermId = appid; TermKey = key; Loginname = name; Password = pass; CompanyId = comid; AppUrl = url; CompanyIdList.clear(); if(CompanyId.indexOf(",")>0) CompanyIdList = CompanyId.split(","); else CompanyIdList.append(CompanyId); NoteBgLabel->hide(); NoteLabel->hide(); alarmList.clear(); deviceList.clear(); for(int i=0;i<39;i++) DevInfoLabel[i]->setText(""); for(int i=0;i<18;i++) AlarmInfoLabel[i]->setText(""); frontpage->setParam(Loginname,Password,CompanyId,AppUrl); dbThread->appendSql(QString("update yt_t_conf set AppId='%1', AppKey='%2', LoginName='%3', PassWord='%4', CompanyId='%5'") .arg(TermId).arg(TermKey).arg(Loginname).arg(Password).arg(CompanyId)); dbThread->appendSql(QString("update yt_t_url set AppUrl='%1'").arg(AppUrl)); // frontpage->sendRequest(); wsc->reset(); } void Widget::setupClick() { SetupForm *form = new SetupForm(this,TermId,TermKey,Loginname,Password,CompanyId,AppUrl); connect(form,&SetupForm::cancel,this,&Widget::cancel); connect(form,&SetupForm::save,this,&Widget::save); form->setGeometry((this->size().width()-400)/2,(this->size().height()-300)/2,400,300); NoteBgLabel->show(); NoteLabel->show(); form->show(); } void Widget::setOperationBtn(QSize size) { int btnWidth = size.width()*64/3840; int btnHeight = size.height()*64/2160; int btnSep = size.width()*8/3840; int btnY = size.height()*80/2160; int btnX = size.width()-btnWidth-btnSep/2; int pBtnWidth = size.width()*58/3840; int pBtnHeight = size.height()*38/2160; CmdBtn = new QToolButton(this); CmdBtn->setIcon(QIcon(QPixmap(":/img/pics/min.png"))); CmdBtn->setGeometry(btnX-btnWidth,size.height()*82/2160,btnWidth,btnHeight); CmdBtn->setIconSize(QSize(btnWidth,btnHeight)); //CmdBtn->setToolTip(QString::fromUtf8("参数设置")); CmdBtn->setToolTip(QString::fromUtf8("最小化")); CmdBtn->setAutoRaise(true); CmdBtn->show(); //connect(CmdBtn,&QToolButton::clicked,this,&Widget::setupClick); //参数设置 connect(CmdBtn,&QToolButton::clicked,this,&Widget::showMinimized); QuitBtn = new QToolButton(this); QuitBtn->setIcon(QIcon(QPixmap(":/img/pics/exit2.png"))); QuitBtn->setGeometry(btnX,btnY,btnWidth,btnHeight); QuitBtn->setIconSize(QSize(btnWidth,btnHeight)); QuitBtn->setToolTip(QString::fromUtf8("退出")); QuitBtn->setAutoRaise(true); QuitBtn->show(); connect(QuitBtn,&QToolButton::clicked,this,&Widget::close); prevPageBtn = new QToolButton(this); prevPageBtn->setIcon(QPixmap(":/img/pics/prev.png")); prevPageBtn->setGeometry(size.width()*3662/3840,size.height()*204/2160,pBtnWidth,pBtnHeight); prevPageBtn->setIconSize(QSize(pBtnWidth,pBtnHeight)); prevPageBtn->setAutoRaise(true); connect(prevPageBtn,&QToolButton::clicked,this,&Widget::pageClick); prevPageBtn->show(); nextPageBtn = new QToolButton(this); nextPageBtn->setIcon(QPixmap(":/img/pics/next.png")); nextPageBtn->setGeometry(size.width()*3750/3840,size.height()*204/2160,pBtnWidth,pBtnHeight); nextPageBtn->setIconSize(QSize(pBtnWidth,pBtnHeight)); nextPageBtn->setAutoRaise(true); connect(nextPageBtn,&QToolButton::clicked,this,&Widget::pageClick); nextPageBtn->show(); } void Widget::setAlarmInfoLabels(QSize size) { QFont font("Microsoft YaHei"); font.setFamily("Microsoft YaHei"); font.setPointSize(size.width()*24/3840); for(int i=0;i<9;i++){ AlarmInfoLabel[i*2+0] = new CustQLabel(this); AlarmInfoLabel[i*2+0]->setGeometry(size.width()*3169/3840,size.height()*1521/2160+(i*70*size.height()/2160),size.width()*100/3840,size.height()*40/2160); AlarmInfoLabel[i*2+0]->setStyleSheet("color: rgba(255, 255, 255, 255)"); connect(AlarmInfoLabel[i*2+0],&CustQLabel::clicked,this,&Widget::devClick); AlarmInfoLabel[i*2+0]->show(); AlarmInfoLabel[i*2+1] = new CustQLabel(this); AlarmInfoLabel[i*2+1]->setGeometry(size.width()*3279/3840,size.height()*1521/2160+(i*70*size.height()/2160),size.width()*510/3840,size.height()*40/2160); AlarmInfoLabel[i*2+1]->setStyleSheet("color: rgba(255, 0, 0, 255)"); connect(AlarmInfoLabel[i*2+1],&CustQLabel::clicked,this,&Widget::devClick); AlarmInfoLabel[i*2+1]->show(); } } void Widget::setNoteLabels(QSize size) { NoteBgLabel = new QLabel(this); NoteBgLabel->setGeometry(0,0,size.width(),size.height()); NoteBgLabel->setStyleSheet("background-color: rgba(0,0,0,64);"); NoteBgLabel->hide(); NoteLabel = new QLabel(this); NoteLabel->setGeometry((size.width()-400)/2+5,(size.height()-300)/2+5,400,300); NoteLabel->setStyleSheet("background-color: rgba(0,0,0,128);"); NoteLabel->hide(); NoteBtn = new CustQLabel(this); NoteBtn->setGeometry(size.width()/2+340,(size.height()-600)/2+2,58,38); NoteBtn->setStyleSheet("background-color: rgba(255,0,0,196);border:2px,rgba(255,0,0,255);color: rgba(255,255,255,255);"); NoteBtn->setAlignment(Qt::AlignCenter); NoteBtn->setText("X"); connect(NoteBtn,&CustQLabel::clicked,this,&Widget::devClick); NoteBtn->hide(); } void Widget::setDevInfoLabels(QSize size) { QFont font("Microsoft YaHei"); font.setFamily("Microsoft YaHei"); font.setPointSize(size.width()*24/3840); for(int i=0;i<13;i++){ DevInfoLabel[i*3+0] = new CustQLabel(this); DevInfoLabel[i*3+0]->setGeometry(size.width()*3169/3840,size.height()*385/2160+(i*70*size.height()/2160),size.width()*240/3840,size.height()*40/2160); DevInfoLabel[i*3+0]->setStyleSheet("color: rgba(255, 255, 255, 255)"); connect(DevInfoLabel[i*3+0],&CustQLabel::clicked,this,&Widget::devClick); DevInfoLabel[i*3+0]->show(); DevInfoLabel[i*3+1] = new CustQLabel(this); DevInfoLabel[i*3+1]->setGeometry(size.width()*3419/3840,size.height()*385/2160+(i*70*size.height()/2160),size.width()*100/3840,size.height()*40/2160); DevInfoLabel[i*3+1]->setStyleSheet("color: rgba(0, 255, 186, 255)"); connect(DevInfoLabel[i*3+1],&CustQLabel::clicked,this,&Widget::devClick); DevInfoLabel[i*3+1]->show(); DevInfoLabel[i*3+2] = new CustQLabel(this); DevInfoLabel[i*3+2]->setGeometry(size.width()*3525/3840,size.height()*385/2160+(i*70*size.height()/2160),size.width()*270/3840,size.height()*40/2160); DevInfoLabel[i*3+2]->setStyleSheet("color: rgba(255, 234, 0, 255)"); connect(DevInfoLabel[i*3+2],&CustQLabel::clicked,this,&Widget::devClick); DevInfoLabel[i*3+2]->show(); } } void Widget::devClick() { CustQLabel *label = (CustQLabel *)sender(); for(int i=0;i<39;i++){ if(label == DevInfoLabel[i]){ DevInfo *info = deviceList.at(devPage*13+i/3); DevDataForm *form = new DevDataForm(this,info->DevName,info->DevDataInfoList); connect(form,&DevDataForm::cancel,this,&Widget::cancel); form->setGeometry((this->size().width()-400)/2,(this->size().height()-300)/2,400,300); NoteBgLabel->show(); NoteLabel->show(); form->show(); return; } } for(int i=0;i<18;i++){ if(label == AlarmInfoLabel[i]){ AlarmInfo info = alarmList.at(i/2); AlarmInfoForm *form = new AlarmInfoForm(this, info.DevName, info.AlarmTime.toString("yyyy-MM-dd HH:mm:ss"), QString("%1,%2").arg(info.DevType).arg(info.Alarminfo)); connect(form,&AlarmInfoForm::cancel,this,&Widget::cancel); form->setGeometry((this->size().width()-400)/2,(this->size().height()-300)/2,400,300); NoteBgLabel->show(); NoteLabel->show(); form->show(); return; } } if(label==NoteBtn){ NoteBgLabel->hide(); NoteLabel->setText(""); NoteLabel->hide(); NoteBtn->hide(); } } void Widget::setPieView(QSize size) { for(int i=0;i<5;i++){ pieView[i] = new QGraphicsView(this); pieView[i]->setGeometry(size.width()*2718/3840,size.height()*312/2160+(size.height()*376*i/2160),size.width()*281/3840, size.height()*281/2160); pieView[i]->setStyleSheet("padding:0px;border:0px;background: transparent;"); series[i] = new QPieSeries(); QList sliceList; QPieSlice *v1 = new QPieSlice(QString::fromUtf8("已处置"),100,this); v1->setBorderWidth(4); v1->setBorderColor(QColor(255,255,255,128)); v1->setColor(QColor(0,255,0,255)); sliceList.append(v1); QPieSlice *v2 = new QPieSlice(QString::fromUtf8("未处置"),0,this); v2->setBorderWidth(4); v2->setBorderColor(QColor(255,255,255,128)); v2->setColor(QColor(255,255,255,128)); sliceList.append(v2); series[i]->append(sliceList); series[i]->setHoleSize(0.70); series[i]->setPieSize(0.95); QChart *chart = new QChart(); chart->setCursor(QCursor(Qt::PointingHandCursor)); chart->addSeries(series[i]); chart->legend()->hide(); chart->setBackgroundVisible(false); chart->setMargins(QMargins(0,0,0,0)); chart->resize(150,150); QChartView *chartview = new QChartView(chart,pieView[i]); chartview->setRenderHint(QPainter::Antialiasing); chartview->show(); pieView[i]->show(); } }