| | |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Linq.Expressions; |
| | | using System.Runtime.Intrinsics.X86; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using Model.ModelDto.SysDto; |
| | | using Model.ModelVm.SysVm; |
| | | using SqlSugar; |
| | | using WMS.BLL.LogServer; |
| | | using WMS.DAL; |
| | | using WMS.Entity.BllAsnEntity; |
| | | using WMS.Entity.Context; |
| | | using WMS.Entity.DataEntity; |
| | | using WMS.Entity.SysEntity; |
| | | using WMS.IBLL.ILogServer; |
| | | using WMS.IBLL.ISysServer; |
| | | using WMS.IDAL.ISysInterface; |
| | | |
| | | namespace WMS.BLL.SysServer |
| | | { |
| | | public class StorageLocatServer:DbHelper<SysStorageLocat>,IStorageLocatServer |
| | | public class StorageLocatServer : DbHelper<SysStorageLocat>, IStorageLocatServer |
| | | { |
| | | private static readonly SqlSugarScope Db = DataContext.Db; |
| | | public IStorageLocatRepository LocatRst { get; set; } |
| | | public StorageLocatServer(IStorageLocatRepository locatRst):base(Db) |
| | | public StorageLocatServer(IStorageLocatRepository locatRst) : base(Db) |
| | | { |
| | | LocatRst = locatRst; |
| | | } |
| | |
| | | /// <param name="limit"></param> |
| | | /// <param name="count"></param> |
| | | /// <returns></returns> |
| | | public List<LocatDto> GetStorageLocatList(string houseNo, string roadwayNo, string areaNo, string status, string flag,string locat, int? row, int? col, int? layer, int page, int limit,out int count) |
| | | public List<LocatDto> GetStorageLocatList(string houseNo, string roadwayNo, string areaNo, string status, string flag, string locat, int? row, int? col, int? layer, int page, int limit, out int count) |
| | | { |
| | | try |
| | | { |
| | |
| | | .AndIF(layer != null, it => it.Layer == layer) |
| | | .ToExpression();//注意 这一句 不能少 |
| | | |
| | | |
| | | var data = LocatRst.GetAllByOrderPageAsync(item, limit, page,out int counts) |
| | | |
| | | var data = LocatRst.GetAllByOrderPageAsync(item, limit, page, out int counts) |
| | | .Includes(x => x.WareHouseInfo) |
| | | .Includes(x => x.AreaInfo) |
| | | .Includes(x => x.RoadwayInfo) |
| | | .Includes(x => x.TemperatureInfo) |
| | | .Includes(x => x.CreateUserInfo) |
| | | .Includes(x => x.UpdateUserInfo).ToList(); |
| | |
| | | { |
| | | Id = m.Id, |
| | | LocatNo = m.LocatNo, |
| | | WareHouseNo = m.WareHouseNo, |
| | | WareHouseName = m.WareHouseInfo == null ? "" : m.WareHouseInfo.WareHouseName, |
| | | RoadwayNo = m.RoadwayNo, |
| | | RoadwayName = m.RoadwayInfo == null ? "" : m.RoadwayInfo.RoadwayName, |
| | | AreaNo = m.AreaNo, |
| | | AreaName = m.AreaInfo == null ? "" : m.AreaInfo.AreaName, |
| | | Status = m.Status, |
| | | StatusName = GetStatus(m.Status), |
| | |
| | | try |
| | | { |
| | | var data = LocatRst.GetOneById(id); |
| | | //var data = Db.Queryable<SysStorageLocat>().First(m=>m.Id == id); |
| | | return data; |
| | | } |
| | | catch (Exception e) |
| | |
| | | throw; |
| | | } |
| | | } |
| | | public List<SysStorageLocat> GetStorageLocat(List<int> id) |
| | | { |
| | | try |
| | | { |
| | | var SysStorageLocats = new List<SysStorageLocat>(); |
| | | foreach (var item in id) |
| | | { |
| | | var storage = LocatRst.GetOneById(item); |
| | | SysStorageLocats.Add(storage); |
| | | } |
| | | return SysStorageLocats; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | Console.WriteLine(e); |
| | | throw; |
| | | } |
| | | } |
| | | |
| | | |
| | | public bool EditStorageLocat(EditLocateVm model, int userId) |
| | | { |
| | | try |
| | | { |
| | | var bl = LocatRst.EditStorageLocat(model.Id, model.Status, model.Flag, model.Temperature, userId); |
| | | var bl = LocatRst.EditStorageLocat(model.Id, model.Status, model.Flag, model.Temperature,model.Area, userId); |
| | | |
| | | return bl; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | { |
| | | throw new Exception(e.Message); |
| | | } |
| | | } |
| | |
| | | c1 = c.ToString(); |
| | | } |
| | | var area = l <= 7 ? "A12" : "A11";//区域 |
| | | for (int d = 1; d<= int.Parse(dept); d++) //深度 |
| | | for (int d = 1; d <= int.Parse(dept); d++) //深度 |
| | | { |
| | | var s = "0" + d;//深度 |
| | | q += await LocatRst.AddAsync(new SysStorageLocat() |
| | | { |
| | | LocatNo = r1 + c1 + l1+s, |
| | | LocatNo = r1 + c1 + l1 + s, |
| | | WareHouseNo = houseNo, |
| | | RoadwayNo = roadwayNo, |
| | | AreaNo = area, |
| | |
| | | CreateUser = userId |
| | | }); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | } |
| | | } |
| | |
| | | throw new Exception(e.Message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 添加储位信息(平库)用于开发人员添加基础信息 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <param name="userId"></param> |
| | | /// <returns></returns> |
| | | public async Task<int> AddPkStorageLocat(AddLocateVm model, int userId) |
| | | { |
| | | try |
| | | { |
| | | var q = 0; |
| | | // 排(组)循环 |
| | | for (int i = 1; i <= model.Row; i++) |
| | | { |
| | | // 列循环 |
| | | for (int z = 1; z <= model.Col; z++) |
| | | { |
| | | q += await LocatRst.AddAsync(new SysStorageLocat() |
| | | { |
| | | // 区域+排+列+层 |
| | | LocatNo = model.AreaNo + i.ToString().PadLeft(2, '0') + z.ToString().PadLeft(2, '0') + "01", |
| | | WareHouseNo = model.HouseNo, |
| | | RoadwayNo = "", |
| | | AreaNo = model.AreaNo, |
| | | Status = "0", |
| | | AisleOne = "1", |
| | | AisleTwo = "", |
| | | Flag = "0", |
| | | Depth = z.ToString(), |
| | | Row = i, |
| | | Column = z, |
| | | Layer = 1, |
| | | CreateUser = userId |
| | | }); ; |
| | | } |
| | | } |
| | | |
| | | return q; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | throw new Exception(e.Message); |
| | | } |
| | | } |
| | | |
| | | public bool EditStorageLocatList(EditLocateListVm model, int userId) |
| | | { |
| | | try |
| | | { |
| | | var bl = LocatRst.EditStorageLocatList(model.Id, model.Status, model.Flag,model.Temperature ,userId); |
| | | var bl = LocatRst.EditStorageLocatList(model.Id, model.Status, model.Flag, model.Temperature, userId); |
| | | |
| | | return bl; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | throw new Exception(e.Message); |
| | | } |
| | | } |
| | | public bool EditStorageLocatListNew(EditLocateListNewVm model, int userId) |
| | | { |
| | | try |
| | | { |
| | | if (string.IsNullOrWhiteSpace(model.RoadWayNo)) |
| | | { |
| | | throw new Exception("巷道不能为空"); |
| | | } |
| | | bool isRow = false; |
| | | if (model.Row != null) |
| | | { |
| | | if (model.Row <= 0) |
| | | { |
| | | throw new Exception("排需要大于0"); |
| | | } |
| | | isRow = true; |
| | | } |
| | | bool isColumn = false; |
| | | if (model.Column != null) |
| | | { |
| | | if (model.Column <= 0) |
| | | { |
| | | throw new Exception("列需要大于0"); |
| | | } |
| | | isColumn = true; |
| | | } |
| | | bool isLayer = false; |
| | | if (model.Layer != null ) |
| | | { |
| | | if (model.Column <= 0) |
| | | { |
| | | throw new Exception("层需要大于0"); |
| | | } |
| | | isLayer = true; |
| | | } |
| | | bool isDepth = false; |
| | | if (model.Dept != null) |
| | | { |
| | | if (model.Dept != 1 && model.Dept != 2) |
| | | { |
| | | throw new Exception("深度只能为1或2"); |
| | | } |
| | | isDepth = true; |
| | | } |
| | | Expression<Func<SysStorageLocat, bool>> item = Expressionable.Create<SysStorageLocat>() //创建表达式 |
| | | .AndIF(isRow, it => it.Row == model.Row) |
| | | .AndIF(isColumn, it => it.Column == model.Column) |
| | | .AndIF(isLayer, it => it.Layer == model.Layer) |
| | | .AndIF(isDepth, it => it.Depth == "0"+model.Dept) |
| | | .AndIF(!string.IsNullOrWhiteSpace(model.RoadWayNo), it => it.RoadwayNo == model.RoadWayNo) |
| | | .ToExpression();//注意 这一句 不能少 |
| | | var locateList = Db.Queryable<SysStorageLocat>().Where(item).ToList(); |
| | | if (locateList.Count == 0) |
| | | { |
| | | throw new Exception($"未查询到相对应的储位信息"); |
| | | } |
| | | |
| | | var com = new Common(); |
| | | var i = 0; |
| | | Db.BeginTran(); |
| | | foreach (var locate in locateList) |
| | | { |
| | | if (model.Flag == "2" && locate.Depth == "01")//标识是损坏且深度是01时 需把深度为2的储位给屏蔽 |
| | | { |
| | | var locate2 = com.GetLocateNoDepth2(locate.WareHouseNo, locate.LocatNo); |
| | | if (locate2.Flag == "0" && !locateList.Contains(locate2)) |
| | | { |
| | | locate2.Flag = "1"; |
| | | locate2.UpdateUser = userId; |
| | | locate2.UpdateTime = DateTime.Now; |
| | | var m = Db.Updateable(locate2).ExecuteCommand(); |
| | | } |
| | | |
| | | } |
| | | if (model.Flag == "0" && locate.Depth == "02")//标识是正常且深度是02时 需判断深度为1的储位状态是否正常 |
| | | { |
| | | var locate1 = com.GetLocateNoDepth1(locate.WareHouseNo, locate.LocatNo); |
| | | |
| | | if (locate1.Flag == "2") |
| | | { |
| | | throw new Exception($"需先修改{locate1.LocatNo}的储位标识为不是损坏"); |
| | | } |
| | | } |
| | | |
| | | if (!string.IsNullOrEmpty(model.Status)) |
| | | { |
| | | locate.Status = model.Status; |
| | | } |
| | | if (!string.IsNullOrEmpty(model.Flag)) |
| | | { |
| | | locate.Flag = model.Flag; |
| | | } |
| | | if (!string.IsNullOrEmpty(model.AreaNo)) |
| | | { |
| | | locate.AreaNo = model.AreaNo; |
| | | } |
| | | locate.UpdateUser = userId; |
| | | locate.UpdateTime = DateTime.Now; |
| | | i = Db.Updateable(locate).ExecuteCommand(); |
| | | } |
| | | Db.CommitTran(); |
| | | return i > 0; |
| | | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | Db.RollbackTran(); |
| | | throw new Exception(e.Message); |
| | | } |
| | | } |
| | |
| | | { |
| | | var list = Db.Queryable<SysStorageLocat>().Where(m => |
| | | m.IsDel == "0" && m.WareHouseNo == wareHouseNo && m.RoadwayNo == roadway && m.Row == int.Parse(row) && m.Depth == depth).ToList(); |
| | | |
| | | |
| | | return list; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | throw new Exception(e.Message); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | public int GetMaxLayer(string wareHouseNo, string roadway, string row) |
| | | { |
| | | try |
| | | { |
| | | { |
| | | var road = roadway.Substring(1, roadway.Length - 1); |
| | | var num = int.Parse(road); |
| | | var rows = (num - 1) * 2 + int.Parse(row);//排 |
| | | |
| | | var maxLayer = Db.Queryable<SysStorageLocat>().Where(m => |
| | | m.IsDel == "0" && m.WareHouseNo == wareHouseNo && m.RoadwayNo == roadway && m.Row == int.Parse(row)).Max(m=>m.Layer); |
| | | m.IsDel == "0" && m.WareHouseNo == wareHouseNo && m.RoadwayNo == roadway && m.Row == int.Parse(row)).Max(m => m.Layer); |
| | | |
| | | return maxLayer; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | throw new Exception(e.Message); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | return depthlist; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 获取库位占比(圆) |
| | |
| | | int b = 0; //1:有物品 |
| | | int c = 0; //2:入库中 |
| | | int d = 0; //3:出库中 |
| | | //int e = 0; //4:移入中 |
| | | //int f = 0; //5:移出中 |
| | | int e = 0; //4:移入中 |
| | | int f = 0; //5:移出中 |
| | | int g = 0; //6:损坏\屏蔽 |
| | | |
| | | foreach (var item in getLocateVms) |
| | |
| | | d = 1; //3:出库中 |
| | | continue; |
| | | } |
| | | ////4:移入中 |
| | | //if (item.Status == "4") |
| | | //{ |
| | | // e = 1; //4:移入中 |
| | | // continue; |
| | | //} |
| | | ////5:移出中 |
| | | //if (item.Status == "5") |
| | | //{ |
| | | // f = 1; //5:移出中 |
| | | // continue; |
| | | //} |
| | | //4:移入中 |
| | | if (item.Status == "4") |
| | | { |
| | | e = 1; //4:移入中 |
| | | continue; |
| | | } |
| | | //5:移出中 |
| | | if (item.Status == "5") |
| | | { |
| | | f = 1; //5:移出中 |
| | | continue; |
| | | } |
| | | //6:损坏\屏蔽 |
| | | if (item.Status == "6") |
| | | { |
| | |
| | | getLocateVm.Status = "3"; |
| | | getLocateVms.Add(getLocateVm); |
| | | } |
| | | ////4:移入中 |
| | | //if (e == 0) |
| | | //{ |
| | | // getLocateVm = new GetLocateVm(); |
| | | // getLocateVm.WareHouseNo = wareHouseNo; //仓库号 |
| | | // getLocateVm.StatusNum = "0"; |
| | | // getLocateVm.Status = "4"; |
| | | // getLocateVms.Add(getLocateVm); |
| | | //} |
| | | ////5:移出中 |
| | | //if (f == 0) |
| | | //{ |
| | | // getLocateVm = new GetLocateVm(); |
| | | // getLocateVm.WareHouseNo = wareHouseNo; //仓库号 |
| | | // getLocateVm.StatusNum = "0"; |
| | | // getLocateVm.Status = "5"; |
| | | // getLocateVms.Add(getLocateVm); |
| | | //} |
| | | //4:移入中 |
| | | if (e == 0) |
| | | { |
| | | getLocateVm = new GetLocateVm(); |
| | | getLocateVm.WareHouseNo = wareHouseNo; //仓库号 |
| | | getLocateVm.StatusNum = "0"; |
| | | getLocateVm.Status = "4"; |
| | | getLocateVms.Add(getLocateVm); |
| | | } |
| | | //5:移出中 |
| | | if (f == 0) |
| | | { |
| | | getLocateVm = new GetLocateVm(); |
| | | getLocateVm.WareHouseNo = wareHouseNo; //仓库号 |
| | | getLocateVm.StatusNum = "0"; |
| | | getLocateVm.Status = "5"; |
| | | getLocateVms.Add(getLocateVm); |
| | | } |
| | | //6:损坏\屏蔽 |
| | | if (g == 0) |
| | | { |
| | |
| | | { |
| | | //根据仓库号以及巷道号获取储位各状态数据 |
| | | string str = "select Row,Status,COUNT(Status) StatusNum from SysStorageLocat where WareHouseNo = @warehouseno and RoadwayNo = @roadwayno group by Row,Status order by Row,Status"; |
| | | |
| | | |
| | | List<GetLocateVm> getLocateVms = Db.Ado.SqlQuery<GetLocateVm>(str, new |
| | | { |
| | | warehouseno = wareHouseNo, //仓库号 |
| | |
| | | { |
| | | try |
| | | { |
| | | string str = "select RoadwayNo,RoadwayName from SysStorageRoadway where IsDel = @isdel and WareHouseNo = @warehouseno"; |
| | | |
| | | string str = "select RoadwayNo,RoadwayName,WareHouseNo from SysStorageRoadway where IsDel = @isdel"; |
| | | |
| | | if (!string.IsNullOrWhiteSpace(wareHouseNo)) |
| | | { |
| | | str += " and WareHouseNo = @warehouseno"; |
| | | } |
| | | |
| | | List<RoadwayDto> roadway = Db.Ado.SqlQuery<RoadwayDto>(str, new |
| | | { |
| | | isdel = "0", //是否删除 |
| | |
| | | try |
| | | { |
| | | LocateInfoVm model = new LocateInfoVm(); |
| | | string status = ""; |
| | | //储位信息 |
| | | SysStorageLocat storageLocat = Db.Queryable<SysStorageLocat>().First(w => w.LocatNo == locatNo && w.IsDel == "0"); |
| | | if (storageLocat == null) |
| | |
| | | throw new Exception("未找到对应储位"); |
| | | } |
| | | //有物品、出库中数据源(库存明细表) |
| | | if (storageLocat.Status == "1" || storageLocat.Status == "3") |
| | | if (storageLocat.Status == "1" || storageLocat.Status == "3" || storageLocat.Status == "5") |
| | | { |
| | | //库存明细 |
| | | List<DataStockDetail> stockDetailList = Db.Queryable<DataStockDetail>().Where(w => w.LocatNo == locatNo && w.IsDel == "0").ToList(); |
| | |
| | | model.LocatNo = locatNo; |
| | | model.Status = storageLocat.Status; |
| | | model.PalletNo = stockDetailList[0].PalletNo; |
| | | |
| | | |
| | | List<LocateGoodsInfoVm> goodsList = new List<LocateGoodsInfoVm>(); |
| | | foreach (var item in stockDetailList) |
| | | { |
| | |
| | | goodsModel.SkuName = item.SkuName; |
| | | goodsModel.LotNo = item.LotNo; |
| | | goodsModel.Qty = item.Qty; |
| | | switch (item.InspectStatus) |
| | | { |
| | | case "0": |
| | | status = "待检验"; |
| | | break; |
| | | case "1": |
| | | status = "合格"; |
| | | break; |
| | | case "2": |
| | | status = "不合格"; |
| | | break; |
| | | } |
| | | goodsModel.InspectStatus = status; |
| | | |
| | | goodsList.Add(goodsModel); |
| | | } |
| | |
| | | else if (storageLocat.Status == "2") |
| | | { |
| | | //托盘绑定信息 |
| | | List<BllPalletBind> palletBindList = Db.Queryable<BllPalletBind>().Where(w => w.LocatNo == locatNo && w.IsDel == "0").ToList(); |
| | | List<BllPalletBind> palletBindList = Db.Queryable<BllPalletBind>() |
| | | .Where(w => w.LocatNo == locatNo && w.IsDel == "0" && w.Status == "1").ToList(); |
| | | if (palletBindList == null || palletBindList.Count <= 0) |
| | | { |
| | | throw new Exception("未找到对应的托盘绑定信息"); |
| | |
| | | goodsModel.SkuName = noticeDetail.SkuName; |
| | | goodsModel.LotNo = noticeDetail.LotNo; |
| | | goodsModel.Qty = noticeDetail.Qty; |
| | | goodsModel.InspectStatus = "待检验"; |
| | | |
| | | goodsList.Add(goodsModel); |
| | | } |
| | |
| | | case "3": |
| | | model.Status = "出库中"; |
| | | break; |
| | | case "4": |
| | | model.Status = "移入中"; |
| | | break; |
| | | case "5": |
| | | model.Status = "移出中"; |
| | | break; |
| | | default: |
| | | model.Status = ""; |
| | | break; |
| | |
| | | throw new Exception(e.Message); |
| | | } |
| | | } |
| | | |
| | | #region 平库图例 |
| | | |
| | | /// <summary> |
| | | /// 获取储位信息(平库图例) |
| | | /// </summary> |
| | | /// <param name="wareHouseNo">仓库</param> |
| | | /// <param name="row">排</param> |
| | | /// <returns></returns> |
| | | public List<SysStorageLocat> GetFlatLibraryLegend(string wareHouseNo, string row) |
| | | { |
| | | try |
| | | { |
| | | //一楼区域 |
| | | //List<string> row1 = new List<string>() |
| | | //{ |
| | | // "B01", |
| | | // "B02", |
| | | // "B03", |
| | | // "B04", |
| | | // "B05", |
| | | // "B06", |
| | | // "B07", |
| | | //}; |
| | | ////二楼区域 |
| | | //List<string> row3 = new List<string>() |
| | | //{ |
| | | // "B11", |
| | | // "B12", |
| | | // "B13", |
| | | // "B14", |
| | | // "B15", |
| | | //}; |
| | | string row1 = "'B01','B02','B03','B04','B05','B06','B07'"; |
| | | string row3 = "'B11','B12','B13','B14','B15'"; |
| | | string str = $"select * from SysStorageLocat where IsDel = '0' and WareHouseNo = '{wareHouseNo}' and "; |
| | | if (row == "1") |
| | | { |
| | | str += $" AreaNo in ({row1})"; |
| | | } |
| | | else if (row == "3") |
| | | { |
| | | str += $" AreaNo in ({row3})"; |
| | | } |
| | | |
| | | var list = Db.Ado.SqlQuery<SysStorageLocat>(str); |
| | | |
| | | //var list = Db.Queryable<SysStorageLocat>().Where(m => m.IsDel == "0" && m.WareHouseNo == wareHouseNo && row == "1" ? row1.Contains(m.AreaNo) : row3.Contains(m.AreaNo)).ToList(); |
| | | |
| | | return list; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | throw new Exception(e.Message); |
| | | } |
| | | |
| | | } |
| | | |
| | | #endregion |
| | | } |
| | | } |