first commit
This commit is contained in:
17
src/main/java/com/pledge/torgi/MainApplication.java
Normal file
17
src/main/java/com/pledge/torgi/MainApplication.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.pledge.torgi;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableJpaRepositories
|
||||
@EnableJpaAuditing
|
||||
@EnableConfigurationProperties
|
||||
public class MainApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(MainApplication.class, args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,202 @@
|
||||
package com.pledge.torgi.controller;
|
||||
|
||||
import com.pledge.torgi.model.Configs;
|
||||
import com.pledge.torgi.model.TorgiEvent;
|
||||
import com.pledge.torgi.repositories.ConfigsRepository;
|
||||
import com.pledge.torgi.repositories.TorgiEventRepository;
|
||||
import com.pledge.torgi.service.DownloadHeadlessService;
|
||||
import com.pledge.torgi.service.SendEmailService;
|
||||
import com.pledge.torgi.service.Lot;
|
||||
import com.pledge.torgi.utils.StartParams;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import static com.pledge.torgi.model.Configs.LAST_RUN_TIME;
|
||||
|
||||
@Service
|
||||
public class DownloadHeadlessController {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(DownloadHeadlessController.class);
|
||||
private final Set<String> content = new HashSet<>();
|
||||
private final TorgiEventRepository eventRepository;
|
||||
private final ConfigsRepository configsRepository;
|
||||
|
||||
public DownloadHeadlessController(TorgiEventRepository eventRepository, ConfigsRepository configsRepository) {
|
||||
this.eventRepository = eventRepository;
|
||||
this.configsRepository = configsRepository;
|
||||
eventRepository.findAllByOrderByCreatedAtDesc(PageRequest.of(0, 10000)).forEach(event -> content.add(event.getKey()));
|
||||
}
|
||||
|
||||
public void process() {
|
||||
addNewToDiff();
|
||||
}
|
||||
|
||||
private void addNewToDiff() {
|
||||
logger.error("startProcessing");
|
||||
DownloadHeadlessService downloadHeadlessService = new DownloadHeadlessService();
|
||||
Map<String, Lot> currentContent = downloadHeadlessService.downloadExcel();
|
||||
List<TorgiEvent> newEvents = new ArrayList<>();
|
||||
|
||||
for (String key : currentContent.keySet()) {
|
||||
if (!content.contains(key)) {
|
||||
newEvents.add(new TorgiEvent(key, currentContent.get(key)));
|
||||
content.add(key);
|
||||
logger.error("added new diff content");
|
||||
}
|
||||
}
|
||||
eventRepository.saveAll(newEvents);
|
||||
logger.error("completeProcessing");
|
||||
}
|
||||
|
||||
public void sendNewContent(StartParams params, List<String> cadastral, String email) {
|
||||
DownloadHeadlessService downloadHeadlessService = new DownloadHeadlessService();
|
||||
LocalDate now = LocalDate.now();
|
||||
downloadHeadlessService.createNewDocument(eventRepository, cadastral, now);
|
||||
createArchive(now);
|
||||
sendArchive(params, now, email);
|
||||
removeArchiveAndSource(now);
|
||||
logger.error("sended archive");
|
||||
}
|
||||
|
||||
public void sendNewContent(StartParams params) {
|
||||
if (alreadyRunnedToday()) {
|
||||
return;
|
||||
}
|
||||
DownloadHeadlessService downloadHeadlessService = new DownloadHeadlessService();
|
||||
LocalDate now = LocalDate.now();
|
||||
downloadHeadlessService.createNewDocument(eventRepository, now);
|
||||
// int i = 0;
|
||||
// while (true) {
|
||||
// List<Lot> partition = eventRepository.findAllByOrderByCreatedAtDesc(PageRequest.of(i, 30000)).stream().map(Lot::new).toList();
|
||||
// if (partition.isEmpty()) {
|
||||
// break;
|
||||
// }
|
||||
// downloadHeadlessService.createNewDocument(eventRepository, now, i);
|
||||
// i++;
|
||||
// }
|
||||
createArchive(now);
|
||||
sendArchive(params, now);
|
||||
removeArchiveAndSource(now);
|
||||
logger.error("sended archive");
|
||||
saveTime();
|
||||
}
|
||||
|
||||
private void saveTime() {
|
||||
List<Configs> configs = configsRepository.findAll().stream().filter(cfg -> cfg.getKey().equals(LAST_RUN_TIME)).toList();
|
||||
if (configs.isEmpty()) {
|
||||
Configs newValue = new Configs();
|
||||
newValue.setId(1L);
|
||||
newValue.setKey(LAST_RUN_TIME);
|
||||
newValue.setValue(LocalDateTime.now().toString());
|
||||
configsRepository.save(newValue);
|
||||
}
|
||||
else {
|
||||
Configs oldValue = configs.get(0);
|
||||
oldValue.setValue(LocalDateTime.now().toString());
|
||||
configsRepository.save(oldValue);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean alreadyRunnedToday() {
|
||||
List<Configs> configs = configsRepository.findAll().stream().filter(cfg -> cfg.getKey().equals(LAST_RUN_TIME)).toList();
|
||||
if (configs.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
LocalDateTime fromDB = LocalDateTime.parse(configs.get(0).getValue());
|
||||
return fromDB.format(DateTimeFormatter.ISO_LOCAL_DATE).equals(LocalDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE));
|
||||
}
|
||||
|
||||
private void removeArchiveAndSource(LocalDate now) {
|
||||
new File(now + ".zip").delete();
|
||||
deleteDirectory(new File(now.toString()));
|
||||
}
|
||||
|
||||
private boolean deleteDirectory(File directoryToBeDeleted) {
|
||||
File[] allContents = directoryToBeDeleted.listFiles();
|
||||
if (allContents != null) {
|
||||
for (File file : allContents) {
|
||||
deleteDirectory(file);
|
||||
}
|
||||
}
|
||||
return directoryToBeDeleted.delete();
|
||||
}
|
||||
|
||||
private void sendArchive(StartParams params, LocalDate now) {
|
||||
try {
|
||||
new SendEmailService("smtp.gmail.com", 587, params.getFrom(), params.getToken())
|
||||
.sendMail(params.getFrom(),
|
||||
params.getTo(),//"m.ryabyh@gmail.com,MEvRyabykh@sberbank.ru",
|
||||
"Новая Выгрузка по торгам от " + now,
|
||||
"Новая Выгрузка по торгам от " + now,
|
||||
new File(now + ".zip"));
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void sendArchive(StartParams params, LocalDate now, String to) {
|
||||
try {
|
||||
new SendEmailService("smtp.gmail.com", 587, params.getFrom(), params.getToken())
|
||||
.sendMail(params.getFrom(),
|
||||
to,//"m.ryabyh@gmail.com,MEvRyabykh@sberbank.ru",
|
||||
"Новая Выгрузка по торгам от " + now,
|
||||
"Новая Выгрузка по торгам от " + now,
|
||||
new File(now + ".zip"));
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void createArchive(LocalDate now) {
|
||||
String sourceFile = now.toString();
|
||||
try (FileOutputStream fos = new FileOutputStream(now + ".zip");
|
||||
ZipOutputStream zipOut = new ZipOutputStream(fos)) {
|
||||
File fileToZip = new File(sourceFile);
|
||||
zipFile(fileToZip, fileToZip.getName(), zipOut);
|
||||
} catch (Exception ex) {
|
||||
logger.error("in createArchive" + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private static void zipFile(File fileToZip, String fileName, ZipOutputStream zipOut) throws IOException {
|
||||
if (fileToZip.isHidden()) {
|
||||
return;
|
||||
}
|
||||
if (fileToZip.isDirectory()) {
|
||||
if (fileName.endsWith("/")) {
|
||||
zipOut.putNextEntry(new ZipEntry(fileName));
|
||||
zipOut.closeEntry();
|
||||
} else {
|
||||
zipOut.putNextEntry(new ZipEntry(fileName + "/"));
|
||||
zipOut.closeEntry();
|
||||
}
|
||||
File[] children = fileToZip.listFiles();
|
||||
for (File childFile : children) {
|
||||
zipFile(childFile, fileName + "/" + childFile.getName(), zipOut);
|
||||
}
|
||||
return;
|
||||
}
|
||||
FileInputStream fis = new FileInputStream(fileToZip);
|
||||
ZipEntry zipEntry = new ZipEntry(fileName);
|
||||
zipOut.putNextEntry(zipEntry);
|
||||
byte[] bytes = new byte[1024];
|
||||
int length;
|
||||
while ((length = fis.read(bytes)) >= 0) {
|
||||
zipOut.write(bytes, 0, length);
|
||||
}
|
||||
fis.close();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.pledge.torgi.controller;
|
||||
|
||||
import com.pledge.torgi.controller.storage.FileService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
|
||||
@Controller
|
||||
public class FileUploadController {
|
||||
|
||||
private final FileService storageService;
|
||||
|
||||
@Autowired
|
||||
public FileUploadController(FileService storageService) {
|
||||
this.storageService = storageService;
|
||||
}
|
||||
|
||||
@GetMapping("/")
|
||||
public String listUploadedFiles() {
|
||||
return "uploadForm";
|
||||
}
|
||||
|
||||
@PostMapping("/")
|
||||
public String handleFileUpload(@RequestParam("file") MultipartFile file, @RequestParam("email") String email,
|
||||
RedirectAttributes redirectAttributes) {
|
||||
|
||||
String result = storageService.processAsync(file, email);
|
||||
redirectAttributes.addFlashAttribute("message",
|
||||
result);
|
||||
return "redirect:/";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.pledge.torgi.controller;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
public class HealthController {
|
||||
|
||||
@GetMapping("/health")
|
||||
public ResponseEntity<String> getPerson() {
|
||||
return ResponseEntity.ok().body("OK");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.pledge.torgi.controller.storage;
|
||||
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
public interface FileService {
|
||||
|
||||
String processAsync(MultipartFile file, String email);
|
||||
String processSync(Workbook file, String email);
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.pledge.torgi.controller.storage;
|
||||
|
||||
import com.pledge.torgi.controller.DownloadHeadlessController;
|
||||
import com.pledge.torgi.utils.StartParams;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class FileServiceImpl implements FileService {
|
||||
|
||||
private final DownloadHeadlessController headlessController;
|
||||
private final StartParams params;
|
||||
|
||||
@Override
|
||||
public String processAsync(MultipartFile file, String email) {
|
||||
try {
|
||||
log.error("Get request");
|
||||
IOUtils.setByteArrayMaxOverride(1000000000);
|
||||
Workbook wb = new XSSFWorkbook(file.getInputStream());
|
||||
List<String> cadastrals = extractCadastral(wb);
|
||||
log.error("Extract cadastrals: " + cadastrals.size());
|
||||
|
||||
Thread myThread = new Thread(() -> headlessController.sendNewContent(params, cadastrals, email));
|
||||
myThread.start();
|
||||
|
||||
log.error("Complete request");
|
||||
return "Взято в обработку " + cadastrals.size() + " кадастровых номеров";
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new StorageException("Failed to store file.", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String processSync(Workbook file, String email) {
|
||||
log.error("Get request");
|
||||
List<String> cadastrals = extractCadastral(file);
|
||||
log.error("Extract cadastrals: " + cadastrals.size());
|
||||
|
||||
headlessController.sendNewContent(params, cadastrals, email);
|
||||
|
||||
log.error("Complete request");
|
||||
return "Обработано " + cadastrals.size() + " кадастровых номеров";
|
||||
}
|
||||
|
||||
private List<String> extractCadastral(Workbook wb) {
|
||||
List<String> result = new ArrayList<>();
|
||||
Sheet firstSheet = wb.getSheetAt(0);
|
||||
int rowNum = 0;
|
||||
Row currentRow = firstSheet.getRow(rowNum);
|
||||
|
||||
while(currentRow != null && currentRow.getCell(0) != null) {
|
||||
try {
|
||||
String stringCellValue = currentRow.getCell(0).getStringCellValue();
|
||||
if (StringUtils.isBlank(stringCellValue)) {
|
||||
break;
|
||||
} else {
|
||||
result.add(stringCellValue);
|
||||
}
|
||||
} catch (IllegalStateException e) {
|
||||
log.error("Error during processing " + rowNum + " " + e);
|
||||
}
|
||||
|
||||
rowNum++;
|
||||
currentRow = firstSheet.getRow(rowNum);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.pledge.torgi.controller.storage;
|
||||
|
||||
public class StorageException extends RuntimeException {
|
||||
|
||||
public StorageException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public StorageException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
30
src/main/java/com/pledge/torgi/enums/IntervalEnum.java
Normal file
30
src/main/java/com/pledge/torgi/enums/IntervalEnum.java
Normal file
@@ -0,0 +1,30 @@
|
||||
package com.pledge.torgi.enums;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public enum IntervalEnum {
|
||||
PUB("По дате публикации", "pub"),
|
||||
BIDD_END("По дате окончания срока подачи заявок", "biddEnd"),
|
||||
AUC_START("По дате проведения торгов", "aucStart"),
|
||||
;
|
||||
|
||||
private final String description;
|
||||
private final String searchParam;
|
||||
|
||||
IntervalEnum(String description, String searchParam) {
|
||||
this.description = description;
|
||||
this.searchParam = searchParam;
|
||||
}
|
||||
|
||||
public static IntervalEnum getByDescription(String description) {
|
||||
return Arrays.stream(IntervalEnum.values()).filter(el -> el.getDescription().equals(description)).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public String getSearchParam() {
|
||||
return searchParam;
|
||||
}
|
||||
}
|
||||
23
src/main/java/com/pledge/torgi/model/Configs.java
Normal file
23
src/main/java/com/pledge/torgi/model/Configs.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package com.pledge.torgi.model;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Table(name = "CONFIGS")
|
||||
public class Configs {
|
||||
|
||||
public static final String LAST_RUN_TIME = "LAST_RUN_TIME";
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
private String key;
|
||||
private String value;
|
||||
}
|
||||
28
src/main/java/com/pledge/torgi/model/Emails.java
Normal file
28
src/main/java/com/pledge/torgi/model/Emails.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package com.pledge.torgi.model;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Entity
|
||||
@Getter
|
||||
@Setter
|
||||
@EntityListeners(AuditingEntityListener.class)
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Emails {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "EmailId")
|
||||
@SequenceGenerator(name = "EmailId", sequenceName = "EMAILS_SEQ", allocationSize = 1)
|
||||
private Long id;
|
||||
|
||||
private String mailId;
|
||||
private String replyTo;
|
||||
private LocalDateTime processedTime;
|
||||
}
|
||||
59
src/main/java/com/pledge/torgi/model/TorgiEvent.java
Normal file
59
src/main/java/com/pledge/torgi/model/TorgiEvent.java
Normal file
@@ -0,0 +1,59 @@
|
||||
package com.pledge.torgi.model;
|
||||
|
||||
import com.pledge.torgi.service.Lot;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.springframework.data.annotation.CreatedDate;
|
||||
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Entity
|
||||
@Getter
|
||||
@Setter
|
||||
@EntityListeners(AuditingEntityListener.class)
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class TorgiEvent {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "TorgiId")
|
||||
@SequenceGenerator(name = "TorgiId", sequenceName = "TORGI_EVENT_SEQ", allocationSize = 1)
|
||||
private Long id;
|
||||
private String key;
|
||||
private String status;
|
||||
private String bidStart;
|
||||
private String bidEnd;
|
||||
private String tradesDate;
|
||||
private String startPrice;
|
||||
private String step;
|
||||
private String initMoney;
|
||||
private String finalPrice;
|
||||
private String notice;
|
||||
private Integer lotNumber;
|
||||
private String cadastral;
|
||||
private String type;
|
||||
private String fullInfo;
|
||||
@CreatedDate
|
||||
@Column(name = "created_at")
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
public TorgiEvent(String key, Lot lotInfo) {
|
||||
this.key = key;
|
||||
this.status = lotInfo.getStatus();
|
||||
this.bidStart = lotInfo.getBidStart();
|
||||
this.bidEnd = lotInfo.getBidEnd();
|
||||
this.tradesDate = lotInfo.getTradesDate();
|
||||
this.startPrice = lotInfo.getStartPrice();
|
||||
this.step = lotInfo.getStep();
|
||||
this.initMoney = lotInfo.getInitMoney();
|
||||
this.finalPrice = lotInfo.getFinalPrice();
|
||||
this.notice = lotInfo.getNotice();
|
||||
this.lotNumber = lotInfo.getLotNumber();
|
||||
this.cadastral = lotInfo.getCadastral();
|
||||
this.type = lotInfo.getType();
|
||||
this.fullInfo = lotInfo.getFullInfo();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.pledge.torgi.repositories;
|
||||
|
||||
import com.pledge.torgi.model.Configs;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface ConfigsRepository extends JpaRepository<Configs, Long> {
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.pledge.torgi.repositories;
|
||||
|
||||
import com.pledge.torgi.model.Emails;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface EmailsRepository extends JpaRepository<Emails, Long> {
|
||||
boolean existsByMailId(String mailId);
|
||||
List<Emails> findTop10ByOrderByIdDesc();
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.pledge.torgi.repositories;
|
||||
|
||||
import com.pledge.torgi.model.TorgiEvent;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface TorgiEventRepository extends JpaRepository<TorgiEvent, Long> {
|
||||
List<TorgiEvent> findAllByOrderByCreatedAtDesc();
|
||||
|
||||
Page<TorgiEvent> findAllByOrderByCreatedAtDesc(Pageable pageable);
|
||||
List<TorgiEvent> findAllByFullInfoLikeOrderByCreatedAtDesc(String cadastral);
|
||||
}
|
||||
@@ -0,0 +1,237 @@
|
||||
package com.pledge.torgi.service;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.pledge.torgi.model.TorgiEvent;
|
||||
import com.pledge.torgi.repositories.TorgiEventRepository;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFRow;
|
||||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.nio.file.FileSystems;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static com.pledge.torgi.utils.AppUtils.EMPTY;
|
||||
import static com.pledge.torgi.utils.AppUtils.EXCEL_LINK;
|
||||
import static java.util.Objects.nonNull;
|
||||
|
||||
public class DownloadHeadlessService {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(DownloadHeadlessService.class);
|
||||
private final ObjectMapper objectMapper = new ObjectMapper().configure(JsonParser.Feature.INCLUDE_SOURCE_IN_LOCATION, true).configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false).enable(JsonParser.Feature.INCLUDE_SOURCE_IN_LOCATION);
|
||||
Pattern cadastralPattern = Pattern.compile("\\d{1,2}:\\d{1,2}:\\d{1,7}:\\d{1,9}");
|
||||
Pattern vinPattern = Pattern.compile("\\b[A-HJ-NPR-Z0-9-]{12,17}\\b");
|
||||
|
||||
public Map<String, Lot> downloadExcel() {
|
||||
try {
|
||||
HttpURLConnection connection = (HttpURLConnection) new URL(EXCEL_LINK).openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
|
||||
Map<String, Lot> data = new HashMap<>();
|
||||
Workbook wb = new XSSFWorkbook(connection.getInputStream());
|
||||
Sheet sheetWithData = wb.getSheetAt(0);
|
||||
int currentRow = 2;
|
||||
while (sheetWithData.getRow(currentRow) != null) {
|
||||
List<String> cadastrals = extractCadastral(sheetWithData.getRow(currentRow).getCell(29).getStringCellValue());
|
||||
if (cadastrals.isEmpty()) {
|
||||
Lot extractedContent = extractDataFromRow(sheetWithData.getRow(currentRow), "");
|
||||
data.put(extractedContent.getNotice()+ "_" + extractedContent.getLotNumber() + "_" + extractedContent.getStatus(), extractedContent);
|
||||
} else {
|
||||
for (String cadastral : cadastrals) {
|
||||
Lot extractedContent = extractDataFromRow(sheetWithData.getRow(currentRow), cadastral);
|
||||
data.put(extractedContent.getNotice()+ "_" + extractedContent.getLotNumber() + "_" + extractedContent.getStatus() + "_" + cadastral, extractedContent);
|
||||
}
|
||||
}
|
||||
|
||||
currentRow++;
|
||||
}
|
||||
return data;
|
||||
} else {
|
||||
logger.error("Error in line 99 ");
|
||||
return downloadExcel();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("Error in line 103 " + e);
|
||||
}
|
||||
return downloadExcel();
|
||||
}
|
||||
|
||||
private Lot extractDataFromRow(Row row, String cadastral) {
|
||||
Lot lot = new Lot();
|
||||
lot.setBidStart(row.getCell(6).getStringCellValue());
|
||||
lot.setBidEnd(row.getCell(7).getStringCellValue());
|
||||
lot.setCadastral(cadastral);
|
||||
lot.setLotNumber((int)row.getCell(16).getNumericCellValue());
|
||||
lot.setFinalPrice(row.getCell(27).getStringCellValue());
|
||||
lot.setNotice(row.getCell(3).getStringCellValue());
|
||||
lot.setInitMoney(row.getCell(24).getStringCellValue());
|
||||
lot.setStep(row.getCell(25).getStringCellValue());
|
||||
lot.setStartPrice(row.getCell(26).getStringCellValue());
|
||||
lot.setStatus(row.getCell(17).getStringCellValue());
|
||||
lot.setTradesDate(row.getCell(9).getStringCellValue());
|
||||
lot.setFullInfo(row.getCell(29).getStringCellValue());
|
||||
lot.setType(row.getCell(1).getStringCellValue());
|
||||
return lot;
|
||||
}
|
||||
|
||||
public List<String> extractCadastral(String rawValue) {
|
||||
String[] split = rawValue.split(";");
|
||||
List<String> cadastrals = new ArrayList<>();
|
||||
for (String part : split) {
|
||||
int delimiter = part.indexOf(":");
|
||||
if (delimiter == -1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (part.trim().startsWith("Кадастровый номер") || part.trim().startsWith("VIN") || part.trim().startsWith("Условный номер земельного участка")) {
|
||||
String value = part.substring(delimiter + 1).trim();
|
||||
if (value.contains("|")) {
|
||||
String[] differentCadastrals = value.split("\\|");
|
||||
for (String singleCadastral : differentCadastrals) {
|
||||
cadastrals.add(singleCadastral.trim());
|
||||
}
|
||||
} else if (value.contains(",")) {
|
||||
String[] differentCadastrals = value.split(",");
|
||||
for (String singleCadastral : differentCadastrals) {
|
||||
cadastrals.add(singleCadastral.trim());
|
||||
}
|
||||
} else {
|
||||
cadastrals.add(part.substring(delimiter + 1).trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
return cadastrals;
|
||||
}
|
||||
|
||||
public void createNewDocument(TorgiEventRepository eventRepository, LocalDate now) {
|
||||
try (XSSFWorkbook workbook = new XSSFWorkbook()) {
|
||||
XSSFSheet sheet = workbook.createSheet("sheet");
|
||||
setRowHead(sheet);
|
||||
logger.error("before write body");
|
||||
int i = 0;
|
||||
int currentRow = 1;
|
||||
while (true) {
|
||||
List<Lot> partition = eventRepository.findAllByOrderByCreatedAtDesc(PageRequest.of(i, 1000)).stream().map(Lot::new).toList();
|
||||
if (partition.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
currentRow = setRowBodyNew(sheet, currentRow, partition);
|
||||
i++;
|
||||
}
|
||||
//setRowWith(sheet);
|
||||
logger.error("before write to file");
|
||||
try (FileOutputStream fileOut = new FileOutputStream(getFileToSave(now))) {
|
||||
workbook.write(fileOut);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.error("in createNewDocument " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void createNewDocument(TorgiEventRepository eventRepository, List<String> cadastrals, LocalDate now) {
|
||||
try (XSSFWorkbook workbook = new XSSFWorkbook()) {
|
||||
XSSFSheet sheet = workbook.createSheet("sheet");
|
||||
setRowHead(sheet);
|
||||
|
||||
List<Lot> data = extractData(eventRepository, cadastrals);
|
||||
int currentRow = 1;
|
||||
setRowBodyNew(sheet, currentRow, data);
|
||||
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
workbook.write(out);
|
||||
logger.error("before write to file");
|
||||
try (FileOutputStream fileOut = new FileOutputStream(getFileToSave(now))) {
|
||||
workbook.write(fileOut);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.error("in createNewDocument " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private List<Lot> extractData(TorgiEventRepository eventRepository, List<String> cadastrals) {
|
||||
Set<TorgiEvent> events = new LinkedHashSet<>();
|
||||
int i = 0;
|
||||
for (String cadastral : cadastrals) {
|
||||
i++;
|
||||
try {
|
||||
events.addAll(eventRepository.findAllByFullInfoLikeOrderByCreatedAtDesc("% " + cadastral + " %"));
|
||||
} catch (Exception e) {
|
||||
logger.error("Error during process cadastral = " + cadastral + " " + e);
|
||||
}
|
||||
if (i % 100 == 0) {
|
||||
logger.error("executed = " + i + " added = " + events.size());
|
||||
}
|
||||
}
|
||||
return events.stream().map(Lot::new).toList();
|
||||
}
|
||||
|
||||
private void setRowHead(XSSFSheet sheet) {
|
||||
XSSFRow rowHead = sheet.createRow( 0);
|
||||
rowHead.createCell(0).setCellValue("Статус торгов");
|
||||
rowHead.createCell(1).setCellValue("Дата начала подачи заявок");
|
||||
rowHead.createCell(2).setCellValue("Дата окончания подачи заявок");
|
||||
rowHead.createCell(3).setCellValue("Дата проведения торгов");
|
||||
rowHead.createCell(4).setCellValue("Начальная цена");
|
||||
rowHead.createCell(5).setCellValue("Шаг аукциона");
|
||||
rowHead.createCell(6).setCellValue("Размер задатка");
|
||||
rowHead.createCell(7).setCellValue("Итоговая цена");
|
||||
rowHead.createCell(8).setCellValue("Извещение");
|
||||
rowHead.createCell(9).setCellValue("Лот");
|
||||
rowHead.createCell(10).setCellValue("Кадастровый номер");
|
||||
rowHead.createCell(11).setCellValue("Общая информация");
|
||||
rowHead.createCell(12).setCellValue("Тип активности");
|
||||
rowHead.createCell(13).setCellValue("Время получения события");
|
||||
}
|
||||
|
||||
private int setRowBodyNew(XSSFSheet sheet, int currentRow, Collection<Lot> contents) throws JsonProcessingException {
|
||||
for (Lot lot : contents) {
|
||||
currentRow = createRow(sheet, currentRow, lot);
|
||||
}
|
||||
return currentRow;
|
||||
}
|
||||
|
||||
private static int createRow(XSSFSheet sheet, int rowCount, Lot lotShema) {
|
||||
XSSFRow row = sheet.createRow(rowCount);
|
||||
row.createCell(0).setCellValue(nonNull(lotShema.getStatus()) ? lotShema.getStatus() : EMPTY); // Статус торгов
|
||||
row.createCell(1).setCellValue(nonNull(lotShema.getBidStart()) ? lotShema.getBidStart() : EMPTY); // Дата начала подачи заявок
|
||||
row.createCell(2).setCellValue(nonNull(lotShema.getBidEnd()) ? lotShema.getBidEnd() : EMPTY); // Дата окончания подачи заявок
|
||||
row.createCell(3).setCellValue(nonNull(lotShema.getTradesDate()) ? lotShema.getTradesDate() : EMPTY); // Дата проведения торгов
|
||||
row.createCell(4).setCellValue(nonNull(lotShema.getStartPrice()) ? lotShema.getStartPrice() : EMPTY); // Начальная цена
|
||||
row.createCell(5).setCellValue(nonNull(lotShema.getStep()) ? lotShema.getStep() : EMPTY); // Шаг аукциона
|
||||
row.createCell(6).setCellValue(nonNull(lotShema.getInitMoney()) ? lotShema.getInitMoney() : EMPTY); // Размер задатка
|
||||
row.createCell(7).setCellValue(nonNull(lotShema.getFinalPrice()) ? lotShema.getFinalPrice() : EMPTY); // Итоговая цена
|
||||
row.createCell(8).setCellValue(nonNull(lotShema.getNotice()) ? lotShema.getNotice() : EMPTY); // Извещение
|
||||
row.createCell(9).setCellValue(nonNull(lotShema.getLotNumber()) ? lotShema.getLotNumber() : 0); // Лот
|
||||
row.createCell(10).setCellValue(lotShema.getCadastral());
|
||||
row.createCell(11).setCellValue(nonNull(lotShema.getFullInfo()) ? lotShema.getFullInfo() : EMPTY);
|
||||
row.createCell(12).setCellValue(nonNull(lotShema.getType()) ? lotShema.getType() : EMPTY);
|
||||
row.createCell(13).setCellValue(nonNull(lotShema.getGettedAt()) ? lotShema.getGettedAt().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME) : EMPTY);
|
||||
rowCount++;
|
||||
return rowCount;
|
||||
}
|
||||
|
||||
|
||||
private File getFileToSave(LocalDate now) {
|
||||
File dir = new File(now.toString());
|
||||
if(!dir.exists()) {
|
||||
dir.mkdir();
|
||||
}
|
||||
return new File(dir.getAbsolutePath() + FileSystems.getDefault().getSeparator() + now + ".xlsx");
|
||||
}
|
||||
}
|
||||
13
src/main/java/com/pledge/torgi/service/EmailData.java
Normal file
13
src/main/java/com/pledge/torgi/service/EmailData.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package com.pledge.torgi.service;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class EmailData {
|
||||
private String emails;
|
||||
private String emailId;
|
||||
private Workbook file;
|
||||
}
|
||||
44
src/main/java/com/pledge/torgi/service/EmailService.java
Normal file
44
src/main/java/com/pledge/torgi/service/EmailService.java
Normal file
@@ -0,0 +1,44 @@
|
||||
package com.pledge.torgi.service;
|
||||
|
||||
import com.pledge.torgi.controller.storage.FileService;
|
||||
import com.pledge.torgi.model.Emails;
|
||||
import com.pledge.torgi.repositories.EmailsRepository;
|
||||
import com.pledge.torgi.utils.StartParams;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class EmailService {
|
||||
|
||||
private final FileService fileService;
|
||||
private final EmailsRepository emailsRepository;
|
||||
|
||||
public void processEmails(StartParams params) {
|
||||
List<Emails> alreadyProcessed = emailsRepository.findTop10ByOrderByIdDesc();
|
||||
List<EmailData> emailData = new ReceiveEmailService("imap.gmail.com", 993, params.getFrom(), params.getToken(), params.getSpecialEmail())
|
||||
.downloadEmails(alreadyProcessed);
|
||||
for (EmailData data : emailData) {
|
||||
if (alreadyProcessed(data.getEmailId())) {
|
||||
continue;
|
||||
}
|
||||
fileService.processSync(data.getFile(), data.getEmails());
|
||||
saveProcessedEmail(data);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean alreadyProcessed(String emailId) {
|
||||
return emailsRepository.existsByMailId(emailId);
|
||||
}
|
||||
|
||||
private void saveProcessedEmail(EmailData data) {
|
||||
Emails processed = new Emails();
|
||||
processed.setMailId(data.getEmailId());
|
||||
processed.setReplyTo(data.getEmails());
|
||||
processed.setProcessedTime(LocalDateTime.now());
|
||||
emailsRepository.save(processed);
|
||||
}
|
||||
}
|
||||
48
src/main/java/com/pledge/torgi/service/Lot.java
Normal file
48
src/main/java/com/pledge/torgi/service/Lot.java
Normal file
@@ -0,0 +1,48 @@
|
||||
package com.pledge.torgi.service;
|
||||
|
||||
import com.pledge.torgi.model.TorgiEvent;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public class Lot {
|
||||
|
||||
private String status;
|
||||
private String bidStart;
|
||||
private String bidEnd;
|
||||
private String tradesDate;
|
||||
private String startPrice;
|
||||
private String step;
|
||||
private String initMoney;
|
||||
private String finalPrice;
|
||||
private String notice;
|
||||
private Integer lotNumber;
|
||||
private String cadastral;
|
||||
private String type;
|
||||
|
||||
private String fullInfo;
|
||||
private LocalDateTime gettedAt;
|
||||
|
||||
public Lot(TorgiEvent event) {
|
||||
status = event.getStatus();
|
||||
bidStart = event.getBidStart();
|
||||
bidEnd = event.getBidEnd();
|
||||
tradesDate = event.getTradesDate();
|
||||
startPrice = event.getStartPrice();
|
||||
step = event.getStep();
|
||||
initMoney = event.getInitMoney();
|
||||
finalPrice = event.getFinalPrice();
|
||||
notice = event.getNotice();
|
||||
lotNumber = event.getLotNumber();
|
||||
cadastral = event.getCadastral();
|
||||
type = event.getType();
|
||||
fullInfo = event.getFullInfo();
|
||||
gettedAt = event.getCreatedAt();
|
||||
}
|
||||
|
||||
public Lot() {
|
||||
}
|
||||
}
|
||||
33
src/main/java/com/pledge/torgi/service/MainService.java
Normal file
33
src/main/java/com/pledge/torgi/service/MainService.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package com.pledge.torgi.service;
|
||||
|
||||
import com.pledge.torgi.controller.DownloadHeadlessController;
|
||||
import com.pledge.torgi.controller.storage.FileService;
|
||||
import com.pledge.torgi.utils.StartParams;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Service
|
||||
@EnableScheduling
|
||||
@AllArgsConstructor
|
||||
public class MainService {
|
||||
private final StartParams params;
|
||||
private final DownloadHeadlessController headlessController;
|
||||
private final EmailService emailService;
|
||||
|
||||
@Scheduled(timeUnit = TimeUnit.SECONDS, fixedRate = 120)
|
||||
public void getNewData() {
|
||||
headlessController.process();
|
||||
}
|
||||
|
||||
@Scheduled(timeUnit = TimeUnit.SECONDS, fixedRate = 600)
|
||||
public void checkEmail() {
|
||||
emailService.processEmails(params);
|
||||
}
|
||||
}
|
||||
122
src/main/java/com/pledge/torgi/service/ReceiveEmailService.java
Normal file
122
src/main/java/com/pledge/torgi/service/ReceiveEmailService.java
Normal file
@@ -0,0 +1,122 @@
|
||||
package com.pledge.torgi.service;
|
||||
|
||||
import com.pledge.torgi.model.Emails;
|
||||
import com.sun.mail.imap.IMAPMessage;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
import javax.mail.*;
|
||||
import javax.mail.internet.InternetAddress;
|
||||
import javax.mail.internet.MimeMultipart;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
|
||||
public class ReceiveEmailService {
|
||||
private String username;
|
||||
private String password;
|
||||
private String specialEmail;
|
||||
private String protocol = "imaps";
|
||||
|
||||
private final Properties prop;
|
||||
public ReceiveEmailService(String host, int port, String username, String password, String specialEmail) {
|
||||
prop = getServerProperties(host, port);
|
||||
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
this.specialEmail = specialEmail;
|
||||
}
|
||||
|
||||
public List<EmailData> downloadEmails(List<Emails> alreadyProcessed) {
|
||||
List<EmailData> result = new ArrayList<>();
|
||||
Session session = Session.getDefaultInstance(prop);
|
||||
|
||||
try {
|
||||
// connects to the message store
|
||||
Store store = session.getStore(protocol);
|
||||
store.connect(prop.getProperty("mail.imaps.host"), username, password);
|
||||
|
||||
// opens the inbox folder
|
||||
Folder folderInbox = store.getFolder("INBOX");
|
||||
folderInbox.open(Folder.READ_ONLY);
|
||||
|
||||
// fetches new messages from server
|
||||
int messageCount = folderInbox.getMessageCount();
|
||||
Message[] messages = folderInbox.getMessages(messageCount - 50, messageCount);
|
||||
|
||||
for (int i = 0; i < messages.length; i++) {
|
||||
Message msg = messages[i];
|
||||
Address[] toList = msg.getRecipients(Message.RecipientType.TO);
|
||||
boolean specialAddress = Arrays.stream(toList).anyMatch(addr -> ((InternetAddress) addr).getAddress().equals(specialEmail));
|
||||
if (!specialAddress) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String messageID = ((IMAPMessage) msg).getMessageID();
|
||||
if (alreadyProcessed.stream().anyMatch(processed -> processed.getMailId().equals(messageID))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
MimeMultipart content = (MimeMultipart) msg.getDataHandler().getContent();
|
||||
if (content.getCount() == 1 || !Part.ATTACHMENT.equalsIgnoreCase(content.getBodyPart(1).getDisposition())) {
|
||||
continue;
|
||||
}
|
||||
InputStream excelIS = content.getBodyPart(1).getInputStream();
|
||||
IOUtils.setByteArrayMaxOverride(1000000000);
|
||||
Workbook wb = new XSSFWorkbook(excelIS);
|
||||
List<String> replyMails = new ArrayList<>(Arrays.stream(toList).map(addr -> ((InternetAddress) addr).getAddress())
|
||||
.filter(email -> !email.equals(specialEmail))
|
||||
.toList());
|
||||
replyMails.add(((InternetAddress)((IMAPMessage) msg).getSender()).getAddress());
|
||||
EmailData data = new EmailData();
|
||||
data.setEmailId(messageID);
|
||||
data.setFile(wb);
|
||||
data.setEmails(String.join(",", replyMails));
|
||||
System.out.println("Emails for reply: " + data.getEmails());
|
||||
result.add(data);
|
||||
} catch (Exception ex) {
|
||||
System.out.println("No provider for protocol: " + protocol);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// disconnect
|
||||
folderInbox.close(false);
|
||||
store.close();
|
||||
} catch (NoSuchProviderException ex) {
|
||||
System.out.println("No provider for protocol: " + protocol);
|
||||
ex.printStackTrace();
|
||||
} catch (MessagingException ex) {
|
||||
System.out.println("Could not connect to the message store");
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private Properties getServerProperties(String host, int port) {
|
||||
|
||||
Properties properties = new Properties();
|
||||
|
||||
// server setting
|
||||
properties.put(String.format("mail.%s.host", protocol), host);
|
||||
properties.put(String.format("mail.%s.port", protocol), port);
|
||||
|
||||
// SSL setting
|
||||
properties.setProperty(
|
||||
String.format("mail.%s.socketFactory.class", protocol),
|
||||
"javax.net.ssl.SSLSocketFactory");
|
||||
properties.setProperty(
|
||||
String.format("mail.%s.socketFactory.fallback", protocol),
|
||||
"false");
|
||||
properties.setProperty(
|
||||
String.format("mail.%s.socketFactory.port", protocol),
|
||||
String.valueOf(port));
|
||||
|
||||
return properties;
|
||||
}
|
||||
}
|
||||
64
src/main/java/com/pledge/torgi/service/SendEmailService.java
Normal file
64
src/main/java/com/pledge/torgi/service/SendEmailService.java
Normal file
@@ -0,0 +1,64 @@
|
||||
package com.pledge.torgi.service;
|
||||
|
||||
import javax.activation.DataHandler;
|
||||
import javax.activation.DataSource;
|
||||
import javax.activation.FileDataSource;
|
||||
import javax.mail.*;
|
||||
import javax.mail.internet.InternetAddress;
|
||||
import javax.mail.internet.MimeBodyPart;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
import javax.mail.internet.MimeMultipart;
|
||||
import java.io.File;
|
||||
import java.util.Properties;
|
||||
|
||||
|
||||
public class SendEmailService {
|
||||
private String username;
|
||||
private String password;
|
||||
|
||||
private final Properties prop;
|
||||
public SendEmailService(String host, int port, String username, String password) {
|
||||
prop = new Properties();
|
||||
prop.put("mail.smtp.auth", true);
|
||||
prop.put("mail.smtp.starttls.enable", "true");
|
||||
prop.put("mail.smtp.host", host);
|
||||
prop.put("mail.smtp.port", port);
|
||||
prop.put("mail.smtp.ssl.trust", host);
|
||||
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public void sendMail(String from,String to,String subject, String msg, File archive) throws Exception {
|
||||
|
||||
Session session = Session.getInstance(prop, new Authenticator() {
|
||||
@Override
|
||||
protected PasswordAuthentication getPasswordAuthentication() {
|
||||
return new PasswordAuthentication(username, password);
|
||||
}
|
||||
});
|
||||
|
||||
Message message = new MimeMessage(session);
|
||||
message.setFrom(new InternetAddress(from));
|
||||
message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(to));
|
||||
message.setSubject(subject);
|
||||
|
||||
MimeBodyPart mimeBodyPart = new MimeBodyPart();
|
||||
mimeBodyPart.setContent(msg, "text/html; charset=utf-8");
|
||||
|
||||
|
||||
MimeBodyPart attachmentPart = new MimeBodyPart();
|
||||
DataSource source = new FileDataSource(archive);
|
||||
attachmentPart.setDataHandler(new DataHandler(source));
|
||||
attachmentPart.setFileName(source.getName());
|
||||
|
||||
// Combine body and attachment parts
|
||||
MimeMultipart multipart = new MimeMultipart();
|
||||
multipart.addBodyPart(mimeBodyPart);
|
||||
multipart.addBodyPart(attachmentPart);
|
||||
|
||||
message.setContent(multipart);
|
||||
|
||||
Transport.send(message);
|
||||
}
|
||||
}
|
||||
33
src/main/java/com/pledge/torgi/utils/AppUtils.java
Normal file
33
src/main/java/com/pledge/torgi/utils/AppUtils.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package com.pledge.torgi.utils;
|
||||
|
||||
import java.text.Format;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public final class AppUtils {
|
||||
|
||||
public final static Map<String, String> STATUS_TRANSLATE = new HashMap<String, String>() {{
|
||||
put("DETERMINING_WINNER", "Определение победителя");
|
||||
put("APPLICATIONS_SUBMISSION", "Прием заявок");
|
||||
put("CANCELED", "Отменен");
|
||||
put("PUBLISHED", "Опубликован");
|
||||
put("SUCCEED", "Состоялся");
|
||||
put("FAILED", "Не состоялся");
|
||||
}};
|
||||
public static final ArrayList<String> CADASTRAL_NUMBER_LIST = new ArrayList<String>() {{
|
||||
add("Кадастровый номер");
|
||||
add("Кадастровые номера");
|
||||
add("Кадастровый номер земельного участка");
|
||||
add("VIN номер");
|
||||
}};
|
||||
public static final int THREAD_SIZE = 16;
|
||||
public static final String EMPTY = "";
|
||||
public static final String XLSX = ".xlsx";
|
||||
public static final int MAX_DAY = 7;
|
||||
public static final String LOT_CARDS_URL = "https://torgi.gov.ru/new/api/public/lotcards/"; //example https://torgi.gov.ru/new/api/public/lotcards/21000000050000000852_1
|
||||
public static final String SEARCH_URL = "https://torgi.gov.ru/new/api/public/lotcards/search?"; //example https://torgi.gov.ru/new/api/public/lotcards/search?pubFrom=2025-02-04&pubTo=2025-02-04&byFirstVersion=true&withFacets=true&page=0&size=10&sort=firstVersionPublicationDate,desc
|
||||
public static final Format DATE_FORMATTER = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
public static final String EXCEL_LINK = "https://torgi.gov.ru/new/api/public/lotcards/export/excel?byFirstVersion=true&sort=updateDate,desc";
|
||||
}
|
||||
19
src/main/java/com/pledge/torgi/utils/StartParams.java
Normal file
19
src/main/java/com/pledge/torgi/utils/StartParams.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package com.pledge.torgi.utils;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "pledge.params")
|
||||
public class StartParams {
|
||||
|
||||
private String from;
|
||||
private String token;
|
||||
private String to;
|
||||
private String days;
|
||||
private String specialEmail;
|
||||
}
|
||||
14
src/main/resources/application.properties
Normal file
14
src/main/resources/application.properties
Normal file
@@ -0,0 +1,14 @@
|
||||
pledge.params.from=changeit@gmail.com
|
||||
pledge.params.token=changeit
|
||||
pledge.params.to=m.ryabyh@gmail.com,AAAtapina@sberbank.ru,Oreshkina.V.V@sberbank.ru,MEvRyabykh@sberbank.ru
|
||||
pledge.params.days=1
|
||||
pledge.params.special-email=m.ryabyh+torgi@gmail.com
|
||||
spring.datasource.url=jdbc:postgresql://localhost:5432/torgi
|
||||
spring.datasource.username=torgi
|
||||
spring.datasource.password=17maxim02
|
||||
spring.datasource.driver-class-name=org.postgresql.Driver
|
||||
spring.servlet.multipart.max-file-size=20MB
|
||||
spring.servlet.multipart.max-request-size=20MB
|
||||
server.tomcat.connection-timeout=300000
|
||||
server.tomcat.keep-alive-timeout=300000
|
||||
server.connection-timeout=300000
|
||||
22
src/main/resources/db/migration/V1__init_event_table.sql
Normal file
22
src/main/resources/db/migration/V1__init_event_table.sql
Normal file
@@ -0,0 +1,22 @@
|
||||
CREATE TABLE torgi_event
|
||||
(
|
||||
id BIGINT NOT NULL,
|
||||
key VARCHAR(255),
|
||||
status VARCHAR(255),
|
||||
bid_start VARCHAR(255),
|
||||
bid_end VARCHAR(255),
|
||||
trades_date VARCHAR(255),
|
||||
start_price VARCHAR(255),
|
||||
step VARCHAR(255),
|
||||
init_money VARCHAR(255),
|
||||
final_price VARCHAR(255),
|
||||
notice VARCHAR(255),
|
||||
lot_number INTEGER,
|
||||
cadastral VARCHAR(255),
|
||||
type VARCHAR(255),
|
||||
created_at TIMESTAMP,
|
||||
full_info VARCHAR,
|
||||
CONSTRAINT pk_torgievent PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE SEQUENCE TORGI_EVENT_SEQ;
|
||||
7
src/main/resources/db/migration/V2__add_configs.sql
Normal file
7
src/main/resources/db/migration/V2__add_configs.sql
Normal file
@@ -0,0 +1,7 @@
|
||||
CREATE TABLE configs
|
||||
(
|
||||
id BIGINT NOT NULL,
|
||||
key VARCHAR(255),
|
||||
value VARCHAR(255),
|
||||
CONSTRAINT pk_configs PRIMARY KEY (id)
|
||||
);
|
||||
10
src/main/resources/db/migration/V3__add_emails.sql
Normal file
10
src/main/resources/db/migration/V3__add_emails.sql
Normal file
@@ -0,0 +1,10 @@
|
||||
CREATE TABLE emails
|
||||
(
|
||||
id BIGINT NOT NULL,
|
||||
mail_id VARCHAR(255),
|
||||
processed_time TIMESTAMP,
|
||||
reply_to VARCHAR(255),
|
||||
CONSTRAINT pk_emails PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE SEQUENCE emails_seq;
|
||||
471
src/main/resources/schemas/lot-shema.json
Normal file
471
src/main/resources/schemas/lot-shema.json
Normal file
@@ -0,0 +1,471 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"lotName": {
|
||||
"type": "string"
|
||||
},
|
||||
"lotStatus": {
|
||||
"type": "string"
|
||||
},
|
||||
"biddForm": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"noticeNumber": {
|
||||
"type": "string"
|
||||
},
|
||||
"lotNumber": {
|
||||
"type": "integer"
|
||||
},
|
||||
"biddType": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"subjectRFCode": {
|
||||
"type": "string"
|
||||
},
|
||||
"lotDescription": {
|
||||
"type": "string"
|
||||
},
|
||||
"priceMin": {
|
||||
"type": "number"
|
||||
},
|
||||
"priceStep": {
|
||||
"type": "number"
|
||||
},
|
||||
"previousProcedures": {
|
||||
"type": "array"
|
||||
},
|
||||
"lotImages": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"lotAttachments": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"fileId": {
|
||||
"type": "string"
|
||||
},
|
||||
"signatureId": {
|
||||
"type": "string"
|
||||
},
|
||||
"fileName": {
|
||||
"type": "string"
|
||||
},
|
||||
"fileSize": {
|
||||
"type": "integer"
|
||||
},
|
||||
"uploadDate": {
|
||||
"type": "string"
|
||||
},
|
||||
"hash": {
|
||||
"type": "string"
|
||||
},
|
||||
"attachmentTypeCode": {
|
||||
"type": "string"
|
||||
},
|
||||
"attachmentTypeName": {
|
||||
"type": "string"
|
||||
},
|
||||
"inactive": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"checkResult": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"noticeAttachments": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"fileId": {
|
||||
"type": "string"
|
||||
},
|
||||
"signatureId": {
|
||||
"type": "string"
|
||||
},
|
||||
"fileName": {
|
||||
"type": "string"
|
||||
},
|
||||
"fileSize": {
|
||||
"type": "integer"
|
||||
},
|
||||
"uploadDate": {
|
||||
"type": "string"
|
||||
},
|
||||
"hash": {
|
||||
"type": "string"
|
||||
},
|
||||
"attachmentTypeCode": {
|
||||
"type": "string"
|
||||
},
|
||||
"attachmentTypeName": {
|
||||
"type": "string"
|
||||
},
|
||||
"inactive": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"checkResult": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"characteristics": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"characteristicValue": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": [
|
||||
"number",
|
||||
"string"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"value": {
|
||||
"type": "string"
|
||||
},
|
||||
"selectNsi": {
|
||||
"type": "string"
|
||||
},
|
||||
"code": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"actual": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"code": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": {
|
||||
"type": "string"
|
||||
},
|
||||
"unit": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"symbol": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"currencyCode": {
|
||||
"type": "string"
|
||||
},
|
||||
"etpCode": {
|
||||
"type": "string"
|
||||
},
|
||||
"category": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"timeZoneName": {
|
||||
"type": "string"
|
||||
},
|
||||
"timezoneOffset": {
|
||||
"type": "string"
|
||||
},
|
||||
"ownershipForm": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"etpUrl": {
|
||||
"type": "string"
|
||||
},
|
||||
"deposit": {
|
||||
"type": "number"
|
||||
},
|
||||
"estateAddress": {
|
||||
"type": "string"
|
||||
},
|
||||
"attributes": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "string"
|
||||
},
|
||||
"fullName": {
|
||||
"type": "string"
|
||||
},
|
||||
"value": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
{
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
"attributeType": {
|
||||
"type": "string"
|
||||
},
|
||||
"group": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"displayGroupType": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"sortOrder": {
|
||||
"type": "integer"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"depositElectronicPlatform": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"depositRecipientName": {
|
||||
"type": "string"
|
||||
},
|
||||
"depositRecipientINN": {
|
||||
"type": "string"
|
||||
},
|
||||
"depositRecipientKPP": {
|
||||
"type": "string"
|
||||
},
|
||||
"depositBankName": {
|
||||
"type": "string"
|
||||
},
|
||||
"depositBIK": {
|
||||
"type": "string"
|
||||
},
|
||||
"depositPayAccount": {
|
||||
"type": "string"
|
||||
},
|
||||
"depositCorAccount": {
|
||||
"type": "string"
|
||||
},
|
||||
"depositPurposePayment": {
|
||||
"type": "string"
|
||||
},
|
||||
"hasAppeals": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"isStopped": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"auctionStartDate": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"biddStartTime": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"biddEndTime": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"versionId": {
|
||||
"type": "string"
|
||||
},
|
||||
"noticeSignedData": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"fileId": {
|
||||
"type": "string"
|
||||
},
|
||||
"signatureId": {
|
||||
"type": "string"
|
||||
},
|
||||
"fileName": {
|
||||
"type": "string"
|
||||
},
|
||||
"fileSize": {
|
||||
"type": "integer"
|
||||
},
|
||||
"uploadDate": {
|
||||
"type": "string"
|
||||
},
|
||||
"hash": {
|
||||
"type": "string"
|
||||
},
|
||||
"inactive": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"egrkns": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"number": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"egrnInfoRequestList": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"requestId": {
|
||||
"type": "string"
|
||||
},
|
||||
"status": {
|
||||
"type": "string"
|
||||
},
|
||||
"hasRestrictions": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"cadastralOrderNumber": {
|
||||
"type": "integer"
|
||||
},
|
||||
"objects": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "string"
|
||||
},
|
||||
"objectTypeCode": {
|
||||
"type": "string"
|
||||
},
|
||||
"cadastralNumber": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"noticeFirstVersionPublicationDate": {
|
||||
"type": "string"
|
||||
},
|
||||
"isAnnulled": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"lotVat": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"npaHintCode": {
|
||||
"type": "string"
|
||||
},
|
||||
"typeTransaction": {
|
||||
"type": "string"
|
||||
},
|
||||
"priceFin": {
|
||||
"type": "integer"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
268
src/main/resources/schemas/shema.json
Normal file
268
src/main/resources/schemas/shema.json
Normal file
@@ -0,0 +1,268 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "Generated schema for Root",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"content": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"noticeNumber": {
|
||||
"type": "string"
|
||||
},
|
||||
"lotNumber": {
|
||||
"type": "number"
|
||||
},
|
||||
"lotStatus": {
|
||||
"type": "string"
|
||||
},
|
||||
"biddType": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"biddForm": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"lotName": {
|
||||
"type": "string"
|
||||
},
|
||||
"lotDescription": {
|
||||
"type": "string"
|
||||
},
|
||||
"biddEndTime": {
|
||||
"type": "string"
|
||||
},
|
||||
"lotImages": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"characteristics": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"characteristicValue": {},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"code": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": {
|
||||
"type": "string"
|
||||
},
|
||||
"unit": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"symbol": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"currencyCode": {
|
||||
"type": "string"
|
||||
},
|
||||
"subjectRFCode": {
|
||||
"type": "string"
|
||||
},
|
||||
"category": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"createDate": {
|
||||
"type": "string"
|
||||
},
|
||||
"timeZoneName": {
|
||||
"type": "string"
|
||||
},
|
||||
"timezoneOffset": {
|
||||
"type": "string"
|
||||
},
|
||||
"hasAppeals": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"isStopped": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"attributes": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "string"
|
||||
},
|
||||
"fullName": {
|
||||
"type": "string"
|
||||
},
|
||||
"attributeType": {
|
||||
"type": "string"
|
||||
},
|
||||
"group": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"displayGroupType": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"sortOrder": {
|
||||
"type": "number"
|
||||
},
|
||||
"value": {}
|
||||
}
|
||||
}
|
||||
},
|
||||
"isAnnulled": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"noticeFirstVersionPublicationDate": {
|
||||
"type": "string"
|
||||
},
|
||||
"npaHintCode": {
|
||||
"type": "string"
|
||||
},
|
||||
"typeTransaction": {
|
||||
"type": "string"
|
||||
},
|
||||
"priceMin": {
|
||||
"type": "number"
|
||||
},
|
||||
"etpCode": {
|
||||
"type": "string"
|
||||
},
|
||||
"lotVat": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"pageable": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"sort": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"unsorted": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"sorted": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"empty": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"pageNumber": {
|
||||
"type": "number"
|
||||
},
|
||||
"pageSize": {
|
||||
"type": "number"
|
||||
},
|
||||
"offset": {
|
||||
"type": "number"
|
||||
},
|
||||
"paged": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"unpaged": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"categoryFacet": {
|
||||
"type": "array",
|
||||
"items": {}
|
||||
},
|
||||
"totalPages": {
|
||||
"type": "number"
|
||||
},
|
||||
"totalElements": {
|
||||
"type": "number"
|
||||
},
|
||||
"last": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"numberOfElements": {
|
||||
"type": "number"
|
||||
},
|
||||
"first": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"size": {
|
||||
"type": "number"
|
||||
},
|
||||
"number": {
|
||||
"type": "number"
|
||||
},
|
||||
"sort": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"unsorted": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"sorted": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"empty": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"empty": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
}
|
||||
22
src/main/resources/templates/uploadForm.html
Normal file
22
src/main/resources/templates/uploadForm.html
Normal file
@@ -0,0 +1,22 @@
|
||||
<html xmlns:th="https://www.thymeleaf.org">
|
||||
<body>
|
||||
|
||||
<div th:if="${message}">
|
||||
<h2 th:text="${message}"/>
|
||||
</div>
|
||||
<div>
|
||||
<h2>Нужно загрузить эксель файл на 1 листе которого в первом столбце будут кадастровые или vin номера тех объектов, информацию по которым необходимо получить</h2>
|
||||
</div>
|
||||
<br/>
|
||||
<div>
|
||||
<form method="POST" enctype="multipart/form-data" action="/">
|
||||
<table>
|
||||
<tr><td>Выберите файл:</td><td><input type="file" name="file" /></td></tr>
|
||||
<tr><td>Почта для получения:</td><td><input type="text" name="email" /></td></tr>
|
||||
<tr><td></td><td><input type="submit" value="Обработать" /></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user