fix: 코드 정리 및 comment 추가

main
Jonguk. Lim 2 months ago
parent b5d538baa9
commit ca60c92bf2

@ -1,12 +1,18 @@
package cokr.xit.ens.modules.common.ctgy.intgrnbill.support.entity.repository;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.entity.Bill;
import io.lettuce.core.dynamic.annotation.Param;
import java.util.Optional;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import java.util.Optional;
import cokr.xit.ens.modules.common.ctgy.intgrnbill.support.entity.Bill;
import io.lettuce.core.dynamic.annotation.Param;
/**
* Bill - ens_bill
* TODO: - Accept
*/
public interface BillRepository extends JpaRepository<Bill, Long> {
@Query("select a from Bill a inner join a.orgMng where a.billUid = :billUid")

@ -1,12 +1,17 @@
package cokr.xit.ens.modules.common.ctgy.intgrnnoti.domain.repository;
import cokr.xit.ens.modules.common.ctgy.intgrnnoti.domain.IntgrnSendDetail;
import cokr.xit.ens.modules.common.ctgy.intgrnnoti.domain.IntgrnSendMast;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
import java.util.Optional;
import org.springframework.data.jpa.repository.JpaRepository;
import cokr.xit.ens.modules.common.ctgy.intgrnnoti.domain.IntgrnSendDetail;
import cokr.xit.ens.modules.common.ctgy.intgrnnoti.domain.IntgrnSendMast;
/**
* Send details - ens_intgrn_snd_dtl
* TODO: - Accept
*/
public interface IntgrnSendDetailRepository extends JpaRepository<IntgrnSendDetail, Long>, IntgrnSendDetailRepositoryCustom {
List<IntgrnSendDetail> findAllByIntgrnSendMast(IntgrnSendMast intgrnSendMast);

@ -1,13 +1,18 @@
package cokr.xit.ens.modules.common.ctgy.intgrnnoti.domain.repository;
import cokr.xit.ens.modules.common.code.StatCd;
import cokr.xit.ens.modules.common.ctgy.intgrnnoti.domain.IntgrnSendMast;
import cokr.xit.ens.modules.common.ctgy.intgrnnoti.code.TryStatCd;
import org.springframework.data.jpa.repository.JpaRepository;
import java.time.LocalDateTime;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import cokr.xit.ens.modules.common.code.StatCd;
import cokr.xit.ens.modules.common.ctgy.intgrnnoti.code.TryStatCd;
import cokr.xit.ens.modules.common.ctgy.intgrnnoti.domain.IntgrnSendMast;
/**
* Send master - ens_intgrn_snd_dtl
* TODO: - Accept
*/
public interface IntgrnSendMastRepository extends JpaRepository<IntgrnSendMast, Long>, IntgrnSendMastRepositoryCustom {
List<IntgrnSendMast> findAllByIntSendMastIdIn(List<Long> sendMastIds);

@ -1,5 +1,16 @@
package cokr.xit.ens.modules.common.ctgy.intgrnnoti.service;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import cokr.xit.ens.core.aop.EnsResponseVO;
import cokr.xit.ens.core.exception.EnsException;
import cokr.xit.ens.core.exception.code.EnsErrCd;
@ -9,18 +20,16 @@ import cokr.xit.ens.modules.common.ctgy.intgrnnoti.domain.IntgrnSendMast;
import cokr.xit.ens.modules.common.ctgy.intgrnnoti.domain.repository.IntgrnSendDetailRepository;
import cokr.xit.ens.modules.common.ctgy.intgrnnoti.domain.repository.IntgrnSendMastRepository;
import cokr.xit.ens.modules.common.ctgy.intgrnnoti.model.IntgrnNotiAcceptReqDTO;
import cokr.xit.ens.modules.common.ctgy.intgrnnoti.service.support.*;
import cokr.xit.ens.modules.common.ctgy.intgrnnoti.service.support.IntgrnNotiAcceptor;
import cokr.xit.ens.modules.common.ctgy.intgrnnoti.service.support.IntgrnNotiMaker;
import cokr.xit.ens.modules.common.ctgy.intgrnnoti.service.support.IntgrnNotiRsltFetcher;
import cokr.xit.ens.modules.common.ctgy.intgrnnoti.service.support.IntgrnNotiRsltProvider;
import cokr.xit.ens.modules.common.ctgy.intgrnnoti.service.support.IntgrnNotiSender;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import lombok.val;
// TODO: 전자고지 서비스
@Slf4j
@Service
@RequiredArgsConstructor
@ -44,8 +53,8 @@ public class IntgrnNotiService {
* @return
*/
@Transactional(propagation = Propagation.SUPPORTS)
public EnsResponseVO accept(IntgrnNotiAcceptReqDTO reqDTO) {
EnsResponseVO responseVO = null;
public EnsResponseVO<?> accept(IntgrnNotiAcceptReqDTO reqDTO) {
EnsResponseVO<?> responseVO = null;
try {
responseVO = intgrnSendAcceptor.statBegin(reqDTO);
if (!EnsErrCd.OK.equals(responseVO.getErrCode()))
@ -70,7 +79,7 @@ public class IntgrnNotiService {
* @return
*/
@Transactional(propagation = Propagation.SUPPORTS)
public EnsResponseVO remake(Long intSendMastId) {
public EnsResponseVO<?> remake(Long intSendMastId) {
try {
IntgrnSendMast sendMast = intgrnSendMastRepository.findById(intSendMastId)
.orElseThrow(() -> new EnsException(EnsErrCd.MAKE404, "일치하는 자료가 없습니다."));
@ -84,7 +93,7 @@ public class IntgrnNotiService {
.build();
}
intgrnNotiMaker.statReady(Arrays.asList(intSendMastId));
intgrnNotiMaker.statReady(Collections.singletonList(intSendMastId));
return this.make(intSendMastId);
@ -96,12 +105,12 @@ public class IntgrnNotiService {
* @return
*/
@Transactional(propagation = Propagation.SUPPORTS)
public EnsResponseVO makeAll() {
public EnsResponseVO<?> makeAll() {
List<Long> sendMastIds = intgrnSendMastRepository.findAllByStatCdIn(Arrays.asList(StatCd.accept))
.stream()
.map(row -> row.getIntSendMastId())
.collect(Collectors.toList());
if (sendMastIds.size() < 1)
if (sendMastIds.isEmpty())
return EnsResponseVO.errBuilder()
.errCode(EnsErrCd.MAKE404)
.errMsg("\"접수(accept)\" 상태인 자료가 없습니다")
@ -109,15 +118,15 @@ public class IntgrnNotiService {
intgrnNotiMaker.statReady(sendMastIds);
List<EnsResponseVO> resultInfo = sendMastIds.stream()
.map(intSendMastId -> this.make(intSendMastId))
val resultInfo = sendMastIds.stream()
.map(this::make)
.collect(Collectors.toList());
return EnsResponseVO.okBuilder().resultInfo(resultInfo).build();
}
private EnsResponseVO make(Long intSendMastId) {
EnsResponseVO responseVO = intgrnNotiMaker.statBegin(intSendMastId);
private EnsResponseVO<?> make(Long intSendMastId) {
EnsResponseVO<?> responseVO = intgrnNotiMaker.statBegin(intSendMastId);
if (!EnsErrCd.OK.equals(responseVO.getErrCode()))
return responseVO;
@ -159,10 +168,10 @@ public class IntgrnNotiService {
* @return
*/
@Transactional(propagation = Propagation.SUPPORTS)
public EnsResponseVO sendBulk(Long intSendMastId) {
public EnsResponseVO<?> sendBulk(Long intSendMastId) {
try {
if (intgrnSendDetailRepository.findAllBySendTargetAndSendMast(IntgrnSendMast.builder().intSendMastId(intSendMastId).build()).size() < 1)
if (intgrnSendDetailRepository.findAllBySendTargetAndSendMast(IntgrnSendMast.builder().intSendMastId(intSendMastId).build()).isEmpty())
throw new EnsException(EnsErrCd.SEND404, "일치하는 자료가 없거나 전송 가능한 상태의 자료가 없습니다. (1회차:상태=makeok&try상태=stby&dtl상태=MAKING, 2~3회차:try상태:ok/fail&발송일시=기한경과&dtl상태=실패(ACPT_FAIL/FAIL/...)");
} catch (EnsException e) {
return EnsResponseVO.errBuilder()
@ -171,7 +180,7 @@ public class IntgrnNotiService {
.build();
}
List<Long> sendMastIds = Arrays.asList(intSendMastId);
List<Long> sendMastIds = Collections.singletonList(intSendMastId);
return this.send(sendMastIds);
@ -181,10 +190,10 @@ public class IntgrnNotiService {
* () -
*/
@Transactional(propagation = Propagation.SUPPORTS)
public EnsResponseVO sendBulkAll() {
public EnsResponseVO<?> sendBulkAll() {
List<Long> intSendMastIds = intgrnSendDetailRepository.findIntSendMastIdsBySendTarget();
if (intSendMastIds.size() < 1)
if (intSendMastIds.isEmpty())
return EnsResponseVO.errBuilder()
.errCode(EnsErrCd.SEND404)
.errMsg("전송 타깃 데이터가 없습니다.")
@ -193,13 +202,10 @@ public class IntgrnNotiService {
return this.send(intSendMastIds);
}
private EnsResponseVO send(List<Long> intSendMastIds) {
List<EnsResponseVO> resultInfo = intSendMastIds.stream()
.map(intSendMastId -> {
intgrnNotiSender.statBegin(intSendMastId);
return intSendMastId;
})
.map(intSendMastId -> intgrnNotiSender.execute(intSendMastId))
private EnsResponseVO<?> send(List<Long> intSendMastIds) {
val resultInfo = intSendMastIds.stream()
.peek(intgrnNotiSender::statBegin)
.map(intgrnNotiSender::execute)
.collect(Collectors.toList());
@ -211,18 +217,18 @@ public class IntgrnNotiService {
* (/)
*/
@Transactional(propagation = Propagation.SUPPORTS)
public EnsResponseVO statBulk(Long intSendMastId) {
public EnsResponseVO<?> statBulk(Long intSendMastId) {
IntgrnSendMast intgrnSendMast = null;
try {
intgrnSendMast = intgrnSendMastRepository.findById(intSendMastId)
.orElseThrow(() -> new EnsException(EnsErrCd.ERR404, String.format("[ intSendMastId %s ]와 일치하는 자료가 없습니다.", intSendMastId)));
int validCnt = 0;
IntgrnSendMast finalIntgrnSendMast = intgrnSendMast;
if (!Arrays.asList(StatCd.sendok, StatCd.sendcmplt, StatCd.open).stream()
.anyMatch(statCd -> statCd.equals(finalIntgrnSendMast.getStatCd())))
if (Stream.of(StatCd.sendok, StatCd.sendcmplt, StatCd.open)
.noneMatch(statCd -> statCd.equals(finalIntgrnSendMast.getStatCd())))
validCnt++;
if (!Arrays.asList(TryStatCd.sndRsrv, TryStatCd.sndRtme).stream()
.anyMatch(statCd -> statCd.equals(finalIntgrnSendMast.getTryStatCd())))
if (Stream.of(TryStatCd.sndRsrv, TryStatCd.sndRtme)
.noneMatch(statCd -> statCd.equals(finalIntgrnSendMast.getTryStatCd())))
validCnt++;
if (validCnt == 2)
throw new EnsException(EnsErrCd.RSLT404, "\"진행상태\"가 전송성공/전송완료/열람중(sendok/sendcmplt/open) 또는 \"현재 회차상태\"가 예약전송/실시간전송(sndRsrv/sndRtme) 상태가 아닙니다.");
@ -233,17 +239,17 @@ public class IntgrnNotiService {
.build();
}
return this.stat(Arrays.asList(intgrnSendMast));
return this.stat(Collections.singletonList(intgrnSendMast));
}
/**
* (/)
*/
@Transactional(propagation = Propagation.SUPPORTS)
public EnsResponseVO statBulkAll() {
public EnsResponseVO<?> statBulkAll() {
// List<IntgrnSendMast> intgrnSendMasts = intgrnSendMastRepository.findAllByStatCdIn(Arrays.asList(StatCd.sendok, StatCd.sendcmplt, StatCd.open));
List<IntgrnSendMast> intgrnSendMasts = intgrnSendMastRepository.findAllByStatCdInOrTryStatCdIn(Arrays.asList(StatCd.sendok, StatCd.sendcmplt, StatCd.open), Arrays.asList(TryStatCd.sndRsrv, TryStatCd.sndRtme));
if (intgrnSendMasts.size() < 1)
if (intgrnSendMasts.isEmpty())
return EnsResponseVO.errBuilder()
.errCode(EnsErrCd.RSLT404)
// .errMsg("\"전송성공/전송완료/열람중(sendok/sendcmplt/open)\" 상태인 자료가 없습니다")
@ -253,8 +259,8 @@ public class IntgrnNotiService {
return this.stat(intgrnSendMasts);
}
private EnsResponseVO stat(List<IntgrnSendMast> intgrnSendMasts) {
List<EnsResponseVO> resultInfo = intgrnSendMasts.stream()
private EnsResponseVO<?> stat(List<IntgrnSendMast> intgrnSendMasts) {
val resultInfo = intgrnSendMasts.stream()
.map(data -> intgrnNotiRsltFetcher.execute(data.getIntSendMastId()))
.collect(Collectors.toList());
@ -268,7 +274,7 @@ public class IntgrnNotiService {
* @return
*/
@Transactional(propagation = Propagation.SUPPORTS)
public EnsResponseVO sendResultProvide(Long intSendMastId) {
public EnsResponseVO<?> sendResultProvide(Long intSendMastId) {
return intgrnNotiRsltProvider.execute(intSendMastId);
}

@ -1,5 +1,14 @@
package cokr.xit.ens.modules.common.ctgy.intgrnnoti.service.support;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import cokr.xit.ens.core.aop.EnsResponseVO;
import cokr.xit.ens.core.exception.EnsException;
import cokr.xit.ens.core.exception.code.EnsErrCd;
@ -20,15 +29,8 @@ import cokr.xit.ens.modules.common.domain.support.FieldError;
import cokr.xit.ens.modules.common.monitor.MessageByPhase;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
// TODO: Make
@Slf4j
@Component
@RequiredArgsConstructor

@ -1,5 +1,13 @@
package cokr.xit.ens.modules.common.ctgy.intgrnnoti.service.support;
import java.util.Arrays;
import java.util.List;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import cokr.xit.ens.core.aop.EnsResponseVO;
import cokr.xit.ens.core.exception.EnsException;
import cokr.xit.ens.core.exception.code.EnsErrCd;
@ -13,14 +21,8 @@ import cokr.xit.ens.modules.common.ctgy.intgrnnoti.domain.repository.IntgrnSendD
import cokr.xit.ens.modules.common.ctgy.intgrnnoti.domain.repository.IntgrnSendMastRepository;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.List;
// TODO: Send
@Slf4j
@Component
@RequiredArgsConstructor
@ -76,18 +78,18 @@ public class IntgrnNotiSender extends SendProcTemplate {
intgrnSendMast = intgrnSendMastRepository.findById(intSendMastId).orElseThrow(() -> new EnsException(EnsErrCd.SEND404, String.format("일치하는 발송마스터 자료가 없습니다. [ intSendMastId %s ]", intSendMastId)));
intgrnSendDetails = intgrnSendDetailRepository.findAllBySendTargetAndSendMastAndTryStatCdIn(intgrnSendMast, Arrays.asList(TryStatCd.start));
if (intgrnSendDetails.size() < 1)
if (intgrnSendDetails.isEmpty())
throw new EnsException(EnsErrCd.SEND500, "조회된 발송상세 자료가 없음.");
PostSeCd postSeCd = null;
final int currentTryNum = intgrnSendMast.getTrySeq() + 1;
final boolean isReserve = currentTryNum == 1 ? true : false;
final boolean isReserve = currentTryNum == 1;
final TryStatCd tryStatCd = currentTryNum == 1 ? TryStatCd.sndRsrv : TryStatCd.sndRtme;
if (currentTryNum == 1) postSeCd = intgrnSendMast.getTry1();
else if (currentTryNum == 2) postSeCd = intgrnSendMast.getTry2();
else if (currentTryNum == 3) postSeCd = intgrnSendMast.getTry3();
AcceptDataFactory makerFactory = new AcceptDataMakerFactory(intgrnSendMast, intgrnSendDetails, isReserve);
AcceptDataFactory<AcceptData<?>> makerFactory = new AcceptDataMakerFactory(intgrnSendMast, intgrnSendDetails, isReserve);
applicationEventPublisher.publishEvent(makerFactory.get(postSeCd));

@ -1,4 +1,7 @@
mybatis:
mapper-locations: mybatis-mapper/**/*.xml
configuration:
map-underscore-to-camel-case: true
config-location: classpath:mybatis-mapper/mybatis-config.xml
mapper-locations:
- classpath:mybatis-mapper/**/*Mapper.xml
- classpath:mybatis-mapper/**/*-mapper.xml
# configuration:
# map-underscore-to-camel-case: true

Loading…
Cancel
Save