|
@@ -0,0 +1,790 @@
|
|
|
+package com.malk.ruisi.service.impl;
|
|
|
+
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.malk.ruisi.service.QysService;
|
|
|
+import com.malk.ruisi.service.RsQysService;
|
|
|
+import com.malk.server.aliwork.YDConf;
|
|
|
+import com.malk.server.aliwork.YDParam;
|
|
|
+import com.malk.server.common.McR;
|
|
|
+import com.malk.server.dingtalk.DDConf;
|
|
|
+import com.malk.service.aliwork.YDClient;
|
|
|
+import com.malk.utils.UtilMap;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.tomcat.util.http.fileupload.FileUtils;
|
|
|
+import org.apache.tomcat.util.http.fileupload.IOUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.io.*;
|
|
|
+import java.net.HttpURLConnection;
|
|
|
+import java.net.URL;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
+import java.util.zip.ZipEntry;
|
|
|
+import java.util.zip.ZipInputStream;
|
|
|
+
|
|
|
+import static com.malk.ruisi.constant.QysConstant.QYS_SUCCESS_CODE;
|
|
|
+
|
|
|
+@Service
|
|
|
+@Slf4j
|
|
|
+public class RsQysServiceImpl implements RsQysService {
|
|
|
+ @Autowired
|
|
|
+ private QysService qysService;
|
|
|
+ @Autowired
|
|
|
+ private YDClient ydClient;
|
|
|
+ @Autowired
|
|
|
+ private YDConf ydConf;
|
|
|
+ @Autowired
|
|
|
+ private DDConf ddConf;
|
|
|
+ @Value("${qiyuesuo.bdurl}")
|
|
|
+ private String BDURL;
|
|
|
+ @Value("${qiyuesuo.pdfbdurl}")
|
|
|
+ private String PDFBDURL;
|
|
|
+ @Value("${qiyuesuo.url}")
|
|
|
+ private String URL;
|
|
|
+ private String getCust(String type, String key) throws Exception {
|
|
|
+ Map<String, String> map = UtilMap.empty();
|
|
|
+ if (type.equals("FORM-55D56A69CCCE4043A01660C8910E33BAQ4N0")) {
|
|
|
+ // 合同用印 组件编号
|
|
|
+ map.put("subject", "textField_ltsbwegw");//合同名称
|
|
|
+ map.put("sn", "serialNumberField_ltsbweh2");//合同编号
|
|
|
+ map.put("tenantName", "textField_lvz1kozf");//公司名称
|
|
|
+ map.put("categoryId", "textField_lvm5xmqe");//业务分类Id
|
|
|
+ map.put("contractId", "textField_lwah8x72");//合同Id
|
|
|
+ map.put("categoryName", "textField_lvz1kozg");//业务分类名称
|
|
|
+ map.put("fujian", "attachmentField_ltsbweir");//附件
|
|
|
+ map.put("creatorName", "employeeField_ltsbwefl");//创建人姓名
|
|
|
+ map.put("applyerNumber", "textField_lwebkb16");//创建人员工编号
|
|
|
+ map.put("sealName", "textField_lvw4umfr");//授权印章名称
|
|
|
+ map.put("count", "numberField_ltwa0vj6");//授权次数
|
|
|
+ map.put("mobile", "textField_lwzqvg93");//授权人手机号
|
|
|
+ map.put("tenantNameP", "textField_ltwa0vke");//对方个人签署人姓名
|
|
|
+ map.put("contactP", "textField_ltwa0vkf");//对方个人签署人联系电话
|
|
|
+ map.put("tenantNameA", "textField_ltwa0vk0");//对方公司名称
|
|
|
+ map.put("receiverNameA", "textField_ltwa0vk1");//对方公司签署人名称
|
|
|
+ map.put("contactA", "textField_ltwa0vk2");//对方公司签署人联系电话
|
|
|
+ } else if (type.equals("FORM-5DB656AF0F0E4EFA85A4739D55C23ED85BXO")) {
|
|
|
+ // 框架类用印
|
|
|
+ map.put("subject", "textField_lvz8coad");//合同名称
|
|
|
+ map.put("sn", "serialNumberField_lvz8coae");//合同编号
|
|
|
+ map.put("tenantName", "textField_lvza5uwu");//公司名称
|
|
|
+ map.put("categoryId", "textField_lvz8cobe");//业务分类Id
|
|
|
+ map.put("contractId", "textField_lwg205ug");//合同Id
|
|
|
+ map.put("categoryName", "textField_lvz8cobd");//业务分类名称
|
|
|
+ map.put("fujian", "attachmentField_lvz8cocl");//附件
|
|
|
+ map.put("creatorName", "employeeField_lvz8co98");//创建人姓名
|
|
|
+ map.put("applyerNumber", "textField_lweccz0q");//创建人员工编号
|
|
|
+ map.put("sealName", "textField_lwelg27e");//授权印章名称
|
|
|
+ map.put("mobile", "textField_lwzqvg93");//授权人手机号
|
|
|
+ map.put("count", "numberField_lvz8cobz");//授权次数
|
|
|
+ map.put("tenantNameP", "textField_lvz8cocg");//对方个人签署人姓名
|
|
|
+ map.put("contactP", "textField_lvz8coce");//对方个人签署人联系电话
|
|
|
+ map.put("tenantNameA", "textField_lvz8coc5");//对方公司名称
|
|
|
+ map.put("receiverNameA", "textField_lvz8coc6");//对方公司签署人名称
|
|
|
+ map.put("contactA", "textField_lvz8coc7");//对方公司签署人联系电话
|
|
|
+
|
|
|
+ } else if (type.equals("FORM-B27C1AE7298648F29E836B5FDF469DBDPFCK")) {
|
|
|
+ // 其他用印
|
|
|
+ map.put("subject", "textField_ltwktalv");//合同名称
|
|
|
+ map.put("sn", "serialNumberField_ltwktal5");//合同编号
|
|
|
+ map.put("tenantName", "textField_lvz45lif");//公司名称
|
|
|
+ map.put("categoryId", "textField_lvz45lii");//业务分类Id
|
|
|
+ map.put("contractId", "textField_lwg1z6hk");//合同Id
|
|
|
+ map.put("applyerNumber", "textField_lwelap55");//创建人员工编号
|
|
|
+ map.put("sealName", "textField_lx1gzqai");//授权印章名称
|
|
|
+ map.put("mobile", "textField_lwzqvg93");//授权人手机号
|
|
|
+ map.put("count", "numberField_ltwktalp");//授权次数
|
|
|
+ map.put("categoryName", "textField_lvz45lih");//业务分类名称
|
|
|
+ map.put("fujian", "attachmentField_ltwktamq");//附件
|
|
|
+// map.put("creatorName", "employeeField_ltwktal6");//创建人姓名
|
|
|
+// map.put("creatorContact", "textField_ltsbwef1");//创建人联系方式
|
|
|
+// map.put("receiverNameP", "textField_ltwa0vke");//对方个人签署人姓名
|
|
|
+// map.put("contactP", "textField_ltwa0vkf");//对方个人签署人联系电话
|
|
|
+// map.put("tenantNameA", "textField_ltwa0vk0");//对方公司名称
|
|
|
+// map.put("receiverNameA", "textField_ltwa0vk1");//对方公司签署人名称
|
|
|
+// map.put("contactA", "textField_ltwa0vk2");//对方公司签署人联系电话
|
|
|
+ } else if (type.equals("FORM-FCDDD18FD63E49B2A4C652FBDB1874F6DPHW")) {
|
|
|
+ // 租赁类用印 组件编号
|
|
|
+ map.put("subject", "textField_ltwcj54k");//合同名称
|
|
|
+ map.put("sn", "serialNumberField_ltwcj54l");//合同编号
|
|
|
+ map.put("tenantName", "textField_lvz3j6lq");//公司名称
|
|
|
+ map.put("categoryId", "textField_lvz3j6ls");//业务分类Id
|
|
|
+ map.put("contractId", "textField_lwg1wbix");//合同Id
|
|
|
+ map.put("mobile", "textField_lwzqvg93");//授权人手机号
|
|
|
+ map.put("categoryName", "textField_ltwe0wyb");//业务分类名称
|
|
|
+ map.put("fujian", "attachmentField_ltwe0wyz");//附件
|
|
|
+ map.put("creatorName", "employeeField_ltwcj52j");//创建人姓名
|
|
|
+ map.put("applyerNumber", "textField_lwel4lyq");//创建人员工编号
|
|
|
+// map.put("creatorContact", "textField_ltsbwef1");//创建人联系方式
|
|
|
+ map.put("tenantNameP", "textField_ltwe0wyw");//对方个人签署人姓名
|
|
|
+ map.put("contactP", "textField_ltwe0wyx");//对方个人签署人联系电话
|
|
|
+ map.put("tenantNameA", "textField_ltwe0wyq");//对方公司名称
|
|
|
+ map.put("receiverNameA", "textField_ltwe0wyr");//对方公司签署人名称
|
|
|
+ map.put("contactA", "textField_ltwe0wys");//对方公司签署人联系电话
|
|
|
+// } else if (type.equals("FORM-53A0FB8715FB4378B0708794DFAF7089SV8P")) {
|
|
|
+// // 加盟签约
|
|
|
+// map.put("subject", "textField_ltsbwegw");//合同名称
|
|
|
+// map.put("sn", "serialNumberField_ltsbweh2");//合同编号
|
|
|
+// map.put("tenantName", "textField_lvz1kozf");//公司名称
|
|
|
+// map.put("categoryId", "textField_lvm5xmqe");//业务分类Id
|
|
|
+// map.put("fujian", "attachmentField_ltsbweir");//附件
|
|
|
+// map.put("creatorName", "employeeField_ltsbwefl");//创建人姓名
|
|
|
+// map.put("creatorContact", "textField_ltsbwef1");//创建人联系方式
|
|
|
+// map.put("receiverNameP", "textField_ltwa0vke");//对方个人签署人姓名
|
|
|
+// map.put("contactP", "textField_ltwa0vkf");//对方个人签署人联系电话
|
|
|
+// map.put("tenantNameA", "textField_ltwa0vk0");//对方公司名称
|
|
|
+// map.put("receiverNameA", "textField_ltwa0vk1");//对方公司签署人名称
|
|
|
+// map.put("contactA", "textField_ltwa0vk2");//对方公司签署人联系电话
|
|
|
+ } else if (type.equals("FORM-88F968E75CC340EB91B1AC692F4184DC9I9W")) {
|
|
|
+ // 合同/申购流程
|
|
|
+ map.put("subject", "textField_lu7ycpub");//合同名称
|
|
|
+ map.put("sn", "serialNumberField_lu7ycpuc");//合同编号
|
|
|
+ map.put("tenantName", "textField_lw05x5rk");//公司名称
|
|
|
+ map.put("categoryId", "textField_lw05x5rm");//业务分类Id
|
|
|
+ map.put("contractId", "textField_lwg219kl");//合同Id
|
|
|
+ map.put("mobile", "textField_lwzqvg93");//授权人手机号
|
|
|
+ map.put("categoryName", "textField_lwa2350q");//业务分类名称
|
|
|
+ map.put("fujian", "attachmentField_lu81zomp");//附件
|
|
|
+ map.put("applyerNumber", "textField_lwelmmkr");//创建人员工编号
|
|
|
+ map.put("sealName", "textField_lwelmmks");//授权印章名称
|
|
|
+ map.put("count", "numberField_lual6ol8");//授权次数
|
|
|
+// map.put("creatorName", "employeeField_ltsbwefl");//创建人姓名
|
|
|
+// map.put("creatorContact", "textField_ltsbwef1");//创建人联系方式
|
|
|
+ map.put("tenantNameP", "textField_lu81zome");//对方个人签署人姓名
|
|
|
+ map.put("contactP", "textField_lu81zomf");//对方个人签署人联系电话
|
|
|
+ map.put("tenantNameA", "textField_lu81zomd");//对方公司名称
|
|
|
+ map.put("receiverNameA", "textField_lu81zome");//对方公司签署人名称
|
|
|
+ map.put("contactA", "textField_lu81zomf");//对方公司签署人联系电话
|
|
|
+
|
|
|
+ } else if (type.equals("FORM-54972289A0B7416287A9BA44DA6CCDC50QUC")) {
|
|
|
+ // HR用印
|
|
|
+ map.put("subject", "textField_lu9euh7n");//合同名称
|
|
|
+ map.put("sn", "serialNumberField_lu9euh7o");//合同编号
|
|
|
+ map.put("tenantName", "textField_lvzz59hk");//公司名称
|
|
|
+ map.put("categoryId", "textField_lvzz59hn");//业务分类Id
|
|
|
+ map.put("contractId", "textField_lwg22nvj");//合同Id
|
|
|
+ map.put("mobile", "textField_lwzqvg93");//授权人手机号
|
|
|
+ map.put("categoryName", "textField_lvzz59hm");//业务分类名称
|
|
|
+ map.put("applyerNumber", "textField_lweezm68");//创建人员工编号
|
|
|
+ map.put("sealName", "textField_lweezm69");//授权印章名称
|
|
|
+ map.put("count", "numberField_lu9euh8c");//授权次数
|
|
|
+ map.put("fujian", "attachmentField_lu9euh8d");//附件
|
|
|
+ } else if (type.equals("FORM-0D501EF1688247DC932E7784298BD46BRYHC")) {
|
|
|
+ // 新签劳动合同/协议
|
|
|
+ map.put("subject", "textField_luauhgb4");//合同名称
|
|
|
+ map.put("sn", "serialNumberField_luauhgb5");//合同编号
|
|
|
+ map.put("tenantName", "textField_lw4rpz1w");//公司名称
|
|
|
+ map.put("categoryId", "textField_lw4rpz1x");//业务分类Id
|
|
|
+ map.put("mobile", "textField_lwzqvg93");//授权人手机号
|
|
|
+ map.put("jf", "textField_lwk0stof");//甲方名称
|
|
|
+ map.put("txdz", "textField_lup3q6ke");//甲方通讯地址
|
|
|
+ map.put("yf", "textField_lup3q6kf");//乙方
|
|
|
+ map.put("sjhm", "textField_lup3q6kg");//乙方手机号码
|
|
|
+ map.put("syqksrq", "dateField_lup3q6kv");//试用期开始日期
|
|
|
+ map.put("syqjsrq", "dateField_lup3q6kw");//试用期结束日期
|
|
|
+ map.put("ldhtksrq", "dateField_lup3q6kx");//劳动合同开始日期
|
|
|
+ map.put("ldhtjsrq", "dateField_lup3q6ky");//劳动合同结束日期
|
|
|
+ map.put("gzdd", "textField_lup3q6kk");//工作地点
|
|
|
+ map.put("yftgfw", "textField_lup3q6kh");//乙方提供服务
|
|
|
+ map.put("xchsgz", "selectField_lup3q6ki");//薪酬核算规则
|
|
|
+ map.put("dyzmtbc", "numberField_lup3q6kj");//报酬金额
|
|
|
+ map.put("dyzarksrq", "dateField_lup3q6kl");//开始日期
|
|
|
+ map.put("dyzarjsrq", "dateField_lup3q6km");//结束日期
|
|
|
+ map.put("contractId", "textField_lwg241g6");//合同Id
|
|
|
+ map.put("categoryName", "textField_lwa1xm1p");//业务分类名称
|
|
|
+ map.put("tenantNameP", "textField_lup3q6kf");//对方个人签署人姓名
|
|
|
+ map.put("contactP", "textField_lup3q6kg");//对方个人签署人联系电话
|
|
|
+ } else if (type.equals("FORM-3E04D5456B2341CCBA62C955B791CF45IAH1")) {
|
|
|
+ // 发文审批用印
|
|
|
+ map.put("subject", "textField_ltwmutnp");//合同名称
|
|
|
+ map.put("sn", "serialNumberField_ltwmutno");//合同编号
|
|
|
+ map.put("tenantName", "textField_lw044nmp");//公司名称
|
|
|
+ map.put("categoryId", "textField_lw044nmr");//业务分类Id
|
|
|
+ map.put("contractId", "textField_lwg251gn");//合同Id
|
|
|
+ map.put("mobile", "textField_lwzqvg93");//授权人手机号
|
|
|
+ map.put("categoryName", "textField_ltwmutoc");//业务分类名称
|
|
|
+ map.put("applyerNumber", "textField_lweluap2");//创建人员工编号
|
|
|
+ map.put("sealName", "textField_lweluap3");//授权印章名称
|
|
|
+ map.put("count", "numberField_ltwmutow");//授权次数
|
|
|
+ map.put("fujian", "attachmentField_ltwmutq4");//附件
|
|
|
+ } else if (type.equals("FORM-87BD065161F84560B999FE94713255E20E6E")) {
|
|
|
+ //印章授权&承诺书
|
|
|
+ map.put("subject", "textField_ltwp3e43");//合同名称
|
|
|
+ map.put("sn", "serialNumberField_ltwp3e44");//合同编号
|
|
|
+ map.put("tenantName", "textField_lw04hhp1");//公司名称
|
|
|
+ map.put("categoryId", "textField_lw04hhp3");//业务分类Id
|
|
|
+ map.put("contractId", "textField_lwg260n6");//合同Id
|
|
|
+ map.put("mobile", "textField_lwzqvg93");//授权人手机号
|
|
|
+ map.put("categoryName", "textField_lwa29saw");//业务分类名称
|
|
|
+ map.put("fujian", "attachmentField_ltwp3e4g");//附件
|
|
|
+ map.put("tenantNameP", "textField_lw93mjk9");//授权人姓名
|
|
|
+ map.put("contactP", "textField_ltwp3e4d");//授权人联系电话
|
|
|
+ map.put("tenantNameA", "textField_lw93mjka");//被授权人姓名
|
|
|
+ map.put("contactA", "textField_ltwp3e4f");//被授权人联系电话
|
|
|
+ } else {
|
|
|
+ throw new Exception();
|
|
|
+ }
|
|
|
+ return map.get(key);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public McR createByFile(JSONObject param) throws Exception {
|
|
|
+ String formInstanceId = param.getString("formInstanceId");
|
|
|
+ String type = param.getString("type");
|
|
|
+ log.info("formInstanceId:{}", formInstanceId);
|
|
|
+ log.info("type:{}", type);
|
|
|
+ //根据实例ID获取表单数据
|
|
|
+ Map data = (Map) ydClient.queryData(YDParam.builder().formInstId(formInstanceId)
|
|
|
+ .appType(ydConf.getAppType()).systemToken(ydConf.getSystemToken())
|
|
|
+ .userId(ddConf.getOperator()).build(), YDConf.FORM_QUERY.retrieve_id).getFormData();
|
|
|
+ log.info("data:{}", data);
|
|
|
+ //把文件下载到本地路径 ,并获取到文档ID
|
|
|
+ List<String> documentId = new ArrayList<>();
|
|
|
+ if (!type.equals("FORM-0D501EF1688247DC932E7784298BD46BRYHC")) {
|
|
|
+ documentId = createbyfile(data, type);
|
|
|
+ }
|
|
|
+ //定义参数 创建合同草稿
|
|
|
+ JSONObject obj = new JSONObject();
|
|
|
+// obj.put("subject",data.get("textField_ltsbwef0"));//合同名称
|
|
|
+ obj.put("subject", data.get(getCust(type, "subject")).toString());//合同名称
|
|
|
+// obj.put("sn",data.get("serialNumberField_ltsbweh2"));//合同编号流水号
|
|
|
+ obj.put("sn", data.get(getCust(type, "sn")));//合同编号流水号
|
|
|
+ obj.put("tenantName", data.get(getCust(type, "tenantName")));//发起方公司名称
|
|
|
+ obj.put("categoryId", data.get(getCust(type, "categoryId")));//业务分类Id data.get("textField_lvm5xmqe")
|
|
|
+ if (!type.equals("FORM-0D501EF1688247DC932E7784298BD46BRYHC")) {
|
|
|
+ if (documentId != null) {
|
|
|
+ obj.put("documents", documentId);//文档ID
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<Map<String, Object>> params1 = new ArrayList<>();
|
|
|
+ List<Map<String, Object>> params2 = new ArrayList<>();
|
|
|
+ if (type.equals("FORM-0D501EF1688247DC932E7784298BD46BRYHC")) {
|
|
|
+ JSONObject jf = new JSONObject();
|
|
|
+ jf.put("name", "jf");
|
|
|
+ jf.put("value", data.get(getCust(type, "jf")));//甲方名称
|
|
|
+ JSONObject txdz = new JSONObject();
|
|
|
+ txdz.put("name", "txdz");
|
|
|
+ txdz.put("value", data.get(getCust(type, "txdz")));//甲方通讯地址
|
|
|
+ JSONObject yf = new JSONObject();
|
|
|
+ yf.put("name", "yf");
|
|
|
+ yf.put("value", data.get(getCust(type, "yf")));//乙方
|
|
|
+ JSONObject sjhm = new JSONObject();
|
|
|
+ sjhm.put("name", "sjhm");
|
|
|
+ sjhm.put("value", data.get(getCust(type, "sjhm")));//乙方手机号码
|
|
|
+ JSONObject syqksrq = new JSONObject();
|
|
|
+ long timestamp = (long) data.get(getCust(type, "syqksrq"));
|
|
|
+ // 创建 SimpleDateFormat 对象来定义输出日期的格式
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ // 将时间戳转换为 Date 对象
|
|
|
+ Date date = new Date(timestamp);
|
|
|
+ // 使用 SimpleDateFormat 格式化 Date 对象为所需的日期格式
|
|
|
+ String formattedDate = sdf.format(date);
|
|
|
+ syqksrq.put("name", "syqksrq");
|
|
|
+ syqksrq.put("value", formattedDate);//试用期开始日期
|
|
|
+ JSONObject syqjsrq = new JSONObject();
|
|
|
+ long timestamp1 = (long) data.get(getCust(type, "syqjsrq"));
|
|
|
+ // 将时间戳转换为 Date 对象
|
|
|
+ Date date1 = new Date(timestamp1);
|
|
|
+ // 使用 SimpleDateFormat 格式化 Date 对象为所需的日期格式
|
|
|
+ String formattedDate1 = sdf.format(date1);
|
|
|
+ syqjsrq.put("name", "syqjsrq");
|
|
|
+ syqjsrq.put("value", formattedDate1);//试用期结束日期
|
|
|
+ JSONObject ldhtksrq = new JSONObject();
|
|
|
+ long timestamp2 = (long) data.get(getCust(type, "syqksrq"));
|
|
|
+ // 将时间戳转换为 Date 对象
|
|
|
+ Date date2 = new Date(timestamp2);
|
|
|
+ // 使用 SimpleDateFormat 格式化 Date 对象为所需的日期格式
|
|
|
+ String formattedDate2 = sdf.format(date2);
|
|
|
+ ldhtksrq.put("name", "ldhtksrq");
|
|
|
+ ldhtksrq.put("value", formattedDate2);//劳动合同开始日期
|
|
|
+ JSONObject ldhtjsrq = new JSONObject();
|
|
|
+ long timestamp3 = (long) data.get(getCust(type, "ldhtjsrq"));
|
|
|
+ // 将时间戳转换为 Date 对象
|
|
|
+ Date date3 = new Date(timestamp3);
|
|
|
+ // 使用 SimpleDateFormat 格式化 Date 对象为所需的日期格式
|
|
|
+ String formattedDate3 = sdf.format(date3);
|
|
|
+ ldhtjsrq.put("name", "ldhtjsrq");
|
|
|
+ ldhtjsrq.put("value", formattedDate3);//劳动合同结束日期
|
|
|
+ JSONObject gzdd = new JSONObject();
|
|
|
+ gzdd.put("name", "gzdd");
|
|
|
+ gzdd.put("value", data.get(getCust(type, "gzdd")));//工作地点
|
|
|
+ JSONObject yftgfw = new JSONObject();
|
|
|
+ yftgfw.put("name", "yftgfw");
|
|
|
+ yftgfw.put("value", data.get(getCust(type, "yftgfw")));//乙方提供服务
|
|
|
+ JSONObject xchsgz = new JSONObject();
|
|
|
+ xchsgz.put("name", "xchsgz");
|
|
|
+ xchsgz.put("value", data.get(getCust(type, "xchsgz")));//薪酬核算规则
|
|
|
+ JSONObject dyzmtbc = new JSONObject();
|
|
|
+ dyzmtbc.put("name", "dyzmtbc");
|
|
|
+ dyzmtbc.put("value", data.get(getCust(type, "dyzmtbc")));//报酬金额
|
|
|
+ JSONObject dyzarksrq = new JSONObject();
|
|
|
+ long timestamp4 = (long) data.get(getCust(type, "syqjsrq"));
|
|
|
+ // 将时间戳转换为 Date 对象
|
|
|
+ Date date4 = new Date(timestamp4);
|
|
|
+ // 使用 SimpleDateFormat 格式化 Date 对象为所需的日期格式
|
|
|
+ String formattedDate4 = sdf.format(date4);
|
|
|
+ dyzarksrq.put("name", "dyzarksrq");
|
|
|
+ dyzarksrq.put("value", formattedDate4);//开始日期
|
|
|
+ JSONObject dyzarjsrq = new JSONObject();
|
|
|
+ long timestamp5 = (long) data.get(getCust(type, "syqjsrq"));
|
|
|
+ // 将时间戳转换为 Date 对象
|
|
|
+ Date date5 = new Date(timestamp5);
|
|
|
+ // 使用 SimpleDateFormat 格式化 Date 对象为所需的日期格式
|
|
|
+ String formattedDate5 = sdf.format(date5);
|
|
|
+ dyzarjsrq.put("name", "dyzarjsrq");
|
|
|
+ dyzarjsrq.put("value", formattedDate5);//结束日期
|
|
|
+ params1.add(jf);
|
|
|
+ params1.add(txdz);
|
|
|
+ params1.add(yf);
|
|
|
+ params1.add(sjhm);
|
|
|
+ params1.add(syqksrq);
|
|
|
+ params1.add(syqjsrq);
|
|
|
+ params1.add(ldhtksrq);
|
|
|
+ params1.add(ldhtjsrq);
|
|
|
+ params1.add(gzdd);
|
|
|
+ params2.add(jf);
|
|
|
+ params2.add(txdz);
|
|
|
+ params2.add(yf);
|
|
|
+ params2.add(sjhm);
|
|
|
+ params2.add(yftgfw);
|
|
|
+ params2.add(xchsgz);
|
|
|
+ params2.add(dyzmtbc);
|
|
|
+ params2.add(dyzarksrq);
|
|
|
+ params2.add(dyzarjsrq);
|
|
|
+ }
|
|
|
+ String categoryName = data.get(getCust(type, "categoryName")).toString();
|
|
|
+ if (categoryName.equals("劳动合同") || categoryName.equals("校区劳动合同")
|
|
|
+ ) {
|
|
|
+ obj.put("send", true);
|
|
|
+ obj.put("documentParams", params1);
|
|
|
+ } else if (categoryName.equals("校区劳务协议") || categoryName.equals("劳务协议")) {
|
|
|
+ obj.put("send", true);
|
|
|
+ obj.put("documentParams", params2);
|
|
|
+ } else {
|
|
|
+ obj.put("send", false);// 是否发起合同;发起合同后不能再进行添加文档、指定签署位置等操作
|
|
|
+ }
|
|
|
+ //签署人数据
|
|
|
+ JSONArray array = new JSONArray();
|
|
|
+ JSONArray array1 = new JSONArray();
|
|
|
+
|
|
|
+ if (categoryName.equals("多方电子用印(个人)(我方先签)") ||
|
|
|
+ categoryName.equals("我方电子对方物理(个人)(我方先签)")) {
|
|
|
+ array.add(getCompASignatory());
|
|
|
+ array.add(getPeopSignatory(data.get(getCust(type, "tenantNameP")).toString(), data.get(getCust(type, "contactP")).toString()));
|
|
|
+ } else if (categoryName.equals("我方电子对方物理(企业)(我方先签)") ||
|
|
|
+ categoryName.equals("多方电子用印(企业)(我方先签)")) {
|
|
|
+ array.add(getCompASignatory());
|
|
|
+ array.add(getCompSignatory(data.get(getCust(type, "tenantNameA")).toString(), data.get(getCust(type, "contactA")).toString(), data.get(getCust(type, "receiverNameA")).toString()));
|
|
|
+ } else if (categoryName.equals("我方电子对方物理(企业&个人)(我方先签)") ||
|
|
|
+ categoryName.equals("多方电子用印(企业&个人)(我方先签)")) {
|
|
|
+ array.add(getCompASignatory());
|
|
|
+ array.add(getCompSignatory(data.get(getCust(type, "tenantNameA")).toString(), data.get(getCust(type, "contactA")).toString(), data.get(getCust(type, "receiverNameA")).toString()));
|
|
|
+ array.add(getPeopSignatory(data.get(getCust(type, "tenantNameP")).toString(), data.get(getCust(type, "contactP")).toString()));
|
|
|
+ } else if (categoryName.equals("我方电子对方物理(个人)") ||
|
|
|
+ categoryName.equals("多方电子用印(个人)(对方先签)") ||
|
|
|
+ categoryName.equals("劳动合同") ||
|
|
|
+ categoryName.equals("校区劳务协议") ||
|
|
|
+ categoryName.equals("校区劳动合同") ||
|
|
|
+ categoryName.equals("劳务协议") ||
|
|
|
+ categoryName.equals("续签(固定几年)") ||
|
|
|
+ categoryName.equals("续签(无固定期限)") ||
|
|
|
+ categoryName.equals("续签(员工合同到期公司不再与员工续签)") ||
|
|
|
+ categoryName.equals("续签(员工合同到期员工本人不愿意与公司续签时签订)") ||
|
|
|
+ categoryName.equals("解除劳动合同")
|
|
|
+ ) {
|
|
|
+ array.add(getPeopSignatory(data.get(getCust(type, "tenantNameP")).toString(), data.get(getCust(type, "contactP")).toString()));
|
|
|
+ array.add(getCompASignatory());
|
|
|
+ } else if (categoryName.equals("我方电子对方物理(企业)") ||
|
|
|
+ categoryName.equals("多方电子用印(企业)(对方先签)")) {
|
|
|
+ array.add(getCompSignatory(data.get(getCust(type, "tenantNameA")).toString(), data.get(getCust(type, "contactA")).toString(), data.get(getCust(type, "receiverNameA")).toString()));
|
|
|
+ array.add(getCompASignatory());
|
|
|
+ } else if (categoryName.equals("我方电子对方物理(企业&个人)") ||
|
|
|
+ categoryName.equals("多方电子用印(企业&个人)(对方先签)")) {
|
|
|
+ array.add(getCompSignatory(data.get(getCust(type, "tenantNameA")).toString(), data.get(getCust(type, "contactA")).toString(), data.get(getCust(type, "receiverNameA")).toString()));
|
|
|
+ array.add(getPeopSignatory(data.get(getCust(type, "tenantNameP")).toString(), data.get(getCust(type, "contactP")).toString()));
|
|
|
+ array.add(getCompASignatory());
|
|
|
+ } else if (categoryName.equals("内部企业单签") ||
|
|
|
+ categoryName.equals("默认业务分类")) {
|
|
|
+ array.add(getCompASignatory());
|
|
|
+ } else if (categoryName.equals("印章保管授权&承诺书")) {
|
|
|
+ array.add(getPeopSignatory(data.get(getCust(type, "tenantNameP")).toString(), data.get(getCust(type, "contactP")).toString()));
|
|
|
+ array.add(getPeopSignatory(data.get(getCust(type, "tenantNameA")).toString(), data.get(getCust(type, "contactA")).toString()));
|
|
|
+ } else if (categoryName.equals("物理用印外带场景") ||
|
|
|
+ categoryName.equals("物理用印公司用印场景")) {
|
|
|
+ array1.add(getAuths(data.get(getCust(type, "sealName")).toString(), data.get(getCust(type, "count")).toString()));
|
|
|
+ }
|
|
|
+ //把所有参数传到obj中
|
|
|
+ if (categoryName.equals("物理用印外带场景") ||
|
|
|
+ categoryName.equals("物理用印公司用印场景")) {
|
|
|
+ obj.put("applyerNumber", data.get(getCust(type, "applyerNumber")));
|
|
|
+ obj.put("auths", array1);
|
|
|
+ } else {
|
|
|
+ obj.put("signatories", array);
|
|
|
+ }
|
|
|
+ System.out.println("obj:{}" + obj);
|
|
|
+ try {
|
|
|
+ if (categoryName.equals("物理用印外带场景") ||
|
|
|
+ categoryName.equals("物理用印公司用印场景")) {
|
|
|
+ qysService.createseal(obj);
|
|
|
+ } else {
|
|
|
+ //1.调用创建合同草稿方法
|
|
|
+ JSONObject draft = qysService.createDraft(obj);
|
|
|
+ System.out.println(draft);
|
|
|
+ if (draft != null) {
|
|
|
+ String contractId = draft.getString("contractId");
|
|
|
+ if (contractId != "") {
|
|
|
+ //发起合同
|
|
|
+ System.out.println("contractId" + contractId);
|
|
|
+// //合同id 写入宜搭
|
|
|
+ String sc = getCust(type, "sn");//合同id字段
|
|
|
+ String sc_values = data.get(getCust(type, "sn")).toString();//合同id字段的值
|
|
|
+ String fd = getCust(type, "contractId");//字段名称
|
|
|
+ ydClient.operateData(YDParam.builder()
|
|
|
+ .formUuid(type)
|
|
|
+ .searchCondition(JSONObject.toJSONString(UtilMap.map(sc, sc_values)))
|
|
|
+ .formDataJson(JSONObject.toJSONString(UtilMap.map(fd, contractId)))
|
|
|
+ .build(), YDConf.FORM_OPERATION.upsert).toString();
|
|
|
+ qysService.send(contractId, data.get(getCust(type, "tenantName")).toString());
|
|
|
+// FileUtil.file("C:\\Users\\Administrator\\Desktop\\合同.pdf");
|
|
|
+// System.out.println("send:" + send);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return McR.success("success");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public McR callback(Map<String, String> param) throws Exception {
|
|
|
+ String sn = param.get("sn");
|
|
|
+ String contractId = param.get("contractId");
|
|
|
+ String status = param.get("status");
|
|
|
+ log.info("sn:{}", sn);
|
|
|
+ log.info("contractId:{}", contractId);
|
|
|
+ if (status.equals("SIGNED")) {
|
|
|
+ qysService.download(contractId, new File(BDURL + sn + ".zip"));
|
|
|
+ }
|
|
|
+ List<String> unzippedFiles = new ArrayList<>();
|
|
|
+ String zipFilePath = BDURL + sn + ".zip";
|
|
|
+ String destDirectory = PDFBDURL + sn;
|
|
|
+ try {
|
|
|
+ File destDir = new File(destDirectory);
|
|
|
+ if (!destDir.exists()) {
|
|
|
+ destDir.mkdir();
|
|
|
+ }
|
|
|
+ byte[] buffer = new byte[1024];
|
|
|
+ ZipInputStream zipIn = new ZipInputStream(new FileInputStream(zipFilePath));
|
|
|
+ ZipEntry entry = zipIn.getNextEntry();
|
|
|
+ while (entry != null) {
|
|
|
+ String filePath = destDirectory + File.separator + entry.getName();
|
|
|
+ if (!entry.isDirectory()) {
|
|
|
+ new File(filePath).getParentFile().mkdirs();
|
|
|
+ FileOutputStream fos = new FileOutputStream(filePath);
|
|
|
+ int len;
|
|
|
+ while ((len = zipIn.read(buffer)) > 0) {
|
|
|
+ fos.write(buffer, 0, len);
|
|
|
+ }
|
|
|
+ fos.close();
|
|
|
+ unzippedFiles.add(filePath);
|
|
|
+ }
|
|
|
+ zipIn.closeEntry();
|
|
|
+ entry = zipIn.getNextEntry();
|
|
|
+ }
|
|
|
+ zipIn.close();
|
|
|
+ System.out.println("ZIP 文件解压完成。");
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.out.println("发生异常: " + e.getMessage());
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ List list = new ArrayList();
|
|
|
+ for (String unzippedFile : unzippedFiles) {
|
|
|
+ Map map = new HashMap();
|
|
|
+ String fileName = FileUtil.getName(unzippedFile);
|
|
|
+ map.put("downloadUrl", URL + sn + "/" + fileName);
|
|
|
+ map.put("name", fileName);
|
|
|
+ map.put("previewUrl", map.get("downloadUrl"));
|
|
|
+ map.put("url", map.get("downloadUrl"));
|
|
|
+ map.put("ext", FileUtil.extName(unzippedFile));
|
|
|
+ list.add(map);
|
|
|
+ }
|
|
|
+ log.info("list:{}", list);
|
|
|
+ //查询宜搭底表数据
|
|
|
+ String[] sns = sn.split("-");
|
|
|
+ Map<String, String> formUuid = getFormUuid(sns[0]);
|
|
|
+ List<Map> list1 = (List<Map>) ydClient.queryData(YDParam.builder().formUuid(formUuid.get("type")).searchCondition(
|
|
|
+ JSONObject.toJSONString(UtilMap.map(formUuid.get("sn"), sn))
|
|
|
+ ).build(), YDConf.FORM_QUERY.retrieve_list).getData();
|
|
|
+ Map map = list1.get(0);
|
|
|
+ String instanceId = (String) map.get("formInstanceId");
|
|
|
+ ydClient.operateData(YDParam.builder()
|
|
|
+ .appType(ydConf.getAppType()).systemToken(ydConf.getSystemToken())
|
|
|
+ .userId(ddConf.getOperator()).formInstId(instanceId)
|
|
|
+ .updateFormDataJson(JSONObject.toJSONString(UtilMap.map("attachmentField_ltsbweit", list)))
|
|
|
+ .build(), YDConf.FORM_OPERATION.update);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public McR appointurl(String contractId) throws Exception {
|
|
|
+ try {
|
|
|
+ log.info("获取预签署地址 {}",contractId);
|
|
|
+ JSONObject urlR=qysService.appointurl(contractId);
|
|
|
+ String presignUrl = urlR.getString("presignUrl");
|
|
|
+ if(!QYS_SUCCESS_CODE.equals(urlR.getString("code"))){
|
|
|
+ return McR.error(urlR.getString("code"),urlR.getString("message"));
|
|
|
+ }else{
|
|
|
+ return McR.success(presignUrl);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ return McR.error("401","获取失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+// @Override
|
|
|
+// public McR sendContract(String contractId,String tenantName) throws Exception {
|
|
|
+// JSONObject send = qysService.send(contractId, tenantName);
|
|
|
+// return McR.success(send);
|
|
|
+// }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public McR apply(JSONObject param) throws Exception {
|
|
|
+ String formInstanceId = param.getString("formInstanceId");
|
|
|
+ String type = param.getString("type");
|
|
|
+ log.info("formInstanceId:{}", formInstanceId);
|
|
|
+ log.info("type:{}", type);
|
|
|
+ //根据实例ID获取表单数据
|
|
|
+ Map data = (Map) ydClient.queryData(YDParam.builder().formInstId(formInstanceId)
|
|
|
+ .userId(ddConf.getOperator()).build(), YDConf.FORM_QUERY.retrieve_id).getFormData();
|
|
|
+ log.info("data:{}", data);
|
|
|
+ JSONObject obj = new JSONObject();
|
|
|
+ JSONObject obj1 = new JSONObject();
|
|
|
+ JSONObject obj2 = new JSONObject();
|
|
|
+ JSONArray arr = new JSONArray();
|
|
|
+ JSONArray arr1 = new JSONArray();
|
|
|
+ obj2.put("mobile", data.get(getCust(type, "mobile")));
|
|
|
+ arr1.add(obj2);
|
|
|
+ obj1.put("sealName", data.get(getCust(type, "sealName")));
|
|
|
+ obj1.put("count", data.get(getCust(type, "count")));
|
|
|
+ obj1.put("users", arr1);
|
|
|
+ arr.add(obj1);
|
|
|
+ obj.put("subject", data.get(getCust(type, "subject")).toString());//合同名称
|
|
|
+ obj.put("tenantName", data.get(getCust(type, "tenantName")));//发起方公司名称
|
|
|
+ obj.put("applyerNumber", data.get(getCust(type, "applyerNumber")));//发起员工编号
|
|
|
+// obj.put("applyerNumber", "722");//发起员工编号
|
|
|
+ obj.put("auths", arr);
|
|
|
+ JSONObject code = qysService.applyseals(obj);
|
|
|
+ JSONObject json = code.getJSONObject("result");
|
|
|
+ JSONArray sealAuthsArray = json.getJSONArray("sealAuths");
|
|
|
+// 检查数组是否非空且至少有一个元素
|
|
|
+ String vertifyCode;
|
|
|
+ if (sealAuthsArray != null && !sealAuthsArray.isEmpty()) {
|
|
|
+ JSONObject firstSealAuth = sealAuthsArray.getJSONObject(0);
|
|
|
+ vertifyCode = firstSealAuth.getString("vertifyCode");
|
|
|
+ } else {
|
|
|
+ vertifyCode = "物理授权码不存在";
|
|
|
+ }
|
|
|
+ // 返回结果
|
|
|
+ return McR.success(vertifyCode);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public McR signurl(JSONObject param) throws Exception {
|
|
|
+ String formInstanceId = param.getString("formInstanceId");
|
|
|
+ String type = param.getString("type");
|
|
|
+ log.info("formInstanceId:{}", formInstanceId);
|
|
|
+ log.info("type:{}", type);
|
|
|
+ //根据实例ID获取表单数据
|
|
|
+ Map data = (Map) ydClient.queryData(YDParam.builder().formInstId(formInstanceId)
|
|
|
+ .appType(ydConf.getAppType()).systemToken(ydConf.getSystemToken())
|
|
|
+ .userId(ddConf.getOperator()).build(), YDConf.FORM_QUERY.retrieve_id).getFormData();
|
|
|
+ log.info("data:{}", data);
|
|
|
+// String categoryName = data.get(getCust(type, "categoryName")).toString();
|
|
|
+ JSONObject signatory = new JSONObject();
|
|
|
+ signatory.put("tenantType", "COMPANY");
|
|
|
+ signatory.put("tenantName", data.get(getCust(type, "tenantName")));
|
|
|
+ signatory.put("contractId", data.get(getCust(type, "contractId")));
|
|
|
+ JSONObject urlR = qysService.signurla(signatory);
|
|
|
+ String signUrl = urlR.getString("signUrl");
|
|
|
+ System.out.println("aaa---------------"+signUrl);
|
|
|
+ System.out.println(urlR);
|
|
|
+ if(!QYS_SUCCESS_CODE.equals(urlR.getString("code"))){
|
|
|
+ return McR.error(urlR.getString("code"),urlR.getString("message"));
|
|
|
+ }else{
|
|
|
+ return McR.success(signUrl);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private Map<String, String> getFormUuid(String type) {
|
|
|
+ Map<String, String> map = UtilMap.empty();
|
|
|
+ switch (type) {
|
|
|
+ case "HT01"://合同
|
|
|
+ map.put("type", "FORM-55D56A69CCCE4043A01660C8910E33BAQ4N0");
|
|
|
+ map.put("sn", "serialNumberField_ltsbweh2");
|
|
|
+ break;
|
|
|
+ case "HT02"://框架
|
|
|
+ map.put("type", "FORM-5DB656AF0F0E4EFA85A4739D55C23ED85BXO");
|
|
|
+ map.put("sn", "serialNumberField_lvz8coae");
|
|
|
+ break;
|
|
|
+ case "HT03"://租赁
|
|
|
+ map.put("type", "FORM-FCDDD18FD63E49B2A4C652FBDB1874F6DPHW");
|
|
|
+ map.put("sn", "serialNumberField_ltwcj54l");
|
|
|
+ break;
|
|
|
+ case "XZ04"://其他
|
|
|
+ map.put("type", "FORM-B27C1AE7298648F29E836B5FDF469DBDPFCK");
|
|
|
+ map.put("sn", "serialNumberField_ltwktal5");
|
|
|
+ break;
|
|
|
+ case "HTSG"://合同/申购
|
|
|
+ map.put("type", "FORM-88F968E75CC340EB91B1AC692F4184DC9I9W");
|
|
|
+ map.put("sn", "serialNumberField_lu7ycpuc");
|
|
|
+ break;
|
|
|
+ case "HR03"://hr用印
|
|
|
+ map.put("type", "FORM-54972289A0B7416287A9BA44DA6CCDC50QUC");
|
|
|
+ map.put("sn", "serialNumberField_lu9euh7o");
|
|
|
+ break;
|
|
|
+ case "HR18"://新签劳动合同/协议
|
|
|
+ map.put("type", "FORM-0D501EF1688247DC932E7784298BD46BRYHC");
|
|
|
+ map.put("sn", "serialNumberField_luauhgb5");
|
|
|
+ break;
|
|
|
+ case "XZ05"://发文审批
|
|
|
+ map.put("type", "FORM-3E04D5456B2341CCBA62C955B791CF45IAH1");
|
|
|
+ map.put("sn", "serialNumberField_ltwmutno");
|
|
|
+ break;
|
|
|
+ case "XZ08"://印章授权
|
|
|
+ map.put("type", "FORM-87BD065161F84560B999FE94713255E20E6E");
|
|
|
+ map.put("sn", "serialNumberField_ltwp3e44");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ /***
|
|
|
+ * 获取对方公司签署对象
|
|
|
+ * @param name
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private Map getCompSignatory(String name, String contact, String receiverName) {
|
|
|
+ JSONObject signatory = new JSONObject();
|
|
|
+ signatory.put("tenantType", "COMPANY");
|
|
|
+ signatory.put("tenantName", name);//对方(物理)名称
|
|
|
+ signatory.put("contact", contact);
|
|
|
+ signatory.put("receiverName", receiverName);
|
|
|
+ return signatory;
|
|
|
+ }
|
|
|
+ private Map getPeosignurl(String contractId, String name, String contact) {
|
|
|
+ JSONObject signurl = new JSONObject();
|
|
|
+ signurl.put("tenantType", "PERSONAL");
|
|
|
+ signurl.put("tenantName", name);
|
|
|
+ signurl.put("contractId", contractId);
|
|
|
+ signurl.put("contact", contact);
|
|
|
+ return signurl;
|
|
|
+ }
|
|
|
+ private Map getComsignurl(String contractId, String name) {
|
|
|
+ JSONObject signatory = new JSONObject();
|
|
|
+ signatory.put("tenantType", "COMPANY");
|
|
|
+ signatory.put("tenantName", name);
|
|
|
+ signatory.put("contractId", contractId);
|
|
|
+ return signatory;
|
|
|
+ }
|
|
|
+ //获取物理印章信息
|
|
|
+ private Map getAuths(String name, String count) {
|
|
|
+ JSONObject auths = new JSONObject();
|
|
|
+ auths.put("sealName", name);//印章名称
|
|
|
+ auths.put("count", count);//授权数量
|
|
|
+ return auths;
|
|
|
+ }
|
|
|
+
|
|
|
+ /***
|
|
|
+ * 获取我方公司签署对象
|
|
|
+ * @param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private Map getCompASignatory() {
|
|
|
+ JSONObject signatory = new JSONObject();
|
|
|
+ signatory.put("tenantType", "COMPANY");
|
|
|
+ return signatory;
|
|
|
+ }
|
|
|
+
|
|
|
+ /***
|
|
|
+ * 获取个人签署对象
|
|
|
+ * @param name
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private Map getPeopSignatory(String name, String contact) {
|
|
|
+ JSONObject signatory = new JSONObject();
|
|
|
+ signatory.put("tenantType", "PERSONAL");
|
|
|
+ signatory.put("contact", contact);
|
|
|
+ signatory.put("tenantName", name);//对方(个人)名称
|
|
|
+ return signatory;
|
|
|
+ }
|
|
|
+
|
|
|
+ //根据附件创建合同文档得到文档Id
|
|
|
+ public List<String> createbyfile(Map data, String type) throws Exception {
|
|
|
+// String jsonString = data.get("attachmentField_ltsbweir").toString();
|
|
|
+ String jsonString = data.get(getCust(type, "fujian")).toString();
|
|
|
+ JSONArray jsonArray = JSONObject.parseArray(jsonString);
|
|
|
+ List<String> resultList = new ArrayList<>();
|
|
|
+ if (jsonArray != null) {
|
|
|
+ for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
+ // 将元素转换为JSONObject
|
|
|
+ JSONObject jsonObj = jsonArray.getJSONObject(i);
|
|
|
+ String fj_url = ydClient.convertTemporaryUrl(jsonObj.getString("url"));
|
|
|
+ String fj_name = jsonObj.getString("name");
|
|
|
+ String localFilePath = "/home/file/" + fj_name;
|
|
|
+ //下载文件到本地
|
|
|
+ RsQysServiceImpl.downloadFile1(fj_url, localFilePath);
|
|
|
+ Map<String, Object> data1 = new HashMap<>();
|
|
|
+ data1.put("file", FileUtil.file("/home/file/" + fj_name));
|
|
|
+ data1.put("title", FileUtil.mainName(fj_name));
|
|
|
+ data1.put("fileType", FileUtil.extName(fj_name));// 获取文件格式(通过文件名)
|
|
|
+ try {
|
|
|
+ log.info("2. 根据文件类型创建合同文档");
|
|
|
+ JSONObject draft = qysService.createbyfile(data1);
|
|
|
+ if (draft != null) {
|
|
|
+ resultList.add(draft.getJSONObject("result").getString("documentId"));
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return resultList;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public static void downloadFile1(String downloadUrl, String path) {
|
|
|
+ InputStream inputStream = null;
|
|
|
+ OutputStream outputStream = null;
|
|
|
+ try {
|
|
|
+ URL url = new URL(downloadUrl);
|
|
|
+ //这里没有使用 封装后的ResponseEntity 就是也是因为这里不适合一次性的拿到结果,放不下content,会造成内存溢出
|
|
|
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
|
|
+ //使用bufferedInputStream 缓存流的方式来获取下载文件,不然大文件会出现内存溢出的情况
|
|
|
+ inputStream = new BufferedInputStream(connection.getInputStream());
|
|
|
+ File file = new File(path);
|
|
|
+ if (file.exists()) {
|
|
|
+ file.delete();
|
|
|
+ }
|
|
|
+ // 创建目录和父文件夹
|
|
|
+ FileUtils.forceMkdirParent(file);
|
|
|
+ outputStream = new FileOutputStream(file);
|
|
|
+ //这里也很关键每次读取的大小为5M 不一次性读取完
|
|
|
+ byte[] buffer = new byte[1024 * 1024 * 5];// 5MB
|
|
|
+ int len = 0;
|
|
|
+ while ((len = inputStream.read(buffer)) != -1) {
|
|
|
+ outputStream.write(buffer, 0, len);
|
|
|
+ }
|
|
|
+ connection.disconnect();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ IOUtils.closeQuietly(outputStream);
|
|
|
+ IOUtils.closeQuietly(inputStream);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|