chenmingliang 3 mesi fa
parent
commit
05ae542dd6

+ 85 - 0
websrc/com/kingdee/eas/custom/ssPDF/handler/AttendanceResultSumCalDynamicListHandlerEx.java

@@ -0,0 +1,85 @@
+package com.kingdee.eas.custom.ssPDF.handler;
+
+import com.kingdee.bos.Context;
+import com.kingdee.eas.hr.ats.AttendanceProjectInfo;
+import com.kingdee.eas.hr.ats.decimalPlace.util.DecimalPlaceUtil;
+import com.kingdee.shr.ats.web.handler.dynamic.AttendanceResultSumCalDynamicListHandler;
+import com.kingdee.shr.ats.web.handler.dynamic.calculate.AttendanceResultToSumHelper;
+import com.kingdee.shr.base.syssetting.context.SHRContext;
+import com.kingdee.shr.base.syssetting.exception.SHRWebException;
+import com.kingdee.shr.base.syssetting.exception.ShrWebBizException;
+import com.kingdee.shr.base.syssetting.json.GridDataEntity;
+import com.kingdee.shr.base.syssetting.web.dynamic.model.UIViewInfo;
+import com.kingdee.shr.base.syssetting.web.dynamic.util.ExportHelper;
+import com.kingdee.shr.base.syssetting.web.dynamic.util.UIViewUtil;
+import org.springframework.ui.ModelMap;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class AttendanceResultSumCalDynamicListHandlerEx extends AttendanceResultSumCalDynamicListHandler {
+
+    protected Map<String, Object> initExportExcelConfig(HttpServletRequest request, ExportHelper helper) throws SHRWebException {
+        Map<String, Object> params = helper.assembleHandleParam(request);
+//        String column = params.get("columnModel") + "person.name,false,Ô±¹¤ÐÕÃû;";
+//        params.put("columnModel",column);
+        Map<String, Object> excelConfig = helper.createExcel(request, params);
+
+        //Map<String, Object> excelConfig = super.initExportExcelConfig(request, helper);
+        List<Map<String, Object>> columnModel = (List)excelConfig.get("columnModel");
+        Context ctx = SHRContext.getInstance().getContext();
+        UIViewInfo uiViewInfo = UIViewUtil.getCurrentUIViewInfo(request);
+        String scheme = uiViewInfo.getModel();
+        Map<String, AttendanceProjectInfo> atsProjectInfo = AttendanceResultToSumHelper.getAtsProjectMap(ctx, scheme, "ATS_RESULT.S");
+        int decimalPlaces = DecimalPlaceUtil.getDecimalPlaceSystem(ctx);
+        Map<String, Object> attributes = new HashMap();
+        attributes.put("decimalPrecision", decimalPlaces + "");
+        Map<String, Object> intAttributes = new HashMap();
+        intAttributes.put("decimalPrecision", "0");
+        Map<String, Object> modelMap = null;
+        AttendanceProjectInfo atsProject = null;
+
+        for(int i = 0; i < columnModel.size(); ++i) {
+            modelMap = (Map)columnModel.get(i);
+            String name = (String)modelMap.get("name");
+            if (name.startsWith("ATS_RESULT.S")) {
+                atsProject = (AttendanceProjectInfo)atsProjectInfo.get(name);
+                if (null != atsProject) {
+                    if (atsProject.getDataType().getValue() == 1) {
+                        modelMap.put("attributes", intAttributes);
+                    } else if (atsProject.getDataType().getValue() == 2) {
+                        modelMap.put("attributes", attributes);
+                    }
+                }
+            }
+        }
+
+        return excelConfig;
+    }
+
+    @Override
+    protected GridDataEntity getGridRequestData(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws SHRWebException {
+        Map<String, String> params = this.assembleQueryParams(request, modelMap);
+        String selector = params.get("selector") + ",person.name,person.number";
+        params.put("selector",selector);
+        return this.getFieldPermFilterDynamicGridData(request, params);
+        //return super.getGridRequestData(request, response, modelMap);
+
+    }
+
+    @Override
+    public void afterGetExportData(HttpServletRequest request, HttpServletResponse response, List listData) throws SHRWebException {
+        super.afterGetExportData(request, response, listData);
+        for (int i = 0; i < listData.size(); i++) {
+            //listData.get()
+        }
+    }
+
+    @Override
+    protected void afterGetListData(HttpServletRequest request, HttpServletResponse response, GridDataEntity gridDataEntity) throws SHRWebException {
+        super.afterGetListData(request, response, gridDataEntity);
+    }
+}

+ 301 - 0
websrc/com/kingdee/eas/custom/ssPDF/handler/CmpReportDynamicListHandlerEx.java

@@ -0,0 +1,301 @@
+package com.kingdee.eas.custom.ssPDF.handler;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.kingdee.bos.BOSException;
+import com.kingdee.bos.Context;
+import com.kingdee.eas.base.permission.UserInfo;
+import com.kingdee.eas.util.app.ContextUtil;
+import com.kingdee.eas.util.app.DbUtil;
+import com.kingdee.jdbc.rowset.IRowSet;
+import com.kingdee.shr.base.syssetting.context.SHRContext;
+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.dynamic.util.MD5;
+import com.kingdee.shr.base.syssetting.web.util.UserUtil;
+import com.kingdee.shr.compensation.web.handler.CmpReportDynamicListHandler;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.ui.ModelMap;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.nio.charset.Charset;
+import java.sql.Date;
+import java.text.MessageFormat;
+import java.text.SimpleDateFormat;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 胜生TXT下载
+ */
+public class CmpReportDynamicListHandlerEx extends CmpReportDynamicListHandler {
+
+    /**
+     * 员工对应组织 的 雇主编号
+     * 空
+     * 员工查询界面 统计年
+     * 默认 32
+     * 员工信息--税务编码
+     * 员工信息--中文姓名 (Big-5編碼)
+     * 员工信息--葡文姓名
+     * 薪酬核算--应纳税所得额
+     * 空
+     * 空
+     * 薪酬核算--职业税
+     * 员工离职日期
+     * 默认 01
+     * 默认 02
+     * 空
+     */
+
+    public void importTXTAction(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws SHRWebException {
+        Map<String, String> map = new HashMap<>();;
+        try {
+            String data = request.getParameter("data");
+            JSONArray jsonArray = (JSONArray) JSONArray.parse(data);
+            Context ctx = SHRContext.getInstance().getContext();//上下文
+            long time = System.currentTimeMillis();
+            HttpSession session = request.getSession();
+            String tempFilePath = UserUtil.getUserTempDirAbsolutePath(session); //存放
+            File tempFile = new File(tempFilePath);
+            if (!tempFile.exists()) {
+                tempFile.mkdirs();
+            }
+            // 创建 FileWriter 对象来写入文本文件
+            String fileName = "output_" + time + ".txt";
+            String txtNameHash = MD5.md5Hash(fileName);
+            String realFileName = getEncryRealFileName(ctx,txtNameHash);
+            String txtPath = tempFilePath + File.separator + realFileName;
+            String fileStr = txtNameHash;
+            FileWriter fileWriter = new FileWriter(txtPath);
+            BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
+            for (int i = 0; i < jsonArray.size(); i++) {
+                JSONObject jsonObject = (JSONObject) jsonArray.get(i);
+                String personId = (String) jsonObject.get("personId");
+                String ctbPeriodyear = String.valueOf(jsonObject.get("ctbPeriodyear"));//
+                String ctbMonth = String.valueOf(jsonObject.get("ctbMonth"));
+                String calNumber = (String) jsonObject.get("calNumber");//规则名称
+                String dataTxt = getSql(ctx, personId, ctbPeriodyear, ctbMonth, calNumber);
+                bufferedWriter.write(dataTxt);
+            }
+            // 关闭 BufferedWriter
+            bufferedWriter.close();
+            // 关闭 FileWriter
+            fileWriter.close();
+
+            Map<String, String> param = new HashMap<String, String>();
+            param.put("method", "tmp");
+            param.put("file", fileStr);
+            param.put("filename",fileName);
+            String link = DynamicUtil.assembleUrl("/shr/downloadfile.do", param).replaceAll("\\+", "%20");
+            map.put("msgType","1");
+            map.put("link",link);
+            map.put("msg","下载成功");
+        } catch (Exception e) {
+            e.printStackTrace();
+            map.put("msg",e.getMessage());
+            map.put("msgType","0");
+        }
+
+        this.writeSuccessData(map);
+    }
+
+    /**
+     * 9.9版本 下载url
+     * @param ctx
+     * @param realFileName
+     * @return
+     */
+    public static String getEncryRealFileName(Context ctx, String realFileName) {
+        UserInfo currentUserInfo = ContextUtil.getCurrentUserInfo(ctx);
+        return MessageFormat.format("{0}_{1}", realFileName, MD5.md5Hash(currentUserInfo.getId().toString()));
+    }
+
+    /**
+     * 去除无效位数
+     * @param strNumber
+     * @return
+     */
+    public static String removeTrailingZeros(String strNumber) {
+        String pattern = "\\.?0*$"; // 匹配小数点后的零和小数点本身
+        String formattedNumber = strNumber.replaceAll(pattern, "");
+        return formattedNumber;
+    }
+
+
+    /**
+     *
+     * @param personId
+     * @param ctbPeriodyear 统计年
+     * @param ctbMonth 统计月
+     * @param calNumber 计算规则
+     *
+     *
+     */
+    public String getSql(Context ctx,String personId,String ctbPeriodyear,String ctbMonth,String calNumber) throws Exception {
+        SimpleDateFormat outputFormatter = new SimpleDateFormat("dd/MM/yyyy");
+        StringBuilder query = new StringBuilder();
+        query.append("SELECT").append("\n");
+        query.append("org.Fname_l2 orgName,").append("\n");
+        query.append("org.FCode as orgCode,").append("\n");
+        query.append("person.CFOccupationcode personOccTion,").append("\n");
+        query.append("person.CFChinesesurname personChineX,").append("\n");
+        query.append("person.CFChinesename personChineM,").append("\n");
+        query.append("person.CFPortuguesesurname personPX,").append("\n");
+        query.append("person.CFPortuguesename personPM,").append("\n");
+        query.append("sc.S5 s5,").append("\n");
+        query.append("sc.S93 s93,").append("\n");
+        query.append("res.FBIZDATE bizDate").append("\n");
+        query.append("FROM T_HR_SCmpCalTable sc ").append("\n");
+        query.append("left join T_HR_SCalScheme ch on sc.FCALSCHEMEID = ch.fid").append("\n");
+        query.append("left join t_hr_personposition pp on sc.FPERSONID = pp.FPERSONID ").append("\n");
+        query.append("left join T_BD_PERSON person on pp.FPERSONID = person.fid ").append("\n");
+        query.append("left join T_Org_admin org on org.fid = pp.FCOMPANYID").append("\n");
+        query.append("left join T_HR_ResignBizBillEntry res on res.FPERSONID = person.fid").append("\n");
+        query.append("where sc.FPERSONID = '"+personId+"' and sc.FPERIODYEAR = '"+ctbPeriodyear+"' and sc.FPERIODMONTH = '"+ctbMonth+"' and ch.FNumber  = '"+calNumber+"'").append("\n");
+        IRowSet rowSet = DbUtil.executeQuery(ctx, query.toString());
+        String orgCode = "";//雇主编号
+        String taxFile = "";//营业税档案编号或僱主编号文字部份
+
+        String clauseNumber = "32";//职业税条款编号
+        String personOccTion = "";
+        String ChineName = "";
+        String ChinePWName = "";
+        String s5Str = "";
+        String nonMonetary = "";//若有接受非金錢收益
+        String notTaxable = "";//不属课税收益
+        String s93Str = "";
+        String leftStr = "";
+        String txt01 = "00";
+        String txt02 = "00";
+        String reserved = "";
+        while (rowSet.next()) {
+            //orgName = rowSet.getString("orgName");
+            orgCode = rowSet.getString("orgCode");//雇主编号
+            personOccTion = rowSet.getString("personOccTion") == null ? "" : rowSet.getString("personOccTion");//税务编码
+            String personChineX = rowSet.getString("personChineX") == null ? "" : rowSet.getString("personChineX");//中文姓
+            String personChineM = rowSet.getString("personChineM") == null ? "" : rowSet.getString("personChineM");//中文名
+            String personPX = rowSet.getString("personPX") == null ? "" : rowSet.getString("personPX");//葡文姓
+            String personPM = rowSet.getString("personPM") == null ? "" : rowSet.getString("personPM");//葡文名
+            BigDecimal s5 = rowSet.getBigDecimal("s5");//应纳税所得额
+            BigDecimal s93 = rowSet.getBigDecimal("s93");//职业税
+            Date bizDate = rowSet.getDate("bizDate");//员工离职日期
+            if (bizDate != null){
+                leftStr = outputFormatter.format(bizDate);
+            }
+            String[] s5split = convertToString(s5).split("\\.");
+            String strS5 = s5split[0];
+            if (StringUtils.isNotBlank(strS5)){
+                if (convertToBigDecimal(strS5).compareTo(BigDecimal.ZERO) > 0){
+                    s5Str += strLengthReturn(strS5,11,"0",0);
+                }
+            }
+            s5Str += s5split[1];
+
+
+            String[] s93split = convertToString(s93).split("\\.");
+            String strS93 = s93split[0];
+            if (StringUtils.isNotBlank(strS93)){
+                if (convertToBigDecimal(strS93).compareTo(BigDecimal.ZERO) > 0){
+                    s93Str += strLengthReturn(strS93,11,"0",0);
+                }
+            }
+            s93Str += s93split[1];
+            /**
+             * 员工对应组织 的 雇主编号 --7
+             * 营业税档案编号或僱主编号文字部份  空  --1
+             * 员工查询界面 统计年  --4
+             * 职业税条款编号 默认 32  --2
+             * 员工信息--税务编码  --8
+             * 员工信息--中文姓名 (Big-5編碼)  --40
+             * 员工信息--葡文姓名  --40
+             * 薪酬核算--应纳税所得额  --13
+             * 若有接受非金钱收益 空  --1
+             * 不属课税收益  空  --13
+             * 薪酬核算--职业税  --13
+             * 员工离职日期  --8
+             * 默认 01  --2
+             * 默认 12  --2
+             * 预留供日后使用 空  --20
+             */
+            ChineName = stringToBig5Bytes(personChineX + personChineM);
+            ChinePWName = personPX + personPM;
+            orgCode = strLengthReturn(orgCode,7,"0",0);//雇主编号
+            taxFile = strLengthReturn("",1," ",0);//营业税档案编号或僱主编号文字部份
+
+
+            personOccTion = strLengthReturn(personOccTion,8," ",personOccTion.length());//税务编码
+            ChineName = strLengthReturn(ChineName,40," ",ChineName.length());//中文姓名
+            ChinePWName = strLengthReturn(ChinePWName,40," ",ChinePWName.length());//葡文姓名
+            //s5 = strLengthReturn(removeTrailingZeros(s5),13,"0",0);//应纳税所得额
+            nonMonetary = strLengthReturn("",1," ",0);//若有接受非金錢收益
+            notTaxable = strLengthReturn("",13,"0",0);//不属课税收益
+            //s93 = strLengthReturn(removeTrailingZeros(s93),13,"0",0);//职业税
+            leftStr = strLengthReturn(leftStr,8,"0",leftStr.length());//员工离职日期
+
+
+            reserved = strLengthReturn("",20," ",0);//预留供日后使用
+
+        }
+
+        return orgCode+ taxFile + ctbPeriodyear + clauseNumber+ personOccTion+ ChineName+ ChinePWName+ s5Str+ nonMonetary+ notTaxable+ s93Str+ leftStr+ txt01+ txt02+ reserved;
+    }
+
+
+    public BigDecimal convertToBigDecimal(String numberAsString) {
+        return new BigDecimal(numberAsString);
+    }
+
+    public String convertToString(BigDecimal number) {
+        BigDecimal bigDecimal = number.setScale(2, RoundingMode.HALF_UP.ordinal());
+        return bigDecimal.toString();
+    }
+
+    /**
+     * 转化为big-5编码,返回16进制
+     * @param input
+     * @return
+     */
+    public String stringToBig5Bytes(String input) {
+        byte[] big5s = input.getBytes(Charset.forName("Big5"));// 使用 Big-5 编码转换字符串
+        StringBuilder hexString = new StringBuilder(); // 创建一个 StringBuilder 用于构建字符串
+        for (byte b : big5s) {
+            hexString.append(String.format("%02X", b)); // 将每个字节格式化为十六进制并添加到字符串中
+        }
+        return hexString.toString();
+    }
+
+    /**
+     * 传入字符串,判断长度,不足时拼接替换值
+     * @param value
+     * @param totalLength 总长度
+     * @param replaceValue 替换值
+     * @return
+     * @throws Exception
+     */
+    public String strLengthReturn(String value ,int totalLength,String replaceValue ,int replacePosition ) throws Exception {
+        if (value.length() > totalLength){
+            throw new Exception("");
+        }
+        if (value.length() < totalLength) {
+            StringBuilder stringBuilder = new StringBuilder(value);
+
+            // 在替换位置之前添加替换值
+            while (stringBuilder.length() < totalLength) {
+                stringBuilder.insert(replacePosition, replaceValue);
+            }
+            value = stringBuilder.toString();
+        }
+        return value;
+    }
+
+
+
+}

+ 255 - 0
websrc/com/kingdee/eas/custom/ssPDF/handler/ResignBizBillHrManListHandlerEx.java

@@ -0,0 +1,255 @@
+package com.kingdee.eas.custom.ssPDF.handler;
+
+import com.itextpdf.text.DocumentException;
+import com.itextpdf.text.pdf.*;
+import com.kingdee.bos.BOSException;
+import com.kingdee.bos.Context;
+import com.kingdee.eas.base.permission.UserInfo;
+import com.kingdee.eas.custom.shengshen.utils.PDFFillInformationUtil;
+import com.kingdee.eas.hr.ats.AtsUtil;
+import com.kingdee.eas.util.app.ContextUtil;
+import com.kingdee.eas.util.app.DbUtil;
+import com.kingdee.jdbc.rowset.IRowSet;
+import com.kingdee.shr.affair.web.handler.hrman.ResignBizBillHrManListHandler;
+
+import com.kingdee.shr.base.syssetting.context.SHRContext;
+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.dynamic.util.MD5;
+import com.kingdee.shr.base.syssetting.web.util.UserUtil;
+import org.springframework.ui.ModelMap;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import java.io.*;
+import java.sql.SQLException;
+import java.text.MessageFormat;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/**
+ * @author cml
+ * @date 2024/9/10
+ * @apiNote
+ */
+public class ResignBizBillHrManListHandlerEx extends ResignBizBillHrManListHandler {
+
+    /**
+     * 离职员工生成离职PDF
+     * @param request templatePrint
+     * @param response
+     * @param modelMap
+     * @throws IOException
+     */
+    public void importPDFAction(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws IOException, SHRWebException {
+        generatePDF(request,response,modelMap);
+    }
+    public void generatePDF(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws SHRWebException {
+        Map<String, String> map = new HashMap<>();
+        Context ctx = SHRContext.getInstance().getContext();//上下文
+        HttpSession session = request.getSession();
+        long time = System.currentTimeMillis();
+        String tempFilePath1 = UserUtil.getUserTempDirAbsolutePath(session); //存放
+        File tempFile1 = new File(tempFilePath1);
+        if (!tempFile1.exists()) {
+            tempFile1.mkdirs();
+        }
+        List<String> list = new ArrayList<String>();
+        try{
+            String numbers = request.getParameter("number");
+            String number = "";
+            String[] split = numbers.split(",");
+            for (int i = 0; i < split.length; i++) {
+                list.add(split[i]);
+            }
+            List<Set<String>> listSet = this.splitListIntoSets(list, 20); //超过 20(需要)第二页 pdf
+            List<File> listFile = new ArrayList<>();
+            for (int i = 0; i < listSet.size(); i++) {
+                Set<String> set = listSet.get(i);
+                Map<String, String> data = getSql(set, ctx, listSet.size(), i);
+                if (data.containsKey("msgType") && "0".equals(data.get("msgType"))){
+                    this.writeSuccessData(data);
+                    return;
+                }
+                number = data.get("number");
+                PDFFillInformationUtil pdfFillInformationUtil = new PDFFillInformationUtil();
+                String realPath = session.getServletContext().getRealPath("/") + "addon/custom/html/DSF_Mod.pdf";
+                File file = new File(realPath);
+                byte[] pdfBytes = convertPdfToByteArray(file);
+                File file1 = pdfFillInformationUtil.fillInformation(pdfBytes, data, tempFilePath1, "DSF_Mod"+i+".pdf");
+                listFile.add(file1);
+            }
+            //压缩文件名
+            String zipName =  "员工离职_" + time + ".zip";
+            String zipNameHash = MD5.md5Hash(zipName);
+            String realFileName = getEncryRealFileName(ctx,zipNameHash);
+            String fileStr = zipNameHash;
+            String zipPath = tempFilePath1 + File.separator + realFileName;
+            PDFFillInformationUtil.compress(zipPath, listFile);
+
+            Map<String, String> param = new HashMap<String, String>();
+            param.put("method", "tmp");
+            param.put("file", fileStr);
+            param.put("filename", zipName);
+            String link = DynamicUtil.assembleUrl("/shr/downloadfile.do", param).replaceAll("\\+", "%20");
+            map.put("msg","离职pdf导出:" + split.length + "条数据;成功:" + number + ";失败:" + (split.length - Integer.parseInt(number)));
+            map.put("msgType","1");
+            map.put("link",link);
+
+        }catch (Exception e){
+            e.printStackTrace();
+            map.put("msg",e.getMessage());
+            map.put("msgType","0");
+        }
+        this.writeSuccessData(map);
+    }
+    public static String getEncryRealFileName(Context ctx, String realFileName) {
+        UserInfo currentUserInfo = ContextUtil.getCurrentUserInfo(ctx);
+        return MessageFormat.format("{0}_{1}", realFileName, MD5.md5Hash(currentUserInfo.getId().toString()));
+    }
+
+    public byte[] convertPdfToByteArray(File file) throws IOException {
+        FileInputStream fis = new FileInputStream(file);
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+        byte[] buffer = new byte[1024];
+        int bytesRead;
+        while ((bytesRead = fis.read(buffer)) != -1) {
+            baos.write(buffer, 0, bytesRead);
+        }
+        fis.close();
+        baos.close();
+
+        return baos.toByteArray();
+    }
+
+    public Map<String, String> getSql(Set<String> set,Context ctx,int page,int num) throws BOSException, SQLException {
+        StringBuilder query = new StringBuilder();
+        query.append("SELECT").append("\n");
+        query.append("res.FBIZDATE bizDate,").append("\n");
+        query.append("org.FNAME_l3 orgName,").append("\n");
+        query.append("org.FPhoneNumber as orgPhone,").append("\n");
+        query.append("org.FCode as orgCode,").append("\n");
+        query.append("person.fname_l3 personName,").append("\n");
+        query.append("person.CFPinyin personPY,").append("\n");
+        query.append("person.CFOccupationcode personOccTion,").append("\n");
+        query.append("pal.FCredentialsTypeNO creNumber").append("\n");
+//        query.append("cre.fname_l3 creName,").append("\n");
+//        query.append("cre.fname_l3 creNumber").append("\n");
+        query.append("FROM t_hr_personposition pp").append("\n");
+        query.append("left join T_BD_person person on pp.FPERSONID = person.Fid").append("\n");
+        query.append("left join T_Org_admin org on org.fid = pp.FCOMPANYID").append("\n");
+        query.append("left join T_HR_ResignBizBillEntry res on res.FPERSONID = person.fid").append("\n");
+        query.append("left join T_HR_personcredentialsType pal on pal.FPERSONID = person.fid").append("\n");
+        //query.append("left join T_HR_CredentialsType cre on cre.FID = pal.fCredentialsTypeId").append("\n");
+        query.append("where person.FNUMBER in(").append("\n");
+        query.append(AtsUtil.convertSetToString(set));
+        query.append(")").append("\n");
+        query.append("and pal.FIsSingle='1' and res.FBIZDATE is not null").append("\n");
+        IRowSet kyIRowSet = DbUtil.executeQuery(ctx, query.toString());
+        Map<String, String> map = pdfData(kyIRowSet, page, num);
+        return map;
+    }
+
+    /**
+     * 按指定大小,分隔集合,将集合按规定个数分为n个部分
+     * @param inputList 数据
+     * @param setSize 分割长度
+     * @return
+     */
+    public <T> List<Set<T>> splitListIntoSets(List<T> inputList, int setSize) {
+        List<Set<T>> sets = new ArrayList<>();
+        for (int i = 0; i < inputList.size(); i += setSize) {
+            int endIndex = Math.min(i + setSize, inputList.size());
+            List<T> sublist = inputList.subList(i, endIndex);
+            Set<T> set = new HashSet<>(sublist);
+            sets.add(set);
+        }
+        return sets;
+    }
+
+    /**
+     * 填充模板中的数据
+     */
+    public void fillData(AcroFields fields, Map<String, String> data) throws DocumentException, IOException {
+        System.out.println("fillDatafillData12");
+        Map<String, AcroFields.Item> fields1 = fields.getFields();
+        System.out.println(fields1.keySet());
+        System.out.println(data);
+        fields.setField("year", "2024");
+        //fields.setField("empName", "22334");
+//        fields.setField("taxpayerName0", "234345");
+//        fields.setField("page", "2");
+        try {
+            for (String key : data.keySet()) {
+                String value = data.get(key);
+                fields.setField(key, value);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * 填充数据源
+     * 其中data存放的key值与pdf模板中的文本域值相对应
+     */
+    public Map<String, String> pdfData(IRowSet rowSet,int num,int page) throws SQLException {
+        Map<String, String> data = new HashMap<String, String>();
+        if (rowSet.size() == 0){
+            data.put("msg","所选员工未查询到离职员工或还在离职流程中");
+            data.put("msgType","0");
+            return data;
+        }
+        SimpleDateFormat outputFormatter = new SimpleDateFormat("dd/MM/yyyy");
+        int index = 2;
+        int indexAdd = 4;
+        Date date = new Date();
+        String dateStr = outputFormatter.format(date);
+        String sun = dateStr.substring(0, 2);
+        String month = dateStr.substring(3, 5);
+        String year = dateStr.substring(6, 10);
+        while (rowSet.next()) {
+            Date bizDate = rowSet.getDate("bizDate");//离职日期
+            String orgName = rowSet.getString("orgName");//所属公司
+            String orgPhone = rowSet.getString("orgPhone");//联系电话
+            String orgCode = rowSet.getString("orgCode");//雇主税号
+            String creNumber = rowSet.getString("creNumber");//证件类型编码
+            String personName = rowSet.getString("personName");//员工姓名
+            String personPY = rowSet.getString("personPY") != null ? rowSet.getString("personPY") : "";//外语拼音
+            String personOccTion = rowSet.getString("personOccTion");//员工信息-职业税编号
+            String leftStr = outputFormatter.format(bizDate);
+            if (index == 2){//表头 取第一条数据员工数据
+                data.put("topmostSubform[0].Page1[0].TextField1[0]", leftStr.substring(6,10)); //第一条员工离职的离职日期年份
+                data.put("topmostSubform[0].Page1[0].TextField1[1]", orgCode);//雇主税号 (行政组织维护-雇主税号) 1
+                data.put("topmostSubform[0].Page1[0].TextField1[2]", orgName); //雇主名称(员工信息-所属公司)
+                data.put("topmostSubform[0].Page1[0].TextField1[3]", orgPhone);//联系电话 (行政组织维护-联系电话) 1
+                data.put("topmostSubform[0].Page1[0].NumericField1[0]", String.valueOf(page+1)); //当前页数
+                data.put("topmostSubform[0].Page1[0].NumericField1[1]", String.valueOf(num)); //总页数
+                data.put("topmostSubform[0].Page1[0].TextField21[1]", orgName); //
+            }
+            data.put("topmostSubform[0].Page1[0].TextField1[" + indexAdd + "]", personOccTion); //税务号码(员工信息-职业税编号)
+            ++indexAdd;
+            data.put("topmostSubform[0].Page1[0].TextField1[" + indexAdd + "]", personName + " " + personPY); // 纳税人姓名(员工姓名+外语拼音)
+            ++indexAdd;
+            if ("62".equals(creNumber) || "64".equals(creNumber)){
+                creNumber = 15 + "/" + creNumber;
+            }else {
+                creNumber = 20 + "/" + creNumber;
+            }
+            data.put("topmostSubform[0].Page1[0].TextField1[" + indexAdd + "]", creNumber); //证件类型及编号(员工信息-证件类型和证件编码  澳门永久或非永久身份证为15  其他的都为20)
+            data.put("topmostSubform[0].Page1[0].TextField" +index+ "[0]", leftStr); //离职日期(离职单-离职日期)
+            index++;
+            ++indexAdd;
+        }
+        //key要与模板中的别名一一对应
+        data.put("topmostSubform[0].Page1[0].TextField23[0]", year);
+        data.put("topmostSubform[0].Page1[0].TextField22[0]", month);
+        data.put("topmostSubform[0].Page1[0].TextField24[0]", sun);
+        data.put("number", String.valueOf(rowSet.size()));
+        return data;
+    }
+
+
+}

+ 195 - 0
websrc/com/kingdee/eas/custom/ssPDF/utils/HttpClient3.java

@@ -0,0 +1,195 @@
+package com.kingdee.eas.custom.ssPDF.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));*/
+    }
+}

+ 97 - 0
websrc/com/kingdee/eas/custom/ssPDF/utils/PDFFillInformationUtil.java

@@ -0,0 +1,97 @@
+package com.kingdee.eas.custom.ssPDF.utils;
+
+import com.itextpdf.text.pdf.*;
+import com.kingdee.bos.BOSException;
+//import net.lingala.zip4j.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.ArrayList;
+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();
+            BaseFont bf = BaseFont.createFont("c:/windows/fonts/SIMSUN.TTC,1",BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);// 设置字段数据
+            ArrayList<BaseFont> fontList = new ArrayList<BaseFont>();
+            fontList.add(bf);
+            form.setSubstitutionFonts(fontList);
+            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);
+                //form.setFieldProperty(key, "setflags", PdfFormField.MARKUP_HIGHLIGHT, null);
+
+            }
+            //生成后的pdf 可以在编辑
+            pdfStamper.setFormFlattening(false);
+            // 关闭修改器,并释放资源
+            pdfStamper.close();
+            pdfReader.close();
+            File outFile = new File(tempFilePath+"/"+fileName);
+//            if (!outFile.createNewFile()) {
+//                throw new RuntimeException("pdf 填充数据失败!!");
+//            }
+            if (!(outFile.exists())) {
+                outFile.createNewFile();
+            } else {
+                outFile.delete();
+                outFile.createNewFile();
+            }
+
+            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());
+//        }
+//    }
+}