DataMaintenance
parent
054ed8aaa8
commit
89686f639a
|
|
@ -269,10 +269,10 @@ public class LayerApp : SqlSugarBaseApp<DmLayer, SugarDbContext>
|
|||
}
|
||||
public Response<Dictionary<string, object>> TableDataByTableName(string tablename, string type, string keyword, string keyvalue, int page, int pagesize)
|
||||
{
|
||||
Dictionary<string,object> result = new Dictionary<string,object>();
|
||||
// string sql = $"select column_name as name from INFORMATION_SCHEMA.COLUMNS WHERE table_schema = 'public' AND table_name ='" + tablename + "'";
|
||||
Dictionary<string, object> result = new Dictionary<string, object>();
|
||||
// string sql = $"select column_name as name from INFORMATION_SCHEMA.COLUMNS WHERE table_schema = 'public' AND table_name ='" + tablename + "'";
|
||||
string sqlcom = $"SELECT \r\n\r\n\r\n c.column_name AS \"columnName\", pgd.description AS \"comment\" \r\nFROM \r\n information_schema.columns c\r\nLEFT JOIN \r\n " +
|
||||
$"pg_catalog.pg_description pgd ON pgd.objoid = c.table_name::regclass::oid \r\n AND pgd.objsubid = c.ordinal_position\r\nWHERE \r\n c.table_name ='"+tablename+"';";
|
||||
$"pg_catalog.pg_description pgd ON pgd.objoid = c.table_name::regclass::oid \r\n AND pgd.objsubid = c.ordinal_position\r\nWHERE \r\n c.table_name ='" + tablename + "';";
|
||||
//var cloumnlist = _client.Ado.SqlQuery<string>(sql);
|
||||
var coment = _client.Ado.SqlQuery<dynamic>(sqlcom);
|
||||
//result.Add("head", cloumnlist);
|
||||
|
|
@ -280,23 +280,24 @@ public class LayerApp : SqlSugarBaseApp<DmLayer, SugarDbContext>
|
|||
string names = "";
|
||||
string geoms = "";
|
||||
for (int i = 0; i < coment.Count; i++)
|
||||
{ var name = coment[i].columnName;
|
||||
{
|
||||
var name = coment[i].columnName;
|
||||
if (name.Contains("geom"))
|
||||
{
|
||||
geoms = name;
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
names = names +"\""+ name + "\",";
|
||||
names = names + "\"" + name + "\",";
|
||||
}
|
||||
}
|
||||
string sql1 = $"select " + names + "ST_AsText(" + geoms + ") as " + geoms + $" from " + tablename + " where 1=1 ";
|
||||
string sql2 = "";
|
||||
if (string.IsNullOrEmpty(keyword) || string.IsNullOrEmpty(keyvalue))
|
||||
{
|
||||
sql1 = sql1 + "limit "+ pagesize + " offset "+(page-1)*pagesize;
|
||||
sql1 = sql1 + "limit " + pagesize + " offset " + (page - 1) * pagesize;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -304,16 +305,16 @@ public class LayerApp : SqlSugarBaseApp<DmLayer, SugarDbContext>
|
|||
sql2 = " and " + keyword + " like '%" + keyvalue + "%'";
|
||||
}
|
||||
string sqlcount = $"select count(*) from " + tablename + " where 1=1 ";
|
||||
var count = _client.Ado.GetInt(sqlcount+sql2);
|
||||
var count = _client.Ado.GetInt(sqlcount + sql2);
|
||||
var result1 = _client.Ado.SqlQuery<dynamic>(sql1);
|
||||
result.Add("data", result1);
|
||||
result.Add("data", result1);
|
||||
result.Add("total", count);
|
||||
return new Response<Dictionary<string, object>>
|
||||
{
|
||||
Result = result
|
||||
};
|
||||
}
|
||||
public Response<MemoryStream> TempeleteByTableName(string tablename,int type, string shpFilePath, string shpFilePathzip)
|
||||
public Response<MemoryStream> TempeleteByTableName(string tablename, int type, string shpFilePath, string shpFilePathzip)
|
||||
{
|
||||
Response<MemoryStream> response = new Response<MemoryStream>();
|
||||
string sql = $"select column_name as name from INFORMATION_SCHEMA.COLUMNS WHERE table_schema = 'public' AND table_name ='" + tablename + "'";
|
||||
|
|
@ -357,7 +358,7 @@ public class LayerApp : SqlSugarBaseApp<DmLayer, SugarDbContext>
|
|||
ISheet sheet = workbook.CreateSheet("Sheet0");
|
||||
IRow rowHeader = sheet.CreateRow(0);
|
||||
rowHeader.Height = 20 * 30;
|
||||
for (int i = 0; i < cloumnlist.Count+1; i++)
|
||||
for (int i = 0; i < cloumnlist.Count + 1; i++)
|
||||
{
|
||||
if (i == cloumnlist.Count)
|
||||
{
|
||||
|
|
@ -365,7 +366,8 @@ public class LayerApp : SqlSugarBaseApp<DmLayer, SugarDbContext>
|
|||
rowHeader.Cells[i].CellStyle = style1;
|
||||
rowHeader.Cells[i].SetCellValue("lng");
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
var header = cloumnlist[i];
|
||||
if (header.Contains("geom"))
|
||||
{
|
||||
|
|
@ -373,14 +375,15 @@ public class LayerApp : SqlSugarBaseApp<DmLayer, SugarDbContext>
|
|||
rowHeader.Cells[i].CellStyle = style1;
|
||||
rowHeader.Cells[i].SetCellValue("lat");
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
rowHeader.CreateCell(i);
|
||||
rowHeader.Cells[i].CellStyle = style1;
|
||||
rowHeader.Cells[i].SetCellValue(header);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
response.Result = new MemoryStream();
|
||||
workbook.Write(response.Result);
|
||||
|
|
@ -406,7 +409,7 @@ public class LayerApp : SqlSugarBaseApp<DmLayer, SugarDbContext>
|
|||
var geometry = ParseGeometry(wkt);
|
||||
for (int i = 0; i < cloumnlist.Count; i++)
|
||||
{
|
||||
|
||||
|
||||
var header = cloumnlist[i];
|
||||
if (header.Contains("geom"))
|
||||
{
|
||||
|
|
@ -577,8 +580,8 @@ public class LayerApp : SqlSugarBaseApp<DmLayer, SugarDbContext>
|
|||
|
||||
}
|
||||
// 遍历列
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (lat != null && lng != null)
|
||||
{
|
||||
|
|
@ -589,7 +592,7 @@ public class LayerApp : SqlSugarBaseApp<DmLayer, SugarDbContext>
|
|||
map["geom"] = point.AsText();
|
||||
}
|
||||
listmap.Add(map);
|
||||
}
|
||||
}
|
||||
_client.Insertable(listmap).AS(tableName).ExecuteCommand();
|
||||
await GeoUtil.CreateStoreAndLayer("", "EPSG:4326", tableName, "");
|
||||
// 返回结果
|
||||
|
|
@ -598,14 +601,15 @@ public class LayerApp : SqlSugarBaseApp<DmLayer, SugarDbContext>
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public bool UpdateTableData(UpdateTableReq req) {
|
||||
public bool UpdateTableData(UpdateTableReq req)
|
||||
{
|
||||
|
||||
string tableName = req.TableName;
|
||||
string id = "";
|
||||
|
|
@ -632,7 +636,7 @@ public class LayerApp : SqlSugarBaseApp<DmLayer, SugarDbContext>
|
|||
sql1 = sql1 + "\"" + map["name"] + "\" = '" + map["value"] + "',";
|
||||
}
|
||||
}
|
||||
var sql2 = sql1.Substring(0,sql1.Length-1)+ " where 1=1 and \""+num+"\"="+id;
|
||||
var sql2 = sql1.Substring(0, sql1.Length - 1) + " where 1=1 and \"" + num + "\"=" + id;
|
||||
_client.Ado.ExecuteCommand(sql + sql2);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -653,11 +657,11 @@ public class LayerApp : SqlSugarBaseApp<DmLayer, SugarDbContext>
|
|||
id = map["name"].ToString();
|
||||
}
|
||||
}
|
||||
var maxid = nextid(req.TableName, id);
|
||||
|
||||
var maxid = nextid(req.TableName, id);
|
||||
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
maxid++;
|
||||
maxid++;
|
||||
var map = list[i];
|
||||
if ("id".Equals(map["name"].ToString().ToLower()))
|
||||
{
|
||||
|
|
@ -679,14 +683,14 @@ public class LayerApp : SqlSugarBaseApp<DmLayer, SugarDbContext>
|
|||
_client.Ado.ExecuteCommand(sql + sql3);
|
||||
return true;
|
||||
}
|
||||
public bool UpdateTableData1(UpdateTableReq req)
|
||||
public bool UpdateTableData1(UpdateTableReq req)
|
||||
{
|
||||
|
||||
string tableName = req.TableName;
|
||||
string id = "";
|
||||
var list = req.list;
|
||||
string sql = "update " + tableName + " set ";
|
||||
|
||||
|
||||
string num = "";
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
|
|
@ -715,8 +719,8 @@ public class LayerApp : SqlSugarBaseApp<DmLayer, SugarDbContext>
|
|||
var sql2 = sql1.Substring(0, sql1.Length - 1) + " where 1=1 and \"" + num + "\"=" + id;
|
||||
_client.Ado.ExecuteCommand(sql + sql2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -760,7 +764,7 @@ public class LayerApp : SqlSugarBaseApp<DmLayer, SugarDbContext>
|
|||
throw new Exception("没有数据");
|
||||
}
|
||||
|
||||
|
||||
|
||||
var currentRow1 = sheet.GetRow(0);
|
||||
var cols = new string[currentRow1.LastCellNum];
|
||||
string ids = "";
|
||||
|
|
@ -770,7 +774,7 @@ public class LayerApp : SqlSugarBaseApp<DmLayer, SugarDbContext>
|
|||
cols[i] = cell1.ToString();
|
||||
if (cell1.ToString().ToLower().Equals("gid"))
|
||||
{
|
||||
ids= cell1.ToString();
|
||||
ids = cell1.ToString();
|
||||
}
|
||||
}
|
||||
var result = new List<string[]>();
|
||||
|
|
@ -792,7 +796,7 @@ public class LayerApp : SqlSugarBaseApp<DmLayer, SugarDbContext>
|
|||
var flag1 = false;
|
||||
for (int col = 0; col < currentRow.LastCellNum; col++)
|
||||
{
|
||||
|
||||
|
||||
var cell = currentRow.GetCell(col);
|
||||
if (cell == null)
|
||||
{
|
||||
|
|
@ -804,7 +808,7 @@ public class LayerApp : SqlSugarBaseApp<DmLayer, SugarDbContext>
|
|||
{
|
||||
string cloName = tablelist[i].ColumnName;
|
||||
string cloType = tablelist[i].Type;
|
||||
if (head.ToLower().Equals(cloName.ToLower()) &&"gid".Equals(head.ToLower()))
|
||||
if (head.ToLower().Equals(cloName.ToLower()) && "gid".Equals(head.ToLower()))
|
||||
{
|
||||
dict.Add(head, cellValue);
|
||||
errorData.Add(head, cellValue);
|
||||
|
|
@ -812,13 +816,15 @@ public class LayerApp : SqlSugarBaseApp<DmLayer, SugarDbContext>
|
|||
{
|
||||
map.Add(head, maxid);
|
||||
}
|
||||
if (cloType.Contains("character")) {
|
||||
if (cloType.Contains("character"))
|
||||
{
|
||||
map.Add(head, Guid.NewGuid().ToString());
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
if (head.Contains("geom")) {
|
||||
if (head.Contains("geom"))
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (head.Contains("time"))
|
||||
|
|
@ -827,45 +833,46 @@ public class LayerApp : SqlSugarBaseApp<DmLayer, SugarDbContext>
|
|||
}
|
||||
if (head.Equals(cloName))
|
||||
{
|
||||
var dictres = dealType(cloName, cloType,head, cellValue);
|
||||
var dictres = dealType(cloName, cloType, head, cellValue);
|
||||
if ((bool)dictres["flag"])
|
||||
{
|
||||
map.Add(head, dictres["data"]);
|
||||
dict.Add(head, cellValue);
|
||||
errorData.Add(head, cellValue);
|
||||
}
|
||||
else {
|
||||
errorData.Add(head, "error"+cellValue);
|
||||
else
|
||||
{
|
||||
errorData.Add(head, "error" + cellValue);
|
||||
dict.Add(head, cellValue);
|
||||
flag1 = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
switch (head)
|
||||
{
|
||||
case "lat":
|
||||
lat = cellValue;
|
||||
|
||||
|
||||
dict.Add(head, cellValue);
|
||||
errorData.Add(head, cellValue);
|
||||
continue;
|
||||
case "lng":
|
||||
lng = cellValue;
|
||||
|
||||
|
||||
dict.Add(head, cellValue);
|
||||
errorData.Add(head, cellValue);
|
||||
continue;
|
||||
|
||||
|
||||
default:
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
if (flag1)
|
||||
|
|
@ -881,7 +888,7 @@ public class LayerApp : SqlSugarBaseApp<DmLayer, SugarDbContext>
|
|||
int.Parse("4326"));
|
||||
var point = geography.CreatePoint(new Coordinate(double.Parse(lng), double.Parse(lat)));
|
||||
map.Add("geom", point.AsText());
|
||||
|
||||
|
||||
}
|
||||
var geometryForWgs84 = map["geom"];
|
||||
|
||||
|
|
@ -950,7 +957,7 @@ public class LayerApp : SqlSugarBaseApp<DmLayer, SugarDbContext>
|
|||
[HttpPost]
|
||||
public async Task<Response<Dictionary<string, object>>> AddUploadExcel(UploadExcelReq req)
|
||||
{
|
||||
|
||||
|
||||
if (req.file == null || req.file.Length == 0)
|
||||
{
|
||||
return null;
|
||||
|
|
@ -1029,7 +1036,7 @@ public class LayerApp : SqlSugarBaseApp<DmLayer, SugarDbContext>
|
|||
string cloType = tablelist[i].Type;
|
||||
if (head.ToLower().Equals(cloName.ToLower()) && "gid".Equals(head.ToLower()))
|
||||
{
|
||||
|
||||
|
||||
errorData.Add(head, cellValue);
|
||||
if (cloType.Contains("int"))
|
||||
{
|
||||
|
|
@ -1076,13 +1083,13 @@ public class LayerApp : SqlSugarBaseApp<DmLayer, SugarDbContext>
|
|||
case "lat":
|
||||
lat = cellValue;
|
||||
|
||||
|
||||
|
||||
errorData.Add(head, cellValue);
|
||||
continue;
|
||||
case "lng":
|
||||
lng = cellValue;
|
||||
|
||||
|
||||
|
||||
errorData.Add(head, cellValue);
|
||||
continue;
|
||||
|
||||
|
|
@ -1114,7 +1121,7 @@ public class LayerApp : SqlSugarBaseApp<DmLayer, SugarDbContext>
|
|||
//await GeoUtil.CreateStoreAndLayer("", "EPSG:4326", req.tableName, "");
|
||||
// 返回结果
|
||||
Dictionary<string, object> res = new Dictionary<string, object>();
|
||||
|
||||
|
||||
res.Add("errorData", errordicts);
|
||||
return new Response<Dictionary<string, object>>
|
||||
{
|
||||
|
|
@ -1134,41 +1141,44 @@ public class LayerApp : SqlSugarBaseApp<DmLayer, SugarDbContext>
|
|||
|
||||
}
|
||||
|
||||
public async Task<Response<dynamic>> GetSldFilePath(string tablename) {
|
||||
public async Task<Response<dynamic>> GetSldFilePath(string tablename)
|
||||
{
|
||||
Response<dynamic> response = new Response<dynamic>();
|
||||
string sql = $"select * from sldfile_record where name='" + tablename + "'";
|
||||
var filepath = _client.Ado.SqlQuerySingle<dynamic>(sql);
|
||||
response.Result = filepath;
|
||||
return response;
|
||||
}
|
||||
public async Task<Response<bool>> uploadSldStyle(string styleName, string tablename,string filepath,string fileid)
|
||||
public async Task<Response<bool>> uploadSldStyle(string styleName, string tablename, string filepath, string fileid)
|
||||
{
|
||||
Response<bool> response = new Response<bool>();
|
||||
|
||||
|
||||
var sldpath = Path.Combine(_filePath, filepath);
|
||||
var flag = await GeoUtil.ExistStyle("", tablename);
|
||||
var flag1 = false;
|
||||
if (flag)
|
||||
{
|
||||
flag1 = await GeoUtil.UpdateSldStyle(filepath, tablename);
|
||||
flag1 = await GeoUtil.UpdateSldStyle(filepath, tablename);
|
||||
await GeoUtil.UpdateStyle("", tablename, tablename);
|
||||
}
|
||||
|
||||
else {
|
||||
flag1 = await GeoUtil.PublishSldStyle(sldpath, tablename);
|
||||
else
|
||||
{
|
||||
flag1 = await GeoUtil.PublishSldStyle(sldpath, tablename);
|
||||
await GeoUtil.UpdateStyle("", tablename, tablename);
|
||||
}
|
||||
|
||||
|
||||
string sql = $"select count(*) from sldfile_record where name='" + tablename + "'";
|
||||
var count = _client.Ado.GetInt(sql);
|
||||
if (count > 0)
|
||||
{
|
||||
string updatesql = $"update sldfile_record set filepath='"+filepath + "',styleName='"+ tablename + "',fileid='"+fileid+"' where name='" + tablename+"'" ;
|
||||
string updatesql = $"update sldfile_record set filepath='" + filepath + "',styleName='" + tablename + "',fileid='" + fileid + "' where name='" + tablename + "'";
|
||||
_client.Ado.ExecuteCommand(updatesql);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
string id = Guid.NewGuid().ToString();
|
||||
string insertsql = $"insert into sldfile_record(id,name,filepath,stylename,fileid) values('" +id+ "','"+tablename + "','"+filepath+"','"+ tablename + "',"+fileid+"')";
|
||||
string insertsql = $"insert into sldfile_record(id,name,filepath,stylename,fileid) values('" + id + "','" + tablename + "','" + filepath + "','" + tablename + "'," + fileid + "')";
|
||||
_client.Ado.ExecuteCommand(insertsql);
|
||||
}
|
||||
if (flag1)
|
||||
|
|
@ -1177,7 +1187,8 @@ public class LayerApp : SqlSugarBaseApp<DmLayer, SugarDbContext>
|
|||
response.Result = flag1;
|
||||
return response;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
response.Message = "发布失败";
|
||||
response.Result = false;
|
||||
response.Code = 500;
|
||||
|
|
@ -1223,7 +1234,7 @@ public class LayerApp : SqlSugarBaseApp<DmLayer, SugarDbContext>
|
|||
|
||||
var dbfReader = dataReader.DbaseHeader;
|
||||
List<string> headlist = new List<string>();
|
||||
|
||||
|
||||
string ids = "";
|
||||
foreach (var dbaseFieldDescriptor in dbfReader.Fields)
|
||||
{
|
||||
|
|
@ -1346,12 +1357,12 @@ public class LayerApp : SqlSugarBaseApp<DmLayer, SugarDbContext>
|
|||
throw new CommonException(ex.Message, 500);
|
||||
}
|
||||
}
|
||||
public async Task<Response<bool>> UploadShape3(string zipFilePath, string tableName
|
||||
)
|
||||
public async Task<Response<bool>> UploadShape3(string zipFilePath, string tableName
|
||||
)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
|
||||
string srd = "";
|
||||
using var db = Repository.AsSugarClient();
|
||||
// 开启事务
|
||||
|
|
@ -1519,12 +1530,12 @@ public class LayerApp : SqlSugarBaseApp<DmLayer, SugarDbContext>
|
|||
}
|
||||
});
|
||||
}
|
||||
public async Task<Response<Dictionary<string,object>>> UploadShape1(string zipFilePath, string tableName
|
||||
public async Task<Response<Dictionary<string, object>>> UploadShape1(string zipFilePath, string tableName
|
||||
)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
|
||||
string srd = "";
|
||||
using var db = Repository.AsSugarClient();
|
||||
// 开启事务
|
||||
|
|
@ -1588,12 +1599,12 @@ public class LayerApp : SqlSugarBaseApp<DmLayer, SugarDbContext>
|
|||
var flag1 = false;
|
||||
// 读取列
|
||||
Dictionary<string, object> dict = new Dictionary<string, object>();
|
||||
// 读取列
|
||||
var flag = false;
|
||||
for (int i = 0; i < dataReader.FieldCount; i++)
|
||||
// 读取列
|
||||
var flag = false;
|
||||
for (int i = 0; i < dataReader.FieldCount; i++)
|
||||
{
|
||||
var colName = dataReader.GetName(i);
|
||||
if (dataReader.GetValue(i)==null)
|
||||
if (dataReader.GetValue(i) == null)
|
||||
{
|
||||
map.Add(colName, dataReader.GetValue(i));
|
||||
errorData.Add(colName, dataReader.GetValue(i));
|
||||
|
|
@ -1606,7 +1617,7 @@ public class LayerApp : SqlSugarBaseApp<DmLayer, SugarDbContext>
|
|||
string cloType = tablelist[l].Type;
|
||||
if (colName.ToLower().Equals(colName.ToLower()) && "gid".Equals(colName.ToLower()))
|
||||
{
|
||||
|
||||
|
||||
errorData.Add(colName, dataReader.GetValue(i));
|
||||
if (cloType.Contains("int"))
|
||||
{
|
||||
|
|
@ -1630,7 +1641,7 @@ public class LayerApp : SqlSugarBaseApp<DmLayer, SugarDbContext>
|
|||
var geometryForWgs84 = GeometryFactory.Default.WithSRID(4326)
|
||||
.CreateGeometry(geometry);
|
||||
map.Add("geom", geometryForWgs84.AsText());
|
||||
|
||||
|
||||
errorData.Add("geom", geometryForWgs84.AsText());
|
||||
break;
|
||||
}
|
||||
|
|
@ -1640,12 +1651,12 @@ public class LayerApp : SqlSugarBaseApp<DmLayer, SugarDbContext>
|
|||
if ((bool)dictres["flag"])
|
||||
{
|
||||
map.Add(colName, dictres["data"]);
|
||||
|
||||
|
||||
errorData.Add(colName, dataReader.GetValue(i));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
errorData.Add(colName, dataReader.GetValue(i));
|
||||
flag1 = true;
|
||||
}
|
||||
|
|
@ -1661,7 +1672,7 @@ public class LayerApp : SqlSugarBaseApp<DmLayer, SugarDbContext>
|
|||
string sql = $"select column_name as name from INFORMATION_SCHEMA.COLUMNS WHERE table_schema = 'public' AND table_name ='" + tableName + "'";
|
||||
|
||||
var cloumnlist = _client.Ado.SqlQuery<string>(sql);
|
||||
|
||||
|
||||
string names = "";
|
||||
string geoms = "";
|
||||
for (int l = 0; l < cloumnlist.Count; l++)
|
||||
|
|
@ -1681,18 +1692,19 @@ public class LayerApp : SqlSugarBaseApp<DmLayer, SugarDbContext>
|
|||
string sql1 = $"select " + names + "ST_AsText(" + geoms + ") as " + geoms + $" from " + tableName + " where geom='" + geometryForWgs84.AsText() + "'";
|
||||
|
||||
var obj = _client.Ado.SqlQuerySingle<dynamic>(sql1);
|
||||
if (obj!=null)
|
||||
if (obj != null)
|
||||
{
|
||||
dynamics.Add(obj);
|
||||
dict.Add("geom", geometryForWgs84.AsText());
|
||||
flag = true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
dict.Add(colName, dataReader.GetValue(i));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
if (flag1)
|
||||
|
|
@ -1738,32 +1750,35 @@ public class LayerApp : SqlSugarBaseApp<DmLayer, SugarDbContext>
|
|||
{
|
||||
throw new CommonException(ex.Message, 500);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
public int nextid(string tablename,string id) {
|
||||
public int nextid(string tablename, string id)
|
||||
{
|
||||
string sql = "select max(\"" + id + "\") from " + tablename;
|
||||
var maxid = _client.Ado.GetInt(sql);
|
||||
return maxid;
|
||||
}
|
||||
public List<dynamic> tablestruc(string tableName) {
|
||||
public List<dynamic> tablestruc(string tableName)
|
||||
{
|
||||
string tableStruc = $"\t\t\r\nSELECT \r\n c.column_name AS \"ColumnName\",\r\n c.data_type AS \"Type\"\r\n\r\nFROM \r\n " +
|
||||
$" information_schema.columns c\r\nLEFT JOIN \r\n pg_catalog.pg_description pgd ON pgd.objoid = c.table_name::regclass::oid \r\n " +
|
||||
$" AND pgd.objsubid = c.ordinal_position\r\nWHERE \r\n c.table_name = '" + tableName + "'; ";
|
||||
return _client.Ado.SqlQuery<dynamic>(tableStruc);
|
||||
return _client.Ado.SqlQuery<dynamic>(tableStruc);
|
||||
}
|
||||
public Dictionary<string,object> dealType(string cloum,string type,string head,string data) {
|
||||
public Dictionary<string, object> dealType(string cloum, string type, string head, string data)
|
||||
{
|
||||
Dictionary<string, object> dict = new Dictionary<string, object>();
|
||||
string str = "";
|
||||
bool flag = false;
|
||||
double d = 0.0;
|
||||
float f = 0.0f;
|
||||
int i = 0;
|
||||
Object obj = null;
|
||||
Object obj = null;
|
||||
switch (type)
|
||||
{
|
||||
case "real":
|
||||
flag = float.TryParse(data,out f);
|
||||
flag = float.TryParse(data, out f);
|
||||
obj = f;
|
||||
break;
|
||||
case "integer":
|
||||
|
|
@ -1784,8 +1799,8 @@ public class LayerApp : SqlSugarBaseApp<DmLayer, SugarDbContext>
|
|||
obj = d;
|
||||
break;
|
||||
case "character varying":
|
||||
flag = true;
|
||||
obj = data;
|
||||
flag = true;
|
||||
obj = data;
|
||||
break;
|
||||
case "date":
|
||||
flag = true;
|
||||
|
|
@ -1795,7 +1810,7 @@ public class LayerApp : SqlSugarBaseApp<DmLayer, SugarDbContext>
|
|||
flag = true;
|
||||
obj = new Timestamp();
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
flag = false;
|
||||
break;
|
||||
|
|
|
|||
Loading…
Reference in New Issue