guoshilong
2024-03-04 8ea0f39d1c072e1f3ab9970be110bca212773848
skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/resDataCheck/feign/RulesClient.java
@@ -12,6 +12,7 @@
import org.springblade.core.mp.support.Condition;
import org.springblade.core.tenant.annotation.NonDS;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;
@@ -49,7 +50,7 @@
      String retStr = "-1";
      switch (key) {
         case "EQUAL": //等于
            retStr = " is null OR = '' ";
            retStr = " is null";
            break;
         case "UNEQUAL": //不等于
            retStr = " is not null ";
@@ -237,7 +238,7 @@
         } else if (rc.getRelation().equals("OR")) {
            relation = " OR ";
         } else {
            relation = " WHERE ";
            relation = " WHERE (";
         }
         sqlStr += relation + getPropSqlStr(rc.getBasic());
@@ -246,7 +247,9 @@
         if (rc.getProp().equals("NULLVAL")) { // 空值
            sqlStr += getConditionSqlStrByNullVal(rc.getCondition());
         } else if (rc.getProp().equals("TARGET")) { // 指标
            sqlStr += getConditionSqlStrByTarget(rc.getCondition(), getPropSqlStr(rc.getTarget()), rc.getValue());
            sqlStr += ObjectUtil.isNotEmpty(rc.getFixValue())?
               getConditionSqlStrByTarget(rc.getCondition(), getPropSqlStr(rc.getTarget()), rc.getValue())+"-"+rc.getFixValue() :
               getConditionSqlStrByTarget(rc.getCondition(), getPropSqlStr(rc.getTarget()), rc.getValue());
         } else {
            sqlStr += getConditionSqlStrByVal(rc.getCondition(), rc.getValue());
         }
@@ -267,10 +270,15 @@
      }
      sqlStr += ")";
      varStr = "concat(" + varStr +") AS val";
      if (StringUtil.isNotBlank(rules.getIsGate())) {
         sqlStr += " and a.\"is_gate\" = " + rules.getIsGate();
         String gateStr = rules.getIsGate().equals("1") ?"'有闸控制'":"'无闸控制'";
         sqlStr += " and a.\"is_gate\" = " + gateStr;
      }
      // 拼接条件有问题,不操作
@@ -278,6 +286,7 @@
         log.info("查询条件错误,请检查规则设置......:", sqlStr);
         return R.fail(-1, sqlStr + "\\n 查询条件错误,请检查规则设置");
      }
      Integer ret = 0;
      try {
@@ -289,7 +298,7 @@
         log.info("执行完成......:");
      }
      // 执行sql
//       执行sql
      return R.data(ret);
   }
}