wangxinhui
2025-10-26 733c975cd8647f6d006736f1863bad731e32e6fb
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
71
72
73
74
75
76
77
78
79
80
81
82
83
using Autofac.Builder;
using AutoMapper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Common.CommonEnum;
using WIDESEA_Common.MaterielEnum;
using WIDESEA_Common.OrderEnum;
using WIDESEA_Common.StockEnum;
using WIDESEA_Common.WareHouseEnum;
using WIDESEA_Core.Helper;
using WIDESEA_DTO;
using WIDESEA_DTO.Basic;
using WIDESEA_DTO.ERP;
using WIDESEA_DTO.Inbound;
using WIDESEA_DTO.MES;
using WIDESEA_DTO.System;
using WIDESEA_DTO.Task;
using WIDESEA_Model.Models;
 
namespace WIDESEA_WMSServer.Filter
{
    public class CustomProfile : Profile
    {
        /// <summary>
        /// 配置构造函数,用来创建关系映射
        /// </summary>
        public CustomProfile()
        {
            CreateMap<Sys_Menu, MenuDTO>();
            CreateMap<Dt_Task, WMSTaskDTO>();
            //物料实体BST转换
            CreateMap<BSTMaterialDTO, Dt_MaterielInfo>().ForMember(x => x.MaterialSourceId, b => b.MapFrom(b => b.MaterialId)).ForMember(x => x.WarehouseId, b => b.MapFrom(b => WarehouseEnum.LLDYL.ObjToInt())).ForMember(x => x.MaterielCode, b => b.MapFrom(b => b.MaterialNo)).ForMember(x => x.MaterielName, b => b.MapFrom(b => b.Name)).ForMember(x => x.MaterielSourceType, b => b.MapFrom(b => b.MaterielType)).ForMember(x => x.MaterielInvOrgId, b => b.MapFrom(b => b.InvOrgId)).ForMember(x => x.MaterielUnit, b => b.MapFrom(b => b.Unit)).ForMember(x => x.MaterielUnit, b => b.MapFrom(b => b.Unit)).ForMember(x => x.MaterielState, b => b.MapFrom(b => b.Status)).ForMember(x => x.IsCheck, b => b.MapFrom(b => WhetherEnum.False.ObjToInt())).ForMember(x => x.MaterielSpec, b => b.MapFrom(b => b.Spec)).ForMember(x => x.MaterielWeight, b => b.MapFrom(b => b.Weight));
            //物料实体转换
            CreateMap<BSTSupplierDTO, Dt_SupplierInfo>().ForMember(x => x.SupplierSourceId, b => b.MapFrom(b => b.VendId)).ForMember(x => x.SupplierCode, b => b.MapFrom(b => b.VendNo)).ForMember(x => x.SupplierName, b => b.MapFrom(b => b.ShortName)).ForMember(x => x.SupplierShortName, b => b.MapFrom(b => b.ShortName)).ForMember(x => x.Contacts, b => b.MapFrom(b => b.BusinessContact)).ForMember(x => x.ContactNumber, b => b.MapFrom(b => b.Tel)).ForMember(x => x.ContactAddress, b => b.MapFrom(b => b.Address)).ForMember(x => x.InvOrgId, b => b.MapFrom(b => MaterielInvOrgEnum.老厂.ObjToInt()));
            //采购实体转换
            CreateMap<BSTPurchaseOrderDTO, Dt_PurchaseBSTOrder>().ForMember(x => x.ReceiptDate, b => b.MapFrom(b => DateTimeOffset.FromUnixTimeMilliseconds(b.ReceiptDate).DateTime));
            CreateMap<PaperReceiptDetailsItem, Dt_PurchaseBSTOrderDetail>().ForMember(x => x.MaterialWide, b => b.MapFrom(b => b.W)).ForMember(x => x.MaterialThick, b => b.MapFrom(b => b.Thick)).ForMember(x => x.PurchaseBSTOrderDetailStatus, b => b.MapFrom(b => InOrderStatusEnum.未开始.ObjToInt()));
            //BST出库排程实体转换
            CreateMap<BSTOutOrderDTO, Dt_OutBSTOrder>().ForMember(x => x.OutBSTOrderStatus, b => b.MapFrom(b => OutOrderStatusEnum.未开始.ObjToInt())).ForMember(x => x.ProductionDate, b => b.MapFrom(b => DateTimeOffset.FromUnixTimeMilliseconds(b.ProductionDate).DateTime)).ForMember(x => x.WarehouseId, b => b.MapFrom(b => WarehouseEnum.LLDYL.ObjToInt()));
            CreateMap<BstBoardMpsDetailItem, Dt_OutBSTOrderDetail>().ForMember(x => x.OutBSTOrderDetailStatus, b => b.MapFrom(b => OutOrderStatusEnum.未开始.ObjToInt()));
            //BST退料单实体转换
            CreateMap<BSTReturnOrderDTO, Dt_ReturnBSTOrder>().ForMember(x => x.ReturnOrderStatus, b => b.MapFrom(b => InOrderStatusEnum.未开始.ObjToInt())).ForMember(x => x.WreturnDate, b => b.MapFrom(b => DateTimeOffset.FromUnixTimeMilliseconds(b.WreturnDate).DateTime)).ForMember(x => x.WarehouseId, b => b.MapFrom(b => WarehouseEnum.LLDYL.ObjToInt()));
            CreateMap<BSTReturnOrderDTOItem, Dt_ReturnBSTOrderDetail>().ForMember(x => x.ReturnBSTOrderDetailStatus, b => b.MapFrom(b => OutOrderStatusEnum.未开始.ObjToInt())).ForMember(x => x.MaterialWide, b => b.MapFrom(b => b.W)).ForMember(x => x.MaterialThick, b => b.MapFrom(b => b.Thick));
            //MES领料计划实体转换
            CreateMap<OutMESOrderDTO, Dt_OutMESOrder>().ForMember(x => x.OutMESOrderStatus, b => b.MapFrom(b => OutOrderStatusEnum.未开始.ObjToInt()));
            //生管排程实体转换
            CreateMap<SGOutOrderDTO, Dt_OutSGOrder>().ForMember(x => x.OutSGOrderStatus, b => b.MapFrom(b => OutOrderStatusEnum.未开始.ObjToInt())).ForMember(x => x.WarehouseId, b => b.MapFrom(b => WarehouseEnum.LLDYL.ObjToInt()));
            CreateMap<SGOutOrderDTO, Dt_OutSGOrderDetail>().ForMember(x => x.OutSGOrderDetailStatus, b => b.MapFrom(b => OutOrderStatusEnum.未开始.ObjToInt()));
            //成品半成品实体转换
            CreateMap<MESProInDTO, Dt_MESProInOrderInfo>().ForMember(x => x.MESProInStatus, b => b.MapFrom(b => InOrderStatusEnum.未开始.ObjToInt()));
            //二期ERP物料接收实体转换
            CreateMap<ERPMaterialDTO, Dt_MaterielInfo>().ForMember(x => x.MaterielInvOrgId, b => b.MapFrom(b => MaterielInvOrgEnum.新厂.ObjToInt())).ForMember(x => x.MaterielCode, b => b.MapFrom(b => b.MaterielNo)).ForMember(x => x.MaterielSourceType, b => b.MapFrom(b => b.MaterielType)).ForMember(x => x.MaterielWide, b => b.MapFrom(b => b.MaterielWidth)).ForMember(x => x.MaterielWeight, b => b.MapFrom(b => b.Weight)).ForMember(x => x.MaterielState, b => b.MapFrom(b => b.State)).ForMember(x => x.MaterielUnit, b => b.MapFrom(b => b.Unit)).ForMember(x => x.MaterielSpec, b => b.MapFrom(b => b.MaterielSpec));
            //博思通缓存采购转换
            CreateMap<Dt_PurchaseBSTOrderDetail, Dt_YLInboundCache>().ForMember(x => x.Id, b => b.MapFrom(b => 0)).ForMember(x => x.BindStatus, b => b.MapFrom(b => WhetherEnum.False.ObjToInt())).ForMember(x => x.RfidCode, b => b.MapFrom(b => "")).ForMember(x => x.InvOrg, b => b.MapFrom(b => MaterielInvOrgEnum.老厂.ToString()));
            //二期ERP供应商转换
            CreateMap<ERPSupplierDTO, Dt_SupplierInfo>().ForMember(x => x.SupplierSourceId, b => b.MapFrom(b => 0)).ForMember(x => x.SupplierShortName, b => b.MapFrom(b => b.ShortName)).ForMember(x => x.Status, b => b.MapFrom(b => b.State)).ForMember(x => x.InvOrgId, b => b.MapFrom(b => MaterielInvOrgEnum.新厂.ObjToInt()));
            //二期ERP客户转换
            CreateMap<ERPCustomerDTO, Dt_CustomerInfo>().ForMember(x => x.OutRule, b => b.MapFrom(b => 0)).ForMember(x => x.Status, b => b.MapFrom(b => b.State));
            //二期ERP客户转换
            CreateMap<ERPUserInfoDTO, Dt_UserInfo>().ForMember(x => x.Code, b => b.MapFrom(b => b.StaffCode)).ForMember(x => x.Name, b => b.MapFrom(b => b.StaffName));
            //博思通缓存库存转换
            CreateMap<Dt_StockInfo, Dt_YLInboundCache>().ForMember(x => x.Id, b => b.MapFrom(b => 0)).ForMember(x => x.BindStatus, b => b.MapFrom(b => WhetherEnum.False.ObjToInt())).ForMember(x => x.RfidCode, b => b.MapFrom(b => "")).ForMember(x => x.InvOrg, b => b.MapFrom(b => MaterielInvOrgEnum.老厂.ToString())).ForMember(x => x.BarCode, b => b.MapFrom(b => b.PalletCode)).ForMember(x => x.MaterialNo, b => b.MapFrom(b => b.MaterielCode)).ForMember(x => x.DeliveryQty, b => b.MapFrom(b => b.MaterielWeight)).ForMember(x => x.MaterialThick, b => b.MapFrom(b => b.MaterielThickness)).ForMember(x => x.ProcurementLength, b => b.MapFrom(b => b.StockLength)).ForMember(x => x.MaterialWide, b => b.MapFrom(b => b.MaterielWide));
            //采购实体转换
            CreateMap<ERPPurchaseOrderDTO, Dt_PurchaseOrder>().ForMember(x => x.PurchaseOrderNo, b => b.MapFrom(b =>b.PurchaseInCode)).ForMember(x => x.OrderQuantity, b => b.MapFrom(b => b.SumQty));
            CreateMap<PurchaseInDetailItem, Dt_PurchaseOrderDetail>().ForMember(x => x.DetailId, b => b.MapFrom(b => b.DetailId)).ForMember(x => x.PurchaseDetailWeight, b => b.MapFrom(b => b.Weight)).ForMember(x => x.PurchaseDetailWide, b => b.MapFrom(b => b.Wide)).ForMember(x => x.PurchaseDetailStatus, b => b.MapFrom(b => InOrderStatusEnum.未开始.ObjToInt())).ForMember(x => x.PurchaseDetailInboundQty, b => b.MapFrom(b =>0)).ForMember(x => x.PurchaseDetailQuantity, b => b.MapFrom(b => b.MaterialQty)).ForMember(x => x.MaterialCode, b => b.MapFrom(b => b.MaterialCode)).ForMember(x => x.BarCode, b => b.MapFrom(b => b.Barcode)).ForMember(x => x.MaterialLot, b => b.MapFrom(b => b.MaterialLot));
            //退货实体转换
            CreateMap<ERPReturnOrderDTO, Dt_ReturnOutOrder>().ForMember(x => x.ReturnNo, b => b.MapFrom(b => b.ReturnCode)).ForMember(x => x.EmployeeName, b => b.MapFrom(b => b.Creater)).ForMember(x => x.ReturnOrderStatus, b => b.MapFrom(b => InOrderStatusEnum.未开始.ObjToInt()));
            CreateMap<ReturnDetailItem, Dt_ReturnOutOrderDetail>().ForMember(x => x.DetailId, b => b.MapFrom(b => b.DetailId)).ForMember(x => x.BarCode, b => b.MapFrom(b => b.BarCode)).ForMember(x => x.ReturnQuantity, b => b.MapFrom(b => b.MaterialQty)).ForMember(x => x.ReturnOutDetailStatus, b => b.MapFrom(b => InOrderStatusEnum.未开始.ObjToInt()));
            //销售实体转换
            CreateMap<ERPProDeliveryDTO, Dt_ProDeliveryOrder>().ForMember(x => x.DeliveryType, b => b.MapFrom(b => 1)).ForMember(x => x.EmployeeName, b => b.MapFrom(b => b.Creater)).ForMember(x => x.ProDeliveryStatus, b => b.MapFrom(b => OutOrderStatusEnum.未开始.ObjToInt()));
            CreateMap<DeliveryDetailItem, Dt_ProDeliveryOrderDetail>().ForMember(x => x.DetailId, b => b.MapFrom(b => b.DetailId)).ForMember(x => x.Quantity, b => b.MapFrom(b => b.MaterialQty)).ForMember(x => x.ProDeliveryDetailStatus, b => b.MapFrom(b => OutOrderStatusEnum.未开始.ObjToInt()));
            //非生产领料转换
            CreateMap<ERPPickOutOrderDTO, Dt_PickOutOrder>().ForMember(x => x.EmployeeName, b => b.MapFrom(b => b.Creater)).ForMember(x => x.OutOrderStatus, b => b.MapFrom(b => OutOrderStatusEnum.未开始.ObjToInt()));
            CreateMap<PickDetailItem, Dt_PickOutOrderDetail>().ForMember(x => x.DetailId, b => b.MapFrom(b => b.DetailId)).ForMember(x => x.Quantity, b => b.MapFrom(b => b.MaterialQty)).ForMember(x => x.PickOutDetailStatus, b => b.MapFrom(b => OutOrderStatusEnum.未开始.ObjToInt()));
            //销售退货实体转换
            CreateMap<ERPProDeliverBackDTO, Dt_ProDeliverBackOrder>().ForMember(x => x.EmployeeName, b => b.MapFrom(b => b.Creater)).ForMember(x => x.DeliveryBackStatus, b => b.MapFrom(b => InOrderStatusEnum.未开始.ObjToInt())).ForMember(x => x.OrderType, b => b.MapFrom(b => b.DeliveryType));
            CreateMap<DeliveryBackDetailItem, Dt_ProDeliverBackOrderDetail>().ForMember(x => x.DeliverCode, b => b.MapFrom(b => b)).ForMember(x => x.Quantity, b => b.MapFrom(b => b.MaterialQty)).ForMember(x => x.DeliverBackDetailStatus, b => b.MapFrom(b => InOrderStatusEnum.未开始.ObjToInt()));
        }
    }
}