|
@@ -1,14 +1,80 @@
|
|
|
package com.kingdee.eas.custom.shengshen.handle;
|
|
|
|
|
|
-import com.kingdee.shr.base.syssetting.web.handler.ListHandler;
|
|
|
+import com.kingdee.bos.BOSException;
|
|
|
+import com.kingdee.eas.custom.shengshen.utils.HttpClient3;
|
|
|
+import com.kingdee.eas.custom.shengshen.utils.PDFFillInformationUtil;
|
|
|
+import com.kingdee.shr.affair.web.handler.hrman.EmpEnrollBizBillHrManListHandler;
|
|
|
+import com.kingdee.shr.base.syssetting.exception.SHRWebException;
|
|
|
+import com.kingdee.shr.base.syssetting.web.dynamic.util.DynamicUtil;
|
|
|
+import com.kingdee.shr.base.syssetting.web.util.UserUtil;
|
|
|
+import org.apache.commons.io.FileUtils;
|
|
|
import org.springframework.ui.ModelMap;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.ByteArrayOutputStream;
|
|
|
+import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.*;
|
|
|
+import java.util.zip.GZIPOutputStream;
|
|
|
|
|
|
-public class EntryRegistrationHandle extends ListHandler {
|
|
|
- public String getRegisterFileAtion(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap){
|
|
|
-
|
|
|
- return null;
|
|
|
+public class EntryRegistrationHandle extends EmpEnrollBizBillHrManListHandler {
|
|
|
+ public void getRegisterFileAction(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws SHRWebException{
|
|
|
+ //填充数据
|
|
|
+ List<Map<String,String>> dataList = new ArrayList<Map<String,String>>();
|
|
|
+ Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
+ dataMap.put("topmostSubform[0].Page1[0].topmostSubform_0_\\.Page1_0_\\.TextField1_3_[0]", "Data1");
|
|
|
+ dataMap.put("topmostSubform[0].Page1[0].topmostSubform_0_\\.Page1_0_\\.TextField1_0_[0]", "Data2");
|
|
|
+ String url = "http://169.254.157.139:6888/easWebClient/download/DSF_Mod_373.pdf";
|
|
|
+ dataList.add(dataMap);
|
|
|
+ PDFFillInformationUtil pdfFillInformationUtil = new PDFFillInformationUtil();
|
|
|
+ //填充后的文件
|
|
|
+ List<File> list = new ArrayList<>();
|
|
|
+ long time = new Date().getTime();
|
|
|
+ //获取当前登入人的 临时存储地址
|
|
|
+ String userTempDirAbsolutePath = UserUtil.getUserTempDirAbsolutePath(request.getSession());
|
|
|
+ String tempFilePath = userTempDirAbsolutePath + File.separator + time + File.separator;
|
|
|
+ //压缩文件名
|
|
|
+ String zipName = time + File.separator + "personDocument.zip";
|
|
|
+ String zipPath = UserUtil.getUserTempDirAbsolutePath(request.getSession()) + File.separator + zipName;
|
|
|
+ //判断路径是否存在 如果没有创建
|
|
|
+ File userTempDirAbsolute = new File(userTempDirAbsolutePath);
|
|
|
+ if (!userTempDirAbsolute.exists()) {
|
|
|
+ userTempDirAbsolute.mkdir();
|
|
|
+ }
|
|
|
+ //判断路径是否存在 如果没有创建
|
|
|
+ File tempFile = new File(tempFilePath);
|
|
|
+ if (!tempFile.exists()) {
|
|
|
+ tempFile.mkdir();
|
|
|
+ }
|
|
|
+ String fileName = "刘颖";
|
|
|
+ try {
|
|
|
+ byte[] bytesByNetURL = HttpClient3.getBytesByNetURL(url);
|
|
|
+ for (int i = 0; i < dataList.size(); i++) {
|
|
|
+ File file = pdfFillInformationUtil.fillInformation(bytesByNetURL, dataList.get(i),tempFilePath,fileName+i+".pdf");
|
|
|
+ list.add(file);
|
|
|
+ }
|
|
|
+ //创建压缩文件
|
|
|
+ PDFFillInformationUtil.compress(zipPath, list);
|
|
|
+ } catch (IOException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ } catch (BOSException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }finally {
|
|
|
+ //删除源文件
|
|
|
+ for (int i = 0; i < list.size(); i++) {
|
|
|
+ FileUtils.deleteQuietly(list.get(i));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Map<String, String> param = new HashMap<String, String>();
|
|
|
+ param.put("method", "tmp");
|
|
|
+ param.put("file", zipName);
|
|
|
+ param.put("filename", "员工档案.zip");
|
|
|
+ String link = DynamicUtil.assembleUrl("/shr/downloadfile.do", param).replaceAll("\\+", "%20");
|
|
|
+ try {
|
|
|
+ this.writeSuccessData(link);
|
|
|
+ } catch (SHRWebException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
}
|
|
|
}
|