|
@@ -8,7 +8,11 @@ import com.rf.kjb.excel.ExcelUtil;
|
|
|
import com.rf.kjb.exception.ErrorCode;
|
|
|
import com.rf.kjb.intelligentDialogue.dao.domain.IntelligentDialogueEntity;
|
|
|
import com.rf.kjb.intelligentDialogue.service.IntelligentDialogueService;
|
|
|
+import com.rf.kjb.opLog.dao.model.SysLogEntity;
|
|
|
+import com.rf.kjb.opLog.service.SysLogService;
|
|
|
import com.rf.kjb.scale.util.DateUtil;
|
|
|
+import com.rf.kjb.user.dao.model.UserEntry;
|
|
|
+import com.rf.kjb.user.service.UserService;
|
|
|
import com.rf.kjb.utils.JWTUtil;
|
|
|
import com.rf.kjb.utils.Result;
|
|
|
import com.rf.kjb.utils.ZipUtils;
|
|
@@ -30,8 +34,6 @@ import java.io.*;
|
|
|
import java.nio.file.Files;
|
|
|
import java.nio.file.Path;
|
|
|
import java.nio.file.Paths;
|
|
|
-import java.text.DateFormat;
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
@@ -41,9 +43,15 @@ import java.util.stream.Stream;
|
|
|
@Api(tags = "对话")
|
|
|
public class IntelligentDialogueController extends BaseController {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private UserService userService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private IntelligentDialogueService intelligentDialogueService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private SysLogService sysLogService;
|
|
|
+
|
|
|
|
|
|
@PostMapping("/save")
|
|
|
@ApiOperation(value = "保存对话", notes = "identifier:用户编号;userName:用户名;label:对话分类:0-问;1-答;content:对话内容")
|
|
@@ -67,19 +75,24 @@ public class IntelligentDialogueController extends BaseController {
|
|
|
return success(jsonObject);
|
|
|
}else {
|
|
|
Date beginTime = intelligentDialogueEntities.getContent().get(0).getCreateTime();
|
|
|
- //当前时间
|
|
|
- Date endTime = new Date();
|
|
|
- //计算时间差---分钟
|
|
|
- int diff = DateUtil.getDistanceByUnit(beginTime, endTime, 4);
|
|
|
String token = request.getHeader("Authorization");
|
|
|
token = token.split(" ")[1];//以空格划分Bearer token,获取token
|
|
|
//从请求头中获取token
|
|
|
DecodedJWT verify = JWTUtil.verify(token);
|
|
|
- String userName = verify.getClaim("userName").asString();
|
|
|
- if (diff < 0 || diff >= 4) {
|
|
|
- greetings = userName + "你好,很高兴你又来跟我聊天了。咱们已经" + diff + "天没有见面了。";
|
|
|
- }else {
|
|
|
- greetings = userName + "你好,很高兴你又来跟我聊天了。";
|
|
|
+ String identifier2 = verify.getClaim("identifier").asString();
|
|
|
+ SysLogEntity sysLogEntity = this.sysLogService.getSysLogByIdentifier(identifier2);
|
|
|
+ UserEntry userEntry = this.userService.findByIdentifier(identifier2);
|
|
|
+ //当前时间
|
|
|
+ Date endTime = sysLogEntity.getCreateTime();
|
|
|
+ //计算时间差
|
|
|
+ int diff = DateUtil.getDistanceByUnit(beginTime, endTime, 4);
|
|
|
+ int diff1 = DateUtil.getDistanceByUnit(beginTime, endTime, 1);
|
|
|
+ if (diff1 > 0){
|
|
|
+ if (diff >= 3) {
|
|
|
+ greetings = userEntry.getUserName() + "你好,很高兴你又来跟我聊天了。咱们已经" + diff + "天没有见面了。是否继续上次聊天?";
|
|
|
+ }else {
|
|
|
+ greetings = userEntry.getUserName() + "你好,很高兴你又来跟我聊天了。是否继续上次聊天?";
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
JSONObject jsonObject = new JSONObject();
|