From 1e26a7575d9969e728b0aa01466f490409cb173c Mon Sep 17 00:00:00 2001 From: chengsc <Demo@DESKTOP-CPA90BF> Date: 星期五, 18 十月 2024 18:41:30 +0800 Subject: [PATCH] Merge branch 'master' into csc --- Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs | 462 ++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 390 insertions(+), 72 deletions(-) diff --git a/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs b/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs index 1d8d751..3a2dabc 100644 --- a/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs +++ b/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs @@ -17,6 +17,11 @@ using Model.ModelDto.PdaDto; using Dm; using Model.InterFaceModel; +using WMS.Entity.BllQualityEntity; +using Newtonsoft.Json; +using Utility.Tools; +using System.Reflection; +using System.IO; namespace WMS.BLL.BllPdaServer { @@ -24,17 +29,117 @@ { private static readonly SqlSugarScope Db = DataContext.Db; + #region 淇敼鎵樼洏缁戝畾鏃跺叆搴撳崟鍘婚櫎鍙樹负鐗╂枡+鏁伴噺 + + /// <summary> + /// 鑾峰彇鍗曟嵁鏄庣粏鏄剧ず鐨勭墿鏂� + /// </summary> + /// <param name="model"></param> + /// <returns></returns> + public List<ArrivalNoticeDetailDto> GetArrivalNoticesInfo(ArrivalNoticeVm model) + { + try + { + //model.Type锛氬崟鎹被鍨� 鍦ㄨ繖閲屼唬琛ㄥ墠绔〉绛剧被鍨嬶細鍗虫爣绛鹃〉绛撅細璐存爣鐗╂枡锛� 鏁伴噺椤电锛氫笉璐磋〃鐗╂枡锛屽師鍥狅細鎳掑緱鍔犲弬鏁� + var data = Db.Queryable<BllArrivalNotice>().Where(m => m.IsDel == "0" && m.Status != "3" && m.Status != "4").Select(m => m.ASNNo).ToList(); + var list = new List<ArrivalNoticeDetailDto>(); + if (model.Type.Contains("0"))//0璐存爣 + { + list = Db.Queryable<BllArrivalNoticeDetail>().Where(m => m.IsDel == "0" && data.Contains(m.ASNNo) && !string.IsNullOrWhiteSpace(m.PackagNo)).Select(m => new ArrivalNoticeDetailDto()).ToList(); + } + else if (model.Type.Contains("1"))//1涓嶈创鏍� + { + list = Db.Queryable<BllArrivalNoticeDetail>().Where(m => m.IsDel == "0" && data.Contains(m.ASNNo) && string.IsNullOrWhiteSpace(m.PackagNo)).Select(m=>new ArrivalNoticeDetailDto()).ToList(); + } + else + { + throw new Exception("椤电绫诲瀷鍙傛暟閿欒"); + } + + List<ArrivalNoticeDetailDto> noticeList = new List<ArrivalNoticeDetailDto>(); + foreach (var item in list) + { + 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); + } + } + } + //List<ArrivalNoticeDetailDto> list = new List<ArrivalNoticeDetailDto>(); + //foreach (var item in noticeList) + //{ + // string str = BySkuNoGetPackInfo(item.SkuNo); + // if (str == "瀛樺湪") + // { + // list.Add(item); + // } + //} + + return noticeList; + } + catch (Exception ex) + { + throw ex; + } + } + + + #endregion + // 鑾峰彇鍗曟嵁鍒楄〃 - public List<ArrivalNoticeDto> GetArrivalNotices(ArrivalNoticeVm model) + public List<string> GetArrivalNotices(ArrivalNoticeVm model) { string sqlString = string.Empty; try { // 鏈叧鍗曠殑鍗曟嵁 - 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); + //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; + //model.Type锛氬崟鎹被鍨� 鍦ㄨ繖閲屼唬琛ㄥ墠绔〉绛剧被鍨嬶細鍗虫爣绛鹃〉绛撅細璐存爣鐗╂枡锛� 鏁伴噺椤电锛氫笉璐磋〃鐗╂枡锛屽師鍥狅細鎳掑緱鍔犲弬鏁� + var data = Db.Queryable<BllArrivalNotice>().Where(m => m.IsDel == "0" && m.Status != "3" && m.Status != "4").Select(m=>m.ASNNo).ToList(); + var list = new List<string>(); + if (model.Type.Contains("0"))//0璐存爣 + { + list = Db.Queryable<BllArrivalNoticeDetail>().Where(m =>m.IsDel == "0" && data.Contains(m.ASNNo) && !string.IsNullOrWhiteSpace(m.PackagNo)).Select(m => m.ASNNo).Distinct().ToList(); + } + else if(model.Type.Contains("1"))//1涓嶈创鏍� + { + list = Db.Queryable<BllArrivalNoticeDetail>().Where(m => m.IsDel == "0" && data.Contains(m.ASNNo) && string.IsNullOrWhiteSpace(m.PackagNo)).Select(m=>m.ASNNo).Distinct().ToList(); + } + else + { + throw new Exception("椤电绫诲瀷鍙傛暟閿欒"); + } + + + return list; } catch (Exception ex) { @@ -68,7 +173,17 @@ sqlString = $"select * from BllArrivalNoticeDetail where ASNNo = '{model.ASNNo}' and isdel='0' order by CreateTime;"; var modelList = Db.Ado.SqlQuery<ArrivalNoticeDetailDto>(sqlString); - return modelList; + List<ArrivalNoticeDetailDto> list = new List<ArrivalNoticeDetailDto>(); + foreach (var item in modelList) + { + string str = BySkuNoGetPackInfo(item.SkuNo); + if (str == "涓嶅瓨鍦�") + { + list.Add(item); + } + } + + return list; } catch (Exception ex) { @@ -366,12 +481,12 @@ { //鑾峰彇浠诲姟淇℃伅 var logtask = Db.Queryable<LogTask>().First(a => a.PalletNo == upBindPalletNo && a.IsDel == "0" && a.Status == "1"); - if (logtask == null) + if (logtask != null) { strMsg = "璇ユ墭鐩樹换鍔″凡瀹屾垚 鎴栨湭鎴愬姛鍒涘缓浠诲姟 璇锋牳瀹烇紒"; return strMsg; } - string bindstr = "select * from BllPalletBind Where IsDel = @isdel and PalletNo = @palletno and ASNDetailNo = 0 and ASNNo = ''"; + string bindstr = "select * from BllPalletBind Where IsDel = @isdel and PalletNo = @palletno and ASNDetailNo = 0 and ASNNo = '' "; //鑾峰彇缁戝畾鎵樼洏琛ㄤ俊鎭� List<PalletBindVm> bindVms = Db.Ado.SqlQuery<PalletBindVm>(bindstr, new { @@ -387,10 +502,13 @@ return strMsg; } //鍒犻櫎缁戝畾鎵樼洏琛ㄤ俊鎭� - string delstr = "delete from BllPalletBind Where PalletNo = @palletno"; + string delstr = "update BllPalletBind set IsDel = 1,UpdateUser = @UpdateUser,UpdateTime = @UpdateTime Where PalletNo = @palletno and Id =@Id "; int i = Db.Ado.ExecuteCommand(delstr, new { - palletno = upBindPalletNo + UpdateUser = createUser, + UpdateTime = DateTime.Now, + palletno = upBindPalletNo, + Id = bindVms[0].Id }); //淇敼鎵樼洏鐘舵�� Db.BeginTran(); @@ -401,7 +519,7 @@ UpbindPalletNo = upBindPalletNo, PalletNo2 = bindVms[0].PalletNo2, PalletNo3 = bindVms[0].PalletNo3, - Qty = (int)bindVms[0].Qty, + Qty = bindVms[0].Qty, LotNo = bindVms[0].LotNo, LotText = bindVms[0].LotText, SupplierLot = bindVms[0].SupplierLot, @@ -417,12 +535,12 @@ box.IsDel = "1"; Db.Updateable(box).ExecuteCommand(); - //淇敼浠诲姟鐘舵�� - logtask.IsDel = "1"; - logtask.Status = "4"; //3 宸插彇娑� - logtask.UpdateUser = createUser; //鍙栨秷浜� - logtask.UpdateTime = DateTime.Now; //鍙栨秷鏃堕棿 - Db.Updateable(logtask).ExecuteCommand(); + ////淇敼浠诲姟鐘舵�� + //logtask.IsDel = "1"; + //logtask.Status = "4"; //3 宸插彇娑� + //logtask.UpdateUser = createUser; //鍙栨秷浜� + //logtask.UpdateTime = DateTime.Now; //鍙栨秷鏃堕棿 + //Db.Updateable(logtask).ExecuteCommand(); //鏇存敼搴撳瓨鏁伴噺 //string str = $"update DataStock set Qty = Qty - {(int)bindVms[0].Qty} Where SkuNo = '100099'"; // 鏇存敼鎵樼洏浣跨敤鐘舵�� @@ -787,7 +905,7 @@ return strMsg; } #endregion - var pallQty = 0;//鎵樼洏涓婃暟閲� + decimal pallQty = 0;//鎵樼洏涓婃暟閲� var boxinfo2 = boxinfo.Where(w => w.SkuNo == noticeItem.SkuNo && w.LotNo == noticeItem.LotNo && w.PalletNo == model.PalletNo).ToList(); if (boxinfo2.Count <= 0) { @@ -1388,7 +1506,7 @@ { throw new Exception("-1:绠辩爜淇℃伅涓嶅瓨鍦紝璇锋牳鏌�!"); } - var bNum = 0;//鏁伴噺 + decimal bNum = 0;//鏁伴噺 //楠岃瘉绠辩爜鏄惁宸茬粦瀹氭墭鐩� foreach (var item in boxinfo) { @@ -1671,6 +1789,104 @@ } #region 浜у搧缁勬墭 + + public void GetBoxInfoByFuMa(string boxNo,string url) + { + try + { + var list = new List<BllBoxInfo>(); + + var data = new { BoxNo = boxNo }; + var jsonData = JsonConvert.SerializeObject(data); + + #region 娴嬭瘯鐗堟湰 + + //璇诲彇json鏂囦欢锛屾坊鍔犳暟鎹� + var ss = AppDomain.CurrentDomain.BaseDirectory; + string filePath = Path.Combine(ss, "CreateBoxInfo.json"); + string json = File.ReadAllText(filePath); + var person = JsonConvert.DeserializeObject<List<BllBoxInfo>>(json); + + var comTime = DateTime.Now; + //娣诲姞绠辩爜淇℃伅琛ㄤ腑 //鏆傛椂杩欎簺鍐�--娣诲姞鏁版嵁锛屽悗缁渶瑕佸拰璧嬬爜绯荤粺瀵规帴鍚� 鏍规嵁鏄庣‘杩斿洖鐨勬暟鎹牸寮忔洿鏀� + foreach (var item in person) + { + if (item.BoxNo!= boxNo) + { + continue; + } + + var sku = Db.Queryable<SysMaterials>().First(m=>m.IsDel =="0" && m.SkuNo == item.SkuNo); + if (sku == null) + { + continue; + } + var boxInfo = new BllBoxInfo() + { + ASNNo = "", + //ASNDetailNo = 0, + OrderCode = "", + //BindNo = 0, + BoxNo = item.BoxNo, + BoxNo2 = item.BoxNo2, + BoxNo3 = item.BoxNo3, + PalletNo = "", + Qty = item.Qty, + FullQty = item.FullQty, + Status = "0", + SkuNo = item.SkuNo, + SkuName = sku.SkuName, + LotNo = item.LotNo, + LotText = item.LotText, + SupplierLot = item.SupplierLot, + ProductionTime = item.ProductionTime, + ExpirationTime = item.ExpirationTime, + //CompleteTime = comTime, + InspectMark = item.InspectMark, + BitBoxMark = item.BitBoxMark, + InspectStatus = item.InspectStatus, + Origin = "璧嬬爜", + Standard = item.Standard, + PackageStandard = item.PackageStandard, + StoreTime = item.StoreTime, + QtyOrd = item.QtyOrd, + QtyCount = item.QtyCount, + CreateUser = 0, + CreateTime = comTime, + }; + list.Add(boxInfo); + } + Db.Insertable(list).ExecuteCommand(); + + #endregion + + #region 姝e紡鐗堟湰 + + + ////绋嬪簭姝e紡鍙戝竷鍚庢斁寮� + //var time1 = DateTime.Now;//鍙戦�佹椂闂� .ToString("yyyy-MM-dd HH:mm:ss") + //var response = HttpHelper.DoPost(url, jsonData, "鑾峰彇绠辩爜淇℃伅", "璧嬬爜"); + //var time2 = DateTime.Now;//杩斿洖鏃堕棿 .ToString("yyyy-MM-dd HH:mm:ss") + + ////瑙f瀽杩斿洖鏁版嵁 + //var fuMaModel = JsonConvert.DeserializeObject<FuMaModel>(response); + //if (fuMaModel.Success == 0) + //{ + + //} + //if (fuMaModel.Success == -1) + //{ + // throw new Exception($"璧嬬爜绯荤粺杩斿洖鐘舵�佸紓甯革細{fuMaModel.Message}"); + //} + #endregion + + } + catch (Exception e) + { + throw new Exception(e.Message); + } + } + /// <summary> /// 鏍规嵁绠辩爜鑾峰彇鏍囩绠辩爜淇℃伅 /// </summary> @@ -1683,6 +1899,19 @@ if (string.IsNullOrEmpty(model.BoxNo)) { throw new Exception("璇锋壂鎻忓绠辨潯鐮�!"); + } + if (!string.IsNullOrWhiteSpace(model.ASNNo)) + { + var asnData = Db.Queryable<BllArrivalNotice>().First(m => m.IsDel == "0" && m.ASNNo == model.ASNNo); + if (asnData != null && (asnData.Type == "0" || asnData.Type == "3")) + { + var count = Db.Queryable<BllBoxInfo>().Count(m => m.IsDel == "0" && m.Status == "0" && m.BoxNo == model.BoxNo); + if (count == 0) + { + GetBoxInfoByFuMa(model.BoxNo, ""); //浠庤祴鐮佺郴缁熻幏鍙栫鐮佷俊鎭� + } + } + } string sqlString = $@"SELECT ASNNo, @@ -1697,7 +1926,7 @@ AND BoxNo = '{model.BoxNo}' GROUP BY ASNNo,BoxNo,SkuNo,SkuName,LotNo; "; var models = Db.Ado.SqlQuery<BoxInfoDto>(sqlString); - if (models == null) + if (models.Count == 0) { throw new Exception("绠辩爜淇℃伅涓嶅瓨鍦�!"); } @@ -1751,11 +1980,44 @@ } } } - return noticeList; + List<ArrivalNoticeDetailDto> list = new List<ArrivalNoticeDetailDto>(); + foreach (var item in noticeList) + { + string str = BySkuNoGetPackInfo(item.SkuNo); + if (str == "瀛樺湪") + { + list.Add(item); + } + } + + return list; } catch (Exception ex) { throw ex; + } + } + + //鏍规嵁鐗╂枡鑾峰彇鏄惁瀛樺湪鍖呰淇℃伅 + public string BySkuNoGetPackInfo(string skuNo) + { + try + { + //鑾峰彇鐗╂枡淇℃伅 + var sku = Db.Queryable<SysMaterials>().First(a => a.IsDel == "0" && a.SkuNo == skuNo); + //鍒ゆ柇鐗╂枡淇℃伅鏄惁涓虹┖ + if (!string.IsNullOrWhiteSpace(sku.PackagNo)) + { + return "瀛樺湪"; + } + else + { + return "涓嶅瓨鍦�"; + } + } + catch (Exception ex) + { + return ex.Message; } } @@ -1776,21 +2038,30 @@ if (string.IsNullOrEmpty(model.AsnNo)) { - throw new Exception("-1:鍗曟嵁鍙蜂笉鍙负绌�!"); + throw new Exception("-1:鐗╂枡鏄庣粏涓嶅彲涓虹┖!"); } - if (model.AsnDetailId == null || model.AsnDetailId == 0) - { - 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") + var detailId = model.AsnNo.Split("-"); + model.AsnDetailId = int.Parse(detailId[0]); + // 楠岃瘉鍏ュ簱鍗曟槑缁嗘槸鍚﹀瓨鍦� + var detail = Db.Queryable<BllArrivalNoticeDetail>().First(m => m.IsDel == "0" && m.Id == model.AsnDetailId); + if (detail == null) { - throw new Exception("-1:鍏ュ簱鍗曠姸鎬佷笉鏄瓑寰呮墽琛屾垨鎵ц瀹屾垚!"); + throw new Exception("-1:褰撳墠鐗╂枡鏈煡璇㈠埌鍗曟嵁锛岃鏍稿疄!"); + } + model.AsnNo = detail.ASNNo; + //鏍规嵁鍗曟嵁鍙疯幏鍙栧叆搴撳崟鎬诲崟 + var notice = Db.Queryable<BllArrivalNotice>().First(a => a.IsDel == "0" && a.ASNNo == detail.ASNNo); + if (notice.Status != "0" && notice.Status != "1" && notice.Status != "2") + { + throw new Exception("-1:璇ュ崟鎹凡鍏冲崟!"); } if (string.IsNullOrEmpty(model.LotNo)) { @@ -1804,10 +2075,11 @@ else { //浠庣墿鏂欏悕绉�-鎵规涓彇鍑烘壒娆� - int indexOfDash = model.LotNo.IndexOf("-"); - if (indexOfDash != -1) + var indexOfDash = model.LotNo.Split("-"); + var len = indexOfDash.Length; + if (len >= 1) { - model.LotNo = model.LotNo.Substring(indexOfDash + 1); + model.LotNo =indexOfDash[len-1]; } else { @@ -1815,7 +2087,7 @@ } } //鍒ゆ柇鐗╂枡鏁伴噺鏄惁涓�0 涓�0鍒ゆ柇绠辩爜淇℃伅 涓嶄负0缁х画 - if (model.SkuQty == 0) + if (model.TableType == 0) { if (string.IsNullOrEmpty(model.BoxNo)) { @@ -1831,6 +2103,7 @@ } } + int isTextTable = model.TableType; int isDeposit = 0; //鍒ゆ柇鎬诲崟鍗曟嵁鏄惁涓哄瘎瀛樺崟鎹� if (notice.Type == "7") @@ -1889,16 +2162,11 @@ } //鍒ゆ柇鎵樼洏鏄惁鍦ㄥ簱澶� var stockDetail = Db.Queryable<DataStockDetail>().First(m => m.IsDel == "0" && m.PalletNo == model.PalletNo); - if (stockDetail != null && !string.IsNullOrEmpty(stockDetail.WareHouseNo)) + if (stockDetail != null)// && !string.IsNullOrEmpty(stockDetail.WareHouseNo) { - throw new Exception("璇ユ墭鐩樻湭鍦ㄥ簱澶栵紝璇锋牳瀹烇紒"); + 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); @@ -1908,7 +2176,7 @@ var bNum = 0;//绠辩爜鐗╁搧鏁伴噺 //鍒ゆ柇鏄惁涓哄瘎瀛樼墿鏂� - if (isDeposit == 0) + if (isDeposit == 0 && isTextTable == 0) { if (pack == null) { @@ -1987,10 +2255,10 @@ Demo = model.Demo, }; - if (model.SkuQty > pNum && isDeposit == 0) - { - throw new Exception($"缁戝畾澶辫触锛寋model.PalletNo}鎵樼洏缁戝畾鏁伴噺澶т簬璇ョ墿鍝佹墭鐩樺寘瑁呮暟閲忥紒"); - } + //if (model.TableType == 0 && isDeposit == 0 && isTextTable == 0) 涓嶅お鐞嗚В杩欐浠g爜鐨勫惈涔� + //{ + // throw new Exception($"缁戝畾澶辫触锛寋model.PalletNo}鎵樼洏缁戝畾鏁伴噺澶т簬璇ョ墿鍝佹墭鐩樺寘瑁呮暟閲忥紒"); + //} // 鎻掑叆鎵樼洏缁戝畾琛� bindId = Db.Insertable(bind).ExecuteReturnIdentity(); } @@ -2037,12 +2305,12 @@ // 鏇存敼绠辨敮鍏崇郴琛� decimal factQty = 0.00m;//鎵樼洏鎬绘暟閲� //鎴愬搧缁勬墭 - if (model.SkuQty == 0) + if (isTextTable == 0) { var boxGroup = boxInfoList.GroupBy(m => m.BoxNo).ToList(); foreach (var g in boxGroup) { - var boxFullQty = 0;//绠卞唴鎬绘暟閲� + decimal boxFullQty = 0;//绠卞唴鎬绘暟閲� foreach (var box in g) { if (box.BindNo != null && box.BindNo != 0) @@ -2067,29 +2335,29 @@ factQty += box.Qty; boxFullQty += box.Qty; } - if (boxFullQty > bNum) - { - throw new Exception($"缁戝畾澶辫触锛寋g.Key}绠辩爜缁戝畾鏁伴噺澶т簬璇ョ墿鍝佸寘瑁呮暟閲忥紒"); - } + //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 && isDeposit == 0 && isTextTable == 0) + //{ + // throw new Exception("鎵樼洏缁戝畾鏁伴噺宸茶秴鍑鸿鐗╂枡鍖呰鏁伴噺"); + //} - if (bind.FullQty == bind.Qty) + if (bind.FullQty <= bind.Qty) { bind.BitPalletMark = "0"; } - if (bind.Qty > pNum && isDeposit == 0) - { - throw new Exception($"缁戝畾澶辫触锛寋bind.PalletNo}鎵樼洏缁戝畾鏁伴噺澶т簬璇ョ墿鍝佹墭鐩樺寘瑁呮暟閲忥紒"); - } + //if (bind.Qty > pNum && isDeposit == 0 && isTextTable == 0) + //{ + // throw new Exception($"缁戝畾澶辫触锛寋bind.PalletNo}鎵樼洏缁戝畾鏁伴噺澶т簬璇ョ墿鍝佹墭鐩樺寘瑁呮暟閲忥紒"); + //} Db.Updateable(bind).Where(m => m.Id == bindId).ExecuteCommand(); // 鏇存敼鍏ュ簱鍗曟槑缁嗗凡缁勬暟閲� @@ -2148,10 +2416,10 @@ try { #region 楠岃瘉淇℃伅 - if (string.IsNullOrEmpty(model.ASNNo)) - { - throw new Exception("鍏ュ簱鍗曚笉鑳戒负绌�!"); - } + //if (string.IsNullOrEmpty(model.ASNNo)) + //{ + // throw new Exception("鍏ュ簱鍗曚笉鑳戒负绌�!"); + //} if (string.IsNullOrEmpty(model.PalletNo)) { throw new Exception("鎵樼洏鏉$爜涓嶈兘涓虹┖!"); @@ -2224,7 +2492,7 @@ #endregion #region 绠辩爜淇℃伅 - var boxInfoList = Db.Queryable<BllBoxInfo>().Where(w => w.IsDel == "0" && w.ASNNo == model.ASNNo).ToList(); + 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") { @@ -2298,6 +2566,12 @@ 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(); } @@ -2350,11 +2624,48 @@ PackagNo = sku.PackagNo, IsBale = bindInfo.IsBale, IsBelt = bindInfo.IsBelt, + Demo = bindInfo.Demo, 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;//渚涘簲鍟嗗悕绉� + } + #region 缁存姢璐ㄦ缁撴灉 + + //鑾峰彇璇ユ壒娆℃渶缁堣川妫�缁撴灉 + var quality = Db.Queryable<BllQualityInspect>().Where(a => a.LotNo == noticeDetail.LotNo && a.IsDel == "0").OrderByDescending(a => a.CreateTime).First(); + if (notice.Type == "3") + { + quality = Db.Queryable<BllQualityInspect>().Where(a => a.LotNo == noticeDetail.LotNo && a.ASNNo == notice.ASNNo && a.IsDel == "0").OrderByDescending(a => a.CreateTime).First(); + } + if (quality != null) + { + //淇敼鍚堟牸涓嶅悎鏍兼暟閲� + if (quality.IsQualified == "1") //鍚堟牸 + { + //澧炲姞鍚堟牸鏁伴噺 + quality.PassQty += detailModel.Qty; + detailModel.InspectStatus = "1"; + } + else if (quality.IsQualified == "0") //涓嶅悎鏍� + { + //澧炲姞涓嶅悎鏍兼暟閲� + quality.FailQty += detailModel.Qty; + detailModel.InspectStatus = "2"; + } + Db.Updateable(quality).ExecuteCommand(); //淇敼璐ㄦ淇℃伅 + } + #endregion stId = Db.Insertable<DataStockDetail>(detailModel).ExecuteReturnIdentity(); - } else { @@ -2380,7 +2691,7 @@ SendDate = serverTime, //鍙戦�佹椂闂� BackDate = serverTime, //杩斿洖鏃堕棿 StartLocat = "",//璧峰浣嶇疆 - EndLocat = "鍔涜骞冲簱",//鐩爣浣嶇疆 + EndLocat = model.LocatNo,//鐩爣浣嶇疆 PalletNo = bindInfo.PalletNo,//鎵樼洏鐮� IsSend = 0,//鏄惁鍙啀娆′笅鍙� IsCancel = 0,//鏄惁鍙彇娑� @@ -2427,6 +2738,7 @@ SkuName = item.SkuName, Standard = sku.Standard, ProductionTime = item.ProductionTime, + ExpirationTime = item.ExpirationTime, SupplierLot = item.SupplierLot, InspectMark = item.InspectMark, BitBoxMark = item.BitBoxMark, @@ -2498,14 +2810,14 @@ SendDate = DateTime.Now, //鍙戦�佹椂闂� BackDate = DateTime.Now, //杩斿洖鏃堕棿 StartLocat = "",//璧峰浣嶇疆 - EndLocat = "鍔涜骞冲簱",//鐩爣浣嶇疆 + EndLocat = model.LocatNo,//鐩爣浣嶇疆 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 绉诲簱鍗� + OrderType = "3",//0 鍏ュ簱鍗� 1 鍑哄簱鍗� 2 鐩樼偣鍗� 3 绉诲簱鍗� Msg = "鍔涜骞冲簱鐨勫洖搴撲换鍔�", }; Db.Insertable(exTask).ExecuteCommand(); @@ -2517,8 +2829,14 @@ //淇敼鍌ㄤ綅淇℃伅 Db.Updateable(storageLocat).ExecuteCommand(); - new OperationASNServer().AddLogOperationAsn("PDA妯″潡", "骞冲簱鍏ュ簱", model.PalletNo, "瀹屾垚", $"鍦≒DA涓婂畬鎴愬崟鎹彿涓猴細{model.ASNNo}鐨勬墭鐩樼爜涓猴細{model.PalletNo}鐨勫钩搴撳叆搴撴搷浣�", (int)model.CreateUser); - + if (iscount == 1) + { + new OperationASNServer().AddLogOperationAsn("PDA妯″潡", "骞冲簱鍏ュ簱", model.PalletNo, "瀹屾垚", $"鍦≒DA涓婂畬鎴愭墭鐩樼爜涓猴細{model.PalletNo}鐨勫钩搴撳洖娴佸叆搴撴搷浣�", (int)model.CreateUser); + } + else + { + new OperationASNServer().AddLogOperationAsn("PDA妯″潡", "骞冲簱鍏ュ簱", model.PalletNo, "瀹屾垚", $"鍦≒DA涓婂畬鎴愬崟鎹彿涓猴細{model.ASNNo}鐨勬墭鐩樼爜涓猴細{model.PalletNo}鐨勫钩搴撳叆搴撴搷浣�", (int)model.CreateUser); + } Db.CommitTran(); } catch (Exception ex) -- Gitblit v1.8.0