1
647556386
2025-12-22 640586364fd766bedfcdac0720bd6ad5d2cf2fae
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs
@@ -744,13 +744,15 @@
                }
                Dt_OutboundOrder outboundOrder = _outboundOrderService.Db.Queryable<Dt_OutboundOrder>().Where(x => x.OrderNo == stockInfo.Details.FirstOrDefault().OrderNo).Includes(x=>x.Details).First();
                if(outboundOrder.OrderStatus == OutOrderStatusEnum.鍑哄簱瀹屾垚.ObjToInt())
                ///鍥炶皟MES
                HttpResponseResult<MesResponseDTO> httpResponseResult = new HttpResponseResult<MesResponseDTO>();
                string reqCode = Guid.NewGuid().ToString();
                string reqTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                string requestData = string.Empty;
                List<string> lineNos = new List<string>();
                if (outboundOrder.OrderStatus == OutOrderStatusEnum.鍑哄簱瀹屾垚.ObjToInt())
                {
                    HttpResponseResult<MesResponseDTO> httpResponseResult = new HttpResponseResult<MesResponseDTO>();
                    string reqCode = Guid.NewGuid().ToString();
                    string reqTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    string requestData = string.Empty;
                    List<string> lineNos = new List<string>();
                    Dt_AllocateOrder allocateOrder = _allocateOrderRepository.QueryFirst(x => x.OrderNo == outboundOrder.OrderNo);
                    if (allocateOrder == null)
                    {
@@ -773,6 +775,72 @@
                    httpResponseResult = _httpClientHelper.Post<MesResponseDTO>(apiUrl, requestData);
                    httpResponseResult.ApiUrl = apiUrl;
                }
                bool isSuccess = httpResponseResult.IsSuccess && httpResponseResult.Data.Code == "200";
                string message = "鎴愬姛";
                if (!isSuccess)
                {
                    if (!httpResponseResult.IsSuccess)
                    {
                        message = $"MES鎺ュ彛杩斿洖閿欒锛孒TTP浠g爜锛歿httpResponseResult.StatusCode}锛屼俊鎭細{httpResponseResult.ErrorMessage}";
                    }
                    else if (httpResponseResult?.Data?.Code != "200")
                    {
                        message = $"璋冪敤MES鎺ュ彛澶辫触锛屼唬鐮侊細{httpResponseResult?.Data?.Code}锛屼俊鎭細{httpResponseResult?.Data?.Message}";
                    }
                }
                Dt_MesReturnRecord mesReturnRecord = new Dt_MesReturnRecord()
                {
                    ApiUrl = httpResponseResult.ApiUrl,
                    InterfaceType = outboundOrder.OrderType == 0 ? 1 : 3,
                    OrderId = outboundOrder.Id,
                    OrderNo = outboundOrder.OrderNo,
                    RequestCode = reqCode,
                    RequestData = requestData,
                    FailureReason = message,
                    LastReturnTime = DateTime.Now,
                    HttpStatusCode = httpResponseResult.StatusCode.ObjToInt(),
                    ResponseData = httpResponseResult.Content,
                    ReturnType = 0,
                    ReturnCount = 1,
                    ReturnStatus = isSuccess ? 1 : 2,
                    SuccessTime = isSuccess ? DateTime.Now : null
                };
                _unitOfWorkManage.BeginTran();
                _unitOfWorkManage.Db.Insertable(mesReturnRecord).ExecuteCommand();
                List<Dt_OutboundOrderDetail> outboundOrderDetails = outboundOrder.Details.Where(x => lineNos.Contains(x.lineNo)).ToList();
                outboundOrderDetails.ForEach(x =>
                {
                    if (x.OverOutQuantity == x.OrderQuantity - x.MoveQty)
                    {
                        x.ReturnToMESStatus = isSuccess ? 1 : 2;
                    }
                    else
                    {
                        x.ReturnToMESStatus = isSuccess ? 3 : 4;
                    }
                    x.CurrentDeliveryQty = 0;
                    x.ReturnJsonData = "";
                });
                mesReturnRecord.ReturnType = outboundOrder.Details.Count == outboundOrderDetails.Count ? 1 : 2;
                if (outboundOrder.Details.Count == outboundOrderDetails.Count && outboundOrderDetails.All(x => x.ReturnToMESStatus == 1 || x.ReturnToMESStatus == 2))
                {
                    outboundOrder.ReturnToMESStatus = isSuccess ? 1 : 2;
                }
                else
                {
                    outboundOrder.ReturnToMESStatus = isSuccess ? 3 : 4;
                }
                _outboundOrderService.Db.Updateable(outboundOrderDetails).ExecuteCommand();
                _outboundOrderService.UpdateData(outboundOrder);
                _unitOfWorkManage.CommitTran();
                try
                {
                    _locationStatusChangeRecordService.AddLocationStatusChangeRecord(locationInfo, beforelocationStatus, StockChangeType.Inbound.ObjToInt(), "", task.TaskNum);