From 6967501f2c484c04bb772ce9772247b0b8046bd1 Mon Sep 17 00:00:00 2001
From: heshaofeng <heshaofeng@hnkhzn.com>
Date: 星期五, 27 三月 2026 21:04:51 +0800
Subject: [PATCH] 1
---
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_Model/Models/Inbound/Dt_TakeStockOrder.cs | 1
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_DTO/Basic/ESSModel.cs | 46 +++++++++++
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/TaskInfo/TaskController.cs | 7 +
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_ITaskInfoService/ITaskService.cs | 2
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs | 136 +++++++++++++++++++++++++++++++++
5 files changed, 188 insertions(+), 4 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_DTO/Basic/ESSModel.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_DTO/Basic/ESSModel.cs"
index a0f33cb..b9df6cc 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_DTO/Basic/ESSModel.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_DTO/Basic/ESSModel.cs"
@@ -607,7 +607,49 @@
}
}
-
-
+ /// <summary>
+ /// 浠诲姟鍙栨秷璇锋眰鍙傛暟
+ /// </summary>
+ public class TaskCancelRequest
+ {
+ /// <summary>
+ /// 浠诲姟缂栧彿鍒楄〃锛堜笉鑳戒负绌猴級
+ /// </summary>
+ [JsonProperty("taskCodes")]
+ public List<string> TaskCodes { get; set; }
}
+
+ /// <summary>
+ /// 浠诲姟鍙栨秷杩斿洖缁撴灉
+ /// </summary>
+ public class TaskCancelResultItem
+ {
+ [JsonProperty("errorCode")]
+ public string ErrorCode { get; set; }
+
+ [JsonProperty("message")]
+ public string Message { get; set; }
+
+ [JsonProperty("taskCode")]
+ public string TaskCode { get; set; }
+ }
+
+ public class TaskCancelResponseData
+ {
+ [JsonProperty("tasks")]
+ public List<TaskCancelResultItem> Tasks { get; set; }
+ }
+
+ public class TaskCancelApiResponse
+ {
+ [JsonProperty("code")]
+ public int Code { get; set; }
+
+ [JsonProperty("msg")]
+ public string Msg { get; set; }
+
+ [JsonProperty("data")]
+ public TaskCancelResponseData Data { get; set; }
+ }
+}
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_ITaskInfoService/ITaskService.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_ITaskInfoService/ITaskService.cs"
index bf8c0a8..830fba1 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_ITaskInfoService/ITaskService.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_ITaskInfoService/ITaskService.cs"
@@ -77,5 +77,7 @@
HttpResponseResult<MesResponseDTO> responseModel(Dt_InboundOrder order, int InterfaceType, FeedbackInboundRequestModel model = null, AllocateDto allocateDto = null);
Task<WebResponseContent> HandCompleteTask(string TaskNum);
+
+ Task<WebResponseContent> TaskCancel(List<int> taskCodes);
}
}
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_Model/Models/Inbound/Dt_TakeStockOrder.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_Model/Models/Inbound/Dt_TakeStockOrder.cs"
index ee5433b..30acfbb 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_Model/Models/Inbound/Dt_TakeStockOrder.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_Model/Models/Inbound/Dt_TakeStockOrder.cs"
@@ -26,6 +26,7 @@
/// <summary>
/// 鐩樼偣鍗曞彿
/// </summary>
+ [CodeRule(RuleCodeEnum.PDCodeRule)]
[SugarColumn(IsNullable = false, Length = 50, ColumnDescription = "鐩樼偣鍗曞彿")]
public string OrderNo { get; set; }
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 3334efe..09e3cf5 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)
@@ -305,7 +308,7 @@
}
}
stockInfo.LocationCode = task.TargetAddress;
- stockInfo.StockStatus = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt();
+ stockInfo.StockStatus = StockStatusEmun.鍏ュ簱纭.ObjToInt();
stockInfo.Details.ForEach(x =>
{
x.Status = StockStatusEmun.鍏ュ簱纭.ObjToInt();
@@ -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}");
+ }
+ }
}
}
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_WMSServer/Controllers/TaskInfo/TaskController.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_WMSServer/Controllers/TaskInfo/TaskController.cs"
index 9546504..8d06ecc 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_WMSServer/Controllers/TaskInfo/TaskController.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_WMSServer/Controllers/TaskInfo/TaskController.cs"
@@ -9,6 +9,7 @@
using WIDESEA_Core;
using WIDESEA_Core.Attributes;
using WIDESEA_Core.BaseController;
+using WIDESEA_DTO.Basic;
using WIDESEA_DTO.Stock;
using WIDESEA_DTO.Task;
using WIDESEA_ITaskInfoService;
@@ -125,5 +126,11 @@
{
return await Service.HandCompleteTask(TaskNum);
}
+
+ [HttpPost, Route("TaskCancel"), AllowAnonymous]
+ public async Task<WebResponseContent> TaskCancel(List<int> taskCancel)
+ {
+ return await Service.TaskCancel(taskCancel);
+ }
}
}
--
Gitblit v1.9.3