Просмотр исходного кода

Merge remote-tracking branch 'origin/master' into master

yangyj 2 лет назад
Родитель
Сommit
6d84216661

+ 5 - 5
blade-service/blade-business/src/main/java/org/springblade/business/mapper/InformationQueryMapper.xml

@@ -75,20 +75,20 @@
             wtc.id,
             CASE wtc.parent_id
             WHEN 0 THEN (select ci.contract_name from m_contract_info AS ci where wtc.contract_id = ci.id)
-            ELSE IFNULL(if(length(trim(wtc.full_name)) > 0, wtc.full_name, wtc.dept_name),wtc.dept_name) END AS title,
+            ELSE IFNULL(if(length(trim(wtc.full_name)) > 0, wtc.full_name, wtc.node_name),wtc.node_name) END AS title,
             wtc.parent_id AS parentId,
             wtc.contract_id AS contractIdRelation,
             wtc.old_id AS oldId,
             wtc.major_data_type AS majorDataType,
             CASE
-                wtc.dept_category
+                wtc.node_type
             WHEN 6 THEN 'true'
             ELSE 'false' END AS leaf,
             CASE
-                (select count(tc.p_key_id) from m_wbs_tree_contract AS tc where tc.parent_id = wtc.id and tc.contract_id = wtc.contract_id and tc.type = 1 and tc.is_deleted = 0 and tc.dept_category != 111)
+                (select count(tc.p_key_id) from m_wbs_tree_contract AS tc where tc.parent_id = wtc.id and tc.contract_id = wtc.contract_id and tc.type = 1 and tc.is_deleted = 0 and tc.node_type != 111)
             WHEN 0 THEN 'true'
             ELSE 'false' END AS notExsitChild,
-            (select count(tc.p_key_id) from m_wbs_tree_contract AS tc where tc.parent_id = wtc.id and tc.contract_id = wtc.contract_id and tc.type = 1 and tc.is_deleted = 0 and tc.dept_category != 111) AS childCount,
+            (select count(tc.p_key_id) from m_wbs_tree_contract AS tc where tc.parent_id = wtc.id and tc.contract_id = wtc.contract_id and tc.type = 1 and tc.is_deleted = 0 and tc.node_type != 111) AS childCount,
             ctd.file_url AS fileUrl,
             ctd.id AS drawingsId,
             CASE
@@ -138,7 +138,7 @@
             #{contractId}
         </foreach>
         and wtc.parent_id = #{parentId}
-        and wtc.dept_category != 111
+        and wtc.node_type != 111
         and wtc.type = 1
         and wtc.is_deleted= '0'
     </select>

+ 298 - 30
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/ExcelTabController.java

