From 4fa1bd862843ee6b1f68650a6911cb08f89b74da Mon Sep 17 00:00:00 2001
From: yanjinhui <3306209981@qq.com>
Date: 星期五, 17 十月 2025 12:08:00 +0800
Subject: [PATCH] 修改出入库
---
新建文件夹/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/DeliveryOrderServices.cs | 732 +++++++++++++++++++++++++++----------------------------
1 files changed, 359 insertions(+), 373 deletions(-)
diff --git "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/DeliveryOrderServices.cs" "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/DeliveryOrderServices.cs"
index 14d643e..b0801af 100644
--- "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/DeliveryOrderServices.cs"
+++ "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/DeliveryOrderServices.cs"
@@ -5,6 +5,7 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using WIDESEA_Common;
using WIDESEA_Common.LocationEnum;
using WIDESEA_Common.OrderEnum;
using WIDESEA_Common.TaskEnum;
@@ -449,6 +450,313 @@
}
}
+ /// <summary>
+ /// 杩囨护娌℃湁瀵瑰晢鍝佽繘琛岀淮鎶ょ殑鍑哄簱鍗曡繘琛岃繃婊�
+ /// </summary>
+ /// <returns></returns>
+ public WebResponseContent GetUpstreamOutOrder2()
+ {
+ var responseContent = new WebResponseContent();
+ try
+ {
+ var url = "http://121.37.118.63:80/GYZ2/95fck/outOrder";
+
+ var requestData = new
+ {
+ searchDate = "2022-10-10 20:45:16"
+ };
+
+ var result = HttpHelper.Post(url, requestData.ToJsonString());
+ var response = JsonConvert.DeserializeObject<UpstreamResponse<UpstramOutOrderInfo>>(result);
+
+ if (response.resultCode != "0")
+ {
+ SendErrorToUpstream(3, "", response.resultMsg ?? "涓婃父鎺ュ彛杩斿洖澶辫触", "");
+ return responseContent.Error(response.resultMsg ?? "涓婃父鎺ュ彛杩斿洖澶辫触");
+ }
+
+ if (response.data == null || !response.data.Any())
+ {
+ return responseContent.OK("鏃犳柊鍑哄簱鍗曟暟鎹�");
+ }
+
+ // 宸插瓨鍦ㄥ嚭搴撳崟鍙�
+ var existingOutOrderNos = BaseDal.Db.Queryable<Dt_DeliveryOrder>()
+ .Select(x => x.Out_no)
+ .ToList();
+
+ // 鏂板嚭搴撳崟
+ var newOutOrders = response.data
+ .Where(outorder => !existingOutOrderNos.Contains(outorder.order_no))
+ .ToList();
+
+ if (!newOutOrders.Any())
+ {
+ return responseContent.OK("鎵�鏈夊嚭搴撳崟宸插瓨鍦紝鏃犻渶鏂板");
+ }
+
+ Db.Ado.BeginTran();
+ try
+ {
+ List<Dt_DeliveryOrder> _DeliveryOrders = new List<Dt_DeliveryOrder>();
+ List<string> orderNos = new();
+
+ foreach (var outorder in newOutOrders)
+ {
+
+ bool skipOrder = false; // 鏍囪鏄惁璺宠繃璇ュ叆搴撳崟
+ var entityOrder = new Dt_DeliveryOrder
+ {
+ Out_no = outorder.order_no,
+ Out_type = outorder.order_type,
+ Client_no = outorder.client_no,
+ Client_name = outorder.client_name,
+ Account_time = outorder.account_time,
+ Warehouse_no = outorder.warehouse_no,
+ OutStatus = "鏈畬鎴�",
+ Details = new List<Dt_DeliveryOrderDetail>()
+ };
+
+ // 閬嶅巻鍑哄簱鏄庣粏
+ foreach (var item in outorder.details)
+ {
+ // 1锔忊儯 杞负姝f暟锛堜笂娓稿彲鑳戒紶璐熸暟锛�
+ item.order_qty = Math.Abs(item.order_qty);
+ decimal orderQty = (decimal)item.order_qty;
+
+ // 2锔忊儯 鏌ョ墿鏂欏熀纭�淇℃伅锛堣幏鍙栫瑙勶級
+ var medication = BaseDal.Db.Queryable<Dt_MedicineGoods>()
+ .Where(m => m.Goods_no == item.goods_no)
+ .First();
+ //濡傛灉鐗╂枡淇℃伅涓嶅瓨鍦紝璺宠繃鏁翠釜鍏ュ簱鍗�
+ if (medication == null)
+ {
+ skipOrder = true;
+ Console.WriteLine($"璺宠繃鍏ュ簱鍗� {outorder.order_no}锛屽師鍥狅細鏈壘鍒板晢鍝� [{item.goods_no}] 鐨勭墿鏂欎俊鎭��");
+ break;
+ }
+
+
+ // 鑻ョ墿鏂欎笉瀛樺湪鎴� MaterielSourceType 涓虹┖锛屽垯璺宠繃鏁翠釜鍑哄簱鍗�
+ if (medication == null || !Enum.IsDefined(typeof(MaterielSourceTypeEnum), medication.MaterielSourceType))
+ {
+ skipOrder = true;
+ break;
+ }
+
+ if (medication == null)
+ {
+ SendErrorToUpstream(3, "", $"鎵句笉鍒扮墿鏂欎俊鎭細{item.goods_no}", "");
+ continue;
+ }
+
+ decimal boxQty = medication.BoxQty <= 0 ? 1 : medication.BoxQty;
+
+ // 3锔忊儯 璁$畻鏁翠欢涓庢暎浠舵暟閲�
+ var fullBoxes = (int)(orderQty / boxQty); // 鏁翠欢绠辨暟
+ var partialQty = orderQty % boxQty; // 鏁d欢鏁伴噺
+
+ // 鑻ヤ笂娓哥粰浜嗘壒娆″彿锛屽垯浼樺厛鍖归厤
+ string requestedBatch = string.IsNullOrEmpty(item.batch_num) ? null : item.batch_num;
+
+ // helper: 鏌ヨ搴撳瓨鍑芥暟锛堟寜鍏ュ簱鏃堕棿鍗囧簭锛�
+ // 瀹氫箟涓�涓鎵樺彉閲忥細杈撳叆int鍙傛暟锛岃繑鍥濴ist<Dt_InventoryInfo>
+ Func<int, List<Dt_InventoryInfo>> queryInventoryByStockStatus = (stockStatus) =>
+ {
+ // 1. 鍒涘缓鍩虹鏌ヨ
+ var q = BaseDal.Db.Queryable<Dt_InventoryInfo>()
+ .Where(i => i.MaterielCode == item.goods_no && // 鐗╂枡缂栧彿鍖归厤
+ (i.StockQuantity - i.OutboundQuantity) > 0 && // 鍙敤搴撳瓨>0
+ i.StockStatus == stockStatus); // 搴撳瓨鐘舵�佸尮閰�
+
+ // 2. 鏉′欢绛涢�夛紙濡傛灉鏈夋壒娆″彿瑕佹眰锛�
+ if (!string.IsNullOrEmpty(requestedBatch))
+ q = q.Where(i => i.BatchNo == requestedBatch);
+
+ // 3. 鎵ц鏌ヨ骞惰繑鍥炵粨鏋�
+ return q.OrderBy(i => i.InDate).ToList(); // 鎸夊叆搴撴椂闂存帓搴�
+ };
+ // 4锔忊儯鍒嗛厤鏁d欢锛堜紭鍏堢珛搴� Status=0锛�
+ decimal remainingPartial = partialQty;
+ if (remainingPartial > 0)
+ {
+ var invList_ly = queryInventoryByStockStatus(0);
+ foreach (var inv in invList_ly)
+ {
+ if (remainingPartial <= 0) break;
+
+ decimal available = (decimal)(inv.StockQuantity - inv.OutboundQuantity);
+ if (available <= 0) continue;
+
+ decimal use = Math.Min(available, remainingPartial);
+
+ var detail = new Dt_DeliveryOrderDetail
+ {
+ Goods_no = item.goods_no,
+ Order_qty = use,
+ Batch_num = inv.BatchNo,
+ Exp_date = inv.ValidityPeriod,
+ OotDetailStatus = "鏂板缓",
+ Status = 0, //绔嬪簱
+ Reservoirarea = inv.LocationCode
+ };
+ entityOrder.Details.Add(detail);
+
+ inv.OutboundQuantity += (float)use;
+ BaseDal.Db.Updateable(inv).ExecuteCommand();
+
+ remainingPartial -= use;
+ }
+
+ // 绔嬪簱涓嶅 鈫� 骞冲簱琛� (Status=2)
+ if (remainingPartial > 0)
+ {
+ var invList_pk = queryInventoryByStockStatus(2);
+ foreach (var inv in invList_pk)
+ {
+ if (remainingPartial <= 0) break;
+
+ decimal available = (decimal)(inv.StockQuantity - inv.OutboundQuantity);
+ if (available <= 0) continue;
+
+ decimal use = Math.Min(available, remainingPartial);
+
+ var detail = new Dt_DeliveryOrderDetail
+ {
+ Goods_no = item.goods_no,
+ Order_qty = use,
+ Batch_num = inv.BatchNo,
+ Exp_date = inv.ValidityPeriod,
+ OotDetailStatus = "鏂板缓",
+ Status = 2, //骞冲簱
+ Reservoirarea = inv.LocationCode
+ };
+ entityOrder.Details.Add(detail);
+
+ inv.OutboundQuantity += (float)use;
+ BaseDal.Db.Updateable(inv).ExecuteCommand();
+
+ remainingPartial -= use;
+ }
+ }
+
+ if (remainingPartial > 0)
+ {
+ SendErrorToUpstream(3, "", $"鍑哄簱鍗昜{outorder.order_no}]鐗╂枡[{item.goods_no}]鏁d欢搴撳瓨涓嶈冻锛屾湭鍒嗛厤锛歿remainingPartial}", "");
+ }
+ }
+
+ //鍒嗛厤鏁翠欢锛堜紭鍏堝钩搴� Status=2锛�
+ int remainingFullBoxes = fullBoxes;
+ if (remainingFullBoxes > 0)
+ {
+ var invList_pk = queryInventoryByStockStatus(2);
+ foreach (var inv in invList_pk)
+ {
+ if (remainingFullBoxes <= 0) break;
+
+ decimal available = (decimal)(inv.StockQuantity - inv.OutboundQuantity);
+ if (available < boxQty) continue;
+
+ int canProvideBoxes = (int)(available / boxQty);
+ if (canProvideBoxes <= 0) continue;
+
+ int useBoxes = Math.Min(canProvideBoxes, remainingFullBoxes);
+ decimal useQty = useBoxes * boxQty;
+
+ var detail = new Dt_DeliveryOrderDetail
+ {
+ Goods_no = item.goods_no,
+ Order_qty = useQty,
+ Batch_num = inv.BatchNo,
+ Exp_date = inv.ValidityPeriod,
+ OotDetailStatus = "鏂板缓",
+ Status = 2, //骞冲簱
+ Reservoirarea = inv.LocationCode
+ };
+ entityOrder.Details.Add(detail);
+
+ inv.OutboundQuantity += (float)useQty;
+ BaseDal.Db.Updateable(inv).ExecuteCommand();
+
+ remainingFullBoxes -= useBoxes;
+ }
+
+ // 骞冲簱涓嶅 鈫� 绔嬪簱琛� (Status=1)
+ if (remainingFullBoxes > 0)
+ {
+ var invList_ly = queryInventoryByStockStatus(1);
+ foreach (var inv in invList_ly)
+ {
+ if (remainingFullBoxes <= 0) break;
+
+ decimal available = (decimal)(inv.StockQuantity - inv.OutboundQuantity);
+ if (available < boxQty) continue;
+
+ int canProvideBoxes = (int)(available / boxQty);
+ if (canProvideBoxes <= 0) continue;
+
+ int useBoxes = Math.Min(canProvideBoxes, remainingFullBoxes);
+ decimal useQty = useBoxes * boxQty;
+
+ var detail = new Dt_DeliveryOrderDetail
+ {
+ Goods_no = item.goods_no,
+ Order_qty = useQty,
+ Batch_num = inv.BatchNo,
+ Exp_date = inv.ValidityPeriod,
+ OotDetailStatus = "鏂板缓",
+ Status = 0, //绔嬪簱锛堣ˉ鏁寸锛�
+ Reservoirarea = inv.LocationCode
+ };
+ entityOrder.Details.Add(detail);
+
+ inv.OutboundQuantity += (float)useQty;
+ BaseDal.Db.Updateable(inv).ExecuteCommand();
+
+ remainingFullBoxes -= useBoxes;
+ }
+ }
+ // 鉂楀鏋滆烦杩囪鍗曪紝鍒欑洿鎺ontinue锛屼笉淇濆瓨
+ if (skipOrder)
+ {
+ Console.WriteLine($"璺宠繃鍏ュ簱鍗� {outorder.order_no}锛屽洜涓哄瓨鍦ㄦ湭瀹氫箟鐗╂枡灞炴�х殑鍟嗗搧銆�");
+ continue;
+ }
+
+ if (remainingFullBoxes > 0)
+ {
+ decimal unfilledQty = remainingFullBoxes * boxQty;
+ SendErrorToUpstream(3, "", $"鍑哄簱鍗昜{outorder.order_no}]鐗╂枡[{item.goods_no}]鏁寸搴撳瓨涓嶈冻锛屾湭鍒嗛厤鏁伴噺锛歿unfilledQty}", "");
+ }
+
+ }
+ }
+
+ _DeliveryOrders.Add(entityOrder);
+ }
+
+ // 鎻掑叆涓昏〃+鏄庣粏
+ BaseDal.Db.InsertNav(_DeliveryOrders)
+ .Include(x => x.Details)
+ .ExecuteCommand();
+
+ Db.Ado.CommitTran();
+ return responseContent.OK("鍚屾鍑哄簱鍗曟垚鍔�");
+ }
+ catch (Exception ex)
+ {
+ Db.Ado.RollbackTran();
+ SendErrorToUpstream(3, "", ex.Message, "");
+ return responseContent.Error("鍚屾澶辫触: " + ex.Message);
+ }
+ }
+ catch (Exception ex)
+ {
+ SendErrorToUpstream(3, "", ex.Message, "");
+ return responseContent.Error("鍚屾澶辫触: " + ex.Message);
+ }
+ }
/// <summary>
/// 鍑哄簱鍗曟帹閫佺粰 WCS
@@ -559,221 +867,67 @@
}
- /// <summary>
- /// 鍑哄簱鎶ュ畬鎴愭帴鍙�
- /// </summary>
- /// <param name="out_no">鍑哄簱鍗曞彿</param>
- /// <returns></returns>
- //public WebResponseContent CompleteOutOrder(string out_no)
- //{
- // var responseContent = new WebResponseContent();
- // try
- // {
- // if (string.IsNullOrWhiteSpace(out_no))
- // {
- // return responseContent.Error("鍏ュ簱鍗曞彿涓嶅彲浠ヤ负绌�");
- // }
-
- // Db.Ado.BeginTran();
- // //鍏堟煡澶磋〃
- // var outOerd= BaseDal.Db.Queryable<Dt_DeliveryOrder>()
- // .Where(o => o.Out_no == out_no)
- // .First();
- // if (outOerd == null)
- // {
- // return responseContent.Error($"娌℃湁鎵惧埌璇ュ嚭搴撳崟鍙穥out_no}");
- // }
- // //鏌ユ壘鎵�鏈夋槑缁嗚〃鏄惁閮藉凡瀹屾垚
- // var incompleteDetails = BaseDal.Db.Queryable<Dt_DeliveryOrderDetail>()
- // .Where(d => d.DeliveryOrderId == outOerd.Id && d.OotDetailStatus == "宸插畬鎴�")
- // .Count();
- // if (incompleteDetails>0)
- // {
- // // 鏇存柊鍑哄簱鍗曠姸鎬�
- // BaseDal.Db.Updateable<Dt_DeliveryOrder>()
- // .SetColumns(o => new Dt_DeliveryOrder { OutStatus = "寮�濮�" })
- // .Where(o => o.Out_no == out_no)
- // .ExecuteCommand();
- // var url = " http://127.0.0.1:9090/GYZ2/95fck/outOrderOk";
- // var reslut = HttpHelper.Post(url, new { out_no }.ToJsonString());
- // var response = JsonConvert.DeserializeObject<UpstreamOrderResponse>(reslut);
- // if (response.resultCode != "0")
- // {
- // SendErrorToUpstream(4, "", "涓婃父鎺ュ彛杩斿洖澶辫触", "");
- // return responseContent.Error(response.resultMsg ?? "涓婃父鎺ュ彛杩斿洖澶辫触");
- // }
- // Db.Ado.CommitTran();
- // return responseContent.OK("鎿嶄綔鎴愬姛,鍑哄簱鍗曚互鍙婃槑缁嗗叏閮ㄥ畬鎴�");
- // }
- // else
- // {
- // return responseContent.OK("鎿嶄綔鎴愬姛锛屼絾浠绘湁涓哄畬鎴愮殑鏄庣粏");
- // }
- // }
- // catch (Exception ex)
- // {
- // Db.Ado.RollbackTran();
- // SendErrorToUpstream(1, "", ex.Message, "");
- // return responseContent.Error("鍚屾澶辫触: " + ex.Message);
- // }
- //}
-
-
- /// <summary>
- ///鐩樼偣鍑哄簱鍗曟帹閫佺粰 WCS
- /// </summary>
- /// <param name="externalOrderNo">鍑哄簱鍗曞彿</param>
- /// <returns></returns>
- //public WebResponseContent InventoryGood(string externalOrderNo)
- //{
- // try
- // {
- // // 鏌ヨ鍑哄簱鍗曞強鏄庣粏
- // var orders = BaseDal.Db.CopyNew().Queryable<Dt_DeliveryOrder>()
- // .Where(x => x.Out_no == externalOrderNo)
- // .Includes(o => o.Details, d => d.MedicineGoods)
- // .ToList();
-
-
- // if (orders == null || orders.Count == 0)
- // {
- // return new WebResponseContent().Error("娌℃湁鎵惧埌璇ュ嚭搴撳崟");
- // }
-
- // var url = "http://172.16.1.2:9357/file-admin/api/out/ediOut";
- // bool allSuccess = true;
-
- // foreach (var order in orders)
- // {
- // //鏌ユ壘缁欏晢鍝佺殑搴撳瓨
- // var Invert = BaseDal.Db.Queryable<Dt_Inventory>()
- // .Where(i => i.Goods_no == order.Out_no).First();
- // var ediDto = new TowcsDto.ToediOutInfo
- // {
- // customerCode = "905",
- // materialCode = "YY",
- // externalOrderNo = order.Out_no,
- // outOrderType = "20", // 鐩樼偣鍑哄簱鍗�
- // priority = 1,
- // Is_cancel = 0,
- // details = order.Details.Select(d => new TowcsDto.ToeOutdiInDetail
- // {
- // batchNo = d.Batch_num,
- // productCode = d.Goods_no,
- // productName = d.MedicineGoods?.Goods_spm,
- // productSpecifications = d.MedicineGoods?.Model,
- // quantity = (int)d.Order_qty,
- // stocktakingDetails = new List<TowcsDto.ToOutediInStock>
- // {
- // new TowcsDto.ToOutediInStock
- // {
- // palletCode = Invert.PalletCode, // 瀹為檯浠庣郴缁熷彇
- // quantity = d.Order_qty.ToString()
- // }
- // }
- // }).ToList()
- // };
-
- // var result = HttpHelper.Post(url, ediDto.ToJsonString());
- // var resp = JsonConvert.DeserializeObject<TowcsDto.TowcsResponse<object>>(result);
-
- // if (resp == null || resp.code != "0")
- // {
- // allSuccess = false;
- // break;
- // }
- // }
-
- // return allSuccess
- // ? new WebResponseContent { Status = true, Message = "鐩樼偣鎴愬姛" }
- // : new WebResponseContent { Status = false, Message = "鐩樼偣澶辫触" };
- // }
- // catch (Exception ex)
- // {
- // return new WebResponseContent { Status = false, Message = ex.Message };
- // }
- //}
-
-
- public WebResponseContent InventoryGood(string externalOrderNo)
+ //鐩樼偣 鎷挎暣涓壒娆′俊鎭〃鐨勫晢鍝佹壒鍙峰拰鍟嗗搧缂栧彿鏉ヨ繘琛岀洏鐐�
+ public WebResponseContent InventoryGood(string batchNo, string goodsNo)
{
+ var response = new WebResponseContent();
try
{
- // 1. 鏌ュ嚭鍑哄簱鍗曞強鏄庣粏
- var orders = BaseDal.Db.CopyNew().Queryable<Dt_DeliveryOrder>()
- .Where(x => x.Out_no == externalOrderNo)
- .Includes(o => o.Details, d => d.MedicineGoods)
- .ToList();
+ // 1锔忊儯 鏌ユ壘鎸囧畾鎵规涓庣墿鏂欑殑搴撳瓨淇℃伅
+ var batchInfo = BaseDal.Db.Queryable<Dt_Inventory_Batch>()
+ .Where(x => x.BatchNo == batchNo && x.MaterielCode == goodsNo)
+ .First();
- if (orders == null || orders.Count == 0)
- return new WebResponseContent().Error("娌℃湁鎵惧埌璇ュ嚭搴撳崟");
+ if (batchInfo == null)
+ return response.Error($"鏈壘鍒拌鐗╂枡 [{goodsNo}] 鎵规 [{batchNo}] 鐨勫簱瀛樹俊鎭�");
- // 2. 鑾峰彇鎵�鏈夊晢鍝佺紪鍙�
- var allGoodsNos = orders
- .SelectMany(o => o.Details.Select(d => d.Goods_no))
- .Distinct()
- .ToList();
-
- // 3. 涓�娆℃�ф煡璇㈠簱瀛樹俊鎭�
- var inventoryList = BaseDal.Db.Queryable<Dt_Inventory>()
- .Where(i => allGoodsNos.Contains(i.Goods_no))
- .ToList();
-
- var inventoryDict = inventoryList.ToDictionary(i => i.Goods_no, i => i);
- string url = "http://172.16.1.2:9357/file-admin/api/out/ediOut";
- bool allSuccess = true;
-
- // 4. 鏋勯�犵洏鐐瑰嚭搴撹姹�
- foreach (var order in orders)
+ // 2锔忊儯 缁勮璇锋眰 DTO锛堝畬鍏ㄧ鍚堟帴鍙f枃妗g粨鏋勶級
+ var ediDto = new TowcsDto.ToediOutInfo
{
- var ediDto = new TowcsDto.ToediOutInfo
- {
- customerCode = "905",
- materialCode = "YY",
- externalOrderNo = order.Out_no,
- outOrderType = "20", // 鐩樼偣鍑哄簱鍗�
- priority = 1,
- Is_cancel = 0,
- details = order.Details.Select(d =>
- {
- inventoryDict.TryGetValue(d.Goods_no, out var invert);
-
- return new TowcsDto.ToeOutdiInDetail
- {
- batchNo = d.Batch_num,
- productCode = d.Goods_no,
- productName = d.MedicineGoods?.Goods_spm,
- productSpecifications = d.MedicineGoods?.Model,
- quantity = (int)d.Order_qty,
- stocktakingDetails = new List<TowcsDto.ToOutediInStock>
- {
- new TowcsDto.ToOutediInStock
- {
- palletCode = invert?.PalletCode ?? string.Empty,
- quantity = d.Order_qty.ToString()
- }
- }
- };
- }).ToList()
- };
-
- var result = HttpHelper.Post(url, ediDto.ToJsonString());
- var resp = JsonConvert.DeserializeObject<TowcsDto.TowcsResponse<object>>(result);
-
- if (resp == null || resp.code != "0")
- {
- allSuccess = false;
- break;
- }
+ customerCode = "905",
+ materialCode = "YY", // 鐗╂枡绫诲瀷CODE
+ externalOrderNo = $"PDCK-{batchInfo.Id}", // 澶栭儴鍑哄簱鍗曞彿
+ outOrderType = "20", // 鐩樼偣鍑哄簱鍗�
+ priority = 1,
+ Is_cancel = 0,
+ details = new List<TowcsDto.ToeOutdiInDetail>
+ {
+ new TowcsDto.ToeOutdiInDetail
+ {
+ batchNo = batchInfo.BatchNo,
+ productCode = batchInfo.MaterielCode,
+ productName = batchInfo.MaterielName,
+ productSpecifications = batchInfo.MaterielSpec,
+ quantity = (int)batchInfo.SupplyQuantity,
+ //stocktakingDetails = new List<TowcsDto.ToOutediInStock>
+ //{
+ // // 鐩樼偣鏄庣粏鍙牴鎹疄闄呮墭鐩樻媶鍒嗭紱姝ゅ绀轰緥浠�1鏉�
+ // new TowcsDto.ToOutediInStock
+ // {
+ // palletCode = "FC00001",
+ // quantity = batchInfo.SupplyQuantity.ToString()
+ // }
+ //}
}
+ }
+ };
- return allSuccess
- ? new WebResponseContent { Status = true, Message = "鐩樼偣鎴愬姛" }
- : new WebResponseContent { Status = false, Message = "鐩樼偣澶辫触" };
+ // 3锔忊儯 璋冪敤鎺ュ彛
+ string url = "http://172.16.1.2:9357/file-admin/api/out/ediOut";
+ var result = HttpHelper.Post(url, ediDto.ToJsonString());
+ var resp = JsonConvert.DeserializeObject<TowcsDto.TowcsResponse<object>>(result);
+
+ // 4锔忊儯 鍝嶅簲澶勭悊
+ if (resp == null)
+ return response.Error("WCS 鏃犲搷搴�");
+ if (resp.code != "0")
+ return response.Error($"WCS杩斿洖澶辫触: {resp.msg}");
+
+ return response.OK("鐩樼偣鍑哄簱涓嬪彂鎴愬姛");
}
catch (Exception ex)
{
- return new WebResponseContent { Status = false, Message = ex.Message };
+ return response.Error("鐩樼偣澶辫触锛�" + ex.Message);
}
}
@@ -918,175 +1072,7 @@
}
- //public WebResponseContent CompleteAllOutOrders()
- //{
- // var responseContent = new WebResponseContent();
- // try
- // {
- // var orders = BaseDal.Db.Queryable<Dt_DeliveryOrder>()
- // .Where(o => o.OutStatus == "寮�濮�")
- // .ToList();
-
- // if (orders == null || !orders.Any())
- // {
- // return responseContent.OK("鏆傛棤闇�瑕佸鐞嗙殑鍑哄簱鍗�");
- // }
-
- // int successCount = 0;
- // int failCount = 0;
- // int serverErrorCount = 0;
-
- // foreach (var order in orders)
- // {
- // try
- // {
- // Db.Ado.BeginTran();
-
- // var details = BaseDal.Db.Queryable<Dt_DeliveryOrderDetail>()
- // .Where(d => d.DeliveryOrderId == order.Id)
- // .ToList();
-
- // var completedCount = details.Count(d => d.OotDetailStatus == "宸插畬鎴�");
- // var totalCount = details.Count;
-
- // if (totalCount > 0 && completedCount == totalCount)
- // {
- // // 鏇存柊鐘舵�佷负宸插畬鎴�
- // BaseDal.Db.Updateable<Dt_DeliveryOrder>()
- // .SetColumns(o => o.OutStatus == "宸插畬鎴�")
- // .Where(o => o.Id == order.Id)
- // .ExecuteCommand();
-
- // // 璋冪敤涓婃父鎺ュ彛
- // var url = "http://121.37.118.63:80/GYZ2/95fck/outOrderOk";
- // var requestDate = new
- // {
- // order_no = order.Out_no
- // };
-
- // string result;
- // try
- // {
- // result = HttpHelper.Post(url, requestDate.ToJsonString());
- // }
- // catch (Exception httpEx)
- // {
- // // HTTP璇锋眰寮傚父锛堢綉缁滈棶棰樼瓑锛�
- // Db.Ado.RollbackTran();
- // failCount++;
- // SendErrorToUpstream(3, "", $"缃戠粶璇锋眰澶辫触: {httpEx.Message}", order.Out_no);
- // continue;
- // }
-
- // // 鉁� 妫�鏌ユ槸鍚︽槸500閿欒椤甸潰
- // if (!string.IsNullOrEmpty(result) && result.Contains("500閿欒椤甸潰"))
- // {
- // Db.Ado.RollbackTran();
- // serverErrorCount++;
- // SendErrorToUpstream(5, "", "涓婃父鎺ュ彛鏈嶅姟鍣ㄥ唴閮ㄩ敊璇�(500)锛岃鑱旂郴涓婃父绯荤粺绠$悊鍛�", order.Out_no);
- // continue;
- // }
-
- // // 鉁� 妫�鏌ユ槸鍚︽槸HTML鍝嶅簲
- // if (!string.IsNullOrEmpty(result) && result.Trim().StartsWith("<"))
- // {
- // Db.Ado.RollbackTran();
- // failCount++;
- // SendErrorToUpstream(4, "", "涓婃父鎺ュ彛杩斿洖闈濲SON鏍煎紡鍝嶅簲", order.Out_no);
- // continue;
- // }
-
- // // 鉁� 瀹夊叏瑙f瀽JSON
- // UpstreamOrderResponse response;
- // try
- // {
- // response = JsonConvert.DeserializeObject<UpstreamOrderResponse>(result);
- // }
- // catch (JsonReaderException jsonEx)
- // {
- // Db.Ado.RollbackTran();
- // failCount++;
- // SendErrorToUpstream(4, "", $"涓婃父鎺ュ彛杩斿洖鏁版嵁鏍煎紡閿欒: {jsonEx.Message}", order.Out_no);
- // continue;
- // }
-
- // if (response.resultCode == "0")
- // {
- // // 鎴愬姛澶勭悊閫昏緫...
- // var orderHistory = new Dt_DeliveryOrder_Hty
- // {
- // Id = order.Id,
- // Out_no = order.Out_no,
- // Out_type = order.Out_type,
- // Client_no = order.Client_no,
- // Client_name = order.Client_name,
- // Account_time = order.Account_time,
- // Warehouse_no = order.Warehouse_no,
- // OutStatus = "宸插畬鎴�",
- // Details = details.Select(d => new Dt_DeliveryOrderDetail
- // {
- // Id = d.Id,
- // DeliveryOrderId = d.DeliveryOrderId,
- // Reservoirarea = d.Reservoirarea,
- // Goods_no = d.Goods_no,
- // Order_qty = d.Order_qty,
- // Batch_num = d.Batch_num,
- // Exp_date = d.Exp_date,
- // OotDetailStatus = d.OotDetailStatus,
- // Status = d.Status
- // }).ToList()
- // };
-
- // var historyId = BaseDal.Db.Insertable(orderHistory).ExecuteReturnIdentity();
-
- // var detailHistories = details.Select(d => new Dt_DeliveryOrderDetail_Hty
- // {
- // Id = d.Id,
- // DeliveryOrderId = order.Id,
- // Reservoirarea = d.Reservoirarea,
- // Goods_no = d.Goods_no,
- // Order_qty = d.Order_qty,
- // Batch_num = d.Batch_num,
- // Exp_date = d.Exp_date,
- // OotDetailStatus = d.OotDetailStatus,
- // Status = d.Status
- // }).ToList();
-
- // BaseDal.Db.Insertable(detailHistories).ExecuteCommand();
-
- // BaseDal.Db.Deleteable<Dt_DeliveryOrderDetail>().Where(d => d.DeliveryOrderId == order.Id).ExecuteCommand();
- // BaseDal.Db.Deleteable<Dt_DeliveryOrder>().Where(o => o.Id == order.Id).ExecuteCommand();
-
- // Db.Ado.CommitTran();
- // successCount++;
- // }
- // else
- // {
- // Db.Ado.RollbackTran();
- // failCount++;
- // SendErrorToUpstream(4, "", $"涓婃父鎺ュ彛杩斿洖澶辫触: {response.resultMsg}", order.Out_no);
- // }
- // }
- // else
- // {
- // Db.Ado.RollbackTran();
- // }
- // }
- // catch (Exception ex)
- // {
- // Db.Ado.RollbackTran();
- // failCount++;
- // SendErrorToUpstream(1, "", ex.Message, order.Out_no);
- // }
- // }
-
- // return responseContent.OK($"鎵归噺澶勭悊瀹屾垚锛氭垚鍔� {successCount} 鍗曪紝澶辫触 {failCount} 鍗曪紝鏈嶅姟鍣ㄩ敊璇� {serverErrorCount} 鍗曘��");
- // }
- // catch (Exception ex)
- // {
- // return responseContent.Error("鎵归噺澶勭悊澶辫触锛�" + ex.Message);
- // }
- //}
+
/// <summary>
/// 鎺ㄩ�佸紓甯镐俊鎭粰涓婃父绯荤粺 1.鍏ュ簱鍗曟帴鍙o紱2.鍏ュ簱鍗曟姤瀹屾垚鎺ュ彛锛�3.鍑哄簱鍗曟帴鍙o紱4.鍑哄簱鎶ュ畬鎴愭帴鍙o紱5.鑽搧鍩虹淇℃伅鍚屾鎺ュ彛锛�6.渚涘簲鍟嗕俊鎭帴鍙o紱7.瀹㈡埛淇℃伅鎺ュ彛锛�8.搴撳瓨鏌ヨ鎺ュ彛
--
Gitblit v1.9.3