using System;
|
using System.Collections.Generic;
|
using System.Text;
|
using WIDESEA_Common;
|
using WIDESEA_Common.LogEnum;
|
using WIDESEA_Common.TaskEnum;
|
using WIDESEA_Core.EFDbContext;
|
using WIDESEA_Core.Utilities;
|
using WIDESEA_Entity.DomainModels;
|
using WIDESEA_Services.Repositories;
|
using WIDESEA_Services.Services.APIInvoke;
|
|
namespace WIDESEA_Services.Services.APIReceive.RGV
|
{
|
public class WCSReceiveMsgFromRGV
|
{
|
/// <summary>
|
/// WCS接收RGV上报的任务状态
|
/// </summary>
|
/// <param name="taskModel">任务信息</param>
|
/// <returns></returns>
|
//public static Dictionary<string, object> WCSReceiveRGVData(Dictionary<string, object> statusData)
|
//{
|
// Dictionary<string, object> resultDic = new Dictionary<string, object>();
|
// try
|
// {
|
// //任务编号
|
// string taskId = statusData["taskId"].ToString();
|
// //小车编号
|
// string reportTime = statusData["rgvId"].ToString();
|
// //任务状态
|
// int taskStatus = int.Parse(statusData["status"].ToString());
|
|
// Console.WriteLine($"接受到RGV上报的任务状态:任务号:{taskId},小车编号:{reportTime},任务状态:{taskStatus}");
|
// LogRecord.WriteLog(LogEnum.RGV, $"接受到RGV上报的任务状态:任务号:{taskId},小车编号:{reportTime},任务状态:{taskStatus}");
|
|
// //在此根据上报的任务号,更新任务状态以及任务完成后的相关操作
|
// VOLContext dbcontext = new VOLContext();
|
// Dt_TaskRGVinfoRepository taskRGVinfoRepository = new Dt_TaskRGVinfoRepository(dbcontext);
|
// Dt_TaskRGVinfo_HtyRepository taskRGVinfo_HtyRepository = new Dt_TaskRGVinfo_HtyRepository(dbcontext);
|
// Dt_TaskRGVinfo_HtyService taskRGVinfo_HtyService = new Dt_TaskRGVinfo_HtyService(taskRGVinfo_HtyRepository);
|
|
// Dt_TaskWCSinfoRepository taskWCSinfoRepository = new Dt_TaskWCSinfoRepository(dbcontext);
|
// Dt_TaskWCSinfo_HtyRepository taskWCSinfo_HtyRepository = new Dt_TaskWCSinfo_HtyRepository(dbcontext);
|
// Dt_TaskWCSinfo_HtyService taskWCSinfo_HtyService = new Dt_TaskWCSinfo_HtyService(taskWCSinfo_HtyRepository);
|
// Dt_TaskWCSinfo_Hty taskWCSinfo_Hty = new Dt_TaskWCSinfo_Hty();
|
// Dt_TaskRGVinfo_Hty taskRGVinfo_Hty = new Dt_TaskRGVinfo_Hty();
|
|
// Dt_TaskRGVinfo taskRGVinfo = taskRGVinfoRepository.FindFirst(x => x.rgvtask_taskId == taskId);
|
// Dt_TaskWCSinfo taskWCSinfo = taskWCSinfoRepository.FindFirst(x => x.wcstask_taskNumber == taskRGVinfo.rgvtask_wcsTaskNumber);
|
// if (taskRGVinfo != null)
|
// {
|
// WebResponseContent content = new WebResponseContent();
|
// //RGV上报对应的任务正常完成
|
// if (taskStatus == 1)
|
// {
|
|
// taskWCSinfoRepository.DbContextBeginTransaction(()=>
|
// {
|
// try
|
// {
|
// //区分任务类型,如果是入库类型的任务,RGV完成,则总任务完成,出库型任务,RGV完成,则只是部分完成
|
// //***空托入库*******
|
// //***轴承组盘入库***
|
// if (taskWCSinfo.wcstask_type == TaskType.TaskType_Empty_Pallet_Inbound.ToString() ||
|
// taskWCSinfo.wcstask_type == TaskType.TaskType_Box_Pallet_Inbound.ToString())
|
// {
|
// //完成rgv、wcs任务、移动任务到历史
|
// taskRGVinfoRepository.Delete(taskRGVinfo, true);
|
// taskWCSinfoRepository.Delete(taskWCSinfo, true);
|
// taskRGVinfo_HtyService.AddRgvTaskToHistory(taskRGVinfo, dbcontext);
|
// taskWCSinfo_HtyService.AddWcsTaskToHistory(taskWCSinfo, dbcontext);
|
|
// //上报WMS任务完成,对于入库来说,穿梭车的任务完成,即是整个任务的生命周期结束
|
// content = WMSApi.TellWmsTaskFinished(taskRGVinfo.rgvtask_barCode);
|
// if (content.Status)
|
// {
|
// content.OK();
|
// }
|
// else
|
// {
|
// throw new Exception($"【入库任务】上报WMS任务完成出错,WCS任务号:【{taskWCSinfo.wcstask_taskNumber}】,托盘号:【{taskWCSinfo.wcstask_barcode}】");
|
// }
|
// }
|
// //***测量出库*******,不要删除库存,占着坑,等待测量完回库
|
// else if (taskWCSinfo.wcstask_type == TaskType.TaskType_Box_Pallet_Measure_Out.ToString())
|
// {
|
// //更新rgv、wcs任务状态
|
// taskRGVinfo.rgvtask_taskStatus = RGVTaskState.RgvTaskState_Done.ToString();
|
// taskWCSinfo.wcstask_state = TaskState.TaskState_RGV_Finished.ToString();
|
|
// //完成rgv、移动任务到历史
|
// taskRGVinfoRepository.Delete(taskRGVinfo, true);
|
// taskRGVinfo_HtyService.AddRgvTaskToHistory(taskRGVinfo, dbcontext);
|
|
// //上报WMS最新任务状态,此处状态是穿梭车的任务完成
|
// content = WMSApi.PostTaskStateToWMS(taskRGVinfo.rgvtask_barCode, TaskState.TaskState_RGV_Finished.ToString());
|
// if (content.Status)
|
// {
|
// content.OK();
|
// //进入线体的测量出库逻辑
|
|
// }
|
// else
|
// {
|
// throw new Exception($"【测量出库】上报WMS任务完成出错,WCS任务号:【{taskWCSinfo.wcstask_taskNumber}】,托盘号:【{taskWCSinfo.wcstask_barcode}】");
|
// }
|
// }
|
// //***测量回库*******
|
// else if (taskWCSinfo.wcstask_type == TaskType.TaskType_Box_Pallet_Measure_Back.ToString())
|
// {
|
// //完成rgv、wcs任务、移动任务到历史
|
// taskRGVinfoRepository.Delete(taskRGVinfo, true);
|
// taskWCSinfoRepository.Delete(taskWCSinfo, true);
|
// taskRGVinfo_HtyService.AddRgvTaskToHistory(taskRGVinfo, dbcontext);
|
// taskWCSinfo_HtyService.AddWcsTaskToHistory(taskWCSinfo, dbcontext);
|
|
// //上报WMS任务完成,对于测量回库来说,穿梭车的任务完成,即是整个任务的生命周期结束
|
// //由于测量出库的没有删除库存,所有只要放回去即可,要不生成库存,在WMS做逻辑
|
// content = WMSApi.TellWmsTaskFinished(taskRGVinfo.rgvtask_barCode);
|
// if (content.Status)
|
// {
|
// content.OK();
|
// }
|
// else
|
// {
|
// throw new Exception($"【测量回库】上报WMS任务完成出错,WCS任务号:【{taskWCSinfo.wcstask_taskNumber}】,托盘号:【{taskWCSinfo.wcstask_barcode}】");
|
// }
|
// }
|
|
|
// }
|
// catch(Exception ex)
|
// {
|
// content.Error(ex.Message);
|
// }
|
|
// return content;
|
// });
|
|
// }
|
// }
|
// else
|
// {
|
// Console.WriteLine($"RGV上报了任务状态,但是在RGV任务表中没有找到对应的任务,任务号:【{taskId}】");
|
// }
|
|
// resultDic.Add("Code", "1");
|
// resultDic.Add("Message", "Scuccess");
|
// resultDic.Add("data ", null);
|
// }
|
// catch (Exception ex)
|
// {
|
// resultDic.Add("Code", "0");
|
// resultDic.Add("Message", "Failed");
|
// resultDic.Add("data ", ex.Message);
|
// }
|
|
// return resultDic;
|
//}
|
|
|
|
/// <summary>
|
/// WCS接收RGV上报的任务状态
|
/// </summary>
|
/// <param name="taskModel">任务信息</param>
|
/// <returns></returns>
|
//public static Dictionary<string, object> GetElevatorInfo()
|
//{
|
// Dictionary<string, object> resultDic = new Dictionary<string, object>();
|
// try
|
// {
|
|
// resultDic.Add("code", "1");
|
// resultDic.Add("layer", "3");
|
// resultDic.Add("status ", "提升机当前状态");
|
// }
|
// catch (Exception ex)
|
// {
|
// resultDic.Add("code", "0");
|
// resultDic.Add("layer", "-1");
|
// resultDic.Add("status ", "获取提升机状态失败"+ex.Message);
|
// }
|
|
// return resultDic;
|
//}
|
}
|
}
|