Задание НУ из ui
This commit is contained in:
+10
@@ -91,6 +91,16 @@ class CatalogRestController(
|
||||
return ResponseEntity.accepted().build()
|
||||
}
|
||||
|
||||
@GetMapping("/satellites/pdcm/{satelliteId}/initial-conditions")
|
||||
fun currentPdcmInitialConditions(@PathVariable satelliteId: Long): ResponseEntity<Any> {
|
||||
val response = ballisticsService.currentInitialConditions(satelliteId)
|
||||
return if (response == null) {
|
||||
ResponseEntity.noContent().build()
|
||||
} else {
|
||||
ResponseEntity.ok(response)
|
||||
}
|
||||
}
|
||||
|
||||
private fun parseSendInitialConditionsTime(time: String?): LocalDateTime {
|
||||
val normalizedTime = time?.trim()?.takeIf { it.isNotEmpty() }
|
||||
?: return LocalDateTime.now()
|
||||
|
||||
+13
@@ -82,6 +82,19 @@ class BallisticsService (webClientBuilderProvider: ObjectProvider<WebClient.Buil
|
||||
.block()
|
||||
}
|
||||
|
||||
fun currentInitialConditions(satelliteId: Long): SatelliteICDTO? =
|
||||
webClientBuilder.build()
|
||||
.get()
|
||||
.uri("$url/api/satellites/$satelliteId/initial-conditions/current")
|
||||
.exchangeToMono { response ->
|
||||
when {
|
||||
response.statusCode().is2xxSuccessful -> response.bodyToMono(SatelliteICDTO::class.java)
|
||||
response.statusCode().value() == 404 || response.statusCode().value() == 204 -> reactor.core.publisher.Mono.empty()
|
||||
else -> response.createException().flatMap { reactor.core.publisher.Mono.error(it) }
|
||||
}
|
||||
}
|
||||
.block()
|
||||
|
||||
fun parseTle(tle: TLEDTO): TleParsedDTO =
|
||||
webClientBuilder.build()
|
||||
.post()
|
||||
|
||||
@@ -68,6 +68,21 @@
|
||||
return `${pad(now.getDate())}.${pad(now.getMonth() + 1)}.${now.getFullYear()} ${pad(now.getHours())}:${pad(now.getMinutes())}:${pad(now.getSeconds())}.${pad(now.getMilliseconds(), 3)}`;
|
||||
}
|
||||
|
||||
function formatDateTimeInput(value) {
|
||||
if (!value) {
|
||||
return '';
|
||||
}
|
||||
const match = String(value).match(
|
||||
/^(\d{4})-(\d{2})-(\d{2})[T\s](\d{2}):(\d{2})(?::(\d{2})(?:[.,](\d{1,9}))?)?/
|
||||
);
|
||||
if (!match) {
|
||||
return value;
|
||||
}
|
||||
|
||||
const [, year, month, day, hour, minute, second = '00', millis = '000'] = match;
|
||||
return `${day}.${month}.${year} ${hour}:${minute}:${second}.${millis.slice(0, 3).padEnd(3, '0')}`;
|
||||
}
|
||||
|
||||
function parseSendInitialConditionsTime() {
|
||||
const input = document.getElementById('satellite-pdcm-send-ic-time');
|
||||
const value = input?.value.trim() || '';
|
||||
@@ -194,9 +209,10 @@
|
||||
function renderSetInitialConditionsState(details, loading = false) {
|
||||
const openButton = document.getElementById('satellite-pdcm-open-set-ic');
|
||||
const submitButton = document.getElementById('satellite-pdcm-set-ic-submit');
|
||||
const satelliteSelected = !!state.selectedSatelliteId;
|
||||
if (openButton) {
|
||||
openButton.disabled = !details || loading;
|
||||
openButton.title = details ? '' : 'Выберите спутник';
|
||||
openButton.disabled = !satelliteSelected || loading;
|
||||
openButton.title = satelliteSelected ? '' : 'Выберите спутник';
|
||||
}
|
||||
if (submitButton) {
|
||||
submitButton.disabled = loading;
|
||||
@@ -429,14 +445,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
function openSetInitialConditionsModal() {
|
||||
if (!state.selectedSatelliteId || !state.details) {
|
||||
showAlert('Выберите спутник для задания начальных условий');
|
||||
return;
|
||||
}
|
||||
|
||||
document.getElementById('satellite-pdcm-set-ic-target').textContent =
|
||||
`${state.details.name} · ID ${state.details.satelliteId}`;
|
||||
function resetInitialConditionsForm() {
|
||||
document.getElementById('satellite-pdcm-ic-time').value = currentDateTimeInputValue();
|
||||
document.getElementById('satellite-pdcm-ic-revolution').value = '';
|
||||
document.getElementById('satellite-pdcm-ic-movement-model').value = 'FOTO';
|
||||
@@ -445,10 +454,54 @@
|
||||
['x', 'y', 'z', 'vx', 'vy', 'vz'].forEach(field => {
|
||||
document.getElementById(`satellite-pdcm-ic-${field}`).value = '';
|
||||
});
|
||||
}
|
||||
|
||||
function fillInitialConditionsForm(initialConditions) {
|
||||
document.getElementById('satellite-pdcm-ic-time').value =
|
||||
formatDateTimeInput(initialConditions?.ic?.orbPoint?.time) || currentDateTimeInputValue();
|
||||
document.getElementById('satellite-pdcm-ic-revolution').value =
|
||||
initialConditions?.ic?.orbPoint?.revolution ?? '';
|
||||
document.getElementById('satellite-pdcm-ic-movement-model').value =
|
||||
initialConditions?.movementModel || 'FOTO';
|
||||
document.getElementById('satellite-pdcm-ic-s-ball').value =
|
||||
initialConditions?.ic?.sBall ?? '0';
|
||||
document.getElementById('satellite-pdcm-ic-f81').value =
|
||||
initialConditions?.ic?.f81 ?? '147.8';
|
||||
document.getElementById('satellite-pdcm-ic-x').value = initialConditions?.ic?.orbPoint?.x ?? '';
|
||||
document.getElementById('satellite-pdcm-ic-y').value = initialConditions?.ic?.orbPoint?.y ?? '';
|
||||
document.getElementById('satellite-pdcm-ic-z').value = initialConditions?.ic?.orbPoint?.z ?? '';
|
||||
document.getElementById('satellite-pdcm-ic-vx').value = initialConditions?.ic?.orbPoint?.vx ?? '';
|
||||
document.getElementById('satellite-pdcm-ic-vy').value = initialConditions?.ic?.orbPoint?.vy ?? '';
|
||||
document.getElementById('satellite-pdcm-ic-vz').value = initialConditions?.ic?.orbPoint?.vz ?? '';
|
||||
}
|
||||
|
||||
async function openSetInitialConditionsModal() {
|
||||
if (!state.selectedSatelliteId) {
|
||||
showAlert('Выберите спутник для задания начальных условий');
|
||||
return;
|
||||
}
|
||||
|
||||
const selectedSatellite = state.details?.satelliteId === state.selectedSatelliteId
|
||||
? state.details
|
||||
: state.satellites.find(satellite => satellite.satelliteId === state.selectedSatelliteId);
|
||||
document.getElementById('satellite-pdcm-set-ic-target').textContent =
|
||||
selectedSatellite
|
||||
? `${selectedSatellite.name} · ID ${selectedSatellite.satelliteId}`
|
||||
: `ID ${state.selectedSatelliteId}`;
|
||||
resetInitialConditionsForm();
|
||||
|
||||
if (window.bootstrap) {
|
||||
window.bootstrap.Modal.getOrCreateInstance(document.getElementById('satellite-pdcm-set-ic-modal')).show();
|
||||
}
|
||||
|
||||
try {
|
||||
const currentInitialConditions = await requestJson(`${apiBase}/${state.selectedSatelliteId}/initial-conditions`);
|
||||
if (currentInitialConditions) {
|
||||
fillInitialConditionsForm(currentInitialConditions);
|
||||
}
|
||||
} catch (error) {
|
||||
showAlert(error.message || 'Не удалось загрузить актуальные начальные условия');
|
||||
}
|
||||
}
|
||||
|
||||
function buildInitialConditionsPayload() {
|
||||
@@ -475,7 +528,7 @@
|
||||
|
||||
async function submitInitialConditions(event) {
|
||||
event.preventDefault();
|
||||
if (!state.selectedSatelliteId || !state.details) {
|
||||
if (!state.selectedSatelliteId) {
|
||||
showAlert('Выберите спутник для задания начальных условий');
|
||||
return;
|
||||
}
|
||||
@@ -509,6 +562,7 @@
|
||||
|
||||
async function selectSatellite(satelliteId) {
|
||||
state.selectedSatelliteId = satelliteId;
|
||||
state.details = null;
|
||||
renderList();
|
||||
renderSendInitialConditionsState(null);
|
||||
renderSetInitialConditionsState(null);
|
||||
@@ -523,6 +577,7 @@
|
||||
state.details = null;
|
||||
renderSummary(null);
|
||||
renderTable(null);
|
||||
renderSetInitialConditionsState(null);
|
||||
showAlert(error.message || 'Не удалось загрузить ПДЦМ спутника');
|
||||
}
|
||||
}
|
||||
@@ -538,12 +593,14 @@
|
||||
if (nextSatelliteId) {
|
||||
await selectSatellite(nextSatelliteId);
|
||||
} else {
|
||||
state.selectedSatelliteId = null;
|
||||
state.details = null;
|
||||
renderSummary(null);
|
||||
renderTable(null);
|
||||
}
|
||||
} catch (error) {
|
||||
state.satellites = [];
|
||||
state.selectedSatelliteId = null;
|
||||
state.details = null;
|
||||
renderList();
|
||||
renderSummary(null);
|
||||
|
||||
Reference in New Issue
Block a user