|
@@ -540,15 +540,18 @@ public class KmtExerciseQuestionDealServiceImpl implements KmtExerciseQuestionDe
|
|
|
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.getDealStatus() > 3 && kmtExerciseQuestion.getDealStatus() != 7){
|
|
|
- this.removeQuestionNumMark(request.getStartX(), request.getStartY(), request.getEndX(), request.getEndY(), kmtExerciseQuestion.getImage());
|
|
|
+ String path = this.removeQuestionNumMark(request.getStartX(), request.getStartY(), request.getEndX(), request.getEndY(), kmtExerciseQuestion.getImage());
|
|
|
+ String content = JSONFileUtil.readJSONFile(PropertiesUtil.getValue("EXERCISE_JSON_FILE_PATH") + kmtExerciseQuestion.getQuestionPath());
|
|
|
+ if (StringUtil.isNotBlank(content) && StringUtil.isNotBlank(path)){
|
|
|
+ Map<String, Object> map = JSON.parseObject(content, Map.class);
|
|
|
+ map.put("question_json", Collections.singletonList(ExerciseUtil.getExerciseQuestionAnswerValue(PropertiesUtil.getValue("STATIC_FILE_URL") + path)));
|
|
|
+ JSONFileUtil.saveJSONFile(PropertiesUtil.getValue("EXERCISE_JSON_FILE_PATH") + kmtExerciseQuestion.getQuestionPath(), JSON.toJSONString(map));
|
|
|
}
|
|
|
return responseEntity.success("成功");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void removeQuestionNumMark(int startX, int startY, int endX, int endY, String filePath) {
|
|
|
+ public String removeQuestionNumMark(int startX, int startY, int endX, int endY, String filePath) {
|
|
|
int temp = 0;
|
|
|
if (startX > endX){
|
|
|
temp = startX;
|
|
@@ -560,12 +563,14 @@ public class KmtExerciseQuestionDealServiceImpl implements KmtExerciseQuestionDe
|
|
|
startY = endY;
|
|
|
endY = temp;
|
|
|
}
|
|
|
+ String result = null;
|
|
|
if (StringUtil.isNotBlank(filePath) && endX > 0 && endY > 0){
|
|
|
//1、查询是否有备份图片,没有的话新增一个备份图片
|
|
|
- this.checkBakImage(filePath);
|
|
|
+ //this.checkBakImage(filePath);
|
|
|
//2、生成一个临时图片, 图片区域填充, 临时图片要随机, 把图片上传到oss
|
|
|
- this.createNewFile(startX, startY, endX, endY, filePath);
|
|
|
+ result = this.createNewFile(startX, startY, endX, endY, filePath);
|
|
|
}
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -591,18 +596,14 @@ public class KmtExerciseQuestionDealServiceImpl implements KmtExerciseQuestionDe
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void createNewFile (int startX, int startY, int endX, int endY, String relatePath) {
|
|
|
- String tempPath = "/www/files/data/upload/ai/picture_bak/temp/";
|
|
|
- String tempFilePath = tempPath + IdWorker.generateId() + relatePath.substring(relatePath.lastIndexOf("."));
|
|
|
- File dirFile = new File(tempPath);
|
|
|
- if (!dirFile.exists()){
|
|
|
- dirFile.mkdirs();
|
|
|
- }
|
|
|
- OSSUtils.downloadFile(tempFilePath, relatePath.substring(1));
|
|
|
- drawImagePartColorByPosition(startX, startY, endX, endY, tempFilePath);
|
|
|
- OSSUtils.uploadFile(tempFilePath, relatePath.substring(1));
|
|
|
- File tempFile = new File(tempFilePath);
|
|
|
- tempFile.delete();
|
|
|
+ private String createNewFile (int startX, int startY, int endX, int endY, String relatePath) {
|
|
|
+ String dir = relatePath.substring(0, relatePath.lastIndexOf("/") + 1);
|
|
|
+ String fileName = relatePath.substring(relatePath.lastIndexOf("/") + 1, relatePath.lastIndexOf("."));
|
|
|
+ String resultFilePath = dir + "result_" + fileName + relatePath.substring(relatePath.lastIndexOf("."));
|
|
|
+ OSSUtils.downloadFile(resultFilePath, relatePath.substring(1));
|
|
|
+ drawImagePartColorByPosition(startX, startY, endX, endY, resultFilePath);
|
|
|
+ OSSUtils.uploadFile(resultFilePath, resultFilePath.replace(PropertiesUtil.getValue("file_save_path") + "/", ""));
|
|
|
+ return resultFilePath.replace(PropertiesUtil.getValue("file_save_path"), "");
|
|
|
}
|
|
|
|
|
|
/**
|