From dfd6f91e782f31b9d33030f12de6c72872e8ea03 Mon Sep 17 00:00:00 2001
From: Administrator <Administrator@DESKTOP-5BIMHQ3>
Date: 星期日, 30 六月 2024 16:59:20 +0800
Subject: [PATCH] 修改问题
---
Wms/WMS.BLL/BllTransServer/RcsServer.cs | 195 +++++++++++++++++++++++++++++++++++++-----------
1 files changed, 148 insertions(+), 47 deletions(-)
diff --git a/Wms/WMS.BLL/BllTransServer/RcsServer.cs b/Wms/WMS.BLL/BllTransServer/RcsServer.cs
index 67dac3a..672a451 100644
--- a/Wms/WMS.BLL/BllTransServer/RcsServer.cs
+++ b/Wms/WMS.BLL/BllTransServer/RcsServer.cs
@@ -8,6 +8,7 @@
using Utility.Tools;
using WMS.DAL;
using WMS.Entity.BllAsnEntity;
+using WMS.Entity.BllSoEntity;
using WMS.Entity.Context;
using WMS.Entity.DataEntity;
using WMS.Entity.LogEntity;
@@ -34,7 +35,7 @@
{
var house = "W01";//鍙《浣嶇疆锛屽悗缁牴鎹綅缃叧鑱旀垨瀹氫箟锛屾潵鍒ゆ柇鍙《浣嶇疆鎵�灞炶溅闂�
var url = "";//鍥炰紶MES鐨勬帴鍙e湴鍧�
- var noticeno = "";
+ var noticeno = "0";//鍑哄叆搴撳崟鎹槑缁咺D
var sql = "select PalletNo,LocatNo from DataStockDetail where Status = '0'";
switch (pallnetmsg.Type)
{
@@ -57,7 +58,7 @@
if (obj.Result != "0")//鍙敤锛岀敓鎴愬皬杞︽媺鍑�妗朵换鍔�
{
//鏌ユ壘鏄惁鏈夌┖浣欒剰妗朵綅
- sql = $"select LocatNo from SysStorageLocat where AreaNo like '%04' and WareHouseNo = wareno and Status = 0";
+ sql = $"select LocatNo from SysStorageLocat where AreaNo like '%04' and WareHouseNo = '{house}' and Status = 0";
locat = Db.Ado.SqlQuery<SysStorageLocat>(sql).FirstOrDefault();
if (locat == null)
{
@@ -73,14 +74,26 @@
{
Startport = item.LocatNo,
Endport = locat.LocatNo,
- Pallno = pallnetmsg.Palletno,
- Type = "4",
+ Pallno = item.PalletNo,
+ Type = "3",
Crtype = "0",
Noticedetailno = int.Parse(noticeno),
};
CreateLotTask(ztask);
- return;
+ continue;
}
+ //涓嬪彂灏忚溅浠诲姟
+ var task2 = new TaskDetial
+ {
+ Startport = item.LocatNo,
+ Endport = pallnetmsg.Location,
+ Pallno = item.PalletNo,
+ Type = pallnetmsg.Type,
+ Crtype = "1",
+ Noticedetailno = int.Parse(noticeno),
+ };
+ CreateLotTask(task2);
+ return;
}
else
{
@@ -94,7 +107,7 @@
{
throw new Exception("鎵规鍙蜂负绌猴紒");
}
- BllArrivalNoticeDetail ArriveMes = new BllArrivalNoticeDetail();
+ /*BllArrivalNoticeDetail ArriveMes = new BllArrivalNoticeDetail();
//鍒ゆ柇璇ユ壒娆℃槸鍚︽湁瀵瑰簲鍏ュ簱鍗�
sql = $"select * from BllArrivalNoticeDetail where LotNo = '{pallnetmsg.LotNo}' order by CreateTime desc";
ArriveMes = Db.Ado.SqlQuery<BllArrivalNoticeDetail>(sql).FirstOrDefault();
@@ -102,9 +115,10 @@
{
throw new Exception("璇ユ壒娆℃病鏈夊搴旂殑鍏ュ簱鍗�");
}
+ noticeno = ArriveMes.Id.ToString();*/
//鏌ユ壘搴撳瓨涓槸鍚︽湁鍙敤鐨勬鎵规鐨勬贩鏂欐《
- sql += $"where a.LotNo = '{pallnetmsg.LotNo}'and AreaNo like '%02' and a.WareHouseNo = '{house}' and b.status = '0' " +
- $"order by CompleteTime desc";
+ sql= $"select PalletNo,LocatNo from DataStockDetail where LotNo = '{pallnetmsg.LotNo}'and AreaNo like '%02' " +
+ $"and WareHouseNo = '{house}' and status = '0' order by CompleteTime desc";
pallet = Db.Ado.SqlQuery<DataStockDetail>(sql).FirstOrDefault();
if (pallet == null)
{
@@ -113,14 +127,23 @@
break;
case "2"://鍙枡妗讹紙涓嬫枡锛�
+ BllExportNoticeDetail bllSo = new BllExportNoticeDetail();
//鍒ゆ柇鏄惁鏈夋壒娆″彿
if (string.IsNullOrWhiteSpace(pallnetmsg.LotNo))
{
throw new Exception("鎵规鍙蜂负绌猴紒");
}
+ //鏌ユ壘鏄惁鏈夋鎵规鍑哄簱鍗�
+ sql = $"select * from BllExportNoticeDetail where LotNo = '{pallnetmsg.LotNo}' order by CreateTime desc";
+ bllSo = Db.Ado.SqlQuery<BllExportNoticeDetail>(sql).FirstOrDefault();
+ if (bllSo == null)
+ {
+ throw new Exception("璇ユ壒娆℃病鏈夊搴旂殑鍑哄簱鍗�");
+ }
+ noticeno = bllSo.Id.ToString();
//鏌ユ壘搴撳瓨涓槸鍚︽湁姝ゆ壒娆$殑涓嬫枡妗�
- sql += $"where a.LotNo = '{pallnetmsg.LotNo}'and AreaNo like '%03' and a.WareHouseNo = '{house}' and b.status = '0' " +
- $"order by CompleteTime desc";
+ sql = $"select PalletNo,LocatNo from DataStockDetail where LotNo = '{pallnetmsg.LotNo}'and AreaNo like '%03' " +
+ $"and WareHouseNo = '{house}' and status = '0' order by CompleteTime desc";
pallet = Db.Ado.SqlQuery<DataStockDetail>(sql).FirstOrDefault();
if (pallet == null)
{
@@ -141,14 +164,16 @@
//涓嬪彂灏忚溅浠诲姟
var task = new TaskDetial
{
- Startport = pallnetmsg.Location,
- Endport = pallet.LocatNo,
- Pallno = pallnetmsg.Palletno,
+ Startport = pallet.LocatNo,
+ Endport = pallnetmsg.Location,
+ Pallno = pallet.PalletNo,
Type = pallnetmsg.Type,
Crtype = "1",
Noticedetailno = int.Parse(noticeno),
+ LotNo = pallnetmsg.LotNo,
};
CreateLotTask(task);
+ return;
}
catch (Exception ex)
{
@@ -165,15 +190,17 @@
public void ApplyLocatNo(Pallnetmsg pallnetmsg)
{
var sql = $"select LocatNo from SysStorageLocat where status = '0'";
+ var sql2 = "";
var house = "W01";//鈥︹�﹀彨妗朵綅缃紝鍚庣画鏍规嵁浣嶇疆鍏宠仈鎴栧畾涔夛紝鏉ュ垽鏂彨妗朵綅缃墍灞炶溅闂�
- var noticeno = "";
+ var noticeno = "0";//鍑哄叆搴撳崟鎹槑缁咺D
SysStorageLocat loction = new SysStorageLocat();
+ BllArrivalNoticeDetail ArriveMes = new BllArrivalNoticeDetail();
try
{
switch (pallnetmsg.Type)
{
case "0"://鍑�妗剁敵璇峰偍浣�
- sql += $"and AreaNo like '%01' and WareHouseNo = {house}";
+ sql += $"and AreaNo like '%01' and WareHouseNo = '{house}'";
loction = Db.Ado.SqlQuery<SysStorageLocat>(sql).OrderByDescending(a => a.CreateTime).FirstOrDefault();
if (loction == null)
{
@@ -186,7 +213,15 @@
{
throw new Exception("鎵规鍙蜂负绌猴紒");
}
- sql += $"and AreaNo like '%02' and WareHouseNo = {house}";
+ //鏍¢獙姝ゆ壒娆℃槸鍚︽湁鍏ュ簱鍗�
+ /*sql2 = $"select * from BllArrivalNoticeDetail where LotNo = '{pallnetmsg.LotNo}' order by CreateTime desc";
+ ArriveMes = Db.Ado.SqlQuery<BllArrivalNoticeDetail>(sql).FirstOrDefault();
+ if (ArriveMes == null)
+ {
+ throw new Exception("璇ユ壒娆℃病鏈夊搴旂殑鍏ュ簱鍗�");
+ }
+ noticeno = ArriveMes.Id.ToString();*/
+ sql += $"and AreaNo like '%02' and WareHouseNo = '{house}'";
loction = Db.Ado.SqlQuery<SysStorageLocat>(sql).OrderByDescending(a => a.CreateTime).FirstOrDefault();
if (loction == null)
{
@@ -199,7 +234,15 @@
{
throw new Exception("鎵规鍙蜂负绌猴紒");
}
- sql += $"and AreaNo like '%03' and WareHouseNo = {house}";
+ //鏍¢獙姝ゆ壒娆℃槸鍚︽湁鍏ュ簱鍗�
+ sql2 = $"select * from BllArrivalNoticeDetail where LotNo = '{pallnetmsg.LotNo}' order by CreateTime desc";
+ ArriveMes = Db.Ado.SqlQuery<BllArrivalNoticeDetail>(sql2).FirstOrDefault();
+ if (ArriveMes == null)
+ {
+ throw new Exception("璇ユ壒娆℃病鏈夊搴旂殑鍏ュ簱鍗�");
+ }
+ noticeno = ArriveMes.Id.ToString();
+ sql += $"and AreaNo like '%03' and WareHouseNo = '{house}'";
loction = Db.Ado.SqlQuery<SysStorageLocat>(sql).OrderByDescending(a => a.CreateTime).FirstOrDefault();
if (loction == null)
{
@@ -207,7 +250,7 @@
}
break;
case "3"://鑴忔《鐢宠鍌ㄤ綅
- sql += $"and AreaNo like '%04' and WareHouseNo = {house}";
+ sql += $"and AreaNo like '%04' and WareHouseNo = '{house}'";
loction = Db.Ado.SqlQuery<SysStorageLocat>(sql).OrderByDescending(a => a.CreateTime).FirstOrDefault();
if (loction == null)
{
@@ -221,8 +264,9 @@
Endport = loction.LocatNo,
Pallno = pallnetmsg.Palletno,
Type = pallnetmsg.Type,
- Crtype = "1",
+ Crtype = "0",
Noticedetailno = int.Parse(noticeno),
+ LotNo = pallnetmsg.LotNo,
};
CreateLotTask(task);
}
@@ -325,36 +369,74 @@
{
try
{
- var na = taskDetial.Crtype == "0"?"鍏ュ簱":"鍑哄簱";
- var sql = "";
//寮�鍚簨鍔�
Db.BeginTran();
+ var na = taskDetial.Crtype == "0"?"鍏ュ簱":"鍑哄簱";
+ var bz = "";
+ switch (taskDetial.Type)
+ {
+ case "0":
+ bz = "鍑�妗�"+na+"浠诲姟";
+ break;
+ case "1":
+ bz = "棰勬贩鏂欐《" + na + "浠诲姟";
+ break;
+ case "2":
+ bz = "鍗婃垚鍝佹枡妗�" + na + "浠诲姟";
+ break;
+ case "3":
+ bz = "鑴忔《" + na + "浠诲姟";
+ break;
+ }
+ var sql = "";
+ var sql2 = "";
+ var ordertype = "3";
+ //娑夊強鍑哄叆搴撳崟鎹殑鐘舵�佷俊鎭敼鍙�
+ if (taskDetial.Type == "2" && taskDetial.Crtype =="1")//鍗婃垚鍝佸嚭搴�
+ {
+ ordertype = "1";
+ sql = $"UPDATE BllExportNotice SET Status ='1' " +
+ $"where asnno = (select ASNNO from BllExportNoticeDetail where id = {taskDetial.Noticedetailno})";
+ Db.Ado.ExecuteCommand(sql);
+ }
+ else if(taskDetial.Type =="2" && taskDetial.Crtype == "0")//鍗婃垚鍝佸叆搴�
+ {
+ ordertype = "0";
+ var ArrivalMsg = Db.Queryable<BllArrivalNoticeDetail>().First(it => it.Id == taskDetial.Noticedetailno);
+ //淇敼鍏ュ簱鍗曟�昏〃涓崟鎹姸鎬佷负姝e湪鎵ц
+ sql = $"UPDATE BllArrivalNotice SET Status ='1' where asnno = '{ArrivalMsg.ASNNo}'";
+ Db.Ado.ExecuteCommand(sql);
+ //搴撳瓨涓坊鍔犳鎵樼洏鐗╂枡缂栫爜鍜岀紪鐮佸悕绉�
+ sql2 = $"UPDATE DataStockDetail SET SkuNo = '{ArrivalMsg.SkuNo}',SkuName = '{ArrivalMsg.SkuName}' " +
+ $"where PalletNo = '{taskDetial.Pallno}'and LotNo = '{taskDetial.LotNo}'";
+ Db.Ado.ExecuteCommand(sql2);
+ }
+
//鍒ゆ柇浠诲姟鏄惁涓烘柊浠诲姟
if (string.IsNullOrWhiteSpace(taskDetial.Taskno))
{
- taskDetial.Taskno = new Common().GetMaxNo("T");
-
- var logTaskEntry = new LogTask
- {
- TaskNo = taskDetial.Taskno,
- Sender = "WMS",
- Receiver = "RCS",
- //IsSuccess = 1, //鏄惁涓嬪彂鎴愬姛 0澶辫触 1鎴愬姛
- SendDate = DateTime.Now, //鍙戦�佹椂闂�
- //BackDate = DateTime.Now, //杩斿洖鏃堕棿
- StartLocat = taskDetial.Startport,//璧峰浣嶇疆
- EndLocat = taskDetial.Endport,//鐩爣浣嶇疆
- PalletNo = taskDetial.Pallno,//鎵樼洏鐮�
- IsSend = 1,//鏄惁鍙啀娆′笅鍙�
- IsCancel = 1,//鏄惁鍙彇娑�
- IsFinish = 1,//鏄惁鍙畬鎴�
- Type = taskDetial.Crtype,//浠诲姟绫诲瀷 0 鍏ュ簱浠诲姟 1 鍑哄簱浠诲姟 2 绉诲簱浠诲姟
- Status = "0",//浠诲姟鐘舵��0锛氱瓑寰呮墽琛�1姝e湪鎵ц2鎵ц瀹屾垚
- NoticeDetailNo = int.Parse(taskDetial.Noticedetailno.ToString()),
- Msg = $"{taskDetial.Endport}鐨剓na}浠诲姟", //鍏抽敭淇℃伅
- };
- Db.Insertable(logTaskEntry).ExecuteCommand();
+ taskDetial.Taskno = new Common().GetMaxNo("TK");
}
+ var logTaskEntry = new LogTask
+ {
+ TaskNo = taskDetial.Taskno,
+ Sender = "WMS",
+ Receiver = "RCS",
+ //IsSuccess = 1, //鏄惁涓嬪彂鎴愬姛 0澶辫触 1鎴愬姛
+ SendDate = DateTime.Now, //鍙戦�佹椂闂�
+ //BackDate = DateTime.Now, //杩斿洖鏃堕棿
+ StartLocat = taskDetial.Startport,//璧峰浣嶇疆
+ EndLocat = taskDetial.Endport,//鐩爣浣嶇疆
+ PalletNo = taskDetial.Pallno,//鎵樼洏鐮�
+ IsSend = 1,//鏄惁鍙啀娆′笅鍙�
+ IsCancel = 1,//鏄惁鍙彇娑�
+ IsFinish = 1,//鏄惁鍙畬鎴�
+ Type = taskDetial.Crtype,//浠诲姟绫诲瀷 0 鍏ュ簱浠诲姟 1 鍑哄簱浠诲姟 2 绉诲簱浠诲姟
+ OrderType = ordertype,//鍗曟嵁绫诲瀷 0 鍏ュ簱 1 鍑哄簱 3鍏朵粬
+ Status = "0",//浠诲姟鐘舵��0锛氱瓑寰呮墽琛�1姝e湪鎵ц2鎵ц瀹屾垚
+ NoticeDetailNo = int.Parse(taskDetial.Noticedetailno.ToString()),
+ Msg = bz, //鍏抽敭淇℃伅
+ };
var Agv = new AgvTask
{
taskCode = taskDetial.Taskno,
@@ -363,16 +445,35 @@
endPos = taskDetial.Endport,
agvCode = "1",//鈥︹�﹂渶瑕佸拰AGV纭姝ゅ瓧娈靛��
};
+
//璇锋眰灏忚溅
genAgvSchedulingTaskRep chrep =genAgvSchedulingTask(Agv, "url");
if (chrep.code != "0")
{
- sql = $"UPDATE LogTask SET IsSuccess = '0' WHERE TaskNo = {taskDetial.Taskno}";
- Db.Ado.ExecuteCommand(sql);
+ logTaskEntry.IsSuccess = 0;
+ Db.Insertable(logTaskEntry).ExecuteCommand();
Db.CommitTran();
- throw new Exception("RCS浠诲姟涓嬪彂閿欒锛孯CS杩斿洖娑堟伅锛�"+chrep.message);
+ throw new Exception("RCS浠诲姟涓嬪彂閿欒锛孯CS杩斿洖娑堟伅锛�" + chrep.message);
}
- sql = $"UPDATE LogTask SET IsSuccess = 1,BackDate = {DateTime.Now},Status = '1' WHERE TaskNo = {taskDetial.Taskno}";
+ //璇锋眰鎴愬姛淇敼浠诲姟琛ㄧ浉搴斿瓧娈电姸鎬�
+ logTaskEntry.IsSuccess = 1;
+ logTaskEntry.BackDate = DateTime.Now;
+ logTaskEntry.Status = "1";
+ if (taskDetial.Crtype == "0")
+ {
+ sql = $"UPDATE SysStorageLocat SET Status = '2' where LocatNo = '{taskDetial.Endport}'";
+ if (taskDetial.Type == "2")
+ {
+ sql2 = $"UPDATE DataStockDetail SET PalletStatus = '{taskDetial.Type}',LotNo = '{taskDetial.LotNo}' " +
+ $"where PalletNo = '{taskDetial.Pallno}'";
+ Db.Ado.ExecuteCommand(sql2);
+ }
+ }
+ else
+ {
+ sql = $"UPDATE SysStorageLocat SET Status = '3' where LocatNo = '{taskDetial.Startport}' ";
+ }
+ Db.Insertable(logTaskEntry).ExecuteCommand();
Db.Ado.ExecuteCommand(sql);
//鎻愪氦浜嬪姟
Db.CommitTran();
--
Gitblit v1.8.0