[BO_추가요청사항] 대시보드 연월 검색 추가

This commit is contained in:
kangsunlee
2025-07-28 16:00:42 +09:00
parent 2a51bd0b41
commit 18cc8fd146
8 changed files with 68 additions and 48 deletions

View File

@@ -28,53 +28,50 @@ public class ChartDao implements ChartPortOut {
private final UICodeListMapper uiCodeListMapper; private final UICodeListMapper uiCodeListMapper;
@Override @Override
public ChartDto selectTotalPercentage(String usageType) { public ChartDto selectTotalPercentage(String usageType, String recordMonth) {
TotalPercentageReqVO reqVO = new TotalPercentageReqVO(); TotalPercentageReqVO reqVO = new TotalPercentageReqVO();
reqVO.setUsageType(usageType); reqVO.setUsageType(usageType);
reqVO.setRecordMonth(recordMonth);
LocalDate today = LocalDate.now(); String year = recordMonth.substring(0, 4);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMM"); String month = recordMonth.substring(4, 6);
String formattedDate = today.format(formatter); String recordMonthText = year + "년 " + month + "월 현황";
reqVO.setRecordMonth(formattedDate);
DateTimeFormatter formatterText = DateTimeFormatter.ofPattern("yyyy년 MM월 현황");
String recordMonthText = today.format(formatterText);
if("ROLE_ADMIN".equals(AdminUtil.getLoginUserRole())) { if ("ROLE_ADMIN".equals(AdminUtil.getLoginUserRole())) {
// 관리자 일경우 // 관리자 일경우
return new ChartDto( return new ChartDto(recordMonthText,
recordMonthText, chartMapper.selectTotalPercentage(reqVO, activeProfiles),
chartMapper.selectTotalPercentage(reqVO,activeProfiles), chartMapper.selectLocalRegionPercentage(reqVO, activeProfiles),
chartMapper.selectLocalRegionPercentage(reqVO,activeProfiles), chartMapper.selectLocalRegionResearcherPercentage(reqVO, activeProfiles),
chartMapper.selectLocalRegionResearcherPercentage(reqVO,activeProfiles), uiCodeListMapper.findByParentId("code.region.main", AdminUtil.getLoginUserRole(),
uiCodeListMapper.findByParentId("code.region.main",AdminUtil.getLoginUserRole(),activeProfiles)); activeProfiles));
} else if("ROLE_LOCAL_INSPECTOR".equals(AdminUtil.getLoginUserRole())) { } else if ("ROLE_LOCAL_INSPECTOR".equals(AdminUtil.getLoginUserRole())) {
// 지방 실사 일경우 실사 지역으로만 // 지방 실사 일경우 실사 지역으로만
reqVO.setRegionMainCode(AdminUtil.getLoginUserRegionMainCode()); reqVO.setRegionMainCode(AdminUtil.getLoginUserRegionMainCode());
return new ChartDto( return new ChartDto(recordMonthText,
recordMonthText, chartMapper.selectTotalPercentage(reqVO, activeProfiles),
chartMapper.selectTotalPercentage(reqVO,activeProfiles), chartMapper.selectLocalRegionPercentage(reqVO, activeProfiles),
chartMapper.selectLocalRegionPercentage(reqVO,activeProfiles), chartMapper.selectLocalRegionResearcherPercentage(reqVO, activeProfiles), null);
chartMapper.selectLocalRegionResearcherPercentage(reqVO,activeProfiles), } else if ("ROLE_LOCAL_INSPECTOR".equals(AdminUtil.getLoginUserRole())) {
null);
} else if("ROLE_LOCAL_INSPECTOR".equals(AdminUtil.getLoginUserRole())) {
// 조사원 일경우 // 조사원 일경우
reqVO.setAdminSeq(AdminUtil.getLoginUserSeq()); reqVO.setAdminSeq(AdminUtil.getLoginUserSeq());
return new ChartDto(recordMonthText, chartMapper.selectTotalPercentageResearcher(reqVO,activeProfiles), null,null,null); return new ChartDto(recordMonthText,
chartMapper.selectTotalPercentageResearcher(reqVO, activeProfiles), null, null,
null);
} }
return new ChartDto(null,null,null,null,null); return new ChartDto(null, null, null, null, null);
} }
@Override @Override
public List<LocalRegionResearcherPercentDto> selectRegionMainCodePercentage(String usageType, String regionMainCode) { public List<LocalRegionResearcherPercentDto> selectRegionMainCodePercentage(String usageType, String regionMainCode, String recordMonth) {
LocalDate today = LocalDate.now(); if ("ROLE_ADMIN".equals(AdminUtil.getLoginUserRole())) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMM"); return chartMapper.selectLocalRegionResearcherPercentage(
String formattedDate = today.format(formatter); new TotalPercentageReqVO(usageType, regionMainCode, recordMonth), activeProfiles);
if("ROLE_ADMIN".equals(AdminUtil.getLoginUserRole())) { } else {
return chartMapper.selectLocalRegionResearcherPercentage(new TotalPercentageReqVO(usageType,regionMainCode,formattedDate),activeProfiles);
}else{
throw new NoMatchingURIException("잘못된 접근"); throw new NoMatchingURIException("잘못된 접근");
} }
} }

