Merge branch 'sb'

This commit is contained in:
2026-07-31 16:30:38 +09:00
8 changed files with 60 additions and 13 deletions
@@ -12,7 +12,7 @@ public class ChgrResponseDto {
private String chgrId;
private String chgrNm;
private String speedTp;
private String chgrTp;
private String chgrType;
private double gpsXpos;
private double gpsYpos;
private String locInfo;
@@ -29,7 +29,7 @@ public class ChgrResponseDto {
chgr.setStNm(this.stNm);
chgr.setChgrNm(this.chgrNm);
chgr.setSpeedTp(this.speedTp);
chgr.setChgrTp(this.chgrTp);
chgr.setChgrTp(this.chgrType);
return chgr;
}
}
@@ -22,6 +22,9 @@ public class ChgrHist extends BaseStEntity {
@Column(name = "CHGR_ID", nullable = false)
private String chgrId; // 충전기 id
@Column(name = "CH_ID")
private Integer chId;
@Column(name = "ST_ID", nullable = false)
private String stId; // 충전소 id
@@ -23,6 +23,7 @@ public class ChgrHistController extends BaseController<ChgrHist,Integer,ChgrHist
@GetMapping("list")
public String list() throws IllegalAccessException {
chgrHistService.getChgrHist();
return path+"list";
}
@@ -5,4 +5,5 @@ import org.springframework.stereotype.Repository;
@Repository
public interface ChgrHistRepository extends BaseRecStRepository<ChgrHist,Integer> {
boolean existsByChgrIdAndChIdAndRechgEDt(String chgrId, Integer chId,String rechgEDt);
}
@@ -52,6 +52,7 @@ public class ChgrHistResponseDto {
chgrHist.setRechgAmt(this.rechgAmt);
chgrHist.setPayFnsh(this.payFnsh);
chgrHist.setRechGwh(this.rechgWh);
chgrHist.setChId(this.chId);
return chgrHist;
}
}
@@ -30,7 +30,7 @@ public class ChgrHistService extends BaseService<ChgrHist, Integer, ChgrHistRepo
@Transactional
@Scheduled(cron = "0 */10 * * * *")
public void getChgrHist() throws IllegalAccessException {
public void getChgrHist() {
String startDt = LocalDate.now().toString();
ApiResponse<List<ChgrHistResponseDto>> response = apiClient.fetchChgrHist(startDt, "50");
@@ -50,15 +50,18 @@ public class ChgrHistService extends BaseService<ChgrHist, Integer, ChgrHistRepo
.map(ChgrHistResponseDto::toEntity)
.toList();
int insertCount = 0;
for (ChgrHist h : entityList) {
Integer id = BaseService.getId(h);
if (id != null && super.repository.existsById(id)) {
super.update(h);
} else {
boolean isExist = ((ChgrHistRepository) super.repository).existsByChgrIdAndChIdAndRechgEDt(h.getChgrId(), h.getChId(),h.getRechgEDt());
if (!isExist) {
super.insert(h);
insertCount++;
}
}
log.info("충전이력 수집 완료: API 응답 {}건 중 신규 저장 {}건", entityList.size(), insertCount);
}
@Override
@@ -48,8 +48,32 @@ public class RatePlanService extends BaseService<RatePlan, Integer, RatePlanRepo
}
List<RatePlanResponseDto> dtoList = response.getData();
if (dtoList == null || dtoList.isEmpty()) {
log.info("가져온 요금제 데이터가 없습니다.");
if (dtoList == null) {
dtoList = new ArrayList<>();
}
Set<Integer> validApiIds = dtoList.stream()
.map(RatePlanResponseDto::getRatePlanId)
.collect(Collectors.toSet());
List<RatePlan> localRatePlans = ratePlanRepository.findAll();
int deleteCount = 0;
for (RatePlan localPlan : localRatePlans) {
if (!validApiIds.contains(localPlan.getRatePlanId())) {
Integer idToDelete = localPlan.getRatePlanId();
ratePlanDetailTimeRepository.deleteByRatePlanId(idToDelete);
chargerRatePlanRepository.deleteByRatePlanId(idToDelete);
ratePlanRepository.deleteById(idToDelete);
deleteCount++;
log.info("운영 DB에서 삭제된 요금제를 로컬 DB에서 제거했습니다. - ID: {}", idToDelete);
}
}
if (dtoList.isEmpty()) {
log.info("가져온 요금제 데이터가 없습니다. (로컬 동기화 및 삭제 완료. 삭제 건수: {})", deleteCount);
return;
}
@@ -104,8 +128,8 @@ public class RatePlanService extends BaseService<RatePlan, Integer, RatePlanRepo
chargerRatePlanRepository.saveAll(allChargerRatePlans);
}
log.info("요금제 동기화 완료: 마스터 {}건, 상세단가 {}건, 충전기매핑 {}건",
ratePlanEntities.size(), allDetailTimes.size(), allChargerRatePlans.size());
log.info("요금제 동기화 완료: 마스터 추가/수정 {}건, 삭제 {}건, 상세단가 {}건, 충전기매핑 {}건",
ratePlanEntities.size(), deleteCount, allDetailTimes.size(), allChargerRatePlans.size());
}
public RatePlanResponseDto getRatePlanDetail(Integer ratePlanId) {
@@ -60,15 +60,18 @@
if (strUtil.isNotEmpty($('#rechgEDtLike').val())) {d.rechgEDt = $('#rechgEDtLike').val();}
if (strUtil.isNotEmpty($('#rechgTimeLike').val())) {d.rechgTime = $('#rechgTimeLike').val();}
if (strUtil.isNotEmpty($('#payFnshLike').val())) {d.payFnsh = $('#payFnshLike').val();}
if (strUtil.isNotEmpty($('#chIdLike').val())) {d.chId = $('#chIdLike').val();}
return d;
},
{
order: [[0, 'desc']],
order: [[4, 'desc']],
columns: [
{title: "충전소 아이디", name: "ST_ID", data: "stId", className, orderable: false},
{title: "충전기 아이디", name: "CHGR_ID", data: "chgrId", className, orderable: false},
{title: "결제구분", name: "PAY_TP", data: "payTp", className, orderable: false},
{title: "충전기타입 코드", name: "CHGR_TP", data: "plugTp", className, orderable: false},
{title: "채널", name: "CH_ID", data: "chId", className, orderable: false},
{title: "충전기타입 코드", name: "PLUG_TP", data: "plugTp", className, orderable: false},
{title: "충전 시작일시", name: "RECHG_S_DT", data: "rechgSDt", className, orderable: false},
{title: "충전 종료일시", name: "RECHG_E_DT", data: "rechgEDt", className, orderable: false},
{title: "충전시간", name: "RECHG_TIME", data: "rechgTime", className, orderable: false},
@@ -134,6 +137,17 @@
minLen: 0,
maxLen: 50,
}),
new ModalInput({
inputType: ModalInputType.text,
inputId: "chId",
inputName: "chId",
inputLabel: "채널",
inputPlaceholder: "채널",
isReq: false,
isEnable: true,
minLen: 0,
maxLen: 50,
}),
new ModalInput({
inputType: ModalInputType.textarea,
inputId: "payTp",