From 06e0e3b7d61e95902a6129de2490461cd0693e1d Mon Sep 17 00:00:00 2001
From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com>
Date: 星期三, 15 十月 2025 15:06:40 +0800
Subject: [PATCH] 新增异步方法并优化服务调用逻辑在多个数据库文件中进行了二进制文件的修改、删除和新增操作,可能涉及数据库内容的更新或重建。在 HttpsClient.cs文件中新增了 PostNotLimitAsync方法,用于发送支持 JSON 格式的异步 HTTP POST 请求,并记录请求和响应参数。在 AgingInOrOutInputService.cs文件中,将 HttpsClient.PostAsync替换为PostNotLimitAsync,以利用新方法的功能特性。同时删除了不再需要的注释代码。
---
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Location/LocationInfoService.cs | 103 ++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 100 insertions(+), 3 deletions(-)
diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Location/LocationInfoService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Location/LocationInfoService.cs
index 81c370b..d39fe99 100644
--- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Location/LocationInfoService.cs
+++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Location/LocationInfoService.cs
@@ -3,7 +3,10 @@
using System.Threading.Tasks;
using WIDESEA_Common;
using WIDESEA_Core;
+using WIDESEA_Core.Const;
using WIDESEA_DTO;
+using WIDESEA_DTO.WMS;
+using WIDESEA_IServices;
using WIDESEA_Model.Models;
namespace WIDESEA_StorageBasicService;
@@ -19,7 +22,9 @@
private readonly IDt_WareAreaInfoRepository _wareAreaInfoRepository;
private readonly IPointStackerRelationRepository _pointStackerRelationRepository;
private readonly ITaskExecuteDetailRepository _taskExecuteDetailRepository;
+ private readonly IDt_AreaInfoRepository _AreaInfoRepository;
private readonly ILocationStatusChangeRecordRepository _locationStatusChangeRecordRepository;
+ private readonly ISys_ConfigService _configService;
private readonly IMapper _mapper;
public LocationInfoService(ILocationInfoRepository BaseDal,
@@ -32,7 +37,9 @@
ILocationStatusChangeRecordRepository locationStatusChangeRecordRepository,
IStockInfoDetailRepository stockInfoDetailRepository,
IMapper mapper,
- IDt_TaskService taskService) : base(BaseDal)
+ IDt_TaskService taskService,
+ IDt_AreaInfoRepository AreaInfoRepository,
+ ISys_ConfigService configService) : base(BaseDal)
{
_unitOfWorkManage = unitOfWorkManage;
_taskRepository = taskRepository;
@@ -44,6 +51,8 @@
_stockInfoDetailRepository = stockInfoDetailRepository;
_mapper = mapper;
_taskService = taskService;
+ _AreaInfoRepository = AreaInfoRepository;
+ _configService= configService;
}
/// <summary>
@@ -117,6 +126,94 @@
return base.UpdateData(saveModel);
}
+
+ public WebResponseContent HandOutTask(int locationID)
+ {
+ LogFactory.GetLog("鎵嬪姩鍑哄簱浠诲姟").InfoFormat(true, "鎵嬪姩鍑哄簱浠诲姟", JsonConvert.SerializeObject(locationID), App.User.UserName);
+ WebResponseContent content=new WebResponseContent();
+ try
+ {
+ Dt_AreaInfo areaInfo = _AreaInfoRepository.QueryFirst(x => x.AreaCode == "CWSC1");
+ DtLocationInfo location = BaseDal.QueryFirst(x => x.Id == locationID);
+ DtStockInfo stock = _stockInfoRepository.QueryFirst(x => x.LocationId == location.Id && x.LocationCode == location.LocationCode);
+ if (location.AreaId == areaInfo.AreaID)
+ {
+ Dt_Task task = new Dt_Task
+ {
+ Grade = 3,
+ Roadway = location.RoadwayNo,
+ TargetAddress = "001-035-001",
+ Dispatchertime = DateTime.Now,
+ MaterialNo = "",
+ NextAddress = "001-035-001",
+ OrderNo = null,
+ PalletCode = stock == null ? "M" + DateTime.Now.ToString("MMddHHmmss") + "-" + new Random().Next(100, 1000) : stock.PalletCode,
+ SourceAddress = location.LocationCode,
+ CurrentAddress = location.LocationCode,
+ TaskState = (int)TaskOutStatusEnum.OutNew,
+ TaskType = (int)TaskOutboundTypeEnum.InToOut,
+ TaskNum = _taskRepository.GetTaskNo().Result,
+ Creater = "System", // 淇鎷煎啓閿欒
+ CreateDate = DateTime.Now,
+ TaskId = 0,
+ ProductionLine = stock == null ? "" : stock.ProductionLine,
+ ProcessCode = stock == null ? "" : stock.ProcessCode,
+ };
+
+ var taskDTO = new WMSTaskDTO
+ {
+ TaskNum = task.TaskNum.Value,
+ Grade = task.Grade.Value,
+ PalletCode = task.PalletCode,
+ RoadWay = task.Roadway,
+ SourceAddress = task.SourceAddress,
+ TargetAddress = task.TargetAddress,
+ TaskState = task.TaskState.Value,
+ Id = 0,
+ TaskType = task.TaskType,
+ ProductionLine = task.ProductionLine,
+ };
+ var configs = _configService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
+ var ipAddress = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.WCSIPAddress)?.ConfigValue;
+ var ReceiveByWMSTask = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.ReceiveByWMSTask)?.ConfigValue;
+ if (ReceiveByWMSTask == null || ipAddress == null)
+ {
+ throw new Exception("WMS IP 鏈厤缃�");
+ }
+ var wmsIpAddrss = ipAddress + ReceiveByWMSTask;
+
+ var respon = HttpHelper.Post(wmsIpAddrss, JsonConvert.SerializeObject(taskDTO)); //http://localhost:9291/api/Task/ReceiveTask,
+ if (respon != null)
+ {
+ WebResponseContent respone = JsonConvert.DeserializeObject<WebResponseContent>(respon.ToString());
+ if (respone.Status)
+ {
+ var taskId = _taskRepository.AddData(task);
+ location.LocationStatus = (int)LocationEnum.InStockDisable;
+ BaseDal.UpdateData(location);
+ }
+ else
+ {
+ throw new Exception("WCS澶勭悊澶辫触:" + respone.Message);
+ }
+ }
+ else
+ {
+ throw new Exception("WCS澶勭悊澶辫触");
+ }
+ return content.OK("浠诲姟娣诲姞鎴愬姛锛�");
+ }
+ else
+ {
+ return content.Error("涓嶆槸甯告俯璐т綅锛屼笉鍏佽鍑哄簱锛侊紒");
+ }
+ }
+ catch (Exception ex)
+ {
+ return content.Error(ex.Message);
+ }
+ }
+
#region 鍒濆鍖栧簱浣�
public async Task<WebResponseContent> initializeLocation(int locationID)
{
@@ -132,7 +229,7 @@
DtStockInfo stock = _stockInfoRepository.QueryFirst(x => x.LocationId == location.Id);
if(stock == null)
{
- location.LocationStatus= (int)LocationEnum.Lock;
+ location.LocationStatus= (int)LocationEnum.Free;
BaseDal.UpdateData(location);
}
else
@@ -151,7 +248,7 @@
await AddStockInfoHtyAsync(stockInfo_Hty);
- location.LocationStatus = (int)LocationEnum.Lock;
+ location.LocationStatus = (int)LocationEnum.Free;
BaseDal.UpdateData(location);
_locationStatusChangeRecordRepository.AddLocationStatusChangeRecord(location, LastStatus, (int)StatusChangeTypeEnum.ManualOperation, 0);
--
Gitblit v1.9.3