Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/WebBoServiceImpl.java
@@ -1,7 +1,6 @@
package com.vci.web.service.impl;
import com.vci.client.common.oq.OQTool;
import com.vci.client.common.providers.ClientServiceProvider;
import com.vci.common.qt.object.*;
import com.vci.common.utility.ObjectUtility;
import com.vci.corba.common.PLException;
@@ -15,6 +14,7 @@
import com.vci.corba.query.data.KV;
import com.vci.frameworkcore.compatibility.SmUserQueryServiceI;
import com.vci.omd.utils.ObjectTool;
import com.vci.pagemodel.*;
import com.vci.starter.web.annotation.Column;
import com.vci.starter.web.constant.QueryOptionConstant;
import com.vci.starter.web.enumpck.BooleanEnum;
@@ -24,12 +24,13 @@
import com.vci.starter.web.util.BeanUtil;
import com.vci.starter.web.util.VciBaseUtil;
import com.vci.starter.web.wrapper.VciQueryWrapperForDO;
import com.vci.web.pageModel.*;
import com.vci.web.properties.WebProperties;
import com.vci.web.service.*;
import com.vci.web.util.Func;
import com.vci.web.util.PlatformClientUtil;
import com.vci.web.util.WebUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.math3.distribution.TDistribution;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.slf4j.Logger;
@@ -197,7 +198,7 @@
      bo.versionRule = String.valueOf(btmTypeVO.getVersionRule());
      if(StringUtils.isNotBlank(btmTypeVO.getRevisionRuleId())){
         OsRevisionRuleVO revisionRuleVO = revisionRuleService.getRevisionRuleById(btmTypeVO.getRevisionRuleId());
         bo.revisionValue = revisionRuleVO.getStartCode();
         bo.revisionValue = revisionRuleVO.getInitialValue();
      }
      bo.revisionSeq = (short) 1;
