kazelee
2025-05-16 6abc355aeb4e6f7960c11795dbbcc26396b0c888
Services/DebugService.cs
@@ -76,7 +76,6 @@
            return returnResults;
        }
        /// <summary>
        /// 初始数据库建立
        /// </summary>
@@ -175,16 +174,6 @@
                            loc = newLoc;
                        }
                        //if (loc.N_CURRENT_NUM == 0) {
                        //    loc.N_CURRENT_NUM = 1;
                        //    if (db.Updateable<TN_Location>(loc).UpdateColumns(
                        //        it => new { it.N_CURRENT_NUM, it.T_MODIFY }).ExecuteCommand() <= 0) {
                        //        tran.RollbackTran();
                        //        LogHelper.Info($"修改位置{locCntrCg.LocCode}失败");
                        //        continue;
                        //    }
                        //}
                        if (string.IsNullOrEmpty(locCntrCg.CntrCode)) {
                            LogHelper.Info("容器号为空,不再读取后面的数据");
                            continue;
@@ -210,23 +199,23 @@
                            }
                        }
                        if (string.IsNullOrEmpty(locCntrCg.CgId)) {
                        if (string.IsNullOrEmpty(locCntrCg.ItemCode)) {
                            LogHelper.Info("物料号为空,不再读取后面的数据");
                            continue;
                        }
                        var cgDetail = db.Queryable<TN_CG_Detail>().First(a => a.S_CNTR_CODE == locCntrCg.CntrCode
                            && a.S_ITEM_CODE == locCntrCg.CgId);
                            && a.S_ITEM_CODE == locCntrCg.ItemCode);
                        if (cgDetail == null) {
                            var locList = new List<TN_CG_Detail>();
                            locList.Add(new TN_CG_Detail { S_CNTR_CODE = locCntrCg.CntrCode, S_ITEM_CODE = locCntrCg.CgId, S_BATCH_NO = locCntrCg.BatchNo ?? "" });
                            locList.Add(new TN_CG_Detail { S_CNTR_CODE = locCntrCg.CntrCode, S_ITEM_CODE = locCntrCg.ItemCode, S_BATCH_NO = locCntrCg.BatchNo ?? "" });
                            if (db.Insertable<TN_CG_Detail>(locList).ExecuteCommand() <= 0) {
                                tran.RollbackTran();
                                LogHelper.Info($"插入托盘物料关系{locCntrCg.CntrCode}-{locCntrCg}失败");
                                return "插入失败";
                            }
                        }
                    }
                    }
                    tran.CommitTran();
                }
@@ -240,42 +229,5 @@
                return $"Error reading CSV file: {ex.Message}";
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        //public string InsertOutboundOrder() {
        //    string filePath = PathHelper.GetProjDir("./debug/outbound_order.csv");
        //    var db = DbHelper.GetDbClient();
        //    try {
        //        var configuration = new CsvConfiguration(CultureInfo.InvariantCulture) {
        //            // 配置选项
        //            Delimiter = ",",               // 分隔符
        //            HasHeaderRecord = true,        // 有标题行
        //            MissingFieldFound = null,      // 忽略缺失字段
        //            HeaderValidated = null,        // 跳过标题验证
        //            BadDataFound = context => { }  // 处理错误数据
        //        };
        //        var locCntrCgList = new List<DebugModel.OutboundOrder>();
        //        using (var reader = new StreamReader(filePath))
        //        using (var csv = new CsvReader(reader, configuration)) {
        //            // 读取记录
        //            locCntrCgList = csv.GetRecords<DebugModel.OutboundOrder>().ToList();
        //        }
        //        using (var tran = db.Ado.UseTran()) {
        //        }
        //    }
        //    catch (Exception) {
        //        throw;
        //    }
        //}
    }
}