Form1.cs 64 KB

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