From 7d6194cf002b8f54d41cdc50b7f1b1843c1da636 Mon Sep 17 00:00:00 2001
From: Admin <Admin@ADMIN>
Date: 星期四, 15 一月 2026 13:14:21 +0800
Subject: [PATCH] MES接口
---
项目代码/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs | 91 +++++++++++++++++++++++++++++++++++++++------
1 files changed, 78 insertions(+), 13 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
index 585a380..c48f46f 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
@@ -17,12 +17,17 @@
using AutoMapper;
using SqlSugar;
+using System.Net;
using System.Reflection;
+using WIDESEA_Common.LocationEnum;
+using WIDESEA_Common.OtherEnum;
+using WIDESEA_Common.StockEnum;
using WIDESEA_Common.TaskEnum;
using WIDESEA_Core;
using WIDESEA_Core.BaseRepository;
using WIDESEA_Core.BaseServices;
using WIDESEA_Core.Helper;
+using WIDESEA_DTO.Inbound;
using WIDESEA_DTO.Task;
using WIDESEA_IBasicService;
using WIDESEA_IInboundService;
@@ -55,10 +60,16 @@
public List<int> TaskOutboundTypes => typeof(TaskTypeEnum).GetEnumIndexList();
- public TaskService(IRepository<Dt_Task> BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage) : base(BaseDal)
+ public TaskService(IRepository<Dt_Task> BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IStockInfoService stockInfoService, ILocationInfoService locationInfoService,
+ IWarehouseService warehouseService, IRoadWayinfoService roadWayinfoService) : base(BaseDal)
{
_mapper = mapper;
_unitOfWorkManage = unitOfWorkManage;
+ _stockInfoService = stockInfoService;
+ _locationInfoService = locationInfoService;
+ _warehouseService = warehouseService;
+ _roadWayinfoService=roadWayinfoService;
+
}
public string MES_InReporttask = WIDESEA_Core.Helper.AppSettings.Configuration["MES_InReporttask"]; //鍏ュ簱鍙嶉淇℃伅
public string MES_OutReporttask = WIDESEA_Core.Helper.AppSettings.Configuration["MES_OutReporttask"]; //鍑哄簱鍙嶉淇℃伅
@@ -79,11 +90,12 @@
/// <returns></returns>
public WebResponseContent TaskCompleted(WCSTaskDTO wCSTask)
{
+ WebResponseContent webResponse= new WebResponseContent();
try
{
Dt_Task task = BaseDal.QueryFirst(x => x.TaskId == wCSTask.TaskNum && x.PalletCode == wCSTask.PalletCode);
if (task == null)
- return WebResponseContent.Instance.Error("鏈壘鍒颁换鍔′俊鎭�");
+ return webResponse.Error("鏈壘鍒颁换鍔′俊鎭�");
switch ((TaskTypeEnum)task.TaskType)
{
@@ -94,27 +106,63 @@
case TaskTypeEnum.Relocation:
return HandleRelocationTask(task, wCSTask.TaskType);
default:
- return WebResponseContent.Instance.Error($"浠诲姟绫诲瀷閿欒锛屼换鍔″彿锛歿task.TaskId},鎵樼洏缂栧彿锛歿task.PalletCode},绫诲瀷锛歿task.TaskType}");
+ return webResponse.Error($"浠诲姟绫诲瀷閿欒锛屼换鍔″彿锛歿task.TaskId},鎵樼洏缂栧彿锛歿task.PalletCode},绫诲瀷锛歿task.TaskType}");
}
}
catch (Exception ex)
{
- return WebResponseContent.Instance.Error($"WMS浠诲姟瀹屾垚閿欒锛歿ex.Message}");
+ return webResponse.Error($"WMS浠诲姟瀹屾垚閿欒锛歿ex.Message}");
}
}
private WebResponseContent HandleInboundTask(Dt_Task task, int wcsTaskType)
{
+ WebResponseContent content = new WebResponseContent();
switch (wcsTaskType)
{
case 1:
task.TaskStatus = (int)InTaskStatusEnum.PLC_InFinish;
+ int loctype = 0;
+ if (task.Roadway == "1" || task.Roadway == "2")
+ {
+ if(task.PalletType=="1") loctype = (int)LocationTypeEnum.SmallPallet;
+ else if(task.PalletType=="2") loctype = (int)LocationTypeEnum.MediumPallet;
+ }
+ else
+ {
+ loctype = (int)LocationTypeEnum.LargePallet;
+ }
+ //鏌ユ壘璐т綅锛屾洿鏂颁换鍔�
+ Dt_LocationInfo dt_Location=_locationInfoService.GetLocation(task.Roadway, loctype);
+ Dt_LocationInfo ShallowCargoHold = _locationInfoService.ShallowGetLocation(dt_Location.RoadwayNo, dt_Location.LocationType, dt_Location.Row, dt_Location.Layer, dt_Location.Column);
+ if(ShallowCargoHold==null) return content.Error($"鏈壘鍒拌璐т綅淇℃伅,璐т綅缂栧彿:{dt_Location.LocationCode}鐨勬祬璐т綅");
+ if(ShallowCargoHold.LocationStatus != (int)LocationStatusEnum.Free) return content.Error($"浠诲姟鍙凤細{task.TaskId},鎵樼洏缂栧彿锛歿task.PalletCode},鏌ユ壘鐨勮揣浣嶆祬璐т綅鏈夎揣锛岃揣浣嶇紪鍙凤細{ShallowCargoHold.LocationCode}");
+
+ task.TargetAddress = dt_Location.LocationCode;
+ task.CurrentAddress = task.NextAddress;
+ task.NextAddress= dt_Location.LocationCode;
+ task.TaskStatus = (int)InTaskStatusEnum.PLC_InFinish;
+ dt_Location.LocationStatus = (int)LocationStatusEnum.Lock;
+
+ _locationInfoService.UpdateData(dt_Location);
BaseDal.UpdateData(task);
- return WebResponseContent.Instance.OK($"宸叉帴鏀跺叆搴撹緭閫佺嚎瀹屾垚淇℃伅锛屼换鍔″彿锛歿task.TaskId},鎵樼洏缂栧彿锛歿task.PalletCode}");
+ return content.OK($"宸叉帴鏀跺叆搴撹緭閫佺嚎瀹屾垚淇℃伅锛屼换鍔″彿锛歿task.TaskId},鎵樼洏缂栧彿锛歿task.PalletCode}");
+
+
case 2:
- task.TaskStatus = (int)InTaskStatusEnum.SC_OutFinish;
- BaseDal.UpdateData(task);
- return WebResponseContent.Instance.OK($"宸叉帴鏀跺叆搴撳爢鍨涙満瀹屾垚淇℃伅锛屼换鍔″彿锛歿task.TaskId},鎵樼洏缂栧彿锛歿task.PalletCode}");
+ //涓婃姤MES浠诲姟瀹屾垚
+ MES_parameter mES_Parameter = InStoreDocCallback(task.TaskNum, "Finish", "鎿嶄綔鎴愬姛", task.PalletCode, task.TargetAddress);
+ if (mES_Parameter.Result == "Y")
+ {
+
+ task.TaskStatus = (int)InTaskStatusEnum.SC_OutFinish;
+ BaseDal.DeleteData(task);
+ return content.OK($"宸叉帴鏀跺叆搴撳爢鍨涙満瀹屾垚淇℃伅锛屼换鍔″彿锛歿task.TaskId},鎵樼洏缂栧彿锛歿task.PalletCode}");
+ }
+ else
+ {
+ return content.Error("涓婁紶MES澶辫触锛屽師鍥狅細" + mES_Parameter.ResultMsg);
+ }
default:
return WebResponseContent.Instance.Error($"WCS涓婃姤绫诲瀷閿欒锛歿wcsTaskType}");
}
@@ -122,18 +170,32 @@
private WebResponseContent HandleOutboundTask(Dt_Task task, int wcsTaskType)
{
+ WebResponseContent content = new WebResponseContent();
switch (wcsTaskType)
{
case 1:
- task.TaskStatus = (int)OutTaskStatusEnum.PLC_OutFinish;
- BaseDal.UpdateData(task);
- return WebResponseContent.Instance.OK($"宸叉帴鏀跺嚭搴撹緭閫佺嚎瀹屾垚淇℃伅锛屼换鍔″彿锛歿task.TaskId},鎵樼洏缂栧彿锛歿task.PalletCode}");
+ //涓婃姤MES浠诲姟瀹屾垚
+ MES_parameter mES_Parameter = OutStoreDocCallback(task.TaskNum, "Finish", "鎿嶄綔鎴愬姛");
+ if (mES_Parameter.Result == "Y")
+ {
+ task.TaskStatus = (int)OutTaskStatusEnum.PLC_OutFinish;
+ BaseDal.DeleteData(task);
+ return content.OK($"宸叉帴鏀跺嚭搴撹緭閫佺嚎瀹屾垚淇℃伅锛屼换鍔″彿锛歿task.TaskId},鎵樼洏缂栧彿锛歿task.PalletCode}");
+ }
+ else
+ {
+ return content.Error("涓婁紶MES澶辫触锛屽師鍥狅細" + mES_Parameter.ResultMsg);
+ }
case 2:
+ //鑾峰彇瀵瑰簲PLC绔欏彴淇℃伅
+ Dt_roadwayinfo _Roadwayinfo = _roadWayinfoService.QbtainPlatform(task.Roadway);
+ task.CurrentAddress = _Roadwayinfo.OutStationCode;
+ task.NextAddress = task.TargetAddress;
task.TaskStatus = (int)OutTaskStatusEnum.SC_OutFinish;
BaseDal.UpdateData(task);
- return WebResponseContent.Instance.OK($"宸叉帴鏀跺嚭搴撳爢鍨涙満瀹屾垚淇℃伅锛屼换鍔″彿锛歿task.TaskId},鎵樼洏缂栧彿锛歿task.PalletCode}");
+ return content.OK($"宸叉帴鏀跺嚭搴撳爢鍨涙満瀹屾垚淇℃伅锛屼换鍔″彿锛歿task.TaskId},鎵樼洏缂栧彿锛歿task.PalletCode}");
default:
- return WebResponseContent.Instance.Error($"WCS涓婃姤绫诲瀷閿欒锛歿wcsTaskType}");
+ return content.Error($"WCS涓婃姤绫诲瀷閿欒锛歿wcsTaskType}");
}
}
@@ -147,5 +209,8 @@
}
return WebResponseContent.Instance.Error($"WCS涓婃姤绫诲瀷閿欒锛歿wcsTaskType}");
}
+
+
+
}
}
--
Gitblit v1.9.3