Form1.cs 66 KB

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