Commit 89cef753 by 叶兴兴

项目初始化提交

parents
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**
!**/src/test/**
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
### VS Code ###
.vscode/
/recommendationLogs/
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.8.RELEASE</version>
</parent>
<groupId>com.qiwu</groupId>
<artifactId>inference-game</artifactId>
<version>2.0.0</version>
<packaging>jar</packaging>
<name>inference-game-2.0.0</name>
<description>inference-game-2.0.0</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- 实现对 MyBatis Plus 的自动化配置 -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.2</version>
</dependency>
<!--MyBatis Plus 代码生成器-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
<version>3.5.2</version>
</dependency>
<!--Velocity模板引擎-->
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity-engine-core</artifactId>
<version>2.3</version>
</dependency>
<!--Swagger-UI API文档生产工具-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson</artifactId>
<version>3.17.4</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.2.11</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.70</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>3.1.1</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>compile</scope>
</dependency>
<!--Hutool Java工具包-->
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.8</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.4</version>
</dependency>
<!--解压缩工具包-->
<dependency>
<groupId>com.github.junrar</groupId>
<artifactId>junrar</artifactId>
<version>7.5.4</version>
</dependency>
<dependency>
<groupId>net.lingala</groupId>
<artifactId>zip4j</artifactId>
<version>1.3.3</version>
</dependency>
</dependencies>
<build>
<finalName>inference-game</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.1.7.RELEASE</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
package com.qiwu.inference;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.read.listener.PageReadListener;
import com.qiwu.inference.pojo.*;
import com.qiwu.inference.service.*;
import com.qiwu.inference.util.FileUtil;
import com.qiwu.inference.util.SpringContextUtil;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import java.io.File;
@SpringBootApplication
public class FileImport {
private static EndGoalService endGoalService;
private static KeyClueService keyClueService;
private static IdentityService identityService;
private static PersonService personService;
private static LocationService locationService;
private static DispositionService dispositionService;
private static DispositionTypeService dispositionTypeService;
private static BehaviourService behaviourService;
private static RelationService relationService;
private static RelationTypeService relationTypeService;
private static DemandTaskService demandTaskService;
private static TaskConditionService taskConditionService;
private static ItemService itemService;
private static ClueService clueService;
public static void main(String[] args) {
SpringApplication.run(FileImport.class,args);
ApplicationContext applicationContext = SpringContextUtil.getApplicationContext();
//1. 结局目标
endGoalService = applicationContext.getBean(EndGoalService.class);
String fileName = FileUtil.getPath() + "file" + File.separator + "end_goal.xlsx";
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
// 这里每次会读取100条数据 然后返回过来 直接调用使用数据就行
EasyExcel.read(fileName, EndGoal.class, new PageReadListener<EndGoal>(dataList -> {
endGoalService.saveBatch(dataList);
})).sheet().doRead();
//2. 关键线索
keyClueService = applicationContext.getBean(KeyClueService.class);
fileName = FileUtil.getPath() + "file" + File.separator + "key_clue.xlsx";
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
// 这里每次会读取100条数据 然后返回过来 直接调用使用数据就行
EasyExcel.read(fileName, KeyClue.class, new PageReadListener<KeyClue>(dataList -> {
keyClueService.saveBatch(dataList);
})).sheet().doRead();
//3. 身份
identityService = applicationContext.getBean(IdentityService.class);
fileName = FileUtil.getPath() + "file" + File.separator + "identity.xlsx";
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
// 这里每次会读取100条数据 然后返回过来 直接调用使用数据就行
EasyExcel.read(fileName, Identity.class, new PageReadListener<Identity>(dataList -> {
identityService.saveBatch(dataList);
})).sheet().doRead();
//4. 场所
locationService = applicationContext.getBean(LocationService.class);
fileName = FileUtil.getPath() + "file" + File.separator + "location.xlsx";
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
// 这里每次会读取100条数据 然后返回过来 直接调用使用数据就行
EasyExcel.read(fileName, Location.class, new PageReadListener<Location>(dataList -> {
locationService.saveBatch(dataList);
})).sheet().doRead();
//5. 性格喜好
dispositionService = applicationContext.getBean(DispositionService.class);
fileName = FileUtil.getPath() + "file" + File.separator + "disposition.xlsx";
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
// 这里每次会读取100条数据 然后返回过来 直接调用使用数据就行
EasyExcel.read(fileName, Disposition.class, new PageReadListener<Disposition>(dataList -> {
dispositionService.saveBatch(dataList);
})).sheet().doRead();
//6. 行为
behaviourService = applicationContext.getBean(BehaviourService.class);
fileName = FileUtil.getPath() + "file" + File.separator + "behaviour.xlsx";
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
// 这里每次会读取100条数据 然后返回过来 直接调用使用数据就行
EasyExcel.read(fileName, Behaviour.class, new PageReadListener<Behaviour>(dataList -> {
behaviourService.saveBatch(dataList);
})).sheet().doRead();
//7. 关系
relationService = applicationContext.getBean(RelationService.class);
fileName = FileUtil.getPath() + "file" + File.separator + "relation.xlsx";
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
// 这里每次会读取100条数据 然后返回过来 直接调用使用数据就行
EasyExcel.read(fileName, Relation.class, new PageReadListener<Relation>(dataList -> {
relationService.saveBatch(dataList);
})).sheet().doRead();
//8. 关系类型
relationTypeService = applicationContext.getBean(RelationTypeService.class);
fileName = FileUtil.getPath() + "file" + File.separator + "relation_type.xlsx";
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
// 这里每次会读取100条数据 然后返回过来 直接调用使用数据就行
EasyExcel.read(fileName, RelationType.class, new PageReadListener<RelationType>(dataList -> {
relationTypeService.saveBatch(dataList);
})).sheet().doRead();
//9. 需求任物
demandTaskService = applicationContext.getBean(DemandTaskService.class);
fileName = FileUtil.getPath() + "file" + File.separator + "demand_task.xlsx";
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
// 这里每次会读取100条数据 然后返回过来 直接调用使用数据就行
EasyExcel.read(fileName, DemandTask.class, new PageReadListener<DemandTask>(dataList -> {
demandTaskService.saveBatch(dataList);
})).sheet().doRead();
//10. 任物条件
taskConditionService = applicationContext.getBean(TaskConditionService.class);
fileName = FileUtil.getPath() + "file" + File.separator + "task_condition.xlsx";
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
// 这里每次会读取100条数据 然后返回过来 直接调用使用数据就行
EasyExcel.read(fileName, TaskCondition.class, new PageReadListener<TaskCondition>(dataList -> {
taskConditionService.saveBatch(dataList);
})).sheet().doRead();
//11. 人物表
personService = applicationContext.getBean(PersonService.class);
fileName = FileUtil.getPath() + "file" + File.separator + "person.xlsx";
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
// 这里每次会读取100条数据 然后返回过来 直接调用使用数据就行
EasyExcel.read(fileName, Person.class, new PageReadListener<Person>(dataList -> {
personService.saveBatch(dataList);
})).sheet().doRead();
//12. 物品表
itemService = applicationContext.getBean(ItemService.class);
fileName = FileUtil.getPath() + "file" + File.separator + "item.xlsx";
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
// 这里每次会读取100条数据 然后返回过来 直接调用使用数据就行
EasyExcel.read(fileName, Item.class, new PageReadListener<Item>(dataList -> {
itemService.saveBatch(dataList);
})).sheet().doRead();
//13. 性格类型
dispositionTypeService = applicationContext.getBean(DispositionTypeService.class);
fileName = FileUtil.getPath() + "file" + File.separator + "disposition_type.xlsx";
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
// 这里每次会读取100条数据 然后返回过来 直接调用使用数据就行
EasyExcel.read(fileName, DispositionType.class, new PageReadListener<DispositionType>(dataList -> {
dispositionTypeService.saveBatch(dataList);
})).sheet().doRead();
//14. 线索
clueService = applicationContext.getBean(ClueService.class);
fileName = FileUtil.getPath() + "file" + File.separator + "clue.xlsx";
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
// 这里每次会读取100条数据 然后返回过来 直接调用使用数据就行
EasyExcel.read(fileName, Clue.class, new PageReadListener<Clue>(dataList -> {
clueService.saveBatch(dataList);
})).sheet().doRead();
}
}
package com.qiwu.inference;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication
public class InferenceGameApplication {
public static void main(String[] args) {
SpringApplication.run(InferenceGameApplication.class, args);
}
}
package com.qiwu.inference.auto;
import cn.hutool.core.util.ObjectUtil;
import com.qiwu.inference.auto.enums.ConditionMethod;
import com.qiwu.inference.auto.pojo.*;
import com.qiwu.inference.auto.service.PlayerServiceImpl;
import com.qiwu.inference.common.api.CommonData;
import com.qiwu.inference.common.api.CommonResult;
import com.qiwu.inference.util.FastJsonUtil;
import com.qiwu.inference.util.FileUtil;
import org.springframework.util.StringUtils;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.*;
public class BFS {
private static PlayerServiceImpl playerService;
public static List<String> list = new ArrayList<>();
private static boolean endFlag = true;
private static int count = 0;
public static int steps = 30;
private static double minScore = 0;
public static void main(String[] args) throws Exception {
// String key = "4a2410ec-a131-4a43-bb4b-13b0ce5ea30a";
Player player;
player = new Player();
// if (!RedissonUtil.checkKey(key)) {
// player = new Player();
// RedissonUtil.setStr(player.getGateNo(), FastJsonUtil.obj2json(player));
// } else {
// String playerStr = RedissonUtil.getStr(key);
// player = FastJsonUtil.json2obj(playerStr, Player.class);
// }
playerService = new PlayerServiceImpl();
for (Integer personId : player.getPersonMap().keySet()) {
findTasks(personId, player);
}
minScore = 0;
player.setIndex(0);
player.aStarScore();
aStar(player);
String filePath = FileUtil.getPath() + "file" + File.separator + "results_log.txt";
FileUtil.writeLog(list, filePath);
System.exit(0);
}
/**
* 查询符合条件的任务
*/
private static void findTasks(int personId, Player player) {
List<DemandTask> demandTaskList = player.getPersonMap().get(personId).getDemandTasks();
for (DemandTask demandTask : demandTaskList) {
if (demandTask.getType() == 6) {
if (demandTask.getSubject() == personId && demandTask.getClueSwitch() == 0) {
if (!player.getDemandTaskHashSet().contains(demandTask)) {
demandTask.setStatus(2);
demandTask.setLockStatus(1);
demandTask.setClueProb(1.0);
demandTask.setThresholdStatus(1);
demandTask.setThresholdProb(1.0);
player.getDemandTaskQueue().add(demandTask);
player.getDemandTaskHashSet().add(demandTask);
}
}
}
}
}
/**
* 查询符合条件的任务
*/
private static void findTasks(String postTask, int personId, Player player) {
if (personId == 0) {
return;
}
List<DemandTask> demandTaskList = player.getPersonMap().get(personId).getDemandTasks();
for (DemandTask demandTask : demandTaskList) {
if (demandTask.getType() == 6) {
String[] postTasks = postTask.split("\\|");
for (String taskId : postTasks) {
if (demandTask.getSubject() == personId && demandTask.getDemandTaskId() == Integer.parseInt(taskId)) {
if (!player.getDemandTaskHashSet().contains(demandTask)) {
demandTask.setStatus(2);
demandTask.setLockStatus(1);
player.getDemandTaskQueue().add(demandTask);
player.getDemandTaskHashSet().add(demandTask);
}
}
}
}
}
}
/**
* 执行询问操作
* @param player 玩家信息
*/
private static void performAsk(Player player) {
Map<Integer, Person> personMap = player.getPersonMap();
//List<String> askMethodId = Arrays.asList("1007");
List<String> askMethodId = Arrays.asList("1002", "1007", "1009", "1010", "1015", "1016", "1017", "1018", "1019", "1020", "1021", "1022", "1023", "1029", "1024", "1025", "1026", "1027", "1028");
//List<String> askMethodId = Arrays.asList("1002","1007","1009","1010","1023","1029","1024","1025","1026","1027","1028");
for (Integer subjectId : personMap.keySet()) {
player.setPersonId(subjectId);
//System.out.println("当前询问人物的编号:"+subjectId);
for (Integer objectId : personMap.keySet()) {
if (!Objects.equals(subjectId, objectId)) {
for (String methodId : askMethodId) {
askOperate(personMap.get(objectId), null, methodId, player);
}
}
}
}
}
/**
* 询问操作
*
* @param subject 主体对象
* @param object 客体对象
* @param methodId 方法id
* @param player 玩家信息
*/
private static void askOperate(Person subject, Person object, String methodId, Player player) {
Map<String, String> request = new HashMap<>();
request.put("subjectName", subject.getName());
if ("1003".equals(methodId) || "1004".equals(methodId) || "1008".equals(methodId) || "1011".equals(methodId)) {
request.put("objectName", object.getName());
}
CommonResult<CommonData> result = null;
if ("1001".equals(methodId) || "1002".equals(methodId)) {
request.put("type", "1");
request.put("dispositionName", subject.getDispositions().get(0).getName());
result = playerService.askDisposition(methodId, player, request);
if (result.getCode() == 200) {
if ("1".equals(result.getData().getStatus())) {
List<DemandTask> demandTaskList = result.getData().getDemandTaskList();
if (demandTaskList.size() > 0) {
String res = "向" + player.getPersonMap().get(player.getPersonId()).getName() + "询问,执行" + methodId + "(" + result.getData().getName() + ")操作,向" + subject.getName() + "询问性格," + "反馈结果为:" + result.getData().getText();
printLog(res, player);
saveTask(demandTaskList, player);
}
}
}
} else if ("1003".equals(methodId) || "1004".equals(methodId) || "1005".equals(methodId) || "1006".equals(methodId)) {
if ("1003".equals(methodId)) {
result = playerService.askRelation(methodId, player, request);
if (result.getCode() == 200) {
if ("1".equals(result.getData().getStatus())) {
// String res ="向"+player.getPersonMap().get(player.getPersonId()).getName()+"询问,执行"+methodId+"("+result.getData().getName()+")操作,询问"+subject.getName()+"和"+object.getName()+"的关系,"+"反馈结果为:"+result.getData().getText();
}
}
} else {
Set<String> relations = new HashSet<>();
for (Person person : player.getPersonMap().values()) {
for (Relation relation : person.getRelations()) {
relations.add(relation.getName());
}
}
//String[] relations = new String[]{"面缘","认识","友好","亲密","厌恶","仇恨","儿子","女儿","父亲","母亲","妻子","丈夫","前妻","前夫","孙子","孙女","爷爷","奶奶","外公","外婆","亲戚","远房亲戚","邻居","朋友","被绑架","绑架","被买","被卖","买人","卖人","盗窃","被盗"};
for (String relation : relations) {
request.put("relationName", relation);
result = playerService.askRelation(methodId, player, request);
if (result.getCode() == 200) {
if ("1".equals(result.getData().getStatus())) {
if ("1004".equals(methodId)) {
// String res ="向"+player.getPersonMap().get(player.getPersonId()).getName()+"询问,执行"+methodId+"("+result.getData().getName()+")操作,询问"+subject.getName()+"和"+object.getName()+"之间是否是"+relation+"的关系,"+"反馈结果为:"+result.getData().getText();
} else {
// String res ="向"+player.getPersonMap().get(player.getPersonId()).getName()+"询问,执行"+methodId+"("+result.getData().getName()+")操作,询问"+subject.getName()+"和谁之间是否是"+relation+"的关系,"+"反馈结果为:"+result.getData().getText();
}
}
}
}
}
} else if ("1007".equals(methodId) || "1008".equals(methodId) || "1009".equals(methodId) || "1010".equals(methodId) || "1011".equals(methodId)) {
if ("1007".equals(methodId)) {
result = playerService.askBehaviour(methodId, player, request);
if (result.getCode() == 200) {
if ("1".equals(result.getData().getStatus())) {
List<DemandTask> demandTaskList = result.getData().getDemandTaskList();
if (demandTaskList.size() > 0) {
String res = "向" + player.getPersonMap().get(player.getPersonId()).getName() + "询问,执行" + methodId + "(" + result.getData().getName() + ")操作,询问" + subject.getName() + "有什么样的行为," + "反馈结果为:" + result.getData().getText();
printLog(res, player);
saveTask(demandTaskList, player);
}
}
}
} else if ("1008".equals(methodId)) {
result = playerService.askBehaviour(methodId, player, request);
if (result.getCode() == 200) {
if ("1".equals(result.getData().getStatus())) {
// String res ="向"+player.getPersonMap().get(player.getPersonId()).getName()+"询问,执行"+methodId+"("+result.getData().getName()+")操作,询问"+subject.getName()+"和"+object.getName()+"之间有什么样的行为,"+"反馈结果为:"+result.getData().getText();
}
}
} else {
Set<String> behaviours = new HashSet<>();
for (Person person : player.getPersonMap().values()) {
for (Behaviour behaviour : person.getBehaviours()) {
behaviours.add(behaviour.getName());
}
}
// String[] behaviours = new String[]{"斗殴","殴伤","重伤","绑架","偷盗金钱","偷盗物品","被绑架","贪污金钱","贪污财宝","暗探","在逃", "越狱", "通缉", "通奸", "诈骗", "欺骗", "威胁", "挑拨", "诱拐", "欠债", "欠债不还", "辱骂", "造谣", "强奸", "背叛感情", "背叛上级", "背叛同伴", "出卖感情", "出卖上司", "出卖同伴", "帮助", "贿赂", "受贿", "讨好", "路边看到", "关怀备至", "学习武艺", "杀人", "帮买米", "买东西", "卖东西",
// "偷听", "闲聊", "密谈", "拜访", "取笑", "送礼", "追求", "求学", "传授武艺", "传授学问", "救火", "被打伤", "被打重伤", "被盗", "被贪污", "被通缉", "被诈骗", "被欺骗", "被威胁", "被挑拨", "被诱拐", "被欠债", "被欠债不还", "被辱骂", "被造谣", "被强奸", "被背叛感情", "被背叛", "被出卖感情", "被出卖", "被帮助", "被讨好", "被关怀", "被拜访", "被取笑", "被送礼", "被追求", "丢失钗子", "捡到钗子", "盗窃钗子"};
for (String behaviour : behaviours) {
request.put("behaviourName", behaviour);
result = playerService.askBehaviour(methodId, player, request);
if (result.getCode() == 200) {
if ("1".equals(result.getData().getStatus())) {
if ("1011".equals(methodId)) {
// String res ="向"+player.getPersonMap().get(player.getPersonId()).getName()+"询问,执行"+methodId+"("+result.getData().getName()+")操作,询问"+subject.getName()+"和"+object.getName()+"之间是否有"+behaviour+"的行为,"+"反馈结果为:"+result.getData().getText();
} else {
List<DemandTask> demandTaskList = result.getData().getDemandTaskList();
if (demandTaskList.size() > 0) {
String res = "向" + player.getPersonMap().get(player.getPersonId()).getName() + "询问,执行" + methodId + "(" + result.getData().getName() + ")操作,询问" + subject.getName() + "和谁有" + behaviour + "的行为," + "反馈结果为:" + result.getData().getText();
printLog(res, player);
saveTask(demandTaskList, player);
}
}
}
}
}
}
} else if ("1015".equals(methodId) || "1016".equals(methodId) || "1017".equals(methodId) || "1018".equals(methodId) || "1019".equals(methodId) || "1020".equals(methodId) || "1021".equals(methodId) || "1022".equals(methodId)) {
if ("1017".equals(methodId) || "1018".equals(methodId) || "1021".equals(methodId) || "1022".equals(methodId)) {
Set<String> tasks = new HashSet<>();
for (Person person : player.getPersonMap().values()) {
for (DemandTask demandTask : person.getDemandTasks()) {
tasks.add(demandTask.getName());
}
}
//String[] tasks = new String[]{"饮酒", "开怀畅饮", "打招呼", "喜欢古董", "(后)卖古董", "(后)卖古董低价", "需要金疮药", "(后)买金疮药", "(后)获赠金疮药", "揍人报仇", "(后)挨揍", "请吃饭", "小费", "帮忙挑水", "帮找大夫", "(后)大夫出诊", "一起钓鱼", "需要人送货", "想要茶具", "(后)卖出茶具", "喜欢钓鱼", "送钱(高)", "送钱(中)", "送钱(低)", "寻找钗子", "(后)买回钗子", "(后)抢回钗子", "追查私吞", "(后)追回私吞款", "打探肥羊", "(后)探听身家", "(后)送货"};
for (String task : tasks) {
request.put("taskName", task);
result = playerService.askTask(methodId, player, request);
if (result.getCode() == 200) {
if ("1".equals(result.getData().getStatus())) {
List<DemandTask> demandTaskList = result.getData().getDemandTaskList();
if (demandTaskList.size() > 0) {
String res = "向" + player.getPersonMap().get(player.getPersonId()).getName() + "询问,执行" + methodId + "(" + result.getData().getName() + ")操作,询问" + subject.getName() + "是否有" + task + "的任务," + "反馈结果为:" + result.getData().getText();
printLog(res, player);
saveTask(demandTaskList, player);
}
}
}
}
} else {
result = playerService.askTask(methodId, player, request);
if (result.getCode() == 200) {
if ("1".equals(result.getData().getStatus())) {
List<DemandTask> demandTaskList = result.getData().getDemandTaskList();
if (demandTaskList.size() > 0) {
String res = "向" + player.getPersonMap().get(player.getPersonId()).getName() + "询问,执行" + methodId + "(" + result.getData().getName() + ")操作,询问" + subject.getName() + "是否有可以提升或者降低信任度或者威慑度的任务," + "反馈结果为:" + result.getData().getText();
printLog(res, player);
saveTask(demandTaskList, player);
}
}
}
}
} else if ("1023".equals(methodId) || "1024".equals(methodId)) {
if ("1023".equals(methodId)) {
result = playerService.askIdentity(methodId, player, request);
if (result.getCode() == 200) {
if ("1".equals(result.getData().getStatus())) {
List<DemandTask> demandTaskList = result.getData().getDemandTaskList();
if (demandTaskList.size() > 0) {
String res = "向" + player.getPersonMap().get(player.getPersonId()).getName() + "询问,执行" + methodId + "(" + result.getData().getName() + ")操作,询问" + subject.getName() + "的身份," + "反馈结果为:" + result.getData().getText();
printLog(res, player);
saveTask(demandTaskList, player);
}
}
}
} else {
Set<String> identitys = new HashSet<>();
for (Person person : player.getPersonMap().values()) {
identitys.add(person.getIdentityName());
}
//String[] identitys = new String[]{"大夫", "酒馆掌柜", "店小二", "土匪", "流民", "混混", "老妇人", "美女", "杂货店掌柜", "赌徒"};
for (String identity : identitys) {
request.put("identityName", identity);
result = playerService.askIdentity(methodId, player, request);
if (result.getCode() == 200) {
if ("1".equals(result.getData().getStatus())) {
List<DemandTask> demandTaskList = result.getData().getDemandTaskList();
if (demandTaskList.size() > 0) {
String res = "向" + player.getPersonMap().get(player.getPersonId()).getName() + "询问,执行" + methodId + "(" + result.getData().getName() + ")操作,询问" + subject.getName() + "的身份是否为" + identity + "," + "反馈结果为:" + result.getData().getText();
printLog(res, player);
saveTask(demandTaskList, player);
}
}
}
}
}
} else if ("1025".equals(methodId) || "1026".equals(methodId)) {
if ("1025".equals(methodId)) {
result = playerService.askLocation(methodId, player, request);
if (result.getCode() == 200) {
if ("1".equals(result.getData().getStatus())) {
List<DemandTask> demandTaskList = result.getData().getDemandTaskList();
if (demandTaskList.size() > 0) {
String res = "向" + player.getPersonMap().get(player.getPersonId()).getName() + "询问,执行" + methodId + "(" + result.getData().getName() + ")操作,询问" + subject.getName() + "的位置," + "反馈结果为:" + result.getData().getText();
printLog(res, player);
saveTask(demandTaskList, player);
}
}
}
} else {
String[] locations = new String[]{"公司", "商场", "物业"};
//String[] locations = new String[]{"酒馆", "客栈", "民居", "广场", "小巷", "街道", "后山", "郊外", "赌场", "肉铺", "村舍", "民房", "私塾", "县衙", "青楼", "杂货店", "裁缝店", "县衙后院", "青楼门口", "寺庙"};
for (String location : locations) {
request.put("locationName", location);
result = playerService.askLocation(methodId, player, request);
if (result.getCode() == 200) {
if ("1".equals(result.getData().getStatus())) {
List<DemandTask> demandTaskList = result.getData().getDemandTaskList();
if (demandTaskList.size() > 0) {
String res = "向" + player.getPersonMap().get(player.getPersonId()).getName() + "询问,执行" + methodId + "(" + result.getData().getName() + ")操作,询问" + subject.getName() + "的位置是否在" + location + "," + "反馈结果为:" + result.getData().getText();
printLog(res, player);
saveTask(demandTaskList, player);
}
}
}
}
}
} else if ("1027".equals(methodId)) {
result = playerService.askPrompt(methodId, player, request);
if (result.getCode() == 200) {
if ("1".equals(result.getData().getStatus())) {
List<DemandTask> demandTaskList = result.getData().getDemandTaskList();
if (demandTaskList.size() > 0) {
String res = "向" + player.getPersonMap().get(player.getPersonId()).getName() + "询问,执行" + methodId + "(" + result.getData().getName() + ")操作,询问" + subject.getName() + "给个提示," + "反馈结果为:" + result.getData().getText();
printLog(res, player);
saveTask(demandTaskList, player);
}
}
}
}
}
private static void printLog(String line, Player player) {
list.add(line);
//set.add(line);
player.getLogList().add(line);
//System.out.println(line);
}
/**
* 设置前置任务的 postTaskStatus 为 1
*/
private static void setPostTaskStatus(DemandTask demandTask, Player player) {
Set<DemandTask> demandTaskSet = new HashSet<>();
for (Person person : player.getPersonMap().values()) {
demandTaskSet.addAll(person.getDemandTasks());
}
for (DemandTask temp : demandTaskSet) {
if (!StringUtils.isEmpty(temp.getPostTask()) && temp.getPostTask().contains(String.valueOf(demandTask.getDemandTaskId())) && demandTask.getSubject() == temp.getObject()) {
temp.setPostTaskStatus(1);
break;
}
}
}
/**
* 执行任务
*
* @param demandTask 任务
* @param player 玩家信息
*/
private static boolean performTask(DemandTask demandTask, Player player) throws Exception {
String[] condition1 = demandTask.getCondition1().split("\\|");
Person subject = player.getPersonMap().get(demandTask.getSubject());
String methodId = ConditionMethod.get(condition1[0]).getMethodId();
CommonResult<CommonData> result = playerService.performTask(demandTask, player);
if (result.getCode() == 200) {
if ("1".equals(result.getData().getStatus())) {
demandTask.setStatus(3);
setPostTaskStatus(demandTask, player);
String res = "执行" + methodId + "(" + result.getData().getName() + ")操作,向" + subject.getName() + "执行任务操作,反馈结果为:" + result.getData().getText();
printLog(res, player);
if (demandTask.getTaskLabel() == 3) {
endFlag = false;
System.out.println("------最终成功结果---------");
player.getFinalLogList().addAll(player.getAskLogList());
player.getFinalLogList().addAll(player.getLogList());
player.getFinalTaskList().add(demandTask);
for (int i = 0; i < player.getFinalLogList().size(); i++) {
System.out.println(player.getFinalLogList().get(i));
}
String filePath = FileUtil.getPath() + "file" + File.separator + "results_final.txt";
FileUtil.writeLog(player.getFinalLogList(), filePath);
String fileJsonPath = FileUtil.getPath() + "file" + File.separator + "results_final_task.json";
FastJsonUtil.createJsonFile(player.getFinalTaskList(), fileJsonPath);
System.out.println("------最终成功结果---------");
}
return true;
}
}
if(player.getStep()>steps){
endFlag = false;
System.out.println("------超过最大步数退出---------");
}
return false;
}
/**
* A*找最短路径
*
* @param startPlayer
*/
private static void aStar(Player startPlayer) throws Exception {
List<Player> queue = new ArrayList<>();
int index = 0;
queue.add(startPlayer);
startPlayer.setIndex(0);
while (index >= 0) {
Player currentPlayer = queue.get(index);
count++;
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SS");
// for (String val:currentPlayer.getFinalLogList()){
// System.out.println(val);
// }
DemandTask keyTask = currentPlayer.findKeyTask_();
// postTaskStatus 0 表示后置任务没有执行 1 表示后置任务已经执行
// clueProb 线索解锁的概率占比
// thresholdProb 任务解锁的概率占比
String playerStatus = "[" + keyTask.getPostTaskStatus() + "/" + keyTask.getClueProb() + "/" + keyTask.getThresholdProb() + "]";
//String playerStatus = "["+keyTask.getPostTaskStatus()+"/"+((double)Math.round(keyTask.getCluePro()*10000)/10000)+"/"+((double)Math.round(keyTask.getThresholdPro()*10000)/10000)+"]";
System.out.println("---" + count + "/" + queue.size() + playerStatus + currentPlayer.getScore() + "---" + currentPlayer.getPath() + "---" + sdf.format(date));
currentPlayer.getLogList().clear();
performAsk(currentPlayer);
currentPlayer.setAskLogList(ObjectUtil.cloneByStream(currentPlayer.getLogList()));
Object[] currentTaskList = currentPlayer.getDemandTaskQueue().toArray();
//根据评估排序
if (currentPlayer.getStep() < steps) {
for (int i = 0; i < currentTaskList.length; i++) {
Player player = ObjectUtil.cloneByStream(currentPlayer);
player.setStep(player.getStep() + 1);
Object[] taskList = player.getDemandTaskQueue().toArray();
DemandTask demandTask = (DemandTask) taskList[i];
player.getLogList().clear();
boolean flag = performTask(demandTask, player);
player.getFinalLogList().addAll(player.getAskLogList());
player.getFinalLogList().addAll(player.getLogList());
//System.out.println("任务["+i+"/"+currentTaskList.length+"]:"+demandTask.getName()+"|"+ flag);
//System.out.println("current:"+currentPlayer.getPath());
//System.out.println("thistep:"+player.getPath());
player.setIndex(queue.size());
player.aStarScore();
if (flag && player.getScore() > currentPlayer.getScore()) {
player.getFinalTaskList().add(demandTask);
minScore = player.getScore();
//finalLogList 写入文件
String filePath = FileUtil.getPath() + "file" + File.separator + "final_log" + File.separator + "final_log_" + player.getIndex() + ".txt";
FileUtil.writeLog(player.getFinalLogList(), filePath);
queue.add(player);
player.setPath(player.getPath() + "-" + player.getStep() + "[" + i + "/" + taskList.length + "/" + player.getIndex() + "/" + (double) Math.round(player.getScore() * 10000) / 10000 + "]");
player.setFather(index);
player.setPrevious(-1);
player.setNext(-1);
/*
if (player.getStep()>=steps){
player.setScore(0);
} else {
player.setScore(player.getScore()*(steps-player.getStep()));
}
*/
Player node = queue.get(index);
int next = node.getNext();
//System.out.println("next="+next);
if (next < 0) {
node.setNext(player.getIndex());
player.setPrevious(node.getIndex());
//System.out.println(node.getIndex()+"=>"+player.getIndex());
} else {
while (next >= 0) {
//System.out.println("next1="+next);
Player nextPlayer = queue.get(next);
if (player.getScore() > nextPlayer.getScore()) {
node.setNext(player.getIndex());
player.setPrevious(node.getIndex());
player.setNext(next);
nextPlayer.setPrevious(player.getIndex());
break;
}
node = nextPlayer;
next = node.getNext();
}
if (next < 0) {
node.setNext(player.getIndex());
player.setPrevious(node.getIndex());
}
}
//System.out.println("end task");
}
if (!endFlag) {
break;
}
//System.out.println("i="+i);
}
}
if (!endFlag) {
break;
}
index = currentPlayer.getNext();
//System.out.println("index="+index);
}
}
/**
* 保存任务
*
* @param demandTaskList 任务列表
* @param player 玩家
*/
private static void saveTask(List<DemandTask> demandTaskList, Player player) {
for (int i = 0; i < demandTaskList.size(); i++) {
DemandTask demandTask = demandTaskList.get(i);
if (!player.getDemandTaskHashSet().contains(demandTask)) {
demandTask.setStatus(2);
demandTask.setLockStatus(1);
//加入任务队列
player.getDemandTaskQueue().add(demandTask);
player.getDemandTaskHashSet().add(demandTask);
}
if (!StringUtils.isEmpty(demandTask.getPostTask())) {
findTasks(demandTask.getPostTask(), demandTask.getObject(), player);
}
}
}
}
package com.qiwu.inference.auto.enums;
import java.util.Arrays;
public enum ConditionMethod {
Task_Condition_1("70001", "2001","下达请喝酒的指令"),
Task_Condition_3("70003", "2999","<确认已完成后置任务>"),
Task_Condition_4("70004", "2002","向NPC打招呼"),
Task_Condition_5("70005", "2003","给钱买古董"),
Task_Condition_6("70006", "2004","给钱买东西(药)"),
Task_Condition_7("70007", "2005","确认获赠金疮药"),
Task_Condition_8("70008", "2006","确认揍了某人"),
Task_Condition_9("70009", "2007","请吃饭的指令"),
Task_Condition_10("70010", "2008","给好处费的指令"),
Task_Condition_11("70011", "2009","挑水指令"),
Task_Condition_12("70012", "2010","钓鱼指令"),
Task_Condition_13("70013", "2011","送货指令"),
Task_Condition_14("70014", "2012","给钱指令"),
Task_Condition_15("70015", "2013","请医生"),
Task_Condition_16("70016", "2014","给钱买茶具"),
Task_Condition_17("70017", "2015","花大价钱喝个痛快"),
Task_Condition_18("70018", "2016","花钱买回钗子"),
Task_Condition_19("70019", "2017","用暴力抢回钗子"),
Task_Condition_20("70020", "2018","追回私吞的款项"),
Task_Condition_21("70021", "2019","探听某人的身家"),
Task_Condition_22("70022", "2020","解救被绑女孩"),
Task_Condition_23("70023", "2021","审问罪犯供出老巢"),
Task_Condition_24("70024", "2022","交出藏宝图"),
Task_Condition_25("70025", "2023","抓捕人犯"),
Task_Condition_26("70026", "2024","购买犯人信息"),
Task_Condition_27("70027", "2025","购买物品完成"),
Task_Condition_28("70028", "2026","大夫出诊完成"),
Task_Condition_29("70029", "2027","寻回物品完成"),
Task_Condition_30("70030", "2028","打探肥羊完成"),
Task_Condition_31("70031", "2029","催账完成"),
Task_Condition_32("70032", "2030","催账"),
Task_Condition_33("70033", "2031","砸场子完成"),
Task_Condition_34("70034", "2032","砸场子"),
Task_Condition_35("70035", "2033","探听隐私完成"),
Task_Condition_36("70036", "2034","探听隐私"),
Task_Condition_37("70037", "2035","试药"),
Task_Condition_38("70038", "2036","证据账本完成"),
Task_Condition_39("70039", "2037","证据账本"),
Task_Condition_40("70040", "2038","证据账本类型2完成"),
Task_Condition_41("70041", "2039","栽赃陷害完成"),
Task_Condition_42("70042", "2040","栽赃陷害类型2完成"),
Task_Condition_43("70043", "2041","帮忙做事完成(通用)"),
Task_Condition_44("70044", "2042","求婚"),
Task_Condition_45("70045", "2043","赌场作弊"),
Task_Condition_46("70046", "2044","展示信物"),
Task_Condition_47("70047", "2045","救人"),
Task_Condition_48("71000", "2098","自动完成任务"),
Task_Condition_49("70501", "2051","谴责乱扔垃圾"),
Task_Condition_50("70502", "2052","谴责抽烟"),
Task_Condition_51("70503", "2053","谴责邋遢"),
Task_Condition_52("70504", "2054","谴责颜值"),
Task_Condition_53("70505", "2055","谴责骂人"),
Task_Condition_54("70506", "2056","谴责完成"),
Task_Condition_55("70507", "2057","打探"),
Task_Condition_56("70508", "2058","打探完成"),
Task_Condition_57("70509", "2059","质问打小报告"),
Task_Condition_58("70510", "2060","质问甩锅"),
Task_Condition_59("70511", "2061","质问完成"),
Task_Condition_60("70512", "2062","买高档耳机"),
Task_Condition_61("70513", "2063","买运动手环"),
Task_Condition_62("70514", "2064","买巧克力"),
Task_Condition_63("70515", "2065","买茶叶"),
Task_Condition_64("70516", "2066","买化妆品"),
Task_Condition_65("70517", "2067","买玩偶"),
Task_Condition_66("70518", "2068","买精致餐具"),
Task_Condition_67("70519", "2069","买感冒药"),
Task_Condition_68("70520", "2070","买红糖"),
Task_Condition_69("70521", "2071","买烟"),
Task_Condition_70("70522", "2072","购买礼品完成"),
Task_Condition_71("70523", "2073","恭维"),
Task_Condition_72("70524", "2074","把柄(偷窃)"),
Task_Condition_73("70525", "2075","把柄(打游戏)"),
Task_Condition_74("70526", "2076","把柄(做兼职)"),
Task_Condition_75("70527", "2077","把柄(泄密)"),
Task_Condition_76("70528", "2078","把柄(早退)"),
Task_Condition_77("70529", "2079","举报"),
Task_Condition_78("70530", "2080","澄清"),
Task_Condition_79("70531", "2081","找到间谍");
private final String id;
private final String methodId;
private final String description;
ConditionMethod(String id, String methodId, String description){
this.id =id;
this.methodId = methodId;
this.description = description;
}
public static ConditionMethod get(String id) {
return Arrays.stream(values())
.filter(r -> r.id.equals(id))
.findFirst().get();
}
public String getMethodId(){
return this.methodId;
}
public static void main(String[] args) {
System.out.println(ConditionMethod.get("70001").methodId);
}
}
package com.qiwu.inference.auto.enums;
import java.util.Arrays;
public enum LevelRange {
LEVEL_1(0, 10,-5),
LEVEL_2(11, 20,-4),
LEVEL_3(21, 30,-3),
LEVEL_4(31, 30,-2),
LEVEL_5(41, 45,-1),
LEVEL_6(46, 50,0),
LEVEL_7(51, 60,1),
LEVEL_8(61, 70,2),
LEVEL_9(71, 80,3),
LEVEL_10(81, 90,4),
LEVEL_11(91, 100,5);
private final int min;
private final int max;
private final int val;
private LevelRange(int min, int max, int val) {
this.min = min;
this.max = max;
this.val = val;
}
public String getRangeLevel() {
return String.format("%d,%d", min, max);
}
public static LevelRange get(int val) {
return Arrays.stream(values())
.filter(r -> val >= r.min && val <= r.max)
.findFirst()
.orElse(null);
}
public static void main(String[] args) {
System.out.println(LevelRange.get(90).val);
}
}
\ No newline at end of file
package com.qiwu.inference.auto.enums;
import java.util.Arrays;
public enum Operate {
/**
* 1001 askDisposition
* 请求参数:
* subjectName 人物编号 1
* type 性格类型 1、2、 3
* 返回数据:
* 符合阈值要求 反馈ID 反馈文本
* 100101 线索文本
* 不符合阈值要求 反馈ID 反馈文本
* 100102 “我又不认识你,为什么要告诉你?”
* 人物没有这条线索 反馈ID 反馈文本
* 100103 “不好意思,我不知道”
*/
OPERATE_1("1001", "询问A的性格","askDisposition"),
/**
* 1002 askDisposition
* 请求参数
* subjectName 人物名称 张三
* dispositionName 性格名称 随和
*
* 返回数据:
*
*/
OPERATE_2("1002", "询问A是否是某个性格","askDisposition"),
/**
* 1003 askRelation
* 请求参数
* subjectName A人物名称 张三
* objectName B人物名称 李四
*/
OPERATE_3("1003", "询问A和B是什么关系","askRelation"),
/**
* 1004 askRelation
* 请求参数
* subjectName A人物名称 张三
* objectName B人物名称 李四
* relationName 关系名称 面缘
*/
OPERATE_4("1004", "询问A和B是不是某个关系","askRelation"),
/**
* 1005 askRelation
* 请求参数
* subjectName 人物名称 张三
* relationName 关系名称 面缘
*/
OPERATE_5("1005", "询问和A有某个关系的人是谁","askRelation"),
/**
* 1006 askRelation
* 请求参数
* relationName 关系名称 面缘
*/
OPERATE_6("1006", "询问谁和谁有某个关系","askRelation"),
/**
* 1007 askBehaviour
* 请求参数
* subjectName 人物名称 张三
*/
OPERATE_7("1007", "询问A有过什么行为","askBehaviour"),
/**
* 1008 askBehaviour
* 请求参数
* subjectName A人物名称 张三
* objectName B人物名称 李四
*/
OPERATE_8("1008", "询问A和B有什么行为","askBehaviour"),
/**
* 1009 askBehaviour
* 请求参数
* subjectName 人物名称 张三 (可以为主体或者客体)
* behaviourName 行为名称 斗殴
*/
OPERATE_9("1009", "询问A和谁有了某个行为","askBehaviour"),
/**
* 1010 askBehaviour
* 请求参数
* subjectName 人物名称 张三 (可以为主体或者客体)
* behaviourName 行为名称 斗殴
*/
OPERATE_10("1010", "询问A有没有发生过某个行为","askBehaviour"),
/**
* 1011 askBehaviour
* 请求参数
* subjectName A人物名称 张三
* objectName B人物名称 李四
* behaviourName 行为名称 斗殴
*/
OPERATE_11("1011", "询问A和B有没有发生过某个行为","askBehaviour"),
OPERATE_12("1012", "询问A知道/看见了B和C的什么行为",""),
OPERATE_13("1013", "询问A有没有看到B和C发生了某个行为",""),
OPERATE_14("1014", "询问A知道什么行为事件",""),
/**
* 1015 askTask
* 请求参数
* subjectName 人物名称 张三
*/
OPERATE_15("1015", "询问A的提升信任度任务","askTask"),
/**
* 1016 askTask
* 请求参数
* subjectName 人物名称 张三
*/
OPERATE_16("1016", "询问A的提升威慑度任务","askTask"),
/**
* 1017 askTask
* 请求参数
* subjectName 人物名称 张三
* taskName 任务名称 打招呼
*/
OPERATE_17("1017", "询问A是否有某个提升信任度的任务","askTask"),
/**
* 1018 askTask
* 请求参数
* subjectName 人物名称 张三
* taskName 任务名称 打招呼
*/
OPERATE_18("1018", "询问A是否有某个提升威慑度的任务","askTask"),
/**
* 1019 askTask
* 请求参数
* subjectName 人物名称 张三
*/
OPERATE_19("1019", "询问A降低信任度的任务","askTask"),
/**
* 1020 askTask
* 请求参数
* subjectName 人物名称 张三
*/
OPERATE_20("1020", "询问A降低威慑度的任务","askTask"),
/**
* 1021 askTask
* 请求参数
* subjectName 人物名称 张三、
*/
OPERATE_21("1021", "询问A是否有某个降低信任度的任务","askTask"),
/**
* 1022 askTask
* 请求参数
* subjectName 人物名称 张三、
*/
OPERATE_22("1022", "询问A是否有某个降低威慑度的任务","askTask"),
/**
* 1023 askIdentity
* 请求参数
* subjectName 人物名称 张三
*/
OPERATE_23("1023", "询问A是什么身份","askIdentity"),
/**
* 1024 askIdentity
* 请求参数
* subjectName 人物名称 张三
* identityName 身份名称 张三
*/
OPERATE_24("1024", "询问A是不是某个身份","askIdentity"),
/**
* 1025 askLocation
* 请求参数
* subjectName 人物名称 张三
*/
OPERATE_25("1025", "询问A在哪个场所","askLocation"),
/**
* 1026 askLocation
* 请求参数
* subjectName 人物名称 张三
* locationName 场所名称 酒馆
*/
OPERATE_26("1026", "询问A是不是在某个场所","askLocation"),
/**
* 1027 askPrompt
* 请求参数
* subjectName 人物名称 张三
*/
OPERATE_27("1027", "询问提示","askPrompt"),
/**
* 2001 performTask
* 请求参数
* subjectName 人物名称 李四
* taskConditionId 任务条件ID 70001
*/
OPERATE_28("2001", "饮酒","performTask"),
/**
* 2002 performTask
* 请求参数
* subjectName 人物名称 李四
* taskConditionId 任务条件ID 70004
*/
OPERATE_29("2002", "打招呼","performTask"),
/**
* 2003 performTask
* 请求参数
* subjectName A人物名称 李四
* taskConditionId 任务条件ID 70004
*/
OPERATE_30("2003", "买古董","performTask"),
/**
* 2004 performTask
* 请求参数
* subjectName A人物名称 李四
* taskConditionId 任务条件ID 70005
*/
OPERATE_31("2004", "买药","performTask"),
/**
* 2005 performTask
* 请求参数
* subjectName 人物名称 李四
* taskConditionId 任务条件ID 70006
*/
OPERATE_32("2005", "获赠金疮药","performTask"),
/**
* 2006 performTask
* 请求参数
* subjectName 人物名称 李四
* taskConditionId 任务条件ID 70007
*/
OPERATE_33("2006", "揍人","performTask"),
/**
* 2007 performTask
* 请求参数
* subjectName 人物名称 李四
* taskConditionId 任务条件ID 70008
*/
OPERATE_34("2007", "请吃饭","performTask"),
/**
* 2008 performTask
* 请求参数
* subjectName 人物名称 李四
* taskConditionId 任务条件ID 70009
*/
OPERATE_35("2008", "好处费","performTask"),
/**
* 2009 performTask
* 请求参数
* subjectName A人物名称 李四
* taskConditionId 任务条件ID 70010
*/
OPERATE_36("2009", "帮挑水","performTask"),
/**
* 2010 performTask
* 请求参数
* subjectName A人物名称 李四
* taskConditionId 任务条件ID 70011
*/
OPERATE_37("2010", "一起钓鱼","performTask"),
/**
* 2011 performTask
* 请求参数
* subjectName A人物名称 李四
* taskConditionId 任务条件ID 70012
*/
OPERATE_38("2011", "送货","performTask"),
/**
* 2012 performTask
* 请求参数
* subjectName A人物名称 李四
* taskConditionId 任务条件ID 70013
*/
OPERATE_39("2012", "给钱","performTask"),
/**
* 2013 performTask
* 请求参数
* subjectName A人物名称 李四
* taskConditionId 任务条件ID 70014
*/
OPERATE_40("2013", "邀请医生","performTask"),
/**
* 2014 performTask
* 请求参数
* subjectName A人物名称 李四
* taskConditionId 任务条件ID 70015
*/
OPERATE_41("2014", "给钱买药","performTask"),
/**
* 2015 performTask
* 请求参数
* subjectName A人物名称 李四
* taskConditionId 任务条件ID 70016
*/
OPERATE_42("2015", "开怀畅饮","performTask"),
/**
* 2016 performTask
* 请求参数
* subjectName A人物名称 李四
* taskConditionId 任务条件ID 70017
*/
OPERATE_43("2016", "买回钗子","performTask"),
/**
* 2017 performTask
* 请求参数
* subjectName A人物名称 李四
* taskConditionId 任务条件ID 70018
*/
OPERATE_44("2017", "抢回钗子","performTask"),
/**
* 2018 performTask
* 请求参数
* subjectName A人物名称 李四
* taskConditionId 任务条件ID 70019
*/
OPERATE_45("2018", "追回私吞款项","performTask"),
/**
* 2019 performTask
* 请求参数
* subjectName 人物名称 李四
* taskConditionId 任务条件ID 70020
*/
OPERATE_46("2019", "探听身家","performTask"),
/**
* 2999 performTask
* 请求参数
* subjectName 人物名称 李四
* taskConditionId 任务条件ID 70003
*/
OPERATE_47("2999", "触发后置任务","performTask");
private final String id;
private final String operateName;
private final String operate;
private Operate(String id,String operateName,String operate){
this.id =id;
this.operateName = operateName;
this.operate = operate;
}
public static Operate get(String id) {
return Arrays.stream(values())
.filter(r -> r.id.equals(id))
.findFirst().get();
}
public static void main(String[] args) {
System.out.println(Operate.get("1002").operate);
}
}
package com.qiwu.inference.auto.enums;
import java.util.Arrays;
public enum TaskCondition {
Task_Condition_1("70001", "饮酒","下达请喝酒的指令"),
Task_Condition_2("70002", "买药(备用)","下达买药指令并完成"),
Task_Condition_3("70003", "后置任务","<确认已完成后置任务>"),
Task_Condition_4("70004", "打招呼","向NPC打招呼"),
Task_Condition_5("70005", "买古董","给钱买古董"),
Task_Condition_6("70006", "给钱买药","给钱买东西(药)"),
Task_Condition_7("70007", "获赠金疮药","确认获赠金疮药"),
Task_Condition_8("70008", "揍人","确认揍了某人"),
Task_Condition_9("70009", "请吃饭","请吃饭的指令"),
Task_Condition_10("70010", "好处费","给好处费的指令"),
Task_Condition_11("70011", "帮挑水","挑水指令"),
Task_Condition_12("70012", "一起钓鱼","钓鱼指令"),
Task_Condition_13("70013", "送货","送货指令"),
Task_Condition_14("70014", "给钱","给钱指令"),
Task_Condition_15("70015", "邀请医生","请医生"),
Task_Condition_16("70016", "给钱买茶具","给钱买茶具"),
Task_Condition_17("70017", "开怀畅饮","花大价钱喝个痛快"),
Task_Condition_18("70018", "买回钗子","花钱买回钗子"),
Task_Condition_19("70019", "抢回钗子","用暴力抢回钗子"),
Task_Condition_20("70020", "追回私吞款项","追回私吞的款项"),
Task_Condition_21("70021", "探听身家","探听某人的身家");
private final String id;
private final String taskName;
private final String description;
private TaskCondition(String id, String taskName, String description){
this.id =id;
this.taskName = taskName;
this.description = description;
}
public static TaskCondition get(String taskName) {
return Arrays.stream(values())
.filter(r -> r.taskName.equals(taskName))
.findFirst().get();
}
public static void main(String[] args) {
System.out.println(TaskCondition.get("买药(备用)").id);
}
}
package com.qiwu.inference.auto.enums;
import java.util.Arrays;
public enum TaskMethod {
TASK_METHOD_1("2001", "饮酒","下达请喝酒的指令"),
TASK_METHOD_4("2002", "打招呼","向NPC打招呼"),
TASK_METHOD_5("2003", "买古董","给钱买古董"),
TASK_METHOD_6("2004", "买药","给钱买东西(药)"),
TASK_METHOD_7("2005", "获赠金疮药","确认获赠金疮药"),
TASK_METHOD_8("2006", "揍人","确认揍了某人"),
TASK_METHOD_9("2007", "请吃饭","请吃饭的指令"),
TASK_METHOD_10("2008", "好处费","给好处费的指令"),
TASK_METHOD_11("2009", "帮挑水","挑水指令"),
TASK_METHOD_12("2010", "一起钓鱼","钓鱼指令"),
TASK_METHOD_13("2011", "送货","送货指令"),
TASK_METHOD_14("2012", "给钱","给钱指令"),
TASK_METHOD_15("2013", "邀请医生","请医生"),
TASK_METHOD_16("2014", "给钱买茶具","给钱买茶具"),
TASK_METHOD_17("2015", "开怀畅饮","花大价钱喝个痛快"),
TASK_METHOD_18("2016", "买回钗子","花钱买回钗子"),
TASK_METHOD_19("2017", "抢回钗子","用暴力抢回钗子"),
TASK_METHOD_20("2018", "追回私吞款项","追回私吞的款项"),
TASK_METHOD_21("2019", "探听身家","探听某人的身家");
private final String id;
private final String taskName;
private final String description;
private TaskMethod(String id, String taskName, String description){
this.id =id;
this.taskName = taskName;
this.description = description;
}
public String getId(){
return this.id;
}
public static TaskMethod get(String taskName) {
return Arrays.stream(values())
.filter(r -> r.taskName.equals(taskName))
.findFirst().get();
}
public static void main(String[] args) {
System.out.println(TaskMethod.get("买药(备用)").id);
}
}
package com.qiwu.inference.auto.pojo;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
@Getter
@Setter
public class Behaviour implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
private Integer id;
/**
* 行为名称
*/
private String name;
/**
* 行为id
*/
private int behaviourId;
/**
* 行为描述
*/
private String description;
/**
* 主体
*/
private int subject;
/**
* 主体名称
*/
private String subjectName;
/**
* 客体
*/
private int object;
/**
* 客体名称
*/
private String objectName;
}
package com.qiwu.inference.auto.pojo;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.util.Objects;
@Getter
@Setter
public class Clue implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
private Integer id;
/**
* 线索id
*/
private int clueId;
/**
* 线索名称
*/
private String clueName;
/**
* 主体
*/
private int subject;
/**
* 客体
*/
private int object;
/**
* 描述
*/
private String description;
/**
* 类型: 1:身份 2:场所 3:性格爱好 4:行为 5:关系 6:任务 9: 关键线索
*/
private int type;
/**
* 信息级别
*/
private int infoLevel;
/**
* 关联人物
*/
private int associatedPerson;
/**
* 线索模板
*/
private String clueTemplate;
/**
* 信任度
*/
private int trustDegree=100;
/**
* 威胁度
*/
private int deterrenceDegree=100;
/**
* 1 表示不满足阈值条件 2表示满足阈值 3表示可以解锁任务
*/
private int status=1;
//private DemandTask demandTask;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Clue clue = (Clue) o;
return Objects.equals(id, clue.id) && clueId == clue.clueId && subject == clue.subject && clueName.equals(clue.clueName);
}
@Override
public int hashCode() {
return Objects.hash(id, clueId, clueName, subject);
}
}
package com.qiwu.inference.auto.pojo;
import cn.hutool.core.clone.CloneSupport;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.util.Objects;
@Getter
@Setter
public class DemandTask extends CloneSupport<DemandTask> implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
private Integer id;
/**
* demandTaskId
*/
private int demandTaskId;
/**
* 名称
*/
private String name;
/**
* 任务组
*/
private int taskGroup;
/**
* 描述
*/
private String description;
/**
* 主体
*/
private int subject;
/**
* 客体
*/
private int object;
/**
* 开启条件信任度的开始
*/
private int trustStart=100;
/**
* 开启条件信任度的结束
*/
private int trustEnd=100;
/**
* 开启条件威胁度的开始
*/
private int deterrenceStart=100;
/**
* 开启条件威胁度的结束
*/
private int deterrenceEnd=100;
/**
* 后置任务
*/
private String postTask;
/**
* 条件1|次数
*/
private String condition1;
/**
* 条件2|次数
*/
private String condition2;
/**
* 信任度增减
*/
private int trustDegree;
/**
* 威慑度增减
*/
private int deterrenceDegree;
/**
* 完成奖励
*/
private String completionReward;
/**
* 声望增减
*/
private int reputation;
/**
* 有效次数
*/
private int effectiveDegree;
/**
* 类型: 1:身份 2:场所 3:性格爱好 4:行为 5:关系 6:任务 9:关键线索
*/
private int type;
/**
* 线索id
*/
private int clueId;
/**
* 信息级别
*/
private int infoLevel;
/**
* 任务标签 1普通任务 2关键任务 3 目标任务
*/
private int taskLabel;
/**
* 线索开关 0 代表不需要线索就可执行,1 代表需要线索才能执行此任务
*/
private int clueSwitch;
/**
* 自动触发
*/
private int isAuto;
/**
* 1 表示没有解锁 2 表示解锁了未执行 3 表示满足阈值已经执行
*/
private int status=1;
/**
* 0 表示未解锁 1 表示已经解锁
*/
private int lockStatus=0;
/**
* 线索解锁的概率占比
*/
private double clueProb=0.0;
/**
* 0 表示不满足阈值 1 表示满足阈值
*/
private int thresholdStatus=0;
/**
* 任务解锁的概率占比
*/
private double thresholdProb=0.0;
/**
* 0 表示后置任务没有执行 1 表示后置任务已经执行
*/
private int postTaskStatus=0;
//private Clue clue;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
DemandTask demandTask = (DemandTask) o;
return Objects.equals(id, demandTask.id) && demandTaskId == demandTask.demandTaskId && subject == demandTask.subject && type == demandTask.type && clueId == demandTask.clueId && name.equals(demandTask.name);
}
@Override
public int hashCode() {
return Objects.hash(id, demandTaskId, name, subject, type, clueId);
}
}
package com.qiwu.inference.auto.pojo;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
@Getter
@Setter
public class Disposition implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
private Integer id;
/**
* 性格id
*/
private int dispositionId;
/**
* 人物id
*/
private int subject;
/**
* 性格名称
*/
private String name;
/**
* 性格描述
*/
private String description;
/**
* 类型
*/
private String type;
}
package com.qiwu.inference.auto.pojo;
import cn.hutool.core.clone.CloneSupport;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@Getter
@Setter
public class Person extends CloneSupport<Person> implements Serializable {
/**
* 人物编号
*/
private Integer id;
/**
* 人物名称
*/
private String name;
/**
* 身份id
*/
private int identityId;
/**
* 身份名称
*/
private String identityName;
/**
* 年龄
*/
private int age;
/**
* 是否为关键人物 1 关键人物 2 普通人物
*/
private int isKey;
/**
* 性别
*/
private int gender;
/**
* 所在地
*/
private int location;
/**
* 人物拥有的性格
*/
private List<Disposition> dispositions;
/**
* 人物拥有的关系
*/
private List<Relation> relations;
/**
* 人物拥有的行为
*/
private List<Behaviour> behaviours;
/**
* 人物掌握的线索集合
*/
private List<Clue> clues;
/**
* 人物的需求任务集合
*/
private List<DemandTask> demandTasks;
/**
* 信任度
*/
private int trustDegree = 50;
/**
* 威胁
*/
private int deterrenceDegree = 50;
/**
* 他指向的点的集合
*/
private ArrayList<Person> nexts = new ArrayList<>();
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Person person = (Person) o;
return Objects.equals(id, person.id) && name.equals(person.name) && identityId==person.identityId && identityName.equals(person.identityName) && age==person.age && isKey==(person.isKey) && gender==person.gender && location==person.location;
}
@Override
public int hashCode() {
return Objects.hash(id, name, identityId, identityName, age, isKey, gender, location);
}
}
package com.qiwu.inference.auto.pojo;
import cn.hutool.core.clone.CloneSupport;
import com.qiwu.inference.util.FastJsonUtil;
import com.qiwu.inference.util.FileUtil;
import com.qiwu.inference.util.RandomUtil;
import lombok.Getter;
import lombok.Setter;
import org.springframework.util.StringUtils;
import java.io.*;
import java.util.*;
@Getter
@Setter
public class Player extends CloneSupport<Player> implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 关卡编号
*/
private String gateNo;
/**
* 保存所有人物
*/
Map<Integer,Person> personMap = new HashMap<>();
Map<Integer,Map<Integer, List<Integer>>> relationsMap = new HashMap<>();
Map<String,Integer> name2IdMap = new HashMap<>();
Queue<DemandTask> demandTaskQueue = new LinkedList<>();
HashSet<DemandTask> demandTaskHashSet = new HashSet<>();
private List<String> logList = new ArrayList<>();
private List<String> askLogList = new ArrayList<>();
private List<String> finalLogList = new ArrayList<>();
private List<String> treeLogList = new ArrayList<>();
private List<DemandTask> finalTaskList = new ArrayList<>();
/**
* 玩家当前对话的人物
*/
private Integer personId;
/**
* 货币
*/
private double currency = 1000.0;
private Map<Integer,Map<Integer,Integer>> taskMap = new HashMap<>();
private int index = -1;
private int next = -1;
private int previous = -1;
private int father = -1;
private double score = 0;
private String path="";
private int step = 0;
/**
* 初始人物的阈值
*/
Map<Integer,List<Integer>> initMap = new HashMap<>();
public Player(){
String filePath = FileUtil.getPath() + "file" + File.separator +"results.json";
String jsonStr=readJson(filePath);
Map<String,String> map = FastJsonUtil.parseJSON2Map(jsonStr);
List<String> keys = new ArrayList(map.keySet());
int index = RandomUtil.randomInt(keys.size());
String personListStr = map.get(keys.get(index));
this.setGateNo(keys.get(index));
List<Person> personList = FastJsonUtil.json2List(personListStr, Person.class);
assert personList != null;
for (Person person:personList){
this.getPersonMap().put(person.getId(),person);
List<Integer> temp = new ArrayList<>();
temp.add(person.getTrustDegree());
temp.add(person.getDeterrenceDegree());
this.initMap.put(person.getId(),temp);
this.getName2IdMap().put(person.getName(),person.getId());
this.getTaskMap().put(person.getId(),new HashMap<>());
}
for(Person person:this.getPersonMap().values()){
for (Relation relation:person.getRelations()){
if(this.getRelationsMap().containsKey(relation.getSubject())){
Map<Integer, List<Integer>> relationsMap=this.getRelationsMap().get(relation.getSubject());
if(relationsMap.containsKey(relation.getRelationId())){
List<Integer> list = relationsMap.get(relation.getRelationId());
list.add(relation.getObject());
relationsMap.put(relation.getRelationId(),list);
}else{
List<Integer> list = new ArrayList<>();
list.add(relation.getObject());
relationsMap.put(relation.getRelationId(),list);
}
this.getRelationsMap().put(relation.getSubject(),relationsMap);
}else{
Map<Integer, List<Integer>> relationsMap = new HashMap<>();
List<Integer> list = new ArrayList<>();
list.add(relation.getObject());
relationsMap.put(relation.getRelationId(),list);
this.getRelationsMap().put(relation.getSubject(),relationsMap);
}
if(!Objects.equals(person.getId(), relation.getObject())){
if(!person.getNexts().contains(this.getPersonMap().get(relation.getObject()))){
person.getNexts().add(this.getPersonMap().get(relation.getObject()));
}
}
}
//线索查找相关的任务
// for (Clue clue :person.getClues()){
// DemandTask demandTask = findTask(person.getDemandTasks(),clue);
// if(!StringUtils.isEmpty(demandTask)){
// clue.setDemandTask(demandTask);
// }
// }
//任务查找相关的线索
// for (DemandTask demandTask :person.getDemandTasks()){
// Clue clue = findClue(person.getClues(),demandTask);
// if(!StringUtils.isEmpty(clue)){
// demandTask.setClue(clue);
// }
// }
}
}
/**
* 根据任务查询符合条件的线索
*/
private Clue findClue(List<Clue> clueList,DemandTask demandTask){
for (Clue clue : clueList) {
if (clue.getType() == demandTask.getType() && clue.getClueId() == demandTask.getClueId() && clue.getSubject() == demandTask.getSubject()) {
return clue;
}
}
return null;
}
/**
* 根据线索查询符合条件的任务
* @param demandTaskList 任务列表
* @param clue 线索
* @return 任务
*/
private DemandTask findTask(List<DemandTask> demandTaskList ,Clue clue){
DemandTask result = null;
for (DemandTask demandTask : demandTaskList) {
if (demandTask.getClueId() == clue.getClueId() && demandTask.getType() == clue.getType()) {
result = demandTask;
break;
}
}
if(!StringUtils.isEmpty(result)){
for (DemandTask demandTask:demandTaskList){
if(demandTask.getDemandTaskId()==result.getDemandTaskId()&&demandTask.getType()==6&&result.getSubject()==demandTask.getSubject()){
return demandTask;
}
}
}
return null;
}
public double aStarScore() throws Exception{
score = 0;
List<DemandTask> demandTaskSet = new ArrayList<>();
int depth=1;
DemandTask demandTask = this.findKeyTask_();
demandTaskSet.add(demandTask);
// if (demandTask.getStatus()==3){
// //System.out.print("*");
// }
//System.out.println(demandTask.getName()+"("+getPersonMap().get(demandTask.getSubject()).getName()+")"+"="+1+"/"+this.score);
//计算每个任务和每条线索的概率
getTaskAndCluePro();
//Tree 结构写入文件 之前的文件内容要清空
String filePath = FileUtil.getPath() + "file" + File.separator+"tree_log"+File.separator+"tree_log_"+this.getIndex()+".txt";
treeLogList.clear();
this.dfs(demandTask,demandTaskSet,depth,1);
if(treeLogList.size()>0){
FileUtil.writeLog(treeLogList,filePath);
}
/*
if (this.getStep()>= DFS.steps){
this.setScore(0);
} else {
this.setScore(this.getScore()*(DFS.steps-this.getStep())/DFS.steps);
}
*/
return score;
}
public void getTaskAndCluePro(){
Set<DemandTask> demandTaskSet = new HashSet<>();
for (Person person:this.personMap.values()){
demandTaskSet.addAll(person.getDemandTasks());
}
double temp= 0.0;
for (DemandTask demandTask:demandTaskSet){
if(demandTask.getType()==6){
//查询任务对应的线索
Set<Clue> clueSet=this.findClue(demandTask);
double cluePro = 0.0;
for (Clue clue:clueSet){
//查询线索相关的人物
List<Person> personList=this.getPerson(clue);
for (Person person:personList){
int initTrustDegree=this.getInitMap().get(person.getId()).get(0);
int initDeterrenceDegree=this.getInitMap().get(person.getId()).get(1);
double tempTrustDegreeProb=0.0;
if((clue.getTrustDegree()-initTrustDegree) > 0){
tempTrustDegreeProb=(double)(person.getTrustDegree()-initTrustDegree)/(double)(clue.getTrustDegree()-initTrustDegree);
}else if(person.getTrustDegree()>=clue.getTrustDegree()){
tempTrustDegreeProb=1.0;
}
double tempDeterrenceDegreeProb=0.0;
if((clue.getDeterrenceDegree()-initDeterrenceDegree) > 0){
tempDeterrenceDegreeProb=(double)(person.getDeterrenceDegree()-initDeterrenceDegree)/(double)(clue.getDeterrenceDegree()-initDeterrenceDegree);
}else if(person.getDeterrenceDegree()>=clue.getDeterrenceDegree()){
tempDeterrenceDegreeProb=1.0;
}
temp=Math.max(tempTrustDegreeProb,tempDeterrenceDegreeProb);
cluePro = Math.max(cluePro,temp);
}
}
cluePro = Math.min(cluePro, 1.0);
demandTask.setClueProb(cluePro);
Person person = this.getPersonMap().get(demandTask.getSubject());
if(demandTask.getTrustStart()<= person.getTrustDegree()||demandTask.getDeterrenceStart()<=person.getDeterrenceDegree()){
demandTask.setThresholdStatus(1);
}
int initTrustDegree=this.getInitMap().get(person.getId()).get(0);
int initDeterrenceDegree=this.getInitMap().get(person.getId()).get(1);
double tempTrustDegreeProb=0.0;
if (demandTask.getTrustStart()>=100){
} else if((demandTask.getTrustStart()-initTrustDegree) > 0){
tempTrustDegreeProb=(double)(person.getTrustDegree()-initTrustDegree)/(double)(demandTask.getTrustStart()-initTrustDegree);
} else if (person.getTrustDegree()>=demandTask.getTrustStart()){
tempTrustDegreeProb = 1.0;
}
double tempDeterrenceDegreeProb=0.0;
if (demandTask.getDeterrenceStart()>=100){
} else if((demandTask.getDeterrenceStart()-initDeterrenceDegree) > 0){
tempDeterrenceDegreeProb=(double)(person.getDeterrenceDegree()-initDeterrenceDegree)/(double)(demandTask.getDeterrenceStart()-initDeterrenceDegree);
} else if (person.getDeterrenceDegree()>=demandTask.getDeterrenceStart()){
tempDeterrenceDegreeProb = 1.0;
}
temp = Math.max(tempTrustDegreeProb,tempDeterrenceDegreeProb);
demandTask.setThresholdProb(Math.min(temp, 1.0));
}
}
}
/**
* 查找关键任务
* @return 任务
*/
public DemandTask findKeyTask_(){
Set<DemandTask> demandTaskSet = new HashSet<>();
for (Person person:this.personMap.values()){
demandTaskSet.addAll(person.getDemandTasks());
}
Object[] demandTasks = demandTaskSet.toArray();
for (Object task : demandTasks) {
DemandTask demandTask = (DemandTask) task;
if (demandTask.getTaskLabel() == 3 && demandTask.getType() == 6) {//关键任务
return demandTask;
}
}
return null;
}
/**
* 查找后置任务
* @return 任务
*/
public DemandTask findPostTask(DemandTask demandTask){
Set<DemandTask> demandTaskSet = new HashSet<>();
for (Person person:this.personMap.values()){
if(demandTask.getType()==6){
demandTaskSet.addAll(person.getDemandTasks());
}
}
Object[] demandTasks = demandTaskSet.toArray();
for (Object task : demandTasks) {
DemandTask temp = (DemandTask) task;
String[] postTasks = demandTask.getPostTask().split("\\|");
for (String postTask : postTasks) {
if (temp.getDemandTaskId() == Integer.parseInt(postTask) && temp.getSubject() == demandTask.getObject()) {
return temp;
}
}
}
return null;
}
/**
* 查询任务对应的线索
* @param demandTask
* @return
*/
public Set<Clue> findClue(DemandTask demandTask){
Set<Clue> clueSet = new HashSet<>();
for (Person person:personMap.values()){
if(person.getId()!=demandTask.getSubject()){
for (Clue clue:person.getClues()){
if(clue.getClueId()==demandTask.getClueId()){
clueSet.add(clue);
}
}
}
}
return clueSet;
}
public void dfs(DemandTask root,List<DemandTask> demandTaskSet,int depth,double weight) throws Exception{
if(root==null){
//System.out.println("深度优先回溯");
return;
}
if (root.getStatus()==3){
this.score+=weight;
return;
}
// if(root.getLockStatus()==1&&root.getThresholdStatus()==1&&root.getPostTaskStatus()==1&&weight==1){
// //System.out.print("");
// }
if(demandTaskSet.contains(root)){
//demandTaskSet.add(root);
//查询关键任务相对应的线索
// for (Clue clue:findClue(root)){
//// if(!clueSet.contains(clue)){
//// clueSet.add(clue);
//// }
// }
List<DemandTask> demandTaskNextSet = new ArrayList<DemandTask>();
demandTaskNextSet.addAll(demandTaskSet);
double taskWeight = 0;
//查询可以提升自己阈值的任务
Person person = personMap.get(root.getSubject());
List<DemandTask> demandTaskBaseList = person.getDemandTasks();
List<DemandTask> demandTaskList = new ArrayList<>();
if (root.getThresholdStatus()==0){
taskWeight+=0.3*(1-root.getThresholdProb());
this.score+=weight*0.3*root.getThresholdProb();
for (DemandTask demandTask:demandTaskBaseList){
if (demandTask.getType()==6&&!demandTaskNextSet.contains(demandTask)){
if ((demandTask.getTrustStart()<root.getTrustStart())||(demandTask.getDeterrenceStart()<root.getDeterrenceStart())){
demandTaskList.add(demandTask);
}
}
}
} else {
this.score+=weight*0.3;
}
if (root.getLockStatus()==0){
taskWeight += 0.3*(1-root.getClueProb());
this.score+=weight*0.3*root.getClueProb();
for (Clue clue:findClue(root)){
List<Person> relatedPersons=getPerson(clue);
for (Person relatedPerson:relatedPersons){
List<DemandTask> relatedTaskBaseList = relatedPerson.getDemandTasks();
// List<DemandTask> relatedTaskList = new ArrayList<DemandTask>();
for (DemandTask relatedTask:relatedTaskBaseList){
if (relatedTask.getType()==6&&!demandTaskNextSet.contains(relatedTask)){
if ((relatedTask.getTrustStart()<clue.getTrustDegree())||(relatedTask.getDeterrenceStart()<clue.getDeterrenceDegree())){
demandTaskList.add(relatedTask);
}
}
}
}
}
} else {
this.score+=weight*0.3;
}
demandTaskNextSet.addAll(demandTaskList);
//判断是否有后置任务
if(!StringUtils.isEmpty(root.getPostTask())){
DemandTask postTask= findPostTask(root);
if (root.getPostTaskStatus()==1){
this.score+=weight*0.3;
} else {
if(!demandTaskSet.contains(postTask)&&postTask!=null){
if (!demandTaskNextSet.contains(postTask)){
demandTaskNextSet.add(postTask);
}
if(!Objects.equals(postTask.getId(), root.getId())){
if(root.getTrustDegree()>0||root.getDeterrenceDegree()>0){
String temp="";
for (int j=0;j<depth;j++){
temp+=" ";
//System.out.print(" ");
}
if (postTask.getStatus()==3){
//System.out.print("*");
temp+="*";
}
temp+= postTask.getName()+"("+getPersonMap().get(postTask.getSubject()).getName()+")"+"="+(weight*0.3)+"/"+this.score;
treeLogList.add(temp);
//System.out.println(temp);
dfs(postTask,demandTaskNextSet,depth+1,weight*0.3);
//System.out.println(demandTask);
}
}
}
}
}
double nextWeight = weight*taskWeight;
if (!demandTaskNextSet.isEmpty()){
nextWeight = nextWeight/demandTaskNextSet.size();
}
for (DemandTask demandTask:demandTaskList){
if(!demandTaskSet.contains(demandTask)){
if(!Objects.equals(demandTask.getId(), root.getId())){
if(root.getTrustDegree()>0||root.getDeterrenceDegree()>0){
String temp="";
for (int j=0;j<depth;j++){
temp+=" ";
//System.out.print(" ");
}
if (demandTask.getStatus()==3){
//System.out.print("*");
temp+="*";
}
temp+=demandTask.getName()+"("+getPersonMap().get(demandTask.getSubject()).getName()+")"+"="+nextWeight+"/"+this.score;
//System.out.println(temp);
treeLogList.add(temp);
dfs(demandTask,demandTaskNextSet,depth+1,nextWeight);
//System.out.println(demandTask);
}
}
}
}
}
// if(root.getLockStatus()==1&&root.getThresholdStatus()==1&&root.getPostTaskStatus()==1&&weight==1){
// //System.out.print("");
// }
}
/**
* 查找线索相关的人
* @param clue
* @return
*/
public List<Person> getPerson(Clue clue){
List<Person> personList = new ArrayList<>();
for(Integer key:personMap.keySet()){
if(clue.getSubject()!=key){
Person person = personMap.get(key);
for(Clue c:person.getClues()){
if(c.equals(clue)){
personList.add(person);
}
}
}
}
return personList;
}
/**
* 读取json文件数据
* @param jsonPath json文件路径
* @return 字符串
*/
private static String readJson(String jsonPath) {
File jsonFile = new File(jsonPath);
try {
FileReader fileReader = new FileReader(jsonFile);
BufferedReader reader = new BufferedReader(fileReader);
StringBuilder sb = new StringBuilder();
while (true) {
int ch = reader.read();
if (ch != -1) {
sb.append((char) ch);
} else {
break;
}
}
fileReader.close();
reader.close();
return sb.toString();
} catch (IOException e) {
return "";
}
}
}
package com.qiwu.inference.auto.pojo;
import cn.hutool.core.clone.CloneSupport;
import com.qiwu.inference.util.FastJsonUtil;
import com.qiwu.inference.util.FileUtil;
import com.qiwu.inference.util.RandomUtil;
import lombok.Getter;
import lombok.Setter;
import org.springframework.util.StringUtils;
import java.io.*;
import java.util.*;
@Getter
@Setter
public class Player_bak extends CloneSupport<Player_bak> implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 关卡编号
*/
private String gateNo;
/**
* 保存所有人物
*/
Map<Integer,Person> personMap = new HashMap<>();
Map<Integer,Map<Integer, List<Integer>>> relationsMap = new HashMap<>();
Map<String,Integer> name2IdMap = new HashMap<>();
Queue<DemandTask> demandTaskQueue = new LinkedList<>();
HashSet<DemandTask> demandTaskHashSet = new HashSet<>();
private List<String> logList = new ArrayList<>();
private List<String> askLogList = new ArrayList<>();
private List<String> finalLogList = new ArrayList<>();
/**
* 玩家当前对话的人物
*/
private Integer personId;
/**
* 货币
*/
private Double currency = 1000.0;
private Map<Integer,Map<Integer,Integer>> taskMap = new HashMap<>();
private int index = -1;
private int next = -1;
private int previous = -1;
private int father = -1;
private int score = 0;
private String path="";
private int step = 0;
/**
* 初始人物的阈值
*/
Map<Integer,List<Integer>> initMap = new HashMap<>();
public Player_bak(){
String filePath = FileUtil.getPath() + "file" + File.separator +"results.json";
String jsonStr=readJson(filePath);
Map<String,String> map = FastJsonUtil.parseJSON2Map(jsonStr);
List<String> keys = new ArrayList(map.keySet());
int index = RandomUtil.randomInt(keys.size());
String personListStr = map.get(keys.get(index));
this.setGateNo(keys.get(index));
List<Person> personList = FastJsonUtil.json2List(personListStr, Person.class);
for (Person person:personList){
this.getPersonMap().put(person.getId(),person);
List<Integer> temp = new ArrayList<>();
temp.add(person.getTrustDegree());
temp.add(person.getDeterrenceDegree());
this.initMap.put(person.getId(),temp);
this.getName2IdMap().put(person.getName(),person.getId());
this.getTaskMap().put(person.getId(),new HashMap<>());
}
for(Person person:this.getPersonMap().values()){
for (Relation relation:person.getRelations()){
if(this.getRelationsMap().containsKey(relation.getSubject())){
Map<Integer, List<Integer>> relationsMap=this.getRelationsMap().get(relation.getSubject());
if(relationsMap.containsKey(relation.getRelationId())){
List<Integer> list = relationsMap.get(relation.getRelationId());
list.add(relation.getObject());
relationsMap.put(relation.getRelationId(),list);
}else{
List<Integer> list = new ArrayList<>();
list.add(relation.getObject());
relationsMap.put(relation.getRelationId(),list);
}
this.getRelationsMap().put(relation.getSubject(),relationsMap);
}else{
Map<Integer, List<Integer>> relationsMap = new HashMap<>();
List<Integer> list = new ArrayList<>();
list.add(relation.getObject());
relationsMap.put(relation.getRelationId(),list);
this.getRelationsMap().put(relation.getSubject(),relationsMap);
}
if(!Objects.equals(person.getId(), relation.getObject())){
if(!person.getNexts().contains(this.getPersonMap().get(relation.getObject()))){
person.getNexts().add(this.getPersonMap().get(relation.getObject()));
}
}
}
}
}
/**
* A*评估函数
*/
public int aStarScore(){
score = 0;
//为每个人打分
Set<DemandTask> demandTasksSet = findKeyTask();
Map<Integer,Integer> weightMap = new HashMap<>();
getPersonScore(weightMap,65536,demandTasksSet);
//完成度
Map<Integer,Double> clueMap=getProb();
for (Integer key:weightMap.keySet()){
int characterScore =(int)(clueMap.get(key)*weightMap.get(key));
score+=characterScore;
//System.out.println("score["+personMap.get(key).getName()+"]=("+(clueMap.get(key))+")*"+weightMap.get(key)+"="+characterScore);
}
//System.out.println("score="+score);
if (score>=1024){
//System.out.println("---");
}
return score;
}
/**
* 查找关键任务
* @return
*/
public Set<DemandTask> findKeyTask(){
Set<DemandTask> result = new HashSet<>();
Set<DemandTask> demandTaskSet = new HashSet<>();
for (Person person:this.personMap.values()){
demandTaskSet.addAll(person.getDemandTasks());
}
Object[] demandTasks = demandTaskSet.toArray();
for (int i=0;i<demandTasks.length;i++){
DemandTask demandTask = (DemandTask) demandTasks[i];
if(demandTask.getTaskLabel()==3){//关键任务
if(StringUtils.isEmpty(demandTask.getPostTask())){
result.add(demandTask);
}else{
result.add(demandTask);
DemandTask res=findTask(demandTasks,demandTask.getDemandTaskId(),demandTask.getObject());
if(!StringUtils.isEmpty(res)){
result.add(res);
}
}
}
}
return result;
}
/**
* 查找关键任务
* @return
*/
public DemandTask findTask(Object[] demandTasks,int demandTaskId,int personId){
for (int i=0;i<demandTasks.length;i++){
DemandTask demandTask = (DemandTask) demandTasks[i];
if(demandTask.getDemandTaskId()==demandTaskId&&demandTask.getSubject()==personId){
return demandTask;
}
}
return null;
}
/**
* 对每个人物所拥有的关键线索和任务进行打分
* @return
*/
public Map<Integer,Double> getProb(){
Map<Integer,Double> result = new HashMap<>();
for (Integer key:personMap.keySet()){
Person person = personMap.get(key);
int trustDegreeNumerator =0;
int trustDegreeDenominator =0;
int deterrenceDegreeNumerator =0;
int deterrenceDegreeDenominator =0;
List<Clue> clueList = personMap.get(key).getClues();
for (Clue clue:clueList){
if(person.getTrustDegree()<=clue.getTrustDegree()){
trustDegreeNumerator+=person.getTrustDegree()-initMap.get(key).get(0);
}else
{
trustDegreeNumerator+=clue.getTrustDegree()-initMap.get(key).get(0);
}
if(person.getDeterrenceDegree()<=clue.getDeterrenceDegree()){
deterrenceDegreeNumerator+=person.getDeterrenceDegree()-initMap.get(key).get(1);
}else{
deterrenceDegreeNumerator+=clue.getDeterrenceDegree()-initMap.get(key).get(1);
}
trustDegreeDenominator+=clue.getTrustDegree()-initMap.get(key).get(0);
deterrenceDegreeDenominator+=clue.getDeterrenceDegree()-initMap.get(key).get(1);
}
List<DemandTask> demandTaskList = personMap.get(key).getDemandTasks();
for (DemandTask demandTask:demandTaskList){
if(demandTask.getTrustStart()>0){
if(person.getTrustDegree()<=demandTask.getTrustStart()){
trustDegreeNumerator+=person.getTrustDegree()-initMap.get(key).get(0);
}else{
trustDegreeNumerator+=demandTask.getTrustStart()-initMap.get(key).get(0);
}
trustDegreeDenominator+=demandTask.getTrustStart()-initMap.get(key).get(0);
}
if(demandTask.getDeterrenceStart()>0){
if(person.getTrustDegree()<=demandTask.getDeterrenceStart()){
deterrenceDegreeNumerator+=person.getTrustDegree()-initMap.get(key).get(0);
}else{
deterrenceDegreeNumerator+=demandTask.getDeterrenceStart()-initMap.get(key).get(1);
}
deterrenceDegreeNumerator+=demandTask.getDeterrenceStart()-initMap.get(key).get(1);
}
}
result.put(key,Math.max((double)trustDegreeNumerator/trustDegreeDenominator,(double)deterrenceDegreeNumerator/deterrenceDegreeDenominator));
}
return result;
}
/**
* 对每个人物进行打分
* @param weightMap
* @param weight
* @param demandTasksSet
* @return
*/
public void getPersonScore(Map<Integer,Integer> weightMap,int weight,Set<DemandTask> demandTasksSet){
if(weightMap.size()==personMap.size()){
// System.out.println("深度优先回溯");
return;
}
Set<DemandTask> demandTasks= new HashSet<>();
for (DemandTask demandTask:demandTasksSet){
if(!weightMap.containsKey(demandTask.getSubject())){
weightMap.put(demandTask.getSubject(),weight);
Person person = personMap.get(demandTask.getSubject());
demandTasks.addAll(person.getDemandTasks());
}
}
Set<DemandTask> result= new HashSet<>();
for (DemandTask demandTask:demandTasks){
for (Person person:personMap.values()){
if(person.getId()!=demandTask.getSubject()){
for(Clue clue:person.getClues()){
if(clue.getClueId()==demandTask.getClueId()){
result.addAll(person.getDemandTasks());
}
}
}
}
}
if(result.size()>0){
this.getPersonScore(weightMap,weight/8,result);
}
}
/**
* 读取json文件数据
* @param jsonPath json文件路径
* @return 字符串
*/
private static String readJson(String jsonPath) {
File jsonFile = new File(jsonPath);
try {
FileReader fileReader = new FileReader(jsonFile);
BufferedReader reader = new BufferedReader(fileReader);
StringBuilder sb = new StringBuilder();
while (true) {
int ch = reader.read();
if (ch != -1) {
sb.append((char) ch);
} else {
break;
}
}
fileReader.close();
reader.close();
return sb.toString();
} catch (IOException e) {
return "";
}
}
}
package com.qiwu.inference.auto.pojo;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
@Getter
@Setter
public class Relation implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
private Integer id;
/**
* 关系名称
*/
private String name;
/**
* 关系描述
*/
private String description;
/**
* 类型
*/
private int type;
/**
* 关系id
*/
private int relationId;
/**
* 关系的主体
*/
private int subject;
/**
* 主体名称
*/
private String subjectName;
/**
* 关系客体
*/
private int object;
/**
* 客体名称
*/
private String objectName;
/**
* 掌握信息级别
*/
private int masterInfoLevel;
}
This source diff could not be displayed because it is too large. You can view the blob instead.
package com.qiwu.inference.common.api;
import com.qiwu.inference.auto.pojo.Clue;
import com.qiwu.inference.auto.pojo.DemandTask;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
@Getter
@Setter
public class CommonData {
private Integer id;
private String name;
private Integer type;
private Integer subject;
private String status;
private String aside;
private String text;
private List<DemandTask> demandTaskList;
private List<Clue> clueList;
public CommonData(){
}
public CommonData(Integer id,String text,String aside){
this.id = id;
this.aside = aside;
this.text = text;
}
}
package com.qiwu.inference.common.api;
import cn.hutool.core.convert.Convert;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
/**
* 分页数据封装类
*/
@Getter
@Setter
public class CommonPage<T> {
private Integer pageNum;
private Integer pageSize;
private Integer totalPage;
private Long total;
private List<T> list;
/**
* 将MyBatis Plus 分页结果转化为通用结果
*/
public static <T> CommonPage<T> restPage(Page<T> pageResult) {
CommonPage<T> result = new CommonPage<>();
result.setPageNum(Convert.toInt(pageResult.getCurrent()));
result.setPageSize(Convert.toInt(pageResult.getSize()));
result.setTotal(pageResult.getTotal());
result.setTotalPage(Convert.toInt(pageResult.getTotal()/pageResult.getSize()+1));
result.setList(pageResult.getRecords());
return result;
}
}
package com.qiwu.inference.common.api;
import lombok.Getter;
import lombok.Setter;
/**
* 通用返回对象
*/
@Getter
@Setter
public class CommonResult<T> {
private long code;
private String message;
private T data;
protected CommonResult() {
}
protected CommonResult(long code, String message, T data) {
this.code = code;
this.message = message;
this.data = data;
}
/**
* 成功返回结果
*
* @param data 获取的数据
*/
public static <T> CommonResult<T> success(T data) {
return new CommonResult<T>(ResultCode.SUCCESS.getCode(), ResultCode.SUCCESS.getMessage(), data);
}
/**
* 成功返回结果
*
* @param data 获取的数据
* @param message 提示信息
*/
public static <T> CommonResult<T> success(T data, String message) {
return new CommonResult<T>(ResultCode.SUCCESS.getCode(), message, data);
}
/**
* 失败返回结果
* @param errorCode 错误码
*/
public static <T> CommonResult<T> failed(IErrorCode errorCode) {
return new CommonResult<T>(errorCode.getCode(), errorCode.getMessage(), null);
}
/**
* 失败返回结果
* @param errorCode 错误码
* @param message 错误信息
*/
public static <T> CommonResult<T> failed(IErrorCode errorCode,String message) {
return new CommonResult<T>(errorCode.getCode(), message, null);
}
/**
* 失败返回结果
* @param message 提示信息
*/
public static <T> CommonResult<T> failed(String message) {
return new CommonResult<T>(ResultCode.FAILED.getCode(), message, null);
}
/**
* 失败返回结果
*/
public static <T> CommonResult<T> failed() {
return failed(ResultCode.FAILED);
}
/**
* 参数验证失败返回结果
*/
public static <T> CommonResult<T> validateFailed() {
return failed(ResultCode.VALIDATE_FAILED);
}
/**
* 参数验证失败返回结果
* @param message 提示信息
*/
public static <T> CommonResult<T> validateFailed(String message) {
return new CommonResult<T>(ResultCode.VALIDATE_FAILED.getCode(), message, null);
}
/**
* 未登录返回结果
*/
public static <T> CommonResult<T> unauthorized(T data) {
return new CommonResult<T>(ResultCode.UNAUTHORIZED.getCode(), ResultCode.UNAUTHORIZED.getMessage(), data);
}
/**
* 未授权返回结果
*/
public static <T> CommonResult<T> forbidden(T data) {
return new CommonResult<T>(ResultCode.FORBIDDEN.getCode(), ResultCode.FORBIDDEN.getMessage(), data);
}
}
package com.qiwu.inference.common.api;
/**
* 封装API的错误码
*/
public interface IErrorCode {
long getCode();
String getMessage();
}
package com.qiwu.inference.common.api;
/**
* 枚举了一些常用API操作码
*/
public enum ResultCode implements IErrorCode {
SUCCESS(200, "操作成功"),
FAILED(500, "操作失败"),
VALIDATE_FAILED(404, "参数检验失败"),
UNAUTHORIZED(401, "暂未登录或token已经过期"),
FORBIDDEN(403, "没有相关权限");
private long code;
private String message;
private ResultCode(long code, String message) {
this.code = code;
this.message = message;
}
public long getCode() {
return code;
}
public String getMessage() {
return message;
}
}
package com.qiwu.inference.common.config;
import com.qiwu.inference.common.domain.SwaggerProperties;
import org.springframework.context.annotation.Bean;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.*;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spi.service.contexts.SecurityContext;
import springfox.documentation.spring.web.plugins.Docket;
import java.util.ArrayList;
import java.util.List;
/**
* Swagger基础配置
*/
public abstract class BaseSwaggerConfig {
@Bean
public Docket createRestApi() {
SwaggerProperties swaggerProperties = swaggerProperties();
Docket docket = new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo(swaggerProperties))
.select()
.apis(RequestHandlerSelectors.basePackage(swaggerProperties.getApiBasePackage()))
.paths(PathSelectors.any())
.build();
if (swaggerProperties.isEnableSecurity()) {
docket.securitySchemes(securitySchemes()).securityContexts(securityContexts());
}
return docket;
}
private ApiInfo apiInfo(SwaggerProperties swaggerProperties) {
return new ApiInfoBuilder()
.title(swaggerProperties.getTitle())
.description(swaggerProperties.getDescription())
.contact(new Contact(swaggerProperties.getContactName(), swaggerProperties.getContactUrl(), swaggerProperties.getContactEmail()))
.version(swaggerProperties.getVersion())
.build();
}
private List<SecurityScheme> securitySchemes() {
//设置请求头信息
List<SecurityScheme> result = new ArrayList<>();
ApiKey apiKey = new ApiKey("Authorization", "Authorization", "header");
result.add(apiKey);
return result;
}
private List<SecurityContext> securityContexts() {
//设置需要登录认证的路径
List<SecurityContext> result = new ArrayList<>();
result.add(getContextByPath("/*/.*"));
return result;
}
private SecurityContext getContextByPath(String pathRegex) {
return SecurityContext.builder()
.securityReferences(defaultAuth())
.forPaths(PathSelectors.regex(pathRegex))
.build();
}
private List<SecurityReference> defaultAuth() {
List<SecurityReference> result = new ArrayList<>();
AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
authorizationScopes[0] = authorizationScope;
result.add(new SecurityReference("Authorization", authorizationScopes));
return result;
}
/**
* 自定义Swagger配置
*/
public abstract SwaggerProperties swaggerProperties();
}
package com.qiwu.inference.common.domain;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* Swagger自定义配置
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Builder
public class SwaggerProperties {
/**
* API文档生成基础路径
*/
private String apiBasePackage;
/**
* 是否要启用登录认证
*/
private boolean enableSecurity;
/**
* 文档标题
*/
private String title;
/**
* 文档描述
*/
private String description;
/**
* 文档版本
*/
private String version;
/**
* 文档联系人姓名
*/
private String contactName;
/**
* 文档联系人网址
*/
private String contactUrl;
/**
* 文档联系人邮箱
*/
private String contactEmail;
}
package com.qiwu.inference.common.exception;
import com.qiwu.inference.common.api.IErrorCode;
import lombok.Getter;
import lombok.Setter;
/**
* 自定义API异常
*/
@Getter
@Setter
public class ApiException extends RuntimeException {
private IErrorCode errorCode;
public ApiException(IErrorCode errorCode) {
super(errorCode.getMessage());
this.errorCode = errorCode;
}
public ApiException(String message) {
super(message);
}
public ApiException(Throwable cause) {
super(cause);
}
public ApiException(String message, Throwable cause) {
super(message, cause);
}
}
package com.qiwu.inference.common.exception;
import com.qiwu.inference.common.api.IErrorCode;
/**
* 断言处理类,用于抛出各种API异常
*/
public class Asserts {
public static void fail(String message) {
throw new ApiException(message);
}
public static void fail(IErrorCode errorCode) {
throw new ApiException(errorCode);
}
}
package com.qiwu.inference.common.exception;
import com.qiwu.inference.common.api.CommonResult;
import org.springframework.validation.BindException;
import org.springframework.validation.BindingResult;
import org.springframework.validation.FieldError;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* 全局异常处理
*/
@ControllerAdvice
public class GlobalExceptionHandler {
@ResponseBody
@ExceptionHandler(value = ApiException.class)
public CommonResult handle(ApiException e) {
if (e.getErrorCode() != null) {
return CommonResult.failed(e.getErrorCode());
}
return CommonResult.failed(e.getMessage());
}
@ResponseBody
@ExceptionHandler(value = MethodArgumentNotValidException.class)
public CommonResult handleValidException(MethodArgumentNotValidException e) {
BindingResult bindingResult = e.getBindingResult();
String message = null;
if (bindingResult.hasErrors()) {
FieldError fieldError = bindingResult.getFieldError();
if (fieldError != null) {
message = fieldError.getField()+fieldError.getDefaultMessage();
}
}
return CommonResult.validateFailed(message);
}
@ResponseBody
@ExceptionHandler(value = BindException.class)
public CommonResult handleValidException(BindException e) {
BindingResult bindingResult = e.getBindingResult();
String message = null;
if (bindingResult.hasErrors()) {
FieldError fieldError = bindingResult.getFieldError();
if (fieldError != null) {
message = fieldError.getField()+fieldError.getDefaultMessage();
}
}
return CommonResult.validateFailed(message);
}
}
package com.qiwu.inference.config;
import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
/**
* MyBatis配置类
*/
@Configuration
@EnableTransactionManagement
@MapperScan({"com.qiwu.inference.dao"})
public class MyBatisConfig {
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
return interceptor;
}
}
package com.qiwu.inference.controller;
import cn.hutool.core.lang.UUID;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.ReUtil;
import com.qiwu.inference.common.api.CommonResult;
import com.qiwu.inference.pojo.*;
import com.qiwu.inference.service.*;
import com.qiwu.inference.util.*;
import org.apache.commons.io.FileUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
/**
* <p>
* 前端控制器
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
@RestController
@RequestMapping("/api/personRecord")
public class PersonRecordController {
@Autowired
public EndGoalService endGoalService;
@Autowired
public KeyClueService keyClueService;
@Autowired
public IdentityService identityService;
@Autowired
public PersonService personService;
@Autowired
public PersonRecordService personRecordService;
@Autowired
public RelationService relationService;
@Autowired
public DispositionService dispositionService;
@Autowired
public DispositionTypeService dispositionTypeService;
@Autowired
public RelationRecordService relationRecordService;
@Autowired
public RelationTypeService relationTypeService;
@Autowired
public BehaviourService behaviourService;
@Autowired
public BehaviourRecordService behaviourRecordService;
@Autowired
public ClueRecordService clueRecordService;
@Autowired
public LocationService locationService;
@Autowired
public DemandTaskService demandTaskService;
@Autowired
public DemandTaskRecordService demandTaskRecordService;
@Autowired
public DispositionRecordService dispositionRecordService;
@Autowired
public ClueService clueService;
private final static String ZIP_FILE = "application/zip";
private final static String RAR_FILE = "application/vnd.rar";
@PostMapping("/import")
public CommonResult importZipFile(@RequestBody MultipartFile uploadFile) {
boolean isZipPack = true;
// 解压目录
String packageFileStr = FileUtil.getPath() + "file" + File.separator + "zip";
//不存在则创建
File packFile = new File(packageFileStr);
if (!packFile.exists()) {
boolean mkdirs = packFile.mkdirs();
if (!mkdirs) {
throw new RuntimeException("文件夹创建失败!");
}
}
if (uploadFile == null) {
throw new RuntimeException("请上传文件!");
}
String contentType = uploadFile.getContentType();
String filename = uploadFile.getOriginalFilename();
//将压缩包保存在指定路径
String packageFilePath = packageFileStr + File.separator + filename;
if (ZIP_FILE.equals(contentType)) {
//zip解压缩处理
} else if (RAR_FILE.equals(contentType)) {
//rar解压缩处理
isZipPack = false;
} else {
throw new RuntimeException("上传的压缩包格式不正确,仅支持rar和zip压缩文件!");
}
File file = new File(packageFilePath);
try {
uploadFile.transferTo(file);
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException("压缩文件到:" + packageFileStr + " 失败!");
}
if (isZipPack) {
//zip压缩包
UnPackageUtil.unPackageZip(file, null, packageFileStr);
} else {
//rar压缩包
UnPackageUtil.unPackageRar(file, packageFileStr);
}
file.delete();
//获取压缩包名称
assert filename != null;
filename = filename.substring(0, filename.lastIndexOf("."));
System.out.println("解压成功,解压目录:" + packageFilePath);
//可以根据解压路径、压缩包名称、文件名称,取出对应文件进行操作
return CommonResult.success(filename);
}
@RequestMapping(value = "/view_all", method = RequestMethod.POST)
@ResponseBody
public CommonResult<Map<String, List<com.qiwu.inference.auto.pojo.Person>>> view_all() throws Exception {
List<String> gateNoList = personRecordService.getGateNo();
Map<String, List<com.qiwu.inference.auto.pojo.Person>> map = new HashMap<>();
String filePath = FileUtil.getPath() + "file" + File.separator + "results.txt";
for (String gateNo : gateNoList) {
List<PersonRecord> personRecordList = personRecordService.getPersonRecords(gateNo);
List<com.qiwu.inference.auto.pojo.Person> personList = new ArrayList<>();
for (PersonRecord p : personRecordList) {
com.qiwu.inference.auto.pojo.Person person = new com.qiwu.inference.auto.pojo.Person();
BeanUtil.copyProperties(p, person);
List<String> list = new ArrayList<>();
//人物的基本情况
list.add(String.format("姓名:%s,(%s)", p.getName(), p.getIsKey() == 1 ? "关键人物" : "普通人物"));
list.add(String.format("身份:%s", p.getIdentityName()));
if (p.getGender() == 1) {
list.add(String.format("性别:%s", "男"));
} else {
list.add(String.format("性别:%s", "女"));
}
list.add(String.format("年龄:%s", p.getAge()));
//查询性格
list.add(String.format("性格:%s", p.getDisposition()));
//查询关系
list.add(String.format("正向关系:\n %s", convertRelation(p.getId())));
list.add(String.format("反向关系:\n %s", convertInverseRelation(p.getId())));
//查询行为
list.add(String.format("行为:\n %s", convertBehaviour(p.getId())));
//查询线索记录
list.add(String.format("线索:\n %s", convertClue(p.getId())));
Map<String, Object> result = allocationClueMerge(p.getId());
list.add(String.format("分配的线索:\n %s", result.get("1")));
list.add(String.format("需求任务("+p.getName()+"):\n %s", convertDemandTask(p.getId())));
list.add("-------------------------------------------------------");
FileUtils.writeLines(new File(filePath), "utf-8", list, true);
//人物拥有的性格
List<DispositionRecord> dispositionRecordList = dispositionRecordService.getDispositionRecords(person.getId());
List<com.qiwu.inference.auto.pojo.Disposition> dispositionList = new ArrayList<>();
for (DispositionRecord dispositionRecord : dispositionRecordList) {
com.qiwu.inference.auto.pojo.Disposition disposition = new com.qiwu.inference.auto.pojo.Disposition();
BeanUtil.copyProperties(dispositionRecord, disposition);
dispositionList.add(disposition);
}
person.setDispositions(dispositionList);
//人物拥有的关系
List<RelationRecord> relationRecordList = relationRecordService.getRelationRecords(person.getId());
List<com.qiwu.inference.auto.pojo.Relation> relationList = new ArrayList<>();
for (RelationRecord relationRecord : relationRecordList) {
com.qiwu.inference.auto.pojo.Relation relation = new com.qiwu.inference.auto.pojo.Relation();
BeanUtil.copyProperties(relationRecord, relation);
relationList.add(relation);
}
person.setRelations(relationList);
//人物拥有的行为
List<BehaviourRecord> behaviourRecordList = behaviourRecordService.getBehaviourRecords(person.getId());
List<com.qiwu.inference.auto.pojo.Behaviour> behaviourList = new ArrayList<>();
for (BehaviourRecord behaviourRecord : behaviourRecordList) {
com.qiwu.inference.auto.pojo.Behaviour behaviour = new com.qiwu.inference.auto.pojo.Behaviour();
BeanUtil.copyProperties(behaviourRecord, behaviour);
behaviourList.add(behaviour);
}
person.setBehaviours(behaviourList);
//人物掌握的线索集合
List<ClueRecord> clueRecordList = clueRecordService.getClueRecords(person.getId());
List<com.qiwu.inference.auto.pojo.Clue> clueList = new ArrayList<>();
//人物分配的线索
clueRecordList.addAll((List<ClueRecord>) result.get("2"));
for (ClueRecord clueRecord : clueRecordList) {
com.qiwu.inference.auto.pojo.Clue clue = new com.qiwu.inference.auto.pojo.Clue();
BeanUtil.copyProperties(clueRecord, clue);
clueList.add(clue);
}
person.setClues(clueList);
//人物的需求任务集合
List<DemandTaskRecord> demandTaskRecordList = demandTaskRecordService.getDemandTaskRecords(person.getId());
List<DemandTask> demandTaskList_1 = demandTaskService.list();
List<com.qiwu.inference.auto.pojo.DemandTask> demandTaskList = new ArrayList<>();
for (DemandTaskRecord demandTaskRecord : demandTaskRecordList) {
com.qiwu.inference.auto.pojo.DemandTask demandTask = new com.qiwu.inference.auto.pojo.DemandTask();
BeanUtil.copyProperties(demandTaskRecord, demandTask);
for (DemandTask demandTask_1 : demandTaskList_1) {
if (Objects.equals(demandTask.getDemandTaskId(), demandTask_1.getId())) {
if (!StringUtils.isEmpty(demandTask_1.getTrustCondition())) {
String[] trustCondition = demandTask_1.getTrustCondition().split("\\|");
demandTask.setTrustStart(Integer.parseInt(trustCondition[0]));
demandTask.setTrustEnd(Integer.parseInt(trustCondition[1]));
}
if (!StringUtils.isEmpty(demandTask_1.getDeterrenceCondition())) {
String[] deterrenceCondition = demandTask_1.getDeterrenceCondition().split("\\|");
demandTask.setDeterrenceStart(Integer.parseInt(deterrenceCondition[0]));
demandTask.setDeterrenceEnd(Integer.parseInt(deterrenceCondition[1]));
}
demandTask.setPostTask(demandTask_1.getPostTask());
demandTask.setCondition1(demandTask_1.getCondition1());
demandTask.setCondition2(demandTask_1.getCondition2());
demandTask.setTrustDegree(demandTask_1.getTrustDegree());
demandTask.setDeterrenceDegree(demandTask_1.getDeterrenceDegree());
demandTask.setCompletionReward(demandTask_1.getCompletionReward());
demandTask.setEffectiveDegree(demandTask_1.getEffectiveDegree());
}
}
demandTaskList.add(demandTask);
}
person.setDemandTasks(demandTaskList);
personList.add(person);
}
map.put(gateNo, personList);
}
String fileJsonPath = FileUtil.getPath() + "file" + File.separator + "results.json";
FastJsonUtil.createJsonFile(map, fileJsonPath);
return CommonResult.success(map);
}
@RequestMapping(value = "/generate", method = RequestMethod.GET)
@ResponseBody
public CommonResult<List<String>> generate() throws Exception {
//删除之前生成的关卡
String filePath = FileUtil.getPath() + "file"+File.separator;
FileUtil.delFilesByPath(filePath,"results");
String gateNo = UUID.fastUUID().toString();
//1.结局目标 在结局目标表中使用同等概率随机选中一个结局目标
List<EndGoal> endGoalList = endGoalService.list();
//随机产生一个索引下标
int index = RandomUtil.randomInt(endGoalList.size());
EndGoal endGoal = endGoalList.get(index);
//2.关键线索
String clueGroup = endGoal.getClueGroup();
String[] clueGroups = clueGroup.split("\\|");
//随机产生一个索引下标
index = RandomUtil.randomInt(clueGroups.length);
clueGroup = clueGroups[index];
List<KeyClue> keyClueList = keyClueService.getKeyClues(clueGroup);
//3.人物数量 5至10人之间随机
//int num = RandomUtil.randomInt(5,7);
int num = 8;
Map<Integer, PersonRecord> map = new HashMap<>();
Map<Integer, KeyClue> keyClueMap = new HashMap<>();
Map<Integer, String> kinshipMap = new HashMap<>();
Map<Integer, Integer> identityMap = new HashMap<>();
List<PersonRecord> personRecordList = new ArrayList<>();
//4.关键人物
for (int i = 0; i < keyClueList.size(); i++) {
KeyClue keyClue = keyClueList.get(i);
//随机选取一个主体的身份
Person person = null;
PersonRecord subject = null;
PersonRecord object = null;
String identityId = keyClue.getSubjectIdentity();
if (!StringUtils.isEmpty(identityId)) {
if (!map.containsKey(keyClue.getSubjectLabel())) {
String[] identityIds = identityId.split("\\|");
index = RandomUtil.randomInt(identityIds.length);
identityId = identityIds[index];
if (identityMap.containsKey(Integer.parseInt(identityId))) {
identityMap.put(Integer.parseInt(identityId), identityMap.get(Integer.parseInt(identityId)) + 1);
} else {
identityMap.put(Integer.parseInt(identityId), 1);
}
List<Person> personList = personService.getPersons(Integer.parseInt(identityId));
index = RandomUtil.randomInt(personList.size());
person = personList.get(index);
while (kinshipMap.containsKey(person.getId())) {
index = RandomUtil.randomInt(personList.size());
person = personList.get(index);
}
kinshipMap.put(person.getId(), person.getKinship());
subject = generatePerson(person, true, gateNo);
personRecordList.add(subject);
map.put(keyClue.getSubjectLabel(), subject);
//关键线索
keyClueMap.put(subject.getId(), keyClue);
//generateClueRecord(subject.getId(),keyClue.getDescription(),5,null);
num--;
} else {
subject = map.get(keyClue.getSubjectLabel());
}
}
//随机选取一个客体的身份
identityId = keyClue.getObjectIdentity();
if (!StringUtils.isEmpty(identityId)) {
if (!map.containsKey(keyClue.getObjectLabel())) {
String[] identityIds = identityId.split("\\|");
index = RandomUtil.randomInt(identityIds.length);
identityId = identityIds[index];
if (identityMap.containsKey(Integer.parseInt(identityId))) {
identityMap.put(Integer.parseInt(identityId), identityMap.get(Integer.parseInt(identityId)) + 1);
} else {
identityMap.put(Integer.parseInt(identityId), 1);
}
List<Person> personList = personService.getPersons(Integer.parseInt(identityId));
index = RandomUtil.randomInt(personList.size());
person = personList.get(index);
while (kinshipMap.containsKey(person.getId())) {
index = RandomUtil.randomInt(personList.size());
person = personList.get(index);
}
kinshipMap.put(person.getId(), person.getKinship());
object = generatePerson(person, true, gateNo);
personRecordList.add(object);
map.put(keyClue.getObjectLabel(), object);
//关键线索
keyClueMap.put(object.getId(), keyClue);
//generateClueRecord(object.getId(),keyClue.getDescription(),5,null);
num--;
} else {
object = map.get(keyClue.getObjectLabel());
}
}
//同时不为空,才去判断他们之间的关系
if (!StringUtils.isEmpty(subject) && !StringUtils.isEmpty(object)) {
String relationId = keyClue.getRelation();
if (!StringUtils.isEmpty(relationId)) {
String[] relations = relationId.split("\\|");
index = RandomUtil.randomInt(relations.length);
relationId = relations[index];
Relation relation = relationService.getById(Integer.parseInt(relationId));
List<Relation> list = new ArrayList<>();
list.add(relation);
judgeRelation(subject, object, list, true);
}
}
}
for (Integer key : keyClueMap.keySet()) {
KeyClue keyClue = keyClueMap.get(key);
String description = keyClue.getDescription();
if(!StringUtils.isEmpty(description)){
description = replaceText(map, description);
}
Clue clue = clueService.getClue(9, keyClue.getId());
//生成关键线索
if (!StringUtils.isEmpty(clue)) {
clue.setClueTemplate(description);
if(!StringUtils.isEmpty(description)){
int num_ = Integer.parseInt(ReUtil.findAllGroup0("^*【\\d+】", keyClue.getDescription()).get(0).replace("【", "").replace("】", ""));
generateClueRecord(num_, key, clue);
}
}
//生成关键任务
if (!StringUtils.isEmpty(keyClue.getAssociatedTask())) {
for (String associatedTask : keyClue.getAssociatedTask().split(";")) {
String[] associatedTasks = associatedTask.split("\\|");
DemandTask demandTask = demandTaskService.getById(associatedTasks[0]);
clue = clueService.getClue(6, demandTask.getId());
if (associatedTasks.length > 2) {
generateDemandTaskRecord(demandTask, clue, map.get(Integer.parseInt(associatedTasks[1])).getId(), map.get(Integer.parseInt(associatedTasks[2])).getId());
//生成任务的线索
generateClueRecord(map.get(Integer.parseInt(associatedTasks[1])).getId(), map.get(Integer.parseInt(associatedTasks[2])).getId(), clue);
} else {
generateDemandTaskRecord(demandTask, clue, map.get(Integer.parseInt(associatedTasks[1])).getId(), 0);
//生成任务的线索
generateClueRecord(map.get(Integer.parseInt(associatedTasks[1])).getId(), 0, clue);
}
}
}
}
//5.随机人物
if (num > 0) {
//List<Identity> identityList=identityService.getIdentitys("0");
List<Identity> identityList = identityService.list();
for (int i = 1; i <= num; i++) {
index = RandomUtil.randomInt(identityList.size());
Identity identity = identityList.get(index);
while (identity.getMaxNum() == 0 || (identityMap.containsKey(identity.getId())
&& identityMap.get(identity.getId()) >= identity.getMaxNum())) {
index = RandomUtil.randomInt(identityList.size());
identity = identityList.get(index);
}
if (identityMap.containsKey(identity.getId())) {
identityMap.put(identity.getId(), identityMap.get(identity.getId()) + 1);
} else {
identityMap.put(identity.getId(), 1);
}
List<Person> personList = personService.getPersons(identity.getId());
index = RandomUtil.randomInt(personList.size());
Person person = personList.get(index);
while (kinshipMap.containsKey(person.getId())) {
index = RandomUtil.randomInt(personList.size());
person = personList.get(index);
}
kinshipMap.put(person.getId(), person.getKinship());
PersonRecord p = generatePerson(person, false, gateNo);
personRecordList.add(p);
}
}
//6.判断人物之间的亲缘关系
for (Integer key : kinshipMap.keySet()) {
String kinship = kinshipMap.get(key);
if (!StringUtils.isEmpty(kinship)) {
String[] kinships = kinship.split(";");
for (String obj : kinships) {
String[] objs = obj.split("\\|");
if (kinshipMap.containsKey(Integer.parseInt(objs[0]))) {
//要优化的地方
PersonRecord subject = personRecordService.getPersonRecords(key, gateNo);
PersonRecord object = personRecordService.getPersonRecords(Integer.parseInt(objs[0]), gateNo);
Relation relation = relationService.getById(Integer.parseInt(objs[1]));
generateRelation(subject, object, relation, true);
Clue clue = clueService.getClue(5, relation.getId());
//生成关系线索
if (!StringUtils.isEmpty(clue)) {
generateClueRecord(subject.getId(), object.getId(), clue);
}
}
}
}
}
//7.判断随机人物间关系
generateRandomRelation(personRecordList);
//8.行为事件
generateRandomBehaviour(personRecordList);
//9.任务
generateRandomDemandTask(personRecordList);
return CommonResult.success(null);
}
/**
* 正向关系进行转换
*
* @param subject 人物
* @return String
*/
public String convertRelation(Integer subject) {
List<RelationRecord> relationRecordList = relationRecordService.getRelationRecords(subject);
StringBuilder builder = new StringBuilder();
for (int i = 0; i < relationRecordList.size(); i++) {
RelationRecord relationRecord = relationRecordList.get(i);
builder.append(String.format(" 与%s有%s(%s)的关系 \n ", relationRecord.getObjectName(), relationRecord.getName(), relationRecord.getRelationId()));
}
return ("".equals(builder.toString())) ? "无" : builder.toString();
}
/**
* 反向关系进行转换
*
* @param object 人物
* @return String
*/
public String convertInverseRelation(Integer object) {
List<RelationRecord> relationRecordList = relationRecordService.getInverseRelationRecords(object);
StringBuilder builder = new StringBuilder();
for (int i = 0; i < relationRecordList.size(); i++) {
RelationRecord relationRecord = relationRecordList.get(i);
builder.append(String.format(" %s与我有%s(%s)的关系 \n ", relationRecord.getSubjectName(), relationRecord.getName(), relationRecord.getRelationId()));
}
return ("".equals(builder.toString())) ? "无" : builder.toString();
}
/**
* 行为进行转换
*
* @param subject
* @return
*/
public String convertBehaviour(Integer subject) {
List<BehaviourRecord> behaviourRecordList = behaviourRecordService.getBehaviourRecords(subject);
StringBuilder builder = new StringBuilder();
for (BehaviourRecord behaviourRecord : behaviourRecordList) {
if (behaviourRecord.getObject() == 0) {
builder.append(String.format(" 有%s(%s)的行为 \n ", behaviourRecord.getName(), behaviourRecord.getBehaviourId()));
} else {
builder.append(String.format(" 与%s有%s(%s)的行为 \n ", behaviourRecord.getObjectName(), behaviourRecord.getName(), behaviourRecord.getBehaviourId()));
}
}
return ("".equals(builder.toString())) ? "无" : builder.toString();
}
/**
* 文字替换
*
* @param map
* @return
*/
public String replaceText(Map<Integer, PersonRecord> map, String description) {
String regExp = "^*【\\d+】";
String regExp_gender = "^*【\\d+第三人称】";
if (!(ReUtil.findAllGroup0(regExp, description).size() > 0)) {
return description;
}
int num = Integer.parseInt(ReUtil.findAllGroup0(regExp, description).get(0).replace("【", "").replace("】", ""));
description = description.replaceAll("【" + num + "】", map.get(num).getName());
if (ReUtil.findAllGroup0(regExp, description).size() > 0) {
num = Integer.parseInt(ReUtil.findAllGroup0(regExp, description).get(0).replace("【", "").replace("】", ""));
if (!StringUtils.isEmpty(map.get(num))) {
description = description.replaceAll("【" + num + "】", map.get(num).getName());
}
if (ReUtil.findAllGroup0(regExp_gender, description).size() > 0) {
num = Integer.parseInt(ReUtil.findAllGroup0(regExp_gender, description).get(0).replace("【", "").replace("第三人称】", ""));
String gender = map.get(num).getGender() == 1 ? "他" : "她";
description = description.replaceAll("【" + num + "第三人称】", gender);
return description;
} else {
return description;
}
} else {
if (ReUtil.findAllGroup0(regExp_gender, description).size() > 0) {
num = Integer.parseInt(ReUtil.findAllGroup0(regExp_gender, description).get(0).replace("【", "").replace("第三人称】", ""));
String gender = map.get(num).getGender() == 1 ? "他" : "她";
description = description.replaceAll("【" + num + "第三人称】", gender);
return description;
} else {
return description;
}
}
}
/**
* 线索进行转换
*
* @param subject
* @return
*/
public String convertClue(Integer subject) {
List<ClueRecord> clueRecordList = clueRecordService.getClueRecords(subject);
StringBuilder builder = new StringBuilder();
for (ClueRecord clueRecord : clueRecordList) {
if (!StringUtils.isEmpty(clueRecord.getClueTemplate())) {
if (clueRecord.getType() == 9) {
builder.append(String.format(" %s (%s|%s)\n", clueRecord.getClueTemplate() + "(关键线索)", clueRecord.getTrustDegree(), clueRecord.getDeterrenceDegree()));
} else {
builder.append(String.format(" %s (%s|%s)\n", clueRecord.getClueTemplate(), clueRecord.getTrustDegree(), clueRecord.getDeterrenceDegree()));
}
}
}
return ("".equals(builder.toString())) ? "无" : builder.toString();
}
/**
* 需求任务进行转换
*
* @param subject 人物
* @return String
*/
public String convertDemandTask(Integer subject) {
List<DemandTaskRecord> demandTaskRecordList = demandTaskRecordService.getDemandTaskRecords(subject);
StringBuilder builder = new StringBuilder();
for (DemandTaskRecord demandTaskRecord : demandTaskRecordList) {
if (demandTaskRecord.getType() == 6) {
DemandTask demandTask = demandTaskService.getById(demandTaskRecord.getDemandTaskId());
builder.append(String.format(" %s (信任值开启条件)%s (威慑度开启条件)%s \n ", demandTaskRecord.getName(), demandTask.getTrustCondition(), demandTask.getDeterrenceCondition()));
}
}
return ("".equals(builder.toString())) ? "无" : builder.toString();
}
/**
* 分配的线索
*
* @param subject
* @return
*/
public String convertAllocationClue(Integer subject) {
//List<ClueRecord> clueRecordList=clueRecordService.getClueRecords(subject);
List<RelationRecord> relationRecordList = relationRecordService.getRelationRecords(subject);
Map<Integer, Integer> map = new HashMap<>();
for (RelationRecord relationRecord : relationRecordList) {
if (!map.containsKey(relationRecord.getObject())) {
map.put(relationRecord.getObject(), relationRecord.getMasterInfoLevel());
} else {
if (map.get(relationRecord.getObject()) < relationRecord.getMasterInfoLevel()) {
map.put(relationRecord.getObject(), relationRecord.getMasterInfoLevel());
}
}
}
List<ClueRecord> clueRecordList = new ArrayList<>();
for (Integer key : map.keySet()) {
clueRecordList.addAll(clueRecordService.getClueRecords(key, map.get(key)));
}
Set<String> obj = new HashSet<>();
for (ClueRecord clueRecord : clueRecordList) {
Clue clue = clueService.getById(clueRecord.getClueId());
double prob = RandomUtil.randomDouble(2, RoundingMode.HALF_UP);
if (prob < Double.parseDouble(clue.getProb())) {
if (!StringUtils.isEmpty(clueRecord.getClueTemplate())) {
obj.add(clueRecord.getClueTemplate());
}
}
}
StringBuilder builder = new StringBuilder();
for (String description : obj) {
builder.append(String.format(" %s \n ", description));
}
return ("".equals(builder.toString())) ? "无" : builder.toString();
}
/**
* 分配的线索
*
* @param subject 人物
* @return Map
*/
public Map<String, Object> allocationClueMerge(Integer subject) {
//List<ClueRecord> clueRecordList=clueRecordService.getClueRecords(subject);
Map<String, Object> result = new HashMap<>();
List<RelationRecord> relationRecordList = relationRecordService.getRelationRecords(subject);
Map<Integer, Integer> map = new HashMap<>();
for (RelationRecord relationRecord : relationRecordList) {
if (!map.containsKey(relationRecord.getObject())) {
map.put(relationRecord.getObject(), relationRecord.getMasterInfoLevel());
} else {
if (map.get(relationRecord.getObject()) < relationRecord.getMasterInfoLevel()) {
map.put(relationRecord.getObject(), relationRecord.getMasterInfoLevel());
}
}
}
List<ClueRecord> clueRecordList = new ArrayList<>();
for (Integer key : map.keySet()) {
clueRecordList.addAll(clueRecordService.getClueRecords(key, map.get(key)));
}
Set<String> obj = new HashSet<>();
List<ClueRecord> cueRecordResult = new ArrayList<>();
for (ClueRecord clueRecord : clueRecordList) {
Clue clue = clueService.getById(clueRecord.getClueId());
double prob = RandomUtil.randomDouble(2, RoundingMode.HALF_UP);
if (prob < Double.parseDouble(clue.getProb())) {
if (!StringUtils.isEmpty(clueRecord.getClueTemplate())) {
obj.add(clueRecord.getClueTemplate() + "(" + clue.getTrustDegree() + "|" + clue.getDeterrenceDegree() + ")");
clueRecord.setTrustDegree(clue.getTrustDegree());
clueRecord.setDeterrenceDegree(clue.getDeterrenceDegree());
cueRecordResult.add(clueRecord);
}
}
}
StringBuilder builder = new StringBuilder();
for (String description : obj) {
builder.append(String.format(" %s \n ", description));
}
result.put("1", ("".equals(builder.toString())) ? "无" : builder.toString());
result.put("2", cueRecordResult);
return result;
}
public List<ClueRecord> allocationClue(Integer subject) {
List<RelationRecord> relationRecordList = relationRecordService.getRelationRecords(subject);
Map<Integer, Integer> map = new HashMap<>();
for (RelationRecord relationRecord : relationRecordList) {
if (!map.containsKey(relationRecord.getObject())) {
map.put(relationRecord.getObject(), relationRecord.getMasterInfoLevel());
} else {
if (map.get(relationRecord.getObject()) < relationRecord.getMasterInfoLevel()) {
map.put(relationRecord.getObject(), relationRecord.getMasterInfoLevel());
}
}
}
List<ClueRecord> clueRecordList = new ArrayList<>();
for (Integer key : map.keySet()) {
clueRecordList.addAll(clueRecordService.getClueRecords(key, map.get(key)));
}
List<ClueRecord> result = new ArrayList<>();
for (ClueRecord clueRecord : clueRecordList) {
Clue clue = clueService.getById(clueRecord.getClueId());
double prob = RandomUtil.randomDouble(2, RoundingMode.HALF_UP);
if (prob < Double.parseDouble(clue.getProb())) {
clueRecord.setTrustDegree(clue.getTrustDegree());
clueRecord.setDeterrenceDegree(clue.getDeterrenceDegree());
result.add(clueRecord);
}
}
return result;
}
/**
* 根据身份生成一个人物
*
* @param person 人物
* @return 人物
*/
public PersonRecord generatePerson(Person person, boolean isKey, String gateNo) {
PersonRecord personRecord = new PersonRecord();
if (isKey) {
personRecord.setIsKey(1);
} else {
personRecord.setIsKey(2);
}
personRecord.setGateNo(gateNo);
personRecord.setIdentityId(person.getIdentityId());
personRecord.setIdentityName(identityService.getById(person.getIdentityId()).getName());
personRecord.setAge(generateAge(person.getAge()));
personRecord.setGender(person.getGender());
personRecord.setLocation(person.getLocation());
personRecord.setName(person.getName());
personRecord.setPersonId(person.getId());
personRecord.setFriendly(person.getFriendly());
personRecordService.save(personRecord);
Map<Integer, String> map = new HashMap<>();
//生成特定的性格
if (!StringUtils.isEmpty(person.getSpecialDisposition())) {
String[] specialDispositions =person.getSpecialDisposition().split("\\|");
for (String specialDisposition:specialDispositions){
Disposition disposition = dispositionService.getById(Integer.parseInt(specialDisposition));
DispositionRecord dispositionRecord = new DispositionRecord();
dispositionRecord.setDispositionId(disposition.getId());
dispositionRecord.setSubject(personRecord.getId());
dispositionRecord.setName(disposition.getName());
dispositionRecord.setDescription(disposition.getDescription());
dispositionRecord.setType(disposition.getType());
dispositionRecordService.save(dispositionRecord);
map.put(disposition.getId(), disposition.getName());
Clue clue = clueService.getClue(3, disposition.getId());
//生成性格线索
if (!StringUtils.isEmpty(clue)) {
generateClueRecord(personRecord.getId(), 0, clue);
}
}
}
//判断人物的性格
generateDisposition(personRecord, map);
//生成场所线索
Clue clue = null;
if (person.getLocation() != 0) {
clue = clueService.getClue(2, person.getLocation());
} else {
List<Location> locationList = locationService.list();
int index = RandomUtil.randomInt(locationList.size());
clue = clueService.getClue(2, locationList.get(index).getId());
personRecord.setLocation(locationList.get(index).getId());
}
//生成位置线索
if (!StringUtils.isEmpty(clue)) {
generateClueRecord(personRecord.getId(), 0, clue);
}
clue = null;
//生成身份线索
clue = clueService.getClue(1, person.getId());
if (!StringUtils.isEmpty(clue)) {
generateClueRecord(personRecord.getId(), 0, clue);
}
personRecordService.updateById(personRecord);
return personRecord;
}
/**
* 根据年龄的规则生成一个随机的年龄
*
* @param ageCondition 年龄条件
* @return 年龄
*/
public Integer generateAge(String ageCondition) {
String[] ageConditions = ageCondition.split("\\|");
int age = RandomUtil.randomInt(Integer.parseInt(ageConditions[0]), Integer.parseInt(ageConditions[1]) + 1);
return age;
}
/**
* 随机生成人物的性格关系
*
* @param personRecord 人物
*/
public void generateDisposition(PersonRecord personRecord, Map<Integer, String> map) {
List<DispositionType> dispositionTypeList = dispositionTypeService.list();
double prob = 0.0;
for (DispositionType dispositionType : dispositionTypeList) {
//随机一个概率
prob = RandomUtil.randomDouble(2, RoundingMode.HALF_UP);
if (0 < prob && prob <= Double.parseDouble(dispositionType.getProbability())) {
List<Disposition> dispositionList = dispositionService.getDispositions(dispositionType.getId());
judgeDisposition(personRecord, dispositionList, map);
}
}
personRecord.setDisposition(FastJsonUtil.obj2json(map));
}
/**
* 随机生成一个关系
*
* @param subject
* @param object
* @param relation
* @param inverse 是否是正向关系
*/
public void generateRelation(PersonRecord subject, PersonRecord object, Relation relation, boolean inverse) {
//关系人排除身份
if (!StringUtils.isEmpty(relation.getExclusionIdentity())) {
String[] exclusionIdentitys = relation.getExclusionIdentity().split("\\|");
if (exclusionIdentitys[exclusionIdentitys.length - 1].equals("-1")) { //身份排除
for (int i = 0; i < exclusionIdentitys.length - 1; i++) {
if (Objects.equals(Integer.parseInt(exclusionIdentitys[i]), subject.getIdentityId())) {
return;
}
}
} else {
boolean flag = false;
for (int i = 0; i < exclusionIdentitys.length - 1; i++) {
if (Objects.equals(Integer.parseInt(exclusionIdentitys[i]), subject.getIdentityId())) {
flag = true;
}
}
if (!flag) {
return;
}
}
}
//互斥关系
if (!StringUtils.isEmpty(relation.getExclusionRelation())) {
boolean flag = relationService.isExists(relation.getExclusionRelation().split("\\|"));
if (flag) {
return;
}
}
if (!relationRecordService.isExists(subject.getId(), object.getId(), relation.getId())) {
RelationRecord relationRecord = new RelationRecord();
relationRecord.setName(relation.getName());
relationRecord.setDescription(relation.getDescription());
relationRecord.setType(relation.getType());
relationRecord.setRelationId(relation.getId());
relationRecord.setSubject(subject.getId());
relationRecord.setSubjectName(subject.getName());
relationRecord.setObject(object.getId());
relationRecord.setObjectName(object.getName());
relationRecord.setMasterInfoLevel(relation.getMasterInfoLevel());
relationRecordService.save(relationRecord);
//反向关系
if (!StringUtils.isEmpty(relation.getInverseRelation()) && inverse) {
judgeRelation(object, subject, relationService.getRelations(relation.getInverseRelation().split("\\|")), false);
}
}
}
/**
* 随机生成一个线索记录
*
* @param subject
* @param object
* @param clue
*/
public void generateClueRecord(int subject, int object, Clue clue) {
ClueRecord clueRecord = new ClueRecord();
clueRecord.setClueId(clue.getId());
clueRecord.setClueName(clue.getName());
clueRecord.setDescription(clue.getDescription());
if (clue.getType() != 9) {
String clueTemplate = clue.getClueTemplate();
PersonRecord p = personRecordService.getById(subject);
clueTemplate = clueTemplate.replaceAll("【A】", p.getName());
if (!StringUtils.isEmpty(object)) {
if (ReUtil.findAllGroup0("^*【B】", clueTemplate).size() > 0) {
p = personRecordService.getById(object);
if (!StringUtils.isEmpty(p)) {
clueTemplate = clueTemplate.replaceAll("【B】", p.getName());
}
}
}
clueRecord.setClueTemplate(clueTemplate);
clueRecord.setSubject(subject);
clueRecord.setObject(object);
clueRecord.setAssociatedPerson(subject);
} else {
clueRecord.setClueTemplate(clue.getClueTemplate());
clueRecord.setSubject(subject);
clueRecord.setAssociatedPerson(object);
}
clueRecord.setType(clue.getType());
clueRecord.setInfoLevel(clue.getInfoLevel());
// clueRecord.setTrustDegree(clue.getTrustDegree());
// clueRecord.setThreaten(clue.getThreaten());
clueRecord.setTrustDegree(clue.getMyTrustDegree());
clueRecord.setDeterrenceDegree(clue.getMyDeterrenceDegree());
if (!clueRecordService.isExists(clueRecord)) {
clueRecordService.save(clueRecord);
}
}
/**
* 生成人物的随机关系
*
* @param personRecordList 人物记录列表
* @return void
*/
public void generateRandomRelation(List<PersonRecord> personRecordList) {
int size = personRecordList.size();
for (int i = 0; i < size; i++) {
for (int j = 0; j < size; j++) {
if (i != j) {
PersonRecord subject = personRecordList.get(i);
PersonRecord object = personRecordList.get(j);
List<RelationType> relationTypeList = relationTypeService.list(2);
double prob = 0.0;
for (int k = 0; k < relationTypeList.size(); k++) {
RelationType relationType = relationTypeList.get(k);
//随机一个概率
prob = RandomUtil.randomDouble(2, RoundingMode.HALF_UP);
if (0 < prob && prob <= Double.parseDouble(relationType.getProbability())) {
List<Relation> relationList = relationService.getRelations(relationType.getId());
judgeRelation(subject, object, relationList, true);
}
}
}
}
}
}
/**
* 判断人物之间的关系
*
* @param subject 主体人物
* @param object 客体人物
* @param list
*/
public void judgeRelation(PersonRecord subject, PersonRecord object, List<Relation> list, boolean inverse) {
int sumWeight = 0;
for (int i = 0; i < list.size(); i++) {
Relation relation = list.get(i);
int weight = relation.getWeight();
String genderWeight = relation.getGenderWeight();
//性别影响权重增减
if (!StringUtils.isEmpty(genderWeight)) {
String[] genderWeights = genderWeight.split(";");
for (String s : genderWeights) {
String[] obj = s.split("\\|");
if (obj.length == 2) {
if (obj[0].equals(String.valueOf(subject.getGender()))) {
weight += Integer.parseInt(obj[1]);
}
} else if (obj.length == 3) {
if (obj[0].equals(String.valueOf(subject.getGender())) && obj[1].equals(String.valueOf(object.getGender()))) {
weight += Integer.parseInt(obj[2]);
}
}
}
}
String ageWeight = relation.getAgeWeight();
//年龄影响权重增减
if (!StringUtils.isEmpty(ageWeight)) {
String[] ageWeights = ageWeight.split(";");
for (int j = 0; j < ageWeights.length; j++) {
ageWeight = ageWeights[j];
String[] ageWeights_1 = ageWeight.split("\\|");
if (NumberUtil.isIn(BigDecimal.valueOf(subject.getAge()), BigDecimal.valueOf(Integer.parseInt(ageWeights_1[0])), BigDecimal.valueOf(Integer.parseInt(ageWeights_1[1])))) {
weight += Integer.parseInt(ageWeights_1[2]);
}
}
}
//年龄差影响权重增减
//身份影响概率增减
String identityWeight = relation.getIdentityWeight();
if (!StringUtils.isEmpty(identityWeight)) {
String[] identityWeights = identityWeight.split("\\|");
if (identityWeight.contains(String.valueOf(subject.getIdentityId()))) {
weight += Integer.parseInt(identityWeights[identityWeights.length - 1]);
}
}
//性格/喜好影响权重增减
weight = Math.max(weight, 0);
sumWeight += weight;
relation.setWeight(weight);
list.set(i, relation);
}
double start = 0.0;
double end = 0.0;
//随机一个概率
double prob = RandomUtil.randomDouble(2, RoundingMode.HALF_UP);
for (int i = 0; i < list.size(); i++) {
Relation relation = list.get(i);
if (!relationRecordService.isExistsRelationTypes(subject.getId(), object.getId(), relation.getType())) {
if (relation.getWeight() != 0) {
end += NumberUtil.div(Double.valueOf(relation.getWeight()), Double.valueOf(sumWeight), 2);
if (NumberUtil.isIn(BigDecimal.valueOf(prob), BigDecimal.valueOf(start), BigDecimal.valueOf(end))) {
generateRelation(subject, object, relation, inverse);
Clue clue = clueService.getClue(5, relation.getId());
//生成关系线索
if (!StringUtils.isEmpty(clue)) {
generateClueRecord(subject.getId(), object.getId(), clue);
}
break;
}
start = end;
}
} else {
return;
}
}
}
/**
* 判断人物之间的性格
*
* @param personRecord 人物
* @param list 列表
*/
public void judgeDisposition(PersonRecord personRecord, List<Disposition> list, Map<Integer, String> map) {
int sumWeight = 0;
for (int i = 0; i < list.size(); i++) {
Disposition disposition = list.get(i);
int weight = disposition.getWeight();
weight = Math.max(weight, 0);
sumWeight += weight;
disposition.setWeight(weight);
list.set(i, disposition);
}
double start = 0.0;
double end = 0.0;
//随机一个概率
double prob = RandomUtil.randomDouble(2, RoundingMode.HALF_UP);
for (Disposition disposition : list) {
if (disposition.getWeight() != 0) {
end += NumberUtil.div(Double.valueOf(disposition.getWeight()), Double.valueOf(sumWeight), 2);
if (NumberUtil.isIn(BigDecimal.valueOf(prob), BigDecimal.valueOf(start), BigDecimal.valueOf(end))) {
DispositionRecord dispositionRecord = new DispositionRecord();
dispositionRecord.setDispositionId(disposition.getId());
dispositionRecord.setSubject(personRecord.getId());
dispositionRecord.setName(disposition.getName());
dispositionRecord.setDescription(disposition.getDescription());
dispositionRecord.setType(disposition.getType());
dispositionRecordService.save(dispositionRecord);
map.put(disposition.getId(), disposition.getName());
Clue clue = clueService.getClue(3, disposition.getId());
//生成性格线索
if (!StringUtils.isEmpty(clue)) {
generateClueRecord(personRecord.getId(), 0, clue);
}
break;
}
start = end;
}
}
}
/**
* 生成人物的随机行为
*
* @param personRecordList 人物
* @return void
*/
public void generateRandomBehaviour(List<PersonRecord> personRecordList) {
int size = personRecordList.size();
for (int i = 0; i < size; i++) {
for (int j = 0; j < size; j++) {
if (i != j) {
PersonRecord subject = personRecordList.get(i);
PersonRecord object = personRecordList.get(j);
List<Behaviour> behaviourList = behaviourService.list(0);
double prob = 0.0;
for (Behaviour behaviour : behaviourList) {
//互斥行为
if (!StringUtils.isEmpty(behaviour.getExclusionBehaviour())) {
String[] exclusionBehaviours = behaviour.getExclusionBehaviour().split("\\|");
boolean flag = true;
for (String exclusionBehaviour : exclusionBehaviours) {
//判断是不是单人行为
if (behaviour.getSingleLabel() == 1) {
if (behaviourRecordService.isExists(subject.getId(), behaviour.getId()) || behaviourRecordService.isExists(subject.getId(), Integer.parseInt(exclusionBehaviour))) {
flag = false;
}
} else {
if (behaviourRecordService.isExists(subject.getId(), object.getId(), behaviour.getId()) || behaviourRecordService.isExists(subject.getId(), object.getId(), Integer.parseInt(exclusionBehaviour))) {
flag = false;
}
}
}
if (!flag) {
continue;
}
}
double generationProbability = behaviour.getGenerationProbability();
//行为人性格喜好|概率增减
String subjectDisposition = behaviour.getSubjectDisposition();
if (!StringUtils.isEmpty(subjectDisposition)) {
String[] subjectDispositions = subjectDisposition.split(";");
for (String disposition : subjectDispositions) {
Map<String, String> map = FastJsonUtil.parseJSON2Map(subject.getDisposition());
for (String key : map.keySet()) {
if (disposition.contains(key)) {
String[] obj = disposition.split("\\|");
generationProbability += Double.parseDouble(obj[obj.length - 1]);
}
}
}
}
//行为人身份|概率增减
String subjectIdentityProbability = behaviour.getSubjectIdentityProbability();
if (!StringUtils.isEmpty(subjectIdentityProbability)) {
if (behaviour.getSubjectIdentityProbability().contains(String.valueOf(subject.getIdentityId()))) {
String[] obj = subjectIdentityProbability.split("\\|");
generationProbability += Double.parseDouble(obj[obj.length - 1]);
}
}
//行为对象身份|概率增减(B)
String objectIdentityProbability = behaviour.getObjectIdentityProbability();
if (!StringUtils.isEmpty(objectIdentityProbability)) {
if (behaviour.getObjectIdentityProbability().contains(String.valueOf(object.getIdentityId()))) {
String[] obj = objectIdentityProbability.split("\\|");
generationProbability += Double.parseDouble(obj[obj.length - 1]);
}
}
//与行为对象关系|概率影响(A与B)"
String objectRelationProbability = behaviour.getObjectRelationProbability();
//行为对象性格喜好|概率影响(B)
String objectDispositionProbability = behaviour.getObjectDispositionProbability();
if (!StringUtils.isEmpty(objectDispositionProbability)) {
String[] objectDispositionProbabilitys = objectDispositionProbability.split(";");
for (String dispositionProbability : objectDispositionProbabilitys) {
Map<String, String> map = FastJsonUtil.parseJSON2Map(object.getDisposition());
for (String key : map.keySet()) {
if (dispositionProbability.contains(key)) {
String[] obj = dispositionProbability.split("\\|");
generationProbability += Double.parseDouble(obj[obj.length - 1]);
}
}
}
}
//行为人性别|行为对象性别|概率影响
String genderProbability = behaviour.getGenderProbability();
if (!StringUtils.isEmpty(genderProbability)) {
String[] genderProbabilitys = genderProbability.split(";");
for (String probability : genderProbabilitys) {
String[] obj = probability.split("\\|");
if (obj[0].equals(String.valueOf(subject.getGender())) && obj[1].equals(String.valueOf(object.getGender()))) {
generationProbability += Double.parseDouble(obj[2]);
}
}
}
//随机一个概率
prob = RandomUtil.randomDouble(2, RoundingMode.HALF_UP);
if (0 < prob && prob <= generationProbability) {
//单人行为
if (behaviour.getSingleLabel() == 1) {
generateRandomBehaviour(subject, null, behaviour);
} else {
generateRandomBehaviour(subject, object, behaviour);
}
//反向行为
if (!StringUtils.isEmpty(behaviour.getInverseBehaviour()) && behaviour.getInverseLabel() == 0) {
String[] inverseBehaviours = behaviour.getInverseBehaviour().split("\\|");
int index = RandomUtil.randomInt(inverseBehaviours.length);
behaviour = behaviourService.getById(Integer.parseInt(inverseBehaviours[index]));
//单人行为
if (behaviour.getSingleLabel() == 1) {
generateRandomBehaviour(object, null, behaviour);
} else {
generateRandomBehaviour(object, subject, behaviour);
}
}
}
}
}
}
}
}
/**
* 生成人物的随机需求任务
*
* @param personRecordList 人物列表
* @return void
*/
public void generateRandomDemandTask(List<PersonRecord> personRecordList) {
for (int i = 0; i < personRecordList.size(); i++) {
PersonRecord subject = personRecordList.get(i);
int taskGroupSize = demandTaskService.getTaskGroupSize();
for (int j = 1; j < taskGroupSize; j++) {
List<DemandTask> demandTaskList = demandTaskService.list(j, 0, 1);
Collections.shuffle(demandTaskList);
for (DemandTask demandTask : demandTaskList) {
//根据友好人物 剔除负面任务
if(subject.getFriendly()==1&&demandTask.getNegativeTask()==1){
continue;
}
//主体判断身份
if (!StringUtils.isEmpty(demandTask.getSubjectNeedIdentity())) {
if (!demandTask.getSubjectNeedIdentity().contains(String.valueOf(subject.getIdentityId()))) {
continue;
}
}
//主体判断性别
if (!StringUtils.isEmpty(demandTask.getSubjectNeedGender())) {
if (!demandTask.getSubjectNeedGender().equals(String.valueOf(subject.getGender()))) {
continue;
}
}
boolean flag = false;
Integer objectId = null;
if (!StringUtils.isEmpty(demandTask.getPostTask())) {
String[] postTasks = demandTask.getPostTask().split("\\|");
int index = RandomUtil.randomInt(postTasks.length);
DemandTask postDemandTask = demandTaskService.getById(postTasks[index]);
Map<String, Integer> res = generatePostDemandTask(postDemandTask, subject.getId());
if (res.size() > 0) {
PersonRecord object = personRecordService.getById(res.get("object"));
//根据友好人物 剔除负面任务
if(object.getFriendly()==1&&postDemandTask.getNegativeTask()==1){
continue;
}
//判断客体的必要身份
if (!StringUtils.isEmpty(demandTask.getObjectNeedIdentity())) {
if (!demandTask.getObjectNeedIdentity().contains(String.valueOf(object.getIdentityId()))) {
continue;
}
}
//判断客体的必要性别
if (!StringUtils.isEmpty(demandTask.getObjectNeedGender())) {
if (!demandTask.getObjectNeedGender().equals(String.valueOf(object.getGender()))) {
continue;
}
}
flag = generateDemandTask(demandTask, subject.getId(), res.get("object"));
if (flag) {
Clue clue = clueService.getClue(6, postDemandTask.getId());
boolean flag_ = generateDemandTaskRecord(postDemandTask, clue, res.get("object"), 0);
if (!flag_) {
//删除前置任务相关线索
List<DemandTaskRecord> list_ = demandTaskRecordService.getDemandTaskRecords(demandTask.getId(), subject.getId(), res.get("object"));
for (DemandTaskRecord demandTaskRecord : list_) {
clueRecordService.delete(demandTaskRecord.getClueId(), subject.getId(), res.get("object"));
}
//删除前置任务
demandTaskRecordService.delete(demandTask.getId(), subject.getId(), res.get("object"));
}
}
} else {//后置任务 如果四个条件都没有命中 随机选取一个人物
index = RandomUtil.randomInt(personRecordList.size());
objectId = personRecordList.get(index).getId();
while (Objects.equals(personRecordList.get(index).getId(), subject.getId())) {
index = RandomUtil.randomInt(personRecordList.size());
objectId = personRecordList.get(index).getId();
}
PersonRecord object = personRecordService.getById(objectId);
//根据友好人物 剔除负面任务
if(object.getFriendly()==1&&postDemandTask.getNegativeTask()==1){
continue;
}
//判断客体的必要身份
if (!StringUtils.isEmpty(demandTask.getObjectNeedIdentity())) {
if (!demandTask.getObjectNeedIdentity().contains(String.valueOf(object.getIdentityId()))) {
continue;
}
}
//判断客体的必要性别
if (!StringUtils.isEmpty(demandTask.getObjectNeedGender())) {
if (!demandTask.getObjectNeedGender().equals(String.valueOf(object.getGender()))) {
continue;
}
}
flag = generateDemandTask(demandTask, subject.getId(), objectId);
if (flag) {
Clue clue = clueService.getClue(6, postDemandTask.getId());
boolean flag_ = generateDemandTaskRecord(postDemandTask, clue, objectId, 0);
if (!flag_) {
//删除前置任务相关线索
List<DemandTaskRecord> list_ = demandTaskRecordService.getDemandTaskRecords(demandTask.getId(), subject.getId(), objectId);
for (DemandTaskRecord demandTaskRecord : list_) {
clueRecordService.delete(demandTaskRecord.getClueId(), subject.getId(), objectId);
}
//删除前置任务
demandTaskRecordService.delete(demandTask.getId(), subject.getId(), objectId);
}
}
}
} else {
flag = generateDemandTask(demandTask, subject.getId(), 0);
}
if (flag) {
break;
}
}
}
}
}
public boolean generateDemandTask(DemandTask demandTask, int subjectId, int objectId) {
double prob = 0.0;
PersonRecord subject = personRecordService.getById(subjectId);
boolean flag = false;
List<Clue> clueList = new ArrayList<>();
Clue clue = null;
if (demandTaskRecordService.isExistsTaskGroup(subjectId, demandTask.getTaskGroup())) {
return flag;
}
//性格喜好关联
if (!StringUtils.isEmpty(demandTask.getAssociatedDisposition())) {
String disposition = subject.getDisposition();
Map<String, String> dispositionMap = FastJsonUtil.parseJSON2Map(disposition);
for (String key : dispositionMap.keySet()) {
if (demandTask.getAssociatedDisposition().contains(key)) {
prob = RandomUtil.randomDouble(2, RoundingMode.HALF_UP);
String[] obj = demandTask.getAssociatedDisposition().split("\\|");
if (0 < prob && prob <= Double.parseDouble(obj[obj.length - 1])) {
flag = true;
clue = clueService.getClue(3, Integer.parseInt(obj[0]));
clueList.add(ObjectUtil.clone(clue));
//generateDemandTaskRecord(demandTask,clue,subject.getId(),objectId);
break;
} else {
flag = false;
return flag;
}
}
}
}
//身份关联
if (!StringUtils.isEmpty(demandTask.getAssociatedIdentity())) {
if (demandTask.getAssociatedIdentity().contains(String.valueOf(subject.getIdentityId()))) {
prob = RandomUtil.randomDouble(2, RoundingMode.HALF_UP);
String[] obj = demandTask.getAssociatedIdentity().split("\\|");
if (0 < prob && prob <= Double.parseDouble(obj[obj.length - 1])) {
flag = true;
clue = clueService.getClue(1, Integer.parseInt(obj[0]));
clueList.add(ObjectUtil.clone(clue));
//generateDemandTaskRecord(demandTask,clue,subject.getId(),objectId);
} else {
flag = false;
return flag;
}
}
}
//行为关联
if (!StringUtils.isEmpty(demandTask.getAssociatedBehaviour())) {
List<BehaviourRecord> behaviourRecordList = behaviourRecordService.getBehaviourRecords(subject.getId());
for (BehaviourRecord behaviourRecord : behaviourRecordList) {
if (demandTask.getAssociatedBehaviour().contains(String.valueOf(behaviourRecord.getBehaviourId()))) {
prob = RandomUtil.randomDouble(2, RoundingMode.HALF_UP);
String[] obj = demandTask.getAssociatedBehaviour().split("\\|");
if (0 < prob && prob <= Double.parseDouble(obj[obj.length - 1])) {
flag = true;
clue = clueService.getClue(4, Integer.parseInt(obj[0]));
clueList.add(ObjectUtil.clone(clue));
//generateDemandTaskRecord(demandTask,clue,subject.getId(),objectId);
break;
} else {
flag = false;
return flag;
}
}
}
}
//关系关联
if (!StringUtils.isEmpty(demandTask.getAssociatedRelation())) {
List<RelationRecord> relationRecordList = relationRecordService.getRelationRecords(subject.getId());
for (RelationRecord relationRecord : relationRecordList) {
if (demandTask.getAssociatedRelation().contains(String.valueOf(relationRecord.getRelationId()))) {
prob = RandomUtil.randomDouble(2, RoundingMode.HALF_UP);
String[] obj = demandTask.getAssociatedRelation().split("\\|");
if (0 < prob && prob <= Double.parseDouble(obj[obj.length - 1])) {
flag = true;
clue = clueService.getClue(5, Integer.parseInt(obj[0]));
clueList.add(ObjectUtil.clone(clue));
//generateDemandTaskRecord(demandTask,clue,subject.getId(),objectId);
break;
} else {
flag = false;
return flag;
}
}
}
}
if(flag){
flag = generateDemandTaskRecord(demandTask, null, subject.getId(), objectId);
if(flag){
for (Clue key : clueList) {
generateDemandTaskRecord(demandTask, key, subject.getId(), objectId);
}
}
return flag;
} else {//四个关联都没有命中,直接插入一条数据
if (StringUtils.isEmpty(demandTask.getAssociatedDisposition()) &&
StringUtils.isEmpty(demandTask.getAssociatedBehaviour()) &&
StringUtils.isEmpty(demandTask.getAssociatedIdentity()) &&
StringUtils.isEmpty(demandTask.getAssociatedRelation())) {
generateDemandTaskRecord(demandTask, null, subject.getId(), objectId);
return true;
}else{
return flag;
}
}
}
public Map<String, Integer> generatePostDemandTask(DemandTask demandTask, Integer subjectId) {
double prob = 0.0;
Integer objectId = null;
Map<String, Integer> result = new HashMap<>();
//性格喜好关联
if (!StringUtils.isEmpty(demandTask.getAssociatedDisposition())) {
prob = RandomUtil.randomDouble(2, RoundingMode.HALF_UP);
String[] obj = demandTask.getAssociatedDisposition().split("\\|");
if (0 < prob && prob <= Double.parseDouble(obj[obj.length - 1])) {
for (int i = 0; i < obj.length - 1; i++) {
List<DispositionRecord> dispositionRecordList = dispositionRecordService.getDispositionRecordsNoSubject(subjectId, Integer.parseInt(obj[i]));
if (dispositionRecordList.size() > 0) {
int index = RandomUtil.randomInt(dispositionRecordList.size());
//generateDemandTask(demandTask,dispositionRecordList.get(index).getSubject(),null);
objectId = dispositionRecordList.get(index).getSubject();
result.put("object", objectId);
return result;
}
}
}
}
//身份关联
if (!StringUtils.isEmpty(demandTask.getAssociatedIdentity())) {
prob = RandomUtil.randomDouble(2, RoundingMode.HALF_UP);
String[] obj = demandTask.getAssociatedIdentity().split("\\|");
if (0 < prob && prob <= Double.parseDouble(obj[obj.length - 1])) {
for (int i = 0; i < obj.length - 1; i++) {
List<PersonRecord> personRecordList = personRecordService.getPersonRecordsNoSubject(subjectId, Integer.parseInt(obj[i]));
if (personRecordList.size() > 0) {
int index = RandomUtil.randomInt(personRecordList.size());
//generateDemandTask(demandTask,personRecordList.get(index).getId(),null);
objectId = personRecordList.get(index).getId();
result.put("object", objectId);
return result;
}
}
}
}
//行为关联
if (!StringUtils.isEmpty(demandTask.getAssociatedBehaviour())) {
prob = RandomUtil.randomDouble(2, RoundingMode.HALF_UP);
String[] obj = demandTask.getAssociatedBehaviour().split("\\|");
if (0 < prob && prob <= Double.parseDouble(obj[obj.length - 1])) {
for (int i = 0; i < obj.length - 1; i++) {
Behaviour behaviour = behaviourService.getById(Integer.parseInt(obj[i]));
List<BehaviourRecord> behaviourRecordList;
if (behaviour.getSingleLabel() == 1) {//单人行为标签
behaviourRecordList = behaviourRecordService.getBehaviourRecordsNoSubject(subjectId, Integer.parseInt(obj[i]));
} else {
behaviourRecordList = behaviourRecordService.getBehaviourRecords(subjectId, Integer.parseInt(obj[i]));
}
if (behaviourRecordList.size() > 0) {
int index = RandomUtil.randomInt(behaviourRecordList.size());
//generateDemandTask(demandTask, behaviourRecordList.get(index).getSubject(), null);
objectId = behaviourRecordList.get(index).getSubject();
result.put("object", objectId);
return result;
}
}
}
}
//关系关联
if (!StringUtils.isEmpty(demandTask.getAssociatedRelation())) {
prob = RandomUtil.randomDouble(2, RoundingMode.HALF_UP);
String[] obj = demandTask.getAssociatedRelation().split("\\|");
if (0 < prob && prob <= Double.parseDouble(obj[obj.length - 1])) {
for (int i = 0; i < obj.length - 1; i++) {
List<RelationRecord> relationRecordList = relationRecordService.getRelationRecordsNoSubject(subjectId, Integer.parseInt(obj[i]));
if (relationRecordList.size() > 0) {
int index = RandomUtil.randomInt(relationRecordList.size());
//generateDemandTask(demandTask,relationRecordList.get(index).getSubject(),null);
objectId = relationRecordList.get(index).getSubject();
result.put("object", objectId);
return result;
}
}
}
}
return result;
}
public boolean generateDemandTaskRecord(DemandTask demandTask, Clue clue, int subject, int object) {
boolean flag = true;
//判断互斥任务
if (!StringUtils.isEmpty(demandTask.getExclusiveTask())) {
String exclusiveTask = demandTask.getExclusiveTask();
String[] exclusiveTasks = exclusiveTask.split("\\|");
for (String task : exclusiveTasks) {
if (demandTaskRecordService.isExists(subject, Integer.parseInt(task))) {
flag = false;
break;
}
}
}
if (flag) {
if (StringUtils.isEmpty(clue)) {
if (demandTask.getTaskLabel() == 1) {
clue = clueService.getClue(6, demandTask.getId());
} else {
clue = clueService.getClue(9, demandTask.getId());
}
}
DemandTaskRecord demandTaskRecord = new DemandTaskRecord();
demandTaskRecord.setDemandTaskId(demandTask.getId());
demandTaskRecord.setName(demandTask.getName());
demandTaskRecord.setTaskGroup(demandTask.getTaskGroup());
demandTaskRecord.setDescription(demandTask.getDescription());
demandTaskRecord.setSubject(subject);
demandTaskRecord.setObject(object);
demandTaskRecord.setType(clue.getType());
demandTaskRecord.setClueId(clue.getId());
demandTaskRecord.setInfoLevel(demandTask.getInfoLevel());
demandTaskRecord.setTaskLabel(demandTask.getTaskLabel());
demandTaskRecord.setClueSwitch(demandTask.getClueSwitch());
demandTaskRecord.setIsAuto(demandTask.getIsAuto());
if (!demandTaskRecordService.isExists(demandTaskRecord)) {
demandTaskRecordService.save(demandTaskRecord);
if (clue.getType() == 6 || demandTask.getTaskLabel() == 2) {
//生成任务线索
generateClueRecord(subject, object, clue);
}
} else {
return false;
}
}
return flag;
}
/**
* 随机生成一个行为
*
* @param subject 主体人物
* @param object 客体人物
* @param behaviour 行为
*/
public void generateRandomBehaviour(PersonRecord subject, PersonRecord object, Behaviour behaviour) {
boolean flag = false;
BehaviourRecord behaviourRecord = new BehaviourRecord();
behaviourRecord.setName(behaviour.getName());
behaviourRecord.setDescription(behaviour.getDescription());
behaviourRecord.setBehaviourId(behaviour.getId());
behaviourRecord.setSubject(subject.getId());
behaviourRecord.setSubjectName(subject.getName());
if (!StringUtils.isEmpty(object)) {
behaviourRecord.setObject(object.getId());
behaviourRecord.setObjectName(object.getName());
if(!behaviourRecordService.isExists(subject.getId(), object.getId(), behaviour.getId())) {
behaviourRecordService.save(behaviourRecord);
flag = true;
}
}else{
if (!behaviourRecordService.isExists(subject.getId(), behaviour.getId())) {
behaviourRecordService.save(behaviourRecord);
flag = true;
}
}
if (flag) {
Clue clue = clueService.getClue(4, behaviour.getId());
if (!StringUtils.isEmpty(clue)) {
//生成行为线索
if (!StringUtils.isEmpty(object)) {
generateClueRecord(subject.getId(), object.getId(), clue);
} else {
generateClueRecord(subject.getId(), 0, clue);
}
}
}
}
}
package com.qiwu.inference.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qiwu.inference.pojo.Behaviour;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
public interface BehaviourMapper extends BaseMapper<Behaviour> {
}
package com.qiwu.inference.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qiwu.inference.pojo.BehaviourRecord;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
public interface BehaviourRecordMapper extends BaseMapper<BehaviourRecord> {
}
package com.qiwu.inference.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qiwu.inference.pojo.Clue;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xingxing.ye
* @since 2022-11-07
*/
public interface ClueMapper extends BaseMapper<Clue> {
}
package com.qiwu.inference.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qiwu.inference.pojo.ClueRecord;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
public interface ClueRecordMapper extends BaseMapper<ClueRecord> {
}
package com.qiwu.inference.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qiwu.inference.pojo.DemandTask;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xingxing.ye
* @since 2022-11-07
*/
public interface DemandTaskMapper extends BaseMapper<DemandTask> {
}
package com.qiwu.inference.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qiwu.inference.pojo.DemandTaskRecord;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xingxing.ye
* @since 2022-11-07
*/
public interface DemandTaskRecordMapper extends BaseMapper<DemandTaskRecord> {
}
package com.qiwu.inference.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qiwu.inference.pojo.Disposition;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
public interface DispositionMapper extends BaseMapper<Disposition> {
}
package com.qiwu.inference.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qiwu.inference.pojo.DispositionRecord;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
public interface DispositionRecordMapper extends BaseMapper<DispositionRecord> {
}
package com.qiwu.inference.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qiwu.inference.pojo.DispositionType;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xingxing.ye
* @since 2022-11-04
*/
public interface DispositionTypeMapper extends BaseMapper<DispositionType> {
}
package com.qiwu.inference.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qiwu.inference.pojo.EndGoal;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
public interface EndGoalMapper extends BaseMapper<EndGoal> {
}
package com.qiwu.inference.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qiwu.inference.pojo.Identity;
import com.qiwu.inference.pojo.Person;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
public interface IdentityMapper extends BaseMapper<Identity> {
}
package com.qiwu.inference.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qiwu.inference.pojo.Item;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
public interface ItemMapper extends BaseMapper<Item> {
}
package com.qiwu.inference.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qiwu.inference.pojo.KeyClue;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
public interface KeyClueMapper extends BaseMapper<KeyClue> {
}
package com.qiwu.inference.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qiwu.inference.pojo.Location;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
public interface LocationMapper extends BaseMapper<Location> {
}
package com.qiwu.inference.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qiwu.inference.pojo.Person;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
public interface PersonMapper extends BaseMapper<Person> {
}
package com.qiwu.inference.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qiwu.inference.pojo.PersonRecord;
import java.util.List;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
public interface PersonRecordMapper extends BaseMapper<PersonRecord> {
List<String> getGateNo();
}
package com.qiwu.inference.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qiwu.inference.pojo.Relation;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xingxing.ye
* @since 2022-11-03
*/
public interface RelationMapper extends BaseMapper<Relation> {
}
package com.qiwu.inference.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qiwu.inference.pojo.RelationRecord;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
public interface RelationRecordMapper extends BaseMapper<RelationRecord> {
}
package com.qiwu.inference.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qiwu.inference.pojo.RelationType;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xingxing.ye
* @since 2022-11-03
*/
public interface RelationTypeMapper extends BaseMapper<RelationType> {
}
package com.qiwu.inference.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qiwu.inference.pojo.TaskCondition;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
public interface TaskConditionMapper extends BaseMapper<TaskCondition> {
}
package com.qiwu.inference.generator;
import cn.hutool.core.util.StrUtil;
import cn.hutool.setting.dialect.Props;
import com.baomidou.mybatisplus.core.exceptions.MybatisPlusException;
import com.baomidou.mybatisplus.generator.AutoGenerator;
import com.baomidou.mybatisplus.generator.config.*;
import com.baomidou.mybatisplus.generator.config.po.LikeTable;
import com.baomidou.mybatisplus.generator.config.querys.MySqlQuery;
import com.baomidou.mybatisplus.generator.config.rules.DateType;
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
import com.baomidou.mybatisplus.generator.engine.VelocityTemplateEngine;
import java.util.Collections;
import java.util.Scanner;
/**
* MyBatisPlus代码生成器
*/
public class MyBatisPlusGenerator {
public static void main(String[] args) {
String projectPath = System.getProperty("user.dir");
String moduleName = scanner("模块名");
String[] tableNames = scanner("表名,多个英文逗号分割").split(",");
// 代码生成器
AutoGenerator autoGenerator = new AutoGenerator(initDataSourceConfig());
autoGenerator.global(initGlobalConfig(projectPath));
autoGenerator.packageInfo(initPackageConfig(projectPath,moduleName));
autoGenerator.injection(initInjectionConfig(projectPath, moduleName));
autoGenerator.template(initTemplateConfig());
autoGenerator.strategy(initStrategyConfig(tableNames));
autoGenerator.execute(new VelocityTemplateEngine());
}
/**
* 读取控制台内容信息
*/
private static String scanner(String tip) {
Scanner scanner = new Scanner(System.in);
System.out.println(("请输入" + tip + ":"));
if (scanner.hasNext()) {
String next = scanner.next();
if (StrUtil.isNotEmpty(next)) {
return next;
}
}
throw new MybatisPlusException("请输入正确的" + tip + "!");
}
/**
* 初始化全局配置
*/
private static GlobalConfig initGlobalConfig(String projectPath) {
return new GlobalConfig.Builder()
.outputDir(projectPath + "/src/main/java")
.author("xingxing.ye")
.disableOpenDir()
.enableSwagger()
.dateType(DateType.ONLY_DATE)
.build();
}
/**
* 初始化数据源配置
*/
private static DataSourceConfig initDataSourceConfig() {
Props props = new Props("generator.properties");
String url = props.getStr("dataSource.url");
String username = props.getStr("dataSource.username");
String password = props.getStr("dataSource.password");
return new DataSourceConfig.Builder(url,username,password)
.dbQuery(new MySqlQuery())
.build();
}
/**
* 初始化包配置
*/
private static PackageConfig initPackageConfig(String projectPath,String moduleName) {
Props props = new Props("generator.properties");
return new PackageConfig.Builder()
.moduleName(moduleName)
.parent(props.getStr("package.base"))
.entity("model")
.pathInfo(Collections.singletonMap(OutputFile.xml, projectPath + "/src/main/resources/com/qiwu/api/dao/" + moduleName))
.build();
}
/**
* 初始化模板配置
*/
private static TemplateConfig initTemplateConfig() {
//可以对controller、service、entity模板进行配置
return new TemplateConfig.Builder().build();
}
/**
* 初始化策略配置
*/
private static StrategyConfig initStrategyConfig(String[] tableNames) {
StrategyConfig.Builder builder = new StrategyConfig.Builder();
builder.entityBuilder()
.naming(NamingStrategy.underline_to_camel)
.columnNaming(NamingStrategy.underline_to_camel)
.enableLombok()
.formatFileName("%s")
.mapperBuilder()
.enableBaseResultMap()
.formatMapperFileName("%sMapper")
.formatXmlFileName("%sMapper")
.serviceBuilder()
.formatServiceFileName("%sService")
.formatServiceImplFileName("%sServiceImpl")
.controllerBuilder()
.enableRestStyle()
.formatFileName("%sController");
//当表名中带*号时可以启用通配符模式
if (tableNames.length == 1 && tableNames[0].contains("*")) {
String[] likeStr = tableNames[0].split("_");
String likePrefix = likeStr[0] + "_";
builder.likeTable(new LikeTable(likePrefix));
} else {
builder.addInclude(tableNames);
}
return builder.build();
}
/**
* 初始化自定义配置
*/
private static InjectionConfig initInjectionConfig(String projectPath, String moduleName) {
// 自定义配置
return new InjectionConfig.Builder().build();
}
}
\ No newline at end of file
package com.qiwu.inference.pojo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
*
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
@Getter
@Setter
@ApiModel(value = "Behaviour对象", description = "")
public class Behaviour implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("行为id")
private Integer id;
@ApiModelProperty("行为名称")
private String name;
@ApiModelProperty("行为描述")
private String description;
@ApiModelProperty("发生的概率")
private double generationProbability;
@ApiModelProperty("行为对象身份(B)")
private String objectIdentity;
@ApiModelProperty("关联对象id")
private String associatedId;
@ApiModelProperty("行为人性格喜好|概率增减(A)")
private String subjectDisposition;
@ApiModelProperty("行为人身份|概率增减(A)")
private String subjectIdentityProbability;
@ApiModelProperty("行为对象身份|概率增减(B)")
private String objectIdentityProbability;
@ApiModelProperty("与行为对象关系|概率影响(A与B)")
private String objectRelationProbability;
@ApiModelProperty("行为对象性格喜好|概率影响(B)")
private String objectDispositionProbability;
@ApiModelProperty("行为人性别|行为对象性别|概率影响(A)")
private String genderProbability;
@ApiModelProperty("互斥行为")
private String exclusionBehaviour;
@ApiModelProperty("反向行为")
private String inverseBehaviour;
@ApiModelProperty("反向行为标签:0为非反向行为,1为反向行为")
private int inverseLabel;
@ApiModelProperty("单人行为标签:0为双人行为,1为单人行为")
private int singleLabel;
@ApiModelProperty("信息级别")
private int infoLevel;
@ApiModelProperty("创建时间")
private Date createTime;
@ApiModelProperty("更新时间")
private Date updateTime;
}
package com.qiwu.inference.pojo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
*
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
@Getter
@Setter
@TableName("behaviour_record")
@ApiModel(value = "BehaviourRecord对象", description = "")
public class BehaviourRecord implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("行为记录id")
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@ApiModelProperty("行为名称")
private String name;
@ApiModelProperty("行为id")
private int behaviourId;
@ApiModelProperty("行为描述")
private String description;
@ApiModelProperty("主体:1")
private int subject;
@ApiModelProperty("主体名称:老王")
private String subjectName;
@ApiModelProperty("客体:2")
private int object;
@ApiModelProperty("客体名称:小美")
private String objectName;
@ApiModelProperty("创建时间")
private Date createTime;
@ApiModelProperty("更新时间")
private Date updateTime;
}
package com.qiwu.inference.pojo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
*
* </p>
*
* @author xingxing.ye
* @since 2022-11-07
*/
@Getter
@Setter
@ApiModel(value = "Clue对象", description = "")
public class Clue implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("id")
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@ApiModelProperty("线索名称")
private String name;
@ApiModelProperty("描述")
private String description;
@ApiModelProperty("类型: 1:身份 2:场所 3:性格爱好 4:行为 5:关系 6:任务")
private int type;
@ApiModelProperty("对应的Id")
private int associatedId;
@ApiModelProperty("线索模板")
private String clueTemplate;
@ApiModelProperty("信息级别")
private int infoLevel;
@ApiModelProperty("信任度")
private int trustDegree;
@ApiModelProperty("威胁度")
private int deterrenceDegree;
@ApiModelProperty("概率")
private String prob;
@ApiModelProperty("自己的信任度")
private int myTrustDegree;
@ApiModelProperty("自己的威胁度")
private int myDeterrenceDegree;
@ApiModelProperty("积分")
private int score;
@ApiModelProperty("创建时间")
private Date createTime;
@ApiModelProperty("更新时间")
private Date updateTime;
}
package com.qiwu.inference.pojo;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
*
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
@Getter
@Setter
@TableName("clue_record")
@ApiModel(value = "ClueRecord对象", description = "")
public class ClueRecord implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("id")
private Integer id;
@ApiModelProperty("线索id")
private int clueId;
@ApiModelProperty("线索名称")
private String clueName;
@ApiModelProperty("主体")
private int subject;
@ApiModelProperty("客体")
private int object;
@ApiModelProperty("描述")
private String description;
@ApiModelProperty("类型: 1:身份 2:场所 3:性格爱好 4:行为 5:关系 6:任务 9:关键线索 ")
private int type;
@ApiModelProperty("信息级别")
private int infoLevel;
@ApiModelProperty("关联人物")
private int associatedPerson;
@ApiModelProperty("线索模板")
private String clueTemplate;
@ApiModelProperty("信任度")
private int trustDegree;
@ApiModelProperty("威胁")
private int deterrenceDegree;
@ApiModelProperty("创建时间")
private Date createTime;
@ApiModelProperty("更新时间")
private Date updateTime;
}
package com.qiwu.inference.pojo;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
*
* </p>
*
* @author xingxing.ye
* @since 2022-11-07
*/
@Getter
@Setter
@TableName("demand_task")
@ApiModel(value = "DemandTask对象", description = "")
public class DemandTask implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("id")
private Integer id;
@ApiModelProperty("名称")
private String name;
@ApiModelProperty("任务组")
private int taskGroup;
@ApiModelProperty("描述")
private String description;
@ApiModelProperty("主体必要身份")
private String subjectNeedIdentity;
@ApiModelProperty("客体必要身份")
private String objectNeedIdentity;
@ApiModelProperty("主体必要性别")
private String subjectNeedGender;
@ApiModelProperty("客体必要性别")
private String objectNeedGender;
@ApiModelProperty("开启条件信任度")
private String trustCondition;
@ApiModelProperty("开启条件威慑度")
private String deterrenceCondition;
@ApiModelProperty("后置任务")
private String postTask;
@ApiModelProperty("条件1|次数")
private String condition1;
@ApiModelProperty("条件2|次数")
private String condition2;
@ApiModelProperty("关联喜好")
private String associatedDisposition;
@ApiModelProperty("关联身份")
private String associatedIdentity;
@ApiModelProperty("关联行为")
private String associatedBehaviour;
@ApiModelProperty("关联关系")
private String associatedRelation;
@ApiModelProperty("互斥关系")
private String exclusiveTask;
@ApiModelProperty("信任度增减")
private int trustDegree;
@ApiModelProperty("威慑度增减")
private int deterrenceDegree;
@ApiModelProperty("完成奖励")
private String completionReward;
@ApiModelProperty("声望增减")
private int reputation;
@ApiModelProperty("有效次数")
private int effectiveDegree;
@ApiModelProperty("特殊任务 0 主动任务 1 被动任务")
private int specialTask;
@ApiModelProperty("信息级别")
private int infoLevel;
@ApiModelProperty("任务标签 1普通任务 2关键任务 3目标任务")
private int taskLabel;
@ApiModelProperty("线索开关 0代表不需要线索就可执行,1代表需要线索才能执行此任务")
private int clueSwitch;
@ApiModelProperty("自动触发")
private int isAuto;
@ApiModelProperty("负面任务")
private int negativeTask;
@ApiModelProperty("创建时间")
private Date createTime;
@ApiModelProperty("更新时间")
private Date updateTime;
}
package com.qiwu.inference.pojo;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
*
* </p>
*
* @author xingxing.ye
* @since 2022-11-07
*/
@Getter
@Setter
@TableName("demand_task_record")
@ApiModel(value = "DemandTaskRecord对象", description = "")
public class DemandTaskRecord implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("id")
private Integer id;
@ApiModelProperty("demandTaskId")
private int demandTaskId;
@ApiModelProperty("名称")
private String name;
@ApiModelProperty("任务组")
private int taskGroup;
@ApiModelProperty("描述")
private String description;
@ApiModelProperty("主体")
private int subject;
@ApiModelProperty("客体")
private int object;
@ApiModelProperty("类型: 1:身份 2:场所 3:性格爱好 4:行为 5:关系 6:任务 9:关键线索")
private int type;
@ApiModelProperty("线索id")
private int clueId;
@ApiModelProperty("信息级别")
private int infoLevel;
@ApiModelProperty("任务标签 1普通任务 2关键任务 3目标任")
private int taskLabel;
@ApiModelProperty("线索开关 0代表不需要线索就可执行,1代表需要线索才能执行此任务")
private int clueSwitch;
@ApiModelProperty("自动触发")
private int isAuto;
@ApiModelProperty("创建时间")
private Date createTime;
@ApiModelProperty("更新时间")
private Date updateTime;
}
package com.qiwu.inference.pojo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
*
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
@Getter
@Setter
@ApiModel(value = "Disposition对象", description = "")
public class Disposition implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("性格id")
private Integer id;
@ApiModelProperty("性格名称")
private String name;
@ApiModelProperty("性格描述")
private String description;
@ApiModelProperty("类型")
private int type;
@ApiModelProperty("基础权重")
private int weight;
@ApiModelProperty("身份影响权重:")
private String identityWeight;
@ApiModelProperty("性别影响概率:")
private String genderWeight;
@ApiModelProperty("年龄影响权重:")
private String ageWeight;
@ApiModelProperty("信任度初始值")
private String trustDegree;
@ApiModelProperty("威胁度初始值")
private String deterrenceDegree;
@ApiModelProperty("弱点条件:")
private String weaknessCondition;
@ApiModelProperty("对应物品|好感度增减:")
private String itemFavorDegree;
@ApiModelProperty("对应身份|好感度增减:")
private String identityFavorDegree;
@ApiModelProperty("互斥性格|喜好:")
private String exclusionDisposition;
@ApiModelProperty("信息重要级别")
private int infoLevel;
@ApiModelProperty("创建时间")
private Date createTime;
@ApiModelProperty("更新时间")
private Date updateTime;
}
package com.qiwu.inference.pojo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
*
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
@Getter
@Setter
@ApiModel(value = "DispositionRecord对象", description = "")
public class DispositionRecord implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("id")
private Integer id;
@ApiModelProperty("性格id")
private int dispositionId;
@ApiModelProperty("人物id")
private int subject;
@ApiModelProperty("性格名称")
private String name;
@ApiModelProperty("性格描述")
private String description;
@ApiModelProperty("类型")
private int type;
@ApiModelProperty("创建时间")
private Date createTime;
@ApiModelProperty("更新时间")
private Date updateTime;
}
package com.qiwu.inference.pojo;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
*
* </p>
*
* @author xingxing.ye
* @since 2022-11-04
*/
@Getter
@Setter
@TableName("disposition_type")
@ApiModel(value = "DispositionType对象", description = "")
public class DispositionType implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("关系类型id")
private Integer id;
@ApiModelProperty("名称")
private String name;
@ApiModelProperty("描述")
private String description;
@ApiModelProperty("概率")
private String probability;
@ApiModelProperty("创建时间")
private Date createTime;
@ApiModelProperty("更新时间")
private Date updateTime;
}
package com.qiwu.inference.pojo;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
*
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
@Getter
@Setter
@TableName("end_goal")
@ApiModel(value = "EndGoal对象", description = "")
public class EndGoal implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("结局目标id")
private Integer id;
@ApiModelProperty("目标名称")
private String name;
@ApiModelProperty("目标描述")
private String description;
@ApiModelProperty("组合表:1|2|3|4|5")
private String clueGroup;
@ApiModelProperty("创建时间")
private Date createTime;
@ApiModelProperty("更新时间")
private Date updateTime;
}
package com.qiwu.inference.pojo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
*
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
@Getter
@Setter
@ApiModel(value = "Identity对象", description = "")
public class Identity implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("id")
private Integer id;
@ApiModelProperty("身份名称")
private String name;
@ApiModelProperty("描述")
private String description;
@ApiModelProperty("关键身份")
private int keyIdentity;
@ApiModelProperty("对应性别")
private int gender;
@ApiModelProperty("最大人数")
private int maxNum;
@ApiModelProperty("信息级别")
private int infoLevel;
@ApiModelProperty("创建时间")
private Date createTime;
@ApiModelProperty("更新时间")
private Date updateTime;
}
package com.qiwu.inference.pojo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
*
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
@Getter
@Setter
@ApiModel(value = "Item对象", description = "")
public class Item implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("id")
private Integer id;
@ApiModelProperty("名称")
private String name;
@ApiModelProperty("描述")
private String description;
@ApiModelProperty("价格")
private String price;
@ApiModelProperty("创建时间")
private Date createTime;
@ApiModelProperty("更新时间")
private Date updateTime;
}
package com.qiwu.inference.pojo;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
*
* </p>
*
* @author xingxing.ye
* @since 2022-11-03
*/
@Getter
@Setter
@TableName("key_clue")
@ApiModel(value = "KeyClue对象", description = "")
public class KeyClue implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("关键线索id")
private Integer id;
@ApiModelProperty("名称")
private String name;
@ApiModelProperty("描述")
private String description;
@ApiModelProperty("关键人物身份(甲)")
private String subjectIdentity;
@ApiModelProperty("人物标签(甲)")
private int subjectLabel;
@ApiModelProperty("掌握线索人物身份(乙)")
private String objectIdentity;
@ApiModelProperty("人物标签(乙)")
private int objectLabel;
@ApiModelProperty("关系(留空为自己)")
private String relation;
@ApiModelProperty("前置线索:90002|90003")
private String precue;
@ApiModelProperty("线索组合")
private int clueGroup;
@ApiModelProperty("对应目标")
private int target;
@ApiModelProperty("对应任务")
private String associatedTask;
@ApiModelProperty("信息等级")
private int infoLevel;
@ApiModelProperty("创建时间")
private Date createTime;
@ApiModelProperty("更新时间")
private Date updateTime;
}
package com.qiwu.inference.pojo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
*
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
@Getter
@Setter
@ApiModel(value = "Location对象", description = "")
public class Location implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("场所id")
private Integer id;
@ApiModelProperty("场所名称")
private String name;
@ApiModelProperty("描述")
private String description;
@ApiModelProperty("关键场所")
private String keyLocation;
@ApiModelProperty("是否隐藏")
private int isHidden;
@ApiModelProperty("创建时间")
private Date createTime;
@ApiModelProperty("更新时间")
private Date updateTime;
}
package com.qiwu.inference.pojo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
*
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
@Getter
@Setter
@ApiModel(value = "Person对象", description = "")
public class Person implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("id")
private Integer id;
@ApiModelProperty("人物名称")
private String name;
@ApiModelProperty("身份名称")
private String identityName;
@ApiModelProperty("身份id")
private int identityId;
@ApiModelProperty("对应年龄")
private String age;
@ApiModelProperty("对应场所")
private int location;
@ApiModelProperty("对应性别")
private int gender;
@ApiModelProperty("特定性格")
private String specialDisposition;
@ApiModelProperty("亲缘关系")
private String kinship;
@ApiModelProperty("信息重要级别")
private int infoLevel;
@ApiModelProperty("友好人物")
private int friendly;
@ApiModelProperty("创建时间")
private Date createTime;
@ApiModelProperty("更新时间")
private Date updateTime;
}
package com.qiwu.inference.pojo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* <p>
*
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
@Getter
@Setter
@TableName("person_record")
@ApiModel(value = "PersonRecord对象", description = "")
public class PersonRecord implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("人物id")
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@ApiModelProperty("关卡编号")
private String gateNo;
@ApiModelProperty("人物名称")
private String name;
@ApiModelProperty("人物id")
private int personId;
@ApiModelProperty("身份id")
private int identityId;
@ApiModelProperty("身份名称")
private String identityName;
@ApiModelProperty("年龄")
private int age;
@ApiModelProperty("是否为关键人物 1 关键人物 2 普通人物")
private int isKey;
@ApiModelProperty("性别")
private int gender;
@ApiModelProperty("所在地")
private int location;
@ApiModelProperty("性格")
private String disposition;
@ApiModelProperty("友好人物")
private int friendly;
@ApiModelProperty("人物拥有的关系")
@TableField(exist = false)
private List<RelationRecord> relations;
@ApiModelProperty("人物拥有的行为")
@TableField(exist = false)
private List<BehaviourRecord> behaviours;
@ApiModelProperty("人物掌握的线索集合")
@TableField(exist = false)
private List<ClueRecord> clues;
@ApiModelProperty("创建时间")
private Date createTime;
@ApiModelProperty("更新时间")
private Date updateTime;
}
package com.qiwu.inference.pojo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
*
* </p>
*
* @author xingxing.ye
* @since 2022-11-03
*/
@Getter
@Setter
@ApiModel(value = "Relation对象", description = "")
public class Relation implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("关系id")
private Integer id;
@ApiModelProperty("关系名称")
private String name;
@ApiModelProperty("关系描述")
private String description;
@ApiModelProperty("关系类型")
private int type;
@ApiModelProperty("权重")
private int weight;
@ApiModelProperty("自身|关系人性别影响权重")
private String genderWeight;
@ApiModelProperty("年龄影响概率增减")
private String ageWeight;
@ApiModelProperty("年龄差影响概率增减")
private String ageGapsWeight;
@ApiModelProperty("身份影响概率增减")
private String identityWeight;
@ApiModelProperty("性格/喜好影响概率增减")
private String dispositionWeight;
@ApiModelProperty("关系人排除身份")
private String exclusionIdentity;
@ApiModelProperty("互斥关系")
private String exclusionRelation;
@ApiModelProperty("反向关系")
private String inverseRelation;
@ApiModelProperty("信息重要级别")
private int infoLevel;
@ApiModelProperty("掌握信息级别")
private int masterInfoLevel;
@ApiModelProperty("创建时间")
private Date createTime;
@ApiModelProperty("更新时间")
private Date updateTime;
}
package com.qiwu.inference.pojo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
*
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
@Getter
@Setter
@TableName("relation_record")
@ApiModel(value = "RelationRecord对象", description = "")
public class RelationRecord implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("id")
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@ApiModelProperty("关系名称")
private String name;
@ApiModelProperty("关系描述")
private String description;
@ApiModelProperty("类型")
private int type;
@ApiModelProperty("关系id")
private int relationId;
@ApiModelProperty("关系的主体")
private int subject;
@ApiModelProperty("主体名称:老王")
private String subjectName;
@ApiModelProperty("关系客体")
private int object;
@ApiModelProperty("客体名称:老王")
private String objectName;
@ApiModelProperty("掌握信息级别")
private int masterInfoLevel;
@ApiModelProperty("创建时间")
private Date createTime;
@ApiModelProperty("更新时间")
private Date updateTime;
}
package com.qiwu.inference.pojo;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
*
* </p>
*
* @author xingxing.ye
* @since 2022-11-03
*/
@Getter
@Setter
@TableName("relation_type")
@ApiModel(value = "RelationType对象", description = "")
public class RelationType implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("关系类型id")
private Integer id;
@ApiModelProperty("名称")
private String name;
@ApiModelProperty("描述")
private String description;
@ApiModelProperty("概率")
private String probability;
@ApiModelProperty("身份影响概率增减")
private String identityProbability;
@ApiModelProperty("性格/喜好影响概率增减")
private String dispositionProbability;
@ApiModelProperty("创建时间")
private Date createTime;
@ApiModelProperty("更新时间")
private Date updateTime;
}
package com.qiwu.inference.pojo;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
* 任务条件
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
@Getter
@Setter
@TableName("task_condition")
@ApiModel(value = "TaskCondition对象", description = "")
public class TaskCondition implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("id")
private Integer id;
@ApiModelProperty("名称")
private String name;
@ApiModelProperty("描述")
private String description;
@ApiModelProperty("创建时间")
private Date createTime;
@ApiModelProperty("更新时间")
private Date updateTime;
}
package com.qiwu.inference.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.qiwu.inference.pojo.BehaviourRecord;
import java.util.List;
/**
* <p>
* 服务类
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
public interface BehaviourRecordService extends IService<BehaviourRecord> {
List<BehaviourRecord> getBehaviourRecords(Integer subject);
List<BehaviourRecord> getBehaviourRecords(Integer object, Integer behaviourId);
List<BehaviourRecord> getBehaviourRecordsNoSubject(Integer subject, Integer behaviourId);
Boolean isExists(Integer subject, Integer behaviourId);
Boolean isExists(Integer subject,Integer object, Integer behaviourId);
}
package com.qiwu.inference.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.qiwu.inference.pojo.Behaviour;
import com.qiwu.inference.pojo.DemandTask;
import java.util.List;
/**
* <p>
* 服务类
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
public interface BehaviourService extends IService<Behaviour> {
List<Behaviour> list(Integer inverseLabel);
}
package com.qiwu.inference.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.qiwu.inference.pojo.ClueRecord;
import java.util.List;
/**
* <p>
* 服务类
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
public interface ClueRecordService extends IService<ClueRecord> {
List<ClueRecord> getClueRecords(Integer subject);
List<ClueRecord> getClueRecords(Integer subject,Integer infoLevel);
Boolean isExists(ClueRecord clueRecord);
void delete(Integer clueId,Integer subjectId,Integer objectId);
}
package com.qiwu.inference.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.qiwu.inference.pojo.Clue;
import io.swagger.v3.oas.models.security.SecurityScheme;
/**
* <p>
* 服务类
* </p>
*
* @author xingxing.ye
* @since 2022-11-07
*/
public interface ClueService extends IService<Clue> {
Clue getClue(Integer type,Integer associatedId);
}
package com.qiwu.inference.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.qiwu.inference.pojo.Clue;
import com.qiwu.inference.pojo.DemandTaskRecord;
import com.qiwu.inference.pojo.KeyClue;
import java.util.List;
/**
* <p>
* 服务类
* </p>
*
* @author xingxing.ye
* @since 2022-11-07
*/
public interface DemandTaskRecordService extends IService<DemandTaskRecord> {
List<DemandTaskRecord> getDemandTaskRecords(Integer subject);
Boolean isExists(Integer subjectId,Integer demandTaskId);
Boolean isExistsTaskGroup(Integer subjectId,Integer taskGroup);
Boolean isExists(DemandTaskRecord demandTaskRecord);
void delete(Integer demandTaskId,Integer subjectId,Integer objectId);
List<DemandTaskRecord> getDemandTaskRecords(Integer demandTaskId,Integer subjectId,Integer objectId);
}
package com.qiwu.inference.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.qiwu.inference.pojo.DemandTask;
import com.qiwu.inference.pojo.DemandTaskRecord;
import java.util.List;
/**
* <p>
* 服务类
* </p>
*
* @author xingxing.ye
* @since 2022-11-07
*/
public interface DemandTaskService extends IService<DemandTask> {
List<DemandTask> list(Integer specialTask,Integer taskLabel);
List<DemandTask> list(Integer taskGroup,Integer specialTask,Integer taskLabel);
int getTaskGroupSize();
}
package com.qiwu.inference.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.qiwu.inference.pojo.DispositionRecord;
import java.util.List;
/**
* <p>
* 服务类
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
public interface DispositionRecordService extends IService<DispositionRecord> {
List<DispositionRecord> getDispositionRecords(Integer subject ,Integer dispositionId);
List<DispositionRecord> getDispositionRecords(Integer subject );
List<DispositionRecord> getDispositionRecordsNoSubject(Integer subject ,Integer dispositionId);
}
package com.qiwu.inference.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.qiwu.inference.pojo.Disposition;
import java.util.List;
/**
* <p>
* 服务类
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
public interface DispositionService extends IService<Disposition> {
List<Disposition> getDispositions(Integer type);
}
package com.qiwu.inference.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.qiwu.inference.pojo.DispositionType;
/**
* <p>
* 服务类
* </p>
*
* @author xingxing.ye
* @since 2022-11-04
*/
public interface DispositionTypeService extends IService<DispositionType> {
}
package com.qiwu.inference.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.qiwu.inference.pojo.EndGoal;
/**
* <p>
* 服务类
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
public interface EndGoalService extends IService<EndGoal> {
}
package com.qiwu.inference.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.qiwu.inference.pojo.Identity;
import com.qiwu.inference.pojo.Person;
import java.util.List;
/**
* <p>
* 服务类
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
public interface IdentityService extends IService<Identity> {
List<Identity> getIdentitys(String keyIdentity);
}
package com.qiwu.inference.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.qiwu.inference.pojo.Item;
/**
* <p>
* 服务类
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
public interface ItemService extends IService<Item> {
}
package com.qiwu.inference.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.qiwu.inference.pojo.KeyClue;
import java.util.List;
/**
* <p>
* 服务类
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
public interface KeyClueService extends IService<KeyClue> {
List<KeyClue> getKeyClues(String clueGroup);
}
package com.qiwu.inference.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.qiwu.inference.pojo.Location;
/**
* <p>
* 服务类
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
public interface LocationService extends IService<Location> {
}
package com.qiwu.inference.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.qiwu.inference.pojo.PersonRecord;
import java.util.List;
/**
* <p>
* 服务类
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
public interface PersonRecordService extends IService<PersonRecord> {
List<PersonRecord> getPersonRecords(String gateNo);
PersonRecord getPersonRecords(Integer personId,String gateNo);
List<PersonRecord> getPersonRecordsNoSubject(Integer subject,Integer identityId);
List<String> getGateNo();
}
package com.qiwu.inference.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.qiwu.inference.pojo.Person;
import java.util.List;
/**
* <p>
* 服务类
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
public interface PersonService extends IService<Person> {
List<Person> getPersons(Integer indentityId);
}
package com.qiwu.inference.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.qiwu.inference.pojo.RelationRecord;
import java.util.List;
/**
* <p>
* 服务类
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
public interface RelationRecordService extends IService<RelationRecord> {
List<RelationRecord> getRelationRecords(Integer subject);
List<RelationRecord> getRelationRecordsNoSubject(Integer subject,Integer relationId);
Boolean isExistsRelationTypes(Integer subject,Integer object,Integer type);
List<RelationRecord> getInverseRelationRecords(Integer object);
Boolean isExists(Integer subjectId,Integer objectId,Integer relationId);
}
package com.qiwu.inference.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.qiwu.inference.pojo.Relation;
import java.util.List;
/**
* <p>
* 服务类
* </p>
*
* @author xingxing.ye
* @since 2022-11-03
*/
public interface RelationService extends IService<Relation> {
List<Relation> getRelations(Integer type);
Boolean isExists(String[] relationIds);
List<Relation> getRelations(String[] relationIds);
}
package com.qiwu.inference.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.qiwu.inference.pojo.RelationType;
import java.util.List;
/**
* <p>
* 服务类
* </p>
*
* @author xingxing.ye
* @since 2022-11-03
*/
public interface RelationTypeService extends IService<RelationType> {
List<RelationType> list(Integer type);
}
package com.qiwu.inference.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.qiwu.inference.pojo.TaskCondition;
/**
* <p>
* 服务类
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
public interface TaskConditionService extends IService<TaskCondition> {
}
package com.qiwu.inference.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qiwu.inference.dao.BehaviourRecordMapper;
import com.qiwu.inference.pojo.BehaviourRecord;
import com.qiwu.inference.service.BehaviourRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* <p>
* 服务实现类
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
@Service
public class BehaviourRecordServiceImpl extends ServiceImpl<BehaviourRecordMapper, BehaviourRecord> implements BehaviourRecordService {
@Autowired
private BehaviourRecordMapper behaviourRecordMapper;
@Override
public List<BehaviourRecord> getBehaviourRecords(Integer subject) {
QueryWrapper<BehaviourRecord> wrapper = new QueryWrapper<>();
wrapper.lambda().eq(BehaviourRecord::getSubject,subject);
return list(wrapper);
}
@Override
public List<BehaviourRecord> getBehaviourRecords(Integer object, Integer behaviourId) {
QueryWrapper<BehaviourRecord> wrapper = new QueryWrapper<>();
wrapper.lambda().eq(BehaviourRecord::getObject,object);
wrapper.lambda().eq(BehaviourRecord::getBehaviourId,behaviourId);
return list(wrapper);
}
@Override
public List<BehaviourRecord> getBehaviourRecordsNoSubject(Integer subject, Integer behaviourId) {
QueryWrapper<BehaviourRecord> wrapper = new QueryWrapper<>();
wrapper.lambda().eq(BehaviourRecord::getBehaviourId,behaviourId);
wrapper.lambda().and(temp ->temp.ne(BehaviourRecord::getSubject, subject).or().ne(BehaviourRecord::getObject, subject));
return list(wrapper);
}
@Override
public Boolean isExists(Integer subject, Integer behaviourId) {
QueryWrapper<BehaviourRecord> wrapper = new QueryWrapper<>();
wrapper.lambda().eq(BehaviourRecord::getSubject,subject);
wrapper.lambda().eq(BehaviourRecord::getBehaviourId,behaviourId);
return behaviourRecordMapper.exists(wrapper);
}
@Override
public Boolean isExists(Integer subject, Integer object, Integer behaviourId) {
QueryWrapper<BehaviourRecord> wrapper = new QueryWrapper<>();
wrapper.lambda().eq(BehaviourRecord::getSubject,subject);
wrapper.lambda().eq(BehaviourRecord::getObject,object);
wrapper.lambda().eq(BehaviourRecord::getBehaviourId,behaviourId);
return behaviourRecordMapper.exists(wrapper);
}
}
package com.qiwu.inference.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qiwu.inference.dao.BehaviourMapper;
import com.qiwu.inference.pojo.Behaviour;
import com.qiwu.inference.pojo.DemandTask;
import com.qiwu.inference.service.BehaviourService;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* <p>
* 服务实现类
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
@Service
public class BehaviourServiceImpl extends ServiceImpl<BehaviourMapper, Behaviour> implements BehaviourService {
@Override
public List<Behaviour> list(Integer inverseLabel) {
QueryWrapper<Behaviour> wrapper = new QueryWrapper<>();
wrapper.lambda().eq(Behaviour::getInverseLabel,inverseLabel);
return list(wrapper);
}
}
package com.qiwu.inference.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qiwu.inference.dao.ClueRecordMapper;
import com.qiwu.inference.pojo.ClueRecord;
import com.qiwu.inference.service.ClueRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.List;
/**
* <p>
* 服务实现类
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
@Service
public class ClueRecordServiceImpl extends ServiceImpl<ClueRecordMapper, ClueRecord> implements ClueRecordService {
@Autowired
private ClueRecordMapper clueRecordMapper;
@Override
public List<ClueRecord> getClueRecords(Integer subject) {
QueryWrapper<ClueRecord> wrapper = new QueryWrapper<>();
wrapper.lambda().eq(ClueRecord::getAssociatedPerson,subject);
return list(wrapper);
}
@Override
public List<ClueRecord> getClueRecords(Integer subject, Integer infoLevel) {
QueryWrapper<ClueRecord> wrapper = new QueryWrapper<>();
wrapper.lambda().eq(ClueRecord::getAssociatedPerson,subject);
wrapper.lambda().le(ClueRecord::getInfoLevel,infoLevel);
return list(wrapper);
}
@Override
public Boolean isExists(ClueRecord clueRecord) {
QueryWrapper<ClueRecord> wrapper = new QueryWrapper<>();
if(clueRecord.getClueId()!=0){
wrapper.eq("clue_id",clueRecord.getClueId());
}
if(!StringUtils.isEmpty(clueRecord.getClueName())){
wrapper.eq("clue_name",clueRecord.getClueName());
}
if(clueRecord.getSubject()!=0){
wrapper.eq("subject",clueRecord.getSubject());
}
if(!StringUtils.isEmpty(clueRecord.getClueTemplate())){
wrapper.eq("clue_template",clueRecord.getClueTemplate());
}
if(clueRecord.getAssociatedPerson()!=0){
wrapper.eq("associated_person",clueRecord.getAssociatedPerson());
}
if(clueRecord.getType()!=0){
wrapper.eq("type",clueRecord.getType());
}
return clueRecordMapper.exists(wrapper);
}
@Override
public void delete(Integer clueId, Integer subjectId, Integer objectId) {
QueryWrapper<ClueRecord> wrapper = new QueryWrapper<>();
wrapper.eq("clue_id",clueId);
wrapper.eq("subject",subjectId);
wrapper.eq("object",objectId);
clueRecordMapper.delete(wrapper);
}
}
package com.qiwu.inference.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qiwu.inference.dao.ClueMapper;
import com.qiwu.inference.pojo.Clue;
import com.qiwu.inference.service.ClueService;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author xingxing.ye
* @since 2022-11-07
*/
@Service
public class ClueServiceImpl extends ServiceImpl<ClueMapper, Clue> implements ClueService {
@Override
public Clue getClue(Integer type, Integer associatedId) {
QueryWrapper<Clue> wrapper = new QueryWrapper<>();
wrapper.lambda().eq(Clue::getType,type);
wrapper.lambda().eq(Clue::getAssociatedId,associatedId);
return getOne(wrapper);
}
}
package com.qiwu.inference.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qiwu.inference.dao.DemandTaskRecordMapper;
import com.qiwu.inference.pojo.DemandTaskRecord;
import com.qiwu.inference.service.DemandTaskRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.List;
/**
* <p>
* 服务实现类
* </p>
*
* @author xingxing.ye
* @since 2022-11-07
*/
@Service
public class DemandTaskRecordServiceImpl extends ServiceImpl<DemandTaskRecordMapper, DemandTaskRecord> implements DemandTaskRecordService {
@Autowired
private DemandTaskRecordMapper demandTaskRecordMapper;
@Override
public List<DemandTaskRecord> getDemandTaskRecords(Integer subject) {
QueryWrapper<DemandTaskRecord> wrapper = new QueryWrapper<>();
wrapper.lambda().eq(DemandTaskRecord::getSubject,subject);
return list(wrapper);
}
@Override
public Boolean isExists(Integer subjectId, Integer demandTaskId) {
QueryWrapper<DemandTaskRecord> wrapper = new QueryWrapper<>();
wrapper.eq("subject",subjectId);
wrapper.eq("demand_task_id",demandTaskId);
return demandTaskRecordMapper.exists(wrapper);
}
@Override
public Boolean isExistsTaskGroup(Integer subjectId, Integer taskGroup) {
QueryWrapper<DemandTaskRecord> wrapper = new QueryWrapper<>();
wrapper.eq("subject",subjectId);
wrapper.eq("task_group",taskGroup);
return demandTaskRecordMapper.exists(wrapper);
}
@Override
public Boolean isExists(DemandTaskRecord demandTaskRecord) {
QueryWrapper<DemandTaskRecord> wrapper = new QueryWrapper<>();
if(demandTaskRecord.getDemandTaskId()!=0){
wrapper.eq("demand_task_id",demandTaskRecord.getDemandTaskId());
}
if(!StringUtils.isEmpty(demandTaskRecord.getName())){
wrapper.eq("name",demandTaskRecord.getName());
}
if(demandTaskRecord.getSubject()!=0){
wrapper.eq("subject",demandTaskRecord.getSubject());
}
if(demandTaskRecord.getObject()!=0){
wrapper.eq("object",demandTaskRecord.getObject());
}
if(demandTaskRecord.getType()!=0){
wrapper.eq("type",demandTaskRecord.getType());
}
if(demandTaskRecord.getClueId()!=0){
wrapper.eq("clue_id",demandTaskRecord.getClueId());
}
if(demandTaskRecord.getInfoLevel()!=0){
wrapper.eq("info_level",demandTaskRecord.getInfoLevel());
}
if(demandTaskRecord.getTaskLabel()!=0){
wrapper.eq("task_label",demandTaskRecord.getTaskLabel());
}
return demandTaskRecordMapper.exists(wrapper);
}
@Override
public void delete(Integer demandTaskId, Integer subjectId, Integer objectId) {
QueryWrapper<DemandTaskRecord> wrapper = new QueryWrapper<>();
wrapper.eq("demand_task_id",demandTaskId);
wrapper.eq("subject",subjectId);
wrapper.eq("object",objectId);
demandTaskRecordMapper.delete(wrapper);
}
@Override
public List<DemandTaskRecord> getDemandTaskRecords(Integer demandTaskId, Integer subjectId, Integer objectId) {
QueryWrapper<DemandTaskRecord> wrapper = new QueryWrapper<>();
wrapper.eq("demand_task_id",demandTaskId);
wrapper.eq("subject",subjectId);
wrapper.eq("object",objectId);
return list(wrapper);
}
}
package com.qiwu.inference.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qiwu.inference.dao.DemandTaskMapper;
import com.qiwu.inference.pojo.DemandTask;
import com.qiwu.inference.service.DemandTaskService;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* <p>
* 服务实现类
* </p>
*
* @author xingxing.ye
* @since 2022-11-07
*/
@Service
public class DemandTaskServiceImpl extends ServiceImpl<DemandTaskMapper, DemandTask> implements DemandTaskService {
@Override
public List<DemandTask> list(Integer specialTask,Integer taskLabel) {
QueryWrapper<DemandTask> wrapper = new QueryWrapper<>();
wrapper.lambda().eq(DemandTask::getSpecialTask,specialTask);
wrapper.lambda().eq(DemandTask::getTaskLabel,taskLabel);
return list(wrapper);
}
@Override
public List<DemandTask> list(Integer taskGroup, Integer specialTask, Integer taskLabel) {
QueryWrapper<DemandTask> wrapper = new QueryWrapper<>();
wrapper.lambda().eq(DemandTask::getTaskGroup,taskGroup);
wrapper.lambda().eq(DemandTask::getSpecialTask,specialTask);
wrapper.lambda().eq(DemandTask::getTaskLabel,taskLabel);
return list(wrapper);
}
@Override
public int getTaskGroupSize() {
QueryWrapper<DemandTask> wrapper = new QueryWrapper<>();
wrapper.select("task_group");
return list(wrapper).size();
}
}
package com.qiwu.inference.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qiwu.inference.dao.DispositionRecordMapper;
import com.qiwu.inference.pojo.DispositionRecord;
import com.qiwu.inference.pojo.KeyClue;
import com.qiwu.inference.service.DispositionRecordService;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* <p>
* 服务实现类
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
@Service
public class DispositionRecordServiceImpl extends ServiceImpl<DispositionRecordMapper, DispositionRecord> implements DispositionRecordService {
@Override
public List<DispositionRecord> getDispositionRecords(Integer subject, Integer dispositionId) {
QueryWrapper<DispositionRecord> wrapper = new QueryWrapper<>();
wrapper.lambda().eq(DispositionRecord::getSubject,subject);
wrapper.lambda().eq(DispositionRecord::getDispositionId,dispositionId);
return list(wrapper);
}
@Override
public List<DispositionRecord> getDispositionRecords(Integer subject) {
QueryWrapper<DispositionRecord> wrapper = new QueryWrapper<>();
wrapper.lambda().eq(DispositionRecord::getSubject,subject);
return list(wrapper);
}
@Override
public List<DispositionRecord> getDispositionRecordsNoSubject(Integer subject, Integer dispositionId) {
QueryWrapper<DispositionRecord> wrapper = new QueryWrapper<>();
wrapper.lambda().eq(DispositionRecord::getDispositionId,dispositionId);
wrapper.lambda().ne(DispositionRecord::getSubject,subject);
return list(wrapper);
}
}
package com.qiwu.inference.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qiwu.inference.dao.DispositionMapper;
import com.qiwu.inference.pojo.Disposition;
import com.qiwu.inference.pojo.DispositionRecord;
import com.qiwu.inference.service.DispositionService;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* <p>
* 服务实现类
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
@Service
public class DispositionServiceImpl extends ServiceImpl<DispositionMapper, Disposition> implements DispositionService {
@Override
public List<Disposition> getDispositions(Integer type) {
QueryWrapper<Disposition> wrapper = new QueryWrapper<>();
wrapper.lambda().eq(Disposition::getType,type);
return list(wrapper);
}
}
package com.qiwu.inference.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qiwu.inference.dao.DispositionTypeMapper;
import com.qiwu.inference.pojo.DispositionType;
import com.qiwu.inference.service.DispositionTypeService;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author xingxing.ye
* @since 2022-11-04
*/
@Service
public class DispositionTypeServiceImpl extends ServiceImpl<DispositionTypeMapper, DispositionType> implements DispositionTypeService {
}
package com.qiwu.inference.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qiwu.inference.dao.EndGoalMapper;
import com.qiwu.inference.pojo.EndGoal;
import com.qiwu.inference.service.EndGoalService;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
@Service
public class EndGoalServiceImpl extends ServiceImpl<EndGoalMapper, EndGoal> implements EndGoalService {
}
package com.qiwu.inference.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qiwu.inference.dao.IdentityMapper;
import com.qiwu.inference.pojo.Identity;
import com.qiwu.inference.pojo.Person;
import com.qiwu.inference.service.IdentityService;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* <p>
* 服务实现类
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
@Service
public class IdentityServiceImpl extends ServiceImpl<IdentityMapper, Identity> implements IdentityService {
@Override
public List<Identity> getIdentitys(String keyIdentity) {
QueryWrapper<Identity> wrapper = new QueryWrapper<>();
wrapper.lambda().eq(Identity::getKeyIdentity,keyIdentity);
return list(wrapper);
}
}
package com.qiwu.inference.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qiwu.inference.dao.ItemMapper;
import com.qiwu.inference.pojo.Item;
import com.qiwu.inference.service.ItemService;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
@Service
public class ItemServiceImpl extends ServiceImpl<ItemMapper, Item> implements ItemService {
}
package com.qiwu.inference.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qiwu.inference.dao.KeyClueMapper;
import com.qiwu.inference.pojo.KeyClue;
import com.qiwu.inference.service.KeyClueService;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* <p>
* 服务实现类
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
@Service
public class KeyClueServiceImpl extends ServiceImpl<KeyClueMapper, KeyClue> implements KeyClueService {
@Override
public List<KeyClue> getKeyClues(String clueGroup) {
QueryWrapper<KeyClue> wrapper = new QueryWrapper<>();
wrapper.lambda().eq(KeyClue::getClueGroup,clueGroup);
return list(wrapper);
}
}
package com.qiwu.inference.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qiwu.inference.dao.LocationMapper;
import com.qiwu.inference.pojo.Location;
import com.qiwu.inference.service.LocationService;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
@Service
public class LocationServiceImpl extends ServiceImpl<LocationMapper, Location> implements LocationService {
}
package com.qiwu.inference.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qiwu.inference.dao.PersonRecordMapper;
import com.qiwu.inference.pojo.BehaviourRecord;
import com.qiwu.inference.pojo.ClueRecord;
import com.qiwu.inference.pojo.DispositionRecord;
import com.qiwu.inference.pojo.PersonRecord;
import com.qiwu.inference.service.PersonRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* <p>
* 服务实现类
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
@Service
public class PersonRecordServiceImpl extends ServiceImpl<PersonRecordMapper, PersonRecord> implements PersonRecordService {
@Autowired
PersonRecordMapper personRecordMapper;
@Override
public List<PersonRecord> getPersonRecords(String gateNo) {
QueryWrapper<PersonRecord> wrapper = new QueryWrapper<>();
wrapper.lambda().eq(PersonRecord::getGateNo,gateNo);
return list(wrapper);
}
@Override
public PersonRecord getPersonRecords(Integer personId,String gateNo) {
QueryWrapper<PersonRecord> wrapper = new QueryWrapper<>();
wrapper.lambda().eq(PersonRecord::getPersonId,personId);
wrapper.lambda().eq(PersonRecord::getGateNo,gateNo);
return getOne(wrapper);
}
@Override
public List<PersonRecord> getPersonRecordsNoSubject(Integer subject, Integer identityId) {
QueryWrapper<PersonRecord> wrapper = new QueryWrapper<>();
wrapper.lambda().eq(PersonRecord::getIdentityId,identityId);
wrapper.lambda().ne(PersonRecord::getId,subject);
return list(wrapper);
}
@Override
public List<String> getGateNo() {
return personRecordMapper.getGateNo();
}
}
package com.qiwu.inference.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qiwu.inference.dao.PersonMapper;
import com.qiwu.inference.pojo.Behaviour;
import com.qiwu.inference.pojo.Person;
import com.qiwu.inference.service.PersonService;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* <p>
* 服务实现类
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
@Service
public class PersonServiceImpl extends ServiceImpl<PersonMapper, Person> implements PersonService {
@Override
public List<Person> getPersons(Integer identityId) {
QueryWrapper<Person> wrapper = new QueryWrapper<>();
wrapper.lambda().eq(Person::getIdentityId,identityId);
return list(wrapper);
}
}
package com.qiwu.inference.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qiwu.inference.dao.RelationMapper;
import com.qiwu.inference.dao.RelationRecordMapper;
import com.qiwu.inference.pojo.BehaviourRecord;
import com.qiwu.inference.pojo.KeyClue;
import com.qiwu.inference.pojo.Relation;
import com.qiwu.inference.pojo.RelationRecord;
import com.qiwu.inference.service.RelationRecordService;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* <p>
* 服务实现类
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
@Service
public class RelationRecordServiceImpl extends ServiceImpl<RelationRecordMapper, RelationRecord> implements RelationRecordService{
@Override
public List<RelationRecord> getRelationRecords(Integer subject) {
QueryWrapper<RelationRecord> wrapper = new QueryWrapper<>();
wrapper.lambda().eq(RelationRecord::getSubject,subject);
return list(wrapper);
}
@Override
public List<RelationRecord> getRelationRecordsNoSubject(Integer subject, Integer relationId) {
QueryWrapper<RelationRecord> wrapper = new QueryWrapper<>();
wrapper.lambda().eq(RelationRecord::getRelationId,relationId);
wrapper.lambda().and(tmp ->tmp.ne(RelationRecord::getSubject, subject).or().ne(RelationRecord::getObject, subject));
return list(wrapper);
}
@Override
public Boolean isExistsRelationTypes(Integer subject, Integer object,Integer type) {
QueryWrapper<RelationRecord> wrapper = new QueryWrapper<>();
wrapper.eq("subject",subject);
wrapper.eq("object",object);
wrapper.eq("type",type);
return list(wrapper).size() > 0;
}
@Override
public List<RelationRecord> getInverseRelationRecords(Integer object) {
QueryWrapper<RelationRecord> wrapper = new QueryWrapper<>();
wrapper.lambda().eq(RelationRecord::getObject,object);
return list(wrapper);
}
@Override
public Boolean isExists(Integer subject, Integer object, Integer relationId) {
QueryWrapper<RelationRecord> wrapper = new QueryWrapper<>();
wrapper.eq("subject",subject);
wrapper.eq("object",object);
wrapper.eq("relation_id",relationId);
return list(wrapper).size() > 0;
}
}
package com.qiwu.inference.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qiwu.inference.dao.RelationMapper;
import com.qiwu.inference.pojo.KeyClue;
import com.qiwu.inference.pojo.Relation;
import com.qiwu.inference.service.RelationService;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* <p>
* 服务实现类
* </p>
*
* @author xingxing.ye
* @since 2022-11-03
*/
@Service
public class RelationServiceImpl extends ServiceImpl<RelationMapper, Relation> implements RelationService {
@Override
public List<Relation> getRelations(Integer type) {
QueryWrapper<Relation> wrapper = new QueryWrapper<>();
wrapper.lambda().eq(Relation::getType,type);
return list(wrapper);
}
@Override
public Boolean isExists(String[] relationIds) {
QueryWrapper<Relation> wrapper = new QueryWrapper<>();
wrapper.in("id",relationIds);
return list(wrapper).size() > 0;
}
@Override
public List<Relation> getRelations(String[] relationIds) {
QueryWrapper<Relation> wrapper = new QueryWrapper<>();
wrapper.in("id",relationIds);
return list(wrapper);
}
}
package com.qiwu.inference.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qiwu.inference.dao.RelationTypeMapper;
import com.qiwu.inference.pojo.PersonRecord;
import com.qiwu.inference.pojo.RelationType;
import com.qiwu.inference.service.RelationTypeService;
import org.springframework.stereotype.Service;
import java.lang.reflect.Type;
import java.util.List;
/**
* <p>
* 服务实现类
* </p>
*
* @author xingxing.ye
* @since 2022-11-03
*/
@Service
public class RelationTypeServiceImpl extends ServiceImpl<RelationTypeMapper, RelationType> implements RelationTypeService {
@Override
public List<RelationType> list(Integer type) {
QueryWrapper<RelationType> wrapper = new QueryWrapper<>();
wrapper.lambda().ne(RelationType::getId, type);
return list(wrapper);
}
}
package com.qiwu.inference.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qiwu.inference.dao.TaskConditionMapper;
import com.qiwu.inference.pojo.TaskCondition;
import com.qiwu.inference.service.TaskConditionService;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
@Service
public class TaskConditionServiceImpl extends ServiceImpl<TaskConditionMapper, TaskCondition> implements TaskConditionService {
}
package com.qiwu.inference.util;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.BeanWrapper;
import org.springframework.beans.BeanWrapperImpl;
import org.springframework.util.StringUtils;
public class BeanUtil {
/**
* 拷贝bean中的属性
* @param source
* @param target
* @param ignores
*/
public static void copyProperties(Object source, Object target, String... ignores){
BeanUtils.copyProperties(source, target, ignores);
}
/**
* 拷贝bean中的属性 忽略掉空值属性和ID属性
* @param source
* @param target
*/
public static void copyPropertiesIgnoreNullValueAndId(Object source, Object target){
copyProperties(source, target, getNullPropertyNamesAndIgnoreNames(source, "id"));
}
/**
* 拷贝bean中的属性 忽略掉空值属性
* @param source
* @param target
*/
public static void copyPropertiesIgnoreNullValue(Object source, Object target){
copyProperties(source, target, getNullPropertyNamesAndIgnoreNames(source));
}
/**
* 获取空值属性名称或者忽略
* @param source
* @param ignores
* @return
*/
public static String[] getNullPropertyNamesAndIgnoreNames (Object source, String... ignores ) {
final BeanWrapper src = new BeanWrapperImpl(source);
java.beans.PropertyDescriptor[] pds = src.getPropertyDescriptors();
Set<String> emptyNames = new HashSet<String>();
if (ignores != null && ignores.length > 0){
emptyNames.addAll(Arrays.asList(ignores));
}
for(java.beans.PropertyDescriptor pd : pds) {
Object srcValue = src.getPropertyValue(pd.getName());
if (srcValue == null) emptyNames.add(pd.getName());
}
String[] result = new String[emptyNames.size()];
return emptyNames.toArray(result);
}
public static String[] convertStringToArray(String ids){
if (StringUtils.isEmpty(ids)){
return null;
}
return ids.split(",");
}
}
package com.qiwu.inference.util;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;
public class DateUtil {
/**
* 仅显示年月日,例如 2015-08-11.
*/
public static final String DATE_FORMAT = "yyyy-MM-dd";
/**
* 显示年月日时分秒,例如 2015-08-11 09:51:53.
*/
public static final String DATETIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
/**
* 仅显示时分秒,例如 09:51:53.
*/
public static final String TIME_FORMAT = "HH:mm:ss";
/**
* 每天的毫秒数 8640000.
*/
public static final long MILLISECONDS_PER_DAY = 86400000L;
/**
* 每周的天数.
*/
public static final long DAYS_PER_WEEK = 7L;
/**
* 每小时毫秒数.
*/
public static final long MILLISECONDS_PER_HOUR = 3600000L;
/**
* 每分钟秒数.
*/
public static final long SECONDS_PER_MINUTE = 60L;
/**
* 每小时秒数.
*/
public static final long SECONDS_PER_HOUR = 3600L;
/**
* 每天秒数.
*/
public static final long SECONDS_PER_DAY = 86400L;
/**
* 每个月秒数,默认每月30天.
*/
public static final long SECONDS_PER_MONTH = 2592000L;
/**
* 每年秒数,默认每年365天.
*/
public static final long SECONDS_PER_YEAR = 31536000L;
/**
* 常用的时间格式.
*/
private static String[] parsePatterns = { "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy/MM/dd",
"yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm" };
/**
* 得到当前日期字符串.
* @return String 日期字符串,例如2015-08-11
* @since 1.0
*/
public static String getDate() {
return getDate(DateUtil.DATE_FORMAT);
}
/**
* 得到当前时间字符串.
* @return String 时间字符串,例如 09:51:53
* @since 1.0
*/
public static String getTime() {
return formatDate(new Date(), DateUtil.TIME_FORMAT);
}
/**
* 得到当前日期和时间字符串.
* @return String 日期和时间字符串,例如 2015-08-11 09:51:53
* @since 1.0
*/
public static String getDateTime() {
return formatDate(new Date(), DateUtil.DATETIME_FORMAT);
}
/**
* 获取当前时间指定格式下的字符串.
* @param pattern
* 转化后时间展示的格式,例如"yyyy-MM-dd","yyyy-MM-dd HH:mm:ss"等
* @return String 格式转换之后的时间字符串.
* @since 1.0
*/
public static String getDate(String pattern) {
return DateFormatUtils.format(new Date(), pattern);
}
/**
* 获取指定日期的字符串格式.
* @param date 需要格式化的时间,不能为空
* @param pattern 时间格式,例如"yyyy-MM-dd","yyyy-MM-dd HH:mm:ss"等
* @return String 格式转换之后的时间字符串.
* @since 1.0
*/
public static String getDate(Date date, String pattern) {
return DateFormatUtils.format(date, pattern);
}
/**
* 获取日期时间字符串,默认格式为(yyyy-MM-dd).
* @param date 需要转化的日期时间
* @param pattern 时间格式,例如"yyyy-MM-dd" "HH:mm:ss" "E"等
* @return String 格式转换后的时间字符串
* @since 1.0
*/
public static String formatDate(Date date, Object... pattern) {
String formatDate = null;
if (pattern != null && pattern.length > 0) {
formatDate = DateFormatUtils.format(date, pattern[0].toString());
} else {
formatDate = DateFormatUtils.format(date, DateUtil.DATE_FORMAT);
}
return formatDate;
}
/**
* 获取当前年份字符串.
* @return String 当前年份字符串,例如 2015
* @since 1.0
*/
public static String getYear() {
return formatDate(new Date(), "yyyy");
}
/**
* 获取当前月份字符串.
* @return String 当前月份字符串,例如 08
* @since 1.0
*/
public static String getMonth() {
return formatDate(new Date(), "MM");
}
/**
* 获取当前天数字符串.
* @return String 当前天数字符串,例如 11
* @since 1.0
*/
public static String getDay() {
return formatDate(new Date(), "dd");
}
/**
* 获取当前星期字符串.
* @return String 当前星期字符串,例如星期二
* @since 1.0
*/
public static String getWeek() {
return formatDate(new Date(), "E");
}
/**
* 将日期型字符串转换为日期格式.
* 支持的日期字符串格式包括"yyyy-MM-dd","yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm",
* "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm"
* @param str
* @return Date
* @since 1.0
*/
public static Date parseDate(Object str) {
if (str == null) {
return null;
}
try {
return DateUtils.parseDate(str.toString(), parsePatterns);
} catch (ParseException e) {
return null;
}
}
/**
* 获取当前日期与指定日期相隔的天数.
* @param date 给定的日期
* @return long 日期间隔天数,正数表示给定日期在当前日期之前,负数表示在当前日期之后
* @since 1.0
*/
public static long pastDays(Date date) {
// 将指定日期转换为yyyy-MM-dd格式
date = DateUtil.parseDate(DateUtil.formatDate(date, DateUtil.DATE_FORMAT));
// 当前日期转换为yyyy-MM-dd格式
Date currentDate = DateUtil.parseDate(DateUtil.formatDate(new Date(), DateUtil.DATE_FORMAT));
long t=0;
if(date!=null&&currentDate!=null){
t = (currentDate.getTime() - date.getTime()) / DateUtil.MILLISECONDS_PER_DAY;
}
return t;
}
/**
* 获取当前日期指定天数之后的日期.
* @param num 相隔天数
* @return Date 日期
* @since 1.0
*/
public static Date nextDay(int num) {
Calendar curr = Calendar.getInstance();
curr.set(Calendar.DAY_OF_MONTH, curr.get(Calendar.DAY_OF_MONTH) + num);
return curr.getTime();
}
/**
* 获取当前日期指定月数之后的日期.
* @param num 间隔月数
* @return Date 日期
* @since 1.0
*/
public static Date nextMonth(int num) {
Calendar curr = Calendar.getInstance();
curr.set(Calendar.MONTH, curr.get(Calendar.MONTH) + num);
return curr.getTime();
}
/**
* 获取当前日期指定年数之后的日期.
* @param num 间隔年数
* @return Date 日期
* @since 1.0
*/
public static Date nextYear(int num) {
Calendar curr = Calendar.getInstance();
curr.set(Calendar.YEAR, curr.get(Calendar.YEAR) + num);
return curr.getTime();
}
/**
* 将 Date 日期转化为 Calendar 类型日期.
* @param date 给定的时间,若为null,则默认为当前时间
* @return Calendar Calendar对象
* @since 1.0
*/
public static Calendar getCalendar(Date date) {
Calendar calendar = Calendar.getInstance();
// calendar.setFirstDayOfWeek(Calendar.SUNDAY);//每周从周日开始
// calendar.setMinimalDaysInFirstWeek(1); // 设置每周最少为1天
if (date != null) {
calendar.setTime(date);
}
return calendar;
}
/**
* 计算两个日期之间相差天数.
* @param start 计算开始日期
* @param end 计算结束日期
* @return long 相隔天数
* @since 1.0
*/
public static long getDaysBetween(Date start, Date end) {
// 将指定日期转换为yyyy-MM-dd格式
start = DateUtil.parseDate(DateUtil.formatDate(start, DateUtil.DATE_FORMAT));
// 当前日期转换为yyyy-MM-dd格式
end = DateUtil.parseDate(DateUtil.formatDate(end, DateUtil.DATE_FORMAT));
long diff=0;
if(start!=null&&end!=null) {
diff = (end.getTime() - start.getTime()) / DateUtil.MILLISECONDS_PER_DAY;
}
return diff;
}
/**
* 计算两个日期之前相隔多少周.
* @param start 计算开始时间
* @param end 计算结束时间
* @return long 相隔周数,向下取整
* @since 1.0
*/
public static long getWeeksBetween(Date start, Date end) {
return getDaysBetween(start, end) / DateUtil.DAYS_PER_WEEK;
}
/**
* 获取与指定日期间隔给定天数的日期.
* @param specifiedDay 给定的字符串格式日期,支持的日期字符串格式包括"yyyy-MM-dd","yyyy-MM-dd HH:mm:ss",
* "yyyy-MM-dd HH:mm", "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss",
* "yyyy/MM/dd HH:mm"
* @param num 间隔天数
* @return String 间隔指定天数之后的日期
* @since 1.0
*/
public static String getSpecifiedDayAfter(String specifiedDay, int num) {
Date specifiedDate = parseDate(specifiedDay);
Calendar c = Calendar.getInstance();
c.setTime(specifiedDate);
int day = c.get(Calendar.DATE);
c.set(Calendar.DATE, day + num);
String dayAfter = formatDate(c.getTime(), DateUtil.DATE_FORMAT);
return dayAfter;
}
/**
* 计算两个日期之前间隔的小时数.
*
* @param date1
* 结束时间
* @param date2
* 开始时间
* @return String 相差的小时数,保留一位小数
* @since 1.0
*/
public static String dateMinus(Date date1, Date date2) {
if (date1 == null || date2 == null) {
return "0";
}
Long r = date1.getTime() - date2.getTime();
DecimalFormat df = new DecimalFormat("#.0");
double result = r * 1.0 / DateUtil.MILLISECONDS_PER_HOUR;
return df.format(result);
}
/**
* 获取当前季度 .
*
* @return Integer 当前季度数
* @since 1.0
*/
public static Integer getCurrentSeason() {
Calendar calendar = Calendar.getInstance();
Integer month = calendar.get(Calendar.MONTH) + 1;
int season = 0;
if (month >= 1 && month <= 3) {
season = 1;
} else if (month >= 4 && month <= 6) {
season = 2;
} else if (month >= 7 && month <= 9) {
season = 3;
} else if (month >= 10 && month <= 12) {
season = 4;
}
return season;
}
/**
* 将以秒为单位的时间转换为其他单位.
*
* @param seconds
* 秒数
* @return String 例如 16分钟前、2小时前、3天前、4月前、5年前等
* @since 1.0
*/
public static String getIntervalBySeconds(long seconds) {
StringBuffer buffer = new StringBuffer();
if (seconds < SECONDS_PER_MINUTE) {
buffer.append(seconds).append("秒前");
} else if (seconds < SECONDS_PER_HOUR) {
buffer.append(seconds / SECONDS_PER_MINUTE).append("分钟前");
} else if (seconds < SECONDS_PER_DAY) {
buffer.append(seconds / SECONDS_PER_HOUR).append("小时前");
} else if (seconds < SECONDS_PER_MONTH) {
buffer.append(seconds / SECONDS_PER_DAY).append("天前");
} else if (seconds < SECONDS_PER_YEAR) {
buffer.append(seconds / SECONDS_PER_MONTH).append("月前");
} else {
buffer.append(seconds / DateUtil.SECONDS_PER_YEAR).append("年前");
}
return buffer.toString();
}
/**
*
* getNowTimeBefore(记录时间相当于目前多久之前)
*
* @param seconds
* 秒
* @return
* @exception @since
* 1.0
* @author rlliu
*/
public static String getNowTimeBefore(long seconds) {
StringBuffer buffer = new StringBuffer();
buffer.append("上传于");
if (seconds < 3600) {
buffer.append((long) Math.floor(seconds / 60.0)).append("分钟前");
} else if (seconds < 86400) {
buffer.append((long) Math.floor(seconds / 3600.0)).append("小时前");
} else if (seconds < 604800) {
buffer.append((long) Math.floor(seconds / 86400.0)).append("天前");
} else if (seconds < 2592000) {
buffer.append((long) Math.floor(seconds / 604800.0)).append("周前");
} else if (seconds < 31104000) {
buffer.append((long) Math.floor(seconds / 2592000.0)).append("月前");
} else {
buffer.append((long) Math.floor(seconds / 31104000.0)).append("年前");
}
return buffer.toString();
}
/**
*
* getMonthsBetween(查询两个日期相隔的月份)
*
* @param startDate 开始日期1 (格式yyyy-MM-dd)
* @param endDate 截止日期2 (格式yyyy-MM-dd)
* @return
*/
public static int getMonthsBetween(String startDate, String endDate) {
Calendar c1 = Calendar.getInstance();
Calendar c2 = Calendar.getInstance();
c1.setTime(DateUtil.parseDate(startDate));
c2.setTime(DateUtil.parseDate(endDate));
int year = c2.get(Calendar.YEAR) - c1.get(Calendar.YEAR);
int month = c2.get(Calendar.MONTH) - c1.get(Calendar.MONTH);
return Math.abs(year * 12 + month);
}
/**
*
* getDayOfWeek(获取当前日期是星期几)
*
* @param dateStr 日期
* @return 星期几
*/
public static String getDayOfWeek(String dateStr) {
String[] weekOfDays = { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
Date date = parseDate(dateStr);
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
int num = calendar.get(Calendar.DAY_OF_WEEK) - 1;
return weekOfDays[num];
}
/**
* sns 格式 如几秒前,几分钟前,几小时前,几天前,几个月前,几年后, ... 精细,类如某个明星几秒钟之前发表了一篇微博
*
* @param createTime
* @return
*/
public static String snsFormat(long createTime) {
long now = System.currentTimeMillis() / 1000;
long differ = now - createTime / 1000;
String dateStr = "";
if (differ <= 60) {
dateStr = "刚刚";
} else if (differ <= 3600) {
dateStr = (differ / 60) + "分钟前";
} else if (differ <= 3600 * 24) {
dateStr = (differ / 3600) + "小时前";
} else if (differ <= 3600 * 24 * 30) {
dateStr = (differ / (3600 * 24)) + "天前";
} else {
Date date = new Date(createTime);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
dateStr = sdf.format(date);
}
return dateStr;
}
/**
* 得到UTC时间,类型为字符串,格式为"yyyy-MM-dd HH:mm"
* 如果获取失败,返回null
* @return
*/
public static String getUTCTimeStr() {
StringBuffer UTCTimeBuffer = new StringBuffer();
// 1、取得本地时间:
Calendar cal = Calendar.getInstance() ;
// 2、取得时间偏移量:
int zoneOffset = cal.get(java.util.Calendar.ZONE_OFFSET);
// 3、取得夏令时差:
int dstOffset = cal.get(java.util.Calendar.DST_OFFSET);
// 4、从本地时间里扣除这些差量,即可以取得UTC时间:
cal.add(java.util.Calendar.MILLISECOND, -(zoneOffset + dstOffset));
int year = cal.get(Calendar.YEAR);
int month = cal.get(Calendar.MONTH)+1;
int day = cal.get(Calendar.DAY_OF_MONTH);
int hour = cal.get(Calendar.HOUR_OF_DAY);
int minute = cal.get(Calendar.MINUTE);
UTCTimeBuffer.append(year).append("-").append(month).append("-").append(day) ;
UTCTimeBuffer.append(" ").append(hour).append(":").append(minute) ;
try{
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
sdf.parse(UTCTimeBuffer.toString()) ;
return UTCTimeBuffer.toString() ;
}catch(ParseException e)
{
e.printStackTrace() ;
}
return null ;
}
}
package com.qiwu.inference.util;
import java.math.BigDecimal;
/**
* 提供精确的浮点数运算工具类
* @author xingxing.ye.ye
*
*/
public class DoubleUtil {
// 除法运算默认精度,下面自定义方法可修改
private static final int DEF_DIV_SCALE = 10;
private DoubleUtil() {
}
/**
* 精确加法
*/
public static double add(double firValue, double sedValue) {
BigDecimal firBD = BigDecimal.valueOf(firValue);
BigDecimal sedBD = BigDecimal.valueOf(sedValue);
return firBD.add(sedBD).doubleValue();
}
/**
* 精确减法
*/
public static double sub(double firValue, double sedValue) {
BigDecimal firBD = BigDecimal.valueOf(firValue);
BigDecimal sedBD = BigDecimal.valueOf(sedValue);
return firBD.subtract(sedBD).doubleValue();
}
/**
* 精确乘法
*/
public static double mul(double firValue, double sedValue) {
BigDecimal firBD = BigDecimal.valueOf(firValue);
BigDecimal sedBD = BigDecimal.valueOf(sedValue);
return firBD.multiply(sedBD).doubleValue();
}
/**
* 精确除法 使用默认精度
*/
public static double div(double firValue, double sedValue) {
double num = 0;
try {
num = div(firValue, sedValue, DEF_DIV_SCALE);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
return num;
}
/**
* 精确除法
*
* @param scale 精度
* @throws IllegalAccessException
*/
public static double div(double firValue, double sedValue, int scale) throws IllegalAccessException {
if (scale < 0) {
throw new IllegalAccessException("精确度不能小于0");
}
BigDecimal b1 = BigDecimal.valueOf(firValue);
BigDecimal b2 = BigDecimal.valueOf(sedValue);
return b1.divide(b2, scale, BigDecimal.ROUND_HALF_UP).doubleValue();
}
/**
* 四舍五入
*
* @param scale 小数点后保留几位
*/
public static double round(double value, int scale) {
double num = 0;
try {
num = div(value, 1, scale);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
return num;
}
/**
* 比较两数是否相等
*/
public static boolean equalTo(BigDecimal firBD, BigDecimal sedBD) {
if (firBD == null || sedBD == null) {
return false;
}
return 0 == firBD.compareTo(sedBD);
}
/**
* 百分号的数转化为小数
*/
public static double convert(String str) {
return Double.parseDouble(str.replace("%",""))*0.01;
}
}
\ No newline at end of file
package com.qiwu.inference.util;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author: xingxing.ye
* @describe: fastjson 工具
*/
public final class FastJsonUtil {
private FastJsonUtil() {
}
/**
* 将对象转换为json
* null ->list =[]
* 输出null 值
* @param value 对象
* @return
*/
public static String obj2json(Object value) {
try {
return JSON.toJSONString(value,SerializerFeature.WriteMapNullValue,SerializerFeature.WriteNullListAsEmpty);
} catch (Exception e) {
try {
return obj2json3(value);
} catch (Exception e1) {
e.printStackTrace();
return null;
}
}
}
public static String obj2jsonPretty(Object value) {
try {
return JSON.toJSONString(value, SerializerFeature.PrettyFormat);
} catch (Exception e) {
try {
return obj2json2(value);
} catch (Exception e1) {
e.printStackTrace();
return null;
}
}
}
public static String obj2jsonDateFormat(Object value) {
try {
return JSON.toJSONStringWithDateFormat(value, "yyyy-MM-dd HH:mm:ss",
SerializerFeature.WriteDateUseDateFormat,SerializerFeature.DisableCircularReferenceDetect);
} catch (Exception e) {
try {
return obj2json2(value);
} catch (Exception e1) {
e.printStackTrace();
return null;
}
}
}
public static String obj2jsonDateFormat(Object value, String format) {
try {
// return JSON.toJSONString(value, SerializerFeature.PrettyFormat);
return JSON.toJSONStringWithDateFormat(value, format,
SerializerFeature.WriteDateUseDateFormat);
} catch (Exception e) {
try {
return obj2json2(value);
} catch (Exception e1) {
e.printStackTrace();
return null;
}
}
}
@SuppressWarnings("deprecation")
public static String obj2json2(Object value) {
try {
return JSON.toJSONString(value, SerializerFeature.WriteTabAsSpecial, SerializerFeature.WriteSlashAsSpecial);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
@SuppressWarnings("deprecation")
public static String obj2json3(Object value) {
try {
return JSON.toJSONString(value, SerializerFeature.WriteTabAsSpecial, SerializerFeature.WriteSlashAsSpecial,
SerializerFeature.BrowserCompatible);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
/**
* 将json转换为对象
*
* @param <T> 转换的类型
* @param json json数据
* @param clazz 被转化对象的class
* @return
*/
public static <T> T json2obj(String json, Class<T> clazz) {
try {
return JSON.parseObject(json, clazz);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
/**
* 将json转换为对象数组
*
* @param <T> 转换的类型
* @param json json数据
* @param clazz 被转化对象的class
* @return
*/
public static <T> List<T> json2List(String json, Class<T> clazz) {
try {
return JSON.parseArray(json, clazz);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
/**
* jsonStr to Map
*
* @param jsonStr jsonStr
* @return
*/
public static Map<String, String> parseJSON2Map(String jsonStr) {
// 参数di
Map<String, String> map = new HashMap<String, String>();
JSONObject json = null;
// 最外层解析
try {
json = JSONObject.parseObject(jsonStr);
for (String k : json.keySet()) {
Object v = json.get(k);
if (null != v) {
map.put(k.toString(), v.toString());
}
}
} catch (Exception e) {
e.printStackTrace();
return null;
}
return map;
}
/**
* jsonStr to Map
*
* @param jsonStr jsonStr
* @return
*/
public static Map<String, Object> parseJSON2Map2(String jsonStr) {
// 参数di
Map<String, Object> map = new HashMap<String, Object>();
JSONObject json = null;
// 最外层解析
try {
json = JSONObject.parseObject(jsonStr);
for (String k : json.keySet()) {
Object v = json.get(k);
if (null != v) {
map.put(k.toString(), v.toString());
}
}
} catch (Exception e) {
e.printStackTrace();
return null;
}
return map;
}
/**
* 保存json数据到指定的文件路径
* @param jsonData json数据
* @param filePath 文件路径
* @return
*/
public static boolean createJsonFile(Object jsonData, String filePath) {
String content = JSON.toJSONString(jsonData, SerializerFeature.PrettyFormat, SerializerFeature.WriteMapNullValue,
SerializerFeature.WriteDateUseDateFormat);
try {
File file = new File(filePath);
// 创建上级目录
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
// 如果文件存在,则删除文件
if (file.exists()) {
file.delete();
}
// 创建文件
file.createNewFile();
// 写入文件
Writer write = new OutputStreamWriter(Files.newOutputStream(file.toPath()), StandardCharsets.UTF_8);
write.write(content);
write.flush();
write.close();
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
}
\ No newline at end of file
package com.qiwu.inference.util;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.io.InputStream;
import java.util.List;
public class FileUtil {
public static InputStream getResourcesFileInputStream(String fileName) {
return Thread.currentThread().getContextClassLoader().getResourceAsStream("" + fileName);
}
public static String getPath() {
return FileUtil.class.getResource("/").getPath();
}
public static File createNewFile(String pathName) {
File file = new File(getPath() + pathName);
if (file.exists()) {
file.delete();
} else {
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
}
return file;
}
public static void writeLog(List<String> list, String filePath)throws Exception{
FileUtils.writeLines(new File(filePath), "utf-8", list,false);
}
public static File readFile(String pathName) {
return new File(getPath() + pathName);
}
public static File readUserHomeFile(String pathName) {
return new File(System.getProperty("user.home") + File.separator + pathName);
}
/**
* 用以模糊删除头部为str的文件
* @param path 要删除的文件的文件夹的路径
* @param str 匹配的字符串的头
* @return boolean
*/
public static boolean delFilesByPath(String path,String str){
boolean flag=false;
File file = new File(path);
File[] tempFile = file.listFiles();
for (File value : tempFile) {
if (value.getName().startsWith(str) || value.getName().endsWith(str)) {
System.out.println("将被删除的文件名:" + value.getName());
boolean del = deleteFile(path + value.getName());
if (del) {
System.out.println("文件" + value.getName() + "删除成功!");
flag = true;
} else {
System.out.println("文件" + value.getName() + "删除失败!");
}
}
}
return flag;
}
/**
* 用以删除文件
* @param path 要删除的文件的路径
* @return boolean
*/
private static boolean deleteFile(String path){
System.out.println(path);
boolean del=false;
File file=new File(path);
if(file.isFile()){
file.delete();
del=true;
}
return del;
}
}
package com.qiwu.inference.util;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
public class NumberUtil {
/**
* 开闭区间正则表达式
*/
private static final Pattern NUM_RANGE_PATTERN = Pattern.compile("[\\[|\\(]\\s?\\d+\\s?,\\s?\\d+\\s?[\\)|\\]]");
/**
* 左半区间正则表达式
*/
private static final Pattern LEFT_NUM_RANGE_PATTERN = Pattern.compile("[\\[|\\(]\\s?\\d+\\s?,\\s?[\\)|\\]]");
/**
* 右半区间正则表达式
*/
private static final Pattern RIGHT_NUM_RANGE_PATTERN = Pattern.compile("[\\[|\\(],\\s?\\d+\\s?[\\)|\\]]");
/**
* 判断是否为有效的数字区间范围
* @param numRange 数字区间
* @return boolean
*/
public static boolean isValidNumRange(String numRange) {
return NUM_RANGE_PATTERN.matcher(numRange).matches()
|| LEFT_NUM_RANGE_PATTERN.matcher(numRange).matches()
|| RIGHT_NUM_RANGE_PATTERN.matcher(numRange).matches();
}
/**
* 判断数值是否在区间范围内
* @param number 数值
* @param numRange 开闭区间
* @return boolean
*/
public static boolean inNumRange(int number, String numRange) {
Objects.requireNonNull(numRange);
if (!isValidNumRange(numRange)) {
return false;
}
String[] pairs = numRange.split(",");
// 获取开闭区间的最小值和最大值
List<String> rangeNums = Arrays.stream(pairs).map(str -> str.replaceAll("[(|)|\\[|\\]]", "").trim()).collect(Collectors.toList());
Integer minValue = "".equals(rangeNums.get(0)) ? null : Integer.valueOf(rangeNums.get(0));
Integer maxValue = "".equals(rangeNums.get(1)) ? null : Integer.valueOf(rangeNums.get(1));
// 判定数值是否大于最小值
boolean minMatched = (minValue == null) || (pairs[0].startsWith("[") ? number >= minValue : number > minValue);
// 判定数值是否小于最大值
boolean maxMatched = (maxValue == null) || (pairs[1].endsWith("]") ? number <= maxValue : number < maxValue);
return minMatched && maxMatched;
}
public static void main(String[] args) {
System.out.println(inNumRange(1, "[15, 29]"));
}
}
package com.qiwu.inference.util;
import java.awt.Color;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.*;
import java.util.concurrent.ThreadLocalRandom;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.exceptions.UtilException;
import cn.hutool.core.lang.UUID;
import cn.hutool.core.lang.WeightRandom;
import cn.hutool.core.lang.WeightRandom.WeightObj;
import cn.hutool.core.util.NumberUtil;
/**
* 随机工具类
*
*/
public class RandomUtil {
/** 用于随机选的数字 */
public static final String BASE_NUMBER = "0123456789";
/** 用于随机选的字符 */
public static final String BASE_CHAR = "abcdefghijklmnopqrstuvwxyz";
/** 用于随机选的字符和数字 */
public static final String BASE_CHAR_NUMBER = BASE_CHAR + BASE_NUMBER;
/**
* 获取随机数生成器对象<br>
* ThreadLocalRandom是JDK 7之后提供并发产生随机数,能够解决多个线程发生的竞争争夺。
*
* @return {@link ThreadLocalRandom}
* @since 3.1.2
*/
public static ThreadLocalRandom getRandom() {
return ThreadLocalRandom.current();
}
/**
* 获取{@link SecureRandom},类提供加密的强随机数生成器 (RNG)
*
* @return {@link SecureRandom}
* @since 3.1.2
*/
public static SecureRandom getSecureRandom() {
try {
return SecureRandom.getInstance("SHA1PRNG");
} catch (NoSuchAlgorithmException e) {
throw new UtilException(e);
}
}
/**
* 获取随机数产生器
*
* @param isSecure 是否为强随机数生成器 (RNG)
* @return {@link Random}
* @since 4.1.15
* @see #getSecureRandom()
* @see #getRandom()
*/
public static Random getRandom(boolean isSecure) {
return isSecure ? getSecureRandom() : getRandom();
}
/**
* 获得指定范围内的随机数
*
* @param min 最小数(包含)
* @param max 最大数(不包含)
* @return 随机数
*/
public static int randomInt(int min, int max) {
return getRandom().nextInt(min, max);
}
/**
* 获得随机数[0, 2^32)
*
* @return 随机数
*/
public static int randomInt() {
return getRandom().nextInt();
}
/**
* 获得指定范围内的随机数 [0,limit)
*
* @param limit 限制随机数的范围,不包括这个数
* @return 随机数
*/
public static int randomInt(int limit) {
return getRandom().nextInt(limit);
}
/**
* 获得指定范围内的随机数[min, max)
*
* @param min 最小数(包含)
* @param max 最大数(不包含)
* @return 随机数
* @since 3.3.0
*/
public static long randomLong(long min, long max) {
return getRandom().nextLong(min, max);
}
/**
* 获得随机数
*
* @return 随机数
* @since 3.3.0
*/
public static long randomLong() {
return getRandom().nextLong();
}
/**
* 获得指定范围内的随机数 [0,limit)
*
* @param limit 限制随机数的范围,不包括这个数
* @return 随机数
*/
public static long randomLong(long limit) {
return getRandom().nextLong(limit);
}
/**
* 获得指定范围内的随机数
*
* @param min 最小数(包含)
* @param max 最大数(不包含)
* @return 随机数
* @since 3.3.0
*/
public static double randomDouble(double min, double max) {
return getRandom().nextDouble(min, max);
}
/**
* 获得指定范围内的随机数
*
* @param min 最小数(包含)
* @param max 最大数(不包含)
* @param scale 保留小数位数
* @param roundingMode 保留小数的模式 {@link RoundingMode}
* @return 随机数
* @since 4.0.8
*/
public static double randomDouble(double min, double max, int scale, RoundingMode roundingMode) {
return NumberUtil.round(randomDouble(min, max), scale, roundingMode).doubleValue();
}
/**
* 获得随机数[0, 1)
*
* @return 随机数
* @since 3.3.0
*/
public static double randomDouble() {
return getRandom().nextDouble();
}
/**
* 获得指定范围内的随机数
*
* @param scale 保留小数位数
* @param roundingMode 保留小数的模式 {@link RoundingMode}
* @return 随机数
* @since 4.0.8
*/
public static double randomDouble(int scale, RoundingMode roundingMode) {
return NumberUtil.round(randomDouble(), scale, roundingMode).doubleValue();
}
/**
* 获得指定范围内的随机数 [0,limit)
*
* @param limit 限制随机数的范围,不包括这个数
* @return 随机数
* @since 3.3.0
*/
public static double randomDouble(double limit) {
return getRandom().nextDouble(limit);
}
/**
* 获得指定范围内的随机数
*
* @param limit 限制随机数的范围,不包括这个数
* @param scale 保留小数位数
* @param roundingMode 保留小数的模式 {@link RoundingMode}
* @return 随机数
* @since 4.0.8
*/
public static double randomDouble(double limit, int scale, RoundingMode roundingMode) {
return NumberUtil.round(randomDouble(limit), scale, roundingMode).doubleValue();
}
/**
* 获得指定范围内的随机数[0, 1)
*
* @return 随机数
* @since 4.0.9
*/
public static BigDecimal randomBigDecimal() {
return NumberUtil.toBigDecimal(getRandom().nextDouble());
}
/**
* 获得指定范围内的随机数 [0,limit)
*
* @param limit 最大数(不包含)
* @return 随机数
* @since 4.0.9
*/
public static BigDecimal randomBigDecimal(BigDecimal limit) {
return NumberUtil.toBigDecimal(getRandom().nextDouble(limit.doubleValue()));
}
/**
* 获得指定范围内的随机数
*
* @param min 最小数(包含)
* @param max 最大数(不包含)
* @return 随机数
* @since 4.0.9
*/
public static BigDecimal randomBigDecimal(BigDecimal min, BigDecimal max) {
return NumberUtil.toBigDecimal(getRandom().nextDouble(min.doubleValue(), max.doubleValue()));
}
/**
* 随机bytes
*
* @param length 长度
* @return bytes
*/
public static byte[] randomBytes(int length) {
byte[] bytes = new byte[length];
getRandom().nextBytes(bytes);
return bytes;
}
/**
* 随机获得列表中的元素
*
* @param <T> 元素类型
* @param list 列表
* @return 随机元素
*/
public static <T> T randomEle(List<T> list) {
return randomEle(list, list.size());
}
/**
* 随机获得列表中的元素
*
* @param <T> 元素类型
* @param list 列表
* @param limit 限制列表的前N项
* @return 随机元素
*/
public static <T> T randomEle(List<T> list, int limit) {
return list.get(randomInt(limit));
}
/**
* 随机获得数组中的元素
*
* @param <T> 元素类型
* @param array 列表
* @return 随机元素
* @since 3.3.0
*/
public static <T> T randomEle(T[] array) {
return randomEle(array, array.length);
}
/**
* 随机获得数组中的元素
*
* @param <T> 元素类型
* @param array 列表
* @param limit 限制列表的前N项
* @return 随机元素
* @since 3.3.0
*/
public static <T> T randomEle(T[] array, int limit) {
return array[randomInt(limit)];
}
/**
* 随机获得列表中的一定量元素
*
* @param <T> 元素类型
* @param list 列表
* @param count 随机取出的个数
* @return 随机元素
*/
public static <T> List<T> randomEles(List<T> list, int count) {
final List<T> result = new ArrayList<T>(count);
int limit = list.size();
while (result.size() < count) {
result.add(randomEle(list, limit));
}
return result;
}
/**
* 随机获得列表中的一定量的不重复元素,返回Set
*
* @param <T> 元素类型
* @param collection 列表
* @param count 随机取出的个数
* @return 随机元素
* @throws IllegalArgumentException 需要的长度大于给定集合非重复总数
*/
public static <T> Set<T> randomEleSet(Collection<T> collection, int count) {
ArrayList<T> source = new ArrayList<>(new HashSet<>(collection));
if (count > source.size()) {
throw new IllegalArgumentException("Count is larger than collection distinct size !");
}
final HashSet<T> result = new HashSet<T>(count);
int limit = collection.size();
while (result.size() < count) {
result.add(randomEle(source, limit));
}
return result;
}
/**
* 获得一个随机的字符串(只包含数字和字符)
*
* @param length 字符串的长度
* @return 随机字符串
*/
public static String randomString(int length) {
return randomString(BASE_CHAR_NUMBER, length);
}
/**
* 获得一个随机的字符串(只包含数字和大写字符)
*
* @param length 字符串的长度
* @return 随机字符串
* @since 4.0.13
*/
public static String randomStringUpper(int length) {
return randomString(BASE_CHAR_NUMBER, length).toUpperCase();
}
/**
* 获得一个只包含数字的字符串
*
* @param length 字符串的长度
* @return 随机字符串
*/
public static String randomNumbers(int length) {
return randomString(BASE_NUMBER, length);
}
/**
* 获得一个随机的字符串
*
* @param baseString 随机字符选取的样本
* @param length 字符串的长度
* @return 随机字符串
*/
public static String randomString(String baseString, int length) {
final StringBuilder sb = new StringBuilder();
if (length < 1) {
length = 1;
}
int baseLength = baseString.length();
for (int i = 0; i < length; i++) {
int number = getRandom().nextInt(baseLength);
sb.append(baseString.charAt(number));
}
return sb.toString();
}
/**
* 随机数字,数字为0~9单个数字
*
* @return 随机数字字符
* @since 3.1.2
*/
public static int randomNumber() {
return randomChar(BASE_NUMBER);
}
/**
* 随机字母或数字,小写
*
* @return 随机字符
* @since 3.1.2
*/
public static char randomChar() {
return randomChar(BASE_CHAR_NUMBER);
}
/**
* 随机字符
*
* @param baseString 随机字符选取的样本
* @return 随机字符
* @since 3.1.2
*/
public static char randomChar(String baseString) {
return baseString.charAt(getRandom().nextInt(baseString.length()));
}
/**
* 生成随机颜色
*
* @return 随机颜色
* @since 4.1.5
*/
public static Color randomColor() {
final Random random = getRandom();
return new Color(random.nextInt(255), random.nextInt(255), random.nextInt(255));
}
/**
* 带有权重的随机生成器
*
* @param weightObjs 带有权重的对象列表
* @return {@link WeightRandom}
* @since 4.0.3
*/
public static <T> WeightRandom<T> weightRandom(WeightObj<T>[] weightObjs) {
return new WeightRandom<>(weightObjs);
}
/**
* 带有权重的随机生成器
*
* @param weightObjs 带有权重的对象列表
* @return {@link WeightRandom}
* @since 4.0.3
*/
public static <T> WeightRandom<T> weightRandom(Iterable<WeightObj<T>> weightObjs) {
return new WeightRandom<>(weightObjs);
}
// ------------------------------------------------------------------- UUID
/**
* @return 随机UUID
* @deprecated 请使用{@link IdUtil#randomUUID()}
*/
@Deprecated
public static String randomUUID() {
return UUID.randomUUID().toString();
}
/**
* 简化的UUID,去掉了横线
*
* @return 简化的UUID,去掉了横线
* @since 3.2.2
* @deprecated 请使用{@link IdUtil#simpleUUID()}
*/
@Deprecated
public static String simpleUUID() {
return UUID.randomUUID().toString(true);
}
/**
* 以当天为基准,随机产生一个日期
*
* @param min 偏移最小天,可以为负数表示过去的时间
* @param max 偏移最大天,可以为负数表示过去的时间
* @return 随机日期(随机天,其它时间不变)
* @since 4.0.8
*/
public static DateTime randomDay(int min, int max) {
return DateUtil.offsetDay(DateUtil.date(), randomInt(min, max));
}
public static void main(String[] args) {
double num = randomDouble(2,RoundingMode.UP);
Map<String, String> map = new HashMap<>();
map.put("0","0.0");
map.put("1","0.35"); //0.35
map.put("2","0.27"); //0.62
map.put("3","0.37"); //0.99
double start =0.0;
double end =0.0;
int level =0 ;
for(int i=0;i<4;i++){
end +=Double.parseDouble(map.get(String.valueOf(i)));
if(num >= start && num <=end){
level = i;
}
start = end;
}
System.out.println(num);
System.out.println(level);
}
}
package com.qiwu.inference.util;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
/**
* 基于Redisson实现Redis数据的操作
*/
public class RedissonUtil {
private static RedissonClient client;
static {
Config config = new Config();
config.setThreads(1000);
config.useSingleServer().setAddress("redis://127.0.0.1:6379"); // 单机
client = Redisson.create(config);
}
// 新增
public static void setStr(String key,String val){
client.getBucket(key).set(val);
}
public static void setStr(String key,String val,long seconds){
client.getBucket(key).set(val,seconds, TimeUnit.SECONDS);
}
public static void setSet(String key,String val){
client.getSet(key).add(val);
}
public static void setSet(String key, Set<Object> vals){
client.getSet(key).addAll(vals);
}
public static void setSet(String key,double score,String val){
client.getScoredSortedSet(key).add(score,val);
}
public static void setSet(String key, Map<Object,Double> vals){
client.getScoredSortedSet(key).addAll(vals);
}
public static void setHash(String key,String val,Object file){
client.getMap(key).put(val,file);
}
public static void serHashAll(String key,Map<String,Object> map){
client.getMap(key).putAll(map);
}
// 查询
public static String getStr(String key){
return client.getBucket(key).get().toString();
}
public static Set<Object> getSet(String key){
return client.getSet(key).readAll();
}
public static Collection<Object> getzSet(String key){
return client.getScoredSortedSet(key).readAll();
}
public static boolean checkSet(String key,Object val){
return client.getSet(key).contains(val);
}
public static boolean checkzSet(String key,Object val){
return client.getScoredSortedSet(key).contains(val);
}
public static boolean checkKey(String key){
return client.getKeys().countExists(key) > 0;
}
public static boolean checkField(String key,String file){
return client.getMap(key).containsKey(file);
}
public static Object getHash(String key,String file){
return client.getMap(key).get(file);
}
// 设置有效期
public static void setTime(String key,long time,TimeUnit timeUnit){
client.getKeys().expire(key, time, timeUnit);
}
// 移除元素
public static boolean delZet(String key,Object val){
return client.getScoredSortedSet(key).remove(val);
}
// 删除key
public static void delKey(String... key){
client.getKeys().delete(key);
}
public static void delHash(String key,Object val){
client.getMap(key).remove(val);
}
// 分布式锁 Redis = (Setnx + Java中的LOCK)
// 加锁
public static void lock(String key){
client.getLock(key).lock();
}
// 加锁设置有效期 超出有效期自动释放
public static void lock(String key,long seconds){
client.getLock(key).lock(seconds,TimeUnit.SECONDS);
}
// 释放锁
public static void unlock(String key){
client.getLock(key).unlock();
}
public static Iterable<String> getKeys(String key){
return client.getKeys().getKeysByPattern(key);
}
public static void main(String[] args) {
System.out.println(RedissonUtil.getSet("2ba767cf-62e8-41a2-9f9f-d0581a0c9fa5"));
}
}
package com.qiwu.inference.util;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
@Component
public class SpringContextUtil implements ApplicationContextAware {
private static ApplicationContext applicationContext = null;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
if (SpringContextUtil.applicationContext == null) {
SpringContextUtil.applicationContext = applicationContext;
}
}
public static ApplicationContext getApplicationContext() {
return applicationContext;
}
public static Object getBean(String name) {
return getApplicationContext().getBean(name);
}
public static <T> T getBean(Class<T> clazz) {
return getApplicationContext().getBean(clazz);
}
public static <T> T getBean(String name, Class<T> clazz) {
return getApplicationContext().getBean(name, clazz);
}
}
\ No newline at end of file
package com.qiwu.inference.util;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* <pre>
* ThreadLocal을 사용하여 스레드 간 객체를 전파하기 위한 유틸리리 클래스
* </pre>
*/
public class ThreadLocalUtil {
private static final Logger LOGGER = LoggerFactory.getLogger(ThreadLocalUtil.class);
// 스레드 간 공유 객체를 저장하기 위한 ThreadLocal
private static ThreadLocal<Map<String, Object>> threadLocal = new ThreadLocal<Map<String, Object>>();
/**
* <pre>
* ThreadLocal 用于在线程之间传播对象的实用程序类
* </pre>
* @return
*/
private static Map<String, Object> getThreadLocal() {
if (threadLocal.get() == null) {
Map<String, Object> sharedObject = new HashMap<String, Object>();
threadLocal.set(sharedObject);
}
return threadLocal.get();
}//end of getThreadLocal()
/**
* <pre>
* 以在线程间共享对象中指定的键的名称存储对象
* </pre>
* @param key
* @param object
*/
public static void add(String key, Object object) { // NOPMD
getThreadLocal().put(key, object);
}//end of add()
/**
* <pre>
* 从线程之间的共享对象导入与指定键相对应的对象
* </pre>
* @param key
* @return
*/
public static Object get(String key) { // NOPMD
return getThreadLocal().get(key);
}//end of get()
/**
* <pre>
* 调查是否存在与线程间共享对象上指定的键相对应的对象
* </pre>
* @param key
* @return
*/
public static boolean isExist(String key) {
Object object = getThreadLocal().get(key);
if (object != null) {
return true;
} else {
return false;
}
}//end of isExist()
/**
* <pre>
* 初始化线程之间的共享对象
* </pre>
*/
public static void clearSharedObject() {
getThreadLocal().clear();
threadLocal.set(null);
}//end of clearSharedObject()
/**
* <pre>
* </pre>
* @return
*/
public static String[] getThreadLocalKeys() {
String[] arrKeys = new String[getThreadLocal().size()];
Iterator<String> keyIter = getThreadLocal().keySet().iterator();
int i = 0;
while (keyIter.hasNext()) {
arrKeys[i] = keyIter.next();
i++;
}
return arrKeys;
}//end of getThreadLocalKeys()
/**
* <pre>
* </pre>
* @return
*/
public static int size() {
return getThreadLocal().size();
}//end of size()
/**
* <pre>
* </pre>
* @return
*/
public static Object[] getThreadLocalValues() {
int size = size();
String[] arrKeys = getThreadLocalKeys();
Object[] values = new Object[size];
for (int i = 0; i < size; i++) {
values[i] = getThreadLocal().get(arrKeys[i]);
}
return values;
}//end of getThreadLocalValues()
/**
* <pre>
* </pre>
*/
public static void toPrintString() {
int size = size();
StringBuffer str = new StringBuffer();
String[] keys = getThreadLocalKeys();
Object[] values = getThreadLocalValues();
for (int i = 0; i < size; i++) {
str.append(" " + keys[i] + " = " + values[i] + " \n");
}
LOGGER.info("{}", str.toString());
}//end of toPringString()
}// end of ThreadLocalUtil.java
\ No newline at end of file
package com.qiwu.inference.util;
import com.github.junrar.Archive;
import com.github.junrar.rarfile.FileHeader;
import net.lingala.zip4j.core.ZipFile;
import org.slf4j.LoggerFactory;
import org.slf4j.Logger;
import java.io.File;
import java.io.FileOutputStream;
public class UnPackageUtil {
private static final Logger logger = LoggerFactory.getLogger(UnPackageUtil.class);
/**
* zip文件解压
*
* @param destPath 解压文件路径
* @param zipFile 压缩文件
* @param password 解压密码(如果有)
*/
public static void unPackageZip(File zipFile, String password, String destPath) {
try {
ZipFile zip = new ZipFile(zipFile);
/*zip4j默认用GBK编码去解压,这里设置编码为GBK的*/
zip.setFileNameCharset("GBK");
logger.info("begin unpack zip file....");
zip.extractAll(destPath);
// 如果解压需要密码
if (password != null) {
if (zip.isEncrypted()) {
zip.setPassword(password);
}
}
} catch (Exception e) {
logger.error("解压失败:", e.getMessage(), e);
}
}
/**
* rar文件解压(不支持有密码的压缩包)
*
* @param rarFile rar压缩包
* @param destPath 解压保存路径
*/
public static void unPackageRar(File rarFile, String destPath) {
try (Archive archive = new Archive(rarFile)) {
if (null != archive) {
FileHeader fileHeader = archive.nextFileHeader();
File file = null;
while (null != fileHeader) {
// 防止文件名中文乱码问题的处理
String fileName = fileHeader.getFileNameW().isEmpty() ? fileHeader.getFileNameString() : fileHeader.getFileNameW();
if (fileHeader.isDirectory()) {
//是文件夹
file = new File(destPath + File.separator + fileName);
file.mkdirs();
} else {
//不是文件夹
file = new File(destPath + File.separator + fileName.trim());
if (!file.exists()) {
if (!file.getParentFile().exists()) {
// 相对路径可能多级,可能需要创建父目录.
file.getParentFile().mkdirs();
}
file.createNewFile();
}
FileOutputStream os = new FileOutputStream(file);
archive.extractFile(fileHeader, os);
os.close();
}
fileHeader = archive.nextFileHeader();
}
}
} catch (Exception e) {
logger.error("解压失败:", e.getMessage(), e);
}
}
}
server:
port: 8082
serlvet:
context-path:/inferenceGame
#设置当前服务名
spring:
application:
#注册到注册中心的服务名
name: inference-game
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/inference_game_1?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC
username: root
password: admin!@#$
type: com.alibaba.druid.pool.DruidDataSource
druid:
initial-size: 5
min-idle: 5
max-active: 20
max-wait: 60000
#配置间隔多久才进行一次检测,检测需要关闭的空闲连接
time-between-eviction-runs-millis: 20000
#配置一个连接在池中最小生存的时间
min-evictable-idle-time-millis: 300000
servlet:
multipart:
max-file-size: 1GB #文件最大大小
max-request-size: 1GB #文件请求大小
#location: /tmp/pimport #文件存储路径
mybatis-plus:
mapper-locations: classpath:com.qiwu.inference.dao/*.xml
global-config:
db-config:
id-type: auto
configuration:
auto-mapping-behavior: partial
map-underscore-to-camel-case: true
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
logging:
level:
root: info
com.qiwu.inference: debug
\ No newline at end of file
spring:
profiles:
active: dev
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.qiwu.inference.dao.BehaviourMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.qiwu.inference.pojo.Behaviour">
<id column="id" property="id" />
<result column="name" property="name" />
<result column="description" property="description" />
<result column="generation_probability" property="generationProbability" />
<result column="object_identity" property="objectIdentity" />
<result column="subject_disposition" property="subjectDisposition" />
<result column="subject_identity_probability" property="subjectIdentityProbability" />
<result column="object_identity_probability" property="objectIdentityProbability" />
<result column="object_relation_probability" property="objectRelationProbability" />
<result column="object_disposition_probability" property="objectDispositionProbability" />
<result column="gender_probability" property="genderProbability" />
<result column="exclusion_behaviour" property="exclusionBehaviour" />
<result column="inverse_behaviour" property="inverseBehaviour" />
<result column="inverse_label" property="inverseLabel" />
<result column="single_label" property="singleLabel" />
<result column="info_level" property="infoLevel" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
</resultMap>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.qiwu.inference.dao.BehaviourRecordMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.qiwu.inference.pojo.BehaviourRecord">
<id column="id" property="id" />
<result column="name" property="name" />
<result column="behaviour_id" property="behaviourId" />
<result column="description" property="description" />
<result column="subject" property="subject" />
<result column="subject_name" property="subjectName" />
<result column="object" property="object" />
<result column="object_name" property="objectName" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
</resultMap>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.qiwu.inference.dao.ClueMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.qiwu.inference.pojo.Clue">
<id column="id" property="id" />
<result column="description" property="description" />
<result column="type" property="type" />
<result column="associated_id" property="associatedId" />
<result column="clue_template" property="clueTemplate" />
<result column="info_level" property="infoLevel" />
<result column="trust_degree" property="trustDegree" />
<result column="deterrence_degree" property="deterrenceDegree" />
<result column="prob" property="prob" />
<result column="my_trust_degree" property="myTrustDegree" />
<result column="my_deterrence_degree" property="myDeterrenceDegree" />
<result column="operate" property="operate" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
</resultMap>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.qiwu.inference.dao.ClueRecordMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.qiwu.inference.pojo.ClueRecord">
<id column="id" property="id" />
<result column="clue_id" property="clueId" />
<result column="subject" property="subject" />
<result column="object" property="object" />
<result column="description" property="description" />
<result column="type" property="type" />
<result column="info_level" property="infoLevel" />
<result column="associated_person" property="associatedPerson" />
<result column="clue_template" property="clueTemplate" />
<result column="trust_degree" property="trustDegree" />
<result column="deterrence_degree" property="deterrenceDegree" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
</resultMap>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.qiwu.inference.dao.DemandTaskMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.qiwu.inference.pojo.DemandTask">
<id column="id" property="id" />
<result column="name" property="name" />
<result column="description" property="description" />
<result column="trust_condition" property="trustCondition" />
<result column="deterrence_condition" property="deterrenceCondition" />
<result column="post_task" property="postTask" />
<result column="condition1" property="condition1" />
<result column="condition2" property="condition2" />
<result column="associated_disposition" property="associatedDisposition" />
<result column="associated_identity" property="associatedIdentity" />
<result column="associated_behaviour" property="associatedBehaviour" />
<result column="associated_relation" property="associatedRelation" />
<result column="exclusive_task" property="exclusiveTask" />
<result column="trust_degree" property="trustDegree" />
<result column="deterrence_degree" property="deterrenceDegree" />
<result column="completion_reward" property="completionReward" />
<result column="effective_degree" property="effectiveDegree" />
<result column="special_task" property="specialTask" />
<result column="info_level" property="infoLevel" />
<result column="task_label" property="taskLabel" />
<result column="clue_switch" property="clueSwitch" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
</resultMap>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.qiwu.inference.dao.DemandTaskRecordMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.qiwu.inference.pojo.DemandTaskRecord">
<id column="id" property="id" />
<id column="demand_task_id" property="demandTaskId" />
<result column="name" property="name" />
<result column="description" property="description" />
<result column="subject" property="subject" />
<result column="object" property="object" />
<result column="type" property="type" />
<result column="clue_id" property="clueId" />
<result column="info_level" property="infoLevel" />
<result column="task_label" property="taskLabel" />
<result column="clue_switch" property="clueSwitch" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
</resultMap>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.qiwu.inference.dao.DispositionMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.qiwu.inference.pojo.Disposition">
<id column="id" property="id" />
<result column="name" property="name" />
<result column="description" property="description" />
<result column="type" property="type" />
<result column="weight" property="generationProbability" />
<result column="identity_weight" property="identityWeight" />
<result column="gender_weight" property="genderWeight" />
<result column="age_weight" property="ageWeight" />
<result column="favor_degree" property="favorDegree" />
<result column="weakness_condition" property="weaknessCondition" />
<result column="item_favor_degree" property="itemFavorDegree" />
<result column="identity_favor_degree" property="identityFavorDegree" />
<result column="exclusion_disposition" property="exclusionDisposition" />
<result column="info_level" property="infoLevel" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
</resultMap>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.qiwu.inference.dao.DispositionRecordMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.qiwu.inference.pojo.DispositionRecord">
<id column="id" property="id" />
<result column="subject" property="subject" />
<result column="disposition_id" property="dispositionId" />
<result column="name" property="name" />
<result column="description" property="description" />
<result column="type" property="type" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
</resultMap>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.qiwu.inference.dao.DispositionTypeMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.qiwu.inference.pojo.DispositionType">
<id column="id" property="id" />
<result column="name" property="name" />
<result column="description" property="description" />
<result column="probability" property="probability" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
</resultMap>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.qiwu.inference.dao.EndGoalMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.qiwu.inference.pojo.EndGoal">
<id column="id" property="id" />
<result column="name" property="name" />
<result column="description" property="description" />
<result column="clue_group" property="clueGroup" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
</resultMap>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.qiwu.inference.dao.IdentityMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.qiwu.inference.pojo.Identity">
<id column="id" property="id" />
<result column="name" property="name" />
<result column="description" property="description" />
<result column="key_identity" property="keyIdentity" />
<result column="gender" property="gender" />
<result column="max_num" property="maxNum" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
</resultMap>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.qiwu.inference.dao.ItemMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.qiwu.inference.pojo.Item">
<id column="id" property="id" />
<result column="name" property="name" />
<result column="description" property="description" />
<result column="price" property="price" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
</resultMap>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.qiwu.inference.dao.KeyClueMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.qiwu.inference.pojo.KeyClue">
<id column="id" property="id" />
<result column="name" property="name" />
<result column="description" property="description" />
<result column="subject_identity" property="subjectIdentity" />
<result column="subject_label" property="subjectLabel" />
<result column="object_identity" property="objectIdentity" />
<result column="object_label" property="objectLabel" />
<result column="relation" property="relation" />
<result column="precue" property="precue" />
<result column="clue_group" property="clueGroup" />
<result column="target" property="target" />
<result column="associated_task" property="associatedTask" />
<result column="info_level" property="infoLevel" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
</resultMap>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.qiwu.inference.dao.LocationMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.qiwu.inference.pojo.Location">
<id column="id" property="id" />
<result column="name" property="name" />
<result column="description" property="description" />
<result column="key_location" property="keyLocation" />
<result column="is_hidden" property="isHidden" />
<result column="clue_template" property="clueTemplate" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
</resultMap>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.qiwu.inference.dao.PersonMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.qiwu.inference.pojo.Person">
<id column="id" property="id" />
<result column="name" property="name" />
<result column="description" property="description" />
<result column="identity_id" property="identityId" />
<result column="age" property="age" />
<result column="location" property="location" />
<result column="gender" property="gender" />
<result column="special_disposition" property="specialDisposition" />
<result column="kinship" property="kinship" />
<result column="infoLevel" property="infoLevel" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
</resultMap>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.qiwu.inference.dao.PersonRecordMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.qiwu.inference.pojo.PersonRecord">
<id column="id" property="id" />
<result column="gate_no" property="gateNo" />
<result column="name" property="name" />
<result column="person_id" property="personId" />
<result column="identity_id" property="identityId" />
<result column="identity_name" property="identityName" />
<result column="age" property="age" />
<result column="is_key" property="isKey" />
<result column="gender" property="gender" />
<result column="location" property="location" />
<result column="disposition" property="disposition" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
</resultMap>
<select id="getGateNo" resultType="String">
select distinct (gate_no) as gateNo from person_record
</select>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.qiwu.inference.dao.RelationMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.qiwu.inference.pojo.Relation">
<id column="id" property="id" />
<result column="name" property="name" />
<result column="description" property="description" />
<result column="type" property="type" />
<result column="weight" property="weight" />
<result column="gender_weight" property="genderWeight" />
<result column="age_weight" property="ageWeight" />
<result column="age_gaps_weight" property="ageGapsWeight" />
<result column="identity_weight" property="identityWeight" />
<result column="disposition_weight" property="dispositionWeight" />
<result column="exclusion_identity" property="exclusionIdentity" />
<result column="exclusion_relation" property="exclusionRelation" />
<result column="inverse_relation" property="inverseRelation" />
<result column="info_level" property="infoLevel" />
<result column="master_info_level" property="masterInfoLevel" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
</resultMap>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.qiwu.inference.dao.RelationRecordMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.qiwu.inference.pojo.RelationRecord">
<id column="id" property="id" />
<result column="name" property="name" />
<result column="description" property="description" />
<result column="type" property="type" />
<result column="relation_id" property="relationId" />
<result column="subject" property="subject" />
<result column="subject_name" property="subjectName" />
<result column="object" property="object" />
<result column="object_name" property="objectName" />
<result column="master_info_level" property="masterInfoLevel" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
</resultMap>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.qiwu.inference.dao.RelationTypeMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.qiwu.inference.pojo.RelationType">
<id column="id" property="id" />
<result column="name" property="name" />
<result column="description" property="description" />
<result column="probability" property="probability" />
<result column="identity_probability" property="identityProbability" />
<result column="disposition_probability" property="dispositionProbability" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
</resultMap>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.qiwu.inference.dao.TaskConditionMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.qiwu.inference.pojo.TaskCondition">
<id column="id" property="id" />
<result column="name" property="name" />
<result column="description" property="description" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
</resultMap>
</mapper>
dataSource.url=jdbc:mysql://localhost:3306/inference_game?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
dataSource.driverName=com.mysql.cj.jdbc.Driver
dataSource.username=root
dataSource.password=admin!@#$
package.base=com.qiwu.inference
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="fatal">
<!--打印在本地,根据具体存储地址填写-->
<Properties>
<Property name="baseDir" value="/home/inferenceGame/logs"/>
</Properties>
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<!--控制台只输出level及以上级别的信息(onMatch),其他的直接拒绝(onMismatch) -->
<ThresholdFilter level="info" onMatch="ACCEPT"
onMismatch="DENY"/>
<PatternLayout
pattern="[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%level] [%logger{36}] - %msg%n"/>
</Console>
<!--debug级别日志文件输出-->
<RollingFile name="debug_appender" fileName="${baseDir}/debug.log"
filePattern="${baseDir}/debug_%i.log.%d{yyyy-MM-dd}">
<!-- 过滤器 -->
<Filters>
<!-- 限制日志级别在debug及以上在info以下 -->
<ThresholdFilter level="debug"/>
<ThresholdFilter level="info" onMatch="DENY" onMismatch="NEUTRAL"/>
</Filters>
<!-- 日志格式 -->
<PatternLayout pattern="[%d{HH:mm:ss:SSS}] [%p] - %l - %m%n"/>
<!-- 策略 -->
<Policies>
<!-- 每隔一天转存 -->
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
<!-- 文件大小 -->
<SizeBasedTriggeringPolicy size="100 MB"/>
</Policies>
</RollingFile>
<!-- info级别日志文件输出 -->
<RollingFile name="info_appender" fileName="${baseDir}/info.log"
filePattern="${baseDir}/info_%i.log.%d{yyyy-MM-dd}">
<!-- 过滤器 -->
<Filters>
<!-- 限制日志级别在info及以上在error以下 -->
<ThresholdFilter level="info"/>
<ThresholdFilter level="error" onMatch="DENY" onMismatch="NEUTRAL"/>
</Filters>
<!-- 日志格式 -->
<PatternLayout pattern="[%d{HH:mm:ss:SSS}] [%p] - %l - %m%n"/>
<!-- 策略 -->
<Policies>
<!-- 每隔一天转存 -->
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
<!-- 文件大小 -->
<SizeBasedTriggeringPolicy size="100 MB"/>
</Policies>
</RollingFile>
<!-- error级别日志文件输出 -->
<RollingFile name="error_appender" fileName="${baseDir}/error.log"
filePattern="${baseDir}/error_%i.log.%d{yyyy-MM-dd}">
<!-- 过滤器 -->
<Filters>
<!-- 限制日志级别在error及以上 -->
<ThresholdFilter level="error"/>
</Filters>
<!-- 日志格式 -->
<PatternLayout pattern="[%d{HH:mm:ss:SSS}] [%p] - %l - %m%n"/>
<Policies>
<!-- 每隔一天转存 -->
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
<!-- 文件大小 -->
<SizeBasedTriggeringPolicy size="100 MB"/>
</Policies>
</RollingFile>
</Appenders>
<Loggers>
<Root level="debug">
<AppenderRef ref="Console"/>
<AppenderRef ref="debug_appender"/>
<AppenderRef ref="info_appender"/>
<AppenderRef ref="error_appender"/>
</Root>
</Loggers>
</Configuration>
\ No newline at end of file
-- ----------------------------
-- Table structure for person_record
-- ----------------------------
DROP TABLE IF EXISTS `person_record`;
CREATE TABLE `person_record` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '人物id',
`gate_no` varchar(255) DEFAULT NULL COMMENT '关卡编号',
`name` varchar(255) DEFAULT NULL COMMENT '人物名称',
`person_id` int(20) DEFAULT NULL COMMENT '人物id',
`description` varchar(255) DEFAULT NULL COMMENT '人物描述',
`identity_id` int(20) DEFAULT NULL COMMENT '身份id',
`identity_name` varchar(255) DEFAULT NULL COMMENT '身份名称',
`age` int(2) DEFAULT NULL COMMENT '年龄',
`is_key` int(2) DEFAULT NULL COMMENT '是否为关键人物 1 关键人物 2 普通人物',
`gender` int(2) DEFAULT NULL COMMENT '性别',
`location` int(11) DEFAULT NULL COMMENT '所在地',
`disposition` text COMMENT '性格',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` timestamp NULL DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
-- ----------------------------
-- Table structure for relation_record
-- ----------------------------
DROP TABLE IF EXISTS `relation_record`;
CREATE TABLE `relation_record` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id',
`name` varchar(255) DEFAULT NULL COMMENT '关系名称',
`description` varchar(255) DEFAULT NULL COMMENT '关系描述',
`type` int(2) DEFAULT NULL COMMENT '关系类型',
`relation_id` int(11) DEFAULT NULL COMMENT '关系id',
`subject` int(11) DEFAULT NULL COMMENT '关系的主体',
`subject_name` varchar(255) DEFAULT NULL COMMENT '主体名称:老王',
`object` int(11) DEFAULT NULL COMMENT '关系客体',
`object_name` varchar(255) DEFAULT NULL COMMENT '主体名称:老王',
`master_info_level` int(2) DEFAULT NULL COMMENT '掌握信息级别',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` timestamp NULL DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
-- ----------------------------
-- Table structure for disposition_record
-- ----------------------------
DROP TABLE IF EXISTS `disposition_record`;
CREATE TABLE `disposition_record` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id',
`subject` int(11) DEFAULT NULL COMMENT '人物id',
`disposition_id` int(11) DEFAULT NULL COMMENT '性格id',
`name` varchar(255) DEFAULT NULL COMMENT '性格名称',
`description` varchar(255) DEFAULT NULL COMMENT '性格描述',
`type` varchar(255) DEFAULT NULL COMMENT '类型',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` timestamp NULL DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
-- ----------------------------
-- Table structure for demand_task_record
-- ----------------------------
DROP TABLE IF EXISTS `demand_task_record`;
CREATE TABLE `demand_task_record` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id',
`demand_task_id` varchar(255) DEFAULT NULL COMMENT '任务id',
`name` varchar(255) DEFAULT NULL COMMENT '名称',
`description` varchar(255) DEFAULT NULL COMMENT '描述',
`subject` int(11) DEFAULT NULL COMMENT '主体',
`object` int(11) DEFAULT NULL COMMENT '客体',
`type` int(2) DEFAULT NULL COMMENT '类型: 1:身份 2:场所 3:性格爱好 4:行为 5:关系 6:任务 9:关键线索',
`clue_id` int(11) DEFAULT NULL COMMENT '线索id',
`info_level` int(2) DEFAULT NULL COMMENT '信息级别',
`task_label` int(2) DEFAULT NULL COMMENT '任务标签 1普通任务 2关键任务 3目标任务',
`clue_switch` int(2) DEFAULT NULL COMMENT '线索开关 0代表不需要线索就可执行,1代表需要线索才能执行此任务',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` timestamp NULL DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
-- ----------------------------
-- Table structure for clue_record
-- ----------------------------
DROP TABLE IF EXISTS `clue_record`;
CREATE TABLE `clue_record` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id',
`clue_id` int(11) DEFAULT NULL COMMENT '线索id',
`clue_name` varchar(255) DEFAULT NULL COMMENT '线索名称',
`subject` int(11) DEFAULT NULL COMMENT '主体',
`object` int(11) DEFAULT NULL COMMENT '客体',
`description` varchar(255) DEFAULT NULL COMMENT '描述',
`type` int(2) DEFAULT NULL COMMENT '类型: 1:身份 2:场所 3:性格爱好 4:行为 5:关系 6:任务 9:关键线索 ',
`info_level` int(2) DEFAULT NULL COMMENT '信息级别',
`associated_person` int(11) DEFAULT NULL COMMENT '关联人物',
`clue_template` varchar(255) DEFAULT NULL COMMENT '线索模板',
`trust_degree` int(11) DEFAULT NULL COMMENT '信任度',
`deterrence_degree` int(11) DEFAULT NULL COMMENT '威胁',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` timestamp NULL DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
-- ----------------------------
-- Table structure for behaviour_record
-- ----------------------------
DROP TABLE IF EXISTS `behaviour_record`;
CREATE TABLE `behaviour_record` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '行为记录id',
`name` varchar(255) DEFAULT NULL COMMENT '行为名称',
`behaviour_id` int(11) DEFAULT NULL COMMENT '行为id',
`description` varchar(255) DEFAULT NULL COMMENT '行为描述',
`subject` int(11) DEFAULT NULL COMMENT '主体:1',
`subject_name` varchar(255) DEFAULT NULL COMMENT '主体名称:老王',
`object` int(11) DEFAULT NULL COMMENT '客体:2',
`object_name` varchar(255) DEFAULT NULL COMMENT '客体名称:小美',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` timestamp NULL DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
\ No newline at end of file
/*
Navicat Premium Data Transfer
Source Server : mysql
Source Server Type : MySQL
Source Server Version : 50733
Source Host : 127.0.0.1:3306
Source Schema : inference_game_1
Target Server Type : MySQL
Target Server Version : 50733
File Encoding : 65001
Date: 02/02/2023 13:51:37
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for behaviour
-- ----------------------------
DROP TABLE IF EXISTS `behaviour`;
CREATE TABLE `behaviour` (
`id` int(11) NOT NULL COMMENT '行为id',
`name` varchar(255) DEFAULT NULL COMMENT '行为名称',
`description` varchar(255) DEFAULT NULL COMMENT '行为描述',
`generation_probability` float(8,2) DEFAULT NULL COMMENT '发生的概率',
`object_identity` varchar(255) DEFAULT NULL COMMENT '行为对象身份(B)',
`associated_id` varchar(255) DEFAULT NULL COMMENT '关联对象id',
`subject_disposition` varchar(255) DEFAULT NULL COMMENT '行为人性格喜好|概率增减(A)',
`subject_identity_probability` varchar(255) DEFAULT NULL COMMENT '行为人身份|概率增减(A)',
`object_identity_probability` varchar(255) DEFAULT NULL COMMENT '行为对象身份|概率增减(B)',
`object_relation_probability` varchar(255) DEFAULT NULL COMMENT '与行为对象关系|概率影响(A与B)',
`object_disposition_probability` varchar(255) DEFAULT NULL COMMENT '行为对象性格喜好|概率影响(B)',
`gender_probability` varchar(255) DEFAULT NULL COMMENT '行为人性别|行为对象性别|概率影响(A)',
`exclusion_behaviour` varchar(255) DEFAULT NULL COMMENT '互斥行为',
`inverse_behaviour` varchar(255) DEFAULT NULL COMMENT '反向行为',
`inverse_label` int(2) DEFAULT NULL COMMENT '被动行为标签:0为主行为,1为被动行为',
`single_label` int(2) DEFAULT NULL COMMENT '单人行为标签:0为双人行为,1为单人行为',
`info_level` int(2) DEFAULT NULL COMMENT '信息重要级别',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` timestamp NULL DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
-- ----------------------------
-- Table structure for behaviour_record
-- ----------------------------
DROP TABLE IF EXISTS `behaviour_record`;
CREATE TABLE `behaviour_record` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '行为记录id',
`name` varchar(255) DEFAULT NULL COMMENT '行为名称',
`behaviour_id` int(11) DEFAULT NULL COMMENT '行为id',
`description` varchar(255) DEFAULT NULL COMMENT '行为描述',
`subject` int(11) DEFAULT NULL COMMENT '主体:1',
`subject_name` varchar(255) DEFAULT NULL COMMENT '主体名称:老王',
`object` int(11) DEFAULT NULL COMMENT '客体:2',
`object_name` varchar(255) DEFAULT NULL COMMENT '客体名称:小美',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` timestamp NULL DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
-- ----------------------------
-- Table structure for clue
-- ----------------------------
DROP TABLE IF EXISTS `clue`;
CREATE TABLE `clue` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id',
`name` varchar(255) DEFAULT NULL COMMENT '线索名称',
`description` varchar(255) DEFAULT NULL COMMENT '描述',
`type` int(2) DEFAULT NULL COMMENT '类型: 1:身份 2:场所 3:性格爱好 4:行为 5:关系 6:任务',
`associated_id` int(11) DEFAULT NULL COMMENT '对应的Id',
`clue_template` varchar(255) DEFAULT NULL COMMENT '线索模板',
`info_level` varchar(255) DEFAULT NULL COMMENT '信息级别',
`trust_degree` int(11) DEFAULT NULL COMMENT '信任度',
`deterrence_degree` int(11) DEFAULT NULL COMMENT '威胁',
`prob` varchar(255) DEFAULT NULL COMMENT '概率',
`my_trust_degree` int(11) DEFAULT NULL COMMENT '自己的信任度',
`my_deterrence_degree` int(11) DEFAULT NULL COMMENT '自己的威胁度',
`score` int(11) DEFAULT NULL COMMENT '积分',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` timestamp NULL DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
-- ----------------------------
-- Table structure for clue_record
-- ----------------------------
DROP TABLE IF EXISTS `clue_record`;
CREATE TABLE `clue_record` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id',
`clue_id` int(11) DEFAULT NULL COMMENT '线索id',
`clue_name` varchar(255) DEFAULT NULL COMMENT '线索名称',
`subject` int(11) DEFAULT NULL COMMENT '主体',
`object` int(11) DEFAULT NULL COMMENT '客体',
`description` varchar(255) DEFAULT NULL COMMENT '描述',
`type` int(2) DEFAULT NULL COMMENT '类型: 1:身份 2:场所 3:性格爱好 4:行为 5:关系 6:任务 9:关键线索 ',
`info_level` int(2) DEFAULT NULL COMMENT '信息级别',
`associated_person` int(11) DEFAULT NULL COMMENT '关联人物',
`clue_template` varchar(255) DEFAULT NULL COMMENT '线索模板',
`trust_degree` int(11) DEFAULT NULL COMMENT '信任度',
`deterrence_degree` int(11) DEFAULT NULL COMMENT '威胁度',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` timestamp NULL DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
-- ----------------------------
-- Table structure for demand_task
-- ----------------------------
DROP TABLE IF EXISTS `demand_task`;
CREATE TABLE `demand_task` (
`id` int(11) NOT NULL COMMENT 'id',
`name` varchar(255) DEFAULT NULL COMMENT '名称',
`description` varchar(255) DEFAULT NULL COMMENT '描述',
`task_group` int(2) DEFAULT NULL COMMENT '任务组',
`subject_need_identity` varchar(255) DEFAULT NULL COMMENT '主体必要身份',
`object_need_identity` varchar(255) DEFAULT NULL COMMENT '客体必要身份',
`subject_need_gender` varchar(255) DEFAULT NULL COMMENT '主体必要的性别',
`object_need_gender` varchar(255) DEFAULT NULL COMMENT '客体必要的性别',
`trust_condition` varchar(255) DEFAULT NULL COMMENT '开启条件信任度',
`deterrence_condition` varchar(255) DEFAULT NULL COMMENT '开启条件威慑度',
`post_task` varchar(255) DEFAULT NULL COMMENT '后置任务',
`condition1` varchar(255) DEFAULT NULL COMMENT '条件1|次数',
`condition2` varchar(255) DEFAULT NULL COMMENT '条件2|次数',
`associated_disposition` varchar(255) DEFAULT NULL COMMENT '关联喜好',
`associated_identity` varchar(255) DEFAULT NULL COMMENT '关联身份',
`associated_behaviour` varchar(255) DEFAULT NULL COMMENT '关联行为',
`associated_relation` varchar(255) DEFAULT NULL COMMENT '关联关系',
`exclusive_task` varchar(255) DEFAULT NULL COMMENT '互斥任务',
`trust_degree` int(5) DEFAULT NULL COMMENT '信任度增减',
`deterrence_degree` int(5) DEFAULT NULL COMMENT '威慑度增减',
`completion_reward` varchar(255) DEFAULT NULL COMMENT '完成奖励',
`reputation` int(5) DEFAULT NULL COMMENT '声望增减',
`effective_degree` int(2) DEFAULT NULL COMMENT '有效次数',
`special_task` int(2) DEFAULT NULL COMMENT '特殊任务 0 主动任务 1 被动任务',
`info_level` int(2) DEFAULT NULL COMMENT '信息级别',
`task_label` int(2) DEFAULT NULL COMMENT '任务标签 1普通任务 2关键任务 3目标任务',
`clue_switch` int(2) DEFAULT NULL COMMENT '线索开关 0代表不需要线索就可执行,1代表需要线索才能执行此任务',
`is_auto` int(2) DEFAULT NULL COMMENT '自动触发',
`negative_task` int(2) DEFAULT NULL COMMENT '负面任务',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` timestamp NULL DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
-- ----------------------------
-- Table structure for demand_task_record
-- ----------------------------
DROP TABLE IF EXISTS `demand_task_record`;
CREATE TABLE `demand_task_record` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id',
`demand_task_id` varchar(255) DEFAULT NULL COMMENT '任务id',
`name` varchar(255) DEFAULT NULL COMMENT '名称',
`task_group` int(2) DEFAULT NULL COMMENT '任务组',
`description` varchar(255) DEFAULT NULL COMMENT '描述',
`subject` int(11) DEFAULT NULL COMMENT '主体',
`object` int(11) DEFAULT NULL COMMENT '客体',
`type` int(2) DEFAULT NULL COMMENT '类型: 1:身份 2:场所 3:性格爱好 4:行为 5:关系 6:任务 9:关键线索',
`clue_id` int(11) DEFAULT NULL COMMENT '线索id',
`info_level` int(2) DEFAULT NULL COMMENT '信息级别',
`task_label` int(2) DEFAULT NULL COMMENT '任务标签 1普通任务 2关键任务 3目标任务',
`clue_switch` int(2) DEFAULT NULL COMMENT '线索开关 0代表不需要线索就可执行,1代表需要线索才能执行此任务',
`is_auto` int(2) DEFAULT NULL COMMENT '自动触发',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` timestamp NULL DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
-- ----------------------------
-- Table structure for disposition
-- ----------------------------
DROP TABLE IF EXISTS `disposition`;
CREATE TABLE `disposition` (
`id` int(11) NOT NULL COMMENT '性格id',
`name` varchar(255) DEFAULT NULL COMMENT '性格名称',
`description` varchar(255) DEFAULT NULL COMMENT '性格描述',
`type` int(2) DEFAULT NULL COMMENT '类型',
`weight` int(10) DEFAULT NULL COMMENT '基础权重',
`identity_weight` varchar(255) DEFAULT NULL COMMENT '身份影响权重:',
`gender_weight` varchar(255) DEFAULT NULL COMMENT '性别影响权重:',
`age_weight` varchar(255) DEFAULT NULL COMMENT '年龄影响权重:',
`trust_degree` int(10) DEFAULT NULL COMMENT '信任度初始值',
`deterrence_degree` int(10) DEFAULT NULL COMMENT '威胁度初始值:',
`weakness_condition` varchar(255) DEFAULT NULL COMMENT '弱点条件:',
`item_favor_degree` varchar(255) DEFAULT NULL COMMENT '对应物品|好感度增减:',
`identity_favor_degree` varchar(255) DEFAULT NULL COMMENT '对应身份|好感度增减:',
`exclusion_disposition` varchar(255) DEFAULT NULL COMMENT '互斥性格|喜好:',
`info_level` varchar(255) DEFAULT NULL COMMENT '信息重要级别',
`clue_template` varchar(255) DEFAULT NULL COMMENT '对应线索模板:',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` timestamp NULL DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
-- ----------------------------
-- Table structure for disposition_record
-- ----------------------------
DROP TABLE IF EXISTS `disposition_record`;
CREATE TABLE `disposition_record` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id',
`subject` int(11) DEFAULT NULL COMMENT '人物id',
`disposition_id` int(11) DEFAULT NULL COMMENT '性格id',
`name` varchar(255) DEFAULT NULL COMMENT '性格名称',
`description` varchar(255) DEFAULT NULL COMMENT '性格描述',
`type` int(2) DEFAULT NULL COMMENT '类型',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` timestamp NULL DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
-- ----------------------------
-- Table structure for disposition_type
-- ----------------------------
DROP TABLE IF EXISTS `disposition_type`;
CREATE TABLE `disposition_type` (
`id` int(11) NOT NULL COMMENT '关系类型id',
`name` varchar(255) DEFAULT NULL COMMENT '名称',
`description` varchar(255) DEFAULT NULL COMMENT '描述',
`probability` varchar(255) DEFAULT NULL COMMENT '概率',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` timestamp NULL DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
-- ----------------------------
-- Table structure for end_goal
-- ----------------------------
DROP TABLE IF EXISTS `end_goal`;
CREATE TABLE `end_goal` (
`id` int(11) NOT NULL COMMENT '结局目标id',
`name` varchar(255) DEFAULT NULL COMMENT '目标名称',
`description` varchar(255) DEFAULT NULL COMMENT '目标描述',
`clue_group` varchar(255) DEFAULT NULL COMMENT '组合表:1|2|3|4|5',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` timestamp NULL DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
-- ----------------------------
-- Table structure for identity
-- ----------------------------
DROP TABLE IF EXISTS `identity`;
CREATE TABLE `identity` (
`id` int(11) NOT NULL COMMENT '身份id',
`name` varchar(255) DEFAULT NULL COMMENT '身份名称',
`description` varchar(255) DEFAULT NULL COMMENT '身份描述',
`key_identity` int(2) DEFAULT NULL COMMENT '关键身份',
`gender` int(2) DEFAULT NULL COMMENT '对应性别',
`max_num` int(2) DEFAULT NULL COMMENT '最大人数',
`info_level` int(2) DEFAULT NULL COMMENT '信息级别',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` timestamp NULL DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
-- ----------------------------
-- Table structure for item
-- ----------------------------
DROP TABLE IF EXISTS `item`;
CREATE TABLE `item` (
`id` int(11) NOT NULL COMMENT 'id',
`name` varchar(255) DEFAULT NULL COMMENT '名称',
`description` varchar(255) DEFAULT NULL COMMENT '描述',
`price` varchar(255) DEFAULT NULL COMMENT '价格',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` timestamp NULL DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
-- ----------------------------
-- Table structure for key_clue
-- ----------------------------
DROP TABLE IF EXISTS `key_clue`;
CREATE TABLE `key_clue` (
`id` int(11) NOT NULL COMMENT '关键线索id',
`name` varchar(255) DEFAULT NULL COMMENT '名称',
`description` varchar(255) DEFAULT NULL COMMENT '描述',
`subject_identity` varchar(255) DEFAULT NULL COMMENT '关键人物身份(甲)',
`subject_label` int(2) DEFAULT NULL COMMENT '人物标签(甲)',
`object_identity` varchar(255) DEFAULT NULL COMMENT '掌握线索人物身份(乙)',
`object_label` int(2) DEFAULT NULL COMMENT '人物标签(乙)',
`relation` varchar(255) DEFAULT NULL COMMENT '关系(留空为自己)',
`precue` varchar(255) DEFAULT NULL COMMENT '前置线索:90002|90003',
`clue_group` int(2) DEFAULT NULL COMMENT '线索组合:',
`target` int(11) DEFAULT NULL COMMENT '对应目标:',
`associated_task` varchar(255) DEFAULT NULL COMMENT '对应任务',
`info_level` int(2) DEFAULT NULL COMMENT '信息等级',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` timestamp NULL DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
-- ----------------------------
-- Table structure for location
-- ----------------------------
DROP TABLE IF EXISTS `location`;
CREATE TABLE `location` (
`id` int(11) NOT NULL COMMENT '场所id',
`name` varchar(255) DEFAULT NULL COMMENT '场所名称',
`description` varchar(255) DEFAULT NULL COMMENT '描述',
`key_location` varchar(255) DEFAULT NULL COMMENT '关键场所',
`is_hidden` int(2) DEFAULT NULL COMMENT '是否隐藏',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` timestamp NULL DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
-- ----------------------------
-- Table structure for person
-- ----------------------------
DROP TABLE IF EXISTS `person`;
CREATE TABLE `person` (
`id` int(11) NOT NULL COMMENT '身份id',
`name` varchar(255) DEFAULT NULL COMMENT '人物名称',
`identity_name` varchar(255) DEFAULT NULL COMMENT '身份名称',
`identity_id` int(2) DEFAULT NULL COMMENT '身份id',
`age` varchar(255) DEFAULT NULL COMMENT '对应年龄',
`location` int(11) DEFAULT NULL COMMENT '对应场所',
`gender` int(2) DEFAULT NULL COMMENT '对应性别',
`special_disposition` varchar(255) DEFAULT NULL COMMENT '特定性格',
`kinship` varchar(255) DEFAULT NULL COMMENT '亲缘关系',
`info_level` varchar(255) DEFAULT NULL COMMENT '信息重要级别',
`friendly` int(2) DEFAULT NULL COMMENT '友好人物',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` timestamp NULL DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
-- ----------------------------
-- Table structure for person_record
-- ----------------------------
DROP TABLE IF EXISTS `person_record`;
CREATE TABLE `person_record` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '人物id',
`gate_no` varchar(255) DEFAULT NULL COMMENT '关卡编号',
`name` varchar(255) DEFAULT NULL COMMENT '人物名称',
`person_id` int(20) DEFAULT NULL COMMENT '人物id',
`identity_id` int(20) DEFAULT NULL COMMENT '身份id',
`identity_name` varchar(255) DEFAULT NULL COMMENT '身份名称',
`age` int(2) DEFAULT NULL COMMENT '年龄',
`is_key` int(2) DEFAULT NULL COMMENT '是否为关键人物 1 关键人物 2 普通人物',
`gender` int(2) DEFAULT NULL COMMENT '性别',
`location` int(11) DEFAULT NULL COMMENT '所在地',
`disposition` text COMMENT '性格',
`friendly` int(2) DEFAULT NULL COMMENT '友好人物',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` timestamp NULL DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
-- ----------------------------
-- Table structure for relation
-- ----------------------------
DROP TABLE IF EXISTS `relation`;
CREATE TABLE `relation` (
`id` int(11) NOT NULL COMMENT '关系id',
`name` varchar(255) DEFAULT NULL COMMENT '关系名称',
`description` varchar(255) DEFAULT NULL COMMENT '关系描述',
`type` int(2) DEFAULT NULL COMMENT '关系类型',
`weight` int(5) DEFAULT NULL COMMENT '权重',
`gender_weight` varchar(255) DEFAULT NULL COMMENT '性别影响概率增减',
`age_weight` varchar(255) DEFAULT NULL COMMENT '年龄影响概率增减',
`age_gaps_weight` varchar(255) DEFAULT NULL COMMENT '年龄差影响概率增减',
`identity_weight` varchar(255) DEFAULT NULL COMMENT '身份影响概率增减',
`disposition_weight` varchar(255) DEFAULT NULL COMMENT '性格/喜好影响概率增减',
`exclusion_identity` varchar(255) DEFAULT NULL COMMENT '关系人排除身份',
`exclusion_relation` varchar(255) DEFAULT NULL COMMENT '互斥关系',
`inverse_relation` varchar(255) DEFAULT NULL COMMENT '反向关系',
`info_level` int(2) DEFAULT NULL COMMENT '信息重要级别',
`master_info_level` int(2) DEFAULT NULL COMMENT '掌握信息级别',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` timestamp NULL DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
-- ----------------------------
-- Table structure for relation_record
-- ----------------------------
DROP TABLE IF EXISTS `relation_record`;
CREATE TABLE `relation_record` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id',
`name` varchar(255) DEFAULT NULL COMMENT '关系名称',
`description` varchar(255) DEFAULT NULL COMMENT '关系描述',
`type` int(2) DEFAULT NULL COMMENT '关系类型',
`relation_id` int(11) DEFAULT NULL COMMENT '关系id',
`subject` int(11) DEFAULT NULL COMMENT '关系的主体',
`subject_name` varchar(255) DEFAULT NULL COMMENT '主体名称:老王',
`object` int(11) DEFAULT NULL COMMENT '关系客体',
`object_name` varchar(255) DEFAULT NULL COMMENT '主体名称:老王',
`master_info_level` int(2) DEFAULT NULL COMMENT '掌握信息级别',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` timestamp NULL DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
-- ----------------------------
-- Table structure for relation_type
-- ----------------------------
DROP TABLE IF EXISTS `relation_type`;
CREATE TABLE `relation_type` (
`id` int(11) NOT NULL COMMENT '关系类型id',
`name` varchar(255) DEFAULT NULL COMMENT '名称',
`description` varchar(255) DEFAULT NULL COMMENT '描述',
`probability` varchar(255) DEFAULT NULL COMMENT '概率',
`identity_probability` varchar(255) DEFAULT NULL COMMENT '身份影响概率增减',
`disposition_probability` varchar(255) DEFAULT NULL COMMENT '性格/喜好影响概率增减',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` timestamp NULL DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
-- ----------------------------
-- Table structure for task_condition
-- ----------------------------
DROP TABLE IF EXISTS `task_condition`;
CREATE TABLE `task_condition` (
`id` int(11) NOT NULL COMMENT 'id',
`name` varchar(255) DEFAULT NULL COMMENT '名称',
`description` varchar(255) DEFAULT NULL COMMENT '描述',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` timestamp NULL DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
SET FOREIGN_KEY_CHECKS = 1;
rm -rf ~/.config/navicat
rm -rf ~/.config/navicat
rm -rf ~/.config/dconf/user
\ No newline at end of file
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