Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gk
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
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
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
micro_app
gk
Commits
f84952e9
Commit
f84952e9
authored
Apr 13, 2021
by
yangshuxing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
契约锁开发
parent
aeb17965
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
1113 additions
and
5 deletions
+1113
-5
pom.xml
pom.xml
+12
-2
Application.java
src/main/java/com/dlbridge/jadp/Application.java
+1
-1
RmiConfig.java
src/main/java/com/dlbridge/jadp/config/web/RmiConfig.java
+32
-0
EnrollInfo.java
.../java/com/dlbridge/jadp/plugins/cmpt/bean/EnrollInfo.java
+1
-0
RemoteService.java
...com/dlbridge/jadp/plugins/cmpt/service/RemoteService.java
+1
-0
NavigationController.java
.../dlbridge/jadp/plugins/cmpt/web/NavigationController.java
+33
-0
CmptContact.java
.../com/dlbridge/jadp/plugins/qiyuesuo/bean/CmptContact.java
+28
-0
ContactLock.java
.../com/dlbridge/jadp/plugins/qiyuesuo/bean/ContactLock.java
+26
-0
ContactLockController.java
...dp/plugins/qiyuesuo/controller/ContactLockController.java
+74
-0
ContactLockMapper.java
...ridge/jadp/plugins/qiyuesuo/mapper/ContactLockMapper.java
+21
-0
ContactLockMapper.xml
...bridge/jadp/plugins/qiyuesuo/mapper/ContactLockMapper.xml
+36
-0
SendByCategoryService.java
.../jadp/plugins/qiyuesuo/service/SendByCategoryService.java
+365
-0
application-dev.properties
src/main/resources/application-dev.properties
+9
-1
application-production.properties
src/main/resources/application-production.properties
+8
-0
application-test.properties
src/main/resources/application-test.properties
+10
-1
navigation.jsp
src/main/webapp/WEB-INF/views/cmpt/navigation.jsp
+291
-0
LamdatTest.java
src/test/java/com/dlbridge/jadp/LamdatTest.java
+23
-0
LockMain.java
src/test/java/com/dlbridge/jadp/LockMain.java
+142
-0
No files found.
pom.xml
View file @
f84952e9
...
...
@@ -368,6 +368,16 @@
<artifactId>
qrgen
</artifactId>
<version>
1.4
</version>
</dependency>
<dependency>
<groupId>
com.qiyuesuo.sdk
</groupId>
<artifactId>
sdk-java
</artifactId>
<version>
3.3.2
</version>
</dependency>
<dependency>
<groupId>
com.neusoft.shg3.service
</groupId>
<artifactId>
rmi
</artifactId>
<version>
0.0.3
</version>
</dependency>
</dependencies>
<repositories>
...
...
@@ -375,7 +385,7 @@
<repository>
<id>
nexus
</id>
<name>
Private Repositories
</name>
<url>
http://maven.geexek.com.cn
:8081
/nexus/content/groups/public/
</url>
<url>
http://maven.geexek.com.cn/nexus/content/groups/public/
</url>
<snapshots>
<enabled>
true
</enabled>
<updatePolicy>
daily
</updatePolicy>
...
...
@@ -387,7 +397,7 @@
<pluginRepository>
<id>
nexus
</id>
<name>
Private Repositories
</name>
<url>
http://maven.geexek.com.cn
:8081
/nexus/content/groups/public/
</url>
<url>
http://maven.geexek.com.cn/nexus/content/groups/public/
</url>
<snapshots>
<enabled>
false
</enabled>
<updatePolicy>
daily
</updatePolicy>
...
...
src/main/java/com/dlbridge/jadp/Application.java
View file @
f84952e9
...
...
@@ -25,7 +25,7 @@ import org.springframework.web.servlet.config.annotation.EnableWebMvc;
@EnableCaching
@SpringBootApplication
(
exclude
=
{
RedisAutoConfiguration
.
class
})
@EnableWebMvc
@MapperScan
(
basePackages
=
"com.dlbridge.jadp.plugins
.cmpt.dao.mapper
"
)
@MapperScan
(
basePackages
=
"com.dlbridge.jadp.plugins"
)
@EnableAspectJAutoProxy
(
proxyTargetClass
=
true
)
@EnableFeignClients
(
basePackages
=
"com.dlbridge.feign"
)
@EnableDiscoveryClient
...
...
src/main/java/com/dlbridge/jadp/config/web/RmiConfig.java
0 → 100644
View file @
f84952e9
package
com
.
dlbridge
.
jadp
.
config
.
web
;
import
com.neusoft.upload.service.RMIUpload
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.remoting.rmi.RmiProxyFactoryBean
;
/**
* @Author shuxing.yang
* @Date 2021/4/9 13:29
*/
@Configuration
@Slf4j
public
class
RmiConfig
{
@Value
(
"${upload.rmi}"
)
private
String
serviceUrl
;
@Bean
public
RmiProxyFactoryBean
rmiUpload
(){
log
.
info
(
"rmi : "
+
serviceUrl
);
RmiProxyFactoryBean
rmiProxyFactoryBean
=
new
RmiProxyFactoryBean
();
rmiProxyFactoryBean
.
setRefreshStubOnConnectFailure
(
true
);
rmiProxyFactoryBean
.
setLookupStubOnStartup
(
false
);
rmiProxyFactoryBean
.
setServiceInterface
(
RMIUpload
.
class
);
rmiProxyFactoryBean
.
setServiceUrl
(
serviceUrl
);
return
rmiProxyFactoryBean
;
}
}
src/main/java/com/dlbridge/jadp/plugins/cmpt/bean/EnrollInfo.java
View file @
f84952e9
...
...
@@ -29,6 +29,7 @@ public class EnrollInfo {
@ApiModelProperty
(
value
=
"项目ID"
)
private
Integer
roadId
;
@ApiModelProperty
(
value
=
"救援人员电话"
)
private
String
remark
;
private
String
gender
;
...
...
src/main/java/com/dlbridge/jadp/plugins/cmpt/service/RemoteService.java
View file @
f84952e9
...
...
@@ -87,6 +87,7 @@ public class RemoteService {
info
.
setUserName
(
content
.
getString
(
"name"
));
info
.
setEnrollId
(
content
.
getString
(
"enrollId"
));
info
.
setPhone
(
content
.
getString
(
"phone"
));
info
.
setIdentityNo
(
content
.
getString
(
"identityNo"
));
return
info
;
}
else
{
return
null
;
...
...
src/main/java/com/dlbridge/jadp/plugins/cmpt/web/NavigationController.java
0 → 100644
View file @
f84952e9
package
com
.
dlbridge
.
jadp
.
plugins
.
cmpt
.
web
;
import
com.dlbridge.jadp.common.interceptor.PageView
;
import
com.dlbridge.jadp.plugins.cmpt.dao.model.Cmpt
;
import
com.dlbridge.jadp.plugins.cmpt.service.CmptService
;
import
lombok.extern.log4j.Log4j2
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.servlet.ModelAndView
;
import
springfox.documentation.annotations.ApiIgnore
;
import
javax.annotation.Resource
;
@Controller
@Log4j2
@RequestMapping
(
"gk/navigation/"
)
@ApiIgnore
public
class
NavigationController
{
@Resource
private
CmptService
cmptService
;
@RequestMapping
(
"index/{cmptId}"
)
@PageView
public
ModelAndView
index
(
@PathVariable
(
"cmptId"
)
Integer
cmptId
,
ModelAndView
mv
)
{
Cmpt
cmpt
=
cmptService
.
queryCmptBycmptId
(
cmptId
);
mv
.
addObject
(
"cmpt"
,
cmpt
);
mv
.
setViewName
(
"cmpt/navigation"
);
return
mv
;
}
}
src/main/java/com/dlbridge/jadp/plugins/qiyuesuo/bean/CmptContact.java
0 → 100644
View file @
f84952e9
package
com
.
dlbridge
.
jadp
.
plugins
.
qiyuesuo
.
bean
;
import
lombok.Data
;
/**
* @Author shuxing.yang
* @Date 2021/4/9 10:08
*/
@Data
public
class
CmptContact
{
private
int
cmptId
;
private
long
sealId
;
private
long
templateId
;
private
int
contactType
;
private
int
categoryType
;
private
String
subject
;
private
long
categoryId
;
private
String
companyReceiver
;
}
src/main/java/com/dlbridge/jadp/plugins/qiyuesuo/bean/ContactLock.java
0 → 100644
View file @
f84952e9
package
com
.
dlbridge
.
jadp
.
plugins
.
qiyuesuo
.
bean
;
import
lombok.Data
;
/**
* @Author shuxing.yang
* @Date 2021/4/8 10:06
*/
@Data
public
class
ContactLock
{
private
int
id
;
private
int
cmptId
;
private
String
idCard
;
private
String
userName
;
private
String
phone
;
private
String
contactId
;
private
int
isSign
;
private
int
isAuth
;
private
String
createTime
;
private
String
ticket
;
private
int
companySign
;
private
String
msg
;
}
src/main/java/com/dlbridge/jadp/plugins/qiyuesuo/controller/ContactLockController.java
0 → 100644
View file @
f84952e9
package
com
.
dlbridge
.
jadp
.
plugins
.
qiyuesuo
.
controller
;
import
com.dlbridge.jadp.plugins.qiyuesuo.bean.ContactLock
;
import
com.dlbridge.jadp.plugins.qiyuesuo.service.SendByCategoryService
;
import
com.neusoft.www.utils.web.Result
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* @Author shuxing.yang
* @Date 2021/4/7 17:35
*/
@RestController
(
value
=
"qiyueContactController"
)
@RequestMapping
(
"/api"
)
@Slf4j
public
class
ContactLockController
{
@Autowired
private
SendByCategoryService
sendByCategoryService
;
@RequestMapping
(
"/person-auth"
)
public
Result
personAuth
(
ContactLock
lock
){
log
.
info
(
"入参:"
+
lock
);
if
(
StringUtils
.
isBlank
(
lock
.
getIdCard
())){
return
Result
.
fail
().
setMsg
(
"无证件号!"
);
}
Map
<
String
,
String
>
param
=
new
HashMap
<>();
param
.
put
(
"cmptId"
,
lock
.
getCmptId
()+
""
);
param
.
put
(
"idCard"
,
lock
.
getIdCard
());
param
.
put
(
"userName"
,
lock
.
getUserName
());
param
.
put
(
"phone"
,
lock
.
getPhone
());
ContactLock
ticket
=
sendByCategoryService
.
getPersonAuthToken
(
param
);
log
.
info
(
"返回前端的json:"
+
ticket
);
if
(
ticket
==
null
||
ticket
.
getMsg
()
!=
null
){
return
new
Result
().
setMsg
(
"获取ticket失败:"
+
ticket
.
getMsg
()
).
setCode
(-
1
);
}
return
new
Result
().
setContent
(
ticket
);
}
@RequestMapping
(
"/authSuccess"
)
public
Result
authSuccess
(
ContactLock
lock
){
sendByCategoryService
.
authSuccess
(
lock
);
return
new
Result
().
setContent
(
null
);
}
@RequestMapping
(
"/signSuccess"
)
public
Result
signSuccess
(
ContactLock
lock
)
throws
Exception
{
sendByCategoryService
.
signSuccess
(
lock
);
return
new
Result
().
setContent
(
null
);
}
@RequestMapping
(
"/doc"
)
public
Result
doc
(
ContactLock
lock
){
log
.
info
(
"入参:"
+
lock
);
if
(
StringUtils
.
isBlank
(
lock
.
getIdCard
())){
return
Result
.
fail
().
setMsg
(
"无证件号!"
);
}
Map
<
String
,
String
>
param
=
new
HashMap
<>();
param
.
put
(
"cmptId"
,
lock
.
getCmptId
()+
""
);
param
.
put
(
"idCard"
,
lock
.
getIdCard
());
param
.
put
(
"userName"
,
lock
.
getUserName
());
param
.
put
(
"phone"
,
lock
.
getPhone
());
ContactLock
ticket
=
sendByCategoryService
.
getContactToken
(
param
);
return
new
Result
().
setContent
(
ticket
);
}
}
src/main/java/com/dlbridge/jadp/plugins/qiyuesuo/mapper/ContactLockMapper.java
0 → 100644
View file @
f84952e9
package
com
.
dlbridge
.
jadp
.
plugins
.
qiyuesuo
.
mapper
;
import
com.dlbridge.jadp.plugins.qiyuesuo.bean.CmptContact
;
import
com.dlbridge.jadp.plugins.qiyuesuo.bean.ContactLock
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.Map
;
public
interface
ContactLockMapper
{
ContactLock
getContactByCmptIdAndIdCard
(
@Param
(
"param"
)
Map
<
String
,
String
>
param
);
int
saveContactLock
(
@Param
(
"param"
)
Map
<
String
,
String
>
param
);
void
updateAuthSuccess
(
@Param
(
"lock"
)
ContactLock
lock
);
void
updateSignSuccess
(
@Param
(
"lock"
)
ContactLock
lock
);
CmptContact
getCmptContact
(
int
cmptId
);
}
src/main/java/com/dlbridge/jadp/plugins/qiyuesuo/mapper/ContactLockMapper.xml
0 → 100644
View file @
f84952e9
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.dlbridge.jadp.plugins.qiyuesuo.mapper.ContactLockMapper"
>
<select
id=
"getContactByCmptIdAndIdCard"
resultType=
"com.dlbridge.jadp.plugins.qiyuesuo.bean.ContactLock"
>
select contactId,cmptId,idcard idCard,userName,contactId,isSign,isAuth,phone,companySign
from contact
where cmptId=#{param.cmptId} and idCard=#{param.idCard}
and userName=#{param.userName} and phone = #{param.phone}
limit 1
</select>
<insert
id=
"saveContactLock"
>
insert into contact (cmptId,idcard,userName,phone,contactId,createTime,companySign)
values (#{param.cmptId},#{param.idCard},#{param.userName},#{param.phone},
#{param.contactId},now(),#{param.companySign})
</insert>
<update
id=
"updateAuthSuccess"
>
update contact
set isAuth = 1
where cmptId=#{lock.cmptId} and idCard=#{lock.idCard}
</update>
<update
id=
"updateSignSuccess"
>
update contact
set isSign = 1
where cmptId=#{lock.cmptId} and idCard=#{lock.idCard}
</update>
<select
id=
"getCmptContact"
resultType=
"com.dlbridge.jadp.plugins.qiyuesuo.bean.CmptContact"
>
select cmptId,sealId,templateId,contactType,categoryType,subject,categoryId,companyReceiver
from cmpt_contact
where cmptId=#{cmptId} limit 1
</select>
</mapper>
\ No newline at end of file
src/main/java/com/dlbridge/jadp/plugins/qiyuesuo/service/SendByCategoryService.java
0 → 100644
View file @
f84952e9
package
com
.
dlbridge
.
jadp
.
plugins
.
qiyuesuo
.
service
;
import
com.alibaba.nacos.client.naming.utils.RandomUtils
;
import
com.dlbridge.jadp.plugins.qiyuesuo.bean.CmptContact
;
import
com.dlbridge.jadp.plugins.qiyuesuo.bean.ContactLock
;
import
com.dlbridge.jadp.plugins.qiyuesuo.mapper.ContactLockMapper
;
import
com.neusoft.upload.service.RMIUpload
;
import
com.qiyuesuo.sdk.v2.SdkClient
;
import
com.qiyuesuo.sdk.v2.bean.*
;
import
com.qiyuesuo.sdk.v2.json.JSONUtils
;
import
com.qiyuesuo.sdk.v2.param.SignParam
;
import
com.qiyuesuo.sdk.v2.request.*
;
import
com.qiyuesuo.sdk.v2.response.ContractPageResult
;
import
com.qiyuesuo.sdk.v2.response.MiniappTicketResult
;
import
com.qiyuesuo.sdk.v2.response.SdkResponse
;
import
com.qiyuesuo.sdk.v2.utils.IOUtils
;
import
net.sf.json.JSONObject
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.client.RestTemplate
;
import
javax.annotation.PostConstruct
;
import
javax.annotation.Resource
;
import
java.io.ByteArrayOutputStream
;
import
java.io.FileNotFoundException
;
import
java.io.FileOutputStream
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@Service
public
class
SendByCategoryService
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
SendByCategoryService
.
class
);
private
static
final
String
PLATFORM_NAME
=
"上海赛客信息科技有限公司"
;
@Value
(
"${lock.url}"
)
private
String
url
;
@Value
(
"${lock.accessKey}"
)
private
String
accessKey
;
@Value
(
"${lock.accessSecret}"
)
private
String
accessSecret
;
@Value
(
"${lock.categoryId}"
)
private
Long
categoryId
;
@Value
(
"${lock.companyReceiver}"
)
private
String
companyReceiver
;
@Value
(
"${geexek.cmpt.url}"
)
private
String
timerBackend
;
SdkClient
client
=
null
;
@PostConstruct
public
void
init
(){
client
=
new
SdkClient
(
url
,
accessKey
,
accessSecret
);
}
@Resource
private
RMIUpload
rmiUpload
;
@Resource
ContactLockMapper
contactLockMapper
;
@Resource
private
RestTemplate
template
=
new
RestTemplate
();
/**
* 根据业务分类配置创建合同草稿并发起合同
*
* @param client
* @return
* @throws Exception
*/
public
SdkResponse
<
Contract
>
draft
(
SdkClient
client
,
String
mobile
,
String
userName
,
String
idCard
,
CmptContact
cmptContact
){
Contract
draftContract
=
new
Contract
();
draftContract
.
setSubject
(
cmptContact
.
getSubject
());
draftContract
.
setCategory
(
new
Category
(
cmptContact
.
getCategoryId
()));
// 设置业务分类ID,套用该业务分类的配置
//draftContract.addTemplateParam(new TemplateParam("接收方2", "发起方填参")); // 若业务分类中包含参数模板,设置参数内容
//draftContract.addTemplateParam(new TemplateParam("接收方1", "发起方填参"));
// 设置接收方详情,接收方需要与业务分类中设置的签署方流程匹配
// 公司签署方
Signatory
companySignatory
=
new
Signatory
();
companySignatory
.
setTenantName
(
PLATFORM_NAME
);
companySignatory
.
setTenantType
(
"COMPANY"
);
companySignatory
.
setReceiver
(
new
User
(
cmptContact
.
getCompanyReceiver
(),
"MOBILE"
));
companySignatory
.
setSerialNo
(
1
);
draftContract
.
addSignatory
(
companySignatory
);
// 个人签署方
Signatory
personalSignatory
=
new
Signatory
();
personalSignatory
.
setTenantType
(
"PERSONAL"
);
personalSignatory
.
setReceiver
(
new
User
(
mobile
,
"MOBILE"
));
UserAuthInfo
userAuthInfo
=
new
UserAuthInfo
();
userAuthInfo
.
setIdCardNo
(
idCard
);
personalSignatory
.
setUserAuthInfo
(
userAuthInfo
);
personalSignatory
.
setTenantName
(
userName
);
draftContract
.
addSignatory
(
personalSignatory
);
draftContract
.
setSend
(
true
);
// 创建合同草稿并发起合同
String
response
=
null
;
try
{
response
=
client
.
service
(
new
ContractDraftRequest
(
draftContract
));
}
catch
(
Exception
e
)
{
logger
.
info
(
"创建合同草稿请求服务器失败,失败原因:"
+
e
.
getMessage
());
}
SdkResponse
<
Contract
>
sdkResponse
=
JSONUtils
.
toQysResponse
(
response
,
Contract
.
class
);
return
sdkResponse
;
}
/**
* 根据业务分类配置的签署位置与印章签署公章
* 若未配置签署位置需要设置签署位置与印章
*
* @param client
* @param contractId
* @param cmptContact
* @return
* @throws Exception
*/
private
static
SdkResponse
companySealSignByCategoryConfig
(
SdkClient
client
,
Long
contractId
,
CmptContact
cmptContact
){
SignParam
param
=
new
SignParam
();
param
.
setContractId
(
contractId
);
param
.
setSealId
(
cmptContact
.
getSealId
());
//2816978947428847753L
String
response
=
null
;
try
{
response
=
client
.
service
(
new
ContractSignCompanyRequest
(
param
));
}
catch
(
Exception
e
)
{
logger
.
info
(
"公章签署请求服务器失败,失败原因:"
+
e
.
getMessage
());
}
SdkResponse
sdkResponse
=
JSONUtils
.
toQysResponse
(
response
,
Object
.
class
);
return
sdkResponse
;
}
/**
* 生成用户的签署链接
*
* @param client
* @param contractId
* @return
* @throws Exception
*/
private
static
SdkResponse
<
ContractPageResult
>
gerenateSignUrl
(
SdkClient
client
,
Long
contractId
,
String
mobile
)
throws
Exception
{
User
signUser
=
new
User
(
mobile
,
"MOBILE"
);
String
callbackPage
=
"https://www.qiyuesuo.com"
;
ContractPageRequest
request
=
new
ContractPageRequest
(
contractId
,
signUser
,
callbackPage
);
String
response
;
try
{
response
=
client
.
service
(
request
);
}
catch
(
Exception
e
)
{
throw
new
Exception
(
"生成签署链接请求服务器失败,失败原因:"
+
e
.
getMessage
());
}
SdkResponse
<
ContractPageResult
>
sdkResponse
=
JSONUtils
.
toQysResponse
(
response
,
ContractPageResult
.
class
);
if
(!
sdkResponse
.
getCode
().
equals
(
0
))
{
throw
new
Exception
(
"法人章签署失败,失败原因:"
+
sdkResponse
.
getMessage
());
}
return
sdkResponse
;
}
public
ContactLock
getPersonAuthToken
(
Map
<
String
,
String
>
param
)
{
ContactLock
contact
=
getContactByCmptIdAndIdCard
(
param
);
if
(
contact
!=
null
&&
contact
.
getMsg
()
==
null
){
return
getContactToken
(
param
);
}
else
{
logger
.
info
(
"未获取到token"
);
return
contact
;
}
}
private
ContactLock
getContactLockAuth
(
Map
<
String
,
String
>
param
,
SdkClient
client
,
ContactLock
contact
)
{
UserAuthMiniappTicketRequest
request
=
new
UserAuthMiniappTicketRequest
(
new
User
(
param
.
get
(
"phone"
),
"MOBILE"
));
request
.
setIdCardNo
(
param
.
get
(
"idCard"
));
request
.
setUsername
(
param
.
get
(
"userName"
));
request
.
setMode
(
"IVS"
);
String
response
=
null
;
try
{
response
=
client
.
service
(
request
);
}
catch
(
Exception
e
)
{
logger
.
info
(
"调用接口错误,错误原因:"
+
e
.
getMessage
());
}
SdkResponse
<
MiniappTicketResult
>
result
=
JSONUtils
.
toQysResponse
(
response
,
MiniappTicketResult
.
class
);
if
(
result
.
getCode
().
equals
(
0
))
{
logger
.
info
(
"获取认证,Ticket:"
+
result
.
getResult
().
getTicket
());
contact
.
setTicket
(
result
.
getResult
().
getTicket
());
return
contact
;
}
else
{
logger
.
info
(
"获取合同签署Ticket失败,失败原因:"
+
result
.
getCode
()
+
","
+
result
.
getMessage
());
return
null
;
}
}
public
ContactLock
getContactByCmptIdAndIdCard
(
Map
<
String
,
String
>
param
){
ContactLock
contact
=
contactLockMapper
.
getContactByCmptIdAndIdCard
(
param
);
if
(
contact
==
null
){
contact
=
new
ContactLock
();
CmptContact
cmptContact
=
contactLockMapper
.
getCmptContact
(
Integer
.
valueOf
(
param
.
get
(
"cmptId"
)));
SdkResponse
<
Contract
>
draft
=
draft
(
client
,
param
.
get
(
"phone"
),
param
.
get
(
"userName"
),
param
.
get
(
"idCard"
),
cmptContact
);
if
(
draft
.
getCode
().
equals
(
0
)){
System
.
out
.
println
(
"创建合同草稿成功,并发起,合同ID: "
+
draft
.
getResult
().
getId
());
param
.
put
(
"contactId"
,
draft
.
getResult
().
getId
()+
""
);
SdkResponse
sdkResponse
=
companySealSignByCategoryConfig
(
client
,
draft
.
getResult
().
getId
(),
cmptContact
);
if
(
sdkResponse
.
getCode
().
equals
(
0
))
{
param
.
put
(
"companySign"
,
"1"
);;
}
else
{
param
.
put
(
"companySign"
,
"0"
);;
logger
.
info
(
"公章签署失败:"
+
sdkResponse
.
getMessage
());
contact
.
setMsg
(
sdkResponse
.
getMessage
());
}
contactLockMapper
.
saveContactLock
(
param
);
contact
.
setContactId
(
draft
.
getResult
().
getId
()+
""
);
contact
.
setIsSign
(
0
);
return
contact
;
}
else
{
contact
.
setMsg
(
draft
.
getMessage
());
logger
.
info
(
"起草合同失败:"
+
draft
.
getMessage
());
}
}
return
contact
;
}
public
ContactLock
getContactToken
(
Map
<
String
,
String
>
param
)
{
ContactLock
contact
=
contactLockMapper
.
getContactByCmptIdAndIdCard
(
param
);
logger
.
info
(
"获取数据合同:"
+
contact
);
if
(
contact
.
getCompanySign
()
==
0
){
CmptContact
cmptContact
=
contactLockMapper
.
getCmptContact
(
Integer
.
valueOf
(
param
.
get
(
"cmptId"
)));
SdkResponse
sdkResponse
=
companySealSignByCategoryConfig
(
client
,
Long
.
valueOf
(
contact
.
getContactId
()),
cmptContact
);
if
(
sdkResponse
.
getCode
().
equals
(
0
))
{
logger
.
info
(
"公章签署成功"
);
}
else
{
contact
.
setMsg
(
sdkResponse
.
getMessage
());
logger
.
info
(
"公章签署失败"
+
sdkResponse
.
getMessage
());
}
}
ContractMiniappTicketRequest
request
=
new
ContractMiniappTicketRequest
(
Long
.
valueOf
(
contact
.
getContactId
()),
new
User
(
param
.
get
(
"phone"
),
"MOBILE"
));
String
response
=
null
;
try
{
response
=
client
.
service
(
request
);
}
catch
(
Exception
e
)
{
logger
.
info
(
"调用接口错误,错误原因:"
+
e
.
getMessage
());
}
SdkResponse
<
MiniappTicketResult
>
result
=
JSONUtils
.
toQysResponse
(
response
,
MiniappTicketResult
.
class
);
if
(
result
.
getCode
().
equals
(
0
))
{
System
.
out
.
println
(
"获取合同签署Ticket成功,Ticket:"
+
result
.
getResult
().
getTicket
());
contact
.
setTicket
(
result
.
getResult
().
getTicket
());
return
contact
;
}
else
{
logger
.
info
(
"获取合同签署Ticket失败,失败原因:"
+
result
.
getCode
()
+
","
+
result
.
getMessage
());
contact
.
setMsg
(
result
.
getMessage
());
return
contact
;
}
}
public
void
authSuccess
(
ContactLock
lock
)
{
contactLockMapper
.
updateAuthSuccess
(
lock
);
}
public
void
signSuccess
(
ContactLock
lock
)
throws
Exception
{
contactLockMapper
.
updateSignSuccess
(
lock
);
Map
<
String
,
String
>
param
=
new
HashMap
<>();
param
.
put
(
"cmptId"
,
lock
.
getCmptId
()+
""
);
param
.
put
(
"idCard"
,
lock
.
getIdCard
());
param
.
put
(
"userName"
,
lock
.
getUserName
());
param
.
put
(
"phone"
,
lock
.
getPhone
());
ContactLock
contact
=
contactLockMapper
.
getContactByCmptIdAndIdCard
(
param
);
logger
.
info
(
"待下载的合同:"
+
contact
);
SdkClient
sdkClient
=
new
SdkClient
(
url
,
accessKey
,
accessSecret
);
ContractDetailRequest
request3
=
new
ContractDetailRequest
(
Long
.
valueOf
(
contact
.
getContactId
()));
String
response2
=
sdkClient
.
service
(
request3
);
SdkResponse
<
Contract
>
responseObj
=
JSONUtils
.
toQysResponse
(
response2
,
Contract
.
class
);
if
(
responseObj
.
getCode
()
==
0
)
{
Contract
contract4
=
responseObj
.
getResult
();
List
<
Document
>
documents
=
contract4
.
getDocuments
();
if
(
documents
!=
null
&&
documents
.
size
()
>
0
){
System
.
out
.
println
(
documents
.
get
(
0
).
getId
());
DocumentDownloadRequest
request2
=
new
DocumentDownloadRequest
(
documents
.
get
(
0
).
getId
());
ByteArrayOutputStream
fos
=
new
ByteArrayOutputStream
();
sdkClient
.
download
(
request2
,
fos
);
String
picName
=
contact
.
getContactId
()+
"_"
+
contact
.
getUserName
()+
"_"
+
contact
.
getPhone
()+
".pdf"
;
Map
<
String
,
String
>
r
=
rmiUpload
.
uploadOSSFile
(
fos
.
toByteArray
(),
picName
,
"gk/contact/"
+
contact
.
getCmptId
()+
"/"
);
String
fileRelativePath
=
r
.
get
(
"fileRelativePath"
);
JSONObject
object
=
new
JSONObject
();
object
.
put
(
"cmptId"
,
contact
.
getCmptId
());
object
.
put
(
"idCardNo"
,
contact
.
getIdCard
());
object
.
put
(
"picName"
,
picName
);
object
.
put
(
"name"
,
contact
.
getUserName
());
object
.
put
(
"picUrl"
,
fileRelativePath
);
ResponseEntity
<
String
>
forEntity
=
template
.
getForEntity
(
timerBackend
+
"saveBagSignPicInfo.do?signInfo="
+
object
.
toString
(),
String
.
class
);
logger
.
info
(
"结果:"
+
forEntity
.
getBody
());
}
}
else
{
logger
.
info
(
"请求失败,错误码:{},错误信息:{}"
,
responseObj
.
getCode
(),
responseObj
.
getMessage
());
}
}
public
static
void
main
(
String
[]
args
)
throws
FileNotFoundException
{
String
url
=
"https://openapi.qiyuesuo.cn"
;
String
accessKey
=
"trRQR9ewQX"
;
String
accessSecret
=
"W6PysadsbPppDfts18ukZBUJ2GPkQZ"
;
SdkClient
sdkClient
=
new
SdkClient
(
url
,
accessKey
,
accessSecret
);
ContractDetailRequest
request3
=
new
ContractDetailRequest
(
2818014264638313354L
);
String
response2
=
sdkClient
.
service
(
request3
);
SdkResponse
<
Contract
>
responseObj
=
JSONUtils
.
toQysResponse
(
response2
,
Contract
.
class
);
if
(
responseObj
.
getCode
()
==
0
)
{
Contract
contract4
=
responseObj
.
getResult
();
List
<
Document
>
documents
=
contract4
.
getDocuments
();
if
(
documents
!=
null
){
for
(
Document
document
:
documents
){
System
.
out
.
println
(
document
.
getId
());
DocumentDownloadRequest
request2
=
new
DocumentDownloadRequest
(
document
.
getId
());
FileOutputStream
fos
=
new
FileOutputStream
(
"E:/test/"
+
RandomUtils
.
nextInt
()+
".pdf"
);
sdkClient
.
download
(
request2
,
fos
);
IOUtils
.
safeClose
(
fos
);
logger
.
info
(
"下载合同文档成功"
);
}
}
}
else
{
logger
.
info
(
"请求失败,错误码:{},错误信息:{}"
,
responseObj
.
getCode
(),
responseObj
.
getMessage
());
}
/*// 创建请求对象
ContractListRequest request = new ContractListRequest();
request.setSelectOffset(0);
request.setSelectLimit(1000);
// 解析请求结果
String response = sdkClient.service(request);
SdkResponse<ContractListResult> qysResponse = JSONUtils.toQysResponse(response, ContractListResult.class);
if(qysResponse.getCode() == 0) {
ContractListResult contractListResult = qysResponse.getResult();
List<Contract> list = contractListResult.getList();
for(Contract contract : list){
// 合同详情
}
logger.info("业务分类列表查询,数量:{}", contractListResult.getTotalCount());
}*/
}
}
src/main/resources/application-dev.properties
View file @
f84952e9
...
...
@@ -108,4 +108,12 @@ spring.cloud.sentinel.datasource.ds.nacos.groupId=dev
spring.cloud.sentinel.datasource.ds.nacos.rule-type
=
flow
base.url
=
http://localhost:8080
\ No newline at end of file
base.url
=
http://localhost:8080
lock.url
=
https://openapi.qiyuesuo.cn
lock.accessKey
=
trRQR9ewQX
lock.accessSecret
=
W6PysadsbPppDfts18ukZBUJ2GPkQZ
lock.categoryId
=
2816977402314363323
lock.companyReceiver
=
18201908070
upload.rmi
=
rmi://172.16.214.236:9125/RMIUpload
\ No newline at end of file
src/main/resources/application-production.properties
View file @
f84952e9
...
...
@@ -103,3 +103,11 @@ spring.cloud.sentinel.datasource.ds.nacos.groupId=production
#
## 规则类型
spring.cloud.sentinel.datasource.ds.nacos.rule-type
=
flow
lock.url
=
https://openapi.qiyuesuo.cn
lock.accessKey
=
trRQR9ewQX
lock.accessSecret
=
W6PysadsbPppDfts18ukZBUJ2GPkQZ
lock.categoryId
=
2816977402314363323
lock.companyReceiver
=
18201908070
upload.rmi
=
rmi://10.25.255.181:9125/RMIUpload
src/main/resources/application-test.properties
View file @
f84952e9
...
...
@@ -101,4 +101,13 @@ spring.cloud.sentinel.datasource.ds.nacos.groupId=test
## 规则类型
spring.cloud.sentinel.datasource.ds.nacos.rule-type
=
flow
base.url
=
https://testzs.geexek.com.cn/
\ No newline at end of file
base.url
=
https://testzs.geexek.com.cn/
lock.url
=
https://openapi.qiyuesuo.cn
lock.accessKey
=
trRQR9ewQX
lock.accessSecret
=
W6PysadsbPppDfts18ukZBUJ2GPkQZ
lock.categoryId
=
2816977402314363323
lock.companyReceiver
=
18201908070
upload.rmi
=
rmi://172.16.214.236:9125/RMIUpload
\ No newline at end of file
src/main/webapp/WEB-INF/views/cmpt/navigation.jsp
0 → 100644
View file @
f84952e9
<%@ page
language=
"java"
contentType=
"text/html; charset=utf-8"
pageEncoding=
"utf-8"
%>
<%@ include
file=
"/WEB-INF/views/include/taglib.jsp"
%>
<%@ taglib
prefix=
"fn"
uri=
"http://java.sun.com/jsp/jstl/functions"
%>
<%@ taglib
prefix=
"fmt"
uri=
"http://java.sun.com/jsp/jstl/fmt"
%>
<!doctype html>
<html>
<head>
<title>
</title>
<!-- Bootstrap CSS-->
<link
rel=
"stylesheet"
href=
"${ctxStatic}/newdermon/vendor/bootstrap/css/bootstrap.min.css"
>
<!-- Font Awesome CSS-->
<link
rel=
"stylesheet"
href=
"${ctxStatic}/newdermon/vendor/font-awesome/css/font-awesome.min.css"
>
<!-- Fontastic Custom icon font-->
<link
rel=
"stylesheet"
href=
"${ctxStatic}/newdermon/css/fontastic.css"
>
<!-- Google fonts - Poppins -->
<link
rel=
"stylesheet"
href=
"${ctxStatic}/newdermon/css/font-css.css"
>
<!-- theme stylesheet-->
<link
rel=
"stylesheet"
href=
"${ctxStatic}/newdermon/css/style.default.css?v=
<%=
System
.
currentTimeMillis
()
%>
"
id=
"theme-stylesheet"
>
<!-- Custom stylesheet - for your changes-->
<link
rel=
"stylesheet"
href=
"${ctxStatic}/newdermon/css/custom.css?v=
<%=
System
.
currentTimeMillis
()
%>
"
>
<link
rel=
"stylesheet"
href=
"${ctxStatic}/newdermon/css/juery-ui-1.12.css"
>
<!-- Favicon-->
<link
rel=
"shortcut icon"
href=
"https://img.geexek.com/files/home/favicon.ico"
>
<link
rel=
"stylesheet"
href=
"${ctxStatic}/newdermon/css/custom.css?v=
<%=
System
.
currentTimeMillis
()
%>
"
>
<link
rel=
"stylesheet"
href=
"${ctxStatic}/newdermon/css/main.css?v=
<%=
System
.
currentTimeMillis
()
%>
"
>
<link
rel=
"stylesheet"
href=
"${ctxStatic}/cmpt/setting.css?v=
<%=
System
.
currentTimeMillis
()
%>
"
>
<link
rel=
"stylesheet"
href=
"${ctxStatic}/leaflet/css/leaflet.css?v=
<%=
System
.
currentTimeMillis
()
%>
"
/>
<link
rel=
"stylesheet"
href=
"${ctxStatic}/leaflet/css/leaflet_label.css"
/>
<link
rel=
"stylesheet"
href=
"${ctxStatic}/cmpt/road.css?v=
<%=
System
.
currentTimeMillis
()
%>
"
/>
<link
rel=
"stylesheet"
href=
"${ctxStatic}/cmpt/road-new.css?v=
<%=
System
.
currentTimeMillis
()
%>
"
/>
<script
src=
"${ctxStatic}/My97DatePicker/WdatePicker.js"
type=
"text/javascript"
></script>
<script
src=
"${ctxStatic}/newdermon/vendor/jquery/jquery.min.js"
></script>
<script
type=
"text/javascript"
charset=
"utf-8"
src=
"${ctxStatic}/layer/layer.js"
></script>
<link
rel=
"stylesheet"
href=
"${ctxStatic}/layer/skin/layer.css"
>
<link
rel=
"stylesheet"
href=
"/static/cmpt/score.css?
<%=
System
.
currentTimeMillis
()
%>
"
>
<script
type=
"text/javascript"
src=
"https://webapi.amap.com/maps?v=1.3&key=a121386588a2f3d6db483a9b20f5a8f1&ver=1"
></script>
<style>
.data
{
width
:
100%
;
margin
:
20px
0px
;
background
:
#FFFFFF
;
position
:
relative
;
}
.road-name
{
color
:
#333
;
background
:
rgba
(
229
,
229
,
229
,
1
);
font-size
:
14px
;
line-height
:
30px
;
padding
:
0px
18px
;
cursor
:
pointer
;
border-radius
:
0px
4px
0px
0px
;
border
:
1px
solid
rgba
(
229
,
229
,
229
,
1
);
position
:
relative
;
text-align
:
center
;
float
:
left
;
margin-right
:
18px
;
border-radius
:
4px
;
margin-bottom
:
20px
;
}
.road-name.active
{
background
:
#ce3939
;
border-bottom
:
1px
solid
white
;
color
:
white
;
}
table
{
width
:
96%
;
padding
:
0px
2%
;
}
table
thead
th
{
padding-left
:
26px
;
}
table
thead
th
td
{
font-size
:
12px
;
color
:
#f3f3f3
;
}
table
tbody
tr
{
background
:
rgba
(
250
,
250
,
250
,
1
);
border-radius
:
4px
;
height
:
70px
;
border-bottom
:
5px
solid
white
;
border-radius
:
5px
;
}
table
tbody
tr
td
{
padding-left
:
26px
;
}
.road
{
/* display: flex;
border-bottom: 1px solid #f4f4f4;*/
margin-bottom
:
30px
;
}
.select-group
{
position
:
relative
;
width
:
200px
;
}
.select
{
text-transform
:
none
;
width
:
200px
;
height
:
40px
;
padding
:
0px
5px
;
border-radius
:
4px
;
background
:
rgba
(
250
,
250
,
250
,
1
);
border
:
none
;
outline
:
none
;
appearance
:
none
;
-moz-appearance
:
none
;
-webkit-appearance
:
none
;
cursor
:
pointer
;
}
.load
{
display
:
none
;
width
:
146px
;
height
:
40px
;
background
:
rgba
(
206
,
57
,
57
,
1
);
border-radius
:
4px
;
color
:
white
;
display
:
inline-block
;
line-height
:
40px
;
position
:
absolute
;
right
:
35px
;
top
:
72px
;
text-align
:
center
;
font-size
:
18px
;
cursor
:
pointer
;
}
.no-route-icon
{
width
:
16px
;
height
:
16px
;
background
:
url("/static/images/warning.png")
;
background-size
:
contain
;
background-position
:
center
;
background-repeat
:
no-repeat
;
}
.load
{
display
:
none
;
}
.noroute
{
display
:
none
;
position
:
absolute
;
width
:
140px
;
font-size
:
16px
;
bottom
:
-15px
;
left
:
50%
;
margin-left
:
-70px
;
}
.itemName
{
width
:
250px
;
height
:
40px
;
line-height
:
40px
;
font-size
:
21px
;
color
:
#333
;
}
.close
{
height
:
40px
;
line-height
:
40px
;
}
</style>
</head>
<body>
<jsp:include
page=
"../common/header.jsp"
></jsp:include>
<div
class=
"page-content d-flex align-items-stretch main-body"
>
<jsp:include
page=
"../common/menu.jsp"
></jsp:include>
<div
class=
"rght"
>
<div
class=
"title-new"
>
<span
class=
"title"
id=
"text"
>
自动打卡
</span>
<div
style=
"line-height: 22px"
>
<span
class=
"road-notice"
></span>
<span
class=
"road-notice-txt"
>
此功能仅适用于线下自助赛
</span>
</div>
</div>
<div
class=
"section"
>
<h3
class=
"title"
>
设置打卡点
</h3>
<div
style=
"line-height: 22px"
>
<span
class=
"road-notice"
></span>
<span
class=
"road-notice-txt"
>
仅比赛日之前可修改;所有项目和打卡点设置源自计时设置
</span>
</div>
<div
class=
"data"
style=
"display: flex;"
>
<div
id=
"mapFrame"
style=
"width:600px;height: 400px;"
></div>
<div
style=
"padding: 0px 20px;"
>
<div>
<span
class=
"itemName"
>
谁发的发
</span>
<span
class=
"close"
>
X
</span>
</div>
<div>
<span
class=
"itemName"
>
谁发的发
</span>
<span
class=
"close"
>
X
</span>
</div>
<div>
<span
class=
"itemName"
>
谁发的发
</span>
<span
class=
"close"
>
X
</span>
</div>
<div>
<span
class=
"itemName"
>
谁发的发
</span>
<span
class=
"close"
>
X
</span>
</div>
<div>
<span
class=
"itemName"
>
谁发的发
</span>
<span
class=
"close"
>
X
</span>
</div>
<div>
<span
class=
"itemName"
>
谁发的发
</span>
<span
class=
"close"
>
X
</span>
</div>
<div>
<span
class=
"itemName"
>
谁发的发
</span>
<span
class=
"close"
>
X
</span>
</div>
</div>
</div>
</div>
<div
style=
"display: flex;justify-content: center; margin: 60px;"
>
<span
class=
" save-btn"
>
保存
</span>
</div>
</div>
<div>
<div>
<div>
<span>
地点名称:
</span>
<input
type=
"text"
>
</div>
<div>
<span>
备注:
</span>
<input
type=
"text"
>
</div>
</div>
</div>
<script
src=
"${ctxStatic}/newdermon/vendor/popper.js/umd/popper.min.js"
></script>
<script
src=
"${ctxStatic}/js/qikoo.js"
></script>
<script>
var
map
=
{
mapContainer
:
''
,
_map
:
null
,
initMap
:
function
()
{
var
container
=
'mapFrame'
;
map
.
_map
=
new
AMap
.
Map
(
container
,
{
resizeEnable
:
true
,
//是否监控地图容器尺寸变化
zoom
:
11
,
//初始化地图层级
center
:
[
116.397428
,
39.90923
],
//初始化地图中心点
layers
:
[
// 卫星
new
AMap
.
TileLayer
.
Satellite
()
]
});
var
mapOpts
=
{
showIndoorMap
:
true
,
// 是否在有矢量底图的时候自动展示室内地图,PC默认true,移动端默认false
resizeEnable
:
true
,
//是否监控地图容器尺寸变化,默认值为false
dragEnable
:
true
,
// 地图是否可通过鼠标拖拽平移,默认为true
keyboardEnable
:
true
,
//地图是否可通过键盘控制,默认为true
doubleClickZoom
:
true
,
// 地图是否可通过双击鼠标放大地图,默认为true
zoomEnable
:
true
,
//地图是否可缩放,默认值为true
rotateEnable
:
true
,
// 地图是否可旋转,3D视图默认为true,2D视图默认false
}
if
(
container
==
'mobile'
){
map
.
_map
.
setOptions
(
mapOpts
);
}
map
.
_map
.
plugin
([
"AMap.Scale"
],
function
(){
var
scale
=
new
AMap
.
Scale
();
map
.
_map
.
addControl
(
scale
);
});
map
.
_map
.
on
(
'click'
,
showInfoClick
);
}
}
map
.
initMap
();
function
showInfoClick
(
e
){
var
ampaIcon
=
new
AMap
.
Icon
({
image
:
'/static/images/start.png'
,
size
:
new
AMap
.
Size
(
52
,
52
),
//图标大小
imageSize
:
new
AMap
.
Size
(
26
,
26
)
});
var
text
=
'您在 [ '
+
e
.
lnglat
.
getLng
()
+
','
+
e
.
lnglat
.
getLat
()
+
' ] 的位置单击了地图!'
document
.
querySelector
(
"#text"
).
innerText
=
text
;
var
markIcon
=
{
position
:
[
Number
(
e
.
lnglat
.
getLng
()),
Number
(
e
.
lnglat
.
getLat
())],
icon
:
ampaIcon
,
offset
:
new
AMap
.
Pixel
(
0
,
0
)
};
map
.
_map
.
add
(
new
AMap
.
Marker
(
markIcon
));
}
$
(
document
).
ready
(
function
(){
$
(
'body'
).
on
(
'click'
,
'.close'
,
function
()
{
$
(
this
).
parent
().
remove
();
})
});
</script>
</body>
</html>
src/test/java/com/dlbridge/jadp/LamdatTest.java
0 → 100644
View file @
f84952e9
package
com
.
dlbridge
.
jadp
;
import
java.util.Arrays
;
import
java.util.List
;
/**
* @Author shuxing.yang
* @Date 2021/4/11 11:48
*/
public
class
LamdatTest
{
public
static
void
main
(
String
[]
args
)
{
//Reduction
List
<
Integer
>
integers
=
Arrays
.
asList
(
1
,
2
,
3
);
Integer
reduced
=
integers
.
stream
().
reduce
(
100
,
(
a
,
b
)
->
{
System
.
out
.
println
(
"a:"
+
a
);
System
.
out
.
println
(
"b:"
+
b
);
return
a
+
b
;
});
}
}
src/test/java/com/dlbridge/jadp/LockMain.java
0 → 100644
View file @
f84952e9
package
com
.
dlbridge
.
jadp
;
import
com.qiyuesuo.sdk.v2.SdkClient
;
import
com.qiyuesuo.sdk.v2.bean.*
;
import
com.qiyuesuo.sdk.v2.json.JSONUtils
;
import
com.qiyuesuo.sdk.v2.param.SignParam
;
import
com.qiyuesuo.sdk.v2.request.ContractDraftRequest
;
import
com.qiyuesuo.sdk.v2.request.ContractPageRequest
;
import
com.qiyuesuo.sdk.v2.request.ContractSignCompanyRequest
;
import
com.qiyuesuo.sdk.v2.response.ContractPageResult
;
import
com.qiyuesuo.sdk.v2.response.SdkResponse
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @Author shuxing.yang
* @Date 2021/4/6 17:33
*/
public
class
LockMain
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
LockMain
.
class
);
private
static
final
String
PLATFORM_NAME
=
"大头橙橙汁公司"
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
String
url
=
"https://openapi.qiyuesuo.cn"
;
String
accessKey
=
"trRQR9ewQX"
;
String
accessSecret
=
"W6PysadsbPppDfts18ukZBUJ2GPkQZ"
;
SdkClient
client
=
new
SdkClient
(
url
,
accessKey
,
accessSecret
);
/**
* 根据业务分类配置进行合同发起,文件、签署流程、签署公章、签署位置均在业务分类中维护
* 该场景模拟一个人事合同的场景,即平台方公司与员工签署合同,平台方公司先签署,员工后签
*/
SdkResponse
<
Contract
>
draft
=
draft
(
client
);
System
.
out
.
println
(
"创建合同草稿成功,并发起,合同ID:{}"
+
draft
.
getResult
().
getId
());
companySealSignByCategoryConfig
(
client
,
draft
.
getResult
().
getId
());
System
.
out
.
println
(
"公章签署成功"
);
/**
* 平台方签署完成,签署方签署可采用
* (1)接收短信的方式登录契约锁云平台进行签署
* (2)生成内嵌页面签署链接进行签署(下方生成的链接)
* (3)JS-SDK签署(仅支持个人)
*/
SdkResponse
<
ContractPageResult
>
pageResponse
=
gerenateSignUrl
(
client
,
draft
.
getResult
().
getId
());
System
.
out
.
println
(
"生成签署链接成功,签署地址:{}"
+
pageResponse
.
getResult
().
getPageUrl
());
}
/**
* 根据业务分类配置创建合同草稿并发起合同
*
* @param client
* @return
* @throws Exception
*/
private
static
SdkResponse
<
Contract
>
draft
(
SdkClient
client
)
throws
Exception
{
Contract
draftContract
=
new
Contract
();
draftContract
.
setSubject
(
"合同主题"
);
draftContract
.
setCategory
(
new
Category
(
2584280095237849689L
));
// 设置业务分类ID,套用该业务分类的配置
draftContract
.
addTemplateParam
(
new
TemplateParam
(
"接收方2"
,
"发起方填参"
));
// 若业务分类中包含参数模板,设置参数内容
draftContract
.
addTemplateParam
(
new
TemplateParam
(
"接收方1"
,
"发起方填参"
));
// 设置接收方详情,接收方需要与业务分类中设置的签署方流程匹配
// 公司签署方
Signatory
companySignatory
=
new
Signatory
();
companySignatory
.
setTenantName
(
PLATFORM_NAME
);
companySignatory
.
setTenantType
(
"COMPANY"
);
companySignatory
.
setReceiver
(
new
User
(
"17621699044"
,
"MOBILE"
));
companySignatory
.
setSerialNo
(
1
);
draftContract
.
addSignatory
(
companySignatory
);
// 个人签署方
Signatory
personalSignatory
=
new
Signatory
();
personalSignatory
.
setTenantType
(
"PERSONAL"
);
personalSignatory
.
setReceiver
(
new
User
(
"15021504325"
,
"MOBILE"
));
personalSignatory
.
setTenantName
(
"邓茜茜"
);
draftContract
.
addSignatory
(
personalSignatory
);
draftContract
.
setSend
(
true
);
// 创建合同草稿并发起合同
String
response
=
null
;
try
{
response
=
client
.
service
(
new
ContractDraftRequest
(
draftContract
));
}
catch
(
Exception
e
)
{
throw
new
Exception
(
"创建合同草稿请求服务器失败,失败原因:"
+
e
.
getMessage
());
}
SdkResponse
<
Contract
>
sdkResponse
=
JSONUtils
.
toQysResponse
(
response
,
Contract
.
class
);
if
(!
sdkResponse
.
getCode
().
equals
(
0
))
{
throw
new
Exception
(
"创建合同草稿失败,失败原因:"
+
sdkResponse
.
getMessage
());
}
return
sdkResponse
;
}
/**
* 根据业务分类配置的签署位置与印章签署公章
* 若未配置签署位置需要设置签署位置与印章
*
* @param client
* @param contractId
* @return
* @throws Exception
*/
private
static
SdkResponse
companySealSignByCategoryConfig
(
SdkClient
client
,
Long
contractId
)
throws
Exception
{
SignParam
param
=
new
SignParam
();
param
.
setContractId
(
contractId
);
String
response
=
null
;
try
{
response
=
client
.
service
(
new
ContractSignCompanyRequest
(
param
));
}
catch
(
Exception
e
)
{
throw
new
Exception
(
"公章签署请求服务器失败,失败原因:"
+
e
.
getMessage
());
}
SdkResponse
sdkResponse
=
JSONUtils
.
toQysResponse
(
response
,
Object
.
class
);
if
(!
sdkResponse
.
getCode
().
equals
(
0
))
{
throw
new
Exception
(
"公章签署失败,失败原因:"
+
sdkResponse
.
getMessage
());
}
return
sdkResponse
;
}
/**
* 生成用户的签署链接
*
* @param client
* @param contractId
* @return
* @throws Exception
*/
private
static
SdkResponse
<
ContractPageResult
>
gerenateSignUrl
(
SdkClient
client
,
Long
contractId
)
throws
Exception
{
User
signUser
=
new
User
(
"15021504325"
,
"MOBILE"
);
String
callbackPage
=
"https://www.qiyuesuo.com"
;
ContractPageRequest
request
=
new
ContractPageRequest
(
contractId
,
signUser
,
callbackPage
);
String
response
;
try
{
response
=
client
.
service
(
request
);
}
catch
(
Exception
e
)
{
throw
new
Exception
(
"生成签署链接请求服务器失败,失败原因:"
+
e
.
getMessage
());
}
SdkResponse
<
ContractPageResult
>
sdkResponse
=
JSONUtils
.
toQysResponse
(
response
,
ContractPageResult
.
class
);
if
(!
sdkResponse
.
getCode
().
equals
(
0
))
{
throw
new
Exception
(
"法人章签署失败,失败原因:"
+
sdkResponse
.
getMessage
());
}
return
sdkResponse
;
}
}
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