|
@@ -541,10 +541,14 @@ public class KmtExerciseQuestionDealServiceImpl implements KmtExerciseQuestionDe
|
|
|
|
|
|
@Override
|
|
|
public ResponseEntity removeQuestionNumMark(String userId, QuestionNumMarkRemoveVo request) {
|
|
|
+ ResponseEntity responseEntity = new ResponseEntity();
|
|
|
+ if (request.getStartX() < 0 || request.getStartY() < 0 || request.getEndX() < 0 || request.getEndY() < 0){
|
|
|
+ return responseEntity.failure("请把坐标定位在图片内");
|
|
|
+ }
|
|
|
+
|
|
|
KmtExerciseQuestion kmtExerciseQuestion = kmtExerciseQuestionService.getById(request.getQuestionId());
|
|
|
kmtExerciseMapper.updateQuestionStartPointAndEndPoint(request.getStartX(), request.getStartY(),
|
|
|
request.getEndX(), request.getEndY(), request.getQuestionId());
|
|
|
- ResponseEntity responseEntity = new ResponseEntity();
|
|
|
TbLibManager manager = bookManagerDao.findByUserIdAndType(userId, 18);
|
|
|
if (manager != null && kmtExerciseQuestion != null && kmtExerciseQuestion.getDealStatus() > 3 && kmtExerciseQuestion.getDealStatus() != 7) {
|
|
|
String path = this.removeQuestionNumMark(request.getStartX(), request.getStartY(), request.getEndX(), request.getEndY(), kmtExerciseQuestion.getImage());
|
|
@@ -612,9 +616,13 @@ public class KmtExerciseQuestionDealServiceImpl implements KmtExerciseQuestionDe
|
|
|
String fileName = relatePath.substring(relatePath.lastIndexOf("/") + 1, relatePath.lastIndexOf("."));
|
|
|
String resultFilePath = prefix + dir + "result_" + fileName + relatePath.substring(relatePath.lastIndexOf("."));
|
|
|
// OSSUtils.downloadFile(resultFilePath, relatePath.substring(1));
|
|
|
- drawImagePartColorByPosition(startX, startY, endX, endY, resultFilePath, relatePath);
|
|
|
- OSSUtils.uploadFile(resultFilePath, resultFilePath.replace(prefix + "/", ""));
|
|
|
- return resultFilePath.replace(prefix, "");
|
|
|
+ boolean result = drawImagePartColorByPosition(startX, startY, endX, endY, resultFilePath, relatePath);
|
|
|
+ if (result){
|
|
|
+ OSSUtils.uploadFile(resultFilePath, resultFilePath.replace(prefix + "/", ""));
|
|
|
+ return resultFilePath.replace(prefix, "");
|
|
|
+ } else {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -625,8 +633,9 @@ public class KmtExerciseQuestionDealServiceImpl implements KmtExerciseQuestionDe
|
|
|
* @param maxy
|
|
|
* @param filePath
|
|
|
*/
|
|
|
- public void drawImagePartColorByPosition (int minx, int miny, int maxx, int maxy, String filePath, String relatePath) {
|
|
|
+ public boolean drawImagePartColorByPosition (int minx, int miny, int maxx, int maxy, String filePath, String relatePath) {
|
|
|
BufferedImage bi = null;
|
|
|
+ boolean result = true;
|
|
|
try {
|
|
|
//有宽高的才处理
|
|
|
if (maxx > 0 && maxy > 0){
|
|
@@ -653,7 +662,9 @@ public class KmtExerciseQuestionDealServiceImpl implements KmtExerciseQuestionDe
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
logger.error("异常", e);
|
|
|
+ result = false;
|
|
|
}
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
/**
|