SUPPORT-9484: fix

This commit is contained in:
Eduard Tihomiorv 2025-11-05 15:18:26 +03:00
parent 737e126f39
commit 1297ac89e8
9 changed files with 42 additions and 21 deletions

View file

@ -100,9 +100,9 @@ public class InteractionLog extends TableImpl<InteractionLogRecord> {
public final TableField<InteractionLogRecord, String> ERVU_ID = createField(DSL.name("ervu_id"), SQLDataType.VARCHAR(36), this, ""); public final TableField<InteractionLogRecord, String> ERVU_ID = createField(DSL.name("ervu_id"), SQLDataType.VARCHAR(36), this, "");
/** /**
* The column <code>public.interaction_log.offset</code>. * The column <code>public.interaction_log.zone_offset</code>.
*/ */
public final TableField<InteractionLogRecord, String> OFFSET = createField(DSL.name("offset"), SQLDataType.VARCHAR(10), this, ""); public final TableField<InteractionLogRecord, String> ZONE_OFFSET = createField(DSL.name("zone_offset"), SQLDataType.VARCHAR(10), this, "");
private InteractionLog(Name alias, Table<InteractionLogRecord> aliased) { private InteractionLog(Name alias, Table<InteractionLogRecord> aliased) {
this(alias, aliased, (Field<?>[]) null, null); this(alias, aliased, (Field<?>[]) null, null);

View file

@ -160,16 +160,16 @@ public class InteractionLogRecord extends TableRecordImpl<InteractionLogRecord>
} }
/** /**
* Setter for <code>public.interaction_log.offset</code>. * Setter for <code>public.interaction_log.zone_offset</code>.
*/ */
public void setOffset(String value) { public void setZoneOffset(String value) {
set(10, value); set(10, value);
} }
/** /**
* Getter for <code>public.interaction_log.offset</code>. * Getter for <code>public.interaction_log.zone_offset</code>.
*/ */
public String getOffset() { public String getZoneOffset() {
return (String) get(10); return (String) get(10);
} }
@ -187,7 +187,7 @@ public class InteractionLogRecord extends TableRecordImpl<InteractionLogRecord>
/** /**
* Create a detached, initialised InteractionLogRecord * Create a detached, initialised InteractionLogRecord
*/ */
public InteractionLogRecord(Long id, Timestamp sentDate, String form, String sender, String status, String fileName, Integer recordsSent, Integer recordsAccepted, String fileId, String ervuId, String offset) { public InteractionLogRecord(Long id, Timestamp sentDate, String form, String sender, String status, String fileName, Integer recordsSent, Integer recordsAccepted, String fileId, String ervuId, String zoneOffset) {
super(InteractionLog.INTERACTION_LOG); super(InteractionLog.INTERACTION_LOG);
setId(id); setId(id);
@ -200,7 +200,7 @@ public class InteractionLogRecord extends TableRecordImpl<InteractionLogRecord>
setRecordsAccepted(recordsAccepted); setRecordsAccepted(recordsAccepted);
setFileId(fileId); setFileId(fileId);
setErvuId(ervuId); setErvuId(ervuId);
setOffset(offset); setZoneOffset(zoneOffset);
resetChangedOnNotNull(); resetChangedOnNotNull();
} }
} }

View file

@ -1,6 +1,7 @@
package ru.micord.ervu.journal; package ru.micord.ervu.journal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZonedDateTime;
import java.util.List; import java.util.List;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@ -78,7 +79,7 @@ public class JournalFileInfo {
private Integer filePatternCode; // Номер шаблона(Формы) private Integer filePatternCode; // Номер шаблона(Формы)
private String filePatternName; private String filePatternName;
@JsonDeserialize(using = DepartureDateTimeDeserializer.class) @JsonDeserialize(using = DepartureDateTimeDeserializer.class)
private LocalDateTime departureDateTime; // Дата-время отправки файла private ZonedDateTime departureDateTime; // Дата-время отправки файла
private String timeZone; //Таймзона private String timeZone; //Таймзона
private JournalFileStatus fileStatus; private JournalFileStatus fileStatus;
private String type; private String type;
@ -119,11 +120,11 @@ public class JournalFileInfo {
return this; return this;
} }
public LocalDateTime getDepartureDateTime() { public ZonedDateTime getDepartureDateTime() {
return departureDateTime; return departureDateTime;
} }
public JournalFileDetails setDepartureDateTime(LocalDateTime departureDateTime) { public JournalFileDetails setDepartureDateTime(ZonedDateTime departureDateTime) {
this.departureDateTime = departureDateTime; this.departureDateTime = departureDateTime;
return this; return this;
} }

View file

