浏览代码

Merge remote-tracking branch 'origin/test-merge' into test-merge

LHB 1 月之前
父节点
当前提交
350cdcdf69

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

@@ -85,12 +85,12 @@ public class TextdictInfo implements Serializable {
     /**
      * 偏移坐标X
      */
-    private double pyzbx;
+    private Double pyzbx;
 
     /**
      * 偏移坐标Y
      */
-    private double pyzby;
+    private Double pyzby;
 
     /**
      * excelId
@@ -120,5 +120,5 @@ public class TextdictInfo implements Serializable {
     /**
      * 是否需要时间 1需要 0不需要
      */
-    private int timeState;
+    private Integer timeState;
 }

+ 3 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/ExceTabTreVO.java

@@ -51,6 +51,9 @@ public class ExceTabTreVO extends ExcelTab implements INode<ExceTabTreVO> {
     @JsonSerialize(using = ToStringSerializer.class)
     private Long parentId;
 
+
+    private Integer tableOwner;
+
     /**
      * 子孙节点
      */

+ 24 - 4
blade-service/blade-e-visa/src/main/java/org/springblade/evisa/service/impl/EVDataServiceImpl.java

@@ -557,9 +557,19 @@ public class EVDataServiceImpl implements EVDataService {
             for (int i = 0; i < strArray.length; i++) {
                 List<Map<String, Object>> maps2 = null;
                 if (dqIds.length() > 0) {
-                    String sqlinfo = " SELECT * from ( SELECT a.id as keyWord,a.project_id,a.pyzbx ,a.pyzby,(SELECT acc_code from blade_user where id='" + strArray[i] + "' and is_deleted=0  ) as sealId from m_textdict_info a where  a.type =2 and a.id in (" + dqIds + ")  and sig_role_id in (SELECT DISTINCT c.role_id from m_project_assignment_user c  where c.contract_id=" + task.getContractId() + " and user_id=" + strArray[i] + " and c.is_deleted=0 ) ) x where x.sealId is not null ";
+                    String sqlinfo;
+                    long seconds = DateUtil.between(new Date(), DateUtil.parse("2025-08-14 11:00:00", "yyyy-MM-dd HH:mm:ss")).getSeconds();
+                    if (seconds < 0) {
+                        sqlinfo = " SELECT * from ( SELECT a.id as keyWord,a.project_id,a.pyzbx ,a.pyzby,(SELECT acc_code from blade_user where id='" + strArray[i] + "' and is_deleted=0  ) as sealId from m_textdict_info a where a.project_id = " + task.getProjectId() + " and  a.type =2 and a.id in (" + dqIds + ")  and sig_role_id in (SELECT DISTINCT c.role_id from m_project_assignment_user c  where c.contract_id=" + task.getContractId() + " and user_id=" + strArray[i] + " and c.is_deleted=0 ) ) x where x.sealId is not null ";
+                    } else {
+                        sqlinfo = " SELECT * from ( SELECT a.id as keyWord,a.project_id,a.pyzbx ,a.pyzby,(SELECT acc_code from blade_user where id='" + strArray[i] + "' and is_deleted=0  ) as sealId from m_textdict_info a where a.type =2 and a.id in (" + dqIds + ")  and sig_role_id in (SELECT DISTINCT c.role_id from m_project_assignment_user c  where c.contract_id=" + task.getContractId() + " and user_id=" + strArray[i] + " and c.is_deleted=0 ) ) x where x.sealId is not null ";
+                    }
                     if (task.getSigType() == 2) {
-                        sqlinfo = "SELECT a.id as keyWord,a.pyzbx,a.pyzby,b.certificate_number as sealId from m_textdict_info a ,m_sign_pfx_file b where a.sig_role_id = b.pfx_type and b.project_contract_role like '%" + task.getContractId() + "%' and a.is_deleted=0 and b.is_deleted=0 and a.type=6 and a.id in(" + dqIds + ")";
+                        if (seconds < 0) {
+                            sqlinfo = "SELECT a.id as keyWord,a.pyzbx,a.pyzby,b.certificate_number as sealId from m_textdict_info a ,m_sign_pfx_file b where a.project_id = " + task.getProjectId() + " and a.sig_role_id = b.pfx_type and b.project_contract_role like '%" + task.getContractId() + "%' and a.is_deleted=0 and b.is_deleted=0 and a.type=6 and a.id in(" + dqIds + ")";
+                        } else {
+                            sqlinfo = "SELECT a.id as keyWord,a.pyzbx,a.pyzby,b.certificate_number as sealId from m_textdict_info a ,m_sign_pfx_file b where a.sig_role_id = b.pfx_type and b.project_contract_role like '%" + task.getContractId() + "%' and a.is_deleted=0 and b.is_deleted=0 and a.type=6 and a.id in(" + dqIds + ")";
+                        }
                         System.out.println("东方中讯--签章--" + sqlinfo);
                     } else {
                         System.out.println("东方中讯--签字--" + sqlinfo);
@@ -640,9 +650,19 @@ public class EVDataServiceImpl implements EVDataService {
                 String userId =strArray[i];
                 List<Map<String, Object>> maps2 = null;
                 if (dqIds.length() > 0) {
-                    String sqlinfo = "SELECT * from ( SELECT DISTINCT a.id,a.pyzbx ,a.pyzby,a.project_id,(SELECT signature_file_url from m_sign_pfx_file where is_register=1 and certificate_user_id='" + userId + "' and is_deleted=0  ) as signature_file_url, (SELECT wide from m_sign_pfx_file where is_register=1 and certificate_user_id='" + userId + "' and is_deleted=0  ) as wide ,(SELECT high from m_sign_pfx_file where is_register=1 and certificate_user_id='" + userId + "' and is_deleted=0  ) as high from m_textdict_info a where  a.type =2 and a.id in (" + dqIds + ") and sig_role_id in (SELECT DISTINCT c.role_id from m_project_assignment_user c  where c.contract_id=" + task.getContractId() + " and user_id=" + userId + " and c.is_deleted=0 ) ) x where x.signature_file_url is not null ";
+                    long seconds = DateUtil.between(new Date(), DateUtil.parse("2025-08-14 11:00:00", "yyyy-MM-dd HH:mm:ss")).getSeconds();
+                    String sqlinfo;
+                    if (seconds < 0) {
+                        sqlinfo = "SELECT * from ( SELECT DISTINCT a.id,a.pyzbx ,a.pyzby,a.project_id,(SELECT signature_file_url from m_sign_pfx_file where is_register=1 and certificate_user_id='" + userId + "' and is_deleted=0  ) as signature_file_url, (SELECT wide from m_sign_pfx_file where is_register=1 and certificate_user_id='" + userId + "' and is_deleted=0  ) as wide ,(SELECT high from m_sign_pfx_file where is_register=1 and certificate_user_id='" + userId + "' and is_deleted=0  ) as high from m_textdict_info a where a.project_id = " + task.getProjectId() + " and a.type =2 and a.id in (" + dqIds + ") and sig_role_id in (SELECT DISTINCT c.role_id from m_project_assignment_user c  where c.contract_id=" + task.getContractId() + " and user_id=" + userId + " and c.is_deleted=0 ) ) x where x.signature_file_url is not null ";
+                    } else {
+                        sqlinfo = "SELECT * from ( SELECT DISTINCT a.id,a.pyzbx ,a.pyzby,a.project_id,(SELECT signature_file_url from m_sign_pfx_file where is_register=1 and certificate_user_id='" + userId + "' and is_deleted=0  ) as signature_file_url, (SELECT wide from m_sign_pfx_file where is_register=1 and certificate_user_id='" + userId + "' and is_deleted=0  ) as wide ,(SELECT high from m_sign_pfx_file where is_register=1 and certificate_user_id='" + userId + "' and is_deleted=0  ) as high from m_textdict_info a where  a.type =2 and a.id in (" + dqIds + ") and sig_role_id in (SELECT DISTINCT c.role_id from m_project_assignment_user c  where c.contract_id=" + task.getContractId() + " and user_id=" + userId + " and c.is_deleted=0 ) ) x where x.signature_file_url is not null ";
+                    }
                     if (task.getSigType() == 2) {
-                        sqlinfo = "SELECT a.id,a.pyzbx,a.pyzby,b.signature_file_url,b.id as sfId,a.project_id,b.certificate_password,b.certificate_user_name,b.certificate_number ,b.wide,b.high from m_textdict_info a ,m_sign_pfx_file b where a.sig_role_id = b.pfx_type and b.project_contract_role like '%" + task.getContractId() + "%' and a.is_deleted=0 and b.is_deleted=0 and a.type=6 and a.id in(" + dqIds + ") ";
+                        if (seconds < 0 ) {
+                            sqlinfo = "SELECT a.id,a.pyzbx,a.pyzby,b.signature_file_url,b.id as sfId,a.project_id,b.certificate_password,b.certificate_user_name,b.certificate_number ,b.wide,b.high from m_textdict_info a ,m_sign_pfx_file b where a.project_id = " + task.getProjectId() + " and a.sig_role_id = b.pfx_type and b.project_contract_role like '%" + task.getContractId() + "%' and a.is_deleted=0 and b.is_deleted=0 and a.type=6 and a.id in(" + dqIds + ") ";
+                        } else {
+                            sqlinfo = "SELECT a.id,a.pyzbx,a.pyzby,b.signature_file_url,b.id as sfId,a.project_id,b.certificate_password,b.certificate_user_name,b.certificate_number ,b.wide,b.high from m_textdict_info a ,m_sign_pfx_file b where a.sig_role_id = b.pfx_type and b.project_contract_role like '%" + task.getContractId() + "%' and a.is_deleted=0 and b.is_deleted=0 and a.type=6 and a.id in(" + dqIds + ") ";
+                        }
                         System.out.println("安心签--签章--=" + sqlinfo);
                     } else {
                         System.out.println("安心签--签字--=" + sqlinfo);

+ 247 - 57
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/TextdictInfoController.java

@@ -247,8 +247,10 @@ public class TextdictInfoController extends BladeController {
             param.put("ids", ids);
             param.put("tabId", tabId);
             dqOperationLogService.save(new DqOperationLog(wbsTreePrivate, AuthUtil.getUser(), String.join( ",", delIds), 2,param.toJSONString(), JSON.toJSONString(query), ""));
+            textdictInfoService.update(Wrappers.<TextdictInfo>lambdaUpdate().in(TextdictInfo::getId, delIds).eq(TextdictInfo::getProjectId, wbsTreePrivate.getProjectId()).set(TextdictInfo::getIsDeleted, 1));
+        } else {
+            textdictInfoService.getBaseMapper().deleteBatchIds(delIds);
         }
-        textdictInfoService.getBaseMapper().deleteBatchIds(delIds);
 
         return R.success("删除成功");
     }
@@ -419,19 +421,186 @@ public class TextdictInfoController extends BladeController {
         return R.success("操作成功");
     }
 
+    /**
+     * 保存电签
+     */
+//    @PostMapping("/save_sigInfo")
+//    @ApiOperationSupport(order = 7)
+//    @ApiOperation(value = "保存电签", notes = "保存电签")
+//    @Transactional
+//    public R<String> saveSigInfo(@Valid @RequestBody JSONObject dataInfo) throws Exception {
+//        String redisValue = bladeRedis.get("save-eVis-lock:" + SecureUtil.getUserId());
+//        if (StringUtils.isNotEmpty(redisValue) && redisValue.equals("1")) {
+//            throw new ServiceException("请勿重复提交,请3秒后再尝试");
+//        }
+//        JSONArray jsonArray = dataInfo.getJSONArray("dataInfo");
+//
+//        // -------- 移除所有html 的dqid -----
+//        Long tableId = dataInfo.getLong("tabId"); //节点pkid
+//        //当前清表信息
+//        WbsTreePrivate wbsTreePrivate = wbsTreePrivateMapper.getByPKeyId(tableId);
+//        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("操作成功");
+//        }
+//
+//        List<WbsTreePrivate> wbsTreePrivatesEqual = wbsTreePrivateMapper.selectList(Wrappers.<WbsTreePrivate>lambdaQuery()
+//                .eq(WbsTreePrivate::getProjectId, wbsTreePrivate.getProjectId())
+//                .eq(WbsTreePrivate::getIsDeleted, 0)
+//                .eq(WbsTreePrivate::getExcelId, wbsTreePrivate.getExcelId()));
+//        List<Long> pKeyIds = wbsTreePrivatesEqual.stream().map(WbsTreePrivate::getPKeyId).collect(Collectors.toList());
+//        String ids = StringUtils.join(pKeyIds, ",");
+//
+//        //删除历史数据
+//        String querySql = "select * from m_textdict_info where (tab_id in(SELECT p_key_id from m_wbs_tree_private where project_id='"+wbsTreePrivate.getProjectId()+"' and excel_id='"+wbsTreePrivate.getExcelId()+"' and type=2 and is_deleted=0) or (excel_id="+wbsTreePrivate.getExcelId()+" AND project_id='"+wbsTreePrivate.getProjectId()+"')) and project_id="+wbsTreePrivate.getProjectId()+" and type in(2,6) ";
+//        List<TextdictInfo> oldTextdictInfos = jdbcTemplate.query(querySql, new BeanPropertyRowMapper<>(TextdictInfo.class));
+//        String delSql = "delete from m_textdict_info where (tab_id in(SELECT p_key_id from m_wbs_tree_private where project_id='"+wbsTreePrivate.getProjectId()+"' and excel_id='"+wbsTreePrivate.getExcelId()+"' and type=2 and is_deleted=0) or (excel_id="+wbsTreePrivate.getExcelId()+" AND project_id='"+wbsTreePrivate.getProjectId()+"')) and project_id="+wbsTreePrivate.getProjectId()+" and type in(2,6) ";
+//        jdbcTemplate.execute(delSql);
+//
+//        // 由于要实现电签 一对多(1个key 对应多个电签Id)
+//        Map<String,String> keyMap = new HashMap<>();
+//
+//        // ------- 查询数据库是否存在 该该电签信息 ---------
+//        StringBuilder dqIds = new StringBuilder();
+//        List<TextdictInfo> newTextDictInfos = new ArrayList<>();
+//        for (int i = 0; i < jsonArray.size(); i++) {
+//            JSONObject jsonObject = jsonArray.getJSONObject(i);
+//            TextdictInfo textdictInfo = new TextdictInfo();
+//            String keky = jsonObject.getString("colKey");
+//
+//            String[] trtd = keky.split("__")[1].split("_");
+//            Element element = trs.get(Integer.parseInt(trtd[0])).select("td").get(Integer.parseInt(trtd[1]));
+//
+//            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);
+//            }
+//            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"));
+//            Integer timeState = jsonObject.getInteger("timeState");
+//            textdictInfo.setTimeState(timeState);
+//            if(timeState!=null && timeState==1){
+//                textdictInfo.setTimeColKey(jsonObject.getString("timeColKey"));
+//                textdictInfo.setTimeName(jsonObject.getString("timeName"));
+//            }else{
+//                textdictInfo.setTimeColKey("");
+//                textdictInfo.setTimeName("");
+//            }
+//
+//            textdictInfo.setProjectId(wbsTreePrivate.getProjectId());
+//
+//            //由于使用联合主键
+//            TextdictInfo one = textdictInfoService.selectTextdictInfoOne(textdictInfo.getId()+"",textdictInfo.getSigRoleId(),textdictInfo.getProjectId());
+//            if(ObjectUtil.isNotEmpty(one)){
+//                textdictInfoService.saveOrUpdate(textdictInfo);
+//            }else{
+//                textdictInfoService.save(textdictInfo);
+//            }
+//            newTextDictInfos.add(textdictInfo);
+//            dqIds.append(textdictInfo.getId()).append( ",");
+//            String dqId = "";
+//            if(keyMap.containsKey(keky)){
+//                dqId = keyMap.get(keky)+"||"+textdictInfo.getId();
+//            }else{
+//                dqId=textdictInfo.getId()+"";
+//            }
+//            keyMap.put(keky,dqId);
+//            element.removeAttr("dqId");
+//            element.attr("dqId", keyMap.get(keky));
+//            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");
+//                }
+//            }
+//        }
+//        File writeFile = new File(wbsTreePrivate.getHtmlUrl());
+////        File writeFile = new File("D:\\file\\downfile\\1792757075013533696.html");
+//        FileUtil.writeToFile(writeFile, doc.html(), Boolean.parseBoolean("UTF-8"));
+//
+//        String str1 = wbsTreePrivate.getHtmlUrl().replace("Desktop//privateUrl", "Desktop/privateUrl");
+//        String replace = str1.replace("\\", "\\\\");
+//
+//        //修改同几点的数据
+//        if(StringUtils.isNotBlank(ids)){
+//            String updateSqlP = "update m_wbs_tree_private set html_url = '" + replace + "' where p_key_id in ("+ids+") and project_id="+wbsTreePrivate.getProjectId()+"";
+//            jdbcTemplate.execute(updateSqlP);
+//        }
+//
+//        //修改对应合同段的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())
+//                .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 + ") and project_id="+wbsTreePrivate.getProjectId()+"";
+//            jdbcTemplate.execute(updateSqlC);
+//        }
+//        BladeUser user = AuthUtil.getUser();
+//        DqOperationLog log = new DqOperationLog(wbsTreePrivate, user, "", 1, dataInfo.toJSONString(), JSON.toJSONString(oldTextdictInfos), JSON.toJSONString(newTextDictInfos));
+//        if (dqIds.length() > 1) {
+//            log.setBusinessId(dqIds.deleteCharAt(dqIds.length() - 1).toString());
+//        }
+//        dqOperationLogService.save(log);
+//        bladeRedis.set("save-eVis-lock:" + SecureUtil.getUserId(), "1");
+//        bladeRedis.expire("save-eVis-lock:" + SecureUtil.getUserId(), 3);
+//
+//        return R.success("操作成功");
+//    }
+
     /**
      * 保存电签
      */
     @PostMapping("/save_sigInfo")
     @ApiOperationSupport(order = 7)
-    @ApiOperation(value = "保存电签", notes = "保存电签")
+    @ApiOperation(value = "保存电签(version 3.0)", notes = "保存电签(version 3.0)")
     @Transactional
-    public R<String> saveSigInfo(@Valid @RequestBody JSONObject dataInfo) throws Exception {
+    public R<String> saveSigInfoV3(@Valid @RequestBody JSONObject dataInfo) throws Exception {
         String redisValue = bladeRedis.get("save-eVis-lock:" + SecureUtil.getUserId());
         if (StringUtils.isNotEmpty(redisValue) && redisValue.equals("1")) {
             throw new ServiceException("请勿重复提交,请3秒后再尝试");
         }
         JSONArray jsonArray = dataInfo.getJSONArray("dataInfo");
+        if (jsonArray == null || jsonArray.isEmpty()) {
+            return R.success("操作成功");
+        }
 
         // -------- 移除所有html 的dqid -----
         Long tableId = dataInfo.getLong("tabId"); //节点pkid
@@ -442,101 +611,98 @@ public class TextdictInfoController extends BladeController {
         // 样式集合
         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) {
+        if (onlyInfo != null && !onlyInfo.isEmpty()) {
             for (Element element : onlyInfo) {
                 element.removeAttr(":readonly");
             }
         }
         Elements tryInfo = doc.select("td[dqid]");
-        if (tryInfo != null && tryInfo.size() >= 1) {
+        if (tryInfo != null && !tryInfo.isEmpty()) {
             for (Element element : tryInfo) {
                 element.removeAttr("dqid");
             }
         }
-        if (jsonArray == null || jsonArray.size() == 0) {
-            return R.success("操作成功");
-        }
-
-        List<WbsTreePrivate> wbsTreePrivatesEqual = wbsTreePrivateMapper.selectList(Wrappers.<WbsTreePrivate>lambdaQuery()
-                .eq(WbsTreePrivate::getProjectId, wbsTreePrivate.getProjectId())
-                .eq(WbsTreePrivate::getIsDeleted, 0)
-                .eq(WbsTreePrivate::getExcelId, wbsTreePrivate.getExcelId()));
-        List<Long> pKeyIds = wbsTreePrivatesEqual.stream().map(WbsTreePrivate::getPKeyId).collect(Collectors.toList());
-        String ids = StringUtils.join(pKeyIds, ",");
-
-        //删除历史数据
-        String querySql = "select * from m_textdict_info where (tab_id in(SELECT p_key_id from m_wbs_tree_private where project_id='"+wbsTreePrivate.getProjectId()+"' and excel_id='"+wbsTreePrivate.getExcelId()+"' and type=2 and is_deleted=0) or (excel_id="+wbsTreePrivate.getExcelId()+" AND project_id='"+wbsTreePrivate.getProjectId()+"')) and project_id="+wbsTreePrivate.getProjectId()+" and type in(2,6) ";
-        List<TextdictInfo> oldTextdictInfos = jdbcTemplate.query(querySql, new BeanPropertyRowMapper<>(TextdictInfo.class));
-        String delSql = "delete from m_textdict_info where (tab_id in(SELECT p_key_id from m_wbs_tree_private where project_id='"+wbsTreePrivate.getProjectId()+"' and excel_id='"+wbsTreePrivate.getExcelId()+"' and type=2 and is_deleted=0) or (excel_id="+wbsTreePrivate.getExcelId()+" AND project_id='"+wbsTreePrivate.getProjectId()+"')) and project_id="+wbsTreePrivate.getProjectId()+" and type in(2,6) ";
-        jdbcTemplate.execute(delSql);
 
+        // 查询历史数据
+        String querySql = String.format("SELECT * from m_textdict_info WHERE project_id = %d and excel_id = %d and type in (2, 6) and (SELECT 1 from m_wbs_tree_private WHERE p_key_id = tab_id and html_url = '%s' ) = 1"
+                    , Long.parseLong(wbsTreePrivate.getProjectId()), wbsTreePrivate.getExcelId(), wbsTreePrivate.getHtmlUrl());
+        List<TextdictInfo> oldTextDictInfos = jdbcTemplate.query(querySql, new BeanPropertyRowMapper<>(TextdictInfo.class));
+        Map<String, TextdictInfo> oldTextDictInfoMap;
+        if (!oldTextDictInfos.isEmpty()) {
+            oldTextDictInfoMap = oldTextDictInfos.stream().collect(Collectors.toMap(item -> item.getProjectId() + item.getExcelId()
+                    + (item.getColKey() != null && item.getColKey().contains("__") ? item.getColKey().split("__")[0] : item.getColKey())
+                    + item.getSigRoleId(), textdictInfo -> textdictInfo));
+        } else {
+            oldTextDictInfoMap = new HashMap<>();
+        }
         // 由于要实现电签 一对多(1个key 对应多个电签Id)
         Map<String,String> keyMap = new HashMap<>();
+        //解析
+        Element table = doc.select("table").first();
+        Elements trs = table.select("tr");
 
         // ------- 查询数据库是否存在 该该电签信息 ---------
         StringBuilder dqIds = new StringBuilder();
         List<TextdictInfo> newTextDictInfos = new ArrayList<>();
+        List<TextdictInfo> updateList = new ArrayList<>();
+        List<TextdictInfo> addList = new ArrayList<>();
         for (int i = 0; i < jsonArray.size(); i++) {
             JSONObject jsonObject = jsonArray.getJSONObject(i);
-            TextdictInfo textdictInfo = new TextdictInfo();
-            String keky = jsonObject.getString("colKey");
-
-            String[] trtd = keky.split("__")[1].split("_");
-            Element element = trs.get(Integer.parseInt(trtd[0])).select("td").get(Integer.parseInt(trtd[1]));
+            String key = jsonObject.getString("colKey");
+            String sigRoleId = jsonObject.getString("sigRoleId");
 
-            String id = element.children().get(0).attr("keyname");
-            if (jsonObject.containsKey("id")) {
-                textdictInfo.setId(jsonObject.getLong("id"));
+            TextdictInfo textdictInfo = new TextdictInfo();
+            Long id = jsonObject.getLong("id");
+            if (id != null && id > 0) {
+                textdictInfo.setId(id);
             } else {
                 textdictInfo.setId(SnowFlakeUtil.getId());
                 textdictInfo.setIsDeleted(0);
             }
             textdictInfo.setName("电签位置配置");
             textdictInfo.setType(jsonObject.getInteger("type"));
-            textdictInfo.setColKey(id);
-            textdictInfo.setSigRoleId(jsonObject.getString("sigRoleId"));
-
+            textdictInfo.setSigRoleId(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"));
             Integer timeState = jsonObject.getInteger("timeState");
             textdictInfo.setTimeState(timeState);
-            if(timeState!=null && timeState==1){
+            if(timeState == 1){
                 textdictInfo.setTimeColKey(jsonObject.getString("timeColKey"));
                 textdictInfo.setTimeName(jsonObject.getString("timeName"));
             }else{
                 textdictInfo.setTimeColKey("");
                 textdictInfo.setTimeName("");
             }
-
             textdictInfo.setProjectId(wbsTreePrivate.getProjectId());
 
-            //由于使用联合主键
-            TextdictInfo one = textdictInfoService.selectTextdictInfoOne(textdictInfo.getId()+"",textdictInfo.getSigRoleId(),textdictInfo.getProjectId());
-            if(ObjectUtil.isNotEmpty(one)){
-                textdictInfoService.saveOrUpdate(textdictInfo);
-            }else{
-                textdictInfoService.save(textdictInfo);
+            String[] trtd = key.split("__")[1].split("_");
+            Element element = trs.get(Integer.parseInt(trtd[0])).select("td").get(Integer.parseInt(trtd[1]));
+            String colKey = element.children().get(0).attr("keyname");
+            textdictInfo.setColKey(colKey);
+
+            TextdictInfo info = oldTextDictInfoMap.get(wbsTreePrivate.getProjectId() + wbsTreePrivate.getExcelId() + (colKey != null && colKey.contains("__") ? colKey.split("__")[0] : colKey) + sigRoleId);
+            if (info != null) {
+                textdictInfo.setId(info.getId());
+                updateList.add(textdictInfo);
+            } else {
+                addList.add(textdictInfo);
             }
             newTextDictInfos.add(textdictInfo);
             dqIds.append(textdictInfo.getId()).append( ",");
             String dqId = "";
-            if(keyMap.containsKey(keky)){
-                dqId = keyMap.get(keky)+"||"+textdictInfo.getId();
+            if(keyMap.containsKey(key)){
+                dqId = keyMap.get(key)+"||"+textdictInfo.getId();
             }else{
                 dqId=textdictInfo.getId()+"";
             }
-            keyMap.put(keky,dqId);
+            keyMap.put(key,dqId);
             element.removeAttr("dqId");
-            element.attr("dqId", keyMap.get(keky));
+            element.attr("dqId", keyMap.get(key));
             if (jsonObject.getInteger("type") == 2) { //个人签字 不能用户输入
                 if (element.html().indexOf("el-tooltip") >= 0) {
                     element.children().get(0).children().get(0).attr(":readonly", "true");
@@ -546,25 +712,52 @@ public class TextdictInfoController extends BladeController {
             }
         }
         File writeFile = new File(wbsTreePrivate.getHtmlUrl());
-//        File writeFile = new File("D:\\file\\downfile\\1792757075013533696.html");
         FileUtil.writeToFile(writeFile, doc.html(), Boolean.parseBoolean("UTF-8"));
-
         String str1 = wbsTreePrivate.getHtmlUrl().replace("Desktop//privateUrl", "Desktop/privateUrl");
         String replace = str1.replace("\\", "\\\\");
+        Set<Long> set = oldTextDictInfos.stream().map(TextdictInfo::getId).collect(Collectors.toSet());
+        // 先逻辑删除然后修改
+        this.textdictInfoService.update(Wrappers.<TextdictInfo>lambdaUpdate().eq(TextdictInfo::getProjectId, wbsTreePrivate.getProjectId())
+                .eq(TextdictInfo::getExcelId, wbsTreePrivate.getExcelId()).in(TextdictInfo::getType, 2, 6).in(TextdictInfo::getId, set).set(TextdictInfo::getIsDeleted, 1));
+        if (!updateList.isEmpty()) {
+            for (TextdictInfo info : updateList) {
+                this.textdictInfoService.update(Wrappers.<TextdictInfo>lambdaUpdate().eq(TextdictInfo::getId, info.getId()).eq(TextdictInfo::getProjectId, info.getProjectId())
+                        .eq(TextdictInfo::getExcelId, info.getExcelId()).eq(TextdictInfo::getSigRoleId, info.getSigRoleId())
+                        .set(info.getName() != null ,TextdictInfo::getName, info.getName())
+                        .set(info.getType() != null ,TextdictInfo::getType, info.getType())
+                        .set(info.getColName() != null, TextdictInfo::getColName, info.getColName())
+                        .set(info.getSigRoleName() != null, TextdictInfo::getSigRoleName, info.getSigRoleName())
+                        .set(info.getPyzbx() != null, TextdictInfo::getPyzbx, info.getPyzbx())
+                        .set(info.getPyzby() != null, TextdictInfo::getPyzby, info.getPyzby())
+                        .set(info.getTimeColKey() != null, TextdictInfo::getTimeColKey, info.getTimeColKey())
+                        .set(info.getTimeName() != null, TextdictInfo::getTimeName, info.getTimeName())
+                        .set(info.getColKey() != null, TextdictInfo::getColKey, info.getColKey())
+                        .set(info.getTabId() != null,TextdictInfo::getTabId, info.getTabId())
+                        .set(info.getTimeState() != null ,TextdictInfo::getTimeState, info.getTimeState()).set(TextdictInfo::getIsDeleted, 0));
+            }
+        }
+        if (!addList.isEmpty()) {
+            this.textdictInfoService.saveBatch(addList);
+        }
 
         //修改同几点的数据
+        List<WbsTreePrivate> wbsTreePrivatesEqual = wbsTreePrivateMapper.selectList(Wrappers.<WbsTreePrivate>lambdaQuery()
+                .eq(WbsTreePrivate::getProjectId, wbsTreePrivate.getProjectId())
+                .eq(WbsTreePrivate::getIsDeleted, 0)
+                .eq(WbsTreePrivate::getExcelId, wbsTreePrivate.getExcelId()).eq(WbsTreePrivate::getHtmlUrl, wbsTreePrivate.getHtmlUrl()));
+        List<Long> pKeyIds = wbsTreePrivatesEqual.stream().map(WbsTreePrivate::getPKeyId).collect(Collectors.toList());
+        String ids = StringUtils.join(pKeyIds, ",");
         if(StringUtils.isNotBlank(ids)){
             String updateSqlP = "update m_wbs_tree_private set html_url = '" + replace + "' where p_key_id in ("+ids+") and project_id="+wbsTreePrivate.getProjectId()+"";
             jdbcTemplate.execute(updateSqlP);
         }
 
         //修改对应合同段的htmlUrl,当前项目下对应合同段的节点
-        List<Long> cIdsList = wbsTreePrivatesEqual.stream().map(WbsTreePrivate::getId).distinct().collect(Collectors.toList());
-
+        List<Long> cIdsList = wbsTreePrivatesEqual.stream().map(WbsTreePrivate::getPKeyId).distinct().collect(Collectors.toList());
         List<Long> cPkeyIds = wbsTreeContractService.getBaseMapper().selectList(Wrappers.<WbsTreeContract>lambdaQuery()
                 .eq(WbsTreeContract::getProjectId, wbsTreePrivate.getProjectId())
                 .eq(WbsTreeContract::getExcelId, wbsTreePrivate.getExcelId())
-                .in(WbsTreeContract::getId, cIdsList)).stream().map(WbsTreeContract::getPKeyId).collect(Collectors.toList());
+                .in(WbsTreeContract::getIsTypePrivatePid, cIdsList)).stream().map(WbsTreeContract::getPKeyId).collect(Collectors.toList());
         String cPkeyIdsStr = StringUtils.join(cPkeyIds, ",");
 
         if (StringUtils.isNotEmpty(cPkeyIdsStr)) {
@@ -572,18 +765,15 @@ public class TextdictInfoController extends BladeController {
             jdbcTemplate.execute(updateSqlC);
         }
         BladeUser user = AuthUtil.getUser();
-        DqOperationLog log = new DqOperationLog(wbsTreePrivate, user, "", 1, dataInfo.toJSONString(), JSON.toJSONString(oldTextdictInfos), JSON.toJSONString(newTextDictInfos));
+        DqOperationLog log = new DqOperationLog(wbsTreePrivate, user, "", 1, dataInfo.toJSONString(), JSON.toJSONString(oldTextDictInfos), JSON.toJSONString(newTextDictInfos));
         if (dqIds.length() > 1) {
             log.setBusinessId(dqIds.deleteCharAt(dqIds.length() - 1).toString());
         }
         dqOperationLogService.save(log);
         bladeRedis.set("save-eVis-lock:" + SecureUtil.getUserId(), "1");
         bladeRedis.expire("save-eVis-lock:" + SecureUtil.getUserId(), 3);
-
         return R.success("操作成功");
     }
-
-
     /**
      * 保存默认值
      */

+ 87 - 6
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/WbsParamController.java

@@ -1,6 +1,7 @@
 package org.springblade.manager.controller;
 
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -12,14 +13,13 @@ import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 import lombok.AllArgsConstructor;
 import org.springblade.common.utils.BaseUtils;
+import org.springblade.common.utils.SnowFlakeUtil;
 import org.springblade.core.mp.base.BaseService;
 import org.springblade.core.mp.support.Condition;
 import org.springblade.core.mp.support.Query;
+import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.tool.api.R;
-import org.springblade.core.tool.utils.BeanUtil;
-import org.springblade.core.tool.utils.CollectionUtil;
-import org.springblade.core.tool.utils.Func;
-import org.springblade.core.tool.utils.StringPool;
+import org.springblade.core.tool.utils.*;
 import org.springblade.manager.dto.FileNameRuleDto;
 import org.springblade.manager.dto.FormulaBean;
 import org.springblade.manager.dto.WbsParamBean;
@@ -603,7 +603,88 @@ public class WbsParamController {
         return R.success("操作成功");
     }
 
-
-
+    private static final String G10PCFW = "G10pcfw";
+    private static final String G8PCFW = "g8pcfw";
+    /**
+     * 获取偏差范围(高程偏差和平面偏差)
+     * @param
+     * @return
+     */
+    @GetMapping("/getDeviationRange")
+    public R<List<WbsParam>> getDeviationRange(@RequestParam Long pKeyId){
+        List<WbsParam> wps = this.service.list(Wrappers.<WbsParam>lambdaUpdate().eq(WbsParam::getNodeId,pKeyId).in(WbsParam::getK,G10PCFW, G8PCFW));
+        if (wps == null || wps.isEmpty()) {
+            // 获取父节点
+            wps = this.service.list(Wrappers.<WbsParam>lambdaQuery().in(WbsParam::getK, G10PCFW, G8PCFW).apply(" node_id = (select p_id from m_wbs_tree_contract where p_key_id = " + pKeyId + " )"));
+            if (wps == null || wps.isEmpty()) {
+                wps = this.service.list(Wrappers.<WbsParam>lambdaQuery().in(WbsParam::getK, G10PCFW, G8PCFW)
+                        .apply(" node_id = (SELECT is_type_private_pid from m_wbs_tree_contract WHERE p_key_id = (select p_id from m_wbs_tree_contract where p_key_id =  "+ pKeyId +" ))"));
+            }
+        }
+        return R.data(wps);
+    }
+    /**
+     * 设置偏差范围(高程偏差和平面偏差)
+     * @param
+     * @return
+     */
+    @PostMapping("/setDeviationRange")
+    public R<Boolean> setDeviationRange(@RequestBody JSONObject obj){
+        Long nodeId = obj.getLong("pKeyId");
+        if (nodeId == null || nodeId <= 0) {
+            return R.fail("参数错误");
+        }
+        String g10 = checkDeviationRange(obj.getString("g10pcfw"));
+        String g8 = checkDeviationRange(obj.getString(G8PCFW));
+        if (StringUtil.isBlank(g10) && StringUtil.isBlank(g8)) {
+            return R.fail("请输入偏差范围");
+        }
+        try {
+            saveOrUpdateDeviationRange(nodeId, G10PCFW, g10, "G10偏差范围");
+            saveOrUpdateDeviationRange(nodeId, G8PCFW, g8, "G8高程偏差");
+        } catch (Exception e) {
+            e.printStackTrace();
+            return R.fail("操作失败");
+        }
+        return R.data(true);
+    }
+    private void saveOrUpdateDeviationRange(Long nodeId, String k,String v, String name) {
+        if (v == null) {
+            return;
+        }
+        WbsParam g10Param = this.service.getOne(Wrappers.<WbsParam>lambdaUpdate().eq(WbsParam::getNodeId, nodeId).eq(WbsParam::getK,k).last(" limit 1"));
+        if (g10Param == null) {
+            g10Param = new WbsParam();
+            g10Param.setId(SnowFlakeUtil.getId());
+            g10Param.setName(name);
+            g10Param.setK(k);
+            g10Param.setNodeId(nodeId);
+            g10Param.setType(220);
+            g10Param.setCreateUser(AuthUtil.getUserId());
+            g10Param.setCreateTime(new Date());
+            g10Param.setV(v);
+            this.service.save(g10Param);
+        } else {
+            this.service.update(Wrappers.<WbsParam>lambdaUpdate().eq(WbsParam::getId,g10Param.getId()).set(WbsParam::getV, v).set(WbsParam::getUpdateUser,AuthUtil.getUserId()).set(WbsParam::getUpdateTime,new Date()));
+        }
+    }
+    private static String checkDeviationRange(String deviationRange) {
+        if (deviationRange ==  null || deviationRange.trim().isEmpty()) {
+            return null;
+        }
+        if (deviationRange.contains("±") && StringUtils.isNumber(deviationRange.replace("±", ""))) {
+            return deviationRange;
+        }
+        if (deviationRange.contains(",")) {
+            String[] split = deviationRange.split("[,,]");
+            if (split.length <= 1) {
+                return null;
+            }
+            if (StringUtils.isNumber(split[0]) && StringUtils.isNumber(split[1])) {
+                return split[0] + "," + split[1];
+            }
+        }
+        return null;
+    }
 
 }

+ 9 - 6
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ExcelTabMapper.xml

@@ -55,8 +55,9 @@
         dept.parent_id,
         dept.name,
         dept.file_type,
-        dept.tab_type AS "tabType",
-        dept.is_deleted,
+        dept.tab_type,
+        dept.tab_id,
+        info.table_owner as tableOwner,
         (
         SELECT
         CASE WHEN count(1) > 0 THEN 1 ELSE 0 END
@@ -67,18 +68,20 @@
         ) AS "has_children"
         FROM
         m_excel_tab dept
+        LEFT JOIN
+        m_table_info info ON dept.tab_id = info.id
         WHERE
-        (dept.is_deleted = 0 or dept.is_deleted = 3)
+        dept.is_deleted = 0
         <if test="param3!=null and param3!=''">
             AND dept.parent_id = #{param3}
         </if>
         <if test="param2!=null and param2!=''">
-            and dept.alias like concat(concat('%', #{param2}),'%')
+            AND dept.alias like concat(concat('%', #{param2}),'%')
         </if>
         <if test="param1!=null and param1!=''">
-            and dept.tenant_id = #{param1}
+            AND dept.tenant_id = #{param1}
         </if>
-        ORDER BY dept.sort,dept.create_time
+        ORDER BY dept.sort, dept.create_time
     </select>
 
 

+ 2 - 2
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/TextdictInfoMapper.java

@@ -62,9 +62,9 @@ public interface TextdictInfoMapper extends EasyBaseMapper<TextdictInfo> {
     //通过表单Id 获取电签信息
     List<TextdictInfoVO> getTextdictListInfoByPkeyId(@Param("tabId") String tabId,@Param("projectId") String projectId);
 
-    @Select("select * from m_textdict_info where project_id = #{treePrivate.projectId} and tab_id = #{treePrivate.pKeyId} and type = 2")
+    @Select("select * from m_textdict_info where project_id = #{treePrivate.projectId} and tab_id = #{treePrivate.pKeyId} and type in (2,6) and is_deleted = 0")
     List<TextdictInfoVO> selectTextDictInfoByProjectIdAndTabId(IPage<TextdictInfoVO> page, @Param("treePrivate") WbsTreePrivate treePrivate);
 
-    @Select("SELECT * from m_textdict_info WHERE project_id = #{treePrivate.projectId} and excel_id = #{treePrivate.excelId} and type = 2 and (SELECT 1 from m_wbs_tree_private WHERE p_key_id = tab_id and html_url = #{treePrivate.htmlUrl}) = 1")
+    @Select("SELECT * from m_textdict_info WHERE project_id = #{treePrivate.projectId} and excel_id = #{treePrivate.excelId} and type in (2,6) and is_deleted = 0 and (SELECT 1 from m_wbs_tree_private WHERE p_key_id = tab_id and html_url = #{treePrivate.htmlUrl}) = 1")
     List<TextdictInfoVO> selectTextdictInfoByExcelIdAndProjectIdAndHtmlUrl(IPage<TextdictInfoVO> page,@Param("treePrivate") WbsTreePrivate treePrivate);
 }

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

@@ -6403,6 +6403,9 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
         int i=0;
         boolean flag=false;
         for (WbsTreeContract contract : resultList) {
+            List<String> strings1=new ArrayList<>();
+            String sql="select "+strings[0]+ " from "+contract.getInitTableName()+" where p_key_id="+contract.getPKeyId();
+            strings1= jdbcTemplate.queryForList(sql, String.class);
             if(flag){
                 break;
             }
@@ -6412,11 +6415,6 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
             String htmlString = IoUtil.readToString(fileInputStream);
             Document doc = Jsoup.parse(htmlString);
             Elements keyNames = doc.getElementsByAttribute("keyname");
-            List<String> strings1=new ArrayList<>();
-            if(Objects.equals(contract.getPKeyId(), dto.getPkeyId())){
-                String sql="select "+strings[0]+ " from "+contract.getInitTableName()+" where p_key_id="+contract.getPKeyId();
-                strings1= jdbcTemplate.queryForList(sql, String.class);
-            }
             for (Element keyName : keyNames) {
                 String result = keyName.attr("keyname");
                 if(result.contains(strings[0])){
@@ -6430,6 +6428,18 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                             if(i2>=i1){
                                 map.put(result, numbers.get(i));
                                 i++;
+                                if(strings1.size()>0){
+                                    String string = strings1.get(0);
+                                    if(StringUtils.isNotEmpty(string)){
+                                        String[] split = string.split("☆");
+                                        for (String s : split) {
+                                            if(Objects.equals(s.split("_\\^_")[1], result.split("__")[1])){
+                                                map.put(result, s.split("_\\^_")[0]);
+                                                i--;
+                                            }
+                                        }
+                                    }
+                                }
                             }else {
                                 if(strings1.size()>0){
                                     String string = strings1.get(0);
@@ -6446,6 +6456,18 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                         }else {
                             map.put(result, numbers.get(i));
                             i++;
+                            if(strings1.size()>0){
+                                String string = strings1.get(0);
+                                if(StringUtils.isNotEmpty(string)){
+                                    String[] split = string.split("☆");
+                                    for (String s : split) {
+                                        if(Objects.equals(s.split("_\\^_")[1], result.split("__")[1])){
+                                            map.put(result, s.split("_\\^_")[0]);
+                                            i--;
+                                        }
+                                    }
+                                }
+                            }
                         }
                     } else {
                         flag=true;