From 4df579fcaba629e57397b86ac952a423637f8f97 Mon Sep 17 00:00:00 2001 From: chengsc <Demo@DESKTOP-CPA90BF> Date: 星期日, 21 七月 2024 17:50:33 +0800 Subject: [PATCH] 修改托盘绑定方法 --- Pda/View/AsnSetting/productEnterQuantity.html | 4 Wms/WMS.BLL/BllAsnServer/ArrivalNoticeServer.cs | 8 Wms/WMS.IBLL/IPdaServer/IPdaAsnServer.cs | 14 HTML/views/ASNSetting/PalletBind.html | 1 HTML/views/ASNSetting/ArrivalNotice.html | 22 Wms/Wms/Controllers/PdaAsnController.cs | 4 Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs | 1013 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 1,050 insertions(+), 16 deletions(-) diff --git a/HTML/views/ASNSetting/ArrivalNotice.html b/HTML/views/ASNSetting/ArrivalNotice.html index a47b6b5..396741c 100644 --- a/HTML/views/ASNSetting/ArrivalNotice.html +++ b/HTML/views/ASNSetting/ArrivalNotice.html @@ -291,7 +291,10 @@ <i class="layui-icon"></i>娣诲姞 </button> </script> - + <!-- if((d.AsnType =="1" || d.AsnType == "4" || d.AsnType == "5" || d.AsnType == "6") && d.IsPasteCode == "1" && (d.Status == "0" || d.Status == "1")){ + html += `<a class="layui-btn layui-btn-normal layui-btn-xs addLabelClass" lay-event="Addlabel"> + <i class="layui-icon layui-icon-edit"></i>鐢熸垚鏍囩</a>`; + } --> <script type="text/html" id="toolbarDemoList"> {{# function GetBtn2(d){ console.log(d); @@ -300,10 +303,7 @@ html = `<a class="layui-btn layui-btn-danger layui-btn-xs delClass" lay-event="del"> <i class="layui-icon layui-icon-delete"></i>鍒犻櫎</a>`; } - if((d.AsnType =="1" || d.AsnType == "4" || d.AsnType == "5" || d.AsnType == "6") && d.IsPasteCode == "1" && (d.Status == "0" || d.Status == "1")){ - html += `<a class="layui-btn layui-btn-normal layui-btn-xs addLabelClass" lay-event="Addlabel"> - <i class="layui-icon layui-icon-edit"></i>鐢熸垚鏍囩</a>`; - } + return html; } @@ -600,7 +600,7 @@ $(".clossClass").hide(); $(".editDemoClass").hide();//澶囨敞 $(".checkClass").hide(); //澶嶆牳 - $(".addLabelClass").hide(); //澶嶆牳 + //$(".addLabelClass").hide(); //鐢熸垚鏍囩 }); sendData(IP + "/Basis/GetRoleRightList", {}, 'get', function (res) { @@ -641,11 +641,11 @@ $(".checkClass").show(); }); } - if (res.data[k].MenuName == "鐢熸垚鏍囩") { - $(function () { - $(".addLabelClass").show(); - }); - } + // if (res.data[k].MenuName == "鐢熸垚鏍囩") { + // $(function () { + // $(".addLabelClass").show(); + // }); + // } } } else { //涓嶆垚鍔� layer.msg('鑾峰彇鏉冮檺淇℃伅澶辫触', { diff --git a/HTML/views/ASNSetting/PalletBind.html b/HTML/views/ASNSetting/PalletBind.html index 8a091f9..c769367 100644 --- a/HTML/views/ASNSetting/PalletBind.html +++ b/HTML/views/ASNSetting/PalletBind.html @@ -469,6 +469,7 @@ { field: 'WareHouseNo', title: '鎵�灞炰粨搴�', align: 'center', width: 90, templet: '#WareHouseButton' }, { field: 'SkuNo', title: '鐗╂枡缂栫爜', align: 'center', width: 110 }, { field: 'SkuName', title: '鐗╂枡鍚嶇О', align: 'center' }, + { field: 'LotNo', title: '鎵规鍙�', align: 'center',width: 120 }, { field: 'Qty', title: '鏁伴噺', align: 'center', width: 90 }, { field: 'FullQty', title: '鏁存墭鏁伴噺', align: 'center', width: 90 }, { field: 'SamplingQty', title: '鍙栨牱鏁伴噺', align: 'center', width: 90 }, diff --git a/Pda/View/AsnSetting/productEnterQuantity.html b/Pda/View/AsnSetting/productEnterQuantity.html index 24537f3..53fecbf 100644 --- a/Pda/View/AsnSetting/productEnterQuantity.html +++ b/Pda/View/AsnSetting/productEnterQuantity.html @@ -587,7 +587,7 @@ form.render('select'); var param = { - Type: "0,1,3,4,5,6" + Type: "0,3" }; sendData(IP + "/PdaAsn/GetArrivalNotices", param, 'post', function (res) { if (res.code == 0) { //鎴愬姛 @@ -622,7 +622,7 @@ form.render('select'); var param = { - Type: "1,2,3,4,5,6" + Type: "1,2,4" }; sendData(IP + "/PdaAsn/GetArrivalNotices", param, 'post', function (res) { if (res.code == 0) { //鎴愬姛 diff --git a/Wms/WMS.BLL/BllAsnServer/ArrivalNoticeServer.cs b/Wms/WMS.BLL/BllAsnServer/ArrivalNoticeServer.cs index 93c6c16..ba41cd5 100644 --- a/Wms/WMS.BLL/BllAsnServer/ArrivalNoticeServer.cs +++ b/Wms/WMS.BLL/BllAsnServer/ArrivalNoticeServer.cs @@ -92,7 +92,7 @@ .LeftJoin<BllArrivalNotice>((tb1, tb2) => tb1.ASNNo == tb2.ASNNo) .LeftJoin<SysUserInfor>((tb1, tb2,tb3) => tb1.CreateUser == tb3.Id) .LeftJoin<SysUserInfor>((tb1,tb2,tb3,tb4) => tb1.UpdateUser == tb4.Id) - .LeftJoin<SysMaterials>((tb1, tb2, tb3, tb4,tb5) => tb1.SkuNo == tb5.SkuNo) + .LeftJoin<SysMaterials>((tb1, tb2, tb3, tb4,tb5) => tb1.SkuNo == tb5.SkuNo && tb5.IsDel == "0") .LeftJoin<SysUnit>((tb1, tb2, tb3, tb4, tb5,tb6) => tb5.UnitNo == tb6.UnitNo) .LeftJoin<SysPackag>((tb1, tb2, tb3, tb4, tb5, tb6,tb7) => tb1.PackagNo == tb7.PackagNo) .Select((tb1, tb2, tb3, tb4, tb5,tb6, tb7) => new ArrivalNoticeDetailDto() @@ -492,6 +492,7 @@ string toDayTime = dateTime.ToString("yyyymmdd"); List<BllArrivalNoticeDetail> addDetails = new List<BllArrivalNoticeDetail>(); List<BllArrivalNoticeDetail> editDetails = new List<BllArrivalNoticeDetail>(); + var maxLotNo = ""; foreach (ArrivalNoticeDetailVm detailModel in detailModels) { if (string.IsNullOrEmpty(detailModel.SkuNo)) @@ -534,7 +535,10 @@ if (detailModel.Id == 0 || detailModel.Id == null || string.IsNullOrWhiteSpace(detailModel.LotNo)) { var notice = Db.Queryable<BllArrivalNotice>().Where(m => m.IsDel == "0" && TypeLot.Contains(m.Type)).Select(m => m.ASNNo).ToList(); - var maxLotNo = Db.Queryable<BllArrivalNoticeDetail>().Where(m=>m.IsDel == "0" && !string.IsNullOrWhiteSpace(m.LotNo) && notice.Contains(m.ASNNo)).Max(m=>m.LotNo); + if (string.IsNullOrWhiteSpace(maxLotNo)) + { + maxLotNo = Db.Queryable<BllArrivalNoticeDetail>().Where(m => m.IsDel == "0" && !string.IsNullOrWhiteSpace(m.LotNo) && notice.Contains(m.ASNNo)).Max(m => m.LotNo); + } if (string.IsNullOrWhiteSpace(maxLotNo)) { maxLotNo = toDayTime.Substring(2, 6) + "0001"; diff --git a/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs b/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs index d328fe6..4558ce5 100644 --- a/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs +++ b/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs @@ -3351,6 +3351,1019 @@ throw new Exception(e.Message); } } + + + //JC26缁戝畾鎵樼洏 璐存爣鐗╂枡 + public void BindPalletPasteCode(PdaPalletBindVm model, int userId) + { + try + { + #region 鍒ゆ柇 + + //0锛氭垚鍝佸叆搴� 1锛氶噰璐叆搴� 3锛氶��璐у叆搴� 4锛氳溅闂翠綑鏂欏叆搴� 5锛氬叾瀹冨叆搴� 6锛氫唬鍌ㄥ叆搴� + var TypeLot = "5, 6"; + + if (string.IsNullOrEmpty(model.AsnNo)) + { + throw new Exception("鍗曟嵁鍙蜂笉鍙负绌�!"); + } + if (model.AsnDetailId == null || model.AsnDetailId == 0) + { + throw new Exception("鐗╂枡涓嶅彲涓虹┖!"); + } + if (string.IsNullOrEmpty(model.PalletNo)) + { + throw new Exception("鎵樼洏鍙蜂笉鍙负绌�!"); + } + + //鏍规嵁鍗曟嵁鍙疯幏鍙栧叆搴撳崟鎬诲崟 + var notice = Db.Queryable<BllArrivalNotice>().First(a => a.IsDel == "0" && a.ASNNo == model.AsnNo); + if (notice.Status != "0" && notice.Status != "1" && notice.Status != "2") + { + throw new Exception("璇ュ崟鎹凡鍏冲崟!"); + } + + if (string.IsNullOrEmpty(model.LotNo)) + { + throw new Exception("鐗╂枡涓嶄负绌�!"); + } + else + { + //浠庣墿鏂欏悕绉�-鎵规涓彇鍑烘壒娆� + int indexOfDash = model.LotNo.IndexOf("-"); + if (indexOfDash != -1) + { + model.LotNo = model.LotNo.Substring(indexOfDash + 1); + } + else + { + if (!TypeLot.Contains(notice.Type)) + { + throw new Exception("鐗╂枡鎵规涓嶅彲涓虹┖!"); + } + + model.LotNo = ""; + } + } + + if (string.IsNullOrEmpty(model.BoxNo)) + { + throw new Exception("绠辩爜淇℃伅涓嶅彲涓虹┖!"); + } + + if (model.IsContinue == "1") + { + if (string.IsNullOrWhiteSpace(model.TailBoxNo)) + { + throw new Exception("寮�鍚繛缁粍鎵樻椂锛屽熬绠辩爜淇℃伅涓嶅彲涓虹┖!"); + } + } + + #endregion + + var comTime = DateTime.Now; + + //鎵樼洏鏄惁瀛樺湪 + 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 && m.LotNo.Contains(model.LotNo)); + if (detail == 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("璇ユ墭鐩樺凡鏈夊偍浣嶄俊鎭紝璇锋牳瀹烇紒"); + } + if (stockDetail != null && (stockDetail.SkuNo != detail.SkuNo || stockDetail.LotNo != model.LotNo)) + { + throw new Exception("璇ユ墭鐩樺湪搴撳瓨宸叉湁鍏跺畠鐗╂枡鎵规淇℃伅锛岃鏍稿疄锛�"); + } + + #region 鍖呰 + + var sku = Db.Queryable<SysMaterials>().First(m => m.IsDel == "0" && m.SkuNo == detail.SkuNo); + var pack = Db.Queryable<SysPackag>().First(m => m.IsDel == "0" && m.PackagNo == detail.PackagNo); // liudl 鐢盨ku鍖呰缂栧彿鍙樻洿涓哄叆搴撳崟鏄庣粏鍖呰缂栧彿 + + var pNum = 0;//鎵樼洏鐗╁搧鏁伴噺 + var bNum = 0;//绠辩爜鐗╁搧鏁伴噺 + + if (pack == null) + { + throw new Exception("鑾峰彇鐗╂枡鍖呰澶辫触锛岃鏍稿疄!"); + } + 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 || !detail.LotNo.Contains(box.LotNo))) + { + var funSetting = Db.Queryable<SysFunSetting>().First(a => a.IsDel == "0" && a.FunSetNo == "Fun045"); + if (funSetting == null || funSetting.IsEnable == "OFF") + { + throw new Exception($"涓嶅厑璁哥珛搴撳悓鎵樼洏涓嶅悓鐗╂枡鍏ュ簱鎴栧悓鎵樼洏涓嶅悓鎵规鍏ュ簱锛�"); + } + } + } + #endregion + //liudl && m.Status != "2" 缁勭洏鏃㈠叆搴撳畬鎴愭棤闇�鏍规嵁鎵樼洏鐘舵�佸垽鏂� + 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, + + Qty = model.SkuQty, + FullQty = pNum, + Status = "2",//鍏ュ簱瀹屾垚 + Type = "0", + LotNo = model.LotNo, + LotText = detail.LotText, + SupplierLot = detail.SupplierLot, + //InspectMark = model.IsSample, //鏄惁鍙栨牱鎵樼洏 鍚庢湡涓氬姟寮�鍙戞椂 鎺ュ彛浼犲�奸渶娣诲姞瀵瑰簲瀛楁鍒ゆ柇 + //SamplingQty = 0, //鍙栨牱鏁伴噺 鍚庢湡涓氬姟寮�鍙戞椂 鎺ュ彛浼犲�奸渶娣诲姞瀵瑰簲瀛楁鍒ゆ柇 + BitPalletMark = "1", + IsBale = "0", + IsBelt = "0", + CreateUser = userId, + Demo = model.Demo, + + }; + // 鎻掑叆鎵樼洏缁戝畾琛� + bindId = Db.Insertable(bind).ExecuteReturnIdentity(); + } + else + { + bindId = bind.Id; + bind.Qty += model.SkuQty; + } + if (bind.Qty < 0) + { + throw new Exception("缁勭洏鏁伴噺涓嶈兘灏忎簬0"); + } + #region 搴撳瓨鏄庣粏 + //鑾峰彇璇ユ壒娆℃渶缁堣川妫�缁撴灉 + BllQualityInspect quality = new BllQualityInspect(); + //鍒ゆ柇鏄惁涓洪��璐у叆搴撳崟 + if (notice.Type == "3") + { + quality = Db.Queryable<BllQualityInspect>().Where(a => a.IsDel == "0" && a.ASNNo == detail.ASNNo && a.SkuNo == detail.SkuNo && a.LotNo == detail.LotNo).OrderByDescending(a => a.CreateTime).First(); + } + else + { + quality = Db.Queryable<BllQualityInspect>().Where(a => a.IsDel == "0" && a.SkuNo == detail.SkuNo && a.LotNo == detail.LotNo).OrderByDescending(a => a.CreateTime).First(); + } + var tags = "0"; + if (notice.Type == "3" || notice.Type == "4") + { + tags = "1"; + } + + // 鍒ゆ柇搴撳瓨鏄庣粏鏄惁宸叉湁姝ゆ墭鐩樹俊鎭� + var sd1 = Db.Queryable<DataStockDetail>() + .First(m => m.IsDel == "0" && m.ASNDetailNo == bind.ASNDetailNo && m.PalletNo == model.PalletNo); + var sdId1 = 0; + if (sd1 != null) + { + sdId1 = sd1.Id; + // 搴撳瓨宸插瓨鍦� 鏇存柊鏁版嵁 + sd1.Qty = bind.Qty; + sd1.CompleteTime = comTime; + sd1.UpdateUser = userId; + sd1.UpdateTime = comTime; + + Db.Updateable(sd1).ExecuteCommand(); //淇敼璐ㄦ淇℃伅 + } + else + { + // 搴撳瓨涓嶅瓨鍦� 鎻掑叆鏁版嵁 + sd1 = new DataStockDetail() + { + LotNo = bind.LotNo, + LotText = bind.LotText, + SupplierLot = bind.SupplierLot, + SkuNo = sku.SkuNo, + SkuName = sku.SkuName, + Standard = sku.Standard, + Qty = bind.Qty, + LockQty = 0, + FrozenQty = 0, + InspectQty = 0, + ASNNo = bind.ASNNo, + ASNDetailNo = bind.ASNDetailNo, + WareHouseNo = "",//鎵�灞炰粨搴� + RoadwayNo = "",//鎵�灞炲贩閬� + AreaNo = "",//鎵�灞炲尯鍩� + LocatNo = "",//鍌ㄤ綅鍦板潃 + PalletNo = bind.PalletNo, + PalletNo2 = bind.PalletNo2, + PalletNo3 = bind.PalletNo3, + PalletTags = tags, + CompleteTime = comTime, + ProductionTime = bind.ProductionTime, + ExpirationTime = bind.ExpirationTime, + Status = "0", + InspectMark = bind.InspectMark, + InspectStatus = sku.IsInspect, + BitPalletMark = bind.BitPalletMark, + PackagNo = detail.PackagNo, //liudl 鐢眘ku鐨勫寘瑁呯紪鍙峰彉涓哄叆搴撳崟鏄庣粏鐨勫寘瑁呯紪鐮� + IsBale = bind.IsBale, + IsBelt = bind.IsBelt, + + IsDel = "0", + CreateUser = 0, + CreateTime = comTime + }; + + //缁存姢搴撳瓨鏄庣粏璐т富/渚涘簲鍟嗕俊鎭� + if (notice.Type == "0" || notice.Type == "2" || notice.Type == "4" || notice.Type == "6" || notice.Type == "7")//0:鎴愬搧鍏ュ簱锛�2:涓棿鍝佸叆搴�,4:杞﹂棿浣欐枡鍏ュ簱,6:浠e偍鍏ュ簱,7:瀵勫瓨鍏ュ簱 + { + sd1.OwnerNo = notice.CustomerNo;//璐т富缂栫爜 + sd1.OwnerName = notice.CustomerName;//璐т富鍚嶇О + } + else if (notice.Type == "1" || notice.Type == "5")//1:閲囪喘鍏ュ簱,2:鍏跺畠鍏ュ簱 + { + sd1.SupplierNo = notice.CustomerNo;//渚涘簲鍟嗙紪鐮� + sd1.SupplierName = notice.CustomerName;//渚涘簲鍟嗗悕绉� + } + if (quality != null) + { + //淇敼鍚堟牸涓嶅悎鏍兼暟閲� + if (quality.IsQualified == "1") //鍚堟牸 + { + //澧炲姞鍚堟牸鏁伴噺 + quality.PassQty += bind.Qty; + sd1.InspectStatus = "1"; + } + else if (quality.IsQualified == "0") //涓嶅悎鏍� + { + //澧炲姞涓嶅悎鏍兼暟閲� + quality.FailQty += bind.Qty; + sd1.InspectStatus = "2"; + } + Db.Updateable(quality).ExecuteCommand(); //淇敼璐ㄦ淇℃伅 + } + //娣诲姞搴撳瓨鏄庣粏 + sdId1 = Db.Insertable(sd1).ExecuteReturnIdentity(); + } + #endregion + + #region 绠辩爜淇℃伅 + var msgStr = $"绠卞彿涓簕model.BoxNo}"; + var boxInfoList = new List<BllBoxInfo>(); + + //棣栫 + var boxInfo = Db.Queryable<BllBoxInfo>().Where(m => m.IsDel == "0" && m.BoxNo == model.BoxNo).ToList(); + if (boxInfo.Count == 0) + { + throw new Exception("绠辩爜淇℃伅涓嶅瓨鍦�!"); + } + boxInfo = boxInfo.Where(m => m.Status == "0").ToList(); + if (boxInfo.Count == 0) + { + throw new Exception("绠辩爜宸茶浣跨敤!"); + } + boxInfoList.AddRange(boxInfo); + //鏄惁杩炵画缁勬墭 + if (model.IsContinue == "1") + { + //灏剧 + var boxInfo2 = Db.Queryable<BllBoxInfo>().Where(m => m.IsDel == "0" && m.BoxNo == model.TailBoxNo).ToList(); + if (boxInfo2.Count == 0) + { + throw new Exception("灏剧鐮佷俊鎭笉瀛樺湪!"); + } + boxInfo2 = boxInfo2.Where(m => m.Status == "0").ToList(); + if (boxInfo2.Count == 0) + { + throw new Exception("灏剧绠辩爜宸茶浣跨敤!"); + } + 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;//鎵樼洏鎬绘暟閲� + var isSample = "0";//鏄惁鍙栨牱 + var sampleQty = 0m;//鍙栨牱鏁伴噺 + + + var boxGroup = boxInfoList.GroupBy(m => m.BoxNo).ToList(); + foreach (var g in boxGroup) + { + decimal 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 = "2"; + //box.InspectMark = model.IsSample; //鏄惁鍙栨牱鎵樼洏 鍚庢湡涓氬姟寮�鍙戞椂 鎺ュ彛浼犲�奸渶娣诲姞瀵瑰簲瀛楁鍒ゆ柇 + //box.SamplingQty = 0; //鍙栨牱鏁伴噺 鍚庢湡涓氬姟寮�鍙戞椂 鎺ュ彛浼犲�奸渶娣诲姞瀵瑰簲瀛楁鍒ゆ柇 + box.CompleteTime = comTime; + box.UpdateTime = comTime; + box.UpdateUser = userId; + + //box.Qty = box.Qty; + //box.BitBoxMark = box.Qty == box.FullQty ? "0" : "1"; + + factQty += box.Qty; + boxFullQty += box.Qty; + if (box.InspectMark == "1") //鍒ゆ柇鏄惁鍙栨牱 + { + isSample = "1"; + sampleQty += (decimal)box.SamplingQty; + } + + #region 搴撳瓨绠辩爜鏄庣粏 + var box2 = new DataBoxInfo() + { + StockDetailId = sdId1, + BindNo = bind.Id, + BoxNo = box.BoxNo, + BoxNo2 = box.BoxNo2, + BoxNo3 = box.BoxNo3, + PalletNo = box.PalletNo, + PalletNo2 = box.PalletNo2, + PalletNo3 = box.PalletNo3, + Qty = box.Qty, + FullQty = box.FullQty, + Status = "2",//0锛氭湭缁勬墭 1锛氬凡缁勬墭 2锛氬凡鍏ュ簱 3锛氬凡鍑哄簱 4:宸插垎閰� 5锛氬凡鎷h揣 + LotNo = box.LotNo, + LotText = box.LotText, + SkuNo = box.SkuNo, + SkuName = box.SkuName, + Standard = sku.Standard, + ProductionTime = box.ProductionTime, + SupplierLot = box.SupplierLot, + InspectStatus = sku.IsInspect, + InspectMark = box.InspectMark, + BitBoxMark = box.BitBoxMark, + ExpirationTime = box.ExpirationTime, + + CreateUser = 0, + CreateTime = comTime + }; + //娣诲姞搴撳瓨绠辩爜鏄庣粏 + Db.Insertable(box2).ExecuteCommand(); + #endregion + } + if (boxFullQty > bNum) + { + throw new Exception($"缁戝畾澶辫触锛寋g.Key}绠辩爜缁戝畾鏁伴噺澶т簬璇ョ墿鍝佸寘瑁呮暟閲忥紒"); + } + } + Db.Updateable(boxInfoList).ExecuteCommand(); + + // 鏇存柊鎵樼洏缁戝畾琛� + bind.Qty += factQty; + + //if (bind.FullQty < bind.Qty && isTextTable == 0) + if (bind.FullQty < bind.Qty) + { + throw new Exception("鎵樼洏缁戝畾鏁伴噺宸茶秴鍑鸿鐗╂枡鍖呰鏁伴噺"); + } + + if (bind.FullQty == bind.Qty) + { + bind.BitPalletMark = "0"; + sd1.BitPalletMark = "0"; + } + //if (bind.Qty > pNum && isTextTable == 0) + if (bind.Qty > pNum) + { + throw new Exception($"缁戝畾澶辫触锛寋bind.PalletNo}鎵樼洏缁戝畾鏁伴噺澶т簬璇ョ墿鍝佹墭鐩樺寘瑁呮暟閲忥紒"); + } + + if (isSample == "1") + { + bind.InspectMark = "1"; + bind.SamplingQty = bind.SamplingQty == null ? sampleQty : bind.SamplingQty + sampleQty; + } + Db.Updateable(bind).Where(m => m.Id == bindId).ExecuteCommand(); + + #region 鍏ュ簱鍗曞強鏄庣粏 + decimal addQty = factQty; + + detail.FactQty += addQty;//宸茬粍鏁伴噺 + detail.CompleteQty += addQty;//瀹屾垚鏁伴噺 + if (isSample == "1") //鍚庢湡涓氬姟寮�鍙戞椂 鎺ュ彛浼犲�兼敼涓哄垽鏂槸鍚﹀彇鏍� + { + detail.IsSampling = "1"; + } + detail.Status = "1";//0锛氱瓑寰呮墽琛� 1锛氭鍦ㄦ墽琛� 2锛氭墽琛屽畬鎴� + if (detail.CompleteQty >= detail.Qty) + { + detail.Status = "2"; + detail.CompleteTime = comTime; + } + detail.UpdateUser = userId; + detail.UpdateTime = comTime; + //鏇存柊鍏ュ簱鍗曟槑缁� + Db.Updateable(detail).ExecuteCommand(); + + notice.UpdateUser = userId; + notice.UpdateTime = comTime; + if (notice.Status == "0") + { + notice.Status = "1"; + } + var asnDetailNum = Db.Queryable<BllArrivalNoticeDetail>() + .Count(m => m.IsDel == "0" && m.ASNNo == detail.ASNNo && m.Status != "2"); + if (asnDetailNum == 0) + { + notice.Status = "2"; + notice.CompleteTime = comTime;//瀹屾垚鏃堕棿 + } + //鏇存柊鍏ュ簱鍗� + Db.Updateable(notice).ExecuteCommand(); + #endregion + + #region 搴撳瓨鏄庣粏 + sd1.Qty = bind.Qty; + //鏇存敼搴撳瓨鏄庣粏鏁伴噺 + Db.Updateable(sd1).Where(m => m.Id == sdId1).ExecuteCommand(); + #endregion + + #region 搴撳瓨 + var dataStock = Db.Queryable<DataStock>().First(m => m.IsDel == "0" && m.SkuNo == sku.SkuNo && m.LotNo == bind.LotNo); + if (dataStock != null) + { + dataStock.Qty += factQty; + + if (bind.InspectMark == "1") + { + dataStock.IsSampling = bind.InspectMark; + } + Db.Updateable(dataStock).ExecuteCommand(); + } + else + { + var stock = new DataStock() + { + SkuNo = sku.SkuNo, + SkuName = sku.SkuName, + Standard = sku.Standard, + LotNo = bind.LotNo, + LotText = bind.LotText, + Qty = bind.Qty, + LockQty = 0, + FrozenQty = 0, + IsSampling = bind.InspectMark, + IsDel = "0", + CreateUser = userId, + CreateTime = comTime + }; + //缁存姢搴撳瓨璐т富淇℃伅 + if (notice.Type == "0" || notice.Type == "2" || notice.Type == "4" || notice.Type == "6" || notice.Type == "7")//0:鎴愬搧鍏ュ簱锛�2:涓棿鍝佸叆搴�,4:杞﹂棿浣欐枡鍏ュ簱,6:浠e偍鍏ュ簱,7:瀵勫瓨鍏ュ簱 + { + stock.OwnerNo = notice.CustomerNo;//璐т富缂栫爜 + stock.OwnerName = notice.CustomerName;//璐т富鍚嶇О + } + Db.Insertable(stock).ExecuteCommand(); + } + #endregion + + #region 璐ㄦ璇烽獙 + if ((notice.Type == "1" || notice.Type == "4" || notice.Type == "5") && sku.IsInspect != "1") + { + var qualityRequest = Db.Queryable<BllQualityInspectionRequest>().First(m => m.IsDel == "0" && m.SkuNo == sku.SkuNo && m.LotNo == bind.LotNo && m.SupplierLot == bind.SupplierLot); + if (qualityRequest == null) + { + string qcNo = new Common().GetMaxNo("QC"); + qualityRequest = new BllQualityInspectionRequest(); + qualityRequest.QcNo = qcNo; + qualityRequest.Status = "0"; + qualityRequest.SkuNo = sku.SkuNo; + qualityRequest.SkuName = sku.SkuName; + qualityRequest.LotNo = bind.LotNo; + qualityRequest.SupplierLot = bind.SupplierLot; + qualityRequest.Qty = detail.Qty; + qualityRequest.SamplingQty = 0; + qualityRequest.ASNNo = detail.ASNNo; + qualityRequest.CreateUser = userId; + qualityRequest.CreateTime = comTime; + //娣诲姞璐ㄦ璇烽獙鍗� + Db.Insertable(qualityRequest).ExecuteCommand(); + } + } + #endregion + + // 鏇存敼鎵樼洏浣跨敤鐘舵�� + 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 e) + { + Db.RollbackTran(); + throw new Exception(e.Message); + } + } + + + //JC26缁戝畾鎵樼洏 涓嶈创鏍囩墿鏂� + public void BindPalletNoPasteCode(PdaPalletBindVm model, int userId) + { + + #region 鍒ゆ柇 + + //0锛氭垚鍝佸叆搴� 1锛氶噰璐叆搴� 3锛氶��璐у叆搴� 4锛氳溅闂翠綑鏂欏叆搴� 5锛氬叾瀹冨叆搴� 6锛氫唬鍌ㄥ叆搴� + var TypeLot = "5, 6"; + + if (string.IsNullOrEmpty(model.AsnNo)) + { + throw new Exception("鍗曟嵁鍙蜂笉鍙负绌�!"); + } + if (model.AsnDetailId == null || model.AsnDetailId == 0) + { + throw new Exception("鐗╂枡涓嶅彲涓虹┖!"); + } + if (string.IsNullOrEmpty(model.PalletNo)) + { + throw new Exception("鎵樼洏鍙蜂笉鍙负绌�!"); + } + if (model.SkuQty < 0) + { + throw new Exception("鐗╂枡鏁伴噺涓嶈兘灏忎簬0!"); + } + //鏍规嵁鍗曟嵁鍙疯幏鍙栧叆搴撳崟鎬诲崟 + var notice = Db.Queryable<BllArrivalNotice>().First(a => a.IsDel == "0" && a.ASNNo == model.AsnNo); + if (notice.Status != "0" && notice.Status != "1" && notice.Status != "2") + { + throw new Exception("璇ュ崟鎹凡鍏冲崟!"); + } + + if (string.IsNullOrEmpty(model.LotNo)) + { + throw new Exception("鐗╂枡鎵规涓嶄负绌�!"); + } + else + { + //浠庣墿鏂欏悕绉�-鎵规涓彇鍑烘壒娆� + int indexOfDash = model.LotNo.IndexOf("-"); + if (indexOfDash != -1) + { + model.LotNo = model.LotNo.Substring(indexOfDash + 1); + } + else + { + if (!TypeLot.Contains(notice.Type)) + { + throw new Exception("鐗╂枡鎵规涓嶅彲涓虹┖!"); + } + + model.LotNo = ""; + } + } + + //int isTextTable = model.TableType; + #endregion + + var comTime = DateTime.Now; + + //鎵樼洏鏄惁瀛樺湪 + 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 && m.LotNo.Contains(model.LotNo)); + if (detail == 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("璇ユ墭鐩樺凡鏈夊偍浣嶄俊鎭紝璇锋牳瀹烇紒"); + } + if (stockDetail != null && (stockDetail.SkuNo != detail.SkuNo || stockDetail.LotNo != model.LotNo)) + { + throw new Exception("璇ユ墭鐩樺湪搴撳瓨宸叉湁鍏跺畠鐗╂枡鎵规淇℃伅锛岃鏍稿疄锛�"); + } + + #region 鍖呰 + var sku = Db.Queryable<SysMaterials>().First(m => m.IsDel == "0" && m.SkuNo == detail.SkuNo); + var pack = Db.Queryable<SysPackag>().First(m => m.IsDel == "0" && m.PackagNo == detail.PackagNo); // liudl 鐢盨ku鍖呰缂栧彿鍙樻洿涓哄叆搴撳崟鏄庣粏鍖呰缂栧彿 + + var pNum = 0;//鎵樼洏鐗╁搧鏁伴噺 + var bNum = 0;//绠辩爜鐗╁搧鏁伴噺 + + if (pack == null) + { + throw new Exception("鑾峰彇鐗╂枡鍖呰澶辫触锛岃鏍稿疄!"); + } + 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 || !detail.LotNo.Contains(box.LotNo))) + { + var funSetting = Db.Queryable<SysFunSetting>().First(a => a.IsDel == "0" && a.FunSetNo == "Fun045"); + if (funSetting == null || funSetting.IsEnable == "OFF") + { + throw new Exception($"涓嶅厑璁哥珛搴撳悓鎵樼洏涓嶅悓鐗╂枡鍏ュ簱鎴栧悓鎵樼洏涓嶅悓鎵规鍏ュ簱锛�"); + } + } + } + #endregion + //liudl && m.Status != "2" 缁勭洏鏃㈠叆搴撳畬鎴愭棤闇�鏍规嵁鎵樼洏鐘舵�佸垽鏂� + 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, + + Qty = model.SkuQty, + FullQty = pNum, + Status = "2",//鍏ュ簱瀹屾垚 + Type = "0", + LotNo = model.LotNo, + LotText = detail.LotText, + SupplierLot = detail.SupplierLot, + //InspectMark = model.IsSample, //鏄惁鍙栨牱鎵樼洏 鍚庢湡涓氬姟寮�鍙戞椂 鎺ュ彛浼犲�奸渶娣诲姞瀵瑰簲瀛楁鍒ゆ柇 + //SamplingQty = 0, //鍙栨牱鏁伴噺 鍚庢湡涓氬姟寮�鍙戞椂 鎺ュ彛浼犲�奸渶娣诲姞瀵瑰簲瀛楁鍒ゆ柇 + BitPalletMark = "1", + IsBale = "0", + IsBelt = "0", + CreateUser = userId, + Demo = model.Demo, + + }; + // 鎻掑叆鎵樼洏缁戝畾琛� + bindId = Db.Insertable(bind).ExecuteReturnIdentity(); + } + else + { + bindId = bind.Id; + bind.Qty += model.SkuQty; + } + if (bind.Qty < 0) + { + throw new Exception("缁勭洏鏁伴噺涓嶈兘灏忎簬0"); + } + + #region 搴撳瓨鏄庣粏 + //鑾峰彇璇ユ壒娆℃渶缁堣川妫�缁撴灉 + BllQualityInspect quality = new BllQualityInspect(); + //鍒ゆ柇鏄惁涓洪��璐у叆搴撳崟 + if (notice.Type == "3") + { + quality = Db.Queryable<BllQualityInspect>().Where(a => a.IsDel == "0" && a.ASNNo == detail.ASNNo && a.SkuNo == detail.SkuNo && a.LotNo == detail.LotNo).OrderByDescending(a => a.CreateTime).First(); + } + else + { + quality = Db.Queryable<BllQualityInspect>().Where(a => a.IsDel == "0" && a.SkuNo == detail.SkuNo && a.LotNo == detail.LotNo).OrderByDescending(a => a.CreateTime).First(); + } + var tags = "0"; + if (notice.Type == "3" || notice.Type == "4") + { + tags = "1"; + } + + // 鍒ゆ柇搴撳瓨鏄庣粏鏄惁宸叉湁姝ゆ墭鐩樹俊鎭� + var sd1 = Db.Queryable<DataStockDetail>() + .First(m => m.IsDel == "0" && m.ASNDetailNo == bind.ASNDetailNo && m.PalletNo == model.PalletNo && m.LotNo == bind.LotNo); + var sdId1 = 0; + if (sd1 != null) + { + sdId1 = sd1.Id; + // 搴撳瓨宸插瓨鍦� 鏇存柊鏁版嵁 + sd1.Qty = bind.Qty; + sd1.CompleteTime = comTime; + sd1.UpdateUser = userId; + sd1.UpdateTime = comTime; + + Db.Updateable(sd1).ExecuteCommand(); //淇敼璐ㄦ淇℃伅 + } + else + { + // 搴撳瓨涓嶅瓨鍦� 鎻掑叆鏁版嵁 + sd1 = new DataStockDetail() + { + LotNo = bind.LotNo, + LotText = bind.LotText, + SupplierLot = bind.SupplierLot, + SkuNo = sku.SkuNo, + SkuName = sku.SkuName, + Standard = sku.Standard, + Qty = bind.Qty, + LockQty = 0, + FrozenQty = 0, + InspectQty = 0, + ASNNo = bind.ASNNo, + ASNDetailNo = bind.ASNDetailNo, + WareHouseNo = "",//鎵�灞炰粨搴� + RoadwayNo = "",//鎵�灞炲贩閬� + AreaNo = "",//鎵�灞炲尯鍩� + LocatNo = "",//鍌ㄤ綅鍦板潃 + PalletNo = bind.PalletNo, + PalletNo2 = bind.PalletNo2, + PalletNo3 = bind.PalletNo3, + PalletTags = tags, + CompleteTime = comTime, + ProductionTime = bind.ProductionTime, + ExpirationTime = bind.ExpirationTime, + Status = "0", + InspectMark = bind.InspectMark, + InspectStatus = sku.IsInspect, + BitPalletMark = bind.BitPalletMark, + PackagNo = detail.PackagNo, //liudl 鐢眘ku鐨勫寘瑁呯紪鍙峰彉涓哄叆搴撳崟鏄庣粏鐨勫寘瑁呯紪鐮� + IsBale = bind.IsBale, + IsBelt = bind.IsBelt, + + IsDel = "0", + CreateUser = 0, + CreateTime = comTime + }; + + //缁存姢搴撳瓨鏄庣粏璐т富/渚涘簲鍟嗕俊鎭� + if (notice.Type == "0" || notice.Type == "2" || notice.Type == "4" || notice.Type == "6" || notice.Type == "7")//0:鎴愬搧鍏ュ簱锛�2:涓棿鍝佸叆搴�,4:杞﹂棿浣欐枡鍏ュ簱,6:浠e偍鍏ュ簱,7:瀵勫瓨鍏ュ簱 + { + sd1.OwnerNo = notice.CustomerNo;//璐т富缂栫爜 + sd1.OwnerName = notice.CustomerName;//璐т富鍚嶇О + } + else if (notice.Type == "1" || notice.Type == "5")//1:閲囪喘鍏ュ簱,2:鍏跺畠鍏ュ簱 + { + sd1.SupplierNo = notice.CustomerNo;//渚涘簲鍟嗙紪鐮� + sd1.SupplierName = notice.CustomerName;//渚涘簲鍟嗗悕绉� + } + if (quality != null) + { + //淇敼鍚堟牸涓嶅悎鏍兼暟閲� + if (quality.IsQualified == "1") //鍚堟牸 + { + //澧炲姞鍚堟牸鏁伴噺 + quality.PassQty += bind.Qty; + sd1.InspectStatus = "1"; + } + else if (quality.IsQualified == "0") //涓嶅悎鏍� + { + //澧炲姞涓嶅悎鏍兼暟閲� + quality.FailQty += bind.Qty; + sd1.InspectStatus = "2"; + } + Db.Updateable(quality).ExecuteCommand(); //淇敼璐ㄦ淇℃伅 + } + //娣诲姞搴撳瓨鏄庣粏 + sdId1 = Db.Insertable(sd1).ExecuteReturnIdentity(); + } + #endregion + + + + // 鏇存敼绠辨敮鍏崇郴琛� + + var isSample = "0";//鏄惁鍙栨牱 + var sampleQty = 0m;//鍙栨牱鏁伴噺 + + + //if (bind.FullQty < bind.Qty && isTextTable == 0) + if (bind.FullQty < bind.Qty) + { + throw new Exception("鎵樼洏缁戝畾鏁伴噺宸茶秴鍑鸿鐗╂枡鍖呰鏁伴噺"); + } + + if (bind.FullQty == bind.Qty) + { + bind.BitPalletMark = "0"; + sd1.BitPalletMark = "0"; + } + //if (bind.Qty > pNum && isTextTable == 0) + if (bind.Qty > pNum) + { + throw new Exception($"缁戝畾澶辫触锛寋bind.PalletNo}鎵樼洏缁戝畾鏁伴噺澶т簬璇ョ墿鍝佹墭鐩樺寘瑁呮暟閲忥紒"); + } + + if (isSample == "1") + { + bind.InspectMark = "1"; + bind.SamplingQty = bind.SamplingQty == null ? sampleQty : bind.SamplingQty + sampleQty; + } + Db.Updateable(bind).Where(m => m.Id == bindId).ExecuteCommand(); + + #region 鍏ュ簱鍗曞強鏄庣粏 + decimal addQty = model.SkuQty; + + detail.FactQty += addQty;//宸茬粍鏁伴噺 + detail.CompleteQty += addQty;//瀹屾垚鏁伴噺 + if (isSample == "1") //鍚庢湡涓氬姟寮�鍙戞椂 鎺ュ彛浼犲�兼敼涓哄垽鏂槸鍚﹀彇鏍� + { + detail.IsSampling = "1"; + } + detail.Status = "1";//0锛氱瓑寰呮墽琛� 1锛氭鍦ㄦ墽琛� 2锛氭墽琛屽畬鎴� + if (detail.CompleteQty >= detail.Qty) + { + detail.Status = "2"; + detail.CompleteTime = comTime; + } + detail.UpdateUser = userId; + detail.UpdateTime = comTime; + //鏇存柊鍏ュ簱鍗曟槑缁� + Db.Updateable(detail).ExecuteCommand(); + + notice.UpdateUser = userId; + notice.UpdateTime = comTime; + if (notice.Status == "0") + { + notice.Status = "1"; + } + var asnDetailNum = Db.Queryable<BllArrivalNoticeDetail>() + .Count(m => m.IsDel == "0" && m.ASNNo == detail.ASNNo && m.Status != "2"); + if (asnDetailNum == 0) + { + notice.Status = "2"; + notice.CompleteTime = comTime;//瀹屾垚鏃堕棿 + } + //鏇存柊鍏ュ簱鍗� + Db.Updateable(notice).ExecuteCommand(); + #endregion + + #region 搴撳瓨鏄庣粏 + sd1.Qty = bind.Qty; + //鏇存敼搴撳瓨鏄庣粏鏁伴噺 + Db.Updateable(sd1).Where(m => m.Id == sdId1).ExecuteCommand(); + #endregion + + #region 搴撳瓨 + var dataStock = Db.Queryable<DataStock>().First(m => m.IsDel == "0" && m.SkuNo == sku.SkuNo && m.LotNo == bind.LotNo); + if (dataStock != null) + { + dataStock.Qty += model.SkuQty; + + + if (bind.InspectMark == "1") + { + dataStock.IsSampling = bind.InspectMark; + } + Db.Updateable(dataStock).ExecuteCommand(); + } + else + { + var stock = new DataStock() + { + SkuNo = sku.SkuNo, + SkuName = sku.SkuName, + Standard = sku.Standard, + LotNo = bind.LotNo, + LotText = bind.LotText, + Qty = bind.Qty, + LockQty = 0, + FrozenQty = 0, + IsSampling = bind.InspectMark, + IsDel = "0", + CreateUser = userId, + CreateTime = comTime + }; + //缁存姢搴撳瓨璐т富淇℃伅 + if (notice.Type == "0" || notice.Type == "2" || notice.Type == "4" || notice.Type == "6" || notice.Type == "7")//0:鎴愬搧鍏ュ簱锛�2:涓棿鍝佸叆搴�,4:杞﹂棿浣欐枡鍏ュ簱,6:浠e偍鍏ュ簱,7:瀵勫瓨鍏ュ簱 + { + stock.OwnerNo = notice.CustomerNo;//璐т富缂栫爜 + stock.OwnerName = notice.CustomerName;//璐т富鍚嶇О + } + Db.Insertable(stock).ExecuteCommand(); + } + #endregion + + #region 璐ㄦ璇烽獙 + if ((notice.Type == "1" || notice.Type == "4" || notice.Type == "5") && sku.IsInspect != "1") + { + var qualityRequest = Db.Queryable<BllQualityInspectionRequest>().First(m => m.IsDel == "0" && m.SkuNo == sku.SkuNo && m.LotNo == bind.LotNo && m.SupplierLot == bind.SupplierLot); + if (qualityRequest == null) + { + string qcNo = new Common().GetMaxNo("QC"); + qualityRequest = new BllQualityInspectionRequest(); + qualityRequest.QcNo = qcNo; + qualityRequest.Status = "0"; + qualityRequest.SkuNo = sku.SkuNo; + qualityRequest.SkuName = sku.SkuName; + qualityRequest.LotNo = bind.LotNo; + qualityRequest.SupplierLot = bind.SupplierLot; + qualityRequest.Qty = detail.Qty; + qualityRequest.SamplingQty = 0; + qualityRequest.ASNNo = detail.ASNNo; + qualityRequest.CreateUser = userId; + qualityRequest.CreateTime = comTime; + //娣诲姞璐ㄦ璇烽獙鍗� + Db.Insertable(qualityRequest).ExecuteCommand(); + } + } + #endregion + + // 鏇存敼鎵樼洏浣跨敤鐘舵�� + 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}鐨勭粍鐩樹俊鎭�", userId); + + + + } + #endregion #region 骞冲簱鍏ュ簱 diff --git a/Wms/WMS.IBLL/IPdaServer/IPdaAsnServer.cs b/Wms/WMS.IBLL/IPdaServer/IPdaAsnServer.cs index a032bf4..06436ae 100644 --- a/Wms/WMS.IBLL/IPdaServer/IPdaAsnServer.cs +++ b/Wms/WMS.IBLL/IPdaServer/IPdaAsnServer.cs @@ -53,6 +53,20 @@ //JC23缁戝畾鐗╂枡鎵樼洏鍗冲鍔犲簱瀛� public void BindPalletStock(PdaPalletBindVm model, int userId, string origin); + /// <summary> + /// JC26缁戝畾鎵樼洏 璐存爣鐗╂枡 + /// </summary> + /// <param name="model"></param> + /// <param name="userId"></param> + void BindPalletPasteCode(PdaPalletBindVm model, int userId); + + /// <summary> + /// JC26缁戝畾鎵樼洏 涓嶈创鏍囩墿鏂� + /// </summary> + /// <param name="model"></param> + /// <param name="userId"></param> + void BindPalletNoPasteCode(PdaPalletBindVm model, int userId); + // 缁戝畾绌烘墭鐩� string BindNullPallet(PalletBindVm model); diff --git a/Wms/Wms/Controllers/PdaAsnController.cs b/Wms/Wms/Controllers/PdaAsnController.cs index 1eb2b37..2ae334d 100644 --- a/Wms/Wms/Controllers/PdaAsnController.cs +++ b/Wms/Wms/Controllers/PdaAsnController.cs @@ -6,6 +6,7 @@ using Model.ModelVm.PdaVm; using System; using System.Security.Claims; +using Utility; using WMS.Entity.BllAsnEntity; using WMS.IBLL.IPdaServer; @@ -569,6 +570,7 @@ /// <param name="model"></param> /// <returns></returns> [HttpPost] + [UnitOfWork] public IActionResult BindPallet(PdaPalletBindVm model) { try @@ -583,7 +585,7 @@ { throw new Exception("鏈幏鍙栧埌鐢ㄦ埛淇℃伅"); } - _PdaAsnSvc.BindPalletStock(model, int.Parse(UserId), model.Origin); + _PdaAsnSvc.BindPalletNoPasteCode(model, int.Parse(UserId)); return Ok(new { code = 0, msg = "缁戝畾鎴愬姛!" }); -- Gitblit v1.8.0