@@ -893,7 +894,7 @@
    */
   @Override
   public List<BusinessObject> queryCBOByScheme(String queryScheme,
         Map<String, String> conditionMap, Map<String, String> replaceMap)
         Map<String, String> conditionMap, Map<String, Object> replaceMap)
         throws VciBaseException {
      PageHelper ph = new PageHelper(-1);
      return queryCBOByScheme(queryScheme,conditionMap,replaceMap,ph);
@@ -911,7 +912,7 @@
    */
   @Override
   public List<BusinessObject> queryCBOByScheme(String queryScheme,
         Map<String, String> conditionMap, Map<String, String> replaceMap,
         Map<String, String> conditionMap, Map<String, Object> replaceMap,
         PageHelper ph) throws VciBaseException {
      List<String> clauseList = new ArrayList<String>();
      clauseList.add("*");
@@ -926,7 +927,7 @@
    * @throws VciBaseException 查询出错的时候会抛出异常
    */
   @Override
   public QueryTemplate getQtByName(String name, Map<String, String> replaceMap) throws VciBaseException{
   public QueryTemplate getQtByName(String name, Map<String, Object> replaceMap) throws VciBaseException{
      QueryTemplate qt = null;
      try{
         VciBaseUtil.alertNotNull(name,"查询模板的名称");
@@ -935,15 +936,18 @@
         //因为之前平台的Tool.replaceQTValues 没有处理 ${xxx}。, 为了忽略大小写,我们这里单独处理 weidy@2021-3-10
         //我们转换为小写
         Condition condition = qt.getCondition();
         Map<String,String> replaceLowMap = new HashMap<>();
         Map<String,Object> replaceLowMap = new HashMap<>();
         if(condition !=null && condition.getCIMap()!=null){
            // Map<String, String> systemVarValueMap = VciSystemVarConstants.getSystemVarValueMap();
            //转小写
            if(!CollectionUtils.isEmpty(replaceMap)){
               replaceMap.forEach((key,value)->{
                  replaceLowMap.put(key.toLowerCase(),value);
               });
            }
            Map<String, ConditionItem> ciMap = condition.getCIMap();
            //改为递归,处理模板套模板的问题
            this.recurReplaceCiMap(qt,replaceLowMap);
            /*Map<String, ConditionItem> ciMap = condition.getCIMap();
            ciMap.forEach((ciId,ci)->{
               if(ci.isLeaf()) {
                  LeafInfo lInfo = ci.getLeafInfo();
@@ -966,7 +970,7 @@
                     }
                  }
               }
            });
            });*/
         }
      }catch(PLException e){
         logger.error(e.code,e);
@@ -976,6 +980,44 @@
         throw new VciBaseException(this.msgCodePrefix + "qtError", new Object[]{name});
      }
      return qt;
   }
   /**
    * 递归处理ciMap中值替换问题,处理模板套模板的问题
    * @param qt
    * @param replaceLowMap
    */
   private void recurReplaceCiMap(QueryTemplate qt, Map<String,Object> replaceLowMap){
      //跳出递归
      if(Func.isEmpty(qt)){
         return;
      }
      Map<String, ConditionItem> ciMap = qt.getCondition().getCIMap();
      ciMap.forEach((ciId,ci)->{
         if(ci.isLeaf()) {
            LeafInfo lInfo = ci.getLeafInfo();
            String value = lInfo.getValue().getOrdinaryValue();
            if(StringUtils.isNotBlank(value)){
               if(value.contains("#")){
                  //系统变量.支持一个
                  //lInfo.getValue().setOrdinaryValue(systemVarValueMap.getOrDefault(value.toUpperCase(),""));
               }else if(value.contains("${")){
                  //有${xxxx}的方式
                  if(!CollectionUtils.isEmpty(replaceLowMap)) {
                     try {
                        lInfo.getValue().setOrdinaryValue(VciBaseUtil.replaceByFreeMarker(value, replaceLowMap));
                     }catch (Throwable e){
                        logger.error("可能配置有问题,在转换freemarker表达式的时候,没有找到对应的值,目前表达式为{}",new String[]{value},e);
                     }
                  }
               }else if(replaceLowMap.containsKey(value.toLowerCase())){
                  lInfo.getValue().setOrdinaryValue((String) replaceLowMap.get(value.toLowerCase()));
               }
            }else {
               recurReplaceCiMap(lInfo.getValue().getQueryTemplate(),replaceLowMap);
            }
         }
      });
   }
   /**
@@ -990,7 +1032,7 @@
    */
   @Override
   public List<BusinessObject> queryCBOByScheme(String queryScheme,
         Map<String, String> conditionMap, Map<String, String> replaceMap,
         Map<String, String> conditionMap, Map<String, Object> replaceMap,
         PageHelper ph, List<String> clauseList) throws VciBaseException {
      QueryTemplate qt = getQtByName(queryScheme,replaceMap);
      return baseQueryCBO(qt,conditionMap,ph,clauseList);
@@ -1094,7 +1136,7 @@
    */
   @Override
   public int queryCountByScheme(String queryScheme,
         Map<String, String> conditionMap, Map<String, String> replaceMap)
         Map<String, String> conditionMap, Map<String, Object> replaceMap)
         throws VciBaseException {
      QueryTemplate qt = getQtByName(queryScheme,replaceMap);
      return baseQueryCount(qt,conditionMap);
@@ -1442,7 +1484,7 @@
   @Override
   public <T> List<T> queryObjectByScheme(String queryScheme, Class<T> c,
         Map<String, String> conditionMap, PageHelper ph,
         Map<String, String> replaceMap) throws VciBaseException {
         Map<String, Object> replaceMap) throws VciBaseException {
      WebUtil.alertNotNull(queryScheme,"查询方案");
      //直接从对象里去查询业务类型的名称
      swapConditionMap(c,conditionMap);
@@ -2068,7 +2110,7 @@
     */
   @Override
   public DataGrid queryGridByScheme(String queryScheme,
         Map<String, String> conditionMap, Map<String, String> replaceMap)
         Map<String, String> conditionMap, Map<String, Object> replaceMap)
         throws VciBaseException {
      return queryGridByScheme(queryScheme,conditionMap,replaceMap,new PageHelper(-1,true),null);
   }
@@ -2084,7 +2126,7 @@
     */
   @Override
   public DataGrid queryGridByScheme(String queryScheme,
         Map<String, String> conditionMap, Map<String, String> replaceMap,
         Map<String, String> conditionMap, Map<String, Object> replaceMap,
         PageHelper ph) throws VciBaseException {
      return queryGridByScheme(queryScheme,conditionMap,replaceMap,ph,null);
   }
@@ -2101,7 +2143,7 @@
     */
   @Override
   public DataGrid queryGridByScheme(String queryScheme,
         Map<String, String> conditionMap, Map<String, String> replaceMap,
         Map<String, String> conditionMap, Map<String, Object> replaceMap,
         PageHelper ph, List<String> clauseList) throws VciBaseException {
      if(ph == null){
         ph = new PageHelper(-1,true);
@@ -2172,7 +2214,7 @@
     */
   @Override
   public DataGrid queryGridClassByScheme(String queryScheme, Class c,
         Map<String, String> conditionMap,Map<String,String> replaceMap) throws VciBaseException {
         Map<String, String> conditionMap,Map<String,Object> replaceMap) throws VciBaseException {
      return queryGridClassByScheme(queryScheme,c,conditionMap,replaceMap,new PageHelper(-1,true));
   }
   
@@ -2187,7 +2229,7 @@
     */
   @Override
   public DataGrid queryGridClassByScheme(String queryScheme, Class c,
         Map<String, String> conditionMap, Map<String,String> replaceMap,PageHelper ph)
         Map<String, String> conditionMap, Map<String,Object> replaceMap,PageHelper ph)
         throws VciBaseException {
      if(ph == null){
         ph = new PageHelper(-1,true);
@@ -2232,9 +2274,13 @@
   public Map cbo2Map(BusinessObject cbo) throws VciBaseException {
      Map<String,String> map = new HashMap<String, String>();
      WebUtil.copyValueToMapFromCbos(cbo, map);
      return map;
      //TODO:20241128 过滤掉空key和空value
      Map<String, Object> filteredCbo2Map = map.entrySet()
            .stream()
            .filter(entry -> entry.getKey() != null && !entry.getKey().isEmpty() && entry.getValue() != null && !entry.getValue().toString().isEmpty())
            .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
      return filteredCbo2Map;
   }
    /**
     * map转为BusinessObject