啊鑫
2024-07-12 f80d5cdf701b3d3f2e21bffaff6e99a2a240fc0e
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
using MES.Service.DB;
using MES.Service.Dto.webApi;
using MES.Service.Modes;
using SqlSugar;
 
namespace MES.Service.service.BasicData;
 
public class ShipmentNoticeManager : Repository<ShipmentNotice>
{
    private readonly ShipmentDetailManager shipmentDetailManager = new();
 
    //当前类已经继承了 Repository 增、删、查、改的方法
    public bool Save(ErpShipment shipment)
    {
        var shipmentNotice = GetShipmentNotice(shipment.ShipmentNotice);
 
        var shipmentDetails = GetShipmentDetails(shipment.ShipmentDetails);
        
        return false;
    }
 
    private ShipmentNotice GetShipmentNotice(ErpShipmentNotice notice)
    {
        ShipmentNotice entity = new ShipmentNotice();
 
        entity.Creator = notice.FCreatorId;
        entity.DocId = notice.FBillNo;
        entity.Approver = notice.FApproverID;
 
        if (notice.FCreateDate != null)
        {
            entity.CreateDate = DateTime.ParseExact(notice.FCreateDate,
                "yyyy-MM-dd HH:mm:ss", null);
        }
 
        if (notice.FApproveDate != null)
        {
            entity.ApproveDate = DateTime.ParseExact(notice.FApproveDate,
                "yyyy-MM-dd HH:mm:ss", null);
        }
        
        entity.DeptCode = notice.FSaleDeptId;
        entity.CustCode = notice.FCustomerID;
        entity.ListNote = notice.FNote;
        entity.RepCode = notice.FSalesManID;
 
        return entity;
    }
 
    private List<ShipmentDetail> GetShipmentDetails(
        List<ErpShipmentDetail> shipmentDetails)
    {
        return shipmentDetails.Select(s =>
            {
                var entity = new ShipmentDetail
                {
                    ErpId = s.ErpId,
                    ErpHeadId = s.ErpHeadId,
                    ProdCode = s.FMaterialID,
                    ProdName = s.FMaterialName,
                    Amount = Convert.ToDouble(s.FAmount),
                    UnitPrice = Convert.ToDouble(s.FPrice),
                    Quantity = Convert.ToDouble(s.FQty),
                    BatchNo = s.FLot,
                    Remarks = s.FNoteEntry,
                    OrderNo = s.F_UNW_Text_xsddh,
                    OrderId = s.FSOEntryId,
                    BasePrice = Convert.ToDouble(s.FPrice),
                    WarehouseCode = s.FStockID,
                    Unit = s.FBaseUnitID
                };
                return entity;
            }).ToList();
    }
}