From 8fcd7a67e4391a5f1fbdb590c2a3f913aeb2a0a0 Mon Sep 17 00:00:00 2001
From: helongyang <647556386@qq.com>
Date: 星期二, 31 三月 2026 14:11:23 +0800
Subject: [PATCH] PP平库功能上线,PDA优化,部分问题点优化
---
代码管理/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Inbound.cs | 220 ++++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 162 insertions(+), 58 deletions(-)
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Inbound.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Inbound.cs"
index f7f350b..a40c4b3 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Inbound.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Inbound.cs"
@@ -853,7 +853,7 @@
WebResponseContent content = new WebResponseContent();
try
{
- //鑾峰彇娴嬭瘯鏋跺師搴撳瓨淇℃伅
+ //鑾峰彇闃荤剨搴撳瓨淇℃伅
Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA154.ToString());
//鑾峰彇搴撳瓨璁板綍
List<Dt_StockInfo> stockInfos = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x =>
@@ -867,26 +867,32 @@
{
return content.Error($"搴撳瓨淇℃伅宸插瓨鍦�");
}
+
+ Dt_Task task = BaseDal.QueryFirst(x => x.PalletCode == palletCode);
+ if(task != null)
+ {
+ return content.Error($"鎵樼洏{palletCode}宸茬粡瀛樺湪浠诲姟锛岃鍕块噸澶嶄笅杈�");
+ }
Dt_PalletTypeInfo palletTypeInfo = _palletTypeInfoRepository.QueryFirst(x=>x.CodeStartStr== palletType);
if (palletTypeInfo == null)
{
return content.Error($"鎵樼洏绫诲瀷淇℃伅涓嶅瓨鍦�");
}
- ////鑾峰彇闃荤剨鎵规
- //WebResponseContent requestLotInfo = GetZHMesMaterialLot(materialLot);
- //if (!requestLotInfo.Status)
- //{
- // return content.Error($"璇锋眰闃荤剨鎵规淇℃伅澶辫触,{requestLotInfo.Message}");
- //}
- //MesLotInfoModel mesLotInfo = JsonConvert.DeserializeObject<MesLotInfoModel>(requestLotInfo.Data.ToString());
- MesLotInfoModel mesLotInfo = new MesLotInfoModel()
+ //鑾峰彇闃荤剨鎵规
+ WebResponseContent requestLotInfo = GetZHMesMaterialLot(materialLot);
+ if (!requestLotInfo.Status)
{
- Product="FH001",
- ProductVersion="A1",
- Qty=20,
- LotNo= materialLot,
- IsFullNumber=true
- };
+ return content.Error($"璇锋眰闃荤剨鎵规淇℃伅澶辫触,{requestLotInfo.Message}");
+ }
+ MesLotInfoModel mesLotInfo = JsonConvert.DeserializeObject<MesLotInfoModel>(requestLotInfo.Data.ToString());
+ //MesLotInfoModel mesLotInfo = new MesLotInfoModel()
+ //{
+ // Product="FH001",
+ // ProductVersion="A1",
+ // Qty=20,
+ // LotNo= materialLot,
+ // IsFullNumber=true
+ //};
Dt_StockInfoDetail stockInfoDetail = new Dt_StockInfoDetail()
{
MaterielSpec = mesLotInfo.ProductVersion,
@@ -1029,6 +1035,7 @@
{
x.ProOutDetailStatus = StockStatusEmun.鎴愬搧浣欐枡鍥炲簱.ObjToInt();
});
+ proStockInfo.WarehouseId = locationInfo.WarehouseId;
Dt_Task newTask = new Dt_Task()
{
CurrentAddress = startPoint,
@@ -1064,78 +1071,175 @@
}
return content;
}
+ private static object emptyBack_inbound = new object();
/// <summary>
/// 绌烘鍥炲簱
/// </summary>
public WebResponseContent EmptyBackTask(string barCode, string startPoint)
{
- WebResponseContent content = new WebResponseContent();
+ lock (emptyBack_inbound)
+ {
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+ string palletCode = @"^C\d{5}$"; // 姝e垯琛ㄨ揪寮�
+ bool isValid = Regex.IsMatch(barCode, palletCode);
+ if (!isValid)
+ {
+ return content.Error($"妗嗙爜鏍煎紡閿欒{barCode}");
+ }
+ if (!OutStartPonits.Contains(startPoint))
+ {
+ return content.Error($"璧风偣閿欒{startPoint}");
+ }
+ //鍒ゆ柇褰撳墠鐐逛綅鏄惁閲嶅
+ Dt_Task taskOldPoint = BaseDal.QueryFirst(x => x.SourceAddress == startPoint && (x.TaskStatus == TaskStatusEnum.New.ObjToInt() || x.TaskStatus == TaskStatusEnum.Line_Execute.ObjToInt() || x.TaskStatus == TaskStatusEnum.Line_Executing.ObjToInt()));
+ //if (taskOldPoint != null)
+ //{
+ // return content.Error($"绔欑偣{startPoint}宸插瓨鍦ㄤ换鍔�");
+ //}
+ Dt_Task taskOld = BaseDal.QueryFirst(x => x.PalletCode == barCode);
+ if (taskOld != null)
+ {
+ return content.Error($"鑳舵{barCode}浠诲姟宸插瓨鍦�");
+ }
+ //if (_stockRepository.ProStockInfoRepository.QueryFirst(x => x.PalletCode == barCode) != null)
+ //{
+ // return content.Error($"鑳舵{barCode}搴撳瓨淇℃伅宸插瓨鍦�");
+ //}
+ //todo:涓存椂瑙g粦
+ Dt_ProStockInfo proStockInfo = _stockRepository.ProStockInfoRepository.QueryFirst(x => x.PalletCode == barCode && x.StockStatus == StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt());
+ if (_stockRepository.ProStockInfoRepository.QueryFirst(x => x.PalletCode == barCode) != null)
+ {
+ proStockInfo.PalletCode = proStockInfo.PalletCode + ":" + DateTime.Now.ToString("MM/dd");
+ }
+ //鑾峰彇鎴愬搧骞冲簱
+ Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA101.ToString());
+ Dt_Task newTask = new Dt_Task()
+ {
+ CurrentAddress = startPoint,
+ Grade = 0,
+ NextAddress = "",
+ PalletCode = barCode,
+ Roadway = "CL01_CP",
+ SourceAddress = startPoint,
+ TargetAddress = "",
+ TaskType = TaskTypeEnum.EmptyProductBack.ObjToInt(),
+ TaskStatus = TaskStatusEnum.New.ObjToInt(),
+ WarehouseId = warehouse.WarehouseId,
+ PalletType = 1
+ };
+ _unitOfWorkManage.BeginTran();
+ int taskId = BaseDal.AddData(newTask);
+ if (proStockInfo != null)
+ {
+ _stockRepository.ProStockInfoRepository.UpdateData(proStockInfo);
+ }
+ newTask.TaskId = taskId;
+ _unitOfWorkManage.CommitTran();
+ //鎺ㄩ�佷换鍔�
+ PushTasksToWCS(new List<Dt_Task> { newTask });
+ content.OK("鍙戦�佹垚鍔�");
+ }
+ catch (Exception ex)
+ {
+ content.Error(ex.Message);
+ }
+ return content;
+ }
+
+ }
+
+ /// <summary>
+ /// PP骞冲簱鐢宠鍏ュ簱浠诲姟
+ /// </summary>
+ /// <param name="saveModel"></param>
+ /// <returns></returns>
+ public WebResponseContent PPPKRequestInboundTask(SaveModel saveModel)
+ {
try
{
- string palletCode = @"^C\d{5}$"; // 姝e垯琛ㄨ揪寮�
- bool isValid = Regex.IsMatch(barCode, palletCode);
- if (!isValid)
+ var palletCode = saveModel.MainData["barcode"].ToString();
+ var warehouseId = saveModel.MainData["warehouseId"].ObjToInt();
+ var stationCode = saveModel.MainData["startPoint"].ToString();
+ Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseId == warehouseId);
+ if (warehouse == null)
{
- return content.Error($"妗嗙爜鏍煎紡閿欒{barCode}");
+ return WebResponseContent.Instance.Error($"鏈壘鍒板簱鍖�");
}
- if (!OutStartPonits.Contains(startPoint))
+
+ Dt_Task task = Repository.QueryFirst(x => x.PalletCode == palletCode && x.WarehouseId == warehouseId);
+ if (task != null)
{
- return content.Error($"璧风偣閿欒{startPoint}");
+ return WebResponseContent.Instance.Error($"璇ユ墭鐩樺凡鐢熸垚浠诲姟");
}
- //鍒ゆ柇褰撳墠鐐逛綅鏄惁閲嶅
- Dt_Task taskOldPoint = BaseDal.QueryFirst(x => x.SourceAddress == startPoint && (x.TaskStatus == TaskStatusEnum.New.ObjToInt() || x.TaskStatus == TaskStatusEnum.Line_Execute.ObjToInt() || x.TaskStatus == TaskStatusEnum.Line_Executing.ObjToInt()));
- //if (taskOldPoint != null)
- //{
- // return content.Error($"绔欑偣{startPoint}宸插瓨鍦ㄤ换鍔�");
- //}
- Dt_Task taskOld = BaseDal.QueryFirst(x => x.PalletCode == barCode);
- if (taskOld != null)
+
+ Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletCode == palletCode).Includes(x => x.Details).First();
+ if (stockInfo == null)
{
- return content.Error($"鑳舵{barCode}浠诲姟宸插瓨鍦�");
+ return WebResponseContent.Instance.Error($"鏈壘鍒扮粍鐩樹俊鎭�");
}
- //if (_stockRepository.ProStockInfoRepository.QueryFirst(x => x.PalletCode == barCode) != null)
- //{
- // return content.Error($"鑳舵{barCode}搴撳瓨淇℃伅宸插瓨鍦�");
- //}
- //todo:涓存椂瑙g粦
- Dt_ProStockInfo proStockInfo = _stockRepository.ProStockInfoRepository.QueryFirst(x => x.PalletCode == barCode);
- if (_stockRepository.ProStockInfoRepository.QueryFirst(x => x.PalletCode == barCode) != null)
+ if (stockInfo.StockStatus != StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.鎵嬪姩缁勭洏鏆傚瓨.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.鎷i�夊畬鎴�.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.閫佹搴撳瓨瀹屾垚.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.鐩樼偣搴撳瓨瀹屾垚.ObjToInt())
{
- proStockInfo.PalletCode = proStockInfo.PalletCode + ":" + DateTime.Now.ToString("MM/dd");
+ return WebResponseContent.Instance.Error($"璇ユ墭鐩樼姸鎬佷笉姝g‘,涓嶅彲鐢宠鍏ュ簱");
}
- //鑾峰彇鎴愬搧骞冲簱
- Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA101.ToString());
+ if (!string.IsNullOrEmpty(stockInfo.LocationCode))
+ {
+ return WebResponseContent.Instance.Error($"璇ユ墭鐩樺凡缁戝畾璐т綅");
+ }
+ if (warehouseId != stockInfo.WarehouseId)
+ {
+ return WebResponseContent.Instance.Error($"浠撳簱涓嶆纭�");
+ }
+
+ Dt_LocationInfo? locationInfoPPPK = _basicService.LocationInfoService.AssignLocation("AGV_PP", stockInfo.PalletType, stockInfo.WarehouseId);
+ if (locationInfoPPPK == null)
+ {
+ return WebResponseContent.Instance.Error($"璐т綅鍒嗛厤澶辫触,鏈壘鍒板彲鍒嗛厤璐т綅");
+ }
Dt_Task newTask = new Dt_Task()
{
- CurrentAddress = startPoint,
+ CurrentAddress = stationCode,
Grade = 0,
NextAddress = "",
- PalletCode = barCode,
- Roadway = "CL01_CP",
- SourceAddress = startPoint,
- TargetAddress = "",
- TaskType = TaskTypeEnum.EmptyProductBack.ObjToInt(),
+ PalletCode = palletCode,
+ Roadway = "AGV_PP",
+ SourceAddress = stationCode,
+ TargetAddress = locationInfoPPPK.LocationCode,
+ TaskType = TaskTypeEnum.PPPKInbound.ObjToInt(),
TaskStatus = TaskStatusEnum.New.ObjToInt(),
- WarehouseId = warehouse.WarehouseId,
- PalletType = 1
+ WarehouseId = stockInfo.WarehouseId,
+ PalletType = stockInfo.PalletType,
+ MaterielCode = stockInfo.Details?.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.MaterielCode,
+ Quantity = (float)stockInfo.Details?.Where(x => x.StockId == stockInfo.Id).Sum(x => x.StockQuantity),
+ BatchNo = stockInfo.Details?.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.BatchNo
};
- _unitOfWorkManage.BeginTran();
- int taskId = BaseDal.AddData(newTask);
- if (proStockInfo!=null)
+ if (stockInfo.StockStatus == StockStatusEmun.鎵嬪姩缁勭洏鏆傚瓨.ObjToInt())
{
- _stockRepository.ProStockInfoRepository.UpdateData(proStockInfo);
+ stockInfo.StockStatus = StockStatusEmun.鎵嬪姩缁勭洏鍏ュ簱纭.ObjToInt();
}
+ else
+ {
+ stockInfo.StockStatus = StockStatusEmun.鍏ュ簱纭.ObjToInt();
+ }
+
+ _unitOfWorkManage.BeginTran();
+ LocationStatusEnum lastStatusPPorGM = (LocationStatusEnum)locationInfoPPPK.LocationStatus;
+ _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfoPPPK, lastStatusPPorGM, LocationStatusEnum.Lock, LocationChangeType.InboundAssignLocation);
+ _basicService.LocationInfoService.UpdateLocationStatus(locationInfoPPPK, newTask.PalletType, LocationStatusEnum.Lock, newTask.WarehouseId);
+ int taskId = BaseDal.AddData(newTask);
newTask.TaskId = taskId;
+ _stockRepository.StockInfoRepository.UpdateData(stockInfo);
_unitOfWorkManage.CommitTran();
- //鎺ㄩ�佷换鍔�
- PushTasksToWCS(new List<Dt_Task> { newTask });
- content.OK("鍙戦�佹垚鍔�");
+ PushTasksToWCS(new List<Dt_Task> { newTask },"AGV_PP");
+ return WebResponseContent.Instance.OK(data: newTask);
+
}
catch (Exception ex)
{
- content.Error(ex.Message);
+ _unitOfWorkManage.RollbackTran();
+ return WebResponseContent.Instance.Error(ex.Message);
}
- return content;
}
}
}
--
Gitblit v1.9.3