文件缓存,保存路径等
This commit is contained in:
parent
98244fc048
commit
1682de731d
@ -27,6 +27,17 @@
|
|||||||
<version>1.6.2</version>
|
<version>1.6.2</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-test</artifactId>
|
||||||
|
<version>RELEASE</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.httpcomponents</groupId>
|
||||||
|
<artifactId>httpcore</artifactId>
|
||||||
|
<version>4.4.8</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
|
@ -0,0 +1,83 @@
|
|||||||
|
package com.ruoyi.productionManager.domain;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
import com.ruoyi.common.annotation.Excel;
|
||||||
|
import com.ruoyi.common.core.domain.BaseEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 标准信息文件对象 standard_info_details
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2021-10-18
|
||||||
|
*/
|
||||||
|
public class StandardInfoDetails extends BaseEntity
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 标准明细ID */
|
||||||
|
private Long detailsId;
|
||||||
|
|
||||||
|
/** 标准id */
|
||||||
|
private Long standardId;
|
||||||
|
|
||||||
|
/** 文件名称 */
|
||||||
|
@Excel(name = "文件名称")
|
||||||
|
private String fileName;
|
||||||
|
|
||||||
|
/** 文件路径 */
|
||||||
|
@Excel(name = "文件路径")
|
||||||
|
private String fileUrl;
|
||||||
|
|
||||||
|
public void setDetailsId(Long detailsId)
|
||||||
|
{
|
||||||
|
this.detailsId = detailsId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getDetailsId()
|
||||||
|
{
|
||||||
|
return detailsId;
|
||||||
|
}
|
||||||
|
public void setStandardId(Long standardId)
|
||||||
|
{
|
||||||
|
this.standardId = standardId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getStandardId()
|
||||||
|
{
|
||||||
|
return standardId;
|
||||||
|
}
|
||||||
|
public void setFileName(String fileName)
|
||||||
|
{
|
||||||
|
this.fileName = fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFileName()
|
||||||
|
{
|
||||||
|
return fileName;
|
||||||
|
}
|
||||||
|
public void setFileUrl(String fileUrl)
|
||||||
|
{
|
||||||
|
this.fileUrl = fileUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFileUrl()
|
||||||
|
{
|
||||||
|
return fileUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||||
|
.append("detailsId", getDetailsId())
|
||||||
|
.append("standardId", getStandardId())
|
||||||
|
.append("fileName", getFileName())
|
||||||
|
.append("fileUrl", getFileUrl())
|
||||||
|
.append("createBy", getCreateBy())
|
||||||
|
.append("createTime", getCreateTime())
|
||||||
|
.append("updateBy", getUpdateBy())
|
||||||
|
.append("updateTime", getUpdateTime())
|
||||||
|
.append("remark", getRemark())
|
||||||
|
.toString();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,61 @@
|
|||||||
|
package com.ruoyi.productionManager.mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import com.ruoyi.productionManager.domain.StandardInfoDetails;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 标准信息文件Mapper接口
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2021-10-18
|
||||||
|
*/
|
||||||
|
public interface StandardInfoDetailsMapper
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 查询标准信息文件
|
||||||
|
*
|
||||||
|
* @param detailsId 标准信息文件主键
|
||||||
|
* @return 标准信息文件
|
||||||
|
*/
|
||||||
|
public StandardInfoDetails selectStandardInfoDetailsByDetailsId(Long detailsId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询标准信息文件列表
|
||||||
|
*
|
||||||
|
* @param standardInfoDetails 标准信息文件
|
||||||
|
* @return 标准信息文件集合
|
||||||
|
*/
|
||||||
|
public List<StandardInfoDetails> selectStandardInfoDetailsList(StandardInfoDetails standardInfoDetails);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增标准信息文件
|
||||||
|
*
|
||||||
|
* @param standardInfoDetails 标准信息文件
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int insertStandardInfoDetails(StandardInfoDetails standardInfoDetails);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改标准信息文件
|
||||||
|
*
|
||||||
|
* @param standardInfoDetails 标准信息文件
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updateStandardInfoDetails(StandardInfoDetails standardInfoDetails);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除标准信息文件
|
||||||
|
*
|
||||||
|
* @param detailsId 标准信息文件主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteStandardInfoDetailsByDetailsId(Long detailsId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除标准信息文件
|
||||||
|
*
|
||||||
|
* @param detailsIds 需要删除的数据主键集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteStandardInfoDetailsByDetailsIds(Long[] detailsIds);
|
||||||
|
}
|
@ -0,0 +1,61 @@
|
|||||||
|
package com.ruoyi.productionManager.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import com.ruoyi.productionManager.domain.StandardInfoDetails;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 标准信息文件Service接口
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2021-10-18
|
||||||
|
*/
|
||||||
|
public interface IStandardInfoDetailsService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 查询标准信息文件
|
||||||
|
*
|
||||||
|
* @param detailsId 标准信息文件主键
|
||||||
|
* @return 标准信息文件
|
||||||
|
*/
|
||||||
|
public StandardInfoDetails selectStandardInfoDetailsByDetailsId(Long detailsId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询标准信息文件列表
|
||||||
|
*
|
||||||
|
* @param standardInfoDetails 标准信息文件
|
||||||
|
* @return 标准信息文件集合
|
||||||
|
*/
|
||||||
|
public List<StandardInfoDetails> selectStandardInfoDetailsList(StandardInfoDetails standardInfoDetails);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增标准信息文件
|
||||||
|
*
|
||||||
|
* @param standardInfoDetails 标准信息文件
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int insertStandardInfoDetails(StandardInfoDetails standardInfoDetails);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改标准信息文件
|
||||||
|
*
|
||||||
|
* @param standardInfoDetails 标准信息文件
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updateStandardInfoDetails(StandardInfoDetails standardInfoDetails);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除标准信息文件
|
||||||
|
*
|
||||||
|
* @param detailsIds 需要删除的标准信息文件主键集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteStandardInfoDetailsByDetailsIds(Long[] detailsIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除标准信息文件信息
|
||||||
|
*
|
||||||
|
* @param detailsId 标准信息文件主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteStandardInfoDetailsByDetailsId(Long detailsId);
|
||||||
|
}
|
@ -2,6 +2,7 @@ package com.ruoyi.productionManager.service;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.ruoyi.productionManager.domain.StandardInfo;
|
import com.ruoyi.productionManager.domain.StandardInfo;
|
||||||
|
import com.ruoyi.productionManager.vo.StandardManagerVO;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,7 +35,7 @@ public interface IStandardInfoService
|
|||||||
* @param standardInfo 试验标准管理
|
* @param standardInfo 试验标准管理
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int insertStandardInfo(StandardInfo standardInfo);
|
public int insertStandardInfo(StandardManagerVO standardManagerVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改试验标准管理
|
* 修改试验标准管理
|
||||||
|
@ -0,0 +1,96 @@
|
|||||||
|
package com.ruoyi.productionManager.service.impl;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import com.ruoyi.productionManager.mapper.StandardInfoDetailsMapper;
|
||||||
|
import com.ruoyi.productionManager.domain.StandardInfoDetails;
|
||||||
|
import com.ruoyi.productionManager.service.IStandardInfoDetailsService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 标准信息文件Service业务层处理
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2021-10-18
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class StandardInfoDetailsServiceImpl implements IStandardInfoDetailsService
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private StandardInfoDetailsMapper standardInfoDetailsMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询标准信息文件
|
||||||
|
*
|
||||||
|
* @param detailsId 标准信息文件主键
|
||||||
|
* @return 标准信息文件
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public StandardInfoDetails selectStandardInfoDetailsByDetailsId(Long detailsId)
|
||||||
|
{
|
||||||
|
return standardInfoDetailsMapper.selectStandardInfoDetailsByDetailsId(detailsId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询标准信息文件列表
|
||||||
|
*
|
||||||
|
* @param standardInfoDetails 标准信息文件
|
||||||
|
* @return 标准信息文件
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<StandardInfoDetails> selectStandardInfoDetailsList(StandardInfoDetails standardInfoDetails)
|
||||||
|
{
|
||||||
|
return standardInfoDetailsMapper.selectStandardInfoDetailsList(standardInfoDetails);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增标准信息文件
|
||||||
|
*
|
||||||
|
* @param standardInfoDetails 标准信息文件
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int insertStandardInfoDetails(StandardInfoDetails standardInfoDetails)
|
||||||
|
{
|
||||||
|
standardInfoDetails.setCreateTime(DateUtils.getNowDate());
|
||||||
|
return standardInfoDetailsMapper.insertStandardInfoDetails(standardInfoDetails);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改标准信息文件
|
||||||
|
*
|
||||||
|
* @param standardInfoDetails 标准信息文件
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int updateStandardInfoDetails(StandardInfoDetails standardInfoDetails)
|
||||||
|
{
|
||||||
|
standardInfoDetails.setUpdateTime(DateUtils.getNowDate());
|
||||||
|
return standardInfoDetailsMapper.updateStandardInfoDetails(standardInfoDetails);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除标准信息文件
|
||||||
|
*
|
||||||
|
* @param detailsIds 需要删除的标准信息文件主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int deleteStandardInfoDetailsByDetailsIds(Long[] detailsIds)
|
||||||
|
{
|
||||||
|
return standardInfoDetailsMapper.deleteStandardInfoDetailsByDetailsIds(detailsIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除标准信息文件信息
|
||||||
|
*
|
||||||
|
* @param detailsId 标准信息文件主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int deleteStandardInfoDetailsByDetailsId(Long detailsId)
|
||||||
|
{
|
||||||
|
return standardInfoDetailsMapper.deleteStandardInfoDetailsByDetailsId(detailsId);
|
||||||
|
}
|
||||||
|
}
|
@ -1,24 +1,32 @@
|
|||||||
package com.ruoyi.productionManager.service.impl;
|
package com.ruoyi.productionManager.service.impl;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import com.ruoyi.common.config.RuoYiConfig;
|
import com.ruoyi.common.config.RuoYiConfig;
|
||||||
import com.ruoyi.common.constant.Constants;
|
import com.ruoyi.common.constant.Constants;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
|
||||||
import com.ruoyi.common.core.redis.RedisCache;
|
import com.ruoyi.common.core.redis.RedisCache;
|
||||||
import com.ruoyi.common.exception.ServiceException;
|
import com.ruoyi.common.exception.ServiceException;
|
||||||
import com.ruoyi.common.utils.DateUtils;
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
|
import com.ruoyi.common.utils.file.FileTypeUtils;
|
||||||
import com.ruoyi.common.utils.file.FileUploadUtils;
|
import com.ruoyi.common.utils.file.FileUploadUtils;
|
||||||
import com.ruoyi.common.utils.uuid.IdUtils;
|
import com.ruoyi.common.utils.uuid.IdUtils;
|
||||||
import io.netty.handler.codec.base64.Base64;
|
import com.ruoyi.productionManager.domain.StandardInfoDetails;
|
||||||
|
import com.ruoyi.productionManager.service.IStandardInfoDetailsService;
|
||||||
|
import com.ruoyi.productionManager.vo.StandardManagerVO;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.mock.web.MockMultipartFile;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.ruoyi.productionManager.mapper.StandardInfoMapper;
|
import com.ruoyi.productionManager.mapper.StandardInfoMapper;
|
||||||
import com.ruoyi.productionManager.domain.StandardInfo;
|
import com.ruoyi.productionManager.domain.StandardInfo;
|
||||||
import com.ruoyi.productionManager.service.IStandardInfoService;
|
import com.ruoyi.productionManager.service.IStandardInfoService;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import sun.misc.BASE64Encoder;
|
import org.apache.http.entity.ContentType;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 试验标准管理Service业务层处理
|
* 试验标准管理Service业务层处理
|
||||||
@ -35,6 +43,9 @@ public class StandardInfoServiceImpl implements IStandardInfoService
|
|||||||
@Autowired
|
@Autowired
|
||||||
private RedisCache redisCache;
|
private RedisCache redisCache;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IStandardInfoDetailsService standardInfoDetailsService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询试验标准管理
|
* 查询试验标准管理
|
||||||
*
|
*
|
||||||
@ -62,14 +73,48 @@ public class StandardInfoServiceImpl implements IStandardInfoService
|
|||||||
/**
|
/**
|
||||||
* 新增试验标准管理
|
* 新增试验标准管理
|
||||||
*
|
*
|
||||||
* @param standardInfo 试验标准管理
|
* @param standardManagerVO 试验标准管理
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int insertStandardInfo(StandardInfo standardInfo)
|
public int insertStandardInfo(StandardManagerVO standardManagerVO)
|
||||||
{
|
{
|
||||||
standardInfo.setCreateTime(DateUtils.getNowDate());
|
String filePath = RuoYiConfig.getUploadPath();
|
||||||
return standardInfoMapper.insertStandardInfo(standardInfo);
|
// 取出缓存数据
|
||||||
|
String name = "";
|
||||||
|
String fileName = "";
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
// String s:standardManagerVO.getPath().split("/",9)
|
||||||
|
String[] str = standardManagerVO.getPath().split("/",6);
|
||||||
|
for(int i=0;i<str.length;i++){
|
||||||
|
System.out.println("name>>>"+str[i]);
|
||||||
|
if(i>=2){
|
||||||
|
sb.append("/");
|
||||||
|
sb.append(str[i]);
|
||||||
|
}
|
||||||
|
name = str[i];
|
||||||
|
}
|
||||||
|
System.out.println("sb>>>"+sb.toString());
|
||||||
|
try{
|
||||||
|
byte[] bytes = redisCache.getCacheObject(Constants.UPLOAD_FILE+name);
|
||||||
|
InputStream inputStream = new ByteArrayInputStream(bytes);
|
||||||
|
// String fileType = FileTypeUtils.getType(bytes);
|
||||||
|
MultipartFile files = new MockMultipartFile(ContentType.APPLICATION_OCTET_STREAM.toString(), inputStream);
|
||||||
|
fileName = sb.toString();
|
||||||
|
File desc = FileUploadUtils.getAbsoluteFile(filePath, fileName);
|
||||||
|
files.transferTo(desc);
|
||||||
|
standardManagerVO.setCreateTime(DateUtils.getNowDate());
|
||||||
|
|
||||||
|
standardInfoMapper.insertStandardInfo(standardManagerVO);
|
||||||
|
StandardInfoDetails standardInfoDetails = new StandardInfoDetails();
|
||||||
|
standardInfoDetails.setFileUrl(filePath+fileName);
|
||||||
|
standardInfoDetails.setFileName(name);
|
||||||
|
standardInfoDetails.setStandardId(standardManagerVO.getStandardId());
|
||||||
|
standardInfoDetails.setCreateBy(SecurityUtils.getLoginUser().getUsername());
|
||||||
|
return standardInfoDetailsService.insertStandardInfoDetails(standardInfoDetails);
|
||||||
|
}catch (Exception e){
|
||||||
|
throw new ServiceException("新增失败:" + e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -113,7 +158,6 @@ public class StandardInfoServiceImpl implements IStandardInfoService
|
|||||||
public String uploadFile(MultipartFile file) {
|
public String uploadFile(MultipartFile file) {
|
||||||
try {
|
try {
|
||||||
String filePath = RuoYiConfig.getUploadPath();
|
String filePath = RuoYiConfig.getUploadPath();
|
||||||
IdUtils.fastUUID();
|
|
||||||
// 上传并返回新文件名称
|
// 上传并返回新文件名称
|
||||||
String fileName = FileUploadUtils.upload(filePath, file);
|
String fileName = FileUploadUtils.upload(filePath, file);
|
||||||
String name ="";
|
String name ="";
|
||||||
@ -121,12 +165,18 @@ public class StandardInfoServiceImpl implements IStandardInfoService
|
|||||||
System.out.println("path>>>"+s);
|
System.out.println("path>>>"+s);
|
||||||
name = s;
|
name = s;
|
||||||
}
|
}
|
||||||
Byte[] data = new Byte[file.getResource().getInputStream().available()];
|
|
||||||
|
byte[] data = file.getBytes();
|
||||||
|
// Byte[] data = new Byte[file.getResource().getInputStream().available()];
|
||||||
|
|
||||||
redisCache.setCacheObject(Constants.UPLOAD_FILE+name,
|
redisCache.setCacheObject(Constants.UPLOAD_FILE+name,
|
||||||
data, 30, TimeUnit.MINUTES);
|
data, 30, TimeUnit.MINUTES);
|
||||||
// 取出缓存数据
|
// byte[] bytes = redisCache.getCacheObject(Constants.UPLOAD_FILE+name);
|
||||||
Byte[] bytes = redisCache.getCacheObject(Constants.UPLOAD_FILE+name);
|
// InputStream inputStream = new ByteArrayInputStream(bytes);
|
||||||
|
// String fileType = FileTypeUtils.getType(bytes);
|
||||||
|
// MultipartFile testFiles = new MockMultipartFile(ContentType.APPLICATION_OCTET_STREAM.toString(), inputStream);
|
||||||
|
// File desc = FileUploadUtils.getAbsoluteFile(filePath, name);
|
||||||
|
// testFiles.transferTo(desc);
|
||||||
return fileName;
|
return fileName;
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
throw new ServiceException("上传失败:" + e.getMessage());
|
throw new ServiceException("上传失败:" + e.getMessage());
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
package com.ruoyi.productionManager.vo;
|
||||||
|
|
||||||
|
import com.ruoyi.productionManager.domain.StandardInfo;
|
||||||
|
|
||||||
|
public class StandardManagerVO extends StandardInfo {
|
||||||
|
private static final long serialVersionUID = -5124848255962397905L;
|
||||||
|
|
||||||
|
private String path;
|
||||||
|
|
||||||
|
public void setPath(String path) {
|
||||||
|
this.path = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPath() {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "StandardManagerVO{" +
|
||||||
|
"path='" + path + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,85 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.ruoyi.productionManager.mapper.StandardInfoDetailsMapper">
|
||||||
|
|
||||||
|
<resultMap type="StandardInfoDetails" id="StandardInfoDetailsResult">
|
||||||
|
<result property="detailsId" column="details_id" />
|
||||||
|
<result property="standardId" column="standard_id" />
|
||||||
|
<result property="fileName" column="file_name" />
|
||||||
|
<result property="fileUrl" column="file_url" />
|
||||||
|
<result property="createBy" column="create_by" />
|
||||||
|
<result property="createTime" column="create_time" />
|
||||||
|
<result property="updateBy" column="update_by" />
|
||||||
|
<result property="updateTime" column="update_time" />
|
||||||
|
<result property="remark" column="remark" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="selectStandardInfoDetailsVo">
|
||||||
|
select details_id, standard_id, file_name, file_url, create_by, create_time, update_by, update_time, remark from standard_info_details
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectStandardInfoDetailsList" parameterType="StandardInfoDetails" resultMap="StandardInfoDetailsResult">
|
||||||
|
<include refid="selectStandardInfoDetailsVo"/>
|
||||||
|
<where>
|
||||||
|
<if test="fileName != null and fileName != ''"> and file_name like concat('%', #{fileName}, '%')</if>
|
||||||
|
<if test="fileUrl != null and fileUrl != ''"> and file_url = #{fileUrl}</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectStandardInfoDetailsByDetailsId" parameterType="Long" resultMap="StandardInfoDetailsResult">
|
||||||
|
<include refid="selectStandardInfoDetailsVo"/>
|
||||||
|
where details_id = #{detailsId}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertStandardInfoDetails" parameterType="StandardInfoDetails" useGeneratedKeys="true" keyProperty="detailsId">
|
||||||
|
insert into standard_info_details
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="standardId != null">standard_id,</if>
|
||||||
|
<if test="fileName != null and fileName != ''">file_name,</if>
|
||||||
|
<if test="fileUrl != null and fileUrl != ''">file_url,</if>
|
||||||
|
<if test="createBy != null">create_by,</if>
|
||||||
|
<if test="createTime != null">create_time,</if>
|
||||||
|
<if test="updateBy != null">update_by,</if>
|
||||||
|
<if test="updateTime != null">update_time,</if>
|
||||||
|
<if test="remark != null">remark,</if>
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="standardId != null">#{standardId},</if>
|
||||||
|
<if test="fileName != null and fileName != ''">#{fileName},</if>
|
||||||
|
<if test="fileUrl != null and fileUrl != ''">#{fileUrl},</if>
|
||||||
|
<if test="createBy != null">#{createBy},</if>
|
||||||
|
<if test="createTime != null">#{createTime},</if>
|
||||||
|
<if test="updateBy != null">#{updateBy},</if>
|
||||||
|
<if test="updateTime != null">#{updateTime},</if>
|
||||||
|
<if test="remark != null">#{remark},</if>
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<update id="updateStandardInfoDetails" parameterType="StandardInfoDetails">
|
||||||
|
update standard_info_details
|
||||||
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
|
<if test="standardId != null">standard_id = #{standardId},</if>
|
||||||
|
<if test="fileName != null and fileName != ''">file_name = #{fileName},</if>
|
||||||
|
<if test="fileUrl != null and fileUrl != ''">file_url = #{fileUrl},</if>
|
||||||
|
<if test="createBy != null">create_by = #{createBy},</if>
|
||||||
|
<if test="createTime != null">create_time = #{createTime},</if>
|
||||||
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||||
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||||
|
<if test="remark != null">remark = #{remark},</if>
|
||||||
|
</trim>
|
||||||
|
where details_id = #{detailsId}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<delete id="deleteStandardInfoDetailsByDetailsId" parameterType="Long">
|
||||||
|
delete from standard_info_details where details_id = #{detailsId}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<delete id="deleteStandardInfoDetailsByDetailsIds" parameterType="String">
|
||||||
|
delete from standard_info_details where details_id in
|
||||||
|
<foreach item="detailsId" collection="array" open="(" separator="," close=")">
|
||||||
|
#{detailsId}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
</mapper>
|
@ -38,9 +38,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
where standard_id = #{standardId}
|
where standard_id = #{standardId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<insert id="insertStandardInfo" parameterType="StandardInfo" useGeneratedKeys="true" keyProperty="standardId">
|
<insert id="insertStandardInfo"
|
||||||
|
parameterType="StandardInfo" useGeneratedKeys="true" keyProperty="standardId">
|
||||||
|
<selectKey resultType="java.lang.Long" keyProperty="standardId" order="AFTER" >
|
||||||
|
SELECT LAST_INSERT_ID()
|
||||||
|
</selectKey>
|
||||||
insert into standard_info
|
insert into standard_info
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<!--<if test="standardId != null and standardId != ''">standard_id,</if>-->
|
||||||
<if test="areaCategory != null and areaCategory != ''">area_category,</if>
|
<if test="areaCategory != null and areaCategory != ''">area_category,</if>
|
||||||
<if test="standardName != null and standardName != ''">standard_name,</if>
|
<if test="standardName != null and standardName != ''">standard_name,</if>
|
||||||
<if test="standardCategory != null and standardCategory != ''">standard_category,</if>
|
<if test="standardCategory != null and standardCategory != ''">standard_category,</if>
|
||||||
|
@ -7,6 +7,7 @@ import com.ruoyi.common.constant.Constants;
|
|||||||
import com.ruoyi.common.utils.file.FileUploadUtils;
|
import com.ruoyi.common.utils.file.FileUploadUtils;
|
||||||
import com.ruoyi.framework.config.ServerConfig;
|
import com.ruoyi.framework.config.ServerConfig;
|
||||||
import com.ruoyi.productionManager.domain.StandardInfo;
|
import com.ruoyi.productionManager.domain.StandardInfo;
|
||||||
|
import com.ruoyi.productionManager.vo.StandardManagerVO;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -83,8 +84,9 @@ public class StandardInfoController extends BaseController
|
|||||||
@PreAuthorize("@ss.hasPermi('productionManager:standard:add')")
|
@PreAuthorize("@ss.hasPermi('productionManager:standard:add')")
|
||||||
@Log(title = "试验标准管理", businessType = BusinessType.INSERT)
|
@Log(title = "试验标准管理", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@RequestBody StandardInfo standardInfo)
|
public AjaxResult add(@RequestBody StandardManagerVO standardInfo)
|
||||||
{
|
{
|
||||||
|
standardInfo.setCreateBy(getUsername());
|
||||||
return toAjax(standardInfoService.insertStandardInfo(standardInfo));
|
return toAjax(standardInfoService.insertStandardInfo(standardInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,103 @@
|
|||||||
|
package com.ruoyi.web.controller.productionManager;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import com.ruoyi.common.annotation.Log;
|
||||||
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
|
import com.ruoyi.productionManager.domain.StandardInfoDetails;
|
||||||
|
import com.ruoyi.productionManager.service.IStandardInfoDetailsService;
|
||||||
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 标准信息文件Controller
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2021-10-18
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/productionManager/details")
|
||||||
|
public class StandardInfoDetailsController extends BaseController
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private IStandardInfoDetailsService standardInfoDetailsService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询标准信息文件列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('productionManager:details:list')")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public TableDataInfo list(StandardInfoDetails standardInfoDetails)
|
||||||
|
{
|
||||||
|
startPage();
|
||||||
|
List<StandardInfoDetails> list = standardInfoDetailsService.selectStandardInfoDetailsList(standardInfoDetails);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出标准信息文件列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('productionManager:details:export')")
|
||||||
|
@Log(title = "标准信息文件", businessType = BusinessType.EXPORT)
|
||||||
|
@GetMapping("/export")
|
||||||
|
public AjaxResult export(StandardInfoDetails standardInfoDetails)
|
||||||
|
{
|
||||||
|
List<StandardInfoDetails> list = standardInfoDetailsService.selectStandardInfoDetailsList(standardInfoDetails);
|
||||||
|
ExcelUtil<StandardInfoDetails> util = new ExcelUtil<StandardInfoDetails>(StandardInfoDetails.class);
|
||||||
|
return util.exportExcel(list, "标准信息文件数据");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取标准信息文件详细信息
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('productionManager:details:query')")
|
||||||
|
@GetMapping(value = "/{detailsId}")
|
||||||
|
public AjaxResult getInfo(@PathVariable("detailsId") Long detailsId)
|
||||||
|
{
|
||||||
|
return AjaxResult.success(standardInfoDetailsService.selectStandardInfoDetailsByDetailsId(detailsId));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增标准信息文件
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('productionManager:details:add')")
|
||||||
|
@Log(title = "标准信息文件", businessType = BusinessType.INSERT)
|
||||||
|
@PostMapping
|
||||||
|
public AjaxResult add(@RequestBody StandardInfoDetails standardInfoDetails)
|
||||||
|
{
|
||||||
|
return toAjax(standardInfoDetailsService.insertStandardInfoDetails(standardInfoDetails));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改标准信息文件
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('productionManager:details:edit')")
|
||||||
|
@Log(title = "标准信息文件", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping
|
||||||
|
public AjaxResult edit(@RequestBody StandardInfoDetails standardInfoDetails)
|
||||||
|
{
|
||||||
|
return toAjax(standardInfoDetailsService.updateStandardInfoDetails(standardInfoDetails));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除标准信息文件
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('productionManager:details:remove')")
|
||||||
|
@Log(title = "标准信息文件", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{detailsIds}")
|
||||||
|
public AjaxResult remove(@PathVariable Long[] detailsIds)
|
||||||
|
{
|
||||||
|
return toAjax(standardInfoDetailsService.deleteStandardInfoDetailsByDetailsIds(detailsIds));
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,8 @@
|
|||||||
package com.ruoyi.common.utils.file;
|
package com.ruoyi.common.utils.file;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -10,6 +12,42 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
*/
|
*/
|
||||||
public class FileTypeUtils
|
public class FileTypeUtils
|
||||||
{
|
{
|
||||||
|
// 缓存文件头信息-文件头信息
|
||||||
|
public static final HashMap<String, String> FILE_TYPE_MAP= new HashMap<>();
|
||||||
|
static {
|
||||||
|
FILE_TYPE_MAP.put("jpg", "FFD8FF"); //JPEG (jpg)
|
||||||
|
FILE_TYPE_MAP.put("png", "89504E47"); //PNG (png)
|
||||||
|
FILE_TYPE_MAP.put("gif", "47494638"); //GIF (gif)
|
||||||
|
FILE_TYPE_MAP.put("tif", "49492A00"); //TIFF (tif)
|
||||||
|
FILE_TYPE_MAP.put("bmp", "424D"); //Windows Bitmap (bmp)
|
||||||
|
FILE_TYPE_MAP.put("dwg", "41433130"); //CAD (dwg)
|
||||||
|
FILE_TYPE_MAP.put("html", "68746D6C3E"); //HTML (html)
|
||||||
|
FILE_TYPE_MAP.put("rtf", "7B5C727466"); //Rich Text Format (rtf)
|
||||||
|
FILE_TYPE_MAP.put("xml", "3C3F786D6C");
|
||||||
|
FILE_TYPE_MAP.put("zip", "504B0304");
|
||||||
|
FILE_TYPE_MAP.put("rar", "52617221");
|
||||||
|
FILE_TYPE_MAP.put("psd", "38425053"); //Photoshop (psd)
|
||||||
|
FILE_TYPE_MAP.put("eml", "44656C69766572792D646174653A"); //Email [thorough only] (eml)
|
||||||
|
FILE_TYPE_MAP.put("dbx", "CFAD12FEC5FD746F"); //Outlook Express (dbx)
|
||||||
|
FILE_TYPE_MAP.put("pst", "2142444E"); //Outlook (pst)
|
||||||
|
FILE_TYPE_MAP.put("xls", "D0CF11E0"); //MS Word
|
||||||
|
FILE_TYPE_MAP.put("doc", "D0CF11E0"); //MS Excel 注意:word 和 excel的文件头一样
|
||||||
|
FILE_TYPE_MAP.put("mdb", "5374616E64617264204A"); //MS Access (mdb)
|
||||||
|
FILE_TYPE_MAP.put("wpd", "FF575043"); //WordPerfect (wpd)
|
||||||
|
FILE_TYPE_MAP.put("eps", "252150532D41646F6265");
|
||||||
|
FILE_TYPE_MAP.put("ps", "252150532D41646F6265");
|
||||||
|
FILE_TYPE_MAP.put("pdf", "255044462D312E"); //Adobe Acrobat (pdf)
|
||||||
|
FILE_TYPE_MAP.put("qdf", "AC9EBD8F"); //Quicken (qdf)
|
||||||
|
FILE_TYPE_MAP.put("pwl", "E3828596"); //Windows Password (pwl)
|
||||||
|
FILE_TYPE_MAP.put("wav", "57415645"); //Wave (wav)
|
||||||
|
FILE_TYPE_MAP.put("avi", "41564920");
|
||||||
|
FILE_TYPE_MAP.put("ram", "2E7261FD"); //Real Audio (ram)
|
||||||
|
FILE_TYPE_MAP.put("rm", "2E524D46"); //Real Media (rm)
|
||||||
|
FILE_TYPE_MAP.put("mpg", "000001BA"); //
|
||||||
|
FILE_TYPE_MAP.put("mov", "6D6F6F76"); //Quicktime (mov)
|
||||||
|
FILE_TYPE_MAP.put("asf", "3026B2758E66CF11"); //Windows Media (asf)
|
||||||
|
FILE_TYPE_MAP.put("mid", "4D546864"); //MIDI (mid)
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 获取文件类型
|
* 获取文件类型
|
||||||
* <p>
|
* <p>
|
||||||
@ -73,4 +111,58 @@ public class FileTypeUtils
|
|||||||
}
|
}
|
||||||
return strFileExtendName;
|
return strFileExtendName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 方法描述:将要读取文件头信息的文件的byte数组转换成string类型表示
|
||||||
|
*
|
||||||
|
* 要读取文件头信息的文件的byte数组
|
||||||
|
*
|
||||||
|
* @return 文件头信息
|
||||||
|
* @param src
|
||||||
|
* @return
|
||||||
|
* @author:chengjx
|
||||||
|
* @createTime:2021年10月18日 下午5:08:23
|
||||||
|
*/
|
||||||
|
public static String bytesToHexString(byte[] src) {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
if (src == null || src.length <= 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
String hv;
|
||||||
|
for (int i = 0; i < src.length; i++) {
|
||||||
|
// 以十六进制(基数 16)无符号整数形式返回一个整数参数的字符串表示形式,并转换为大写
|
||||||
|
hv = Integer.toHexString(src[i] & 0xFF).toUpperCase();
|
||||||
|
if (hv.length() < 2) {
|
||||||
|
builder.append(0);
|
||||||
|
}
|
||||||
|
builder.append(hv);
|
||||||
|
}
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getType(byte[] bytes){
|
||||||
|
String s = bytesToHexString(bytes);
|
||||||
|
s = s.toUpperCase();
|
||||||
|
String type;
|
||||||
|
if (s.startsWith(FileTypeUtils.FILE_TYPE_MAP.get("jpg"))) {
|
||||||
|
type = "jpg";
|
||||||
|
} else if (s.startsWith(FileTypeUtils.FILE_TYPE_MAP.get("png"))) {
|
||||||
|
type = "png";
|
||||||
|
} else if (s.startsWith(FileTypeUtils.FILE_TYPE_MAP.get("gif"))) {
|
||||||
|
type = "gif";
|
||||||
|
} else if (s.startsWith(FileTypeUtils.FILE_TYPE_MAP.get("tif"))) {
|
||||||
|
type = "tif";
|
||||||
|
} else if(s.startsWith(FileTypeUtils.FILE_TYPE_MAP.get("bmp"))){
|
||||||
|
type = "bmp";
|
||||||
|
} else if(s.startsWith(FileTypeUtils.FILE_TYPE_MAP.get("pdf"))){
|
||||||
|
type = "pdf";
|
||||||
|
} else if(s.startsWith(FileTypeUtils.FILE_TYPE_MAP.get("xml"))){
|
||||||
|
type = "xml";
|
||||||
|
}else {
|
||||||
|
type = "undefined";
|
||||||
|
}
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user