| | |
| | | using System.Collections.Generic; |
| | | using System.Drawing.Printing; |
| | | using System.Linq.Expressions; |
| | | using WIDESEA_Common; |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Core.Enums; |
| | | using WIDESEA_DTO; |
| | | using WIDESEA_IRecordService; |
| | | |
| | | namespace WIDESEA_StorageBasicService; |
| | | |
| | | public class VV_StockInfoService : ServiceBase<VV_StockInfo, IVV_StockInfoRepository>, IVV_StockInfoService |
| | | { |
| | | private readonly IDt_PalletStockInfoRepository _repository; |
| | | private readonly IDt_PalletStockInfoRepository _PalletStockInfoRepository; |
| | | private readonly IStockQuantityChangeRecordService _stockQuantityChangeRecord; |
| | | public VV_StockInfoService(IVV_StockInfoRepository BaseDal, IDt_PalletStockInfoRepository repository, IStockQuantityChangeRecordService stockQuantityChangeRecord) : base(BaseDal) |
| | | private readonly IDt_CarBodyInfoRepository _carBodyInfoRepository; |
| | | private readonly ILocationInfoRepository _locationInfoRepository; |
| | | private readonly ILocationStatusChangeRecordRepository _locationStatusChangeRecordRepository; |
| | | private readonly IUnitOfWorkManage _unitOfWorkManage; |
| | | |
| | | public VV_StockInfoService(IVV_StockInfoRepository BaseDal, IDt_PalletStockInfoRepository PalletStockInfoRepository, IStockQuantityChangeRecordService stockQuantityChangeRecord, IDt_CarBodyInfoRepository carBodyInfoRepository, ILocationInfoRepository locationInfoRepository, ILocationStatusChangeRecordRepository locationStatusChangeRecordRepository, IUnitOfWorkManage unitOfWorkManage) : base(BaseDal) |
| | | { |
| | | _repository = repository; |
| | | _PalletStockInfoRepository = PalletStockInfoRepository; |
| | | _stockQuantityChangeRecord = stockQuantityChangeRecord; |
| | | _carBodyInfoRepository = carBodyInfoRepository; |
| | | _locationInfoRepository = locationInfoRepository; |
| | | _locationStatusChangeRecordRepository = locationStatusChangeRecordRepository; |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | | } |
| | | |
| | | public WebResponseContent stockLock(object[] keys) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | foreach (var item in keys) |
| | | { |
| | | var stock = _repository.QueryFirst(x => x.Id == Convert.ToInt32(item)); |
| | | if (stock.LockOrder != 1){ |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | foreach (var item in keys) |
| | | { |
| | | var stock = _PalletStockInfoRepository.QueryFirst(x => x.Id == Convert.ToInt32(item)); |
| | | if (stock.LockOrder != 1) |
| | | { |
| | | stock.StockStatus = 1; |
| | | _repository.UpdateData(stock); |
| | | _PalletStockInfoRepository.UpdateData(stock); |
| | | } |
| | | |
| | | } |
| | | return content.OK("閿佸畾鎴愬姛!"); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | return content.Error(e.Message); |
| | | } |
| | | |
| | | return content.OK("閿佸畾鎴愬姛!"); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | return content.Error(e.Message); |
| | | } |
| | | } |
| | | |
| | | public WebResponseContent stockUnLock(object[] keys) |
| | |
| | | { |
| | | foreach (var item in keys) |
| | | { |
| | | var stock = _repository.QueryFirst(x => x.Id == Convert.ToInt32(item)); |
| | | var stock = _PalletStockInfoRepository.QueryFirst(x => x.Id == Convert.ToInt32(item)); |
| | | stock.StockStatus = 0; |
| | | _repository.UpdateData(stock); |
| | | |
| | | _PalletStockInfoRepository.UpdateData(stock); |
| | | } |
| | | return content.OK("瑙i攣鎴愬姛!"); |
| | | } |
| | |
| | | { |
| | | return content.Error(e.Message); |
| | | } |
| | | } |
| | | |
| | | |
| | | public override WebResponseContent DeleteData(object[] keys) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | var stockInfo = BaseDal.QueryFirst(x => x.Id == keys[0].ObjToInt()); |
| | | var stock = _PalletStockInfoRepository.QueryFirst(x => x.Id == keys[0].ObjToInt()); |
| | | var location = _locationInfoRepository.QueryFirst(x => x.LocationCode == stock.LocationCode); |
| | | var carInfo = _carBodyInfoRepository.QueryData(x => x.Id == stock.carBodyID); |
| | | |
| | | int beforState = location.LocationStatus; |
| | | stock.StockStatus = 5; |
| | | location.LocationStatus = LocationEnum.Free.ObjToInt(); |
| | | |
| | | LocationChangeRecordDto changeRecordDto = new LocationChangeRecordDto() |
| | | { |
| | | AfterStatus = 0, |
| | | BeforeStatus = beforState, |
| | | TaskNum = 0, |
| | | LocationId = location.Id, |
| | | LocationCode = location.LocationCode, |
| | | ChangeType = (int)StatusChangeTypeEnum.ManualOperation |
| | | }; |
| | | |
| | | _unitOfWorkManage.BeginTran(); |
| | | _PalletStockInfoRepository.DeleteData(stock); |
| | | _locationInfoRepository.UpdateData(location); |
| | | _carBodyInfoRepository.DeleteData(carInfo); |
| | | |
| | | _locationStatusChangeRecordRepository.AddStatusChangeRecord(changeRecordDto); |
| | | _unitOfWorkManage.CommitTran(); |
| | | |
| | | return content.OK("鍒犻櫎鎴愬姛"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return content.Error(ex.Message); |
| | | } |
| | | } |
| | | } |