From b2d25faa69ee7e9f24b6ac98d3b4dcbddada70bc Mon Sep 17 00:00:00 2001
From: yuyou_x <2336760928@qq.com>
Date: 星期四, 14 三月 2024 13:37:15 +0800
Subject: [PATCH] 修改pda托盘绑定同一物料多批次 无法具体选中批次问题。
---
Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs | 1329 ++++++++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 1,072 insertions(+), 257 deletions(-)
diff --git a/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs b/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs
index 38278f0..8d0d9c4 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
{
@@ -29,8 +31,25 @@
try
{
// 鏈叧鍗曠殑鍗曟嵁
- sqlString = $"select * from BllArrivalNotice where Type in ({model.Type}) and Status != '3' and IsDel='0' order by CreateTime;";
+ sqlString = $"select * from BllArrivalNotice where Type in ({model.Type}) and Status != '3' and Status != '4' and IsDel='0' order by CreateTime;";
var modelList = Db.Ado.SqlQuery<ArrivalNoticeDto>(sqlString);
+
+ return modelList;
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ }
+
+ //鏍规嵁鍏ュ簱鍗曞彿鑾峰彇鍏ュ簱鎬诲崟淇℃伅
+ public List<BllArrivalNotice> GetArrivalNotice(ArrivalNoticeVm model)
+ {
+ string sqlString = string.Empty;
+ try
+ {
+ sqlString = $"select * from BllArrivalNotice where ASNNo = '{model.ASNNo}' and isdel='0' ";
+ var modelList = Db.Ado.SqlQuery<BllArrivalNotice>(sqlString);
return modelList;
}
@@ -132,7 +151,7 @@
public List<BoxInfoDto> GetBoxInfos(BoxInfoVm model)
{
try
- {
+ {
string sqlString = string.Empty;
if (model.IsHuiKu == 0)
{
@@ -166,249 +185,27 @@
}
}
- // 缁戝畾鐗╂枡鎵樼洏
- public void BindPallet(PdaPalletBindVm model, int userId,string origin)
+ // 鏍规嵁鎵樼洏鍙锋垨绠辩爜鑾峰彇鎵樼洏淇℃伅 liudl
+ public List<PalletBindDto> GetPalletBindInfo(BllPalletBind model)
{
try
{
- #region 鍒ゆ柇
-
- if (string.IsNullOrEmpty(model.AsnNo))
+ 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))
{
- throw new Exception("-1:鍗曟嵁鍙蜂笉鍙负绌�!");
- }
- if (model.AsnDetailId == null || model.AsnDetailId == 0)
- {
- throw new Exception("-1:鐗╂枡涓嶅彲涓虹┖!");
- }
- if (string.IsNullOrEmpty(model.PalletNo))
- {
- throw new Exception("-1:鎵樼洏鍙蜂笉鍙负绌�!");
- }
- if (string.IsNullOrEmpty(model.BoxNo))
- {
- throw new Exception("-1:绠辩爜淇℃伅涓嶅彲涓虹┖!");
- }
-
- if (model.IsContinue == "1")
- {
- if (string.IsNullOrWhiteSpace(model.TailBoxNo))
- {
- throw new Exception("-1:寮�鍚繛缁粍鎵樻椂锛屽熬绠辩爜淇℃伅涓嶅彲涓虹┖!");
- }
-
- }
- #endregion
-
- Db.BeginTran();
-
- //鎵樼洏鏄惁瀛樺湪
- var pallet = Db.Queryable<SysPallets>().First(m => m.IsDel == "0" && m.PalletNo == model.PalletNo);
- if (pallet == null)
- {
- throw new Exception("鏈煡璇㈠埌鎵樼洏淇℃伅锛岃鏍稿疄锛�");
- }
- // 楠岃瘉鍏ュ簱鍗曟槑缁嗘槸鍚﹀瓨鍦�
- var detail = Db.Queryable<BllArrivalNoticeDetail>().First(m => m.IsDel == "0" && m.Id == model.AsnDetailId && m.ASNNo == model.AsnNo);
- if (detail == null)
- {
- throw new Exception("-1:褰撳墠鐗╂枡鍙婃壒娆′笌鍗曟嵁鏃犲叧鑱旓紝璇锋牳瀹�!");
- }
- #region 鍖呰
- var package = Db.Queryable<SysPackag>().Where(m => m.IsDel == "0");
- var sku = Db.Queryable<SysMaterials>().First(m => m.IsDel == "0" && m.SkuNo == detail.SkuNo);
- var pack = package.First(m => m.IsDel == "0" && m.PackagNo == sku.PackagNo);
- if (pack == null)
- {
- throw new Exception("-1:鑾峰彇鐗╂枡鍖呰澶辫触锛岃鏍稿疄!");
- }
- var pNum = 0;//鎵樼洏鐗╁搧鏁伴噺
- var bNum = 0;//绠辩爜鐗╁搧鏁伴噺
- if (pack.L5Num.HasValue)
- {
- pNum = (int)pack.L5Num;
- bNum = (int)pack.L4Num;
- }
- else if (pack.L4Num.HasValue)
- {
- pNum = (int)pack.L4Num;
- bNum = (int)pack.L3Num;
- }
- else if (pack.L3Num.HasValue)
- {
- pNum = (int)pack.L3Num;
- bNum = (int)pack.L2Num;
- }
- else if (pack.L2Num.HasValue)
- {
- pNum = (int)pack.L2Num;
- bNum = (int)pack.L1Num;
- }
- else if (pack.L1Num.HasValue)
- {
- pNum = (int)pack.L1Num;
- bNum = (int)pack.L1Num;
- }
- if (pNum == 0 || bNum == 0)
- {
- throw new Exception($"缁戝畾澶辫触锛寋detail.SkuNo}鐗╁搧鍖呰鏈壘鍒帮紒");
- }
- #region 楠岃瘉鏄惁鍏佽绔嬪簱鍚屾墭鐩樹笉鍚岀墿鏂欏叆搴撴垨鍚屾墭鐩樺悓鐗╂枡涓嶅悓鎵规鍏ュ簱
- var palletBind = Db.Queryable<BllPalletBind>().First(m => m.IsDel == "0" && m.ASNNo == model.AsnNo && m.PalletNo == model.PalletNo && m.ASNDetailNo != model.AsnDetailId);
- if (palletBind != null)
- {
- var box = Db.Queryable<BllBoxInfo>().First(m => m.IsDel == "0" && m.BindNo == palletBind.Id && m.BitBoxMark == "0");
- if (box != null && (box.SkuNo != detail.SkuNo || box.LotNo != detail.LotNo))
- {
- var funSetting = Db.Queryable<SysFunSetting>().First(a => a.IsDel == "0" && a.FunSetNo == "Fun045");
- if (funSetting == null || funSetting.IsEnable == "OFF")
- {
- throw new Exception($"涓嶅厑璁哥珛搴撳悓鎵樼洏涓嶅悓鐗╂枡鍏ュ簱鎴栧悓鎵樼洏涓嶅悓鎵规鍏ュ簱锛�");
- }
- }
- }
- #endregion
- var bind = Db.Queryable<BllPalletBind>().First(m => m.IsDel == "0" && m.ASNDetailNo == model.AsnDetailId && m.PalletNo == model.PalletNo);
- var bindId = 0;
- if (bind == null)
- {
- bind = new BllPalletBind
- {
- ASNNo = model.AsnNo,
- ASNDetailNo = (int)model.AsnDetailId,
- PalletNo = model.PalletNo,
- PalletNo2 = "",
- PalletNo3 = "",
- Qty = 0,
- FullQty = pNum,
- Status = "0",
- Type = "0",
- LotNo = detail.LotNo,
- LotText = detail.LotText,
- SupplierLot = "",
- InspectMark = "0",
- BitPalletMark = "1",
- IsBale = "0",
- IsBelt = "0",
- CreateUser = userId
- };
- // 鎻掑叆鎵樼洏缁戝畾琛�
- bindId = Db.Insertable(bind).ExecuteReturnIdentity();
+ sqlString += $"and PalletNo = '{model.PalletNo}' and a.Status = '0' ";
}
else
{
- if (bind.Status != "0")
- {
- throw new Exception("-1:褰撳墠鎵樼洏姝e湪鎵ц涓紝缁戝畾澶辫触锛岃鏍稿疄!");
- }
- bindId = bind.Id;
+ throw new Exception("鎵樼洏鍙峰紓甯革紒");
}
+ var models = Db.Ado.SqlQuery<PalletBindDto>(sqlString);
- #region 绠辩爜淇℃伅
-
- var msgStr = $"绠卞彿涓簕model.BoxNo}";
- var boxInfoList = new List<BllBoxInfo>();
- //棣栫
- var boxInfo = Db.Queryable<BllBoxInfo>().Where(m => m.IsDel == "0" && m.BoxNo == model.BoxNo && m.Status == "0").ToList();
- if (boxInfo.Count == 0)
- {
- throw new Exception("-1:绠辩爜淇℃伅涓嶅瓨鍦�!");
- }
- boxInfoList.AddRange(boxInfo);
- //鏄惁杩炵画缁勬墭
- if (model.IsContinue == "1")
- {
- //灏剧
- var boxInfo2 = Db.Queryable<BllBoxInfo>().Where(m => m.IsDel == "0" && m.BoxNo == model.TailBoxNo && m.Status == "0").ToList();
- if (boxInfo2.Count == 0)
- {
- throw new Exception("-1:灏剧鐮佷俊鎭笉瀛樺湪!");
- }
- boxInfoList.AddRange(boxInfo2);
- var sql = $"select * from BllBoxInfo where IsDel = '0' and Status = '0' and boxNo>'{model.BoxNo}' and boxNo<'{model.TailBoxNo}'; ";
- var list = Db.Ado.SqlQuery<BllBoxInfo>(sql);
- boxInfoList.AddRange(list);
- msgStr += $"灏剧鍙蜂负{model.TailBoxNo}";
- }
- #endregion
- #endregion
- // 鏇存敼绠辨敮鍏崇郴琛�
- var factQty = 0;//鎵樼洏鎬绘暟閲�
- var boxGroup = boxInfoList.GroupBy(m => m.BoxNo).ToList();
- foreach (var g in boxGroup)
- {
- var boxFullQty = 0;//绠卞唴鎬绘暟閲�
- foreach (var box in g)
- {
- if (box.BindNo != null && box.BindNo != 0)
- {
- continue;
- }
- //绠卞唴鐗╂枡鎵规涓庡崟鎹槑缁嗕笉绗﹀悎
- if (box.SkuNo != detail.SkuNo || box.LotNo != detail.LotNo)
- {
- throw new Exception($"-1:{box.BoxNo}绠卞唴鐗╂枡鍙婃壒娆′笌鍗曟嵁涓嶄竴鑷达紝璇锋牳瀹�!");
- }
-
- box.ASNNo = model.AsnNo;
- box.ASNDetailNo = model.AsnDetailId;
- box.BindNo = bindId;
- box.PalletNo = model.PalletNo;
- box.Status = "1";
- box.CompleteTime = DateTime.Now;
- box.UpdateTime = DateTime.Now;
- box.UpdateUser = userId;
-
- factQty += box.Qty;
- boxFullQty += box.Qty;
- }
- if (boxFullQty > bNum)
- {
- throw new Exception($"缁戝畾澶辫触锛寋g.Key}绠辩爜缁戝畾鏁伴噺澶т簬璇ョ墿鍝佸寘瑁呮暟閲忥紒");
- }
- }
- Db.Updateable(boxInfoList).ExecuteCommand();
-
- // 鏇存柊鎵樼洏缁戝畾琛�
- bind.Qty += factQty;
- if (bind.FullQty < bind.Qty)
- {
- throw new Exception("鎵樼洏缁戝畾鏁伴噺宸茶秴鍑鸿鐗╂枡鍖呰鏁伴噺");
- }
-
- if (bind.FullQty == bind.Qty)
- {
- bind.BitPalletMark = "0";
- }
- Db.Updateable(bind).Where(m => m.Id == bindId).ExecuteCommand();
-
- // 鏇存敼鍏ュ簱鍗曟槑缁嗗凡缁勬暟閲�
- var sqlString = string.Empty;
- sqlString += $"update BllArrivalNoticeDetail set FactQty = FactQty + '{factQty}' where id = '{model.AsnDetailId}';";
- Db.Ado.ExecuteCommand(sqlString);
-
- // 鏇存敼鍏ュ簱鍗曞強鍏ュ簱鏄庣粏鐘舵��
- if (detail.Status == "0")
- {
- var sqlString2 = string.Empty;
- sqlString2 += $"update BllArrivalNotice set Status = '1',CompleteTime= getDate() where ASNNo = '{model.AsnNo}' and Status ='0';";
- sqlString2 += $"update BllArrivalNoticeDetail set Status = '1',CompleteTime= getDate() where id = '{model.AsnDetailId}' and Status ='0';";
- Db.Ado.ExecuteCommand(sqlString2);
- }
-
- // 鏇存敼鎵樼洏浣跨敤鐘舵��
- var sqlStr = $"update SysPallets set Status = '1' where PalletNo = '{model.PalletNo}';";
- //娣诲姞鎵樼洏璁板綍琛ㄦ暟鎹�
- 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);
-
- Db.CommitTran();
-
+ return models;
}
catch (Exception ex)
{
- Db.Ado.RollbackTran();
throw ex;
}
}
@@ -732,12 +529,124 @@
}
}
+ // 鍒犻櫎宸茬粍淇℃伅
+ 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)
{
- //string sttr = "select * from BllArrivalNoticeDetail where id in (select ASNDetailNo from BllBoxInfo where ASNNo = 'ASN2023042400002' and PalletNo = 'T2300004' and Status = '1');";
- //var noticeDetaila = Db.Ado.SqlQuery<BllArrivalNoticeDetail>(sttr);
-
string strMsg = "";
string sqlString = string.Empty;
try
@@ -767,7 +676,7 @@
#region 鏄惁鍥炴祦鍏ュ簱
int iscount = 0;
//搴撳瓨鏄庣粏淇℃伅
- var stockDetail = Db.Queryable<DataStockDetail>().Where(a => a.IsDel == "0" && a.PalletNo == model.PalletNo).ToList();
+ var stockDetail = Db.Queryable<DataStockDetail>().Where(a => a.IsDel == "0" && a.PalletNo == model.PalletNo).ToList();
//楠岃瘉搴撳瓨鏄惁鎷ユ湁璇ユ墭淇℃伅
if (stockDetail != null && stockDetail.Count > 0)
{
@@ -780,6 +689,15 @@
}
}
iscount = 1; //鍥炴祦鍏ュ簱
+ }
+ #endregion
+
+ #region 鍦扮爜淇℃伅(鍌ㄤ綅淇℃伅)
+ 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:鍌ㄤ綅淇℃伅涓嶅瓨鍦ㄦ垨闈炵┖闂茬姸鎬侊紝璇锋牳鏌�!";
+ return strMsg;
}
#endregion
@@ -849,17 +767,6 @@
}
#endregion
- #region 浠诲姟
- //var task = Db.Queryable<LogTask>().First(t => t.IsDel == "0" && t.TaskNo == palletbind.TaskNo && t.Status == "0" || t.Status == "1");
- ////楠岃瘉浠诲姟淇℃伅鏄惁瀛樺湪
- //if (task == null)
- //{
- // strMsg = "-1:浠诲姟淇℃伅涓嶅瓨鍦紝璇锋牳鏌�!";
- // return strMsg;
- //}
-
- #endregion
-
#endregion
Db.BeginTran();//寮�鍚簨鍔�
@@ -887,7 +794,7 @@
strMsg = "-1:绠辩爜淇℃伅涓嶅瓨鍦紝璇锋牳鏌�!";
return strMsg;
}
- else
+ else
{
// 鏀瑰彉绠辨敮鍏崇郴琛ㄧ姸鎬侊細宸插叆搴�
sqlString = $"Update BllBoxInfo set Status = '2' where PalletNo = '{model.PalletNo}' and ASNNo = '{model.ASNNo}' and Status = '1'";
@@ -896,7 +803,7 @@
pallQty = boxinfo2.Sum(w => w.Qty);
//鍏ュ簱鍗曟槑缁嗗畬鎴愭暟閲忓鍔�
noticeItem.CompleteQty += pallQty;
- }
+ }
//鍒ゆ柇鍏ュ簱鏁伴噺澧炲姞鍚庢槸鍚﹀ぇ浜庣瓑浜庡崟鎹暟閲�
if (noticeItem.CompleteQty >= noticeItem.Qty)
{
@@ -955,7 +862,7 @@
sqlString = "select sum(qty) from BllBoxInfo where isdel = 0 and ";
sqlString += $"BindNo = '{palletbindInfo.Id}'";
int inspectQty = Db.Ado.GetInt(sqlString);
-
+
// 娣诲姞搴撳瓨鏄庣粏琛�
detailModel = new DataStockDetail()
{
@@ -1032,6 +939,8 @@
//淇敼缁勬墭鐘舵��
palletbindInfo.Status = "2"; //2 鍏ュ簱瀹屾垚
+ palletbindInfo.WareHouseNo = "W02";//鎵�灞炰粨搴�
+ palletbindInfo.LocatNo = model.LocatNo;//鍌ㄤ綅鍦板潃
palletbindInfo.UpdateTime = serverTime;
palletbindInfo.UpdateUser = model.CreateUser;
palletbindInfo.CompleteTime = serverTime; //瀹屾垚鏃堕棿
@@ -1198,6 +1107,11 @@
#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);
@@ -1361,7 +1275,7 @@
try
{
//鍏ュ簱涓�
- var aSNNoList= Db.Ado.SqlQuery<string>($"SELECT DISTINCT ASNNo from BllPalletBind where IsDel=0 and Status=0 and PalletNo='{palletNo}' ").ToList();
+ var aSNNoList = Db.Ado.SqlQuery<string>($"SELECT DISTINCT ASNNo from BllPalletBind where IsDel=0 and Status=0 and PalletNo='{palletNo}' ").ToList();
if (aSNNoList.Count <= 0)
{
//搴撳鎵樼洏鎴栧钩搴撴墭鐩�
@@ -1377,6 +1291,30 @@
throw new Exception("鍚屼竴涓墭鐩樺彿瀛樺湪澶氫釜鍏ュ簱鍗�,璇锋鏌�!");
}
return aSNNoList[0];
+ }
+ catch (Exception ex)
+ {
+ throw new Exception(ex.Message);
+ }
+ }
+
+ /// <summary>
+ /// 楠岃瘉鍌ㄤ綅鍦板潃(鍦扮爜)鏄惁鍙敤
+ /// </summary>
+ /// <param name="locatNo">鍌ㄤ綅缂栫爜</param>
+ /// <returns></returns>
+ public string CheckLocatNo(string locatNo)
+ {
+ try
+ {
+ string strMsg = "";
+ var storageLocat = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.LocatNo == locatNo && w.Status == "0" && w.WareHouseNo == "W02");
+ if (storageLocat == null)
+ {
+ throw new Exception("-1:鍦扮爜(鍌ㄤ綅淇℃伅)涓嶅瓨鍦ㄦ垨闈炵┖闂茬姸鎬侊紝璇锋牳鏌�!");
+ }
+
+ return strMsg;
}
catch (Exception ex)
{
@@ -1418,7 +1356,7 @@
//鎷兼墭鍏ュ簱
public void CompleteInStockLing(PdaLingAsnVm model, int userId)
{
- try
+ try
{
if (string.IsNullOrWhiteSpace(model.AsnNo))
{
@@ -1455,10 +1393,10 @@
foreach (var item in boxinfo)
{
if (!string.IsNullOrEmpty(item.PalletNo))
- {
+ {
throw new Exception("-1:璇ョ鐮佸凡缁戝畾鍏朵粬鎵樼洏锛岃鍏堣В缁戞墭鐩�!");
}
- bNum += item.Qty;
+ bNum += item.Qty;
}
if (bNum == boxinfo[0].FullQty)
{
@@ -1519,7 +1457,7 @@
//淇敼鍏ュ簱鍗曟�诲崟淇℃伅
arrival.Status = "2";
arrival.CompleteTime = serverTime;
- arrival.UpdateUser =userId;
+ arrival.UpdateUser = userId;
arrival.UpdateTime = serverTime;
Db.Updateable(arrival).ExecuteCommand();
}
@@ -1625,7 +1563,7 @@
#region 搴撳瓨鏄庣粏琛�
var boxinfoItem = boxinfo.First();
- var detailModel = Db.Queryable<DataStockDetail>() .First(it => it.PalletNo == model.PalletNo && it.LotNo == arrivalnotice.LotNo
+ var detailModel = Db.Queryable<DataStockDetail>().First(it => it.PalletNo == model.PalletNo && it.LotNo == arrivalnotice.LotNo
&& it.SkuNo == arrivalnotice.SkuNo && it.Standard == arrivalnotice.Standard && it.IsDel == "0");
var stId = 0;
if (detailModel == null || detailModel.Id == 0)
@@ -1731,5 +1669,882 @@
throw ex;
}
}
+
+ #region 浜у搧缁勬墭
+ /// <summary>
+ /// 鏍规嵁绠辩爜鑾峰彇鏍囩绠辩爜淇℃伅
+ /// </summary>
+ /// <param name="model"></param>
+ /// <returns></returns>
+ public List<BoxInfoDto> GetBindBoxInfos(BoxInfoVm model)
+ {
+ try
+ {
+ if (string.IsNullOrEmpty(model.BoxNo))
+ {
+ throw new Exception("璇锋壂鎻忓绠辨潯鐮�!");
+ }
+ string sqlString = $@"SELECT
+ ASNNo,
+ BoxNo,
+ SkuNo,
+ SkuName,
+ LotNo,
+ SUM(Qty) as Qty
+ FROM BllBoxInfo
+ WHERE IsDel = '0'
+ AND Status='0'
+ AND BoxNo = '{model.BoxNo}'
+ GROUP BY ASNNo,BoxNo,SkuNo,SkuName,LotNo; ";
+ var models = Db.Ado.SqlQuery<BoxInfoDto>(sqlString);
+ if (models == null)
+ {
+ throw new Exception("绠辩爜淇℃伅涓嶅瓨鍦�!");
+ }
+ return models;
+ }
+ catch (Exception ex)
+ {
+ 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()
+ {
+ Id = item.Id,
+ ASNNo = item.ASNNo,
+ CompleteQty = item.CompleteQty,
+ CompleteTime = item.CompleteTime,
+ CreateTime = item.CreateTime,
+ Qty = item.Qty,
+ FactQty = item.FactQty,
+ LotNo = item2,
+ Money = item.Money,
+ PackagNo = item.PackagNo,
+ PackagName = item.PackagName,
+ Status = item.Status,
+ SkuNo = item.SkuNo,
+ SkuName = item.SkuName,
+ };
+
+
+ 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
+ {
+ #region 鍒ゆ柇
+
+ //0锛氭垚鍝佸叆搴� 1锛氶噰璐叆搴� 2锛氫腑闂村搧鍏ュ簱 3锛氶��璐у叆搴� 4锛氳溅闂翠綑鏂欏叆搴� 5锛氬叾瀹冨叆搴� 6锛氫唬鍌ㄥ叆搴� 7锛氬瘎瀛樺叆搴�
+ var TypeLot = "1, 2, 5, 6, 7";
+
+ if (string.IsNullOrEmpty(model.AsnNo))
+ {
+ throw new Exception("-1:鍗曟嵁鍙蜂笉鍙负绌�!");
+ }
+ if (model.AsnDetailId == null || model.AsnDetailId == 0)
+ {
+ throw new Exception("-1:鐗╂枡涓嶅彲涓虹┖!");
+ }
+ if (string.IsNullOrEmpty(model.PalletNo))
+ {
+ throw new Exception("-1:鎵樼洏鍙蜂笉鍙负绌�!");
+ }
+ //鏍规嵁鍗曟嵁鍙疯幏鍙栧叆搴撳崟鎬诲崟
+ var notice = Db.Queryable<BllArrivalNotice>().First(a => a.IsDel == "0" && a.ASNNo == model.AsnNo);
+ if (notice.Status != "0" && notice.Status != "1")
+ {
+ throw new Exception("-1:鍏ュ簱鍗曠姸鎬佷笉鏄瓑寰呮墽琛屾垨鎵ц瀹屾垚!");
+ }
+ if (string.IsNullOrEmpty(model.LotNo))
+ {
+ //鍒ゆ柇鏄惁涓轰笉闄愬埗鎵规鍗曟嵁
+ if (!TypeLot.Contains(notice.Type))
+ {
+ throw new Exception("-1:鐗╂枡鎵规涓嶅彲涓虹┖!");
+ }
+
+ }
+ else
+ {
+ //浠庣墿鏂欏悕绉�-鎵规涓彇鍑烘壒娆�
+ int indexOfDash = model.LotNo.IndexOf("-");
+ if (indexOfDash != -1)
+ {
+ model.LotNo = model.LotNo.Substring(indexOfDash + 1);
+ }
+ else
+ {
+ model.LotNo = "";
+ }
+ }
+ //鍒ゆ柇鐗╂枡鏁伴噺鏄惁涓�0 涓�0鍒ゆ柇绠辩爜淇℃伅 涓嶄负0缁х画
+ if (model.SkuQty == 0)
+ {
+ if (string.IsNullOrEmpty(model.BoxNo))
+ {
+ throw new Exception("-1:绠辩爜淇℃伅涓嶅彲涓虹┖!");
+ }
+
+ if (model.IsContinue == "1")
+ {
+ if (string.IsNullOrWhiteSpace(model.TailBoxNo))
+ {
+ throw new Exception("-1:寮�鍚繛缁粍鎵樻椂锛屽熬绠辩爜淇℃伅涓嶅彲涓虹┖!");
+ }
+
+ }
+ }
+ int isDeposit = 0;
+ //鍒ゆ柇鎬诲崟鍗曟嵁鏄惁涓哄瘎瀛樺崟鎹�
+ if (notice.Type == "7")
+ {
+ isDeposit = 1;
+ }
+ if (isDeposit == 1)
+ {
+ //鍒ゆ柇鎬诲崟澶囨敞鏄惁涓虹┖
+ if (!string.IsNullOrWhiteSpace(notice.Demo))
+ {
+ //鍒嗗壊鎬诲崟澶囨敞鍙婃墭鐩樺娉�
+ var noticeDemo = notice.Demo.Split('銆�'); //鎬诲崟澶囨敞
+ var palletDemo = model.Demo.Split('銆�'); //鎵樼洏澶囨敞
+
+ //寰幆鎵樼洏澶囨敞
+ foreach (var itemPallet in palletDemo)
+ {
+ int isDemo = 0;
+ //寰幆鎬诲崟澶囨敞
+ foreach (var itemNotice in noticeDemo)
+ {
+ //鍒ゆ柇鏄惁鏈夌浉鍚屽娉�
+ if (itemPallet == itemNotice)
+ {
+ isDemo = 1;
+ break;
+ }
+ }
+ if (isDemo == 0)
+ {
+ throw new Exception("-1:鎬诲崟澶囨敞涓庢墭鐩樺娉ㄤ笉绗︼紝璇锋牳瀹炲悗閲嶆柊缁戝畾!");
+ }
+ }
+ }
+ else if (string.IsNullOrWhiteSpace(notice.Demo))
+ {
+ //鍒ゆ柇鎵樼洏澶囨敞鏄惁涓虹┖
+ if (!string.IsNullOrWhiteSpace(model.Demo))
+ {
+ throw new Exception("-1:璇锋坊鍔犳�诲崟澶囨敞鍚庤緭鍏ユ墭鐩樺娉�!");
+ }
+ }
+ }
+
+
+ #endregion
+
+ Db.BeginTran();
+
+ //鎵樼洏鏄惁瀛樺湪
+ var pallet = Db.Queryable<SysPallets>().First(m => m.IsDel == "0" && m.PalletNo == model.PalletNo);
+ if (pallet == null)
+ {
+ throw new Exception("鏈煡璇㈠埌鎵樼洏淇℃伅锛岃鏍稿疄锛�");
+ }
+ //鍒ゆ柇鎵樼洏鏄惁鍦ㄥ簱澶�
+ var stockDetail = Db.Queryable<DataStockDetail>().First(m => m.IsDel == "0" && m.PalletNo == model.PalletNo);
+ if (stockDetail != null && !string.IsNullOrEmpty(stockDetail.WareHouseNo))
+ {
+ throw new Exception("璇ユ墭鐩樻湭鍦ㄥ簱澶栵紝璇锋牳瀹烇紒");
+ }
+ // 楠岃瘉鍏ュ簱鍗曟槑缁嗘槸鍚﹀瓨鍦�
+ 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:褰撳墠鐗╂枡鍙婃壒娆′笌鍗曟嵁鏃犲叧鑱旓紝璇锋牳瀹�!");
+ }
+ #region 鍖呰
+ var package = Db.Queryable<SysPackag>().Where(m => m.IsDel == "0");
+ var sku = Db.Queryable<SysMaterials>().First(m => m.IsDel == "0" && m.SkuNo == detail.SkuNo);
+ var pack = package.First(m => m.IsDel == "0" && m.PackagNo == sku.PackagNo);
+
+ var pNum = 0;//鎵樼洏鐗╁搧鏁伴噺
+ var bNum = 0;//绠辩爜鐗╁搧鏁伴噺
+
+ //鍒ゆ柇鏄惁涓哄瘎瀛樼墿鏂�
+ if (isDeposit == 0)
+ {
+ if (pack == null)
+ {
+ throw new Exception("-1:鑾峰彇鐗╂枡鍖呰澶辫触锛岃鏍稿疄!");
+ }
+ if (pack.L5Num.HasValue)
+ {
+ pNum = (int)pack.L5Num;
+ bNum = (int)pack.L4Num;
+ }
+ else if (pack.L4Num.HasValue)
+ {
+ pNum = (int)pack.L4Num;
+ bNum = (int)pack.L3Num;
+ }
+ else if (pack.L3Num.HasValue)
+ {
+ pNum = (int)pack.L3Num;
+ bNum = (int)pack.L2Num;
+ }
+ else if (pack.L2Num.HasValue)
+ {
+ pNum = (int)pack.L2Num;
+ bNum = (int)pack.L1Num;
+ }
+ else if (pack.L1Num.HasValue)
+ {
+ pNum = (int)pack.L1Num;
+ bNum = (int)pack.L1Num;
+ }
+ if (pNum == 0 || bNum == 0)
+ {
+ throw new Exception($"缁戝畾澶辫触锛寋detail.SkuNo}鐗╁搧鍖呰鏈壘鍒帮紒");
+ }
+ }
+ #endregion
+
+ #region 楠岃瘉鏄惁鍏佽绔嬪簱鍚屾墭鐩樹笉鍚岀墿鏂欏叆搴撴垨鍚屾墭鐩樺悓鐗╂枡涓嶅悓鎵规鍏ュ簱
+ var palletBind = Db.Queryable<BllPalletBind>().First(m => m.IsDel == "0" && m.ASNNo == model.AsnNo && m.PalletNo == model.PalletNo && m.ASNDetailNo != model.AsnDetailId);
+ if (palletBind != null)
+ {
+ var box = Db.Queryable<BllBoxInfo>().First(m => m.IsDel == "0" && m.BindNo == palletBind.Id && m.BitBoxMark == "0");
+ if (box != null && (box.SkuNo != detail.SkuNo || box.LotNo != detail.LotNo))
+ {
+ var funSetting = Db.Queryable<SysFunSetting>().First(a => a.IsDel == "0" && a.FunSetNo == "Fun045");
+ if (funSetting == null || funSetting.IsEnable == "OFF")
+ {
+ throw new Exception($"涓嶅厑璁哥珛搴撳悓鎵樼洏涓嶅悓鐗╂枡鍏ュ簱鎴栧悓鎵樼洏涓嶅悓鎵规鍏ュ簱锛�");
+ }
+ }
+ }
+ #endregion
+ var bind = Db.Queryable<BllPalletBind>().First(m => m.IsDel == "0" && m.ASNDetailNo == model.AsnDetailId && m.PalletNo == model.PalletNo && m.Status != "2");
+ var bindId = 0;
+ if (bind == null)
+ {
+ bind = new BllPalletBind
+ {
+ ASNNo = model.AsnNo,
+ ASNDetailNo = (int)model.AsnDetailId,
+ PalletNo = model.PalletNo,
+ PalletNo2 = "",
+ PalletNo3 = "",
+ Qty = model.SkuQty,
+ FullQty = pNum,
+ Status = "0",
+ Type = "0",
+ LotNo = model.LotNo,
+ LotText = detail.LotText,
+ SupplierLot = detail.SupplierLot,
+ InspectMark = "0",
+ BitPalletMark = "1",
+ IsBale = "0",
+ IsBelt = "0",
+ CreateUser = userId,
+ Demo = model.Demo,
+
+ };
+ if (model.SkuQty > pNum && isDeposit == 0)
+ {
+ throw new Exception($"缁戝畾澶辫触锛寋model.PalletNo}鎵樼洏缁戝畾鏁伴噺澶т簬璇ョ墿鍝佹墭鐩樺寘瑁呮暟閲忥紒");
+ }
+ // 鎻掑叆鎵樼洏缁戝畾琛�
+ bindId = Db.Insertable(bind).ExecuteReturnIdentity();
+ }
+ else
+ {
+ if (bind.Status != "0")
+ {
+ throw new Exception("-1:褰撳墠鎵樼洏姝e湪鎵ц涓紝缁戝畾澶辫触锛岃鏍稿疄!");
+ }
+ bindId = bind.Id;
+ bind.Qty += model.SkuQty;
+ }
+
+ #region 绠辩爜淇℃伅
+ var msgStr = $"绠卞彿涓簕model.BoxNo}";
+ var boxInfoList = new List<BllBoxInfo>();
+ if (model.SkuQty == 0)
+ {
+ //棣栫
+ var boxInfo = Db.Queryable<BllBoxInfo>().Where(m => m.IsDel == "0" && m.BoxNo == model.BoxNo && m.Status == "0").ToList();
+ if (boxInfo.Count == 0)
+ {
+ throw new Exception("-1:绠辩爜淇℃伅涓嶅瓨鍦�!");
+ }
+ boxInfoList.AddRange(boxInfo);
+ //鏄惁杩炵画缁勬墭
+ if (model.IsContinue == "1")
+ {
+ //灏剧
+ var boxInfo2 = Db.Queryable<BllBoxInfo>().Where(m => m.IsDel == "0" && m.BoxNo == model.TailBoxNo && m.Status == "0").ToList();
+ if (boxInfo2.Count == 0)
+ {
+ throw new Exception("-1:灏剧鐮佷俊鎭笉瀛樺湪!");
+ }
+ boxInfoList.AddRange(boxInfo2);
+ var sql = $"select * from BllBoxInfo where IsDel = '0' and Status = '0' and boxNo>'{model.BoxNo}' and boxNo<'{model.TailBoxNo}'; ";
+ var list = Db.Ado.SqlQuery<BllBoxInfo>(sql);
+ boxInfoList.AddRange(list);
+ msgStr += $"灏剧鍙蜂负{model.TailBoxNo}";
+ }
+ }
+ #endregion
+
+ // 鏇存敼绠辨敮鍏崇郴琛�
+ decimal factQty = 0.00m;//鎵樼洏鎬绘暟閲�
+ //鎴愬搧缁勬墭
+ if (model.SkuQty == 0)
+ {
+ var boxGroup = boxInfoList.GroupBy(m => m.BoxNo).ToList();
+ foreach (var g in boxGroup)
+ {
+ var boxFullQty = 0;//绠卞唴鎬绘暟閲�
+ foreach (var box in g)
+ {
+ if (box.BindNo != null && box.BindNo != 0)
+ {
+ continue;
+ }
+ //绠卞唴鐗╂枡鎵规涓庡崟鎹槑缁嗕笉绗﹀悎
+ if (box.SkuNo != detail.SkuNo || box.LotNo != model.LotNo)
+ {
+ throw new Exception($"-1:{box.BoxNo}绠卞唴鐗╂枡鍙婃壒娆′笌鍗曟嵁涓嶄竴鑷达紝璇锋牳瀹�!");
+ }
+
+ box.ASNNo = model.AsnNo;
+ box.ASNDetailNo = model.AsnDetailId;
+ box.BindNo = bindId;
+ box.PalletNo = model.PalletNo;
+ box.Status = "1";
+ box.CompleteTime = DateTime.Now;
+ box.UpdateTime = DateTime.Now;
+ box.UpdateUser = userId;
+
+ factQty += box.Qty;
+ boxFullQty += box.Qty;
+ }
+ if (boxFullQty > bNum)
+ {
+ throw new Exception($"缁戝畾澶辫触锛寋g.Key}绠辩爜缁戝畾鏁伴噺澶т簬璇ョ墿鍝佸寘瑁呮暟閲忥紒");
+ }
+ }
+ Db.Updateable(boxInfoList).ExecuteCommand();
+
+ // 鏇存柊鎵樼洏缁戝畾琛�
+ bind.Qty += factQty;
+ }
+ if (bind.FullQty < bind.Qty && isDeposit == 0)
+ {
+ throw new Exception("鎵樼洏缁戝畾鏁伴噺宸茶秴鍑鸿鐗╂枡鍖呰鏁伴噺");
+ }
+
+ if (bind.FullQty == bind.Qty)
+ {
+ bind.BitPalletMark = "0";
+ }
+ if (bind.Qty > pNum && isDeposit == 0)
+ {
+ throw new Exception($"缁戝畾澶辫触锛寋bind.PalletNo}鎵樼洏缁戝畾鏁伴噺澶т簬璇ョ墿鍝佹墭鐩樺寘瑁呮暟閲忥紒");
+ }
+ Db.Updateable(bind).Where(m => m.Id == bindId).ExecuteCommand();
+
+ // 鏇存敼鍏ュ簱鍗曟槑缁嗗凡缁勬暟閲�
+ var sqlString = string.Empty;
+ if (factQty == 0)
+ {
+ sqlString += $"update BllArrivalNoticeDetail set FactQty = FactQty + '{model.SkuQty}' where id = '{model.AsnDetailId}';";
+ }
+ else
+ {
+ sqlString += $"update BllArrivalNoticeDetail set FactQty = FactQty + '{factQty}' where id = '{model.AsnDetailId}';";
+ }
+
+ Db.Ado.ExecuteCommand(sqlString);
+
+ // 鏇存敼鍏ュ簱鍗曞強鍏ュ簱鏄庣粏鐘舵��
+ if (detail.Status == "0")
+ {
+ var sqlString2 = string.Empty;
+ sqlString2 += $"update BllArrivalNotice set Status = '1',UpdateTime= getDate(),UpdateUser = {userId} where ASNNo = '{model.AsnNo}' and Status ='0';";
+ sqlString2 += $"update BllArrivalNoticeDetail set Status = '1',UpdateTime= getDate(),UpdateUser = {userId} where id = '{model.AsnDetailId}' and Status ='0';";
+ Db.Ado.ExecuteCommand(sqlString2);
+ }
+ else if (detail.Status == "1")
+ {
+ var sqlString2 = string.Empty;
+ sqlString2 += $"update BllArrivalNotice set UpdateTime= getDate(),UpdateUser = {userId} where ASNNo = '{model.AsnNo}' and Status ='1';";
+ sqlString2 += $"update BllArrivalNoticeDetail set UpdateTime= getDate(),UpdateUser = {userId} where id = '{model.AsnDetailId}' and Status ='1';";
+ Db.Ado.ExecuteCommand(sqlString2);
+ }
+
+ // 鏇存敼鎵樼洏浣跨敤鐘舵��
+ var sqlStr = $"update SysPallets set Status = '1' where PalletNo = '{model.PalletNo}';";
+ //娣诲姞鎵樼洏璁板綍琛ㄦ暟鎹�
+ 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);
+
+ Db.CommitTran();
+ }
+ catch (Exception ex)
+ {
+ Db.RollbackTran();
+ throw ex;
+ }
+ }
+ #endregion
+
+ #region 骞冲簱鍏ュ簱
+ /// <summary>
+ /// 骞冲簱纭鍏ュ簱
+ /// </summary>
+ /// <param name="model"></param>
+ public void ConfirmInStock(PalletBindVm model)
+ {
+ try
+ {
+ #region 楠岃瘉淇℃伅
+ if (string.IsNullOrEmpty(model.ASNNo))
+ {
+ throw new Exception("鍏ュ簱鍗曚笉鑳戒负绌�!");
+ }
+ if (string.IsNullOrEmpty(model.PalletNo))
+ {
+ throw new Exception("鎵樼洏鏉$爜涓嶈兘涓虹┖!");
+ }
+ if (string.IsNullOrEmpty(model.LocatNo))
+ {
+ throw new Exception("鍌ㄤ綅鍦板潃涓嶈兘涓虹┖!");
+ }
+ #endregion
+ //鑾峰彇褰撳墠鏃堕棿
+ DateTime serverTime = Db.Ado.GetDateTime("select GETDATE();");
+
+ #region 鏄惁鍥炴祦鍏ュ簱
+ int iscount = 0;
+ //搴撳瓨鏄庣粏淇℃伅
+ var stockDetail = Db.Queryable<DataStockDetail>().Where(a => a.IsDel == "0" && a.PalletNo == model.PalletNo).ToList();
+ //楠岃瘉搴撳瓨鏄惁鎷ユ湁璇ユ墭淇℃伅
+ if (stockDetail != null && stockDetail.Count > 0)
+ {
+ foreach (var item in stockDetail)
+ {
+ if (!string.IsNullOrEmpty(item.WareHouseNo))
+ {
+ throw new Exception("璇ユ墭鐩樻湭鍦ㄥ簱澶栵紝璇锋牳鏌�!");
+ }
+ }
+ iscount = 1; //鍥炴祦鍏ュ簱
+ }
+ #endregion
+
+ #region 鎵樼洏缁戝畾淇℃伅
+ var bindInfo = Db.Queryable<BllPalletBind>().First(w => w.IsDel == "0" && w.ASNNo == model.ASNNo && w.PalletNo == model.PalletNo && w.Status != "2");
+ if (iscount == 0)
+ {
+ if (bindInfo == null)
+ {
+ throw new Exception("鎵樼洏缁戝畾淇℃伅涓嶅瓨鍦紝璇锋牳鏌�!");
+ }
+ if (!string.IsNullOrEmpty(bindInfo.WareHouseNo))
+ {
+ throw new Exception("璇ユ墭鐩樻湭鍦ㄥ簱澶栵紝璇锋牳鏌�!");
+ }
+ }
+
+ #endregion
+
+ #region 鍦扮爜淇℃伅(鍌ㄤ綅淇℃伅)
+ var storageLocat = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.LocatNo == model.LocatNo && w.Status == "0" && w.WareHouseNo == "W02");
+ if (storageLocat == null)
+ {
+ throw new Exception("鍌ㄤ綅淇℃伅涓嶅瓨鍦ㄦ垨闈炵┖闂茬姸鎬侊紝璇锋牳鏌�!");
+ }
+ #endregion
+
+ Db.BeginTran();//寮�鍚簨鍔�
+ if (iscount == 0)//姝e父鍏ュ簱
+ {
+ #region 鍏ュ簱鎬诲崟淇℃伅
+ var notice = Db.Queryable<BllArrivalNotice>().First(a => a.IsDel == "0" && a.Status != "3" && a.ASNNo == model.ASNNo);
+ //楠岃瘉鍏ュ簱鍗曟�诲崟鏄惁鍏抽棴
+ if (notice == null)
+ {
+ throw new Exception("鍏ュ簱鍗曟�诲崟淇℃伅涓嶅瓨鍦紝璇锋牳鏌�!");
+ }
+ //鍒ゆ柇鍏ュ簱鍗曟�诲崟鏄惁涓哄凡鍏抽棴
+ if (notice.Status == "3")
+ {
+ throw new Exception("鍏ュ簱鍗曟�诲崟宸插叧闂紝璇锋牳鏌�!");
+ }
+ #endregion
+
+ #region 绠辩爜淇℃伅
+ var boxInfoList = Db.Queryable<BllBoxInfo>().Where(w => w.IsDel == "0" && w.ASNNo == model.ASNNo && w.PalletNo == model.PalletNo).ToList();
+ // type 0:鎴愬搧鍏ュ簱 1:閲囪喘鍏ュ簱 2:涓棿鍝佸叆搴� 3:閫�璐у叆搴� 4:杞﹂棿浣欐枡閫�鍥炲叆搴� 5:鍏跺畠鍏ュ簱 6:浠e偍鍏ュ簱 7:瀵勫瓨鍏ュ簱
+ if (notice.Type == "2" || notice.Type == "6" || notice.Type == "7")
+ {
+ // 涓嶈创鐮佺墿鏂� 鏃犻渶楠岃瘉绠辩爜淇℃伅
+ }
+ else
+ {
+ //楠岃瘉绠辩爜淇℃伅鏄惁瀛樺湪
+ if (boxInfoList.Count <= 0)
+ {
+ throw new Exception("绠辩爜淇℃伅涓嶅瓨鍦紝璇锋牳鏌�!");
+ }
+ foreach (var item in boxInfoList)
+ {
+ item.Status = "2"; // 鏀瑰彉绠辨敮鍏崇郴琛ㄧ姸鎬侊細宸插叆搴�
+ item.UpdateTime = serverTime;
+ item.UpdateUser = model.CreateUser;
+ }
+ Db.Updateable(boxInfoList).ExecuteCommand();
+ }
+ #endregion
+
+ bool isFinsh = true;//鏄惁鍏ㄩ儴鍏ュ簱瀹屾垚
+ #region 鍏ュ簱鍗曟槑缁�
+ var noticeDetail = Db.Queryable<BllArrivalNoticeDetail>().First(w => w.IsDel == "0" && w.ASNNo == model.ASNNo && w.Id == bindInfo.ASNDetailNo);
+ if (noticeDetail == null)
+ {
+ throw new Exception("鍏ュ簱鍗曟槑缁嗕俊鎭笉瀛樺湪锛岃鏍告煡!");
+ }
+ noticeDetail.CompleteQty += bindInfo.Qty;//澧炲姞鍏ュ簱鏁伴噺
+ //鍒ゆ柇鍏ュ簱鏁伴噺澧炲姞鍚庢槸鍚﹀ぇ浜庣瓑浜庡崟鎹暟閲�
+ if (noticeDetail.CompleteQty >= noticeDetail.Qty)
+ {
+ noticeDetail.Status = "2";//鎵ц瀹屾垚
+ noticeDetail.CompleteTime = serverTime;
+ }
+ else
+ {
+ noticeDetail.Status = "1";//姝e湪鎵ц
+
+ isFinsh = false;
+ }
+ noticeDetail.UpdateUser = model.CreateUser;
+ noticeDetail.UpdateTime = serverTime;
+ Db.Updateable(noticeDetail).ExecuteCommand();
+ #endregion
+
+ #region 鐗╂枡淇℃伅
+ var sku = Db.Queryable<SysMaterials>().First(s => s.SkuNo == noticeDetail.SkuNo && s.IsDel == "0" && s.SkuName == noticeDetail.SkuName);
+ //鍒ゆ柇鐗╂枡淇℃伅鏄惁涓虹┖
+ if (sku == null)
+ {
+ throw new Exception("鐗╂枡淇℃伅涓嶅瓨鍦紝璇锋牳鏌�!");
+ }
+ #endregion
+
+ #region 搴撳瓨鎬昏〃
+ // 鍒ゆ柇褰撳墠鐗╂枡搴撳瓨琛ㄦ槸鍚﹀凡瀛樺湪
+ var stockModel = Db.Queryable<DataStock>().First(w => w.IsDel == "0" && w.SkuNo == noticeDetail.SkuNo && w.LotNo == bindInfo.LotNo && w.Standard == noticeDetail.Standard);
+ if (stockModel == null || stockModel.Id == 0)
+ {
+ stockModel = new DataStock
+ {
+ LotNo = bindInfo.LotNo,
+ LotText = bindInfo.LotText,
+ SupplierLot = bindInfo.SupplierLot,
+ SkuNo = noticeDetail.SkuNo,
+ SkuName = noticeDetail.SkuName,
+ Qty = bindInfo.Qty,
+ Standard = noticeDetail.Standard,
+ CreateUser = (int)model.CreateUser,
+ CreateTime = serverTime
+ };
+ //缁存姢搴撳瓨璐т富淇℃伅
+ if (notice.Type == "0" || notice.Type == "2" || notice.Type == "4" || notice.Type == "6" || notice.Type == "7")//0:鎴愬搧鍏ュ簱锛�2:涓棿鍝佸叆搴�,4:杞﹂棿浣欐枡鍏ュ簱,6:浠e偍鍏ュ簱,7:瀵勫瓨鍏ュ簱
+ {
+ stockModel.OwnerNo = notice.CustomerNo;//璐т富缂栫爜
+ stockModel.OwnerName = notice.CustomerName;//璐т富鍚嶇О
+ }
+ //鏂板搴撳瓨鎬讳俊鎭�
+ Db.Insertable<DataStock>(stockModel).ExecuteCommand();
+ }
+ else
+ {
+ stockModel.Qty += bindInfo.Qty;
+ stockModel.UpdateUser = (int)model.CreateUser;
+ stockModel.UpdateTime = serverTime;
+ //淇敼搴撳瓨鎬讳俊鎭�
+ Db.Updateable(stockModel).ExecuteCommand();
+ }
+ #endregion
+
+ #region 搴撳瓨鏄庣粏琛�
+ // 鍒ゆ柇褰撳墠鎵樼洏鏄惁宸插瓨鍦紙鎷h揣鍥炲簱鎵樼洏锛�
+ var detailModel = Db.Queryable<DataStockDetail>().First(it => it.PalletNo == bindInfo.PalletNo && it.LotNo == bindInfo.LotNo && it.SkuNo == noticeDetail.SkuNo
+ && it.Standard == noticeDetail.Standard && it.IsDel == "0");
+ var stId = 0;
+ if (detailModel == null || detailModel.Id == 0)
+ {
+ // 娣诲姞搴撳瓨鏄庣粏琛�
+ detailModel = new DataStockDetail()
+ {
+ LotNo = bindInfo.LotNo,
+ LotText = bindInfo.LotText,
+ SupplierLot = noticeDetail.SupplierLot,
+ SkuNo = noticeDetail.SkuNo,
+ SkuName = noticeDetail.SkuName,
+ Standard = noticeDetail.Standard,
+ Qty = bindInfo.Qty,
+ LockQty = 0,
+ FrozenQty = 0,
+ InspectQty = bindInfo.Qty,
+ ASNNo = noticeDetail.ASNNo,
+ ASNDetailNo = (int)bindInfo.ASNDetailNo,
+ WareHouseNo = "W02",
+ RoadwayNo = "",
+ AreaNo = storageLocat.AreaNo,
+ LocatNo = model.LocatNo,
+ PalletNo = model.PalletNo,
+ PalletNo2 = bindInfo.PalletNo2,
+ PalletNo3 = bindInfo.PalletNo3,
+ CompleteTime = serverTime,
+ ProductionTime = bindInfo.ProductionTime,
+ ExpirationTime = bindInfo.ExpirationTime,
+ Status = "0",
+ InspectMark = bindInfo.InspectMark,
+ BitPalletMark = bindInfo.BitPalletMark,
+ InspectStatus = sku.IsInspect,// 缁勭洏鐨勬椂鍊欏氨瑕侀粯璁よ瀹氬ソ鏄惁鍚堟牸
+ PackagNo = sku.PackagNo,
+ IsBale = bindInfo.IsBale,
+ IsBelt = bindInfo.IsBelt,
+
+ CreateUser = (int)model.CreateUser,
+ CreateTime = serverTime
+ };
+ //缁存姢搴撳瓨鏄庣粏璐т富/渚涘簲鍟嗕俊鎭�
+ if (notice.Type == "0" || notice.Type == "2" || notice.Type == "4" || notice.Type == "6" || notice.Type == "7")//0:鎴愬搧鍏ュ簱锛�2:涓棿鍝佸叆搴�,4:杞﹂棿浣欐枡鍏ュ簱,6:浠e偍鍏ュ簱,7:瀵勫瓨鍏ュ簱
+ {
+ detailModel.OwnerNo = notice.CustomerNo;//璐т富缂栫爜
+ detailModel.OwnerName = notice.CustomerName;//璐т富鍚嶇О
+ }
+ else if (notice.Type == "1" || notice.Type == "5")//1:閲囪喘鍏ュ簱,2:鍏跺畠鍏ュ簱
+ {
+ detailModel.SupplierNo = notice.CustomerNo;//渚涘簲鍟嗙紪鐮�
+ detailModel.SupplierName = notice.CustomerName;//渚涘簲鍟嗗悕绉�
+ }
+ stId = Db.Insertable<DataStockDetail>(detailModel).ExecuteReturnIdentity();
+
+ }
+ else
+ {
+ stId = detailModel.Id;
+ detailModel.LocatNo = model.LocatNo;
+ detailModel.AreaNo = storageLocat.AreaNo;
+ detailModel.UpdateTime = serverTime;
+ detailModel.UpdateUser = (int)model.CreateUser;
+ // 鍙樻洿鍌ㄤ綅鍦板潃
+ Db.Updateable<DataStockDetail>(detailModel).UpdateColumns(it => new { it.LocatNo, it.UpdateTime, it.UpdateUser }).ExecuteCommand();
+ }
+ #endregion
+
+ #region 浠诲姟鍙婄粍鎵樹俊鎭�
+ //鍒涘缓浠诲姟淇℃伅
+ var taskNo = new Common().GetMaxNo("TK");
+ var exTask = new LogTask //鍏ュ簱浠诲姟
+ {
+ TaskNo = taskNo,
+ Sender = "WMS",
+ Receiver = "PDA",
+ IsSuccess = 1, //鏄惁涓嬪彂鎴愬姛 0澶辫触 1鎴愬姛
+ SendDate = serverTime, //鍙戦�佹椂闂�
+ BackDate = serverTime, //杩斿洖鏃堕棿
+ StartLocat = "",//璧峰浣嶇疆
+ EndLocat = "鍔涜骞冲簱",//鐩爣浣嶇疆
+ PalletNo = bindInfo.PalletNo,//鎵樼洏鐮�
+ IsSend = 0,//鏄惁鍙啀娆′笅鍙�
+ IsCancel = 0,//鏄惁鍙彇娑�
+ IsFinish = 0,//鏄惁鍙畬鎴�
+ Type = "0",//浠诲姟绫诲瀷 0 鍏ュ簱浠诲姟 1 鍑哄簱浠诲姟 2 绉诲簱浠诲姟
+ Status = "2",//浠诲姟鐘舵��0锛氱瓑寰呮墽琛�1姝e湪鎵ц2鎵ц瀹屾垚
+ OrderType = "0",//0 鍏ュ簱鍗� 1 鍑哄簱鍗� 2 鐩樼偣鍗� 3 绉诲簱鍗�
+ Msg = "鍔涜骞冲簱鐨勫叆搴撲换鍔�",
+ };
+ Db.Insertable(exTask).ExecuteCommand();
+
+ //淇敼缁勬墭鐘舵��
+ bindInfo.Status = "2"; //2 鍏ュ簱瀹屾垚
+ bindInfo.WareHouseNo = "W02";//鎵�灞炰粨搴�
+ bindInfo.LocatNo = model.LocatNo;//鍌ㄤ綅鍦板潃
+ bindInfo.UpdateTime = serverTime;
+ bindInfo.UpdateUser = model.CreateUser;
+ bindInfo.CompleteTime = serverTime; //瀹屾垚鏃堕棿
+ bindInfo.TaskNo = taskNo; //浠诲姟鍙�
+ Db.Updateable(bindInfo).ExecuteCommand();
+ #endregion
+
+ #region 搴撳瓨绠辨敮鏄庣粏琛�
+ // 鎻掑叆鏂扮粍鐨勭鏀俊鎭�
+ var comTime = DateTime.Now;
+ foreach (var item in boxInfoList)
+ {
+ var info = new DataBoxInfo()
+ {
+ StockDetailId = stId,
+ BindNo = bindInfo.Id,
+ BoxNo = item.BoxNo,
+ BoxNo2 = item.BoxNo2,
+ BoxNo3 = item.BoxNo3,
+ PalletNo = item.PalletNo,
+ PalletNo2 = item.PalletNo2,
+ PalletNo3 = item.PalletNo3,
+ Qty = item.Qty,
+ FullQty = item.FullQty,
+ Status = "2",
+ LotNo = item.LotNo,
+ LotText = item.LotText,
+ SkuNo = item.SkuNo,
+ SkuName = item.SkuName,
+ Standard = sku.Standard,
+ ProductionTime = item.ProductionTime,
+ SupplierLot = item.SupplierLot,
+ InspectMark = item.InspectMark,
+ BitBoxMark = item.BitBoxMark,
+ InspectStatus = item.InspectStatus,
+ //InspectTime = item.,
+
+ IsDel = "0",
+ CreateUser = 0,
+ CreateTime = comTime
+ };
+ Db.Insertable(info).ExecuteCommand();
+ }
+ #endregion
+
+ var entryList = Db.Queryable<BllArrivalNoticeDetail>().Where(w => w.IsDel == "0" && w.ASNNo == notice.ASNNo && w.Id != noticeDetail.Id && w.Status != "2").ToList();
+ if (isFinsh && entryList.Count <= 0)//鍏ュ簱鍗曟槑缁嗗叏閮ㄥ畬鎴�
+ {
+ //淇敼鍏ュ簱鍗曟�诲崟淇℃伅
+ notice.Status = "2";
+ notice.UpdateUser = model.CreateUser;
+ notice.UpdateTime = serverTime;
+ Db.Updateable(notice).ExecuteCommand();
+ }
+ else
+ {
+ //鍒ゆ柇鎬诲崟鐘舵�佹槸鍚︿负姝e湪鎵ц
+ if (notice.Status == "0")
+ {
+ //淇敼鍏ュ簱鍗曟�诲崟淇℃伅
+ notice.Status = "1";
+ notice.UpdateUser = model.CreateUser;
+ notice.UpdateTime = serverTime;
+ Db.Updateable(notice).ExecuteCommand();
+ }
+ }
+ }
+ else
+ {
+ //淇敼搴撳瓨鏄庣粏淇℃伅
+ foreach (var item in stockDetail)
+ {
+ item.Status = "0"; //鐘舵�佹洿鏀逛负寰呭垎閰�
+ item.WareHouseNo = "W02"; //鎵�灞炰粨搴�
+ item.LocatNo = model.LocatNo;//鍌ㄤ綅鍦板潃
+ item.UpdateTime = serverTime; //淇敼鏃堕棿
+ item.UpdateUser = model.CreateUser; //淇敼浜�
+ //淇敼搴撳瓨鏄庣粏淇℃伅
+ Db.Updateable(item).ExecuteCommand();
+ }
+ //鑾峰彇鎷h揣淇℃伅
+ var alotr = Db.Queryable<BllExportAllot>().First(a => a.IsDel == "0" && a.PalletNo == model.PalletNo && a.Status == "4");
+ if (alotr != null)
+ {
+ alotr.Status = "5"; //5 宸插畬鎴�
+ alotr.UpdateUser = model.CreateUser; //淇敼浜�
+ alotr.UpdateTime = serverTime; //淇敼鏃堕棿
+ //淇敼鎷h揣淇℃伅
+ Db.Updateable(alotr).ExecuteCommand();
+ }
+ #region 浠诲姟鍙婄粍鎵樹俊鎭�
+ //鍒涘缓浠诲姟淇℃伅
+ var taskNo = new Common().GetMaxNo("TK");
+ var exTask = new LogTask //鍏ュ簱浠诲姟
+ {
+ TaskNo = taskNo,
+ Sender = "WMS",
+ Receiver = "PDA",
+ IsSuccess = 1, //鏄惁涓嬪彂鎴愬姛 0澶辫触 1鎴愬姛
+ SendDate = DateTime.Now, //鍙戦�佹椂闂�
+ BackDate = DateTime.Now, //杩斿洖鏃堕棿
+ StartLocat = "",//璧峰浣嶇疆
+ EndLocat = "鍔涜骞冲簱",//鐩爣浣嶇疆
+ PalletNo = model.PalletNo,//鎵樼洏鐮�
+ IsSend = 0,//鏄惁鍙啀娆′笅鍙�
+ IsCancel = 0,//鏄惁鍙彇娑�
+ IsFinish = 0,//鏄惁鍙畬鎴�
+ Type = "0",//浠诲姟绫诲瀷 0 鍏ュ簱浠诲姟 1 鍑哄簱浠诲姟 2 绉诲簱浠诲姟
+ Status = "2",//浠诲姟鐘舵��0锛氱瓑寰呮墽琛�1姝e湪鎵ц2鎵ц瀹屾垚
+ OrderType = "0",//0 鍏ュ簱鍗� 1 鍑哄簱鍗� 2 鐩樼偣鍗� 3 绉诲簱鍗�
+ Msg = "鍔涜骞冲簱鐨勫洖搴撲换鍔�",
+ };
+ Db.Insertable(exTask).ExecuteCommand();
+ #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);
+
+ Db.CommitTran();
+ }
+ catch (Exception ex)
+ {
+ Db.RollbackTran();
+ throw ex;
+ }
+ }
+ #endregion
}
}
--
Gitblit v1.8.0