|
|
|
|
using Aucma.Scada.Business;
|
|
|
|
|
using Aucma.Scada.Model.domain;
|
|
|
|
|
using Aucma.Scada.UI.Page.AssemblyPlan;
|
|
|
|
|
using GalaSoft.MvvmLight;
|
|
|
|
|
using GalaSoft.MvvmLight.Command;
|
|
|
|
|
using HighWayIot.Config;
|
|
|
|
|
using LiveCharts;
|
|
|
|
|
using LiveCharts.Wpf;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
|
|
|
|
|
namespace Aucma.Scada.UI.viewModel.AssemblyPlan
|
|
|
|
|
{
|
|
|
|
|
public class AssemblyPlanViewModel : ViewModelBase
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
private AssemblyPlanBusiness assemblyPlanBusiness = AssemblyPlanBusiness.Instance;
|
|
|
|
|
|
|
|
|
|
private AppConfig appConfig = AppConfig.Instance;
|
|
|
|
|
|
|
|
|
|
private OutStoreBusiness outStoreBusiness = OutStoreBusiness.Instance;
|
|
|
|
|
public AssemblyPlanViewModel()
|
|
|
|
|
{
|
|
|
|
|
MoveUpCommand = new RelayCommand<object>(obj => MoveUp(obj));
|
|
|
|
|
MoveDownCommand = new RelayCommand<object>(obj => MoveDown(obj));
|
|
|
|
|
DeletePlanCommand = new RelayCommand<object>(obj => DeletePlan(obj));
|
|
|
|
|
NextPassCommand = new RelayCommand<object>(obj => NextPass(obj));
|
|
|
|
|
|
|
|
|
|
PlanInfoEditCommand = new RelayCommand(PlanInfoEdit);
|
|
|
|
|
|
|
|
|
|
assemblyPlanBusiness.RefreshExecutePlanInfoEvent += RefreshDataGrid;
|
|
|
|
|
outStoreBusiness.RefreshAssemblyPlanInitEvent += RefreshPlanInfoDataGrid;
|
|
|
|
|
|
|
|
|
|
Init();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 参数定义
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 工位名称
|
|
|
|
|
/// </summary>
|
|
|
|
|
private string stationName = string.Empty;
|
|
|
|
|
public string StationName
|
|
|
|
|
{
|
|
|
|
|
get { return stationName; }
|
|
|
|
|
set { stationName = value; RaisePropertyChanged(nameof(StationName)); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 订单编号
|
|
|
|
|
/// </summary>
|
|
|
|
|
private string orderCode = string.Empty;
|
|
|
|
|
public string OrderCode
|
|
|
|
|
{
|
|
|
|
|
get { return orderCode; }
|
|
|
|
|
set { orderCode = value; RaisePropertyChanged(nameof(OrderCode)); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 计划编号
|
|
|
|
|
/// </summary>
|
|
|
|
|
private string planCode = string.Empty;
|
|
|
|
|
public string PlanCode
|
|
|
|
|
{
|
|
|
|
|
get { return planCode; }
|
|
|
|
|
set { planCode = value; RaisePropertyChanged(nameof(PlanCode)); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 产品型号
|
|
|
|
|
/// </summary>
|
|
|
|
|
private string productModel = string.Empty;
|
|
|
|
|
public string ProductModel
|
|
|
|
|
{
|
|
|
|
|
get { return productModel; }
|
|
|
|
|
set { productModel = value; RaisePropertyChanged(nameof(ProductModel)); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 开始时间
|
|
|
|
|
/// </summary>
|
|
|
|
|
private string beginTime = string.Empty;
|
|
|
|
|
public string BeginTime
|
|
|
|
|
{
|
|
|
|
|
get { return beginTime; }
|
|
|
|
|
set { beginTime = value; RaisePropertyChanged(nameof(BeginTime)); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 计划列表DataGrid
|
|
|
|
|
/// </summary>
|
|
|
|
|
private ObservableCollection<ExecutePlanInfo> planInfoDataGrid;
|
|
|
|
|
|
|
|
|
|
public ObservableCollection<ExecutePlanInfo> PlanInfoDataGrid
|
|
|
|
|
{
|
|
|
|
|
get { return planInfoDataGrid; }
|
|
|
|
|
set { planInfoDataGrid = value; RaisePropertyChanged(() => PlanInfoDataGrid); }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 日产量柱状图
|
|
|
|
|
/// </summary>
|
|
|
|
|
private SeriesCollection achievement = new SeriesCollection();
|
|
|
|
|
|
|
|
|
|
public SeriesCollection Achievement
|
|
|
|
|
{
|
|
|
|
|
get { return achievement; }
|
|
|
|
|
set { achievement = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 型号统计柱状图
|
|
|
|
|
/// </summary>
|
|
|
|
|
private SeriesCollection modelStatistics = new SeriesCollection();
|
|
|
|
|
|
|
|
|
|
public SeriesCollection ModelStatistics
|
|
|
|
|
{
|
|
|
|
|
get { return modelStatistics; }
|
|
|
|
|
set { modelStatistics = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 日产量柱状图X轴日期
|
|
|
|
|
/// </summary>
|
|
|
|
|
private List<string> productionHourList;
|
|
|
|
|
|
|
|
|
|
public List<string> ProductionHourList
|
|
|
|
|
{
|
|
|
|
|
get { return productionHourList; }
|
|
|
|
|
set { productionHourList = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 型号统计柱状图x轴物料类型
|
|
|
|
|
/// </summary>
|
|
|
|
|
private List<string> materialNameList;
|
|
|
|
|
|
|
|
|
|
public List<string> MaterialNameList
|
|
|
|
|
{
|
|
|
|
|
get { return materialNameList; }
|
|
|
|
|
set { materialNameList = value; }
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 事件定义
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 上移事件
|
|
|
|
|
/// </summary>
|
|
|
|
|
public RelayCommand<object> MoveUpCommand { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 下移事件
|
|
|
|
|
/// </summary>
|
|
|
|
|
public RelayCommand<object> MoveDownCommand { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 删除计划
|
|
|
|
|
/// </summary>
|
|
|
|
|
public RelayCommand<object> DeletePlanCommand { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 下传事件
|
|
|
|
|
/// </summary>
|
|
|
|
|
public RelayCommand<object> NextPassCommand { get; set; }
|
|
|
|
|
|
|
|
|
|
public RelayCommand PlanInfoEditCommand { get; set; }
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 箱壳入库任务列表查询
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void RefreshDataGrid(List<ExecutePlanInfo> executePlanInfos)
|
|
|
|
|
{
|
|
|
|
|
PlanInfoDataGrid = new ObservableCollection<ExecutePlanInfo>();
|
|
|
|
|
if (executePlanInfos != null)
|
|
|
|
|
{
|
|
|
|
|
executePlanInfos.ForEach(
|
|
|
|
|
arg =>
|
|
|
|
|
{
|
|
|
|
|
PlanInfoDataGrid.Add(arg);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 计划上移
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="obj"></param>
|
|
|
|
|
public void MoveUp(object obj)
|
|
|
|
|
{
|
|
|
|
|
string info = obj as string;
|
|
|
|
|
assemblyPlanBusiness.ExecutePlanInfo_MoveUp(planInfoDataGrid.ToList(), info);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 计划下移
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="obj"></param>
|
|
|
|
|
public void MoveDown(object obj)
|
|
|
|
|
{
|
|
|
|
|
string info = obj as string;
|
|
|
|
|
assemblyPlanBusiness.ExecutePlanInfo_MoveDown(planInfoDataGrid.ToList(), info);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 删除计划
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="obj"></param>
|
|
|
|
|
public void DeletePlan(object obj)
|
|
|
|
|
{
|
|
|
|
|
string info = obj as string;
|
|
|
|
|
bool result = assemblyPlanBusiness.ExecutePlanInfo_Delete(info);
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
OrderCode = string.Empty;
|
|
|
|
|
PlanCode = string.Empty;
|
|
|
|
|
ProductModel = string.Empty;
|
|
|
|
|
BeginTime = string.Empty;
|
|
|
|
|
MessageBox.Show("执行计划删除成功");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("执行计划删除失败");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 下传计划
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="obj"></param>
|
|
|
|
|
public void NextPass(object obj)
|
|
|
|
|
{
|
|
|
|
|
string info = obj as string;
|
|
|
|
|
if (info == planCode)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("该计划正在执行中,请勿重复下传");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var result = assemblyPlanBusiness.ExecutePlanInfo_NextPass(info, planCode);
|
|
|
|
|
if (result != null)
|
|
|
|
|
{
|
|
|
|
|
RefreshPlanExecute(result);
|
|
|
|
|
MessageBox.Show("执行计划已下达");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("执行计划下达失败");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void RefreshPlanInfoDataGrid()
|
|
|
|
|
{
|
|
|
|
|
App.Current.Dispatcher.Invoke((Action)(() =>
|
|
|
|
|
{
|
|
|
|
|
var planInfos = assemblyPlanBusiness.GetEexecutePlanInfosByProductLineCode();
|
|
|
|
|
RefreshDataGrid(planInfos);
|
|
|
|
|
|
|
|
|
|
//加载正在执行的计划
|
|
|
|
|
planInfos = planInfos.Where(x => x.executeStatus == 2).ToList();
|
|
|
|
|
if (planInfos.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
ExecutePlanInfo planInfo = planInfos.OrderBy(x => x.executeOrder).First();
|
|
|
|
|
RefreshPlanExecute(planInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
OrderCode = string.Empty;
|
|
|
|
|
PlanCode = string.Empty;
|
|
|
|
|
ProductModel = string.Empty;
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 柱状体加载
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void Init()
|
|
|
|
|
{
|
|
|
|
|
var planInfos = assemblyPlanBusiness.GetEexecutePlanInfosByProductLineCode();
|
|
|
|
|
RefreshDataGrid(planInfos);
|
|
|
|
|
|
|
|
|
|
//加载正在执行的计划
|
|
|
|
|
planInfos = planInfos.Where(x => x.executeStatus == 2).ToList();
|
|
|
|
|
if (planInfos.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
ExecutePlanInfo planInfo = planInfos.OrderBy(x => x.executeOrder).First();
|
|
|
|
|
RefreshPlanExecute(planInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MaterialNameList = new List<string>()
|
|
|
|
|
{
|
|
|
|
|
"SC232",
|
|
|
|
|
"SA124",
|
|
|
|
|
"SC387",
|
|
|
|
|
"SC211",
|
|
|
|
|
"DQ196",
|
|
|
|
|
};
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 计划维护
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void PlanInfoEdit()
|
|
|
|
|
{
|
|
|
|
|
PlanInfoEditWindow planInfoEditWindow = new PlanInfoEditWindow();
|
|
|
|
|
planInfoEditWindow.ShowDialog();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 刷新计划执行
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="planInfo"></param>
|
|
|
|
|
private void RefreshPlanExecute(ExecutePlanInfo planInfo)
|
|
|
|
|
{
|
|
|
|
|
StationName = appConfig.stationName;
|
|
|
|
|
OrderCode = planInfo.orderCode;
|
|
|
|
|
PlanCode = planInfo.executePlanCode;
|
|
|
|
|
ProductModel = planInfo.materialName;
|
|
|
|
|
DateTime dateTime = (DateTime)planInfo.beginTime;
|
|
|
|
|
BeginTime = dateTime.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|