|
|
@ -17,12 +17,12 @@ import com.ccsens.util.*; |
|
|
|
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.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Propagation; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import javax.script.ScriptEngine; |
|
|
@ -133,7 +133,7 @@ public class QuestionService implements IQuestionService { |
|
|
|
|
|
|
|
Integer maxSort = htQuestionDao.selectMaxSort(query.getCode()); |
|
|
|
//查询关联题目
|
|
|
|
if (!StringUtils.isEmpty(question.getRelationCode())) { |
|
|
|
if (!StrUtil.isEmpty(question.getRelationCode())) { |
|
|
|
String[] codes = question.getRelationCode().split(Constant.COMMA); |
|
|
|
HtQuestionExample example = new HtQuestionExample(); |
|
|
|
example.createCriteria().andParentCodeIn(CollectionUtils.arrayToList(codes)); |
|
|
@ -612,6 +612,31 @@ public class QuestionService implements IQuestionService { |
|
|
|
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 画板信息 |
|
|
@ -659,30 +684,57 @@ public class QuestionService implements IQuestionService { |
|
|
|
// 落笔总时间(所有笔画绘图时间)
|
|
|
|
long paintTime = 0; |
|
|
|
//X最小值
|
|
|
|
int minX = 0; |
|
|
|
PointPosition minX = null; |
|
|
|
//X最大值
|
|
|
|
int maxX = 0; |
|
|
|
PointPosition maxX = null; |
|
|
|
//Y最小值
|
|
|
|
int minY = 0; |
|
|
|
PointPosition minY = null; |
|
|
|
//Y最大值
|
|
|
|
int maxY = 0; |
|
|
|
PointPosition maxY = null; |
|
|
|
//总长度
|
|
|
|
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(); |
|
|
|
String[] a = canvas.getValue().split(";"); |
|
|
|
if(a.length <= 0){ |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
//获取最边缘的四个点
|
|
|
|
for (String value : a) { |
|
|
|
for (int j = 0; j < a.length ; j++) { |
|
|
|
|
|
|
|
String value = a[j]; |
|
|
|
String[] split1 = value.split(","); |
|
|
|
minX = Math.min(Integer.parseInt(split1[0]), minX); |
|
|
|
maxX = Math.max(Integer.parseInt(split1[0]), maxX); |
|
|
|
minY = Math.min(Integer.parseInt(split1[1]), minY); |
|
|
|
maxY = Math.max(Integer.parseInt(split1[1]), maxY); |
|
|
|
int x = Integer.parseInt(split1[0]); |
|
|
|
int y = Integer.parseInt(split1[1]); |
|
|
|
if (!hadValue) { |
|
|
|
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(","); |
|
|
|
if(s.length <= 0){ |
|
|
@ -735,6 +787,8 @@ public class QuestionService implements IQuestionService { |
|
|
|
parameter.setLineParameterList(lineParameterList); |
|
|
|
//最长笔画
|
|
|
|
parameter.setLongLine(longLine); |
|
|
|
//最长笔画速度
|
|
|
|
parameter.setLongSpeed(new BigDecimal(longLine/canvasPoints.size()).setScale(2, BigDecimal.ROUND_HALF_UP)); |
|
|
|
//最短笔画
|
|
|
|
parameter.setShortLine(shortLine); |
|
|
|
//思考总时长
|
|
|
@ -742,13 +796,21 @@ public class QuestionService implements IQuestionService { |
|
|
|
// 落笔总时长
|
|
|
|
parameter.setPaintTime(paintTime); |
|
|
|
//计算中心
|
|
|
|
int x = minX + ((maxX - minX) / 2); |
|
|
|
int y = minY + ((maxY - minY) / 2); |
|
|
|
int x = (maxX.value + minX.value) / 2; |
|
|
|
int y = (maxY.value + minY.value) / 2; |
|
|
|
String centreCoordinate = x + "," + y; |
|
|
|
parameter.setCentreCoordinate(centreCoordinate); |
|
|
|
//面积
|
|
|
|
double acreage = (maxX - minX) * (maxY - minY); |
|
|
|
parameter.setAcreage(acreage); |
|
|
|
// TODO 重心
|
|
|
|
parameter.setBarycenterCoordinate(centreCoordinate); |
|
|
|
//最小长方形面积
|
|
|
|
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 aveReflectOnTime = BigDecimal.valueOf(reflectOnTime / canvasPoints.size()).setScale(2, RoundingMode.HALF_UP); |
|
|
@ -766,6 +828,46 @@ public class QuestionService implements IQuestionService { |
|
|
|
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("短线和短时间思考数目") |
|
|
|
private static class Nums{ |
|
|
|
public int shortNums; |
|
|
@ -796,10 +898,10 @@ public class QuestionService implements IQuestionService { |
|
|
|
} |
|
|
|
|
|
|
|
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++; |
|
|
|
} else { |
|
|
|
lineParameter.setLengthStatus(Constant.LineColour.REFLECT_ON_STATUS_SLOW); |
|
|
|
lineParameter.setReflectOnStatus(Constant.LineColour.REFLECT_ON_STATUS_SLOW); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|