From f2b85c65234e0dcdd3fcce4dafbe16933b7f1b48 Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期日, 30 十一月 2025 04:22:51 +0800
Subject: [PATCH] 出入库流程代码更新
---
项目代码/WCSServices/WIDESEAWCS_TaskInfoService/TaskService.cs | 462 ++++++++++++++++++++-------------------------------------
1 files changed, 165 insertions(+), 297 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_TaskInfoService/TaskService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_TaskInfoService/TaskService.cs"
index d85473f..bc33716 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_TaskInfoService/TaskService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_TaskInfoService/TaskService.cs"
@@ -16,19 +16,25 @@
#endregion << 鐗� 鏈� 娉� 閲� >>
using AutoMapper;
using Newtonsoft.Json;
+using NPOI.SS.Formula.Functions;
using SqlSugar;
using System.Diagnostics.CodeAnalysis;
+using System.DirectoryServices.Protocols;
using System.Net.Http.Headers;
+using System.Security.Policy;
using WIDESEA_DTO.Agv;
+using WIDESEA_External.Model;
using WIDESEAWCS_Common;
using WIDESEAWCS_Common.APIEnum;
using WIDESEAWCS_Common.TaskEnum;
using WIDESEAWCS_Core;
+using WIDESEAWCS_Core.BaseRepository;
using WIDESEAWCS_Core.BaseServices;
using WIDESEAWCS_Core.Enums;
using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_Core.LogHelper;
using WIDESEAWCS_DTO;
+using WIDESEAWCS_DTO.Agv;
using WIDESEAWCS_DTO.TaskInfo;
using WIDESEAWCS_IBasicInfoRepository;
using WIDESEAWCS_ITaskInfoRepository;
@@ -44,6 +50,7 @@
public partial class TaskService : ServiceBase<Dt_Task, ITaskRepository>, ITaskService
{
private readonly IMapper _mapper;
+ private readonly IUnitOfWorkManage _unitOfWorkManage;
private readonly ICacheService _cacheService;
private readonly IRouterService _routerService;
private readonly ITaskExecuteDetailService _taskExecuteDetailService;
@@ -51,7 +58,7 @@
private readonly IStationMangerRepository _stationMangerRepository;
private readonly IRouterRepository _routerRepository;
private readonly IApiInfoRepository _apiInfoRepository;
- private List<Dt_ApiInfo> apiInfos;
+ private readonly ILocationInfoRepository _locationInfoRepository;
private Dictionary<string, OrderByType> _taskOrderBy = new()
{
@@ -60,7 +67,6 @@
{nameof(Dt_Task.CreateDate),OrderByType.Asc},
};
- private List<Dt_Warehouse>? Warehouses = new List<Dt_Warehouse>();
public Dictionary<string, OrderByType> TaskOrderBy { get { return _taskOrderBy; } set { _taskOrderBy = value; } }
@@ -70,7 +76,7 @@
public List<int> TaskRelocationTypes => typeof(TaskTypeEnum).GetEnumIndexList().Where(x => x >= 900 && x < 1000).ToList();
- public TaskService(ITaskRepository BaseDal, IMapper mapper, ICacheService cacheService, IRouterService routerService, ITaskExecuteDetailService taskExecuteDetailService, ITaskExecuteDetailRepository taskExecuteDetailRepository, IStationMangerRepository stationMangerRepository, IRouterRepository routerRepository, IApiInfoRepository apiInfoRepository) : base(BaseDal)
+ public TaskService(ITaskRepository BaseDal, IMapper mapper, ICacheService cacheService, IRouterService routerService, ITaskExecuteDetailService taskExecuteDetailService, ITaskExecuteDetailRepository taskExecuteDetailRepository, IStationMangerRepository stationMangerRepository, IRouterRepository routerRepository, IApiInfoRepository apiInfoRepository,ILocationInfoRepository locationInfoRepository,IUnitOfWorkManage unitOfWorkManage) : base(BaseDal)
{
_mapper = mapper;
_cacheService = cacheService;
@@ -80,278 +86,73 @@
_stationMangerRepository = stationMangerRepository;
_routerRepository = routerRepository;
_apiInfoRepository = apiInfoRepository;
-
- string? cacheStr = _cacheService.Get(nameof(Dt_Warehouse));
- if (!string.IsNullOrEmpty(cacheStr))
- {
- Warehouses = JsonConvert.DeserializeObject<List<Dt_Warehouse>>(cacheStr);
- }
-
-
- string? apiInfoStr = _cacheService.Get("apiInfos");
- if (!string.IsNullOrEmpty(apiInfoStr))
- {
- List<Dt_ApiInfo>? infos = JsonConvert.DeserializeObject<List<Dt_ApiInfo>>(apiInfoStr);
- if (infos == null || infos.Count == 0)
- {
- apiInfos = new List<Dt_ApiInfo>();
- }
- else
- {
- apiInfos = infos;
- }
- }
+ _locationInfoRepository = locationInfoRepository;
+ _unitOfWorkManage = unitOfWorkManage;
}
+ static object lock_taskReceive = new object();
/// <summary>
/// 鎺ユ敹WMS浠诲姟淇℃伅
/// </summary>
/// <param name="taskDTOs">WMS浠诲姟瀵硅薄闆嗗悎</param>
/// <returns>杩斿洖澶勭悊缁撴灉</returns>
- public WebResponseContent ReceiveWMSTask([NotNull] List<WMSTaskDTO> taskDTOs)
+ public WebResponseContent ReceiveWMSTask([NotNull] WMSTaskDTO taskDTO)
{
WebResponseContent content = new WebResponseContent();
try
{
- bool flag = false;
- List<Dt_Task> tasks = new List<Dt_Task>();
- foreach (var item in taskDTOs)
+ lock (lock_taskReceive)
{
- if (BaseDal.QueryFirst(x => x.TaskNum == item.TaskNum) != null)
+ List<Dt_Task> tasks = new List<Dt_Task>();
+ List<Dt_LocationInfo> locationInfos = _locationInfoRepository.GetCanOut(taskDTO.Tasks.Select(x=>x.ContainerCode).ToList());
+ TasksItem? tasksItem = taskDTO.Tasks.FirstOrDefault(x => !locationInfos.Select(t => t.PalletCode).Contains(x.ContainerCode));
+ if (tasksItem != null) throw new Exception($"浠诲姟{tasksItem.TaskCode}鏂欑鍙穥tasksItem.ContainerCode}涓嶅瓨鍦�");
+ Dt_LocationInfo? noOutLocation = locationInfos.FirstOrDefault(x=>x.LocationStatus != LocationStatusEnum.InStock.ObjToInt() || x.EnableStatus != EnableStatusEnum.Normal.ObjToInt());
+ if (noOutLocation != null) throw new Exception($"鏂欑{noOutLocation.PalletCode}璐т綅{noOutLocation.LocationCode}鐘舵�佷笉鍙嚭搴�");
+ List<Dt_StationManger> stationMangers = _stationMangerRepository.QueryData();
+ //涓嬪彂浠诲姟缁�
+ string taskGroup= taskDTO.TaskGroupCode.IsNullOrEmpty() ? Guid.NewGuid().ToString().Replace("-","") : taskDTO.TaskGroupCode;
+ foreach (var item in taskDTO.Tasks)
{
- flag = true;
- continue;
+ if (item.ToStationCode.IsNullOrEmpty()) throw new Exception($"浠诲姟{item.TaskCode}鍑哄簱鐩爣鎿嶄綔鍙颁笉鑳戒负绌�");
+ //鑾峰彇鎿嶄綔鍙�
+ Dt_StationManger? stationManger = stationMangers.FirstOrDefault(x => x.PickStationCode == item.ToStationCode);
+ if (stationManger == null) throw new Exception($"浠诲姟{item.TaskCode}鍑哄簱鐩爣鎿嶄綔鍙皗item.ToStationCode}涓嶅瓨鍦�");
+ Dt_Task task = _mapper.Map<Dt_Task>(item);
+ Dt_LocationInfo locationInfo = locationInfos.FirstOrDefault(x=>x.PalletCode==item.ContainerCode);
+ task.SourceAddress = locationInfo.LocationCode;
+ task.CurrentAddress = locationInfo.LocationCode;
+ task.NextAddress = stationManger.PickStationCode;
+ task.TargetAddress = stationManger.PickStationCode;
+ task.GroupId = taskGroup;
+ task.TaskType = TaskTypeEnum.Outbound.ObjToInt();
+ task.Roadway = locationInfo.RoadwayNo;
+ task.DeviceCode = "AGV";
+ task.TaskState = TaskStatusEnum.AGV_Execute.ObjToInt();
+ tasks.Add(task);
}
- Dt_Task task = _mapper.Map<Dt_Task>(item);
- task.Creater = "WMS";
- task.TaskState = (int)TaskStatusEnum.New;
- task.CurrentAddress = item.SourceAddress;
- Dt_Router? router;
-
- }
- BaseDal.AddData(tasks);
-
- _taskExecuteDetailService.AddTaskExecuteDetail(tasks.Select(x => x.TaskNum).ToList(), "鎺ユ敹WMS浠诲姟");
-
- content = (flag || tasks.Count > 0) ? WebResponseContent.Instance.OK("鎴愬姛") : WebResponseContent.Instance.Error("澶辫触");
- }
- catch (Exception ex)
- {
- content = WebResponseContent.Instance.Error($"浠诲姟鎺ユ敹閿欒,閿欒淇℃伅:{ex.Message}");
- }
- return content;
- }
-
- /// <summary>
- /// 鏍规嵁鎵樼洏鍙枫�佽捣濮嬪湴鍧�鍚慦MS璇锋眰浠诲姟
- /// </summary>
- /// <param name="palletCode">鎵樼洏鍙�</param>
- /// <param name="sourceAddress">璧峰鍦板潃</param>
- /// <returns></returns>
- public WebResponseContent RequestWMSTask(string palletCode, string sourceAddress, string materielBoxCode = "")
- {
- WebResponseContent content = new WebResponseContent();
- try
- {
- Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x => x.StationCode == sourceAddress);
- if (stationManger == null)
- {
- return WebResponseContent.Instance.Error($"鏈壘鍒扮珯鍙颁俊鎭�");
- }
- string address = AppSettings.Get("WMSApiAddress");
- if (string.IsNullOrEmpty(address))
- {
- return WebResponseContent.Instance.Error($"鏈壘鍒癢MSApi鍦板潃");
- }
- string responseStr = "";
- if (!string.IsNullOrEmpty(materielBoxCode))
- {
- responseStr = HttpHelper.Get($"{address}/api/Task/DeviceRequestInboundTask?stationCode={sourceAddress}&roadwayNo={stationManger.StackerCraneCode}&palletCode={palletCode}&materielBoxCode={materielBoxCode}");
- }
- else
- {
- responseStr = HttpHelper.Get($"{address}/api/Task/DeviceRequestInboundTask?stationCode={sourceAddress}&roadwayNo={stationManger.StackerCraneCode}&palletCode={palletCode}");
- }
- WebResponseContent? responseContent = JsonConvert.DeserializeObject<WebResponseContent>(responseStr);
- if (responseContent != null && responseContent.Status && responseContent.Data != null)
- {
- WMSTaskDTO? taskDTO = JsonConvert.DeserializeObject<WMSTaskDTO>(responseContent.Data.ToString());
- if (taskDTO != null)
+ locationInfos.ForEach(x =>
{
- content = ReceiveWMSTask(new List<WMSTaskDTO> { taskDTO });
- }
- }
+ x.LocationStatus=LocationStatusEnum.Lock.ObjToInt();
+ });
+ //娣诲姞浠诲姟鏇存柊璐т綅鏁版嵁
+ _unitOfWorkManage.BeginTran();
+ BaseDal.AddData(tasks);
+ _locationInfoRepository.UpdateData(locationInfos);
+ _unitOfWorkManage.CommitTran();
+ _taskExecuteDetailService.AddTaskExecuteDetail(tasks.Select(x => x.TaskNum).ToList(), "鎺ユ敹WMS浠诲姟");
+
+ content = tasks.Count > 0 ? content.OK("鎴愬姛") : content.Error("澶辫触");
+ }
}
catch (Exception ex)
{
- content = WebResponseContent.Instance.Error(ex.Message);
+ content.Error($"浠诲姟鎺ユ敹閿欒,閿欒淇℃伅:{ex.Message}");
}
return content;
}
- // <summary>
- /// 璇锋眰鍏ュ簱浠诲姟
- /// </summary>
- /// <param name="palletCode">鎵樼洏鍙�</param>
- /// <param name="sourceAddress">璧峰鍦板潃</param>
- /// /// <param name="roadWay">宸烽亾</param>
- /// <returns></returns>
- public WebResponseContent RequestYLWMSTaskSimple(string palletCode, string sourceAddress,int taskNum=0)
- {
- WebResponseContent content = new WebResponseContent();
- try
- {
- string address = AppSettings.Get("WMSApiAddress");
- if (string.IsNullOrEmpty(address))
- {
- return WebResponseContent.Instance.Error($"鏈壘鍒癢MSApi鍦板潃");
- }
- string responseStr = HttpHelper.Get($"{address}/api/Task/RequestYLWMSTaskSimple?stationCode={sourceAddress}&palletCode={palletCode}&taskNum{taskNum}");
- WebResponseContent? responseContent = JsonConvert.DeserializeObject<WebResponseContent>(responseStr);
- if (responseContent != null && responseContent.Status && responseContent.Data != null)
- {
- WMSTaskDTO? taskDTO = JsonConvert.DeserializeObject<WMSTaskDTO>(responseContent.Data.ToString());
- if (taskDTO != null)
- {
- content = ReceiveWMSTask(new List<WMSTaskDTO> { taskDTO });
- }
- }
- else
- {
- content = responseContent ?? content.Error("缁撴灉閿欒");
- }
-
- }
- catch (Exception ex)
- {
- content = WebResponseContent.Instance.Error(ex.Message);
- }
- return content;
- }
- // <summary>
- /// 璇锋眰鍏ュ簱宸烽亾
- /// </summary>
- /// <returns></returns>
- public WebResponseContent AssignCPRoadwayNo()
- {
- WebResponseContent content = new WebResponseContent();
- try
- {
- string address = AppSettings.Get("WMSApiAddress");
- if (string.IsNullOrEmpty(address))
- {
- return WebResponseContent.Instance.Error($"鏈壘鍒癢MSApi鍦板潃");
- }
- string responseStr = HttpHelper.Get($"{address}/api/Task/AssignCPRoadwayNo");
-
- if (!responseStr.IsNullOrEmpty())
- {
- content.OK("鎴愬姛", responseStr);
- }
-
- }
- catch (Exception ex)
- {
- content = WebResponseContent.Instance.Error(ex.Message);
- }
- return content;
- }
-
- // <summary>
- /// 璇锋眰鍘熸枡鍏ュ簱宸烽亾
- /// </summary>
- /// <returns></returns>
- public WebResponseContent AssignYLRoadwayNo(string palletCode)
- {
- WebResponseContent content = new WebResponseContent();
- try
- {
- string address = AppSettings.Get("WMSApiAddress");
- if (string.IsNullOrEmpty(address))
- {
- return WebResponseContent.Instance.Error($"鏈壘鍒癢MSApi鍦板潃");
- }
- string responseStr = HttpHelper.Get($"{address}/api/Task/AssignYLRoadwayNo?palletCode={palletCode}");
- WebResponseContent? responseContent = JsonConvert.DeserializeObject<WebResponseContent>(responseStr);
- if (responseContent != null && responseContent.Status && responseContent.Data != null)
- {
- content = responseContent;
- }
-
- }
- catch (Exception ex)
- {
- content = WebResponseContent.Instance.Error(ex.Message);
- }
- return content;
- }
- // <summary>
- /// 璇锋眰鍏ュ簱浠诲姟
- /// </summary>
- /// <param name="palletCode">鎵樼洏鍙�</param>
- /// <param name="sourceAddress">璧峰鍦板潃</param>
- /// /// <param name="roadWay">宸烽亾</param>
- /// <returns></returns>
- public WebResponseContent RequestWMSTaskSimple(string palletCode, string sourceAddress,string roadWay="", int taskType=630, int taskNum = 0, string targetAddress = "")
- {
- WebResponseContent content = new WebResponseContent();
- try
- {
- //string address = AppSettings.Get("WMSApiAddress");
- //if (string.IsNullOrEmpty(address))
- //{
- // return WebResponseContent.Instance.Error($"鏈壘鍒癢MSApi鍦板潃");
- //}
- //string responseStr = HttpHelper.Get($"{address}/api/Task/DeviceRequestInboundTaskSimple?stationCode={sourceAddress}&palletCode={palletCode}");
- //WebResponseContent? responseContent = JsonConvert.DeserializeObject<WebResponseContent>(responseStr);
- //if (responseContent != null && responseContent.Status && responseContent.Data != null)
- //{
- // WMSTaskDTO? taskDTO = JsonConvert.DeserializeObject<WMSTaskDTO>(responseContent.Data.ToString());
- // if (taskDTO != null)
- // {
- WMSTaskDTO? taskDTO = new WMSTaskDTO()
- {
- TaskNum = taskNum ==0 ? DateTime.Now.ToString("mmss").ObjToInt(): taskNum,
- PalletCode= palletCode,
- RoadWay= roadWay,
- TaskType= taskType,
- PalletType=1,
- TaskStatus= TaskStatusEnum.New.ObjToInt(),
- SourceAddress= sourceAddress,
- TargetAddress= targetAddress,
- WarehouseId=2,
- Grade=0,
- };
- content = ReceiveWMSTask(new List<WMSTaskDTO> { taskDTO });
- // }
- //}
-
- }
- catch (Exception ex)
- {
- content = WebResponseContent.Instance.Error(ex.Message);
- }
- return content;
- }
- public WebResponseContent MESBoxCodeNotice(string boxCode)
- {
- WebResponseContent content = new WebResponseContent();
- try
- {
- string address = AppSettings.Get("WMSApiAddress");
- if (string.IsNullOrEmpty(address))
- {
- return WebResponseContent.Instance.Error($"鏈壘鍒癢MSApi鍦板潃");
- }
- string responseStr = HttpHelper.Get($"{address}/api/Mes/MESBoxCodeNotice?boxCode={boxCode}");
- return content.OK(responseStr);
- }
- catch (Exception ex)
- {
- content = WebResponseContent.Instance.Error(ex.Message);
- }
- return content;
- }
+
public static string Post(string serviceAddress, string requestJson = "", string contentType = "application/json", Dictionary<string, string>? headers = null)
{
string result = string.Empty;
@@ -388,47 +189,6 @@
{
Logger.Add(serviceAddress, requestJson == null ? "" : requestJson, result, beginDate);
}
- }
-
- /// <summary>
- /// 鍚慦MS鐢宠鍒嗛厤璐т綅
- /// </summary>
- /// <param name="taskNum">浠诲姟鍙�</param>
- /// <param name="roadwayNo">宸烽亾鍙�</param>
- /// <returns></returns>
- public string? RequestAssignLocation(int taskNum, string roadwayNo)
- {
- string address = AppSettings.Get("WMSApiAddress");
- if (string.IsNullOrEmpty(address)) throw new Exception("鏈壘鍒癢MSApi鍦板潃");
- string responseStr = HttpHelper.Get($"{address}/api/Task/AssignInboundTaskLocation?taskNum={taskNum}&roadwayNo={roadwayNo}");
-
- WebResponseContent? responseContent = JsonConvert.DeserializeObject<WebResponseContent>(responseStr);
- if (responseContent != null && responseContent.Status && responseContent.Data != null)
- {
- return responseContent.Data.ToString();
- }
-
- return "";
- }
- /// <summary>
- /// 鍚慦MS鐢宠鍑哄簱AGV缁堢偣
- /// </summary>
- /// <param name="taskNum">浠诲姟鍙�</param>
- /// <returns></returns>
- /// <exception cref="Exception"></exception>
- public string? RequestTargetAddress(int taskNum)
- {
- string address = AppSettings.Get("WMSApiAddress");
- if (string.IsNullOrEmpty(address)) throw new Exception("鏈壘鍒癢MSApi鍦板潃");
- string responseStr = HttpHelper.Get($"{address}/api/Task/AssignOutTargetAddress?taskNum={taskNum}");
-
- WebResponseContent? responseContent = JsonConvert.DeserializeObject<WebResponseContent>(responseStr);
- if (responseContent != null && responseContent.Status && responseContent.Data != null)
- {
- return responseContent.Data.ToString();
- }
-
- return "";
}
/// <summary>
@@ -565,10 +325,118 @@
return WebResponseContent.Instance.Error(ex.Message);
}
}
-
- public Dt_Task QueryBarCodeAGVFinishTask(int TaskNum, string currentAddress)
+ /// <summary>
+ /// AGV浠诲姟鏀捐
+ /// </summary>
+ /// <returns></returns>
+ public WebResponseContent AgvTaskFlow(string code)
{
- return BaseDal.QueryFirst(x => TaskInboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskStatusEnum.AGV_Finish && x.CurrentAddress == currentAddress && x.TaskNum == TaskNum, TaskOrderBy);
+ WebResponseContent content=new WebResponseContent();
+ try
+ {
+ string? url = _apiInfoRepository.QueryFirst(x => x.ApiCode == APIEnum.AgvTaskFlow.ToString())?.ApiAddress;
+ if (string.IsNullOrEmpty(url)) throw new Exception($"{code},鏈壘鍒癆GV浠诲姟鏀捐鎺ュ彛,璇锋鏌ユ帴鍙i厤缃�");
+ AgvTaskFlowDTO agvTaskFlowDTO = new AgvTaskFlowDTO()
+ {
+ RequestId = Guid.NewGuid().ToString().Replace("-", ""),
+ ContainerCode = code
+ };
+ string request = JsonConvert.SerializeObject(agvTaskFlowDTO, settings);
+ string response = HttpHelper.Post(url, request);
+ AgvResponseContent agvResponse = JsonConvert.DeserializeObject<AgvResponseContent>(response) ?? throw new Exception($"{code},鏈帴鏀跺埌AGV浠诲姟鏀捐杩斿洖鍊�");
+ if (!agvResponse.Success) throw new Exception($"鏂欑{code},AGV浠诲姟鏀捐閿欒,淇℃伅:{agvResponse.Message}");
+ content.OK();
+ }
+ catch (Exception ex)
+ {
+ content.Error(ex.Message);
+ }
+ return content;
+ }
+ /// <summary>
+ /// WMS鏂欑鍒拌揪鎷i�変綅涓婃姤
+ /// </summary>
+ /// <returns></returns>
+ public WebResponseContent WMSPickUp(string stationCode,string pickCode)
+ {
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+ string? url = _apiInfoRepository.QueryFirst(x => x.ApiCode == APIEnum.WMSPickArrivedUp.ToString())?.ApiAddress;
+ if (string.IsNullOrEmpty(url)) throw new Exception($"鏈壘鍒癢MS鏂欑鍒拌揪鎷i�変綅涓婃姤鎺ュ彛,璇锋鏌ユ帴鍙i厤缃�");
+ ContainerArriveDTO containerArriveDTO = new ContainerArriveDTO()
+ {
+ SlotCode = stationCode,
+ ContainerCode = pickCode
+ };
+ string request = JsonConvert.SerializeObject(containerArriveDTO, settings);
+ string response = HttpHelper.Post(url, request);
+ WMSResponseContent wMSResponse = JsonConvert.DeserializeObject<WMSResponseContent>(response) ?? throw new Exception($"{pickCode},鏈帴鏀跺埌WMS鏂欑鍒拌揪鎷i�変綅涓婃姤杩斿洖鍊�");
+ if (wMSResponse.Code != "0") throw new Exception($"鏂欑{pickCode}WMS鏂欑鍒拌揪鎷i�変綅涓婃姤閿欒,淇℃伅:{wMSResponse.Msg}");
+ content.OK();
+ }
+ catch (Exception ex)
+ {
+ content.Error(ex.Message);
+ }
+ return content;
+ }
+ /// <summary>
+ /// 浠诲姟瀹屾垚
+ /// </summary>
+ /// <param name="taskNum"></param>
+ /// <returns></returns>
+ public WebResponseContent TaskCompleted(int taskNum)
+ {
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+ Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum);
+ if (task != null && task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)//鍑哄簱浠诲姟閫昏緫
+ {
+ Dt_LocationInfo locationInfo = _locationInfoRepository.QueryFirst(x=>x.PalletCode==task.PalletCode);
+ if (locationInfo.LocationStatus != LocationStatusEnum.Lock.ObjToInt())
+ {
+ return content.Error($"{locationInfo.LocationCode}璐т綅鐘舵�佷笉姝g‘");
+ }
+ task.TaskState = TaskStatusEnum.Finish.ObjToInt();
+ locationInfo.LocationStatus = LocationStatusEnum.Free.ObjToInt();
+ locationInfo.PalletCode = "";
+ _unitOfWorkManage.BeginTran();
+ _locationInfoRepository.UpdateData(locationInfo);
+ BaseDal.DeleteAndMoveIntoHty(task, App.User?.UserId == 0 ? OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚);
+ _unitOfWorkManage.CommitTran();
+ }
+ else if(task != null && task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup)//鍏ュ簱浠诲姟閫昏緫
+ {
+ string? url = _apiInfoRepository.QueryFirst(x => x.ApiCode == APIEnum.WMSInBoundBack.ToString())?.ApiAddress;
+ if (string.IsNullOrEmpty(url))
+ {
+ _taskExecuteDetailService.AddTaskExecuteDetail(taskNum, $"鏈壘鍒癢MS鍏ュ簱涓婃姤鎺ュ彛,璇锋鏌ユ帴鍙i厤缃�");
+ UpdateTaskExceptionMessage(taskNum, $"鏈壘鍒癢MS鍏ュ簱涓婃姤鎺ュ彛,璇锋鏌ユ帴鍙i厤缃�");
+ return content.Error($"{taskNum},鏈壘鍒癢MS鍏ュ簱涓婃姤鎺ュ彛,璇锋鏌ユ帴鍙i厤缃�");
+ }
+ ContainerInFinishDTO containerInFinishDTO = new ContainerInFinishDTO()
+ {
+ TaskCode= task.TaskNum.ToString(),
+ ContainerCode = task.PalletCode,
+ FromStationCode = task.SourceAddress,
+ ToLocationCode = task.TargetAddress
+ };
+ string request = JsonConvert.SerializeObject(containerInFinishDTO, settings);
+ //璋冪敤鎺ュ彛
+ string response = HttpHelper.Post(url, request);
+ WMSResponseContent wMSResponse = JsonConvert.DeserializeObject<WMSResponseContent>(response) ??throw new Exception($"{taskNum},鏈帴鏀跺埌WMS鍏ュ簱涓婃姤杩斿洖鍊�");
+ if (wMSResponse.Code!="0") throw new Exception($"鍏ュ簱浠诲姟{task.TaskNum}WMS鍏ュ簱涓婃姤閿欒,淇℃伅:{wMSResponse.Msg}");
+ }
+ content.OK("浠诲姟瀹屾垚");
+ }
+ catch (Exception ex)
+ {
+ _unitOfWorkManage.RollbackTran();
+ content.Error(ex.Message);
+ }
+ return content;
}
}
}
--
Gitblit v1.9.3