From fc8ec59582b334316650eb5a76349b0fbaab829a Mon Sep 17 00:00:00 2001
From: yanjinhui <3306209981@qq.com>
Date: 星期五, 17 十月 2025 10:48:39 +0800
Subject: [PATCH] 优化入库和出库单逻辑
---
新建文件夹/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.12.38.29086/CodeChunks.db-shm | 0
新建文件夹/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.12.38.29086/SemanticSymbols.db-wal | 0
新建文件夹/WIDESEA_WMSServer/WIDESEA_ISquareCabinServices/ICabinOrderServices.cs | 5
新建文件夹/WIDESEA_WMSServer/WIDESEA_WMSServer/appsettings.json | 2
新建文件夹/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.12.38.29086/SemanticSymbols.db-shm | 0
新建文件夹/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.12.38.29086/CodeChunks.db-wal | 0
新建文件夹/WIDESEA_WMSServer/WIDESEA_ISquareCabinServices/IDeliveryOrderServices.cs | 1
新建文件夹/WIDESEA_WMSServer/WIDESEA_WMSServer/OutOrderJob.cs | 2
新建文件夹/WIDESEA_WMSServer/WIDESEA_WMSServer/GoodsJob.cs | 2
新建文件夹/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.12.38.29086/CodeChunks.db | 0
新建文件夹/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/DeliveryOrderServices.cs | 725 +++++++++++++++++++--------------------
新建文件夹/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/CabinOrderServices.cs | 306 +++++++++++-----
新建文件夹/WIDESEA_WMSServer/WIDESEA_Model/Models/SquareCabin/Dt_DeliveryOrderDetail_Hty.cs | 4
新建文件夹/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.12.38.29086/SemanticSymbols.db | 0
14 files changed, 572 insertions(+), 475 deletions(-)
diff --git "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.12.38.29086/CodeChunks.db" "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.12.38.29086/CodeChunks.db"
index ad50a8e..048cf8f 100644
--- "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.12.38.29086/CodeChunks.db"
+++ "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.12.38.29086/CodeChunks.db"
Binary files differ
diff --git "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.12.38.29086/CodeChunks.db-shm" "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.12.38.29086/CodeChunks.db-shm"
new file mode 100644
index 0000000..20debe0
--- /dev/null
+++ "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.12.38.29086/CodeChunks.db-shm"
Binary files differ
diff --git "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.12.38.29086/CodeChunks.db-wal" "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.12.38.29086/CodeChunks.db-wal"
new file mode 100644
index 0000000..b8e04e4
--- /dev/null
+++ "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.12.38.29086/CodeChunks.db-wal"
Binary files differ
diff --git "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.12.38.29086/SemanticSymbols.db" "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.12.38.29086/SemanticSymbols.db"
index 436a607..af6a815 100644
--- "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.12.38.29086/SemanticSymbols.db"
+++ "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.12.38.29086/SemanticSymbols.db"
Binary files differ
diff --git "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.12.38.29086/SemanticSymbols.db-shm" "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.12.38.29086/SemanticSymbols.db-shm"
index d72a8a5..dda9604 100644
--- "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.12.38.29086/SemanticSymbols.db-shm"
+++ "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.12.38.29086/SemanticSymbols.db-shm"
Binary files differ
diff --git "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.12.38.29086/SemanticSymbols.db-wal" "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.12.38.29086/SemanticSymbols.db-wal"
index d3b0b18..90af370 100644
--- "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.12.38.29086/SemanticSymbols.db-wal"
+++ "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.12.38.29086/SemanticSymbols.db-wal"
Binary files differ
diff --git "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_ISquareCabinServices/ICabinOrderServices.cs" "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_ISquareCabinServices/ICabinOrderServices.cs"
index 1da20f3..1104bc5 100644
--- "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_ISquareCabinServices/ICabinOrderServices.cs"
+++ "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_ISquareCabinServices/ICabinOrderServices.cs"
@@ -17,6 +17,8 @@
/// <returns></returns>
WebResponseContent GetUpstreamOrder();
+ WebResponseContent GetUpstreamOrder2();
+
/// <summary>
/// 鍏ュ簱鎶ュ畬鎴愭帴鍙�
@@ -32,6 +34,9 @@
/// </summary>
/// <returns></returns>
WebResponseContent EdiIn();
+
+
+
WebResponseContent GetCabinOrders(SaveModel saveModel);
WebResponseContent GetCabinOrderDetail(int pageNo, string orderNo);
WebResponseContent FeedbackIn(SaveModel saveModel);
diff --git "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_ISquareCabinServices/IDeliveryOrderServices.cs" "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_ISquareCabinServices/IDeliveryOrderServices.cs"
index d5c3e40..97b1548 100644
--- "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_ISquareCabinServices/IDeliveryOrderServices.cs"
+++ "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_ISquareCabinServices/IDeliveryOrderServices.cs"
@@ -18,6 +18,7 @@
/// <returns></returns>
WebResponseContent GetUpstreamOutOrder();
+ WebResponseContent GetUpstreamOutOrder2();
/// <summary>
/// 缁欎笅娓竪cs鍑哄簱鍗�
/// </summary>
diff --git "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_Model/Models/SquareCabin/Dt_DeliveryOrderDetail_Hty.cs" "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_Model/Models/SquareCabin/Dt_DeliveryOrderDetail_Hty.cs"
index f817e86..ca990b8 100644
--- "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_Model/Models/SquareCabin/Dt_DeliveryOrderDetail_Hty.cs"
+++ "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_Model/Models/SquareCabin/Dt_DeliveryOrderDetail_Hty.cs"
@@ -30,6 +30,10 @@
[SugarColumn(ColumnName = "Order_qty", IsNullable = true, ColumnDescription = "鍑哄簱閫�璐ф椂涓鸿礋鏁�")]
public decimal Order_qty { get; set; }
+
+ [SugarColumn(ColumnName = "Order_Outqty", IsNullable = true, ColumnDescription = "鍑哄簱瀹屾垚鏁伴噺")]
+ public decimal Order_Outqty { get; set; }
+
[SugarColumn(ColumnName = "Batch_num", IsNullable = true, Length = 50, ColumnDescription = "鎵瑰彿")]
public string Batch_num { get; set; }
diff --git "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/CabinOrderServices.cs" "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/CabinOrderServices.cs"
index e1c8101..4a56fe5 100644
--- "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/CabinOrderServices.cs"
+++ "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/CabinOrderServices.cs"
@@ -32,7 +32,6 @@
{
public class CabinOrderServices : ServiceBase<Dt_CabinOrder, IRepository<Dt_CabinOrder>>, ICabinOrderServices
{
-
static string SearchDate = "";
private readonly IBasicService _basicService;
private readonly IMedicineGoodsServices _medicineGoodsServices;
@@ -54,104 +53,8 @@
_supplyTaskService = supplyTaskService;
}
- /// <summary>
- /// 鑾峰彇涓婃父绯荤粺鐨勫叆搴撳崟
- /// </summary>
- /// <param name="searchDate"></param>
- /// <returns></returns>
- //public WebResponseContent GetUpstreamOrder(DateTime searchDate)
- //{
- // var responseContent = new WebResponseContent();
-
- // try
- // {
- // // 璇锋眰鍦板潃
- // var url = "http://127.0.0.1:9090/GYZ2/95fck/inOrder";
-
- // //// 璇锋眰鍙傛暟
- // var requestData = new
- // {
- // searchDate = searchDate.ToString("yyyy-MM-dd HH:mm:ss")
- // };
-
- // // 鍙戣捣璇锋眰
- // var result = HttpHelper.Post(url, requestData.ToJsonString());
-
- // // 鍙嶅簭鍒楀寲
- // var response = JsonConvert.DeserializeObject<UpstreamResponse<UpstreamOrderInfo>>(result);
-
- // if (response.resultCode != "0")
- // {
- // // 璋冪敤寮傚父鎺ュ彛
- // SendErrorToUpstream(1, "", response.resultMsg ?? "涓婃父鎺ュ彛杩斿洖澶辫触", "");
- // return responseContent.Error(response.resultMsg ?? "涓婃父鎺ュ彛杩斿洖澶辫触");
- // }
-
- // if (response.data == null || !response.data.Any())
- // {
- // return responseContent.OK("鏃犳柊鍏ュ簱鍗曟暟鎹�");
- // }
-
- // Db.Ado.BeginTran();
- // List<Dt_CabinOrder> _CabinOrders = new List<Dt_CabinOrder>();
- // foreach (var order in response.data)
- // {
- // try
- // {
- // // 鎻掑叆鍏ュ簱鍗曡〃
- // var entityOrder = new Dt_CabinOrder
- // {
-
- // Order_no = order.order_no,
- // Order_type = order.order_type,
- // Supplier_no = order.supplier_no,
- // Account_tiem = order.account_time,
- // OdrderStatus = "鏂板缓",
- // };
- // //var orderId = Db.Insertable(entityOrder).ExecuteReturnIdentity(); //灏辨槸杩斿洖涓婚敭ID銆�
-
- // // 鎻掑叆鍏ュ簱鏄庣粏琛�
- // var detailEntities = order.details.Select(d => new Dt_CabinOrderDetail
- // {
- // //OrderId= orderId,
- // Goods_no = d.goods_no,
- // Order_qty = d.order_qty,
- // Batch_num = d.batch_num,
- // Exp_date = d.exp_date,
- // Warehouse_no = d.warehouse_no,
- // Status = 0,
- // }).ToList();
- // entityOrder.Details.AddRange(detailEntities); //寤虹珛涓诲璞′笌瀛愬璞$殑鍏宠仈鍏崇郴
- // _CabinOrders.Add(entityOrder);
-
- // //鑷繁
- // /// Db.Insertable(detailEntities).ExecuteCommand();
-
- // //杩欓噷瑕佽皟鐢ㄤ竴涓帴鍙e皢涓婇潰鐨勪俊鎭紶缁檞cs锛岀劧鍚庢敼鍙樼姸鎬�
- // }
- // catch (Exception innerEx)
- // {
- // // 閽堝鏌愭潯璁㈠崟鎶ラ敊鏃讹紝鎺ㄩ�佸紓甯哥粰涓婃父
- // SendErrorToUpstream(1, order.order_no, innerEx.Message, "");
- // throw; // 鎶涘嚭寮傚父锛岃澶栧眰鎹曡幏鍥炴粴
- // }
- // }
- // // 鎵归噺鎻掑叆锛圫qlSugar鑷姩澶勭悊涓诲閿叧绯伙級
- // Db.Insertable(_CabinOrders).ExecuteCommand();
- // Db.Ado.CommitTran();
-
- // //濡傛灉EdiIn瀹屾垚閭d箞灏辫皟鐢–ompleteOrder鎺ュ彛
-
- // return responseContent.OK("鍚屾鍏ュ簱鍗曟垚鍔�");
- // }
- // catch (Exception ex)
- // {
- // // 鍏ㄥ眬寮傚父鏃讹紝涔熸帹閫佸紓甯哥粰涓婃父
- // SendErrorToUpstream(1, "", ex.Message, "");
- // Db.Ado.RollbackTran();
- // return responseContent.Error("鍚屾澶辫触: " + ex.Message);
- // }
- //}
+
+
public WebResponseContent GetCabinOrders(SaveModel saveModel)
{
WebResponseContent content = new WebResponseContent();
@@ -331,6 +234,12 @@
return content;
}
+
+ /// <summary>
+ /// 鑾峰彇涓婃父绯荤粺鐨勫叆搴撳崟
+ /// </summary>
+ /// <param name="searchDate"></param>
+ /// <returns></returns>
public WebResponseContent GetUpstreamOrder()
{
var responseContent = new WebResponseContent();
@@ -533,6 +442,205 @@
}
/// <summary>
+ /// 瀵规病鏈夎繘琛岀淮鎶ゅ晢鍝佷俊鎭〃鐨勫叆搴撳崟杩涜杩囨护澶勭悊
+ /// </summary>
+ /// <returns></returns>
+ public WebResponseContent GetUpstreamOrder2()
+ {
+ var responseContent = new WebResponseContent();
+ try
+ {
+ // 璇锋眰鍦板潃
+ var url = "http://121.37.118.63:80/GYZ2/95fck/inOrder";
+ //if (string.IsNullOrEmpty(SearchDate)) SearchDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+ //// 璇锋眰鍙傛暟
+ var requestData = new
+ {
+ //searchDate = SearchDate
+ searchDate = "2020-10-10 20:45:16" // 姝g‘鐨勬牸寮�
+ };
+ //SearchDate = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
+
+ var result = HttpHelper.Post(url, requestData.ToJsonString());
+ var response = JsonConvert.DeserializeObject<UpstreamResponse<UpstreamOrderInfo>>(result);
+
+ if (response.resultCode != "0")
+ {
+ SendErrorToUpstream(1, "", response.resultMsg ?? "涓婃父鎺ュ彛杩斿洖澶辫触", "");
+ return responseContent.Error(response.resultMsg ?? "涓婃父鎺ュ彛杩斿洖澶辫触");
+ }
+
+ if (response.data == null || !response.data.Any())
+ return responseContent.OK("鏃犳柊鍏ュ簱鍗曟暟鎹�");
+
+ var existingOrderNos = BaseDal.Db.Queryable<Dt_CabinOrder>()
+ .Select(x => x.Order_no)
+ .ToList();
+
+ var newOrders = response.data
+ .Where(order => !existingOrderNos.Contains(order.order_no))
+ .ToList();
+
+ if (!newOrders.Any())
+ return responseContent.OK("鎵�鏈夊叆搴撳崟宸插瓨鍦紝鏃犻渶鏂板");
+
+ Db.Ado.BeginTran();
+ try
+ {
+ List<Dt_CabinOrder> _CabinOrders = new();
+ List<string> orderNos = new();
+
+ foreach (var order in newOrders)
+ {
+ bool skipOrder = false; // 鏍囪鏄惁璺宠繃璇ュ叆搴撳崟
+ var entityOrder = new Dt_CabinOrder
+ {
+ Order_no = order.order_no,
+ Order_type = order.order_type,
+ Supplier_no = order.supplier_no,
+ Account_tiem = order.account_time,
+ OdrderStatus = "鏂板缓",
+ Supplier_name = order.supplier_name,
+ Warehouse_no = order.warehouse_no,
+ Details = new List<Dt_CabinOrderDetail>()
+ };
+
+ foreach (var item in order.details)
+ {
+ item.order_qty = Math.Abs(item.order_qty);
+
+ // 鏌ヨ鐗╂枡淇℃伅
+ var materielInfo = BaseDal.Db.Queryable<Dt_MedicineGoods>()
+ .Where(x => x.Goods_no == item.goods_no)
+ .First();
+
+ // 鑻ョ墿鏂欎笉瀛樺湪鎴� MaterielSourceType 涓虹┖锛屽垯璺宠繃鏁翠釜鍏ュ簱鍗�
+ if (materielInfo == null || !Enum.IsDefined(typeof(MaterielSourceTypeEnum), materielInfo.MaterielSourceType))
+ {
+ skipOrder = true;
+ break;
+ }
+
+ // 鍖哄垎澶т欢/灏忎欢
+ if (materielInfo.MaterielSourceType == MaterielSourceTypeEnum.PurchasePart)
+ {
+ var detail = new Dt_CabinOrderDetail
+ {
+ Reservoirarea = order.warehouse_no,
+ Goods_no = item.goods_no,
+ Order_qty = item.order_qty,
+ Batch_num = item.batch_num,
+ Exp_date = item.exp_date,
+ OrderDetailStatus = "鏂板缓",
+ Status = 2
+ };
+ entityOrder.Details.Add(detail);
+ }
+ else
+ {
+ Dt_CabinOrderDetail orderDetail = null;
+ var ys = item.order_qty % materielInfo.BoxQty; // 涓嶈兘鏁撮櫎鐨勬暎浠�
+ var xs = item.order_qty / materielInfo.BoxQty; // 鏁寸鏁伴噺
+
+ // 鏈夋暎浠�
+ if (ys > 0)
+ {
+ orderDetail = new Dt_CabinOrderDetail
+ {
+ Reservoirarea = order.warehouse_no,
+ Goods_no = item.goods_no,
+ Order_qty = ys,
+ Batch_num = item.batch_num,
+ Exp_date = item.exp_date,
+ OrderDetailStatus = "鏂板缓",
+ Status = 0
+ };
+ materielInfo.Business_qty += ys;
+ }
+
+ // 涓嶈冻鏈�浣庡簱瀛樻椂琛ュ叆绔嬪簱
+ while (materielInfo.Business_qty < materielInfo.MinQty && xs > 0)
+ {
+ xs--;
+ if (orderDetail == null)
+ {
+ orderDetail = new Dt_CabinOrderDetail
+ {
+ Reservoirarea = order.warehouse_no,
+ Goods_no = item.goods_no,
+ Order_qty = materielInfo.BoxQty,
+ Batch_num = item.batch_num,
+ Exp_date = item.exp_date,
+ OrderDetailStatus = "鏂板缓",
+ Status = 0
+ };
+ }
+ else
+ {
+ orderDetail.Order_qty += materielInfo.BoxQty;
+ }
+ materielInfo.Business_qty += materielInfo.BoxQty;
+ }
+
+ if (orderDetail != null) entityOrder.Details.Add(orderDetail);
+
+ // 鍓╀綑鏁寸鍏ュ钩搴�
+ if (xs > 0)
+ {
+ entityOrder.Details.Add(new Dt_CabinOrderDetail
+ {
+ Reservoirarea = order.warehouse_no,
+ Goods_no = item.goods_no,
+ Order_qty = materielInfo.BoxQty * xs,
+ Batch_num = item.batch_num,
+ Exp_date = item.exp_date,
+ OrderDetailStatus = "鏂板缓",
+ Status = 2
+ });
+ }
+ }
+
+ _medicineGoodsServices.Db.Updateable(materielInfo).ExecuteCommand();
+ }
+
+ // 鉂楀鏋滆烦杩囪鍗曪紝鍒欑洿鎺ontinue锛屼笉淇濆瓨
+ if (skipOrder)
+ {
+ Console.WriteLine($"璺宠繃鍏ュ簱鍗� {order.order_no}锛屽洜涓哄瓨鍦ㄦ湭瀹氫箟鐗╂枡灞炴�х殑鍟嗗搧銆�");
+ continue;
+ }
+
+ _CabinOrders.Add(entityOrder);
+ orderNos.Add(order.order_no);
+ }
+
+ if (_CabinOrders.Any())
+ {
+ BaseDal.Db.InsertNav(_CabinOrders).Include(x => x.Details).ExecuteCommand();
+ Db.Ado.CommitTran();
+ return responseContent.OK($"鎴愬姛鍚屾 {_CabinOrders.Count} 鏉″叆搴撳崟");
+ }
+ else
+ {
+ Db.Ado.RollbackTran();
+ return responseContent.OK("鏃犲彲澶勭悊鐨勫叆搴撳崟锛堝晢鍝佸睘鎬ф湭瀹氫箟鎴栨湭鎵惧埌锛�");
+ }
+ }
+ catch (Exception ex)
+ {
+ Db.Ado.RollbackTran();
+ SendErrorToUpstream(1, "", ex.Message, "");
+ return responseContent.Error("鍚屾澶辫触: " + ex.Message);
+ }
+ }
+ catch (Exception ex)
+ {
+ SendErrorToUpstream(1, "", ex.Message, "");
+ return responseContent.Error("鍚屾澶辫触: " + ex.Message);
+ }
+ }
+
+ /// <summary>
/// 浼犵粰wcs
/// </summary>
public WebResponseContent EdiIn()
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..874c196 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,306 @@
}
}
+ /// <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();
+
+
+ // 鑻ョ墿鏂欎笉瀛樺湪鎴� 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 +860,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 +1065,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.搴撳瓨鏌ヨ鎺ュ彛
diff --git "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_WMSServer/GoodsJob.cs" "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_WMSServer/GoodsJob.cs"
index 2782566..f07b525 100644
--- "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_WMSServer/GoodsJob.cs"
+++ "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_WMSServer/GoodsJob.cs"
@@ -12,7 +12,7 @@
_medicineGoodsServices = medicineGoodsServices;
}
//姣忛殧1绉掓墽琛屼竴娆�
- [Invoke(Begin = "2025-09-01", Interval = 1000 * 5, IsEnabled = true, SkipWhileExecuting = true)]
+ [Invoke(Begin = "2025-09-01", Interval = 1000 * 5, IsEnabled = false, SkipWhileExecuting = true)]
public void Run()
{
_medicineGoodsServices.GetMedicineGoodsInfom();
diff --git "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_WMSServer/OutOrderJob.cs" "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_WMSServer/OutOrderJob.cs"
index ea9909d..644cc05 100644
--- "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_WMSServer/OutOrderJob.cs"
+++ "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_WMSServer/OutOrderJob.cs"
@@ -15,7 +15,7 @@
public void Run()
{
//鑾峰彇涓婃父鍑哄簱鍗曟暟鎹�
- _deliveryOrderServices.GetUpstreamOutOrder();
+ _deliveryOrderServices.GetUpstreamOutOrder2();
//涓嬪彂wcs
_deliveryOrderServices.EdiOut();
_deliveryOrderServices.CompleteAllOutOrders();
diff --git "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_WMSServer/appsettings.json" "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_WMSServer/appsettings.json"
index 0f84a35..8be8b3a 100644
--- "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_WMSServer/appsettings.json"
+++ "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_WMSServer/appsettings.json"
@@ -16,7 +16,7 @@
//"ConnectionString": "Data Source=.;Initial Catalog=WIDESEAWMS_HUAIAN;User ID=sa;Password=P@ssw0rd;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
//"ConnectionString": "Data Source=10.30.4.92;Initial Catalog=WMS_TC;User ID=sa;Password=duo123456;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
//鏃MS鏁版嵁搴撹繛鎺�
- "ConnectionString": "Data Source=.;Initial Catalog=WIDESEA_WMSDBF_Z22;User ID=sa;Password=P@ssw0rd;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
+ "ConnectionString": "Data Source=.;Initial Catalog=WIDESEA_WMSDBF_Z22;User ID=sa;Password=123456;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
//璺ㄥ煙
"Cors": {
"PolicyName": "CorsIpAccess", //绛栫暐鍚嶇О
--
Gitblit v1.9.3