1
heshaofeng
2026-03-25 37454e625df68d40897112b2e8c2e3cf4d7163e3
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_BasicService/MESOperation/FeedbackMesService.cs
@@ -7,6 +7,7 @@
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;
@@ -51,7 +52,20 @@
                {
                    return webResponse = WebResponseContent.Instance.Error($"未找到对应的出库单信息");
                }
                if(outboundOrder.OrderType == InOrderTypeEnum.ReCheck.ObjToInt() || outboundOrder.CreateType == OrderCreateTypeEnum.CreateInSystem.ObjToInt())
                {
                    return webResponse = WebResponseContent.Instance.OK($"该单据无需回传MES");
                }
                if (outboundOrder.IsBatch == 0 && outboundOrder.OrderStatus != OutOrderStatusEnum.出库完成.ObjToInt())
                {
                    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("该单据还要未拣选的物料,请先拣选完成再点击回传");
                }
                List<Dt_MesReturnRecord> returnRecords = BaseDal.QueryData(x => x.OrderNo == orderNo && x.OrderId == outboundOrder.Id && x.ReturnStatus == 2);
                foreach (var item in returnRecords)
@@ -100,7 +114,19 @@
                    {
                        if (returnRecords.Count() == returnRecords.Count(x => x.ReturnStatus == 1))
                        {
                            outboundOrder.ReturnToMESStatus = 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)
                        {
@@ -113,7 +139,7 @@
                        _outboundOrderRepository.UpdateData(outboundOrder);
                        return webResponse = WebResponseContent.Instance.OK($"该单据没有需要回传明细,失败数据回传{returnRecords.Count()}条,回传成功{returnRecords.Count(x=>x.ReturnStatus == 1)}条,回传失败{returnRecords.Count(x => x.ReturnStatus == 2)}条");
                        return webResponse = WebResponseContent.Instance.OK($"该单据没有需要回传明细,回传{returnRecords.Count()}条,回传成功{returnRecords.Count(x=>x.ReturnStatus == 1)}条,回传失败{returnRecords.Count(x => x.ReturnStatus == 2)}条");
                    }
@@ -147,7 +173,18 @@
                    {
                        if(returnRecords.Count() == returnRecords.Count(x => x.ReturnStatus == 1))
                        {
                            outboundOrder.ReturnToMESStatus = 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)
                        {
@@ -160,10 +197,10 @@
                        _outboundOrderRepository.UpdateData(outboundOrder);
                        
                        
                        return webResponse = WebResponseContent.Instance.OK($"该单据没有需要回传明细,失败数据回传{returnRecords.Count()}条,回传成功{returnRecords.Count(x => x.ReturnStatus == 1)}条,回传失败{returnRecords.Count(x => x.ReturnStatus == 2)}条");
                        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
@@ -244,7 +281,7 @@
                _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);
                int failCount = returnRecords.Where(x => x.ReturnStatus == 2).Count() + (!isSuccess ? 1 : 0);
                webResponse.Status = true;
                webResponse.Message = $"回调成功条数:{successCount},回调失败条数:{failCount}";
@@ -493,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,