Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
manager
Project
Overview
Details
Activity
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
reyun
manager
Commits
0e91d6b6
Commit
0e91d6b6
authored
May 30, 2018
by
manxiaoqiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adi
parent
c5c1e13d
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
222 additions
and
54 deletions
+222
-54
workspace.xml
.idea/workspace.xml
+0
-0
pom.xml
pom.xml
+1
-1
ContractController.java
src/main/java/common/controller/ContractController.java
+14
-14
UserLog.java
src/main/java/common/model/UserLog.java
+9
-0
ContractService.java
src/main/java/common/service/ContractService.java
+1
-1
ContractServiceImpl.java
src/main/java/common/service/impl/ContractServiceImpl.java
+90
-16
AuthorizationInterceptor.java
...n/java/security/interceptor/AuthorizationInterceptor.java
+15
-5
HttpClientUtil.java
src/main/java/util/HttpClientUtil.java
+85
-16
NewUserLogThread.java
src/main/java/util/NewUserLogThread.java
+3
-1
UserLogThread.java
src/main/java/util/UserLogThread.java
+2
-0
rest-servlet.xml
src/main/resources/rest-servlet.xml
+1
-0
applicationContext.xml
src/main/resources/spring/applicationContext.xml
+1
-0
No files found.
.idea/workspace.xml
View file @
0e91d6b6
This diff is collapsed.
Click to expand it.
pom.xml
View file @
0e91d6b6
...
...
@@ -827,7 +827,7 @@
<version>
${maven.jetty.version}
</version>
<configuration>
<httpConnector>
<port>
808
0
</port>
<port>
808
2
</port>
</httpConnector>
<webAppConfig>
<defaultsDescriptor>
src/main/resources/webdefault.xml
</defaultsDescriptor>
...
...
src/main/java/common/controller/ContractController.java
View file @
0e91d6b6
...
...
@@ -91,7 +91,7 @@ public class ContractController {
response
.
setHeader
(
"Content-Type"
,
"text/csv"
);
response
.
setContentType
(
"APPLICATION/OCTET-STREAM"
);
NewUserLogThread
userlog
=
new
NewUserLogThread
(
loginAccount
.
getEmail
(),
loginAccount
.
getName
(),
OperateObjectTypeEnum
.
CUSTOMER
.
getKey
(),
platform
,
"导出合同"
,
startDate
,
endDate
,
request
);
NewUserLogThread
userlog
=
new
NewUserLogThread
(
loginAccount
.
getEmail
(),
loginAccount
.
getName
(),
OperateObjectTypeEnum
.
CUSTOMER
.
getKey
(),
platform
,
"导出合同"
,
startDate
,
endDate
,
request
,
platform
);
userlog
.
start
();
//返回文件字符串
return
new
ResponseEntity
<
byte
[]>(
content
,
headers
,
HttpStatus
.
CREATED
);
...
...
@@ -128,7 +128,7 @@ public class ContractController {
response
.
setHeader
(
"Content-Type"
,
"text/csv"
);
response
.
setContentType
(
"APPLICATION/OCTET-STREAM"
);
NewUserLogThread
userlog
=
new
NewUserLogThread
(
loginAccount
.
getEmail
(),
loginAccount
.
getName
(),
OperateObjectTypeEnum
.
CUSTOMER
.
getKey
(),
platform
,
"导出收款开票"
,
startDate
,
endDate
,
request
);
NewUserLogThread
userlog
=
new
NewUserLogThread
(
loginAccount
.
getEmail
(),
loginAccount
.
getName
(),
OperateObjectTypeEnum
.
CUSTOMER
.
getKey
(),
platform
,
"导出收款开票"
,
startDate
,
endDate
,
request
,
platform
);
userlog
.
start
();
//返回文件字符串
return
new
ResponseEntity
<
byte
[]>(
content
,
headers
,
HttpStatus
.
CREATED
);
...
...
@@ -167,8 +167,8 @@ public class ContractController {
@RequestMapping
(
value
=
"find/pricelevel"
,
method
=
RequestMethod
.
GET
)
@ResponseBody
public
ResultModel
findPricelevel
(
@CurrentAccount
User
loginAccount
)
{
return
ResultModel
.
OK
(
service
.
findSetmeal
());
public
ResultModel
findPricelevel
(
@CurrentAccount
User
loginAccount
,
@PathVariable
String
platform
)
{
return
ResultModel
.
OK
(
service
.
findSetmeal
(
platform
));
}
@RequestMapping
(
value
=
"find/increment"
,
method
=
RequestMethod
.
GET
)
...
...
@@ -193,9 +193,9 @@ public class ContractController {
@RequestMapping
(
value
=
"create"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
public
ResultModel
create
(
@CurrentAccount
User
loginAccount
,
@RequestBody
Contract
contract
,
HttpServletRequest
request
)
{
public
ResultModel
create
(
@CurrentAccount
User
loginAccount
,
@RequestBody
Contract
contract
,
HttpServletRequest
request
,
@PathVariable
String
platform
)
{
Contract
contract1
=
service
.
create
(
loginAccount
,
contract
);
NewUserLogThread
userlog
=
new
NewUserLogThread
(
loginAccount
.
getEmail
(),
loginAccount
.
getName
(),
OperateObjectTypeEnum
.
CUSTOMER
.
getKey
(),
contract1
.
getContractCode
(),
"新建合同"
,
""
,
contract1
.
toString
(),
request
);
NewUserLogThread
userlog
=
new
NewUserLogThread
(
loginAccount
.
getEmail
(),
loginAccount
.
getName
(),
OperateObjectTypeEnum
.
CUSTOMER
.
getKey
(),
contract1
.
getContractCode
(),
"新建合同"
,
""
,
contract1
.
toString
(),
request
,
platform
);
userlog
.
start
();
ContractSendEmailThread
email
=
new
ContractSendEmailThread
(
contract
);
...
...
@@ -205,27 +205,27 @@ public class ContractController {
@RequestMapping
(
value
=
"update"
,
method
=
RequestMethod
.
PUT
)
@ResponseBody
public
ResultModel
update
(
@CurrentAccount
User
loginAccount
,
@RequestBody
Contract
contract
,
HttpServletRequest
request
)
{
public
ResultModel
update
(
@CurrentAccount
User
loginAccount
,
@RequestBody
Contract
contract
,
HttpServletRequest
request
,
@PathVariable
String
platform
)
{
Contract
contract1
=
service
.
update
(
loginAccount
,
contract
);
NewUserLogThread
userlog
=
new
NewUserLogThread
(
loginAccount
.
getEmail
(),
loginAccount
.
getName
(),
OperateObjectTypeEnum
.
CUSTOMER
.
getKey
(),
contract1
.
getContractCode
(),
"修改合同"
,
""
,
contract1
.
toString
(),
request
);
NewUserLogThread
userlog
=
new
NewUserLogThread
(
loginAccount
.
getEmail
(),
loginAccount
.
getName
(),
OperateObjectTypeEnum
.
CUSTOMER
.
getKey
(),
contract1
.
getContractCode
(),
"修改合同"
,
""
,
contract1
.
toString
(),
request
,
platform
);
userlog
.
start
();
return
ResultModel
.
OK
(
contract1
);
}
@RequestMapping
(
value
=
"pay"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
public
ResultModel
pay
(
@CurrentAccount
User
loginAccount
,
@RequestBody
ContractMoney
contract
,
HttpServletRequest
request
)
{
public
ResultModel
pay
(
@CurrentAccount
User
loginAccount
,
@RequestBody
ContractMoney
contract
,
HttpServletRequest
request
,
@PathVariable
String
platform
)
{
ContractMoney
contract1
=
service
.
pay
(
loginAccount
,
contract
);
NewUserLogThread
userlog
=
new
NewUserLogThread
(
loginAccount
.
getEmail
(),
loginAccount
.
getName
(),
OperateObjectTypeEnum
.
CUSTOMER
.
getKey
(),
contract1
.
getContractCode
(),
"收款开票"
,
""
,
contract1
.
toString
(),
request
);
NewUserLogThread
userlog
=
new
NewUserLogThread
(
loginAccount
.
getEmail
(),
loginAccount
.
getName
(),
OperateObjectTypeEnum
.
CUSTOMER
.
getKey
(),
contract1
.
getContractCode
(),
"收款开票"
,
""
,
contract1
.
toString
(),
request
,
platform
);
userlog
.
start
();
return
ResultModel
.
OK
(
contract1
);
}
@RequestMapping
(
value
=
"change"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
public
ResultModel
change
(
@CurrentAccount
User
loginAccount
,
@RequestBody
ContractChange
contract
,
HttpServletRequest
request
)
{
public
ResultModel
change
(
@CurrentAccount
User
loginAccount
,
@RequestBody
ContractChange
contract
,
HttpServletRequest
request
,
@PathVariable
String
platform
)
{
Contract
contract1
=
service
.
change
(
loginAccount
,
contract
);
NewUserLogThread
userlog
=
new
NewUserLogThread
(
loginAccount
.
getEmail
(),
loginAccount
.
getName
(),
OperateObjectTypeEnum
.
CUSTOMER
.
getKey
(),
contract1
.
getContractCode
(),
"修改套餐"
,
""
,
contract1
.
toString
(),
request
);
NewUserLogThread
userlog
=
new
NewUserLogThread
(
loginAccount
.
getEmail
(),
loginAccount
.
getName
(),
OperateObjectTypeEnum
.
CUSTOMER
.
getKey
(),
contract1
.
getContractCode
(),
"修改套餐"
,
""
,
contract1
.
toString
(),
request
,
platform
);
userlog
.
start
();
return
ResultModel
.
OK
(
contract1
);
}
...
...
@@ -246,9 +246,9 @@ public class ContractController {
@RequestMapping
(
value
=
"update/pay"
,
method
=
RequestMethod
.
PUT
)
@ResponseBody
public
ResultModel
updatePay
(
@CurrentAccount
User
loginAccount
,
@RequestBody
ContractMoney
contract
,
HttpServletRequest
request
)
{
public
ResultModel
updatePay
(
@CurrentAccount
User
loginAccount
,
@RequestBody
ContractMoney
contract
,
HttpServletRequest
request
,
@PathVariable
String
platform
)
{
Contract
contract1
=
service
.
updatePay
(
loginAccount
,
contract
);
NewUserLogThread
userlog
=
new
NewUserLogThread
(
loginAccount
.
getEmail
(),
loginAccount
.
getName
(),
OperateObjectTypeEnum
.
CUSTOMER
.
getKey
(),
contract1
.
getContractCode
(),
"修改收款开票"
,
""
,
service
.
updatePay
(
loginAccount
,
contract
).
toString
(),
request
);
NewUserLogThread
userlog
=
new
NewUserLogThread
(
loginAccount
.
getEmail
(),
loginAccount
.
getName
(),
OperateObjectTypeEnum
.
CUSTOMER
.
getKey
(),
contract1
.
getContractCode
(),
"修改收款开票"
,
""
,
service
.
updatePay
(
loginAccount
,
contract
).
toString
(),
request
,
platform
);
userlog
.
start
();
return
ResultModel
.
OK
(
contract1
);
}
...
...
src/main/java/common/model/UserLog.java
View file @
0e91d6b6
...
...
@@ -24,6 +24,7 @@ public class UserLog
private
String
OldObject
;
private
String
newObject
;
private
Long
role
;
private
String
platfrom
;
@Id
@GeneratedValue
...
...
@@ -141,6 +142,14 @@ public class UserLog
this
.
role
=
role
;
}
public
String
getPlatfrom
()
{
return
platfrom
;
}
public
void
setPlatfrom
(
String
platfrom
)
{
this
.
platfrom
=
platfrom
;
}
@Override
public
String
toString
()
{
return
"UserLog{"
+
...
...
src/main/java/common/service/ContractService.java
View file @
0e91d6b6
...
...
@@ -19,7 +19,7 @@ public interface ContractService {
String
getContractCode
(
String
code
);
List
findSetmeal
();
List
findSetmeal
(
String
platform
);
//增值服务
List
<
ContractIncrement
>
findIncrement
();
...
...
src/main/java/common/service/impl/ContractServiceImpl.java
View file @
0e91d6b6
package
common
.
service
.
impl
;
import
adi.dic.PackageEnum
;
import
adi.model.ADIUser
;
import
adi.service.ADIAccountService
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.google.api.ads.adwords.lib.AdWordsProductFrameworkModule
;
import
common.model.*
;
import
common.repository.*
;
...
...
@@ -9,6 +13,8 @@ import dic.ContractStatusEnum;
import
dic.ContractTypeEnum
;
import
dic.RoleEnum
;
import
dic.RoleTypeEnum
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
tkio.model.Account
;
...
...
@@ -21,11 +27,15 @@ import tkio.service.AccountService;
import
tkio.service.TkioAccountService
;
import
userio.service.AccountIOService
;
import
userio.service.IOAccountService
;
import
util.DateUtil
;
import
util.ResultModel
;
import
util.ResultStatus
;
import
util.ValidateUtil
;
import
util.*
;
import
java.beans.BeanInfo
;
import
java.beans.IntrospectionException
;
import
java.beans.Introspector
;
import
java.beans.PropertyDescriptor
;
import
java.io.IOException
;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.Method
;
import
java.math.BigDecimal
;
import
java.math.BigInteger
;
import
java.util.*
;
...
...
@@ -70,23 +80,33 @@ public class ContractServiceImpl implements ContractService{
UserService
userService
;
@Autowired
IncrementFlowRepository
incrementFlowRepository
;
@Autowired
ADIAccountService
adiAccountService
;
@Override
public
Map
<
String
,
Object
>
checkAccount
(
String
email
,
String
platfrom
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
Account4Web
account4Web
=
null
;
IOAccount4Web
ioAccount4Web
=
null
;
ADIUser
adiUser
=
null
;
if
(
"tkio"
.
equals
(
platfrom
)){
account4Web
=
account4WebRepository
.
findByEmail
(
email
);
}
else
if
(
"io"
.
equals
(
platfrom
)){
ioAccount4Web
=
ioAccount4WebRepository
.
findByEmail
(
email
);
}
else
if
(
"adi"
.
equals
(
platfrom
)){
adiUser
=
adiAccountService
.
findOne
(
email
);
}
if
(
null
==
account4Web
&&
null
==
ioAccount4Web
){
if
(
null
==
account4Web
&&
null
==
ioAccount4Web
&&
null
==
adiUser
){
map
.
put
(
"result"
,
0
);
}
else
{
BigInteger
integer
=
contractRepository
.
countNumByEmail
(
email
,
platfrom
);
map
.
put
(
"result"
,
1
);
map
.
put
(
"company"
,
null
==
account4Web
?
ioAccount4Web
.
getCompany
()
:
account4Web
.
getCompany
());
if
(
platfrom
.
equals
(
"adi"
)){
map
.
put
(
"company"
,
adiUser
.
getCompany
());
}
else
{
map
.
put
(
"company"
,
null
==
account4Web
?
ioAccount4Web
.
getCompany
()
:
account4Web
.
getCompany
());
}
map
.
put
(
"num"
,
integer
.
intValue
());
Contract
contract
=
contractRepository
.
findByPlatformAndEmailLimitVaild
(
platfrom
,
email
);
if
(
null
==
contract
){
...
...
@@ -147,16 +167,30 @@ public class ContractServiceImpl implements ContractService{
}
@Override
public
List
findSetmeal
()
{
public
List
findSetmeal
(
String
platform
)
{
List
list
=
new
ArrayList
();
List
<
PackageType
>
packageTypeList
=
packageTypeRepository
.
findAll
();
for
(
PackageType
p
:
packageTypeList
){
p
.
setType
(
"main"
);
list
.
add
(
p
);
if
(
"adi"
.
equals
(
platform
)){
for
(
int
i
=
1
;
i
<
3
;
i
++)
{
Map
<
String
,
String
>
packageMap
=
new
HashMap
<>();
packageMap
.
put
(
"id"
,
i
+
""
);
if
(
i
==
1
){
packageMap
.
put
(
"packageName"
,
PackageEnum
.
PROBATION
.
getValue
());
}
else
{
packageMap
.
put
(
"packageName"
,
PackageEnum
.
FORMAL
.
getValue
());
}
list
.
add
(
packageMap
);
}
}
else
{
List
<
PackageType
>
packageTypeList
=
packageTypeRepository
.
findAll
();
for
(
PackageType
p
:
packageTypeList
){
p
.
setType
(
"main"
);
list
.
add
(
p
);
}
List
<
ContractIncrement
>
increments
=
contractIncrementRepository
.
findAll
();
list
.
addAll
(
increments
);
}
List
<
ContractIncrement
>
increments
=
contractIncrementRepository
.
findAll
();
list
.
addAll
(
increments
);
return
list
;
}
...
...
@@ -236,7 +270,13 @@ public class ContractServiceImpl implements ContractService{
resource
.
setDs
(
DateUtil
.
getBeforeDays
(
0
));
resource
.
setStatus
(
"wait"
);
}
Double
rebat
=
getRebat
(
resource
.
getProduct
(),
resource
.
getPriceLevel
().
intValue
(),
resource
.
getMoney
());
Double
rebat
=
null
;
if
(
null
!=
resource
.
getPriceLevel
()){
rebat
=
getRebat
(
resource
.
getProduct
(),
resource
.
getPriceLevel
().
intValue
(),
resource
.
getMoney
());
}
else
{
rebat
=
getRebat
(
resource
.
getProduct
(),
0
,
resource
.
getMoney
());
}
BigDecimal
bg
=
new
BigDecimal
(
rebat
);
double
f1
=
bg
.
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
).
doubleValue
();
resource
.
setRebate
(
f1
);
...
...
@@ -253,6 +293,9 @@ public class ContractServiceImpl implements ContractService{
if
(
resource
.
getPlatform
().
equals
(
"io"
)
&&
resource
.
getType
().
equals
(
"main"
)){
accountIOService
.
update
(
resource
);
}
if
(
resource
.
getPlatform
().
equals
(
"adi"
)){
adiAccountService
.
updateAccount
(
resource
);
}
if
(
resource
.
getType
().
equals
(
ContractTypeEnum
.
MAIN
.
getKey
())
||
(
resource
.
getType
().
equals
(
ContractTypeEnum
.
INCREMENT
.
getKey
())
&&
resource
.
getPriceLevel
().
equals
(
1L
))){
...
...
@@ -309,7 +352,7 @@ public class ContractServiceImpl implements ContractService{
}
boolean
newRebat
=
false
;
if
(
contract
.
getType
().
equals
(
ContractTypeEnum
.
MAIN
.
getKey
())){
if
(
contract
.
getType
().
equals
(
ContractTypeEnum
.
MAIN
.
getKey
())
&&
null
!=
resource
.
getPriceLevel
()
){
if
(!
resource
.
getPriceLevel
().
equals
(
contract
.
getPriceLevel
())){
cc
.
setContent
(
cc
.
getContent
()
+
" 套餐变更:"
+
packageMap
.
get
(
contract
.
getPriceLevel
())
+
"-->"
+
packageMap
.
get
(
resource
.
getPriceLevel
()));
newRebat
=
true
;
...
...
@@ -344,6 +387,9 @@ public class ContractServiceImpl implements ContractService{
if
(
contract
.
getPlatform
().
equals
(
"io"
)
&&
resource
.
getType
().
equals
(
"main"
)){
accountIOService
.
update
(
contract
);
}
if
(
contract
.
getPlatform
().
equals
(
"adi"
)){
adiAccountService
.
updateAccount
(
contract
);
}
if
(
contract
.
getPlatform
().
equals
(
"tkio"
)){
if
(
contract
.
getPlatform
().
equals
(
"tkio"
))
{
...
...
@@ -673,4 +719,32 @@ public class ContractServiceImpl implements ContractService{
}
return
saleMap
;
}
public
static
Map
<
String
,
String
>
convertBean
(
Object
bean
)
throws
IntrospectionException
,
IllegalArgumentException
,
IllegalAccessException
,
InvocationTargetException
{
Class
type
=
bean
.
getClass
();
Map
<
String
,
String
>
returnMap
=
new
HashMap
<
String
,
String
>();
BeanInfo
beanInfo
=
Introspector
.
getBeanInfo
(
type
);
PropertyDescriptor
[]
propertyDescriptors
=
beanInfo
.
getPropertyDescriptors
();
for
(
int
i
=
0
;
i
<
propertyDescriptors
.
length
;
i
++)
{
PropertyDescriptor
descriptor
=
propertyDescriptors
[
i
];
String
propertyName
=
descriptor
.
getName
();
if
(!
propertyName
.
equals
(
"class"
))
{
Method
readMethod
=
descriptor
.
getReadMethod
();
Object
invoke
=
readMethod
.
invoke
(
bean
,
new
Object
[
0
]);
String
result
=
(
null
==
invoke
?
null
:
invoke
.
toString
());
if
(
result
!=
null
)
{
returnMap
.
put
(
propertyName
,
result
);
}
else
{
returnMap
.
put
(
propertyName
,
null
);
}
}
}
return
returnMap
;
}
}
src/main/java/security/interceptor/AuthorizationInterceptor.java
View file @
0e91d6b6
...
...
@@ -47,13 +47,23 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter {
public
boolean
preHandle
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
)
{
//放开登录
if
(
request
.
getRequestURL
().
indexOf
(
"login/login"
)
!=
-
1
||
request
.
getRequestURL
().
indexOf
(
"update/pwd"
)
!=
-
1
||
request
.
getRequestURL
().
indexOf
(
"user/forget"
)
!=
-
1
||
request
.
getRequestURL
().
indexOf
(
"user/code"
)
!=
-
1
||
request
.
getRequestURL
().
indexOf
(
"contract/build"
)
!=
-
1
){
String
requestURL
=
request
.
getRequestURL
().
toString
();
if
(
requestURL
.
contains
(
"findSaleInfo"
)){
System
.
out
.
println
(
"-----"
+
requestURL
.
contains
(
"findSaleInfo"
));
return
true
;
}
System
.
out
.
println
(
"============="
+
requestURL
);
System
.
out
.
println
(
requestURL
.
indexOf
(
"accountmng/findSaleInfo"
));
if
(
requestURL
.
indexOf
(
"login/login"
)
!=
-
1
||
requestURL
.
indexOf
(
"update/pwd"
)
!=
-
1
||
requestURL
.
indexOf
(
"user/forget"
)
!=
-
1
||
requestURL
.
indexOf
(
"user/code"
)
!=
-
1
||
requestURL
.
indexOf
(
"contract/build"
)
!=
-
1
||
requestURL
.
indexOf
(
"accountmng/findSaleInfo"
)
!=
-
1
){
return
true
;
}
//从header中得到token
String
token
=
request
.
getHeader
(
httpHeaderName
);
//token = StringUtil.isEmpty(token) ? getCookieToken(request.getCookies(), "TOKEN") : token;
...
...
src/main/java/util/HttpClientUtil.java
View file @
0e91d6b6
...
...
@@ -9,9 +9,7 @@ import org.apache.commons.httpclient.params.HttpMethodParams;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.*
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
...
...
@@ -289,13 +287,56 @@ public class HttpClientUtil {
return
result
;
}
public
static
String
doHttpPostRequest
(
String
url
,
String
ip
,
Map
<
String
,
String
>
params
,
String
cookie
)
{
long
start
=
System
.
currentTimeMillis
();
// public static String doHttpPostRequest(String url, String ip, Map<String, String> params, String cookie) {
// long start = System.currentTimeMillis();
// HttpClient httpClient = new HttpClient(httpConnectionManager);
// httpClient.getHttpConnectionManager().getParams()
// .setConnectionTimeout(300000);
// httpClient.getHttpConnectionManager().getParams().setSoTimeout(300000);
// resetRequestHeader(httpClient, ip, cookie);
// PostMethod method = new PostMethod(url);
// List<NameValuePair> list = new ArrayList<NameValuePair>();
//
// for (String key : params.keySet()) {
// NameValuePair pair = new NameValuePair(key, params.get(key));
// list.add(pair);
// }
// method.setRequestBody(list.toArray(new NameValuePair[list.size()]));
// String response = null;
// try {
// int status = httpClient.executeMethod(method);
// response = method.getResponseBodyAsString();
// } catch (IOException e) {
// log.error("执行HTTP Post请求" + url + "时,发生异常!", e);
// } finally {
// method.releaseConnection();
// }
// long end = System.currentTimeMillis();
// log.debug("---------------http's time to get data from report-------------------");
// log.debug(start-end + "ms");
// log.debug("---------------------------------------------------------------------");
// return response;
// }
public
static
String
doHttpPostRequest
(
String
url
,
String
ip
,
Map
<
String
,
String
>
params
,
String
code
)
{
return
doHttpPostRequest
(
url
,
ip
,
params
,
"ISO-8859-1"
,
code
);
}
/**
* Http post请求,获取结果.
*
* @param url
* @param ip
* @return
*/
public
static
String
doHttpPostRequest
(
String
url
,
String
ip
,
Map
<
String
,
String
>
params
,
String
readCharsetName
,
String
writeCharsetName
)
{
HttpClient
httpClient
=
new
HttpClient
(
httpConnectionManager
);
httpClient
.
getHttpConnectionManager
().
getParams
()
.
setConnectionTimeout
(
300000
);
httpClient
.
getHttpConnectionManager
().
getParams
().
setSoTimeout
(
300000
);
resetRequestHeader
(
httpClient
,
ip
,
cookie
);
resetRequestHeader
(
httpClient
,
ip
);
PostMethod
method
=
new
PostMethod
(
url
);
List
<
NameValuePair
>
list
=
new
ArrayList
<
NameValuePair
>();
...
...
@@ -303,20 +344,48 @@ public class HttpClientUtil {
NameValuePair
pair
=
new
NameValuePair
(
key
,
params
.
get
(
key
));
list
.
add
(
pair
);
}
method
.
setRequestBody
(
list
.
toArray
(
new
NameValuePair
[
list
.
size
()]));
NameValuePair
[]
body
=
new
NameValuePair
[
list
.
size
()];
body
=
list
.
toArray
(
body
);
method
.
setRequestBody
(
body
);
return
executeMethod
(
httpClient
,
method
,
readCharsetName
,
writeCharsetName
);
}
private
static
String
executeMethod
(
HttpClient
httpClient
,
HttpMethod
method
,
String
readCharsetName
,
String
writeCharsetName
)
{
String
response
=
null
;
try
{
int
status
=
httpClient
.
executeMethod
(
method
);
response
=
method
.
getResponseBodyAsString
();
}
catch
(
IOException
e
)
{
log
.
error
(
"执行HTTP Post请求"
+
url
+
"时,发生异常!"
,
e
);
}
finally
{
httpClient
.
executeMethod
(
method
);
}
catch
(
IOException
e
)
{
// try {
// logger.error("执行HTTP请求" + method.getURI().toString() + "时,发生异常!", e);
// }
// catch (URIException e1) {
// logger.error("URIException", e1);
// }
}
finally
{
if
(
method
.
getStatusCode
()
==
HttpStatus
.
SC_OK
)
{
StringBuffer
stringBuffer
=
new
StringBuffer
();
try
{
BufferedReader
reader
=
new
BufferedReader
(
new
InputStreamReader
(
method
.
getResponseBodyAsStream
(),
readCharsetName
));
String
str
=
""
;
while
((
str
=
reader
.
readLine
())
!=
null
)
{
stringBuffer
.
append
(
new
String
(
str
.
getBytes
(
readCharsetName
),
writeCharsetName
));
}
}
catch
(
IOException
e
)
{
// try {
// //logger.error("执行HTTP响应结果" + method.getURI().toString() + "时,发生异常!", e);
// }
// catch (URIException e1) {
// //logger.error("URIException", e1);
// }
}
response
=
stringBuffer
.
toString
();
}
method
.
releaseConnection
();
}
long
end
=
System
.
currentTimeMillis
();
log
.
debug
(
"---------------http's time to get data from report-------------------"
);
log
.
debug
(
start
-
end
+
"ms"
);
log
.
debug
(
"---------------------------------------------------------------------"
);
return
response
;
}
}
src/main/java/util/NewUserLogThread.java
View file @
0e91d6b6
...
...
@@ -38,13 +38,14 @@ public class NewUserLogThread
private
String
newObject
;
//为了获取ip及解析地点
private
HttpServletRequest
request
;
private
String
platform
;
/**
* 传入内容为对象
* UserLogThread userlog = new UserLogThread("zxy@reyun.com", "zxy", OperateObjectTypeEnum.CUSTOMER.getKey(), "app", "查看app", request);
* userlog.start();
*/
public
NewUserLogThread
(
String
operaAccount
,
String
accountName
,
String
operateObjectType
,
String
operateObject
,
String
operateType
,
String
oldObject
,
String
newObject
,
HttpServletRequest
request
)
{
public
NewUserLogThread
(
String
operaAccount
,
String
accountName
,
String
operateObjectType
,
String
operateObject
,
String
operateType
,
String
oldObject
,
String
newObject
,
HttpServletRequest
request
,
String
platform
)
{
this
.
operaAccount
=
operaAccount
;
this
.
accountName
=
accountName
;
this
.
operateObjectType
=
operateObjectType
;
...
...
@@ -70,6 +71,7 @@ public class NewUserLogThread
audit
.
setOperateType
(
this
.
operateType
);
audit
.
setOldObject
(
this
.
oldObject
);
audit
.
setNewObject
(
this
.
newObject
);
audit
.
setPlatfrom
(
this
.
platform
);
User
user
=
userRepository
.
findByEmail
(
this
.
operaAccount
);
audit
.
setRole
(
user
.
getRole
());
...
...
src/main/java/util/UserLogThread.java
View file @
0e91d6b6
...
...
@@ -34,6 +34,8 @@ public class UserLogThread
private
Long
role
;
private
String
platfrom
;
/**
* 传入内容为对象
* UserLogThread userlog = new UserLogThread("zxy@reyun.com", "zxy", OperateObjectTypeEnum.CUSTOMER.getKey(), "app", "查看app", request);
...
...
src/main/resources/rest-servlet.xml
View file @
0e91d6b6
...
...
@@ -11,6 +11,7 @@
<context:component-scan
base-package=
"track.controller"
/>
<context:component-scan
base-package=
"tkio.controller"
/>
<context:component-scan
base-package=
"userio.controller"
/>
<context:component-scan
base-package=
"adi.controller"
/>
<mvc:annotation-driven>
<mvc:argument-resolvers>
...
...
src/main/resources/spring/applicationContext.xml
View file @
0e91d6b6
...
...
@@ -23,6 +23,7 @@
<context:component-scan
base-package=
"office"
/>
<context:component-scan
base-package=
"dmp"
/>
<context:component-scan
base-package=
"security"
/>
<context:component-scan
base-package=
"adi"
/>
<context:property-placeholder
location=
"classpath:persistence.properties,classpath:redis.properties"
/>
...
...
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