From 6cd2a2d6991f13ac11796abd11d61c098cdd3ce1 Mon Sep 17 00:00:00 2001 From: wxw <Administrator@DESKTOP-5BIMHQ3> Date: 星期六, 28 十二月 2024 08:32:39 +0800 Subject: [PATCH] 修改问题 --- Wms/WMS.BLL/DataServer/StockDetailServer.cs | 251 +++++++++++++++++++++++++------------------------- 1 files changed, 125 insertions(+), 126 deletions(-) diff --git a/Wms/WMS.BLL/DataServer/StockDetailServer.cs b/Wms/WMS.BLL/DataServer/StockDetailServer.cs index 732a837..f2f2563 100644 --- a/Wms/WMS.BLL/DataServer/StockDetailServer.cs +++ b/Wms/WMS.BLL/DataServer/StockDetailServer.cs @@ -9,6 +9,7 @@ using WMS.Entity.BllQualityEntity; using WMS.Entity.Context; using WMS.Entity.DataEntity; +using WMS.Entity.SysEntity; using WMS.IBLL.IDataServer; namespace WMS.BLL.DataServer @@ -37,146 +38,47 @@ /// <param name="bitBoxMark">闆剁鏍囪</param> /// <param name="inspectStatus">璐ㄩ噺鐘舵��</param> /// <returns></returns> - public List<StockDetailDto> GetBindList(string skuNo, string skuName, string palletNo, string lotNo, string boxNo, string status, string inspectMark, string bitPalletMark, string bitBoxMark, string inspectStatus, string ownerNo, string ownerName, string startTime, string endTime) + public List<StockDetailDto> GetBindList(string wareHouseName, string areaName, string locatNo, string palletNo, string lotNo) { - string str = "select detail.*,house.WareHouseNo + '-' + house.WareHouseName as WareHouseName,roadway.RoadwayNo + '-' + roadway.RoadwayName as RoadwayName,area.AreaNo + '-' + area.AreaName as AreaName from DataStockDetail detail left join SysStorageRoadway roadway on detail.RoadwayNo = roadway.RoadwayNo left join SysWareHouse house on detail.WareHouseNo = house.WareHouseNo left join SysStorageArea area on detail.AreaNo = area.AreaNo where detail.IsDel = @isdel"; - //鍒ゆ柇鐗╂枡鍙锋槸鍚︿负绌� - if (!string.IsNullOrEmpty(skuNo)) + string str = $@"select + detail.*, + house.WareHouseNo + '-' + house.WareHouseName as WareHouseName, + roadway.RoadwayNo + '-' + roadway.RoadwayName as RoadwayName, + area.AreaNo + '-' + area.AreaName as AreaName + from DataStockDetail detail + left join SysStorageRoadway roadway on detail.RoadwayNo = roadway.RoadwayNo + left join SysWareHouse house on detail.WareHouseNo = house.WareHouseNo + left join SysStorageArea area on detail.AreaNo = area.AreaNo + where detail.IsDel = '0'"; + + //鍒ゆ柇鎵�灞炰粨搴撴槸鍚︿负绌� + if (!string.IsNullOrEmpty(wareHouseName)) { - str += " and detail.SkuNo like @skuno"; + str += $" and (house.WareHouseNo like '%{wareHouseName}%' or house.WareHouseName like '%{wareHouseName}%')"; } - //鍒ゆ柇鐗╂枡鍚嶇О鏄惁涓虹┖ - if (!string.IsNullOrEmpty(skuName)) + //鍒ゆ柇鎵�灞炲尯鍩熸槸鍚︿负绌� + if (!string.IsNullOrEmpty(areaName)) { - str += " and detail.SkuName like @skuname"; + str += $" and (area.AreaNo like '%{areaName}%' or area.AreaName like '%{areaName}%')"; + } + //鍒ゆ柇鎵�灞炲偍浣嶆槸鍚︿负绌� + if (!string.IsNullOrEmpty(locatNo)) + { + str += $" and detail.LocatNo like '%{locatNo}%'"; } //鍒ゆ柇鎵樼洏鍙锋槸鍚︿负绌� if (!string.IsNullOrEmpty(palletNo)) { - str += " and detail.PalletNo like @palletno"; + str += $" and detail.PalletNo like '%{palletNo}%'"; } //鍒ゆ柇鎵规鏄惁涓虹┖ if (!string.IsNullOrEmpty(lotNo)) { - str += " and detail.LotNo like @lotno"; + str += $" and detail.LotNo like '%{lotNo}%'"; } - //鍒ゆ柇闆舵墭鏍囪鏄惁涓虹┖ - if (!string.IsNullOrEmpty(bitPalletMark)) - { - str += " and detail.BitPalletMark = @bitpalletmark"; - } - //鍒ゆ柇璐т富缂栫爜鏄惁涓虹┖ - if (!string.IsNullOrEmpty(ownerNo)) - { - str += " and detail.OwnerNo like @ownerNo"; - } - //鍒ゆ柇璐т富鍚嶇О鏄惁涓虹┖ - if (!string.IsNullOrEmpty(ownerName)) - { - str += " and detail.OwnerName like @ownerName"; - } - if (!string.IsNullOrEmpty(startTime)) - { - str += $" and detail.CompleteTime >= '{startTime}'"; - } - if (!string.IsNullOrEmpty(endTime)) - { - endTime = Convert.ToDateTime(endTime).AddDays(1).ToString(); - str += $" and detail.CompleteTime < '{endTime}'"; - } - - int i = 0; - //鍦ㄧ鐮佹槑缁嗕腑鑾峰彇鐩稿簲鏁版嵁 - string boxstr = "select StockDetailId from DataBoxInfo Where IsDel = @isdel"; - //鍒ゆ柇绠辩爜鏄惁涓虹┖ - if (!string.IsNullOrEmpty(boxNo)) - { - boxstr += " and BoxNo like @boxno"; - i = 1; - } - //鍒ゆ柇绠辨敮鐘舵�佹槸鍚︿负绌� - if (!string.IsNullOrEmpty(status)) - { - boxstr += " and Status = @status"; - i = 1; - } - //鍒ゆ柇妫�楠屾爣璁版槸鍚︿负绌� - if (!string.IsNullOrEmpty(inspectMark)) - { - boxstr += " and InspectMark = @inspectmark"; - str += " and detail.InspectMark = @inspectmark"; - i = 1; - } - //鍒ゆ柇闆剁鏍囪鏄惁涓虹┖ - if (!string.IsNullOrEmpty(bitBoxMark)) - { - boxstr += " and BitBoxMark = @bitboxmark"; - i = 1; - } - //鍒ゆ柇璐ㄩ噺鐘舵�佹槸鍚︿负绌� - if (!string.IsNullOrEmpty(inspectStatus)) - { - boxstr += " and InspectStatus = @inspectstatus"; - str += " and detail.InspectStatus = @inspectstatus"; - i = 1; - } - //灏嗙鐮佹暟鎹繘琛屾帓搴� - boxstr += " order by StockDetailId"; - //鏌ュ嚭绠辩爜鏄庣粏涓俊鎭� - List<int> stockDetailId = Db.Ado.SqlQuery<int>(boxstr, new - { - isdel = "0", //鏄惁鍒犻櫎 - boxno = "%" + boxNo + "%", //绠辩爜 - status, //绠辨敮鐘舵�� - inspectmark = inspectMark, //妫�楠屾爣璁� - bitboxmark = bitBoxMark, //闆剁鏍囪 - inspectstatus = inspectStatus //璐ㄩ噺鐘舵�� - }); - //鍘婚噸 - // List<int> newArr = null; - string arr = ""; - //鍒ゆ柇鏄惁鏈夋煡绠辩爜淇℃伅 - if (i == 1) - { - if (stockDetailId.Count > 0) - { - //鍘婚噸 - arr += stockDetailId[0].ToString(); - - for (int a = 1; a < stockDetailId.Count; a++) - { - if (stockDetailId[a] != stockDetailId[a - 1]) - { - arr += ',' + stockDetailId[a].ToString(); - } - } - } - if (!string.IsNullOrEmpty(arr)) - { - str += $" and Id in ({arr})"; - } - else - { - str += " and Id = ''"; - } - } - //鎺掑簭 - str += " order by PalletNo,SkuNo,LotNo"; - List<StockDetailDto> boxInforList = Db.Ado.SqlQuery<StockDetailDto>(str, new - { - isdel = "0", //鏄惁鍒犻櫎 - skuno = "%" + skuNo + "%", //鐗╂枡鍙� - skuname = "%" + skuName + "%", //鐗╂枡鍚嶇О - palletno = "%" + palletNo + "%", //鎵樼洏 - lotno = "%" + lotNo + "%", //鎵规鍙� - bitpalletmark = bitPalletMark, //闆舵墭鏍囪 - inspectmark = inspectMark, //妫�楠屾爣璁� - inspectstatus = inspectStatus, //璐ㄩ噺鐘舵�� - ownerNo = "%" + ownerNo + "%", //璐т富缂栫爜 - ownerName = "%" + ownerName + "%" //璐т富鍚嶇О - //stockdetailid = "(" + arr + ")" //搴撳瓨鏄庣粏id - }); + str += " order by PalletNo"; + List<StockDetailDto> boxInforList = Db.Ado.SqlQuery<StockDetailDto>(str).ToList(); return boxInforList; } @@ -403,5 +305,102 @@ } } #endregion + + #region 浜屾ゼ涓氬姟 + /// <summary> + /// 娣诲姞鎵樼洏搴撳瓨鏄庣粏 + /// </summary> + public void InsertStockDetail(string PalletNo,string WareHouseNo,string AreaNo,string LocatNo, string PalletStatus, string SkuNo, string SkuName, string LotNo, int userId) + { + try + { + if (string.IsNullOrEmpty(PalletNo)) + { + throw new Exception("鎵樼洏鍙蜂笉鑳戒负绌�!"); + } + if (string.IsNullOrEmpty(WareHouseNo)) + { + throw new Exception("鎵�灞炰粨搴撲笉鑳戒负绌�!"); + } + if (string.IsNullOrEmpty(AreaNo)) + { + throw new Exception("鎵�灞炲尯鍩熶笉鑳戒负绌�!"); + } + if (string.IsNullOrEmpty(LocatNo)) + { + throw new Exception("鍌ㄤ綅鍦板潃涓嶈兘涓虹┖!"); + } + if (string.IsNullOrEmpty(PalletStatus)) + { + throw new Exception("鎵樼洏鐘舵�佷笉鑳戒负绌�!"); + } + var palletInfo = Db.Queryable<DataStockDetail>().First(w => w.PalletNo == PalletNo); + if (palletInfo != null) + { + throw new Exception($"搴撳瓨涓凡鏈夌紪鍙蜂负锛歿PalletNo}鐨勬槑缁嗭紝璇峰嬁閲嶅娣诲姞!"); + } + //鐩爣鍌ㄤ綅淇℃伅 + var locatInfo = Db.Queryable<SysStorageLocat>().First(w => w.LocatNo == LocatNo && w.Status == "0" && w.IsDel == "0"); + if (locatInfo == null) + { + throw new Exception("鍌ㄤ綅鍦板潃涓嶅瓨鍦�!"); + } + + Db.BeginTran(); + + var comTime = DateTime.Now; + var model = new DataStockDetail() + { + Qty = 0, + LockQty = 0, + FrozenQty = 0, + InspectQty = 0, + WareHouseNo = WareHouseNo,//鎵�灞炰粨搴� + RoadwayNo = "",//鎵�灞炲贩閬� + AreaNo = AreaNo,//鎵�灞炲尯鍩� + LocatNo = LocatNo,//鍌ㄤ綅鍦板潃 + PalletNo = PalletNo, + PalletNo2 = "", + PalletNo3 = "", + PalletTags = "0", + CompleteTime = comTime, + ProductionTime = null, + ExpirationTime = null, + Status = "0", + InspectMark = "0", + InspectStatus = "0",//寰呮楠� + BitPalletMark = "0", + PackagNo = "", + IsBale = "0", + IsBelt = "0", + + SkuNo = SkuNo, + SkuName = SkuName, + LotNo = LotNo, + + PalletStatus = PalletStatus, + + IsDel = "0", + CreateUser = userId, + CreateTime = comTime + }; + //鎻掑叆搴撳瓨鏄庣粏 + Db.Insertable(model).ExecuteCommand(); + + locatInfo.Status = "1";//鏈夌墿鍝� + //淇敼鐩爣鍌ㄤ綅鐘舵�� + Db.Updateable(locatInfo).ExecuteCommand(); + + Db.CommitTran(); + } + catch (Exception e) + { + //鍥炴粴浜嬪姟 + Db.RollbackTran(); + throw new Exception(e.Message); + } + } + + #endregion } } -- Gitblit v1.8.0