Explorar o código

Merge remote-tracking branch 'origin/master'

liuyc hai 1 ano
pai
achega
a102108618

+ 5 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/entity/TextdictInfo.java

@@ -92,6 +92,11 @@ public class TextdictInfo implements Serializable {
      */
     private double pyzby;
 
+    /**
+     * excelId
+     */
+    private String excelId;
+
     /**
      * 是否删除
      */

+ 49 - 60
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/TextdictInfoController.java

@@ -528,112 +528,101 @@ public class TextdictInfoController extends BladeController {
             throw new ServiceException("请勿重复提交,请3秒后再尝试");
         }
         JSONArray jsonArray = dataInfo.getJSONArray("dataInfo");
-        Long tableId = dataInfo.getLong("tabId"); //节点pkid
 
+        // -------- 移除所有html 的dqid -----
+        Long tableId = dataInfo.getLong("tabId"); //节点pkid
         //当前清表信息
         WbsTreePrivate wbsTreePrivate = wbsTreePrivateMapper.getByPKeyId(tableId);
-
-        //获取当前项目下引用相同模板的元素表信息
-        List<WbsTreePrivate> wbsTreePrivatesEqual = wbsTreePrivateMapper.selectList(Wrappers.<WbsTreePrivate>lambdaQuery()
-                .eq(WbsTreePrivate::getProjectId, wbsTreePrivate.getProjectId())
-                .eq(WbsTreePrivate::getExcelId, wbsTreePrivate.getExcelId()));
-//                .eq(WbsTreePrivate::getStatus, 1));
-        List<Long> pKeyIds = wbsTreePrivatesEqual.stream().map(WbsTreePrivate::getPKeyId).collect(Collectors.toList());
-        String ids = StringUtils.join(pKeyIds, ",");
-        if (StringUtils.isNotEmpty(ids)) {
-            //删除引用当前模板所有电签信息
-            String delSql = "delete from m_textdict_info where tab_id in(" + ids + ") and type in(2,6)";
-            jdbcTemplate.execute(delSql);
-        }
-
-        // 读取html页面信息
-
         InputStream inputStreamByUrl = FileUtils.getInputStreamByUrl(wbsTreePrivate.getHtmlUrl());
         String htmlString = IoUtil.readToString(inputStreamByUrl);
-
         // 样式集合
         Document doc = Jsoup.parse(htmlString);
-
         //解析
         Element table = doc.select("table").first();
         Elements trs = table.select("tr");
-
+        //解析
         Elements onlyInfo = doc.select("[:readonly]");
         if (onlyInfo != null && onlyInfo.size() >= 1) {
             for (Element element : onlyInfo) {
                 element.removeAttr(":readonly");
             }
         }
-
         Elements tryInfo = doc.select("td[dqid]");
         if (tryInfo != null && tryInfo.size() >= 1) {
             for (Element element : tryInfo) {
                 element.removeAttr("dqid");
             }
         }
-
         if (jsonArray == null || jsonArray.size() == 0) {
             return R.success("操作成功");
         }
 
-        //当前项目下引用相同清表,同步保存电签信息
-        for (Long pKeyId : pKeyIds) {
-            for (int i = 0; i < jsonArray.size(); i++) {
-                JSONObject jsonObject = jsonArray.getJSONObject(i);
-                TextdictInfo textdictInfo = new TextdictInfo();
-                String[] trtd = jsonObject.getString("colKey").split("__")[1].split("_");
-                Element element = trs.get(Integer.parseInt(trtd[0])).select("td").get(Integer.parseInt(trtd[1]));
+        //删除历史数据
+        String delSql = "delete from m_textdict_info where tab_id in(SELECT p_key_id from m_wbs_tree_contract where p_key_id!='"+tableId+"' and  project_id="+wbsTreePrivate.getProjectId()+" and excel_id="+wbsTreePrivate.getExcelId()+") and type in(2,6) and excel_id is null";
+        jdbcTemplate.execute(delSql);
 
-                String id = element.children().get(0).attr("keyname");
+        // ------- 查询数据库是否存在 该该电签信息 ---------
+        for (int i = 0; i < jsonArray.size(); i++) {
+            JSONObject jsonObject = jsonArray.getJSONObject(i);
+            TextdictInfo textdictInfo = new TextdictInfo();
 
-                textdictInfo.setId(SnowFlakeUtil.getId());
-                textdictInfo.setName("电签位置配置");
-                textdictInfo.setType(jsonObject.getInteger("type"));
-                textdictInfo.setColKey(id);
-                textdictInfo.setSigRoleId(jsonObject.getString("sigRoleId"));
-
-                textdictInfo.setTabId(pKeyId.toString());
+            String[] trtd = jsonObject.getString("colKey").split("__")[1].split("_");
+            Element element = trs.get(Integer.parseInt(trtd[0])).select("td").get(Integer.parseInt(trtd[1]));
 
-                textdictInfo.setColName(jsonObject.getString("colName"));
-                textdictInfo.setSigRoleName(jsonObject.getString("sigRoleName"));
-                textdictInfo.setPyzbx(jsonObject.getDouble("pyzbx"));
-                textdictInfo.setPyzby(jsonObject.getDouble("pyzby"));
+            String id = element.children().get(0).attr("keyname");
+            if(jsonObject.containsKey("id")){
+                textdictInfo.setId(jsonObject.getLong("id"));
+            }else{
+                textdictInfo.setId(SnowFlakeUtil.getId());
                 textdictInfo.setIsDeleted(0);
-                textdictInfoService.saveOrUpdate(textdictInfo);
-
-                element.removeAttr("dqId");
-                element.attr("dqId", textdictInfo.getId() + "");
-                if (jsonObject.getInteger("type") == 2) { //个人签字 不能用户输入
-                    if (element.html().indexOf("el-tooltip") >= 0) {
-                        element.children().get(0).children().get(0).attr(":readonly", "true");
-                    } else {
-                        element.children().get(0).attr(":readonly", "true");
-                    }
+            }
+            textdictInfo.setName("电签位置配置");
+            textdictInfo.setType(jsonObject.getInteger("type"));
+            textdictInfo.setColKey(id);
+            textdictInfo.setSigRoleId(jsonObject.getString("sigRoleId"));
+
+            textdictInfo.setTabId(tableId.toString());
+            textdictInfo.setExcelId(wbsTreePrivate.getExcelId()+"");
+
+            textdictInfo.setColName(jsonObject.getString("colName"));
+            textdictInfo.setSigRoleName(jsonObject.getString("sigRoleName"));
+            textdictInfo.setPyzbx(jsonObject.getDouble("pyzbx"));
+            textdictInfo.setPyzby(jsonObject.getDouble("pyzby"));
+            textdictInfoService.saveOrUpdate(textdictInfo);
+            element.removeAttr("dqId");
+            element.attr("dqId", textdictInfo.getId() + "");
+            if (jsonObject.getInteger("type") == 2) { //个人签字 不能用户输入
+                if (element.html().indexOf("el-tooltip") >= 0) {
+                    element.children().get(0).children().get(0).attr(":readonly", "true");
+                } else {
+                    element.children().get(0).attr(":readonly", "true");
                 }
             }
         }
 
-        //写入excel
-        FileUtils.getSysLocalFileUrl();
         File writeFile = new File(wbsTreePrivate.getHtmlUrl());
         FileUtil.writeToFile(writeFile, doc.html(), Boolean.parseBoolean("UTF-8"));
 
         String str1 = wbsTreePrivate.getHtmlUrl().replace("Desktop//privateUrl", "Desktop/privateUrl");
         String replace = str1.replace("\\", "\\\\");
-        if (StringUtils.isNotEmpty(ids)) {
-            //修改所有节点的htmlUrl
-            String updateSqlP = "update m_wbs_tree_private set html_url = '" + replace + "' where p_key_id in (" + ids + ")";
-            jdbcTemplate.execute(updateSqlP);
-        }
+
+        //修改同几点的数据
+        String updateSqlP = "update m_wbs_tree_private set html_url = '" + replace + "' where p_key_id in (SELECT p_key_id from m_wbs_tree_contract where project_id="+wbsTreePrivate.getProjectId()+" and excel_id="+wbsTreePrivate.getExcelId()+")";
+        jdbcTemplate.execute(updateSqlP);
+
+        List<WbsTreePrivate> wbsTreePrivatesEqual = wbsTreePrivateMapper.selectList(Wrappers.<WbsTreePrivate>lambdaQuery()
+                .eq(WbsTreePrivate::getProjectId, wbsTreePrivate.getProjectId())
+                .eq(WbsTreePrivate::getExcelId, wbsTreePrivate.getExcelId()));
 
         //修改对应合同段的htmlUrl,当前项目下对应合同段的节点
         List<Long> cIdsList = wbsTreePrivatesEqual.stream().map(WbsTreePrivate::getId).distinct().collect(Collectors.toList());
+
         List<Long> cPkeyIds = wbsTreeContractService.getBaseMapper().selectList(Wrappers.<WbsTreeContract>lambdaQuery()
                 .eq(WbsTreeContract::getProjectId, wbsTreePrivate.getProjectId())
                 .eq(WbsTreeContract::getExcelId, wbsTreePrivate.getExcelId())
-//                .eq(WbsTreeContract::getStatus, 1)
                 .in(WbsTreeContract::getId, cIdsList)).stream().map(WbsTreeContract::getPKeyId).collect(Collectors.toList());
         String cPkeyIdsStr = StringUtils.join(cPkeyIds, ",");
+
         if (StringUtils.isNotEmpty(cPkeyIdsStr)) {
             String updateSqlC = "update m_wbs_tree_contract set html_url = '" + replace + "' where p_key_id in (" + cPkeyIdsStr + ")";
             jdbcTemplate.execute(updateSqlC);
@@ -646,7 +635,7 @@ public class TextdictInfoController extends BladeController {
     }
 
     /**
-     * 保存电签
+     * 保存默认值
      */
     @PostMapping("/save_defaulVal")
     @ApiOperationSupport(order = 7)

+ 5 - 3
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/TextdictInfoMapper.xml

@@ -16,15 +16,17 @@
         <result column="sig_role_name" property="sigRoleName"/>
         <result column="pyzbx" property="pyzbx"/>
         <result column="pyzby" property="pyzby"/>
+        <result column="pyzby" property="pyzby"/>
+        <result column="excel_id" property="excelId"/>
     </resultMap>
 
     <select id="selectTextdictInfoPage" resultMap="textdictInfoResultMap">
-        select * from m_textdict_info where is_deleted = 0 and tab_id=#{param2.tabId}
+        select distinct * from m_textdict_info where is_deleted = 0
         <if test="param2.type== 2 ">
-            and type in('2','6')
+            and type in('2','6')    and (excel_id=#{param2.excelId} or tab_id=#{param2.tabId})
         </if>
         <if test="param2.type!= 2 ">
-            and type =#{param2.type}
+            and type =#{param2.type} and tab_id=#{param2.tabId}
         </if>
     </select>
 

+ 3 - 3
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ExcelTabServiceImpl.java

@@ -1646,19 +1646,19 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                                 redFont.setFontName(oldfontAt.getFontName());//设置字体
                                 String CellValue = cell.getStringCellValue().trim();
 
-                                if(CellValue!=null && StringUtils.isNotEmpty(CellValue)){
+                               /* if(CellValue!=null && StringUtils.isNotEmpty(CellValue)){
                                     RichTextString ts= new HSSFRichTextString(CellValue + "--"+dqid);
                                    // ts.applyFont(0,CellValue.length(),oldfontAt);
                                  //   ts.applyFont(10,ts.length(),redFont);
                                     cell.setCellValue(ts);
-                                }else{
+                                }else{*/
                                     CellStyle newStyle = workbook.createCellStyle(); //创建单元格样式
                                     newStyle.cloneStyleFrom(cell.getCellStyle());
                                     newStyle.setFont(redFont);
                                     newStyle.setShrinkToFit(true);
                                     cell.setCellStyle(newStyle);
                                     cell.setCellValue(dqid);
-                                }
+                              //  }
                             }
                         }
                     }