widget.cpp 82 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476
  1. #include "widget.h"
  2. #include "ui_widget.h"
  3. Widget::Widget(QWidget *parent)
  4. : QWidget(parent)
  5. , ui(new Ui::Widget)
  6. {
  7. getWeather = new GetWeather(this);
  8. logThread = new LogThread(this);
  9. dbThread = new DBThread(this);
  10. connect(dbThread,&DBThread::getParam,this,&Widget::getParam);
  11. deviceList.clear();
  12. alarmList.clear();
  13. firstTime = true;
  14. weekday.clear();
  15. weekday<<"日"<<"一"<<"二"<<"三"<<"四"<<"五"<<"六";
  16. weatherstring.clear();
  17. weatherstring<<"晴"<<"多云"<<"阴"<<"阵雨"<<"雷阵雨"<<"雷阵雨伴有冰雹"
  18. <<"雨夹雪"<<"小雨"<<"中雨"<<"大雨"<<"暴雨"<<"大暴雨"<<"特大暴雨"
  19. <<"阵雪"<<"小雪"<<"中雪"<<"大雪"<<"暴雪"<<"雾"<<"冻雨"<<"沙尘暴"
  20. <<"小雨-中雨"<<"中雨-大雨"<<"大雨-暴雨"<<"暴雨-大暴雨"<<"大暴雨-特大暴雨"
  21. <<"小雪-中雪"<<"中雪-大雪"<<"大雪-暴雪"<<"浮尘"<<"扬沙"<<"强沙尘暴"<<"霾";
  22. dayWeather = "";
  23. dayWeatherCode = "99";
  24. nightWeather = "";
  25. nightWeatherCode = "99";
  26. dayTemperature = "";
  27. nightTemperature = "";
  28. sunBegin = "06:00";
  29. sunEnd = "17:00";
  30. TermId = "";//博华
  31. TermKey = "";
  32. Loginname = "";
  33. Password = "";
  34. CompanyId = "10122";
  35. AppUrl = "https://fire.usky.cn:8443";
  36. dbThread->initdb();
  37. for(int i=0;i<5;i++)
  38. {
  39. AlarmCount[i] = 0;
  40. AlarmConfrmCount[i] = 0;
  41. }
  42. frontpage = new getFrontPage(this,Loginname,Password,CompanyId,AppUrl);
  43. speechThread = new SpeechThread(this);
  44. ui->setupUi(this);
  45. setAttribute(Qt::WA_TranslucentBackground,true);
  46. this->activateWindow();
  47. count = 0;
  48. day = 0;
  49. hour = 255;
  50. timer = new QTimer(this);
  51. a_timer = new QTimer(this);
  52. showFullScreen();
  53. QSize size = this->size();
  54. setBackground(size);
  55. setPieView(size);
  56. setWeatherLabel(size);
  57. setOperationBtn(size);
  58. setDateLabel(size);
  59. setTimeLabel(size);
  60. setAlarmBarLabels(size);
  61. setDevLabels(size);
  62. setDevInfoLabels(size);
  63. setAlarmInfoLabels(size);
  64. setNoteLabels(size);
  65. logThread->start();
  66. connect(getWeather,&GetWeather::get_weather,this,&Widget::get_weather);
  67. connect(frontpage,&getFrontPage::getFrontpage,this,&Widget::getFrontpage);
  68. connect(timer,&QTimer::timeout,this,&Widget::timeout);
  69. connect(a_timer,&QTimer::timeout,this,&Widget::closeAlarmBar);
  70. this->start();
  71. }
  72. Widget::~Widget()
  73. {
  74. logThread->stop();
  75. delete ui;
  76. }
  77. void Widget::start()
  78. {
  79. timer->start(500);
  80. hour = QDateTime::currentDateTime().time().hour()/3;
  81. getWeather->sendRequest();
  82. frontpage->sendRequest();
  83. dbThread->start();
  84. speechThread->start();
  85. connectDC();
  86. }
  87. void Widget::getParam(QString appid, QString key, QString name, QString pass, QString comid, QString url)
  88. {
  89. TermId = appid;
  90. TermKey = key;
  91. Loginname = name;
  92. Password = pass;
  93. CompanyId = comid;
  94. AppUrl = url;
  95. CompanyIdList.clear();
  96. if(CompanyId.indexOf(",")>0)
  97. CompanyIdList = CompanyId.split(",");
  98. else
  99. CompanyIdList.append(CompanyId);
  100. }
  101. void Widget::connectDC()
  102. {
  103. //wsc = new WebsocketClient(this,"47.98.201.73",55128,TermId,TermKey);
  104. wsc = new WebsocketClient(this,"wss://iot.usky.cn",55120,TermId,TermKey);
  105. connect(wsc,&WebsocketClient::getData,this,&Widget::getDcData);
  106. connect(wsc,&WebsocketClient::SoClosed,this,&Widget::DcSoClosed);
  107. }
  108. void Widget::setPieVlue(QGraphicsView *view, int value)
  109. {
  110. QColor color;
  111. if(value<60)
  112. color = QColor(255,0,0,255);
  113. else if(value<75)
  114. color = QColor(0,0,255,255);
  115. else
  116. color = QColor(0,255,0,255);
  117. for(int i=0;i<5;i++){
  118. if(pieView[i]==view){
  119. series[i]->slices().at(0)->setValue(value);
  120. series[i]->slices().at(0)->setColor(color);
  121. series[i]->slices().at(1)->setValue(100-value);
  122. }
  123. }
  124. }
  125. void Widget::setDevInfo()
  126. {
  127. if(devPage>0)
  128. prevPageBtn->setEnabled(true);
  129. else
  130. prevPageBtn->setEnabled(false);
  131. if(deviceList.length()>((devPage+1)*13))
  132. nextPageBtn->setEnabled(true);
  133. else
  134. nextPageBtn->setEnabled(false);
  135. for(int i=0;i<39;i++)
  136. DevInfoLabel[i]->setText("");
  137. for(int i=0;i<13;i++){
  138. if((devPage*13+i)>=deviceList.length())
  139. break;
  140. DevInfo *info = deviceList.at(devPage*13+i);
  141. DevInfoLabel[i*3+0]->setText(info->DevName);
  142. DevInfoLabel[i*3+1]->setText(info->DevType);
  143. DevInfoLabel[i*3+2]->setText(info->DeviceInfo);
  144. }
  145. }
  146. void Widget::setAlarmInfo()
  147. {
  148. for(int i=0;i<18;i++)
  149. AlarmInfoLabel[i]->setText("");
  150. for(int i=0;i<9;i++){
  151. if(i>=(alarmList.length()))
  152. break;
  153. AlarmInfo info = alarmList.at(i);
  154. AlarmInfoLabel[i*2+0]->setText(info.DevType);
  155. AlarmInfoLabel[i*2+1]->setText(QString::fromUtf8("%1,%2,%3")
  156. .arg(info.Alarminfo)
  157. .arg(info.DevName)
  158. .arg(info.AlarmTime.toString("yyyy-MM-dd HH:mm:ss")));
  159. }
  160. }
  161. void Widget::setDevData(QString devCode, QJsonObject data)
  162. {
  163. for(int i=0;i<deviceList.length();i++){
  164. DevInfo *info = deviceList.at(i);
  165. if(QString::compare(devCode,info->DevCode)==0){
  166. info->appendData(data);
  167. break;
  168. }
  169. }
  170. }
  171. void Widget::getFrontpage(QString data)
  172. {
  173. logThread->appendLog(QString("[ %1 frontpage ] get data: %2")
  174. .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss.zzz"))
  175. .arg(data.trimmed()));
  176. QSize size = this->size();
  177. QJsonParseError json_error;
  178. QJsonDocument jsonDoc(QJsonDocument::fromJson(data.trimmed().toUtf8(),&json_error));
  179. if(json_error.error==QJsonParseError::NoError){
  180. QJsonObject root = jsonDoc.object();
  181. if((!root.value("action").isUndefined())&&(!root.value("action").isNull())){
  182. QString jAction = root.value("action").toString();
  183. // qDebug()<<jAction;
  184. if(QString::compare(jAction,"getSyncStatusVListByCompany")==0){
  185. if((!root.value("RESULT").isUndefined())&&(!root.value("RESULT").isNull())){
  186. QJsonArray jResultList = root.value("RESULT").toArray();
  187. for(int k=0;k<jResultList.size();k++){
  188. QJsonObject jResult = jResultList.at(k).toObject();
  189. if((!jResult.value("point_list").isUndefined())&&(!jResult.value("point_list").isNull())){
  190. // qDebug()<<QJsonDocument(jResult.value("point_list").toArray()).toJson();
  191. QJsonArray jPointList = jResult.value("point_list").toArray();
  192. uint t = QDateTime::fromString("2020-01-01 00:00:00","yyyy-MM-dd HH:mm:ss").toTime_t();
  193. for(int i=0;i<jPointList.size();i++){
  194. QJsonObject jPoint = jPointList.at(i).toObject();
  195. if((!jPoint.value("device_id").isUndefined())&&(!jPoint.value("device_id").isNull())
  196. &&(!jPoint.value("data_time").isUndefined())&&(!jPoint.value("data_time").isNull())
  197. &&(!jPoint.value("point_data").isUndefined()&&(!jPoint.value("point_data").isNull()))
  198. &&(!jPoint.value("point_code").isUndefined())&&(!jPoint.value("point_code").isNull())
  199. &&(!jPoint.value("content").isUndefined())&&(!jPoint.value("content").isNull())){
  200. QString devCode = jPoint.value("device_id").toString();
  201. // QString pointCode = jPoint.value("point_code").toString();
  202. // QString pointData = jPoint.value("point_data").toString();
  203. // QString Content = jPoint.value("content").toString();
  204. QString dataTime = jPoint.value("data_time").toString();
  205. if(QDateTime::fromString(dataTime,"yyyy-MM-dd HH:mm:ss").toTime_t()>t){
  206. setDevData(devCode,jPoint);
  207. }
  208. }
  209. }
  210. }
  211. }
  212. }
  213. }else if(QString::compare(jAction,"getFrontpageQuery")==0){
  214. if(!firstTime){
  215. if((!root.value("ALARM").isUndefined())&&(!root.value("ALARM").isNull())){
  216. QJsonArray jList = root.value("ALARM").toArray();
  217. for(int i=(jList.size()-1);i>=0;i--){
  218. QJsonObject obj = jList.at(i).toObject();
  219. if((!obj.value("name").isUndefined())&&(!obj.value("name").isNull())
  220. &&(!obj.value("dwtype").isUndefined())&&(!obj.value("dwtype").isNull())
  221. &&(!obj.value("data").isUndefined())&&(!obj.value("data").isNull())
  222. &&(!obj.value("time").isUndefined())&&(!obj.value("time").isNull())){
  223. // QString devName = root.value("name").toString();
  224. // QString alarm_info = root.value("data").toString();
  225. QString alarm_time = root.value("time").toString();
  226. QDateTime dt = QDateTime::fromString(alarm_time,"yyyy-MM-dd HH:mm:ss");
  227. if((dt.toTime_t()>alarmList.first().AlarmTime.toTime_t())){
  228. AlarmInfo info;
  229. switch (obj.value("dwtype").toString().toInt()) {
  230. case 1:
  231. case 3:
  232. info = AlarmInfo(obj.value("name").toString(),
  233. QString::fromUtf8("火灾监控"),
  234. obj.value("data").toString(),
  235. obj.value("time").toString());
  236. break;
  237. case 2:
  238. case 4:
  239. case 5:
  240. info = AlarmInfo(obj.value("name").toString(),
  241. QString::fromUtf8("水系统"),
  242. obj.value("data").toString(),
  243. obj.value("time").toString());
  244. break;
  245. case 6:
  246. info = AlarmInfo(obj.value("name").toString(),
  247. QString::fromUtf8("RTU"),
  248. obj.value("data").toString(),
  249. obj.value("time").toString());
  250. break;
  251. case 7:
  252. info = AlarmInfo(obj.value("name").toString(),
  253. QString::fromUtf8("电气火灾"),
  254. obj.value("data").toString(),
  255. obj.value("time").toString());
  256. break;
  257. case 16:
  258. info = AlarmInfo(obj.value("name").toString(),
  259. QString::fromUtf8("视频告警"),
  260. obj.value("data").toString(),
  261. obj.value("time").toString());
  262. break;
  263. default:
  264. info = AlarmInfo(obj.value("name").toString(),
  265. QString::fromUtf8("通用"),
  266. obj.value("data").toString(),
  267. obj.value("time").toString());
  268. break;
  269. }
  270. if(isNewAlarm(info)){
  271. alarmList.insert(0,info);
  272. if(alarmList.length()>10)
  273. alarmList.removeLast();
  274. speechThread->append(QString::fromUtf8("%1报告,%2,%3").arg(info.DevType).arg(info.DevName).arg(info.Alarminfo));
  275. setAlarmInfo();
  276. }
  277. }
  278. }
  279. }
  280. }
  281. return;
  282. }
  283. firstTime = false;
  284. QString COMPANYCODE="";
  285. if((!root.value("LIST").isUndefined())&&(!root.value("LIST").isNull())){
  286. CompanyName.clear();
  287. Address.clear();
  288. CompanyGPS.clear();
  289. userName.clear();
  290. Phone.clear();
  291. CompanyCode.clear();
  292. QJsonArray jList = root.value("LIST").toArray();
  293. for(int i=0;i<jList.size();i++){
  294. QJsonObject obj = jList.at(i).toObject();
  295. if((!obj.value("company_code").isUndefined())&&(!obj.value("company_code").isNull())){
  296. COMPANYCODE = obj.value("company_code").toString();
  297. CompanyCode.append(COMPANYCODE);
  298. if((!obj.value("company_name").isUndefined())&&(!obj.value("company_name").isNull()))
  299. CompanyName.append(obj.value("company_name").toString());
  300. if((!obj.value("address").isUndefined())&&(!obj.value("address").isNull()))
  301. Address.append(obj.value("address").toString());
  302. if((!obj.value("lng").isUndefined())&&(!obj.value("lng").isNull())
  303. &&(!obj.value("lat").isUndefined())&&(!obj.value("lat").isNull()))
  304. CompanyGPS.append(QString("%1, %2").arg(QString::number(obj.value("lng").toDouble(),'f',4)).arg(QString::number(obj.value("lat").toDouble(),'f',4)));
  305. if((!obj.value("username").isUndefined())&&(!obj.value("username").isNull()))
  306. userName.append(obj.value("username").toString());
  307. if((!obj.value("phone").isUndefined())&&(!obj.value("phone").isNull()))
  308. Phone.append(obj.value("phone").toString());
  309. }
  310. }
  311. }
  312. if((!root.value("ALARM").isUndefined())&&(!root.value("ALARM").isNull())){
  313. QJsonArray jList = root.value("ALARM").toArray();
  314. QList<AlarmInfo> tmpList;
  315. for(int i=0;i<jList.size();i++){
  316. QJsonObject obj = jList.at(i).toObject();
  317. if((!obj.value("name").isUndefined())&&(!obj.value("name").isNull())
  318. &&(!obj.value("dwtype").isUndefined())&&(!obj.value("dwtype").isNull())
  319. &&(!obj.value("data").isUndefined())&&(!obj.value("data").isNull())
  320. &&(!obj.value("time").isUndefined())&&(!obj.value("time").isNull())){
  321. switch (obj.value("dwtype").toString().toInt()) {
  322. case 1:
  323. case 3:
  324. tmpList.append(AlarmInfo(obj.value("name").toString(),
  325. QString::fromUtf8("火灾监控"),
  326. obj.value("data").toString(),
  327. obj.value("time").toString()));
  328. break;
  329. case 2:
  330. case 4:
  331. case 5:
  332. tmpList.append(AlarmInfo(obj.value("name").toString(),
  333. QString::fromUtf8("水系统"),
  334. obj.value("data").toString(),
  335. obj.value("time").toString()));
  336. break;
  337. case 6:
  338. tmpList.append(AlarmInfo(obj.value("name").toString(),
  339. QString::fromUtf8("RTU"),
  340. obj.value("data").toString(),
  341. obj.value("time").toString()));
  342. break;
  343. case 7:
  344. tmpList.append(AlarmInfo(obj.value("name").toString(),
  345. QString::fromUtf8("电气火灾"),
  346. obj.value("data").toString(),
  347. obj.value("time").toString()));
  348. break;
  349. case 16:
  350. tmpList.append(AlarmInfo(obj.value("name").toString(),
  351. QString::fromUtf8("视频告警"),
  352. obj.value("data").toString(),
  353. obj.value("time").toString()));
  354. break;
  355. default:
  356. tmpList.append(AlarmInfo(obj.value("name").toString(),
  357. QString::fromUtf8("通用"),
  358. obj.value("data").toString(),
  359. obj.value("time").toString()));
  360. break;
  361. }
  362. }
  363. }
  364. for(int i=(tmpList.length()-1);i>=0;i--){
  365. AlarmInfo info = tmpList.at(i);
  366. if(isNewAlarm(info)){
  367. speechThread->append(QString::fromUtf8("%1报告,%2,%3,%4")
  368. .arg(info.DevType)
  369. .arg(info.DevName)
  370. .arg(info.Alarminfo)
  371. .arg(info.AlarmTime.toString("HH:mm:ss")));
  372. }
  373. }
  374. alarmList.clear();
  375. alarmList.append(tmpList);
  376. // speechThread->append(QString::fromUtf8("%1报告,%2,%3").arg(alarmList.first().DevType).arg(alarmList.first().DevName).arg(alarmList.first().Alarminfo));
  377. setAlarmInfo();
  378. }
  379. }else if(QString::compare(jAction,"getCurrentObjectListByCompanyId")==0){
  380. QString COMPANYCODE = "";
  381. if((!root.value("COMPANY").isUndefined())&&(!root.value("COMPANY").isNull())){
  382. QJsonObject jCompany = root.value("COMPANY").toObject();
  383. if((!jCompany.value("company_code").isUndefined())&&(!jCompany.value("company_code").isNull()))
  384. COMPANYCODE = jCompany.value("company_code").toString();
  385. if(COMPANYCODE.compare(CompanyIdList.at(0))==0){
  386. for(int i=0;i<5;i++){
  387. DevCountLabelValue[i] = 0;
  388. OutCountLabelValue[i] = 0;
  389. AlarmCountLabelValue[i] = 0;
  390. AlarmUncomCountLabelValue[i] = 0;
  391. AlarmComCountLabelValue[i] = 0;
  392. AlarmUncomPLabelValue[i] = 0;
  393. AlarmComPLabelValue[i] = 0;
  394. AlarmPLabelValue[i] = 0;
  395. AlarmCount[i] = 0;
  396. AlarmConfrmCount[i] = 0;
  397. }
  398. }
  399. if((!jCompany.value("d7").isUndefined())&&(!jCompany.value("d7").isNull()))
  400. DevCountLabelValue[0] += jCompany.value("d7").toInt();
  401. if((!jCompany.value("d7o").isUndefined())&&(!jCompany.value("d7o").isNull()))
  402. OutCountLabelValue[0] += jCompany.value("d7o").toInt();
  403. if((!jCompany.value("d7a").isUndefined())&&(!jCompany.value("d7a").isNull()))
  404. AlarmCount[0] += jCompany.value("d7a").toInt();
  405. if((!jCompany.value("d7ac").isUndefined())&&(!jCompany.value("d7ac").isNull()))
  406. AlarmConfrmCount[0] += jCompany.value("d7ac").toInt();
  407. if(COMPANYCODE.compare(CompanyIdList.at(CompanyIdList.length()-1))==0){
  408. DevCountLabel[0]->setText(QString("%1").arg(DevCountLabelValue[0]));
  409. OutCountLabel[0]->setText(QString("%1").arg(OutCountLabelValue[0]));
  410. AlarmCountLabel[0]->setText(QString("%1").arg(AlarmCount[0]));
  411. AlarmUncomCountLabel[0]->setText(QString("%1").arg(AlarmCount[0]-AlarmConfrmCount[0]));
  412. AlarmComCountLabel[0]->setText(QString("%1").arg(AlarmConfrmCount[0]));
  413. if(AlarmCount[0]==0){
  414. AlarmComPLabel[0]->setText("100.00%");
  415. AlarmUncomPLabel[0]->setText("0.00%");
  416. AlarmPLabel[0]->setText("100%");
  417. AlarmBarValueLabel[0]->resize(0,size.height()*32/2160);
  418. AlarmBarValueLabel[1]->resize(size.width()*755/3840,size.height()*32/2160);
  419. setPieVlue(pieView[0],100);
  420. }else{
  421. AlarmComPLabel[0]->setText(QString("%1%").arg(QString::number((AlarmConfrmCount[0]*100.0/(AlarmCount[0]*1.0)),'f',2)));
  422. AlarmUncomPLabel[0]->setText(QString("%1%").arg(QString::number(((AlarmCount[0]*100.0-AlarmConfrmCount[0]*100.0)/(AlarmCount[0]*1.0)),'f',2)));
  423. AlarmPLabel[0]->setText(QString("%1%").arg(AlarmConfrmCount[0]*100/AlarmCount[0]));
  424. AlarmBarValueLabel[0]->resize((AlarmCount[0]-AlarmConfrmCount[0])*755/(AlarmCount[0]*3840/size.width()),size.height()*32/2160);
  425. AlarmBarValueLabel[1]->resize(AlarmConfrmCount[0]*755/(AlarmCount[0]*3840/size.width()),size.height()*32/2160);
  426. setPieVlue(pieView[0],AlarmConfrmCount[0]*100/AlarmCount[0]);
  427. }
  428. }
  429. // if((!jCompany.value("d7").isUndefined())&&(!jCompany.value("d7").isNull()))
  430. // DevCountLabel[0]->setText(QString("%1").arg(jCompany.value("d7").toInt()));
  431. // else
  432. // DevCountLabel[0]->setText("0");
  433. // if((!jCompany.value("d7o").isUndefined())&&(!jCompany.value("d7o").isNull()))
  434. // OutCountLabel[0]->setText(QString("%1").arg(jCompany.value("d7o").toInt()));
  435. // else
  436. // OutCountLabel[0]->setText("0");
  437. // if((!jCompany.value("d7a").isUndefined())&&(!jCompany.value("d7a").isNull()))
  438. // AlarmCount[0] = jCompany.value("d7a").toInt();
  439. // else
  440. // AlarmCount[0] = 0;
  441. // if((!jCompany.value("d7ac").isUndefined())&&(!jCompany.value("d7ac").isNull()))
  442. // AlarmConfrmCount[0] = jCompany.value("d7ac").toInt();
  443. // else
  444. // AlarmConfrmCount[0] = 0;
  445. // AlarmCountLabel[0]->setText(QString("%1").arg(AlarmCount[0]));
  446. // AlarmUncomCountLabel[0]->setText(QString("%1").arg(AlarmCount[0]-AlarmConfrmCount[0]));
  447. // AlarmComCountLabel[0]->setText(QString("%1").arg(AlarmConfrmCount[0]));
  448. // if(AlarmCount[0]==0){
  449. // AlarmComPLabel[0]->setText("100.00%");
  450. // AlarmUncomPLabel[0]->setText("0.00%");
  451. // AlarmPLabel[0]->setText("100%");
  452. // AlarmBarValueLabel[0]->resize(0,size.height()*32/2160);
  453. // AlarmBarValueLabel[1]->resize(size.width()*755/3840,size.height()*32/2160);
  454. // setPieVlue(pieView[0],100);
  455. // }else{
  456. // AlarmComPLabel[0]->setText(QString("%1%").arg(QString::number((AlarmConfrmCount[0]*100.0/(AlarmCount[0]*1.0)),'f',2)));
  457. // AlarmUncomPLabel[0]->setText(QString("%1%").arg(QString::number(((AlarmCount[0]*100.0-AlarmConfrmCount[0]*100.0)/(AlarmCount[0]*1.0)),'f',2)));
  458. // AlarmPLabel[0]->setText(QString("%1%").arg(AlarmConfrmCount[0]*100/AlarmCount[0]));
  459. // AlarmBarValueLabel[0]->resize((AlarmCount[0]-AlarmConfrmCount[0])*755/(AlarmCount[0]*3840/size.width()),size.height()*32/2160);
  460. // AlarmBarValueLabel[1]->resize(AlarmConfrmCount[0]*755/(AlarmCount[0]*3840/size.width()),size.height()*32/2160);
  461. // setPieVlue(pieView[0],AlarmConfrmCount[0]*100/AlarmCount[0]);
  462. // }
  463. if(((!jCompany.value("d0").isUndefined())&&(!jCompany.value("d0").isNull()))&&((!jCompany.value("d2").isUndefined())&&(!jCompany.value("d2").isNull()))){
  464. DevCountLabelValue[1] += jCompany.value("d0").toInt(); //液位
  465. DevCountLabelValue[1] += jCompany.value("d2").toInt(); //水表
  466. }
  467. if(((!jCompany.value("d0o").isUndefined())&&(!jCompany.value("d0o").isNull()))&&((!jCompany.value("d2o").isUndefined())&&(!jCompany.value("d2o").isNull()))){
  468. OutCountLabelValue[1] += jCompany.value("d0o").toInt();
  469. OutCountLabelValue[1] += jCompany.value("d2o").toInt();
  470. }
  471. if(((!jCompany.value("d0a").isUndefined())&&(!jCompany.value("d0a").isNull()))&&((!jCompany.value("d2a").isUndefined())&&(!jCompany.value("d2a").isNull()))){
  472. AlarmCount[1] += jCompany.value("d0a").toInt();
  473. AlarmCount[1] += jCompany.value("d2a").toInt();
  474. }
  475. if(((!jCompany.value("d0ac").isUndefined())&&(!jCompany.value("d0ac").isNull()))&&((!jCompany.value("d2ac").isUndefined())&&(!jCompany.value("d2ac").isNull()))){
  476. AlarmConfrmCount[1] += jCompany.value("d0ac").toInt();
  477. AlarmConfrmCount[1] += jCompany.value("d2ac").toInt();
  478. }
  479. if(COMPANYCODE.compare(CompanyIdList.at(CompanyIdList.length()-1))==0){
  480. DevCountLabel[1]->setText(QString("%1").arg(DevCountLabelValue[1]));
  481. OutCountLabel[1]->setText(QString("%1").arg(OutCountLabelValue[1]));
  482. AlarmCountLabel[1]->setText(QString("%1").arg(AlarmCount[1]));
  483. AlarmUncomCountLabel[1]->setText(QString("%1").arg(AlarmCount[1]-AlarmConfrmCount[1]));
  484. AlarmComCountLabel[1]->setText(QString("%1").arg(AlarmConfrmCount[1]));
  485. if(AlarmCount[1]==0){
  486. AlarmComPLabel[1]->setText("100.00%");
  487. AlarmUncomPLabel[1]->setText("0.00%");
  488. AlarmPLabel[1]->setText("100%");
  489. AlarmBarValueLabel[2]->resize(0,size.height()*32/2160);
  490. AlarmBarValueLabel[3]->resize(size.width()*755/3840,size.height()*32/2160);
  491. setPieVlue(pieView[1],100);
  492. }else{
  493. AlarmComPLabel[1]->setText(QString("%1%").arg(QString::number((AlarmConfrmCount[1]*100.0/(AlarmCount[1]*1.0)),'f',2)));
  494. AlarmUncomPLabel[1]->setText(QString("%1%").arg(QString::number(((AlarmCount[1]*100.0-AlarmConfrmCount[1]*100.0)/(AlarmCount[1]*1.0)),'f',2)));
  495. AlarmPLabel[1]->setText(QString("%1%").arg(AlarmConfrmCount[1]*100/AlarmCount[1]));
  496. AlarmBarValueLabel[2]->resize((AlarmCount[1]-AlarmConfrmCount[1])*755/(AlarmCount[1]*3840/size.width()),size.height()*32/2160);
  497. AlarmBarValueLabel[3]->resize(AlarmConfrmCount[1]*755/(AlarmCount[1]*3840/size.width()),size.height()*32/2160);
  498. setPieVlue(pieView[1],AlarmConfrmCount[1]*100/AlarmCount[1]);
  499. }
  500. }
  501. // if((!jCompany.value("d2").isUndefined())&&(!jCompany.value("d2").isNull()))
  502. // DevCountLabel[1]->setText(QString("%1").arg(jCompany.value("d2").toInt()));
  503. // else
  504. // DevCountLabel[1]->setText("0");
  505. // if((!jCompany.value("d2o").isUndefined())&&(!jCompany.value("d2o").isNull()))
  506. // OutCountLabel[1]->setText(QString("%1").arg(jCompany.value("d2o").toInt()));
  507. // else
  508. // OutCountLabel[1]->setText("0");
  509. // if((!jCompany.value("d2a").isUndefined())&&(!jCompany.value("d2a").isNull()))
  510. // AlarmCount[1] = jCompany.value("d2a").toInt();
  511. // else
  512. // AlarmCount[1] = 0;
  513. // if((!jCompany.value("d2ac").isUndefined())&&(!jCompany.value("d2ac").isNull()))
  514. // AlarmConfrmCount[1] = jCompany.value("d2ac").toInt();
  515. // else
  516. // AlarmConfrmCount[1] = 0;
  517. // AlarmCountLabel[1]->setText(QString("%1").arg(AlarmCount[1]));
  518. // AlarmUncomCountLabel[1]->setText(QString("%1").arg(AlarmCount[1]-AlarmConfrmCount[1]));
  519. // AlarmComCountLabel[1]->setText(QString("%1").arg(AlarmConfrmCount[1]));
  520. // if(AlarmCount[1]==0){
  521. // AlarmComPLabel[1]->setText("100.00%");
  522. // AlarmUncomPLabel[1]->setText("0.00%");
  523. // AlarmPLabel[1]->setText("100%");
  524. // AlarmBarValueLabel[2]->resize(0,size.height()*32/2160);
  525. // AlarmBarValueLabel[3]->resize(size.width()*755/3840,size.height()*32/2160);
  526. // setPieVlue(pieView[1],100);
  527. // }else{
  528. // AlarmComPLabel[1]->setText(QString("%1%").arg(QString::number((AlarmConfrmCount[1]*100.0/(AlarmCount[1]*1.0)),'f',2)));
  529. // AlarmUncomPLabel[1]->setText(QString("%1%").arg(QString::number(((AlarmCount[1]*100.0-AlarmConfrmCount[1]*100.0)/(AlarmCount[1]*1.0)),'f',2)));
  530. // AlarmPLabel[1]->setText(QString("%1%").arg(AlarmConfrmCount[1]*100/AlarmCount[1]));
  531. // AlarmBarValueLabel[2]->resize((AlarmCount[1]-AlarmConfrmCount[1])*755/(AlarmCount[1]*3840/size.width()),size.height()*32/2160);
  532. // AlarmBarValueLabel[3]->resize(AlarmConfrmCount[1]*755/(AlarmCount[1]*3840/size.width()),size.height()*32/2160);
  533. // setPieVlue(pieView[1],AlarmConfrmCount[1]*100/AlarmCount[1]);
  534. // }
  535. if((!jCompany.value("d6").isUndefined())&&(!jCompany.value("d6").isNull()))
  536. DevCountLabelValue[2] += jCompany.value("d6").toInt();
  537. if((!jCompany.value("d6o").isUndefined())&&(!jCompany.value("d6o").isNull()))
  538. OutCountLabelValue[2] += jCompany.value("d6o").toInt();
  539. if((!jCompany.value("d6a").isUndefined())&&(!jCompany.value("d6a").isNull()))
  540. AlarmCount[2] += jCompany.value("d6a").toInt();
  541. if((!jCompany.value("d6ac").isUndefined())&&(!jCompany.value("d6ac").isNull()))
  542. AlarmConfrmCount[2] += jCompany.value("d6ac").toInt();
  543. if(COMPANYCODE.compare(CompanyIdList.at(CompanyIdList.length()-1))==0){
  544. DevCountLabel[2]->setText(QString("%1").arg(DevCountLabelValue[2]));
  545. OutCountLabel[2]->setText(QString("%1").arg(OutCountLabelValue[2]));
  546. AlarmCountLabel[2]->setText(QString("%1").arg(AlarmCount[2]));
  547. AlarmUncomCountLabel[2]->setText(QString("%1").arg(AlarmCount[2]-AlarmConfrmCount[2]));
  548. AlarmComCountLabel[2]->setText(QString("%1").arg(AlarmConfrmCount[2]));
  549. if(AlarmCount[2]==0){
  550. AlarmComPLabel[2]->setText("100.00%");
  551. AlarmUncomPLabel[2]->setText("0.00%");
  552. AlarmPLabel[2]->setText("100%");
  553. AlarmBarValueLabel[4]->resize(0,size.height()*32/2160);
  554. AlarmBarValueLabel[5]->resize(size.width()*755/3840,size.height()*32/2160);
  555. setPieVlue(pieView[2],100);
  556. }else{
  557. AlarmComPLabel[2]->setText(QString("%1%").arg(QString::number((AlarmConfrmCount[2]*100.0/(AlarmCount[2]*1.0)),'f',2)));
  558. AlarmUncomPLabel[2]->setText(QString("%1%").arg(QString::number(((AlarmCount[2]*100.0-AlarmConfrmCount[2]*100.0)/(AlarmCount[2]*1.0)),'f',2)));
  559. AlarmPLabel[2]->setText(QString("%1%").arg(AlarmConfrmCount[2]*100/AlarmCount[2]));
  560. AlarmBarValueLabel[4]->resize((AlarmCount[2]-AlarmConfrmCount[2])*755/(AlarmCount[2]*3840/size.width()),size.height()*32/2160);
  561. AlarmBarValueLabel[5]->resize(AlarmConfrmCount[2]*755/(AlarmCount[2]*3840/size.width()),size.height()*32/2160);
  562. setPieVlue(pieView[2],AlarmConfrmCount[2]*100/AlarmCount[2]);
  563. }
  564. }
  565. // if((!jCompany.value("d6").isUndefined())&&(!jCompany.value("d6").isNull()))
  566. // DevCountLabel[2]->setText(QString("%1").arg(jCompany.value("d6").toInt()));
  567. // else
  568. // DevCountLabel[2]->setText("0");
  569. // if((!jCompany.value("d6o").isUndefined())&&(!jCompany.value("d6o").isNull()))
  570. // OutCountLabel[2]->setText(QString("%1").arg(jCompany.value("d6o").toInt()));
  571. // else
  572. // OutCountLabel[2]->setText("0");
  573. // if((!jCompany.value("d6a").isUndefined())&&(!jCompany.value("d6a").isNull()))
  574. // AlarmCount[2] = jCompany.value("d6a").toInt();
  575. // else
  576. // AlarmCount[2] = 0;
  577. // if((!jCompany.value("d6ac").isUndefined())&&(!jCompany.value("d6ac").isNull()))
  578. // AlarmConfrmCount[2] = jCompany.value("d6ac").toInt();
  579. // else
  580. // AlarmConfrmCount[2] = 0;
  581. // AlarmCountLabel[2]->setText(QString("%1").arg(AlarmCount[2]));
  582. // AlarmUncomCountLabel[2]->setText(QString("%1").arg(AlarmCount[2]-AlarmConfrmCount[2]));
  583. // AlarmComCountLabel[2]->setText(QString("%1").arg(AlarmConfrmCount[2]));
  584. // if(AlarmCount[2]==0){
  585. // AlarmComPLabel[2]->setText("100.00%");
  586. // AlarmUncomPLabel[2]->setText("0.00%");
  587. // AlarmPLabel[2]->setText("100%");
  588. // AlarmBarValueLabel[4]->resize(0,size.height()*32/2160);
  589. // AlarmBarValueLabel[5]->resize(size.width()*755/3840,size.height()*32/2160);
  590. // setPieVlue(pieView[2],100);
  591. // }else{
  592. // AlarmComPLabel[2]->setText(QString("%1%").arg(QString::number((AlarmConfrmCount[2]*100.0/(AlarmCount[2]*1.0)),'f',2)));
  593. // AlarmUncomPLabel[2]->setText(QString("%1%").arg(QString::number(((AlarmCount[2]*100.0-AlarmConfrmCount[2]*100.0)/(AlarmCount[2]*1.0)),'f',2)));
  594. // AlarmPLabel[2]->setText(QString("%1%").arg(AlarmConfrmCount[2]*100/AlarmCount[2]));
  595. // AlarmBarValueLabel[4]->resize((AlarmCount[2]-AlarmConfrmCount[2])*755/(AlarmCount[2]*3840/size.width()),size.height()*32/2160);
  596. // AlarmBarValueLabel[5]->resize(AlarmConfrmCount[2]*755/(AlarmCount[2]*3840/size.width()),size.height()*32/2160);
  597. // setPieVlue(pieView[2],AlarmConfrmCount[2]*100/AlarmCount[2]);
  598. // }
  599. if((!jCompany.value("d1").isUndefined())&&(!jCompany.value("d1").isNull()))
  600. DevCountLabelValue[3] += jCompany.value("d1").toInt();
  601. if((!jCompany.value("d1o").isUndefined())&&(!jCompany.value("d1o").isNull()))
  602. OutCountLabelValue[3] += jCompany.value("d1o").toInt();
  603. if((!jCompany.value("d1a").isUndefined())&&(!jCompany.value("d1a").isNull()))
  604. AlarmCount[3] += jCompany.value("d1a").toInt();
  605. if((!jCompany.value("d1ac").isUndefined())&&(!jCompany.value("d1ac").isNull()))
  606. AlarmConfrmCount[3] += jCompany.value("d1ac").toInt();
  607. if(COMPANYCODE.compare(CompanyIdList.at(CompanyIdList.length()-1))==0){
  608. DevCountLabel[3]->setText(QString("%1").arg(DevCountLabelValue[3]));
  609. OutCountLabel[3]->setText(QString("%1").arg(OutCountLabelValue[3]));
  610. AlarmCountLabel[3]->setText(QString("%1").arg(AlarmCount[3]));
  611. AlarmUncomCountLabel[3]->setText(QString("%1").arg(AlarmCount[3]-AlarmConfrmCount[3]));
  612. AlarmComCountLabel[3]->setText(QString("%1").arg(AlarmConfrmCount[3]));
  613. if(AlarmCount[3]==0){
  614. AlarmComPLabel[3]->setText("100.00%");
  615. AlarmUncomPLabel[3]->setText("0.00%");
  616. AlarmPLabel[3]->setText("100%");
  617. AlarmBarValueLabel[6]->resize(0,size.height()*32/2160);
  618. AlarmBarValueLabel[7]->resize(size.width()*755/3840,size.height()*32/2160);
  619. setPieVlue(pieView[3],100);
  620. }else{
  621. AlarmComPLabel[3]->setText(QString("%1%").arg(QString::number((AlarmConfrmCount[3]*100.0/(AlarmCount[3]*1.0)),'f',2)));
  622. AlarmUncomPLabel[3]->setText(QString("%1%").arg(QString::number(((AlarmCount[3]*100.0-AlarmConfrmCount[3]*100.0)/(AlarmCount[3]*1.0)),'f',2)));
  623. AlarmPLabel[3]->setText(QString("%1%").arg(AlarmConfrmCount[3]*100/AlarmCount[3]));
  624. AlarmBarValueLabel[6]->resize((AlarmCount[3]-AlarmConfrmCount[3])*755/(AlarmCount[3]*3840/size.width()),size.height()*32/2160);
  625. AlarmBarValueLabel[7]->resize(AlarmConfrmCount[3]*755/(AlarmCount[3]*3840/size.width()),size.height()*32/2160);
  626. setPieVlue(pieView[3],AlarmConfrmCount[3]*100/AlarmCount[3]);
  627. }
  628. }
  629. // if((!jCompany.value("d1").isUndefined())&&(!jCompany.value("d1").isNull()))
  630. // DevCountLabel[3]->setText(QString("%1").arg(jCompany.value("d1").toInt()));
  631. // else
  632. // DevCountLabel[3]->setText("0");
  633. // if((!jCompany.value("d1o").isUndefined())&&(!jCompany.value("d1o").isNull()))
  634. // OutCountLabel[3]->setText(QString("%1").arg(jCompany.value("d1o").toInt()));
  635. // else
  636. // OutCountLabel[3]->setText("0");
  637. // if((!jCompany.value("d1a").isUndefined())&&(!jCompany.value("d1a").isNull()))
  638. // AlarmCount[3] = jCompany.value("d1a").toInt();
  639. // else
  640. // AlarmCount[3] = 0;
  641. // if((!jCompany.value("d1ac").isUndefined())&&(!jCompany.value("d1ac").isNull()))
  642. // AlarmConfrmCount[3] = jCompany.value("d1ac").toInt();
  643. // else
  644. // AlarmConfrmCount[3] = 0;
  645. // AlarmCountLabel[3]->setText(QString("%1").arg(AlarmCount[3]));
  646. // AlarmUncomCountLabel[3]->setText(QString("%1").arg(AlarmCount[3]-AlarmConfrmCount[3]));
  647. // AlarmComCountLabel[3]->setText(QString("%1").arg(AlarmConfrmCount[3]));
  648. // if(AlarmCount[3]==0){
  649. // AlarmComPLabel[3]->setText("100.00%");
  650. // AlarmUncomPLabel[3]->setText("0.00%");
  651. // AlarmPLabel[3]->setText("100%");
  652. // AlarmBarValueLabel[6]->resize(0,size.height()*32/2160);
  653. // AlarmBarValueLabel[7]->resize(size.width()*755/3840,size.height()*32/2160);
  654. // setPieVlue(pieView[3],100);
  655. // }else{
  656. // AlarmComPLabel[3]->setText(QString("%1%").arg(QString::number((AlarmConfrmCount[3]*100.0/(AlarmCount[3]*1.0)),'f',2)));
  657. // AlarmUncomPLabel[3]->setText(QString("%1%").arg(QString::number(((AlarmCount[3]*100.0-AlarmConfrmCount[3]*100.0)/(AlarmCount[3]*1.0)),'f',2)));
  658. // AlarmPLabel[3]->setText(QString("%1%").arg(AlarmConfrmCount[3]*100/AlarmCount[3]));
  659. // AlarmBarValueLabel[6]->resize((AlarmCount[3]-AlarmConfrmCount[3])*755/(AlarmCount[3]*3840/size.width()),size.height()*32/2160);
  660. // AlarmBarValueLabel[7]->resize(AlarmConfrmCount[3]*755/(AlarmCount[3]*3840/size.width()),size.height()*32/2160);
  661. // setPieVlue(pieView[3],AlarmConfrmCount[3]*100/AlarmCount[3]);
  662. // }
  663. if((!jCompany.value("d16").isUndefined())&&(!jCompany.value("d16").isNull()))
  664. DevCountLabelValue[4] += jCompany.value("d16").toInt();
  665. if((!jCompany.value("d16o").isUndefined())&&(!jCompany.value("d16o").isNull()))
  666. OutCountLabelValue[4] += jCompany.value("d16o").toInt();
  667. if((!jCompany.value("d16a").isUndefined())&&(!jCompany.value("d16a").isNull()))
  668. AlarmCount[4] += jCompany.value("d16a").toInt();
  669. if((!jCompany.value("d16ac").isUndefined())&&(!jCompany.value("d16ac").isNull()))
  670. AlarmConfrmCount[4] += jCompany.value("d16ac").toInt();
  671. if(COMPANYCODE.compare(CompanyIdList.at(CompanyIdList.length()-1))==0){
  672. DevCountLabel[4]->setText(QString("%1").arg(DevCountLabelValue[4]));
  673. OutCountLabel[4]->setText(QString("%1").arg(OutCountLabelValue[4]));
  674. AlarmCountLabel[4]->setText(QString("%1").arg(AlarmCount[4]));
  675. AlarmUncomCountLabel[4]->setText(QString("%1").arg(AlarmCount[4]-AlarmConfrmCount[4]));
  676. AlarmComCountLabel[4]->setText(QString("%1").arg(AlarmConfrmCount[4]));
  677. if(AlarmCount[4]==0){
  678. AlarmComPLabel[4]->setText("100.00%");
  679. AlarmUncomPLabel[4]->setText("0.00%");
  680. AlarmPLabel[4]->setText("100%");
  681. AlarmBarValueLabel[8]->resize(0,size.height()*32/2160);
  682. AlarmBarValueLabel[9]->resize(size.width()*755/3840,size.height()*32/2160);
  683. setPieVlue(pieView[4],100);
  684. }else{
  685. AlarmComPLabel[4]->setText(QString("%1%").arg(QString::number((AlarmConfrmCount[4]*100.0/(AlarmCount[4]*1.0)),'f',2)));
  686. AlarmUncomPLabel[4]->setText(QString("%1%").arg(QString::number(((AlarmCount[4]*100.0-AlarmConfrmCount[4]*100.0)/(AlarmCount[4]*1.0)),'f',2)));
  687. AlarmPLabel[4]->setText(QString("%1%").arg(AlarmConfrmCount[4]*100/AlarmCount[4]));
  688. AlarmBarValueLabel[8]->resize((AlarmCount[4]-AlarmConfrmCount[4])*755/(AlarmCount[4]*3840/size.width()),size.height()*32/2160);
  689. AlarmBarValueLabel[9]->resize(AlarmConfrmCount[4]*755/(AlarmCount[4]*3840/size.width()),size.height()*32/2160);
  690. setPieVlue(pieView[4],AlarmConfrmCount[4]*100/AlarmCount[4]);
  691. }
  692. }
  693. // if((!jCompany.value("d16").isUndefined())&&(!jCompany.value("d16").isNull()))
  694. // DevCountLabel[4]->setText(QString("%1").arg(jCompany.value("d16").toInt()));
  695. // else
  696. // DevCountLabel[4]->setText("0");
  697. // if((!jCompany.value("d16o").isUndefined())&&(!jCompany.value("d16o").isNull()))
  698. // OutCountLabel[4]->setText(QString("%1").arg(jCompany.value("d16o").toInt()));
  699. // else
  700. // OutCountLabel[4]->setText("0");
  701. // if((!jCompany.value("d16a").isUndefined())&&(!jCompany.value("d16a").isNull()))
  702. // AlarmCount[4] = jCompany.value("d16a").toInt();
  703. // else
  704. // AlarmCount[4] = 0;
  705. // if((!jCompany.value("d16ac").isUndefined())&&(!jCompany.value("d16ac").isNull()))
  706. // AlarmConfrmCount[4] = jCompany.value("d16ac").toInt();
  707. // else
  708. // AlarmConfrmCount[4] = 0;
  709. // AlarmCountLabel[4]->setText(QString("%1").arg(AlarmCount[4]));
  710. // AlarmUncomCountLabel[4]->setText(QString("%1").arg(AlarmCount[4]-AlarmConfrmCount[4]));
  711. // AlarmComCountLabel[4]->setText(QString("%1").arg(AlarmConfrmCount[4]));
  712. // if(AlarmCount[4]==0){
  713. // AlarmComPLabel[4]->setText("100.00%");
  714. // AlarmUncomPLabel[4]->setText("0.00%");
  715. // AlarmPLabel[4]->setText("100%");
  716. // AlarmBarValueLabel[8]->resize(0,size.height()*32/2160);
  717. // AlarmBarValueLabel[9]->resize(size.width()*755/3840,size.height()*32/2160);
  718. // setPieVlue(pieView[4],100);
  719. // }else{
  720. // AlarmComPLabel[4]->setText(QString("%1%").arg(QString::number((AlarmConfrmCount[4]*100.0/(AlarmCount[4]*1.0)),'f',2)));
  721. // AlarmUncomPLabel[4]->setText(QString("%1%").arg(QString::number(((AlarmCount[4]*100.0-AlarmConfrmCount[4]*100.0)/(AlarmCount[4]*1.0)),'f',2)));
  722. // AlarmPLabel[4]->setText(QString("%1%").arg(AlarmConfrmCount[4]*100/AlarmCount[4]));
  723. // AlarmBarValueLabel[8]->resize((AlarmCount[4]-AlarmConfrmCount[4])*755/(AlarmCount[4]*3840/size.width()),size.height()*32/2160);
  724. // AlarmBarValueLabel[9]->resize(AlarmConfrmCount[4]*755/(AlarmCount[4]*3840/size.width()),size.height()*32/2160);
  725. // setPieVlue(pieView[4],AlarmConfrmCount[4]*100/AlarmCount[4]);
  726. // }
  727. }
  728. //
  729. if((!root.value("LIST").isUndefined())&&(!root.value("LIST").isNull())){
  730. QJsonArray jList = root.value("LIST").toArray();
  731. QList<DevInfo *> tmpList;
  732. for(int i=0;i<jList.size();i++){
  733. QJsonObject obj = jList.at(i).toObject();
  734. if((!obj.value("device_name").isUndefined())&&(!obj.value("device_name").isNull())
  735. &&(!obj.value("min_level").isUndefined())&&(!obj.value("min_level").isNull())
  736. &&(!obj.value("object_name").isUndefined())&&(!obj.value("object_name").isNull())
  737. &&(!obj.value("owner_code").isUndefined())&&(!obj.value("owner_code").isNull())
  738. &&(!obj.value("owner_dwtype").isUndefined())&&(!obj.value("owner_dwtype").isNull())){
  739. switch (obj.value("owner_dwtype").toInt()) {
  740. case 1:
  741. case 3:
  742. tmpList.append(new DevInfo(obj.value("device_name").toString(),
  743. QString::fromUtf8("火灾监控"),
  744. QString("%1").arg(obj.value("min_level").toInt()),
  745. obj.value("owner_code").toString(),
  746. obj.value("object_name").toString()));
  747. break;
  748. case 2:
  749. case 4:
  750. case 5:
  751. tmpList.append(new DevInfo(obj.value("device_name").toString(),
  752. QString::fromUtf8("水系统"),
  753. QString("%1").arg(obj.value("min_level").toInt()),
  754. obj.value("owner_code").toString(),
  755. obj.value("object_name").toString()));
  756. break;
  757. case 6:
  758. tmpList.append(new DevInfo(obj.value("device_name").toString(),
  759. QString::fromUtf8("RTU"),
  760. QString("%1").arg(obj.value("min_level").toInt()),
  761. obj.value("owner_code").toString(),
  762. obj.value("object_name").toString()));
  763. break;
  764. case 7:
  765. tmpList.append(new DevInfo(obj.value("device_name").toString(),
  766. QString::fromUtf8("电气火灾"),
  767. QString("%1").arg(obj.value("min_level").toInt()),
  768. obj.value("owner_code").toString(),
  769. obj.value("object_name").toString()));
  770. break;
  771. case 16:
  772. tmpList.append(new DevInfo(obj.value("device_name").toString(),
  773. QString::fromUtf8("视频告警"),
  774. QString("%1").arg(obj.value("min_level").toInt()),
  775. obj.value("owner_code").toString(),
  776. obj.value("object_name").toString()));
  777. break;
  778. default:
  779. tmpList.append(new DevInfo(obj.value("device_name").toString(),
  780. QString::fromUtf8("通用"),
  781. QString("%1").arg(obj.value("min_level").toInt()),
  782. obj.value("owner_code").toString(),
  783. obj.value("object_name").toString()));
  784. break;
  785. }
  786. }
  787. }
  788. if(COMPANYCODE.compare(CompanyIdList.at(0))==0)
  789. deviceList.clear();
  790. deviceList.append(tmpList);
  791. devPage = 0;
  792. if(COMPANYCODE.compare(CompanyIdList.at(CompanyIdList.length()-1))==0)
  793. setDevInfo();
  794. }
  795. }
  796. }
  797. }
  798. }
  799. void Widget::getDcData(QString data)
  800. {
  801. logThread->appendLog(QString("[ %1 datacenter ] get data: %2")
  802. .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss.zzz"))
  803. .arg(data));
  804. QJsonParseError json_error;
  805. QJsonDocument jsonDoc(QJsonDocument::fromJson(data.trimmed().toUtf8(),&json_error));
  806. if(json_error.error==QJsonParseError::NoError){
  807. QJsonObject root = jsonDoc.object();
  808. if((!root.value("dwtype").isUndefined())&&(!root.value("dwtype").isNull())
  809. &&(!root.value("deviceid").isUndefined())&&(!root.value("deviceid").isNull())
  810. &&(!root.value("devicename").isUndefined())&&(!root.value("devicename").isNull())
  811. &&(!root.value("evtname").isUndefined())&&(!root.value("evtname").isNull())
  812. &&(!root.value("time").isUndefined())&&(!root.value("time").isNull())){
  813. QString devCode = root.value("deviceid").toString();
  814. QString devName = root.value("devicename").toString();
  815. QString alarm_info = root.value("evtname").toString();
  816. QString alarm_time = root.value("time").toString();
  817. switch (root.value("dwtype").toInt()) {
  818. case 1:
  819. case 3:
  820. {
  821. AlarmInfo Info = AlarmInfo(devName,
  822. QString::fromUtf8("火灾监控"),
  823. alarm_info,
  824. alarm_time);
  825. if(isNewAlarm(Info)){
  826. alarmList.insert(0,Info);
  827. speechThread->append(QString::fromUtf8("%1报告,%2,%3,%4")
  828. .arg(Info.DevType)
  829. .arg(Info.DevName)
  830. .arg(Info.Alarminfo)
  831. .arg(Info.AlarmTime.toString("HH:mm:ss")));
  832. if(alarmList.length()>10)
  833. alarmList.removeLast();
  834. }
  835. }
  836. break;
  837. case 2:
  838. case 4:
  839. case 5:
  840. {
  841. AlarmInfo Info = AlarmInfo(devName,
  842. QString::fromUtf8("水系统"),
  843. alarm_info,
  844. alarm_time);
  845. if(isNewAlarm(Info)){
  846. alarmList.insert(0,Info);
  847. speechThread->append(QString::fromUtf8("%1报告,%2,%3,%4")
  848. .arg(Info.DevType)
  849. .arg(Info.DevName)
  850. .arg(Info.Alarminfo)
  851. .arg(Info.AlarmTime.toString("HH:mm:ss")));
  852. if(alarmList.length()>10)
  853. alarmList.removeLast();
  854. }
  855. }
  856. break;
  857. case 6:
  858. {
  859. AlarmInfo Info = AlarmInfo(devName,
  860. QString::fromUtf8("RTU"),
  861. alarm_info,
  862. alarm_time);
  863. if(isNewAlarm(Info)){
  864. alarmList.insert(0,Info);
  865. speechThread->append(QString::fromUtf8("%1报告,%2,%3,%4")
  866. .arg(Info.DevType)
  867. .arg(Info.DevName)
  868. .arg(Info.Alarminfo)
  869. .arg(Info.AlarmTime.toString("HH:mm:ss")));
  870. if(alarmList.length()>10)
  871. alarmList.removeLast();
  872. }
  873. }
  874. break;
  875. case 7:
  876. {
  877. AlarmInfo Info = AlarmInfo(devName,
  878. QString::fromUtf8("电气火灾"),
  879. alarm_info,
  880. alarm_time);
  881. if(isNewAlarm(Info)){
  882. alarmList.insert(0,Info);
  883. speechThread->append(QString::fromUtf8("%1报告,%2,%3,%4")
  884. .arg(Info.DevType)
  885. .arg(Info.DevName)
  886. .arg(Info.Alarminfo)
  887. .arg(Info.AlarmTime.toString("HH:mm:ss")));
  888. if(alarmList.length()>10)
  889. alarmList.removeLast();
  890. }
  891. }
  892. break;
  893. case 16:
  894. {
  895. AlarmInfo Info = AlarmInfo(devName,
  896. QString::fromUtf8("视频告警"),
  897. alarm_info,
  898. alarm_time);
  899. if(isNewAlarm(Info)){
  900. alarmList.insert(0,Info);
  901. speechThread->append(QString::fromUtf8("%1报告,%2,%3,%4")
  902. .arg(Info.DevType)
  903. .arg(Info.DevName)
  904. .arg(Info.Alarminfo)
  905. .arg(Info.AlarmTime.toString("HH:mm:ss")));
  906. if(alarmList.length()>10)
  907. alarmList.removeLast();
  908. }
  909. }
  910. break;
  911. default:
  912. {
  913. AlarmInfo Info = AlarmInfo(devName,
  914. QString::fromUtf8("通用"),
  915. alarm_info,
  916. alarm_time);
  917. if(isNewAlarm(Info)){
  918. alarmList.insert(0,Info);
  919. speechThread->append(QString::fromUtf8("%1报告,%2,%3,%4")
  920. .arg(Info.DevType)
  921. .arg(Info.DevName)
  922. .arg(Info.Alarminfo)
  923. .arg(Info.AlarmTime.toString("HH:mm:ss")));
  924. if(alarmList.length()>10)
  925. alarmList.removeLast();
  926. }
  927. }
  928. break;
  929. }
  930. setAlarmInfo();
  931. }
  932. }
  933. }
  934. void Widget::DcSoClosed()
  935. {
  936. WebsocketClient *ws = (WebsocketClient *)sender();
  937. ws->deleteLater();
  938. connectDC();
  939. }
  940. 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){
  941. dayWeather = day_weather;
  942. nightWeather = night_weather;
  943. dayWeatherCode = day_weather_code;
  944. nightWeatherCode = night_weather_code;
  945. sunBegin = sun_begin;
  946. sunEnd = sun_end;
  947. dayTemperature = day_air_temperature;
  948. nightTemperature = night_air_temperature;
  949. logThread->appendLog(QString("[ %1 weather ] get data: %2 %3 %4 %5 %6 %7 %8 %9")
  950. .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss.zzz"))
  951. .arg(day_weather).arg(day_weather_code).arg(day_air_temperature)
  952. .arg(night_weather).arg(night_weather_code).arg(night_air_temperature)
  953. .arg(sun_begin).arg(sun_end));
  954. setWeatherInfo();
  955. }
  956. void Widget::setWeatherInfo()
  957. {
  958. bool isday=false;
  959. QSize size = this->size();
  960. QTime dt = QTime::currentTime();
  961. QTime begin = QTime::fromString(sunBegin,"HH:mm");
  962. QTime end = QTime::fromString(sunEnd,"HH:mm");
  963. int dtt = dt.hour()*60+dt.minute();
  964. int btt = begin.hour()*60+begin.minute();
  965. int ett = end.hour()*60+end.minute();
  966. if((dtt>=btt)&&(dtt<ett))
  967. isday = true;
  968. QImage image;
  969. QString imgname = "";
  970. if(isday){
  971. int weatherCode = dayWeatherCode.toInt();
  972. if((weatherCode>=0)&&(weatherCode<32)){
  973. imgname = QString(":/img/pics/weather/day/%1.png").arg(weatherCode,2,10,QChar('0'));
  974. }
  975. temperatureLabel->setText(QString::fromUtf8("%1°C").arg(dayTemperature));
  976. }else{
  977. int weatherCode = nightWeatherCode.toInt();
  978. if((weatherCode>=0)&&(weatherCode<32)){
  979. imgname = QString(":/img/pics/weather/night/%1.png").arg(weatherCode,2,10,QChar('0'));
  980. }
  981. temperatureLabel->setText(QString::fromUtf8("%1°C").arg(nightTemperature));
  982. }
  983. image.load(imgname);
  984. weatherIconLabel->setPixmap(QPixmap::fromImage(image));
  985. weatherIconLabel->setScaledContents(true);
  986. weatherIconLabel->resize(size.width()*80/3840,size.height()*80/2160);
  987. }
  988. void Widget::timeout()
  989. {
  990. QDateTime dt = QDateTime::currentDateTime();
  991. count++;
  992. 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')));
  993. if(day!=dt.date().dayOfYear()){
  994. day = dt.date().dayOfYear();
  995. 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())));
  996. }
  997. if(hour!=dt.time().hour()/3){
  998. hour = dt.time().hour()/3;
  999. getWeather->sendRequest();
  1000. }
  1001. if((count%600)==0){
  1002. setWeatherInfo();
  1003. // frontpage->sendRequest();
  1004. count=0;
  1005. }
  1006. if(count>1199)
  1007. count=0;
  1008. if(count==0){
  1009. this->activateWindow();
  1010. frontpage->sendRequest();
  1011. }
  1012. }
  1013. void Widget::setDevLabels(QSize size)
  1014. {
  1015. for(int i=0;i<5;i++){
  1016. QFont font("Agency FB");
  1017. font.setFamily("Agency FB");
  1018. font.setBold(true);
  1019. font.setPointSize(size.width()*48/3840);
  1020. QFont font2("Agency FB");
  1021. font2.setFamily("Agency FB");
  1022. font2.setPointSize(size.width()*32/3840);
  1023. DevCountLabel[i] = new QLabel(this);
  1024. DevCountLabel[i]->setStyleSheet("color: rgba(65, 249, 40,255);");
  1025. DevCountLabel[i]->setFont(font);
  1026. DevCountLabel[i]->setGeometry(size.width()*171/3840,size.height()*525/2160+(size.height()*376*i/2160),size.width()*160/3840,size.height()*50/2160);
  1027. DevCountLabel[i]->setText("0");
  1028. DevCountLabel[i]->show();
  1029. OutCountLabel[i] = new QLabel(this);
  1030. OutCountLabel[i]->setStyleSheet("color: rgba(255, 97, 2, 255);");
  1031. OutCountLabel[i]->setFont(font);
  1032. OutCountLabel[i]->setGeometry(size.width()*438/3840,size.height()*525/2160+(size.height()*376*i/2160),size.width()*160/3840,size.height()*50/2160);
  1033. OutCountLabel[i]->setText("0");
  1034. OutCountLabel[i]->show();
  1035. font.setPointSize(size.width()*54/3840);
  1036. AlarmCountLabel[i] = new QLabel(this);
  1037. AlarmCountLabel[i]->setStyleSheet("color: rgba(255, 170, 35, 255);");
  1038. AlarmCountLabel[i]->setFont(font);
  1039. AlarmCountLabel[i]->setGeometry(size.width()*1200/3840,size.height()*456/2160+(size.height()*376*i/2160),size.width()*160/3840,size.height()*60/2160);
  1040. AlarmCountLabel[i]->show();
  1041. AlarmUncomCountLabel[i] = new QLabel(this);
  1042. AlarmUncomCountLabel[i]->setStyleSheet("color: rgba(52, 236, 255, 255);");
  1043. AlarmUncomCountLabel[i]->setFont(font2);
  1044. AlarmUncomCountLabel[i]->setGeometry(size.width()*2335/3840,size.height()*381/2160+(size.height()*376*i/2160),size.width()*90/3840,size.height()*40/2160);
  1045. AlarmUncomCountLabel[i]->setText("0");
  1046. AlarmUncomCountLabel[i]->show();
  1047. AlarmComPLabel[i] = new QLabel(this);
  1048. AlarmComPLabel[i]->setStyleSheet("color: rgba(0, 255, 168, 255);");
  1049. AlarmComPLabel[i]->setFont(font2);
  1050. AlarmComPLabel[i]->setGeometry(size.width()*2450/3840,size.height()*513/2160+(size.height()*376*i/2160),size.width()*120/3840,size.height()*40/2160);
  1051. AlarmComPLabel[i]->setText("0.00%");
  1052. AlarmComPLabel[i]->show();
  1053. AlarmComCountLabel[i] = new QLabel(this);
  1054. AlarmComCountLabel[i]->setStyleSheet("color: rgba(52, 236, 255, 255);");
  1055. AlarmComCountLabel[i]->setFont(font2);
  1056. AlarmComCountLabel[i]->setGeometry(size.width()*2335/3840,size.height()*513/2160+(size.height()*376*i/2160),size.width()*90/3840,size.height()*40/2160);
  1057. AlarmComCountLabel[i]->setText("0");
  1058. AlarmComCountLabel[i]->show();
  1059. AlarmUncomPLabel[i] = new QLabel(this);
  1060. AlarmUncomPLabel[i]->setStyleSheet("color: rgba(251, 56, 54, 255);");
  1061. AlarmUncomPLabel[i]->setFont(font2);
  1062. AlarmUncomPLabel[i]->setGeometry(size.width()*2450/3840,size.height()*381/2160+(size.height()*376*i/2160),size.width()*120/3840,size.height()*40/2160);
  1063. AlarmUncomPLabel[i]->setText("0.00%");
  1064. AlarmUncomPLabel[i]->show();
  1065. AlarmPLabel[i] = new QLabel(this);
  1066. AlarmPLabel[i]->setStyleSheet("color: rgba(255, 138,0, 255);");
  1067. font2.setPointSize(size.width()*32/3840);
  1068. font2.setBold(true);
  1069. AlarmPLabel[i]->setFont(font2);
  1070. AlarmPLabel[i]->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
  1071. AlarmPLabel[i]->setGeometry(size.width()*2830/3840,size.height()*402/2160+(size.height()*376*i/2160),size.width()*72/3840,size.height()*60/2160);
  1072. AlarmPLabel[i]->setText("100%");
  1073. AlarmPLabel[i]->show();
  1074. }
  1075. }
  1076. void Widget::closeAlarmBar()
  1077. {
  1078. currentAlarmNote->setText("");
  1079. currentAlarmBG->hide();
  1080. a_start = false;
  1081. }
  1082. void Widget::setAlarmBarLabels(QSize size)
  1083. {
  1084. QImage image;
  1085. image.load(":/img/pics/cover.png");
  1086. for(int i=0;i<5;i++){
  1087. QRect rect(size.width()*1540/3840,size.height()*385/2160+(size.height()*376*i/2160),size.width()*755/3840,size.height()*32/2160);
  1088. QRect rect2(size.width()*1540/3840,size.height()*517/2160+(size.height()*376*i/2160),size.width()*755/3840,size.height()*32/2160);
  1089. AlarmBarBGLabel[i*2+0] = new QLabel(this);
  1090. AlarmBarBGLabel[i*2+0]->setGeometry(rect);
  1091. AlarmBarBGLabel[i*2+0]->setStyleSheet("background-color: rgba(52, 89, 126, 255);");
  1092. AlarmBarBGLabel[i*2+0]->show();
  1093. AlarmBarValueLabel[i*2+0] = new QLabel(this);
  1094. AlarmBarValueLabel[i*2+0]->setGeometry(rect);
  1095. 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));");
  1096. AlarmBarValueLabel[i*2+0]->show();
  1097. AlarmBarCoverLabel[i*2+0] = new QLabel(this);
  1098. AlarmBarCoverLabel[i*2+0]->setGeometry(rect);
  1099. AlarmBarCoverLabel[i*2+0]->setPixmap(QPixmap::fromImage(image));
  1100. AlarmBarCoverLabel[i*2+0]->setScaledContents(true);
  1101. AlarmBarCoverLabel[i*2+0]->resize(rect.size());
  1102. AlarmBarCoverLabel[i*2+0]->show();
  1103. AlarmBarBGLabel[i*2+1] = new QLabel(this);
  1104. AlarmBarBGLabel[i*2+1]->setGeometry(rect2);
  1105. AlarmBarBGLabel[i*2+1]->setStyleSheet("background-color: rgba(52, 89, 126, 255);");
  1106. AlarmBarBGLabel[i*2+1]->show();
  1107. AlarmBarValueLabel[i*2+1] = new QLabel(this);
  1108. AlarmBarValueLabel[i*2+1]->setGeometry(rect2);
  1109. 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));");
  1110. AlarmBarValueLabel[i*2+1]->show();
  1111. AlarmBarCoverLabel[i*2+1] = new QLabel(this);
  1112. AlarmBarCoverLabel[i*2+1]->setGeometry(rect2);
  1113. AlarmBarCoverLabel[i*2+1]->setPixmap(QPixmap::fromImage(image));
  1114. AlarmBarCoverLabel[i*2+1]->setScaledContents(true);
  1115. AlarmBarCoverLabel[i*2+1]->resize(rect2.size());
  1116. AlarmBarCoverLabel[i*2+1]->show();
  1117. }
  1118. }
  1119. void Widget::setCurrentAlarmNote(AlarmInfo info)
  1120. {
  1121. if(a_start)
  1122. a_timer->stop();
  1123. currentAlarmBG->show();
  1124. currentAlarmNote->setText(QString::fromUtf8("项目名称:%1\n项目地址:%2\n项目坐标:%3\n联 系 人:%4\n报告来源:%5\n报告时间:%6")
  1125. .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")));
  1126. a_start = true;
  1127. a_timer->start(30000);
  1128. }
  1129. void Widget::setAlarmNote(QSize size)
  1130. {
  1131. QImage image;
  1132. QFont font("Microsoft YaHei");
  1133. font.setFamily("Microsoft YaHei");
  1134. font.setBold(false);
  1135. font.setPointSize(size.width()*28/3840);
  1136. image.load(":/img/pics/alarm_bg.png");
  1137. currentAlarmBG = new QLabel(this);
  1138. currentAlarmBG->setGeometry(size.width()*(3840-1334)/2/3840, size.height()*847/2160, size.width()*1334/3840, size.height()*466/2160);
  1139. currentAlarmBG->setPixmap(QPixmap::fromImage(image));
  1140. currentAlarmBG->setScaledContents(true);
  1141. currentAlarmBG->resize(size.width()*1334/3840, size.height()*466/2160);
  1142. currentAlarmNote = new QLabel(currentAlarmBG);
  1143. currentAlarmNote->setGeometry(size.width()*450/3840, size.height()*50/2160, size.width()*800/3840, size.height()*360/2160);
  1144. currentAlarmNote->setFont(font);
  1145. currentAlarmNote->setStyleSheet("color: rgba(255, 255, 255, 255)");
  1146. currentAlarmNote->setText("");
  1147. currentAlarmBG->hide();
  1148. }
  1149. void Widget::setWeatherLabel(QSize size)
  1150. {
  1151. QFont font("Impact");
  1152. font.setFamily("Impact");
  1153. font.setPointSize(size.width()*40/3840);
  1154. weatherIconLabel = new QLabel(this);
  1155. weatherIconLabel->setGeometry(size.width()*3446/3840,size.height()*80/2160,size.width()*72/3840,size.height()*72/2160);
  1156. weatherIconLabel->show();
  1157. temperatureLabel = new QLabel(this);
  1158. 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);
  1159. temperatureLabel->setFont(font);
  1160. 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));");
  1161. temperatureLabel->show();
  1162. }
  1163. bool Widget::isNewAlarm(AlarmInfo info)
  1164. {
  1165. for(int i=0;i<alarmList.length();i++){
  1166. AlarmInfo obj = alarmList.at(i);
  1167. if(obj.AlarmTime.toTime_t()>=info.AlarmTime.toTime_t())
  1168. return false;
  1169. }
  1170. return true;
  1171. }
  1172. void Widget::setDateLabel(QSize size)
  1173. {
  1174. QDateTime dt = QDateTime::currentDateTime();
  1175. day = dt.date().dayOfYear();
  1176. QFont font("Microsoft YaHei");
  1177. font.setFamily("Microsoft YaHei");
  1178. font.setBold(true);
  1179. font.setPointSize(size.width()*24/3840);
  1180. DateLabel = new QLabel(this);
  1181. DateLabel->setGeometry(size.width()*72/3840,size.height()*96/2160,size.width()*396/3840,size.height()*36/2160);
  1182. DateLabel->setAlignment(Qt::AlignTop|Qt::AlignLeft);
  1183. 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));");
  1184. DateLabel->setFont(font);
  1185. 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())));
  1186. DateLabel->show();
  1187. }
  1188. void Widget::setTimeLabel(QSize size)
  1189. {
  1190. QDateTime dt = QDateTime::currentDateTime();
  1191. QFont font("Impact");
  1192. font.setFamily("Impact");
  1193. font.setPointSize(size.width()*40/3840);
  1194. TimeLabel = new QLabel(this);
  1195. 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));");
  1196. TimeLabel->setFont(font);
  1197. TimeLabel->setAlignment(Qt::AlignTop|Qt::AlignLeft);
  1198. TimeLabel->setGeometry(size.width()*468/3840,size.height()*80/2160,size.width()*240/3840,size.height()*80/2160);
  1199. 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')));
  1200. TimeLabel->show();
  1201. }
  1202. void Widget::setBackground(QSize size)
  1203. {
  1204. QImage image;
  1205. image.load(":/img/pics/background.png");
  1206. ui->background->setPixmap(QPixmap::fromImage(image));
  1207. ui->background->setScaledContents(true);
  1208. ui->background->resize(size);
  1209. }
  1210. void Widget::pageClick()
  1211. {
  1212. QToolButton *btn = (QToolButton *)sender();
  1213. if(btn==prevPageBtn){
  1214. devPage--;
  1215. setDevInfo();
  1216. }else if(btn==nextPageBtn){
  1217. devPage++;
  1218. setDevInfo();
  1219. }
  1220. }
  1221. void Widget::cancel()
  1222. {
  1223. NoteBgLabel->hide();
  1224. NoteLabel->hide();
  1225. }
  1226. void Widget::save(QString appid, QString key, QString name, QString pass, QString comid, QString url)
  1227. {
  1228. TermId = appid;
  1229. TermKey = key;
  1230. Loginname = name;
  1231. Password = pass;
  1232. CompanyId = comid;
  1233. AppUrl = url;
  1234. CompanyIdList.clear();
  1235. if(CompanyId.indexOf(",")>0)
  1236. CompanyIdList = CompanyId.split(",");
  1237. else
  1238. CompanyIdList.append(CompanyId);
  1239. NoteBgLabel->hide();
  1240. NoteLabel->hide();
  1241. alarmList.clear();
  1242. deviceList.clear();
  1243. for(int i=0;i<39;i++)
  1244. DevInfoLabel[i]->setText("");
  1245. for(int i=0;i<18;i++)
  1246. AlarmInfoLabel[i]->setText("");
  1247. frontpage->setParam(Loginname,Password,CompanyId,AppUrl);
  1248. dbThread->appendSql(QString("update yt_t_conf set AppId='%1', AppKey='%2', LoginName='%3', PassWord='%4', CompanyId='%5'")
  1249. .arg(TermId).arg(TermKey).arg(Loginname).arg(Password).arg(CompanyId));
  1250. dbThread->appendSql(QString("update yt_t_url set AppUrl='%1'").arg(AppUrl));
  1251. // frontpage->sendRequest();
  1252. wsc->reset();
  1253. }
  1254. void Widget::setupClick()
  1255. {
  1256. SetupForm *form = new SetupForm(this,TermId,TermKey,Loginname,Password,CompanyId,AppUrl);
  1257. connect(form,&SetupForm::cancel,this,&Widget::cancel);
  1258. connect(form,&SetupForm::save,this,&Widget::save);
  1259. form->setGeometry((this->size().width()-400)/2,(this->size().height()-300)/2,400,300);
  1260. NoteBgLabel->show();
  1261. NoteLabel->show();
  1262. form->show();
  1263. }
  1264. void Widget::setOperationBtn(QSize size)
  1265. {
  1266. int btnWidth = size.width()*64/3840;
  1267. int btnHeight = size.height()*64/2160;
  1268. int btnSep = size.width()*8/3840;
  1269. int btnY = size.height()*80/2160;
  1270. int btnX = size.width()-btnWidth-btnSep/2;
  1271. int pBtnWidth = size.width()*58/3840;
  1272. int pBtnHeight = size.height()*38/2160;
  1273. CmdBtn = new QToolButton(this);
  1274. CmdBtn->setIcon(QIcon(QPixmap(":/img/pics/min.png")));
  1275. CmdBtn->setGeometry(btnX-btnWidth,size.height()*82/2160,btnWidth,btnHeight);
  1276. CmdBtn->setIconSize(QSize(btnWidth,btnHeight));
  1277. //CmdBtn->setToolTip(QString::fromUtf8("参数设置"));
  1278. CmdBtn->setToolTip(QString::fromUtf8("最小化"));
  1279. CmdBtn->setAutoRaise(true);
  1280. CmdBtn->show();
  1281. //connect(CmdBtn,&QToolButton::clicked,this,&Widget::setupClick); //参数设置
  1282. connect(CmdBtn,&QToolButton::clicked,this,&Widget::showMinimized);
  1283. QuitBtn = new QToolButton(this);
  1284. QuitBtn->setIcon(QIcon(QPixmap(":/img/pics/exit2.png")));
  1285. QuitBtn->setGeometry(btnX,btnY,btnWidth,btnHeight);
  1286. QuitBtn->setIconSize(QSize(btnWidth,btnHeight));
  1287. QuitBtn->setToolTip(QString::fromUtf8("退出"));
  1288. QuitBtn->setAutoRaise(true);
  1289. QuitBtn->show();
  1290. connect(QuitBtn,&QToolButton::clicked,this,&Widget::close);
  1291. prevPageBtn = new QToolButton(this);
  1292. prevPageBtn->setIcon(QPixmap(":/img/pics/prev.png"));
  1293. prevPageBtn->setGeometry(size.width()*3662/3840,size.height()*204/2160,pBtnWidth,pBtnHeight);
  1294. prevPageBtn->setIconSize(QSize(pBtnWidth,pBtnHeight));
  1295. prevPageBtn->setAutoRaise(true);
  1296. connect(prevPageBtn,&QToolButton::clicked,this,&Widget::pageClick);
  1297. prevPageBtn->show();
  1298. nextPageBtn = new QToolButton(this);
  1299. nextPageBtn->setIcon(QPixmap(":/img/pics/next.png"));
  1300. nextPageBtn->setGeometry(size.width()*3750/3840,size.height()*204/2160,pBtnWidth,pBtnHeight);
  1301. nextPageBtn->setIconSize(QSize(pBtnWidth,pBtnHeight));
  1302. nextPageBtn->setAutoRaise(true);
  1303. connect(nextPageBtn,&QToolButton::clicked,this,&Widget::pageClick);
  1304. nextPageBtn->show();
  1305. }
  1306. void Widget::setAlarmInfoLabels(QSize size)
  1307. {
  1308. QFont font("Microsoft YaHei");
  1309. font.setFamily("Microsoft YaHei");
  1310. font.setPointSize(size.width()*24/3840);
  1311. for(int i=0;i<9;i++){
  1312. AlarmInfoLabel[i*2+0] = new CustQLabel(this);
  1313. 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);
  1314. AlarmInfoLabel[i*2+0]->setStyleSheet("color: rgba(255, 255, 255, 255)");
  1315. connect(AlarmInfoLabel[i*2+0],&CustQLabel::clicked,this,&Widget::devClick);
  1316. AlarmInfoLabel[i*2+0]->show();
  1317. AlarmInfoLabel[i*2+1] = new CustQLabel(this);
  1318. 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);
  1319. AlarmInfoLabel[i*2+1]->setStyleSheet("color: rgba(255, 0, 0, 255)");
  1320. connect(AlarmInfoLabel[i*2+1],&CustQLabel::clicked,this,&Widget::devClick);
  1321. AlarmInfoLabel[i*2+1]->show();
  1322. }
  1323. }
  1324. void Widget::setNoteLabels(QSize size)
  1325. {
  1326. NoteBgLabel = new QLabel(this);
  1327. NoteBgLabel->setGeometry(0,0,size.width(),size.height());
  1328. NoteBgLabel->setStyleSheet("background-color: rgba(0,0,0,64);");
  1329. NoteBgLabel->hide();
  1330. NoteLabel = new QLabel(this);
  1331. NoteLabel->setGeometry((size.width()-400)/2+5,(size.height()-300)/2+5,400,300);
  1332. NoteLabel->setStyleSheet("background-color: rgba(0,0,0,128);");
  1333. NoteLabel->hide();
  1334. NoteBtn = new CustQLabel(this);
  1335. NoteBtn->setGeometry(size.width()/2+340,(size.height()-600)/2+2,58,38);
  1336. NoteBtn->setStyleSheet("background-color: rgba(255,0,0,196);border:2px,rgba(255,0,0,255);color: rgba(255,255,255,255);");
  1337. NoteBtn->setAlignment(Qt::AlignCenter);
  1338. NoteBtn->setText("X");
  1339. connect(NoteBtn,&CustQLabel::clicked,this,&Widget::devClick);
  1340. NoteBtn->hide();
  1341. }
  1342. void Widget::setDevInfoLabels(QSize size)
  1343. {
  1344. QFont font("Microsoft YaHei");
  1345. font.setFamily("Microsoft YaHei");
  1346. font.setPointSize(size.width()*24/3840);
  1347. for(int i=0;i<13;i++){
  1348. DevInfoLabel[i*3+0] = new CustQLabel(this);
  1349. 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);
  1350. DevInfoLabel[i*3+0]->setStyleSheet("color: rgba(255, 255, 255, 255)");
  1351. connect(DevInfoLabel[i*3+0],&CustQLabel::clicked,this,&Widget::devClick);
  1352. DevInfoLabel[i*3+0]->show();
  1353. DevInfoLabel[i*3+1] = new CustQLabel(this);
  1354. 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);
  1355. DevInfoLabel[i*3+1]->setStyleSheet("color: rgba(0, 255, 186, 255)");
  1356. connect(DevInfoLabel[i*3+1],&CustQLabel::clicked,this,&Widget::devClick);
  1357. DevInfoLabel[i*3+1]->show();
  1358. DevInfoLabel[i*3+2] = new CustQLabel(this);
  1359. 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);
  1360. DevInfoLabel[i*3+2]->setStyleSheet("color: rgba(255, 234, 0, 255)");
  1361. connect(DevInfoLabel[i*3+2],&CustQLabel::clicked,this,&Widget::devClick);
  1362. DevInfoLabel[i*3+2]->show();
  1363. }
  1364. }
  1365. void Widget::devClick()
  1366. {
  1367. CustQLabel *label = (CustQLabel *)sender();
  1368. for(int i=0;i<39;i++){
  1369. if(label == DevInfoLabel[i]){
  1370. DevInfo *info = deviceList.at(devPage*13+i/3);
  1371. DevDataForm *form = new DevDataForm(this,info->DevName,info->DevDataInfoList);
  1372. connect(form,&DevDataForm::cancel,this,&Widget::cancel);
  1373. form->setGeometry((this->size().width()-400)/2,(this->size().height()-300)/2,400,300);
  1374. NoteBgLabel->show();
  1375. NoteLabel->show();
  1376. form->show();
  1377. return;
  1378. }
  1379. }
  1380. for(int i=0;i<18;i++){
  1381. if(label == AlarmInfoLabel[i]){
  1382. AlarmInfo info = alarmList.at(i/2);
  1383. AlarmInfoForm *form = new AlarmInfoForm(this,
  1384. info.DevName,
  1385. info.AlarmTime.toString("yyyy-MM-dd HH:mm:ss"),
  1386. QString("%1,%2").arg(info.DevType).arg(info.Alarminfo));
  1387. connect(form,&AlarmInfoForm::cancel,this,&Widget::cancel);
  1388. form->setGeometry((this->size().width()-400)/2,(this->size().height()-300)/2,400,300);
  1389. NoteBgLabel->show();
  1390. NoteLabel->show();
  1391. form->show();
  1392. return;
  1393. }
  1394. }
  1395. if(label==NoteBtn){
  1396. NoteBgLabel->hide();
  1397. NoteLabel->setText("");
  1398. NoteLabel->hide();
  1399. NoteBtn->hide();
  1400. }
  1401. }
  1402. void Widget::setPieView(QSize size)
  1403. {
  1404. for(int i=0;i<5;i++){
  1405. pieView[i] = new QGraphicsView(this);
  1406. pieView[i]->setGeometry(size.width()*2718/3840,size.height()*312/2160+(size.height()*376*i/2160),size.width()*281/3840, size.height()*281/2160);
  1407. pieView[i]->setStyleSheet("padding:0px;border:0px;background: transparent;");
  1408. series[i] = new QPieSeries();
  1409. QList<QPieSlice *> sliceList;
  1410. QPieSlice *v1 = new QPieSlice(QString::fromUtf8("已处置"),100,this);
  1411. v1->setBorderWidth(4);
  1412. v1->setBorderColor(QColor(255,255,255,128));
  1413. v1->setColor(QColor(0,255,0,255));
  1414. sliceList.append(v1);
  1415. QPieSlice *v2 = new QPieSlice(QString::fromUtf8("未处置"),0,this);
  1416. v2->setBorderWidth(4);
  1417. v2->setBorderColor(QColor(255,255,255,128));
  1418. v2->setColor(QColor(255,255,255,128));
  1419. sliceList.append(v2);
  1420. series[i]->append(sliceList);
  1421. series[i]->setHoleSize(0.70);
  1422. series[i]->setPieSize(0.95);
  1423. QChart *chart = new QChart();
  1424. chart->setCursor(QCursor(Qt::PointingHandCursor));
  1425. chart->addSeries(series[i]);
  1426. chart->legend()->hide();
  1427. chart->setBackgroundVisible(false);
  1428. chart->setMargins(QMargins(0,0,0,0));
  1429. chart->resize(150,150);
  1430. QChartView *chartview = new QChartView(chart,pieView[i]);
  1431. chartview->setRenderHint(QPainter::Antialiasing);
  1432. chartview->show();
  1433. pieView[i]->show();
  1434. }
  1435. }