XlController.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel.DataAnnotations;
  4. using System.Data.Entity;
  5. using System.Data.SqlClient;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Web.Http;
  10. using Serilog;
  11. using XdCxRhDw.Dto;
  12. using XdCxRhDW.App.Api;
  13. using XdCxRhDW.Core.Api;
  14. using XdCxRhDW.Dto;
  15. namespace XdCxRhDW.WebApi.Controllers
  16. {
  17. /// <summary>
  18. /// 星历推算功能相关接口
  19. /// </summary>
  20. public class XlController : BaseController
  21. {
  22. /// <summary>
  23. /// 推算某个时间点星历
  24. /// </summary>
  25. /// <param name="dto">推算参数</param>
  26. /// <returns></returns>
  27. [HttpPost]
  28. [CustomValidation(typeof(XlCalcDto), "Validate")]
  29. public AjaxResult<SatEphDto> Calc(XlCalcDto dto)
  30. {
  31. try
  32. {
  33. var p = EphHelper.Calc(dto.tleStr, dto.dt);
  34. return Success(new SatEphDto()
  35. {
  36. SatId = p.SatId,
  37. SatTime = p.SatTime,
  38. TleTime = p.TleTime,
  39. X = p.X,
  40. Y = p.Y,
  41. Z = p.Z,
  42. VX = p.VX,
  43. VY = p.VY,
  44. VZ = p.VZ,
  45. });
  46. }
  47. catch (Exception ex)
  48. {
  49. return Error<SatEphDto>(ex.Message);
  50. }
  51. }
  52. /// <summary>
  53. /// 推算某个时间段星星历
  54. /// </summary>
  55. /// <param name="dto">推算参数</param>
  56. /// <returns></returns>
  57. [HttpPost]
  58. [CustomValidation(typeof(XlCalcMultDto), "Validate")]
  59. public AjaxResult<List<EphResDto>> CalcMult(XlCalcMultDto dto)
  60. {
  61. try
  62. {
  63. var eph = EphHelper.CalcMult(dto.tleStr, dto.start, dto.end, dto.spanSeconds);
  64. return Success(eph.Select(p => new EphResDto()
  65. {
  66. SatId = p.SatId,
  67. SatTime = p.SatTime,
  68. TleTime = p.TleTime,
  69. X = p.X,
  70. Y = p.Y,
  71. Z = p.Z,
  72. VX = p.VX,
  73. VY = p.VY,
  74. VZ = p.VZ,
  75. }).ToList());
  76. }
  77. catch (Exception ex)
  78. {
  79. return Error<List<EphResDto>>(ex.Message);
  80. }
  81. }
  82. }
  83. }