change - 出入库逻辑优化

collectionStore
wenjy 1 year ago
parent 47699ccaaf
commit 79748bbb8e

Binary file not shown.

@ -105,7 +105,7 @@ namespace Aucma.Scada.Business
//} //}
//_executePlanInfoService.UpdateRangeExecutePlanInfo(planInfos); //_executePlanInfoService.UpdateRangeExecutePlanInfo(planInfos);
RefreshExecutePlanInfoEvent?.Invoke(planInfos); RefreshExecutePlanInfoEvent?.Invoke(planInfos.Where(x=>x.executeStatus != 3).ToList());
} }
} }
catch (Exception ex) catch (Exception ex)

@ -90,8 +90,15 @@ namespace Aucma.Scada.Business
grabImage.RefreshLogMessageEvent += PrintLogInfoMessage; grabImage.RefreshLogMessageEvent += PrintLogInfoMessage;
StartPassDown(); StartPassDown();
//InStore(appConfig.shellStoreCode, "B236000007811019001"); //Task.Run(() =>
//InStore(appConfig.linerStoreCode, "L236000007881019001"); //{
// Thread.Sleep(6000);
// for(int i = 2;i<10;i++)
// {
// InStore(appConfig.shellStoreCode, "B23600000781101900"+i);
// InStore(appConfig.linerStoreCode, "L23600000788101900"+i);
// }
//});
} }
/// <summary> /// <summary>
@ -308,12 +315,6 @@ namespace Aucma.Scada.Business
{ {
taskInfo = _taskInfoService.GetTaskInfoByStoreCode(storeCode, 1); taskInfo = _taskInfoService.GetTaskInfoByStoreCode(storeCode, 1);
if (taskInfo != null)
{
taskInfo.taskStatus = 2;
_taskInfoService.UpdateTaskInfo(taskInfo);
}
} }
catch (Exception ex) catch (Exception ex)
{ {

@ -58,6 +58,10 @@ namespace Aucma.Scada.Business
/// 货道明细 /// 货道明细
/// </summary> /// </summary>
private IBaseSpaceDetailService _spaceDetailService; private IBaseSpaceDetailService _spaceDetailService;
private IExecutePlanInfoService _executePlanInfoService;
private IProductPlanInfoService _productPlanInfoService;
#endregion #endregion
#region 委托事件 #region 委托事件
@ -84,6 +88,9 @@ namespace Aucma.Scada.Business
/// <param name="message"></param> /// <param name="message"></param>
public delegate void RefreshLogMessage(string message); public delegate void RefreshLogMessage(string message);
public event RefreshLogMessage RefreshLogMessageEvent; public event RefreshLogMessage RefreshLogMessageEvent;
public delegate void RefreshAssemblyPlanInit();
public event RefreshAssemblyPlanInit RefreshAssemblyPlanInitEvent;
#endregion #endregion
private OutStoreBusiness() private OutStoreBusiness()
@ -92,7 +99,8 @@ namespace Aucma.Scada.Business
_taskInfoService = registerServices.GetService<IRealTaskInfoService>(); _taskInfoService = registerServices.GetService<IRealTaskInfoService>();
_bomInfoService = registerServices.GetService<IBaseBomInfoService>(); _bomInfoService = registerServices.GetService<IBaseBomInfoService>();
_spaceDetailService = registerServices.GetService<IBaseSpaceDetailService>(); _spaceDetailService = registerServices.GetService<IBaseSpaceDetailService>();
_executePlanInfoService = registerServices.GetService<IExecutePlanInfoService>();
_productPlanInfoService = registerServices.GetService<IProductPlanInfoService>();
assemblyPlanBusiness.NextPassExecutePlanInfoEvent += PlanHandle; assemblyPlanBusiness.NextPassExecutePlanInfoEvent += PlanHandle;
taskHandleBusiness.OutStoreFinsihEvent += TaskFeedback; taskHandleBusiness.OutStoreFinsihEvent += TaskFeedback;
StartPassDown(); StartPassDown();
@ -299,6 +307,7 @@ namespace Aucma.Scada.Business
string shellCode = string.Empty; string shellCode = string.Empty;
string linerCode = string.Empty; string linerCode = string.Empty;
string taskCode = string.Empty; string taskCode = string.Empty;
string executePlanCode = string.Empty;
int iFlag = 0; int iFlag = 0;
completedTasks = 0; completedTasks = 0;
@ -312,6 +321,7 @@ namespace Aucma.Scada.Business
foreach (var item in taskInfoList) foreach (var item in taskInfoList)
{ {
taskCode = item.taskCode; taskCode = item.taskCode;
executePlanCode = item.planCode;
if (item.storeCode == appConfig.shellStoreCode) if (item.storeCode == appConfig.shellStoreCode)
{ {
if (taskHandleBusiness.SendShellTask_OutStore(item)) if (taskHandleBusiness.SendShellTask_OutStore(item))
@ -365,6 +375,9 @@ namespace Aucma.Scada.Business
PrintLogInfoMessage($"出库任务:{taskCode};执行完成,绑定箱壳条码:{shellCode};内胆条码:{linerCode}"); PrintLogInfoMessage($"出库任务:{taskCode};执行完成,绑定箱壳条码:{shellCode};内胆条码:{linerCode}");
UpdatePlanInfo(executePlanCode);
} }
} }
else else
@ -498,15 +511,16 @@ namespace Aucma.Scada.Business
} }
_spaceInfoService.UpdateSpaceInfo(spaceInfo); _spaceInfoService.UpdateSpaceInfo(spaceInfo);
//读取PLC获取物料类型进行绑定
} }
//清除任务信息 //清除任务信息
_taskInfoService.DeleteTaskInfo(taskCode, storeCode); _taskInfoService.DeleteTaskInfo(taskCode, storeCode);
_spaceDetailService.DeleteSpaceDetailByMaterialCode(taskInfo.materialCode);
//刷新界面 //刷新界面
RefreshScanMateriaCodeEvent?.Invoke(string.Empty, string.Empty, string.Empty, taskInfo.storeCode); RefreshScanMateriaCodeEvent?.Invoke(string.Empty, string.Empty, string.Empty, taskInfo.storeCode);
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -514,6 +528,48 @@ namespace Aucma.Scada.Business
} }
} }
/// <summary>
/// 更新计划信息
/// </summary>
/// <param name="planCode"></param>
private void UpdatePlanInfo(string planCode)
{
try
{
var executeInfo = _executePlanInfoService.GetExecutePlanInfoByPlanCode(planCode);
if (executeInfo != null)
{
executeInfo.completeAmount += 1;
if (executeInfo.completeAmount == executeInfo.planAmount)
{
executeInfo.executeStatus = 3;
}
_executePlanInfoService.UpdateExecutePlanInfo(executeInfo);
var productInfo = _productPlanInfoService.GetProductPlanByPlanCode(executeInfo.productPlanCode);
if(productInfo != null)
{
productInfo.completeAmount += 1;
if (productInfo.completeAmount == productInfo.planAmount)
{
productInfo.endTime = DateTime.Now;
}
_productPlanInfoService.UpdateProductPlanInfo(productInfo);
}
}
RefreshAssemblyPlanInitEvent?.Invoke();
}
catch(Exception ex)
{
PrintLogErrorMessage("计划信息更新异常", ex);
}
}
/// <summary> /// <summary>
/// 获取出库任务 /// 获取出库任务
/// </summary> /// </summary>

