| | |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Common.OrderEnum; |
| | | using WIDESEA_Common.StockEnum; |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Core.BaseRepository; |
| | | using WIDESEA_Core.BaseServices; |
| | | using WIDESEA_Core.Enums; |
| | | using WIDESEA_Core.Helper; |
| | |
| | | using WIDESEA_IBasicService; |
| | | using WIDESEA_IOutboundRepository; |
| | | using WIDESEA_IOutboundService; |
| | | using WIDESEA_IStockRepository; |
| | | using WIDESEA_IStockService; |
| | | using WIDESEA_Model.Models; |
| | | |
| | |
| | | public class OutboundOrderService : ServiceBase<Dt_OutboundOrder, IOutboundOrderRepository>, IOutboundOrderService |
| | | { |
| | | private readonly IMapper _mapper; |
| | | private readonly IUnitOfWorkManage _unitOfWorkManage; |
| | | private readonly IBasicService _basicService; |
| | | private readonly IOutboundOrderDetailRepository _outboundOrderDetailRepository; |
| | | |
| | | private readonly IStockInfoService _stockInfoService; |
| | | private readonly IStockInfoRepository _stockInfoRepository; |
| | | public IOutboundOrderRepository Repository => BaseDal; |
| | | |
| | | public OutboundOrderService(IOutboundOrderRepository BaseDal, IMapper mapper, IBasicService basicService, IOutboundOrderDetailRepository outboundOrderDetailRepository) : base(BaseDal) |
| | | public OutboundOrderService(IOutboundOrderRepository BaseDal, IMapper mapper,IUnitOfWorkManage unitOfWorkManage, IBasicService basicService, IOutboundOrderDetailRepository outboundOrderDetailRepository, IStockInfoService stockInfoService, |
| | | IStockInfoRepository stockInfoRepository) : base(BaseDal) |
| | | { |
| | | _mapper = mapper; |
| | | _unitOfWorkManage=unitOfWorkManage; |
| | | _basicService = basicService; |
| | | _outboundOrderDetailRepository = outboundOrderDetailRepository; |
| | | _stockInfoService = stockInfoService; |
| | | _stockInfoRepository= stockInfoRepository; |
| | | } |
| | | |
| | | public WebResponseContent ReceiveOutOrder(ErpOutOrderDTO model) |
| | |
| | | } |
| | | else |
| | | { |
| | | Dt_StockInfo? stockInfo = null; |
| | | Dt_OutboundOrderDetail outboundOrderDetail = new Dt_OutboundOrderDetail() |
| | | { |
| | | RowNo = Convert.ToInt32(model.RowNo), |
| | |
| | | OrderQuantity = model.Qty, |
| | | OrderId = oldOutboundOrder.Id |
| | | }; |
| | | |
| | | //ERPä¸ä¼ æµè¯ä»é¢æåæ´æ°å¯¹åºåºåç¶æ |
| | | if (warehouse.WarehouseId == 1) |
| | | { |
| | | //è·ååºåºååºå |
| | | stockInfo = _stockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.WarehouseId == warehouse.WarehouseId).Includes(x => x.Details).Where(x => x.Details.Any(x => x.MaterielCode == model.MCode && x.BatchNo == model.MLot && x.InboundOrderRowNo == Convert.ToInt32(model.RowNo))).First(); |
| | | stockInfo.StockStatus = StockStatusEmun.å
¥åºå®æ.ObjToInt(); |
| | | } |
| | | _unitOfWorkManage.BeginTran(); |
| | | if (stockInfo != null) |
| | | { |
| | | _stockInfoRepository.UpdateData(stockInfo); |
| | | } |
| | | _outboundOrderDetailRepository.AddData(outboundOrderDetail); |
| | | _unitOfWorkManage.CommitTran(); |
| | | } |
| | | } |
| | | else |
| | |
| | | WarehouseId = warehouse.WarehouseId, |
| | | Details = new List<Dt_OutboundOrderDetail> { outboundOrderDetail } |
| | | }; |
| | | |
| | | Dt_StockInfo? stockInfo = null; |
| | | //ERPä¸ä¼ æµè¯ä»é¢æåæ´æ°å¯¹åºåºåç¶æ |
| | | if (warehouse.WarehouseId==1) |
| | | { |
| | | //è·ååºåºååºå |
| | | stockInfo = _stockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.WarehouseId == warehouse.WarehouseId).Includes(x => x.Details).Where(x => x.Details.Any(x => x.MaterielCode == model.MCode && x.BatchNo == model.MLot && x.InboundOrderRowNo == Convert.ToInt32(model.RowNo))).First(); |
| | | stockInfo.StockStatus=StockStatusEmun.å
¥åºå®æ.ObjToInt(); |
| | | } |
| | | _unitOfWorkManage.BeginTran(); |
| | | if (stockInfo!=null) |
| | | { |
| | | _stockInfoRepository.UpdateData(stockInfo); |
| | | } |
| | | Db.InsertNav(outboundOrder).Include(x => x.Details).ExecuteCommand(); |
| | | _unitOfWorkManage.CommitTran(); |
| | | } |
| | | } |
| | | else if (model.Way == 2) |
| | |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°è¯¥æç»è¡å·ä¿¡æ¯"); |
| | | } |
| | | if(outboundOrderDetail.OrderDetailStatus != OrderDetailStatusEnum.New.ObjToInt()) |
| | | if (outboundOrderDetail.OrderDetailStatus != OrderDetailStatusEnum.New.ObjToInt()) |
| | | { |
| | | return WebResponseContent.Instance.Error($"该æç»ä¸å¯ä¿®æ¹"); |
| | | } |
| | |
| | | |
| | | _outboundOrderDetailRepository.UpdateData(outboundOrderDetail); |
| | | } |
| | | else if (model.Way == 3) |
| | | { |
| | | if (oldOutboundOrder == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°è¯¥åºåºå"); |
| | | } |
| | | } |
| | | |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | public WebResponseContent ReleaseOutOrder(int id) |
| | | { |
| | | try |
| | | { |
| | | Dt_OutboundOrder outboundOrder = Db.Queryable<Dt_OutboundOrder>().Where(x => x.Id == id).Includes(x => x.Details).First(); |
| | | if (outboundOrder == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°è¯¥åºåºå"); |
| | | } |
| | | if(outboundOrder.Details == null || outboundOrder.Details.Count == 0) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°æç»ä¿¡æ¯"); |
| | | } |
| | | |
| | | foreach (var item in outboundOrder.Details) |
| | | { |
| | | } |
| | | |
| | | return WebResponseContent.Instance.OK(); |
| | | } |