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.io.UnsupportedEncodingException; import java.lang.reflect.Field; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.security.GeneralSecurityException; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Base64; import java.util.HashMap; import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; 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.CenterInfoDTO; import com.lemon.lifecenter.dto.FileDownloadDTO; import com.lemon.lifecenter.dto.PatientDTO; import com.lemon.lifecenter.dto.PrivateLogDTO; import com.lemon.lifecenter.dto.PushDTO; import com.lemon.lifecenter.dto.StaffDTO; import com.lemon.lifecenter.service.CenterService; import com.lemon.lifecenter.service.FileDownloadService; import com.lemon.lifecenter.service.PatientService; import com.lemon.lifecenter.service.PrivateLogService; import com.lemon.lifecenter.service.PushService; import com.lemon.lifecenter.service.StaffService; import org.apache.poi.hssf.usermodel.HSSFCellStyle; 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.xssf.usermodel.XSSFWorkbook; import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.servlet.ModelAndView; @Controller @RequestMapping("/patient") //@DependsOn(value = {"LifeCenterPaging"}) public class PatientController extends LifeCenterController { @Autowired private PatientService patientService; @Autowired private CenterService centerService; @Autowired private StaffService staffService; @Autowired private FileDownloadService fileDownloadService; @Autowired private PushService pushService; @Autowired private LifeCenterConfigVO config; @Autowired private PrivateLogService privateLogService; private LifeCenterPaging paging; private final Logger logger = LoggerFactory.getLogger(this.getClass()); @RequestMapping("/list") public ModelAndView patientList( @RequestParam(value="inputState", required=false, defaultValue="ALL") String inputState, @RequestParam(value="patientName", required=false, defaultValue="") String patientName, @RequestParam(value="startDate", required=false, defaultValue="") String startDate, @RequestParam(value="endDate", required=false, defaultValue="") String endDate, @RequestParam(value="page", required=false, defaultValue="1") int page, @RequestParam(value="sortType", required=false, defaultValue="patient_name") String sortType, @RequestParam(value="sort", required=false, defaultValue="desc") String sort, @RequestParam(value="cla", required=false, defaultValue="") String cla, @RequestParam(value="dateType", required=false, defaultValue="") String dateType, HttpServletRequest request,HttpServletResponse response) { String sesId = LifeCenterSessionController.getSession( request, "sesId" ); String sesCenterCode = LifeCenterSessionController.getSession( request, "sesCenterCode" ); String sesGroupIdx = LifeCenterSessionController.getSession( request, "sesGroupIdx" ); String sesName = LifeCenterSessionController.getSession( request, "sesName" ); String sesCenterName = LifeCenterSessionController.getSession( request, "sesCenterName" ); String logCenterName = !sesCenterName.equals( "" )? "["+sesCenterName+"] " : ""; String processingContents = "환자리스트 조회"; PrivateLogDTO logDTO = new PrivateLogDTO(); logDTO.setId( sesId ); logDTO.setAccessorDetail( logCenterName + sesName + " (" + sesId + ")" ); logDTO.setIp( LifeCenterFunction.getRemoteAddr( request ) ); logDTO.setFullUrl( LifeCenterFunction.getFullURL( request ) ); logDTO.setProcessingTarget( "" ); logDTO.setProcessingContents( processingContents ); // privateLogService.insertPrivateAccessLog( logDTO ); PatientDTO dto = new PatientDTO(); dto.setCenterCode(Integer.parseInt(sesCenterCode)); dto.setGroupIdx( Integer.valueOf( sesGroupIdx ) ); dto.setPatientName(patientName); dto.setState(inputState); dto.setStartDate(startDate); dto.setEndDate(endDate); dto.setSortType(sortType); dto.setSort(sort); dto.setLimit( ( Integer.valueOf( page ) - 1 ) * config.pageDataSize ); dto.setLimitMax( config.pageDataSize ); dto.setCla(cla); dto.setDateType(dateType); int total = patientService.selectPatientCount(dto); List result = new ArrayList(); if (total > 0) { result = patientService.selectPatientList(dto); for( PatientDTO temp : result ) { // logger.error("temp -- > " + result.get( result.indexOf( temp ) ).getJumin()); // String age = result.get( result.indexOf( temp ) ).getJumin(); // try { // age = String.valueOf(LifeCenterFunction.getAgeFromBirthday(age)); // } catch (ParseException e) { // // TODO Auto-generated catch block // e.printStackTrace(); // } // result.get( result.indexOf( temp ) ).setAge(age); result.get( result.indexOf( temp ) ).setSymptomContent( LifeCenterFunction.getSymptom( temp ) ); } } ModelAndView mv = setMV("patient/list"); String param = ""; try { param = "patientName=" + URLEncoder.encode(patientName, "UTF-8") + "&inputState=" + inputState + "&startDate=" + startDate + "&endDate=" + endDate + "&sortType=" + sortType + "&sort=" + sort + "&cla=" + cla + "&dateType=" + dateType; } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } paging = LifeCenterPaging.getInstance(); paging.paging(config, total, page, param); CenterInfoDTO cDTO = new CenterInfoDTO(); List centerListAll = new ArrayList(); centerListAll = centerService.selectCenterListAllYn(cDTO); mv.addObject("inputState", inputState); mv.addObject("patientName", patientName); mv.addObject("total", total); mv.addObject("item", result); mv.addObject("paging", paging); mv.addObject( "startDate", startDate ); mv.addObject( "endDate", endDate ); mv.addObject( "page", page ); mv.addObject( "pageSize", dto.getLimitMax() ); mv.addObject( "sesGroupIdx" , sesGroupIdx ); mv.addObject("sort", sort); mv.addObject("sortType", sortType); mv.addObject("centerListAll", centerListAll); mv.addObject("selectCode", cla); mv.addObject("dateType", dateType); return mv; } @RequestMapping("/new") public ModelAndView patientNew( HttpServletRequest request,HttpServletResponse response ) { ModelAndView mv = setMV("patient/new"); String sesCenterCode = LifeCenterSessionController.getSession( request, "sesCenterCode" ); String sesId = LifeCenterSessionController.getSession( request, "sesId" ); String sesName = LifeCenterSessionController.getSession( request, "sesName" ); String sesCenterName = LifeCenterSessionController.getSession( request, "sesCenterName" ); String logCenterName = !sesCenterName.equals( "" )? "["+sesCenterName+"] " : ""; //개인정보로그 String processingContents = "신규환자등록페이지 접속"; PrivateLogDTO logDTO = new PrivateLogDTO(); logDTO.setId( sesId ); logDTO.setAccessorDetail( logCenterName + sesName + " (" + sesId + ")" ); logDTO.setIp( LifeCenterFunction.getRemoteAddr( request ) ); logDTO.setFullUrl( LifeCenterFunction.getFullURL( request ) ); logDTO.setProcessingTarget( "" ); logDTO.setProcessingContents( processingContents ); // privateLogService.insertPrivateAccessLog( logDTO ); // 세션의 센터코드 들고와서 치료센터명 조회후 view 전달 CenterInfoDTO dto = new CenterInfoDTO(); dto.setCenterCode( Integer.valueOf( sesCenterCode ) ); dto.setStaffId( sesId ); int centerCount = centerService.selectCenterOneCount( dto ); String centerName = ""; if( centerCount > 0 ) { centerName = centerService.selectCenterInfoOne( dto ).getCenterName(); } StaffDTO staffDTO = new StaffDTO(); List staffList = new ArrayList(); staffDTO.setGroupIdx( 2 ); //2설정 set 조회시 해당센터 모든 의료진 리스트표출 staffDTO.setCenterCode( Integer.valueOf( sesCenterCode ) ); staffDTO.setUseYn( "" ); int staffCount = staffService.selectMemberListCount( staffDTO ); if( staffCount > 0 ) { staffDTO.setLimit( 0 ); staffDTO.setLimitMax( staffCount ); staffList = staffService.selectMemberList( staffDTO ); } mv.addObject( "centerName", centerName ); mv.addObject( "centerCount", centerCount ); mv.addObject( "actionType", "new" ); mv.addObject( "staffList", staffList ); return mv; } @RequestMapping("/new/insert") @Transactional(propagation=Propagation.REQUIRED) public String patientNewInsert( @ModelAttribute("dto") final PatientDTO dto, HttpServletRequest request,HttpServletResponse response ) throws Exception { int sesCenterCode = Integer.valueOf( LifeCenterSessionController.getSession( request, "sesCenterCode" ) ) ; String sesId = LifeCenterSessionController.getSession( request, "sesId" ); String sesName = LifeCenterSessionController.getSession( request, "sesName" ); String sesCenterName = LifeCenterSessionController.getSession( request, "sesCenterName" ); String logCenterName = !sesCenterName.equals( "" )? "["+sesCenterName+"] " : ""; //patientCare Insert //System.out.println( "dto.getJumin().substring(2) : " + dto.getJumin().replace( "-" , "" ).substring(2) ); String jumin = dto.getJumin(); jumin = LifeCenterFunction.removeStringChar(jumin, "-"); dto.setJumin( jumin ); dto.setId( dto.getWardNumber().trim() + dto.getRoomNumber().trim() ); // 환자 password는 생년월일(yyyymmdd)을 암호화 // dto.setPw( LifeCenterFunction.aesEncrypt( config.aesKey, config.IV, jumin ) ); // dto.setPw( LifeCenterFunction.sha256Encrypt( jumin ) ); dto.setPw(jumin); dto.setCenterCode( sesCenterCode ); dto.setState( "H" ); // H : 입소 dto.setCreateBy( sesId ); if( dto.getDisisolationDate() != null && dto.getDisisolationDate().equals( "" ) ) { dto.setDisisolationDate( null ); } if( dto.getSymptomStartDate() != null && dto.getSymptomStartDate().equals( "" ) ) { dto.setSymptomStartDate( null ); } if (dto.getExpectedDischargeDate() != null && dto.getExpectedDischargeDate().equals("")) { dto.setExpectedDischargeDate(null); } // base64 decode 주민뒷자리 if (!dto.getResidentNumberLast().equals("")) { byte[] decoded = Base64.getDecoder().decode(dto.getResidentNumberLast()); dto.setResidentNumberLast(new String(decoded, StandardCharsets.UTF_8)); } // base64 decode 외국인등록번호 뒷자리 if (!dto.getForeignNumberLast().equals("")) { byte[] decoded = Base64.getDecoder().decode(dto.getForeignNumberLast()); dto.setForeignNumberLast(new String(decoded, StandardCharsets.UTF_8)); } // base64 decode 여권번호 if (!dto.getPassportNumber().equals("")) { byte[] decoded = Base64.getDecoder().decode(dto.getPassportNumber()); dto.setPassportNumber(new String(decoded, StandardCharsets.UTF_8)); } patientService.insertPatientCare( dto ); // 환지 기본정보 insert int patientIdx = dto.getPatientIdx(); //개인정보로그 String processingContents = "신규환자 생성"; PrivateLogDTO logDTO = new PrivateLogDTO(); logDTO.setId( sesId ); logDTO.setAccessorDetail( logCenterName + sesName + " (" + sesId + ")" ); logDTO.setIp( LifeCenterFunction.getRemoteAddr( request ) ); logDTO.setFullUrl( LifeCenterFunction.getFullURL( request ) ); logDTO.setProcessingTarget( "(환자)" + dto.getPatientName() + "["+dto.getPatientIdx()+"]" ); logDTO.setProcessingContents( processingContents ); // privateLogService.insertPrivateAccessLog( logDTO ); dto.setPatientIdx( patientIdx ); //patientDisease Insert dto.setEtcCheck( dto.getEtcCheckDisease() ); dto.setEtcContent( dto.getEtcContentDisease() ); patientService.insertPatientDisease( dto ); //patientSymptom Insert dto.setEtcCheck( dto.getEtcCheckSymptom() ); dto.setEtcContent( dto.getEtcContentSymptom() ); dto.setBloodPressureLevel( dto.getBloodPressureLevelCon() + "|" + dto.getBloodPressureLevelRel() ); // patientService.insertPatientSymptom( dto ); return "redirect:/patient/info?patientIdx=" + patientIdx; } @RequestMapping("/info") public ModelAndView patientInfo( @ModelAttribute("dto") PatientDTO dto, HttpServletRequest request,HttpServletResponse response ) throws Exception { String referer = request.getHeader("referer"); ModelAndView mv = setMV("patient/info"); int patientIdx = dto.getPatientIdx(); String sesId = LifeCenterSessionController.getSession( request, "sesId" ); String sesName = LifeCenterSessionController.getSession( request, "sesName" ); String sesCenterName = LifeCenterSessionController.getSession( request, "sesCenterName" ); String logCenterName = !sesCenterName.equals( "" )? "["+sesCenterName+"] " : ""; dto = patientService.selectPatientOne(dto); //개인정보로그 String processingContents = "환자상세 조회 "; PrivateLogDTO logDTO = new PrivateLogDTO(); logDTO.setId( sesId ); logDTO.setAccessorDetail( logCenterName + sesName + " (" + sesId + ")" ); logDTO.setIp( LifeCenterFunction.getRemoteAddr( request ) ); logDTO.setFullUrl( LifeCenterFunction.getFullURL( request ) ); logDTO.setProcessingTarget( "(환자)" + dto.getPatientName() + "["+dto.getPatientIdx()+"]" ); logDTO.setProcessingContents( processingContents ); // privateLogService.insertPrivateAccessLog( logDTO ); String jumin = dto.getJumin(); jumin = LifeCenterFunction.changeJuminToBirthday(jumin); dto.setJumin(jumin); dto.setPatientPhone(LifeCenterFunction.phone(dto.getPatientPhone())); dto.setGuardianPhone(LifeCenterFunction.phone(dto.getGuardianPhone())); String bloodPress = dto.getBloodPressureLevel(); try { if (!bloodPress.equals("") && !bloodPress.equals("|")) { String[] bloodPressureLevel = bloodPress.split("[|]"); if (bloodPressureLevel[0] != null) { dto.setBloodPressureLevelCon(bloodPressureLevel[0]); } if (bloodPressureLevel[1] != null) { dto.setBloodPressureLevelRel(bloodPressureLevel[1]); } } } catch (Exception e) { //TODO: handle exception dto.setBloodPressureLevelCon("0"); dto.setBloodPressureLevelRel("0"); } String strDisease = ""; String strSymptom = LifeCenterFunction.getSymptom(dto); if (dto.getBasalDiseaseYn().equals("Y")) { strDisease = LifeCenterFunction.getDisease(dto); } StaffDTO staffDTO = new StaffDTO(); List staffList = new ArrayList(); staffDTO.setGroupIdx( 2 ); //2설정 set 조회시 해당센터 모든 의료진 리스트표출 staffDTO.setCenterCode( Integer.valueOf( dto.getCenterCode() ) ); staffDTO.setUseYn( "" ); int staffCount = staffService.selectMemberListCount( staffDTO ); if( staffCount > 0 ) { staffDTO.setLimit( 0 ); staffDTO.setLimitMax( staffCount ); staffList = staffService.selectMemberList( staffDTO ); } CenterInfoDTO cdto = new CenterInfoDTO(); List centerListAll = centerService.selectCenterListAll( cdto ); mv.addObject( "disease", strDisease ); mv.addObject( "symptom", strSymptom ); mv.addObject( "patientIdx", patientIdx ); mv.addObject( "enIdx", LifeCenterFunction.aesEncrypt( config.aesKey, config.IV, String.valueOf( patientIdx ) ) ); mv.addObject( "info", dto ); mv.addObject( "staffList", staffList ); mv.addObject( "referer", referer ); mv.addObject( "centerListAll", centerListAll ); return mv; } @RequestMapping( value="/changeCenterInfo", method=RequestMethod.POST ) @Transactional(propagation=Propagation.REQUIRED) public String changeCenterInfo( @RequestParam(value="oldCenterCode", required=true ) int oldCenterCode, @RequestParam(value="newCenterCode", required=true ) int newCenterCode, @RequestParam(value="oldCenterName", required=true ) String oldCenterName, @RequestParam(value="newCenterName", required=true ) String newCenterName, @RequestParam(value="patientIdx", required=true ) int patientIdx, @RequestParam(value="patientName", required=true ) String patientName, HttpServletRequest request,HttpServletResponse response ) { String sesId = LifeCenterSessionController.getSession( request, "sesId" ); String comment = patientName+"[patient_idx:"+13+"] - " + oldCenterName + "[center_code:"+oldCenterCode+"] => " + newCenterName + "[center_code:"+newCenterCode+"]"; PatientDTO dto = new PatientDTO(); dto.setOldCenterCode( oldCenterCode ); dto.setNewCenterCode( newCenterCode ); dto.setPatientIdx( patientIdx ); dto.setUpdateBy( sesId ); dto.setComment( comment ); // System.err.println( "comment : " + comment ); patientService.updatePatientCenterInfo(dto); patientService.insertCenterChangeLog(dto); return "redirect:/patient/list"; } @RequestMapping("/delete") @Transactional(propagation=Propagation.REQUIRED) public String patientDelete( @RequestParam( value="enIdx", required = true ) String enIdx, @RequestParam( value="deleteReason", required = false, defaultValue = "" ) String deleteReason, HttpServletRequest request,HttpServletResponse response ) throws Exception { String deIdx = LifeCenterFunction.aesDecrypt( config.aesKey, config.IV, enIdx ); int patientIdx = Integer.valueOf( deIdx ); PatientDTO dto = new PatientDTO(); dto.setPatientIdx( patientIdx ); // System.err.println( "patientIdx : " + patientIdx ); int total = patientService.selectPatientOneCount(dto); if( total == 0 ) { LifeCenterFunction.scriptMessage( response, "alertBox({ txt: '이미 삭제되었거나 존재하지않는 환자입니다.', callBack : function(){ history.back(); } });" ); return "/common/blank"; } else { // patientService.deletePatientCare(dto); // 환자데이터를 삭제하지않고 flag 값을 변경 (21.04.12 수정) PatientDTO patientOne = patientService.selectPatientOne(dto); dto.setUseYn( "N" ); dto.setDeleteReason( deleteReason ); patientService.updatePatientCareUseYn(dto); String sesId = LifeCenterSessionController.getSession( request, "sesId" ); String sesName = LifeCenterSessionController.getSession( request, "sesName" ); String sesCenterName = LifeCenterSessionController.getSession( request, "sesCenterName" ); String logCenterName = !sesCenterName.equals( "" )? "["+sesCenterName+"] " : ""; String processingContents = "환자삭제 [사유:"+deleteReason+"]"; PrivateLogDTO logDTO = new PrivateLogDTO(); logDTO.setId( sesId ); logDTO.setAccessorDetail( logCenterName + sesName + " (" + sesId + ")" ); logDTO.setIp( LifeCenterFunction.getRemoteAddr( request ) ); logDTO.setFullUrl( LifeCenterFunction.getFullURL( request ) ); logDTO.setProcessingTarget( "(환자)" + patientOne.getPatientName() + "["+patientOne.getPatientIdx()+"]" ); logDTO.setProcessingContents( processingContents ); // privateLogService.insertPrivateAccessLog( logDTO ); } LifeCenterFunction.scriptMessage( response, "alertBox({ txt: '환자정보가 삭제되었습니다. ', callBack : function(){ location.href='./list'; } });" ); return "/common/blank"; } @RequestMapping("/edit") public ModelAndView patientEdit( @ModelAttribute("dto") PatientDTO patientDTO, HttpServletRequest request,HttpServletResponse response ) { ModelAndView mv = setMV("patient/edit"); String sesCenterCode = LifeCenterSessionController.getSession( request, "sesCenterCode" ); String sesId = LifeCenterSessionController.getSession( request, "sesId" ); int patientIdx = patientDTO.getPatientIdx(); int cnt = patientService.selectPatientOneCount(patientDTO); if (cnt > 0) { patientDTO = patientService.selectPatientOne( patientDTO ); String sesName = LifeCenterSessionController.getSession( request, "sesName" ); String sesCenterName = LifeCenterSessionController.getSession( request, "sesCenterName" ); String logCenterName = !sesCenterName.equals( "" )? "["+sesCenterName+"] " : ""; String processingContents = "환자수정페이지 접속"; PrivateLogDTO logDTO = new PrivateLogDTO(); logDTO.setId( sesId ); logDTO.setAccessorDetail( logCenterName + sesName + " (" + sesId + ")" ); logDTO.setIp( LifeCenterFunction.getRemoteAddr( request ) ); logDTO.setFullUrl( LifeCenterFunction.getFullURL( request ) ); logDTO.setProcessingTarget( "(환자)" + patientDTO.getPatientName() + "["+patientDTO.getPatientIdx()+"]" ); logDTO.setProcessingContents( processingContents ); // privateLogService.insertPrivateAccessLog( logDTO ); // 세션의 센터코드 들고와서 치료센터명 조회후 view 전달 // 센터가 존재하는지 체크 CenterInfoDTO dto = new CenterInfoDTO(); dto.setCenterCode( Integer.valueOf( sesCenterCode ) ); dto.setStaffId( sesId ); String centerName = ""; int centerCount = centerService.selectCenterCount( dto ); if( sesCenterCode.equals( "0" ) ) { //센터코드가 없는 시스템권한 계정인경우 centerName = patientDTO.getCenterName(); } else { if( centerCount > 0 ) { centerName = centerService.selectCenterInfoOne( dto ).getCenterName(); } else { LifeCenterFunction.scriptMessage(response, "alertBox({ txt : '문진이 정상적으로 제출되었습니다.', callBack : function(){ history.back(); } });" ); // return ""; 아직처리안함 } } String bloodPress = patientDTO.getBloodPressureLevel(); try { if (!bloodPress.equals("") && !bloodPress.equals("|")) { String[] bloodPressureLevel = bloodPress.split("[|]"); if (bloodPressureLevel[0] != null) { patientDTO.setBloodPressureLevelCon(bloodPressureLevel[0]); } if (bloodPressureLevel[1] != null) { patientDTO.setBloodPressureLevelRel(bloodPressureLevel[1]); } } } catch (Exception e) { // TODO: handle exception patientDTO.setBloodPressureLevelCon("0"); patientDTO.setBloodPressureLevelRel("0"); } StaffDTO staffDTO = new StaffDTO(); List staffList = new ArrayList(); staffDTO.setGroupIdx( 2 ); //2설정 set 조회시 해당센터 모든 의료진 리스트표출 staffDTO.setCenterCode( Integer.valueOf( sesCenterCode ) ); staffDTO.setUseYn( "" ); int staffCount = staffService.selectMemberListCount( staffDTO ); if( staffCount > 0 ) { staffDTO.setLimit( 0 ); staffDTO.setLimitMax( staffCount ); staffList = staffService.selectMemberList( staffDTO ); } mv.addObject( "centerName", centerName ); mv.addObject( "centerCount", centerCount ); mv.addObject( "staffList", staffList ); mv.addObject( "patientIdx", patientIdx ); mv.addObject( "patientData", patientDTO ); mv.addObject( "actionType", "edit" ); } else { mv.addObject( "error", "error" ); mv.addObject( "message", "삭제되었거나 존재하지 않는 환자입니다." ); } return mv; } @RequestMapping("/edit/update") @Transactional(propagation=Propagation.REQUIRED) public String patientEditUpdate( @ModelAttribute("dto") PatientDTO dto, HttpServletRequest request,HttpServletResponse response ) throws Exception { int sesCenterCode = Integer.valueOf( LifeCenterSessionController.getSession( request, "sesCenterCode" ) ) ; String sesId = LifeCenterSessionController.getSession( request, "sesId" ); int patientIdx = dto.getPatientIdx(); dto.setPatientIdx( patientIdx ); PatientDTO originPatientData = patientService.selectPatientOne( dto ); //patientCare Update String jumin = dto.getJumin(); jumin = LifeCenterFunction.removeStringChar(jumin, "-"); dto.setJumin( jumin ); dto.setId( dto.getWardNumber().trim() + dto.getRoomNumber().trim() ); // dto.setPw( LifeCenterFunction.sha256Encrypt( jumin ) ); dto.setPw(jumin); dto.setCenterCode( sesCenterCode ); dto.setUpdateBy( sesId ); if( dto.getDisisolationDate() != null && dto.getDisisolationDate().equals( "" ) ) { dto.setDisisolationDate( null ); } if( dto.getSymptomStartDate() != null && dto.getSymptomStartDate().equals( "" ) ) { dto.setSymptomStartDate( null ); } logger.error("getPw -- > " + dto.getPw()); patientService.updatePatientCare( dto ); // 환지 기본정보 //patientDisease Insert dto.setEtcCheck( dto.getEtcCheckDisease() ); dto.setEtcContent( dto.getEtcContentDisease() ); patientService.updatePatientDisease( dto ); //patientSymptom Insert dto.setEtcCheck( dto.getEtcCheckSymptom() ); dto.setEtcContent( dto.getEtcContentSymptom() ); dto.setBloodPressureLevel( dto.getBloodPressureLevelCon() + "|" + dto.getBloodPressureLevelRel() ); // System.err.println( dto.toString() ); patientService.updatePatientSymptom( dto ); dto = new PatientDTO(); dto.setPatientIdx( patientIdx ); PatientDTO newPatientData = patientService.selectPatientOne( dto ); String sesName = LifeCenterSessionController.getSession( request, "sesName" ); String sesCenterName = LifeCenterSessionController.getSession( request, "sesCenterName" ); String logCenterName = !sesCenterName.equals( "" )? "["+sesCenterName+"] " : ""; String processingDetail = "[수정내역 :"; PrivateLogDTO logDTO = new PrivateLogDTO(); int cnt = 0; try{ Object objNew=newPatientData; for (Field field : objNew.getClass().getDeclaredFields()){ Object objOrigin=originPatientData; for (Field field1 : objOrigin.getClass().getDeclaredFields()){ if( field1.getName().equals( field.getName() ) ) { field1.setAccessible(true); Object valueOrigin = field1.get(objOrigin); String originVal = valueOrigin == null ? "": valueOrigin.toString(); field.setAccessible(true); Object valueNew=field.get(objNew); String newVal = valueNew == null ? "": valueNew.toString(); // System.err.println(field.getName()+","+originVal + " -> " + newVal); if( !originVal.equals( newVal ) ) { // System.out.println(field.getName()+","+originVal + " -> " + newVal); String nv = cnt >= 1 ? ", " : " "; processingDetail += nv + field.getName()+"컬럼 값 변경 ("+originVal + " -> " + newVal +")"; cnt ++; } } } } processingDetail +="]"; }catch (Exception e){ e.printStackTrace(); } String processingContents = "환자정보 수정 [총 " + cnt + "건 항목] " + processingDetail; //System.err.println( "processingContents : " + processingContents ); logDTO.setId( sesId ); logDTO.setAccessorDetail( logCenterName + sesName + " (" + sesId + ")" ); logDTO.setIp( LifeCenterFunction.getRemoteAddr( request ) ); logDTO.setFullUrl( LifeCenterFunction.getFullURL( request ) ); logDTO.setProcessingTarget( "(환자)" + originPatientData.getPatientName() + "["+originPatientData.getPatientIdx()+"]" ); logDTO.setProcessingContents( processingContents ); // privateLogService.insertPrivateAccessLog( logDTO ); return "redirect:/patient/info?patientIdx=" + patientIdx; } @RequestMapping("/privacy") public ModelAndView patientPrivacy() { ModelAndView mv = setMV("patient/privacy"); return mv; } @RequestMapping( value="/nonFaceStart", method = RequestMethod.POST ) @ResponseBody public String nonFaceStart( @RequestParam( value="pId", required = true ) String pId, @RequestParam( value="patientIdx", required = true ) String patientIdx, @RequestParam( value="roomId", required = true ) String roomId, @RequestParam( value="pName", required = true ) String pName, HttpServletRequest request, HttpServletResponse response) throws Exception { String salt = LifeCenterFunction.getSalt(); String timeStamp = LifeCenterFunction.getTimestamp(); String signature = LifeCenterFunction.getSignature(config.nonFaceApiSecret, salt, timeStamp); String userId = LifeCenterSessionController.getSession(request, "sesId"); String userNm = LifeCenterSessionController.getSession(request, "sesName"); HashMap data = new HashMap(); data.put("api_key", config.nonFaceApiKey); data.put("salt", salt); data.put("timestamp", timeStamp); data.put("signature", signature); data.put("client_id", config.nonFaceClientId); data.put("member_id", userId); String result = LifeCenterFunction.httpUrlConnection(config.nonFaceApiTokenUrl, data); JSONObject object = new JSONObject(result); String message = ""; String token = ""; for(String key : object.keySet()) { if (key.equals("errorCode")) { message = object.getString("message"); } else if (key.equals("token")){ token = object.getString("token"); } } if (!message.equals("")) { //error } else { int sesCenterCode = Integer.valueOf( LifeCenterSessionController.getSession( request, "sesCenterCode" ) ) ; String sesId = LifeCenterSessionController.getSession( request, "sesId" ); String remoteIp = LifeCenterFunction.getRemoteAddr( request ); PushDTO dto = new PushDTO(); dto.setSendType("D"); dto.setTargetType("P"); dto.setPushTitle("비대면 진료"); dto.setPushContent("비대면 진료를 요청하였습니다."); dto.setPushPayLoad1("nonface"); dto.setCenterCode( sesCenterCode ); dto.setSender( sesId ); dto.setSenderIp( remoteIp ); dto.setSendState( "W" ); pushService.insertPushData(dto); dto.setPatientIdx(Integer.valueOf(patientIdx)); pushService.insertPushTargetTemp(dto); } String hashData = LifeCenterFunction.getSignature(config.nonFaceApiSecret, config.nonFaceApiKey, roomId + userId); //"1011503101" object.put("api_key", config.nonFaceApiKey); object.put("member_id", userId); object.put("token", token); object.put("room_id", roomId); object.put("member_name", userNm); object.put("classify", "d"); // p이면 환자 d이면 의사 object.put("hashData", hashData); return object.toString(); } @RequestMapping( value="/excel", method=RequestMethod.POST ) public void getPatientList( @RequestParam(value="downMemo", required=false, defaultValue="") String downMemo, @RequestParam(value="inputState", required=false, defaultValue="ALL") String inputState, @RequestParam(value="patientName", required=false, defaultValue="") String patientName, @RequestParam(value="startDate", required=false, defaultValue="") String startDate, @RequestParam(value="endDate", required=false, defaultValue="") String endDate, @RequestParam(value="excelDateYm", required=false, defaultValue="") String excelDateYm, @RequestParam(value="page", required=false, defaultValue="1") int page, HttpServletRequest request,HttpServletResponse response ) { String userId = LifeCenterSessionController.getSession(request, "sesId"); String sesCenterCode = LifeCenterSessionController.getSession(request, "sesCenterCode"); String sesGroupIdx = LifeCenterSessionController.getSession(request, "sesGroupIdx"); //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 ); // 권한이 SYSTEM일경우 PatientDTO dto = new PatientDTO(); dto.setCenterCode(Integer.parseInt(sesCenterCode)); dto.setGroupIdx(Integer.valueOf(sesGroupIdx)); dto.setPatientName(patientName); dto.setState(inputState); dto.setStartDate(startDate); dto.setEndDate(endDate); if (dto.getCenterCode() == 0) { if( !excelDateYm.equals( "" ) ) { String[] ymSplit = excelDateYm.split("/"); String y = ymSplit[0]; String m = ymSplit[1]; if( Integer.valueOf(m) < 10 ) { m = "0" + m; } excelDateYm = y+"-"+m; } } dto.setExcelDateYm(excelDateYm); int total = patientService.selectPatientCount(dto); List result = new ArrayList(); if (total > 0) { dto.setLimit( 0 ); dto.setLimitMax( total ); if (dto.getCenterCode() == 0) { result = patientService.selectPatientListSystem(dto); } else { result = patientService.selectPatientList(dto); } for (PatientDTO temp : result) { result.get(result.indexOf(temp)).setSymptomContent(LifeCenterFunction.getSymptom(temp)); } } if (dto.getCenterCode() == 0) { getPatientListExcelSystem(request, response, result ); } else { getPatientListExcel(request, response, result ); } } private void getPatientListExcel(HttpServletRequest request, HttpServletResponse response, List data ) { String password = LifeCenterSessionController.getSession(request, "sesPhoneNumber"); password = password.toLowerCase(); if (!password.equals("null")) { 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); int i = 1; 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); Cell cell10 = row.createCell(9); Cell cell11 = row.createCell(10); Cell cell12 = row.createCell(11); Cell cell13 = row.createCell(12); Cell cell14 = row.createCell(13); Cell cell15 = row.createCell(14); 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); cell10.setCellStyle(styleOfBoardFillFontBlackBold16); cell11.setCellStyle(styleOfBoardFillFontBlackBold16); cell12.setCellStyle(styleOfBoardFillFontBlackBold16); cell13.setCellStyle(styleOfBoardFillFontBlackBold16); cell14.setCellStyle(styleOfBoardFillFontBlackBold16); cell15.setCellStyle(styleOfBoardFillFontBlackBold16); sheet1.setColumnWidth( 0, 5000); //센터명 sheet1.setColumnWidth( 1, 3000); //환자명 sheet1.setColumnWidth( 2, 4000); //동호실 sheet1.setColumnWidth( 3, 2000); //성별 sheet1.setColumnWidth( 4, 3500); //나이 sheet1.setColumnWidth( 5, 3500); //생년월일 sheet1.setColumnWidth( 6, 3500); //입소일자 sheet1.setColumnWidth( 7, 3500); //상태변경일 sheet1.setColumnWidth( 8, 3800); //상태 sheet1.setColumnWidth( 9, 6000); //체온 sheet1.setColumnWidth( 10, 10000); //혈압 sheet1.setColumnWidth( 11, 6200); //맥박 sheet1.setColumnWidth( 12, 6200); //산소포화도 sheet1.setColumnWidth( 13, 7000); //혈당 sheet1.setColumnWidth( 14, 14000); //임상증상 cell1.setCellValue("생활치료센터명"); cell2.setCellValue("환자명"); cell3.setCellValue("동,호실"); cell4.setCellValue("성별/나이"); cell5.setCellValue("생년월일"); cell6.setCellValue("확진일자"); cell7.setCellValue("입소일자"); cell8.setCellValue("퇴소예정일"); cell9.setCellValue("상태(상태 변경일)"); cell10.setCellValue("체온"); cell11.setCellValue("혈압"); cell12.setCellValue("맥박"); cell13.setCellValue("산소포화도"); cell14.setCellValue("혈당"); cell15.setCellValue("임상증상"); 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); cell9 = row.createCell(8); cell10 = row.createCell(9); cell11 = row.createCell(10); cell12 = row.createCell(11); cell13 = row.createCell(12); cell14 = row.createCell(13); cell15 = row.createCell(14); String patientName = dto.getPatientName(); String roomWard = ( dto.getWardNumber() == null || dto.getWardNumber().equals( "" ) ) ? "" : dto.getWardNumber()+"동"; roomWard += ( dto.getRoomNumber() == null || dto.getRoomNumber().equals( "" ) ) ? "" : dto.getRoomNumber()+"호 "; String gender = dto.getGender(); String age = dto.getAge(); String jumin = dto.getJumin(); String confirmationDate = dto.getConfirmationDate(); String hospitalizationDate = dto.getHospitalizationDate(); String expecteDischargeDate = dto.getExpectedDischargeDate(); String disisolationDate = dto.getDisisolationDate(); String state = dto.getState(); String temperature = dto.getTemperature(); String temperatureCreateDate = dto.getTemperatureCreateDate(); String systolicBloodPressure = dto.getSystolicBloodPressure(); String systolicBloodPressureCreateDate = dto.getSystolicBloodPressureCreateDate(); String diastolicBloodPressure = dto.getDiastolicBloodPressure(); String diastolicBloodPressureCreateDate = dto.getDiastolicBloodPressureCreateDate(); String pulseRate = dto.getPulseRate(); String pulseRateCreateDate = dto.getPulseRateCreateDate(); String oxygenSaturation = dto.getOxygenSaturation(); String oxygenSaturationCreateDate = dto.getOxygenSaturationCreateDate(); String bloodSugar = dto.getBloodSugar(); String bloodSugarCreateDate = dto.getBloodSugarCreateDate(); String notMeasured = "-"; String symptomDate = dto.getCreateDate(); String symptomContent = dto.getSymptomContent(); // String symptom = LifeCenterFunction.getSymptom( dto ); String centerName = dto.getCenterName(); cell1.setCellValue( centerName ); cell2.setCellValue( patientName ); cell3.setCellValue( roomWard ); cell4.setCellValue( gender + "/" + age ); cell5.setCellValue( jumin ); cell6.setCellValue( confirmationDate ); cell7.setCellValue( hospitalizationDate ); cell8.setCellValue( expecteDischargeDate ); if (state.equals("입소(지정)")) { cell9.setCellValue( state ); } else { cell9.setCellValue( state + "(" + disisolationDate + ")" ); } cell10.setCellValue( ( temperature == null || temperature.equals("") ) ? notMeasured : temperature + " ˚C (" + temperatureCreateDate + ")" ); cell11.setCellValue( ( systolicBloodPressure == null || systolicBloodPressure.equals("") ) ? notMeasured : systolicBloodPressure + " mmHg / " + diastolicBloodPressure + " mmHg (" + systolicBloodPressureCreateDate + ")" ); cell12.setCellValue( ( pulseRate == null || pulseRate.equals("") ) ? notMeasured : pulseRate + " bpm (" + pulseRateCreateDate + ")" ); cell13.setCellValue( ( oxygenSaturation == null || oxygenSaturation.equals("") ) ? notMeasured : oxygenSaturation + " % (" + oxygenSaturationCreateDate + ")" ); cell14.setCellValue( ( bloodSugar == null || bloodSugar.equals("") ) ? notMeasured : bloodSugar + " mg/dL (" + bloodSugarCreateDate + ")" ); cell15.setCellValue( ( symptomContent == null || symptomDate == null || symptomContent.equals("") || symptomDate.equals( "" ) ) ? notMeasured : symptomContent + " (" + symptomDate + ")" ); 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); cell10 = row.createCell(11); cell11 = row.createCell(12); cell12 = row.createCell(13); cell13 = row.createCell(14); cell14 = row.createCell(15); cell15 = row.createCell(16); try { // File file = new File("."); // String rootPath = file.getAbsolutePath(); // System.out.println("현재 프로젝트의 경로 : "+rootPath ); // 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(); } } private void getPatientListExcelSystem(HttpServletRequest request, HttpServletResponse response, List data ) { String password = LifeCenterSessionController.getSession(request, "sesPhoneNumber"); password = password.toLowerCase(); if (!password.equals("null")) { 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); int i = 1; 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, 5000); //센터명 sheet1.setColumnWidth( 1, 3000); //환자명 sheet1.setColumnWidth( 2, 4000); //동호실 sheet1.setColumnWidth( 3, 2000); //성별 sheet1.setColumnWidth( 4, 3500); //나이 sheet1.setColumnWidth( 5, 3500); //생년월일 sheet1.setColumnWidth( 6, 3500); //입소일자 sheet1.setColumnWidth( 7, 3500); //상태변경일 sheet1.setColumnWidth( 8, 3800); //상태 cell1.setCellValue("생활치료센터명"); cell2.setCellValue("환자명"); cell3.setCellValue("동,호실"); cell4.setCellValue("성별/나이"); cell5.setCellValue("생년월일"); cell6.setCellValue("확진일자"); cell7.setCellValue("입소일자"); cell8.setCellValue("퇴소예정일"); cell9.setCellValue("상태(상태 변경일)"); 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); cell9 = row.createCell(8); String patientName = dto.getPatientName(); String roomWard = ( dto.getWardNumber() == null || dto.getWardNumber().equals( "" ) ) ? "" : dto.getWardNumber()+"동"; roomWard += ( dto.getRoomNumber() == null || dto.getRoomNumber().equals( "" ) ) ? "" : dto.getRoomNumber()+"호 "; String gender = dto.getGender(); String age = dto.getAge(); String jumin = dto.getJumin(); String confirmationDate = dto.getConfirmationDate(); String hospitalizationDate = dto.getHospitalizationDate(); String expecteDischargeDate = dto.getExpectedDischargeDate(); String disisolationDate = dto.getDisisolationDate(); String state = dto.getState(); String notMeasured = "-"; String symptomDate = dto.getCreateDate(); String symptomContent = dto.getSymptomContent(); // String symptom = LifeCenterFunction.getSymptom( dto ); String centerName = dto.getCenterName(); cell1.setCellValue( centerName ); cell2.setCellValue( patientName ); cell3.setCellValue( roomWard ); cell4.setCellValue( gender + "/" + age ); cell5.setCellValue( jumin ); cell6.setCellValue( confirmationDate ); cell7.setCellValue( hospitalizationDate ); cell8.setCellValue( expecteDischargeDate ); if (state.equals("입소(지정)")) { cell9.setCellValue( state ); } else { cell9.setCellValue( state + "(" + disisolationDate + ")" ); } 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 { // File file = new File("."); // String rootPath = file.getAbsolutePath(); // System.out.println("현재 프로젝트의 경로 : "+rootPath ); // 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(); } } }