Commit e67dec12 authored by 梁光意's avatar 梁光意

修改不限过滤条件

parent ad82269a
Pipeline #9248 passed with stages
in 2 minutes 41 seconds
...@@ -53,9 +53,20 @@ public enum Condition { ...@@ -53,9 +53,20 @@ public enum Condition {
/** /**
* nin * nin
*/ */
NO_INS("no_ins"); NO_INS("no_ins"),
/**
* 不限
*/
NO_LIMIT("no_limit");
private String value; private String value;
Condition(String v) { Condition(String v) {
this.value = v; this.value = v;
}} }
public String getValue() {
return value;
}
}
...@@ -14,11 +14,13 @@ import com.syc.slm.common.core.constant.SlmConstants; ...@@ -14,11 +14,13 @@ import com.syc.slm.common.core.constant.SlmConstants;
import com.syc.slm.common.core.util.R; import com.syc.slm.common.core.util.R;
import com.syc.slm.common.core.util.RestTemplateUtils; import com.syc.slm.common.core.util.RestTemplateUtils;
import com.syc.slm.slmbi.dao.BusinessConfigMapper; import com.syc.slm.slmbi.dao.BusinessConfigMapper;
import com.syc.slm.slmbi.dto.BusinessConditionDTO;
import com.syc.slm.slmbi.dto.BusinessDTO; import com.syc.slm.slmbi.dto.BusinessDTO;
import com.syc.slm.slmbi.dto.BusinessStatisticsDTO; import com.syc.slm.slmbi.dto.BusinessStatisticsDTO;
import com.syc.slm.slmbi.entity.BaseEntity; import com.syc.slm.slmbi.entity.BaseEntity;
import com.syc.slm.slmbi.entity.BusinessConfig; import com.syc.slm.slmbi.entity.BusinessConfig;
import com.syc.slm.slmbi.entity.CurrentUser; import com.syc.slm.slmbi.entity.CurrentUser;
import com.syc.slm.slmbi.enums.Condition;
import com.syc.slm.slmbi.exception.SysException; import com.syc.slm.slmbi.exception.SysException;
import com.syc.slm.slmbi.service.BusinessConfigService; import com.syc.slm.slmbi.service.BusinessConfigService;
import com.syc.slm.slmbi.vo.BusinessConfigVo; import com.syc.slm.slmbi.vo.BusinessConfigVo;
...@@ -28,8 +30,10 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -28,8 +30,10 @@ import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.net.URLDecoder; import java.net.URLDecoder;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
/** /**
* slm-bi * slm-bi
...@@ -110,13 +114,13 @@ public class BusinessConfigServiceImpl extends ServiceImpl<BusinessConfigMapper, ...@@ -110,13 +114,13 @@ public class BusinessConfigServiceImpl extends ServiceImpl<BusinessConfigMapper,
} }
x.forEach((k,v)->{ x.forEach((k,v)->{
if(v.stream().anyMatch(y -> StringUtils.isBlank(y.getKey())) if(v.stream().anyMatch(y -> StringUtils.isBlank(y.getKey()))
|| v.stream().anyMatch(y -> ObjectUtils.isEmpty(y.getValue())) || v.stream().filter(y -> !Condition.NO_LIMIT.getValue().equals(y.getQueryType())).anyMatch(y -> ObjectUtils.isEmpty(y.getValue()))
|| v.stream().anyMatch(y -> StringUtils.isBlank(y.getQueryType()))) { || v.stream().anyMatch(y -> StringUtils.isBlank(y.getQueryType()))) {
throw new SysException("where 条件不能key value queryType 都不能为空"); throw new SysException("where 条件不能key value queryType 都不能为空");
} }
}); });
}); });
dto.setWhere(this.filterWhereNoLimit(dto.getWhere()));
Map<String, String> uriVariables = Maps.newHashMap(); Map<String, String> uriVariables = Maps.newHashMap();
uriVariables.put("appId", user.getAppId()); uriVariables.put("appId", user.getAppId());
R<Map<String,List<Object>>> result = RestTemplateUtils.post(uri, null,dto, new TypeToken<R<Map<String,List<Object>>>>() {}.getType(), uriVariables); R<Map<String,List<Object>>> result = RestTemplateUtils.post(uri, null,dto, new TypeToken<R<Map<String,List<Object>>>>() {}.getType(), uriVariables);
...@@ -148,13 +152,13 @@ public class BusinessConfigServiceImpl extends ServiceImpl<BusinessConfigMapper, ...@@ -148,13 +152,13 @@ public class BusinessConfigServiceImpl extends ServiceImpl<BusinessConfigMapper,
} }
x.forEach((k,v)->{ x.forEach((k,v)->{
if(v.stream().anyMatch(y -> StringUtils.isBlank(y.getKey())) if(v.stream().anyMatch(y -> StringUtils.isBlank(y.getKey()))
|| v.stream().anyMatch(y -> ObjectUtils.isEmpty(y.getValue())) || v.stream().filter(y -> !Condition.NO_LIMIT.getValue().equals(y.getQueryType())).anyMatch(y -> ObjectUtils.isEmpty(y.getValue()))
|| v.stream().anyMatch(y -> StringUtils.isBlank(y.getQueryType()))) { || v.stream().anyMatch(y -> StringUtils.isBlank(y.getQueryType()))) {
throw new SysException("where 条件不能key value queryType 都不能为空"); throw new SysException("where 条件不能key value queryType 都不能为空");
} }
}); });
}); });
dto.setWhere(this.filterWhereNoLimit(dto.getWhere()));
Map<String, String> uriVariables = Maps.newHashMap(); Map<String, String> uriVariables = Maps.newHashMap();
uriVariables.put("appId", user.getAppId()); uriVariables.put("appId", user.getAppId());
R<Map<String,Object>> result = RestTemplateUtils.post(uri, null,dto, new TypeToken<R<Map<String,Object>>>() {}.getType(), uriVariables); R<Map<String,Object>> result = RestTemplateUtils.post(uri, null,dto, new TypeToken<R<Map<String,Object>>>() {}.getType(), uriVariables);
...@@ -189,4 +193,22 @@ public class BusinessConfigServiceImpl extends ServiceImpl<BusinessConfigMapper, ...@@ -189,4 +193,22 @@ public class BusinessConfigServiceImpl extends ServiceImpl<BusinessConfigMapper,
} }
return page; return page;
} }
private List<Map<String, List<BusinessConditionDTO>>> filterWhereNoLimit(List<Map<String, List<BusinessConditionDTO>>> where){
List<Map<String, List<BusinessConditionDTO>>> resultList = Lists.newArrayList();
where.forEach(map -> {
Map<String, List<BusinessConditionDTO>> resultMap = Maps.newHashMap();
map.forEach((key,value) ->{
List<BusinessConditionDTO> dtoList =
value.stream().filter(dto -> !Condition.NO_LIMIT.getValue().equals(dto.getQueryType())).collect(Collectors.toList());
if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(dtoList)){
resultMap.put(key,dtoList);
}
});
if (!resultMap.isEmpty()){
resultList.add(resultMap);
}
});
return resultList;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment