Commit 7d2055fe by 周君强

1.推理项目整合代码

parent 61a5c717
...@@ -8,9 +8,9 @@ ...@@ -8,9 +8,9 @@
<artifactId>InferenceGame</artifactId> <artifactId>InferenceGame</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>InferenceGame</name> <name>inferenceGame</name>
<build> <build>
<finalName>InferenceGame</finalName> <finalName>inferenceGame</finalName>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
...@@ -82,6 +82,41 @@ ...@@ -82,6 +82,41 @@
<artifactId>jxl</artifactId> <artifactId>jxl</artifactId>
<version>2.6.12</version> <version>2.6.12</version>
</dependency> </dependency>
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson</artifactId>
<version>3.17.4</version>
</dependency>
<!--Swagger-UI API文档生产工具-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>3.0.0</version>
</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>
<!--Hutool Java工具包-->
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.8</version>
</dependency>
</dependencies> </dependencies>
<properties> <properties>
......
...@@ -2,20 +2,13 @@ package com.qiwu.inference; ...@@ -2,20 +2,13 @@ package com.qiwu.inference;
import com.qiwu.inference.common.TimingAcquisition; import com.qiwu.inference.common.TimingAcquisition;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;
@SpringBootConfiguration
@SpringBootApplication @SpringBootApplication
public class InferenceApplication { public class InferenceApplication {
@Bean
public RestTemplate restTemplate(RestTemplateBuilder builder) {
return builder.build();
}
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(InferenceApplication.class, args); SpringApplication.run(InferenceApplication.class, args);
//加载话术
TimingAcquisition.speechLoading();
} }
} }
package com.qiwu.inference.aop;
import com.qiwu.inference.common.utils.CacheUtil;
import com.qiwu.inference.common.utils.YamlUtil;
import com.qiwu.inference.dto.request.OperationRequest;
import com.qiwu.inference.dto.response.CommonResponse;
import com.qiwu.inference.dto.response.ResultVarsResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import org.yaml.snakeyaml.Yaml;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
public class MyAop implements InvocationHandler{
Logger log = LoggerFactory.getLogger(MyAop.class);
private String offlineTime = YamlUtil.getValueByKey("offlineTime");
private Object object;
//构造代理对象
public Object newProxy(Object object) {
this.object = object;
return Proxy.newProxyInstance(object.getClass().getClassLoader(),
object.getClass().getInterfaces(), this);
}
@Override
public Object invoke(Object o, Method method, Object[] objects) throws Throwable {
OperationRequest request = (OperationRequest) objects[0];
//该玩家以唯一标识加入全局缓存,用于玩家离线判断
String uniqueUid = request.getUid() + "%#%online%#%";
CacheUtil.put(uniqueUid, "", Long.parseLong(offlineTime));
//通过反射获取方法返参
Object var = method.invoke(this.object, objects);
//检索到有新消息
CommonResponse commonResponse = (CommonResponse) var;
ResultVarsResponse data = commonResponse.getData();
if (!StringUtils.isEmpty(data)) {
//所有“后台附加返回”为null值的都给转成“无效返回”
if (StringUtils.isEmpty(data.getVars().get后台附加返回())) {
data.getVars().set后台附加返回("无效返回");
}
//所有“后台附加返回”为null值的都给转成“无效返回”
if (StringUtils.isEmpty(data.getVars().get后台附加返回2())) {
data.getVars().set后台附加返回2("无效返回");
}
String feedContent = "后台返回参数 = [" +
"code:" + commonResponse.getCode() +
", msg:" + commonResponse.getMsg() +
", 反馈ID:" + data.getVars().get反馈ID() +
", 反馈文本:" + data.getVars().get反馈文本() +
", 后台附加返回:" + data.getVars().get后台附加返回() +
", 后台附加返回2:" + data.getVars().get后台附加返回2() +
"]";
//玩家有新消息提示
log.info(feedContent);
}
return var;
}
}
package com.qiwu.inference.common; package com.qiwu.inference.common;
import org.springframework.beans.factory.annotation.Value;
public class Constants { public class Constants {
/** /**
...@@ -66,13 +68,9 @@ public class Constants { ...@@ -66,13 +68,9 @@ public class Constants {
*/ */
public static final String SPEECH_ASIDE = "aside"; public static final String SPEECH_ASIDE = "aside";
/** /**
* 话术-男园丁 * 话术-人物
*/
public static final String SPEECH_MAN = "man";
/**
* 话术-女园丁
*/ */
public static final String SPEECH_WOMAN = "woman"; public static final String SPEECH_PERSON = "person";
...@@ -86,4 +84,27 @@ public class Constants { ...@@ -86,4 +84,27 @@ public class Constants {
*/ */
public static final String NON_STR = "0"; public static final String NON_STR = "0";
/**
* "1":场所为隐藏
*/
public static final String IS_HIDDEN = "1";
/**
* 查看操作
*/
public static final String OPERATE_CHECK = "查看操作";
/**
* 关卡操作
*/
public static final String OPERATE_BARRIER = "关卡操作";
/**
* 询问操作
*/
public static final String OPERATE_ASK = "询问操作";
/**
* 线索-关系类型-5
*/
public static final Integer RELATION_TYPE = 5;
} }
package com.qiwu.inference.common;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.qiwu.inference.common.utils.PersistenceUtil;
import com.qiwu.inference.dao.*;
import com.qiwu.inference.dto.Person;
import com.qiwu.inference.dto.Player;
import com.qiwu.inference.pojo.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.io.File;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@Component
public class InitSysServlet implements InitializingBean {
Logger log = LoggerFactory.getLogger(InitSysServlet.class);
@Value("${userFilePath}")
private String userFilePath;
@Value("${configFilePath}")
private String configFilePath;
@Value("${speechFilePath}")
private String speechFilePath;
@Autowired
private SystemConfigMapper systemConfigMapper;
@Autowired
private LocationMapper locationMapper;
@Autowired
private ClueMapper clueMapper;
@Autowired
private DemandTaskMapper demandTaskMapper;
@Autowired
private DispositionMapper dispositionMapper;
/**
* 保存配置信息到缓存
*/
@Override
public void afterPropertiesSet() throws Exception {
//--------------------------缓存关卡数据---------------------
log.info("开始缓存关卡数据");
String gateInfo = PersistenceUtil.getConfigFromFile(configFilePath, "results.json");
Map<String, List<Person>> gateInfoMap = JSON.parseObject(gateInfo, new TypeReference<Map<String, List<Person>>>(){});
TimingAcquisition.gateInfoMap.putAll(gateInfoMap);
log.info("关卡数据缓存完成");
//--------------------------加载玩家数据----------------------
log.info("开始加载玩家数据");
//从yml配置文件中取出存放玩家数据的地址
File file = new File(userFilePath);
File[] files = file.listFiles();
if (files == null) {
log.info("路径" + userFilePath+ "下没有文件");
return;
}
Map<String, Player> playerMap = new ConcurrentHashMap<>();
for (File f : files) {
if (f.isFile()) {
String s = PersistenceUtil.getDataFromFile(String.valueOf(f));
//JSON转map对象
Player player = JSON.parseObject(s, new TypeReference<Player>(){});
String fileName = f.getName().replace(".json", "");
playerMap.put(fileName, player);
TimingAcquisition.playerMap.putAll(playerMap);
}
}
log.info("玩家数据缓存完成");
//--------------------加载话术-----------------
TimingAcquisition.speechLoading(speechFilePath);
//-----------------缓存场所信息------------------
Map<String, Location> locationMap = new ConcurrentHashMap<>();
List<Location> locationList = locationMapper.findAll();
for (Location location : locationList) {
locationMap.put(location.getId().toString(), location);
}
TimingAcquisition.locationMap.putAll(locationMap);
log.info("场所配置信息缓存完成");
//-----------------缓存线索信息------------------
Map<Integer, Clue> clueMap = new ConcurrentHashMap<>();
List<Clue> clueList = clueMapper.findAll();
for (Clue clue : clueList) {
clueMap.put(clue.getId(), clue);
}
TimingAcquisition.clueMap.putAll(clueMap);
log.info("线索配置信息缓存完成");
//-----------------缓存线索类型信息------------------
Map<Integer, String> clueTypeMap = new ConcurrentHashMap<>();
List<ClueType> clueTypeList = clueMapper.getTypeInfo();
for (ClueType clueType : clueTypeList) {
clueTypeMap.put(clueType.getId(), clueType.getName());
}
TimingAcquisition.clueTypeMap.putAll(clueTypeMap);
log.info("线索类型配置信息缓存完成");
//-----------------缓存需求任务配置信息------------------
Map<Integer, DemandTask> demandTaskMap = new ConcurrentHashMap<>();
List<DemandTask> demandTaskList = demandTaskMapper.findAll();
for (DemandTask demandTask : demandTaskList) {
demandTaskMap.put(demandTask.getId(), demandTask);
}
TimingAcquisition.demandTaskMap.putAll(demandTaskMap);
log.info("需求任务配置信息缓存完成");
//-----------------缓存性格信息------------------
Map<Integer, Disposition> dispositionMap = new ConcurrentHashMap<>();
List<Disposition> dispositionList = dispositionMapper.findAll();
for (Disposition disposition : dispositionList) {
dispositionMap.put(disposition.getId(), disposition);
}
TimingAcquisition.dispositionMap.putAll(dispositionMap);
log.info("性格配置信息缓存完成");
//-----------------缓存系统配置信息------------------
Map<String, SystemConfigPojo> systemConfigMap = new ConcurrentHashMap<>();
List<SystemConfigPojo> systemConfigList = systemConfigMapper.findAll();
for (SystemConfigPojo systemConfig : systemConfigList) {
systemConfigMap.put(systemConfig.getName(), systemConfig);
}
TimingAcquisition.systemConfigMap.putAll(systemConfigMap);
log.info("系统配置信息缓存完成");
}
}
package com.qiwu.inference.common; package com.qiwu.inference.common;
import com.qiwu.inference.common.utils.PersistenceUtil;
import com.qiwu.inference.common.utils.YamlUtil; import com.qiwu.inference.common.utils.YamlUtil;
import com.qiwu.inference.dto.Person;
import com.qiwu.inference.dto.Player;
import com.qiwu.inference.pojo.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
...@@ -12,6 +19,44 @@ public class TimingAcquisition { ...@@ -12,6 +19,44 @@ public class TimingAcquisition {
static Logger log = LoggerFactory.getLogger(TimingAcquisition.class); static Logger log = LoggerFactory.getLogger(TimingAcquisition.class);
/** /**
* 关卡信息,Map<gateNo, List<Person>>
*/
public volatile static Map<String, List<Person>> gateInfoMap = new ConcurrentHashMap<>();
/**
* 用户id跟关卡编号对应关系
*/
public volatile static Map<String, String> uidGateNoMap = new ConcurrentHashMap<>();
/**
* 玩家信息,Map<sid, Player>
*/
public volatile static Map<String, Player> playerMap = new ConcurrentHashMap<>();
/**
* 场所配置信息
*/
public volatile static Map<String, Location> locationMap = new ConcurrentHashMap<>();
/**
* 线索配置信息
*/
public volatile static Map<Integer, Clue> clueMap = new ConcurrentHashMap<>();
/**
* 线索类型配置信息
*/
public volatile static Map<Integer, String> clueTypeMap = new ConcurrentHashMap<>();
/**
* 需求任务配置信息
*/
public volatile static Map<Integer, DemandTask> demandTaskMap = new ConcurrentHashMap<>();
/**
* 性格配置信息
*/
public volatile static Map<Integer, Disposition> dispositionMap = new ConcurrentHashMap<>();
/**
* 系统配置信息
*/
public volatile static Map<String, SystemConfigPojo> systemConfigMap = new ConcurrentHashMap<>();
/**
* 询问模块话术 * 询问模块话术
*/ */
public volatile static Map<String, Map<Integer, List<String>>> askSpeechMap = new ConcurrentHashMap<>(); public volatile static Map<String, Map<Integer, List<String>>> askSpeechMap = new ConcurrentHashMap<>();
...@@ -23,19 +68,25 @@ public class TimingAcquisition { ...@@ -23,19 +68,25 @@ public class TimingAcquisition {
* 查看模块话术 * 查看模块话术
*/ */
public volatile static Map<String, Map<Integer, List<String>>> checkSpeechMap = new ConcurrentHashMap<>(); public volatile static Map<String, Map<Integer, List<String>>> checkSpeechMap = new ConcurrentHashMap<>();
/**
* 查看模块话术
*/
public volatile static Map<String, Map<Integer, List<String>>> barrierSpeechMap = new ConcurrentHashMap<>();
/** /**
* 通过yaml文件加载所有话术到缓存中 * 通过yaml文件加载所有话术到缓存中
*/ */
public static void speechLoading() { public static void speechLoading(String speechFilePath) {
log.info("---------开始加载话术到缓存中---------"); log.info("---------开始加载话术到缓存中---------");
Map<String, Map<Integer, List<String>>> askSpeech = new HashMap<>(); Map<String, Map<Integer, List<String>>> askSpeech = new HashMap<>();
Map<String, Map<Integer, List<String>>> taskSpeech = new HashMap<>(); Map<String, Map<Integer, List<String>>> taskSpeech = new HashMap<>();
Map<String, Map<Integer, List<String>>> checkSpeech = new HashMap<>(); Map<String, Map<Integer, List<String>>> checkSpeech = new HashMap<>();
Map<String, Map<Integer, List<String>>> barrierSpeech = new HashMap<>();
try { try {
askSpeech = YamlUtil.loadSpeechToMap("ask.yaml"); askSpeech = PersistenceUtil.loadSpeechToMap(speechFilePath,"ask.yaml");
taskSpeech = YamlUtil.loadSpeechToMap("task.yaml"); taskSpeech = PersistenceUtil.loadSpeechToMap(speechFilePath,"task.yaml");
checkSpeech = YamlUtil.loadSpeechToMap("check.yaml"); checkSpeech = PersistenceUtil.loadSpeechToMap(speechFilePath,"check.yaml");
barrierSpeech = PersistenceUtil.loadSpeechToMap(speechFilePath,"barrier.yaml");
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -43,7 +94,63 @@ public class TimingAcquisition { ...@@ -43,7 +94,63 @@ public class TimingAcquisition {
askSpeechMap.putAll(askSpeech); askSpeechMap.putAll(askSpeech);
taskSpeechMap.putAll(taskSpeech); taskSpeechMap.putAll(taskSpeech);
checkSpeechMap.putAll(checkSpeech); checkSpeechMap.putAll(checkSpeech);
barrierSpeechMap.putAll(barrierSpeech);
log.info("---------加载话术到缓存的操作完成---------"); log.info("---------加载话术到缓存的操作完成---------");
} }
/**
* 通过线索类型获取对应id
*/
public static Integer getClueTypeIdByName(String name) {
for (Map.Entry<Integer, String> entry : clueTypeMap.entrySet()) {
if (name.equals(entry.getValue())) {
return entry.getKey();
}
}
return Constants.REQ_NON;
}
/**
* 通过场所名称获取对应id
*/
public static String getLocationIdByName(String name) {
for (Map.Entry<String, Location> entry : locationMap.entrySet()) {
if (name.equals(entry.getValue().getName())) {
return entry.getKey();
}
}
return Constants.NON_STR;
}
/**
* 通过玩家名称获取对应id
*/
public static Integer getPersonIdByName(String uid, String name) {
Integer personId = TimingAcquisition.playerMap.get(uid).getName2IdMap().get(name);
if (!StringUtils.isEmpty(personId)) {
return personId;
}
return Constants.REQ_NON;
}
/**
* 通过id获取玩家名称
*/
public static String getNameByPersonId(String uid, Integer personId) {
for (Map.Entry<String, Integer> entry : TimingAcquisition.playerMap.get(uid).getName2IdMap().entrySet()) {
if (personId.equals(entry.getValue())) {
return entry.getKey();
}
}
return Constants.NON_STR;
}
/**
* 获取当前正在对话的人物名称
*/
public static String getTalkName(String uid) {
Integer personId = TimingAcquisition.playerMap.get(uid).getPersonId();
return getNameByPersonId(uid, personId);
}
} }
package com.qiwu.inference.common.api;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class CommonData {
private Integer id;
private String aside;
private String text;
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 java.util.List;
/**
* 分页数据封装类
*/
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;
}
public Integer getPageNum() {
return pageNum;
}
public void setPageNum(Integer pageNum) {
this.pageNum = pageNum;
}
public Integer getPageSize() {
return pageSize;
}
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
}
public Integer getTotalPage() {
return totalPage;
}
public void setTotalPage(Integer totalPage) {
this.totalPage = totalPage;
}
public List<T> getList() {
return list;
}
public void setList(List<T> list) {
this.list = list;
}
public Long getTotal() {
return total;
}
public void setTotal(Long total) {
this.total = total;
}
}
package com.qiwu.inference.common.api;
/**
* 通用返回对象
*/
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);
}
public long getCode() {
return code;
}
public void setCode(long code) {
this.code = code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = 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(1, "成功"),
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.cache; package com.qiwu.inference.common.cache;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.qiwu.inference.common.Constants;
import com.qiwu.inference.common.TimingAcquisition;
import com.qiwu.inference.common.utils.DateUtil;
import com.qiwu.inference.common.utils.PersistenceUtil;
import com.qiwu.inference.dto.Player;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
...@@ -13,6 +20,9 @@ import java.util.concurrent.TimeUnit; ...@@ -13,6 +20,9 @@ import java.util.concurrent.TimeUnit;
@EnableAsync @EnableAsync
@Component @Component
public class ExpireThread implements Runnable{ public class ExpireThread implements Runnable{
@Value("${userFilePath}")
private String userFilePath;
@Override @Override
public void run() { public void run() {
while (true) { while (true) {
...@@ -35,6 +45,20 @@ public class ExpireThread implements Runnable{ ...@@ -35,6 +45,20 @@ public class ExpireThread implements Runnable{
if (timeoutTime < myCache.getExpireTime()) { if (timeoutTime < myCache.getExpireTime()) {
continue; continue;
} }
//规定时间内玩家无操作默认下线
if (key.contains("%#%online%#%")) {
String uid = key.replace("%#%online%#%", "");
Player player = TimingAcquisition.playerMap.get(uid);
//更新玩家为离线状态
player.setStatus(Constants.OFFLINE);
//修改下线时间
player.setOfflineTime(DateUtil.getCurrentTime());
//--------------持久化该园丁信息---------------
Map<String, Player> playerMap = new ConcurrentHashMap<>();
playerMap.put(uid, TimingAcquisition.playerMap.get(uid));
String playerStr = JSON.toJSONString(playerMap);
PersistenceUtil.saveDataToFile(userFilePath, uid, playerStr);
}
//清除过期缓存 //清除过期缓存
CacheGlobal.concurrentMap.remove(key); CacheGlobal.concurrentMap.remove(key);
} }
......
package com.qiwu.inference.common.utils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.BeanWrapper;
import org.springframework.beans.BeanWrapperImpl;
import org.springframework.util.StringUtils;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
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(",");
}
}
...@@ -24,7 +24,7 @@ public class CacheUtil { ...@@ -24,7 +24,7 @@ public class CacheUtil {
myCache.setLastTime(System.currentTimeMillis()); myCache.setLastTime(System.currentTimeMillis());
myCache.setExpireTime(System.currentTimeMillis()); myCache.setExpireTime(System.currentTimeMillis());
myCache.setValue(value); myCache.setValue(value);
} } else {
MyCache myCache = new MyCache(); MyCache myCache = new MyCache();
myCache.setKey(key); myCache.setKey(key);
myCache.setValue(value); myCache.setValue(value);
...@@ -34,6 +34,7 @@ public class CacheUtil { ...@@ -34,6 +34,7 @@ public class CacheUtil {
myCache.setHitCount(1); myCache.setHitCount(1);
CacheGlobal.concurrentMap.put(key, myCache); CacheGlobal.concurrentMap.put(key, myCache);
} }
}
/** /**
* 获取缓存 * 获取缓存
......
package com.qiwu.inference.common.utils;
import com.qiwu.inference.common.Constants;
import com.qiwu.inference.common.TimingAcquisition;
import com.qiwu.inference.common.api.CommonResult;
import com.qiwu.inference.dto.Player;
import com.qiwu.inference.dto.response.ResultVarsResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.StringUtils;
import java.text.ParseException;
import java.util.List;
import java.util.Map;
public class DataTrimUtil {
static Logger log = LoggerFactory.getLogger(DataTrimUtil.class);
/**
* 判断整数尾数是否为1
*/
public static boolean checkIntWithOne(Integer num) {
int remain = num % 10;
if (remain == 1) {
return true;
}
return false;
}
/**
* 玩家状态更改
*/
public static void AdjustStatus(String uid, String offlineTime) throws ParseException {
//玩家当前为离线状态
Player player = TimingAcquisition.playerMap.get(uid);
//操作日期为今天之前,需更改为在线状态
String nowTime = DateUtil.getCurrentTime();
if (!StringUtils.isEmpty(player.getOnlineTime())) {
if (DateUtil.compare(nowTime, player.getOnlineTime()) == 1) {
//更新玩家在线状态
statusUpdate(uid);
}
}
if (player.getStatus() == Constants.OFFLINE) {
//更新玩家在线状态
statusUpdate(uid);
}
//该玩家以唯一标识加入全局缓存,用于玩家离线判断
String uniqueUid = uid + "%#%online%#%";
CacheUtil.put(uniqueUid, "", Long.parseLong(offlineTime));
}
/**
* 玩家状态更新为在线
*/
public static void statusUpdate(String uid) {
if (!StringUtils.isEmpty(TimingAcquisition.playerMap.get(uid))) {
TimingAcquisition.playerMap.get(uid).setStatus(Constants.ONLINE);
//修改上线时间
TimingAcquisition.playerMap.get(uid).setOnlineTime(DateUtil.getCurrentTime());
}
}
/**
* 判断整数尾数是否为1
*/
public static CommonResult<ResultVarsResponse> AdjustParams(CommonResult<ResultVarsResponse> result) {
if (StringUtils.isEmpty(result)) {
return CommonResult.failed("操作失败");
}
ResultVarsResponse data = result.getData();
if (!StringUtils.isEmpty(data)) {
//所有“后台附加返回”为null值的都给转成“无效返回”
if (StringUtils.isEmpty(data.getVars().get后台附加返回())) {
data.getVars().set后台附加返回("无效返回");
}
//所有“后台附加返回”为null值的都给转成“无效返回”
if (StringUtils.isEmpty(data.getVars().get后台附加返回2())) {
data.getVars().set后台附加返回2("无效返回");
}
String feedContent = "后台返回参数 = [" +
"code:" + result.getCode() +
", msg:" + result.getMessage() +
", 反馈ID:" + data.getVars().get反馈ID() +
", 反馈文本:" + data.getVars().get反馈文本() +
", 后台附加返回:" + data.getVars().get后台附加返回() +
", 后台附加返回2:" + data.getVars().get后台附加返回2() +
"]";
//玩家有新消息提示
log.info(feedContent);
}
return result;
}
}
package com.qiwu.inference.common.utils;
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.common.utils;
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.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author: xingxing.ye
* @describe: fast json 工具
*/
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
* @author tongys
* @date 2013-4-2
*/
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(new FileOutputStream(file), 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.common.utils;
import java.io.File;
import java.io.InputStream;
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 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);
}
}
package com.qiwu.inference.common.utils;
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.common.utils;
import org.springframework.beans.factory.annotation.Value;
import org.yaml.snakeyaml.Yaml;
import java.io.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class PersistenceUtil {
/**
* 保存玩家数据到json文件
* @param fileName
* @param data
* @return void
*/
public static void saveDataToFile(String path, String fileName, String data) {
BufferedWriter writer = null;
File file = new File(path + fileName + ".json");
if (!file.exists()) {
try {
file.createNewFile();
} catch (Exception e) {
e.printStackTrace();
}
}
try {
writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file, false), "UTF-8"));
writer.write(data);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (writer != null) {
writer.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
/**
* 从json文件中读取玩家数据
* @param filePath
* @return String
*/
public static String getDataFromFile(String filePath) {
BufferedReader reader = null;
String lastStr = "";
try {
FileInputStream fileInputStream = new FileInputStream(filePath);
InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8");
reader = new BufferedReader(inputStreamReader);
String stringTmp = null;
while ((stringTmp = reader.readLine()) != null) {
lastStr += stringTmp;
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (reader != null) {
reader.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
return lastStr;
}
/**
* 从json文件中读取各配置文件的信息
* @param path
* @param fileName
* @return String
*/
public static String getConfigFromFile(String path, String fileName) {
BufferedReader reader = null;
String lastStr = "";
try {
FileInputStream fileInputStream = new FileInputStream(path + fileName);
InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8");
reader = new BufferedReader(inputStreamReader);
String stringTmp = null;
while ((stringTmp = reader.readLine()) != null) {
lastStr += stringTmp;
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (reader != null) {
reader.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
return lastStr;
}
/**
* 将话术转成map格式
* @param
* @return Map<String, Map<String, List<String>>>
*/
public static Map<String, Map<Integer, List<String>>> loadSpeechToMap(String speechFilePath, String fileName) {
Map<String, Map<Integer, List<String>>> speechMap = new HashMap<>();
try {
InputStream in = new FileInputStream(speechFilePath + fileName);
Yaml yaml = new Yaml();
speechMap = yaml.load(in);
} catch (Exception e) {
e.printStackTrace();
}
return speechMap;
}
}
package com.qiwu.inference.common.utils;
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.common.utils; package com.qiwu.inference.common.utils;
import com.qiwu.inference.common.TimingAcquisition;
import com.qiwu.inference.dto.request.CallRequest; import com.qiwu.inference.dto.request.CallRequest;
import com.qiwu.inference.dto.request.CommonRequest; import com.qiwu.inference.dto.request.CommonRequest;
import com.qiwu.inference.dto.request.OperationRequest; import com.qiwu.inference.dto.request.OperationRequest;
...@@ -19,10 +20,92 @@ public class RequestConversionUtil { ...@@ -19,10 +20,92 @@ public class RequestConversionUtil {
CallRequest callRequest = commonRequest.getVars(); CallRequest callRequest = commonRequest.getVars();
operationRequest.setUid(commonRequest.getUid()); operationRequest.setUid(commonRequest.getUid());
//---------------------存在姓名----------------------- //---------------------存在"方法编号"-----------------------
String name = callRequest.get玩家称呼(); String methodId = callRequest.get方法编号();
if (!StringUtils.isEmpty(name)) { if (!StringUtils.isEmpty(methodId)) {
operationRequest.setName(name); operationRequest.setMethodId(methodId);
}
//---------------------存在"人物名称1"-----------------------
String subjectName = callRequest.get人物名称1();
if (!StringUtils.isEmpty(subjectName)) {
//subjectName包含了多个人物名称
if (subjectName.contains("+")) {
String[] name = subjectName.split("\\+");
subjectName = name[0];
}
operationRequest.setSubjectName(subjectName);
Integer subjectId = TimingAcquisition.getPersonIdByName(commonRequest.getUid(), subjectName);
operationRequest.setSubjectId(subjectId);
//找到中文数字对应的阿拉伯数字
Integer number = TypeConvertUtil.change2Integer(subjectName);
//中文中不包含中文数字时,提取阿拉伯数字
if (number == 0) {
number = TypeConvertUtil.extractNum(subjectName);
}
operationRequest.setNum(number);
}
//---------------------存在"人物名称2"-----------------------
String objectName = callRequest.get人物名称2();
if (!StringUtils.isEmpty(objectName)) {
//objectName包含了多个人物名称
if (objectName.contains("+")) {
objectName = objectName.replace(subjectName, "");
objectName = objectName.replace("+", "");
}
operationRequest.setObjectName(objectName);
}
//---------------------存在"性格类型"-----------------------
String dispositionType = callRequest.get性格类型();
if (!StringUtils.isEmpty(dispositionType)) {
operationRequest.setDispositionType(dispositionType);
}
//---------------------存在"性格名称"-----------------------
String dispositionName = callRequest.get性格名称();
if (!StringUtils.isEmpty(dispositionName)) {
operationRequest.setDispositionName(dispositionName);
}
//---------------------存在"关系名称"-----------------------
String relationName = callRequest.get关系名称();
if (!StringUtils.isEmpty(relationName)) {
operationRequest.setRelationName(relationName);
}
//---------------------存在"行为名称"-----------------------
String behaviourName = callRequest.get行为名称();
if (!StringUtils.isEmpty(behaviourName)) {
operationRequest.setBehaviourName(behaviourName);
}
//---------------------存在"任务名称"-----------------------
String taskName = callRequest.get任务名称();
if (!StringUtils.isEmpty(taskName)) {
operationRequest.setTaskName(taskName);
}
//---------------------存在"身份名称"-----------------------
String identityName = callRequest.get身份名称();
if (!StringUtils.isEmpty(identityName)) {
operationRequest.setIdentityName(identityName);
}
//---------------------存在"场所名称"-----------------------
String locationName = callRequest.get场所名称();
if (!StringUtils.isEmpty(locationName)) {
String locationId = TimingAcquisition.getLocationIdByName(locationName);
operationRequest.setLocationName(locationName);
operationRequest.setLocationId(locationId);
}
//---------------------存在"人物名称ID"-----------------------
String subjectId = callRequest.get人物名称ID();
if (!StringUtils.isEmpty(subjectId)) {
operationRequest.setSubjectId(Integer.valueOf(subjectId));
}
//---------------------存在"任务条件"-----------------------
String taskConditionId = callRequest.get任务条件();
if (!StringUtils.isEmpty(taskConditionId)) {
operationRequest.setTaskConditionId(taskConditionId);
}
//---------------------存在"线索类型"-----------------------
String clueType = callRequest.get线索类型();
if (!StringUtils.isEmpty(clueType)) {
Integer clueTypeId = TimingAcquisition.getClueTypeIdByName(clueType);
operationRequest.setClueTypeId(clueTypeId);
} }
return operationRequest; return operationRequest;
} }
......
package com.qiwu.inference.common.utils; package com.qiwu.inference.common.utils;
import com.qiwu.inference.common.TimingAcquisition; import com.qiwu.inference.common.TimingAcquisition;
import com.qiwu.inference.pojo.DemandTask;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
...@@ -54,7 +55,7 @@ public class SpeechUtil { ...@@ -54,7 +55,7 @@ public class SpeechUtil {
* @param feedText * @param feedText
* @return String * @return String
*/ */
public static String getHelpSpeech(String someone, Integer feedText) { public static String getCheckSpeech(String someone, Integer feedText) {
String result = ""; String result = "";
List<String> speech = TimingAcquisition.checkSpeechMap.get(someone).get(feedText); List<String> speech = TimingAcquisition.checkSpeechMap.get(someone).get(feedText);
Integer i = getRandomNum(0, speech.size()); Integer i = getRandomNum(0, speech.size());
...@@ -63,6 +64,20 @@ public class SpeechUtil { ...@@ -63,6 +64,20 @@ public class SpeechUtil {
} }
/** /**
* 从查看模块话术获取话术
* @param someone
* @param feedText
* @return String
*/
public static String getBarrierSpeech(String someone, Integer feedText) {
String result = "";
List<String> speech = TimingAcquisition.barrierSpeechMap.get(someone).get(feedText);
Integer i = getRandomNum(0, speech.size());
result = speech.get(i);
return result;
}
/**
* 替换话术中的一个数字 * 替换话术中的一个数字
* @param one * @param one
* @return String * @return String
...@@ -187,6 +202,33 @@ public class SpeechUtil { ...@@ -187,6 +202,33 @@ public class SpeechUtil {
} }
/** /**
* 替换话术中的【A】
* @param A
* @return String
*/
public static String speechReplaceLetter(String text, String A) {
return text.replace("【A】", A);
}
/**
* 替换话术中的【A】和【B】
* @param A
* @param B
* @return String
*/
public static String speechReplaceLetter(String text, String A, String B) {
return text.replace("【A】", A).replace("【B】", B);
}
/**
* 获取线索配置表中的话术
*/
public static String getSpeechFromClue(String uid, Integer taskId) {
DemandTask demandTask = TimingAcquisition.demandTaskMap.get(taskId);
return null;
}
/**
* 删除话术的开头“【旁白@正常】” * 删除话术的开头“【旁白@正常】”
* @param text * @param text
*/ */
...@@ -203,4 +245,13 @@ public class SpeechUtil { ...@@ -203,4 +245,13 @@ public class SpeechUtil {
text2 = deleteAsideHead(text2); text2 = deleteAsideHead(text2);
return text1 + text2; return text1 + text2;
} }
/**
* 替换人物名称
* @param text
* @return String
*/
public static String replaceHeader(String text, String name) {
return text.replaceAll("【人物名称", "【" + name);
}
} }
package com.qiwu.inference.common.utils;
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.common.utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
/**
* <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
...@@ -16,22 +16,6 @@ public class YamlUtil { ...@@ -16,22 +16,6 @@ public class YamlUtil {
public static String speechFilePath = YamlUtil.getValueByKey("speechFilePath"); public static String speechFilePath = YamlUtil.getValueByKey("speechFilePath");
private static LinkedHashMap<String, Map<String, Map<String, String>>> properties = new LinkedHashMap<>(); private static LinkedHashMap<String, Map<String, Map<String, String>>> properties = new LinkedHashMap<>();
/**
* 将话术转成map格式
* @param
* @return Map<String, Map<String, List<String>>>
*/
public static Map<String, Map<Integer, List<String>>> loadSpeechToMap(String fileName) {
Map<String, Map<Integer, List<String>>> speechMap = new HashMap<>();
try {
InputStream in = new FileInputStream(speechFilePath + fileName);
Yaml yaml = new Yaml();
speechMap = yaml.load(in);
} catch (Exception e) {
e.printStackTrace();
}
return speechMap;
}
/** /**
* 读取配置文件yml中的某个值,只支持取第一层的值 * 读取配置文件yml中的某个值,只支持取第一层的值
......
package com.qiwu.inference.controller; package com.qiwu.inference.controller;
import com.qiwu.inference.common.ProxyFactory; import com.qiwu.inference.common.Constants;
import com.qiwu.inference.common.TimingAcquisition;
import com.qiwu.inference.common.api.CommonResult;
import com.qiwu.inference.common.utils.DataTrimUtil;
import com.qiwu.inference.common.utils.RequestConversionUtil; import com.qiwu.inference.common.utils.RequestConversionUtil;
import com.qiwu.inference.dto.request.CommonRequest; import com.qiwu.inference.dto.request.CommonRequest;
import com.qiwu.inference.dto.request.OperationRequest; import com.qiwu.inference.dto.request.OperationRequest;
import com.qiwu.inference.dto.response.CommonResponse;
import com.qiwu.inference.dto.response.ResultResponse; import com.qiwu.inference.dto.response.ResultResponse;
import com.qiwu.inference.dto.response.ResultVarsResponse; import com.qiwu.inference.dto.response.ResultVarsResponse;
import com.qiwu.inference.service.ask.AskService; import com.qiwu.inference.service.ask.AskService;
import com.qiwu.inference.service.ask.impl.AskServiceImpl; import com.qiwu.inference.service.barrier.BarrierService;
import com.qiwu.inference.service.check.CheckService;
import com.qiwu.inference.service.login.LoginService;
import com.qiwu.inference.service.task.TaskService;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.text.ParseException;
@RestController @RestController
@RequestMapping("/inference") @RequestMapping("/inference")
public class CommonController { public class CommonController {
Logger log = LoggerFactory.getLogger(CommonController.class); Logger log = LoggerFactory.getLogger(CommonController.class);
//询问模块动态代理 @Value("${offlineTime}")
AskService askService = new AskServiceImpl(); private String offlineTime;
AskService askServiceProxy = (AskService) new ProxyFactory(askService).getProxyInstance();
@Autowired
private LoginService loginService;
@Autowired
private AskService askService;
@Autowired
private TaskService taskService;
@Autowired
private CheckService checkService;
@Autowired
private BarrierService barrierService;
@PostMapping(value = "/ask", produces = "application/json;charset=UTF-8") @PostMapping(value = "/ask", produces = "application/json;charset=UTF-8")
public CommonResponse startGame(@RequestBody CommonRequest commonRequest) { public CommonResult<ResultVarsResponse> startGame(@RequestBody CommonRequest commonRequest) throws ParseException {
log.info(commonRequest.getUid() + "当前操作的原始请求参数:" + commonRequest.getVars()); log.info(commonRequest.getUid() + "当前操作的原始请求参数:" + commonRequest.getVars());
CommonResponse result = new CommonResponse(); CommonResult<ResultVarsResponse> result = null;
String uid = commonRequest.getUid();
boolean login = false;
//玩家第一次登录
if (StringUtils.isEmpty(TimingAcquisition.playerMap.get(uid))) {
loginService.login(uid);
login = true;
}
//请求参数转换
OperationRequest operationReq = RequestConversionUtil.request2Operation(commonRequest); OperationRequest operationReq = RequestConversionUtil.request2Operation(commonRequest);
//非新登录玩家,修改在线状态
if (!login && !StringUtils.isEmpty(uid)) {
DataTrimUtil.AdjustStatus(commonRequest.getUid(), offlineTime);
}
String operateName = commonRequest.getVars().get操作名(); String operateName = commonRequest.getVars().get操作名();
log.info(operationReq.getUid() + "开始执行操作:【" + operateName + "】, 请求参数:" + operationReq); log.info(uid + "开始执行操作:【" + operateName + "】, 请求参数:" + operationReq);
//操作名为null //操作名为null
if (StringUtils.isEmpty(operateName)) { if (StringUtils.isEmpty(operateName)) {
log.info(operationReq.getUid() + "未提供操作名,无法操作"); log.info(operationReq.getUid() + "未提供操作名,无法操作");
ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); ResultVarsResponse resultVarsResponse = new ResultVarsResponse();
ResultResponse resultResponse = new ResultResponse(); ResultResponse resultResponse = new ResultResponse();;
result.setCode(1);
result.setMsg("成功");
resultResponse.set反馈ID(100000); resultResponse.set反馈ID(100000);
resultResponse.set反馈文本("【旁白@正常】你想做什么呢?"); resultResponse.set反馈文本("【旁白@正常】你想做什么呢?");
resultVarsResponse.setVars(resultResponse); resultVarsResponse.setVars(resultResponse);
result.setData(resultVarsResponse); return CommonResult.success(resultVarsResponse);
return result;
} }
switch (operateName) { switch (operateName) {
case "开始游戏": case "询问操作":
result = askServiceProxy.ask(operationReq); result = askService.ask(operationReq);
break;
case "任务操作":
result = taskService.execute(operationReq);
break;
case "查看操作":
result = checkService.check(operationReq);
break;
case "关卡操作":
result = barrierService.operate(operationReq);
break;
case "取消操作指令":
result = barrierService.cancel(operationReq);
break; break;
} }
log.info(operationReq.getUid() + "已完成操作:【" + commonRequest.getVars().get操作名() + "】"); log.info(uid + "已完成操作:【" + operateName + "】");
return result; return DataTrimUtil.AdjustParams(result);
} }
} }
package com.qiwu.inference.controller;
import cn.hutool.core.lang.UUID;
import com.alibaba.fastjson.JSON;
import com.qiwu.inference.common.TimingAcquisition;
import com.qiwu.inference.common.api.CommonData;
import com.qiwu.inference.common.api.CommonResult;
import com.qiwu.inference.common.utils.*;
import com.qiwu.inference.dto.Player;
import com.qiwu.inference.dto.request.OperationRequest;
import com.qiwu.inference.dto.response.ResultVarsResponse;
import com.qiwu.inference.service.PersonRecordService;
import com.qiwu.inference.service.player.PlayerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
* <p>
* 前端控制器
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
@RestController
@RequestMapping("/api")
public class PlayerController {
@Value("${userFilePath}")
private String userFilePath;
@Autowired
private PersonRecordService personRecordService;
@Autowired
private PlayerService playerService;
@RequestMapping(value = "/getGateNo", method = RequestMethod.GET)
@ResponseBody
public CommonResult<Player> getGateNo() throws Exception{
List<String> gateNoList = personRecordService.getGateNo();
int index = RandomUtil.randomInt(gateNoList.size());
Player player = new Player();
player.setGateNo(gateNoList.get(index));
String sid = UUID.fastUUID().toString();
player.setSid(sid);
PersistenceUtil.saveDataToFile(userFilePath, sid, JSON.toJSONString(player));
//ThreadLocalUtil.add(sid,player);
return CommonResult.success(player);
}
@RequestMapping(value = "/operate", method = RequestMethod.POST)
@ResponseBody
public CommonResult<ResultVarsResponse> operate(@RequestBody OperationRequest request) throws Exception{
String methodId = request.getMethodId();
switch (methodId){
case "1001":
case "1002":
return playerService.askDisposition(request);
case "1003":
case "1004":
case "1005":
case "1006":
return playerService.askRelation(request);
case "1007":
case "1008":
case "1009":
case "1010":
case "1011":
return playerService.askBehaviour(request);
case "1012":
case "1013":
case "1014":
case "1015":
case "1016":
case "1017":
case "1018":
case "1019":
case "1020":
case "1021":
case "1022":
return playerService.askTask(request);
case "1023":
case "1024":
return playerService.askIdentity(request);
case "1025":
case "1026":
return playerService.askLocation(request);
case "1027":
return playerService.askPrompt(request);
case "2001":
case "2003":
case "2002":
case "2004":
case "2005":
case "2006":
case "2007":
case "2008":
case "2009":
case "2010":
case "2011":
case "2012":
case "2013":
case "2014":
case "2015":
case "2016":
case "2017":
case "2018":
case "2019":
return playerService.performTask(request);
}
return null;
}
}
package com.qiwu.inference.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qiwu.inference.pojo.Behaviour;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
@Mapper
@Repository
public interface BehaviourMapper extends BaseMapper<Behaviour> {
}
package com.qiwu.inference.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qiwu.inference.pojo.BehaviourRecord;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
@Mapper
@Repository
public interface BehaviourRecordMapper extends BaseMapper<BehaviourRecord> {
}
package com.qiwu.inference.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qiwu.inference.pojo.Clue;
import com.qiwu.inference.pojo.ClueType;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xingxing.ye
* @since 2022-11-07
*/
@Mapper
@Repository
public interface ClueMapper extends BaseMapper<Clue> {
List<ClueType> getTypeInfo();
List<Clue> findAll();
}
package com.qiwu.inference.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qiwu.inference.pojo.ClueRecord;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
@Mapper
@Repository
public interface ClueRecordMapper extends BaseMapper<ClueRecord> {
}
package com.qiwu.inference.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qiwu.inference.pojo.DemandTask;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xingxing.ye
* @since 2022-11-07
*/
@Mapper
@Repository
public interface DemandTaskMapper extends BaseMapper<DemandTask> {
List<DemandTask> findAll();
}
package com.qiwu.inference.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qiwu.inference.pojo.DemandTaskRecord;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xingxing.ye
* @since 2022-11-07
*/
@Mapper
@Repository
public interface DemandTaskRecordMapper extends BaseMapper<DemandTaskRecord> {
}
package com.qiwu.inference.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qiwu.inference.pojo.Disposition;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
@Mapper
@Repository
public interface DispositionMapper extends BaseMapper<Disposition> {
List<Disposition> findAll();
}
package com.qiwu.inference.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qiwu.inference.pojo.DispositionRecord;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
@Mapper
@Repository
public interface DispositionRecordMapper extends BaseMapper<DispositionRecord> {
}
package com.qiwu.inference.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qiwu.inference.pojo.DispositionType;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xingxing.ye
* @since 2022-11-04
*/
@Mapper
@Repository
public interface DispositionTypeMapper extends BaseMapper<DispositionType> {
}
package com.qiwu.inference.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qiwu.inference.pojo.EndGoal;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
@Mapper
@Repository
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 org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
@Mapper
@Repository
public interface IdentityMapper extends BaseMapper<Identity> {
}
package com.qiwu.inference.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qiwu.inference.pojo.Item;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
@Mapper
@Repository
public interface ItemMapper extends BaseMapper<Item> {
}
package com.qiwu.inference.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qiwu.inference.pojo.KeyClue;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
@Mapper
@Repository
public interface KeyClueMapper extends BaseMapper<KeyClue> {
}
package com.qiwu.inference.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qiwu.inference.pojo.Location;
import com.qiwu.inference.pojo.SystemConfigPojo;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
@Mapper
@Repository
public interface LocationMapper extends BaseMapper<Location> {
List<Location> findAll();
}
package com.qiwu.inference.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qiwu.inference.pojo.Moniker;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
@Mapper
@Repository
public interface MonikerMapper extends BaseMapper<Moniker> {
}
package com.qiwu.inference.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qiwu.inference.pojo.PersonRecord;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
@Mapper
@Repository
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;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xingxing.ye
* @since 2022-11-03
*/
@Mapper
@Repository
public interface RelationMapper extends BaseMapper<Relation> {
}
package com.qiwu.inference.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qiwu.inference.pojo.RelationRecord;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
@Mapper
@Repository
public interface RelationRecordMapper extends BaseMapper<RelationRecord> {
}
package com.qiwu.inference.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qiwu.inference.pojo.RelationType;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xingxing.ye
* @since 2022-11-03
*/
@Mapper
@Repository
public interface RelationTypeMapper extends BaseMapper<RelationType> {
}
package com.qiwu.inference.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qiwu.inference.pojo.Surname;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
@Mapper
@Repository
public interface SurnameMapper extends BaseMapper<Surname> {
}
package com.qiwu.inference.dao;
import com.qiwu.inference.pojo.SystemConfigPojo;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
import java.util.List;
@Mapper
@Repository
public interface SystemConfigMapper {
List<SystemConfigPojo> findAll();
SystemConfigPojo findByName(String name);
}
package com.qiwu.inference.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qiwu.inference.pojo.TaskCondition;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xingxing.ye
* @since 2022-11-02
*/
@Mapper
@Repository
public interface TaskConditionMapper extends BaseMapper<TaskCondition> {
}
package com.qiwu.inference.dto;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
@Getter
@Setter
public class BehaviourDto implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
private Integer id;
/**
* 行为名称
*/
private String name;
/**
* 行为id
*/
private Integer behaviourId;
/**
* 行为描述
*/
private String description;
/**
* 主体
*/
private Integer subject;
/**
* 主体名称
*/
private String subjectName;
/**
* 客体
*/
private Integer object;
/**
* 客体名称
*/
private String objectName;
}
package com.qiwu.inference.dto;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
@Getter
@Setter
public class ClueDto implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
private Integer id;
/**
* 线索id
*/
private Integer clueId;
/**
* 线索名称
*/
private String clueName;
/**
* 主体
*/
private Integer subject;
/**
* 客体
*/
private Integer object;
/**
* 描述
*/
private String description;
/**
* 类型: 1:身份 2:场所 3:性格爱好 4:行为 5:关系 6:任务 9: 关键线索
*/
private Integer type;
/**
* 信息级别
*/
private Integer infoLevel;
/**
* 关联人物
*/
private Integer associatedPerson;
/**
* 线索模板
*/
private String clueTemplate;
/**
* 信任度
*/
private Integer trustDegree;
/**
* 威胁
*/
private Integer threaten;
}
package com.qiwu.inference.dto;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
@Getter
@Setter
public class DemandTaskDto implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
private Integer id;
/**
* demandTaskId
*/
private Integer demandTaskId;
/**
* 名称
*/
private String name;
/**
* 描述
*/
private String description;
/**
* 主体
*/
private Integer subject;
/**
* 客体
*/
private Integer object;
/**
* 开启条件信任度
*/
private String trustCondition;
/**
* 开启条件威慑度
*/
private String deterrenceCondition;
/**
* 条件1|次数
*/
private String condition1;
/**
* 条件2|次数
*/
private String condition2;
/**
* 信任度增减
*/
private String trustDegree;
/**
* 威慑度增减
*/
private String deterrenceDegree;
/**
* 完成奖励
*/
private String completionReward;
/**
* 完成反馈
*/
private String completionFeedback;
/**
* 有效次数
*/
private String effectiveDegree;
/**
* 后置任务
*/
private String postTask;
/**
* 类型: 1:身份 2:场所 3:性格爱好 4:行为 5:关系 6:任务 9:关键线索
*/
private Integer type;
/**
* 线索id
*/
private Integer clueId;
/**
* 信息级别
*/
private Integer infoLevel;
/**
* 任务标签 1普通任务 2关键任务 3目标任
*/
private Integer taskLabel;
}
package com.qiwu.inference.dto;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
@Getter
@Setter
public class DispositionDto implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
private Integer id;
/**
* 性格id
*/
private Integer dispositionId;
/**
* 人物id
*/
private Integer subject;
/**
* 性格名称
*/
private String name;
/**
* 性格描述
*/
private String description;
/**
* 类型
*/
private String type;
}
package com.qiwu.inference.dto;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.util.List;
@Getter
@Setter
public class Person implements Serializable {
/**
* 人物编号
*/
private Integer id;
/**
* 人物名称
*/
private String name;
/**
* 身份id
*/
private Integer identityId;
/**
* 身份名称
*/
private String identityName;
/**
* 年龄
*/
private Integer age;
/**
* 是否为关键人物 1 关键人物 2 普通人物
*/
private Integer isKey;
/**
* 性别
*/
private Integer gender;
/**
* 所在地
*/
private String location;
/**
* 人物拥有的性格
*/
private List<DispositionDto> dispositions;
/**
* 人物拥有的关系
*/
private List<RelationDto> relations;
/**
* 人物拥有的行为
*/
private List<BehaviourDto> behaviours;
/**
* 人物掌握的线索集合
*/
private List<ClueDto> clues;
/**
* 人物的需求任务集合
*/
private List<DemandTaskDto> demandTasks;
/**
* 信任度
*/
private Integer trustDegree = 50;
/**
* 威胁
*/
private Integer deterrenceDegree = 50;
}
package com.qiwu.inference.dto;
import com.qiwu.inference.common.Constants;
import com.qiwu.inference.common.TimingAcquisition;
import com.qiwu.inference.common.utils.FastJsonUtil;
import com.qiwu.inference.common.utils.RandomUtil;
import lombok.Getter;
import lombok.Setter;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Getter
@Setter
public class Player {
/**
* 会话id
*/
private String sid;
/**
* 关卡编号
*/
private String gateNo;
/**
* 关卡等级
*/
private String level;
/**
* 当前等级通关总次数
*/
private String total;
/**
* 当前关卡已完成次数
*/
private String finished;
/**
* 玩家在线状态
*/
private Integer status = Constants.OFFLINE;
/**
* 玩家上线时间
*/
private String onlineTime;
/**
* 玩家下线时间
*/
private String offlineTime;
/**
* 玩家所在场所
*/
private String location;
/**
* 玩家当前对话的人物
*/
private Integer personId;
/**
* 人物集合
*/
private Map<Integer,Person> personMap;
/**
* 人物的姓名和编号转换 map
*/
private Map<String,Integer> name2IdMap;
/**
* 当前关卡的货币
*/
private Double currency = 1000.0;
/**
* 当前关卡的积分
*/
private Integer point = 0;
/**
* 总货币
*/
private Double totalCurrency = 0.0;
/**
* 总积分
*/
private Integer totalPoint = 0;
/**
* 已获得人物线索: Map<人物id, Map<线索类型id, List<线索>>。没有线索则仅仅对话过
*/
private Map<Integer,Map<Integer,List<ClueDto>>> clueMap = new HashMap<>();
/**
* 线索集合表
*/
private List<ClueDto> clues = new ArrayList<>();
/**
* 已完成任务集合表: Map<人物id, Map<任务id, 任务状态>>
*/
private Map<Integer,Map<Integer,Integer>> taskMap = new HashMap<>();
public Player(){
//初始化推理游戏人物
List<String> keys = new ArrayList<>(TimingAcquisition.gateInfoMap.keySet());
int index = RandomUtil.randomInt(keys.size());
this.gateNo = keys.get(index);
List<Person> personList = TimingAcquisition.gateInfoMap.get(keys.get(index));
personMap = new HashMap<>();
name2IdMap = new HashMap<>();
for (Person person : personList) {
taskMap.put(person.getId(), new HashMap<>());
personMap.put(person.getId(), person);
name2IdMap.put(person.getName(), person.getId());
}
}
/**
* 读取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.dto;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
@Getter
@Setter
public class RelationDto implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
private Integer id;
/**
* 关系名称
*/
private String name;
/**
* 关系描述
*/
private String description;
/**
* 类型
*/
private Integer type;
/**
* 关系id
*/
private Integer relationId;
/**
* 关系的主体
*/
private Integer subject;
/**
* 主体名称
*/
private String subjectName;
/**
* 关系客体
*/
private Integer object;
/**
* 客体名称
*/
private String objectName;
/**
* 掌握信息级别
*/
private Integer masterInfoLevel;
}
...@@ -10,8 +10,59 @@ public class CallRequest { ...@@ -10,8 +10,59 @@ public class CallRequest {
*/ */
private String 操作名; private String 操作名;
/** /**
* 玩家称呼 * 方法编号
*/ */
@JsonProperty(value = "GB_玩家称呼") private String 方法编号;
private String 玩家称呼; /**
* 人物名称1
*/
private String 人物名称1;
/**
* 人物名称2
*/
private String 人物名称2;
/**
* 人物名称3
*/
private String 人物名称3;
/**
* 性格类型
*/
private String 性格类型;
/**
* 性格名称
*/
private String 性格名称;
/**
* 关系名称
*/
private String 关系名称;
/**
* 行为名称
*/
private String 行为名称;
/**
* 任务名称
*/
private String 任务名称;
/**
* 身份名称
*/
private String 身份名称;
/**
* 场所名称
*/
private String 场所名称;
/**
* 人物名称ID
*/
private String 人物名称ID;
/**
* 任务条件ID
*/
private String 任务条件;
/**
* 线索类型
*/
private String 线索类型;
} }
package com.qiwu.inference.dto.request; package com.qiwu.inference.dto.request;
import com.qiwu.inference.dto.ClueDto;
import io.swagger.models.auth.In;
import lombok.Data; import lombok.Data;
import java.util.List;
@Data @Data
public class OperationRequest { public class OperationRequest {
/** /**
...@@ -9,19 +13,79 @@ public class OperationRequest { ...@@ -9,19 +13,79 @@ public class OperationRequest {
*/ */
private String operate; private String operate;
/** /**
* 方法编号
*/
private String methodId;
/**
* 用户唯一ID * 用户唯一ID
*/ */
private String uid; private String uid;
/** /**
* 名称 * 人物名称1
*/
private String subjectName;
/**
* 人物名称2
*/
private String objectName;
/**
* 性格名称
*/
private String dispositionName;
/**
* 关系名称
*/
private String relationName;
/**
* 行为名称
*/
private String behaviourName;
/**
* 任务名称
*/
private String taskName;
/**
* 身份名称
*/
private String identityName;
/**
* 场所名称
*/
private String locationName;
/**
* 场所id
*/
private String locationId;
/**
* 性格类型
*/
private String dispositionType;
/**
* 人物名称ID
*/
private Integer subjectId;
/**
* 任务条件ID
*/
private String taskConditionId;
/**
* 线索类型ID
*/
private Integer clueTypeId;
/**
* 玩家获得某人的线索集合
*/
private List<ClueDto> clueList;
/**
* 集合待查看的索引
*/ */
private String name; private Integer index;
/** /**
* 性别: 男-1,女-2 * 待查看人物id集合
*/ */
private Integer gender; private List<Integer> personIdList;
/** /**
* 地点 * 序号
*/ */
private String place; private Integer num;
} }
package com.qiwu.inference.dto.response;
import lombok.Data;
@Data
public class DataResponse {
/**
* 消息id
*/
public Integer id;
/**
* 消息文本
*/
public String text;
}
package com.qiwu.inference.dto.response;
import lombok.Data;
import java.io.Serializable;
@Data
public class InferenceResponse implements Serializable {
/**
* 返回状态码
*/
private Integer code;
/**
* 返回信息
*/
private String message;
/**
* 返回内容
*/
private DataResponse data;
}
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 Integer inverseLabel;
@ApiModelProperty("单人行为标签:0为双人行为,1为单人行为")
private Integer singleLabel;
@ApiModelProperty("信息级别")
private Integer 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 Integer behaviourId;
@ApiModelProperty("行为描述")
private String description;
@ApiModelProperty("主体:1")
private Integer subject;
@ApiModelProperty("主体名称:老王")
private String subjectName;
@ApiModelProperty("客体:2")
private Integer 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 Integer type;
@ApiModelProperty("对应的Id")
private Integer associatedId;
@ApiModelProperty("线索模板")
private String clueTemplate;
@ApiModelProperty("信息级别")
private Integer infoLevel;
@ApiModelProperty("信任度")
private Integer trustDegree;
@ApiModelProperty("威胁")
private Integer threaten;
@ApiModelProperty("操作1|信任度|威胁")
private Integer operate;
@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 Integer clueId;
@ApiModelProperty("线索名称")
private String clueName;
@ApiModelProperty("主体")
private Integer subject;
@ApiModelProperty("客体")
private Integer object;
@ApiModelProperty("描述")
private String description;
@ApiModelProperty("类型: 1:身份 2:场所 3:性格爱好 4:行为 5:关系 6:任务 9: 关键线索 ")
private Integer type;
@ApiModelProperty("信息级别")
private Integer infoLevel;
@ApiModelProperty("关联人物")
private Integer associatedPerson;
@ApiModelProperty("线索模板")
private String clueTemplate;
@ApiModelProperty("信任度")
private Integer trustDegree;
@ApiModelProperty("威胁")
private Integer threaten;
@ApiModelProperty("创建时间")
private Date createTime;
@ApiModelProperty("更新时间")
private Date updateTime;
}
package com.qiwu.inference.pojo;
import lombok.Data;
@Data
public class ClueType {
private Integer id;
private String name;
}
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 String description;
@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 String trustDegree;
@ApiModelProperty("威慑度增减")
private String deterrenceDegree;
@ApiModelProperty("完成奖励")
private String completionReward;
@ApiModelProperty("完成反馈")
private String completionFeedback;
@ApiModelProperty("有效次数")
private String effectiveDegree;
@ApiModelProperty("特殊任务 0 主动任务 1 被动任务")
private String specialTask;
@ApiModelProperty("信息级别")
private Integer infoLevel;
@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 Integer demandTaskId;
@ApiModelProperty("名称")
private String name;
@ApiModelProperty("描述")
private String description;
@ApiModelProperty("主体")
private Integer subject;
@ApiModelProperty("客体")
private Integer object;
@ApiModelProperty("信息级别")
private Integer 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 = "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 String type;
@ApiModelProperty("基础权重")
private Integer weight;
@ApiModelProperty("身份影响权重:")
private String identityWeight;
@ApiModelProperty("性别影响概率:")
private String genderWeight;
@ApiModelProperty("年龄影响权重:")
private String ageWeight;
@ApiModelProperty("好感度初始值:")
private String favorDegree;
@ApiModelProperty("弱点条件:")
private String weaknessCondition;
@ApiModelProperty("对应物品|好感度增减:")
private String itemFavorDegree;
@ApiModelProperty("对应身份|好感度增减:")
private String identityFavorDegree;
@ApiModelProperty("互斥性格|喜好:")
private String exclusionDisposition;
@ApiModelProperty("信息重要级别")
private Integer 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 Integer dispositionId;
@ApiModelProperty("人物id")
private Integer subject;
@ApiModelProperty("性格名称")
private String name;
@ApiModelProperty("性格描述")
private String description;
@ApiModelProperty("类型")
private String 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 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("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 String keyIdentity;
@ApiModelProperty("年龄生成规则:5|99")
private String ageCondition;
@ApiModelProperty("对应场所:")
private String location;
@ApiModelProperty("对应性别")
private Integer gender;
@ApiModelProperty("指定名称:")
private String createName;
@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 String subjectLabel;
@ApiModelProperty("掌握线索人物身份(乙)")
private String objectIdentity;
@ApiModelProperty("人物标签(乙)")
private String objectLabel;
@ApiModelProperty("关系(留空为自己)")
private String relation;
@ApiModelProperty("前置线索:90002|90003")
private String precue;
@ApiModelProperty("线索组合:")
private String clueGroup;
@ApiModelProperty("对应目标:")
private String target;
@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 String isHidden;
@ApiModelProperty("对应线索模板:")
private String clueTemplate;
@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 = "Moniker对象", description = "")
public class Moniker implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("id")
private Integer id;
@ApiModelProperty("名字")
private String name;
@ApiModelProperty("性别")
private String gender;
@ApiModelProperty("特殊身份")
private String specialIdentity;
@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 Integer identityId;
@ApiModelProperty("身份名称")
private String identityName;
@ApiModelProperty("年龄")
private Integer age;
@ApiModelProperty("是否为关键人物 1 关键人物 2 普通人物")
private Integer isKey;
@ApiModelProperty("性别")
private Integer gender;
@ApiModelProperty("所在地")
private String location;
@ApiModelProperty("性格")
private String disposition;
@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 Integer type;
@ApiModelProperty("权重")
private Integer 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 Integer infoLevel;
@ApiModelProperty("掌握信息级别")
private Integer 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 Integer type;
@ApiModelProperty("关系id")
private Integer relationId;
@ApiModelProperty("关系的主体")
private Integer subject;
@ApiModelProperty("主体名称:老王")
private String subjectName;
@ApiModelProperty("关系客体")
private Integer object;
@ApiModelProperty("客体名称:老王")
private String objectName;
@ApiModelProperty("掌握信息级别")
private Integer 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 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 = "Surname对象", description = "")
public class Surname implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("id")
private Integer id;
@ApiModelProperty("姓氏")
private String name;
@ApiModelProperty("创建时间")
private Date createTime;
@ApiModelProperty("更新时间")
private Date updateTime;
}
package com.qiwu.inference.pojo;
import lombok.Data;
@Data
public class SystemConfigPojo {
/**
* 系统参数名称
*/
private String name;
/**
* 系统参数值
*/
private String value;
/**
* 参数说明
*/
private String description;
/**
* 参数状态:0-不可用,1-可用
*/
private Integer status;
/**
* 创建时间
*/
private String createTime;
/**
* 修改时间
*/
private String updateTime;
}
This source diff could not be displayed because it is too large. You can view the blob instead.
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