feat: 提交项目代码

This commit is contained in:
super_liu
2021-05-31 14:56:05 +08:00
parent d50bb875cb
commit 3ed9ca235a
234 changed files with 27792 additions and 0 deletions
@@ -0,0 +1,578 @@
package com.adc.da.att.controller;
import com.adc.da.att.entity.AttFileEO;
import com.adc.da.att.service.IAttFileEOService;
import com.adc.da.att.vo.AttFileVo;
import com.adc.da.file.store.IFileStore;
import com.adc.da.http.ResponseMessage;
import com.adc.da.http.Result;
import com.adc.da.util.MD5Util;
import com.adc.da.util.UUIDUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import sun.misc.BASE64Encoder;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotNull;
import java.io.*;
import java.net.URLEncoder;
import java.nio.file.Files;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@RestController
@RequestMapping("/${restPath}/att/attFile")
@Api(description = "|AttFileEO|文件上传")
public class AttFileEOController {
private static final Logger logger = LoggerFactory.getLogger(AttFileEOController.class);
@Autowired
private IAttFileEOService attFileEOService;
@Autowired
private IFileStore iFileStore;
@Value("${file.path}")
private String filePath;//文件存储路径
// @Autowired
// private RoleEOService roleEOService;
//
// @Autowired
// private UserEOService userEOService;
@Value("${upload.file.white.lists}")
private String uploadFileWhiteLists; //上传文件白名单
@ApiOperation(value="|File|上传文件")
@PostMapping(value="/upload",consumes="multipart/*",headers="content-type=multipart/form-data" )
@CrossOrigin(origins = "*", maxAge = 3600)
// @RequiresPermissions("att:attFile:uploadFile")
public ResponseMessage<AttFileVo> uploadFile(@RequestParam("file") @ApiParam(value="上传文件",required=true) MultipartFile file) throws Exception{
if(StringUtils.isNotEmpty(uploadFileWhiteLists)){
String[] fileLists = uploadFileWhiteLists.split(",");
List<String> arrList = Arrays.asList(fileLists);
String getFileName = file.getOriginalFilename();
Pattern pReg = Pattern.compile("\\/|\\/|\\||:|\\?|\\%|\\*|\"|<|>|\\p{Cntrl}");
// getFileName = getFileName.replaceAll(, "_");
Matcher matcher = pReg.matcher(getFileName);
if (matcher.find()) {
return Result.error("文件上传失败,该文件名可能导致文件类型改变,请修改后重试");
}
//截取文件后缀
int pos = getFileName.lastIndexOf(".");
String str = getFileName.substring(pos+1).toLowerCase();
if (arrList.contains(str)) {
AttFileVo fileInfo = attFileEOService.saveFileInfo(file);
if (fileInfo != null && fileInfo.getId() != null) {
String oriFileName = fileInfo.getOldFileName();
if (StringUtils.isNotEmpty(oriFileName)) {
String standNumber = "";
oriFileName = oriFileName.replaceAll("."+fileInfo.getFileSuffix(),"");
Pattern ptest = Pattern.compile("[A-Z]{1,}/{0,1}[A-Z]{1,}\\s{0,1}[0-9]\\d*\\.?\\d*");
Pattern ptest2 = Pattern.compile("[A-Z]{1,}/{0,1}[A-Z]{1,}\\s{0,1}[0-9]\\d*\\.?\\d*-[0-9]{1,4}");
Matcher matcher1 = ptest.matcher(oriFileName);
Matcher matcher2 = ptest2.matcher(oriFileName);
if (matcher2.find()) {
standNumber = matcher2.group();
} else if (matcher1.find()) {
standNumber = matcher1.group();
}
fileInfo.setStandNum(standNumber);
String standName = oriFileName.replace(standNumber,"");
fileInfo.setStandName(standName);
}
return Result.success("true", "上传成功", fileInfo);
} else {
return Result.error("文件上传失败");
}
} else {
return Result.error("文件上传失败,不允许上传该类型文件");
}
} else {
return Result.error("文件上传失败,不允许上传该类型文件");
}
}
@ApiOperation(value="|File|上传文件")
@PostMapping(value="/uploadFiles",consumes="multipart/*",headers="content-type=multipart/form-data" )
@CrossOrigin(origins = "*", maxAge = 3600)
public ResponseMessage<List<AttFileVo>> uploadFile(@RequestParam("files") @ApiParam(value="上传文件",required=true) MultipartFile[] files) throws Exception{
List<AttFileVo> fileInfoList= attFileEOService.saveFilesInfo(files);
return Result.success(fileInfoList);
}
/**
* @Author yangxuenan
* @Description 下载文件
* Date 2018/10/10 18:36
* @Param [response, fileId]
* @return void
**/
@ApiOperation(value = "|File|下载文件")
@GetMapping("/downloadFile")
// @RequiresPermissions("sys:file:download")
public void downloadFile(String fileId, HttpServletResponse response, HttpServletRequest request) throws Exception {
AttFileEO attFileEO = attFileEOService.getFileInfo(fileId);
InputStream is = null;
OutputStream os = null;
response.reset();
try {
String fileOldName = fileNameEncoding(attFileEO.getOldFileName(),request);
response.setHeader("Content-Disposition", "attachment; filename=\""+ fileOldName +"\"");
response.setContentType("application/octet-stream");
is = iFileStore.loadFile(attFileEO.getFilePath()+attFileEO.getFileName());
os = response.getOutputStream();
IOUtils.copy(is, os);
os.flush();
} catch (IOException e) {
logger.error(e.getMessage(), e);
} finally {
IOUtils.closeQuietly(is);
IOUtils.closeQuietly(os);
}
}
@ApiOperation(value = "|File|手机下载文件")
@GetMapping("/downloadFileByPhone")
// @RequiresPermissions("sys:file:download")
public ResponseMessage downloadFileByPhone(@RequestParam("fileId")@NotNull String fileId,@RequestParam("sign")@NotNull String sign, HttpServletResponse response, HttpServletRequest request) throws Exception {
logger.info("手机下载文件调取到了----------------------"+fileId);
String key = "dufy20170329java";
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd-HH");
String time = df.format(new Date());
String signConvert = fileId + time + key;
String signEncrypt = MD5Util.string2MD5(signConvert);
if(StringUtils.isEmpty(sign)){
logger.info("非法请求");
return Result.error("非法请求");
}else {
if(!signEncrypt.equals(sign)){
logger.info("非法请求");
return Result.error("非法请求");
}
}
logger.info("手机下载验证已过----------------------"+sign);
AttFileEO attFileEO = attFileEOService.getFileInfo(fileId);
String filePathResult = "";
try {
if (attFileEO != null) {
File oldFile = new File(filePath + attFileEO.getFilePath()+attFileEO.getFileName());
String fileOldName = attFileEO.getOldFileName();
String timeStr = String.valueOf(System.currentTimeMillis());
String fileOutputPath = filePath + "/" + "phoneLoadFiles/" + timeStr;
File dir = new File(fileOutputPath);
if (!dir.exists()) {
dir.mkdirs();
}
String newFilePath = fileOutputPath + "/" + fileOldName;
File newFile = new File(newFilePath);
if (!newFile.exists()) {
Files.copy(oldFile.toPath(), newFile.toPath());
}
filePathResult = "uploadPath/phoneLoadFiles/" + timeStr + "/" + fileOldName;
return Result.success(filePathResult);
} else {
return Result.error("获取文件信息失败");
}
} catch (IOException e){
logger.error(e.getMessage(), e);
}
return Result.error("获取文件信息失败");
/*InputStream is = null;
OutputStream os = null;
response.reset();
try {
String fileOldName = fileNameEncoding(attFileEO.getOldFileName(),request);
response.setHeader("Content-Disposition", "attachment; filename=\""+ fileOldName +"\"");
response.setContentType("application/octet-stream");
logger.info("请求头设置完毕");
is = iFileStore.loadFile(attFileEO.getFilePath()+attFileEO.getFileName());
logger.info("序列化流完毕");
os = response.getOutputStream();
IOUtils.copy(is, os);
logger.info("文件复制完毕");
os.flush();
} catch (IOException e) {
logger.error(e.getMessage(), e);
} finally {
IOUtils.closeQuietly(is);
IOUtils.closeQuietly(os);
}*/
}
@ApiOperation(value = "|File|下载文件")
@GetMapping("/downloadFileForSar")
// @RequiresPermissions("sys:file:downloadFileForSar")
public void downloadFileForSar(String fileId, HttpServletResponse response, HttpServletRequest request) throws Exception {
AttFileEO attFileEO = attFileEOService.getFileInfo(fileId);
InputStream is = null;
OutputStream os = null;
response.reset();
try {
String fileOldName = fileNameEncoding(attFileEO.getOldFileName(),request);
response.setHeader("Content-Disposition", "attachment;filename=\""+fileOldName+"\"");
response.setContentType("application/octet-stream");
is = iFileStore.loadFile(attFileEO.getFilePath()+attFileEO.getFileName());
os = response.getOutputStream();
IOUtils.copy(is, os);
os.flush();
} catch (IOException e) {
logger.error(e.getMessage(), e);
} finally {
IOUtils.closeQuietly(is);
IOUtils.closeQuietly(os);
}
}
@ApiOperation(value = "|File|下载文件加水印")
@GetMapping("/downloadFileForSarWaterMark")
// @RequiresPermissions("sys:file:downloadFileForSar")
public void downloadFileForSarWaterMark(String fileId, HttpServletResponse response, HttpServletRequest request) throws Exception {
AttFileEO attFileEO = attFileEOService.getFileInfo(fileId);
InputStream is = null;
OutputStream os = null;
response.reset();
try {
String fileOldName = fileNameEncoding(attFileEO.getOldFileName(),request);
//生成一份水印文件
String oldFilePath = filePath + attFileEO.getFilePath()+attFileEO.getFileName();
String newFilePath = filePath + attFileEO.getFilePath()+"waterPath/";
File dir = new File(newFilePath);
if (!dir.exists()) {
dir.mkdirs();
}
String waterFilePath = newFilePath + attFileEO.getOldFileName();
// 添加水印
String waterContent = "";
// String userId = LoginUserUtil.getUserId();
// String userMsg = "";
// UserEO userEO = userEOService.selectByPrimaryKey(userId);
// if (userEO != null) {
// userMsg = userEO.getUname() + ",";
// if (StringUtils.isNotEmpty(userEO.getWorkNum())) {
// userMsg += userEO.getWorkNum() + ",";
// }
// }
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");//设置日期格式
String date = df.format(new Date());
// waterContent = userMsg + date;
//2020年9月5日 去掉水印处理
// WaterMarkUtil.waterMark(oldFilePath,waterFilePath,waterContent);
response.setHeader("Content-Disposition", "attachment;filename=\""+fileOldName+"\"");
response.setContentType("application/octet-stream");
is = iFileStore.loadFile(attFileEO.getFilePath()+"waterPath/"+attFileEO.getOldFileName());
os = response.getOutputStream();
IOUtils.copy(is, os);
os.flush();
} catch (IOException e) {
logger.error(e.getMessage(), e);
} finally {
IOUtils.closeQuietly(is);
IOUtils.closeQuietly(os);
}
}
/**
* @Author yangxuenan
* @Description 根据不同浏览器定义下载文件编码
* Date 2018/10/11 10:40
* @Param [fileName, request]
* @return java.lang.String
**/
public String fileNameEncoding(String fileName, HttpServletRequest request) throws IOException {
String agent = request.getHeader("User-Agent");
if (agent.contains("Firefox")) {
/*BASE64Encoder base64Encoder = new BASE64Encoder();
fileName = "=?utf-8?B?"
+ base64Encoder.encode(fileName.getBytes("utf-8")) + "?=";*/
fileName = new String(fileName.getBytes("UTF-8"), "ISO8859-1"); // firefox浏览器
} else {
fileName = URLEncoder.encode(fileName, "utf-8");
//谷歌中空格变为+问题
fileName = fileName.replaceAll("\\+","%20");
}
return fileName;
}
/**
* @Author yangxuenan
* @Description 查询文件信息
* Date 2018/10/10 18:41
* @Param [fileId]
* @return com.adc.da.util.http.ResponseMessage<com.adc.da.att.entity.AttFileEO>
**/
@ApiOperation(value = "|File|查询文件信息")
@GetMapping("/getAttFileInfo")
public ResponseMessage<AttFileEO> getAttFileInfo(String fileId){
AttFileEO attFileEO = attFileEOService.getFileInfo(fileId);
return Result.success(attFileEO);
}
/**
* @Author yangxuenan
* @Description 查询多个文件信息
* Date 2018/10/24 9:47
* @Param [fileIds]
* @return com.adc.da.util.http.ResponseMessage<com.adc.da.att.entity.AttFileEO>
**/
@ApiOperation(value = "|File|查询多个文件信息")
@GetMapping("/getMultiFileInfos")
// @RequiresPermissions("att:attFile:getMultiFileInfos")
public ResponseMessage<List<AttFileEO>> getMultiFileInfos(String fileIds){
List<AttFileEO> fileObj = attFileEOService.getMultiFileInfos(fileIds);
return Result.success(fileObj);
}
@ApiOperation(value = "|File|下载文件")
@GetMapping("/uploadModalFile")
// @RequiresPermissions("att:attFile:uploadModalFile")
public void uploadModalFile(String fileName, HttpServletResponse response, HttpServletRequest request) throws Exception {
InputStream is = null;
OutputStream os = null;
response.reset();
try {
String fileOldName = fileNameEncoding(fileName,request);
response.setHeader("Content-Disposition", "attachment; filename=" + fileOldName);
response.setContentType("application/octet-stream");
is = iFileStore.loadFile("/modal/"+fileName);
os = response.getOutputStream();
IOUtils.copy(is, os);
os.flush();
} catch (IOException e) {
logger.error(e.getMessage(), e);
} finally {
IOUtils.closeQuietly(is);
IOUtils.closeQuietly(os);
}
}
@ApiOperation(value = "|File|获取文件流")
@GetMapping("/getFileInfo")
// @RequiresPermissions("sys:file:getFileInfo")
public void getPdfFileSteam(String fileId,HttpServletRequest request,HttpServletResponse response) {
AttFileEO attFileEO = attFileEOService.getFileInfo(fileId);
InputStream is = null;
OutputStream os = null;
response.reset();
try {
String fileOldName = fileNameEncoding(attFileEO.getOldFileName(), request);
response.setHeader("Content-Disposition", "attachment; filename=" + fileOldName);
response.setContentType("application/octet-stream");
String readFilePath = filePath + "/" + attFileEO.getFilePath() + attFileEO.getFileName();
File readFile = new File(readFilePath);
if (readFile.exists()) {
byte[] data = null;
try (FileInputStream input = new FileInputStream(readFile)){
data = new byte[10000];
int readIndex=0;
while((readIndex=input.read(data)) > 0){
response.getOutputStream().write(data,0,readIndex);
}
}
} else {
return;
}
/* is = iFileStore.loadFile(attFileEO.getFilePath()+attFileEO.getFileName());
os = response.getOutputStream();
IOUtils.copy(is, os);
os.flush();*/
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
}
@ApiOperation(value = "|File|获取转换后的pdf文件流")
@GetMapping("/getPdfFileInfo")
// @RequiresPermissions("sys:file:getFileInfo")
public ResponseMessage getPdfFileInfo(String fileId,HttpServletRequest request,HttpServletResponse response) {
AttFileEO attFileEO = attFileEOService.getFileInfo(fileId);
InputStream is = null;
OutputStream os = null;
response.reset();
String encreptFileStr = "";
try {
String fileOldName = fileNameEncoding(attFileEO.getOldFileName(), request);
response.setHeader("Content-Disposition", "attachment; filename=" + fileOldName);
response.setContentType("application/octet-stream");
String readFilePath = filePath + "/" + attFileEO.getFilePath() + attFileEO.getFileName();
File readFile = new File(readFilePath);
String codeStr = "";
BASE64Encoder encoder = new BASE64Encoder();
if (readFile.exists()) {
byte[] data = null;
try (FileInputStream input = new FileInputStream(readFile)){
data = new byte[(int) readFile.length()];
input.read(data);
input.close();
} catch (IOException e) {
logger.info(e.getMessage(),e);
}
//base64编码
codeStr = encoder.encode(data);
codeStr = codeStr.replaceAll("\r|\n", "");
//加密处理,前30后50拼上随机生成字符串
encreptFileStr = UUIDUtils.randomUUID(30) + codeStr + UUIDUtils.randomUUID(50);
}
/* is = iFileStore.loadFile(attFileEO.getFilePath()+attFileEO.getFileName());
os = response.getOutputStream();
IOUtils.copy(is, os);
os.flush();*/
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
if(StringUtils.isNotEmpty(encreptFileStr)){
return Result.success("0","",encreptFileStr);
} else {
return Result.error("获取文件信息失败");
}
}
@ApiOperation(value = "|File|分段获取转换后的pdf文件流")
@GetMapping("/getSyncPdfFileInfo")
public void getSyncPdfFileInfo(String fileId,HttpServletRequest request,HttpServletResponse response) {
AttFileEO attFileEO = attFileEOService.getFileInfo(fileId);
InputStream is = null;
OutputStream os = null;
response.reset();
try {
String fileOldName = fileNameEncoding(attFileEO.getOldFileName(), request);
response.setHeader("Content-Disposition", "attachment; filename=" + fileOldName);
String readFilePath = filePath + "/" + attFileEO.getFilePath() + attFileEO.getFileName();
File readFile = new File(readFilePath);
if (readFile.exists()) {
downloadExistsFile(request,response,readFile);
} else {
return;
}
/* is = iFileStore.loadFile(attFileEO.getFilePath()+attFileEO.getFileName());
os = response.getOutputStream();
IOUtils.copy(is, os);
os.flush();*/
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
}
private void downloadExistsFile(HttpServletRequest request, HttpServletResponse response, File proposeFile) throws IOException,FileNotFoundException {
logger.debug("下载文件路径:" + proposeFile.getPath());
long fSize = proposeFile.length();
// 下载
response.setContentType("application/x-download");
response.setHeader("Accept-Ranges", "bytes");
response.setHeader("Content-Length", String.valueOf(fSize));
long pos = 0;
if (null != request.getHeader("Range")) {
// 断点续传
response.setStatus(HttpServletResponse.SC_PARTIAL_CONTENT);
try {
// pos = Long.parseLong(request.getHeader("Range").replaceAll(
// "bytes=", "").replaceAll("-", ""));
pos = Long.parseLong((request.getHeader("Range").replaceAll("bytes=", "").split("-")[0]));
} catch (NumberFormatException e) {
logger.error(request.getHeader("Range") + " is not Number!");
pos = 0;
}
}
ServletOutputStream out = response.getOutputStream();
BufferedOutputStream bufferOut = new BufferedOutputStream(out);
InputStream inputStream = new FileInputStream(proposeFile);
String contentRange = new StringBuffer("bytes ").append(
new Long(pos).toString()).append("-").append(
new Long(fSize - 1).toString()).append("/").append(
new Long(fSize).toString()).toString();
response.setHeader("Content-Range", contentRange);
logger.debug("Content-Range", contentRange);
inputStream.skip(pos);
byte[] buffer = new byte[64 * 1024];
int length = 0;
while ((length = inputStream.read(buffer, 0, buffer.length)) != -1) {
bufferOut.write(buffer, 0, length);
}
bufferOut.flush();
bufferOut.close();
out.close();
inputStream.close();
}
@ApiOperation(value = "|File|获取转换后图片流")
@GetMapping("/getFileImgInfo")
// @RequiresPermissions("sys:file:getFileInfo")
public ResponseMessage<Map<String,String>> getFileImgInfo(String fileId,int pageNo,HttpServletRequest request,HttpServletResponse response) {
Map<String,String> resultMap = new HashMap<>();
AttFileEO attFileEO = attFileEOService.getFileInfo(fileId);
InputStream is = null;
OutputStream os = null;
response.reset();
String encreptFileStr = "";
try {
String fileOldName = fileNameEncoding(attFileEO.getOldFileName(), request);
response.setHeader("Content-Disposition", "attachment; filename=" + fileOldName);
response.setContentType("application/octet-stream");
String fileName = attFileEO.getFileName().substring(0, attFileEO.getFileName().indexOf("."));
String readFilePath = filePath + attFileEO.getFilePath() + fileName + "img/" + pageNo + ".png";
String fileDic = filePath + attFileEO.getFilePath() + fileName + "img";
File readFile = new File(readFilePath);
String codeStr = "";
BASE64Encoder encoder = new BASE64Encoder();
if (readFile.exists()) {
byte[] data = null;
try (FileInputStream input = new FileInputStream(readFile)){
data = new byte[(int) readFile.length()];
input.read(data);
input.close();
} catch (IOException e) {
logger.info(e.getMessage(),e);
}
//base64编码
codeStr = encoder.encode(data);
codeStr = codeStr.replaceAll("\r|\n", "");
//加密处理,前30后50拼上随机生成字符串
encreptFileStr = UUIDUtils.randomUUID(30) + codeStr + UUIDUtils.randomUUID(50);
resultMap.put("data",encreptFileStr);
//获取文件夹下图片数量
int imgCount = 0;
File readFileDic = new File(fileDic);
if (readFileDic.isDirectory()) {
File[] files = readFileDic.listFiles();
if (files != null && files.length>0) {
imgCount = files.length;
}
}
resultMap.put("count",String.valueOf(imgCount));
}
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
if(StringUtils.isNotEmpty(encreptFileStr)){
return Result.success("0","获取成功",resultMap);
} else {
return Result.error("获取文件信息失败");
}
}
}
@@ -0,0 +1,101 @@
package com.adc.da.att.controller;
import com.adc.da.att.entity.UeditorImage;
import com.adc.da.att.service.IAttFileEOService;
import com.adc.da.att.vo.AttFileVo;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import javax.servlet.http.HttpServletRequest;
import java.nio.charset.Charset;
import java.util.List;
/*import com.adc.da.att.common.ueditor.ActionEnter;*/
/**
* 用于处理关于ueditor插件相关的请求
* @author zhangyanduan
* @date 2018年9月25日
*
*/
@Slf4j
@RestController
@CrossOrigin
@RequestMapping("/${restPath}/ueditor")
public class UeditorController {
@Value("classpath:ueditor/config.json")
private Resource ueditorConfig;
@Autowired
private IAttFileEOService attFileEOService;
@RequestMapping(value = "/getConfig")
@ResponseBody
public String getUeditorConfig(HttpServletRequest request) throws Exception{
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
log.info(path);
log.info(basePath);
String ueditorData = IOUtils.toString(ueditorConfig.getInputStream(), Charset.forName("UTF-8"));
return ueditorData;
}
@RequestMapping("/uploadImageData")
@ResponseBody
public String uploadImageData(HttpServletRequest request) {
UeditorImage msg = uploadFile(request);
return JSONObject.toJSONString(msg);
}
private UeditorImage uploadFile(HttpServletRequest request) {
UeditorImage image = new UeditorImage();
try{
List<MultipartFile> files = ((MultipartHttpServletRequest) request).getFiles("upfile");
String referer = request.getHeader("referer");
if(files!=null && !files.isEmpty()){
MultipartFile uploadFile=files.get(0);
AttFileVo attFileVo= attFileEOService.saveFileInfo(uploadFile);
String picUrlPath ="";
if(StringUtils.isNotEmpty(referer)){
picUrlPath=referer+"uploadPath"+ attFileVo.getFilePath()+attFileVo.getFileName();
}else{
picUrlPath="uploadPath"+attFileVo.getFilePath()+attFileVo.getFileName();
}
log.info("Ueditor 上传图片返回路径:"+picUrlPath);
image.setState("SUCCESS");
image.setUrl(picUrlPath);
image.setTitle(attFileVo.getOldFileName());
// image.setState(attFileVo.getOldFileName());
image.setOriginal(attFileVo.getOldFileName());
}else{
image.setState("FAIL");
}
}catch (Exception e){
image.setState("FAIL");
log.error(e.getMessage());
}
/* image.setUrl(serverPath + path);
image.setState("SUCCESS");
image.setOriginal(fileName);
image.setTitle(fileName);*/
return image;
}
}
@@ -0,0 +1,25 @@
package com.adc.da.att.dao;
import com.adc.da.att.entity.AttFileEO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
/**
*
* <br>
* <b>功能:</b>ATT_FILE AttFileEODao<br>
* <b>作者:</b>code generator<br>
* <b>日期:</b> 2018-09-07 <br>
* <b>版权所有:<b>版权归北京卡达克数据技术中心所有。<br>
*/
public interface AttFileEODao extends BaseMapper<AttFileEO> {
public void creatTableInfo(@Param("tableName") String tableName);
public int existTable(@Param("tableName") String tableName);
public AttFileEO selectFileInfoById(AttFileEO attFileEO);
public int insertData(AttFileEO attFileEO);
}
@@ -0,0 +1,217 @@
package com.adc.da.att.entity;
import com.adc.da.base.entity.BaseEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.Serializable;
import java.util.Date;
/**
* <b>功能:</b>ATT_FILE AttFileEOEntity<br>
* <b>作者:</b>code generator<br>
* <b>日期:</b> 2018-09-07 <br>
* <b>版权所有:<b>版权归北京卡达克数据技术中心所有。<br>
*/
public class AttFileEO extends BaseEntity implements Serializable{
private static final long serialVersionUID = 1284335706608668758L;
private static final Logger logger = LoggerFactory.getLogger(AttFileEO.class);
private String id;
private String fileName;
private String oldFileName;
private String fileSuffix;
private String filePath;
private Integer validFlag;
@org.springframework.format.annotation.DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date creationTime;
@org.springframework.format.annotation.DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date modifyTime;
private String tableName;
private String resId;
/**
* java字段名转换为原始数据库列名。<b>如果不存在则返回null</b><br>
* <p>字段列表:</p>
* <li>id -> id</li>
* <li>fileName -> file_name</li>
* <li>oldFileName -> old_file_name</li>
* <li>fileSuffix -> file_suffix</li>
* <li>filePath -> file_path</li>
* <li>validFlag -> valid_flag</li>
* <li>creationTime -> creation_time</li>
* <li>modifyTime -> modify_time</li>
*/
public static String fieldToColumn(String fieldName) {
if (fieldName == null){
return null;
}
switch (fieldName) {
case "id": return "id";
case "fileName": return "file_name";
case "oldFileName": return "old_file_name";
case "fileSuffix": return "file_suffix";
case "filePath": return "file_path";
case "validFlag": return "valid_flag";
case "creationTime": return "creation_time";
case "modifyTime": return "modify_time";
default: return null;
}
}
/**
* 原始数据库列名转换为java字段名。<b>如果不存在则返回null</b><br>
* <p>字段列表:</p>
* <li>id -> id</li>
* <li>file_name -> fileName</li>
* <li>old_file_name -> oldFileName</li>
* <li>file_suffix -> fileSuffix</li>
* <li>file_path -> filePath</li>
* <li>valid_flag -> validFlag</li>
* <li>creation_time -> creationTime</li>
* <li>modify_time -> modifyTime</li>
*/
public static String columnToField(String columnName) {
if (columnName == null){
return null;
}
switch (columnName) {
case "id": return "id";
case "file_name": return "fileName";
case "old_file_name": return "oldFileName";
case "file_suffix": return "fileSuffix";
case "file_path": return "filePath";
case "valid_flag": return "validFlag";
case "creation_time": return "creationTime";
case "modify_time": return "modifyTime";
default: return null;
}
}
/** **/
public String getId() {
int tableNameIndex = this.id.lastIndexOf("_");
if(tableNameIndex!= -1){
String tableName = this.id.substring(0, tableNameIndex);
this.tableName=tableName;
}else{
logger.error("文件ID格式错误:"+this.id);
}
return this.id;
}
/** **/
public void setId(String id) {
if(tableName!=null && !tableName.isEmpty()){
this.id = tableName+"_"+id;
}
//此处注意保存时表结构是否存在
this.id=id;
}
/** **/
public String getFileName() {
return this.fileName;
}
/** **/
public void setFileName(String fileName) {
this.fileName = fileName;
}
/** **/
public String getOldFileName() {
return this.oldFileName;
}
/** **/
public void setOldFileName(String oldFileName) {
this.oldFileName = oldFileName;
}
/** **/
public String getFileSuffix() {
return this.fileSuffix;
}
/** **/
public void setFileSuffix(String fileSuffix) {
this.fileSuffix = fileSuffix;
}
/** **/
public String getFilePath() {
return this.filePath;
}
/** **/
public void setFilePath(String filePath) {
this.filePath = filePath;
}
/** **/
public Integer getValidFlag() {
return this.validFlag;
}
/** **/
public void setValidFlag(Integer validFlag) {
this.validFlag = validFlag;
}
/** **/
public Date getCreationTime() {
return this.creationTime;
}
/** **/
public void setCreationTime(Date creationTime) {
this.creationTime = creationTime;
}
/** **/
public Date getModifyTime() {
return this.modifyTime;
}
/** **/
public void setModifyTime(Date modifyTime) {
this.modifyTime = modifyTime;
}
public String getTableName() {
if(this.tableName !=null && !this.tableName.isEmpty()){
return this.tableName;
}else{
int tableNameIndex = this.id.lastIndexOf("_");
if(tableNameIndex !=-1){
String tableName = this.id.substring(0, tableNameIndex);
this.tableName=tableName;
}else{
logger.error("文件ID格式错误:"+this.id);
}
return this.tableName;
}
}
public void setTableName(String tableName) {
this.tableName = tableName;
}
public static long getSerialVersionUID() {
return serialVersionUID;
}
public String getResId() {
return resId;
}
public void setResId(String resId) {
this.resId = resId;
}
}
@@ -0,0 +1,41 @@
package com.adc.da.att.entity;
public class UeditorImage {
private String state;
private String url;
private String title;
private String original;
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getOriginal() {
return original;
}
public void setOriginal(String original) {
this.original = original;
}
}
@@ -0,0 +1,215 @@
package com.adc.da.att.page;
import com.adc.da.base.page.BasePage;
/**
* <b>功能:</b>ATT_FILE AttFileEOPage<br>
* <b>作者:</b>code generator<br>
* <b>日期:</b> 2018-09-07 <br>
* <b>版权所有:<b>版权归北京卡达克数据技术中心所有。<br>
*/
public class AttFileEOPage extends BasePage {
private String id;
private String idOperator = "=";
private String fileName;
private String fileNameOperator = "=";
private String oldFileName;
private String oldFileNameOperator = "=";
private String fileSuffix;
private String fileSuffixOperator = "=";
private String filePath;
private String filePathOperator = "=";
private String validFlag;
private String validFlagOperator = "=";
private String creationTime;
private String creationTime1;
private String creationTime2;
private String creationTimeOperator = "=";
private String modifyTime;
private String modifyTime1;
private String modifyTime2;
private String modifyTimeOperator = "=";
private String tableName;
public String getId() {
int tableNameIndex = this.id.lastIndexOf("_");
String tableName = this.id.substring(0, tableNameIndex);
this.tableName=tableName;
return this.id;
}
public void setId(String id) {
this.id = id;
int tableNameIndex = id.lastIndexOf("_");
String tableName = id.substring(0, tableNameIndex);
this.tableName=tableName;
}
public String getIdOperator() {
return this.idOperator;
}
public void setIdOperator(String idOperator) {
this.idOperator = idOperator;
}
public String getFileName() {
return this.fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public String getFileNameOperator() {
return this.fileNameOperator;
}
public void setFileNameOperator(String fileNameOperator) {
this.fileNameOperator = fileNameOperator;
}
public String getOldFileName() {
return this.oldFileName;
}
public void setOldFileName(String oldFileName) {
this.oldFileName = oldFileName;
}
public String getOldFileNameOperator() {
return this.oldFileNameOperator;
}
public void setOldFileNameOperator(String oldFileNameOperator) {
this.oldFileNameOperator = oldFileNameOperator;
}
public String getFileSuffix() {
return this.fileSuffix;
}
public void setFileSuffix(String fileSuffix) {
this.fileSuffix = fileSuffix;
}
public String getFileSuffixOperator() {
return this.fileSuffixOperator;
}
public void setFileSuffixOperator(String fileSuffixOperator) {
this.fileSuffixOperator = fileSuffixOperator;
}
public String getFilePath() {
return this.filePath;
}
public void setFilePath(String filePath) {
this.filePath = filePath;
}
public String getFilePathOperator() {
return this.filePathOperator;
}
public void setFilePathOperator(String filePathOperator) {
this.filePathOperator = filePathOperator;
}
public String getValidFlag() {
return this.validFlag;
}
public void setValidFlag(String validFlag) {
this.validFlag = validFlag;
}
public String getValidFlagOperator() {
return this.validFlagOperator;
}
public void setValidFlagOperator(String validFlagOperator) {
this.validFlagOperator = validFlagOperator;
}
public String getCreationTime() {
return this.creationTime;
}
public void setCreationTime(String creationTime) {
this.creationTime = creationTime;
}
public String getCreationTime1() {
return this.creationTime1;
}
public void setCreationTime1(String creationTime1) {
this.creationTime1 = creationTime1;
}
public String getCreationTime2() {
return this.creationTime2;
}
public void setCreationTime2(String creationTime2) {
this.creationTime2 = creationTime2;
}
public String getCreationTimeOperator() {
return this.creationTimeOperator;
}
public void setCreationTimeOperator(String creationTimeOperator) {
this.creationTimeOperator = creationTimeOperator;
}
public String getModifyTime() {
return this.modifyTime;
}
public void setModifyTime(String modifyTime) {
this.modifyTime = modifyTime;
}
public String getModifyTime1() {
return this.modifyTime1;
}
public void setModifyTime1(String modifyTime1) {
this.modifyTime1 = modifyTime1;
}
public String getModifyTime2() {
return this.modifyTime2;
}
public void setModifyTime2(String modifyTime2) {
this.modifyTime2 = modifyTime2;
}
public String getModifyTimeOperator() {
return this.modifyTimeOperator;
}
public void setModifyTimeOperator(String modifyTimeOperator) {
this.modifyTimeOperator = modifyTimeOperator;
}
public String getTableName() {
int tableNameIndex = this.id.lastIndexOf("_");
String tableName = this.id.substring(0, tableNameIndex);
this.tableName=tableName;
return tableName;
}
public void setTableName(String tableName) {
this.tableName = tableName;
}
}
@@ -0,0 +1,25 @@
package com.adc.da.att.service;
import com.adc.da.att.entity.AttFileEO;
import com.adc.da.att.vo.AttFileVo;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.util.List;
public interface IAttFileEOService extends IService<AttFileEO> {
public AttFileVo saveFileInfo(File file);
public AttFileVo saveFileInfo(MultipartFile file);
public List<AttFileVo> saveFilesInfo(MultipartFile[] files);
public AttFileEO getFileInfo(String attId);
public List<AttFileEO> getMultiFileInfos(String fileIds);
public String saveFileAttId(File file);
}
@@ -0,0 +1,361 @@
package com.adc.da.att.service.impl;
import com.adc.da.att.dao.AttFileEODao;
import com.adc.da.att.entity.AttFileEO;
import com.adc.da.att.service.IAttFileEOService;
import com.adc.da.att.vo.AttFileVo;
import com.adc.da.common.ValidFlagEnum;
import com.adc.da.util.FileUtil;
import com.adc.da.util.UUIDUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Service("attFileEOService")
@Transactional(value = "transactionManager", readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
@Slf4j
public class AttFileEOServiceImpl extends ServiceImpl<AttFileEODao, AttFileEO> implements IAttFileEOService {
@Value("${file.path}")
private String filePath;//文件存储路径
/**
* 保存文件并返回文件ID
*
* @param file
*/
@Transactional(rollbackFor = Exception.class)
public AttFileVo saveFileInfo(File file) {
/**
* 1、首先生成文件保存的主键ID
* 2、根据文件ID生成随机路径
* 3、生成文件名
* 3、保存文件
* 4、获取文件相关信息
* 5、判断当前表是否有存在,如果存在则执行insert语句 如果不存在则创建表结构
* 5、保存入库并返回主键ID
*/
AttFileVo attFileVo = new AttFileVo();
String fileId = UUIDUtils.randomUUID20();
try {
String uuidPath = UUIDUtils.getUUIDPath(fileId);
String FileSavePath = filePath + uuidPath + "/";
File dir = new File(FileSavePath);
if (!dir.exists()) {
dir.mkdirs();
}
String fileName = file.getName();
String fileSuffix = fileName.substring(fileName.lastIndexOf(".")+1, fileName.length());
String newFileName = fileId +"."+ fileSuffix;
File saveFile = new File(FileSavePath + newFileName);
FileUtils.copyFile(file,saveFile);
//开始存储文件信息
String tableName = UUIDUtils.getAttTable();
int existTable = this.baseMapper.existTable(tableName);
if (existTable == 0) {
this.baseMapper.creatTableInfo(tableName);
}
fileId = tableName + "_" + fileId;
AttFileEO attFileEO = new AttFileEO();
attFileEO.setTableName(tableName);
attFileEO.setId(fileId);
attFileEO.setOldFileName(fileName);
attFileEO.setFileSuffix(fileSuffix);
attFileEO.setFilePath(uuidPath);
attFileEO.setFileName(newFileName);
attFileEO.setValidFlag(ValidFlagEnum.VALID_TRUE.getValue());
attFileEO.setCreationTime(new Date());
attFileEO.setModifyTime(new Date());
this.baseMapper.insertData(attFileEO);
attFileVo.setId(fileId);
attFileVo.setFileName(newFileName);
attFileVo.setFilePath(uuidPath);
attFileVo.setFileSuffix(fileSuffix);
attFileVo.setOldFileName(fileName);
} catch (IOException e) {
log.error(e.getMessage(),e);
} catch (Exception e) {
log.error(e.getMessage(),e);
}
return attFileVo;
}
/**
* 保存文件并返回文件ID
*
* @param file
*/
@Transactional(rollbackFor = Exception.class)
public AttFileVo saveFileInfo(MultipartFile file) {
/**
* 1、首先生成文件保存的主键ID
* 2、根据文件ID生成随机路径
* 3、生成文件名
* 3、保存文件
* 4、获取文件相关信息
* 5、判断当前表是否有存在,如果存在则执行insert语句 如果不存在则创建表结构
* 5、保存入库并返回主键ID
*/
AttFileVo attFileVo = new AttFileVo();
String fileId = UUIDUtils.randomUUID20();
try {
String uuidPath = UUIDUtils.getUUIDPath(fileId);
String FileSavePath = filePath + uuidPath;
File dir = new File(FileSavePath);
if (!dir.exists()) {
dir.mkdirs();
}
//开始存储文件
String fileName = file.getOriginalFilename();
// 此处发现在IE 11中存在获取文件名时获取了文件路径,此处将文件路径去除
if(fileName.indexOf(":\\")>-1){
// 此时说明存在从根路径获取的内容 需要处理
fileName = fileName.substring(fileName.lastIndexOf("\\") + 1, fileName.length());
}
String fileSuffix = fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length());
String newFileName = fileId + "." + fileSuffix;
FileUtils.copyInputStreamToFile(file.getInputStream(), new File(FileSavePath + newFileName));
//开始存储文件信息
String tableName = UUIDUtils.getAttTable();
int existTable = this.baseMapper.existTable(tableName);
if (existTable == 0) {
this.baseMapper.creatTableInfo(tableName);
}
fileId = tableName + "_" + fileId;
AttFileEO attFileEO = new AttFileEO();
attFileEO.setTableName(tableName);
attFileEO.setId(fileId);
attFileEO.setOldFileName(fileName);
attFileEO.setFileSuffix(fileSuffix);
attFileEO.setFilePath(uuidPath);
attFileEO.setFileName(newFileName);
attFileEO.setValidFlag(ValidFlagEnum.VALID_TRUE.getValue());
attFileEO.setCreationTime(new Date());
attFileEO.setModifyTime(new Date());
this.baseMapper.insertData(attFileEO);
attFileVo.setId(fileId);
attFileVo.setFileName(newFileName);
attFileVo.setFilePath(uuidPath);
attFileVo.setFileSuffix(fileSuffix);
attFileVo.setOldFileName(fileName);
} catch (IOException e) {
log.error(e.getMessage(),e);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
return attFileVo;
}
/***
* 保存文件列表
* @MethodName:saveFilesInfo
* @author: zhangyanduan
* @param:[files]
* @return:java.lang.String
* date: 2018/9/19 9:48
*/
@Transactional(rollbackFor = Exception.class)
public List<AttFileVo> saveFilesInfo(MultipartFile[] files) {
/**
* 1、首先生成文件保存的主键ID
* 2、根据文件ID生成随机路径
* 3、生成文件名
* 3、保存文件
* 4、获取文件相关信息
* 5、判断当前表是否有存在,如果存在则执行insert语句 如果不存在则创建表结构
* 5、保存入库并返回主键ID
*/
List<AttFileVo> fileInfoList = new ArrayList<AttFileVo>();
if (files != null && files.length > 0) {
for (int index = 0; index < files.length; index++) {
MultipartFile file = files[index];
AttFileVo attFileVo = new AttFileVo();
String fileId = UUIDUtils.randomUUID20();
try {
String uuidPath = UUIDUtils.getUUIDPath(fileId);
String FileSavePath = filePath + uuidPath;
File dir = new File(FileSavePath);
if (!dir.exists()) {
dir.mkdirs();
}
//开始存储文件
String fileName = file.getOriginalFilename();
if(fileName.indexOf(":\\")>-1){
// 此时说明存在从根路径获取的内容 需要处理
fileName = fileName.substring(fileName.lastIndexOf("\\") + 1, fileName.length());
}
String fileSuffix = fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length());
String newFileName = fileId + "." + fileSuffix;
FileUtils.copyInputStreamToFile(file.getInputStream(), new File(FileSavePath + newFileName));
//开始存储文件信息
String tableName = UUIDUtils.getAttTable();
int existTable = this.baseMapper.existTable(tableName);
if (existTable == 0) {
this.baseMapper.creatTableInfo(tableName);
}
fileId = tableName + "_" + fileId;
AttFileEO attFileEO = new AttFileEO();
attFileEO.setTableName(tableName);
attFileEO.setId(fileId);
attFileEO.setOldFileName(fileName);
attFileEO.setFileSuffix(fileSuffix);
attFileEO.setFilePath(uuidPath);
attFileEO.setFileName(newFileName);
attFileEO.setValidFlag(ValidFlagEnum.VALID_TRUE.getValue());
attFileEO.setCreationTime(new Date());
attFileEO.setModifyTime(new Date());
this.baseMapper.insertData(attFileEO);
attFileVo.setId(fileId);
attFileVo.setFileName(newFileName);
attFileVo.setFilePath(uuidPath);
attFileVo.setFileSuffix(fileSuffix);
attFileVo.setOldFileName(fileName);
fileInfoList.add(attFileVo);
} catch (IOException e) {
log.error(e.getMessage(),e);
} catch (Exception e) {
log.error(e.getMessage(),e);
}
}
}
return fileInfoList;
}
/**
* 根据文件ID获取文件信息
*
* @param attId
* @return
*/
public AttFileEO getFileInfo(String attId) {
/**
* 根据ID获取文件信息
*/
AttFileEO attFileEO = new AttFileEO();
AttFileEO attFileInfo=null;
try {
attFileEO.setId(attId);
attFileInfo = this.baseMapper.selectFileInfoById(attFileEO);
return attFileInfo;
} catch (Exception e) {
log.error(e.getMessage(),e);
}
return attFileEO;
}
/**
* @Author yangxuenan
* @Description 多文件查询
* Date 2018/10/24 11:08
* @Param [fileIds]
* @return java.util.List<com.adc.da.att.entity.AttFileEO>
**/
public List<AttFileEO> getMultiFileInfos(String fileIds) {
List<AttFileEO> fileObj = new ArrayList<>();
if(StringUtils.isNotEmpty(fileIds)){
String idList[] = fileIds.split(",");
for(int i=0;i<idList.length;i++){
AttFileEO attFileEO = new AttFileEO();
try {
if(StringUtils.isNotEmpty(idList[i])){
attFileEO.setId(idList[i]);
AttFileEO getFile = this.baseMapper.selectFileInfoById(attFileEO);
if(attFileEO != null){
fileObj.add(getFile);
}
}
} catch (Exception e) {
log.error(e.getMessage(),e);
}
}
}
return fileObj;
}
/**
* @Author yangxuenan
* @Description 获取attId
* Date 2018/10/30 21:05
* @Param [file]
* @return java.lang.String
**/
@Transactional(rollbackFor = Exception.class)
public String saveFileAttId(File file) {
/**
* 1、首先生成文件保存的主键ID
* 2、根据文件ID生成随机路径
* 3、生成文件名
* 3、保存文件
* 4、获取文件相关信息
* 5、判断当前表是否有存在,如果存在则执行insert语句 如果不存在则创建表结构
* 5、保存入库并返回主键ID
*/
String fileId = UUIDUtils.randomUUID20();
try {
String uuidPath = UUIDUtils.getUUIDPath(fileId);
String FileSavePath = filePath + uuidPath;
File dir = new File(FileSavePath);
if (!dir.exists()) {
dir.mkdirs();
}
String fileName = file.getName();
String fileSuffix = fileName.substring(fileName.lastIndexOf("."), fileName.length());
String newFileName = fileId + fileSuffix;
File saveFile = new File(FileSavePath + newFileName);
// FileUtil.copyInputStreamToFile(file.get, saveFile);
FileUtils.moveFile(file,saveFile);
//开始存储文件信息
String tableName = UUIDUtils.getAttTable();
int existTable = this.baseMapper.existTable(tableName);
if (existTable == 0) {
this.baseMapper.creatTableInfo(tableName);
}
fileId = tableName + "_" + fileId;
AttFileEO attFileEO = new AttFileEO();
attFileEO.setTableName(tableName);
attFileEO.setId(fileId);
attFileEO.setOldFileName(fileName);
attFileEO.setFileSuffix(fileSuffix);
attFileEO.setFilePath(uuidPath);
attFileEO.setFileName(newFileName);
attFileEO.setValidFlag(ValidFlagEnum.VALID_TRUE.getValue());
attFileEO.setCreationTime(new Date());
attFileEO.setModifyTime(new Date());
this.baseMapper.insertData(attFileEO);
} catch (IOException e) {
log.error(e.getMessage(),e);
} catch (Exception e) {
log.error(e.getMessage(),e);
} finally {
FileUtil.deleteQuietly(file);
}
return fileId;
}
}
@@ -0,0 +1,90 @@
package com.adc.da.att.vo;
public class AttFileVo {
private String id;
private String fileName;
private String oldFileName;
private String fileSuffix;
private String filePath;
private String attId;
private String name;
//识别文件名中的标准号和名称
private String standNum;
private String standName;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public String getOldFileName() {
return oldFileName;
}
public void setOldFileName(String oldFileName) {
this.oldFileName = oldFileName;
}
public String getFileSuffix() {
return fileSuffix;
}
public void setFileSuffix(String fileSuffix) {
this.fileSuffix = fileSuffix;
}
public String getFilePath() {
return filePath;
}
public void setFilePath(String filePath) {
this.filePath = filePath;
}
public String getName() {
this.name = this.oldFileName;
return this.name;
}
public void setName(String name) {
this.name = name;
}
public String getAttId() {
this.attId=this.id;
return this.attId;
}
public void setAttId(String attId) {
this.attId = attId;
}
public String getStandNum() {
return standNum;
}
public void setStandNum(String standNum) {
this.standNum = standNum;
}
public String getStandName() {
return standName;
}
public void setStandName(String standName) {
this.standName = standName;
}
}