| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962 |
- using com.hnshituo.core.webapp.vo;
- using Common;
- using Infragistics.Win.UltraWinGrid;
- using JC_MeasuringSystem;
- using MeterPlugInLibrary;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Net;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace RailMeterSystem
- {
- public partial class frmTgStaticMain : Form
- {
- public frmTgStaticMain()
- {
- InitializeComponent();
- }
- #region 查询服务
- //一次计量重量
- private MeterWorkRailwayActFirst first = null;
- private MeterWorkRailwayActualService mwas = new MeterWorkRailwayActualService();//计量结净数据
- private MeterWorkRailwayActFirstService railwayActFirstService = new MeterWorkRailwayActFirstService();//一次计量数据
- MeterWorkRailwayActFirstService actFirstService = new MeterWorkRailwayActFirstService(); //
- #endregion
- private BaseDbCls bd = new BaseDbCls();
- private Log l = Log.GetInstance();
- private string userId = "", userName = "";
- private CoreAppUser appUser = null;
- private StaticCollectModel scModel1 = new StaticCollectModel(); //静态1
- //实时表数据采集
- private StaticDataCollectionControl collection1 = new StaticDataCollectionControl();
- private string _controlIp = "";
- private void frmTgStaticMain_Load(object sender, EventArgs e)
- {
- timer1.Start();
- txtCarNo.LostFocus += new EventHandler(txtCarNo_LostFocus);
- _controlIp = GetIP();
- userId = ((ST_MainForm)(this.MdiParent)).UserID;
- userName = ((ST_MainForm)(this.MdiParent)).UserName;
- appUser = ((ST_MainForm)(this.MdiParent)).AppUser;
- collection1.EventDataCollectionArgs += new StaticEventDataCollection(EventData);//数据采集1
- if (!bd.setBaseDb())
- {
- MessageBox.Show("基础数据载入失败,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n");
- l.WriteLog(13, "基础数据载入失败,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n");
- return;
- }
- else
- {
- List<MeterBaseSpotInfo> lt = PbStaticRailwayCache.sportInfos.Where(s => s.baseSpotName.Contains("静态")).ToList();
- dtJGPointInfo.Clear(); //2021年4月22日 杨秀东新加
- DataTable dt = dtJGPointInfo.Clone();
- foreach (MeterBaseSpotInfo mbsi in lt)
- {
- DataRow dr = dt.NewRow();
- dr["baseSpotNo"] = mbsi.baseSpotNo;
- dr["baseSpotName"] = mbsi.baseSpotName;
- dr["validFlag"] = string.IsNullOrEmpty(mbsi.controlIp) ? "未接管" : "已接管";
- dt.Rows.Add(dr);
- }
- ClsControlPack.CopyDataToDatatable(ref dt, ref this.dtJGPointInfo, true);
- ClsControlPack.RefreshAndAutoSize(ultraGridPW);
- collection1.Start("CAR11"); //白家嘴计检站静态衡一
- }
- }
- private void txtCarNo_LostFocus(object sender, EventArgs e)
- {
- txtTare.Text = "";
- txtGroess.Text = "";
- txtNet.Text = "";
- first = null;
- if (txtCarNo.Text.Trim() != "")
- {
- BindFirstWgt();
- BindNetWgt();
- }
- }
- 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();
- MessageBox.Show("GetIP方法异常,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n!" + ex);
- l.WriteLog(13, "GetIP方法异常:" + ex.Message);
- return rd.Next(99999, 999999) + "";
- }
- }
- #region 数据采集部分
- //private bool bTest = false;
- int decimalWgt = 0;
- frmMsgInfo fm = null;
- bool bClean = false;
- /// <summary>
- /// 数据采集;双称
- /// </summary>
- private void EventData(object o, StaticCollectModel e)
- {
- //这里每隔0.5秒执行一次
- try
- {
- /*
- if (bTest)
- {
- e.carno = "";//功能测试
- e.mainWgt = decimalWgt;//rd.Next(40000, 50000);
- e.firstRed = "0";
- e.secondRed = "0";
- e.thirdRed = "1";
- e.carType = "车型1";
- }
- //*/
- #region
- scModel1.mainWgt = e.mainWgt;
- scModel1.weightStatus = e.weightStatus;
- scModel1.datetime = e.datetime;
- scModel1.carno = e.carno;
- ucStorageWeightT1.setWgt(scModel1.mainWgt);
- ucStorageWeightT1.setStable(scModel1.weightStatus != 1 ? true : false);
- //重量大于1000的情况下
- if (e.mainWgt > 1000)
- {
- if (PbStaticRailwayCache.sportInfo == null)
- {
- setGridColor(ultraGridPW, "00012", "1");
- }
- else
- {
- if (fm != null) fm.Close();
- setGridColor(ultraGridPW, "00012", "3");
- }
- }
- else
- {
- if (bClean)
- {
- CleanForm();
- }
-
- }
- #endregion
- }
- catch (Exception ex)
- {
- //MessageBox.Show("frmMeterMain.EventData2数据采集异常,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n" + ex);
- l.WriteLog(13, "frmMeterMain.EventData2数据采集异常,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n" + ex);
- }
- }
- #endregion
- #region 数据清理
- private void Clean()
- {
- try
- {
- updateSport("");
- PbStaticRailwayCache.videoInfo = null;
- PbStaticRailwayCache.dtStartTime = null;
- PbStaticRailwayCache.sportInfo = null;
- PbStaticRailwayCache.collect = null;
- try
- {
- cameraShotMain.StopRealPlay(iPic);
- setMsgInfo(plImgShow, "false", "2");
- iPic = 0;
- }
- catch { }
- //退出语音登录
- try
- {
- VoiceClose();
- IPVideoClose();
- }
- catch (Exception ex)
- {
- }
-
- setPanelRemovenfo(panel1);
- CleanForm(); //Clean方法
- }
- catch (Exception ex)
- {
- MessageBox.Show("Clean方法异常,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n" + ex);
- l.WriteLog(13, "Clean方法异常,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n" + ex);
- }
- }
- private void CleanForm()
- {
- try
- {
- ucStorageWeightT1.setStable(true);
- setMsgInfo(txtCarNo, "", "");
- setMsgInfo(txtGroess, "", "");
- setMsgInfo(txtTare, "", "");
- setMsgInfo(txtNet, "", "");
- setMsgInfo(txtMemo,"","");
- setMsgInfo(txtMsgInfo, "", "");
- }
- catch (Exception ex)
- {
- //MessageBox.Show("CleanForm方法异常,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n" + ex);
- l.WriteLog(13, "CleanForm方法异常,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n" + ex);
- }
- }
- #endregion
- #region 控件设置
- public void setMsgInfo(Control control, string ResultMessage, string sType)
- {
- setMsgMsg(control, ResultMessage, sType);
- }
- private void setMsgMsg(Control control, string ResultMessage, string sType)
- {
- try
- {
- 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")
- {
- 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;
- }
- }
- else if (ResultMessage == "color")
- {
- switch (sType)
- {
- case "Red":
- control.BackColor = Color.Red;
- ; break;
- case "Lime":
- control.BackColor = Color.Lime;
- ; break;
- case "GreenYellow":
- control.BackColor = Color.GreenYellow;
- ; break;
- default: break;
- }
- }
- else
- {
- control.Text = ResultMessage == null ? "" : ResultMessage;
- }
- }
- }
- catch (Exception ex)
- {
- //MessageBox.Show("setMsgMsg设置控件值异常,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n" + ex);
- l.WriteLog(13, "setMsgMsg设置控件值异常,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n" + ex);
- }
- }
-
- /// <summary>
- /// 设置颜色提醒
- /// </summary>
- /// <param name="pointNo"></param>
- /// <param name="sType">1橘色提醒,2白色 3红色</param>
- private void setGridColor(UltraGrid control, string pointNo, string sType)
- {
- if (control != null && control.Rows != null && control.Rows.Count > 0 && !string.IsNullOrEmpty(pointNo) && !string.IsNullOrEmpty(sType))
- {
- setGridColorMsg(control, pointNo, sType);
- }
- }
- private void btnStart_Click(object sender, EventArgs e)
- {
- try
- {
- if (btnStart.Text != "释放")
- {
- UltraGridRow ugr = ultraGridPW.ActiveRow;
- if (ugr != null)
- {
- if (!string.IsNullOrEmpty(ugr.Cells["controlIp"].Text) && ugr.Cells["controlIp"].Text != _controlIp)
- {
- MessageBox.Show("当前计量点已被他人接管");
- return;
- }
- btnStart.BackColor = Color.Red;
- btnStart.Text = "释放";
- PbStaticRailwayCache.sportInfo = PbStaticRailwayCache.sportInfos.Where(s => s.baseSpotNo == ugr.Cells["baseSpotNo"].Text.Trim()).FirstOrDefault();
- //controlIp
- updateSport(_controlIp);
- bd.getSpot();
- GetIPVideo(PbStaticRailwayCache.videoInfo);
- setPicBoxSet();
- }
- }
- else
- {
- btnStart.BackColor = Color.DodgerBlue;
- btnStart.Text = "接管";
- foreach (UltraGridRow ugrs in ultraGridPW.Rows)
- {
- ugrs.Appearance.BackColor = Color.White;
- }
- Clean();//释放按钮
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show("btnStart_Click接管按钮异常,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n" + ex);
- l.WriteLog(13, "btnStart_Click接管按钮异常,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n" + ex);
- }
- }
- private PbModelDbService<string> pdb = new PbModelDbService<string>();
- private MeterMonitorNoteService noteService = new MeterMonitorNoteService();
- /// <summary>
- /// 修改监控表的状态
- /// </summary>
- /// <param name="controlIp"></param>
- private void updateSport(string controlIp)
- {
- try
- {
- string sql = string.Format("update meter_base_spot_info set CONTROL_IP = '{0}' where CONTROL_IP='{1}' or base_spot_no='{2}'", controlIp, _controlIp, (PbStaticRailwayCache.sportInfo == null ? "" : PbStaticRailwayCache.sportInfo.baseSpotNo));
- RESTfulResult<string> rm = pdb.executeSqlDataWf(sql);
- if (rm.Succeed)
- {
- WriteMonitorNote("修改meter_base_spot_info接管状态为" + (string.IsNullOrEmpty(controlIp) ? "取消接管" : "接管"));
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show("updateSport方法异常,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n" + ex);
- l.WriteLog(13, "updateSport方法异常,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n" + ex);
- }
- }
- private void WriteMonitorNote(string content)
- {
- try
- {
- if (PbStaticRailwayCache.sportInfo != null && PbStaticRailwayCache.sportInfo.baseSpotNo != null)
- {
- RESTfulResult<string> rm = noteService.doAddWf(new MeterMonitorNote
- {
- baseSpotNo = PbStaticRailwayCache.sportInfo.baseSpotNo,
- baseSpotName = PbStaticRailwayCache.sportInfo.baseSpotName,
- operationContent = content,//str + chk.Text,
- carNo = txtCarNo.Text.Trim(),
- meterManNo = appUser.userid,
- meterManName = appUser.username,
- meterNoteSource = "5"
- });
- if (!rm.Succeed)
- {
- l.WriteLog(5, "静态衡写入操作日志异常:" + content);
- }
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show("WriteMonitorNote方法异常,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n" + ex);
- l.WriteLog(13, "WriteMonitorNote方法异常,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n" + ex);
- }
- }
- private void setGridColorMsg(UltraGrid control, string pointNo, string sType)
- {
- try
- {
- if (ultraGridPW.InvokeRequired)
- {
- Action<UltraGrid, string, string> action = new Action<UltraGrid, string, string>(setGridColor);
- Invoke(action, new object[] { control, pointNo, sType });
- }
- else
- {
- if (control != null && control.Rows != null && control.Rows.Count > 0)
- {
- foreach (UltraGridRow ugr in control.Rows)
- {
- if (ugr.Cells["baseSpotNo"].Text == pointNo)
- {
- switch (sType)
- {
- case "1":
- if (string.IsNullOrEmpty(ugr.Cells["controlIp"].Text))
- {
- ugr.Appearance.BackColor = Color.Orange;
- };
- break;
- case "2":
- ugr.Appearance.BackColor = Color.White;
- break;
- case "3":
- ugr.Appearance.BackColor = Color.Red;
- break;
- }
- break;
- }
- }
- }
- }
- }
- catch (Exception ex)
- {
- //MessageBox.Show("setGridColorMsg设置颜色异常,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n" + ex);
- l.WriteLog(13, "setGridColorMsg设置颜色异常,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n" + ex);
- }
- }
- #endregion
- #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, "");
- return false;
- }
- return true;
- }
- /// <summary>
- /// 必须先打开视频,然后再打开语音
- /// </summary>
- private void VoiceOpen()
- {
- try
- {
- if (cameraShotMain.StartTalk())
- {
- btnOpenVoice.Text = "关闭对讲";
- }
- }
- catch (Exception ex)
- {
- setMsgInfo(txtMsgInfo, "打开语音失败:" + ex.Message, "");
- }
- }
- /// <summary>
- /// 关闭语音对讲
- /// </summary>
- private void VoiceClose()
- {
- try
- {
- if (cameraShotMain.StopTalk())
- {
- setMsgInfo(btnOpenVoice, "打开对讲", "");
- }
- }
- catch (Exception ex)
- {
- setMsgInfo(txtMsgInfo, "打开对讲失败:" + ex.Message, "");
- }
- }
- /// <summary>
- /// 关闭视频
- /// </summary>
- private void IPVideoClose()
- {
- try
- {
- cameraShotMain.Close();
- }
- catch (Exception ex)
- {
- setMsgInfo(txtMsgInfo, "关闭对讲失败:" + ex.Message, "");
- }
- }
- private List<PictureBox> ltPicBoxs = new List<PictureBox>();
- /// <summary>
- /// 加载图相框
- /// </summary>
- private void setPicBoxSet()
- {
- try
- {
- if (PbStaticRailwayCache.videoChild != null && PbStaticRailwayCache.videoChild.Count > 0)
- {
- if (PbStaticRailwayCache.sportInfo != null)
- {
- for (int k = 1; k <= 2; k++)
- {
- PictureBox pb = new PictureBox();
- pb.Name = "pb" + k;
- pb.Dock = DockStyle.Top;
- pb.Height = 260;
- pb.DoubleClick += new EventHandler(PictureBoxDoubleClick);
- pb.BorderStyle = BorderStyle.FixedSingle;
- panel1.Controls.Add(pb);
- ltPicBoxs.Add(pb);
- cameraShotMain.RealPlay(pb, k);
- }
- #region 室内摄像头
- PictureBox pb4 = new PictureBox();
- pb4.Name = "pb4";
- pb4.Dock = DockStyle.Top;
- pb4.Height = 260;
- pb4.DoubleClick += new EventHandler(PictureBoxDoubleClick);
- pb4.BorderStyle = BorderStyle.FixedSingle;
- panel1.Controls.Add(pb4);
- ltPicBoxs.Add(pb4);
- cameraShotMain.RealPlay(pb4, 4);
- #endregion
- }
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show("setPicBoxSet载入录像异常,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n" + ex);
- l.WriteLog(13, "setPicBoxSet载入录像异常,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n" + ex);
- }
- }
- 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)
- {
- try
- {
- 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);
- }
- }
- }
- catch (Exception ex)
- {
- //MessageBox.Show("setPanelRemove移除界面控件异常,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n" + ex);
- l.WriteLog(13, "setPanelRemove移除界面控件异常,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n" + ex);
- }
- }
- private int 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);
- }
- private void btnOpenVoice_Click(object sender, EventArgs e)
- {
- try
- {
- if (panel1.Controls.Count > 0)
- {
- if (btnOpenVoice.Text == "打开对讲")
- {
- VoiceOpen();
- }
- else
- {
- VoiceClose();
- }
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show("btnOpenVoice_Click打开对讲异常,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n" + ex);
- l.WriteLog(13, "btnOpenVoice_Click打开对讲异常,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n" + ex);
- }
- }
- private void frmTgStaticMain_FormClosing(object sender, FormClosingEventArgs e)
- {
- try
- {
- Clean(); //关闭按钮
- }
- catch { }
- try
- {
- collection1.Stop();
- }
- catch { }
- }
- private void BindFirstWgt()
- {
- string sql = $@"select actual_first_no actualFirstNo,
- railway_no railwayNo,
- railway_carriage_no railwayCarriageNo,
- railway_work_no railwayWorkNo,
- railway_speed railwaySpeed,
- nvl(meter_weight, 0) meterWeight,
- weight_type weightType,
- create_man_no createManNo,
- railway_model_name railwayModelName,
- create_man_name createManName,
- to_char(create_time, 'yyyy-mm-dd hh24:mi:ss') createTime,
- base_spot_no baseSpotNo,
- base_spot_name baseSpotName,
- value_flag valueFlag,
- shipment_Gross_Weight shipmentGrossWeight,
- shipment_Net_Weight shipmentNetWeight
- from Meter_Work_Railway_Act_First
- where value_flag = '1' and weight_type='1' and base_spot_no='00012' and railway_no='{txtCarNo.Text.Trim()}' order by CREATE_TIME,RAILWAY_CARRIAGE_NO";
- dtRailwayActFirst.Clear();
- DataTable dtV = dtRailwayActFirst.Clone();
- PbModelDbService<List<MeterWorkRailwayActFirst>> pb = new PbModelDbService<List<MeterWorkRailwayActFirst>>();
- RESTfulResult<List<MeterWorkRailwayActFirst>> rmType = pb.executeSqlDataWf(sql);
- if (rmType.Succeed && rmType.Data != null && rmType.Data.Count > 0)
- {
- dtV = rmType.Data.ListToDataTable<MeterWorkRailwayActFirst>();
- }
- ClsControlPack.CopyDataToDatatable(ref dtV, ref this.dtRailwayActFirst, true);
- ClsControlPack.RefreshAndAutoSize(ultraGridFirst);
- }
- private void BindNetWgt()
- {
- string sql = $@"select * from (select actual_no actualNo,
- prediction_no predictionNo,
- notice_no noticeNo,
- railway_no railwayNo,
- railway_carriage_no railwayCarriageNo,
- matter_no matterNo,
- matter_name matterName,
- contract_no contractNo,
- batch_no batchNo,
- customer_supplier_no customerSupplierNo,
- customer_supplier_name customerSupplierName,
- forwarding_unit_no forwardingUnitNo,
- forwarding_unit_name forwardingUnitName,
- receiving_uint_no receivingUintNo,
- receiving_uint_name receivingUintName,
- material_no materialNo,
- material_name materialName,
- spec_no specNo,
- spec_name specName,
- load_point_no loadPointNo,
- load_point_name loadPointName,
- sample_voucher sampleVoucher,
- carrier_unit_no carrierUnitNo,
- carrier_unit_name carrierUnitName,
- meter_type_no meterTypeNo,
- meter_type_name meterTypeName,
- meter_process_no meterProcessNo,
- meter_process_edition_no meterProcessEditionNo,
- actual_first1_no actualFirst1No,
- nvl(gross_weight,0) grossWeight,
- gross_man_no grossManNo,
- gross_man_name grossManName,
- to_char(gross_time, 'yyyy-mm-dd hh24:mi:ss') grossTime ,
- base_spot1_no baseSpot1No,
- base_spot1_name baseSpot1Name,
- gross_class grossClass,
- gross_group grossGroup,
- gross_mode grossMode,
- actual_first2_no actualFirst2No,
- nvl(tare_weight,0) tareWeight,
- tare_man_no tareManNo,
- tare_man_name tareManName,
- to_char(tare_time, 'yyyy-mm-dd hh24:mi:ss') tareTime ,
- base_spot2_no baseSpot2No,
- base_spot2_name baseSpot2Name,
- tare_class tareClass,
- tare_group tareGroup,
- tare_mode tareMode,
- nvl(net_weight,0) netWeight,
- net_man_no netManNo,
- net_man_name netManName,
- to_char(net_time, 'yyyy-mm-dd hh24:mi:ss') netTime ,
- net_spot3_no netSpot3No,
- net_spot3_name netSpot3Name,
- net_class netClass,
- net_group netGroup,
- net_mode netMode,
- value_flag valueFlag,
- upload_flag uploadFlag,
- check_man_no checkManNo,
- check_man_name checkManName,
- to_char(check_time, 'yyyy-mm-dd hh24:mi:ss') checkTime ,
- upload_man_no uploadManNo,
- upload_man_name uploadManName,
- to_char(upload_time, 'yyyy-mm-dd hh24:mi:ss') uploadTime,
- sample_no sampleNo,
- railway_type_no railwayTypeNo,
- railway_type_name railwayTypeName,
- water_num waterNum,
- round((nvl(net_weight,0)- nvl(net_weight,0) * nvl(water_num,0)/100),2) dryWgt,
- RAILWAY_MODEL_NAME railwayModelName
- from meter_work_railway_actual
- where value_flag = '0' and railway_no='{txtCarNo.Text.Trim()}' and NET_SPOT3_NO ='00012' order by net_time desc) where rownum<10";
-
- dtRailwayActual.Clear();
- DataTable dt = dtRailwayActual.Clone();
- PbModelDbService<List<MeterWorkRailwayActual>> pb = new PbModelDbService<List<MeterWorkRailwayActual>>();
- RESTfulResult<List<MeterWorkRailwayActual>> rmType = pb.executeSqlDataWf(sql);
- if (rmType.Succeed && rmType.Data != null && rmType.Data.Count > 0)
- {
- dt = rmType.Data.ListToDataTable<MeterWorkRailwayActual>();
- }
- ClsControlPack.CopyDataToDatatable(ref dt, ref this.dtRailwayActual, true);
- ClsControlPack.RefreshAndAutoSize(ultraGridNet);
- }
- private void btnTareSave_Click(object sender, EventArgs e)
- {
- if (PbStaticRailwayCache.sportInfo == null)
- {
- MessageBox.Show("请先接管计量点");
- return;
- }
- if (txtCarNo.Text.Trim() == "")
- {
- MessageBox.Show("请先输入车号");
- return;
- }
- double db = ucStorageWeightT1.getWgt();
- if (ucStorageWeightT1.getWgt() < 1)
- {
- MessageBox.Show("当前重量过小");
- return;
- }
- MeterWorkRailwayActFirst fs = new MeterWorkRailwayActFirst();
- fs.railwayNo = txtCarNo.Text.Trim();
- fs.actualFirstNo = "";
- fs.railwayCarriageNo = "";
- fs.railwaySpeed = 0;
- fs.createTime = new DateTime();
- fs.baseSpotNo = "00012";
- fs.baseSpotName = "静态轨道衡";
- fs.valueFlag = "1";
- fs.createManNo = appUser.userid;
- fs.createManName = appUser.username;
- fs.shipmentGrossWeight = 0;
- fs.shipmentNetWeight = 0;
- fs.weightType = "1";
- fs.createTime = DateTime.Now;
- //==============================================================
- fs.meterWeight = ucStorageWeightT1.getWgt();
- fs.predictionNo = txtPredictionNo.Text.Trim();
- fs.matterName = txtMatterName.Text.Trim();
- fs.customerSupplierName = txtCustomerSupplierName.Text.Trim();
- fs.forwardingUnitName = fs.customerSupplierName;
- fs.receivingUintName = txtReceivingUintName.Text.Trim();
- fs.memo = txtMemo.Text.Trim();
- fs.railwayTypeNo = "001019001";
- fs.railwayTypeName = "静态轨道衡";
- //==============================================================
- RESTfulResult<string> result = actFirstService.doAddStaticRailWf(fs);
- if (result.Succeed)
- {
- if (txtGroess.Text.Trim() != "")
- {
- txtTare.Text = ucStorageWeightT1.getWgt() + "";
- txtNet.Text = (first.meterWeight - ucStorageWeightT1.getWgt()) + "";
- }
- BindFirstWgt();
- BindNetWgt();
- }
- }
- private void btnGrossSave_Click(object sender, EventArgs e)
- {
- if (PbStaticRailwayCache.sportInfo == null)
- {
- MessageBox.Show("请先接管计量点");
- return;
- }
- if (txtCarNo.Text.Trim() == "")
- {
- MessageBox.Show("请先输入车号");
- return;
- }
- if (ucStorageWeightT1.getWgt() < 1)
- {
- MessageBox.Show("当前重量过小");
- return;
- }
- MeterWorkRailwayActFirst fs = new MeterWorkRailwayActFirst();
- fs.railwayNo = txtCarNo.Text.Trim();
- fs.actualFirstNo = "";
- fs.railwayCarriageNo = "";
- fs.railwaySpeed = 0;
- fs.createTime = new DateTime();
- fs.baseSpotNo = "00012";
- fs.baseSpotName = "静态轨道衡";
- fs.valueFlag = "1";
- fs.createManNo = appUser.userid;
- fs.createManName = appUser.username;
- fs.shipmentGrossWeight = 0;
- fs.shipmentNetWeight = 0;
- fs.weightType = "0";
- fs.createTime = DateTime.Now;
- //==============================================================
- fs.meterWeight = ucStorageWeightT1.getWgt();
- fs.predictionNo = txtPredictionNo.Text.Trim();
- fs.matterName = txtMatterName.Text.Trim();
- fs.customerSupplierName = txtCustomerSupplierName.Text.Trim();
- fs.forwardingUnitName = fs.customerSupplierName;
- fs.receivingUintName = txtReceivingUintName.Text.Trim();
- fs.memo = txtMemo.Text.Trim();
- fs.railwayTypeNo = "001019001";
- fs.railwayTypeName = "静态轨道衡";
- //==============================================================
- RESTfulResult<string> result = actFirstService.doAddStaticRailWf(fs);
- if (result.Succeed)
- {
- if (txtTare.Text.Trim() != "")
- {
- txtGroess.Text = ucStorageWeightT1.getWgt() + "";
- txtNet.Text = (ucStorageWeightT1.getWgt() - first.meterWeight) + "";
- }
- BindFirstWgt();
- BindNetWgt();
- }
- }
- private void timer1_Tick(object sender, EventArgs e)
- {
- if (ucStorageWeightT1.getWgt() > 1000)
- {
- if (fm == null)
- {
- fm = frmMsgInfo.CreateInstrance();
- fm.setLbTxt("静态轨道衡");
- }
- }
- else
- {
- if (fm != null)
- {
- fm.setFrmNull();
- fm.CloseFrm();
- fm = null;
- }
- }
- }
- //private void button1_Click(object sender, EventArgs e)
- //{
- // decimalWgt = ((int)numericUpDown1.Value);
- // bTest = !bTest;
- //}
- /// <summary>
- /// 不显示大图
- /// </summary>
- private void pictureShow_DoubleClick(object sender, EventArgs e)
- {
- plImgShow.Visible = false;
- cameraShotMain.StopRealPlay(iPic);
- iPic = 0;
- }
- #endregion
- }
- }
|