|
|
|
@ -977,6 +977,159 @@ namespace OpenAuth.App.ServiceApp
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 添加地图标注
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 添加地图标注
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="model"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<Response<string>> AddAnnotation(LasaAnnotation model)
|
|
|
|
|
{
|
|
|
|
|
var _user = _auth.GetCurrentUser().User;
|
|
|
|
|
model.CreateTime = DateTime.Now;
|
|
|
|
|
model.CreateUser = _user.Id.ToString();
|
|
|
|
|
model.CreateUserName = _user.Name.ToString();
|
|
|
|
|
using (var db = base.UnitWork.CreateContext().Db.CopyNew())
|
|
|
|
|
{
|
|
|
|
|
//获取主键
|
|
|
|
|
string id = Guid.NewGuid().ToString();
|
|
|
|
|
model.Id = id;
|
|
|
|
|
|
|
|
|
|
//格式化数据
|
|
|
|
|
string _wktModel = _commonDataManager.WktDataConvert(model.Geom, "MULTIPOLYGON ZM", 4);
|
|
|
|
|
|
|
|
|
|
model.Geom = null;
|
|
|
|
|
|
|
|
|
|
StringBuilder geomSql = new StringBuilder();
|
|
|
|
|
geomSql.AppendFormat(
|
|
|
|
|
$" update lasa_shpdata set \"Geom\" = st_geomfromtext('{_wktModel}',4326) where \"Id\" = '{id}'");
|
|
|
|
|
|
|
|
|
|
////更新面积
|
|
|
|
|
//StringBuilder sql = new StringBuilder();
|
|
|
|
|
//sql.AppendFormat(
|
|
|
|
|
// $" update lasa_shpdata set \"Area\" = st_area(st_transform(\"Geom\",4527)) where \"Geom\" is not null and \"Id\" = '{id}'");
|
|
|
|
|
|
|
|
|
|
////更新周长
|
|
|
|
|
//StringBuilder sqlle = new StringBuilder();
|
|
|
|
|
//sqlle.AppendFormat(
|
|
|
|
|
// $" update lasa_shpdata set \"Length\" = ST_Perimeter(st_transform(\"Geom\",4527)) where \"Geom\" is not null and \"Id\" = '{id}'");
|
|
|
|
|
|
|
|
|
|
//使用事务提交数据
|
|
|
|
|
var transFlag = await db.UseTranAsync(async () =>
|
|
|
|
|
{
|
|
|
|
|
//插入图斑数据
|
|
|
|
|
var flag = await db.Insertable(model).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
//修改图斑数据
|
|
|
|
|
var flagGeom = await db.Ado.ExecuteCommandAsync(geomSql.ToString());
|
|
|
|
|
|
|
|
|
|
////修改图斑面积
|
|
|
|
|
//var flagUpdate = await db.Ado.ExecuteCommandAsync(sql.ToString());
|
|
|
|
|
|
|
|
|
|
////修改图斑周长
|
|
|
|
|
//var lengthUpdate = await db.Ado.ExecuteCommandAsync(sqlle.ToString());
|
|
|
|
|
});
|
|
|
|
|
if (transFlag.IsSuccess)
|
|
|
|
|
return new Response<string>
|
|
|
|
|
{
|
|
|
|
|
Result = id,
|
|
|
|
|
Message = "新增成功"
|
|
|
|
|
};
|
|
|
|
|
else
|
|
|
|
|
return new Response<string>
|
|
|
|
|
{
|
|
|
|
|
Message = "新增失败"
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 更新地图标注
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="model"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<Response<string>> UpdateAnnotation(LasaAnnotation model)
|
|
|
|
|
{
|
|
|
|
|
using (var db = base.UnitWork.CreateContext().Db.CopyNew())
|
|
|
|
|
{
|
|
|
|
|
//格式化数据
|
|
|
|
|
string _wktModel = _commonDataManager.WktDataConvert(model.Geom, "MULTIPOLYGON ZM", 4);
|
|
|
|
|
|
|
|
|
|
model.Geom = null;
|
|
|
|
|
|
|
|
|
|
StringBuilder geomSql = new StringBuilder();
|
|
|
|
|
geomSql.AppendFormat(
|
|
|
|
|
$" update lasa_shpdata set \"Geom\" = st_geomfromtext('{_wktModel}',4326) where \"Id\" = '{model.Id}'");
|
|
|
|
|
|
|
|
|
|
//使用事务提交数据
|
|
|
|
|
var transFlag = await db.UseTranAsync(async () =>
|
|
|
|
|
{
|
|
|
|
|
//插入图斑数据
|
|
|
|
|
var flag = await db.Updateable(model).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
//修改图斑数据
|
|
|
|
|
var flagGeom = await db.Ado.ExecuteCommandAsync(geomSql.ToString());
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
if (transFlag.IsSuccess)
|
|
|
|
|
return new Response<string>
|
|
|
|
|
{
|
|
|
|
|
Result = model.Id,
|
|
|
|
|
Message = "更新成功"
|
|
|
|
|
};
|
|
|
|
|
else
|
|
|
|
|
return new Response<string>
|
|
|
|
|
{
|
|
|
|
|
Message = "更新失败"
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//删除地图标注
|
|
|
|
|
public async Task<Response<bool>> DeleteAnnotation(string id)
|
|
|
|
|
{
|
|
|
|
|
using (var db = UnitWork.CreateContext())
|
|
|
|
|
{
|
|
|
|
|
await db.LasaAnnotation.DeleteByIdAsync(id);
|
|
|
|
|
if (db.Commit())
|
|
|
|
|
return new Response<bool> { Result = true, Message = "删除成功" };
|
|
|
|
|
else
|
|
|
|
|
return new Response<bool> { Result = false, Message = "删除失败" };
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取地图标注列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="workspaceid">项目id</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<Response<List<LasaAnnotation>>> GetAnnotationList(string workspaceid, int? state, int? type)
|
|
|
|
|
{
|
|
|
|
|
using (var db = UnitWork.CreateContext())
|
|
|
|
|
{
|
|
|
|
|
StringBuilder sql = new StringBuilder();
|
|
|
|
|
sql.AppendFormat($" Select * from lasa_annotation where \"WorkSpaceId\" = '{workspaceid}'");
|
|
|
|
|
var list = db.Db.SqlQueryable<LasaAnnotation>(sql.ToString()).ToList();
|
|
|
|
|
if (type!=null && list.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
list = list.Where(r => r.Type == type).ToList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (state != null)
|
|
|
|
|
{
|
|
|
|
|
list = list.Where(r => r.State == state).ToList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new Response<List<LasaAnnotation>>
|
|
|
|
|
{
|
|
|
|
|
Result = list
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
public async Task<string> TestExecuteFlyTask(string flightid)
|
|
|
|
|
{
|
|
|
|
|
// flighttask_prepare method
|
|
|
|
|