| | |
| | | using HslCommunication; |
| | | using MailKit.Search; |
| | | using Newtonsoft.Json; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Reflection.Metadata; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using SqlSugar; |
| | | using WIDESEA_Common; |
| | | using WIDESEA_Common.OrderEnum; |
| | | using WIDESEA_Common.StockEnum; |
| | | using WIDESEA_Common.TaskEnum; |
| | |
| | | private readonly ICabinOrderServices _cabinOrderServices; |
| | | private readonly IDeliveryOrderServices _deliveryOrderServices; |
| | | private readonly ISupplyTaskService _supplyTaskService; |
| | | public InventoryServices(IRepository<Dt_Inventory> BaseDal, ICabinOrderServices cabinOrderServices, IDeliveryOrderServices deliveryOrderServices, ISupplyTaskService supplyTaskService) : base(BaseDal) |
| | | private readonly IInventory_BatchServices _inventoryBatchServices; |
| | | private readonly IMessageInfoService _infoService; |
| | | public InventoryServices(IRepository<Dt_Inventory> BaseDal, ICabinOrderServices cabinOrderServices, IDeliveryOrderServices deliveryOrderServices, ISupplyTaskService supplyTaskService, IInventory_BatchServices inventoryBatchServices, IMessageInfoService infoService) : base(BaseDal) |
| | | { |
| | | _cabinOrderServices = cabinOrderServices; |
| | | _deliveryOrderServices = deliveryOrderServices; |
| | | _supplyTaskService = supplyTaskService; |
| | | _inventoryBatchServices = inventoryBatchServices; |
| | | _infoService = infoService; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <param name="batch_num">æ¹å·</param> |
| | | /// <returns></returns> |
| | | /// <exception cref="NotImplementedException"></exception> |
| | | public WebResponseContent GetInventoryList(string goods_no, string batch_num) |
| | | public WebResponseContent GetInventoryList(int[] keys) |
| | | { |
| | | var responseContent = new WebResponseContent(); |
| | | try |
| | | { |
| | | var url = "http://121.37.118.63/GYZ2/95fck/repositoryInfo"; |
| | | var result = HttpHelper.Post(url, new { goods_no, batch_num }.ToJsonString()); |
| | | //æ ¹æ®idæ¥è¯¢åºåæ¹æ¬¡ä¿¡æ¯è¡¨ï¼è·åå°ä»ä»¬çååç¼ç åæ¹æ¬¡å· |
| | | var inventoryBatches = _inventoryBatchServices.Repository.QueryData(x => keys.Contains(x.Id)); //æ¥å
¨é¨ |
| | | |
| | | var response = JsonConvert.DeserializeObject<UpstreamResponse<InventoryInfo>>(result); |
| | | |
| | | if (response.resultCode != "0") |
| | | var url = "http://121.37.118.63:80/GYZ2/95fck/repositoryInfo"; |
| | | foreach (var item in inventoryBatches) |
| | | { |
| | | //SendErrorToUpstream(8, "", response.resultMsg ?? "䏿¸¸æ¥å£è¿å失败", ""); |
| | | return responseContent.Error(response.resultMsg ?? "䏿¸¸æ¥å£è¿å失败"); |
| | | } |
| | | var result = HttpHelper.Post(url, new { goods_no = item.MaterielCode, batch_num = item.BatchNo }.ToJsonString()); |
| | | |
| | | if (response.data == null || !response.data.Any()) |
| | | { |
| | | return responseContent.OK("æ æ°åºåæ°æ®"); |
| | | var response = JsonConvert.DeserializeObject<UpstreamResponse<InventoryInfo>>(result); |
| | | if (response == null) continue; |
| | | var data = response.data.FirstOrDefault(); |
| | | if (data != null) |
| | | item.ERPStockQuantity = data.business_qty; |
| | | } |
| | | |
| | | Db.Ado.BeginTran(); |
| | | foreach (var item in response.data) |
| | | { |
| | | // ä½¿ç¨ FirstOrDefault é¿å
æ¾ä¸å°è®°å½æ¶æåºå¼å¸¸ |
| | | var Inver = Db.Queryable<Dt_Inventory_Batch>() |
| | | .First(x => x.MaterielCode == item.goods_no && x.BatchNo == item.batch_num); |
| | | |
| | | if (Inver != null) |
| | | { |
| | | Inver.ERPStockQuantity = item.business_qty; |
| | | Db.Updateable(Inver).ExecuteCommand(); |
| | | } |
| | | } |
| | | Db.Ado.CommitTran(); |
| | | _inventoryBatchServices.UpdateData(inventoryBatches); |
| | | return responseContent.OK("åºåä¿¡æ¯åæ¥å®æ"); |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Db.Ado.RollbackTran(); |
| | | //SendErrorToUpstream(8, "", ex.Message, ""); |
| | | return responseContent.Error("åæ¥å¤±è´¥: " + ex.Message); |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// ä¸è®ºæ¯åºåºå
¥åºçç¹ï¼wcsé½ä¼è°ç¨æè¿ä¸ªæ¹æ³ |
| | | /// </summary> |
| | | /// <param name="request"></param> |
| | | /// <returns></returns> |
| | | |
| | | public ApiResponse<Dt_InventoryInfo> OrderFeedback(EdiOrderCallbackRequest request) |
| | | { |
| | | try |