| | |
| | | TypeName = GetTypeName(m.Type),//类别名称 |
| | | Temp = m.Temperature, |
| | | TempName = m.TemperatureInfo == null ? "" : m.TemperatureInfo.DictName, |
| | | DeviceCode=m.DeviceCode, |
| | | CreateTime = m.CreateTime, |
| | | CreateUserName = m.CreateUserInfo == null ? "" : m.CreateUserInfo.RealName, |
| | | UpdateTime = m.UpdateTime, |
| | | UpdateUserName = m.UpdateUserInfo == null ? "" : m.UpdateUserInfo.RealName |
| | | }).ToList(); |
| | | }).OrderBy(w=>w.WareHouseNo).OrderBy(w => w.AreaNo).ToList(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | { |
| | | try |
| | | { |
| | | string str = ""; |
| | | //判断所属仓库是否为立体库 |
| | | if (model.WareHouseNo != "W01") |
| | | string str = ""; |
| | | |
| | | var area = Db.Queryable<SysStorageArea>().First(a => a.IsDel == "0" && a.AreaNo == model.AreaNo); |
| | | if (area != null) |
| | | { |
| | | str = "-1:所属仓库不为立体库,请重新选择!"; |
| | | return str; |
| | | throw new Exception("当前区域编码对应的区域已存在"); |
| | | } |
| | | //获取立体库最大编码 |
| | | //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) |
| | | if (!string.IsNullOrEmpty(model.DeviceCode)) |
| | | { |
| | | model.AreaNo = "A01"; |
| | | } |
| | | else |
| | | { |
| | | var arr = area.AreaNo.Split("A"); |
| | | int a = int.Parse(arr[1]) + 1; |
| | | //判断是否小于10 |
| | | if (a < 10) |
| | | var area2 = Db.Queryable<SysStorageArea>().First(a => a.IsDel == "0" && a.DeviceCode == model.AreaNo); |
| | | if (area2 != null) |
| | | { |
| | | model.AreaNo = "A0" + (int.Parse(arr[1]) + 1).ToString(); |
| | | throw new Exception("当前设备编码对应的区域已存在"); |
| | | } |
| | | else |
| | | { |
| | | model.AreaNo = "A" + (int.Parse(arr[1]) + 1).ToString(); |
| | | } |
| | | |
| | | } |
| | | Db.BeginTran(); |
| | | |
| | |
| | | { |
| | | AreaNo = model.AreaNo, //区域编码 |
| | | AreaName = model.AreaName, //区域名称 |
| | | DeviceCode=model.DeviceCode,//设备编码 |
| | | WareHouseNo = model.WareHouseNo, //所属仓库 |
| | | RoadwayNo = null, //所属巷道 |
| | | Status = model.Status, //是否启用 |
| | |
| | | /// <param name="temp">存储环境</param> |
| | | /// <param name="userId">操作人</param> |
| | | /// <returns>是否成功</returns> |
| | | public bool EditStorageArea(int id, string name, int priority, string type, string temp, int userId) |
| | | public bool EditStorageArea(int id, string name, int priority, string type, string temp,string deviceCode, int userId) |
| | | { |
| | | try |
| | | { |
| | | //判断除当前id信息以外是否含有编号和名称 |
| | | var bol = AreaRst.GetAllAsync() |
| | | .Any(m => m.Id != id && m.AreaName == name.Trim()); |
| | | if (bol) |
| | | //var bol = AreaRst.GetAllAsync() |
| | | // .Any(m => m.Id != id && m.AreaName == name.Trim()); |
| | | //if (bol) |
| | | //{ |
| | | // throw new Exception("当前区域号或区域名称已存在"); |
| | | //} |
| | | if (!string.IsNullOrEmpty(deviceCode)) |
| | | { |
| | | throw new Exception("当前区域号或区域名称已存在"); |
| | | var bol2 = AreaRst.GetAllAsync().Any(m => m.Id != id && m.DeviceCode == deviceCode.Trim()); |
| | | if (bol2) |
| | | { |
| | | throw new Exception("当前设备编码对应的区域已存在"); |
| | | } |
| | | } |
| | | |
| | | var area = AreaRst.GetOneById(id); |
| | |
| | | area.Priority = priority; |
| | | area.Type = type; |
| | | area.Temperature = temp; |
| | | area.DeviceCode = deviceCode; |
| | | area.UpdateUser = userId; |
| | | area.UpdateTime = DateTime.Now; |
| | | var num = AreaRst.Edit(area); |