@@ -513,7 +513,7 @@ public class ExcelTabController extends BladeController {
                     String oncklickText = "'" + lastName + "'," + i + "," + j;
 
                     //字段正则表达式校验
-                    String regularExpression = "'" + RegularExpressionUtil.getRegularExpression(filedType) + "'," + "'字段类型:" + (StringUtils.isNotEmpty(filedType) ? WbsElementUtil.getTypeName(filedType) : null) + "'," + i + "," + j;
+                    String regularExpression = "$event"+","+"'" + RegularExpressionUtil.getRegularExpression(filedType) + "','" + (StringUtils.isNotEmpty(filedType) ? WbsElementUtil.getTypeTips(filedType) : null) + "'," + i + "," + j;
 
                     if (is_true) {
                         element.children().get(0).attr("placeholder", lastName).attr("@focus", "getInformation(" + oncklickText + ")")
@@ -658,12 +658,11 @@ public class ExcelTabController extends BladeController {
 
 
 
-
-   /* public static void main(String[] args) throws FileNotFoundException {
+ /*   public static void main(String[] args) throws FileNotFoundException {
 
         String thmlUrl = "/Users/hongchuangyanfa/Desktop/1234567890.html";
 
-        File file1 = ResourceUtil.getFile("/Users/hongchuangyanfa/Downloads/D8.101.xlsx");
+        File file1 = ResourceUtil.getFile("/Users/hongchuangyanfa/Downloads/A16.xlsx");
 
         Workbook wb = new Workbook();
         wb.loadFromMHtml(new FileInputStream(file1));
@@ -698,7 +697,6 @@ public class ExcelTabController extends BladeController {
         Element table = doc.select("table").first();
 
         Elements trs = table.select("tr");
-
         Element tableinfo = trs.get(0).parent().parent().attr("style", "border-collapse: collapse;");
 
         // 获取图片信息
@@ -959,7 +957,7 @@ public class ExcelTabController extends BladeController {
                         String parm = i + "," + j + "," + x1 + "," + x2 + "," + y1 + "," + y2 + ",$event";
                         // 设置文本信息
                         ExctabCell exctabCell = new ExctabCell();
-                        if ((textInfo.indexOf("年") >= 0 && textInfo.indexOf("月") >= 0 && textInfo.indexOf("日") >= 0)|| textInfo.indexOf("日期")>=0 ) {
+                        if (textInfo.indexOf("年") >= 0 && textInfo.indexOf("月") >= 0 && textInfo.indexOf("日") >= 0) {
 
                             data.empty().append("<el-input type='text'  @contextmenu.prevent.native='RightClick(" + parm + ")' trIndex=" + i + " tdIndex=" + j + "  x1=" + x1 + " x2=" + x2 + " y1=" + y1 + " y2=" + y2 + " style='width:100%;height:100%;' placeholder='年月日'> </el-input>");
                             exctabCell.setExctabId(excelId);
@@ -1349,7 +1347,6 @@ public class ExcelTabController extends BladeController {
                 Document doc = Jsoup.parse(htmlString);
                 Element table = doc.select("table").first();
                 Elements trs = table.select("tr");
-                Elements cols = table.select("col");
 
                 if (ObjectUtil.isNotEmpty(DataInfo)) {
                     for (String val : DataInfo.keySet()) {
@@ -1395,33 +1392,22 @@ public class ExcelTabController extends BladeController {
                                 }
                                 //https:bladex-test-info.oss-cn-chengdu.aliyuncs.com//upload/20220819/b53cb6700db369381e3b03d7737bcdec.jpg__16_1
                                 if (myData.indexOf("https") >= 0 && myData.indexOf("aliyuncs") >= 0) {
-
-                                    BufferedImage image = ImageIO.read(CommonUtil.getOSSInputStream(myData));
-
-                                    int colspan = Integer.parseInt(data.attr("colspan"));
-                                    int rowspan = Integer.parseInt(data.attr("rowspan"));
-                                    int picHeight = 0;
-                                    int picWidth = 0;
-                                    for (int i=y1;i<=(y1+rowspan);i++){ // 跨列处理
-                                        String dataInfo = trs.get(i).attr("height");
-                                        if(StringUtils.isNotEmpty(dataInfo)){
-                                            picHeight += Integer.parseInt(dataInfo);
-                                        }
-                                    }
-
-                                    if(colspan>=1){ //框行处理
-                                        for(int i=x1-1;i<x1+colspan-1;i++){
-                                            String dataInfo=cols.get(i).attr("width").replaceAll("px","");
-                                            if(StringUtils.isNotEmpty(dataInfo)){
-                                                picWidth += Integer.parseInt(dataInfo);
-                                            }
+                                  //  Element element = trs.get(y1).select("td").get(x1);
+                                    String styles[] = data.attr("style").split(";");
+                                    int Height = 0;
+                                    for (String sty : styles) {
+                                        if (sty.indexOf("height:") >= 0) {
+                                            Height = Integer.parseInt(sty.replace("height:", "").replace("px", ""));
                                         }
                                     }
 
+                                    BufferedImage image = ImageIO.read(CommonUtil.getOSSInputStream(myData));
                                     ExcelPicture pic = sheet.getPictures().add(y1, x1, image);
-                                    pic.setWidth(picWidth-10);
-                                    pic.setHeight(picHeight);
-                                    pic.setLeft(5);
+                                    pic.setHeight(Height);
+                                    System.out.println(sheet.getCellRange(y1, x1).getRowHeight());
+                                    System.out.println(sheet.getCellRange(y1, x1).getColumnWidth());
+                                    sheet.getCellRange(y1, x1).getStyle().setShrinkToFit(true);
+
                                 } else {
                                     final CellRange cellRange = sheet.getCellRange(y1, x1);
                                     cellRange.setText(myData);
@@ -2211,4 +2197,286 @@ public class ExcelTabController extends BladeController {
         return null;
     }
 
+    /**
+     * 获取首件填报记录
+     */
+    @GetMapping("/get-first-business-data")
+    @ApiOperationSupport(order = 28)
+    @ApiOperation(value = "获取首件填报记录")
+    @ApiImplicitParam(name = "firstId", value = "首件列表ID")
+    public R<List<Map<String, Object>>> getFirstBusinessData(String firstId){
+        if(StringUtils.isNotEmpty(firstId)){
+            List<Map<String, Object>> result = new ArrayList<>();
+
+            JSONObject json = this.informationQueryClient.queryFirstBusinessDataByFirstId(firstId);
+            if(json != null){
+                //获取数据所在表格
+                WbsTreeContract tableNode = this.wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getPKeyId, json.getString("tableId")));
+                if(tableNode != null && StringUtils.isNotEmpty(tableNode.getInitTableName())){
+                    //获取填报数据
+                    List<Map<String, Object>> businessDataMapList = this.jdbcTemplate.queryForList("SELECT * FROM " + tableNode.getInitTableName() + " WHERE group_id = " + json.getString("id"));
+                    if(businessDataMapList.size() > 0){
+                        for(Map<String, Object> mysqlData : businessDataMapList){
+                            //数据结果
+                            Map<String, Object> reData = new HashMap<>();
+
+                            for (String key : mysqlData.keySet()) {
+                                String tabVal = mysqlData.get(key) + "";
+                                // 时间段处理
+                                if (StringUtils.isNotEmpty(tabVal) && !tabVal.equals("null")) {
+                                    if (tabVal.indexOf("T") >= 0 && tabVal.indexOf(".000Z]") >= 0) {
+                                        String tabData[] = tabVal.split("_\\^_");
+
+                                        if (reData.containsKey("pickerKey")) {
+                                            String pickerKey = reData.get("pickerKey") + "," + key + "__" + tabData[1];
+                                            reData.put("pickerKey", pickerKey);
+                                        } else {
+                                            reData.put("pickerKey", key + "__" + tabData[1]);
+                                        }
+
+                                        String sql = tabData[0];
+                                        sql = sql.replaceAll("\\[", "['");
+                                        sql = sql.replaceAll("]", "\']");
+                                        sql = sql.replaceAll("000Z,", "000Z\',");
+                                        sql = sql.replaceAll(", 20", ", \'20");
+                                        sql = sql.replaceAll("'", "");
+                                        reData.put(key + "__" + tabData[1], sql);
+                                    } else if (tabVal.indexOf("T") >= 0 && tabVal.indexOf(".000Z") >= 0) { //时间
+
+                                        String tabData[] = tabVal.split("_\\^_");
+                                        reData.put(key + "__" + tabData[1], tabData[0]);
+
+                                    } else if (tabVal.indexOf("☆") >= 0) {
+                                        String mysql[] = tabVal.split("☆");
+                                        for (String data : mysql) {
+                                            String tabData[] = data.split("_\\^_");
+                                            reData.put(key + "__" + tabData[1], tabData[0]);
+                                        }
+                                    } else if (tabVal.indexOf("_^_") >= 0) {
+                                        String tabData[] = tabVal.split("_\\^_");
+                                        reData.put(key + "__" + tabData[1], tabData[0]);
+                                    } else {
+                                        reData.put(key, tabVal);
+                                    }
+                                }
+                            }
+
+                            reData.remove("p_key_id");
+                            reData.remove("classify");
+                            reData.remove("contractId");
+                            reData.remove("pkeyId");
+                            reData.remove("projectId");
+
+                            result.add(reData);
+                        }
+
+                        return R.data(result);
+                    }
+                }
+            }
+        }
+
+        return R.data(300, null, "未找到对应的业务数据");
+    }
+
+    /**
+     * 预览首件PDF
+     */
+    @GetMapping("/get-first-pdf-info")
+    @ApiOperationSupport(order = 28)
+    @ApiOperation(value = "获取首件填报记录")
+    @ApiImplicitParam(name = "firstId", value = "首件列表ID")
+    public R<String> getFirstPdfInfo(String firstId){
+        if(StringUtils.isNotEmpty(firstId)){
+            //PDF路径集合
+            List<String> pdfUrls = new ArrayList<>();
+
+            //获取配置的路径
+            String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
+            //获取数据
+            JSONObject firstJson = this.informationQueryClient.queryFirstBusinessDataByFirstId(firstId);
+            if(firstJson != null){
+                if(StringUtils.isNotEmpty(firstJson.getString("eVisaPdfUrl")) || StringUtils.isNotEmpty(firstJson.getString("pdfUrl"))){
+                    pdfUrls.add(StringUtils.isNotEmpty(firstJson.getString("eVisaPdfUrl")) ? firstJson.getString("eVisaPdfUrl") : firstJson.getString("pdfUrl"));
+                } else {
+                    //没有生成拼接的记录,生成
+                    //获取html
+                    WbsTreeContract tableNode = this.wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getPKeyId, firstJson.getString("tableId")));
+
+                    if(tableNode == null){
+                        return R.fail("该数据下无此节点!");
+                    }
+
+                    if(StringUtils.isEmpty(tableNode.getHtmlUrl())){
+                        return R.fail("请关联清表!");
+                    }
+
+                    // 获取清表信息
+                    ExcelTab excelTab = excelTabService.getById(tableNode.getExcelId());
+                    if (excelTab == null) {
+                        return R.fail("失败");
+                    }
+
+                    List<Map<String, Object>> businessDataMapList = this.getFirstBusinessData(firstId).getData();
+
+                    try{
+                        //处理数据
+                        for(Map<String, Object> dataMap : businessDataMapList){
+                            // 获取excel流 和 html流
+                            Workbook wb = new Workbook();
+                            wb.loadFromMHtml(CommonUtil.getOSSInputStream(excelTab.getFileUrl()));
+                            //获取工作表
+                            Worksheet sheet = wb.getWorksheets().get(0);
+
+                            // 数据不为空 &&
+                            if (StringUtils.isNotEmpty(tableNode.getHtmlUrl())) {
+                                File htmlFile = ResourceUtil.getFile(tableNode.getHtmlUrl());
+                                if (htmlFile.exists()) {
+                                    String htmlString = IoUtil.readToString(new FileInputStream(htmlFile));
+                                    Document doc = Jsoup.parse(htmlString);
+                                    Element table = doc.select("table").first();
+                                    Elements trs = table.select("tr");
+
+                                    if (ObjectUtil.isNotEmpty(dataMap)) {
+                                        for (String val : dataMap.keySet()) {
+                                            if (val.indexOf("__") >= 0) {
+                                                String DataVal[] = val.split("__");
+                                                String[] xy = DataVal[1].split("_");
+                                                Element data = trs.get(Integer.parseInt(xy[0])).select("td").get(Integer.parseInt(xy[1]));
+
+                                                if (data.html().indexOf("x1") >= 0 && data.html().indexOf("y1") >= 0) {
+                                                    int x1, y1;
+
+                                                    if (data.html().indexOf("el-tooltip") >= 0) {
+                                                        x1 = Integer.parseInt(data.children().get(0).children().get(0).attr("x1"));
+                                                        y1 = Integer.parseInt(data.children().get(0).children().get(0).attr("y1"));
+                                                    } else {
+                                                        x1 = Integer.parseInt(data.children().get(0).attr("x1"));
+                                                        y1 = Integer.parseInt(data.children().get(0).attr("y1"));
+                                                    }
+                                                    if (x1 == 0) {
+                                                        x1 = 1;
+                                                    }
+                                                    String myData = dataMap.get(val) + "";
+                                                    if (myData.indexOf("T") >= 0 && myData.indexOf("-") >= 0) {
+                                                        if (myData.indexOf(",") >= 0 && myData.indexOf("]") >= 0) {
+                                                            myData = myData.replace("[", "").replace("]", "");
+                                                            String[] dataVal = myData.split(",");
+                                                            String Start_dataStr[] = dataVal[0].split("T")[0].split("-");
+                                                            String StartDate = StringUtil.format("{}年{}月{}日", new Object[]{Start_dataStr[0], Start_dataStr[1], Integer.parseInt(Start_dataStr[2]) + 1});
+
+                                                            String end_dataStr[] = dataVal[1].split("T")[0].split("-");
+                                                            String endDate = StringUtil.format("{}年{}月{}日", new Object[]{end_dataStr[0], end_dataStr[1], Integer.parseInt(end_dataStr[2]) + 1});
+
+                                                            if (StartDate.equals(endDate)) {
+                                                                myData = StartDate;
+                                                            } else {
+                                                                myData = StartDate + "-" + endDate;
+                                                            }
+                                                        } else {
+                                                            String dataStr[] = myData.split("T")[0].split("-");
+                                                            myData = StringUtil.format("{}年{}月{}日", new Object[]{dataStr[0], dataStr[1], Integer.parseInt(dataStr[2]) + 1});
+                                                        }
+                                                    }
+
+                                                    if (myData.indexOf("https") >= 0 && myData.indexOf("aliyuncs") >= 0) {
+                                                        Element element = trs.get(y1).select("td").get(x1);
+                                                        String styles[] = element.attr("style").split(";");
+                                                        int Height = 0;
+                                                        for (String sty : styles) {
+                                                            if (sty.indexOf("height:") >= 0) {
+                                                                Height = Integer.parseInt(sty.replace("height:", "").replace("px", ""));
+                                                            }
+                                                        }
+
+                                                        BufferedImage image = ImageIO.read(CommonUtil.getOSSInputStream(myData));
+                                                        ExcelPicture pic = sheet.getPictures().add(y1, x1, image);
+                                                        pic.setHeight(Height);
+                                                        sheet.getCellRange(y1, x1).getStyle().setShrinkToFit(true);
+
+                                                    } else {
+                                                        final CellRange cellRange = sheet.getCellRange(y1, x1);
+                                                        cellRange.setText(myData);
+                                                    }
+                                                }
+                                            }
+                                        }
+                                    }
+
+                                    // 组装电签设置
+                                    QueryWrapper<TextdictInfo> queryWrapper = new QueryWrapper<>();
+                                    queryWrapper.eq("type", 2);
+                                    queryWrapper.eq("tab_id", tableNode.getPKeyId());
+
+                                    final List<TextdictInfo> textdictInfos = textdictInfoService.getBaseMapper().selectList(queryWrapper);
+                                    if (textdictInfos != null && !textdictInfos.isEmpty()) {
+                                        textdictInfos.forEach(e -> {
+                                            String key = e.getColKey();
+                                            String keys[] = key.split("__");
+                                            String[] trtd = keys[1].split("_");
+                                            Element data = trs.get(Integer.parseInt(trtd[0])).select("td").get(Integer.parseInt(trtd[1]));
+                                            int x1 = Integer.parseInt(data.children().get(0).attr("x1"));
+                                            if (x1 == 0) {
+                                                x1 = 1;
+                                            }
+                                            int y1 = Integer.parseInt(data.children().get(0).attr("y1"));
+
+                                            final CellRange cellRange = sheet.getCellRange(y1, x1);
+
+                                            cellRange.setText(e.getId() + "");
+                                            cellRange.getCellStyle().getFont().setColor(Color.white);
+
+                                        });
+                                    }
+                                }
+                            }
+
+                            Long fileName = SnowFlakeUtil.getId();
+                            String onePdfPath = file_path + "/pdf//" + fileName + ".pdf";
+
+                            sheet.saveToPdf(onePdfPath);
+
+                            BladeFile bladeFile = this.newIOSSClient.uploadFile( fileName + ".pdf", onePdfPath);
+
+                            pdfUrls.add(bladeFile.getLink());
+
+                            wb.dispose();
+                        }
+                    }catch (Exception e){
+                        e.printStackTrace();
+                    }
+                }
+
+                if(pdfUrls.size() > 0){
+                    try{
+                        //关联的数据
+                        if(StringUtils.isNotEmpty(firstJson.getString("linkMergePdfUrl"))){
+                            pdfUrls.add(firstJson.getString("linkMergePdfUrl"));
+                        }
+                        //总结报告,暂时无
+
+                        //上传
+                        String mergePdfPath = file_path + "/pdf//" + firstId + ".pdf";
+                        File oldMergePdf = ResourceUtil.getFile(mergePdfPath);
+                        if (oldMergePdf.exists()) {
+                            oldMergePdf.delete();
+                        }
+                        //合并
+                        FileUtils.mergePdfPublicMethods(pdfUrls, mergePdfPath);
+                        //上传
+                        BladeFile mergeFile = this.newIOSSClient.uploadFile(firstId + '-' + new Date().getTime() + ".pdf", mergePdfPath);
+
+                        //返回
+                        return R.data(mergeFile.getLink());
+
+                    }catch (Exception e){
+                        e.printStackTrace();
+                    }
+                }
+            }
+        }
+
+        return R.data(300, null, "未找到数据");
+    }
+
 }

