From 1d685ca799f0b50ad63336963511cbbf21ab2e4c Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期四, 18 十二月 2025 09:41:53 +0800
Subject: [PATCH] 需求优化
---
项目代码/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Inbound.cs | 316 +++++++++++++++++++++++++++++++++++++---------------
1 files changed, 226 insertions(+), 90 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Inbound.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Inbound.cs"
index 5d9e50b..e20a855 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Inbound.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Inbound.cs"
@@ -405,98 +405,200 @@
}
if (orderType>0) //鏂板巶绾稿嵎骞冲彴鍏ュ簱
{
- //鑾峰彇涓诲崟
- Dt_InboundOrder inboundOrder = BaseDal.Db.Queryable<Dt_InboundOrder>().Where(x=>x.OrderType==orderType).Includes(x=>x.Details).Where(x=>x.Details.Any(v=>v.BarCode==palletCode)).First();
- if (inboundOrder==null)
+ InOrderTypeEnum inOrderTypeEnum = (InOrderTypeEnum)orderType;
+ if (inOrderTypeEnum== InOrderTypeEnum.PurchaseIn)
{
- throw new Exception($"鏈壘鍒版潯鐮亄palletCode}鍏ュ簱鍗曟嵁淇℃伅");
- }
- Dt_InboundOrderDetail inboundOrderDetail = inboundOrder.Details.FirstOrDefault(x=>x.BarCode == palletCode);
- if (inboundOrderDetail==null)
- {
- throw new Exception($"鏈壘鍒板叆搴撳崟鍙蜂负{inboundOrder.UpperOrderNo}鏉$爜{palletCode}鍗曟嵁淇℃伅");
- }
- if (inboundOrderDetail.MaterialWide < 690)
- {
- return content.Error("鏂板巶鐗╂枡骞呭闄愬埗涓�690-2700mm");
- }
- if (inboundOrderDetail.MaterialThick<=0)
- {
- return content.Error("鐗╂枡鐩村緞闇�瑕佸ぇ浜�0");
- }
- if (inboundOrderDetail.OrderDetailStatus != InOrderStatusEnum.鏈紑濮�.ObjToInt())
- {
- throw new Exception($"鏉$爜{palletCode}淇℃伅宸插叆搴撴垨鍏ュ簱涓�");
- }
- Dt_YLInboundCache? yLInboundCache = _inboundRepository.YLInboundCacheRepository.QueryData(x => x.InvOrg == MaterielInvOrgEnum.鏂板巶.ToString()).FirstOrDefault();
- if (yLInboundCache == null)
- {
- throw new Exception("鏈壘鍒板師鏂欐潯鐮佺紦瀛樹俊鎭�");
- }
- int Id = yLInboundCache.Id;
- if (yLInboundCache.BarCode == palletCode)
- {
- throw new Exception($"鏉$爜{palletCode}宸叉壂鐮�");
- }
- else if (yLInboundCache.BarCode != palletCode && yLInboundCache.BindStatus == WhetherEnum.True.ObjToInt())
- {
- yLInboundCache = _mapper.Map<Dt_YLInboundCache>(inboundOrderDetail);
- yLInboundCache.Id = Id;
+ //鑾峰彇涓诲崟
+ Dt_PurchaseOrder inboundOrder = BaseDal.Db.Queryable<Dt_PurchaseOrder>().Includes(x => x.Details).Where(x => x.Details.Any(v => v.BarCode == palletCode)).First();
- //鑾峰彇鐗╂枡
- Dt_MaterielInfo materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x => x.MaterielCode == inboundOrderDetail.MaterialCode);
- //鐢熸垚搴撳瓨缁勭洏淇℃伅
- Dt_StockInfo stockInfo = new Dt_StockInfo()
+ if (inboundOrder == null)
{
- MaterielInvOrgId = materielInfo.MaterielInvOrgId,
- PalletCode = inboundOrderDetail.BarCode,
- RfidCode = "",
- LocationCode = "",
- PalletType = 1,
- WarehouseId = materielInfo.WarehouseId,
- StockAttribute = materielInfo.MaterielSourceType,
- StockStatus = StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt(),
- MaterielSpec = materielInfo.MaterielSpec,
- Unit = materielInfo.MaterielUnit,
- MaterielThickness = inboundOrderDetail.MaterialThick,
- MaterielWide = inboundOrderDetail.MaterialWide,
- MaterielWeight = inboundOrderDetail.MaterialWeight,
- MaterielCode = materielInfo.MaterielCode,
- MaterielName = materielInfo.MaterielName,
- BatchNo=inboundOrderDetail.MaterialLot,
- StockLength = inboundOrderDetail.OrderQuantity
- };
- if (inboundOrderDetail.MaterialWide > 1200)
- {
- stockInfo.PalletType = 2;
+ throw new Exception($"鏈壘鍒版潯鐮亄palletCode}閲囪喘鍏ュ簱鍗曟嵁淇℃伅");
}
- inboundOrderDetail.OrderDetailStatus = InOrderStatusEnum.鍏ュ簱涓�.ObjToInt();
- _unitOfWorkManage.BeginTran();
- _inboundRepository.YLInboundCacheRepository.UpdateData(yLInboundCache);
- //鏂板缁勭洏淇℃伅
- _stockRepository.StockInfoRepository.AddData(stockInfo);
- if (inboundOrder.InboundOrderStatus == InOrderStatusEnum.鏈紑濮�.ObjToInt())
+ Dt_PurchaseOrderDetail inboundOrderDetail = inboundOrder.Details.FirstOrDefault(x => x.BarCode == palletCode);
+
+ if (inboundOrderDetail == null)
{
- inboundOrder.InboundOrderStatus = InOrderStatusEnum.鍏ュ簱涓�.ObjToInt();
- _inboundRepository.InboundOrderRepository.UpdateData(inboundOrder);
+ throw new Exception($"鏈壘鍒板叆搴撳崟鍙蜂负{inboundOrder.PurchaseOrderNo}鏉$爜{palletCode}鍗曟嵁淇℃伅");
}
- _inboundRepository.InboundOrderDetailRepository.UpdateData(inboundOrderDetail);
- //鍚姩绾夸綋
- WebResponseContent webResponse = YLPurchasePush();
- if (!webResponse.Status)
+ if (inboundOrderDetail.PurchaseDetailWide < 690)
{
- throw new Exception(webResponse.Message);
+ return content.Error("鏂板巶鐗╂枡骞呭闄愬埗涓�690-2700mm");
}
- _unitOfWorkManage.CommitTran();
- Dt_StockInfo stockInfoAdd = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == stockInfo.PalletCode);
- //璁板綍搴撳瓨鍙樺姩
- _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfoAdd, 0, stockInfoAdd.StockLength, StockChangeTypeEnum.MaterielGroup);
- return content.OK("鎴愬姛", yLInboundCache);
+ if (inboundOrderDetail.PurchaseDetailThickness <= 0)
+ {
+ return content.Error("鐗╂枡鐩村緞闇�瑕佸ぇ浜�0");
+ }
+ if (inboundOrderDetail.PurchaseDetailStatus != InOrderStatusEnum.鏈紑濮�.ObjToInt())
+ {
+ throw new Exception($"鏉$爜{palletCode}淇℃伅宸插叆搴撴垨鍏ュ簱涓�");
+ }
+ Dt_YLInboundCache? yLInboundCache = _inboundRepository.YLInboundCacheRepository.QueryData(x => x.InvOrg == MaterielInvOrgEnum.鏂板巶.ToString()).FirstOrDefault();
+ if (yLInboundCache == null)
+ {
+ throw new Exception("鏈壘鍒板師鏂欐潯鐮佺紦瀛樹俊鎭�");
+ }
+ int Id = yLInboundCache.Id;
+ if (yLInboundCache.BarCode == palletCode)
+ {
+ throw new Exception($"鏉$爜{palletCode}宸叉壂鐮�");
+ }
+ else if (yLInboundCache.BarCode != palletCode && yLInboundCache.BindStatus == WhetherEnum.True.ObjToInt())
+ {
+ yLInboundCache = _mapper.Map<Dt_YLInboundCache>(inboundOrderDetail);
+ yLInboundCache.Id = Id;
+
+ //鑾峰彇鐗╂枡
+ Dt_MaterielInfo materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x => x.MaterielCode == inboundOrderDetail.MaterialCode);
+ //鐢熸垚搴撳瓨缁勭洏淇℃伅
+ Dt_StockInfo stockInfo = new Dt_StockInfo()
+ {
+ MaterielInvOrgId = materielInfo.MaterielInvOrgId,
+ PalletCode = inboundOrderDetail.BarCode,
+ RfidCode = "",
+ LocationCode = "",
+ PalletType = 1,
+ WarehouseId = materielInfo.WarehouseId,
+ StockAttribute = materielInfo.MaterielSourceType,
+ StockStatus = StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt(),
+ MaterielSpec = materielInfo.MaterielSpec,
+ Unit = materielInfo.MaterielUnit,
+ MaterielThickness = inboundOrderDetail.PurchaseDetailThickness,
+ MaterielWide = inboundOrderDetail.PurchaseDetailWide,
+ MaterielWeight = inboundOrderDetail.PurchaseDetailWeight,
+ MaterielCode = materielInfo.MaterielCode,
+ MaterielName = materielInfo.MaterielName,
+ BatchNo = inboundOrderDetail.MaterialLot,
+ StockLength = inboundOrderDetail.PurchaseDetailQuantity
+ };
+ if (inboundOrderDetail.PurchaseDetailWide > 1200)
+ {
+ stockInfo.PalletType = 2;
+ }
+ inboundOrderDetail.PurchaseDetailStatus = InOrderStatusEnum.鍏ュ簱涓�.ObjToInt();
+ _unitOfWorkManage.BeginTran();
+ _inboundRepository.YLInboundCacheRepository.UpdateData(yLInboundCache);
+ //鏂板缁勭洏淇℃伅
+ _stockRepository.StockInfoRepository.AddData(stockInfo);
+ if (inboundOrder.PurchaseOrderStatus == InOrderStatusEnum.鏈紑濮�.ObjToInt())
+ {
+ inboundOrder.PurchaseOrderStatus = InOrderStatusEnum.鍏ュ簱涓�.ObjToInt();
+ _inboundRepository.PurchaseOrderRepository.UpdateData(inboundOrder);
+ }
+ _inboundRepository.PurchaseOrderDetailRepository.UpdateData(inboundOrderDetail);
+ //鍚姩绾夸綋
+ WebResponseContent webResponse = YLPurchasePush();
+ if (!webResponse.Status)
+ {
+ throw new Exception(webResponse.Message);
+ }
+ _unitOfWorkManage.CommitTran();
+ Dt_StockInfo stockInfoAdd = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == stockInfo.PalletCode);
+ //璁板綍搴撳瓨鍙樺姩
+ _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfoAdd, 0, stockInfoAdd.StockLength, StockChangeTypeEnum.MaterielGroup);
+ return content.OK("鎴愬姛", yLInboundCache);
+ }
+ else
+ {
+ throw new Exception($"涓婂嵎鏉$爜{yLInboundCache.BarCode}杩樻湭杩涜缁戝畾");
+ }
}
else
{
- throw new Exception($"涓婂嵎鏉$爜{yLInboundCache.BarCode}杩樻湭杩涜缁戝畾");
+ //鑾峰彇涓诲崟
+ Dt_InboundOrder inboundOrder = BaseDal.Db.Queryable<Dt_InboundOrder>().Where(x => x.OrderType == orderType).Includes(x => x.Details).Where(x => x.Details.Any(v => v.BarCode == palletCode)).First();
+ if (inboundOrder == null)
+ {
+ throw new Exception($"鏈壘鍒版潯鐮亄palletCode}鍏ュ簱鍗曟嵁淇℃伅");
+ }
+ Dt_InboundOrderDetail inboundOrderDetail = inboundOrder.Details.FirstOrDefault(x => x.BarCode == palletCode);
+ if (inboundOrderDetail == null)
+ {
+ throw new Exception($"鏈壘鍒板叆搴撳崟鍙蜂负{inboundOrder.UpperOrderNo}鏉$爜{palletCode}鍗曟嵁淇℃伅");
+ }
+ if (inboundOrderDetail.MaterialWide < 690)
+ {
+ return content.Error("鏂板巶鐗╂枡骞呭闄愬埗涓�690-2700mm");
+ }
+ if (inboundOrderDetail.MaterialThick <= 0)
+ {
+ return content.Error("鐗╂枡鐩村緞闇�瑕佸ぇ浜�0");
+ }
+ if (inboundOrderDetail.OrderDetailStatus != InOrderStatusEnum.鏈紑濮�.ObjToInt())
+ {
+ throw new Exception($"鏉$爜{palletCode}淇℃伅宸插叆搴撴垨鍏ュ簱涓�");
+ }
+ Dt_YLInboundCache? yLInboundCache = _inboundRepository.YLInboundCacheRepository.QueryData(x => x.InvOrg == MaterielInvOrgEnum.鏂板巶.ToString()).FirstOrDefault();
+ if (yLInboundCache == null)
+ {
+ throw new Exception("鏈壘鍒板師鏂欐潯鐮佺紦瀛樹俊鎭�");
+ }
+ int Id = yLInboundCache.Id;
+ if (yLInboundCache.BarCode == palletCode)
+ {
+ throw new Exception($"鏉$爜{palletCode}宸叉壂鐮�");
+ }
+ else if (yLInboundCache.BarCode != palletCode && yLInboundCache.BindStatus == WhetherEnum.True.ObjToInt())
+ {
+ yLInboundCache = _mapper.Map<Dt_YLInboundCache>(inboundOrderDetail);
+ yLInboundCache.Id = Id;
+
+ //鑾峰彇鐗╂枡
+ Dt_MaterielInfo materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x => x.MaterielCode == inboundOrderDetail.MaterialCode);
+ //鐢熸垚搴撳瓨缁勭洏淇℃伅
+ Dt_StockInfo stockInfo = new Dt_StockInfo()
+ {
+ MaterielInvOrgId = materielInfo.MaterielInvOrgId,
+ PalletCode = inboundOrderDetail.BarCode,
+ RfidCode = "",
+ LocationCode = "",
+ PalletType = 1,
+ WarehouseId = materielInfo.WarehouseId,
+ StockAttribute = materielInfo.MaterielSourceType,
+ StockStatus = StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt(),
+ MaterielSpec = materielInfo.MaterielSpec,
+ Unit = materielInfo.MaterielUnit,
+ MaterielThickness = inboundOrderDetail.MaterialThick,
+ MaterielWide = inboundOrderDetail.MaterialWide,
+ MaterielWeight = inboundOrderDetail.MaterialWeight,
+ MaterielCode = materielInfo.MaterielCode,
+ MaterielName = materielInfo.MaterielName,
+ BatchNo = inboundOrderDetail.MaterialLot,
+ StockLength = inboundOrderDetail.OrderQuantity
+ };
+ if (inboundOrderDetail.MaterialWide > 1200)
+ {
+ stockInfo.PalletType = 2;
+ }
+ inboundOrderDetail.OrderDetailStatus = InOrderStatusEnum.鍏ュ簱涓�.ObjToInt();
+ _unitOfWorkManage.BeginTran();
+ _inboundRepository.YLInboundCacheRepository.UpdateData(yLInboundCache);
+ //鏂板缁勭洏淇℃伅
+ _stockRepository.StockInfoRepository.AddData(stockInfo);
+ if (inboundOrder.InboundOrderStatus == InOrderStatusEnum.鏈紑濮�.ObjToInt())
+ {
+ inboundOrder.InboundOrderStatus = InOrderStatusEnum.鍏ュ簱涓�.ObjToInt();
+ _inboundRepository.InboundOrderRepository.UpdateData(inboundOrder);
+ }
+ _inboundRepository.InboundOrderDetailRepository.UpdateData(inboundOrderDetail);
+ //鍚姩绾夸綋
+ WebResponseContent webResponse = YLPurchasePush();
+ if (!webResponse.Status)
+ {
+ throw new Exception(webResponse.Message);
+ }
+ _unitOfWorkManage.CommitTran();
+ Dt_StockInfo stockInfoAdd = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == stockInfo.PalletCode);
+ //璁板綍搴撳瓨鍙樺姩
+ _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfoAdd, 0, stockInfoAdd.StockLength, StockChangeTypeEnum.MaterielGroup);
+ return content.OK("鎴愬姛", yLInboundCache);
+ }
+ else
+ {
+ throw new Exception($"涓婂嵎鏉$爜{yLInboundCache.BarCode}杩樻湭杩涜缁戝畾");
+ }
}
+
}
else //鑰佸巶绾稿嵎骞冲彴鍏ュ簱
{
@@ -686,7 +788,7 @@
/// <param name="palletCode">鏉$爜鍙�</param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
- public string AssignYLRoadwayNo(string palletCode)
+ public string AssignYLRoadwayNo(string palletCode, int wide = 0, int thickness = 0, int weight = 0)
{
try
{
@@ -704,10 +806,19 @@
string roadwayNo = "";
+ bool isReturn=false;
+
if (stockInfo.MaterielInvOrgId==MaterielInvOrgEnum.鏂板巶.ObjToInt())
{
+ if (wide>0 && thickness>0 && weight>0)
+ {
+ stockInfo.CheckThickness = thickness;
+ stockInfo.CheckWeight = weight;
+ stockInfo.CheckWide = wide;
+ isReturn = true;
+ }
//闄愬埗鐩村緞
- if (stockInfo.CheckThickness >= 300 && stockInfo.CheckThickness <= 1300 && stockInfo.MaterielWide >= 690 && stockInfo.MaterielWide <= 2700)
+ if (stockInfo.CheckThickness >= 300 && stockInfo.CheckThickness <= 1300 && stockInfo.MaterielWide >= 690 && stockInfo.MaterielWide <= 2500)
{
//鑾峰彇鍒嗛厤
List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => x.WarehouseId == warehouse.WarehouseId && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && x.EnableStatus == EnableStatusEnum.Normal.ObjToInt() && x.RoadwayNo.Contains("YLDual") && (stockInfo.PalletType == LocationTypeEnum.MediumPallet.ObjToInt() ? x.LocationType == LocationTypeEnum.MediumPallet.ObjToInt(): x.LocationType == LocationTypeEnum.SmallPallet.ObjToInt())).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).OrderBy(x => x.RoadwayNo).ToList();
@@ -720,17 +831,33 @@
//闄愬埗
if (stockInfo.CheckThickness >= 800 && stockInfo.CheckThickness <= 1500 && stockInfo.MaterielWide >= 700 && stockInfo.MaterielWide <= 2500)
{
- bool LayerLimit = false;
- if (stockInfo.CheckThickness > 1300)
+ bool LayerLimit = stockInfo.CheckThickness > 1300;
+ bool RoadwayLimit = stockInfo.MaterielWide > 2200;
+ var query = Db.Queryable<Dt_LocationInfo>()
+ .Where(x => x.WarehouseId == warehouse.WarehouseId
+ && x.LocationStatus == (int)LocationStatusEnum.Free
+ && x.EnableStatus == (int)EnableStatusEnum.Normal
+ && x.RoadwayNo.Contains("YL"))
+ .Select(x => new { x.RoadwayNo, x.Columns });
+
+ // 鏍规嵁鏉′欢杩囨护
+ if (LayerLimit)
{
- LayerLimit = true;
+ query = query.Where(x => x.Columns >= 56 && !x.RoadwayNo.Contains("YLDual"));
}
- //鑾峰彇鍒嗛厤
- List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => x.WarehouseId == warehouse.WarehouseId && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && x.EnableStatus == EnableStatusEnum.Normal.ObjToInt() && x.RoadwayNo.Contains("YL") && !x.RoadwayNo.Contains("YLDual") && (LayerLimit ? x.Columns>=56 : x.Columns<=55)).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).OrderBy(x => x.RoadwayNo).ToList();
- if (stockInfo.MaterielWide > 2200)
+ if (RoadwayLimit)
{
- locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => x.WarehouseId == warehouse.WarehouseId && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && x.EnableStatus == EnableStatusEnum.Normal.ObjToInt() && x.RoadwayNo == "SC02_YL" && (LayerLimit ? x.Columns >= 56 : x.Columns <= 55)).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).OrderBy(x => x.RoadwayNo).ToList();
+ query = query.Where(x => !x.RoadwayNo.Contains("SC01_YL"));
}
+ List<LocationCount> locationCounts = query
+ .GroupBy(x => x.RoadwayNo)
+ .Select(x => new LocationCount
+ {
+ RoadwayNo = x.RoadwayNo,
+ Count = SqlFunc.AggregateCount(x)
+ })
+ .OrderBy(x => x.RoadwayNo)
+ .ToList();
roadwayNo = HandleRoadway(locationCounts, warehouse);
}
@@ -742,7 +869,12 @@
roadwayNo = HandleRoadway(locationCounts, warehouse);
}
}
-
+
+ if (isReturn && !string.IsNullOrEmpty(roadwayNo))
+ {
+ _stockRepository.StockInfoRepository.UpdateData(stockInfo);
+ }
+
return !string.IsNullOrEmpty(roadwayNo) ? (roadwayNo) : throw new Exception("鏈壘鍒板彲鍒嗛厤宸烽亾");
}
catch (Exception ex)
@@ -1264,6 +1396,10 @@
Quantity = inboundOrderDetail.OrderQuantity,
PalletType = 1
};
+ if (agvstation.StationArea==StationAreaEnum.浜屾ゼ鎴愬搧搴撶紦瀛樺尯.ToString())
+ {
+ newTask.TaskType = TaskTypeEnum.Inbound2ndFloor.ObjToInt();
+ }
inboundOrderDetail.OrderDetailStatus = InOrderStatusEnum.鍏ュ簱涓�.ObjToInt();
_unitOfWorkManage.BeginTran();
if (inboundOrder.InboundOrderStatus == InOrderStatusEnum.鏈紑濮�.ObjToInt())
--
Gitblit v1.9.3