From 6f5848adda1d0bb53c2bcd205ac459c6bbab2e12 Mon Sep 17 00:00:00 2001 From: "JiaXing_Cheng@163.com" <JiaXing_Cheng@163.com> Date: Mon, 11 Oct 2021 10:47:46 +0800 Subject: [PATCH 01/10] =?UTF-8?q?=E6=9C=AC=E5=9C=B0mysql=EF=BC=8Credis?= =?UTF-8?q?=E5=AF=86=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-admin/src/main/resources/application-druid.yml | 4 ++-- ruoyi-admin/src/main/resources/application.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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..66c6e222c 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -65,7 +65,7 @@ spring: # 数据库索引 database: 0 # 密码 - password: + password: chengjiaxing123 # 连接超时时间 timeout: 10s lettuce: From 07d4c55f16b7c914db40addf810d82e18952cc8b Mon Sep 17 00:00:00 2001 From: "JiaXing_Cheng@163.com" <JiaXing_Cheng@163.com> Date: Tue, 12 Oct 2021 14:34:53 +0800 Subject: [PATCH 02/10] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 5 +++ .../src/main/resources/application.yml | 5 +++ .../src/layout/components/Sidebar/Logo.vue | 37 +++++++++++++------ 3 files changed, 36 insertions(+), 11 deletions(-) diff --git a/pom.xml b/pom.xml index 91ac13cee..44fc6373b 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> diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index 66c6e222c..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 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 } } From e94783fd183f0c8dada93737a27b1e0f03f81985 Mon Sep 17 00:00:00 2001 From: "JiaXing_Cheng@163.com" <JiaXing_Cheng@163.com> Date: Wed, 13 Oct 2021 11:17:31 +0800 Subject: [PATCH 03/10] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=9F=BA=E7=A1=80?= =?UTF-8?q?=E7=94=9F=E4=BA=A7=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 1 + productManager/pom.xml | 33 ++++++ .../domain/StandardInfo.java | 112 ++++++++++++++++++ .../mapper/StandardInfoMapper.java | 61 ++++++++++ .../service/IStandardInfoService.java | 62 ++++++++++ .../service/impl/StandardInfoServiceImpl.java | 96 +++++++++++++++ .../productionManager/StandardInfoMapper.xml | 96 +++++++++++++++ ruoyi-admin/pom.xml | 6 + .../StandardInfoController.java | 103 ++++++++++++++++ .../src/main/resources/generator.yml | 2 +- 10 files changed, 571 insertions(+), 1 deletion(-) create mode 100644 productManager/pom.xml create mode 100644 productManager/src/main/java/com/ruoyi/productionManager/domain/StandardInfo.java create mode 100644 productManager/src/main/java/com/ruoyi/productionManager/mapper/StandardInfoMapper.java create mode 100644 productManager/src/main/java/com/ruoyi/productionManager/service/IStandardInfoService.java create mode 100644 productManager/src/main/java/com/ruoyi/productionManager/service/impl/StandardInfoServiceImpl.java create mode 100644 productManager/src/main/resources/mapper/productionManager/StandardInfoMapper.xml create mode 100644 ruoyi-admin/src/main/java/com/ruoyi/web/controller/productionManager/StandardInfoController.java diff --git a/pom.xml b/pom.xml index 44fc6373b..669adb035 100644 --- a/pom.xml +++ b/pom.xml @@ -220,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..4359307df --- /dev/null +++ b/productManager/pom.xml @@ -0,0 +1,33 @@ +<?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> + </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..1e4f8aad5 --- /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/mapper/StandardInfoMapper.java b/productManager/src/main/java/com/ruoyi/productionManager/mapper/StandardInfoMapper.java new file mode 100644 index 000000000..6aa230726 --- /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/IStandardInfoService.java b/productManager/src/main/java/com/ruoyi/productionManager/service/IStandardInfoService.java new file mode 100644 index 000000000..2efa5c602 --- /dev/null +++ b/productManager/src/main/java/com/ruoyi/productionManager/service/IStandardInfoService.java @@ -0,0 +1,62 @@ +package com.ruoyi.productionManager.service; + +import com.ruoyi.productionManager.domain.StandardInfo; + +import java.util.List; + +/** + * 标准信息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(StandardInfo standardInfo); + + /** + * 修改标准信息 + * + * @param standardInfo 标准信息 + * @return 结果 + */ + public int updateStandardInfo(StandardInfo standardInfo); + + /** + * 批量删除标准信息 + * + * @param standardIds 需要删除的标准信息主键集合 + * @return 结果 + */ + public int deleteStandardInfoByStandardIds(Long[] standardIds); + + /** + * 删除标准信息信息 + * + * @param standardId 标准信息主键 + * @return 结果 + */ + public int deleteStandardInfoByStandardId(Long standardId); +} 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..168836299 --- /dev/null +++ b/productManager/src/main/java/com/ruoyi/productionManager/service/impl/StandardInfoServiceImpl.java @@ -0,0 +1,96 @@ +package com.ruoyi.productionManager.service.impl; + +import java.util.List; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.productionManager.domain.StandardInfo; +import com.ruoyi.productionManager.mapper.StandardInfoMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ruoyi.productionManager.service.IStandardInfoService; + +/** + * 标准信息Service业务层处理 + * + * @author ruoyi + * @date 2021-10-13 + */ +@Service +public class StandardInfoServiceImpl implements IStandardInfoService +{ + @Autowired + private StandardInfoMapper standardInfoMapper; + + /** + * 查询标准信息 + * + * @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 standardInfo 标准信息 + * @return 结果 + */ + @Override + public int insertStandardInfo(StandardInfo standardInfo) + { + standardInfo.setCreateTime(DateUtils.getNowDate()); + return standardInfoMapper.insertStandardInfo(standardInfo); + } + + /** + * 修改标准信息 + * + * @param standardInfo 标准信息 + * @return 结果 + */ + @Override + public int updateStandardInfo(StandardInfo standardInfo) + { + standardInfo.setUpdateTime(DateUtils.getNowDate()); + return standardInfoMapper.updateStandardInfo(standardInfo); + } + + /** + * 批量删除标准信息 + * + * @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); + } +} 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..5ac601caa --- /dev/null +++ b/productManager/src/main/resources/mapper/productionManager/StandardInfoMapper.xml @@ -0,0 +1,96 @@ +<?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"> + insert into standard_info + <trim prefix="(" suffix=")" suffixOverrides=","> + <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..a9199d32b --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/productionManager/StandardInfoController.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.StandardInfo; +import com.ruoyi.productionManager.service.IStandardInfoService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 标准信息Controller + * + * @author ruoyi + * @date 2021-10-13 + */ +@RestController +@RequestMapping("/productionManager/standard") +public class StandardInfoController extends BaseController +{ + @Autowired + private IStandardInfoService standardInfoService; + + /** + * 查询标准信息列表 + */ + @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 StandardInfo standardInfo) + { + return toAjax(standardInfoService.insertStandardInfo(standardInfo)); + } + + /** + * 修改标准信息 + */ + @PreAuthorize("@ss.hasPermi('productionManager:standard:edit')") + @Log(title = "标准信息", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody StandardInfo 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)); + } +} 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 # 表前缀(生成类名不会包含表前缀,多个用逗号分隔) From e31329c7b6fcf53eb9e8c231ba7d16fa836ba0ac Mon Sep 17 00:00:00 2001 From: "JiaXing_Cheng@163.com" <JiaXing_Cheng@163.com> Date: Wed, 13 Oct 2021 11:19:21 +0800 Subject: [PATCH 04/10] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=B8=9A=E5=8A=A1?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/ry_20210908.sql | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/sql/ry_20210908.sql b/sql/ry_20210908.sql index 650238a1a..af0868fbd 100644 --- a/sql/ry_20210908.sql +++ b/sql/ry_20210908.sql @@ -685,4 +685,34 @@ 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 ( + standard_id bigint(20) not null auto_increment comment '标准id', + details_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 (standard_id, details_id) +) engine=innodb comment = '标准信息文件表'; From 7786ee89150f801dc2afde7f862ee533f2d69cef Mon Sep 17 00:00:00 2001 From: "JiaXing_Cheng@163.com" <JiaXing_Cheng@163.com> Date: Wed, 13 Oct 2021 13:55:01 +0800 Subject: [PATCH 05/10] =?UTF-8?q?=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/StandardInfo.java | 2 +- .../mapper/StandardInfoMapper.java | 28 +- .../service/IStandardInfoService.java | 33 +- .../service/impl/StandardInfoServiceImpl.java | 34 +- .../StandardInfoController.java | 27 +- .../src/api/productionManager/standard.js | 53 +++ .../productionManager/standard/index.vue | 366 ++++++++++++++++++ 7 files changed, 481 insertions(+), 62 deletions(-) create mode 100644 ruoyi-ui/src/api/productionManager/standard.js create mode 100644 ruoyi-ui/src/views/productionManager/standard/index.vue diff --git a/productManager/src/main/java/com/ruoyi/productionManager/domain/StandardInfo.java b/productManager/src/main/java/com/ruoyi/productionManager/domain/StandardInfo.java index 1e4f8aad5..ad2a69130 100644 --- a/productManager/src/main/java/com/ruoyi/productionManager/domain/StandardInfo.java +++ b/productManager/src/main/java/com/ruoyi/productionManager/domain/StandardInfo.java @@ -6,7 +6,7 @@ import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.core.domain.BaseEntity; /** - * 标准信息对象 standard_info + * 试验标准管理对象 standard_info * * @author ruoyi * @date 2021-10-13 diff --git a/productManager/src/main/java/com/ruoyi/productionManager/mapper/StandardInfoMapper.java b/productManager/src/main/java/com/ruoyi/productionManager/mapper/StandardInfoMapper.java index 6aa230726..d34e81781 100644 --- a/productManager/src/main/java/com/ruoyi/productionManager/mapper/StandardInfoMapper.java +++ b/productManager/src/main/java/com/ruoyi/productionManager/mapper/StandardInfoMapper.java @@ -4,7 +4,7 @@ import java.util.List; import com.ruoyi.productionManager.domain.StandardInfo; /** - * 标准信息Mapper接口 + * 试验标准管理Mapper接口 * * @author ruoyi * @date 2021-10-13 @@ -12,47 +12,47 @@ import com.ruoyi.productionManager.domain.StandardInfo; public interface StandardInfoMapper { /** - * 查询标准信息 + * 查询试验标准管理 * - * @param standardId 标准信息主键 - * @return 标准信息 + * @param standardId 试验标准管理主键 + * @return 试验标准管理 */ public StandardInfo selectStandardInfoByStandardId(Long standardId); /** - * 查询标准信息列表 + * 查询试验标准管理列表 * - * @param standardInfo 标准信息 - * @return 标准信息集合 + * @param standardInfo 试验标准管理 + * @return 试验标准管理集合 */ public List<StandardInfo> selectStandardInfoList(StandardInfo standardInfo); /** - * 新增标准信息 + * 新增试验标准管理 * - * @param standardInfo 标准信息 + * @param standardInfo 试验标准管理 * @return 结果 */ public int insertStandardInfo(StandardInfo standardInfo); /** - * 修改标准信息 + * 修改试验标准管理 * - * @param standardInfo 标准信息 + * @param standardInfo 试验标准管理 * @return 结果 */ public int updateStandardInfo(StandardInfo standardInfo); /** - * 删除标准信息 + * 删除试验标准管理 * - * @param standardId 标准信息主键 + * @param standardId 试验标准管理主键 * @return 结果 */ public int deleteStandardInfoByStandardId(Long standardId); /** - * 批量删除标准信息 + * 批量删除试验标准管理 * * @param standardIds 需要删除的数据主键集合 * @return 结果 diff --git a/productManager/src/main/java/com/ruoyi/productionManager/service/IStandardInfoService.java b/productManager/src/main/java/com/ruoyi/productionManager/service/IStandardInfoService.java index 2efa5c602..ef7837e2d 100644 --- a/productManager/src/main/java/com/ruoyi/productionManager/service/IStandardInfoService.java +++ b/productManager/src/main/java/com/ruoyi/productionManager/service/IStandardInfoService.java @@ -1,11 +1,10 @@ package com.ruoyi.productionManager.service; +import java.util.List; import com.ruoyi.productionManager.domain.StandardInfo; -import java.util.List; - /** - * 标准信息Service接口 + * 试验标准管理Service接口 * * @author ruoyi * @date 2021-10-13 @@ -13,49 +12,49 @@ import java.util.List; public interface IStandardInfoService { /** - * 查询标准信息 + * 查询试验标准管理 * - * @param standardId 标准信息主键 - * @return 标准信息 + * @param standardId 试验标准管理主键 + * @return 试验标准管理 */ public StandardInfo selectStandardInfoByStandardId(Long standardId); /** - * 查询标准信息列表 + * 查询试验标准管理列表 * - * @param standardInfo 标准信息 - * @return 标准信息集合 + * @param standardInfo 试验标准管理 + * @return 试验标准管理集合 */ public List<StandardInfo> selectStandardInfoList(StandardInfo standardInfo); /** - * 新增标准信息 + * 新增试验标准管理 * - * @param standardInfo 标准信息 + * @param standardInfo 试验标准管理 * @return 结果 */ public int insertStandardInfo(StandardInfo standardInfo); /** - * 修改标准信息 + * 修改试验标准管理 * - * @param standardInfo 标准信息 + * @param standardInfo 试验标准管理 * @return 结果 */ public int updateStandardInfo(StandardInfo standardInfo); /** - * 批量删除标准信息 + * 批量删除试验标准管理 * - * @param standardIds 需要删除的标准信息主键集合 + * @param standardIds 需要删除的试验标准管理主键集合 * @return 结果 */ public int deleteStandardInfoByStandardIds(Long[] standardIds); /** - * 删除标准信息信息 + * 删除试验标准管理信息 * - * @param standardId 标准信息主键 + * @param standardId 试验标准管理主键 * @return 结果 */ public int deleteStandardInfoByStandardId(Long standardId); 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 index 168836299..ea8a868a0 100644 --- a/productManager/src/main/java/com/ruoyi/productionManager/service/impl/StandardInfoServiceImpl.java +++ b/productManager/src/main/java/com/ruoyi/productionManager/service/impl/StandardInfoServiceImpl.java @@ -2,14 +2,14 @@ package com.ruoyi.productionManager.service.impl; import java.util.List; import com.ruoyi.common.utils.DateUtils; -import com.ruoyi.productionManager.domain.StandardInfo; -import com.ruoyi.productionManager.mapper.StandardInfoMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import com.ruoyi.productionManager.mapper.StandardInfoMapper; +import com.ruoyi.productionManager.domain.StandardInfo; import com.ruoyi.productionManager.service.IStandardInfoService; /** - * 标准信息Service业务层处理 + * 试验标准管理Service业务层处理 * * @author ruoyi * @date 2021-10-13 @@ -21,10 +21,10 @@ public class StandardInfoServiceImpl implements IStandardInfoService private StandardInfoMapper standardInfoMapper; /** - * 查询标准信息 + * 查询试验标准管理 * - * @param standardId 标准信息主键 - * @return 标准信息 + * @param standardId 试验标准管理主键 + * @return 试验标准管理 */ @Override public StandardInfo selectStandardInfoByStandardId(Long standardId) @@ -33,10 +33,10 @@ public class StandardInfoServiceImpl implements IStandardInfoService } /** - * 查询标准信息列表 + * 查询试验标准管理列表 * - * @param standardInfo 标准信息 - * @return 标准信息 + * @param standardInfo 试验标准管理 + * @return 试验标准管理 */ @Override public List<StandardInfo> selectStandardInfoList(StandardInfo standardInfo) @@ -45,9 +45,9 @@ public class StandardInfoServiceImpl implements IStandardInfoService } /** - * 新增标准信息 + * 新增试验标准管理 * - * @param standardInfo 标准信息 + * @param standardInfo 试验标准管理 * @return 结果 */ @Override @@ -58,9 +58,9 @@ public class StandardInfoServiceImpl implements IStandardInfoService } /** - * 修改标准信息 + * 修改试验标准管理 * - * @param standardInfo 标准信息 + * @param standardInfo 试验标准管理 * @return 结果 */ @Override @@ -71,9 +71,9 @@ public class StandardInfoServiceImpl implements IStandardInfoService } /** - * 批量删除标准信息 + * 批量删除试验标准管理 * - * @param standardIds 需要删除的标准信息主键 + * @param standardIds 需要删除的试验标准管理主键 * @return 结果 */ @Override @@ -83,9 +83,9 @@ public class StandardInfoServiceImpl implements IStandardInfoService } /** - * 删除标准信息信息 + * 删除试验标准管理信息 * - * @param standardId 标准信息主键 + * @param standardId 试验标准管理主键 * @return 结果 */ @Override 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 index a9199d32b..9b9b40837 100644 --- 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 @@ -1,6 +1,8 @@ package com.ruoyi.web.controller.productionManager; import java.util.List; + +import com.ruoyi.productionManager.domain.StandardInfo; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; @@ -15,13 +17,12 @@ 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.StandardInfo; import com.ruoyi.productionManager.service.IStandardInfoService; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.core.page.TableDataInfo; /** - * 标准信息Controller + * 试验标准管理Controller * * @author ruoyi * @date 2021-10-13 @@ -34,7 +35,7 @@ public class StandardInfoController extends BaseController private IStandardInfoService standardInfoService; /** - * 查询标准信息列表 + * 查询试验标准管理列表 */ @PreAuthorize("@ss.hasPermi('productionManager:standard:list')") @GetMapping("/list") @@ -46,20 +47,20 @@ public class StandardInfoController extends BaseController } /** - * 导出标准信息列表 + * 导出试验标准管理列表 */ @PreAuthorize("@ss.hasPermi('productionManager:standard:export')") - @Log(title = "标准信息", businessType = BusinessType.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, "标准信息数据"); + return util.exportExcel(list, "试验标准管理数据"); } /** - * 获取标准信息详细信息 + * 获取试验标准管理详细信息 */ @PreAuthorize("@ss.hasPermi('productionManager:standard:query')") @GetMapping(value = "/{standardId}") @@ -69,10 +70,10 @@ public class StandardInfoController extends BaseController } /** - * 新增标准信息 + * 新增试验标准管理 */ @PreAuthorize("@ss.hasPermi('productionManager:standard:add')") - @Log(title = "标准信息", businessType = BusinessType.INSERT) + @Log(title = "试验标准管理", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody StandardInfo standardInfo) { @@ -80,10 +81,10 @@ public class StandardInfoController extends BaseController } /** - * 修改标准信息 + * 修改试验标准管理 */ @PreAuthorize("@ss.hasPermi('productionManager:standard:edit')") - @Log(title = "标准信息", businessType = BusinessType.UPDATE) + @Log(title = "试验标准管理", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody StandardInfo standardInfo) { @@ -91,10 +92,10 @@ public class StandardInfoController extends BaseController } /** - * 删除标准信息 + * 删除试验标准管理 */ @PreAuthorize("@ss.hasPermi('productionManager:standard:remove')") - @Log(title = "标准信息", businessType = BusinessType.DELETE) + @Log(title = "试验标准管理", businessType = BusinessType.DELETE) @DeleteMapping("/{standardIds}") public AjaxResult remove(@PathVariable Long[] standardIds) { 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/views/productionManager/standard/index.vue b/ruoyi-ui/src/views/productionManager/standard/index.vue new file mode 100644 index 000000000..4a60cbc60 --- /dev/null +++ b/ruoyi-ui/src/views/productionManager/standard/index.vue @@ -0,0 +1,366 @@ +<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" /> + <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> + </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="标准类型"> + <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"; + +export default { + name: "Standard", + dicts: ['pro_standard_category', 'pro_standard_status'], + data() { + return { + // 遮罩层 + 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" } + ], + } + }; + }, + created() { + this.getList(); + }, + methods: { + /** 查询试验标准管理列表 */ + 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.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> From 469548b9725c63b79c4bb8c09011caac66382263 Mon Sep 17 00:00:00 2001 From: "JiaXing_Cheng@163.com" <JiaXing_Cheng@163.com> Date: Fri, 15 Oct 2021 11:05:51 +0800 Subject: [PATCH 06/10] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StandardInfoController.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) 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 index 9b9b40837..1b2552e83 100644 --- 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 @@ -2,7 +2,11 @@ package com.ruoyi.web.controller.productionManager; import java.util.List; +import com.ruoyi.common.config.RuoYiConfig; +import com.ruoyi.common.utils.file.FileUploadUtils; +import com.ruoyi.framework.config.ServerConfig; import com.ruoyi.productionManager.domain.StandardInfo; +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; @@ -20,6 +24,7 @@ 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 @@ -33,6 +38,8 @@ public class StandardInfoController extends BaseController { @Autowired private IStandardInfoService standardInfoService; + @Autowired + private ServerConfig serverConfig; /** * 查询试验标准管理列表 @@ -101,4 +108,21 @@ public class StandardInfoController extends BaseController { return toAjax(standardInfoService.deleteStandardInfoByStandardIds(standardIds)); } + + @PostMapping("/upload") + public AjaxResult getFiles(@Param("file") MultipartFile file){ + try{ + String filePath = RuoYiConfig.getUploadPath(); + // 上传并返回新文件名称 + String fileName = FileUploadUtils.upload(filePath, file); + String url = serverConfig.getUrl() + fileName; + AjaxResult ajax = AjaxResult.success(); + ajax.put("fileName", fileName); + ajax.put("url", url); + return ajax; + }catch (Exception e){ + return AjaxResult.error(e.getMessage()); + } + + } } From 98244fc04889a262b85d33d75f704ce56d932e7d Mon Sep 17 00:00:00 2001 From: "JiaXing_Cheng@163.com" <JiaXing_Cheng@163.com> Date: Fri, 15 Oct 2021 17:27:07 +0800 Subject: [PATCH 07/10] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/IStandardInfoService.java | 8 + .../service/impl/StandardInfoServiceImpl.java | 49 ++ .../StandardInfoController.java | 21 +- .../com/ruoyi/common/constant/Constants.java | 5 + .../common/utils/file/FileUploadUtils.java | 11 +- ruoyi-ui/src/components/Editor/index.vue | 47 +- .../productionManager/standard/index.vue | 488 ++++++++++++------ sql/ry_20210908.sql | 14 +- 8 files changed, 449 insertions(+), 194 deletions(-) diff --git a/productManager/src/main/java/com/ruoyi/productionManager/service/IStandardInfoService.java b/productManager/src/main/java/com/ruoyi/productionManager/service/IStandardInfoService.java index ef7837e2d..844617375 100644 --- a/productManager/src/main/java/com/ruoyi/productionManager/service/IStandardInfoService.java +++ b/productManager/src/main/java/com/ruoyi/productionManager/service/IStandardInfoService.java @@ -2,6 +2,7 @@ package com.ruoyi.productionManager.service; import java.util.List; import com.ruoyi.productionManager.domain.StandardInfo; +import org.springframework.web.multipart.MultipartFile; /** * 试验标准管理Service接口 @@ -58,4 +59,11 @@ public interface IStandardInfoService * @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/StandardInfoServiceImpl.java b/productManager/src/main/java/com/ruoyi/productionManager/service/impl/StandardInfoServiceImpl.java index ea8a868a0..b30632f42 100644 --- a/productManager/src/main/java/com/ruoyi/productionManager/service/impl/StandardInfoServiceImpl.java +++ b/productManager/src/main/java/com/ruoyi/productionManager/service/impl/StandardInfoServiceImpl.java @@ -1,12 +1,24 @@ package com.ruoyi.productionManager.service.impl; 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.domain.AjaxResult; +import com.ruoyi.common.core.redis.RedisCache; +import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.file.FileUploadUtils; +import com.ruoyi.common.utils.uuid.IdUtils; +import io.netty.handler.codec.base64.Base64; import org.springframework.beans.factory.annotation.Autowired; 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.web.multipart.MultipartFile; +import sun.misc.BASE64Encoder; /** * 试验标准管理Service业务层处理 @@ -20,6 +32,9 @@ public class StandardInfoServiceImpl implements IStandardInfoService @Autowired private StandardInfoMapper standardInfoMapper; + @Autowired + private RedisCache redisCache; + /** * 查询试验标准管理 * @@ -93,4 +108,38 @@ public class StandardInfoServiceImpl implements IStandardInfoService { return standardInfoMapper.deleteStandardInfoByStandardId(standardId); } + + @Override + public String uploadFile(MultipartFile file) { + try { + String filePath = RuoYiConfig.getUploadPath(); + IdUtils.fastUUID(); + // 上传并返回新文件名称 + String fileName = FileUploadUtils.upload(filePath, file); + String name =""; + for(String s:fileName.split("/",9)){ + System.out.println("path>>>"+s); + name = s; + } + Byte[] data = new Byte[file.getResource().getInputStream().available()]; + redisCache.setCacheObject(Constants.UPLOAD_FILE+name, + data, 30, TimeUnit.MINUTES); +// 取出缓存数据 + Byte[] bytes = redisCache.getCacheObject(Constants.UPLOAD_FILE+name); + + 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/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 index 1b2552e83..df339b21a 100644 --- 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 @@ -3,6 +3,7 @@ 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; @@ -111,18 +112,22 @@ public class StandardInfoController extends BaseController @PostMapping("/upload") public AjaxResult getFiles(@Param("file") MultipartFile file){ - try{ - String filePath = RuoYiConfig.getUploadPath(); - // 上传并返回新文件名称 - String fileName = FileUploadUtils.upload(filePath, 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); - ajax.put("url", url); + url.split("/"); + String path =""; + for(String s:url.split("/",4)){ + System.out.println("path>>>"+s); + path = s; + } + ajax.put("url", path); return ajax; - }catch (Exception e){ - return AjaxResult.error(e.getMessage()); - } } + } 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..0d526f84b 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,9 @@ public class Constants * LDAP 远程方法调用 */ public static final String LOOKUP_LDAP = "ldap://"; + + /** + * LDAP 远程方法调用 + */ + public static final String UPLOAD_FILE = "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-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/views/productionManager/standard/index.vue b/ruoyi-ui/src/views/productionManager/standard/index.vue index 4a60cbc60..ae5cf908f 100644 --- a/ruoyi-ui/src/views/productionManager/standard/index.vue +++ b/ruoyi-ui/src/views/productionManager/standard/index.vue @@ -1,195 +1,289 @@ <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 :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 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-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-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-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-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-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-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-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-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-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> + <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" /> - <el-table-column label="区域分类" align="center" prop="areaCategory" /> - <el-table-column label="标准名称" align="center" prop="standardName" /> - <el-table-column label="标准类型" align="center" prop="standardCategory"> + <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"/> + <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"> + <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"> + <el-table-column label="标准状态" + align="center" + prop="standardStatus"> <template slot-scope="scope"> - <dict-tag :options="dict.type.pro_standard_status" :value="scope.row.standardStatus"/> + <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"> + <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-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" - /> + + <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-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 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 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-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 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 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> + <div slot="footer" + class="dialog-footer"> + <el-button type="primary" + @click="submitForm">确 定</el-button> <el-button @click="cancel">取 消</el-button> </div> </el-dialog> @@ -198,12 +292,41 @@ <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() { + 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, // 导出遮罩层 @@ -233,6 +356,7 @@ export default { standardCategory: null, standardBeginDate: null, standardStatus: null, + }, // 表单参数 form: {}, @@ -250,15 +374,63 @@ export default { standardStatus: [ { required: true, message: "标准状态不能为空", trigger: "blur" } ], + // path: [ + // { required: true, message: "文件不能为空", trigger: ["blur"] } + // ], + // path: [ + // { required: true, validator: validatorPath, trigger: ["blur", "change"] } + // ], } }; }, - created() { + 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() { + getList () { this.loading = true; listStandard(this.queryParams).then(response => { this.standardList = response.rows; @@ -267,12 +439,12 @@ export default { }); }, // 取消按钮 - cancel() { + cancel () { this.open = false; this.reset(); }, // 表单重置 - reset() { + reset () { this.form = { standardId: null, areaCategory: null, @@ -289,29 +461,30 @@ export default { this.resetForm("form"); }, /** 搜索按钮操作 */ - handleQuery() { + handleQuery () { this.queryParams.pageNum = 1; this.getList(); }, /** 重置按钮操作 */ - resetQuery() { + resetQuery () { this.resetForm("queryForm"); this.handleQuery(); }, // 多选框选中数据 - handleSelectionChange(selection) { + handleSelectionChange (selection) { this.ids = selection.map(item => item.standardId) - this.single = selection.length!==1 + this.single = selection.length !== 1 this.multiple = !selection.length }, /** 新增按钮操作 */ - handleAdd() { + handleAdd () { this.reset(); this.open = true; + this.upload.fileList = []; this.title = "添加试验标准管理"; }, /** 修改按钮操作 */ - handleUpdate(row) { + handleUpdate (row) { this.reset(); const standardId = row.standardId || this.ids getStandard(standardId).then(response => { @@ -321,7 +494,7 @@ export default { }); }, /** 提交按钮 */ - submitForm() { + submitForm () { this.$refs["form"].validate(valid => { if (valid) { if (this.form.standardId != null) { @@ -341,17 +514,17 @@ export default { }); }, /** 删除按钮操作 */ - handleDelete(row) { + handleDelete (row) { const standardIds = row.standardId || this.ids; - this.$modal.confirm('是否确认删除试验标准管理编号为"' + standardIds + '"的数据项?').then(function() { + this.$modal.confirm('是否确认删除试验标准管理编号为"' + standardIds + '"的数据项?').then(function () { return delStandard(standardIds); }).then(() => { this.getList(); this.$modal.msgSuccess("删除成功"); - }).catch(() => {}); + }).catch(() => { }); }, /** 导出按钮操作 */ - handleExport() { + handleExport () { const queryParams = this.queryParams; this.$modal.confirm('是否确认导出所有试验标准管理数据项?').then(() => { this.exportLoading = true; @@ -359,8 +532,13 @@ export default { }).then(response => { this.$download.name(response.msg); this.exportLoading = false; - }).catch(() => {}); + }).catch(() => { }); } } }; </script> +<style> +.el-upload__tip { + line-height: 1.2; +} +</style> diff --git a/sql/ry_20210908.sql b/sql/ry_20210908.sql index af0868fbd..7a89a1774 100644 --- a/sql/ry_20210908.sql +++ b/sql/ry_20210908.sql @@ -693,9 +693,9 @@ 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_category varchar(200) not null comment '标准类型', standard_begin_date varchar(250) null comment '标准实施日期', - standard_status varchar(20) not 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 '更新者', @@ -703,16 +703,18 @@ create table STANDARD_INFO ( 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 ( - standard_id bigint(20) not null auto_increment comment '标准id', - details_id bigint(20) not null comment '岗位ID', - file_name varchar(200) not null comment '文件名称', + 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 (standard_id, details_id) + primary key (details_id,standard_id) ) engine=innodb comment = '标准信息文件表'; From 1682de731d039fa249491923117d3f0d2c31b40a Mon Sep 17 00:00:00 2001 From: "JiaXing_Cheng@163.com" <JiaXing_Cheng@163.com> Date: Tue, 19 Oct 2021 11:10:16 +0800 Subject: [PATCH 08/10] =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=BC=93=E5=AD=98?= =?UTF-8?q?=EF=BC=8C=E4=BF=9D=E5=AD=98=E8=B7=AF=E5=BE=84=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- productManager/pom.xml | 11 ++ .../domain/StandardInfoDetails.java | 83 ++++++++++++++ .../mapper/StandardInfoDetailsMapper.java | 61 +++++++++++ .../service/IStandardInfoDetailsService.java | 61 +++++++++++ .../service/IStandardInfoService.java | 3 +- .../impl/StandardInfoDetailsServiceImpl.java | 96 ++++++++++++++++ .../service/impl/StandardInfoServiceImpl.java | 74 +++++++++++-- .../vo/StandardManagerVO.java | 24 ++++ .../StandardInfoDetailsMapper.xml | 85 +++++++++++++++ .../productionManager/StandardInfoMapper.xml | 7 +- .../StandardInfoController.java | 4 +- .../StandardInfoDetailsController.java | 103 ++++++++++++++++++ .../common/utils/file/FileTypeUtils.java | 92 ++++++++++++++++ 13 files changed, 689 insertions(+), 15 deletions(-) create mode 100644 productManager/src/main/java/com/ruoyi/productionManager/domain/StandardInfoDetails.java create mode 100644 productManager/src/main/java/com/ruoyi/productionManager/mapper/StandardInfoDetailsMapper.java create mode 100644 productManager/src/main/java/com/ruoyi/productionManager/service/IStandardInfoDetailsService.java create mode 100644 productManager/src/main/java/com/ruoyi/productionManager/service/impl/StandardInfoDetailsServiceImpl.java create mode 100644 productManager/src/main/java/com/ruoyi/productionManager/vo/StandardManagerVO.java create mode 100644 productManager/src/main/resources/mapper/productionManager/StandardInfoDetailsMapper.xml create mode 100644 ruoyi-admin/src/main/java/com/ruoyi/web/controller/productionManager/StandardInfoDetailsController.java diff --git a/productManager/pom.xml b/productManager/pom.xml index 4359307df..a46bad5e0 100644 --- a/productManager/pom.xml +++ b/productManager/pom.xml @@ -27,6 +27,17 @@ <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> 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/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 index 844617375..9a71e1f2d 100644 --- a/productManager/src/main/java/com/ruoyi/productionManager/service/IStandardInfoService.java +++ b/productManager/src/main/java/com/ruoyi/productionManager/service/IStandardInfoService.java @@ -2,6 +2,7 @@ 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; /** @@ -34,7 +35,7 @@ public interface IStandardInfoService * @param standardInfo 试验标准管理 * @return 结果 */ - public int insertStandardInfo(StandardInfo standardInfo); + public int insertStandardInfo(StandardManagerVO standardManagerVO); /** * 修改试验标准管理 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 index b30632f42..1e737ba74 100644 --- a/productManager/src/main/java/com/ruoyi/productionManager/service/impl/StandardInfoServiceImpl.java +++ b/productManager/src/main/java/com/ruoyi/productionManager/service/impl/StandardInfoServiceImpl.java @@ -1,24 +1,32 @@ 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.domain.AjaxResult; 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 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.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.web.multipart.MultipartFile; -import sun.misc.BASE64Encoder; +import org.apache.http.entity.ContentType; + /** * 试验标准管理Service业务层处理 @@ -35,6 +43,9 @@ public class StandardInfoServiceImpl implements IStandardInfoService @Autowired private RedisCache redisCache; + @Autowired + private IStandardInfoDetailsService standardInfoDetailsService; + /** * 查询试验标准管理 * @@ -62,14 +73,48 @@ public class StandardInfoServiceImpl implements IStandardInfoService /** * 新增试验标准管理 * - * @param standardInfo 试验标准管理 + * @param standardManagerVO 试验标准管理 * @return 结果 */ @Override - public int insertStandardInfo(StandardInfo standardInfo) + public int insertStandardInfo(StandardManagerVO standardManagerVO) { - standardInfo.setCreateTime(DateUtils.getNowDate()); - return standardInfoMapper.insertStandardInfo(standardInfo); + String filePath = RuoYiConfig.getUploadPath(); + // 取出缓存数据 + 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) { try { String filePath = RuoYiConfig.getUploadPath(); - IdUtils.fastUUID(); // 上传并返回新文件名称 String fileName = FileUploadUtils.upload(filePath, file); String name =""; @@ -121,12 +165,18 @@ public class StandardInfoServiceImpl implements IStandardInfoService System.out.println("path>>>"+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, 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; }catch (Exception e){ throw new ServiceException("上传失败:" + e.getMessage()); 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 index 5ac601caa..a3fc02109 100644 --- a/productManager/src/main/resources/mapper/productionManager/StandardInfoMapper.xml +++ b/productManager/src/main/resources/mapper/productionManager/StandardInfoMapper.xml @@ -38,9 +38,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where standard_id = #{standardId} </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 <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> 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 index df339b21a..89136e21b 100644 --- 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 @@ -7,6 +7,7 @@ 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; @@ -83,8 +84,9 @@ public class StandardInfoController extends BaseController @PreAuthorize("@ss.hasPermi('productionManager:standard:add')") @Log(title = "试验标准管理", businessType = BusinessType.INSERT) @PostMapping - public AjaxResult add(@RequestBody StandardInfo standardInfo) + public AjaxResult add(@RequestBody StandardManagerVO standardInfo) { + standardInfo.setCreateBy(getUsername()); return toAjax(standardInfoService.insertStandardInfo(standardInfo)); } 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-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 From 1a4db5fa077b67b2343493f75953edada27f9a9c Mon Sep 17 00:00:00 2001 From: "JiaXing_Cheng@163.com" <JiaXing_Cheng@163.com> Date: Tue, 19 Oct 2021 14:00:42 +0800 Subject: [PATCH 09/10] =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=BC=93=E5=AD=98?= =?UTF-8?q?=EF=BC=8C=E4=BF=9D=E5=AD=98=E8=B7=AF=E5=BE=84=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../productionManager/service/impl/StandardInfoServiceImpl.java | 1 + 1 file changed, 1 insertion(+) 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 index 1e737ba74..52009b0f7 100644 --- a/productManager/src/main/java/com/ruoyi/productionManager/service/impl/StandardInfoServiceImpl.java +++ b/productManager/src/main/java/com/ruoyi/productionManager/service/impl/StandardInfoServiceImpl.java @@ -111,6 +111,7 @@ public class StandardInfoServiceImpl implements IStandardInfoService standardInfoDetails.setFileName(name); standardInfoDetails.setStandardId(standardManagerVO.getStandardId()); standardInfoDetails.setCreateBy(SecurityUtils.getLoginUser().getUsername()); + redisCache.deleteObject(Constants.UPLOAD_FILE+name); return standardInfoDetailsService.insertStandardInfoDetails(standardInfoDetails); }catch (Exception e){ throw new ServiceException("新增失败:" + e.getMessage()); From 9a2271957bdee8f4bfdbb3216fa1567a868f0dba Mon Sep 17 00:00:00 2001 From: "JiaXing_Cheng@163.com" <JiaXing_Cheng@163.com> Date: Tue, 19 Oct 2021 15:30:46 +0800 Subject: [PATCH 10/10] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=BA=90=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/IStandardInfoService.java | 2 +- .../service/impl/StandardInfoServiceImpl.java | 47 ++++++++++++++++--- .../StandardInfoController.java | 2 +- .../com/ruoyi/common/constant/Constants.java | 7 ++- 4 files changed, 49 insertions(+), 9 deletions(-) diff --git a/productManager/src/main/java/com/ruoyi/productionManager/service/IStandardInfoService.java b/productManager/src/main/java/com/ruoyi/productionManager/service/IStandardInfoService.java index 9a71e1f2d..4e5a137d7 100644 --- a/productManager/src/main/java/com/ruoyi/productionManager/service/IStandardInfoService.java +++ b/productManager/src/main/java/com/ruoyi/productionManager/service/IStandardInfoService.java @@ -43,7 +43,7 @@ public interface IStandardInfoService * @param standardInfo 试验标准管理 * @return 结果 */ - public int updateStandardInfo(StandardInfo standardInfo); + public int updateStandardInfo(StandardManagerVO standardManagerVO); /** * 批量删除试验标准管理 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 index 52009b0f7..93b0e98c9 100644 --- a/productManager/src/main/java/com/ruoyi/productionManager/service/impl/StandardInfoServiceImpl.java +++ b/productManager/src/main/java/com/ruoyi/productionManager/service/impl/StandardInfoServiceImpl.java @@ -24,6 +24,7 @@ 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; @@ -84,19 +85,19 @@ public class StandardInfoServiceImpl implements IStandardInfoService 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++){ - 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); + 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); @@ -108,11 +109,14 @@ public class StandardInfoServiceImpl implements IStandardInfoService standardInfoMapper.insertStandardInfo(standardManagerVO); StandardInfoDetails standardInfoDetails = new StandardInfoDetails(); standardInfoDetails.setFileUrl(filePath+fileName); - standardInfoDetails.setFileName(name); + 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()); } @@ -125,10 +129,40 @@ public class StandardInfoServiceImpl implements IStandardInfoService * @return 结果 */ @Override - public int updateStandardInfo(StandardInfo standardInfo) + public int updateStandardInfo(StandardManagerVO standardManagerVO) { - standardInfo.setUpdateTime(DateUtils.getNowDate()); - return standardInfoMapper.updateStandardInfo(standardInfo); + 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()); + } } /** @@ -172,6 +206,7 @@ public class StandardInfoServiceImpl implements IStandardInfoService 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); 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 index 89136e21b..b55be367a 100644 --- 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 @@ -96,7 +96,7 @@ public class StandardInfoController extends BaseController @PreAuthorize("@ss.hasPermi('productionManager:standard:edit')") @Log(title = "试验标准管理", businessType = BusinessType.UPDATE) @PutMapping - public AjaxResult edit(@RequestBody StandardInfo standardInfo) + public AjaxResult edit(@RequestBody StandardManagerVO standardInfo) { return toAjax(standardInfoService.updateStandardInfo(standardInfo)); } 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 0d526f84b..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 @@ -150,7 +150,12 @@ public class Constants public static final String LOOKUP_LDAP = "ldap://"; /** - * LDAP 远程方法调用 + * 文件上传 */ public static final String UPLOAD_FILE = "file:"; + + /** + * 文件上传 + */ + public static final String UPLOAD_FILE_NAME = "filename:"; }