Form1.cs 66 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490
  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;
  11. using System.Collections.Generic;
  12. using System.Data;
  13. using System.Diagnostics;
  14. using System.Drawing;
  15. using System.IO;
  16. using System.Linq;
  17. using System.Windows.Forms;
  18. using SystemOffLine;
  19. namespace CarMeterSystem
  20. {
  21. public partial class Form1 : Form
  22. {
  23. public Form1()
  24. {
  25. InitializeComponent();
  26. }
  27. private Log l = Log.GetInstance();
  28. private Print printClass = new Print();//打印
  29. //内存表
  30. private MemoryTableDataSocket MemoClass = new MemoryTableDataSocket("");
  31. //实时表数据采集
  32. private DataCollectionControl collection = new DataCollectionControl();
  33. //图片控制器含图片压缩及上传curl
  34. private ImageCurlControl imageCurlControl = new ImageCurlControl();
  35. //与监控界面对接的表
  36. private MeterWorkMonitorService meterWorkMonitor = new MeterWorkMonitorService();
  37. //零点报警表
  38. private meterworkzeroalarmservice zeroAlarmService = new meterworkzeroalarmservice();
  39. //车号修正
  40. private CarNoModfiy modfiy = new CarNoModfiy();
  41. //验证对射
  42. private validParkStatus valid = new validParkStatus();
  43. //语音播报
  44. private VoicePlay vicPlayClass = new VoicePlay();
  45. private LED_Control led_controler = null;
  46. //验证校秤数据
  47. private validCalibration vCalib = new validCalibration();
  48. private MeterWorkCarActualFirstService workCarActualFirstService = new MeterWorkCarActualFirstService(); //一次计量数据
  49. //查询当前是否校秤
  50. private bool bRelation = true;
  51. /// <summary>
  52. /// 欢迎界面
  53. /// </summary>
  54. private frmWelcome_Jisco frmWelcome = new frmWelcome_Jisco();//欢迎
  55. /// <summary>
  56. /// 计量页
  57. /// </summary>
  58. private frmOneYardToEnd fcc = null;
  59. /// <summary>
  60. /// 基础数据载入
  61. /// </summary>
  62. private BaseDbCls bd = new BaseDbCls();
  63. //扫码修正车号标识
  64. private bool codeFlag = false;
  65. private List<ucBusinessType> lu = new List<ucBusinessType>();
  66. private bool isVoiceDownCar = false;//车上人员请下车播放一次
  67. private bool isShowFrmWelcome = false; //是否显示欢迎界面;在这个测试界面,不显示欢迎界面
  68. private bool isOpened = false;//是否已经打开了扫码计量界面
  69. private SerialPortES sweepCodeClass = new SerialPortES();
  70. private SerialPortES sweepCodeClass2 = new SerialPortES();
  71. frmOneYardToEnd frmOneYardToEnd = new frmOneYardToEnd();
  72. private void Form1_Load(object sender, EventArgs e)
  73. {
  74. //*
  75. try
  76. {
  77. //CollectModel temp = new CollectModel();
  78. //temp.weight = 501;
  79. //PbCache.collect = temp;
  80. //frmMatMsgInfo frmMatMsgInfo = new frmMatMsgInfo();
  81. //frmMatMsgInfo.Show();
  82. timer1.Start();
  83. //2021年6月21日 杨秀东添加
  84. if (isShowFrmWelcome)
  85. {
  86. frmWelcome.Show();
  87. frmWelcome.Visible = true;
  88. }
  89. LoginCls lg = new LoginCls();
  90. if (lg.LoginIn())
  91. {
  92. //if (SystemUpdate(false))
  93. //{
  94. // return;
  95. //}
  96. // 加载并验证基本配置
  97. if (bd.setBaseDb() && bd.getBaseDb())
  98. {
  99. if (!string.IsNullOrEmpty(PbCache.sportInfo.ledIp))
  100. {
  101. led_controler = new LED_Control(PbCache.sportInfo.ledIp);
  102. }
  103. //调用该方法时已赋值
  104. RESTfulResult<List<MeterWorkMonitor>> rm = meterWorkMonitor.doQueryOneWf(new MeterWorkMonitor { validFlag = "1", pointNo = PbCache.sportInfo.baseSpotNo });
  105. if (!rm.Succeed)
  106. {
  107. l.WriteLog(1, "载入监控表数据异常");
  108. return;
  109. }
  110. else if (rm.Data != null && rm.Data.Count > 0)
  111. {
  112. if (string.IsNullOrEmpty(PbCache.collect_no))
  113. {
  114. PbCache.collect_no = rm.Data[0].collectionCode;
  115. MemoClass = new MemoryTableDataSocket(PbCache.collect_no);
  116. }
  117. }
  118. else
  119. {
  120. //l.WriteLog(1, "为配置监控数据");
  121. //return;
  122. }
  123. //若未校秤的话,也不允许计量
  124. //载入界面业务按钮
  125. if (PbCache.businessType != null && PbCache.businessType.Count > 0)
  126. {
  127. foreach (ComBaseInfo info in PbCache.businessType)
  128. {
  129. ucBusinessType uc = new ucBusinessType();
  130. switch (info.baseCode)
  131. {
  132. case "001006003":
  133. uc.setControl(info.baseName, info.memo, info.baseCode);
  134. break;
  135. case "001006001":
  136. case "001006002":
  137. uc.setControl(info.baseName, info.memo, info.baseCode);
  138. break;
  139. default:
  140. uc.setControl(info.baseName, info.memo, info.baseCode);
  141. break;
  142. }
  143. uc.Dock = DockStyle.Top;
  144. //uc.setControl("","","",);
  145. uc.ucEvent += new EventHandler(ucEvents);
  146. lu.Add(uc);
  147. panel7.Controls.Add(uc);
  148. }
  149. }
  150. //开启基础进程
  151. l.WriteLog(0, "系统登录成功");
  152. collection.EventDataCollectionArgs += new EventDataCollection(EventData);//数据采集
  153. collection.Start(PbCache.sportInfo.baseSpotNo, PbCache.sportInfo.baseSpotName);
  154. imageCurlControl.Start(); //图片采集线程
  155. //新扫码线程
  156. if (AppConfigCache._comPara?.Split(new char[] { ',' })?.Length == 5)
  157. {
  158. sweepCodeClass.StartThreadSweep(AppConfigCache._comPara); //扫码线程
  159. }
  160. if (AppConfigCache._comPara2?.Split(new char[] { ',' })?.Length == 5)
  161. {
  162. sweepCodeClass2.StartThreadSweep(AppConfigCache._comPara2); //扫码线程
  163. }
  164. // 计量页
  165. fcc = new frmOneYardToEnd();
  166. }
  167. else
  168. {
  169. l.WriteLog(0, "系统登录失败");
  170. }
  171. }
  172. else
  173. {
  174. l.WriteLog(0, "按IP地址找不到计量点信息,系统登录失败");
  175. }
  176. }
  177. catch (Exception ex)
  178. {
  179. l.WriteLog(0, "系统加载失败:" + ex.Message);
  180. }
  181. //*/
  182. }
  183. #region
  184. //*
  185. public void ucEvents(object sender, EventArgs e)
  186. {
  187. Control control = (Control)sender;
  188. ucBusinessType um = control.Parent.Parent as ucBusinessType;
  189. try
  190. {
  191. switch (control.Name)
  192. {
  193. case "btnContext":
  194. case "btnPurchase":
  195. {
  196. PbCache.bussinessTypeName = um._bussiness == null ? "" : um._bussiness;
  197. PbCache.bussinessTypeCode = um._code;
  198. switch (um._code)
  199. {
  200. case "001006003":
  201. frmInternalTransport frm = new frmInternalTransport();
  202. frm.isTest = true;
  203. frm.ShowDialog();
  204. break;
  205. /*
  206. case "001006001":
  207. case "001006002":
  208. frmCarSalePurchase frmCar = new frmCarSalePurchase();
  209. frmCar.ShowDialog();
  210. break;
  211. //*/
  212. default:
  213. frmCarSalePurchase frmCar = new frmCarSalePurchase();
  214. frmCar.isTest = true;
  215. frmCar.ShowDialog();
  216. break;
  217. }
  218. };
  219. break;
  220. default: break;
  221. }
  222. }
  223. catch (Exception ex)
  224. {
  225. MessageBox.Show("操作异常:" + ex.Message);
  226. }
  227. }
  228. //*/
  229. #endregion
  230. #region
  231. private void setWelecomeVis(bool visb)
  232. {
  233. /*
  234. if (frmWelcome.InvokeRequired)
  235. {
  236. Action<bool> action = new Action<bool>(setWelecomeVis);
  237. Invoke(action, new object[] { visb });
  238. }
  239. else
  240. {
  241. if (frmWelcome.Visible != visb)
  242. {
  243. frmWelcome.Visible = visb;
  244. frmWelcome.setLogin();
  245. }
  246. }
  247. //*/
  248. }
  249. #endregion
  250. private int iCount = 0, iHodeTime = 0;
  251. private bool flagCarMonit = false;//车号修正
  252. private bool isOpenMeter = false; //是否已打开计量界面,若已经打开则这里关于超量程及红外的语音将停止播报
  253. private string firstCode = "";//上次扫码的信息
  254. private string ledTxt = "";
  255. private bool isLedWrite = true;//是否写入一次LED
  256. private string sCarNo = "";
  257. private string editCarNo = "";
  258. private string preCarNo = "";
  259. public bool sss = false;
  260. MeterWorkCarActualFirstService mwcfs = new MeterWorkCarActualFirstService();
  261. RESTfulResult<string> rmsSweepCodeClass = new RESTfulResult<string>();
  262. /// <summary>
  263. /// 数据采集
  264. /// </summary>
  265. /// <param name="o"></param>
  266. /// <param name="e"></param>
  267. private void EventData(object o, DataCollectionArgs e)
  268. {
  269. //这里每隔0.5秒执行一次
  270. try
  271. {
  272. #region
  273. /*
  274. if (e.licType == PbCache.collect.licType)
  275. {
  276. iCollection++;
  277. if (iCollection > 59 && iCollection % 20 == 0) //若连续30秒采集不到数据则提示中断,并每隔10秒播放一次
  278. {
  279. //采集线程中断
  280. vicPlayClass.GetVoicePlay("实时库采集中断", "");
  281. sweepCodeClass.StrState = "";
  282. }
  283. }
  284. else
  285. {
  286. sweepCodeClass.StrState = e.weightStatus + "";
  287. iCollection = 0;
  288. }
  289. //*/
  290. #endregion
  291. #region 扫码信息
  292. if (!string.IsNullOrEmpty(sweepCodeClass2.StrCode))
  293. {
  294. Console.WriteLine("code:"+sweepCodeClass2.StrCode);
  295. }
  296. // 司机扫码为空,取工控机二维码
  297. if (string.IsNullOrEmpty(sweepCodeClass2.StrCode))
  298. {
  299. if (string.IsNullOrEmpty(sweepCodeClass.StrCode))
  300. {
  301. if (string.IsNullOrEmpty(PbCache.strCode))
  302. {
  303. codeFlag = false;
  304. firstCode = "";
  305. PbCache.strCode = "";
  306. l.WriteLog(12, "主线程扫码值为空时清空;sweepCodeClass.StrCode值为" + sweepCodeClass.StrCode + " ;PbCache.strCode值为:" + PbCache.strCode);
  307. }
  308. }
  309. else
  310. {
  311. DecodeQRCode(sweepCodeClass.StrCode);
  312. }
  313. }
  314. else
  315. {
  316. DecodeQRCode(sweepCodeClass2.StrCode);
  317. }
  318. #endregion
  319. #region 秤上无车10分钟获取一次基础数据
  320. if (iCount < 1200)
  321. {
  322. iCount++;
  323. }
  324. else
  325. {
  326. iCount = 0;
  327. try
  328. {
  329. //秤上没有车时,每隔10分钟获取一次基础数据
  330. if (e.weight < 500)
  331. {
  332. editCarNo = "";
  333. preCarNo = "";
  334. if (bd.setBaseDb())
  335. {
  336. l.WriteLog(0, "十分钟获取基础数据成功");
  337. }
  338. else
  339. {
  340. l.WriteLog(0, "十分钟获取基础数据失败");
  341. }
  342. }
  343. }
  344. catch (Exception ex)
  345. {
  346. l.WriteLog(0, "十分钟获取基础数据失败:" + ex.Message);
  347. }
  348. }
  349. #endregion
  350. #region 每10秒写入一次当前时间
  351. if (iCount % 20 == 0)
  352. {
  353. RESTfulResult<string> rms = meterWorkMonitor.doUpdateWfBySpotNo(new MeterWorkMonitor { pointNo = PbCache.sportInfo.baseSpotNo });
  354. if (!rms.Succeed)
  355. {
  356. l.WriteLog(0, "frmMain.EventData异常:写入时间异常");
  357. }
  358. }
  359. #endregion
  360. #region
  361. //一旦界面锁定则不采集数据
  362. //if (!PbCache.isLockFrm)
  363. //{
  364. PbCache.collect.pointid = PbCache.sportInfo.baseSpotNo;
  365. PbCache.collect.parkStatus = e.parkStatus;
  366. PbCache.collect.datetime = e.datetime;
  367. PbCache.collect.licType = e.licType;
  368. if (testFlag)
  369. {
  370. sCarNo = testCarNo;
  371. //PbCache.collect.carno = testCarNo;
  372. if (!sss)
  373. {
  374. PbCache.collect.weight = testWgt;
  375. }
  376. PbCache.collect.weightStatus = 0;
  377. PbCache.monitorResult.valid_park_status = true;
  378. PbCache.collect.parkStatus = 0;
  379. if (PbCache.collect.weight > e.weight)
  380. e.weight = PbCache.collect.weight;
  381. PbCache.strCode = testPlanNo;
  382. e.carno = testCarNo;
  383. sss = true;
  384. //PbCache.strQRCode = testCode;
  385. }
  386. else
  387. {
  388. PbCache.collect.weight = e.weight;
  389. PbCache.collect.weightStatus = e.weightStatus;
  390. }
  391. if (!flagCarMonit)
  392. {
  393. sCarNo = e.carno;
  394. //PbCache.collect.carno = e.carno;
  395. }
  396. #if DEBUG
  397. #endif
  398. #region 摄像头当前采集的车号与上次采集的不一样且当前未勾选不验证的情况
  399. if (preCarNo != e.carno && PbCache.monitor != null && PbCache.monitor.validCarno != "0")
  400. {
  401. flagCarMonit = false;
  402. }
  403. preCarNo = e.carno;
  404. #endregion
  405. //*
  406. //有车号,且重量稳定的情况下,只修正一次车号
  407. if (!string.IsNullOrEmpty(e.carno) && e.weightStatus == 0 && !flagCarMonit && PbCache.monitor != null && PbCache.monitor.carMonitor == "1" && PbCache.monitor.carMonitorLvl > 0)
  408. {
  409. flagCarMonit = true;
  410. string methods = "";
  411. for (int i = 0; i <= PbCache.monitor.carMonitorLvl; i++)
  412. {
  413. methods += "CarNoTrustCorrect" + i + ",";
  414. }
  415. editCarNo = modfiy.CarNoCorrect(e.carno, methods.Substring(0, methods.Length - 1));
  416. sCarNo = editCarNo;
  417. }
  418. //勾选了不验证车号的情况
  419. if (PbCache.monitor.validCarno == "0")
  420. {
  421. flagCarMonit = true;
  422. }
  423. // 更新监控表
  424. doLive();
  425. //}
  426. //*/
  427. //重量大于500的情况下
  428. if (e.weight > 500)
  429. {
  430. if (PbCache.dtStartTime == null)
  431. PbCache.dtStartTime = DateTime.Now;
  432. isLedWrite = true;
  433. PbCache.strState = "0";
  434. #region 查一次是否校秤,若未校秤则不能计量
  435. /*
  436. if (bRelation)
  437. {
  438. string msgInfo = "";
  439. isCalibration = vCalib.ValidMethod(new MeterWorkCalibrationMain { baseSpotNo = PbCache.sportInfo.baseSpotNo, valueFlag = "2" }, out msgInfo);
  440. if (!isCalibration)
  441. {
  442. foreach (ucBusinessType uc in lu)
  443. {
  444. uc.setControlEnable(false);
  445. }
  446. ledTxt = msgInfo;
  447. l.WriteLog(1, msgInfo);
  448. }
  449. bRelation = false;
  450. }
  451. if (!isCalibration)
  452. {
  453. vicPlayClass.GetVoicePlay("未校秤", "");
  454. Thread.Sleep(2000);
  455. return;
  456. }
  457. //*/
  458. #endregion
  459. #region 车上人员请下车
  460. try
  461. {
  462. //界面未锁定的情况下,有车号,如果重量稳定了,停车线验证通过,未超量程的情况下,则按钮可用
  463. if (!string.IsNullOrEmpty(PbCache.collect.carno) && PbCache.collect.weightStatus == 0 && PbCache.monitorResult.valid_park_status && PbCache.collect.weight < PbCache.range.upperRange)
  464. {
  465. if (!isVoiceDownCar)
  466. {
  467. isVoiceDownCar = true;
  468. vicPlayClass.GetVoicePlay("车上人员请下车", PbCache.collect.carno);
  469. }
  470. }
  471. }
  472. catch { }
  473. #endregion
  474. setWelecomeVis(false);
  475. //每隔1秒刷一次计量实时监控表数据值
  476. if (iCount % 2 == 0)
  477. {
  478. #region 停留超时
  479. iHodeTime++;
  480. MeterWorkMonitor mwUpdate = new MeterWorkMonitor();
  481. mwUpdate.pointNo = PbCache.sportInfo.baseSpotNo;
  482. if (PbCache.holdTime != null && PbCache.holdTime.Count > 0)
  483. {
  484. if (PbCache.holdTime[0].retentionTime != null)
  485. {
  486. if (PbCache.holdTime[0].retentionTime.Value < iHodeTime)
  487. {
  488. PbCache.isOvertimeAlarm = true; //是否超时报警
  489. mwUpdate.stopOverTime = "1"; //写入一次停留超时
  490. //mwUpdate.isHelp = "1";//派位
  491. //mwUpdate.isTakeOver = "1";
  492. iHodeTime = 99999;//不再增长避免超出
  493. }
  494. }
  495. }
  496. #endregion
  497. #region 车号信息
  498. mwUpdate.rfidCar = "";
  499. mwUpdate.photoCar = e.vdioCarNos;
  500. if (testFlag)
  501. {
  502. mwUpdate.photoCar = PbCache.collect.carno;
  503. }
  504. //e.RfidNos = "0003";
  505. if (!string.IsNullOrEmpty(e.RfidNos))
  506. {
  507. string sqls = @"SELECT RFID_ID id,CAR_NO text FROM METER_BASE_RFID_INFO where RFID_CODE = '" + e.RfidNos + "' and valueFlag = '0'";
  508. PbModelDbService<List<PbModelDb>> pbp = new PbModelDbService<List<PbModelDb>>();
  509. RESTfulResult<List<PbModelDb>> rmT = pbp.executeSqlDataWf(sqls);
  510. if (rmT.Data == null || rmT.Data.Count == 0)
  511. {}
  512. else
  513. {
  514. mwUpdate.rfidCar = rmT.Data[0].text;
  515. sCarNo = rmT.Data[0].text;
  516. }
  517. }
  518. if (PbCache.monitor != null && !string.IsNullOrEmpty(PbCache.monitor.setCar))
  519. {
  520. //未锁定的情况下,若监控界面设置了车号,则车号将改为设定车号
  521. sCarNo = PbCache.monitor.setCar;
  522. codeFlag = false;
  523. sweepCodeClass.StrCode = "";
  524. sweepCodeClass2.StrCode = "";
  525. }
  526. #endregion
  527. #region 重量信息
  528. if (!PbCache.isLockFrm)
  529. {
  530. mwUpdate.wgt = e.weight;
  531. }
  532. else
  533. {
  534. mwUpdate.wgt = Convert.ToInt32(PbCache.lockWgt);
  535. }
  536. #endregion
  537. #region 写入一次监控表,将重量/车号停留超时等信息写入
  538. mwUpdate.weightStatus = PbCache.collect.weightStatus;
  539. mwUpdate.msgInfo = PbCache.ResultMessage;
  540. if (codeFlag)
  541. {
  542. mwUpdate.scanCar = PbCache.collect.carno;
  543. }
  544. //另外初始化一次监控数据
  545. RESTfulResult<string> rms = meterWorkMonitor.doUpdateWf(mwUpdate);
  546. if (!rms.Succeed)
  547. {
  548. l.WriteLog(0, "frmMain.EventData异常doUpdateWf:写入信息异常");
  549. }
  550. #endregion
  551. //调用该方法时已赋值
  552. RESTfulResult<List<MeterWorkMonitor>> rm = meterWorkMonitor.doQueryOneWf(new MeterWorkMonitor { validFlag = "1", pointNo = PbCache.sportInfo.baseSpotNo });
  553. if (!rm.Succeed)
  554. {
  555. l.WriteLog(0, "frmMain.EventData异常doQueryWf:" + rm.ResultMessage);
  556. }
  557. else
  558. {
  559. if (rm.Data != null && rm.Data.Count > 0)
  560. {
  561. PbCache.monitor = rm.Data[0];
  562. if (string.IsNullOrEmpty(PbCache.collect_no))
  563. {
  564. PbCache.collect_no = rm.Data[0].collectionCode;
  565. }
  566. if (ledTxt != rm.Data[0].ledWriter && rm.Data[0].ledWriter != "")
  567. {
  568. //调用LED信息写入******************************
  569. ledTxt = rm.Data[0].ledWriter;
  570. }
  571. if (string.IsNullOrEmpty(ledTxt))
  572. {
  573. ledTxt = "车号甘A12345,重量98.76吨,计量完成";
  574. }
  575. }
  576. }
  577. //验证对射
  578. valid.ValidMethod();
  579. if (!isOpenMeter)
  580. {
  581. //if (PbCache.range != null && PbCache.range.upperRange < e.weight)
  582. if (PbCache.range != null && PbCache.range.upperRange < e.weight)
  583. {
  584. //超量程
  585. vicPlayClass.GetVoicePlay("已超量程", e.carno);
  586. //return;
  587. }
  588. else if (e.weightStatus == 0 && !PbCache.monitorResult.valid_park_status)
  589. {
  590. //重量稳定,且对射验证不合格
  591. vicPlayClass.GetVoicePlay("您的车辆未停到位", e.carno);
  592. //return;
  593. }
  594. }
  595. if (!lu[0].bcEnable)
  596. {
  597. foreach (ucBusinessType uc in lu)
  598. {
  599. uc.setControlEnable(true);
  600. }
  601. }
  602. if ((sweepCodeClass.StrCode == "" || sweepCodeClass2.StrCode == "") && !codeFlag)
  603. {
  604. PbCache.collect.carno = sCarNo;
  605. }
  606. }
  607. ////写入LED信息
  608. //if (PbCache.sportInfo != null && PbCache.ledInfo != PbCache.OldLedInfo)
  609. //{
  610. // PbCache.OldLedInfo = PbCache.ledInfo;
  611. // if (PbCache.monitor != null && PbCache.monitor.ledKeep == "0")
  612. // {
  613. // //led_controler.setOneLineMsg(PbCache.sportInfo.ledIp, PbCache.ledInfo);
  614. // }
  615. //}
  616. }
  617. else
  618. {
  619. if (e.weight > 0 && e.weight < 200)
  620. {
  621. doOperateLive();
  622. }
  623. if (e.weight==0)
  624. {
  625. PbCache.isZeroAlarm = false;
  626. }
  627. //======测试 的时候注释,正式用的时候启用下面这行代码***************************************************************
  628. //PbCache.ResultMessage = "";
  629. PbCache.isOvertimeAlarm = false;
  630. isOpened = false;
  631. isVoiceDownCar = false;
  632. flagCarMonit = false;
  633. iHodeTime = 0;
  634. sCarNo = "";
  635. if (!testFlag)
  636. {
  637. bRelation = true;
  638. PbCache.isLockFrm = false;
  639. PbCache.dtStartTime = null;
  640. PbCache.voiceOver = true;
  641. setWelecomeVis(true);
  642. if (lu[0].bcEnable)
  643. {
  644. foreach (ucBusinessType uc in lu)
  645. {
  646. uc.setControlEnable(false);
  647. }
  648. }
  649. //LED写入
  650. if (isLedWrite)
  651. {
  652. //if (PbCache.monitor == null || string.IsNullOrEmpty(PbCache.monitor.ledWriter))
  653. //{
  654. // PbCache.ledInfo = "车号甘A12345\n\r重量98.76吨\n\r之前存在一个未结净的毛重\n\r请联系";
  655. //}
  656. //else
  657. //{
  658. // PbCache.ledInfo = PbCache.monitor == null ? "" : PbCache.monitor.ledWriter;
  659. //}
  660. //led_controler.setStaticLineMsg(PbCache.sportInfo.ledIp, PbCache.ledInfo);
  661. //led_controler.setStatic4LineMsg(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. ferroalloyResult = "0",
  686. stopOverTime = "0",
  687. msgInfo = "",
  688. ledWriter = "",
  689. isOverWgt = "",
  690. isHelp = "0",
  691. wgt = 0
  692. });
  693. if (!rms.Succeed)
  694. {
  695. l.WriteLog(0, "frmMain.EventData异常:写入信息异常");
  696. isLedWrite = true;
  697. }
  698. //*/
  699. }
  700. //*
  701. }
  702. else
  703. {
  704. if (!lu[0].bcEnable)
  705. {
  706. foreach (ucBusinessType uc in lu)
  707. {
  708. uc.setControlEnable(true);
  709. }
  710. }
  711. }
  712. //*/
  713. }
  714. #endregion
  715. }
  716. catch (Exception ex)
  717. {
  718. l.WriteLog(0, "frmMain.EventData异常:" + ex.Message);
  719. }
  720. }
  721. private void DecodeQRCode(string strCode)
  722. {
  723. codeFlag = true;
  724. //frmOneYardToEnd frmOneYardToEnd = new frmOneYardToEnd();
  725. Hashtable hashTable = new Hashtable();
  726. hashTable.Add("message", strCode);
  727. rmsSweepCodeClass = mwcfs.DecryptionForWfTest(hashTable);
  728. if (rmsSweepCodeClass.Code == "0")
  729. {
  730. PbCache.collect.carno = rmsSweepCodeClass.Data;
  731. PbCache.strCode = rmsSweepCodeClass.Data;
  732. }
  733. if (rmsSweepCodeClass.Code == "1")
  734. {
  735. vicPlayClass.GetVoicePlay("车号二维码已过期", PbCache.collect.carno);
  736. frmOneYardToEnd.setMsgInfo("车号二维码已过期");
  737. }
  738. if (rmsSweepCodeClass.Code == "2")
  739. {
  740. vicPlayClass.GetVoicePlay("不是有效车号二维码", PbCache.collect.carno);
  741. frmOneYardToEnd.setMsgInfo("不是有效车号二维码");
  742. }
  743. if (rmsSweepCodeClass.Code == "9")
  744. {
  745. vicPlayClass.GetVoicePlay("不是有效车号二维码", PbCache.collect.carno);
  746. frmOneYardToEnd.setMsgInfo("不是有效车号二维码");
  747. }
  748. l.WriteLog(12, "测试扫码值" + rmsSweepCodeClass.Data);
  749. }
  750. private delegate void ShowBtnTare(bool flag);//定义委托 期限皮重按钮
  751. private int testWgt = 1000;
  752. private string testCarNo = "", testPlanNo = "";
  753. private bool testFlag = false;
  754. /// <summary>
  755. /// 截图测试
  756. /// </summary>
  757. /// <param name="sender"></param>
  758. /// <param name="e"></param>
  759. private void button2_Click(object sender, EventArgs e)
  760. {
  761. CameraShotCls cameraShot = new CameraShotCls();
  762. //cameraShot.CapMethod("1");
  763. _ = Invoke(new Action(() => { cameraShot.CapMethod("15"); }));
  764. }
  765. //测试打印
  766. private string strFirstNo = "";
  767. private void btnTestPrint_Click(object sender, EventArgs e)
  768. {
  769. Print1(txtPlanNo.Text);
  770. }
  771. //弹窗
  772. private static FrmMessage FrmMess(string strMess, string strBtnSaveInfo)
  773. {
  774. FrmMessage frmMessage = new FrmMessage();
  775. frmMessage.StartPosition = FormStartPosition.Manual;
  776. frmMessage.Location = new Point(350, 450);
  777. frmMessage.ShowMessage = strMess;
  778. frmMessage.BtnSaveText = strBtnSaveInfo;
  779. frmMessage.BtnCancelText = "取消";
  780. return frmMessage;
  781. }
  782. private class PrintCls
  783. {
  784. public int printNum { get; set; }
  785. public MeterWorkCarActual printDb { get; set; }
  786. public int iType { get; set; } //0毛 1 皮 2净
  787. public string qrCode { get; set; }
  788. }
  789. private PrintCls printData = new PrintCls();
  790. private void Print1(string firstNo)
  791. {
  792. try
  793. {
  794. //lg.WriteLog(1, "打印开始");
  795. #region 获取打印信息,若需要打印则调用打印操作
  796. List<PrintCls> prrintC = new List<PrintCls>();
  797. string sql = @"select actual_no actualNo,
  798. prediction_no predictionNo,
  799. car_no carNo,
  800. matter_no matterNo,
  801. matter_name matterName,
  802. gross_weight grossWeight,
  803. gross_time grossTime,
  804. tare_weight tareWeight,
  805. tare_time tareTime,
  806. net_weight netWeight,
  807. net_Time netTime,
  808. 'x' meterTypeNo,
  809. meter_type_name meterTypeName,
  810. spec_name specName,
  811. forwarding_unit_name forwardingUnitName,
  812. receiving_uint_name receivingUintName,
  813. load_point_name loadPointName,
  814. add_weight addWeight,
  815. '1' uploadFlag --1结净数据 0一次表数据
  816. from meter_work_car_actual where actual_first1_no = '" + firstNo + @"' or actual_first2_no='" + firstNo + @"'
  817. union all
  818. select t.actual_first_no actualNo,
  819. t.prediction_no predictionNo,
  820. t.car_no carNo,
  821. t.matter_no matterNo,
  822. t.matter_name matterName,
  823. t.meter_weight grossWeight,
  824. t.create_time grossTime,
  825. 0 tareWeight,
  826. t.create_time tareTime,
  827. 0 netWeight,
  828. null netTime,
  829. t.weight_type meterTypeNo, --0毛重 否则皮重
  830. t.meter_type_name meterTypeName,
  831. t.spec_name specName,
  832. t.forwarding_unit_name forwardingUnitName,
  833. t.receiving_uint_name receivingUintName,
  834. t.load_point_name loadPointName,
  835. t.add_weight addWeight,
  836. '0' uploadFlag
  837. from METER_WORK_CAR_ACTUAL_FIRST t
  838. where t.actual_first_no = '" + firstNo + "' or t.actual_first_no = (select max(actual_first2_no) from meter_work_car_actual where actual_first1_no='" + firstNo + "')";
  839. //查下如果有毛重或者结净数据,则可进入打印判断
  840. PbModelDbService<List<MeterWorkCarActual>> pbModelDbService = new PbModelDbService<List<MeterWorkCarActual>>();
  841. RESTfulResult<List<MeterWorkCarActual>> rm = pbModelDbService.executeSqlDataWf(sql);
  842. //lg.WriteLog(1, "打印第一个sql:" + sql);
  843. if (rm.Succeed)
  844. {
  845. if (rm.Data != null && rm.Data.Count > 0)
  846. {
  847. //2021年6月26日 对一车联运的进行处理;用一次计量编号查二次计量数据,
  848. sql = @"select t3.actual_no actualNo, t3.prediction_no predictionNo, t3.car_no carNo, t3.matter_no matterNo, t3.matter_name matterName,
  849. t3.gross_weight grossWeight, t3.gross_time grossTime, t3.tare_weight tareWeight, t3.tare_time tareTime, t3.net_weight netWeight,
  850. t3.net_Time netTime, 'x' meterTypeNo, t3.meter_type_name meterTypeName, t3.spec_name specName,
  851. t3.forwarding_unit_name forwardingUnitName, t3.receiving_uint_name receivingUintName, t3.load_point_name loadPointName,
  852. t3.add_weight addWeight, '1' uploadFlag from meter_work_car_actual_first t2
  853. left join meter_work_car_actual t3 on t2.actual_first_no = t3.actual_first1_no
  854. where t2.prediction_combination in (select t.prediction_combination
  855. from meter_work_car_actual_first t
  856. where t3.value_flag = '0' and t.actual_first_no = '" + firstNo + @"' and
  857. instr(t.prediction_combination, '20') > 0) order by t3.net_time desc";
  858. RESTfulResult<List<MeterWorkCarActual>> rmLy = pbModelDbService.executeSqlDataWf(sql);
  859. if (rmLy.Succeed && rmLy.Data != null && rmLy.Data.Count == 1)
  860. {
  861. rm.Data = rmLy.Data; //一车联运,将毛重替换为净重数据
  862. }
  863. //若有毛重或者净重,找到对应数据的物料信息,若有,那么去找打印配置信息数据
  864. List<MeterWorkCarActual> mwa = rm.Data.Where(s => !string.IsNullOrEmpty(s.matterNo) && (s.meterTypeNo == "x" || s.meterTypeNo == "0")).ToList();
  865. if (mwa != null && mwa.Count > 0 && !string.IsNullOrEmpty(mwa[0].matterNo))
  866. {
  867. sql = @"select BASE_SPOT_NO baseSpotNo,
  868. load_point_no loadPointNo,
  869. matter_no matterNo,
  870. METER_TYPE_NO meterTypeNo,
  871. weight_type_name weightTypeName,
  872. PRINT_NUM printNum
  873. from METER_BASE_BILL_PRINT
  874. where matter_no = '" + mwa[0].matterNo + @"'
  875. and nvl(BASE_SPOT_NO, '" + PbCache.sportInfo.baseSpotNo + @"') = '" + PbCache.sportInfo.baseSpotNo + @"'
  876. and nvl(load_point_no, '" + (mwa[0].loadPointNo == null ? "1" : mwa[0].loadPointNo) + @"') = '" + (mwa[0].loadPointNo == null ? "1" : mwa[0].loadPointNo) + @"'";
  877. //lg.WriteLog(1, "打印第二个sql:" + sql); and nvl(METER_TYPE_NO, '" + PbCache.bussinessTypeCode + @"') = '" + PbCache.bussinessTypeCode + @"'
  878. //and nvl(METER_TYPE_NO, '') = ''
  879. PbModelDbService<List<MeterBaseBillPrint>> pbPrintService = new PbModelDbService<List<MeterBaseBillPrint>>();
  880. RESTfulResult<List<MeterBaseBillPrint>> rmPint = pbPrintService.executeSqlDataWf(sql);
  881. if (rmPint.Succeed)
  882. {
  883. if (rmPint.Data != null && rmPint.Data.Count > 0)
  884. {
  885. //若有净重信息:1毛重时间晚于皮重时间,则打印毛、皮、净重,2毛重早于皮重,打印皮、净
  886. //若只有毛重信息则打印毛重
  887. List<MeterBaseBillPrint> lGrossprint = rmPint.Data.Where(s => s.weightTypeName.Contains("毛")).ToList();
  888. List<MeterBaseBillPrint> lTarePrint = rmPint.Data.Where(s => s.weightTypeName.Contains("皮")).ToList();
  889. List<MeterBaseBillPrint> lNetprint = rmPint.Data.Where(s => s.weightTypeName.Contains("净")).ToList();
  890. List<MeterWorkCarActual> mwaChild = mwa.Where(s => s.meterTypeNo == "x").ToList();
  891. if (mwaChild != null && mwaChild.Count > 0) //若有净重信息
  892. {
  893. if (lTarePrint != null && lTarePrint.Count > 0)
  894. {
  895. //获取非毛,非净重信息如果没有则用的期限皮,此时不打,否则则打印
  896. MeterWorkCarActual mwca = rm.Data.Where(s => s.meterTypeNo != "x" && s.meterTypeNo != "0").FirstOrDefault();
  897. if (mwca != null)
  898. {
  899. PrintCls cls = new PrintCls();
  900. cls.printNum = (int)(lTarePrint[0].printNum == null ? 0 : lTarePrint[0].printNum.Value);
  901. cls.iType = 1;//皮重
  902. cls.printDb = mwca;
  903. prrintC.Add(cls);
  904. }
  905. }
  906. if (lGrossprint != null && lGrossprint.Count > 0)
  907. {
  908. //获取毛重信息
  909. MeterWorkCarActual mwca = rm.Data.Where(s => s.meterTypeNo == "0").FirstOrDefault();
  910. if (mwca != null)
  911. {
  912. PrintCls cls = new PrintCls();
  913. cls.printNum = (int)(lGrossprint[0].printNum == null ? 0 : lGrossprint[0].printNum.Value);
  914. cls.iType = 0;//毛重
  915. cls.printDb = mwca;
  916. prrintC.Add(cls);
  917. }
  918. }
  919. if (lNetprint != null && lNetprint.Count > 0)
  920. {
  921. //获取净重信息
  922. MeterWorkCarActual mwca = rm.Data.Where(s => s.meterTypeNo == "x").FirstOrDefault();
  923. if (mwca != null)
  924. {
  925. PrintCls cls = new PrintCls();
  926. cls.printNum = (int)(lNetprint[0].printNum == null ? 0 : lNetprint[0].printNum.Value);
  927. cls.iType = 2;//净重
  928. cls.printDb = mwca;
  929. prrintC.Add(cls);
  930. }
  931. }
  932. }
  933. else //只有毛重信息则打印毛重
  934. {
  935. if (lGrossprint != null && lGrossprint.Count > 0)
  936. {
  937. //获取毛重信息
  938. MeterWorkCarActual mwca = rm.Data.Where(s => s.meterTypeNo == "0").FirstOrDefault();
  939. if (mwca != null)
  940. {
  941. PrintCls cls = new PrintCls();
  942. cls.printNum = (int)(lGrossprint[0].printNum == null ? 0 : lGrossprint[0].printNum.Value);
  943. cls.iType = 0;//毛重
  944. cls.printDb = mwca;
  945. prrintC.Add(cls);
  946. }
  947. }
  948. }
  949. if (prrintC != null && prrintC.Count > 0)
  950. {
  951. FrmMessage frmMessage = FrmMess("是否打印第【1】张票据!", "打印");
  952. if (frmMessage.ShowDialog(this) == DialogResult.OK)
  953. {
  954. l.WriteLog(10, "车号【" + PbCache.lockCarNo + "】是否打印选择了【是】");
  955. l.WriteLog(15, PbCache.lockCarNo + "是否打印选择了【是】");
  956. strFirstNo = firstNo;
  957. //printDocument1.PrinterSettings.PrinterName = PbCache.sportInfo.printerName;//strPntSvrName;
  958. System.Drawing.Printing.PaperSize customSize1 = new System.Drawing.Printing.PaperSize("TestPaper", 398, 433); //101mm*110mm,换算成英寸
  959. printDocument1.DefaultPageSettings.PaperSize = customSize1;//将自定义的Papersize赋给PrintDocument
  960. System.Drawing.Printing.Margins marginss = new System.Drawing.Printing.Margins(0, 0, 0, 0);
  961. printDocument1.DefaultPageSettings.Margins = marginss;
  962. printDocument1.PrintController = new System.Drawing.Printing.StandardPrintController();
  963. foreach (PrintCls db in prrintC)
  964. {
  965. switch (db.printDb.meterTypeNo)
  966. {
  967. case "0": //毛
  968. db.qrCode = db.printDb.actualNo + "," + db.printDb.grossWeight + "," + "1";
  969. break;
  970. case "x": //净
  971. db.qrCode = db.printDb.actualNo + "," + db.printDb.netWeight + "," + "2";
  972. break;
  973. default: //皮
  974. db.qrCode = db.printDb.actualNo + "," + db.printDb.grossWeight + "," + "1";
  975. break;
  976. }
  977. RESTfulResult<string> rQRCode = workCarActualFirstService.doQRCodeWf(db.qrCode);
  978. db.qrCode = rQRCode.Data;
  979. for (int i = 0; i < db.printNum; i++)
  980. {
  981. if (i == 0)
  982. {
  983. printData = db;
  984. printDocument1.Print();
  985. l.WriteLog(10, "当前第" + (i + 1) + "次打印:" + printData.iType + " 车号:" + db.printDb.carNo + ",二维码:" + db.qrCode);
  986. }
  987. else
  988. {
  989. FrmMessage frmMessageContinue = FrmMess("已打印【" + i + "】张,是否继续打印第【" + (i + 1) + "】张票据!", "打印");
  990. if (frmMessageContinue.ShowDialog(this) == DialogResult.OK)
  991. {
  992. printData = db;
  993. printDocument1.Print();
  994. l.WriteLog(10, "当前第" + (i + 1) + "次打印:" + printData.iType + " 车号:" + db.printDb.carNo + ",二维码:" + db.qrCode);
  995. }
  996. else
  997. {
  998. l.WriteLog(10, "车号【" + PbCache.lockCarNo + "】第" + i + "次是否打印,选择了【否】");
  999. }
  1000. }
  1001. //printData = db;
  1002. //printDocument1.Print();
  1003. //lg.WriteLog(11, "当前打印:" + printData.iType + " 车号:" + db.printDb.carNo);
  1004. }
  1005. }
  1006. }
  1007. else
  1008. {
  1009. l.WriteLog(10, "车号【" + PbCache.lockCarNo + "】是否打印选择了【否】");
  1010. l.WriteLog(15, PbCache.lockCarNo + "是否打印选择了【否】");
  1011. }
  1012. }
  1013. }
  1014. }
  1015. else
  1016. {
  1017. l.WriteLog(10, "车号【" + PbCache.lockCarNo + "】获取打印配置数据信息异常sql:【" + sql + "】");
  1018. }
  1019. }
  1020. }
  1021. }
  1022. else
  1023. {
  1024. l.WriteLog(10, "车号【" + PbCache.lockCarNo + "】获取计量数据信息异常sql:【" + sql + "】");
  1025. }
  1026. #endregion 获取打印信息,若需要打印则调用打印操作
  1027. }
  1028. catch (Exception ex)
  1029. {
  1030. l.WriteLog(10, "车号【" + PbCache.lockCarNo + "】打印异常" + ex);
  1031. }
  1032. }
  1033. private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
  1034. {
  1035. try
  1036. {
  1037. if (printData != null && printData.printDb != null)
  1038. {
  1039. printClass.PrintAllPage(e, printData.printDb, printData.qrCode);
  1040. /*
  1041. //结净打印
  1042. if (printData.iType == 2)
  1043. {
  1044. printClass.PrintPage(e, printData.printDb, PbCache.strQRCode);
  1045. }
  1046. else //非结净打印
  1047. {
  1048. printClass.PrintWgtPage(e, printData.printDb, PbCache.strQRCode);
  1049. }
  1050. //*/
  1051. }
  1052. }
  1053. catch (Exception ex)
  1054. {
  1055. l.WriteLog(11, "打印异常" + ex);
  1056. }
  1057. }
  1058. /// <summary>
  1059. /// 重量大于500,直接打开主界面
  1060. /// </summary>
  1061. /// <param name="sender"></param>
  1062. /// <param name="e"></param>
  1063. private void timer1_Tick(object sender, EventArgs e)
  1064. {
  1065. if (!isOpened && PbCache.collect?.weight > 500)
  1066. {
  1067. isOpened = true;
  1068. isOpenMeter = true;
  1069. PbCache.bussinessTypeName = "";
  1070. PbCache.bussinessTypeCode = "";
  1071. if (fcc.Visible == false)
  1072. {
  1073. fcc.Visible = true;
  1074. fcc.init();
  1075. }
  1076. }
  1077. }
  1078. /// <summary>
  1079. /// 操作Live表的数据:零点报警
  1080. /// </summary>
  1081. private void doOperateLive()
  1082. {
  1083. if (PbCache.collect_no == null)
  1084. {
  1085. return;
  1086. }
  1087. List<LiveData> ll = MemoClass.getWarnInfo(PbCache.collect_no);
  1088. if (ll != null)
  1089. {
  1090. foreach (LiveData lv in ll)
  1091. {
  1092. switch (lv.Tagname.Replace(PbCache.collect_no, ""))
  1093. {
  1094. case "StaticStatus"://车辆检测 "0、东西方向激光均无报警;否则报警
  1095. break;
  1096. case "SwitchLight"://PLC红绿灯控制模式状态 "PLC有三种控制模式:1、自动、2、远控;3、检修
  1097. break;
  1098. case "LightWest"://红绿灯:1、为绿灯;2、为红灯;"
  1099. break;
  1100. case "ZeroWeightStatus": //0、其它,1、零点报警,红绿灯变红,
  1101. if (((lv.Value ?? "0") + "").Equals("1"))
  1102. {
  1103. doInsertZeroAlarm();
  1104. PbCache.isZeroAlarm = true;
  1105. }
  1106. else
  1107. {
  1108. PbCache.isZeroAlarm = false;
  1109. }
  1110. break;
  1111. }
  1112. }
  1113. }
  1114. }
  1115. /// <summary>
  1116. /// 操作Live表的数据:零点报警
  1117. /// </summary>
  1118. private void doLive()
  1119. {
  1120. if (PbCache.collect_no == null)
  1121. {
  1122. return;
  1123. }
  1124. List<LiveData> ll = MemoClass.getWarnInfo(PbCache.collect_no);
  1125. MeterWorkMonitor mwm = new MeterWorkMonitor();
  1126. mwm.pointNo = PbCache.sportInfo.baseSpotNo;
  1127. mwm.redGreenLightState = "0";
  1128. if (ll != null)
  1129. {
  1130. foreach (LiveData lv in ll)
  1131. {
  1132. switch (lv.Tagname.Replace(PbCache.collect_no, ""))
  1133. {
  1134. case "PowerStatus":
  1135. mwm.powerState = lv.Value.ToString();
  1136. break;
  1137. case "PlcWatchDog":
  1138. if (int.Parse(lv.Value.ToString()) >= 0 && int.Parse(lv.Value.ToString()) <= 0)
  1139. {
  1140. mwm.plcState = 0.ToString();
  1141. }
  1142. break;
  1143. case "InfraredWest":
  1144. if (lv.Value.ToString() == "2")
  1145. {
  1146. mwm.leftInfraredRayState = "0";
  1147. }
  1148. else
  1149. {
  1150. mwm.leftInfraredRayState = lv.Value.ToString();
  1151. }
  1152. break;
  1153. case "InfraredEast":
  1154. if (lv.Value.ToString() == "2")
  1155. {
  1156. mwm.rightInfraredRayState = "0";
  1157. }
  1158. else
  1159. {
  1160. mwm.rightInfraredRayState = lv.Value.ToString();
  1161. }
  1162. break;
  1163. case "AmplifierState":
  1164. mwm.amplifierState = lv.Value.ToString();
  1165. break;
  1166. case "LampState":
  1167. if (lv.Value.ToString() == "2")
  1168. {
  1169. mwm.lampState = "0";
  1170. }
  1171. else
  1172. {
  1173. mwm.lampState = lv.Value.ToString();
  1174. }
  1175. break;
  1176. case "InfraredLeft":
  1177. if (lv.Value.ToString() == "2")
  1178. {
  1179. mwm.frontInfraredRayState = "0";
  1180. }
  1181. else
  1182. {
  1183. mwm.frontInfraredRayState = lv.Value.ToString();
  1184. }
  1185. break;
  1186. case "InfraredRight":
  1187. if (lv.Value.ToString() == "2")
  1188. {
  1189. mwm.rearInfraredRayState = "0";
  1190. }
  1191. else
  1192. {
  1193. mwm.rearInfraredRayState = lv.Value.ToString();
  1194. }
  1195. break;
  1196. case "ZeroWeightStatus":
  1197. mwm.zeroState = lv.Value.ToString();
  1198. break;
  1199. case "RfidState":
  1200. mwm.rfidState = lv.Value.ToString();
  1201. if (((lv.Value ?? "0") + "").Equals("1"))
  1202. {
  1203. doInsertZeroAlarm();
  1204. PbCache.isZeroAlarm = true;
  1205. }
  1206. else
  1207. {
  1208. PbCache.isZeroAlarm = false;
  1209. }
  1210. break;
  1211. }
  1212. }
  1213. }
  1214. RESTfulResult<string> rms = meterWorkMonitor.doUpdateWf(mwm);
  1215. }
  1216. /// <summary>
  1217. /// 新增零点报警的数据
  1218. /// </summary>
  1219. private void doInsertZeroAlarm()
  1220. {
  1221. if (!PbCache.isZeroAlarm)
  1222. {
  1223. PbCache.isZeroAlarm = true;
  1224. MeterWorkZeroAlarm workZeroAlarm = new MeterWorkZeroAlarm();
  1225. workZeroAlarm.zeroWeight = PbCache.collect.weight;
  1226. workZeroAlarm.spotTypeNo = PbCache.sportInfo.spotTypeNo;
  1227. workZeroAlarm.spotTypeName = PbCache.sportInfo.spotTypeName;
  1228. workZeroAlarm.baseSpotNo = PbCache.sportInfo.baseSpotNo;
  1229. workZeroAlarm.baseSpotName = PbCache.sportInfo.baseSpotName;
  1230. workZeroAlarm.scalePointNo = PbCache.collect_no;
  1231. workZeroAlarm.createManNo = PbCache.sportInfo.baseSpotNo;
  1232. workZeroAlarm.createManName = PbCache.sportInfo.baseSpotName;
  1233. RESTfulResult<String> rms = zeroAlarmService.doInsertZeroAlarm(workZeroAlarm);
  1234. if (rms.Succeed)
  1235. {
  1236. l.WriteLog(20, "新增成功:" + workZeroAlarm.baseSpotName + ":" + workZeroAlarm.zeroWeight);
  1237. }
  1238. else
  1239. {
  1240. l.WriteLog(20, "操作失败:" + workZeroAlarm.baseSpotName + ":" + workZeroAlarm.zeroWeight + rms.Data + rms.Message);
  1241. }
  1242. }
  1243. }
  1244. private void button3_Click(object sender, EventArgs e)
  1245. {
  1246. string limsResult = "";
  1247. JGLimsInterface gLimsInterface = new JGLimsInterface();
  1248. }
  1249. /// <summary>
  1250. /// 查询重量信息,显示在界面上面
  1251. /// </summary>
  1252. /// <param name="sender"></param>
  1253. /// <param name="e"></param>
  1254. private void button4_Click(object sender, EventArgs e)
  1255. {
  1256. try
  1257. {
  1258. string sqls = @"select '毛重:' || t.gross_weight / 1000 || ' T / 皮重:' || t.tare_weight / 1000 || ' T / 净重:' || t.net_weight / 1000 || ' T ' as text
  1259. from meter_work_car_actual t where t.value_flag = '0' and T.Prediction_No = '" + txtPlanNo.Text + @"'";
  1260. PbModelDbService<List<PbModelDb>> pbRelation = new PbModelDbService<List<PbModelDb>>();
  1261. RESTfulResult<List<PbModelDb>> rmRelation = pbRelation.executeSqlDataWf(sqls);
  1262. if (rmRelation.Succeed && rmRelation.Data != null && rmRelation.Data.Count > 0)
  1263. {
  1264. MessageBox.Show(rmRelation.Data[0].text);
  1265. }
  1266. else
  1267. {
  1268. MessageBox.Show("空");
  1269. }
  1270. }
  1271. catch (Exception ex)
  1272. {
  1273. }
  1274. }
  1275. private void button1_Click(object sender, EventArgs e)
  1276. {
  1277. isOpened = false;
  1278. testFlag = true;
  1279. sss = false;
  1280. PbCache.isTest= true;
  1281. testWgt = (int)numericUpDown1.Value;
  1282. //CollectModel model = new CollectModel();
  1283. //model.weight = testWgt;
  1284. //PbCache.collect = model;
  1285. testCarNo = textBox1.Text.Trim();
  1286. testPlanNo = txtPlanNo.Text.Trim();
  1287. }
  1288. private void Form1_FormClosing(object sender, FormClosingEventArgs e)
  1289. {
  1290. collection.Stop();
  1291. imageCurlControl.Stop();
  1292. sweepCodeClass.CloseThread();
  1293. sweepCodeClass2.CloseThread();
  1294. timer1.Stop();
  1295. timer1.Dispose();
  1296. }
  1297. private bool SystemUpdate(bool isMessage)
  1298. {
  1299. ReleaseList releaseList = new ReleaseList(Application.StartupPath + @"\" + GlobalVariable.Instance.ReleaseFileName);
  1300. DownloadTools dt = new DownloadTools();
  1301. try
  1302. {
  1303. bool isDownload = dt.IsDownloadFile(GlobalVariable.Instance.LocalPath, GlobalVariable.Instance.ReleaseURL, GlobalVariable.Instance.ReleaseFileName);
  1304. if (!isDownload)
  1305. {
  1306. if (isMessage) MessageBox.Show("无法连接到远程主机!", Application.ProductName);
  1307. return false;
  1308. }
  1309. }
  1310. catch (Exception e)
  1311. {
  1312. MessageBox.Show(e.Message);
  1313. }
  1314. bool flag = this.CheckUpdate(releaseList);
  1315. if (flag)
  1316. {
  1317. MessageBox.Show("有新版本,现在更新");
  1318. string t = dt.DownloadFile(Application.StartupPath, GlobalVariable.Instance.ReleaseURL, GlobalVariable.Instance.ApplicationUpdater);
  1319. this.Close();
  1320. Application.Exit();
  1321. GC.Collect();
  1322. Process.Start(Application.StartupPath + @"\" + GlobalVariable.Instance.ApplicationUpdater);
  1323. return true;
  1324. }
  1325. else
  1326. {
  1327. if (isMessage) MessageBox.Show("你的系统已经是最新版本,不需要更新!", Application.ProductName);
  1328. return false;
  1329. }
  1330. }
  1331. private bool CheckUpdate(ReleaseList localRelease)
  1332. {
  1333. try
  1334. {
  1335. string fileNameAll = Application.StartupPath + "\\" + GlobalVariable.Instance.LocalPath + "\\" + GlobalVariable.Instance.ReleaseFileName;
  1336. ReleaseList remoteRelease = new ReleaseList(fileNameAll);
  1337. return (((localRelease != null) && (remoteRelease != null)) && localRelease.ReleaseDate.CompareTo(remoteRelease.ReleaseDate) < 0);
  1338. }
  1339. catch (Exception exception)
  1340. {
  1341. MessageBox.Show(exception.Message);
  1342. }
  1343. return false;
  1344. }
  1345. }
  1346. }