|
@@ -16,6 +16,7 @@ import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
|
import com.qmth.teachcloud.common.entity.SysUser;
|
|
|
import com.qmth.teachcloud.common.enums.mark.MarkPaperStatus;
|
|
|
import com.qmth.teachcloud.common.service.BasicRoleDataPermissionService;
|
|
|
+import com.qmth.teachcloud.common.service.FileUploadService;
|
|
|
import com.qmth.teachcloud.common.service.TeachcloudCommonService;
|
|
|
import com.qmth.teachcloud.common.util.HttpUtil;
|
|
|
import com.qmth.teachcloud.common.util.ServletUtil;
|
|
@@ -37,7 +38,9 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
+import java.nio.file.Files;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
@@ -67,6 +70,8 @@ public class ScanAnswerCardServiceImpl extends ServiceImpl<ScanAnswerCardMapper,
|
|
|
private TeachcloudCommonService teachcloudCommonService;
|
|
|
@Resource
|
|
|
private FileStoreUtils fileStoreUtils;
|
|
|
+ @Resource
|
|
|
+ private FileUploadService fileUploadService;
|
|
|
|
|
|
@Override
|
|
|
public ScanAnswerCard findByExamAndNumber(Long examId, Integer cardNumber) {
|
|
@@ -288,23 +293,18 @@ public class ScanAnswerCardServiceImpl extends ServiceImpl<ScanAnswerCardMapper,
|
|
|
if (scanAnswerCard != null && StringUtils.isNotBlank(scanAnswerCard.getAdapteUri())) {
|
|
|
FilePathVo filePathVo = JSON.parseObject(scanAnswerCard.getAdapteUri(), FilePathVo.class);
|
|
|
if (filePathVo != null && StringUtils.isNotBlank(filePathVo.getPath())) {
|
|
|
- String url = fileStoreUtils.getPrivateUrl(filePathVo.getPath(), filePathVo.getUploadType().getFssType());
|
|
|
- try {
|
|
|
- String jsonContent = HttpUtil.get(url, null, null, null);
|
|
|
- if (StringUtils.isNotBlank(jsonContent)) {
|
|
|
- AnswerCard answerCard = JSON.parseObject(jsonContent, AnswerCard.class);
|
|
|
- if (answerCard != null && CollectionUtils.isNotEmpty(answerCard.getPages())) {
|
|
|
- int pageIndex = 1;
|
|
|
- for (AnswerCardPage page : answerCard.getPages()) {
|
|
|
- if (page.getExchange() != null && StringUtils.isNotBlank(page.getExchange().getPageImage())) {
|
|
|
- String pageImage = page.getExchange().getPageImage().replaceAll("\\r\\n", "");
|
|
|
- cardJpgResultList.add(new CardJpgResult("page" + pageIndex, pageIndex, "data:image/png;base64," + pageImage));
|
|
|
- }
|
|
|
+ String jsonContent = SystemConstant.readJson(fileUploadService.downloadFile(filePathVo.getPath(), filePathVo.getUploadType(), filePathVo.getType()));
|
|
|
+ if (StringUtils.isNotBlank(jsonContent)) {
|
|
|
+ AnswerCard answerCard = JSON.parseObject(jsonContent, AnswerCard.class);
|
|
|
+ if (answerCard != null && CollectionUtils.isNotEmpty(answerCard.getPages())) {
|
|
|
+ int pageIndex = 1;
|
|
|
+ for (AnswerCardPage page : answerCard.getPages()) {
|
|
|
+ if (page.getExchange() != null && StringUtils.isNotBlank(page.getExchange().getPageImage())) {
|
|
|
+ String pageImage = page.getExchange().getPageImage().replaceAll("\\r\\n", "");
|
|
|
+ cardJpgResultList.add(new CardJpgResult("page" + pageIndex, pageIndex, "data:image/png;base64," + pageImage));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- } catch (IOException e) {
|
|
|
- return cardJpgResultList;
|
|
|
}
|
|
|
}
|
|
|
}
|