Jelajahi Sumber

-修改:现在下载excel不会出现文件不存在的报错

jiangbiao 2 tahun lalu
induk
melakukan
4c93f6313e

+ 64 - 57
master/src/main/java/com/ruoyi/project/production/controller/TFivesRegionController.java

@@ -255,43 +255,46 @@ public class TFivesRegionController extends BaseController {
                 }
 
                 for (int i = 0; i < urls.size(); i++) {
-                    String url = urls.get(i);
-                    ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
-                    BufferedImage bufferImg = ImageIO.read(new File(RuoYiConfig.getProfile() + url.replaceFirst("/profile", "")));
-                    ImageIO.write(bufferImg, "jpg", byteArrayOut);
-                    int h = 0;
-                    int l = 0;
-                    int endh = 0;
-                    int endl = 0;
-                    if (urls.size() == 1) {
-                        endl = 5;
-                        endh = 10;
-                    }
-                    if (i == 0) {
-                        if (urls.size() == 2) {
+                    try {
+                        String url = urls.get(i);
+                        ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
+                        BufferedImage bufferImg = ImageIO.read(new File(RuoYiConfig.getProfile() + url.replaceFirst("/profile", "")));
+                        ImageIO.write(bufferImg, "jpg", byteArrayOut);
+                        int h = 0;
+                        int l = 0;
+                        int endh = 0;
+                        int endl = 0;
+                        if (urls.size() == 1) {
                             endl = 5;
+                            endh = 10;
                         }
-                    } else if (i == 1) {
-                        if (urls.size() == 2) {
+                        if (i == 0) {
+                            if (urls.size() == 2) {
+                                endl = 5;
+                            }
+                        } else if (i == 1) {
+                            if (urls.size() == 2) {
+                                h = 12;
+                                endh = 10;
+                            } else {
+                                l = 5;
+                            }
+                            endl = 5;
+                        } else if (i == 2) {
                             h = 12;
                             endh = 10;
-                        } else {
+                        } else if (i == 3) {
                             l = 5;
+                            endl = 5;
+                            h = 12;
+                            endh = 10;
                         }
-                        endl = 5;
-                    } else if (i == 2) {
-                        h = 12;
-                        endh = 10;
-                    } else if (i == 3) {
-                        l = 5;
-                        endl = 5;
-                        h = 12;
-                        endh = 10;
+                        XSSFClientAnchor anchor = new XSSFClientAnchor(0, 0, 0, 0, 6 + l, 2 + h, 11 + endl, 14 + endh);
+                        // 插入图片
+                        patriarch.createPicture(anchor, wb.addPicture(byteArrayOut.toByteArray(), XSSFWorkbook.PICTURE_TYPE_JPEG));
+                        byteArrayOut.close();
+                    } catch (Exception e) {
                     }
-                    XSSFClientAnchor anchor = new XSSFClientAnchor(0, 0, 0, 0, 6 + l, 2 + h, 11 + endl, 14 + endh);
-                    // 插入图片
-                    patriarch.createPicture(anchor, wb.addPicture(byteArrayOut.toByteArray(), XSSFWorkbook.PICTURE_TYPE_JPEG));
-                    byteArrayOut.close();
                 }
             }
             List<String> urls = new ArrayList<>();
@@ -311,34 +314,38 @@ public class TFivesRegionController extends BaseController {
                 }
             }
             for (int i = 0; i < urls.size(); i++) {
-                String url = urls.get(i);
-                ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
-                BufferedImage bufferImg = ImageIO.read(new File(RuoYiConfig.getProfile() + url.replaceFirst("/profile", "")));
-                ImageIO.write(bufferImg, "jpg", byteArrayOut);
-                int h = 0;
-                int l = 0;
-                int endh = 0;
-                int endl = 0;
-                if (urls.size() == 1) {
-                    endl = 1;
-                    endh = 2;
-                }
-                if (i == 1) {
-                    l = 1;
-                    endl = 1;
-                } else if (i == 2) {
-                    h = 2;
-                    endh = 2;
-                } else if (i == 3) {
-                    l = 1;
-                    endl = 1;
-                    h = 2;
-                    endh = 2;
+                try {
+                    String url = urls.get(i);
+                    ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
+                    BufferedImage bufferImg = ImageIO.read(new File(RuoYiConfig.getProfile() + url.replaceFirst("/profile", "")));
+                    ImageIO.write(bufferImg, "jpg", byteArrayOut);
+                    int h = 0;
+                    int l = 0;
+                    int endh = 0;
+                    int endl = 0;
+                    if (urls.size() == 1) {
+                        endl = 1;
+                        endh = 2;
+                    }
+                    if (i == 1) {
+                        l = 1;
+                        endl = 1;
+                    } else if (i == 2) {
+                        h = 2;
+                        endh = 2;
+                    } else if (i == 3) {
+                        l = 1;
+                        endl = 1;
+                        h = 2;
+                        endh = 2;
+                    }
+                    XSSFClientAnchor anchor = new XSSFClientAnchor(0, 0, 0, 0, 0 + l, 14 + h, 1 + endl, 16 + endh);
+                    // 插入图片
+                    patriarch.createPicture(anchor, wb.addPicture(byteArrayOut.toByteArray(), XSSFWorkbook.PICTURE_TYPE_JPEG));
+                    byteArrayOut.close();
+                } catch (Exception e) {
+                    continue;
                 }
-                XSSFClientAnchor anchor = new XSSFClientAnchor(0, 0, 0, 0, 0 + l, 14 + h, 1 + endl, 16 + endh);
-                // 插入图片
-                patriarch.createPicture(anchor, wb.addPicture(byteArrayOut.toByteArray(), XSSFWorkbook.PICTURE_TYPE_JPEG));
-                byteArrayOut.close();
             }
             String fileName = DateUtils.dateTimeNow() + "_" + tFivesRegion.getPersonLiable() + ".xlsx";
             wb.write(Files.newOutputStream(Paths.get(filePath + "/" + fileName)));

+ 0 - 2
master/src/main/resources/mybatis/production/TFivesChangeRecordMapper.xml

@@ -132,8 +132,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="changeFile != null and changeFile != ''">change_file = #{changeFile},</if>
             <if test="changeResult != null">change_result = #{changeResult},</if>
             <if test="delFlag != null">del_flag = #{delFlag},</if>
-            <if test="createrCode != null">creater_code = #{createrCode},</if>
-            <if test="createdate != null">createdate = #{createdate},</if>
             <if test="updaterCode != null">updater_code = #{updaterCode},</if>
             <if test="updatedate != null">updatedate = #{updatedate},</if>
             <if test="remarks != null">remarks = #{remarks},</if>

+ 6 - 8
master/src/main/resources/mybatis/production/TFivesFileMapper.xml

@@ -3,7 +3,7 @@
 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.ruoyi.project.production.mapper.TFivesFileMapper">
-    
+
     <resultMap type="TFivesFile" id="TFivesFileResult">
         <result property="id"    column="id"    />
         <result property="url"    column="url"    />
@@ -26,7 +26,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectTFivesFileList" parameterType="TFivesFile" resultMap="TFivesFileResult">
         <include refid="selectTFivesFileVo"/>
-        <where>  
+        <where>
             <if test="url != null  and url != ''"> and url = #{url}</if>
             <if test="name != null  and name != ''"> and name like concat(concat('%', #{name}), '%')</if>
             <if test="remarks != null  and remarks != ''"> and remarks = #{remarks}</if>
@@ -41,12 +41,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <!-- 数据范围过滤 -->
         ${params.dataScope}
     </select>
-    
+
     <select id="selectTFivesFileById" parameterType="Long" resultMap="TFivesFileResult">
         <include refid="selectTFivesFileVo"/>
         where id = #{id}
     </select>
-        
+
     <insert id="insertTFivesFile" parameterType="TFivesFile">
         <selectKey keyProperty="id" resultType="long" order="BEFORE">
             SELECT seq_t_fives_file.NEXTVAL as id FROM DUAL
@@ -88,8 +88,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="remarks != null">remarks = #{remarks},</if>
             <if test="status != null">status = #{status},</if>
             <if test="delFlag != null">del_flag = #{delFlag},</if>
-            <if test="createrCode != null">creater_code = #{createrCode},</if>
-            <if test="createdate != null">createdate = #{createdate},</if>
             <if test="updaterCode != null">updater_code = #{updaterCode},</if>
             <if test="updatedate != null">updatedate = #{updatedate},</if>
             <if test="deptId != null">dept_id = #{deptId},</if>
@@ -107,5 +105,5 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             #{id}
         </foreach>
     </update>
-    
-</mapper>
+
+</mapper>

+ 0 - 2
master/src/main/resources/mybatis/production/TFivesMonthlyInspectionMapper.xml

@@ -152,8 +152,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="nov != null">nov = #{nov},</if>
             <if test="dec != null">dec = #{dec},</if>
             <if test="delFlag != null">del_flag = #{delFlag},</if>
-            <if test="createrCode != null">creater_code = #{createrCode},</if>
-            <if test="createdate != null">createdate = #{createdate},</if>
             <if test="updaterCode != null">updater_code = #{updaterCode},</if>
             <if test="updatedate != null">updatedate = #{updatedate},</if>
             <if test="remarks != null">remarks = #{remarks},</if>

+ 0 - 2
master/src/main/resources/mybatis/production/TFivesRecordDetailsMapper.xml

@@ -95,8 +95,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="recordId != null">record_id = #{recordId},</if>
             <if test="fileId != null">file_id = #{fileId},</if>
             <if test="delFlag != null">del_flag = #{delFlag},</if>
-            <if test="createrCode != null">creater_code = #{createrCode},</if>
-            <if test="createdate != null">createdate = #{createdate},</if>
             <if test="updaterCode != null">updater_code = #{updaterCode},</if>
             <if test="updatedate != null">updatedate = #{updatedate},</if>
             <if test="remarks != null">remarks = #{remarks},</if>

+ 0 - 2
master/src/main/resources/mybatis/production/TFivesRegionMapper.xml

@@ -121,8 +121,6 @@
             <if test="remarks != null">remarks = #{remarks},</if>
             <if test="status != null">status = #{status},</if>
             <if test="delFlag != null">del_flag = #{delFlag},</if>
-            <if test="createrCode != null">creater_code = #{createrCode},</if>
-            <if test="createdate != null">createdate = #{createdate},</if>
             <if test="updaterCode != null">updater_code = #{updaterCode},</if>
             <if test="updatedate != null">updatedate = #{updatedate},</if>
             <if test="deptId != null">dept_id = #{deptId},</if>