From a6a33f6916afbf1fc629baecb772939cda2ee981 Mon Sep 17 00:00:00 2001
From: wankeda <Administrator@DESKTOP-HAU3ST3>
Date: 星期四, 13 三月 2025 17:58:12 +0800
Subject: [PATCH] 代码提交

---
 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Outbound.cs |  176 +++++++++++++++++++++++++++++++++++-----------------------
 1 files changed, 107 insertions(+), 69 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Outbound.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Outbound.cs"
index 68231f0..77aa65d 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Outbound.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Outbound.cs"
@@ -18,9 +18,14 @@
 using System.Linq.Expressions;
 using WIDESEA_DTO.Inbound;
 using WIDESEA_DTO.Task;
-
+using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
+using System.Drawing.Printing;
+using WIDESEA_Core.DB;
+using System.Drawing;
+using WIDESEA_ITaskInfoService;
 namespace WIDESEA_TaskInfoService
 {
+
     public partial class TaskService
     {
 
@@ -544,7 +549,7 @@
                 int maxPage = Convert.ToInt32(Math.Ceiling(count / 10.0));
                 if (taskDTO.pageNo <= maxPage)
                 {
-                    var inboundOrder = BaseDal.Db.Queryable<Dt_Task>().Where(expressionOrder).Where(x => x.TaskType == TaskTypeEnum.Outbound.ObjToInt()).OrderByDescending(x => x.CreateDate).Select(x => new Dt_Task { TaskNum = x.TaskNum, TaskId = x.TaskId, CreateDate = x.CreateDate, Creater = x.Creater }).ToList();
+                    var inboundOrder = BaseDal.Db.Queryable<Dt_Task>().Where(expressionOrder).Where(x => x.TaskType == TaskTypeEnum.Outbound.ObjToInt()).OrderByDescending(x => x.CreateDate).Select(x => new Dt_Task { TaskNum = x.TaskNum, TaskId = x.TaskId, CreateDate = x.CreateDate, Creater = x.Creater, Materialtype = x.Materialtype }).ToList();
 
                     content = WebResponseContent.Instance.OK(data: inboundOrder);
                 }
@@ -560,101 +565,134 @@
 
             return content;
         }
-
+        /// <summary>
+        /// 纭鍑哄簱浠诲姟
+        /// </summary>
+        /// <param name="saveModel"></param>
+        /// <returns></returns>
         public WebResponseContent RequestInbound(SaveModel saveModel)
         {
 
             WebResponseContent content = new WebResponseContent();
             try
             {
-                int taskname = saveModel.MainData["taskname"].ObjToInt();
-                string address = saveModel.MainData["startPoint"].ToString();
-                string inboundBarcode = saveModel.MainData["barcode"].ToString();
-                Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskname);
+                string stationcode = saveModel.MainData["stationcode"].ToString();
+                string PalletCode = saveModel.MainData["PalletCode"].ToString();
+                Dt_Task task = BaseDal.QueryFirst(x => x.SourceAddress == stationcode && x.Materialtype == PalletCode);
                 if (task != null)
                 {
-                    task.SourceAddress = address;
-                    task.TaskStatus = OutTaskStatusEnum.OutNew.ObjToInt();
+                    task.TaskStatus = AGVTaskStatusEnum.AGV_New.ObjToInt();
                     BaseDal.UpdateData(task);
                     content = WebResponseContent.Instance.OK();
                 }
                 else
                 {
-                    content = WebResponseContent.Instance.Error("鏈壘鍒版浠诲姟");
+                    return content = WebResponseContent.Instance.Error("鏈壘鍒版浠诲姟鎴栫墿鏂欑被鍨嬩笉鍖归厤");
                 }
             }
             catch (Exception ex)
             {
-                content = WebResponseContent.Instance.Error($"娣诲姞浠诲姟璧风偣寮傚父,閿欒淇℃伅:{ex.Message}");
+                content = WebResponseContent.Instance.Error($"浠诲姟璧风偣寮傚父,閿欒淇℃伅:{ex.Message}");
             }
             return content;
         }
