From 5d756f53f07880dc8b7ba0bc9f060b9e94d4b25e Mon Sep 17 00:00:00 2001
From: yanjinhui <3306209981@qq.com>
Date: 星期三, 05 十一月 2025 18:08:34 +0800
Subject: [PATCH] 修改人工入库完成和wcs小车问题
---
新建文件夹/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/InventoryServices.cs | 224 +++++++++++++++++++++++++++++++++++++------------------
1 files changed, 150 insertions(+), 74 deletions(-)
diff --git "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/InventoryServices.cs" "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/InventoryServices.cs"
index 7130732..cbf773e 100644
--- "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/InventoryServices.cs"
+++ "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/InventoryServices.cs"
@@ -1,12 +1,8 @@
锘縰sing 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;
using WIDESEA_Common.WareHouseEnum;
@@ -27,12 +23,19 @@
{
public class InventoryServices : ServiceBase<Dt_Inventory, IRepository<Dt_Inventory>>, IInventoryServices
{
+ private readonly ICabinOrderServices _cabinOrderServices;
private readonly IDeliveryOrderServices _deliveryOrderServices;
- public InventoryServices(IRepository<Dt_Inventory> BaseDal, IDeliveryOrderServices deliveryOrderServices) : base(BaseDal)
+ private readonly ISupplyTaskService _supplyTaskService;
+ 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>
/// 鑾峰彇涓婃父搴撳瓨淇℃伅
@@ -41,59 +44,121 @@
/// <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
+ {
+ if (request == null || request.details == null || request.details.Count < 1) throw new Exception("璇锋眰鍙傛暟鏃犳晥");
+ var Warecode = WarehouseEnum.绔嬪簱.ObjToInt().ToString("000");
+ switch (request.orderType)
+ {
+ case "1": //鍏ュ簱
+ {
+ Dt_CabinOrder cabinOrder = _cabinOrderServices.Db.Queryable<Dt_CabinOrder>().Where(x => x.Order_no == request.externalOrderNo && x.Warehouse_no == Warecode).Includes(x => x.Details).First();
+ if (cabinOrder == null) throw new Exception($"鏈壘鍒板叆搴撳崟鍙枫�恵request.externalOrderNo}銆戠殑鍏ュ簱鍗曚俊鎭�");
+ if (cabinOrder.OdrderStatus == "宸插畬鎴�")
+ return new ApiResponse<Dt_InventoryInfo> { code = "0", msg = $"鎴愬姛" };
+ WebResponseContent content = _cabinOrderServices.CompleteLKInOrder(cabinOrder, request);
+ if (!content.Status) throw new Exception(content.Message);
+ }
+ break;
+ case "2":
+ {
+ Dt_DeliveryOrder deliveryOrder = _deliveryOrderServices.Db.Queryable<Dt_DeliveryOrder>().Where(x => x.Out_no == request.externalOrderNo && x.Warehouse_no == Warecode).Includes(x => x.Details).First();
+ if (deliveryOrder == null) throw new Exception($"鏈壘鍒板嚭搴撳崟鍙枫�恵request.externalOrderNo}銆戠殑鍑哄簱鍗曚俊鎭�");
+ if (deliveryOrder.OutStatus == "宸插畬鎴�")
+ return new ApiResponse<Dt_InventoryInfo> { code = "0", msg = $"鎴愬姛" };
+ WebResponseContent content = _deliveryOrderServices.CompleteLKOutOrder(deliveryOrder, request);
+ if (!content.Status) throw new Exception(content.Message);
+ }
+ break;
+ case "3":
+ {
+ #region 鎵剧洏鐐逛换鍔�
+ List<Dt_SupplyTask> supplyTasks = _supplyTaskService.Repository.QueryData(x => x.OrderNo == request.externalOrderNo && x.WarehouseCode == Warecode && x.TaskStatus == SupplyStatusEnum.NewCheck.ObjToInt());
+ foreach (var detail in request.details)
+ {
+ Dt_SupplyTask? supplyTask = supplyTasks.Where(x => x.MaterielCode == detail.productCode && x.BatchNo == detail.batchNo).FirstOrDefault();
+ if (supplyTask == null) throw new Exception($"鏈壘鍒拌鍗曞彿銆恵request.externalOrderNo}銆戠墿鏂欑紪鍙枫�恵detail.productCode}銆戠殑鐩樼偣浠诲姟");
+ if (detail.isLossOrProfit == 1) // 鐩樹簭
+ {
+ supplyTask.SupplyQuantity = supplyTask.StockQuantity - detail.ea;
+ }
+ else if (detail.isLossOrProfit == 2) // 鐩樼泩
+ {
+ supplyTask.SupplyQuantity = supplyTask.StockQuantity + detail.ea;
+ }
+ else // 鐩樹腑
+ {
+ supplyTask.SupplyQuantity = supplyTask.StockQuantity;
+ }
+ var content = _deliveryOrderServices.CheckTaskFinish(supplyTask);
+ if (!content.Status) throw new Exception(content.Message);
+ }
+ #endregion
+ }
+ break;
+ default:
+ throw new Exception($"鏈畾涔夌殑绫诲瀷銆恵request.orderType}銆�");
+ }
+ return new ApiResponse<Dt_InventoryInfo>
+ {
+ code = "0",
+ msg = $"鎴愬姛"
+ };
+ }
+ catch (Exception ex)
+ {
+ return new ApiResponse<Dt_InventoryInfo>
+ {
+ code = "500",
+ msg = $"澶勭悊澶辫触: {ex.Message}"
+ };
+ }
+ }
/// <summary>
/// wcs鍥炰紶缁欐垜璋冪敤鎴戠殑鏂规硶 涓嶇鏄叆搴� 鍑哄簱 鐩樼偣閮戒細璋冪敤杩欎釜鎺ュ彛
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
- public ApiResponse<Dt_InventoryInfo> OrderFeedback(EdiOrderCallbackRequest request)
+ public ApiResponse<Dt_InventoryInfo> OrderFeedback1(EdiOrderCallbackRequest request)
{
try
{
@@ -104,7 +169,7 @@
}
var reslut = WarehouseEnum.绔嬪簱.ObjToInt().ToString("000");
// 2锔忊儯 寮�鍚簨鍔�
- BaseDal.Db.Ado.BeginTran();
+ //BaseDal.Db.Ado.BeginTran();
foreach (var detail in request.details)
{
#region 鏌ヨ鐗╂枡淇℃伅銆佽绠楁�诲拰
@@ -178,8 +243,12 @@
#endregion
else
{
- if (cabinOrder == null || cabinOrder.OdrderStatus == "宸插畬鎴�")
- throw new Exception($"鍏ュ簱鍗曞凡瀹屾垚");
+ if (cabinOrder.OdrderStatus == "宸插畬鎴�")
+ return new ApiResponse<Dt_InventoryInfo>
+ {
+ code = "0",
+ msg = "鎴愬姛"
+ };
Dt_CabinOrderDetail cabinOrderDetail = cabinOrder.Details.Where(x => x.Goods_no == detail.productCode && x.Batch_num == detail.batchNo && x.Status == 1).First();
if (cabinOrderDetail == null || cabinOrderDetail.OrderDetailStatus == "宸插畬鎴�")
throw new Exception($"鍏ュ簱鍗曟槑缁嗗凡瀹屾垚");
@@ -228,42 +297,45 @@
ProductionDate = detail.finishDate.ToString("yyyy-MM-dd"),
ShelfLife = 0,
ValidityPeriod = cabinOrderDetail.Exp_date,
- Remark = "WCS鍥炰紶鍒涘缓"
+ Remark = "鏅鸿兘绔嬪簱"
};
BaseDal.Db.Insertable(inventoryInfo).ExecuteCommand();
}
#endregion
- #region 鍒涘缓搴撳瓨鎵规淇℃伅
- // 6锔忊儯 鏌ヨ搴撳瓨鎵规淇℃伅
- var inventory_Batch = BaseDal.Db.Queryable<Dt_Inventory_Batch>()
- .First(x => x.MaterielCode == inventoryInfo.MaterielCode && x.BatchNo == inventoryInfo.BatchNo);
+ #region 鍒涘缓搴撳瓨鎵规淇℃伅 鍙湁涓嶆槸璋冩嫧鍏ュ簱鍗曪紙115锛夋墠瀵规壒娆′俊鎭繘琛屼慨鏀�
+ if (cabinOrder.Order_type != InOrderTypeEnum.Allocat.ObjToInt().ToString())
+ {
+ // 6锔忊儯 鏌ヨ搴撳瓨鎵规淇℃伅
+ var inventory_Batch = BaseDal.Db.Queryable<Dt_Inventory_Batch>()
+ .First(x => x.MaterielCode == inventoryInfo.MaterielCode && x.BatchNo == inventoryInfo.BatchNo);
- if (inventory_Batch != null)
- {
- inventory_Batch.StockQuantity += orderQty;
- inventory_Batch.AvailableQuantity += orderQty;
- BaseDal.Db.Updateable(inventory_Batch).ExecuteCommand();
- }
- else
- {
- inventory_Batch = new Dt_Inventory_Batch
+ if (inventory_Batch != null)
{
- MaterielCode = inventoryInfo.MaterielCode,
- MaterielName = inventoryInfo.MaterielName,
- MaterielSpec = inventoryInfo.MaterielSpec,
- BatchNo = inventoryInfo.BatchNo,
- StockQuantity = inventoryInfo.StockQuantity,
- OutboundQuantity = inventoryInfo.OutboundQuantity,
- AvailableQuantity = inventoryInfo.AvailableQuantity,
- SupplyQuantity = inventoryInfo.SupplyQuantity,
- ERPStockQuantity = 0,
- Status = false,
- ProductionDate = detail.finishDate.ToString("yyyy-MM-dd"),
- ValidityPeriod = inventoryInfo.ValidityPeriod,
- Remark = "鑷姩鍒涘缓"
- };
- BaseDal.Db.Insertable(inventory_Batch).ExecuteCommand();
+ inventory_Batch.StockQuantity += orderQty;
+ inventory_Batch.AvailableQuantity += orderQty;
+ BaseDal.Db.Updateable(inventory_Batch).ExecuteCommand();
+ }
+ else
+ {
+ inventory_Batch = new Dt_Inventory_Batch
+ {
+ MaterielCode = inventoryInfo.MaterielCode,
+ MaterielName = inventoryInfo.MaterielName,
+ MaterielSpec = inventoryInfo.MaterielSpec,
+ BatchNo = inventoryInfo.BatchNo,
+ StockQuantity = inventoryInfo.StockQuantity,
+ OutboundQuantity = inventoryInfo.OutboundQuantity,
+ AvailableQuantity = inventoryInfo.AvailableQuantity,
+ SupplyQuantity = inventoryInfo.SupplyQuantity,
+ ERPStockQuantity = 0,
+ Status = false,
+ ProductionDate = detail.finishDate.ToString("yyyy-MM-dd"),
+ ValidityPeriod = inventoryInfo.ValidityPeriod.ObjToDate(),
+ Remark = "鑷姩鍒涘缓"
+ };
+ BaseDal.Db.Insertable(inventory_Batch).ExecuteCommand();
+ }
}
#endregion
@@ -288,6 +360,8 @@
SupplyQuantity = 0,
Remark = "鍏ュ簱"
};
+ //杩欓噷杩欓噷鐨勫叆搴撹皟鎷ㄥ崟鐘舵�佹槸115锛屽氨灏嗚皟鎷ㄤ换鍔$姸鎬佹敼涓�7
+ if (cabinOrder.Order_type == InOrderTypeEnum.Allocat.ObjToInt().ToString()) supplyTask_Hty.TaskType = TaskTypeEnum.AllocatIn.ObjToInt();
BaseDal.Db.Insertable(supplyTask_Hty).ExecuteCommand();
#endregion
}
@@ -296,7 +370,7 @@
case "2":
{
Dt_DeliveryOrder cabinOrder = Db.Queryable<Dt_DeliveryOrder>().Where(x => x.Out_no == request.externalOrderNo && x.Warehouse_no == reslut).Includes(x => x.Details).First();
- if (cabinOrder == null) throw new Exception($"鏈壘鍒板嚭搴撳崟鍙枫�恵request.externalOrderNo}銆戠殑鍏ュ簱鍗曚俊鎭�");
+ if (cabinOrder == null) throw new Exception($"鏈壘鍒板嚭搴撳崟鍙枫�恵request.externalOrderNo}銆戠殑鍑哄簱鍗曚俊鎭�");
if (cabinOrder.Out_type == "6")
{
@@ -388,7 +462,7 @@
}
// 9锔忊儯 鎻愪氦浜嬪姟
- BaseDal.Db.Ado.CommitTran();
+ //BaseDal.Db.Ado.CommitTran();
return new ApiResponse<Dt_InventoryInfo>
{
@@ -399,13 +473,15 @@
catch (Exception ex)
{
// 馃敓 鍥炴粴浜嬪姟
- BaseDal.Db.Ado.RollbackTran();
+ //BaseDal.Db.Ado.RollbackTran();
return new ApiResponse<Dt_InventoryInfo>
{
code = "500",
msg = $"澶勭悊澶辫触: {ex.Message}"
};
+
+ //Console.WriteLine(ex.Message);
}
}
--
Gitblit v1.9.3