| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244 |
- using com.hnshituo.core.webapp.vo;
- using Common;
- using Infragistics.Win;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace StorageMeterSystem
- {
- public partial class frmCalibration : Form
- {
- public frmCalibration()
- {
- InitializeComponent();
- }
- Log lg = Log.GetInstance();
- //校秤主
- MeterWorkCalibrationMainService calibrationMainService = new MeterWorkCalibrationMainService();
- //校秤从
- MeterWorkCalibrationBranchService calibrationBranchService = new MeterWorkCalibrationBranchService();
- MeterBaseMutualDiffService mutualDiffService = new MeterBaseMutualDiffService();//互检差值
- ComBaseInfoService cis = new ComBaseInfoService();
- MeterWorkCalibrationBranch calibrationBranch { get; set; }
- public string userId = "", userName = "";
- private void timer1_Tick(object sender, EventArgs e)
- {
- txtWgt.Value = (decimal)Math.Round(PbStorageCache.collect.mainWgt, 1);
- }
- private void btnClose_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- private void btnSave_Click(object sender, EventArgs e)
- {
- lbMsgInfo.Visible = false;
- if (cbCalibrationType.Value == null || cbCalibrationType.Text.Trim() == "")
- {
- MessageBox.Show("请选择校秤类型");
- return;
- }
- if (cbCalibrationType.Value != null && cbCalibrationType.Value.ToString() == "001005002")
- {
- if (cbWorkMonitor.Value == null || cbWorkMonitor.Text.Trim() == "")
- {
- MessageBox.Show("请选择对比计量点");
- return;
- }
- }
- DialogResult dr = MessageBox.Show("确认进行校秤吗?", "提示", MessageBoxButtons.OKCancel);
- if (dr == DialogResult.OK)
- {
- btnSave.Enabled = false;
- string baseContrastNo = PbStorageCache.sportInfo.baseSpotNo;
- string baseContrastName = PbStorageCache.sportInfo.baseSpotName;
- string dbWgt = PbStorageCache.collect.mainWgt + "";
- if (calibrationBranch != null)
- {
- baseContrastNo = calibrationBranch.baseSpotNo;
- baseContrastName = calibrationBranch.baseSpotName;
- dbWgt = calibrationBranch.calibrationWeight;
- }
- RESTfulResult<MeterWorkCalibrationBranch> rm = calibrationMainService.doSaveWf(
- new MeterWorkCalibrationMain
- {
- baseSpotNo = baseContrastNo,
- baseSpotName = baseContrastName,
- spotTypeNo = cbSpotType.Value == null ? "001002003" : cbSpotType.Value.ToString().Trim(),
- spotTypeName = cbSpotType.Text == "" ? "成品秤" : cbSpotType.Text.Trim(),
- calibrationTypeNo = cbCalibrationType.Value == null ? "" : cbCalibrationType.Value.ToString().Trim(),
- calibrationTypeName = cbCalibrationType.Text,
- baseContrastSpotNo = cbWorkMonitor.Value == null ? "" : cbWorkMonitor.Value.ToString().Trim(),
- baseContrastSpotName = cbWorkMonitor.Text.Trim()
- },
- new MeterWorkCalibrationBranch
- {
- baseSpotNo = baseContrastNo,
- baseSpotName = baseContrastName,
- calibrationWeight = dbWgt + "",
- spotTypeNo = cbSpotType.Value == null ? "001002003" : cbSpotType.Value.ToString().Trim(),
- spotTypeName = cbSpotType.Text == "" ? "成品秤" : cbSpotType.Text.Trim(),
- calibrationTypeNo = cbCalibrationType.Value == null ? "" : cbCalibrationType.Value.ToString().Trim(),
- calibrationTypeName = cbCalibrationType.Text,
- createManNo = userId,
- createManName = userName
- }
- );
- if (rm.Succeed)
- {
- #region 截取图片信息
- try
- {
- calibrationBranch = rm.Data;
- //*
- //截取屏幕信息
- 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,
- PbStorageCache.sportInfo.baseSpotNo,
- "S" + rm.Message,
- (PbStorageCache.videoChild.Count + 1)), System.Drawing.Imaging.ImageFormat.Jpeg);
- //循环摄像头,然后根据摄像头有多少,则取硬盘录像机多少个通道数据
- for (uint i = 1; i <= CarCache.cameraShots.Count; i++)
- {
- cameraShotMain.CapPicFromVideo(i,
- string.Format("{0}\\imgShort\\formalImg\\{1}_{2}_{3}",
- AppDomain.CurrentDomain.SetupInformation.ApplicationBase,
- PbStorageCache.sportInfo.baseSpotNo,
- "S" + rm.Message, i)
- );
- }
- /*
- //最后进行截图操作
- CameraShotCls cameraShot = new CameraShotCls();
- cameraShot.CapMethod(rm.Message);
- //*/
- }
- catch (Exception ex)
- {
- lg.WriteLog(5, PbStorageCache.sportInfo.baseSpotName + "校秤截图失败");
- }
- #endregion
- if (rm.Data == null || string.IsNullOrEmpty(rm.Data.baseSpotNo))
- {
- this.DialogResult = DialogResult.OK;
- this.Close(); //校秤成功了,可能是单点通过,可能是同时通过
- }
- else //说明是单点校秤然后失败了,此时提醒选择下一个对比校秤点
- {
- cbWorkMonitor.Enabled = true;
- cbCalibrationType.Enabled = true;
- lbMsgInfo.Visible = true;
- btnSave.Enabled = true;
- }
- }
- else
- {
- MessageBox.Show("校秤异常:" + rm.Message);
- btnSave.Enabled = true;
- }
- }
- }
- public CameraShotCls cameraShotMain { get; set; }
- private void frmCalibration_FormClosing(object sender, FormClosingEventArgs e)
- {
- timer1.Stop();
- }
- private void frmCalibration_Load(object sender, EventArgs e)
- {
- timer1.Start();
- ValueList vlistSpot = new ValueList();
- vlistSpot.ValueListItems.Add("001002003", "成品秤");
- cbSpotType.ValueList = vlistSpot;
- cbSpotType.Value = "001002003";
- cbSpotType.Enabled = false;
- //校秤类型
- RESTfulResult<List<PbModelDb>> rm = cis.doQueryWf(new ComBaseInfo { pBaseCode = "001005" });
- ValueList vlistCalibration = new ValueList();
- foreach (PbModelDb pb in rm.Data)
- {
- vlistCalibration.ValueListItems.Add(pb.id, pb.text);
- }
- cbCalibrationType.ValueList = vlistCalibration;
- RESTfulResult<List<MeterWorkCalibrationBranch>> rmMwcb = calibrationBranchService.doQueryWf(new MeterWorkCalibrationBranch { baseSpotNo = PbStorageCache.sportInfo.baseSpotNo });
- if (rmMwcb.Succeed)
- {
- if (rmMwcb.Data != null && rmMwcb.Data.Count > 0)
- {
- cbCalibrationType.Value = rmMwcb.Data[0].calibrationTypeNo;
- cbWorkMonitor.Value = rmMwcb.Data[0].baseSpotNo;
- cbCalibrationType.Enabled = false;
- cbWorkMonitor.Enabled = false;
- }
- }
- }
- private void cbCalibrationType_SelectionChanged(object sender, EventArgs e)
- {
- //互检
- if (cbCalibrationType.Value != null && cbCalibrationType.Value.ToString() == "001005002")
- {
- label1.Visible = true;
- cbWorkMonitor.Visible = true;
- RESTfulResult<List<MeterBaseMutualDiff>> rm = mutualDiffService.doQueryWf(new MeterBaseMutualDiff { baseSpotOneNo = PbStorageCache.sportInfo.baseSpotNo });
- if (rm.Data == null || rm.Data.Count == 0)
- {
- MessageBox.Show("互检差值表未配置当前计量点对应的互检计量点数据");
- return;
- }
- ValueList vlist = new ValueList();
- foreach (MeterBaseMutualDiff diff in rm.Data)
- {
- vlist.ValueListItems.Add(diff.baseSpotOneNo, diff.baseSpotOneName);
- }
- cbWorkMonitor.ValueList = vlist;
- }
- else
- {
- cbWorkMonitor.SelectedIndex = -1;
- cbWorkMonitor.ValueList = null;
- label1.Visible = false;
- cbWorkMonitor.Visible = false;
- }
- }
- }
- }
|