Commit 0edbad7c authored by 赵啸非's avatar 赵啸非

修改读取配置文件

parent 99309be3
...@@ -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>
......
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("*");
}
}
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;
}
}
...@@ -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:
......
...@@ -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;
} }
......
...@@ -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,15 +34,21 @@ public class CaptureServiceImpl implements CaptureService { ...@@ -33,15 +34,21 @@ 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);
Rest<List<File>> rest = JSON.parseObject(resp, new TypeReference<Rest<List<File>>>() { if (ObjectUtils.isEmpty(resp)) {
}); Rest<List<File>> rest = JSON.parseObject(resp, new TypeReference<Rest<List<File>>>() {
if (rest.getCode() == YesNoEnum.YES.getValue()) { });
log.info("获取拍照成功!fileData:{}", rest.getData().size()); if (rest.getCode() == YesNoEnum.YES.getValue()) {
return rest; log.info("获取拍照成功!fileData:{}", rest.getData().size());
return rest;
} else {
return Rest.fail();
}
} else { } else {
log.info("获取拍照失败!resp:{}", resp);
return Rest.fail(); return Rest.fail();
} }
} }
} }
...@@ -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>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment