Commit 59759779 by 李辅翼

v3

parent d2d74cda
......@@ -18,6 +18,14 @@
<java.version>1.8</java.version>
</properties>
<repositories>
<repository>
<id>cloudera</id>
<url>https://repository.cloudera.com/artifactory/cloudera-repos/</url>
</repository>
</repositories>
<dependencies>
......@@ -82,6 +90,12 @@
<artifactId>fastdfs-client</artifactId>
<version>1.26.5</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
</dependencies>
<build>
......@@ -92,10 +106,5 @@
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>cloudera</id>
<url>https://repository.cloudera.com/artifactory/cloudera-repos/</url>
</repository>
</repositories>
</project>
......@@ -2,6 +2,7 @@ package com.hikcreate.controller;
import com.alibaba.fastjson.JSONObject;
import com.hikcreate.drv_photo_pic.DrvPhoto;
import com.hikcreate.service.fdfs.service.FileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
......@@ -10,8 +11,8 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.io.*;
/**
* @author lifuyi
......@@ -25,6 +26,9 @@ public class PicController {
@Autowired
private DrvPhoto drvPhoto;
@Autowired
private FileService fileService;
@GetMapping("/drvPhotoHis")
public void getHisDrvPhoto(@RequestParam("time") String time, HttpServletResponse response){
......@@ -40,4 +44,37 @@ public class PicController {
}
@GetMapping("/testFastDfs")
public void testFastDfs(@RequestParam("url") String url, HttpServletResponse response){
try {
File file=new File("C:\\Users\\lifuyi5\\Downloads\\2019-05-15");
FileInputStream fis = new FileInputStream(file);
ByteArrayOutputStream bos = new ByteArrayOutputStream(fis.available());
byte[] b = new byte[1024];
int len = -1;
while((len = fis.read(b)) != -1) {
bos.write(b, 0, len);
}
byte[] fileByte = bos.toByteArray();
String urlFast = fileService.uploadFile(fileByte, "2019-05-15");
response.setContentType("application/json;charset=UTF-8");
response.getWriter().write(urlFast);
} catch (Exception e) {
e.printStackTrace();
}
}
@GetMapping("/testUrl")
public void testUrl(@RequestParam("url") String url, HttpServletResponse response){
try {
System.out.println("dddddddddddddd");
response.setContentType("application/json;charset=UTF-8");
response.getWriter().write("cjdncvjf");
} catch (IOException e) {
e.printStackTrace();
}
}
}
......@@ -52,7 +52,6 @@ public class DrvPhotoImpl implements DrvPhoto {
* @param time
* @return
*/
@Override
public boolean getHisDrvPhoto(String time) {
try {
endTime = time;
......@@ -112,6 +111,7 @@ public class DrvPhotoImpl implements DrvPhoto {
String time = "2019-07-02 00:00:00";
System.out.println(time.substring(0, 10));
System.out.println(s.compareTo(time.substring(0, 10)));
}
}
......@@ -7,6 +7,11 @@ package com.hikcreate.illegalPic;
*/
public class synchronizationDay {
}
......
......@@ -10,7 +10,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Resource;
/**
......@@ -19,7 +20,7 @@ import javax.annotation.Resource;
*/
@Service
public class FileServiceImpl implements FileService {
private static Logger logger = LoggerFactory.getLogger(FileServiceImpl.class);
@Resource
private FastDFSClient fastDFSClient;
......@@ -32,14 +33,14 @@ public class FileServiceImpl implements FileService {
//将文件上装到fast文件服务器上,成功则返回文件保存的路径
String path = fastDFSClient.uploadFile(file, fileName);
if (!StringUtils.hasText(path)) {
// log.error("Upload Img Error");
logger.error("Upload Img Error");
}
// log.info("Upload Img Success. path {}", ("/group" + path.split("group")[1]));
logger.info("Upload Img Success. path {}", ("/group" + path.split("group")[1]));
return "/group" + path.split("group")[1];
} catch (Exception e) {
// log.error("Upload Img Error, msg ={}", e);
// throw new BusinessException("上传图片失败");
logger.error("Upload Img Error, msg ={}", e);
throw new RuntimeException("上传图片失败");
}
}
......
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