场景加载处理一些卡顿的情况
This commit is contained in:
1 parent
e7a3214cb5
commit
65fc5b5c50
35 files changed
+8668
-2075
No files matched your search
@@ -16,14 +16,14 @@ namespace Assets.Scenes.Ride.Scripts.Model.CyclingModels
|
||||
/// <param name="manufacturerId"></param>
|
||||
/// <param name="deviceNumber"></param>
|
||||
/// <param name="antModelId"></param>
|
||||
public SingleModel(Route route1, SelectParamModel param)
|
||||
public SingleModel(Route route1) //SelectParamModel param)
|
||||
: base(route1, CyclingModel.Single)
|
||||
{
|
||||
//recorderData = recorderData1;
|
||||
this.IsRecord = true;
|
||||
recorderData = new RecorderDataModel()
|
||||
{
|
||||
CurrentUser = PubCommData.CurrentUser,
|
||||
CurrentUser = null,//TODO:PubCommData.CurrentUser,
|
||||
//BelongUserId = PubCommData.CurrentUser.Id,
|
||||
Competitionid = 0,
|
||||
ContinueIndex = 0,
|
||||
@@ -39,63 +39,57 @@ namespace Assets.Scenes.Ride.Scripts.Model.CyclingModels
|
||||
//AntModelId = antModelId,
|
||||
StartTime = DateTime.Now
|
||||
};
|
||||
if (param != null)
|
||||
{
|
||||
recorderData.EndDistance = param.EndDistance;
|
||||
recorderData.CurrentRouteStartDistance = param.EndDistance;
|
||||
if (!string.IsNullOrWhiteSpace(param.ContinueMark))
|
||||
{
|
||||
recorderData.ContinueMark = param.ContinueMark;
|
||||
}
|
||||
recorderData.ContinueIndex = param.ContinueIndex.GetValueOrDefault(0);
|
||||
}
|
||||
recorderData.PreDistance = recorderData.EndDistance;
|
||||
#region TODO 线路上的人
|
||||
//if (param != null)
|
||||
//{
|
||||
// recorderData.EndDistance = param.EndDistance;
|
||||
// recorderData.CurrentRouteStartDistance = param.EndDistance;
|
||||
// if (!string.IsNullOrWhiteSpace(param.ContinueMark))
|
||||
// {
|
||||
// recorderData.ContinueMark = param.ContinueMark;
|
||||
// }
|
||||
// recorderData.ContinueIndex = param.ContinueIndex.GetValueOrDefault(0);
|
||||
//}
|
||||
//recorderData.PreDistance = recorderData.EndDistance;
|
||||
//Rhino.PowerFun.Services.MapUDPService.Send(route.RouteInstance.Id, riders.First().UserId, route.Point.First());
|
||||
|
||||
|
||||
riders = new List<BaseRider>();
|
||||
var rider = new OnlineRiderModel()
|
||||
{
|
||||
NickName = PubCommData.CurrentUser.Nickname,
|
||||
UserId = PubCommData.CurrentUser.Id,
|
||||
WxHeadImg = PubCommData.CurrentUser.WxHeadImg + "?t=1",
|
||||
//Point = new GeoJSON.Net.Geometry.GeographicPosition(this.route.RouteInstance.Point[0], this.route.RouteInstance.Point[1]),
|
||||
EndDistance = recorderData.EndDistance
|
||||
};
|
||||
rider.Point = _turfHelper.Along(rider.EndDistance);
|
||||
//riders = new List<BaseRider>();
|
||||
//TODO 附件的人列表加上自己
|
||||
//var rider = new OnlineRiderModel()
|
||||
//{
|
||||
// NickName = PubCommData.CurrentUser.Nickname,
|
||||
// UserId = PubCommData.CurrentUser.Id,
|
||||
// WxHeadImg = PubCommData.CurrentUser.WxHeadImg + "?t=1",
|
||||
// //Point = new GeoJSON.Net.Geometry.GeographicPosition(this.route.RouteInstance.Point[0], this.route.RouteInstance.Point[1]),
|
||||
// EndDistance = recorderData.EndDistance
|
||||
//};
|
||||
//rider.Point = _turfHelper.Along(rider.EndDistance);
|
||||
|
||||
riders.Add(rider);
|
||||
//riders.Add(rider);
|
||||
#endregion
|
||||
}
|
||||
|
||||
protected override void Run(TargetData targetData)
|
||||
{
|
||||
//base.BeforeRun(targetData);
|
||||
var dis1 = SpeedToDistance(targetData._Speed);
|
||||
currentDistance = recorderData.EndDistance + dis1;//实时计算距离
|
||||
if (recorderData.CyclingState == CyclingStateEnum.Prepare || recorderData.CyclingState == CyclingStateEnum.Stop)
|
||||
{
|
||||
currentDistance = recorderData.EndDistance;
|
||||
}
|
||||
if (recorderData.CyclingState == CyclingStateEnum.Cycling)
|
||||
{
|
||||
//Console.WriteLine($"{Ticks + 1}, 总距离:{currentDistance},速度:{ targetData._Speed },移动距离:{ dis1 }");
|
||||
}
|
||||
riders.RemoveAll(r => r.IsSelf == false);
|
||||
var onlineUsers = MapUDPService.GetOnlineUsers(recorderData.CurrentRoute.RouteInstance.Id).Where(d => d.IsSelf == false)
|
||||
.ToList();
|
||||
#region TODO 获取在线用户
|
||||
//riders.RemoveAll(r => r.IsSelf == false);
|
||||
//var onlineUsers = MapUDPService.GetOnlineUsers(recorderData.CurrentRoute.RouteInstance.Id).Where(d => d.IsSelf == false)
|
||||
// .ToList();
|
||||
|
||||
foreach (var item in onlineUsers)
|
||||
{
|
||||
riders.Add(new OnlineRiderModel()
|
||||
{
|
||||
NickName = item.Name,
|
||||
UserId = item.Id,
|
||||
WxHeadImg = item.HeadImage,
|
||||
Point = new GeoJSON.Net.Geometry.GeographicPosition(item.Point[0], item.Point[1]),
|
||||
EndDistance = item.EndDistance,
|
||||
PreDistance = item.PreDistance,
|
||||
});
|
||||
}
|
||||
//foreach (var item in onlineUsers)
|
||||
//{
|
||||
// riders.Add(new OnlineRiderModel()
|
||||
// {
|
||||
// NickName = item.Name,
|
||||
// UserId = item.Id,
|
||||
// WxHeadImg = item.HeadImage,
|
||||
// Point = new GeoJSON.Net.Geometry.GeographicPosition(item.Point[0], item.Point[1]),
|
||||
// EndDistance = item.EndDistance,
|
||||
// PreDistance = item.PreDistance,
|
||||
// });
|
||||
//}
|
||||
#endregion
|
||||
base.Run(targetData);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Assets.Scenes.Ride.Scripts.Model
|
||||
{
|
||||
get
|
||||
{
|
||||
return CurrentUser.Id;
|
||||
return 10688;//CurrentUser.Id;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
@@ -109,7 +109,7 @@ namespace Assets.Scenes.Ride.Scripts.Model
|
||||
/// </summary>
|
||||
/// <param name="base64Image"></param>
|
||||
/// <returns></returns>
|
||||
public JsonResult<AddMapRecordResultModel> SaveData(CyclingModel cyclingModel, SelectParamModel selectParam, DateTime createTime, string base64Image = "")
|
||||
public JsonResult<AddMapRecordResultModel> SaveData(CyclingModel cyclingModel, SelectParamModel selectParam, string base64Image = "")
|
||||
{
|
||||
if (RiderDatas.Count <= 0)
|
||||
{
|
||||
@@ -126,13 +126,14 @@ namespace Assets.Scenes.Ride.Scripts.Model
|
||||
MapInterruptRecordApi service = new MapInterruptRecordApi();
|
||||
//AntManufacturer manufacturer = service.GetAntManufacturer(ManufacturerId);
|
||||
var recordId = Guid.NewGuid().ToString();
|
||||
var ticks = RiderDatas.Last().Ticks;
|
||||
var interruptRecord = new MapInterruptRecord
|
||||
{
|
||||
Id = recordId,
|
||||
RouteId = CurrentRoute.RouteInstance.Id,
|
||||
RouteName = CurrentRoute.RouteInstance.Name,
|
||||
TotalDistance = CurrentRoute.RouteInstance.Distance,
|
||||
UserId = BelongUserId,
|
||||
UserId = 10688,//BelongUserId,
|
||||
RecordFileName = newFileName + ".txt",
|
||||
Ftp = FTP,//FTP设置
|
||||
IF = Math.Round(IF, 2),
|
||||
@@ -145,9 +146,9 @@ namespace Assets.Scenes.Ride.Scripts.Model
|
||||
NormalizedPower = Math.Floor(NP),//标准化功率
|
||||
AveragePower = averagePower,//平均功率
|
||||
MaxPower = RiderDatas.Max(a => a._Power),//最大功率
|
||||
WeightKg = Math.Round(averagePower / PubCommData.CurrentUser.Weight, 2),
|
||||
Weight = PubCommData.CurrentUser.Weight,
|
||||
BicycleWeight = PubCommData.CurrentUser.BicycleWeight,
|
||||
WeightKg = Math.Round(averagePower / 65, 2),
|
||||
Weight = 65, //PubCommData.CurrentUser.Weight,
|
||||
BicycleWeight =7, //PubCommData.CurrentUser.BicycleWeight,
|
||||
ContinueMark = ContinueMark,
|
||||
ContinueIndex = ContinueIndex,
|
||||
IsDelete = false,
|
||||
@@ -159,11 +160,11 @@ namespace Assets.Scenes.Ride.Scripts.Model
|
||||
ManufacturerId = ManufacturerId,
|
||||
AntModelId = AntModelId,
|
||||
StartTime = StartTime,
|
||||
CreateTime = createTime,
|
||||
Ticks = RiderDatas.Last().Ticks,
|
||||
CreateTime = StartTime.AddSeconds(ticks),
|
||||
Ticks = ticks,
|
||||
Mode = cyclingModel.ToString(),
|
||||
Param = Newtonsoft.Json.JsonConvert.SerializeObject(selectParam),
|
||||
GlobalCyclingId = selectParam.GlobalCyclingId
|
||||
//Param = Newtonsoft.Json.JsonConvert.SerializeObject(selectParam),
|
||||
//GlobalCyclingId = selectParam.GlobalCyclingId
|
||||
};
|
||||
//var range = new MapSpeedRange().GetSpeedRange(RiderDatas, CurrentRoute.RouteInstance.Distance);
|
||||
interruptRecord.SpeedRange = null; //JsonConvert.SerializeObject(range);
|
||||
@@ -195,7 +196,7 @@ namespace Assets.Scenes.Ride.Scripts.Model
|
||||
stream.Close();
|
||||
files.Add(fname);
|
||||
}
|
||||
//TODO 截图
|
||||
#region TODO 截图
|
||||
if (!string.IsNullOrEmpty(base64Image))
|
||||
{
|
||||
//var imageName = path + "/" + Guid.NewGuid().ToString() + ".png";
|
||||
@@ -209,6 +210,7 @@ namespace Assets.Scenes.Ride.Scripts.Model
|
||||
//}
|
||||
//files.Add(imageName);
|
||||
}
|
||||
#endregion
|
||||
var result = service.Add(interruptRecord, files);
|
||||
return new JsonResult<AddMapRecordResultModel> { result = result.result, errMsg = result.errMsg, data = result.data };
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user