Commit 87ce018e by zzrdark

1.fix

parent acead85a
...@@ -12,4 +12,3 @@ eureka: ...@@ -12,4 +12,3 @@ eureka:
defaultZone: http://127.0.0.1:8761/eureka/ defaultZone: http://127.0.0.1:8761/eureka/
instance: instance:
prefer-ip-address: true prefer-ip-address: true
ip-address: 192.168.2.244
\ No newline at end of file
spring: spring:
profiles: profiles:
active: dev active: prod
application: application:
name: cneeds-server-authorization name: cneeds-server-authorization
server: server:
......
...@@ -32,6 +32,11 @@ ...@@ -32,6 +32,11 @@
<artifactId>cneeds-common-pojo</artifactId> <artifactId>cneeds-common-pojo</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency>
<groupId>com.mx.cneeds</groupId>
<artifactId>cneeds-common-hadoop-dfs</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<!-- for Spring Security --> <!-- for Spring Security -->
<dependency> <dependency>
......
package com.mx.cneeds.common.constant;
/**
* @ClassName FilePath
* @Author zzrdark
* @Date 2020-04-22 14:29
* @Description TODO
**/
public class FilePath {
public static String LogFilePath = "/cneedsFile/LogFilePath/";
public static String wechatFilePath = "/cneedsFile/wechatPath/";
}
...@@ -21,6 +21,8 @@ public class OAuth2ResourceServer extends ResourceServerConfigurerAdapter { ...@@ -21,6 +21,8 @@ public class OAuth2ResourceServer extends ResourceServerConfigurerAdapter {
http.authorizeRequests() http.authorizeRequests()
.antMatchers("/user/login", .antMatchers("/user/login",
"/device/device/getChannel_nums", "/device/device/getChannel_nums",
"/wechat/wechatFileUpload",
"/wechat/wechatDownload/**",
// "/user/info", // "/user/info",
"/statics/**") "/statics/**")
.permitAll() .permitAll()
......
package com.mx.cneeds.server.datashow.web.device; package com.mx.cneeds.server.datashow.web.device;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.mx.cneeds.common.constant.FilePath;
import com.mx.cneeds.common.converter.RequestParamterConverter; import com.mx.cneeds.common.converter.RequestParamterConverter;
import com.mx.cneeds.common.dto.*; import com.mx.cneeds.common.dto.*;
import com.mx.cneeds.common.result.R; import com.mx.cneeds.common.result.R;
...@@ -8,6 +9,7 @@ import com.mx.cneeds.common.vo.DeviceLogFileVo; ...@@ -8,6 +9,7 @@ import com.mx.cneeds.common.vo.DeviceLogFileVo;
import com.mx.cneeds.common.vo.WechatDeviceLogVo; import com.mx.cneeds.common.vo.WechatDeviceLogVo;
import com.mx.cneeds.server.datashow.client.DeviceClient; import com.mx.cneeds.server.datashow.client.DeviceClient;
import com.mx.cneeds.server.datashow.client.LogFileClient; import com.mx.cneeds.server.datashow.client.LogFileClient;
import com.mx.hbasefile.hadoop.hdfs.api.HdfsTemplate;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
...@@ -22,10 +24,8 @@ import org.springframework.web.multipart.MultipartFile; ...@@ -22,10 +24,8 @@ import org.springframework.web.multipart.MultipartFile;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.text.SimpleDateFormat;
import java.util.HashSet; import java.util.*;
import java.util.List;
import java.util.Set;
/** /**
* @ClassName LogFileController * @ClassName LogFileController
...@@ -44,6 +44,9 @@ public class LogFlieController { ...@@ -44,6 +44,9 @@ public class LogFlieController {
@Autowired @Autowired
private DeviceClient deviceClient; private DeviceClient deviceClient;
@Autowired
private HdfsTemplate hdfsTemplate;
@PostMapping("/logfile/wechatDeviceLogUpload") @PostMapping("/logfile/wechatDeviceLogUpload")
public R wechatUploadLog(WechatDeviceLogVo vo, MultipartFile[] file){ public R wechatUploadLog(WechatDeviceLogVo vo, MultipartFile[] file){
WechatDeviceLogDto dto = new WechatDeviceLogDto(); WechatDeviceLogDto dto = new WechatDeviceLogDto();
...@@ -51,6 +54,7 @@ public class LogFlieController { ...@@ -51,6 +54,7 @@ public class LogFlieController {
// 把图片存入oos 返回路径 // 把图片存入oos 返回路径
// dto.setLogfileUrl() // dto.setLogfileUrl()
DeviceInfoDto deviceInfoDto = deviceClient.queryDeviceByImei(dto.getImei()); DeviceInfoDto deviceInfoDto = deviceClient.queryDeviceByImei(dto.getImei());
dto.setDeviceId(deviceInfoDto.getDeviceId()); dto.setDeviceId(deviceInfoDto.getDeviceId());
logFileClient.wechatUploadLog(dto); logFileClient.wechatUploadLog(dto);
...@@ -64,6 +68,18 @@ public class LogFlieController { ...@@ -64,6 +68,18 @@ public class LogFlieController {
// 把图片存入oos 返回路径 // 把图片存入oos 返回路径
// dto.setLogfileUrl() // dto.setLogfileUrl()
StringBuffer dir = new StringBuffer(FilePath.LogFilePath);
// 1. 读取系统时间
Calendar calendar = Calendar.getInstance();
Date time = calendar.getTime();
// 2. 格式化系统时间
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
String fileName = format.format(time);
dir.append(fileName);
hdfsTemplate.saveFile(dir.toString(),file.getName(),file.getInputStream(),file.getSize(), (short) 2);
DeviceInfoDto deviceInfoDto = deviceClient.queryDeviceByImei(dto.getImei()); DeviceInfoDto deviceInfoDto = deviceClient.queryDeviceByImei(dto.getImei());
dto.setDeviceId(deviceInfoDto.getDeviceId()); dto.setDeviceId(deviceInfoDto.getDeviceId());
logFileClient.uploadLogFile(dto); logFileClient.uploadLogFile(dto);
......
package com.mx.cneeds.server.datashow.web.wechat;
import com.mx.cneeds.common.constant.FilePath;
import com.mx.cneeds.common.result.R;
import com.mx.hbasefile.hadoop.hdfs.api.HdfsTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
/**
* @ClassName WechatController
* @Author zzrdark
* @Date 2020-04-22 16:29
* @Description TODO
**/
@Controller
@RequestMapping("/wechat")
public class WechatController {
@Autowired
private HdfsTemplate hdfsTemplate;
@RequestMapping("/wechatFileUpload")
@ResponseBody
public R upload(HttpServletRequest httpServletRequest, MultipartFile file) throws IOException {
StringBuffer dir = new StringBuffer(FilePath.wechatFilePath);
// 1. 读取系统时间
Calendar calendar = Calendar.getInstance();
Date time = calendar.getTime();
// 2. 格式化系统时间
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
String fileName = format.format(time);
dir.append(fileName);
hdfsTemplate.saveFile(dir.toString(),file.getOriginalFilename(),file.getInputStream(),file.getSize(), (short) 2);
String sufUrl = httpServletRequest.getScheme() +"://" +
httpServletRequest.getServerName() + ":" +
httpServletRequest.getServerPort()+
"/wechat/wechatDownload/"+fileName+"/"
+file.getOriginalFilename();
return R.ok().put("data",sufUrl);
}
@RequestMapping("/wechatDownload/{dir}/{fileName}")
public void download(@PathVariable("dir") String dir, @PathVariable("fileName") String fileName,
HttpServletResponse response) throws IOException {
StringBuffer dirPath = new StringBuffer(FilePath.wechatFilePath);
dirPath.append(dir);
InputStream inputStream = hdfsTemplate.openFile(dirPath.toString(), fileName);
ServletOutputStream outputStream = response.getOutputStream();
String mediaType = fileName.substring(fileName.indexOf("."));
response.setContentType(mediaType);
response.addHeader("Content-Disposition", "attachment; filename" + "testfilename");
byte[] bytes = new byte[1024];
int i = 0;
while ((i = inputStream.read(bytes)) != -1) {
outputStream.write(bytes,0, i);
outputStream.flush();
}
outputStream.close();
}
}
...@@ -6,3 +6,15 @@ eureka: ...@@ -6,3 +6,15 @@ eureka:
prefer-ip-address: true prefer-ip-address: true
spring:
hadoop:
hdfs:
hadoopConfigDir: D:\hadoop2.6_Win_x64\etc\hadoop
# hadoopConfigDir: /home/fengte/hadoop/etc/hadoop/
hdfsUrl: hdfs://192.168.2.244:9100
defaultBlockSize: 128000000
bufferSize: 512000
servlet:
multipart:
max-file-size: 100000MB
max-request-size: 100000MB
\ No newline at end of file
eureka: eureka:
client: client:
service-url: service-url:
defaultZone: http://192.168.2.244:8761/eureka/ defaultZone: http://localhost:8761/eureka/
instance: instance:
prefer-ip-address: true prefer-ip-address: true
ip-address: 192.168.2.244
spring:
hadoop:
hdfs:
hadoopConfigDir: /root/hadoop-2.7.1/etc/hadoop/
hdfsUrl: hdfs://localhost:9100
defaultBlockSize: 128000000
bufferSize: 512000
servlet:
multipart:
max-file-size: 100000MB
max-request-size: 100000MB
\ No newline at end of file
spring: spring:
profiles: profiles:
active: dev active: prod
application: application:
name: cneeds-server-datashow name: cneeds-server-datashow
server: server:
port: 9000 port: 9000
servlet: servlet:
context-path: / context-path: /
\ No newline at end of file
spring: spring:
datasource: datasource:
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://192.168.2.244:3306/cneeds_server?useUnicode=true&characterEncoding=UTF-8&useSSL=false url: jdbc:mysql://localhost:3306/cneeds_server?useUnicode=true&characterEncoding=UTF-8&useSSL=false
password: cneeds!QAZ1qaz password: cneeds!QAZ1qaz
username: root username: root
...@@ -9,31 +9,6 @@ spring: ...@@ -9,31 +9,6 @@ spring:
eureka: eureka:
client: client:
service-url: service-url:
defaultZone: http://192.168.2.244:8761/eureka/ defaultZone: http://localhost:8761/eureka/
instance: instance:
prefer-ip-address: true prefer-ip-address: true
ip-address: 192.168.2.244
mybatis-plus:
mapper-locations: classpath:mapper/*.xml
#实体扫描,多个package用逗号或者分号分隔
typeAliasesPackage: com.mx.cneeds.server.entity
global-config:
#数据库相关配置
db-config:
#主键类型 AUTO:"数据库ID自增", INPUT:"用户输入ID", ID_WORKER:"全局唯一ID (数字类型唯一ID)", UUID:"全局唯一ID UUID";
id-type: AUTO
#字段策略 IGNORED:"忽略判断",NOT_NULL:"非 NULL 判断"),NOT_EMPTY:"非空判断"
field-strategy: NOT_NULL
#驼峰下划线转换
column-underline: true
logic-delete-value: -1
logic-not-delete-value: 0
banner: false
#原生配置
configuration:
map-underscore-to-camel-case: true
cache-enabled: false
call-setters-on-nulls: true
jdbc-type-for-null: 'null'
\ No newline at end of file
spring: spring:
profiles: profiles:
active: dev active: prod
application: application:
name: cneeds-server-eureka name: cneeds-server-eureka
server: server:
......
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/cneeds_server?useUnicode=true&characterEncoding=UTF-8&useSSL=false
password: cneeds!QAZ1qaz
username: root
eureka:
client:
service-url:
defaultZone: http://localhost:8761/eureka/
instance:
prefer-ip-address: true
spring: spring:
profiles: profiles:
active: dev active: prod
application: application:
name: cneeds-server-logupload name: cneeds-server-logupload
......
spring: spring:
datasource: datasource:
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://192.168.2.244:3306/cneeds_server?useUnicode=true&characterEncoding=UTF-8&useSSL=false url: jdbc:mysql://127.0.0.1:3306/cneeds_server?useUnicode=true&characterEncoding=UTF-8&useSSL=false
password: cneeds!QAZ1qaz password: cneeds!QAZ1qaz
username: root username: root
mqtt: mqtt:
...@@ -22,9 +22,8 @@ spring: ...@@ -22,9 +22,8 @@ spring:
eureka: eureka:
client: client:
service-url: service-url:
defaultZone: http://192.168.2.244:8761/eureka/ defaultZone: http://localhost:8761/eureka/
instance: instance:
prefer-ip-address: true prefer-ip-address: true
ip-address: 192.168.2.244
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