| | |
| | | |
| | | int deleteByPrimaryKey(Long id); |
| | | |
| | | int insert(PltProductFile record); |
| | | |
| | | int insertSelective(PltProductFile record); |
| | | |
| | | PltProductFile selectByPrimaryKey(Long id); |
| | |
| | | @NotNull(message = "技术参数不能为空") |
| | | public List<PltProductParams> params; |
| | | |
| | | /** |
| | | * 文件类型:01:工艺文件,02:用户手册,03:物料清单 |
| | | */ |
| | | @NotNull(message = "工艺文件不能为空") |
| | | public List<PltProductFile> processDocuments; |
| | | |
| | | @NotNull(message = "用户手册不能为空") |
| | | public List<PltProductFile> userManual; |
| | | |
| | | @NotNull(message = "物料清单不能为空") |
| | | public List<PltProductFile> materials; |
| | | @NotNull(message = "产品文件不能为空") |
| | | public List<PltProductFile> proFiles; |
| | | |
| | | |
| | | } |
| | |
| | | delete from plt_product_file |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </delete> |
| | | <delete id="deleteByProId"> |
| | | delete from plt_product_file |
| | | where pro_id = #{proId,jdbcType=BIGINT} |
| | | </delete> |
| | | <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.dy.pmsGlobal.pojoPlt.PltProductFile" useGeneratedKeys="true"> |
| | | insert into plt_product_file |
| | | ( id,pro_id,file_id |
| | | ,file_type) |
| | | values (#{id,jdbcType=BIGINT},#{proId,jdbcType=BIGINT},#{fileId,jdbcType=BIGINT} |
| | | ,#{fileType,jdbcType=VARCHAR}) |
| | | </insert> |
| | | <delete id="deleteByProId"> |
| | | delete from plt_product_file |
| | | where pro_id = #{proId,jdbcType=BIGINT} |
| | | </delete> |
| | | <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.dy.pmsGlobal.pojoPlt.PltProductFile" useGeneratedKeys="true"> |
| | | insert into plt_product_file |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | |
| | | |
| | | <resultMap id="BaseResultMap2" type="com.dy.pmsGlobal.pojoPlt.PltProduct" extends="BaseResultMap"> |
| | | <collection property="params" ofType="com.dy.pmsGlobal.pojoPlt.PltProductParams" fetchType="eager" select="selectParams" column="id" /> |
| | | <collection property="processDocuments" ofType="com.dy.pmsGlobal.pojoPlt.PltProductFile" fetchType="eager" select="selectDocuments" column="id"/> |
| | | <collection property="userManual" ofType="com.dy.pmsGlobal.pojoPlt.PltProductFile" fetchType="eager" select="selectUserManual" column="id" /> |
| | | <collection property="materials" ofType="com.dy.pmsGlobal.pojoPlt.PltProductFile" fetchType="eager" select="selectMaterials" column="id"/> |
| | | <collection property="proFiles" ofType="com.dy.pmsGlobal.pojoPlt.PltProductFile" fetchType="eager" select="selectDocuments" column="id"/> |
| | | </resultMap> |
| | | <sql id="Base_Column_List"> |
| | | <!--@mbg.generated--> |
| | |
| | | <select id="selectDocuments" resultMap="com.dy.pmsGlobal.daoPlt.PltProductFileMapper.BaseResultMap"> |
| | | select * |
| | | from plt_product_file |
| | | where pro_id = #{proId,jdbcType=BIGINT} and file_type = '01' |
| | | </select> |
| | | <select id="selectUserManual" resultMap="com.dy.pmsGlobal.daoPlt.PltProductFileMapper.BaseResultMap"> |
| | | select * |
| | | from plt_product_file |
| | | where pro_id = #{proId,jdbcType=BIGINT} and file_type = '02' |
| | | </select> |
| | | <select id="selectMaterials" resultMap="com.dy.pmsGlobal.daoPlt.PltProductFileMapper.BaseResultMap"> |
| | | select * |
| | | from plt_product_file |
| | | where pro_id = #{proId,jdbcType=BIGINT} and file_type = '03' |
| | | where pro_id = #{proId,jdbcType=BIGINT} |
| | | </select> |
| | | |
| | | <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap2"> |
| | |
| | | package com.dy.pmsPlatform.product; |
| | | |
| | | import com.alibaba.excel.converters.Converter; |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.dy.common.aop.SsoPowerAop; |
| | | import com.dy.common.webUtil.BaseResponse; |
| | | import com.dy.common.webUtil.BaseResponseUtils; |
| | |
| | | import jakarta.validation.Valid; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.core.io.ByteArrayResource; |
| | | import org.springframework.core.io.FileSystemResource; |
| | | import org.springframework.core.io.Resource; |
| | | import org.springframework.http.ContentDisposition; |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.util.StreamUtils; |
| | | import org.springframework.validation.BindingResult; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.zip.ZipEntry; |
| | | import java.util.zip.ZipOutputStream; |
| | | |
| | | /** |
| | | * 产品管理 |
| | |
| | | paramDao.insert(param); |
| | | } |
| | | }); |
| | | saveRel(p, p.processDocuments, "01"); |
| | | saveRel(p, p.userManual, "02"); |
| | | saveRel(p, p.materials, "03"); |
| | | saveRel(p, p.proFiles); |
| | | } |
| | | |
| | | private void saveRel(PltProduct p, List<PltProductFile> docs, String fileType) { |
| | | private void saveRel(PltProduct p, List<PltProductFile> docs) { |
| | | docs.forEach(doc -> { |
| | | doc.proId = p.id; |
| | | doc.fileType = fileType; |
| | | pfDao.insert(doc); |
| | | if(doc.id == null){ |
| | | doc.proId = p.id; |
| | | pfDao.insertSelective(doc); |
| | | } |
| | | }); |
| | | } |
| | | |
| | |
| | | pro.imageWebPathZip = fileOperate.getImgFileZipPath(filePathWithWebUrl); |
| | | } |
| | | |
| | | Stream.concat( |
| | | pro.userManual.stream(), |
| | | Stream.concat(pro.processDocuments.stream(), pro.materials.stream()) |
| | | ) |
| | | .forEach(doc -> { |
| | | pro.proFiles.stream().forEach(doc -> { |
| | | OthFile file = othFileMapper.selectByPrimaryKey(doc.fileId); |
| | | FileRestVo fileRestVo = fileOperate.parseHashcode(fmUrl, file.hash); |
| | | |