parent
6bfed15b7e
commit
6662c11813
@ -0,0 +1,55 @@
|
||||
package com.worker.conf;
|
||||
|
||||
import jakarta.persistence.EntityManagerFactory;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.orm.jpa.JpaTransactionManager;
|
||||
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
@Configuration
|
||||
@EnableJpaRepositories(
|
||||
basePackages = "com.worker.domain.repo.cp", // Clean Parking용 레포지토리 경로
|
||||
entityManagerFactoryRef = "cpEntityManagerFactory",
|
||||
transactionManagerRef = "cpTransactionManager"
|
||||
)
|
||||
public class CpDbConf {
|
||||
|
||||
@Bean
|
||||
@Primary
|
||||
@ConfigurationProperties("spring.datasource.cp")
|
||||
public DataSourceProperties cpDataSourceProperties() {
|
||||
return new DataSourceProperties();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Primary
|
||||
public DataSource cpDataSource() {
|
||||
return cpDataSourceProperties().initializeDataSourceBuilder().build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Primary
|
||||
public LocalContainerEntityManagerFactoryBean cpEntityManagerFactory(EntityManagerFactoryBuilder builder) {
|
||||
return builder
|
||||
.dataSource(cpDataSource())
|
||||
.packages("com.worker.domain.entity")
|
||||
.persistenceUnit("cp")
|
||||
.build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Primary
|
||||
public PlatformTransactionManager cpTransactionManager(
|
||||
@Qualifier("cpEntityManagerFactory") EntityManagerFactory cpEntityManagerFactory) {
|
||||
return new JpaTransactionManager(cpEntityManagerFactory);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,51 @@
|
||||
package com.worker.conf;
|
||||
|
||||
import jakarta.persistence.EntityManagerFactory;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.orm.jpa.JpaTransactionManager;
|
||||
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
@Configuration
|
||||
@EnableJpaRepositories(
|
||||
basePackages = "com.worker.domain.repo.ep", // Electric Parking용 레포지토리 경로
|
||||
entityManagerFactoryRef = "epEntityManagerFactory",
|
||||
transactionManagerRef = "epTransactionManager"
|
||||
)
|
||||
public class EpDbConf {
|
||||
|
||||
@Bean
|
||||
@ConfigurationProperties("spring.datasource.ep")
|
||||
public DataSourceProperties epDataSourceProperties() {
|
||||
return new DataSourceProperties();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public DataSource epDataSource() {
|
||||
return epDataSourceProperties().initializeDataSourceBuilder().build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public LocalContainerEntityManagerFactoryBean epEntityManagerFactory(EntityManagerFactoryBuilder builder) {
|
||||
return builder
|
||||
.dataSource(epDataSource())
|
||||
.packages("com.worker.domain.entity")
|
||||
.persistenceUnit("ep")
|
||||
.build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public PlatformTransactionManager epTransactionManager(
|
||||
@Qualifier("epEntityManagerFactory") EntityManagerFactory epEntityManagerFactory) {
|
||||
return new JpaTransactionManager(epEntityManagerFactory);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,80 @@
|
||||
package com.worker.domain.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.*;
|
||||
|
||||
@Entity
|
||||
@Table(name = "cp_answer")
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class CpAnswer {
|
||||
|
||||
@Id
|
||||
@Column(name = "AS_MMCODE", length = 16)
|
||||
private String asMmcode;
|
||||
|
||||
@Column(name = "AS_SGGCODE", length = 5)
|
||||
private String asSggcode;
|
||||
|
||||
@Column(name = "AS_INGB", length = 3)
|
||||
private String asIngb;
|
||||
|
||||
@Column(name = "AS_JSDATE", length = 8)
|
||||
private String asJsdate;
|
||||
|
||||
@Column(name = "AS_JSNO", length = 30)
|
||||
private String asJsno;
|
||||
|
||||
@Column(name = "AS_JSNO_M", length = 30)
|
||||
private String asJsnoM;
|
||||
|
||||
@Column(name = "AS_BBS_NO", length = 15)
|
||||
private String asBbsNo;
|
||||
|
||||
@Column(name = "AS_LIMIT_DT", length = 16)
|
||||
private String asLimitDt;
|
||||
|
||||
@Column(name = "AS_USER", length = 50)
|
||||
private String asUser;
|
||||
|
||||
@Column(name = "AS_TEL", length = 20)
|
||||
private String asTel;
|
||||
|
||||
@Column(name = "AS_CELL", length = 20)
|
||||
private String asCell;
|
||||
|
||||
@Column(name = "AS_EMAIL", length = 50)
|
||||
private String asEmail;
|
||||
|
||||
@Column(name = "AS_STATE", length = 1)
|
||||
private String asState;
|
||||
|
||||
@Column(name = "AS_POST_CD", length = 1)
|
||||
private String asPostCd;
|
||||
|
||||
@Column(name = "AS_POST_DT", length = 14)
|
||||
private String asPostDt;
|
||||
|
||||
@Column(name = "AS_STATE_DT", length = 14)
|
||||
private String asStateDt;
|
||||
|
||||
@Column(name = "AS_TEXT", length = 1000)
|
||||
private String asText;
|
||||
|
||||
@Column(name = "AS_REUSER")
|
||||
private Integer asReuser;
|
||||
|
||||
@Column(name = "AS_INLINE", length = 1)
|
||||
private String asInline;
|
||||
|
||||
@Column(name = "AS_SYS_GUBUN_C", length = 8)
|
||||
private String asSysGubunC;
|
||||
|
||||
@Column(name = "AS_PETI_ANC_CODE_V", length = 7)
|
||||
private String asPetiAncCodeV;
|
||||
|
||||
@Column(name = "AS_PETI_NO_C", length = 30)
|
||||
private String asPetiNoC;
|
||||
}
|
||||
@ -1,10 +1,7 @@
|
||||
package com.worker.entity;
|
||||
package com.worker.domain.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Entity
|
||||
@Table(name = "cp_setinfo")
|
||||
@ -1,4 +1,4 @@
|
||||
package com.worker.entity;
|
||||
package com.worker.domain.entity;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Embeddable;
|
||||
@ -0,0 +1,7 @@
|
||||
package com.worker.domain.repo.cp;
|
||||
|
||||
import com.worker.domain.entity.CpAnswer;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface CpAnswerRepository extends JpaRepository<CpAnswer,Integer> {
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
package com.worker.entity;
|
||||
package com.worker.domain.repo.cp;
|
||||
|
||||
import com.worker.domain.entity.CpMain;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
package com.worker.entity;
|
||||
package com.worker.domain.repo.cp;
|
||||
|
||||
import com.worker.domain.entity.CpSetinfo;
|
||||
import com.worker.domain.entity.CpSetinfoId;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public interface CpSetinfoRepository extends JpaRepository<CpSetinfo, CpSetinfoId> {
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
package com.worker.domain.repo.ep;
|
||||
|
||||
import com.worker.domain.entity.CpAnswer;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface EpAnswerRepository extends JpaRepository<CpAnswer,Integer> {
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
package com.worker.domain.repo.ep;
|
||||
|
||||
import com.worker.domain.entity.CpMain;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface EpMainRepository extends JpaRepository<CpMain,Integer> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
package com.worker.domain.repo.ep;
|
||||
|
||||
import com.worker.domain.entity.CpSetinfo;
|
||||
import com.worker.domain.entity.CpSetinfoId;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface EpSetinfoRepository extends JpaRepository<CpSetinfo, CpSetinfoId> {
|
||||
|
||||
|
||||
}
|
||||
@ -1,105 +0,0 @@
|
||||
package com.worker.scheduler.smg;
|
||||
|
||||
import com.worker.dto.SinmungoDto;
|
||||
import com.worker.entity.*;
|
||||
import com.worker.util.fileReader.XmlParserInterface;
|
||||
import com.worker.util.fileReader.XmlReader;
|
||||
import com.worker.util.fileReader.impl.SinmungoXmlParser;
|
||||
import jakarta.transaction.Transactional;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class SinmungoInOutScheduler {
|
||||
private final Environment env;
|
||||
|
||||
private final CpMainRepository cpMainRepository;
|
||||
|
||||
private final CpSetinfoRepository cpSetinfoRepository;
|
||||
private final XmlReader xmlReader;
|
||||
|
||||
// esb에이전트 xml파일 읽기
|
||||
@Scheduled(fixedRate = 10 * 60 * 1000) // 10분
|
||||
@Transactional
|
||||
public void sinmungoInOutScheduler() throws IOException {
|
||||
//setinfo 테이블에서 esb에이전트 정보 조회
|
||||
Optional<CpSetinfo> esbXmlDir = cpSetinfoRepository.findById(
|
||||
CpSetinfoId.builder()
|
||||
.codeName(env.getProperty("esb.info.xmlDir.codeName"))
|
||||
.groupCode(env.getProperty("esb.info.xmlDir.groupCode"))
|
||||
.detailCode(env.getProperty("esb.info.xmlDir.detailCode"))
|
||||
.build()
|
||||
);
|
||||
|
||||
Optional<CpSetinfo> esbBackupDir = cpSetinfoRepository.findById(
|
||||
CpSetinfoId.builder()
|
||||
.codeName(env.getProperty("esb.info.backupDir.codeName"))
|
||||
.groupCode(env.getProperty("esb.info.backupDir.groupCode"))
|
||||
.detailCode(env.getProperty("esb.info.backupDir.detailCode"))
|
||||
.build()
|
||||
);
|
||||
|
||||
// 국민신문고 esb에이전트 pull path 정의
|
||||
Path esbRcvPath = Paths.get(esbXmlDir.get().getStrValue4());
|
||||
Path esbSendPath = Paths.get(esbXmlDir.get().getStrValue5());
|
||||
|
||||
// 백업 디렉토리
|
||||
Path localImgPath = Paths.get(esbBackupDir.get().getStrValue1()); //img
|
||||
// StrValue2에 신문고xml 백업하는 디렉토리 넣으면 될듯.
|
||||
Path localXmlPath = Paths.get(esbBackupDir.get().getStrValue2()); //sinmungo path 는 하드코딩 되어있었음
|
||||
|
||||
//파일읽기
|
||||
XmlParserInterface<SinmungoDto.ParseResult> parser = new SinmungoXmlParser();
|
||||
List<SinmungoDto.ParseResult> parseResult = xmlReader.readXmlFiles(esbXmlDir.get().getStrValue4(), parser);
|
||||
|
||||
// cpMain만 추출
|
||||
List<CpMain> cpMainList = parseResult.stream()
|
||||
.map(SinmungoDto.ParseResult::getCpMain)
|
||||
.collect(Collectors.toList());
|
||||
// db폴링
|
||||
// cpMainRepository.saveAll(cpMainList);
|
||||
|
||||
// 파일백업으로 이동
|
||||
// xml은 HP_ROOT/PROGRAM/BATCH/sinmungo 로 백업?
|
||||
// xml안에 있던 이미지 바이너리는 HP_ROOT/DATA/IMAGE/${담당자번호?}/2025 로 백업?
|
||||
// esb에이전트 xml 파일 백업
|
||||
xmlReader.xmlFileBackup(esbRcvPath, localXmlPath);
|
||||
List<SinmungoDto.ImgParser> imgParsers = parseResult.stream()
|
||||
.flatMap(result -> result.getImgParsers().stream())
|
||||
.collect(Collectors.toList());
|
||||
xmlReader.imgLocalSave(localImgPath, imgParsers);
|
||||
|
||||
}
|
||||
|
||||
// 90일이 초과한 백업 파일들 삭제
|
||||
public void sinmungoInOutFileRemoveScheduler() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
// esb 에이전트 답변 보내기
|
||||
public void sinmungoAnswerSendScheduler() {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,128 @@
|
||||
package com.worker.scheduler.smg.sechdule;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.worker.dto.SinmungoDto;
|
||||
import com.worker.scheduler.smg.service.DbPolling;
|
||||
import com.worker.util.fileReader.XmlParserInterface;
|
||||
import com.worker.util.fileReader.XmlReader;
|
||||
import com.worker.util.fileReader.impl.SinmungoXmlParser;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class SinmungoInOutScheduler {
|
||||
|
||||
private final XmlReader xmlReader;
|
||||
|
||||
private final DbPolling dbPolling;
|
||||
|
||||
// esb에이전트 xml파일 읽기
|
||||
@Scheduled(fixedRate = 10 * 60 * 1000) // 10분
|
||||
public void sinmungoInOutScheduler() throws IOException {
|
||||
//setinfo 테이블에서 esb에이전트 정보 조회
|
||||
SinmungoDto.SetInfo setInfo = dbPolling.findSetInfo();
|
||||
|
||||
|
||||
//세외수입 부과코드인데 해당코드를 통해 cp/ep 자료를 구분함.
|
||||
// Map<String, Integer> TAXELSE_CODE_CP = new ObjectMapper()
|
||||
// .readValue(setInfo.getCpSetinfo().getStrValue6(), new TypeReference<>() {});
|
||||
// Map<String, Integer> TAXELSE_CODE_CP = setInfo.getCpSetinfo().getStrValue6();
|
||||
// Map<String, Integer> TAXELSE_CODE_EP = new ObjectMapper()
|
||||
// .readValue(setInfo.getEpSetinfo().getStrValue6(), new TypeReference<>() {});
|
||||
// Map<String, Integer> TAXELSE_CODE_EP = null;
|
||||
|
||||
// 국민신문고 esb에이전트 pull path 정의
|
||||
// Path esbRcvPath = Paths.get(setInfo.getCpSetinfo().getStrValue2());
|
||||
// Path esbSendPath = Paths.get(setInfo.getCpSetinfo().getStrValue3());
|
||||
|
||||
// 백업 디렉토리
|
||||
// sinmungo path 는 델파이에서 하드코딩 되어있었음
|
||||
// StrValue2에 신문고xml 백업하는 디렉토리 넣으면 될듯.
|
||||
// Path localCpXmlBackupPath = Paths.get(setInfo.getCpSetinfo().getStrValue4());
|
||||
// Path localCpImgBackupPath = Paths.get(setInfo.getCpSetinfo().getStrValue5()); //img
|
||||
//
|
||||
// Path localEpXmlBackupPath = Paths.get(setInfo.getEpSetinfo().getStrValue4());
|
||||
// Path localEpImgBackupPath = Paths.get(setInfo.getEpSetinfo().getStrValue5()); //img
|
||||
|
||||
//파일읽기
|
||||
XmlParserInterface<SinmungoDto.SinmungoXml> parser = new SinmungoXmlParser();
|
||||
List<SinmungoDto.SinmungoXml> parseResult = xmlReader.readXmlFiles(setInfo.getCpSetinfo().getStrValue2(), parser);
|
||||
|
||||
// cpMain만 추출
|
||||
// cp와 ep 디비가 따로있다고함.
|
||||
// db폴링
|
||||
// save cp
|
||||
List<SinmungoDto.SinmungoXml> cpList = parseResult.stream()
|
||||
.filter(item -> {
|
||||
try {
|
||||
int deptCode = Integer.parseInt(item.getPcd_dept_v());
|
||||
return new ObjectMapper()
|
||||
.readValue(setInfo.getCpSetinfo().getStrValue6(), new TypeReference<Map<String, List<Integer>>>() {})
|
||||
.values().stream()
|
||||
.map(list -> list.get(1))
|
||||
.anyMatch(v -> v == deptCode);
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
dbPolling.saveCP(cpList, setInfo);
|
||||
// save ep
|
||||
List<SinmungoDto.SinmungoXml> epList = parseResult.stream()
|
||||
.filter(item -> {
|
||||
try {
|
||||
int deptCode = Integer.parseInt(item.getPcd_dept_v());
|
||||
return new ObjectMapper()
|
||||
.readValue(setInfo.getEpSetinfo().getStrValue6(), new TypeReference<Map<String, List<Integer>>>() {})
|
||||
.values().stream()
|
||||
.map(list -> list.get(1))
|
||||
.anyMatch(v -> v == deptCode);
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
dbPolling.saveEP(epList, setInfo);
|
||||
|
||||
|
||||
/** 디비 폴링 트랜젝션 내부에서 동작하도록 이동 */
|
||||
// 파일백업으로 이동
|
||||
// xml은 HP_ROOT/PROGRAM/BATCH/sinmungo 로 백업?
|
||||
// xml안에 있던 이미지 바이너리는 HP_ROOT/DATA/IMAGE/${담당자번호?}/2025 로 백업?
|
||||
// esb에이전트 xml 파일 백업
|
||||
// xmlReader.xmlFileBackup(esbRcvPath, localXmlPath);
|
||||
// List<SinmungoDto.ImgParser> imgParsers = parseResult.stream()
|
||||
// .flatMap(result -> result.getImgParsers().stream())
|
||||
// .collect(Collectors.toList());
|
||||
// xmlReader.imgLocalSave(localImgPath, imgParsers);
|
||||
|
||||
}
|
||||
|
||||
// 90일이 초과한 백업 파일들 삭제
|
||||
public void sinmungoInOutFileRemoveScheduler() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
// esb 에이전트 답변 보내기
|
||||
public void sinmungoAnswerSendScheduler() {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,97 @@
|
||||
package com.worker.scheduler.smg.service;
|
||||
|
||||
import com.worker.domain.entity.*;
|
||||
import com.worker.domain.repo.cp.CpAnswerRepository;
|
||||
import com.worker.domain.repo.cp.CpMainRepository;
|
||||
import com.worker.domain.repo.cp.CpSetinfoRepository;
|
||||
import com.worker.domain.repo.ep.EpSetinfoRepository;
|
||||
import com.worker.dto.SinmungoDto;
|
||||
import com.worker.util.fileReader.XmlReader;
|
||||
import jakarta.transaction.Transactional;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class DbPolling {
|
||||
|
||||
private final Environment env;
|
||||
private final XmlReader xmlReader;
|
||||
|
||||
private final CpSetinfoRepository cpSetinfoRepository;
|
||||
private final EpSetinfoRepository epSetinfoRepository;
|
||||
private final CpMainRepository cpMainRepository;
|
||||
private final CpAnswerRepository cpAnswerRepository;
|
||||
|
||||
public SinmungoDto.SetInfo findSetInfo() {
|
||||
return SinmungoDto.SetInfo.builder()
|
||||
.cpSetinfo(
|
||||
cpSetinfoRepository.findById(
|
||||
CpSetinfoId.builder()
|
||||
.codeName(env.getProperty("esb.info.cp.codeName"))
|
||||
.groupCode(env.getProperty("esb.info.cp.groupCode"))
|
||||
.detailCode(env.getProperty("esb.info.cp.detailCode"))
|
||||
.build()
|
||||
).orElse(null)
|
||||
)
|
||||
.epSetinfo(
|
||||
epSetinfoRepository.findById(
|
||||
CpSetinfoId.builder()
|
||||
.codeName(env.getProperty("esb.info.ep.codeName"))
|
||||
.groupCode(env.getProperty("esb.info.ep.groupCode"))
|
||||
.detailCode(env.getProperty("esb.info.ep.detailCode"))
|
||||
.build()
|
||||
).orElse(null)
|
||||
)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void saveCP(List<SinmungoDto.SinmungoXml> cpList, SinmungoDto.SetInfo setInfo) {
|
||||
List<CpMain> cpMainList = cpList.stream()
|
||||
.map(xml -> CpMain.builder()
|
||||
.mmCarno("sample")
|
||||
.build())
|
||||
.collect(Collectors.toUnmodifiableList());
|
||||
|
||||
|
||||
List<CpAnswer> cpAnswerList = cpList.stream()
|
||||
.map(xml -> CpAnswer.builder()
|
||||
.asCell(xml.getCel_no_v())
|
||||
.asTel(xml.getTel_no_v())
|
||||
.build())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
log.info(cpAnswerList.toString());
|
||||
|
||||
//
|
||||
// cpMainRepository.saveAll(cpMainList);
|
||||
// cpAnswerRepository.saveAll(cpAnswerList);
|
||||
|
||||
// fileBackup(setInfo, cpList);
|
||||
}
|
||||
@Transactional
|
||||
public void saveEP(List<SinmungoDto.SinmungoXml> epList, SinmungoDto.SetInfo setInfo) {
|
||||
|
||||
|
||||
// fileBackup(setInfo, epList);
|
||||
}
|
||||
|
||||
// xml파일백업 및 바이너리 이미지 저장
|
||||
private void fileBackup(SinmungoDto.SetInfo setInfo, List<SinmungoDto.SinmungoXml> cpList) {
|
||||
|
||||
xmlReader.xmlFileBackup(Paths.get(setInfo.getCpSetinfo().getStrValue2()), Paths.get(setInfo.getCpSetinfo().getStrValue4()));
|
||||
List<SinmungoDto.ImgParser> imgParsers = cpList.stream()
|
||||
.flatMap(result -> result.getImgParsers().stream())
|
||||
.collect(Collectors.toList());
|
||||
xmlReader.imgLocalSave(Paths.get(setInfo.getCpSetinfo().getStrValue5()), imgParsers);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue