From aa4aa67abfdf69e30d5076451716e5aba11d5ec0 Mon Sep 17 00:00:00 2001
From: yangpeixing <yangpeixing@hnkhzn.com>
Date: 星期二, 14 四月 2026 16:12:40 +0800
Subject: [PATCH] 1
---
WMS/WIDESEA_WMSServer/WIDESEA_InboundService/Base/InboundOrderService.cs | 877 ++++++++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 787 insertions(+), 90 deletions(-)
diff --git a/WMS/WIDESEA_WMSServer/WIDESEA_InboundService/Base/InboundOrderService.cs b/WMS/WIDESEA_WMSServer/WIDESEA_InboundService/Base/InboundOrderService.cs
index 10471c1..bd7bea0 100644
--- a/WMS/WIDESEA_WMSServer/WIDESEA_InboundService/Base/InboundOrderService.cs
+++ b/WMS/WIDESEA_WMSServer/WIDESEA_InboundService/Base/InboundOrderService.cs
@@ -37,6 +37,9 @@
using WIDESEA_Model.Models;
using WIDESEA_Model.Models.Inbound;
using static WIDESEA_Common.HouseInventoryIn;
+using static WIDESEA_Common.HouseSyncretism;
+using static WIDESEA_Common.InventoryAllocate;
+using Parameter = WIDESEA_Common.Parameter;
namespace WIDESEA_InboundService
{
@@ -158,6 +161,7 @@
return WebResponseContent.Instance.Error($"鏈壘鍒板叆搴撳崟鏄庣粏淇℃伅");
}
List<MatSerNumAnalysisModel> models = CodeAnalysisHelper.CodeAnalysis<MatSerNumAnalysisModel>(AnalysisCodeEnum.MatSerNumAnalysis, serialNumbers);
+
//楠岃瘉鍒ゆ柇鏃堕棿鏍煎紡
WebResponseContent IsValidContent = IsValidMCDates(models);
if (!IsValidContent.Status)
@@ -171,8 +175,13 @@
{
return WebResponseContent.Instance.Error($"鏈壘鍒拌鐗╂枡鐨勪俊鎭�");
}
+ List<Dt_InboundOrderDetail> inboundOrderDetails = new List<Dt_InboundOrderDetail>();
///鎵炬暟閲忓尮閰嶇殑
- List<Dt_InboundOrderDetail> inboundOrderDetails = inboundOrder.Details.Where(x => x.MaterielCode == materielCode && x.SupplierBatch == (models.FirstOrDefault()?.LotNo ?? "") && x.OrderQuantity > x.ReceiptQuantity && x.OrderQuantity == (quantitys.FirstOrDefault())).ToList();
+ if (warehouse.WarehouseCode.Contains("BC"))
+ {
+ inboundOrderDetails = inboundOrder.Details.Where(x => x.MaterielCode == materielCode && x.SupplierBatch == (models.FirstOrDefault()?.LotNo ?? "") && x.OrderQuantity > x.ReceiptQuantity && x.OrderQuantity == (quantitys.FirstOrDefault())).ToList();
+ }
+
if (inboundOrderDetails == null || inboundOrderDetails.Count <= 0)
{
@@ -201,6 +210,7 @@
Wlstatus = (int)InventoryMaterialStatus.鍚堟牸,
Mgeneratetime = DateTime.Now,
WarehouseId = warehouse.WarehouseId,
+ System = inboundOrder.System,
Details = new List<Dt_StockInfoDetail>()
};
}
@@ -246,7 +256,13 @@
List<Dt_StockInfoDetail> stockInfoDetails = new List<Dt_StockInfoDetail>();
foreach (var model in models)
{
- Dt_InboundOrderDetail? notGroupDetail = inboundOrderDetails.Where(x => x.OrderDetailStatus <= OrderDetailStatusEnum.Inbounding.ObjToInt() && x.MaterielCode == model.MaterielCode && x.SupplierBatch == model.LotNo && x.OrderQuantity > x.ReceiptQuantity).FirstOrDefault();
+
+ Dt_InboundOrderDetail notGroupDetail = new Dt_InboundOrderDetail();
+ ///鎵炬暟閲忓尮閰嶇殑
+ if (warehouse.WarehouseCode.Contains("BC"))
+ {
+ notGroupDetail = inboundOrderDetails.Where(x => x.OrderDetailStatus <= OrderDetailStatusEnum.Inbounding.ObjToInt() && x.MaterielCode == model.MaterielCode && x.SupplierBatch == model.LotNo && x.OrderQuantity > x.ReceiptQuantity).FirstOrDefault();
+ }
if (notGroupDetail == null)
{
@@ -266,7 +282,8 @@
Id = inboundOrderDet.LinId.ObjToInt(),
DeliveryNote = model.DeliveryNote,
SupplierBatch = inboundOrderDet.SupplierBatch,
- MaterieSpec = inboundOrderDet.MaterieSpec
+ MaterieSpec = inboundOrderDet.MaterieSpec,
+ OrinalLocation = inboundOrderDet.OrinalLocation
};
if (stockInfo.Id > 0)
@@ -323,12 +340,522 @@
return content;
}
+ //鑽按锛屼綆娓╀粨缁勭洏
+ public WebResponseContent NewMaterielGroup(SaveModel saveModel)
+ {
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+
+ var orderNo = saveModel.MainData["orderNo"].ToString();
+ var palletCode = saveModel.MainData["palletCode"].ToString();
+ var warehouseId = saveModel.MainData["warehouseId"].ObjToInt();
+ var Initiallife = saveModel.MainData["initiallife"].ObjToInt();
+ List<string> serialNumbers = new List<string>();
+ List<decimal> quantitys = new List<decimal>();
+ foreach (var item in saveModel.DelKeys)
+ {
+ string json = JsonConvert.SerializeObject(item);
+ Dictionary<string, object> delKeyDict = JsonConvert.DeserializeObject<Dictionary<string, object>>(json);
+
+ string serialNumber = string.Empty;
+ decimal quantity = 0;
+
+ // 绗竴姝ワ細璇诲彇serialNumber骞舵牎楠�
+ if (delKeyDict.TryGetValue("serialNumber", out object serialNumberObj))
+ {
+ serialNumber = serialNumberObj?.ToString();
+ if (string.IsNullOrEmpty(serialNumber))
+ {
+ return WebResponseContent.Instance.Error("serialNumber鐨勫�间负绌�");
+ }
+ }
+ else
+ {
+ return WebResponseContent.Instance.Error("缂哄皯serialNumber瀛楁");
+ }
+
+ if (delKeyDict.TryGetValue("quantity", out object quantityObj))
+ {
+ if (quantityObj == null)
+ {
+ return WebResponseContent.Instance.Error("鐗╂枡鏁伴噺鐨勫�间负绌�");
+ }
+ try
+ {
+ quantity = Convert.ToDecimal(quantityObj);
+ }
+ catch
+ {
+ return WebResponseContent.Instance.Error($"鐗╂枡鏁伴噺{quantityObj}鏃犳硶杞崲涓烘暟瀛�");
+ }
+ if (quantity <= 0)
+ {
+ return WebResponseContent.Instance.Error("鐗╂枡鏁伴噺蹇呴』澶т簬0");
+ }
+ }
+ else
+ {
+ return WebResponseContent.Instance.Error("缂哄皯鐗╂枡鏁伴噺瀛楁");
+ }
+
+ var keyValuePairs = serialNumber.Split(',');
+ List<string> newKeyValuePairs = new List<string>();
+ bool qFieldUpdated = false;
+
+ foreach (var pair in keyValuePairs)
+ {
+ if (pair.StartsWith("Q:"))
+ {
+ newKeyValuePairs.Add($"Q:{quantity}");
+ qFieldUpdated = true;
+ }
+ else
+ {
+ newKeyValuePairs.Add(pair);
+ }
+ }
+ string updatedSerialNumber = string.Join(',', newKeyValuePairs);
+ serialNumbers.Add(updatedSerialNumber);
+ }
+ Dt_Warehouse warehouse = _warehouseService.Repository.QueryFirst(x => x.WarehouseId == warehouseId);
+ if (warehouse == null)
+ {
+ return WebResponseContent.Instance.Error($"鏈壘鍒拌浠撳簱淇℃伅");
+ }
+
+ Dt_InboundOrder inboundOrder = BaseDal.Db.Queryable<Dt_InboundOrder>().Where(x => x.OrderNo == orderNo && x.WarehouseId == warehouse.WarehouseId).Includes(x => x.Details).First();
+ if (inboundOrder == null)
+ {
+ return WebResponseContent.Instance.Error($"鏈壘鍒板叆搴撳崟淇℃伅");
+ }
+ if (inboundOrder.Details == null || inboundOrder.Details.Count <= 0)
+ {
+ return WebResponseContent.Instance.Error($"鏈壘鍒板叆搴撳崟鏄庣粏淇℃伅");
+ }
+ List<MatSerNumAnalysisModel> models = CodeAnalysisHelper.CodeAnalysis<MatSerNumAnalysisModel>(AnalysisCodeEnum.MatSerNumAnalysis, serialNumbers);
+ //楠岃瘉鍒ゆ柇鏃堕棿鏍煎紡
+ WebResponseContent IsValidContent = IsValidMCDates(models);
+ if (!IsValidContent.Status)
+ {
+ return content.Error(IsValidContent.Message);
+ }
+
+ string materielCode = models.FirstOrDefault()?.MaterielCode ?? "";
+ Dt_MaterielInfo materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x => x.MaterielCode == materielCode);
+ if (materielInfo == null)
+ {
+ return WebResponseContent.Instance.Error($"鏈壘鍒拌鐗╂枡鐨勪俊鎭�");
+ }
+
+ decimal beforeQuantity = 0;
+
+ Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletCode == palletCode).Includes(x => x.Details).First();
+ if (stockInfo == null)
+ {
+ stockInfo = new Dt_StockInfo()
+ {
+ BatchNo = "",
+ PalletCode = palletCode,
+ PalletType = GetPalletType(warehouse, palletCode),//GetPalletType(warehouse, palletCode)
+ IsFull = true,
+ StockStatus = (int)StockStatusEmun.缁勭洏鏆傚瓨,
+ Creater = "WMS",
+ CreateDate = DateTime.Now,
+ MaterialType = (int)InventoryMaterialType.鍘熸潗鏂�,
+ Materialweight = 0,
+ Wlstatus = (int)InventoryMaterialStatus.鍚堟牸,
+ Mgeneratetime = DateTime.Now,
+ WarehouseId = 0,
+ System = inboundOrder.System,
+ Details = new List<Dt_StockInfoDetail>()
+ };
+ }
+ else
+ {
+ return WebResponseContent.Instance.Error($"鎵樼洏鍙烽噸澶�,璇ユ墭鐩樺凡缁勮繃鐗╂枡");
+ }
+ List<Dt_StockInfoDetail> stockInfoDetails = new List<Dt_StockInfoDetail>();
+ _unitOfWorkManage.BeginTran();
+ foreach (var model in models)
+ {
+
+ Dt_InboundOrderDetail notGroupDetail = new Dt_InboundOrderDetail();
+
+ notGroupDetail = inboundOrder.Details.Where(x => x.OrderDetailStatus <= OrderDetailStatusEnum.Inbounding.ObjToInt() && x.MaterielCode == model.MaterielCode && x.SupplierBatch == model.LotNo && x.OrderQuantity > x.ReceiptQuantity && x.OrderQuantity == model.Quantity).FirstOrDefault();
+ if (notGroupDetail == null)
+ {
+ return WebResponseContent.Instance.Error($"璇锋鏌ョ墿鏂欎俊鎭潯鐮佸拰鍏ュ簱鍗曟槑缁嗘槸鍚﹀搴旀纭�");
+ }
+
+ if (notGroupDetail.MaterielType == 1)
+ {
+ stockInfo.WarehouseId = 6;
+ }
+ else if (notGroupDetail.MaterielType == 2)
+ {
+ stockInfo.WarehouseId = 5;
+ }
+
+ if (notGroupDetail == null)
+ {
+ return WebResponseContent.Instance.Error($"璇ョ墿鏂欏湪璇ュ叆搴撳崟涓凡鍏ㄩ儴缁勭洏瀹屾垚");
+ }
+ Dt_StockInfoDetail stockInfoDetail = new Dt_StockInfoDetail()
+ {
+ MaterielCode = notGroupDetail.MaterielCode,
+ MaterielName = notGroupDetail.MaterielName,
+ OrderNo = inboundOrder.OrderNo,
+ BatchNo = notGroupDetail.BatchNo,
+ LinId = notGroupDetail.LinId,
+ StockQuantity = model.Quantity,
+ Status = (int)StockStatusEmun.缁勭洏鏆傚瓨,
+ Creater = "WMS",
+ CreateDate = DateTime.Now,
+ Id = notGroupDetail.LinId.ObjToInt(),
+ DeliveryNote = model.DeliveryNote,
+ SupplierBatch = notGroupDetail.SupplierBatch,
+ MaterieSpec = notGroupDetail.MaterieSpec,
+ OrinalLocation = notGroupDetail.OrinalLocation
+ };
+
+ if (stockInfo.Id > 0)
+ {
+ stockInfoDetail.StockId = stockInfo.Id;
+ }
+ stockInfo.Details.Add(stockInfoDetail);
+
+ stockInfoDetails.Add(stockInfoDetail);
+
+ decimal decimalReceiptQuantity = Convert.ToDecimal(notGroupDetail.ReceiptQuantity);
+ decimal decimalModelQuantity = Convert.ToDecimal(notGroupDetail.OrderQuantity);
+ decimal decimalOrderQuantity = Convert.ToDecimal(notGroupDetail.OrderQuantity);
+ decimalReceiptQuantity += model.Quantity;
+ // 妫�鏌ユ槸鍚﹁秴鍑鸿鍗曟暟閲�
+ if (decimalReceiptQuantity > decimalOrderQuantity)
+ {
+ return WebResponseContent.Instance.Error($"缁勭洏鏁伴噺婧㈠嚭{decimalReceiptQuantity - decimalOrderQuantity}");
+ }
+ // 杞洖float绫诲瀷瀛樺偍锛屼絾姣旇緝鍜岃绠楅兘浣跨敤decimal瀹屾垚
+ notGroupDetail.ReceiptQuantity = Convert.ToDecimal(decimalReceiptQuantity);
+ if (notGroupDetail.OrderDetailStatus == OrderDetailStatusEnum.New.ObjToInt())
+ {
+ notGroupDetail.OrderDetailStatus = OrderDetailStatusEnum.GroupAndInbound.ObjToInt();
+ }
+ }
+
+ decimal totalQuantity = stockInfo.Details.Sum(x => x.StockQuantity);
+
+ inboundOrder.OrderStatus = InOrderStatusEnum.鍏ュ簱涓�.ObjToInt();
+
+
+ if (stockInfo.Id == 0)
+ {
+ _stockRepository.StockInfoRepository.Db.InsertNav(stockInfo).Include(x => x.Details).ExecuteCommand();
+ }
+ else
+ {
+ _stockRepository.StockInfoRepository.Db.UpdateNav(stockInfo).Include(x => x.Details, new UpdateNavOptions() { OneToManyInsertOrUpdate = true }).ExecuteCommand();
+ }
+ _inboundRepository.InboundOrderDetailRepository.UpdateData(inboundOrder.Details);
+ _inboundRepository.InboundOrderRepository.UpdateData(inboundOrder);
+ _unitOfWorkManage.CommitTran();
+ content.OK();
+ }
+ catch (Exception ex)
+ {
+ content = WebResponseContent.Instance.Error(ex.Message);
+ }
+ finally
+ {
+
+ }
+ return content;
+ }
+
/// <summary>
/// 鎴愬搧缁勭洏
/// </summary>
/// <param name="materielGroupDTO"></param>
/// <returns></returns>
+ #region
public WebResponseContent CPMaterielGroup(SaveModel saveModel)
+ {
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+ var orderNo = saveModel.MainData["orderNo"].ToString();
+ var palletCode = saveModel.MainData["palletCode"].ToString();
+ var warehouseId = saveModel.MainData["warehouseId"].ObjToInt();
+ var serialNumbers = new List<string>();
+ var quantities = new List<decimal>();
+ var lotNos = new List<string>();
+ var materielCodes = new List<string>();
+ // 鑾峰彇浠撳簱淇℃伅
+ Dt_Warehouse warehouse = _warehouseService.Repository.QueryFirst(x => x.WarehouseId == warehouseId);
+ if (warehouse == null)
+ {
+ return WebResponseContent.Instance.Error($"鏈壘鍒拌浠撳簱淇℃伅");
+ }
+
+ // 鑾峰彇鍏ュ簱鍗曚俊鎭�
+ Dt_InboundOrder inboundOrder = BaseDal.Db.Queryable<Dt_InboundOrder>()
+ .Where(x => x.OrderNo == orderNo && x.WarehouseId == warehouse.WarehouseId)
+ .Includes(x => x.Details)
+ .First();
+
+ if (inboundOrder == null || inboundOrder.Details == null || inboundOrder.Details.Count <= 0)
+ {
+ return WebResponseContent.Instance.Error($"鏈壘鍒板叆搴撳崟淇℃伅");
+ }
+
+ // 鎵归噺鏌ヨ鎵�鏈夌浉鍏崇鍙风殑CP鍏ュ簱鍗曟槑缁�
+ List<Dt_CPInboundOrderDetail> CPinboundOrderDetails = BaseDal.Db.Queryable<Dt_CPInboundOrderDetail>()
+ .LeftJoin<Dt_InboundOrderDetail>((cp, d) => cp.OrderDetailId == d.Id)
+ .LeftJoin<Dt_InboundOrder>((cp, d, o) => d.OrderId == o.Id)
+ .Where((cp, d, o) =>
+ o.OrderNo == orderNo &&
+ o.WarehouseId == warehouse.WarehouseId
+ )
+ .Select((cp, d, o) => cp)
+ .ToList();
+
+ //float totalQty = CPinboundOrderDetails.Sum(x => x.QtyOfpcs);
+
+
+ // 鎸夌収绠卞彿鍒嗙粍锛岀敤浜庡悗缁鐞�
+ var boxCodesToCheck = CPinboundOrderDetails
+ .Select(x => x.BoxCode)
+ .Where(bc => !string.IsNullOrEmpty(bc))
+ .Distinct()
+ .ToList();
+
+
+ // 3. 鏌ヨ杩欎簺绠卞彿鏄惁宸插瓨鍦ㄤ簬搴撳瓨涓�
+ var existingStockBoxCodes = _stockRepository.StockInfoRepository.Db
+ .Queryable<Dt_StockInfo>()
+ .LeftJoin<Dt_StockInfoDetail>((s, d) => s.Id == d.StockId)
+ .LeftJoin<Dt_StockInfoDetailCP>((s, d, cp) => d.Id == cp.StockDetailId)
+ .Where((s, d, cp) => boxCodesToCheck.Contains(cp.BoxCode) && !string.IsNullOrEmpty(cp.BoxCode))
+ .Select((s, d, cp) => cp.BoxCode)
+ .Distinct()
+ .ToList();
+
+ // 4. 妫�鏌ユ槸鍚︽湁閲嶅
+ if (existingStockBoxCodes.Any())
+ {
+ return WebResponseContent.Instance.Error($"浠ヤ笅绠卞彿宸插湪搴撳瓨涓細{string.Join(",", existingStockBoxCodes)}");
+ }
+
+ // 鑾峰彇鎵�鏈夌浉鍏崇殑鍏ュ簱鍗曟槑缁咺D
+ var orderDetailIds = CPinboundOrderDetails.Select(x => x.OrderDetailId).Distinct().ToList();
+
+ // 鏌ヨ瀵瑰簲鐨勫叆搴撳崟鏄庣粏
+ List<Dt_InboundOrderDetail> inboundOrderDetails = BaseDal.Db.Queryable<Dt_InboundOrderDetail>()
+ .Where(x => orderDetailIds.Contains(x.Id))
+ .ToList();
+
+ if (inboundOrderDetails.Sum(x => x.OrderQuantity) <= inboundOrderDetails.Sum(x => x.ReceiptQuantity))
+ {
+ return WebResponseContent.Instance.Error($"姝ゅ崟鎹凡鍏ㄩ儴缁勭洏瀹屾垚");
+ }
+
+ // 鎸夎鍗曟槑缁咺D鍒嗙粍锛屾鏌ユ瘡涓槑缁嗙殑鎵�鏈夌鍙锋槸鍚﹂兘鎵弿浜�
+ var detailsByOrderDetailId = CPinboundOrderDetails
+ .GroupBy(x => x.OrderDetailId)
+ .ToDictionary(g => g.Key, g => g.ToList());
+
+ // 鑾峰彇鐩稿叧鐨勮鍗曟槑缁�
+ List<Dt_InboundOrderDetail> orderDetails = new List<Dt_InboundOrderDetail>();
+ List<Dt_InboundOrderDetail> detailsToUpdate = new List<Dt_InboundOrderDetail>();
+
+ // 妫�鏌ユ瘡涓鍗曟槑缁嗘槸鍚﹀畬鎴愪簡鎵�鏈夌鍙风殑鎵弿
+ foreach (var kvp in detailsByOrderDetailId)
+ {
+ int orderDetailId = kvp.Key;
+ var cpDetails = kvp.Value;
+
+ // 鑾峰彇璁㈠崟鏄庣粏
+ var orderDetail = inboundOrder.Details.FirstOrDefault(x => x.Id == orderDetailId);
+ if (orderDetail == null)
+ {
+ orderDetail = BaseDal.Db.Queryable<Dt_InboundOrderDetail>()
+ .First(x => x.Id == orderDetailId);
+ }
+
+ if (orderDetail == null)
+ {
+ return WebResponseContent.Instance.Error($"鏈壘鍒拌鍗曟槑缁咺D锛歿orderDetailId}");
+ }
+
+ orderDetails.Add(orderDetail);
+
+ // 鏍囪璇ユ槑缁嗕负宸插畬鎴愮粍鐩�
+ orderDetail.OrderDetailStatus = OrderDetailStatusEnum.GroupAndInbound.ObjToInt();
+ var recqty = orderDetail.ReceiptQuantity;
+ float totalQty = cpDetails.Sum(item => item.QtyOfpcs);
+ orderDetail.ReceiptQuantity = (decimal)totalQty + recqty; // 鏀惰揣鏁伴噺绛変簬璁㈠崟鏁伴噺
+
+ detailsToUpdate.Add(orderDetail);
+ }
+
+
+
+ // 妫�鏌ユ墭鐩樻槸鍚﹀凡瀛樺湪
+ Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.Db
+ .Queryable<Dt_StockInfo>()
+ .Where(x => x.PalletCode == palletCode)
+ .First();
+
+ if (stockInfo == null)
+ {
+ // 鍒涘缓鏂版墭鐩�
+ stockInfo = new Dt_StockInfo()
+ {
+ BatchNo = "", // 浣跨敤鍏ュ簱鍗曟壒娆″彿
+ PalletCode = palletCode,
+ PalletType = GetPalletType(warehouse, palletCode),
+ IsFull = true,
+ StockStatus = (int)StockStatusEmun.缁勭洏鏆傚瓨,
+ Creater = "WMS",
+ CreateDate = DateTime.Now,
+ MaterialType = (int)InventoryMaterialType.鍘熸潗鏂�,
+ Materialweight = 0,
+ Wlstatus = (int)InventoryMaterialStatus.鍚堟牸,
+ Mgeneratetime = DateTime.Now,
+ WarehouseId = warehouse.WarehouseId,
+ System = inboundOrder.System,
+ Details = new List<Dt_StockInfoDetail>()
+ };
+ }
+ else
+ {
+ // 濡傛灉鎵樼洏宸插瓨鍦紝妫�鏌ユ槸鍚﹀凡缁忔槸缁勭洏鏆傚瓨鐘舵��
+ if (stockInfo.StockStatus != (int)StockStatusEmun.缁勭洏鏆傚瓨)
+ {
+ return WebResponseContent.Instance.Error($"鎵樼洏鍙烽噸澶�,璇ユ墭鐩樺凡缁勮繃鐗╂枡");
+ }
+ }
+
+ List<Dt_CPInboundOrderDetail> cPInboundOrderDetail = new List<Dt_CPInboundOrderDetail>();
+ // 鍒涘缓搴撳瓨鏄庣粏 - 鎸夎鍗曟槑缁嗗垱寤�
+ foreach (var orderDetail in orderDetails)
+ {
+ // 鑾峰彇璇ユ槑缁嗗搴旂殑鎵�鏈夌鍙�
+ var detailBoxCodes = detailsByOrderDetailId[orderDetail.Id]
+ .Select(x => x.BoxCode)
+ .ToList();
+
+ cPInboundOrderDetail = BaseDal.Db.Queryable<Dt_CPInboundOrderDetail>().Where(x => detailBoxCodes.Contains(x.BoxCode)).ToList();
+
+ List<Dt_StockInfoDetailCP> stockInfoDetailCP = new List<Dt_StockInfoDetailCP>();
+ foreach (var item in cPInboundOrderDetail)
+ {
+ Dt_StockInfoDetailCP stockInfoDetailCP1 = new Dt_StockInfoDetailCP()
+ {
+ BoxId = item.BoxId,
+ BoxCode = item.BoxCode,
+ DateCode = item.DateCode,
+ JobId = item.JobId,
+ PartNum = item.PartNum,
+ QtyOfpcs = item.QtyOfpcs,
+ QtyOfxout = item.QtyOfxout,
+ CPStockDetailStatus = (int)StockStatusEmun.缁勭洏鏆傚瓨,
+ LPNNO = item.LPNNO,
+ OrinalLocation = item.OrinalLocation,
+ Creater = "涓婃父WMS",
+ };
+ stockInfoDetailCP.Add(stockInfoDetailCP1);
+
+ item.CPOrderDetailStatus = InOrderStatusEnum.鍏ュ簱涓�.ObjToInt();
+ }
+
+ // 鍒涘缓搴撳瓨鏄庣粏
+ Dt_StockInfoDetail stockInfoDetail = new Dt_StockInfoDetail()
+ {
+ MaterielCode = orderDetail.MaterielCode,
+ MaterielName = orderDetail.MaterielName,
+ OrderNo = inboundOrder.OrderNo,
+ BatchNo = orderDetail.BatchNo,
+ SupplierBatch = orderDetail.SupplierBatch,
+ LinId = orderDetail.LinId,
+ StockQuantity = (decimal)cPInboundOrderDetail.Sum(item => item.QtyOfpcs),
+ Status = (int)StockStatusEmun.缁勭洏鏆傚瓨,
+ Creater = "WMS",
+ CreateDate = DateTime.Now,
+ Id = orderDetail.LinId.ObjToInt(),
+ //DeliveryNote = orderDetail.DeliveryNote,
+ MaterieSpec = orderDetail.MaterieSpec,
+ StockDetails = stockInfoDetailCP,
+ OrinalLocation = orderDetail.OrinalLocation
+ };
+
+ if (stockInfo.Id > 0)
+ {
+ stockInfoDetail.StockId = stockInfo.Id;
+ }
+ stockInfo.Details.Add(stockInfoDetail);
+ }
+
+ // 妫�鏌ュ叆搴撳崟鏄惁鎵�鏈夋槑缁嗛兘宸插畬鎴愮粍鐩�
+ bool allDetailsCompleted = inboundOrder.Details.All(x =>
+ detailsToUpdate.Any(d => d.Id == x.Id) ||
+ x.OrderDetailStatus == OrderDetailStatusEnum.GroupAndInbound.ObjToInt());
+
+
+
+ // 浜嬪姟澶勭悊
+ _unitOfWorkManage.BeginTran();
+ try
+ {
+ if (stockInfo.Id == 0)
+ {
+ _stockRepository.StockInfoRepository.Db.InsertNav(stockInfo)
+ .Include(x => x.Details).ThenInclude(x => x.StockDetails)
+ .ExecuteCommand();
+ }
+ else
+ {
+ _stockRepository.StockInfoRepository.Db.UpdateNav(stockInfo)
+ .Include(x => x.Details, new UpdateNavOptions()
+ {
+ OneToManyInsertOrUpdate = true
+ }).ThenInclude(x => x.StockDetails)
+ .ExecuteCommand();
+ }
+
+ // 鏇存柊璁㈠崟鏄庣粏
+ if (detailsToUpdate.Count > 0)
+ {
+ _inboundRepository.InboundOrderDetailRepository.UpdateData(detailsToUpdate);
+ }
+
+ // 鏇存柊璁㈠崟
+ _inboundRepository.InboundOrderRepository.UpdateData(inboundOrder);
+
+ _cPInboundOrderDetailRepository.UpdateData(cPInboundOrderDetail);
+
+ _unitOfWorkManage.CommitTran();
+
+ content = WebResponseContent.Instance.OK("缁勭洏鎴愬姛");
+ }
+ catch (Exception ex)
+ {
+ _unitOfWorkManage.RollbackTran();
+ throw new Exception($"缁勭洏浜嬪姟澶勭悊澶辫触锛歿ex.Message}", ex);
+ }
+ }
+ catch (Exception ex)
+ {
+ content = WebResponseContent.Instance.Error($"缁勭洏澶辫触锛歿ex.Message}");
+ }
+
+ return content;
+ }
+ #endregion
+
+ #region 寮冪敤
+ public WebResponseContent CP1MaterielGroup(SaveModel saveModel)
{
WebResponseContent content = new WebResponseContent();
try
@@ -393,7 +920,8 @@
.Select((cp, d, o) => cp)
.ToList();
- float totalQty = CPinboundOrderDetails.Sum(x => x.QtyOfpcs);
+ //float totalQty = CPinboundOrderDetails.Sum(x => x.QtyOfpcs);
+
// 楠岃瘉鏌ヨ鍒扮殑鏁版嵁鏁伴噺鏄惁鍖归厤
if (CPinboundOrderDetails.Count < serialNumbers.Count)
@@ -407,6 +935,20 @@
.ToDictionary(g => g.Key, g => g.ToList());
+ var existingStockBoxCodes = _stockRepository.StockInfoRepository.Db
+ .Queryable<Dt_StockInfo>()
+ .LeftJoin<Dt_StockInfoDetail>((s, d) => s.Id == d.StockId)
+ .LeftJoin<Dt_StockInfoDetailCP>((s, d, cp) => d.Id == cp.StockDetailId)
+ .Where((s, d, cp) =>
+ serialNumbers.Contains(cp.BoxCode))
+ .Select((s, d, cp) => cp.BoxCode)
+ .Distinct()
+ .ToList();
+
+ if (existingStockBoxCodes.Any())
+ {
+ return WebResponseContent.Instance.Error($"浠ヤ笅绠卞彿宸插湪搴撳瓨涓細{string.Join(",", existingStockBoxCodes)}");
+ }
// 鑾峰彇鎵�鏈夌浉鍏崇殑鍏ュ簱鍗曟槑缁咺D
var orderDetailIds = CPinboundOrderDetails.Select(x => x.OrderDetailId).Distinct().ToList();
@@ -415,6 +957,11 @@
List<Dt_InboundOrderDetail> inboundOrderDetails = BaseDal.Db.Queryable<Dt_InboundOrderDetail>()
.Where(x => orderDetailIds.Contains(x.Id))
.ToList();
+
+ if (inboundOrderDetails.Sum(x => x.OrderQuantity) <= inboundOrderDetails.Sum(x => x.ReceiptQuantity))
+ {
+ return WebResponseContent.Instance.Error($"姝ゅ崟鎹凡鍏ㄩ儴缁勭洏瀹屾垚");
+ }
// 鎸夎鍗曟槑缁咺D鍒嗙粍锛屾鏌ユ瘡涓槑缁嗙殑鎵�鏈夌鍙锋槸鍚﹂兘鎵弿浜�
var detailsByOrderDetailId = CPinboundOrderDetails
@@ -449,16 +996,18 @@
// 鏍囪璇ユ槑缁嗕负宸插畬鎴愮粍鐩�
orderDetail.OrderDetailStatus = OrderDetailStatusEnum.GroupAndInbound.ObjToInt();
var recqty = orderDetail.ReceiptQuantity;
- orderDetail.ReceiptQuantity = ((decimal)totalQty) + recqty; // 鏀惰揣鏁伴噺绛変簬璁㈠崟鏁伴噺
+ float totalQty = cpDetails.Sum(item => item.QtyOfpcs);
+ orderDetail.ReceiptQuantity = (decimal)totalQty + recqty; // 鏀惰揣鏁伴噺绛変簬璁㈠崟鏁伴噺
detailsToUpdate.Add(orderDetail);
}
+
+
// 妫�鏌ユ墭鐩樻槸鍚﹀凡瀛樺湪
Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.Db
.Queryable<Dt_StockInfo>()
.Where(x => x.PalletCode == palletCode)
- .Includes(x => x.Details)
.First();
if (stockInfo == null)
@@ -478,6 +1027,7 @@
Wlstatus = (int)InventoryMaterialStatus.鍚堟牸,
Mgeneratetime = DateTime.Now,
WarehouseId = warehouse.WarehouseId,
+ System = inboundOrder.System,
Details = new List<Dt_StockInfoDetail>()
};
}
@@ -490,6 +1040,7 @@
}
}
+ List<Dt_CPInboundOrderDetail> cPInboundOrderDetail = new List<Dt_CPInboundOrderDetail>();
// 鍒涘缓搴撳瓨鏄庣粏 - 鎸夎鍗曟槑缁嗗垱寤�
foreach (var orderDetail in orderDetails)
{
@@ -498,7 +1049,8 @@
.Select(x => x.BoxCode)
.ToList();
- List<Dt_CPInboundOrderDetail> cPInboundOrderDetail = BaseDal.Db.Queryable<Dt_CPInboundOrderDetail>().Where(x => detailBoxCodes.Contains(x.BoxCode)).ToList();
+ cPInboundOrderDetail = BaseDal.Db.Queryable<Dt_CPInboundOrderDetail>().Where(x => detailBoxCodes.Contains(x.BoxCode)).ToList();
+
List<Dt_StockInfoDetailCP> stockInfoDetailCP = new List<Dt_StockInfoDetailCP>();
foreach (var item in cPInboundOrderDetail)
{
@@ -528,14 +1080,15 @@
BatchNo = orderDetail.BatchNo,
SupplierBatch = orderDetail.SupplierBatch,
LinId = orderDetail.LinId,
- StockQuantity = ((decimal)totalQty),
+ StockQuantity = (decimal)cPInboundOrderDetail.Sum(item => item.QtyOfpcs),
Status = (int)StockStatusEmun.缁勭洏鏆傚瓨,
Creater = "WMS",
CreateDate = DateTime.Now,
Id = orderDetail.LinId.ObjToInt(),
//DeliveryNote = orderDetail.DeliveryNote,
MaterieSpec = orderDetail.MaterieSpec,
- StockDetails = stockInfoDetailCP
+ StockDetails = stockInfoDetailCP,
+ OrinalLocation = orderDetail.OrinalLocation
};
if (stockInfo.Id > 0)
@@ -581,7 +1134,7 @@
// 鏇存柊璁㈠崟
_inboundRepository.InboundOrderRepository.UpdateData(inboundOrder);
- _cPInboundOrderDetailRepository.UpdateData(CPinboundOrderDetails);
+ _cPInboundOrderDetailRepository.UpdateData(cPInboundOrderDetail);
_unitOfWorkManage.CommitTran();
@@ -600,11 +1153,170 @@
return content;
}
+ #endregion
+
+ public string ReceiveWMSTaskin = WIDESEA_Core.Helper.AppSettings.Configuration["ReceiveWMSTaskin"];
+
+ /// <summary>
+ /// 缁勭洏鍚堟墭
+ /// </summary>
+ /// <param name="saveModel"></param>
+ /// <returns></returns>
+ public WebResponseContent SYMaterielGroup(SaveModel saveModel)
+ {
+
+ WebResponseContent webResponseContent = new WebResponseContent();
+ try
+ {
+ var soussAddress = saveModel.MainData["soussAddress"];
+ var targetAddress = saveModel.MainData["targetAddress"];
+
+ Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Includes(x => x.Details).Where(x => x.PalletCode == soussAddress).First();
+ Dt_StockInfo targetstockInfo = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Includes(x => x.Details).Where(x => x.PalletCode == targetAddress).First();
+ Dt_Warehouse warehouse = _warehouseService.Repository.QueryFirst(x => x.WarehouseId == targetstockInfo.WarehouseId);
+ if (stockInfo == null || targetstockInfo == null)
+ {
+ throw new Exception("搴撳瓨鏈壘鍒版墭鐩樺彿");
+ }
+
+ var sameItems = from sourceItem in stockInfo.Details
+ join targetItem in targetstockInfo.Details
+ on new
+ {
+ sourceItem.BatchNo,
+ sourceItem.MaterielName,
+ sourceItem.MaterielCode
+ }
+ equals new
+ {
+ targetItem.BatchNo,
+ targetItem.MaterielName,
+ targetItem.MaterielCode
+ }
+ select new
+ {
+ SourceItem = sourceItem,
+ TargetItem = targetItem,
+ BatchNo = sourceItem.BatchNo,
+ MaterialCode = sourceItem.MaterielCode,
+ MaterialType = sourceItem.MaterielName
+ };
+
+ var matchedSourceItemIds = sameItems.Select(x => x.SourceItem.Id).ToList();
+
+ foreach (var item in stockInfo.Details)
+ {
+ if (!matchedSourceItemIds.Contains(item.Id))
+ {
+ item.StockId = targetstockInfo.Id;
+ }
+ }
+ var differentItems = stockInfo.Details
+ .Where(x => !matchedSourceItemIds.Contains(x.Id))
+ .ToList();
+ targetstockInfo.Details = targetstockInfo.Details
+ .Where(x => !matchedSourceItemIds.Contains(x.Id))
+ .Concat(differentItems)
+ .ToList();
+ if (warehouse.WarehouseCode == "SC02_CP")
+ {
+ warehouse.WarehouseCode = "SC01_CP";
+ }
+ if (warehouse.WarehouseCode == "SC02_BC")
+ {
+ warehouse.WarehouseCode = "SC01_BC";
+ }
+ var houseSyncretism = new HouseSyncretism
+ {
+ ApiType = "InventoryMoveController",
+ Method = "AsrsSubmitMoveDatas",
+
+ Parameters = new List<HouseSyncretism.Parame>
+ {
+ new HouseSyncretism.Parame {
+ Value = stockInfo.Details.Select(g => new Parame.Syncretism
+ {
+ Lpn = stockInfo.PalletCode,
+ MoveType = 0,
+ WareHouseCode = warehouse.WarehouseCode,
+ ItemCode = g.MaterielCode,
+ MoveNumber = g.StockQuantity,
+ LotNo = g.BatchNo,
+ WipBatch = g.BatchNo,
+ LocationName = stockInfo.LocationCode,
+ TargetLocName = targetstockInfo.LocationCode,
+ TargetLpn = targetstockInfo.PalletCode,
+
+ }).ToList()
+ }
+ }
+ };
+ var authResult = AuthenticateWithWMS();
+ if (authResult.IsSuccess)
+ {
+ houseSyncretism.Context = new Dictionary<string, string>
+ {
+ { "Ticket", authResult.Ticket },
+ { "InvOrgId", authResult.InvOrgId }
+
+ };
+
+ var response = HttpHelper.Post<MomRequestContent>(ReceiveWMSTaskin, houseSyncretism, "绔嬪簱鍏ュ簱鏁伴噺鍥炰紶WMS");
+ if (!response.Success)
+ {
+ throw new Exception($"鎿嶄綔澶辫触: {response.Message ?? "鏈彁渚涢敊璇俊鎭�"}");
+ }
+
+ }
+ _unitOfWorkManage.BeginTran();
+ foreach (var sameItem in sameItems)
+ {
+ sameItem.TargetItem.StockQuantity += sameItem.SourceItem.StockQuantity;
+ _stockRepository.StockInfoDetailRepository.UpdateData(sameItem.TargetItem);
+ _stockRepository.StockInfoDetailRepository.DeleteData(sameItem.SourceItem);
+ }
+ _stockRepository.StockInfoRepository.UpdateData(targetstockInfo);
+ _stockRepository.StockInfoDetailRepository.UpdateData(targetstockInfo.Details);
+ _stockRepository.StockInfoRepository.DeleteData(stockInfo);
+
+ _unitOfWorkManage.CommitTran();
+ webResponseContent = WebResponseContent.Instance.OK("鍚堟墭鎴愬姛");
+ }
+ catch (Exception ex)
+ {
+ _unitOfWorkManage.RollbackTran();
+ webResponseContent = WebResponseContent.Instance.Error($"缁勭洏澶辫触锛歿ex.Message}");
+ }
+ return webResponseContent;
+ }
+
+ private (bool IsSuccess, string Ticket, string InvOrgId) AuthenticateWithWMS()
+ {
+ var authentication = new Authentication
+ {
+ ApiType = "AuthenticationController",
+ Parameters = new List<Parameter>
+ {
+ new Parameter { Value = "LK-Admin" },
+ new Parameter { Value = "LK-Admin" }
+ },
+ Method = "Login",
+ };
+
+ var response = HttpHelper.Post<WebResponseContent>(ReceiveWMSTaskin, authentication, "鐧诲綍WMS璐﹀彿");
+
+ if (response.Context != null)
+ {
+ return (true, response.Context["Ticket"].ToString(), response.Context["InvOrgId"].ToString());
+ }
+
+ return (false, null, null);
+ }
+
public int GetPalletType(Dt_Warehouse warehouse, string palletCode)
{
-
- if (warehouse.WarehouseCode == WarehouseEnum.SC01_BC.ObjToString())
+ if (warehouse.WarehouseCode.Contains("BC"))
{
Dt_PalletTypeInfo palletTypeInfo = _palletTypeInfoRepository.QueryFirst(x => x.CodeStartStr == palletCode.Substring(0, 3));
if (palletTypeInfo == null)
@@ -613,34 +1325,16 @@
}
return palletTypeInfo.PalletType;
}
- //else if (warehouse.WarehouseCode == WarehouseEnum.HA152.ObjToString())
- //{
- // Dt_PalletTypeInfo palletTypeInfo = _palletTypeInfoRepository.QueryFirst(x => x.CodeStartStr == palletCode.Substring(0, 2));
- // if (palletTypeInfo == null)
- // {
- // throw new Exception($"鎵樼洏鍙烽敊璇�");
- // }
- // return palletTypeInfo.PalletType;
- //}
- //else if (warehouse.WarehouseCode == WarehouseEnum.HA57.ObjToString())
- //{
- // Dt_PalletTypeInfo palletTypeInfo = _palletTypeInfoRepository.QueryFirst(x => x.CodeStartStr == palletCode.Substring(0, 3));
- // if (palletTypeInfo == null)
- // {
- // throw new Exception($"鎵樼洏鍙烽敊璇�");
- // }
- // return palletTypeInfo.PalletType;
- //}
- //else if (warehouse.WarehouseCode == WarehouseEnum.HA58.ObjToString())
- //{
- // Dt_PalletTypeInfo palletTypeInfo = _palletTypeInfoRepository.QueryFirst(x => x.CodeStartStr == palletCode.Substring(0, 2));
- // if (palletTypeInfo == null)
- // {
- // throw new Exception($"鎵樼洏鍙烽敊璇�");
- // }
- // return palletTypeInfo.PalletType;
- //}
- return -1;
+ else
+ {
+ Dt_PalletTypeInfo palletTypeInfo = _palletTypeInfoRepository.QueryFirst(x => x.CodeStartStr == palletCode.Substring(0, 2));
+ if (palletTypeInfo == null)
+ {
+ throw new Exception($"鎵樼洏鍙烽敊璇�");
+ }
+ return palletTypeInfo.PalletType;
+ }
+ return 0;
}
/// <summary>
/// 鍒ゆ柇姝g‘鏃堕棿鏍煎紡
@@ -714,10 +1408,6 @@
}
if (warehouse.WarehouseCode.Contains("CP"))
{
- if (item.SupplierBatch == null)
- {
- return content.Error("渚涘簲鍟嗘壒娆′笉鍙负绌�");
- }
Dt_InboundOrder inboundOrderOld = BaseDal.Db.Queryable<Dt_InboundOrder>().Where(x => x.UpperOrderNo == model.AsnNo).Includes(x => x.Details).First();
if (inboundOrderOld != null)
@@ -736,6 +1426,26 @@
}
else
{
+ List<Dt_CPInboundOrderDetail> cPInboundOrderDetail = new List<Dt_CPInboundOrderDetail>();
+ foreach (var list in item.BoxList)
+ {
+ Dt_CPInboundOrderDetail cPInboundOrderDetail1 = new Dt_CPInboundOrderDetail()
+ {
+ BoxId = (float)list.BoxId,
+ BoxCode = list.BoxCode,
+ DateCode = list.DateCode,
+ JobId = (float)list.JobId,
+ PartNum = list.PartNum,
+ QtyOfpcs = (float)list.QtyOfpcs,
+ QtyOfxout = (float)list.QtyOfxout,
+ CPOrderDetailStatus = OrderDetailStatusEnum.New.ObjToInt(),
+ LPNNO = list.LPNNO,
+ OrinalLocation = list.OrinalLocation,
+ Creater = "涓婃父WMS",
+ };
+ cPInboundOrderDetail.Add(cPInboundOrderDetail1);
+ }
+
Dt_InboundOrderDetail orderDetail = new Dt_InboundOrderDetail()
{
OrderId = orderDetail1.OrderId,
@@ -750,9 +1460,12 @@
MaterielName = item.MaterielName,
MaterieSpec = item.MaterieSpec,
Creater = "涓婃父WMS",
- SupplierBatch = item.SupplierBatch
+ SupplierBatch = item.SupplierBatch,
+ OrinalLocation = item.OrinalLocation,
+ CPDetails = cPInboundOrderDetail
};
- _inboundRepository.InboundOrderDetailRepository.AddData(orderDetail);
+ //_inboundRepository.InboundOrderDetailRepository.AddData(orderDetail);
+ Db.InsertNav(orderDetail).Include(x => x.CPDetails).ExecuteCommand();
}
}
else
@@ -770,6 +1483,8 @@
QtyOfpcs = (float)list.QtyOfpcs,
QtyOfxout = (float)list.QtyOfxout,
CPOrderDetailStatus = OrderDetailStatusEnum.New.ObjToInt(),
+ LPNNO = list.LPNNO,
+ OrinalLocation = list.OrinalLocation,
Creater = "涓婃父WMS",
};
cPInboundOrderDetail.Add(cPInboundOrderDetail1);
@@ -789,9 +1504,9 @@
MaterieSpec = item.MaterieSpec,
Creater = "涓婃父WMS",
SupplierBatch = item.SupplierBatch,
+ OrinalLocation = item.OrinalLocation,
CPDetails = cPInboundOrderDetail
};
-
Dt_InboundOrder inboundOrder = new Dt_InboundOrder()
{
OrderNo = model.AsnNo,
@@ -829,10 +1544,10 @@
}
else
{
- if (item.SupplierBatch == null)
- {
- return content.Error("渚涘簲鍟嗘壒娆′笉鍙负绌�");
- }
+ //if (item.SupplierBatch == null)
+ //{
+ // return content.Error("渚涘簲鍟嗘壒娆′笉鍙负绌�");
+ //}
Dt_InboundOrder inboundOrderOld = BaseDal.Db.Queryable<Dt_InboundOrder>().Where(x => x.UpperOrderNo == model.AsnNo).Includes(x => x.Details).First();
if (inboundOrderOld != null)
@@ -847,6 +1562,7 @@
if (inboundOrderDetailOld != null)
{
inboundOrderDetailOld.OrderQuantity += item.OrderQuantity;
+ inboundOrderDetailOld.OrderDetailStatus = OrderDetailStatusEnum.Inbounding.ObjToInt();
_inboundRepository.InboundOrderDetailRepository.UpdateData(inboundOrderDetailOld);
}
else
@@ -855,6 +1571,7 @@
{
OrderId = orderDetail1.OrderId,
MaterielCode = item.MaterielCode,
+ MaterielType = item.MaterielType,
BatchNo = item.BatchNo,
OrderQuantity = item.OrderQuantity,
ReceiptQuantity = 0,
@@ -874,6 +1591,7 @@
{
Dt_InboundOrderDetail orderDetail = new Dt_InboundOrderDetail()
{
+ MaterielType = item.MaterielType,
MaterielCode = item.MaterielCode,
BatchNo = item.BatchNo,
OrderQuantity = item.OrderQuantity,
@@ -904,46 +1622,12 @@
System = model.System,
Details = new List<Dt_InboundOrderDetail> { orderDetail }
};
- //switch (model.OrderType)//鍗曟嵁绫诲瀷
- //{
- // case 1:
- // inboundOrder.OrderType = InOrderTypeEnum.Allocat.ObjToInt();
- // break;
- // case 3:
- // inboundOrder.OrderType = InOrderTypeEnum.CustomerRecovery.ObjToInt();
- // break;
- // case 6:
- // inboundOrder.OrderType = InOrderTypeEnum.SaleReturn.ObjToInt();
- // break;
- // default:
- // break;
- //};
Db.InsertNav(inboundOrder).Include(x => x.Details).ExecuteCommand();
-
}
}
}
_unitOfWorkManage.CommitTran();
content = WebResponseContent.Instance.OK();
- //InboundOrderAddDTO orderAddDTO1 = new InboundOrderAddDTO();
- //orderAddDTO1.OrderNo = orderAddDTO.AsnNo;
- //orderAddDTO1.UpperOrderNo = orderAddDTO.AsnNo;
- //orderAddDTO1.OutWareHouse = orderAddDTO.InWarehouse;
- //orderAddDTO1.TransactionCode = orderAddDTO.TransactionCode;
- //orderAddDTO1.InoutType = orderAddDTO.OrderType;
- //orderAddDTO1.OrderType = orderAddDTO.InoutType.ObjToInt();
- //orderAddDTO1.Details = orderAddDTO.DetailList.DicToIEnumerable<InboundOrderDetailAddDTO>();
- //#region 楠岃瘉鏁版嵁
- //(bool, string, object?) result = CheckInboundOrderAddData(orderAddDTO1);
- //if (!result.Item1) return content = WebResponseContent.Instance.Error(result.Item2);
- //#endregion
-
- //Dt_InboundOrder inboundOrder = _mapper.Map<Dt_InboundOrder>(orderAddDTO1);
- //inboundOrder.OrderStatus = InboundStatusEnum.鏈紑濮�.ObjToInt();
- //inboundOrder.Creater = "WMS";
- //inboundOrder.CreateDate = DateTime.Now;
- //bool a = BaseDal.Db.InsertNav(inboundOrder).Include(x => x.Details).ExecuteCommand();
-
}
catch (Exception ex)
{
@@ -1079,17 +1763,26 @@
{
int pageNo = saveModel.MainData["pageNo"].ObjToInt();
string? orderNo = saveModel.MainData["orderNo"].ToString();
- int warehouseId = saveModel.MainData["warehouseId"].ObjToInt();
+ int warehouseId = saveModel.MainData["warehouseId"].ObjToInt();
List<Dt_InboundOrder> dt_ReceiveOrders = new List<Dt_InboundOrder>();
if (string.IsNullOrEmpty(orderNo))
{
- dt_ReceiveOrders = Db.Queryable<Dt_InboundOrder>().Where(x => x.OrderStatus < InboundStatusEnum.鍏ュ簱瀹屾垚.ObjToInt() && x.WarehouseId == warehouseId).Includes(x => x.Details).OrderByDescending(x => x.CreateDate).ToPageList(pageNo, 10);
+ dt_ReceiveOrders = Db.Queryable<Dt_InboundOrder>().Where(x => x.OrderStatus < InboundStatusEnum.鍏ュ簱瀹屾垚.ObjToInt() && x.WarehouseId == warehouseId).Includes(x => x.Details).OrderByDescending(x => x.CreateDate).ToPageList(pageNo, 50);
}
else
{
- dt_ReceiveOrders = Db.Queryable<Dt_InboundOrder>().Where(x => (x.OrderNo.Contains(orderNo)) && x.OrderStatus < InboundStatusEnum.鍏ュ簱瀹屾垚.ObjToInt() && x.WarehouseId == warehouseId).Includes(x => x.Details).OrderByDescending(x => x.CreateDate).ToPageList(pageNo, 10);
+ dt_ReceiveOrders = Db.Queryable<Dt_InboundOrder>().Where(x => (x.OrderNo.Contains(orderNo)) && x.OrderStatus < InboundStatusEnum.鍏ュ簱瀹屾垚.ObjToInt() && x.WarehouseId == warehouseId).Includes(x => x.Details).OrderByDescending(x => x.CreateDate).ToPageList(pageNo, 50);
}
-
+ if(dt_ReceiveOrders == null || dt_ReceiveOrders.Count == 0)
+ {
+ List<int> orderNos = _inboundOrderDetailService.Db.Queryable<Dt_InboundOrderDetail>().Where(x => x.MaterielCode.Contains(orderNo)).Select(x => x.OrderId).Distinct().ToList();
+ foreach (var item in orderNos)
+ {
+ Dt_InboundOrder inboundOrders = Db.Queryable<Dt_InboundOrder>().Where(x => (x.Id == item) && x.OrderStatus < InboundStatusEnum.鍏ュ簱瀹屾垚.ObjToInt() && x.WarehouseId == warehouseId).Includes(x => x.Details).OrderByDescending(x => x.CreateDate).First();
+ dt_ReceiveOrders.Add(inboundOrders);
+ }
+ }
+
content.OK(data: dt_ReceiveOrders);
}
catch (Exception ex)
@@ -1098,7 +1791,11 @@
}
return content;
}
-
+ /// <summary>
+ /// erp鍗曟嵁涓嬪彂
+ /// </summary>
+ /// <param name="addInboundOrder"></param>
+ /// <returns></returns>
public WebResponseContent Save(AddInboundOrderModel addInboundOrder)
{
try
--
Gitblit v1.9.3