frmMain.cs 68 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592
  1. using CarMeterSystem.OptionCls;
  2. using com.hnshituo.core.webapp.vo;
  3. using Common;
  4. using iCore.Rtdb;
  5. using iCore.Rtdb.RtdbTable;
  6. using MeterConditionLibrary;
  7. using MeterModelLibrary;
  8. using MeterModuleLibrary.uc;
  9. using MeterPlugInLibrary;
  10. using System;
  11. using System.Collections;
  12. using System.Collections.Generic;
  13. using System.Configuration;
  14. using System.Data;
  15. using System.Diagnostics;
  16. using System.Drawing;
  17. using System.Linq;
  18. using System.Net.NetworkInformation;
  19. using System.Threading;
  20. using System.Windows.Forms;
  21. using SystemOffLine;
  22. namespace CarMeterSystem
  23. {
  24. public partial class frmMain : Form
  25. {
  26. public frmMain()
  27. {
  28. InitializeComponent();
  29. }
  30. private Log l = Log.GetInstance();
  31. private Print printClass = new Print();//打印
  32. //内存表
  33. private MemoryTableDataSocket MemoClass = new MemoryTableDataSocket("");
  34. //实时表数据采集
  35. private DataCollectionControl collection = new DataCollectionControl();
  36. //图片控制器含图片压缩及上传curl
  37. private ImageCurlControl imageCurlControl = new ImageCurlControl();
  38. //与监控界面对接的表
  39. private MeterWorkMonitorService meterWorkMonitor = new MeterWorkMonitorService();
  40. //零点报警表
  41. private meterworkzeroalarmservice zeroAlarmService = new meterworkzeroalarmservice();
  42. //车号修正
  43. private CarNoModfiy modfiy = new CarNoModfiy();
  44. /// <summary>
  45. /// 这个是保存前一次采集中的车号信息
  46. /// </summary>
  47. private string preCarNo = "";
  48. //一码通接口调用
  49. private HttpRequest httpRequest = new HttpRequest();
  50. //验证对射
  51. private validParkStatus valid = new validParkStatus();
  52. //语音播报
  53. private VoicePlay vicPlayClass = new VoicePlay();
  54. private LED_Control led_controler = null;
  55. //监控表操作
  56. private MeterMonitorWeightService monitorWeightService = new MeterMonitorWeightService();
  57. private MeterWorkScheduledHelpService meterWorkScheduledHelpService = new MeterWorkScheduledHelpService();
  58. //历史皮操作
  59. private MeterBaseHisTareDataService hisTareDataService = new MeterBaseHisTareDataService();
  60. /// <summary>
  61. /// 欢迎界面
  62. /// </summary>
  63. private frmWelcome_Jisco frmWelcome = new frmWelcome_Jisco();//欢迎
  64. /// <summary>
  65. /// 计量页
  66. /// </summary>
  67. private frmOneYardToEnd fcc = null;
  68. /// <summary>
  69. /// 基础数据载入
  70. /// </summary>
  71. private BaseDbCls bd = new BaseDbCls();
  72. //扫码修正车号标识
  73. private bool codeFlag = false;
  74. private List<ucBusinessType> lu = new List<ucBusinessType>();
  75. private bool isVoiceDownCar = false;//车上人员请下车播放一次
  76. private bool isShowFrmWelcome = true; //是否显示欢迎界面
  77. private bool isOpened = false;//是否已经打开了扫码计量界面
  78. private bool noteCode = false;
  79. string validParkStatuConfig = ConfigurationManager.AppSettings["validParkStatuConfig"].ToString();
  80. //扫码器
  81. private SerialPortES sweepCodeClass = new SerialPortES();
  82. private SerialPortES sweepCodeClass2 = new SerialPortES();
  83. private void frmMain_Load(object sender, EventArgs e)
  84. {
  85. //*
  86. try
  87. {
  88. this.Hide();
  89. LoginCls lg = new LoginCls();
  90. // 计量页
  91. fcc = new frmOneYardToEnd();
  92. timer1.Start();
  93. //2021年6月21日 杨秀东添加
  94. if (isShowFrmWelcome)
  95. {
  96. frmWelcome.Show();
  97. frmWelcome.Visible = true;
  98. }
  99. if (lg.LoginIn())
  100. {
  101. //if (SystemUpdate(false))
  102. //{
  103. // return;
  104. //}
  105. if (bd.setBaseDb() && bd.getBaseDb())
  106. {
  107. if (!string.IsNullOrEmpty(PbCache.sportInfo.ledIp))
  108. {
  109. led_controler = new LED_Control(PbCache.sportInfo.ledIp);
  110. }
  111. //调用该方法时已赋值 test git 测试git推送代码123;456
  112. RESTfulResult<List<MeterWorkMonitor>> rm = meterWorkMonitor.doQueryOneWf(new MeterWorkMonitor { validFlag = "1", pointNo = PbCache.sportInfo.baseSpotNo });
  113. if (!rm.Succeed)
  114. {
  115. l.WriteLog(1, "载入监控表数据异常");
  116. return;
  117. }
  118. else if (rm.Data != null && rm.Data.Count > 0)
  119. {
  120. if (string.IsNullOrEmpty(PbCache.collect_no))
  121. {
  122. PbCache.collect_no = rm.Data[0].collectionCode;
  123. MemoClass = new MemoryTableDataSocket(PbCache.collect_no);
  124. }
  125. }
  126. else
  127. {
  128. l.WriteLog(1, "为配置监控数据");
  129. return;
  130. }
  131. //若未校秤的话,也不允许计量
  132. //载入界面业务按钮
  133. if (PbCache.businessType != null && PbCache.businessType.Count > 0)
  134. {
  135. foreach (ComBaseInfo info in PbCache.businessType)
  136. {
  137. ucBusinessType uc = new ucBusinessType();
  138. switch (info.baseCode)
  139. {
  140. case "001006003":
  141. uc.setControl(info.baseName, info.memo, info.baseCode);
  142. break;
  143. case "001006001":
  144. case "001006002":
  145. uc.setControl(info.baseName, info.memo, info.baseCode);
  146. break;
  147. default:
  148. uc.setControl(info.baseName, info.memo, info.baseCode);
  149. break;
  150. }
  151. uc.Dock = DockStyle.Top;
  152. //uc.setControl("","","",);
  153. uc.ucEvent += new EventHandler(ucEvents);
  154. lu.Add(uc);
  155. //panel7.Controls.Add(uc);
  156. }
  157. }
  158. //开启基础进程
  159. l.WriteLog(0, "系统登录成功");
  160. collection.EventDataCollectionArgs += new EventDataCollection(EventData);//数据采集及扫码信息
  161. collection.Start(PbCache.sportInfo.baseSpotNo, PbCache.sportInfo.baseSpotName);
  162. StartWriteMonitor(0);//启动更新监控表线程
  163. // 数据提交线程
  164. imageCurlControl.Start(); //图片上传线程
  165. //新扫码线程
  166. if (AppConfigCache._comPara?.Split(new char[] { ',' })?.Length == 5)
  167. {
  168. sweepCodeClass.StartThreadSweep(AppConfigCache._comPara); //扫码线程
  169. }
  170. if (AppConfigCache._comPara2?.Split(new char[] { ',' })?.Length == 5)
  171. {
  172. sweepCodeClass2.StartThreadSweep(AppConfigCache._comPara2); //扫码线程
  173. }
  174. }
  175. else
  176. {
  177. l.WriteLog(0, "系统登录失败");
  178. }
  179. }
  180. else
  181. {
  182. l.WriteLog(0, "按IP地址找不到计量点信息,系统登录失败,ip:" + IpAddress.getIp);
  183. }
  184. }
  185. catch (Exception ex)
  186. {
  187. l.WriteLog(0, "系统加载失败:" + ex.Message);
  188. }
  189. //*/
  190. }
  191. private void timer1_Tick(object sender, EventArgs e)
  192. {
  193. //timer1.Stop();
  194. try
  195. {
  196. if ( PbCache.collect?.weight > 500)
  197. {
  198. PbCache.bussinessTypeName = "";
  199. PbCache.bussinessTypeCode = "";
  200. if (fcc.Visible == false)
  201. {
  202. fcc.Visible = true;
  203. fcc.init();
  204. }
  205. }
  206. timer1.Interval = 1000;
  207. }
  208. catch (Exception ee)
  209. {
  210. //GlobalInstanceController.Instance.LastCallMessage = ee.Message;
  211. timer1.Interval = 1000;
  212. }
  213. //timer1.Start();
  214. }
  215. /// <summary>
  216. /// 直接打开扫码计量界面
  217. /// </summary>
  218. /// <param name="sender"></param>
  219. /// <param name="e"></param>
  220. //private void timer1_Tick(object sender, EventArgs e)
  221. //{
  222. // if (!isOpened && PbCache.collect?.weight > 500)
  223. // {
  224. // l.WriteLog(31, "frmOneYardToEnd页面打开(timer1_Tick:frmMain),车号:" + PbCache.resultCarNo + "||" + (PbCache.collect == null ? "" : PbCache.collect.carno));
  225. // isOpened = true;
  226. // PbCache.bussinessTypeName = "";
  227. // PbCache.bussinessTypeCode = "";
  228. // try
  229. // {
  230. // if(fcc.Visible == false)
  231. // {
  232. // fcc.Visible = true;
  233. // fcc.init();
  234. // }
  235. // }
  236. // catch(Exception exp)
  237. // {
  238. // }
  239. // }
  240. //}
  241. #region
  242. //*
  243. /// <summary>
  244. /// 委托的方式调用控件的点击事件
  245. /// </summary>
  246. /// <param name="sender"></param>
  247. /// <param name="e"></param>
  248. public void ucEvents(object sender, EventArgs e)
  249. {
  250. Control control = (Control)sender;
  251. ucBusinessType um = control.Parent.Parent as ucBusinessType;
  252. try
  253. {
  254. switch (control.Name)
  255. {
  256. case "btnContext":
  257. case "btnPurchase":
  258. {
  259. PbCache.bussinessTypeName = um._bussiness == null ? "" : um._bussiness;
  260. PbCache.bussinessTypeCode = um._code;
  261. switch (um._code)
  262. {
  263. case "001006003":
  264. frmInternalTransport frm = new frmInternalTransport();
  265. frm.ShowDialog();
  266. break;
  267. /*
  268. case "001006001":
  269. case "001006002":
  270. frmCarSalePurchase frmCar = new frmCarSalePurchase();
  271. frmCar.ShowDialog();
  272. break;
  273. //*/
  274. default:
  275. frmCarSalePurchase frmCar = new frmCarSalePurchase();
  276. frmCar.ShowDialog();
  277. break;
  278. }
  279. };
  280. break;
  281. default: break;
  282. }
  283. }
  284. catch (Exception ex)
  285. {
  286. //MessageBox.Show("操作异常:" + ex.Message);
  287. }
  288. }
  289. //*/
  290. #endregion
  291. #region
  292. private void setThisVis(bool visb)
  293. {
  294. if (this.InvokeRequired)
  295. {
  296. Action<bool> action = new Action<bool>(setThisVis);
  297. Invoke(action, new object[] { visb });
  298. }
  299. else
  300. {
  301. if (this.Visible != visb)
  302. {
  303. this.Visible = visb;
  304. }
  305. }
  306. }
  307. #endregion
  308. #region
  309. private void setWelecomeVis(bool visb)
  310. {
  311. if (!isShowFrmWelcome) return;//2021年6月21日 杨秀东添加
  312. if (frmWelcome.InvokeRequired)
  313. {
  314. Action<bool> action = new Action<bool>(setWelecomeVis);
  315. Invoke(action, new object[] { visb });
  316. }
  317. else
  318. {
  319. if (frmWelcome.Visible != visb)
  320. {
  321. frmWelcome.Visible = visb;
  322. frmWelcome.setLogin();
  323. }
  324. }
  325. //*/
  326. }
  327. #endregion
  328. private int iCount = 0, iHodeTime = 0;
  329. private bool flagCarMonit = false;//车号修正
  330. private bool bEditCar = false; //手动修正车号
  331. private bool isOpenMeter = false; //是否已打开计量界面,若已经打开则这里关于超量程及红外的语音将停止播报
  332. private string firstCode = "";//上次扫码的信息
  333. private string ledTxt = "";
  334. private bool isLedWrite = false;//是否写入一次LED
  335. private string sPreNo = ""; //记录重量曲线变化
  336. private int preWgt = 0;//前一次重量,用于重量曲线
  337. private string sCarNo = "";
  338. private int iCountPark = 0;
  339. private string editCarNo = "";
  340. private bool isCarSource = false;
  341. private bool isResFlag = true;
  342. private string RFIDCarNo = "";
  343. private string isWriteRFID = AppConfigCache.isWriteRFID;
  344. private int num = 0;
  345. //EventData实例化
  346. RESTfulResult<string> rmsEventDataLastTime = new RESTfulResult<string>();
  347. RESTfulResult<List<MeterWorkMonitor>> rmUpdateEventDataMonitor = new RESTfulResult<List<MeterWorkMonitor>>();
  348. MeterWorkMonitor updateEventDataMonitor = new MeterWorkMonitor();
  349. MeterMonitorWeight meterMonitorWeightEventData1 = new MeterMonitorWeight();
  350. MeterMonitorWeight meterMonitorWeightEventData2 = new MeterMonitorWeight();
  351. MeterWorkMonitor mwUpdate = new MeterWorkMonitor();
  352. PbModelDbService<List<PbModelDb>> pbpRFIDEventData = new PbModelDbService<List<PbModelDb>>();
  353. RESTfulResult<List<PbModelDb>> rmTRFIDEventData = new RESTfulResult<List<PbModelDb>>();
  354. RESTfulResult<string> rmsmwUpdateEventData = new RESTfulResult<string>();
  355. MeterWorkScheduledHelp meterWorkScheduledHelp1 = new MeterWorkScheduledHelp();
  356. MeterWorkScheduledHelp meterWorkScheduledHelpRFID = new MeterWorkScheduledHelp();
  357. RESTfulResult<string> rmsdoUpdateWfEventData = new RESTfulResult<string>();
  358. RESTfulResult<string> rmssEventData = new RESTfulResult<string>();
  359. MeterWorkMonitor meterWorkMonitorEventDataI = new MeterWorkMonitor();
  360. MeterWorkCarActualFirstService mwcfs = new MeterWorkCarActualFirstService();
  361. RESTfulResult<string> rmsSweepCodeClass = new RESTfulResult<string>();
  362. frmOneYardToEnd frmOneYardToEnd = new frmOneYardToEnd();
  363. /// <summary>
  364. /// 数据采集
  365. /// </summary>
  366. /// <param name="o"></param>
  367. /// <param name="e"></param>
  368. private void EventData(object o, DataCollectionArgs e)
  369. {
  370. if (!timer1.Enabled)
  371. {
  372. timer1.Enabled = true;
  373. //l.WriteLog(32, "定时器重启(timer1_Tick:frmMain),车号:" + PbCache.resultCarNo + "||" + (PbCache.collect == null ? "" : PbCache.collect.carno));
  374. }
  375. #region
  376. num++;
  377. // BourneCao 20230228 怀疑int超长导致程序长期运行卡死
  378. if (num > 200000000) num = 0;
  379. //e.weight = 23580;
  380. //e.carno = "湘G88888";
  381. //e.weight = 23580;
  382. //e.weightStatus = 0;
  383. //if (num > 10)
  384. //{
  385. // e.carno = "甘B76917";
  386. // e.weight = 23580;
  387. // e.weightStatus = 0;
  388. //}
  389. //if (num < 20)
  390. //{
  391. // e.weight = 23580;
  392. // e.weightStatus = 1;
  393. //}
  394. //else if (num < 26)
  395. //{
  396. // e.weight = 23580;
  397. // e.weightStatus = 0;
  398. //}
  399. //else if (num < 39)
  400. //{
  401. // e.weight = 23580;
  402. // e.weightStatus = 0;
  403. //}
  404. //else if (num < 45)
  405. //{
  406. // e.weight = 15000;
  407. // e.weightStatus = 1;
  408. //}
  409. //else
  410. //{
  411. // e.weight = 400;
  412. //}
  413. #endregion
  414. //这里每隔0.5秒执行一次
  415. try
  416. {
  417. if (PbCache.carNoSource == 0)
  418. {
  419. PbCache.carNoSource = 1;
  420. }
  421. if (e.carno == "nown")
  422. {
  423. e.carno = "";
  424. }
  425. #region 扫码信息
  426. //if (string.IsNullOrEmpty(sweepCodeClass.StrCode))
  427. //{
  428. // if (string.IsNullOrEmpty(PbCache.strCode))
  429. // {
  430. // codeFlag = false;
  431. // firstCode = "";
  432. // PbCache.strCode = "";
  433. // l.WriteLog(12, "主线程扫码值为空时清空;sweepCodeClass.StrCode值为" + sweepCodeClass.StrCode + " ;PbCache.strCode值为:" + PbCache.strCode);
  434. // }
  435. //}
  436. //else
  437. //{
  438. // codeFlag = true;
  439. // frmOneYardToEnd frmOneYardToEnd = new frmOneYardToEnd();
  440. // Hashtable hashTable = new Hashtable();
  441. // hashTable.Add("message", sweepCodeClass.StrCode);
  442. // rmsSweepCodeClass = mwcfs.DecryptionForWfTest(hashTable);
  443. // if (rmsSweepCodeClass.Code == "0")
  444. // {
  445. // PbCache.collect.carno = rmsSweepCodeClass.Data;
  446. // PbCache.strCode = rmsSweepCodeClass.Data;
  447. // }
  448. // if (rmsSweepCodeClass.Code == "1")
  449. // {
  450. // vicPlayClass.GetVoicePlay("车号二维码已过期", PbCache.collect.carno);
  451. // frmOneYardToEnd.setMsgInfo("车号二维码已过期");
  452. // }
  453. // if (rmsSweepCodeClass.Code == "2")
  454. // {
  455. // vicPlayClass.GetVoicePlay("不是有效车号二维码", PbCache.collect.carno);
  456. // frmOneYardToEnd.setMsgInfo("不是有效车号二维码");
  457. // }
  458. // if (rmsSweepCodeClass.Code == "9")
  459. // {
  460. // vicPlayClass.GetVoicePlay("不是有效车号二维码", PbCache.collect.carno);
  461. // frmOneYardToEnd.setMsgInfo("不是有效车号二维码");
  462. // }
  463. // l.WriteLog(12, "测试扫码值" + rmsSweepCodeClass.Data);
  464. //}
  465. // 司机扫码为空,取工控机二维码
  466. if (PbCache.sportInfo.scanRequireValid == "1")
  467. {
  468. if (PbCache.monitor.isValidScan == "0")
  469. {
  470. PbCache.isValidScan = true;
  471. if (string.IsNullOrEmpty(sweepCodeClass2.StrCode))
  472. {
  473. if (string.IsNullOrEmpty(sweepCodeClass.StrCode))
  474. {
  475. if (string.IsNullOrEmpty(PbCache.strCode))
  476. {
  477. codeFlag = false;
  478. firstCode = "";
  479. PbCache.strCode = "";
  480. //l.WriteLog(12, "主线程扫码值为空时清空;sweepCodeClass.StrCode值为" + sweepCodeClass.StrCode + " ;PbCache.strCode值为:" + PbCache.strCode);
  481. }
  482. }
  483. else
  484. {
  485. l.WriteLog(12, "'"+sweepCodeClass.StrCode+ "'");
  486. if (sweepCodeClass.StrCode.Length > 3 && sweepCodeClass.StrCode.Substring(0, 3) == "TWB")
  487. {
  488. DecodeQRCodeYMT(sweepCodeClass.StrCode);
  489. }
  490. else
  491. {
  492. DecodeQRCode(sweepCodeClass.StrCode);
  493. }
  494. }
  495. }
  496. else
  497. {
  498. l.WriteLog(12, "'" + sweepCodeClass.StrCode+"'" );
  499. if (sweepCodeClass.StrCode.Length > 3 && sweepCodeClass2.StrCode.Substring(0, 3) == "TWB")
  500. {
  501. DecodeQRCodeYMT(sweepCodeClass2.StrCode);
  502. }
  503. else
  504. {
  505. DecodeQRCode(sweepCodeClass2.StrCode);
  506. }
  507. }
  508. }
  509. else
  510. {
  511. PbCache.isValidScan = false;
  512. if (string.IsNullOrEmpty(sweepCodeClass2.StrCode))
  513. {
  514. if (string.IsNullOrEmpty(sweepCodeClass.StrCode))
  515. {
  516. if (string.IsNullOrEmpty(PbCache.strCode))
  517. {
  518. PbCache.isValidScan = true;
  519. codeFlag = false;
  520. firstCode = "";
  521. PbCache.strCode = "";
  522. //l.WriteLog(12, "主线程扫码值为空时清空;sweepCodeClass.StrCode值为" + sweepCodeClass.StrCode + " ;PbCache.strCode值为:" + PbCache.strCode);
  523. }
  524. }
  525. else
  526. {
  527. l.WriteLog(12, "'" + sweepCodeClass.StrCode+ "'" );
  528. if (sweepCodeClass.StrCode.Length > 3 && sweepCodeClass.StrCode.Substring(0, 3) == "TWB")
  529. {
  530. DecodeQRCodeYMT(sweepCodeClass.StrCode);
  531. }
  532. else
  533. {
  534. DecodeQRCode(sweepCodeClass.StrCode);
  535. }
  536. }
  537. }
  538. else
  539. {
  540. l.WriteLog(12, "'" + sweepCodeClass.StrCode+"'");
  541. if (sweepCodeClass.StrCode.Length > 3 && sweepCodeClass2.StrCode.Substring(0, 3) == "TWB")
  542. {
  543. DecodeQRCodeYMT(sweepCodeClass2.StrCode);
  544. }
  545. else
  546. {
  547. DecodeQRCode(sweepCodeClass2.StrCode);
  548. }
  549. }
  550. }
  551. }
  552. else
  553. {
  554. PbCache.isValidScan = true;
  555. if (string.IsNullOrEmpty(sweepCodeClass2.StrCode))
  556. {
  557. if (string.IsNullOrEmpty(sweepCodeClass.StrCode))
  558. {
  559. if (string.IsNullOrEmpty(PbCache.strCode))
  560. {
  561. codeFlag = false;
  562. firstCode = "";
  563. PbCache.strCode = "";
  564. //l.WriteLog(12, "主线程扫码值为空时清空;sweepCodeClass.StrCode值为" + sweepCodeClass.StrCode + " ;PbCache.strCode值为:" + PbCache.strCode);
  565. }
  566. }
  567. else
  568. {
  569. l.WriteLog(12, "'" + sweepCodeClass.StrCode+"'");
  570. if (sweepCodeClass.StrCode.Length > 3 && sweepCodeClass.StrCode.Substring(0, 3) == "TWB")
  571. {
  572. DecodeQRCodeYMT(sweepCodeClass.StrCode);
  573. }
  574. else
  575. {
  576. DecodeQRCode(sweepCodeClass.StrCode);
  577. }
  578. }
  579. }
  580. else
  581. {
  582. l.WriteLog(12, "'" + sweepCodeClass.StrCode+ "'");
  583. if (sweepCodeClass.StrCode.Length > 3 && sweepCodeClass2.StrCode.Substring(0, 3) == "TWB")
  584. {
  585. DecodeQRCodeYMT(sweepCodeClass2.StrCode);
  586. }
  587. else
  588. {
  589. DecodeQRCode(sweepCodeClass2.StrCode);
  590. }
  591. }
  592. }
  593. #endregion
  594. #region 秤上无车10分钟获取一次基础数据
  595. if (iCount < 1200)
  596. {
  597. iCount++;
  598. }
  599. else
  600. {
  601. try
  602. {
  603. //秤上没有车时,每隔10分钟获取一次基础数据
  604. if (e.weight < 500)
  605. {
  606. if (bd.setBaseDb())
  607. {
  608. l.WriteLog(0, "十分钟获取基础数据成功");
  609. }
  610. else
  611. {
  612. l.WriteLog(0, "十分钟获取基础数据失败");
  613. }
  614. iCount = 0;
  615. }
  616. }
  617. catch (Exception ex)
  618. {
  619. l.WriteLog(0, "十分钟获取基础数据失败:" + ex.Message);
  620. iCount = 0;
  621. }
  622. }
  623. #endregion
  624. #region 每10秒写入一次当前时间
  625. if (iCount % 20 == 0)
  626. {
  627. //更新在线时间
  628. rmsEventDataLastTime = meterWorkMonitor.doUpdateWfBySpotNo(new MeterWorkMonitor { pointNo = PbCache.sportInfo.baseSpotNo});
  629. if (!rmsEventDataLastTime.Succeed)
  630. {
  631. l.WriteLog(0, "frmMain.EventData异常:写入时间异常,原因:" + rmsEventDataLastTime.ResultMessage);
  632. }
  633. }
  634. #endregion
  635. #region
  636. //一旦界面锁定则不采集数据
  637. if (!PbCache.isLockFrm)
  638. {
  639. PbCache.collect.pointid = PbCache.sportInfo.baseSpotNo;
  640. PbCache.collect.weight = e.weight;
  641. PbCache.collect.weight = e.weight;
  642. PbCache.collect.weightStatus = e.weightStatus;
  643. PbCache.collect.parkStatus = e.parkStatus;
  644. PbCache.collect.datetime = e.datetime;
  645. PbCache.collect.licType = e.licType;
  646. if (!bEditCar && !codeFlag && String.IsNullOrEmpty(RFIDCarNo)) {
  647. PbCache.collect.carno = e.carno;
  648. }
  649. PbCache.collect.videoCarNo1 = e.videoCarNo1;
  650. PbCache.collect.videoCarNo2 = e.videoCarNo2;
  651. PbCache.collect.rfidCarNo = e.RfidNos;
  652. PbCache.collect.carnoAlert = e.carnoAlert;
  653. }
  654. //界面锁定后,仍然更新判稳状态
  655. //BourneCao 20221230
  656. else
  657. {
  658. PbCache.collect.weightStatus = e.weightStatus;
  659. PbCache.collect.parkStatus = e.parkStatus;
  660. }
  661. if (PbCache.collect != null && PbCache.collect.weightStatus == 0)
  662. {
  663. if (string.IsNullOrEmpty(PbCache.resultWgt))
  664. {
  665. PbCache.resultWgt = e.weight + "";
  666. }
  667. if (!string.IsNullOrEmpty(PbCache.resultWgt) && e.weight > Convert.ToInt32(PbCache.resultWgt))
  668. {
  669. PbCache.resultWgt = e.weight + "";
  670. }
  671. if (!string.IsNullOrEmpty(e.carno) && PbCache.resultCarNo != e.carno)
  672. {
  673. PbCache.resultCarNo = e.carno + "";
  674. //l.WriteLog(28, "车号賦值跟蹤:PbCache.resultCarNo" + PbCache.resultCarNo + "||e.carno" + e.carno);
  675. }
  676. }
  677. //*/
  678. // 更新监控表
  679. //doLive();
  680. //重量大于500的情况下
  681. if (e.weight > 500)
  682. {
  683. isResFlag = true;
  684. isCarSource = true;
  685. if (PbCache.dtStartTime == null)
  686. PbCache.dtStartTime = DateTime.Now;
  687. isLedWrite = true;
  688. PbCache.strState = "0";
  689. #region 车上人员请下车
  690. try
  691. {
  692. //界面未锁定的情况下,有车号,如果重量稳定了,停车线验证通过,未超量程的情况下,则按钮可用
  693. if (PbCache.collect != null && !string.IsNullOrEmpty(PbCache.collect.carno) && PbCache.collect.weightStatus == 0 && PbCache.monitorResult.valid_park_status && PbCache.collect.weight < PbCache.range.upperRange)
  694. {
  695. if (!isVoiceDownCar)
  696. {
  697. isVoiceDownCar = true;
  698. vicPlayClass.GetVoicePlay("车上人员请下车", PbCache.collect.carno);
  699. }
  700. }
  701. }
  702. catch { }
  703. #endregion
  704. setWelecomeVis(false);
  705. //每隔1秒刷一次计量实时监控表数据值
  706. if (iCount % 2 == 0)
  707. {
  708. //调用该方法时已赋值
  709. updateEventDataMonitor.validFlag = "1";
  710. updateEventDataMonitor.pointNo = PbCache.sportInfo.baseSpotNo;
  711. rmUpdateEventDataMonitor = meterWorkMonitor.doQueryOneWf(updateEventDataMonitor);
  712. if (!rmUpdateEventDataMonitor.Succeed)
  713. {
  714. l.WriteLog(0, "frmMain.EventData异常419:" + rmUpdateEventDataMonitor.ResultMessage);
  715. }
  716. else
  717. {
  718. if (rmUpdateEventDataMonitor.Data != null && rmUpdateEventDataMonitor.Data.Count > 0)
  719. {
  720. PbCache.monitor = rmUpdateEventDataMonitor.Data[0];
  721. if (string.IsNullOrEmpty(PbCache.collect_no))
  722. {
  723. PbCache.collect_no = rmUpdateEventDataMonitor.Data[0].collectionCode;
  724. }
  725. if (ledTxt != rmUpdateEventDataMonitor.Data[0].ledWriter && rmUpdateEventDataMonitor.Data[0].ledWriter != "")
  726. {
  727. //调用LED信息写入******************************
  728. ledTxt = rmUpdateEventDataMonitor.Data[0].ledWriter;
  729. }
  730. if (string.IsNullOrEmpty(ledTxt))
  731. {
  732. ledTxt = "欢迎使用酒钢汽车衡智能计量系统!";
  733. }
  734. }
  735. }
  736. #region 2021-03-29
  737. #region 摄像头当前采集的车号与上次采集的不一样且当前未勾选不验证,且当前车号未进行手动修正的情况下
  738. if (preCarNo != e.carno && PbCache.monitor != null && PbCache.monitor.validCarno != "0" && !bEditCar)
  739. {
  740. flagCarMonit = false;
  741. }
  742. preCarNo = e.carno;
  743. #endregion
  744. if (!flagCarMonit)
  745. {
  746. sCarNo = e.carno;
  747. }
  748. //*
  749. //有车号,且重量稳定的情况下,只修正一次车号
  750. if (!string.IsNullOrEmpty(e.carno) && e.weightStatus == 0 && !flagCarMonit && PbCache.monitor != null && PbCache.monitor.carMonitor == "1" && PbCache.monitor.carMonitorLvl > 0)
  751. {
  752. flagCarMonit = true;
  753. string methods = "";
  754. for (int i = 0; i <= PbCache.monitor.carMonitorLvl; i++)
  755. {
  756. methods += "CarNoTrustCorrect" + i + ",";
  757. }
  758. l.WriteLog(0, "methods:"+methods);
  759. editCarNo = modfiy.CarNoCorrect(e.carno, methods.Substring(0, methods.Length - 1));
  760. sCarNo = editCarNo;
  761. //mwUpdate
  762. }
  763. //勾选了不验证车号的情况
  764. if (PbCache.monitor.validCarno == "0")
  765. {
  766. flagCarMonit = true;
  767. }
  768. #endregion
  769. #region 每隔1秒写入一次重量曲线
  770. try
  771. {
  772. if (preWgt != e.weight)
  773. {
  774. preWgt = e.weight;
  775. sPreNo = PbCache.sportInfo.baseSpotNo + DateTime.Now.ToString("yyyyMMddHHmmssfff");
  776. meterMonitorWeightEventData1.weightNo = sPreNo;
  777. meterMonitorWeightEventData1.baseSpotNo = PbCache.sportInfo.baseSpotNo;
  778. meterMonitorWeightEventData1.baseSpotName = PbCache.sportInfo.baseSpotName;
  779. meterMonitorWeightEventData1.collectWeight = e.weight + "";
  780. meterMonitorWeightEventData1.collectStartTime = PbCache.dtStartTime.Value;
  781. meterMonitorWeightEventData1.collectEndTime = DateTime.Now;
  782. meterMonitorWeightEventData1.spotTypeNo = "001002001";
  783. meterMonitorWeightEventData1.spotTypeName = "汽车衡";
  784. meterMonitorWeightEventData1.actualFirstNo = PbCache.actualFirstNo;
  785. monitorWeightService.doAddWf(meterMonitorWeightEventData1);
  786. }
  787. else
  788. {
  789. if (!string.IsNullOrEmpty(sPreNo))
  790. {
  791. meterMonitorWeightEventData2.weightNo = sPreNo;
  792. meterMonitorWeightEventData2.collectEndTime = DateTime.Now;
  793. monitorWeightService.doUpdateWf(meterMonitorWeightEventData2);
  794. }
  795. }
  796. }
  797. catch { }
  798. #endregion
  799. #region 停留超时
  800. iHodeTime++;
  801. mwUpdate.pointNo = PbCache.sportInfo.baseSpotNo;
  802. mwUpdate.editCar = editCarNo;
  803. if (PbCache.holdTime != null && PbCache.holdTime.Count > 0)
  804. {
  805. if (PbCache.holdTime[0].retentionTime != null)
  806. {
  807. if (PbCache.holdTime[0].retentionTime.Value < iHodeTime)
  808. {
  809. l.WriteLog(33, "iHodeTime:"+ iHodeTime + ",PbCache.holdTime[0].retentionTime.Value:"+ PbCache.holdTime[0].retentionTime.Value + ",mwUpdate.stopOverTime:"+ mwUpdate.stopOverTime);
  810. PbCache.isOvertimeAlarm = true; //是否超时报警
  811. mwUpdate.stopOverTime = "1"; //写入一次停留超时
  812. //mwUpdate.isHelp = "1";//派位
  813. //mwUpdate.isTakeOver = "1";
  814. iHodeTime = 99999;//不再增长避免超出
  815. }
  816. }
  817. }
  818. #endregion
  819. #region RFID识别车号信息
  820. mwUpdate.rfidCar = "";
  821. mwUpdate.photoCar = e.videoCarNo1;
  822. mwUpdate.photoCar2 = e.videoCarNo2;
  823. mwUpdate.scanCar = "";
  824. if (codeFlag)
  825. {
  826. mwUpdate.scanCar = PbCache.collect.carno;
  827. }
  828. //mwUpdate.photoCar = PbCache.collect.carno;
  829. if (!string.IsNullOrEmpty(e.RfidNos))
  830. {
  831. string sqls = @"SELECT RFID_ID id,CAR_NO text FROM METER_BASE_RFID_INFO where RFID_CODE = '" + e.RfidNos + "'";
  832. rmTRFIDEventData = pbpRFIDEventData.executeSqlDataWf(sqls);
  833. if (rmTRFIDEventData.Data == null || rmTRFIDEventData.Data.Count == 0)
  834. { }
  835. else
  836. {
  837. if (PbCache.carNoSource == 1)
  838. {
  839. PbCache.carNoSource = 2;
  840. }
  841. mwUpdate.rfidCar = rmTRFIDEventData.Data[0].text;
  842. sCarNo = rmTRFIDEventData.Data[0].text;
  843. RFIDCarNo = rmTRFIDEventData.Data[0].text;
  844. }
  845. }
  846. #endregion
  847. #region 计量员修改的车号信息
  848. if (PbCache.monitor != null && !string.IsNullOrEmpty(PbCache.monitor.setCar))
  849. {
  850. PbCache.carNoSource = 4;
  851. sCarNo = PbCache.monitor.setCar;
  852. bEditCar = true;
  853. flagCarMonit = true;
  854. codeFlag = false;
  855. sweepCodeClass.StrCode = "";
  856. sweepCodeClass2.StrCode = "";
  857. }
  858. #endregion
  859. #region 重量信息
  860. if (!PbCache.isLockFrm)
  861. {
  862. mwUpdate.wgt = e.weight;
  863. }
  864. else
  865. {
  866. mwUpdate.wgt = Convert.ToInt32(PbCache.lockWgt);
  867. }
  868. #endregion
  869. #region 写入一次监控表,将重量/车号停留超时等信息写入
  870. mwUpdate.msgInfo = PbCache.ResultMessage;
  871. mwUpdate.weightStatus = PbCache.collect.weightStatus;
  872. //另外初始化一次监控数据
  873. rmsmwUpdateEventData = meterWorkMonitor.doUpdateWf(mwUpdate);
  874. if (!rmsmwUpdateEventData.Succeed)
  875. {
  876. l.WriteLog(0, "frmMain.EventData异常583:写入信息异常" + mwUpdate);
  877. }
  878. #endregion
  879. //验证对射
  880. valid.ValidMethod();
  881. if (!isOpenMeter)
  882. {
  883. //if (PbCache.range != null && PbCache.range.upperRange < e.weight)
  884. if (PbCache.range != null && PbCache.range.upperRange < e.weight)
  885. {
  886. //超量程
  887. vicPlayClass.GetVoicePlay("已超量程", e.carno);
  888. //return;
  889. }
  890. else if (e.weightStatus == 0)
  891. {
  892. if (!PbCache.monitorResult.valid_park_status && validParkStatuConfig == "true")
  893. {
  894. iCountPark++;
  895. if (iCountPark > 9 && !string.IsNullOrEmpty(PbCache.collect.carno))
  896. {
  897. PbCache.ResultMessage = "车辆超出秤台,请调整车位1"; //btnSave_Click
  898. //重量稳定,且对射验证不合格
  899. vicPlayClass.GetVoicePlay("车辆超出秤台,请调整车位", e.carno);
  900. led_controler.setStaticLineMsg(PbCache.sportInfo.ledIp, "车辆超出秤台,请调整车位1");
  901. //return;
  902. iCountPark = 0; //2021年7月27日5s播一次,然后重新在播
  903. }
  904. }
  905. else
  906. {
  907. iCountPark = 0;
  908. }
  909. }
  910. }
  911. if (!lu[0].bcEnable)
  912. {
  913. foreach (ucBusinessType uc in lu)
  914. {
  915. uc.setControlEnable(true);
  916. }
  917. }
  918. if ((sweepCodeClass.StrCode == "" || sweepCodeClass2.StrCode == "") && !codeFlag)
  919. {
  920. PbCache.collect.carno = sCarNo;
  921. }
  922. if (codeFlag && !noteCode)
  923. {
  924. noteCode = true;
  925. meterWorkScheduledHelp1.baseSpotNo = PbCache.sportInfo.baseSpotNo;
  926. meterWorkScheduledHelp1.baseSpotName = PbCache.sportInfo.baseSpotName;
  927. meterWorkScheduledHelp1.carNo = string.IsNullOrEmpty(PbCache.collect.carno) ? PbCache.resultCarNo : PbCache.collect.carno;
  928. meterWorkScheduledHelp1.helpContent = "车号:" + sCarNo + "扫码过秤";
  929. meterWorkScheduledHelp1.warmType = "2";
  930. meterWorkScheduledHelp1.warmTypeName = "智能终端报警";
  931. meterWorkScheduledHelpService.add(meterWorkScheduledHelp1);
  932. }
  933. }
  934. //写入LED信息
  935. //if (PbCache.sportInfo != null && PbCache.ledInfo != PbCache.OldLedInfo)
  936. //{
  937. // PbCache.OldLedInfo = PbCache.ledInfo;
  938. // if (PbCache.monitor != null && PbCache.monitor.ledKeep == "0")
  939. // {
  940. // //led_controler.setOneLineMsg(PbCache.sportInfo.ledIp, PbCache.ledInfo);
  941. // }
  942. //}
  943. }
  944. else
  945. {
  946. isOpened = false; //下次上秤直接打开主界面
  947. if (e.weight > 10 && e.weight < 500)
  948. {
  949. //重量小于500,大于10
  950. MeterWorkMonitor mwUpdate = new MeterWorkMonitor();
  951. mwUpdate.pointNo = PbCache.sportInfo.baseSpotNo;
  952. mwUpdate.wgt = e.weight;
  953. rmsdoUpdateWfEventData = meterWorkMonitor.doUpdateWf(mwUpdate);
  954. }
  955. if (e.weight > 0 && e.weight < 200)
  956. {
  957. doOperateLive();
  958. }
  959. if (e.weight == 0)
  960. {
  961. PbCache.isZeroAlarm = false;
  962. }
  963. editCarNo = "";
  964. firstCode = ""; //历史的扫码枪的值
  965. preCarNo = "";
  966. sCarNo = "";
  967. sPreNo = "";
  968. preWgt = 0;
  969. //不等于空的时候说明写过一次日志了
  970. if (isResFlag)
  971. {
  972. isResFlag = false;
  973. meterWorkScheduledHelp1.baseSpotNo = PbCache.sportInfo.baseSpotNo;
  974. meterWorkScheduledHelp1.baseSpotName = PbCache.sportInfo.baseSpotName;
  975. meterWorkScheduledHelp1.carNo = string.IsNullOrEmpty(PbCache.collect.carno) ? PbCache.resultCarNo : PbCache.collect.carno;
  976. meterWorkScheduledHelp1.helpContent = "车号:" + (string.IsNullOrEmpty(PbCache.collect.carno) ? (string.IsNullOrEmpty(PbCache.resultCarNo) ? "未识别" : PbCache.resultCarNo) : PbCache.collect.carno) + ";重量:" + (PbCache.lockWgt == 0 ? PbCache.resultWgt : PbCache.lockWgt + "") + ";提示信息:" + PbCache.resultMsgAll;
  977. meterWorkScheduledHelp1.warmType = "5";
  978. meterWorkScheduledHelp1.warmTypeName = "计量提示跟踪";
  979. meterWorkScheduledHelpService.add(meterWorkScheduledHelp1);
  980. //l.WriteLog(28, "车号:" + (string.IsNullOrEmpty(PbCache.collect.carno) ? (string.IsNullOrEmpty(PbCache.resultCarNo) ? "未识别" : PbCache.resultCarNo) : PbCache.collect.carno) + ";重量:" + (PbCache.lockWgt == 0 ? PbCache.resultWgt : PbCache.lockWgt + "") + ";提示信息:" + PbCache.resultMsgAll);
  981. }
  982. //不等于空的时候说明写过一次日志了
  983. if (!string.IsNullOrEmpty(RFIDCarNo) && isWriteRFID == "1")
  984. {
  985. meterWorkScheduledHelp1.baseSpotNo = PbCache.sportInfo.baseSpotNo;
  986. meterWorkScheduledHelp1.baseSpotName = PbCache.sportInfo.baseSpotName;
  987. meterWorkScheduledHelp1.carNo = string.IsNullOrEmpty(PbCache.collect.carno) ? PbCache.resultCarNo : PbCache.collect.carno;
  988. meterWorkScheduledHelp1.helpContent = RFIDCarNo;
  989. meterWorkScheduledHelp1.warmType = "7";
  990. meterWorkScheduledHelp1.warmTypeName = "RFID识别率";
  991. meterWorkScheduledHelpService.add(meterWorkScheduledHelp1);
  992. RFIDCarNo = "";
  993. }
  994. //车号来源记录
  995. if (isCarSource)
  996. {
  997. meterWorkScheduledHelp1.baseSpotNo = PbCache.sportInfo.baseSpotNo;
  998. meterWorkScheduledHelp1.baseSpotName = PbCache.sportInfo.baseSpotName;
  999. meterWorkScheduledHelp1.carNo = string.IsNullOrEmpty(PbCache.collect.carno) ? PbCache.resultCarNo : PbCache.collect.carno;
  1000. meterWorkScheduledHelp1.helpContent = PbCache.carNoSource.ToString();
  1001. meterWorkScheduledHelp1.warmType = "8";
  1002. meterWorkScheduledHelp1.warmTypeName = "车号来源记录";
  1003. meterWorkScheduledHelpService.add(meterWorkScheduledHelp1);
  1004. isCarSource = false;
  1005. PbCache.carNoSource = 0;
  1006. }
  1007. PbCache.isOvertimeAlarm = false; //是否超时报警
  1008. PbCache.strCode = "";
  1009. PbCache.strState = "";
  1010. PbCache.ResultMessage = "";
  1011. PbCache.resultMsgAll = "";
  1012. PbCache.resultCarNo = "";
  1013. PbCache.resultWgt = "";
  1014. bEditCar = false;
  1015. isVoiceDownCar = false;
  1016. flagCarMonit = false;
  1017. iHodeTime = 0;
  1018. isOpenMeter = false;
  1019. PbCache.isLockFrm = false;
  1020. PbCache.dtStartTime = null;
  1021. PbCache.voiceOver = true;
  1022. if (PbCache.collect != null && !string.IsNullOrEmpty(PbCache.collect.carno))
  1023. {
  1024. PbCache.collect.carno = "";
  1025. }
  1026. setWelecomeVis(true);
  1027. if (lu[0].bcEnable)
  1028. {
  1029. foreach (ucBusinessType uc in lu)
  1030. {
  1031. uc.setControlEnable(false);
  1032. }
  1033. }
  1034. noteCode = false;
  1035. meterWorkMonitorEventDataI.pointNo = PbCache.sportInfo.baseSpotNo;
  1036. meterWorkMonitorEventDataI.validWgt = "1";
  1037. meterWorkMonitorEventDataI.validCarno = "1";
  1038. meterWorkMonitorEventDataI.validTareTime = "1";
  1039. meterWorkMonitorEventDataI.validMatTime = "1";
  1040. meterWorkMonitorEventDataI.validTimeInterval = "1";
  1041. meterWorkMonitorEventDataI.validParkStatus = "1";
  1042. meterWorkMonitorEventDataI.validExceedWgt = "1";
  1043. meterWorkMonitorEventDataI.validPredictionDiff = "1";
  1044. meterWorkMonitorEventDataI.validLianda = "1";
  1045. meterWorkMonitorEventDataI.validMatClick = "1";
  1046. meterWorkMonitorEventDataI.validArea = "1";
  1047. meterWorkMonitorEventDataI.setCar = "";
  1048. meterWorkMonitorEventDataI.isValidScan = "1";
  1049. meterWorkMonitorEventDataI.rfidCar = "";
  1050. meterWorkMonitorEventDataI.photoCar = "";
  1051. meterWorkMonitorEventDataI.scanCar = "";
  1052. meterWorkMonitorEventDataI.editCar = "";
  1053. meterWorkMonitorEventDataI.zeroState = "0";
  1054. meterWorkMonitorEventDataI.carErr = "0";
  1055. meterWorkMonitorEventDataI.ferroalloyResult = "0";
  1056. meterWorkMonitorEventDataI.wgtErr = "0";
  1057. meterWorkMonitorEventDataI.stopOverTime = "0";
  1058. meterWorkMonitorEventDataI.msgInfo = "";
  1059. meterWorkMonitorEventDataI.ledWriter = "";
  1060. meterWorkMonitorEventDataI.isOverWgt = "";
  1061. meterWorkMonitorEventDataI.isHelp = "0";
  1062. meterWorkMonitorEventDataI.weightStatus = 0;
  1063. meterWorkMonitorEventDataI.wgt = e.weight;
  1064. // DVR,MOXA,PLC状态监控
  1065. // 20220928 by BourneCao
  1066. bool DVR_Online = PingIp(PbCache.sportInfo.videoIp);
  1067. meterWorkMonitorEventDataI.dvrState = DVR_Online == true ? "0" : "1";
  1068. bool Power_Online = PingIp(PbCache.sportInfo.controlIp);
  1069. meterWorkMonitorEventDataI.powerState = Power_Online == true ? "0" : "1";
  1070. bool MOXA_Online = PingIp(PbCache.sportInfo.moxaIp);
  1071. meterWorkMonitorEventDataI.moxaState = MOXA_Online == true ? "0" : "1";
  1072. bool PLC_Online = PingIp(PbCache.sportInfo.plcIp);
  1073. meterWorkMonitorEventDataI.plcState = PLC_Online == true ? "0" : "1";
  1074. //*
  1075. //另外初始化一次监控数据
  1076. RESTfulResult<string> rmssEventData = meterWorkMonitor.doUpdateWf(meterWorkMonitorEventDataI);
  1077. if (!rmssEventData.Succeed)
  1078. {
  1079. l.WriteLog(0, "frmMain.EventData异常754:写入信息异常");
  1080. }
  1081. //*/
  1082. //LED写入
  1083. if (isLedWrite)
  1084. {
  1085. isLedWrite = false;
  1086. }
  1087. }
  1088. #endregion
  1089. }
  1090. catch (Exception ex)
  1091. {
  1092. l.WriteLog(0, "frmMain.EventData异常:" + ex.Message);
  1093. }
  1094. }
  1095. private delegate void ShowBtnTare(bool flag);//定义委托 期限皮重按钮
  1096. List<LiveData> lldoOperateLive = new List<LiveData>();
  1097. /// <summary>
  1098. /// 操作Live表的数据:零点报警
  1099. /// </summary>
  1100. private void doOperateLive () {
  1101. if (PbCache.collect_no==null)
  1102. {
  1103. return;
  1104. }
  1105. lldoOperateLive = MemoClass.getWarnInfo(PbCache.collect_no);
  1106. if (lldoOperateLive != null)
  1107. {
  1108. foreach (LiveData lv in lldoOperateLive)
  1109. {
  1110. switch (lv.Tagname.Replace(PbCache.collect_no, ""))
  1111. {
  1112. case "StaticStatus"://车辆检测 "0、东西方向激光均无报警;否则报警
  1113. break;
  1114. case "SwitchLight"://PLC红绿灯控制模式状态 "PLC有三种控制模式:1、自动、2、远控;3、检修
  1115. break;
  1116. case "LightWest"://红绿灯:1、为绿灯;2、为红灯;"
  1117. break;
  1118. case "ZeroWeightStatus": //0、其它,1、零点报警,红绿灯变红,
  1119. if (((lv.Value ?? "0") + "").Equals("1"))
  1120. {
  1121. doInsertZeroAlarm();
  1122. PbCache.isZeroAlarm = true;
  1123. }
  1124. else
  1125. {
  1126. PbCache.isZeroAlarm = false;
  1127. }
  1128. break;
  1129. case "ZeroWeight":
  1130. mwmdoLive.zeroWeight = lv.Value.ToString();
  1131. break;
  1132. }
  1133. }
  1134. }
  1135. }
  1136. List<LiveData> lldoLive = new List<LiveData>();
  1137. RESTfulResult<string> rmsdoLive = new RESTfulResult<string>();
  1138. MeterWorkMonitor mwmdoLive = new MeterWorkMonitor();
  1139. /// <summary>
  1140. /// 操作Live表的数据:零点报警
  1141. /// </summary>
  1142. private void doLive()
  1143. {
  1144. if (PbCache.collect_no == null)
  1145. {
  1146. return;
  1147. }
  1148. lldoLive = MemoClass.getWarnInfo(PbCache.collect_no);
  1149. mwmdoLive.pointNo = PbCache.sportInfo.baseSpotNo;
  1150. mwmdoLive.redGreenLightState = "0";
  1151. if (lldoLive != null)
  1152. {
  1153. foreach (LiveData lv in lldoLive)
  1154. {
  1155. switch (lv.Tagname.Replace(PbCache.collect_no, ""))
  1156. {
  1157. case "PowerStatus":
  1158. mwmdoLive.powerState = lv.Value.ToString();
  1159. break;
  1160. case "PlcWatchDog":
  1161. if (int.Parse(lv.Value.ToString()) >= 0 && int.Parse(lv.Value.ToString()) <= 0)
  1162. {
  1163. mwmdoLive.plcState = 0.ToString();
  1164. }
  1165. break;
  1166. case "InfraredWest":
  1167. if (lv.Value.ToString() == "2")
  1168. {
  1169. mwmdoLive.leftInfraredRayState = "0";
  1170. }
  1171. else
  1172. {
  1173. mwmdoLive.leftInfraredRayState = lv.Value.ToString();
  1174. }
  1175. break;
  1176. case "InfraredEast":
  1177. if (lv.Value.ToString() == "2")
  1178. {
  1179. mwmdoLive.rightInfraredRayState = "0";
  1180. }
  1181. else
  1182. {
  1183. mwmdoLive.rightInfraredRayState = lv.Value.ToString();
  1184. }
  1185. break;
  1186. case "AmplifierState":
  1187. mwmdoLive.amplifierState = lv.Value.ToString();
  1188. break;
  1189. case "Lamp":
  1190. if (lv.Value.ToString() == "2")
  1191. {
  1192. mwmdoLive.lampState = "0";
  1193. }
  1194. else
  1195. {
  1196. mwmdoLive.lampState = lv.Value.ToString();
  1197. }
  1198. break;
  1199. case "InfraredLeft":
  1200. if (lv.Value.ToString() == "2")
  1201. {
  1202. mwmdoLive.frontInfraredRayState = "0";
  1203. PbCache.monitorResult.valid_frontInfraredRay_right_status = false;
  1204. }
  1205. else
  1206. {
  1207. mwmdoLive.frontInfraredRayState = lv.Value.ToString();
  1208. PbCache.monitorResult.valid_frontInfraredRay_right_status = true;
  1209. }
  1210. break;
  1211. case "InfraredRight":
  1212. if (lv.Value.ToString() == "2")
  1213. {
  1214. mwmdoLive.rearInfraredRayState = "0";
  1215. PbCache.monitorResult.valid_frontInfraredRay_left_status = false;
  1216. }
  1217. else
  1218. {
  1219. mwmdoLive.rearInfraredRayState = lv.Value.ToString();
  1220. PbCache.monitorResult.valid_frontInfraredRay_left_status = true;
  1221. }
  1222. break;
  1223. case "RfidState":
  1224. mwmdoLive.rfidState = lv.Value.ToString();
  1225. break;
  1226. case "ZeroWeightStatus":
  1227. mwmdoLive.zeroState = lv.Value.ToString();
  1228. if (((lv.Value ?? "0") + "").Equals("1"))
  1229. {
  1230. doInsertZeroAlarm();
  1231. PbCache.isZeroAlarm = true;
  1232. }
  1233. else
  1234. {
  1235. PbCache.isZeroAlarm = false;
  1236. }
  1237. break;
  1238. case "ZeroWeight":
  1239. mwmdoLive.zeroWeight = lv.Value.ToString();
  1240. break;
  1241. }
  1242. }
  1243. }
  1244. rmsdoLive = meterWorkMonitor.doUpdateWf(mwmdoLive);
  1245. }
  1246. MeterWorkZeroAlarm workZeroAlarmdoInsertZeroAlarm = new MeterWorkZeroAlarm();
  1247. RESTfulResult<String> rmsworkZeroAlarmdoInsertZeroAlarm = new RESTfulResult<string>();
  1248. /// <summary>
  1249. /// 新增零点报警的数据
  1250. /// </summary>
  1251. private void doInsertZeroAlarm()
  1252. {
  1253. if (!PbCache.isZeroAlarm)
  1254. {
  1255. PbCache.isZeroAlarm = true;
  1256. workZeroAlarmdoInsertZeroAlarm.zeroWeight = PbCache.collect.weight;
  1257. workZeroAlarmdoInsertZeroAlarm.spotTypeNo = PbCache.sportInfo.spotTypeNo;
  1258. workZeroAlarmdoInsertZeroAlarm.spotTypeName = PbCache.sportInfo.spotTypeName;
  1259. workZeroAlarmdoInsertZeroAlarm.baseSpotNo = PbCache.sportInfo.baseSpotNo;
  1260. workZeroAlarmdoInsertZeroAlarm.baseSpotName = PbCache.sportInfo.baseSpotName;
  1261. workZeroAlarmdoInsertZeroAlarm.scalePointNo = PbCache.collect_no;
  1262. workZeroAlarmdoInsertZeroAlarm.createManNo = PbCache.sportInfo.baseSpotNo;
  1263. workZeroAlarmdoInsertZeroAlarm.createManName = PbCache.sportInfo.baseSpotName;
  1264. rmsworkZeroAlarmdoInsertZeroAlarm = zeroAlarmService.doInsertZeroAlarm(workZeroAlarmdoInsertZeroAlarm);
  1265. if (rmsworkZeroAlarmdoInsertZeroAlarm.Succeed)
  1266. {
  1267. l.WriteLog(20, "新增成功:" + workZeroAlarmdoInsertZeroAlarm.baseSpotName +":"+ workZeroAlarmdoInsertZeroAlarm.zeroWeight);
  1268. }
  1269. else
  1270. {
  1271. l.WriteLog(20, "操作失败:" + workZeroAlarmdoInsertZeroAlarm.baseSpotName + ":" + workZeroAlarmdoInsertZeroAlarm.zeroWeight + rmsworkZeroAlarmdoInsertZeroAlarm.Data + rmsworkZeroAlarmdoInsertZeroAlarm.Message);
  1272. }
  1273. }
  1274. }
  1275. /// <summary>
  1276. /// 关闭程序
  1277. /// </summary>
  1278. /// <param name="sender"></param>
  1279. /// <param name="e"></param>
  1280. private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
  1281. {
  1282. StopWriteMonitor();//结束更新监控表线程
  1283. collection.Stop();
  1284. imageCurlControl.Stop();
  1285. sweepCodeClass.CloseThread();
  1286. sweepCodeClass2.CloseThread();
  1287. timer1.Stop();
  1288. timer1.Dispose();
  1289. }
  1290. private bool SystemUpdate(bool isMessage)
  1291. {
  1292. ReleaseList releaseList = new ReleaseList(Application.StartupPath + @"\" + GlobalVariable.Instance.ReleaseFileName);
  1293. DownloadTools dt = new DownloadTools();
  1294. try
  1295. {
  1296. bool isDownload = dt.IsDownloadFile(GlobalVariable.Instance.LocalPath, GlobalVariable.Instance.ReleaseURL, GlobalVariable.Instance.ReleaseFileName);
  1297. if (!isDownload)
  1298. {
  1299. if (isMessage) MessageBox.Show("无法连接到远程主机!", Application.ProductName);
  1300. return false;
  1301. }
  1302. }
  1303. catch (Exception e)
  1304. {
  1305. MessageBox.Show(e.Message);
  1306. }
  1307. bool flag = this.CheckUpdate(releaseList);
  1308. if (flag)
  1309. {
  1310. MessageBox.Show("有新版本,现在更新");
  1311. string t = dt.DownloadFile(Application.StartupPath, GlobalVariable.Instance.ReleaseURL, GlobalVariable.Instance.ApplicationUpdater);
  1312. this.Close();
  1313. Application.Exit();
  1314. GC.Collect();
  1315. Process.Start(Application.StartupPath + @"\" + GlobalVariable.Instance.ApplicationUpdater);
  1316. return true;
  1317. }
  1318. else
  1319. {
  1320. if (isMessage) MessageBox.Show("你的系统已经是最新版本,不需要更新!", Application.ProductName);
  1321. return false;
  1322. }
  1323. }
  1324. private bool CheckUpdate(ReleaseList localRelease)
  1325. {
  1326. try
  1327. {
  1328. string fileNameAll = Application.StartupPath + "\\" + GlobalVariable.Instance.LocalPath + "\\" + GlobalVariable.Instance.ReleaseFileName;
  1329. ReleaseList remoteRelease = new ReleaseList(fileNameAll);
  1330. return (((localRelease != null) && (remoteRelease != null)) && localRelease.ReleaseDate.CompareTo(remoteRelease.ReleaseDate) < 0);
  1331. }
  1332. catch (Exception exception)
  1333. {
  1334. MessageBox.Show(exception.Message);
  1335. }
  1336. return false;
  1337. }
  1338. private void DecodeQRCodeYMT(string strCode)
  1339. {
  1340. try
  1341. {
  1342. //进行扫码,判断
  1343. if (PbCache.carNoSource == 1 || PbCache.carNoSource == 2)
  1344. {
  1345. PbCache.carNoSource = 3;
  1346. }
  1347. codeFlag = true;
  1348. string token = httpRequest.GetToken();
  1349. string carNo = httpRequest.getCarNo(strCode, token);
  1350. PbCache.collect.carno = carNo;
  1351. PbCache.strCode = carNo;
  1352. }
  1353. catch (Exception e)
  1354. {
  1355. }
  1356. }
  1357. private void DecodeQRCode(string strCode)
  1358. {
  1359. if (PbCache.carNoSource == 1 || PbCache.carNoSource == 2)
  1360. {
  1361. PbCache.carNoSource = 3;
  1362. }
  1363. codeFlag = true;
  1364. //frmOneYardToEnd frmOneYardToEnd = new frmOneYardToEnd();
  1365. Hashtable hashTable = new Hashtable();
  1366. hashTable.Add("message", strCode);
  1367. rmsSweepCodeClass = mwcfs.DecryptionForWfTest(hashTable);
  1368. if (rmsSweepCodeClass.Code == "0")
  1369. {
  1370. PbCache.collect.carno = rmsSweepCodeClass.Data;
  1371. PbCache.strCode = rmsSweepCodeClass.Data;
  1372. }
  1373. if (rmsSweepCodeClass.Code == "1")
  1374. {
  1375. vicPlayClass.GetVoicePlay("车号二维码已过期", PbCache.collect.carno);
  1376. frmOneYardToEnd.setMsgInfo("车号二维码已过期");
  1377. }
  1378. if (rmsSweepCodeClass.Code == "2")
  1379. {
  1380. //vicPlayClass.GetVoicePlay("不是有效车号二维码", PbCache.collect.carno);
  1381. //frmOneYardToEnd.setMsgInfo("不是有效车号二维码");
  1382. }
  1383. if (rmsSweepCodeClass.Code == "9")
  1384. {
  1385. //vicPlayClass.GetVoicePlay("不是有效车号二维码", PbCache.collect.carno);
  1386. //frmOneYardToEnd.setMsgInfo("不是有效车号二维码");
  1387. }
  1388. l.WriteLog(12, "测试扫码值:'" + rmsSweepCodeClass.Data+"'");
  1389. }
  1390. #region 更新监控表线程
  1391. //rxh add
  1392. private Thread thWriteMonitor;//更新监控表线程
  1393. private int writeMonitorInterval;//时间间隔
  1394. private void WriteMonitorInTime()
  1395. {
  1396. while (true)
  1397. {
  1398. try
  1399. {
  1400. doLive();//更新监控表!!!!!!!!!!!
  1401. writeMonitorInterval = 1000;
  1402. }
  1403. catch (Exception ee)
  1404. {
  1405. //GlobalInstanceController.Instance.LastCallMessage = ee.Message;
  1406. writeMonitorInterval = 5000;
  1407. }
  1408. Thread.Sleep(writeMonitorInterval);
  1409. }
  1410. }
  1411. private void StopWriteMonitor()
  1412. {
  1413. if (thWriteMonitor != null)
  1414. {
  1415. thWriteMonitor.Abort();
  1416. thWriteMonitor = null;
  1417. }
  1418. }
  1419. private void StartWriteMonitor(int interval)
  1420. {
  1421. writeMonitorInterval = (interval == 0 ? 1000 : interval);
  1422. if (thWriteMonitor == null)
  1423. {
  1424. thWriteMonitor = new Thread(WriteMonitorInTime);
  1425. }
  1426. thWriteMonitor.Start();
  1427. }
  1428. #endregion 更新监控表线程
  1429. #region PING IP
  1430. /// <summary>
  1431. /// ping ip,测试能否ping通
  1432. /// </summary>
  1433. /// <param name="strIP">IP地址</param>
  1434. /// <returns></returns>
  1435. private bool PingIp(string strIP)
  1436. {
  1437. bool bRet = false;
  1438. try
  1439. {
  1440. Ping pingSend = new Ping();
  1441. PingReply reply = pingSend.Send(strIP, 1000);
  1442. if (reply.Status == IPStatus.Success)
  1443. bRet = true;
  1444. }
  1445. catch (Exception)
  1446. {
  1447. bRet = false;
  1448. }
  1449. return bRet;
  1450. }
  1451. #endregion
  1452. }
  1453. }