From 5189c42ee1b15ba8c54fd258102b4c7262a2e6c7 Mon Sep 17 00:00:00 2001
From: 647556386 <647556386@qq.com>
Date: 星期一, 30 三月 2026 11:40:11 +0800
Subject: [PATCH] 1
---
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs | 144 ++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 138 insertions(+), 6 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
index cc7dbd8..572a087 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
@@ -27,6 +27,7 @@
using SqlSugar;
using System.Reflection;
using System.Reflection.Emit;
+using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using WIDESEA_BasicService;
@@ -98,6 +99,7 @@
private readonly IRepository<Dt_TakeStockOrder> _takeStockOrder;
public readonly IRepository<Dt_LocationType> _locationTypeRepository;
public readonly IRepository<Dt_WarehouseArea> _warehouseAreaRepository;
+ private readonly IRepository<Dt_OutStockLockInfo> _outboundLockInfoRepository;
public IRepository<Dt_Task> Repository => BaseDal;
private Dictionary<string, SqlSugar.OrderByType> _taskOrderBy = new()
@@ -117,7 +119,7 @@
public List<int> TaskOutboundTypes => typeof(TaskTypeEnum).GetEnumIndexList();
- public TaskService(IRepository<Dt_Task> BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IRepository<Dt_StockInfo> stockRepository, ILocationInfoService locationInfoService, IInboundOrderService inboundOrderService, ILocationStatusChangeRecordService locationStatusChangeRecordService, IESSApiService eSSApiService, ILogger<TaskService> logger, IStockService stockService, IRecordService recordService, IInboundOrderDetailService inboundOrderDetailService, IOutboundOrderService outboundOrderService, IOutboundOrderDetailService outboundOrderDetailService, IInvokeMESService invokeMESService, IOutStockLockInfoService outStockLockInfoService, IAllocateService allocateService, IRepository<Dt_OutboundBatch> outboundBatchRepository, IRepository<Dt_ReCheckOrder> reCheckOrderRepository, IRepository<Dt_AllocateOrderDetail> allocateOrderDetailRepository, IRepository<Dt_AllocateOrder> allocateOrderRepository, IMaterialUnitService materialUnitService, ITask_HtyService task_HtyService, IRepository<Dt_AllocateMaterialInfo> allocateMaterialInfo, IRepository<Dt_AllocateMaterialInfo_Hty> allocateMaterialInfo_Hty, HttpClientHelper httpClientHelper, IBasicService basicService,IRepository<Dt_TakeStockOrder> takeStockOrder, IRepository<Dt_LocationType> locationTypeRepository, IRepository<Dt_WarehouseArea> warehouseAreaRepository) : base(BaseDal)
+ public TaskService(IRepository<Dt_Task> BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IRepository<Dt_StockInfo> stockRepository, ILocationInfoService locationInfoService, IInboundOrderService inboundOrderService, ILocationStatusChangeRecordService locationStatusChangeRecordService, IESSApiService eSSApiService, ILogger<TaskService> logger, IStockService stockService, IRecordService recordService, IInboundOrderDetailService inboundOrderDetailService, IOutboundOrderService outboundOrderService, IOutboundOrderDetailService outboundOrderDetailService, IInvokeMESService invokeMESService, IOutStockLockInfoService outStockLockInfoService, IAllocateService allocateService, IRepository<Dt_OutboundBatch> outboundBatchRepository, IRepository<Dt_ReCheckOrder> reCheckOrderRepository, IRepository<Dt_AllocateOrderDetail> allocateOrderDetailRepository, IRepository<Dt_AllocateOrder> allocateOrderRepository, IMaterialUnitService materialUnitService, ITask_HtyService task_HtyService, IRepository<Dt_AllocateMaterialInfo> allocateMaterialInfo, IRepository<Dt_AllocateMaterialInfo_Hty> allocateMaterialInfo_Hty, HttpClientHelper httpClientHelper, IBasicService basicService,IRepository<Dt_TakeStockOrder> takeStockOrder, IRepository<Dt_LocationType> locationTypeRepository, IRepository<Dt_WarehouseArea> warehouseAreaRepository, IRepository<Dt_OutStockLockInfo> outboundLockInfoRepository) : base(BaseDal)
{
_mapper = mapper;
_unitOfWorkManage = unitOfWorkManage;
@@ -148,6 +150,7 @@
_takeStockOrder = takeStockOrder;
_locationTypeRepository = locationTypeRepository;
_warehouseAreaRepository = warehouseAreaRepository;
+ _outboundLockInfoRepository = outboundLockInfoRepository;
}
public async Task TaskStatusChange(string taskNum, TaskStatusEnum taskStatusEnum)
@@ -388,7 +391,7 @@
allocatefeedmodel.Details = groupedData;
var response = responseModel(inboundOrder, 3, null, allocatefeedmodel);
- if (response != null && response.IsSuccess)
+ if (response != null && response.IsSuccess && response.Data.Code =="200")
{
var detailStatusList = _inboundOrderDetailService.Db.Queryable<Dt_InboundOrderDetail>()
.Where(it => it.OrderId == inboundOrder.Id)
@@ -453,7 +456,7 @@
}
else
{
- if (inboundOrder != null && inboundOrder.OrderStatus == InOrderStatusEnum.鍏ュ簱瀹屾垚.ObjToInt())
+ if (inboundOrder != null && inboundOrder.OrderStatus == InOrderStatusEnum.鍏ュ簱瀹屾垚.ObjToInt() && inboundOrder.CreateType == (int)OrderCreateTypeEnum.UpperSystemPush)
{
var feedmodel = new FeedbackInboundRequestModel
{
@@ -493,7 +496,7 @@
var response= responseModel(inboundOrder,2, feedmodel);
- if (response != null && response.IsSuccess)
+ if (response != null && response.IsSuccess && response.Data.Code == "200")
{
var detailStatusList = _inboundOrderDetailService.Db.Queryable<Dt_InboundOrderDetail>()
.Where(it => it.OrderId == inboundOrder.Id)
@@ -2231,7 +2234,7 @@
/// <summary>
/// 鐩樼偣鍑哄簱瀹屾垚
/// </summary>
- public WebResponseContent OutInventoryTaskCompleted(Dt_Task task)
+ public async Task<WebResponseContent> OutInventoryTaskCompleted(Dt_Task task)
{
WebResponseContent content = new WebResponseContent();
try
@@ -2282,7 +2285,7 @@
catch (Exception ex)
{
_unitOfWorkManage.RollbackTran();
- content.Error(ex.Message);
+ return await Task.FromResult(WebResponseContent.Instance.Error(ex.Message));
}
return content;
}
@@ -2451,6 +2454,135 @@
return await Task.FromResult(WebResponseContent.Instance.Error(ex.Message));
}
}
+
+ /// <summary>
+ /// 浠诲姟鍙栨秷
+ /// </summary>
+ /// <param name="taskCodes"></param>
+ /// <returns></returns>
+ /// <summary>
+ public async Task<WebResponseContent> TaskCancel(List<int> taskCodes)
+ {
+ try
+ {
+ if (taskCodes == null || !taskCodes.Any())
+ {
+ return WebResponseContent.Instance.Error("鍙栨秷鐨勪换鍔″彿涓嶈兘涓虹┖");
+ }
+
+ //var taskCancelUrl = AppSettings.GetValue("TaskCancelUrl");
+ //TaskCancelRequest taskc = new TaskCancelRequest();
+ //taskc.TaskCodes = taskCodes.Select(x => x.ToString()).ToList();
+
+ //string json = JsonConvert.SerializeObject(taskc);
+
+ //using var clientHttp = new HttpClient();
+ //var content = new StringContent(json, Encoding.UTF8, "application/json");
+
+ //HttpResponseMessage response = await clientHttp.PostAsync(taskCancelUrl,content);
+
+ //string responseJson = await response.Content.ReadAsStringAsync();
+ //TaskCancelApiResponse apiResponse = JsonConvert.DeserializeObject<TaskCancelApiResponse>(responseJson);
+
+ //if (apiResponse.Code != 0)
+ //{
+ // return WebResponseContent.Instance.Error($"璇锋眰澶辫触锛歿apiResponse.Msg}");
+ //}
+ _unitOfWorkManage.BeginTran();
+
+ var tasks = await Db.Queryable<Dt_Task>()
+ .Where(x => taskCodes.Contains(x.TaskNum))
+ .ToListAsync();
+
+ if (!tasks.Any())
+ {
+ _unitOfWorkManage.RollbackTran();
+ return WebResponseContent.Instance.Error("鏈壘鍒板搴旂殑浠诲姟淇℃伅");
+ }
+
+ int inPickType = TaskTypeEnum.InPick.ObjToInt();
+ var inboundTypes = new List<int>
+ {
+ TaskTypeEnum.InAllocate.ObjToInt(),
+ TaskTypeEnum.InEmpty.ObjToInt(),
+ TaskTypeEnum.Inbound.ObjToInt(),
+ TaskTypeEnum.InInventory.ObjToInt(),
+ TaskTypeEnum.InQuality.ObjToInt()
+ };
+ var outboundTypes = new List<int>
+ {
+ TaskTypeEnum.Outbound.ObjToInt(),
+ TaskTypeEnum.OutAllocate.ObjToInt()
+ };
+
+ foreach (var task in tasks)
+ {
+ if (task.TaskStatus == TaskStatusEnum.Cancel.ObjToInt())
+ continue;
+
+ var stock = await _stockRepository.QueryFirstAsync(x => x.PalletCode == task.PalletCode);
+ if (stock == null)
+ throw new Exception($"鎵樼洏 {task.PalletCode} 鏈壘鍒板簱瀛樹俊鎭�");
+
+ if (task.TaskType == inPickType)
+ {
+ stock.StockStatus = StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt();
+ }
+ else if (inboundTypes.Contains(task.TaskType))
+ {
+ stock.StockStatus = StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt();
+ }
+ else if (outboundTypes.Contains(task.TaskType))
+ {
+ stock.StockStatus = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt();
+
+ var outStockLock = await _outStockLockInfoService.Db
+ .Queryable<Dt_OutStockLockInfo>()
+ .Where(x => x.PalletCode == task.PalletCode)
+ .FirstAsync();
+
+ if (outStockLock == null)
+ throw new Exception($"鎵樼洏 {task.PalletCode} 鏈壘鍒板嚭搴撻攣瀹氫俊鎭�");
+
+ int detailId = outStockLock.OrderDetailIds.ObjToInt();
+ var outboundDetail = await _outboundOrderDetailService.Db
+ .Queryable<Dt_OutboundOrderDetail>()
+ .Where(x => x.Id == detailId)
+ .FirstAsync();
+
+ if (outboundDetail == null)
+ throw new Exception($"鍑哄簱鏄庣粏ID {detailId} 涓嶅瓨鍦�");
+
+ if (outboundDetail.LockQuantity < outStockLock.AssignQuantity)
+ throw new Exception($"鍑哄簱鏄庣粏 {detailId} 閿佸畾鏁伴噺涓嶈冻");
+
+ outboundDetail.LockQuantity -= outStockLock.AssignQuantity;
+ _outboundOrderDetailService.UpdateData(outboundDetail);
+
+ _outboundLockInfoRepository.DeleteAndMoveIntoHty(outStockLock, OperateTypeEnum.浜哄伐鍒犻櫎);
+ }
+
+ await _stockRepository.UpdateDataAsync(stock);
+
+ task.TaskStatus = TaskStatusEnum.Cancel.ObjToInt();
+ bool archiveSuccess = _task_HtyService.DeleteAndMoveIntoHty(task, OperateTypeEnum.浜哄伐鍒犻櫎);
+
+ if (!archiveSuccess)
+ {
+ await Db.Deleteable(task).ExecuteCommandAsync();
+ }
+ }
+
+ _unitOfWorkManage.CommitTran();
+ return WebResponseContent.Instance.OK("浠诲姟鍙栨秷鎴愬姛");
+ }
+ catch (Exception ex)
+ {
+ _unitOfWorkManage.RollbackTran();
+ _logger.LogError(ex, "浠诲姟鍙栨秷寮傚父");
+ return WebResponseContent.Instance.Error($"浠诲姟鍙栨秷澶辫触锛歿ex.Message}");
+ }
+ }
}
}
--
Gitblit v1.9.3