|
@@ -1,21 +1,41 @@
|
|
|
package service;
|
|
package service;
|
|
|
|
|
|
|
|
|
|
+import beans.parameter.Parameter;
|
|
|
|
|
+import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.tencentcloudapi.essbasic.v20210526.models.DescribeFlowDetailInfoResponse;
|
|
import com.tencentcloudapi.essbasic.v20210526.models.DescribeFlowDetailInfoResponse;
|
|
|
import com.tencentcloudapi.essbasic.v20210526.models.FlowDetailInfo;
|
|
import com.tencentcloudapi.essbasic.v20210526.models.FlowDetailInfo;
|
|
|
|
|
+import common.Controller;
|
|
|
import common.ServiceController;
|
|
import common.ServiceController;
|
|
|
|
|
+import common.YosException;
|
|
|
import common.data.Row;
|
|
import common.data.Row;
|
|
|
import common.data.Rows;
|
|
import common.data.Rows;
|
|
|
import common.data.SQLFactory;
|
|
import common.data.SQLFactory;
|
|
|
import common.data.UpdateSQL;
|
|
import common.data.UpdateSQL;
|
|
|
|
|
+import common.data.db.DBConnect;
|
|
|
|
|
+import org.apache.commons.io.FileUtils;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
|
+import restcontroller.system.attachment.service.YosServer;
|
|
|
import restcontroller.webmanage.sale.contracttask.WeChatContractUtil;
|
|
import restcontroller.webmanage.sale.contracttask.WeChatContractUtil;
|
|
|
|
|
|
|
|
|
|
+import java.io.File;
|
|
|
|
|
+import java.net.URL;
|
|
|
|
|
+
|
|
|
import static restcontroller.webmanage.sale.contracttask.WeChatConfig.SuperProxyOperatorOpenId;
|
|
import static restcontroller.webmanage.sale.contracttask.WeChatConfig.SuperProxyOperatorOpenId;
|
|
|
import static restcontroller.webmanage.sale.contracttask.WeChatContractUtil.describeFlowDetailInfo;
|
|
import static restcontroller.webmanage.sale.contracttask.WeChatContractUtil.describeFlowDetailInfo;
|
|
|
import static restcontroller.webmanage.sale.contracttask.WeChatContractUtil.setAgent;
|
|
import static restcontroller.webmanage.sale.contracttask.WeChatContractUtil.setAgent;
|
|
|
|
|
|
|
|
public class EsignContractTaskService extends ServiceController {
|
|
public class EsignContractTaskService extends ServiceController {
|
|
|
|
|
|
|
|
|
|
+ Controller controller;
|
|
|
|
|
+
|
|
|
|
|
+ public EsignContractTaskService() throws YosException {
|
|
|
|
|
+ controller = new Controller(new JSONObject());
|
|
|
|
|
+ controller.dbConnect = dbConnect;
|
|
|
|
|
+ controller.siteid = "MD";
|
|
|
|
|
+ controller.userid = 1;
|
|
|
|
|
+ controller.username = "admin";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public ServiceParam paramSet() {
|
|
public ServiceParam paramSet() {
|
|
|
return new ServiceParam("腾讯电子签合同状态查询", 30, RunType.second);
|
|
return new ServiceParam("腾讯电子签合同状态查询", 30, RunType.second);
|
|
@@ -23,7 +43,7 @@ public class EsignContractTaskService extends ServiceController {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void serviceRun() throws Exception {
|
|
public void serviceRun() throws Exception {
|
|
|
- System.err.println(getDateTime_Str() + ":开始查询腾讯电子签合同状态...");
|
|
|
|
|
|
|
+ logger.info("开始查询腾讯电子签合同状态...");
|
|
|
Rows rows = dbConnect.runSqlQuery("SELECT * from sa_esign_contract_taskmx WHERE status in ('合同创建','合同签署中','合同即将过期')");
|
|
Rows rows = dbConnect.runSqlQuery("SELECT * from sa_esign_contract_taskmx WHERE status in ('合同创建','合同签署中','合同即将过期')");
|
|
|
for (Row row : rows) {
|
|
for (Row row : rows) {
|
|
|
String flowid = row.getString("flowid");
|
|
String flowid = row.getString("flowid");
|
|
@@ -31,15 +51,15 @@ public class EsignContractTaskService extends ServiceController {
|
|
|
if (StringUtils.isBlank(flowid)) {
|
|
if (StringUtils.isBlank(flowid)) {
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
- String flowStatus = row.getString("status");
|
|
|
|
|
|
|
+ String status = row.getString("status");
|
|
|
String approveStatus = row.getString("approvestatus");
|
|
String approveStatus = row.getString("approvestatus");
|
|
|
- String tempflowStatus = "";
|
|
|
|
|
|
|
+ String tempStatus = "";
|
|
|
String tempapproveStatus = "";
|
|
String tempapproveStatus = "";
|
|
|
String[] flowIds = {flowid};
|
|
String[] flowIds = {flowid};
|
|
|
DescribeFlowDetailInfoResponse res = describeFlowDetailInfo(setAgent(SuperProxyOperatorOpenId), flowIds);
|
|
DescribeFlowDetailInfoResponse res = describeFlowDetailInfo(setAgent(SuperProxyOperatorOpenId), flowIds);
|
|
|
if (res.getFlowInfo().length > 0) {
|
|
if (res.getFlowInfo().length > 0) {
|
|
|
FlowDetailInfo flowDetailInfo = res.getFlowInfo()[0];
|
|
FlowDetailInfo flowDetailInfo = res.getFlowInfo()[0];
|
|
|
- tempflowStatus = WeChatContractUtil.getFlowStatus(flowDetailInfo.getFlowStatus());
|
|
|
|
|
|
|
+ tempStatus = WeChatContractUtil.getFlowStatus(flowDetailInfo.getFlowStatus());
|
|
|
if (flowDetailInfo.getFlowApproverInfos().length > 0) {
|
|
if (flowDetailInfo.getFlowApproverInfos().length > 0) {
|
|
|
tempapproveStatus = WeChatContractUtil.getApproveStatus(flowDetailInfo.getFlowApproverInfos()[0].getApproveStatus());
|
|
tempapproveStatus = WeChatContractUtil.getApproveStatus(flowDetailInfo.getFlowApproverInfos()[0].getApproveStatus());
|
|
|
}
|
|
}
|
|
@@ -47,23 +67,49 @@ public class EsignContractTaskService extends ServiceController {
|
|
|
boolean isUpdate = false;
|
|
boolean isUpdate = false;
|
|
|
UpdateSQL updateSQL = SQLFactory.createUpdateSQL(dbConnect, "sa_esign_contract_taskmx");
|
|
UpdateSQL updateSQL = SQLFactory.createUpdateSQL(dbConnect, "sa_esign_contract_taskmx");
|
|
|
updateSQL.setUniqueid(sa_esign_contract_taskmxid);
|
|
updateSQL.setUniqueid(sa_esign_contract_taskmxid);
|
|
|
- if (!flowStatus.equals(tempflowStatus) && !tempflowStatus.equals("")) {
|
|
|
|
|
- updateSQL.setValue("status", tempflowStatus);
|
|
|
|
|
|
|
+ if (!status.equals(tempStatus) && !tempStatus.equals("")) {
|
|
|
|
|
+ updateSQL.setValue("status", tempStatus);
|
|
|
isUpdate = true;
|
|
isUpdate = true;
|
|
|
- System.err.println(getDateTime_Str() + ":更新合同状态:" + tempflowStatus);
|
|
|
|
|
}
|
|
}
|
|
|
if (!approveStatus.equals(tempapproveStatus) && !tempapproveStatus.equals("")) {
|
|
if (!approveStatus.equals(tempapproveStatus) && !tempapproveStatus.equals("")) {
|
|
|
updateSQL.setValue("approvestatus", tempapproveStatus);
|
|
updateSQL.setValue("approvestatus", tempapproveStatus);
|
|
|
isUpdate = true;
|
|
isUpdate = true;
|
|
|
- System.err.println(getDateTime_Str() + ":更新合同状态:" + tempapproveStatus);
|
|
|
|
|
}
|
|
}
|
|
|
if (isUpdate) {
|
|
if (isUpdate) {
|
|
|
|
|
+ updateSQL.update();
|
|
|
|
|
+ }
|
|
|
|
|
+ //保存签署合同文件并更新归档日期
|
|
|
|
|
+ if (tempStatus.equals("合同签署完成")) {
|
|
|
|
|
+ Rows rows1 = dbConnect.runSqlQuery("SELECT CONCAT(year,'-',type,'-',name) title from sa_esign_contract_taskmx t1 " +
|
|
|
|
|
+ "INNER JOIN sa_esign_contract_task t2 ON t2.sa_esign_contract_taskid=t1.sa_esign_contract_taskid " +
|
|
|
|
|
+ "INNER JOIN sa_esign_contract_template t3 ON t3.sa_esign_contract_templateid=t2.sa_esign_contract_templateid " +
|
|
|
|
|
+ "WHERE t1.sa_esign_contract_taskmxid=" + sa_esign_contract_taskmxid);
|
|
|
|
|
+ String title = "";
|
|
|
|
|
+ if (rows1.isNotEmpty()) {
|
|
|
|
|
+ title = rows1.get(0).getString("title");
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ String downloadurl = WeChatContractUtil.describeFileUrls(flowid);
|
|
|
|
|
+ Rows parameterrows = (new DBConnect()).runSqlQuery("select paramvalue from sys_parameter where paramname='attachment_localhost_path'");
|
|
|
|
|
+ String localhostPath = parameterrows.get(0).getString("paramvalue");
|
|
|
|
|
+ File tempFile = new File(localhostPath, title + flowid + ".pdf");
|
|
|
|
|
+ URL url = new URL(downloadurl);
|
|
|
|
|
+ FileUtils.copyURLToFile(url, tempFile);
|
|
|
|
|
+ YosServer yosServer = new YosServer(controller);
|
|
|
|
|
+ Rows attachmentRows = yosServer.createAttachment(tempFile);
|
|
|
|
|
+ if (attachmentRows.isNotEmpty()) {
|
|
|
|
|
+ Long attachmentid = attachmentRows.get(0).getLong("attachmentid");
|
|
|
|
|
+ controller.createFileLink("sa_esign_contract_taskmx", sa_esign_contract_taskmxid, "default", attachmentid);
|
|
|
|
|
+ }
|
|
|
|
|
+ updateSQL = SQLFactory.createUpdateSQL(dbConnect, "sa_esign_contract_taskmx");
|
|
|
|
|
+ updateSQL.setUniqueid(sa_esign_contract_taskmxid);
|
|
|
|
|
+ updateSQL.setValue("archiveddate", getDateTime());
|
|
|
updateSQL.update();
|
|
updateSQL.update();
|
|
|
|
|
+ logger.info("归档完成");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- System.err.println(getDateTime_Str() + ":查询腾讯电子签合同状态完成");
|
|
|
|
|
|
|
+ logger.info("查询腾讯电子签合同状态完成");
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|