|
@@ -34,6 +34,11 @@ import com.zhongzheng.modules.exam.service.IExamKnowledgeService;
|
|
|
import com.zhongzheng.modules.goods.bo.GoodsQueryBo;
|
|
import com.zhongzheng.modules.goods.bo.GoodsQueryBo;
|
|
|
import com.zhongzheng.modules.goods.vo.GoodsUserQuestionVo;
|
|
import com.zhongzheng.modules.goods.vo.GoodsUserQuestionVo;
|
|
|
import io.micrometer.core.lang.NonNull;
|
|
import io.micrometer.core.lang.NonNull;
|
|
|
|
|
+import org.apache.poi.hwpf.extractor.WordExtractor;
|
|
|
|
|
+import org.apache.poi.ooxml.POIXMLDocument;
|
|
|
|
|
+import org.apache.poi.ooxml.extractor.POIXMLTextExtractor;
|
|
|
|
|
+import org.apache.poi.openxml4j.opc.OPCPackage;
|
|
|
|
|
+import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
|
|
|
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
|
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -329,9 +334,26 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void importWordQuestion(MultipartFile file) {
|
|
public void importWordQuestion(MultipartFile file) {
|
|
|
|
|
+ String buffer = "";
|
|
|
try{
|
|
try{
|
|
|
- /* InputStream inputStream = baseInfoFile.getInputStream();
|
|
|
|
|
- XWPFDocument doc = new XWPFDocument(inputStream);*/
|
|
|
|
|
|
|
+ String path = file.getOriginalFilename();
|
|
|
|
|
+ if (path.endsWith(".doc")) {
|
|
|
|
|
+ InputStream is = file.getInputStream();
|
|
|
|
|
+
|
|
|
|
|
+ WordExtractor wordExtractor = new WordExtractor(is);
|
|
|
|
|
+ buffer = wordExtractor.getText();
|
|
|
|
|
+ wordExtractor.close();
|
|
|
|
|
+ System.out.println("CC");
|
|
|
|
|
+ System.out.println(buffer);
|
|
|
|
|
+ } else if (path.endsWith("docx")) {
|
|
|
|
|
+ OPCPackage opcPackage = POIXMLDocument.openPackage(path);
|
|
|
|
|
+ POIXMLTextExtractor extractor = new XWPFWordExtractor(opcPackage);
|
|
|
|
|
+ buffer = extractor.getText();
|
|
|
|
|
+ extractor.close();
|
|
|
|
|
+ System.out.println(buffer);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ System.out.println("此文件不是word文件!");
|
|
|
|
|
+ }
|
|
|
}catch (Exception e){
|
|
}catch (Exception e){
|
|
|
|
|
|
|
|
}
|
|
}
|