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

修改读取配置文件

parent 99309be3
......@@ -47,12 +47,12 @@
</properties>
</profile>
<profile>
<id>product</id>
<id>reg</id>
<properties>
<profiles.active>product</profiles.active>
<profiles.active>reg</profiles.active>
<profiles.filepath>/root</profiles.filepath>
<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.server.port>80</profiles.server.port>
<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 {
String getType = (String) reqMap.getOrDefault("GetType", "");
String reqJson = (String) reqMap.getOrDefault("PrinterJson", "");
String printerName = (String) reqMap.getOrDefault("printerName", "");
log.info("getType:" + getType);
log.info("req==>getType:{},body=>{}", getType, JSON.toJSONString(reqMap));
try {
switch (BusizTypeEnum.getByValue(getType)) {
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");
return assessResp;
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");
return rest;
case BUSIZ_PRINTLIST:
......
......@@ -91,6 +91,8 @@ public class CaptureThread implements Runnable {
Request.parser(value, request);
}
//校验uripath
log.info("uri:"+request.getRequestURI());
if (checkRequestUri(filterMap, request)) continue;
if (request.getContentType() == null) {
......@@ -193,8 +195,8 @@ public class CaptureThread implements Runnable {
private boolean checkHttpPacket(TcpPacket tcp) throws UnsupportedEncodingException {
String payLoad = new String(tcp.getPayload().getRawData(), "utf-8");
if (payLoad.indexOf("HTTP") == -1) return true;
// log.info("playLoad:"+payLoad);
// if (payLoad.indexOf("HTTP") == -1) return true;
//System.out.println("payLoad:"+payLoad);
return false;
}
......@@ -202,7 +204,7 @@ public class CaptureThread implements Runnable {
private boolean checkTcpPacket(Map<String, Set<String>> filterMap, TcpPacket tcp) {
String dstPort = tcp.getHeader().getDstPort().valueAsString();
// log.info("destPort before:"+dstPort);
//log.info("destPort before:"+dstPort);
if (!filterMap.get("SendServerPort").contains(dstPort)) {
return true;
}
......@@ -210,7 +212,7 @@ public class CaptureThread implements Runnable {
if (tcp.getPayload() == null) {
return true;
}
log.info("destPort:" + dstPort);
//log.info("destPort:" + dstPort);
return false;
}
......@@ -221,6 +223,7 @@ public class CaptureThread implements Runnable {
return true;
}
String dest = ipV4Packet.getHeader().getDstAddr().getHostAddress();
// log.info("dest:"+dest);
if (!filterMap.get("SendServerIp").contains(dest)) {
return true;
}
......
......@@ -11,6 +11,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import java.util.ArrayList;
import java.util.List;
......@@ -33,8 +34,9 @@ public class CaptureServiceImpl implements CaptureService {
@Override
public Rest<List<File>> getCapture() {
url=url+"&watiTime="+timeout;
String resp = HttpUtil.get(url, timeout);
url = url + "&watiTime=" + timeout;
String resp = HttpUtil.get(url, timeout * 1000);
if (ObjectUtils.isEmpty(resp)) {
Rest<List<File>> rest = JSON.parseObject(resp, new TypeReference<Rest<List<File>>>() {
});
if (rest.getCode() == YesNoEnum.YES.getValue()) {
......@@ -43,5 +45,10 @@ public class CaptureServiceImpl implements CaptureService {
} else {
return Rest.fail();
}
} else {
log.info("获取拍照失败!resp:{}", resp);
return Rest.fail();
}
}
}
......@@ -24,4 +24,10 @@
<SendServerPath>dothingsui/affair/getHcpSin</SendServerPath>
</Capture>
<Capture>
<SendServerIp>59.225.209.96</SendServerIp>
<SendServerPort>443</SendServerPort>
<SendServerPath>bl/api/approval/externalsys/hcp/evaluation</SendServerPath>
</Capture>
</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