| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389 |
- using com.hnshituo.core.webapp.vo;
- using Common;
- using Infragistics.Win;
- using Infragistics.Win.UltraWinGrid;
- using JC_MeasuringSystem;
- using MeterConditionLibrary;
- using MeterModelLibrary;
- using MeterModuleLibrary;
- using MeterPlugInLibrary;
- using MeterSceneLibrary;
- using System;
- using System.Collections.Generic;
- using System.Configuration;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Net;
- using System.Windows.Forms;
- namespace CarRemoteMeter
- {
- public partial class frmMeterMain2 : Form
- {
- public frmMeterMain2()
- {
- InitializeComponent();
- }
- //图片控制器含图片压缩及上传sftp
- //ImageControl imageControl = new ImageControl();
- /// <summary>
- /// 基础数据载入
- /// </summary>
- private BaseDbCls bd = new BaseDbCls();
- private Log l = Log.GetInstance();
- private string userId = "", userName = "";
- private CoreAppUser appUser = null;
- //实时表数据采集
- private DataCollectionControl collection = new DataCollectionControl();
- private bool bCollectionStart = false;
- #region 服务查询
- //预报查询
- private PreTrackScaleService service = new PreTrackScaleService();
- private PreTrackScale preTack = null;
- //与监控界面对接的表
- private MeterWorkMonitorService monitorService = new MeterWorkMonitorService();
- //实时在线写入,每隔2秒一次
- private MeterWorkOnlineService onlineService = new MeterWorkOnlineService();
- //验证是否可留期限皮
- private validTermTareCar termTareCar = new validTermTareCar();
- //留期限皮操作
- private MeterBaseTermTareDataService termTareDate = new MeterBaseTermTareDataService();
- //内倒业务处理
- private InnerRemoteMeter inner = new InnerRemoteMeter();
- //非内倒业务处理
- private SceneControl scene = new SceneControl();
- //历史皮重数据
- private MeterBaseHisTareDataService meterBaseHisTareData = new MeterBaseHisTareDataService();
- //计量实绩
- private MeterWorkCarActualService mwas = new MeterWorkCarActualService();
- //校秤记录
- private MeterWorkCalibrationMainService mainService = new MeterWorkCalibrationMainService();
- //附加重量
- private PerAddWeightService perAddWeight = new PerAddWeightService();
- //一次计量重量
- private MeterWorkCarActualFirst first = null;
- private MeterMonitorWeightService monitorWeightService = new MeterMonitorWeightService();
- private validCalibration vCalib = new validCalibration();
- //车号修正
- private CarNoModfiy modfiy = new CarNoModfiy();
- private string sPreNo = ""; //记录重量曲线变化
- private int preWgt = 0;//前一次重量,用于重量曲线
- //一次计量数据查询
- private MeterWorkCarActualFirstService workCarActualFirstService = new MeterWorkCarActualFirstService();
- //物料信息
- private MeterBaseMatterInfoService matterInfoService = new MeterBaseMatterInfoService(); //物料信息
- //联达过磅
- LianDaMeter2 lianda = new LianDaMeter2();
- int lianDaWgt = Convert.ToInt32(ConfigurationManager.AppSettings["lianDaWgt"]?.ToString() ?? "0");
- string lianDaPointNo = ConfigurationManager.AppSettings["lianDaPointNo"]?.ToString() ?? "00019";
- #endregion 服务查询
- #region 初始化数据
- private void frmMeterMain2_Load(object sender, EventArgs e)
- {
- setMsgInfo(btnInnerQuery, "false", "1");
- setMsgInfo(btnCheck, "false", "1");
- setMsgInfo(btnSave, "false", "1");
- setMsgInfo(btnTareWgt, "false", "1");
- setMsgInfo(btnCheckBalance, "false", "1");
- ValueList vlist = new ValueList();
- vlist.ValueListItems.Add("0", "批次预报");
- vlist.ValueListItems.Add("1", "单次预报");
- vlist.ValueListItems.Add("2", "联运预报");
- vlist.ValueListItems.Add("3", "分检预报");
- ultraGridYb.DisplayLayout.Bands[0].Columns["predictionType"].ValueList = vlist;
- timer1.Start();
- collection.EventDataCollectionArgs += new EventDataCollection(EventData);//数据采集
- userId = ((ST_MainForm)(this.MdiParent)).UserID;
- userName = ((ST_MainForm)(this.MdiParent)).UserName;
- appUser = ((ST_MainForm)(this.MdiParent)).AppUser;
- if (bd.setBaseDb() && bd.getBaseDb())
- {
- timer2.Start();
- lbPointName.Text = "";
- lbMeterMan.Text = userName;
- PbCache.isNotValid = true;
- //imageControl.Start();
- }
- else
- {
- MessageBox.Show("基础数据载入失败,请关闭界面并稍后打开,或联系管理员");
- return;
- }
- string _controlIp = GetIP();
- if (!_controlIp.Contains("192") && !_controlIp.Contains("168")) //只有在测试环境,【测试】按钮才有效
- {
- btnTest.Visible = false;
- btnTest.Enabled = false;
- txtTestWeight.Visible = false;
- txtTestWeight.Enabled = false;
- }
- //txtCarNo.LostFocus += new EventHandler(txtCarNo_KeyDown);
- lbWgt.LostFocus += new EventHandler(lbWgt_ValueChanged);
- }
- #endregion 初始化数据
- #region 数据采集部分
- private int iCounts = 0; //计数器
- private bool iWgtChange = true; //重量初次大于500
- private string preCarNo = "";//上次车号
- private string editCarNo = "";//修正车号
- private bool ndRemind = true;//内倒提示信息;提示当前是毛重或者皮重;
- /// <summary>
- /// 数据采集;由于自动接管,相当于程序入口
- /// </summary>
- private void EventData(object o, DataCollectionArgs e)
- {
- //测试 固定重量
- if (testFlage)
- {
- txtTestWeight.Text = "".Equals(txtTestWeight.Text.Trim()) ? "0" : txtTestWeight.Text.Trim();
- e.weight = Convert.ToInt32(txtTestWeight.Text);
- }
- //这里每隔0.5秒执行一次
- try
- {
- if (iCounts < 1200)
- {
- iCounts++;
- }
- else
- {
- iCounts = 0;
- try
- {
- //秤上没有车时,每隔10分钟获取一次基础数据
- if (e.weight < 500)
- {
- editCarNo = "";
- preCarNo = "";
- if (bd.setBaseDb())
- {
- l.WriteLog(0, "十分钟获取基础数据成功");
- }
- else
- {
- l.WriteLog(0, "十分钟获取基础数据失败");
- }
- }
- }
- catch (Exception ex)
- {
- l.WriteLog(0, "十分钟获取基础数据失败:" + ex.Message);
- }
- }
- #region
- PbCache.collect.pointid = PbCache.sportInfo.baseSpotNo;
- 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;
- #region 车号设置
- getFocusInfo(txtCarNo);
- if (!isFocus) //光标不在里面
- {
- if (strCbCarNo == "" || strTxtCarNo == "")
- {
- PbCache.collect.carno = e.carno;
- if (!string.IsNullOrEmpty(e.carno) && e.carno.Length > 1)
- {
- if (preCarNo == "")
- {
- preCarNo = e.carno;
- string methods = "";
- for (int i = 0; i <= PbCache.monitor.carMonitorLvl; i++)
- {
- methods += "CarNoTrustCorrect" + i + ",";
- }
- editCarNo = modfiy.CarNoCorrect(e.carno, methods.Substring(0, methods.Length - 1));
- }
- e.carno = editCarNo;
- setTxtCarNo(e.carno.Substring(1, e.carno.Length - 1));
- setCbCarNoInfo(e.carno.Substring(0, 1));
- QueryCarNo();
- }
- }
- else
- {
- if (!flagCarNo && (strCbCarNo + strTxtCarNo) != e.carno) //没有按回车,且车号不等于的时候
- {
- if (!string.IsNullOrEmpty(e.carno) && e.carno.Length > 1)
- {
- if (preCarNo == "" || preCarNo != e.carno)
- {
- preCarNo = e.carno;
- string methods = "";
- for (int i = 0; i <= PbCache.monitor.carMonitorLvl; i++)
- {
- methods += "CarNoTrustCorrect" + i + ",";
- }
- editCarNo = modfiy.CarNoCorrect(e.carno, methods.Substring(0, methods.Length - 1));
- }
- e.carno = editCarNo;
- PbCache.collect.carno = e.carno;
- setTxtCarNo(e.carno.Substring(1, e.carno.Length - 1));
- setCbCarNoInfo(e.carno.Substring(0, 1));
- QueryCarNo();
- }
- }
- else if (flagCarNo)
- {
- PbCache.collect.carno = strCbCarNo + strTxtCarNo;
- }
- }
- }
- #endregion 车号设置
- //重量大于500的情况下
- if (e.weight > 500)
- {
- if (!PbCache.isLockFrm)
- {
- ucWeightT1.setWgt(PbCache.collect.weight);
- ucWeightT1.setStable(PbCache.collect.weightStatus != 1 ? true : false);
- ucWeightT1.setExceed(PbCache.collect.weight > PbCache.range.upperRange ? false : true);
- PbCache.addWgt = dAddWgt;
- if (first != null)
- {
- if (PbCache.collect.weight < first.meterWeight.Value)
- {
- setMsgInfo(txtTare, PbCache.collect.weight + "", "");
- setMsgInfo(txtGroess, first.meterWeight.Value + "", "");
- }
- else
- {
- setMsgInfo(txtGroess, PbCache.collect.weight + "", "");
- setMsgInfo(txtTare, first.meterWeight.Value + "", "");
- }
- double dbAddWgt = 0;
- if (first.addWeight != null && first.addWeight.Value > 0)
- {
- dbAddWgt = first.addWeight.Value;
- }
- else
- {
- dbAddWgt = dAddWgt;
- }
- //PbCache.addWgt = dbAddWgt;
- setMsgInfo(txtNet, Math.Abs(PbCache.collect.weight - first.meterWeight.Value) - dbAddWgt + "", "");
- }
- }
- if (iWgtChange)
- {
- setMsgInfo(btnInnerQuery, "true", "1");
- setMsgInfo(btnSave, "true", "1");
- setMsgInfo(btnTareWgt, "true", "1");
- setMsgInfo(btnCheckBalance, "true", "1");
- setMsgInfo(btnCheck, "true", "1");
- setReadOnlyInfo(txtPREDICTION_NO, "false", "0");
- }
- if (PbCache.dtStartTime == null)
- PbCache.dtStartTime = DateTime.Now;
- //每隔1秒刷一次计量实时监控表数据值
- if (iCounts % 2 == 0)
- {
- #region 每隔1秒写入一次重量曲线
- try
- {
- if (preWgt != e.weight)
- {
- preWgt = e.weight;
- sPreNo = PbCache.sportInfo.baseSpotNo + DateTime.Now.ToString("yyyyMMddHHmmssfff");
- monitorWeightService.doAddWf(new MeterMonitorWeight
- {
- weightNo = sPreNo,
- baseSpotNo = PbCache.sportInfo.baseSpotNo,
- baseSpotName = PbCache.sportInfo.baseSpotName,
- collectWeight = e.weight + "",
- collectStartTime = PbCache.dtStartTime.Value,
- collectEndTime = DateTime.Now,
- spotTypeNo = "001002001",
- spotTypeName = "汽车衡",
- actualFirstNo = PbCache.actualFirstNo
- });
- }
- else
- {
- if (!string.IsNullOrEmpty(sPreNo))
- {
- monitorWeightService.doUpdateWf(new MeterMonitorWeight
- {
- weightNo = sPreNo,
- collectEndTime = DateTime.Now
- });
- }
- }
- }
- catch { }
- #endregion 每隔1秒写入一次重量曲线
- switch (e.parkStatus)
- {
- case 1:
- setPicQRed(true);
- setPicHRed(false);
- break;
- case 2:
- setPicQRed(false);
- setPicHRed(true);
- break;
- case 3:
- setPicQRed(true);
- setPicHRed(true);
- break;
- default:
- setPicQRed(false);
- setPicHRed(false);
- break;
- }
- }
- iWgtChange = false;
- }
- else
- {
- if (flagStart && strIsRemote == "0")
- {
- Clean();
- }
- else
- {
- CleanForm();
- }
- }
- #endregion 数据采集部分
- }
- catch (Exception ex)
- {
- l.WriteLog(0, "frmMeterMain2.EventData异常3:" + ex.Message);
- }
- }
- #endregion
- #region 从接管到未的时候清理下数据
- //清理一次数据
- private void Clean()
- {
- if (PbCache.sportInfo == null || string.IsNullOrEmpty(PbCache.sportInfo.baseSpotNo)) return;
- MeterWorkMonitor mwmUpdate = new MeterWorkMonitor
- {
- pointNo = PbCache.sportInfo.baseSpotNo,
- validWgt = "1",
- validCarno = "1",
- validTareTime = "1",
- validMatTime = "1",
- validTimeInterval = "1",
- validParkStatus = "1",
- validExceedWgt = "1",
- validPredictionDiff = "1",
- validLianda = "1",
- validMatClick = "1",
- setCar = "",
- rfidCar = "",
- photoCar = "",
- scanCar = "",
- editCar = "",
- carErr = "0",
- wgtErr = "0",
- stopOverTime = "0",
- msgInfo = "",
- //isTakeOver = "0",
- //userNo = "",
- ledWriter = ""
- };
- if (bVoice)
- {
- mwmUpdate.isHelp = "0";
- }
- //如果为1则是监控点击的远程计量,这个时候是不能清理的
- if (strIsRemote == "0")
- {
- mwmUpdate.userNo = "";
- mwmUpdate.isTakeOver = "0";
- }
- RESTfulResult<string> rm = monitorService.doUpdateWf(mwmUpdate);
- if (!rm.Succeed)
- {
- l.WriteLog(5, "初始化远程计量信息失败");
- }
- else
- {
- RESTfulResult<string> rmx = onlineService.doSaveWf(new MeterWorkOnline { userId = userId, workFlag = "0" });
- if (rmx.Succeed)
- {
- CleanForm();
- CleanCloseDb();
- }
- else
- {
- l.WriteLog(5, "初始化在线接管状态失败");
- }
- }
- }
- //如果ResultMessage为true或者false,则sType 为0的时候readonly 1为enable 2为visable
- public void setMsgInfo(Control control, string ResultMessage, string sType)
- {
- setMsgMsg(control, ResultMessage, sType);
- }
- /// <summary>
- /// 如果ResultMessage为true或者false,则sType 为0的时候readonly 1为enable 2为visable 3为check
- /// </summary>
- /// <param name="control"></param>
- /// <param name="ResultMessage"></param>
- /// <param name="sType"></param>
- private void setMsgMsg(Control control, string ResultMessage, string sType)
- {
- if (control.InvokeRequired)
- {
- Action<Control, string, string> action = new Action<Control, string, string>(setMsgInfo);
- Invoke(action, new object[] { control, ResultMessage, sType });
- }
- else
- {
- if (ResultMessage != "true" && ResultMessage != "false")
- {
- control.Text = ResultMessage == null ? "" : ResultMessage.Replace("请远程求助", "").Replace(",请点击语音求助", "");
- }
- else
- {
- switch (sType)
- {
- case "1":
- control.Enabled = ResultMessage == "true" ? true : false;
- ; break;
- case "2":
- control.Visible = ResultMessage == "true" ? true : false;
- ; break;
- case "3":
- ((CheckBox)control).Checked = ResultMessage == "true" ? true : false;
- break;
- default: break;
- }
- }
- }
- }
- public void setListBoxInfo(ListBox control)
- {
- setListBoxMsg(control);
- }
- /// <summary>
- /// 如果ResultMessage为true或者false,则sType 为0的时候readonly 1为enable 2为visable
- /// </summary>
- /// <param name="control"></param>
- /// <param name="ResultMessage"></param>
- /// <param name="sType"></param>
- private void setListBoxMsg(ListBox control)
- {
- if (control.InvokeRequired)
- {
- Action<ListBox> action = new Action<ListBox>(setListBoxInfo);
- Invoke(action, new object[] { control });
- }
- else
- {
- control.Items.Clear();
- }
- }
- /// <summary>
- /// 设置readonly
- /// </summary>
- /// <param name="control"></param>
- /// <param name="sType">0为textbox 1为button</param>
- public void setReadOnlyInfo(Control control, string resultMsg, string sType)
- {
- setReadOnlyMsg(control, resultMsg, sType);
- }
- /// <summary>
- /// 如果ResultMessage为true或者false,则sType 为0的时候readonly 1为enable 2为visable
- /// </summary>
- /// <param name="control"></param>
- /// <param name="ResultMessage"></param>
- /// <param name="sType"></param>
- private void setReadOnlyMsg(Control control, string resultMsg, string sType)
- {
- if (control.InvokeRequired)
- {
- Action<Control, string, string> action = new Action<Control, string, string>(setReadOnlyInfo);
- Invoke(action, new object[] { control, resultMsg, sType });
- }
- else
- {
- switch (sType)
- {
- case "0":
- ((TextBox)control).ReadOnly = resultMsg == "true" ? true : false;
- break;
- }
- }
- }
- public void setPanelRemovenfo(Panel control)
- {
- setPanelRemoveMsg(control);
- }
- /// <summary>
- /// 如果ResultMessage为true或者false,则sType 为0的时候readonly 1为enable 2为visable
- /// </summary>
- /// <param name="control"></param>
- /// <param name="ResultMessage"></param>
- /// <param name="sType"></param>
- private void setPanelRemoveMsg(Panel p)
- {
- if (p.InvokeRequired)
- {
- Action<Panel> action = new Action<Panel>(setPanelRemovenfo);
- Invoke(action, new object[] { p });
- }
- else
- {
- for (int i = p.Controls.Count - 1; i >= 0; i--)
- {
- p.Controls.RemoveAt(i);
- }
- }
- }
- public void setGridInfo(UltraGrid control, DataTable dt1, DataTable dt2)
- {
- setGridMsg(control, dt1, dt2);
- }
- /// <summary>
- /// 如果ResultMessage为true或者false,则sType 为0的时候readonly 1为enable 2为visable
- /// </summary>
- /// <param name="control"></param>
- /// <param name="ResultMessage"></param>
- /// <param name="sType"></param>
- private void setGridMsg(UltraGrid p, DataTable dt1, DataTable dt2)
- {
- if (p.InvokeRequired)
- {
- Action<UltraGrid, DataTable, DataTable> action = new Action<UltraGrid, DataTable, DataTable>(setGridInfo);
- Invoke(action, new object[] { p, dt1, dt2 });
- }
- else
- {
- ClsControlPack.CopyDataToDatatable(ref dt1, ref dt2, true);
- ClsControlPack.RefreshAndAutoSize(p);
- }
- }
- private void CleanCloseDb()
- {
- //*****************这里需要将语音对讲/视频都关闭*******************
- //退出语音登录
- try
- {
- VoiceClose();
- IPVideoClose();
- }
- catch (Exception ex)
- {
- }
- ls = null;
- //*****************************************************************
- flagCarNo = false;
- setMsgInfo(plImgShow, "false", "2");
- DataTable dtJld = dtJGPointInfo.Clone();
- setGridInfo(ultraGridPW, dtJld, this.dtJGPointInfo);
- setMsgInfo(lbPointName, "", "");
- setMsgInfo(lbMeterMan, "", "");
- PbCache.Load();
- PbCache.sportInfo = null;
- PbCache.videoInfo = null;
- PbCache.videoChild = null;
- CarCache.cameraShots = null;
- PbCache.range = null;
- PbCache.relations = null;
- setPanelRemovenfo(panel1);
- bCollectionStart = false;
- //关闭采集进程
- collection.Stop();
- }
- private void CleanForm()
- {
- editCarNo = "";
- preCarNo = "";
- sPreNo = "";
- preWgt = 0;
- ndRemind = true;
- ls = null;
- preTack = null;
- iWgtChange = true;
- PbCache.dtStartTime = null;
- PbCache.isTermTare = false;
- dAddWgt = 0;
- PbCache.addWgt = 0;
- first = null;
- PbCache.isLockFrm = false;
- PbCache.lockWgt = 0;
- PbCache.lockCarNo = "";
- strCbCarNo = "";
- strTxtCarNo = "";
- strType = "0";
- PbCache.ResultMessage = "";
- setMsgInfo(btnInnerQuery, "false", "1");
- setMsgInfo(btnCheck, "false", "1");
- setMsgInfo(btnSave, "false", "1");
- setMsgInfo(btnTareWgt, "false", "1");
- setMsgInfo(btnCheckBalance, "false", "1");
- setMsgInfo(txtGroess, "", "");
- setMsgInfo(txtTare, "", "");
- setMsgInfo(txtNet, "", "");
- setMsgInfo(lbWgt, "", "");
- setMsgInfo(txtPage, "", "");
- setCbCarNoInfo("");
- setTxtCarNoInfo("");
- ucWeightT1.setWgt(0);
- ucWeightT1.setStable(true);
- ucWeightT1.setExceed(true);
- setPicQRed(false);
- setPicHRed(false);
- setPreTrackInfo(new PreTrackScale());
- setHistWgt(null, null);
- setReadOnlyInfo(txtPREDICTION_NO, "true", "0");
- setListBoxInfo(lb1);
- setListBoxInfo(lb2);
- setMsgInfo(txtMsgInfo, "", "");
- DataTable dtYb = dtPreTrackScale.Clone();
- setGridInfo(ultraGridYb, dtYb, this.dtPreTrackScale);
- DataTable dtSj = dataTable1.Clone();
- setGridInfo(ultraGridSj, dtSj, this.dataTable1);
- DataTable dtQxp = dtTare.Clone();
- setGridInfo(ultraGridTare, dtQxp, this.dtTare);
- DataTable dtJl = dtCalibration.Clone();
- setGridInfo(ultraGridJl, dtJl, this.dtCalibration);
- }
- #endregion
- #region button按钮事件
- private bool flagStart = true;
- private bool testFlage = false; //若为true,则重量就是输入的重量
- /// <summary>
- /// 自动派位
- /// </summary>
- private void btnStart_Click(object sender, EventArgs e)
- {
- if (btnStart.Text == "自动派位")
- {
- if (PbCache.sportInfo != null)
- {
- btnStart.BackColor = Color.Red;
- btnStart.Text = "取消接管";
- timer2.Stop();
- flagStart = false;
- }
- }
- else
- {
- strIsRemote = "0";
- if (PbCache.sportInfo != null)
- {
- Clean();
- }
- try
- {
- bCollectionStart = false;
- btnStart.BackColor = Color.DodgerBlue;
- btnStart.Text = "自动派位";
- timer2.Start();
- flagStart = true;
- }
- catch { }
- }
- }
- private bool bGQ = false;
- private void btnGQ_Click(object sender, EventArgs e)
- {
- if (btnGQ.Text == "挂起")
- {
- btnGQ.Text = "取消挂起";
- btnGQ.BackColor = Color.Red;
- bGQ = true;
- btnStart.Enabled = false;
- btnStart.BackColor = Color.DodgerBlue;
- btnStart.Text = "自动派位";
- timer2.Stop();
- flagStart = false;
- strIsRemote = "0";
- if (PbCache.sportInfo != null)
- {
- Clean();
- }
- try
- {
- //让用户处于掉线状态
- string sql = @"update Meter_Work_Online set last_time=sysdate-1 where user_id='" + appUser.userid + "'";
- PbModelDbService<string> pb = new PbModelDbService<string>();
- RESTfulResult<string> rm = pb.executeSqlDataWf(sql);
- }
- catch { }
- }
- else
- {
- bCollectionStart = false;
- btnGQ.Text = "挂起"; //改为非挂起状态
- btnGQ.BackColor = Color.DodgerBlue;
- bGQ = false;
- btnStart.Enabled = true;
- timer2.Start();
- flagStart = true;
- }
- }
- private List<string> ls = new List<string>();
- private double dAddWgt = 0;
- /// <summary>
- /// 选择器具
- /// </summary>
- private void btnCheck_Click(object sender, EventArgs e)
- {
- double dWgt = 0;
- //if (PbCache.collect.weightStatus == 0 && PbCache.collect.weight > 500)
- {
- frmApplianceCheck fac = new frmApplianceCheck();
- fac.ltAddWeightNo = ls == null ? null : ls;
- if (fac.ShowDialog() == DialogResult.OK)
- {
- dAddWgt = 0;
- lbUTENSIL_UTENSIL_NAME.Text = "";
- lbWgt.Text = "0";
- lb1.Items.Clear();
- lb2.Items.Clear();
- DataTable dt = fac.dtChecked;
- ls = fac.ltAddWeightNo;
- if (dt != null && dt.Rows.Count > 0)
- {
- foreach (DataRow dr in dt.Rows)
- {
- if (lbUTENSIL_UTENSIL_NAME.Text == "")
- {
- lbUTENSIL_UTENSIL_NAME.Text = dr["utensilUtensilName"].ToString();
- }
- if (lb1.Items.Count < 7)
- {
- lb1.Items.Add(dr["utensilNo"].ToString());
- }
- else
- {
- lb2.Items.Add(dr["utensilNo"].ToString());
- }
- dWgt += Convert.ToDouble(dr["utensilWeight"].ToString());
- }
- lbWgt.Text = dWgt + "";
- dAddWgt = dWgt;
- }
- }
- if (txtGroess.Text.Trim() != "" && txtTare.Text.Trim() != "")
- {
- txtNet.Text = (Convert.ToInt32(txtGroess.Text.Trim()) - Convert.ToInt32(txtTare.Text.Trim()) - dWgt) + "";
- }
- }
- }
- #region 对讲代码
- /// <summary>
- /// 硬盘录像机登录
- /// </summary>
- private DhCameraShot cameraShotMain = new DhCameraShot();
- /// <summary>
- /// 必须先打开连接
- /// </summary>
- private bool GetIPVideo(MeterBaseVideoinfo video)
- {
- try
- {
- cameraShotMain.ip = video.videoip;
- cameraShotMain.port = video.vdoPort;
- cameraShotMain.uid = video.vdoUser;
- cameraShotMain.pwd = video.vdoPwd;
- cameraShotMain.Connection();
- }
- catch (Exception ex)
- {
- setMsgInfo(txtMsgInfo, "视频连接打开失败:" + ex.Message, "");
- //MessageBox.Show(ex.Message);
- return false;
- }
- return true;
- }
- private bool bVoice = false;
- /// <summary>
- /// 必须先打开视频,然后再打开语音
- /// </summary>
- private void VoiceOpen()
- {
- try
- {
- if (cameraShotMain.StartTalk())
- {
- btnOpenVoice.Text = "关闭对讲";
- bVoice = true;
- }
- }
- catch (Exception ex)
- {
- setMsgInfo(txtMsgInfo, "打开语音失败:" + ex.Message, "");
- //MessageBox.Show("打开语音失败:" + ex.Message);
- }
- }
- /// <summary>
- /// 关闭语音对讲
- /// </summary>
- private void VoiceClose()
- {
- try
- {
- if (cameraShotMain.StopTalk())
- {
- setMsgInfo(btnOpenVoice, "打开对讲", "");
- bVoice = false;
- }
- }
- catch (Exception ex)
- {
- setMsgInfo(txtMsgInfo, "打开对讲失败:" + ex.Message, "");
- //MessageBox.Show(ex.Message);
- }
- }
- /// <summary>
- /// 关闭视频
- /// </summary>
- private void IPVideoClose()
- {
- try
- {
- cameraShotMain.Close();
- }
- catch (Exception ex)
- {
- setMsgInfo(txtMsgInfo, "关闭对讲失败:" + ex.Message, "");
- //MessageBox.Show(ex.Message);
- }
- }
- #endregion
- /// <summary>
- /// 对讲
- /// </summary>
- private void btnOpenVoice_Click(object sender, EventArgs e)
- {
- if (panel1.Controls.Count > 0)
- {
- if (btnOpenVoice.Text == "打开对讲")
- {
- VoiceOpen();
- }
- else
- {
- VoiceClose();
- }
- }
- }
- /// <summary>
- /// 校秤
- /// </summary>
- private void btnCheckBalance_Click(object sender, EventArgs e)
- {
- //if (PbCache.collect.weightStatus == 0 && PbCache.collect.weight > 500)
- {
- PbCache.isLockFrm = true;
- if (PbCache.collect != null)
- {
- txtMsgInfo.Text = "";
- PbCache.lockWgt = PbCache.collect.weight;
- frmCalibration fc = new frmCalibration();
- fc.userId = userId;
- fc.userName = userName;
- if (fc.ShowDialog() == DialogResult.OK)
- {
- txtMsgInfo.Text = "校秤完成";
- PbCache.isLockFrm = false;
- //Clean();
- }
- else
- {
- PbCache.isLockFrm = false;
- }
- }
- }
- }
- /// <summary>
- /// 期限皮
- /// </summary>
- private void btnTareWgt_Click(object sender, EventArgs e)
- {
- //if (PbCache.collect.weightStatus == 0 && PbCache.collect.weight > 500)
- {
- if (string.IsNullOrEmpty(strCbCarNo + strTxtCarNo))
- {
- MessageBox.Show("请先输入一个车号");
- return;
- }
- PbCache.lockWgt = PbCache.collect.weight;
- //是否可留期限皮
- if (!termTareCar.ValidMethod(PbCache.collect.carno))
- {
- if (PbCache.ResultMessage.Contains("无法留期限皮"))
- {
- DialogResult drs = MessageBox.Show(PbCache.ResultMessage.Replace("无法留期限皮", "") + " 确认留期限皮吗?", "提示", MessageBoxButtons.OKCancel);
- if (drs != DialogResult.OK)
- return;
- }
- else
- {
- txtMsgInfo.Text = PbCache.ResultMessage;
- //MessageBox.Show(PbCache.ResultMessage);
- return;
- }
- }
- else
- {
- DialogResult dr = MessageBox.Show("确认留期限皮吗?", "提示", MessageBoxButtons.OKCancel);
- if (dr != DialogResult.OK)
- return;
- }
- txtMsgInfo.Text = "称重保存中,请稍等......";
- PbCache.isLockFrm = true;
- PbCache.lockCarNo = strCbCarNo + strTxtCarNo;
- MeterBaseTermTareData mbttd = new MeterBaseTermTareData();
- mbttd.baseSpotNo = PbCache.sportInfo.baseSpotNo;
- mbttd.baseSpotName = PbCache.sportInfo.baseSpotName;
- mbttd.carNo = PbCache.collect.carno;
- mbttd.meterWeight = PbCache.lockWgt;
- mbttd.valueFlag = "0";
- mbttd.createTime = DateTime.Now;
- mbttd.createManNo = PbCache.sportInfo.baseSpotNo;
- mbttd.createManName = PbCache.sportInfo.baseSpotName;
- mbttd.meterTime = mbttd.createTime.Value;
- mbttd.startTime = mbttd.createTime.Value;
- //操作日志
- MeterMonitorNote monitorNote = new MeterMonitorNote();
- monitorNote.baseSpotNo = mbttd.baseSpotNo;
- monitorNote.baseSpotName = mbttd.baseSpotName;
- monitorNote.operationContent = string.Format("保存期限皮重");
- monitorNote.operationTime = mbttd.createTime.Value.ToString("yyyy-MM-dd HH:mm:ss");
- monitorNote.carNo = mbttd.carNo;
- monitorNote.meterNoteSource = "4";
- monitorNote.meterManNo = userId;
- monitorNote.meterManName = userName;
- //期限皮重数据保存
- RESTfulResult<string> RESTfulResult = termTareDate.doSaveWf(mbttd, monitorNote);
- if (RESTfulResult.Succeed)
- {
- txtMsgInfo.Text = "期限皮重保存成功!";
- //MessageBox.Show("期限皮重保存成功!");
- //Clean();
- }
- else
- {
- txtMsgInfo.Text = "期限皮重保存失败!" + RESTfulResult.ResultMessage;
- //MessageBox.Show("保存失败:" + RESTfulResult.ResultMessage);
- }
- }
- }
- /// <summary>
- /// 保存
- /// </summary>
- private void btnSave_Click(object sender, EventArgs e)
- {
- //if (PbCache.collect.weightStatus == 0 && PbCache.collect.weight > 500)
- {
- if (string.IsNullOrEmpty(strCbCarNo + strTxtCarNo))
- {
- MessageBox.Show("请先输入一个车号");
- return;
- }
- txtMsgInfo.Text = "";
- DialogResult dr = MessageBox.Show("是否确认保存当前计量数据?", "提示", MessageBoxButtons.OKCancel);
- #region 增加校秤判断
- string msgInfo = "";
- bool isCalibration = vCalib.ValidMethod(new MeterWorkCalibrationMain { baseSpotNo = PbCache.sportInfo.baseSpotNo, valueFlag = "2" }, out msgInfo);
- if (!isCalibration)
- {
- MeterBaseCalibraNumRel calibraNumRel = PbCache.ltBaseCalibraNumRel.Where(s => s.baseSpotNo == PbCache.sportInfo.baseSpotNo).FirstOrDefault();
- if (calibraNumRel == null || calibraNumRel.isMeter == "否" || PbCache.collect.weight > (calibraNumRel.upWeight == null ? 0 : calibraNumRel.upWeight.Value))
- {
- txtMsgInfo.Text = "未校秤无法计量";
- return;
- }
- }
- #endregion
- PbCache.isLockFrm = true;
- PbCache.lockWgt = PbCache.collect.weight;
- PbCache.lockCarNo = strCbCarNo + strTxtCarNo;
- btnSave.Enabled = false;
- //PbCache.addWgt = lbWgt.Text.Trim() == "" ? 0 : Convert.ToDouble(lbWgt.Text.Trim());
- PbCache.addWgt = Convert.ToDouble(string.IsNullOrEmpty(lbWgt.Text) ? 0 : lbWgt.Value);
- if (dr == DialogResult.OK)
- {
- txtMsgInfo.Text = "称重保存中,请稍等......";
- btnSave.Enabled = false;
- try
- {
- bool flag = false;
- string strMsg = "";
- #region =================eason add 2021-11-26联达业务=====================
- bool fLianda = false;
- RESTfulResult<MeterBaseMatterInfo> result = matterInfoService.doQueryId(preTack.matterNo);
- if (result.Succeed)
- {
- RESTfulResult<List<MeterWorkCarActualFirst>> resultFst = workCarActualFirstService.doQueryWf(new MeterWorkCarActualFirst { carNo = (cbCarNo.Text.Trim() + txtCarNo.Text.Trim()), valueFlag = "1" });
- //计量实绩
- CommonPage<MeterWorkCarActual> cpc = new CommonPage<MeterWorkCarActual>();
- MeterWorkCarActual mwca = new MeterWorkCarActual();
- mwca.carNo = (cbCarNo.Text.Trim() + txtCarNo.Text.Trim());
- mwca.predictionNo = txtPREDICTION_NO.Text.Trim();
- cpc.param = mwca;
- cpc.pageSize = 1;
- RESTfulResult<List<MeterWorkCarActual>> rm = mwas.doQueryOneWf(cpc);
- if (!resultFst.Succeed)
- {
- throw new Exception("获取一次计量数据失败!");
- }
- if (PbCache.sportInfo?.baseSpotNo == lianDaPointNo)
- {
- //1.1是联达秤点则判断是不是联达物料
- if (result?.Data?.isLianda == "1")
- {
- //1.1.1是联达物料则判断是否存在未结净的数据,若存在则该数据必须与当前预报编号一致,不一致则提示错误,
- //一致则看结净表中存在一条预报编号一致的正常结净数据若存在则联达结净,若不存在正常结净的数据则提示先去过其它磅
- if (resultFst.Data == null)
- {
- //=====================直接联达过毛重即可=====================
- rtInfo ri = lianda.MeterMethod(preTack, appUser, lianDaWgt);
- fLianda = true;
- flag = ri.result;
- strMsg = PbCache.ResultMessage;
- }
- else if (resultFst.Data.Count == 1)
- {
- //若存在则该数据必须与当前预报编号一致,不一致则提示错误
- if (resultFst.Data[0].predictionNo == $"{preTack.predictionNo}_")
- {
- if (rm.Succeed)
- {
- if (rm.Data == null || rm.Data.Count == 0)
- {
- throw new Exception("请先去其它秤点完成一、二次计量,最后再来联达过皮重");
- }
- else
- {
- //=====================联达结净=====================
- rtInfo ri = lianda.MeterMethod(preTack, appUser, lianDaWgt);
- fLianda = true;
- flag = ri.result;
- strMsg = PbCache.ResultMessage;
- }
- }
- else
- {
- throw new Exception("获取结净数据失败!");
- }
- }
- else
- {
- throw new Exception($"存在一条未完成计量的联达数据,预报编号为{resultFst.Data[0].predictionNo}");
- }
- }
- else
- {
- //可能是一条联达的未结净,然后一条正常过磅的未结净,需要先将未结净的结净再来过联达的
- throw new Exception("存在多条未结净的数据");
- }
- }
- else
- {
- //1.1.2不是联达物料则看是否存在未结净的联达物料
- if (resultFst.Data != null)
- {
- //1.1.2.1存在未结净的物料若不是同一个预报编号则提示
- if (resultFst.Data.Count == 1)
- {
- if (resultFst.Data[0].predictionNo != preTack.predictionNo)
- {
- throw new Exception("当前过磅预报与未结净预报编号不一致");
- }
- //否则正常结净
- }
- else
- {
- throw new Exception("存在多条未结净的数据");
- }
- }
- //1.1.2.2不存在未结净的物料则按正常过磅走
- }
- }
- else
- {
- //1.2不是联达秤点则判断是不是联达物料
- if (result?.Data?.isLianda == "1")
- {
- //如果是联达的物料,则判断是否存在该预报对应的未结净的联达数据,若存在则结净,不存在则提示 这里严谨点的话,得根据车号未结净的判断
- if (resultFst.Data == null)
- {
- throw new Exception("当前物料为联达物料请先到联达秤过磅");
- }
- else if (resultFst.Data.Count == 1)
- {
- //如果预报编号相同,且是联达的预报编号,则让其正常走过毛的流程,若不相同则提示
- if (resultFst.Data[0].predictionNo != $"{preTack.predictionNo}_")
- {
- throw new Exception("当前过磅预报与未结净预报编号不一致");
- }
- //正常过毛重即可
- }
- else if (resultFst.Data.Count == 2)
- {
- //如果两条数据分别是联达的及一条普通毛则走结净,否则提示错误
- int icnt = 0;
- foreach (MeterWorkCarActualFirst firstD in resultFst.Data)
- {
- if (firstD.predictionNo == preTack.predictionNo || firstD.predictionNo == $"{preTack.predictionNo}_")
- {
- icnt++;
- }
- }
- if (icnt != 2)
- {
- throw new Exception("存在多条未结净的数据");
- }
- //否则正常结净即可
- }
- else
- {
- throw new Exception("存在多条未结净的数据");
- }
- }
- else
- {
- //不是联达的物料则看是否存在未结净的计量数据,若存在则必须预报编号一致否则提示错误,若不存在还是往后走
- if (resultFst.Data != null)
- {
- if (resultFst.Data.Count == 1)
- {
- if (resultFst.Data[0].predictionNo != preTack.predictionNo)
- {
- throw new Exception("当前过磅预报与未结净预报编号不一致");
- }
- //继续走结净流程
- }
- else
- {
- throw new Exception("存在多条未结净的数据");
- }
- }
- //走一次计量流程
- }
- }
- }
- else
- {
- throw new Exception("获取物料信息失败!");
- }
- if (!fLianda)
- {
- #endregion ===============================================================
- //没有业务编号或者业务编号不是非内倒业务则认为是内倒
- if (strType == "0")
- {
- rtInfo ri = null;
- //获取稳定的重量,车号,计量信息等,然后进行计量业务操作; preTack仅有一个来源即输入业务号的时候,否则全是皮重;
- if (preTack != null)
- {
- ri = inner.MeterMethod(new InnerMeterInfo
- {
- carNo = cbCarNo.Text.Trim() + txtCarNo.Text.Trim(),
- batchNo = "",
- forwardingUnitNo = preTack.forwardingUnitNo,
- forwardingUnitName = preTack.forwardingUnitName,
- matterNo = preTack.matterNo,
- matterName = preTack.matterName,
- receivingUintName = preTack.receivingUintName,
- receivingUintNo = preTack.receivingUintNo,
- meterTypeNo = "001006003",
- meterTypeName = PbCache.businessType.Where(s => s.baseCode == "001006003").FirstOrDefault().baseName,
- predictionNo = txtPREDICTION_NO.Text.Trim()
- }, appUser);
- }
- else
- {
- ri = inner.MeterMethod(new InnerMeterInfo
- {
- carNo = cbCarNo.Text.Trim() + txtCarNo.Text.Trim(),
- batchNo = "",
- forwardingUnitNo = "",
- forwardingUnitName = "",
- matterNo = "",
- matterName = "",
- receivingUintName = "",
- receivingUintNo = "",
- meterTypeNo = "001006003",
- meterTypeName = PbCache.businessType.Where(s => s.baseCode == "001006003").FirstOrDefault().baseName,
- predictionNo = ""
- }, appUser);
- }
- flag = ri.result;
- strMsg = PbCache.ResultMessage;
- }
- else if (strType == "1")//存在业务编号且是非内倒计量业务
- {
- //将卡控条件设置为0,放过所有卡控
- PbCache.isNotValid = true;
- flag = false;
- if (scene.WeightMeter(preTack, appUser, out strMsg)) //meterTypeNo "001006001","001006002"
- {
- flag = true;
- }
- }
- else
- {
- flag = false;
- PbCache.ResultMessage = "请输入正确的业务编号之后按回车";
- }
- }
- if (flag)
- {
- #region 截取图片信息
- try
- {
- //*
- //截取屏幕信息
- Point screenPoint = this.PointToScreen(new Point());
- Rectangle rect = new Rectangle(screenPoint, this.Size);
- Image img = new Bitmap(rect.Width, rect.Height);
- Graphics g = Graphics.FromImage(img);
- g.CopyFromScreen(rect.X - 1, rect.Y - 1, 0, 0, rect.Size);//"D://file/1.jpg"
- img.Save(string.Format("{0}imgShort\\tempImg\\{1}_{2}_{3}.jpg",
- AppDomain.CurrentDomain.SetupInformation.ApplicationBase,
- PbCache.sportInfo.baseSpotNo,
- "C" + PbCache.actualFirstNo,
- (PbCache.videoChild.Count + 1)), System.Drawing.Imaging.ImageFormat.Jpeg);
- //*
- //最后进行截图操作
- CameraShotCls cameraShot = new CameraShotCls();
- cameraShot.CapMethod(PbCache.actualFirstNo);
- //*/
- }
- catch (Exception ex)
- {
- l.WriteLog(5, PbCache.lockCarNo + "截图失败");
- }
- #endregion
- #region LED写入
- PbCache.ledInfo = string.Format("计量完成,车号:{0},车重:{1},物资:{2}", PbCache.lockCarNo, PbCache.lockWgt, txtMATTER_NAME.Text.Trim());
- #endregion
- //Clean();
- try
- {
- QueryCarNo();
- }
- catch { }
- }
- else
- {
- PbCache.isLockFrm = false;
- btnSave.Enabled = true;
- }
- txtMsgInfo.Text = PbCache.ResultMessage;
- if (!string.IsNullOrEmpty(PbCache.ResultMessage))
- {
- txtMsgInfo.Text = PbCache.ResultMessage;
- //MessageBox.Show(PbCache.ResultMessage);
- }
- }
- catch (Exception ex)
- {
- btnSave.Enabled = true;
- PbCache.isLockFrm = false;
- txtMsgInfo.Text = "保存失败:" + ex.Message.Trim();
- l.WriteLog(5, "保存失败:" + ex.Message.Trim());
- //MessageBox.Show("保存失败:" + ex.Message.Trim());
- }
- }
- else
- {
- txtMsgInfo.Text = PbCache.ResultMessage;
- btnSave.Enabled = true;
- PbCache.isLockFrm = false;
- }
- }
- }
- /// <summary>
- /// 0为内倒 1为非内倒
- /// </summary>
- private string strType = "0";
- /// <summary>
- /// 回车时触发查询
- /// </summary>
- private void txtPREDICTION_NO_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyValue == 13)
- {
- QueryInnerInfo(); //回车时触发查询
- }
- }
- /// <summary>
- /// 查询内倒业务号信息
- /// </summary>
- private void QueryInnerInfo()
- {
- txtFORWARDING_UNIT_NAME.Text = "";
- txtMATTER_NAME.Text = "";
- txtRECEIVING_UINT_NAME.Text = "";
- preTack = null;
- string strM = txtPREDICTION_NO.Text.Trim();
- PbCache.strCode = strM;
- setPreTrackInfo(new PreTrackScale());
- if (strM.Length == 9)
- {
- strType = "0";
- //内部物料,需确认车辆是否为内倒车辆
- string sql = @"select t1.load_point_no as id, t1.load_point_name text, t1.meter_code text2
- from meter_base_load_point t1
- where t1.meter_code = '" + strM.Substring(3, 3) + @"'
- and t1.valid_Flag = '1'
- union all
- select t1.load_point_no as id, t1.load_point_name text, t1.meter_code text2
- from meter_base_load_point t1
- where t1.meter_code = '" + strM.Substring(6, 3) + @"'
- and t1.valid_Flag = '1'
- union all
- select t2.matter_no as id, t2.matter_name text, t2.meter_code text2
- from meter_base_matter_info t2
- where t2.meter_code = '" + strM.Substring(0, 3) + @"'
- and t2.valid_Flag = '1'";
- PbModelDbService<List<PbModelDb>> pb = new PbModelDbService<List<PbModelDb>>();
- RESTfulResult<List<PbModelDb>> rm = pb.executeSqlDataWf(sql);
- if (rm.Succeed && rm.Data.Count == 3)
- {
- txtMsgInfo.Text = "内倒计量:当前为毛重状态";
- txtFORWARDING_UNIT_NAME.Text = rm.Data[0].text;
- txtMATTER_NAME.Text = rm.Data[2].text;
- txtRECEIVING_UINT_NAME.Text = rm.Data[1].text;
- preTack = new PreTrackScale
- {
- predictionNo = strM,
- forwardingUnitNo = rm.Data[0].id,
- forwardingUnitName = rm.Data[0].text,
- matterNo = rm.Data[2].id,
- matterName = rm.Data[2].text,
- receivingUintNo = rm.Data[1].id,
- receivingUintName = rm.Data[1].text,
- meterTypeNo = "001006003",
- meterTypeName = ""
- };
- setPreTrackInfo(preTack);
- seValidWhp();
- txtMETER_TYPE.Text = "内倒";
- #region 是否可用期限皮
- PbCache.isTermTare = false;
- sql = @"select matter_no id,
- allowed_tare_weight text,
- allowed_add_weight text2
- from meter_base_matter_info
- where valid_Flag = '1' and matter_no = '" + rm.Data[2].id + "'";
- RESTfulResult<List<PbModelDb>> rmT = pb.executeSqlDataWf(sql);
- if (rmT.Succeed)
- {
- if (rmT.Data != null && rmT.Data.Count > 0 && rmT.Data[0].text == "1")
- {
- PbCache.isTermTare = true;
- }
- }
- #endregion
- }
- else
- {
- txtMsgInfo.Text = "不存在该业务编码,请确定输入的信息是否有错或业务编码是否存在";
- //MessageBox.Show("不存在该业务编码,请确定输入的信息是否有错或业务编码是否存在");
- }
- }
- else if (strM.Length > 0)
- {
- strType = "2";
- RESTfulResult<List<PreTrackScale>> rm = service.doQueryWf(new PreTrackScale { predictionNo = strM });
- if (rm.Succeed)
- {
- if (rm.Data == null || rm.Data.Count == 0)
- {
- txtMsgInfo.Text = "未找到预报信息,请确定输入的信息是否有错";
- }
- else
- {
- if (rm.Data[0].valueFlag != "1" && rm.Data[0].valueFlag != "4") //1未使用,4正使用
- {
- txtMsgInfo.Text = "请确保当前预报已配车且未使用或正使用";
- }
- else
- {
- preTack = rm.Data[0];
- setPreTrackInfo(preTack);
- seValidWhp();
- strType = "1";
- btnSave.Visible = validPredictionNo(preTack.predictionNo);
- }
- }
- }
- }
- txtPREDICTION_NO.Text = strM;
- }
- #endregion
- #region 数据设置及清空
- /// <summary>
- /// 清空或设置预报信息
- /// </summary>
- private void setPreTrackInfo(PreTrackScale pts)
- {
- setMsgInfo(txtPREDICTION_NO, pts.predictionNo == null ? "" : pts.predictionNo, "");
- setMsgInfo(txtBATCH_NO, pts.batchNo == null ? "" : pts.batchNo, "");
- setMsgInfo(txtBATCH_NO, pts.batchNo == null ? "" : pts.batchNo, "");
- setMsgInfo(txtMATTER_NAME, pts.matterName == null ? "" : pts.matterName, "");
- setMsgInfo(txtMETER_TYPE, pts.meterTypeName == null ? "" : pts.meterTypeName, "");
- setMsgInfo(txtFORWARDING_UNIT_NAME, pts.forwardingUnitName == null ? "" : pts.forwardingUnitName, "");
- setMsgInfo(txtRECEIVING_UINT_NAME, pts.receivingUintName == null ? "" : pts.receivingUintName, "");
- setMsgInfo(txtLOAD_POINT_NAME, pts.loadPointName == null ? "" : pts.loadPointName, "");
- setMsgInfo(txtCARRIER_UNIT_NAME, pts.carrierUnitName == null ? "" : pts.carrierUnitName, "");
- setMsgInfo(txtRemark, pts.memo == null ? "" : pts.memo, "");
- setMsgInfo(txtSHIPMENT_NET_WEIGHT, pts.shipmentNetWeight == null ? "" : pts.shipmentNetWeight.Value + "", "");
- setMsgInfo(txtSHIPMENT_GROSS_WEIGHT, pts.shipmentGrossWeight == null ? "" : pts.shipmentGrossWeight.Value + "", "");
- setMsgInfo(chkSample, string.IsNullOrEmpty(pts.sampleNo) ? "false" : "true", "3");
- setMsgInfo(chkChemical, "false", "3");
- }
- private void setHistWgt(double? dHisTareWgt, int? iCount)
- {
- setMsgInfo(txtHisTare, dHisTareWgt == null ? "" : dHisTareWgt.Value + "", "");
- setMsgInfo(txtCount, iCount == null ? "" : iCount.Value + "", "");
- }
- private string strCbCarNo = "";
- public void setCbCarNoInfo(string ResultMessage)
- {
- setCbCarNo(ResultMessage);
- }
- private void setCbCarNo(string ResultMessage)
- {
- if (cbCarNo.InvokeRequired)
- {
- Action<string> action = new Action<string>(setCbCarNoInfo);
- Invoke(action, new object[] { ResultMessage });
- }
- else
- {
- if (string.IsNullOrEmpty(ResultMessage))
- {
- cbCarNo.SelectedIndex = -1;
- }
- cbCarNo.Text = ResultMessage;
- strCbCarNo = cbCarNo.Text.Trim();
- }
- }
- private string strTxtCarNo = "";
- public void setTxtCarNoInfo(string ResultMessage)
- {
- setTxtCarNo(ResultMessage);
- }
- private void setTxtCarNo(string ResultMessage)
- {
- if (txtCarNo.InvokeRequired)
- {
- Action<string> action = new Action<string>(setTxtCarNoInfo);
- Invoke(action, new object[] { ResultMessage });
- }
- else
- {
- txtCarNo.Text = ResultMessage;
- strTxtCarNo = txtCarNo.Text.Trim();
- }
- }
- public void setPicQRed(bool bRed)
- {
- setQRed(bRed);
- }
- private void setQRed(bool bRed)
- {
- if (picQRed.InvokeRequired)
- {
- Action<bool> action = new Action<bool>(setPicQRed);
- Invoke(action, new object[] { bRed });
- }
- else
- {
- if (bRed)
- {
- picQRed.Load(PbCache.path + "\\image\\icon\\red.gif");
- }
- else
- {
- picQRed.Load(PbCache.path + "\\image\\icon\\green.gif");
- }
- }
- }
- public void setPicHRed(bool bRed)
- {
- setHRed(bRed);
- }
- private void setHRed(bool bRed)
- {
- if (picHRed.InvokeRequired)
- {
- Action<bool> action = new Action<bool>(setPicHRed);
- Invoke(action, new object[] { bRed });
- }
- else
- {
- if (bRed)
- {
- picHRed.Load(PbCache.path + "\\image\\icon\\red.gif");
- }
- else
- {
- picHRed.Load(PbCache.path + "\\image\\icon\\green.gif");
- }
- }
- }
- #endregion
- private int iCnt = 0, iTimes = 0;
- private void timer1_Tick(object sender, EventArgs e)
- {
- iCnt++;
- if (iCnt % 3 == 0)
- {
- //未挂起则3秒写入一次在线状态
- if (!bGQ)
- {
- RESTfulResult<string> rm = onlineService.doSaveWf(new MeterWorkOnline { userId = userId });
- }
- iCnt = 0;
- }
- iTimes++;
- if (iTimes > 600 && !bCollectionStart)
- {
- //没有远程接管的情况下十分钟载入一次基础数据
- iTimes = 0;
- bd.setBaseDb();
- }
- }
- private void cbCarNo_SelectedIndexChanged(object sender, EventArgs e)
- {
- if (PbCache.collect != null && PbCache.collect.weight > 0)
- {
- if (cbCarNo.SelectedIndex > -1)
- {
- strCbCarNo = cbCarNo.Text.Trim();
- QueryCarNo();
- flagCarNo = true;
- }
- }
- }
- private bool flagCarNo = false, isFocus = false;
- private void txtCarNo_KeyDown(object sender, EventArgs e)
- {
- if (PbCache.collect != null && PbCache.collect.weight > 0)
- {
- strTxtCarNo = txtCarNo.Text.Trim();
- QueryCarNo();
- flagCarNo = true;
- }
- }
- private void getFocusInfo(Control control)
- {
- if (txtCarNo.InvokeRequired)
- {
- Action<Control> action = new Action<Control>(getFocusInfo);
- Invoke(action, new object[] { control });
- }
- else
- {
- isFocus = control.Focused;
- }
- }
- private void QueryCarNo()
- {
- if (PbCache.sportInfo != null)
- {
- if (strTxtCarNo != "" && strCbCarNo != "") //&& PbCache.collect.weightStatus == 0)
- {
- PbCache.collect.carno = strCbCarNo + strTxtCarNo;
- first = null;
- //setHistWgt(null, null);
- //METER_BASE_HIS_TARE_DATA
- RESTfulResult<List<MeterBaseHisTareData>> rmH = meterBaseHisTareData.doQueryWf(new MeterBaseHisTareData { carNo = PbCache.collect.carno, valueFlag = "0" });
- if (rmH.Succeed && rmH.Data != null && rmH.Data.Count > 0)
- {
- string HisTareWgt = PbCache.tareCount != null ? (PbCache.tareCount.contrastTypeNo == "001012001" ? rmH.Data[0].upWeight.Value : rmH.Data[0].avgWeight.Value) + "" : rmH.Data[0].avgWeight.Value + "";
- setMsgInfo(txtHisTare, HisTareWgt, "");
- setMsgInfo(txtCount, rmH.Data[0].meterNum + "", "");
- }
- //通过车号查询计量预报
- RESTfulResult<List<PreTrackScale>> rmx = service.doQueryTenWf(new PreTrackScale { carNo = PbCache.collect.carno });
- dtPreTrackScale.Clear();
- DataTable dt = dtPreTrackScale.Clone();
- if (rmx.Succeed && rmx.Data != null && rmx.Data.Count > 0)
- {
- dt = rmx.Data.ListToDataTable<PreTrackScale>();
- }
- ClsControlPack.CopyDataToDatatable(ref dt, ref this.dtPreTrackScale, true);
- ClsControlPack.RefreshAndAutoSize(ultraGridYb);
- //计量实绩
- CommonPage<MeterWorkCarActual> cpc = new CommonPage<MeterWorkCarActual>();
- MeterWorkCarActual mwca = new MeterWorkCarActual();
- mwca.carNo = PbCache.collect.carno;
- cpc.param = mwca;
- cpc.pageNum = 1;
- cpc.pageSize = 10;
- RESTfulResult<DataTable> rm = mwas.doQueryWf(cpc);
- if (rm.Succeed)
- {
- //WriteLog("二次计量数据查询失败!" + rm.ResultMessage);
- dataTable1.Clear();
- DataTable dts = dataTable1.Clone();
- if (rm.Data != null && rm.Data.Rows.Count > 0)
- {
- dts = rm.Data;
- }
- ClsControlPack.CopyDataToDatatable(ref dts, ref this.dataTable1, true);
- ClsControlPack.RefreshAndAutoSize(ultraGridSj);
- }
- //期限皮重
- RESTfulResult<List<MeterBaseTermTareData>> rmTerm = termTareDate.doQueryWf(new MeterBaseTermTareData { carNo = PbCache.collect.carno, valueFlag = "0" });
- dtTare.Clear();
- DataTable dtTerm = dtTare.Clone();
- if (rmTerm.Succeed && rmTerm.Data != null && rmTerm.Data.Count > 0)
- {
- dtTerm = rmTerm.Data.ListToDataTable<MeterBaseTermTareData>();
- }
- ClsControlPack.CopyDataToDatatable(ref dtTerm, ref this.dtTare, true);
- ClsControlPack.RefreshAndAutoSize(ultraGridTare);
- //校秤记录
- RESTfulResult<List<MeterWorkCalibrationMain>> rmMain = mainService.doQueryWf(new MeterWorkCalibrationMain { baseSpotNo = PbCache.sportInfo.baseSpotNo });
- dtCalibration.Clear();
- DataTable dtMain = dtCalibration.Clone();
- if (rmMain.Succeed && rmMain.Data != null && rmMain.Data.Count > 0)
- {
- dtMain = rmMain.Data.ListToDataTable<MeterWorkCalibrationMain>();
- }
- ClsControlPack.CopyDataToDatatable(ref dtMain, ref this.dtCalibration, true);
- ClsControlPack.RefreshAndAutoSize(ultraGridJl);
- //剩余纸张数 meter_work_monitor
- RESTfulResult<List<MeterWorkMonitor>> rmMonitor = monitorService.doQueryOneWf(new MeterWorkMonitor { validFlag = "1", pointNo = PbCache.sportInfo.baseSpotNo });
- if (rmMonitor.Succeed)
- {
- if (rmMonitor.Data != null && rmMonitor.Data.Count > 0)
- {
- //txtPage.Text = rmMonitor.Data[0].printNum == null ? "0" : (rmMonitor.Data[0].printNum.Value + "");
- setMsgInfo(txtPage, rmMonitor.Data[0].printNum == null ? "0" : (rmMonitor.Data[0].printNum.Value + ""), "");
- }
- }
- //是否存在一次计量数据,存在则毛皮净写入界面
- RESTfulResult<List<MeterWorkCarActualFirst>> RESTfulResult = workCarActualFirstService.doQueryWf(new MeterWorkCarActualFirst { carNo = PbCache.collect.carno, valueFlag = "1" });
- if (RESTfulResult.Succeed)
- {
- if (RESTfulResult.Data != null && RESTfulResult.Data.Count > 0)
- {
- #region ===========eason add 2021-11-27先判断下当前车号对应的秤点是不是联达磅=================
- bool flag = false;
- bool fLianDa = false;
- int iDb = 0;
- //是联达磅,且存在一次计量数据,若一次计量数据只有1条,看预报编号是不是有_,若没有则认为是普通过磅,若有则看最后结净的数据是不是跟这个预报相同只是没有_,若有最后结净数据则一次写入
- if (PbCache.sportInfo?.baseSpotNo == lianDaPointNo)
- {
- if (RESTfulResult.Data.Count == 1)
- {
- if (RESTfulResult.Data[0].predictionNo.Contains("_"))
- {
- //看最后结净的数据是不是跟这个预报相同只是没有_,若有最后结净数据则一次写入
- if (rm.Data != null && rm.Data.Rows.Count > 0)
- {
- if (RESTfulResult.Data[0].predictionNo.Replace("_", "") == rm.Data.Rows[0]["predictionNo"].ToString().Trim())
- {
- flag = true;
- fLianDa = true;
- }
- }
- }
- else
- {
- flag = true;
- }
- }
- }
- else
- {
- //非联达的磅
- if (RESTfulResult.Data.Count == 1)
- {
- if (!RESTfulResult.Data[0].predictionNo.Contains("_")) //未结净的不是联达的数据,则为true
- {
- flag = true;
- }
- }
- else if (RESTfulResult.Data.Count == 2)
- {
- //有两条一条是联达,1条是非联达的,则使用非联达的数据
- if (RESTfulResult.Data[0].predictionNo.Replace("_", "") == RESTfulResult.Data[1].predictionNo.Replace("_", "")
- && RESTfulResult.Data[0].predictionNo != RESTfulResult.Data[1].predictionNo)
- {
- flag = true;
- if (RESTfulResult.Data[0].predictionNo.Contains("_")) iDb = 1;
- }
- }
- }
-
- if (flag)
- {
- #endregion ====================================================================================
- first = RESTfulResult.Data[iDb];
- first.predictionNo = first.predictionNo.Replace("_", "");
- PbCache.strCode = first.predictionNo;
- //setMsgInfo(lbWgt, (first.addWeight == null ? 0 : first.addWeight.Value) + "", ""); //一次附加重量作为附加重量显示
- if (first.meterTypeNo == "001006003")
- {
- strType = "0"; //如果是内倒计量
- setMsgInfo(txtPREDICTION_NO, first.predictionNo, "");
- setMsgInfo(txtMATTER_NAME, first.matterName, "");
- setMsgInfo(txtMETER_TYPE, first.meterTypeName, "");
- setMsgInfo(txtFORWARDING_UNIT_NAME, first.forwardingUnitName, "");
- setMsgInfo(txtRECEIVING_UINT_NAME, first.receivingUintName, "");
- if (ndRemind)
- {
- ndRemind = false;
- txtMsgInfo.Text = "内倒计量:当前为皮重状态,若计量皮重,直接点击保存;若计量毛重请点击【业务编号】输入业务号,若业务号已存在,请在业务号文本框中按回车键!";
- }
- }
- else
- {
- setAddWgt(first.predictionNo); //非内倒才有这款逻辑
- strType = "1"; //非内倒计量,此时计量预报中存在编号与一次一致的情况,则认为是非一车联运,或者一车联运互锁的方式或者最后一车一车联运预报,此时可将一次的信息填充到界面
- //如果是联达的物料,那么此时预报实际上是没有了,我们需要从1次计量里面的数据提取出信息出来然后重新查一次预报信息
- if (fLianDa)
- {
- rmx = service.doQueryWf(new PreTrackScale { predictionNo = first.predictionNo });
- }
- if (rmx.Succeed && rmx.Data != null && rmx.Data.Count > 0)
- {
- PreTrackScale ptsQ = rmx.Data.Where(s => s.predictionNo == RESTfulResult.Data[0].predictionNo).FirstOrDefault();
- if (ptsQ != null && ptsQ.predictionNo != "")
- {
- setMsgInfo(txtPREDICTION_NO, ptsQ.predictionNo, "");
- setMsgInfo(txtBATCH_NO, ptsQ.batchNo, "");
- setMsgInfo(txtMATTER_NAME, ptsQ.matterName, "");
- setMsgInfo(txtMETER_TYPE, ptsQ.meterTypeName, "");
- setMsgInfo(txtCount, ptsQ.shipmentNum == null ? "" : ptsQ.shipmentNum.Value + "", "");
- setMsgInfo(txtFORWARDING_UNIT_NAME, ptsQ.forwardingUnitName, "");
- setMsgInfo(txtRECEIVING_UINT_NAME, ptsQ.receivingUintName, "");
- setMsgInfo(txtCARRIER_UNIT_NAME, ptsQ.carrierUnitName, "");
- setMsgInfo(txtLOAD_POINT_NAME, ptsQ.loadPointName, "");
- setMsgInfo(txtSHIPMENT_GROSS_WEIGHT, ptsQ.shipmentGrossWeight == null ? "" : ptsQ.shipmentGrossWeight.Value + "", "");
- setMsgInfo(txtSHIPMENT_NET_WEIGHT, ptsQ.shipmentNetWeight == null ? "" : ptsQ.shipmentNetWeight.Value + "", "");
- preTack = ptsQ;
- }
- }
- }
- }
- }
- }
- seValidWhp();
- }
- }
- }
- /// <summary>
- /// 验证当前物料是否是危化品
- /// </summary>
- private void seValidWhp()
- {
- if (txtCarNo.Text.Trim() != "" && cbCarNo.Text.Trim() != "" && preTack != null && preTack.matterNo != "")
- {
- string strCarNo = cbCarNo.Text.Trim() + txtCarNo.Text.Trim();
- if (PbCache.limit != null && PbCache.limit.Count > 0)
- {
- List<MeterBaseLimitChemical> mblc = PbCache.limit.Where(s => s.matterNo == preTack.matterNo).ToList();
- //该物料是危化品
- if (mblc.Count > 0)
- {
- chkChemical.Checked = true;
- }
- }
- }
- }
- /// <summary>
- /// 预报数据双击
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGridYb_DoubleClick(object sender, EventArgs e)
- {
- UltraGridRow ugr = ultraGridYb.ActiveRow;
- if (ugr != null)
- {
- DataRow[] dr = dtPreTrackScale.Select("predictionNo='" + ugr.Cells["predictionNo"].Text.Trim() + "'"); //Select(" CAR_NO = '" + strCarNO + "'")
- if (dr != null && dr.Length > 0)
- {
- preTack = dr[0].CreateItem<PreTrackScale>();
- setPreTrackInfo(preTack);
- seValidWhp();
- strType = "1";
- lbWgt.Text = string.IsNullOrEmpty(dr[0]["addWeightSum"].ToString().Trim()) ? "" : dr[0]["addWeightSum"].ToString().Trim();
- setAddWgt(preTack.predictionNo);
- PbCache.strCode = preTack.predictionNo;
- btnSave.Visible = validPredictionNo(ugr.Cells["predictionNo"].Text.Trim());
- }
- }
- }
- //
- private void setAddWgt(string predictionNo)
- {
- try
- {
- setMsgInfo(lbUTENSIL_UTENSIL_NAME, "", "");
- ls = new List<string>();
- setListBoxInfo(lb1, "", "1");
- setListBoxInfo(lb2, "", "1");
- dAddWgt = 0;
- RESTfulResult<List<PerAddWeight>> rm = perAddWeight.doQueryWf(new PerAddWeight { predictionNo = predictionNo });
- if (rm.Succeed)
- {
- if (rm.Data != null && rm.Data.Count > 0)
- {
- int i = 0;
- foreach (PerAddWeight per in rm.Data)
- {
- setMsgInfo(lbUTENSIL_UTENSIL_NAME, per.utensilUtensilName, "");
- ls.Add(per.addWeightNo);
- i++;
- if (i < 8)
- {
- setListBoxInfo(lb1, per.utensilNo, "2");
- }
- else
- {
- setListBoxInfo(lb2, per.utensilNo, "2");
- }
- dAddWgt += string.IsNullOrEmpty(per.utensilWeight) ? 0 : Convert.ToDouble(per.utensilWeight);
- }
- }
- }
- //PbCache.addWgt = dAddWgt;
- setMsgInfo(lbWgt, dAddWgt + "", "");
- }
- catch (Exception ex)
- {
- l.WriteLog(1, ex.Message.Trim());
- }
- }
- public void setListBoxInfo(ListBox control, string ResultMessage, string sType)
- {
- setListBoxMsg(control, ResultMessage, sType);
- }
- private void setListBoxMsg(ListBox control, string ResultMessage, string sType)
- {
- if (control.InvokeRequired)
- {
- Action<ListBox, string, string> action = new Action<ListBox, string, string>(setListBoxInfo);
- Invoke(action, new object[] { control, ResultMessage, sType });
- }
- else
- {
- switch (sType)
- {
- case "1":
- control.Items.Clear();
- ; break;
- case "2":
- control.Items.Add(ResultMessage);
- ; break;
- case "3":
- control.Items.Remove(ResultMessage);
- break;
- default: break;
- }
- }
- }
- private bool validPredictionNo(string predictionNo)
- {
- bool flag = true;
- txtMsgInfo.Text = "";
- #region 如果存在一次信息,且当前预报编号与一次的不一样
- if (first != null && !string.IsNullOrEmpty(first.predictionNo) && !string.IsNullOrEmpty(predictionNo))
- {
- if (PbCache.strCode != first.predictionNo)
- {
- if (first.predictionType != "2")//一次计量的计量预报如果不是联运预报,那么当前扫的码必须与前面那个一致
- {
- txtMsgInfo.Text = "当前计量预报【" + predictionNo + "】与上次未结净数据预报【" + first.predictionNo + "】不一致,请重新扫码或语音求助!";
- flag = false;
- }
- else //如果一次计量是联运预报,且预报的使用状态为4(正使用)则认为走了互锁式计量,因为非互锁的情况计量一次预报状态会变为2
- {
- RESTfulResult<List<PreTrackScale>> rm = service.doQueryWf(new PreTrackScale { predictionNo = first.predictionNo, valueFlag = "4" });
- if (rm.Succeed)
- {
- if (rm.Data != null && rm.Data.Count > 0)
- {
- txtMsgInfo.Text = "当前计量预报【" + predictionNo + "】与上次未结净数据预报【" + first.predictionNo + "】不一致,请重新扫码或语音求助!";
- flag = false;
- }
- else //非互锁的情况计量,此时编号应该存在在一次计量中的编号中
- {
- string sCode = first.predictionCombination.Split(',').ToList().Where(s => s.CompareTo(predictionNo) == 0).FirstOrDefault();
- if (string.IsNullOrEmpty(sCode))
- {
- txtMsgInfo.Text = "当前计量预报【" + predictionNo + "】不在上次计量联运预报【" + first.predictionCombination + "】中,请重新扫码或语音求助!";
- flag = false;
- }
- }
- }
- else
- {
- l.WriteLog(0, "查询预报编号异常");
- txtMsgInfo.Text = "获取一次计量时的预报失败,请稍后再试,预报编号【" + first.predictionNo + "】!";
- flag = false;
- }
- }
- }
- }
- #endregion
- return flag;
- }
- /// <summary>
- /// 计量实绩数据双击
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGridSj_DoubleClick(object sender, EventArgs e)
- {
- UltraGridRow ugr = ultraGridSj.ActiveRow;
- if (ugr != null)
- {
- strType = "0";
- preTack = new PreTrackScale
- {
- predictionNo = ugr.Cells["predictionNo"].Text.Trim(),
- forwardingUnitNo = ugr.Cells["forwardingUnitNo"].Text.Trim(),
- forwardingUnitName = ugr.Cells["forwardingUnitName"].Text.Trim(),
- matterNo = ugr.Cells["matterNo"].Text.Trim(),
- matterName = ugr.Cells["matterName"].Text.Trim(),
- receivingUintNo = ugr.Cells["receivingUintNo"].Text.Trim(),
- receivingUintName = ugr.Cells["receivingUintName"].Text.Trim()
- };
- setPreTrackInfo(preTack);
- seValidWhp();
- }
- }
- private string strIsRemote = "0";
- private void timer2_Tick(object sender, EventArgs e)
- {
- if (!bCollectionStart)
- {
- //RESTfulResult<List<MeterWorkMonitor>> rm = monitorService.doQueryOneWf(new MeterWorkMonitor { userNo = userId });
- RESTfulResult<List<MeterWorkMonitor>> rm = monitorService.doQueryOneWf(new MeterWorkMonitor { userNo = userId });
- if (rm.Succeed)
- {
- if (rm.Data != null && rm.Data.Count > 0)
- {
- strIsRemote = rm.Data[0].isRemote;
- #region 将按钮设置为接管的状态
- btnStart.BackColor = Color.Red;
- btnStart.Text = "取消接管";
- timer2.Stop();
- flagStart = false;
- #endregion
- lbPointName.Text = "";
- lbMeterMan.Text = "";
- txtPREDICTION_NO.ReadOnly = false;
- cbCarNo.Enabled = true;
- txtCarNo.ReadOnly = false;
- DataTable dt = dtJGPointInfo.Clone();
- DataRow dr = dt.NewRow();
- PbCache.sportInfo = PbCache.sportInfos.Where(s => s.baseSpotNo == rm.Data[0].pointNo).FirstOrDefault();
- dr["baseSpotNo"] = rm.Data[0].pointNo;
- dr["baseSpotName"] = rm.Data[0].pointName;
- dt.Rows.Add(dr);
- ClsControlPack.CopyDataToDatatable(ref dt, ref this.dtJGPointInfo, true);
- ClsControlPack.RefreshAndAutoSize(ultraGridPW);
- PbCache.collect_no = rm.Data[0].collectionCode;
- bd.getSpot();
- //=====如果此时的远程接管状态是2,则说明是监控端点击的远程接管,此时将自动派位改为挂起状态===========
- /*
- if (rm.Data[0].isTakeOver == "2")
- {
- btnStart.BackColor = Color.Red;
- btnStart.Text = "挂起";
- timer2.Enabled = false;
- flagStart = false;
- }
- //*/
- //===================================================================================================
- collection.Start(rm.Data[0].pointNo, rm.Data[0].pointName);
- GetIPVideo(PbCache.videoInfo);
- setPicBoxSet();
- bCollectionStart = true;
- lbPointName.Text = rm.Data[0].pointName;
- lbMeterMan.Text = userName;
- //放开按钮
- /*
- btnOpenVoice.Enabled = true;
- btnCheckBalance.Enabled = true;
- btnTareWgt.Enabled = true;
- btnSave.Enabled = true;
- //*/
- }
- }
- }
- else
- {
- /*
- if (btnOpenVoice.Enabled)
- {
- //禁用按钮
- btnOpenVoice.Enabled = false;
- btnCheckBalance.Enabled = false;
- btnTareWgt.Enabled = false;
- btnSave.Enabled = false;
- }
- //*/
- }
- }
- private List<PictureBox> ltPicBoxs = new List<PictureBox>();
- private void setPicBoxSet()
- {
- if (PbCache.videoChild != null && PbCache.videoChild.Count > 0)
- {
- int i = 0;
- foreach (MeterBaseVideoChild child in PbCache.videoChild.OrderByDescending(s => s.p_ip))
- {
- i++;
- if (i < 4 || i == 6) //只开启4个视频 1-3通道 左右上 6通道室内
- {
- PictureBox pb = new PictureBox();
- pb.Name = "pb" + i;
- pb.Dock = DockStyle.Top;
- pb.Height = 245;
- pb.DoubleClick += new EventHandler(PictureBoxDoubleClick);
- pb.BorderStyle = BorderStyle.FixedSingle;
- panel1.Controls.Add(pb);
- cameraShotMain.RealPlay(pb, i);
- }
- }
- }
- }
- private void frmMeterMain2_FormClosing(object sender, FormClosingEventArgs e)
- {
- try
- {
- timer1.Stop();
- timer2.Stop();
- }
- catch { }
- try
- {
- strIsRemote = "0";
- Clean();
- }
- catch { }
- //imageControl.Stop();
- }
- private void lbWgt_ValueChanged(object sender, EventArgs e)
- {
- try
- {
- dAddWgt = Convert.ToDouble(lbWgt.Value);
- }
- catch
- {
- dAddWgt = 0;
- }
- }
- private void txtCarNo_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyValue == 13)
- {
- if (PbCache.collect != null && PbCache.collect.weight > 0)
- {
- strTxtCarNo = txtCarNo.Text.Trim();
- QueryCarNo(); //txtCarNo_KeyDown
- flagCarNo = true;
- }
- }
- }
- /// <summary>
- /// 业务编号 点击事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnInnerQuery_Click(object sender, EventArgs e)
- {
- frmMatCompanyInfo frmM = new frmMatCompanyInfo();
- if (frmM.ShowDialog() == DialogResult.OK)
- {
- txtPREDICTION_NO.Text = frmM.PreNo;
- QueryInnerInfo(); //业务编号点击事件
- }
- }
- /// <summary>
- /// 测试按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnTest_Click(object sender, EventArgs e)
- {
- testFlage = true;
- }
- private int iPic = 0;
- /// <summary>
- /// 不显示大图
- /// </summary>
- private void pictureShow_DoubleClick(object sender, EventArgs e)
- {
- plImgShow.Visible = false;
- cameraShotMain.StopRealPlay(iPic);
- iPic = 0;
- }
- /// <summary>
- /// 放大图像
- /// </summary>
- private void PictureBoxDoubleClick(object sender, EventArgs e)
- {
- if (iPic != 0)
- {
- cameraShotMain.StopRealPlay(iPic);
- }
- PictureBox picture = (PictureBox)sender;
- iPic = Convert.ToInt32(picture.Name.Substring(picture.Name.Length - 1, 1));
- plImgShow.Visible = true;
- cameraShotMain.RealPlay(pictureShow, iPic);
- }
- public string GetIP()
- {
- try
- {
- IPHostEntry ipHost = Dns.Resolve(Dns.GetHostName());
- IPAddress ipAddr = ipHost.AddressList[0];
- return ipAddr.ToString();
- }
- catch (Exception ex)
- {
- Random rd = new Random();
- l.WriteLog(13, "GetIP方法异常:" + ex.Message);
- return rd.Next(99999, 999999) + "";
- }
- }
- }
- }
|