| | |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Linq.Expressions; |
| | | using System.Security.Permissions; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using Dm; |
| | | using Model.ModelDto.SysDto; |
| | | using SqlSugar; |
| | | using WMS.DAL; |
| | | using WMS.Entity.Context; |
| | | using WMS.Entity.SysEntity; |
| | | using WMS.IBLL.ISysServer; |
| | | using WMS.IDAL.ISysInterface; |
| | | |
| | | namespace WMS.BLL.SysServer |
| | | { |
| | | public class StorageAreaServer: IStorageAreaServer |
| | | public class StorageAreaServer : DbHelper<SysStorageArea>, IStorageAreaServer |
| | | { |
| | | private static readonly SqlSugarScope Db = DataContext.Db; |
| | | public IStorageAreaRepository AreaRst { get; set; } |
| | | public StorageAreaServer(IStorageAreaRepository areaRst) |
| | | public StorageAreaServer(IStorageAreaRepository areaRst) : base(Db) |
| | | { |
| | | AreaRst = areaRst; |
| | | } |
| | |
| | | throw new Exception(e.Message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取单条库区域信息 |
| | | /// </summary> |
| | | /// <param name="id">ID</param> |
| | | /// <returns></returns> |
| | | public SysStorageArea GetStorageMaxArea() |
| | | { |
| | | try |
| | | { |
| | | var data = Db.Queryable<SysStorageArea>().Where(a => a.IsDel == "0" && a.WareHouseNo == "W01").OrderByDescending(a => a.CreateTime).First(); |
| | | return data; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | throw new Exception(e.Message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取区域信息(根据仓库号) |
| | | /// </summary> |
| | |
| | | /// <summary> |
| | | /// 修改库区域信息 |
| | | /// </summary> |
| | | /// <param name="model">区域实体</param> |
| | | /// <returns>是否成功</returns> |
| | | public string InsertStorageArea(SysStorageArea model) |
| | | { |
| | | try |
| | | { |
| | | string str = ""; |
| | | //判断所属仓库是否为立体库 |
| | | if (model.WareHouseNo != "W01") |
| | | { |
| | | str = "-1:所属仓库不为立体库,请重新选择!"; |
| | | return str; |
| | | } |
| | | //获取立体库最大编码 |
| | | //var area = Db.Queryable<SysStorageArea>().Max(a => a.Id)(a => a.IsDel == "0" && a.WareHouseNo == "W01"); |
| | | var area = Db.Queryable<SysStorageArea>().Where(a => a.IsDel == "0" && a.WareHouseNo == "W01").OrderByDescending(a=>a.CreateTime).First(); |
| | | //验证是否存在立体库第一条区域信息 |
| | | if (area == null) |
| | | { |
| | | model.AreaNo = "A01"; |
| | | } |
| | | else |
| | | { |
| | | var arr = area.AreaNo.Split("A"); |
| | | int a = int.Parse(arr[1]) + 1; |
| | | //判断是否小于10 |
| | | if (a < 10) |
| | | { |
| | | model.AreaNo = "A0" + (int.Parse(arr[1]) + 1).ToString(); |
| | | } |
| | | else |
| | | { |
| | | model.AreaNo = "A" + (int.Parse(arr[1]) + 1).ToString(); |
| | | } |
| | | |
| | | } |
| | | Db.BeginTran(); |
| | | |
| | | //新增区域信息 |
| | | SysStorageArea list = new SysStorageArea() |
| | | { |
| | | AreaNo = model.AreaNo, //区域编码 |
| | | AreaName = model.AreaName, //区域名称 |
| | | WareHouseNo = model.WareHouseNo, //所属仓库 |
| | | RoadwayNo = null, //所属巷道 |
| | | Status = model.Status, //是否启用 |
| | | Priority = model.Priority, //优先级 |
| | | Type = model.Type, //存储类别 |
| | | Temperature = model.Temperature, //存储环境 |
| | | IsDel = "0", //是否删除 |
| | | CreateUser = model.CreateUser, //创建人 |
| | | CreateTime = Db.GetDate(), //创建时间 |
| | | UpdateUser = null, //修改人 |
| | | UpdateTime = null, //修改时间 |
| | | }; |
| | | Db.Insertable(list).ExecuteCommand(); |
| | | |
| | | Db.CommitTran(); |
| | | |
| | | str = "添加成功"; |
| | | return str; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | Db.RollbackTran(); |
| | | throw new Exception(e.Message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 修改库区域信息 |
| | | /// </summary> |
| | | /// <param name="id">ID</param> |
| | | /// <param name="name">区域名称</param> |
| | | /// <param name="priority">优先级</param> |