change - 出入库逻辑优化

collectionStore
wenjy 11 months ago
parent 47699ccaaf
commit 79748bbb8e

Binary file not shown.

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

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

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

@ -21,6 +21,8 @@ namespace Aucma.Scada.UI.viewModel.AssemblyPlan
private AppConfig appConfig = AppConfig.Instance;
private OutStoreBusiness outStoreBusiness = OutStoreBusiness.Instance;
public AssemblyPlanViewModel()
{
MoveUpCommand = new RelayCommand<object>(obj => MoveUp(obj));
@ -31,6 +33,7 @@ namespace Aucma.Scada.UI.viewModel.AssemblyPlan
PlanInfoEditCommand = new RelayCommand(PlanInfoEdit);
assemblyPlanBusiness.RefreshExecutePlanInfoEvent += RefreshDataGrid;
outStoreBusiness.RefreshAssemblyPlanInitEvent += RefreshPlanInfoDataGrid;
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>
public void Init()
{
var planInfos = assemblyPlanBusiness.GetEexecutePlanInfosByProductLineCode();
RefreshDataGrid(planInfos);
//加载正在执行的计划
planInfos = planInfos.Where(x => x.executeStatus == 2).ToList();
if (planInfos.Count > 0)
App.Current.Dispatcher.Invoke((Action)(() =>
{
ExecutePlanInfo planInfo = planInfos.OrderBy(x => x.executeOrder).First();
RefreshPlanExecute(planInfo);
}
var planInfos = assemblyPlanBusiness.GetEexecutePlanInfosByProductLineCode();
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",
"SA124",
@ -278,21 +300,21 @@ namespace Aucma.Scada.UI.viewModel.AssemblyPlan
"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;
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);
ModelStatistics.Add(column);
ProductionHourList = new List<string>()
ProductionHourList = new List<string>()
{
"12",
"13",
@ -301,19 +323,21 @@ namespace Aucma.Scada.UI.viewModel.AssemblyPlan
"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;
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);
Achievement.Add(column2);
}));
}
/// <summary>

@ -223,45 +223,47 @@ namespace Aucma.Scada.UI.viewModel.InStoreInfo
public void Query()
{
#region 通过数据库获取数据进行刷新
var info = inStoreBusiness.GetInStoreTask();
if (info != null)
lock (string.Empty)
{
taskItems = new ObservableCollection<RealTaskInfo>();
//info.ForEach(x => RefreshInStoreTask(x));
try
#region 通过数据库获取数据进行刷新
var info = inStoreBusiness.GetInStoreTask();
if (info != null)
{
foreach (var item in info)
taskItems = new ObservableCollection<RealTaskInfo>();
//info.ForEach(x => RefreshInStoreTask(x));
try
{
App.Current.Dispatcher.Invoke((Action)(() =>
foreach (var item in info)
{
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>

Loading…
Cancel
Save