-
+        private static readonly object text = new object();
+        /// <summary>
+        /// 鍑哄簱浠诲姟
+        /// </summary>
+        /// <param name="saveModel"></param>
+        /// <returns></returns>
         public WebResponseContent OutboundTasks(SaveModel saveModel)
         {
-            WebResponseContent content = new WebResponseContent();
-            try
+            lock (text)
             {
-                string stationcode = saveModel.MainData["stationcode"].ToString();
-                string PalletCode = saveModel.MainData["PalletCode"].ToString();
-                List<Dt_Task> tasks = new List<Dt_Task>();
-                Dt_Task task = new Dt_Task()
+                WebResponseContent content = new WebResponseContent();
+                try
                 {
-                    CurrentAddress = "1",
-                    Grade = 1,
-                    NextAddress = "1",
-                    PalletCode = PalletCode,
-                    Roadway = "1",
-                    SourceAddress = "",
-                    TargetAddress = stationcode,
-                    TaskStatus = OutTaskStatusEnum.OutNew.ObjToInt(),
-                    TaskType = TaskTypeEnum.Outbound.ObjToInt(),
-                    Depth = 1,
-                    TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum))
-                };
-                tasks.Add(task);
-                Repository.AddData(tasks);
-                content = WebResponseContent.Instance.OK();
+                    string stationcode = saveModel.MainData["stationcode"].ToString();
+                    string PalletCode = saveModel.MainData["PalletCode"].ToString();
+                    if (stationcode == "" || PalletCode == "")//寮傚父杩斿洖銆傘�傘�傘�傘�傘��
+                    {
+                        return content = WebResponseContent.Instance.Error($"娣诲姞浠诲姟寮傚父,閿欒淇℃伅:鎵爜淇℃伅涓嶈兘涓虹┖");
+                    }
+                    Dt_CachePoint endCachePoint = _basicService.CachePointService.Repository.QueryFirst(x => x.PointCode.Contains("鍘熸潗鏂欏簱") && x.PointStatus == LocationStatusEnum.Free.ObjToInt());//&& x.PointStatus == LocationStatusEnum.Free.ObjToInt()
+                    if (endCachePoint == null)
+                    {
+                        return content = WebResponseContent.Instance.Error($"娣诲姞浠诲姟寮傚父,閿欒淇℃伅:{"鏈壘鍒板師鏉愭枡搴撳彲鐢ㄧ紦瀛樹綅"}");
+                    }
+                    Dt_CachePoint point = _basicService.CachePointService.Repository.QueryFirst(x => x.PointCode == stationcode && x.Materialtype == PalletCode);
+                    if (point == null)
+                    {
+                        return content = WebResponseContent.Instance.Error($"娣诲姞浠诲姟寮傚父,閿欒淇℃伅:{"鎵爜鏁版嵁寮傚父锛屾湭鎵惧埌姝ょ紦瀛樻灦鎴栫墿鏂欑被鍨嬩笉鍖归厤"}");
+                    }
+                    Dt_CachePoint points = _basicService.CachePointService.Repository.QueryFirst(x => x.PointCode == stationcode && x.PointStatus == LocationStatusEnum.Free.ObjToInt());
+                    if (points == null)
+                    {
+                        return content = WebResponseContent.Instance.Error($"娣诲姞浠诲姟寮傚父,閿欒淇℃伅:{"鎵爜鏁版嵁寮傚父锛屾缂撳瓨鐐瑰凡琚攣瀹�"}");
+                    }
+                    Dt_Task taskcode = BaseDal.QueryFirst(x => x.SourceAddress == stationcode || x.TargetAddress == stationcode);
+                    if (taskcode != null)
+                    {
+                        return content = WebResponseContent.Instance.Error($"娣诲姞浠诲姟寮傚父,閿欒淇℃伅:璇ョ珯鐐瑰凡瀛樺湪浠诲姟");
+                    }
+                    var pointname = _basicService.CachePointService.Repository.QueryData(x => x.PointName == point.PointName).ToList();
+                    foreach (var item in pointname)
+                    {
+                        var a = point.Remark.ObjToInt();
+                        var b = item.Remark.ObjToInt();
+                        if (b < a)
+                        {
+                            Dt_CachePoint c = _basicService.CachePointService.Repository.QueryFirst(x => x.PointCode == item.PointCode && x.PointStatus == 0);
+                            if (c != null)
+                            {
+                                return content = WebResponseContent.Instance.Error($"娣诲姞浠诲姟寮傚父,閿欒淇℃伅:{"璇锋寜浠庨噷鍒板缂撳瓨鐐归『搴忚姹備换鍔�"}");
+                            }
+                        }
+                    }
+                    List<Dt_Task> tasks = new List<Dt_Task>();
+                    Dt_Task task = new Dt_Task()
+                    {
+                        CurrentAddress = "1",
+                        Grade = 1,
+                        NextAddress = "1",
+                        PalletCode = "",
+                        Roadway = "1",
+                        SourceAddress = endCachePoint.PointCode,
+                        TargetAddress = stationcode,
+                        TaskStatus = AGVTaskStatusEnum.AGV_Query.ObjToInt(),
+                        TaskType = TaskTypeEnum.Outbound.ObjToInt(),
+                        Materialtype = PalletCode,
+                        Depth = 1,
+                        TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum))
+                    };
+                    tasks.Add(task);
+                    Repository.AddData(tasks);
+                    HCJLock(task);
+                    //Main();
+                    content = WebResponseContent.Instance.OK();
+
+                }
+                catch (Exception ex)
+                {
+                    content = WebResponseContent.Instance.Error($"娣诲姞浠诲姟寮傚父,閿欒淇℃伅:{ex.Message}");
+                }
+                return content;
             }
-            catch (Exception ex)
-            {
-                content = WebResponseContent.Instance.Error($"娣诲姞浠诲姟寮傚父,閿欒淇℃伅:{ex.Message}");
-            }
-            return content;
+
+        }
+        public void Main()
+        {
+            PrintDocument printDocument = new PrintDocument();
+            printDocument.PrintPage += new PrintPageEventHandler(PrintPage);
+            printDocument.Print();
         }
 
-
-        public WebResponseContent InboundTask(SaveModel saveModel)
+        private void PrintPage(object sender, PrintPageEventArgs e)
         {
-            WebResponseContent content = new WebResponseContent();
-            try
-            {
-                string stationcode = saveModel.MainData["stationcode"].ToString();
-                string PalletCode = saveModel.MainData["PalletCode"].ToString();
-                List<Dt_Task> tasks = new List<Dt_Task>();
-                Dt_Task task = new Dt_Task()
-                {
-                    CurrentAddress = "",
-                    Grade = 1,
-                    NextAddress = "",
-                    PalletCode = PalletCode,
-                    Roadway = "",
-                    SourceAddress = stationcode,
-                    TargetAddress = "",
-                    TaskStatus = OutTaskStatusEnum.OutNew.ObjToInt(),
-                    TaskType = TaskTypeEnum.Inbound.ObjToInt(),
-                    Depth = 1,
-                    TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum))
-                };
-                tasks.Add(task);
-                Repository.AddData(tasks);
-                content = WebResponseContent.Instance.OK();
-            }
-            catch (Exception ex)
-            {
-                content = WebResponseContent.Instance.Error($"娣诲姞浠诲姟寮傚父,閿欒淇℃伅:{ex.Message}");
-            }
-            return content;
+            var agvtask = BaseDal.QueryData(x => x.TaskStatus == AGVTaskStatusEnum.AGV_Query.ObjToInt()).OrderByDescending(x => x.CreateDate).First();
+            string textToPrint = "鏀捐揣璐т綅浣嶏細" + agvtask.SourceAddress + Environment.NewLine + "鐗╂枡绫诲瀷锛�" + agvtask.Materialtype + Environment.NewLine + "浠诲姟鍒涘缓鏃堕棿锛�" + agvtask.CreateDate;
+            Font printFont = new Font("Arial", 12);
+            e.Graphics.DrawString(textToPrint, printFont, Brushes.Black, 10, 10);
         }
     }
 }

--
Gitblit v1.9.3