|
@@ -3,6 +3,7 @@ package com.its.op.service.its.road;
|
|
|
import com.its.op.dao.repository.its.road.TbRoadRepository;
|
|
import com.its.op.dao.repository.its.road.TbRoadRepository;
|
|
|
import com.its.op.dto.its.road.TbRoadDto;
|
|
import com.its.op.dto.its.road.TbRoadDto;
|
|
|
import com.its.op.entity.its.road.TbRoad;
|
|
import com.its.op.entity.its.road.TbRoad;
|
|
|
|
|
+import com.its.op.global.TbRoadManager;
|
|
|
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;
|
|
@@ -12,6 +13,7 @@ import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.NoSuchElementException;
|
|
import java.util.NoSuchElementException;
|
|
|
import java.util.Optional;
|
|
import java.util.Optional;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
|
@RequiredArgsConstructor
|
|
@RequiredArgsConstructor
|
|
@@ -19,6 +21,7 @@ import java.util.Optional;
|
|
|
public class TbRoadService {
|
|
public class TbRoadService {
|
|
|
|
|
|
|
|
private final TbRoadRepository repo;
|
|
private final TbRoadRepository repo;
|
|
|
|
|
+ private final TbRoadManager manager;
|
|
|
|
|
|
|
|
// 데이터 1건 조회, 없으면 exception
|
|
// 데이터 1건 조회, 없으면 exception
|
|
|
private TbRoad requireOne(Long id) throws NoSuchElementException {
|
|
private TbRoad requireOne(Long id) throws NoSuchElementException {
|
|
@@ -38,9 +41,15 @@ public class TbRoadService {
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
@Transactional(readOnly = true)
|
|
@Transactional(readOnly = true)
|
|
|
- public List<TbRoadDto> findAll() {
|
|
|
|
|
|
|
+ public List<TbRoadDto> findAll(boolean isMemory) {
|
|
|
List<TbRoadDto> result = new ArrayList<>();
|
|
List<TbRoadDto> result = new ArrayList<>();
|
|
|
- List<TbRoad> data = this.repo.findAll();
|
|
|
|
|
|
|
+ List<TbRoad> data;
|
|
|
|
|
+ if (isMemory) {
|
|
|
|
|
+ data = this.manager.findAll();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ data = this.repo.findAll();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
for (TbRoad entity : data) {
|
|
for (TbRoad entity : data) {
|
|
|
result.add(entity.toDto());
|
|
result.add(entity.toDto());
|
|
|
}
|
|
}
|
|
@@ -52,9 +61,15 @@ public class TbRoadService {
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
@Transactional(readOnly = true)
|
|
@Transactional(readOnly = true)
|
|
|
- public List<TbRoadDto> findAllList() {
|
|
|
|
|
|
|
+ public List<TbRoadDto> findAllList(boolean isMemory) {
|
|
|
List<TbRoadDto> result = new ArrayList<>();
|
|
List<TbRoadDto> result = new ArrayList<>();
|
|
|
- List<TbRoad> data = this.repo.findAllList();
|
|
|
|
|
|
|
+ List<TbRoad> data;
|
|
|
|
|
+ if (isMemory) {
|
|
|
|
|
+ List<TbRoad> temp = this.manager.findAll();
|
|
|
|
|
+ data = temp.stream().filter(obj -> "N".equals(obj.getDelYn())).collect(Collectors.toList());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ data = this.repo.findAllList();
|
|
|
|
|
+ }
|
|
|
for (TbRoad entity : data) {
|
|
for (TbRoad entity : data) {
|
|
|
result.add(entity.toDto());
|
|
result.add(entity.toDto());
|
|
|
}
|
|
}
|
|
@@ -63,9 +78,16 @@ public class TbRoadService {
|
|
|
|
|
|
|
|
// 지역센터 전체 데이터 조회
|
|
// 지역센터 전체 데이터 조회
|
|
|
@Transactional(readOnly = true)
|
|
@Transactional(readOnly = true)
|
|
|
- public List<TbRoadDto> findLocalAll() {
|
|
|
|
|
|
|
+ public List<TbRoadDto> findLocalAll(boolean isMemory) {
|
|
|
List<TbRoadDto> result = new ArrayList<>();
|
|
List<TbRoadDto> result = new ArrayList<>();
|
|
|
- List<TbRoad> data = this.repo.findAll();
|
|
|
|
|
|
|
+ List<TbRoad> data;
|
|
|
|
|
+ if (isMemory) {
|
|
|
|
|
+ List<TbRoad> temp = this.manager.findAll();
|
|
|
|
|
+ data = temp.stream().filter(obj -> "N".equals(obj.getDelYn())).collect(Collectors.toList());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ data = this.repo.findAllList();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
for (TbRoad entity : data) {
|
|
for (TbRoad entity : data) {
|
|
|
if (("LAT001").equals(entity.getAreaCd())) {
|
|
if (("LAT001").equals(entity.getAreaCd())) {
|
|
|
result.add(entity.toDto());
|
|
result.add(entity.toDto());
|
|
@@ -87,6 +109,7 @@ public class TbRoadService {
|
|
|
TbRoad entity = requireOne(id);
|
|
TbRoad entity = requireOne(id);
|
|
|
entity.updateInfo(req);
|
|
entity.updateInfo(req);
|
|
|
this.repo.save(entity);
|
|
this.repo.save(entity);
|
|
|
|
|
+ this.manager.put(entity.getRoadId(), entity);
|
|
|
return entity.toDto();
|
|
return entity.toDto();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -97,6 +120,7 @@ public class TbRoadService {
|
|
|
for (TbRoadDto.TbRoadUpdReq req : reqList) {
|
|
for (TbRoadDto.TbRoadUpdReq req : reqList) {
|
|
|
TbRoad obj = req.toEntity();
|
|
TbRoad obj = req.toEntity();
|
|
|
this.repo.save(obj);
|
|
this.repo.save(obj);
|
|
|
|
|
+ this.manager.put(obj.getRoadId(), obj);
|
|
|
result.add(obj.toDto());
|
|
result.add(obj.toDto());
|
|
|
}
|
|
}
|
|
|
return result;
|
|
return result;
|
|
@@ -107,6 +131,7 @@ public class TbRoadService {
|
|
|
public TbRoadDto mergeInfo(TbRoadDto.TbRoadUpdReq req) {
|
|
public TbRoadDto mergeInfo(TbRoadDto.TbRoadUpdReq req) {
|
|
|
TbRoad obj = req.toEntity();
|
|
TbRoad obj = req.toEntity();
|
|
|
this.repo.save(obj);
|
|
this.repo.save(obj);
|
|
|
|
|
+ this.manager.put(obj.getRoadId(), obj);
|
|
|
return obj.toDto();
|
|
return obj.toDto();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -115,6 +140,7 @@ public class TbRoadService {
|
|
|
public TbRoadDto deleteById(Long id) {
|
|
public TbRoadDto deleteById(Long id) {
|
|
|
TbRoad entity = requireOne(id);
|
|
TbRoad entity = requireOne(id);
|
|
|
this.repo.deleteById(id);
|
|
this.repo.deleteById(id);
|
|
|
|
|
+ this.manager.remove(id);
|
|
|
return entity.toDto();
|
|
return entity.toDto();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -126,6 +152,7 @@ public class TbRoadService {
|
|
|
Optional<TbRoad> obj = this.repo.findById(id);
|
|
Optional<TbRoad> obj = this.repo.findById(id);
|
|
|
if (obj.isPresent()) {
|
|
if (obj.isPresent()) {
|
|
|
this.repo.deleteById(id);
|
|
this.repo.deleteById(id);
|
|
|
|
|
+ this.manager.remove(id);
|
|
|
result.add(obj.get().toDto());
|
|
result.add(obj.get().toDto());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -138,13 +165,17 @@ public class TbRoadService {
|
|
|
* @param filter
|
|
* @param filter
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
- public List<TbRoadDto> findByFilter(String filter) {
|
|
|
|
|
|
|
+ public List<TbRoadDto> findByFilter(String filter, boolean isMemory) {
|
|
|
List<TbRoadDto> result = new ArrayList<>();
|
|
List<TbRoadDto> result = new ArrayList<>();
|
|
|
- List<TbRoad> data = this.repo.findAll();
|
|
|
|
|
|
|
+ List<TbRoad> data;
|
|
|
|
|
+ if (isMemory) {
|
|
|
|
|
+ List<TbRoad> temp = this.manager.findAll();
|
|
|
|
|
+ data = temp.stream().filter(obj -> "N".equals(obj.getDelYn())).collect(Collectors.toList());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ data = this.repo.findAllList();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
data.forEach(obj -> {
|
|
data.forEach(obj -> {
|
|
|
- if (("Y").equals(obj.getDelYn())) {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
if (filter == null || filter.isEmpty()) {
|
|
if (filter == null || filter.isEmpty()) {
|
|
|
result.add(obj.toDto());
|
|
result.add(obj.toDto());
|
|
|
} else {
|
|
} else {
|
|
@@ -162,12 +193,15 @@ public class TbRoadService {
|
|
|
TbRoad entity = requireOne(id);
|
|
TbRoad entity = requireOne(id);
|
|
|
entity.updateName(req);
|
|
entity.updateName(req);
|
|
|
this.repo.save(entity);
|
|
this.repo.save(entity);
|
|
|
|
|
+ this.manager.put(entity.getRoadId(), entity);
|
|
|
return entity.toDto();
|
|
return entity.toDto();
|
|
|
}
|
|
}
|
|
|
public TbRoadDto updateSectGradById(Long id, TbRoadDto.TbRoadSectGradUpdReq req) {
|
|
public TbRoadDto updateSectGradById(Long id, TbRoadDto.TbRoadSectGradUpdReq req) {
|
|
|
TbRoad entity = requireOne(id);
|
|
TbRoad entity = requireOne(id);
|
|
|
entity.updateSectGrad(req);
|
|
entity.updateSectGrad(req);
|
|
|
this.repo.save(entity);
|
|
this.repo.save(entity);
|
|
|
|
|
+ this.manager.put(entity.getRoadId(), entity);
|
|
|
return entity.toDto();
|
|
return entity.toDto();
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
}
|
|
}
|