caozixuan 4 жил өмнө
parent
commit
92fab0a285

+ 15 - 0
distributed-print-business/pom.xml

@@ -86,6 +86,21 @@
 			<artifactId>easyexcel</artifactId>
 			<version>2.2.8</version>
 		</dependency>
+        <dependency>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi</artifactId>
+            <version>3.17</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi-ooxml</artifactId>
+            <version>3.17</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi-ooxml-schemas</artifactId>
+            <version>3.17</version>
+        </dependency>
     </dependencies>
 
 </project>

+ 6 - 3
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/BasicAttachmentServiceImpl.java

@@ -244,9 +244,12 @@ public class BasicAttachmentServiceImpl extends ServiceImpl<BasicAttachmentMappe
 
             JSONObject jsonObject = new JSONObject();
             stringJoiner.add(File.separator).add(SystemConstant.getUuid()).add(format);
-            if (oss) {//上传至oss
-                ossUtil.ossUpload(stringJoiner.toString(), file.getInputStream(), BinaryUtil.toBase64String(HexUtils.decodeHex(md5)));
+            if (oss) {//上传至oss\
+                String dirName = stringJoiner.toString();
+                dirName = dirName.replaceAll("\\\\", "/");
+                ossUtil.ossUpload(dirName, file.getInputStream(), BinaryUtil.toBase64String(HexUtils.decodeHex(md5)));
                 jsonObject.put(SystemConstant.TYPE, SystemConstant.OSS);
+                jsonObject.put(SystemConstant.PATH, dirName);
             } else {//上传至服务器
                 File finalFile = new File(stringJoiner.toString());
                 if (!finalFile.exists()) {
@@ -255,8 +258,8 @@ public class BasicAttachmentServiceImpl extends ServiceImpl<BasicAttachmentMappe
                 }
                 FileUtils.copyInputStreamToFile(file.getInputStream(), finalFile);
                 jsonObject.put(SystemConstant.TYPE, SystemConstant.LOCAL);
+                jsonObject.put(SystemConstant.PATH, stringJoiner.toString());
             }
-            jsonObject.put(SystemConstant.PATH, stringJoiner.toString());
             jsonObject.put(SystemConstant.UPLOAD_TYPE, type);
 
             basicAttachment = new BasicAttachment(jsonObject.toJSONString(), fileName, format, b, fileMd5, requestUser.getId(), objId);

+ 44 - 54
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/execute/AsyncExaminationImportTemplateService.java

@@ -3,6 +3,7 @@ package com.qmth.distributed.print.business.templete.execute;
 import com.alibaba.excel.ExcelReader;
 import com.alibaba.excel.support.ExcelTypeEnum;
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.qmth.distributed.print.business.bean.dto.FieldsDto;
 import com.qmth.distributed.print.business.entity.ExamPrintPlan;
@@ -47,66 +48,55 @@ public class AsyncExaminationImportTemplateService extends AsyncImportTaskTemple
     public Result importTask(Map<String, Object> map) throws IOException {
         TBTask tbTask = (TBTask) map.get(SystemConstant.TASK);
         System.out.println("printPlanId = " + tbTask.getPrintPlanId());
+        System.out.println("------开始----------");
         InputStream inputStream = super.getUploadFileInputStream(tbTask);
+        System.out.println("------结束----------");
         StringJoiner stringJoinerSummary = new StringJoiner("\n")
                 .add(MessageFormat.format("{0}{1}{2}", FORMAT_TIME, BEGIN_TITLE, OBJ_TITLE));
         tbTask.setStatus(TaskStatusEnum.RUNNING);
-        try {
-            ExaminationListener listener = new ExaminationListener();
+        // try
+
+            String importFilePath = tbTask.getImportFilePath();
+            Map importFilePathMap = JSONObject.parseObject(importFilePath);
+            String path = String.valueOf(importFilePathMap.get("path"));
+            System.out.println("path = " + path);
+//            // 该学校有效考务数据
+//            List<FieldsDto> fieldsDtoList = examDetailService.findExaminationFields(tbTask.getSchoolId());
+//            if (fieldsDtoList.size() == 0){
+//                throw ExceptionResultEnum.ERROR.exception("该学校没有设置考务数据");
+//            }
+//            for (FieldsDto fieldsDto : fieldsDtoList) {
+//                if (!headerList.contains(fieldsDto.getName())){
+//                    System.out.println("exception " + fieldsDto.getName());
+//                    throw ExceptionResultEnum.ERROR.exception("学校考务必填字段 :'" + fieldsDto.getName() + "' 不存在");
+//                }
+//            }
+//            for (FieldsDto fieldsDto : fieldsDtoList) {
+//                String name = fieldsDto.getName();
+//                String code = fieldsDto.getCode();
+//                for (int i = 0;i < headerList.size();i++){
+//                    String headName = headerList.get(i);
+//                    if (name.equals(headName)){
+//                        fieldsDto.setIndex(i);
+//                    }
+//                }
+//            }
+//
+//            // 组装exam_detail数据
+//            Long schoolId = tbTask.getSchoolId();
+//            Long printPlanId = tbTask.getPrintPlanId();
+//            List<ExamPrintPlan> examPrintPlanList = examPrintPlanService.list(new QueryWrapper<ExamPrintPlan>().lambda().eq(ExamPrintPlan::getSchoolId,schoolId).eq(ExamPrintPlan::getId,printPlanId));
+//            if (examPrintPlanList.size() != 1){
+//                throw ExceptionResultEnum.ERROR.exception("没有找到对应的考试计划");
+//            }
+//            String printPlanName = examPrintPlanList.get(0).getName();
+//            int examPlaceIndex = fieldsDtoList.stream().filter(e -> "examPlace".equals(e.getCode())).map(FieldsDto::getIndex).collect(Collectors.toList()).get(0);
+//
+//            // 组装exam_detail_course数据
+//
+//            // 组装exam_student数据
 
-            ExcelReader excelReader = new ExcelReader(inputStream, ExcelTypeEnum.XLSX, null, listener);
-            excelReader.read();
-            // 解析的excel数据
-            List<Map<Integer, String>> dataList = listener.getDataList();
-            System.out.println(JSON.toJSONString(dataList));
 
-            // 表头列表
-            List<String> headerList = (List<String>) dataList.get(0);
-            // 该学校有效考务数据
-            List<FieldsDto> fieldsDtoList = examDetailService.findExaminationFields(tbTask.getSchoolId());
-            if (fieldsDtoList.size() == 0){
-                throw ExceptionResultEnum.ERROR.exception("该学校没有设置考务数据");
-            }
-            for (FieldsDto fieldsDto : fieldsDtoList) {
-                if (!headerList.contains(fieldsDto.getName())){
-                    System.out.println("exception " + fieldsDto.getName());
-                    throw ExceptionResultEnum.ERROR.exception("学校考务必填字段 :'" + fieldsDto.getName() + "' 不存在");
-                }
-            }
-            for (FieldsDto fieldsDto : fieldsDtoList) {
-                String name = fieldsDto.getName();
-                String code = fieldsDto.getCode();
-                for (int i = 0;i < headerList.size();i++){
-                    String headName = headerList.get(i);
-                    if (name.equals(headName)){
-                        fieldsDto.setIndex(i);
-                    }
-                }
-            }
-
-            // 组装exam_detail数据
-            Long schoolId = tbTask.getSchoolId();
-            Long printPlanId = tbTask.getPrintPlanId();
-            List<ExamPrintPlan> examPrintPlanList = examPrintPlanService.list(new QueryWrapper<ExamPrintPlan>().lambda().eq(ExamPrintPlan::getSchoolId,schoolId).eq(ExamPrintPlan::getId,printPlanId));
-            if (examPrintPlanList.size() != 1){
-                throw ExceptionResultEnum.ERROR.exception("没有找到对应的考试计划");
-            }
-            String printPlanName = examPrintPlanList.get(0).getName();
-            int examPlaceIndex = fieldsDtoList.stream().filter(e -> "examPlace".equals(e.getCode())).map(FieldsDto::getIndex).collect(Collectors.toList()).get(0);
-
-            // 组装exam_detail_course数据
-
-            // 组装exam_student数据
-
-
-
-
-
-        }catch (Exception e){
-
-        }finally {
-
-        }
         return null;
     }
 }

+ 1 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/util/OssUtil.java

@@ -55,7 +55,7 @@ public class OssUtil {
             // 设置MD5校验。
             meta.setContentMD5(md5);
         }
-        PutObjectRequest putObjectRequest = new PutObjectRequest(this.aliYunOssDomain.getBucket(), dirName.replaceAll("\\\\", "/"), inputStream);
+        PutObjectRequest putObjectRequest = new PutObjectRequest(this.aliYunOssDomain.getBucket(), dirName, inputStream);
         PutObjectResult por = this.ossClient.putObject(putObjectRequest);
         log.info("dirName:{},requestid:{}", dirName, por.getRequestId());
     }