| | |
| | | using WMS.Entity.BllQualityEntity; |
| | | using WMS.Entity.Context; |
| | | using WMS.Entity.DataEntity; |
| | | using WMS.Entity.SysEntity; |
| | | using WMS.IBLL.IDataServer; |
| | | |
| | | namespace WMS.BLL.DataServer |
| | |
| | | /// <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; |
| | | } |
| | |
| | | } |
| | | } |
| | | #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 |
| | | } |
| | | } |