From 3e19792c0061879ebe17ea04264c4c1f86bb3504 Mon Sep 17 00:00:00 2001
From: wxw <Administrator@DESKTOP-5BIMHQ3>
Date: 星期四, 24 四月 2025 16:51:18 +0800
Subject: [PATCH] 编写料斗转运功能
---
Wms/WMS.BLL/BllTransServer/HopperTransportServer.cs | 651 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
Wms/WMS.IBLL/IBllTransServer/IHopperTransportServer.cs | 2
HTML/views/StatisticalReport/BoxInfor.html | 3
Wms/Wms/Controllers/DownApiController.cs | 2
HTML/views/WareHouseSetting/Locate.html | 12
5 files changed, 636 insertions(+), 34 deletions(-)
diff --git a/HTML/views/StatisticalReport/BoxInfor.html b/HTML/views/StatisticalReport/BoxInfor.html
index 08e4611..fd4280b 100644
--- a/HTML/views/StatisticalReport/BoxInfor.html
+++ b/HTML/views/StatisticalReport/BoxInfor.html
@@ -337,8 +337,9 @@
{field: 'LocatNo', title: '鍌ㄤ綅鍦板潃', align: 'center'},
{field: 'PalletNo', title: '妗跺彿', align: 'center'},
{field: 'PalletStatus', title: '妗剁姸鎬�', align: 'center', templet: '#InspectPalletStatus'},
+ {field: 'Standard',title: '妗惰鏍�',align: 'center'},
{field: 'SkuNo', title: '鐗╂枡缂栫爜', align: 'center'},
- {field: 'SkuName', title: '鐗╂枡鍚嶇О', align: 'center'},
+ {field: 'SkuName', title: '鐗╂枡鍚嶇О', align: 'center'},
//{field: 'OwnerNo',title: '璐т富缂栫爜',align: 'center'},
//{field: 'OwnerName',title: '璐т富鍚嶇О',align: 'center'},
//{field: 'SupplierNo',title: '渚涘簲鍟嗙紪鐮�',align: 'center'},
diff --git a/HTML/views/WareHouseSetting/Locate.html b/HTML/views/WareHouseSetting/Locate.html
index 7a95e2e..4783145 100644
--- a/HTML/views/WareHouseSetting/Locate.html
+++ b/HTML/views/WareHouseSetting/Locate.html
@@ -387,12 +387,12 @@
align: 'center',
width: 160,
},
- // {
- // field: 'Layer',
- // title: '灞�',
- // align: 'center',
- // width: 70,
- // },
+ {
+ field: 'Layer',
+ title: '灞�',
+ align: 'center',
+ width: 70,
+ },
// {
// field: 'Depth',
// title: '娣卞害',
diff --git a/Wms/WMS.BLL/BllTransServer/HopperTransportServer.cs b/Wms/WMS.BLL/BllTransServer/HopperTransportServer.cs
index f1f55f3..ed0d101 100644
--- a/Wms/WMS.BLL/BllTransServer/HopperTransportServer.cs
+++ b/Wms/WMS.BLL/BllTransServer/HopperTransportServer.cs
@@ -1,16 +1,21 @@
锘縰sing Model.InterFaceModel;
+using Model.ModelDto.LogDto;
using Model.ModelDto.SysDto;
+using Newtonsoft.Json;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
+using System.Threading.Tasks;
+using Utility.Tools;
using WMS.DAL;
using WMS.Entity.Context;
using WMS.Entity.DataEntity;
using WMS.Entity.LogEntity;
using WMS.Entity.SysEntity;
using WMS.IBLL.IBllTransServer;
+using static Model.InterFaceModel.RCSModel;
namespace WMS.BLL.BllTransServer
{
@@ -21,11 +26,16 @@
private readonly object RcsLock = new object();
+ /// <summary>
+ /// 鏍规嵁鐢ㄦ埛瑙掕壊鏉冮檺鑾峰彇褰撳墠瑙掕壊鐨勫尯鍩�
+ /// </summary>
+ /// <param name="userId"></param>
+ /// <returns></returns>
+ /// <exception cref="Exception"></exception>
public List<SysStorageArea> GetAreaListByUser(int userId)
{
try
- {
- //鏍规嵁鐢ㄦ埛瑙掕壊鏉冮檺鑾峰彇褰撳墠瑙掕壊鐨勫尯鍩�
+ {
var user = Db.Queryable<SysUserInfor>().First(m=>m.IsDel == "0" && m.Id == userId);
if (user == null)
{
@@ -56,7 +66,12 @@
throw new Exception(e.Message);
}
}
-
+ /// <summary>
+ /// 鏍规嵁鍖哄煙鑾峰彇鍌ㄤ綅鍦板潃
+ /// </summary>
+ /// <param name="area"></param>
+ /// <returns></returns>
+ /// <exception cref="Exception"></exception>
public List<SysStorageLocat> GetLocatByArea(string area)
{
try
@@ -70,7 +85,12 @@
throw new Exception(e.Message);
}
}
-
+ /// <summary>
+ /// 鏍规嵁鍖哄煙鎴栬�呮《鐘舵��
+ /// </summary>
+ /// <param name="area"></param>
+ /// <returns></returns>
+ /// <exception cref="Exception"></exception>
public List<DicModel> GetPlnStatusByArea(string area)
{
try
@@ -129,7 +149,12 @@
throw new Exception(e.Message);
}
}
-
+ /// <summary>
+ /// 鏍规嵁妗剁姸鎬佽幏鍙栫墿鏂欑紪鐮�
+ /// </summary>
+ /// <param name="palletStatus"></param>
+ /// <returns></returns>
+ /// <exception cref="Exception"></exception>
public List<string> GetSkuByStatus(string palletStatus)
{
try
@@ -143,7 +168,12 @@
throw new Exception(e.Message);
}
}
-
+ /// <summary>
+ /// 鏍规嵁鐗╂枡缂栫爜鑾峰彇鎵规鍙�
+ /// </summary>
+ /// <param name="skuNo"></param>
+ /// <returns></returns>
+ /// <exception cref="Exception"></exception>
public List<string> GetLotNoBySku(string skuNo)
{
try
@@ -178,12 +208,12 @@
/// <param name="areaNo">鍖哄煙</param>
/// <param name="endLocate">璧峰浣嶇疆</param>
/// <param name="plnStatus">妗剁被鍨� 0鍑�妗� 2婊℃《 3鑴忔《 </param>
- /// <param name="standard">瑙勬牸</param>
+ /// <param name="standard">妗惰鏍�</param>
/// <param name="skuNo">鐗╂枡鍙�</param>
/// <param name="lotNo">鎵规</param>
/// <param name="userId">鎿嶄綔浜�</param>
/// <exception cref="Exception"></exception>
- public void jiaoLiaoHopper(string areaNo,string endLocate,string plnStatus,string standard,string skuNo,string lotNo,int userId)
+ public void jiaoLiaoHopper(string areaNo,string endLocate,string plnStatus,string standard,string skuNo,string lotNo,string url,int userId)
{
try
{
@@ -213,7 +243,7 @@
{
throw new Exception("鐩爣鍌ㄤ綅鏍囪瘑涓嶆槸姝e父鍙敤鐨�");
}
- if (endLocateInfo.Status!="0")
+ if (endLocateInfo.Status != "0")
{
throw new Exception("鐩爣鍌ㄤ綅鐘舵�佷笉鏄┖鍌ㄤ綅");
}
@@ -223,7 +253,7 @@
//鐩爣妤煎眰
var layer = endLocateInfo.Layer;
var houseStr = layer == 3 ? "3妤间腑闂寸珯" : layer == 4 ? "4妤间腑闂寸珯" : "";
-
+ //閫氳繃浠撳簱鍚嶇О鏌ヨ浠撳簱淇℃伅
var house = Db.Queryable<SysWareHouse>().First(m => m.IsDel == "0" && m.WareHouseName == houseStr);
if (house == null)
{
@@ -232,10 +262,12 @@
//鏌ユ壘鐘舵�佹槸鏈垎閰嶄笖鍌ㄤ綅涓嶄负绌虹殑搴撳瓨淇℃伅
var stockDetail = Db.Queryable<DataStockDetail>().Where(m => m.Status == "0" && m.WareHouseNo == house.WareHouseNo && !string.IsNullOrWhiteSpace(m.LocatNo)).ToList();
+ //鍑�妗�
if (plnStatus == "0")
{
- stockDetail = stockDetail.Where(m => m.PalletStatus == "0" && m.Standard == standard).OrderBy(m=>m.LocatNo).ToList();
+ stockDetail = stockDetail.Where(m => m.PalletStatus == "0" && m.Standard == standard).OrderBy(m => m.LocatNo).ToList();
}
+ //婊℃《
else if (plnStatus == "2")
{
stockDetail = stockDetail.Where(m => m.PalletStatus == "2" && m.SkuNo == skuNo && m.LotNo == lotNo).OrderBy(m => m.LocatNo).ToList();
@@ -244,24 +276,52 @@
{
throw new Exception("妗剁被鍨嬮敊璇�");
}
- if (stockDetail == null)
+ if (stockDetail == null || stockDetail.Count <= 0)
{
throw new Exception("娌℃湁鏌ヨ鍒板彨鏂欑殑搴撳瓨淇℃伅");
}
- //鏌ユ壘鍚堥�傜殑 妗跺彿 鍌ㄤ綅
- foreach (var item in stockDetail)
- {
-
- }
-
-
+ //寮�鍚簨鍔�
+ Db.BeginTran();
+ //鐢熶骇浠诲姟鍙�
var taskNo = new Common().GetMaxNo("TK");
+
+ bool resultYi = false;
+ #region#鏌ユ壘鍚堥�傜殑 妗跺彿 鍌ㄤ綅
+ //鐩爣浠撳簱鎵�鏈夊偍浣�
+ var locatList = Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.WareHouseNo == house.WareHouseNo).ToList();
+ //鐩爣浠撳簱鎵�鏈変笉闇�瑕佺Щ搴撶殑鍌ㄤ綅
+ var locatListWai = locatList.Where(w => string.IsNullOrEmpty(w.AisleOne)).Select(s => s.LocatNo);
+
+ //鍏堟壘涓嶉渶瑕佺Щ搴撶殑妗�
+ var palletModel = stockDetail.Where(w => locatListWai.Contains(w.LocatNo)).OrderBy(o => o.UpdateTime).FirstOrDefault();
+ if (palletModel == null)
+ {
+ //鎵鹃渶瑕佺Щ搴撶殑妗�
+ palletModel= stockDetail.Where(w => !locatListWai.Contains(w.LocatNo)).OrderBy(o => o.UpdateTime).FirstOrDefault();
+ if (palletModel == null)
+ {
+ throw new Exception("鏈壘鍒板搴旀《淇℃伅");
+ }
+ resultYi = YikuTask(palletModel.PalletNo, taskNo, url);
+ }
+ #endregion
+ //璧峰鍌ㄤ綅鍦板潃淇℃伅
+ var startLoction = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.Status == "1" && w.LocatNo == palletModel.LocatNo);
+ if (startLoction == null)
+ {
+ throw new Exception($"璧峰鐩爣鍌ㄤ綅淇℃伅涓嶅瓨鍦紝妗跺彿锛歿palletModel.LocatNo}");
+ }
+ //浜х敓绉诲簱浠诲姟
+ if (resultYi)
+ {
+ taskNo = taskNo + "-1";
+ }
//娣诲姞浠诲姟
- var task = new LogTask
+ var logTaskEntry = new LogTask
{
TaskNo = taskNo,
Sender = "WMS",
- Receiver = "WCS",
+ Receiver = "RCS",
IsSuccess = 0, //鏄惁涓嬪彂鎴愬姛 0澶辫触 1鎴愬姛
StartLocat = "",//璧峰浣嶇疆
@@ -270,18 +330,61 @@
IsSend = 1,//鏄惁鍙啀娆′笅鍙�
IsCancel = 1,//鏄惁鍙彇娑�
IsFinish = 1,//鏄惁鍙畬鎴�
- Type = "2",//浠诲姟绫诲瀷 0 鍏ュ簱浠诲姟 1 鍑哄簱浠诲姟 2 绉诲簱浠诲姟
+ Type = "1",//浠诲姟绫诲瀷 0 鍏ュ簱浠诲姟 1 鍑哄簱浠诲姟 2 绉诲簱浠诲姟
Status = "0",//浠诲姟鐘舵��0锛氱瓑寰呮墽琛�1姝e湪鎵ц2鎵ц瀹屾垚
OrderType = "3",//0 鍏ュ簱鍗� 1 鍑哄簱鍗� 2 鐩樼偣鍗� 3 绉诲簱鍗�
CreateTime = DateTime.Now
};
- Db.Insertable(task).ExecuteCommand();
- //璋冪敤AGV鎺ュ彛涓嬪彂浠诲姟
+ Db.Insertable(logTaskEntry).ExecuteCommand();
+
+ //娌℃湁浜х敓绉诲簱浠诲姟灏辩洿鎺ョ粰灏忚溅涓嬪彂鍑哄簱浠诲姟锛岃嫢浜х敓绉诲簱浠诲姟绛夊皬杞︽妸绉诲簱鐨勬《鎶捣鏃跺啀涓嬪彂鍑哄簱浠诲姟
+ if (!resultYi)
+ {
+ //缁勭粐涓嬪彂灏忚溅浠诲姟淇℃伅
+ var task = new TaskDetial
+ {
+ Taskno = taskNo,//浠诲姟鍙�
+ Startport = palletModel.LocatNo,//璧峰浣嶇疆
+ Endport = endLocate,//鐩爣浣嶇疆
+ Pallno = palletModel.PalletNo,//妗跺彿
+ Crtype = "1",//鍙《
+ };
+ string agvMsg = string.Empty;
+ //缁欎笅杞︿笅鍙戜换鍔�
+ logTaskEntry.SendDate = DateTime.Now;//鍙戦�佹椂闂�
+ var agvResult = CreateTaskForAgv(task, url, out agvMsg);
+ if (agvResult)//鎴愬姛
+ {
+ //璇锋眰鎴愬姛淇敼浠诲姟琛ㄧ浉搴斿瓧娈电姸鎬�
+ logTaskEntry.IsSuccess = 1;
+ logTaskEntry.IsSend = 0;
+ //logTaskEntry.IsCancel = 0;
+ logTaskEntry.BackDate = DateTime.Now;
+ logTaskEntry.Status = "1";//姝e湪鎵ц
+ Db.Insertable(logTaskEntry).ExecuteCommand();
+
+ startLoction.Status = "3";//鍑哄簱涓�
+ Db.Updateable(startLoction).ExecuteCommand();
+
+ endLocateInfo.Status = "2";//鍏ュ簱涓�
+ Db.Updateable(endLocateInfo).ExecuteCommand();
+ }
+ else//澶辫触
+ {
+ logTaskEntry.IsSuccess = 0;
+ logTaskEntry.Information = agvMsg;
+ Db.Insertable(logTaskEntry).ExecuteCommand();
+ }
+ }
+ //鎻愪氦浜嬪姟
+ Db.CommitTran();
}
catch (Exception e)
{
+ //鍥炴粴浜嬪姟
+ Db.RollbackTran();
throw new Exception(e.Message);
}
}
@@ -428,8 +531,506 @@
throw new Exception(e.Message);
}
}
-
+ private bool YikuTask(string palletNo, string taskNo, string url)
+ {
+ try
+ {
+ //鍒嗛厤妗剁殑搴撳瓨淇℃伅
+ var palletInfo = Db.Queryable<DataStockDetail>().First(w => w.IsDel == "0" && w.PalletNo == palletNo);
+ if (palletInfo == null)
+ {
+ throw new Exception("鏈煡璇㈠埌鍒嗛厤妗剁殑搴撳瓨淇℃伅");
+ }
+ //鍒ゆ柇鍒嗛厤鐨勬《鏈夋病鏈夋鍦ㄦ墽琛岀殑浠诲姟锛堢Щ搴撲腑锛�
+ var taskIng = Db.Queryable<LogTask>().First(w => w.IsDel == "0" && (w.Status == "0" || w.Status == "1") && w.PalletNo == palletNo);
+ if (taskIng != null)
+ {
+ throw new Exception("鍒嗛厤鐨勬《鏈夋鍦ㄦ墽琛岀殑浠诲姟锛岃绋嶅悗鍐嶈瘯");
+ }
+ //鍒嗛厤妗剁殑鍌ㄤ綅淇℃伅
+ var locatInfo = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.LocatNo == palletInfo.LocatNo);
+ if (locatInfo == null)
+ {
+ throw new Exception("鏈煡璇㈠埌鍒嗛厤妗舵墍鍦ㄧ殑鍌ㄤ綅淇℃伅");
+ }
+ string WareHouseNo = locatInfo.WareHouseNo;//鎵�灞炰粨搴撶紪鍙�
+ //鍒ゆ柇璇ュ偍浣嶆槸鍚︽槸鍐呬晶鍌ㄤ綅
+ if (!string.IsNullOrEmpty(locatInfo.AisleOne))
+ {
+ //鍒ゆ柇澶栦晶鍌ㄤ綅鏄惁鏈夋《
+ var palletInfoYi = Db.Queryable<DataStockDetail>().First(w => w.IsDel == "0" && w.LocatNo == locatInfo.AisleOne);
+ if (palletInfoYi != null)
+ {
+ //鍒ゆ柇瑕佺Щ搴撶殑妗舵槸鍚﹁鍒嗛厤
+ if (palletInfoYi.Status != "0")
+ {
+ throw new Exception("瑕佺Щ搴撶殑妗跺凡琚垎閰嶏紝璇风◢鍚庡啀璇�");
+ }
+ //鍒ゆ柇瑕佺Щ搴撶殑妗舵槸鍚︽湁姝e湪鎵ц鐨勪换鍔�
+ var taskInfo = Db.Queryable<LogTask>().First(w => w.IsDel == "0" && (w.Status == "0" || w.Status == "1") && w.PalletNo == palletInfoYi.PalletNo);
+ if (taskInfo != null)
+ {
+ throw new Exception("瑕佺Щ搴撶殑妗舵湁姝e湪鎵ц鐨勪换鍔★紝璇风◢鍚庡啀璇�");
+ }
+ #region#缁欒绉诲簱鐨勬《鍏堢Щ鍒颁腑杞偍浣�
+ //鎵惧埌涓浆鍌ㄤ綅鎵�鍦ㄥ尯鍩�
+ var transfeArea = Db.Queryable<SysStorageArea>().First(w => w.IsDel == "0" && w.WareHouseNo == WareHouseNo && w.AreaName.Contains("杞繍鍖�"));
+ if (transfeArea == null)
+ {
+ throw new Exception("鏈壘鍒拌浆杩愬尯鍩�");
+ }
+ //鎵惧埌涓浆鍌ㄤ綅
+ var transferLocat = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.WareHouseNo == WareHouseNo && w.AreaNo == transfeArea.AreaNo);
+ if (transferLocat == null)
+ {
+ throw new Exception("娌℃湁绌洪棽涓浆鍌ㄤ綅锛岃绋嶅悗鍐嶈瘯");
+ }
+ #endregion
+
+ //浠诲姟淇℃伅
+ var logTaskEntry = new LogTask
+ {
+ TaskNo = taskNo,
+ Sender = "WMS",
+ Receiver = "RCS",
+ //IsSuccess = 1, //鏄惁涓嬪彂鎴愬姛 0澶辫触 1鎴愬姛
+ SendDate = DateTime.Now, //鍙戦�佹椂闂�
+ //BackDate = DateTime.Now, //杩斿洖鏃堕棿
+ StartLocat = palletInfoYi.LocatNo,//璧峰浣嶇疆
+ EndLocat = transferLocat.LocatNo,//鐩爣浣嶇疆
+ PalletNo = palletInfoYi.PalletNo,//鎵樼洏鐮�
+ IsSend = 1,//鏄惁鍙啀娆′笅鍙�
+ IsCancel = 1,//鏄惁鍙彇娑�
+ IsFinish = 1,//鏄惁鍙畬鎴�
+ Type = "2",//浠诲姟绫诲瀷 0 鍏ュ簱浠诲姟 1 鍑哄簱浠诲姟 2 绉诲簱浠诲姟
+ OrderType = "3",//鍗曟嵁绫诲瀷 0 鍏ュ簱 1 鍑哄簱 3绉诲簱
+ Status = "0",//浠诲姟鐘舵��0锛氱瓑寰呮墽琛�1姝e湪鎵ц2鎵ц瀹屾垚
+ NoticeDetailNo = 0,
+ Msg = $"灏嗘《{palletInfoYi.PalletNo}浠巤palletInfoYi.LocatNo}绉诲埌{transferLocat.LocatNo}", //鍏抽敭淇℃伅
+ LotNo = ""//鎵规鍙�
+ };
+
+ //缁勭粐涓嬪彂灏忚溅浠诲姟淇℃伅
+ var task = new TaskDetial
+ {
+ Taskno = taskNo,//浠诲姟鍙�
+ Startport = palletInfoYi.LocatNo,//璧峰浣嶇疆
+ Endport = transferLocat.LocatNo,//鐩爣浣嶇疆
+ Pallno = palletInfoYi.PalletNo,//妗跺彿
+ Crtype = "1",//鍙《
+ WareHouseNo = palletInfoYi.WareHouseNo//杞﹂棿缂栫爜
+ };
+ string agvMsg = string.Empty;
+ //缁欎笅杞︿笅鍙戜换鍔�
+ logTaskEntry.SendDate = DateTime.Now;//鍙戦�佹椂闂�
+ var agvResult = CreateTaskForAgv(task, url, out agvMsg, "70");
+ if (agvResult)//鎴愬姛
+ {
+ //璇锋眰鎴愬姛淇敼浠诲姟琛ㄧ浉搴斿瓧娈电姸鎬�
+ logTaskEntry.IsSuccess = 1;
+ logTaskEntry.IsSend = 0;
+ //logTaskEntry.IsCancel = 0;
+ logTaskEntry.BackDate = DateTime.Now;
+ logTaskEntry.Status = "1";//姝e湪鎵ц
+ Db.Insertable(logTaskEntry).ExecuteCommand();
+
+ //淇敼绉诲嚭鍌ㄤ綅鐘舵��
+ locatInfo.Status = "5";//绉诲嚭涓�
+ Db.Updateable(locatInfo).ExecuteCommand();
+
+ //淇敼绉诲叆鍌ㄤ綅鐘舵��
+ transferLocat.Status = "4";//绉诲叆涓�
+ Db.Updateable(transferLocat).ExecuteCommand();
+ }
+ else//澶辫触
+ {
+ logTaskEntry.IsSuccess = 0;
+ logTaskEntry.Information = agvMsg;
+ Db.Insertable(logTaskEntry).ExecuteCommand();
+
+ throw new Exception($"缁欏皬杞︿笅鍙戠Щ搴撲换鍔″け璐ワ紝妗跺彿锛歿palletInfoYi.PalletNo}");
+ }
+ }
+ }
+ return true;
+ }
+ catch (Exception e)
+ {
+ throw new Exception(e.Message);
+ }
+ }
+ /// <summary>
+ /// 灏忚溅璧板嚭鍌ㄤ綅鍥炰紶浜嬩欢
+ /// </summary>
+ /// <param name="taskNo"></param>
+ /// <param name="url"></param>
+ /// <exception cref="Exception"></exception>
+ public void OutBinAgv(string taskNo,string url)
+ {
+ try
+ {
+ //寮�鍚簨鍔�
+ Db.BeginTran();
+
+ //鏌ユ壘浠诲姟淇℃伅
+ var logTaskInfo = Db.Queryable<LogTask>().First(w => w.IsDel == "0" && w.Status == "1" && w.TaskNo == taskNo);
+ if (logTaskInfo == null)
+ {
+ throw new Exception("鏈煡璇㈠埌璇ヤ换鍔�");
+ }
+ //璧峰鍌ㄤ綅鍦板潃
+ var startLocatInfo = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.LocatNo == logTaskInfo.StartLocat);
+ if (startLocatInfo == null)
+ {
+ throw new Exception("鏈煡璇㈠埌璧峰鍌ㄤ綅鍦板潃淇℃伅");
+ }
+ startLocatInfo.Status = "0";//绌哄偍浣�
+ //淇敼璧峰鍌ㄤ綅鐘舵�佷负绌哄偍浣�
+ Db.Updateable(startLocatInfo).ExecuteCommand();
+
+ //鍒ゆ柇鏈夋棤瀛愪换鍔�
+ string taskNoZ = logTaskInfo.TaskNo + "-1";
+ var logTaskInfoZ = Db.Queryable<LogTask>().First(w => w.IsDel == "0" && w.Status == "0" && w.TaskNo == taskNoZ);
+ if (logTaskInfoZ != null)
+ {
+ //瀛愪换鍔¤捣濮嬪偍浣嶄俊鎭�
+ var startLocatInfoZ= Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.LocatNo == logTaskInfoZ.StartLocat);
+ if (startLocatInfoZ == null)
+ {
+ throw new Exception("鏈煡璇㈠埌瀛愪换鍔¤捣濮嬪偍浣嶅湴鍧�淇℃伅");
+ }
+ //瀛愪换鍔$洰鏍囧偍浣嶄俊鎭�
+ var endLocatInfoZ = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.LocatNo == logTaskInfoZ.EndLocat);
+ if (endLocatInfoZ == null)
+ {
+ throw new Exception("鏈煡璇㈠埌瀛愪换鍔$洰鏍囧偍浣嶅湴鍧�淇℃伅");
+ }
+
+ //缁勭粐涓嬪彂灏忚溅浠诲姟淇℃伅
+ var task = new TaskDetial
+ {
+ Taskno = taskNo,//浠诲姟鍙�
+ Startport = logTaskInfoZ.StartLocat,//璧峰浣嶇疆
+ Endport = logTaskInfoZ.EndLocat,//鐩爣浣嶇疆
+ Pallno = logTaskInfoZ.PalletNo,//妗跺彿
+ Crtype = "1",//鍙《
+ };
+ string agvMsg = string.Empty;
+ //缁欎笅杞︿笅鍙戜换鍔�
+ logTaskInfoZ.SendDate = DateTime.Now;//鍙戦�佹椂闂�
+ var agvResult = CreateTaskForAgv(task, url, out agvMsg, "70");
+ if (agvResult)//鎴愬姛
+ {
+ //璇锋眰鎴愬姛淇敼浠诲姟琛ㄧ浉搴斿瓧娈电姸鎬�
+ logTaskInfoZ.IsSuccess = 1;
+ logTaskInfoZ.IsSend = 0;
+ //logTaskEntry.IsCancel = 0;
+ logTaskInfoZ.BackDate = DateTime.Now;
+ logTaskInfoZ.Status = "1";//姝e湪鎵ц
+ Db.Insertable(logTaskInfoZ).ExecuteCommand();
+
+ //淇敼绉诲嚭鍌ㄤ綅鐘舵��
+ startLocatInfoZ.Status = "5";//绉诲嚭涓�
+ Db.Updateable(startLocatInfoZ).ExecuteCommand();
+
+ //淇敼绉诲叆鍌ㄤ綅鐘舵��
+ endLocatInfoZ.Status = "4";//绉诲叆涓�
+ Db.Updateable(endLocatInfoZ).ExecuteCommand();
+ }
+ else//澶辫触
+ {
+ logTaskInfoZ.IsSuccess = 0;
+ logTaskInfoZ.Information = agvMsg;
+ Db.Insertable(logTaskInfoZ).ExecuteCommand();
+
+ throw new Exception($"缁欏皬杞︿笅鍙戠Щ搴撲换鍔″け璐ワ紝妗跺彿锛歿logTaskInfoZ.PalletNo}");
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ //鍥炴粴浜嬪姟
+ Db.RollbackTran();
+ throw new Exception(e.Message);
+ }
+ }
+
+ /// <summary>
+ /// 瀹氭椂灏嗕腑杞偍浣嶄笂鐨勬《绉昏蛋
+ /// </summary>
+ /// <param name="url"></param>
+ /// <exception cref="Exception"></exception>
+ public void TransferBackTimer(string url)
+ {
+ try
+ {
+ //寮�鍚簨鍔�
+ Db.BeginTran();
+
+ //涓棿绔欎粨搴�
+ var transferWareHouseList = new List<string>() { "M01", "M16" };
+ foreach (var itemHouseNo in transferWareHouseList)
+ {
+ //鎵惧埌涓浆鍌ㄤ綅鎵�鍦ㄥ尯鍩�
+ var transfeArea = Db.Queryable<SysStorageArea>().First(w => w.IsDel == "0" && w.WareHouseNo == itemHouseNo && w.AreaName.Contains("杞繍鍖�"));
+ if (transfeArea == null)
+ {
+ throw new Exception("鏈壘鍒拌浆杩愬尯鍩�");
+ }
+ //鎵惧埌涓浆鍌ㄤ綅
+ var transferLocatList = Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.WareHouseNo == itemHouseNo && w.AreaNo == transfeArea.AreaNo).ToList();
+ foreach (var locatModel in transferLocatList)
+ {
+ //鍌ㄤ綅淇℃伅
+ if (locatModel.Status != "1")
+ {
+ continue;
+ }
+ //鍌ㄤ綅涓婂簱瀛樹俊鎭�
+ var detailInfo = Db.Queryable<DataStockDetail>().First(w => w.IsDel == "0" && w.LocatNo == locatModel.LocatNo);
+ if (detailInfo == null)
+ {
+ continue;
+ }
+ //鍒嗛厤鍌ㄤ綅
+ var endLocatInfo = new SysStorageLocat();//鐩爣鍌ㄤ綅
+ string areaNo = string.Empty;
+ switch (detailInfo.PalletStatus)
+ {
+ case "0"://鍑�妗�
+ //鏌ュ埌鍒板噣妗跺尯鍩熺紪鍙�
+ areaNo = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.WareHouseNo == itemHouseNo && w.Type == "0").Select(s => s.AreaNo).First();
+ //鍒嗛厤鍌ㄤ綅
+ endLocatInfo = Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Flag == "0"
+ && w.WareHouseNo == detailInfo.WareHouseNo && w.AreaNo == areaNo)
+ .OrderBy(o => o.Row).OrderByDescending(o => o.Column).First();
+ break;
+ case "2"://婊℃《
+ //鏌ュ埌鍒版弧妗跺尯鍩熺紪鍙�
+ areaNo = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.WareHouseNo == itemHouseNo && w.Type == "1").Select(s => s.AreaNo).First();
+ //鍒嗛厤鍌ㄤ綅
+ //鍏堟煡鍒板悓鐗╂枡鐨勭粍
+ string sql = $@"select Row from SysStorageLocat where WareHouseNo='{itemHouseNo}' and AreaNo='{areaNo}' and LocatNo in(
+ select LocatNo from DataStockDetail where SkuNo='{detailInfo.SkuNo}' and SkuName='{detailInfo.SkuName}' and Standard='{detailInfo.Standard}' and WareHouseNo='{itemHouseNo}' and AreaNo='{areaNo}'
+ ) group by Row";
+
+ List<int> RowList = Db.Ado.SqlQuery<int>(sql).ToList();
+ foreach (var rowItem in RowList)
+ {
+ endLocatInfo = Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Flag == "0"
+ && w.WareHouseNo == detailInfo.WareHouseNo && w.AreaNo == areaNo && w.Row == rowItem)
+ .OrderByDescending(o => o.Column).First();
+
+ if (endLocatInfo != null)
+ {
+ break;
+ }
+ }
+ //娌℃湁鎵惧埌鐩稿悓鐗╂枡鍚岀粍鐨勭┖鍌ㄤ綅
+ if (endLocatInfo == null)
+ {
+ endLocatInfo = Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Flag == "0"
+ && w.WareHouseNo == detailInfo.WareHouseNo && w.AreaNo == areaNo)
+ .OrderBy(o => o.Row).OrderByDescending(o => o.Column).First();
+ }
+
+ break;
+ case "3"://鑴忔《
+ //鏌ュ埌鍒拌剰妗跺尯鍩熺紪鍙�
+ areaNo = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.WareHouseNo == itemHouseNo && w.Type == "2").Select(s => s.AreaNo).First();
+ //鍒嗛厤鍌ㄤ綅
+ endLocatInfo = Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Flag == "0"
+ && w.WareHouseNo == detailInfo.WareHouseNo && w.AreaNo == areaNo)
+ .OrderBy(o => o.Row).OrderByDescending(o => o.Column).First();
+
+
+ break;
+ }
+ //娌℃湁鍙敤绌哄偍浣�
+ if (endLocatInfo == null)
+ {
+ continue;
+ }
+ var taskNo = new Common().GetMaxNo("TK");
+ //浠诲姟淇℃伅
+ var logTaskEntry = new LogTask
+ {
+ TaskNo = taskNo,
+ Sender = "WMS",
+ Receiver = "RCS",
+ //IsSuccess = 1, //鏄惁涓嬪彂鎴愬姛 0澶辫触 1鎴愬姛
+ SendDate = DateTime.Now, //鍙戦�佹椂闂�
+ //BackDate = DateTime.Now, //杩斿洖鏃堕棿
+ StartLocat = detailInfo.LocatNo,//璧峰浣嶇疆
+ EndLocat = endLocatInfo.LocatNo,//鐩爣浣嶇疆
+ PalletNo = detailInfo.PalletNo,//鎵樼洏鐮�
+ IsSend = 1,//鏄惁鍙啀娆′笅鍙�
+ IsCancel = 1,//鏄惁鍙彇娑�
+ IsFinish = 1,//鏄惁鍙畬鎴�
+ Type = "2",//浠诲姟绫诲瀷 0 鍏ュ簱浠诲姟 1 鍑哄簱浠诲姟 2 绉诲簱浠诲姟
+ OrderType = "3",//鍗曟嵁绫诲瀷 0 鍏ュ簱 1 鍑哄簱 3绉诲簱
+ Status = "0",//浠诲姟鐘舵��0锛氱瓑寰呮墽琛�1姝e湪鎵ц2鎵ц瀹屾垚
+ NoticeDetailNo = 0,
+ Msg = $"灏嗘《{detailInfo.PalletNo}浠巤detailInfo.LocatNo}绉诲埌{endLocatInfo.LocatNo}", //鍏抽敭淇℃伅
+ LotNo = ""//鎵规鍙�
+ };
+
+ //缁勭粐涓嬪彂灏忚溅浠诲姟淇℃伅
+ var task = new TaskDetial
+ {
+ Taskno = taskNo,//浠诲姟鍙�
+ Startport = detailInfo.LocatNo,//璧峰浣嶇疆
+ Endport = endLocatInfo.LocatNo,//鐩爣浣嶇疆
+ Pallno = detailInfo.PalletNo,//妗跺彿
+ Crtype = "2"//鍙《
+ };
+ string agvMsg = string.Empty;
+ //缁欎笅杞︿笅鍙戜换鍔�
+ logTaskEntry.SendDate = DateTime.Now;//鍙戦�佹椂闂�
+ var agvResult = CreateTaskForAgv(task, url, out agvMsg);
+ if (agvResult)//鎴愬姛
+ {
+ //璇锋眰鎴愬姛淇敼浠诲姟琛ㄧ浉搴斿瓧娈电姸鎬�
+ logTaskEntry.IsSuccess = 1;
+ logTaskEntry.IsSend = 0;
+ //logTaskEntry.IsCancel = 0;
+ logTaskEntry.BackDate = DateTime.Now;
+ logTaskEntry.Status = "1";//姝e湪鎵ц
+ Db.Insertable(logTaskEntry).ExecuteCommand();
+
+ //淇敼绉诲嚭鍌ㄤ綅鐘舵��
+ locatModel.Status = "5";//绉诲嚭涓�
+ Db.Updateable(locatModel).ExecuteCommand();
+
+ //淇敼绉诲叆鍌ㄤ綅鐘舵��
+ endLocatInfo.Status = "4";//绉诲叆涓�
+ Db.Updateable(endLocatInfo).ExecuteCommand();
+ }
+ else//澶辫触
+ {
+ logTaskEntry.IsSuccess = 0;
+ logTaskEntry.Information = agvMsg;
+ Db.Insertable(logTaskEntry).ExecuteCommand();
+
+ throw new Exception($"缁欏皬杞︿笅鍙戠Щ搴撲换鍔″け璐ワ紝妗跺彿锛歿detailInfo.PalletNo}");
+ }
+
+ }
+ }
+ //鎻愪氦浜嬪姟
+ Db.CommitTran();
+ }
+ catch (Exception e)
+ {
+ //鍥炴粴浜嬪姟
+ Db.RollbackTran();
+ throw new Exception(e.Message);
+ }
+ }
+ /// <summary>
+ /// 缁欏皬杞︿笅鍙戜换鍔�
+ /// </summary>
+ /// <param name="req"></param>
+ /// <returns></returns>
+ public bool CreateTaskForAgv(TaskDetial taskDetial, string url, out string agvMsg, string priority = null)
+ {
+ bool result = false;
+
+ #region 鍛煎彨灏忚溅浠g爜
+ List<PositionCodePath> pahtList = new List<PositionCodePath>();
+ //璧峰浣嶇疆
+ PositionCodePath path1 = new PositionCodePath();
+ path1.positionCode = taskDetial.Startport;
+ if (taskDetial.Crtype == "1")//鍙《锛堟《鍑哄簱锛�
+ {
+ path1.type = "05";
+ }
+ else if (taskDetial.Crtype == "0")//鐢宠鍌ㄤ綅锛堟《鍏ュ簱锛�
+ {
+ path1.type = "00";
+ }
+ else//鍚岃溅闂村钩灞傛惉杩�
+ {
+ path1.type = "05";
+ }
+ pahtList.Add(path1);
+
+ //鐩爣浣嶇疆
+ PositionCodePath path2 = new PositionCodePath();
+ path2.positionCode = taskDetial.Endport;
+ if (taskDetial.Crtype == "1")//鍙《锛堟《鍑哄簱锛�
+ {
+ path2.type = "00";
+ }
+ else if (taskDetial.Crtype == "1")//鐢宠鍌ㄤ綅锛堟《鍏ュ簱锛�
+ {
+ path2.type = "05";
+ }
+ else //鍚岃溅闂村钩灞傛惉杩�
+ {
+ path2.type = "05";
+ }
+ pahtList.Add(path2);
+
+ //涓嬭溅浠诲姟鍗�
+ AgvSchedulingTask agvTask = new AgvSchedulingTask();
+ agvTask.reqCode = taskDetial.Taskno;//璇锋眰缂栧彿
+ agvTask.taskCode = taskDetial.Taskno;//浠诲姟鍙�
+ agvTask.ctnrCode = taskDetial.Pallno;//妗跺彿
+ agvTask.reqTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");//璇锋眰鏃堕棿
+ agvTask.wbCode = "";
+ agvTask.positionCodePath = pahtList;//灏忚溅璺緞
+ agvTask.podCode = "";
+ agvTask.userCallCode = "";//taskDetial.Endport;//鐩爣浣嶇疆
+ agvTask.priority = priority;//浼樺厛绾�
+ //鍒ゆ柇瀹瑰櫒绫诲瀷
+ agvTask.ctnrTyp = "1";// 1锛氭《 2锛氭《锛堝皬锛� 3锛氭墭鐩�
+
+ //鍒ゆ柇浠诲姟绫诲瀷
+ if (taskDetial.Crtype == "1")//鍙《锛堟《鍑哄簱锛�
+ {
+ agvTask.taskTyp = "Z3";//浠诲姟绫诲瀷 绾胯竟鍒版墭鐩樻敹闆嗗櫒 Z1锛� 鎵樼洏鍨涚敵璇峰叆搴� Z2
+ }
+ else if (taskDetial.Crtype == "0")//鐢宠鍌ㄤ綅锛堟《鍏ュ簱锛�
+ {
+ agvTask.taskTyp = "Z4";//浠诲姟绫诲瀷 绾胯竟鍒版墭鐩樻敹闆嗗櫒 Z1锛� 鎵樼洏鍨涚敵璇峰叆搴� Z2
+ }
+ else//鍚岃溅闂村钩灞傛惉杩�
+ {
+ agvTask.taskTyp = "Z5";
+ }
+
+ // 姝e紡杩愯绋嬪簭鏀惧紑
+ var jsonData = JsonConvert.SerializeObject(agvTask);
+ string response = HttpHelper.DoPost(url, jsonData, "涓嬪彂缁橝GV杞繍鍛戒护", "AGV");
+ //瑙f瀽杩斿洖鏁版嵁
+ var agvModel = JsonConvert.DeserializeObject<OutCommanAgvDto>(response);
+ if (agvModel.Code == "0")
+ {
+ result = true;//缁欎笅杞︿笅鍙戜换鍔℃垚鍔�
+
+ agvMsg = "";
+ }
+ else
+ {
+ string logMsg = "";
+ if (taskDetial.Crtype == "1")//鍙《锛堟《鍑哄簱锛�
+ {
+ logMsg = "鐢宠鍙《";
+ }
+ else if (taskDetial.Crtype == "0")//鐢宠鍌ㄤ綅锛堟《鍏ュ簱锛�
+ {
+ logMsg = "鐢宠鍌ㄤ綅";
+ }
+ var logStr = $@".\log\AGV\AGV{logMsg}" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
+ LogFile.SaveLogToFile($"AGV{logMsg}寮傚父锛�( {agvModel.Message} ),", logStr);
+
+ agvMsg = agvModel.Message;
+ }
+ return result;
+ #endregion
+ }
}
diff --git a/Wms/WMS.IBLL/IBllTransServer/IHopperTransportServer.cs b/Wms/WMS.IBLL/IBllTransServer/IHopperTransportServer.cs
index 8d71f5b..baae27f 100644
--- a/Wms/WMS.IBLL/IBllTransServer/IHopperTransportServer.cs
+++ b/Wms/WMS.IBLL/IBllTransServer/IHopperTransportServer.cs
@@ -16,7 +16,7 @@
List<string> GetLotNoBySku(string skuNo);
List<string> GetSku();
- void jiaoLiaoHopper(string areaNo, string endLocate, string plnStatus, string standard, string skuNo, string lotNo, int userId);
+ void jiaoLiaoHopper(string areaNo, string endLocate, string plnStatus, string standard, string skuNo, string lotNo, string url, int userId);
void jiaoCheHopper(string areaNo, string StartLocate, string plnNo, string plnStatus, decimal weight, string skuNo, string lotNo, int userId);
diff --git a/Wms/Wms/Controllers/DownApiController.cs b/Wms/Wms/Controllers/DownApiController.cs
index c027bdf..5f20b40 100644
--- a/Wms/Wms/Controllers/DownApiController.cs
+++ b/Wms/Wms/Controllers/DownApiController.cs
@@ -1271,7 +1271,7 @@
{
return Ok(new { code = 1, msg = "鏈幏鍙栧埌褰撳墠鎿嶄綔浜轰俊鎭�" });
}
- _hopper.jiaoLiaoHopper(model.AreaNo,model.LocateNo,model.PlnStatus,model.Standard,model.SkuNo,model.LotNo, int.Parse(userId));
+ _hopper.jiaoLiaoHopper(model.AreaNo,model.LocateNo,model.PlnStatus,model.Standard,model.SkuNo,model.LotNo,"", int.Parse(userId));
return Ok(new { data = model, code = 0, msg = "" });
}
--
Gitblit v1.8.0