Commit 57754bd8 authored by zhengjian's avatar zhengjian

6.6-2

parent 7bd81b90
......@@ -25,5 +25,6 @@ public class FundConfigCondition implements Serializable {
public static class Result{
private Boolean success;
private String fundInfo;
private String message;
}
}
......@@ -18,7 +18,9 @@ import com.quantgroup.asset.distribution.service.rule.IRuleService;
import com.quantgroup.asset.distribution.service.rule.vo.BaseRuleVO;
import com.quantgroup.asset.distribution.service.rule.vo.IRuleVO;
import com.quantgroup.asset.distribution.service.rule.vo.UnionRuleVO;
import org.apache.commons.collections.Bag;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.bag.HashBag;
import org.apache.commons.lang3.RandomUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -251,6 +253,8 @@ public class FundModuleServiceImpl implements IFundModuleService{
// 资方去重, 可能存在多条件同一个资方
Set<String> fundSet = new HashSet<>();
JSONArray fundArray = new JSONArray();
List<String> fundIds = new ArrayList<>();
Map<String,String> fundIdToTranslateMap = new HashMap<>();
A:for (ChannelFundConfigNew channelFundConfig : fundConfigList) {
IRuleVO ruleVO = ruleService.getIRuleVo(channelFundConfig.getLimits());
if (ruleVO == null) { throw new QGException(QGExceptionType.CRATE_RULE_VO_ERROR); }
......@@ -272,11 +276,13 @@ public class FundModuleServiceImpl implements IFundModuleService{
fundInfoJSON.put("priority", channelFundConfig.getPriority());
fundArray.add(fundInfoJSON);
fundSet.add(key);
fundIds.add(channelFundConfig.getFundId().toString());
}
}
FundConfigCondition.Result result = new FundConfigCondition.Result();
if (CollectionUtils.isEmpty(fundArray)){
result.setSuccess(false);
result.setMessage("不存在输出结果");
configCondition.setResult(result);
continue;
}
......@@ -286,14 +292,38 @@ public class FundModuleServiceImpl implements IFundModuleService{
for (int i = 0, len = fundArray.size(); i < len; i++) {
int priority = fundArray.getJSONObject(i).getIntValue("priority");
if (!(priority > 0 && priority <= len)) {
throw new QGException(QGExceptionType.FUND_PRIORITY_IS_ERROR);
result.setSuccess(false);
result.setMessage("多个资方配置存在交集");
configCondition.setResult(result);
continue ;
}
if (bucket[priority]) {
// 多个相同的优先级
throw new QGException(QGExceptionType.FUND_PRIORITY_IS_ERROR);
result.setSuccess(false);
result.setMessage("多个资方配置存在交集");
configCondition.setResult(result);
continue ;
}
bucket[priority] = true;
}
// 查看是否两个资方ID相同且条件存在交集
Bag bag = new HashBag(fundIds);
boolean hasSameResultTotal = false;
for (String id : fundIds){
if (bag.getCount(id) > 1 ){
boolean hasSameResult = hasSameResult(configId,id);
if (hasSameResult){
hasSameResultTotal = true;
break;
}
}
}
if (hasSameResultTotal){
result.setSuccess(false);
result.setMessage("同资方存在配置交集");
configCondition.setResult(result);
continue ;
}
result.setSuccess(true);
fundArray = JSONArray.parseArray(JSON.toJSONString(fundArray.stream().sorted(Comparator.comparingInt(o -> ((JSONObject) o).getInteger("priority"))).collect(Collectors.toList())));
String fundProductId = fundArray.getJSONObject(0).getString("fundProductId");
......@@ -306,6 +336,20 @@ public class FundModuleServiceImpl implements IFundModuleService{
return GlobalResponse.success(vo);
}
private boolean hasSameResult(Long configId,String fundId){
List<BaseRuleVO> ruleVOS = new ArrayList<>();
FundModuleChannelFundConfigNew config = fundModuleChannelFundConfigNewService.findById(configId);
List<ChannelFundConfigNew> fundConfigList = JSONArray.parseArray(config.getFunds(), ChannelFundConfigNew.class);
for (ChannelFundConfigNew channelFundConfig : fundConfigList){
if (fundId.equals(channelFundConfig.getFundId().toString())){
IRuleVO ruleVO = ruleService.getIRuleVo(channelFundConfig.getLimits());
ruleVOS.addAll(getAllBaseRule(ruleVO));
}
}
//对多个rule求交集
return false;
}
private static List<BaseRuleVO> getAllBaseRule(IRuleVO ruleVO){
List<BaseRuleVO> baseRuleList = new ArrayList<>();
if (ruleVO.getClass().isAssignableFrom(UnionRuleVO.class)){
......
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