ソースを参照

Merge branch 'refs/heads/feature-sync-lihb-20250813' into dev-test

# Conflicts:
#	blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/WbsTreeContractTreeAllVO.java
#	blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ContractInfoServiceImpl.java
#	blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreeContractServiceImpl.java
LHB 1 ヶ月 前
コミット
0d6967702f

+ 2 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/AppWbsTreeContractVO.java

@@ -21,4 +21,6 @@ public class AppWbsTreeContractVO extends WbsTreeContract {
     @ApiModelProperty(value = "文件题名")
     private String fileName;
 
+    @ApiModelProperty(value = "是否最近同步节点")
+    private Integer isSync;
 }

+ 2 - 1
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/WbsTreeContractLazyVO.java

@@ -139,6 +139,7 @@ public class WbsTreeContractLazyVO implements Serializable {
     @ApiModelProperty(value = "是否完成日期填写1是2否")
     private Integer dateIsComplete;
 
-
+    @ApiModelProperty(value = "是否最近同步节点")
+    private Integer isSync;
 
 }

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

@@ -44,6 +44,9 @@ public class WbsTreeContractTreeAllVO implements INode<WbsTreeContractTreeAllVO>
     @ApiModelProperty(value = "是否完成日期填写 1是 2否")
     private Integer dateIsComplete;
 
+    @ApiModelProperty(value = "是否为自定义新增节点 1=是")
+    private Integer isSync;
+
     @JsonInclude(JsonInclude.Include.NON_EMPTY)
     private List<WbsTreeContractTreeAllVO> children;
 

+ 30 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ContractInfoServiceImpl.java

@@ -16,9 +16,11 @@ import org.springblade.common.utils.BaiduApiUtil;
 import org.springblade.common.utils.SnowFlakeUtil;
 import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.mp.base.BaseServiceImpl;
+import org.springblade.core.secure.utils.SecureUtil;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.node.ForestNodeMerger;
 import org.springblade.core.tool.utils.BeanUtil;
+import org.springblade.core.tool.utils.CollectionUtil;
 import org.springblade.core.tool.utils.ObjectUtil;
 import org.springblade.manager.bean.NodeVO;
 import org.springblade.manager.dto.FindAllUserByConditionDTO;
@@ -34,6 +36,7 @@ import org.springblade.system.user.feign.IUserClient;
 import org.springblade.system.user.vo.UserContractInfoVO;
 import org.springblade.system.user.vo.UserVO2;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.dao.DataAccessException;
 import org.springframework.data.redis.core.StringRedisTemplate;
 import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.JdbcTemplate;
@@ -368,6 +371,25 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
     public R<Object> getTreeNodeByValueAndContractId(String queryValue, String contractId, String tableOwner) {
         if (StringUtils.isNotEmpty(queryValue) && StringUtils.isNotEmpty(contractId)) {
             ContractInfo contractInfo = contractInfoMapper.selectById(contractId);
+
+            //查询wbs同步信息
+            String contractExtendSql = "select a.ancestors from m_wbs_tree_contract_extend a " +
+                    "inner join m_wbs_tree_contract b on a.p_key_id = b.p_key_id and b.is_deleted = 0 and b.is_buss_show != 2 " +
+                    "where a.type = " + tableOwner + " and a.is_sync = 1 and a.is_deleted = 0 and a.contract_id = " + contractId;
+            Set<String> syncPKeyIds = new HashSet<>();
+            if(SecureUtil.isAdministrator()){
+                List<String> strings = null;
+                try {
+                    strings = jdbcTemplate.queryForList(contractExtendSql, String.class);
+                } catch (DataAccessException e) {
+                    e.printStackTrace();
+                    //TODO 暂时忽略错误
+                }
+                if(CollectionUtil.isNotEmpty(strings)){
+                    strings.stream().filter(com.alibaba.nacos.common.utils.StringUtils::isNotEmpty).forEach(f -> syncPKeyIds.addAll(Arrays.asList(f.split(","))));
+                }
+            }
+
             if (contractInfo != null) {
                 /*质检施工合同段*/
                 if (contractInfo.getContractType().equals(1)) {
@@ -519,6 +541,10 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
 //                                                    vo.setColorStatus(lowestNode.getColorStatus());
 //                                                }
 //                                            }
+                                            if(CollectionUtil.isNotEmpty(syncPKeyIds)){
+                                                //判断是否展示同步标识
+                                                vo.setIsSync(syncPKeyIds.contains(vo.getPrimaryKeyId().toString()) ? 1 : 0);
+                                            }
                                         }
                                         return vo;
                                     }).collect(Collectors.toList());
@@ -684,6 +710,10 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
 //                                                        vo.setColorStatus(lowestNode.getColorStatus());
 //                                                    }
 //                                                }
+                                                if(CollectionUtil.isNotEmpty(syncPKeyIds)){
+                                                    //判断是否展示同步标识
+                                                    vo.setIsSync(syncPKeyIds.contains(vo.getPrimaryKeyId().toString()) ? 1 : 0);
+                                                }
                                             }
                                             return vo;
                                         }).collect(Collectors.toList());

