Merge branch 'household_tab' into bo_daily
This commit is contained in:
@@ -120,6 +120,12 @@ recycle 의 demo 가 궁금하다면 아래 URL 에서 확인 해주세요.
|
|||||||
-Dfile.upload.sftp.id=etribe
|
-Dfile.upload.sftp.id=etribe
|
||||||
-Dfile.upload.sftp.password=Etribe@3415
|
-Dfile.upload.sftp.password=Etribe@3415
|
||||||
-Dfile.upload.sftp.port=22
|
-Dfile.upload.sftp.port=22
|
||||||
|
-Dspring.datasource.hikari.maximum-pool-size=10
|
||||||
|
-Dspring.datasource.hikari.minimum-idle=5
|
||||||
|
-Dspring.datasource.hikari.idle-timeout=120000
|
||||||
|
-Dspring.datasource.hikari.max-lifetime=900000
|
||||||
|
-Dspring.datasource.hikari.connection-timeout=5000
|
||||||
|
-Dspring.datasource.hikari.leak-detection-threshold=30000
|
||||||
```
|
```
|
||||||
** 주의 : 운영서버일 경우 -Dpath.upload.storage=SFTP로 설정
|
** 주의 : 운영서버일 경우 -Dpath.upload.storage=SFTP로 설정
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,31 @@
|
|||||||
package app.module.admin.usecase.household.tab.dailyRecord.getDailyRecordsStatus.adapters.web;
|
package app.module.admin.usecase.household.tab.dailyRecord.getDailyRecordsStatus.adapters.web;
|
||||||
|
|
||||||
|
import app.module.admin.config.application.util.ExcelWriterUtil;
|
||||||
|
import app.module.admin.config.application.util.model.ExcelSheetDto;
|
||||||
|
import app.module.admin.usecase.household.getHouseholdStatus.ports.GetHouseholdStatusPortIn;
|
||||||
|
import app.module.admin.usecase.household.getHouseholdStatus.ports.application.domain.GetHouseholdStatus;
|
||||||
|
import app.module.admin.usecase.household.getHouseholdStatus.ports.application.domain.GetHouseholdStatusCmd;
|
||||||
import app.module.admin.usecase.household.tab.dailyRecord.getDailyRecordsCount.ports.GetDailyRecordsCountPortIn;
|
import app.module.admin.usecase.household.tab.dailyRecord.getDailyRecordsCount.ports.GetDailyRecordsCountPortIn;
|
||||||
import app.module.admin.usecase.household.tab.dailyRecord.getDailyRecordsCount.ports.application.domain.GetDailyRecordsCount;
|
import app.module.admin.usecase.household.tab.dailyRecord.getDailyRecordsCount.ports.application.domain.GetDailyRecordsCount;
|
||||||
import app.module.admin.usecase.household.tab.dailyRecord.getDailyRecordsCount.ports.application.domain.GetDailyRecordsCountCmd;
|
import app.module.admin.usecase.household.tab.dailyRecord.getDailyRecordsCount.ports.application.domain.GetDailyRecordsCountCmd;
|
||||||
import app.module.admin.usecase.household.tab.dailyRecord.getDailyRecordsStatus.ports.GetDailyRecordsStatusPortIn;
|
import app.module.admin.usecase.household.tab.dailyRecord.getDailyRecordsStatus.ports.GetDailyRecordsStatusPortIn;
|
||||||
import app.module.admin.usecase.household.tab.dailyRecord.getDailyRecordsStatus.ports.application.domain.GetDailyRecordsStatus;
|
import app.module.admin.usecase.household.tab.dailyRecord.getDailyRecordsStatus.ports.application.domain.GetDailyRecordsStatus;
|
||||||
import app.module.admin.usecase.household.tab.dailyRecord.getDailyRecordsStatus.ports.application.domain.GetDailyRecordsStatusCmd;
|
import app.module.admin.usecase.household.tab.dailyRecord.getDailyRecordsStatus.ports.application.domain.GetDailyRecordsStatusCmd;
|
||||||
|
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.apache.poi.ss.usermodel.IndexedColors;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
@@ -18,22 +35,81 @@ import app.module.admin.usecase.household.tab.dailyRecord.getDailyRecordsStatus.
|
|||||||
@RestController
|
@RestController
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
class GetDailyRecordsStatusController {
|
class GetDailyRecordsStatusController {
|
||||||
private final GetDailyRecordsStatusPortIn getDailyRecordsStatusPortIn;
|
private final GetDailyRecordsStatusPortIn getDailyRecordsStatusPortIn;
|
||||||
private final GetDailyRecordsCountPortIn getDailyRecordsCountPortIn;
|
private final GetDailyRecordsCountPortIn getDailyRecordsCountPortIn;
|
||||||
|
private final GetHouseholdStatusPortIn getHouseholdStatusPortIn;
|
||||||
|
|
||||||
@GetMapping(path = "/api/household/dailyRecordsStatus")
|
@GetMapping(path = "/api/household/dailyRecordsStatus")
|
||||||
ResponseEntity<?> operate(
|
ResponseEntity<?> operate(GetDailyRecordsStatusReqVO reqVO) {
|
||||||
GetDailyRecordsStatusReqVO reqVO) {
|
|
||||||
|
|
||||||
List<GetDailyRecordsStatus> dailyRecords =
|
List<GetDailyRecordsStatus> dailyRecords =
|
||||||
getDailyRecordsStatusPortIn.operate(
|
getDailyRecordsStatusPortIn.operate(
|
||||||
new GetDailyRecordsStatusCmd(reqVO.getHouseholdSeq(), reqVO.getRecordMonth()));
|
new GetDailyRecordsStatusCmd(reqVO.getHouseholdSeq(), reqVO.getRecordMonth()));
|
||||||
|
|
||||||
GetDailyRecordsCount summary =
|
GetDailyRecordsCount summary =
|
||||||
getDailyRecordsCountPortIn.operate(
|
getDailyRecordsCountPortIn.operate(
|
||||||
new GetDailyRecordsCountCmd(reqVO.getHouseholdSeq(), reqVO.getRecordMonth())).orElse(null);
|
new GetDailyRecordsCountCmd(reqVO.getHouseholdSeq(), reqVO.getRecordMonth())).orElse(null);
|
||||||
|
|
||||||
return ResponseEntity.status(HttpStatus.OK)
|
return ResponseEntity.status(HttpStatus.OK)
|
||||||
.body(new GetDailyRecordsStatusResVO(summary, dailyRecords));
|
.body(new GetDailyRecordsStatusResVO(summary, dailyRecords));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일계부 등록 현황 엑셀 다운로드
|
||||||
|
*
|
||||||
|
* @param reqVO 검색 조건
|
||||||
|
* @return 엑셀 파일 다운로드
|
||||||
|
*/
|
||||||
|
@GetMapping("/api/household/dailyRecordsStatus/excel")
|
||||||
|
public ResponseEntity<byte[]> exportHouseholdExcel(GetDailyRecordsStatusReqVO reqVO) {
|
||||||
|
|
||||||
|
String householdNum = "-";
|
||||||
|
String ownerName = "-";
|
||||||
|
GetHouseholdStatus householdInfo = getHouseholdStatusPortIn.operate(new GetHouseholdStatusCmd(reqVO.getHouseholdSeq())).orElse(null);
|
||||||
|
if (householdInfo != null) {
|
||||||
|
householdNum = householdInfo.getHouseholdNum();
|
||||||
|
ownerName = householdInfo.getHouseholdName();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<GetDailyRecordsStatus> dailyRecords =
|
||||||
|
getDailyRecordsStatusPortIn.operate(
|
||||||
|
new GetDailyRecordsStatusCmd(reqVO.getHouseholdSeq(), reqVO.getRecordMonth()));
|
||||||
|
|
||||||
|
List<List<String>> rows = new ArrayList<>();
|
||||||
|
for (GetDailyRecordsStatus record : dailyRecords) {
|
||||||
|
rows.add(List.of(householdNum, ownerName,
|
||||||
|
record.getDayGroup(),
|
||||||
|
record.getAllStatusType().getDesc(),
|
||||||
|
record.getIncomeStatus(),
|
||||||
|
record.getWorkStatus(),
|
||||||
|
record.getExpenseStatus(),
|
||||||
|
record.getPowerStatus(),
|
||||||
|
record.getForestryStatus(),
|
||||||
|
record.getFarmingStatus()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 시트 1: 등록 현황 목록
|
||||||
|
ExcelSheetDto sheet1 = new ExcelSheetDto(
|
||||||
|
"일계부 등록 현황",
|
||||||
|
List.of("임가번호", "경영주 성명", "입력 날짜", "완료상태", "수입", "노동투입", "지출", "동력사용시간", "임업 자가소비량", "농업 자가소비량"),
|
||||||
|
rows,
|
||||||
|
null,
|
||||||
|
Map.of(
|
||||||
|
0, IndexedColors.LIGHT_YELLOW
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// 시트 모음
|
||||||
|
List<ExcelSheetDto> sheets = List.of(sheet1);
|
||||||
|
|
||||||
|
byte[] excel = ExcelWriterUtil.writeExcel(sheets);
|
||||||
|
|
||||||
|
String rawFileName = "02. 일계부 등록 현황[" + reqVO.getRecordMonth() + "][" + householdNum + "]_" + LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")) + ".xlsx";
|
||||||
|
String encodedFileName = URLEncoder.encode(rawFileName, StandardCharsets.UTF_8).replaceAll("\\+", "%20");
|
||||||
|
|
||||||
|
return ResponseEntity.ok()
|
||||||
|
.contentType(MediaType.APPLICATION_OCTET_STREAM)
|
||||||
|
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename*=UTF-8''" + encodedFileName)
|
||||||
|
.body(excel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
File diff suppressed because one or more lines are too long
@@ -125,7 +125,7 @@
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
<div class="component-tab" data-active="tab1">
|
<div class="component-tab" data-active="none">
|
||||||
<div class="tab-head">
|
<div class="tab-head">
|
||||||
<button type="button" class="tab-label select-tab" data-tab-type="daily-record" data-tab-value="tab1">일계부 등록 현황</button>
|
<button type="button" class="tab-label select-tab" data-tab-type="daily-record" data-tab-value="tab1">일계부 등록 현황</button>
|
||||||
<button type="button" class="tab-label select-tab" data-tab-type="forest-product" data-tab-value="tab2" th:unless="${activeProfile != 'local'}">임산물 현황</button>
|
<button type="button" class="tab-label select-tab" data-tab-type="forest-product" data-tab-value="tab2" th:unless="${activeProfile != 'local'}">임산물 현황</button>
|
||||||
@@ -164,8 +164,17 @@
|
|||||||
<span class="btn-txt">목록</span>
|
<span class="btn-txt">목록</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="btns-col-2 align-right" th:unless="${activeProfile != 'local'}">
|
<div class="btns-col-2 align-right _excelDownload" th:unless="${activeProfile != 'local'}">
|
||||||
<button type="button" class="btn">
|
<button type="button" class="btn" data-tab-type="daily-record" data-tab-value="tab1" onclick="goExcel(this)">
|
||||||
|
<span class="btn-txt">엑셀 다운로드 <i class="ico-download" aria-hidden="true"></i></span>
|
||||||
|
</button>
|
||||||
|
<button type="button" class="btn" data-tab-type="forest-product" data-tab-value="tab2" onclick="goExcel(this)">
|
||||||
|
<span class="btn-txt">엑셀 다운로드 <i class="ico-download" aria-hidden="true"></i></span>
|
||||||
|
</button>
|
||||||
|
<button type="button" class="btn" data-tab-type="bank-auto-transfer" data-tab-value="tab3" onclick="goExcel(this)">
|
||||||
|
<span class="btn-txt">엑셀 다운로드 <i class="ico-download" aria-hidden="true"></i></span>
|
||||||
|
</button>
|
||||||
|
<button type="button" class="btn" data-tab-type="household-visit" data-tab-value="tab4" onclick="goExcel(this)">
|
||||||
<span class="btn-txt">엑셀 다운로드 <i class="ico-download" aria-hidden="true"></i></span>
|
<span class="btn-txt">엑셀 다운로드 <i class="ico-download" aria-hidden="true"></i></span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -223,12 +232,32 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
const tabStorageName = 'tabActive';
|
||||||
|
let tabActive = 'tab1';
|
||||||
|
window.onpageshow = function (event) {
|
||||||
|
if (event.persisted || (window.performance && window.performance.navigation.type == 1)) {
|
||||||
|
if (('sessionStorage' in window) && window['sessionStorage'] !== null) {
|
||||||
|
if (sessionStorage.getItem(tabStorageName)) {
|
||||||
|
tabActive = sessionStorage.getItem(tabStorageName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (event.persisted || (window.performance && window.performance.navigation.type == 2)) {
|
||||||
|
sessionStorage.removeItem(tabStorageName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$(document).ready(() => {
|
$(document).ready(() => {
|
||||||
getDailyRecords();
|
$('._excelDownload button').hide();
|
||||||
|
|
||||||
|
setTimeout(function () {
|
||||||
|
let $tab = $('.component-tab button[data-tab-value="' + tabActive + '"]');
|
||||||
|
|
||||||
|
getTabData($tab.data('tabType'), $tab.data('tabValue'));
|
||||||
|
}, 500);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.select-tab').on('click', function () {
|
$('.select-tab').on('click', function () {
|
||||||
getTabData(this.dataset.tabType);
|
getTabData(this.dataset.tabType, this.dataset.tabValue);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -241,7 +270,7 @@
|
|||||||
getTabData(selectedTab.dataset.tabType);
|
getTabData(selectedTab.dataset.tabType);
|
||||||
}
|
}
|
||||||
|
|
||||||
const getTabData = (tabType) => {
|
const getTabData = (tabType, tabValue) => {
|
||||||
switch (tabType) {
|
switch (tabType) {
|
||||||
case 'daily-record': // 일계부 등록 현황
|
case 'daily-record': // 일계부 등록 현황
|
||||||
getDailyRecords();
|
getDailyRecords();
|
||||||
@@ -256,6 +285,13 @@
|
|||||||
getVisitInfo();
|
getVisitInfo();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sessionStorage.setItem(tabStorageName, tabValue);
|
||||||
|
|
||||||
|
document.querySelector('.component-tab').ui.setValue(tabValue);
|
||||||
|
|
||||||
|
$('._excelDownload button').hide();
|
||||||
|
$('._excelDownload button[data-tab-value="' + tabValue + '"]').show();
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -362,6 +398,36 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
// 엑셀 다운로드
|
||||||
|
const goExcel = (el) => {
|
||||||
|
let url = '';
|
||||||
|
if (el.dataset.tabValue === 'tab1') {
|
||||||
|
url = $('.tab-content .daily-record-list').is(':hidden') ? '' : '/api/household/dailyRecordsStatus/excel';
|
||||||
|
} else if (el.dataset.tabValue === 'tab2') {
|
||||||
|
url = '';
|
||||||
|
} else if (el.dataset.tabValue === 'tab3') {
|
||||||
|
url = '';
|
||||||
|
} else if (el.dataset.tabValue === 'tab4') {
|
||||||
|
url = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('goExcel', el.dataset.tabValue, url);
|
||||||
|
|
||||||
|
const f = document.reqForm;
|
||||||
|
const data = $(f).serializeObject();
|
||||||
|
|
||||||
|
// size 를 제거하면 전체 목록을 가져온다.
|
||||||
|
delete data.size;
|
||||||
|
|
||||||
|
if (url !== '') {
|
||||||
|
location.href = url + '?' + new URLSearchParams(data).toString();
|
||||||
|
} else {
|
||||||
|
console.warn('엑셀 다운르도 경로 없음.')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
Reference in New Issue
Block a user