| | |
| | | using Microsoft.AspNetCore.Mvc; |
| | | using Microsoft.Extensions.Logging; |
| | | using Newtonsoft.Json; |
| | | using Newtonsoft.Json.Serialization; |
| | | using Org.BouncyCastle.Asn1.Ocsp; |
| | | using Org.BouncyCastle.Asn1.Pkcs; |
| | | using SqlSugar; |
| | |
| | | { |
| | | return content.Error("æªæ¾å°å
¥æºä»çç©æä¿¡æ¯"); |
| | | } |
| | | |
| | | string Operator = allocateMaterialInfos.FirstOrDefault().Creater; |
| | | |
| | | _unitOfWorkManage.BeginTran(); |
| | | var alldelete = _allocateMaterialInfo.DeleteAndMoveIntoHty(allocateMaterialInfos ,OperateTypeEnum.èªå¨å é¤); |
| | | if (!alldelete) |
| | |
| | | } |
| | | 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) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°å¯¹åºçè°æ¨å"); |
| | | } |
| | | AllocationReturnDTO? returnDTO = BuildAllocationFeedbackData(outboundOrder, allocateOrder.FromWarehouse, allocateOrder.ToWarehouse); |
| | | AllocationReturnDTO? returnDTO = BuildAllocationFeedbackData(outboundOrder, allocateOrder.FromWarehouse, allocateOrder.ToWarehouse, Operator); |
| | | if (returnDTO == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æå»ºåè°å¯¹è±¡å¤±è´¥"); |
| | |
| | | string apiUrl = AppSettings.GetValue("AllocationFeedbackUrl"); ; |
| | | returnDTO.ReqCode = reqCode; |
| | | returnDTO.ReqTime = reqTime; |
| | | requestData = returnDTO.Serialize(); |
| | | JsonSerializerSettings settings = new JsonSerializerSettings |
| | | { |
| | | ContractResolver = new CamelCasePropertyNamesContractResolver() |
| | | }; |
| | | requestData = JsonConvert.SerializeObject(returnDTO, settings); |
| | | lineNos = returnDTO.Details.Select(x => x.LineNo).ToList(); |
| | | 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æ¥å£è¿åé误ï¼HTTP代ç ï¼{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); |
| | |
| | | } |
| | | } |
| | | |
| | | public AllocationReturnDTO? BuildAllocationFeedbackData(Dt_OutboundOrder outboundOrder, string fromWarehouse, string toWarehouse) |
| | | public AllocationReturnDTO? BuildAllocationFeedbackData(Dt_OutboundOrder outboundOrder, string fromWarehouse, string toWarehouse,string Operator) |
| | | { |
| | | try |
| | | { |
| | |
| | | Details = returnDetails, |
| | | FactoryArea = outboundOrder.FactoryArea, |
| | | OperationType = 1, |
| | | OrderNo = outboundOrder.OrderNo, |
| | | OrderNo = outboundOrder.UpperOrderNo, |
| | | FromWarehouse = fromWarehouse, |
| | | ToWarehouse = toWarehouse |
| | | ToWarehouse = toWarehouse, |
| | | Operator = Operator |
| | | }; |
| | | |
| | | return outboundReturnDTO; |
| | |
| | | } |
| | | } |
| | | |
| | | public Task<WebResponseContent> HandCompleteTask(string TaskNum) |
| | | { |
| | | return TaskCompleted(TaskNum); |
| | | } |
| | | |
| | | } |
| | | } |