Form1.cs 64 KB

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