火力规则:java代码层面设计
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
package com.solution.rule.domain.ultimately.fact;
|
||||
|
||||
import com.solution.rule.domain.ultimately.dto.FireRuleInputRedWeaponElementDTO;
|
||||
import com.solution.rule.domain.ultimately.dto.FireRuleTaskInputDTO;
|
||||
import com.solution.rule.domain.ultimately.vo.FireRuleOutputVO;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class DroolsFact {
|
||||
|
||||
//蓝方任务列表
|
||||
private FireRuleTaskInputDTO task;
|
||||
|
||||
//红方武器库
|
||||
private List<FireRuleInputRedWeaponElementDTO> redWeapons;
|
||||
|
||||
private FireRuleOutputVO fireRuleOutputVO;
|
||||
}
|
||||
@@ -9,7 +9,9 @@ import com.solution.rule.domain.simplerulepojo.Task;
|
||||
import com.solution.rule.domain.simplerulepojo.Weapon;
|
||||
import com.solution.rule.domain.simplerulepojo.fact.FactTask;
|
||||
import com.solution.rule.domain.ultimately.dto.FireRuleInputDTO;
|
||||
import com.solution.rule.domain.ultimately.dto.FireRuleInputRedWeaponElementDTO;
|
||||
import com.solution.rule.domain.ultimately.dto.FireRuleTaskInputDTO;
|
||||
import com.solution.rule.domain.ultimately.fact.DroolsFact;
|
||||
import com.solution.rule.domain.ultimately.vo.FireRuleOutputVO;
|
||||
import com.solution.rule.domain.vo.ComponentCountVO;
|
||||
import com.solution.rule.domain.vo.PlatformComponentNamesVO;
|
||||
@@ -202,16 +204,28 @@ public class FireRuleServiceImpl implements FireRuleService {
|
||||
if(CollUtil.isEmpty( tasks)){
|
||||
throw new RuntimeException(ExceptionConstants.PARAMETER_EXCEPTION);
|
||||
}
|
||||
//创建KieSession
|
||||
KieSession kieSession = kieBase.newKieSession();
|
||||
//设置Drools全局变量
|
||||
Map<String, Object> globalParams = new HashMap<>();
|
||||
kieSession.setGlobal("globalParams", globalParams);
|
||||
//获取红方武器库
|
||||
List<FireRuleInputRedWeaponElementDTO> redWeapons = task.getRedWeapons();
|
||||
//创建返回数据
|
||||
FireRuleOutputVO fireRuleOutputVO = new FireRuleOutputVO();
|
||||
fireRuleOutputVO.setSourceFile(task.getSourceFile());
|
||||
|
||||
DroolsFact droolsFact = new DroolsFact();
|
||||
droolsFact.setRedWeapons(redWeapons);
|
||||
|
||||
// droolsFact.getFireRuleOutputVO().setRedWeapons(redWeapons);
|
||||
droolsFact.setFireRuleOutputVO(fireRuleOutputVO);
|
||||
for (FireRuleTaskInputDTO fireRuleTaskInputDTO : tasks) {
|
||||
|
||||
|
||||
droolsFact.setTask(fireRuleTaskInputDTO);
|
||||
kieSession.insert(droolsFact);
|
||||
}
|
||||
|
||||
FireRuleOutputVO FireRuleOutputVO = new FireRuleOutputVO();
|
||||
return FireRuleOutputVO;
|
||||
return droolsFact.getFireRuleOutputVO();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user