+ 5 - 5
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreeServiceImpl.java

@@ -443,7 +443,7 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
             }
         }
 
-        return this.saveBatch(allNodeData, 10000) && baseMapper.updateById(wbsTree1) > 0;
+        return this.saveBatch(allNodeData, 1000) && baseMapper.updateById(wbsTree1) > 0;
 
     }
 
@@ -1009,16 +1009,16 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
                 //新增
                 if (pawDTO.getReferenceType().equals("public")) {
                     //批量插入
-                    insertBatch(insertData1, 100);
+                    insertBatch(insertData1, 1000);
 
                     projectInfoMapper.updateTemplateIdById(pawDTO.getProjectId(), pawDTO.getWbsId(), "public");
 
                 } else if (pawDTO.getReferenceType().equals("private")) {
                     //批量插入
-                    insertBatch(insertData2, 100);
+                    insertBatch(insertData2, 1000);
 
                     //同步电签位置配置信息、编辑默认信息数据
-                    textDictInfoService.saveBatch(insertData3, 100);
+                    textDictInfoService.saveBatch(insertData3, 1000);
 
                     projectInfoMapper.updateTemplateIdById(pawDTO.getProjectId(), pawDTO.getPrimaryKeyId(), "private");
                 }
@@ -1135,7 +1135,7 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
         }
 
         //新增元素
-        boolean b2 = wbsFormElementService.saveBatch(elementList, 10000);
+        boolean b2 = wbsFormElementService.saveBatch(elementList, 1000);
 
         List<WbsFormElement> list = wbsFormElementService.selectElementListByFid(String.valueOf(formElementDTO.getId()));
 

+ 6 - 6
blade-service/blade-manager/src/main/java/org/springblade/manager/utils/WbsElementUtil.java

@@ -195,20 +195,20 @@ public class WbsElementUtil {
         }
     }
 
-    public static String getTypeName(String type) {
+    public static String getTypeTips(String type) {
         if (type != null) {
             switch (type) {
                 case "bigint":
-                    return "整数数值";
+                    return "请输入0-9整数数值";
                 case "decimal":
-                    return "小数";
+                    return "请输入小数";
                 case "datetime":
-                    return "日期";
+                    return "请输入日期";
                 default:
-                    return "字符串";
+                    return "请输入字符串";
             }
         } else {
-            return "字符串";
+            return "请输入字符串";
         }
     }