소스정리

This commit is contained in:
2026-07-29 10:24:43 +09:00
parent 938fae0359
commit 290928a839
9 changed files with 328 additions and 16 deletions
Binary file not shown.
Binary file not shown.
@@ -1,7 +1,7 @@
package net.jwsi.jcms.vpp.api; package net.jwsi.jcms.vpp.api;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import net.jwsi.jcms.vpp.charger.Chgr; import net.jwsi.jcms.vpp.charger.ChgrResponseDto;
import net.jwsi.jcms.vpp.provider.ProviderDto; import net.jwsi.jcms.vpp.provider.ProviderDto;
import net.jwsi.jcms.vpp.station.StationDto; import net.jwsi.jcms.vpp.station.StationDto;
import org.springframework.core.ParameterizedTypeReference; import org.springframework.core.ParameterizedTypeReference;
@@ -46,16 +46,17 @@ public class ApiClient {
.body(new ParameterizedTypeReference<ApiResponse<List<ProviderDto>>>() {}); .body(new ParameterizedTypeReference<ApiResponse<List<ProviderDto>>>() {});
} }
public ApiResponse<List<Chgr>> fetchChgr(String baseUrl, String token) { public ApiResponse<List<ChgrResponseDto>> fetchChgr(String baseUrl, String token) {
URI uri = UriComponentsBuilder.fromUriString(baseUrl) URI uri = UriComponentsBuilder.fromUriString(baseUrl)
.path("/api/charge/list") .path("/api/charger/list")
.build() .build()
.toUri(); .toUri();
return restClient.post() return restClient.post()
.uri(uri) .uri(uri)
.header("Authorization", "Bearer " + token) .header("Authorization", "Bearer " + token)
.body(Collections.emptyMap())
.retrieve() .retrieve()
.body(new ParameterizedTypeReference<ApiResponse<List<Chgr>>>() {}); .body(new ParameterizedTypeReference<ApiResponse<List<ChgrResponseDto>>>() {});
} }
} }
@@ -1,5 +1,6 @@
package net.jwsi.jcms.vpp.charger; package net.jwsi.jcms.vpp.charger;
import jakarta.persistence.Column;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
import jakarta.persistence.Id; import jakarta.persistence.Id;
import lombok.Getter; import lombok.Getter;
@@ -15,13 +16,15 @@ import net.jwsi.jcms.base.BaseStEntity;
@Entity(name = "vpp_chgr") @Entity(name = "vpp_chgr")
public class Chgr extends BaseStEntity { public class Chgr extends BaseStEntity {
@Id @Id
@Column(name = "CHGR_ID")
private String chgrId; //충전기 id(pk) private String chgrId; //충전기 id(pk)
@Column(name = "PROVIDER_ID")
private String providerId; //충전사업자 id(pk) @Id private String providerId; //충전사업자 id(pk) @Id
private String stId; //충전소 id(pk) @Id private String stId; //충전소 id(pk) @Id
private String stNm; //충전소 명 private String stNm; //충전소 명
private String chgrNm; //충전기 명 private String chgrNm; //충전기 명
private String speedTpCd; //충전기속도 코드 private String speedTp; //충전기속도 코드
private String chgrTypeCd; //충전기타입 코드 private String chgrTp; //충전기타입 코드
} }
@@ -1,16 +1,62 @@
package net.jwsi.jcms.vpp.charger; package net.jwsi.jcms.vpp.charger;
import lombok.extern.slf4j.Slf4j;
import net.jwsi.jcms.base.BaseController; import net.jwsi.jcms.base.BaseController;
import net.jwsi.jcms.exception.JsonDataException; import net.jwsi.jcms.exception.JsonDataException;
import org.springframework.stereotype.Controller; 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.List;
import java.util.Map;
@Controller @Controller
@Slf4j
@RequestMapping("/cms/chgr")
public class ChgrController extends BaseController<Chgr,String,ChgrRepository,ChgrService> { public class ChgrController extends BaseController<Chgr,String,ChgrRepository,ChgrService> {
private final String path = "/system/chgr/";
public ChgrController(ChgrService service) { private final ChgrService chgrService;
public ChgrController(ChgrService service, ChgrService chgrService) {
super(service); super(service);
this.chgrService = chgrService;
}
@GetMapping("list")
public String list(){
return path+"list";
}
@PostMapping("list.json")
@ResponseBody
public Map<String,Object> list(Chgr chgr){
return svcSelectList(chgr);
}
@PostMapping("view.json")
@ResponseBody
public Map<String, Object> viewData(Chgr chgr) throws JsonDataException {
return svcSelectOne(chgr);
}
@PostMapping("insert.json")
@ResponseBody
public Map<String, Object> insert(Chgr chgr) throws JsonDataException {
return svcInsert(chgr);
}
@PostMapping("update.json")
@ResponseBody
public Map<String, Object> update(Chgr chgr) throws JsonDataException {
return svcUpdate(chgr);
}
@PostMapping("delete.json")
@ResponseBody
public Map<String, Object> delete(Chgr chgr) throws JsonDataException {
return svcDelete(chgr.getChgrId());
} }
@Override @Override
@@ -5,14 +5,14 @@ import lombok.Setter;
@Getter @Getter
@Setter @Setter
public class ResponseDto { public class ChgrResponseDto {
private String providerId; private String providerId;
private String stId; private String stId;
private String stNm; private String stNm;
private String chgrId; private String chgrId;
private String chgrNm; private String chgrNm;
private String speedTp; private String speedTp;
private String chgrType; private String chgrTp;
private double gpsXpos; private double gpsXpos;
private double gpsYpos; private double gpsYpos;
private String locInfo; private String locInfo;
@@ -24,11 +24,12 @@ public class ResponseDto {
public Chgr toEntity(){ public Chgr toEntity(){
Chgr chgr = new Chgr(); Chgr chgr = new Chgr();
chgr.setChgrId(this.chgrId); chgr.setChgrId(this.chgrId);
chgr.setProviderId(this.providerId);
chgr.setStId(this.stId); chgr.setStId(this.stId);
chgr.setStNm(this.stNm); chgr.setStNm(this.stNm);
chgr.setChgrNm(this.chgrNm); chgr.setChgrNm(this.chgrNm);
chgr.setSpeedTpCd(this.speedTp); chgr.setSpeedTp(this.speedTp);
chgr.setChgrTypeCd(this.chgrType); chgr.setChgrTp(this.chgrTp);
return chgr; return chgr;
} }
} }
@@ -1,17 +1,22 @@
package net.jwsi.jcms.vpp.charger; package net.jwsi.jcms.vpp.charger;
import jakarta.transaction.Transactional;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.jwsi.jcms.base.BaseService; import net.jwsi.jcms.base.BaseService;
import net.jwsi.jcms.base.EnumSqlType; import net.jwsi.jcms.base.EnumSqlType;
import net.jwsi.jcms.utils.HttpUtil; import net.jwsi.jcms.utils.HttpUtil;
import net.jwsi.jcms.utils.LoginUtil; import net.jwsi.jcms.utils.LoginUtil;
import net.jwsi.jcms.vpp.api.ApiClient; import net.jwsi.jcms.vpp.api.ApiClient;
import net.jwsi.jcms.vpp.api.ApiResponse;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.jpa.domain.Specification; import org.springframework.data.jpa.domain.Specification;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
@Service @Service
@Slf4j @Slf4j
public class ChgrService extends BaseService<Chgr,String,ChgrRepository> { public class ChgrService extends BaseService<Chgr,String,ChgrRepository> {
@@ -26,7 +31,30 @@ public class ChgrService extends BaseService<Chgr,String,ChgrRepository> {
super(repository); super(repository);
this.apiClient = apiClient; this.apiClient = apiClient;
} }
@Transactional
@Scheduled(cron = "0 0 0 * * *")
public void getCharger() {
ApiResponse<List<ChgrResponseDto>> response = apiClient.fetchChgr(baseUrl, apiToken);
if (response == null || !Integer.valueOf(200).equals(response.getCode())) {
String msg = (response != null) ? response.getMessage() : "응답 없음";
throw new RuntimeException("API 호출 실패: " + msg);
}
List<ChgrResponseDto> dtoList = response.getData();
if (dtoList == null || dtoList.isEmpty()) {
log.info("가져온 충전소 데이터가 없습니다.");
}
List<Chgr> entityList = dtoList.stream()
.map(ChgrResponseDto::toEntity)
.collect(Collectors.toList());
List<Chgr> savedStations = super.repository.saveAll(entityList);
log.info("총 {}건의 충전소 데이터가 DB에 동기화되었습니다.", savedStations.size());
}
@Override @Override
protected Integer getUserId() { protected Integer getUserId() {
@@ -15,7 +15,7 @@ import net.jwsi.jcms.base.BaseStEntity;
public class Station extends BaseStEntity { public class Station extends BaseStEntity {
@Id @Id
@Column(name = "st_id") @Column(name = "ST_ID")
private String stationId; private String stationId;
@Column(name = "PROVIDER_ID") @Column(name = "PROVIDER_ID")
@@ -36,19 +36,19 @@ public class Station extends BaseStEntity {
@Column(name = "ADDR_LD_D") @Column(name = "ADDR_LD_D")
private String addrLdD; private String addrLdD;
@Column(name = "st_facil_tp_cd") @Column(name = "ST_FACIL_TP_CD")
private String stFacilTpCd; private String stFacilTpCd;
@Column(name = "st_facil_d_tp_cd") @Column(name = "ST_FACIL_D_TP_CD")
private String stFacilDTpCd; private String stFacilDTpCd;
@Column(name = "parking_fee_yn") @Column(name = "PARKING_FEE_YN")
private String parkingFeeYn; private String parkingFeeYn;
@Column(name = "PARKING_FEE_DETL") @Column(name = "PARKING_FEE_DETL")
private String parkingFeeDetl; private String parkingFeeDetl;
@Column(name = "pnu_no") @Column(name = "PNU_NO")
private String pnuNo; private String pnuNo;
@Column(name = "PNU_DO_NM") @Column(name = "PNU_DO_NM")
@@ -0,0 +1,233 @@
<!DOCTYPE html>
<html xmlns:th="http://thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{layout/cmsLayout}">
<body>
<section layout:fragment="Content">
<div class="w-100" style="margin-bottom: .3rem;">
<div th:replace="~{common/fragments/searchBox :: SearchBoxFragment(~{ :: #searchBoxContent}, ~{ :: #searchBoxFooter})}">
<div id="searchBoxContent">
<div class="row px-2">
<div class="col-lg-4 col-sm-6 col-xs-12 pb-1">
<div class="input-group">
<span class="input-group-text" style="width:140px">충전사업자 ID</span>
<input type="text" id="providerIdLike" name="providerIdLike" class="form-control" placeholder="충전사업자 ID 입력" maxlength="50">
</div>
</div>
<div class="col-lg-4 col-sm-6 col-xs-12 pb-1">
<div class="input-group">
<span class="input-group-text" style="width:140px">충전소 ID</span>
<input type="text" id="stIdLike" name="stIdLike" class="form-control" placeholder="충전소 ID 입력" maxlength="50">
</div>
</div>
<div class="col-lg-4 col-sm-6 col-xs-12 pb-1">
<div class="input-group">
<span class="input-group-text" style="width:140px">충전기 ID</span>
<input type="text" id="chgrIdLike" name="chgrIdLike" class="form-control" placeholder="충전기 ID 입력" maxlength="50">
</div>
</div>
<div class="col-lg-4 col-sm-6 col-xs-12 pb-1">
<div class="input-group">
<span class="input-group-text" style="width:140px">충전소 명</span>
<input type="text" id="stNmLike" name="stNmLike" class="form-control" placeholder="충전소 명 입력" maxlength="50">
</div>
</div>
<div class="col-lg-4 col-sm-6 col-xs-12 pb-1">
<div class="input-group">
<span class="input-group-text" style="width:140px">충전기 명</span>
<input type="text" id="chgrNmLike" name="chgrNmLike" class="form-control" placeholder="충전기 명 입력" maxlength="50">
</div>
</div>
<div class="col-lg-4 col-sm-6 col-xs-12 pb-1">
<div class="input-group">
<span class="input-group-text" style="width:140px">충전기속도</span>
<input type="text" id="speedTpLike" name="speedTpLike" class="form-control" placeholder="충전기속도 입력" maxlength="50">
</div>
</div>
<div class="col-lg-4 col-sm-6 col-xs-12 pb-1">
<div class="input-group">
<span class="input-group-text" style="width:140px">충전기타입</span>
<input type="text" id="chgrTpLike" name="chgrTpLike" class="form-control" placeholder="충전기타입 입력" maxlength="50">
</div>
</div>
</div>
</div>
<div id="searchBoxFooter">
<div class="row float-end">
<div class="col-xs-12 ">
<button type="button" class="btn btn-sm btn-info" id="searchBtn">검색</button>
<button type="button" class="btn btn-sm btn-info" id="resetBtn">리셋</button>
<button type="button" class="btn btn-sm btn-primary pl-2" onclick="showModal(ModalMode.REGISTER, {}, '');">등록</button>
</th:block>
</div>
</div>
</div>
</div>
</div>
<div class="w-100">
<div class="box box-primary">
<div class="form">
<table id="datatable" class="table table-striped table-hover dataTable" style="width:100%;"></table>
</div>
</div>
</div>
<script th:inline="none">
const rootPath = "/cms/chgr/";
let datatable;
$(document).ready(function() {
const className = "dt-head-center dt-body-center";
datatable = newDataTable(
"#datatable",
rootPath + "list.json",
function(d) {
if (strUtil.isNotEmpty($('#providerIdLike').val())) {d.providerId = $('#providerIdLike').val();}
if (strUtil.isNotEmpty($('#stIdLike').val())) {d.stId = $('#stIdLike').val();}
if (strUtil.isNotEmpty($('#chgrIdLike').val())) {d.chgrId = $('#chgrIdLike').val();}
if (strUtil.isNotEmpty($('#stNmLike').val())) {d.stNm = $('#stNmLike').val();}
if (strUtil.isNotEmpty($('#chgrNmLike').val())) {d.chgrNm = $('#chgrNmLike').val();}
if (strUtil.isNotEmpty($('#speedTpLike').val())) {d.speedTp = $('#speedTpLike').val();}
if (strUtil.isNotEmpty($('#chgrTpLike').val())) {d.chgrTp = $('#chgrTpLike').val();}
return d;
},
{
order: [],
columns: [
{title: "충전사업자 ID", name: "provider_id", data: "providerId", className},
{title: "충전소 ID", name: "st_id", data: "stId", className},
{title: "충전기 ID", name: "chgr_id", data: "chgrId", className},
{title: "충전소 명", name: "st_nm", data: "stNm", className, orderable: false},
{title: "충전기 명", name: "chgr_nm", data: "chgrNm", className, orderable: false},
{title: "충전기속도", name: "speed_tp", data: "speedTp", className, orderable: false},
{title: "충전기타입", name: "chgr_tp", data: "chgrTp", className, orderable: false},
{title: "기능", orderable:false, width:"110px",
render: (data, type, row) => {
return mkRowDataFunctions({providerId: row['providerId'], stId: row['stId'], chgrId: row['chgrId']}, row['chgrNm'], true, menuRoleModify, menuRoleDel);
}
}
],
allCheck: false,
});
});
const showModal = (mode, ids, title) => {
if(!checkRole(mode)) { alert("권한이 없습니다."); return; }
let modalInputArray = [
new ModalInput({
inputType: ModalInputType.text,
inputId: "providerId",
inputName: "providerId",
hasOldPk: true,
inputLabel: "충전사업자 ID",
inputPlaceholder: "충전사업자 ID",
isReq: false,
isEnable: true,
minLen: 0,
maxLen: 20,
}),
new ModalInput({
inputType: ModalInputType.text,
inputId: "stId",
inputName: "stId",
hasOldPk: true,
inputLabel: "충전소 ID",
inputPlaceholder: "충전소 ID",
isReq: false,
isEnable: true,
minLen: 0,
maxLen: 20,
}),
new ModalInput({
inputType: ModalInputType.text,
inputId: "chgrId",
inputName: "chgrId",
hasOldPk: true,
inputLabel: "충전기 ID",
inputPlaceholder: "충전기 ID",
isReq: false,
isEnable: true,
minLen: 0,
maxLen: 20,
}),
new ModalInput({
inputType: ModalInputType.text,
inputId: "stNm",
inputName: "stNm",
inputLabel: "충전소 명",
inputPlaceholder: "충전소 명",
isReq: false,
isEnable: true,
minLen: 0,
maxLen: 50,
}),
new ModalInput({
inputType: ModalInputType.text,
inputId: "chgrNm",
inputName: "chgrNm",
inputLabel: "충전기 명",
inputPlaceholder: "충전기 명",
isReq: false,
isEnable: true,
minLen: 0,
maxLen: 50,
}),
new ModalInput({
inputType: ModalInputType.text,
inputId: "speedTp",
inputName: "speedTp",
inputLabel: "충전기속도",
inputPlaceholder: "충전기속도",
isReq: false,
isEnable: true,
minLen: 0,
maxLen: 250,
}),
new ModalInput({
inputType: ModalInputType.text,
inputId: "chgrTp",
inputName: "chgrTp",
inputLabel: "충전기타입",
inputPlaceholder: "충전기타입",
isReq: false,
isEnable: true,
minLen: 0,
maxLen: 250,
})
];
if(!rootPath){ alert("rootPath를 지정하십시요."); return; }
const insertUrl = rootPath+"insert.json";
const updateUrl = rootPath+"update.json";
const loadUrl = rootPath+"view.json";
const deleteUrl = rootPath+"delete.json";
const modalWidth = 500;
const labelWidth = '90px';
if(mode === ModalMode.REGISTER) {
newModal(new ModalInfo({modalTitle: "등록", inputArray: modalInputArray, modalWidth}), mode, 'main', {insertUrl, labelWidth, callBack: () => { defaultCallback(); }})
} else if(mode===ModalMode.VIEW || mode===ModalMode.VIEW_ONLY || mode===ModalMode.MODIFY) {
newModal(new ModalInfo({modalTitle: "상세정보", inputArray: modalInputArray, modalWidth}), mode, 'main', {loadUrl, updateUrl, ids, labelWidth, callBack: () => { defaultCallback(); }})
} else if(mode === ModalMode.DELETE) {
newDelete(deleteUrl, ids, title, () => { defaultCallback(); });
}
const defaultCallback = () => {
datatable.ajax.reload();
}
};
$("#searchBtn").click(function() {
datatable.ajax.reload();
});
$("#resetBtn").click(function() {
$("#providerIdLike").val("");
$("#stIdLike").val("");
$("#chgrIdLike").val("");
$("#stNmLike").val("");
$("#chgrNmLike").val("");
$("#speedTpLike").val("");
$("#chgrTpLike").val("");
datatable.ajax.reload();
});
</script>
</section>
</body>
</html>