You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
454 lines
13 KiB
C#
454 lines
13 KiB
C#
using Aucma.Core.SheetMetal.Models;
|
|
using Aucma.Core.SheetMetal.Views;
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using CommunityToolkit.Mvvm.Input;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Windows;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Admin.Core.IService;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Aucma.Core.SheetMetal.Common;
|
|
using Admin.Core.Model.Model_New;
|
|
using Admin.Core.Tasks;
|
|
using CommunityToolkit.Mvvm.Messaging;
|
|
using LiveCharts;
|
|
using LiveCharts.Wpf;
|
|
using Admin.Core.Service;
|
|
using Admin.Core.Model;
|
|
/*
|
|
* 首页信息
|
|
*
|
|
*/
|
|
namespace Aucma.Core.SheetMetal.ViewModels
|
|
{
|
|
public partial class IndexPageViewModel : ObservableObject
|
|
{
|
|
protected readonly IExecutePlanInfoServices? _taskExecutionServices;
|
|
int k = 100;
|
|
public IndexPageViewModel()
|
|
{
|
|
_taskExecutionServices = App.ServiceProvider.GetService<IExecutePlanInfoServices>();
|
|
|
|
PlanMaxNum = 100;
|
|
StationName = "U壳/侧板钣金生产";
|
|
OrderCode = "";
|
|
PlanCode = "";
|
|
ProductModel = "";
|
|
BeginTime = string.Empty;
|
|
|
|
Job_SheetMetalTask_Quartz.SmDelegateEvent += LoadData;
|
|
WeakReferenceMessenger.Default.Register<string>(this, Recive);
|
|
LoadData();
|
|
InitExecMethod();
|
|
InitEveryDayMethod();
|
|
}
|
|
|
|
private async void InitExecMethod()
|
|
{
|
|
string station = "1001";
|
|
var list=await _taskExecutionServices.QueryAsync(d=>d.ProductLineCode.Equals(station));
|
|
if (list == null) return;
|
|
ExecutePlanInfo info=list.FirstOrDefault(d => d.ExecuteStatus == 2);
|
|
if (info == null) return;
|
|
PlanNum = info.PlanAmount;
|
|
RealQuantity = info.CompleteAmount;
|
|
DiffQuantity = info.PlanAmount- info.CompleteAmount;
|
|
CompletionRate = info.CompleteAmount/ info.PlanAmount;
|
|
}
|
|
private void InitEveryDayMethod()
|
|
{
|
|
ChartValues<double> achievement = new ChartValues<double>();
|
|
Random random = new Random();
|
|
for (int i = 0; i < 5; i++)
|
|
{
|
|
achievement.Add(random.Next(60, 100));
|
|
}
|
|
|
|
var column = new ColumnSeries();
|
|
column.DataLabels = true;
|
|
column.Title = "型号";
|
|
column.Values = achievement;
|
|
|
|
|
|
ModelStatistics.Add(column);
|
|
|
|
ProductionHourList = new List<string>()
|
|
{
|
|
"12",
|
|
"13",
|
|
"14",
|
|
"15",
|
|
"16",
|
|
};
|
|
|
|
ChartValues<double> achievement2 = new ChartValues<double>();
|
|
Random random2 = new Random();
|
|
for (int i = 0; i < 5; i++)
|
|
{
|
|
achievement2.Add(random2.Next(60, 100));
|
|
}
|
|
var column2 = new ColumnSeries();
|
|
column2.DataLabels = true;
|
|
column2.Title = "产量";
|
|
column2.Values = achievement2;
|
|
|
|
|
|
Achievement.Add(column2);
|
|
}
|
|
|
|
|
|
|
|
#region 计划列表
|
|
|
|
#region 加载DataGrid数据
|
|
private async void LoadData()
|
|
{
|
|
var list= await _taskExecutionServices.QueryAsync(d=>d.ProductLineCode.Equals("1001"));
|
|
var execList= list.OrderBy(d=>d.ExecuteOrder);
|
|
foreach (var item in execList)
|
|
{
|
|
PlanInfoDataGrid.Add(new TaskExecModel() {
|
|
ID = item.ObjId.ToString(),
|
|
OrderCode = item.OrderCode,
|
|
MaterialCode = item.MaterialCode,
|
|
MaterialName = item.MaterialName,
|
|
TaskAmount = item.PlanAmount,
|
|
CompleteAmount = item.CompleteAmount,
|
|
BeginTime = item.BeginTime,
|
|
IsExec = item.ExecuteStatus
|
|
});
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 向上
|
|
/// <summary>
|
|
/// 向上
|
|
/// </summary>
|
|
[RelayCommand]
|
|
private async Task MoveUp(string info)
|
|
{
|
|
string station = "1001";
|
|
bool result = await _taskExecutionServices.PlanMoveUp(info, station);
|
|
if (result)
|
|
{
|
|
PlanInfoDataGrid.Clear();
|
|
LoadData();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 向下
|
|
/// <summary>
|
|
/// 向下
|
|
/// </summary>
|
|
[RelayCommand]
|
|
private async Task MoveDown(string info)
|
|
{
|
|
string station = "1001";
|
|
bool result = await _taskExecutionServices.PlanMoveDown(info, station);
|
|
if (result)
|
|
{
|
|
PlanInfoDataGrid.Clear();
|
|
LoadData();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 删除
|
|
/// <summary>
|
|
/// 删除
|
|
/// </summary>
|
|
[RelayCommand]
|
|
private async Task DeletePlan(string info)
|
|
{
|
|
MessageBoxResult msg = MessageBox.Show("确定要删除吗?", "系统提醒", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No);
|
|
if (MessageBoxResult.Yes == msg)
|
|
{
|
|
bool result = await _taskExecutionServices.ExecPlanDelete(info);
|
|
if (result)
|
|
{
|
|
PlanInfoDataGrid.Clear();
|
|
LoadData();
|
|
MessageBox.Show("执行计划删除成功", "系统信息");
|
|
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("执行计划删除失败", "系统信息");
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 下传计划
|
|
/// <summary>
|
|
/// 下传计划
|
|
/// </summary>
|
|
[RelayCommand]
|
|
private async Task NextPass(string info)
|
|
{
|
|
MessageBoxResult msg = MessageBox.Show("确定要下发计划吗?", "系统提醒", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No);
|
|
if (MessageBoxResult.Yes != msg) return;
|
|
|
|
var model = await _taskExecutionServices.FirstAsync(d => d.ObjId == int.Parse(info));
|
|
if (model.ExecuteStatus == 2)
|
|
{
|
|
MessageBox.Show("该计划正在执行中,请勿重复下传", "系统信息");
|
|
}
|
|
else
|
|
{
|
|
var result = _taskExecutionServices.PlanNextPass(model);
|
|
if (result != null)
|
|
{
|
|
//刷新列表
|
|
MessageBox.Show("执行计划已下达", "系统信息");
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("执行计划下达失败", "系统信息");
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 初始化datagrid
|
|
private ObservableCollection<TaskExecModel> planInfoDataGrid = new ObservableCollection<TaskExecModel>();
|
|
public ObservableCollection<TaskExecModel> PlanInfoDataGrid
|
|
{
|
|
get { return planInfoDataGrid; }
|
|
set
|
|
{
|
|
planInfoDataGrid = value;
|
|
OnPropertyChanged();//属性通知
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 计划拆分执行
|
|
/// <summary>
|
|
/// 计划拆分执行
|
|
/// </summary>
|
|
[RelayCommand]
|
|
private void SplitPlan()
|
|
{
|
|
SplitPlanView split=new SplitPlanView();
|
|
split.ShowDialog();
|
|
}
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
#region 执行计划
|
|
|
|
#region 工位名称
|
|
private string _stationName;
|
|
public string StationName
|
|
{
|
|
get { return _stationName; }
|
|
set
|
|
{
|
|
_stationName = value;
|
|
SetProperty(ref _stationName, value);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 订单编号
|
|
private string _orderCode;
|
|
public string OrderCode
|
|
{
|
|
get { return _orderCode; }
|
|
set
|
|
{
|
|
_orderCode = value;
|
|
SetProperty(ref _orderCode, value);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 计划编号
|
|
private string _planCode;
|
|
public string PlanCode
|
|
{
|
|
get { return _planCode; }
|
|
set
|
|
{
|
|
_planCode = value;
|
|
SetProperty(ref _planCode, value);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 产品型号
|
|
private string _productModel;
|
|
public string ProductModel
|
|
{
|
|
get { return _productModel; }
|
|
set
|
|
{
|
|
_productModel = value;
|
|
SetProperty(ref _productModel, value);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 开始时间
|
|
private string _beginTime;
|
|
public string BeginTime
|
|
{
|
|
get { return _beginTime; }
|
|
set
|
|
{
|
|
_beginTime = value;
|
|
SetProperty(ref _beginTime, value);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 计划数量
|
|
private int _planNum;
|
|
public int PlanNum
|
|
{
|
|
get => _planNum;
|
|
set => SetProperty(ref _planNum, value);
|
|
}
|
|
/// <summary>
|
|
/// 计划最大值
|
|
/// </summary>
|
|
private int _planMaxNum;
|
|
public int PlanMaxNum
|
|
{
|
|
get => _planMaxNum;
|
|
set => SetProperty(ref _planMaxNum, value);
|
|
}
|
|
#endregion
|
|
|
|
#region 实际数量
|
|
private int _realQuantity;
|
|
public int RealQuantity
|
|
{
|
|
get => _realQuantity;
|
|
set => SetProperty(ref _realQuantity, value);
|
|
}
|
|
#endregion
|
|
|
|
#region 差异数量
|
|
private int _diffQuantity;
|
|
public int DiffQuantity
|
|
{
|
|
get => _diffQuantity;
|
|
set => SetProperty(ref _diffQuantity, value);
|
|
}
|
|
#endregion
|
|
|
|
#region 完成率
|
|
private double _completionRate;
|
|
public double CompletionRate
|
|
{
|
|
get => _completionRate;
|
|
set => SetProperty(ref _completionRate, value);
|
|
}
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
#region 当日产量
|
|
|
|
#region 日产量柱状图X轴日期
|
|
/// <summary>
|
|
/// 日产量柱状图X轴日期
|
|
/// </summary>
|
|
private List<string> productionHourList;
|
|
|
|
public List<string> ProductionHourList
|
|
{
|
|
get { return productionHourList; }
|
|
set { productionHourList = value; }
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 日产量柱状图
|
|
/// </summary>
|
|
private SeriesCollection achievement = new SeriesCollection();
|
|
|
|
public SeriesCollection Achievement
|
|
{
|
|
get { return achievement; }
|
|
set { achievement = value; }
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 型号统计
|
|
|
|
#region 型号统计柱状图x轴物料类型
|
|
/// <summary>
|
|
/// 型号统计柱状图x轴物料类型
|
|
/// </summary>
|
|
private List<string> materialNameList;
|
|
|
|
public List<string> MaterialNameList
|
|
{
|
|
get { return materialNameList; }
|
|
set { materialNameList = value; }
|
|
}
|
|
#endregion
|
|
|
|
#region 型号统计柱状图
|
|
/// <summary>
|
|
/// 型号统计柱状图
|
|
/// </summary>
|
|
private SeriesCollection modelStatistics = new SeriesCollection();
|
|
|
|
public SeriesCollection ModelStatistics
|
|
{
|
|
get { return modelStatistics; }
|
|
set { modelStatistics = value; }
|
|
}
|
|
#endregion
|
|
#endregion
|
|
|
|
#region 刷新列表-其他界面刷新该方法
|
|
/// <summary>
|
|
/// 刷新列表
|
|
/// </summary>
|
|
/// <param name="recipient"></param>
|
|
/// <param name="message"></param>
|
|
private void Recive(object recipient, object message)
|
|
{
|
|
PlanInfoDataGrid.Clear();
|
|
LoadData();
|
|
}
|
|
#endregion
|
|
|
|
#region 刷新界面显示数据
|
|
/// <summary>
|
|
/// 刷新界面显示数据
|
|
/// </summary>
|
|
/// <param name="planMaxNum"></param>
|
|
/// <param name="orderCode"></param>
|
|
/// <param name="planCode"></param>
|
|
/// <param name="productModel"></param>
|
|
/// <param name="beginTime"></param>
|
|
/// <returns></returns>
|
|
public async Task<bool> UpdatePlanSHow(int planMaxNum, string orderCode, string planCode,
|
|
string productModel, DateTime beginTime)
|
|
{
|
|
PlanMaxNum = planMaxNum;
|
|
OrderCode = orderCode;
|
|
PlanCode = planCode;
|
|
ProductModel = productModel;
|
|
BeginTime = beginTime.ToString();
|
|
|
|
return await Task.FromResult(true);
|
|
}
|
|
#endregion
|
|
}
|
|
}
|