| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869 |
- using CarMeterSystem.OptionCls;
- using com.hnshituo.core.webapp.vo;
- using Common;
- using iCore.Rtdb.RtdbTable;
- using MeterConditionLibrary;
- using MeterModelLibrary;
- using MeterModuleLibrary.uc;
- using MeterPlugInLibrary;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Configuration;
- using System.Data;
- using System.Diagnostics;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Net.NetworkInformation;
- using System.Windows.Forms;
- using SystemOffLine;
- namespace CarMeterSystem
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private Log l = Log.GetInstance();
- private Print printClass = new Print();//打印
- //内存表
- private MemoryTableDataSocket MemoClass = new MemoryTableDataSocket("");
- //实时表数据采集
- private DataCollectionControl collection = new DataCollectionControl();
- //图片控制器含图片压缩及上传curl
- private ImageCurlControl imageCurlControl = new ImageCurlControl();
- //与监控界面对接的表
- private MeterWorkMonitorService meterWorkMonitor = new MeterWorkMonitorService();
- //零点报警表
- private meterworkzeroalarmservice zeroAlarmService = new meterworkzeroalarmservice();
- //车号修正
- private CarNoModfiy modfiy = new CarNoModfiy();
- //一码通接口调用
- private HttpRequest httpRequest = new HttpRequest();
- /// <summary>
- /// 这个是保存前一次采集中的车号信息
- /// </summary>
- private string preCarNo = "";
- //验证对射
- private validParkStatus valid = new validParkStatus();
- //语音播报
- private VoicePlay vicPlayClass = new VoicePlay();
- private LED_Control led_controler = null;
- //监控表操作
- private MeterMonitorWeightService monitorWeightService = new MeterMonitorWeightService();
- private MeterWorkScheduledHelpService meterWorkScheduledHelpService = new MeterWorkScheduledHelpService();
- //验证校秤数据
- private validCalibration vCalib = new validCalibration();
- private MeterWorkCarActualFirstService workCarActualFirstService = new MeterWorkCarActualFirstService(); //一次计量数据
- //查询当前是否校秤
- private bool bRelation = true;
- /// <summary>
- /// 欢迎界面
- /// </summary>
- private frmWelcome_Jisco frmWelcome = new frmWelcome_Jisco();//欢迎
- /// <summary>
- /// 计量页
- /// </summary>
- private frmOneYardToEnd fcc = null;
- /// <summary>
- /// 基础数据载入
- /// </summary>
- private BaseDbCls bd = new BaseDbCls();
- //扫码修正车号标识
- private bool codeFlag = false;
- private List<ucBusinessType> lu = new List<ucBusinessType>();
- private bool isVoiceDownCar = false;//车上人员请下车播放一次
- private bool isShowFrmWelcome = false; //是否显示欢迎界面
- private bool isOpened = false;//是否已经打开了扫码计量界面
- private bool noteCode = false;
- string validParkStatuConfig = ConfigurationManager.AppSettings["validParkStatuConfig"].ToString();
- //扫码器
- private SerialPortES sweepCodeClass = new SerialPortES();
- private SerialPortES sweepCodeClass2 = new SerialPortES();
- private void Form1_Load(object sender, EventArgs e)
- {
- //*
- try
- {
-
- //CollectModel temp = new CollectModel();
- //temp.weight = 501;
- //PbCache.collect = temp;
- //frmMatMsgInfo frmMatMsgInfo = new frmMatMsgInfo();
- //frmMatMsgInfo.Show();
- // 计量页
- fcc = new frmOneYardToEnd();
- timer1.Start();
- //2021年6月21日 杨秀东添加
- if (isShowFrmWelcome)
- {
- frmWelcome.Show();
- frmWelcome.Visible = true;
- }
- LoginCls lg = new LoginCls();
- if (lg.LoginIn())
- {
- //if (SystemUpdate(false))
- //{
- // return;
- //}
- // 加载并验证基本配置
- if (bd.setBaseDb() && bd.getBaseDb())
- {
- if (!string.IsNullOrEmpty(PbCache.sportInfo.ledIp))
- {
- led_controler = new LED_Control(PbCache.sportInfo.ledIp);
- }
- //调用该方法时已赋值
- RESTfulResult<List<MeterWorkMonitor>> rm = meterWorkMonitor.doQueryOneWf(new MeterWorkMonitor { validFlag = "1", pointNo = PbCache.sportInfo.baseSpotNo });
- if (!rm.Succeed)
- {
- l.WriteLog(1, "载入监控表数据异常");
- return;
- }
- else if (rm.Data != null && rm.Data.Count > 0)
- {
- if (string.IsNullOrEmpty(PbCache.collect_no))
- {
- PbCache.collect_no = rm.Data[0].collectionCode;
- MemoClass = new MemoryTableDataSocket(PbCache.collect_no);
- }
- }
- else
- {
- //l.WriteLog(1, "为配置监控数据");
- //return;
- }
- //若未校秤的话,也不允许计量
- //载入界面业务按钮
- if (PbCache.businessType != null && PbCache.businessType.Count > 0)
- {
- foreach (ComBaseInfo info in PbCache.businessType)
- {
- ucBusinessType uc = new ucBusinessType();
- switch (info.baseCode)
- {
- case "001006003":
- uc.setControl(info.baseName, info.memo, info.baseCode);
- break;
- case "001006001":
- case "001006002":
- uc.setControl(info.baseName, info.memo, info.baseCode);
- break;
- default:
- uc.setControl(info.baseName, info.memo, info.baseCode);
- break;
- }
- uc.Dock = DockStyle.Top;
- //uc.setControl("","","",);
- uc.ucEvent += new EventHandler(ucEvents);
- lu.Add(uc);
- panel7.Controls.Add(uc);
- }
- }
- //开启基础进程
- l.WriteLog(0, "系统登录成功");
- collection.EventDataCollectionArgs += new EventDataCollection(EventData);//数据采集
- collection.Start(PbCache.sportInfo.baseSpotNo, PbCache.sportInfo.baseSpotName);
- imageCurlControl.Start(); //图片采集线程
- //新扫码线程
- if (AppConfigCache._comPara?.Split(new char[] { ',' })?.Length == 5)
- {
- sweepCodeClass.StartThreadSweep(AppConfigCache._comPara); //扫码线程
- }
- if (AppConfigCache._comPara2?.Split(new char[] { ',' })?.Length == 5)
- {
- sweepCodeClass2.StartThreadSweep(AppConfigCache._comPara2); //扫码线程
- }
- }
- else
- {
- l.WriteLog(0, "系统登录失败");
- }
- }
- else
- {
- l.WriteLog(0, "按IP地址找不到计量点信息,系统登录失败,ip:" + IpAddress.getIp);
- }
- }
- catch (Exception ex)
- {
- l.WriteLog(0, "系统加载失败:" + ex.Message);
- }
- //*/
- }
- #region
- //*
- /// <summary>
- /// 委托的方式调用控件的点击事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- public void ucEvents(object sender, EventArgs e)
- {
- Control control = (Control)sender;
- ucBusinessType um = control.Parent.Parent as ucBusinessType;
- try
- {
- switch (control.Name)
- {
- case "btnContext":
- case "btnPurchase":
- {
- PbCache.bussinessTypeName = um._bussiness == null ? "" : um._bussiness;
- PbCache.bussinessTypeCode = um._code;
- switch (um._code)
- {
- case "001006003":
- frmInternalTransport frm = new frmInternalTransport();
- frm.ShowDialog();
- break;
- /*
- case "001006001":
- case "001006002":
- frmCarSalePurchase frmCar = new frmCarSalePurchase();
- frmCar.ShowDialog();
- break;
- //*/
- default:
- frmCarSalePurchase frmCar = new frmCarSalePurchase();
- frmCar.ShowDialog();
- break;
- }
- };
- break;
- default: break;
- }
- }
- catch (Exception ex)
- {
- //MessageBox.Show("操作异常:" + ex.Message);
- }
- }
- //*/
- #endregion
- #region
- private void setWelecomeVis(bool visb)
- {
- /*
- if (frmWelcome.InvokeRequired)
- {
- Action<bool> action = new Action<bool>(setWelecomeVis);
- Invoke(action, new object[] { visb });
- }
- else
- {
- if (frmWelcome.Visible != visb)
- {
- frmWelcome.Visible = visb;
- frmWelcome.setLogin();
- }
- }
- //*/
- }
- #endregion
- private int iCount = 0, iHodeTime = 0;
- private bool flagCarMonit = false;//车号修正
- private bool bEditCar = false; //手动修正车号
- private bool isOpenMeter = false; //是否已打开计量界面,若已经打开则这里关于超量程及红外的语音将停止播报
- private string firstCode = "";//上次扫码的信息
- private string ledTxt = "";
- private bool isLedWrite = false;//是否写入一次LED
- private string sPreNo = ""; //记录重量曲线变化
- private int preWgt = 0;//前一次重量,用于重量曲线
- private string sCarNo = "";
- private int iCountPark = 0;
- private string editCarNo = "";
- private bool isCarSource = false;
- private bool isResFlag = true;
- private string RFIDCarNo = "";
- private string isWriteRFID = AppConfigCache.isWriteRFID;
- //EventData实例化
- RESTfulResult<string> rmsEventDataLastTime = new RESTfulResult<string>();
- RESTfulResult<List<MeterWorkMonitor>> rmUpdateEventDataMonitor = new RESTfulResult<List<MeterWorkMonitor>>();
- MeterWorkMonitor updateEventDataMonitor = new MeterWorkMonitor();
- MeterMonitorWeight meterMonitorWeightEventData1 = new MeterMonitorWeight();
- MeterMonitorWeight meterMonitorWeightEventData2 = new MeterMonitorWeight();
- MeterWorkMonitor mwUpdate = new MeterWorkMonitor();
- PbModelDbService<List<PbModelDb>> pbpRFIDEventData = new PbModelDbService<List<PbModelDb>>();
- RESTfulResult<List<PbModelDb>> rmTRFIDEventData = new RESTfulResult<List<PbModelDb>>();
- RESTfulResult<string> rmsmwUpdateEventData = new RESTfulResult<string>();
- MeterWorkScheduledHelp meterWorkScheduledHelp1 = new MeterWorkScheduledHelp();
- MeterWorkScheduledHelp meterWorkScheduledHelpRFID = new MeterWorkScheduledHelp();
- RESTfulResult<string> rmsdoUpdateWfEventData = new RESTfulResult<string>();
- RESTfulResult<string> rmssEventData = new RESTfulResult<string>();
- MeterWorkMonitor meterWorkMonitorEventDataI = new MeterWorkMonitor();
- MeterWorkCarActualFirstService mwcfs = new MeterWorkCarActualFirstService();
- RESTfulResult<string> rmsSweepCodeClass = new RESTfulResult<string>();
- frmOneYardToEnd frmOneYardToEnd = new frmOneYardToEnd();
- private int num = 0;
- private void EventData(object o, DataCollectionArgs e)
- {
- if (!timer1.Enabled)
- {
- timer1.Enabled = true;
- //l.WriteLog(32, "定时器重启(timer1_Tick:frmMain),车号:" + PbCache.resultCarNo + "||" + (PbCache.collect == null ? "" : PbCache.collect.carno));
- }
- #region
- //num++;
- //e.carno = "湘G88888";
- //e.weight = 23580;
- //e.weightStatus = 0;
- //if (num < 20)
- //{
- // e.weight = 23580;
- // e.weightStatus = 1;
- //}
- //else if (num < 26)
- //{
- // e.weight = 23580;
- // e.weightStatus = 0;
- //}
- //else if (num < 39)
- //{
- // e.weight = 23580;
- // e.weightStatus = 0;
- //}
- //else if (num < 45)
- //{
- // e.weight = 15000;
- // e.weightStatus = 1;
- //}
- //else
- //{
- // e.weight = 400;
- //}
- #endregion
- //这里每隔0.5秒执行一次
- try
- {
- if (PbCache.carNoSource == 0)
- {
- PbCache.carNoSource = 1;
- }
- if (e.carno == "nown")
- {
- e.carno = "";
- }
- #region 扫码信息
- //if (string.IsNullOrEmpty(sweepCodeClass.StrCode))
- //{
- // if (string.IsNullOrEmpty(PbCache.strCode))
- // {
- // codeFlag = false;
- // firstCode = "";
- // PbCache.strCode = "";
- // l.WriteLog(12, "主线程扫码值为空时清空;sweepCodeClass.StrCode值为" + sweepCodeClass.StrCode + " ;PbCache.strCode值为:" + PbCache.strCode);
- // }
- //}
- //else
- //{
- // codeFlag = true;
- // frmOneYardToEnd frmOneYardToEnd = new frmOneYardToEnd();
- // Hashtable hashTable = new Hashtable();
- // hashTable.Add("message", sweepCodeClass.StrCode);
- // rmsSweepCodeClass = mwcfs.DecryptionForWfTest(hashTable);
- // if (rmsSweepCodeClass.Code == "0")
- // {
- // PbCache.collect.carno = rmsSweepCodeClass.Data;
- // PbCache.strCode = rmsSweepCodeClass.Data;
- // }
- // if (rmsSweepCodeClass.Code == "1")
- // {
- // vicPlayClass.GetVoicePlay("车号二维码已过期", PbCache.collect.carno);
- // frmOneYardToEnd.setMsgInfo("车号二维码已过期");
- // }
- // if (rmsSweepCodeClass.Code == "2")
- // {
- // vicPlayClass.GetVoicePlay("不是有效车号二维码", PbCache.collect.carno);
- // frmOneYardToEnd.setMsgInfo("不是有效车号二维码");
- // }
- // if (rmsSweepCodeClass.Code == "9")
- // {
- // vicPlayClass.GetVoicePlay("不是有效车号二维码", PbCache.collect.carno);
- // frmOneYardToEnd.setMsgInfo("不是有效车号二维码");
- // }
- // l.WriteLog(12, "测试扫码值" + rmsSweepCodeClass.Data);
- //}
- // 司机扫码为空,取工控机二维码
- if (PbCache.sportInfo.scanRequireValid == "1")
- {
- if (PbCache.monitor.isValidScan == "0")
- {
- PbCache.isValidScan = true;
- if (string.IsNullOrEmpty(sweepCodeClass2.StrCode))
- {
- if (string.IsNullOrEmpty(sweepCodeClass.StrCode))
- {
- if (string.IsNullOrEmpty(PbCache.strCode))
- {
- codeFlag = false;
- firstCode = "";
- PbCache.strCode = "";
- //l.WriteLog(12, "主线程扫码值为空时清空;sweepCodeClass.StrCode值为" + sweepCodeClass.StrCode + " ;PbCache.strCode值为:" + PbCache.strCode);
- }
- }
- else
- {
- l.WriteLog(0, sweepCodeClass.StrCode);
- if (sweepCodeClass.StrCode.Length > 3 && sweepCodeClass.StrCode.Substring(0, 3) == "TWB")
- {
- DecodeQRCodeYMT(sweepCodeClass.StrCode);
- }
- else
- {
- DecodeQRCode(sweepCodeClass.StrCode);
- }
- }
- }
- else
- {
- l.WriteLog(0, sweepCodeClass.StrCode);
- if (sweepCodeClass.StrCode.Length > 3 && sweepCodeClass2.StrCode.Substring(0, 3) == "TWB")
- {
- DecodeQRCodeYMT(sweepCodeClass2.StrCode);
- }
- else
- {
- DecodeQRCode(sweepCodeClass2.StrCode);
- }
- }
- }
- else
- {
- PbCache.isValidScan = false;
- if (string.IsNullOrEmpty(sweepCodeClass2.StrCode))
- {
- if (string.IsNullOrEmpty(sweepCodeClass.StrCode))
- {
- if (string.IsNullOrEmpty(PbCache.strCode))
- {
- codeFlag = false;
- firstCode = "";
- PbCache.strCode = "";
- //l.WriteLog(12, "主线程扫码值为空时清空;sweepCodeClass.StrCode值为" + sweepCodeClass.StrCode + " ;PbCache.strCode值为:" + PbCache.strCode);
- }
- }
- else
- {
- l.WriteLog(0, sweepCodeClass.StrCode);
- if (sweepCodeClass.StrCode.Length > 3 && sweepCodeClass.StrCode.Substring(0, 3) == "TWB")
- {
- DecodeQRCodeYMT(sweepCodeClass.StrCode);
- }
- else
- {
- DecodeQRCode(sweepCodeClass.StrCode);
- }
- }
- }
- else
- {
- l.WriteLog(0, sweepCodeClass.StrCode);
- if (sweepCodeClass.StrCode.Length > 3 && sweepCodeClass2.StrCode.Substring(0, 3) == "TWB")
- {
- DecodeQRCodeYMT(sweepCodeClass2.StrCode);
- }
- else
- {
- DecodeQRCode(sweepCodeClass2.StrCode);
- }
- }
- }
- }
- else
- {
- PbCache.isValidScan = true;
- if (string.IsNullOrEmpty(sweepCodeClass2.StrCode))
- {
- if (string.IsNullOrEmpty(sweepCodeClass.StrCode))
- {
- if (string.IsNullOrEmpty(PbCache.strCode))
- {
- codeFlag = false;
- firstCode = "";
- PbCache.strCode = "";
- //l.WriteLog(12, "主线程扫码值为空时清空;sweepCodeClass.StrCode值为" + sweepCodeClass.StrCode + " ;PbCache.strCode值为:" + PbCache.strCode);
- }
- }
- else
- {
- l.WriteLog(0, sweepCodeClass.StrCode);
- if (sweepCodeClass.StrCode.Length > 3 && sweepCodeClass.StrCode.Substring(0, 3) == "TWB")
- {
- DecodeQRCodeYMT(sweepCodeClass.StrCode);
- }
- else
- {
- DecodeQRCode(sweepCodeClass.StrCode);
- }
- }
- }
- else
- {
- l.WriteLog(0, sweepCodeClass.StrCode);
- if (sweepCodeClass.StrCode.Length > 3 && sweepCodeClass2.StrCode.Substring(0, 3) == "TWB")
- {
- DecodeQRCodeYMT(sweepCodeClass2.StrCode);
- }
- else
- {
- DecodeQRCode(sweepCodeClass2.StrCode);
- }
- }
- }
- #endregion
- #region 秤上无车10分钟获取一次基础数据
- if (iCount < 1200)
- {
- iCount++;
- }
- else
- {
- try
- {
- //秤上没有车时,每隔10分钟获取一次基础数据
- if (e.weight < 500)
- {
- if (bd.setBaseDb())
- {
- l.WriteLog(0, "十分钟获取基础数据成功");
- }
- else
- {
- l.WriteLog(0, "十分钟获取基础数据失败");
- }
- iCount = 0;
- }
- }
- catch (Exception ex)
- {
- l.WriteLog(0, "十分钟获取基础数据失败:" + ex.Message);
- iCount = 0;
- }
- }
- #endregion
- #region 每10秒写入一次当前时间
- if (iCount % 20 == 0)
- {
- //更新在线时间
- rmsEventDataLastTime = meterWorkMonitor.doUpdateWfBySpotNo(new MeterWorkMonitor { pointNo = PbCache.sportInfo.baseSpotNo });
- if (!rmsEventDataLastTime.Succeed)
- {
- l.WriteLog(0, "frmMain.EventData异常:写入时间异常,原因:" + rmsEventDataLastTime.ResultMessage);
- }
- }
- #endregion
- #region
- //一旦界面锁定则不采集数据
- PbCache.collect.pointid = PbCache.sportInfo.baseSpotNo;
- PbCache.collect.parkStatus = e.parkStatus;
- PbCache.collect.datetime = e.datetime;
- PbCache.collect.licType = e.licType;
- if (testFlag)
- {
- sCarNo = testCarNo;
- //PbCache.collect.carno = testCarNo;
- PbCache.collect.weight = testWgt;
- PbCache.collect.weightStatus = 0;
- PbCache.monitorResult.valid_park_status = true;
- PbCache.collect.parkStatus = 0;
- if (PbCache.collect.weight > e.weight)
- e.weight = PbCache.collect.weight;
- PbCache.strCode = testPlanNo;
- //e.carno = testCarNo;
- //PbCache.strQRCode = testCode;
- }
- else if (!PbCache.isLockFrm)
- {
- PbCache.collect.weight = e.weight;
- PbCache.collect.weight = e.weight;
- PbCache.collect.weightStatus = e.weightStatus;
- PbCache.collect.parkStatus = e.parkStatus;
- PbCache.collect.datetime = e.datetime;
- PbCache.collect.licType = e.licType;
- if (!bEditCar && !codeFlag && String.IsNullOrEmpty(RFIDCarNo))
- {
- PbCache.collect.carno = e.carno;
- }
- PbCache.collect.videoCarNo1 = e.videoCarNo1;
- PbCache.collect.videoCarNo2 = e.videoCarNo2;
- PbCache.collect.rfidCarNo = e.RfidNos;
- PbCache.collect.carnoAlert = e.carnoAlert;
- }
- //界面锁定后,仍然更新判稳状态
- //BourneCao 20221230
- else
- {
- PbCache.collect.weightStatus = e.weightStatus;
- PbCache.collect.parkStatus = e.parkStatus;
- }
- if (PbCache.collect != null && PbCache.collect.weightStatus == 0)
- {
- if (string.IsNullOrEmpty(PbCache.resultWgt))
- {
- PbCache.resultWgt = e.weight + "";
- }
- if (!string.IsNullOrEmpty(PbCache.resultWgt) && e.weight > Convert.ToInt32(PbCache.resultWgt))
- {
- PbCache.resultWgt = e.weight + "";
- }
- if (!string.IsNullOrEmpty(e.carno) && PbCache.resultCarNo != e.carno)
- {
- PbCache.resultCarNo = e.carno + "";
- //l.WriteLog(28, "车号賦值跟蹤:PbCache.resultCarNo" + PbCache.resultCarNo + "||e.carno" + e.carno);
- }
- }
- //*/
- // 更新监控表
- //doLive();
- //重量大于500的情况下
- if (e.weight > 500)
- {
- isResFlag = true;
- isCarSource = true;
- if (PbCache.dtStartTime == null)
- PbCache.dtStartTime = DateTime.Now;
- isLedWrite = true;
- PbCache.strState = "0";
- #region 车上人员请下车
- try
- {
- //界面未锁定的情况下,有车号,如果重量稳定了,停车线验证通过,未超量程的情况下,则按钮可用
- if (PbCache.collect != null && !string.IsNullOrEmpty(PbCache.collect.carno) && PbCache.collect.weightStatus == 0 && PbCache.monitorResult.valid_park_status && PbCache.collect.weight < PbCache.range.upperRange)
- {
- if (!isVoiceDownCar)
- {
- isVoiceDownCar = true;
- vicPlayClass.GetVoicePlay("车上人员请下车", PbCache.collect.carno);
- }
- }
- }
- catch { }
- #endregion
- setWelecomeVis(false);
- //每隔1秒刷一次计量实时监控表数据值
- if (iCount % 2 == 0)
- {
- //调用该方法时已赋值
- updateEventDataMonitor.validFlag = "1";
- updateEventDataMonitor.pointNo = PbCache.sportInfo.baseSpotNo;
- rmUpdateEventDataMonitor = meterWorkMonitor.doQueryOneWf(updateEventDataMonitor);
- if (!rmUpdateEventDataMonitor.Succeed)
- {
- l.WriteLog(0, "frmMain.EventData异常419:" + rmUpdateEventDataMonitor.ResultMessage);
- }
- else
- {
- if (rmUpdateEventDataMonitor.Data != null && rmUpdateEventDataMonitor.Data.Count > 0)
- {
- PbCache.monitor = rmUpdateEventDataMonitor.Data[0];
- if (string.IsNullOrEmpty(PbCache.collect_no))
- {
- PbCache.collect_no = rmUpdateEventDataMonitor.Data[0].collectionCode;
- }
- if (ledTxt != rmUpdateEventDataMonitor.Data[0].ledWriter && rmUpdateEventDataMonitor.Data[0].ledWriter != "")
- {
- //调用LED信息写入******************************
- ledTxt = rmUpdateEventDataMonitor.Data[0].ledWriter;
- }
- if (string.IsNullOrEmpty(ledTxt))
- {
- ledTxt = "欢迎使用酒钢汽车衡智能计量系统!";
- }
- }
- }
- #region 2021-03-29
- #region 摄像头当前采集的车号与上次采集的不一样且当前未勾选不验证,且当前车号未进行手动修正的情况下
- if (preCarNo != e.carno && PbCache.monitor != null && PbCache.monitor.validCarno != "0" && !bEditCar)
- {
- flagCarMonit = false;
- }
- preCarNo = e.carno;
- #endregion
- if (!flagCarMonit)
- {
- sCarNo = e.carno;
- }
- //*
- //有车号,且重量稳定的情况下,只修正一次车号
- if (!string.IsNullOrEmpty(e.carno) && e.weightStatus == 0 && !flagCarMonit && PbCache.monitor != null && PbCache.monitor.carMonitor == "1" && PbCache.monitor.carMonitorLvl > 0)
- {
- flagCarMonit = true;
- string methods = "";
- for (int i = 0; i <= PbCache.monitor.carMonitorLvl; i++)
- {
- methods += "CarNoTrustCorrect" + i + ",";
- }
- l.WriteLog(0, "methods:" + methods);
- editCarNo = modfiy.CarNoCorrect(e.carno, methods.Substring(0, methods.Length - 1));
- sCarNo = editCarNo;
- //mwUpdate
- }
- //勾选了不验证车号的情况
- if (PbCache.monitor.validCarno == "0")
- {
- flagCarMonit = true;
- }
- #endregion
- #region 每隔1秒写入一次重量曲线
- try
- {
- if (preWgt != e.weight)
- {
- preWgt = e.weight;
- sPreNo = PbCache.sportInfo.baseSpotNo + DateTime.Now.ToString("yyyyMMddHHmmssfff");
- meterMonitorWeightEventData1.weightNo = sPreNo;
- meterMonitorWeightEventData1.baseSpotNo = PbCache.sportInfo.baseSpotNo;
- meterMonitorWeightEventData1.baseSpotName = PbCache.sportInfo.baseSpotName;
- meterMonitorWeightEventData1.collectWeight = e.weight + "";
- meterMonitorWeightEventData1.collectStartTime = PbCache.dtStartTime.Value;
- meterMonitorWeightEventData1.collectEndTime = DateTime.Now;
- meterMonitorWeightEventData1.spotTypeNo = "001002001";
- meterMonitorWeightEventData1.spotTypeName = "汽车衡";
- meterMonitorWeightEventData1.actualFirstNo = PbCache.actualFirstNo;
- monitorWeightService.doAddWf(meterMonitorWeightEventData1);
- }
- else
- {
- if (!string.IsNullOrEmpty(sPreNo))
- {
- meterMonitorWeightEventData2.weightNo = sPreNo;
- meterMonitorWeightEventData2.collectEndTime = DateTime.Now;
- monitorWeightService.doUpdateWf(meterMonitorWeightEventData2);
- }
- }
- }
- catch { }
- #endregion
- #region 停留超时
- iHodeTime++;
- mwUpdate.pointNo = PbCache.sportInfo.baseSpotNo;
- mwUpdate.editCar = editCarNo;
- if (PbCache.holdTime != null && PbCache.holdTime.Count > 0)
- {
- if (PbCache.holdTime[0].retentionTime != null)
- {
- if (PbCache.holdTime[0].retentionTime.Value < iHodeTime)
- {
- l.WriteLog(33, "iHodeTime:" + iHodeTime + ",PbCache.holdTime[0].retentionTime.Value:" + PbCache.holdTime[0].retentionTime.Value + ",mwUpdate.stopOverTime:" + mwUpdate.stopOverTime);
- PbCache.isOvertimeAlarm = true; //是否超时报警
- mwUpdate.stopOverTime = "1"; //写入一次停留超时
- //mwUpdate.isHelp = "1";//派位
- //mwUpdate.isTakeOver = "1";
- iHodeTime = 99999;//不再增长避免超出
- }
- }
- }
- #endregion
- #region RFID识别车号信息
- mwUpdate.rfidCar = "";
- mwUpdate.photoCar = e.videoCarNo1;
- mwUpdate.photoCar2 = e.videoCarNo2;
- mwUpdate.scanCar = "";
- if (codeFlag)
- {
- mwUpdate.scanCar = PbCache.collect.carno;
- }
- //mwUpdate.photoCar = PbCache.collect.carno;
- if (!string.IsNullOrEmpty(e.RfidNos))
- {
- string sqls = @"SELECT RFID_ID id,CAR_NO text FROM METER_BASE_RFID_INFO where RFID_CODE = '" + e.RfidNos + "'";
- rmTRFIDEventData = pbpRFIDEventData.executeSqlDataWf(sqls);
- if (rmTRFIDEventData.Data == null || rmTRFIDEventData.Data.Count == 0)
- { }
- else
- {
- if (PbCache.carNoSource == 1)
- {
- PbCache.carNoSource = 2;
- }
- mwUpdate.rfidCar = rmTRFIDEventData.Data[0].text;
- sCarNo = rmTRFIDEventData.Data[0].text;
- RFIDCarNo = rmTRFIDEventData.Data[0].text;
- }
- }
- #endregion
- #region 计量员修改的车号信息
- if (PbCache.monitor != null && !string.IsNullOrEmpty(PbCache.monitor.setCar))
- {
- PbCache.carNoSource = 4;
- sCarNo = PbCache.monitor.setCar;
- bEditCar = true;
- flagCarMonit = true;
- codeFlag = false;
- sweepCodeClass.StrCode = "";
- sweepCodeClass2.StrCode = "";
- }
- #endregion
- #region 重量信息
- if (!PbCache.isLockFrm)
- {
- mwUpdate.wgt = e.weight;
- }
- else
- {
- mwUpdate.wgt = Convert.ToInt32(PbCache.lockWgt);
- }
- #endregion
- #region 写入一次监控表,将重量/车号停留超时等信息写入
- mwUpdate.msgInfo = PbCache.ResultMessage;
- mwUpdate.weightStatus = PbCache.collect.weightStatus;
- //另外初始化一次监控数据
- rmsmwUpdateEventData = meterWorkMonitor.doUpdateWf(mwUpdate);
- if (!rmsmwUpdateEventData.Succeed)
- {
- l.WriteLog(0, "frmMain.EventData异常583:写入信息异常" + mwUpdate);
- }
- #endregion
- //验证对射
- valid.ValidMethod();
- if (!isOpenMeter)
- {
- //if (PbCache.range != null && PbCache.range.upperRange < e.weight)
- if (PbCache.range != null && PbCache.range.upperRange < e.weight)
- {
- //超量程
- vicPlayClass.GetVoicePlay("已超量程", e.carno);
- //return;
- }
- else if (e.weightStatus == 0)
- {
- if (!PbCache.monitorResult.valid_park_status && validParkStatuConfig == "true")
- {
- iCountPark++;
- if (iCountPark > 9 && !string.IsNullOrEmpty(PbCache.collect.carno))
- {
- PbCache.ResultMessage = "车辆超出秤台,请调整车位1"; //btnSave_Click
- //重量稳定,且对射验证不合格
- vicPlayClass.GetVoicePlay("车辆超出秤台,请调整车位", e.carno);
- led_controler.setStaticLineMsg(PbCache.sportInfo.ledIp, "车辆超出秤台,请调整车位1");
- //return;
- iCountPark = 0; //2021年7月27日5s播一次,然后重新在播
- }
- }
- else
- {
- iCountPark = 0;
- }
- }
- }
- if (!lu[0].bcEnable)
- {
- foreach (ucBusinessType uc in lu)
- {
- uc.setControlEnable(true);
- }
- }
- if ((sweepCodeClass.StrCode == "" || sweepCodeClass2.StrCode == "") && !codeFlag)
- {
- PbCache.collect.carno = sCarNo;
- }
- if (codeFlag && !noteCode)
- {
- noteCode = true;
- meterWorkScheduledHelp1.baseSpotNo = PbCache.sportInfo.baseSpotNo;
- meterWorkScheduledHelp1.baseSpotName = PbCache.sportInfo.baseSpotName;
- meterWorkScheduledHelp1.carNo = string.IsNullOrEmpty(PbCache.collect.carno) ? PbCache.resultCarNo : PbCache.collect.carno;
- meterWorkScheduledHelp1.helpContent = "车号:" + sCarNo + "扫码过秤";
- meterWorkScheduledHelp1.warmType = "2";
- meterWorkScheduledHelp1.warmTypeName = "智能终端报警";
- meterWorkScheduledHelpService.add(meterWorkScheduledHelp1);
- }
- }
- PbCache.collect.carno = sCarNo;
- //写入LED信息
- //if (PbCache.sportInfo != null && PbCache.ledInfo != PbCache.OldLedInfo)
- //{
- // PbCache.OldLedInfo = PbCache.ledInfo;
- // if (PbCache.monitor != null && PbCache.monitor.ledKeep == "0")
- // {
- // //led_controler.setOneLineMsg(PbCache.sportInfo.ledIp, PbCache.ledInfo);
- // }
- //}
- }
- else
- {
- isOpened = false; //下次上秤直接打开主界面
- if (e.weight > 10 && e.weight < 500)
- {
- //重量小于500,大于10
- MeterWorkMonitor mwUpdate = new MeterWorkMonitor();
- mwUpdate.pointNo = PbCache.sportInfo.baseSpotNo;
- mwUpdate.wgt = e.weight;
- rmsdoUpdateWfEventData = meterWorkMonitor.doUpdateWf(mwUpdate);
- }
- if (e.weight > 0 && e.weight < 200)
- {
- doOperateLive();
- }
- if (e.weight == 0)
- {
- PbCache.isZeroAlarm = false;
- }
- editCarNo = "";
- firstCode = ""; //历史的扫码枪的值
- preCarNo = "";
- sCarNo = "";
- sPreNo = "";
- preWgt = 0;
- //不等于空的时候说明写过一次日志了
- if (isResFlag)
- {
- isResFlag = false;
- meterWorkScheduledHelp1.baseSpotNo = PbCache.sportInfo.baseSpotNo;
- meterWorkScheduledHelp1.baseSpotName = PbCache.sportInfo.baseSpotName;
- meterWorkScheduledHelp1.carNo = string.IsNullOrEmpty(PbCache.collect.carno) ? PbCache.resultCarNo : PbCache.collect.carno;
- meterWorkScheduledHelp1.helpContent = "车号:" + (string.IsNullOrEmpty(PbCache.collect.carno) ? (string.IsNullOrEmpty(PbCache.resultCarNo) ? "未识别" : PbCache.resultCarNo) : PbCache.collect.carno) + ";重量:" + (PbCache.lockWgt == 0 ? PbCache.resultWgt : PbCache.lockWgt + "") + ";提示信息:" + PbCache.resultMsgAll;
- meterWorkScheduledHelp1.warmType = "5";
- meterWorkScheduledHelp1.warmTypeName = "计量提示跟踪";
- meterWorkScheduledHelpService.add(meterWorkScheduledHelp1);
- //l.WriteLog(28, "车号:" + (string.IsNullOrEmpty(PbCache.collect.carno) ? (string.IsNullOrEmpty(PbCache.resultCarNo) ? "未识别" : PbCache.resultCarNo) : PbCache.collect.carno) + ";重量:" + (PbCache.lockWgt == 0 ? PbCache.resultWgt : PbCache.lockWgt + "") + ";提示信息:" + PbCache.resultMsgAll);
- }
- //不等于空的时候说明写过一次日志了
- if (!string.IsNullOrEmpty(RFIDCarNo) && isWriteRFID == "1")
- {
- meterWorkScheduledHelp1.baseSpotNo = PbCache.sportInfo.baseSpotNo;
- meterWorkScheduledHelp1.baseSpotName = PbCache.sportInfo.baseSpotName;
- meterWorkScheduledHelp1.carNo = string.IsNullOrEmpty(PbCache.collect.carno) ? PbCache.resultCarNo : PbCache.collect.carno;
- meterWorkScheduledHelp1.helpContent = RFIDCarNo;
- meterWorkScheduledHelp1.warmType = "7";
- meterWorkScheduledHelp1.warmTypeName = "RFID识别率";
- meterWorkScheduledHelpService.add(meterWorkScheduledHelp1);
- RFIDCarNo = "";
- }
- //车号来源记录
- if (isCarSource)
- {
- meterWorkScheduledHelp1.baseSpotNo = PbCache.sportInfo.baseSpotNo;
- meterWorkScheduledHelp1.baseSpotName = PbCache.sportInfo.baseSpotName;
- meterWorkScheduledHelp1.carNo = string.IsNullOrEmpty(PbCache.collect.carno) ? PbCache.resultCarNo : PbCache.collect.carno;
- meterWorkScheduledHelp1.helpContent = PbCache.carNoSource.ToString();
- meterWorkScheduledHelp1.warmType = "8";
- meterWorkScheduledHelp1.warmTypeName = "车号来源记录";
- meterWorkScheduledHelpService.add(meterWorkScheduledHelp1);
- isCarSource = false;
- PbCache.carNoSource = 0;
- }
- PbCache.isOvertimeAlarm = false; //是否超时报警
- PbCache.strCode = "";
- PbCache.strState = "";
- PbCache.ResultMessage = "";
- PbCache.resultMsgAll = "";
- PbCache.resultCarNo = "";
- PbCache.resultWgt = "";
- bEditCar = false;
- isVoiceDownCar = false;
- flagCarMonit = false;
- iHodeTime = 0;
- isOpenMeter = false;
- PbCache.isLockFrm = false;
- PbCache.dtStartTime = null;
- PbCache.voiceOver = true;
- if (PbCache.collect != null && !string.IsNullOrEmpty(PbCache.collect.carno))
- {
- PbCache.collect.carno = "";
- }
- setWelecomeVis(true);
- if (lu[0].bcEnable)
- {
- foreach (ucBusinessType uc in lu)
- {
- uc.setControlEnable(false);
- }
- }
- noteCode = false;
- meterWorkMonitorEventDataI.pointNo = PbCache.sportInfo.baseSpotNo;
- meterWorkMonitorEventDataI.validWgt = "1";
- meterWorkMonitorEventDataI.validCarno = "1";
- meterWorkMonitorEventDataI.validTareTime = "1";
- meterWorkMonitorEventDataI.validMatTime = "1";
- meterWorkMonitorEventDataI.validTimeInterval = "1";
- meterWorkMonitorEventDataI.validParkStatus = "1";
- meterWorkMonitorEventDataI.validExceedWgt = "1";
- meterWorkMonitorEventDataI.validPredictionDiff = "1";
- meterWorkMonitorEventDataI.validLianda = "1";
- meterWorkMonitorEventDataI.validMatClick = "1";
- meterWorkMonitorEventDataI.setCar = "";
- meterWorkMonitorEventDataI.isValidScan = "1";
- meterWorkMonitorEventDataI.rfidCar = "";
- meterWorkMonitorEventDataI.photoCar = "";
- meterWorkMonitorEventDataI.scanCar = "";
- meterWorkMonitorEventDataI.editCar = "";
- meterWorkMonitorEventDataI.zeroState = "0";
- meterWorkMonitorEventDataI.carErr = "0";
- meterWorkMonitorEventDataI.ferroalloyResult = "0";
- meterWorkMonitorEventDataI.wgtErr = "0";
- meterWorkMonitorEventDataI.stopOverTime = "0";
- meterWorkMonitorEventDataI.msgInfo = "";
- meterWorkMonitorEventDataI.ledWriter = "";
- meterWorkMonitorEventDataI.isOverWgt = "";
- meterWorkMonitorEventDataI.isHelp = "0";
- meterWorkMonitorEventDataI.wgt = e.weight;
- // DVR,MOXA,PLC状态监控
- // 20220928 by BourneCao
- bool DVR_Online = PingIp(PbCache.sportInfo.videoIp);
- meterWorkMonitorEventDataI.dvrState = DVR_Online == true ? "0" : "1";
- bool Power_Online = PingIp(PbCache.sportInfo.controlIp);
- meterWorkMonitorEventDataI.powerState = Power_Online == true ? "0" : "1";
- bool MOXA_Online = PingIp(PbCache.sportInfo.moxaIp);
- meterWorkMonitorEventDataI.moxaState = MOXA_Online == true ? "0" : "1";
- bool PLC_Online = PingIp(PbCache.sportInfo.plcIp);
- meterWorkMonitorEventDataI.plcState = PLC_Online == true ? "0" : "1";
- //*
- //另外初始化一次监控数据
- RESTfulResult<string> rmssEventData = meterWorkMonitor.doUpdateWf(meterWorkMonitorEventDataI);
- if (!rmssEventData.Succeed)
- {
- l.WriteLog(0, "frmMain.EventData异常754:写入信息异常");
- }
- //*/
- //LED写入
- if (isLedWrite)
- {
- isLedWrite = false;
- }
- }
- #endregion
- }
- catch (Exception ex)
- {
- l.WriteLog(0, "frmMain.EventData异常:" + ex.Message);
- }
- }
- private void DecodeQRCodeYMT(string strCode)
- {
- try
- {
- string test = strCode.Substring(0, 3);
- codeFlag = true;
- string token = httpRequest.GetToken();
- string carNo = httpRequest.getCarNo(strCode,token);
- PbCache.collect.carno = carNo;
- PbCache.strCode = carNo;
- }
- catch (Exception e)
- {
- }
- }
- private void DecodeQRCode(string strCode)
- {
- codeFlag = true;
- //frmOneYardToEnd frmOneYardToEnd = new frmOneYardToEnd();
- Hashtable hashTable = new Hashtable();
- hashTable.Add("message", strCode);
- rmsSweepCodeClass = mwcfs.DecryptionForWfTest(hashTable);
- if (rmsSweepCodeClass.Code == "0")
- {
- PbCache.collect.carno = rmsSweepCodeClass.Data;
- PbCache.strCode = rmsSweepCodeClass.Data;
- }
- if (rmsSweepCodeClass.Code == "1")
- {
- vicPlayClass.GetVoicePlay("车号二维码已过期", PbCache.collect.carno);
- frmOneYardToEnd.setMsgInfo("车号二维码已过期");
- }
- if (rmsSweepCodeClass.Code == "2")
- {
- vicPlayClass.GetVoicePlay("不是有效车号二维码", PbCache.collect.carno);
- frmOneYardToEnd.setMsgInfo("不是有效车号二维码");
- }
- if (rmsSweepCodeClass.Code == "9")
- {
- vicPlayClass.GetVoicePlay("不是有效车号二维码", PbCache.collect.carno);
- frmOneYardToEnd.setMsgInfo("不是有效车号二维码");
- }
- l.WriteLog(12, "测试扫码值" + rmsSweepCodeClass.Data);
- }
- private delegate void ShowBtnTare(bool flag);//定义委托 期限皮重按钮
- private int testWgt = 0;
- private string testCarNo = "", testPlanNo = "";
- private bool testFlag = true;
- /// <summary>
- /// 截图测试
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button2_Click(object sender, EventArgs e)
- {
- CameraShotCls cameraShot = new CameraShotCls();
- //cameraShot.CapMethod("1");
- _ = Invoke(new Action(() => { cameraShot.CapMethod("15"); }));
- }
- //测试打印
- private string strFirstNo = "";
- private void btnTestPrint_Click(object sender, EventArgs e)
- {
- Print1(txtPlanNo.Text);
- }
- //弹窗
- private static FrmMessage FrmMess(string strMess, string strBtnSaveInfo)
- {
- FrmMessage frmMessage = new FrmMessage();
- frmMessage.StartPosition = FormStartPosition.Manual;
- frmMessage.Location = new Point(350, 450);
- frmMessage.ShowMessage = strMess;
- frmMessage.BtnSaveText = strBtnSaveInfo;
- frmMessage.BtnCancelText = "取消";
- return frmMessage;
- }
- private class PrintCls
- {
- public int printNum { get; set; }
- public MeterWorkCarActual printDb { get; set; }
- public int iType { get; set; } //0毛 1 皮 2净
- public string qrCode { get; set; }
- }
- private PrintCls printData = new PrintCls();
- private void Print1(string firstNo)
- {
- try
- {
- //lg.WriteLog(1, "打印开始");
- #region 获取打印信息,若需要打印则调用打印操作
- List<PrintCls> prrintC = new List<PrintCls>();
- string sql = @"select actual_no actualNo,
- prediction_no predictionNo,
- car_no carNo,
- matter_no matterNo,
- matter_name matterName,
- gross_weight grossWeight,
- gross_time grossTime,
- tare_weight tareWeight,
- tare_time tareTime,
- net_weight netWeight,
- net_Time netTime,
- 'x' meterTypeNo,
- meter_type_name meterTypeName,
- spec_name specName,
- forwarding_unit_name forwardingUnitName,
- receiving_uint_name receivingUintName,
- load_point_name loadPointName,
- add_weight addWeight,
- '1' uploadFlag --1结净数据 0一次表数据
- from meter_work_car_actual where actual_first1_no = '" + firstNo + @"' or actual_first2_no='" + firstNo + @"'
- union all
- select t.actual_first_no actualNo,
- t.prediction_no predictionNo,
- t.car_no carNo,
- t.matter_no matterNo,
- t.matter_name matterName,
- t.meter_weight grossWeight,
- t.create_time grossTime,
- 0 tareWeight,
- t.create_time tareTime,
- 0 netWeight,
- null netTime,
- t.weight_type meterTypeNo, --0毛重 否则皮重
- t.meter_type_name meterTypeName,
- t.spec_name specName,
- t.forwarding_unit_name forwardingUnitName,
- t.receiving_uint_name receivingUintName,
- t.load_point_name loadPointName,
- t.add_weight addWeight,
- '0' uploadFlag
- from METER_WORK_CAR_ACTUAL_FIRST t
- 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 + "')";
- //查下如果有毛重或者结净数据,则可进入打印判断
- PbModelDbService<List<MeterWorkCarActual>> pbModelDbService = new PbModelDbService<List<MeterWorkCarActual>>();
- RESTfulResult<List<MeterWorkCarActual>> rm = pbModelDbService.executeSqlDataWf(sql);
- //lg.WriteLog(1, "打印第一个sql:" + sql);
- if (rm.Succeed)
- {
- if (rm.Data != null && rm.Data.Count > 0)
- {
- //2021年6月26日 对一车联运的进行处理;用一次计量编号查二次计量数据,
- sql = @"select t3.actual_no actualNo, t3.prediction_no predictionNo, t3.car_no carNo, t3.matter_no matterNo, t3.matter_name matterName,
- t3.gross_weight grossWeight, t3.gross_time grossTime, t3.tare_weight tareWeight, t3.tare_time tareTime, t3.net_weight netWeight,
- t3.net_Time netTime, 'x' meterTypeNo, t3.meter_type_name meterTypeName, t3.spec_name specName,
- t3.forwarding_unit_name forwardingUnitName, t3.receiving_uint_name receivingUintName, t3.load_point_name loadPointName,
- t3.add_weight addWeight, '1' uploadFlag from meter_work_car_actual_first t2
- left join meter_work_car_actual t3 on t2.actual_first_no = t3.actual_first1_no
- where t2.prediction_combination in (select t.prediction_combination
- from meter_work_car_actual_first t
- where t3.value_flag = '0' and t.actual_first_no = '" + firstNo + @"' and
- instr(t.prediction_combination, '20') > 0) order by t3.net_time desc";
- RESTfulResult<List<MeterWorkCarActual>> rmLy = pbModelDbService.executeSqlDataWf(sql);
- if (rmLy.Succeed && rmLy.Data != null && rmLy.Data.Count == 1)
- {
- rm.Data = rmLy.Data; //一车联运,将毛重替换为净重数据
- }
- //若有毛重或者净重,找到对应数据的物料信息,若有,那么去找打印配置信息数据
- List<MeterWorkCarActual> mwa = rm.Data.Where(s => !string.IsNullOrEmpty(s.matterNo) && (s.meterTypeNo == "x" || s.meterTypeNo == "0")).ToList();
- if (mwa != null && mwa.Count > 0 && !string.IsNullOrEmpty(mwa[0].matterNo))
- {
- sql = @"select BASE_SPOT_NO baseSpotNo,
- load_point_no loadPointNo,
- matter_no matterNo,
- METER_TYPE_NO meterTypeNo,
- weight_type_name weightTypeName,
- PRINT_NUM printNum
- from METER_BASE_BILL_PRINT
- where matter_no = '" + mwa[0].matterNo + @"'
- and nvl(BASE_SPOT_NO, '" + PbCache.sportInfo.baseSpotNo + @"') = '" + PbCache.sportInfo.baseSpotNo + @"'
- and nvl(load_point_no, '" + (mwa[0].loadPointNo == null ? "1" : mwa[0].loadPointNo) + @"') = '" + (mwa[0].loadPointNo == null ? "1" : mwa[0].loadPointNo) + @"'";
- //lg.WriteLog(1, "打印第二个sql:" + sql); and nvl(METER_TYPE_NO, '" + PbCache.bussinessTypeCode + @"') = '" + PbCache.bussinessTypeCode + @"'
- //and nvl(METER_TYPE_NO, '') = ''
- PbModelDbService<List<MeterBaseBillPrint>> pbPrintService = new PbModelDbService<List<MeterBaseBillPrint>>();
- RESTfulResult<List<MeterBaseBillPrint>> rmPint = pbPrintService.executeSqlDataWf(sql);
- if (rmPint.Succeed)
- {
- if (rmPint.Data != null && rmPint.Data.Count > 0)
- {
- //若有净重信息:1毛重时间晚于皮重时间,则打印毛、皮、净重,2毛重早于皮重,打印皮、净
- //若只有毛重信息则打印毛重
- List<MeterBaseBillPrint> lGrossprint = rmPint.Data.Where(s => s.weightTypeName.Contains("毛")).ToList();
- List<MeterBaseBillPrint> lTarePrint = rmPint.Data.Where(s => s.weightTypeName.Contains("皮")).ToList();
- List<MeterBaseBillPrint> lNetprint = rmPint.Data.Where(s => s.weightTypeName.Contains("净")).ToList();
- List<MeterWorkCarActual> mwaChild = mwa.Where(s => s.meterTypeNo == "x").ToList();
- if (mwaChild != null && mwaChild.Count > 0) //若有净重信息
- {
- if (lTarePrint != null && lTarePrint.Count > 0)
- {
- //获取非毛,非净重信息如果没有则用的期限皮,此时不打,否则则打印
- MeterWorkCarActual mwca = rm.Data.Where(s => s.meterTypeNo != "x" && s.meterTypeNo != "0").FirstOrDefault();
- if (mwca != null)
- {
- PrintCls cls = new PrintCls();
- cls.printNum = (int)(lTarePrint[0].printNum == null ? 0 : lTarePrint[0].printNum.Value);
- cls.iType = 1;//皮重
- cls.printDb = mwca;
- prrintC.Add(cls);
- }
- }
- if (lGrossprint != null && lGrossprint.Count > 0)
- {
- //获取毛重信息
- MeterWorkCarActual mwca = rm.Data.Where(s => s.meterTypeNo == "0").FirstOrDefault();
- if (mwca != null)
- {
- PrintCls cls = new PrintCls();
- cls.printNum = (int)(lGrossprint[0].printNum == null ? 0 : lGrossprint[0].printNum.Value);
- cls.iType = 0;//毛重
- cls.printDb = mwca;
- prrintC.Add(cls);
- }
- }
- if (lNetprint != null && lNetprint.Count > 0)
- {
- //获取净重信息
- MeterWorkCarActual mwca = rm.Data.Where(s => s.meterTypeNo == "x").FirstOrDefault();
- if (mwca != null)
- {
- PrintCls cls = new PrintCls();
- cls.printNum = (int)(lNetprint[0].printNum == null ? 0 : lNetprint[0].printNum.Value);
- cls.iType = 2;//净重
- cls.printDb = mwca;
- prrintC.Add(cls);
- }
- }
- }
- else //只有毛重信息则打印毛重
- {
- if (lGrossprint != null && lGrossprint.Count > 0)
- {
- //获取毛重信息
- MeterWorkCarActual mwca = rm.Data.Where(s => s.meterTypeNo == "0").FirstOrDefault();
- if (mwca != null)
- {
- PrintCls cls = new PrintCls();
- cls.printNum = (int)(lGrossprint[0].printNum == null ? 0 : lGrossprint[0].printNum.Value);
- cls.iType = 0;//毛重
- cls.printDb = mwca;
- prrintC.Add(cls);
- }
- }
- }
- if (prrintC != null && prrintC.Count > 0)
- {
- FrmMessage frmMessage = FrmMess("是否打印第【1】张票据!", "打印");
- if (frmMessage.ShowDialog(this) == DialogResult.OK)
- {
- l.WriteLog(10, "车号【" + PbCache.lockCarNo + "】是否打印选择了【是】");
- l.WriteLog(15, PbCache.lockCarNo + "是否打印选择了【是】");
- strFirstNo = firstNo;
- //printDocument1.PrinterSettings.PrinterName = PbCache.sportInfo.printerName;//strPntSvrName;
- System.Drawing.Printing.PaperSize customSize1 = new System.Drawing.Printing.PaperSize("TestPaper", 398, 433); //101mm*110mm,换算成英寸
- printDocument1.DefaultPageSettings.PaperSize = customSize1;//将自定义的Papersize赋给PrintDocument
- System.Drawing.Printing.Margins marginss = new System.Drawing.Printing.Margins(0, 0, 0, 0);
- printDocument1.DefaultPageSettings.Margins = marginss;
- printDocument1.PrintController = new System.Drawing.Printing.StandardPrintController();
- foreach (PrintCls db in prrintC)
- {
- switch (db.printDb.meterTypeNo)
- {
- case "0": //毛
- db.qrCode = db.printDb.actualNo + "," + db.printDb.grossWeight + "," + "1";
- break;
- case "x": //净
- db.qrCode = db.printDb.actualNo + "," + db.printDb.netWeight + "," + "2";
- break;
- default: //皮
- db.qrCode = db.printDb.actualNo + "," + db.printDb.grossWeight + "," + "1";
- break;
- }
- RESTfulResult<string> rQRCode = workCarActualFirstService.doQRCodeWf(db.qrCode);
- db.qrCode = rQRCode.Data;
- for (int i = 0; i < db.printNum; i++)
- {
- if (i == 0)
- {
- printData = db;
- printDocument1.Print();
- l.WriteLog(10, "当前第" + (i + 1) + "次打印:" + printData.iType + " 车号:" + db.printDb.carNo + ",二维码:" + db.qrCode);
- }
- else
- {
- FrmMessage frmMessageContinue = FrmMess("已打印【" + i + "】张,是否继续打印第【" + (i + 1) + "】张票据!", "打印");
- if (frmMessageContinue.ShowDialog(this) == DialogResult.OK)
- {
- printData = db;
- printDocument1.Print();
- l.WriteLog(10, "当前第" + (i + 1) + "次打印:" + printData.iType + " 车号:" + db.printDb.carNo + ",二维码:" + db.qrCode);
- }
- else
- {
- l.WriteLog(10, "车号【" + PbCache.lockCarNo + "】第" + i + "次是否打印,选择了【否】");
- }
- }
- //printData = db;
- //printDocument1.Print();
- //lg.WriteLog(11, "当前打印:" + printData.iType + " 车号:" + db.printDb.carNo);
- }
- }
- }
- else
- {
- l.WriteLog(10, "车号【" + PbCache.lockCarNo + "】是否打印选择了【否】");
- l.WriteLog(15, PbCache.lockCarNo + "是否打印选择了【否】");
- }
- }
- }
- }
- else
- {
- l.WriteLog(10, "车号【" + PbCache.lockCarNo + "】获取打印配置数据信息异常sql:【" + sql + "】");
- }
- }
- }
- }
- else
- {
- l.WriteLog(10, "车号【" + PbCache.lockCarNo + "】获取计量数据信息异常sql:【" + sql + "】");
- }
- #endregion 获取打印信息,若需要打印则调用打印操作
- }
- catch (Exception ex)
- {
- l.WriteLog(10, "车号【" + PbCache.lockCarNo + "】打印异常" + ex);
- }
- }
- private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
- {
- try
- {
- if (printData != null && printData.printDb != null)
- {
- printClass.PrintAllPage(e, printData.printDb, printData.qrCode);
- /*
- //结净打印
- if (printData.iType == 2)
- {
- printClass.PrintPage(e, printData.printDb, PbCache.strQRCode);
- }
- else //非结净打印
- {
- printClass.PrintWgtPage(e, printData.printDb, PbCache.strQRCode);
- }
- //*/
- }
- }
- catch (Exception ex)
- {
- l.WriteLog(11, "打印异常" + ex);
- }
- }
- /// <summary>
- /// 重量大于500,直接打开主界面
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void timer1_Tick(object sender, EventArgs e)
- {
- //timer1.Stop();
- try
- {
- if (!isOpened && PbCache.collect?.weight > 500)
- {
- PbCache.bussinessTypeName = "";
- PbCache.bussinessTypeCode = "";
- if (fcc.Visible == false)
- {
- fcc.Visible = true;
- fcc.init();
- }
- }
- timer1.Interval = 1000;
- }
- catch (Exception ee)
- {
- //GlobalInstanceController.Instance.LastCallMessage = ee.Message;
- timer1.Interval = 1000;
- }
- //timer1.Start();
- }
- /// <summary>
- /// 操作Live表的数据:零点报警
- /// </summary>
- private void doOperateLive()
- {
- if (PbCache.collect_no == null)
- {
- return;
- }
- List<LiveData> ll = MemoClass.getWarnInfo(PbCache.collect_no);
- if (ll != null)
- {
- foreach (LiveData lv in ll)
- {
- switch (lv.Tagname.Replace(PbCache.collect_no, ""))
- {
- case "StaticStatus"://车辆检测 "0、东西方向激光均无报警;否则报警
- break;
- case "SwitchLight"://PLC红绿灯控制模式状态 "PLC有三种控制模式:1、自动、2、远控;3、检修
- break;
- case "LightWest"://红绿灯:1、为绿灯;2、为红灯;"
- break;
- case "ZeroWeightStatus": //0、其它,1、零点报警,红绿灯变红,
- if (((lv.Value ?? "0") + "").Equals("1"))
- {
- doInsertZeroAlarm();
- PbCache.isZeroAlarm = true;
- }
- else
- {
- PbCache.isZeroAlarm = false;
- }
- break;
- }
- }
- }
- }
- /// <summary>
- /// 操作Live表的数据:零点报警
- /// </summary>
- private void doLive()
- {
- if (PbCache.collect_no == null)
- {
- return;
- }
- List<LiveData> ll = MemoClass.getWarnInfo(PbCache.collect_no);
- MeterWorkMonitor mwm = new MeterWorkMonitor();
- mwm.pointNo = PbCache.sportInfo.baseSpotNo;
- mwm.redGreenLightState = "0";
- if (ll != null)
- {
- foreach (LiveData lv in ll)
- {
- switch (lv.Tagname.Replace(PbCache.collect_no, ""))
- {
- case "PowerStatus":
- mwm.powerState = lv.Value.ToString();
- break;
- case "PlcWatchDog":
- if (int.Parse(lv.Value.ToString()) >= 0 && int.Parse(lv.Value.ToString()) <= 0)
- {
- mwm.plcState = 0.ToString();
- }
- break;
- case "InfraredWest":
- if (lv.Value.ToString() == "2")
- {
- mwm.leftInfraredRayState = "0";
- }
- else
- {
- mwm.leftInfraredRayState = lv.Value.ToString();
- }
- break;
- case "InfraredEast":
- if (lv.Value.ToString() == "2")
- {
- mwm.rightInfraredRayState = "0";
- }
- else
- {
- mwm.rightInfraredRayState = lv.Value.ToString();
- }
- break;
- case "AmplifierState":
- mwm.amplifierState = lv.Value.ToString();
- break;
- case "LampState":
- if (lv.Value.ToString() == "2")
- {
- mwm.lampState = "0";
- }
- else
- {
- mwm.lampState = lv.Value.ToString();
- }
- break;
- case "InfraredLeft":
- if (lv.Value.ToString() == "2")
- {
- mwm.frontInfraredRayState = "0";
- }
- else
- {
- mwm.frontInfraredRayState = lv.Value.ToString();
- }
- break;
- case "InfraredRight":
- if (lv.Value.ToString() == "2")
- {
- mwm.rearInfraredRayState = "0";
- }
- else
- {
- mwm.rearInfraredRayState = lv.Value.ToString();
- }
- break;
- case "ZeroWeightStatus":
- mwm.zeroState = lv.Value.ToString();
- break;
- case "RfidState":
- mwm.rfidState = lv.Value.ToString();
- if (((lv.Value ?? "0") + "").Equals("1"))
- {
- doInsertZeroAlarm();
- PbCache.isZeroAlarm = true;
- }
- else
- {
- PbCache.isZeroAlarm = false;
- }
- break;
- }
- }
- }
- RESTfulResult<string> rms = meterWorkMonitor.doUpdateWf(mwm);
- }
- /// <summary>
- /// 新增零点报警的数据
- /// </summary>
- private void doInsertZeroAlarm()
- {
- if (!PbCache.isZeroAlarm)
- {
- PbCache.isZeroAlarm = true;
- MeterWorkZeroAlarm workZeroAlarm = new MeterWorkZeroAlarm();
- workZeroAlarm.zeroWeight = PbCache.collect.weight;
- workZeroAlarm.spotTypeNo = PbCache.sportInfo.spotTypeNo;
- workZeroAlarm.spotTypeName = PbCache.sportInfo.spotTypeName;
- workZeroAlarm.baseSpotNo = PbCache.sportInfo.baseSpotNo;
- workZeroAlarm.baseSpotName = PbCache.sportInfo.baseSpotName;
- workZeroAlarm.scalePointNo = PbCache.collect_no;
- workZeroAlarm.createManNo = PbCache.sportInfo.baseSpotNo;
- workZeroAlarm.createManName = PbCache.sportInfo.baseSpotName;
- RESTfulResult<String> rms = zeroAlarmService.doInsertZeroAlarm(workZeroAlarm);
- if (rms.Succeed)
- {
- l.WriteLog(20, "新增成功:" + workZeroAlarm.baseSpotName + ":" + workZeroAlarm.zeroWeight);
- }
- else
- {
- l.WriteLog(20, "操作失败:" + workZeroAlarm.baseSpotName + ":" + workZeroAlarm.zeroWeight + rms.Data + rms.Message);
- }
- }
- }
- private void button3_Click(object sender, EventArgs e)
- {
- string limsResult = "";
- JGLimsInterface gLimsInterface = new JGLimsInterface();
-
- }
- /// <summary>
- /// 查询重量信息,显示在界面上面
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button4_Click(object sender, EventArgs e)
- {
- try
- {
- string sqls = @"select '毛重:' || t.gross_weight / 1000 || ' T / 皮重:' || t.tare_weight / 1000 || ' T / 净重:' || t.net_weight / 1000 || ' T ' as text
- from meter_work_car_actual t where t.value_flag = '0' and T.Prediction_No = '" + txtPlanNo.Text + @"'";
- PbModelDbService<List<PbModelDb>> pbRelation = new PbModelDbService<List<PbModelDb>>();
- RESTfulResult<List<PbModelDb>> rmRelation = pbRelation.executeSqlDataWf(sqls);
- if (rmRelation.Succeed && rmRelation.Data != null && rmRelation.Data.Count > 0)
- {
- MessageBox.Show(rmRelation.Data[0].text);
- }
- else
- {
- MessageBox.Show("空");
- }
- }
- catch (Exception ex)
- {
-
- }
- }
- private void button1_Click(object sender, EventArgs e)
- {
- isOpened = false;
- testFlag = true;
- PbCache.isTest= true;
- testWgt = (int)numericUpDown1.Value;
- //CollectModel model = new CollectModel();
- //model.weight = testWgt;
- //PbCache.collect = model;
- testCarNo = textBox1.Text.Trim();
- testPlanNo = txtPlanNo.Text.Trim();
- }
- private void Form1_FormClosing(object sender, FormClosingEventArgs e)
- {
- collection.Stop();
- imageCurlControl.Stop();
- sweepCodeClass.CloseThread();
- sweepCodeClass2.CloseThread();
- timer1.Stop();
- timer1.Dispose();
- }
- private bool SystemUpdate(bool isMessage)
- {
- ReleaseList releaseList = new ReleaseList(Application.StartupPath + @"\" + GlobalVariable.Instance.ReleaseFileName);
- DownloadTools dt = new DownloadTools();
- try
- {
- bool isDownload = dt.IsDownloadFile(GlobalVariable.Instance.LocalPath, GlobalVariable.Instance.ReleaseURL, GlobalVariable.Instance.ReleaseFileName);
- if (!isDownload)
- {
- if (isMessage) MessageBox.Show("无法连接到远程主机!", Application.ProductName);
- return false;
- }
- }
- catch (Exception e)
- {
- MessageBox.Show(e.Message);
- }
- bool flag = this.CheckUpdate(releaseList);
- if (flag)
- {
- MessageBox.Show("有新版本,现在更新");
- string t = dt.DownloadFile(Application.StartupPath, GlobalVariable.Instance.ReleaseURL, GlobalVariable.Instance.ApplicationUpdater);
- this.Close();
- Application.Exit();
- GC.Collect();
- Process.Start(Application.StartupPath + @"\" + GlobalVariable.Instance.ApplicationUpdater);
- return true;
- }
- else
- {
- if (isMessage) MessageBox.Show("你的系统已经是最新版本,不需要更新!", Application.ProductName);
- return false;
- }
- }
- private bool CheckUpdate(ReleaseList localRelease)
- {
- try
- {
- string fileNameAll = Application.StartupPath + "\\" + GlobalVariable.Instance.LocalPath + "\\" + GlobalVariable.Instance.ReleaseFileName;
- ReleaseList remoteRelease = new ReleaseList(fileNameAll);
- return (((localRelease != null) && (remoteRelease != null)) && localRelease.ReleaseDate.CompareTo(remoteRelease.ReleaseDate) < 0);
- }
- catch (Exception exception)
- {
- MessageBox.Show(exception.Message);
- }
- return false;
- }
- #region PING IP
- /// <summary>
- /// ping ip,测试能否ping通
- /// </summary>
- /// <param name="strIP">IP地址</param>
- /// <returns></returns>
- private bool PingIp(string strIP)
- {
- bool bRet = false;
- try
- {
- Ping pingSend = new Ping();
- PingReply reply = pingSend.Send(strIP, 1000);
- if (reply.Status == IPStatus.Success)
- bRet = true;
- }
- catch (Exception)
- {
- bRet = false;
- }
- return bRet;
- }
- #endregion
- }
- }
|