Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
김현주
2025-07-18 15:04:53 +09:00
4 changed files with 65 additions and 46 deletions

View File

@@ -43,9 +43,9 @@ public class ChartDao implements ChartPortOut {
// 관리자 일경우
return new ChartDto(
recordMonthText,
chartMapper.selectTotalPercentage(reqVO),
chartMapper.selectLocalRegionPercentage(reqVO),
chartMapper.selectLocalRegionResearcherPercentage(reqVO),
chartMapper.selectTotalPercentage(reqVO,activeProfiles),
chartMapper.selectLocalRegionPercentage(reqVO,activeProfiles),
chartMapper.selectLocalRegionResearcherPercentage(reqVO,activeProfiles),
uiCodeListMapper.findByParentId("code.region.main",AdminUtil.getLoginUserRole(),activeProfiles));
} else if("ROLE_LOCAL_INSPECTOR".equals(AdminUtil.getLoginUserRole())) {
@@ -54,14 +54,14 @@ public class ChartDao implements ChartPortOut {
return new ChartDto(
recordMonthText,
chartMapper.selectTotalPercentage(reqVO),
chartMapper.selectTotalPercentage(reqVO,activeProfiles),
null,
chartMapper.selectLocalRegionResearcherPercentage(reqVO),
chartMapper.selectLocalRegionResearcherPercentage(reqVO,activeProfiles),
null);
} else if("ROLE_LOCAL_INSPECTOR".equals(AdminUtil.getLoginUserRole())) {
// 조사원 일경우
reqVO.setAdminSeq(AdminUtil.getLoginUserSeq());
return new ChartDto(recordMonthText, chartMapper.selectTotalPercentageResearcher(reqVO), null,null,null);
return new ChartDto(recordMonthText, chartMapper.selectTotalPercentageResearcher(reqVO,activeProfiles), null,null,null);
}
return new ChartDto(null,null,null,null,null);
@@ -73,7 +73,7 @@ public class ChartDao implements ChartPortOut {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMM");
String formattedDate = today.format(formatter);
if("ROLE_ADMIN".equals(AdminUtil.getLoginUserRole())) {
return chartMapper.selectLocalRegionResearcherPercentage(new TotalPercentageReqVO(usageType,regionMainCode,formattedDate));
return chartMapper.selectLocalRegionResearcherPercentage(new TotalPercentageReqVO(usageType,regionMainCode,formattedDate),activeProfiles);
}else{
throw new NoMatchingURIException("잘못된 접근");
}
@@ -82,7 +82,7 @@ public class ChartDao implements ChartPortOut {
@Override
public DashboardExcelDto selectDashboard(String recordMonth) {
return new DashboardExcelDto(
chartMapper.selectRegionMainExcel(recordMonth),
chartMapper.selectRegionDetailExcel(recordMonth));
chartMapper.selectRegionMainExcel(recordMonth,activeProfiles),
chartMapper.selectRegionDetailExcel(recordMonth,activeProfiles));
}
}

View File

@@ -3,17 +3,18 @@ package app.module.admin.usecase.dashboard.chart.adapters.persistence;
import app.module.admin.usecase.dashboard.chart.adapters.persistence.model.*;
import app.module.admin.usecase.dashboard.chart.adapters.web.model.TotalPercentageReqVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface ChartMapper {
TotalPercentDto selectTotalPercentage(TotalPercentageReqVO reqVO);
TotalPercentDto selectTotalPercentageResearcher(TotalPercentageReqVO reqVO);
List<LocalRegionPercentDto> selectLocalRegionPercentage(TotalPercentageReqVO reqVO);
List<LocalRegionResearcherPercentDto> selectLocalRegionResearcherPercentage(TotalPercentageReqVO reqVO);
List<RegionMainExcelDto> selectRegionMainExcel(String recordMonth);
List<RegionDetailExcelDto> selectRegionDetailExcel(String recordMonth);
TotalPercentDto selectTotalPercentage(@Param("reqVO") TotalPercentageReqVO reqVO,@Param("activeProfiles") String activeProfiles);
TotalPercentDto selectTotalPercentageResearcher(@Param("reqVO") TotalPercentageReqVO reqVO,@Param("activeProfiles") String activeProfiles);
List<LocalRegionPercentDto> selectLocalRegionPercentage(@Param("reqVO") TotalPercentageReqVO reqVO,@Param("activeProfiles") String activeProfiles);
List<LocalRegionResearcherPercentDto> selectLocalRegionResearcherPercentage(@Param("reqVO") TotalPercentageReqVO reqVO,@Param("activeProfiles") String activeProfiles);
List<RegionMainExcelDto> selectRegionMainExcel(@Param("recordMonth") String recordMonth,@Param("activeProfiles") String activeProfiles);
List<RegionDetailExcelDto> selectRegionDetailExcel(@Param("recordMonth") String recordMonth,@Param("activeProfiles") String activeProfiles);
}

View File

@@ -155,12 +155,21 @@ class ExcelUploadCreateHouseholdDao implements ExcelUploadCreateHouseholdPortOut
private String getUiCode(Cell cell,List<UICodeElement> uiCodeElementList,String codeId){
if (cell == null) return "";
try {
String cellValue = cell.getStringCellValue().trim();
String[] cellValueParts = cellValue.split("\\.");
return uiCodeElementList.stream().filter(code -> {
String[] cellValue = cell.getStringCellValue().trim().split("\\.");
return code.getId().equals(codeId+"."+cellValue[0]) || code.getCodeText().equals(cellValue[1]) ;
if(cellValueParts.length == 1 ) return code.getCodeText().equals(codeId+"."+cellValueParts[0]) || code.getCodeText().equals(cellValueParts[0]) ;
if(cellValueParts.length == 2 ) return code.getId().equals(codeId+"."+cellValueParts[0]) || code.getCodeText().equals(cellValueParts[1]) ;
return Boolean.parseBoolean(null);
} )
.findFirst()
.map(UICodeElement::getId).orElse("");
} catch (ArrayIndexOutOfBoundsException e) {
return null;
}
}
private ExcelUploadContactVO getDivisionContact(Cell cell){

View File

@@ -12,15 +12,15 @@
COUNT(DISTINCT CASE WHEN hv.is_gift_sent = true THEN hv.household_seq END) AS total_gift_sent_count,
COALESCE(ROUND(COUNT(DISTINCT CASE WHEN hv.is_gift_sent = true THEN hv.household_seq END) * 100::numeric / NULLIF(COUNT(DISTINCT h.seq), 0), 1) , 0 ) as gift_sent_percent
FROM household h
JOIN uicode u on u.parent_id ='code.region.main' and u.in_use = true and u.is_deleted = false
LEFT JOIN v_monthly_completion_rate cr on cr.household_seq = h.seq AND cr.record_month = #{recordMonth}
LEFT join household_visit hv on hv.household_seq = h.seq and to_char(hv.visit_date,'YYYYMM') = #{recordMonth} and hv.is_deleted = false
JOIN uicode u on u.parent_id ='code.region.main' and u.is_deleted = false <if test="'prod'.equals(activeProfiles)"> and u.in_use = true </if>
LEFT JOIN v_monthly_completion_rate cr on cr.household_seq = h.seq AND cr.record_month = #{reqVO.recordMonth}
LEFT join household_visit hv on hv.household_seq = h.seq and to_char(hv.visit_date,'YYYYMM') = #{reqVO.recordMonth} and hv.is_deleted = false
WHERE h.is_deleted = false
<if test="usageType != null and usageType != ''">
and h.usage_type = #{usageType}
<if test="reqVO.usageType != null and reqVO.usageType != ''">
and h.usage_type = #{reqVO.usageType}
</if>
<if test="regionMainCode != null and regionMainCode != ''">
and h.region_main_code = #{regionMainCode}
<if test="reqVO.regionMainCode != null and reqVO.regionMainCode != ''">
and h.region_main_code = #{reqVO.regionMainCode}
</if>
</select>
@@ -33,16 +33,16 @@
COUNT(DISTINCT CASE WHEN hv.is_gift_sent = true THEN hv.household_seq END) AS total_gift_sent_count,
COALESCE(ROUND(COUNT(DISTINCT CASE WHEN hv.is_gift_sent = true THEN hv.household_seq END) * 100::numeric / NULLIF(COUNT(DISTINCT rhh.household_seq), 0), 1),0) as gift_sent_percent
FROM household h
JOIN uicode u on u.parent_id ='code.region.main' and u.in_use = true and u.is_deleted = false
JOIN researcher_has_household rhh on rhh.household_seq = h.seq and rhh.admin_seq = #{adminSeq} and rhh.is_deleted = false
LEFT JOIN v_monthly_completion_rate cr on cr.household_seq = h.seq AND cr.record_month = #{recordMonth}
LEFT JOIN household_visit hv on hv.household_seq = h.seq and to_char(hv.visit_date,'YYYYMM') = #{recordMonth} and hv.is_deleted = false
JOIN uicode u on u.parent_id ='code.region.main' and u.is_deleted = false <if test="'prod'.equals(activeProfiles)"> and u.in_use = true </if>
JOIN researcher_has_household rhh on rhh.household_seq = h.seq and rhh.admin_seq = #{reqVO.adminSeq} and rhh.is_deleted = false
LEFT JOIN v_monthly_completion_rate cr on cr.household_seq = h.seq AND cr.record_month = #{reqVO.recordMonth}
LEFT JOIN household_visit hv on hv.household_seq = h.seq and to_char(hv.visit_date,'YYYYMM') = #{reqVO.recordMonth} and hv.is_deleted = false
WHERE h.is_deleted = false
<if test="usageType != null and usageType != ''">
and h.usage_type = #{usageType}
<if test="reqVO.usageType != null and reqVO.usageType != ''">
and h.usage_type = #{reqVO.usageType}
</if>
<if test="regionMainCode != null and regionMainCode != ''">
and h.region_main_code = #{regionMainCode}
<if test="reqVO.regionMainCode != null and reqVO.regionMainCode != ''">
and h.region_main_code = #{reqVO.regionMainCode}
</if>
</select>
@@ -65,14 +65,17 @@
ON rhh.admin_seq = a.seq AND rhh.is_deleted = false
LEFT JOIN household h
ON h.seq = rhh.household_seq AND h.is_deleted = false AND h.is_panel = true
<if test="usageType != null and usageType != ''">
and h.usage_type = #{usageType}
<if test="reqVO.usageType != null and reqVO.usageType != ''">
and h.usage_type = #{reqVO.usageType}
</if>
LEFT JOIN household_visit hv
ON hv.household_seq = h.seq AND hv.is_deleted = false AND to_char(hv.visit_date,'YYYYMM') = #{recordMonth}
ON hv.household_seq = h.seq AND hv.is_deleted = false AND to_char(hv.visit_date,'YYYYMM') = #{reqVO.recordMonth}
LEFT JOIN v_monthly_completion_rate v
ON v.household_seq = h.seq AND v.record_month = #{recordMonth}
WHERE u.parent_id = 'code.region.main' and u.in_use = true
ON v.household_seq = h.seq AND v.record_month = #{reqVO.recordMonth}
WHERE u.parent_id = 'code.region.main'
<if test="'prod'.equals(activeProfiles)">
and u.in_use = true
</if>
GROUP BY ROLLUP(u.code_text)
ORDER BY CASE WHEN COALESCE(u.code_text, '전체') = '전체' THEN 1 ELSE 0 END,
MIN(u.order_no) NULLS LAST,
@@ -91,18 +94,18 @@
COUNT(DISTINCT CASE WHEN hv.is_gift_sent = true THEN hv.household_seq END) AS total_gift_sent_count,
COALESCE(ROUND(COUNT(DISTINCT CASE WHEN hv.is_gift_sent = true THEN hv.household_seq END) * 100::numeric / NULLIF(COUNT(DISTINCT h.seq), 0), 1), 0) AS gift_sent_percent
FROM admin a
JOIN uicode u ON a.region_main_code = u.id and u.parent_id = 'code.region.main' and u.in_use = true
JOIN uicode u ON a.region_main_code = u.id and u.parent_id = 'code.region.main' <if test="'prod'.equals(activeProfiles)"> and u.in_use = true </if>
JOIN admin_has_role ahr ON a.seq = ahr.admin_seq AND ahr.is_deleted = false AND ahr.role_id = 'ROLE_RESEARCHER'
LEFT JOIN researcher_has_household rhh on rhh.admin_seq = ahr.admin_seq
LEFT JOIN household h on h.seq = rhh.household_seq
<if test="usageType != null and usageType != ''">
and h.usage_type = #{usageType}
<if test="reqVO.usageType != null and reqVO.usageType != ''">
and h.usage_type = #{reqVO.usageType}
</if>
LEFT JOIN v_monthly_completion_rate cr on cr.household_seq = h.seq AND cr.record_month = #{recordMonth}
LEFT JOIN household_visit hv on hv.household_seq = h.seq and to_char(hv.visit_date,'YYYYMM') = #{recordMonth}
LEFT JOIN v_monthly_completion_rate cr on cr.household_seq = h.seq AND cr.record_month = #{reqVO.recordMonth}
LEFT JOIN household_visit hv on hv.household_seq = h.seq and to_char(hv.visit_date,'YYYYMM') = #{reqVO.recordMonth}
WHERE a.is_deleted = false and a.account_disabled = false
<if test="regionMainCode != null and regionMainCode != ''">
and a.region_main_code = #{regionMainCode}
<if test="reqVO.regionMainCode != null and reqVO.regionMainCode != ''">
and a.region_main_code = #{reqVO.regionMainCode}
</if>
GROUP BY a.seq,u.id
</select>
@@ -143,7 +146,10 @@
LEFT JOIN v_monthly_completion_rate v
ON v.household_seq = h.seq
AND v.record_month = #{recordMonth}
WHERE u.parent_id = 'code.region.main' and u.in_use = true and u.is_deleted = false
WHERE u.parent_id = 'code.region.main' and u.is_deleted = false
<if test="'prod'.equals(activeProfiles)">
and u.in_use = true
</if>
GROUP BY u.code_text, u.order_no
UNION ALL
-- 전체 합계 행
@@ -177,7 +183,10 @@
LEFT JOIN v_monthly_completion_rate v
ON v.household_seq = h.seq
AND v.record_month = #{recordMonth}
WHERE u.parent_id = 'code.region.main' and u.in_use = true and u.is_deleted = false
WHERE u.parent_id = 'code.region.main' and u.is_deleted = false
<if test="'prod'.equals(activeProfiles)">
and u.in_use = true
</if>
ORDER BY order_no
</select>