提交会话管理相关代码

main
liu 1 year ago
parent 9949937e21
commit dfe559509e

@ -1,9 +1,11 @@
package com.supervision;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
@MapperScan(basePackages = {"com.supervision.**.mapper"})
public class InterroRobotApplication {
public static void main(String[] args) {

@ -1,6 +1,9 @@
package com.supervision.config;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.supervision.config.domain.UserInfo;
import com.supervision.util.UserUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;
@ -16,11 +19,21 @@ public class MybatisMetaHandler implements MetaObjectHandler {
// 填充
this.strictInsertFill(metaObject, "createTime", LocalDateTime.class, LocalDateTime.now());
this.strictInsertFill(metaObject, "updateTime", LocalDateTime.class, LocalDateTime.now());
UserInfo user = UserUtil.getUser();
if (ObjectUtil.isNotEmpty(user)) {
this.strictInsertFill(metaObject, "createUserId", String.class, user.getId());
this.strictInsertFill(metaObject, "updateUserId", String.class, user.getId());
}
}
@Override
public void updateFill(MetaObject metaObject) {
log.info("填充修改时间以及修改用户");
this.strictUpdateFill(metaObject, "updateTime", LocalDateTime.class, LocalDateTime.now());
UserInfo user = UserUtil.getUser();
if (ObjectUtil.isNotEmpty(user)) {
this.strictInsertFill(metaObject, "updateUserId", String.class, user.getId());
}
}
}

@ -0,0 +1,119 @@
package com.supervision.config;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.supervision.config.domain.GlobalResult;
import com.supervision.exception.BusinessException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.MethodParameter;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.server.ServerHttpRequest;
import org.springframework.http.server.ServerHttpResponse;
import org.springframework.lang.Nullable;
import org.springframework.validation.BindException;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
import java.util.Objects;
import java.util.stream.Collectors;
/**
*
*
* @author wb
* @date 2022/3/10 13:24
*/
@Slf4j
@RestControllerAdvice(annotations = RestController.class, basePackages = {"com.**.controller"})
public class ResponseConfig implements ResponseBodyAdvice<Object> {
@Override
public boolean supports(@Nullable MethodParameter methodParameter,
@Nullable Class<? extends HttpMessageConverter<?>> aClass) {
assert methodParameter != null;
return !methodParameter.getDeclaringClass().getName().contains("swagger");
}
@Override
@SuppressWarnings("all")
public Object beforeBodyWrite(Object o, @Nullable MethodParameter methodParameter, @Nullable MediaType mediaType,
@Nullable Class<? extends HttpMessageConverter<?>> aClass, @Nullable ServerHttpRequest serverHttpRequest,
@Nullable ServerHttpResponse serverHttpResponse) {
serverHttpResponse.getHeaders().set("Content-Type", "application/json");
if (Objects.isNull(o)) {
return GlobalResult.ok(null, "success");
}
if (o instanceof GlobalResult) {
return o;
}
// 对于String类型的返回值需要进行特殊处理
if (o instanceof String) {
return JSONUtil.toJsonStr(GlobalResult.ok(o, "success"));
}
return GlobalResult.ok(o, "success");
}
/**
*
*
* @param exception
* @return
*/
@ExceptionHandler(BusinessException.class)
public GlobalResult<?> businessExceptionResponse(BusinessException exception) {
log.error(exception.getMessage(), exception);
Integer code = null == exception.getCode() ? HttpStatus.INTERNAL_SERVER_ERROR.value(): exception.getCode();
String message = StrUtil.isNotEmpty(exception.getMessage()) ? exception.getMessage() : "业务异常";
return GlobalResult.error( code, exception.getMessage(), message);
}
/**
*
*
* @param exception
* @return
*/
@ExceptionHandler({MethodArgumentNotValidException.class, BindException.class})
public GlobalResult<?> validationExceptionResponse(MethodArgumentNotValidException exception) {
log.error(exception.getMessage(), exception);
// 格式化错误信息
String errorMsg = exception.getBindingResult().getFieldErrors().stream()
.map(e -> e.getField() + ":" + e.getDefaultMessage()).collect(Collectors.joining("、"));
return GlobalResult.error(HttpStatus.INTERNAL_SERVER_ERROR.value(), errorMsg, "参数验证异常");
}
/**
*
* @param exception
* @return
*/
@ExceptionHandler(IllegalArgumentException.class)
public GlobalResult<?> manualValidationExceptionResponse(IllegalArgumentException exception) {
log.error(exception.getMessage(), exception);
return GlobalResult.error(HttpStatus.INTERNAL_SERVER_ERROR.value(), exception.getMessage(), "参数验证异常");
}
/**
*
*
* @param exception
* @return
*/
@ExceptionHandler(Exception.class)
public GlobalResult<?> validationExceptionResponse(Exception exception) {
log.error(exception.getMessage(), exception);
return GlobalResult.error(HttpStatus.INTERNAL_SERVER_ERROR.value(), "未知错误", "未知错误");
}
}

@ -0,0 +1,49 @@
package com.supervision.config.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.http.HttpStatus;
@Data
@ApiModel
public class GlobalResult<T> {
private int code = 200;
private String msg = "success";
@ApiModelProperty
private T data;
public static <T> GlobalResult<T> ok() {
return ok(null);
}
public static <T> GlobalResult<T> ok(T data) {
GlobalResult<T> globalResult = new GlobalResult<>();
globalResult.setData(data);
return globalResult;
}
public static <T> GlobalResult<T> ok(T data, String message) {
GlobalResult<T> globalResult = new GlobalResult<>();
globalResult.setMsg(message);
globalResult.setData(data);
return globalResult;
}
public static <T> GlobalResult<T> error(String msg) {
return error(HttpStatus.INTERNAL_SERVER_ERROR.value(), null, msg);
}
public static <T> GlobalResult<T> error(int code, T data, String msg) {
GlobalResult<T> globalResult = new GlobalResult<>();
globalResult.setCode(code);
globalResult.setData(data);
globalResult.setMsg(msg);
return globalResult;
}
}

@ -0,0 +1,11 @@
package com.supervision.config.domain;
import lombok.Data;
@Data
public class UserInfo {
private String id;
private String name;
}

@ -0,0 +1,59 @@
package com.supervision.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.supervision.domain.IrSession;
import com.supervision.domain.IrSessionHistory;
import com.supervision.service.IrSessionService;
import com.supervision.vo.session.FinishSessionVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotBlank;
import java.math.BigDecimal;
import java.util.List;
@Slf4j
@Api(tags = "会话管理")
@RestController
@RequestMapping("session")
@RequiredArgsConstructor
public class SessionController {
private final IrSessionService irSessionService;
@ApiOperation("创建新的会话")
@GetMapping("createNewSession")
@ApiImplicitParams({
@ApiImplicitParam(name = "caseNumber", value = "案件编号", required = true, dataType = "String", paramType = "query"),
@ApiImplicitParam(name = "type", value = "播报方式(1语音 2文字)", required = true, dataType = "Integer", paramType = "query"),
@ApiImplicitParam(name = "speed", value = "播放速度(2位,小数后1位,例如:1.0,0.5,1.5,2.0)", required = true, dataType = "String", paramType = "query")
})
public IrSession createNewSession(String caseNumber, Integer type, BigDecimal speed) {
return irSessionService.createNewSession(caseNumber, type, speed);
}
@ApiOperation("分页获取会话列表")
@GetMapping("querySessionPage")
public IPage<IrSession> querySessionPage(Integer pageSize, Integer pageNum) {
return irSessionService.querySessionPage(pageSize, pageNum);
}
@ApiOperation("结束会话")
@PostMapping("finishSession")
public void finishSession(@RequestBody FinishSessionVO finishSessionVO) {
irSessionService.finishSession(finishSessionVO);
}
@ApiOperation("查询所有会话列表")
@GetMapping("querySessionHistory")
public List<IrSessionHistory> querySessionHistory(@NotBlank(message = "会话ID不能为空") String sessionId) {
return irSessionService.querySessionHistory(sessionId);
}
}

@ -1,11 +1,15 @@
package com.supervision.controller;
import com.supervision.domain.IrRobotConfig;
import com.supervision.service.IrRobotConfigService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping("test")
@ -13,13 +17,13 @@ import org.springframework.web.bind.annotation.RestController;
@Slf4j
public class TestController {
private final IrRobotConfigService irRobotConfigService;
@GetMapping("hello")
public String hello() {
System.out.println("hello");
log.info("ddddd");
return "OK";
public List<IrRobotConfig> hello() {
return irRobotConfigService.list();
}

@ -0,0 +1,74 @@
package com.supervision.domain;
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 java.io.Serializable;
import java.time.LocalDateTime;
import lombok.Data;
/**
*
*
* @TableName ir_knowledge
*/
@TableName(value = "ir_knowledge", schema = "interro_robot")
@Data
public class IrKnowledge implements Serializable {
/**
*
*/
@TableId
private String id;
/**
* ()
*/
private Integer questionCode;
/**
*
*/
private String standardQuestion;
/**
* (1 2 3)
*/
private Integer state;
/**
* SQL(使)
*/
private String sqlTemplate;
/**
* (使)
*/
private String resultTemplate;
/**
*
*/
private String createUserId;
/**
*
*/
private LocalDateTime createTime;
/**
*
*/
private String updateUserId;
/**
*
*/
private LocalDateTime updateTime;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
}

@ -0,0 +1,107 @@
package com.supervision.domain;
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 java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import lombok.Data;
/**
*
* @TableName ir_robot_config
*/
@TableName(value ="ir_robot_config", schema = "interro_robot")
@Data
public class IrRobotConfig implements Serializable {
/**
*
*/
@TableId
private String id;
/**
*
*/
private String deviceName;
/**
*
*/
private String deptName;
/**
*
*/
private String deviceCode;
/**
* (1 2)
*/
private Integer state;
/**
*
*/
private BigDecimal talkSpeed;
/**
*
*/
private String iconBase64;
/**
*
*/
private String activeLanguage;
/**
*
*/
private String errorLanguage;
/**
* 1
*/
private String unrecognizedOne;
/**
* 2
*/
private String unrecognizedTwo;
/**
* 3
*/
private String unrecognizedThree;
/**
* 5
*/
private String unrecognizedFour;
/**
*
*/
private String createUserId;
/**
*
*/
private LocalDateTime createTime;
/**
*
*/
private String updateUserId;
/**
*
*/
private LocalDateTime updateTime;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
}

@ -0,0 +1,72 @@
package com.supervision.domain;
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 java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import lombok.Data;
/**
*
* @TableName ir_session
*/
@TableName(value ="ir_session", schema = "interro_robot")
@Data
public class IrSession implements Serializable {
/**
*
*/
@TableId
private String id;
/**
* (1,2)
*/
private Integer sessionState;
/**
* ID
*/
private String userId;
/**
* (2,1,:1.5)
*/
private BigDecimal videoSpeed;
/**
* (1 2)
*/
private Integer broadcastType;
/**
* (1 2,3)
*/
private Integer sessionScore;
/**
*
*/
private String createUserId;
/**
*
*/
private LocalDateTime createTime;
/**
*
*/
private String updateUserId;
/**
*
*/
private LocalDateTime updateTime;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
}

@ -0,0 +1,92 @@
package com.supervision.domain;
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 java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import lombok.Data;
/**
*
* @TableName ir_session_history
*/
@TableName(value ="ir_session_history", schema = "interro_robot")
@Data
public class IrSessionHistory implements Serializable {
/**
*
*/
@TableId
private String id;
/**
* ID
*/
private String sessionId;
/**
*
*/
private String userQuestion;
/**
* ID(ID)
*/
private String userQuestionVideoId;
/**
* ID
*/
private String matchKnowledgeId;
/**
* ID
*/
private String userId;
/**
*
*/
private BigDecimal threshold;
/**
* ( 1 2 3),
*/
private Integer scoreCause;
/**
*
*/
private LocalDateTime answerTime;
/**
* (1 2)
*/
private Integer dealState;
/**
*
*/
private String createUserId;
/**
*
*/
private LocalDateTime createTime;
/**
*
*/
private String updateUserId;
/**
*
*/
private LocalDateTime updateTime;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
}

@ -0,0 +1,66 @@
package com.supervision.domain;
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 java.io.Serializable;
import java.time.LocalDateTime;
import lombok.Data;
/**
*
* @TableName ir_session_param
*/
@TableName(value ="ir_session_param", schema = "interro_robot")
@Data
public class IrSessionParam implements Serializable {
/**
*
*/
@TableId
private String id;
/**
* ID
*/
private String sessionId;
/**
*
*/
private String paramName;
/**
*
*/
private String paramValue;
/**
*
*/
private String paramType;
/**
*
*/
private String createUserId;
/**
*
*/
private LocalDateTime createTime;
/**
*
*/
private String updateUserId;
/**
*
*/
private LocalDateTime updateTime;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
}

@ -0,0 +1,71 @@
package com.supervision.domain;
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 java.io.Serializable;
import java.time.LocalDateTime;
import lombok.Data;
/**
*
* @TableName ir_sql_param
*/
@TableName(value ="ir_sql_param", schema = "interro_robot")
@Data
public class IrSqlParam implements Serializable {
/**
*
*/
@TableId
private String id;
/**
* ID
*/
private Integer knowledgeId;
/**
*
*/
private String paramName;
/**
*
*/
private String paramType;
/**
* (1,2)
*/
private Integer paramRequire;
/**
*
*/
private String paramDesc;
/**
*
*/
private String createUserId;
/**
*
*/
private LocalDateTime createTime;
/**
*
*/
private String updateUserId;
/**
*
*/
private LocalDateTime updateTime;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
}

@ -0,0 +1,76 @@
package com.supervision.domain;
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 java.io.Serializable;
import java.time.LocalDateTime;
import lombok.Data;
/**
*
*
* @TableName ir_user
*/
@TableName(value = "ir_user", schema = "interro_robot")
@Data
public class IrUser implements Serializable {
/**
*
*/
@TableId
private String id;
/**
*
*/
private String userAccount;
/**
*
*/
private String realName;
/**
*
*/
private String ps;
/**
* (1 2)
*/
private Integer state;
/**
* (1 2)
*/
private Integer roleType;
/**
* ID
*/
private String createUserId;
/**
*
*/
private LocalDateTime createTime;
/**
* ID
*/
private String updateUserId;
/**
*
*/
private LocalDateTime updateTime;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
}

@ -0,0 +1,24 @@
package com.supervision.enums;
public enum SessionParamEnum {
CASE_NUMBER("CASE_NUMBER", String.class);
private final String paramName;
private final Class<?> paramType;
SessionParamEnum(String paramName, Class<?> paramType) {
this.paramName = paramName;
this.paramType = paramType;
}
public String getParamName() {
return paramName;
}
public Class<?> getParamType() {
return paramType;
}
}

@ -0,0 +1,76 @@
/*
* : CustomException
* :
* : <>
* : RedName
* : 2022/8/5
* : <>
* : <>
* : <>
*/
package com.supervision.exception;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
/**
* <>
*
*
* @author ljt
* @version [, 2022/8/5]
* @see [/]
* @since [/]
*/
@Slf4j
public class BusinessException extends RuntimeException {
/**
*
*/
private final Integer code;
/**
*
*/
private final String message;
public BusinessException(Throwable cause) {
super(cause);
this.code = HttpStatus.INTERNAL_SERVER_ERROR.value();
this.message = null;
}
public BusinessException(Throwable cause, String message) {
super(cause);
this.code = HttpStatus.INTERNAL_SERVER_ERROR.value();
this.message = message;
}
public BusinessException(String message) {
this.code = HttpStatus.INTERNAL_SERVER_ERROR.value();
this.message = message;
}
public BusinessException(String message, Integer code) {
this.message = message;
this.code = code;
}
public BusinessException(String message, Throwable e) {
super(message, e);
log.error(message, e);
this.code = HttpStatus.INTERNAL_SERVER_ERROR.value();
this.message = message;
}
@Override
public String getMessage() {
return message;
}
public Integer getCode() {
return code;
}
}

@ -0,0 +1,18 @@
package com.supervision.mapper;
import com.supervision.domain.IrKnowledge;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @author flevance
* @description ir_knowledge()Mapper
* @createDate 2024-03-21 13:14:43
* @Entity com.supervision.domain.IrKnowledge
*/
public interface IrKnowledgeMapper extends BaseMapper<IrKnowledge> {
}

@ -0,0 +1,18 @@
package com.supervision.mapper;
import com.supervision.domain.IrRobotConfig;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @author flevance
* @description ir_robot_config()Mapper
* @createDate 2024-03-21 13:14:43
* @Entity com.supervision.domain.IrRobotConfig
*/
public interface IrRobotConfigMapper extends BaseMapper<IrRobotConfig> {
}

@ -0,0 +1,18 @@
package com.supervision.mapper;
import com.supervision.domain.IrSessionHistory;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @author flevance
* @description ir_session_history()Mapper
* @createDate 2024-03-21 13:14:43
* @Entity com.supervision.domain.IrSessionHistory
*/
public interface IrSessionHistoryMapper extends BaseMapper<IrSessionHistory> {
}

@ -0,0 +1,18 @@
package com.supervision.mapper;
import com.supervision.domain.IrSession;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @author flevance
* @description ir_session()Mapper
* @createDate 2024-03-21 13:14:43
* @Entity com.supervision.domain.IrSession
*/
public interface IrSessionMapper extends BaseMapper<IrSession> {
}

@ -0,0 +1,18 @@
package com.supervision.mapper;
import com.supervision.domain.IrSessionParam;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @author flevance
* @description ir_session_param()Mapper
* @createDate 2024-03-21 13:14:43
* @Entity com.supervision.domain.IrSessionParam
*/
public interface IrSessionParamMapper extends BaseMapper<IrSessionParam> {
}

@ -0,0 +1,18 @@
package com.supervision.mapper;
import com.supervision.domain.IrSqlParam;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @author flevance
* @description ir_sql_param()Mapper
* @createDate 2024-03-21 13:14:43
* @Entity com.supervision.domain.IrSqlParam
*/
public interface IrSqlParamMapper extends BaseMapper<IrSqlParam> {
}

@ -0,0 +1,18 @@
package com.supervision.mapper;
import com.supervision.domain.IrUser;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @author flevance
* @description ir_user()Mapper
* @createDate 2024-03-21 13:14:43
* @Entity com.supervision.domain.IrUser
*/
public interface IrUserMapper extends BaseMapper<IrUser> {
}

@ -0,0 +1,13 @@
package com.supervision.service;
import com.supervision.domain.IrKnowledge;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @author flevance
* @description ir_knowledge()Service
* @createDate 2024-03-21 13:14:43
*/
public interface IrKnowledgeService extends IService<IrKnowledge> {
}

@ -0,0 +1,13 @@
package com.supervision.service;
import com.supervision.domain.IrRobotConfig;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @author flevance
* @description ir_robot_config()Service
* @createDate 2024-03-21 13:14:43
*/
public interface IrRobotConfigService extends IService<IrRobotConfig> {
}

@ -0,0 +1,13 @@
package com.supervision.service;
import com.supervision.domain.IrSessionHistory;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @author flevance
* @description ir_session_history()Service
* @createDate 2024-03-21 13:14:43
*/
public interface IrSessionHistoryService extends IService<IrSessionHistory> {
}

@ -0,0 +1,13 @@
package com.supervision.service;
import com.supervision.domain.IrSessionParam;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @author flevance
* @description ir_session_param()Service
* @createDate 2024-03-21 13:14:43
*/
public interface IrSessionParamService extends IService<IrSessionParam> {
}

@ -0,0 +1,28 @@
package com.supervision.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.supervision.domain.IrSession;
import com.baomidou.mybatisplus.extension.service.IService;
import com.supervision.domain.IrSessionHistory;
import com.supervision.vo.session.FinishSessionVO;
import javax.validation.constraints.NotBlank;
import java.math.BigDecimal;
import java.util.List;
/**
* @author flevance
* @description ir_session()Service
* @createDate 2024-03-21 13:14:43
*/
public interface IrSessionService extends IService<IrSession> {
IrSession createNewSession(String caseNumber, Integer type, BigDecimal speed);
IPage<IrSession> querySessionPage(Integer pageSize, Integer pageNum);
void finishSession(FinishSessionVO finishSessionVO);
List<IrSessionHistory> querySessionHistory(String sessionId);
}

@ -0,0 +1,13 @@
package com.supervision.service;
import com.supervision.domain.IrSqlParam;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @author flevance
* @description ir_sql_param()Service
* @createDate 2024-03-21 13:14:43
*/
public interface IrSqlParamService extends IService<IrSqlParam> {
}

@ -0,0 +1,13 @@
package com.supervision.service;
import com.supervision.domain.IrUser;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @author flevance
* @description ir_user()Service
* @createDate 2024-03-21 13:14:43
*/
public interface IrUserService extends IService<IrUser> {
}

@ -0,0 +1,22 @@
package com.supervision.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.supervision.domain.IrKnowledge;
import com.supervision.service.IrKnowledgeService;
import com.supervision.mapper.IrKnowledgeMapper;
import org.springframework.stereotype.Service;
/**
* @author flevance
* @description ir_knowledge()Service
* @createDate 2024-03-21 13:14:43
*/
@Service
public class IrKnowledgeServiceImpl extends ServiceImpl<IrKnowledgeMapper, IrKnowledge>
implements IrKnowledgeService{
}

@ -0,0 +1,22 @@
package com.supervision.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.supervision.domain.IrRobotConfig;
import com.supervision.service.IrRobotConfigService;
import com.supervision.mapper.IrRobotConfigMapper;
import org.springframework.stereotype.Service;
/**
* @author flevance
* @description ir_robot_config()Service
* @createDate 2024-03-21 13:14:43
*/
@Service
public class IrRobotConfigServiceImpl extends ServiceImpl<IrRobotConfigMapper, IrRobotConfig>
implements IrRobotConfigService{
}

@ -0,0 +1,22 @@
package com.supervision.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.supervision.domain.IrSessionHistory;
import com.supervision.service.IrSessionHistoryService;
import com.supervision.mapper.IrSessionHistoryMapper;
import org.springframework.stereotype.Service;
/**
* @author flevance
* @description ir_session_history()Service
* @createDate 2024-03-21 13:14:43
*/
@Service
public class IrSessionHistoryServiceImpl extends ServiceImpl<IrSessionHistoryMapper, IrSessionHistory>
implements IrSessionHistoryService{
}

@ -0,0 +1,22 @@
package com.supervision.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.supervision.domain.IrSessionParam;
import com.supervision.service.IrSessionParamService;
import com.supervision.mapper.IrSessionParamMapper;
import org.springframework.stereotype.Service;
/**
* @author flevance
* @description ir_session_param()Service
* @createDate 2024-03-21 13:14:43
*/
@Service
public class IrSessionParamServiceImpl extends ServiceImpl<IrSessionParamMapper, IrSessionParam>
implements IrSessionParamService{
}

@ -0,0 +1,92 @@
package com.supervision.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.supervision.config.domain.UserInfo;
import com.supervision.domain.IrSession;
import com.supervision.exception.BusinessException;
import com.supervision.service.IrSessionHistoryService;
import com.supervision.service.IrSessionService;
import com.supervision.mapper.IrSessionMapper;
import com.supervision.util.UserUtil;
import com.supervision.vo.session.FinishSessionVO;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.supervision.domain.IrSessionHistory;
import java.math.BigDecimal;
import java.util.List;
import java.util.Optional;
/**
* @author flevance
* @description ir_session()Service
* @createDate 2024-03-21 13:14:43
*/
@Service
@RequiredArgsConstructor
public class IrSessionServiceImpl extends ServiceImpl<IrSessionMapper, IrSession>
implements IrSessionService {
private final IrSessionHistoryService irSessionHistoryService;
@Override
public IrSession createNewSession(String caseNumber, Integer type, BigDecimal speed) {
UserInfo user = UserUtil.getUser();
IrSession irSession = new IrSession();
irSession.setSessionState(1);
irSession.setUserId(user.getId());
irSession.setVideoSpeed(speed);
irSession.setBroadcastType(type);
this.save(irSession);
return irSession;
}
@Override
public IPage<IrSession> querySessionPage(Integer pageSize, Integer pageNum) {
UserInfo user = UserUtil.getUser();
return this.lambdaQuery().eq(IrSession::getUserId, user.getId()).page(new Page<>(pageNum, pageSize));
}
@Override
@Transactional(rollbackFor = Exception.class)
public void finishSession(FinishSessionVO finishSessionVO) {
IrSession irSession = Optional.ofNullable(this.getById(finishSessionVO.getSessionId())).orElseThrow(() -> new BusinessException("未找到的会话"));
if (irSession.getSessionState() == 2) {
throw new BusinessException("会话已结束");
}
// 更新会话
irSession.setSessionState(2);
if (ObjUtil.isNotEmpty(finishSessionVO.getSessionScore())) {
irSession.setSessionScore(finishSessionVO.getSessionScore());
}
this.updateById(irSession);
// 更新会话历史
if (CollUtil.isNotEmpty(finishSessionVO.getIrrelevantAnswerHistoryId())) {
irSessionHistoryService.lambdaUpdate().set(IrSessionHistory::getScoreCause, 2).set(IrSessionHistory::getDealState, 1)
.in(IrSessionHistory::getId, finishSessionVO.getIrrelevantAnswerHistoryId()).update();
}
if (CollUtil.isNotEmpty(finishSessionVO.getErrorAnswerHistoryId())) {
irSessionHistoryService.lambdaUpdate().set(IrSessionHistory::getScoreCause, 1).set(IrSessionHistory::getDealState, 1)
.in(IrSessionHistory::getId, finishSessionVO.getErrorAnswerHistoryId()).update();
}
if (CollUtil.isNotEmpty(finishSessionVO.getOtherAnswerHistoryId())) {
irSessionHistoryService.lambdaUpdate().set(IrSessionHistory::getScoreCause, 2).set(IrSessionHistory::getDealState, 1)
.in(IrSessionHistory::getId, finishSessionVO.getOtherAnswerHistoryId()).update();
}
}
@Override
public List<IrSessionHistory> querySessionHistory(String sessionId) {
return irSessionHistoryService.lambdaQuery().eq(IrSessionHistory::getSessionId, sessionId).list();
}
}

@ -0,0 +1,22 @@
package com.supervision.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.supervision.domain.IrSqlParam;
import com.supervision.service.IrSqlParamService;
import com.supervision.mapper.IrSqlParamMapper;
import org.springframework.stereotype.Service;
/**
* @author flevance
* @description ir_sql_param()Service
* @createDate 2024-03-21 13:14:43
*/
@Service
public class IrSqlParamServiceImpl extends ServiceImpl<IrSqlParamMapper, IrSqlParam>
implements IrSqlParamService{
}

@ -0,0 +1,22 @@
package com.supervision.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.supervision.domain.IrUser;
import com.supervision.service.IrUserService;
import com.supervision.mapper.IrUserMapper;
import org.springframework.stereotype.Service;
/**
* @author flevance
* @description ir_user()Service
* @createDate 2024-03-21 13:14:43
*/
@Service
public class IrUserServiceImpl extends ServiceImpl<IrUserMapper, IrUser>
implements IrUserService{
}

@ -0,0 +1,127 @@
package com.supervision.util;
import cn.hutool.core.util.ArrayUtil;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import java.util.Map;
/***
* @author ljt
* @since 2020/8/4 17:37
*
*/
@Component
@Lazy(false)
public class SpringBeanUtil implements ApplicationContextAware {
private static ApplicationContext applicationContext;
/**
* applicationContext
*
* @return ApplicationContext
*/
public static ApplicationContext getApplicationContext() {
return applicationContext;
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) {
SpringBeanUtil.applicationContext = applicationContext;
}
//通过name获取 Bean.
/**
* name Bean
*
* @param <T> Bean
* @param name Bean
* @return Bean
*/
@SuppressWarnings("unchecked")
public static <T> T getBean(String name) {
return (T) applicationContext.getBean(name);
}
/**
* classBean
*
* @param <T> Bean
* @param clazz Bean
* @return Bean
*/
public static <T> T getBean(Class<T> clazz) {
return applicationContext.getBean(clazz);
}
/**
* name,ClazzBean
*
* @param <T> bean
* @param name Bean
* @param clazz bean
* @return Bean
*/
public static <T> T getBean(String name, Class<T> clazz) {
return applicationContext.getBean(name, clazz);
}
/**
* Bean
*
* @param <T> Bean
* @param type nullbean
* @return beankeybeannamevalueBean
* @since 5.3.3
*/
public static <T> Map<String, T> getBeansOfType(Class<T> type) {
return applicationContext.getBeansOfType(type);
}
/**
* Bean
*
* @param type nullbean
* @return bean
* @since 5.3.3
*/
public static String[] getBeanNamesForType(Class<?> type) {
return applicationContext.getBeanNamesForType(type);
}
/**
*
*
* @param key key
* @return
* @since 5.3.3
*/
public static String getProperty(String key) {
return applicationContext.getEnvironment().getProperty(key);
}
/**
* null
*
* @return
* @since 5.3.3
*/
public static String[] getActiveProfiles() {
return applicationContext.getEnvironment().getActiveProfiles();
}
/**
*
*
* @return
* @since 5.3.3
*/
public static String getActiveProfile() {
final String[] activeProfiles = getActiveProfiles();
return ArrayUtil.isNotEmpty(activeProfiles) ? activeProfiles[0] : null;
}
}

@ -0,0 +1,20 @@
package com.supervision.util;
import com.supervision.config.domain.UserInfo;
public class UserUtil {
public static UserInfo getUser(){
// String userStr = ThreadCache.USER.get();
// User bean = JSONUtil.toBean(userStr, User.class);
// if (ObjectUtil.isEmpty(bean)){
// throw new BusinessException("未获取到用户信息");
// }
// return bean;
UserInfo userInfo = new UserInfo();
userInfo.setId("1");
userInfo.setName("张警官");
return userInfo;
}
}

@ -0,0 +1,27 @@
package com.supervision.vo.session;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
public class FinishSessionVO {
@ApiModelProperty("会话ID")
private String sessionId;
@ApiModelProperty("会话评分(1满意 2不满意,3未评估)")
private Integer sessionScore;
@ApiModelProperty("答非所问historyId")
private List<String> irrelevantAnswerHistoryId;
@ApiModelProperty("信息错误historyId")
private List<String> errorAnswerHistoryId;
@ApiModelProperty("其他historyId")
private List<String> otherAnswerHistoryId;
}

@ -0,0 +1,15 @@
package com.supervision.vo.session;
import io.swagger.annotations.ApiModel;
import lombok.Data;
@Data
@ApiModel
public class talkHistoryVO {
private String historyId;
private String question;
private String answer;
}

@ -13,7 +13,7 @@
</springProfile>-->
<!-- 测试环境,生产环境 -->
<springProfile name="dev,local,prod">
<springProfile name="prod">
<logger name="org.springframework.web" level="INFO"/>
<logger name="org.springboot.sample" level="INFO"/>
<logger name="com.supervision" level="INFO"/>

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.supervision.mapper.IrKnowledgeMapper">
<resultMap id="BaseResultMap" type="com.supervision.domain.IrKnowledge">
<id property="id" column="id" jdbcType="VARCHAR"/>
<result property="questionCode" column="question_code" jdbcType="INTEGER"/>
<result property="standardQuestion" column="standard_question" jdbcType="VARCHAR"/>
<result property="state" column="state" jdbcType="INTEGER"/>
<result property="sqlTemplate" column="sql_template" jdbcType="VARCHAR"/>
<result property="resultTemplate" column="result_template" jdbcType="VARCHAR"/>
<result property="createUserId" column="create_user_id" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateUserId" column="update_user_id" jdbcType="VARCHAR"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id,question_code,standard_question,
state,sql_template,result_template,
create_user_id,create_time,update_user_id,
update_time
</sql>
</mapper>

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.supervision.mapper.IrRobotConfigMapper">
<resultMap id="BaseResultMap" type="com.supervision.domain.IrRobotConfig">
<id property="id" column="id" jdbcType="VARCHAR"/>
<result property="deviceName" column="device_name" jdbcType="VARCHAR"/>
<result property="deptName" column="dept_name" jdbcType="VARCHAR"/>
<result property="deviceCode" column="device_code" jdbcType="VARCHAR"/>
<result property="state" column="state" jdbcType="INTEGER"/>
<result property="talkSpeed" column="talk_speed" jdbcType="NUMERIC"/>
<result property="iconBase64" column="icon_base64" jdbcType="VARCHAR"/>
<result property="activeLanguage" column="active_language" jdbcType="VARCHAR"/>
<result property="errorLanguage" column="error_language" jdbcType="VARCHAR"/>
<result property="unrecognizedOne" column="unrecognized_one" jdbcType="VARCHAR"/>
<result property="unrecognizedTwo" column="unrecognized_two" jdbcType="VARCHAR"/>
<result property="unrecognizedThree" column="unrecognized_three" jdbcType="VARCHAR"/>
<result property="unrecognizedFour" column="unrecognized_four" jdbcType="VARCHAR"/>
<result property="createUserId" column="create_user_id" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateUserId" column="update_user_id" jdbcType="VARCHAR"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id,device_name,dept_name,
device_code,state,talk_speed,
icon_base64,active_language,error_language,
unrecognized_one,unrecognized_two,unrecognized_three,
unrecognized_four,create_user_id,create_time,
update_user_id,update_time
</sql>
</mapper>

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.supervision.mapper.IrSessionHistoryMapper">
<resultMap id="BaseResultMap" type="com.supervision.domain.IrSessionHistory">
<id property="id" column="id" jdbcType="VARCHAR"/>
<result property="sessionId" column="session_id" jdbcType="VARCHAR"/>
<result property="userQuestion" column="user_question" jdbcType="VARCHAR"/>
<result property="userQuestionVideoId" column="user_question_video_id" jdbcType="VARCHAR"/>
<result property="matchKnowledgeId" column="match_knowledge_id" jdbcType="VARCHAR"/>
<result property="userId" column="user_id" jdbcType="VARCHAR"/>
<result property="threshold" column="threshold" jdbcType="NUMERIC"/>
<result property="score" column="score" jdbcType="INTEGER"/>
<result property="scoreCause" column="score_cause" jdbcType="INTEGER"/>
<result property="answerTime" column="answer_time" jdbcType="TIMESTAMP"/>
<result property="dealState" column="deal_state" jdbcType="INTEGER"/>
<result property="createUserId" column="create_user_id" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateUserId" column="update_user_id" jdbcType="VARCHAR"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id,session_id,user_question,
user_question_video_id,match_knowledge_id,user_id,
threshold,score,score_cause,
answer_time,deal_state,create_user_id,
create_time,update_user_id,update_time
</sql>
</mapper>

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.supervision.mapper.IrSessionMapper">
<resultMap id="BaseResultMap" type="com.supervision.domain.IrSession">
<id property="id" column="id" jdbcType="VARCHAR"/>
<result property="sessionState" column="session_state" jdbcType="INTEGER"/>
<result property="userId" column="user_id" jdbcType="VARCHAR"/>
<result property="videoSpeed" column="video_speed" jdbcType="NUMERIC"/>
<result property="broadcastType" column="broadcast_type" jdbcType="INTEGER"/>
<result property="sessionScore" column="session_score" jdbcType="INTEGER"/>
<result property="scoreCause" column="score_cause" jdbcType="INTEGER"/>
<result property="scoreExplain" column="score_explain" jdbcType="VARCHAR"/>
<result property="createUserId" column="create_user_id" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateUserId" column="update_user_id" jdbcType="VARCHAR"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id,session_state,user_id,
video_speed,broadcast_type,session_score,
score_cause,score_explain,create_user_id,
create_time,update_user_id,update_time
</sql>
</mapper>

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.supervision.mapper.IrSessionParamMapper">
<resultMap id="BaseResultMap" type="com.supervision.domain.IrSessionParam">
<id property="id" column="id" jdbcType="VARCHAR"/>
<result property="sessionId" column="session_id" jdbcType="VARCHAR"/>
<result property="paramName" column="param_name" jdbcType="VARCHAR"/>
<result property="paramValue" column="param_value" jdbcType="VARCHAR"/>
<result property="paramType" column="param_type" jdbcType="VARCHAR"/>
<result property="createUserId" column="create_user_id" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateUserId" column="update_user_id" jdbcType="VARCHAR"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id,session_id,param_name,
param_value,param_type,create_user_id,
create_time,update_user_id,update_time
</sql>
</mapper>

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.supervision.mapper.IrSqlParamMapper">
<resultMap id="BaseResultMap" type="com.supervision.domain.IrSqlParam">
<id property="id" column="id" jdbcType="VARCHAR"/>
<result property="knowledgeId" column="knowledge_id" jdbcType="INTEGER"/>
<result property="paramName" column="param_name" jdbcType="VARCHAR"/>
<result property="paramType" column="param_type" jdbcType="VARCHAR"/>
<result property="paramRequire" column="param_require" jdbcType="INTEGER"/>
<result property="paramDesc" column="param_desc" jdbcType="VARCHAR"/>
<result property="createUserId" column="create_user_id" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateUserId" column="update_user_id" jdbcType="VARCHAR"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id,knowledge_id,param_name,
param_type,param_require,param_desc,
create_user_id,create_time,update_user_id,
update_time
</sql>
</mapper>

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.supervision.mapper.IrUserMapper">
<resultMap id="BaseResultMap" type="com.supervision.domain.IrUser">
<id property="id" column="id" jdbcType="VARCHAR"/>
<result property="userAccount" column="user_account" jdbcType="VARCHAR"/>
<result property="realName" column="real_name" jdbcType="VARCHAR"/>
<result property="ps" column="ps" jdbcType="VARCHAR"/>
<result property="createUserId" column="create_user_id" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateUserId" column="update_user_id" jdbcType="VARCHAR"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
<result property="state" column="state" jdbcType="INTEGER"/>
<result property="roleType" column="role_type" jdbcType="INTEGER"/>
</resultMap>
<sql id="Base_Column_List">
id,user_account,real_name,
ps,create_user_id,create_time,
update_user_id,update_time,state,
role_type
</sql>
</mapper>
Loading…
Cancel
Save