61 changed files with 2895 additions and 617 deletions
@ -0,0 +1,47 @@ |
|||
package com.ccsens.yanyuan.api; |
|||
|
|||
import com.ccsens.cloudutil.annotation.MustLogin; |
|||
import com.ccsens.util.JsonResponse; |
|||
import com.ccsens.util.bean.dto.QueryDto; |
|||
import com.ccsens.yanyuan.bean.dto.MentalTestDto; |
|||
import com.ccsens.yanyuan.bean.dto.QuestionDto; |
|||
import com.ccsens.yanyuan.bean.vo.MentalTestVo; |
|||
import com.ccsens.yanyuan.bean.vo.QuestionVo; |
|||
import com.ccsens.yanyuan.service.IMentalTestService; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import io.swagger.annotations.ApiParam; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.validation.annotation.Validated; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestMethod; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import javax.annotation.Resource; |
|||
|
|||
/** |
|||
* @description: |
|||
* @author: whj |
|||
* @time: 2021/11/10 16:37 |
|||
*/ |
|||
@Api(tags = "脑力测评" ) |
|||
@Slf4j |
|||
@RestController |
|||
@RequestMapping(value = "/mentalTest") |
|||
public class MentalTestController { |
|||
|
|||
@Resource |
|||
private IMentalTestService mentalTestService; |
|||
|
|||
@MustLogin |
|||
@ApiOperation(value = "脑力测评结果计算", notes = "脑力测评结果计算") |
|||
@RequestMapping(value = "/calculate", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) |
|||
public JsonResponse<MentalTestVo.Result> calculate(@ApiParam @Validated @RequestBody QueryDto<MentalTestDto.Id> params) throws Exception{ |
|||
log.info("脑力测评结果计算:{}",params); |
|||
MentalTestVo.Result message = mentalTestService.calculate(params.getParam(), params.getUserId()); |
|||
log.info("脑力测评结果计算结束{}", message); |
|||
return JsonResponse.newInstance().ok(message); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,56 @@ |
|||
package com.ccsens.yanyuan.api; |
|||
|
|||
import com.ccsens.cloudutil.annotation.MustLogin; |
|||
import com.ccsens.util.JsonResponse; |
|||
import com.ccsens.util.bean.dto.QueryDto; |
|||
import com.ccsens.yanyuan.bean.dto.QuestionDto; |
|||
import com.ccsens.yanyuan.bean.vo.QuestionVo; |
|||
import com.ccsens.yanyuan.service.IQuestionService; |
|||
import com.ccsens.yanyuan.util.YanYuanCodeError; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import io.swagger.annotations.ApiParam; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.validation.annotation.Validated; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestMethod; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import javax.annotation.Resource; |
|||
|
|||
/** |
|||
* @description: 试题 |
|||
* @author: whj |
|||
* @time: 2021/11/11 17:27 |
|||
*/ |
|||
@Api(tags = "测评" ) |
|||
@Slf4j |
|||
@RestController |
|||
@RequestMapping(value = "/question") |
|||
public class QuestionController { |
|||
|
|||
@Resource |
|||
private IQuestionService questionService; |
|||
|
|||
@MustLogin |
|||
@ApiOperation(value = "试题查询", notes = "试题查询") |
|||
@RequestMapping(value = "/get", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) |
|||
public JsonResponse<QuestionVo.QuestionMessage> get(@ApiParam @Validated @RequestBody QueryDto<QuestionDto.Get> params) throws Exception{ |
|||
log.info("试题查询:{}",params); |
|||
QuestionVo.QuestionMessage message = questionService.get(params.getParam(), params.getUserId()); |
|||
log.info("试题查询结束{}", message); |
|||
return JsonResponse.newInstance().ok(message); |
|||
} |
|||
|
|||
@MustLogin |
|||
@ApiOperation(value = "试题答案保存", notes = "试题答案保存") |
|||
@RequestMapping(value = "/saveAnswer", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) |
|||
public JsonResponse saveAnswer(@ApiParam @Validated @RequestBody QueryDto<QuestionDto.SaveAnswer> params) throws Exception{ |
|||
log.info("试题答案保存:{}",params); |
|||
questionService.saveAnswer(params.getParam(), params.getUserId()); |
|||
log.info("试题答案保存结束"); |
|||
return JsonResponse.newInstance().ok(); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,26 @@ |
|||
package com.ccsens.yanyuan.bean.dto; |
|||
|
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @description: 脑力测评-请求 |
|||
* @author: whj |
|||
* @time: 2021/11/10 16:48 |
|||
*/ |
|||
public class MentalTestDto { |
|||
|
|||
@Data |
|||
@ApiModel("为某个用户生成脑力测评") |
|||
public static class GenerateOne{ |
|||
@ApiModelProperty("使用者ID") |
|||
private Long keyUserId; |
|||
} |
|||
@Data |
|||
@ApiModel("测评报告ID") |
|||
public static class Id { |
|||
@ApiModelProperty("脑力测评ID") |
|||
private Long mentalTestId; |
|||
} |
|||
} |
@ -0,0 +1,44 @@ |
|||
package com.ccsens.yanyuan.bean.dto; |
|||
|
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotEmpty; |
|||
import javax.validation.constraints.NotNull; |
|||
|
|||
/** |
|||
* @description: 试题 |
|||
* @author: whj |
|||
* @time: 2021/11/11 17:37 |
|||
*/ |
|||
public class QuestionDto { |
|||
@ApiModel("查询试题-请求") |
|||
@Data |
|||
public static class Get { |
|||
@NotEmpty |
|||
@ApiModelProperty("题目code NLCP:脑力测评 ZARIT:照顾者负担量表") |
|||
private String code; |
|||
@NotNull |
|||
@ApiModelProperty("测评ID 脑力测评ID或zaritID") |
|||
private Long reportId; |
|||
@ApiModelProperty("题号") |
|||
private int num; |
|||
} |
|||
@ApiModel("保存试题答案-请求") |
|||
@Data |
|||
public static class SaveAnswer { |
|||
@NotEmpty |
|||
@ApiModelProperty("题目code NLCP:脑力测评 ZARIT:照顾者负担量表") |
|||
private String code; |
|||
@NotNull |
|||
@ApiModelProperty("测评ID 脑力测评ID或zaritID") |
|||
private Long reportId; |
|||
@NotNull |
|||
@ApiModelProperty("题目ID") |
|||
private Long questionId; |
|||
@NotNull |
|||
@ApiModelProperty("选项ID") |
|||
private Long optionId; |
|||
} |
|||
} |
@ -0,0 +1,117 @@ |
|||
package com.ccsens.yanyuan.bean.po; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
|
|||
public class EvaluationNum implements Serializable { |
|||
private Long id; |
|||
|
|||
private String code; |
|||
|
|||
private Integer num; |
|||
|
|||
private Integer sort; |
|||
|
|||
private String remark; |
|||
|
|||
private Long operator; |
|||
|
|||
private Date createdAt; |
|||
|
|||
private Date updatedAt; |
|||
|
|||
private Byte recStatus; |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
public Long getId() { |
|||
return id; |
|||
} |
|||
|
|||
public void setId(Long id) { |
|||
this.id = id; |
|||
} |
|||
|
|||
public String getCode() { |
|||
return code; |
|||
} |
|||
|
|||
public void setCode(String code) { |
|||
this.code = code == null ? null : code.trim(); |
|||
} |
|||
|
|||
public Integer getNum() { |
|||
return num; |
|||
} |
|||
|
|||
public void setNum(Integer num) { |
|||
this.num = num; |
|||
} |
|||
|
|||
public Integer getSort() { |
|||
return sort; |
|||
} |
|||
|
|||
public void setSort(Integer sort) { |
|||
this.sort = sort; |
|||
} |
|||
|
|||
public String getRemark() { |
|||
return remark; |
|||
} |
|||
|
|||
public void setRemark(String remark) { |
|||
this.remark = remark == null ? null : remark.trim(); |
|||
} |
|||
|
|||
public Long getOperator() { |
|||
return operator; |
|||
} |
|||
|
|||
public void setOperator(Long operator) { |
|||
this.operator = operator; |
|||
} |
|||
|
|||
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 Byte getRecStatus() { |
|||
return recStatus; |
|||
} |
|||
|
|||
public void setRecStatus(Byte recStatus) { |
|||
this.recStatus = recStatus; |
|||
} |
|||
|
|||
@Override |
|||
public String toString() { |
|||
StringBuilder sb = new StringBuilder(); |
|||
sb.append(getClass().getSimpleName()); |
|||
sb.append(" ["); |
|||
sb.append("Hash = ").append(hashCode()); |
|||
sb.append(", id=").append(id); |
|||
sb.append(", code=").append(code); |
|||
sb.append(", num=").append(num); |
|||
sb.append(", sort=").append(sort); |
|||
sb.append(", remark=").append(remark); |
|||
sb.append(", operator=").append(operator); |
|||
sb.append(", createdAt=").append(createdAt); |
|||
sb.append(", updatedAt=").append(updatedAt); |
|||
sb.append(", recStatus=").append(recStatus); |
|||
sb.append("]"); |
|||
return sb.toString(); |
|||
} |
|||
} |
@ -0,0 +1,761 @@ |
|||
package com.ccsens.yanyuan.bean.po; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.Date; |
|||
import java.util.List; |
|||
|
|||
public class EvaluationNumExample { |
|||
protected String orderByClause; |
|||
|
|||
protected boolean distinct; |
|||
|
|||
protected List<Criteria> oredCriteria; |
|||
|
|||
public EvaluationNumExample() { |
|||
oredCriteria = new ArrayList<Criteria>(); |
|||
} |
|||
|
|||
public void setOrderByClause(String orderByClause) { |
|||
this.orderByClause = orderByClause; |
|||
} |
|||
|
|||
public String getOrderByClause() { |
|||
return orderByClause; |
|||
} |
|||
|
|||
public void setDistinct(boolean distinct) { |
|||
this.distinct = distinct; |
|||
} |
|||
|
|||
public boolean isDistinct() { |
|||
return distinct; |
|||
} |
|||
|
|||
public List<Criteria> getOredCriteria() { |
|||
return oredCriteria; |
|||
} |
|||
|
|||
public void or(Criteria criteria) { |
|||
oredCriteria.add(criteria); |
|||
} |
|||
|
|||
public Criteria or() { |
|||
Criteria criteria = createCriteriaInternal(); |
|||
oredCriteria.add(criteria); |
|||
return criteria; |
|||
} |
|||
|
|||
public Criteria createCriteria() { |
|||
Criteria criteria = createCriteriaInternal(); |
|||
if (oredCriteria.size() == 0) { |
|||
oredCriteria.add(criteria); |
|||
} |
|||
return criteria; |
|||
} |
|||
|
|||
protected Criteria createCriteriaInternal() { |
|||
Criteria criteria = new Criteria(); |
|||
return criteria; |
|||
} |
|||
|
|||
public void clear() { |
|||
oredCriteria.clear(); |
|||
orderByClause = null; |
|||
distinct = false; |
|||
} |
|||
|
|||
protected abstract static class GeneratedCriteria { |
|||
protected List<Criterion> criteria; |
|||
|
|||
protected GeneratedCriteria() { |
|||
super(); |
|||
criteria = new ArrayList<Criterion>(); |
|||
} |
|||
|
|||
public boolean isValid() { |
|||
return criteria.size() > 0; |
|||
} |
|||
|
|||
public List<Criterion> getAllCriteria() { |
|||
return criteria; |
|||
} |
|||
|
|||
public List<Criterion> getCriteria() { |
|||
return criteria; |
|||
} |
|||
|
|||
protected void addCriterion(String condition) { |
|||
if (condition == null) { |
|||
throw new RuntimeException("Value for condition cannot be null"); |
|||
} |
|||
criteria.add(new Criterion(condition)); |
|||
} |
|||
|
|||
protected void addCriterion(String condition, Object value, String property) { |
|||
if (value == null) { |
|||
throw new RuntimeException("Value for " + property + " cannot be null"); |
|||
} |
|||
criteria.add(new Criterion(condition, value)); |
|||
} |
|||
|
|||
protected void addCriterion(String condition, Object value1, Object value2, String property) { |
|||
if (value1 == null || value2 == null) { |
|||
throw new RuntimeException("Between values for " + property + " cannot be null"); |
|||
} |
|||
criteria.add(new Criterion(condition, value1, value2)); |
|||
} |
|||
|
|||
public Criteria andIdIsNull() { |
|||
addCriterion("id is null"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andIdIsNotNull() { |
|||
addCriterion("id is not null"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andIdEqualTo(Long value) { |
|||
addCriterion("id =", value, "id"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andIdNotEqualTo(Long value) { |
|||
addCriterion("id <>", value, "id"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andIdGreaterThan(Long value) { |
|||
addCriterion("id >", value, "id"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andIdGreaterThanOrEqualTo(Long value) { |
|||
addCriterion("id >=", value, "id"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andIdLessThan(Long value) { |
|||
addCriterion("id <", value, "id"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andIdLessThanOrEqualTo(Long value) { |
|||
addCriterion("id <=", value, "id"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andIdIn(List<Long> values) { |
|||
addCriterion("id in", values, "id"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andIdNotIn(List<Long> values) { |
|||
addCriterion("id not in", values, "id"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andIdBetween(Long value1, Long value2) { |
|||
addCriterion("id between", value1, value2, "id"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andIdNotBetween(Long value1, Long value2) { |
|||
addCriterion("id not between", value1, value2, "id"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andCodeIsNull() { |
|||
addCriterion("code is null"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andCodeIsNotNull() { |
|||
addCriterion("code is not null"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andCodeEqualTo(String value) { |
|||
addCriterion("code =", value, "code"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andCodeNotEqualTo(String value) { |
|||
addCriterion("code <>", value, "code"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andCodeGreaterThan(String value) { |
|||
addCriterion("code >", value, "code"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andCodeGreaterThanOrEqualTo(String value) { |
|||
addCriterion("code >=", value, "code"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andCodeLessThan(String value) { |
|||
addCriterion("code <", value, "code"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andCodeLessThanOrEqualTo(String value) { |
|||
addCriterion("code <=", value, "code"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andCodeLike(String value) { |
|||
addCriterion("code like", value, "code"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andCodeNotLike(String value) { |
|||
addCriterion("code not like", value, "code"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andCodeIn(List<String> values) { |
|||
addCriterion("code in", values, "code"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andCodeNotIn(List<String> values) { |
|||
addCriterion("code not in", values, "code"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andCodeBetween(String value1, String value2) { |
|||
addCriterion("code between", value1, value2, "code"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andCodeNotBetween(String value1, String value2) { |
|||
addCriterion("code not between", value1, value2, "code"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andNumIsNull() { |
|||
addCriterion("num is null"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andNumIsNotNull() { |
|||
addCriterion("num is not null"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andNumEqualTo(Integer value) { |
|||
addCriterion("num =", value, "num"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andNumNotEqualTo(Integer value) { |
|||
addCriterion("num <>", value, "num"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andNumGreaterThan(Integer value) { |
|||
addCriterion("num >", value, "num"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andNumGreaterThanOrEqualTo(Integer value) { |
|||
addCriterion("num >=", value, "num"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andNumLessThan(Integer value) { |
|||
addCriterion("num <", value, "num"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andNumLessThanOrEqualTo(Integer value) { |
|||
addCriterion("num <=", value, "num"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andNumIn(List<Integer> values) { |
|||
addCriterion("num in", values, "num"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andNumNotIn(List<Integer> values) { |
|||
addCriterion("num not in", values, "num"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andNumBetween(Integer value1, Integer value2) { |
|||
addCriterion("num between", value1, value2, "num"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andNumNotBetween(Integer value1, Integer value2) { |
|||
addCriterion("num not between", value1, value2, "num"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andSortIsNull() { |
|||
addCriterion("sort is null"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andSortIsNotNull() { |
|||
addCriterion("sort is not null"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andSortEqualTo(Integer value) { |
|||
addCriterion("sort =", value, "sort"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andSortNotEqualTo(Integer value) { |
|||
addCriterion("sort <>", value, "sort"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andSortGreaterThan(Integer value) { |
|||
addCriterion("sort >", value, "sort"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andSortGreaterThanOrEqualTo(Integer value) { |
|||
addCriterion("sort >=", value, "sort"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andSortLessThan(Integer value) { |
|||
addCriterion("sort <", value, "sort"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andSortLessThanOrEqualTo(Integer value) { |
|||
addCriterion("sort <=", value, "sort"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andSortIn(List<Integer> values) { |
|||
addCriterion("sort in", values, "sort"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andSortNotIn(List<Integer> values) { |
|||
addCriterion("sort not in", values, "sort"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andSortBetween(Integer value1, Integer value2) { |
|||
addCriterion("sort between", value1, value2, "sort"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andSortNotBetween(Integer value1, Integer value2) { |
|||
addCriterion("sort not between", value1, value2, "sort"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andRemarkIsNull() { |
|||
addCriterion("remark is null"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andRemarkIsNotNull() { |
|||
addCriterion("remark is not null"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andRemarkEqualTo(String value) { |
|||
addCriterion("remark =", value, "remark"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andRemarkNotEqualTo(String value) { |
|||
addCriterion("remark <>", value, "remark"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andRemarkGreaterThan(String value) { |
|||
addCriterion("remark >", value, "remark"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andRemarkGreaterThanOrEqualTo(String value) { |
|||
addCriterion("remark >=", value, "remark"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andRemarkLessThan(String value) { |
|||
addCriterion("remark <", value, "remark"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andRemarkLessThanOrEqualTo(String value) { |
|||
addCriterion("remark <=", value, "remark"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andRemarkLike(String value) { |
|||
addCriterion("remark like", value, "remark"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andRemarkNotLike(String value) { |
|||
addCriterion("remark not like", value, "remark"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andRemarkIn(List<String> values) { |
|||
addCriterion("remark in", values, "remark"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andRemarkNotIn(List<String> values) { |
|||
addCriterion("remark not in", values, "remark"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andRemarkBetween(String value1, String value2) { |
|||
addCriterion("remark between", value1, value2, "remark"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andRemarkNotBetween(String value1, String value2) { |
|||
addCriterion("remark not between", value1, value2, "remark"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andOperatorIsNull() { |
|||
addCriterion("operator is null"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andOperatorIsNotNull() { |
|||
addCriterion("operator is not null"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andOperatorEqualTo(Long value) { |
|||
addCriterion("operator =", value, "operator"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andOperatorNotEqualTo(Long value) { |
|||
addCriterion("operator <>", value, "operator"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andOperatorGreaterThan(Long value) { |
|||
addCriterion("operator >", value, "operator"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andOperatorGreaterThanOrEqualTo(Long value) { |
|||
addCriterion("operator >=", value, "operator"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andOperatorLessThan(Long value) { |
|||
addCriterion("operator <", value, "operator"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andOperatorLessThanOrEqualTo(Long value) { |
|||
addCriterion("operator <=", value, "operator"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andOperatorIn(List<Long> values) { |
|||
addCriterion("operator in", values, "operator"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andOperatorNotIn(List<Long> values) { |
|||
addCriterion("operator not in", values, "operator"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andOperatorBetween(Long value1, Long value2) { |
|||
addCriterion("operator between", value1, value2, "operator"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andOperatorNotBetween(Long value1, Long value2) { |
|||
addCriterion("operator not between", value1, value2, "operator"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andCreatedAtIsNull() { |
|||
addCriterion("created_at is null"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andCreatedAtIsNotNull() { |
|||
addCriterion("created_at is not null"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andCreatedAtEqualTo(Date value) { |
|||
addCriterion("created_at =", value, "createdAt"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andCreatedAtNotEqualTo(Date value) { |
|||
addCriterion("created_at <>", value, "createdAt"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andCreatedAtGreaterThan(Date value) { |
|||
addCriterion("created_at >", value, "createdAt"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andCreatedAtGreaterThanOrEqualTo(Date value) { |
|||
addCriterion("created_at >=", value, "createdAt"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andCreatedAtLessThan(Date value) { |
|||
addCriterion("created_at <", value, "createdAt"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andCreatedAtLessThanOrEqualTo(Date value) { |
|||
addCriterion("created_at <=", value, "createdAt"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andCreatedAtIn(List<Date> values) { |
|||
addCriterion("created_at in", values, "createdAt"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andCreatedAtNotIn(List<Date> values) { |
|||
addCriterion("created_at not in", values, "createdAt"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andCreatedAtBetween(Date value1, Date value2) { |
|||
addCriterion("created_at between", value1, value2, "createdAt"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andCreatedAtNotBetween(Date value1, Date value2) { |
|||
addCriterion("created_at not between", value1, value2, "createdAt"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andUpdatedAtIsNull() { |
|||
addCriterion("updated_at is null"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andUpdatedAtIsNotNull() { |
|||
addCriterion("updated_at is not null"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andUpdatedAtEqualTo(Date value) { |
|||
addCriterion("updated_at =", value, "updatedAt"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andUpdatedAtNotEqualTo(Date value) { |
|||
addCriterion("updated_at <>", value, "updatedAt"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andUpdatedAtGreaterThan(Date value) { |
|||
addCriterion("updated_at >", value, "updatedAt"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andUpdatedAtGreaterThanOrEqualTo(Date value) { |
|||
addCriterion("updated_at >=", value, "updatedAt"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andUpdatedAtLessThan(Date value) { |
|||
addCriterion("updated_at <", value, "updatedAt"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andUpdatedAtLessThanOrEqualTo(Date value) { |
|||
addCriterion("updated_at <=", value, "updatedAt"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andUpdatedAtIn(List<Date> values) { |
|||
addCriterion("updated_at in", values, "updatedAt"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andUpdatedAtNotIn(List<Date> values) { |
|||
addCriterion("updated_at not in", values, "updatedAt"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andUpdatedAtBetween(Date value1, Date value2) { |
|||
addCriterion("updated_at between", value1, value2, "updatedAt"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andUpdatedAtNotBetween(Date value1, Date value2) { |
|||
addCriterion("updated_at not between", value1, value2, "updatedAt"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andRecStatusIsNull() { |
|||
addCriterion("rec_status is null"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andRecStatusIsNotNull() { |
|||
addCriterion("rec_status is not null"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andRecStatusEqualTo(Byte value) { |
|||
addCriterion("rec_status =", value, "recStatus"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andRecStatusNotEqualTo(Byte value) { |
|||
addCriterion("rec_status <>", value, "recStatus"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andRecStatusGreaterThan(Byte value) { |
|||
addCriterion("rec_status >", value, "recStatus"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andRecStatusGreaterThanOrEqualTo(Byte value) { |
|||
addCriterion("rec_status >=", value, "recStatus"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andRecStatusLessThan(Byte value) { |
|||
addCriterion("rec_status <", value, "recStatus"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andRecStatusLessThanOrEqualTo(Byte value) { |
|||
addCriterion("rec_status <=", value, "recStatus"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andRecStatusIn(List<Byte> values) { |
|||
addCriterion("rec_status in", values, "recStatus"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andRecStatusNotIn(List<Byte> values) { |
|||
addCriterion("rec_status not in", values, "recStatus"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andRecStatusBetween(Byte value1, Byte value2) { |
|||
addCriterion("rec_status between", value1, value2, "recStatus"); |
|||
return (Criteria) this; |
|||
} |
|||
|
|||
public Criteria andRecStatusNotBetween(Byte value1, Byte value2) { |
|||
addCriterion("rec_status not between", value1, value2, "recStatus"); |
|||
return (Criteria) this; |
|||
} |
|||
} |
|||
|
|||
public static class Criteria extends GeneratedCriteria { |
|||
|
|||
protected Criteria() { |
|||
super(); |
|||
} |
|||
} |
|||
|
|||
public static class Criterion { |
|||
private String condition; |
|||
|
|||
private Object value; |
|||
|
|||
private Object secondValue; |
|||
|
|||
private boolean noValue; |
|||
|
|||
private boolean singleValue; |
|||
|
|||
private boolean betweenValue; |
|||
|
|||
private boolean listValue; |
|||
|
|||
private String typeHandler; |
|||
|
|||
public String getCondition() { |
|||
return condition; |
|||
} |
|||
|
|||
public Object getValue() { |
|||
return value; |
|||
} |
|||
|
|||
public Object getSecondValue() { |
|||
return secondValue; |
|||
} |
|||
|
|||
public boolean isNoValue() { |
|||
return noValue; |
|||
} |
|||
|
|||
public boolean isSingleValue() { |
|||
return singleValue; |
|||
} |
|||
|
|||
public boolean isBetweenValue() { |
|||
return betweenValue; |
|||
} |
|||
|
|||
public boolean isListValue() { |
|||
return listValue; |
|||
} |
|||
|
|||
public String getTypeHandler() { |
|||
return typeHandler; |
|||
} |
|||
|
|||
protected Criterion(String condition) { |
|||
super(); |
|||
this.condition = condition; |
|||
this.typeHandler = null; |
|||
this.noValue = true; |
|||
} |
|||
|
|||
protected Criterion(String condition, Object value, String typeHandler) { |
|||
super(); |
|||
this.condition = condition; |
|||
this.value = value; |
|||
this.typeHandler = typeHandler; |
|||
if (value instanceof List<?>) { |
|||
this.listValue = true; |
|||
} else { |
|||
this.singleValue = true; |
|||
} |
|||
} |
|||
|
|||
protected Criterion(String condition, Object value) { |
|||
this(condition, value, null); |
|||
} |
|||
|
|||
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { |
|||
super(); |
|||
this.condition = condition; |
|||
this.value = value; |
|||
this.secondValue = secondValue; |
|||
this.typeHandler = typeHandler; |
|||
this.betweenValue = true; |
|||
} |
|||
|
|||
protected Criterion(String condition, Object value, Object secondValue) { |
|||
this(condition, value, secondValue, null); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,44 @@ |
|||
package com.ccsens.yanyuan.bean.vo; |
|||
|
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
import java.math.BigDecimal; |
|||
|
|||
/** |
|||
* @description: 脑力测评-响应 |
|||
* @author: whj |
|||
* @time: 2021/11/10 16:50 |
|||
*/ |
|||
public class MentalTestVo { |
|||
|
|||
@Data |
|||
@ApiModel("脑力测评ID-响应") |
|||
public static class Simple{ |
|||
@ApiModelProperty("脑力测评ID") |
|||
private Long mentalTestId; |
|||
@ApiModelProperty("是否为新的脑力测评 0:原有的脑力测评 1:新生成的脑力测评") |
|||
private byte newMentalTest; |
|||
} |
|||
@Data |
|||
@ApiModel("脑力测评结果-响应") |
|||
public static class Result { |
|||
@ApiModelProperty("记忆力") |
|||
private BigDecimal memoryNum; |
|||
@ApiModelProperty("语言能力") |
|||
private BigDecimal expressNum; |
|||
@ApiModelProperty("视空间") |
|||
private BigDecimal viewNum; |
|||
@ApiModelProperty("注意力") |
|||
private BigDecimal attentionNum; |
|||
@ApiModelProperty("定向力") |
|||
private BigDecimal directionNum; |
|||
@ApiModelProperty("计算能力") |
|||
private BigDecimal countNum; |
|||
@ApiModelProperty("逻辑执行") |
|||
private BigDecimal logicNum; |
|||
@ApiModelProperty("等级") |
|||
private Integer gradeResult; |
|||
} |
|||
} |
@ -0,0 +1,83 @@ |
|||
package com.ccsens.yanyuan.bean.vo; |
|||
|
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @description:试题 |
|||
* @author: whj |
|||
* @time: 2021/11/11 17:37 |
|||
*/ |
|||
public class QuestionVo { |
|||
@Data |
|||
@ApiModel("题目综合信息") |
|||
public static class QuestionMessage { |
|||
@ApiModelProperty("题目ID") |
|||
private Long id; |
|||
@ApiModelProperty("题号") |
|||
private int num; |
|||
@ApiModelProperty("题目页码") |
|||
private List<QuestionPage> questions; |
|||
@ApiModelProperty("选项") |
|||
private List<Option> options; |
|||
} |
|||
|
|||
@Data |
|||
@ApiModel("题目页码") |
|||
public static class QuestionPage{ |
|||
@ApiModelProperty("第几页 0:第一页 1:第二页") |
|||
private byte page; |
|||
@ApiModelProperty("题目位置") |
|||
private List<QuestionPosition> positions; |
|||
} |
|||
|
|||
@Data |
|||
@ApiModel("题目位置") |
|||
public static class QuestionPosition { |
|||
@ApiModelProperty("题目位置:0:title 1:选项前 2:选项后 3:选项左 4:选项右") |
|||
private byte position; |
|||
private List<QuestionContent> contents; |
|||
} |
|||
|
|||
@Data |
|||
@ApiModel("题目内容") |
|||
private static class QuestionContent { |
|||
@ApiModelProperty("题目内容") |
|||
private String content; |
|||
@ApiModelProperty("题目类型 0:文字 1:图片") |
|||
private byte showType; |
|||
} |
|||
@Data |
|||
@ApiModel("选项") |
|||
private static class Option { |
|||
@ApiModelProperty("第几页 0:第一页 1:第二页") |
|||
private byte page; |
|||
@ApiModelProperty("选项位置") |
|||
private List<OptionRow> positions; |
|||
} |
|||
@Data |
|||
@ApiModel("选项第几行") |
|||
private static class OptionRow { |
|||
@ApiModelProperty("第几行") |
|||
private byte row; |
|||
@ApiModelProperty("选项内容") |
|||
private List<OptionCol> contents; |
|||
} |
|||
@Data |
|||
@ApiModel("选项第几列") |
|||
private static class OptionCol { |
|||
@ApiModelProperty("选项ID") |
|||
private Long id; |
|||
@ApiModelProperty("选项内容") |
|||
private String content; |
|||
@ApiModelProperty("题目类型 0:文字 1:图片") |
|||
private byte showType; |
|||
@ApiModelProperty("第几列") |
|||
private byte col; |
|||
@ApiModelProperty("选中状态 0:未被选中 1:选中") |
|||
private byte chooseStatus; |
|||
} |
|||
} |
@ -0,0 +1,44 @@ |
|||
package com.ccsens.yanyuan.mq; |
|||
|
|||
import cn.hutool.core.util.StrUtil; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.ccsens.yanyuan.bean.vo.TraineeVo; |
|||
import com.ccsens.yanyuan.service.IMentalTestService; |
|||
import com.ccsens.yanyuan.util.YanYuanConstant; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.amqp.rabbit.annotation.RabbitHandler; |
|||
import org.springframework.amqp.rabbit.annotation.RabbitListener; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import javax.annotation.Resource; |
|||
|
|||
/** |
|||
* @description: 脑力测评 |
|||
* @author: whj |
|||
* @time: 2021/11/11 16:36 |
|||
*/ |
|||
@Slf4j |
|||
@Component |
|||
@RabbitListener(queues = YanYuanConstant.Mq.MENTAL_TEST_SINGLE) |
|||
public class MentalTestGenerateReceive { |
|||
|
|||
@Resource |
|||
private IMentalTestService mentalTestService; |
|||
|
|||
@RabbitHandler |
|||
public void process(String messageJson){ |
|||
log.info("收到添加脑力测评的mq任务:{}", messageJson); |
|||
if (StrUtil.isEmpty(messageJson)) { |
|||
return; |
|||
} |
|||
TraineeVo.UserId userId; |
|||
try { |
|||
userId = JSONObject.parseObject(messageJson, TraineeVo.UserId.class); |
|||
} catch (Exception e) { |
|||
log.info("生成单个脑力测评,请求参数格式不正确"); |
|||
return; |
|||
} |
|||
Long id = mentalTestService.generateMentalTest(userId.getKeyUserId(), userId.getId()); |
|||
log.info("为{}生成了脑力测评ID:{}", userId.getKeyUserId(), id); |
|||
} |
|||
} |
@ -0,0 +1,51 @@ |
|||
package com.ccsens.yanyuan.mq; |
|||
|
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.ccsens.util.DateUtil; |
|||
import com.ccsens.util.JacksonUtil; |
|||
import com.ccsens.util.config.RabbitMQConfig; |
|||
import com.ccsens.yanyuan.bean.vo.TraineeVo; |
|||
import com.ccsens.yanyuan.persist.dao.MentalTestDao; |
|||
import com.ccsens.yanyuan.service.IMentalTestService; |
|||
import com.ccsens.yanyuan.util.YanYuanConstant; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.amqp.core.AmqpTemplate; |
|||
import org.springframework.amqp.rabbit.annotation.RabbitHandler; |
|||
import org.springframework.amqp.rabbit.annotation.RabbitListener; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import javax.annotation.Resource; |
|||
import java.util.Calendar; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @description: 脑力测评 |
|||
* @author: whj |
|||
* @time: 2021/11/11 16:36 |
|||
*/ |
|||
@Slf4j |
|||
@Component |
|||
@RabbitListener(queues = YanYuanConstant.Mq.MENTAL_TEST_ALL) |
|||
public class MentalTestReceive { |
|||
|
|||
@Resource |
|||
private MentalTestDao mentalTestDao; |
|||
@Resource |
|||
private AmqpTemplate amqpTemplate; |
|||
|
|||
@RabbitHandler |
|||
public void process(String messageJson){ |
|||
Calendar instance = Calendar.getInstance(); |
|||
instance = DateUtil.beginOfDay(instance); |
|||
instance.add(Calendar.DAY_OF_YEAR, -YanYuanConstant.MentalTest.PERIOD); |
|||
log.info("有调度系统调用,为所有用户生成脑力测评"); |
|||
long total = mentalTestDao.countNeedGenerateMental(instance.getTime()); |
|||
int pageSize = 100; |
|||
for (int i = 0; i < total; i+= pageSize) { |
|||
List<TraineeVo.UserId> userIds = mentalTestDao.queryUserIds(i, pageSize, instance.getTime()); |
|||
userIds.forEach(userId -> amqpTemplate.convertAndSend(YanYuanConstant.Mq.MENTAL_TEST_SINGLE, JSONObject.toJSONString(userId))); |
|||
log.info("第{}批用户生成脑力测评", i + 1); |
|||
} |
|||
} |
|||
|
|||
} |
@ -0,0 +1,28 @@ |
|||
package com.ccsens.yanyuan.persist.dao; |
|||
|
|||
import com.ccsens.yanyuan.bean.dto.QuestionDto; |
|||
import com.ccsens.yanyuan.bean.vo.QuestionVo; |
|||
import com.ccsens.yanyuan.persist.mapper.EvaluationNumMapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author whj |
|||
*/ |
|||
public interface EvaluationNumDao extends EvaluationNumMapper { |
|||
/** |
|||
* 随机生成该类型的题目 |
|||
* @param code 类型 |
|||
* @param total 共几套题 |
|||
* @return 题目ID |
|||
*/ |
|||
List<Long> queryRandomIds(@Param("code") String code, @Param("total") int total); |
|||
|
|||
/** |
|||
* 查询试题信息,含答案 |
|||
* @param param 试题信息查询 |
|||
* @return 试题详情 |
|||
*/ |
|||
QuestionVo.QuestionMessage getQuestionMessage(QuestionDto.Get param); |
|||
} |
@ -0,0 +1,20 @@ |
|||
package com.ccsens.yanyuan.persist.dao; |
|||
|
|||
import com.ccsens.yanyuan.bean.dto.QuestionDto; |
|||
import com.ccsens.yanyuan.bean.po.MentalQuestion; |
|||
import com.ccsens.yanyuan.bean.vo.QuestionVo; |
|||
import com.ccsens.yanyuan.persist.mapper.MentalQuestionMapper; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author whj |
|||
*/ |
|||
public interface MentalQuestionDao extends MentalQuestionMapper { |
|||
/** |
|||
* 批量添加脑力测评题目 |
|||
* @param mentalQuestions 脑力测评题目 |
|||
*/ |
|||
void insertBatch(List<MentalQuestion> mentalQuestions); |
|||
|
|||
} |
@ -0,0 +1,45 @@ |
|||
package com.ccsens.yanyuan.persist.dao; |
|||
|
|||
import com.ccsens.yanyuan.bean.po.MentalTest; |
|||
import com.ccsens.yanyuan.bean.vo.MentalTestVo; |
|||
import com.ccsens.yanyuan.bean.vo.TraineeVo; |
|||
import com.ccsens.yanyuan.persist.mapper.MentalTestMapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.Date; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author whj |
|||
*/ |
|||
public interface MentalTestDao extends MentalTestMapper { |
|||
/** |
|||
* 查询用户最近的脑力测评 |
|||
* @param keyUserId 用户ID |
|||
* @return 脑力测评 |
|||
*/ |
|||
MentalTest getRecent(@Param("keyUserId") Long keyUserId); |
|||
|
|||
/** |
|||
* 统计需要生成脑力测评的用户数量 |
|||
* @param date 开始日期 |
|||
* @return 用户数量 |
|||
*/ |
|||
long countNeedGenerateMental(@Param("date") Date date); |
|||
|
|||
/** |
|||
* 查询需要生成脑力测评的用户信息 |
|||
* @param start 开始 |
|||
* @param size 长度 |
|||
* @param date 开始日期 |
|||
* @return 用户id |
|||
*/ |
|||
List<TraineeVo.UserId> queryUserIds(@Param("start") int start, @Param("size") int size, @Param("date") Date date); |
|||
|
|||
/** |
|||
* 计算分数 |
|||
* @param mentalTestId 脑力测评ID |
|||
* @return 分数 |
|||
*/ |
|||
MentalTestVo.Result calculateScore(@Param("mentalTestId") Long mentalTestId); |
|||
} |
@ -0,0 +1,30 @@ |
|||
package com.ccsens.yanyuan.persist.mapper; |
|||
|
|||
import com.ccsens.yanyuan.bean.po.EvaluationNum; |
|||
import com.ccsens.yanyuan.bean.po.EvaluationNumExample; |
|||
import java.util.List; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
public interface EvaluationNumMapper { |
|||
long countByExample(EvaluationNumExample example); |
|||
|
|||
int deleteByExample(EvaluationNumExample example); |
|||
|
|||
int deleteByPrimaryKey(Long id); |
|||
|
|||
int insert(EvaluationNum record); |
|||
|
|||
int insertSelective(EvaluationNum record); |
|||
|
|||
List<EvaluationNum> selectByExample(EvaluationNumExample example); |
|||
|
|||
EvaluationNum selectByPrimaryKey(Long id); |
|||
|
|||
int updateByExampleSelective(@Param("record") EvaluationNum record, @Param("example") EvaluationNumExample example); |
|||
|
|||
int updateByExample(@Param("record") EvaluationNum record, @Param("example") EvaluationNumExample example); |
|||
|
|||
int updateByPrimaryKeySelective(EvaluationNum record); |
|||
|
|||
int updateByPrimaryKey(EvaluationNum record); |
|||
} |
@ -0,0 +1,34 @@ |
|||
package com.ccsens.yanyuan.service; |
|||
|
|||
import com.ccsens.yanyuan.bean.dto.MentalTestDto; |
|||
import com.ccsens.yanyuan.bean.vo.MentalTestVo; |
|||
|
|||
/** |
|||
* @author whj |
|||
*/ |
|||
public interface IMentalTestService { |
|||
|
|||
/** |
|||
* 为某个使用者生成脑力测评(校验是否应该生成) |
|||
* @param param 使用者 |
|||
* @param userId 操作者 |
|||
* @return 脑力测评ID |
|||
*/ |
|||
MentalTestVo.Simple generateMentalTestByValid(MentalTestDto.GenerateOne param, Long userId); |
|||
|
|||
/** |
|||
* 为用户升车脑力测评(不校验是否应该生成) |
|||
* @param keyUserId 使用者keyId |
|||
* @param userId 使用者ID |
|||
* @return 脑力测评ID |
|||
*/ |
|||
Long generateMentalTest(Long keyUserId, String userId); |
|||
|
|||
/** |
|||
* 脑力测评结果计算 |
|||
* @param param 脑力测评 |
|||
* @param userId 操作用户ID |
|||
* @return 结果 |
|||
*/ |
|||
MentalTestVo.Result calculate(MentalTestDto.Id param, Long userId); |
|||
} |
@ -0,0 +1,24 @@ |
|||
package com.ccsens.yanyuan.service; |
|||
|
|||
import com.ccsens.yanyuan.bean.dto.QuestionDto; |
|||
import com.ccsens.yanyuan.bean.vo.QuestionVo; |
|||
|
|||
/** |
|||
* @author whj |
|||
*/ |
|||
public interface IQuestionService { |
|||
/** |
|||
* 查询试题信息 |
|||
* @param param 试题和用户信息 |
|||
* @param userId 操作者 |
|||
* @return 试题信息 |
|||
*/ |
|||
QuestionVo.QuestionMessage get(QuestionDto.Get param, Long userId); |
|||
|
|||
/** |
|||
* 保存答案 |
|||
* @param param 答案 |
|||
* @param userId 用户ID |
|||
*/ |
|||
void saveAnswer(QuestionDto.SaveAnswer param, Long userId); |
|||
} |
@ -0,0 +1,137 @@ |
|||
package com.ccsens.yanyuan.service; |
|||
|
|||
import cn.hutool.core.collection.CollectionUtil; |
|||
import cn.hutool.core.date.DateUtil; |
|||
import cn.hutool.core.lang.Snowflake; |
|||
import com.ccsens.util.CodeEnum; |
|||
import com.ccsens.util.exception.BaseException; |
|||
import com.ccsens.yanyuan.bean.dto.MentalTestDto; |
|||
import com.ccsens.yanyuan.bean.po.*; |
|||
import com.ccsens.yanyuan.bean.vo.MentalTestVo; |
|||
import com.ccsens.yanyuan.persist.dao.EvaluationNumDao; |
|||
import com.ccsens.yanyuan.persist.dao.MentalQuestionDao; |
|||
import com.ccsens.yanyuan.persist.dao.MentalTestDao; |
|||
import com.ccsens.yanyuan.persist.dao.TraineeDao; |
|||
import com.ccsens.yanyuan.util.YanYuanCodeError; |
|||
import com.ccsens.yanyuan.util.YanYuanConstant; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.beans.BeanUtils; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Propagation; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import javax.annotation.Resource; |
|||
import java.util.*; |
|||
|
|||
/** |
|||
* @description: |
|||
* @author: whj |
|||
* @time: 2021/11/10 16:39 |
|||
*/ |
|||
@Slf4j |
|||
@Service |
|||
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) |
|||
public class MentalTestService implements IMentalTestService { |
|||
@Resource |
|||
private Snowflake snowflake; |
|||
@Resource |
|||
private MentalTestDao mentalTestDao; |
|||
@Resource |
|||
private TraineeDao traineeDao; |
|||
@Resource |
|||
private EvaluationNumDao evaluationNumDao; |
|||
@Resource |
|||
private MentalQuestionDao mentalQuestionDao; |
|||
|
|||
@Override |
|||
public MentalTestVo.Simple generateMentalTestByValid(MentalTestDto.GenerateOne param, Long userId) { |
|||
log.info("为{}生成脑力测评", param); |
|||
MentalTestVo.Simple simple = new MentalTestVo.Simple(); |
|||
// 用户存在
|
|||
UserExample userExample = new UserExample(); |
|||
userExample.createCriteria().andKeyIdEqualTo(param.getKeyUserId()); |
|||
List<User> users = traineeDao.selectByExample(userExample); |
|||
if (CollectionUtil.isEmpty(users)) { |
|||
log.info("{}不存在该用户", param.getKeyUserId()); |
|||
throw new BaseException(CodeEnum.PARAM_ERROR); |
|||
} |
|||
// 查询最近的脑力测评
|
|||
MentalTest mentalTest = mentalTestDao.getRecent(param.getKeyUserId()); |
|||
// 判断是否需要生成脑力测评
|
|||
Calendar onePeriod = Calendar.getInstance(); |
|||
onePeriod = DateUtil.endOfDay(onePeriod); |
|||
onePeriod.set(Calendar.DAY_OF_YEAR, -YanYuanConstant.MentalTest.PERIOD); |
|||
// 需生成脑力测评:1.最近无 2.早于14天 3.未完成
|
|||
boolean generate = mentalTest == null || mentalTest.getCreateAt().getTime() < onePeriod.getTimeInMillis() |
|||
|| mentalTest.getFinishStatus() != YanYuanConstant.MentalTest.FINISH_STATUS_YES; |
|||
if (!generate) { |
|||
log.info("不需要生成新的脑力测评"); |
|||
simple.setMentalTestId(mentalTest.getKeyId()); |
|||
simple.setNewMentalTest(YanYuanConstant.MentalTest.GENERATE_OLD); |
|||
return simple; |
|||
} |
|||
log.info("开始生成脑力测评"); |
|||
Long id = generateMentalTest(param.getKeyUserId(), users.get(0).getId()); |
|||
simple.setMentalTestId(id); |
|||
simple.setNewMentalTest(YanYuanConstant.MentalTest.GENERATE_NEW); |
|||
return simple; |
|||
} |
|||
|
|||
@Override |
|||
public Long generateMentalTest(Long keyUserId, String userId) { |
|||
// 将未完成的设置为过时
|
|||
MentalTestExample mentalTestExample = new MentalTestExample(); |
|||
mentalTestExample.createCriteria().andKeyUserIdEqualTo(keyUserId).andFinishStatusEqualTo(YanYuanConstant.MentalTest.FINISH_STATUS_NO); |
|||
MentalTest updateMental = new MentalTest(); |
|||
updateMental.setFinishStatus(YanYuanConstant.MentalTest.FINISH_STATUS_OUT_DATE); |
|||
mentalTestDao.updateByExampleSelective(updateMental, mentalTestExample); |
|||
// 保存脑力测评
|
|||
MentalTest mentalTest = new MentalTest(); |
|||
mentalTest.setId(UUID.randomUUID().toString()); |
|||
mentalTest.setKeyId(snowflake.nextId()); |
|||
mentalTest.setKeyUserId(keyUserId); |
|||
mentalTest.setUserId(userId); |
|||
mentalTestDao.insertSelective(mentalTest); |
|||
// 随机获取题目ID
|
|||
List<Long> numIds = evaluationNumDao.queryRandomIds(YanYuanConstant.Evaluation.TYPE_NLCP, YanYuanConstant.Evaluation.TYPE_NLCP_TOTAL); |
|||
// 生成题目
|
|||
List<MentalQuestion> mentalQuestions = new ArrayList<>(); |
|||
numIds.forEach(numId -> { |
|||
MentalQuestion mentalQuestion = new MentalQuestion(); |
|||
mentalQuestion.setId(snowflake.nextId()); |
|||
mentalQuestion.setMentalTestId(mentalTest.getKeyId()); |
|||
mentalQuestion.setNumId(numId); |
|||
mentalQuestions.add(mentalQuestion); |
|||
}); |
|||
if (CollectionUtil.isNotEmpty(mentalQuestions)) { |
|||
mentalQuestionDao.insertBatch(mentalQuestions); |
|||
} |
|||
return keyUserId; |
|||
} |
|||
|
|||
@Override |
|||
public MentalTestVo.Result calculate(MentalTestDto.Id param, Long userId) { |
|||
MentalTestVo.Result result = new MentalTestVo.Result(); |
|||
//判断是否有成绩
|
|||
MentalTestExample testExample = new MentalTestExample(); |
|||
testExample.createCriteria().andKeyIdEqualTo(param.getMentalTestId()); |
|||
List<MentalTest> mentalTests = mentalTestDao.selectByExample(testExample); |
|||
if (CollectionUtil.isEmpty(mentalTests)) { |
|||
throw new BaseException(YanYuanCodeError.PARAM_ERROR); |
|||
} |
|||
MentalTest mentalTest = mentalTests.get(0); |
|||
if (mentalTest.getFinishStatus() == YanYuanConstant.MentalTest.FINISH_STATUS_YES) { |
|||
BeanUtils.copyProperties(mentalTest, result); |
|||
log.info("脑力测评成绩已存在:{}", mentalTest); |
|||
} |
|||
// 计算分数
|
|||
result = mentalTestDao.calculateScore(param.getMentalTestId()); |
|||
log.info("{}的分数:{}", param.getMentalTestId(), result); |
|||
MentalTest updateTest = new MentalTest(); |
|||
BeanUtils.copyProperties(result, updateTest); |
|||
updateTest.setFinishStatus(YanYuanConstant.MentalTest.FINISH_STATUS_YES); |
|||
updateTest.setId(mentalTest.getId()); |
|||
mentalTestDao.updateByPrimaryKeySelective(updateTest); |
|||
return result; |
|||
} |
|||
} |
@ -0,0 +1,111 @@ |
|||
package com.ccsens.yanyuan.service; |
|||
|
|||
import cn.hutool.core.collection.CollectionUtil; |
|||
import cn.hutool.core.lang.Snowflake; |
|||
import com.ccsens.util.WebConstant; |
|||
import com.ccsens.util.exception.BaseException; |
|||
import com.ccsens.yanyuan.bean.dto.QuestionDto; |
|||
import com.ccsens.yanyuan.bean.po.*; |
|||
import com.ccsens.yanyuan.bean.vo.QuestionVo; |
|||
import com.ccsens.yanyuan.persist.dao.EvaluationNumDao; |
|||
import com.ccsens.yanyuan.persist.dao.MentalQuestionDao; |
|||
import com.ccsens.yanyuan.persist.dao.MentalTestDao; |
|||
import com.ccsens.yanyuan.persist.mapper.EvaluationOptionMapper; |
|||
import com.ccsens.yanyuan.persist.mapper.MentalRecordMapper; |
|||
import com.ccsens.yanyuan.util.YanYuanCodeError; |
|||
import com.ccsens.yanyuan.util.YanYuanConstant; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Propagation; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import javax.annotation.Resource; |
|||
import javax.validation.constraints.NotNull; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @description: |
|||
* @author: whj |
|||
* @time: 2021/11/11 17:30 |
|||
*/ |
|||
@Slf4j |
|||
@Service |
|||
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) |
|||
public class QuestionService implements IQuestionService { |
|||
|
|||
@Resource |
|||
private Snowflake snowflake; |
|||
@Resource |
|||
private MentalQuestionDao mentalQuestionDao; |
|||
@Resource |
|||
private EvaluationNumDao evaluationNumDao; |
|||
@Resource |
|||
private MentalTestDao mentalTestDao; |
|||
@Resource |
|||
private EvaluationOptionMapper evaluationOptionMapper; |
|||
@Resource |
|||
private MentalRecordMapper mentalRecordMapper; |
|||
|
|||
|
|||
|
|||
@Override |
|||
public QuestionVo.QuestionMessage get(QuestionDto.Get param, Long userId) { |
|||
|
|||
QuestionVo.QuestionMessage message = evaluationNumDao.getQuestionMessage(param); |
|||
|
|||
return message; |
|||
} |
|||
|
|||
@Override |
|||
public void saveAnswer(QuestionDto.SaveAnswer param, Long userId) { |
|||
// 校验报告单ID、题目、选项存在
|
|||
Object o; |
|||
Long reportId = param.getReportId(); |
|||
switch (param.getCode()) { |
|||
case YanYuanConstant.Evaluation.TYPE_NLCP: |
|||
// 判断脑力测评是否存在
|
|||
o = getMentalTest(reportId); |
|||
break; |
|||
case YanYuanConstant.Evaluation.TYPE_ZARIT: |
|||
// TODO 判断照顾者量表是否存在
|
|||
break; |
|||
default: |
|||
break; |
|||
} |
|||
// 校验题目和选项
|
|||
EvaluationNum num = evaluationNumDao.selectByPrimaryKey(param.getQuestionId()); |
|||
EvaluationOption option = evaluationOptionMapper.selectByPrimaryKey(param.getOptionId()); |
|||
if (num == null || option == null || option.getNumId().longValue() != num.getId().longValue()) { |
|||
throw new BaseException(YanYuanCodeError.PARAM_ERROR); |
|||
} |
|||
// 保存答案
|
|||
// 删除原有答案
|
|||
MentalRecord delRecord = new MentalRecord(); |
|||
delRecord.setRecStatus(WebConstant.REC_STATUS.Deleted.value); |
|||
MentalRecordExample delExample = new MentalRecordExample(); |
|||
delExample.createCriteria().andTestIdEqualTo(param.getReportId()).andNumIdEqualTo(param.getQuestionId()); |
|||
mentalRecordMapper.updateByExampleSelective(delRecord, delExample); |
|||
MentalRecord record = new MentalRecord(); |
|||
record.setId(snowflake.nextId()); |
|||
record.setTestId(param.getReportId()); |
|||
record.setNumId(param.getQuestionId()); |
|||
record.setOptionId(param.getOptionId()); |
|||
record.setOperator(userId); |
|||
mentalRecordMapper.insertSelective(record); |
|||
} |
|||
|
|||
/** |
|||
* 获取mentalTest |
|||
* @param reportId keyId |
|||
* @return mentalTest |
|||
*/ |
|||
private MentalTest getMentalTest(Long reportId) { |
|||
MentalTestExample mentalTestExample = new MentalTestExample(); |
|||
mentalTestExample.createCriteria().andKeyIdEqualTo(reportId); |
|||
List<MentalTest> mentalTests = mentalTestDao.selectByExample(mentalTestExample); |
|||
if (CollectionUtil.isEmpty(mentalTests)) { |
|||
throw new BaseException(YanYuanCodeError.PARAM_ERROR); |
|||
} |
|||
return mentalTests.get(0); |
|||
} |
|||
} |
@ -0,0 +1,115 @@ |
|||
<?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.ccsens.yanyuan.persist.dao.EvaluationNumDao"> |
|||
<resultMap id="questionMessage" type="com.ccsens.yanyuan.bean.vo.QuestionVo$QuestionMessage"> |
|||
<id column="id" property="id"/> |
|||
<result column="num" property="num"/> |
|||
<collection property="questions" ofType="com.ccsens.yanyuan.bean.vo.QuestionVo$QuestionPage"> |
|||
<id column="qPage" property="page"/> |
|||
<collection property="positions" ofType="com.ccsens.yanyuan.bean.vo.QuestionVo$QuestionPosition"> |
|||
<id column="qPosition" property="position"/> |
|||
<collection property="contents" ofType="com.ccsens.yanyuan.bean.vo.QuestionVo$QuestionContent"> |
|||
<id column="qId"/> |
|||
<result column="qContent" property="content"/> |
|||
<result column="qShowType" property="showType"/> |
|||
</collection> |
|||
</collection> |
|||
</collection> |
|||
<collection property="options" ofType="com.ccsens.yanyuan.bean.vo.QuestionVo$Option"> |
|||
<id column="oPage" property="page"/> |
|||
<collection property="positions" ofType="com.ccsens.yanyuan.bean.vo.QuestionVo$OptionRow"> |
|||
<id column="row" property="row"/> |
|||
<collection property="contents" ofType="com.ccsens.yanyuan.bean.vo.QuestionVo$OptionCol"> |
|||
<id column="oId" property="id"/> |
|||
<result column="oContent" property="content"/> |
|||
<result column="oShowType" property="showType"/> |
|||
<result column="col" property="col"/> |
|||
<result column="choose" property="chooseStatus"/> |
|||
</collection> |
|||
</collection> |
|||
</collection> |
|||
</resultMap> |
|||
<select id="queryRandomIds" resultType="java.lang.Long"> |
|||
SELECT |
|||
n.id |
|||
FROM |
|||
( |
|||
SELECT CODE, |
|||
num, |
|||
floor( rand()* #{total} ) + 1 AS sort |
|||
FROM |
|||
t_evaluation_num |
|||
WHERE |
|||
CODE = #{code} |
|||
AND sort = 1 |
|||
AND rec_status = 0 |
|||
) t, |
|||
t_evaluation_num n |
|||
WHERE |
|||
n.CODE = t.CODE |
|||
AND n.num = t.num |
|||
AND n.sort = t.sort |
|||
AND n.rec_status = 0 |
|||
ORDER BY n.num |
|||
</select> |
|||
<select id="getQuestionMessage" resultMap="questionMessage"> |
|||
SELECT |
|||
t.*, |
|||
IF( r.id IS NULL, 0, 1 ) AS choose |
|||
FROM |
|||
( |
|||
SELECT |
|||
n.id, |
|||
n.num, |
|||
q.id AS qId, |
|||
q.content AS qContent, |
|||
q.show_type AS qShowType, |
|||
q.page AS qPage, |
|||
q.position AS qPosition, |
|||
o.id AS oId, |
|||
o.content AS oContent, |
|||
o.page AS oPage, |
|||
o.show_type AS oShowType, |
|||
o.row, |
|||
o.col |
|||
FROM |
|||
( |
|||
<choose> |
|||
<when test="code == 'NLCP'"> |
|||
SELECT |
|||
n.* |
|||
FROM |
|||
u_mental_question r, |
|||
t_evaluation_num n |
|||
WHERE |
|||
r.num_id = n.id |
|||
AND r.mental_test_id = #{reportId} |
|||
AND n.num = #{num} |
|||
AND r.rec_status = 0 |
|||
AND n.rec_status = 0 |
|||
</when> |
|||
<otherwise> |
|||
SELECT |
|||
n.* |
|||
FROM |
|||
t_evaluation_num n |
|||
WHERE |
|||
n.num = #{num} |
|||
AND n.rec_status = 0 |
|||
</otherwise> |
|||
</choose> |
|||
) n, |
|||
t_evaluation_question q, |
|||
t_evaluation_option o |
|||
WHERE |
|||
n.id = q.num_id |
|||
AND n.id = o.num_id |
|||
AND q.rec_status = 0 |
|||
AND o.rec_status = 0 |
|||
) t |
|||
LEFT JOIN u_mental_record r ON r.test_id = #{reportId} |
|||
AND r.num_id = t.id |
|||
AND r.option_id = t.oId |
|||
AND r.rec_status = 0 |
|||
</select> |
|||
</mapper> |
@ -0,0 +1,11 @@ |
|||
<?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.ccsens.yanyuan.persist.dao.MentalQuestionDao"> |
|||
<insert id="insertBatch"> |
|||
INSERT INTO u_mental_question ( id, mental_test_id, num_id ) |
|||
VALUES |
|||
<foreach collection="list" item="item" separator="," > |
|||
(#{item.id}, #{item.mentalTestId}, #{item.numId}) |
|||
</foreach> |
|||
</insert> |
|||
</mapper> |
@ -0,0 +1,98 @@ |
|||
<?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.ccsens.yanyuan.persist.dao.MentalTestDao"> |
|||
|
|||
|
|||
<select id="getRecent" resultType="com.ccsens.yanyuan.bean.po.MentalTest"> |
|||
SELECT |
|||
* |
|||
FROM |
|||
u_mental_test |
|||
WHERE |
|||
key_user_id = #{keyUserId} |
|||
AND rec_status = 0 |
|||
ORDER BY |
|||
create_at DESC |
|||
LIMIT 1 |
|||
</select> |
|||
<select id="countNeedGenerateMental" resultType="java.lang.Long"> |
|||
SELECT |
|||
count(*) |
|||
FROM |
|||
u_user u |
|||
LEFT JOIN u_mental_test t ON u.id = t.user_id AND t.test_at >= #{date} and t.finish_status = 0 |
|||
where u.use_level = 1 and u.rec_status = 0 and t.id is null |
|||
</select> |
|||
<select id="queryUserIds" resultType="com.ccsens.yanyuan.bean.vo.TraineeVo$UserId"> |
|||
SELECT |
|||
u.id, |
|||
u.key_id as keyUserId |
|||
FROM |
|||
u_user u |
|||
LEFT JOIN u_mental_test t ON u.id = t.user_id AND t.test_at >= #{date} and t.finish_status = 0 |
|||
where u.use_level = 1 and u.rec_status = 0 and t.id is null |
|||
limit ${start}, ${size} |
|||
</select> |
|||
<select id="calculateScore" resultType="com.ccsens.yanyuan.bean.vo.MentalTestVo$Result"> |
|||
SELECT |
|||
t.*, |
|||
s.grade AS gradeResult |
|||
FROM |
|||
( |
|||
SELECT |
|||
truncate(ceil( t1.menory * 100 / t2.menory )/ 100,2) AS memoryNum, |
|||
truncate(ceil( t1.express * 100 / t2.express )/ 100,2) AS expressNum, |
|||
truncate(ceil( t1.VIEW * 100 / t2.VIEW )/ 100,2) AS viewNum, |
|||
truncate(ceil( t1.attention * 100 / t2.attention )/ 100,2) AS attentionNum, |
|||
truncate(ceil( t1.direction * 100 / t2.direction )/ 100,2) AS directionNum, |
|||
truncate(ceil( t1.count * 100 / t2.count )/ 100,2) AS countNum, |
|||
truncate(ceil( t1.logic * 100 / t2.logic )/ 100,2) AS logicNum, |
|||
truncate(ceil(( |
|||
t1.menory + t1.express + t1.VIEW + t1.attention + t1.direction + t1.count + t1.logic |
|||
)* 100 /( |
|||
t2.menory + t2.express + t2.VIEW + t2.attention + t2.direction + t2.count + t2.logic |
|||
))/ 100,2) AS grade |
|||
FROM |
|||
( |
|||
SELECT |
|||
sum( memory_score ) AS menory, |
|||
sum( express_score ) AS express, |
|||
sum( view_score ) AS VIEW, |
|||
sum( attention_score ) AS attention, |
|||
sum( direction_score ) AS direction, |
|||
sum( count_score ) AS count, |
|||
sum( logic_score ) AS logic |
|||
FROM |
|||
u_mental_record r, |
|||
t_evaluation_num n, |
|||
t_evaluation_option o, |
|||
u_score s |
|||
WHERE |
|||
r.test_id = #{mentalTestId} |
|||
AND r.num_id = n.id |
|||
AND r.option_id = o.id |
|||
AND o.score > 0 |
|||
AND n.num = s.num |
|||
AND r.rec_status = 0 |
|||
AND n.rec_status = 0 |
|||
AND o.rec_status = 0 |
|||
) t1, |
|||
( |
|||
SELECT |
|||
sum( memory_score ) AS menory, |
|||
sum( express_score ) AS express, |
|||
sum( view_score ) AS VIEW, |
|||
sum( attention_score ) AS attention, |
|||
sum( direction_score ) AS direction, |
|||
sum( count_score ) AS count, |
|||
sum( logic_score ) AS logic |
|||
FROM |
|||
u_score |
|||
) t2 |
|||
) t, |
|||
s_grade s |
|||
WHERE |
|||
t.grade >= s.minValue |
|||
AND t.grade <= s.MAXVALUE |
|||
</select> |
|||
</mapper> |
@ -0,0 +1,275 @@ |
|||
<?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.ccsens.yanyuan.persist.mapper.EvaluationNumMapper"> |
|||
<resultMap id="BaseResultMap" type="com.ccsens.yanyuan.bean.po.EvaluationNum"> |
|||
<id column="id" jdbcType="BIGINT" property="id" /> |
|||
<result column="code" jdbcType="VARCHAR" property="code" /> |
|||
<result column="num" jdbcType="INTEGER" property="num" /> |
|||
<result column="sort" jdbcType="INTEGER" property="sort" /> |
|||
<result column="remark" jdbcType="VARCHAR" property="remark" /> |
|||
<result column="operator" jdbcType="BIGINT" property="operator" /> |
|||
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt" /> |
|||
<result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" /> |
|||
<result column="rec_status" jdbcType="TINYINT" property="recStatus" /> |
|||
</resultMap> |
|||
<sql id="Example_Where_Clause"> |
|||
<where> |
|||
<foreach collection="oredCriteria" item="criteria" separator="or"> |
|||
<if test="criteria.valid"> |
|||
<trim prefix="(" prefixOverrides="and" suffix=")"> |
|||
<foreach collection="criteria.criteria" item="criterion"> |
|||
<choose> |
|||
<when test="criterion.noValue"> |
|||
and ${criterion.condition} |
|||
</when> |
|||
<when test="criterion.singleValue"> |
|||
and ${criterion.condition} #{criterion.value} |
|||
</when> |
|||
<when test="criterion.betweenValue"> |
|||
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} |
|||
</when> |
|||
<when test="criterion.listValue"> |
|||
and ${criterion.condition} |
|||
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=","> |
|||
#{listItem} |
|||
</foreach> |
|||
</when> |
|||
</choose> |
|||
</foreach> |
|||
</trim> |
|||
</if> |
|||
</foreach> |
|||
</where> |
|||
</sql> |
|||
<sql id="Update_By_Example_Where_Clause"> |
|||
<where> |
|||
<foreach collection="example.oredCriteria" item="criteria" separator="or"> |
|||
<if test="criteria.valid"> |
|||
<trim prefix="(" prefixOverrides="and" suffix=")"> |
|||
<foreach collection="criteria.criteria" item="criterion"> |
|||
<choose> |
|||
<when test="criterion.noValue"> |
|||
and ${criterion.condition} |
|||
</when> |
|||
<when test="criterion.singleValue"> |
|||
and ${criterion.condition} #{criterion.value} |
|||
</when> |
|||
<when test="criterion.betweenValue"> |
|||
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} |
|||
</when> |
|||
<when test="criterion.listValue"> |
|||
and ${criterion.condition} |
|||
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=","> |
|||
#{listItem} |
|||
</foreach> |
|||
</when> |
|||
</choose> |
|||
</foreach> |
|||
</trim> |
|||
</if> |
|||
</foreach> |
|||
</where> |
|||
</sql> |
|||
<sql id="Base_Column_List"> |
|||
id, code, num, sort, remark, operator, created_at, updated_at, rec_status |
|||
</sql> |
|||
<select id="selectByExample" parameterType="com.ccsens.yanyuan.bean.po.EvaluationNumExample" resultMap="BaseResultMap"> |
|||
select |
|||
<if test="distinct"> |
|||
distinct |
|||
</if> |
|||
<include refid="Base_Column_List" /> |
|||
from t_evaluation_num |
|||
<if test="_parameter != null"> |
|||
<include refid="Example_Where_Clause" /> |
|||
</if> |
|||
<if test="orderByClause != null"> |
|||
order by ${orderByClause} |
|||
</if> |
|||
</select> |
|||
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> |
|||
select |
|||
<include refid="Base_Column_List" /> |
|||
from t_evaluation_num |
|||
where id = #{id,jdbcType=BIGINT} |
|||
</select> |
|||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> |
|||
delete from t_evaluation_num |
|||
where id = #{id,jdbcType=BIGINT} |
|||
</delete> |
|||
<delete id="deleteByExample" parameterType="com.ccsens.yanyuan.bean.po.EvaluationNumExample"> |
|||
delete from t_evaluation_num |
|||
<if test="_parameter != null"> |
|||
<include refid="Example_Where_Clause" /> |
|||
</if> |
|||
</delete> |
|||
<insert id="insert" parameterType="com.ccsens.yanyuan.bean.po.EvaluationNum"> |
|||
insert into t_evaluation_num (id, code, num, |
|||
sort, remark, operator, |
|||
created_at, updated_at, rec_status |
|||
) |
|||
values (#{id,jdbcType=BIGINT}, #{code,jdbcType=VARCHAR}, #{num,jdbcType=INTEGER}, |
|||
#{sort,jdbcType=INTEGER}, #{remark,jdbcType=VARCHAR}, #{operator,jdbcType=BIGINT}, |
|||
#{createdAt,jdbcType=TIMESTAMP}, #{updatedAt,jdbcType=TIMESTAMP}, #{recStatus,jdbcType=TINYINT} |
|||
) |
|||
</insert> |
|||
<insert id="insertSelective" parameterType="com.ccsens.yanyuan.bean.po.EvaluationNum"> |
|||
insert into t_evaluation_num |
|||
<trim prefix="(" suffix=")" suffixOverrides=","> |
|||
<if test="id != null"> |
|||
id, |
|||
</if> |
|||
<if test="code != null"> |
|||
code, |
|||
</if> |
|||
<if test="num != null"> |
|||
num, |
|||
</if> |
|||
<if test="sort != null"> |
|||
sort, |
|||
</if> |
|||
<if test="remark != null"> |
|||
remark, |
|||
</if> |
|||
<if test="operator != null"> |
|||
operator, |
|||
</if> |
|||
<if test="createdAt != null"> |
|||
created_at, |
|||
</if> |
|||
<if test="updatedAt != null"> |
|||
updated_at, |
|||
</if> |
|||
<if test="recStatus != null"> |
|||
rec_status, |
|||
</if> |
|||
</trim> |
|||
<trim prefix="values (" suffix=")" suffixOverrides=","> |
|||
<if test="id != null"> |
|||
#{id,jdbcType=BIGINT}, |
|||
</if> |
|||
<if test="code != null"> |
|||
#{code,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="num != null"> |
|||
#{num,jdbcType=INTEGER}, |
|||
</if> |
|||
<if test="sort != null"> |
|||
#{sort,jdbcType=INTEGER}, |
|||
</if> |
|||
<if test="remark != null"> |
|||
#{remark,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="operator != null"> |
|||
#{operator,jdbcType=BIGINT}, |
|||
</if> |
|||
<if test="createdAt != null"> |
|||
#{createdAt,jdbcType=TIMESTAMP}, |
|||
</if> |
|||
<if test="updatedAt != null"> |
|||
#{updatedAt,jdbcType=TIMESTAMP}, |
|||
</if> |
|||
<if test="recStatus != null"> |
|||
#{recStatus,jdbcType=TINYINT}, |
|||
</if> |
|||
</trim> |
|||
</insert> |
|||
<select id="countByExample" parameterType="com.ccsens.yanyuan.bean.po.EvaluationNumExample" resultType="java.lang.Long"> |
|||
select count(*) from t_evaluation_num |
|||
<if test="_parameter != null"> |
|||
<include refid="Example_Where_Clause" /> |
|||
</if> |
|||
</select> |
|||
<update id="updateByExampleSelective" parameterType="map"> |
|||
update t_evaluation_num |
|||
<set> |
|||
<if test="record.id != null"> |
|||
id = #{record.id,jdbcType=BIGINT}, |
|||
</if> |
|||
<if test="record.code != null"> |
|||
code = #{record.code,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="record.num != null"> |
|||
num = #{record.num,jdbcType=INTEGER}, |
|||
</if> |
|||
<if test="record.sort != null"> |
|||
sort = #{record.sort,jdbcType=INTEGER}, |
|||
</if> |
|||
<if test="record.remark != null"> |
|||
remark = #{record.remark,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="record.operator != null"> |
|||
operator = #{record.operator,jdbcType=BIGINT}, |
|||
</if> |
|||
<if test="record.createdAt != null"> |
|||
created_at = #{record.createdAt,jdbcType=TIMESTAMP}, |
|||
</if> |
|||
<if test="record.updatedAt != null"> |
|||
updated_at = #{record.updatedAt,jdbcType=TIMESTAMP}, |
|||
</if> |
|||
<if test="record.recStatus != null"> |
|||
rec_status = #{record.recStatus,jdbcType=TINYINT}, |
|||
</if> |
|||
</set> |
|||
<if test="_parameter != null"> |
|||
<include refid="Update_By_Example_Where_Clause" /> |
|||
</if> |
|||
</update> |
|||
<update id="updateByExample" parameterType="map"> |
|||
update t_evaluation_num |
|||
set id = #{record.id,jdbcType=BIGINT}, |
|||
code = #{record.code,jdbcType=VARCHAR}, |
|||
num = #{record.num,jdbcType=INTEGER}, |
|||
sort = #{record.sort,jdbcType=INTEGER}, |
|||
remark = #{record.remark,jdbcType=VARCHAR}, |
|||
operator = #{record.operator,jdbcType=BIGINT}, |
|||
created_at = #{record.createdAt,jdbcType=TIMESTAMP}, |
|||
updated_at = #{record.updatedAt,jdbcType=TIMESTAMP}, |
|||
rec_status = #{record.recStatus,jdbcType=TINYINT} |
|||
<if test="_parameter != null"> |
|||
<include refid="Update_By_Example_Where_Clause" /> |
|||
</if> |
|||
</update> |
|||
<update id="updateByPrimaryKeySelective" parameterType="com.ccsens.yanyuan.bean.po.EvaluationNum"> |
|||
update t_evaluation_num |
|||
<set> |
|||
<if test="code != null"> |
|||
code = #{code,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="num != null"> |
|||
num = #{num,jdbcType=INTEGER}, |
|||
</if> |
|||
<if test="sort != null"> |
|||
sort = #{sort,jdbcType=INTEGER}, |
|||
</if> |
|||
<if test="remark != null"> |
|||
remark = #{remark,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="operator != null"> |
|||
operator = #{operator,jdbcType=BIGINT}, |
|||
</if> |
|||
<if test="createdAt != null"> |
|||
created_at = #{createdAt,jdbcType=TIMESTAMP}, |
|||
</if> |
|||
<if test="updatedAt != null"> |
|||
updated_at = #{updatedAt,jdbcType=TIMESTAMP}, |
|||
</if> |
|||
<if test="recStatus != null"> |
|||
rec_status = #{recStatus,jdbcType=TINYINT}, |
|||
</if> |
|||
</set> |
|||
where id = #{id,jdbcType=BIGINT} |
|||
</update> |
|||
<update id="updateByPrimaryKey" parameterType="com.ccsens.yanyuan.bean.po.EvaluationNum"> |
|||
update t_evaluation_num |
|||
set code = #{code,jdbcType=VARCHAR}, |
|||
num = #{num,jdbcType=INTEGER}, |
|||
sort = #{sort,jdbcType=INTEGER}, |
|||
remark = #{remark,jdbcType=VARCHAR}, |
|||
operator = #{operator,jdbcType=BIGINT}, |
|||
created_at = #{createdAt,jdbcType=TIMESTAMP}, |
|||
updated_at = #{updatedAt,jdbcType=TIMESTAMP}, |
|||
rec_status = #{recStatus,jdbcType=TINYINT} |
|||
where id = #{id,jdbcType=BIGINT} |
|||
</update> |
|||
</mapper> |
Loading…
Reference in new issue