管道基础大数据平台系统开发-【CS】-ExportMap
1
13693261870
2023-07-25 d6bc097e6974c0ba8f7ff74b9f8a86ba5addf036
1
已修改3个文件
48 ■■■■ 文件已修改
ExportMap/cs/TerraUtils.cs 39 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ExportMap/db/PubDBHelper.cs 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ExportMap/export.html 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ExportMap/cs/TerraUtils.cs
@@ -134,14 +134,34 @@
            string txtFile = null;
            try
            {
                txtFile = Path.Combine(Tools.TempDir, ExportUtil.DateStr + ".txt");
                string dirPath = GetTerrainPath(args.dircode);
                if (!Directory.Exists(dirPath)) Directory.CreateDirectory(dirPath);
                txtFile = Path.Combine(Tools.TempDir, ExportUtil.DateStr + ".txt");
                string tifFile = Path.Combine(dirPath, args.dircode + ".tif");
                //if (File.Exists(tifFile)) File.Delete(tifFile);
                WriteText(txtFile, metas);
                int pubid = PubDBHelper.GetPushlishId(args.dircode, "DEM");
                if (pubid > 0 && File.Exists(tifFile))
                {
                    List<int> ids = PubDBHelper.GetPublishMetaId(pubid);
                    List<SysMeta> news = new List<SysMeta>();
                    foreach (SysMeta m in metas)
                    {
                        if (!ids.Contains(m.id)) news.Add(m);
                    }
                    if (0 == news.Count) return tifFile;
                    string oldTif = Path.Combine(dirPath, args.dircode + "_old.tif");
                    if (File.Exists(oldTif)) File.Delete(oldTif);
                    File.Move(tifFile, oldTif);
                    WriteText(txtFile, news, oldTif);
                }
                else
                {
                    if (File.Exists(tifFile)) File.Delete(tifFile);
                    WriteText(txtFile, metas, null);
                }
                string cmd = string.Format("python \"{0}\" -qgz {1} -file \"{2}\" -out \"{3}\"", PyFile, Qgz, txtFile, tifFile);
                err = Tools.ExecCmd(cmd, true, false);
@@ -157,24 +177,30 @@
            finally
            {
                if (!string.IsNullOrEmpty(txtFile) && File.Exists(txtFile)) File.Delete(txtFile);
                string dirPath = GetTerrainPath(args.dircode);
                string tifFile = Path.Combine(dirPath, args.dircode + ".tif");
                string oldTif = Path.Combine(dirPath, args.dircode + "_old.tif");
                if (File.Exists(tifFile) && File.Exists(oldTif)) File.Delete(oldTif);
            }
        }
        /// <summary>
        /// 写文本文件
        /// </summary>
        private static void WriteText(string txtFile, List<SysMeta> list)
        private static void WriteText(string txtFile, List<SysMeta> list, string tif)
        {
            string uploadFolder = Tools.GetSetting("uploadFolder");
            List<string> files = new List<string>();
            if (!string.IsNullOrEmpty(tif)) files.Add(tif);
            foreach (SysMeta meta in list)
            {
                string filePath = Path.Combine(uploadFolder, meta.path);
                if (File.Exists(filePath)) files.Add(filePath);
            }
            string str = string.Join("\r\n", files);
            string str = string.Join("\r\n", files);
            File.WriteAllText(txtFile, str);
        }
@@ -235,6 +261,9 @@
                {
                    if (!ids.Contains(m.id)) PubDBHelper.InsertMetaPub(m.id, pubid, args.userId);
                }
                string json = GetPointZ(args);
                if (!string.IsNullOrEmpty(json)) PubDBHelper.UpdatePublishCoord(pubid, json);
                return pubid;
            }
ExportMap/db/PubDBHelper.cs
@@ -100,9 +100,10 @@
        /// </summary>
        public static int UpdatePublishCoord(int pid, string json)
        {
            string sql = string.Format("update lf.sys_publish set json = '{0}' where id = {1}", json, pid);
            string sql = string.Format("update lf.sys_publish set json = @json where id = {0}", pid);
            DbParameter dp = new NpgsqlParameter("@json", json);
            return Tools.DBHelper.ExecuteNonQuery(sql);
            return Tools.DBHelper.ExecuteNonQuery(sql, dp);
        }
        /// <summary>
ExportMap/export.html
@@ -10,7 +10,7 @@
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <script src="js/jquery.1.12.4.js"></script>
  <script>
    var token = "0de31b49-1957-4e15-8258-965a35ea56cb";
    var token = "5f98316d-de91-4850-a20f-44080a278115";
    // Ajax
    function ajax(url, type, data, dataType, contentType, fn) {
@@ -127,7 +127,7 @@
    
    // 测试Terra:10526,10527
    function toTerra() {
      var data = { token: token, ids: [10526], min: 0, max: 18, depcode: "00", dircode: "09", userId: 1, name: "BN_GD" };
      var data = { token: token, ids: [10526, 10527], min: 0, max: 18, depcode: "00", dircode: "09", userId: 1, name: "BN_GD" };
      ajax("Convert/ToTerra", "POST", JSON.stringify(data), null, null, function (rs) {
        alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result);
        console.log(rs);