From 8f997184b1698d7e28625ddd0df6ae09d496823e Mon Sep 17 00:00:00 2001 From: Administrator <Administrator@DESKTOP-5BIMHQ3> Date: 星期日, 23 六月 2024 16:58:59 +0800 Subject: [PATCH] 编写RCS任务完成反馈接口 --- Wms/WMS.BLL/BllTransServer/RcsServer.cs | 278 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 276 insertions(+), 2 deletions(-) diff --git a/Wms/WMS.BLL/BllTransServer/RcsServer.cs b/Wms/WMS.BLL/BllTransServer/RcsServer.cs index f77469a..930861c 100644 --- a/Wms/WMS.BLL/BllTransServer/RcsServer.cs +++ b/Wms/WMS.BLL/BllTransServer/RcsServer.cs @@ -1,10 +1,284 @@ -锘縰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 WMS.IBLL.IBllTransServer; +using static Model.InterFaceModel.RCSModel; namespace WMS.BLL.BllTransServer { - class RcsServer + public class RcsServer:IRcsServer { + 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(AgvTask agv,string url, ref genAgvSchedulingTaskRep cbrep) + { + try + { + PositionCodePath pcd1 = new PositionCodePath() + { + positionCode = agv.startPos.ToString(), + type = "00", + }; + PositionCodePath pcd2 = new PositionCodePath() + { + positionCode = agv.endPos.ToString(), + type = "00", + }; + List<PositionCodePath> lst = new List<PositionCodePath>(); + lst.Add(pcd1); + lst.Add(pcd2); + genAgvSchedulingTaskReq cbreq = new genAgvSchedulingTaskReq() + { + reqCode = agv.taskCode.ToString(), + taskCode = agv.taskCode.ToString(), + taskTyp = agv.taskType, + positionCodePath = lst, + podCode = "", + agvCode = agv.agvCode, + ctnrTyp = "1", + //ctnrCode="2", + + }; + if (agv.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