|
@ -521,11 +521,14 @@ public class QuestionService implements IQuestionService { |
|
|
if(CollectionUtil.isNotEmpty(param.getPoints())){ |
|
|
if(CollectionUtil.isNotEmpty(param.getPoints())){ |
|
|
param.getPoints().forEach(point -> { |
|
|
param.getPoints().forEach(point -> { |
|
|
log.info("添加轨迹信息"); |
|
|
log.info("添加轨迹信息"); |
|
|
|
|
|
if (StrUtil.isNotBlank(point)) { |
|
|
HtPatientCanvasLine patientCanvasLine = new HtPatientCanvasLine(); |
|
|
HtPatientCanvasLine patientCanvasLine = new HtPatientCanvasLine(); |
|
|
patientCanvasLine.setId(snowflake.nextId()); |
|
|
patientCanvasLine.setId(snowflake.nextId()); |
|
|
patientCanvasLine.setPatientCanvasId(patientCanvas.getId()); |
|
|
patientCanvasLine.setPatientCanvasId(patientCanvas.getId()); |
|
|
patientCanvasLine.setPoints(point); |
|
|
patientCanvasLine.setPoints(point); |
|
|
patientCanvasLineMapper.insertSelective(patientCanvasLine); |
|
|
patientCanvasLineMapper.insertSelective(patientCanvasLine); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
//查询轨迹信息
|
|
|
//查询轨迹信息
|
|
@ -681,11 +684,13 @@ public class QuestionService implements IQuestionService { |
|
|
parameter.setAveTimes((int) Math.round(canvasPoints.size() / d)); |
|
|
parameter.setAveTimes((int) Math.round(canvasPoints.size() / d)); |
|
|
//每笔数据
|
|
|
//每笔数据
|
|
|
List<QuestionVo.LineParameter> lineParameterList = new ArrayList<>(); |
|
|
List<QuestionVo.LineParameter> lineParameterList = new ArrayList<>(); |
|
|
long intervalDuration = 0; |
|
|
// long intervalDuration = 0;
|
|
|
//最长的笔画
|
|
|
//最长的笔画
|
|
|
double longLine = 0; |
|
|
double longLine = 0; |
|
|
|
|
|
int longIndex = 0; |
|
|
//最短的笔画
|
|
|
//最短的笔画
|
|
|
double shortLine = 0; |
|
|
double shortLine = 0; |
|
|
|
|
|
int shortIndex = 0; |
|
|
//思考总时间 每笔间隔相加
|
|
|
//思考总时间 每笔间隔相加
|
|
|
long reflectOnTime = 0; |
|
|
long reflectOnTime = 0; |
|
|
// 落笔总时间(所有笔画绘图时间)
|
|
|
// 落笔总时间(所有笔画绘图时间)
|
|
@ -761,13 +766,17 @@ public class QuestionService implements IQuestionService { |
|
|
//计算最长最短
|
|
|
//计算最长最短
|
|
|
if(longLine == 0){ |
|
|
if(longLine == 0){ |
|
|
longLine = length; |
|
|
longLine = length; |
|
|
|
|
|
longIndex = i; |
|
|
}else if(length > longLine){ |
|
|
}else if(length > longLine){ |
|
|
longLine = length; |
|
|
longLine = length; |
|
|
|
|
|
longIndex = i; |
|
|
} |
|
|
} |
|
|
if(shortLine == 0){ |
|
|
if(shortLine == 0){ |
|
|
shortLine = length; |
|
|
shortLine = length; |
|
|
|
|
|
shortIndex = i; |
|
|
}else if(length < shortLine){ |
|
|
}else if(length < shortLine){ |
|
|
shortLine = length; |
|
|
shortLine = length; |
|
|
|
|
|
shortIndex = i; |
|
|
} |
|
|
} |
|
|
//速度
|
|
|
//速度
|
|
|
double speed = 0; |
|
|
double speed = 0; |
|
@ -778,24 +787,31 @@ public class QuestionService implements IQuestionService { |
|
|
// 落笔总时间
|
|
|
// 落笔总时间
|
|
|
paintTime += Long.parseLong(e[e.length - 1]) - Long.parseLong(s[s.length - 1]); |
|
|
paintTime += Long.parseLong(e[e.length - 1]) - Long.parseLong(s[s.length - 1]); |
|
|
//和上一笔的间隔 & 思考总时长
|
|
|
//和上一笔的间隔 & 思考总时长
|
|
|
if(Long.parseLong(e[e.length - 1]) == 0){ |
|
|
// if(Long.parseLong(e[e.length - 1]) == 0){
|
|
|
lineParameter.setIntervalDuration(htPatientCanvas.getBeginTime() - htPatientCanvas.getOpenCanvasTime()); |
|
|
// lineParameter.setIntervalDuration(htPatientCanvas.getBeginTime() - htPatientCanvas.getOpenCanvasTime());
|
|
|
reflectOnTime += htPatientCanvas.getBeginTime() - htPatientCanvas.getOpenCanvasTime(); |
|
|
// reflectOnTime += htPatientCanvas.getBeginTime() - htPatientCanvas.getOpenCanvasTime();
|
|
|
}else { |
|
|
// }else {
|
|
|
intervalDuration = Long.parseLong(e[e.length - 1]) - intervalDuration; |
|
|
// intervalDuration = Long.parseLong(e[e.length - 1]) - intervalDuration;
|
|
|
lineParameter.setIntervalDuration(intervalDuration); |
|
|
// lineParameter.setIntervalDuration(intervalDuration);
|
|
|
reflectOnTime += 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(); |
|
|
} |
|
|
} |
|
|
lineParameterList.add(lineParameter); |
|
|
lineParameterList.add(lineParameter); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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); |
|
|
//思考总时长
|
|
|
//思考总时长
|
|
@ -812,11 +828,9 @@ public class QuestionService implements IQuestionService { |
|
|
//最小长方形面积
|
|
|
//最小长方形面积
|
|
|
double acreage = (maxX.value - minX.value) * (maxY.value - minY.value); |
|
|
double acreage = (maxX.value - minX.value) * (maxY.value - minY.value); |
|
|
parameter.setMinRectangleAcreage(acreage); |
|
|
parameter.setMinRectangleAcreage(acreage); |
|
|
//最小圆面积 四舍五入
|
|
|
// 四个边界点 + 最小圆面积 四舍五入 sqrt
|
|
|
int diameter = maxX.value - minX.value > maxY.value - minY.value ? maxX.value - minX.value : maxY.value - minY.value; |
|
|
int radiusSqrt = setFourPoint(canvasPoints, minX, maxX, minY, maxY, x, y); |
|
|
parameter.setMinCircleAcreage(new BigDecimal(Math.PI * diameter * diameter / 4).setScale(2, BigDecimal.ROUND_HALF_UP)); |
|
|
parameter.setMinCircleAcreage(new BigDecimal(Math.PI * radiusSqrt).setScale(2, BigDecimal.ROUND_HALF_UP)); |
|
|
// 四个边界点
|
|
|
|
|
|
setFourPoint(canvasPoints, minX, maxX, minY, maxY); |
|
|
|
|
|
// 计算四个边界点构成的长方形距离画板重心的距离
|
|
|
// 计算四个边界点构成的长方形距离画板重心的距离
|
|
|
int canvasHeight = htPatientCanvas.getCanvasHeight(); |
|
|
int canvasHeight = htPatientCanvas.getCanvasHeight(); |
|
|
int canvasWidth = htPatientCanvas.getCanvasWidth(); |
|
|
int canvasWidth = htPatientCanvas.getCanvasWidth(); |
|
@ -835,11 +849,15 @@ public class QuestionService implements IQuestionService { |
|
|
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); |
|
|
parameter.setAveLength(aveLength.doubleValue()); |
|
|
parameter.setAveLength(aveLength.doubleValue()); |
|
|
|
|
|
parameter.setAveReflectOnTime(aveReflectOnTime.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); |
|
|
//短笔画数量
|
|
|
//短笔画数量
|
|
|
// double coefficient = 1.00;
|
|
|
// double coefficient = 1.00;
|
|
|
BigDecimal referenceLength = param.getReferenceLength() != null && param.getReferenceLength().compareTo(new BigDecimal(0)) > 0 ? param.getReferenceLength() : aveLength; |
|
|
BigDecimal referenceLength = param.getReferenceLength() != null && param.getReferenceLength().compareTo(new BigDecimal(0)) > 0 ? param.getReferenceLength() : aveLength; |
|
|
BigDecimal referenceReflectOnTime = param.getReferenceReflectOnTime() != null && param.getReferenceReflectOnTime().compareTo(new BigDecimal(0)) > 0 ? param.getReferenceReflectOnTime() : aveReflectOnTime; |
|
|
BigDecimal referenceReflectOnTime = param.getReferenceReflectOnTime() != null && param.getReferenceReflectOnTime().compareTo(new BigDecimal(0)) > 0 ? param.getReferenceReflectOnTime() : aveReflectOnTime; |
|
|
Nums nums = getShortNums( referenceLength, referenceReflectOnTime, lineParameterList); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取短笔画数量、快思考数量,计算并赋值最长最短笔画速度
|
|
|
|
|
|
Nums nums = getShortNums( referenceLength, referenceReflectOnTime, lineParameterList, longIndex, shortIndex, parameter); |
|
|
parameter.setShortNums(nums.shortNums); |
|
|
parameter.setShortNums(nums.shortNums); |
|
|
//长笔画数量,等于总笔画减去短笔画的数量
|
|
|
//长笔画数量,等于总笔画减去短笔画的数量
|
|
|
parameter.setLongNums(lineParameterList.size() - nums.shortNums); |
|
|
parameter.setLongNums(lineParameterList.size() - nums.shortNums); |
|
@ -855,8 +873,12 @@ public class QuestionService implements IQuestionService { |
|
|
* @param maxX 最右点 |
|
|
* @param maxX 最右点 |
|
|
* @param minY 最上点 |
|
|
* @param minY 最上点 |
|
|
* @param maxY 最下点 |
|
|
* @param maxY 最下点 |
|
|
|
|
|
* @param x 中心点 x |
|
|
|
|
|
* @param y 中心点 y |
|
|
|
|
|
* @return 点到中心点距离的平方的最大值 |
|
|
*/ |
|
|
*/ |
|
|
private void setFourPoint(List<QuestionVo.Point> canvasPoints, PointPosition minX, PointPosition maxX, PointPosition minY, PointPosition maxY) { |
|
|
private int setFourPoint(List<QuestionVo.Point> canvasPoints, PointPosition minX, PointPosition maxX, PointPosition minY, PointPosition maxY, int x, int y) { |
|
|
|
|
|
int max = 0; |
|
|
for (int i = 0; i < canvasPoints.size(); i++) { |
|
|
for (int i = 0; i < canvasPoints.size(); i++) { |
|
|
QuestionVo.Point point = canvasPoints.get(i); |
|
|
QuestionVo.Point point = canvasPoints.get(i); |
|
|
if (StrUtil.isEmpty(point.getValue())) { |
|
|
if (StrUtil.isEmpty(point.getValue())) { |
|
@ -882,9 +904,17 @@ public class QuestionService implements IQuestionService { |
|
|
} else { |
|
|
} else { |
|
|
pointArr[j] += ",0"; |
|
|
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, ";")); |
|
|
point.setValue(StringUtils.join(pointArr, ";")); |
|
|
} |
|
|
} |
|
|
|
|
|
return max; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -901,15 +931,19 @@ public class QuestionService implements IQuestionService { |
|
|
* @param aveLength 参考长度 |
|
|
* @param aveLength 参考长度 |
|
|
* @param referenceReflectOnTime 参考思考时间 |
|
|
* @param referenceReflectOnTime 参考思考时间 |
|
|
* @param lineParameterList 所有笔画的参数 |
|
|
* @param lineParameterList 所有笔画的参数 |
|
|
|
|
|
* @param longIndex |
|
|
|
|
|
* @param shortIndex |
|
|
|
|
|
* @param parameter |
|
|
* @return 返回短笔画的数量 |
|
|
* @return 返回短笔画的数量 |
|
|
*/ |
|
|
*/ |
|
|
private Nums getShortNums(BigDecimal aveLength, BigDecimal referenceReflectOnTime, List<QuestionVo.LineParameter> lineParameterList) { |
|
|
private Nums getShortNums(BigDecimal aveLength, BigDecimal referenceReflectOnTime, List<QuestionVo.LineParameter> lineParameterList, int longIndex, int shortIndex, QuestionVo.Parameter parameter) { |
|
|
Nums nums = new Nums(); |
|
|
Nums nums = new Nums(); |
|
|
int shortNums = 0; |
|
|
int shortNums = 0; |
|
|
int quickNums = 0; |
|
|
int quickNums = 0; |
|
|
// double a = aveLength * coefficient;
|
|
|
// double a = aveLength * coefficient;
|
|
|
if(CollectionUtil.isNotEmpty(lineParameterList)){ |
|
|
if(CollectionUtil.isNotEmpty(lineParameterList)){ |
|
|
for(QuestionVo.LineParameter lineParameter : lineParameterList){ |
|
|
for (int i = 0; i < lineParameterList.size(); i++) { |
|
|
|
|
|
QuestionVo.LineParameter lineParameter = lineParameterList.get(i); |
|
|
if(aveLength.compareTo(new BigDecimal(lineParameter.getLength())) >= 0){ |
|
|
if(aveLength.compareTo(new BigDecimal(lineParameter.getLength())) >= 0){ |
|
|
lineParameter.setLengthStatus(Constant.LineColour.LENGTH_STATUS_SHORT); |
|
|
lineParameter.setLengthStatus(Constant.LineColour.LENGTH_STATUS_SHORT); |
|
|
shortNums++; |
|
|
shortNums++; |
|
@ -923,6 +957,13 @@ public class QuestionService implements IQuestionService { |
|
|
} else { |
|
|
} else { |
|
|
lineParameter.setReflectOnStatus(Constant.LineColour.REFLECT_ON_STATUS_SLOW); |
|
|
lineParameter.setReflectOnStatus(Constant.LineColour.REFLECT_ON_STATUS_SLOW); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (longIndex == i) { |
|
|
|
|
|
parameter.setLongSpeed(lineParameter.getSpeed()); |
|
|
|
|
|
} |
|
|
|
|
|
if (shortIndex == i) { |
|
|
|
|
|
parameter.setShortSpeed(lineParameter.getSpeed()); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
nums.shortNums = shortNums; |
|
|
nums.shortNums = shortNums; |
|
|