Form1.cs 87 KB

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