啊鑫
5 天以前 e6cdb148ba75253136ec0bf7bad7785c24e84a86
MES.Service/service/BasicData/MesRohInManager.cs
@@ -104,10 +104,12 @@
        // 1. 处理 fDate(采购日期)
        if (!rohIn.FDate.IsNullOrEmpty())
        {
            if (!DateTime.TryParseExact(rohIn.FDate, "yyyy-MM-d H:m:s", CultureInfo.InvariantCulture,
            if (!DateTime.TryParseExact(rohIn.FDate, "yyyy-MM-d H:m:s",
                    CultureInfo.InvariantCulture,
                    DateTimeStyles.None, out DateTime purchaseDate))
            {
                throw new FormatException($"采购日期(FDate)解析失败!值:【{rohIn.FDate}】,支持格式:yyyy-MM-d H:m:s");
                throw new FormatException(
                    $"采购日期(FDate)解析失败!值:【{rohIn.FDate}】,支持格式:yyyy-MM-d H:m:s");
            }
            mesRohIn.PurchaseDate = purchaseDate;
@@ -118,7 +120,15 @@
        }
        mesRohIn.Supplier = rohIn.FSupplierId;
        var mesSupplier = Db.Queryable<MesSupplier>()
            .Where(s => s.SuppNo == rohIn.FSupplierId)
            .First();
        if (mesSupplier != null)
        {
            mesRohIn.Supplier = mesSupplier.Id.ToString();
        }
        mesRohIn.CloseStatus = rohIn.FCloseStatus;
        mesRohIn.PurchaseOrg = rohIn.FPurchaseOrgId;
        mesRohIn.PurchaseDept = rohIn.FPurchaseDeptId;
@@ -147,12 +157,15 @@
            ? DateTime.ParseExact(rohIn.Prearrivaldate,
                "yyyy-MM-d H:m:s", null)
            : null;*/
        if (!rohIn.FCancelDate.IsNullOrEmpty() && !mesRohIn.CancellationPerson.IsNullOrEmpty())
        if (!rohIn.FCancelDate.IsNullOrEmpty() &&
            !mesRohIn.CancellationPerson.IsNullOrEmpty())
        {
            if (!DateTime.TryParseExact(rohIn.FCancelDate, "yyyy-MM-d H:m:s", CultureInfo.InvariantCulture,
            if (!DateTime.TryParseExact(rohIn.FCancelDate, "yyyy-MM-d H:m:s",
                    CultureInfo.InvariantCulture,
                    DateTimeStyles.None, out DateTime cancelDate))
            {
                throw new FormatException($"取消日期(FCancelDate)解析失败!值:【{rohIn.FCancelDate}】,支持格式:yyyy-MM-d H:m:s");
                throw new FormatException(
                    $"取消日期(FCancelDate)解析失败!值:【{rohIn.FCancelDate}】,支持格式:yyyy-MM-d H:m:s");
            }
            mesRohIn.CancellationDate = cancelDate;
@@ -165,10 +178,12 @@
        // 3. 处理 fCreateDate(创建日期)
        if (!rohIn.FCreateDate.IsNullOrEmpty())
        {
            if (!DateTime.TryParseExact(rohIn.FCreateDate, "yyyy-MM-d H:m:s", CultureInfo.InvariantCulture,
            if (!DateTime.TryParseExact(rohIn.FCreateDate, "yyyy-MM-d H:m:s",
                    CultureInfo.InvariantCulture,
                    DateTimeStyles.None, out DateTime createDate))
            {
                throw new FormatException($"创建日期(FCreateDate)解析失败!值:【{rohIn.FCreateDate}】,支持格式:yyyy-MM-d H:m:s");
                throw new FormatException(
                    $"创建日期(FCreateDate)解析失败!值:【{rohIn.FCreateDate}】,支持格式:yyyy-MM-d H:m:s");
            }
            mesRohIn.CreateDate = createDate;
@@ -181,10 +196,12 @@
        // 4. 处理 fModifyDate(修改日期)
        if (!rohIn.FModifyDate.IsNullOrEmpty())
        {
            if (!DateTime.TryParseExact(rohIn.FModifyDate, "yyyy-MM-d H:m:s", CultureInfo.InvariantCulture,
            if (!DateTime.TryParseExact(rohIn.FModifyDate, "yyyy-MM-d H:m:s",
                    CultureInfo.InvariantCulture,
                    DateTimeStyles.None, out DateTime modifyDate))
            {
                throw new FormatException($"修改日期(FModifyDate)解析失败!值:【{rohIn.FModifyDate}】,支持格式:yyyy-MM-d H:m:s");
                throw new FormatException(
                    $"修改日期(FModifyDate)解析失败!值:【{rohIn.FModifyDate}】,支持格式:yyyy-MM-d H:m:s");
            }
            mesRohIn.LastupdateDate = modifyDate;
@@ -198,7 +215,8 @@
        // 6. 处理 prearrivaldate(预计到货日期)
        if (!rohIn.Prearrivaldate.IsNullOrEmpty())
        {
            if (!DateTime.TryParseExact(rohIn.Prearrivaldate, "yyyy-MM-d H:m:s", CultureInfo.InvariantCulture,
            if (!DateTime.TryParseExact(rohIn.Prearrivaldate, "yyyy-MM-d H:m:s",
                    CultureInfo.InvariantCulture,
                    DateTimeStyles.None, out DateTime preArrivalDate))
            {
                throw new FormatException(
@@ -261,7 +279,8 @@
                    */
                // 1. 处理 fDeliveryDate(交货日期)
                DeliveryDate = !s.FDeliveryDate.IsNullOrEmpty()
                    ? (DateTime.TryParseExact(s.FDeliveryDate, "yyyy-MM-d H:m:s", CultureInfo.InvariantCulture,
                    ? (DateTime.TryParseExact(s.FDeliveryDate,
                        "yyyy-MM-d H:m:s", CultureInfo.InvariantCulture,
                        DateTimeStyles.None, out DateTime deliveryDate)
                        ? deliveryDate
                        : throw new FormatException(
@@ -270,7 +289,8 @@
                // 2. 处理 fDeliveryEarlyDate(最早交货日期)
                EarliestDeliveryDate = !s.FDeliveryEarlyDate.IsNullOrEmpty()
                    ? (DateTime.TryParseExact(s.FDeliveryEarlyDate, "yyyy-MM-d H:m:s", CultureInfo.InvariantCulture,
                    ? (DateTime.TryParseExact(s.FDeliveryEarlyDate,
                        "yyyy-MM-d H:m:s", CultureInfo.InvariantCulture,
                        DateTimeStyles.None, out DateTime earlyDate)
                        ? earlyDate
                        : throw new FormatException(
@@ -279,7 +299,8 @@
                // 3. 处理 fDeliveryLastDate(最晚交货日期)
                LatestDeliveryDate = !s.FDeliveryLastDate.IsNullOrEmpty()
                    ? (DateTime.TryParseExact(s.FDeliveryLastDate, "yyyy-MM-d H:m:s", CultureInfo.InvariantCulture,
                    ? (DateTime.TryParseExact(s.FDeliveryLastDate,
                        "yyyy-MM-d H:m:s", CultureInfo.InvariantCulture,
                        DateTimeStyles.None, out DateTime lastDate)
                        ? lastDate
                        : throw new FormatException(
@@ -341,10 +362,12 @@
// 4. 处理 fFreezeDate(冻结日期)
            if (!s.FFreezeDate.IsNullOrEmpty() && !s.FFreezerId.IsNullOrEmpty())
            {
                if (!DateTime.TryParseExact(s.FFreezeDate, "yyyy-MM-d H:m:s", CultureInfo.InvariantCulture,
                if (!DateTime.TryParseExact(s.FFreezeDate, "yyyy-MM-d H:m:s",
                        CultureInfo.InvariantCulture,
                        DateTimeStyles.None, out DateTime freezeTime))
                {
                    throw new FormatException($"冻结日期(FFreezeDate)解析失败!值:【{s.FFreezeDate}】,支持格式:yyyy-MM-d H:m:s");
                    throw new FormatException(
                        $"冻结日期(FFreezeDate)解析失败!值:【{s.FFreezeDate}】,支持格式:yyyy-MM-d H:m:s");
                }
                entity.FreezeTime = freezeTime;
@@ -355,12 +378,15 @@
            }
            // 5. 处理 fTerminateDate(终止日期)
            if (!s.FTerminateDate.IsNullOrEmpty() && !s.FTerminaterId.IsNullOrEmpty())
            if (!s.FTerminateDate.IsNullOrEmpty() &&
                !s.FTerminaterId.IsNullOrEmpty())
            {
                if (!DateTime.TryParseExact(s.FTerminateDate, "yyyy-MM-d H:m:s", CultureInfo.InvariantCulture,
                if (!DateTime.TryParseExact(s.FTerminateDate, "yyyy-MM-d H:m:s",
                        CultureInfo.InvariantCulture,
                        DateTimeStyles.None, out DateTime terminateTime))
                {
                    throw new FormatException($"终止日期(FTerminateDate)解析失败!值:【{s.FTerminateDate}】,支持格式:yyyy-MM-d H:m:s");
                    throw new FormatException(
                        $"终止日期(FTerminateDate)解析失败!值:【{s.FTerminateDate}】,支持格式:yyyy-MM-d H:m:s");
                }
                entity.TerminateTime = terminateTime;
@@ -370,6 +396,16 @@
                entity.TerminateTime = null;
            }
            //ItemId
            var mesItems = Db.Queryable<MesItems>()
                .Where(s => s.ItemNo == entity.ItemId)
                .First();
            if (mesItems != null)
            {
                entity.ItemId = mesItems.Id.ToString();
            }
            var single = rohInDataManager.GetSingle(it =>
                it.EbelnK3id == entity.EbelnK3id);
            if (single != null) entity.Guid = single.Guid;