From daad807a255285274f3b8559b48a12536cdacfac Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期二, 21 四月 2026 16:59:42 +0800
Subject: [PATCH] 成品入库上传ERP新增销售单号字段,成品出库上传MES及外包装机新增订单出货数量字段
---
代码管理/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Inbound.cs | 287 +++++++++++++++++++++++++++++++++++++++------------------
1 files changed, 195 insertions(+), 92 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 25714e7..1709c62 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"
@@ -847,106 +847,116 @@
return WebResponseContent.Instance.Error(ex.Message);
}
}
-
+ private static object _requestZH = new object();
public WebResponseContent RequestZHInboundTask(string agvTaskCode, string palletCode, string palletType, string materialLot)
{
- WebResponseContent content = new WebResponseContent();
- try
+ lock (_requestZH)
{
- //鑾峰彇闃荤剨搴撳瓨淇℃伅
- Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA154.ToString());
- //鑾峰彇搴撳瓨璁板綍
- List<Dt_StockInfo> stockInfos = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x =>
- x.WarehouseId == warehouse.WarehouseId && x.PalletCode== palletCode).Includes(x => x.Details).ToList();
- if (stockInfos.Count > 0)
+ WebResponseContent content = new WebResponseContent();
+ try
{
- return content.Error($"杞藉叿鎵樼洏宸插瓨鍦�");
+ //鑾峰彇闃荤剨搴撳瓨淇℃伅
+ Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA154.ToString());
+ //鑾峰彇搴撳瓨璁板綍
+ List<Dt_StockInfo> stockInfos = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x =>
+ x.WarehouseId == warehouse.WarehouseId && x.PalletCode == palletCode).Includes(x => x.Details).ToList();
+ if (stockInfos.Count > 0)
+ {
+ return content.Error($"杞藉叿鎵樼洏宸插瓨鍦�");
+ }
+ Dt_StockInfo? stockInfoOld = stockInfos.FirstOrDefault(x => x.Details.Any(x => x.BatchNo == materialLot));
+ if (stockInfoOld != null)
+ {
+ 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()
+ //{
+ // Product="FH001",
+ // ProductVersion="A1",
+ // Qty=20,
+ // LotNo= materialLot,
+ // IsFullNumber=true
+ //};
+ Dt_StockInfoDetail stockInfoDetail = new Dt_StockInfoDetail()
+ {
+ MaterielSpec = mesLotInfo.ProductVersion,
+ BatchNo = materialLot,
+ EffectiveDate = mesLotInfo.DateCode ?? " ",
+ MaterielCode = mesLotInfo.Product,
+ InboundOrderRowNo = 0,
+ MaterielName = mesLotInfo.Product,
+ ProductionDate = mesLotInfo.DateCode ?? " ",
+ OrderNo = "",
+ OutboundQuantity = 0,
+ SerialNumber = materialLot,
+ StockQuantity = (float)mesLotInfo.Qty,
+ Status = StockStatusEmun.鍏ュ簱纭.ObjToInt(),
+ Unit = "Lot",
+ Remark = mesLotInfo.IsFullNumber ? "婊ot" : "涓嶆弧Lot"
+ };
+ Dt_StockInfo stockInfo = new Dt_StockInfo()
+ {
+ PalletCode = palletCode,
+ PalletType = palletTypeInfo.PalletType,
+ WarehouseId = warehouse.WarehouseId,
+ StockStatus = StockStatusEmun.鍏ュ簱纭.ObjToInt(),
+ Details = new List<Dt_StockInfoDetail> { stockInfoDetail }
+ };
+
+ //鐢熸垚閫�搴撲换鍔�
+ Dt_Task taskIn = new()
+ {
+ CurrentAddress = "AGV_ZH",
+ Grade = 0,
+ PalletCode = palletCode,
+ NextAddress = "",
+ Roadway = "SC01_ZH",
+ SourceAddress = "AGV_ZH",
+ TargetAddress = "",
+ TaskStatus = (int)TaskStatusEnum.New,
+ TaskType = palletTypeInfo.LocaitonCount == 2 ? (int)TaskTypeEnum.InZHProductLarge : (int)TaskTypeEnum.InZHProductSmall,
+ TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
+ PalletType = palletTypeInfo.PalletType,
+ WarehouseId = warehouse.WarehouseId,
+ MaterielCode = mesLotInfo.Product,
+ Quantity = (float)mesLotInfo.Qty,
+ BatchNo = mesLotInfo.LotNo
+ };
+ _unitOfWorkManage.BeginTran();
+ Db.InsertNav(stockInfo).Include(x => x.Details).ExecuteCommand();
+ BaseDal.AddData(taskIn);
+ //BaseDal.AddData(task);
+ _unitOfWorkManage.CommitTran();
+ //灏嗕换鍔℃帹閫佸埌WCS
+ PushTasksToWCS(new List<Dt_Task>() { taskIn }, "AGV_ZH", agvTaskCode);
+ content.OK(data: taskIn);
}
- Dt_StockInfo? stockInfoOld = stockInfos.FirstOrDefault(x => x.Details.Any(x => x.BatchNo == materialLot));
- if (stockInfoOld != null)
+ catch (Exception ex)
{
- return content.Error($"搴撳瓨淇℃伅宸插瓨鍦�");
+ _unitOfWorkManage.RollbackTran();
+ content.Error(ex.Message);
}
- 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()
- //{
- // Product="FH001",
- // ProductVersion="A1",
- // Qty=20,
- // LotNo= materialLot,
- // IsFullNumber=true
- //};
- Dt_StockInfoDetail stockInfoDetail = new Dt_StockInfoDetail()
- {
- MaterielSpec = mesLotInfo.ProductVersion,
- BatchNo = materialLot,
- EffectiveDate = mesLotInfo.DateCode ?? " ",
- MaterielCode = mesLotInfo.Product,
- InboundOrderRowNo = 0,
- MaterielName = mesLotInfo.Product,
- ProductionDate = mesLotInfo.DateCode ?? " ",
- OrderNo = "",
- OutboundQuantity = 0,
- SerialNumber = materialLot,
- StockQuantity = (float)mesLotInfo.Qty,
- Status = StockStatusEmun.鍏ュ簱纭.ObjToInt(),
- Unit = "Lot",
- Remark= mesLotInfo.IsFullNumber?"婊ot":"涓嶆弧Lot"
- };
- Dt_StockInfo stockInfo = new Dt_StockInfo()
- {
- PalletCode = palletCode,
- PalletType = palletTypeInfo.PalletType,
- WarehouseId = warehouse.WarehouseId,
- StockStatus = StockStatusEmun.鍏ュ簱纭.ObjToInt(),
- Details = new List<Dt_StockInfoDetail> { stockInfoDetail }
- };
-
- //鐢熸垚閫�搴撲换鍔�
- Dt_Task taskIn = new()
- {
- CurrentAddress = "AGV_ZH",
- Grade = 0,
- PalletCode = palletCode,
- NextAddress = "",
- Roadway = "SC01_ZH",
- SourceAddress = "AGV_ZH",
- TargetAddress = "",
- TaskStatus = (int)TaskStatusEnum.New,
- TaskType = palletTypeInfo.LocaitonCount==2? (int)TaskTypeEnum.InZHProductLarge : (int)TaskTypeEnum.InZHProductSmall,
- TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
- PalletType = palletTypeInfo.PalletType,
- WarehouseId = warehouse.WarehouseId,
- MaterielCode = mesLotInfo.Product,
- Quantity = (float)mesLotInfo.Qty,
- BatchNo = mesLotInfo.LotNo
- };
- _unitOfWorkManage.BeginTran();
- Db.InsertNav(stockInfo).Include(x => x.Details).ExecuteCommand();
- BaseDal.AddData(taskIn);
- //BaseDal.AddData(task);
- _unitOfWorkManage.CommitTran();
- //灏嗕换鍔℃帹閫佸埌WCS
- PushTasksToWCS(new List<Dt_Task>() { taskIn }, "AGV_ZH", agvTaskCode);
- content.OK(data: taskIn);
+ return content;
}
- catch (Exception ex)
- {
- _unitOfWorkManage.RollbackTran();
- content.Error(ex.Message);
- }
- return content;
+
}
public readonly string[] OutStartPonits = { "5230", "5237", "5244" };
@@ -1029,6 +1039,7 @@
{
x.ProOutDetailStatus = StockStatusEmun.鎴愬搧浣欐枡鍥炲簱.ObjToInt();
});
+ proStockInfo.WarehouseId = locationInfo.WarehouseId;
Dt_Task newTask = new Dt_Task()
{
CurrentAddress = startPoint,
@@ -1142,5 +1153,97 @@
}
}
+
+ /// <summary>
+ /// PP骞冲簱鐢宠鍏ュ簱浠诲姟
+ /// </summary>
+ /// <param name="saveModel"></param>
+ /// <returns></returns>
+ public WebResponseContent PPPKRequestInboundTask(SaveModel saveModel)
+ {
+ try
+ {
+ 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 WebResponseContent.Instance.Error($"鏈壘鍒板簱鍖�");
+ }
+
+ Dt_Task task = Repository.QueryFirst(x => x.PalletCode == palletCode && x.WarehouseId == warehouseId);
+ if (task != null)
+ {
+ return WebResponseContent.Instance.Error($"璇ユ墭鐩樺凡鐢熸垚浠诲姟");
+ }
+
+ Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletCode == palletCode).Includes(x => x.Details).First();
+ if (stockInfo == null)
+ {
+ return WebResponseContent.Instance.Error($"鏈壘鍒扮粍鐩樹俊鎭�");
+ }
+ if (stockInfo.StockStatus != StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.鎵嬪姩缁勭洏鏆傚瓨.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.鎷i�夊畬鎴�.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.閫佹搴撳瓨瀹屾垚.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.鐩樼偣搴撳瓨瀹屾垚.ObjToInt())
+ {
+ return WebResponseContent.Instance.Error($"璇ユ墭鐩樼姸鎬佷笉姝g‘,涓嶅彲鐢宠鍏ュ簱");
+ }
+ 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 = stationCode,
+ Grade = 0,
+ NextAddress = "",
+ PalletCode = palletCode,
+ Roadway = "AGV_PP",
+ SourceAddress = stationCode,
+ TargetAddress = locationInfoPPPK.LocationCode,
+ TaskType = TaskTypeEnum.PPPKInbound.ObjToInt(),
+ TaskStatus = TaskStatusEnum.New.ObjToInt(),
+ 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
+ };
+ if (stockInfo.StockStatus == StockStatusEmun.鎵嬪姩缁勭洏鏆傚瓨.ObjToInt())
+ {
+ 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 },"AGV_PP");
+ return WebResponseContent.Instance.OK(data: newTask);
+
+ }
+ catch (Exception ex)
+ {
+ _unitOfWorkManage.RollbackTran();
+ return WebResponseContent.Instance.Error(ex.Message);
+ }
+ }
}
}
--
Gitblit v1.9.3