| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476 |
- #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;i<deviceList.length();i++){
- DevInfo *info = deviceList.at(i);
- if(QString::compare(devCode,info->DevCode)==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()<<jAction;
- if(QString::compare(jAction,"getSyncStatusVListByCompany")==0){
- if((!root.value("RESULT").isUndefined())&&(!root.value("RESULT").isNull())){
- QJsonArray jResultList = root.value("RESULT").toArray();
- for(int k=0;k<jResultList.size();k++){
- QJsonObject jResult = jResultList.at(k).toObject();
- if((!jResult.value("point_list").isUndefined())&&(!jResult.value("point_list").isNull())){
- // qDebug()<<QJsonDocument(jResult.value("point_list").toArray()).toJson();
- QJsonArray jPointList = jResult.value("point_list").toArray();
- uint t = QDateTime::fromString("2020-01-01 00:00:00","yyyy-MM-dd HH:mm:ss").toTime_t();
- for(int i=0;i<jPointList.size();i++){
- QJsonObject jPoint = jPointList.at(i).toObject();
- if((!jPoint.value("device_id").isUndefined())&&(!jPoint.value("device_id").isNull())
- &&(!jPoint.value("data_time").isUndefined())&&(!jPoint.value("data_time").isNull())
- &&(!jPoint.value("point_data").isUndefined()&&(!jPoint.value("point_data").isNull()))
- &&(!jPoint.value("point_code").isUndefined())&&(!jPoint.value("point_code").isNull())
- &&(!jPoint.value("content").isUndefined())&&(!jPoint.value("content").isNull())){
- QString devCode = jPoint.value("device_id").toString();
- // QString pointCode = jPoint.value("point_code").toString();
- // QString pointData = jPoint.value("point_data").toString();
- // QString Content = jPoint.value("content").toString();
- QString dataTime = jPoint.value("data_time").toString();
- if(QDateTime::fromString(dataTime,"yyyy-MM-dd HH:mm:ss").toTime_t()>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<jList.size();i++){
- QJsonObject obj = jList.at(i).toObject();
- if((!obj.value("company_code").isUndefined())&&(!obj.value("company_code").isNull())){
- COMPANYCODE = obj.value("company_code").toString();
- CompanyCode.append(COMPANYCODE);
- if((!obj.value("company_name").isUndefined())&&(!obj.value("company_name").isNull()))
- CompanyName.append(obj.value("company_name").toString());
- if((!obj.value("address").isUndefined())&&(!obj.value("address").isNull()))
- Address.append(obj.value("address").toString());
- if((!obj.value("lng").isUndefined())&&(!obj.value("lng").isNull())
- &&(!obj.value("lat").isUndefined())&&(!obj.value("lat").isNull()))
- CompanyGPS.append(QString("%1, %2").arg(QString::number(obj.value("lng").toDouble(),'f',4)).arg(QString::number(obj.value("lat").toDouble(),'f',4)));
- if((!obj.value("username").isUndefined())&&(!obj.value("username").isNull()))
- userName.append(obj.value("username").toString());
- if((!obj.value("phone").isUndefined())&&(!obj.value("phone").isNull()))
- Phone.append(obj.value("phone").toString());
- }
- }
- }
- if((!root.value("ALARM").isUndefined())&&(!root.value("ALARM").isNull())){
- QJsonArray jList = root.value("ALARM").toArray();
- QList<AlarmInfo> tmpList;
- for(int i=0;i<jList.size();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())){
- switch (obj.value("dwtype").toString().toInt()) {
- case 1:
- case 3:
- tmpList.append(AlarmInfo(obj.value("name").toString(),
- QString::fromUtf8("火灾监控"),
- obj.value("data").toString(),
- obj.value("time").toString()));
- break;
- case 2:
- case 4:
- case 5:
- tmpList.append(AlarmInfo(obj.value("name").toString(),
- QString::fromUtf8("水系统"),
- obj.value("data").toString(),
- obj.value("time").toString()));
- break;
- case 6:
- tmpList.append(AlarmInfo(obj.value("name").toString(),
- QString::fromUtf8("RTU"),
- obj.value("data").toString(),
- obj.value("time").toString()));
- break;
- case 7:
- tmpList.append(AlarmInfo(obj.value("name").toString(),
- QString::fromUtf8("电气火灾"),
- obj.value("data").toString(),
- obj.value("time").toString()));
- break;
- case 16:
- tmpList.append(AlarmInfo(obj.value("name").toString(),
- QString::fromUtf8("视频告警"),
- obj.value("data").toString(),
- obj.value("time").toString()));
- break;
- default:
- tmpList.append(AlarmInfo(obj.value("name").toString(),
- QString::fromUtf8("通用"),
- obj.value("data").toString(),
- obj.value("time").toString()));
- break;
- }
- }
- }
- for(int i=(tmpList.length()-1);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<DevInfo *> tmpList;
- for(int i=0;i<jList.size();i++){
- QJsonObject obj = jList.at(i).toObject();
- if((!obj.value("device_name").isUndefined())&&(!obj.value("device_name").isNull())
- &&(!obj.value("min_level").isUndefined())&&(!obj.value("min_level").isNull())
- &&(!obj.value("object_name").isUndefined())&&(!obj.value("object_name").isNull())
- &&(!obj.value("owner_code").isUndefined())&&(!obj.value("owner_code").isNull())
- &&(!obj.value("owner_dwtype").isUndefined())&&(!obj.value("owner_dwtype").isNull())){
- switch (obj.value("owner_dwtype").toInt()) {
- case 1:
- case 3:
- tmpList.append(new DevInfo(obj.value("device_name").toString(),
- QString::fromUtf8("火灾监控"),
- QString("%1").arg(obj.value("min_level").toInt()),
- obj.value("owner_code").toString(),
- obj.value("object_name").toString()));
- break;
- case 2:
- case 4:
- case 5:
- tmpList.append(new DevInfo(obj.value("device_name").toString(),
- QString::fromUtf8("水系统"),
- QString("%1").arg(obj.value("min_level").toInt()),
- obj.value("owner_code").toString(),
- obj.value("object_name").toString()));
- break;
- case 6:
- tmpList.append(new DevInfo(obj.value("device_name").toString(),
- QString::fromUtf8("RTU"),
- QString("%1").arg(obj.value("min_level").toInt()),
- obj.value("owner_code").toString(),
- obj.value("object_name").toString()));
- break;
- case 7:
- tmpList.append(new DevInfo(obj.value("device_name").toString(),
- QString::fromUtf8("电气火灾"),
- QString("%1").arg(obj.value("min_level").toInt()),
- obj.value("owner_code").toString(),
- obj.value("object_name").toString()));
- break;
- case 16:
- tmpList.append(new DevInfo(obj.value("device_name").toString(),
- QString::fromUtf8("视频告警"),
- QString("%1").arg(obj.value("min_level").toInt()),
- obj.value("owner_code").toString(),
- obj.value("object_name").toString()));
- break;
- default:
- tmpList.append(new DevInfo(obj.value("device_name").toString(),
- QString::fromUtf8("通用"),
- QString("%1").arg(obj.value("min_level").toInt()),
- obj.value("owner_code").toString(),
- obj.value("object_name").toString()));
- break;
- }
- }
- }
- if(COMPANYCODE.compare(CompanyIdList.at(0))==0)
- deviceList.clear();
- deviceList.append(tmpList);
- devPage = 0;
- if(COMPANYCODE.compare(CompanyIdList.at(CompanyIdList.length()-1))==0)
- setDevInfo();
- }
- }
- }
- }
- }
- void Widget::getDcData(QString data)
- {
- logThread->appendLog(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<ett))
- isday = true;
- QImage image;
- QString imgname = "";
- if(isday){
- int weatherCode = dayWeatherCode.toInt();
- if((weatherCode>=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<alarmList.length();i++){
- AlarmInfo obj = alarmList.at(i);
- if(obj.AlarmTime.toTime_t()>=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<QPieSlice *> 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();
- }
- }
|