|
@@ -2,16 +2,16 @@ package com.its.op.service.its.code;
|
|
|
|
|
|
import com.its.op.dao.repository.its.code.TbSectGradStupRepository;
|
|
import com.its.op.dao.repository.its.code.TbSectGradStupRepository;
|
|
import com.its.op.dto.its.code.TbCmtrGradClsfDto;
|
|
import com.its.op.dto.its.code.TbCmtrGradClsfDto;
|
|
|
|
+import com.its.op.dto.its.code.TbSectGradClsfDto;
|
|
import com.its.op.entity.its.code.TbSectGradStup;
|
|
import com.its.op.entity.its.code.TbSectGradStup;
|
|
-import com.its.op.entity.its.code.TbSectGradStupKey;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
+import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
-import java.util.Optional;
|
|
|
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
@RequiredArgsConstructor
|
|
@RequiredArgsConstructor
|
|
@@ -19,14 +19,39 @@ import java.util.Optional;
|
|
public class TbSectGradStupService {
|
|
public class TbSectGradStupService {
|
|
|
|
|
|
private final TbSectGradStupRepository repo;
|
|
private final TbSectGradStupRepository repo;
|
|
|
|
+ private final TbSectGradService sectService;
|
|
|
|
+ private final HashMap<String, TbSectGradClsfDto> sectGradMap = new HashMap<>();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ private void loadSectGrad() {
|
|
|
|
+ List<TbSectGradClsfDto> sectData = this.sectService.findAll();
|
|
|
|
+ for (TbSectGradClsfDto entity : sectData) {
|
|
|
|
+ this.sectGradMap.put(entity.getSectGradCd(), entity);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void setSectGradDesc(TbCmtrGradClsfDto obj) {
|
|
|
|
+ String sectGradCd = obj.getSectGradCd();
|
|
|
|
+ TbSectGradClsfDto sect = this.sectGradMap.get(sectGradCd);
|
|
|
|
+ if (sect == null) {
|
|
|
|
+ obj.setSectGradDesc("[" + sectGradCd + "] ?");
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ obj.setSectGradDesc("[" + sectGradCd+ "] " + sect.getSectGradNm());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
// 전체 데이터 조회
|
|
// 전체 데이터 조회
|
|
@Transactional(readOnly = true)
|
|
@Transactional(readOnly = true)
|
|
public List<TbCmtrGradClsfDto> findAll() {
|
|
public List<TbCmtrGradClsfDto> findAll() {
|
|
List<TbCmtrGradClsfDto> result = new ArrayList<>();
|
|
List<TbCmtrGradClsfDto> result = new ArrayList<>();
|
|
|
|
+ loadSectGrad();
|
|
|
|
+
|
|
List<TbSectGradStup> data = this.repo.findAll();
|
|
List<TbSectGradStup> data = this.repo.findAll();
|
|
for (TbSectGradStup entity : data) {
|
|
for (TbSectGradStup entity : data) {
|
|
- result.add(entity.toDto());
|
|
|
|
|
|
+ TbCmtrGradClsfDto dto = entity.toDto();
|
|
|
|
+ setSectGradDesc(dto);
|
|
|
|
+ result.add(dto);
|
|
}
|
|
}
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
@@ -35,36 +60,40 @@ public class TbSectGradStupService {
|
|
@Transactional
|
|
@Transactional
|
|
public List<TbCmtrGradClsfDto> mergeInfoList(List<TbCmtrGradClsfDto.TbCmtrGradClsfUpdReq> reqList) {
|
|
public List<TbCmtrGradClsfDto> mergeInfoList(List<TbCmtrGradClsfDto.TbCmtrGradClsfUpdReq> reqList) {
|
|
List<TbCmtrGradClsfDto> result = new ArrayList<>();
|
|
List<TbCmtrGradClsfDto> result = new ArrayList<>();
|
|
|
|
+ loadSectGrad();
|
|
|
|
+
|
|
for (TbCmtrGradClsfDto.TbCmtrGradClsfUpdReq req : reqList) {
|
|
for (TbCmtrGradClsfDto.TbCmtrGradClsfUpdReq req : reqList) {
|
|
TbSectGradStup obj = req.toEntity();
|
|
TbSectGradStup obj = req.toEntity();
|
|
this.repo.save(obj);
|
|
this.repo.save(obj);
|
|
- result.add(obj.toDto());
|
|
|
|
|
|
+ TbCmtrGradClsfDto dto = obj.toDto();
|
|
|
|
+ setSectGradDesc(dto);
|
|
|
|
+ result.add(dto);
|
|
}
|
|
}
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
// 데이터 변경 또는 생성-개별(데이터가 존재하면 업데이트 없으면 신규로 생성)
|
|
// 데이터 변경 또는 생성-개별(데이터가 존재하면 업데이트 없으면 신규로 생성)
|
|
- @Transactional
|
|
|
|
- public TbCmtrGradClsfDto mergeInfo(TbCmtrGradClsfDto.TbCmtrGradClsfUpdReq req) {
|
|
|
|
- TbSectGradStup obj = req.toEntity();
|
|
|
|
- this.repo.save(obj);
|
|
|
|
- return obj.toDto();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 정보 삭제-목록, 존재하는 데이터 만 삭제
|
|
|
|
- @Transactional
|
|
|
|
- public List<TbCmtrGradClsfDto> deleteByIds(List<TbSectGradStupKey> ids) {
|
|
|
|
- List<TbCmtrGradClsfDto> result = new ArrayList<>();
|
|
|
|
- for (TbSectGradStupKey id : ids) {
|
|
|
|
- Optional<TbSectGradStup> obj = this.repo.findById(id);
|
|
|
|
- if (obj.isPresent()) {
|
|
|
|
- this.repo.deleteById(id);
|
|
|
|
- result.add(obj.get().toDto());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return result;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+// @Transactional
|
|
|
|
+// public TbCmtrGradClsfDto mergeInfo(TbCmtrGradClsfDto.TbCmtrGradClsfUpdReq req) {
|
|
|
|
+// TbSectGradStup obj = req.toEntity();
|
|
|
|
+// this.repo.save(obj);
|
|
|
|
+// return obj.toDto();
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// // 정보 삭제-목록, 존재하는 데이터 만 삭제
|
|
|
|
+// @Transactional
|
|
|
|
+// public List<TbCmtrGradClsfDto> deleteByIds(List<TbSectGradStupKey> ids) {
|
|
|
|
+// List<TbCmtrGradClsfDto> result = new ArrayList<>();
|
|
|
|
+// for (TbSectGradStupKey id : ids) {
|
|
|
|
+// Optional<TbSectGradStup> obj = this.repo.findById(id);
|
|
|
|
+// if (obj.isPresent()) {
|
|
|
|
+// this.repo.deleteById(id);
|
|
|
|
+// result.add(obj.get().toDto());
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// return result;
|
|
|
|
+// }
|
|
|
|
+//
|
|
/**
|
|
/**
|
|
* 구간등급에 해당되는 소통등급 정보 조회
|
|
* 구간등급에 해당되는 소통등급 정보 조회
|
|
* @param sectGradCd
|
|
* @param sectGradCd
|
|
@@ -73,9 +102,13 @@ public class TbSectGradStupService {
|
|
@Transactional
|
|
@Transactional
|
|
public List<TbCmtrGradClsfDto> findAllGradeList(String sectGradCd) {
|
|
public List<TbCmtrGradClsfDto> findAllGradeList(String sectGradCd) {
|
|
List<TbCmtrGradClsfDto> result = new ArrayList<>();
|
|
List<TbCmtrGradClsfDto> result = new ArrayList<>();
|
|
|
|
+ loadSectGrad();
|
|
|
|
+
|
|
List<TbSectGradStup> data = this.repo.findAllGradeList(sectGradCd);
|
|
List<TbSectGradStup> data = this.repo.findAllGradeList(sectGradCd);
|
|
for (TbSectGradStup entity : data) {
|
|
for (TbSectGradStup entity : data) {
|
|
- result.add(entity.toDto());
|
|
|
|
|
|
+ TbCmtrGradClsfDto dto = entity.toDto();
|
|
|
|
+ setSectGradDesc(dto);
|
|
|
|
+ result.add(dto);
|
|
}
|
|
}
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|