Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
S
shr-server
Project
Project
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
Graph
比较
统计图
议题
0
议题
0
列表
看板
标记
Milestones
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
inroi
shr-server
Commits
69fb415b
提交
69fb415b
authored
7月 27, 2022
作者:
inroi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
微调
上级
7c825117
显示空白字符变更
内嵌
并排
正在显示
17 个修改的文件
包含
589 行增加
和
34 行删除
+589
-34
pom.xml
pom.xml
+6
-1
CallShrOsfApi.java
src/main/java/com/shr/api/CallShrOsfApi.java
+79
-3
EasController.java
src/main/java/com/shr/controller/EasController.java
+9
-9
EmployeeController.java
src/main/java/com/shr/controller/EmployeeController.java
+3
-6
ToDoTaskController.java
src/main/java/com/shr/controller/ToDoTaskController.java
+43
-0
LogMapper.java
src/main/java/com/shr/dao/LogMapper.java
+12
-0
LogMapper.xml
src/main/java/com/shr/dao/mapper/LogMapper.xml
+21
-0
Log.java
src/main/java/com/shr/model/Log.java
+3
-9
IToDoTaskService.java
src/main/java/com/shr/serivce/IToDoTaskService.java
+30
-0
LogServiceImpl.java
src/main/java/com/shr/serivce/impl/LogServiceImpl.java
+10
-0
ToDoTaskServiceImpl.java
src/main/java/com/shr/serivce/impl/ToDoTaskServiceImpl.java
+109
-0
ToDoTaskDetailListInVo.java
...in/java/com/shr/transfer/task/ToDoTaskDetailListInVo.java
+20
-0
ToDoTaskDetailListOutVo.java
...n/java/com/shr/transfer/task/ToDoTaskDetailListOutVo.java
+19
-0
ToDoTaskListInVo.java
src/main/java/com/shr/transfer/task/ToDoTaskListInVo.java
+20
-0
ToDoTaskListOutVo.java
src/main/java/com/shr/transfer/task/ToDoTaskListOutVo.java
+31
-0
HttpClientUtil.java
src/main/java/com/shr/utils/HttpClientUtil.java
+163
-0
application-docker.yml
src/main/resources/application-docker.yml
+11
-6
没有找到文件。
pom.xml
浏览文件 @
69fb415b
...
...
@@ -61,9 +61,14 @@
</dependency>
<!-- Mysql -->
<dependency>
<
!--<
dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>-->
<dependency>
<groupId>
com.oracle
</groupId>
<artifactId>
ojdbc8
</artifactId>
<version>
12.2.0.1
</version>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
...
...
src/main/java/com/shr/api/CallShrOsfApi.java
浏览文件 @
69fb415b
...
...
@@ -2,12 +2,21 @@ package com.shr.api;
import
com.kingdee.shr.api.Response
;
import
com.kingdee.shr.api.SHRClient
;
import
com.kingdee.shr.api.Token
;
import
com.kingdee.shr.sso.client.ltpa.LtpaTokenManager
;
import
com.kingdee.shr.sso.client.util.UrlUtil
;
import
com.shr.exception.ShrException
;
import
com.shr.utils.JsonUtil
;
import
org.apache.commons.httpclient.Cookie
;
import
org.apache.commons.httpclient.HttpClient
;
import
org.apache.commons.httpclient.HttpException
;
import
org.apache.commons.httpclient.methods.GetMethod
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Component
;
import
java.io.IOException
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
...
...
@@ -21,14 +30,15 @@ public class CallShrOsfApi {
private
String
serverUrl
;
public
CallShrOsfApi
()
{
serverUrl
=
"http://172.16.1.67:
80
90/shr"
;
serverUrl
=
"http://172.16.1.67:
68
90/shr"
;
}
public
Response
callShrOsf
(
String
serviceName
,
Map
<
String
,
Object
>
param
)
{
SHRClient
shrClient
=
new
SHRClient
();
try
{
Response
response
=
shrClient
.
executeService
(
serverUrl
,
serviceName
,
param
);
log
.
info
(
"SHR返回结果: {}"
,
response
);
Token
token
=
this
.
loginShrByUser
(
serverUrl
);
Response
response
=
shrClient
.
executeOSFService
(
serverUrl
,
token
,
serviceName
,
param
);
log
.
info
(
"SHR返回结果: {}"
,
JsonUtil
.
toString
(
response
.
getData
()));
return
response
;
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
...
...
@@ -36,5 +46,71 @@ public class CallShrOsfApi {
}
}
public
Token
loginShrByUser
(
String
serverUrl
)
throws
IOException
{
String
loginUrl
=
serverUrl
+
"/OTP2sso.jsp"
;
Map
<
String
,
Object
>
parameters
=
new
HashMap
<>(
10
);
parameters
.
put
(
"username"
,
"0196"
);
String
password
=
LtpaTokenManager
.
generate
((
String
)
parameters
.
get
(
"username"
),
LtpaTokenManager
.
getDefaultLtpaConfig
(),
"OTP"
).
toString
();
parameters
.
put
(
"password"
,
password
);
parameters
.
put
(
"userAuthPattern"
,
"OTP"
);
parameters
.
put
(
"isNotCheckRelogin"
,
"true"
);
String
url
=
UrlUtil
.
assembleUrl
(
loginUrl
,
parameters
);
HttpClient
client
=
new
HttpClient
();
client
.
getParams
().
setParameter
(
"http.protocol.allow-circular-redirects"
,
true
);
GetMethod
method
=
new
GetMethod
(
url
);
method
.
addRequestHeader
(
"Referer"
,
serverUrl
);
method
.
getParams
().
setParameter
(
"http.protocol.single-cookie-header"
,
true
);
method
.
getParams
().
setParameter
(
"http.protocol.cookie-policy"
,
"compatibility"
);
method
.
setFollowRedirects
(
true
);
int
status
=
client
.
executeMethod
(
method
);
Token
token
;
if
(
status
!=
200
)
{
System
.
err
.
println
(
"Method failed: "
+
method
.
getStatusLine
());
throw
new
HttpException
(
"login shr fail, status: "
+
status
);
}
else
{
token
=
this
.
getToken
(
client
.
getState
().
getCookies
());
return
token
;
}
}
private
Token
getToken
(
Cookie
[]
cookies
)
throws
HttpException
{
Cookie
cookie
;
for
(
Cookie
value
:
cookies
)
{
cookie
=
value
;
if
(
"JSESSIONID"
.
equalsIgnoreCase
(
cookie
.
getName
())
&&
!
cookie
.
getPath
().
contains
(
"sso"
))
{
Token
token
=
new
Token
();
token
.
setDomain
(
cookie
.
getDomain
());
token
.
setPath
(
cookie
.
getPath
());
token
.
setValue
(
cookie
.
getValue
());
return
token
;
}
}
throw
new
HttpException
(
"getToken fail, cookies: "
+
this
.
cookieToString
(
cookies
));
}
private
String
cookieToString
(
Cookie
[]
cookies
)
{
Cookie
cookie
;
StringBuilder
sb
=
new
StringBuilder
();
for
(
int
i
=
0
;
i
<
cookies
.
length
;
++
i
)
{
cookie
=
cookies
[
i
];
if
(
i
!=
0
)
{
sb
.
append
(
","
);
}
sb
.
append
(
"[name="
);
sb
.
append
(
cookie
.
getName
());
sb
.
append
(
", path="
);
sb
.
append
(
cookie
.
getPath
());
sb
.
append
(
", value="
);
sb
.
append
(
cookie
.
getValue
());
sb
.
append
(
"]"
);
}
return
sb
.
toString
();
}
}
src/main/java/com/shr/controller/EasController.java
浏览文件 @
69fb415b
package
com
.
shr
.
controller
;
import
com.kingdee.shr.sso.client.ltpa.LtpaTokenManager
;
import
com.shr.config.ThreadLocalConfig
;
import
com.shr.utils.StringUtil
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
...
...
@@ -28,10 +26,11 @@ public class EasController {
//要跳转的url '//'代表首页
String
redirectTo
=
"//"
;
//调用LtpaTokenManager,根据密钥生成用户令牌
String
ssoUsername
=
ThreadLocalConfig
.
get
().
get
(
"ssoUsername"
).
toString
();
/*
String ssoUsername = ThreadLocalConfig.get().get("ssoUsername").toString();
if (StringUtil.isBlank(ssoUsername)) {
ssoUsername
=
"administrator"
;
}
return;
}*/
String
ssoUsername
=
"administrator"
;
String
password
=
LtpaTokenManager
.
generate
(
ssoUsername
,
LtpaTokenManager
.
getDefaultLtpaConfig
()).
toString
();
System
.
out
.
println
(
"password: "
+
password
);
...
...
@@ -47,14 +46,15 @@ public class EasController {
@GetMapping
(
value
=
"/shr/ssoLogin"
)
public
void
shrSsoLogin
(
HttpServletResponse
response
)
throws
IOException
{
//s-HR地址
String
shrLocal
=
"http://1
27.0.0.1:6888
/shr/home.do"
;
String
shrLocal
=
"http://1
72.16.1.67:8090
/shr/home.do"
;
String
redirectTo
=
URLEncoder
.
encode
(
shrLocal
);
//登陆用户名
String
ssoUsername
=
ThreadLocalConfig
.
get
().
get
(
"ssoUsername"
).
toString
();
/*
String ssoUsername = ThreadLocalConfig.get().get("ssoUsername").toString();
if (StringUtil.isBlank(ssoUsername)) {
ssoUsername
=
"administrator"
;
}
return;
}*/
String
ssoUsername
=
"administrator"
;
//根据密钥生成的密码串
String
password
=
LtpaTokenManager
.
generate
(
ssoUsername
,
LtpaTokenManager
.
getDefaultLtpaConfig
(),
"OTP"
).
toString
();
System
.
out
.
println
(
"password: "
+
password
);
...
...
src/main/java/com/shr/controller/EmployeeController.java
浏览文件 @
69fb415b
...
...
@@ -6,10 +6,7 @@ import com.shr.serivce.IEmployeeService;
import
com.shr.transfer.employee.*
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.*
;
/**
* @author Inori
...
...
@@ -23,8 +20,8 @@ public class EmployeeController {
@AccessLog
(
"员工列表"
)
@
Pos
tMapping
(
"/employee/list"
)
public
RestResponse
employeeList
(
@
RequestBody
(
required
=
true
)
@Validated
EmployeeListInVo
inVo
)
{
@
Ge
tMapping
(
"/employee/list"
)
public
RestResponse
employeeList
(
@
ModelAttribute
@Validated
EmployeeListInVo
inVo
)
{
EmployeeListOutVo
outVo
=
employeeService
.
employeeList
(
inVo
);
return
RestResponse
.
success
(
outVo
);
}
...
...
src/main/java/com/shr/controller/ToDoTaskController.java
0 → 100644
浏览文件 @
69fb415b
package
com
.
shr
.
controller
;
import
com.shr.annotion.AccessLog
;
import
com.shr.common.response.RestResponse
;
import
com.shr.serivce.IToDoTaskService
;
import
com.shr.transfer.task.ToDoTaskDetailListInVo
;
import
com.shr.transfer.task.ToDoTaskDetailListOutVo
;
import
com.shr.transfer.task.ToDoTaskListInVo
;
import
com.shr.transfer.task.ToDoTaskListOutVo
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.ModelAttribute
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
/**
* @author Inori
*/
@RestController
@RequestMapping
(
"/api"
)
public
class
ToDoTaskController
{
@Autowired
private
IToDoTaskService
toDoTaskService
;
@AccessLog
(
"待办任务列表总数"
)
@GetMapping
(
"/to/do/task/list"
)
public
RestResponse
toDoTaskList
(
@ModelAttribute
@Validated
ToDoTaskListInVo
inVo
)
{
ToDoTaskListOutVo
outVo
=
toDoTaskService
.
toDoTaskList
(
inVo
);
return
RestResponse
.
success
(
outVo
);
}
@AccessLog
(
"待办任务明细列表"
)
@GetMapping
(
"/to/do/task/detail/list"
)
public
RestResponse
toDoTaskDetailList
(
@ModelAttribute
@Validated
ToDoTaskDetailListInVo
inVo
)
{
ToDoTaskDetailListOutVo
outVo
=
toDoTaskService
.
toDoTaskDetailList
(
inVo
);
return
RestResponse
.
success
(
outVo
);
}
}
src/main/java/com/shr/dao/LogMapper.java
浏览文件 @
69fb415b
...
...
@@ -23,5 +23,17 @@ public interface LogMapper extends BaseMapper<Log> {
*/
List
<
LogListOutVoRecords
>
logList
(
@Param
(
"page"
)
Page
<
LogListOutVoRecords
>
page
,
@Param
(
"inVo"
)
LogListInVo
inVo
);
/**
* 是否存在表
*
* @return 0-不存在 1-已存在
*/
Integer
isTable
();
/**
* 创建日志表
*/
void
createTable
();
}
src/main/java/com/shr/dao/mapper/LogMapper.xml
浏览文件 @
69fb415b
...
...
@@ -28,4 +28,25 @@
<select
id=
"isTable"
resultType=
"java.lang.Integer"
>
select count(*) from user_tables where table_name =upper('tb_log')
</select>
<insert
id=
"createTable"
>
create table tb_log (
`id` VARCHAR2(32) DEFAULT SYS_GUID() PRIMARY KEY,
`content` VARCHAR2(500) default null,
`system_type` VARCHAR2(50) default null,
`result` BLOB default null
)
</insert>
</mapper>
src/main/java/com/shr/model/Log.java
浏览文件 @
69fb415b
package
com
.
shr
.
model
;
import
com.baomidou.mybatisplus.annotations.TableField
;
import
com.baomidou.mybatisplus.annotations.TableId
;
import
com.baomidou.mybatisplus.annotations.TableName
;
import
com.baomidou.mybatisplus.enums.IdType
;
/**
* @author Inori
...
...
@@ -14,8 +11,7 @@ public class Log {
/**
* 用户ID
*/
@TableId
(
value
=
"id"
,
type
=
IdType
.
AUTO
)
private
Integer
id
;
private
String
id
;
/**
...
...
@@ -27,7 +23,6 @@ public class Log {
/**
* 系统类型
*/
@TableField
(
"system_type"
)
private
String
systemType
;
...
...
@@ -40,18 +35,17 @@ public class Log {
/**
* 创建时间
*/
@TableField
(
"create_time"
)
private
String
createTime
;
public
Log
()
{
}
public
Integer
getId
()
{
public
String
getId
()
{
return
id
;
}
public
void
setId
(
Integer
id
)
{
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
...
...
src/main/java/com/shr/serivce/IToDoTaskService.java
0 → 100644
浏览文件 @
69fb415b
package
com
.
shr
.
serivce
;
import
com.shr.transfer.task.ToDoTaskDetailListInVo
;
import
com.shr.transfer.task.ToDoTaskDetailListOutVo
;
import
com.shr.transfer.task.ToDoTaskListInVo
;
import
com.shr.transfer.task.ToDoTaskListOutVo
;
/**
* @author Inori
*/
public
interface
IToDoTaskService
{
/**
* 待办列表总数
*
* @param inVo 条件
* @return 列表
*/
ToDoTaskListOutVo
toDoTaskList
(
ToDoTaskListInVo
inVo
);
/**
* 待办任务明细列表
*
* @param inVo 条件
* @return 列表
*/
ToDoTaskDetailListOutVo
toDoTaskDetailList
(
ToDoTaskDetailListInVo
inVo
);
}
src/main/java/com/shr/serivce/impl/LogServiceImpl.java
浏览文件 @
69fb415b
...
...
@@ -9,6 +9,7 @@ import com.shr.transfer.log.LogListOutVoRecords;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.PostConstruct
;
import
java.util.List
;
/**
...
...
@@ -21,6 +22,15 @@ public class LogServiceImpl implements ILogService {
private
LogMapper
logMapper
;
@PostConstruct
public
void
init
()
{
Integer
isTable
=
logMapper
.
isTable
();
System
.
out
.
println
(
isTable
);
if
(
isTable
==
0
)
{
logMapper
.
createTable
();
}
}
@Override
public
LogListOutVo
logList
(
LogListInVo
inVo
)
{
Page
<
LogListOutVoRecords
>
page
=
new
Page
<>(
inVo
.
getPageNo
(),
inVo
.
getPageSize
());
...
...
src/main/java/com/shr/serivce/impl/ToDoTaskServiceImpl.java
0 → 100644
浏览文件 @
69fb415b
package
com
.
shr
.
serivce
.
impl
;
import
com.kingdee.shr.api.Response
;
import
com.shr.api.CallShrOsfApi
;
import
com.shr.common.response.RestResponse
;
import
com.shr.serivce.IToDoTaskService
;
import
com.shr.transfer.task.ToDoTaskDetailListInVo
;
import
com.shr.transfer.task.ToDoTaskDetailListOutVo
;
import
com.shr.transfer.task.ToDoTaskListInVo
;
import
com.shr.transfer.task.ToDoTaskListOutVo
;
import
com.shr.utils.HttpClientUtil
;
import
com.shr.utils.JsonUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
* @author Inori
*/
@Service
public
class
ToDoTaskServiceImpl
implements
IToDoTaskService
{
@Autowired
private
CallShrOsfApi
callShrOsfApi
;
@Override
public
ToDoTaskListOutVo
toDoTaskList
(
ToDoTaskListInVo
inVo
)
{
Response
totalResponse
=
callShrOsfApi
.
callShrOsf
(
"getUnProcessAssignCount"
,
null
);
Map
<
String
,
Object
>
map
=
JsonUtil
.
toMap
(
JsonUtil
.
toString
(
totalResponse
.
getData
()),
String
.
class
,
Object
.
class
);
Map
<
String
,
Object
>
temp
=
new
HashMap
<>();
temp
.
put
(
"total"
,
Integer
.
parseInt
((
String
)
map
.
get
(
"total"
)));
temp
.
put
(
"page"
,
1
);
temp
.
put
(
"rows"
,
9999
);
Response
detailResponse
=
callShrOsfApi
.
callShrOsf
(
"getUnProcessAssign"
,
temp
);
ToDoTaskListOutVo
outVo
=
new
ToDoTaskListOutVo
();
outVo
.
setTotal
(
Integer
.
parseInt
((
String
)
map
.
get
(
"total"
)));
outVo
.
setTotalRecords
(
JsonUtil
.
toList
(
JsonUtil
.
toString
(
map
.
get
(
"categoryCount"
)),
Object
.
class
));
outVo
.
setDetailRecords
(
JsonUtil
.
toList
(
JsonUtil
.
toString
(
detailResponse
.
getData
()),
Object
.
class
));
this
.
toDoTaskSynchronization
(
outVo
);
return
outVo
;
}
@Override
public
ToDoTaskDetailListOutVo
toDoTaskDetailList
(
ToDoTaskDetailListInVo
inVo
)
{
Response
response
=
callShrOsfApi
.
callShrOsf
(
"getUnProcessAssign"
,
null
);
ToDoTaskDetailListOutVo
outVo
=
new
ToDoTaskDetailListOutVo
();
outVo
.
setRecords
(
JsonUtil
.
toList
(
JsonUtil
.
toString
(
response
.
getData
()),
Object
.
class
));
return
outVo
;
}
public
RestResponse
toDoTaskSynchronization
(
ToDoTaskListOutVo
outVo
)
{
String
url
=
"http://172.16.1.78:81"
;
String
json
=
"{\"userName\":\"hrrest\",\"password\":\"hrhdrest123\"}"
;
String
toekn
=
HttpClientUtil
.
sendPost
(
url
+
"/seeyon/rest/token"
,
json
);
Map
<
String
,
Object
>
temp
=
JsonUtil
.
toMap
(
toekn
,
String
.
class
,
Object
.
class
);
if
(
CollectionUtils
.
isEmpty
(
temp
)
&&
!
temp
.
containsKey
(
"id"
))
{
return
RestResponse
.
fail
(
"OA登陆失败"
);
}
List
<
Map
<
String
,
Object
>>
tempList
=
new
ArrayList
<>();
for
(
Object
object
:
outVo
.
getDetailRecords
())
{
Map
<
String
,
Object
>
map
=
JsonUtil
.
toMap
(
JsonUtil
.
toString
(
object
),
String
.
class
,
Object
.
class
);
Map
<
String
,
Object
>
reqeust
=
new
HashMap
<>(
15
);
reqeust
.
put
(
"taskId"
,
map
.
get
(
"id"
));
reqeust
.
put
(
"registerCode"
,
"3001"
);
reqeust
.
put
(
"title"
,
map
.
get
(
"subject"
));
reqeust
.
put
(
"classify"
,
"erp"
);
reqeust
.
put
(
"contentType"
,
"erp"
);
reqeust
.
put
(
"thirdSenderId"
,
""
);
reqeust
.
put
(
"senderName"
,
map
.
get
(
"sender"
));
reqeust
.
put
(
"thirdReceiverId"
,
""
);
reqeust
.
put
(
"noneBindingReceiver"
,
map
.
get
(
"priorPerform"
));
reqeust
.
put
(
"noneBindingSender"
,
map
.
get
(
"sender"
));
reqeust
.
put
(
"creationDate"
,
map
.
get
(
"createdTime"
));
reqeust
.
put
(
"state"
,
map
.
get
(
"state"
));
reqeust
.
put
(
"subState"
,
"0"
);
reqeust
.
put
(
"content"
,
""
);
reqeust
.
put
(
"url"
,
"http://ericbing/K3Cloud7.5/html5/index.aspx"
);
reqeust
.
put
(
"h5url"
,
""
);
reqeust
.
put
(
"appParam"
,
""
);
tempList
.
add
(
reqeust
);
}
String
result
=
HttpClientUtil
.
sendPost
(
url
+
"/seeyon/rest/thirdpartyPending/receive?token="
+
temp
.
get
(
"id"
),
JsonUtil
.
toString
(
tempList
));
System
.
out
.
println
(
"---------------->"
+
result
);
Map
<
String
,
Object
>
map
=
JsonUtil
.
toMap
(
result
,
String
.
class
,
Object
.
class
);
if
(
CollectionUtils
.
isEmpty
(
map
))
{
return
RestResponse
.
fail
(
"无返回值"
);
}
if
(
"false"
.
equals
(
map
.
get
(
"success"
)))
{
List
<
Object
>
errorList
=
JsonUtil
.
toList
(
JsonUtil
.
toString
(
map
.
get
(
"errorMsgs"
)),
Object
.
class
);
String
errorDetail
=
errorList
.
stream
().
map
(
m
->
(
String
)
JsonUtil
.
toMap
(
JsonUtil
.
toString
(
m
),
String
.
class
,
Object
.
class
).
get
(
"errorDetail"
)).
collect
(
Collectors
.
joining
(
", "
));
return
RestResponse
.
fail
(
errorDetail
);
}
return
RestResponse
.
success
();
}
}
src/main/java/com/shr/transfer/task/ToDoTaskDetailListInVo.java
0 → 100644
浏览文件 @
69fb415b
package
com
.
shr
.
transfer
.
task
;
import
lombok.Data
;
import
javax.validation.constraints.NotBlank
;
/**
* @author Inori
*/
@Data
public
class
ToDoTaskDetailListInVo
{
/**
* 系统类型
*/
@NotBlank
(
message
=
"参数systemType缺失"
)
private
String
systemType
;
}
src/main/java/com/shr/transfer/task/ToDoTaskDetailListOutVo.java
0 → 100644
浏览文件 @
69fb415b
package
com
.
shr
.
transfer
.
task
;
import
lombok.Data
;
import
java.util.List
;
/**
* @author Inori
*/
@Data
public
class
ToDoTaskDetailListOutVo
{
/**
* 记录
*/
private
List
<
Object
>
records
;
}
src/main/java/com/shr/transfer/task/ToDoTaskListInVo.java
0 → 100644
浏览文件 @
69fb415b
package
com
.
shr
.
transfer
.
task
;
import
lombok.Data
;
import
javax.validation.constraints.NotBlank
;
/**
* @author Inori
*/
@Data
public
class
ToDoTaskListInVo
{
/**
* 系统类型
*/
@NotBlank
(
message
=
"参数systemType缺失"
)
private
String
systemType
;
}
src/main/java/com/shr/transfer/task/ToDoTaskListOutVo.java
0 → 100644
浏览文件 @
69fb415b
package
com
.
shr
.
transfer
.
task
;
import
lombok.Data
;
import
java.util.List
;
/**
* @author Inori
*/
@Data
public
class
ToDoTaskListOutVo
{
/**
* 总数
*/
private
Integer
total
;
/**
* 总数记录
*/
private
List
<
Object
>
totalRecords
;
/**
* 明细记录
*/
private
List
<
Object
>
detailRecords
;
}
src/main/java/com/shr/utils/HttpClientUtil.java
0 → 100644
浏览文件 @
69fb415b
package
com
.
shr
.
utils
;
import
org.apache.commons.httpclient.DefaultHttpMethodRetryHandler
;
import
org.apache.commons.httpclient.HttpClient
;
import
org.apache.commons.httpclient.HttpException
;
import
org.apache.commons.httpclient.HttpStatus
;
import
org.apache.commons.httpclient.methods.GetMethod
;
import
org.apache.commons.httpclient.methods.PostMethod
;
import
org.apache.commons.httpclient.methods.RequestEntity
;
import
org.apache.commons.httpclient.methods.StringRequestEntity
;
import
org.apache.commons.httpclient.params.HttpMethodParams
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.io.IOException
;
import
java.io.UnsupportedEncodingException
;
import
java.nio.charset.StandardCharsets
;
import
java.util.List
;
/**
* 发送请求工具类
*
* @author Lnori
*/
public
class
HttpClientUtil
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
HttpClientUtil
.
class
);
public
static
void
main
(
String
[]
args
)
throws
UnsupportedEncodingException
{
String
s
=
sendGet
(
"https://r.qzone.qq.com/fcg-bin/cgi_get_portrait.fcg?g_tk=&uins=865347524"
);
System
.
out
.
println
(
s
.
indexOf
(
"{"
));
System
.
out
.
println
(
s
.
indexOf
(
"}"
));
String
substring1
=
s
.
substring
(
s
.
indexOf
(
"{"
)
+
2
,
s
.
indexOf
(
":"
)
-
1
);
System
.
out
.
println
(
substring1
);
String
substring
=
s
.
substring
(
s
.
indexOf
(
"["
),
s
.
indexOf
(
"]"
)
+
1
);
List
<
String
>
list
=
JsonUtil
.
toList
(
substring
,
String
.
class
);
for
(
String
s1
:
list
)
{
System
.
out
.
println
(
s1
);
}
}
public
static
final
String
[]
ENCODES
=
new
String
[]{
"UTF-8"
,
"GBK"
,
"GB2312"
,
"ISO-8859-1"
,
"ISO-8859-2"
};
/**
* 发送Get请求
*
* @param url url
* @return 结果
*/
public
static
String
sendGet
(
String
url
)
{
log
.
info
(
"【Get请求】Url: {}"
,
url
);
/*
* 1.生成HttpClient对象并设置参数
*/
HttpClient
httpClient
=
new
HttpClient
();
//设置Http连接超时为10秒
httpClient
.
getHttpConnectionManager
().
getParams
().
setConnectionTimeout
(
10000
);
/*
* 2.生成GetMethod对象并设置参数
*/
GetMethod
getMethod
=
new
GetMethod
(
url
);
//设置get请求超时为10秒
getMethod
.
getParams
().
setParameter
(
HttpMethodParams
.
SO_TIMEOUT
,
10000
);
//设置请求重试处理,用的是默认的重试处理:请求三次
getMethod
.
getParams
().
setParameter
(
HttpMethodParams
.
RETRY_HANDLER
,
new
DefaultHttpMethodRetryHandler
());
String
response
;
/*
* 3.执行HTTP GET 请求
*/
try
{
int
statusCode
=
httpClient
.
executeMethod
(
getMethod
);
/*
* 4.判断访问的状态码
*/
if
(
statusCode
!=
HttpStatus
.
SC_OK
)
{
log
.
error
(
"请求出错:{}"
,
getMethod
.
getStatusLine
());
}
/*
* 5.处理HTTP响应内容
*/
//读取为字节数组
byte
[]
responseBody
=
getMethod
.
getResponseBody
();
response
=
new
String
(
responseBody
,
"GBK"
);
log
.
info
(
"【Get请求】返回值: {}"
,
response
);
return
response
;
}
catch
(
HttpException
e
)
{
log
.
error
(
"请检查输入的URL!"
);
}
catch
(
IOException
e
)
{
log
.
error
(
"发生网络异常!"
);
}
finally
{
/*
* 6.释放连接
*/
getMethod
.
releaseConnection
();
httpClient
.
getHttpConnectionManager
().
closeIdleConnections
(
0L
);
}
return
""
;
}
public
static
String
sendPost
(
String
url
,
String
json
)
{
log
.
info
(
"【Post请求】Url: {}"
,
url
);
/*
* 1.生成HttpClient对象并设置参数
*/
HttpClient
httpClient
=
new
HttpClient
();
//设置Http连接超时为10秒
httpClient
.
getHttpConnectionManager
().
getParams
().
setConnectionTimeout
(
10000
);
/*
* 2.生成PostMethod对象并设置参数
*/
PostMethod
postMethod
=
new
PostMethod
(
url
);
//设置post请求超时为10秒
postMethod
.
getParams
().
setParameter
(
HttpMethodParams
.
SO_TIMEOUT
,
10000
);
//设置请求重试处理,用的是默认的重试处理:请求三次
postMethod
.
getParams
().
setParameter
(
HttpMethodParams
.
RETRY_HANDLER
,
new
DefaultHttpMethodRetryHandler
());
//设置请求头
postMethod
.
addRequestHeader
(
"Content-Type"
,
"application/json"
);
/*
* 3.执行HTTP GET 请求
*/
String
response
=
""
;
try
{
//json格式的参数解析
RequestEntity
entity
=
new
StringRequestEntity
(
json
,
"application/json"
,
"UTF-8"
);
postMethod
.
setRequestEntity
(
entity
);
int
statusCode
=
httpClient
.
executeMethod
(
postMethod
);
/*
* 4.判断访问的状态码
*/
if
(
statusCode
!=
HttpStatus
.
SC_OK
)
{
log
.
error
(
"请求出错:{}"
,
postMethod
.
getStatusLine
());
}
/*
* 5.处理HTTP响应内容
*/
byte
[]
responseBody
=
postMethod
.
getResponseBody
();
response
=
new
String
(
responseBody
,
StandardCharsets
.
UTF_8
);
log
.
info
(
"【Post请求】返回值: {}"
,
response
);
return
response
;
}
catch
(
HttpException
e
)
{
log
.
error
(
"请检查输入的URL!"
);
}
catch
(
IOException
e
)
{
log
.
error
(
"发生网络异常!"
);
}
finally
{
/*
* 6.释放连接
*/
postMethod
.
releaseConnection
();
httpClient
.
getHttpConnectionManager
().
closeIdleConnections
(
0L
);
}
return
""
;
}
}
src/main/resources/application-docker.yml
浏览文件 @
69fb415b
...
...
@@ -19,16 +19,21 @@ spring:
max-request-size
:
100MB
max-file-size
:
100MB
# datasource:
# url: jdbc:mysql://127.0.0.1:3306/shr_server?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=CTT&allowPublicKeyRetrieval=true
# username: root
# password: 123456
# driver-class-name: com.mysql.cj.jdbc.Driver
datasource
:
url
:
jdbc:
mysql://127.0.0.1:3306/shr_server?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=CTT&allowPublicKeyRetrieval=true
username
:
root
url
:
jdbc:
oracle:thin:@192.168.20.128:1521:orcl
username
:
ssm
password
:
123456
driver-class-name
:
com.mysql.cj.jdbc.
Driver
driver-class-name
:
oracle.jdbc.driver.Oracle
Driver
mybatis-plus
:
mapper-locations
:
classpath*:/**/*Mapper.xml
typeAliasesPackage
:
com.shr.model
configuration
:
log-impl
:
org.apache.ibatis.logging.stdout.StdOutImpl
#
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
mapUnderscoreToCamelCase
:
true
\ No newline at end of file
cache-enabled
:
true
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论