wangxinhui
2025-03-31 a6e0ea9ce13e791f3edae4edffeb3be3ccb760be
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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;
        }
    }
}