From 696edbff3c8812e4b820f624d66a02ae6ddb1a06 Mon Sep 17 00:00:00 2001
From: 647556386 <647556386@qq.com>
Date: 星期四, 16 四月 2026 13:40:18 +0800
Subject: [PATCH] Merge branch 'htq20251215' of http://115.159.85.185:8098/r/ZhongRui/ALDbanyunxiangmu into htq20251215
---
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_BasicService/MESOperation/FeedbackMesService.cs | 135 ++++++++++++++++++++++++++++++++++----------
1 files changed, 104 insertions(+), 31 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_BasicService/MESOperation/FeedbackMesService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_BasicService/MESOperation/FeedbackMesService.cs"
index 7341189..b584824 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_BasicService/MESOperation/FeedbackMesService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_BasicService/MESOperation/FeedbackMesService.cs"
@@ -7,11 +7,13 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using WIDESEA_Common.OrderEnum;
using WIDESEA_Core;
using WIDESEA_Core.BaseRepository;
using WIDESEA_Core.BaseServices;
using WIDESEA_Core.Helper;
using WIDESEA_Core.HttpContextUser;
+using WIDESEA_Core.LogHelper;
using WIDESEA_Core.Util;
using WIDESEA_DTO.Base;
using WIDESEA_DTO.ReturnMES;
@@ -42,18 +44,33 @@
public WebResponseContent OutboundFeedback(string orderNo)
{
+ WebResponseContent webResponse = new WebResponseContent();
try
{
Dt_OutboundOrder outboundOrder = _outboundOrderRepository.Db.Queryable<Dt_OutboundOrder>().Where(x => x.OrderNo == orderNo).Includes(x => x.Details).First();
if (outboundOrder == null)
{
- return WebResponseContent.Instance.Error($"鏈壘鍒板搴旂殑鍑哄簱鍗曚俊鎭�");
+ return webResponse = WebResponseContent.Instance.Error($"鏈壘鍒板搴旂殑鍑哄簱鍗曚俊鎭�");
+ }
+ if(outboundOrder.OrderType == InOrderTypeEnum.ReCheck.ObjToInt() || outboundOrder.CreateType == OrderCreateTypeEnum.CreateInSystem.ObjToInt())
+ {
+ return webResponse = WebResponseContent.Instance.OK($"璇ュ崟鎹棤闇�鍥炰紶MES");
}
- Dt_MesReturnRecord returnRecord = BaseDal.QueryFirst(x => x.OrderNo == orderNo && x.OrderId == outboundOrder.Id && x.ReturnStatus == 2, new Dictionary<string, OrderByType> { { nameof(Dt_MesReturnRecord.Id), OrderByType.Desc } });
- if (returnRecord != null)
+ if (outboundOrder.IsBatch == 0 && outboundOrder.OrderStatus != OutOrderStatusEnum.鍑哄簱瀹屾垚.ObjToInt())
{
- HttpResponseResult<MesResponseDTO> httpResponse = _httpClientHelper.Post<MesResponseDTO>(returnRecord.ApiUrl, returnRecord.RequestData);
+ return webResponse = WebResponseContent.Instance.OK($"璇ュ崟鎹睘浜庝笉鍒嗘壒鑷姩鍥炰紶锛屼笉鍙墜鍔ㄥ垎鎵瑰洖浼�");
+ }
+ Dt_OutStockLockInfo outStockLockInfo = _allocateRepository.Db.Queryable<Dt_OutStockLockInfo>().Where(x => x.OrderNo == outboundOrder.OrderNo).First();
+ if (outStockLockInfo != null)
+ {
+ return WebResponseContent.Instance.Error("璇ュ崟鎹繕瑕佹湭鎷i�夌殑鐗╂枡锛岃鍏堟嫞閫夊畬鎴愬啀鐐瑰嚮鍥炰紶");
+ }
+ List<Dt_MesReturnRecord> returnRecords = BaseDal.QueryData(x => x.OrderNo == orderNo && x.OrderId == outboundOrder.Id && x.ReturnStatus == 2);
+
+ foreach (var item in returnRecords)
+ {
+ HttpResponseResult<MesResponseDTO> httpResponse = _httpClientHelper.Post<MesResponseDTO>(item.ApiUrl, item.RequestData);
string rMsg = "鎴愬姛";
bool success = httpResponse.IsSuccess && httpResponse.Data.Code == "200";
@@ -69,22 +86,16 @@
}
}
- returnRecord.ReturnCount += 1;
+ item.ReturnCount += 1;
- returnRecord.ReturnStatus = success ? 1 : 2;
- returnRecord.HttpStatusCode = httpResponse.StatusCode.ObjToInt();
- returnRecord.LastReturnTime = DateTime.Now;
- returnRecord.ResponseData = httpResponse.Content;
- returnRecord.SuccessTime = success ? DateTime.Now : null;
- BaseDal.UpdateData(returnRecord);
- WebResponseContent content = new WebResponseContent();
- content.Status = success;
- content.Message = rMsg;
- return content;
+ item.ReturnStatus = success ? 1 : 2;
+ item.HttpStatusCode = httpResponse.StatusCode.ObjToInt();
+ item.LastReturnTime = DateTime.Now;
+ item.ResponseData = httpResponse.Content;
+ item.SuccessTime = success ? DateTime.Now : null;
}
-
-
+ BaseDal.UpdateData(returnRecords);
HttpResponseResult<MesResponseDTO> httpResponseResult = new HttpResponseResult<MesResponseDTO>();
string reqCode = Guid.NewGuid().ToString();
@@ -96,12 +107,40 @@
MaterialOutboundReturnDTO? returnDTO = BuildOutboundFeedbackData(outboundOrder);
if (returnDTO == null)
{
- return WebResponseContent.Instance.Error($"鏋勫缓鍥炶皟瀵硅薄澶辫触");
+ return webResponse = WebResponseContent.Instance.Error($"鏋勫缓鍥炶皟瀵硅薄澶辫触");
}
- if(returnDTO.Details.Count <= 0)
+ if (returnDTO.Details.Count <= 0)
{
- return WebResponseContent.Instance.Error($"璇ュ崟鎹棤鏄庣粏鍙洖浼�");
+ if (returnRecords.Count() == returnRecords.Count(x => x.ReturnStatus == 1))
+ {
+ if(outboundOrder.OrderStatus == OutOrderStatusEnum.鍑哄簱瀹屾垚.ObjToInt())
+ {
+ outboundOrder.ReturnToMESStatus = 1;
+ }
+ else if (outboundOrder.OrderStatus == OutOrderStatusEnum.鍑哄簱涓�.ObjToInt())
+ {
+ outboundOrder.ReturnToMESStatus = 3;
+ }
+ else
+ {
+ outboundOrder.ReturnToMESStatus = 0;
+ }
+
+ }
+ else if (returnRecords.Count(x => x.ReturnStatus == 2) > 0)
+ {
+ outboundOrder.ReturnToMESStatus = 4;
+ }
+ else if (returnRecords.Count() == returnRecords.Count(x => x.ReturnStatus == 2))
+ {
+ outboundOrder.ReturnToMESStatus = 2;
+ }
+ _outboundOrderRepository.UpdateData(outboundOrder);
+
+
+ return webResponse = WebResponseContent.Instance.OK($"璇ュ崟鎹病鏈夐渶瑕佸洖浼犳槑缁嗭紝鍥炰紶{returnRecords.Count()}鏉★紝鍥炰紶鎴愬姛{returnRecords.Count(x=>x.ReturnStatus == 1)}鏉★紝鍥炰紶澶辫触{returnRecords.Count(x => x.ReturnStatus == 2)}鏉�");
+
}
string apiUrl = AppSettings.GetValue("MaterialOutboundFeedbackUrl");
@@ -121,21 +160,47 @@
Dt_AllocateOrder allocateOrder = _allocateRepository.QueryFirst(x => x.OrderNo == outboundOrder.OrderNo);
if (allocateOrder == null)
{
- return WebResponseContent.Instance.Error($"鏈壘鍒板搴旂殑璋冩嫧鍗�");
+ return webResponse = WebResponseContent.Instance.Error($"鏈壘鍒板搴旂殑璋冩嫧鍗�");
}
AllocationReturnDTO? returnDTO = BuildAllocationFeedbackData(outboundOrder, allocateOrder.FromWarehouse, allocateOrder.ToWarehouse);
if (returnDTO == null)
{
- return WebResponseContent.Instance.Error($"鏋勫缓鍥炶皟瀵硅薄澶辫触");
+ return webResponse = WebResponseContent.Instance.Error($"鏋勫缓鍥炶皟瀵硅薄澶辫触");
}
if (returnDTO.Details.Count <= 0)
{
- return WebResponseContent.Instance.Error($"璇ュ崟鎹棤鏄庣粏鍙洖浼�");
+ if(returnRecords.Count() == returnRecords.Count(x => x.ReturnStatus == 1))
+ {
+ if (outboundOrder.OrderStatus == OutOrderStatusEnum.鍑哄簱瀹屾垚.ObjToInt())
+ {
+ outboundOrder.ReturnToMESStatus = 1;
+ }
+ else if (outboundOrder.OrderStatus == OutOrderStatusEnum.鍑哄簱涓�.ObjToInt())
+ {
+ outboundOrder.ReturnToMESStatus = 3;
+ }
+ else
+ {
+ outboundOrder.ReturnToMESStatus = 0;
+ }
+ }
+ else if(returnRecords.Count(x => x.ReturnStatus == 2)>0)
+ {
+ outboundOrder.ReturnToMESStatus = 4;
+ }
+ else if (returnRecords.Count() == returnRecords.Count(x => x.ReturnStatus == 2))
+ {
+ outboundOrder.ReturnToMESStatus = 2;
+ }
+ _outboundOrderRepository.UpdateData(outboundOrder);
+
+
+ return webResponse = WebResponseContent.Instance.OK($"璇ュ崟鎹病鏈夐渶瑕佸洖浼犳槑缁嗭紝鍥炰紶{returnRecords.Count()}鏉★紝鍥炰紶鎴愬姛{returnRecords.Count(x => x.ReturnStatus == 1)}鏉★紝鍥炰紶澶辫触{returnRecords.Count(x => x.ReturnStatus == 2)}鏉�");
}
- string apiUrl = AppSettings.GetValue("AllocationFeedbackUrl"); ;
+ string apiUrl = AppSettings.GetValue("AllocationFeedbackUrl");
returnDTO.ReqCode = reqCode;
returnDTO.ReqTime = reqTime;
JsonSerializerSettings settings = new JsonSerializerSettings
@@ -146,6 +211,8 @@
lineNos = returnDTO.Details.Select(x => x.LineNo).ToList();
httpResponseResult = _httpClientHelper.Post<MesResponseDTO>(apiUrl, requestData);
httpResponseResult.ApiUrl = apiUrl;
+
+ Logger.Add(requestData, httpResponseResult.Serialize());
}
bool isSuccess = httpResponseResult.IsSuccess && httpResponseResult.Data.Code == "200";
@@ -200,7 +267,7 @@
mesReturnRecord.ReturnType = outboundOrder.Details.Count == outboundOrderDetails.Count ? 1 : 2;
- if (outboundOrder.Details.Count == outboundOrderDetails.Count && outboundOrderDetails.All(x => x.ReturnToMESStatus == 1 || x.ReturnToMESStatus == 2))
+ if (outboundOrder.OrderStatus == OutOrderStatusEnum.鍑哄簱瀹屾垚.ObjToInt() && outboundOrderDetails.All(x => x.ReturnToMESStatus == 1 || x.ReturnToMESStatus == 2))
{
outboundOrder.ReturnToMESStatus = isSuccess ? 1 : 2;
}
@@ -213,15 +280,21 @@
_outboundOrderRepository.UpdateData(outboundOrder);
_unitOfWorkManage.CommitTran();
+ int successCount = returnRecords.Where(x => x.ReturnStatus == 1).Count() + (isSuccess ? 1 : 0);
+ int failCount = returnRecords.Where(x => x.ReturnStatus == 2).Count() + (!isSuccess ? 1 : 0);
- WebResponseContent responseContent = new WebResponseContent();
- responseContent.Status = isSuccess;
- responseContent.Message = message;
- return responseContent;
+ webResponse.Status = true;
+ webResponse.Message = $"鍥炶皟鎴愬姛鏉℃暟锛歿successCount}锛屽洖璋冨け璐ユ潯鏁帮細{failCount}";
+
+ return webResponse;
}
catch (Exception ex)
{
- return WebResponseContent.Instance.Error(ex.Message);
+ return webResponse = WebResponseContent.Instance.Error(ex.Message);
+ }
+ finally
+ {
+ Logger.Add(orderNo, webResponse.Serialize());
}
}
@@ -457,7 +530,7 @@
Dt_MesReturnRecord mesReturnRecord = new Dt_MesReturnRecord()
{
ApiUrl = httpResponseResult.ApiUrl,
- InterfaceType = 1,
+ InterfaceType = 4,
OrderId = materialCodeInfo.OrderId ?? 0,
OrderNo = materialCodeInfo.OrderNo ?? "",
RequestCode = reqCode,
--
Gitblit v1.9.3