|
|
|
@ -6,6 +6,7 @@ import com.palnet.biz.api.bas.dos.model.CptStatRS;
|
|
|
|
|
import com.palnet.biz.api.bas.dos.service.StatisticsDosService; |
|
|
|
|
import com.palnet.biz.jpa.entity.QDosFltPlanArea; |
|
|
|
|
import com.palnet.biz.jpa.entity.QDosFltPlanBas; |
|
|
|
|
import com.palnet.biz.jpa.entity.QFltCptAuthBas; |
|
|
|
|
import com.palnet.comn.code.ErrorCode; |
|
|
|
|
import com.palnet.comn.exception.CustomException; |
|
|
|
|
import com.querydsl.core.BooleanBuilder; |
|
|
|
@ -33,7 +34,7 @@ public class DosFltPlanAreaQueryRepository {
|
|
|
|
|
* 총 데이터 조회 |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
public List<AllStatDataRS.GroupModel> allApplyTopData() { |
|
|
|
|
public List<AllStatDataRS.GroupProccessModel> allApplyTopData() { |
|
|
|
|
|
|
|
|
|
QDosFltPlanArea qDosFltPlanArea = QDosFltPlanArea.dosFltPlanArea; |
|
|
|
|
QDosFltPlanBas qDosFltPlanBas = QDosFltPlanBas.dosFltPlanBas; |
|
|
|
@ -48,10 +49,10 @@ public class DosFltPlanAreaQueryRepository {
|
|
|
|
|
BooleanBuilder builder = new BooleanBuilder(); |
|
|
|
|
builder.and(Expressions.booleanTemplate("{0} IS NOT NULL", qDosFltPlanArea.cptCd)); |
|
|
|
|
|
|
|
|
|
Map<String, AllStatDataRS.GroupModel> groupModel = query |
|
|
|
|
Map<String, AllStatDataRS.GroupProccessModel> groupModel = query |
|
|
|
|
.select( |
|
|
|
|
Projections.bean( |
|
|
|
|
AllStatDataRS.GroupModel.class, |
|
|
|
|
AllStatDataRS.GroupProccessModel.class, |
|
|
|
|
qDosFltPlanArea.cptCd.as("groupName"), |
|
|
|
|
qDosFltPlanArea.count().as("all"), |
|
|
|
|
yearTemplate.as("year"), |
|
|
|
@ -93,7 +94,7 @@ public class DosFltPlanAreaQueryRepository {
|
|
|
|
|
* @param controlFlag TRUE : 관제권 조회, FALSE : 비 관제권 조회 |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
public List<AllStatDataRS.GroupModel> controlApplyTopData(Boolean controlFlag) { |
|
|
|
|
public List<AllStatDataRS.GroupProccessModel> controlApplyTopData(Boolean controlFlag) { |
|
|
|
|
QDosFltPlanArea qDosFltPlanArea = QDosFltPlanArea.dosFltPlanArea; |
|
|
|
|
QDosFltPlanBas qDosFltPlanBas = QDosFltPlanBas.dosFltPlanBas; |
|
|
|
|
|
|
|
|
@ -116,10 +117,10 @@ public class DosFltPlanAreaQueryRepository {
|
|
|
|
|
groupingColumn = qDosFltPlanArea.cptCd; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Map<String, AllStatDataRS.GroupModel> groupModel = query |
|
|
|
|
Map<String, AllStatDataRS.GroupProccessModel> groupModel = query |
|
|
|
|
.select( |
|
|
|
|
Projections.bean( |
|
|
|
|
AllStatDataRS.GroupModel.class, |
|
|
|
|
AllStatDataRS.GroupProccessModel.class, |
|
|
|
|
groupingColumn.as("groupName"), |
|
|
|
|
qDosFltPlanArea.count().as("all"), |
|
|
|
|
yearTemplate.as("year"), |
|
|
|
@ -227,12 +228,23 @@ public class DosFltPlanAreaQueryRepository {
|
|
|
|
|
return cptStatList; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private String cptAuthNmByCptCd(String cptCd){ |
|
|
|
|
QFltCptAuthBas qFltCptAuthBas = QFltCptAuthBas.fltCptAuthBas; |
|
|
|
|
|
|
|
|
|
private List<AllStatDataRS.GroupModel> topDataParsing(Map<String, AllStatDataRS.GroupModel> groupModel){ |
|
|
|
|
Map<String, AllStatDataRS.GroupModel> currentMap = new ConcurrentHashMap<>(groupModel); |
|
|
|
|
return query |
|
|
|
|
.select( |
|
|
|
|
qFltCptAuthBas.cptAuthNm |
|
|
|
|
) |
|
|
|
|
.from(qFltCptAuthBas) |
|
|
|
|
.where(qFltCptAuthBas.cptAuthCode.eq(cptCd)) |
|
|
|
|
.fetchOne(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private List<AllStatDataRS.GroupProccessModel> topDataParsing(Map<String, AllStatDataRS.GroupProccessModel> groupModel){ |
|
|
|
|
Map<String, AllStatDataRS.GroupProccessModel> currentMap = new ConcurrentHashMap<>(groupModel); |
|
|
|
|
|
|
|
|
|
// CptCd가 한 개가 아닌 값들에 대한 로직
|
|
|
|
|
for(Map.Entry<String, AllStatDataRS.GroupModel> entry : currentMap.entrySet()){ |
|
|
|
|
for(Map.Entry<String, AllStatDataRS.GroupProccessModel> entry : currentMap.entrySet()){ |
|
|
|
|
|
|
|
|
|
String[] cptCdArray = entry.getKey().split(","); |
|
|
|
|
|
|
|
|
@ -243,7 +255,7 @@ public class DosFltPlanAreaQueryRepository {
|
|
|
|
|
|
|
|
|
|
// 기존 Map에 없는 값일 경우 CptCd를 Key로 새로 만들어 put
|
|
|
|
|
if(currentMap.get(cptCd) == null){ |
|
|
|
|
AllStatDataRS.GroupModel node = new AllStatDataRS.GroupModel(); |
|
|
|
|
AllStatDataRS.GroupProccessModel node = new AllStatDataRS.GroupProccessModel(); |
|
|
|
|
node.setGroupName(Collections.singletonList(cptCd)); |
|
|
|
|
node.setAll(entry.getValue().getAll()); |
|
|
|
|
node.setYear(entry.getValue().getYear()); |
|
|
|
@ -255,7 +267,7 @@ public class DosFltPlanAreaQueryRepository {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 기존 값이 있을 경우 객체를 새로운 메모리에 할당하여 put
|
|
|
|
|
AllStatDataRS.GroupModel node = new AllStatDataRS.GroupModel(); |
|
|
|
|
AllStatDataRS.GroupProccessModel node = new AllStatDataRS.GroupProccessModel(); |
|
|
|
|
node.setGroupName(Collections.singletonList(cptCd)); |
|
|
|
|
node.setAll(currentMap.get(cptCd).getAll() + entry.getValue().getAll()); |
|
|
|
|
node.setYear(currentMap.get(cptCd).getYear() + entry.getValue().getYear()); |
|
|
|
@ -275,20 +287,31 @@ public class DosFltPlanAreaQueryRepository {
|
|
|
|
|
|
|
|
|
|
// 총 카운트가 가장많은 값 추출
|
|
|
|
|
Long max = currentMap.values().stream() |
|
|
|
|
.mapToLong(AllStatDataRS.GroupModel::getAll) |
|
|
|
|
.mapToLong(AllStatDataRS.GroupProccessModel::getAll) |
|
|
|
|
.max() |
|
|
|
|
.orElse(0); |
|
|
|
|
|
|
|
|
|
List<AllStatDataRS.GroupModel> result = new ArrayList<>(); |
|
|
|
|
List<AllStatDataRS.GroupProccessModel> result = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
// 가장 많은 값만 반환 리스트에 ADD
|
|
|
|
|
for(Map.Entry<String, AllStatDataRS.GroupModel> entry : currentMap.entrySet()){ |
|
|
|
|
for(Map.Entry<String, AllStatDataRS.GroupProccessModel> entry : currentMap.entrySet()){ |
|
|
|
|
if(entry.getValue().getAll().equals(max)){ |
|
|
|
|
result.add(entry.getValue()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(result.isEmpty()) result.add(new AllStatDataRS.GroupModel()); |
|
|
|
|
result.forEach(node -> { |
|
|
|
|
List<String> groupDesc = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
for(String groupName : node.getGroupName()){ |
|
|
|
|
groupDesc.add(this.cptAuthNmByCptCd(groupName)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
node.setGroupName(groupDesc); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(result.isEmpty()) result.add(new AllStatDataRS.GroupProccessModel()); |
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|