yuanzhi_kuang 8 kuukautta sitten
vanhempi
commit
b8492fd73d

BIN
web/com.zip


+ 0 - 80
web/com/kingdee/custom/shengshen/handle/EntryRegistrationHandle.java

@@ -1,80 +0,0 @@
-package com.kingdee.eas.custom.shengshen.handle;
-
-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 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);
-        }
-    }
-}

+ 0 - 195
web/com/kingdee/custom/shengshen/utils/HttpClient3.java

@@ -1,195 +0,0 @@
-package com.kingdee.eas.custom.shengshen.utils;
-
-
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
-
-import java.io.*;
-import java.net.HttpURLConnection;
-import java.net.MalformedURLException;
-import java.net.URL;
-
-
-public class HttpClient3 {
-    public static byte[] getBytesByNetURL(String urlStr) throws IOException {
-//		RestTemplate restTemplate = new RestTemplate();
-//		ResponseEntity<byte[]> responseEntity = restTemplate.exchange(urlStr, HttpMethod.GET, null, byte[].class);
-//		byte[] fileContent = responseEntity.getBody();
-        URL url = new URL(urlStr);
-        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
-//		//设置超时时间
-        conn.setConnectTimeout(5 * 1000);
-//		//通过输入流获取图片数据
-        InputStream in = conn.getInputStream();
-//		//得到图片的二进制数据
-        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
-        byte[] buffer = new byte[1024];
-        int len;
-        while ((len = in.read(buffer)) != -1) {
-            outputStream.write(buffer, 0, len);
-        }
-        in.close();
-        return outputStream.toByteArray();
-//		return fileContent;
-    }
-    /**
-     * http get请求
-     * @param httpUrl 链接
-     * @return 响应数据
-     */
-    public static InputStream doGet(String httpUrl){
-        //链接
-        HttpURLConnection connection=null;
-        InputStream is=null;
-        BufferedReader br = null;
-        StringBuffer result=new StringBuffer();
-        try {
-            //创建连接
-            URL url=new URL(httpUrl);
-            connection= (HttpURLConnection) url.openConnection();
-            //设置请求方式
-            connection.setRequestMethod("GET");
-            //设置连接超时时间
-            connection.setConnectTimeout(15000);
-            //设置读取超时时间
-            connection.setReadTimeout(15000);
-            //开始连接
-            connection.connect();
-            //获取响应数据
-            if(connection.getResponseCode()==200){
-                //获取返回的数据
-                is=connection.getInputStream();
-
-//                if(is!=null){
-//                    br=new BufferedReader(new InputStreamReader(is,"UTF-8"));
-//                    String temp = null;
-//                    while ((temp=br.readLine())!=null){
-//                        result.append(temp);
-//                    }
-//                }
-            }
-        } catch (MalformedURLException e) {
-            e.printStackTrace();
-        } catch (IOException e) {
-            e.printStackTrace();
-        }finally {
-            if(br!=null){
-                try {
-                    br.close();
-                } catch (IOException e) {
-                    e.printStackTrace();
-                }
-            }
-            if(is!=null){
-                try {
-                    is.close();
-                } catch (IOException e) {
-                    e.printStackTrace();
-                }
-            }
-            connection.disconnect();// 关闭远程连接
-        }
-
-        return is;
-    }
-
-    /**
-     * post请求
-     * @param httpUrl 链接
-     * @param param 参数
-     * @return
-     */
-    public static JSONObject doPost(String httpUrl,  String param) {
-        StringBuffer result=new StringBuffer();
-        //连接
-        HttpURLConnection connection=null;
-        OutputStream os=null;
-        InputStream is=null;
-        BufferedReader br=null;
-        JSONObject jsonObject = null;
-        try {
-            //创建连接对象
-            URL url=new URL(httpUrl);
-            //创建连接
-            connection= (HttpURLConnection) url.openConnection();
-            //设置请求方法
-            connection.setRequestMethod("POST");
-            //设置连接超时时间
-            connection.setConnectTimeout(15000);
-            //设置读取超时时间
-            connection.setReadTimeout(15000);
-            //设置是否可读取
-            connection.setDoOutput(true);
-            //设置响应是否可读取
-            connection.setDoInput(true);
-            //设置参数类型
-            connection.setRequestProperty("Content-Type", "application/json");
-            //拼装参数
-            if(param!=null&&!param.equals("")){
-                //设置参数
-                os=connection.getOutputStream();
-                //拼装参数
-                os.write(param.getBytes("UTF-8"));
-            }
-            //设置权限
-            //设置请求头等
-
-            //开启连接
-            //connection.connect();
-            //读取响应
-            if(connection.getResponseCode()==200){
-                is=connection.getInputStream();
-                if(is!=null){
-                    br=new BufferedReader(new InputStreamReader(is,"UTF-8"));
-                    String temp=null;
-                    if((temp=br.readLine())!=null){
-                        result.append(temp);
-                    }
-                }
-                 jsonObject =  JSON.parseObject(String.valueOf(result));
-
-            }
-            //关闭连接
-        } catch (MalformedURLException e) {
-            e.printStackTrace();
-        } catch (IOException e) {
-            e.printStackTrace();
-        }finally {
-            if(br!=null){
-                try {
-                    br.close();
-                } catch (IOException e) {
-                    e.printStackTrace();
-                }
-            }
-            if(os!=null){
-                try {
-                    os.close();
-                } catch (IOException e) {
-                    e.printStackTrace();
-                }
-            }
-            if(is!=null){
-                try {
-                    is.close();
-                } catch (IOException e) {
-                    e.printStackTrace();
-                }
-            }
-            //关闭连接
-            connection.disconnect();
-        }
-        return jsonObject;
-    }
-
-
-    public static void main(String[] str){
-        /*String result=HttpURLConnectionUtil.doGet("http://localhost:8080/test");
-        System.out.println(result);*/
-        /*Map<String, Object> map=new HashMap<>();
-        map.put("1","1");
-        map.put("2","2");
-        map.put("3","3");
-        System.out.println(HttpURLConnectionUtil.getParamStr(map));*/
-    }
-}

