frmTgStaticMain.cs 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962
  1. using com.hnshituo.core.webapp.vo;
  2. using Common;
  3. using Infragistics.Win.UltraWinGrid;
  4. using JC_MeasuringSystem;
  5. using MeterPlugInLibrary;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.ComponentModel;
  9. using System.Data;
  10. using System.Drawing;
  11. using System.Linq;
  12. using System.Net;
  13. using System.Text;
  14. using System.Threading.Tasks;
  15. using System.Windows.Forms;
  16. namespace RailMeterSystem
  17. {
  18. public partial class frmTgStaticMain : Form
  19. {
  20. public frmTgStaticMain()
  21. {
  22. InitializeComponent();
  23. }
  24. #region 查询服务
  25. //一次计量重量
  26. private MeterWorkRailwayActFirst first = null;
  27. private MeterWorkRailwayActualService mwas = new MeterWorkRailwayActualService();//计量结净数据
  28. private MeterWorkRailwayActFirstService railwayActFirstService = new MeterWorkRailwayActFirstService();//一次计量数据
  29. MeterWorkRailwayActFirstService actFirstService = new MeterWorkRailwayActFirstService(); //
  30. #endregion
  31. private BaseDbCls bd = new BaseDbCls();
  32. private Log l = Log.GetInstance();
  33. private string userId = "", userName = "";
  34. private CoreAppUser appUser = null;
  35. private StaticCollectModel scModel1 = new StaticCollectModel(); //静态1
  36. //实时表数据采集
  37. private StaticDataCollectionControl collection1 = new StaticDataCollectionControl();
  38. private string _controlIp = "";
  39. private void frmTgStaticMain_Load(object sender, EventArgs e)
  40. {
  41. timer1.Start();
  42. txtCarNo.LostFocus += new EventHandler(txtCarNo_LostFocus);
  43. _controlIp = GetIP();
  44. userId = ((ST_MainForm)(this.MdiParent)).UserID;
  45. userName = ((ST_MainForm)(this.MdiParent)).UserName;
  46. appUser = ((ST_MainForm)(this.MdiParent)).AppUser;
  47. collection1.EventDataCollectionArgs += new StaticEventDataCollection(EventData);//数据采集1
  48. if (!bd.setBaseDb())
  49. {
  50. MessageBox.Show("基础数据载入失败,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n");
  51. l.WriteLog(13, "基础数据载入失败,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n");
  52. return;
  53. }
  54. else
  55. {
  56. List<MeterBaseSpotInfo> lt = PbStaticRailwayCache.sportInfos.Where(s => s.baseSpotName.Contains("静态")).ToList();
  57. dtJGPointInfo.Clear(); //2021年4月22日 杨秀东新加
  58. DataTable dt = dtJGPointInfo.Clone();
  59. foreach (MeterBaseSpotInfo mbsi in lt)
  60. {
  61. DataRow dr = dt.NewRow();
  62. dr["baseSpotNo"] = mbsi.baseSpotNo;
  63. dr["baseSpotName"] = mbsi.baseSpotName;
  64. dr["validFlag"] = string.IsNullOrEmpty(mbsi.controlIp) ? "未接管" : "已接管";
  65. dt.Rows.Add(dr);
  66. }
  67. ClsControlPack.CopyDataToDatatable(ref dt, ref this.dtJGPointInfo, true);
  68. ClsControlPack.RefreshAndAutoSize(ultraGridPW);
  69. collection1.Start("CAR11"); //白家嘴计检站静态衡一
  70. }
  71. }
  72. private void txtCarNo_LostFocus(object sender, EventArgs e)
  73. {
  74. txtTare.Text = "";
  75. txtGroess.Text = "";
  76. txtNet.Text = "";
  77. first = null;
  78. if (txtCarNo.Text.Trim() != "")
  79. {
  80. BindFirstWgt();
  81. BindNetWgt();
  82. }
  83. }
  84. public string GetIP()
  85. {
  86. try
  87. {
  88. IPHostEntry ipHost = Dns.Resolve(Dns.GetHostName());
  89. IPAddress ipAddr = ipHost.AddressList[0];
  90. return ipAddr.ToString();
  91. }
  92. catch (Exception ex)
  93. {
  94. Random rd = new Random();
  95. MessageBox.Show("GetIP方法异常,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n!" + ex);
  96. l.WriteLog(13, "GetIP方法异常:" + ex.Message);
  97. return rd.Next(99999, 999999) + "";
  98. }
  99. }
  100. #region 数据采集部分
  101. //private bool bTest = false;
  102. int decimalWgt = 0;
  103. frmMsgInfo fm = null;
  104. bool bClean = false;
  105. /// <summary>
  106. /// 数据采集;双称
  107. /// </summary>
  108. private void EventData(object o, StaticCollectModel e)
  109. {
  110. //这里每隔0.5秒执行一次
  111. try
  112. {
  113. /*
  114. if (bTest)
  115. {
  116. e.carno = "";//功能测试
  117. e.mainWgt = decimalWgt;//rd.Next(40000, 50000);
  118. e.firstRed = "0";
  119. e.secondRed = "0";
  120. e.thirdRed = "1";
  121. e.carType = "车型1";
  122. }
  123. //*/
  124. #region
  125. scModel1.mainWgt = e.mainWgt;
  126. scModel1.weightStatus = e.weightStatus;
  127. scModel1.datetime = e.datetime;
  128. scModel1.carno = e.carno;
  129. ucStorageWeightT1.setWgt(scModel1.mainWgt);
  130. ucStorageWeightT1.setStable(scModel1.weightStatus != 1 ? true : false);
  131. //重量大于1000的情况下
  132. if (e.mainWgt > 1000)
  133. {
  134. if (PbStaticRailwayCache.sportInfo == null)
  135. {
  136. setGridColor(ultraGridPW, "00012", "1");
  137. }
  138. else
  139. {
  140. if (fm != null) fm.Close();
  141. setGridColor(ultraGridPW, "00012", "3");
  142. }
  143. }
  144. else
  145. {
  146. if (bClean)
  147. {
  148. CleanForm();
  149. }
  150. }
  151. #endregion
  152. }
  153. catch (Exception ex)
  154. {
  155. //MessageBox.Show("frmMeterMain.EventData2数据采集异常,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n" + ex);
  156. l.WriteLog(13, "frmMeterMain.EventData2数据采集异常,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n" + ex);
  157. }
  158. }
  159. #endregion
  160. #region 数据清理
  161. private void Clean()
  162. {
  163. try
  164. {
  165. updateSport("");
  166. PbStaticRailwayCache.videoInfo = null;
  167. PbStaticRailwayCache.dtStartTime = null;
  168. PbStaticRailwayCache.sportInfo = null;
  169. PbStaticRailwayCache.collect = null;
  170. try
  171. {
  172. cameraShotMain.StopRealPlay(iPic);
  173. setMsgInfo(plImgShow, "false", "2");
  174. iPic = 0;
  175. }
  176. catch { }
  177. //退出语音登录
  178. try
  179. {
  180. VoiceClose();
  181. IPVideoClose();
  182. }
  183. catch (Exception ex)
  184. {
  185. }
  186. setPanelRemovenfo(panel1);
  187. CleanForm(); //Clean方法
  188. }
  189. catch (Exception ex)
  190. {
  191. MessageBox.Show("Clean方法异常,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n" + ex);
  192. l.WriteLog(13, "Clean方法异常,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n" + ex);
  193. }
  194. }
  195. private void CleanForm()
  196. {
  197. try
  198. {
  199. ucStorageWeightT1.setStable(true);
  200. setMsgInfo(txtCarNo, "", "");
  201. setMsgInfo(txtGroess, "", "");
  202. setMsgInfo(txtTare, "", "");
  203. setMsgInfo(txtNet, "", "");
  204. setMsgInfo(txtMemo,"","");
  205. setMsgInfo(txtMsgInfo, "", "");
  206. }
  207. catch (Exception ex)
  208. {
  209. //MessageBox.Show("CleanForm方法异常,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n" + ex);
  210. l.WriteLog(13, "CleanForm方法异常,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n" + ex);
  211. }
  212. }
  213. #endregion
  214. #region 控件设置
  215. public void setMsgInfo(Control control, string ResultMessage, string sType)
  216. {
  217. setMsgMsg(control, ResultMessage, sType);
  218. }
  219. private void setMsgMsg(Control control, string ResultMessage, string sType)
  220. {
  221. try
  222. {
  223. if (control.InvokeRequired)
  224. {
  225. Action<Control, string, string> action = new Action<Control, string, string>(setMsgInfo);
  226. Invoke(action, new object[] { control, ResultMessage, sType });
  227. }
  228. else
  229. {
  230. if (ResultMessage == "true" || ResultMessage == "false")
  231. {
  232. switch (sType)
  233. {
  234. case "1":
  235. control.Enabled = ResultMessage == "true" ? true : false;
  236. ; break;
  237. case "2":
  238. control.Visible = ResultMessage == "true" ? true : false;
  239. ; break;
  240. case "3":
  241. ((CheckBox)control).Checked = ResultMessage == "true" ? true : false;
  242. break;
  243. default: break;
  244. }
  245. }
  246. else if (ResultMessage == "color")
  247. {
  248. switch (sType)
  249. {
  250. case "Red":
  251. control.BackColor = Color.Red;
  252. ; break;
  253. case "Lime":
  254. control.BackColor = Color.Lime;
  255. ; break;
  256. case "GreenYellow":
  257. control.BackColor = Color.GreenYellow;
  258. ; break;
  259. default: break;
  260. }
  261. }
  262. else
  263. {
  264. control.Text = ResultMessage == null ? "" : ResultMessage;
  265. }
  266. }
  267. }
  268. catch (Exception ex)
  269. {
  270. //MessageBox.Show("setMsgMsg设置控件值异常,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n" + ex);
  271. l.WriteLog(13, "setMsgMsg设置控件值异常,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n" + ex);
  272. }
  273. }
  274. /// <summary>
  275. /// 设置颜色提醒
  276. /// </summary>
  277. /// <param name="pointNo"></param>
  278. /// <param name="sType">1橘色提醒,2白色 3红色</param>
  279. private void setGridColor(UltraGrid control, string pointNo, string sType)
  280. {
  281. if (control != null && control.Rows != null && control.Rows.Count > 0 && !string.IsNullOrEmpty(pointNo) && !string.IsNullOrEmpty(sType))
  282. {
  283. setGridColorMsg(control, pointNo, sType);
  284. }
  285. }
  286. private void btnStart_Click(object sender, EventArgs e)
  287. {
  288. try
  289. {
  290. if (btnStart.Text != "释放")
  291. {
  292. UltraGridRow ugr = ultraGridPW.ActiveRow;
  293. if (ugr != null)
  294. {
  295. if (!string.IsNullOrEmpty(ugr.Cells["controlIp"].Text) && ugr.Cells["controlIp"].Text != _controlIp)
  296. {
  297. MessageBox.Show("当前计量点已被他人接管");
  298. return;
  299. }
  300. btnStart.BackColor = Color.Red;
  301. btnStart.Text = "释放";
  302. PbStaticRailwayCache.sportInfo = PbStaticRailwayCache.sportInfos.Where(s => s.baseSpotNo == ugr.Cells["baseSpotNo"].Text.Trim()).FirstOrDefault();
  303. //controlIp
  304. updateSport(_controlIp);
  305. bd.getSpot();
  306. GetIPVideo(PbStaticRailwayCache.videoInfo);
  307. setPicBoxSet();
  308. }
  309. }
  310. else
  311. {
  312. btnStart.BackColor = Color.DodgerBlue;
  313. btnStart.Text = "接管";
  314. foreach (UltraGridRow ugrs in ultraGridPW.Rows)
  315. {
  316. ugrs.Appearance.BackColor = Color.White;
  317. }
  318. Clean();//释放按钮
  319. }
  320. }
  321. catch (Exception ex)
  322. {
  323. MessageBox.Show("btnStart_Click接管按钮异常,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n" + ex);
  324. l.WriteLog(13, "btnStart_Click接管按钮异常,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n" + ex);
  325. }
  326. }
  327. private PbModelDbService<string> pdb = new PbModelDbService<string>();
  328. private MeterMonitorNoteService noteService = new MeterMonitorNoteService();
  329. /// <summary>
  330. /// 修改监控表的状态
  331. /// </summary>
  332. /// <param name="controlIp"></param>
  333. private void updateSport(string controlIp)
  334. {
  335. try
  336. {
  337. 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));
  338. RESTfulResult<string> rm = pdb.executeSqlDataWf(sql);
  339. if (rm.Succeed)
  340. {
  341. WriteMonitorNote("修改meter_base_spot_info接管状态为" + (string.IsNullOrEmpty(controlIp) ? "取消接管" : "接管"));
  342. }
  343. }
  344. catch (Exception ex)
  345. {
  346. MessageBox.Show("updateSport方法异常,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n" + ex);
  347. l.WriteLog(13, "updateSport方法异常,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n" + ex);
  348. }
  349. }
  350. private void WriteMonitorNote(string content)
  351. {
  352. try
  353. {
  354. if (PbStaticRailwayCache.sportInfo != null && PbStaticRailwayCache.sportInfo.baseSpotNo != null)
  355. {
  356. RESTfulResult<string> rm = noteService.doAddWf(new MeterMonitorNote
  357. {
  358. baseSpotNo = PbStaticRailwayCache.sportInfo.baseSpotNo,
  359. baseSpotName = PbStaticRailwayCache.sportInfo.baseSpotName,
  360. operationContent = content,//str + chk.Text,
  361. carNo = txtCarNo.Text.Trim(),
  362. meterManNo = appUser.userid,
  363. meterManName = appUser.username,
  364. meterNoteSource = "5"
  365. });
  366. if (!rm.Succeed)
  367. {
  368. l.WriteLog(5, "静态衡写入操作日志异常:" + content);
  369. }
  370. }
  371. }
  372. catch (Exception ex)
  373. {
  374. MessageBox.Show("WriteMonitorNote方法异常,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n" + ex);
  375. l.WriteLog(13, "WriteMonitorNote方法异常,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n" + ex);
  376. }
  377. }
  378. private void setGridColorMsg(UltraGrid control, string pointNo, string sType)
  379. {
  380. try
  381. {
  382. if (ultraGridPW.InvokeRequired)
  383. {
  384. Action<UltraGrid, string, string> action = new Action<UltraGrid, string, string>(setGridColor);
  385. Invoke(action, new object[] { control, pointNo, sType });
  386. }
  387. else
  388. {
  389. if (control != null && control.Rows != null && control.Rows.Count > 0)
  390. {
  391. foreach (UltraGridRow ugr in control.Rows)
  392. {
  393. if (ugr.Cells["baseSpotNo"].Text == pointNo)
  394. {
  395. switch (sType)
  396. {
  397. case "1":
  398. if (string.IsNullOrEmpty(ugr.Cells["controlIp"].Text))
  399. {
  400. ugr.Appearance.BackColor = Color.Orange;
  401. };
  402. break;
  403. case "2":
  404. ugr.Appearance.BackColor = Color.White;
  405. break;
  406. case "3":
  407. ugr.Appearance.BackColor = Color.Red;
  408. break;
  409. }
  410. break;
  411. }
  412. }
  413. }
  414. }
  415. }
  416. catch (Exception ex)
  417. {
  418. //MessageBox.Show("setGridColorMsg设置颜色异常,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n" + ex);
  419. l.WriteLog(13, "setGridColorMsg设置颜色异常,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n" + ex);
  420. }
  421. }
  422. #endregion
  423. #region 对讲代码
  424. /// <summary>
  425. /// 硬盘录像机登录
  426. /// </summary>
  427. private DhCameraShot cameraShotMain = new DhCameraShot();
  428. /// <summary>
  429. /// 必须先打开连接
  430. /// </summary>
  431. private bool GetIPVideo(MeterBaseVideoinfo video)
  432. {
  433. try
  434. {
  435. cameraShotMain.ip = video.videoip;
  436. cameraShotMain.port = video.vdoPort;
  437. cameraShotMain.uid = video.vdoUser;
  438. cameraShotMain.pwd = video.vdoPwd;
  439. cameraShotMain.Connection();
  440. }
  441. catch (Exception ex)
  442. {
  443. setMsgInfo(txtMsgInfo, "视频连接打开失败:" + ex.Message, "");
  444. return false;
  445. }
  446. return true;
  447. }
  448. /// <summary>
  449. /// 必须先打开视频,然后再打开语音
  450. /// </summary>
  451. private void VoiceOpen()
  452. {
  453. try
  454. {
  455. if (cameraShotMain.StartTalk())
  456. {
  457. btnOpenVoice.Text = "关闭对讲";
  458. }
  459. }
  460. catch (Exception ex)
  461. {
  462. setMsgInfo(txtMsgInfo, "打开语音失败:" + ex.Message, "");
  463. }
  464. }
  465. /// <summary>
  466. /// 关闭语音对讲
  467. /// </summary>
  468. private void VoiceClose()
  469. {
  470. try
  471. {
  472. if (cameraShotMain.StopTalk())
  473. {
  474. setMsgInfo(btnOpenVoice, "打开对讲", "");
  475. }
  476. }
  477. catch (Exception ex)
  478. {
  479. setMsgInfo(txtMsgInfo, "打开对讲失败:" + ex.Message, "");
  480. }
  481. }
  482. /// <summary>
  483. /// 关闭视频
  484. /// </summary>
  485. private void IPVideoClose()
  486. {
  487. try
  488. {
  489. cameraShotMain.Close();
  490. }
  491. catch (Exception ex)
  492. {
  493. setMsgInfo(txtMsgInfo, "关闭对讲失败:" + ex.Message, "");
  494. }
  495. }
  496. private List<PictureBox> ltPicBoxs = new List<PictureBox>();
  497. /// <summary>
  498. /// 加载图相框
  499. /// </summary>
  500. private void setPicBoxSet()
  501. {
  502. try
  503. {
  504. if (PbStaticRailwayCache.videoChild != null && PbStaticRailwayCache.videoChild.Count > 0)
  505. {
  506. if (PbStaticRailwayCache.sportInfo != null)
  507. {
  508. for (int k = 1; k <= 2; k++)
  509. {
  510. PictureBox pb = new PictureBox();
  511. pb.Name = "pb" + k;
  512. pb.Dock = DockStyle.Top;
  513. pb.Height = 260;
  514. pb.DoubleClick += new EventHandler(PictureBoxDoubleClick);
  515. pb.BorderStyle = BorderStyle.FixedSingle;
  516. panel1.Controls.Add(pb);
  517. ltPicBoxs.Add(pb);
  518. cameraShotMain.RealPlay(pb, k);
  519. }
  520. #region 室内摄像头
  521. PictureBox pb4 = new PictureBox();
  522. pb4.Name = "pb4";
  523. pb4.Dock = DockStyle.Top;
  524. pb4.Height = 260;
  525. pb4.DoubleClick += new EventHandler(PictureBoxDoubleClick);
  526. pb4.BorderStyle = BorderStyle.FixedSingle;
  527. panel1.Controls.Add(pb4);
  528. ltPicBoxs.Add(pb4);
  529. cameraShotMain.RealPlay(pb4, 4);
  530. #endregion
  531. }
  532. }
  533. }
  534. catch (Exception ex)
  535. {
  536. MessageBox.Show("setPicBoxSet载入录像异常,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n" + ex);
  537. l.WriteLog(13, "setPicBoxSet载入录像异常,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n" + ex);
  538. }
  539. }
  540. public void setPanelRemovenfo(Panel control)
  541. {
  542. setPanelRemoveMsg(control);
  543. }
  544. /// <summary>
  545. /// 如果ResultMessage为true或者false,则sType 为0的时候readonly 1为enable 2为visable
  546. /// </summary>
  547. /// <param name="control"></param>
  548. /// <param name="ResultMessage"></param>
  549. /// <param name="sType"></param>
  550. private void setPanelRemoveMsg(Panel p)
  551. {
  552. try
  553. {
  554. if (p.InvokeRequired)
  555. {
  556. Action<Panel> action = new Action<Panel>(setPanelRemovenfo);
  557. Invoke(action, new object[] { p });
  558. }
  559. else
  560. {
  561. for (int i = p.Controls.Count - 1; i >= 0; i--)
  562. {
  563. p.Controls.RemoveAt(i);
  564. }
  565. }
  566. }
  567. catch (Exception ex)
  568. {
  569. //MessageBox.Show("setPanelRemove移除界面控件异常,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n" + ex);
  570. l.WriteLog(13, "setPanelRemove移除界面控件异常,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n" + ex);
  571. }
  572. }
  573. private int iPic = 0;
  574. /// <summary>
  575. /// 放大图像
  576. /// </summary>
  577. private void PictureBoxDoubleClick(object sender, EventArgs e)
  578. {
  579. if (iPic != 0)
  580. {
  581. cameraShotMain.StopRealPlay(iPic);
  582. }
  583. PictureBox picture = (PictureBox)sender;
  584. iPic = Convert.ToInt32(picture.Name.Substring(picture.Name.Length - 1, 1));
  585. plImgShow.Visible = true;
  586. cameraShotMain.RealPlay(pictureShow, iPic);
  587. }
  588. private void btnOpenVoice_Click(object sender, EventArgs e)
  589. {
  590. try
  591. {
  592. if (panel1.Controls.Count > 0)
  593. {
  594. if (btnOpenVoice.Text == "打开对讲")
  595. {
  596. VoiceOpen();
  597. }
  598. else
  599. {
  600. VoiceClose();
  601. }
  602. }
  603. }
  604. catch (Exception ex)
  605. {
  606. MessageBox.Show("btnOpenVoice_Click打开对讲异常,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n" + ex);
  607. l.WriteLog(13, "btnOpenVoice_Click打开对讲异常,请关闭界面并稍后打开,或联系管理员!\r\n异常原因:\r\n" + ex);
  608. }
  609. }
  610. private void frmTgStaticMain_FormClosing(object sender, FormClosingEventArgs e)
  611. {
  612. try
  613. {
  614. Clean(); //关闭按钮
  615. }
  616. catch { }
  617. try
  618. {
  619. collection1.Stop();
  620. }
  621. catch { }
  622. }
  623. private void BindFirstWgt()
  624. {
  625. string sql = $@"select actual_first_no actualFirstNo,
  626. railway_no railwayNo,
  627. railway_carriage_no railwayCarriageNo,
  628. railway_work_no railwayWorkNo,
  629. railway_speed railwaySpeed,
  630. nvl(meter_weight, 0) meterWeight,
  631. weight_type weightType,
  632. create_man_no createManNo,
  633. railway_model_name railwayModelName,
  634. create_man_name createManName,
  635. to_char(create_time, 'yyyy-mm-dd hh24:mi:ss') createTime,
  636. base_spot_no baseSpotNo,
  637. base_spot_name baseSpotName,
  638. value_flag valueFlag,
  639. shipment_Gross_Weight shipmentGrossWeight,
  640. shipment_Net_Weight shipmentNetWeight
  641. from Meter_Work_Railway_Act_First
  642. 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";
  643. dtRailwayActFirst.Clear();
  644. DataTable dtV = dtRailwayActFirst.Clone();
  645. PbModelDbService<List<MeterWorkRailwayActFirst>> pb = new PbModelDbService<List<MeterWorkRailwayActFirst>>();
  646. RESTfulResult<List<MeterWorkRailwayActFirst>> rmType = pb.executeSqlDataWf(sql);
  647. if (rmType.Succeed && rmType.Data != null && rmType.Data.Count > 0)
  648. {
  649. dtV = rmType.Data.ListToDataTable<MeterWorkRailwayActFirst>();
  650. }
  651. ClsControlPack.CopyDataToDatatable(ref dtV, ref this.dtRailwayActFirst, true);
  652. ClsControlPack.RefreshAndAutoSize(ultraGridFirst);
  653. }
  654. private void BindNetWgt()
  655. {
  656. string sql = $@"select * from (select actual_no actualNo,
  657. prediction_no predictionNo,
  658. notice_no noticeNo,
  659. railway_no railwayNo,
  660. railway_carriage_no railwayCarriageNo,
  661. matter_no matterNo,
  662. matter_name matterName,
  663. contract_no contractNo,
  664. batch_no batchNo,
  665. customer_supplier_no customerSupplierNo,
  666. customer_supplier_name customerSupplierName,
  667. forwarding_unit_no forwardingUnitNo,
  668. forwarding_unit_name forwardingUnitName,
  669. receiving_uint_no receivingUintNo,
  670. receiving_uint_name receivingUintName,
  671. material_no materialNo,
  672. material_name materialName,
  673. spec_no specNo,
  674. spec_name specName,
  675. load_point_no loadPointNo,
  676. load_point_name loadPointName,
  677. sample_voucher sampleVoucher,
  678. carrier_unit_no carrierUnitNo,
  679. carrier_unit_name carrierUnitName,
  680. meter_type_no meterTypeNo,
  681. meter_type_name meterTypeName,
  682. meter_process_no meterProcessNo,
  683. meter_process_edition_no meterProcessEditionNo,
  684. actual_first1_no actualFirst1No,
  685. nvl(gross_weight,0) grossWeight,
  686. gross_man_no grossManNo,
  687. gross_man_name grossManName,
  688. to_char(gross_time, 'yyyy-mm-dd hh24:mi:ss') grossTime ,
  689. base_spot1_no baseSpot1No,
  690. base_spot1_name baseSpot1Name,
  691. gross_class grossClass,
  692. gross_group grossGroup,
  693. gross_mode grossMode,
  694. actual_first2_no actualFirst2No,
  695. nvl(tare_weight,0) tareWeight,
  696. tare_man_no tareManNo,
  697. tare_man_name tareManName,
  698. to_char(tare_time, 'yyyy-mm-dd hh24:mi:ss') tareTime ,
  699. base_spot2_no baseSpot2No,
  700. base_spot2_name baseSpot2Name,
  701. tare_class tareClass,
  702. tare_group tareGroup,
  703. tare_mode tareMode,
  704. nvl(net_weight,0) netWeight,
  705. net_man_no netManNo,
  706. net_man_name netManName,
  707. to_char(net_time, 'yyyy-mm-dd hh24:mi:ss') netTime ,
  708. net_spot3_no netSpot3No,
  709. net_spot3_name netSpot3Name,
  710. net_class netClass,
  711. net_group netGroup,
  712. net_mode netMode,
  713. value_flag valueFlag,
  714. upload_flag uploadFlag,
  715. check_man_no checkManNo,
  716. check_man_name checkManName,
  717. to_char(check_time, 'yyyy-mm-dd hh24:mi:ss') checkTime ,
  718. upload_man_no uploadManNo,
  719. upload_man_name uploadManName,
  720. to_char(upload_time, 'yyyy-mm-dd hh24:mi:ss') uploadTime,
  721. sample_no sampleNo,
  722. railway_type_no railwayTypeNo,
  723. railway_type_name railwayTypeName,
  724. water_num waterNum,
  725. round((nvl(net_weight,0)- nvl(net_weight,0) * nvl(water_num,0)/100),2) dryWgt,
  726. RAILWAY_MODEL_NAME railwayModelName
  727. from meter_work_railway_actual
  728. where value_flag = '0' and railway_no='{txtCarNo.Text.Trim()}' and NET_SPOT3_NO ='00012' order by net_time desc) where rownum<10";
  729. dtRailwayActual.Clear();
  730. DataTable dt = dtRailwayActual.Clone();
  731. PbModelDbService<List<MeterWorkRailwayActual>> pb = new PbModelDbService<List<MeterWorkRailwayActual>>();
  732. RESTfulResult<List<MeterWorkRailwayActual>> rmType = pb.executeSqlDataWf(sql);
  733. if (rmType.Succeed && rmType.Data != null && rmType.Data.Count > 0)
  734. {
  735. dt = rmType.Data.ListToDataTable<MeterWorkRailwayActual>();
  736. }
  737. ClsControlPack.CopyDataToDatatable(ref dt, ref this.dtRailwayActual, true);
  738. ClsControlPack.RefreshAndAutoSize(ultraGridNet);
  739. }
  740. private void btnTareSave_Click(object sender, EventArgs e)
  741. {
  742. if (PbStaticRailwayCache.sportInfo == null)
  743. {
  744. MessageBox.Show("请先接管计量点");
  745. return;
  746. }
  747. if (txtCarNo.Text.Trim() == "")
  748. {
  749. MessageBox.Show("请先输入车号");
  750. return;
  751. }
  752. double db = ucStorageWeightT1.getWgt();
  753. if (ucStorageWeightT1.getWgt() < 1)
  754. {
  755. MessageBox.Show("当前重量过小");
  756. return;
  757. }
  758. MeterWorkRailwayActFirst fs = new MeterWorkRailwayActFirst();
  759. fs.railwayNo = txtCarNo.Text.Trim();
  760. fs.actualFirstNo = "";
  761. fs.railwayCarriageNo = "";
  762. fs.railwaySpeed = 0;
  763. fs.createTime = new DateTime();
  764. fs.baseSpotNo = "00012";
  765. fs.baseSpotName = "静态轨道衡";
  766. fs.valueFlag = "1";
  767. fs.createManNo = appUser.userid;
  768. fs.createManName = appUser.username;
  769. fs.shipmentGrossWeight = 0;
  770. fs.shipmentNetWeight = 0;
  771. fs.weightType = "1";
  772. fs.createTime = DateTime.Now;
  773. //==============================================================
  774. fs.meterWeight = ucStorageWeightT1.getWgt();
  775. fs.predictionNo = txtPredictionNo.Text.Trim();
  776. fs.matterName = txtMatterName.Text.Trim();
  777. fs.customerSupplierName = txtCustomerSupplierName.Text.Trim();
  778. fs.forwardingUnitName = fs.customerSupplierName;
  779. fs.receivingUintName = txtReceivingUintName.Text.Trim();
  780. fs.memo = txtMemo.Text.Trim();
  781. fs.railwayTypeNo = "001019001";
  782. fs.railwayTypeName = "静态轨道衡";
  783. //==============================================================
  784. RESTfulResult<string> result = actFirstService.doAddStaticRailWf(fs);
  785. if (result.Succeed)
  786. {
  787. if (txtGroess.Text.Trim() != "")
  788. {
  789. txtTare.Text = ucStorageWeightT1.getWgt() + "";
  790. txtNet.Text = (first.meterWeight - ucStorageWeightT1.getWgt()) + "";
  791. }
  792. BindFirstWgt();
  793. BindNetWgt();
  794. }
  795. }
  796. private void btnGrossSave_Click(object sender, EventArgs e)
  797. {
  798. if (PbStaticRailwayCache.sportInfo == null)
  799. {
  800. MessageBox.Show("请先接管计量点");
  801. return;
  802. }
  803. if (txtCarNo.Text.Trim() == "")
  804. {
  805. MessageBox.Show("请先输入车号");
  806. return;
  807. }
  808. if (ucStorageWeightT1.getWgt() < 1)
  809. {
  810. MessageBox.Show("当前重量过小");
  811. return;
  812. }
  813. MeterWorkRailwayActFirst fs = new MeterWorkRailwayActFirst();
  814. fs.railwayNo = txtCarNo.Text.Trim();
  815. fs.actualFirstNo = "";
  816. fs.railwayCarriageNo = "";
  817. fs.railwaySpeed = 0;
  818. fs.createTime = new DateTime();
  819. fs.baseSpotNo = "00012";
  820. fs.baseSpotName = "静态轨道衡";
  821. fs.valueFlag = "1";
  822. fs.createManNo = appUser.userid;
  823. fs.createManName = appUser.username;
  824. fs.shipmentGrossWeight = 0;
  825. fs.shipmentNetWeight = 0;
  826. fs.weightType = "0";
  827. fs.createTime = DateTime.Now;
  828. //==============================================================
  829. fs.meterWeight = ucStorageWeightT1.getWgt();
  830. fs.predictionNo = txtPredictionNo.Text.Trim();
  831. fs.matterName = txtMatterName.Text.Trim();
  832. fs.customerSupplierName = txtCustomerSupplierName.Text.Trim();
  833. fs.forwardingUnitName = fs.customerSupplierName;
  834. fs.receivingUintName = txtReceivingUintName.Text.Trim();
  835. fs.memo = txtMemo.Text.Trim();
  836. fs.railwayTypeNo = "001019001";
  837. fs.railwayTypeName = "静态轨道衡";
  838. //==============================================================
  839. RESTfulResult<string> result = actFirstService.doAddStaticRailWf(fs);
  840. if (result.Succeed)
  841. {
  842. if (txtTare.Text.Trim() != "")
  843. {
  844. txtGroess.Text = ucStorageWeightT1.getWgt() + "";
  845. txtNet.Text = (ucStorageWeightT1.getWgt() - first.meterWeight) + "";
  846. }
  847. BindFirstWgt();
  848. BindNetWgt();
  849. }
  850. }
  851. private void timer1_Tick(object sender, EventArgs e)
  852. {
  853. if (ucStorageWeightT1.getWgt() > 1000)
  854. {
  855. if (fm == null)
  856. {
  857. fm = frmMsgInfo.CreateInstrance();
  858. fm.setLbTxt("静态轨道衡");
  859. }
  860. }
  861. else
  862. {
  863. if (fm != null)
  864. {
  865. fm.setFrmNull();
  866. fm.CloseFrm();
  867. fm = null;
  868. }
  869. }
  870. }
  871. //private void button1_Click(object sender, EventArgs e)
  872. //{
  873. // decimalWgt = ((int)numericUpDown1.Value);
  874. // bTest = !bTest;
  875. //}
  876. /// <summary>
  877. /// 不显示大图
  878. /// </summary>
  879. private void pictureShow_DoubleClick(object sender, EventArgs e)
  880. {
  881. plImgShow.Visible = false;
  882. cameraShotMain.StopRealPlay(iPic);
  883. iPic = 0;
  884. }
  885. #endregion
  886. }
  887. }