| | |
| | | 锘縰sing SqlSugar; |
| | | 锘縰sing Microsoft.Extensions.Logging; |
| | | using SqlSugar; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | |
| | | public readonly IOutboundService _outboundService; |
| | | public readonly IRepository<Dt_AllocateOrder> _allocateOrderRepository; |
| | | public readonly IRepository<Dt_AllocateOrderDetail> _allocateOrderDetailRepository; |
| | | |
| | | private readonly ILogger<AllocateService> _logger; |
| | | public AllocateService(IRepository<Dt_AllocateOrder> BaseDal, |
| | | IUnitOfWorkManage unitOfWorkManage, |
| | | IInboundService inboundService, |
| | | IOutboundService outboundService, |
| | | IRepository<Dt_AllocateOrder> allocateOrderRepository, |
| | | IRepository<Dt_AllocateOrderDetail> allocateOrderDetailRepository) : base(BaseDal) |
| | | IRepository<Dt_AllocateOrderDetail> allocateOrderDetailRepository, |
| | | ILogger<AllocateService> logger) : base(BaseDal) |
| | | { |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | | _inboundService = inboundService; |
| | | _outboundService = outboundService; |
| | | _allocateOrderRepository = allocateOrderRepository; |
| | | _allocateOrderDetailRepository = allocateOrderDetailRepository; |
| | | _logger = logger; |
| | | } |
| | | |
| | | public IRepository<Dt_AllocateOrder> Repository => BaseDal; |
| | |
| | | { |
| | | return operateType switch |
| | | { |
| | | 1 => AddInboundOrder(allocateOrder), |
| | | 2 => UpdateInboundOrder(allocateOrder), |
| | | 3 => DeleteInboundOrder(allocateOrder), |
| | | 1 => AddAllocateOrder(allocateOrder), |
| | | 2 => UpdateAllocateOrder(allocateOrder), |
| | | 3 => DeleteAllocateOrder(allocateOrder), |
| | | |
| | | _ => WebResponseContent.Instance.OK(), |
| | | }; |
| | |
| | | } |
| | | } |
| | | |
| | | public WebResponseContent AddInboundOrder(Dt_AllocateOrder allocateOrder) |
| | | public WebResponseContent AddAllocateOrder(Dt_AllocateOrder allocateOrder) |
| | | { |
| | | try |
| | | { |
| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _logger.LogInformation("AllocateService AddAllocateOrder err: " + ex.Message); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | public WebResponseContent UpdateInboundOrder(Dt_AllocateOrder model) |
| | | public WebResponseContent UpdateAllocateOrder(Dt_AllocateOrder model) |
| | | { |
| | | try |
| | | { |
| | |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | _logger.LogInformation("AllocateService UpdateAllocateOrder err: " + ex.Message); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | public WebResponseContent DeleteInboundOrder(Dt_AllocateOrder model) |
| | | public WebResponseContent DeleteAllocateOrder(Dt_AllocateOrder model) |
| | | { |
| | | try |
| | | { |
| | |
| | | { |
| | | return WebResponseContent.Instance.Error($"鏈壘鍒拌皟鎷ㄥ崟鏄庣粏淇℃伅"); |
| | | } |
| | | //Db.DeleteNav(inboundOrder).Include(x => x.Details).ExecuteCommand(); |
| | | //Db.DeleteNav(Allocate).Include(x => x.Details).ExecuteCommand(); |
| | | _unitOfWorkManage.BeginTran(); |
| | | // BaseDal.DeleteAndMoveIntoHty(allocateOrder, OperateTypeEnum.鑷姩鍒犻櫎); |
| | | foreach (var item in allocateOrder.Details) |
| | |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | _logger.LogInformation("AllocateService DeleteAllocateOrder err: " + ex.Message); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |