Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-zx-biz
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Jobs
Commits
Open sidebar
项目统一框架
一体化_户用光伏项目代码
amos-boot-zx-biz
Commits
32242a81
Commit
32242a81
authored
Jun 13, 2024
by
wujiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交预览令牌接口
parent
ce382de3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
313 additions
and
290 deletions
+313
-290
.factorypath
...-boot-system-jxiop/amos-boot-module-hygf-biz/.factorypath
+1
-1
pom.xml
amos-boot-system-jxiop/amos-boot-module-hygf-biz/pom.xml
+1
-1
QiyuesuoController.java
...s/boot/module/hygf/biz/controller/QiyuesuoController.java
+10
-4
QiyuesuoServiceImpl.java
...oot/module/hygf/biz/service/impl/QiyuesuoServiceImpl.java
+301
-284
No files found.
amos-boot-system-jxiop/amos-boot-module-hygf-biz/.factorypath
View file @
32242a81
...
...
@@ -79,7 +79,7 @@
<factorypathentry kind="VARJAR" id="M2_REPO/net/sf/ezmorph/ezmorph/1.0.6/ezmorph-1.0.6.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/cn/hutool/hutool-all/5.8.16/hutool-all-5.8.16.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/com/yeejoin/amos-feign-rule/1.8.5/amos-feign-rule-1.8.5.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/com/qiyuesuo/sdk/sdk-java/3.
6.3/sdk-java-3.6
.3.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/com/qiyuesuo/sdk/sdk-java/3.
8.3/sdk-java-3.8
.3.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/com/yeejoin/amos-feign-workflow/1.10.4/amos-feign-workflow-1.10.4.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/com/yeejoin/amos-component-feign/1.10.4/amos-component-feign-1.10.4.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/cloud/spring-cloud-starter-openfeign/2.2.5.RELEASE/spring-cloud-starter-openfeign-2.2.5.RELEASE.jar" enabled="true" runInBatchMode="false"/>
...
...
amos-boot-system-jxiop/amos-boot-module-hygf-biz/pom.xml
View file @
32242a81
...
...
@@ -54,7 +54,7 @@
<dependency>
<groupId>
com.qiyuesuo.sdk
</groupId>
<artifactId>
sdk-java
</artifactId>
<version>
3.
6
.3
</version>
<version>
3.
8
.3
</version>
</dependency>
<dependency>
<groupId>
com.yeejoin
</groupId>
...
...
amos-boot-system-jxiop/amos-boot-module-hygf-biz/src/main/java/com/yeejoin/amos/boot/module/hygf/biz/controller/QiyuesuoController.java
View file @
32242a81
...
...
@@ -86,8 +86,7 @@ public class QiyuesuoController extends BaseController {
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"个人token"
,
notes
=
"个人token"
)
@PostMapping
(
value
=
"/getUserToken"
)
public
ResponseModel
<
Object
>
getSdkResponse
(
@RequestBody
UserAuthMiniappTicketRequest
request
)
{
SdkResponse
<
MiniappTicketResult
>
result
=
qiyuesuoService
.
getSdkResponse
(
request
);
SdkResponse
<
MiniappTicketResult
>
result
=
qiyuesuoService
.
getSdkResponse
(
request
);
return
ResponseHelper
.
buildResponse
(
result
.
getResult
());
}
...
...
@@ -96,11 +95,10 @@ public class QiyuesuoController extends BaseController {
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"合同token"
,
notes
=
"合同token"
)
@PostMapping
(
value
=
"/getContractToken"
)
public
ResponseModel
<
Object
>
getContractSdkResponse
(
@RequestBody
ContractMiniappTicketRequest
request
)
{
SdkResponse
<
MiniappTicketResult
>
result
=
qiyuesuoService
.
getContractSdkResponse
(
request
);
return
ResponseHelper
.
buildResponse
(
result
.
getResult
());
}
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"合同token"
,
notes
=
"合同token"
)
@PostMapping
(
value
=
"/getContractTokengz/{sequenceNbr}"
)
...
...
@@ -113,6 +111,14 @@ public class QiyuesuoController extends BaseController {
SdkResponse
<
MiniappTicketResult
>
result
=
qiyuesuoService
.
getContractSdkResponse
(
request
);
return
ResponseHelper
.
buildResponse
(
result
.
getResult
());
}
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"获取合同浏览令牌"
,
notes
=
"获取合同浏览令牌"
)
@GetMapping
(
value
=
"/getContractTokenTicket/{sequenceNbr}"
)
public
ResponseModel
<
Object
>
getContractTokenTicket
(
@PathVariable
(
value
=
"sequenceNbr"
)
Long
sequenceNbr
)
{
SdkResponse
<
MiniappTicketResult
>
result
=
qiyuesuoService
.
getContractTokenTicket
(
sequenceNbr
);
return
ResponseHelper
.
buildResponse
(
result
.
getResult
());
}
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
...
...
amos-boot-system-jxiop/amos-boot-module-hygf-biz/src/main/java/com/yeejoin/amos/boot/module/hygf/biz/service/impl/QiyuesuoServiceImpl.java
View file @
32242a81
...
...
@@ -27,289 +27,306 @@ import java.util.List;
@Service
public
class
QiyuesuoServiceImpl
{
@Value
(
"${qiyuesuo.serverUrl}"
)
String
serverUrl
;
@Value
(
"${qiyuesuo.accessKey}"
)
String
accessKey
;
@Value
(
"${qiyuesuo.accessSecret}"
)
String
accessSecret
;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
QiyuesuoServiceImpl
.
class
);
/***
*
* 个人权限
* */
public
SdkResponse
<
MiniappTicketResult
>
getSdkResponse
(
UserAuthMiniappTicketRequest
request
){
SdkClient
sdkClient
=
new
SdkClient
(
serverUrl
,
accessKey
,
accessSecret
);
String
response
=
null
;
try
{
response
=
sdkClient
.
service
(
request
);
}
catch
(
Exception
e
)
{
throw
new
BaseSdkException
(
"调用接口错误,错误原因:"
+
e
.
getMessage
());
}
SdkResponse
<
MiniappTicketResult
>
result
=
JSONUtils
.
toQysResponse
(
response
,
MiniappTicketResult
.
class
);
if
(!
result
.
getCode
().
equals
(
0
))
{
throw
new
BaseSdkException
(
"获取个人认证Ticket失败,失败原因:"
+
result
.
getCode
()+
","
+
result
.
getMessage
());
}
return
result
;
}
/**
合同授权
*
* **/
public
SdkResponse
<
MiniappTicketResult
>
getContractSdkResponse
(
ContractMiniappTicketRequest
request
){
SdkClient
sdkClient
=
new
SdkClient
(
serverUrl
,
accessKey
,
accessSecret
);
String
response
=
null
;
try
{
response
=
sdkClient
.
service
(
request
);
}
catch
(
Exception
e
)
{
throw
new
BaseSdkException
(
"调用接口错误,错误原因:"
+
e
.
getMessage
());
}
SdkResponse
<
MiniappTicketResult
>
result
=
JSONUtils
.
toQysResponse
(
response
,
MiniappTicketResult
.
class
);
if
(!
result
.
getCode
().
equals
(
0
))
{
throw
new
BaseSdkException
(
"获取合同签署Ticket失败,失败原因:"
+
result
.
getCode
()
+
","
+
result
.
getMessage
());
}
return
result
;
}
/**
*创建合同
*
*
* **/
public
Long
addContract
(
ContractDataDto
contractDataDto
,
List
<
TemplateParamDto
>
templateParam
){
SdkResponse
<
Contract
>
responseObj
=
null
;
// 返回结果
Contract
result
=
new
Contract
();
String
username
=
contractDataDto
.
getUsername
();
String
contact
=
contractDataDto
.
getContact
();
String
IDCard
=
contractDataDto
.
getIDCard
();
String
subject
=
contractDataDto
.
getSubject
();
String
endTime
=
contractDataDto
.
getEndTime
();
String
expireTime
=
contractDataDto
.
getExpireTime
();
String
category
=
contractDataDto
.
getCategory
();
String
companyTenantName
=
contractDataDto
.
getCompanyTenantName
();
String
companyUsername
=
contractDataDto
.
getCompanyUsername
();
String
companyContact
=
contractDataDto
.
getCompanyContact
();
Long
emplateId
=
contractDataDto
.
getEmplateId
();
String
companykeyword
=
contractDataDto
.
getCompanykeyword
();
Integer
companykeywordIndex
=
contractDataDto
.
getCompanyKeywordIndex
();
Integer
companyPage
=
contractDataDto
.
getCompanyPage
();
Double
companyOffsetX
=
contractDataDto
.
getCompanyOffsetX
();
Double
companyOffsetY
=
contractDataDto
.
getCompanyOffsetY
();
String
personalkeyword
=
contractDataDto
.
getPersonalkeyword
();
Integer
personalkeywordIndex
=
contractDataDto
.
getPersonalKeywordIndex
();
Integer
personalPage
=
contractDataDto
.
getPersonalPage
();
Double
personalOffsetX
=
contractDataDto
.
getPersonalOffsetX
();
Double
personalOffsetY
=
contractDataDto
.
getPersonalOffsetY
();
List
<
Long
>
corpSealIds
=
contractDataDto
.
getSealId
();
try
{
SdkClient
sdkClient
=
new
SdkClient
(
serverUrl
,
accessKey
,
accessSecret
);
// 合同基本参数
//进行日期格式化
Contract
contract
=
new
Contract
();
contract
.
setSubject
(
subject
);
contract
.
setDescription
(
subject
);
contract
.
setCategory
(
new
Category
(
category
));
contract
.
setSend
(
false
);
// 个人
Signatory
signatory1
=
new
Signatory
();
signatory1
.
setTenantName
(
username
);
signatory1
.
setTenantType
(
"PERSONAL"
);
signatory1
.
setReceiver
(
new
User
(
username
,
contact
,
"MOBILE"
));
signatory1
.
setSerialNo
(
1
);
// 对接方
Signatory
signatory2
=
new
Signatory
();
signatory2
.
setTenantName
(
companyTenantName
);
signatory2
.
setTenantType
(
"COMPANY"
);
signatory2
.
setReceiver
(
new
User
(
companyUsername
,
companyContact
,
"MOBILE"
));
signatory2
.
setSerialNo
(
2
);
Action
action
=
new
Action
(
"COMPANY"
,
0
);
//指定印章
action
.
setCorpSealIds
(
corpSealIds
);
signatory2
.
addAction
(
action
);
// 设置签署方
contract
.
addSignatory
(
signatory1
);
contract
.
addSignatory
(
signatory2
);
// 创建合同
ContractDraftRequest
request
=
new
ContractDraftRequest
(
contract
);
logger
.
info
(
"创建草稿合同调用前"
+
JSON
.
toJSONString
(
request
));
String
response
=
sdkClient
.
service
(
request
);
responseObj
=
JSONUtils
.
toQysResponse
(
response
,
Contract
.
class
);
logger
.
info
(
"创建草稿合同调用后"
+
JSON
.
toJSONString
(
responseObj
));
}
catch
(
Exception
e
){
e
.
printStackTrace
();
throw
new
BadRequest
(
"创建草稿合同失败"
);
}
if
(
responseObj
.
getCode
()
==
0
)
{
result
=
responseObj
.
getResult
();
logger
.
info
(
JSON
.
toJSONString
(
responseObj
));
}
else
{
logger
.
info
(
"请求失败,错误码:{},错误信息:{}"
,
responseObj
.
getCode
(),
responseObj
.
getMessage
());
}
DocumentAddResult
documentAddResult
=
this
.
getDocumentAddResult
(
result
.
getId
(),
subject
,
templateParam
,
emplateId
);
List
<
Signatory
>
list
=
result
.
getSignatories
();
Long
ActionId
=
null
;
Long
SignatoryId
=
null
;
for
(
Signatory
signatory
:
list
)
{
if
(
signatory
.
getTenantType
().
equals
(
"COMPANY"
)){
ActionId
=
signatory
.
getActions
().
get
(
0
).
getId
();
}
else
{
SignatoryId
=
signatory
.
getId
();
}
}
// 发起时可以设置签署位置
Stamper
stamper
=
new
Stamper
();
stamper
.
setActionId
(
ActionId
);
stamper
.
setDocumentId
(
documentAddResult
.
getDocumentId
());
stamper
.
setKeyword
(
companykeyword
);
stamper
.
setType
(
"COMPANY"
);
// stamper.setPage(companyPage);
stamper
.
setOffsetX
(
companyOffsetX
);
stamper
.
setOffsetY
(
companyOffsetY
);
stamper
.
setKeywordIndex
(
companykeywordIndex
);
Stamper
stamper2
=
new
Stamper
();
stamper2
.
setSignatoryId
(
SignatoryId
);
stamper2
.
setDocumentId
(
documentAddResult
.
getDocumentId
());
stamper2
.
setKeyword
(
personalkeyword
);
stamper2
.
setType
(
"PERSONAL"
);
// stamper2.setPage(personalPage);
stamper2
.
setOffsetX
(
personalOffsetX
);
stamper2
.
setOffsetY
(
personalOffsetY
);
stamper2
.
setKeywordIndex
(
personalkeywordIndex
);
List
<
Stamper
>
stampers
=
new
ArrayList
<>();
stampers
.
add
(
stamper
);
stampers
.
add
(
stamper2
);
SdkResponse
<
Object
>
data
=
this
.
getSdkResponse
(
result
.
getId
(),
stampers
);
return
result
.
getId
();
}
public
DocumentAddResult
getDocumentAddResult
(
Long
contractId
,
String
subject
,
List
<
TemplateParamDto
>
templateParam
,
Long
emplateId
)
{
DocumentAddResult
result
=
null
;
SdkResponse
<
DocumentAddResult
>
responseObj
=
null
;
try
{
SdkClient
sdkClient
=
new
SdkClient
(
serverUrl
,
accessKey
,
accessSecret
);
// 添加合同文档
List
<
TemplateParam
>
params
=
new
ArrayList
<>();
for
(
TemplateParamDto
templateParamDto
:
templateParam
)
{
if
(
templateParamDto
.
getValue
()!=
null
){
params
.
add
(
new
TemplateParam
(
templateParamDto
.
getKey
(),
templateParamDto
.
getValue
()));
}
}
logger
.
info
(
"添加合同文档参数"
+
JSON
.
toJSONString
(
params
));
DocumentAddByTemplateRequest
request
=
new
DocumentAddByTemplateRequest
(
contractId
,
emplateId
,
params
,
subject
);
logger
.
info
(
"添加合同文档前"
+
JSON
.
toJSONString
(
request
));
String
response
=
sdkClient
.
service
(
request
);
responseObj
=
JSONUtils
.
toQysResponse
(
response
,
DocumentAddResult
.
class
);
logger
.
info
(
"添加合同文档后"
+
JSON
.
toJSONString
(
responseObj
));
}
catch
(
Exception
e
){
e
.
printStackTrace
();
throw
new
BadRequest
(
"添加合同文档失败"
);
}
if
(
responseObj
!=
null
&&
responseObj
.
getCode
()
==
0
)
{
result
=
responseObj
.
getResult
();
logger
.
info
(
"添加合同文档成功,文档ID:{}"
,
JSON
.
toJSONString
(
result
));
}
else
{
throw
new
BadRequest
(
"添加合同文档"
+
responseObj
.
getMessage
());
}
return
result
;
}
public
SdkResponse
<
Object
>
getSdkResponse
(
Long
contractId
,
List
<
Stamper
>
stampers
){
// 发起合同
SdkResponse
<
Object
>
responseObj
=
null
;
try
{
SdkClient
sdkClient
=
new
SdkClient
(
serverUrl
,
accessKey
,
accessSecret
);
ContractSendRequest
request
=
new
ContractSendRequest
(
contractId
,
stampers
);
logger
.
info
(
"请求契约锁发起合同前"
+
JSON
.
toJSONString
(
request
));
String
response
=
sdkClient
.
service
(
request
);
responseObj
=
JSONUtils
.
toQysResponse
(
response
);
}
catch
(
Exception
e
){
e
.
printStackTrace
();
throw
new
BadRequest
(
"请求契约锁发起合同接口失败"
);
}
logger
.
info
(
"请求契约锁发起合同后"
+
JSON
.
toJSONString
(
responseObj
));
if
(
responseObj
!=
null
&&
responseObj
.
getCode
()
==
0
)
{
logger
.
info
(
"请求契约锁发起合同成功"
);
}
else
{
throw
new
BadRequest
(
"请求契约锁发起合同失败"
+
responseObj
.
getMessage
());
}
return
responseObj
;
}
public
String
getPageUrl
(
Long
contractId
)
{
String
url
=
null
;
SdkClient
sdkClient
=
new
SdkClient
(
serverUrl
,
accessKey
,
accessSecret
);
ContractViewPageRequest
request
=
new
ContractViewPageRequest
(
contractId
);
String
response
=
sdkClient
.
service
(
request
);
SdkResponse
<
ContractPageResult
>
responseObj
=
JSONUtils
.
toQysResponse
(
response
,
ContractPageResult
.
class
);
if
(
responseObj
.
getCode
()
==
0
)
{
ContractPageResult
result
=
responseObj
.
getResult
();
url
=
result
.
getPageUrl
();
logger
.
info
(
"合同页面地址为:{}"
,
result
.
getPageUrl
());
}
else
{
logger
.
info
(
"请求失败,错误码:{},错误信息:{}"
,
responseObj
.
getCode
(),
responseObj
.
getMessage
());
}
return
url
;
}
public
String
getdownloadUrl
(
Long
contractId
)
{
String
url
=
null
;
SdkClient
sdkClient
=
new
SdkClient
(
serverUrl
,
accessKey
,
accessSecret
);
ContractDownloadUrlRequest
downloadRequest
=
new
ContractDownloadUrlRequest
(
contractId
);
String
response
=
sdkClient
.
service
(
downloadRequest
);
SdkResponse
<
ContractDownloadUrlResult
>
responseObj
=
JSONUtils
.
toQysResponse
(
response
,
ContractDownloadUrlResult
.
class
);
if
(
responseObj
.
getCode
().
equals
(
0
))
{
List
<
DocumentUrlVO
>
downloadUrls
=
responseObj
.
getResult
().
getDownloadUrls
();
for
(
DocumentUrlVO
vo
:
downloadUrls
)
{
if
(
"CONTRACT"
.
equals
(
vo
.
getDownloadItems
())){
url
=
vo
.
getDownloadUrl
();
}
}
}
else
{
throw
new
BadRequest
(
"请求失败"
);
}
return
url
;
}
public
String
getUrl
(
Long
contractId
)
{
String
url
=
null
;
SdkClient
sdkClient
=
new
SdkClient
(
serverUrl
,
accessKey
,
accessSecret
);
ContractViewPageRequest
request
=
new
ContractViewPageRequest
(
contractId
);
String
response
=
sdkClient
.
service
(
request
);
SdkResponse
<
ContractPageResult
>
responseObj
=
JSONUtils
.
toQysResponse
(
response
,
ContractPageResult
.
class
);
if
(
responseObj
.
getCode
()
==
0
)
{
ContractPageResult
result
=
responseObj
.
getResult
();
url
=
result
.
getPageUrl
();
}
else
{
logger
.
info
(
"请求失败,错误码:{},错误信息:{}"
,
responseObj
.
getCode
(),
responseObj
.
getMessage
());
}
return
url
;
}
@Value
(
"${qiyuesuo.serverUrl}"
)
String
serverUrl
;
@Value
(
"${qiyuesuo.accessKey}"
)
String
accessKey
;
@Value
(
"${qiyuesuo.accessSecret}"
)
String
accessSecret
;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
QiyuesuoServiceImpl
.
class
);
/***
*
* 个人权限
*/
public
SdkResponse
<
MiniappTicketResult
>
getSdkResponse
(
UserAuthMiniappTicketRequest
request
)
{
SdkClient
sdkClient
=
new
SdkClient
(
serverUrl
,
accessKey
,
accessSecret
);
String
response
=
null
;
try
{
response
=
sdkClient
.
service
(
request
);
}
catch
(
Exception
e
)
{
throw
new
BaseSdkException
(
"调用接口错误,错误原因:"
+
e
.
getMessage
());
}
SdkResponse
<
MiniappTicketResult
>
result
=
JSONUtils
.
toQysResponse
(
response
,
MiniappTicketResult
.
class
);
if
(!
result
.
getCode
().
equals
(
0
))
{
throw
new
BaseSdkException
(
"获取个人认证Ticket失败,失败原因:"
+
result
.
getCode
()
+
","
+
result
.
getMessage
());
}
return
result
;
}
/**
* 合同授权
*
**/
public
SdkResponse
<
MiniappTicketResult
>
getContractSdkResponse
(
ContractMiniappTicketRequest
request
)
{
SdkClient
sdkClient
=
new
SdkClient
(
serverUrl
,
accessKey
,
accessSecret
);
String
response
=
null
;
try
{
response
=
sdkClient
.
service
(
request
);
}
catch
(
Exception
e
)
{
throw
new
BaseSdkException
(
"调用接口错误,错误原因:"
+
e
.
getMessage
());
}
SdkResponse
<
MiniappTicketResult
>
result
=
JSONUtils
.
toQysResponse
(
response
,
MiniappTicketResult
.
class
);
if
(!
result
.
getCode
().
equals
(
0
))
{
throw
new
BaseSdkException
(
"获取合同签署Ticket失败,失败原因:"
+
result
.
getCode
()
+
","
+
result
.
getMessage
());
}
return
result
;
}
/**
* 获取合同浏览令牌
*
* @param request
* @return
*/
public
SdkResponse
<
MiniappTicketResult
>
getContractTokenTicket
(
Long
sequenceNbr
)
{
SdkClient
sdkClient
=
new
SdkClient
(
serverUrl
,
accessKey
,
accessSecret
);
ContractMiniappViewTicketRequest
request
=
new
ContractMiniappViewTicketRequest
(
sequenceNbr
);
String
response
=
null
;
try
{
response
=
sdkClient
.
service
(
request
);
}
catch
(
Exception
e
)
{
throw
new
BaseSdkException
(
"调用接口错误,错误原因:"
+
e
.
getMessage
());
}
SdkResponse
<
MiniappTicketResult
>
result
=
JSONUtils
.
toQysResponse
(
response
,
MiniappTicketResult
.
class
);
if
(!
result
.
getCode
().
equals
(
0
))
{
throw
new
BaseSdkException
(
"获取合同签署Ticket失败,失败原因:"
+
result
.
getCode
()
+
","
+
result
.
getMessage
());
}
logger
.
info
(
"获取合同签署Ticket成功,Ticket:"
+
result
.
getResult
().
getTicket
());
return
result
;
}
/**
* 创建合同
*
*
**/
public
Long
addContract
(
ContractDataDto
contractDataDto
,
List
<
TemplateParamDto
>
templateParam
)
{
SdkResponse
<
Contract
>
responseObj
=
null
;
// 返回结果
Contract
result
=
new
Contract
();
String
username
=
contractDataDto
.
getUsername
();
String
contact
=
contractDataDto
.
getContact
();
String
IDCard
=
contractDataDto
.
getIDCard
();
String
subject
=
contractDataDto
.
getSubject
();
String
endTime
=
contractDataDto
.
getEndTime
();
String
expireTime
=
contractDataDto
.
getExpireTime
();
String
category
=
contractDataDto
.
getCategory
();
String
companyTenantName
=
contractDataDto
.
getCompanyTenantName
();
String
companyUsername
=
contractDataDto
.
getCompanyUsername
();
String
companyContact
=
contractDataDto
.
getCompanyContact
();
Long
emplateId
=
contractDataDto
.
getEmplateId
();
String
companykeyword
=
contractDataDto
.
getCompanykeyword
();
Integer
companykeywordIndex
=
contractDataDto
.
getCompanyKeywordIndex
();
Integer
companyPage
=
contractDataDto
.
getCompanyPage
();
Double
companyOffsetX
=
contractDataDto
.
getCompanyOffsetX
();
Double
companyOffsetY
=
contractDataDto
.
getCompanyOffsetY
();
String
personalkeyword
=
contractDataDto
.
getPersonalkeyword
();
Integer
personalkeywordIndex
=
contractDataDto
.
getPersonalKeywordIndex
();
Integer
personalPage
=
contractDataDto
.
getPersonalPage
();
Double
personalOffsetX
=
contractDataDto
.
getPersonalOffsetX
();
Double
personalOffsetY
=
contractDataDto
.
getPersonalOffsetY
();
List
<
Long
>
corpSealIds
=
contractDataDto
.
getSealId
();
try
{
SdkClient
sdkClient
=
new
SdkClient
(
serverUrl
,
accessKey
,
accessSecret
);
// 合同基本参数
// 进行日期格式化
Contract
contract
=
new
Contract
();
contract
.
setSubject
(
subject
);
contract
.
setDescription
(
subject
);
contract
.
setCategory
(
new
Category
(
category
));
contract
.
setSend
(
false
);
// 个人
Signatory
signatory1
=
new
Signatory
();
signatory1
.
setTenantName
(
username
);
signatory1
.
setTenantType
(
"PERSONAL"
);
signatory1
.
setReceiver
(
new
User
(
username
,
contact
,
"MOBILE"
));
signatory1
.
setSerialNo
(
1
);
// 对接方
Signatory
signatory2
=
new
Signatory
();
signatory2
.
setTenantName
(
companyTenantName
);
signatory2
.
setTenantType
(
"COMPANY"
);
signatory2
.
setReceiver
(
new
User
(
companyUsername
,
companyContact
,
"MOBILE"
));
signatory2
.
setSerialNo
(
2
);
Action
action
=
new
Action
(
"COMPANY"
,
0
);
// 指定印章
action
.
setCorpSealIds
(
corpSealIds
);
signatory2
.
addAction
(
action
);
// 设置签署方
contract
.
addSignatory
(
signatory1
);
contract
.
addSignatory
(
signatory2
);
// 创建合同
ContractDraftRequest
request
=
new
ContractDraftRequest
(
contract
);
logger
.
info
(
"创建草稿合同调用前"
+
JSON
.
toJSONString
(
request
));
String
response
=
sdkClient
.
service
(
request
);
responseObj
=
JSONUtils
.
toQysResponse
(
response
,
Contract
.
class
);
logger
.
info
(
"创建草稿合同调用后"
+
JSON
.
toJSONString
(
responseObj
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
BadRequest
(
"创建草稿合同失败"
);
}
if
(
responseObj
.
getCode
()
==
0
)
{
result
=
responseObj
.
getResult
();
logger
.
info
(
JSON
.
toJSONString
(
responseObj
));
}
else
{
logger
.
info
(
"请求失败,错误码:{},错误信息:{}"
,
responseObj
.
getCode
(),
responseObj
.
getMessage
());
}
DocumentAddResult
documentAddResult
=
this
.
getDocumentAddResult
(
result
.
getId
(),
subject
,
templateParam
,
emplateId
);
List
<
Signatory
>
list
=
result
.
getSignatories
();
Long
ActionId
=
null
;
Long
SignatoryId
=
null
;
for
(
Signatory
signatory
:
list
)
{
if
(
signatory
.
getTenantType
().
equals
(
"COMPANY"
))
{
ActionId
=
signatory
.
getActions
().
get
(
0
).
getId
();
}
else
{
SignatoryId
=
signatory
.
getId
();
}
}
// 发起时可以设置签署位置
Stamper
stamper
=
new
Stamper
();
stamper
.
setActionId
(
ActionId
);
stamper
.
setDocumentId
(
documentAddResult
.
getDocumentId
());
stamper
.
setKeyword
(
companykeyword
);
stamper
.
setType
(
"COMPANY"
);
// stamper.setPage(companyPage);
stamper
.
setOffsetX
(
companyOffsetX
);
stamper
.
setOffsetY
(
companyOffsetY
);
stamper
.
setKeywordIndex
(
companykeywordIndex
);
Stamper
stamper2
=
new
Stamper
();
stamper2
.
setSignatoryId
(
SignatoryId
);
stamper2
.
setDocumentId
(
documentAddResult
.
getDocumentId
());
stamper2
.
setKeyword
(
personalkeyword
);
stamper2
.
setType
(
"PERSONAL"
);
// stamper2.setPage(personalPage);
stamper2
.
setOffsetX
(
personalOffsetX
);
stamper2
.
setOffsetY
(
personalOffsetY
);
stamper2
.
setKeywordIndex
(
personalkeywordIndex
);
List
<
Stamper
>
stampers
=
new
ArrayList
<>();
stampers
.
add
(
stamper
);
stampers
.
add
(
stamper2
);
SdkResponse
<
Object
>
data
=
this
.
getSdkResponse
(
result
.
getId
(),
stampers
);
return
result
.
getId
();
}
public
DocumentAddResult
getDocumentAddResult
(
Long
contractId
,
String
subject
,
List
<
TemplateParamDto
>
templateParam
,
Long
emplateId
)
{
DocumentAddResult
result
=
null
;
SdkResponse
<
DocumentAddResult
>
responseObj
=
null
;
try
{
SdkClient
sdkClient
=
new
SdkClient
(
serverUrl
,
accessKey
,
accessSecret
);
// 添加合同文档
List
<
TemplateParam
>
params
=
new
ArrayList
<>();
for
(
TemplateParamDto
templateParamDto
:
templateParam
)
{
if
(
templateParamDto
.
getValue
()
!=
null
)
{
params
.
add
(
new
TemplateParam
(
templateParamDto
.
getKey
(),
templateParamDto
.
getValue
()));
}
}
logger
.
info
(
"添加合同文档参数"
+
JSON
.
toJSONString
(
params
));
DocumentAddByTemplateRequest
request
=
new
DocumentAddByTemplateRequest
(
contractId
,
emplateId
,
params
,
subject
);
logger
.
info
(
"添加合同文档前"
+
JSON
.
toJSONString
(
request
));
String
response
=
sdkClient
.
service
(
request
);
responseObj
=
JSONUtils
.
toQysResponse
(
response
,
DocumentAddResult
.
class
);
logger
.
info
(
"添加合同文档后"
+
JSON
.
toJSONString
(
responseObj
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
BadRequest
(
"添加合同文档失败"
);
}
if
(
responseObj
!=
null
&&
responseObj
.
getCode
()
==
0
)
{
result
=
responseObj
.
getResult
();
logger
.
info
(
"添加合同文档成功,文档ID:{}"
,
JSON
.
toJSONString
(
result
));
}
else
{
throw
new
BadRequest
(
"添加合同文档"
+
responseObj
.
getMessage
());
}
return
result
;
}
public
SdkResponse
<
Object
>
getSdkResponse
(
Long
contractId
,
List
<
Stamper
>
stampers
)
{
// 发起合同
SdkResponse
<
Object
>
responseObj
=
null
;
try
{
SdkClient
sdkClient
=
new
SdkClient
(
serverUrl
,
accessKey
,
accessSecret
);
ContractSendRequest
request
=
new
ContractSendRequest
(
contractId
,
stampers
);
logger
.
info
(
"请求契约锁发起合同前"
+
JSON
.
toJSONString
(
request
));
String
response
=
sdkClient
.
service
(
request
);
responseObj
=
JSONUtils
.
toQysResponse
(
response
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
BadRequest
(
"请求契约锁发起合同接口失败"
);
}
logger
.
info
(
"请求契约锁发起合同后"
+
JSON
.
toJSONString
(
responseObj
));
if
(
responseObj
!=
null
&&
responseObj
.
getCode
()
==
0
)
{
logger
.
info
(
"请求契约锁发起合同成功"
);
}
else
{
throw
new
BadRequest
(
"请求契约锁发起合同失败"
+
responseObj
.
getMessage
());
}
return
responseObj
;
}
public
String
getPageUrl
(
Long
contractId
)
{
String
url
=
null
;
SdkClient
sdkClient
=
new
SdkClient
(
serverUrl
,
accessKey
,
accessSecret
);
ContractViewPageRequest
request
=
new
ContractViewPageRequest
(
contractId
);
String
response
=
sdkClient
.
service
(
request
);
SdkResponse
<
ContractPageResult
>
responseObj
=
JSONUtils
.
toQysResponse
(
response
,
ContractPageResult
.
class
);
if
(
responseObj
.
getCode
()
==
0
)
{
ContractPageResult
result
=
responseObj
.
getResult
();
url
=
result
.
getPageUrl
();
logger
.
info
(
"合同页面地址为:{}"
,
result
.
getPageUrl
());
}
else
{
logger
.
info
(
"请求失败,错误码:{},错误信息:{}"
,
responseObj
.
getCode
(),
responseObj
.
getMessage
());
}
return
url
;
}
public
String
getdownloadUrl
(
Long
contractId
)
{
String
url
=
null
;
SdkClient
sdkClient
=
new
SdkClient
(
serverUrl
,
accessKey
,
accessSecret
);
ContractDownloadUrlRequest
downloadRequest
=
new
ContractDownloadUrlRequest
(
contractId
);
String
response
=
sdkClient
.
service
(
downloadRequest
);
SdkResponse
<
ContractDownloadUrlResult
>
responseObj
=
JSONUtils
.
toQysResponse
(
response
,
ContractDownloadUrlResult
.
class
);
if
(
responseObj
.
getCode
().
equals
(
0
))
{
List
<
DocumentUrlVO
>
downloadUrls
=
responseObj
.
getResult
().
getDownloadUrls
();
for
(
DocumentUrlVO
vo
:
downloadUrls
)
{
if
(
"CONTRACT"
.
equals
(
vo
.
getDownloadItems
()))
{
url
=
vo
.
getDownloadUrl
();
}
}
}
else
{
throw
new
BadRequest
(
"请求失败"
);
}
return
url
;
}
public
String
getUrl
(
Long
contractId
)
{
String
url
=
null
;
SdkClient
sdkClient
=
new
SdkClient
(
serverUrl
,
accessKey
,
accessSecret
);
ContractViewPageRequest
request
=
new
ContractViewPageRequest
(
contractId
);
String
response
=
sdkClient
.
service
(
request
);
SdkResponse
<
ContractPageResult
>
responseObj
=
JSONUtils
.
toQysResponse
(
response
,
ContractPageResult
.
class
);
if
(
responseObj
.
getCode
()
==
0
)
{
ContractPageResult
result
=
responseObj
.
getResult
();
url
=
result
.
getPageUrl
();
}
else
{
logger
.
info
(
"请求失败,错误码:{},错误信息:{}"
,
responseObj
.
getCode
(),
responseObj
.
getMessage
());
}
return
url
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment