|
@@ -121,8 +121,7 @@ public class ApiMonitoringController extends LifeCenterController {
|
|
|
}
|
|
|
|
|
|
if( startDate.equals( "" ) ) {
|
|
|
- //기록상 최초 환자 입소일 이후부터 계산
|
|
|
- startDate = "2021-02-15";
|
|
|
+ startDate = LifeCenterFunction.addDate(endDate, "yyyy-MM-dd", 0, 0, -15, 0, 0);
|
|
|
}
|
|
|
|
|
|
dto.setEndDate(endDate);
|
|
@@ -143,13 +142,183 @@ public class ApiMonitoringController extends LifeCenterController {
|
|
|
return mv;
|
|
|
}
|
|
|
|
|
|
- @RequestMapping("/state")
|
|
|
- public ModelAndView state() {
|
|
|
- ModelAndView mv = setMV("api/monitor/state");
|
|
|
- return mv;
|
|
|
+ @RequestMapping(value="/statisticsChartStateExcel", method=RequestMethod.POST)
|
|
|
+ public void getstatisticsChartState(
|
|
|
+ @RequestParam(value="downMemo", required=false, defaultValue="") String downMemo,
|
|
|
+ @RequestParam(value="startDate", required=false, defaultValue="") String startDate,
|
|
|
+ @RequestParam(value="endDate", required=false, defaultValue="") String endDate,
|
|
|
+ HttpServletRequest request,HttpServletResponse response) {
|
|
|
+
|
|
|
+ String userId = LifeCenterSessionController.getSession(request, "sesId");
|
|
|
+
|
|
|
+ //excel 다운로드 로그 남기기
|
|
|
+ FileDownloadDTO fileDTO = new FileDownloadDTO();
|
|
|
+ fileDTO.setId( userId );
|
|
|
+ fileDTO.setIp( LifeCenterFunction.getRemoteAddr( request ) );
|
|
|
+ fileDTO.setUrl( request.getRequestURI().toString() );
|
|
|
+ fileDTO.setMemo( downMemo );
|
|
|
+ fileDTO.setEtc( "" );
|
|
|
+ fileDownloadService.insertExcelDownloadLog( fileDTO );
|
|
|
+
|
|
|
+ if( endDate.equals( "" ) ) {
|
|
|
+ endDate = LifeCenterFunction.getNow( "yyyy-MM-dd" );
|
|
|
+ }
|
|
|
+
|
|
|
+ if( startDate.equals( "" ) ) {
|
|
|
+// startDate = "2021-02-15";
|
|
|
+ startDate = LifeCenterFunction.addDate(endDate, "yyyy-MM-dd", 0, 0, -14, 0, 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ ApiMonitorDTO dto = new ApiMonitorDTO();
|
|
|
+ dto.setEndDate(endDate);
|
|
|
+ dto.setStartDate(startDate);
|
|
|
+
|
|
|
+ ApiMonitorDTO stateData = monitorService.selectStatisticsState(dto);
|
|
|
+ List<ApiMonitorDTO> charList = monitorService.selectStatisticsChart(dto);
|
|
|
+
|
|
|
+ getStatisticsChartStateExcel(request, response, charList, stateData);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void getStatisticsChartStateExcel(HttpServletRequest request, HttpServletResponse response,
|
|
|
+ List<ApiMonitorDTO> data, ApiMonitorDTO stateData) {
|
|
|
+ String password = LifeCenterSessionController.getSession(request, "sesPhoneNumber");
|
|
|
+ password = password.toLowerCase();
|
|
|
+ if (!password.equals("null") && !password.equals("")) {
|
|
|
+ password = password.replace("-", "");
|
|
|
+ password = password.substring(3).trim();
|
|
|
+ } else {
|
|
|
+ password = "";
|
|
|
+ }
|
|
|
+
|
|
|
+ Workbook workbook = new XSSFWorkbook();
|
|
|
+ Sheet sheet1 = workbook.createSheet("firstSheet");
|
|
|
+ DecimalFormat df = new DecimalFormat("#,###");
|
|
|
+
|
|
|
+ // 1.셀 스타일 및 폰트 설정
|
|
|
+ CellStyle styleOfBoardFillFontBlackBold16 = workbook.createCellStyle();
|
|
|
+ // 정렬
|
|
|
+ styleOfBoardFillFontBlackBold16.setAlignment(CellStyle.ALIGN_CENTER); // 가운데 정렬
|
|
|
+ styleOfBoardFillFontBlackBold16.setVerticalAlignment(CellStyle.VERTICAL_CENTER); // 높이 가운데 정렬
|
|
|
+ // 배경색
|
|
|
+ styleOfBoardFillFontBlackBold16.setFillForegroundColor(IndexedColors.LIGHT_YELLOW.getIndex());
|
|
|
+ styleOfBoardFillFontBlackBold16.setFillPattern(CellStyle.SOLID_FOREGROUND);
|
|
|
+ // 테두리 선 (우,좌,위,아래)
|
|
|
+ styleOfBoardFillFontBlackBold16.setBorderRight(HSSFCellStyle.BORDER_THIN);
|
|
|
+ styleOfBoardFillFontBlackBold16.setBorderLeft(HSSFCellStyle.BORDER_THIN);
|
|
|
+ styleOfBoardFillFontBlackBold16.setBorderTop(HSSFCellStyle.BORDER_THIN);
|
|
|
+ styleOfBoardFillFontBlackBold16.setBorderBottom(HSSFCellStyle.BORDER_THIN);
|
|
|
+ // 폰트 설정
|
|
|
+ Font fontOfGothicBlackBold16 = workbook.createFont();
|
|
|
+// fontOfGothicBlackBold16.setFontName("나눔고딕"); //글씨체
|
|
|
+ fontOfGothicBlackBold16.setFontHeight((short) (10 * 20)); // 사이즈
|
|
|
+ fontOfGothicBlackBold16.setBoldweight(Font.BOLDWEIGHT_BOLD); // 볼드 (굵게)
|
|
|
+ styleOfBoardFillFontBlackBold16.setFont(fontOfGothicBlackBold16);
|
|
|
+
|
|
|
+ Row row = sheet1.createRow(0);
|
|
|
+ Cell cell1 = row.createCell(0);
|
|
|
+ Cell cell2 = row.createCell(1);
|
|
|
+ Cell cell3 = row.createCell(2);
|
|
|
+
|
|
|
+ cell1.setCellStyle(styleOfBoardFillFontBlackBold16);
|
|
|
+ cell2.setCellStyle(styleOfBoardFillFontBlackBold16);
|
|
|
+ cell3.setCellStyle(styleOfBoardFillFontBlackBold16);
|
|
|
+
|
|
|
+ sheet1.setColumnWidth(0, 5000); // 오픈 API 병원 건수
|
|
|
+ sheet1.setColumnWidth(1, 5000); // 오픈 API 호출 횟수
|
|
|
+ sheet1.setColumnWidth(2, 5000); // 오픈 API 호출 횟수
|
|
|
+
|
|
|
+ cell1.setCellValue("오픈 API 병원 건수");
|
|
|
+ cell2.setCellValue("오픈 API 호출 횟수");
|
|
|
+ cell3.setCellValue("오픈 API 호출 횟수");
|
|
|
+
|
|
|
+ row = sheet1.createRow(1);
|
|
|
+ cell1 = row.createCell(0);
|
|
|
+ cell2 = row.createCell(1);
|
|
|
+ cell3 = row.createCell(2);
|
|
|
+
|
|
|
+ int hospitalCount = stateData.getTotal();
|
|
|
+ int apiCount = stateData.getApiCount();
|
|
|
+ int numberOfCase = stateData.getNumberOfCase();
|
|
|
+
|
|
|
+ cell1.setCellValue(hospitalCount);
|
|
|
+ cell2.setCellValue(apiCount);
|
|
|
+ cell3.setCellValue(numberOfCase);
|
|
|
+
|
|
|
+ row = sheet1.createRow(3);
|
|
|
+ cell1 = row.createCell(0);
|
|
|
+ cell2 = row.createCell(1);
|
|
|
+
|
|
|
+ cell1.setCellStyle(styleOfBoardFillFontBlackBold16);
|
|
|
+ cell2.setCellStyle(styleOfBoardFillFontBlackBold16);
|
|
|
+
|
|
|
+ sheet1.setColumnWidth(0, 5000); // 오픈 API 병원 건수
|
|
|
+ sheet1.setColumnWidth(1, 5000); // 오픈 API 호출 횟수
|
|
|
+
|
|
|
+ cell1.setCellValue("날짜");
|
|
|
+ cell2.setCellValue("오픈 API 호출 건수");
|
|
|
+
|
|
|
+ int i = 4;
|
|
|
+ for (ApiMonitorDTO dto : data) {
|
|
|
+ row = sheet1.createRow(i);
|
|
|
+ cell1 = row.createCell(0);
|
|
|
+ cell2 = row.createCell(1);
|
|
|
+
|
|
|
+ String inDate = dto.getInDate();
|
|
|
+ int total = dto.getTotal();
|
|
|
+
|
|
|
+ cell1.setCellValue(inDate);
|
|
|
+ cell2.setCellValue(total);
|
|
|
+
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ String tempPath = "../excel-temp/testExcel.xlsx";
|
|
|
+ String downName = LifeCenterFunction.getNow() + " open_api_statistics_chart_state.xlsx";
|
|
|
+ File xlsFile = new File(tempPath);
|
|
|
+
|
|
|
+ ByteArrayOutputStream fileOut = new ByteArrayOutputStream();
|
|
|
+ FileOutputStream fos = new FileOutputStream(tempPath);
|
|
|
+ workbook.write(fileOut);
|
|
|
+
|
|
|
+ InputStream filein = new ByteArrayInputStream(fileOut.toByteArray());
|
|
|
+ OPCPackage opc = OPCPackage.open(filein);
|
|
|
+
|
|
|
+ POIFSFileSystem fileSystem = new POIFSFileSystem();
|
|
|
+
|
|
|
+ EncryptionInfo encryptionInfo = new EncryptionInfo(EncryptionMode.agile);
|
|
|
+ Encryptor encryptor = encryptionInfo.getEncryptor();
|
|
|
+ encryptor.confirmPassword(password);
|
|
|
+
|
|
|
+ opc.save(encryptor.getDataStream(fileSystem));
|
|
|
+ opc.flush();
|
|
|
+
|
|
|
+ fileSystem.writeFilesystem(fos);
|
|
|
+
|
|
|
+ fileOut.close();
|
|
|
+ opc.close();
|
|
|
+
|
|
|
+ filein.close();
|
|
|
+ fileSystem.close();
|
|
|
+
|
|
|
+ LifeCenterFileDownload.download(request, response, tempPath, downName);
|
|
|
+
|
|
|
+ xlsFile.delete();
|
|
|
+ } catch (FileNotFoundException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } catch (InvalidFormatException e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
+ } catch (GeneralSecurityException e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- @RequestMapping( value="/statisticsExcel", method=RequestMethod.POST )
|
|
|
+ @RequestMapping(value="/statisticsExcel", method=RequestMethod.POST)
|
|
|
public void getStatisticsList(
|
|
|
@RequestParam(value="downMemo", required=false, defaultValue="") String downMemo,
|
|
|
HttpServletRequest request,HttpServletResponse response ) {
|
|
@@ -176,7 +345,7 @@ public class ApiMonitoringController extends LifeCenterController {
|
|
|
getStatisticsListExcel(request, response, result);
|
|
|
}
|
|
|
|
|
|
- private void getStatisticsListExcel(HttpServletRequest request, HttpServletResponse response, List<ApiMonitorDTO> data ) {
|
|
|
+ private void getStatisticsListExcel(HttpServletRequest request, HttpServletResponse response, List<ApiMonitorDTO> data) {
|
|
|
String password = LifeCenterSessionController.getSession(request, "sesPhoneNumber");
|
|
|
password = password.toLowerCase();
|
|
|
if (!password.equals("null") && !password.equals("")) {
|