feat : taxsunap 작업 1차완료

master
Kurt92 4 months ago
parent a9daf6d43b
commit f6d48fe1be

@ -208,4 +208,9 @@ public class CpGojiPrt {
@Column(name = "GP_ELPOST_STATE", length = 2)
private String gpElpostState;
public void changeGpSunapAfterSunap() {
this.gpSunap = "1";
}
}

@ -158,4 +158,17 @@ public class CpMain {
@Column(name = "MM_TRANSMIT_TEAM", length = 50)
private String mmTransmitTeam;
public void changeMmStateAfterSunap() {
this.mmState = switch (this.mmState) {
case "41" -> "71";
case "51" -> "72";
case "52" -> "73";
case "53" -> "74";
case "54", "55" -> "75";
default -> "71";
};
}
}

@ -1,7 +1,9 @@
package com.worker.domain.repo.cp;
import com.worker.domain.entity.CpGojiPrt;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.jpa.repository.JpaRepository;
public interface CpGojiPrtRepository extends CrudRepository<CpGojiPrt, Integer> {
import java.util.Optional;
public interface CpGojiPrtRepository extends JpaRepository<CpGojiPrt, Long> {
}

@ -5,4 +5,5 @@ import com.worker.domain.entity.CpViolationId;
import org.springframework.data.jpa.repository.JpaRepository;
public interface CpViolationRepository extends JpaRepository<CpViolation, CpViolationId> {
CpViolation findByIdVlCode(String gpLawGb);
}

@ -1,7 +1,9 @@
package com.worker.domain.repo.ep;
import com.worker.domain.entity.CpGojiPrt;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.jpa.repository.JpaRepository;
public interface EpGojiPrtRepository extends CrudRepository<CpGojiPrt, Integer> {
import java.util.Optional;
public interface EpGojiPrtRepository extends JpaRepository<CpGojiPrt, Long> {
}

@ -0,0 +1,34 @@
package com.worker.scheduler.epost.schedule;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@Component
@RequiredArgsConstructor
@Slf4j
public class EPostScheduler {
@Scheduled(fixedRate = 10 * 60 * 1000) // 10분
public void ePostScheduler() {
/**
*
* , text
* */
// esb경로 info
//전송대상 찾기
//대상 text만들기
//대상 읽기
}
}

@ -29,6 +29,8 @@ public class TaxSunapDto {
private String gpLvyNo;
private String gpLawgb;
private String gpAccYear;
private Long gpCode;
private String mmCode;
}
@Getter
@ -91,7 +93,7 @@ public class TaxSunapDto {
private String state; // Success/Fail
private int code; // 200/500 ...
private List<Result> result; // 상세 메시지
private Result result; // 상세 메시지

@ -26,13 +26,16 @@ public class TaxSunapQueryDslRepository {
TaxSunapDto.Request.GojiTarget.class,
cpGojiPrt.gpLvyNo,
cpGojiPrt.gpLawgb,
cpGojiPrt.gpAccYear
cpGojiPrt.gpAccYear,
cpGojiPrt.gpCode,
cpMain.mmCode
)
)
.from(cpGojiPrt)
.innerJoin(cpMain).on(cpMain.mmCode.eq(cpGojiPrt.gpMmcode))
.innerJoin(cpSgg).on(cpSgg.sgSggcode.eq(cpGojiPrt.gpSggcode))
.where(
// todo: now기준으로 바꿔야함.
cpGojiPrt.gpSdate.loe("20250704"),
cpGojiPrt.gpEdate.goe("20250717"),
cpGojiPrt.gpState.goe("2"),

@ -14,8 +14,6 @@ import org.springframework.stereotype.Component;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Mono;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
@Component
@ -39,6 +37,10 @@ public class TaxSunapScheduler {
List<TaxSunapDto.Request.GojiTarget> cpTargets = taxSunapService.findGojiTarget();
List<TaxSunapDto.Request.GojiTarget> epTargets = taxSunapService.findGojiTarget();
if(cpTargets.isEmpty() || epTargets.isEmpty()) {
log.info("연계할 타겟 없음");
}
for (TaxSunapDto.Request.GojiTarget target : cpTargets) taxSunap("cp", setInfo.getCpSetinfo(), target);
for (TaxSunapDto.Request.GojiTarget target : epTargets) taxSunap("ep", setInfo.getEpSetinfo(), target);
@ -66,11 +68,11 @@ public class TaxSunapScheduler {
res != null ? res.getState() : null,
res != null ? res.getCode() : null,
res != null ? res.getResult() : null);
log.info(res.getResult().size() + "건 조회 완료.");
log.info(res.getResult().getPyrNm() + "건 조회 완료.");
taxSunapService.taxSunapUpdate(res.getResult(), kind, target);
for(int i = 0; i < res.getResult().size(); i++) {
taxSunapService.taxSunapUpdate(res.getResult().get(i), kind);
}
}

@ -1,15 +1,8 @@
package com.worker.scheduler.tax.service;
import com.worker.domain.entity.CpMatch;
import com.worker.domain.entity.CpSetinfo;
import com.worker.domain.entity.CpSetinfoId;
import com.worker.domain.entity.CpViolation;
import com.worker.domain.repo.cp.CpMatchRepository;
import com.worker.domain.repo.cp.CpSetinfoRepository;
import com.worker.domain.repo.cp.CpViolationRepository;
import com.worker.domain.repo.ep.EpMatchRepository;
import com.worker.domain.repo.ep.EpSetinfoRepository;
import com.worker.domain.repo.ep.EpViolationRepository;
import com.worker.domain.entity.*;
import com.worker.domain.repo.cp.*;
import com.worker.domain.repo.ep.*;
import com.worker.scheduler.tax.dto.TaxSunapDto;
import com.worker.scheduler.tax.repository.TaxSunapQueryDslRepository;
import lombok.RequiredArgsConstructor;
@ -20,6 +13,7 @@ import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
@Service
@ -29,10 +23,14 @@ public class TaxSunapService {
private final Environment env;
private final CpMainRepository cpMainRepository;
private final EpMainRepository epMainRepository;
private final CpGojiPrtRepository cpGojiPrtRepository;
private final EpGojiPrtRepository epGojiPrtRepository;
private final CpSetinfoRepository cpSetinfoRepository;
private final EpSetinfoRepository epSetinfoRepository;
private final CpMatchRepository cpMatchRepository;
private final EpMatchRepository epMatchRepository;
private final CpViolationRepository cpViolationRepository;
private final EpViolationRepository epViolationRepository;
@ -71,9 +69,9 @@ public class TaxSunapService {
}
public TaxSunapDto.Request.SendReq taxSunapFindReqInfo(String kind, CpSetinfo setInfo, TaxSunapDto.Request.GojiTarget target) {
CpViolation cpViolation = epViolationRepository.findByIdVlCode(target.getGpLawgb());
CpViolation cpViolation = new CpViolation();
if (kind.equals("cp")) cpViolationRepository.findByIdVlCode(target.getGpLawgb());
else epViolationRepository.findByIdVlCode(target.getGpLawgb());
log.info("taxSunapFindReqInfo 세목1: " + cpViolation.getVlSemok1());
log.info("taxSunapFindReqInfo 세목2: " + cpViolation.getVlSemok2());
@ -111,63 +109,32 @@ public class TaxSunapService {
return sendReq;
}
public void taxSunapUpdate(TaxSunapDto.Response.Result result, String kind) {
CpMatch cpMatch = null;
if(kind.equals("cp")) cpMatch = cpMatchRepository.findByMcMmcode(result.getMngItemSn6());
else cpMatch = epMatchRepository.findByMcMmcode(result.getMngItemSn6());
if(cpMatch != null) {
// 매치자료가 있으면 업데이트
} else {
// 매치자료가 없으면 인서트
cpMatch = CpMatch.builder()
.mcMmcode(result.getMngItemSn6())
.mcLvyKey(result.getLvyKey())
.mcLvyNo(result.getLvyNo())
// .mcAccYear(result.)
.mcMmWdatetime("")
.mcMmSgpos("")
.mcBdong("")
.mcLvyKey("")
.mcAccYear("")
.mcLvyNo("")
.mcAccountNo("")
.mcAccountNo2("")
.mcAccountNo3("")
.mcAccountNo4("")
.mcAccountNo5("")
.mcAccountNo6("")
.mcAccountNo7("")
.mcAccountNo8("")
.mcAccountNo9("")
.mcAccountNo10("")
.mcAccountNo11("")
.mcBankNm("")
.mcBankNm2("")
.mcBankNm3("")
.mcBankNm4("")
.mcBankNm5("")
.mcBankNm6("")
.mcBankNm7("")
.mcBankNm8("")
.mcBankNm9("")
.mcBankNm10("")
.mcBankNm11("")
.mcErcNo("")
.mcKeumT("")
.mcKeumA("")
.mcKeumB("")
.mcIndt("")
.mcEditdt("")
.build();
public void taxSunapUpdate(TaxSunapDto.Response.Result result, String kind, TaxSunapDto.Request.GojiTarget target) {
if(kind.equals("cp") && result.getLinkRstCd().equals("004")) {
cpMainRepository.findById(target.getMmCode())
.ifPresent(cp -> {
cp.changeMmStateAfterSunap();
cpMainRepository.save(cp); // 필요 시
});
cpGojiPrtRepository.findById(target.getGpCode())
.ifPresent(cp -> {
cp.changeGpSunapAfterSunap();
cpGojiPrtRepository.save(cp);
});
} else if (kind.equals("ep") && result.getLinkRstCd().equals("004")){
epMainRepository.findById(target.getMmCode())
.ifPresent(ep -> {
ep.changeMmStateAfterSunap();
epMainRepository.save(ep); // 필요 시
});
epGojiPrtRepository.findById(target.getGpCode())
.ifPresent(ep -> {
ep.changeGpSunapAfterSunap();
epGojiPrtRepository.save(ep);
});
}
if(kind.equals("cp")) cpMatchRepository.save(cpMatch);
else epMatchRepository.save(cpMatch);
}

Loading…
Cancel
Save