123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739 |
- package com.lemon.lifecenter.controller;
- import java.io.ByteArrayInputStream;
- import java.io.ByteArrayOutputStream;
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.io.FileOutputStream;
- import java.io.IOException;
- import java.io.InputStream;
- import java.security.GeneralSecurityException;
- import java.text.DecimalFormat;
- import java.util.ArrayList;
- import java.util.List;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import org.apache.poi.hssf.usermodel.HSSFCellStyle;
- import org.apache.poi.hssf.usermodel.HSSFDataFormat;
- import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
- import org.apache.poi.openxml4j.opc.OPCPackage;
- import org.apache.poi.poifs.crypt.EncryptionInfo;
- import org.apache.poi.poifs.crypt.EncryptionMode;
- import org.apache.poi.poifs.crypt.Encryptor;
- import org.apache.poi.poifs.filesystem.POIFSFileSystem;
- import org.apache.poi.ss.usermodel.Cell;
- import org.apache.poi.ss.usermodel.CellStyle;
- import org.apache.poi.ss.usermodel.Font;
- import org.apache.poi.ss.usermodel.IndexedColors;
- import org.apache.poi.ss.usermodel.Row;
- import org.apache.poi.ss.usermodel.Sheet;
- import org.apache.poi.ss.usermodel.Workbook;
- import org.apache.poi.ss.util.CellRangeAddress;
- import org.apache.poi.xssf.usermodel.XSSFWorkbook;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Controller;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestParam;
- import org.springframework.web.servlet.ModelAndView;
- import com.lemon.lifecenter.common.LifeCenterConfigVO;
- import com.lemon.lifecenter.common.LifeCenterController;
- import com.lemon.lifecenter.common.LifeCenterFileDownload;
- import com.lemon.lifecenter.common.LifeCenterFunction;
- import com.lemon.lifecenter.common.LifeCenterPaging;
- import com.lemon.lifecenter.common.LifeCenterSessionController;
- import com.lemon.lifecenter.dto.LocationDTO;
- import com.lemon.lifecenter.dto.PatientDTO;
- import com.lemon.lifecenter.service.CenterService;
- import com.lemon.lifecenter.service.PatientService;
- @Controller
- @RequestMapping( "/statistics/patient" )
- public class PatientStatistics extends LifeCenterController {
- @Autowired
- private CenterService centerService;
- @Autowired
- private LifeCenterConfigVO config;
- @Autowired
- private PatientService patientService;
- private LifeCenterPaging paging;
-
- @RequestMapping( "/list" )
- public ModelAndView list(
- @RequestParam(value="page", required=false, defaultValue="1") int page,
- @RequestParam(value="q", required=false, defaultValue="") String q,
- @RequestParam(value="locationCode", required=false, defaultValue="") String locationCode,
- @RequestParam(value="startDate", required=false, defaultValue="") String startDate,
- @RequestParam(value="endDate", required=false, defaultValue="") String endDate,
- @RequestParam(value="registDay", required=false, defaultValue="") String inputRegistDay,
- @RequestParam(value="v", required=false, defaultValue="") String v ) {
-
- //일자별 통계
- if( v.equals( "day" ) ) {
- PatientDTO dto = new PatientDTO();
-
- if( endDate.equals( "" ) ) {
- endDate = LifeCenterFunction.getNow( "yyyy-MM-dd" );
- }
-
- if( startDate.equals( "" ) ) {
- //기록상 최초 환자 입소일 이후부터 계산
- startDate = "2020-11-23";
- }
-
- dto.setLimit( ( Integer.valueOf( page ) - 1 ) * config.pageDataSize );
- dto.setLimitMax( config.pageDataSize );
- dto.setQ(q);
- dto.setLocationCode(locationCode);
- dto.setStartDate(startDate);
- dto.setEndDate(endDate);
-
- List<LocationDTO> locationList = centerService.selectLocation();
-
- int total = patientService.selectStatisticsPatientCount(dto);
- List<PatientDTO> statisticsList = patientService.selectStatisticsPatientList(dto);
- PatientDTO statisticsSum = patientService.selectStatisticsPatientSum(dto);
-
- String param = "q=" + q + "&locationCode=" + locationCode + "&startDate=" + startDate + "&endDate=" + endDate + "&v=day";
- paging = LifeCenterPaging.getInstance();
- paging.paging(config, total, page, param);
-
- ModelAndView mv = setMV("statistics/list2");
-
-
- mv.addObject( "q" , q );
- mv.addObject( "statisticsList" , statisticsList );
- mv.addObject( "statisticsSum" , statisticsSum );
- mv.addObject( "locationList", locationList );
- mv.addObject( "locationCode", locationCode );
- mv.addObject( "startDate", startDate);
- mv.addObject( "endDate", endDate);
- mv.addObject( "total", total);
- mv.addObject( "paging", paging );
- mv.addObject( "page", page );
- mv.addObject( "pageSize", dto.getLimitMax() );
-
- return mv;
- } else {
- String registDayTime = "";
- //센터별 통계
- PatientDTO dto = new PatientDTO();
-
- dto.setLimit( ( Integer.valueOf( page ) - 1 ) * config.pageDataSize );
- dto.setLimitMax( config.pageDataSize );
- dto.setQ(q);
- dto.setLocationCode(locationCode);
-
- if (inputRegistDay.isEmpty()) {
- inputRegistDay = LifeCenterFunction.getNow("yyyy-MM-dd");
- }
-
- if( inputRegistDay.equals( LifeCenterFunction.getNow("yyyy-MM-dd") ) ) {
- dto.setRegistDayTime( inputRegistDay + " " + LifeCenterFunction.getNow("hh:mm") );
- } else {
- dto.setRegistDayTime( inputRegistDay + " 00:00" );
- }
-
- dto.setRegistDay(inputRegistDay);
- registDayTime = dto.getRegistDayTime();
-
- List<LocationDTO> locationList = centerService.selectLocation();
-
- int total = patientService.selectStatisticsPatientByCenterCount(dto);
- List<PatientDTO> statisticsList = new ArrayList<PatientDTO>();
-
- if( total > 0 ) {
- statisticsList = patientService.selectStatisticsPatientByCenterList(dto);
- }
-
-
- String param = "locationCode="+locationCode+"&q="+q+"®istDay="+inputRegistDay;
-
- paging = LifeCenterPaging.getInstance();
- paging.paging(config, total, page, param);
-
- ModelAndView mv = setMV("statistics/list");
-
- mv.addObject( "q" , q );
- mv.addObject( "statisticsList" , statisticsList );
- mv.addObject( "locationList", locationList );
- mv.addObject( "locationCode", locationCode );
- mv.addObject( "registDay", inputRegistDay );
- mv.addObject( "registDayTime", registDayTime );
- mv.addObject( "total", total);
- mv.addObject( "paging", paging );
- mv.addObject( "page", page );
- mv.addObject( "pageSize", dto.getLimitMax() );
-
- return mv;
- }
- }
-
-
-
- @RequestMapping( "/excel" )
- public void excel(
- HttpServletRequest request, HttpServletResponse response,
- @RequestParam(value="page", required=false, defaultValue="1") int page,
- @RequestParam(value="q", required=false, defaultValue="") String q,
- @RequestParam(value="locationCode", required=false, defaultValue="") String locationCode,
- @RequestParam(value="startDate", required=false, defaultValue="") String startDate,
- @RequestParam(value="endDate", required=false, defaultValue="") String endDate,
- @RequestParam(value="registDay", required=false, defaultValue="") String inputRegistDay,
- @RequestParam(value="v", required=false, defaultValue="") String v ) {
-
- // 일자별 통계
- if( v.equals( "day" ) ) {
- PatientDTO dto = new PatientDTO();
-
- if( endDate.equals( "" ) ) {
- endDate = LifeCenterFunction.getNow( "yyyy-MM-dd" );
- }
-
- if( startDate.equals( "" ) ) {
- //기록상 최초 환자 입소일 이후부터 계산
- startDate = "2020-11-23";
- }
-
- dto.setQ(q);
- dto.setLocationCode(locationCode);
- dto.setStartDate(startDate);
- dto.setEndDate(endDate);
-
- int total = patientService.selectStatisticsPatientCount(dto);
-
- dto.setLimit( 0 );
- dto.setLimitMax( total );
-
- List<PatientDTO> statisticsList = patientService.selectStatisticsPatientList(dto);
- PatientDTO statisticsSum = patientService.selectStatisticsPatientSum(dto);
-
- getStatisticsPatientExcel(request, response, statisticsList, statisticsSum);
- } else {
-
- //센터별 통계
- PatientDTO dto = new PatientDTO();
-
- dto.setQ(q);
- dto.setLocationCode(locationCode);
-
- if (inputRegistDay.isEmpty()) {
- inputRegistDay = LifeCenterFunction.getNow("yyyy-MM-dd");
- }
-
- if( inputRegistDay.equals( LifeCenterFunction.getNow("yyyy-MM-dd") ) ) {
- dto.setRegistDayTime( inputRegistDay + " " + LifeCenterFunction.getNow("hh:mm") );
- } else {
- dto.setRegistDayTime( inputRegistDay + " 00:00" );
- }
-
- dto.setRegistDay(inputRegistDay);
-
- List<LocationDTO> locationList = centerService.selectLocation();
-
- int total = patientService.selectStatisticsPatientByCenterCount(dto);
- List<PatientDTO> statisticsList = new ArrayList<PatientDTO>();
-
- dto.setLimit( 0 );
- dto.setLimitMax( total );
-
- if( total > 0 ) {
- statisticsList = patientService.selectStatisticsPatientByCenterList(dto);
- }
-
- getStatisticsPatientByCenterExcel(request, response, statisticsList, inputRegistDay );
- }
- }
-
- private void getStatisticsPatientByCenterExcel(HttpServletRequest request, HttpServletResponse response, List<PatientDTO> data, String registDay ) {
- 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);
-
-
- styleOfBoardFillFontBlackBold16.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0"));
-
- int i = 1;
-
- // th영역
- Row row = sheet1.createRow(0);
- Cell cell1 = row.createCell(0);
- Cell cell2 = row.createCell(1);
- Cell cell3 = row.createCell(2);
- Cell cell4 = row.createCell(3);
- Cell cell5 = row.createCell(4);
- Cell cell6 = row.createCell(5);
- Cell cell7 = row.createCell(6);
- Cell cell8 = row.createCell(7);
- Cell cell9 = row.createCell(8);
-
- cell1.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell2.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell3.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell4.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell5.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell6.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell7.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell8.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell9.setCellStyle(styleOfBoardFillFontBlackBold16);
-
-
- sheet1.setColumnWidth( 0, 10000); //생활치료센터명
- sheet1.setColumnWidth( 1, 6000); //소관
- sheet1.setColumnWidth( 2, 6000); //환자인원
- sheet1.setColumnWidth( 3, 6000); //입소
- sheet1.setColumnWidth( 4, 15000); //퇴실소계
- sheet1.setColumnWidth( 5, 6000); //퇴소
- sheet1.setColumnWidth( 6, 6000); //지정병원이송
- sheet1.setColumnWidth( 7, 6000); //생치센터이송
- sheet1.setColumnWidth( 8, 6000); //자가격리
-
-
- cell1.setCellValue("생활치료센터명");
- sheet1.addMergedRegion(new CellRangeAddress(0,1,0,0));
-
- cell2.setCellValue("소관");
- sheet1.addMergedRegion(new CellRangeAddress(0,1,1,1));
-
- cell3.setCellValue("환자인원");
- sheet1.addMergedRegion(new CellRangeAddress(0,1,2,2));
-
- cell4.setCellValue("입소");
- sheet1.addMergedRegion(new CellRangeAddress(0,1,3,3));
-
- cell5.setCellValue("퇴실소계 (퇴소 + 지정병원이송 + 생치센터이송 + 자가격리)");
- sheet1.addMergedRegion(new CellRangeAddress(0,1,4,4));
-
- cell6.setCellValue("퇴실");
- sheet1.addMergedRegion(new CellRangeAddress(0,0,5,8));
-
- row = sheet1.createRow(i);
- cell1 = row.createCell(0);
- cell2 = row.createCell(1);
- cell3 = row.createCell(2);
- cell4 = row.createCell(3);
- cell5 = row.createCell(4);
- cell6 = row.createCell(5);
- cell7 = row.createCell(6);
- cell8 = row.createCell(7);
- cell9 = row.createCell(8);
-
- cell1.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell2.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell3.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell4.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell5.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell6.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell7.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell8.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell9.setCellStyle(styleOfBoardFillFontBlackBold16);
-
- cell6.setCellValue( "퇴소" );
- cell7.setCellValue( "지정병원이송" );
- cell8.setCellValue( "생치센터이송" );
- cell9.setCellValue( "자가격리" );
-
- i++;
- // th영역 끝
-
- CellStyle styleOfBoardFillFontBlackBold17 = workbook.createCellStyle();
- CellStyle styleOfBoardFillFontBlackBold18 = workbook.createCellStyle();
- CellStyle styleOfBoardFillFontBlackBold19 = workbook.createCellStyle();
- Font fontOfGothicBlackBold17 = workbook.createFont();
- Font fontOfGothicBlackBold18 = workbook.createFont();
- Font fontOfGothicBlackBold19 = workbook.createFont();
- fontOfGothicBlackBold17.setFontName("맑은 고딕"); //글씨체
- fontOfGothicBlackBold18.setFontName("맑은 고딕"); //글씨체
- fontOfGothicBlackBold19.setFontName("맑은 고딕"); //글씨체
- fontOfGothicBlackBold17.setBoldweight(Font.BOLDWEIGHT_BOLD); //볼드 (굵게)
- styleOfBoardFillFontBlackBold17.setFont(fontOfGothicBlackBold17);
- styleOfBoardFillFontBlackBold17.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0"));
- styleOfBoardFillFontBlackBold18.setFont(fontOfGothicBlackBold18);
- styleOfBoardFillFontBlackBold19.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0"));
-
- for (PatientDTO dto : data) {
- // 센터별 통계 row
- row = sheet1.createRow(i);
- cell1 = row.createCell(0);
- cell2 = row.createCell(1);
- cell3 = row.createCell(2);
- cell4 = row.createCell(3);
- cell5 = row.createCell(4);
- cell6 = row.createCell(5);
- cell7 = row.createCell(6);
- cell8 = row.createCell(7);
- cell9 = row.createCell(8);
-
- styleOfBoardFillFontBlackBold17.setAlignment(CellStyle.ALIGN_RIGHT);
- cell1.setCellStyle(styleOfBoardFillFontBlackBold18);
- cell2.setCellStyle(styleOfBoardFillFontBlackBold19);
- cell3.setCellStyle(styleOfBoardFillFontBlackBold17);
- cell4.setCellStyle(styleOfBoardFillFontBlackBold17);
- cell5.setCellStyle(styleOfBoardFillFontBlackBold19);
- cell6.setCellStyle(styleOfBoardFillFontBlackBold19);
- cell7.setCellStyle(styleOfBoardFillFontBlackBold19);
- cell8.setCellStyle(styleOfBoardFillFontBlackBold19);
- cell9.setCellStyle(styleOfBoardFillFontBlackBold19);
-
- cell1.setCellValue( dto.getCenterName() );
- cell2.setCellValue( dto.getJurisdictionName() );
- cell3.setCellValue( dto.gethTotal() + dto.getdTotal() + dto.gettTotal() + dto.getlTotal() + dto.getsTotal() );
- cell4.setCellValue( dto.gethTotal() );
- cell5.setCellValue( dto.getdTotal() + dto.gettTotal() + dto.getlTotal() + dto.getsTotal() );
- cell6.setCellValue( dto.getdTotal() ); // 퇴소
- cell7.setCellValue( dto.gettTotal() ); // 지정병원이송
- cell8.setCellValue( dto.getlTotal() ); // 생치센터이송
- cell9.setCellValue( dto.getsTotal() ); // 자가격리
-
- i++;
- }
-
- row = sheet1.createRow(i);
- cell1 = row.createCell(2);
- cell2 = row.createCell(3);
- cell3 = row.createCell(4);
- cell4 = row.createCell(5);
- cell5 = row.createCell(6);
- cell6 = row.createCell(7);
- cell7 = row.createCell(8);
- cell8 = row.createCell(9);
- cell9 = row.createCell(10);
-
- try {
- // JBOSS에서 구동시 /home1/jboss/jboss-eap-7.3/domain/test/excel-temp 경로에 저장이됨
- String tempPath = "../excel-temp/testExcel.xlsx";
- String downName = LifeCenterFunction.getNow() + "_["+registDay+"] 환자입퇴소통계.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();
- }
- }
-
- private void getStatisticsPatientExcel(HttpServletRequest request, HttpServletResponse response, List<PatientDTO> data, PatientDTO sum ) {
- 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);
-
-
- styleOfBoardFillFontBlackBold16.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0"));
-
- int i = 1;
-
- // th영역
- Row row = sheet1.createRow(0);
- Cell cell1 = row.createCell(0);
- Cell cell2 = row.createCell(1);
- Cell cell3 = row.createCell(2);
- Cell cell4 = row.createCell(3);
- Cell cell5 = row.createCell(4);
- Cell cell6 = row.createCell(5);
- Cell cell7 = row.createCell(6);
- Cell cell8 = row.createCell(7);
-
- cell1.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell2.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell3.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell4.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell5.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell6.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell7.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell8.setCellStyle(styleOfBoardFillFontBlackBold16);
-
-
- sheet1.setColumnWidth( 0, 5000); //날짜
- sheet1.setColumnWidth( 1, 6000); //환자인원
- sheet1.setColumnWidth( 2, 6000); //입소
- sheet1.setColumnWidth( 3, 15000); //퇴실소계
- sheet1.setColumnWidth( 4, 6000); //퇴소
- sheet1.setColumnWidth( 5, 6000); //지정병원 이송
- sheet1.setColumnWidth( 6, 6000); //생치센터이송
- sheet1.setColumnWidth( 6, 6000); //자가격리
-
-
- cell1.setCellValue("날짜");
- sheet1.addMergedRegion(new CellRangeAddress(0,1,0,0));
- cell2.setCellValue("환자인원");
- sheet1.addMergedRegion(new CellRangeAddress(0,1,1,1));
- cell3.setCellValue("입소");
- sheet1.addMergedRegion(new CellRangeAddress(0,1,2,2));
- cell4.setCellValue("퇴실소계 (퇴소 + 지정병원이송 + 생치센터이송 + 자가격리)");
- sheet1.addMergedRegion(new CellRangeAddress(0,1,3,3));
-
- cell5.setCellValue("퇴실");
- sheet1.addMergedRegion(new CellRangeAddress(0,0,4,7));
-
- row = sheet1.createRow(i);
- cell1 = row.createCell(0);
- cell2 = row.createCell(1);
- cell3 = row.createCell(2);
- cell4 = row.createCell(3);
- cell5 = row.createCell(4);
- cell6 = row.createCell(5);
- cell7 = row.createCell(6);
- cell8 = row.createCell(7);
-
- cell1.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell2.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell3.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell4.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell5.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell6.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell7.setCellStyle(styleOfBoardFillFontBlackBold16);
- cell8.setCellStyle(styleOfBoardFillFontBlackBold16);
-
- cell5.setCellValue( "퇴소" );
- cell6.setCellValue( "지정병원이송" );
- cell7.setCellValue( "생치센터이송" );
- cell8.setCellValue( "자가격리" );
-
- i++;
- // th영역 끝
-
-
-
- // 누적 row
- CellStyle styleOfBoardFillFontBlackBold17 = workbook.createCellStyle();
- CellStyle styleOfBoardFillFontBlackBold18 = workbook.createCellStyle();
- CellStyle styleOfBoardFillFontBlackBold19 = workbook.createCellStyle();
- Font fontOfGothicBlackBold17 = workbook.createFont();
- Font fontOfGothicBlackBold18 = workbook.createFont();
- Font fontOfGothicBlackBold19 = workbook.createFont();
- fontOfGothicBlackBold17.setFontName("맑은 고딕"); //글씨체
- fontOfGothicBlackBold18.setFontName("맑은 고딕"); //글씨체
- fontOfGothicBlackBold19.setFontName("맑은 고딕"); //글씨체
- fontOfGothicBlackBold17.setBoldweight(Font.BOLDWEIGHT_BOLD); //볼드 (굵게)
- styleOfBoardFillFontBlackBold17.setFont(fontOfGothicBlackBold17);
- styleOfBoardFillFontBlackBold17.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0"));
- styleOfBoardFillFontBlackBold18.setFont(fontOfGothicBlackBold18);
- styleOfBoardFillFontBlackBold19.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0"));
-
- row = sheet1.createRow(i);
- cell1 = row.createCell(0);
- cell2 = row.createCell(1);
- cell3 = row.createCell(2);
- cell4 = row.createCell(3);
- cell5 = row.createCell(4);
- cell6 = row.createCell(5);
- cell7 = row.createCell(6);
- cell8 = row.createCell(7);
-
- styleOfBoardFillFontBlackBold17.setAlignment(CellStyle.ALIGN_RIGHT);
- styleOfBoardFillFontBlackBold17.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
-
- styleOfBoardFillFontBlackBold18.setAlignment(CellStyle.ALIGN_CENTER);
- cell1.setCellStyle(styleOfBoardFillFontBlackBold18);
- cell2.setCellStyle(styleOfBoardFillFontBlackBold19);
- cell3.setCellStyle(styleOfBoardFillFontBlackBold17);
- cell4.setCellStyle(styleOfBoardFillFontBlackBold17);
- cell5.setCellStyle(styleOfBoardFillFontBlackBold19);
- cell6.setCellStyle(styleOfBoardFillFontBlackBold19);
- cell7.setCellStyle(styleOfBoardFillFontBlackBold19);
- cell8.setCellStyle(styleOfBoardFillFontBlackBold19);
-
- cell1.setCellValue( "누적" );
- cell2.setCellValue( sum.gethTotal() + sum.getdTotal() + sum.gettTotal() + sum.getlTotal() + sum.getsTotal() );
- cell3.setCellValue( sum.gethTotal() );
- cell4.setCellValue( sum.getdTotal() + sum.gettTotal() + sum.getlTotal() + sum.getsTotal() );
- cell5.setCellValue( sum.getdTotal() );
- cell6.setCellValue( sum.gettTotal() );
- cell7.setCellValue( sum.getlTotal() );
- cell8.setCellValue( sum.getsTotal() );
-
- i++;
- // 누적 row 끝
-
-
-
- // 일별 통계 row
- for (PatientDTO dto : data) {
- row = sheet1.createRow(i);
- cell1 = row.createCell(0);
- cell2 = row.createCell(1);
- cell3 = row.createCell(2);
- cell4 = row.createCell(3);
- cell5 = row.createCell(4);
- cell6 = row.createCell(5);
- cell7 = row.createCell(6);
- cell8 = row.createCell(7);
-
- styleOfBoardFillFontBlackBold17.setAlignment(CellStyle.ALIGN_RIGHT);
- cell1.setCellStyle(styleOfBoardFillFontBlackBold18);
- cell2.setCellStyle(styleOfBoardFillFontBlackBold19);
- cell3.setCellStyle(styleOfBoardFillFontBlackBold17);
- cell4.setCellStyle(styleOfBoardFillFontBlackBold17);
- cell5.setCellStyle(styleOfBoardFillFontBlackBold19);
- cell6.setCellStyle(styleOfBoardFillFontBlackBold19);
- cell7.setCellStyle(styleOfBoardFillFontBlackBold19);
- cell8.setCellStyle(styleOfBoardFillFontBlackBold19);
-
- cell1.setCellValue( dto.getInDate() );
- cell2.setCellValue( dto.gethTotal() + dto.getdTotal() + dto.gettTotal() + dto.getlTotal() + dto.getsTotal() );
- cell3.setCellValue( dto.gethTotal() );
- cell4.setCellValue( dto.getdTotal() + dto.gettTotal() + dto.getlTotal() + dto.getsTotal() );
- cell5.setCellValue( dto.getdTotal() );
- cell6.setCellValue( dto.gettTotal() );
- cell7.setCellValue( dto.getlTotal() );
- cell8.setCellValue( dto.getsTotal() );
-
- i++;
- }
-
- row = sheet1.createRow(i);
- cell1 = row.createCell(2);
- cell2 = row.createCell(3);
- cell3 = row.createCell(4);
- cell4 = row.createCell(5);
- cell5 = row.createCell(6);
- cell6 = row.createCell(7);
- cell7 = row.createCell(8);
- cell8 = row.createCell(9);
-
- try {
- // JBOSS에서 구동시 /home1/jboss/jboss-eap-7.3/domain/test/excel-temp 경로에 저장이됨
- String tempPath = "../excel-temp/testExcel.xlsx";
- String downName = LifeCenterFunction.getNow() + " 환자입퇴소통계.xlsx";
- File xlsFile = new File(tempPath);
- // FileOutputStream fileOut = new FileOutputStream(tempPath);
- // workbook.write(fileOut);
- // fileOut.close();
-
- 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();
- }
- }
- }
|