Commit e9d1ff23 authored by linruibiao's avatar linruibiao

Merge remote-tracking branch 'origin/develop' into develop

parents ce37fc4b 0a9e69e4
...@@ -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
...@@ -102,21 +106,21 @@ public class BusinessConfigServiceImpl extends ServiceImpl<BusinessConfigMapper, ...@@ -102,21 +106,21 @@ public class BusinessConfigServiceImpl extends ServiceImpl<BusinessConfigMapper,
} }
if(CollectionUtils.isEmpty(dto.getWhere())){ if(CollectionUtils.isEmpty(dto.getWhere())){
throw new SysException("where 条件不能为空"); throw new SysException("暂无数据,请检查图表数据或关联查询组件是否已配置");
} }
dto.getWhere().forEach(x->{ dto.getWhere().forEach(x->{
if(CollectionUtils.isEmpty(x.keySet())){ if(CollectionUtils.isEmpty(x.keySet())){
throw new SysException("条件 and 或者or 都必须说明"); throw new SysException("暂无数据,请检查图表数据或关联查询组件是否已配置");
} }
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("暂无数据,请检查图表数据或关联查询组件是否已配置");
} }
}); });
}); });
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);
...@@ -140,21 +144,21 @@ public class BusinessConfigServiceImpl extends ServiceImpl<BusinessConfigMapper, ...@@ -140,21 +144,21 @@ public class BusinessConfigServiceImpl extends ServiceImpl<BusinessConfigMapper,
} }
} }
if(CollectionUtils.isEmpty(dto.getWhere())){ if(CollectionUtils.isEmpty(dto.getWhere())){
throw new SysException("where 条件不能为空"); throw new SysException("暂无数据,请检查图表数据或关联查询组件是否已配置");
} }
dto.getWhere().forEach(x->{ dto.getWhere().forEach(x->{
if(CollectionUtils.isEmpty(x.keySet())){ if(CollectionUtils.isEmpty(x.keySet())){
throw new SysException("条件 and 或者or 都必须说明"); throw new SysException("暂无数据,请检查图表数据或关联查询组件是否已配置");
} }
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("暂无数据,请检查图表数据或关联查询组件是否已配置");
} }
}); });
}); });
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