change-出库完成任务从数据库取

collectionStore
liuwf 1 year ago
parent 4b04e8f6be
commit 36dc552505

@ -629,7 +629,7 @@ namespace Aucma.Scada.Business
if (spaceInfo != null) if (spaceInfo != null)
{ {
taskHandleBusiness.WritePlc(spaceInfo.storeCode, spaceInfo.spaceCode); // taskHandleBusiness.WritePlc(spaceInfo.storeCode, spaceInfo.spaceCode);
//读取PLC获取货道信息存放数量、在途数量 //读取PLC获取货道信息存放数量、在途数量
spaceInfo.spaceStock -= 1; spaceInfo.spaceStock -= 1;
@ -752,7 +752,7 @@ namespace Aucma.Scada.Business
/// </summary> /// </summary>
/// <param name="taskCode"></param> /// <param name="taskCode"></param>
/// <returns></returns> /// <returns></returns>
public bool DeleteTaskInfoByTaskCode(string taskCode) public bool DeleteTaskInfoByTaskCode(string taskCode,bool isFlag)
{ {
bool result = false; bool result = false;
var info = _taskInfoService.GetTaskInfosByTaskCode(taskCode); var info = _taskInfoService.GetTaskInfosByTaskCode(taskCode);
@ -760,20 +760,28 @@ namespace Aucma.Scada.Business
{ {
foreach(var taskInfo in info) foreach(var taskInfo in info)
{ {
if(taskInfo.taskStatus == 2) //if(taskInfo.taskStatus == 2)
{ //{
PrintLogInfoMessage("任务正在执行中不运行删除"); // PrintLogInfoMessage("任务正在执行中不运行删除");
continue; // continue;
} //}
result = _taskInfoService.DeleteTaskInfoById(taskInfo.objId); result = _taskInfoService.DeleteTaskInfoById(taskInfo.objId);
if (result) if (result)
{ {
var spaceDetailInfo =_spaceDetailService.GetSpaceDetailByMaterialCode(taskInfo.materialCode); var spaceDetailInfo =_spaceDetailService.GetSpaceDetailByMaterialCode(taskInfo.materialCode);
if(spaceDetailInfo != null) if(spaceDetailInfo != null)
{ {
spaceDetailInfo.isFlag = 0; if (!isFlag)
_spaceDetailService.UpdateSpaceDetail(spaceDetailInfo); {
spaceDetailInfo.isFlag = 0;
_spaceDetailService.UpdateSpaceDetail(spaceDetailInfo);
}
else
{
_spaceDetailService.DeleteSpaceDetailByMaterialCode(spaceDetailInfo.materialCode);
}
} }
} }
} }

@ -38,8 +38,10 @@ namespace Aucma.Scada.Business
private PlcPool _pool = PlcPool.Instance; private PlcPool _pool = PlcPool.Instance;
private PlcSpaceConfig spaceConfig = PlcSpaceConfig.Instance; private PlcSpaceConfig spaceConfig = PlcSpaceConfig.Instance;
private RegisterServices registerServices = RegisterServices.Instance; private RegisterServices registerServices = RegisterServices.Instance;
private ICodeBindingRecordServices _codeBindingRecordServices;
private IRealTaskInfoService _taskInfoService;
#endregion #endregion
#region 私有变量 #region 私有变量
@ -86,8 +88,8 @@ namespace Aucma.Scada.Business
private OutStoreTaskHandle() private OutStoreTaskHandle()
{ {
_codeBindingRecordServices = registerServices.GetService<ICodeBindingRecordServices>();
_plcDictionary = _pool.GetAll(); _plcDictionary = _pool.GetAll();
_taskInfoService = registerServices.GetService<IRealTaskInfoService>();
RealReadShellFinish(); RealReadShellFinish();
@ -178,7 +180,7 @@ namespace Aucma.Scada.Business
OutStoreAnswerEvent?.Invoke(appConfig.shellStoreCode, taskInfo.taskCode); OutStoreAnswerEvent?.Invoke(appConfig.shellStoreCode, taskInfo.taskCode);
shellTaskInfos.Add(taskInfo); //shellTaskInfos.Add(taskInfo);
} }
Thread.Sleep(1000); Thread.Sleep(1000);
@ -335,7 +337,7 @@ namespace Aucma.Scada.Business
//ReadLinerFinish_OutStore(taskCode); //ReadLinerFinish_OutStore(taskCode);
OutStoreAnswerEvent?.Invoke(appConfig.linerStoreCode, taskInfo.taskCode); OutStoreAnswerEvent?.Invoke(appConfig.linerStoreCode, taskInfo.taskCode);
linerTaskInfos.Add(taskInfo); //linerTaskInfos.Add(taskInfo);
} }
Thread.Sleep(1000); Thread.Sleep(1000);
@ -420,13 +422,15 @@ namespace Aucma.Scada.Business
{ {
while (true) while (true)
{ {
var info = shellTaskInfos.Where(x => x.taskStatus != 3).ToList(); //var info = shellTaskInfos.Where(x => x.taskStatus != 3).ToList();
var info = GetTaskInfoByTaskStatus(appConfig.shellStoreCode);
for (int i = 0; i < info.Count; i++) for (int i = 0; i < info.Count; i++)
{ {
var item = info[i]; var item = info[i];
ReadShellFinish_OutStore(item); ReadShellFinish_OutStore(item);
Console.WriteLine($"箱壳任务:{item.taskCode};物料:{item.materialCode};出库完成"); Console.WriteLine($"箱壳任务:{item.taskCode};物料:{item.materialCode};出库完成");
item.taskStatus = 3; item.taskStatus = 3;
shellTaskInfos.Add(item);
} }
Thread.Sleep(1000); Thread.Sleep(1000);
@ -443,13 +447,15 @@ namespace Aucma.Scada.Business
{ {
while (true) while (true)
{ {
var info = linerTaskInfos.Where(x => x.taskStatus != 3).ToList(); //var info = linerTaskInfos.Where(x => x.taskStatus != 3).ToList();
var info = GetTaskInfoByTaskStatus(appConfig.linerStoreCode);
for (int i = 0; i < info.Count; i++) for (int i = 0; i < info.Count; i++)
{ {
var item = info[i]; var item = info[i];
ReadLinerFinish_OutStore(item); ReadLinerFinish_OutStore(item);
Console.WriteLine($"内胆任务:{item.taskCode};物料:{item.materialCode};出库完成"); Console.WriteLine($"内胆任务:{item.taskCode};物料:{item.materialCode};出库完成");
item.taskStatus = 3; item.taskStatus = 3;
linerTaskInfos.Add(item);
} }
Thread.Sleep(1000); Thread.Sleep(1000);
@ -485,9 +491,7 @@ namespace Aucma.Scada.Business
if (shellTask != null && linerTask != null) if (shellTask != null && linerTask != null)
{ {
logHelper.Info($"绑定条码:箱壳:{shellTask.materialCode};内胆:{linerTask.materialCode}"); Console.WriteLine($"绑定箱壳:{shellTask.materialCode};内胆:{linerTask.materialCode};条码");
// 条码绑定表,绑定箱壳和内胆码 shellTask.materialCode,linerTask.materialCode
_codeBindingRecordServices.BindingCode(shellTask.materialCode, linerTask.materialCode);
shellTaskInfos.Remove(shellTask); shellTaskInfos.Remove(shellTask);
linerTaskInfos.Remove(linerTask); linerTaskInfos.Remove(linerTask);
@ -500,6 +504,26 @@ namespace Aucma.Scada.Business
} }
#endregion #endregion
/// <summary>
/// 根据任务状态获取执行中的任务
/// </summary>
/// <param name="storeCode"></param>
/// <param name="taskStatus"></param>
private List<RealTaskInfo> GetTaskInfoByTaskStatus(string storeCode, int taskStatus = 2)
{
List<RealTaskInfo> result = null;
try
{
result = _taskInfoService.GetTaskInfosByTaskStatus(new string[] { storeCode }, appConfig.outstoreTaskType, taskStatus);
}
catch (Exception ex)
{
logHelper.Error("根据任务状态获取执行中的任务异常", ex);
}
return result;
}
/// <summary> /// <summary>
/// 通过PLC获取货道信息 /// 通过PLC获取货道信息

@ -299,8 +299,16 @@ namespace Aucma.Scada.UI.viewModel.OutStoreInfo
private void DeleteTaskInfo(object obj) private void DeleteTaskInfo(object obj)
{ {
string taskCode = obj as string; string taskCode = obj as string;
MessageBoxResult result = MessageBox.Show("货物是否已出库?", "出库确认", MessageBoxButton.YesNo, MessageBoxImage.Question);
if (outStoreBusiness.DeleteTaskInfoByTaskCode(taskCode)) if(result == MessageBoxResult.Yes)
{
if(outStoreBusiness.DeleteTaskInfoByTaskCode(taskCode,true))
{
MessageBox.Show("任务删除成功","提示",MessageBoxButton.OK,MessageBoxImage.Information,MessageBoxResult.OK,MessageBoxOptions.DefaultDesktopOnly);
Query();
}
}
if (outStoreBusiness.DeleteTaskInfoByTaskCode(taskCode, false))
{ {
MessageBox.Show("任务删除成功", "提示", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly); MessageBox.Show("任务删除成功", "提示", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly);
Query(); Query();

Loading…
Cancel
Save