+ 0 - 85
web/com/kingdee/custom/shengshen/utils/PDFFillInformationUtil.java

@@ -1,85 +0,0 @@
-package com.kingdee.eas.custom.shengshen.utils;
-
-import com.itextpdf.text.pdf.AcroFields;
-import com.itextpdf.text.pdf.PdfReader;
-import com.itextpdf.text.pdf.PdfStamper;
-import com.kingdee.bos.BOSException;
-import net.lingala.zip4j.core.ZipFile;
-import net.lingala.zip4j.exception.ZipException;
-import net.lingala.zip4j.model.ZipParameters;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-public class PDFFillInformationUtil {
-    /**
-     * 给pdf填充数据
-     * @param file 原始文件
-     * @param field map<String,String> key 为字段名,value 为填充值
-     * @return 填充后的文件  文件类型为byte[]
-     */
-    public File fillInformation(byte[] file, Map<String,String> field,String tempFilePath,String fileName) throws IOException {
-        try {
-            System.setProperty("javax.xml.parsers.DocumentBuilderFactory","com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl");
-            // 读取PDF模板
-            PdfReader pdfReader = new PdfReader(file);
-            ByteArrayOutputStream baos = new ByteArrayOutputStream();
-            // 创建需就改PDF文件
-            PdfStamper pdfStamper = new PdfStamper(pdfReader, baos);
-            AcroFields form = pdfStamper.getAcroFields();
-            // 设置字段数据
-            Iterator<Map.Entry<String, String>> iterator = field.entrySet().iterator();
-            while (iterator.hasNext()) {
-                Map.Entry<String, String> entry = iterator.next();
-                String key = entry.getKey();
-                String value = entry.getValue();
-                //给字段添加值
-                form.setField(key, value);
-            }
-            //生成后的pdf 可以在编辑
-            pdfStamper.setFormFlattening(false);
-            // 关闭修改器,并释放资源
-            pdfStamper.close();
-            pdfReader.close();
-            File outFile = new File(tempFilePath+"/"+fileName);
-            if (!outFile.createNewFile()) {
-                throw new RuntimeException("pdf 填充数据失败!!");
-            }
-            FileOutputStream fos = new FileOutputStream(outFile);
-            baos.writeTo(fos);
-            fos.close(); // 关闭流释放资源
-            return  outFile;
-        } catch (Exception e) {
-            e.printStackTrace();
-            throw new RuntimeException("pdf 填充数据失败!!");
-        }
-    }
-    /**
-     * 创建压缩包
-     *
-     * @param destFileName
-     * @param files
-     * @return
-     */
-    public static String compress(String destFileName, List<File> files) throws BOSException {
-        ZipParameters parameters = new ZipParameters();
-        parameters.setCompressionMethod(8);
-        parameters.setCompressionLevel(5);
-        try {
-            ZipFile zipFile = new ZipFile(destFileName);
-            for (int i = 0; i < files.size(); ++i) {
-                File file = files.get(i);
-                zipFile.addFile(file, parameters);
-            }
-            return destFileName;
-        } catch (ZipException var9) {
-            var9.printStackTrace();
-            throw new BOSException(var9.getMessage());
-        }
-    }
-}