change-优化下线页面加载,添加语音播报,条码绑定加终检校验,语音播报,空板链放行按钮

main
liuwf 12 months ago
parent c4100683c3
commit 7ea7b66090

@ -2756,6 +2756,11 @@
异常类型1=69码校验;2=重复扫描;3=未绑条码;4=未终检)
</summary>
</member>
<member name="P:Admin.Core.Model.ExceptionRecord.Position">
<summary>
所在位置
</summary>
</member>
<member name="T:Admin.Core.Model.ExecutePlanInfo">
<summary>
计划执行表

@ -48,7 +48,12 @@ namespace Admin.Core.Model
/// </summary>
[SugarColumn(ColumnName = "EXCEPTION_TYPE")]
public int ExceptionType { get; set; }
/// <summary>
/// 所在位置
/// </summary>
[SugarColumn(ColumnName = "POSITION")]
public string Position { get; set; }
}
}

@ -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;//设置语速

@ -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<ICodeBindingRecordServices>();
_baseBomInfoServices = App.ServiceProvider.GetService<IBaseBomInfoServices>();
_baseMaterialInfoServices = App.ServiceProvider.GetService<IBaseMaterialInfoServices>();
_reportQualityInspectionServices = App.ServiceProvider.GetService<IReportQualityInspectionServices>();
_printBarCodeServices = App.ServiceProvider.GetService<IPrintBarCodeServices>();
_iMaterialCompletionServices = App.ServiceProvider.GetService<IMaterialCompletionServices>();
exceptionRecordServices = App.ServiceProvider.GetService<IExceptionRecordServices>();
// 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
}
/// <summary>
/// 实时绑定条码和实时下发plc放行信号
/// </summary>
@ -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("扫码失败,请补扫");
}
/// <summary>
@ -577,15 +584,33 @@ namespace Aucma.Core.CodeBinding.ViewModels
/// 提示信息刷新并且存日志
/// </summary>
/// <param name="logStr"></param>
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);
}
/// <summary>
/// 提示信息-颜色
/// </summary>
public string msgUIColor;
public string MsgUIColor
{
get => msgUIColor;
set => SetProperty(ref msgUIColor, value);
}
/// <summary>
/// 条码绑定
/// </summary>
@ -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
}
}
/// <summary>
/// 往mes数据库添加异常记录
/// </summary>
/// <param name="SNCode"></param>
/// <param name="Msg"></param>
/// <param name="Type">1=69码校验;2=重复扫描;3=未绑条码;4=未终检</param>
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交互
/// <summary>

@ -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()

@ -141,10 +141,12 @@
<StackPanel Grid.Column="1" Orientation="Horizontal" VerticalAlignment="Center" Margin="100 0 0 0 ">
<Label Content="提示信息 " FontSize="20" Foreground="#FFFFFF"/>
<TextBox TextWrapping="Wrap" IsReadOnly="True" Text="{Binding BindingInfo}" Width="600" Height="200" FontSize="18" Foreground="#FFFFFF"/>
<TextBox TextWrapping="Wrap" IsReadOnly="True" Text="{Binding BindingInfo}" Width="600" Height="200" FontSize="18" Foreground="{Binding MsgUIColor}"/>
</StackPanel>
</Grid>
<Button Cursor="Hand" Content="空板启动" Background="#FF9900" BorderBrush="#FF9900" Click="Button_Click" Width="100" HorizontalAlignment="Left" VerticalAlignment="Bottom" Grid.Row="2" />
</Grid>
<Grid Grid.Column="1">

@ -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未连接");
}
}
/// <summary>
/// 下发plc放行信号
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
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)
/// <summary>
/// 下发plc放行信号
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
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;
}
}

