From c3ed42924f19d383dd643814b754d60b392496d3 Mon Sep 17 00:00:00 2001 From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com> Date: 星期三, 16 七月 2025 19:22:07 +0800 Subject: [PATCH] 添加常温直接出库功能,增加实框入库存在任务发往异常口 --- Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Basic/LocationInfoController.cs | 6 + Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/GWTask/RequestInbound.cs | 2 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_IStorageBasicService/Location/ILocationInfoService.cs | 2 Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/appsettings.json | 2 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs | 16 +- Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Location/LocationInfoService.cs | 103 ++++++++++++++++ Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs | 13 + Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Partial/TaskService.cs | 24 +++- Code Management/WMS/WIDESEA_WMSClient/src/api/buttons.js | 11 + Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs | 84 +++++++++---- Code Management/WMS/WIDESEA_WMSClient/src/extension/widesea_wms/basicinfo/Dt_LocationInfo.jsx | 21 +++ Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs | 25 +++ 12 files changed, 259 insertions(+), 50 deletions(-) diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/appsettings.json b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/appsettings.json index 3c01be4..ab8ccef 100644 --- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/appsettings.json +++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/appsettings.json @@ -12,7 +12,7 @@ "MainDB": "DB_WIDESEA", //褰撳墠椤圭洰鐨勪富搴擄紝鎵�瀵瑰簲鐨勮繛鎺ュ瓧绗︿覆鐨凟nabled蹇呴』涓簍rue //杩炴帴瀛楃涓� //"ConnectionString": "Data Source=.\\LIULEI;Initial Catalog=WIDESEA_WCSDBB2F;User ID=sa;Password=123456;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", - "ConnectionString": "Data Source=.;Initial Catalog=WIDESEA_WCSDB_BBMain;User ID=sa;Password=123456;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", + "ConnectionString": "Data Source=.;Initial Catalog=WIDESEA_WCSDB;User ID=sa;Password=P@ssw0rd;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", //璺ㄥ煙 "Cors": { "PolicyName": "CorsIpAccess", //绛栫暐鍚嶇О diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Partial/TaskService.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Partial/TaskService.cs index 00395f2..f93798d 100644 --- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Partial/TaskService.cs +++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Partial/TaskService.cs @@ -443,12 +443,24 @@ if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) { - var stationinfo = _stationManagerRepository.QueryFirst(x => x.stationLocation == taskDTO.TargetAddress && x.Roadway == taskDTO.RoadWay); - task.TaskState = (int)TaskOutStatusEnum.OutNew; - task.CurrentAddress = taskDTO.RoadWay; - task.NextAddress = stationinfo.stationChildCode; - task.SourceAddress = taskDTO.SourceAddress; - task.TargetAddress = taskDTO.TargetAddress; + if (task.TaskType == (int)TaskOutboundTypeEnum.InToOut) + { + var stationinfo = _stationManagerRepository.QueryFirst(x => x.stationPLC == "1017" && x.stationType == 10&&x.Roadway==taskDTO.RoadWay); + task.TaskState = (int)TaskOutStatusEnum.OutNew; + task.CurrentAddress = taskDTO.SourceAddress; + task.NextAddress = stationinfo.stationChildCode; + task.SourceAddress = taskDTO.SourceAddress; + task.TargetAddress = taskDTO.TargetAddress; + } + else + { + var stationinfo = _stationManagerRepository.QueryFirst(x => x.stationLocation == taskDTO.TargetAddress && x.Roadway == taskDTO.RoadWay); + task.TaskState = (int)TaskOutStatusEnum.OutNew; + task.CurrentAddress = taskDTO.RoadWay; + task.NextAddress = stationinfo.stationChildCode; + task.SourceAddress = taskDTO.SourceAddress; + task.TargetAddress = taskDTO.TargetAddress; + } } else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup) { diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs index dd4e3a2..94d21a5 100644 --- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs +++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs @@ -24,6 +24,7 @@ using WIDESEAWCS_QuartzJob.Models; using WIDESEAWCS_QuartzJob.Repository; using WIDESEAWCS_QuartzJob.Service; +using WIDESEAWCS_TaskInfoRepository; using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database; namespace WIDESEAWCS_TaskInfoService @@ -204,7 +205,15 @@ var hasTask = await BaseDal.QueryFirstAsync(x => x.PalletCode == palletCode); if (hasTask != null) { - return content.OK("褰撳墠鎵樼洏瀛樺湪浠诲姟"); + var taskExecuting = BaseDal.QueryFirst(x => x.PalletCode == palletCode && x.TaskState == (int)TaskOutStatusEnum.Line_OutExecuting); + + if (taskExecuting != null) + { + taskExecuting.ExceptionMessage = "鏈帴鏀跺埌绾夸綋瀹屾垚淇″彿绯荤粺鍐呴儴鑷姩瀹屾垚"; + Delete(taskExecuting); + } + ConsoleHelper.WriteErrorLine($"褰撳墠鎵樼洏瀛樺湪浠诲姟锛氥�恵palletCode}銆�"); + QuartzLogger.WriteLogToFile($"浠诲姟寮傚父鏈畬鎴�", $"褰撳墠鎵樼洏瀛樺湪浠诲姟锛氥�恵palletCode}銆憑Environment.NewLine}"); } var wmsIpAddrss = string.Empty; @@ -764,7 +773,7 @@ if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup && task.TaskState == (int)TaskOutStatusEnum.SC_OutExecuting) { - if (!task.Roadway.Contains("GW")) + if (!task.Roadway.Contains("GW") && task.TaskType != (int)TaskOutboundTypeEnum.InToOut) { var routers = _routerService.QueryNextRoutes(task.NextAddress, task.TargetAddress); if (!routers.Any()) return WebResponseContent.Instance.Error($"鏈壘鍒拌澶囪矾鐢变俊鎭�"); diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/GWTask/RequestInbound.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/GWTask/RequestInbound.cs index 5e28fa3..e3cd3d6 100644 --- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/GWTask/RequestInbound.cs +++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/GWTask/RequestInbound.cs @@ -344,7 +344,7 @@ } else { - if (content.Message != "璇锋眰杩囦簬棰戠箒锛岃绋嶅悗鍐嶈瘯" || content.Message != "鏃犳硶鑾峰彇鐩爣鍦板潃") + if (content.Message != "璇锋眰杩囦簬棰戠箒锛岃绋嶅悗鍐嶈瘯" && content.Message != "鏃犳硶鑾峰彇鐩爣鍦板潃") { WriteInfo(conveyorLine.DeviceName, content.Message); conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, stationManager.stationNGChildCode, childDeviceCode); diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs index 5206c1b..b5c54e0 100644 --- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs +++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs @@ -102,7 +102,17 @@ builder.AppendLine(); ConsoleHelper.WriteColorLine(builder, ConsoleColor.Blue); commonStackerCrane.LastTaskType = task.TaskType; - _taskService.UpdateTaskStatusToNext(task.TaskNum); + + if(task.TaskType == (int)TaskOutboundTypeEnum.InToOut) + { + task.TaskState = (int)TaskOutStatusEnum.SC_OutExecuting; + _taskRepository.AddData(task); + _taskService.StackCraneTaskCompleted(task.TaskNum); + } + else + { + _taskService.UpdateTaskStatusToNext(task.TaskNum); + } } } else @@ -496,7 +506,18 @@ } else { - if (((task.TargetAddress == "002-021-001" || task.TargetAddress == "001-021-001") && task.Roadway.Contains("JZ")) || task.TaskType == (int)TaskOutboundTypeEnum.OutFireAlarm) + if ( task.TaskType == (int)TaskOutboundTypeEnum.InToOut) + { + string[] endCodes = task.TargetAddress.Split("-"); + stackerCraneTaskCommand.EndRow = Convert.ToInt16(endCodes[0]); + stackerCraneTaskCommand.EndColumn = Convert.ToInt16(endCodes[1]); + stackerCraneTaskCommand.EndLayer = Convert.ToInt16(endCodes[2]); + string[] sourceCodes = task.SourceAddress.Split("-"); + stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[0]) % 2 != 0 ? (short)1 : (short)2; + stackerCraneTaskCommand.StartColumn = Convert.ToInt16(sourceCodes[1]); + stackerCraneTaskCommand.StartLayer = Convert.ToInt16(sourceCodes[2]); + } + else if (((task.TargetAddress == "002-021-001" || task.TargetAddress == "001-021-001") && task.Roadway.Contains("JZ")) || task.TaskType == (int)TaskOutboundTypeEnum.OutFireAlarm) { string[] endCodes = task.NextAddress.Split("-"); stackerCraneTaskCommand.EndRow = Convert.ToInt16(endCodes[0]); diff --git a/Code Management/WMS/WIDESEA_WMSClient/src/api/buttons.js b/Code Management/WMS/WIDESEA_WMSClient/src/api/buttons.js index 812e7d4..6481b4b 100644 --- a/Code Management/WMS/WIDESEA_WMSClient/src/api/buttons.js +++ b/Code Management/WMS/WIDESEA_WMSClient/src/api/buttons.js @@ -140,7 +140,16 @@ onClick: function () { } - } + },{ + name: '鎵嬪姩鍑哄簱', + type: 'primary', + // color: '#529b2e', + value: 'HandOutTask', + onClick: function () { + + } + + }, ] export default buttons diff --git a/Code Management/WMS/WIDESEA_WMSClient/src/extension/widesea_wms/basicinfo/Dt_LocationInfo.jsx b/Code Management/WMS/WIDESEA_WMSClient/src/extension/widesea_wms/basicinfo/Dt_LocationInfo.jsx index a9dcf94..d3f50ac 100644 --- a/Code Management/WMS/WIDESEA_WMSClient/src/extension/widesea_wms/basicinfo/Dt_LocationInfo.jsx +++ b/Code Management/WMS/WIDESEA_WMSClient/src/extension/widesea_wms/basicinfo/Dt_LocationInfo.jsx @@ -33,6 +33,27 @@ // this.$Message.success('鐐瑰嚮浜嗘寜閽�'); // } // }); + var HandOutTask = this.buttons.find(x => x.value == "HandOutTask"); + if (HandOutTask != null) { + HandOutTask.onClick = () => { + let rows = this.$refs.table.getSelected(); + if (rows.length == 0) return this.$error("璇烽�夋嫨鏁版嵁!"); + this.http + .post("api/LocationInfo/HandOutTask?locationID="+rows[0].id, "","鏁版嵁澶勭悊涓�...") + .then((x) => { + if (x.status) { + this.$Message.success('鎴愬姛.'); + this.refresh(); + } else { + return this.$error(x.message); + } + }); + } + } + + + + var btninitializeLocation = this.buttons.find(x => x.value == "initializeLocation"); if (btninitializeLocation != null) { btninitializeLocation.onClick = () => { diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_IStorageBasicService/Location/ILocationInfoService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_IStorageBasicService/Location/ILocationInfoService.cs index 316fa99..d9d5dc2 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_IStorageBasicService/Location/ILocationInfoService.cs +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_IStorageBasicService/Location/ILocationInfoService.cs @@ -14,4 +14,6 @@ Task<WebResponseContent> initializeLocation(int locationID); WebResponseContent CreateLocation(int x, int y, int z, int locType, int areaId); + + WebResponseContent HandOutTask(int locationID); } \ No newline at end of file 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..4f5a1b8 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 = 1, + 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); diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs index 55978af..ff4ee7c 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs @@ -617,13 +617,13 @@ } LogFactory.GetLog("浠诲姟瀹屾垚").InfoFormat(true, "楠岃瘉浠诲姟鏄惁瀛樺湪", JsonConvert.SerializeObject(task)); - if (task.TaskType == (int)TaskOutboundTypeEnum.InToOut) - { - return await CompleteInToOutTaskAsync(task); - } + // 楠岃瘉搴撳瓨鏄惁瀛樺湪 var stock = await _stockInfoRepository.QueryFirstNavAsync(x => x.PalletCode == task.PalletCode); - + if (task.TaskType == (int)TaskOutboundTypeEnum.InToOut) + { + return await CompleteInToOutTaskAsync(task,stock); + } // 鏍规嵁浠诲姟绫诲瀷璋冪敤鐩稿簲鐨勫畬鎴愪换鍔℃柟娉� switch (task.TaskType) { @@ -648,7 +648,6 @@ case (int)TaskRelocationTypeEnum.Relocation: return await CompleteTransferTaskAsync(task, stock); - default: return content.Error("浠诲姟绫诲瀷涓嶅瓨鍦�"); } @@ -675,6 +674,11 @@ var stock = await QueryStockInfo(input.PalletCode); if (stock != null) { + List<string> strings = new List<string>() { "GW","CW","FR"}; + if (stock.AreaCode.Contains(strings)) + { + return content.Error($"鎵樼洏銆恵stock.PalletCode}銆戝瓨鍦ㄥ簱瀛樹笉鍏佽鍏ュ簱"); + } Dt_Task taskNew = new Dt_Task { Grade = 1, diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs index f8c87c9..c0fedb2 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs @@ -1,4 +1,5 @@ -锘縰sing Masuit.Tools; +锘縰sing Mapster; +using Masuit.Tools; using SqlSugar; using WIDESEA_Common.CustomModels; using WIDESEA_Core.Const; @@ -183,26 +184,28 @@ if (!result.Success) { - var taskNG = new Dt_Task - { - CurrentAddress = input.Position, - Grade = 1, - Roadway = input.Roadways, - TargetAddress = stationManager.stationNGLocation, - Dispatchertime = DateTime.Now, - MaterialNo = "", - NextAddress = stationManager.stationNGChildCode, - OrderNo = null, - PalletCode = input.PalletCode, - SourceAddress = stationManager.stationLocation, - TaskState = (int)TaskInStatusEnum.Line_InFinish, - TaskType = (int)TaskOutboundTypeEnum.InToOut, - TaskNum = await BaseDal.GetTaskNo(), - Creater = "System", - ProductionLine = result.ProductionLine, - ProcessCode = result.ProcessCode, - }; - return taskNG; + //var taskNG = new Dt_Task + //{ + // CurrentAddress = input.Position, + // Grade = 1, + // Roadway = input.Roadways, + // TargetAddress = stationManager.stationNGLocation, + // Dispatchertime = DateTime.Now, + // MaterialNo = "", + // NextAddress = stationManager.stationNGChildCode, + // OrderNo = null, + // PalletCode = input.PalletCode, + // SourceAddress = stationManager.stationLocation, + // TaskState = (int)TaskInStatusEnum.Line_InFinish, + // TaskType = (int)TaskOutboundTypeEnum.InToOut, + // TaskNum = await BaseDal.GetTaskNo(), + // Creater = "System", + // ProductionLine = result.ProductionLine, + // ProcessCode = result.ProcessCode, + //}; + //return taskNG; + Console.WriteLine($"{result.MOMMessage}"); + return null; } if (result.SerialNos.Count <= 0) @@ -586,17 +589,42 @@ #region 鐩存帴鍑哄簱浠诲姟瀹屾垚 - public async Task<WebResponseContent> CompleteInToOutTaskAsync(Dt_Task task) + public async Task<WebResponseContent> CompleteInToOutTaskAsync(Dt_Task task,DtStockInfo stock) { WebResponseContent content = new WebResponseContent(); try { - //娣诲姞鍘嗗彶 - var taskHty = CreateHistoricalTask(task); - // 娣诲姞鍘嗗彶浠诲姟 - var isTaskHtyAdd = await _task_HtyRepository.AddDataAsync(taskHty) > 0; - //鍒犻櫎浠诲姟 - BaseDal.DeleteData(task); + DtStockInfo_Hty stockInfo_Hty = null; + if (stock != null) + { + stockInfo_Hty = stock.Adapt<DtStockInfo_Hty>(); + stockInfo_Hty.ModifyDate = DateTime.Now; + } + var taskHty = task.Adapt<Dt_Task_Hty>(); + taskHty.FinishTime = DateTime.Now; + taskHty.OperateType = App.User.UserName != null ? (int)OperateTypeEnum.浜哄伐瀹屾垚 : (int)OperateTypeEnum.鑷姩瀹屾垚; + taskHty.Creater = App.User.UserName != null ? App.User.UserName : "System"; + + var location = _locationRepository.QueryFirst(x => x.LocationCode == task.SourceAddress && x.RoadwayNo == task.Roadway); + int lastStatus = location.LocationStatus; + location.LocationStatus = (int)LocationEnum.Free; + task.TaskState = (int)TaskOutStatusEnum.OutFinish; + + _locationStatusChangeRecordRepository.AddLocationStatusChangeRecord(location, lastStatus, (int)StatusChangeTypeEnum.AutomaticDelivery, task.TaskNum); + // 浜嬪姟澶勭悊 + await _unitOfWorkManage.UseTranAsync(async () => + { + if (stockInfo_Hty != null) + { + await DeleteStockInfoAsync(stock.Id); + await DeleteStockInfoDetailsAsync(stock.StockInfoDetails); + await AddStockInfoHtyAsync(stockInfo_Hty); + } + + await UpdateLocationAsync(location); + await DeleteTaskAsync(task.TaskId); + await AddTaskHtyAsync(taskHty); + }); return content.OK(); } diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Basic/LocationInfoController.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Basic/LocationInfoController.cs index 627e3e0..3680d01 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Basic/LocationInfoController.cs +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Basic/LocationInfoController.cs @@ -30,4 +30,10 @@ { return await Service.initializeLocation(locationID); } + [HttpPost, AllowAnonymous, Route("HandOutTask")] + public WebResponseContent HandOutTask(int locationID) + { + return Service.HandOutTask(locationID); + } + } \ No newline at end of file -- Gitblit v1.9.3