SUPPORT-8471: new changes
This commit is contained in:
parent
d377655863
commit
5c85e84078
2 changed files with 10 additions and 24 deletions
|
|
@ -10,10 +10,7 @@ import ervu.dao.classifier.RecordAttributesDao;
|
|||
import ervu.service.classifier.model.ClassifierAttributeModel;
|
||||
import ervu.service.classifier.model.ClassifierFormModel;
|
||||
import ervu.service.classifier.model.RecordModel;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
|
@ -23,8 +20,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
*/
|
||||
@Service
|
||||
public class SchedulerServiceImpl implements SchedulerService{
|
||||
private static final Logger logger = LoggerFactory.getLogger(SchedulerServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private ClassifierOrgClient classifierOrgClient;
|
||||
@Autowired
|
||||
|
|
@ -34,29 +29,21 @@ public class SchedulerServiceImpl implements SchedulerService{
|
|||
@Autowired
|
||||
private ObjectMapper mapper;
|
||||
|
||||
@Value("${ervu.cron.load.enable:true}")
|
||||
private Boolean isEnableCron;
|
||||
|
||||
@Scheduled(cron = "${ervu.cron.load.time:0 0 */1 * * *}")
|
||||
@Transactional
|
||||
public void loadEveryPeriod() {
|
||||
if (isEnableCron) {
|
||||
try {
|
||||
String json = Objects.requireNonNull(classifierOrgClient.getJsonClassifierOrgResponse());
|
||||
ClassifierFormModel classifierFormModel = mapper.readValue(json, ClassifierFormModel.class);
|
||||
ClassifierAttributeModel[] classifierAttributeModels = classifierFormModel.getClassifier().getAttributes();
|
||||
RecordModel[] recordModels = classifierFormModel.getData().getRecords();
|
||||
String currentVersion = classifierFormModel.getClassifier().getVersion();
|
||||
try {
|
||||
String json = Objects.requireNonNull(classifierOrgClient.getJsonClassifierOrgResponse());
|
||||
ClassifierFormModel classifierFormModel = mapper.readValue(json, ClassifierFormModel.class);
|
||||
ClassifierAttributeModel[] classifierAttributeModels = classifierFormModel.getClassifier().getAttributes();
|
||||
RecordModel[] recordModels = classifierFormModel.getData().getRecords();
|
||||
String currentVersion = classifierFormModel.getClassifier().getVersion();
|
||||
|
||||
classifierAttributeDao.save(classifierAttributeModels);
|
||||
recordAttributesDao.save(recordModels, currentVersion);
|
||||
}
|
||||
catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
classifierAttributeDao.save(classifierAttributeModels);
|
||||
recordAttributesDao.save(recordModels, currentVersion);
|
||||
}
|
||||
else {
|
||||
logger.debug("Data was not load. Enabled cron: false");
|
||||
catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,7 +66,6 @@
|
|||
<property name="ervu.fileupload.max_file_size" value="5242880"/>
|
||||
<property name="ervu.fileupload.max_request_size" value="6291456"/>
|
||||
<property name="ervu.fileupload.file_size_threshold" value="0"/>
|
||||
<property name="ervu.cron.load.enable" value="true"/>
|
||||
<property name="ervu.cron.load.time" value="0 0 */1 * * *"/>
|
||||
<property name="ervu.esnsi.classifier.url.load" value="https://esnsi.gosuslugi.ru/rest/ext/v1/classifiers/11465/file?extension=JSON&encoding=UTF_8"/>
|
||||
</system-properties>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue