|
|
@ -15,6 +15,7 @@ import com.ccsens.ht.persist.mapper.*; |
|
|
|
import com.ccsens.ht.uitl.Constant; |
|
|
|
import com.ccsens.util.*; |
|
|
|
import com.ccsens.util.exception.BaseException; |
|
|
|
import io.swagger.annotations.ApiModel; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
@ -571,7 +572,7 @@ public class QuestionService implements IQuestionService { |
|
|
|
List<QuestionVo.Point> canvasPoints = getCanvasPoints(htPatientCanvas); |
|
|
|
patientCanvas.setPoints(canvasPoints); |
|
|
|
//计算参数
|
|
|
|
QuestionVo.Parameter parameter = getParameter(htPatientCanvas); |
|
|
|
QuestionVo.Parameter parameter = getParameter(htPatientCanvas, param); |
|
|
|
patientCanvas.setParameters(parameter); |
|
|
|
canvasList.add(patientCanvas); |
|
|
|
}); |
|
|
@ -614,9 +615,10 @@ public class QuestionService implements IQuestionService { |
|
|
|
/** |
|
|
|
* 统计画图的参数 |
|
|
|
* @param htPatientCanvas 画板信息 |
|
|
|
* @param param 请求参数 参考长度 参考思考时间 |
|
|
|
* @return 返回此次画图的参数 |
|
|
|
*/ |
|
|
|
private QuestionVo.Parameter getParameter(HtPatientCanvas htPatientCanvas) { |
|
|
|
private QuestionVo.Parameter getParameter(HtPatientCanvas htPatientCanvas, QuestionDto.QueryPatientCanvas param) { |
|
|
|
QuestionVo.Parameter parameter = new QuestionVo.Parameter(); |
|
|
|
//开始画图时长:打开画板到第一笔画图时长
|
|
|
|
parameter.setStartDuration(htPatientCanvas.getBeginTime() - htPatientCanvas.getOpenCanvasTime()); |
|
|
@ -654,6 +656,8 @@ public class QuestionService implements IQuestionService { |
|
|
|
double shortLine = 0; |
|
|
|
//思考总时间 每笔间隔相加
|
|
|
|
long reflectOnTime = 0; |
|
|
|
// 落笔总时间(所有笔画绘图时间)
|
|
|
|
long paintTime = 0; |
|
|
|
//X最小值
|
|
|
|
int minX = 0; |
|
|
|
//X最大值
|
|
|
@ -664,6 +668,7 @@ public class QuestionService implements IQuestionService { |
|
|
|
int maxY = 0; |
|
|
|
//总长度
|
|
|
|
double totalLength = 0; |
|
|
|
|
|
|
|
for(QuestionVo.Point canvas : canvasPoints){ |
|
|
|
//时间
|
|
|
|
QuestionVo.LineParameter lineParameter = new QuestionVo.LineParameter(); |
|
|
@ -711,6 +716,8 @@ public class QuestionService implements IQuestionService { |
|
|
|
speed = BigDecimal.valueOf(length / duration).setScale(2, RoundingMode.HALF_UP).doubleValue(); |
|
|
|
} |
|
|
|
lineParameter.setSpeed(speed); |
|
|
|
// 落笔总时间
|
|
|
|
paintTime += Long.parseLong(e[e.length - 1]) - Long.parseLong(a[a.length - 1]); |
|
|
|
//和上一笔的间隔 & 思考总时长
|
|
|
|
if(Long.parseLong(e[e.length - 1]) == 0){ |
|
|
|
lineParameter.setIntervalDuration(htPatientCanvas.getBeginTime() - htPatientCanvas.getOpenCanvasTime()); |
|
|
@ -723,6 +730,8 @@ public class QuestionService implements IQuestionService { |
|
|
|
lineParameterList.add(lineParameter); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
parameter.setLineParameterList(lineParameterList); |
|
|
|
//最长笔画
|
|
|
|
parameter.setLongLine(longLine); |
|
|
@ -730,6 +739,8 @@ public class QuestionService implements IQuestionService { |
|
|
|
parameter.setShortLine(shortLine); |
|
|
|
//思考总时长
|
|
|
|
parameter.setReflectOnTime(reflectOnTime); |
|
|
|
// 落笔总时长
|
|
|
|
parameter.setPaintTime(paintTime); |
|
|
|
//计算中心
|
|
|
|
int x = minX + ((maxX - minX) / 2); |
|
|
|
int y = minY + ((maxY - minY) / 2); |
|
|
@ -739,36 +750,62 @@ public class QuestionService implements IQuestionService { |
|
|
|
double acreage = (maxX - minX) * (maxY - minY); |
|
|
|
parameter.setAcreage(acreage); |
|
|
|
//平均长度
|
|
|
|
double aveLength = BigDecimal.valueOf(totalLength / canvasPoints.size()).setScale(2, RoundingMode.HALF_UP).doubleValue(); |
|
|
|
parameter.setAveLength(aveLength); |
|
|
|
BigDecimal aveLength = BigDecimal.valueOf(totalLength / canvasPoints.size()).setScale(2, RoundingMode.HALF_UP); |
|
|
|
BigDecimal aveReflectOnTime = BigDecimal.valueOf(reflectOnTime / canvasPoints.size()).setScale(2, RoundingMode.HALF_UP); |
|
|
|
parameter.setAveLength(aveLength.doubleValue()); |
|
|
|
//短笔画数量
|
|
|
|
double coefficient = 1.00; |
|
|
|
int shortNums = getShortNums(aveLength,coefficient,lineParameterList); |
|
|
|
parameter.setShortNums(shortNums); |
|
|
|
// double coefficient = 1.00;
|
|
|
|
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; |
|
|
|
Nums nums = getShortNums( referenceLength, referenceReflectOnTime, lineParameterList); |
|
|
|
parameter.setShortNums(nums.shortNums); |
|
|
|
//长笔画数量,等于总笔画减去短笔画的数量
|
|
|
|
parameter.setLongNums(lineParameterList.size() - shortNums); |
|
|
|
//TODO 笔画中间值
|
|
|
|
parameter.setLongNums(lineParameterList.size() - nums.shortNums); |
|
|
|
parameter.setQuickNums(nums.quickNums); |
|
|
|
parameter.setSlowNums(lineParameterList.size() - nums.quickNums); |
|
|
|
return parameter; |
|
|
|
} |
|
|
|
|
|
|
|
@ApiModel("短线和短时间思考数目") |
|
|
|
private static class Nums{ |
|
|
|
public int shortNums; |
|
|
|
public int quickNums; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取短笔画的数量 |
|
|
|
* @param aveLength 平均长度 |
|
|
|
* @param coefficient 自定义系数 |
|
|
|
* |
|
|
|
* |
|
|
|
* @param aveLength 参考长度 |
|
|
|
* @param referenceReflectOnTime 参考思考时间 |
|
|
|
* @param lineParameterList 所有笔画的参数 |
|
|
|
* @return 返回短笔画的数量 |
|
|
|
*/ |
|
|
|
private int getShortNums(double aveLength, double coefficient, List<QuestionVo.LineParameter> lineParameterList) { |
|
|
|
private Nums getShortNums(BigDecimal aveLength, BigDecimal referenceReflectOnTime, List<QuestionVo.LineParameter> lineParameterList) { |
|
|
|
Nums nums = new Nums(); |
|
|
|
int shortNums = 0; |
|
|
|
double a = aveLength * coefficient; |
|
|
|
int quickNums = 0; |
|
|
|
// double a = aveLength * coefficient;
|
|
|
|
if(CollectionUtil.isNotEmpty(lineParameterList)){ |
|
|
|
for(QuestionVo.LineParameter lineParameter : lineParameterList){ |
|
|
|
if(lineParameter.getLength() <= a){ |
|
|
|
if(aveLength.compareTo(new BigDecimal(lineParameter.getLength())) >= 0){ |
|
|
|
lineParameter.setLengthStatus(Constant.LineColour.LENGTH_STATUS_SHORT); |
|
|
|
shortNums++; |
|
|
|
} else { |
|
|
|
lineParameter.setLengthStatus(Constant.LineColour.LENGTH_STATUS_LONG); |
|
|
|
} |
|
|
|
|
|
|
|
if(referenceReflectOnTime.compareTo(new BigDecimal(lineParameter.getIntervalDuration())) >= 0){ |
|
|
|
lineParameter.setLengthStatus(Constant.LineColour.REFLECT_ON_STATUS_QUICK); |
|
|
|
quickNums++; |
|
|
|
} else { |
|
|
|
lineParameter.setLengthStatus(Constant.LineColour.REFLECT_ON_STATUS_SLOW); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return shortNums; |
|
|
|
nums.shortNums = shortNums; |
|
|
|
nums.quickNums = quickNums; |
|
|
|
return nums; |
|
|
|
} |
|
|
|
|
|
|
|
private double getLengthByCanvas(String[] canvas) { |
|
|
|