diff --git a/Admin.Core.Api/Admin.Core.Model.xml b/Admin.Core.Api/Admin.Core.Model.xml
index 1253d367..9408fbfb 100644
--- a/Admin.Core.Api/Admin.Core.Model.xml
+++ b/Admin.Core.Api/Admin.Core.Model.xml
@@ -2756,6 +2756,11 @@
异常类型(1=69码校验;2=重复扫描;3=未绑条码;4=未终检)
+
+
+ 所在位置
+
+
计划执行表
diff --git a/Admin.Core.Model/Model_New/ExceptionRecord.cs b/Admin.Core.Model/Model_New/ExceptionRecord.cs
index 4e077b05..e4a7d6a6 100644
--- a/Admin.Core.Model/Model_New/ExceptionRecord.cs
+++ b/Admin.Core.Model/Model_New/ExceptionRecord.cs
@@ -48,7 +48,12 @@ namespace Admin.Core.Model
///
[SugarColumn(ColumnName = "EXCEPTION_TYPE")]
public int ExceptionType { get; set; }
-
+
+ ///
+ /// 所在位置
+ ///
+ [SugarColumn(ColumnName = "POSITION")]
+ public string Position { get; set; }
}
}
diff --git a/Aucma.Core.CodeBinding/Common/SpeechStr.cs b/Aucma.Core.CodeBinding/Common/SpeechStr.cs
index 5a1dac7a..32b4f782 100644
--- a/Aucma.Core.CodeBinding/Common/SpeechStr.cs
+++ b/Aucma.Core.CodeBinding/Common/SpeechStr.cs
@@ -18,7 +18,7 @@ namespace Aucma.Core.CodeBinding.Common
}
}
- public void speech(string str) {
+ public async void SpeakAsync(string str) {
SpeechSynthesizer speech = new SpeechSynthesizer();
speech.Rate = 3;//设置语速
diff --git a/Aucma.Core.CodeBinding/ViewModels/IndexPageViewModel.cs b/Aucma.Core.CodeBinding/ViewModels/IndexPageViewModel.cs
index 4d292e36..7ae0a039 100644
--- a/Aucma.Core.CodeBinding/ViewModels/IndexPageViewModel.cs
+++ b/Aucma.Core.CodeBinding/ViewModels/IndexPageViewModel.cs
@@ -68,6 +68,16 @@ namespace Aucma.Core.CodeBinding.ViewModels
// sn扫码器ip
private static string SnScannerIp = allScanners.First(x => x.Name == "sn扫码器").Ip;
+ private SpeechStr speechStr = SpeechStr.Instance;
+
+ private string ProductLineCode = Appsettings.app("StationInfo", "ProductLineCode");
+
+
+
+ // 质检记录
+ private readonly IReportQualityInspectionServices? _reportQualityInspectionServices;
+ //异常记录,记录质检失败情况
+ private readonly IExceptionRecordServices? exceptionRecordServices;
public IndexPageViewModel()
{
@@ -76,9 +86,10 @@ namespace Aucma.Core.CodeBinding.ViewModels
_codeBindingRecordServices = App.ServiceProvider.GetService();
_baseBomInfoServices = App.ServiceProvider.GetService();
_baseMaterialInfoServices = App.ServiceProvider.GetService();
-
+ _reportQualityInspectionServices = App.ServiceProvider.GetService();
_printBarCodeServices = App.ServiceProvider.GetService();
_iMaterialCompletionServices = App.ServiceProvider.GetService();
+ exceptionRecordServices = App.ServiceProvider.GetService();
// Business.MvCodeHelper.ReceiveCodeEvent += ReceiveCode;
// Business.MvCodeHelper.BindingCodeEvent += BindingCode;
// Business.MvCodeHelper.NoReadEvent += ReceiveNoRead;
@@ -86,20 +97,15 @@ namespace Aucma.Core.CodeBinding.ViewModels
TouchSocketService.NoReadReceiveEvent += ReceiveNoRead;
GunBusiness.BindingReceiveCodeEvent += BindingCode;
GunBusiness.RefreshMaterialCodeStrEvent += ReceiveCode;
-
+ MsgUIColor = "White";
LoadData();
-
+
//实时绑定条码和实时下发plc放行信号
realBindingAndSendPlc();
LoadCharts();
- //Task.Run(() =>
- //{
- // Thread.Sleep(4000);
-
- //});
-
+
}
catch (Exception ex)
@@ -109,7 +115,6 @@ namespace Aucma.Core.CodeBinding.ViewModels
}
-
///
/// 实时绑定条码和实时下发plc放行信号
///
@@ -465,16 +470,18 @@ namespace Aucma.Core.CodeBinding.ViewModels
SendPlcStop();
Clear();
- RefreshAndWriteLog("MES条码未扫描到,NoRead报警,线体停止,请重新扫描!");
+ RefreshAndWriteLog("MES条码未扫描到,NoRead报警,线体停止,请重新扫描!",true);
+
}
else if (SnScannerIp == scannerIp)
- {
-
+ {
SendPlcStop();
Clear();
- RefreshAndWriteLog("SN条码未扫描到,NoRead报警,线体停止,请重新扫描!");
+ RefreshAndWriteLog("SN条码未扫描到,NoRead报警,线体停止,请重新扫描!", true);
+
}
+ speechStr.SpeakAsync("扫码失败,请补扫");
}
///
@@ -577,15 +584,33 @@ namespace Aucma.Core.CodeBinding.ViewModels
/// 提示信息刷新并且存日志
///
///
- private void RefreshAndWriteLog(string logStr)
+ private void RefreshAndWriteLog(string logStr,bool warnflag=false)
{
TimeSpan currentTime = DateTime.Now.TimeOfDay;
// DateTime time = System.DateTime.Now;
string timeString = currentTime.ToString(@"hh\:mm\:ss");
BindingInfo = timeString + ":" + logStr;
+ if(warnflag)
+ {
+ MsgUIColor = "Red";
+ }
+ else
+ {
+ MsgUIColor = "White";
+ }
log.Info(BindingInfo);
}
+ ///
+ /// 提示信息-颜色
+ ///
+ public string msgUIColor;
+ public string MsgUIColor
+ {
+ get => msgUIColor;
+ set => SetProperty(ref msgUIColor, value);
+ }
+
///
/// 条码绑定
///
@@ -598,16 +623,30 @@ namespace Aucma.Core.CodeBinding.ViewModels
{
if (code1.Substring(0, 1) != "B")
{
+ speechStr.SpeakAsync("扫码失败,请补扫");
RefreshAndWriteLog("MES码:" + code1 + ",扫描错误,请重新扫描!");
SendPlcStop();
return;
}
if (code2.Length != 20)
{
+ speechStr.SpeakAsync("扫码失败,请补扫");
RefreshAndWriteLog("SN码:" + code2 + ",扫描错误,请重新扫描!");
SendPlcStop();
return;
}
+ #region 终检校验-未查到终检合格记录即为质检不合格
+
+ ReportQualityInsPection qualityList = _reportQualityInspectionServices.JudgeIsQualified(code1);
+ if (qualityList == null)
+ {
+ SendPlcStop();
+ RefreshAndWriteLog($"终检失败!! 箱体码{code1}未查询到终检合格记录,请重新终检!",true);
+ speechStr.SpeakAsync("终检失败,请终检");
+ AddExceptionRecord(code1, $"终检失败!! 箱体码{code1}未查询到终检合格记录,请重新终检!", 4);
+ return;
+ }
+ #endregion
RefreshAndWriteLog("开始绑定MES条码:" + code1 + " SN条码:" + code2);
// 1.数据库查询各个工序质检结果,不合格报警
@@ -677,7 +716,7 @@ namespace Aucma.Core.CodeBinding.ViewModels
}
else
{
- RefreshAndWriteLog("条码【" + record.BoxCode + "】与SN码【" + record.ProductCode + "】绑定失败");
+ RefreshAndWriteLog("条码【" + record.BoxCode + "】与SN码【" + record.ProductCode + "】绑定失败", true);
if (SendPlcStop())
{
RefreshAndWriteLog("条码绑定失败,线体停止");
@@ -697,6 +736,31 @@ namespace Aucma.Core.CodeBinding.ViewModels
}
}
+
+ ///
+ /// 往mes数据库添加异常记录
+ ///
+ ///
+ ///
+ /// 1=69码校验;2=重复扫描;3=未绑条码;4=未终检
+ public async void AddExceptionRecord(string BoxCode, string Msg, int Type)
+ {
+ try
+ {
+ ExceptionRecord record = new ExceptionRecord();
+ record.ProductSnCode = BoxCode;
+ record.ProductScanTime = DateTime.Now;
+ record.ProductLineCode = ProductLineCode;
+ record.ExceptionMsg = Msg;
+ record.ExceptionType = Type;
+ record.Position = "条码绑定";
+ await exceptionRecordServices.AddAsync(record);
+ }
+ catch (Exception ex)
+ {
+ log.Info("添加异常记录方法AddExceptionRecord异常:" + ex.Message.ToString());
+ }
+ }
#region plc交互
///
diff --git a/Aucma.Core.CodeBinding/ViewModels/MainWindowViewModel.cs b/Aucma.Core.CodeBinding/ViewModels/MainWindowViewModel.cs
index 20334bc5..15271326 100644
--- a/Aucma.Core.CodeBinding/ViewModels/MainWindowViewModel.cs
+++ b/Aucma.Core.CodeBinding/ViewModels/MainWindowViewModel.cs
@@ -60,15 +60,32 @@ namespace Aucma.Core.CodeBinding.ViewModels
timer.Tick += Timer_Tick;
timer.Start();
Scanner1State(false);
- Scanner2State(false);
-
+ Scanner2State(false);
+ PlcState(false);
// Job_AllState_Quartz.RefreshStateEvent += RefreshStatus;
// MvCodeHelper.RefreshStateEvent += RefreshScanner;
TouchSocketService.RefreshStateEvent += RefreshScanner;
GunBusiness.InstanceSerialPort3();
+ updatePlcState();
// InitHikRobot();
}
+ private void updatePlcState()
+ {
+ Task.Run(() =>
+ {
+ Thread.Sleep(4000);
+ var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("条码绑定Plc"));
+ if (obj.plc.IsConnected)
+ {
+ PlcState(true);
+ }
+ else
+ {
+ PlcState(false);
+ }
+ });
+ }
#region 开启海康扫码器
public void InitHikRobot()
diff --git a/Aucma.Core.CodeBinding/Views/IndexPageView.xaml b/Aucma.Core.CodeBinding/Views/IndexPageView.xaml
index 4a15346f..43e1cea6 100644
--- a/Aucma.Core.CodeBinding/Views/IndexPageView.xaml
+++ b/Aucma.Core.CodeBinding/Views/IndexPageView.xaml
@@ -141,10 +141,12 @@
-
+
+
+
diff --git a/Aucma.Core.CodeBinding/Views/IndexPageView.xaml.cs b/Aucma.Core.CodeBinding/Views/IndexPageView.xaml.cs
index f09576eb..866a6ed4 100644
--- a/Aucma.Core.CodeBinding/Views/IndexPageView.xaml.cs
+++ b/Aucma.Core.CodeBinding/Views/IndexPageView.xaml.cs
@@ -16,6 +16,7 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Aucma.Core.HwPLc;
+using RabbitMQ.Client;
namespace Aucma.Core.CodeBinding.Views
{
@@ -35,52 +36,56 @@ namespace Aucma.Core.CodeBinding.Views
}
- private void Button_Click(object sender, RoutedEventArgs e)
+ public void Button_Click(object sender, RoutedEventArgs e)
{
- if (SendPlcPass())
+ MessageBoxResult result = MessageBox.Show("请先确认当前无未绑定箱体,如导致未绑定箱体将无法下线!!\n\n系统将会记录您当前行为,请谨慎使用该功能!!\n\n是否继续启动?", "确认", MessageBoxButton.YesNo, MessageBoxImage.Question);
+ if (result == MessageBoxResult.Yes)
{
- MessageBox.Show("放行成功");
- }
- else
- {
- MessageBox.Show("放行失败,plc未连接");
- }
- }
-
- ///
- /// 下发plc放行信号
- ///
- ///
- ///
- private bool SendPlcPass()
- {
- bool result = false;
- try
- {
- var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("条码绑定Plc"));
- if (obj != null)
+ if (SendPlcPass())
{
- //log.Info("停止信号D7102写1");
- // 停止信号复位
- obj.plc.WriteInt16("D7102", "0");
- // 报警信号复位
- obj.plc.WriteInt16("D7101", "0");
- result = true;
-
+ MessageBox.Show("放行成功");
}
else
{
- result = false;
+ MessageBox.Show("放行失败,plc未连接");
}
+ } }
- }
- catch (Exception ex)
+
+ ///
+ /// 下发plc放行信号
+ ///
+ ///
+ ///
+ public bool SendPlcPass()
{
- result = false;
- // log.Error("下发plc停止信号方法出现异常,ex:" + ex);
- }
- return result;
- }
+ bool result = false;
+ try
+ {
+ var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("条码绑定Plc"));
+ if (obj != null)
+ {
+ //log.Info("停止信号D7102写1");
+ // 停止信号复位
+ obj.plc.WriteInt16("D7102", "0");
+ // 报警信号复位
+ obj.plc.WriteInt16("D7101", "0");
+ result = true;
+
+ }
+ else
+ {
+ result = false;
+ }
+
+ }
+ catch (Exception ex)
+ {
+ result = false;
+ // log.Error("下发plc停止信号方法出现异常,ex:" + ex);
+ }
+ return result;
+ }
}
diff --git a/Aucma.Core.CodeBinding/appsettings.json b/Aucma.Core.CodeBinding/appsettings.json
index 3020bd66..0c950315 100644
--- a/Aucma.Core.CodeBinding/appsettings.json
+++ b/Aucma.Core.CodeBinding/appsettings.json
@@ -213,8 +213,10 @@
}
],
"StationInfo": {
- "StationCode": "1010"
+ "StationCode": "1010",
+ "ProductLineCode": "CX_02"
},
+
"PLCServer": [
{
"Id": 1,
diff --git a/Aucma.Core.ProductOffLine/Aucma.Core.ProductOffLine.csproj b/Aucma.Core.ProductOffLine/Aucma.Core.ProductOffLine.csproj
index f36c89a0..07dfcf0f 100644
--- a/Aucma.Core.ProductOffLine/Aucma.Core.ProductOffLine.csproj
+++ b/Aucma.Core.ProductOffLine/Aucma.Core.ProductOffLine.csproj
@@ -1,7 +1,7 @@
- Exe
+ WinExe
net6.0-windows
enable
true
diff --git a/Aucma.Core.ProductOffLine/Business/offLineBusiness.cs b/Aucma.Core.ProductOffLine/Business/offLineBusiness.cs
index ba7dc360..d358e2ce 100644
--- a/Aucma.Core.ProductOffLine/Business/offLineBusiness.cs
+++ b/Aucma.Core.ProductOffLine/Business/offLineBusiness.cs
@@ -7,6 +7,7 @@ using Admin.Core.Service;
using Admin.Core.Socket;
using Aucma.Core.HwPLc;
using Aucma.Core.ProductOffLine;
+using Aucma.Core.ProductOffLine.Common;
using Aucma.Core.ProductOffLine.Config;
using Aucma.Core.ProductOffLine.Models;
using Aucma.Core.ProductOffLine.Views;
@@ -61,8 +62,9 @@ namespace Aucma.Core.ProductOffLine.Business
// 箱壳扫码器ip
private static string ShellScannerIp = allScanners.First(x => x.Name == "外侧扫码器2").Ip;
+ private SpeechStr speechStr = SpeechStr.Instance;
+
-
// 扫码器标准返回数据长度
private const string BarcodeRef = "6933973114570;1621240AP0098E3D3497";
@@ -130,7 +132,7 @@ namespace Aucma.Core.ProductOffLine.Business
HandSendPlcWindow.SendPlcPassEvent += DownLoadPassFlag;
TouchSocketService.ReceiveCodeDelegateEvent += ReceiveAndConsumption;
TouchSocketService.NoReadReceiveEvent += NoRead;
-
+
}
#region 变量定义
///
@@ -150,10 +152,12 @@ namespace Aucma.Core.ProductOffLine.Business
if (LinerScannerIp == ip)
{
Console.WriteLine($"内侧扫码器ip: {ip} 未扫描到条码");
+ speechStr.SpeakAsync("东侧扫码失败");
}
else if(ShellScannerIp == ip)
{
Console.WriteLine($"外侧扫码器ip: {ip} 未扫描到条码");
+ speechStr.SpeakAsync("西侧扫码失败");
}
}
@@ -272,6 +276,7 @@ namespace Aucma.Core.ProductOffLine.Business
}
else
{
+ speechStr.SpeakAsync("更新数据库失败,禁止放行");
log.Info("条码:" + TempOffLineInfo1.ProductSNCode + "更新Mes数据库失败");
TempOffLineInfo1.MsgInfo = TempOffLineInfo1.MsgInfo + "更新Mes数据库失败";
TempOffLineInfo1.MsgAlarmFlag = true;
@@ -329,6 +334,7 @@ namespace Aucma.Core.ProductOffLine.Business
}
else
{
+ speechStr.SpeakAsync("更新数据库失败,禁止放行");
log.Info("条码:" + TempOffLineInfo2.ProductSNCode + "更新Mes数据库失败");
TempOffLineInfo2.MsgInfo = TempOffLineInfo2.MsgInfo + "更新Mes数据库失败";
TempOffLineInfo2.MsgAlarmFlag = true;
@@ -359,6 +365,7 @@ namespace Aucma.Core.ProductOffLine.Business
record.ProductSnCode = SNCode;
record.ProductScanTime = DateTime.Now;
record.ProductLineCode = appConfig.ProductlineCode;
+ record.Position = "成品下线";
record.ExceptionMsg = Msg;
record.ExceptionType = Type;
await exceptionRecordServices.AddAsync(record);
@@ -538,7 +545,8 @@ namespace Aucma.Core.ProductOffLine.Business
RefreshScanMateriaCodeEvent?.Invoke(TempOffLineInfo);
log.Info(TempOffLineInfo.ProductSNCode + "条码绑定工位未查询到条码绑定记录,请拆掉包装重新绑定");
AddExceptionRecord(TempOffLineInfo.ProductSNCode, TempOffLineInfo.MsgInfo,3);
- // return false;
+ speechStr.SpeakAsync("条码未绑定,请回到绑定工位");
+ // return false;
}
if (bindingRecord1 != null)
@@ -557,7 +565,8 @@ namespace Aucma.Core.ProductOffLine.Business
// TempOffLineInfo.ProductRefreshFlag = true;
RefreshScanMateriaCodeEvent?.Invoke(TempOffLineInfo);
AddExceptionRecord(TempOffLineInfo.ProductSNCode, TempOffLineInfo.MsgInfo, 4);
- // return false;
+ speechStr.SpeakAsync("终检不合格,请重新终检");
+ // return false;
}
#endregion
@@ -585,6 +594,7 @@ namespace Aucma.Core.ProductOffLine.Business
{
FArrayList[0] = "N";
FArrayList[1] = "条码系统查询接口调用失败,请检查网络重新扫描";
+ speechStr.SpeakAsync("条码系统查询失败,请检查网络重新扫描");
}
if (FArrayList[0].ToUpper() == "Y") //查询数据成功
@@ -689,7 +699,7 @@ namespace Aucma.Core.ProductOffLine.Business
//界面刷新
// TempOffLineInfo.ProductRefreshFlag = true;
RefreshScanMateriaCodeEvent?.Invoke(TempOffLineInfo);
-
+
AddExceptionRecord(TempOffLineInfo.ProductSNCode, TempOffLineInfo.MsgInfo,5);
return false;
}
@@ -697,6 +707,7 @@ namespace Aucma.Core.ProductOffLine.Business
}
catch (Exception ex)
{
+ speechStr.SpeakAsync("条码系统验证异常");
TempOffLineInfo.MsgInfo = "获取产品条码异常:" + ex.Message;
TempOffLineInfo.MsgAlarmFlag = true;
//界面刷新
@@ -761,6 +772,7 @@ namespace Aucma.Core.ProductOffLine.Business
}
else
{
+ speechStr.SpeakAsync("条码系统上传失败");
log.Info(TempOffLineInfo.ProductSNCode + "上传条码失败:" + strSave);
TempOffLineInfo.MsgInfo = TempOffLineInfo.MsgInfo + ",上传条码失败" + strSave;
@@ -779,6 +791,7 @@ namespace Aucma.Core.ProductOffLine.Business
}
else
{
+
TempOffLineInfo.MsgInfo = TempOffLineInfo.MsgInfo + ",条码系统保存接口异常";
TempOffLineInfo.MsgAlarmFlag = true;
AddExceptionRecord(TempOffLineInfo.ProductSNCode, TempOffLineInfo.MsgInfo,6);
diff --git a/Aucma.Core.ProductOffLine/Business/SpeechStr.cs b/Aucma.Core.ProductOffLine/Common/SpeechStr.cs
similarity index 89%
rename from Aucma.Core.ProductOffLine/Business/SpeechStr.cs
rename to Aucma.Core.ProductOffLine/Common/SpeechStr.cs
index 5a1dac7a..d0c18c11 100644
--- a/Aucma.Core.ProductOffLine/Business/SpeechStr.cs
+++ b/Aucma.Core.ProductOffLine/Common/SpeechStr.cs
@@ -5,7 +5,7 @@ using System.Speech.Synthesis;
using System.Text;
using System.Threading.Tasks;
-namespace Aucma.Core.CodeBinding.Common
+namespace Aucma.Core.ProductOffLine.Common
{
public class SpeechStr
{
@@ -18,7 +18,7 @@ namespace Aucma.Core.CodeBinding.Common
}
}
- public void speech(string str) {
+ public void SpeakAsync(string str) {
SpeechSynthesizer speech = new SpeechSynthesizer();
speech.Rate = 3;//设置语速
diff --git a/Aucma.Core.ProductOffLine/ViewModels/IndexPageViewModel.cs b/Aucma.Core.ProductOffLine/ViewModels/IndexPageViewModel.cs
index 8fe032a2..0a2c631b 100644
--- a/Aucma.Core.ProductOffLine/ViewModels/IndexPageViewModel.cs
+++ b/Aucma.Core.ProductOffLine/ViewModels/IndexPageViewModel.cs
@@ -54,11 +54,12 @@ namespace Aucma.Core.ProductOffLine.ViewModels
// 成品下线操作mes数据
private readonly IOffLineInfoServices? _offLineInfoServices = App.ServiceProvider.GetService();
+
// System.Timers.Timer timer = new System.Timers.Timer(500);//界面刷新定时器
private readonly IBaseBomInfoServices? _baseBomInfoServices;
private OffLineBusiness offLineBusiness = OffLineBusiness.Instance;
- private static double aaa = 100.0;
- int a = 0;
+ public List listTime;
+
public IndexPageViewModel()
{
OffLineBusiness.RefreshScanMateriaCodeEvent += ModelToPage;
@@ -66,11 +67,11 @@ namespace Aucma.Core.ProductOffLine.ViewModels
MainWindowViewModel.RefreshFirstPageChartsEvent += RefreshCharts;
_offLineInfoServices = App.ServiceProvider.GetService();
_baseBomInfoServices = App.ServiceProvider.GetService();
-
+
RefreshCharts();
+ listTime = _baseBomInfoServices.getWorkTime().Result;
-
}
///
@@ -319,97 +320,112 @@ namespace Aucma.Core.ProductOffLine.ViewModels
private async void InitEveryDayMethod(List list)
{
-
- Application.Current.Dispatcher.Invoke(() =>
+ try
{
- ProductionHourList.Clear();
- Achievement.Clear();
- #region 小时产量统计
- List listTime = _baseBomInfoServices.getWorkTime().Result;
- if (listTime == null) return;
- // List xList = new List();
- foreach (WorkTime workTime in listTime)
- {
- // xList.Add(workTime.startTime.Hour.ToString());
- ProductionHourList.Add(workTime.startTime.Hour.ToString());
- }
- // ProductionHourList = xList;
- // y轴
- if (list == null || list.Count <= 0) return;
- var result = list.GroupBy(x => x.ProductScanTime.Hour) // 按照小时进行分组
- .Select(g => new
- {
- Hour = g.Key.ToString(), // 小时
- Count = g.Count() // 统计每个小时的个数
- }).ToList();
+ if (list == null) return;
+ // 当日下线记录
+ List offList = _offLineInfoServices.QueryAsync(x => x.ProductScanTime >= listTime[0].startTime && x.ProductScanTime <= listTime[11].startTime).Result;
- ChartValues achievement2 = new ChartValues();
- int i = 0;
- foreach (string item in ProductionHourList)
+ Application.Current.Dispatcher.Invoke(() =>
{
- var target = result.Where(x => x.Hour == item).FirstOrDefault();
- if (target != null)
+ ProductionHourList.Clear();
+ Achievement.Clear();
+ #region 小时产量统计
+
+ if (listTime == null)
{
- achievement2.Add(new ObservablePoint(i, target.Count));
+ listTime = _baseBomInfoServices.getWorkTime().Result;
+ if (listTime == null) return;
}
- else
+ // List xList = new List();
+ foreach (WorkTime workTime in listTime)
{
- achievement2.Add(new ObservablePoint(i, 0));
+ // xList.Add(workTime.startTime.Hour.ToString());
+ ProductionHourList.Add(workTime.startTime.Hour.ToString());
}
- i++;
- }
-
- var column2 = new ColumnSeries();
- column2.DataLabels = true;
- column2.Title = "产量";
- column2.Values = achievement2;
- column2.Foreground = Brushes.White;
- Achievement.Add(column2);
- #endregion
-
- #region 型号统计
- List nameList = new List();
- ChartValues achievement = new ChartValues();
- var column = new ColumnSeries();
-
- List offList = _offLineInfoServices.QueryAsync(x => x.ProductScanTime >= listTime[0].startTime && x.ProductScanTime <= listTime[11].startTime).Result;
- var modelList = offList.GroupBy(x => x.ProductModel);
-
- foreach (var item in modelList)
- {
- achievement.Add(item.Count());
- nameList.Add(item.Key);
- }
- column.DataLabels = true;
- column.Title = "型号";
- column.Values = achievement;
- column.Foreground = Brushes.White;
+ // ProductionHourList = xList;
+ // y轴
+ if (list == null || list.Count <= 0) return;
+ var result = list.GroupBy(x => x.ProductScanTime.Hour) // 按照小时进行分组
+ .Select(g => new
+ {
+ Hour = g.Key.ToString(), // 小时
+ Count = g.Count() // 统计每个小时的个数
+ }).ToList();
- // x轴
- MaterialNameList = null;
- MaterialNameList = nameList;
- // y轴
- //if (ModelStatistics.Count > 0)
- //{
- // for (int j = 0; j < modelList.Count(); j++)
- // {
- // Achievement.FirstOrDefault().Values[j] = modelList.ElementAt(j).Count();
- // }
+ ChartValues achievement2 = new ChartValues();
+ int i = 0;
+ foreach (string item in ProductionHourList)
+ {
+ var target = result.Where(x => x.Hour == item).FirstOrDefault();
+ if (target != null)
+ {
+ achievement2.Add(new ObservablePoint(i, target.Count));
+ }
+ else
+ {
+ achievement2.Add(new ObservablePoint(i, 0));
+ }
+ i++;
+ }
- //}
- //else
- //{
- ModelStatistics.Clear();
- ModelStatistics.Add(column);
- // }
+ var column2 = new ColumnSeries();
+ column2.DataLabels = true;
+ column2.Title = "产量";
+ column2.Values = achievement2;
+ column2.Foreground = Brushes.White;
+ Achievement.Add(column2);
+ #endregion
+
+ #region 型号统计
+ // List nameList = new List();
+ ChartValues achievement = new ChartValues();
+ var column = new ColumnSeries();
+ MaterialNameList.Clear();
+ // List offList = _offLineInfoServices.QueryAsync(x => x.ProductScanTime >= listTime[0].startTime && x.ProductScanTime <= listTime[11].startTime).Result;
+ var modelList = offList.GroupBy(x => x.ProductModel);
+
+ foreach (var item in modelList)
+ {
+ achievement.Add(item.Count());
+ // nameList.Add(item.Key);
+ MaterialNameList.Add(item.Key);
+ }
+ column.DataLabels = true;
+ column.Title = "型号";
+ column.Values = achievement;
+ column.Foreground = Brushes.White;
+
+ // x轴
+ // MaterialNameList = null;
+ // MaterialNameList = nameList;
+ // y轴
+ //if (ModelStatistics.Count > 0)
+ //{
+ // for (int j = 0; j < modelList.Count(); j++)
+ // {
+ // Achievement.FirstOrDefault().Values[j] = modelList.ElementAt(j).Count();
+ // }
+
+ //}
+ //else
+ //{
+ ModelStatistics.Clear();
+ ModelStatistics.Add(column);
+ // }
- #endregion
+ #endregion
- });
+ });
+ }
+ catch (Exception ex)
+ {
+ log.Info($"刷新图表方法InitEveryDayMethod异常:{ex.Message}");
+ }
}
private async void InitEveryDayMethod11(List list)
@@ -552,9 +568,13 @@ namespace Aucma.Core.ProductOffLine.ViewModels
{
try
{
-
- List listTime = _baseBomInfoServices.getWorkTime().Result;
- if (listTime == null) return null;
+
+ // List listTime = _baseBomInfoServices.getWorkTime().Result;
+ if (listTime == null)
+ {
+ listTime = _baseBomInfoServices.getWorkTime().Result;
+ if (listTime == null) return null;
+ }
List list = _offLineInfoServices.Query(x => x.ProductScanTime >= listTime[0].startTime && x.ProductScanTime <= listTime[11].endTime && x.ProductLineCode == "CX_02");
OffLineQty = list.Count.ToString();
if (list == null || list.Count <= 0) return null;
diff --git a/Aucma.Core.ProductOffLine/ViewModels/SelectQualityViewModel.cs b/Aucma.Core.ProductOffLine/ViewModels/SelectQualityViewModel.cs
index c7d77bae..7a576031 100644
--- a/Aucma.Core.ProductOffLine/ViewModels/SelectQualityViewModel.cs
+++ b/Aucma.Core.ProductOffLine/ViewModels/SelectQualityViewModel.cs
@@ -1,6 +1,7 @@
using Admin.Core.IService;
using Admin.Core.Model;
using Admin.Core.Service;
+using Aucma.Core.ProductOffLine.Config;
using Aucma.Core.ProductOffLine.Models;
using Aucma.Core.ProductOffLine.Views;
using CommunityToolkit.Mvvm.ComponentModel;
@@ -32,6 +33,7 @@ namespace Aucma.Core.ProductOffLine.ViewModels
public RelayCommand