diff --git a/pom.xml b/pom.xml index 6feb0ee79..199aa1da1 100644 --- a/pom.xml +++ b/pom.xml @@ -205,6 +205,11 @@ <version>${ruoyi.version}</version> </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-data-mongodb</artifactId> + </dependency> + </dependencies> </dependencyManagement> @@ -215,6 +220,7 @@ <module>ruoyi-quartz</module> <module>ruoyi-generator</module> <module>ruoyi-common</module> + <module>productManager</module> </modules> <packaging>pom</packaging> diff --git a/productManager/pom.xml b/productManager/pom.xml new file mode 100644 index 000000000..a46bad5e0 --- /dev/null +++ b/productManager/pom.xml @@ -0,0 +1,44 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <artifactId>ruoyi</artifactId> + <groupId>com.ruoyi</groupId> + <version>3.7.0</version> + </parent> + <modelVersion>4.0.0</modelVersion> + + <artifactId>productManager</artifactId> + <dependencies> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-web</artifactId> + <version>5.3.10</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>com.ruoyi</groupId> + <artifactId>ruoyi-common</artifactId> + </dependency> + <dependency> + <groupId>io.swagger</groupId> + <artifactId>swagger-annotations</artifactId> + <version>1.6.2</version> + <scope>compile</scope> + </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> + + +</project> \ No newline at end of file diff --git a/productManager/src/main/java/com/ruoyi/productionManager/domain/StandardInfo.java b/productManager/src/main/java/com/ruoyi/productionManager/domain/StandardInfo.java new file mode 100644 index 000000000..ad2a69130 --- /dev/null +++ b/productManager/src/main/java/com/ruoyi/productionManager/domain/StandardInfo.java @@ -0,0 +1,112 @@ +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 + * + * @author ruoyi + * @date 2021-10-13 + */ +public class StandardInfo extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 标准id */ + private Long standardId; + + /** 区域分类 */ + @Excel(name = "区域分类") + private String areaCategory; + + /** 标准名称 */ + @Excel(name = "标准名称") + private String standardName; + + /** 标准类型 */ + @Excel(name = "标准类型") + private String standardCategory; + + /** 实施日期 */ + @Excel(name = "实施日期") + private String standardBeginDate; + + /** 标准状态 */ + @Excel(name = "标准状态") + private String standardStatus; + + public void setStandardId(Long standardId) + { + this.standardId = standardId; + } + + public Long getStandardId() + { + return standardId; + } + public void setAreaCategory(String areaCategory) + { + this.areaCategory = areaCategory; + } + + public String getAreaCategory() + { + return areaCategory; + } + public void setStandardName(String standardName) + { + this.standardName = standardName; + } + + public String getStandardName() + { + return standardName; + } + public void setStandardCategory(String standardCategory) + { + this.standardCategory = standardCategory; + } + + public String getStandardCategory() + { + return standardCategory; + } + public void setStandardBeginDate(String standardBeginDate) + { + this.standardBeginDate = standardBeginDate; + } + + public String getStandardBeginDate() + { + return standardBeginDate; + } + public void setStandardStatus(String standardStatus) + { + this.standardStatus = standardStatus; + } + + public String getStandardStatus() + { + return standardStatus; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("standardId", getStandardId()) + .append("areaCategory", getAreaCategory()) + .append("standardName", getStandardName()) + .append("standardCategory", getStandardCategory()) + .append("standardBeginDate", getStandardBeginDate()) + .append("standardStatus", getStandardStatus()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); + } +} diff --git a/productManager/src/main/java/com/ruoyi/productionManager/domain/StandardInfoDetails.java b/productManager/src/main/java/com/ruoyi/productionManager/domain/StandardInfoDetails.java new file mode 100644 index 000000000..dac9cd52c --- /dev/null +++ b/productManager/src/main/java/com/ruoyi/productionManager/domain/StandardInfoDetails.java @@ -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(); + } +} diff --git a/productManager/src/main/java/com/ruoyi/productionManager/mapper/StandardInfoDetailsMapper.java b/productManager/src/main/java/com/ruoyi/productionManager/mapper/StandardInfoDetailsMapper.java new file mode 100644 index 000000000..9830ce462 --- /dev/null +++ b/productManager/src/main/java/com/ruoyi/productionManager/mapper/StandardInfoDetailsMapper.java @@ -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); +} diff --git a/productManager/src/main/java/com/ruoyi/productionManager/mapper/StandardInfoMapper.java b/productManager/src/main/java/com/ruoyi/productionManager/mapper/StandardInfoMapper.java new file mode 100644 index 000000000..d34e81781 --- /dev/null +++ b/productManager/src/main/java/com/ruoyi/productionManager/mapper/StandardInfoMapper.java @@ -0,0 +1,61 @@ +package com.ruoyi.productionManager.mapper; + +import java.util.List; +import com.ruoyi.productionManager.domain.StandardInfo; + +/** + * 试验标准管理Mapper接口 + * + * @author ruoyi + * @date 2021-10-13 + */ +public interface StandardInfoMapper +{ + /** + * 查询试验标准管理 + * + * @param standardId 试验标准管理主键 + * @return 试验标准管理 + */ + public StandardInfo selectStandardInfoByStandardId(Long standardId); + + /** + * 查询试验标准管理列表 + * + * @param standardInfo 试验标准管理 + * @return 试验标准管理集合 + */ + public List<StandardInfo> selectStandardInfoList(StandardInfo standardInfo); + + /** + * 新增试验标准管理 + * + * @param standardInfo 试验标准管理 + * @return 结果 + */ + public int insertStandardInfo(StandardInfo standardInfo); + + /** + * 修改试验标准管理 + * + * @param standardInfo 试验标准管理 + * @return 结果 + */ + public int updateStandardInfo(StandardInfo standardInfo); + + /** + * 删除试验标准管理 + * + * @param standardId 试验标准管理主键 + * @return 结果 + */ + public int deleteStandardInfoByStandardId(Long standardId); + + /** + * 批量删除试验标准管理 + * + * @param standardIds 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteStandardInfoByStandardIds(Long[] standardIds); +} diff --git a/productManager/src/main/java/com/ruoyi/productionManager/service/IStandardInfoDetailsService.java b/productManager/src/main/java/com/ruoyi/productionManager/service/IStandardInfoDetailsService.java new file mode 100644 index 000000000..c5a903391 --- /dev/null +++ b/productManager/src/main/java/com/ruoyi/productionManager/service/IStandardInfoDetailsService.java @@ -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); +} diff --git a/productManager/src/main/java/com/ruoyi/productionManager/service/IStandardInfoService.java b/productManager/src/main/java/com/ruoyi/productionManager/service/IStandardInfoService.java new file mode 100644 index 000000000..4e5a137d7 --- /dev/null +++ b/productManager/src/main/java/com/ruoyi/productionManager/service/IStandardInfoService.java @@ -0,0 +1,70 @@ +package com.ruoyi.productionManager.service; + +import java.util.List; +import com.ruoyi.productionManager.domain.StandardInfo; +import com.ruoyi.productionManager.vo.StandardManagerVO; +import org.springframework.web.multipart.MultipartFile; + +/** + * 试验标准管理Service接口 + * + * @author ruoyi + * @date 2021-10-13 + */ +public interface IStandardInfoService +{ + /** + * 查询试验标准管理 + * + * @param standardId 试验标准管理主键 + * @return 试验标准管理 + */ + public StandardInfo selectStandardInfoByStandardId(Long standardId); + + /** + * 查询试验标准管理列表 + * + * @param standardInfo 试验标准管理 + * @return 试验标准管理集合 + */ + public List<StandardInfo> selectStandardInfoList(StandardInfo standardInfo); + + /** + * 新增试验标准管理 + * + * @param standardInfo 试验标准管理 + * @return 结果 + */ + public int insertStandardInfo(StandardManagerVO standardManagerVO); + + /** + * 修改试验标准管理 + * + * @param standardInfo 试验标准管理 + * @return 结果 + */ + public int updateStandardInfo(StandardManagerVO standardManagerVO); + + /** + * 批量删除试验标准管理 + * + * @param standardIds 需要删除的试验标准管理主键集合 + * @return 结果 + */ + public int deleteStandardInfoByStandardIds(Long[] standardIds); + + /** + * 删除试验标准管理信息 + * + * @param standardId 试验标准管理主键 + * @return 结果 + */ + public int deleteStandardInfoByStandardId(Long standardId); + + /** + * 上传文件 + * @param file + * @return + */ + public String uploadFile(MultipartFile file); +} diff --git a/productManager/src/main/java/com/ruoyi/productionManager/service/impl/StandardInfoDetailsServiceImpl.java b/productManager/src/main/java/com/ruoyi/productionManager/service/impl/StandardInfoDetailsServiceImpl.java new file mode 100644 index 000000000..32d258a3b --- /dev/null +++ b/productManager/src/main/java/com/ruoyi/productionManager/service/impl/StandardInfoDetailsServiceImpl.java @@ -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); + } +} diff --git a/productManager/src/main/java/com/ruoyi/productionManager/service/impl/StandardInfoServiceImpl.java b/productManager/src/main/java/com/ruoyi/productionManager/service/impl/StandardInfoServiceImpl.java new file mode 100644 index 000000000..93b0e98c9 --- /dev/null +++ b/productManager/src/main/java/com/ruoyi/productionManager/service/impl/StandardInfoServiceImpl.java @@ -0,0 +1,231 @@ +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.concurrent.TimeUnit; + +import com.ruoyi.common.config.RuoYiConfig; +import com.ruoyi.common.constant.Constants; +import com.ruoyi.common.core.redis.RedisCache; +import com.ruoyi.common.exception.ServiceException; +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.uuid.IdUtils; +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.mock.web.MockMultipartFile; +import org.springframework.stereotype.Service; +import com.ruoyi.productionManager.mapper.StandardInfoMapper; +import com.ruoyi.productionManager.domain.StandardInfo; +import com.ruoyi.productionManager.service.IStandardInfoService; +import org.springframework.util.Assert; +import org.springframework.web.multipart.MultipartFile; +import org.apache.http.entity.ContentType; + + +/** + * 试验标准管理Service业务层处理 + * + * @author ruoyi + * @date 2021-10-13 + */ +@Service +public class StandardInfoServiceImpl implements IStandardInfoService +{ + @Autowired + private StandardInfoMapper standardInfoMapper; + + @Autowired + private RedisCache redisCache; + + @Autowired + private IStandardInfoDetailsService standardInfoDetailsService; + + /** + * 查询试验标准管理 + * + * @param standardId 试验标准管理主键 + * @return 试验标准管理 + */ + @Override + public StandardInfo selectStandardInfoByStandardId(Long standardId) + { + return standardInfoMapper.selectStandardInfoByStandardId(standardId); + } + + /** + * 查询试验标准管理列表 + * + * @param standardInfo 试验标准管理 + * @return 试验标准管理 + */ + @Override + public List<StandardInfo> selectStandardInfoList(StandardInfo standardInfo) + { + return standardInfoMapper.selectStandardInfoList(standardInfo); + } + + /** + * 新增试验标准管理 + * + * @param standardManagerVO 试验标准管理 + * @return 结果 + */ + @Override + public int insertStandardInfo(StandardManagerVO standardManagerVO) + { + String filePath = RuoYiConfig.getUploadPath(); + // 取出缓存数据 + String name = ""; + String fileName = ""; + StringBuffer sb = new StringBuffer(); + Assert.notNull(standardManagerVO.getPath(),"文件未上传!"); +// String s:standardManagerVO.getPath().split("/",9) + String[] str = standardManagerVO.getPath().split("/",6); + for(int i=0;i<str.length;i++){ + if(i>=2){ + sb.append("/"); + sb.append(str[i]); + } + name = str[i]; + } + try{ + byte[] bytes = redisCache.getCacheObject(Constants.UPLOAD_FILE+name); + String s = redisCache.getCacheObject(Constants.UPLOAD_FILE_NAME+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(s); + standardInfoDetails.setStandardId(standardManagerVO.getStandardId()); + standardInfoDetails.setCreateBy(SecurityUtils.getLoginUser().getUsername()); + redisCache.deleteObject(Constants.UPLOAD_FILE+name); + redisCache.deleteObject(Constants.UPLOAD_FILE_NAME+name); + return standardInfoDetailsService.insertStandardInfoDetails(standardInfoDetails); + }catch (NullPointerException e){ + throw new ServiceException("新增失败:文件已过期重新上传!"); + }catch (Exception e){ + throw new ServiceException("新增失败:" + e.getMessage()); + } + } + + /** + * 修改试验标准管理 + * + * @param standardInfo 试验标准管理 + * @return 结果 + */ + @Override + public int updateStandardInfo(StandardManagerVO standardManagerVO) + { + String filePath = RuoYiConfig.getUploadPath(); + // 取出缓存数据 + String name = ""; + String fileName = ""; + StringBuffer sb = new StringBuffer(); + Assert.notNull(standardManagerVO.getPath(),"文件未上传!"); +// String s:standardManagerVO.getPath().split("/",9) + String[] str = standardManagerVO.getPath().split("/",6); + for(int i=0;i<str.length;i++){ + if(i>=2){ + sb.append("/"); + sb.append(str[i]); + } + name = str[i]; + } + 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.setUpdateBy(SecurityUtils.getLoginUser().getUsername()); + standardManagerVO.setUpdateTime(DateUtils.getNowDate()); + return standardInfoMapper.updateStandardInfo(standardManagerVO); + }catch (NullPointerException e){ + throw new ServiceException("修改失败:文件已过期重新上传!"); + }catch (Exception e){ + throw new ServiceException("修改失败:" + e.getMessage()); + } + } + + /** + * 批量删除试验标准管理 + * + * @param standardIds 需要删除的试验标准管理主键 + * @return 结果 + */ + @Override + public int deleteStandardInfoByStandardIds(Long[] standardIds) + { + return standardInfoMapper.deleteStandardInfoByStandardIds(standardIds); + } + + /** + * 删除试验标准管理信息 + * + * @param standardId 试验标准管理主键 + * @return 结果 + */ + @Override + public int deleteStandardInfoByStandardId(Long standardId) + { + return standardInfoMapper.deleteStandardInfoByStandardId(standardId); + } + + @Override + public String uploadFile(MultipartFile file) { + try { + String filePath = RuoYiConfig.getUploadPath(); + // 上传并返回新文件名称 + String fileName = FileUploadUtils.upload(filePath, file); + String name =""; + for(String s:fileName.split("/",9)){ + System.out.println("path>>>"+s); + name = s; + } + + byte[] data = file.getBytes(); +// Byte[] data = new Byte[file.getResource().getInputStream().available()]; + + redisCache.setCacheObject(Constants.UPLOAD_FILE+name, + data, 30, TimeUnit.MINUTES); + redisCache.setCacheObject(Constants.UPLOAD_FILE_NAME+name,file.getOriginalFilename(),30,TimeUnit.MINUTES); +// 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; + }catch (Exception e){ + throw new ServiceException("上传失败:" + e.getMessage()); + } + } + /** + * 设置cache key + * + * @param fileName 参数键 + * @return 缓存键key + */ + private String getCacheKey(String fileName) + { + return Constants.UPLOAD_FILE + fileName; + } +} diff --git a/productManager/src/main/java/com/ruoyi/productionManager/vo/StandardManagerVO.java b/productManager/src/main/java/com/ruoyi/productionManager/vo/StandardManagerVO.java new file mode 100644 index 000000000..57ba4956f --- /dev/null +++ b/productManager/src/main/java/com/ruoyi/productionManager/vo/StandardManagerVO.java @@ -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 + '\'' + + '}'; + } +} diff --git a/productManager/src/main/resources/mapper/productionManager/StandardInfoDetailsMapper.xml b/productManager/src/main/resources/mapper/productionManager/StandardInfoDetailsMapper.xml new file mode 100644 index 000000000..023607778 --- /dev/null +++ b/productManager/src/main/resources/mapper/productionManager/StandardInfoDetailsMapper.xml @@ -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> \ No newline at end of file diff --git a/productManager/src/main/resources/mapper/productionManager/StandardInfoMapper.xml b/productManager/src/main/resources/mapper/productionManager/StandardInfoMapper.xml new file mode 100644 index 000000000..a3fc02109 --- /dev/null +++ b/productManager/src/main/resources/mapper/productionManager/StandardInfoMapper.xml @@ -0,0 +1,101 @@ +<?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.StandardInfoMapper"> + + <resultMap type="StandardInfo" id="StandardInfoResult"> + <result property="standardId" column="standard_id" /> + <result property="areaCategory" column="area_category" /> + <result property="standardName" column="standard_name" /> + <result property="standardCategory" column="standard_category" /> + <result property="standardBeginDate" column="standard_begin_date" /> + <result property="standardStatus" column="standard_status" /> + <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="selectStandardInfoVo"> + select standard_id, area_category, standard_name, standard_category, standard_begin_date, standard_status, create_by, create_time, update_by, update_time, remark from standard_info + </sql> + + <select id="selectStandardInfoList" parameterType="StandardInfo" resultMap="StandardInfoResult"> + <include refid="selectStandardInfoVo"/> + <where> + <if test="areaCategory != null and areaCategory != ''"> and area_category = #{areaCategory}</if> + <if test="standardName != null and standardName != ''"> and standard_name like concat('%', #{standardName}, '%')</if> + <if test="standardCategory != null and standardCategory != ''"> and standard_category = #{standardCategory}</if> + <if test="standardBeginDate != null and standardBeginDate != ''"> and standard_begin_date = #{standardBeginDate}</if> + <if test="standardStatus != null and standardStatus != ''"> and standard_status = #{standardStatus}</if> + </where> + </select> + + <select id="selectStandardInfoByStandardId" parameterType="Long" resultMap="StandardInfoResult"> + <include refid="selectStandardInfoVo"/> + where standard_id = #{standardId} + </select> + + <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 + <trim prefix="(" suffix=")" suffixOverrides=","> + <!--<if test="standardId != null and standardId != ''">standard_id,</if>--> + <if test="areaCategory != null and areaCategory != ''">area_category,</if> + <if test="standardName != null and standardName != ''">standard_name,</if> + <if test="standardCategory != null and standardCategory != ''">standard_category,</if> + <if test="standardBeginDate != null">standard_begin_date,</if> + <if test="standardStatus != null and standardStatus != ''">standard_status,</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="areaCategory != null and areaCategory != ''">#{areaCategory},</if> + <if test="standardName != null and standardName != ''">#{standardName},</if> + <if test="standardCategory != null and standardCategory != ''">#{standardCategory},</if> + <if test="standardBeginDate != null">#{standardBeginDate},</if> + <if test="standardStatus != null and standardStatus != ''">#{standardStatus},</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="updateStandardInfo" parameterType="StandardInfo"> + update standard_info + <trim prefix="SET" suffixOverrides=","> + <if test="areaCategory != null and areaCategory != ''">area_category = #{areaCategory},</if> + <if test="standardName != null and standardName != ''">standard_name = #{standardName},</if> + <if test="standardCategory != null and standardCategory != ''">standard_category = #{standardCategory},</if> + <if test="standardBeginDate != null">standard_begin_date = #{standardBeginDate},</if> + <if test="standardStatus != null and standardStatus != ''">standard_status = #{standardStatus},</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 standard_id = #{standardId} + </update> + + <delete id="deleteStandardInfoByStandardId" parameterType="Long"> + delete from standard_info where standard_id = #{standardId} + </delete> + + <delete id="deleteStandardInfoByStandardIds" parameterType="String"> + delete from standard_info where standard_id in + <foreach item="standardId" collection="array" open="(" separator="," close=")"> + #{standardId} + </foreach> + </delete> +</mapper> \ No newline at end of file diff --git a/ruoyi-admin/pom.xml b/ruoyi-admin/pom.xml index 1d1d687b4..be081bc7d 100644 --- a/ruoyi-admin/pom.xml +++ b/ruoyi-admin/pom.xml @@ -60,6 +60,12 @@ <groupId>com.ruoyi</groupId> <artifactId>ruoyi-generator</artifactId> </dependency> + <dependency> + <groupId>com.ruoyi</groupId> + <artifactId>productManager</artifactId> + <version>3.7.0</version> + <scope>compile</scope> + </dependency> </dependencies> diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/productionManager/StandardInfoController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/productionManager/StandardInfoController.java new file mode 100644 index 000000000..b55be367a --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/productionManager/StandardInfoController.java @@ -0,0 +1,135 @@ +package com.ruoyi.web.controller.productionManager; + +import java.util.List; + +import com.ruoyi.common.config.RuoYiConfig; +import com.ruoyi.common.constant.Constants; +import com.ruoyi.common.utils.file.FileUploadUtils; +import com.ruoyi.framework.config.ServerConfig; +import com.ruoyi.productionManager.domain.StandardInfo; +import com.ruoyi.productionManager.vo.StandardManagerVO; +import org.apache.ibatis.annotations.Param; +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.service.IStandardInfoService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; +import org.springframework.web.multipart.MultipartFile; + +/** + * 试验标准管理Controller + * + * @author ruoyi + * @date 2021-10-13 + */ +@RestController +@RequestMapping("/productionManager/standard") +public class StandardInfoController extends BaseController +{ + @Autowired + private IStandardInfoService standardInfoService; + @Autowired + private ServerConfig serverConfig; + + /** + * 查询试验标准管理列表 + */ + @PreAuthorize("@ss.hasPermi('productionManager:standard:list')") + @GetMapping("/list") + public TableDataInfo list(StandardInfo standardInfo) + { + startPage(); + List<StandardInfo> list = standardInfoService.selectStandardInfoList(standardInfo); + return getDataTable(list); + } + + /** + * 导出试验标准管理列表 + */ + @PreAuthorize("@ss.hasPermi('productionManager:standard:export')") + @Log(title = "试验标准管理", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(StandardInfo standardInfo) + { + List<StandardInfo> list = standardInfoService.selectStandardInfoList(standardInfo); + ExcelUtil<StandardInfo> util = new ExcelUtil<StandardInfo>(StandardInfo.class); + return util.exportExcel(list, "试验标准管理数据"); + } + + /** + * 获取试验标准管理详细信息 + */ + @PreAuthorize("@ss.hasPermi('productionManager:standard:query')") + @GetMapping(value = "/{standardId}") + public AjaxResult getInfo(@PathVariable("standardId") Long standardId) + { + return AjaxResult.success(standardInfoService.selectStandardInfoByStandardId(standardId)); + } + + /** + * 新增试验标准管理 + */ + @PreAuthorize("@ss.hasPermi('productionManager:standard:add')") + @Log(title = "试验标准管理", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody StandardManagerVO standardInfo) + { + standardInfo.setCreateBy(getUsername()); + return toAjax(standardInfoService.insertStandardInfo(standardInfo)); + } + + /** + * 修改试验标准管理 + */ + @PreAuthorize("@ss.hasPermi('productionManager:standard:edit')") + @Log(title = "试验标准管理", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody StandardManagerVO standardInfo) + { + return toAjax(standardInfoService.updateStandardInfo(standardInfo)); + } + + /** + * 删除试验标准管理 + */ + @PreAuthorize("@ss.hasPermi('productionManager:standard:remove')") + @Log(title = "试验标准管理", businessType = BusinessType.DELETE) + @DeleteMapping("/{standardIds}") + public AjaxResult remove(@PathVariable Long[] standardIds) + { + return toAjax(standardInfoService.deleteStandardInfoByStandardIds(standardIds)); + } + + @PostMapping("/upload") + public AjaxResult getFiles(@Param("file") MultipartFile file){ +// String filePath = RuoYiConfig.getUploadPath(); +// // 上传并返回新文件名称 +// String fileName = FileUploadUtils.upload(filePath, file); + String fileName = standardInfoService.uploadFile(file); + String url = serverConfig.getUrl() + fileName; + AjaxResult ajax = AjaxResult.success(); + ajax.put("fileName", fileName); + url.split("/"); + String path =""; + for(String s:url.split("/",4)){ + System.out.println("path>>>"+s); + path = s; + } + ajax.put("url", path); + return ajax; + + } + +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/productionManager/StandardInfoDetailsController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/productionManager/StandardInfoDetailsController.java new file mode 100644 index 000000000..d08995a34 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/productionManager/StandardInfoDetailsController.java @@ -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)); + } +} diff --git a/ruoyi-admin/src/main/resources/application-druid.yml b/ruoyi-admin/src/main/resources/application-druid.yml index 1f098e407..68dd7a81f 100644 --- a/ruoyi-admin/src/main/resources/application-druid.yml +++ b/ruoyi-admin/src/main/resources/application-druid.yml @@ -6,9 +6,9 @@ spring: druid: # 主库数据源 master: - url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + url: jdbc:mysql://localhost:3306/szsyb?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 username: root - password: password + password: root # 从库数据源 slave: # 从数据源开关/默认关闭 diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index ae0ffbc9e..68ca72618 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -57,6 +57,11 @@ spring: # 热部署开关 enabled: true # redis 配置 +# mongodb: +# host: localhost # mongodb的连接地址 +# port: 27017 # mongodb的连接端口号 +# database: ruoyi # mongodb的连接的数据库 + redis: # 地址 host: localhost @@ -65,7 +70,7 @@ spring: # 数据库索引 database: 0 # 密码 - password: + password: chengjiaxing123 # 连接超时时间 timeout: 10s lettuce: diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java b/ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java index 9f55771bf..2f65cc95b 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java @@ -148,4 +148,14 @@ public class Constants * LDAP 远程方法调用 */ public static final String LOOKUP_LDAP = "ldap://"; + + /** + * 文件上传 + */ + public static final String UPLOAD_FILE = "file:"; + + /** + * 文件上传 + */ + public static final String UPLOAD_FILE_NAME = "filename:"; } diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileTypeUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileTypeUtils.java index 25f530666..6d4f1ac33 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileTypeUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileTypeUtils.java @@ -1,6 +1,8 @@ package com.ruoyi.common.utils.file; import java.io.File; +import java.util.HashMap; + import org.apache.commons.lang3.StringUtils; /** @@ -10,6 +12,42 @@ import org.apache.commons.lang3.StringUtils; */ 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> @@ -73,4 +111,58 @@ public class FileTypeUtils } 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; + } + + } \ No newline at end of file diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java index 76b647a10..2ba077998 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java @@ -2,7 +2,12 @@ package com.ruoyi.common.utils.file; import java.io.File; import java.io.IOException; +import java.util.Base64; +import java.util.concurrent.TimeUnit; + +import com.ruoyi.common.core.redis.RedisCache; import org.apache.commons.io.FilenameUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.multipart.MultipartFile; import com.ruoyi.common.config.RuoYiConfig; import com.ruoyi.common.constant.Constants; @@ -12,6 +17,7 @@ import com.ruoyi.common.exception.file.InvalidExtensionException; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.uuid.IdUtils; +import sun.misc.BASE64Encoder; /** * 文件上传工具类 @@ -20,6 +26,7 @@ import com.ruoyi.common.utils.uuid.IdUtils; */ public class FileUploadUtils { + /** * 默认大小 50M */ @@ -110,8 +117,8 @@ public class FileUploadUtils String fileName = extractFilename(file); - File desc = getAbsoluteFile(baseDir, fileName); - file.transferTo(desc); +// File desc = getAbsoluteFile(baseDir, fileName); +// file.transferTo(desc); String pathFileName = getPathFileName(baseDir, fileName); return pathFileName; } diff --git a/ruoyi-generator/src/main/resources/generator.yml b/ruoyi-generator/src/main/resources/generator.yml index 4544c8c24..9f3372f58 100644 --- a/ruoyi-generator/src/main/resources/generator.yml +++ b/ruoyi-generator/src/main/resources/generator.yml @@ -3,7 +3,7 @@ gen: # 作者 author: ruoyi # 默认生成包路径 system 需改成自己的模块名称 如 system monitor tool - packageName: com.ruoyi.system + packageName: com.ruoyi.productionManager # 自动去除表前缀,默认是false autoRemovePre: false # 表前缀(生成类名不会包含表前缀,多个用逗号分隔) diff --git a/ruoyi-ui/src/api/productionManager/standard.js b/ruoyi-ui/src/api/productionManager/standard.js new file mode 100644 index 000000000..3126fa715 --- /dev/null +++ b/ruoyi-ui/src/api/productionManager/standard.js @@ -0,0 +1,53 @@ +import request from '@/utils/request' + +// 查询试验标准管理列表 +export function listStandard(query) { + return request({ + url: '/productionManager/standard/list', + method: 'get', + params: query + }) +} + +// 查询试验标准管理详细 +export function getStandard(standardId) { + return request({ + url: '/productionManager/standard/' + standardId, + method: 'get' + }) +} + +// 新增试验标准管理 +export function addStandard(data) { + return request({ + url: '/productionManager/standard', + method: 'post', + data: data + }) +} + +// 修改试验标准管理 +export function updateStandard(data) { + return request({ + url: '/productionManager/standard', + method: 'put', + data: data + }) +} + +// 删除试验标准管理 +export function delStandard(standardId) { + return request({ + url: '/productionManager/standard/' + standardId, + method: 'delete' + }) +} + +// 导出试验标准管理 +export function exportStandard(query) { + return request({ + url: '/productionManager/standard/export', + method: 'get', + params: query + }) +} \ No newline at end of file diff --git a/ruoyi-ui/src/components/Editor/index.vue b/ruoyi-ui/src/components/Editor/index.vue index 6bb5a18d3..fb603e084 100644 --- a/ruoyi-ui/src/components/Editor/index.vue +++ b/ruoyi-ui/src/components/Editor/index.vue @@ -1,19 +1,19 @@ <template> <div> - <el-upload - :action="uploadUrl" - :before-upload="handleBeforeUpload" - :on-success="handleUploadSuccess" - :on-error="handleUploadError" - name="file" - :show-file-list="false" - :headers="headers" - style="display: none" - ref="upload" - v-if="this.type == 'url'" - > + <el-upload :action="uploadUrl" + :before-upload="handleBeforeUpload" + :on-success="handleUploadSuccess" + :on-error="handleUploadError" + name="file" + :show-file-list="false" + :headers="headers" + style="display: none" + ref="upload" + v-if="this.type == 'url'"> </el-upload> - <div class="editor" ref="editor" :style="styles"></div> + <div class="editor" + ref="editor" + :style="styles"></div> </div> </template> @@ -58,7 +58,7 @@ export default { default: "url", } }, - data() { + data () { return { uploadUrl: process.env.VUE_APP_BASE_API + "/common/upload", // 上传的图片服务器地址 headers: { @@ -91,7 +91,7 @@ export default { }; }, computed: { - styles() { + styles () { let style = {}; if (this.minHeight) { style.minHeight = `${this.minHeight}px`; @@ -104,7 +104,7 @@ export default { }, watch: { value: { - handler(val) { + handler (val) { if (val !== this.currentValue) { this.currentValue = val === null ? "" : val; if (this.Quill) { @@ -115,14 +115,14 @@ export default { immediate: true, }, }, - mounted() { + mounted () { this.init(); }, - beforeDestroy() { + beforeDestroy () { this.Quill = null; }, methods: { - init() { + init () { const editor = this.$refs.editor; this.Quill = new Quill(editor, this.options); // 如果设置了上传地址则自定义图片上传事件 @@ -157,7 +157,7 @@ export default { }); }, // 上传前校检格式和大小 - handleBeforeUpload(file) { + handleBeforeUpload (file) { // 校检文件大小 if (this.fileSize) { const isLt = file.size / 1024 / 1024 < this.fileSize; @@ -168,7 +168,7 @@ export default { } return true; }, - handleUploadSuccess(res, file) { + handleUploadSuccess (res, file) { // 获取富文本组件实例 let quill = this.Quill; // 如果上传成功 @@ -183,7 +183,7 @@ export default { this.$message.error("图片插入失败"); } }, - handleUploadError() { + handleUploadError () { this.$message.error("图片插入失败"); }, }, @@ -191,7 +191,8 @@ export default { </script> <style> -.editor, .ql-toolbar { +.editor, +.ql-toolbar { white-space: pre-wrap !important; line-height: normal !important; } diff --git a/ruoyi-ui/src/layout/components/Sidebar/Logo.vue b/ruoyi-ui/src/layout/components/Sidebar/Logo.vue index 82f3d581b..d976c29d4 100644 --- a/ruoyi-ui/src/layout/components/Sidebar/Logo.vue +++ b/ruoyi-ui/src/layout/components/Sidebar/Logo.vue @@ -1,13 +1,28 @@ <template> - <div class="sidebar-logo-container" :class="{'collapse':collapse}" :style="{ backgroundColor: sideTheme === 'theme-dark' ? variables.menuBackground : variables.menuLightBackground }"> + <div class="sidebar-logo-container" + :class="{'collapse':collapse}" + :style="{ backgroundColor: sideTheme === 'theme-dark' ? variables.menuBackground : variables.menuLightBackground }"> <transition name="sidebarLogoFade"> - <router-link v-if="collapse" key="collapse" class="sidebar-logo-link" to="/"> - <img v-if="logo" :src="logo" class="sidebar-logo" /> - <h1 v-else class="sidebar-title" :style="{ color: sideTheme === 'theme-dark' ? variables.logoTitleColor : variables.logoLightTitleColor }">{{ title }} </h1> + <router-link v-if="collapse" + key="collapse" + class="sidebar-logo-link" + to="/"> + <img v-if="logo" + :src="logo" + class="sidebar-logo" /> + <h1 v-else + class="sidebar-title" + :style="{ color: sideTheme === 'theme-dark' ? variables.logoTitleColor : variables.logoLightTitleColor }">{{ title }} </h1> </router-link> - <router-link v-else key="expand" class="sidebar-logo-link" to="/"> - <img v-if="logo" :src="logo" class="sidebar-logo" /> - <h1 class="sidebar-title" :style="{ color: sideTheme === 'theme-dark' ? variables.logoTitleColor : variables.logoLightTitleColor }">{{ title }} </h1> + <router-link v-else + key="expand" + class="sidebar-logo-link" + to="/"> + <img v-if="logo" + :src="logo" + class="sidebar-logo" /> + <h1 class="sidebar-title" + :style="{ color: sideTheme === 'theme-dark' ? variables.logoTitleColor : variables.logoLightTitleColor }">{{ title }} </h1> </router-link> </transition> </div> @@ -26,16 +41,16 @@ export default { } }, computed: { - variables() { + variables () { return variables; }, - sideTheme() { + sideTheme () { return this.$store.state.settings.sideTheme } }, - data() { + data () { return { - title: '若依管理系统', + title: '云度信息系统', logo: logoImg } } diff --git a/ruoyi-ui/src/views/productionManager/standard/index.vue b/ruoyi-ui/src/views/productionManager/standard/index.vue new file mode 100644 index 000000000..ae5cf908f --- /dev/null +++ b/ruoyi-ui/src/views/productionManager/standard/index.vue @@ -0,0 +1,544 @@ +<template> + <div class="app-container"> + <el-form :model="queryParams" + ref="queryForm" + :inline="true" + v-show="showSearch" + label-width="68px"> + <el-form-item label="区域分类" + prop="areaCategory"> + <el-input v-model="queryParams.areaCategory" + placeholder="请输入区域分类" + clearable + size="small" + @keyup.enter.native="handleQuery" /> + </el-form-item> + <el-form-item label="标准名称" + prop="standardName"> + <el-input v-model="queryParams.standardName" + placeholder="请输入标准名称" + clearable + size="small" + @keyup.enter.native="handleQuery" /> + </el-form-item> + <el-form-item label="标准类型" + prop="standardCategory"> + <el-select v-model="queryParams.standardCategory" + placeholder="请选择标准类型" + clearable + size="small"> + <el-option v-for="dict in dict.type.pro_standard_category" + :key="dict.value" + :label="dict.label" + :value="dict.value" /> + </el-select> + </el-form-item> + <el-form-item label="实施日期" + prop="standardBeginDate"> + <el-date-picker clearable + size="small" + v-model="queryParams.standardBeginDate" + type="date" + value-format="yyyy-MM-dd" + placeholder="选择实施日期"> + </el-date-picker> + </el-form-item> + <el-form-item label="标准状态" + prop="standardStatus"> + <el-select v-model="queryParams.standardStatus" + placeholder="请选择标准状态" + clearable + size="small"> + <el-option v-for="dict in dict.type.pro_standard_status" + :key="dict.value" + :label="dict.label" + :value="dict.value" /> + </el-select> + </el-form-item> + <el-form-item> + <el-button type="primary" + icon="el-icon-search" + size="mini" + @click="handleQuery">搜索</el-button> + <el-button icon="el-icon-refresh" + size="mini" + @click="resetQuery">重置</el-button> + </el-form-item> + </el-form> + + <el-row :gutter="10" + class="mb8"> + <el-col :span="1.5"> + <el-button type="primary" + plain + icon="el-icon-plus" + size="mini" + @click="handleAdd" + v-hasPermi="['productionManager:standard:add']">新增</el-button> + </el-col> + <el-col :span="1.5"> + <el-button type="success" + plain + icon="el-icon-edit" + size="mini" + :disabled="single" + @click="handleUpdate" + v-hasPermi="['productionManager:standard:edit']">修改</el-button> + </el-col> + <el-col :span="1.5"> + <el-button type="danger" + plain + icon="el-icon-delete" + size="mini" + :disabled="multiple" + @click="handleDelete" + v-hasPermi="['productionManager:standard:remove']">删除</el-button> + </el-col> + <el-col :span="1.5"> + <el-button type="warning" + plain + icon="el-icon-download" + size="mini" + :loading="exportLoading" + @click="handleExport" + v-hasPermi="['productionManager:standard:export']">导出</el-button> + </el-col> + <right-toolbar :showSearch.sync="showSearch" + @queryTable="getList"></right-toolbar> + </el-row> + + <el-table v-loading="loading" + :data="standardList" + @selection-change="handleSelectionChange"> + <el-table-column type="selection" + width="55" + align="center" /> + <el-table-column label="标准id" + align="center" + prop="standardId" + v-if="false" /> + <el-table-column label="区域分类" + align="center" + prop="areaCategory" /> + <el-table-column label="标准名称" + align="center" + prop="standardName" /> + <el-table-column label="标准类型" + align="center" + prop="standardCategory"> + <template slot-scope="scope"> + <dict-tag :options="dict.type.pro_standard_category" + :value="scope.row.standardCategory" /> + </template> + </el-table-column> + <el-table-column label="实施日期" + align="center" + prop="standardBeginDate" + width="180"> + <template slot-scope="scope"> + <span>{{ parseTime(scope.row.standardBeginDate, '{y}-{m}-{d}') }}</span> + </template> + </el-table-column> + <el-table-column label="标准状态" + align="center" + prop="standardStatus"> + <template slot-scope="scope"> + <dict-tag :options="dict.type.pro_standard_status" + :value="scope.row.standardStatus" /> + </template> + </el-table-column> + <el-table-column label="备注" + align="center" + prop="remark" /> + <el-table-column label="操作" + align="center" + class-name="small-padding fixed-width"> + <template slot-scope="scope"> + <el-button size="mini" + type="text" + icon="el-icon-edit" + @click="handleUpdate(scope.row)" + v-hasPermi="['productionManager:standard:edit']">修改</el-button> + <el-button size="mini" + type="text" + icon="el-icon-delete" + @click="handleDelete(scope.row)" + v-hasPermi="['productionManager:standard:remove']">删除</el-button> + <el-button size="mini" + type="text" + icon="el-icon-download" + @click="downloadFile(scope.row)" + v-hasPermi="['productionManager:standard:remove']">下载</el-button> + <el-dropdown size="mini" + @command="(command) => handleCommand(command, scope.row)" + v-hasPermi="['system:user:resetPwd', 'system:user:edit']"> + <span class="el-dropdown-link"> + <i class="el-icon-d-arrow-right el-icon--right"></i>更多 + </span> + <el-dropdown-menu slot="dropdown"> + <!-- <el-dropdown-item command="handleResetPwd" + icon="el-icon-key" + v-hasPermi="['system:user:resetPwd']">重置密码</el-dropdown-item> + <el-dropdown-item command="handleAuthRole" + icon="el-icon-circle-check" + v-hasPermi="['system:user:edit']">分配角色</el-dropdown-item> --> + </el-dropdown-menu> + </el-dropdown> + </template> + </el-table-column> + </el-table> + + <pagination v-show="total>0" + :total="total" + :page.sync="queryParams.pageNum" + :limit.sync="queryParams.pageSize" + @pagination="getList" /> + + <!-- 添加或修改试验标准管理对话框 --> + <el-dialog :title="title" + :visible.sync="open" + width="500px" + append-to-body> + <el-form ref="form" + :model="form" + :rules="rules" + label-width="80px"> + <el-form-item label="区域分类" + prop="areaCategory"> + <el-input v-model="form.areaCategory" + placeholder="请输入区域分类" /> + </el-form-item> + <el-form-item label="标准名称" + prop="standardName"> + <el-input v-model="form.standardName" + placeholder="请输入标准名称" /> + </el-form-item> + <!-- <el-form-item label="PDF文件" + prop="pdfFiles"> + </el-form-item> --> + + <el-form-item label="上传" + prop="path"> + <el-input v-model="form.path" + placeholder="请选择上传文件" + :disabled="true" /> + <!-- accept=".jpg, .png" --> + <el-upload ref="upload" + :limit="1" + :action="upload.url" + :headers="upload.headers" + :file-list="upload.fileList" + :on-progress="handleFileUploadProgress" + :on-success="handleFileSuccess" + :auto-upload="false"> + <el-button slot="trigger" + size="small" + type="primary">选取文件</el-button> + <el-button style="margin-left: 10px;" + size="small" + type="success" + :loading="upload.isUploading" + @click="submitUpload">上传到服务器</el-button> + <!-- <div slot="tip" + class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div> --> + </el-upload> + </el-form-item> + <!-- <el-form-item size="large"> + <el-button type="primary" + @click="submitForm">提交</el-button> + <el-button @click="resetForm">重置</el-button> + </el-form-item> --> + + <el-form-item label="标准类型"> + <el-radio-group v-model="form.standardCategory"> + <el-radio v-for="dict in dict.type.pro_standard_category" + :key="dict.value" + :label="dict.value">{{dict.label}}</el-radio> + </el-radio-group> + </el-form-item> + <el-form-item label="实施日期" + prop="standardBeginDate"> + <el-date-picker clearable + size="small" + v-model="form.standardBeginDate" + type="date" + value-format="yyyy-MM-dd" + placeholder="选择实施日期"> + </el-date-picker> + </el-form-item> + <el-form-item label="标准状态"> + <el-radio-group v-model="form.standardStatus"> + <el-radio v-for="dict in dict.type.pro_standard_status" + :key="dict.value" + :label="dict.value">{{dict.label}}</el-radio> + </el-radio-group> + </el-form-item> + <el-form-item label="备注" + prop="remark"> + <el-input v-model="form.remark" + type="textarea" + placeholder="请输入内容" /> + </el-form-item> + </el-form> + <div slot="footer" + class="dialog-footer"> + <el-button type="primary" + @click="submitForm">确 定</el-button> + <el-button @click="cancel">取 消</el-button> + </div> + </el-dialog> + </div> +</template> + +<script> +import { listStandard, getStandard, delStandard, addStandard, updateStandard, exportStandard } from "@/api/productionManager/standard"; +import { getToken } from "@/utils/auth"; + +export default { + // pdf文件导入参数 + + // + + name: "Standard", + dicts: ['pro_standard_category', 'pro_standard_status'], + data () { + var validatorPath = (rule, value, callback) => { + if (value === '') { + callback(new Error('请上传文件')); + } else { + // if (this.form.path !== '') { + // this.$refs.ruleForm.validateField('checkPass'); + // } + callback(); + } + }; + return { + //导入相关参数 process.env.VUE_APP_BASE_API + "/productionManager/standard/upload" + // 上传参数 + upload: { + // 是否禁用上传 + isUploading: false, + // 设置上传的请求头部 + headers: { Authorization: "Bearer " + getToken() }, + // 上传的地址 + url: process.env.VUE_APP_BASE_API + "/productionManager/standard/upload", + // 上传的文件列表 + fileList: [], + filePath: "" + + }, + // 遮罩层 + loading: true, + // 导出遮罩层 + exportLoading: false, + // 选中数组 + ids: [], + // 非单个禁用 + single: true, + // 非多个禁用 + multiple: true, + // 显示搜索条件 + showSearch: true, + // 总条数 + total: 0, + // 试验标准管理表格数据 + standardList: [], + // 弹出层标题 + title: "", + // 是否显示弹出层 + open: false, + // 查询参数 + queryParams: { + pageNum: 1, + pageSize: 10, + areaCategory: null, + standardName: null, + standardCategory: null, + standardBeginDate: null, + standardStatus: null, + + }, + // 表单参数 + form: {}, + // 表单校验 + rules: { + areaCategory: [ + { required: true, message: "区域分类不能为空", trigger: "blur" } + ], + standardName: [ + { required: true, message: "标准名称不能为空", trigger: "blur" } + ], + standardCategory: [ + { required: true, message: "标准类型不能为空", trigger: "blur" } + ], + standardStatus: [ + { required: true, message: "标准状态不能为空", trigger: "blur" } + ], + // path: [ + // { required: true, message: "文件不能为空", trigger: ["blur"] } + // ], + // path: [ + // { required: true, validator: validatorPath, trigger: ["blur", "change"] } + // ], + } + }; + }, + created () { + this.getList(); + }, + methods: { + // pdf导入相关方法 + // submitForm () { + // this.$refs['elForm'].validate(valid => { + // if (!valid) return + // // TODO 提交表单 + // }) + // }, + // resetForm () { + // this.$refs['elForm'].resetFields() + // }, + + + pdffileBeforeUpload (file) { + let isRightSize = file.size / 1024 / 1024 < 20 + if (!isRightSize) { + this.$message.error('文件大小超过 20MB') + } + let isAccept = new RegExp('.pdf').test(file.type) + if (!isAccept) { + this.$message.error('应该选择.pdf类型的文件') + } + return isRightSize && isAccept + }, + // 文件提交处理 + submitUpload () { + this.$refs.upload.submit(); + }, + // 文件上传中处理 + handleFileUploadProgress (event, file, fileList) { + this.upload.isUploading = true; + }, + // 文件上传成功处理 + handleFileSuccess (response, file, fileList) { + this.upload.isUploading = false; + this.upload.filePath = response.url; + console.log("filepath>>>" + this.upload.filePath) + this.form.path = response.url; + this.$modal.msgSuccess(response.msg); + // this.$nextTick(() => this.$refs.form.clearValidate()) + }, + + + /** 查询试验标准管理列表 */ + getList () { + this.loading = true; + listStandard(this.queryParams).then(response => { + this.standardList = response.rows; + this.total = response.total; + this.loading = false; + }); + }, + // 取消按钮 + cancel () { + this.open = false; + this.reset(); + }, + // 表单重置 + reset () { + this.form = { + standardId: null, + areaCategory: null, + standardName: null, + standardCategory: "0", + standardBeginDate: null, + standardStatus: "0", + createBy: null, + createTime: null, + updateBy: null, + updateTime: null, + remark: null + }; + this.resetForm("form"); + }, + /** 搜索按钮操作 */ + handleQuery () { + this.queryParams.pageNum = 1; + this.getList(); + }, + /** 重置按钮操作 */ + resetQuery () { + this.resetForm("queryForm"); + this.handleQuery(); + }, + // 多选框选中数据 + handleSelectionChange (selection) { + this.ids = selection.map(item => item.standardId) + this.single = selection.length !== 1 + this.multiple = !selection.length + }, + /** 新增按钮操作 */ + handleAdd () { + this.reset(); + this.open = true; + this.upload.fileList = []; + this.title = "添加试验标准管理"; + }, + /** 修改按钮操作 */ + handleUpdate (row) { + this.reset(); + const standardId = row.standardId || this.ids + getStandard(standardId).then(response => { + this.form = response.data; + this.open = true; + this.title = "修改试验标准管理"; + }); + }, + /** 提交按钮 */ + submitForm () { + this.$refs["form"].validate(valid => { + if (valid) { + if (this.form.standardId != null) { + updateStandard(this.form).then(response => { + this.$modal.msgSuccess("修改成功"); + this.open = false; + this.getList(); + }); + } else { + addStandard(this.form).then(response => { + this.$modal.msgSuccess("新增成功"); + this.open = false; + this.getList(); + }); + } + } + }); + }, + /** 删除按钮操作 */ + handleDelete (row) { + const standardIds = row.standardId || this.ids; + this.$modal.confirm('是否确认删除试验标准管理编号为"' + standardIds + '"的数据项?').then(function () { + return delStandard(standardIds); + }).then(() => { + this.getList(); + this.$modal.msgSuccess("删除成功"); + }).catch(() => { }); + }, + /** 导出按钮操作 */ + handleExport () { + const queryParams = this.queryParams; + this.$modal.confirm('是否确认导出所有试验标准管理数据项?').then(() => { + this.exportLoading = true; + return exportStandard(queryParams); + }).then(response => { + this.$download.name(response.msg); + this.exportLoading = false; + }).catch(() => { }); + } + } +}; +</script> +<style> +.el-upload__tip { + line-height: 1.2; +} +</style> diff --git a/sql/ry_20210908.sql b/sql/ry_20210908.sql index 650238a1a..7a89a1774 100644 --- a/sql/ry_20210908.sql +++ b/sql/ry_20210908.sql @@ -685,4 +685,36 @@ create table gen_table_column ( update_by varchar(64) default '' comment '更新者', update_time datetime comment '更新时间', primary key (column_id) -) engine=innodb auto_increment=1 comment = '代码生成业务表字段'; \ No newline at end of file +) engine=innodb auto_increment=1 comment = '代码生成业务表字段'; + +-- 添加业务表 +drop table if exists STANDARD_INFO; +create table STANDARD_INFO ( + standard_id bigint(20) not null auto_increment comment '标准id', + area_category varchar(120) not null comment '区域分类', + standard_name varchar(200) not null comment '标准名称', + standard_category varchar(200) not null comment '标准类型', + standard_begin_date varchar(250) null comment '标准实施日期', + standard_status varchar(20) not null comment '标准状态', + create_by varchar(64) default '' comment '创建者', + create_time datetime comment '创建时间', + update_by varchar(64) default '' comment '更新者', + update_time datetime comment '更新时间', + remark varchar(500) default null comment '备注', + primary key (standard_id) +) engine=innodb comment = '标准信息表'; + + +drop table if exists STANDARD_INFO_DETAILS; +create table STANDARD_INFO_DETAILS ( + details_id bigint(20) not null auto_increment comment '标准明细ID', + standard_id bigint(20) not null comment '标准id', + file_name varchar(200) not null comment '文件名称', + file_url varchar(200) not null comment '文件路径', + create_by varchar(64) default '' comment '创建者', + create_time datetime comment '创建时间', + update_by varchar(64) default '' comment '更新者', + update_time datetime comment '更新时间', + remark varchar(500) default null comment '备注', + primary key (details_id,standard_id) +) engine=innodb comment = '标准信息文件表';