@ -2,18 +2,19 @@ package ru.micord.ervu.journal.deserializer;
import java.io.IOException; import java.io.IOException;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZonedDateTime;
import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer; import com.fasterxml.jackson.databind.JsonDeserializer;
import ru.micord.ervu.util.DateUtils; import ru.micord.ervu.util.DateUtils;
public class DepartureDateTimeDeserializer extends JsonDeserializer<LocalDateTime> { public class DepartureDateTimeDeserializer extends JsonDeserializer<ZonedDateTime> {
@Override @Override
public LocalDateTime deserialize(JsonParser jsonParser, public ZonedDateTime deserialize(JsonParser jsonParser,
DeserializationContext deserializationContext) throws IOException { DeserializationContext deserializationContext) throws IOException {
String dateTimeString = jsonParser.getText(); String dateTimeString = jsonParser.getText();
return DateUtils.convertToLocalDateTime(dateTimeString); return DateUtils.convertToZoneDateTime(dateTimeString);
} }
} }

View file

@ -1,6 +1,5 @@
package ru.micord.ervu.journal.mapper; package ru.micord.ervu.journal.mapper;
import java.time.LocalDateTime;
import java.time.ZoneOffset; import java.time.ZoneOffset;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
@ -35,7 +34,7 @@ public class JournalDtoMapper {
public static JournalDto mapToJournalDto(InteractionLogRecord record) { public static JournalDto mapToJournalDto(InteractionLogRecord record) {
return new JournalDto() return new JournalDto()
.setDepartureDateTime( .setDepartureDateTime(
parseDateTime(record.getSentDate().toLocalDateTime(), record.getOffset())) parseDateTime(record.getSentDate().toInstant().atZone(ZoneOffset.UTC), record.getZoneOffset()))
.setFileName(record.getFileName()) .setFileName(record.getFileName())
.setFilePatternCode(Integer.valueOf(record.getForm())) .setFilePatternCode(Integer.valueOf(record.getForm()))
.setSenderFio(record.getSender()) .setSenderFio(record.getSender())
@ -46,14 +45,13 @@ public class JournalDtoMapper {
.setFileId(record.getFileId()); .setFileId(record.getFileId());
} }
private static String parseDateTime(LocalDateTime dateTime, String timeZone) { private static String parseDateTime(ZonedDateTime dateTime, String timeZone) {
if (timeZone == null) { if (timeZone == null) {
timeZone = "+00:00"; timeZone = "+00:00";
} }
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm:ss"); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm:ss");
ZonedDateTime utcZoned = dateTime.atZone(ZoneOffset.UTC);
ZoneOffset offset = ZoneOffset.of(timeZone); ZoneOffset offset = ZoneOffset.of(timeZone);
ZonedDateTime zonedDateTime = utcZoned.withZoneSameInstant(offset); ZonedDateTime zonedDateTime = dateTime.withZoneSameInstant(offset);
return zonedDateTime.format(formatter) + " (" + timeZone + ")"; return zonedDateTime.format(formatter) + " (" + timeZone + ")";
} }
} }

View file

@ -42,7 +42,7 @@ public class InteractionServiceImpl implements InteractionService {
.set(INTERACTION_LOG.SENDER, sender) .set(INTERACTION_LOG.SENDER, sender)
.set(INTERACTION_LOG.FILE_NAME, fileName) .set(INTERACTION_LOG.FILE_NAME, fileName)
.set(INTERACTION_LOG.ERVU_ID, ervuId) .set(INTERACTION_LOG.ERVU_ID, ervuId)
.set(INTERACTION_LOG.OFFSET, offset) .set(INTERACTION_LOG.ZONE_OFFSET, offset)
.execute(); .execute();
} }

View file

@ -50,6 +50,12 @@ public final class DateUtils {
: null; : null;
} }
public static ZonedDateTime convertToZoneDateTime(String dateTime) {
return hasText(dateTime)
? ZonedDateTime.parse(dateTime, DATE_TIME_FORMATTER)
: null;
}
public static String convertToString(LocalDateTime dateTime) { public static String convertToString(LocalDateTime dateTime) {
return dateTime == null ? "" : dateTime.format(DATE_TIME_FORMATTER); return dateTime == null ? "" : dateTime.format(DATE_TIME_FORMATTER);
} }

View file

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd">
<changeSet id="01" author="tihomirov">
<comment>Rename column offset to zoneOffset</comment>
<createTable tableName="organization_allowed">
<column name="id" type="bigint" autoIncrement="true">
<constraints primaryKey="true" primaryKeyName="pk_organization_allowed"/>
</column>
<column name="ogrn" type="varchar(15)">
<constraints nullable="false" unique="true" uniqueConstraintName="uni_organization_allowed_ogrn"/>
</column>
</createTable>
</changeSet>
</databaseChangeLog>

View file

@ -9,6 +9,6 @@
<include file="2024-09-11--01-create-table-interaction-log.xml" relativeToChangelogFile="true"/> <include file="2024-09-11--01-create-table-interaction-log.xml" relativeToChangelogFile="true"/>
<include file="2024-09-18--02-add-shedlock-table.xml" relativeToChangelogFile="true"/> <include file="2024-09-18--02-add-shedlock-table.xml" relativeToChangelogFile="true"/>
<include file="2025-10-20-create-offset-column.xml" relativeToChangelogFile="true"/> <include file="2025-10-20-create-offset-column.xml" relativeToChangelogFile="true"/>
<include file="2025-11-05-rename-column.xml" relativeToChangelogFile="true"/>
</databaseChangeLog> </databaseChangeLog>