| using System; | 
| using System.Collections.Generic; | 
| using System.Linq; | 
| using System.Text; | 
| using System.Threading.Tasks; | 
| using WIDESEA_Common.LocationEnum; | 
| using WIDESEA_Common.OrderEnum; | 
| using WIDESEA_Core.BaseRepository; | 
| using WIDESEA_Core.BaseServices; | 
| using WIDESEA_Core; | 
| using WIDESEA_IBasicService; | 
| using WIDESEA_IOutboundRepository; | 
| using WIDESEA_IOutboundService; | 
| using WIDESEA_IRecordService; | 
| using WIDESEA_IStockService; | 
| using WIDESEA_Model.Models; | 
| using WIDESEA_DTO.ERP; | 
| using WIDESEA_IBasicRepository; | 
| using WIDESEA_Common.WareHouseEnum; | 
| using AutoMapper; | 
|   | 
| namespace WIDESEA_OutboundService | 
| { | 
|     public partial class ErpProTransferOrderService : ServiceBase<Dt_ErpProTransferOrder, IErpProTransferOrderRepository>, IErpProTransferOrderService | 
|     { | 
|         private readonly IUnitOfWorkManage _unitOfWorkManage; | 
|   | 
|         public IErpProTransferOrderRepository Repository => BaseDal; | 
|         public IBasicRepository _basicRepository; | 
|         public IMapper _mapper; | 
|         public ErpProTransferOrderService(IErpProTransferOrderRepository BaseDal, IUnitOfWorkManage unitOfWorkManage, IBasicRepository basicRepository,IMapper mapper) : base(BaseDal) | 
|         { | 
|             _unitOfWorkManage = unitOfWorkManage; | 
|             _basicRepository = basicRepository; | 
|             _mapper = mapper; | 
|         } | 
|         /// <summary> | 
|         /// 成品调拨出(研发) | 
|         /// </summary> | 
|         public WebResponseContent ProductTransferOrder(ErpProductTransferOrderDTO  productTransferOrderDTO) | 
|         { | 
|             WebResponseContent content = new WebResponseContent(); | 
|             try | 
|             { | 
|                 //判断单据是否已存在 | 
|                 Dt_ErpProTransferOrder erpProInOrderOld = BaseDal.QueryFirst(x => x.UpperOrderNo == productTransferOrderDTO.TransferNo); | 
|                 if (erpProInOrderOld != null) | 
|                 { | 
|                     return content.Error($"单据{productTransferOrderDTO.TransferNo}已存在"); | 
|                 } | 
|                 //判断所传客户是否存在 | 
|                 Dt_CustomerInfo customerInfo = _basicRepository.CustomerInfoRepository.QueryFirst(x => x.Code == productTransferOrderDTO.Customer); | 
|                 if (customerInfo == null) | 
|                 { | 
|                     return content.Error($"客户{productTransferOrderDTO.Customer}信息不存在"); | 
|                 } | 
|                 Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA101.ToString()); | 
|                 Dt_ErpProTransferOrder erpProTransferOrder = _mapper.Map<Dt_ErpProTransferOrder>(productTransferOrderDTO); | 
|                 erpProTransferOrder.WarehouseId = warehouse.WarehouseId; | 
|                 BaseDal.AddData(erpProTransferOrder); | 
|                 content.OK(); | 
|             } | 
|             catch (Exception ex) | 
|             { | 
|                 content.Error(ex.Message); | 
|             } | 
|             return content; | 
|         } | 
|     } | 
| } |