From c3d7843cd9508afbeca86df38e2d7322be227a00 Mon Sep 17 00:00:00 2001
From: zhaowc <526854230@qq.com>
Date: 星期四, 20 六月 2024 16:51:25 +0800
Subject: [PATCH] 小车叫桶接口,任务下发接口编写,小车任务model添加

---
 Wms/WMS.BLL/BllTransServer/RcsServer.cs     |  277 +++++++++++++++++++++++++++++++++++++++
 Wms/Model/InterFaceModel/RCSModel.cs        |  118 ++++++++++++++++
 Wms/WMS.BLL/BllTransServer/QualityServer.cs |   12 +
 3 files changed, 403 insertions(+), 4 deletions(-)

diff --git a/Wms/Model/InterFaceModel/RCSModel.cs b/Wms/Model/InterFaceModel/RCSModel.cs
new file mode 100644
index 0000000..811de33
--- /dev/null
+++ b/Wms/Model/InterFaceModel/RCSModel.cs
@@ -0,0 +1,118 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Model.InterFaceModel
+{
+    public class RCSModel
+    {
+        /// <summary>
+        /// 鐢熸垚RCS浠诲姟鍗� 浠诲姟涓嬪彂鎺ュ彛淇℃伅
+        /// </summary>
+        public class genAgvSchedulingTaskReq
+        {
+            /// <summary>
+            /// 璇锋眰缂栧彿锛屾瘡涓姹傞兘瑕佷竴涓敮涓�缂栧彿锛屽悓涓�涓姹傞噸澶嶆彁浜わ紝浣跨敤鍚屼竴缂栧彿
+            /// 蹇呭~
+            /// </summary>
+            public string reqCode { get; set; }
+            /// <summary>
+            /// 璇锋眰鏃堕棿 yyyy-MM-dd HH:mm:ss CMS绯荤粺鐢熸垚
+            /// </summary>
+            public string reqTime { get; set; }
+            /// <summary>
+            /// 瀹㈡埛绔紪鍙�
+            /// </summary>    
+            public string clientCode { get; set; }
+            /// <summary>
+            /// 浠ょ墝鍙�
+            /// </summary>
+            public string tokenCode { get; set; }
+            /// <summary>
+            /// 浠诲姟绫诲瀷锛屾牴鎹厤缃殑浠诲姟妯℃澘鍙峰~鍐�
+            /// 蹇呭~
+            /// </summary>
+            public string taskTyp { get; set; }
+            public string scenetTyp { get; set; }
+            /// <summary>
+            /// 瀹瑰櫒绫诲瀷
+            /// </summary>
+            public string ctnrTyp { get; set; }
+            /// <summary>
+            /// 瀹瑰櫒缂栧彿
+            /// </summary>
+            public string ctnrCode { get; set; }
+            /// <summary>
+            /// 宸ヤ綔浣�
+            /// </summary>
+            public string wbCode { get; set; }
+            /// <summary>
+            /// 浣嶇疆璺緞 閫旂粡鐐�--璧风偣鍜岀粓鐐�
+            /// 蹇呴』
+            /// </summary>
+            public List<PositionCodePath> positionCodePath { get; set; }
+            /// <summary>
+            /// 璐ф灦缂栧彿
+            /// </summary>
+            public string podCode { get; set; }
+            /// <summary>
+            /// 璐ф灦鏂瑰悜
+            /// </summary>
+            public string podDir { get; set; }
+            /// <summary>
+            /// 璐ф灦绫诲瀷
+            /// </summary>
+            public string podTyp { get; set; }
+            /// <summary>
+            /// 鐗╂枡鎵规鎴栬揣鏋朵笂鐨勭墿鏂欏敮涓�缂栫爜
+            /// </summary>
+            public string materialLot { get; set; }
+            /// <summary>
+            /// 浼樺厛绾�
+            /// </summary>
+            public string priorit { get; set; }
+            /// <summary>
+            /// 浠诲姟鍗曞彿
+            /// </summary>
+            public string taskCode { get; set; }
+            /// <summary>
+            /// AGV缂栧彿
+            /// </summary>
+            public string agvCode { get; set; }
+            /// <summary>
+            /// 鑷畾涔夊瓧娈�
+            /// </summary>
+            public List<data> data { get; set; }
+        }
+        public class PositionCodePath
+        {
+            public string positionCode { get; set; }
+            public string type { get; set; }
+        }
+
+        public class data
+        {
+            public string materialLot { get; set; }
+            public string materialCode { get; set; }
+        }
+
+        /// <summary>
+        /// RCS浠诲姟杩斿洖
+        /// </summary>
+        public class genAgvSchedulingTaskRep
+        {
+            /// <summary>
+            /// 杩斿洖鐮� 
+            /// 0锛氭垚鍔�
+            /// 1~N锛氬け璐�
+            /// </summary>
+            public string code { get; set; }
+
+            public string message { get; set; }
+
+            public string reqCode { get; set; }
+
+            public string data { get; set; }
+        }
+    }
+}
diff --git a/Wms/WMS.BLL/BllTransServer/QualityServer.cs b/Wms/WMS.BLL/BllTransServer/QualityServer.cs
index f2d8da4..96bd70a 100644
--- a/Wms/WMS.BLL/BllTransServer/QualityServer.cs
+++ b/Wms/WMS.BLL/BllTransServer/QualityServer.cs
@@ -1,10 +1,18 @@
-锘縰sing System;
+锘縰sing SqlSugar;
+using System;
 using System.Collections.Generic;
