Browse Source

动作采集分析

sd
zhizhi wu 4 years ago
parent
commit
43c103836d
  1. 24
      ht/src/main/java/com/ccsens/ht/bean/vo/QuestionVo.java
  2. 142
      ht/src/main/java/com/ccsens/ht/service/QuestionService.java
  3. 3
      ht/src/main/resources/application-dev.yml
  4. 8
      tall/src/main/resources/application-dev.yml
  5. 4
      tall/src/main/resources/application.yml

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

@ -10,6 +10,7 @@ import lombok.Data;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -311,10 +312,19 @@ public class QuestionVo {
private Long pointId; private Long pointId;
@ApiModelProperty("颜色") @ApiModelProperty("颜色")
private Integer color; private Integer color;
@ApiModelProperty("轨迹坐标值") @ApiModelProperty("轨迹坐标值 x,y,time,type type:0 普通 1左 2右 3 上 4 下")
private String value; private String value;
} }
@Data
@ApiModel("坐标")
public static class Coordinate {
@ApiModelProperty("横坐标")
private int x;
@ApiModelProperty("横坐标")
private int y;
}
@Data @Data
@ApiModel("画板信息") @ApiModel("画板信息")
@ -344,7 +354,7 @@ public class QuestionVo {
@ApiModelProperty("最长笔画长度") @ApiModelProperty("最长笔画长度")
private double longLine; private double longLine;
@ApiModelProperty("最长笔画速度") @ApiModelProperty("最长笔画速度")
private double longSpeed; private BigDecimal longSpeed;
@ApiModelProperty("最短笔画长度") @ApiModelProperty("最短笔画长度")
private double shortLine; private double shortLine;
@ApiModelProperty("最短笔画速度") @ApiModelProperty("最短笔画速度")
@ -364,15 +374,19 @@ public class QuestionVo {
private long paintTime; private long paintTime;
@ApiModelProperty("中心 暂定为坐标:X,Y") @ApiModelProperty("中心 暂定为坐标:X,Y")
private String centreCoordinate; private String centreCoordinate;
@ApiModelProperty("面积 暂定均为最小外接长方形 单位为px") @ApiModelProperty("重心 暂定为坐标:X,Y")
private double acreage; private String barycenterCoordinate;
@ApiModelProperty("最小外接长方形面积 单位为px")
private double minRectangleAcreage;
@ApiModelProperty("最小外接圆面积 单位为px 保留两位小数")
private BigDecimal minCircleAcreage;
@ApiModelProperty("平均笔画长度") @ApiModelProperty("平均笔画长度")
private double aveLength; private double aveLength;
@ApiModelProperty("平均思考时间") @ApiModelProperty("平均思考时间")
private double aveReflectOnTime; private double aveReflectOnTime;
@ApiModelProperty("长笔画数量") @ApiModelProperty("长笔画数量")
private int longNums; private int longNums;
@ApiModelProperty("笔画数量") @ApiModelProperty("笔画数量")
private int shortNums; private int shortNums;
@ApiModelProperty("快速思考数量") @ApiModelProperty("快速思考数量")
private int quickNums; private int quickNums;

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

@ -17,12 +17,12 @@ import com.ccsens.util.*;
import com.ccsens.util.exception.BaseException; import com.ccsens.util.exception.BaseException;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.script.ScriptEngine; import javax.script.ScriptEngine;
@ -133,7 +133,7 @@ public class QuestionService implements IQuestionService {
Integer maxSort = htQuestionDao.selectMaxSort(query.getCode()); Integer maxSort = htQuestionDao.selectMaxSort(query.getCode());
//查询关联题目 //查询关联题目
if (!StringUtils.isEmpty(question.getRelationCode())) { if (!StrUtil.isEmpty(question.getRelationCode())) {
String[] codes = question.getRelationCode().split(Constant.COMMA); String[] codes = question.getRelationCode().split(Constant.COMMA);
HtQuestionExample example = new HtQuestionExample(); HtQuestionExample example = new HtQuestionExample();
example.createCriteria().andParentCodeIn(CollectionUtils.arrayToList(codes)); example.createCriteria().andParentCodeIn(CollectionUtils.arrayToList(codes));
@ -612,6 +612,31 @@ public class QuestionService implements IQuestionService {
return canvasPoints; return canvasPoints;
} }
/**
* 点位置
*/
private static class PointPosition{
/** 对应值 */
public int value;
/** 第几条线 */
public int line;
/** 第几个点 */
public int point;
public PointPosition(){}
public PointPosition(int value, int line, int point) {
this.value = value;
this.line = line;
this.point = point;
}
public void change(int value, int line, int point) {
this.value = value;
this.line = line;
this.point = point;
}
}
/** /**
* 统计画图的参数 * 统计画图的参数
* @param htPatientCanvas 画板信息 * @param htPatientCanvas 画板信息
@ -659,30 +684,57 @@ public class QuestionService implements IQuestionService {
// 落笔总时间(所有笔画绘图时间) // 落笔总时间(所有笔画绘图时间)
long paintTime = 0; long paintTime = 0;
//X最小值 //X最小值
int minX = 0; PointPosition minX = null;
//X最大值 //X最大值
int maxX = 0; PointPosition maxX = null;
//Y最小值 //Y最小值
int minY = 0; PointPosition minY = null;
//Y最大值 //Y最大值
int maxY = 0; PointPosition maxY = null;
//总长度 //总长度
double totalLength = 0; double totalLength = 0;
/**已经给最大最小点赋值*/
for(QuestionVo.Point canvas : canvasPoints){ boolean hadValue = false;
for (int i = 0; i < canvasPoints.size(); i++) {
QuestionVo.Point canvas = canvasPoints.get(i);
//时间 //时间
QuestionVo.LineParameter lineParameter = new QuestionVo.LineParameter(); QuestionVo.LineParameter lineParameter = new QuestionVo.LineParameter();
String[] a = canvas.getValue().split(";"); String[] a = canvas.getValue().split(";");
if(a.length <= 0){ if(a.length <= 0){
continue; continue;
} }
//获取最边缘的四个点 //获取最边缘的四个点
for (String value : a) { for (int j = 0; j < a.length ; j++) {
String value = a[j];
String[] split1 = value.split(","); String[] split1 = value.split(",");
minX = Math.min(Integer.parseInt(split1[0]), minX); int x = Integer.parseInt(split1[0]);
maxX = Math.max(Integer.parseInt(split1[0]), maxX); int y = Integer.parseInt(split1[1]);
minY = Math.min(Integer.parseInt(split1[1]), minY); if (!hadValue) {
maxY = Math.max(Integer.parseInt(split1[1]), maxY); minX = new PointPosition(x, i, j);
maxX = new PointPosition(x, i, j);
minY = new PointPosition(y, i, j);
maxY = new PointPosition(y, i, j);
hadValue = true;
continue;
}
// 最大最小横坐标
if (minX.value > x) {
minX.change(x,i,j);
} else if (maxX.value < x) {
maxX.change(x,i,j);
}
// 最大最小纵坐标
if (minY.value > y) {
minY.change(y,i,j);
} else if (maxY.value < y) {
maxY.change(y,i,j);
}
} }
String[] s = a[0].split(","); String[] s = a[0].split(",");
if(s.length <= 0){ if(s.length <= 0){
@ -735,6 +787,8 @@ public class QuestionService implements IQuestionService {
parameter.setLineParameterList(lineParameterList); parameter.setLineParameterList(lineParameterList);
//最长笔画 //最长笔画
parameter.setLongLine(longLine); parameter.setLongLine(longLine);
//最长笔画速度
parameter.setLongSpeed(new BigDecimal(longLine/canvasPoints.size()).setScale(2, BigDecimal.ROUND_HALF_UP));
//最短笔画 //最短笔画
parameter.setShortLine(shortLine); parameter.setShortLine(shortLine);
//思考总时长 //思考总时长
@ -742,13 +796,21 @@ public class QuestionService implements IQuestionService {
// 落笔总时长 // 落笔总时长
parameter.setPaintTime(paintTime); parameter.setPaintTime(paintTime);
//计算中心 //计算中心
int x = minX + ((maxX - minX) / 2); int x = (maxX.value + minX.value) / 2;
int y = minY + ((maxY - minY) / 2); int y = (maxY.value + minY.value) / 2;
String centreCoordinate = x + "," + y; String centreCoordinate = x + "," + y;
parameter.setCentreCoordinate(centreCoordinate); parameter.setCentreCoordinate(centreCoordinate);
//面积 // TODO 重心
double acreage = (maxX - minX) * (maxY - minY); parameter.setBarycenterCoordinate(centreCoordinate);
parameter.setAcreage(acreage); //最小长方形面积
double acreage = (maxX.value - minX.value) * (maxY.value - minY.value);
parameter.setMinRectangleAcreage(acreage);
//最小圆面积 四舍五入
int diameter = maxX.value - minX.value > maxY.value - minY.value ? maxX.value - minX.value : maxY.value - minY.value;
parameter.setMinCircleAcreage(new BigDecimal(Math.PI * diameter * diameter / 4).setScale(2, BigDecimal.ROUND_HALF_UP));
// 四个边界点
setFourPoint(canvasPoints, minX, maxX, minY, maxY);
//平均长度 //平均长度
BigDecimal aveLength = BigDecimal.valueOf(totalLength / canvasPoints.size()).setScale(2, RoundingMode.HALF_UP); BigDecimal aveLength = BigDecimal.valueOf(totalLength / canvasPoints.size()).setScale(2, RoundingMode.HALF_UP);
BigDecimal aveReflectOnTime = BigDecimal.valueOf(reflectOnTime / canvasPoints.size()).setScale(2, RoundingMode.HALF_UP); BigDecimal aveReflectOnTime = BigDecimal.valueOf(reflectOnTime / canvasPoints.size()).setScale(2, RoundingMode.HALF_UP);
@ -766,6 +828,46 @@ public class QuestionService implements IQuestionService {
return parameter; return parameter;
} }
/**
* 设置 四个特殊点
* @param canvasPoints 记录
* @param minX 最左点
* @param maxX 最右点
* @param minY 最上点
* @param maxY 最下点
*/
private void setFourPoint(List<QuestionVo.Point> canvasPoints, PointPosition minX, PointPosition maxX, PointPosition minY, PointPosition maxY) {
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) {
continue;
}
for (int j = 0; j < pointArr.length; j++) {
String s = pointArr[j];
if (StrUtil.isEmpty(s)) {
continue;
}
if (i == minX.line && j == minX.point) {
pointArr[j] += ",1";
} else if (i == maxX.line && j == maxX.point) {
pointArr[j] += ",2";
} else if (i == minY.line && j == minY.point) {
pointArr[j] += ",3";
} else if (i == maxY.line && j == maxY.point) {
pointArr[j] += ",4";
} else {
pointArr[j] += ",0";
}
}
point.setValue(StringUtils.join(pointArr, ";"));
}
}
@ApiModel("短线和短时间思考数目") @ApiModel("短线和短时间思考数目")
private static class Nums{ private static class Nums{
public int shortNums; public int shortNums;
@ -796,10 +898,10 @@ public class QuestionService implements IQuestionService {
} }
if(referenceReflectOnTime.compareTo(new BigDecimal(lineParameter.getIntervalDuration())) >= 0){ if(referenceReflectOnTime.compareTo(new BigDecimal(lineParameter.getIntervalDuration())) >= 0){
lineParameter.setLengthStatus(Constant.LineColour.REFLECT_ON_STATUS_QUICK); lineParameter.setReflectOnStatus(Constant.LineColour.REFLECT_ON_STATUS_QUICK);
quickNums++; quickNums++;
} else { } else {
lineParameter.setLengthStatus(Constant.LineColour.REFLECT_ON_STATUS_SLOW); lineParameter.setReflectOnStatus(Constant.LineColour.REFLECT_ON_STATUS_SLOW);
} }
} }
} }

3
ht/src/main/resources/application-dev.yml

@ -8,7 +8,8 @@ spring:
datasource: datasource:
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource
rabbitmq: rabbitmq:
host: 127.0.0.1 host: 192.168.31.13
# host: 127.0.0.1
password: 111111 password: 111111
port: 5672 port: 5672
username: admin username: admin

8
tall/src/main/resources/application-dev.yml

@ -11,11 +11,11 @@ spring:
datasource: datasource:
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource
rabbitmq: rabbitmq:
# host: 192.168.0.99 host: 192.168.31.13
host: 127.0.0.1 # host: 127.0.0.1
password: guest password: 111111
port: 5672 port: 5672
username: guest username: admin
redis: redis:
database: 0 database: 0
host: 127.0.0.1 host: 127.0.0.1

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

@ -1,4 +1,4 @@
spring: spring:
profiles: profiles:
active: test active: dev
include: util-test,common include: util-dev,common
Loading…
Cancel
Save