Задание НУ из ui

This commit is contained in:
emelianov
2026-05-29 10:52:36 +03:00
parent 7dfa1163e9
commit d693bf799d
13 changed files with 393 additions and 8 deletions
@@ -4,6 +4,7 @@ import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.Parameter
import jakarta.validation.Valid
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.PostMapping
@@ -11,9 +12,11 @@ import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController
import space.nstart.pcp.pcp_request_service.service.SatelliteIcEventService
import space.nstart.pcp.pcp_request_service.service.SatelliteService
import space.nstart.pcp.pcp_types_lib.configuration.CustomValidationException
import space.nstart.pcp.pcp_types_lib.dto.ballistics.ExactTimePositionRequestDTO
import space.nstart.pcp.pcp_types_lib.dto.ballistics.SatelliteICDTO
import java.time.LocalDateTime
@@ -23,6 +26,9 @@ class SatelliteController {
@Autowired
private lateinit var satelliteService: SatelliteService
@Autowired
private lateinit var satelliteIcEventService: SatelliteIcEventService
@PostMapping("/{satellite_id}/extract-time")
fun extractTime(
@PathVariable("satellite_id") satelliteId : Long,
@@ -30,6 +36,12 @@ class SatelliteController {
) =
satelliteService.exactTime(satelliteId, body)
@PostMapping("/receive-rv")
fun receiveRv(@RequestBody body: SatelliteICDTO): ResponseEntity<Void> {
satelliteIcEventService.handlePlacedIcRv(body)
return ResponseEntity.accepted().build()
}
@Operation(
@@ -6,6 +6,7 @@ import org.springframework.kafka.annotation.KafkaListener
import org.springframework.stereotype.Component
import space.nstart.pcp.pcp_request_service.service.SatelliteIcEventService
import space.nstart.pcp.pcp_types_lib.dto.ballistics.InitialConditionsDTO
import space.nstart.pcp.pcp_types_lib.dto.ballistics.MovementModel
import space.nstart.pcp.pcp_types_lib.dto.ballistics.SatelliteICDTO
import tools.jackson.databind.ObjectMapper
import tools.jackson.databind.node.ObjectNode
@@ -52,6 +53,11 @@ class SatelliteIcRvKafkaListener(
*/
private fun normalizePayload(payloadNode: tools.jackson.databind.JsonNode): tools.jackson.databind.JsonNode {
val normalizedPayload = payloadNode.deepCopy()
if (normalizedPayload is ObjectNode &&
(normalizedPayload["movementModel"] == null || normalizedPayload["movementModel"].isNull)
) {
normalizedPayload.put("movementModel", DEFAULT_MOVEMENT_MODEL.name)
}
val initialConditionsNode = normalizedPayload["ic"]
if (initialConditionsNode is ObjectNode) {
if (initialConditionsNode["sBall"] == null || initialConditionsNode["sBall"].isNull) {
@@ -66,5 +72,6 @@ class SatelliteIcRvKafkaListener(
companion object {
private val DEFAULT_INITIAL_CONDITIONS = InitialConditionsDTO()
private val DEFAULT_MOVEMENT_MODEL = MovementModel.FOTO
}
}
@@ -7,6 +7,7 @@ import ballistics.types.EarthType
import ballistics.types.FleghtLineSector
import ballistics.types.InitialConditions
import ballistics.types.KeplerParams
import ballistics.types.ModDVType
import ballistics.types.OPKatObj
import ballistics.types.OrbitalPoint
import ballistics.types.PPI
@@ -46,6 +47,7 @@ import space.nstart.pcp.pcp_request_service.utils.ContourClipService
import space.nstart.pcp.pcp_types_lib.dto.ballistics.AscNodeDTO
import space.nstart.pcp.pcp_types_lib.dto.ballistics.ExactTimePositionRequestDTO
import space.nstart.pcp.pcp_types_lib.dto.ballistics.InitialConditionsDTO
import space.nstart.pcp.pcp_types_lib.dto.ballistics.MovementModel
import space.nstart.pcp.pcp_types_lib.dto.ballistics.ObjDTO
import space.nstart.pcp.pcp_types_lib.dto.ballistics.OrbPointDTO
import space.nstart.pcp.pcp_types_lib.dto.ballistics.PointViewParamDTO
@@ -184,8 +186,9 @@ class SatelliteService {
suspend fun resieveRV(rv: SatelliteICDTO) {
val bal = Ballistics()
bal.modDVType = rv.movementModel.toModDVType()
logger.info("Начало расчета баллистики по RV id = ${rv.satelliteId}")
logger.info("Начало расчета баллистики по RV id = ${rv.satelliteId}, model = ${rv.movementModel}")
bal.rollMax = (45.0 * PI / 180.0)
bal.rollMin = (20.0 * PI / 180.0)
@@ -231,6 +234,16 @@ class SatelliteService {
logger.info("Расчет для КА ${rv.satelliteId} завершился успешно")
}
private fun MovementModel.toModDVType(): ModDVType =
when (this) {
MovementModel.FOTO -> ModDVType.FOTO
MovementModel.KONDOR -> ModDVType.KONDOR
MovementModel.METEORM1 -> ModDVType.METEORM1
MovementModel.METEORM2 -> ModDVType.METEORM2
MovementModel.BARS -> ModDVType.BARS
MovementModel.KONDOR_PROGNOZ -> ModDVType.KONDOR_PROGNOZ
}
fun mergeSectors(sectors: List<FleghtLineSector>): List<FleghtLineSector> {
if (sectors.isEmpty()) return emptyList()
@@ -4,6 +4,7 @@ import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import org.springframework.beans.factory.ObjectProvider
import space.nstart.pcp.pcp_request_service.service.SatelliteIcEventService
import space.nstart.pcp.pcp_types_lib.dto.ballistics.MovementModel
import space.nstart.pcp.pcp_types_lib.dto.ballistics.SatelliteICDTO
import tools.jackson.databind.ObjectMapper
@@ -46,6 +47,7 @@ class SatelliteIcRvKafkaListenerTest {
assertEquals(56756L, satelliteIcEventService.lastMessage?.satelliteId)
assertEquals(42L, satelliteIcEventService.lastMessage?.ic?.orbPoint?.revolution)
assertEquals(140.0, satelliteIcEventService.lastMessage?.ic?.f81)
assertEquals(MovementModel.FOTO, satelliteIcEventService.lastMessage?.movementModel)
}
@Test
@@ -54,8 +56,9 @@ class SatelliteIcRvKafkaListenerTest {
"""
{
"type": "ICRVPlacedEvent",
"data": {
"data": {
"satelliteId": 56756,
"movementModel": null,
"ic": {
"orbPoint": {
"time": "2026-04-16T12:00:00",
@@ -77,6 +80,7 @@ class SatelliteIcRvKafkaListenerTest {
assertEquals(0.0, satelliteIcEventService.lastMessage?.ic?.sBall)
assertEquals(147.8, satelliteIcEventService.lastMessage?.ic?.f81)
assertEquals(MovementModel.FOTO, satelliteIcEventService.lastMessage?.movementModel)
}
private class RecordingSatelliteIcEventService : SatelliteIcEventService() {