|
@@ -1,9 +1,13 @@
|
|
|
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.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
@@ -13,6 +17,12 @@ import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
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;
|
|
@@ -510,16 +520,52 @@ public class ClinicController extends LifeCenterController {
|
|
|
directory.mkdir();
|
|
|
}
|
|
|
|
|
|
+ String password = LifeCenterSessionController.getSession(request, "sesPhoneNumber");
|
|
|
+ password = password.toLowerCase();
|
|
|
+ if (!password.equals("null")) {
|
|
|
+ password = password.replace("-", "");
|
|
|
+ password = password.substring(3).trim();
|
|
|
+ } else {
|
|
|
+ password = "";
|
|
|
+ }
|
|
|
+
|
|
|
String timestamp = LifeCenterFunction.getNow("yyyy-MM-dd_HH-mm-ss");
|
|
|
// 다운로드 파일 명: 호실_환자명(생년월일)_건강정보기록_다운로드일시.xlsx
|
|
|
String downName = patientDto.getRoomNumber() + "_" + patientDto.getPatientName() + "(" + patientDto.getJumin() + ")_건강정보기록_" + timestamp + ".xlsx";
|
|
|
- String tempPath = directoryName + downName;
|
|
|
-
|
|
|
+ String tempPath = directoryName + downName;
|
|
|
|
|
|
File xlsFile = new File(tempPath);
|
|
|
- FileOutputStream fileOut = new FileOutputStream(xlsFile);
|
|
|
+// FileOutputStream fileOut = new FileOutputStream(xlsFile);
|
|
|
+// workbook.write(fileOut);
|
|
|
+//
|
|
|
+// LifeCenterFileDownload.download(request, response, tempPath, downName);
|
|
|
+//
|
|
|
+// xlsFile.delete();
|
|
|
+
|
|
|
+ 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();
|
|
@@ -527,7 +573,11 @@ public class ClinicController extends LifeCenterController {
|
|
|
e.printStackTrace();
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
- }
|
|
|
+ } catch (InvalidFormatException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } catch (GeneralSecurityException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void createPHRSheet(Workbook workbook, CellStyle styleOfBoardFillFontBlackBold16, PatientDTO patientDto, String phrTypeKorean, String phrType) {
|