From 981a80940e47409300c09847684ca530f75b4a5f Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期五, 10 一月 2025 23:56:33 +0800
Subject: [PATCH] 优化WCS辅料出库逻辑
---
代码管理/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Inbound.cs | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 109 insertions(+), 2 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 a129365..b42dee9 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"
@@ -1,4 +1,6 @@
-锘縰sing System;
+锘縰sing OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup;
+using System;
+using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -51,7 +53,7 @@
{
return WebResponseContent.Instance.Error($"鏈壘鍒扮粍鐩樹俊鎭�");
}
- if (stockInfo.StockStatus != StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.鎵嬪姩缁勭洏鏆傚瓨.ObjToInt())
+ if (stockInfo.StockStatus != StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.鎵嬪姩缁勭洏鏆傚瓨.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt())
{
return WebResponseContent.Instance.Error($"璇ユ墭鐩樼姸鎬佷笉姝g‘,涓嶅彲鐢宠鍏ュ簱");
}
@@ -109,7 +111,111 @@
return WebResponseContent.Instance.Error(ex.Message);
}
}
+ /// <summary>
+ /// 鍏ョ┖绠�
+ /// </summary>
+ /// <returns></returns>
+ public WebResponseContent InEmpty(string barcode, string address, int WarehouseId)
+ {
+ try
+ {
+ Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseId == WarehouseId);
+ if (warehouse == null)
+ {
+ return WebResponseContent.Instance.Error($"鏈壘鍒板簱鍖�");
+ }
+ Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == barcode && x.StockStatus != StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt());
+ if (stockInfo != null) throw new Exception($"鎵樼洏鍙峰凡瀛樺湪");
+ stockInfo = new Dt_StockInfo()
+ {
+ PalletCode = barcode,
+ StockStatus = StockStatusEmun.鍏ュ簱纭.ObjToInt(),
+ WarehouseId = WarehouseId,
+ PalletType = PalletTypeEnum.Empty.ObjToInt(),
+ Details = new List<Dt_StockInfoDetail>()
+ };
+ Dt_LocationInfo locationInfo = _basicRepository.LocationInfoRepository.QueryFirst(x => x.WarehouseId == WarehouseId);
+ if (locationInfo == null) return WebResponseContent.Instance.Error($"鏈壘鍒板綋鍓嶅簱鍖鸿揣浣嶄俊鎭�");
+ locationInfo = _basicService.LocationInfoService.AssignLocation(locationInfo.RoadwayNo, ((PalletTypeEnum)stockInfo.PalletType).ObjToInt(), stockInfo.WarehouseId);
+ if (locationInfo == null)
+ {
+ return WebResponseContent.Instance.Error($"璐т綅鍒嗛厤澶辫触,鏈壘鍒板彲鍒嗛厤璐т綅");
+ }
+ Dt_Task newTask = new Dt_Task()
+ {
+ CurrentAddress = address,
+ Grade = 0,
+ NextAddress = locationInfo.LocationCode,
+ PalletCode = barcode,
+ Roadway = locationInfo.RoadwayNo,
+ SourceAddress = address,
+ TargetAddress = locationInfo.LocationCode,
+ TaskType = TaskTypeEnum.InEmpty.ObjToInt(),
+ TaskStatus = TaskStatusEnum.New.ObjToInt(),
+ WarehouseId = stockInfo.WarehouseId,
+ PalletType = stockInfo.PalletType
+ };
+ locationInfo.LocationStatus = LocationStatusEnum.Lock.ObjToInt();
+ _unitOfWorkManage.BeginTran();
+ int taskId = BaseDal.AddData(newTask);
+ newTask.TaskId = taskId;
+ _basicRepository.LocationInfoRepository.UpdateData(locationInfo);
+ _stockRepository.StockInfoRepository.AddData(stockInfo);
+ _unitOfWorkManage.CommitTran();
+ PushTasksToWCS(new List<Dt_Task> { newTask });
+ PutFinish(address);
+ return WebResponseContent.Instance.OK();
+ }
+ catch (Exception ex)
+ {
+ _unitOfWorkManage.RollbackTran();
+ return WebResponseContent.Instance.Error(ex.Message);
+ }
+ }
+ public WebResponseContent OutEmpty(int qty, string address, int WarehouseId, string barcode)
+ {
+ try
+ {
+ Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseId == WarehouseId);
+ if (warehouse == null)
+ {
+ return WebResponseContent.Instance.Error($"鏈壘鍒板簱鍖�");
+ }
+ List<Dt_StockInfo> stockInfos = null;
+ if (string.IsNullOrEmpty(barcode))
+ {
+ stockInfos = _stockRepository.StockInfoRepository.QueryData(x => x.WarehouseId == WarehouseId && x.PalletType == PalletTypeEnum.Empty.ObjToInt() && x.StockStatus == StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt(), qty, nameof(Dt_StockInfo.CreateDate));
+ }
+ else
+ {
+ stockInfos = _stockRepository.StockInfoRepository.QueryData(x => x.WarehouseId == WarehouseId && x.PalletType == PalletTypeEnum.Empty.ObjToInt() && x.StockStatus == StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt() && x.PalletCode == barcode);
+ if (stockInfos.Count == 0) return WebResponseContent.Instance.Error($"{warehouse.WarehouseName}鏈壘鍒扮┖绠便�恵barcode}銆�");
+ }
+
+ if (stockInfos.Count < qty) return WebResponseContent.Instance.Error($"{warehouse.WarehouseName}绌虹搴撳瓨涓嶈冻,搴撳瓨鏁般�恵stockInfos.Count}銆�");
+ List<Dt_Task> tasks = GetTasks(stockInfos, TaskTypeEnum.OutEmpty);
+ stockInfos.ForEach(x =>
+ {
+ x.StockStatus = StockStatusEmun.鍑哄簱閿佸畾.ObjToInt();
+ });
+ tasks.ForEach(x =>
+ {
+ x.TargetAddress = address;
+ x.NextAddress = address;
+ });
+ _unitOfWorkManage.BeginTran();
+ BaseDal.AddData(tasks);
+ _stockRepository.StockInfoRepository.UpdateData(stockInfos);
+ _unitOfWorkManage.CommitTran();
+ PushTasksToWCS(tasks);
+ return WebResponseContent.Instance.OK();
+ }
+ catch (Exception ex)
+ {
+ return WebResponseContent.Instance.Error(ex.Message);
+ }
+ }
public WebResponseContent DeviceRequestInboundTask(string stationCode, string roadwayNo, string palletCode)
{
try
@@ -179,6 +285,7 @@
WMSTaskDTO wMSTaskDTO = _mapper.Map<WMSTaskDTO>(newTask);
PushTasksToWCS(new List<Dt_Task> { newTask });
+ if (newTask.WarehouseId == 5) PutFinish(stationCode);
return WebResponseContent.Instance.OK(data: wMSTaskDTO);
}
catch (Exception ex)
--
Gitblit v1.9.3