@ -21,6 +21,8 @@ namespace Aucma.Scada.UI.viewModel.AssemblyPlan
private AppConfig appConfig = AppConfig.Instance; private AppConfig appConfig = AppConfig.Instance;
private OutStoreBusiness outStoreBusiness = OutStoreBusiness.Instance;
public AssemblyPlanViewModel() public AssemblyPlanViewModel()
{ {
MoveUpCommand = new RelayCommand<object>(obj => MoveUp(obj)); MoveUpCommand = new RelayCommand<object>(obj => MoveUp(obj));
@ -31,6 +33,7 @@ namespace Aucma.Scada.UI.viewModel.AssemblyPlan
PlanInfoEditCommand = new RelayCommand(PlanInfoEdit); PlanInfoEditCommand = new RelayCommand(PlanInfoEdit);
assemblyPlanBusiness.RefreshExecutePlanInfoEvent += RefreshDataGrid; assemblyPlanBusiness.RefreshExecutePlanInfoEvent += RefreshDataGrid;
outStoreBusiness.RefreshAssemblyPlanInitEvent += RefreshPlanInfoDataGrid;
Init(); Init();
} }
@ -254,23 +257,42 @@ namespace Aucma.Scada.UI.viewModel.AssemblyPlan
} }
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);
}
}));
}
/// <summary> /// <summary>
/// 柱状体加载 /// 柱状体加载
/// </summary> /// </summary>
public void Init() public void Init()
{ {
var planInfos = assemblyPlanBusiness.GetEexecutePlanInfosByProductLineCode(); App.Current.Dispatcher.Invoke((Action)(() =>
RefreshDataGrid(planInfos);
//加载正在执行的计划
planInfos = planInfos.Where(x => x.executeStatus == 2).ToList();
if (planInfos.Count > 0)
{ {
ExecutePlanInfo planInfo = planInfos.OrderBy(x => x.executeOrder).First(); var planInfos = assemblyPlanBusiness.GetEexecutePlanInfosByProductLineCode();
RefreshPlanExecute(planInfo); RefreshDataGrid(planInfos);
}
MaterialNameList = new List<string>() //加载正在执行的计划
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", "SC232",
"SA124", "SA124",
@ -278,21 +300,21 @@ namespace Aucma.Scada.UI.viewModel.AssemblyPlan
"SC211", "SC211",
"DQ196", "DQ196",
}; };
ChartValues<double> achievement = new ChartValues<double>(); ChartValues<double> achievement = new ChartValues<double>();
Random random = new Random(); Random random = new Random();
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
{ {
achievement.Add(random.Next(60, 100)); achievement.Add(random.Next(60, 100));
} }
var column = new ColumnSeries(); var column = new ColumnSeries();
column.DataLabels = true; column.DataLabels = true;
column.Title = "型号"; column.Title = "型号";
column.Values = achievement; column.Values = achievement;
ModelStatistics.Add(column); ModelStatistics.Add(column);
ProductionHourList = new List<string>() ProductionHourList = new List<string>()
{ {
"12", "12",
"13", "13",
@ -301,19 +323,21 @@ namespace Aucma.Scada.UI.viewModel.AssemblyPlan
"16", "16",
}; };
ChartValues<double> achievement2 = new ChartValues<double>(); ChartValues<double> achievement2 = new ChartValues<double>();
Random random2 = new Random(); Random random2 = new Random();
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
{ {
achievement2.Add(random2.Next(60, 100)); achievement2.Add(random2.Next(60, 100));
} }
var column2 = new ColumnSeries(); var column2 = new ColumnSeries();
column2.DataLabels = true; column2.DataLabels = true;
column2.Title = "产量"; column2.Title = "产量";
column2.Values = achievement2; column2.Values = achievement2;
Achievement.Add(column2); Achievement.Add(column2);
}));
} }
/// <summary> /// <summary>