+using System.Linq;
 using System.Text;
+using WMS.Entity.BllAsnEntity;
+using WMS.Entity.Context;
+using WMS.Entity.DataEntity;
+using WMS.Entity.SysEntity;
 
 namespace WMS.BLL.BllTransServer
 {
-    class QualityServer
+    public class QualityServer
     {
+       
+
     }
 }
diff --git a/Wms/WMS.BLL/BllTransServer/RcsServer.cs b/Wms/WMS.BLL/BllTransServer/RcsServer.cs
index f77469a..9e5242b 100644
--- a/Wms/WMS.BLL/BllTransServer/RcsServer.cs
+++ b/Wms/WMS.BLL/BllTransServer/RcsServer.cs
@@ -1,10 +1,283 @@
-锘縰sing System;
+锘縰sing Microsoft.IdentityModel.Protocols;
+using Newtonsoft.Json;
+using SqlSugar;
+using System;
 using System.Collections.Generic;
+using System.Linq;
 using System.Text;
+using Utility.Tools;
+using WMS.Entity.BllAsnEntity;
+using WMS.Entity.Context;
+using WMS.Entity.DataEntity;
+using WMS.Entity.SysEntity;
+using static Model.InterFaceModel.RCSModel;
 
 namespace WMS.BLL.BllTransServer
 {
-    class RcsServer
+    public class RcsServer
     {
+        private static readonly SqlSugarScope Db = DataContext.Db;
+        /// <summary>
+        /// RCS鍙《(鍑�妗跺拰鑴忔《)
+        /// </summary>
+        /// <param name="warehouseno">搴撳尯</param>
+        /// <param name="type">鍙枡绫诲瀷</param>
+        /// <returns></returns>
+        public void GetPalletNo(string warehouseno, string type, out string palletno, out string locatno)
+        {
+            var sql = "select LocatNo,palletno from SysStorageLocat where status = '1'";
+            SysStorageLocat pallet = new SysStorageLocat();
+            try
+            {
+                switch (type)
+                {
+                    case "0"://鍙噣妗�
+                        sql += $"and WareHouseNo = 'A01' and WareHouseNo = '{warehouseno}' order by updatetime desc";
+                        pallet = Db.Ado.SqlQuery<SysStorageLocat>(sql).FirstOrDefault();
+                        if (pallet == null)
+                        {
+                            throw new Exception("鏆傛棤鍑�妗跺彲鍒嗛厤");
+                        }
+                        break;
+                    case "3"://鍙剰妗�
+                        sql += $"and WareHouseNo = 'A04' and WareHouseNo = '{warehouseno}' order by updatetime desc";
+                        pallet = Db.Ado.SqlQuery<SysStorageLocat>(sql).FirstOrDefault();
+                        if (pallet == null)
+                        {
+                            throw new Exception("鏆傛棤鑴忔《鍙垎閰�");
+                        }
+                        break;
+                }
+                palletno = pallet.PalletNo;
+                locatno = pallet.LocatNo;
+            }
+            catch (Exception)
+            {
+
+                throw;
+            }
+        }
+
+        /// <summary>
+        /// RCS鍙《(娣锋枡妗跺拰涓嬫枡妗�)
+        /// </summary>
+        /// <param name="warehouseno">搴撳尯</param>
+        /// <param name="type">鍙枡绫诲瀷</param>
+        /// <param name="lotno">鍙枡鎵规</param>
+        /// <returns></returns>
+        public void GetPalletNo(string warehouseno, string type, string lotno, out string palletno, out string locatno)
+        {
+            var sql = "";
+            var pallet = "";
+            DataStockDetail SoMes = new DataStockDetail();
+            try
+            {
+                switch (type)
+                {
+                    case "1"://鍙枡妗讹紙娣锋枡锛�
+                        BllArrivalNoticeDetail ArriveMes = new BllArrivalNoticeDetail();
+                        //鍒ゆ柇璇ユ壒娆℃槸鍚︽湁瀵瑰簲鍏ュ簱鍗�
+                        sql += $"select * from BllArrivalNoticeDetail where LotNo =  '{lotno}' order by CreateTime desc";
+                        ArriveMes = Db.Ado.SqlQuery<BllArrivalNoticeDetail>(sql).FirstOrDefault();
+                        if (ArriveMes == null)
+                        {
+                            throw new Exception("璇ユ壒娆℃病鏈夊搴旂殑鍏ュ簱鍗�");
+                        }
+                        //鏌ユ壘搴撳瓨涓槸鍚︽湁鍙敤鐨勬鎵规鐨勬贩鏂欐《
+                        sql = $"select LocatNo,palletno from DataStockDetail " +
+                            $"left join SysStorageLocat b on a.LocatNo = b.LocatNo " +
+                            $"where a.LotNo =  '{lotno}'and a.WareHouseNo = '{warehouseno}' and b.status = '1' " +
+                            $"order by CompleteTime desc";
+                        SoMes = Db.Ado.SqlQuery<DataStockDetail>(sql).FirstOrDefault();
+                        if (pallet == null)
+                        {
+                            throw new Exception("鏆傛棤娣锋枡妗跺彲鍒嗛厤");
+                        }
+                        break;
+                    case "2"://鍙枡妗讹紙涓嬫枡锛�
+                        //鏌ユ壘搴撳瓨涓槸鍚︽湁姝ゆ壒娆$殑涓嬫枡妗�
+                        sql = $"select LocatNo,palletno from DataStockDetail" +
+                            $"left join SysStorageLocat b on a.LocatNo = b.LocatNo " +
+                            $"where a.LotNo =  '{lotno}'and a.WareHouseNo = '{warehouseno}' and b.status = '1'" +
+                            $" order by CompleteTime desc";
+                        SoMes = Db.Ado.SqlQuery<DataStockDetail>(sql).FirstOrDefault();
+                        if (pallet == null)
+                        {
+                            throw new Exception("鏆傛棤涓嬫枡妗跺彲鍒嗛厤");
+                        }
+
+                        break;
+                }
+                palletno = SoMes.PalletNo;
+                locatno = SoMes.LocatNo;
+
+            }
+            catch (Exception)
+            {
+
+                throw;
+            }
+        }
+
+        /// <summary>
+        /// 鐢宠鍌ㄤ綅
+        /// </summary>
+        /// <param name="PalletNo"></param>
+        /// <returns></returns>
+        public void ApplyLocatNo(string palletno, string type, out string locatno)
+        {
+            var sql = $"select LocatNo from SysStorageLocat where status = '0'";
+            SysStorageLocat loction = new SysStorageLocat();
+            try
+            {
+                switch (type)
+                {
+                    case "0"://鍑�妗剁敵璇峰偍浣�
+                        sql += $"and WareHouseNo = 'A01'";
+                        loction = Db.Ado.SqlQuery<SysStorageLocat>(sql).OrderByDescending(a => a.CreateTime).FirstOrDefault();
+                        if (loction == null)
+                        {
+                            throw new Exception("搴撳唴鏆傛棤绌轰綑鍑�妗跺偍浣�");
+                        }
+                        break;
+                    case "1"://娣锋枡妗剁敵璇峰偍浣�
+                        sql += $"and WareHouseNo = 'A02'";
+                        loction = Db.Ado.SqlQuery<SysStorageLocat>(sql).OrderByDescending(a => a.CreateTime).FirstOrDefault();
+                        if (loction == null)
+                        {
+                            throw new Exception("搴撳唴鏆傛棤绌轰綑娣锋枡妗跺偍浣�");
+                        }
+                        break;
+                    case "2"://鍗婃垚鍝佹《鐢宠鍌ㄤ綅
+                        sql += $"and WareHouseNo = 'A03'";
+                        loction = Db.Ado.SqlQuery<SysStorageLocat>(sql).OrderByDescending(a => a.CreateTime).FirstOrDefault();
+                        if (loction == null)
+                        {
+                            throw new Exception("搴撳唴鏆傛棤绌轰綑鍗婃垚鍝佹《鍌ㄤ綅");
+                        }
+                        break;
+                    case "3"://鑴忔《鐢宠鍌ㄤ綅
+                        sql += $"and WareHouseNo = 'A04'";
+                        loction = Db.Ado.SqlQuery<SysStorageLocat>(sql).OrderByDescending(a => a.CreateTime).FirstOrDefault();
+                        if (loction == null)
+                        {
+                            throw new Exception("搴撳唴鏆傛棤绌轰綑鑴忔《鍌ㄤ綅");
+                        }
+                        break;
+                }
+                locatno = loction.PalletNo;
+            }
+            catch (Exception)
+            {
+
+                throw;
+            }
+        }
+
+
+        /// <summary>
+        /// RCS鐢熸垚浠诲姟
+        /// </summary>
+        /// <param name="taskCode"></param>
+        /// <param name="taskType"></param>
+        /// <param name="startPos">璧峰浣嶇疆</param>
+        /// <param name="endPos">鐩殑浣嶇疆</param>
+        /// <param name="agvCode"></param>
+        /// <param name="url">RCS鍦板潃</param>
+        /// <returns></returns>
+        public string genAgvSchedulingTask(string taskCode, string taskType, string startPos, string endPos, string agvCode,string url, ref genAgvSchedulingTaskRep cbrep)
+        {
+            try
+            {
+                PositionCodePath pcd1 = new PositionCodePath()
+                {
+                    positionCode = startPos.ToString(),
+                    type = "00",
+                };
+                PositionCodePath pcd2 = new PositionCodePath()
+                {
+                    positionCode = endPos.ToString(),
+                    type = "00",
+                };
+                List<PositionCodePath> lst = new List<PositionCodePath>();
+                lst.Add(pcd1);
+                lst.Add(pcd2);
+                genAgvSchedulingTaskReq cbreq = new genAgvSchedulingTaskReq()
+                {
+                    reqCode = taskCode.ToString(),
+                    taskCode = taskCode.ToString(),
+                    taskTyp = taskType,
+                    positionCodePath = lst,
+                    podCode = "",
+                    agvCode = agvCode,
+                    ctnrTyp = "1",
+                    //ctnrCode="2",
+
+                };
+                if (startPos == "50")
+                {
+                    cbreq.ctnrTyp = "4";
+                }
+                cbrep = genAgvSchedulingTask(cbreq,url);
+                
+
+                return cbrep.code;
+            }
+            catch (Exception ex) { throw ex; }
+        }
+
+        /// <summary>
+        /// 鐢熸垚浠诲姟鍗�
+        /// </summary>
+        /// <param name="req"></param>
+        /// <returns></returns>
+        private genAgvSchedulingTaskRep genAgvSchedulingTask(genAgvSchedulingTaskReq req,string url)
+        {
+            genAgvSchedulingTaskRep rep = new genAgvSchedulingTaskRep()
+            {
+                code = "-1",
+                message = "鐢熶骇浠诲姟鍗曞け璐�"
+            };
+            if (req == null)
+            {
+                return rep;
+            }
+            try
+            {
+                string jsonReq = JsonConvert.SerializeObject(req);
+
+                string jsonRep = HttpHelper.DoPost(url + "/genAgvSchedulingTask", jsonReq,"灏忚溅浠诲姟涓嬪彂","RCS");
+                jsonRep = jsonRep.TrimStart('\"');
+                jsonRep = jsonRep.TrimEnd('\"');
+                jsonRep = jsonRep.Replace("\\", "");
+                rep = JsonConvert.DeserializeObject<genAgvSchedulingTaskRep>(jsonRep);
+                return rep;
+            }
+            catch (Exception ex)
+            {
+                throw ex;
+            }
+        }
+
+
+        /// <summary>
+        /// 鐢熸垚浠诲姟鍗曞埌LogTask
+        /// </summary>
+        /// <param name="req"></param>
+        /// <returns></returns>
+        public void CreateLotTask(string startport,string endport,string type,string tasktype)
+        {
+            try
+            {
+
+
+            }
+            catch (Exception)
+            {
+
+                throw;
+            }
+
+        }
     }
 }

--
Gitblit v1.8.0