From 28bfb5dc1e3c0ce432e93e7af5a1c78a1a09e061 Mon Sep 17 00:00:00 2001
From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com>
Date: 星期三, 15 十月 2025 15:45:57 +0800
Subject: [PATCH] 更新 ResponeAgingInputDto 属性类型及数据库文件
---
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MCS/Partial/RequestChangeLocation.cs | 270 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 268 insertions(+), 2 deletions(-)
diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MCS/Partial/RequestChangeLocation.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MCS/Partial/RequestChangeLocation.cs
index f4a39da..450c86c 100644
--- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MCS/Partial/RequestChangeLocation.cs
+++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MCS/Partial/RequestChangeLocation.cs
@@ -1,11 +1,20 @@
-锘縰sing Newtonsoft.Json;
+锘縰sing AngleSharp.Dom;
+using log4net.Core;
+using Masuit.Tools;
+using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using WIDESEA_Common;
using WIDESEA_Core;
+using WIDESEA_Core.Const;
+using WIDESEA_Core.Enums;
+using WIDESEA_Core.Helper;
using WIDESEA_DTO;
+using WIDESEA_DTO.WMS;
+using WIDESEA_Model.Models;
namespace WIDESEA_StoragIntegrationServices
{
@@ -21,18 +30,275 @@
WebResponseContent content = new WebResponseContent();
try
{
- if (string.IsNullOrEmpty(json.ToString())) throw new Exception("涓婁紶鍙傛暟涓虹┖");
+ if (string.IsNullOrEmpty(json.ToString())) throw new Exception("璇锋眰鍙傛暟涓虹┖");
var result = JsonConvert.DeserializeObject<RequestReMove>(json.ToString());
+ var location = _locationRepository.QueryFirst(x => x.AreaId == result.LocationArea && x.LocationCode == result.LocationID);
+ if (location == null) throw new Exception("鏈煡搴撲綅");
+ if (_taskRepository.QueryFirst(x => x.SourceAddress == result.LocationID && x.Roadway == location.RoadwayNo) != null)
+ {
+ throw new Exception("褰撳墠搴撲綅宸插瓨鍦ㄤ换鍔�");
+ }
+
+ switch (result.MoveType)
+ {
+ case 1:
+ CreateMoveTask(location);
+ break;
+ case 5:
+ CreateFireTask(location);
+ break;
+ default:
+ throw new Exception("鏃犳晥鐨勭Щ搴撶敵璇风被鍨�");
+ }
+
+ #region 鐏鍑哄簱
+ //if (result.MoveType == 5)
+ //{
+ // Console.WriteLine($"鍒嗗妫�娴嬫煖鐏瑙﹀彂:搴撲綅{result.LocationID}");
+
+ // //鏌ユ壘娑堥槻绔欏彴
+ // var station = _stationManagerRepository.QueryFirst(t => t.Roadway == location.RoadwayNo
+ // && t.stationType == (int)StationManager.FireStation
+ // /*&& t. == "Enable"*/);
+ // if (station == null)
+ // {
+ // throw new Exception("娑堥槻绔欏彴鏈厤缃�!");
+ // }
+ // //鏌ユ壘搴撳瓨淇℃伅
+ // var barcodeData = _stockInfoRepository.QueryFirst(t => t.LocationCode == location.LocationCode);
+ // //鎵樼洏鐮�
+ // string barcode = string.Empty;
+ // if (barcodeData != null)
+ // {
+ // barcode = barcodeData.PalletCode;
+ // }
+ // else
+ // {
+ // //鏃犲簱瀛樹俊鎭紝鐢熸垚闅忔満鎵樼洏鐮�
+ // barcode = "M" + DateTime.Now.ToString("MMddHHmmss") + "-" + new Random().Next(100, 1000);
+ // }
+ // int taskNum = _taskRepository.GetTaskNo().Result;
+ // Dt_Task task = new Dt_Task
+ // {
+ // CreateDate = DateTime.Now,
+ // Creater = "HK",
+ // CurrentAddress = result.LocationID,
+ // Grade = 1,
+ // Dispatchertime = DateTime.Now,
+ // PalletCode = barcode,
+ // Roadway = location.RoadwayNo,
+ // SourceAddress = result.LocationID,
+ // TaskState = (int)TaskOutStatusEnum.OutNew,
+ // TaskType = 500,
+ // TargetAddress = station.stationLocation,
+ // NextAddress = station.stationChildCode,
+ // TaskNum = taskNum, //_taskRepository.GetTaskNo().Result,
+ // TaskId = 0,
+ // };
+
+ // // 灏濊瘯娣诲姞鏂颁换鍔�
+ // WMSTaskDTO taskDTO = new WMSTaskDTO()
+ // {
+ // TaskNum = task.TaskNum.Value,
+ // Grade = 1,
+ // PalletCode = task.PalletCode,
+ // RoadWay = task.Roadway,
+ // SourceAddress = task.SourceAddress,
+ // TargetAddress = task.TargetAddress,
+ // TaskState = task.TaskState.Value,
+ // Id = 0,
+ // TaskType = 500,
+ // };
+ //}
+ #endregion
+
+ LogFactory.GetLog("鍒嗗绉诲簱鐢宠").Info(true, $"\r\r--------------------------------------");
+ LogFactory.GetLog("鍒嗗绉诲簱鐢宠").Info(true, result.ToJsonString());
return content.OK();
}
catch (Exception ex)
{
+ LogFactory.GetLog("鍒嗗绉诲簱鐢宠").Info(true, $"\r\r--------------------------------------");
+ LogFactory.GetLog("鍒嗗绉诲簱鐢宠").Info(true, ex.Message);
return content.Error(ex.Message);
}
}
+
+ private void CreateMoveTask(DtLocationInfo location)
+ {
+ Console.WriteLine($"鍒嗗鐢宠绉诲簱:搴撲綅{location.LocationCode}");
+
+ //鏌ユ壘鍙敤搴撲綅
+ DtLocationInfo CanRelocation = _locationRepository.QueryFirst(x => x.LocationStatus == (int)LocationEnum.Free && x.RoadwayNo == location.RoadwayNo && x.EnalbeStatus == 1 && x.LocationType == 2 && x.Remark == "1");
+
+ if (CanRelocation == null) throw new Exception("鐢宠绉诲簱澶辫触锛氭棤鍙敤搴撲綅");
+
+ //鏌ユ壘搴撳瓨淇℃伅
+ var stockInfo = _stockInfoRepository.QueryFirst(x => x.LocationCode == location.LocationCode && x.LocationInfo.RoadwayNo == location.RoadwayNo);
+
+ if (stockInfo == null) throw new Exception("鐢宠绉诲簱澶辫触锛氭棤搴撳瓨璁板綍");
+
+ //淇敼绉诲簱鐩爣搴撲綅鐘舵��
+ CanRelocation.LocationStatus = (int)LocationEnum.FreeDisable;
+
+ int taskNum = _taskRepository.GetTaskNo().Result;
+ Dt_Task task = new Dt_Task
+ {
+ CreateDate = DateTime.Now,
+ Creater = "HK",
+ CurrentAddress = location.LocationCode,
+ Grade = 1,
+ Dispatchertime = DateTime.Now,
+ PalletCode = stockInfo.PalletCode,
+ Roadway = location.RoadwayNo,
+ SourceAddress = location.LocationCode,
+ TaskState = (int)TaskStatus.Created,
+ TaskType = (int)TaskRelocationTypeEnum.Relocation,
+ TargetAddress = CanRelocation.LocationCode,
+ NextAddress = CanRelocation.LocationCode,
+ TaskNum = taskNum, //_taskRepository.GetTaskNo().Result,
+ TaskId = 0,
+ };
+
+ // 灏濊瘯娣诲姞鏂颁换鍔�
+ WMSTaskDTO taskDTO = new WMSTaskDTO()
+ {
+ TaskNum = task.TaskNum.Value,
+ Grade = 1,
+ PalletCode = task.PalletCode,
+ RoadWay = task.Roadway,
+ SourceAddress = task.SourceAddress,
+ TargetAddress = task.TargetAddress,
+ TaskState = task.TaskState.Value,
+ Id = 0,
+ TaskType = task.TaskType,
+ };
+
+ 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)
+ {
+ //娣诲姞WMS浠诲姟 骞朵慨鏀瑰簱浣嶇姸鎬�
+ var taskId = _taskRepository.AddData(task);
+ _locationRepository.UpdateData(CanRelocation);
+ }
+ else
+ {
+ throw new Exception("WCS澶勭悊澶辫触:" + respone.Message);
+ }
+ }
+ else
+ {
+ throw new Exception("WCS澶勭悊澶辫触");
+ }
+ }
+
+
+ private void CreateFireTask(DtLocationInfo location)
+ {
+ Console.WriteLine($"鍒嗗妫�娴嬫煖鐏瑙﹀彂:搴撲綅{location.LocationCode}");
+
+ //鏌ユ壘娑堥槻绔欏彴
+ var station = _stationManagerRepository.QueryFirst(t => t.Roadway == location.RoadwayNo
+ && t.stationType == (int)StationManager.FireStation
+ /*&& t. == "Enable"*/);
+ if (station == null)
+ {
+ throw new Exception("娑堥槻绔欏彴鏈厤缃�!");
+ }
+ //鏌ユ壘搴撳瓨淇℃伅
+ var barcodeData = _stockInfoRepository.QueryFirst(t => t.LocationCode == location.LocationCode && t.LocationInfo.RoadwayNo == location.RoadwayNo);
+ //鎵樼洏鐮�
+ string barcode = string.Empty;
+ if (barcodeData != null)
+ {
+ barcode = barcodeData.PalletCode;
+ }
+ else
+ {
+ //鏃犲簱瀛樹俊鎭紝鐢熸垚闅忔満鎵樼洏鐮�
+ barcode = "M" + DateTime.Now.ToString("MMddHHmmss") + "-" + new Random().Next(100, 1000);
+ }
+ int taskNum = _taskRepository.GetTaskNo().Result;
+ Dt_Task task = new Dt_Task
+ {
+ CreateDate = DateTime.Now,
+ Creater = "HK",
+ CurrentAddress = location.LocationCode,
+ Grade = 1,
+ Dispatchertime = DateTime.Now,
+ PalletCode = barcode,
+ Roadway = location.RoadwayNo,
+ SourceAddress = location.LocationCode,
+ TaskState = (int)TaskOutStatusEnum.OutNew,
+ TaskType = 500,
+ TargetAddress = station.stationLocation,
+ NextAddress = station.stationChildCode,
+ TaskNum = taskNum, //_taskRepository.GetTaskNo().Result,
+ TaskId = 0,
+ };
+
+ // 灏濊瘯娣诲姞鏂颁换鍔�
+ WMSTaskDTO taskDTO = new WMSTaskDTO()
+ {
+ TaskNum = task.TaskNum.Value,
+ Grade = 1,
+ PalletCode = task.PalletCode,
+ RoadWay = task.Roadway,
+ SourceAddress = task.SourceAddress,
+ TargetAddress = task.TargetAddress,
+ TaskState = task.TaskState.Value,
+ Id = 0,
+ TaskType = 500,
+ };
+
+
+
+ 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.ReceiveWMSTask)?.ConfigValue;
+ if (ReceiveByWMSTask == null || ipAddress == null)
+ {
+ throw new Exception("WMS IP 鏈厤缃�");
+ }
+ var wmsIpAddrss = ipAddress + ReceiveByWMSTask;
+
+ List<WMSTaskDTO> fireTaskDTO = new List<WMSTaskDTO>();
+ fireTaskDTO.Add(taskDTO);
+
+ var respon = HttpHelper.Post(wmsIpAddrss, JsonConvert.SerializeObject(fireTaskDTO)); //http://localhost:9291/api/Task/ReceiveTask,
+ if (respon != null)
+ {
+ WebResponseContent respone = JsonConvert.DeserializeObject<WebResponseContent>(respon.ToString());
+ if (respone.Status)
+ {
+ var taskId = _taskRepository.AddData(task);
+ }
+
+ else
+ {
+ throw new Exception("WCS澶勭悊澶辫触:" + respone.Message);
+ }
+ }
+ else
+ {
+ throw new Exception("WCS澶勭悊澶辫触");
+ }
+ }
}
}
\ No newline at end of file
--
Gitblit v1.9.3