From 829eabf256e29392ca63f6da48829dba3b075dfe Mon Sep 17 00:00:00 2001
From: huanghongfeng <huanghongfeng@hnkhzn.com>
Date: 星期五, 24 一月 2025 08:59:53 +0800
Subject: [PATCH] 资料,优化程序
---
代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs | 276 ++++++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 240 insertions(+), 36 deletions(-)
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs"
index 0fc8907..4fa7034 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs"
@@ -20,6 +20,7 @@
using NetTaste;
using Newtonsoft.Json;
using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
using SqlSugar;
using System;
@@ -40,14 +41,15 @@
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.BaseServices;
using WIDESEAWCS_Core.Enums;
+using WIDESEAWCS_Core.Utilities;
using WIDESEAWCS_DTO.Enum;
using WIDESEAWCS_DTO.TaskInfo;
using WIDESEAWCS_ITaskInfoRepository;
using WIDESEAWCS_ITaskInfoService;
using WIDESEAWCS_Model.Models;
-using WIDESEAWCS_QuartzJob;
using WIDESEAWCS_QuartzJob.Models;
using WIDESEAWCS_QuartzJob.Service;
+using static Microsoft.IO.RecyclableMemoryStreamManager;
namespace WIDESEAWCS_TaskInfoService
{
@@ -83,9 +85,10 @@
public string urlWMSTask = WIDESEAWCS_Core.Helper.AppSettings.Configuration["urlWMSTask"];
public string urlTaskCompleted = WIDESEAWCS_Core.Helper.AppSettings.Configuration["urlTaskCompleted"];
public string urlWMSMovelibraryTask = WIDESEAWCS_Core.Helper.AppSettings.Configuration["urlWMSMovelibraryTask"];
- public string urlRelocationTaskCompleted = WIDESEAWCS_Core.Helper.AppSettings.Configuration["urlRelocationTaskCompleted"];
public string urlQueryinventory = WIDESEAWCS_Core.Helper.AppSettings.Configuration["urlQueryinventory"];
public string urlEmptyOutbound = WIDESEAWCS_Core.Helper.AppSettings.Configuration["urlEmptyOutbound"];
+ public string urlRawmaterialout = WIDESEAWCS_Core.Helper.AppSettings.Configuration["urlRawmaterialout"];
+ public string urlPalletQueryinventory = WIDESEAWCS_Core.Helper.AppSettings.Configuration["urlPalletQueryinventory"];
/// <summary>
/// 鎺ユ敹WMS浠诲姟淇℃伅
/// </summary>
@@ -106,6 +109,7 @@
Dt_Task task = _mapper.Map<Dt_Task>(item);
task.TaskState = (int)TaskOutStatusEnum.OutNew;
task.Roadway = task.Roadway == "1" ? task.Roadway = "SC01" : task.Roadway = "SC02";
+ task.CreateDate = DateTime.Now;
tasks.Add(task);
}
BaseDal.AddData(tasks);
@@ -134,6 +138,14 @@
public string SourceAddress { get; set; }
public string PalletCode { get; set; }
}
+
+ public class GenerateInv3
+ {
+
+ public string PalletCode { get; set; }
+ public int outCount { get; set; }
+ public string TargetAddress { get; set; }
+ }
public WebResponseContent RequestWMSTask(string palletCode, string sourceAddress)
{
WebResponseContent content = new WebResponseContent();
@@ -154,24 +166,15 @@
task.TaskState = (int)TaskInStatusEnum.Line_InFinish;
task.Roadway = task.Roadway == "1" ? task.Roadway = "SC01" : task.Roadway = "SC02";
BaseDal.AddData(task);
- }
- else
- {
-
- return null;
+ return content = WebResponseContent.Instance.Error();
}
}
- else
- {
- return null;
- }
-
+ return content = WebResponseContent.Instance.Error();
}
catch (Exception ex)
{
- content = WebResponseContent.Instance.Error(ex.Message);
+ return content = WebResponseContent.Instance.Error(ex.Message);
}
- return content;
}
/// <summary>
/// 杩涜缁勭洏
@@ -180,8 +183,38 @@
/// <returns></returns>
public WebResponseContent ToPlatform(string palletCode)
{
- WebResponseContent content = new WebResponseContent();
- return content = HttpHelper.Get<WebResponseContent>($"{urlQueryinventory}?palletCode={palletCode}");
+ try
+ {
+ WebResponseContent content = new WebResponseContent();
+ GenerateInv generate = new GenerateInv()
+ {
+ SourceAddress = "",
+ PalletCode = palletCode
+ };
+
+ return content = HttpHelper.Post<WebResponseContent>($"{urlQueryinventory}", generate);
+ }
+ catch (Exception ex)
+ {
+
+ throw;
+ }
+
+ /*WebResponseContent content = new WebResponseContent();
+ GenerateInv generate = new GenerateInv()
+ {
+ SourceAddress = "",
+ PalletCode = palletCode
+ };
+ content = HttpHelper.Post<WebResponseContent>($"{urlQueryinventory}", generate);
+ if (content != null)
+ {
+ if (content.Status)
+ {
+ return content;
+ }
+ }
+ return content = WebResponseContent.Instance.Error();*/
}
/// <summary>
@@ -190,34 +223,93 @@
/// <param name="palletCode">鎵樼洏鍙�</param>
/// <param name="sourceAddress">璧峰鍦板潃</param>
/// <returns></returns>
- public WebResponseContent RequestWMSTask2(string sourceAddress)
+ public WebResponseContent RequestWMSTask2(string palletCode,string sourceAddress)
{
WebResponseContent content = new WebResponseContent();
try
{
- content = HttpHelper.Get<WebResponseContent>($"{urlEmptyOutbound}?sourceAddress={sourceAddress}");
+ GenerateInv generate = new GenerateInv()
+ {
+ SourceAddress = sourceAddress,
+ PalletCode = palletCode
+ };
+ content = HttpHelper.Post<WebResponseContent>($"{urlEmptyOutbound}", generate);
Dt_Task task = new Dt_Task();
if (content != null)
{
if (content.Status)
{
task = JsonConvert.DeserializeObject<Dt_Task>(content.Data.ToString());
- task.TaskState = (int)TaskInStatusEnum.Line_InFinish;
+ task.TaskState = (int)TaskOutStatusEnum.OutNew;
+ task.TaskType = (int)TaskOutboundTypeEnum.Outbound;
task.Roadway = task.Roadway == "1" ? task.Roadway = "SC01" : task.Roadway = "SC02";
BaseDal.AddData(task);
return content = WebResponseContent.Instance.OK();
}
else
{
-
- return content = WebResponseContent.Instance.Error();
+ WriteLog.GetLog("PLC鏃ュ織鍑哄簱鏃ュ織").Write($"绌烘墭鍑哄簱澶辫触锛岃鎯咃細{content.Message}", "闇�瑕佺┖鎵�");
}
}
- else
- {
- return content = WebResponseContent.Instance.Error();
- }
+ return content = WebResponseContent.Instance.Error();
+ }
+ catch (Exception ex)
+ {
+ return content = WebResponseContent.Instance.Error(ex.Message);
+ }
+ }
+ /// <summary>
+ /// 鏍规嵁鎵樼洏鍙枫�佽捣濮嬪湴鍧�鍚慦MS璇锋眰浠诲姟
+ /// </summary>
+ /// <param name="palletCode">鎵樼洏鍙�</param>
+ /// <param name="sourceAddress">璧峰鍦板潃</param>
+ /// <returns></returns>
+ public WebResponseContent RequestWMSTask3(string palletCode, int outCount,string Loc)
+ {
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+ if (outCount==0)
+ {
+ outCount = 1;
+ }
+ GenerateInv3 generate = new GenerateInv3()
+ {
+ PalletCode = palletCode,
+ outCount = outCount,
+ TargetAddress= Loc
+ };
+ content = HttpHelper.Post<WebResponseContent>($"{urlRawmaterialout}", generate);
+ Dt_Task task = new Dt_Task();
+ if (content != null)
+ {
+ if (content.Status)
+ {
+ task = JsonConvert.DeserializeObject<Dt_Task>(content.Data.ToString());
+ task.TaskState = (int)TaskOutStatusEnum.OutNew;
+ task.TaskType = (int)TaskOutboundTypeEnum.Outbound;
+ task.Roadway = task.Roadway == "1" ? task.Roadway = "SC01" : task.Roadway = "SC02";
+ BaseDal.AddData(task);
+ return content = WebResponseContent.Instance.OK();
+ }
+ }
+ return content = WebResponseContent.Instance.Error();
+ }
+ catch (Exception ex)
+ {
+ return content = WebResponseContent.Instance.Error(ex.Message);
+ }
+ }
+
+
+ public WebResponseContent RequestWMSTask4()
+ {
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+
+ return content = HttpHelper.Get<WebResponseContent>($"{urlPalletQueryinventory}");
}
catch (Exception ex)
{
@@ -239,16 +331,26 @@
{
if (content.Status)
{
- if (Convert.ToInt32(content.Data) != _Task.TaskNum)
+ if(content.Data != null)
{
task = JsonConvert.DeserializeObject<Dt_Task>(content.Data.ToString());
- task.TaskState = (int)TaskRelocationTypeEnum.Relocation;
- task.Roadway = task.Roadway == "1" ? task.Roadway = "SC01" : task.Roadway = "SC02";
- task.Grade = 3;
- BaseDal.AddData(task);
- return task;
- }
+ if (task.TaskNum != _Task.TaskNum)
+ {
+ task.TaskState = (int)TaskRelocationTypeEnum.Relocation;
+ task.Roadway = task.Roadway == "1" ? task.Roadway = "SC01" : task.Roadway = "SC02";
+ task.TaskNum = task.TaskNum;
+ task.Grade = 3;
+ task.TaskType= (int)TaskRelocationTypeEnum.Relocation;
+ BaseDal.AddData(task);
+ return task;
+ }
+ }
+ }
+ else
+ {
+ return null;
+ WriteLog.GetLog("PLC鏃ュ織").Write($"澶辫触淇℃伅锛歿content.Message}", "绉诲簱淇℃伅");
}
}
@@ -324,6 +426,20 @@
return BaseDal.QueryFirst(x => x.Roadway == deviceNo && x.TaskState == (int)TaskInStatusEnum.SC_InExecuting);
}
+ public Dt_Task IngStackerCraneTask2(string deviceNo)
+ {
+ //string deviceNot = deviceNo == "SC01" ? "1" : "2";
+ try
+ {
+ return BaseDal.QueryFirst(x => x.Roadway == deviceNo && x.TaskState == (int)TaskOutStatusEnum.SC_OutExecuting);
+ }
+ catch (Exception ex)
+ {
+
+ throw;
+ }
+ }
+
/// <summary>
/// 鏍规嵁璁惧缂栧彿銆佸綋鍓嶅湴鍧�鎸夌収浼樺厛绾т互鍙婂垱寤烘椂闂存帓搴忔煡璇换鍔℃睜鍏ュ簱绫诲瀷鐨勬柊澧炵殑浠诲姟
/// </summary>
@@ -371,7 +487,7 @@
/// <returns>杩斿洖浠诲姟瀹炰綋瀵硅薄闆嗗悎锛屽彲鑳戒负null</returns>
public List<Dt_Task> QueryStationIsOccupiedOutTasks(string deviceNo, string SourceAddress)
{
- return BaseDal.QueryData(x => x.Roadway == deviceNo && TaskOutboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskOutStatusEnum.OutNew && SourceAddress.Contains(x.SourceAddress), TaskOrderBy);
+ return BaseDal.QueryData(x => x.Roadway == deviceNo && SourceAddress.Contains(x.SourceAddress), TaskOrderBy);
}
/// <summary>
@@ -571,6 +687,12 @@
/// </summary>
/// <param name="taskNum">浠诲姟缂栧彿</param>
/// <returns>杩斿洖澶勭悊缁撴灉</returns>
+ public class GenerateInv2
+ {
+ public string PalletCode { get; set; }
+ public string SourceAddress { get; set; }
+ public string TargetAddress { get; set; }
+ }
public WebResponseContent StackCraneTaskCompleted(int taskNum)
{
WebResponseContent content = new WebResponseContent();
@@ -584,7 +706,7 @@
/*List<Dt_Router> routers = _routerService.QueryNextRoutes(task.NextAddress, task.TargetAddress);
if (!routers.Any()) return WebResponseContent.Instance.Error($"鏈壘鍒拌澶囪矾鐢变俊鎭�");*/
- content = HttpHelper.Get<WebResponseContent>($"{urlTaskCompleted}?TaskNum={task.TaskNum}");
+ content = HttpHelper.Get<WebResponseContent>($"{urlTaskCompleted}?TaskNum={task.TaskNum}&HowWorks=2");
task.TaskState = (int)TaskOutStatusEnum.OutFinish;
task.ModifyDate = DateTime.Now;
BaseDal.DeleteData(task);
@@ -596,7 +718,7 @@
}
else if (task.TaskType == (int)TaskInboundTypeEnum.Inbound && task.TaskState == (int)TaskInStatusEnum.SC_InExecuting)
{
- content = HttpHelper.Get<WebResponseContent>($"{urlTaskCompleted}?TaskNum={task.TaskNum}");
+ content = HttpHelper.Get<WebResponseContent>($"{urlTaskCompleted}?TaskNum={task.TaskNum}&HowWorks=2");
//todo
//int nextStatus = task.TaskState.GetNextNotCompletedStatus<TaskInStatusEnum>();
task.TaskState = (int)TaskInStatusEnum.InFinish;
@@ -609,7 +731,15 @@
}
else if (task.TaskType == (int)TaskRelocationTypeEnum.Relocation)
{
- content = HttpHelper.Get<WebResponseContent>($"{urlRelocationTaskCompleted}?PalletCode={task.PalletCode}&SourceAddress ={ task.SourceAddress}TargetAddress ={task.TargetAddress}");
+ /*GenerateInv2 generate = new GenerateInv2()
+ {
+ PalletCode = task.PalletCode,
+ SourceAddress = task.SourceAddress,
+ TargetAddress = task.TargetAddress
+
+ };
+ content = HttpHelper.Post<WebResponseContent>($"{urlTaskCompleted}", generate);*/
+ content = HttpHelper.Get<WebResponseContent>($"{urlTaskCompleted}?TaskNum={task.TaskNum}&HowWorks=2");
task.TaskState = (int)TaskOutStatusEnum.SC_OutFinish;
task.ModifyDate = DateTime.Now;
BaseDal.DeleteData(task);
@@ -723,5 +853,79 @@
}
return content;
}
+
+
+ /// <summary>
+ /// 鍒犻櫎鏁版嵁
+ /// </summary>
+ /// <param name="keys">涓婚敭鏁扮粍</param>
+ /// <returns></returns>
+ public virtual WebResponseContent DeleteData(object[] keys)
+ {
+ try
+ {
+ List<Dt_Task> tasks = BaseDal.QureyDataByIds(keys);
+ foreach (Dt_Task task in tasks)
+ {
+ _task_HtyService.AddTaskHty(task);
+ }
+
+
+ if (typeof(Dt_Task).GetNavigatePro() == null)
+ return BaseDal.DeleteDataByIds(keys) ? WebResponseContent.Instance.OK() : WebResponseContent.Instance.Error();
+ else
+ {
+ if (keys != null)
+ {
+ Type detailType = typeof(Dt_Task).GetDetailType();
+ string name = typeof(Dt_Task).GetMainIdByDetail();
+ List<object> dynamicDelKeys = new List<object>();
+
+ for (int i = 0; i < keys.Length; i++)
+ {
+ dynamicDelKeys.Add(keys[i]);
+ }
+ ((SqlSugarClient)BaseDal.Db).BeginTran();
+
+ if (dynamicDelKeys.Count > 0)
+ BaseDal.Db.Deleteable<object>().AS(detailType.Name).Where($"{name} in (@id)", new { id = dynamicDelKeys.ToArray() }).ExecuteCommandHasChange();
+
+ BaseDal.DeleteDataByIds(keys);
+
+ ((SqlSugarClient)BaseDal.Db).CommitTran();
+
+ return WebResponseContent.Instance.OK();
+ }
+ else
+ {
+ return WebResponseContent.Instance.Error("鍙傛暟閿欒");
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ ((SqlSugarClient)BaseDal.Db).RollbackTran();
+ return WebResponseContent.Instance.Error(ex.Message);
+ }
+ }
+
+ public WebResponseContent ReceiveWCSTask(int tasknum)
+ {
+ Dt_Task tasks = BaseDal.QueryFirst(x => x.TaskNum == tasknum);
+ try
+ {
+ _task_HtyService.AddTaskHty(tasks);
+ BaseDal.DeleteData(tasks);
+ WriteLog.Write_Log("WMS鎵嬪姩鍒犻櫎浠诲姟", "鍒犻櫎鎴愬姛", $"鐢宠鍒犻櫎鐨勬潯鐮侊細{tasks.TaskNum},鎵樼洏鏉$爜锛歿tasks.PalletCode}", new { 淇℃伅 = "鍒犻櫎鎴愬姛" });
+ return WebResponseContent.Instance.OK();
+
+ }
+ catch (Exception ex)
+ {
+ WriteLog.Write_Log("WMS鎵嬪姩鍒犻櫎浠诲姟","鍒犻櫎澶辫触", $"鐢宠鍒犻櫎鐨勬潯鐮侊細{tasks.TaskNum},鎵樼洏鏉$爜锛歿tasks.PalletCode}", new { 淇℃伅 = ex.Message });
+ return WebResponseContent.Instance.Error();
+ }
+ }
+
}
}
--
Gitblit v1.9.3