frmMain.cs 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882
  1. using CarMeterSystem.OptionCls;
  2. using com.hnshituo.core.webapp.vo;
  3. using Common;
  4. using iCore.Rtdb.RtdbTable;
  5. using MeterConditionLibrary;
  6. using MeterModelLibrary;
  7. using MeterModuleLibrary.uc;
  8. using MeterPlugInLibrary;
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Data;
  12. using System.Drawing;
  13. using System.Linq;
  14. using System.Windows.Forms;
  15. namespace CarMeterSystem
  16. {
  17. public partial class frmMain : Form
  18. {
  19. public frmMain()
  20. {
  21. InitializeComponent();
  22. }
  23. private Log l = Log.GetInstance();
  24. private Print printClass = new Print();//打印
  25. //内存表
  26. private MemoryTableDataSocket MemoClass = new MemoryTableDataSocket("");
  27. //实时表数据采集
  28. private DataCollectionControl collection = new DataCollectionControl();
  29. //图片控制器含图片压缩及上传curl
  30. private ImageCurlControl imageCurlControl = new ImageCurlControl();
  31. //与监控界面对接的表
  32. private MeterWorkMonitorService meterWorkMonitor = new MeterWorkMonitorService();
  33. //零点报警表
  34. private meterworkzeroalarmservice zeroAlarmService = new meterworkzeroalarmservice();
  35. //车号修正
  36. private CarNoModfiy modfiy = new CarNoModfiy();
  37. /// <summary>
  38. /// 这个是保存前一次采集中的车号信息
  39. /// </summary>
  40. private string preCarNo = "";
  41. //验证对射
  42. private validParkStatus valid = new validParkStatus();
  43. //语音播报
  44. private VoicePlay vicPlayClass = new VoicePlay();
  45. //扫码枪
  46. private SweepCode sweepCodeClass = new SweepCode();
  47. private LED_Control led_controler = null;
  48. //监控表操作
  49. private MeterMonitorWeightService monitorWeightService = new MeterMonitorWeightService();
  50. //历史皮操作
  51. private MeterBaseHisTareDataService hisTareDataService = new MeterBaseHisTareDataService();
  52. /// <summary>
  53. /// 欢迎界面
  54. /// </summary>
  55. private frmWelcome_Jisco frmWelcome = new frmWelcome_Jisco();//欢迎
  56. /// <summary>
  57. /// 基础数据载入
  58. /// </summary>
  59. private BaseDbCls bd = new BaseDbCls();
  60. //扫码修正车号标识
  61. private bool codeFlag = false;
  62. private List<ucBusinessType> lu = new List<ucBusinessType>();
  63. private bool isVoiceDownCar = false;//车上人员请下车播放一次
  64. private bool isShowFrmWelcome = true; //是否显示欢迎界面
  65. private bool isOpened = false;//是否已经打开了扫码计量界面
  66. private void frmMain_Load(object sender, EventArgs e)
  67. {
  68. //*
  69. try
  70. {
  71. this.Hide();
  72. LoginCls lg = new LoginCls();
  73. timer1.Start();
  74. //2021年6月21日 杨秀东添加
  75. if (isShowFrmWelcome)
  76. {
  77. frmWelcome.Show();
  78. frmWelcome.Visible = true;
  79. }
  80. if (lg.LoginIn())
  81. {
  82. if (bd.setBaseDb() && bd.getBaseDb())
  83. {
  84. if (!string.IsNullOrEmpty(PbCache.sportInfo.ledIp))
  85. {
  86. led_controler = new LED_Control(PbCache.sportInfo.ledIp);
  87. }
  88. //调用该方法时已赋值 test git 测试git推送代码123;456
  89. RESTfulResult<List<MeterWorkMonitor>> rm = meterWorkMonitor.doQueryOneWf(new MeterWorkMonitor { validFlag = "1", pointNo = PbCache.sportInfo.baseSpotNo });
  90. if (!rm.Succeed)
  91. {
  92. l.WriteLog(1, "载入监控表数据异常");
  93. return;
  94. }
  95. else if (rm.Data != null && rm.Data.Count > 0)
  96. {
  97. if (string.IsNullOrEmpty(PbCache.collect_no))
  98. {
  99. PbCache.collect_no = rm.Data[0].collectionCode;
  100. MemoClass = new MemoryTableDataSocket(PbCache.collect_no);
  101. }
  102. }
  103. else
  104. {
  105. l.WriteLog(1, "为配置监控数据");
  106. return;
  107. }
  108. //若未校秤的话,也不允许计量
  109. //载入界面业务按钮
  110. if (PbCache.businessType != null && PbCache.businessType.Count > 0)
  111. {
  112. foreach (ComBaseInfo info in PbCache.businessType)
  113. {
  114. ucBusinessType uc = new ucBusinessType();
  115. switch (info.baseCode)
  116. {
  117. case "001006003":
  118. uc.setControl(info.baseName, info.memo, info.baseCode);
  119. break;
  120. case "001006001":
  121. case "001006002":
  122. uc.setControl(info.baseName, info.memo, info.baseCode);
  123. break;
  124. default:
  125. uc.setControl(info.baseName, info.memo, info.baseCode);
  126. break;
  127. }
  128. uc.Dock = DockStyle.Top;
  129. //uc.setControl("","","",);
  130. uc.ucEvent += new EventHandler(ucEvents);
  131. lu.Add(uc);
  132. //panel7.Controls.Add(uc);
  133. }
  134. }
  135. //开启基础进程
  136. l.WriteLog(0, "系统登录成功");
  137. collection.EventDataCollectionArgs += new EventDataCollection(EventData);//数据采集及扫码信息
  138. collection.Start(PbCache.sportInfo.baseSpotNo, PbCache.sportInfo.baseSpotName);
  139. //imageCurlControl.Start(); //图片上传线程
  140. sweepCodeClass.StartThreadSweep(); //扫码线程
  141. }
  142. else
  143. {
  144. l.WriteLog(0, "系统登录失败");
  145. }
  146. }
  147. else
  148. {
  149. l.WriteLog(0, "按IP地址找不到计量点信息,系统登录失败");
  150. }
  151. }
  152. catch (Exception ex)
  153. {
  154. l.WriteLog(0, "系统加载失败:" + ex.Message);
  155. }
  156. //*/
  157. }
  158. /// <summary>
  159. /// 直接打开扫码计量界面
  160. /// </summary>
  161. /// <param name="sender"></param>
  162. /// <param name="e"></param>
  163. private void timer1_Tick(object sender, EventArgs e)
  164. {
  165. if (!isOpened && PbCache.collect?.weight > 500)
  166. {
  167. isOpened = true;
  168. PbCache.bussinessTypeName = "";
  169. PbCache.bussinessTypeCode = "";
  170. frmOneYardToEnd fcc = new frmOneYardToEnd();
  171. fcc.ShowDialog();
  172. }
  173. }
  174. #region
  175. //*
  176. /// <summary>
  177. /// 委托的方式调用控件的点击事件
  178. /// </summary>
  179. /// <param name="sender"></param>
  180. /// <param name="e"></param>
  181. public void ucEvents(object sender, EventArgs e)
  182. {
  183. Control control = (Control)sender;
  184. ucBusinessType um = control.Parent.Parent as ucBusinessType;
  185. try
  186. {
  187. switch (control.Name)
  188. {
  189. case "btnContext":
  190. case "btnPurchase":
  191. {
  192. PbCache.bussinessTypeName = um._bussiness == null ? "" : um._bussiness;
  193. PbCache.bussinessTypeCode = um._code;
  194. switch (um._code)
  195. {
  196. case "001006003":
  197. frmInternalTransport frm = new frmInternalTransport();
  198. frm.ShowDialog();
  199. break;
  200. /*
  201. case "001006001":
  202. case "001006002":
  203. frmCarSalePurchase frmCar = new frmCarSalePurchase();
  204. frmCar.ShowDialog();
  205. break;
  206. //*/
  207. default:
  208. frmCarSalePurchase frmCar = new frmCarSalePurchase();
  209. frmCar.ShowDialog();
  210. break;
  211. }
  212. };
  213. break;
  214. default: break;
  215. }
  216. }
  217. catch (Exception ex)
  218. {
  219. //MessageBox.Show("操作异常:" + ex.Message);
  220. }
  221. }
  222. //*/
  223. #endregion
  224. #region
  225. private void setThisVis(bool visb)
  226. {
  227. if (this.InvokeRequired)
  228. {
  229. Action<bool> action = new Action<bool>(setThisVis);
  230. Invoke(action, new object[] { visb });
  231. }
  232. else
  233. {
  234. if (this.Visible != visb)
  235. {
  236. this.Visible = visb;
  237. }
  238. }
  239. }
  240. #endregion
  241. #region
  242. private void setWelecomeVis(bool visb)
  243. {
  244. if (!isShowFrmWelcome) return;//2021年6月21日 杨秀东添加
  245. if (frmWelcome.InvokeRequired)
  246. {
  247. Action<bool> action = new Action<bool>(setWelecomeVis);
  248. Invoke(action, new object[] { visb });
  249. }
  250. else
  251. {
  252. if (frmWelcome.Visible != visb)
  253. {
  254. frmWelcome.Visible = visb;
  255. frmWelcome.setLogin();
  256. }
  257. }
  258. //*/
  259. }
  260. #endregion
  261. private int iCount = 0, iHodeTime = 0;
  262. private bool flagCarMonit = false;//车号修正
  263. private bool bEditCar = false; //手动修正车号
  264. private bool isOpenMeter = false; //是否已打开计量界面,若已经打开则这里关于超量程及红外的语音将停止播报
  265. private string firstCode = "";//上次扫码的信息
  266. private string ledTxt = "";
  267. private bool isLedWrite = false;//是否写入一次LED
  268. private string sPreNo = ""; //记录重量曲线变化
  269. private int preWgt = 0;//前一次重量,用于重量曲线
  270. private string sCarNo = "";
  271. private int iCountPark = 0;
  272. private string editCarNo = "";
  273. /// <summary>
  274. /// 数据采集
  275. /// </summary>
  276. /// <param name="o"></param>
  277. /// <param name="e"></param>
  278. private void EventData(object o, DataCollectionArgs e)
  279. {
  280. //这里每隔0.5秒执行一次
  281. try
  282. {
  283. #region 扫码信息
  284. sweepCodeClass.StrState = e.weightStatus + ""; //重量状态信息;当StrState= 0时,获取扫码信息,StrState= 2时将扫码信息置位“”空;其他状态不处理
  285. if (string.IsNullOrEmpty(sweepCodeClass.StrCode))
  286. {
  287. if (string.IsNullOrEmpty(PbCache.strCode))
  288. {
  289. firstCode = "";
  290. PbCache.strCode = "";
  291. l.WriteLog(12, "主线程扫码值为空时清空;sweepCodeClass.StrCode值为" + sweepCodeClass.StrCode + " ;PbCache.strCode值为:" + PbCache.strCode);
  292. }
  293. }
  294. else
  295. {
  296. ////日期2021年12月22日:重复扫码,取前面12位
  297. //if (sweepCodeClass.StrCode.Length > 15)
  298. //{
  299. // // todo: 加入车号截取逻辑
  300. // sweepCodeClass.StrCode = sweepCodeClass.StrCode.Substring(0,12);
  301. //}
  302. //if (firstCode != sweepCodeClass.StrCode || string.IsNullOrEmpty(PbCache.strCode))
  303. //{
  304. // l.WriteLog(12, "主线程扫码值赋值;sweepCodeClass.StrCode值为" + sweepCodeClass.StrCode + " ;PbCache.strCode前值为:" + PbCache.strCode);
  305. // PbCache.strCode = sweepCodeClass.StrCode;
  306. // firstCode = PbCache.strCode;
  307. //}
  308. l.WriteLog(12, "测试扫码值" + PbCache.strCode);
  309. PbCache.collect.carno = sweepCodeClass.StrCode;
  310. codeFlag = true;
  311. }
  312. #endregion 扫码信息
  313. #region 秤上无车10分钟获取一次基础数据
  314. if (iCount < 1200)
  315. {
  316. iCount++;
  317. }
  318. else
  319. {
  320. try
  321. {
  322. //秤上没有车时,每隔10分钟获取一次基础数据
  323. if (e.weight < 500)
  324. {
  325. if (bd.setBaseDb())
  326. {
  327. l.WriteLog(0, "十分钟获取基础数据成功");
  328. }
  329. else
  330. {
  331. l.WriteLog(0, "十分钟获取基础数据失败");
  332. }
  333. iCount = 0;
  334. }
  335. }
  336. catch (Exception ex)
  337. {
  338. l.WriteLog(0, "十分钟获取基础数据失败:" + ex.Message);
  339. iCount = 0;
  340. }
  341. }
  342. #endregion
  343. #region 每10秒写入一次当前时间
  344. if (iCount % 20 == 0)
  345. {
  346. //更新在线时间
  347. RESTfulResult<string> rms = meterWorkMonitor.doUpdateWf(new MeterWorkMonitor { pointNo = PbCache.sportInfo.baseSpotNo, lastTime = DateTime.Now });
  348. if (!rms.Succeed)
  349. {
  350. l.WriteLog(0, "frmMain.EventData异常:写入时间异常");
  351. }
  352. }
  353. #endregion
  354. #region
  355. //一旦界面锁定则不采集数据
  356. //if (!PbCache.isLockFrm)
  357. //{
  358. PbCache.collect.pointid = PbCache.sportInfo.baseSpotNo;
  359. PbCache.collect.weight = e.weight;
  360. PbCache.collect.weightStatus = e.weightStatus;
  361. PbCache.collect.parkStatus = e.parkStatus;
  362. PbCache.collect.datetime = e.datetime;
  363. PbCache.collect.licType = e.licType;
  364. //}
  365. //*/
  366. //重量大于500的情况下
  367. if (e.weight > 500)
  368. {
  369. if (PbCache.dtStartTime == null)
  370. PbCache.dtStartTime = DateTime.Now;
  371. isLedWrite = true;
  372. #region 车上人员请下车
  373. try
  374. {
  375. //界面未锁定的情况下,有车号,如果重量稳定了,停车线验证通过,未超量程的情况下,则按钮可用
  376. if (PbCache.collect != null && !string.IsNullOrEmpty(PbCache.collect.carno) && PbCache.collect.weightStatus == 0 && PbCache.monitorResult.valid_park_status && PbCache.collect.weight < PbCache.range.upperRange)
  377. {
  378. if (!isVoiceDownCar)
  379. {
  380. isVoiceDownCar = true;
  381. vicPlayClass.GetVoicePlay("车上人员请下车", PbCache.collect.carno);
  382. }
  383. }
  384. }
  385. catch { }
  386. #endregion
  387. setWelecomeVis(false);
  388. //每隔1秒刷一次计量实时监控表数据值
  389. if (iCount % 2 == 0)
  390. {
  391. //调用该方法时已赋值
  392. RESTfulResult<List<MeterWorkMonitor>> rm = meterWorkMonitor.doQueryOneWf(new MeterWorkMonitor { validFlag = "1", pointNo = PbCache.sportInfo.baseSpotNo });
  393. if (!rm.Succeed)
  394. {
  395. l.WriteLog(0, "frmMain.EventData异常419:" + rm.ResultMessage);
  396. }
  397. else
  398. {
  399. if (rm.Data != null && rm.Data.Count > 0)
  400. {
  401. PbCache.monitor = rm.Data[0];
  402. if (string.IsNullOrEmpty(PbCache.collect_no))
  403. {
  404. PbCache.collect_no = rm.Data[0].collectionCode;
  405. }
  406. if (ledTxt != rm.Data[0].ledWriter && rm.Data[0].ledWriter != "")
  407. {
  408. //调用LED信息写入******************************
  409. ledTxt = rm.Data[0].ledWriter;
  410. }
  411. if (string.IsNullOrEmpty(ledTxt))
  412. {
  413. ledTxt = "欢迎使用酒钢汽车衡智能计量系统!";
  414. }
  415. }
  416. }
  417. #region 2021-03-29
  418. #region 摄像头当前采集的车号与上次采集的不一样且当前未勾选不验证,且当前车号未进行手动修正的情况下
  419. if (preCarNo != e.carno && PbCache.monitor != null && PbCache.monitor.validCarno != "0" && !bEditCar)
  420. {
  421. flagCarMonit = false;
  422. }
  423. preCarNo = e.carno;
  424. #endregion
  425. if (!flagCarMonit)
  426. {
  427. sCarNo = e.carno;
  428. }
  429. //*
  430. //有车号,且重量稳定的情况下,只修正一次车号
  431. if (!string.IsNullOrEmpty(e.carno) && e.weightStatus == 0 && !flagCarMonit && PbCache.monitor != null && PbCache.monitor.carMonitor == "1" && PbCache.monitor.carMonitorLvl > 0)
  432. {
  433. flagCarMonit = true;
  434. string methods = "";
  435. for (int i = 0; i <= PbCache.monitor.carMonitorLvl; i++)
  436. {
  437. methods += "CarNoTrustCorrect" + i + ",";
  438. }
  439. editCarNo = modfiy.CarNoCorrect(e.carno, methods.Substring(0, methods.Length - 1));
  440. sCarNo = editCarNo;
  441. //mwUpdate
  442. }
  443. //勾选了不验证车号的情况
  444. if (PbCache.monitor.validCarno == "0")
  445. {
  446. flagCarMonit = true;
  447. }
  448. #endregion
  449. #region 每隔1秒写入一次重量曲线
  450. try
  451. {
  452. if (preWgt != e.weight)
  453. {
  454. preWgt = e.weight;
  455. sPreNo = PbCache.sportInfo.baseSpotNo + DateTime.Now.ToString("yyyyMMddHHmmssfff");
  456. monitorWeightService.doAddWf(new MeterMonitorWeight
  457. {
  458. weightNo = sPreNo,
  459. baseSpotNo = PbCache.sportInfo.baseSpotNo,
  460. baseSpotName = PbCache.sportInfo.baseSpotName,
  461. collectWeight = e.weight + "",
  462. collectStartTime = PbCache.dtStartTime.Value,
  463. collectEndTime = DateTime.Now,
  464. spotTypeNo = "001002001",
  465. spotTypeName = "汽车衡",
  466. actualFirstNo = PbCache.actualFirstNo
  467. });
  468. }
  469. else
  470. {
  471. if (!string.IsNullOrEmpty(sPreNo))
  472. {
  473. monitorWeightService.doUpdateWf(new MeterMonitorWeight
  474. {
  475. weightNo = sPreNo,
  476. collectEndTime = DateTime.Now
  477. });
  478. }
  479. }
  480. }
  481. catch { }
  482. #endregion
  483. #region 停留超时
  484. iHodeTime++;
  485. MeterWorkMonitor mwUpdate = new MeterWorkMonitor();
  486. mwUpdate.pointNo = PbCache.sportInfo.baseSpotNo;
  487. mwUpdate.editCar = editCarNo;
  488. if (PbCache.holdTime != null && PbCache.holdTime.Count > 0)
  489. {
  490. if (PbCache.holdTime[0].retentionTime != null)
  491. {
  492. if (PbCache.holdTime[0].retentionTime.Value < iHodeTime)
  493. {
  494. PbCache.isOvertimeAlarm = true; //是否超时报警
  495. mwUpdate.stopOverTime = "1"; //写入一次停留超时
  496. //mwUpdate.isHelp = "1";//派位
  497. //mwUpdate.isTakeOver = "1";
  498. iHodeTime = 99999;//不再增长避免超出
  499. }
  500. }
  501. }
  502. #endregion
  503. #region RFID识别车号信息
  504. mwUpdate.rfidCar = "";
  505. mwUpdate.photoCar = e.vdioCarNos;
  506. if (!string.IsNullOrEmpty(e.RfidNos))
  507. {
  508. if (PbCache.ltCarCard != null && PbCache.ltCarCard.Count > 0)
  509. {
  510. MeterBaseCarCard carCard = PbCache.ltCarCard.Where(s => s.cardNo == e.RfidNos).FirstOrDefault();
  511. if (carCard != null && !string.IsNullOrEmpty(carCard.carNo))
  512. {
  513. mwUpdate.rfidCar = carCard.carNo;
  514. sCarNo = carCard.carNo;
  515. flagCarMonit = true;
  516. //PbCache.collect.carno = carCard.carNo;
  517. }
  518. }
  519. }
  520. #endregion
  521. #region 计量员修改的车号信息
  522. if (PbCache.monitor != null && !string.IsNullOrEmpty(PbCache.monitor.setCar))
  523. {
  524. sCarNo = PbCache.monitor.setCar;
  525. bEditCar = true;
  526. flagCarMonit = true;
  527. codeFlag = false;
  528. sweepCodeClass.StrCode = "";
  529. }
  530. #endregion
  531. #region 重量信息
  532. if (!PbCache.isLockFrm)
  533. {
  534. mwUpdate.wgt = e.weight;
  535. }
  536. else
  537. {
  538. mwUpdate.wgt = Convert.ToInt32(PbCache.lockWgt);
  539. }
  540. #endregion
  541. #region 写入一次监控表,将重量/车号停留超时等信息写入
  542. mwUpdate.msgInfo = PbCache.ResultMessage;
  543. //另外初始化一次监控数据
  544. RESTfulResult<string> rms = meterWorkMonitor.doUpdateWf(mwUpdate);
  545. if (!rms.Succeed)
  546. {
  547. l.WriteLog(0, "frmMain.EventData异常583:写入信息异常");
  548. }
  549. #endregion
  550. //验证对射
  551. valid.ValidMethod();
  552. if (!isOpenMeter)
  553. {
  554. //if (PbCache.range != null && PbCache.range.upperRange < e.weight)
  555. if (PbCache.range != null && PbCache.range.upperRange < e.weight)
  556. {
  557. //超量程
  558. vicPlayClass.GetVoicePlay("已超量程", e.carno);
  559. //return;
  560. }
  561. else if (e.weightStatus == 0)
  562. {
  563. if (!PbCache.monitorResult.valid_park_status)
  564. {
  565. iCountPark++;
  566. if (iCountPark > 9)
  567. {
  568. //重量稳定,且对射验证不合格
  569. vicPlayClass.GetVoicePlay("您的车辆未停到位", e.carno);
  570. //return;
  571. iCountPark = 0; //2021年7月27日5s播一次,然后重新在播
  572. }
  573. }
  574. else
  575. {
  576. iCountPark = 0;
  577. }
  578. }
  579. }
  580. if (!lu[0].bcEnable)
  581. {
  582. foreach (ucBusinessType uc in lu)
  583. {
  584. uc.setControlEnable(true);
  585. }
  586. }
  587. if (sweepCodeClass.StrCode == "" && !codeFlag)
  588. {
  589. PbCache.collect.carno = sCarNo;
  590. }
  591. }
  592. //写入LED信息
  593. if (PbCache.sportInfo != null && PbCache.ledInfo != PbCache.OldLedInfo)
  594. {
  595. PbCache.OldLedInfo = PbCache.ledInfo;
  596. if (PbCache.monitor != null && PbCache.monitor.ledKeep == "0")
  597. {
  598. //led_controler.setOneLineMsg(PbCache.sportInfo.ledIp, PbCache.ledInfo);
  599. }
  600. }
  601. }
  602. else
  603. {
  604. if (e.weight > 10 && e.weight < 500)
  605. {
  606. //重量小于500,大于10
  607. MeterWorkMonitor mwUpdate = new MeterWorkMonitor();
  608. mwUpdate.pointNo = PbCache.sportInfo.baseSpotNo;
  609. mwUpdate.wgt = e.weight;
  610. RESTfulResult<string> rms = meterWorkMonitor.doUpdateWf(mwUpdate);
  611. }
  612. if (e.weight > 0 && e.weight < 200)
  613. {
  614. doOperateLive();
  615. }
  616. if (e.weight == 0)
  617. {
  618. PbCache.isZeroAlarm = false;
  619. }
  620. isOpened = false; //下次上秤直接打开主界面
  621. editCarNo = "";
  622. firstCode = ""; //历史的扫码枪的值
  623. preCarNo = "";
  624. sCarNo = "";
  625. sPreNo = "";
  626. preWgt = 0;
  627. PbCache.isOvertimeAlarm = false; //是否超时报警
  628. PbCache.strCode = "";
  629. PbCache.ResultMessage = "";
  630. bEditCar = false;
  631. isVoiceDownCar = false;
  632. flagCarMonit = false;
  633. iHodeTime = 0;
  634. isOpenMeter = false;
  635. PbCache.isLockFrm = false;
  636. PbCache.dtStartTime = null;
  637. PbCache.voiceOver = true;
  638. if (PbCache.collect != null && !string.IsNullOrEmpty(PbCache.collect.carno))
  639. {
  640. PbCache.collect.carno = "";
  641. }
  642. setWelecomeVis(true);
  643. if (lu[0].bcEnable)
  644. {
  645. foreach (ucBusinessType uc in lu)
  646. {
  647. uc.setControlEnable(false);
  648. }
  649. }
  650. //LED写入
  651. if (isLedWrite)
  652. {
  653. if (PbCache.monitor == null || string.IsNullOrEmpty(PbCache.monitor.ledWriter))
  654. {
  655. PbCache.ledInfo = "欢迎使用九钢汽车衡智能计量系统";
  656. }
  657. else
  658. {
  659. PbCache.ledInfo = PbCache.monitor == null ? "" : PbCache.monitor.ledWriter;
  660. }
  661. //led_controler.setOneLineMsg(PbCache.sportInfo.ledIp, PbCache.ledInfo);
  662. isLedWrite = false;
  663. //*
  664. //另外初始化一次监控数据
  665. RESTfulResult<string> rms = meterWorkMonitor.doUpdateWf(new MeterWorkMonitor
  666. {
  667. pointNo = PbCache.sportInfo.baseSpotNo,
  668. validWgt = "1",
  669. validCarno = "1",
  670. validTareTime = "1",
  671. validMatTime = "1",
  672. validTimeInterval = "1",
  673. validParkStatus = "1",
  674. validExceedWgt = "1",
  675. validPredictionDiff = "1",
  676. validLianda = "1",
  677. validMatClick = "1",
  678. setCar = "",
  679. rfidCar = "",
  680. photoCar = "",
  681. scanCar = "",
  682. editCar = "",
  683. carErr = "0",
  684. wgtErr = "0",
  685. stopOverTime = "0",
  686. msgInfo = "",
  687. ledWriter = "",
  688. isOverWgt = "",
  689. isHelp = "0",
  690. wgt = 0
  691. });
  692. if (!rms.Succeed)
  693. {
  694. l.WriteLog(0, "frmMain.EventData异常754:写入信息异常");
  695. isLedWrite = true;
  696. }
  697. //*/
  698. }
  699. }
  700. #endregion
  701. }
  702. catch (Exception ex)
  703. {
  704. l.WriteLog(0, "frmMain.EventData异常:" + ex.Message);
  705. }
  706. }
  707. private delegate void ShowBtnTare(bool flag);//定义委托 期限皮重按钮
  708. /// <summary>
  709. /// 操作Live表的数据:零点报警
  710. /// </summary>
  711. private void doOperateLive () {
  712. if (PbCache.collect_no==null)
  713. {
  714. return;
  715. }
  716. List<LiveData> ll = MemoClass.getWarnInfo(PbCache.collect_no);
  717. if (ll != null)
  718. {
  719. foreach (LiveData lv in ll)
  720. {
  721. switch (lv.Tagname.Replace(PbCache.collect_no, ""))
  722. {
  723. case "StaticStatus"://车辆检测 "0、东西方向激光均无报警;否则报警
  724. break;
  725. case "SwitchLight"://PLC红绿灯控制模式状态 "PLC有三种控制模式:1、自动、2、远控;3、检修
  726. break;
  727. case "LightWest"://红绿灯:1、为绿灯;2、为红灯;"
  728. break;
  729. case "ZeroWeightStatus": //0、其它,1、零点报警,红绿灯变红,
  730. if (((lv.Value ?? "0") + "").Equals("1"))
  731. {
  732. doInsertZeroAlarm();
  733. PbCache.isZeroAlarm = true;
  734. }
  735. else {
  736. PbCache.isZeroAlarm = false;
  737. }
  738. break;
  739. }
  740. }
  741. }
  742. }
  743. /// <summary>
  744. /// 新增零点报警的数据
  745. /// </summary>
  746. private void doInsertZeroAlarm()
  747. {
  748. if (!PbCache.isZeroAlarm)
  749. {
  750. PbCache.isZeroAlarm = true;
  751. MeterWorkZeroAlarm workZeroAlarm = new MeterWorkZeroAlarm();
  752. workZeroAlarm.zeroWeight = PbCache.collect.weight;
  753. workZeroAlarm.spotTypeNo = PbCache.sportInfo.spotTypeNo;
  754. workZeroAlarm.spotTypeName = PbCache.sportInfo.spotTypeName;
  755. workZeroAlarm.baseSpotNo = PbCache.sportInfo.baseSpotNo;
  756. workZeroAlarm.baseSpotName = PbCache.sportInfo.baseSpotName;
  757. workZeroAlarm.scalePointNo = PbCache.collect_no;
  758. workZeroAlarm.createManNo = PbCache.sportInfo.baseSpotNo;
  759. workZeroAlarm.createManName = PbCache.sportInfo.baseSpotName;
  760. RESTfulResult<String> rms = zeroAlarmService.doInsertZeroAlarm(workZeroAlarm);
  761. if (rms.Succeed)
  762. {
  763. l.WriteLog(20, "新增成功:" + workZeroAlarm.baseSpotName +":"+ workZeroAlarm.zeroWeight);
  764. }
  765. else
  766. {
  767. l.WriteLog(20, "操作失败:" + workZeroAlarm.baseSpotName + ":" + workZeroAlarm.zeroWeight + rms.Data + rms.Message);
  768. }
  769. }
  770. }
  771. /// <summary>
  772. /// 关闭程序
  773. /// </summary>
  774. /// <param name="sender"></param>
  775. /// <param name="e"></param>
  776. private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
  777. {
  778. collection.Stop();
  779. imageCurlControl.Stop();
  780. sweepCodeClass.CloseThread();
  781. timer1.Stop();
  782. timer1.Dispose();
  783. }
  784. }
  785. }