Commit 0175c46e by 林永健

fix bug

1 parent f488b731
...@@ -29,7 +29,7 @@ import java.util.stream.Collectors; ...@@ -29,7 +29,7 @@ import java.util.stream.Collectors;
@Service @Service
@Slf4j @Slf4j
public class SopDataService { public class SopDataService {
private final String updateStagePrefix = "update cdp_customer_sop_journey set sop_journey_stage='%1$s',sop_journey_stage_enter_time=now() where sop_journey_stage!='%1$s' and sop_journey_id='%2$s'"; private final String updateStagePrefix = "update cdp_customer_sop_journey set sop_journey_stage='%1$s',sop_journey_stage_enter_time=now() where sop_journey_stage!='%1$s' and sop_journey_id='%2$s' and one_id in (select distinct one_id from cdp_customer_event where date(event_time) = current_date()) ";
@Autowired @Autowired
private SopDataFilterActionMapper sopDataFilterActionMapper; private SopDataFilterActionMapper sopDataFilterActionMapper;
...@@ -136,16 +136,35 @@ public class SopDataService { ...@@ -136,16 +136,35 @@ public class SopDataService {
} }
String subCondStr = joinWithDelimiter(" and ", subCondStrList); String subCondStr = joinWithDelimiter(" and ", subCondStrList);
condStr = sqlAnd(condStr, subCondStr); condStr = sqlAnd(condStr, subCondStr);
if (condition.getSql().toLowerCase().contains("(select ")) {
condStr += ")";
} }
} condStrList.add(checkSqlWrap(condStr));
condStrList.add(condStr);
} }
return sqlAnd(res, joinWithDelimiter(" and ", condStrList)); return sqlAnd(res, joinWithDelimiter(" and ", condStrList));
} }
/**
* 检查Condition拼接后的SQL并修复
*/
private String checkSqlWrap(String condStr) {
if (!StringUtils.hasLength(condStr) || !condStr.toLowerCase().contains("(select ")) {
return condStr;
}
int leftCount = 0;
int rightCount = 0;
for (char c : condStr.toCharArray()) {
if (c == '(') leftCount++;
if (c == ')') rightCount++;
}
int diff = leftCount - rightCount;
StringBuilder condStrBuilder = new StringBuilder(condStr);
while (diff > 0) {
condStrBuilder.append(")");
diff--;
}
return condStrBuilder.toString();
}
private String parseSQLWithOperator(SopDataConditionDTO condition) { private String parseSQLWithOperator(SopDataConditionDTO condition) {
String condStr = condition.getSql(); String condStr = condition.getSql();
if (CollectionUtils.isEmpty(condition.getOperators())) { if (CollectionUtils.isEmpty(condition.getOperators())) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!