+ 20 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreeContractServiceImpl.java

@@ -45,6 +45,7 @@ import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.mp.base.BaseServiceImpl;
 import org.springblade.core.redis.cache.BladeRedis;
 import org.springblade.core.secure.utils.AuthUtil;
+import org.springblade.core.secure.utils.SecureUtil;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.node.ForestNodeMerger;
 import org.springblade.core.tool.utils.*;
@@ -61,6 +62,8 @@ import org.springblade.manager.utils.CompositeKey;
 import org.springblade.manager.vo.*;
 import org.springblade.system.cache.ParamCache;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.dao.DataAccessException;
 import org.springframework.data.redis.core.StringRedisTemplate;
 import org.springframework.jdbc.BadSqlGrammarException;
 import org.springframework.jdbc.core.BeanPropertyRowMapper;
@@ -610,6 +613,23 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
 //        if(info!=null){
 //            resultTabs.forEach(tab->tab.setFileName(info.getName()));
 //        }
+        //同步标识
+        if (CollectionUtil.isNotEmpty(resultTabs) && SecureUtil.isAdministrator()) {
+            List<Long> collect1 = resultTabs.stream().map(WbsTreeContract::getPKeyId).collect(Collectors.toList());
+            List<Long> longs = null;
+            try {
+                longs = jdbcTemplate.queryForList("select p_key_id from m_wbs_tree_contract_extend where is_sync = 1 and is_deleted = 0 and p_key_id in (" + StringUtils.join(collect1, ",") + ")", Long.class);
+            } catch (DataAccessException e) {
+                //TODO 暂时忽略异常,避免表不存在报错
+                e.printStackTrace();
+            }
+            if (CollectionUtil.isNotEmpty(longs)) {
+                List<Long> finalLongs = longs;
+                resultTabs.forEach(f -> {
+                    f.setIsSync(finalLongs.contains(f.getPKeyId()) && f.getIsBussShow() != 2 ? 1 : 0);
+                });
+            }
+        }
 
         if (Optional.ofNullable(wbsTreeContract.getIsUseSort()).orElse(0) == 0) {
             //表单排序

+ 38 - 0
blade-service/blade-user/src/main/java/org/springblade/system/user/service/impl/UserServiceImpl.java

@@ -761,6 +761,38 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
         if (cn.hutool.core.util.ObjectUtil.isNotEmpty(contractId)) {
             ContractInfo contractInfo = jdbcTemplate.query("SELECT contract_name,contract_type FROM m_contract_info WHERE id = " + contractId,
                     new BeanPropertyRowMapper<>(ContractInfo.class)).stream().findAny().orElse(null);
+
+            Set<String> ids = new HashSet<>();
+            List<String> strings = null;
+            if (SecureUtil.isAdministrator()) {
+                //查询当前节点的祖级路径和pkid
+                String s = "SELECT concat(ancestors_p_id,',',p_key_id) FROM m_wbs_tree_contract WHERE contract_id = " + contractId;
+                if(StringUtil.isNotBlank(contractIdRelation)){
+                    s = "SELECT concat(ancestors_p_id,',',p_key_id) FROM m_wbs_tree_contract WHERE contract_id = " + contractIdRelation;
+                }
+
+                if(StringUtil.isNotBlank(id)){
+                    s += " and id = " + id;
+                } else {
+                    s += " and parent_id = 0";
+                }
+
+                s += " limit 1";
+                try {
+                    String ancestors = jdbcTemplate.queryForObject(s,String.class);
+                    String contractExtendSql = "select a.ancestors from m_wbs_tree_contract_extend a " +
+                            "inner join m_wbs_tree_contract b on a.p_key_id = b.p_key_id and b.is_deleted = 0 and b.is_buss_show != 2 " +
+                            "where a.type = " + tableOwner + " and a.is_sync = 1 and a.is_deleted = 0 and a.ancestors like concat('" + ancestors + "','%')";
+                    strings = jdbcTemplate.queryForList(contractExtendSql, String.class);
+                } catch (DataAccessException e) {
+                    e.printStackTrace();
+                    //TODO 暂时忽略错误
+                }
+                if (CollectionUtil.isNotEmpty(strings)) {
+                    strings.stream().filter(StringUtils::isNotEmpty).forEach(f -> ids.addAll(Arrays.asList(f.split(","))));
+                }
+            }
+
             if (contractInfo != null) {
                 /* =========================== 施工合同段 =========================== */
                 if (new Integer(1).equals(contractInfo.getContractType())) {
@@ -897,6 +929,9 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
 
 //                            }
                         }
+                        if(CollectionUtil.isNotEmpty(ids)){
+                            lazyNodes.forEach(f -> f.setIsSync(ids.contains(f.getPKeyId().toString()) ? 1 : 0));
+                        }
                         return lazyNodes;
                     }
 
@@ -1036,6 +1071,9 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
                             }
                         }
                     }
+                    if(CollectionUtil.isNotEmpty(ids)){
+                        lazyNodesAll.forEach(f -> f.setIsSync(ids.contains(f.getPKeyId().toString()) ? 1 : 0));
+                    }
                     return lazyNodesAll;
                 }
             }