Browse Source

Merge branch 'sd' of dd.tall.wiki:ccsens_wiki/ccsenscloud into sd

sd
zy_Java 4 years ago
parent
commit
4dd4938a66
  1. 50
      ht/src/main/java/com/ccsens/ht/api/BaiDuController.java
  2. 10
      ht/src/main/java/com/ccsens/ht/api/QuestionController.java
  3. 2
      ht/src/main/java/com/ccsens/ht/bean/dto/QuestionDto.java
  4. 40
      ht/src/main/java/com/ccsens/ht/bean/dto/message/MessageDto.java
  5. 128
      ht/src/main/java/com/ccsens/ht/bean/po/HtQuestionShow.java
  6. 821
      ht/src/main/java/com/ccsens/ht/bean/po/HtQuestionShowExample.java
  7. 83
      ht/src/main/java/com/ccsens/ht/bean/vo/QuestionShowVo.java
  8. 117
      ht/src/main/java/com/ccsens/ht/bean/vo/QuestionVo.java
  9. 17
      ht/src/main/java/com/ccsens/ht/persist/dao/HtQuestionShowDao.java
  10. 30
      ht/src/main/java/com/ccsens/ht/persist/mapper/HtQuestionShowMapper.java
  11. 26
      ht/src/main/java/com/ccsens/ht/service/ExportService.java
  12. 29
      ht/src/main/java/com/ccsens/ht/service/ImportService.java
  13. 323
      ht/src/main/java/com/ccsens/ht/service/QuestionService.java
  14. 37
      ht/src/main/java/com/ccsens/ht/uitl/Constant.java
  15. 4
      ht/src/main/resources/application.yml
  16. 2
      ht/src/main/resources/mapper_dao/HtQuestionOptionDescDao.xml
  17. 13
      ht/src/main/resources/mapper_dao/HtQuestionShowDao.xml
  18. 291
      ht/src/main/resources/mapper_raw/HtQuestionShowMapper.xml
  19. 4
      util/src/main/java/com/ccsens/util/JsonResponse.java
  20. 2
      util/src/main/java/com/ccsens/util/PdfUtil.java
  21. 24
      util/src/main/java/com/ccsens/util/bean/message/common/InMessage.java
  22. 16
      util/src/main/java/com/ccsens/util/bean/message/common/MessageRule.java
  23. 147
      util/src/test/java/com/ccsens/util/JsonTest.java

50
ht/src/main/java/com/ccsens/ht/api/BaiDuController.java

@ -0,0 +1,50 @@
package com.ccsens.ht.api;
import com.alibaba.fastjson.JSONObject;
import com.ccsens.cloudutil.annotation.MustLogin;
import com.ccsens.util.RestTemplateUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import sun.misc.BASE64Decoder;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
/**
* @description:
* @author: whj
* @time: 2021/6/22 8:56
*/
@Slf4j
@Api(tags = "百度相关",value = "百度相关")
@RestController
public class BaiDuController {
@ApiOperation(value = "合成语音",notes = "合成语音")
@RequestMapping(value = "/yuyin", method = RequestMethod.GET)
public void yuyin(String text, HttpServletResponse response) throws IOException {
try {
response.setHeader("content-disposition", "attachment;fileName=yuyin.mp3");
String result = RestTemplateUtil.postUrlEncode("https://cloud.baidu.com/aidemo?type=tns&per=4119&spd=1&pit=5&vol=5&aue=6&tex=" + text, new JSONObject());
JSONObject jsonObject = JSONObject.parseObject(result);
String data = jsonObject.getString("data").replace("data:audio/x-mpeg;base64,", "");
log.info("data:{}",data);
byte[] buffer = new BASE64Decoder().decodeBuffer(data);
OutputStream out = response.getOutputStream();
out.write(buffer);
out.close();
}catch (Exception e) {
e.printStackTrace();
}
}
}

10
ht/src/main/java/com/ccsens/ht/api/QuestionController.java

@ -9,7 +9,6 @@ import com.ccsens.ht.bean.vo.QuestionVo;
import com.ccsens.ht.service.IQuestionService;
import com.ccsens.util.CodeEnum;
import com.ccsens.util.JsonResponse;
import com.ccsens.util.NotSupportedFileTypeException;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@ -19,7 +18,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import java.io.IOException;
import java.util.List;
/**
@ -71,7 +69,7 @@ public class QuestionController {
@ApiImplicitParam(name = "json", value = "试题得分情况", required = true)
})
@RequestMapping(value="/saveScore", method = RequestMethod.POST)
public JsonResponse saveScore(@RequestBody @ApiParam @Valid QueryDto<QuestionDto.Score> queryDto) throws IOException, NotSupportedFileTypeException {
public JsonResponse saveScore(@RequestBody @ApiParam @Valid QueryDto<QuestionDto.Score> queryDto) {
log.info("保存试题得分:{}", queryDto);
CodeEnum codeEnum = questionService.saveScore(queryDto.getParam(), queryDto.getUserId());
log.info("保存试题得分结果:{}", codeEnum);
@ -84,7 +82,7 @@ public class QuestionController {
@ApiImplicitParams({
})
@RequestMapping(value="/saveCanvas", method = RequestMethod.POST)
public JsonResponse<List<QuestionVo.PatientCanvas>> saveCanvas(@RequestBody @ApiParam @Valid QueryDto<QuestionDto.SavePatientCanvas> queryDto) throws IOException, NotSupportedFileTypeException {
public JsonResponse<List<QuestionVo.PatientCanvas>> saveCanvas(@RequestBody @ApiParam @Valid QueryDto<QuestionDto.SavePatientCanvas> queryDto) {
log.info("保存用户画图信息");
List<QuestionVo.PatientCanvas> patientCanvas = questionService.saveCanvas(queryDto.getParam(), queryDto.getUserId());
log.info("保存用户画图信息成功后返回");
@ -110,7 +108,7 @@ public class QuestionController {
@ApiImplicitParams({
})
@RequestMapping(value="/queryCanvas", method = RequestMethod.POST)
public JsonResponse<List<QuestionVo.PatientCanvas>> queryCanvas(@RequestBody @ApiParam @Valid QueryDto<QuestionDto.QueryPatientCanvas> queryDto) throws IOException, NotSupportedFileTypeException {
public JsonResponse<List<QuestionVo.PatientCanvas>> queryCanvas(@RequestBody @ApiParam @Valid QueryDto<QuestionDto.QueryPatientCanvas> queryDto) {
log.info("查看用户画图信息");
List<QuestionVo.PatientCanvas> patientCanvas = questionService.getCanvas(queryDto.getParam(), queryDto.getUserId());
log.info("查看用户画图信息成功");
@ -123,7 +121,7 @@ public class QuestionController {
@ApiImplicitParams({
})
@RequestMapping(value="/delCanvas", method = RequestMethod.POST)
public JsonResponse delCanvas(@RequestBody @ApiParam @Valid QueryDto<QuestionDto.DelPatientCanvas> queryDto) throws IOException, NotSupportedFileTypeException {
public JsonResponse delCanvas(@RequestBody @ApiParam @Valid QueryDto<QuestionDto.DelPatientCanvas> queryDto) {
log.info("删除画图轨迹");
questionService.delCanvas(queryDto.getParam(), queryDto.getUserId());
log.info("删除画图轨迹成功");

2
ht/src/main/java/com/ccsens/ht/bean/dto/QuestionDto.java

@ -43,7 +43,7 @@ public class QuestionDto {
@ApiModelProperty("选项集合")
private List<Option> options;
@ApiModelProperty("病友画图或录音")
private String path;
private List<String> paths;
}
@Data
@ApiModel("QuestionDtoOption")

40
ht/src/main/java/com/ccsens/ht/bean/dto/message/MessageDto.java

@ -0,0 +1,40 @@
package com.ccsens.ht.bean.dto.message;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.lang.reflect.ParameterizedType;
/**
* @description:
* @author: whj
* @time: 2021/6/15 9:17
*/
@Data
public class MessageDto<T> {
private String type;
private String event;
private T data;
public void setData(T data) {
this.data = data;
if (data != null) {
this.type = data.getClass().getSimpleName();
}
}
@ApiModel("通知跳转到指定题目")
@Data
public static final class QuestionInform{
@ApiModelProperty("taskId")
private Long taskId;
@ApiModelProperty("提醒文案")
private String content;
@ApiModelProperty("量表")
private String code;
@ApiModelProperty("序号")
private byte sort;
}
}

128
ht/src/main/java/com/ccsens/ht/bean/po/HtQuestionShow.java

@ -0,0 +1,128 @@
package com.ccsens.ht.bean.po;
import java.io.Serializable;
import java.util.Date;
public class HtQuestionShow implements Serializable {
private Long id;
private Long questionId;
private Byte showType;
private Byte showNode;
private String param;
private Byte sort;
private String remark;
private Date createTime;
private Date updateTime;
private Byte isDel;
private static final long serialVersionUID = 1L;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getQuestionId() {
return questionId;
}
public void setQuestionId(Long questionId) {
this.questionId = questionId;
}
public Byte getShowType() {
return showType;
}
public void setShowType(Byte showType) {
this.showType = showType;
}
public Byte getShowNode() {
return showNode;
}
public void setShowNode(Byte showNode) {
this.showNode = showNode;
}
public String getParam() {
return param;
}
public void setParam(String param) {
this.param = param == null ? null : param.trim();
}
public Byte getSort() {
return sort;
}
public void setSort(Byte sort) {
this.sort = sort;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark == null ? null : remark.trim();
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public Byte getIsDel() {
return isDel;
}
public void setIsDel(Byte isDel) {
this.isDel = isDel;
}
@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(", questionId=").append(questionId);
sb.append(", showType=").append(showType);
sb.append(", showNode=").append(showNode);
sb.append(", param=").append(param);
sb.append(", sort=").append(sort);
sb.append(", remark=").append(remark);
sb.append(", createTime=").append(createTime);
sb.append(", updateTime=").append(updateTime);
sb.append(", isDel=").append(isDel);
sb.append("]");
return sb.toString();
}
}

821
ht/src/main/java/com/ccsens/ht/bean/po/HtQuestionShowExample.java

