CenterController.java 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  1. package com.lemon.lifecenter.controller;
  2. import java.io.ByteArrayInputStream;
  3. import java.io.ByteArrayOutputStream;
  4. import java.io.File;
  5. import java.io.FileNotFoundException;
  6. import java.io.FileOutputStream;
  7. import java.io.IOException;
  8. import java.io.InputStream;
  9. import java.security.GeneralSecurityException;
  10. import java.text.DecimalFormat;
  11. import java.util.ArrayList;
  12. import java.util.List;
  13. import javax.servlet.http.HttpServletRequest;
  14. import javax.servlet.http.HttpServletResponse;
  15. import org.apache.poi.hssf.usermodel.HSSFCellStyle;
  16. import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
  17. import org.apache.poi.openxml4j.opc.OPCPackage;
  18. import org.apache.poi.poifs.crypt.EncryptionInfo;
  19. import org.apache.poi.poifs.crypt.EncryptionMode;
  20. import org.apache.poi.poifs.crypt.Encryptor;
  21. import org.apache.poi.poifs.filesystem.POIFSFileSystem;
  22. import org.apache.poi.ss.usermodel.Cell;
  23. import org.apache.poi.ss.usermodel.CellStyle;
  24. import org.apache.poi.ss.usermodel.Font;
  25. import org.apache.poi.ss.usermodel.IndexedColors;
  26. import org.apache.poi.ss.usermodel.Row;
  27. import org.apache.poi.ss.usermodel.Sheet;
  28. import org.apache.poi.ss.usermodel.Workbook;
  29. import org.apache.poi.xssf.usermodel.XSSFWorkbook;
  30. import org.slf4j.Logger;
  31. import org.slf4j.LoggerFactory;
  32. import org.springframework.beans.factory.annotation.Autowired;
  33. import org.springframework.stereotype.Controller;
  34. import org.springframework.transaction.annotation.Propagation;
  35. import org.springframework.transaction.annotation.Transactional;
  36. import org.springframework.web.bind.annotation.ModelAttribute;
  37. import org.springframework.web.bind.annotation.RequestMapping;
  38. import org.springframework.web.bind.annotation.RequestMethod;
  39. import org.springframework.web.bind.annotation.RequestParam;
  40. import org.springframework.web.bind.annotation.ResponseBody;
  41. import org.springframework.web.servlet.ModelAndView;
  42. import com.lemon.lifecenter.common.LifeCenterConfigVO;
  43. import com.lemon.lifecenter.common.LifeCenterController;
  44. import com.lemon.lifecenter.common.LifeCenterFileDownload;
  45. import com.lemon.lifecenter.common.LifeCenterFunction;
  46. import com.lemon.lifecenter.common.LifeCenterPaging;
  47. import com.lemon.lifecenter.common.LifeCenterSessionController;
  48. import com.lemon.lifecenter.dto.CenterInfoDTO;
  49. import com.lemon.lifecenter.dto.ClinicConfigurationDTO;
  50. import com.lemon.lifecenter.dto.FileDownloadDTO;
  51. import com.lemon.lifecenter.dto.LocationDTO;
  52. import com.lemon.lifecenter.dto.LoginDTO;
  53. import com.lemon.lifecenter.dto.StaffDTO;
  54. import com.lemon.lifecenter.service.CenterService;
  55. import com.lemon.lifecenter.service.ClinicService;
  56. import com.lemon.lifecenter.service.FileDownloadService;
  57. import com.lemon.lifecenter.service.LoginService;
  58. import com.lemon.lifecenter.service.StaffService;
  59. // 생활치료센터관리 contorller
  60. @Controller
  61. @RequestMapping("/center")
  62. public class CenterController extends LifeCenterController {
  63. private final Logger logger = LoggerFactory.getLogger(this.getClass());
  64. @Autowired
  65. private CenterService centerService;
  66. @Autowired
  67. private StaffService memberService;
  68. @Autowired
  69. private LoginService loginService;
  70. @Autowired
  71. private FileDownloadService fileDownloadService;
  72. @Autowired
  73. private ClinicService clinicService;
  74. @Autowired
  75. private LifeCenterConfigVO config;
  76. private LifeCenterPaging paging;
  77. @RequestMapping("/new")
  78. public ModelAndView centerNew() {
  79. List<LocationDTO> jurisdiction = centerService.selectLocation();
  80. List<LocationDTO> list = centerService.selectLocation();
  81. List<LocationDTO> cooperativeList = centerService.selectCooperativeHospialList();
  82. ModelAndView mv = setMV("center/new");
  83. mv.addObject("jurisdiction", jurisdiction);
  84. mv.addObject("cooperativeList", cooperativeList);
  85. list.remove(list.size()-1);
  86. mv.addObject("locationList", list);
  87. return mv;
  88. }
  89. @RequestMapping("/new/regist")
  90. @Transactional(propagation=Propagation.REQUIRED)
  91. public String centerNewRegist(
  92. @ModelAttribute("dto") final CenterInfoDTO dto,
  93. @RequestParam(value="detailAddr", required=true) String detailAddr,
  94. @RequestParam(value="staffId", required=true) String staffId,
  95. @RequestParam(value="staffPw", required=true) String staffPw,
  96. @RequestParam(value="staffName", required=true) String staffName,
  97. @RequestParam(value="staffPhoneNumber", required=true) String staffPhoneNumber) throws Exception {
  98. String centerAddress = dto.getCenterAddress() + "|" + detailAddr;
  99. dto.setCenterAddress(centerAddress);
  100. StaffDTO mDto = new StaffDTO();
  101. centerService.insertCenter(dto);
  102. int centerCode = dto.getCenterCode();
  103. ClinicConfigurationDTO clinicConfig = new ClinicConfigurationDTO();
  104. clinicConfig.setCenterCode(centerCode);
  105. clinicService.insertConfiguration(clinicConfig);
  106. mDto.setCenterCode(centerCode);
  107. mDto.setId(staffId);
  108. // mDto.setPassword(LifeCenterFunction.aesEncrypt(config.aesKey, config.IV, staffPw));
  109. mDto.setPassword(LifeCenterFunction.sha256Encrypt(staffPw));
  110. mDto.setName(staffName);
  111. mDto.setPhoneNumber(staffPhoneNumber);
  112. mDto.setGroupIdx( 2 ); // 1: 시스템관리자 2:관리자 3:일반사용자, 센터신규등록시 아이디생성은 관리자 권한으로 생성, 센터하나에 관리자 1명으로 개발진행
  113. memberService.inserMember(mDto);
  114. return "redirect:/center/info?centerCode=" + dto.getCenterCode();
  115. }
  116. @RequestMapping("/info")
  117. public ModelAndView centerInfo(
  118. @RequestParam(value="centerCode", required=true) int centerCode) {
  119. CenterInfoDTO dto = new CenterInfoDTO();
  120. dto.setCenterCode(centerCode);
  121. dto = centerService.selectCenterInfo(dto);
  122. dto.setStaffPhoneNumber( LifeCenterFunction.phone( dto.getStaffPhoneNumber() ) );
  123. dto.setCenterNumber( LifeCenterFunction.phone( dto.getCenterNumber() ) );
  124. ModelAndView mv = setMV("center/info");
  125. String centerAddress = dto.getCenterAddress().split( "|" )[0];
  126. String detailAddress = dto.getCenterAddress().split( "|" )[1];
  127. mv.addObject("centerInfo", dto);
  128. mv.addObject( "centerAddress", centerAddress );
  129. mv.addObject( "detailAddress", detailAddress );
  130. mv.addObject("centerCode", centerCode);
  131. return mv;
  132. }
  133. @RequestMapping("/edit/update")
  134. @Transactional(propagation=Propagation.REQUIRED, rollbackFor = { RuntimeException.class, Error.class })
  135. public String centerEditUpdate(
  136. @ModelAttribute("dto") final CenterInfoDTO dto,
  137. @RequestParam(value="detailAddr", required=true) String detailAddr,
  138. @RequestParam(value="staffId", required=true) String staffId,
  139. @RequestParam(value="staffName", required=true) String staffName,
  140. @RequestParam(value="staffPhoneNumber", required=true) String staffPhoneNumber,
  141. HttpServletRequest request, HttpServletResponse response ) throws Exception {
  142. String sesGroupIdx = LifeCenterSessionController.getSession( request, "sesGroupIdx" );
  143. String referer = request.getHeader( "Referer" );
  144. if( !sesGroupIdx.equals( "1" ) ) {
  145. LifeCenterFunction.scriptMessage( response, "alertBox({ txt : '권한이 없습니다.', callBack : function(){ location.href='" + referer + "'} });" );
  146. return "/common/blank";
  147. } else {
  148. StaffDTO memberDTO = new StaffDTO();
  149. LoginDTO loginDTO = new LoginDTO();
  150. loginDTO.setId( staffId );
  151. int memberTotal = loginService.selectMemberIdCount( loginDTO );
  152. if( memberTotal == 1 ) {
  153. String address = dto.getCenterAddress() + "|" + detailAddr;
  154. dto.setCenterAddress( address );
  155. int result = centerService.updateCenterInfo( dto );
  156. if (result > 0) {
  157. memberDTO.setId( staffId );
  158. memberDTO.setName( staffName );
  159. memberDTO.setPhoneNumber(staffPhoneNumber);
  160. memberService.updateMember( memberDTO );
  161. }
  162. } else {
  163. LifeCenterFunction.scriptMessage( response, "alertBox({ txt : '비밀번호가 일치하지않습니다.', callBack : function(){ location.href='../edit?centerCode="+dto.getCenterCode()+"'} });" );
  164. return "/common/blank";
  165. }
  166. }
  167. return "redirect:/center/info?centerCode=" + dto.getCenterCode();
  168. }
  169. @RequestMapping("/edit")
  170. public ModelAndView centerEdit(
  171. @RequestParam(value="centerCode", required=true) int centerCode) {
  172. List<LocationDTO> jurisdiction = centerService.selectLocation();
  173. List<LocationDTO> list = centerService.selectLocation();
  174. List<LocationDTO> cooperativeList = centerService.selectCooperativeHospialList();
  175. CenterInfoDTO dto = new CenterInfoDTO();
  176. dto.setCenterCode(centerCode);
  177. dto = centerService.selectCenterInfo(dto);
  178. String address = dto.getCenterAddress();
  179. String mainAddr = "";
  180. String detailAddr = "";
  181. if (address.contains("|") == true) {
  182. String[] strAr = dto.getCenterAddress().split("[|]");
  183. mainAddr = strAr[0];
  184. detailAddr = strAr[1];
  185. } else {
  186. mainAddr = address;
  187. }
  188. ModelAndView mv = setMV("center/edit");
  189. list.remove(list.size()-1);
  190. mv.addObject("locationList", list);
  191. mv.addObject("jurisdiction", jurisdiction);
  192. mv.addObject("cooperativeList", cooperativeList);
  193. mv.addObject("centerInfo", dto);
  194. mv.addObject("mainAddr", mainAddr);
  195. mv.addObject("detailAddr", detailAddr);
  196. return mv;
  197. }
  198. @RequestMapping("/list")
  199. public ModelAndView centerList(
  200. @ModelAttribute("dto") final CenterInfoDTO dto,
  201. @RequestParam(value="page", required=false, defaultValue="1") int page,
  202. @RequestParam(value="centerName", required=false, defaultValue="") String centerName,
  203. @RequestParam(value="locationCode", required=false, defaultValue="") String locationCode,
  204. @RequestParam(value="startDate", required=false, defaultValue="") String startDate,
  205. @RequestParam(value="endDate", required=false, defaultValue="") String endDate) {
  206. dto.setLimit( ( Integer.valueOf( page ) - 1 ) * config.pageDataSize );
  207. dto.setLimitMax( config.pageDataSize );
  208. List<LocationDTO> list = centerService.selectLocation();
  209. int total = centerService.selectCenterCount(dto);
  210. List<CenterInfoDTO> result = new ArrayList<CenterInfoDTO>();
  211. if (total > 0) {
  212. result = centerService.selectCenterList(dto);
  213. for( CenterInfoDTO temp : result ) {
  214. result.get( result.indexOf( temp ) ).setStaffPhoneNumber( LifeCenterFunction.phone( temp.getStaffPhoneNumber() ) );
  215. }
  216. }
  217. String param = "centerName=" + dto.getCenterName() + "&locationCode=" + dto.getLocationCode() + "&startDate=" + dto.getStartDate() + "&endDate=" + dto.getEndDate() + "&useYn=" + dto.getUseYn();
  218. paging = LifeCenterPaging.getInstance();
  219. paging.paging(config, total, page, param);
  220. ModelAndView mv = setMV("center/list");
  221. // startDate = startDate.equals( "" ) ? LifeCenterFunction.getNow( "yyyy-MM-dd" ) : startDate;
  222. // endDate = endDate.equals( "" ) ? LifeCenterFunction.getNow( "yyyy-MM-dd" ) : endDate;
  223. mv.addObject("locationList", list);
  224. mv.addObject("locationCode", locationCode);
  225. mv.addObject("startDate", startDate);
  226. mv.addObject("endDate", endDate);
  227. mv.addObject("useYn", dto.getUseYn());
  228. mv.addObject("centerName", centerName);
  229. mv.addObject("total", total);
  230. mv.addObject("item", result);
  231. mv.addObject("paging", paging);
  232. mv.addObject("page", page);
  233. mv.addObject("pageSize", dto.getLimitMax());
  234. return mv;
  235. }
  236. @RequestMapping( value="/passwordReset", method = RequestMethod.POST )
  237. @ResponseBody
  238. public boolean passwordReset(
  239. @RequestParam( value="staffId", required = true ) String id,
  240. @RequestParam( value="type", required = true ) String type) throws Exception {
  241. boolean result = false;
  242. String pw = "";
  243. StaffDTO dto = new StaffDTO();
  244. dto.setId(id);
  245. if (type.equals("staff")) {
  246. // pw = LifeCenterFunction.aesEncrypt(config.aesKey, config.IV, config.staffResetPw);
  247. pw = LifeCenterFunction.sha256Encrypt(config.staffResetPw);
  248. } else {
  249. // pw = LifeCenterFunction.aesEncrypt(config.aesKey, config.IV, config.centerResetPw);
  250. pw = LifeCenterFunction.sha256Encrypt(config.centerResetPw);
  251. }
  252. dto.setPassword(pw);
  253. int rts = memberService.updateMemberPwReset(dto);
  254. if (rts == 1) {
  255. result = true;
  256. }
  257. return result;
  258. }
  259. @RequestMapping( value="/excel", method=RequestMethod.POST )
  260. public void getCenterList(
  261. @RequestParam(value="downMemo", required=false, defaultValue="") String downMemo,
  262. HttpServletRequest request,HttpServletResponse response ) {
  263. String userId = LifeCenterSessionController.getSession(request, "sesId");
  264. //excel 다운로드 로그 남기기
  265. FileDownloadDTO fileDTO = new FileDownloadDTO();
  266. fileDTO.setId( userId );
  267. fileDTO.setIp( LifeCenterFunction.getRemoteAddr( request ) );
  268. fileDTO.setUrl( request.getRequestURI().toString() );
  269. fileDTO.setMemo( downMemo );
  270. fileDTO.setEtc( "" );
  271. fileDownloadService.insertExcelDownloadLog( fileDTO );
  272. CenterInfoDTO dto = new CenterInfoDTO();
  273. int total = centerService.selectCenterCount(dto);
  274. List<CenterInfoDTO> result = new ArrayList<CenterInfoDTO>();
  275. if (total > 0) {
  276. dto.setLimit(0);
  277. dto.setLimitMax(total);
  278. result = centerService.selectCenterList(dto);
  279. for( CenterInfoDTO temp : result ) {
  280. result.get( result.indexOf( temp ) ).setStaffPhoneNumber( LifeCenterFunction.phone( temp.getStaffPhoneNumber() ) );
  281. }
  282. }
  283. getCenterListExcel(request, response, result);
  284. }
  285. private void getCenterListExcel(HttpServletRequest request, HttpServletResponse response, List<CenterInfoDTO> data ) {
  286. String password = LifeCenterSessionController.getSession(request, "sesPhoneNumber");
  287. password = password.toLowerCase();
  288. if (!password.equals("null") && !password.equals( "" )) {
  289. password = password.replace("-", "");
  290. password = password.substring(3).trim();
  291. } else {
  292. password = "";
  293. }
  294. Workbook workbook = new XSSFWorkbook();
  295. Sheet sheet1 = workbook.createSheet("firstSheet");
  296. DecimalFormat df = new DecimalFormat("#,###");
  297. //1.셀 스타일 및 폰트 설정
  298. CellStyle styleOfBoardFillFontBlackBold16 = workbook.createCellStyle();
  299. //정렬
  300. styleOfBoardFillFontBlackBold16.setAlignment(CellStyle.ALIGN_CENTER); //가운데 정렬
  301. styleOfBoardFillFontBlackBold16.setVerticalAlignment(CellStyle.VERTICAL_CENTER); //높이 가운데 정렬
  302. //배경색
  303. styleOfBoardFillFontBlackBold16.setFillForegroundColor(IndexedColors.LIGHT_YELLOW.getIndex());
  304. styleOfBoardFillFontBlackBold16.setFillPattern(CellStyle.SOLID_FOREGROUND);
  305. //테두리 선 (우,좌,위,아래)
  306. styleOfBoardFillFontBlackBold16.setBorderRight(HSSFCellStyle.BORDER_THIN);
  307. styleOfBoardFillFontBlackBold16.setBorderLeft(HSSFCellStyle.BORDER_THIN);
  308. styleOfBoardFillFontBlackBold16.setBorderTop(HSSFCellStyle.BORDER_THIN);
  309. styleOfBoardFillFontBlackBold16.setBorderBottom(HSSFCellStyle.BORDER_THIN);
  310. //폰트 설정
  311. Font fontOfGothicBlackBold16 = workbook.createFont();
  312. // fontOfGothicBlackBold16.setFontName("나눔고딕"); //글씨체
  313. fontOfGothicBlackBold16.setFontHeight((short)(10*20)); //사이즈
  314. fontOfGothicBlackBold16.setBoldweight(Font.BOLDWEIGHT_BOLD); //볼드 (굵게)
  315. styleOfBoardFillFontBlackBold16.setFont(fontOfGothicBlackBold16);
  316. int i = 1;
  317. Row row = sheet1.createRow(0);
  318. Cell cell1 = row.createCell(0);
  319. Cell cell2 = row.createCell(1);
  320. Cell cell3 = row.createCell(2);
  321. Cell cell4 = row.createCell(3);
  322. Cell cell5 = row.createCell(4);
  323. Cell cell6 = row.createCell(5);
  324. Cell cell7 = row.createCell(6);
  325. Cell cell8 = row.createCell(7);
  326. Cell cell9 = row.createCell(8);
  327. Cell cell10 = row.createCell(9);
  328. Cell cell11 = row.createCell(10);
  329. Cell cell12 = row.createCell(11);
  330. Cell cell13 = row.createCell(12);
  331. Cell cell14 = row.createCell(13);
  332. cell1.setCellStyle(styleOfBoardFillFontBlackBold16);
  333. cell2.setCellStyle(styleOfBoardFillFontBlackBold16);
  334. cell3.setCellStyle(styleOfBoardFillFontBlackBold16);
  335. cell4.setCellStyle(styleOfBoardFillFontBlackBold16);
  336. cell5.setCellStyle(styleOfBoardFillFontBlackBold16);
  337. cell6.setCellStyle(styleOfBoardFillFontBlackBold16);
  338. cell7.setCellStyle(styleOfBoardFillFontBlackBold16);
  339. cell8.setCellStyle(styleOfBoardFillFontBlackBold16);
  340. cell9.setCellStyle(styleOfBoardFillFontBlackBold16);
  341. cell10.setCellStyle(styleOfBoardFillFontBlackBold16);
  342. cell11.setCellStyle(styleOfBoardFillFontBlackBold16);
  343. cell12.setCellStyle(styleOfBoardFillFontBlackBold16);
  344. cell13.setCellStyle(styleOfBoardFillFontBlackBold16);
  345. cell14.setCellStyle(styleOfBoardFillFontBlackBold16);
  346. sheet1.setColumnWidth( 0, 10000); //생활치료센터명
  347. sheet1.setColumnWidth( 1, 5000); //지역
  348. sheet1.setColumnWidth( 2, 5000); //소관
  349. sheet1.setColumnWidth( 3, 8000); //협력병원
  350. sheet1.setColumnWidth( 4, 6000); //담당자 이름
  351. sheet1.setColumnWidth( 5, 4000); //담당자 아이디
  352. sheet1.setColumnWidth( 6, 4000); //담당자 전화번호
  353. sheet1.setColumnWidth( 7, 4000); //전화번호
  354. sheet1.setColumnWidth( 8, 2500); //의료진수
  355. sheet1.setColumnWidth( 9, 2500); //환자 총 수용인원
  356. sheet1.setColumnWidth( 10, 2500); //입소자수
  357. sheet1.setColumnWidth( 11, 2500); //퇴소자수
  358. sheet1.setColumnWidth( 12, 2500); //지정병원이송
  359. sheet1.setColumnWidth( 13, 2500); //기타
  360. cell1.setCellValue("생활치료센터명");
  361. cell2.setCellValue("지역");
  362. cell3.setCellValue("소관");
  363. cell4.setCellValue("협력병원");
  364. cell5.setCellValue("담당자 이름");
  365. cell6.setCellValue("담당자 아이디");
  366. cell7.setCellValue("담당자 전화번호");
  367. cell8.setCellValue("전화번호");
  368. cell9.setCellValue("의료진수");
  369. cell10.setCellValue("환자 총 수용인원");
  370. cell11.setCellValue("입소자수");
  371. cell12.setCellValue("퇴소자수");
  372. cell13.setCellValue("지정병원이송");
  373. cell14.setCellValue("기타");
  374. for (CenterInfoDTO dto : data) {
  375. row = sheet1.createRow(i);
  376. cell1 = row.createCell(0);
  377. cell2 = row.createCell(1);
  378. cell3 = row.createCell(2);
  379. cell4 = row.createCell(3);
  380. cell5 = row.createCell(4);
  381. cell6 = row.createCell(5);
  382. cell7 = row.createCell(6);
  383. cell8 = row.createCell(7);
  384. cell9 = row.createCell(8);
  385. cell10 = row.createCell(9);
  386. cell11 = row.createCell(10);
  387. cell12 = row.createCell(11);
  388. cell13 = row.createCell(12);
  389. cell14 = row.createCell(13);
  390. String centerName = dto.getCenterName();
  391. String locationName = dto.getLocationName();
  392. String jurisdictionName = dto.getJurisdictionName();
  393. String cooperativeName = dto.getCooperativeName();
  394. String staffName = dto.getStaffName();
  395. String staffId = dto.getStaffId();
  396. String staffPhoneNumber = dto.getStaffPhoneNumber();
  397. String centerNumber = dto.getCenterNumber();
  398. int medicalTotal = dto.getTotalStaff();
  399. int patientTotal = dto.getTotalCapacity();
  400. int patientTotalH = dto.getTotalPatientH();
  401. int patientTotalD = dto.getTotalPatientD();
  402. int patientTotalT = dto.getTotalPatientT();
  403. int patientTotalE = dto.getTotalPatientE();
  404. cell1.setCellValue(centerName);
  405. cell2.setCellValue(locationName);
  406. cell3.setCellValue(jurisdictionName);
  407. cell4.setCellValue(cooperativeName);
  408. cell5.setCellValue(staffName);
  409. cell6.setCellValue(staffId);
  410. cell7.setCellValue(staffPhoneNumber);
  411. cell8.setCellValue(centerNumber);
  412. cell9.setCellValue(medicalTotal);
  413. cell10.setCellValue(patientTotal);
  414. cell11.setCellValue(patientTotalH);
  415. cell12.setCellValue(patientTotalD);
  416. cell13.setCellValue(patientTotalT);
  417. cell14.setCellValue(patientTotalE);
  418. i++;
  419. }
  420. row = sheet1.createRow(i);
  421. cell1 = row.createCell(2);
  422. cell2 = row.createCell(3);
  423. cell3 = row.createCell(4);
  424. cell4 = row.createCell(5);
  425. cell5 = row.createCell(6);
  426. cell6 = row.createCell(7);
  427. cell7 = row.createCell(8);
  428. cell8 = row.createCell(9);
  429. cell9 = row.createCell(10);
  430. cell10 = row.createCell(11);
  431. cell11 = row.createCell(12);
  432. cell12 = row.createCell(13);
  433. cell13 = row.createCell(14);
  434. cell14 = row.createCell(15);
  435. try {
  436. // File file = new File(".");
  437. // String rootPath = file.getAbsolutePath();
  438. // System.out.println("현재 프로젝트의 경로 : "+rootPath );
  439. // JBOSS에서 구동시 /home1/jboss/jboss-eap-7.3/domain/test/excel-temp 경로에 저장이됨
  440. String tempPath = "../excel-temp/testExcel.xlsx";
  441. String downName = LifeCenterFunction.getNow() + " 환자리스트.xlsx";
  442. File xlsFile = new File(tempPath);
  443. // FileOutputStream fileOut = new FileOutputStream(tempPath);
  444. // workbook.write(fileOut);
  445. // fileOut.close();
  446. ByteArrayOutputStream fileOut = new ByteArrayOutputStream();
  447. FileOutputStream fos = new FileOutputStream(tempPath);
  448. workbook.write(fileOut);
  449. InputStream filein = new ByteArrayInputStream(fileOut.toByteArray());
  450. OPCPackage opc = OPCPackage.open(filein);
  451. POIFSFileSystem fileSystem = new POIFSFileSystem();
  452. EncryptionInfo encryptionInfo = new EncryptionInfo(EncryptionMode.agile);
  453. Encryptor encryptor = encryptionInfo.getEncryptor();
  454. encryptor.confirmPassword(password);
  455. opc.save(encryptor.getDataStream(fileSystem));
  456. opc.flush();
  457. fileSystem.writeFilesystem(fos);
  458. fileOut.close();
  459. opc.close();
  460. filein.close();
  461. fileSystem.close();
  462. LifeCenterFileDownload.download(request, response, tempPath, downName);
  463. xlsFile.delete();
  464. } catch (FileNotFoundException e) {
  465. e.printStackTrace();
  466. } catch (IOException e) {
  467. e.printStackTrace();
  468. } catch (InvalidFormatException e) {
  469. // TODO Auto-generated catch block
  470. e.printStackTrace();
  471. } catch (GeneralSecurityException e) {
  472. // TODO Auto-generated catch block
  473. e.printStackTrace();
  474. }
  475. }
  476. }