From 009e869b09a63efbc5e58e22f88ad0ed2a315e2b Mon Sep 17 00:00:00 2001
From: yuyou_x <2336760928@qq.com>
Date: 星期日, 04 二月 2024 16:12:16 +0800
Subject: [PATCH] Merge branch 'yyk'
---
Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs | 223 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 217 insertions(+), 6 deletions(-)
diff --git a/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs b/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs
index f691ddc..353c602 100644
--- a/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs
+++ b/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs
@@ -15,6 +15,8 @@
using WMS.Entity.BllSoEntity;
using Model.ModelVm.PdaVm;
using Model.ModelDto.PdaDto;
+using Dm;
+using Model.InterFaceModel;
namespace WMS.BLL.BllPdaServer
{
@@ -157,6 +159,31 @@
sqlString += $"group by BoxNo,SkuNo,SkuName,LotNo; ";
}
var models = Db.Ado.SqlQuery<BoxInfoDto>(sqlString);
+
+ return models;
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ }
+
+ // 鏍规嵁鎵樼洏鍙锋垨绠辩爜鑾峰彇鎵樼洏淇℃伅 liudl
+ public List<PalletBindDto> GetPalletBindInfo(BllPalletBind model)
+ {
+ try
+ {
+ string sqlString = string.Empty;
+ sqlString = "select b.SkuNo,b.SkuName,a.LotNo,a.Qty,a.PalletNo,a.Id from BllPalletBind a left join BllArrivalNoticeDetail b on a.ASNDetailNo = b.Id where a.IsDel = '0' and b.IsDel = '0' ";
+ if (!string.IsNullOrEmpty(model.PalletNo))
+ {
+ sqlString += $"and PalletNo = '{model.PalletNo}' and a.Status = '0' ";
+ }
+ else
+ {
+ throw new Exception("鎵樼洏鍙峰紓甯革紒");
+ }
+ var models = Db.Ado.SqlQuery<PalletBindDto>(sqlString);
return models;
}
@@ -485,6 +512,121 @@
}
}
+ // 鍒犻櫎宸茬粍淇℃伅
+ public string DelPalletBind(BllPalletBind model)
+ {
+ string strMsg = "";
+ string sqlString = string.Empty;
+ try
+ {
+ if (model.Id == 0)
+ {
+ throw new Exception("-1:鎵樼洏ID涓嶅彲涓�0锛�");
+ }
+
+ //鑾峰彇鎵樼洏缁戝畾淇℃伅
+ var bind = Db.Queryable<BllPalletBind>().First(a => a.IsDel == "0" && a.Status == "0" && a.Id == model.Id);
+ //楠岃瘉鎵樼洏缁戝畾淇℃伅鏄惁涓虹┖
+ if (bind == null)
+ {
+ throw new Exception("-1:鏈幏鍙栧埌瀵瑰簲鎵樼洏淇℃伅锛岃鏍稿疄锛�");
+ }
+ //鍒ゆ柇鎵樼洏缁戝畾淇℃伅鏄惁涓嶆槸绛夊緟鎵ц
+ if (bind.Status != "0")
+ {
+ throw new Exception("-1:璇ユ墭鐩樺凡姝e湪鍏ュ簱锛岃鏍稿疄锛�");
+ }
+ //鑾峰彇鏄惁鏈夋寚瀹氬簱浣�
+ SysStorageLocat locat = new SysStorageLocat();
+ int isNullLocat = 0;
+ //鍒ゆ柇鍌ㄤ綅鏄惁涓虹┖
+ if (!string.IsNullOrWhiteSpace(bind.LocatNo))
+ {
+ isNullLocat = 1;
+ locat = Db.Queryable<SysStorageLocat>().First(a=>a.IsDel == "0" && a.WareHouseNo == bind.WareHouseNo && a.RoadwayNo == bind.RoadwayNo && a.LocatNo == bind.LocatNo);
+ //鍒ゆ柇鍌ㄤ綅鍦板潃鏄惁涓烘鍦ㄥ叆搴�
+ if (locat.Status != "2")
+ {
+ throw new Exception("-1:褰撳墠鎵樼洏缁戝畾鐨勫偍浣嶅湴鍧�涓嶆槸姝e湪鍏ュ簱锛岃鏍稿疄锛�");
+ }
+ }
+ //鑾峰彇鎵樼洏淇℃伅
+ var pallet = Db.Queryable<SysPallets>().First(a => a.IsDel == "0" && a.PalletNo == model.PalletNo);
+ //鍒ゆ柇鎵樼洏淇℃伅鏄惁涓虹┖
+ if (pallet == null)
+ {
+ throw new Exception("-1:鏈幏鍙栧埌瀵瑰簲鎵樼洏淇℃伅锛岃鏍稿疄锛�");
+ }
+ //鑾峰彇瀵瑰簲鍏ュ簱鍗曟嵁鎬诲崟
+ var notice = Db.Queryable<BllArrivalNotice>().First(a => a.IsDel == "0" && a.ASNNo == bind.ASNNo);
+ //楠岃瘉鍏ュ簱鍗曟�诲崟淇℃伅
+ if (notice == null)
+ {
+ throw new Exception("-1:鏈幏鍙栧埌瀵瑰簲鍏ュ簱鍗曟�诲崟淇℃伅锛岃鏍稿疄锛�");
+ }
+ //鑾峰彇瀵瑰簲鍏ュ簱鍗曟嵁鏄庣粏
+ var noticeDetail = Db.Queryable<BllArrivalNoticeDetail>().First(a => a.IsDel == "0" && a.Id == bind.ASNDetailNo);
+ //楠岃瘉鍏ュ簱鍗曞崟鎹槑缁�
+ if (noticeDetail == null)
+ {
+ throw new Exception("-1:鏈幏鍙栧埌瀵瑰簲鍏ュ簱鍗曞崟鎹槑缁嗕俊鎭紝璇锋牳瀹烇紒");
+ }
+
+
+ Db.BeginTran();
+ //鍑忓皯鍏ュ簱鍗曟槑缁嗘暟閲� 鍒ゆ柇宸茬粍鏁伴噺鏄惁涓�0 鍐嶅垽鏂畬鎴愭暟閲忔槸鍚︿负0
+ noticeDetail.FactQty -= bind.Qty;
+ //鍒ゆ柇宸茬粍鏁伴噺鏄惁涓�0
+ if (noticeDetail.FactQty == 0)
+ {
+ //鍒ゆ柇鏄惁鏈夊畬鎴愭暟閲�
+ if (noticeDetail.CompleteQty == 0)
+ {
+ noticeDetail.Status = "0"; //鍏ュ簱鍗曟槑缁嗙姸鎬�
+ notice.Status = "0"; //鍏ュ簱鍗曟�诲崟鐘舵��
+ }
+ }
+ Db.Updateable(noticeDetail).ExecuteCommand();
+ Db.Updateable(notice).ExecuteCommand();
+
+
+ // 娓呴櫎鎵樼洏缁戝畾涓婁俊鎭�
+ //ASNNo,ASNDetailNo,Qty,FullQty,LotNo,LotText,SupplierLot,IsDel,UpdateTime,UpdateUser
+ bind.ASNNo = ""; //鍏ュ簱鍗曞彿
+ bind.ASNDetailNo = 0; //鍏ュ簱鍗曟槑缁唅d
+ bind.Qty = 0; //鏁伴噺
+ bind.FullQty = 0; //鏁存墭鏁伴噺
+ bind.LotNo = ""; //鎵规
+ bind.LotText = ""; //鎵规鎻忚堪
+ bind.SupplierLot = ""; //渚涜揣鎵规
+ bind.IsDel = "1"; //鏄惁鍒犻櫎
+ bind.UpdateTime = Db.GetDate(); //淇敼鏃堕棿
+ bind.UpdateUser = model.CreateUser; //淇敼浜�
+ if (isNullLocat == 1)
+ {
+ bind.LocatNo = ""; //鍌ㄤ綅鍦板潃
+ bind.RoadwayNo = ""; //鎵�灞炲贩閬�
+ bind.WareHouseNo = ""; //鎵�灞炰粨搴�
+ //淇敼鍌ㄤ綅淇℃伅鐘舵��
+ locat.Status = "0"; //鍌ㄤ綅鐘舵�� 0锛氱┖鍌ㄤ綅
+ Db.Updateable(locat).ExecuteCommand();
+ }
+ Db.Updateable(bind).ExecuteCommand();
+
+ //淇敼鎵樼洏淇℃伅鐘舵��
+ pallet.Status = "0"; //0锛氭湭浣跨敤
+ Db.Updateable(pallet).ExecuteCommand();
+
+ Db.CommitTran();
+ return strMsg;
+ }
+ catch (Exception ex)
+ {
+ Db.RollbackTran();
+ throw ex;
+ }
+ }
+
// 骞冲簱瀹屾垚鍏ュ簱鎿嶄綔
public string CompleteInStock(PalletBindVm model)
{
@@ -534,7 +676,7 @@
#endregion
#region 鍦扮爜淇℃伅(鍌ㄤ綅淇℃伅)
- var storageLocat = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.LocatNo == model.LocatNo && w.Status == "0");
+ var storageLocat = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.LocatNo == model.LocatNo && w.Status == "0" && w.WareHouseNo == "W02");
if (storageLocat == null)
{
strMsg = "-1:鍌ㄤ綅淇℃伅涓嶅瓨鍦ㄦ垨闈炵┖闂茬姸鎬侊紝璇锋牳鏌�!";
@@ -780,6 +922,8 @@
//淇敼缁勬墭鐘舵��
palletbindInfo.Status = "2"; //2 鍏ュ簱瀹屾垚
+ palletbindInfo.WareHouseNo = "W02";//鎵�灞炰粨搴�
+ palletbindInfo.LocatNo = model.LocatNo;//鍌ㄤ綅鍦板潃
palletbindInfo.UpdateTime = serverTime;
palletbindInfo.UpdateUser = model.CreateUser;
palletbindInfo.CompleteTime = serverTime; //瀹屾垚鏃堕棿
@@ -945,7 +1089,12 @@
#endregion
#endregion
- }
+ }
+ storageLocat.Status = "1";
+ storageLocat.UpdateTime= serverTime; //淇敼鏃堕棿
+ storageLocat.UpdateUser = model.CreateUser; //淇敼浜�
+ //淇敼鍌ㄤ綅鐘舵��
+ Db.Updateable(storageLocat).ExecuteCommand();
new OperationASNServer().AddLogOperationAsn("PDA妯″潡", "骞冲簱鍏ュ簱", model.PalletNo, "瀹屾垚", $"鍦≒DA涓婂畬鎴愬崟鎹彿涓猴細{model.ASNNo}鐨勬墭鐩樼爜涓猴細{model.PalletNo}鐨勫钩搴撳叆搴撴搷浣�", (int)model.CreateUser);
@@ -1518,8 +1667,48 @@
throw ex;
}
}
+ // 鏍规嵁鍗曟嵁鍙疯幏鍙栧崟鎹槑缁嗗垪琛�
+ public List<ArrivalNoticeDetailDto> GetBindArrivalNoticeDetails(ArrivalNoticeVm model)
+ {
+ string sqlString = string.Empty;
+ try
+ {
+ sqlString = $"select * from BllArrivalNoticeDetail where ASNNo = '{model.ASNNo}' and isdel='0' order by CreateTime;";
+ var modelList = Db.Ado.SqlQuery<ArrivalNoticeDetailDto>(sqlString);
+ List<ArrivalNoticeDetailDto> noticeList = new List<ArrivalNoticeDetailDto>();
+ foreach (var item in modelList)
+ {
+ if (string.IsNullOrEmpty(item.LotNo))
+ {
+ noticeList.Add(item);
+ }
+ else
+ {
+ string[] LotNoList = item.LotNo.Split(';');
+ foreach (var item2 in LotNoList)
+ {
+ ArrivalNoticeDetailDto entry = new ArrivalNoticeDetailDto();
+ entry = item;
+ entry.LotNo = item2;
+ noticeList.Add(entry);
+ }
+ }
+ }
+ return noticeList;
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ }
+ /// <summary>
+ /// 缁戝畾鎵樼洏
+ /// </summary>
+ /// <param name="model"></param>
+ /// <param name="userId"></param>
+ /// <param name="origin"></param>
public void BindPallet(PdaPalletBindVm model, int userId, string origin)
{
try
@@ -1537,6 +1726,19 @@
if (string.IsNullOrEmpty(model.PalletNo))
{
throw new Exception("-1:鎵樼洏鍙蜂笉鍙负绌�!");
+ }
+ if (string.IsNullOrEmpty(model.LotNo))
+ {
+ throw new Exception("-1:鐗╂枡鎵规涓嶅彲涓虹┖!");
+ }
+ else
+ {
+ //浠庣墿鏂欏悕绉�-鎵规涓彇鍑烘壒娆�
+ int indexOfDash = model.LotNo.IndexOf("-");
+ if (indexOfDash != -1)
+ {
+ model.LotNo = model.LotNo.Substring(indexOfDash + 1);
+ }
}
//鍒ゆ柇鐗╂枡鏁伴噺鏄惁涓�0 涓�0鍒ゆ柇绠辩爜淇℃伅 涓嶄负0缁х画
if (model.SkuQty == 0)
@@ -1566,7 +1768,7 @@
throw new Exception("鏈煡璇㈠埌鎵樼洏淇℃伅锛岃鏍稿疄锛�");
}
// 楠岃瘉鍏ュ簱鍗曟槑缁嗘槸鍚﹀瓨鍦�
- var detail = Db.Queryable<BllArrivalNoticeDetail>().First(m => m.IsDel == "0" && m.Id == model.AsnDetailId && m.ASNNo == model.AsnNo);
+ var detail = Db.Queryable<BllArrivalNoticeDetail>().First(m => m.IsDel == "0" && m.Id == model.AsnDetailId && m.ASNNo == model.AsnNo && m.LotNo.Contains(model.LotNo));
if (detail == null)
{
throw new Exception("-1:褰撳墠鐗╂枡鍙婃壒娆′笌鍗曟嵁鏃犲叧鑱旓紝璇锋牳瀹�!");
@@ -1642,7 +1844,7 @@
FullQty = pNum,
Status = "0",
Type = "0",
- LotNo = detail.LotNo,
+ LotNo = model.LotNo,
LotText = detail.LotText,
SupplierLot = "",
InspectMark = "0",
@@ -1651,6 +1853,10 @@
IsBelt = "0",
CreateUser = userId
};
+ if (model.SkuQty > pNum)
+ {
+ throw new Exception($"缁戝畾澶辫触锛寋model.PalletNo}鎵樼洏缁戝畾鏁伴噺澶т簬璇ョ墿鍝佹墭鐩樺寘瑁呮暟閲忥紒");
+ }
// 鎻掑叆鎵樼洏缁戝畾琛�
bindId = Db.Insertable(bind).ExecuteReturnIdentity();
}
@@ -1708,7 +1914,7 @@
continue;
}
//绠卞唴鐗╂枡鎵规涓庡崟鎹槑缁嗕笉绗﹀悎
- if (box.SkuNo != detail.SkuNo || box.LotNo != detail.LotNo)
+ if (box.SkuNo != detail.SkuNo || box.LotNo != model.LotNo)
{
throw new Exception($"-1:{box.BoxNo}绠卞唴鐗╂枡鍙婃壒娆′笌鍗曟嵁涓嶄竴鑷达紝璇锋牳瀹�!");
}
@@ -1744,6 +1950,10 @@
{
bind.BitPalletMark = "0";
}
+ if (bind.Qty > pNum)
+ {
+ throw new Exception($"缁戝畾澶辫触锛寋bind.PalletNo}鎵樼洏缁戝畾鏁伴噺澶т簬璇ョ墿鍝佹墭鐩樺寘瑁呮暟閲忥紒");
+ }
Db.Updateable(bind).Where(m => m.Id == bindId).ExecuteCommand();
// 鏇存敼鍏ュ簱鍗曟槑缁嗗凡缁勬暟閲�
@@ -1773,12 +1983,13 @@
//娣诲姞鎵樼洏璁板綍琛ㄦ暟鎹�
sqlStr += $"insert into LogPalletTrack values('{model.PalletNo}','{model.AsnNo}','缁勭洏','0',getDate(),{userId},NULL,NULL);";
Db.Ado.ExecuteCommand(sqlStr);
- new OperationASNServer().AddLogOperationAsn("PDA妯″潡", "浜у搧缁勬墭", model.AsnNo, "娣诲姞", $"娣诲姞浜嗘墭鐩樼爜涓猴細{model.PalletNo}銆亄msgStr}鐨勭粍鐩樹俊鎭�", userId);
+ new OperationASNServer().AddLogOperationAsn("PDA妯″潡", "鎵樼洏缁戝畾", model.AsnNo, "娣诲姞", $"娣诲姞浜嗘墭鐩樼爜涓猴細{model.PalletNo}銆亄msgStr}鐨勭粍鐩樹俊鎭�", userId);
Db.CommitTran();
}
catch (Exception ex)
{
+ Db.RollbackTran();
throw ex;
}
}
--
Gitblit v1.8.0