@ -223,45 +223,47 @@ namespace Aucma.Scada.UI.viewModel.InStoreInfo
public void Query() public void Query()
{ {
#region 通过数据库获取数据进行刷新 lock (string.Empty)
var info = inStoreBusiness.GetInStoreTask();
if (info != null)
{ {
taskItems = new ObservableCollection<RealTaskInfo>(); #region 通过数据库获取数据进行刷新
//info.ForEach(x => RefreshInStoreTask(x)); var info = inStoreBusiness.GetInStoreTask();
if (info != null)
try
{ {
foreach (var item in info) taskItems = new ObservableCollection<RealTaskInfo>();
//info.ForEach(x => RefreshInStoreTask(x));
try
{ {
foreach (var item in info)
App.Current.Dispatcher.Invoke((Action)(() =>
{ {
taskItems.Add(item);
InstoreTask = taskItems; App.Current.Dispatcher.Invoke((Action)(() =>
})); {
taskItems.Add(item);
InstoreTask = taskItems;
}));
}
}
catch (Exception ex)
{
logHelper.Error("入库任务列表刷新异常", ex);
} }
} }
catch (Exception ex) #endregion
if (materialTypeCombox == "箱壳")
{ {
logHelper.Error("入库任务列表刷新异常", ex); materialTypeCombox = "X-001";
} }
else if (materialTypeCombox == "内胆")
{
materialTypeCombox = "X-002";
}
else
{
materialTypeCombox = string.Empty;
}
InstoreTask = taskItems.Where(x => !string.IsNullOrEmpty(search) ? x.materialCode == search : 1 == 1 && !string.IsNullOrEmpty(materialTypeCombox) ? x.storeCode == materialTypeCombox : 1 == 1);
} }
#endregion
if (materialTypeCombox == "箱壳")
{
materialTypeCombox = "X-001";
}
else if (materialTypeCombox == "内胆")
{
materialTypeCombox = "X-002";
}
else
{
materialTypeCombox = string.Empty;
}
InstoreTask = taskItems.Where(x => !string.IsNullOrEmpty(search) ? x.materialCode == search : 1 == 1 && !string.IsNullOrEmpty(materialTypeCombox) ? x.storeCode == materialTypeCombox : 1 == 1);
} }
/// <summary> /// <summary>

Loading…
Cancel
Save