frmMain.cs 35 KB

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