public void ImportKKSFromFile(string file) { Log.Info(LogTags.KKS, string.Format("加载文件:") + file); string basePath = AppDomain.CurrentDomain.BaseDirectory; string filePath = basePath + "KKS\\Data\\中电四会部件级KKS编码2017.5.24\\" + file; KKSCodeHelper.ImportKKSCodeFromFile <KKSCode>(new FileInfo(filePath)); }
private void ImportKKSFromDirectory(string folderPath) { //导入到定位数据库中 List <KKSCode> kksList = bll.KKSCodes.ToList(); KKSImportInfo <KKSCode> importInfo1 = KKSCodeHelper.ImportKKSFromDirectory <KKSCode>(folderPath, kksList); bll.KKSCodes.EditRange(bll.Db, importInfo1.listEditInfo); //修改的部分 bll.KKSCodes.AddRange(bll.Db, importInfo1.listAddInfo); //新增的部分 }
private void InitKKSCode() { //先导入KKS再初始化其他数据 Log.Info("导入土建KKS"); string basePath = AppDomain.CurrentDomain.BaseDirectory; Log.Info("BaseDirectory:" + basePath); string filePath = basePath + "Data\\中电四会部件级KKS编码2017.5.24\\土建\\中电四会热电有限责任公司KKS项目-土建系统-B.xls"; KKSCodeHelper.ImportKKSFromFile <KKSCode>(new FileInfo(filePath)); }
public void InitKKSNode() { //先导入KKS再初始化其他数据 Log.Info(LogTags.DbInit, "导入土建KKS"); string basePath = AppDomain.CurrentDomain.BaseDirectory; Log.Info(LogTags.DbInit, "BaseDirectory:" + basePath); string filePath = basePath + "Data\\KKS\\四会热电KKS和设备编码清册_KKS.xlsx"; FileInfo file = new FileInfo(filePath); KKSCodeHelper.ImportKKSNodeFromFile <KKSCode>(file); }
public void InitKKSCode() { //先导入KKS再初始化其他数据 Log.Info("导入土建KKS"); string basePath = AppDomain.CurrentDomain.BaseDirectory; Log.Info("BaseDirectory:" + basePath); //土建 string filePath = basePath + "Data\\中电四会部件级KKS编码2017.5.24\\土建\\中电四会热电有限责任公司KKS项目-土建系统-B.xls"; KKSCodeHelper.ImportKKSFromFile <KKSCode>(new FileInfo(filePath)); //电气 filePath = basePath + "Data\\中电四会部件级KKS编码2017.5.24\\电气\\中电四会热电有限责任公司KKS项目-电气盘柜系统-B.xls"; KKSCodeHelper.ImportKKSFromFile <KKSCode>(new FileInfo(filePath)); filePath = basePath + "Data\\中电四会部件级KKS编码2017.5.24\\电气\\中电四会热电有限责任公司KKS项目-电气一次总表-B.xls"; KKSCodeHelper.ImportKKSFromFile <KKSCode>(new FileInfo(filePath)); filePath = basePath + "Data\\中电四会部件级KKS编码2017.5.24\\电气\\中电四会热电有限责任公司KKS项目-火灾报警系统-B.xls"; KKSCodeHelper.ImportKKSFromFile <KKSCode>(new FileInfo(filePath)); filePath = basePath + "Data\\中电四会部件级KKS编码2017.5.24\\电气\\中电四会热电有限责任公司KKS项目-视频监控系统-B.xls"; KKSCodeHelper.ImportKKSFromFile <KKSCode>(new FileInfo(filePath)); filePath = basePath + "Data\\中电四会部件级KKS编码2017.5.24\\电气\\中电四会热电有限责任公司KKS项目-照明检修箱系统-B.xls"; KKSCodeHelper.ImportKKSFromFile <KKSCode>(new FileInfo(filePath)); //锅炉 filePath = basePath + "Data\\中电四会部件级KKS编码2017.5.24\\锅炉\\中电四会热电有限责任公司KKS项目-#1炉总表-B.xls"; KKSCodeHelper.ImportKKSFromFile <KKSCode>(new FileInfo(filePath)); filePath = basePath + "Data\\中电四会部件级KKS编码2017.5.24\\锅炉\\中电四会热电有限责任公司KKS项目-#3炉总表-B.xls"; KKSCodeHelper.ImportKKSFromFile <KKSCode>(new FileInfo(filePath)); //化学 filePath = basePath + "Data\\中电四会部件级KKS编码2017.5.24\\化学\\中电四会热电有限责任公司KKS项目-化学总表-B.xls"; KKSCodeHelper.ImportKKSFromFile <KKSCode>(new FileInfo(filePath)); //暖通 filePath = basePath + "Data\\中电四会部件级KKS编码2017.5.24\\暖通\\中电四会热电有限责任公司KKS项目-暖通系统-B.xls"; KKSCodeHelper.ImportKKSFromFile <KKSCode>(new FileInfo(filePath)); //汽机 filePath = basePath + "Data\\中电四会部件级KKS编码2017.5.24\\汽机\\中电四会热电有限责任公司KKS项目-#1汽机总表-B.xls"; KKSCodeHelper.ImportKKSFromFile <KKSCode>(new FileInfo(filePath)); filePath = basePath + "Data\\中电四会部件级KKS编码2017.5.24\\汽机\\中电四会热电有限责任公司KKS项目-#3汽机总表-B.xls"; KKSCodeHelper.ImportKKSFromFile <KKSCode>(new FileInfo(filePath)); //燃机 filePath = basePath + "Data\\中电四会部件级KKS编码2017.5.24\\燃机\\中电四会热电有限责任公司KKS项目-#2燃机总表-B.xls"; KKSCodeHelper.ImportKKSFromFile <KKSCode>(new FileInfo(filePath)); filePath = basePath + "Data\\中电四会部件级KKS编码2017.5.24\\燃机\\中电四会热电有限责任公司KKS项目-#4燃机总表-B.xls"; KKSCodeHelper.ImportKKSFromFile <KKSCode>(new FileInfo(filePath)); filePath = basePath + "Data\\中电四会部件级KKS编码2017.5.24\\燃机\\中电四会热电有限责任公司KKS项目-调压站系统-B.xls"; KKSCodeHelper.ImportKKSFromFile <KKSCode>(new FileInfo(filePath)); //热控 filePath = basePath + "Data\\中电四会部件级KKS编码2017.5.24\\热控\\中电四会热电有限责任公司KKS项目-热控盘柜系统-B.xls"; KKSCodeHelper.ImportKKSFromFile <KKSCode>(new FileInfo(filePath)); //消防 filePath = basePath + "Data\\中电四会部件级KKS编码2017.5.24\\消防\\中电四会热电有限责任公司KKS项目-消防系统-B.xls"; KKSCodeHelper.ImportKKSFromFile <KKSCode>(new FileInfo(filePath)); }
/// <summary> /// 解析测定数据 关联KKS 【UDPoints20190321.xlsx】 /// </summary> public static void ParseMonitorPoint() { try { DateTime start = DateTime.Now; string basePath = AppDomain.CurrentDomain.BaseDirectory; //string filePath = basePath + "Data\\KKS\\EDOSOriginalCode.xls"; //string createfilePath = basePath + "..\\..\\Data\\KKS\\EDOS.xls"; //int nReturn = Location.BLL.Tool.KKSCodeHelper.OriginalKKSCode(new FileInfo(filePath), createfilePath); string filePath = basePath + "Data\\KKS\\UDPoints20190321.xlsx"; Log.Info(LogTags.KKS, "读取测点文件"); DataTable dt = KKSCodeHelper.OriginalKKSCode_New(new FileInfo(filePath), true); //解析 if (dt != null) { //保存到文件 FileInfo file1 = new FileInfo(basePath + "..\\..\\Data\\KKS\\EDOS_New.xls"); if (file1.Exists) //已经存在说明是在vs里面打开 { ExcelHelper.Save(dt, file1, null); //更新的是项目文件中的文件 } FileInfo file2 = new FileInfo(basePath + "Data\\KKS\\EDOS_New.xls"); ExcelHelper.Save(dt, file2, null); Log.Info(LogTags.KKS, "KKS转义完成"); //保存到数据库 //Log.Info(LogTags.KKS, "保存到数据库"); //bool r1 = bll.DevMonitorNodes.Clear(1); //ist<DbModel.Location.AreaAndDev.DevMonitorNode> list1 = DevInfoHelper.CreateDevMonitorNodeListFromDataTable<DbModel.Location.AreaAndDev.DevMonitorNode>(dt); //bool r2 = bll.DevMonitorNodes.AddRange(bll.Db, list1); //新增的部分 } else { Log.Info(LogTags.KKS, "原始KKS码文件不存在"); } TimeSpan time = DateTime.Now - start; Log.Info(LogTags.KKS, string.Format("【2】【ParseMonitorPoint】完成 用时:{0}", time)); } catch (Exception ex) { Log.Error(LogTags.KKS, "KKS转义失败:" + ex.Message); } }
public void InitKKSCode() { Log.Info(LogTags.KKS, string.Format("清空数据")); bool r1 = _bll.KKSCodes.Clear(1); //先导入KKS再初始化其他数据 Log.Info(LogTags.DbInit, "导入土建KKS"); string basePath = AppDomain.CurrentDomain.BaseDirectory; Log.Info(LogTags.DbInit, "BaseDirectory:" + basePath); DirectoryInfo dir = new DirectoryInfo(basePath + "Data\\KKS\\中电四会部件级KKS编码2017.5.24\\"); FileInfo[] files = dir.GetFiles("*.xls", SearchOption.AllDirectories); for (int i = 0; i < files.Length; i++) { FileInfo file = files[i]; Log.Info(LogTags.KKS, string.Format("加载文件:{0}({1}/{2})", file, i + 1, files.Length)); KKSCodeHelper.ImportKKSCodeFromFile <KKSCode>(file); } ////土建 //ImportKKSCodeFromFile("土建\\中电四会热电有限责任公司KKS项目-土建系统-B.xls"); ////电气 //ImportKKSCodeFromFile("电气\\中电四会热电有限责任公司KKS项目-电气盘柜系统-B.xls"); //ImportKKSCodeFromFile("电气\\中电四会热电有限责任公司KKS项目-电气一次总表-B.xls"); //ImportKKSCodeFromFile("电气\\中电四会热电有限责任公司KKS项目-火灾报警系统-B.xls"); //ImportKKSCodeFromFile("电气\\中电四会热电有限责任公司KKS项目-视频监控系统-B.xls"); //ImportKKSCodeFromFile("电气\\中电四会热电有限责任公司KKS项目-照明检修箱系统-B.xls"); ////锅炉 //string filePath = basePath + "KKS\\Data\\中电四会部件级KKS编码2017.5.24\\锅炉\\中电四会热电有限责任公司KKS项目-#1炉总表-B.xls"; //KKSCodeHelper.ImportKKSCodeFromFile<KKSCode>(new FileInfo(filePath)); //filePath = basePath + "KKS\\Data\\中电四会部件级KKS编码2017.5.24\\锅炉\\中电四会热电有限责任公司KKS项目-#3炉总表-B.xls"; //KKSCodeHelper.ImportKKSCodeFromFile<KKSCode>(new FileInfo(filePath)); ////化学 //filePath = basePath + "KKS\\Data\\中电四会部件级KKS编码2017.5.24\\化学\\中电四会热电有限责任公司KKS项目-化学总表-B.xls"; //KKSCodeHelper.ImportKKSCodeFromFile<KKSCode>(new FileInfo(filePath)); ////暖通 //filePath = basePath + "KKS\\Data\\中电四会部件级KKS编码2017.5.24\\暖通\\中电四会热电有限责任公司KKS项目-暖通系统-B.xls"; //KKSCodeHelper.ImportKKSCodeFromFile<KKSCode>(new FileInfo(filePath)); ////汽机 //filePath = basePath + "KKS\\Data\\中电四会部件级KKS编码2017.5.24\\汽机\\中电四会热电有限责任公司KKS项目-#1汽机总表-B.xls"; //KKSCodeHelper.ImportKKSCodeFromFile<KKSCode>(new FileInfo(filePath)); //filePath = basePath + "KKS\\Data\\中电四会部件级KKS编码2017.5.24\\汽机\\中电四会热电有限责任公司KKS项目-#3汽机总表-B.xls"; //KKSCodeHelper.ImportKKSCodeFromFile<KKSCode>(new FileInfo(filePath)); ////燃机 //filePath = basePath + "KKS\\Data\\中电四会部件级KKS编码2017.5.24\\燃机\\中电四会热电有限责任公司KKS项目-#2燃机总表-B.xls"; //KKSCodeHelper.ImportKKSCodeFromFile<KKSCode>(new FileInfo(filePath)); //filePath = basePath + "KKS\\Data\\中电四会部件级KKS编码2017.5.24\\燃机\\中电四会热电有限责任公司KKS项目-#4燃机总表-B.xls"; //KKSCodeHelper.ImportKKSCodeFromFile<KKSCode>(new FileInfo(filePath)); //filePath = basePath + "KKS\\Data\\中电四会部件级KKS编码2017.5.24\\燃机\\中电四会热电有限责任公司KKS项目-调压站系统-B.xls"; //KKSCodeHelper.ImportKKSCodeFromFile<KKSCode>(new FileInfo(filePath)); ////热控 //filePath = basePath + "KKS\\Data\\中电四会部件级KKS编码2017.5.24\\热控\\中电四会热电有限责任公司KKS项目-热控盘柜系统-B.xls"; //KKSCodeHelper.ImportKKSCodeFromFile<KKSCode>(new FileInfo(filePath)); ////消防 //filePath = basePath + "KKS\\Data\\中电四会部件级KKS编码2017.5.24\\消防\\中电四会热电有限责任公司KKS项目-消防系统-B.xls"; //KKSCodeHelper.ImportKKSCodeFromFile<KKSCode>(new FileInfo(filePath)); }
/// <summary> /// 重新分析测点数据,原来未找到kks的进行二次深入分析 /// </summary> public static void ReParseMonitPoint(bool fromFile) { DateTime start = DateTime.Now; Log.Info(LogTags.KKS, "重新分析设备监控节点"); Bll bll = new Bll(); List <DbModel.Location.AreaAndDev.DevMonitorNode> monitors = null; if (fromFile) //从文件读取 { string basePath = AppDomain.CurrentDomain.BaseDirectory; Log.Info(LogTags.KKS, "BaseDirectory:" + basePath); string filePath = basePath + "Data\\KKS\\EDOS_New.xls"; monitors = DevInfoHelper.CreateDevMonitorNodeListFromFile <DbModel.Location.AreaAndDev.DevMonitorNode>( new FileInfo(filePath)); } else //从数据库读取 { monitors = bll.DevMonitorNodes.ToList(); } var kksCodes = bll.KKSCodes.ToListEx(); var kksDict = KKSCode.ToDict(kksCodes); for (int i = 0; i < monitors.Count; i++) { DbModel.Location.AreaAndDev.DevMonitorNode monitor = monitors[i]; if (i > 0) { monitor.PreNode = monitors[i - 1]; } if (i < monitors.Count - 1) { monitor.NextMode = monitors[i + 1]; } if (kksDict.ContainsKey(monitor.ParentKKS)) { monitor.KKSCode = kksDict[monitor.ParentKKS]; } } var monitors1 = monitors.Where(i => i.ParseResult == "0").ToList(); var monitors2 = monitors.Where(i => i.ParseResult == "1").ToList(); var monitors31 = monitors.Where(i => i.ParseResult == "-1").ToList(); var monitors311 = monitors31.Where(i => i.Unit != "").ToList(); var monitors32 = monitors.Where(i => i.ParseResult == "-2").ToList(); var monitors321 = monitors32.Where(i => i.Unit != "").ToList(); var monitors4 = monitors.Where(i => i.ParseResult.ToInt() > 1).ToList(); List <DbModel.Location.AreaAndDev.DevMonitorNode> editMonitorNodes = new List <DbModel.Location.AreaAndDev.DevMonitorNode>(); for (int i = 0; i < monitors4.Count; i++) { DbModel.Location.AreaAndDev.DevMonitorNode monitorNode = monitors4[i]; try { var parentCode = monitorNode.ParentKKS; TagToKKSInfo info = KKSCodeHelper.ReParese(kksCodes, monitorNode.ParentKKS, monitorNode.KKS); var code = info.GetParentCode(); if (info.Type == 1 || info.Type == 0) { monitorNode.ParentKKS = code; monitorNode.ParseResult = "1"; //这里统一为1 editMonitorNodes.Add(monitorNode); Log.Info(LogTags.KKS, string.Format("解析测点:{0}=>{1}[{2}],({3}/{4})", parentCode, code, info.KKS, i, monitors4.Count)); } else { if (monitorNode.PreNode != null) { if (monitorNode.PreNode.KKSCode != null) { var kksCode = monitorNode.PreNode.KKSCode.GetAncestor("系统"); if (kksCode != null) { monitorNode.ParentKKS = kksCode.Code; monitorNode.ParseResult = "1"; //感觉这里要区分开来了 editMonitorNodes.Add(monitorNode); } else { Log.Info(LogTags.KKS, string.Format("monitorNode.PreNode.KKSCode 未找到系统节点:{0}", monitorNode.PreNode.KKSCode)); } } else { Log.Info(LogTags.KKS, string.Format("monitorNode.PreNode.KKSCode == null:{0}", monitorNode.PreNode)); } } else { } } } catch (Exception e) { Log.Error(LogTags.KKS, monitorNode + "\n" + e + ""); } } bll.DevMonitorNodes.EditRange(editMonitorNodes); TimeSpan time = DateTime.Now - start; Log.Info(LogTags.KKS, string.Format("【4】【ReParseMonitPoint】完成 用时:{0}", time)); }