diff --git a/CheckCode.cs b/CheckCode.cs
index 39fd480..2f07101 100644
--- a/CheckCode.cs
+++ b/CheckCode.cs
@@ -426,7 +426,7 @@ namespace ZJ_BYD
///
///
///
- public static (bool ok, string msg) SaveDb(string stationCode, string barCode)
+ public static (bool ok, string msg, T_Result _Result) SaveDb(string stationCode, string barCode)
{
if (Program.type == null)
{
@@ -479,7 +479,7 @@ namespace ZJ_BYD
keyValItem.Val = EnumHelper.GetEnumDescription(enumVal);
if (keyValItem.Val != "OK" && keyValItem.Val != "NG")
{
- return (false, $"一体机数据上传反馈:{keyValItem.KeyDesc}异常={keyValItem.Val},存库NG!");
+ return (false, $"一体机数据上传反馈:{keyValItem.KeyDesc}异常={keyValItem.Val},存库NG!", null);
}
}
prop.SetValue(result, Convert.ChangeType(keyValItem.Val, prop.PropertyType));
@@ -488,18 +488,18 @@ namespace ZJ_BYD
#endregion
var t_Result = result as T_Result;
- t_Result.LineCode = Program.CurrentLineCode;
+ t_Result.LineCode = Program.CurrentLineCode.Replace("\x00", "");
t_Result.StationCode = stationCode;
//主条码
var M28 = list.FirstOrDefault(m => m.Key == "M28");
//重新读取PLc中的主条码 2023-9-20新增逻辑
- var readM28 = PlcHelper.GetPlcVal(M28.DataType, M28.Address);
+ var readM28 = PlcHelper.GetPlcVal(M28.DataType, M28.Address,M28.Length);
if (readM28.ok)
{
M28.Val = readM28.val.Replace("\r", "");
LogHelper.WriteLog($"存本地数据库时,获取到的壳体码={M28.Val}");
}
- t_Result.ProductSfcCode = M28.Val.Replace("\r", "");
+ t_Result.ProductSfcCode = M28.Val.Replace("\r", "").Replace("\x00", "");
//产品总状态
var M5 = list.FirstOrDefault(m => m.Key == "M5");
if (M5 != null && (M5.Val == "undefined" || M5.Val == "UNDEFINED" || M5.Val == "0.000"))
@@ -518,7 +518,7 @@ namespace ZJ_BYD
M5.Val = EnumHelper.GetEnumDescription(enumVal);
if (M5.Val != "OK" && M5.Val != "NG")
{
- return (false, $"一体机数据上传反馈:产品状态异常={M5.Val},存库NG!");
+ return (false, $"一体机数据上传反馈:产品状态异常={M5.Val},存库NG!", t_Result);
}
}
else
@@ -535,7 +535,7 @@ namespace ZJ_BYD
t_Result.Category = station.Category;
}
t_Result.TestFileName = Program.testfilename;
- t_Result.BarCode = barCode;
+ t_Result.BarCode = barCode.Replace("\x00", "");
t_Result.ProgramVersion = Program.programversion;
t_Result.LoginUser = CurrentUser.UserName;
t_Result.SysMode = Program.SysMode;
@@ -549,7 +549,7 @@ namespace ZJ_BYD
{
if (!string.IsNullOrWhiteSpace(subs[i].Val))
{
- strSubCode += $"{subs[i].Val},";
+ strSubCode += $"{subs[i].Val.Replace("\x00", "")},";
}
}
t_Result.BulkParts = strSubCode.TrimEnd(',');
@@ -564,22 +564,22 @@ namespace ZJ_BYD
if (addResult <= 0)
{
LogHelper.WriteLog($"{stationCode}工位,新增结果失败:{JsonConvert.SerializeObject(t_Result)}");
- return (false, "一体机数据上传反馈:存库NG!");
+ return (false, "一体机数据上传反馈:存库NG!", t_Result);
}
else
{
- return (true, $"一体机数据上传反馈:存库OK!,产品总状态:{t_Result.TotalStatus}");
+ return (true, $"一体机数据上传反馈:存库OK!,产品总状态:{t_Result.TotalStatus}", t_Result);
}
}
catch (Exception ex)
{
LogHelper.WriteLog($"一体机数据上传反馈:{stationCode}工位存库发生异常:{ex.Message}!");
- return (false, "一体机数据上传反馈:存库NG!");
+ return (false, "一体机数据上传反馈:存库NG!",null);
}
}
else
{
- return (false, "一体机数据上传反馈:存库NG!");
+ return (false, "一体机数据上传反馈:存库NG!", null);
}
}
diff --git a/Common/CurrentUser.cs b/Common/CurrentUser.cs
index db48fa3..bb4d86c 100644
--- a/Common/CurrentUser.cs
+++ b/Common/CurrentUser.cs
@@ -15,5 +15,10 @@
/// 姓名
///
public static string RealName { get; set; }
+
+ ///
+ /// 机型
+ ///
+ public static string MachineType { get;set; }
}
}
diff --git a/Common/HttpUtilApi.cs b/Common/HttpUtilApi.cs
index e68086d..23a01ba 100644
--- a/Common/HttpUtilApi.cs
+++ b/Common/HttpUtilApi.cs
@@ -54,7 +54,7 @@ namespace ZJ_BYD.Common
ResponseParam result = null;
try
{
- var jsonStr = JsonConvert.SerializeObject(submitWorkStationDataUrl);
+ var jsonStr = JsonConvert.SerializeObject(workData);
var respStr = Post(submitWorkStationDataUrl, jsonStr);
diff --git a/Common/PlcHelper.cs b/Common/PlcHelper.cs
index 62f0ce3..2dae5c3 100644
--- a/Common/PlcHelper.cs
+++ b/Common/PlcHelper.cs
@@ -14,7 +14,7 @@ namespace ZJ_BYD.Common
///
///
///
- public static (bool ok, string val) GetPlcVal(string dataType, string address, string length = "1")
+ public static (bool ok, string val) GetPlcVal(string dataType, string address, string length = "40")
{
var strVal = string.Empty;
try
@@ -118,6 +118,10 @@ namespace ZJ_BYD.Common
else
{
strVal = operateFloatResult.Content;
+ if (!string.IsNullOrEmpty(strVal))
+ {
+ strVal = strVal.Substring(2, strVal.Length - 2).Trim();
+ }
return (true, strVal);
}
}
diff --git a/DoSomething.cs b/DoSomething.cs
index d371d47..3d986f9 100644
--- a/DoSomething.cs
+++ b/DoSomething.cs
@@ -12,6 +12,7 @@ using ZJ_BYD.Common;
using ZJ_BYD.DB;
using ZJ_BYD.Enums;
using ZJ_BYD.Model;
+using ZJ_BYD.Model.HttpApiParam;
using ZJ_BYD.Untils;
using ZJ_BYD.ViewModel;
@@ -124,7 +125,7 @@ namespace ZJ_BYD
{
foreach (var plcPoint in _plcPoints)
{
- var plcResult = PlcHelper.GetPlcVal(plcPoint.DataType, plcPoint.Address);
+ var plcResult = PlcHelper.GetPlcVal(plcPoint.DataType, plcPoint.Address,plcPoint.Length);
if (plcResult.ok)
{
string strVal = plcResult.val;
@@ -611,7 +612,7 @@ namespace ZJ_BYD
#region 本地存储
//存本地库
- var (ok, msg) = CheckCode.SaveDb(_stationInfo.StationCode, BarCode);
+ var (ok, msg,_result) = CheckCode.SaveDb(_stationInfo.StationCode, BarCode);
_logs.Add(new LogVm
{
StationCode = _stationInfo.StationCode,
@@ -628,13 +629,50 @@ namespace ZJ_BYD
#region 上传MES
- var M14 = _plcPoints.FirstOrDefault(m => m.Key == "M14");
- var mskCode = Program.t_MaskCodes.First(m => m.StationCode == _stationInfo.StationCode && m.SortIndex == int.Parse(M14.Val));
- if (mskCode != null)
+ if (Program.SysMode)
{
- var M5 = _plcPoints.FirstOrDefault(m => m.Key == "M5");
- var testList = Program.PointKeyValues
- .Where(m => m.StationCode == _stationInfo.StationCode && m.IsTestItem).ToList();
+ var M14 = _plcPoints.FirstOrDefault(m => m.Key == "M14");
+ var mskCode = Program.t_MaskCodes.First(m => m.StationCode == _stationInfo.StationCode && m.SortIndex == int.Parse(M14.Val));
+ if (mskCode != null)
+ {
+ var M5 = _plcPoints.FirstOrDefault(m => m.Key == "M5");
+ var testList = Program.PointKeyValues
+ .Where(m => m.StationCode == _stationInfo.StationCode && m.IsTestItem).ToList();
+
+ WorkData workData = new WorkData();
+ List dParams = new List();
+
+ if (testList != null)
+ {
+ foreach (var item in testList)
+ {
+ DParams param = new DParams();
+ param.n = item.KeyDesc;
+ param.ng = item.Result;
+ param.v = item.Val;
+ dParams.Add(param);
+ }
+ }
+ workData.dparams = dParams;
+ workData._operator = _result.LoginUser;
+ workData.snList = _result.BulkParts;
+ workData.qc = _result.TotalStatus == "OK" ? 0 : 1;
+ workData.productCode = _result.Category;
+ workData.workStationCode = _result.StationCode;
+ workData.rfId = _result.ProductSfcCode;
+ ResponseParam result = HttpUtilApi.submitWorkStationData(workData);
+
+ if (result.code != 200)
+ {
+ ok = false;
+
+ }
+ _logs.Add(new LogVm
+ {
+ StationCode = _stationInfo.StationCode,
+ HisLog = $"{DateTime.Now:HH:mm:ss}>>>>>{result.msg}{Environment.NewLine}"
+ });
+ }
}
else
{
diff --git a/LoginFrom.cs b/LoginFrom.cs
index 52a9dd7..af683ba 100644
--- a/LoginFrom.cs
+++ b/LoginFrom.cs
@@ -260,20 +260,20 @@ namespace ZJ_BYD
{
if (Program.siemensS7Net != null)
{
- foreach (var item in plcPoints)
- {
- var result = Program.siemensS7Net.Write(item.Address, ushort.Parse("2"));
- if (!result.IsSuccess)
- {
- result = Program.siemensS7Net.Write(item.Address, ushort.Parse("2"));
- if (!result.IsSuccess)
- {
- XtraMessageBox.Show($"离线模式登录时,[{item.StationCode}]工位用户验证结果写入失败,请重新登录!", "系统提示");
- Environment.Exit(0);
- }
- }
- Thread.Sleep(100);
- }
+ //foreach (var item in plcPoints)
+ //{
+ // var result = Program.siemensS7Net.Write(item.Address, ushort.Parse("2"));
+ // if (!result.IsSuccess)
+ // {
+ // result = Program.siemensS7Net.Write(item.Address, ushort.Parse("2"));
+ // if (!result.IsSuccess)
+ // {
+ // XtraMessageBox.Show($"离线模式登录时,[{item.StationCode}]工位用户验证结果写入失败,请重新登录!", "系统提示");
+ // Environment.Exit(0);
+ // }
+ // }
+ // Thread.Sleep(100);
+ //}
}
else
{
diff --git a/Main.cs b/Main.cs
index 153b9f4..49e4d90 100644
--- a/Main.cs
+++ b/Main.cs
@@ -44,14 +44,14 @@ namespace ZJ_BYD
//gridFinished.DataSource = _bindingResultFinishedCodeVMs;
_bindingResultFinishedCodeVMs.ListChanged += OnParamBindingListChanged;
- Task.Run(() =>
- {
- while (!cancellationTokenSource.IsCancellationRequested)
- {
- MyMethod();
- Thread.Sleep(3000);
- }
- }, cancellationTokenSource.Token);
+ //Task.Run(() =>
+ //{
+ // while (!cancellationTokenSource.IsCancellationRequested)
+ // {
+ // MyMethod();
+ // Thread.Sleep(3000);
+ // }
+ //}, cancellationTokenSource.Token);
}
System.Timers.Timer timer;
@@ -738,14 +738,24 @@ namespace ZJ_BYD
{
BeginInvoke(new Action(() =>
{
- machineTypeControl.Text = "当前机型:"+M14.Val;
+ var station = Program.stationInfos.FirstOrDefault(m => m.StationCode == Program.ActiveStatinCode && m.MachineTypeIndex.ToString() == M14?.Val);
+
+ if(station != null)
+ {
+ machineTypeControl.Text = "当前机型:" + station.Category;
+ CurrentUser.MachineType = station.Category;
+ }
+ else
+ {
+ machineTypeControl.Text = "未获取到机型";
+ }
}));
}
else
{
BeginInvoke(new Action(() =>
{
- machineTypeControl.Text = "未获取到机型索引";
+ machineTypeControl.Text = "未获取到机型";
}));
}