Commit d9635c08 by liangkaiping

copy

parent fd407364
# cloud-chat-practice
智能演练
##Xservice与service区别
#### service 层调用repository层进行数据库查询.一个service对应一个repository
#### Xservice 层做业务逻辑处理,需要的数据从service获取.一个Xservice对应一个controller
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>cloud-chat-practice</artifactId>
<groupId>com.yizhi</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>chat-practice-api</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-common-api</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-core</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-util</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
package com.yizhi.practice.application.enums;
public enum PracticeChatLogStatusEnum {
ING(40,"进行中"),
DONE(80,"正常结束"),
QUIT(90,"中途退出")
;
private Integer status;
private String desc;
PracticeChatLogStatusEnum(Integer status, String desc) {
this.status = status;
this.desc = desc;
}
public Integer getStatus() {
return status;
}
public String getDesc() {
return desc;
}
}
package com.yizhi.practice.application.enums;
/**
* 训练策略每轮对话过关条件开关 80:开启 10:关闭
*
*/
public enum PracticeDiaConditionEnum {
TRUE(80,"开启每轮对话过关限制条件"),
FALSE(10,"关闭每轮对话过关限制条件"),
;
private Integer status;
private String desc;
PracticeDiaConditionEnum(Integer status, String desc) {
this.status = status;
this.desc = desc;
}
public Integer getStatus() {
return status;
}
public String getDesc() {
return desc;
}
}
package com.yizhi.practice.application.enums;
public enum PracticeInternationEnum {
SCENE_CHAT_INCOMPLETE("practiceCode1","陪练下场景对话不完整")
;
private String code;
private String name;
PracticeInternationEnum(String code, String name){
this.name = name;
this.code = code;
}
public String getCode() {
return code;
}
public String getName() {
return name;
}
}
package com.yizhi.practice.application.enums;
public enum PracticeLevelMapEnum {
PRACTICE_LEVEL1("1010", "训练(初级)"),
PRACTICE_LEVEL2("1040", "训练(中级)"),
PRACTICE_LEVEL3("1080", "训练(高级)"),
EXAM("200","考核")
;
private String status;
private String desc;
PracticeLevelMapEnum(String status, String desc) {
this.status = status;
this.desc = desc;
}
public String getStatus() {
return status;
}
public String getDesc() {
return desc;
}
public static String getDescByStatus(String code) {
PracticeLevelMapEnum[] values = PracticeLevelMapEnum.values();
for(PracticeLevelMapEnum each : values) {
if(each.getStatus().equals(code)) {
return each.getDesc();
}
}
return "";
}
}
package com.yizhi.practice.application.enums;
/**
* 是否发放积分 80:发放 10:不发放
*
*/
public enum PracticeManyRoudChatEnum {
TRUE(80,"开启"),
FALSE(10,"关闭"),
;
private Integer status;
private String desc;
PracticeManyRoudChatEnum(Integer status, String desc) {
this.status = status;
this.desc = desc;
}
public Integer getStatus() {
return status;
}
public String getDesc() {
return desc;
}
}
package com.yizhi.practice.application.enums;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 陪练模式枚举
* 80:训练+考核 ,10:训练 20:考核
*/
public enum PracticeModelStatusEnum {
PRA_ASSESS(80, "训练+考核"),
PRACTICE(10, "训练"),
ASSESSMENT(20, "考核");
private Integer status;
private String desc;
PracticeModelStatusEnum(Integer status, String desc) {
this.status = status;
this.desc = desc;
}
/**
* 返回所有状态
*
* @return
*/
public static List<Integer> getAllStatus() {
return Arrays.stream(PracticeModelStatusEnum.values()).map(PracticeModelStatusEnum::getStatus).collect(Collectors.toList());
}
public static PracticeModelStatusEnum getByStatus(Integer status) {
Map<Integer,PracticeModelStatusEnum> map = Arrays.stream(PracticeModelStatusEnum.values()).collect(Collectors.toMap(PracticeModelStatusEnum::getStatus, a -> a,(k1, k2)-> k1));
return map.get(status);
}
public Integer getStatus() {
return status;
}
public String getDesc() {
return desc;
}
}
package com.yizhi.practice.application.enums;
/**
* 节点标识 10:机器人,20:学员 节点
*
*/
public enum PracticeNodeEnum {
ROBOT(10,"机器人节点"),
STUDENT(20,"学员节点"),
START(80,"开始节点")
;
private Integer status;
private String desc;
PracticeNodeEnum(Integer status, String desc) {
this.status = status;
this.desc = desc;
}
public Integer getStatus() {
return status;
}
public String getDesc() {
return desc;
}
}
package com.yizhi.practice.application.enums;
/**
* @Date 2020/11/18 2:09 下午
* @Author lvjianhui
**/
public enum PracticePassResultEnum {
PASS (80,"已通过"),
UN_PASS (10,"未通过"),
;
PracticePassResultEnum(Integer status, String msg) {
this.status = status;
this.msg = msg;
}
private Integer status;
private String msg;
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
}
package com.yizhi.practice.application.enums;
/**
* 是否开启多轮对话:80:开启 10:关闭
*
*/
public enum PracticePointGivenEnum {
TRUE(80,"开启"),
FALSE(10,"关闭"),
;
private Integer status;
private String desc;
PracticePointGivenEnum(Integer status, String desc) {
this.status = status;
this.desc = desc;
}
public Integer getStatus() {
return status;
}
public String getDesc() {
return desc;
}
}
package com.yizhi.practice.application.enums;
/**
* 考核策略是否允许重复提交; 80:允许重复提交 10:不允许重复提交
*
*/
public enum PracticeRepSubmitEnum {
TRUE(80,"允许重复提交"),
FALSE(10,"不允许重复提交"),
;
private Integer status;
private String desc;
PracticeRepSubmitEnum(Integer status, String desc) {
this.status = status;
this.desc = desc;
}
public Integer getStatus() {
return status;
}
public String getDesc() {
return desc;
}
}
package com.yizhi.practice.application.enums;
/**
* 未识别回复类型 80:默认回复,10:自定义回复
*
*/
public enum PracticeSimilaryFailedEnum {
TRUE(80,"默认回复"),
FALSE(10,"自定义回复"),
;
private Integer status;
private String desc;
PracticeSimilaryFailedEnum(Integer status, String desc) {
this.status = status;
this.desc = desc;
}
public Integer getStatus() {
return status;
}
public String getDesc() {
return desc;
}
}
package com.yizhi.practice.application.enums;
/**
* 是否跳过对话 80允许,10:不允许
*
*/
public enum PracticeSkipDialogueEnum {
SKIP_TRUE(80,"允许跳过对话"),
SKIP_FALSE(10,"不允许跳过对话"),
;
private Integer status;
private String desc;
PracticeSkipDialogueEnum(Integer status, String desc) {
this.status = status;
this.desc = desc;
}
public Integer getStatus() {
return status;
}
public String getDesc() {
return desc;
}
}
package com.yizhi.practice.application.enums;
public enum PracticeSkipEnum {
SKIP(10, "跳过"),
NOT_SKIP(80, "正常")
;
private Integer code;
private String desc;
private PracticeSkipEnum(Integer code, String desc) {
this.code = code;
this.desc = desc;
}
public Integer getCode() {
return code;
}
public String getDesc() {
return desc;
}
}
package com.yizhi.practice.application.enums;
/**
* 陪练状态
*/
public enum PracticeStatusEnum {
UP(80,"上架"),
DOWN(30,"下架"),
DRAFT(10,"草稿")
;
private Integer status;
private String desc;
PracticeStatusEnum(Integer status, String desc) {
this.status = status;
this.desc = desc;
}
public Integer getStatus() {
return status;
}
public String getDesc() {
return desc;
}
}
package com.yizhi.practice.application.enums;
public enum PracticeUseTypeEnum {
PRACTICE(10, "训练"),
EXAM(20, "考核");
private Integer code;
private String msg;
PracticeUseTypeEnum(Integer code, String msg){
this.code=code;
this.msg=msg;
}
public Integer getCode() {
return code;
}
public String getMsg() {
return msg;
}
}
package com.yizhi.practice.application.enums;
/**
* 陪练可见范围
* 80:平台可见 40:指定用户可见
*/
public enum PracticeVisibleTypeEnum {
ALL(80,"平台可见"),
ORG(50,"部门用户可见"),
PART(40,"指定用户可见"),
;
private Integer status;
private String desc;
PracticeVisibleTypeEnum(Integer status, String desc) {
this.status = status;
this.desc = desc;
}
public Integer getStatus() {
return status;
}
public String getDesc() {
return desc;
}
}
package com.yizhi.practice.application.enums;
public enum PracticeVoiceTypeEnum {
MP3("mp3"), PCM("pcm"), WAV("wav");
private String type;
private PracticeVoiceTypeEnum(String type) {
this.type = type;
}
public String getType() {
return type;
}
}
package com.yizhi.practice.application.enums;
public enum PracticeXunFeiBusinessTypeEnum {
RECOGNIZE // 语音识别
, EVALUATE // 语音评测
, SYNTHESIS // 语音合成
}
package com.yizhi.practice.application.feign;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.util.application.domain.BizResponse;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
/**
* @Date 2020/11/19 2:00 下午
* @Author lvjianhui
**/
@FeignClient(value = "chat-practice",contextId = "MyPracticeStudentClient",path = "/student/practice")
public interface MyPracticeStudentClient {
@GetMapping("/running/count/get")
public BizResponse<Integer> getRuningPracticeCount(@RequestBody RequestContext requestContext);
@GetMapping("/user/auth")
public BizResponse<Boolean> getUserPracticeAuth(@RequestBody RequestContext requestContext
, @RequestParam("practiceId") Long practiceId);
}
package com.yizhi.practice.application.feign;
import com.yizhi.practice.application.pojo.vo.PracticeChatLogVo;
import com.yizhi.practice.application.pojo.vo.PracticeVisibleVo;
import com.yizhi.practice.application.pojo.vo.PracticeVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@FeignClient(value = "chat-practice",contextId = "PracticeConfigClient",path = "/remote/manage/practice")
public interface PracticeConfigClient {
@GetMapping(path = "/range/list")
List<PracticeVo> selectRangeList(@RequestParam(name = "startDate",value="startDate",required=false)String startDate,
@RequestParam(name = "endDate",value="endDate",required=false)String endDate);
@GetMapping(path = "/visible/range/list")
List<PracticeVisibleVo> selectVisibleRangeList(@RequestParam(name = "startDate",value="startDate",required=false) String startDate,
@RequestParam(name = "endDate",value="endDate",required=false) String endDate);
/**
* 查询指定时间范围内更新的陪练记录
*/
@GetMapping(path = "/chat/range/list")
List<PracticeChatLogVo> selectChatLogRangeList(@RequestParam(name = "startDate",value="startDate",required=false) String startDate,
@RequestParam(name = "endDate",value="endDate",required=false) String endDate);
}
package com.yizhi.practice.application.feign;
import com.yizhi.practice.application.pojo.vo.PracticeVo;
import com.yizhi.util.application.domain.BizResponse;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
@FeignClient(name = "chat-practice",contextId = "PracticeConfigStudentClient")
public interface PracticeConfigStudentClient {
@ApiOperation(value = "获取陪练")
@GetMapping("/student/practice/get")
public BizResponse<PracticeVo> getPractice(@ApiParam(value = "陪练的ID") @RequestParam("practiceId") Long practiceId);
}
package com.yizhi.practice.application.pojo.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
@Data
@ApiModel(value = "PracticeBaseInfoVo")
public class PracticeBaseInfoVo {
@ApiModelProperty(value = "陪练id")
private Long id;
@ApiModelProperty(value = "陪练名")
private String name;
@ApiModelProperty(value = "陪练模式",allowableValues = "80:训练+考核 ,10:训练 20:考核")
private Integer useType;
@ApiModelProperty(value = "训练开始时间 yyyy-MM-dd HH:mm")
private Date practiceStartAt;
@ApiModelProperty(value = "训练结束时间 yyyy-MM-dd HH:mm")
private Date practiceEndAt;
@ApiModelProperty(value = "考核开始时间 yyyy-MM-dd HH:mm")
private Date examStartAt;
@ApiModelProperty(value = "考核结束时间 yyyy-MM-dd HH:mm")
private Date examEndAt;
@ApiModelProperty(value = "陪练状态 80:上架 30:下架 10:草稿")
private Integer status;
@ApiModelProperty(value = "练习可见范围 80:平台可见 40:指定用户可见")
private Integer visibleType;
@ApiModelProperty(value = "陪练logoUrl")
private String logoUrl;
}
package com.yizhi.practice.application.pojo.vo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@Api(tags = "初始化草稿陪练")
public class PracticeBlankDraftVo {
@ApiModelProperty(value = "陪练id")
private Long id;
@ApiModelProperty(value = "陪练状态 80:上架 30:下架 10:草稿",allowableValues = "80,30,10")
private Integer status;
}
package com.yizhi.practice.application.pojo.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
* 场景对话结果记录
* </p>
*
* @author MybatisCodeGenerator123
* @since 2020-10-30
*/
@Data
public class PracticeChatLogVo implements Serializable {
private static final long serialVersionUID = 1L;
private Long id;
@ApiModelProperty(value = "陪练ID")
private Long practiceId;
@ApiModelProperty(value = "用户ID")
private Long accountId;
@ApiModelProperty(value = "用户名")
private String accountName;
@ApiModelProperty(value = "用户姓名")
private String accountFullName;
@ApiModelProperty(value = "10:训练 20:考核")
private Integer useType;
@ApiModelProperty(value = "部门名")
private String orgName;
@ApiModelProperty(value = "陪练级别 10:初级 40:中级 80:高级")
private Integer level;
@ApiModelProperty(value = "陪练状态 40:陪练中 80:陪练正常结束 90:陪练中途退出")
private Integer status;
@ApiModelProperty(value = "陪练开始时间")
private Date startAt;
@ApiModelProperty(value = "陪练结束时间")
private Date endAt;
@ApiModelProperty(value = "通过考核最低分")
private Integer passMinScore;
@ApiModelProperty(value = "是否发放积分 80 发放,10不发放")
private Integer givenPointType;
@ApiModelProperty(value = "得分")
private Integer averageScore;
@ApiModelProperty(value = "80:通过,10:未通过")
private Integer passResult;
@ApiModelProperty(value = "关键词得分")
private Integer keywordScore;
@ApiModelProperty(value = "关键词 完成度 单位%")
private Integer keywordRate;
@ApiModelProperty(value = "完整性得分")
private Integer completeScore;
@ApiModelProperty(value = "完整性 完成度 单位%")
private Integer completeRate;
@ApiModelProperty(value = "流畅性得分")
private Integer smoothScore;
@ApiModelProperty(value = "流畅性 完整度 单位%")
private Integer smoothRate;
@ApiModelProperty(value = "表达能力得分")
private Integer expressScore;
@ApiModelProperty(value = "表达能力 完成度 单位%")
private Integer expressRate;
@ApiModelProperty(value = "礼貌用语得分")
private Integer politeScore;
@ApiModelProperty(value = "礼貌用语 完成度 单位%")
private Integer politeRate;
@ApiModelProperty(value = "0: not deledted 1:deleted")
private Boolean deleted;
private Long orgId;
private Long siteId;
private Long companyId;
private Date createdAt;
private Date updatedAt;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getPracticeId() {
return practiceId;
}
public void setPracticeId(Long practiceId) {
this.practiceId = practiceId;
}
public Long getAccountId() {
return accountId;
}
public void setAccountId(Long accountId) {
this.accountId = accountId;
}
public String getAccountName() {
return accountName;
}
public void setAccountName(String accountName) {
this.accountName = accountName;
}
public String getAccountFullName() {
return accountFullName;
}
public void setAccountFullName(String accountFullName) {
this.accountFullName = accountFullName;
}
public Integer getUseType() {
return useType;
}
public void setUseType(Integer useType) {
this.useType = useType;
}
public String getOrgName() {
return orgName;
}
public void setOrgName(String orgName) {
this.orgName = orgName;
}
public Integer getLevel() {
return level;
}
public void setLevel(Integer level) {
this.level = level;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Date getStartAt() {
return startAt;
}
public void setStartAt(Date startAt) {
this.startAt = startAt;
}
public Date getEndAt() {
return endAt;
}
public void setEndAt(Date endAt) {
this.endAt = endAt;
}
public Integer getPassMinScore() {
return passMinScore;
}
public void setPassMinScore(Integer passMinScore) {
this.passMinScore = passMinScore;
}
public Integer getGivenPointType() {
return givenPointType;
}
public void setGivenPointType(Integer givenPointType) {
this.givenPointType = givenPointType;
}
public Integer getAverageScore() {
return averageScore;
}
public void setAverageScore(Integer averageScore) {
this.averageScore = averageScore;
}
public Integer getPassResult() {
return passResult;
}
public void setPassResult(Integer passResult) {
this.passResult = passResult;
}
public Integer getKeywordScore() {
return keywordScore;
}
public void setKeywordScore(Integer keywordScore) {
this.keywordScore = keywordScore;
}
public Integer getKeywordRate() {
return keywordRate;
}
public void setKeywordRate(Integer keywordRate) {
this.keywordRate = keywordRate;
}
public Integer getCompleteScore() {
return completeScore;
}
public void setCompleteScore(Integer completeScore) {
this.completeScore = completeScore;
}
public Integer getCompleteRate() {
return completeRate;
}
public void setCompleteRate(Integer completeRate) {
this.completeRate = completeRate;
}
public Integer getSmoothScore() {
return smoothScore;
}
public void setSmoothScore(Integer smoothScore) {
this.smoothScore = smoothScore;
}
public Integer getSmoothRate() {
return smoothRate;
}
public void setSmoothRate(Integer smoothRate) {
this.smoothRate = smoothRate;
}
public Integer getExpressScore() {
return expressScore;
}
public void setExpressScore(Integer expressScore) {
this.expressScore = expressScore;
}
public Integer getExpressRate() {
return expressRate;
}
public void setExpressRate(Integer expressRate) {
this.expressRate = expressRate;
}
public Integer getPoliteScore() {
return politeScore;
}
public void setPoliteScore(Integer politeScore) {
this.politeScore = politeScore;
}
public Integer getPoliteRate() {
return politeRate;
}
public void setPoliteRate(Integer politeRate) {
this.politeRate = politeRate;
}
public Boolean getDeleted() {
return deleted;
}
public void setDeleted(Boolean deleted) {
this.deleted = deleted;
}
public Long getOrgId() {
return orgId;
}
public void setOrgId(Long orgId) {
this.orgId = orgId;
}
public Long getSiteId() {
return siteId;
}
public void setSiteId(Long siteId) {
this.siteId = siteId;
}
public Long getCompanyId() {
return companyId;
}
public void setCompanyId(Long companyId) {
this.companyId = companyId;
}
public Date getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}
public Date getUpdatedAt() {
return updatedAt;
}
public void setUpdatedAt(Date updatedAt) {
this.updatedAt = updatedAt;
}
@Override
public String toString() {
return "PracticeChatLog{" +
", id=" + id +
", practiceId=" + practiceId +
", accountId=" + accountId +
", accountName=" + accountName +
", accountFullName=" + accountFullName +
", useType=" + useType +
", orgName=" + orgName +
", level=" + level +
", status=" + status +
", startAt=" + startAt +
", endAt=" + endAt +
", passMinScore=" + passMinScore +
", givenPointType=" + givenPointType +
", averageScore=" + averageScore +
", passResult=" + passResult +
", keywordScore=" + keywordScore +
", keywordRate=" + keywordRate +
", completeScore=" + completeScore +
", completeRate=" + completeRate +
", smoothScore=" + smoothScore +
", smoothRate=" + smoothRate +
", expressScore=" + expressScore +
", expressRate=" + expressRate +
", politeScore=" + politeScore +
", politeRate=" + politeRate +
", deleted=" + deleted +
", orgId=" + orgId +
", siteId=" + siteId +
", companyId=" + companyId +
", createdAt=" + createdAt +
", updatedAt=" + updatedAt +
"}";
}
}
package com.yizhi.practice.application.pojo.vo;
import lombok.Data;
@Data
public class PracticePointVo {
private Long id;
private Integer minScore;
private Integer maxScore;
private Integer point;
}
package com.yizhi.practice.application.pojo.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
*/
@Data
public class PracticeVisibleVo implements Serializable {
private static final long serialVersionUID = 1L;
private Long id;
@ApiModelProperty(value = "陪练ID")
private Long practiceId;
@ApiModelProperty(value = "可见站点Id")
private Long visibleSiteId;
@ApiModelProperty(value = "可见部门Id")
private Long visibleOrgId;
@ApiModelProperty(value = "可见部门名")
private String visibleOrgName;
@ApiModelProperty(value = "可见用户Id")
private Long visibleAccountId;
@ApiModelProperty(value = "可见用户工号")
private String visibleAccountWorkNum;
@ApiModelProperty(value = "用户名")
private String visibleAccountName;
@ApiModelProperty(value = "用户全名")
private String visibleAccountFullName;
@ApiModelProperty(value = "陪练可见范围 80:平台可见 50:部门可见 40:指定用户可见")
private Integer visibleType;
@ApiModelProperty(value = "公司Id")
private Long companyId;
@ApiModelProperty(value = "0:not deleted, 1:deleted")
private Boolean deleted;
private Date createdAt;
@ApiModelProperty(value = "创建管理员ID")
private Long createdUid;
private Date updatedAt;
@ApiModelProperty(value = "更新管理员ID")
private Long updatedUid;
}
package com.yizhi.practice.application.pojo.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
@Data
public class PracticeVo {
private Long id;
@ApiModelProperty(value = "陪练名")
private String name;
@ApiModelProperty(value = "陪练logoURL")
private String logoUrl;
@ApiModelProperty(value = "陪练描述")
private String description;
@ApiModelProperty(value = "80:训练+考核 ,10:训练 20:考核")
private Integer useType;
@ApiModelProperty(value = "训练开始时间")
private Date practiceStartAt;
@ApiModelProperty(value = "训练结束时间")
private Date practiceEndAt;
@ApiModelProperty(value = "考核开始时间")
private Date examStartAt;
@ApiModelProperty(value = "考核结束时间")
private Date examEndAt;
@ApiModelProperty(value = "允许最大考试;0:无限次;其他有限次;默认0")
private Integer maxExamCount;
@ApiModelProperty(value = "自定义关键词,逗号分隔,命中得分")
private String keyWord;
@ApiModelProperty(value = "机器人配置ID")
private Long robotId;
@ApiModelProperty(value = "机器人参数")
private String robotParams;
@ApiModelProperty(value = "机器人名字")
private String robotName;
@ApiModelProperty(value = "机器人头像URL null时走默认头像")
private String robotPicUrl;
@ApiModelProperty(value = "陪练状态 80:上架 30:下架 10:草稿")
private Integer status;
@ApiModelProperty(value = "练习可见范围 80:平台可见 40:指定用户可见")
private Integer visibleType;
@ApiModelProperty(value = "跳过对话类型 80允许,10:不允许")
private Integer skipType;
@ApiModelProperty(value = "80:本轮得分超过限制,则进入下轮;10:无论得分多少,直接进入下一轮")
private Integer startNextRoundType;
@ApiModelProperty(value = "超过该分数,进入下一轮对话")
private Integer startNextRoundScore;
@ApiModelProperty(value = "每轮最多失败次数,超过直接到下轮")
private Integer practiceFailedMaxCount;
@ApiModelProperty(value = "80:允许重复提交 10:不允许重复提交")
private Integer repeatPush;
@ApiModelProperty(value = "多轮对话:80:开启 10:关闭")
private Integer manyRoundChat;
@ApiModelProperty(value = "相似度")
private Integer similarityRate;
@ApiModelProperty(value = "考试失败最大次数,超过直接到下轮")
private Integer examFailedMaxCount;
@ApiModelProperty(value = "未识别回复类型 80:默认回复,10:自定义回复")
private Integer similarityFailedMsgType;
@ApiModelProperty(value = "自定义未识别回复,分号分隔。")
private String similarityFailedMsg;
@ApiModelProperty(value = "考试及格分")
private Integer examPassMinScore;
@ApiModelProperty(value = "是否发放积分 80:发放 10:不发放")
private Integer examGivenPointType;
@ApiModelProperty(value = "完整性")
private Integer scoreRuleComplete;
@ApiModelProperty(value = "完整性")
private Integer scoreRuleKeyword;
@ApiModelProperty(value = "流畅性")
private Integer scoreRuleSmooth;
@ApiModelProperty(value = "表达能力")
private Integer scoreRuleExpress;
@ApiModelProperty(value = "礼貌")
private Integer scoreRulePolite;
@ApiModelProperty(value = "0:未删除 1:已删除")
private Boolean deleted;
@ApiModelProperty(value = "部门ID")
private Long orgId;
@ApiModelProperty(value = "站点ID")
private Long siteId;
@ApiModelProperty(value = "公司ID")
private Long companyId;
@ApiModelProperty(value = "创建记录的管理员ID")
private Long createdUid;
@ApiModelProperty(value = "创建时间")
private Date createdAt;
@ApiModelProperty(value = "最后一次更新记录的管理员ID")
private Long updatedUid;
@ApiModelProperty(value = "更新时间")
private Date updatedAt;
}
package com.yizhi.practice.application.pojo.vo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* <p>
* 场景配置
* </p>
*
* @author MybatisCodeGenerator123
* @since 2020-10-21
*/
@Data
@Api(tags = "SceneVo")
public class SceneVo {
@ApiModelProperty(value = "场景id")
private Long id;
@ApiModelProperty(value = "陪练ID")
private Long practiceId;
@ApiModelProperty(value = "场景名")
private String name;
@ApiModelProperty(value = "场景描述")
private String description;
@ApiModelProperty(value = "场景排序")
private int sort;
}
package com.yizhi.practice.application.request;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 关键词请求体
*
*/
@Data
@ApiModel(value = "关键词")
public class
KeyWordsReq {
@ApiModelProperty(name = "key",value = "关键词")
private String key;
/**
* 关键词对应的扩展词
* 多个用分号;分割
*/
@ApiModelProperty(name = "value",value = "关键词对应扩展词")
private String value;
}
package com.yizhi.practice.application.request;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
@ApiModel(value = "指定用户")
public class PracticeAccountReq {
@ApiModelProperty(value = "陪练表主键id")
private Long practiceId;
@ApiModelProperty(value = "用户或者部门信息")
private List<PracticeVisibleAccount> accountList;
}
package com.yizhi.practice.application.request;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
@ApiModel(value = "陪练对话节点信息")
public class PracticeChatNodeReq {
private Long id;
@ApiModelProperty(name = "sceneNodeType",value = "节点标识 10:机器人,20:学员 节点,80:开始节点")
private Integer sceneNodeType;
@ApiModelProperty(name = "level",value = "层级;开始节点层级为0; 开始节点下所有机器人节点层级都为1,依次向下类推")
private Integer level;
@ApiModelProperty(name = "robotContent",value = "该轮 机器人话术")
private String robotContent;
@ApiModelProperty(name = "accountContent",value = "该轮学员标准话术文本")
private String accountContent;
@ApiModelProperty(value = "学员上传真人话术文件名")
private String accountContentFileName;
@ApiModelProperty(name = "accountRealVoiceUrl",value = "学员真人话术音频URL")
private String accountRealVoiceUrl;
@ApiModelProperty(value = "机器人话术音频URL")
private String robotContentVoiceUrl;
@ApiModelProperty(name = "keyWordList",value = "学员话术关键字 key为关键字,value为拓展词,多个拓展词用分号分割")
private List<KeyWordsReq> keyWordList;
@ApiModelProperty(name = "accountContentTabooWord",value = "禁忌词,多个用分号分割")
private String accountContentTabooWord;
@ApiModelProperty(value = "节点坐标;x轴坐标")
@JsonProperty(value = "xAxis")
private String xAxis;
@ApiModelProperty(value = "节点坐标;y轴坐标")
@JsonProperty(value = "yAxis")
private String yAxis;
@ApiModelProperty(name = "childNodes",value = "该对话节点下子节点列表")
private List<PracticeChatNodeReq> childNodes;
}
package com.yizhi.practice.application.request;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yizhi.practice.application.pojo.vo.PracticePointVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
import java.util.List;
@Data
@ApiModel(value = "陪练基本信息和策略信息")
public class PracticeConfigInfoReq {
@ApiModelProperty(value = "陪练id")
private Long id;
@ApiModelProperty(value = "陪练名")
private String name;
@ApiModelProperty(value = "陪练logoURL")
private String logoUrl;
@ApiModelProperty(value = "陪练描述")
private String description;
@ApiModelProperty(value = "陪练模式 80:训练+考核 ,10:训练 20:考核",allowableValues = "80,10,20")
private Integer useType;
@ApiModelProperty(value = "训练开始时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
private Date practiceStartAt;
@ApiModelProperty(value = "训练结束时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
private Date practiceEndAt;
@ApiModelProperty(value = "考核开始时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
private Date examStartAt;
@ApiModelProperty(value = "考核结束时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
private Date examEndAt;
@ApiModelProperty(value = "允许最大考试次数 0:无限次;其他有限次;默认0")
private Integer maxExamCount;
@ApiModelProperty(value = "自定义关键词,逗号分隔")
private String keyWord;
@ApiModelProperty(value = "机器人id")
private Long robotId;
@ApiModelProperty(value = "机器人参数")
private String robotParams;
@ApiModelProperty(value = "机器人称呼")
private String robotAliasName;
@ApiModelProperty(value = "机器人头像URL null时走默认头像")
private String robotPicUrl;
@ApiModelProperty(value = "陪练状态 80:上架 30:下架 10:草稿",allowableValues = "80,30,10",example = "10")
private Integer status;
@ApiModelProperty(value = "80:平台可见 40:指定用户可见",allowableValues = "80,40",example = "80")
private Integer visibleType;
@ApiModelProperty(value = "是否跳过对话 80允许,10:不允许",allowableValues = "80,10")
private Integer skipType;
@ApiModelProperty(value = "每轮对话过关条件 80:开启 10:关闭",allowableValues = "80,10")
private Integer startNextRoundType;
@ApiModelProperty(value = "过关分数")
private Integer startNextRoundScore;
@ApiModelProperty(value = "强制练习轮次")
private Integer practiceFailedMaxCount;
@ApiModelProperty(value = "考核策略是否允许重复提交; 80:允许重复提交 10:不允许重复提交",allowableValues = "80,10")
private Integer repeatPush;
@ApiModelProperty(value = "多轮对话:80:开启 10:关闭",allowableValues = "80,10")
private Integer manyRoundChat;
@ApiModelProperty(value = "相似度")
private Integer similarityRate;
@ApiModelProperty(value = "考核强制对话轮次")
private Integer examFailedMaxCount;
@ApiModelProperty(value = "未识别回复类型 80:默认回复,10:自定义回复",allowableValues = "80,10")
private Integer similarityFailedMsgType;
@ApiModelProperty(value = "自定义未识别回复,分号分隔。")
private String similarityFailedMsg;
@ApiModelProperty(value = "考试及格分")
private Integer examPassMinScore;
@ApiModelProperty(value = "是否发放积分 80:发放 10:不发放",allowableValues = "80,10")
private Integer examGivenPointType;
@ApiModelProperty(value = "积分策略")
private List<PracticePointVo> practicePointList;
@ApiModelProperty(value = "完整性")
private Integer scoreRuleComplete;
@ApiModelProperty(value = "关键词命中")
private Integer scoreRuleKeyword;
@ApiModelProperty(value = "流畅性")
private Integer scoreRuleSmooth;
@ApiModelProperty(value = "表达能力")
private Integer scoreRuleExpress;
@ApiModelProperty(value = "礼貌用语")
private Integer scoreRulePolite;
}
package com.yizhi.practice.application.request;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(value = "智能陪练用户导入导出")
public class PracticeImportAccountReq {
@ApiModelProperty(name = "practiceId",value = "陪练id")
private Long practiceId;
@ApiModelProperty(value = "文件oss路径")
private String fileUrl;
}
package com.yizhi.practice.application.request;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(value = "智能陪练")
public class PracticeReq {
@ApiModelProperty(name = "practiceId",value = "陪练id")
private Long practiceId;
}
package com.yizhi.practice.application.request;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* 场景对话请求
*/
@Data
@ApiModel(value = "陪练场景对话请求体")
public class PracticeSceneDialogueReq {
@ApiModelProperty(name = "practiceId",value = "场景所属陪练id")
private Long practiceId;
@ApiModelProperty(name = "sceneId",value = "对话所属场景id")
private Long sceneId;
//节点列表
private List<PracticeChatNodeReq> chatNodes;
}
package com.yizhi.practice.application.request;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
@Data
@ApiModel("报表统计请求")
public class PracticeStatisticsReq {
@ApiModelProperty(name = "startDate",value = "开始时间")
private String startDate;
@ApiModelProperty(name = "endDate",value = "结束时间")
private String endDate;
@ApiModelProperty(name = "pageNo", value = "当前页码 默认1")
private Integer pageNo = 1;
@ApiModelProperty(name = "pageSize", value = "每页大小 默认10")
private Integer pageSize = 10;
@ApiModelProperty(name = "practiceId",value = "陪练id")
private Long practiceId;
@ApiModelProperty(name = "practiceName",value = "陪练名称")
private String practiceName;
@ApiModelProperty(name = "nameKwd",value = "用户名关键字")
private String nameKwd;
@ApiModelProperty(name = "orgKwd",value = "部门关键字")
private String orgKwd;
private Date startOfDate;
private Date endOfDate;
}
package com.yizhi.practice.application.request;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(value = "智能陪练上架下架请求参数")
public class PracticeStatusReq {
@ApiModelProperty(value = "陪练id")
private Long practiceId;
@ApiModelProperty(value = "陪练状态;80:上架 30:下架",allowableValues = "80,30")
private Integer status;
}
package com.yizhi.practice.application.request;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(value = "可用用户、部门范围")
public class PracticeVisibleAccount {
@ApiModelProperty(value = "用户或者部门id")
private Long visibleId;
@ApiModelProperty(value = "可见范围类型; 50:部门可见 40:用户可见")
private Integer visibleType;
@ApiModelProperty(value = "用户名或部门名")
private String name;
@ApiModelProperty(value = "用户全名;可见范围类型visibleType为用户可见时填写")
private String fullName;
@ApiModelProperty(value = "用户工号;可见范围类型visibleType为用户可见时填写")
private String workNum;
}
package com.yizhi.practice.application.request;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* 查询陪练列表请求体
*/
@Data
@ApiModel(value = "查询陪练列表请求体")
public class PracticesGetReq {
@ApiModelProperty(name = "name",value = "陪练名称或者关键字")
private String name;
@ApiModelProperty(name = "status",value = "陪练状态 80:上架 30:下架 10:草稿",allowableValues = "80,30,10")
private Integer status;
@ApiModelProperty(name = "models",value = "陪练模式 80:训练+考核 ,10:训练 20:考核")
private List<Integer> models;
@ApiModelProperty(name = "pageNo", value = "当前页码 默认1")
private Integer pageNo = 1;
@ApiModelProperty(name = "pageSize", value = "每页大小 默认10")
private Integer pageSize = 10;
/**
* 用户以及用户管理的用户ids
* 用于根据权限查询陪练列表
* */
private List<Long> ids;
private Long companyId;
private Long siteId;
}
package com.yizhi.practice.application.request;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(value = "智能演练场景对话文件导入")
public class SceneChatImportReq {
@ApiModelProperty(value = "文件名")
private String fileName;
@ApiModelProperty(value = "文件url")
private String fileUrl;
@ApiModelProperty(value = "对话所属陪练id")
private Long practiceId;
@ApiModelProperty(value = "对话所属场景id")
private Long sceneId;
}
package com.yizhi.practice.application.request;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(value = "场景")
public class SceneChatReq {
@ApiModelProperty(name = "sceneId",value = "陪练场景id;修改时必传")
private Long sceneId;
}
package com.yizhi.practice.application.request;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(value = "场景请求")
public class SceneReq {
@ApiModelProperty(name = "practiceId",value = "陪练id")
private Long practiceId;
@ApiModelProperty(name = "sceneId",value = "陪练场景id,修改时必传")
private Long sceneId;
@ApiModelProperty(name = "sceneName",value = "陪练场景名称,修改时必传")
private String sceneName;
@ApiModelProperty(name = "desc",value = "陪练场景描述")
private String desc;
@ApiModelProperty(name = "sort",value = "场景排序序号")
private int sort;
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>cloud-chat-practice</artifactId>
<groupId>com.yizhi</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<packaging>jar</packaging>
<modelVersion>4.0.0</modelVersion>
<artifactId>chat-practice-service</artifactId>
<properties>
<kotlin.version>1.4.10</kotlin.version>
</properties>
<dependencies>
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-core</artifactId>
<version>2.4.4</version>
</dependency>
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-native-osx64</artifactId>
<version>2.4.4</version>
</dependency>
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-native-linux64</artifactId>
<version>2.4.4</version>
</dependency>
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-native-win64</artifactId>
<version>2.4.4</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.jave</groupId>-->
<!-- <artifactId>jave</artifactId>-->
<!-- <version>1.0.2</version>-->
<!-- </dependency>-->
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.13.1</version>
</dependency>
<dependency>
<groupId>com.squareup.okio</groupId>
<artifactId>okio</artifactId>
<version>1.15.0</version>
</dependency>
<!-- 百度 自然语言处理SDK -->
<dependency>
<groupId>com.baidu.aip</groupId>
<artifactId>java-sdk</artifactId>
<version>4.15.1</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity-engine-core</artifactId>
<version>2.0</version>
</dependency>
<!-- JPA + QueryDsl-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-apt</artifactId>
</dependency>
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-orm</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-core</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-util</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>chat-practice-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-system-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-point-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-statistics-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-wechat-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
<!-- <build>-->
<!-- <plugins>-->
<!-- <plugin>-->
<!-- <groupId>com.mysema.maven</groupId>-->
<!-- <artifactId>apt-maven-plugin</artifactId>-->
<!-- <version>1.1.3</version>-->
<!-- <executions>-->
<!-- <execution>-->
<!-- &lt;!&ndash; <phase>generate-sources</phase>&ndash;&gt;-->
<!-- <goals>-->
<!-- <goal>process</goal>-->
<!-- </goals>-->
<!-- <configuration>-->
<!-- <outputDirectory>src/main/java/com/yizhi/practice/application/pojo/domain</outputDirectory>-->
<!-- <processor>com.querydsl.apt.jpa.JPAAnnotationProcessor</processor>-->
<!-- </configuration>-->
<!-- </execution>-->
<!-- </executions>-->
<!-- </plugin>-->
<!-- </plugins>-->
<!-- </build>-->
</project>
package com.yizhi.practice.application;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
* @Date 2020/10/21 9:58 上午
* @Author lvjianhui
**/
@SpringBootApplication
@EnableDiscoveryClient
@EnableSwagger2
@EnableCaching
@EnableFeignClients(basePackages = {"com.yizhi"})
@ComponentScan(basePackages = {"com.yizhi"})
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
package com.yizhi.practice.application.aop;
import com.google.gson.Gson;
import com.yizhi.core.application.context.ContextHolder;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.util.application.domain.BizResponse;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.formula.functions.T;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
/**
* 智能陪练aop
*/
@Component
@Aspect
@Slf4j
public class PracticeAop {
/**
* 定义切入点,切入点为com.yizhi.practice.application.controller包下所有controller中的所有函数
*通过@Pointcut注解声明频繁使用的切点表达式
*/
@Pointcut("execution(public * com.yizhi.practice.application.controller.manage.*.*(..)))")
public void webLogAspect(){
}
/**
* 方法执行前后打印日志
*/
@Around("webLogAspect()")
public Object doAround(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletRequest request = attributes.getRequest();
RequestContext context = ContextHolder.get();
Long accountId = context.getAccountId();
Long siteId = context.getSiteId();
String siteCode = context.getSiteCode();
Long orgId = context.getOrgId();
String accountName = context.getAccountName();
Gson gson = new Gson();
//打印请求信息
log.info("===START=====Request AccountId = {} ,AccountName = {},SiteId = {} ,SiteCode = {},OrgId = {}; " +
"URL : {}, Request Class-Method: [{}-{}] " +
" ,Request Args : {} ======\r\n"
,accountId,accountName,siteId,siteCode,orgId
,request.getRequestURL().toString(),proceedingJoinPoint.getTarget().getClass().getName(),proceedingJoinPoint.getSignature().getName()
,gson.toJson(proceedingJoinPoint.getArgs()));
BizResponse<T> result = (BizResponse<T>) proceedingJoinPoint.proceed();
// 打印出参
log.info("Response Args : {}", gson.toJson(result));
log.info("===END=====Request AccountId = {} ,AccountName = {},SiteId = {} ,SiteCode = {},OrgId = {}; " +
"URL : {}, Request Class-Method: [{}-{}] " +
" ,Response : {} ======\r\n"
,accountId,accountName,siteId,siteCode,orgId
,request.getRequestURL().toString(),proceedingJoinPoint.getTarget().getClass().getName(),proceedingJoinPoint.getSignature().getName()
,gson.toJson(result.getData()));
return result;
}
}
package com.yizhi.practice.application.config
import org.apache.commons.io.FileUtils
import org.apache.commons.lang.math.RandomUtils
import org.slf4j.LoggerFactory
import ws.schild.jave.AudioAttributes
import ws.schild.jave.Encoder
import ws.schild.jave.EncodingAttributes
import ws.schild.jave.MultimediaObject
import java.io.File
import java.net.URL
object AudioUtils {
private val logger = LoggerFactory.getLogger(javaClass)
val dir = "tmp/audio/"
init {
val dirFile = File(dir)
if (!dirFile.exists()) {
dirFile.mkdirs()
}
}
private fun wavToMp3(sourceFile: File): File? {
val targetFileName = System.currentTimeMillis().toString() + RandomUtils.nextInt(100000).toString()
val target = File("$dir$targetFileName.mp3")
val audio = AudioAttributes()
audio.setCodec("libmp3lame")
audio.setBitRate(16000)
audio.setChannels(1)
audio.setSamplingRate(16000)
val attrs = EncodingAttributes()
attrs.setFormat("mp3")
attrs.setAudioAttributes(audio)
val encoder = Encoder()
val multimediaObject = MultimediaObject(sourceFile)
encoder.encode(multimediaObject, target, attrs)
return target
}
private fun wavToPcm(sourceFile: File): File? {
val targetFileName = System.currentTimeMillis().toString() + RandomUtils.nextInt(100000).toString()
val target = File("$dir$targetFileName.pcm")
val audio = AudioAttributes()
audio.setCodec("pcm_s16le")
audio.setBitRate(16)
audio.setChannels(1)
audio.setSamplingRate(16000)
val attrs = EncodingAttributes()
attrs.setFormat("s16le")
attrs.setAudioAttributes(audio)
val encoder = Encoder()
val multimediaObject = MultimediaObject(sourceFile)
encoder.encode(multimediaObject, target, attrs)
return target
}
fun wavToPcm(fileUrl: String):File? {
val type = fileUrl.split(".").last()
val httpurl = URL(fileUrl)
// 生成随机文件名
val fileName = System.currentTimeMillis().toString() + RandomUtils.nextInt(100000).toString() + "." + type
val file = File(dir + fileName)
var mp3File: File? = null
try {
FileUtils.copyURLToFile(httpurl, file)
mp3File = wavToPcm(file)!!
return mp3File
} catch (e: Exception) {
logger.error("拷贝文件或转MPCM出错。URL:$fileUrl")
e.printStackTrace()
file.deleteOnExit()
} finally {
file.deleteOnExit()
}
return null
}
fun wavToMp3(fileUrl: String): File? {
val type = fileUrl.split(".").last()
val httpurl = URL(fileUrl)
// 生成随机文件名
val fileName = System.currentTimeMillis().toString() + RandomUtils.nextInt(100000).toString() + "." + type
println("fileName-->>>"+fileName)
val file = File(dir + fileName)
var mp3File: File? = null
try {
FileUtils.copyURLToFile(httpurl, file)
mp3File = wavToMp3(file)!!
return mp3File
} catch (e: Exception) {
logger.error("拷贝文件或转MP3出错。URL:$fileUrl")
e.printStackTrace()
//file.deleteOnExit()
} finally {
//file.deleteOnExit()
}
return null
}
/**
* 获取音频文件时长
*/
fun getAudioDuration(file: File): Long {
val multimediaObject = MultimediaObject(file)
return multimediaObject.info.duration
}
/**
* 获取网络音频资源时长
*/
fun getAudioDuration(fileUrl: String): Long {
val type = fileUrl.split(".").last()
val httpurl = URL(fileUrl)
// 生成随机文件名
val fileName = System.currentTimeMillis().toString() + RandomUtils.nextInt(100000).toString() + "." + type
var file: File? = File(dir + fileName)
var duration = 0L;
try {
FileUtils.copyURLToFile(httpurl, file)
duration = getAudioDuration(file!!)
file.deleteOnExit()
return duration
} catch (e: Exception) {
e.printStackTrace()
logger.error("获取音频时长异常。URL:$fileUrl")
file!!.deleteOnExit()
} finally {
// 删除生成的文件
file!!.deleteOnExit()
}
return duration
}
}
\ No newline at end of file
package com.yizhi.practice.application.config
/**
* @Date 2020/10/26 4:21 下午
* @Author lvjianhui
**/
enum class PracticeLevelEnum(val level:Int,val msg:String) {
PRIMARY_LEVEL (10,"初级"),
INTERMEDIATE_LEVEL (40,"中级"),
SENIOR_LEVEL (80,"高级");
companion object {
val map = values().associateBy { it.level }
fun getAlllevel() = map.keys
}
}
package com.yizhi.practice.application.config
/**
* @Date 2020/10/26 2:04 下午
* @Author lvjianhui
**/
enum class PracticeRunningStatusEnum(val status:Int,val msg:String) {
NOT_STARTED (10,"未开始"),
RUNNING (40,"进行中"),
ENDED (80,"已结束"),
ALL (90,"所有状态");
companion object {
val map = values().associateBy { it.status }
fun getAllStatus() = map.keys
fun getEnumByState(status: Int) :PracticeRunningStatusEnum {
return map[status]!!
}
}
}
\ No newline at end of file
package com.yizhi.practice.application.config;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class ThreadPoolConfig {
@Value("${practice.thread.pool.corePoolSize}")
private Integer corePoolSize;
@Value("${practice.thread.pool.maxPoolSize}")
private Integer maxPoolSize;
@Value("${practice.thread.pool.keepAliveTime}")
private Long keepAliveTime;
@Value("${practice.thread.pool.queueSize}")
private Integer queueSize;
@Bean(value="practiceThreadPool")
public ExecutorService practiceThreadPool() {
return new ThreadPoolExecutor(corePoolSize, maxPoolSize, keepAliveTime, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<>(queueSize), new ThreadPoolExecutor.AbortPolicy());
}
}
package com.yizhi.practice.application.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.context.request.async.DeferredResult;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
* @Author: shengchenglong
* @Date: 2018/3/6 14:30
*/
@Configuration
@EnableSwagger2
public class WebMvcConfigure extends WebMvcConfigurerAdapter {
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.groupName("未木云")
.apiInfo(new ApiInfoBuilder()
.title("智能陪练接口")
.version("1.0")
.build())
.select()
.apis(RequestHandlerSelectors.basePackage("com.yizhi"))
.paths(PathSelectors.any())
.build();
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("docs.html").addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
}
}
package com.yizhi.practice.application.constants;
/**
* 常量表
*/
public class PracticeConstant {
public static final String BUSINESS_TYPE = "PRACTICE";
public static final String SUB_BUSINESS_TYPE = "MANAGECHAT";
public static final String SUB_BUSINESS_TYPE_EXPORT = "EXPORT";
public static final String KEY_WORD_SPERATOR_EN = ";";
public static final String KEY_WORD_SPERATOR_CN = ";";
/**
* 导入对话开始节点默认横坐标(X坐标)值
*/
public static final int CHAT_DEFAULT_XAXIS = 50;
/**
* 导入对话开始节点默认纵坐标(Y坐标)值
*/
public static final int CHAT_DEFAULT_YAXIS = 50;
/**
* 导入对话,默认递增纵坐标(Y坐标)值步长
*/
public static final int YAXIS_STEP_LEN = 100;
/**
* 智能陪练陪练策略未识别回复语句
*/
public static final String EXAM_FAIL_MESSAGE = "我无法理解您的意图,请重新回复";
/**
* 智能陪练默认logo图片地址
*/
public static final String PRACTICE_DEFAULT_LOGO_URL = "https://cloud-wmy.oss-cn-shanghai.aliyuncs.com/practice/logo/practice_logo.png";
}
package com.yizhi.practice.application.constants;
/**
* @Date 2020/11/13 3:47 下午
* @Author lvjianhui
**/
public class PracticePointConstant {
public static final String POINT_EVENT_NAME = "practiceChat";
public static final String POINT_ACTIVITY_TYPE = "陪练考核通过";
public static final String POINT_ACTIVITY_SOURCE = "陪练";
}
package com.yizhi.practice.application.controller.manage;
import com.yizhi.practice.application.pojo.vo.PracticeChatLogListHeaderVo;
import com.yizhi.practice.application.pojo.vo.PracticeChatLogListParamVo;
import com.yizhi.practice.application.pojo.vo.PracticeChatLogListVo;
import com.yizhi.practice.application.xservice.PracticeChatLogXService;
import com.yizhi.util.application.domain.BizResponse;
import com.yizhi.util.application.page.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@Api(tags = "智能演练-陪练记录")
@RequestMapping(path = "/manage/practice/log")
@RestController
public class PracticeChatLogController {
@Autowired
private PracticeChatLogXService xservice;
@ApiOperation(value = "陪练记录-列表-头部基本信息")
@GetMapping("/base/info/get")
public BizResponse<PracticeChatLogListHeaderVo> listHeaderInfo(@ApiParam(value="陪练的ID") @RequestParam("practiceId")Long practiceId){
return BizResponse.ok(xservice.baseInfo(practiceId));
}
@ApiOperation(value = "陪练记录-列表-列表信息")
@PostMapping("/list")
public BizResponse<PageInfo<PracticeChatLogListVo>> list(@ApiParam(name="传入参数") @RequestBody PracticeChatLogListParamVo param){
return BizResponse.ok(xservice.list(param));
}
@ApiOperation("陪练记录-导出陪练记录")
@PostMapping("/download")
public BizResponse<String> export(@ApiParam(name="传入参数") @RequestBody PracticeChatLogListParamVo param) {
return BizResponse.ok(xservice.export(param));
}
}
package com.yizhi.practice.application.controller.manage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.yizhi.core.application.context.ContextHolder;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.practice.application.pojo.vo.PracticeChatLogBaseInfoVo;
import com.yizhi.practice.application.pojo.vo.PracticeChatLogDetailParamVo;
import com.yizhi.practice.application.pojo.vo.PracticeChatRoundLogDetailVo;
import com.yizhi.practice.application.service.IPracticeChatLogService;
import com.yizhi.practice.application.xservice.PracticeChatRoundLogXService;
import com.yizhi.util.application.domain.BizResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@Api(tags = "智能演练-陪练记录-陪练详情")
@RequestMapping(path = "/manage/practice/log/detail")
@RestController
public class PracticeChatRoundLogController {
@Autowired
private PracticeChatRoundLogXService roundXservice;
@Autowired
private IPracticeChatLogService chatservice;
@ApiOperation(value = "本题分析")
@GetMapping("/analysis/get")
public BizResponse<PracticeChatRoundLogDetailVo> analysis(@ApiParam(value="某句对话的ID") @RequestParam("roundId")Long roundId){
return BizResponse.ok(roundXservice.analysis(roundId));
}
@ApiOperation(value = "陪练详情(包含学员信息,总得分信息,场景对话及得分)")
@GetMapping("/get")
public BizResponse<PracticeChatLogBaseInfoVo> baseInfo(@ApiParam(value="陪练记录的ID") @RequestParam("practiceLogId") Long practiceLogId){
return BizResponse.ok(roundXservice.getLogByPracticeChatId(practiceLogId));
}
@ApiOperation(value = "上一份")
@PostMapping("/previous/get")
public BizResponse<PracticeChatLogBaseInfoVo> previous(@RequestBody PracticeChatLogDetailParamVo param){
RequestContext requestContext = ContextHolder.get();
Long previousId = chatservice.previous(param, requestContext);
if(null == previousId) {
log.warn("Previous practice log not exist!");
return BizResponse.ok();
}
return BizResponse.ok(roundXservice.getLogByPracticeChatId(previousId));
}
@ApiOperation(value = "下一份")
@PostMapping("/next/get")
public BizResponse<PracticeChatLogBaseInfoVo> next(@RequestBody PracticeChatLogDetailParamVo param){
RequestContext requestContext = ContextHolder.get();
Long nextId = chatservice.next(param, requestContext);
if(null == nextId) {
log.warn("Next practice log not exist!");
return BizResponse.ok();
}
return BizResponse.ok(roundXservice.getLogByPracticeChatId(nextId));
}
}
package com.yizhi.practice.application.controller.manage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.plugins.Page;
import com.yizhi.core.application.context.ContextHolder;
import com.yizhi.practice.application.util.NumberUtil;
import com.yizhi.statistics.application.feign.StatisticsPracticeByUserClient;
import com.yizhi.statistics.application.request.practice.PracticeReportByUserDetailReq;
import com.yizhi.statistics.application.request.practice.PracticeReportByUserReq;
import com.yizhi.statistics.application.vo.practice.PracticeReportByUserDetailVo;
import com.yizhi.statistics.application.vo.practice.PracticeReportByUserListVo;
import com.yizhi.util.application.domain.BizResponse;
import com.yizhi.util.application.page.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
@Api(tags = "智能演练-报表-按用户统计")
@RequestMapping(path = "/manage/practice/report/user")
@RestController
@Slf4j
public class PracticeReportByUserController {
@Autowired
private StatisticsPracticeByUserClient statisticsClient;
@ApiOperation(value = "列表")
@PostMapping("/list/get")
public BizResponse<PageInfo<PracticeReportByUserListVo>> list(@RequestBody PracticeReportByUserReq param){
param.setContext(ContextHolder.get());
Page<PracticeReportByUserListVo> result = statisticsClient.list(param);
PageInfo<PracticeReportByUserListVo> page = new PageInfo<PracticeReportByUserListVo>();
page.setPageNo(param.getPageNo());
page.setPageSize(param.getPageSize());
page.setPageTotal(NumberUtil.getPageCount((long) result.getTotal(), param.getPageSize()));
page.setPageRecords(result.getTotal());
page.setRecords(result.getRecords());
log.info("Practice report by user - list page - size : {}.", result.getTotal());
return BizResponse.ok(page);
}
@ApiOperation(value = "列表-下载")
@PostMapping("/list/download")
public BizResponse<String> listDownload(@RequestBody PracticeReportByUserReq param){
param.setContext(ContextHolder.get());
return BizResponse.ok(statisticsClient.listDownload(param));
}
@ApiOperation(value = "详情")
@PostMapping("/detail/get")
public BizResponse<PageInfo<PracticeReportByUserDetailVo>> detail(@RequestBody PracticeReportByUserDetailReq param){
param.setContext(ContextHolder.get());
Page<PracticeReportByUserDetailVo> result = statisticsClient.detail(param);
PageInfo<PracticeReportByUserDetailVo> page = new PageInfo<PracticeReportByUserDetailVo>();
page.setPageNo(param.getPageNo());
page.setPageSize(param.getPageSize());
page.setPageTotal(NumberUtil.getPageCount((long) result.getTotal(), param.getPageSize()));
page.setPageRecords(result.getTotal());
page.setRecords(result.getRecords());
log.info("Practice report by user - detail page - size : {}.", result.getTotal());
return BizResponse.ok(page);
}
@ApiOperation(value = "详情-下载")
@PostMapping("/detail/download")
public BizResponse<String> detailDownload(@RequestBody PracticeReportByUserDetailReq param){
param.setContext(ContextHolder.get());
return BizResponse.ok(statisticsClient.detailDownload(param));
}
}
package com.yizhi.practice.application.controller.manage;
import com.alibaba.fastjson.JSONObject;
import com.yizhi.core.application.context.ContextHolder;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.core.application.enums.InternationalEnums;
import com.yizhi.core.application.exception.BizException;
import com.yizhi.practice.application.pojo.vo.SceneVo;
import com.yizhi.practice.application.request.SceneChatReq;
import com.yizhi.practice.application.request.SceneReq;
import com.yizhi.practice.application.xservice.PracticeXSceneservice;
import com.yizhi.util.application.domain.BizResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@Slf4j
@Api(tags = "智能演练-场景")
@RequestMapping(path = "/manage/scene")
@RestController(value = "ManagePracticeSceneController")
public class PracticeSceneController {
private static Logger logger = LoggerFactory.getLogger(PracticeSceneController.class);
@Autowired
PracticeXSceneservice xSceneservice;
/**
* 新增场景
*/
@ApiOperation(value = "新增陪练场景")
@PostMapping(path = "/save")
public BizResponse<SceneVo> addScene(@RequestBody SceneReq sceneReq){
if (null == sceneReq.getPracticeId()){
logger.error("新增陪练场景,陪练id为空! 请求入参: {}", JSONObject.toJSONString(sceneReq));
throw new BizException(InternationalEnums.MATERIALCONTROLLER1);
}
return xSceneservice.save(sceneReq);
}
/**
* 修改场景
*/
@ApiOperation(value = "修改场景")
@PostMapping(path = "/update")
public BizResponse<SceneVo> updateScene(@RequestBody SceneReq sceneReq){
if (null == sceneReq.getPracticeId()){
logger.error("修改陪练场景,陪练id为空! 请求入参: {}", JSONObject.toJSONString(sceneReq));
throw new BizException(InternationalEnums.MATERIALCONTROLLER1);
}
return xSceneservice.save(sceneReq);
}
/**
* 修改场景排序
*/
@ApiOperation(value = "修改场景排序")
@PostMapping(path = "/sort/update")
public BizResponse updateSceneSort(@RequestBody List<SceneReq> sceneReqList){
if (null == sceneReqList || sceneReqList.size() == 0){
logger.error("修改场景排序失败,入参为空!");
throw new BizException(InternationalEnums.MATERIALCONTROLLER1);
}
return xSceneservice.updateSceneSort(sceneReqList);
}
/**
* 删除场景
*/
@ApiOperation(value = "删除场景")
@PostMapping(path = "/delete")
public BizResponse deleteScene(@RequestBody SceneChatReq sceneReq){
//删除场景
RequestContext context = ContextHolder.get();
Long sceneId = sceneReq.getSceneId();
if (null == sceneId){
log.error("[PracticeSceneController:deleteScene]删除场景失败。sceneId is null. accountId = {}",context.getAccountId());
throw new BizException(InternationalEnums.CLASSIFYCONTROLLER4);
}
return xSceneservice.deleteScene(sceneId);
}
/**
* 查询场景
*/
@ApiOperation(value = "查询场景详情")
@GetMapping(path = "/one/get")
public BizResponse<SceneVo> selectScene(@RequestParam(name = "sceneId") Long sceneId){
SceneVo sceneVo = xSceneservice.selectScene(sceneId);
return BizResponse.ok(sceneVo);
}
/**
* 查询场景列表
*/
@ApiOperation(value = "查询场景列表")
@GetMapping(path = "/list")
public BizResponse<List<SceneVo>> selectSceneList(@RequestParam(name = "practiceId") Long practiceId){
RequestContext context = ContextHolder.get();
if (null == practiceId){
log.error("查询场景列表失败.传入practiceId 为空;accountId = {}",context.getAccountId());
return BizResponse.fail("查询场景列表失败");
}
List<SceneVo> list = xSceneservice.selectSceneList(practiceId);
return BizResponse.ok(list);
}
}
package com.yizhi.practice.application.controller.manage;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.plugins.Page;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.yizhi.core.application.context.ContextHolder;
import com.yizhi.core.application.enums.InternationalEnums;
import com.yizhi.core.application.exception.BizException;
import com.yizhi.practice.application.request.PracticeStatisticsReq;
import com.yizhi.statistics.application.feign.StatisticsPracticeClient;
import com.yizhi.statistics.application.request.practice.PracticeStatByPracticeIdReq;
import com.yizhi.statistics.application.request.practice.PracticeStatByPracticeReq;
import com.yizhi.statistics.application.vo.practice.PracticeStatByPracticeVo;
import com.yizhi.statistics.application.vo.practice.PracticeStatViewByIdVo;
import com.yizhi.util.application.domain.BizResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
@Slf4j
@Api(tags = "智能陪练统计")
@RequestMapping("/manage/practice/report")
@RestController
public class PracticeStatisticsController {
private static Logger logger = LoggerFactory.getLogger(PracticeStatisticsController.class);
private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
@Autowired
StatisticsPracticeClient practiceClient;
@PostMapping("/group/list")
@ApiOperation(value = "智能陪练统计-按陪练统计")
public BizResponse<Page<PracticeStatByPracticeVo>> practiceGroup(@RequestBody PracticeStatisticsReq req) throws JsonProcessingException, ParseException {
PracticeStatByPracticeReq practiceReq = new PracticeStatByPracticeReq();
checkAndSetTime(req);
practiceReq.setStartDate(req.getStartOfDate());
practiceReq.setEndDate(req.getEndOfDate());
practiceReq.setName(req.getPracticeName());
practiceReq.setPageNo(req.getPageNo());
practiceReq.setPageSize(req.getPageSize());
practiceReq.setContext(ContextHolder.get());
return BizResponse.ok(practiceClient.practiceGroup(practiceReq));
}
@PostMapping("/group/list/download")
@ApiOperation(value = "智能陪练统计-按陪练统计-按陪练统计下载")
public BizResponse practiceGroupDownload(@RequestBody PracticeStatisticsReq req) throws ParseException {
checkAndSetTime(req);
PracticeStatByPracticeReq practiceReq = new PracticeStatByPracticeReq();
practiceReq.setPageSize(req.getPageSize());
practiceReq.setPageNo(req.getPageNo());
practiceReq.setName(req.getPracticeName());
practiceReq.setStartDate(req.getStartOfDate());
practiceReq.setEndDate(req.getEndOfDate());
practiceReq.setContext(ContextHolder.get());
return BizResponse.ok(practiceClient.practiceGroupDownload(practiceReq));
}
@PostMapping("/group/view/list")
@ApiOperation(value = "智能陪练统计-按陪练统计-学员陪练结果列表")
public BizResponse<Page<PracticeStatViewByIdVo>> practiceGroupView(@RequestBody PracticeStatisticsReq req) throws ParseException {
checkAndSetTime(req);
Long practiceId = req.getPracticeId();
if (null == practiceId){
logger.error("智能陪练学员训练详情列表陪练id为空!");
return BizResponse.fail(InternationalEnums.DROOLSMANAGERCONTROLLER1.getCode(),InternationalEnums.DROOLSMANAGERCONTROLLER1.getName());
}
PracticeStatByPracticeIdReq practiceViewReq = new PracticeStatByPracticeIdReq();
practiceViewReq.setPageSize(req.getPageSize());
practiceViewReq.setPageNo(req.getPageNo());
practiceViewReq.setPracticeId(req.getPracticeId());
practiceViewReq.setPracticeName(req.getPracticeName());
practiceViewReq.setStartDate(req.getStartOfDate());
practiceViewReq.setEndDate(req.getEndOfDate());
practiceViewReq.setNameKwd(req.getNameKwd());
practiceViewReq.setOrgKwd(req.getOrgKwd());
practiceViewReq.setContext(ContextHolder.get());
return BizResponse.ok(practiceClient.practiceGroupView(practiceViewReq));
}
@PostMapping("/group/view/list/download")
@ApiOperation(value = "智能陪练统计-按陪练统计-详情-下载结果数据")
public BizResponse PagepracticeGroupViewDownload(@RequestBody PracticeStatisticsReq req) throws ParseException {
checkAndSetTime(req);
Long practiceId = req.getPracticeId();
if (null == practiceId){
logger.error("智能陪练统计-按陪练统计-详情-下载结果数据,陪练id为空!");
return BizResponse.fail(InternationalEnums.DROOLSMANAGERCONTROLLER1.getCode(),InternationalEnums.DROOLSMANAGERCONTROLLER1.getName());
}
PracticeStatByPracticeIdReq practiceViewReq = new PracticeStatByPracticeIdReq();
practiceViewReq.setPageSize(req.getPageSize());
practiceViewReq.setPageNo(req.getPageNo());
practiceViewReq.setPracticeId(req.getPracticeId());
practiceViewReq.setPracticeName(req.getPracticeName());
practiceViewReq.setStartDate(req.getStartOfDate());
practiceViewReq.setEndDate(req.getEndOfDate());
practiceViewReq.setNameKwd(req.getNameKwd());
practiceViewReq.setOrgKwd(req.getOrgKwd());
practiceViewReq.setContext(ContextHolder.get());
return BizResponse.ok(practiceClient.practiceGroupViewDownload(practiceViewReq));
}
@PostMapping("/group/view/list/detail/download")
@ApiOperation(value = "智能陪练统计-按陪练统计-详情-下载陪练明细")
public BizResponse practiceGroupViewDetailDownload(@RequestBody PracticeStatisticsReq req) throws ParseException {
checkAndSetTime(req);
Long practiceId = req.getPracticeId();
if (null == practiceId){
logger.error("智能陪练统计-按陪练统计-详情-下载陪练明细,陪练id为空!");
return BizResponse.fail(InternationalEnums.DROOLSMANAGERCONTROLLER1.getCode(),InternationalEnums.DROOLSMANAGERCONTROLLER1.getName());
}
PracticeStatByPracticeIdReq practiceViewReq = new PracticeStatByPracticeIdReq();
practiceViewReq.setPageSize(req.getPageSize());
practiceViewReq.setPageNo(req.getPageNo());
practiceViewReq.setPracticeId(req.getPracticeId());
practiceViewReq.setPracticeName(req.getPracticeName());
practiceViewReq.setStartDate(req.getStartOfDate());
practiceViewReq.setEndDate(req.getEndOfDate());
practiceViewReq.setNameKwd(req.getNameKwd());
practiceViewReq.setOrgKwd(req.getOrgKwd());
practiceViewReq.setContext(ContextHolder.get());
return BizResponse.ok(practiceClient.practiceGroupViewDetailDownload(practiceViewReq));
}
//时间转换
private PracticeStatisticsReq checkAndSetTime(PracticeStatisticsReq req) throws ParseException {
String startDate = req.getStartDate();
String endDate = req.getEndDate();
if (StringUtils.isEmpty(startDate) || StringUtils.isEmpty(endDate)){
logger.error("智能陪练统计-按陪练统计时间段包含空值");
throw new BizException(InternationalEnums.OFFLINECOURSEREPORTCONTROLLER);
}
Date startOfDate = DateUtil.beginOfDay(format.parse(startDate));
Date endOfDate = DateUtil.endOfDay(format.parse(endDate));
req.setStartOfDate(startOfDate);
req.setEndOfDate(endOfDate);
return req;
}
}
package com.yizhi.practice.application.controller.manage.export;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.yizhi.core.application.context.TaskContext;
import com.yizhi.core.application.file.task.AbstractDefaultTask;
import com.yizhi.practice.application.constants.PracticeConstant;
import com.yizhi.practice.application.pojo.po.PracticeChatLogExportPo;
import com.yizhi.practice.application.pojo.vo.PracticeChatLogListVo;
import com.yizhi.practice.application.third.aliyun.AliyunUtil;
import com.yizhi.practice.application.third.util.OssFileUtil;
@Component
public class PracticeChatLogExport extends AbstractDefaultTask<String, PracticeChatLogExportPo> {
private static final Logger LOGGER = LoggerFactory.getLogger(PracticeChatLogExport.class);
@Autowired
private AliyunUtil aliyunUtil;
@Override
protected String execute(PracticeChatLogExportPo exportParam) {
String resultUrl = null;
TaskContext taskContext = new TaskContext(exportParam.getTaskId(), exportParam.getSerialNo(), exportParam.getTaskName(),
exportParam.getAccountId(), new Date(), exportParam.getSiteId(), exportParam.getCompanyId());
working(taskContext);
InputStream ins = null;
try(Workbook wb = createExcel(exportParam.getDatas());
ByteArrayOutputStream bos = new ByteArrayOutputStream()){
wb.write(bos);
ins = new ByteArrayInputStream(bos.toByteArray());
resultUrl = aliyunUtil.uploadByStream(OssFileUtil.getManageStandardFileUri(exportParam.getCompanyId(), exportParam.getSiteId()
, PracticeConstant.BUSINESS_TYPE
, PracticeConstant.SUB_BUSINESS_TYPE_EXPORT
, exportParam.getAccountId()
, ".xlsx"), ins);
success(taskContext, "成功", resultUrl);
} catch (IOException e) {
fail(taskContext, "导出陪练记录过程中发生错误");
LOGGER.error("Error occurred : ", e);
} finally {
if(null != ins) {
try {
ins.close();
} catch (IOException e) {
LOGGER.error("Error occurred : ", e);
}
}
}
return resultUrl;
}
private Workbook createExcel(List<PracticeChatLogListVo> datas) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
XSSFWorkbook wb = new XSSFWorkbook();
//创建报表页
XSSFSheet sheet = wb.createSheet("陪练记录");
int rowCount=0;
XSSFRow row = sheet.createRow(rowCount);
rowCount++;
String[] headers = new String[] {"用户名","姓名","部门","陪练模式","完成时间","总得分"};
for(int i = 0 ; i < headers.length; i++) {
row.createCell(i).setCellValue(headers[i]);
}
if(null != datas && datas.size()>0){
for(PracticeChatLogListVo data : datas) {
XSSFRow dataRow = sheet.createRow(rowCount++);
int cellCount = 0;
dataRow.createCell(cellCount++).setCellValue(data.getAccountName());
dataRow.createCell(cellCount++).setCellValue(data.getAccountFullName());
dataRow.createCell(cellCount++).setCellValue(data.getOrgName());
dataRow.createCell(cellCount++).setCellValue(data.getMode());
dataRow.createCell(cellCount++).setCellValue(sdf.format(data.getEndAt()));
dataRow.createCell(cellCount++).setCellValue(data.getTotalScore());
}
}
return wb;
}
}
package com.yizhi.practice.application.controller.manage.statistics;
import com.baomidou.mybatisplus.plugins.Page;
import com.yizhi.core.application.context.ContextHolder;
import com.yizhi.statistics.application.feign.StatisticsPracticeByOrgClient;
import com.yizhi.statistics.application.request.practice.PracticeByOrgPageReq;
import com.yizhi.statistics.application.request.practice.PracticeReportByUserReq;
import com.yizhi.statistics.application.vo.practice.PracticeReportByUserListVo;
import com.yizhi.statistics.application.vo.practice.PracticeStatByOrgVo;
import com.yizhi.util.application.domain.BizResponse;
import com.yizhi.util.application.page.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @Date 2020/11/18 3:17 下午
* @Author lvjianhui
**/
@Api(tags = "智能演练-按部门统计")
@RequestMapping(path = "/manage/statistic/practice/report/org")
@RestController
public class PracticeGroupByOrgController {
@Autowired
private StatisticsPracticeByOrgClient statisticsPracticeByOrgClient;
@PostMapping("/page")
@ApiOperation("按部门统计查询")
public BizResponse<PageInfo<PracticeStatByOrgVo>> getPageByOrg(@RequestBody PracticeByOrgPageReq po) {
po.setRequestContext(ContextHolder.get());
PageInfo<PracticeStatByOrgVo> page = statisticsPracticeByOrgClient.groupByOrgPage(po);
return BizResponse.ok(page);
}
@PostMapping("/detail/page")
@ApiOperation("按部门统计查询")
public BizResponse<PageInfo<PracticeReportByUserListVo>> getPageByOrgDetail(@RequestBody PracticeReportByUserReq po) {
po.setContext(ContextHolder.get());
Page<PracticeReportByUserListVo> page = statisticsPracticeByOrgClient.getDetailByOrgIdPage(po);
PageInfo<PracticeReportByUserListVo> vo = new PageInfo();
vo.setRecords(page.getRecords());
vo.setPageTotal(page.getTotal());
vo.setPageNo(page.getOffset());
vo.setPageSize(page.getSize());
vo.setPageRecords(page.getTotal());
return BizResponse.ok(vo);
}
@PostMapping("/page/export")
@ApiOperation("按部门统计导出")
public BizResponse<String> exportByOrg(@RequestBody PracticeByOrgPageReq po) {
po.setRequestContext(ContextHolder.get());
String taskCode = statisticsPracticeByOrgClient.groupByOrgExport(po);
return BizResponse.ok(taskCode);
}
@PostMapping("/detail/export")
@ApiOperation("按部门+用户统计导出")
public BizResponse<String> exportByOrgDedaill(@RequestBody PracticeReportByUserReq po) {
po.setContext(ContextHolder.get());
String taskCode = statisticsPracticeByOrgClient.getDetailByOrgIdPageExport(po);
return BizResponse.ok(taskCode);
}
@PostMapping("/user/detail/export")
@ApiOperation("按部门+用户-明细统计导出")
public BizResponse<String> exportByOrgUserDetail(@RequestBody PracticeReportByUserReq po) {
po.setContext(ContextHolder.get());
String taskCode = statisticsPracticeByOrgClient.getUserDetailByOrgIdPageExport(po);
return BizResponse.ok(taskCode);
}
}
package com.yizhi.practice.application.controller.remote;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.yizhi.practice.application.pojo.vo.PracticeChatLogVo;
import com.yizhi.practice.application.pojo.vo.PracticeVisibleVo;
import com.yizhi.practice.application.pojo.vo.PracticeVo;
import com.yizhi.practice.application.xservice.PracticeChatLogXService;
import com.yizhi.practice.application.xservice.PracticeXservice;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
@Api(tags = "智能演练remote api")
@RestController
@Slf4j
public class PracticeControllerApi {
@Autowired
PracticeXservice practiceXservice;
@Autowired
private PracticeChatLogXService xservice;
private static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
private Date getStartDate(String startDate) throws ParseException {
log.info("Incoming param start date string:{}", startDate);
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
Date start = null;
if(StringUtils.isEmpty(startDate)) {
Date previousDay = com.yizhi.util.application.date.DateUtil.add(new Date(), Calendar.DAY_OF_MONTH, -1);
start = cn.hutool.core.date.DateUtil.beginOfDay(previousDay);
}else {
start = sdf.parse(startDate);
}
return start;
}
private Date getEndDate(String endDate) throws ParseException {
log.info("Incoming param end date string:{}", endDate);
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
Date end = null;
if(StringUtils.isEmpty(endDate)) {
Date previousDay = com.yizhi.util.application.date.DateUtil.add(new Date(), Calendar.DAY_OF_MONTH, -1);
end = cn.hutool.core.date.DateUtil.endOfDay(previousDay);
}else {
end = sdf.parse(endDate);
}
return end;
}
/**
* 查询指定时间范围内更新的陪练
*/
@ApiOperation(value = "查询指定时间范围内更新的陪练")
@GetMapping(path = "/remote/manage/practice/range/list")
public List<PracticeVo> selectRangeList(@RequestParam(name = "startDate",value="startDate",required=false)String startDate,
@RequestParam(name = "endDate",value="endDate",required=false)String endDate) {
List<PracticeVo> practiceVos = null;
try {
practiceVos = practiceXservice.selectRangeList(getStartDate(startDate), getEndDate(endDate));
} catch (ParseException e) {
log.error("Parse error", e);
}
return practiceVos;
}
/**
* 查询指定时间范围内更新的陪练可见范围
*/
@ApiOperation(value = "查询指定时间范围内更新的陪练可见范围")
@GetMapping(path = "/remote/manage/practice/visible/range/list")
public List<PracticeVisibleVo> selectVisibleRangeList(@RequestParam(name = "startDate",value="startDate",required=false) String startDate,
@RequestParam(name = "endDate",value="endDate",required=false) String endDate) {
List<PracticeVisibleVo> visibleVos= null;
try {
visibleVos = practiceXservice.selectVisibleRangeList(getStartDate(startDate), getEndDate(endDate));
} catch (ParseException e) {
log.error("Parse error", e);
}
return visibleVos;
}
/**
* 查询指定时间范围内更新的陪练记录
*/
@ApiOperation(value = "查询指定时间范围内更新的陪练记录")
@GetMapping(path = "/remote/manage/practice/chat/range/list")
public List<PracticeChatLogVo> selectChatLogRangeList(@RequestParam(name = "startDate",value="startDate",required=false) String startDate,
@RequestParam(name = "endDate",value="endDate",required=false) String endDate) {
List<PracticeChatLogVo> visibleVos= null;
try {
visibleVos = xservice.selectChatLogRangeList(getStartDate(startDate), getEndDate(endDate));
} catch (ParseException e) {
log.error("Parse error", e);
}
return visibleVos;
}
}
package com.yizhi.practice.application.controller.student;
import com.yizhi.core.application.enums.InternationalEnums;
import com.yizhi.practice.application.pojo.domain.PracticeConfig;
import com.yizhi.practice.application.pojo.vo.PracticeVo;
import com.yizhi.practice.application.repository.PracticeConfigRepository;
import com.yizhi.util.application.domain.BizResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@Api(tags = "智能演练-学员端-陪练")
@RequestMapping(path = "/student/practice")
@RestController
public class PracticeConfigStudentController {
@Autowired
private PracticeConfigRepository configRepository;
@ApiOperation(value = "获取陪练")
@GetMapping("/get")
public BizResponse<PracticeVo> getPractice(@ApiParam(value="陪练的ID") @RequestParam("practiceId") Long practiceId){
if (null == practiceId){
return BizResponse.fail(InternationalEnums.DROOLSMANAGERCONTROLLER1.getCode());
}
PracticeVo practiceVo = new PracticeVo();
PracticeConfig practiceConfig = configRepository.findById(practiceId).get();
if (null != practiceConfig){
BeanUtils.copyProperties(practiceConfig,practiceVo);
}
return BizResponse.ok(practiceVo);
}
}
package com.yizhi.practice.application.controller.student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.yizhi.practice.application.pojo.vo.PracticeChatLogBaseInfoVo;
import com.yizhi.practice.application.pojo.vo.PracticeChatLogListParamVo;
import com.yizhi.practice.application.pojo.vo.PracticeChatRoundLogDetailVo;
import com.yizhi.practice.application.pojo.vo.StudentPracticeLogVo;
import com.yizhi.practice.application.xservice.PracticeChatLogXService;
import com.yizhi.practice.application.xservice.PracticeChatRoundLogXService;
import com.yizhi.util.application.domain.BizResponse;
import com.yizhi.util.application.page.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@Api(tags = "智能演练-学员端-陪练记录")
@RequestMapping(path = "/student/practice/log")
@RestController
public class PracticeLogStudentController {
@Autowired
private PracticeChatLogXService xservice;
@Autowired
private PracticeChatRoundLogXService roundXservice;
@ApiOperation(value = "学员端-陪练记录-列表")
@PostMapping("/list")
public BizResponse<PageInfo<StudentPracticeLogVo>> list(@RequestBody PracticeChatLogListParamVo param){
return BizResponse.ok(xservice.studentList(param));
}
@ApiOperation(value = "答案解析")
@GetMapping("/analysis/get")
public BizResponse<PracticeChatRoundLogDetailVo> analysis(@ApiParam(value="某句对话的ID") @RequestParam("roundId")Long roundId){
return BizResponse.ok(roundXservice.analysis(roundId));
}
@ApiOperation(value = "陪练分析")
@GetMapping("/get")
public BizResponse<PracticeChatLogBaseInfoVo> baseInfo(@ApiParam(value="陪练记录的ID") @RequestParam("practiceLogId") Long practiceLogId){
return BizResponse.ok(roundXservice.getLogByPracticeChatId(practiceLogId));
}
}
package com.yizhi.practice.application.controller.student
import com.yizhi.core.application.context.ContextHolder
import com.yizhi.practice.application.pojo.po.AnalyzeStudentVoicePo
import com.yizhi.practice.application.pojo.po.StartPracticePO
import com.yizhi.practice.application.pojo.vo.*
import com.yizhi.practice.application.xservice.PracticeStuChatXService
import com.yizhi.util.application.domain.BizResponse
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import io.swagger.annotations.ApiParam
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.*
/**
* @Date 2020/10/26 3:54 下午
* @Author lvjianhui
**/
@Api(tags = ["开始陪练"])
@RestController
@RequestMapping(path = ["/student/chat"])
class PracticeStuSceneController {
@Autowired
lateinit var practiceStuChatXService: PracticeStuChatXService
@PostMapping("/start/practice/save")
@ApiOperation("陪练开始,新增一条陪练记录")
fun startPractice(@RequestBody startPracticePO: StartPracticePO): BizResponse<StuPracticeLogVo> {
startPracticePO.requestContext = ContextHolder.get()
val vo = practiceStuChatXService.startPractice(startPracticePO)
return BizResponse.ok(vo)
}
@GetMapping("/scene/list")
@ApiOperation("获取所有场景")
fun getAllScene(
@ApiParam("陪练ID")
@RequestParam("practiceId") practiceId: Long): BizResponse<List<SceneChatVO>> {
val list = practiceStuChatXService.getAllScene(practiceId)
return BizResponse.ok(list)
}
@GetMapping("/scene/first/list")
@ApiOperation("按顺序开始场景,返回机器人话术")
fun startChatByScene(
@ApiParam("场景ID")
@RequestParam("sceneId") sceneId: Long,
@ApiParam("陪练模式 模式 10:训练 20:考核", allowableValues = "10,20")
@RequestParam("useType") useType: Int,
@ApiParam("陪练ID")
@RequestParam("practiceId") practiceId: Long
): BizResponse<List<ChatContextVo>> {
val list = practiceStuChatXService.getRobotFirstChat(practiceId, sceneId, useType)
return BizResponse.ok(list)
}
@GetMapping("/context/student/list")
@ApiOperation("根据机器人话术,查询学员话术")
fun getStudentChatByRobot(
@ApiParam("场景ID")
@RequestParam("sceneId") sceneId: Long,
@ApiParam("陪练模式 模式 10:训练 20:考核", allowableValues = "10,20")
@RequestParam("useType") useType: Int,
@ApiParam("陪练ID")
@RequestParam("practiceId") practiceId: Long,
@ApiParam("机器人话术Id")
@RequestParam robotChatId: Long,
@ApiParam("陪练记录Id")
@RequestParam practiceLogId: Long
): BizResponse<List<StudentChatContextVo>> {
val list = practiceStuChatXService.getStudentContent(sceneId, useType, practiceId,practiceLogId, robotChatId)
return BizResponse.ok(list)
}
@PostMapping("/analyze/voice/save")
@ApiOperation("用户上传录音,返回结果")
fun analyzeStudentVoice(@RequestBody po: AnalyzeStudentVoicePo): BizResponse<ChatResultVo> {
po.requestContext = ContextHolder.get()
val vo = practiceStuChatXService.analyzeStudentVoice(po)
return BizResponse.ok(vo)
}
@GetMapping("/chat/log/delete")
fun deletedAccountUploadId(@RequestParam("accountUploadId") accountUploadId:Long):BizResponse<String> {
practiceStuChatXService.deletedAccountUploadId(accountUploadId,ContextHolder.get())
return BizResponse.ok()
}
@GetMapping("/robot/context/get")
@ApiOperation("根据学员话术返回机器人话术")
fun getRobotContext(@ApiParam("场景ID")
@RequestParam("sceneId") sceneId: Long,
@ApiParam("陪练模式 模式 10:训练 20:考核", allowableValues = "10,20")
@RequestParam("useType") useType: Int,
@ApiParam("陪练ID")
@RequestParam("practiceId") practiceId: Long,
@ApiParam("学员话术Id")
@RequestParam chatRoundConfigId: Long): BizResponse<List<ChatContextVo>> {
val vo = practiceStuChatXService.getRobotLevelChat(practiceId, sceneId, chatRoundConfigId, useType)
return BizResponse.ok(vo)
}
@GetMapping("/end/save")
fun endAccountPractice(@ApiParam("陪练模式 模式 10:训练 20:考核", allowableValues = "10,20")
@RequestParam("useType") useType: Int,
@ApiParam("陪练ID")
@RequestParam("practiceId") practiceId: Long,
@ApiParam("陪练记录ID")
@RequestParam("practiceLogId") practiceLogId: Long,
@ApiParam("异常退出 传true")
@RequestParam("errorEnd", defaultValue = "false") errorEnd: Boolean
): BizResponse<PracticeEndResultVo> {
val vo = practiceStuChatXService.endPractice(practiceId, practiceLogId, useType, ContextHolder.get(), errorEnd)
return BizResponse.ok(vo)
}
@GetMapping("/score/get")
fun getResultByLogResult(@ApiParam("陪练记录ID")
@RequestParam("practiceLogId") practiceLogId: Long):BizResponse<PracticeEndResultVo> {
val vo = practiceStuChatXService.getLogResult(practiceLogId,ContextHolder.get().accountId)
return BizResponse.ok(vo)
}
}
\ No newline at end of file
package com.yizhi.practice.application.controller.student
import com.yizhi.core.application.context.ContextHolder
import com.yizhi.core.application.context.RequestContext
import com.yizhi.practice.application.feign.MyPracticeStudentClient
import com.yizhi.practice.application.pojo.vo.PracticeConfigVo
import com.yizhi.practice.application.pojo.vo.PracticeJoinedVo
import com.yizhi.practice.application.xservice.PracticeStudentXSerice
import com.yizhi.util.application.domain.BizResponse
import com.yizhi.util.application.page.PageInfo
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.*
@RestController
@Api(tags = ["学员陪练"])
@RequestMapping(path = ["/student/practice"])
class PracticeStudentController : MyPracticeStudentClient {
@Autowired
lateinit var practiceStudentXSerice: PracticeStudentXSerice
// @ApiOperation("获取用户进行中的配练数")
@GetMapping("/running/count/get")
override fun getRuningPracticeCount(@RequestBody requestContext: RequestContext): BizResponse<Int> {
val count = practiceStudentXSerice.getRunningCount(
requestContext.accountId,
requestContext.orgId,
requestContext.siteId,
requestContext.companyId
)
return BizResponse.ok(count)
}
@ApiOperation(value = "校验用户是否有陪练可见权限")
@GetMapping("/user/auth")
override fun getUserPracticeAuth(@RequestBody requestContext: RequestContext
,@RequestParam("practiceId") practiceId: Long): BizResponse<Boolean> {
return practiceStudentXSerice.getUserPracticeAuth(requestContext,practiceId);
}
@GetMapping("/list/tab/index/get")
@ApiOperation("获取前端走哪个tab 0:未开始 1:进行中 2:已完成")
fun getAccountTab():BizResponse<Int> {
val requestContext = ContextHolder.get()
val index = practiceStudentXSerice.getTabIndex(requestContext)
return BizResponse.ok(index)
}
@GetMapping("/by/state/list")
@ApiOperation("根据状态获取陪练列表 40:进行中 10:未开始 80:已结束")
fun getRunningPracticeList(@RequestParam(defaultValue = "1") pageIndex: Int,
@RequestParam(defaultValue = "10") pageSize: Int,
@RequestParam(defaultValue = "40") state: Int): BizResponse<PageInfo<PracticeConfigVo>> {
val requestContext = ContextHolder.get()
val page = practiceStudentXSerice.getRunningList(
requestContext.accountId,
requestContext.orgId,
requestContext.siteId,
requestContext.companyId,
state,
pageIndex,
pageSize
)
return BizResponse.ok(page)
}
@GetMapping("/msg/by/id/list")
@ApiOperation("获取配练时间及次数信息")
fun getStartMsgById(
@RequestParam(name = "practiceId") practiceId: Long): BizResponse<PracticeConfigVo> {
val requestContext = ContextHolder.get()
val vo: PracticeConfigVo = practiceStudentXSerice.getPracticeInfo(
practiceId,
requestContext.accountId,
requestContext.orgId,
requestContext.siteId,
requestContext.companyId
)
return BizResponse.ok(vo)
}
@GetMapping("/joined/count")
fun getPracticeJoinEd(@RequestParam practiceId: Long):BizResponse<PracticeJoinedVo> {
val vo = practiceStudentXSerice.getPracticeJoined(practiceId, ContextHolder.get())
return BizResponse.ok(vo)
}
}
\ No newline at end of file
package com.yizhi.practice.application.excel;
import com.alibaba.fastjson.JSONObject;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.core.application.file.task.AbstractDefaultTask;
import com.yizhi.practice.application.enums.PracticeVisibleTypeEnum;
import com.yizhi.practice.application.pojo.domain.PracticeConfig;
import com.yizhi.practice.application.pojo.domain.PracticeVisible;
import com.yizhi.practice.application.repository.PracticeConfigRepository;
import com.yizhi.practice.application.repository.PracticeVisibleRepository;
import com.yizhi.system.application.model.AccountRangeExportParam;
import com.yizhi.system.application.system.remote.AccountRangeClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
@Component
public class PracticeAccountExport extends AbstractDefaultTask<String, PracticeAccountExportParam> {
private static final Logger logger = LoggerFactory.getLogger(PracticeAccountExport.class);
@Autowired
private AccountRangeClient accountRangeClient;
@Autowired
private PracticeVisibleRepository visibleRepository;
@Autowired
private PracticeConfigRepository practiceConfigRepository;
@Override
public String execute(PracticeAccountExportParam accountExportParam) {
RequestContext context = accountExportParam.getContext();
Long practiceId = accountExportParam.getPracticeId();
try {
AccountRangeExportParam accountRangeImportParam=new AccountRangeExportParam();
accountRangeImportParam.setContext(context);
PracticeConfig practice = practiceConfigRepository.findById(practiceId).get();
Integer practiceVisibleType = practice.getVisibleType();
List<Long> accountIds = new ArrayList<>();
List<Long> orgIds = new ArrayList<>();
if (PracticeVisibleTypeEnum.ALL.getStatus().equals(practiceVisibleType)){
return "";
}else if (PracticeVisibleTypeEnum.PART.getStatus().equals(practiceVisibleType)){
//指定用户可见
List<PracticeVisible> practiceVisibleList = visibleRepository.findByPracticeId(practiceId);
taskDetail(accountExportParam.getTaskId(),"智能陪练导出用户可见范围:查询可见范围成功;practiceId="+practiceId);
if (null != practiceVisibleList && practiceVisibleList.size() > 0){
for (PracticeVisible practiceVisible : practiceVisibleList) {
Integer visibleType = practiceVisible.getVisibleType();
if (PracticeVisibleTypeEnum.PART.getStatus().equals(visibleType)){
accountIds.add(practiceVisible.getVisibleAccountId());
}
else if (PracticeVisibleTypeEnum.ORG.getStatus().equals(visibleType)){
orgIds.add(practiceVisible.getVisibleOrgId());
}
}
accountRangeImportParam.setAccountIds(accountIds);
accountRangeImportParam.setOrgIds(orgIds);
taskDetail(accountExportParam.getTaskId(),"智能陪练导出用户可见范围:获取到可见范围accountIdsSize="+accountIds.size()+",orgIdsSize="+orgIds.size());
}
}
accountRangeImportParam.setBizName(practice.getName());
logger.info("智能陪练-[PracticeAccountExport:execute]导出可见范围参数: {}", JSONObject.toJSONString(accountRangeImportParam));
taskDetail(accountExportParam.getTaskId(),"智能陪练导出用户可见范围:调用system导出可见范围入参="+JSONObject.toJSONString(accountRangeImportParam));
String serialNo=accountRangeClient.doExport(accountRangeImportParam);
logger.info("智能陪练-[PracticeAccountExport:execute]导出可见范围返回结果: {}",serialNo);
return serialNo;
}catch (Exception e){
logger.error("智能陪练可见范围导出异常;",e);
}
return null;
}
}
package com.yizhi.practice.application.excel;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.core.application.context.TaskContext;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class PracticeAccountExportParam {
@ApiModelProperty(value = "RequestContext")
private RequestContext context;
@ApiModelProperty(value = "陪练id")
private Long practiceId;
@ApiModelProperty(value = "任务id")
private Long taskId;
@ApiModelProperty(value = "序列号")
private String serialNo;
@ApiModelProperty(value = "任务名")
private String taskName;
private TaskContext taskContext;
}
package com.yizhi.practice.application.excel;
import com.alibaba.fastjson.JSONObject;
import com.yizhi.application.orm.id.IdGenerator;
import com.yizhi.core.application.context.ContextHolder;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.core.application.context.TaskContext;
import com.yizhi.core.application.event.LogEvent;
import com.yizhi.core.application.file.task.AbstractDefaultTask;
import com.yizhi.core.application.log.LogEventPublisher;
import com.yizhi.core.application.log.TaskLogDetailEvent;
import com.yizhi.core.application.log.TaskLogEvent;
import com.yizhi.practice.application.enums.PracticeVisibleTypeEnum;
import com.yizhi.practice.application.request.PracticeAccountReq;
import com.yizhi.practice.application.request.PracticeVisibleAccount;
import com.yizhi.practice.application.xservice.PracticeXservice;
import com.yizhi.system.application.model.AccountRangeImportModel;
import com.yizhi.system.application.model.AccountRangeImportParam;
import com.yizhi.system.application.system.remote.AccountClient;
import com.yizhi.system.application.system.remote.AccountRangeClient;
import com.yizhi.system.application.vo.AccountVO;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Component
public class PracticeAccountImport extends AbstractDefaultTask<String, PracticeAccountImportParam> {
private static final Logger logger = LoggerFactory.getLogger(PracticeAccountImport.class);
@Autowired
private AccountRangeClient accountRangeClient;
@Autowired
IdGenerator idGenerator;
@Autowired
AccountClient accountClient;
@Autowired
PracticeXservice practiceXservice;
@Autowired
LogEventPublisher publisher;
@Override
protected String execute(PracticeAccountImportParam accountImportParam) {
String ossUrl = accountImportParam.getFileUrl();
RequestContext context = accountImportParam.getContext();
ContextHolder.set(context);
Long accountId = context.getAccountId();
TaskContext taskContext = new TaskContext(accountImportParam.getTaskId(), accountImportParam.getSerialNo()
, accountImportParam.getTaskName(), accountId, new Date(), context.getSiteId(), context.getCompanyId());
working(taskContext);
AccountRangeImportParam param = new AccountRangeImportParam();
param.setType(AccountRangeImportParam.Type.PRACTICE);
param.setOssUrl(ossUrl);
param.setRequestContext(context);
List<AccountRangeImportModel.SuccessAccount> successList = new ArrayList<>();
List<AccountRangeImportModel.ErrorAccount> errorList = new ArrayList<>();
//进行入库
try {
logger.info("智能演练导入用户可见范围:[AccountRangeClient.doImport]入参: {}",JSONObject.toJSONString(param));
AccountRangeImportModel accountRangeImportModel = accountRangeClient.doImport(param);
if (null == accountRangeImportModel) {
logger.error("智能演练导入用户可见范围:[AccountRangeClient.doImport]出参is null");
logEventPublish(taskContext,successList,errorList,null);
return null;
}
if (null != accountRangeImportModel) {
logger.info("智能演练导入用户可见范围,[AccountRangeClient.doImport]出参: {}", JSONObject.toJSONString(accountRangeImportModel));
successList = accountRangeImportModel.getSuccessList();
errorList = accountRangeImportModel.getErrorList();
}
PracticeAccountReq practiceAccountReq = new PracticeAccountReq();
practiceAccountReq.setPracticeId(accountImportParam.getPracticeId());
List<PracticeVisibleAccount> accountList = new ArrayList<>();
for (AccountRangeImportModel.SuccessAccount successAccount : successList) {
PracticeVisibleAccount visibleAccount = new PracticeVisibleAccount();
Long id = successAccount.getId();
AccountVO accountVO = accountClient.findById(id);
visibleAccount.setName(accountVO.getName());
visibleAccount.setFullName(accountVO.getFullName());
visibleAccount.setWorkNum(accountVO.getWorkNum());
visibleAccount.setVisibleId(id);
visibleAccount.setVisibleType(PracticeVisibleTypeEnum.PART.getStatus());
accountList.add(visibleAccount);
}
practiceAccountReq.setAccountList(accountList);
practiceXservice.addPracticeAccount(practiceAccountReq);
logEventPublish(taskContext,successList,errorList,null);
} catch (Exception e) {
fail(taskContext, "智能陪练可见范围异步导入过程中出现错误");
logger.error("智能陪练可见范围异步导入过程中出现错误.", e);
}
return "ok";
}
public void logEventPublish(TaskContext taskContext, List<AccountRangeImportModel.SuccessAccount> successList,
List<AccountRangeImportModel.ErrorAccount> errorList, String url) {
TaskLogEvent taskLogEvent = TaskLogEvent.success(taskContext, "成功导入" + successList.size() + "条," + "导入失败" + errorList.size() + "条", url);
LogEvent<TaskLogEvent> event = new LogEvent("taskLog", taskLogEvent);
this.publisher.publish(event);
if (CollectionUtils.isNotEmpty(errorList)) {
List<TaskLogDetailEvent> details = new ArrayList(errorList.size());
Long taskId = taskContext.getTaskId();
for (AccountRangeImportModel.ErrorAccount a : errorList) {
details.add(new TaskLogDetailEvent(taskId, "第"+a.getLine()+"行,"+a.getErrMsg()));
}
LogEvent<List<TaskLogDetailEvent>> eventDetails = new LogEvent("batchTaskDetailLog", details);
this.publisher.publish(eventDetails);
}
}
}
package com.yizhi.practice.application.excel;
import com.yizhi.core.application.context.RequestContext;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class PracticeAccountImportParam {
@ApiModelProperty(value = "文件路径")
private String fileUrl;
@ApiModelProperty(value = "RequestContext")
private RequestContext context;
@ApiModelProperty(value = "陪练id")
private Long practiceId;
@ApiModelProperty(value = "任务id")
private Long taskId;
@ApiModelProperty(value = "序列号")
private String serialNo;
@ApiModelProperty(value = "任务名")
private String taskName;
}
package com.yizhi.practice.application.excel;
import com.alibaba.fastjson.JSONObject;
import com.yizhi.core.application.file.domain.Template;
import com.yizhi.core.application.file.util.ProxyCreateUtil;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.Proxy;
import java.net.URL;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
/**
* excel 导入 包含合并单元格
*/
@Component
public class PracticeExcelImporter {
private static Integer httpProxyPort;
private static String httpProxyUrl;
private static final Logger logger = LoggerFactory.getLogger(PracticeExcelImporter.class);
public List<List<String>> parse(String fileUrl,Template template) {
//
InputStream inputStream = this.read(fileUrl);
int columnCount = template.getColumns().size();
Workbook book = null;
try {
book = WorkbookFactory.create(inputStream);
} catch (Exception e) {
logger.error("[PracticeExcelImporter : parse] excel文件读取发生错误",e);
throw new RuntimeException("excel文件读取发生错误");
}
List<List<String>> lines = new ArrayList<>();
Sheet sheet = book.getSheetAt(0);
for (int i = template.getStartLine() - 1; i <= sheet.getLastRowNum(); i++) {
List<String> rowValues = new ArrayList<>();
Row row ;
for (int j = 0; j < columnCount; j++) {
String cellValue = "";
boolean mergedRegion = isMergedRegion(sheet, i, j);
if (mergedRegion){
//合并单元格方式获取整行数据
cellValue = getMergedRegionValue(sheet, i, j);
}else {
row = sheet.getRow(i);
Cell cell = row.getCell(j);
if (null != cell){
cellValue = getCellValue(cell);
}
}
rowValues.add(cellValue);
}
lines.add(rowValues);
}
logger.info("导入场景对话数据解析: {}",JSONObject.toJSONString(lines));
return lines;
}
private InputStream read(String fileUrl) {
HttpURLConnection conn = null;
try {
URL url = new URL(fileUrl);
Proxy proxy = ProxyCreateUtil.createUrlProxy(httpProxyUrl, httpProxyPort);
if (proxy != null) {
conn = (HttpURLConnection)url.openConnection(proxy);
} else {
conn = (HttpURLConnection)url.openConnection();
}
conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
InputStream inputStream = conn.getInputStream();
return inputStream;
} catch (Exception var7) {
logger.error("文件解析失败", var7);
}
return null;
}
/**
* 判断指定的单元格是否是合并单元格
* @param sheet
* @param row 行下标
* @param column 列下标
* @return
*/
private boolean isMergedRegion(Sheet sheet,int row ,int column) {
int sheetMergeCount = sheet.getNumMergedRegions();
for (int i = 0; i < sheetMergeCount; i++) {
CellRangeAddress range = sheet.getMergedRegion(i);
int firstColumn = range.getFirstColumn();
int lastColumn = range.getLastColumn();
int firstRow = range.getFirstRow();
int lastRow = range.getLastRow();
if(row >= firstRow && row <= lastRow){
if(column >= firstColumn && column <= lastColumn){
return true;
}
}
}
return false;
}
/**
* 获取合并单元格的值
*/
public String getMergedRegionValue(Sheet sheet ,int row , int column){
int sheetMergeCount = sheet.getNumMergedRegions();
for(int i = 0 ; i < sheetMergeCount ; i++){
CellRangeAddress ca = sheet.getMergedRegion(i);
int firstColumn = ca.getFirstColumn();
int lastColumn = ca.getLastColumn();
int firstRow = ca.getFirstRow();
int lastRow = ca.getLastRow();
if(row >= firstRow && row <= lastRow){
if(column >= firstColumn && column <= lastColumn){
Row fRow = sheet.getRow(firstRow);
Cell fCell = fRow.getCell(firstColumn);
return getCellValue(fCell) ;
}
}
}
return null ;
}
/**
* 获取单元格的值
*/
public String getCellValue(Cell cell){
CellType cellType = cell.getCellTypeEnum();
String cellValue;
switch (cellType){
case STRING:
cellValue = cell.getStringCellValue();
break;
case BOOLEAN:
cellValue = String.valueOf(cell.getBooleanCellValue());
break;
case FORMULA:
cellValue = String.valueOf(cell.getCellFormula());
break;
case NUMERIC:
cellValue = getDataCellValue(cell);
break;
case ERROR:
cellValue = "非法字符";
break;
default:
cellValue = "";
}
return cellValue;
}
/**获取数值类型单元格的值*/
private String getDataCellValue(Cell cell){
String cellStr = "";
String formatType = cell.getCellStyle().getDataFormatString();
if (formatType.indexOf("%") != -1) {// 判断如果含百分号,则认为百分数类型
int baifenshuxiaoshuwei = 0;
if(formatType.indexOf(".")!=-1) { // 判断包含小数点
baifenshuxiaoshuwei = formatType.substring(formatType.indexOf("."), formatType.indexOf("%")).length()-1; // 获取小数位数
cellStr = "#.";
for(int weishu=0;weishu<baifenshuxiaoshuwei;weishu++) {
cellStr += "0";
}
cellStr = new DecimalFormat(cellStr).format(cell.getNumericCellValue()*100) + "%"; // 保留对应位数百分号
if(cellStr.startsWith(".")) {// 如果以.开头的,前面加0拼接;
cellStr = "0" + cellStr;
}
}else {
// 不含小数点,直接四舍五入整数;
cellStr = Math.round(cell.getNumericCellValue()*100)+"%";
}
}else {
cell.setCellType(CellType.STRING);
cellStr = cell.getStringCellValue();
}
return cellStr;
}
/*public static void main(String[] args) throws FileNotFoundException {
PracticeExcelImporter importer = new PracticeExcelImporter();
Template template = new Template();
List<TemplateColumn> columns = new ArrayList<>();
columns.add(new TemplateColumn("order","序列号",1));
columns.add(new TemplateColumn("robotNode","机器人节点话术(必填)",2));
columns.add(new TemplateColumn("studentNode","学员节点话术(必填)",3));
columns.add(new TemplateColumn("keyword","关键词(必填)",4));
columns.add(new TemplateColumn("extendWord","扩展词(非必填)",5));
columns.add(new TemplateColumn("tabooWord","禁忌词",6));
template.setColumns(columns);
RequestContext context = new RequestContext();
context.setAccountId(1314L);
context.setSiteId(1314L);
context.setCompanyId(1314L);
context.setSiteCode("shyz");
context.setOrgId(1314L);
String fileUrl = "D:\\bugdoc\\岗前培训对话脚本导入已审核1105\\促成对话导入脚本.xlsx";
InputStream inputStream = new FileInputStream(fileUrl);
int columnCount = template.getColumns().size();
Workbook book = null;
try {
book = WorkbookFactory.create(inputStream);
} catch (Exception e) {
logger.error("[PracticeExcelImporter : parse] excel文件读取发生错误",e);
throw new RuntimeException("excel文件读取发生错误");
}
List<List<String>> lines = new ArrayList<>();
Sheet sheet = book.getSheetAt(0);
for (int i = template.getStartLine() - 1; i <= sheet.getLastRowNum(); i++) {
List<String> rowValues = new ArrayList<>();
Row row ;
for (int j = 0; j < columnCount; j++) {
String cellValue = "";
boolean mergedRegion = importer.isMergedRegion(sheet, i, j);
if (mergedRegion){
//合并单元格方式获取整行数据
cellValue = importer.getMergedRegionValue(sheet, i, j);
}else {
row = sheet.getRow(i);
Cell cell = row.getCell(j);
if (null != cell){
cellValue = importer.getCellValue(cell);
}
}
rowValues.add(cellValue);
}
lines.add(rowValues);
}
logger.info("导入场景对话数据解析: {}",JSONObject.toJSONString(lines));
}*/
}
package com.yizhi.practice.application.excel;
import com.yizhi.core.application.file.imp.ImportCallBack;
import com.yizhi.core.application.task.TaskHandler;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* 导入智能陪练场景对话callback
*/
@Component
public class PracticeImportSceneChatCallBack implements ImportCallBack {
@Override
public Boolean exec(TaskHandler taskHandler, List dataObjs) {
// TODO: 2020/11/2 导入对话
System.out.println(dataObjs);
return null;
}
}
package com.yizhi.practice.application.excel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
@ApiModel(value = "场景对话导入模板")
public class PracticeSceneChatImport implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "对话序列号")
private String order;
@ApiModelProperty(value = "机器人节点话术(必填)")
private String robotNode;
@ApiModelProperty(value = "学员节点话术(必填)")
private String studentNode;
@ApiModelProperty(value = "关键词(必填)")
private List<String> keyword;
@ApiModelProperty(value = "扩展词(非必填)")
private List<String> extendWord;
@ApiModelProperty(value = "禁忌词;多个用分号分隔(非必填)")
private String tabooWord;
}
package com.yizhi.practice.application.exception
import com.yizhi.core.application.exception.BizException
import com.yizhi.practice.application.exception.RequestParameter.ERROR_CODE
import com.yizhi.practice.application.exception.RequestParameter.EXCEPTION
import com.yizhi.util.application.domain.BizResponse
import com.yizhi.util.application.enums.i18n.Constants
import org.slf4j.LoggerFactory
import org.springframework.messaging.handler.annotation.support.MethodArgumentNotValidException
import org.springframework.validation.BeanPropertyBindingResult
import org.springframework.web.HttpRequestMethodNotSupportedException
import org.springframework.web.bind.annotation.ControllerAdvice
import org.springframework.web.bind.annotation.ExceptionHandler
import org.springframework.web.bind.annotation.ResponseBody
import javax.servlet.http.HttpServletRequest
/**
* @Author: Lvjh
* @Date 2020/02/19 18:32
*/
@ControllerAdvice
open class ApiResponseHandler {
private val logger = LoggerFactory.getLogger(javaClass)
@ExceptionHandler(HttpRequestMethodNotSupportedException::class)
@ResponseBody
fun requestMethodNotSupportException(e: HttpRequestMethodNotSupportedException, request: HttpServletRequest): BizResponse<Any> {
logger.error(" requestMethodNotSupportException uri[${request.requestURI}]", e)
return BizResponse.fail(Constants.MSG_BIZ_FAIL.code.toString(), Constants.MSG_BIZ_FAIL.name)
}
@ExceptionHandler(MethodArgumentNotValidException::class)
@ResponseBody
fun parameterInvalidException(e: MethodArgumentNotValidException, request: HttpServletRequest): BizResponse<Any> {
logger.error(" parameterInvalidException uri[${request.requestURI}]", e)
var msg = Constants.MSG_BIZ_FAIL.name
try {
val propertyBindResult: BeanPropertyBindingResult = e.bindingResult as BeanPropertyBindingResult
if (propertyBindResult.hasErrors()) {
val sbf = StringBuffer()
propertyBindResult.allErrors.forEach {
sbf.append(it.defaultMessage).append(";")
}
msg = sbf.toString()
}
return BizResponse.fail(Constants.MSG_BIZ_FAIL.code.toString(), msg)
} catch (e: Exception) {
logger.error(" parameterInvalidException url[${request.requestURL}]", e)
e.printStackTrace()
return BizResponse.fail(Constants.MSG_BIZ_FAIL.code.toString(), Constants.MSG_BIZ_FAIL.name)
}
}
@ExceptionHandler(Exception::class)
@ResponseBody
fun sysException(e: Exception, request: HttpServletRequest): BizResponse<Any> {
request.setAttribute(EXCEPTION, getStackTrace(e))
request.setAttribute(ERROR_CODE, Constants.MSG_BIZ_FAIL.code.toString())
val clientIp = request.getHeader("X-Real-IP")
logger.error("Exception requestUrl[${request.requestURI},clientIp:$clientIp] ", e)
e.printStackTrace()
return BizResponse.fail(Constants.MSG_BIZ_FAIL.code.toString(), Constants.MSG_BIZ_FAIL.name)
}
@ExceptionHandler(BizException::class)
@ResponseBody
fun bizException(e: BizException, request: HttpServletRequest): BizResponse<Any> {
request.setAttribute(ERROR_CODE, e.code)
request.setAttribute(EXCEPTION, getStackTrace(e))
logger.error("BizException requestUrl[${request.requestURL}] ${e.code}:${e.msg}")
return BizResponse.fail(e.code, e.msg)
}
private fun getStackTrace(e: Exception): String {
val stringBuffer = StringBuffer(e.toString() + "\n")
val messages = e.stackTrace
messages.forEach {
stringBuffer.append("\t $it \n")
}
return stringBuffer.toString()
}
}
\ No newline at end of file
//package com.yizhi.practice.application.exception;
//
//import com.yizhi.core.application.enums.InternationalEnums;
//import lombok.Data;
//import org.apache.poi.ss.formula.functions.T;
//
///**
// * 陪练业务异常类
// */
//@Data
//public class PracBusinessException extends RuntimeException{
//
// private String errCode;
// private String errMsg;
// private InternationalEnums enums;
// private T data;
//
// /**
// * Constructs a new runtime exception with {@code null} as its
// * detail message. The cause is not initialized, and may subsequently be
// * initialized by a call to {@link #initCause}.
// */
// public PracBusinessException() {
// }
//
// /**
// * Constructs a new runtime exception with the specified detail message.
// * The cause is not initialized, and may subsequently be initialized by a
// * call to {@link #initCause}.
// *
// */
// public PracBusinessException(String errCode, String errMsg) {
// this.errCode = errCode;
// this.errMsg = errMsg;
// }
//
//
// /**
// * Constructs a new runtime exception with {@code null} as its
// * detail message. The cause is not initialized, and may subsequently be
// * initialized by a call to {@link #initCause}.
// */
// public PracBusinessException(InternationalEnums enums) {
// this.errCode = enums.getCode();
// this.errMsg = enums.getName();
// }
//
// /**
// * Constructs a new runtime exception with {@code null} as its
// * detail message. The cause is not initialized, and may subsequently be
// * initialized by a call to {@link #initCause}.
// */
// public PracBusinessException(InternationalEnums enums, T data) {
// this.errCode = enums.getCode();
// this.errMsg = enums.getName();
// this.data = data;
// }
//
// /**
// * Constructs a new runtime exception with {@code null} as its
// * detail message. The cause is not initialized, and may subsequently be
// * initialized by a call to {@link #initCause}.
// */
// public PracBusinessException(String errCode, String errMsg, T data) {
// this.errCode = errCode;
// this.errMsg = errMsg;
// this.data = data;
// }
//}
package com.yizhi.practice.application.exception
/**
* @Author: Lvjh
* @Date 2020/02/19 18:32
*/
object RequestParameter {
const val CUSTOMER_MOBILE = "customer_mobile"
const val CUSTOMER_ID = "customer_id"
const val REQUEST_UUID = "request_uuid"
const val VERSION = "version"
const val PLATFORM = "channel_code"
const val DEVICE_UUID = "device_uuid"
const val TIMESTAMP = "timestamp"
const val EXCEPTION = "exception"
const val ERROR_CODE = "error_code"
const val TIME_ZONE = "user_timezone"
}
\ No newline at end of file
package com.yizhi.practice.application.mapper;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.yizhi.practice.application.pojo.domain.PracticeChatRoundLog;
import com.yizhi.practice.application.pojo.dto.PracticeLogScoreDto;
import org.apache.ibatis.annotations.Param;
/**
* @Date 2020/11/24 7:11 下午
* @Author lvjianhui
**/
public interface PracticeChatRoundLogMapper extends BaseMapper<PracticeChatRoundLog> {
public PracticeLogScoreDto getScoreByAccount(@Param(value = "practiceChatId") Long practiceChatId,
@Param(value = "accountId") Long accountId,
@Param(value = "orgId") Long orgId,
@Param(value = "siteId") Long siteId,
@Param(value = "companyId") Long companyId);
}
<?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.yizhi.practice.application.mapper.PracticeChatRoundLogMapper">
<select id="getScoreByAccount" resultType="com.yizhi.practice.application.pojo.dto.PracticeLogScoreDto">
<!-- 每轮多次提及的取最后一次提交计算得分。
如果该轮最后为跳过,则该轮所有提交不进行得分计算-->
select
avg(a.average_score) as averageScore,
avg(a.keyword_score) as keywordScore,
avg(a.complete_score) as complateScore,
avg(a.smooth_score) as fluencyScore,
avg(a.polite_score) as politeScore,
avg(a.express_score) as expressScore
from practice_chat_round_log a inner join (
select
max(created_at) as created_at,
min(round_skip_type) as minskipType
from practice_chat_round_log
where
practice_chat_id = #{practiceChatId}
and account_id = #{accountId}
and company_id = #{companyId}
and site_id = #{siteId}
and org_id = #{orgId}
and round_skip_type is not null
and deleted = 0
group by round_level
) b
on a.created_at = b.created_at
where a.practice_chat_id = #{practiceChatId}
and a.round_skip_type = 80
and a.account_id = #{accountId}
and a.company_id = #{companyId}
and a.site_id = #{siteId}
and a.org_id = #{orgId}
and a.deleted = 0
and b.minSkipType = 80
order by a.scene_id,a.round_level
</select>
</mapper>
\ No newline at end of file
package com.yizhi.practice.application.pojo.domain;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableName;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import javax.persistence.Entity;
import javax.persistence.Id;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
* 场景对话结果记录
* </p>
*
* @author MybatisCodeGenerator123
* @since 2020-10-30
*/
@DynamicUpdate
@DynamicInsert
@Api(tags = "PracticeChatLog", description = "场景对话结果记录")
@TableName("practice_chat_log")
@Entity
public class PracticeChatLog implements Serializable {
private static final long serialVersionUID = 1L;
@Id
private Long id;
@ApiModelProperty(value = "陪练ID")
@TableField("practice_id")
private Long practiceId;
@ApiModelProperty(value = "用户ID")
@TableField("account_id")
private Long accountId;
@ApiModelProperty(value = "用户名")
@TableField("account_name")
private String accountName;
@ApiModelProperty(value = "用户姓名")
@TableField("account_full_name")
private String accountFullName;
@ApiModelProperty(value = "10:训练 20:考核")
@TableField("use_type")
private Integer useType;
@ApiModelProperty(value = "部门名")
@TableField("org_name")
private String orgName;
@ApiModelProperty(value = "陪练级别 10:初级 40:中级 80:高级")
private Integer level;
@ApiModelProperty(value = "陪练状态 40:陪练中 80:陪练正常结束 90:陪练中途退出")
private Integer status;
@ApiModelProperty(value = "陪练开始时间")
@TableField("start_at")
private Date startAt;
@ApiModelProperty(value = "陪练结束时间")
@TableField("end_at")
private Date endAt;
@ApiModelProperty(value = "通过考核最低分")
@TableField("pass_min_score")
private Integer passMinScore;
@ApiModelProperty(value = "是否发放积分 80 发放,10不发放")
@TableField("given_point_type")
private Integer givenPointType;
@ApiModelProperty(value = "发放积分数量")
@TableField("given_point_count")
private Integer givenPointCount;
@ApiModelProperty(value = "得分")
@TableField("average_score")
private Integer averageScore;
@ApiModelProperty(value = "80:通过,10:未通过")
@TableField("pass_result")
private Integer passResult;
@ApiModelProperty(value = "关键词得分")
@TableField("keyword_score")
private Integer keywordScore;
@ApiModelProperty(value = "关键词 完成度 单位%")
@TableField("keyword_rate")
private Integer keywordRate;
@ApiModelProperty(value = "完整性得分")
@TableField("complete_score")
private Integer completeScore;
@ApiModelProperty(value = "完整性 完成度 单位%")
@TableField("complete_rate")
private Integer completeRate;
@ApiModelProperty(value = "流畅性得分")
@TableField("smooth_score")
private Integer smoothScore;
@ApiModelProperty(value = "流畅性 完整度 单位%")
@TableField("smooth_rate")
private Integer smoothRate;
@ApiModelProperty(value = "表达能力得分")
@TableField("express_score")
private Integer expressScore;
@ApiModelProperty(value = "表达能力 完成度 单位%")
@TableField("express_rate")
private Integer expressRate;
@ApiModelProperty(value = "礼貌用语得分")
@TableField("polite_score")
private Integer politeScore;
@ApiModelProperty(value = "礼貌用语 完成度 单位%")
@TableField("polite_rate")
private Integer politeRate;
@ApiModelProperty(value = "0: not deledted 1:deleted")
private Boolean deleted;
@TableField("org_id")
private Long orgId;
@TableField("site_id")
private Long siteId;
@TableField("company_id")
private Long companyId;
@TableField("created_at")
private Date createdAt;
@TableField("updated_at")
private Date updatedAt;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getPracticeId() {
return practiceId;
}
public void setPracticeId(Long practiceId) {
this.practiceId = practiceId;
}
public Long getAccountId() {
return accountId;
}
public void setAccountId(Long accountId) {
this.accountId = accountId;
}
public String getAccountName() {
return accountName;
}
public void setAccountName(String accountName) {
this.accountName = accountName;
}
public String getAccountFullName() {
return accountFullName;
}
public void setAccountFullName(String accountFullName) {
this.accountFullName = accountFullName;
}
public Integer getUseType() {
return useType;
}
public void setUseType(Integer useType) {
this.useType = useType;
}
public String getOrgName() {
return orgName;
}
public void setOrgName(String orgName) {
this.orgName = orgName;
}
public Integer getLevel() {
return level;
}
public void setLevel(Integer level) {
this.level = level;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Date getStartAt() {
return startAt;
}
public void setStartAt(Date startAt) {
this.startAt = startAt;
}
public Date getEndAt() {
return endAt;
}
public void setEndAt(Date endAt) {
this.endAt = endAt;
}
public Integer getPassMinScore() {
return passMinScore;
}
public void setPassMinScore(Integer passMinScore) {
this.passMinScore = passMinScore;
}
public Integer getGivenPointType() {
return givenPointType;
}
public void setGivenPointType(Integer givenPointType) {
this.givenPointType = givenPointType;
}
public Integer getAverageScore() {
return averageScore;
}
public void setAverageScore(Integer averageScore) {
this.averageScore = averageScore;
}
public Integer getPassResult() {
return passResult;
}
public void setPassResult(Integer passResult) {
this.passResult = passResult;
}
public Integer getKeywordScore() {
return keywordScore;
}
public void setKeywordScore(Integer keywordScore) {
this.keywordScore = keywordScore;
}
public Integer getKeywordRate() {
return keywordRate;
}
public void setKeywordRate(Integer keywordRate) {
this.keywordRate = keywordRate;
}
public Integer getCompleteScore() {
return completeScore;
}
public void setCompleteScore(Integer completeScore) {
this.completeScore = completeScore;
}
public Integer getCompleteRate() {
return completeRate;
}
public void setCompleteRate(Integer completeRate) {
this.completeRate = completeRate;
}
public Integer getSmoothScore() {
return smoothScore;
}
public void setSmoothScore(Integer smoothScore) {
this.smoothScore = smoothScore;
}
public Integer getSmoothRate() {
return smoothRate;
}
public void setSmoothRate(Integer smoothRate) {
this.smoothRate = smoothRate;
}
public Integer getExpressScore() {
return expressScore;
}
public void setExpressScore(Integer expressScore) {
this.expressScore = expressScore;
}
public Integer getExpressRate() {
return expressRate;
}
public void setExpressRate(Integer expressRate) {
this.expressRate = expressRate;
}
public Integer getPoliteScore() {
return politeScore;
}
public void setPoliteScore(Integer politeScore) {
this.politeScore = politeScore;
}
public Integer getPoliteRate() {
return politeRate;
}
public void setPoliteRate(Integer politeRate) {
this.politeRate = politeRate;
}
public Boolean getDeleted() {
return deleted;
}
public void setDeleted(Boolean deleted) {
this.deleted = deleted;
}
public Long getOrgId() {
return orgId;
}
public void setOrgId(Long orgId) {
this.orgId = orgId;
}
public Long getSiteId() {
return siteId;
}
public void setSiteId(Long siteId) {
this.siteId = siteId;
}
public Long getCompanyId() {
return companyId;
}
public void setCompanyId(Long companyId) {
this.companyId = companyId;
}
public Date getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}
public Date getUpdatedAt() {
return updatedAt;
}
public void setUpdatedAt(Date updatedAt) {
this.updatedAt = updatedAt;
}
public Integer getGivenPointCount() {
return givenPointCount;
}
public void setGivenPointCount(Integer givenPointCount) {
this.givenPointCount = givenPointCount;
}
@Override
public String toString() {
return "PracticeChatLog{" +
", id=" + id +
", practiceId=" + practiceId +
", accountId=" + accountId +
", accountName=" + accountName +
", accountFullName=" + accountFullName +
", useType=" + useType +
", orgName=" + orgName +
", level=" + level +
", status=" + status +
", startAt=" + startAt +
", endAt=" + endAt +
", passMinScore=" + passMinScore +
", givenPointType=" + givenPointType +
", averageScore=" + averageScore +
", passResult=" + passResult +
", keywordScore=" + keywordScore +
", keywordRate=" + keywordRate +
", completeScore=" + completeScore +
", completeRate=" + completeRate +
", smoothScore=" + smoothScore +
", smoothRate=" + smoothRate +
", expressScore=" + expressScore +
", expressRate=" + expressRate +
", politeScore=" + politeScore +
", politeRate=" + politeRate +
", deleted=" + deleted +
", orgId=" + orgId +
", siteId=" + siteId +
", companyId=" + companyId +
", createdAt=" + createdAt +
", updatedAt=" + updatedAt +
"}";
}
}
This diff is collapsed. Click to expand it.
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