Form1.cs 64 KB

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