liuyc 2 years ago
parent
commit
d8ded9009c

+ 7 - 7
blade-service/blade-business/src/main/java/org/springblade/business/controller/ImageClassificationFileController.java

@@ -163,8 +163,8 @@ public class ImageClassificationFileController extends BladeController {
                     //需要删除的本地文件集合
                     List<String> removeList = new ArrayList<>();
 
-                    // 压缩到小于指定文件大小500kb
-                    double targetSize = 500 * 1024;
+                    //压缩到小于指定文件大小100kb
+                    //double targetSize = 100 * 1024;
 
                     for (ImageClassificationFile file : fileResult) {
                         //获取图片文件流
@@ -204,16 +204,16 @@ public class ImageClassificationFileController extends BladeController {
 
                                             //获取文件流
                                             byte[] bytes = CommonUtil.InputStreamToBytes(CommonUtil.getOSSInputStream(urls.get(i)));
-                                            byte[] a = new byte[(int) targetSize];
+
                                             //压缩文件大小
-                                            while (bytes.length > targetSize) {
+                                            /*while (bytes.length > targetSize) {
                                                 float reduceMultiple = 0.5f;
                                                 bytes = FileUtils.resizeImage(bytes, reduceMultiple);
-                                                a = bytes;
-                                            }
+                                            }*/
+                                            bytes = FileUtils.resizeImage(bytes, 0f);
 
                                             //创建图片
-                                            drawing.createPicture(anchor, workbook.addPicture(a, Workbook.PICTURE_TYPE_JPEG));
+                                            drawing.createPicture(anchor, workbook.addPicture(bytes, Workbook.PICTURE_TYPE_JPEG));
                                             //图片定位
                                             FileUtils.imageOrientation(sheet, anchor, i == 1 ? new DataVO(1, 28) : new DataVO(0, 0));
 

+ 24 - 15
blade-service/blade-business/src/main/java/org/springblade/business/controller/InformationWriteQueryController.java

@@ -363,7 +363,7 @@ public class InformationWriteQueryController extends BladeController {
             //获取数据源节点
             CopyContractTreeNodeVO.CopyBatch copyBatchResource = batchPathList.stream().filter(f -> f.getPrimaryKeyId().equals(wbsTreeContract.getPKeyId().toString())).findAny().orElse(null);
             if (copyBatchResource != null) {
-                throw new ServiceException("请选择除【" + wbsTreeContract.getNodeName() + "】源节点之外的节点进行复制");
+                return R.fail("请选择除【" + wbsTreeContract.getNodeName() + "】源节点之外的节点进行复制");
             }
 
             String tabOwner;
@@ -388,17 +388,27 @@ public class InformationWriteQueryController extends BladeController {
                 //获取源数据
                 Map<String, List<List<Map<String, Object>>>> tableBusinessDataMap = new HashMap<>();
                 for (WbsTreeContract treeContract : tableList) {
-                    List<Map<String, Object>> tableBusinessData = this.jdbcTemplate.queryForList("select * from " + treeContract.getInitTableName() + " where p_key_id = " + treeContract.getPKeyId());
-                    if (tableBusinessData.size() > 0) {
-                        //设置参数
-                        List<List<Map<String, Object>>> list;
-                        if (tableBusinessDataMap.containsKey(treeContract.getId().toString())) {
-                            list = tableBusinessDataMap.get(treeContract.getId().toString());
-                        } else {
-                            list = new ArrayList<>();
+                    if (StringUtils.isNotEmpty(treeContract.getInitTableName())) {
+                        //判断表是否存在
+                        String isExitSql = "select * from information_schema.TABLES where TABLE_NAME='" + treeContract.getInitTableName() + "'";
+                        List<Map<String, Object>> tabList = this.jdbcTemplate.queryForList(isExitSql);
+                        if (tabList.size() == 0) {
+                            continue; //未找到实体表跳过
+                        }
+
+                        String sql = "select * from " + treeContract.getInitTableName() + " where p_key_id = " + treeContract.getPKeyId();
+                        List<Map<String, Object>> tableBusinessData = this.jdbcTemplate.queryForList(sql);
+                        if (tableBusinessData.size() > 0) {
+                            //设置参数
+                            List<List<Map<String, Object>>> list;
+                            if (tableBusinessDataMap.containsKey(treeContract.getId().toString())) {
+                                list = tableBusinessDataMap.get(treeContract.getId().toString());
+                            } else {
+                                list = new ArrayList<>();
+                            }
+                            list.add(tableBusinessData);
+                            tableBusinessDataMap.put(treeContract.getId().toString(), list);
                         }
-                        list.add(tableBusinessData);
-                        tableBusinessDataMap.put(treeContract.getId().toString(), list);
                     }
                 }
 
@@ -495,7 +505,7 @@ public class InformationWriteQueryController extends BladeController {
                         str.add("【" + map.getValue() + "-" + map.getKey() + "】");
                     }
                     String join = StringUtils.join(str, "、");
-                    throw new ServiceException(StringUtil.format("节点{}已上报,无法复制数据,请重新选择", join));
+                    return R.fail(StringUtil.format("节点{}已上报,无法复制数据,请重新选择", join));
                 }
 
                 //删除原本填写的数据,覆盖
@@ -532,8 +542,8 @@ public class InformationWriteQueryController extends BladeController {
                                 //新增源数据附件到复制节点下对应表中
                                 tableFileClient.saveBatchFile(query, next.getPKeyId());
 
-                                //修改复制节点下对应表的按钮状态
-                                String updateStatus = "update m_wbs_tree_contract set tab_file_type = " + sourceDataObj.getTabFileType() + " ,is_tab_pdf = " + sourceDataObj.getIsTabPdf() + " ,pdf_url = '" + sourceDataObj.getPdfUrl() + "' ,is_buss_show = " + sourceDataObj.getIsBussShow() + " where p_key_id = " + next.getPKeyId();
+                                //修改复制节点下对应表的文件上传的按钮状态
+                                String updateStatus = "update m_wbs_tree_contract set tab_file_type = " + sourceDataObj.getTabFileType() + " where p_key_id = " + next.getPKeyId();
                                 jdbcTemplate.execute(updateStatus);
 
                                 iterator.remove();
@@ -542,7 +552,6 @@ public class InformationWriteQueryController extends BladeController {
                     }
                 }
             }
-
             return R.data(true);
         }
 

+ 4 - 2
blade-service/blade-business/src/main/java/org/springblade/business/utils/FileUtils.java

@@ -104,8 +104,10 @@ public class FileUtils {
      */
     public static byte[] resizeImage(byte[] srcImgData, float reduceMultiple) throws IOException {
         BufferedImage bi = ImageIO.read(new ByteArrayInputStream(srcImgData));
-        int width = (int) (bi.getWidth() * reduceMultiple);
-        int height = (int) (bi.getHeight() * reduceMultiple);
+        /*int width = (int) (bi.getWidth() * reduceMultiple);
+        int height = (int) (bi.getHeight() * reduceMultiple);*/
+        int width = 768;
+        int height = 1024;
         Image image = bi.getScaledInstance(width, height, Image.SCALE_SMOOTH);
         BufferedImage tag = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
         Graphics g = tag.getGraphics();