Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mid-service
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
mid-service
Commits
0edbad7c
Commit
0edbad7c
authored
Mar 11, 2024
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改读取配置文件
parent
99309be3
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
108 additions
and
17 deletions
+108
-17
pom.xml
pom.xml
+3
-3
src/main/java/com/mortals/xhx/base/framework/config/CorsConfig.java
...ava/com/mortals/xhx/base/framework/config/CorsConfig.java
+48
-0
src/main/java/com/mortals/xhx/base/framework/config/CrossInterceptor.java
...m/mortals/xhx/base/framework/config/CrossInterceptor.java
+27
-0
src/main/java/com/mortals/xhx/busiz/web/ApiController.java
src/main/java/com/mortals/xhx/busiz/web/ApiController.java
+3
-3
src/main/java/com/mortals/xhx/daemon/applicationservice/CaptureThread.java
.../mortals/xhx/daemon/applicationservice/CaptureThread.java
+7
-4
src/main/java/com/mortals/xhx/module/capture/service/impl/CaptureServiceImpl.java
...s/xhx/module/capture/service/impl/CaptureServiceImpl.java
+14
-7
src/main/resources/capture.xml
src/main/resources/capture.xml
+6
-0
No files found.
pom.xml
View file @
0edbad7c
...
@@ -47,12 +47,12 @@
...
@@ -47,12 +47,12 @@
</properties>
</properties>
</profile>
</profile>
<profile>
<profile>
<id>
product
</id>
<id>
reg
</id>
<properties>
<properties>
<profiles.active>
product
</profiles.active>
<profiles.active>
reg
</profiles.active>
<profiles.filepath>
/root
</profiles.filepath>
<profiles.filepath>
/root
</profiles.filepath>
<profiles.log.level>
INFO
</profiles.log.level>
<profiles.log.level>
INFO
</profiles.log.level>
<profiles.log.path>
/
root/mid-service
/logs
</profiles.log.path>
<profiles.log.path>
/
mortals/app
/logs
</profiles.log.path>
<profiles.config.path>
/root/mid.prop
</profiles.config.path>
<profiles.config.path>
/root/mid.prop
</profiles.config.path>
<profiles.server.port>
80
</profiles.server.port>
<profiles.server.port>
80
</profiles.server.port>
<profiles.hcpUrl>
http://10.207.153.67:8090/inter/hcpapi/hcpGrabEvaluate
</profiles.hcpUrl>
<profiles.hcpUrl>
http://10.207.153.67:8090/inter/hcpapi/hcpGrabEvaluate
</profiles.hcpUrl>
...
...
src/main/java/com/mortals/xhx/base/framework/config/CorsConfig.java
0 → 100644
View file @
0edbad7c
package
com.mortals.xhx.base.framework.config
;
import
com.alibaba.fastjson.parser.ParserConfig
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.cors.CorsConfiguration
;
import
org.springframework.web.cors.UrlBasedCorsConfigurationSource
;
import
org.springframework.web.filter.CorsFilter
;
import
org.springframework.web.servlet.config.annotation.CorsRegistry
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
;
/**
* @author: zxfei
* @date: 2022/2/15 13:16
* @description:
**/
@Configuration
public
class
CorsConfig
implements
WebMvcConfigurer
{
@Bean
public
CorsFilter
corsFilter
(){
//初始化配置对象
CorsConfiguration
configuration
=
new
CorsConfiguration
();
//允许跨域访问的域名
configuration
.
addAllowedOrigin
(
"*"
);
// configuration.setAllowCredentials(true); //运行携带cookie
configuration
.
addAllowedMethod
(
"*"
);
//代表所有请求方法
configuration
.
addAllowedHeader
(
"*"
);
//允许携带任何头信息
//初始化cors配置源对象
UrlBasedCorsConfigurationSource
configurationSource
=
new
UrlBasedCorsConfigurationSource
();
configurationSource
.
registerCorsConfiguration
(
"/**"
,
configuration
);
//返回CorSfilter实例,参数
return
new
CorsFilter
(
configurationSource
);
}
@Override
public
void
addCorsMappings
(
CorsRegistry
registry
)
{
registry
.
addMapping
(
"/**"
)
.
allowCredentials
(
true
)
.
allowedOrigins
(
"*"
)
.
allowedMethods
(
new
String
[]
{
"GET"
,
"POST"
,
"PUT"
,
"DELETE"
})
.
allowedHeaders
(
"*"
)
.
exposedHeaders
(
"*"
);
}
}
src/main/java/com/mortals/xhx/base/framework/config/CrossInterceptor.java
0 → 100644
View file @
0edbad7c
package
com.mortals.xhx.base.framework.config
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.servlet.handler.HandlerInterceptorAdapter
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
/**
* @author: zxfei
* @date: 2022/6/6 15:05
* @description:添加跨域响应
**/
@Component
public
class
CrossInterceptor
extends
HandlerInterceptorAdapter
{
@Override
public
boolean
preHandle
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
)
throws
Exception
{
response
.
setHeader
(
"Access-Control-Allow-Origin"
,
"*"
);
response
.
setHeader
(
"Access-Control-Allow-Methods"
,
"GET, POST, PUT, DELETE, OPTIONS"
);
response
.
setHeader
(
"Access-Control-Max-Age"
,
"3600"
);
response
.
setHeader
(
"Access-Control-Allow-Headers"
,
"*"
);
response
.
setHeader
(
"Access-Control-Allow-Credentials"
,
"true"
);
response
.
setHeader
(
"Content-Type"
,
"true"
);
return
true
;
}
}
src/main/java/com/mortals/xhx/busiz/web/ApiController.java
View file @
0edbad7c
...
@@ -44,15 +44,15 @@ public class ApiController extends BaseAbstractApiController {
...
@@ -44,15 +44,15 @@ public class ApiController extends BaseAbstractApiController {
String
getType
=
(
String
)
reqMap
.
getOrDefault
(
"GetType"
,
""
);
String
getType
=
(
String
)
reqMap
.
getOrDefault
(
"GetType"
,
""
);
String
reqJson
=
(
String
)
reqMap
.
getOrDefault
(
"PrinterJson"
,
""
);
String
reqJson
=
(
String
)
reqMap
.
getOrDefault
(
"PrinterJson"
,
""
);
String
printerName
=
(
String
)
reqMap
.
getOrDefault
(
"printerName"
,
""
);
String
printerName
=
(
String
)
reqMap
.
getOrDefault
(
"printerName"
,
""
);
log
.
info
(
"
getType:"
+
getType
);
log
.
info
(
"
req==>getType:{},body=>{}"
,
getType
,
JSON
.
toJSONString
(
reqMap
)
);
try
{
try
{
switch
(
BusizTypeEnum
.
getByValue
(
getType
))
{
switch
(
BusizTypeEnum
.
getByValue
(
getType
))
{
case
BUSIZ_ASSESSMENT:
case
BUSIZ_ASSESSMENT:
ApiResp
<
Object
>
assessResp
=
handle
(
JSON
.
parseObject
(
reqJson
,
new
TypeReference
<
PrintReq
>()
{
ApiResp
<
Object
>
assessResp
=
handle
(
JSON
.
parseObject
(
reqJson
,
new
TypeReference
<
Map
<
String
,
Object
>
>()
{
}),
"busizAssessmentReqHandler"
);
}),
"busizAssessmentReqHandler"
);
return
assessResp
;
return
assessResp
;
case
BUSIZ_PRINT:
case
BUSIZ_PRINT:
ApiResp
<
Object
>
rest
=
handle
(
JSON
.
parseObject
(
reqJson
,
new
TypeReference
<
PrintReq
>()
{
ApiResp
<
Object
>
rest
=
handle
(
JSON
.
parseObject
(
reqJson
,
new
TypeReference
<
Map
<
String
,
Object
>
>()
{
}),
"busizPrintReqHandler"
);
}),
"busizPrintReqHandler"
);
return
rest
;
return
rest
;
case
BUSIZ_PRINTLIST:
case
BUSIZ_PRINTLIST:
...
...
src/main/java/com/mortals/xhx/daemon/applicationservice/CaptureThread.java
View file @
0edbad7c
...
@@ -91,6 +91,8 @@ public class CaptureThread implements Runnable {
...
@@ -91,6 +91,8 @@ public class CaptureThread implements Runnable {
Request
.
parser
(
value
,
request
);
Request
.
parser
(
value
,
request
);
}
}
//校验uripath
//校验uripath
log
.
info
(
"uri:"
+
request
.
getRequestURI
());
if
(
checkRequestUri
(
filterMap
,
request
))
continue
;
if
(
checkRequestUri
(
filterMap
,
request
))
continue
;
if
(
request
.
getContentType
()
==
null
)
{
if
(
request
.
getContentType
()
==
null
)
{
...
@@ -193,8 +195,8 @@ public class CaptureThread implements Runnable {
...
@@ -193,8 +195,8 @@ public class CaptureThread implements Runnable {
private
boolean
checkHttpPacket
(
TcpPacket
tcp
)
throws
UnsupportedEncodingException
{
private
boolean
checkHttpPacket
(
TcpPacket
tcp
)
throws
UnsupportedEncodingException
{
String
payLoad
=
new
String
(
tcp
.
getPayload
().
getRawData
(),
"utf-8"
);
String
payLoad
=
new
String
(
tcp
.
getPayload
().
getRawData
(),
"utf-8"
);
// log.info("playLoad:"+payLoad);
if
(
payLoad
.
indexOf
(
"HTTP"
)
==
-
1
)
return
true
;
//
if (payLoad.indexOf("HTTP") == -1) return true;
//System.out.println("payLoad:"+payLoad);
//System.out.println("payLoad:"+payLoad);
return
false
;
return
false
;
}
}
...
@@ -202,7 +204,7 @@ public class CaptureThread implements Runnable {
...
@@ -202,7 +204,7 @@ public class CaptureThread implements Runnable {
private
boolean
checkTcpPacket
(
Map
<
String
,
Set
<
String
>>
filterMap
,
TcpPacket
tcp
)
{
private
boolean
checkTcpPacket
(
Map
<
String
,
Set
<
String
>>
filterMap
,
TcpPacket
tcp
)
{
String
dstPort
=
tcp
.
getHeader
().
getDstPort
().
valueAsString
();
String
dstPort
=
tcp
.
getHeader
().
getDstPort
().
valueAsString
();
//
log.info("destPort before:"+dstPort);
//log.info("destPort before:"+dstPort);
if
(!
filterMap
.
get
(
"SendServerPort"
).
contains
(
dstPort
))
{
if
(!
filterMap
.
get
(
"SendServerPort"
).
contains
(
dstPort
))
{
return
true
;
return
true
;
}
}
...
@@ -210,7 +212,7 @@ public class CaptureThread implements Runnable {
...
@@ -210,7 +212,7 @@ public class CaptureThread implements Runnable {
if
(
tcp
.
getPayload
()
==
null
)
{
if
(
tcp
.
getPayload
()
==
null
)
{
return
true
;
return
true
;
}
}
log
.
info
(
"destPort:"
+
dstPort
);
//
log.info("destPort:" + dstPort);
return
false
;
return
false
;
}
}
...
@@ -221,6 +223,7 @@ public class CaptureThread implements Runnable {
...
@@ -221,6 +223,7 @@ public class CaptureThread implements Runnable {
return
true
;
return
true
;
}
}
String
dest
=
ipV4Packet
.
getHeader
().
getDstAddr
().
getHostAddress
();
String
dest
=
ipV4Packet
.
getHeader
().
getDstAddr
().
getHostAddress
();
// log.info("dest:"+dest);
if
(!
filterMap
.
get
(
"SendServerIp"
).
contains
(
dest
))
{
if
(!
filterMap
.
get
(
"SendServerIp"
).
contains
(
dest
))
{
return
true
;
return
true
;
}
}
...
...
src/main/java/com/mortals/xhx/module/capture/service/impl/CaptureServiceImpl.java
View file @
0edbad7c
...
@@ -11,6 +11,7 @@ import lombok.extern.slf4j.Slf4j;
...
@@ -11,6 +11,7 @@ import lombok.extern.slf4j.Slf4j;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
...
@@ -33,8 +34,9 @@ public class CaptureServiceImpl implements CaptureService {
...
@@ -33,8 +34,9 @@ public class CaptureServiceImpl implements CaptureService {
@Override
@Override
public
Rest
<
List
<
File
>>
getCapture
()
{
public
Rest
<
List
<
File
>>
getCapture
()
{
url
=
url
+
"&watiTime="
+
timeout
;
url
=
url
+
"&watiTime="
+
timeout
;
String
resp
=
HttpUtil
.
get
(
url
,
timeout
);
String
resp
=
HttpUtil
.
get
(
url
,
timeout
*
1000
);
if
(
ObjectUtils
.
isEmpty
(
resp
))
{
Rest
<
List
<
File
>>
rest
=
JSON
.
parseObject
(
resp
,
new
TypeReference
<
Rest
<
List
<
File
>>>()
{
Rest
<
List
<
File
>>
rest
=
JSON
.
parseObject
(
resp
,
new
TypeReference
<
Rest
<
List
<
File
>>>()
{
});
});
if
(
rest
.
getCode
()
==
YesNoEnum
.
YES
.
getValue
())
{
if
(
rest
.
getCode
()
==
YesNoEnum
.
YES
.
getValue
())
{
...
@@ -43,5 +45,10 @@ public class CaptureServiceImpl implements CaptureService {
...
@@ -43,5 +45,10 @@ public class CaptureServiceImpl implements CaptureService {
}
else
{
}
else
{
return
Rest
.
fail
();
return
Rest
.
fail
();
}
}
}
else
{
log
.
info
(
"获取拍照失败!resp:{}"
,
resp
);
return
Rest
.
fail
();
}
}
}
}
}
src/main/resources/capture.xml
View file @
0edbad7c
...
@@ -24,4 +24,10 @@
...
@@ -24,4 +24,10 @@
<SendServerPath>
dothingsui/affair/getHcpSin
</SendServerPath>
<SendServerPath>
dothingsui/affair/getHcpSin
</SendServerPath>
</Capture>
</Capture>
<Capture>
<SendServerIp>
59.225.209.96
</SendServerIp>
<SendServerPort>
443
</SendServerPort>
<SendServerPath>
bl/api/approval/externalsys/hcp/evaluation
</SendServerPath>
</Capture>
</Captures>
</Captures>
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