@ -213,8 +213,10 @@
}
],
"StationInfo": {
"StationCode": "1010"
"StationCode": "1010",
"ProductLineCode": "CX_02"
},
"PLCServer": [
{
"Id": 1,

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>

@ -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 变量定义
/// <summary>
@ -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);

@ -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;//设置语速

@ -54,11 +54,12 @@ namespace Aucma.Core.ProductOffLine.ViewModels
// 成品下线操作mes数据
private readonly IOffLineInfoServices? _offLineInfoServices = App.ServiceProvider.GetService<IOffLineInfoServices>();
// 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<WorkTime> listTime;
public IndexPageViewModel()
{
OffLineBusiness.RefreshScanMateriaCodeEvent += ModelToPage;
@ -66,11 +67,11 @@ namespace Aucma.Core.ProductOffLine.ViewModels
MainWindowViewModel.RefreshFirstPageChartsEvent += RefreshCharts;
_offLineInfoServices = App.ServiceProvider.GetService<IOffLineInfoServices>();
_baseBomInfoServices = App.ServiceProvider.GetService<IBaseBomInfoServices>();
RefreshCharts();
listTime = _baseBomInfoServices.getWorkTime().Result;
}
/// <summary>
@ -319,97 +320,112 @@ namespace Aucma.Core.ProductOffLine.ViewModels
private async void InitEveryDayMethod(List<OffLineInfo> list)
{
Application.Current.Dispatcher.Invoke(() =>
try
{
ProductionHourList.Clear();
Achievement.Clear();
#region 小时产量统计
List<WorkTime> listTime = _baseBomInfoServices.getWorkTime().Result;
if (listTime == null) return;
// List<string> xList = new List<string>();
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<OffLineInfo> offList = _offLineInfoServices.QueryAsync(x => x.ProductScanTime >= listTime[0].startTime && x.ProductScanTime <= listTime[11].startTime).Result;
ChartValues<ObservablePoint> achievement2 = new ChartValues<ObservablePoint>();
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<string> xList = new List<string>();
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<string> nameList = new List<string>();
ChartValues<int> achievement = new ChartValues<int>();
var column = new ColumnSeries();
List<OffLineInfo> 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<ObservablePoint> achievement2 = new ChartValues<ObservablePoint>();
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<string> nameList = new List<string>();
ChartValues<int> achievement = new ChartValues<int>();
var column = new ColumnSeries();
MaterialNameList.Clear();
// List<OffLineInfo> 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<OffLineInfo> list)
@ -552,9 +568,13 @@ namespace Aucma.Core.ProductOffLine.ViewModels
{
try
{
List<WorkTime> listTime = _baseBomInfoServices.getWorkTime().Result;
if (listTime == null) return null;
// List<WorkTime> listTime = _baseBomInfoServices.getWorkTime().Result;
if (listTime == null)
{
listTime = _baseBomInfoServices.getWorkTime().Result;
if (listTime == null) return null;
}
List<OffLineInfo> 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;

@ -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<object> MouseClickCommand { get; set; }
private readonly IExceptionRecordServices? exceptionRecordServices;
private AppConfig appConfig = AppConfig.Instance;
public SelectQualityViewModel()
{
@ -57,7 +59,7 @@ namespace Aucma.Core.ProductOffLine.ViewModels
{
try
{
List<ExceptionRecord> list = await exceptionRecordServices.QueryAsync(x=>x.ProductScanTime>=DateTime.Today);
List<ExceptionRecord> list = await exceptionRecordServices.QueryAsync(x=> x.ProductLineCode==appConfig.ProductlineCode && x.Position=="成品下线" && x.ProductScanTime>=DateTime.Today);
if (list == null || list.Count == 0) {
App.Current.Dispatcher.Invoke(() =>
{

@ -52,6 +52,25 @@ namespace Aucma.Core.ProductOffLine.ViewModels
List<OffLineInfo> list = _offLineInfoServices.QueryAsync(x => x.ProductScanTime >= DateTime.Now.AddDays(-2)).Result;
if (list == null || list.Count <= 0) return;
list = list.OrderByDescending(x => x.ProductScanTime).ToList();
// 按型号统计
var countByProductModel = list.GroupBy(x => x.ProductModel).Select(group => new
{
ProductCode = group.First().ProductCode,
ProductRemark = group.First().ProductRemark,
ProductModel = group.Key,
Count = group.Count()
}).ToList();
// 按订单统计
var countOrderModel = list.GroupBy(x => x.ProductOrderNo).Select(group => new
{
ProductOrderNo = group.Key,
ProductCode = group.First().ProductCode,
ProductRemark = group.First().ProductRemark,
ProductModel = group.First().ProductModel,
Count = group.Count()
}).ToList();
Application.Current.Dispatcher.Invoke(() =>
{
@ -62,29 +81,14 @@ namespace Aucma.Core.ProductOffLine.ViewModels
ListItems.Add(new TempInfo() { No = ListItems.Count + 1, ProductOrderNo = record.ProductOrderNo, ProductSNCode = record.ProductSNCode, ProductModel = record.ProductModel, ProductRemark = record.ProductRemark, ProductScanTime = record.ProductScanTime });
}
// 按型号统计
var countByProductModel = list.GroupBy(x => x.ProductModel).Select(group => new
{
ProductCode = group.First().ProductCode,
ProductRemark = group.First().ProductRemark,
ProductModel = group.Key,
Count = group.Count()
}).ToList();
foreach (var item in countByProductModel)
{
TotalItem.Add(new TempInfo() { No = TotalItem.Count + 1, ProductCode = item.ProductCode, ProductModel = item.ProductModel, ProductRemark = item.ProductRemark, Count = item.Count });
}
// 按订单统计
var countOrderModel = list.GroupBy(x => x.ProductOrderNo).Select(group => new
{
ProductOrderNo = group.Key,
ProductCode = group.First().ProductCode,
ProductRemark = group.First().ProductRemark,
ProductModel = group.First().ProductModel,
Count = group.Count()
}).ToList();
foreach (var item in countOrderModel)
{
OrderListItem.Add(new TempInfo() { No = OrderListItem.Count + 1, ProductOrderNo =item.ProductOrderNo, ProductCode = item.ProductCode, ProductModel = item.ProductModel, ProductRemark = item.ProductRemark, Count = item.Count });
@ -197,7 +201,24 @@ namespace Aucma.Core.ProductOffLine.ViewModels
{
list = list.OrderByDescending(x => x.ProductScanTime).ToList();
var countByProductModel = list.GroupBy(x => x.ProductModel).Select(group => new
{
ProductCode = group.First().ProductCode,
ProductRemark = group.First().ProductRemark,
ProductModel = group.Key,
Count = group.Count()
}).ToList();
// 按订单统计
var countOrderModel = list.GroupBy(x => x.ProductOrderNo).Select(group => new
{
ProductOrderNo = group.Key,
ProductCode = group.First().ProductCode,
ProductRemark = group.First().ProductRemark,
ProductModel = group.First().ProductModel,
Count = group.Count()
}).ToList();
Application.Current.Dispatcher.Invoke(() =>
{
ListItems.Clear();
@ -209,33 +230,18 @@ namespace Aucma.Core.ProductOffLine.ViewModels
ListItems.Add(new TempInfo() { No = ListItems.Count + 1, ProductOrderNo = record.ProductOrderNo, ProductSNCode = record.ProductSNCode, ProductModel = record.ProductModel, ProductRemark = record.ProductRemark, ProductScanTime = record.ProductScanTime });
}
var countByProductModel = list.GroupBy(x => x.ProductModel).Select(group => new
{
ProductCode = group.First().ProductCode,
ProductRemark = group.First().ProductRemark,
ProductModel = group.Key,
Count = group.Count()
}).ToList();
foreach (var item in countByProductModel)
{
TotalItem.Add(new TempInfo() { No = TotalItem.Count + 1, ProductCode = item.ProductCode, ProductModel = item.ProductModel, ProductRemark = item.ProductRemark, Count = item.Count });
}
// 按订单统计
var countOrderModel = list.GroupBy(x => x.ProductOrderNo).Select(group => new
{
ProductOrderNo = group.Key,
ProductCode = group.First().ProductCode,
ProductRemark = group.First().ProductRemark,
ProductModel = group.First().ProductModel,
Count = group.Count()
}).ToList();
foreach (var item in countOrderModel)
{
OrderListItem.Add(new TempInfo() { No = OrderListItem.Count + 1, ProductOrderNo = item.ProductOrderNo, ProductCode = item.ProductCode, ProductModel = item.ProductModel, ProductRemark = item.ProductRemark, Count = item.Count });
}
});
}
}

Loading…
Cancel
Save