@ -0,0 +1,821 @@
package com.ccsens.ht.bean.po;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class HtQuestionShowExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
public HtQuestionShowExample() {
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 andQuestionIdIsNull() {
addCriterion("question_id is null");
return (Criteria) this;
}
public Criteria andQuestionIdIsNotNull() {
addCriterion("question_id is not null");
return (Criteria) this;
}
public Criteria andQuestionIdEqualTo(Long value) {
addCriterion("question_id =", value, "questionId");
return (Criteria) this;
}
public Criteria andQuestionIdNotEqualTo(Long value) {
addCriterion("question_id <>", value, "questionId");
return (Criteria) this;
}
public Criteria andQuestionIdGreaterThan(Long value) {
addCriterion("question_id >", value, "questionId");
return (Criteria) this;
}
public Criteria andQuestionIdGreaterThanOrEqualTo(Long value) {
addCriterion("question_id >=", value, "questionId");
return (Criteria) this;
}
public Criteria andQuestionIdLessThan(Long value) {
addCriterion("question_id <", value, "questionId");
return (Criteria) this;
}
public Criteria andQuestionIdLessThanOrEqualTo(Long value) {
addCriterion("question_id <=", value, "questionId");
return (Criteria) this;
}
public Criteria andQuestionIdIn(List<Long> values) {
addCriterion("question_id in", values, "questionId");
return (Criteria) this;
}
public Criteria andQuestionIdNotIn(List<Long> values) {
addCriterion("question_id not in", values, "questionId");
return (Criteria) this;
}
public Criteria andQuestionIdBetween(Long value1, Long value2) {
addCriterion("question_id between", value1, value2, "questionId");
return (Criteria) this;
}
public Criteria andQuestionIdNotBetween(Long value1, Long value2) {
addCriterion("question_id not between", value1, value2, "questionId");
return (Criteria) this;
}
public Criteria andShowTypeIsNull() {
addCriterion("show_type is null");
return (Criteria) this;
}
public Criteria andShowTypeIsNotNull() {
addCriterion("show_type is not null");
return (Criteria) this;
}
public Criteria andShowTypeEqualTo(Byte value) {
addCriterion("show_type =", value, "showType");
return (Criteria) this;
}
public Criteria andShowTypeNotEqualTo(Byte value) {
addCriterion("show_type <>", value, "showType");
return (Criteria) this;
}
public Criteria andShowTypeGreaterThan(Byte value) {
addCriterion("show_type >", value, "showType");
return (Criteria) this;
}
public Criteria andShowTypeGreaterThanOrEqualTo(Byte value) {
addCriterion("show_type >=", value, "showType");
return (Criteria) this;
}
public Criteria andShowTypeLessThan(Byte value) {
addCriterion("show_type <", value, "showType");
return (Criteria) this;
}
public Criteria andShowTypeLessThanOrEqualTo(Byte value) {
addCriterion("show_type <=", value, "showType");
return (Criteria) this;
}
public Criteria andShowTypeIn(List<Byte> values) {
addCriterion("show_type in", values, "showType");
return (Criteria) this;
}
public Criteria andShowTypeNotIn(List<Byte> values) {
addCriterion("show_type not in", values, "showType");
return (Criteria) this;
}
public Criteria andShowTypeBetween(Byte value1, Byte value2) {
addCriterion("show_type between", value1, value2, "showType");
return (Criteria) this;
}
public Criteria andShowTypeNotBetween(Byte value1, Byte value2) {
addCriterion("show_type not between", value1, value2, "showType");
return (Criteria) this;
}
public Criteria andShowNodeIsNull() {
addCriterion("show_node is null");
return (Criteria) this;
}
public Criteria andShowNodeIsNotNull() {
addCriterion("show_node is not null");
return (Criteria) this;
}
public Criteria andShowNodeEqualTo(Byte value) {
addCriterion("show_node =", value, "showNode");
return (Criteria) this;
}
public Criteria andShowNodeNotEqualTo(Byte value) {
addCriterion("show_node <>", value, "showNode");
return (Criteria) this;
}
public Criteria andShowNodeGreaterThan(Byte value) {
addCriterion("show_node >", value, "showNode");
return (Criteria) this;
}
public Criteria andShowNodeGreaterThanOrEqualTo(Byte value) {
addCriterion("show_node >=", value, "showNode");
return (Criteria) this;
}
public Criteria andShowNodeLessThan(Byte value) {
addCriterion("show_node <", value, "showNode");
return (Criteria) this;
}
public Criteria andShowNodeLessThanOrEqualTo(Byte value) {
addCriterion("show_node <=", value, "showNode");
return (Criteria) this;
}
public Criteria andShowNodeIn(List<Byte> values) {
addCriterion("show_node in", values, "showNode");
return (Criteria) this;
}
public Criteria andShowNodeNotIn(List<Byte> values) {
addCriterion("show_node not in", values, "showNode");
return (Criteria) this;
}
public Criteria andShowNodeBetween(Byte value1, Byte value2) {
addCriterion("show_node between", value1, value2, "showNode");
return (Criteria) this;
}
public Criteria andShowNodeNotBetween(Byte value1, Byte value2) {
addCriterion("show_node not between", value1, value2, "showNode");
return (Criteria) this;
}
public Criteria andParamIsNull() {
addCriterion("param is null");
return (Criteria) this;
}
public Criteria andParamIsNotNull() {
addCriterion("param is not null");
return (Criteria) this;
}
public Criteria andParamEqualTo(String value) {
addCriterion("param =", value, "param");
return (Criteria) this;
}
public Criteria andParamNotEqualTo(String value) {
addCriterion("param <>", value, "param");
return (Criteria) this;
}
public Criteria andParamGreaterThan(String value) {
addCriterion("param >", value, "param");
return (Criteria) this;
}
public Criteria andParamGreaterThanOrEqualTo(String value) {
addCriterion("param >=", value, "param");
return (Criteria) this;
}
public Criteria andParamLessThan(String value) {
addCriterion("param <", value, "param");
return (Criteria) this;
}
public Criteria andParamLessThanOrEqualTo(String value) {
addCriterion("param <=", value, "param");
return (Criteria) this;
}
public Criteria andParamLike(String value) {
addCriterion("param like", value, "param");
return (Criteria) this;
}
public Criteria andParamNotLike(String value) {
addCriterion("param not like", value, "param");
return (Criteria) this;
}
public Criteria andParamIn(List<String> values) {
addCriterion("param in", values, "param");
return (Criteria) this;
}
public Criteria andParamNotIn(List<String> values) {
addCriterion("param not in", values, "param");
return (Criteria) this;
}
public Criteria andParamBetween(String value1, String value2) {
addCriterion("param between", value1, value2, "param");
return (Criteria) this;
}
public Criteria andParamNotBetween(String value1, String value2) {
addCriterion("param not between", value1, value2, "param");
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(Byte value) {
addCriterion("sort =", value, "sort");
return (Criteria) this;
}
public Criteria andSortNotEqualTo(Byte value) {
addCriterion("sort <>", value, "sort");
return (Criteria) this;
}
public Criteria andSortGreaterThan(Byte value) {
addCriterion("sort >", value, "sort");
return (Criteria) this;
}
public Criteria andSortGreaterThanOrEqualTo(Byte value) {
addCriterion("sort >=", value, "sort");
return (Criteria) this;
}
public Criteria andSortLessThan(Byte value) {
addCriterion("sort <", value, "sort");
return (Criteria) this;
}
public Criteria andSortLessThanOrEqualTo(Byte value) {
addCriterion("sort <=", value, "sort");
return (Criteria) this;
}
public Criteria andSortIn(List<Byte> values) {
addCriterion("sort in", values, "sort");
return (Criteria) this;
}
public Criteria andSortNotIn(List<Byte> values) {
addCriterion("sort not in", values, "sort");
return (Criteria) this;
}
public Criteria andSortBetween(Byte value1, Byte value2) {
addCriterion("sort between", value1, value2, "sort");
return (Criteria) this;
}
public Criteria andSortNotBetween(Byte value1, Byte 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 andCreateTimeIsNull() {
addCriterion("create_time is null");
return (Criteria) this;
}
public Criteria andCreateTimeIsNotNull() {
addCriterion("create_time is not null");
return (Criteria) this;
}
public Criteria andCreateTimeEqualTo(Date value) {
addCriterion("create_time =", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotEqualTo(Date value) {
addCriterion("create_time <>", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThan(Date value) {
addCriterion("create_time >", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThanOrEqualTo(Date value) {
addCriterion("create_time >=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThan(Date value) {
addCriterion("create_time <", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThanOrEqualTo(Date value) {
addCriterion("create_time <=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeIn(List<Date> values) {
addCriterion("create_time in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotIn(List<Date> values) {
addCriterion("create_time not in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeBetween(Date value1, Date value2) {
addCriterion("create_time between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotBetween(Date value1, Date value2) {
addCriterion("create_time not between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNull() {
addCriterion("update_time is null");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNotNull() {
addCriterion("update_time is not null");
return (Criteria) this;
}
public Criteria andUpdateTimeEqualTo(Date value) {
addCriterion("update_time =", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotEqualTo(Date value) {
addCriterion("update_time <>", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThan(Date value) {
addCriterion("update_time >", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThanOrEqualTo(Date value) {
addCriterion("update_time >=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThan(Date value) {
addCriterion("update_time <", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThanOrEqualTo(Date value) {
addCriterion("update_time <=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeIn(List<Date> values) {
addCriterion("update_time in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotIn(List<Date> values) {
addCriterion("update_time not in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeBetween(Date value1, Date value2) {
addCriterion("update_time between", value1, value2, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotBetween(Date value1, Date value2) {
addCriterion("update_time not between", value1, value2, "updateTime");
return (Criteria) this;
}
public Criteria andIsDelIsNull() {
addCriterion("is_del is null");
return (Criteria) this;
}
public Criteria andIsDelIsNotNull() {
addCriterion("is_del is not null");
return (Criteria) this;
}
public Criteria andIsDelEqualTo(Byte value) {
addCriterion("is_del =", value, "isDel");
return (Criteria) this;
}
public Criteria andIsDelNotEqualTo(Byte value) {
addCriterion("is_del <>", value, "isDel");
return (Criteria) this;
}
public Criteria andIsDelGreaterThan(Byte value) {
addCriterion("is_del >", value, "isDel");
return (Criteria) this;
}
public Criteria andIsDelGreaterThanOrEqualTo(Byte value) {
addCriterion("is_del >=", value, "isDel");
return (Criteria) this;
}
public Criteria andIsDelLessThan(Byte value) {
addCriterion("is_del <", value, "isDel");
return (Criteria) this;
}
public Criteria andIsDelLessThanOrEqualTo(Byte value) {
addCriterion("is_del <=", value, "isDel");
return (Criteria) this;
}
public Criteria andIsDelIn(List<Byte> values) {
addCriterion("is_del in", values, "isDel");
return (Criteria) this;
}
public Criteria andIsDelNotIn(List<Byte> values) {
addCriterion("is_del not in", values, "isDel");
return (Criteria) this;
}
public Criteria andIsDelBetween(Byte value1, Byte value2) {
addCriterion("is_del between", value1, value2, "isDel");
return (Criteria) this;
}
public Criteria andIsDelNotBetween(Byte value1, Byte value2) {
addCriterion("is_del not between", value1, value2, "isDel");
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);
}
}
}

83
ht/src/main/java/com/ccsens/ht/bean/vo/QuestionShowVo.java

@ -0,0 +1,83 @@
package com.ccsens.ht.bean.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.ArrayList;
import java.util.List;
/**
* @description:
* @author: whj
* @time: 2021/6/10 16:29
*/
public class QuestionShowVo {
@Data
@ApiModel("显示信息")
public static class Show{
@ApiModelProperty("类型 0:倒计时 1:限制选项数量 2:不是选中指定选项执行操作 3:显示内容")
private byte showType;
}
@EqualsAndHashCode(callSuper = true)
@Data
@ApiModel("选项限制")
public static class OptionLimit extends Show{
@ApiModelProperty("限制类型 0:限制数量")
private byte type;
@ApiModelProperty("属性")
private String name;
@ApiModelProperty("最大")
private byte max;
@ApiModelProperty("最小")
private byte min;
}
@EqualsAndHashCode(callSuper = true)
@Data
@ApiModel("特殊指定-返回")
public static class OptionSpecial extends Show{
@ApiModelProperty("限制类型 0:选中选项数量达到最大后,内容非指定选项,则显示对应信息")
private byte type;
@ApiModelProperty("选项ID")
private List<Long> optionIds = new ArrayList<>();
@ApiModelProperty("选项序号")
private List<Byte> optionNums;
@ApiModelProperty("显示类型 0:图片")
private byte show;
@ApiModelProperty("内容")
private String content;
}
@EqualsAndHashCode(callSuper = true)
@Data
@ApiModel("题目内容补充")
public static class QuestionSupplement extends Show{
@ApiModelProperty("类型 0:图片")
private byte type;
@ApiModelProperty("内容")
private String content;
}
@ApiModel("倒计时配置")
@Data
public static class MesTimer {
@ApiModelProperty("限制类型 0:跳转指定题目")
private byte type;
@ApiModelProperty("taskId")
private Long taskId;
@ApiModelProperty("提醒文案")
private String content;
@ApiModelProperty("量表")
private String code;
@ApiModelProperty("序号")
private byte sort;
@ApiModelProperty("时长")
private int time;
}
}

117
ht/src/main/java/com/ccsens/ht/bean/vo/QuestionVo.java

@ -1,13 +1,16 @@
package com.ccsens.ht.bean.vo;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.ccsens.ht.bean.po.HtPatientQuestionRecord;
import com.ccsens.ht.bean.po.HtQuestion;
import com.ccsens.ht.bean.po.HtQuestionIntroducer;
import com.ccsens.ht.bean.po.HtQuestionShow;
import com.ccsens.ht.uitl.Constant;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.ibatis.javassist.runtime.Desc;
import org.springframework.beans.BeanUtils;
import org.springframework.util.CollectionUtils;
@ -46,13 +49,13 @@ public class QuestionVo {
super();
}
public Query(Question question, List<Option> options, List<Introduce> introduces, List<Record> records, int maxSort) {
public Query(Question question, List<Option> options, List<Introduce> introduces, List<Record> records, List<HtQuestionShow> shows, int maxSort) {
this.question = question;
this.introduces = introduces;
this.optionJsons = new ArrayList<>();
//方便后续把相同属性的选项放到一个对象的List中
Map<String, OptionJson> map = new HashMap<>();
if (CollectionUtil.isNotEmpty(options)) {
//方便后续把相同属性的选项放到一个对象的List中
Map<String, OptionJson> map = new HashMap<>();
options.forEach(option -> {
if (map.get(option.getName()) == null) {
OptionJson json = new OptionJson();
@ -66,9 +69,57 @@ public class QuestionVo {
});
}
this.records = records;
this.isLast = question.getSort().intValue() == maxSort;
this.isFirst = question.getSort().intValue() == 1;
this.isLast = question.getSort() == maxSort;
this.isFirst = question.getSort() == 1;
if (CollectionUtil.isEmpty(shows)) {
return;
}
shows.forEach(show->{
if (StrUtil.isBlank(show.getParam())) {
return;
}
switch (show.getShowType()) {
case Constant.Ht.QuestionShow.SHOW_TYPE_LIMIT:
QuestionShowVo.OptionLimit limit = JSONObject.parseObject(show.getParam(), QuestionShowVo.OptionLimit.class);
limit.setShowType(Constant.Ht.QuestionShow.SHOW_TYPE_LIMIT);
// 对选项要求追加到对应name下
OptionJson optionJson = map.get(limit.getName());
if (optionJson == null) {
return;
}
if (optionJson.getOptionShows() == null) {
optionJson.setOptionShows(new ArrayList<>());
}
optionJson.getOptionShows().add(limit);
break;
case Constant.Ht.QuestionShow.SHOW_TYPE_SPECIAL:
QuestionShowVo.OptionSpecial special = JSONObject.parseObject(show.getParam(), QuestionShowVo.OptionSpecial.class);
special.setShowType(Constant.Ht.QuestionShow.SHOW_TYPE_SPECIAL);
if (special.getOptionNums() == null) {
break;
}
// 根据选项序号获取对应的选项ID
special.getOptionNums().forEach(num -> {
if (options.size() >= num) {
special.getOptionIds().add(options.get(num - 1).getId());
}
});
// 追加到题目信息里
question.getQuestionShows().add(special);
break;
case Constant.Ht.QuestionShow.SHOW_TYPE_SHOW:
QuestionShowVo.QuestionSupplement questionSupplement = JSONObject.parseObject(show.getParam(), QuestionShowVo.QuestionSupplement.class);
questionSupplement.setShowType(Constant.Ht.QuestionShow.SHOW_TYPE_SHOW);
// 追加到题目信息里
question.getQuestionShows().add(questionSupplement);
break;
default:
break;
}
});
}
}
@Data
@ -95,7 +146,7 @@ public class QuestionVo {
vo.setQuestion(Question.toQuestionVo(question));
if (CollectionUtil.isNotEmpty(options)) {
//方便后续把相同属性的选项放到一个对象的List中
Map<String, OptionJson> map = new HashMap<>();
Map<String, OptionJson> map = new HashMap<>(16);
options.forEach(option -> {
if (map.get(option.getName()) == null) {
OptionJson json = new OptionJson();
@ -153,10 +204,12 @@ public class QuestionVo {
List<QuestionOption> relationQuestions = new ArrayList<>();
@ApiModelProperty("补充内容")
List<QuestionRecord> questionRecords;
@ApiModelProperty("补充显示内容")
List<? super QuestionShowVo.Show> questionShows = new ArrayList<>();
/**
* 将HtQuestion转化成Question
* @param question
* @return
* @param question 试题信息
* @return 试题vo
*/
public static Question toQuestionVo(HtQuestion question) {
Question vo = new Question();
@ -164,23 +217,6 @@ public class QuestionVo {
return vo;
}
/**
* 将HtQuestion集合转化成Question集合
* @param questions
* @return
*/
public static List<Question> toQuestionVos(List<HtQuestion> questions) {
List<Question> vos = new ArrayList<>();
if (CollectionUtils.isEmpty(questions)) {
return vos;
}
questions.forEach(question -> {
Question vo = new Question();
BeanUtils.copyProperties(question, vo);
vos.add(vo);
});
return vos;
}
}
@Data
@ -206,15 +242,18 @@ public class QuestionVo {
private List<RecordOption> options;
public List<RecordOption> getOptions() {
if (CollectionUtil.isNotEmpty(answers) && CollectionUtil.isNotEmpty(options)) {
for (RecordOption option: options) {
for (String answer: answers) {
if (option.getDataKey().equals(answer)) {
option.choose = 1;
}
if (CollectionUtil.isEmpty(answers) || CollectionUtil.isEmpty(options)) {
return options;
}
for (RecordOption option: options) {
for (String answer: answers) {
if (option.getDataKey().equals(answer)) {
option.choose = 1;
break;
}
}
}
return options;
}
}
@ -256,6 +295,8 @@ public class QuestionVo {
public static class OptionJson {
private String name;
private List<Option> options = new ArrayList<>();
@ApiModelProperty("补充显示内容")
List<? super QuestionShowVo.Show> optionShows = new ArrayList<>();
public void addOption(Option option){
options.add(option);
}
@ -301,17 +342,17 @@ public class QuestionVo {
/**
* 将HtQuestionIntroduce转化成介绍vo
* @param introduces
* @return
* @param introduces 引导语
* @return 引导语vo
*/
public static List<Introduce> toIntroduces(List<HtQuestionIntroducer> introduces) {
List<Introduce> vos = new ArrayList<>();
if (CollectionUtils.isEmpty(introduces)) {
return vos;
}
introduces.forEach(introducer -> {
introduces.forEach(introduce -> {
Introduce vo = new Introduce();
BeanUtils.copyProperties(introducer, vo);
BeanUtils.copyProperties(introduce, vo);
vos.add(vo);
});
return vos;
@ -332,8 +373,8 @@ public class QuestionVo {
/**
* HtPatientQuestionRecord转化成介绍vo
* @param records
* @return
* @param records 其他记录
* @return 其他记录VO
*/
public static List<Record> toRecords(List<HtPatientQuestionRecord> records) {
List<Record> vos = new ArrayList<>();

17
ht/src/main/java/com/ccsens/ht/persist/dao/HtQuestionShowDao.java

@ -0,0 +1,17 @@
package com.ccsens.ht.persist.dao;
import com.ccsens.ht.bean.po.HtQuestionShow;
import com.ccsens.ht.persist.mapper.HtQuestionShowMapper;
import java.util.List;
/**
* @author whj
*/
public interface HtQuestionShowDao extends HtQuestionShowMapper {
/**
* 批量添加题目显示
* @param showList
*/
void insertBatch(List<HtQuestionShow> showList);
}

30
ht/src/main/java/com/ccsens/ht/persist/mapper/HtQuestionShowMapper.java

@ -0,0 +1,30 @@
package com.ccsens.ht.persist.mapper;
import com.ccsens.ht.bean.po.HtQuestionShow;
import com.ccsens.ht.bean.po.HtQuestionShowExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface HtQuestionShowMapper {
long countByExample(HtQuestionShowExample example);
int deleteByExample(HtQuestionShowExample example);
int deleteByPrimaryKey(Long id);
int insert(HtQuestionShow record);
int insertSelective(HtQuestionShow record);
List<HtQuestionShow> selectByExample(HtQuestionShowExample example);
HtQuestionShow selectByPrimaryKey(Long id);
int updateByExampleSelective(@Param("record") HtQuestionShow record, @Param("example") HtQuestionShowExample example);
int updateByExample(@Param("record") HtQuestionShow record, @Param("example") HtQuestionShowExample example);
int updateByPrimaryKeySelective(HtQuestionShow record);
int updateByPrimaryKey(HtQuestionShow record);
}

26
ht/src/main/java/com/ccsens/ht/service/ExportService.java

@ -89,7 +89,7 @@ public class ExportService implements IExportService {
switch (param.getReport()) {
case Constant.Ht.Report.PARENT_CODE_2:
case Constant.Ht.Report.PARENT_CODE_3:
writeParentCode2(content, detail.getScores());
writeParentCode2(param.getReport(), content, detail.getScores());
//添加初步印象和受试者合作评分
addScoreAndImpression(detail.getPatient().getInitialImpression(), content);
//添加测评员和报告日期
@ -173,9 +173,9 @@ public class ExportService implements IExportService {
List<PatientReportVo.ReportScore> scores = patientReportService.getReportScores(reportScore, param.getId());
//生成写入pdf数据
List<PdfUtil.Row> content = new ArrayList<>();
writeParentCode2(content, scores);
writeParentCode2(param.getCode(),content, scores);
//添加初步印象和受试者合作评分
addScoreAndImpression(reportPatient.getInitialImpression(), content);
addScoreAndImpression("", content);
//添加测评员和报告日期
initLast(content, 2);
//表头
@ -183,7 +183,8 @@ public class ExportService implements IExportService {
String title = String.join(" ", split);
//生成pdf并返回路径
String path = PropUtil.imgDomain + "/" + PdfUtil.createPdf(PropUtil.path, title, Constant.Ht.Report.PARENT_NAME, new PdfUtil.Margin(), reportPatient.toPdfRow(), content);
String subHead = CollectionUtil.isEmpty(scores) ? "" : "认知评估量表("+scores.get(0).getName() + ")报告单";
String path = PropUtil.imgDomain + "/" + PdfUtil.createPdf(PropUtil.path, title, subHead, new PdfUtil.Margin(), reportPatient.toPdfRow(), content);
//TODO 将路径存入报告单关联信息表
// reportRelevance.setPdfUrl(path);
// reportRelevanceMapper.updateByPrimaryKeySelective(reportRelevance);
@ -239,7 +240,17 @@ public class ExportService implements IExportService {
content.add(impression);
}
private void writeParentCode2(List<PdfUtil.Row> content, List<PatientReportVo.ReportScore> scores) {
private void writeParentCode2(String code, List<PdfUtil.Row> content, List<PatientReportVo.ReportScore> scores) {
if (StrUtil.isNotBlank(code) && Constant.Export.PURPOSE_MAP.containsKey(code)) {
PdfUtil.Row purpose = new PdfUtil.Row();
PdfUtil.Cell cell = new PdfUtil.Cell(Constant.Export.PURPOSE_MAP.get(code), 4, 1);
cell.setBorderRight(1);
cell.setCenter(false);
purpose.addCell(cell);
content.add(purpose);
}
PdfUtil.Row title = new PdfUtil.Row();
title.addCell(new PdfUtil.Cell("项目",2,1));
// title.addCell(new PdfUtil.Cell());
@ -250,12 +261,13 @@ public class ExportService implements IExportService {
title.addCell(r);
content.add(title);
scores.forEach(reportScore -> {
String name = StrUtil.isEmpty(reportScore.getDescription()) ? reportScore.getName() : reportScore.getDescription();
if (CollectionUtil.isEmpty(reportScore.getSubReport())) {
PdfUtil.Row row = new PdfUtil.Row();
PdfUtil.Cell cellName = new PdfUtil.Cell();
cellName.setColSpan(2);
cellName.setContent(reportScore.getName());
cellName.setContent(name);
row.addCell(cellName);
PdfUtil.Cell cellScore = new PdfUtil.Cell();
@ -275,7 +287,7 @@ public class ExportService implements IExportService {
if (i == 0) {
PdfUtil.Cell cellName = new PdfUtil.Cell();
cellName.setRowSpan(reportScore.getSubReport().size());
cellName.setContent(reportScore.getName());
cellName.setContent(name);
row.addCell(cellName);
}
row.addCell(new PdfUtil.Cell(score.getName()));

29
ht/src/main/java/com/ccsens/ht/service/ImportService.java

@ -57,6 +57,8 @@ public class ImportService implements IImportService {
private HtQuestionRecordOptionDao htQuestionRecordOptionDao;
@Resource
private HtQuestionOptionDescDao htQuestionOptionDescDao;
@Resource
private HtQuestionShowDao htQuestionShowDao;
@Override
@ -284,6 +286,7 @@ public class ImportService implements IImportService {
List<HtQuestionRecordOption> questionRecordOptionList = new ArrayList<>();
List<HtQuestionOptionDesc> optionDescList = new ArrayList<>();
List<Long> optionDescDelList = new ArrayList<>();
List<HtQuestionShow> showList = new ArrayList<>();
//记录那类型题是关联试题
Map<String, String> parentCode = new HashMap<>();
for(Object[] objs : questions) {
@ -294,7 +297,7 @@ public class ImportService implements IImportService {
int sort = objs.length > 3 && StringUtil.checkNum(String.valueOf(objs[3]), false) ? Integer.parseInt(String.valueOf(objs[3])) : 1;
String type = String.valueOf(objs[0]);
initData(evaluationCode, questionList, optionList, introduceList, ruleList, questionRecordList, questionRecordOptionList, optionDescList, optionDescDelList, parentCode, objs, sort, type);
initData(evaluationCode, questionList, showList, optionList, introduceList, ruleList, questionRecordList, questionRecordOptionList, optionDescList, optionDescDelList, parentCode, objs, sort, type);
}
if (!questionList.isEmpty()) {
@ -321,18 +324,29 @@ public class ImportService implements IImportService {
if (!optionDescList.isEmpty()) {
htQuestionOptionDescDao.insertBatch(optionDescList);
}
if (!showList.isEmpty()) {
htQuestionShowDao.insertBatch(showList);
}
}
/**
* 试题导入将obj[] 转换成 对应的data
*/
private void initData(String evaluationCode, List<HtQuestion> questionList, List<HtQuestionOption> optionList, List<HtQuestionIntroducer> introduceList, List<HtQuestionScoringRule> ruleList, List<HtQuestionRecord> questionRecordList, List<HtQuestionRecordOption> questionRecordOptionList, List<HtQuestionOptionDesc> optionDescList, List<Long> optionDescDelList, Map<String, String> parentCode, Object[] objs, int sort, String type) {
private void initData(String evaluationCode, List<HtQuestion> questionList, List<HtQuestionShow> showList, List<HtQuestionOption> optionList, List<HtQuestionIntroducer> introduceList, List<HtQuestionScoringRule> ruleList, List<HtQuestionRecord> questionRecordList, List<HtQuestionRecordOption> questionRecordOptionList, List<HtQuestionOptionDesc> optionDescList, List<Long> optionDescDelList, Map<String, String> parentCode, Object[] objs, int sort, String type) {
switch (type) {
case Constant.Import.EVALUATION_QUESTION :
HtQuestion question = initQuestion(objs, evaluationCode, sort);
question.setEvaluationCode(parentCode.getOrDefault(question.getParentCode(), question.getEvaluationCode()));
questionList.add(question);
break;
case Constant.Import.EVALUATION_QUESTION_SHOW :
if (CollectionUtil.isEmpty(questionList)) {
break;
}
HtQuestionShow questionShow = initQuestionShow(objs, sort);
questionShow.setQuestionId(questionList.get(questionList.size() - 1).getId());
showList.add(questionShow);
break;
case Constant.Import.EVALUATION_RELATION:
HtQuestion relationQuestion = initQuestion(objs, evaluationCode, sort);
relationQuestion.setEvaluationCode(parentCode.getOrDefault(relationQuestion.getParentCode(), relationQuestion.getEvaluationCode()));
@ -380,6 +394,15 @@ public class ImportService implements IImportService {
}
}
private HtQuestionShow initQuestionShow(Object[] objs, int sort) {
String content = (String)objs[2];
HtQuestionShow show = JSONObject.parseObject(content, HtQuestionShow.class);
show.setId(snowflake.nextId());
show.setSort((byte)sort);
show.setRemark(StrUtil.isEmpty(show.getRemark()) ? "" : show.getRemark());
return show;
}
/**
* 封装record option
* @param objs 一列
@ -482,6 +505,7 @@ public class ImportService implements IImportService {
* @param questionId 试题ID
* @param sort 排序
* @param optionDescList 记录其他补充
* @param optionIds 要删除的其他记录的选项ID
* @return 选项
*/
private HtQuestionOption initOption(Object[] objs, Long questionId, int sort, List<HtQuestionOptionDesc> optionDescList, List<Long> optionIds) {
@ -525,6 +549,7 @@ public class ImportService implements IImportService {
for (Object obj: descArr) {
HtQuestionOptionDesc desc = JSONObject.parseObject(JSON.toJSONString(obj), HtQuestionOptionDesc.class);
desc.setId(snowflake.nextId());
desc.setOptionId(option.getId());
optionDescList.add(desc);
}
}

323
ht/src/main/java/com/ccsens/ht/service/QuestionService.java

@ -8,17 +8,25 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ccsens.ht.bean.dto.QuestionDto;
import com.ccsens.ht.bean.dto.message.MessageDto;
import com.ccsens.ht.bean.po.*;
import com.ccsens.ht.bean.vo.QuestionShowVo;
import com.ccsens.ht.bean.vo.QuestionVo;
import com.ccsens.ht.persist.dao.*;
import com.ccsens.ht.persist.mapper.*;
import com.ccsens.ht.persist.mapper.HtPatientCanvasLineMapper;
import com.ccsens.ht.persist.mapper.HtPatientQuestionRecordMapper;
import com.ccsens.ht.persist.mapper.HtPatientReportMapper;
import com.ccsens.ht.uitl.Constant;
import com.ccsens.util.*;
import com.ccsens.util.CodeEnum;
import com.ccsens.util.bean.message.common.InMessage;
import com.ccsens.util.bean.message.common.MessageRule;
import com.ccsens.util.config.RabbitMQConfig;
import com.ccsens.util.exception.BaseException;
import io.swagger.annotations.ApiModel;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.apache.commons.lang3.concurrent.BasicThreadFactory;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
@ -28,10 +36,12 @@ import javax.annotation.Resource;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
/**
@ -45,7 +55,7 @@ import java.util.concurrent.atomic.AtomicInteger;
public class QuestionService implements IQuestionService {
@Autowired
@Resource
private Snowflake snowflake;
@Resource
private HtQuestionDao htQuestionDao;
@ -69,11 +79,10 @@ public class QuestionService implements IQuestionService {
private HtPatientCanvasLineMapper patientCanvasLineMapper;
@Resource
private HtPatientReportRecordDescDao htPatientReportRecordDescDao;
@Resource
private HtQuestionShowDao htQuestionShowDao;
@Resource
private AmqpTemplate rabbitTemplate;
@Override
public QuestionVo.Query queryQuestion(QuestionDto.Query query, Long userId) {
@ -83,6 +92,11 @@ public class QuestionService implements IQuestionService {
if (questionVo == null) {
throw new BaseException(CodeEnum.QUESTION_NOT_FOUND);
}
// 查询试题的其他显示相关的信息
HtQuestionShowExample showExample = new HtQuestionShowExample();
showExample.createCriteria().andQuestionIdEqualTo(questionVo.getId()).andShowNodeIn(Constant.Ht.QuestionShow.SHOW_NODE_RUNNING);
List<HtQuestionShow> shows = htQuestionShowDao.selectByExample(showExample);
//获取code信息及补充信息
QuestionVo.Report reportVo = htReportDao.queryReportAndRecord(questionVo.getParentCode(), query.getPatientReportId());
@ -159,7 +173,7 @@ public class QuestionService implements IQuestionService {
}
//封装返回
QuestionVo.Query data = new QuestionVo.Query(questionVo, optionList, introduceVos, recordVos,maxSort);
QuestionVo.Query data = new QuestionVo.Query(questionVo, optionList, introduceVos, recordVos, shows, maxSort);
data.setReport(reportVo);
log.info("试题信息:{}", data);
return data;
@ -188,7 +202,7 @@ public class QuestionService implements IQuestionService {
}
@Override
public CodeEnum saveScore(QuestionDto.Score score, Long userId) {
public CodeEnum saveScore(QuestionDto.Score score, final Long userId) {
log.info("保存分数{}", score);
if (score.getPatientReportId() == null) {
@ -231,17 +245,17 @@ public class QuestionService implements IQuestionService {
for(QuestionDto.Option option : score.getOptions()) {
HtQuestionOption questionOption = htQuestionOptionDao.selectByPrimaryKey(option.getId());
//未找到对应选项 或选项不是该试题的选项
if (questionOption == null || questionOption.getQuestionId().longValue() != question.getId()) {
log.info("选项不存在或不是对应试题的选项");
return CodeEnum.PARAM_ERROR;
}
//去除整数后多余的小数点
if(ObjectUtil.isNotNull(questionOption.getScore())){
if(BigDecimal.valueOf(questionOption.getScore().intValue()).compareTo(questionOption.getScore()) == 0){
questionOption.setScore(questionOption.getScore().setScale(0,BigDecimal.ROUND_HALF_UP));
}
}
//未找到对应选项 或选项不是该试题的选项
if (questionOption == null || questionOption.getQuestionId().longValue() != question.getId()) {
log.info("选项不存在或不是对应试题的选项");
return CodeEnum.PARAM_ERROR;
}
nameOption.put(questionOption.getName(), questionOption);
idOption.put(questionOption.getId(), questionOption);
}
@ -251,7 +265,7 @@ public class QuestionService implements IQuestionService {
if (!CollectionUtils.isEmpty(ruleList)) {
HtQuestionScoringRule rule = ruleList.get(0);
if (rule.getType() == null || rule.getType().byteValue() == Constant.Ht.Rule.SMALL) {
if (rule.getType() == null || rule.getType() == Constant.Ht.Rule.SMALL) {
// 计算分数
countScore(score, parentCode, report, scores, rule);
} else {
@ -275,7 +289,47 @@ public class QuestionService implements IQuestionService {
saveAnswerRecord(score, question);
//修改报告单是否完成一次测评
changeShowStatus(report, question);
changeShowStatus(report, question);
// 查询提交后要执行的任务
HtQuestionShowExample showExample = new HtQuestionShowExample();
showExample.createCriteria().andQuestionIdEqualTo(question.getId()).andShowNodeIn(Constant.Ht.QuestionShow.SHOW_NODE_RUN);
List<HtQuestionShow> shows = htQuestionShowDao.selectByExample(showExample);
if (CollectionUtil.isEmpty(shows)) {
return CodeEnum.SUCCESS;
}
log.info("执行提交后的任务");
ScheduledExecutorService executor = new ScheduledThreadPoolExecutor(shows.size(),
new BasicThreadFactory.Builder().namingPattern("question-schedule-pool-%d").daemon(true).build());
shows.forEach(show -> {
// 倒计时
if (show.getShowType() == Constant.Ht.QuestionShow.SHOW_TYPE_COUNT_DOWN) {
QuestionShowVo.MesTimer mesTimer = JSONObject.parseObject(show.getParam(), QuestionShowVo.MesTimer.class);
executor.schedule(() -> {
// 设置
try {
MessageDto.QuestionInform inform = new MessageDto.QuestionInform();
inform.setContent(mesTimer.getContent());
inform.setCode(mesTimer.getCode());
inform.setSort(mesTimer.getSort());
MessageDto<MessageDto.QuestionInform> data = new MessageDto<>();
data.setData(inform);
InMessage inMessage = new InMessage(MessageRule.noAck(), JSONObject.toJSONString(data), String.valueOf(userId));
rabbitTemplate.convertAndSend(RabbitMQConfig.TALL_MESSAGE_1, JSONObject.toJSONString(inMessage));
log.info("发送成功:{}", inMessage);
} catch (Exception e) {
log.error("保存试题答案后,推送消息异常", e);
}
}, mesTimer.getTime(), TimeUnit.SECONDS);
}
});
/*
*/
executor.shutdown();
log.info("线程池结束");
return CodeEnum.SUCCESS;
}
@ -296,55 +350,58 @@ public class QuestionService implements IQuestionService {
/**
* 修改报告单显示状态
* @param report
* @param question
* @param report 报告单
* @param question 题目
*/
private void changeShowStatus(HtPatientReport report, HtQuestion question) {
if (report.getShowStatus() != null && report.getShowStatus().byteValue() == Constant.Ht.Report.SHOW_HISTORY) {
if (report.getShowStatus() != null && report.getShowStatus() == Constant.Ht.Report.SHOW_HISTORY) {
return;
}
Integer maxSort = htQuestionDao.selectMaxSort(question.getEvaluationCode());
if (question.getSort() != null && question.getSort().intValue() >= maxSort) {
if (question.getSort() != null && maxSort != null && question.getSort() >= maxSort) {
report.setShowStatus(Constant.Ht.Report.SHOW_HISTORY);
htPatientReportMapper.updateByPrimaryKeySelective(report);
}
}
private void saveAnswerRecord(QuestionDto.Score score, HtQuestion question) {
if (StrUtil.isNotBlank(score.getPath())) {
HtPatientQuestionRecordExample example = new HtPatientQuestionRecordExample();
String type;
switch (question.getOperateType()) {
case Constant.Ht.Operation.VOICE://语音
case Constant.Ht.Operation.KNOCK://敲击
type = Constant.Ht.Record.ANSWER_AUDIO;
break;
case Constant.Ht.Operation.PAINT: //画图
case Constant.Ht.Operation.PAINT_HALF: //画图
case Constant.Ht.Operation.PAINT_HALF_IMG: //画图
case Constant.Ht.Operation.PAINT_NO_IMG: //画图
type = Constant.Ht.Record.ANSWER_IMG;
break;
default:
type = Constant.Ht.Record.ANSWER_TEXT;
break;
}
example.createCriteria().andPatientReportIdEqualTo(score.getPatientReportId()).andQuestionIdEqualTo(score.getQuestionId()).andRecordTypeEqualTo(type);
HtPatientQuestionRecord delRecord = new HtPatientQuestionRecord();
delRecord.setIsDel(Constant.Ht.IS_DEL);
htPatientQuestionRecordMapper.updateByExampleSelective(delRecord, example);
if (CollectionUtil.isEmpty(score.getPaths())) {
return;
}
String type;
switch (question.getOperateType()) {
//语音
case Constant.Ht.Operation.VOICE:
//敲击
case Constant.Ht.Operation.KNOCK:
type = Constant.Ht.Record.ANSWER_AUDIO;
break;
//画图
case Constant.Ht.Operation.PAINT:
case Constant.Ht.Operation.PAINT_HALF:
case Constant.Ht.Operation.PAINT_HALF_IMG:
case Constant.Ht.Operation.PAINT_NO_IMG:
type = Constant.Ht.Record.ANSWER_IMG;
break;
default:
type = Constant.Ht.Record.ANSWER_TEXT;
break;
}
HtPatientQuestionRecordExample example = new HtPatientQuestionRecordExample();
example.createCriteria().andPatientReportIdEqualTo(score.getPatientReportId()).andQuestionIdEqualTo(score.getQuestionId()).andRecordTypeEqualTo(type);
HtPatientQuestionRecord delRecord = new HtPatientQuestionRecord();
delRecord.setIsDel(Constant.Ht.IS_DEL);
htPatientQuestionRecordMapper.updateByExampleSelective(delRecord, example);
score.getPaths().forEach(path->{
HtPatientQuestionRecord record = new HtPatientQuestionRecord();
record.setId(snowflake.nextId());
record.setPatientReportId(score.getPatientReportId());
record.setQuestionId(score.getQuestionId());
record.setRecordTime(System.currentTimeMillis());
record.setRecordType(type);
record.setRecordValue(score.getPath());
record.setRecordValue(path);
htPatientQuestionRecordMapper.insertSelective(record);
}
});
}
private void countScore(QuestionDto.Score score, String parentCode, HtPatientReport report, List<HtPatientScore> scores, HtQuestionScoringRule rule) {
@ -368,9 +425,9 @@ public class QuestionService implements IQuestionService {
}
/**
* 查询试题正确个数
* @param scores
* @return
* 计算试题正确个数
* @param scores 分数
* @return 正确格式
*/
private int getCurrentNum(List<HtPatientScore> scores) {
if (CollectionUtil.isEmpty(scores)) {
@ -394,15 +451,13 @@ public class QuestionService implements IQuestionService {
/**
* 分数数据处理
* @param score
* @param question
* @param report
* @param ruleList
* @param nameOption
* @param idOption
* @return
* @throws IOException
* @throws NotSupportedFileTypeException
* @param score 分数
* @param question 题目
* @param report 报告单
* @param ruleList 计分规则
* @param nameOption 选项
* @param idOption 题目ID
* @return 父子关联的分数集合
*/
private List<HtPatientScore> getHtPatientScores(QuestionDto.Score score, HtQuestion question, HtPatientReport report, List<HtQuestionScoringRule> ruleList, Map<String, HtQuestionOption> nameOption, Map<Long, HtQuestionOption> idOption) {
List<HtPatientScore> scores = new ArrayList<>();
@ -426,13 +481,13 @@ public class QuestionService implements IQuestionService {
/**
* 组装分数对象
* @param score
* @param score 分数
* @param option 当前选项前端传入
* @param question
* @param report
* @param ruleList
* @param nameOption
* @param scores
* @param question 题目
* @param report 报告单
* @param ruleList 计分规则
* @param nameOption 选项
* @param scores 分数集合
* @param questionOption 当前选项数据库查询
*/
private void assembleScore(QuestionDto.Score score, QuestionDto.Option option, HtQuestion question, HtPatientReport report, List<HtQuestionScoringRule> ruleList, Map<String, HtQuestionOption> nameOption, List<HtPatientScore> scores, HtQuestionOption questionOption) {
@ -458,26 +513,26 @@ public class QuestionService implements IQuestionService {
}
private void countScoreByFormula(Map<String, HtQuestionOption> nameOption, HtQuestionOption questionOption, HtPatientScore patientScore, JSONObject remark) {
switch (remark.getIntValue("isAutoformula")) {
case 1:
String formulaSymbol = remark.getString("formulaSymbol");
String[] params = remark.getString("formulaName").split(",");
StringBuilder formula = new StringBuilder();
for (String param: params) {
formula.append(formulaSymbol).append(nameOption.get(param) == null ? 0 : nameOption.get(param) .getScore());
}
String substring = formula.substring(formulaSymbol.length());
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine js = manager.getEngineByName("js");
try {
BigDecimal result = BigDecimal.valueOf((Integer)js.eval(substring));
patientScore.setScore(result);
} catch (ScriptException e) {
log.error("计算出现异常",e);
throw new BaseException(CodeEnum.PARAM_ERROR) ;
}
break;
default: patientScore.setScore(questionOption.getScore());break;
String key = "isAutoformula";
if (remark.getIntValue(key) == 1) {
String formulaSymbol = remark.getString("formulaSymbol");
String[] params = remark.getString("formulaName").split(",");
StringBuilder formula = new StringBuilder();
for (String param : params) {
formula.append(formulaSymbol).append(nameOption.get(param) == null ? 0 : nameOption.get(param).getScore());
}
String substring = formula.substring(formulaSymbol.length());
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine js = manager.getEngineByName("js");
try {
BigDecimal result = BigDecimal.valueOf((Integer) js.eval(substring));
patientScore.setScore(result);
} catch (ScriptException e) {
log.error("计算出现异常", e);
throw new BaseException(CodeEnum.PARAM_ERROR);
}
} else {
patientScore.setScore(questionOption.getScore());
}
}
@ -577,7 +632,8 @@ public class QuestionService implements IQuestionService {
private List<QuestionVo.Point> getCanvasPoints(HtPatientCanvas htPatientCanvas) {
List<QuestionVo.Point> canvasPoints = patientCanvasDao.getCanvasPoints(htPatientCanvas.getId());
if(canvasPoints.size() > 16){
int num = 16;
if(canvasPoints.size() > num){
int c = 240 / (((canvasPoints.size() + 1) / 4) - 1);
int a = 0;
int b = 0;
@ -642,7 +698,7 @@ public class QuestionService implements IQuestionService {
/**
* 统计画图的参数
*
* @param question
* @param question 题目
* @param htPatientCanvas 画板信息
* @param param 请求参数 参考长度 参考思考时间
* @return 返回此次画图的参数
@ -699,7 +755,7 @@ public class QuestionService implements IQuestionService {
PointPosition maxY = null;
//总长度
double totalLength = 0;
/**已经给最大最小点赋值*/
// 已经给最大最小点赋值
boolean hadValue = false;
for (int i = 0; i < canvasPoints.size(); i++) {
QuestionVo.Point canvas = canvasPoints.get(i);
@ -789,15 +845,7 @@ public class QuestionService implements IQuestionService {
// lineParameter.setIntervalDuration(intervalDuration);
// reflectOnTime += intervalDuration;
// }
if (i == 0) {
lineParameter.setIntervalDuration(parameter.getStartDuration());
reflectOnTime += parameter.getStartDuration();
} else {
String[] prevPoints = canvasPoints.get(i - 1).getValue().split(";");
String prevEnd = prevPoints[prevPoints.length - 1].split(",")[2];
lineParameter.setIntervalDuration(Long.parseLong(s[s.length - 1]) - Long.parseLong(prevEnd));
reflectOnTime += lineParameter.getIntervalDuration();
}
reflectOnTime = getReflectOnTime(parameter, canvasPoints, reflectOnTime, i, lineParameter, s);
lineParameterList.add(lineParameter);
}
@ -823,38 +871,26 @@ public class QuestionService implements IQuestionService {
log.info("画板中心:{},{}", centerX, centerY);
//计算图形中心
int x = (maxX.value + minX.value) / 2;
int y = (maxY.value + minY.value) / 2;
int x = maxX == null || minX == null ? 0 : (maxX.value + minX.value) / 2;
int y = maxY == null || minY == null ? 0 : (maxY.value + minY.value) / 2;
String centreCoordinate = x + "," + y;
parameter.setCentreCoordinate(centreCoordinate);
// TODO 重心
parameter.setBarycenterCoordinate(centreCoordinate);
//最小长方形面积
double acreage = (maxX.value - minX.value) * (maxY.value - minY.value);
boolean extremeNoValue = maxX == null || minX == null || maxY == null || minY == null;
double acreage = extremeNoValue ? 0 : (maxX.value - minX.value) * (maxY.value - minY.value);
parameter.setMinRectangleAcreage(acreage);
// 最小圆面积 距离中心最远点-->最小长方形长宽一半的平均数
double radius = ((double)(maxX.value - minX.value + maxY.value - minY.value)) /2 /2;
double radius = extremeNoValue ? 0 : ((double)(maxX.value - minX.value + maxY.value - minY.value)) /2 /2;
parameter.setMinCircleAcreage(new BigDecimal(Math.PI * radius * radius).setScale(2, BigDecimal.ROUND_HALF_UP));
// 四个边界点 四舍五入 sqrt
setFourPoint(canvasPoints, minX, maxX, minY, maxY);
log.info("half:{}",half);
if (half) {
parameter.setShowCentreCoordinate(new QuestionVo.Coordinate(y-centerY, x-centerX ));
// x:y, y:x
parameter.setTop(new QuestionVo.Coordinate(maxY.y - centerY, maxY.x - centerX ));
parameter.setBottom(new QuestionVo.Coordinate(minY.y - centerY, minY.x - centerX));
parameter.setLeft(new QuestionVo.Coordinate(minX.y - centerY, minX.x - centerX));
parameter.setRight(new QuestionVo.Coordinate(maxX.y - centerY, maxX.x - centerX));
} else {
parameter.setShowCentreCoordinate(new QuestionVo.Coordinate(centerX - x, y - centerY));
parameter.setTop(new QuestionVo.Coordinate(centerX - maxY.x , maxY.y - centerY));
parameter.setBottom(new QuestionVo.Coordinate(centerX - minY.x, minY.y - centerY));
parameter.setLeft(new QuestionVo.Coordinate(centerX - minX.x , minX.y - centerY));
parameter.setRight(new QuestionVo.Coordinate(centerX - maxX.x , maxX.y - centerY));
}
setPosition(parameter, minX, maxX, minY, maxY, half, centerX, centerY, x, y, extremeNoValue);
//平均长度
BigDecimal aveLength = BigDecimal.valueOf(totalLength / canvasPoints.size()).setScale(2, RoundingMode.HALF_UP);
@ -880,6 +916,36 @@ public class QuestionService implements IQuestionService {
return parameter;
}
private void setPosition(QuestionVo.Parameter parameter, PointPosition minX, PointPosition maxX, PointPosition minY, PointPosition maxY, boolean half, int centerX, int centerY, int x, int y, boolean extremeNoValue) {
if (half && !extremeNoValue) {
parameter.setShowCentreCoordinate(new QuestionVo.Coordinate(y-centerY, x-centerX ));
// x:y, y:x
parameter.setTop(new QuestionVo.Coordinate(maxY.y - centerY, maxY.x - centerX ));
parameter.setBottom(new QuestionVo.Coordinate(minY.y - centerY, minY.x - centerX));
parameter.setLeft(new QuestionVo.Coordinate(minX.y - centerY, minX.x - centerX));
parameter.setRight(new QuestionVo.Coordinate(maxX.y - centerY, maxX.x - centerX));
} else if (!extremeNoValue) {
parameter.setShowCentreCoordinate(new QuestionVo.Coordinate(centerX - x, y - centerY));
parameter.setTop(new QuestionVo.Coordinate(centerX - maxY.x , maxY.y - centerY));
parameter.setBottom(new QuestionVo.Coordinate(centerX - minY.x, minY.y - centerY));
parameter.setLeft(new QuestionVo.Coordinate(centerX - minX.x , minX.y - centerY));
parameter.setRight(new QuestionVo.Coordinate(centerX - maxX.x , maxX.y - centerY));
}
}
private long getReflectOnTime(QuestionVo.Parameter parameter, List<QuestionVo.Point> canvasPoints, long reflectOnTime, int i, QuestionVo.LineParameter lineParameter, String[] s) {
if (i == 0) {
lineParameter.setIntervalDuration(parameter.getStartDuration());
reflectOnTime += parameter.getStartDuration();
} else {
String[] prevPoints = canvasPoints.get(i - 1).getValue().split(";");
String prevEnd = prevPoints[prevPoints.length - 1].split(",")[2];
lineParameter.setIntervalDuration(Long.parseLong(s[s.length - 1]) - Long.parseLong(prevEnd));
reflectOnTime += lineParameter.getIntervalDuration();
}
return reflectOnTime;
}
/**
* 设置 四个特殊点计算中心点四个特殊点相对原点画板中心的距离 计算点到中心点距离的平方的最大值
* @param canvasPoints 记录
@ -889,14 +955,19 @@ public class QuestionService implements IQuestionService {
* @param maxY 最下点
*/
private void setFourPoint(List<QuestionVo.Point> canvasPoints, PointPosition minX, PointPosition maxX, PointPosition minY, PointPosition maxY) {
// int max = 0;
boolean extremeNoValue = maxX == null || minX == null || maxY == null || minY == null;
if (extremeNoValue) {
log.info("有极限值未找到:{},{},{},{}", maxX, minX, maxY, minY);
return;
}
for (int i = 0; i < canvasPoints.size(); i++) {
QuestionVo.Point point = canvasPoints.get(i);
if (StrUtil.isEmpty(point.getValue())) {
continue;
}
String[] pointArr = point.getValue().split(";");
if (pointArr == null || pointArr.length <= 0) {
if (pointArr.length <= 0) {
continue;
}
//1左 2右 3 上 4 下
@ -916,17 +987,9 @@ public class QuestionService implements IQuestionService {
} else {
pointArr[j] += ",0";
}
String[] strArr = s.split(",");
if (strArr == null || strArr.length < 2) {
continue;
}
// int pointX = Integer.parseInt(strArr[0]);
// int pointY = Integer.parseInt(strArr[1]);
// max = (int) Math.max(max, Math.pow(pointX-x, 2) + Math.pow(pointY - y, 2));
}
point.setValue(StringUtils.join(pointArr, ";"));
}
// return max;
}
@ -968,7 +1031,7 @@ public class QuestionService implements IQuestionService {
QuestionVo.LineParameter lineParameter = lineParameterList.get(i);
// 长短笔画
if(aveLength.compareTo(new BigDecimal(lineParameter.getLength())) >= 0){
if(aveLength.compareTo(BigDecimal.valueOf(lineParameter.getLength())) >= 0){
lineParameter.setLengthStatus(Constant.LineColour.LENGTH_STATUS_SHORT);
shortNums++;
} else {
@ -1004,7 +1067,7 @@ public class QuestionService implements IQuestionService {
lineIndex++;
// 第5条线时,计算长线段的比例
if (lineIndex == lineCount) {
parameter.setLongLineRate(new BigDecimal(longLineIndex * 100).divide(new BigDecimal(lineCount)));
parameter.setLongLineRate(new BigDecimal(longLineIndex * 100).divide(new BigDecimal(lineCount), 2, BigDecimal.ROUND_HALF_UP));
}
}

37
ht/src/main/java/com/ccsens/ht/uitl/Constant.java

@ -28,6 +28,7 @@ public class Constant {
public final static String EVALUATION_RECORD = "其他记录";
public final static String EVALUATION_QUESTION = "题目";
public final static String EVALUATION_QUESTION_SHOW = "题目显示";
public final static String EVALUATION_OPTION = "选项";
public final static String EVALUATION_RELATION = "关联题目";
public final static String EVALUATION_PARSE = "解析";
@ -54,6 +55,14 @@ public class Constant {
}
public static final String MMSE_PURPOSE = "检查目的:MMSE用于筛查痴呆患者、判断认知损害的严重程度并跟踪记录病情变化情况。涵盖了定向力、记忆力、计算及注意力、语言和视空间能力等认知域。";
public static final String MOCA_PURPOSE = "检查目的:MoCA作为总体认知功能评估的筛查量表,覆盖注意力、执行功能、记忆、语言、视空间结构、抽象思维、计算和定向力等认知域。";
public final static Map<String, String> PURPOSE_MAP = new HashMap<>();
static {
PURPOSE_MAP.put("AVLT","检查目的:临床记忆检测(听觉词语记忆测验)用于各种认知障碍疾病记忆功能评估。包括即刻记忆、短延迟回忆、长延迟回忆、线索回忆和再认。反应学习能力、记忆保持率、辨正能力、概念记忆等。");
PURPOSE_MAP.put("DST","检查目的:数字广度测验为注意力测试最基本的方法,包括数字广度顺序测验和数字广度倒序测验两项。");
PURPOSE_MAP.put("TMT","检查目的:空间位置记忆广度测验(连线测验)是最常用的神经心理学测验之一,它反映注意、次序排列、心理灵活性、视觉搜索和运动功能,反映定势转移能力,同时反映手-眼协调能力、空间知觉和注意能力。");
PURPOSE_MAP.put("BNT","检查目的:图片词汇测验(波士顿命名测验)是目前临床上最常见的检测命名障碍神经心理量表。是一种常见的视觉对偶命名测验。");
PURPOSE_MAP.put("LFT","检查目的:立方体组合测验(积木测验)用于检测图形识别及构造功能,可评估受试者辨认空间关系能力、视觉结构分析和综合运用能力,以及视觉-运动协调性等。用于阿尔茨海默病及其他认知障碍疾病的认知功能筛查和鉴别诊断。");
}
}
public static final class ReportExportTitle{
@ -142,6 +151,34 @@ public class Constant {
default: return "其他";
}
}
public static final class QuestionShow{
/**结点:提交后*/
public static final byte SHOW_NODE_SUBMIT = 0;
/**结点:选择时*/
public static final byte SHOW_NODE_CHOOSING = 1;
/**结点:选择结束*/
public static final byte SHOW_NODE_CHOSE = 2;
/**结点:显示题目时*/
public static final byte SHOW_NODE_QUERY = 3;
/**类型:倒计时*/
public static final byte SHOW_TYPE_COUNT_DOWN = 0;
/**类型:限制选项数量*/
public static final byte SHOW_TYPE_LIMIT = 1;
/**类型:选中某些指定选项执行操作*/
public static final byte SHOW_TYPE_SPECIAL = 2;
/**类型:查询题目时的展示内容*/
public static final byte SHOW_TYPE_SHOW = 3;
public static final List<Byte> SHOW_NODE_RUNNING = new ArrayList<>();
public static final List<Byte> SHOW_NODE_RUN = new ArrayList<>();
static {
SHOW_NODE_RUNNING.add(SHOW_NODE_CHOOSING);
SHOW_NODE_RUNNING.add(SHOW_NODE_CHOSE);
SHOW_NODE_RUNNING.add(SHOW_NODE_QUERY);
SHOW_NODE_RUN.add(SHOW_NODE_SUBMIT);
}
}
public static final class Option{
public final static String NUMBER_SCORE = "numberScore";
public final static String NUMBER_TIME = "numberTime";

4
ht/src/main/resources/application.yml

@ -1,5 +1,5 @@
spring:
profiles:
active: prod
include: common, util-prod
active: test
include: common, util-test

2
ht/src/main/resources/mapper_dao/HtQuestionOptionDescDao.xml

@ -13,7 +13,7 @@
</foreach>
</insert>
<delete id="delete">
update t_ht_question_option_desc set rec_status = 0 where option_id in
update t_ht_question_option_desc set is_del = 1 where option_id in
<foreach collection="list" item="item" open="(" close=")" separator=",">
#{item}
</foreach>

13
ht/src/main/resources/mapper_dao/HtQuestionShowDao.xml

@ -0,0 +1,13 @@
<?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.ht.persist.dao.HtQuestionShowDao">
<insert id="insertBatch">
replace into t_ht_question_show(id, question_id,show_type,show_node,param, sort, remark) values
<foreach collection="list" item="show" separator=",">
(
#{show.id},#{show.questionId},#{show.showType},#{show.showNode},#{show.param},#{show.sort},#{show.remark}
)
</foreach>
</insert>
</mapper>

291
ht/src/main/resources/mapper_raw/HtQuestionShowMapper.xml

@ -0,0 +1,291 @@
<?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.ht.persist.mapper.HtQuestionShowMapper">
<resultMap id="BaseResultMap" type="com.ccsens.ht.bean.po.HtQuestionShow">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="question_id" jdbcType="BIGINT" property="questionId" />
<result column="show_type" jdbcType="TINYINT" property="showType" />
<result column="show_node" jdbcType="TINYINT" property="showNode" />
<result column="param" jdbcType="VARCHAR" property="param" />
<result column="sort" jdbcType="TINYINT" property="sort" />
<result column="remark" jdbcType="VARCHAR" property="remark" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="is_del" jdbcType="TINYINT" property="isDel" />
</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, question_id, show_type, show_node, param, sort, remark, create_time, update_time,
is_del
</sql>
<select id="selectByExample" parameterType="com.ccsens.ht.bean.po.HtQuestionShowExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from t_ht_question_show
<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_ht_question_show
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from t_ht_question_show
where id = #{id,jdbcType=BIGINT}
</delete>
<delete id="deleteByExample" parameterType="com.ccsens.ht.bean.po.HtQuestionShowExample">
delete from t_ht_question_show
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="com.ccsens.ht.bean.po.HtQuestionShow">
insert into t_ht_question_show (id, question_id, show_type,
show_node, param, sort,
remark, create_time, update_time,
is_del)
values (#{id,jdbcType=BIGINT}, #{questionId,jdbcType=BIGINT}, #{showType,jdbcType=TINYINT},
#{showNode,jdbcType=TINYINT}, #{param,jdbcType=VARCHAR}, #{sort,jdbcType=TINYINT},
#{remark,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP},
#{isDel,jdbcType=TINYINT})
</insert>
<insert id="insertSelective" parameterType="com.ccsens.ht.bean.po.HtQuestionShow">
insert into t_ht_question_show
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="questionId != null">
question_id,
</if>
<if test="showType != null">
show_type,
</if>
<if test="showNode != null">
show_node,
</if>
<if test="param != null">
param,
</if>
<if test="sort != null">
sort,
</if>
<if test="remark != null">
remark,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="isDel != null">
is_del,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=BIGINT},
</if>
<if test="questionId != null">
#{questionId,jdbcType=BIGINT},
</if>
<if test="showType != null">
#{showType,jdbcType=TINYINT},
</if>
<if test="showNode != null">
#{showNode,jdbcType=TINYINT},
</if>
<if test="param != null">
#{param,jdbcType=VARCHAR},
</if>
<if test="sort != null">
#{sort,jdbcType=TINYINT},
</if>
<if test="remark != null">
#{remark,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="isDel != null">
#{isDel,jdbcType=TINYINT},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.ccsens.ht.bean.po.HtQuestionShowExample" resultType="java.lang.Long">
select count(*) from t_ht_question_show
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update t_ht_question_show
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=BIGINT},
</if>
<if test="record.questionId != null">
question_id = #{record.questionId,jdbcType=BIGINT},
</if>
<if test="record.showType != null">
show_type = #{record.showType,jdbcType=TINYINT},
</if>
<if test="record.showNode != null">
show_node = #{record.showNode,jdbcType=TINYINT},
</if>
<if test="record.param != null">
param = #{record.param,jdbcType=VARCHAR},
</if>
<if test="record.sort != null">
sort = #{record.sort,jdbcType=TINYINT},
</if>
<if test="record.remark != null">
remark = #{record.remark,jdbcType=VARCHAR},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=TIMESTAMP},
</if>
<if test="record.updateTime != null">
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
</if>
<if test="record.isDel != null">
is_del = #{record.isDel,jdbcType=TINYINT},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update t_ht_question_show
set id = #{record.id,jdbcType=BIGINT},
question_id = #{record.questionId,jdbcType=BIGINT},
show_type = #{record.showType,jdbcType=TINYINT},
show_node = #{record.showNode,jdbcType=TINYINT},
param = #{record.param,jdbcType=VARCHAR},
sort = #{record.sort,jdbcType=TINYINT},
remark = #{record.remark,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
is_del = #{record.isDel,jdbcType=TINYINT}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.ccsens.ht.bean.po.HtQuestionShow">
update t_ht_question_show
<set>
<if test="questionId != null">
question_id = #{questionId,jdbcType=BIGINT},
</if>
<if test="showType != null">
show_type = #{showType,jdbcType=TINYINT},
</if>
<if test="showNode != null">
show_node = #{showNode,jdbcType=TINYINT},
</if>
<if test="param != null">
param = #{param,jdbcType=VARCHAR},
</if>
<if test="sort != null">
sort = #{sort,jdbcType=TINYINT},
</if>
<if test="remark != null">
remark = #{remark,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="isDel != null">
is_del = #{isDel,jdbcType=TINYINT},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.ccsens.ht.bean.po.HtQuestionShow">
update t_ht_question_show
set question_id = #{questionId,jdbcType=BIGINT},
show_type = #{showType,jdbcType=TINYINT},
show_node = #{showNode,jdbcType=TINYINT},
param = #{param,jdbcType=VARCHAR},
sort = #{sort,jdbcType=TINYINT},
remark = #{remark,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
is_del = #{isDel,jdbcType=TINYINT}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>

4
util/src/main/java/com/ccsens/util/JsonResponse.java

@ -61,7 +61,7 @@ public class JsonResponse<T> {
return this;
}
public JsonResponse ok(T data){
public JsonResponse<T> ok(T data){
ok();
this.data = data;
return this;
@ -74,7 +74,7 @@ public class JsonResponse<T> {
return this;
}
public JsonResponse ok(CodeEnum codeEnum, T data){
public JsonResponse<T> ok(CodeEnum codeEnum, T data){
this.code = codeEnum.getCode();
this.msg = codeEnum.getMsg();
this.success = codeEnum.isSuccess();

2
util/src/main/java/com/ccsens/util/PdfUtil.java

@ -66,7 +66,7 @@ public class PdfUtil {
document.add(subheadPar);
}
// 每行加空白
fillBlankRow(document, new Font(bfChinese, 8, Font.NORMAL));
fillBlankRow(document, new Font(bfChinese, 3, Font.NORMAL));
//设置介绍内容
if (CollectionUtil.isNotEmpty(intros)) {
fillRow(intros, document);

24
util/src/main/java/com/ccsens/util/bean/message/common/InMessage.java

@ -5,7 +5,9 @@ import com.ccsens.util.JacksonUtil;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonProcessingException;
import lombok.Data;
import org.apache.poi.ss.formula.functions.T;
import java.util.HashSet;
import java.util.Set;
/**
@ -60,6 +62,17 @@ public class InMessage {
public InMessage(){
this.time = DateUtil.currentSeconds();
}
public InMessage(MessageRule rule, String data, String... toArr){
this();
this.rule = rule;
this.data = data;
this.tos = new HashSet<>();
for (String to: toArr) {
tos.add(to);
}
}
public static InMessage newToServerMessage(MessageConstant.DomainType fromDomain,ServerMessage serverMessage) throws JsonProcessingException {
InMessage inMessage = new InMessage();
inMessage.setFromDomain(fromDomain);
@ -88,7 +101,16 @@ public class InMessage {
inMessage.setData(data);
return inMessage;
}
public static InMessage newNo(String from, Set<String> tos, String unikey, MessageRule rule, String data) throws JsonProcessingException {
InMessage inMessage = new InMessage();
inMessage.setToDomain(MessageConstant.DomainType.User);
inMessage.setFrom(from);
inMessage.setTos(tos);
inMessage.setUnikey(unikey);
inMessage.setRule(rule);
inMessage.setData(data);
return inMessage;
}
//TODO
//添加方便链式调用的构造方法,类似builder

16
util/src/main/java/com/ccsens/util/bean/message/common/MessageRule.java

@ -64,11 +64,7 @@ public class MessageRule {
messageRule = new MessageRule((byte) 0, AckRule.ALWAYS, 10, (byte) 1,0L);
break;
case Queue:
messageRule = new MessageRule((byte) 1, AckRule.ALWAYS, 10, (byte) 1,0L);
break;
case Rest:
messageRule = new MessageRule((byte) 1, AckRule.ALWAYS, 10, (byte) 1,0L);
break;
case Server:
messageRule = new MessageRule((byte) 1, AckRule.ALWAYS, 10, (byte) 1,0L);
break;
@ -77,4 +73,16 @@ public class MessageRule {
}
return messageRule;
}
/**
* 不需要回复ACK离线状态直接丢弃
* @return messageRule
*/
public static MessageRule noAck(){
MessageRule rule = new MessageRule();
rule.setAckRule(MessageRule.AckRule.NONE);
rule.setOfflineDiscard((byte) 1);
rule.setNoAckRetryTimes(1);
return rule;
}
}

147
util/src/test/java/com/ccsens/util/JsonTest.java

@ -0,0 +1,147 @@
package com.ccsens.util;
import com.alibaba.fastjson.JSONObject;
import org.junit.Test;
import java.io.Serializable;
import java.util.Date;
/**
* @description:
* @author: whj
* @time: 2021/6/10 14:41
*/
public class JsonTest {
@Test
public void test01(){
String content = "{\"showType\":1,\"showNode\":1,\"param\":{\"type\":0,\"name\":\"one\",\"max\":2,\"min\":2}}";
JSONObject.parseObject("{\"showType\":0,\"showNode\":0,\"param\":{\"type\":\"0\",\"code\":\"AVLT\",\"sort\":4,\"time\":300}}");
HtQuestionShow show = JSONObject.parseObject(content, HtQuestionShow.class);
System.out.println(show);
}
public static class HtQuestionShow implements Serializable {
private Long id;
private Long questionId;
private Byte showType;
private Byte showNode;
private String param;
private Byte sort;
private String remark;
private Date createTime;
private Date updateTime;
private Byte isDel;
private static final long serialVersionUID = 1L;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getQuestionId() {
return questionId;
}
public void setQuestionId(Long questionId) {
this.questionId = questionId;
}
public Byte getShowType() {
return showType;
}
public void setShowType(Byte showType) {
this.showType = showType;
}
public Byte getShowNode() {
return showNode;
}
public void setShowNode(Byte showNode) {
this.showNode = showNode;
}
public String getParam() {
return param;
}
public void setParam(String param) {
this.param = param == null ? null : param.trim();
}
public Byte getSort() {
return sort;
}
public void setSort(Byte sort) {
this.sort = sort;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark == null ? null : remark.trim();
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public Byte getIsDel() {
return isDel;
}
public void setIsDel(Byte isDel) {
this.isDel = isDel;
}
@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(", questionId=").append(questionId);
sb.append(", showType=").append(showType);
sb.append(", showNode=").append(showNode);
sb.append(", param=").append(param);
sb.append(", sort=").append(sort);
sb.append(", remark=").append(remark);
sb.append(", createTime=").append(createTime);
sb.append(", updateTime=").append(updateTime);
sb.append(", isDel=").append(isDel);
sb.append("]");
return sb.toString();
}
}
}
Loading…
Cancel
Save