Form1.cs 61 KB

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