|
|
@ -8,18 +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; |
|
|
@ -29,12 +36,11 @@ 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.Executors; |
|
|
|
import java.util.concurrent.ScheduledExecutorService; |
|
|
|
import java.util.concurrent.ScheduledThreadPoolExecutor; |
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
import java.util.concurrent.atomic.AtomicInteger; |
|
|
|
|
|
|
@ -49,7 +55,7 @@ import java.util.concurrent.atomic.AtomicInteger; |
|
|
|
public class QuestionService implements IQuestionService { |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
@Resource |
|
|
|
private Snowflake snowflake; |
|
|
|
@Resource |
|
|
|
private HtQuestionDao htQuestionDao; |
|
|
@ -75,11 +81,8 @@ public class QuestionService implements IQuestionService { |
|
|
|
private HtPatientReportRecordDescDao htPatientReportRecordDescDao; |
|
|
|
@Resource |
|
|
|
private HtQuestionShowDao htQuestionShowDao; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
private AmqpTemplate rabbitTemplate; |
|
|
|
|
|
|
|
@Override |
|
|
|
public QuestionVo.Query queryQuestion(QuestionDto.Query query, Long userId) { |
|
|
@ -199,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) { |
|
|
@ -242,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); |
|
|
|
} |
|
|
@ -262,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 { |
|
|
@ -296,22 +299,37 @@ public class QuestionService implements IQuestionService { |
|
|
|
return CodeEnum.SUCCESS; |
|
|
|
} |
|
|
|
log.info("执行提交后的任务"); |
|
|
|
ScheduledExecutorService executor = Executors.newScheduledThreadPool(shows.size()); |
|
|
|
ScheduledExecutorService executor = new ScheduledThreadPoolExecutor(shows.size(), |
|
|
|
new BasicThreadFactory.Builder().namingPattern("question-schedule-pool-%d").daemon(true).build()); |
|
|
|
|
|
|
|
shows.forEach(show -> { |
|
|
|
switch (show.getShowType()) { |
|
|
|
case Constant.Ht.QuestionShow.SHOW_TYPE_COUNT_DOWN: |
|
|
|
// 倒计时
|
|
|
|
if (show.getShowType() == Constant.Ht.QuestionShow.SHOW_TYPE_COUNT_DOWN) { |
|
|
|
QuestionShowVo.MesTimer mesTimer = JSONObject.parseObject(show.getParam(), QuestionShowVo.MesTimer.class); |
|
|
|
executor.schedule(new Thread(new Runnable() { |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
// TODO 消息推送
|
|
|
|
} |
|
|
|
}), mesTimer.getTime(), TimeUnit.SECONDS); |
|
|
|
break; |
|
|
|
default: |
|
|
|
break; |
|
|
|
|
|
|
|
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; |
|
|
|
} |
|
|
|
|
|
|
@ -332,15 +350,15 @@ 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 && maxSort != null && question.getSort().intValue() >= maxSort) { |
|
|
|
if (question.getSort() != null && maxSort != null && question.getSort() >= maxSort) { |
|
|
|
report.setShowStatus(Constant.Ht.Report.SHOW_HISTORY); |
|
|
|
htPatientReportMapper.updateByPrimaryKeySelective(report); |
|
|
|
} |
|
|
@ -351,16 +369,17 @@ public class QuestionService implements IQuestionService { |
|
|
|
HtPatientQuestionRecordExample example = new HtPatientQuestionRecordExample(); |
|
|
|
String type; |
|
|
|
switch (question.getOperateType()) { |
|
|
|
|
|
|
|
case Constant.Ht.Operation.VOICE://语音
|
|
|
|
|
|
|
|
case Constant.Ht.Operation.KNOCK://敲击
|
|
|
|
//语音
|
|
|
|
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: //画图
|
|
|
|
//画图
|
|
|
|
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: |
|
|
@ -404,9 +423,9 @@ public class QuestionService implements IQuestionService { |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询试题正确个数 |
|
|
|
* @param scores |
|
|
|
* @return |
|
|
|
* 计算试题正确个数 |
|
|
|
* @param scores 分数 |
|
|
|
* @return 正确格式 |
|
|
|
*/ |
|
|
|
private int getCurrentNum(List<HtPatientScore> scores) { |
|
|
|
if (CollectionUtil.isEmpty(scores)) { |
|
|
@ -430,15 +449,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<>(); |
|
|
@ -462,13 +479,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) { |
|
|
@ -494,8 +511,8 @@ 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 key = "isAutoformula"; |
|
|
|
if (remark.getIntValue(key) == 1) { |
|
|
|
String formulaSymbol = remark.getString("formulaSymbol"); |
|
|
|
String[] params = remark.getString("formulaName").split(","); |
|
|
|
StringBuilder formula = new StringBuilder(); |
|
|
@ -512,8 +529,8 @@ public class QuestionService implements IQuestionService { |
|
|
|
log.error("计算出现异常", e); |
|
|
|
throw new BaseException(CodeEnum.PARAM_ERROR); |
|
|
|
} |
|
|
|
break; |
|
|
|
default: patientScore.setScore(questionOption.getScore());break; |
|
|
|
} else { |
|
|
|
patientScore.setScore(questionOption.getScore()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -613,7 +630,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; |
|
|
@ -678,7 +696,7 @@ public class QuestionService implements IQuestionService { |
|
|
|
/** |
|
|
|
* 统计画图的参数 |
|
|
|
* |
|
|
|
* @param question |
|
|
|
* @param question 题目 |
|
|
|
* @param htPatientCanvas 画板信息 |
|
|
|
* @param param 请求参数 参考长度 参考思考时间 |
|
|
|
* @return 返回此次画图的参数 |
|
|
@ -735,7 +753,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); |
|
|
@ -825,15 +843,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); |
|
|
|
} |
|
|
|
|
|
|
@ -859,38 +869,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); |
|
|
@ -916,6 +914,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 记录 |
|
|
@ -925,14 +953,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 下
|
|
|
@ -952,17 +985,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;
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1004,7 +1029,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 { |
|
|
@ -1040,7 +1065,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)); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|