View File

@@ -37,20 +37,24 @@ class ChartApiController {
private final ChartPortIn chartPortIn; private final ChartPortIn chartPortIn;
@GetMapping(path = "/total") @GetMapping(path = "/total")
ResponseEntity<?> selectTotalPercentage(@RequestParam("usageType") String usageType) { ResponseEntity<?> selectTotalPercentage(@RequestParam("usageType") String usageType,
return ResponseEntity.status(HttpStatus.OK).body(chartPortIn.selectTotalPercentage(usageType)); @RequestParam("recordMonth") String recordMonth) {
return ResponseEntity.status(HttpStatus.OK)
.body(chartPortIn.selectTotalPercentage(usageType, recordMonth));
} }
@GetMapping(path = "/researcher") @GetMapping(path = "/researcher")
ResponseEntity<?> selectRegionMainCodePercentage(@RequestParam("usageType") String usageType,@RequestParam("regionMainCode") String regionMainCode) { ResponseEntity<?> selectRegionMainCodePercentage(@RequestParam("usageType") String usageType,
return ResponseEntity.status(HttpStatus.OK).body(chartPortIn.selectRegionMainCodePercentage(usageType,regionMainCode)); @RequestParam("regionMainCode") String regionMainCode,
@RequestParam("recordMonth") String recordMonth) {
return ResponseEntity.status(HttpStatus.OK).body(
chartPortIn.selectRegionMainCodePercentage(usageType, regionMainCode, recordMonth));
} }
@GetMapping(path = "/excel") @GetMapping(path = "/excel")
ResponseEntity<byte[]> exportDashboardExcel() { ResponseEntity<byte[]> exportDashboardExcel(@RequestParam("recordMonth") String recordMonth) {
DashboardExcelDto dashboardExcel = chartPortIn.selectDashboard( DashboardExcelDto dashboardExcel = chartPortIn.selectDashboard(recordMonth);
DateUiUtil.getCurrentMonthValue());
List<List<String>> rows1 = new ArrayList<>(); List<List<String>> rows1 = new ArrayList<>();
for (RegionMainExcelDto item : dashboardExcel.getRegionMain()) { for (RegionMainExcelDto item : dashboardExcel.getRegionMain()) {

View File

@@ -8,8 +8,8 @@ import java.util.List;
public interface ChartPortIn { public interface ChartPortIn {
ChartDto selectTotalPercentage(String usageType); ChartDto selectTotalPercentage(String usageType, String recordMonth);
List<LocalRegionResearcherPercentDto> selectRegionMainCodePercentage(String usageType,String regionMainCode); List<LocalRegionResearcherPercentDto> selectRegionMainCodePercentage(String usageType,String regionMainCode, String recordMonth);
DashboardExcelDto selectDashboard(String recordMonth); DashboardExcelDto selectDashboard(String recordMonth);
} }

View File

@@ -8,7 +8,7 @@ import java.util.List;
public interface ChartPortOut { public interface ChartPortOut {
ChartDto selectTotalPercentage(String usageType); ChartDto selectTotalPercentage(String usageType, String recordMonth);
List<LocalRegionResearcherPercentDto> selectRegionMainCodePercentage(String usageType,String regionMainCode); List<LocalRegionResearcherPercentDto> selectRegionMainCodePercentage(String usageType,String regionMainCode, String recordMonth);
DashboardExcelDto selectDashboard(String recordMonth); DashboardExcelDto selectDashboard(String recordMonth);
} }

View File

@@ -16,13 +16,14 @@ class ChartService implements ChartPortIn {
private final ChartPortOut portOut; private final ChartPortOut portOut;
@Override @Override
public ChartDto selectTotalPercentage(String usageType){ public ChartDto selectTotalPercentage(String usageType, String recordMonth){
return portOut.selectTotalPercentage(usageType); return portOut.selectTotalPercentage(usageType, recordMonth);
} }
@Override @Override
public List<LocalRegionResearcherPercentDto> selectRegionMainCodePercentage(String usageType,String regionMainCode) { public List<LocalRegionResearcherPercentDto> selectRegionMainCodePercentage(String usageType,
return portOut.selectRegionMainCodePercentage(usageType,regionMainCode); String regionMainCode, String recordMonth) {
return portOut.selectRegionMainCodePercentage(usageType, regionMainCode, recordMonth);
} }
@Override @Override

View File

@@ -1,5 +1,6 @@
package app.module.admin.usecase.home.adapters.web; package app.module.admin.usecase.home.adapters.web;
import app.module.admin.config.application.util.DateUiUtil;
import app.module.admin.usecase.dashboard.getSmsAutoStatus.ports.GetSmsAutoStatusPortIn; import app.module.admin.usecase.dashboard.getSmsAutoStatus.ports.GetSmsAutoStatusPortIn;
import app.module.admin.usecase.dashboard.getSmsAutoStatus.ports.application.domain.GetSmsAutoStatus; import app.module.admin.usecase.dashboard.getSmsAutoStatus.ports.application.domain.GetSmsAutoStatus;
import app.module.core.usecase.admin.view.ports.AdminViewPortIn; import app.module.core.usecase.admin.view.ports.AdminViewPortIn;
@@ -32,6 +33,8 @@ public class HomeController {
GetSmsAutoStatus smsAutoStatus = getSmsAutoStatusPortIn.operate().orElse(null); GetSmsAutoStatus smsAutoStatus = getSmsAutoStatusPortIn.operate().orElse(null);
model.addAttribute("smsActive", smsAutoStatus != null && smsAutoStatus.getActive()); model.addAttribute("smsActive", smsAutoStatus != null && smsAutoStatus.getActive());
model.addAttribute("monthList", DateUiUtil.getRecentMonths(13));
model.addAttribute("currentMonth", DateUiUtil.getCurrentMonthValue());
return "home"; return "home";
} }

File diff suppressed because one or more lines are too long

View File

@@ -19,6 +19,15 @@
<option value="PAPER">지류</option> <option value="PAPER">지류</option>
</select> </select>
</div> </div>
<div class="component-select">
<select class="select-list" id="recordMonth" name="recordMonth" required>
<option th:each="month : ${monthList}"
th:value="${month.value}"
th:text="${month.label}"
th:selected="${month.value == currentMonth}">
</option>
</select>
</div>
</div> </div>
</form> </form>
</div> </div>
@@ -414,6 +423,10 @@
$('#regionMainCode').change(function() { $('#regionMainCode').change(function() {
getResearcherArea(); getResearcherArea();
}); });
$('#recordMonth').change(function() {
getTotalPercentage();
});
}); });
</script> </script>
<script> <script>
@@ -459,7 +472,9 @@
// 엑셀 다운로드 // 엑셀 다운로드
const goExcel = () => { const goExcel = () => {
excelDownload('/api/dashboard/chart/excel', null); const f = document.reqForm;
const data = $(f).serializeObject();
excelDownload('/api/dashboard/chart/excel', data);
} }
</script> </script>
</section> </section>