/// <summary> /// 更新库位 /// </summary> /// <param name="inputDto">库位信息</param> /// <returns></returns> public ReturnInfo UpdateWhStorageLocation(WHStorageLocationInputDto inputDto) { ReturnInfo RInfo = new ReturnInfo(); StringBuilder sb = new StringBuilder(); string ValidateInfo = Helper.BasicValidate(inputDto).ToString(); sb.Append(ValidateInfo); if (sb.Length == 0) { try { WHStorageLocation wareHouse = _wHStorageLocationRepository.GetById(inputDto.WAREID, inputDto.STID, inputDto.SLID).FirstOrDefault(); if (wareHouse != null) { wareHouse.NAME = inputDto.NAME; wareHouse.MAXVOLUME = inputDto.MAXVOLUME; wareHouse.MAXCAPACITY = inputDto.MAXCAPACITY; wareHouse.MANAGER = inputDto.MANAGER; wareHouse.MODIFYUSER = inputDto.MODIFYUSER; wareHouse.MODIFYDATE = DateTime.Now; _unitOfWork.RegisterDirty(wareHouse); } bool result = _unitOfWork.Commit(); RInfo.IsSuccess = result; RInfo.ErrorInfo = sb.ToString(); return(RInfo); } catch (Exception ex) { _unitOfWork.Rollback(); sb.Append(ex.Message); RInfo.IsSuccess = false; RInfo.ErrorInfo = sb.ToString(); return(RInfo); } } else { RInfo.IsSuccess = false; RInfo.ErrorInfo = sb.ToString(); return(RInfo); } }
/// <summary> /// 启用/禁用:仓库/存储类型/库位 /// </summary> /// <param name="wareId"></param> /// <param name="stId"></param> /// <returns></returns> public ReturnInfo ChangeEnable(string wareId, string stId, string SlId, IsEnable isEnable) { ReturnInfo RInfo = new ReturnInfo(); // 启用/禁用库位 if (!String.IsNullOrEmpty(wareId) && !String.IsNullOrEmpty(stId) && !String.IsNullOrEmpty(SlId)) { WHStorageLocation wHStorageLocation = _wHStorageLocationRepository.GetById(wareId, stId, SlId).FirstOrDefault(); if (wHStorageLocation != null) { if (wHStorageLocation.ISENABLE == (int)isEnable && isEnable == IsEnable.启用) { throw new Exception("该库位已启用,不可重复启用"); } else if (wHStorageLocation.ISENABLE == (int)isEnable && isEnable == IsEnable.禁用) { throw new Exception("该库位已禁用,不可重复禁用"); } wHStorageLocation.ISENABLE = (int)isEnable; } else { throw new Exception("当前库位不存在"); } } // 启用/禁用存储类型 else if (!String.IsNullOrEmpty(wareId) && !String.IsNullOrEmpty(stId)) { WHStorageType wHStorageType = _wHStorageTypeReposity.GetById(wareId, stId).FirstOrDefault(); if (wHStorageType != null) { if (wHStorageType.ISENABLE == (int)isEnable && isEnable == IsEnable.启用) { throw new Exception("该存储类型已启用,不可重复启用"); } else if (wHStorageType.ISENABLE == (int)isEnable && isEnable == IsEnable.禁用) { throw new Exception("该存储类型已禁用,不可重复禁用"); } wHStorageType.ISENABLE = (int)isEnable; } else { throw new Exception("当前存储类型不存在"); } } else // 启用/禁用仓库 { WareHouse wareHouse = _warehouseRepository.GetById(wareId).FirstOrDefault(); if (wareHouse != null) { if (wareHouse.ISENABLE == (int)isEnable && isEnable == IsEnable.启用) { throw new Exception("该仓库已启用,不可重复启用"); } else if (wareHouse.ISENABLE == (int)isEnable && isEnable == IsEnable.禁用) { throw new Exception("该仓库已禁用,不可重复禁用"); } wareHouse.ISENABLE = (int)isEnable; } else { throw new Exception("当前仓库不穿在"); } } try { _unitOfWork.Commit(); RInfo.IsSuccess = true; return(RInfo); } catch (Exception ex) { _unitOfWork.Rollback(); RInfo.IsSuccess = false; RInfo.ErrorInfo = ex.Message; return(RInfo); } }
/// <summary> /// 资产移库 /// </summary> /// <param name="inputDto">移库相关信息</param> /// <returns></returns> public ReturnInfo TransferAss(AssTransferInputDto inputDto) { ReturnInfo RInfo = new ReturnInfo(); StringBuilder sb = new StringBuilder(); string ValidateInfo = Helper.BasicValidate(inputDto).ToString(); sb.Append(ValidateInfo); if (sb.Length == 0) { try { WHStorageLocation storageLocation = _whStorageLocationRepository.GetById(inputDto.WAREID, inputDto.STID, inputDto.SLID).AsNoTracking() .FirstOrDefault(); if (storageLocation != null) { //取出SN在范围内的所有资产 var assets = _AssetsRepository.GetAll().Where(a => inputDto.SnList.Contains(a.SN) && a.ISINWAREHOUSE == 1); //遍历,修改库位 foreach (var asset in assets) { //修改库位 asset.WAREID = inputDto.WAREID; asset.STID = inputDto.STID; asset.SLID = inputDto.SLID; _unitOfWork.RegisterDirty(asset); var pr = new AssProcessRecord { ASSID = asset.ASSID, CREATEDATE = DateTime.Now, CREATEUSER = inputDto.UserId, HANDLEDATE = DateTime.Now, HANDLEMAN = inputDto.UserId, MODIFYDATE = DateTime.Now, MODIFYUSER = inputDto.UserId, PROCESSCONTENT = inputDto.UserId + "修改库位为" + inputDto.WAREID + "/" + inputDto.STID + "/" + inputDto.SLID, PROCESSMODE = (int)PROCESSMODE.调拨, QUANTITY = 1 }; _unitOfWork.RegisterNew(pr); } bool result = _unitOfWork.Commit(); RInfo.IsSuccess = result; RInfo.ErrorInfo = ""; return(RInfo); } else { throw new Exception("该库位不存在!"); } } catch (Exception ex) { _unitOfWork.Rollback(); sb.Append(ex.Message); RInfo.IsSuccess = false; RInfo.ErrorInfo = sb.ToString(); return(RInfo); } } else { RInfo.IsSuccess = false; RInfo.ErrorInfo = sb.ToString(); return(RInfo); } }