diff --git a/src/main/java/net/jwsi/jcms/vpp/api/ApiClient.java b/src/main/java/net/jwsi/jcms/vpp/api/ApiClient.java index 5de7147..f8e6c81 100644 --- a/src/main/java/net/jwsi/jcms/vpp/api/ApiClient.java +++ b/src/main/java/net/jwsi/jcms/vpp/api/ApiClient.java @@ -5,6 +5,8 @@ import net.jwsi.jcms.vpp.chgr.ChgrResponseDto; import net.jwsi.jcms.vpp.chgrCurrState.ChgrCurrState; import net.jwsi.jcms.vpp.chgrHist.ChgrHistResponseDto; import net.jwsi.jcms.vpp.provider.ProviderDto; +import net.jwsi.jcms.vpp.rehchgingList.RechgingList; +import net.jwsi.jcms.vpp.rehchgingList.RechgingListDto; import net.jwsi.jcms.vpp.station.StationDto; import org.springframework.core.ParameterizedTypeReference; import org.springframework.stereotype.Component; @@ -64,4 +66,15 @@ public class ApiClient { .retrieve() .body(new ParameterizedTypeReference>>() {}); } + + public ApiResponse> fetchRechgingList() { + + return externalApiClient.post() + .uri("/api/charge/chargingInfo") + .body(Collections.emptyMap()) + .retrieve() + .body(new ParameterizedTypeReference>>() {}); + } + + } \ No newline at end of file diff --git a/src/main/java/net/jwsi/jcms/vpp/rehchgingList/RechgingList.java b/src/main/java/net/jwsi/jcms/vpp/rehchgingList/RechgingList.java new file mode 100644 index 0000000..962b40a --- /dev/null +++ b/src/main/java/net/jwsi/jcms/vpp/rehchgingList/RechgingList.java @@ -0,0 +1,82 @@ +package net.jwsi.jcms.vpp.rehchgingList; + +import jakarta.persistence.*; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import net.jwsi.jcms.base.BaseStEntity; + +@NoArgsConstructor +@Setter +@Getter +@ToString +@Entity(name = "vpp_rechging_list") +public class RechgingList extends BaseStEntity { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "RECHGING_LIST_ID") + private Long rechgingListId; + + @Column(name = "SEARCH_DT") + private String searchDt; + + @Column(name = "PROVIDER_ID") + private String providerId; + + @Column(name = "ST_ID") + private String stId; + + @Column(name = "CHGR_ID") + private String chgrId; + + @Column(name = "CH_ID") + private Integer chId; + + @Column(name = "PLUG_TYPE") + private String plugType; + + @Column(name = "MEM_AUTH_INPUT_NO") + private String memAuthInputNo; + + @Column(name = "CREDIT_P_PAY_TRX_NO") + private String creditPPayTrxNo; + + @Column(name = "CREDIT_P_PAY_TRX_DT") + private String creditPPayTrxDt; + + @Column(name = "RECHG_SDT") + private String rechgSdt; + + @Column(name = "RECHG_REMAIN_TIME") + private String rechgRemainTime; + + @Column(name = "RECHGING_WH") + private Integer rechgingWh; + + @Column(name = "RECHG_DEMAND_AMT") + private Integer rechgDemandAmt; + + @Column(name = "RECHGING_AMT") + private Integer rechgingAmt; + + @Column(name = "PAY_TYPE") + private String payType; + + @Column(name = "INTEGRATED_WH") + private Double integratedWh; + + @Column(name = "DC_POWER_WH") + private Double dcPowerWh; + + @Column(name = "AC_POWER_WH") + private Double AcPowerWh; + + @Column(name = "CURR_VOLT") + private Double currVolt; + + @Column(name = "CURR_C") + private Double currC; + + +} diff --git a/src/main/java/net/jwsi/jcms/vpp/rehchgingList/RechgingListController.java b/src/main/java/net/jwsi/jcms/vpp/rehchgingList/RechgingListController.java new file mode 100644 index 0000000..55a3067 --- /dev/null +++ b/src/main/java/net/jwsi/jcms/vpp/rehchgingList/RechgingListController.java @@ -0,0 +1,57 @@ +package net.jwsi.jcms.vpp.rehchgingList; + +import lombok.extern.slf4j.Slf4j; +import net.jwsi.jcms.base.BaseController; +import net.jwsi.jcms.exception.JsonDataException; +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.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +import java.util.List; +import java.util.Map; + +@Controller +@Slf4j +@RequestMapping("/cms/rechgingList") +public class RechgingListController extends BaseController { + + private final String path = "/system/rechgingList/"; + + private final RechgingListService rechgingListService; + + public RechgingListController(RechgingListService service, RechgingListService rechgingListService) { + super(service); + this.rechgingListService = rechgingListService; + } + + + @GetMapping("list") + public String list() throws IllegalAccessException { + return path + "list"; + } + + @PostMapping("list.json") + @ResponseBody + public Map list(RechgingList rechgingList) { + return svcSelectList(rechgingList); + } + + @PostMapping("view.json") + @ResponseBody + public Map viewData(RechgingList rechgingList) throws JsonDataException { + return svcSelectList(rechgingList); + } + + + @Override + protected void chkSelectList(List list) throws JsonDataException { + + } + + @Override + protected void chkSelect(RechgingList data) throws JsonDataException { + + } +} diff --git a/src/main/java/net/jwsi/jcms/vpp/rehchgingList/RechgingListDto.java b/src/main/java/net/jwsi/jcms/vpp/rehchgingList/RechgingListDto.java new file mode 100644 index 0000000..6289b9b --- /dev/null +++ b/src/main/java/net/jwsi/jcms/vpp/rehchgingList/RechgingListDto.java @@ -0,0 +1,59 @@ +package net.jwsi.jcms.vpp.rehchgingList; + +import lombok.*; + +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class RechgingListDto { + private Long rechgingListId; + private String searchDt; + private String providerId; + private String stId; + private String chgrId; + private Integer chId; + private String plugType; + private String memAuthInputNo; + private String creditPPayTrxNo; + private String creditPPayTrxDt; + private String rechgSdt; + private String rechgRemainTime; + private Integer rechgingWh; + private Integer rechgDemandAmt; + private Integer rechgingAmt; + private String payType; + private Double integratedWh; + private Double dcPowerWh; + private Double acPowerWh; + private Double currVolt; + private Double currC; + + public RechgingList toEntity() { + RechgingList rechgingList = new RechgingList(); + rechgingList.setRechgingListId(this.rechgingListId); + rechgingList.setSearchDt(this.searchDt); + rechgingList.setProviderId(this.providerId); + rechgingList.setStId(this.stId); + rechgingList.setChgrId(this.chgrId); + rechgingList.setChId(this.chId); + rechgingList.setPlugType(this.plugType); + rechgingList.setMemAuthInputNo(this.memAuthInputNo); + rechgingList.setCreditPPayTrxNo(this.creditPPayTrxNo); + rechgingList.setCreditPPayTrxDt(this.creditPPayTrxDt); + rechgingList.setRechgSdt(this.rechgSdt); + rechgingList.setRechgRemainTime(this.rechgRemainTime); + rechgingList.setRechgingWh(this.rechgingWh); + rechgingList.setRechgDemandAmt(this.rechgDemandAmt); + rechgingList.setRechgingAmt(this.rechgingAmt); + rechgingList.setPayType(this.payType); + rechgingList.setIntegratedWh(this.integratedWh); + rechgingList.setDcPowerWh(this.dcPowerWh); + rechgingList.setAcPowerWh(this.acPowerWh); + rechgingList.setCurrVolt(this.currVolt); + rechgingList.setCurrC(this.currC); + return rechgingList; + } + +} diff --git a/src/main/java/net/jwsi/jcms/vpp/rehchgingList/RechgingListRepository.java b/src/main/java/net/jwsi/jcms/vpp/rehchgingList/RechgingListRepository.java new file mode 100644 index 0000000..dcdd23b --- /dev/null +++ b/src/main/java/net/jwsi/jcms/vpp/rehchgingList/RechgingListRepository.java @@ -0,0 +1,8 @@ +package net.jwsi.jcms.vpp.rehchgingList; + +import net.jwsi.jcms.base.BaseRecStRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface RechgingListRepository extends BaseRecStRepository { +} diff --git a/src/main/java/net/jwsi/jcms/vpp/rehchgingList/RechgingListService.java b/src/main/java/net/jwsi/jcms/vpp/rehchgingList/RechgingListService.java new file mode 100644 index 0000000..d5fa2b7 --- /dev/null +++ b/src/main/java/net/jwsi/jcms/vpp/rehchgingList/RechgingListService.java @@ -0,0 +1,99 @@ +package net.jwsi.jcms.vpp.rehchgingList; + +import jakarta.transaction.Transactional; +import lombok.extern.slf4j.Slf4j; +import net.jwsi.jcms.base.BaseService; +import net.jwsi.jcms.base.EnumSqlType; +import net.jwsi.jcms.utils.HttpUtil; +import net.jwsi.jcms.utils.LoginUtil; +import net.jwsi.jcms.vpp.api.ApiClient; +import net.jwsi.jcms.vpp.api.ApiResponse; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.domain.Page; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +@Slf4j +@Service +public class RechgingListService extends BaseService { + + private final ApiClient apiClient; + + public RechgingListService(RechgingListRepository repository, ApiClient apiClient) { + super(repository); + this.apiClient = apiClient; + } + + @Transactional + @Scheduled(cron = "0 0 0 * * *") + public void getRechgingList() { + ApiResponse> response = apiClient.fetchRechgingList(); + + if (response == null || !Integer.valueOf(200).equals(response.getCode())) { + String msg =(response != null) ? response.getMessage() : "응답 없음"; + throw new RuntimeException("API 호출 실패: " + msg); + } + + List dtoList = response.getData(); + if (dtoList == null || dtoList.isEmpty()) { + log.info("가져온 충전중 데이터가 없습니다."); + } + + List entityList = dtoList.stream() + .map(RechgingListDto::toEntity) + .collect(Collectors.toList()); + + List savedRechgingList = super.repository.saveAll(entityList); + + log.info("총 {}건의 충전중 데이터가 DB에 동기화되었습니다.",savedRechgingList.size()); + + + } + + + @Override + protected Integer getUserId() { + return HttpUtil.getUserId(); + } + + @Override + protected String getUserName(Integer id) { + return LoginUtil.getUserName(id); + } + + @Override + protected RechgingList newSearchParam(RechgingList rechgingList) { + if (rechgingList == null) { + rechgingList = new RechgingList(); + } + return rechgingList; + } + + @Override + protected EnumSqlType useSqlTyp() { + return EnumSqlType.SPECIFICATION; + } + + @Override + protected Specification getSpecification(RechgingList srch) { + if (srch == null) return null; + Specification rst = null; + rst = addWhere(rst, srch.getRechgingListId(), RechgingListSpecification.rechgingListId(srch.getRechgingListId())); + return rst; + } + + @Override + protected Page _selectPage(RechgingList rechgingList) { + return null; + } + + @Override + protected List _selectList(RechgingList rechgingList) { + return null; + } +} diff --git a/src/main/java/net/jwsi/jcms/vpp/rehchgingList/RechgingListSpecification.java b/src/main/java/net/jwsi/jcms/vpp/rehchgingList/RechgingListSpecification.java new file mode 100644 index 0000000..178572a --- /dev/null +++ b/src/main/java/net/jwsi/jcms/vpp/rehchgingList/RechgingListSpecification.java @@ -0,0 +1,11 @@ +package net.jwsi.jcms.vpp.rehchgingList; + +import org.springframework.data.jpa.domain.Specification; + +public class RechgingListSpecification { + + public static Specification rechgingListId(Long rechgingListId) { + return (root, query, criteriaBuilder) -> criteriaBuilder.equal(root.get("rechgingListId"), rechgingListId); + } + +} diff --git a/src/main/resources/templates/system/rechgingList/list.html b/src/main/resources/templates/system/rechgingList/list.html new file mode 100644 index 0000000..74dbfa5 --- /dev/null +++ b/src/main/resources/templates/system/rechgingList/list.html @@ -0,0 +1,419 @@ + + + +
+
+
+
+
+
+
+ 요청 일시 + +
+
+
+
+ 충전사업자 ID + +
+
+
+
+ 충전소 ID + +
+
+
+
+ 충전기 ID + +
+
+
+
+ 플러그 타입 + +
+
+
+
+ 회원카드번호 + +
+
+
+
+ 선결제 관련 신용카드 승인번호 + +
+
+
+
+ 선결제 관련 신용카드 승인일시 + +
+
+
+
+ 충전 시작일시 + +
+
+
+
+ 충전 잔여 시간 + +
+
+
+
+ 결제타입 + +
+
+
+
+
+
+
+ + + + + +
+
+
+
+
+ +
+
+
+
+
+
+
+ +
+ +