From cfdbd0eadeb5dbe4ff8872bb67f43ae8f323a799 Mon Sep 17 00:00:00 2001
From: wxw <Administrator@DESKTOP-5BIMHQ3>
Date: 星期一, 13 十月 2025 09:35:13 +0800
Subject: [PATCH] 优化入库单导入功能
---
Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs | 996 +++++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 903 insertions(+), 93 deletions(-)
diff --git a/Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs b/Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs
index 142058b..4653959 100644
--- a/Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs
+++ b/Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs
@@ -1,6 +1,8 @@
锘縰sing System;
using System.Collections.Generic;
+using System.ComponentModel;
using System.Linq;
+using System.Reflection.Metadata;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
@@ -9,9 +11,11 @@
using Model.ModelDto;
using Model.ModelDto.BllCheckDto;
using Model.ModelDto.PdaDto;
+using Model.ModelDto.SysDto;
using Newtonsoft.Json;
using SqlSugar;
using Utility;
+using Utility.Tools;
using WMS.BLL.LogServer;
using WMS.DAL;
using WMS.Entity.BllAsnEntity;
@@ -416,15 +420,115 @@
/// <param name="locatNo">鍌ㄤ綅缂栧彿</param>
/// <param name="palletNo">鎵樼洏鍙�</param>
/// <returns></returns>
- public async Task<List<DataStockDetail>> GetStockQueryList(string locatNo, string palletNo)
+ //public async Task<List<DataStockDetail>> GetStockQueryList(string locatNo, string palletNo)
+ //{
+ // return await Db.Queryable<DataStockDetail>()
+ // .Where(s => s.IsDel == "0" && s.LocatNo.Contains(locatNo) || s.PalletNo.Contains(palletNo))
+ // .OrderBy(s => new { s.LotNo, s.LocatNo, s.PalletNo })
+ // .ToListAsync();
+ //}
+ public async Task<List<StockDetailWithQtyDto>> GetStockQueryList(string locatNo, string palletNo, string boxNo)
{
- return await Db.Queryable<DataStockDetail>()
- .Where(s => s.IsDel == "0" && s.LocatNo.Contains(locatNo) && s.PalletNo.Contains(palletNo))
- .OrderBy(s => new { s.LotNo, s.LocatNo, s.PalletNo })
- .ToListAsync();
-
+ return await Db.Queryable<DataStockDetail>("a")
+ .InnerJoin<DataBoxInfo>((a, b) => a.LotNo == b.LotNo)
+ .Where((a, b) => a.IsDel == "0")
+ .WhereIF(!string.IsNullOrWhiteSpace(locatNo), (a, b) => a.LocatNo.Contains(locatNo))
+ .WhereIF(!string.IsNullOrWhiteSpace(palletNo), (a, b) => a.PalletNo.Contains(palletNo))
+ .WhereIF(!string.IsNullOrWhiteSpace(boxNo), (a, b) => b.BoxNo.Contains(boxNo))
+ .GroupBy((a, b) => new
+ {
+ a.LotNo,
+ a.LotText,
+ a.SupplierLot,
+ a.OwnerNo,
+ a.OwnerName,
+ a.SupplierNo,
+ a.SupplierName,
+ a.SkuNo,
+ a.SkuName,
+ a.Standard,
+ a.LockQty,
+ a.FrozenQty,
+ a.InspectQty,
+ a.ASNNo,
+ a.ASNDetailNo,
+ a.SONo,
+ a.WareHouseNo,
+ a.RoadwayNo,
+ a.AreaNo,
+ a.LocatNo,
+ a.PalletNo,
+ a.PalletNo2,
+ a.PalletNo3,
+ a.PalletTags,
+ a.CompleteTime,
+ a.ProductionTime,
+ a.ExpirationTime,
+ a.Status,
+ a.InspectMark,
+ a.BitPalletMark,
+ a.InspectStatus,
+ a.InspectTime,
+ a.PackagNo,
+ a.IsBale,
+ a.IsBelt,
+ a.UDF5,
+ a.IsDel,
+ a.CreateTime,
+ a.CreateUser,
+ a.UpdateTime,
+ a.UpdateUser,
+ a.Demo
+ })
+ .OrderBy((a, b) => new { a.LotNo, a.LocatNo, a.PalletNo })
+ .Select((a, b) => new StockDetailWithQtyDto
+ {
+ LotNo = a.LotNo,
+ LotText = a.LotText,
+ SupplierLot = a.SupplierLot,
+ OwnerNo = a.OwnerNo,
+ OwnerName = a.OwnerName,
+ SupplierNo = a.SupplierNo,
+ SupplierName = a.SupplierName,
+ SkuNo = a.SkuNo,
+ SkuName = a.SkuName,
+ Standard = a.Standard,
+ Qty = SqlFunc.AggregateSum(b.Qty), // DataBoxInfo鐨凲ty瀛楁
+ LockQty = a.LockQty,
+ FrozenQty = a.FrozenQty,
+ InspectQty = a.InspectQty,
+ ASNNo = a.ASNNo,
+ ASNDetailNo = a.ASNDetailNo,
+ SONo = a.SONo,
+ WareHouseNo = a.WareHouseNo,
+ RoadwayNo = a.RoadwayNo,
+ AreaNo = a.AreaNo,
+ LocatNo = a.LocatNo,
+ PalletNo = a.PalletNo,
+ PalletNo2 = a.PalletNo2,
+ PalletNo3 = a.PalletNo3,
+ PalletTags = a.PalletTags,
+ CompleteTime = a.CompleteTime,
+ ProductionTime = a.ProductionTime,
+ ExpirationTime = a.ExpirationTime,
+ Status = a.Status,
+ InspectMark = a.InspectMark,
+ BitPalletMark = a.BitPalletMark,
+ InspectStatus = a.InspectStatus,
+ InspectTime = a.InspectTime,
+ PackagNo = a.PackagNo,
+ IsBale = a.IsBale,
+ IsBelt = a.IsBelt,
+ UDF5 = a.UDF5,
+ IsDel = a.IsDel,
+ CreateTime = a.CreateTime,
+ CreateUser = a.CreateUser,
+ UpdateTime = a.UpdateTime,
+ UpdateUser = a.UpdateUser,
+ Demo = a.Demo
+ })
+ .ToListAsync();
}
-
#endregion
#region 鎵樼洏鍙樻洿锛堟墭鐩樿В缁戠粦瀹氾級
@@ -690,9 +794,9 @@
{
throw Oops.Bah("鎵樼洏鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
}
- if (models.WareHouseNo != "W04")
+ if (models.WareHouseNo != "W04" && models.WareHouseNo != "W02")
{
- throw Oops.Bah("璇ユ墭鐩樻湭鍦ㄥ钩搴撳唴,璇锋鏌�!");
+ throw Oops.Bah("璇ユ墭鐩樻湭鍦ㄥ钩搴撳唴鎴栬揣鏋跺簱鍐�,璇锋鏌�!");
}
return models.LocatNo;
}
@@ -720,7 +824,7 @@
{
throw Oops.Bah("鎵樼洏鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
}
- if (models.WareHouseNo != "W04")
+ if (models.WareHouseNo != "W04" && models.WareHouseNo != "W02")
{
throw Oops.Bah("璇ユ墭鐩樻湭鍦ㄥ钩搴撳唴,璇锋鏌�!");
}
@@ -730,11 +834,40 @@
throw Oops.Bah("鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
}
-
- storageArea = await Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.Status == "0" && w.AreaNo != storageLocat.AreaNo && w.WareHouseNo == "W04").OrderBy(o => o.AreaNo).ToListAsync();
+ if (models.WareHouseNo == "W02")
+ {
+ storageArea = await Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.Status == "0" && w.AreaNo != storageLocat.AreaNo && w.WareHouseNo == "W04" && (w.AreaNo == "B01" || w.AreaNo == "B02" || w.AreaNo == "B05")).OrderBy(o => o.AreaNo).ToListAsync();
+ }
+ else
+ {
+ storageArea = await Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.Status == "0" && w.AreaNo != storageLocat.AreaNo && w.WareHouseNo == "W04").OrderBy(o => o.AreaNo).ToListAsync();
+ }
}
return storageArea;
+ }
+ /// <summary>
+ /// 鏍规嵁鍖哄煙鍙疯幏鍙栧偍浣嶅湴鍧�闆嗗悎
+ /// </summary>
+ /// <param name="areaNo"></param>
+ /// <returns></returns>
+ /// <exception cref="Exception"></exception>
+ public List<string> GetLocatByArea(string areaNo)
+ {
+ try
+ {
+ if (string.IsNullOrEmpty(areaNo))
+ {
+ throw new Exception("璇烽�夋嫨鍖哄煙");
+ }
+ var _list = Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.AreaNo == areaNo && w.WareHouseNo == "W04").Select(s => s.LocatNo).ToList();
+
+ return _list;
+ }
+ catch (Exception ex)
+ {
+ throw new Exception(ex.Message);
+ }
}
/// <summary>
/// 鑾峰彇宸插垎閰嶇殑鍑哄簱鍗曟嵁
@@ -778,7 +911,7 @@
/// <param name="palletNo"></param>
/// <param name="areaNo"></param>
/// <param name="ruku"></param>
- public async Task AgvTransport(string palletNo, string areaNo, string ruku, string url, int userId)
+ /*public async Task AgvTransport(string palletNo, string areaNo, string ruku, string url, int userId)
{
try
{
@@ -828,7 +961,7 @@
{
throw Oops.Bah("鎵樼洏鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
}
- if (stockDetail.WareHouseNo != "W04")
+ if (stockDetail.WareHouseNo != "W04" && stockDetail.WareHouseNo != "W02")
{
throw Oops.Bah("璇ユ墭鐩樻湭鍦ㄥ钩搴撳唴,璇锋鏌�!");
}
@@ -839,23 +972,22 @@
throw Oops.Bah("鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
}
//鐩爣鍌ㄤ綅淇℃伅
- var storageLocatEnd = new SysStorageLocat();
- if (!string.IsNullOrEmpty(areaNo))
+ //var storageLocatEnd = new SysStorageLocat();
+
+ var storageLocatEnd = await Db.Queryable<SysStorageLocat>().FirstAsync(w => w.IsDel == "0" && w.LocatNo == EndLocat && w.Flag == "0");
+ if (storageLocatEnd == null)
{
- storageLocatEnd = await Db.Queryable<SysStorageLocat>().FirstAsync(w => w.IsDel == "0" && w.LocatNo == EndLocat && w.Flag == "0");
- if (storageLocatEnd == null)
- {
- throw Oops.Bah("鐩爣鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
- }
+ throw Oops.Bah("鐩爣鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
}
+
//娣诲姞鍑哄簱浠诲姟
var taskNo = new Common().GetMaxNo("TK");
- var exTask = new LogTask
+ var moveTask = new LogTask
{
TaskNo = taskNo,
Sender = "WMS",
- Receiver = "AGV",
+ Receiver = "WCS",
IsSuccess = 0, //鏄惁涓嬪彂鎴愬姛 0澶辫触 1鎴愬姛
StartLocat = stockDetail.LocatNo,//璧峰浣嶇疆
@@ -871,7 +1003,7 @@
CreateTime = DateTime.Now
};
- await Db.Insertable(exTask).ExecuteCommandAsync();
+ await Db.Insertable(moveTask).ExecuteCommandAsync();
//淇敼搴撳瓨鏄庣粏淇℃伅
//stockDetail.Status = "4";//绉诲簱閿佸畾
@@ -894,19 +1026,22 @@
//娣诲姞鎿嶄綔鏃ュ織璁板綍
var k = new OperationCrServer().AddLogOperationCr("PDA妯″潡", "AGV杞繍", palletNo, "绉诲簱", $"PDA鍛煎彨灏忚溅瀵规墭鐩樺彿锛歿palletNo}鍙戣捣杞繍", userId);
- var outDto = new List<OutCommandDto>();
- outDto.Add(new OutCommandDto()
+ var outDto = new List<OutCommandDto>
{
- PalletNo = exTask.PalletNo,//鎵樼洏鍙�
- StartLocate = exTask.StartLocat, // 璧峰浣嶇疆
- StartRoadway = storageLocat.RoadwayNo,//鍏跺疄宸烽亾
- EndLocate = EndLocat, // 鐩爣浣嶇疆
- TaskNo = exTask.TaskNo, // 浠诲姟鍙�
- TaskType = "2",// 浠诲姟绫诲瀷 (鍑哄簱)0鍏� 1鍑� 2绉�
- OutMode = "", //鍑哄簱鍙�
- Order = 1
+ new OutCommandDto()
+ {
+ TaskNo = moveTask.TaskNo, // 浠诲姟鍙�
+ TaskType = "2",// 浠诲姟绫诲瀷 0鍏� 1鍑� 2绉�
+ PalletNo = moveTask.PalletNo,//鎵樼洏鍙�
- });
+ StartLocate = moveTask.StartLocat, // 璧峰浣嶇疆
+ EndLocate = EndLocat, // 鐩爣浣嶇疆
+
+ Order = 999,
+ Type = PLCTypeEnum.AGV
+
+ }
+ };
// 姝e紡杩愯绋嬪簭鏀惧紑
var list2 = outDto.Select(m => m.TaskNo).ToList();
@@ -916,21 +1051,367 @@
try
{
var time1 = DateTime.Now;//鍙戦�佹椂闂� .ToString("yyyy-MM-dd HH:mm:ss")
- //response = HttpHelper.DoPost(url, jsonData, "涓嬪彂缁橶CS鍑哄簱鍛戒护", "WCS");
+ response = HttpHelper.DoPost(url, jsonData, "涓嬪彂缁橶CS鍑哄簱鍛戒护", "WCS");
var time2 = DateTime.Now;//杩斿洖鏃堕棿 .ToString("yyyy-MM-dd HH:mm:ss")
- //////瑙f瀽杩斿洖鏁版嵁
- //var wcsModel = JsonConvert.DeserializeObject<WcsModel>(response);
- //if (wcsModel.StatusCode == 0)
- //{
- // //鏇存敼浠诲姟鐨勫彂閫佽繑鍥炴椂闂�//
- new TaskServer().EditTaskIssueOk(list2, time1, time2);
- //}
- //if (wcsModel.StatusCode == -1)
- //{
- // new TaskServer().EditTaskIssueNo(list2, time1, time2, wcsModel.Msg);
- // throw new Exception(wcsModel.Msg);
- //}
+ //瑙f瀽杩斿洖鏁版嵁
+ var wcsModel = JsonConvert.DeserializeObject<WcsModel2>(response);
+ if (wcsModel.code == 200)
+ {
+ // 鏇存敼浠诲姟鐨勫彂閫佽繑鍥炴椂闂�//
+ new TaskServer().EditTaskIssueOk(list2, time1, time2);
+ }
+ else
+ {
+ new TaskServer().EditTaskIssueNo(list2, time1, time2, wcsModel.message);
+ throw new Exception(wcsModel.message);
+ }
+ }
+ catch (Exception ex)
+ {
+ throw new Exception(ex.Message);
+ }
+
+ }
+ catch (Exception e)
+ {
+ throw new Exception(e.Message);
+ }
+ }*/
+
+ public async Task AgvTransport(string palletNo, string areaNo,string locatNoEnd, string ruku, string url, int userId)
+ {
+ try
+ {
+ if (string.IsNullOrEmpty(palletNo))
+ {
+ throw Oops.Bah("璇锋壂鎻忔墭鐩樻潯鐮侊紒");
+ }
+ if (string.IsNullOrEmpty(areaNo) && string.IsNullOrEmpty(ruku))
+ {
+ throw Oops.Bah("璇烽�夋嫨鐩爣鍖哄煙鎴栧叆搴撳彛锛�");
+ }
+ if (!string.IsNullOrEmpty(areaNo) && !string.IsNullOrEmpty(ruku))
+ {
+ throw Oops.Bah("鐩爣鍖哄煙鍜屽叆搴撳彛涓嶈兘鍚屾椂閫夋嫨锛�");
+ }
+ string EndLocat = string.Empty;//鐩爣浣嶇疆
+
+ var log = await Db.Queryable<LogTask>().FirstAsync(w => w.IsDel == "0" && w.PalletNo == palletNo && (w.Status == "0" || w.Status == "1"));
+ if (log != null)
+ {
+ throw Oops.Bah("璇ユ墭鐩樺凡鏈夌瓑寰呮墽琛屾垨姝e湪鎵ц鐨勪换鍔�!");
+ }
+ var stockDetail = await Db.Queryable<DataStockDetail>().FirstAsync(w => w.IsDel == "0" && w.PalletNo == palletNo);
+ if (stockDetail == null)
+ {
+ throw Oops.Bah("鎵樼洏涓婄墿鏂欏簱瀛樻槑缁嗕俊鎭笉瀛樺湪,璇锋鏌�!");
+ }
+ if (!string.IsNullOrEmpty(areaNo))
+ {
+ var storageArea = await Db.Queryable<SysStorageArea>().FirstAsync(w => w.IsDel == "0" && w.AreaNo == areaNo);
+ if (storageArea == null)
+ {
+ throw Oops.Bah("鎵�閫夊尯鍩熶俊鎭笉瀛樺湪,璇锋鏌�!");
+ }
+ if (!string.IsNullOrEmpty(locatNoEnd))
+ {
+ EndLocat = locatNoEnd;//鎸囧畾鍌ㄤ綅鍦板潃
+ }
+ else
+ {
+ EndLocat = await GetLocat(areaNo);//绯荤粺鍒嗛厤鍌ㄤ綅鍦板潃
+ }
+ }
+ else
+ {
+ EndLocat = ruku;
+ }
+ var stock = await Db.Queryable<DataStock>().FirstAsync(w => w.IsDel == "0" && w.SkuNo == stockDetail.SkuNo && w.LotNo == stockDetail.LotNo);
+ if (stock == null)
+ {
+ throw Oops.Bah("鎵樼洏涓婄墿鏂欏簱瀛樹俊鎭笉瀛樺湪,璇锋鏌�!");
+ }
+ if (string.IsNullOrEmpty(stockDetail.LocatNo))
+ {
+ throw Oops.Bah("鎵樼洏鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
+ }
+ if (stockDetail.WareHouseNo != "W04" && stockDetail.WareHouseNo != "W02")
+ {
+ throw Oops.Bah("璇ユ墭鐩樻湭鍦ㄥ钩搴撴垨璐ф灦搴撳唴,璇锋鏌�!");
+ }
+
+ //璧峰鍌ㄤ綅淇℃伅
+ var storageLocat = await Db.Queryable<SysStorageLocat>().FirstAsync(w => w.IsDel == "0" && w.LocatNo == stockDetail.LocatNo);
+ if (storageLocat == null)
+ {
+ throw Oops.Bah("鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
+ }
+ //鐩爣鍌ㄤ綅淇℃伅
+ var storageLocatEnd = new SysStorageLocat();
+ if (!string.IsNullOrEmpty(areaNo))
+ {
+ storageLocatEnd = await Db.Queryable<SysStorageLocat>().FirstAsync(w => w.IsDel == "0" && w.LocatNo == EndLocat && w.Flag == "0" && w.WareHouseNo == "W04" && w.AreaNo == areaNo);
+ }
+ else
+ {
+ storageLocatEnd = await Db.Queryable<SysStorageLocat>().FirstAsync(w => w.IsDel == "0" && w.LocatNo == EndLocat && w.Flag == "0" && w.WareHouseNo == "W04");
+ }
+ if (storageLocatEnd == null)
+ {
+ throw Oops.Bah("鐩爣鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
+ }
+
+
+ //娣诲姞鍑哄簱浠诲姟
+ var taskNo = new Common().GetMaxNo("TK");
+ var moveTask = new LogTask
+ {
+ TaskNo = taskNo,
+ Sender = "WMS",
+ Receiver = "WCS",
+ IsSuccess = 0, //鏄惁涓嬪彂鎴愬姛 0澶辫触 1鎴愬姛
+
+ StartLocat = stockDetail.LocatNo,//璧峰浣嶇疆
+ EndLocat = EndLocat,//鐩爣浣嶇疆
+ PalletNo = palletNo,//鎵樼洏鐮�
+ Msg = string.Format("杞繍浠诲姟锛歿0}=>>{1}", stockDetail.LocatNo, EndLocat),
+ IsSend = 1,//鏄惁鍙啀娆′笅鍙�
+ IsCancel = 1,//鏄惁鍙彇娑�
+ IsFinish = 1,//鏄惁鍙畬鎴�
+ Type = "2",//浠诲姟绫诲瀷 0 鍏ュ簱浠诲姟 1 鍑哄簱浠诲姟 2 绉诲簱浠诲姟
+ Status = "0",//浠诲姟鐘舵��0锛氱瓑寰呮墽琛�1姝e湪鎵ц2鎵ц瀹屾垚
+ OrderType = "3",//0 鍏ュ簱鍗� 1 鍑哄簱鍗� 2 鐩樼偣鍗� 3 绉诲簱鍗�
+
+ CreateTime = DateTime.Now
+ };
+ await Db.Insertable(moveTask).ExecuteCommandAsync();
+
+ //淇敼搴撳瓨鏄庣粏淇℃伅
+ //stockDetail.Status = "4";//绉诲簱閿佸畾
+ //stockDetail.LockQty = stockDetail.Qty;//閿佸畾搴撳瓨鏁伴噺
+ //await Db.Updateable(stockDetail).ExecuteCommandAsync();
+ ////淇敼搴撳瓨淇℃伅
+ //stock.LockQty += (decimal)stockDetail.Qty;
+ //await Db.Updateable(stock).ExecuteCommandAsync();
+
+ //淇敼璧峰鍌ㄤ綅鍦板潃鐘舵��
+ storageLocat.Status = "5";//0锛氱┖鍌ㄤ綅 1锛氭湁鐗╁搧 2锛氬叆搴撲腑 3锛氬嚭搴撲腑 4锛氱Щ鍏ヤ腑 5锛氱Щ鍑轰腑
+ await Db.Updateable(storageLocat).ExecuteCommandAsync();
+
+ //淇敼鐩爣鍌ㄤ綅鍦板潃鐘舵��
+ if (storageLocatEnd != null)
+ {
+ storageLocatEnd.Status = "4";//0锛氱┖鍌ㄤ綅 1锛氭湁鐗╁搧 2锛氬叆搴撲腑 3锛氬嚭搴撲腑 4锛氱Щ鍏ヤ腑 5锛氱Щ鍑轰腑
+ await Db.Updateable(storageLocatEnd).ExecuteCommandAsync();
+ }
+ //娣诲姞鎿嶄綔鏃ュ織璁板綍
+ var k = new OperationCrServer().AddLogOperationCr("PDA妯″潡", "AGV杞繍", palletNo, "绉诲簱", $"PDA鍛煎彨灏忚溅瀵规墭鐩樺彿锛歿palletNo}鍙戣捣杞繍", userId);
+
+ var outDto = new List<OutCommandDto>
+ {
+ new OutCommandDto()
+ {
+ TaskNo = moveTask.TaskNo, // 浠诲姟鍙�
+ TaskType = "2",// 浠诲姟绫诲瀷 0鍏� 1鍑� 2绉�
+ PalletNo = moveTask.PalletNo,//鎵樼洏鍙�
+
+ StartLocate = moveTask.StartLocat, // 璧峰浣嶇疆
+ EndLocate = EndLocat, // 鐩爣浣嶇疆
+
+ Order = 999,
+ Type = PLCTypeEnum.AGV
+
+ }
+ };
+
+ // 姝e紡杩愯绋嬪簭鏀惧紑
+ var list2 = outDto.Select(m => m.TaskNo).ToList();
+ var jsonData = JsonConvert.SerializeObject(outDto);
+ string response = "";
+
+ try
+ {
+ var time1 = DateTime.Now;//鍙戦�佹椂闂� .ToString("yyyy-MM-dd HH:mm:ss")
+ response = HttpHelper.DoPost(url, jsonData, "涓嬪彂缁橶CS鍑哄簱鍛戒护", "WCS");
+ var time2 = DateTime.Now;//杩斿洖鏃堕棿 .ToString("yyyy-MM-dd HH:mm:ss")
+
+ //瑙f瀽杩斿洖鏁版嵁
+ var wcsModel = JsonConvert.DeserializeObject<WcsModel2>(response);
+ if (wcsModel.code == 200)
+ {
+ // 鏇存敼浠诲姟鐨勫彂閫佽繑鍥炴椂闂�//
+ new TaskServer().EditTaskIssueOk(list2, time1, time2);
+ }
+ else
+ {
+ new TaskServer().EditTaskIssueNo(list2, time1, time2, wcsModel.message);
+ throw new Exception(wcsModel.message);
+ }
+ }
+ catch (Exception ex)
+ {
+ throw new Exception(ex.Message);
+ }
+
+ }
+ catch (Exception e)
+ {
+ throw new Exception(e.Message);
+ }
+ }
+ /// <summary>
+ /// 鍛煎彨agv杞繍绌烘墭鐩�
+ /// </summary>
+ /// <param name="palletNo"></param>
+ /// <param name="areaNo"></param>
+ /// <param name="locatNo"></param>
+ /// <param name="url"></param>
+ /// <param name="userId"></param>
+ /// <returns></returns>
+ /// <exception cref="Exception"></exception>
+ public async Task AgvNullPallet(string palletNo, string areaNo, string locatNo, string url, int userId)
+ {
+ try
+ {
+ if (string.IsNullOrEmpty(palletNo))
+ {
+ throw Oops.Bah("璇锋壂鎻忔墭鐩樻潯鐮侊紒");
+ }
+ if (string.IsNullOrEmpty(locatNo))
+ {
+ throw Oops.Bah("璇锋壂鎻忚捣濮嬪湴鐮侊紒");
+ }
+ if (string.IsNullOrEmpty(areaNo))
+ {
+ throw Oops.Bah("璇烽�夋嫨鐩爣鍖哄煙锛�");
+ }
+ string EndLocat = string.Empty;//鐩爣浣嶇疆
+
+ var log = await Db.Queryable<LogTask>().FirstAsync(w => w.IsDel == "0" && w.PalletNo == palletNo && (w.Status == "0" || w.Status == "1"));
+ if (log != null)
+ {
+ throw Oops.Bah("璇ユ墭鐩樺凡鏈夌瓑寰呮墽琛屾垨姝e湪鎵ц鐨勪换鍔�!");
+ }
+ var stockDetail = await Db.Queryable<DataStockDetail>().FirstAsync(w => w.IsDel == "0" && w.PalletNo == palletNo);
+ if (stockDetail != null)
+ {
+ throw Oops.Bah("鎵樼洏涓婄墿鏂欏瓨鍦ㄥ簱瀛樻槑缁嗕俊鎭�,璇锋鏌�!");
+ }
+
+ var storageArea = await Db.Queryable<SysStorageArea>().FirstAsync(w => w.IsDel == "0" && w.AreaNo == areaNo);
+ if (storageArea == null)
+ {
+ throw Oops.Bah("鎵�閫夊尯鍩熶俊鎭笉瀛樺湪,璇锋鏌�!");
+ }
+ var palletInfo = await Db.Queryable<SysPallets>().FirstAsync(w => w.IsDel == "0" && w.PalletNo == palletNo);
+ if (palletInfo == null)
+ {
+ throw Oops.Bah("璇ユ墭鐩樹俊鎭笉瀛樺湪!");
+ }
+ if (palletInfo.Status!="0")
+ {
+ throw Oops.Bah("璇ユ墭鐩樹笉鏄┖鎵樼洏!");
+ }
+ //鏍规嵁鐩爣鍖哄煙鑾峰彇鐩爣鍌ㄤ綅鍦板潃
+ EndLocat = await GetLocat(areaNo);
+ if (string.IsNullOrEmpty(EndLocat))
+ {
+ throw Oops.Bah("鑾峰彇鐩爣鍌ㄤ綅澶辫触!");
+ }
+
+ //璧峰鍌ㄤ綅淇℃伅
+ var storageLocat = await Db.Queryable<SysStorageLocat>().FirstAsync(w => w.IsDel == "0" && w.LocatNo == locatNo);
+ if (storageLocat == null)
+ {
+ throw Oops.Bah("鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
+ }
+ //鐩爣鍌ㄤ綅淇℃伅
+ //var storageLocatEnd = new SysStorageLocat();
+
+ var storageLocatEnd = await Db.Queryable<SysStorageLocat>().FirstAsync(w => w.IsDel == "0" && w.LocatNo == EndLocat && w.Flag == "0");
+ if (storageLocatEnd == null)
+ {
+ throw Oops.Bah("鐩爣鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
+ }
+
+ //娣诲姞鍑哄簱浠诲姟
+ var taskNo = new Common().GetMaxNo("TK");
+ var moveTask = new LogTask
+ {
+ TaskNo = taskNo,
+ Sender = "WMS",
+ Receiver = "WCS",
+ IsSuccess = 0, //鏄惁涓嬪彂鎴愬姛 0澶辫触 1鎴愬姛
+
+ StartLocat = storageLocat.LocatNo,//璧峰浣嶇疆
+ EndLocat = EndLocat,//鐩爣浣嶇疆
+ PalletNo = palletNo,//鎵樼洏鐮�
+ Msg = string.Format("杞繍浠诲姟锛歿0}=>>{1}", storageLocat.LocatNo, EndLocat),
+ IsSend = 1,//鏄惁鍙啀娆′笅鍙�
+ IsCancel = 1,//鏄惁鍙彇娑�
+ IsFinish = 1,//鏄惁鍙畬鎴�
+ Type = "2",//浠诲姟绫诲瀷 0 鍏ュ簱浠诲姟 1 鍑哄簱浠诲姟 2 绉诲簱浠诲姟
+ Status = "0",//浠诲姟鐘舵��0锛氱瓑寰呮墽琛�1姝e湪鎵ц2鎵ц瀹屾垚
+ OrderType = "3",//0 鍏ュ簱鍗� 1 鍑哄簱鍗� 2 鐩樼偣鍗� 3 绉诲簱鍗�
+
+ CreateTime = DateTime.Now
+ };
+ await Db.Insertable(moveTask).ExecuteCommandAsync();
+
+ //淇敼璧峰鍌ㄤ綅鍦板潃鐘舵��
+ storageLocat.Status = "5";//0锛氱┖鍌ㄤ綅 1锛氭湁鐗╁搧 2锛氬叆搴撲腑 3锛氬嚭搴撲腑 4锛氱Щ鍏ヤ腑 5锛氱Щ鍑轰腑
+ await Db.Updateable(storageLocat).ExecuteCommandAsync();
+
+ //淇敼鐩爣鍌ㄤ綅鍦板潃鐘舵��
+ //if (storageLocatEnd != null)
+ //{
+ // storageLocatEnd.Status = "4";//0锛氱┖鍌ㄤ綅 1锛氭湁鐗╁搧 2锛氬叆搴撲腑 3锛氬嚭搴撲腑 4锛氱Щ鍏ヤ腑 5锛氱Щ鍑轰腑
+ // await Db.Updateable(storageLocatEnd).ExecuteCommandAsync();
+ //}
+ //娣诲姞鎿嶄綔鏃ュ織璁板綍
+ var k = new OperationCrServer().AddLogOperationCr("PDA妯″潡", "AGV绌烘墭杞繍", palletNo, "绉诲簱", $"PDA鍛煎彨灏忚溅瀵规墭鐩樺彿锛歿palletNo}鍙戣捣杞繍", userId);
+
+ var outDto = new List<OutCommandDto>
+ {
+ new OutCommandDto()
+ {
+ TaskNo = moveTask.TaskNo, // 浠诲姟鍙�
+ TaskType = "2",// 浠诲姟绫诲瀷 0鍏� 1鍑� 2绉�
+ PalletNo = moveTask.PalletNo,//鎵樼洏鍙�
+
+ StartLocate = moveTask.StartLocat, // 璧峰浣嶇疆
+ EndLocate = EndLocat, // 鐩爣浣嶇疆
+
+ Order = 999,
+ Type = PLCTypeEnum.AGV
+
+ }
+ };
+
+ // 姝e紡杩愯绋嬪簭鏀惧紑
+ var list2 = outDto.Select(m => m.TaskNo).ToList();
+ var jsonData = JsonConvert.SerializeObject(outDto);
+ string response = "";
+
+ try
+ {
+ var time1 = DateTime.Now;//鍙戦�佹椂闂� .ToString("yyyy-MM-dd HH:mm:ss")
+ response = HttpHelper.DoPost(url, jsonData, "涓嬪彂缁橶CS鍑哄簱鍛戒护", "WCS");
+ var time2 = DateTime.Now;//杩斿洖鏃堕棿 .ToString("yyyy-MM-dd HH:mm:ss")
+
+ //瑙f瀽杩斿洖鏁版嵁
+ var wcsModel = JsonConvert.DeserializeObject<WcsModel2>(response);
+ if (wcsModel.code == 200)
+ {
+ // 鏇存敼浠诲姟鐨勫彂閫佽繑鍥炴椂闂�//
+ new TaskServer().EditTaskIssueOk(list2, time1, time2);
+ }
+ else
+ {
+ new TaskServer().EditTaskIssueNo(list2, time1, time2, wcsModel.message);
+ throw new Exception(wcsModel.message);
+ }
}
catch (Exception ex)
{
@@ -1102,25 +1583,34 @@
string endLocat = string.Empty;//鐩爣鍌ㄤ綅
//褰撳墠鍖哄煙鎵�鏈夊偍浣嶄俊鎭�
var storageLocatList = await Db.Queryable<SysStorageLocat>().Where(w => w.WareHouseNo == "W04" && w.AreaNo == areaNo).ToListAsync();
-
- var locatInfo2 = storageLocatList.Where(w => w.IsDel == "0" && w.Flag == "0" && w.Status == "0")
+
+ var locatInfo2 = new SysStorageLocat();
+ if (areaNo == "B10")
+ {
+ locatInfo2 = storageLocatList.Where(w => w.IsDel == "0" && w.Flag == "0")
.OrderByDescending(m => m.Layer).OrderByDescending(m => m.Column).OrderByDescending(m => m.Row).First();
+ }
+ else
+ {
+ locatInfo2 = storageLocatList.Where(w => w.IsDel == "0" && w.Flag == "0" && w.Status == "0")
+ .OrderByDescending(m => m.Layer).OrderByDescending(m => m.Column).OrderByDescending(m => m.Row).First();
+ }
if (locatInfo2 != null)
{
endLocat = locatInfo2.LocatNo;
}
- if (string.IsNullOrEmpty(endLocat))
- {
- var locatInfo3 = storageLocatList.Where(w => w.IsDel == "0" && w.Flag == "0")
- .OrderByDescending(m => m.Layer).OrderByDescending(m => m.Column).OrderByDescending(m => m.Row).First();
+ //if (string.IsNullOrEmpty(endLocat))
+ //{
+ // var locatInfo3 = storageLocatList.Where(w => w.IsDel == "0" && w.Flag == "0")
+ // .OrderByDescending(m => m.Layer).OrderByDescending(m => m.Column).OrderByDescending(m => m.Row).First();
- if (locatInfo3 != null)
- {
- endLocat = locatInfo3.LocatNo;
- }
- }
+ // if (locatInfo3 != null)
+ // {
+ // endLocat = locatInfo3.LocatNo;
+ // }
+ //}
return endLocat;
}
#endregion
@@ -1214,7 +1704,7 @@
/// <param name="boxNo"></param>
/// <param name="devanQty"></param>
/// <param name="userId"></param>
- public void AddLableByDevanning(string boxNo, decimal devanQty, int userId)
+ public BoxListInfoDto AddLableByDevanning(string boxNo, decimal devanQty, int userId)
{
try
{
@@ -1224,9 +1714,9 @@
}
//寮�鍚簨鍔�
Db.BeginTran();
-
+
//搴撳瓨绠辨敮鏄庣粏淇℃伅
- var boxList = Db.Queryable<DataBoxInfo>().Where(w => w.IsDel == "0" && w.BoxNo == boxNo).ToList();
+ var boxList = Db.Queryable<DataBoxInfo>().Where(w => w.IsDel == "0" && w.BoxNo == boxNo && w.Status == "2").ToList();
if (boxList.Count != 1)
{
throw new Exception("璇ョ鐮佷俊鎭敊璇紝瀛樺湪澶氫釜姝ょ鐮佷俊鎭�");
@@ -1290,6 +1780,23 @@
new OperationCrServer().AddLogOperationCr("搴撳唴浣滀笟", "鎿嶄綔鏃ュ織", boxNo, "缂栬緫", $"鎷嗙璐存爣锛氬師绠辩爜锛歿boxNo}鎷嗙锛屾坊鍔犳柊绠辩爜{boxNoNew}", userId);
//鎻愪氦浜嬪姟
Db.CommitTran();
+
+ #region 鑾峰彇鎷嗙鐨勪俊鎭墦鍗�
+
+
+ var data = new BoxListInfoDto()
+ {
+ SkuNo = boxInfo.SkuNo,
+ SkuName = boxInfo.SkuName,
+ LotNo = boxInfo.LotNo,
+ BoxNoList = new List<string>() { boxNoNew } ,
+ Date1 = boxInfo.ProductionTime == null ? "" : Convert.ToDateTime(boxInfo.ProductionTime).ToString("yyyy-MM-dd"),
+ Date2 = boxInfo.ExpirationTime == null ? "" : Convert.ToDateTime(boxInfo.ExpirationTime).ToString("yyyy-MM-dd"),
+ };
+
+ #endregion
+
+ return data;
}
catch (Exception e)
{
@@ -1318,15 +1825,15 @@
{
throw new Exception("鎵樼洏娌℃湁鍑哄簱鍗曚俊鎭�");
}
- var task = Db.Queryable<LogTask>().First(m => m.PalletNo == palletNo && m.IsDel == "0" && m.Status == "5");
- if (task == null)
- {
- throw new Exception("娌℃湁鏌ヨ鍒版墭鐩樹换鍔′俊鎭�");
- }
- if (task.Status != "5")
- {
- throw new Exception("浠诲姟鐘舵�佷笉鏄瓑寰呯‘璁�");
- }
+ //var task = Db.Queryable<LogTask>().First(m => m.PalletNo == palletNo && m.IsDel == "0" && m.Status == "5");
+ //if (task == null)
+ //{
+ // throw new Exception("娌℃湁鏌ヨ鍒版墭鐩樹换鍔′俊鎭�");
+ //}
+ //if (task.Status != "5")
+ //{
+ // throw new Exception("浠诲姟鐘舵�佷笉鏄瓑寰呯‘璁�");
+ //}
return detail;
}
catch (Exception e)
@@ -1346,20 +1853,26 @@
try
{
Db.BeginTran();
- var task = Db.Queryable<LogTask>().First(m => m.PalletNo == palletNo && m.IsDel == "0" && m.Status == "5");
- if (task == null)
+ //var task = Db.Queryable<LogTask>().First(m => m.PalletNo == palletNo && m.IsDel == "0" && m.Status == "5");
+ //if (task == null)
+ //{
+ // throw new Exception("娌℃湁鏌ヨ鍒版墭鐩樹换鍔′俊鎭�");
+ //}
+ //if (task.Status != "5")
+ //{
+ // throw new Exception("浠诲姟鐘舵�佷笉鏄瓑寰呯‘璁�");
+ //}
+ ////浠诲姟鐘舵�佸彉鏇翠负鎵ц瀹屾垚
+ //task.Status = "2";
+ //Db.Updateable(task).ExecuteCommand();
+ var stockDetail = Db.Queryable<DataStockDetail>().Where(m => m.IsDel == "0" && m.PalletNo == palletNo).ToList();
+ if (stockDetail.Count == 0)
{
- throw new Exception("娌℃湁鏌ヨ鍒版墭鐩樹换鍔′俊鎭�");
+ throw new Exception("搴撳瓨鎵樼洏娌℃湁淇℃伅");
}
- if (task.Status != "5")
- {
- throw new Exception("浠诲姟鐘舵�佷笉鏄瓑寰呯‘璁�");
- }
- //浠诲姟鐘舵�佸彉鏇翠负鎵ц瀹屾垚
- task.Status = "2";
- Db.Updateable(task).ExecuteCommand();
- var locatList = Db.Queryable<SysStorageLocat>().Where(m=>m.WareHouseNo == "W04" && (m.AreaNo == "B06" || m.AreaNo == "B07") && m.IsDel == "0").ToList();
- var locat = locatList.FirstOrDefault(m => m.LocatNo == task.EndLocat);
+ var locate = stockDetail.First().LocatNo;
+ var locatList = Db.Queryable<SysStorageLocat>().Where(m=>m.WareHouseNo == "W04" && (m.AreaNo == "B06" || m.AreaNo == "B07" || m.AreaNo == "B09") && m.IsDel == "0").ToList();
+ var locat = locatList.FirstOrDefault(m => m.LocatNo == locate);
//鍒ゆ柇鎵樼洏鍌ㄤ綅鏄惁鍦ㄨ溅闂�
if (locat == null)
{
@@ -1368,7 +1881,7 @@
locat.Status = "0";
Db.Updateable(locat).ExecuteCommand();
//鍒ゆ柇鎵樼洏淇℃伅
- var stockDetail = Db.Queryable<DataStockDetail>().Where(m => m.IsDel == "0" && m.PalletNo == palletNo).ToList();
+
foreach (var item in stockDetail)
{
if (item.UDF5 != "1" || string.IsNullOrWhiteSpace(item.SONo))
@@ -1380,7 +1893,7 @@
//item.RoadwayNo = "";
//item.AreaNo = "";
item.LocatNo = "";
- item.PalletNo = "";
+ //item.PalletNo = "";
item.LockQty = 0; // 閿佸畾鏁伴噺鏇翠负0
item.Status = "0"; // 鐘舵�佸彉涓哄緟鍒嗛厤
var boxInfo = Db.Queryable<DataBoxInfo>().Where(m => m.StockDetailId == item.Id).ToList();
@@ -1393,15 +1906,15 @@
}
Db.Updateable(stockDetail).ExecuteCommand();
//鎵樼洏鍙樻洿鐘舵��
- var pallet = Db.Queryable<SysPallets>().First(m => m.IsDel == "0" && m.PalletNo == palletNo);
- if (pallet == null)
- {
- throw new Exception("娌℃湁鏌ヨ鍒版墭鐩樹俊鎭�");
- }
- pallet.Status = "0";
- Db.Updateable(pallet).ExecuteCommand();
+ //var pallet = Db.Queryable<SysPallets>().First(m => m.IsDel == "0" && m.PalletNo == palletNo);
+ //if (pallet == null)
+ //{
+ // throw new Exception("娌℃湁鏌ヨ鍒版墭鐩樹俊鎭�");
+ //}
+ //pallet.Status = "0";
+ //Db.Updateable(pallet).ExecuteCommand();
//娣诲姞鎿嶄綔鏃ュ織
- new OperationCrServer().AddLogOperationCr("搴撳唴浣滀笟", "鎿嶄綔鏃ュ織", palletNo, "缂栬緫", $"杞﹂棿鏀惰揣锛歿palletNo}鎵樼洏鏀惰揣", userId);
+ new OperationCrServer().AddLogOperationCr("PDA妯″潡", "杞﹂棿鏀惰揣", palletNo, "瀹屾垚", $"杞﹂棿鏀惰揣锛歿palletNo}鎵樼洏鏀惰揣", userId);
Db.CommitTran();
}
catch (Exception e)
@@ -1415,5 +1928,302 @@
#endregion
+ #region 鐗╂枡鎷嗘墭 锛堟爣绛俱�佹暟閲忥級
+
+ /// <summary>
+ /// 鏌ヨ绠变俊鎭�
+ /// </summary>
+ /// <param name="boxNo"></param>
+ /// <param name="pallNo"></param>
+ public void GetBoxInfo(string boxNo,string pallNo)
+ {
+ try
+ {
+ var boxInfo = Db.Queryable<DataBoxInfo>().Where(m=>m.IsDel == "0" && m.BoxNo == boxNo).ToList();
+ if (!string.IsNullOrWhiteSpace(pallNo))
+ {
+ boxInfo = boxInfo.Where(m=>m.PalletNo == pallNo).ToList();
+ }
+ if (boxInfo.Count!=1)
+ {
+ throw new Exception("鏍囩淇℃伅閿欒锛岃鑱旂郴绠$悊鍛�");
+ }
+
+ }
+ catch (Exception e)
+ {
+ throw new Exception(e.Message);
+ }
+ }
+
+ public void UpPalletByBox(string boxNo,string pallet,string palletNew,int userId)
+ {
+ try
+ {
+ Db.BeginTran();
+ if (string.IsNullOrWhiteSpace(boxNo) || string.IsNullOrWhiteSpace(pallet) || string.IsNullOrWhiteSpace(palletNew))
+ {
+ throw new Exception("鍙傛暟閿欒锛屾墭鐩樸�佹柊鎵樼洏銆佺鐮佸潎涓嶈兘涓虹┖");
+ }
+ var boxInfoList = Db.Queryable<DataBoxInfo>().Where(m=>m.IsDel == "0" && m.BoxNo == boxNo).ToList();
+ if (boxInfoList.Count != 1)
+ {
+ throw new Exception("鏍囩淇℃伅鏁伴噺涓嶆槸1鏉�");
+ }
+ var boxInfo = boxInfoList.First();
+ var detail1 = Db.Queryable<DataStockDetail>().First(m=>m.IsDel == "0" && m.PalletNo == pallet && m.Id == boxInfo.StockDetailId );
+ if (detail1 == null)
+ {
+ throw new Exception("鏈煡璇㈠埌鎵樼洏鍜岀鐮佺殑搴撳瓨鏄庣粏");
+ }
+ var palletInfoNew = Db.Queryable<SysPallets>().First(m => m.IsDel == "0" && m.PalletNo == palletNew);
+ if (palletInfoNew == null)
+ {
+ throw new Exception("鏈煡璇㈠埌鏂版墭鐩樹俊鎭�");
+ }
+ var detailNewBl = Db.Queryable<DataStockDetail>().First(m => m.IsDel == "0" && m.PalletNo == palletNew && (m.SkuNo != boxInfo.SkuNo || m.LotNo != boxInfo.LotNo));
+ if (detailNewBl!=null)
+ {
+ throw new Exception("鏂版墭鐩樹笂宸叉湁鍏朵粬鐗╂枡绠变俊鎭�");
+ }
+ //娣诲姞/鏇存柊搴撳瓨鎵樼洏淇℃伅
+ var detailNew1 = Db.Queryable<DataStockDetail>().First(m => m.IsDel == "0" && m.PalletNo == palletNew && m.SkuNo == boxInfo.SkuNo && m.LotNo == boxInfo.LotNo);
+ var newId = 0;
+ if (detailNew1 == null)//add
+ {
+ var detailNew = new DataStockDetail();
+ detailNew.SkuNo = detail1.SkuNo;
+ detailNew.SkuName = detail1.SkuName;
+ detailNew.LotNo = detail1.LotNo;
+ detailNew.LotText = detail1.LotText;
+ detailNew.SupplierLot = detail1.SupplierLot;
+ detailNew.SupplierNo = detail1.SupplierNo;
+ detailNew.SupplierName = detail1.SupplierName;
+ detailNew.Standard = detail1.Standard;
+ detailNew.Qty = boxInfo.Qty;
+ detailNew.LockQty = 0;
+ detailNew.FrozenQty = 0;
+ detailNew.InspectQty = 0;
+ detailNew.ASNNo = "";
+
+ detailNew.PalletNo = palletNew;
+ detailNew.ProductionTime = detail1.ProductionTime;
+ detailNew.ExpirationTime = detail1.ExpirationTime;
+ detailNew.PalletTags = "0";
+ detailNew.CompleteTime = DateTime.Now;
+ detailNew.Status = "0";
+ detailNew.InspectMark = detail1.InspectMark;
+ detailNew.BitPalletMark = "1";
+ detailNew.InspectStatus = detail1.InspectStatus;
+ detailNew.PackagNo = detail1.PackagNo;
+ detailNew.IsBale = detail1.IsBale;
+ detailNew.IsBelt = detail1.IsBelt;
+ detailNew.IsDel = "0";
+ detailNew.CreateTime = DateTime.Now;
+ detailNew.CreateUser = 0;
+
+
+ newId = Db.Insertable(detailNew).ExecuteReturnIdentity();
+ }
+ else //update
+ {
+ detailNew1.Qty += boxInfo.Qty;
+ detailNew1.PalletNo = palletNew;
+
+ Db.Updateable(detailNew1).ExecuteCommand();
+ newId = detailNew1.Id;
+ }
+ //鏇存柊鎵樼洏鐘舵��
+ palletInfoNew.Status = "1";
+ Db.Updateable(palletInfoNew).ExecuteCommand();
+
+ //鏇存敼鍘熸墭鐩樹俊鎭�
+ detail1.Qty -= boxInfo.Qty;
+ detail1.BitPalletMark = "1";
+ if (detail1.Qty <= 0)
+ {
+ //鏇存柊鍘熸墭鐩樼姸鎬�
+ var palletInfo = Db.Queryable<SysPallets>().First(m => m.IsDel == "0" && m.PalletNo == pallet);
+ palletInfo.Status = "0";
+ Db.Updateable(palletInfo).ExecuteCommand();
+
+ Db.Deleteable(detail1).ExecuteCommand();
+ }
+ else
+ {
+ Db.Updateable(detail1).ExecuteCommand();
+ }
+
+ //鏇存柊搴撳瓨绠变俊鎭�
+ boxInfo.StockDetailId = newId;
+ boxInfo.BindNo = 0;
+ boxInfo.PalletNo = palletNew;
+ Db.Updateable(boxInfo).ExecuteCommand();
+ //娣诲姞鎿嶄綔鏃ュ織
+ new OperationCrServer().AddLogOperationCr("搴撳唴浣滀笟", "鎿嶄綔鏃ュ織", boxNo, "缂栬緫", $"鐗╂枡鎷嗘墭锛氱鐮侊細{boxNo}鎹㈡墭锛屽師鎵樼洏{pallet}锛屾柊鎵樼洏{palletNew}", userId);
+
+ Db.CommitTran();
+ }
+ catch (Exception e)
+ {
+ Db.RollbackTran();
+ throw new Exception(e.Message);
+ }
+ }
+
+ //鏁伴噺椤电-----------------------------------------------------------------------------------------------------------------------------------------
+
+ /// <summary>
+ /// 鏍规嵁鎵樼洏鑾峰彇鎵樼洏涓婄殑鐗╂枡鎵规淇℃伅
+ /// </summary>
+ /// <param name="palletNo"></param>
+ /// <returns></returns>
+ /// <exception cref="Exception"></exception>
+ public List<SelectSkuLotNo> GetSelectSkuLotNo(string palletNo)
+ {
+ try
+ {
+ var data = new List<SelectSkuLotNo>();
+ var detailList = Db.Queryable<DataStockDetail>().Where(m=>m.IsDel == "0" && m.PalletNo == palletNo).ToList();
+
+ foreach (var item in detailList)
+ {
+ if (data.Count(m=>m.DetailId == item.Id.ToString()) == 0)
+ {
+ data.Add(new SelectSkuLotNo()
+ {
+ SkuNo = item.SkuNo,
+ SkuName = item.SkuName,
+ LotNo = item.LotNo,
+ DetailId = item.Id.ToString(),
+ });
+ }
+ }
+ return data;
+
+ }
+ catch (Exception e)
+ {
+ throw new Exception(e.Message);
+ }
+ }
+
+
+ /// <summary>
+ /// 鎷嗘墭-鏁伴噺
+ /// </summary>
+ /// <param name="palletNo"></param>
+ /// <param name="palletNoNew"></param>
+ /// <param name="detailId"></param>
+ /// <param name="qty"></param>
+ /// <param name="userId"></param>
+ /// <exception cref="Exception"></exception>
+ public void UpPalletByQty(string palletNo,string palletNoNew,string detailId,decimal qty,int userId)
+ {
+ try
+ {
+ Db.BeginTran();
+ if (string.IsNullOrWhiteSpace(detailId) || string.IsNullOrWhiteSpace(palletNo) || string.IsNullOrWhiteSpace(palletNoNew))
+ {
+ throw new Exception("鍙傛暟閿欒锛屾墭鐩樸�佹柊鎵樼洏銆佺墿鏂欐壒娆″潎涓嶈兘涓虹┖");
+ }
+ if (qty<=0)
+ {
+ throw new Exception("鍙傛暟鏁伴噺涓嶈兘涓哄皬绛�0");
+ }
+ var detailId2 = int.Parse(detailId);
+ var detail1 = Db.Queryable<DataStockDetail>().First(m => m.IsDel == "0" && m.PalletNo == palletNo && m.Id == detailId2);
+ if (detail1 == null)
+ {
+ throw new Exception("鏈煡璇㈠埌鎵樼洏搴撳瓨鏄庣粏");
+ }
+ var palletInfoNew = Db.Queryable<SysPallets>().First(m => m.IsDel == "0" && m.PalletNo == palletNoNew);
+ if (palletInfoNew == null)
+ {
+ throw new Exception("鏈煡璇㈠埌鏂版墭鐩樹俊鎭�");
+ }
+
+ //娣诲姞/鏇存柊搴撳瓨鎵樼洏淇℃伅
+ var detailNew1 = Db.Queryable<DataStockDetail>().First(m => m.IsDel == "0" && m.PalletNo == palletNoNew && m.SkuNo == detail1.SkuNo && m.LotNo == detail1.LotNo);
+ var newId = 0;
+ if (detailNew1 == null)//add
+ {
+ var detailNew = new DataStockDetail();
+ detailNew.SkuNo = detail1.SkuNo;
+ detailNew.SkuName = detail1.SkuName;
+ detailNew.LotNo = detail1.LotNo;
+ detailNew.LotText = detail1.LotText;
+ detailNew.SupplierLot = detail1.SupplierLot;
+ detailNew.SupplierNo = detail1.SupplierNo;
+ detailNew.SupplierName = detail1.SupplierName;
+ detailNew.Standard = detail1.Standard;
+ detailNew.Qty = qty;
+ detailNew.LockQty = 0;
+ detailNew.FrozenQty = 0;
+ detailNew.InspectQty = 0;
+ detailNew.ASNNo = "";
+
+ detailNew.PalletNo = palletNoNew;
+ detailNew.ProductionTime = detail1.ProductionTime;
+ detailNew.ExpirationTime = detail1.ExpirationTime;
+ detailNew.PalletTags = "0";
+ detailNew.CompleteTime = DateTime.Now;
+ detailNew.Status = "0";
+ detailNew.InspectMark = detail1.InspectMark;
+ detailNew.BitPalletMark = "1";
+ detailNew.InspectStatus = detail1.InspectStatus;
+ detailNew.PackagNo = detail1.PackagNo;
+ detailNew.IsBale = detail1.IsBale;
+ detailNew.IsBelt = detail1.IsBelt;
+ detailNew.IsDel = "0";
+ detailNew.CreateTime = DateTime.Now;
+ detailNew.CreateUser = 0;
+
+
+ newId = Db.Insertable(detailNew).ExecuteReturnIdentity();
+ }
+ else //update
+ {
+ detailNew1.Qty += qty;
+ detailNew1.PalletNo = palletNoNew;
+
+ Db.Updateable(detailNew1).ExecuteCommand();
+ newId = detailNew1.Id;
+ }
+ //鏇存柊鎵樼洏鐘舵��
+ palletInfoNew.Status = "1";
+ Db.Updateable(palletInfoNew).ExecuteCommand();
+
+ //鏇存敼鍘熸墭鐩樹俊鎭�
+ detail1.Qty -= qty;
+ detail1.BitPalletMark = "1";
+ if (detail1.Qty <= 0)
+ {
+ //鏇存柊鍘熸墭鐩樼姸鎬�
+ var palletInfo = Db.Queryable<SysPallets>().First(m => m.IsDel == "0" && m.PalletNo == palletNo);
+ palletInfo.Status = "0";
+ Db.Updateable(palletInfo).ExecuteCommand();
+
+ Db.Deleteable(detail1).ExecuteCommand();
+ }
+ else
+ {
+ Db.Updateable(detail1).ExecuteCommand();
+ }
+
+
+ //娣诲姞鎿嶄綔鏃ュ織
+ new OperationCrServer().AddLogOperationCr("搴撳唴浣滀笟", "鎿嶄綔鏃ュ織", palletNo, "缂栬緫", $"鐗╂枡鎷嗘墭:{detail1.SkuName}鐗╂枡鎹㈡墭锛屽師鎵樼洏{palletNo}锛屾柊鎵樼洏{palletNoNew}", userId);
+
+ Db.CommitTran();
+ }
+ catch (Exception e)
+ {
+ throw new Exception(e.Message);
+ }
+ }
+
+ #endregion
+
}
}
--
Gitblit v1.8.0