111
啊鑫
5 天以前 24a228b7f12e2c840f084ee3b483889e99c780db
MES.Service/service/BasicData/ProductionOrderManager.cs
@@ -21,7 +21,8 @@
    public bool Save(ErpWYOrder wyOrder)
    {
        var erpProductionOrderDto = wyOrder.OrderDto;
        var mesRohIn = ConvertErpToProductionOrder(erpProductionOrderDto, wyOrder.Items[0].FBILLNO);
        var mesRohIn = ConvertErpToProductionOrder(erpProductionOrderDto,
            wyOrder.Items[0].FBILLNO);
        var mesRohInDatas =
            ConvertErpToProductionOrderSub(wyOrder.Items);
@@ -77,7 +78,9 @@
        if (mesRohInDatas.Count > 0)
            db.Deleteable<ProductionOrderSub>()
                .Where(s => s.ErpProductionEntryCode == mesRohIn.ErpProductionEntryCode).ExecuteCommand();
                .Where(s =>
                    s.ErpProductionEntryCode == mesRohIn.ErpProductionEntryCode)
                .ExecuteCommand();
        var orUpdate = db.Insertable(mesRohIn)
            .IgnoreColumns(true).ExecuteCommand() > 0;
@@ -86,7 +89,7 @@
        var baOrUpdate = db.Insertable(mesRohInDatas).PageSize(1)
            .IgnoreColumnsNull()
            .ExecuteCommand() > 0;
        if (orUpdate && baOrUpdate) return true;
        throw new NotImplementedException("插入或更新失败");
@@ -100,7 +103,7 @@
    }
    private ProductionOrder ConvertErpToProductionOrder(
        ErpProductionOrderDto erpDto,string SUBBOM)
        ErpProductionOrderDto erpDto, string SUBBOM)
    {
        DateTime parsedDate;
@@ -119,12 +122,11 @@
        var productionOrder = new ProductionOrder
        {
            OrderNo = SUBBOM,
            Warehouse = erpDto.FStockID,
            OrderDate = ParseDateTime(erpDto.FDate) ?? null,
            OrderType = erpDto.FBillType,
            BusinessStatus = erpDto.FStatus,
            ProductCode = erpDto.FMaterialId,
            Unit = erpDto.FUnitID,
            WorkOrderQty = Convert.ToDecimal(erpDto.FQty),
            PlanningGroup = erpDto.FWorkGroupId,
            Planner = erpDto.FPlannerID,
@@ -142,7 +144,7 @@
            ErpProductionOrderId = erpDto.FSUBID,
            ErpProductionOrderLineNo = erpDto.FSUBBILLNOSEQ,
            ErpProductionOrderNo = erpDto.FSUBBILLNO,
            SourceOrderType = erpDto.FSrcBillType,
            SourceOrderNo = erpDto.FSrcBillNo,
            SourceOrderEntryNo = erpDto.FSrcBillEntrySeq,
            DemandOrderNo = erpDto.FSALEORDERNO,
@@ -166,7 +168,53 @@
            Typea = erpDto.TypeA,
        };
        var single = base.GetSingle(it => it.ErpProductionEntryCode == erpDto.FSUBENTRYID);
        productionOrder.SourceOrderType = erpDto.FSrcBillType switch
        {
            //SourceOrderType = erpDto.FSrcBillType,
            "0" => "无来源",
            "1" => "销售订单行号",
            "2" => "预测",
            "3" => "出口订单行号",
            "4" => "需求分类代号",
            "5" => "销售订单号",
            "6" => "出口订单号",
            "7" or "8" => "生产订单",
            _ => "委外订单"
        };
        //Unit = ,
        // CAA009 单位 -> MES_UNIT.id
        if (!string.IsNullOrEmpty(erpDto.FUnitID))
        {
            var unit = Db.Queryable<MesUnit>()
                .Where(u => u.Fnumber == erpDto.FUnitID)
                .Select(u => u.Id)
                .First();
            productionOrder.Unit = unit.ToString();
        }
        // CAA006 产品编码 -> MES_ITEMS.id
        if (!string.IsNullOrEmpty(erpDto.FMaterialId))
        {
            var item = Db.Queryable<MesItems>()
                .Where(i => i.ItemNo == erpDto.FMaterialId)
                .Select(i => i.Id)
                .First();
            productionOrder.ProductCode = item.ToString();
        }
        // Warehouse = erpDto.FStockID,
        if (!string.IsNullOrEmpty(erpDto.FStockID))
        {
            var depot = Db.Queryable<MesDepots>()
                .Where(d => d.DepotCode == erpDto.FStockID)
                .Select(d => d.DepotId)
                .First();
            productionOrder.Warehouse = depot.ToString();
        }
        var single = base.GetSingle(it =>
            it.ErpProductionEntryCode == erpDto.FSUBENTRYID);
        if (single != null) productionOrder.Guid = single.Guid;
        return productionOrder;