Browse Source

重构OSSUtil工具,根据参数自动判断public/private,提前构造好ossclient对象

luoshi 4 years ago
parent
commit
1b7e5b88a3

+ 53 - 39
themis-backend/src/main/java/com/qmth/themis/backend/api/SysController.java

@@ -87,7 +87,7 @@ public class SysController {
 
     @ApiOperation(value = "菜单查询接口")
     @RequestMapping(value = "/getMenu", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "菜单信息", response = TBPrivilege.class)})
+    @ApiResponses({ @ApiResponse(code = 200, message = "菜单信息", response = TBPrivilege.class) })
     public Result getMenu() {
         TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
         if (Objects.isNull(tbUser)) {
@@ -98,23 +98,24 @@ public class SysController {
 
     @ApiOperation(value = "获取环境接口")
     @RequestMapping(value = "/env", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "环境信息", response = Result.class)})
+    @ApiResponses({ @ApiResponse(code = 200, message = "环境信息", response = Result.class) })
     public Result env(@ApiParam(value = "机构id", required = true) @RequestParam Long orgId) {
         if (Objects.isNull(orgId) || Objects.equals(orgId, "")) {
             throw new BusinessException(ExceptionResultEnum.ORG_ID_IS_NULL);
         }
-//        SchoolDto schoolDto = (SchoolDto) redisTemplate.opsForValue().get(SystemConstant.SCHOOL_CACHE + orgId);
-//        Map map = new HashMap();
-//        map.put(SystemConstant.ENV_FILEHOST, schoolDto.getFileHost());
-//        return ResultUtil.ok(map);
+        //        SchoolDto schoolDto = (SchoolDto) redisTemplate.opsForValue().get(SystemConstant.SCHOOL_CACHE + orgId);
+        //        Map map = new HashMap();
+        //        map.put(SystemConstant.ENV_FILEHOST, schoolDto.getFileHost());
+        //        return ResultUtil.ok(map);
         return ResultUtil.ok(Collections.singletonMap(SystemConstant.SUCCESS, true));
     }
 
     @ApiOperation(value = "上传文件接口")
     @RequestMapping(value = "/file/upload", method = RequestMethod.POST)
     @Transactional
-    @ApiResponses({@ApiResponse(code = 200, message = "{\"id\":0}", response = Result.class)})
-    public Result fileUpload(@ApiParam(value = "上传文件", required = true) @RequestParam MultipartFile file, @ApiParam(value = "上传文件类型", required = true) @RequestParam UploadFileEnum type) throws IOException {
+    @ApiResponses({ @ApiResponse(code = 200, message = "{\"id\":0}", response = Result.class) })
+    public Result fileUpload(@ApiParam(value = "上传文件", required = true) @RequestParam MultipartFile file,
+            @ApiParam(value = "上传文件类型", required = true) @RequestParam UploadFileEnum type) throws IOException {
         if (Objects.isNull(file) || Objects.equals(file, "")) {
             throw new BusinessException(ExceptionResultEnum.ATTACHMENT_IS_NULL);
         }
@@ -128,7 +129,9 @@ public class SysController {
             mapParameter = ossUtil.getAliYunOssPublicDomain().getMap();
         }
         TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
-        TBAttachment tbAttachment = tbAttachmentService.saveAttachment(file, ServletUtil.getRequestMd5(), ServletUtil.getRequestPath(), mapParameter, tbUser.getOrgId(), tbUser.getId());
+        TBAttachment tbAttachment = tbAttachmentService
+                .saveAttachment(file, ServletUtil.getRequestMd5(), ServletUtil.getRequestPath(), mapParameter, type,
+                        tbUser.getOrgId(), tbUser.getId());
         if (Objects.isNull(tbAttachment)) {
             throw new BusinessException(ExceptionResultEnum.ATTACHMENT_ERROR);
         }
@@ -158,8 +161,9 @@ public class SysController {
 
     @ApiOperation(value = "文件下载接口")
     @RequestMapping(value = "/file/download", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "{\"url\":string}", response = Result.class)})
-    public Result fileDownload(@ApiParam(value = "任务id", required = true) @RequestParam Long id, @ApiParam(value = "下载文件类型", required = true) @RequestParam DownloadFileEnum type) {
+    @ApiResponses({ @ApiResponse(code = 200, message = "{\"url\":string}", response = Result.class) })
+    public Result fileDownload(@ApiParam(value = "任务id", required = true) @RequestParam Long id,
+            @ApiParam(value = "下载文件类型", required = true) @RequestParam DownloadFileEnum type) {
         if (Objects.isNull(id) || Objects.equals(id, "")) {
             throw new BusinessException(ExceptionResultEnum.TASK_ID_IS_NULL);
         }
@@ -176,15 +180,15 @@ public class SysController {
         boolean oss = dictionaryConfig.sysDomain().isOss();
         JSONObject jsonObject = null;
         switch (type.getId()) {
-            case 0:
-                jsonObject = JSONObject.parseObject(tbTaskHistory.getImportFilePath());
-                break;
-            case 1:
-                jsonObject = JSONObject.parseObject(tbTaskHistory.getReportFilePath());
-                break;
-            default:
-                jsonObject = JSONObject.parseObject(tbTaskHistory.getResultFilePath());
-                break;
+        case 0:
+            jsonObject = JSONObject.parseObject(tbTaskHistory.getImportFilePath());
+            break;
+        case 1:
+            jsonObject = JSONObject.parseObject(tbTaskHistory.getReportFilePath());
+            break;
+        default:
+            jsonObject = JSONObject.parseObject(tbTaskHistory.getResultFilePath());
+            break;
         }
         if (Objects.isNull(jsonObject) || Objects.isNull(jsonObject.get("path"))) {
             throw new BusinessException("下载文件地址不存在");
@@ -196,7 +200,7 @@ public class SysController {
                 String[] strs = filePath.split("/");
                 Integer fileId = UploadFileEnum.convertToId(strs[0]);
                 if (fileId == 3) {
-                    url = OssUtil.getUrlForPrivateBucket(ossUtil.getAliYunOssPrivateDomain().getMap(), filePath);
+                    url = ossUtil.getPrivateUrl(filePath);
                 } else {
                     url = dictionaryConfig.aliYunOssDomain().getPublicUrl() + File.separator + filePath;
                 }
@@ -209,7 +213,7 @@ public class SysController {
 
     @ApiOperation(value = "根据机构代码查询机构信息接口")
     @RequestMapping(value = "/org/queryByOrgCode", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "机构信息", response = TBOrg.class)})
+    @ApiResponses({ @ApiResponse(code = 200, message = "机构信息", response = TBOrg.class) })
     public Result queryByOrgCode(@ApiParam(value = "机构code", required = true) @RequestParam String code) {
         if (Objects.isNull(code) || Objects.equals(code, "")) {
             throw new BusinessException(ExceptionResultEnum.ORG_CODE_IS_NULL);
@@ -235,8 +239,11 @@ public class SysController {
 
     @ApiOperation(value = "机构查询接口")
     @RequestMapping(value = "/org/query", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "机构信息", response = TBOrg.class)})
-    public Result query(@ApiParam(value = "机构id", required = false) @RequestParam(required = false) Long id, @ApiParam(value = "机构代码", required = false) @RequestParam(required = false) String code, @ApiParam(value = "机构名称", required = false) @RequestParam(required = false) String name, @ApiParam(value = "是否启用", required = false) @RequestParam(required = false) Integer enable) {
+    @ApiResponses({ @ApiResponse(code = 200, message = "机构信息", response = TBOrg.class) })
+    public Result query(@ApiParam(value = "机构id", required = false) @RequestParam(required = false) Long id,
+            @ApiParam(value = "机构代码", required = false) @RequestParam(required = false) String code,
+            @ApiParam(value = "机构名称", required = false) @RequestParam(required = false) String name,
+            @ApiParam(value = "是否启用", required = false) @RequestParam(required = false) Integer enable) {
         QueryWrapper<TBOrg> tbOrgQueryWrapper = new QueryWrapper<>();
         if (Objects.nonNull(id)) {
             tbOrgQueryWrapper.lambda().eq(TBOrg::getId, id);
@@ -255,14 +262,15 @@ public class SysController {
 
     @ApiOperation(value = "角色查询接口")
     @RequestMapping(value = "/role/query", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "角色信息", response = TBRole.class)})
+    @ApiResponses({ @ApiResponse(code = 200, message = "角色信息", response = TBRole.class) })
     public Result roleList() {
         List<TBRole> tbRoleList = (List<TBRole>) redisUtil.getRole();
         if (Objects.nonNull(tbRoleList) && tbRoleList.size() > 0) {
             tbRoleList = (List<TBRole>) tbRoleList.get(0);
         } else {
             QueryWrapper<TBRole> tbRoleQueryWrapper = new QueryWrapper<>();
-            tbRoleQueryWrapper.lambda().notIn(TBRole::getRoleCode, RoleEnum.SUPER_ADMIN.name(), RoleEnum.STUDENT.name());
+            tbRoleQueryWrapper.lambda()
+                    .notIn(TBRole::getRoleCode, RoleEnum.SUPER_ADMIN.name(), RoleEnum.STUDENT.name());
             tbRoleList = tbRoleService.list(tbRoleQueryWrapper);
             if (Objects.nonNull(tbRoleList)) {
                 redisUtil.setRole(tbRoleList);
@@ -273,20 +281,22 @@ public class SysController {
 
     @ApiOperation(value = "考试场次查询接口")
     @RequestMapping(value = "/examActivity/query", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "角色信息", response = TEExamActivity.class)})
+    @ApiResponses({ @ApiResponse(code = 200, message = "角色信息", response = TEExamActivity.class) })
     public Result examActivityQuery() {
         return ResultUtil.ok(teExamActivityService.list());
     }
 
     @ApiOperation(value = "考试批次查询接口")
     @RequestMapping(value = "/exam/query", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "角色信息", response = TEExamQueryDto.class)})
-    public Result examQuery(@ApiParam(value = "用户id", required = false) @RequestParam(required = false) Long userId, @ApiParam(value = "批次名称", required = false) @RequestParam(required = false) String name, @ApiParam(value = "类型(区分实时监考台和考务)", required = false) @RequestParam(required = false) String type) {
+    @ApiResponses({ @ApiResponse(code = 200, message = "角色信息", response = TEExamQueryDto.class) })
+    public Result examQuery(@ApiParam(value = "用户id", required = false) @RequestParam(required = false) Long userId,
+            @ApiParam(value = "批次名称", required = false) @RequestParam(required = false) String name,
+            @ApiParam(value = "类型(区分实时监考台和考务)", required = false) @RequestParam(required = false) String type) {
         TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
         AuthDto authDto = (AuthDto) redisUtil.get(SystemConstant.userOauth + "::" + tbUser.getId());
         List<TEExam> teExamList = null;
-        if (authDto.getRoleCodes().toString().contains(RoleEnum.ADMIN.name())
-                || authDto.getRoleCodes().toString().contains(RoleEnum.SUPER_ADMIN.name())) {//管理员
+        if (authDto.getRoleCodes().toString().contains(RoleEnum.ADMIN.name()) || authDto.getRoleCodes().toString()
+                .contains(RoleEnum.SUPER_ADMIN.name())) {//管理员
             QueryWrapper<TEExam> teExamQueryWrapper = new QueryWrapper<>();
             teExamQueryWrapper.lambda().eq(TEExam::getOrgId, tbUser.getOrgId()).eq(TEExam::getEnable, 1);
             if (Objects.nonNull(name) && !Objects.equals(name, "")) {
@@ -304,7 +314,8 @@ public class SysController {
                     teExamQueryWrapper.lambda().like(TEExam::getName, name);
                 }
                 if (Objects.nonNull(type) && !Objects.equals(type, "") && Objects.equals(type, "monitor")) {
-                    teExamQueryWrapper.lambda().ne(TEExam::getMonitorStatus, InvigilateMonitorStatusEnum.FINISHED.name());
+                    teExamQueryWrapper.lambda()
+                            .ne(TEExam::getMonitorStatus, InvigilateMonitorStatusEnum.FINISHED.name());
                 }
                 teExamQueryWrapper.lambda().orderByDesc(TEExam::getCreateTime);
                 teExamList = teExamService.list(teExamQueryWrapper);
@@ -314,6 +325,7 @@ public class SysController {
         if (Objects.nonNull(teExamList)) {
             Gson gson = new Gson();
             teExamQueryDtoList = gson.fromJson(gson.toJson(teExamList), new TypeToken<List<TEExamQueryDto>>() {
+
             }.getType());
         }
         return ResultUtil.ok(teExamQueryDtoList);
@@ -321,14 +333,15 @@ public class SysController {
 
     @ApiOperation(value = "考场查询接口")
     @RequestMapping(value = "/examRoom/query", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "角色信息", response = RoomCodeQueryDto.class)})
-    public Result examRoomQuery(@ApiParam(value = "考场名称", required = false) @RequestParam(required = false) String roomName) {
+    @ApiResponses({ @ApiResponse(code = 200, message = "角色信息", response = RoomCodeQueryDto.class) })
+    public Result examRoomQuery(
+            @ApiParam(value = "考场名称", required = false) @RequestParam(required = false) String roomName) {
         return ResultUtil.ok(teExamStudentService.examRoomQuery(roomName));
     }
 
     @ApiOperation(value = "根据权限获取场次和考场接口")
     @RequestMapping(value = "/exam/privilegeQuery", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "场次和考场信息", response = Result.class)})
+    @ApiResponses({ @ApiResponse(code = 200, message = "场次和考场信息", response = Result.class) })
     public Result examPrivilegeQuery(@ApiParam(value = "考试id", required = true) @RequestParam Long examId) {
         if (Objects.isNull(examId) || Objects.equals(examId, "")) {
             throw new BusinessException(ExceptionResultEnum.EXAM_ID_IS_NULL);
@@ -346,11 +359,12 @@ public class SysController {
         if (authDto.getRoleCodes().toString().contains(RoleEnum.INVIGILATE.name())) {
             examInvigilateUserQueryWrapper.lambda().eq(TBExamInvigilateUser::getUserId, tbUser.getId());
         }
-        List<TBExamInvigilateUser> tbExamInvigilateUserList = tbExamInvigilateUserService.list(examInvigilateUserQueryWrapper);
+        List<TBExamInvigilateUser> tbExamInvigilateUserList = tbExamInvigilateUserService
+                .list(examInvigilateUserQueryWrapper);
         Set<String> roomCodeSet = null;
         if (Objects.nonNull(tbExamInvigilateUserList) && tbExamInvigilateUserList.size() > 0) {
-            Map<String, TBExamInvigilateUser> tbExamInvigilateUserMap = tbExamInvigilateUserList.stream()
-                    .collect(Collectors.toMap(TBExamInvigilateUser::getRoomCode, Function.identity(), (dto1, dto2) -> dto1));
+            Map<String, TBExamInvigilateUser> tbExamInvigilateUserMap = tbExamInvigilateUserList.stream().collect(
+                    Collectors.toMap(TBExamInvigilateUser::getRoomCode, Function.identity(), (dto1, dto2) -> dto1));
             roomCodeSet = new HashSet<>();
             tbExamInvigilateUserList.clear();
             Set<String> finalRoomCodeSet = roomCodeSet;
@@ -395,7 +409,7 @@ public class SysController {
 
     @ApiOperation(value = "获取播放域接口")
     @RequestMapping(value = "/getPlayUrls", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "播放域接口", response = Result.class)})
+    @ApiResponses({ @ApiResponse(code = 200, message = "播放域接口", response = Result.class) })
     public Result getPlayUrls() {
         return ResultUtil.ok(dictionaryConfig.tencentYunDomain().getUrls());
     }

+ 46 - 23
themis-backend/src/main/java/com/qmth/themis/backend/api/TBExamInvigilateUserController.java

@@ -42,6 +42,7 @@ import java.util.stream.Collectors;
 @RestController
 @RequestMapping("/${prefix.url.admin}/invigilateUser")
 public class TBExamInvigilateUserController {
+
     private final static Logger log = LoggerFactory.getLogger(TBExamInvigilateUserController.class);
 
     @Resource
@@ -61,21 +62,26 @@ public class TBExamInvigilateUserController {
 
     @ApiOperation(value = "监考员查询接口")
     @RequestMapping(value = "/query", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "监考员信息", response = TBExamInvigilateUserDto.class)})
-    public Result query(@ApiParam(value = "考试批次id", required = true) @RequestParam(required = false) Long examId, @ApiParam(value = "考场代码", required = false) @RequestParam(required = false) String roomCode, @ApiParam(value = "用户id", required = false) @RequestParam(required = false) Long userId, @ApiParam(value = "分页页码", required = true) @RequestParam int pageNumber, @ApiParam(value = "分页数", required = true) @RequestParam int pageSize) {
+    @ApiResponses({ @ApiResponse(code = 200, message = "监考员信息", response = TBExamInvigilateUserDto.class) })
+    public Result query(@ApiParam(value = "考试批次id", required = true) @RequestParam(required = false) Long examId,
+            @ApiParam(value = "考场代码", required = false) @RequestParam(required = false) String roomCode,
+            @ApiParam(value = "用户id", required = false) @RequestParam(required = false) Long userId,
+            @ApiParam(value = "分页页码", required = true) @RequestParam int pageNumber,
+            @ApiParam(value = "分页数", required = true) @RequestParam int pageSize) {
         TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
-        return ResultUtil.ok(tbExamInvigilateUserService.examInvigilateUserQuery(new Page<>(pageNumber, pageSize), examId, roomCode, userId, tbUser.getOrgId()));
+        return ResultUtil.ok(tbExamInvigilateUserService
+                .examInvigilateUserQuery(new Page<>(pageNumber, pageSize), examId, roomCode, userId,
+                        tbUser.getOrgId()));
     }
 
     @ApiOperation(value = "监考员修改接口")
     @RequestMapping(value = "/save", method = RequestMethod.POST)
     @Transactional
-    @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
+    @ApiResponses({ @ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class) })
     public Result save(@ApiJsonObject(name = "saveInvigilateUser", value = {
             @ApiJsonProperty(key = "examId", type = "long", example = "1", description = "考试批次id", required = true),
             @ApiJsonProperty(key = "roomCode", description = "考场代码"),
-            @ApiJsonProperty(key = "userIds", description = "用户id")
-    }) @ApiParam(value = "监考员信息", required = true) @RequestBody Map<String, Object> mapParameter) {
+            @ApiJsonProperty(key = "userIds", description = "用户id") }) @ApiParam(value = "监考员信息", required = true) @RequestBody Map<String, Object> mapParameter) {
         String roomCode = null;
         try {
             if (Objects.isNull(mapParameter.get("examId")) || Objects.equals(mapParameter.get("examId"), "")) {
@@ -91,22 +97,27 @@ public class TBExamInvigilateUserController {
             }
             List<String> userIds = (List) mapParameter.get("userIds");
             if (userIds.size() > 3) {
-                throw new BusinessException(ExceptionResultEnum.ERROR.getStatusCode(), ExceptionResultEnum.ERROR.getCode(), "一个考场最多设置3名监考员");
+                throw new BusinessException(ExceptionResultEnum.ERROR.getStatusCode(),
+                        ExceptionResultEnum.ERROR.getCode(), "一个考场最多设置3名监考员");
             }
             if (userIds.size() > 0) {
                 TBOrg tbOrg = (TBOrg) ServletUtil.getRequestOrg();
                 QueryWrapper<TBExamInvigilateUser> tbExamInvigilateUserQueryWrapper = new QueryWrapper<>();
-                tbExamInvigilateUserQueryWrapper.lambda().eq(TBExamInvigilateUser::getRoomCode, roomCode).eq(TBExamInvigilateUser::getExamId, examId);
+                tbExamInvigilateUserQueryWrapper.lambda().eq(TBExamInvigilateUser::getRoomCode, roomCode)
+                        .eq(TBExamInvigilateUser::getExamId, examId);
                 if (Objects.nonNull(tbOrg) && Objects.isNull(tbOrg.getId())) {
                     throw new BusinessException("监考员机构id不允许为空");
                 }
-                List<TBExamInvigilateUser> tbExamInvigilateUserList = tbExamInvigilateUserService.list(tbExamInvigilateUserQueryWrapper);
+                List<TBExamInvigilateUser> tbExamInvigilateUserList = tbExamInvigilateUserService
+                        .list(tbExamInvigilateUserQueryWrapper);
                 Long orgId = tbOrg.getId();
-                List<String> roomNameList = tbExamInvigilateUserList.stream().map(s -> s.getRoomName()).collect(Collectors.toList());
+                List<String> roomNameList = tbExamInvigilateUserList.stream().map(s -> s.getRoomName())
+                        .collect(Collectors.toList());
                 tbExamInvigilateUserService.remove(tbExamInvigilateUserQueryWrapper);
                 tbExamInvigilateUserList = new ArrayList<>();
                 for (int i = 0; i < userIds.size(); i++) {
-                    TBExamInvigilateUser tbExamInvigilateUser = new TBExamInvigilateUser(examId, orgId, Long.parseLong(userIds.get(i)), roomCode, roomNameList.get(0));
+                    TBExamInvigilateUser tbExamInvigilateUser = new TBExamInvigilateUser(examId, orgId,
+                            Long.parseLong(userIds.get(i)), roomCode, roomNameList.get(0));
                     tbExamInvigilateUserList.add(tbExamInvigilateUser);
                 }
                 tbExamInvigilateUserService.saveBatch(tbExamInvigilateUserList);
@@ -115,8 +126,10 @@ public class TBExamInvigilateUserController {
             log.error("请求出错", e);
             if (e instanceof DuplicateKeyException) {
                 String errorColumn = e.getCause().toString();
-                String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3, errorColumn.length()).replaceAll("'", "");
-                throw new BusinessException("考场代码[" + roomCode + "]下的" + FieldUniqueEnum.convertToCode(columnStr) + "数据不允许重复插入");
+                String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3, errorColumn.length())
+                        .replaceAll("'", "");
+                throw new BusinessException(
+                        "考场代码[" + roomCode + "]下的" + FieldUniqueEnum.convertToCode(columnStr) + "数据不允许重复插入");
             } else if (e instanceof BusinessException) {
                 throw new BusinessException(e.getMessage());
             } else {
@@ -129,8 +142,9 @@ public class TBExamInvigilateUserController {
     @ApiOperation(value = "监考员导入接口")
     @RequestMapping(value = "/import", method = RequestMethod.POST)
     @Transactional
-    @ApiResponses({@ApiResponse(code = 200, message = "{\"taskId\":0}", response = Result.class)})
-    public Result importData(@ApiParam(value = "上传文件", required = true) @RequestParam MultipartFile file, @ApiParam(value = "考试批次id", required = true) @RequestParam Long examId) {
+    @ApiResponses({ @ApiResponse(code = 200, message = "{\"taskId\":0}", response = Result.class) })
+    public Result importData(@ApiParam(value = "上传文件", required = true) @RequestParam MultipartFile file,
+            @ApiParam(value = "考试批次id", required = true) @RequestParam Long examId) {
         if (Objects.isNull(file) || Objects.equals(file, "")) {
             throw new BusinessException(ExceptionResultEnum.ATTACHMENT_IS_NULL);
         }
@@ -143,12 +157,16 @@ public class TBExamInvigilateUserController {
         Map transMap = new HashMap();
         try {
             TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
-            tbAttachment = tbAttachmentService.saveAttachment(file, ServletUtil.getRequestMd5(), ServletUtil.getRequestPath(), mapParameter, tbUser.getOrgId(), tbUser.getId());
+            tbAttachment = tbAttachmentService
+                    .saveAttachment(file, ServletUtil.getRequestMd5(), ServletUtil.getRequestPath(), mapParameter,
+                            UploadFileEnum.file, tbUser.getOrgId(), tbUser.getId());
             if (Objects.isNull(tbAttachment)) {
                 throw new BusinessException(ExceptionResultEnum.ATTACHMENT_ERROR);
             } else {
                 //往任务表里插一条数据
-                tbTaskHistory = new TBTaskHistory(TaskTypeEnum.IMPORT_INVIGILATE_USER, examId, TaskStatusEnum.INIT, SystemConstant.IMPORT_INIT, 0d, tbAttachment.getName(), tbAttachment.getRemark(), tbUser.getId(), tbUser.getOrgId());
+                tbTaskHistory = new TBTaskHistory(TaskTypeEnum.IMPORT_INVIGILATE_USER, examId, TaskStatusEnum.INIT,
+                        SystemConstant.IMPORT_INIT, 0d, tbAttachment.getName(), tbAttachment.getRemark(),
+                        tbUser.getId(), tbUser.getOrgId());
                 tbTaskHistory.setExamId(examId);
                 taskHistoryService.save(tbTaskHistory);
                 transMap.put("tbTaskHistory", tbTaskHistory);
@@ -158,13 +176,14 @@ public class TBExamInvigilateUserController {
             transMap.put("orgId", tbUser.getOrgId());
             transMap.put("remark", tbAttachment.getRemark());
             //mq发送消息start
-            MqDto mqDto = new MqDto(MqTopicEnum.THEMIS_TOPIC.getCode(), MqTagEnum.ROOM_CODE_IMPORT.name(), transMap, MqTagEnum.ROOM_CODE_IMPORT, String.valueOf(tbTaskHistory.getId()), tbUser.getName());
+            MqDto mqDto = new MqDto(MqTopicEnum.THEMIS_TOPIC.getCode(), MqTagEnum.ROOM_CODE_IMPORT.name(), transMap,
+                    MqTagEnum.ROOM_CODE_IMPORT, String.valueOf(tbTaskHistory.getId()), tbUser.getName());
             mqDtoService.assembleSendOneWayMsg(mqDto);
             //mq发送消息end
         } catch (Exception e) {
             log.error("请求出错", e);
             if (Objects.nonNull(tbAttachment)) {
-                tbAttachmentService.deleteAttachment(mapParameter, tbAttachment);
+                tbAttachmentService.deleteAttachment(mapParameter, UploadFileEnum.file, tbAttachment);
             }
             if (e instanceof BusinessException) {
                 throw new BusinessException(e.getMessage());
@@ -178,8 +197,10 @@ public class TBExamInvigilateUserController {
     @ApiOperation(value = "监考员导出接口")
     @RequestMapping(value = "/export", method = RequestMethod.POST)
     @Transactional
-    @ApiResponses({@ApiResponse(code = 200, message = "{\"taskId\":0}", response = Result.class)})
-    public Result export(@ApiParam(value = "考试批次id", required = true) @RequestParam(required = false) Long examId, @ApiParam(value = "考场代码", required = false) @RequestParam(required = false) String roomCode, @ApiParam(value = "用户id", required = false) @RequestParam(required = false) Long userId) {
+    @ApiResponses({ @ApiResponse(code = 200, message = "{\"taskId\":0}", response = Result.class) })
+    public Result export(@ApiParam(value = "考试批次id", required = true) @RequestParam(required = false) Long examId,
+            @ApiParam(value = "考场代码", required = false) @RequestParam(required = false) String roomCode,
+            @ApiParam(value = "用户id", required = false) @RequestParam(required = false) Long userId) {
         TBTaskHistory tbTaskHistory = null;
         try {
             int count = tbExamInvigilateUserService.count();
@@ -187,7 +208,8 @@ public class TBExamInvigilateUserController {
                 Map transMap = new HashMap();
                 TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
                 //往任务表里插一条数据
-                tbTaskHistory = new TBTaskHistory(TaskTypeEnum.EXPORT_INVIGILATE_USER, TaskStatusEnum.INIT, SystemConstant.EXPORT_INIT, 0d, tbUser.getId(), tbUser.getOrgId());
+                tbTaskHistory = new TBTaskHistory(TaskTypeEnum.EXPORT_INVIGILATE_USER, TaskStatusEnum.INIT,
+                        SystemConstant.EXPORT_INIT, 0d, tbUser.getId(), tbUser.getOrgId());
                 tbTaskHistory.setExamId(examId);
                 taskHistoryService.save(tbTaskHistory);
                 transMap.put("tbTaskHistory", tbTaskHistory);
@@ -197,7 +219,8 @@ public class TBExamInvigilateUserController {
                 transMap.put("roomCode", roomCode);
                 transMap.put("userId", userId);
                 //mq发送消息start
-                MqDto mqDto = new MqDto(MqTopicEnum.THEMIS_TOPIC.getCode(), MqTagEnum.ROOM_CODE_EXPORT.name(), transMap, MqTagEnum.ROOM_CODE_EXPORT, String.valueOf(tbTaskHistory.getId()), tbUser.getName());
+                MqDto mqDto = new MqDto(MqTopicEnum.THEMIS_TOPIC.getCode(), MqTagEnum.ROOM_CODE_EXPORT.name(), transMap,
+                        MqTagEnum.ROOM_CODE_EXPORT, String.valueOf(tbTaskHistory.getId()), tbUser.getName());
                 mqDtoService.assembleSendOneWayMsg(mqDto);
                 //mq发送消息end
             } else {

+ 27 - 17
themis-backend/src/main/java/com/qmth/themis/backend/api/TEExamPaperController.java

@@ -35,6 +35,7 @@ import java.util.*;
 @RestController
 @RequestMapping("/${prefix.url.admin}/exam/paper")
 public class TEExamPaperController {
+
     private final static Logger log = LoggerFactory.getLogger(TEExamPaperController.class);
 
     @Resource
@@ -60,8 +61,9 @@ public class TEExamPaperController {
 
     @ApiOperation(value = "考试试卷查询接口")
     @RequestMapping(value = "/query", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "考试科目信息", response = TEExamPaper.class)})
-    public Result query(@ApiParam(value = "考试批次id", required = true) @RequestParam Long examId, @ApiParam(value = "科目编码", required = true) @RequestParam String courseCode) {
+    @ApiResponses({ @ApiResponse(code = 200, message = "考试科目信息", response = TEExamPaper.class) })
+    public Result query(@ApiParam(value = "考试批次id", required = true) @RequestParam Long examId,
+            @ApiParam(value = "科目编码", required = true) @RequestParam String courseCode) {
         if (Objects.isNull(examId) || Objects.equals(examId, "")) {
             throw new BusinessException(ExceptionResultEnum.EXAM_ID_IS_NULL);
         }
@@ -76,7 +78,7 @@ public class TEExamPaperController {
     @ApiOperation(value = "考试试卷参数修改接口")
     @RequestMapping(value = "/save", method = RequestMethod.POST)
     @Transactional
-    @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
+    @ApiResponses({ @ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class) })
     public Result save(@ApiParam(value = "考试试卷信息", required = true) @RequestBody List<TEExamPaper> teExamPaperList) {
         if (Objects.isNull(teExamPaperList) || teExamPaperList.size() == 0) {
             throw new BusinessException(ExceptionResultEnum.PAPER_INFO_IS_NULL);
@@ -91,8 +93,11 @@ public class TEExamPaperController {
             log.error("请求出错", e);
             if (e instanceof DuplicateKeyException) {
                 String errorColumn = e.getCause().toString();
-                String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3, errorColumn.length()).replaceAll("'", "");
-                throw new BusinessException("机构id[" + teExamPaperList.get(0).getExamId() + "]下的" + FieldUniqueEnum.convertToCode(columnStr) + "数据不允许重复插入");
+                String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3, errorColumn.length())
+                        .replaceAll("'", "");
+                throw new BusinessException(
+                        "机构id[" + teExamPaperList.get(0).getExamId() + "]下的" + FieldUniqueEnum.convertToCode(columnStr)
+                                + "数据不允许重复插入");
             } else if (e instanceof BusinessException) {
                 throw new BusinessException(e.getMessage());
             } else {
@@ -110,14 +115,14 @@ public class TEExamPaperController {
     @ApiOperation(value = "考试试卷数据包上传接口")
     @RequestMapping(value = "/import", method = RequestMethod.POST)
     @Transactional
-    @ApiResponses({@ApiResponse(code = 200, message = "{\"taskId\":0}", response = Result.class)})
-    public Result importData(@ApiParam(value = "上传文件", required = true) @RequestParam MultipartFile file
-            , @ApiParam(value = "批次ID", required = true) @RequestParam Long examId
-            , @ApiParam(value = "客观题乱序", required = false) @RequestParam Boolean objectiveShuffle
-            , @ApiParam(value = "选项乱序", required = false) @RequestParam Boolean optionShuffle
-            , @ApiParam(value = "音频播放次数", required = false) @RequestParam Integer audioPlayCount
-            , @ApiParam(value = "解析试卷", required = true) @RequestParam Boolean processPaper
-            , @ApiParam(value = "解析标答", required = true) @RequestParam Boolean processAnswer) {
+    @ApiResponses({ @ApiResponse(code = 200, message = "{\"taskId\":0}", response = Result.class) })
+    public Result importData(@ApiParam(value = "上传文件", required = true) @RequestParam MultipartFile file,
+            @ApiParam(value = "批次ID", required = true) @RequestParam Long examId,
+            @ApiParam(value = "客观题乱序", required = false) @RequestParam Boolean objectiveShuffle,
+            @ApiParam(value = "选项乱序", required = false) @RequestParam Boolean optionShuffle,
+            @ApiParam(value = "音频播放次数", required = false) @RequestParam Integer audioPlayCount,
+            @ApiParam(value = "解析试卷", required = true) @RequestParam Boolean processPaper,
+            @ApiParam(value = "解析标答", required = true) @RequestParam Boolean processAnswer) {
         if (file == null) {
             throw new BusinessException(ExceptionResultEnum.ATTACHMENT_IS_NULL);
         }
@@ -130,12 +135,16 @@ public class TEExamPaperController {
         Map<String, Object> transMap = new HashMap<String, Object>();
         try {
             TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
-            tbAttachment = tbAttachmentService.saveAttachment(file, ServletUtil.getRequestMd5(), ServletUtil.getRequestPath(), mapParameter, tbUser.getOrgId(), tbUser.getId());
+            tbAttachment = tbAttachmentService
+                    .saveAttachment(file, ServletUtil.getRequestMd5(), ServletUtil.getRequestPath(), mapParameter,
+                            UploadFileEnum.file, tbUser.getOrgId(), tbUser.getId());
             if (Objects.isNull(tbAttachment)) {
                 throw new BusinessException(ExceptionResultEnum.ATTACHMENT_ERROR);
             } else {
                 //往任务表里插一条数据
-                tbTaskHistory = new TBTaskHistory(TaskTypeEnum.IMPORT_EXAM_PAPER, examId, TaskStatusEnum.INIT, SystemConstant.IMPORT_INIT, 0d, tbAttachment.getName(), tbAttachment.getRemark(), tbUser.getId(), tbUser.getOrgId());
+                tbTaskHistory = new TBTaskHistory(TaskTypeEnum.IMPORT_EXAM_PAPER, examId, TaskStatusEnum.INIT,
+                        SystemConstant.IMPORT_INIT, 0d, tbAttachment.getName(), tbAttachment.getRemark(),
+                        tbUser.getId(), tbUser.getOrgId());
                 tbTaskHistory.setExamId(examId);
                 taskHistoryService.save(tbTaskHistory);
                 transMap.put("tbTaskHistory", tbTaskHistory);
@@ -155,13 +164,14 @@ public class TEExamPaperController {
             transMap.put("processAnswer", processAnswer);
             transMap.put("remark", tbAttachment.getRemark());
             //mq发送消息start
-            MqDto mqDto = new MqDto(MqTopicEnum.THEMIS_TOPIC.getCode(), MqTagEnum.EXAM_PAPER_IMPORT.name(), transMap, MqTagEnum.EXAM_PAPER_IMPORT, String.valueOf(tbTaskHistory.getId()), tbUser.getName());
+            MqDto mqDto = new MqDto(MqTopicEnum.THEMIS_TOPIC.getCode(), MqTagEnum.EXAM_PAPER_IMPORT.name(), transMap,
+                    MqTagEnum.EXAM_PAPER_IMPORT, String.valueOf(tbTaskHistory.getId()), tbUser.getName());
             mqDtoService.assembleSendOneWayMsg(mqDto);
             //mq发送消息end
         } catch (Exception e) {
             log.error("请求出错", e);
             if (Objects.nonNull(tbAttachment)) {
-                tbAttachmentService.deleteAttachment(mapParameter, tbAttachment);
+                tbAttachmentService.deleteAttachment(mapParameter, UploadFileEnum.file, tbAttachment);
             }
             if (e instanceof BusinessException) {
                 throw new BusinessException(e.getMessage());

+ 94 - 72
themis-backend/src/main/java/com/qmth/themis/backend/api/TEExamStudentController.java

@@ -47,6 +47,7 @@ import java.util.stream.Collectors;
 @RestController
 @RequestMapping("/${prefix.url.admin}/examStudent")
 public class TEExamStudentController {
+
     private final static Logger log = LoggerFactory.getLogger(TEExamStudentController.class);
 
     @Resource
@@ -85,20 +86,22 @@ public class TEExamStudentController {
     @ApiOperation(value = "考生导出")
     @RequestMapping(value = "/export", method = RequestMethod.POST)
     public Result export(@ApiParam(value = "考试批次id", required = true) @RequestParam Long examId,
-                         @ApiParam(value = "考试场次id", required = false) @RequestParam(required = false) Long activityId,
-                         @ApiParam(value = "证件号", required = false) @RequestParam(required = false) String identity,
-                         @ApiParam(value = "姓名", required = false) @RequestParam(required = false) String name,
-                         @ApiParam(value = "考场代码", required = false) @RequestParam(required = false) String roomCode,
-                         @ApiParam(value = "科目代码", required = false) @RequestParam(required = false) String courseCode,
-                         @ApiParam(value = "年级", required = false) @RequestParam(required = false) String grade,
-                         @ApiParam(value = "是否启用", required = false) @RequestParam(required = false) Integer enable,
-                         @ApiParam(value = "教学班级", required = false) @RequestParam(required = false) String classNo,
-                         @ApiParam(value = "底照是否上传", required = false) @RequestParam(required = false) Integer hasPhoto) throws Exception {
+            @ApiParam(value = "考试场次id", required = false) @RequestParam(required = false) Long activityId,
+            @ApiParam(value = "证件号", required = false) @RequestParam(required = false) String identity,
+            @ApiParam(value = "姓名", required = false) @RequestParam(required = false) String name,
+            @ApiParam(value = "考场代码", required = false) @RequestParam(required = false) String roomCode,
+            @ApiParam(value = "科目代码", required = false) @RequestParam(required = false) String courseCode,
+            @ApiParam(value = "年级", required = false) @RequestParam(required = false) String grade,
+            @ApiParam(value = "是否启用", required = false) @RequestParam(required = false) Integer enable,
+            @ApiParam(value = "教学班级", required = false) @RequestParam(required = false) String classNo,
+            @ApiParam(value = "底照是否上传", required = false) @RequestParam(required = false) Integer hasPhoto)
+            throws Exception {
         TBTaskHistory tbTaskHistory = null;
         Map<String, Object> transMap = new HashMap<String, Object>();
         TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
         //往任务表里插一条数据
-        tbTaskHistory = new TBTaskHistory(TaskTypeEnum.EXPORT_EXAM_STUDENT, TaskStatusEnum.INIT, SystemConstant.EXPORT_INIT, 0d, tbUser.getId(), tbUser.getOrgId());
+        tbTaskHistory = new TBTaskHistory(TaskTypeEnum.EXPORT_EXAM_STUDENT, TaskStatusEnum.INIT,
+                SystemConstant.EXPORT_INIT, 0d, tbUser.getId(), tbUser.getOrgId());
         tbTaskHistory.setExamId(examId);
         taskHistoryService.save(tbTaskHistory);
         transMap.put("tbTaskHistory", tbTaskHistory);
@@ -116,7 +119,8 @@ public class TEExamStudentController {
         transMap.put("createId", tbUser.getId());
 
         //mq发送消息start
-        MqDto mqDto = new MqDto(MqTopicEnum.THEMIS_TOPIC.getCode(), MqTagEnum.EXAM_STUDENT_EXPORT.name(), transMap, MqTagEnum.EXAM_STUDENT_EXPORT, String.valueOf(tbTaskHistory.getId()), tbUser.getName());
+        MqDto mqDto = new MqDto(MqTopicEnum.THEMIS_TOPIC.getCode(), MqTagEnum.EXAM_STUDENT_EXPORT.name(), transMap,
+                MqTagEnum.EXAM_STUDENT_EXPORT, String.valueOf(tbTaskHistory.getId()), tbUser.getName());
 
         mqDtoService.assembleSendOneWayMsg(mqDto);
         //mq发送消息end
@@ -125,29 +129,30 @@ public class TEExamStudentController {
 
     @ApiOperation(value = "考生查询接口")
     @RequestMapping(value = "/query", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "考生信息", response = TEExamStudentDto.class)})
+    @ApiResponses({ @ApiResponse(code = 200, message = "考生信息", response = TEExamStudentDto.class) })
     public Result query(@ApiParam(value = "考试批次id", required = true) @RequestParam Long examId,
-                        @ApiParam(value = "考试场次id", required = false) @RequestParam(required = false) Long activityId,
-                        @ApiParam(value = "证件号", required = false) @RequestParam(required = false) String identity,
-                        @ApiParam(value = "姓名", required = false) @RequestParam(required = false) String name,
-                        @ApiParam(value = "考场代码", required = false) @RequestParam(required = false) String roomCode,
-                        @ApiParam(value = "科目代码", required = false) @RequestParam(required = false) String courseCode,
-                        @ApiParam(value = "年级", required = false) @RequestParam(required = false) String grade,
-                        @ApiParam(value = "是否启用", required = false) @RequestParam(required = false) Integer enable,
-                        @ApiParam(value = "教学班级", required = false) @RequestParam(required = false) String classNo,
-                        @ApiParam(value = "底照是否上传", required = false) @RequestParam(required = false) Integer hasPhoto,
-                        @ApiParam(value = "分页页码", required = true) @RequestParam int pageNumber,
-                        @ApiParam(value = "分页数", required = true) @RequestParam int pageSize) {
+            @ApiParam(value = "考试场次id", required = false) @RequestParam(required = false) Long activityId,
+            @ApiParam(value = "证件号", required = false) @RequestParam(required = false) String identity,
+            @ApiParam(value = "姓名", required = false) @RequestParam(required = false) String name,
+            @ApiParam(value = "考场代码", required = false) @RequestParam(required = false) String roomCode,
+            @ApiParam(value = "科目代码", required = false) @RequestParam(required = false) String courseCode,
+            @ApiParam(value = "年级", required = false) @RequestParam(required = false) String grade,
+            @ApiParam(value = "是否启用", required = false) @RequestParam(required = false) Integer enable,
+            @ApiParam(value = "教学班级", required = false) @RequestParam(required = false) String classNo,
+            @ApiParam(value = "底照是否上传", required = false) @RequestParam(required = false) Integer hasPhoto,
+            @ApiParam(value = "分页页码", required = true) @RequestParam int pageNumber,
+            @ApiParam(value = "分页数", required = true) @RequestParam int pageSize) {
         if (Objects.isNull(examId) || Objects.equals(examId, "")) {
             throw new BusinessException(ExceptionResultEnum.EXAM_ID_IS_NULL);
         }
-        IPage<TEExamStudentDto> teExamStudentIPage = teExamStudentService.examStudentQuery(
-                new Page<>(pageNumber, pageSize), examId, activityId, identity, name, roomCode, courseCode, grade,
-                enable, classNo, hasPhoto);
+        IPage<TEExamStudentDto> teExamStudentIPage = teExamStudentService
+                .examStudentQuery(new Page<>(pageNumber, pageSize), examId, activityId, identity, name, roomCode,
+                        courseCode, grade, enable, classNo, hasPhoto);
         if (teExamStudentIPage.getRecords() != null && teExamStudentIPage.getRecords().size() > 0) {
             for (TEExamStudentDto dto : teExamStudentIPage.getRecords()) {
                 if (StringUtils.isNotBlank(dto.getBasePhotoUrl())) {
-                    dto.setBasePhotoUrl(ossUtil.getAliYunOssPublicDomain().getPublicUrl() + "/" + dto.getBasePhotoUrl());
+                    dto.setBasePhotoUrl(
+                            ossUtil.getAliYunOssPublicDomain().getPublicUrl() + "/" + dto.getBasePhotoUrl());
                 }
             }
         }
@@ -156,11 +161,11 @@ public class TEExamStudentController {
 
     @ApiOperation(value = "考生停用/启用接口")
     @RequestMapping(value = "/toggle", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
+    @ApiResponses({ @ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class) })
     @Transactional
     public Result examStudentToggle(@ApiJsonObject(name = "examStudentToggle", value = {
             @ApiJsonProperty(key = "id", type = "long", example = "1", description = "考生ID"),
-            @ApiJsonProperty(key = "enable", type = "int", example = "1", description = "是否启用")}) @ApiParam(value = "考生信息", required = true) @RequestBody List<Map<String, Object>> mapParameter) {
+            @ApiJsonProperty(key = "enable", type = "int", example = "1", description = "是否启用") }) @ApiParam(value = "考生信息", required = true) @RequestBody List<Map<String, Object>> mapParameter) {
         if (Objects.isNull(mapParameter) || mapParameter.size() == 0) {
             throw new BusinessException(ExceptionResultEnum.EXAM_STUDENT_INFO_IS_NULL);
         }
@@ -185,7 +190,7 @@ public class TEExamStudentController {
 
     @ApiOperation(value = "考生修改接口")
     @RequestMapping(value = "/save", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
+    @ApiResponses({ @ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class) })
     @Transactional
     public Result save(@ApiParam(value = "考生信息", required = true) @RequestBody List<TEExamStudent> teExamStudentList) {
         if (Objects.isNull(teExamStudentList) || teExamStudentList.size() == 0) {
@@ -215,20 +220,21 @@ public class TEExamStudentController {
                 teExamStudentService.update(teExamStudentUpdateWrapper);
 
                 UpdateWrapper<TEStudent> teStudentUpdateWrapper = new UpdateWrapper<>();
-                teStudentUpdateWrapper.lambda().set(TEStudent::getName, s.getName()).eq(TEStudent::getIdentity,
-                        s.getIdentity());
+                teStudentUpdateWrapper.lambda().set(TEStudent::getName, s.getName())
+                        .eq(TEStudent::getIdentity, s.getIdentity());
                 teStudentService.update(teStudentUpdateWrapper);
                 s.setUpdateId(tbUser.getId());
             }
-            ExamCourseCacheBean examCourseCacheBean = teExamCourseService.getExamCourseCacheBean(s.getExamId(), s.getCourseCode());
+            ExamCourseCacheBean examCourseCacheBean = teExamCourseService
+                    .getExamCourseCacheBean(s.getExamId(), s.getCourseCode());
             if (Objects.isNull(examCourseCacheBean)) {
                 throw new BusinessException("考试科目不存在");
             }
             s.setCourseName(examCourseCacheBean.getCourseName());
             List<RoomCodeQueryDto> roomCodeQueryDtoList = teExamStudentService.examRoomQuery(null);
             if (Objects.nonNull(roomCodeQueryDtoList)) {
-                Map<String, RoomCodeQueryDto> roomCodeQueryDtoMap = roomCodeQueryDtoList.stream()
-                        .collect(Collectors.toMap(RoomCodeQueryDto::getRoomCode, Function.identity(), (dto1, dto2) -> dto1));
+                Map<String, RoomCodeQueryDto> roomCodeQueryDtoMap = roomCodeQueryDtoList.stream().collect(
+                        Collectors.toMap(RoomCodeQueryDto::getRoomCode, Function.identity(), (dto1, dto2) -> dto1));
                 String roomName = roomCodeQueryDtoMap.get(s.getRoomCode()).getRoomName();
                 if (Objects.isNull(roomName)) {
                     throw new BusinessException("考场不存在");
@@ -248,7 +254,7 @@ public class TEExamStudentController {
 
     @ApiOperation(value = "考生删除接口")
     @RequestMapping(value = "/delete", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
+    @ApiResponses({ @ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class) })
     @Transactional
     public Result delete(@ApiParam(value = "考生id", required = true) @RequestBody List<Long> ids) {
         if (Objects.isNull(ids) || ids.size() == 0) {
@@ -264,9 +270,9 @@ public class TEExamStudentController {
     @ApiOperation(value = "考生导入接口")
     @RequestMapping(value = "/import", method = RequestMethod.POST)
     @Transactional
-    @ApiResponses({@ApiResponse(code = 200, message = "{\"taskId\":0}", response = Result.class)})
+    @ApiResponses({ @ApiResponse(code = 200, message = "{\"taskId\":0}", response = Result.class) })
     public Result importData(@ApiParam(value = "上传文件", required = true) @RequestParam MultipartFile file,
-                             @ApiParam(value = "考试批次id", required = true) @RequestParam Long examId) throws IOException {
+            @ApiParam(value = "考试批次id", required = true) @RequestParam Long examId) throws IOException {
         if (Objects.isNull(file) || Objects.equals(file, "")) {
             throw new BusinessException(ExceptionResultEnum.ATTACHMENT_IS_NULL);
         }
@@ -279,8 +285,9 @@ public class TEExamStudentController {
         Map transMap = new HashMap();
         try {
             TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
-            tbAttachment = tbAttachmentService.saveAttachment(file, ServletUtil.getRequestMd5(),
-                    ServletUtil.getRequestPath(), mapParameter, tbUser.getOrgId(), tbUser.getId());
+            tbAttachment = tbAttachmentService
+                    .saveAttachment(file, ServletUtil.getRequestMd5(), ServletUtil.getRequestPath(), mapParameter,
+                            UploadFileEnum.file, tbUser.getOrgId(), tbUser.getId());
             if (Objects.isNull(tbAttachment)) {
                 throw new BusinessException(ExceptionResultEnum.ATTACHMENT_ERROR);
             } else {
@@ -317,11 +324,13 @@ public class TEExamStudentController {
 
             // 获取考场代码和考场名称
             QueryWrapper<TBExamInvigilateUser> tbExamInvigilateUserQueryWrapper = new QueryWrapper<>();
-            tbExamInvigilateUserQueryWrapper.lambda().eq(TBExamInvigilateUser::getOrgId, teExam.getOrgId()).eq(TBExamInvigilateUser::getExamId, examId);
-            List<TBExamInvigilateUser> tbExamInvigilateUserList = tbExamInvigilateUserService.list(tbExamInvigilateUserQueryWrapper);
+            tbExamInvigilateUserQueryWrapper.lambda().eq(TBExamInvigilateUser::getOrgId, teExam.getOrgId())
+                    .eq(TBExamInvigilateUser::getExamId, examId);
+            List<TBExamInvigilateUser> tbExamInvigilateUserList = tbExamInvigilateUserService
+                    .list(tbExamInvigilateUserQueryWrapper);
             if (Objects.nonNull(tbExamInvigilateUserList) && tbExamInvigilateUserList.size() > 0) {
-                Map<String, TBExamInvigilateUser> tbExamInvigilateUserMap = tbExamInvigilateUserList.stream()
-                        .collect(Collectors.toMap(TBExamInvigilateUser::getRoomCode, Function.identity(), (dto1, dto2) -> dto1));
+                Map<String, TBExamInvigilateUser> tbExamInvigilateUserMap = tbExamInvigilateUserList.stream().collect(
+                        Collectors.toMap(TBExamInvigilateUser::getRoomCode, Function.identity(), (dto1, dto2) -> dto1));
                 transMap.put("tbExamInvigilateUserMap", tbExamInvigilateUserMap);
             }
             transMap.put("remark", tbAttachment.getRemark());
@@ -333,7 +342,7 @@ public class TEExamStudentController {
         } catch (Exception e) {
             log.error("请求出错", e);
             if (Objects.nonNull(tbAttachment)) {
-                tbAttachmentService.deleteAttachment(mapParameter, tbAttachment);
+                tbAttachmentService.deleteAttachment(mapParameter, UploadFileEnum.file, tbAttachment);
             }
             if (e instanceof BusinessException) {
                 throw new BusinessException(e.getMessage());
@@ -346,30 +355,35 @@ public class TEExamStudentController {
 
     @ApiOperation(value = "成绩查询接口")
     @RequestMapping(value = "/mark/result", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "考试批次信息", response = MarkResultDto.class)})
+    @ApiResponses({ @ApiResponse(code = 200, message = "考试批次信息", response = MarkResultDto.class) })
     public Result markResult(@ApiParam(value = "考试批次id", required = true) @RequestParam Long examId,
-                             @ApiParam(value = "考试场次id", required = false) @RequestParam(required = false) Long activityId,
-                             @ApiParam(value = "证件号", required = false) @RequestParam(required = false) String identity,
-                             @ApiParam(value = "姓名", required = false) @RequestParam(required = false) String name,
-                             @ApiParam(value = "科目代码", required = false) @RequestParam(required = false) String courseCode,
-                             @ApiParam(value = "分页页码", required = true) @RequestParam int pageNumber,
-                             @ApiParam(value = "分页数", required = true) @RequestParam int pageSize) {
+            @ApiParam(value = "考试场次id", required = false) @RequestParam(required = false) Long activityId,
+            @ApiParam(value = "证件号", required = false) @RequestParam(required = false) String identity,
+            @ApiParam(value = "姓名", required = false) @RequestParam(required = false) String name,
+            @ApiParam(value = "科目代码", required = false) @RequestParam(required = false) String courseCode,
+            @ApiParam(value = "分页页码", required = true) @RequestParam int pageNumber,
+            @ApiParam(value = "分页数", required = true) @RequestParam int pageSize) {
         if (Objects.isNull(examId) || Objects.equals(examId, "")) {
             throw new BusinessException(ExceptionResultEnum.EXAM_ID_IS_NULL);
         }
         commonMarkResult(examId);
-        IPage<MarkResultDto> markResultDtoIPage = teExamStudentService.markResultQuery(new Page<>(pageNumber, pageSize), examId, activityId, identity, name, courseCode);
+        IPage<MarkResultDto> markResultDtoIPage = teExamStudentService
+                .markResultQuery(new Page<>(pageNumber, pageSize), examId, activityId, identity, name, courseCode);
         if (Objects.nonNull(markResultDtoIPage)) {
             List<MarkResultDto> markResultDtoList = markResultDtoIPage.getRecords();
             if (Objects.nonNull(markResultDtoList) && markResultDtoList.size() > 0) {
                 for (MarkResultDto markResultDto : markResultDtoList) {
                     if (Objects.nonNull(markResultDto.getExamId())) {
                         ExamCacheBean examCacheBean = teExamService.getExamCacheBean(markResultDto.getExamId());
-                        TOeExamRecord tOeExamRecord = tOeExamRecordService.findMarkResult(markResultDto, examCacheBean.getRecordSelectStrategy());
+                        TOeExamRecord tOeExamRecord = tOeExamRecordService
+                                .findMarkResult(markResultDto, examCacheBean.getRecordSelectStrategy());
                         if (Objects.nonNull(tOeExamRecord)) {
-                            markResultDto.setObjectiveScore(Objects.isNull(tOeExamRecord.getObjectiveScore()) ? 0 : tOeExamRecord.getObjectiveScore());
+                            markResultDto.setObjectiveScore(Objects.isNull(tOeExamRecord.getObjectiveScore()) ?
+                                    0 :
+                                    tOeExamRecord.getObjectiveScore());
                             markResultDto.setRecordId(tOeExamRecord.getId());
-                            markResultDto.setSumScore(markResultDto.getObjectiveScore() + markResultDto.getSubjectiveScore());
+                            markResultDto.setSumScore(
+                                    markResultDto.getObjectiveScore() + markResultDto.getSubjectiveScore());
                         }
                     }
                 }
@@ -381,12 +395,12 @@ public class TEExamStudentController {
     @ApiOperation(value = "成绩查询简版导出接口")
     @RequestMapping(value = "/mark/result/simple/export", method = RequestMethod.POST)
     @Transactional
-    @ApiResponses({@ApiResponse(code = 200, message = "{\"taskId\":0}", response = Result.class)})
+    @ApiResponses({ @ApiResponse(code = 200, message = "{\"taskId\":0}", response = Result.class) })
     public Result markResultSimpleExport(@ApiParam(value = "考试批次id", required = true) @RequestParam Long examId,
-                                         @ApiParam(value = "考试场次id", required = false) @RequestParam(required = false) Long activityId,
-                                         @ApiParam(value = "证件号", required = false) @RequestParam(required = false) String identity,
-                                         @ApiParam(value = "姓名", required = false) @RequestParam(required = false) String name,
-                                         @ApiParam(value = "科目代码", required = false) @RequestParam(required = false) String courseCode) {
+            @ApiParam(value = "考试场次id", required = false) @RequestParam(required = false) Long activityId,
+            @ApiParam(value = "证件号", required = false) @RequestParam(required = false) String identity,
+            @ApiParam(value = "姓名", required = false) @RequestParam(required = false) String name,
+            @ApiParam(value = "科目代码", required = false) @RequestParam(required = false) String courseCode) {
         if (Objects.isNull(examId) || Objects.equals(examId, "")) {
             throw new BusinessException(ExceptionResultEnum.EXAM_ID_IS_NULL);
         }
@@ -396,7 +410,8 @@ public class TEExamStudentController {
             Map transMap = new HashMap();
             TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
             //往任务表里插一条数据
-            tbTaskHistory = new TBTaskHistory(TaskTypeEnum.EXPORT_MARK_RESULT_SIMPLE, TaskStatusEnum.INIT, SystemConstant.EXPORT_INIT, 0d, tbUser.getId(), tbUser.getOrgId());
+            tbTaskHistory = new TBTaskHistory(TaskTypeEnum.EXPORT_MARK_RESULT_SIMPLE, TaskStatusEnum.INIT,
+                    SystemConstant.EXPORT_INIT, 0d, tbUser.getId(), tbUser.getOrgId());
             tbTaskHistory.setExamId(examId);
             taskHistoryService.save(tbTaskHistory);
             transMap.put("tbTaskHistory", tbTaskHistory);
@@ -408,7 +423,9 @@ public class TEExamStudentController {
             transMap.put("name", name);
             transMap.put("courseCode", courseCode);
             //mq发送消息start
-            MqDto mqDto = new MqDto(MqTopicEnum.THEMIS_TOPIC.getCode(), MqTagEnum.MARK_RESULT_SIMPLE_EXPORT.name(), transMap, MqTagEnum.MARK_RESULT_SIMPLE_EXPORT, String.valueOf(tbTaskHistory.getId()), tbUser.getName());
+            MqDto mqDto = new MqDto(MqTopicEnum.THEMIS_TOPIC.getCode(), MqTagEnum.MARK_RESULT_SIMPLE_EXPORT.name(),
+                    transMap, MqTagEnum.MARK_RESULT_SIMPLE_EXPORT, String.valueOf(tbTaskHistory.getId()),
+                    tbUser.getName());
             mqDtoService.assembleSendOneWayMsg(mqDto);
             //mq发送消息end
         } catch (Exception e) {
@@ -425,12 +442,12 @@ public class TEExamStudentController {
     @ApiOperation(value = "成绩查询标准版导出接口")
     @RequestMapping(value = "/mark/result/standard/export", method = RequestMethod.POST)
     @Transactional
-    @ApiResponses({@ApiResponse(code = 200, message = "{\"taskId\":0}", response = Result.class)})
+    @ApiResponses({ @ApiResponse(code = 200, message = "{\"taskId\":0}", response = Result.class) })
     public Result markResultStandardExport(@ApiParam(value = "考试批次id", required = true) @RequestParam Long examId,
-                                           @ApiParam(value = "考试场次id", required = false) @RequestParam(required = false) Long activityId,
-                                           @ApiParam(value = "证件号", required = false) @RequestParam(required = false) String identity,
-                                           @ApiParam(value = "姓名", required = false) @RequestParam(required = false) String name,
-                                           @ApiParam(value = "科目代码", required = false) @RequestParam(required = false) String courseCode) {
+            @ApiParam(value = "考试场次id", required = false) @RequestParam(required = false) Long activityId,
+            @ApiParam(value = "证件号", required = false) @RequestParam(required = false) String identity,
+            @ApiParam(value = "姓名", required = false) @RequestParam(required = false) String name,
+            @ApiParam(value = "科目代码", required = false) @RequestParam(required = false) String courseCode) {
         if (Objects.isNull(examId) || Objects.equals(examId, "")) {
             throw new BusinessException(ExceptionResultEnum.EXAM_ID_IS_NULL);
         }
@@ -440,7 +457,8 @@ public class TEExamStudentController {
             Map transMap = new HashMap();
             TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
             //往任务表里插一条数据
-            tbTaskHistory = new TBTaskHistory(TaskTypeEnum.EXPORT_MARK_RESULT_STANDARD, TaskStatusEnum.INIT, SystemConstant.EXPORT_INIT, 0d, tbUser.getId(), tbUser.getOrgId());
+            tbTaskHistory = new TBTaskHistory(TaskTypeEnum.EXPORT_MARK_RESULT_STANDARD, TaskStatusEnum.INIT,
+                    SystemConstant.EXPORT_INIT, 0d, tbUser.getId(), tbUser.getOrgId());
             tbTaskHistory.setExamId(examId);
             taskHistoryService.save(tbTaskHistory);
             transMap.put("tbTaskHistory", tbTaskHistory);
@@ -452,7 +470,9 @@ public class TEExamStudentController {
             transMap.put("name", name);
             transMap.put("courseCode", courseCode);
             //mq发送消息start
-            MqDto mqDto = new MqDto(MqTopicEnum.THEMIS_TOPIC.getCode(), MqTagEnum.MARK_RESULT_STANDARD_EXPORT.name(), transMap, MqTagEnum.MARK_RESULT_STANDARD_EXPORT, String.valueOf(tbTaskHistory.getId()), tbUser.getName());
+            MqDto mqDto = new MqDto(MqTopicEnum.THEMIS_TOPIC.getCode(), MqTagEnum.MARK_RESULT_STANDARD_EXPORT.name(),
+                    transMap, MqTagEnum.MARK_RESULT_STANDARD_EXPORT, String.valueOf(tbTaskHistory.getId()),
+                    tbUser.getName());
             mqDtoService.assembleSendOneWayMsg(mqDto);
             //mq发送消息end
         } catch (Exception e) {
@@ -477,11 +497,13 @@ public class TEExamStudentController {
             throw new BusinessException(ExceptionResultEnum.EXAM_NO);
         }
         InvigilateMonitorStatusEnum invigilateMonitorStatusEnum = examCacheBean.getMonitorStatus();//监考状态
-        if (Objects.nonNull(invigilateMonitorStatusEnum) && !Objects.equals(invigilateMonitorStatusEnum, InvigilateMonitorStatusEnum.FINISHED)) {
+        if (Objects.nonNull(invigilateMonitorStatusEnum) && !Objects
+                .equals(invigilateMonitorStatusEnum, InvigilateMonitorStatusEnum.FINISHED)) {
             throw new BusinessException("当前批次监考未结束,请在结束后操作");
         }
         ScoreStatusEnum scoreStatusEnum = examCacheBean.getScoreStatus();//算分状态
-        if (Objects.nonNull(scoreStatusEnum) && (Objects.equals(scoreStatusEnum, ScoreStatusEnum.CALCULATING) || Objects.equals(scoreStatusEnum, ScoreStatusEnum.NEED_CALCULATE))) {
+        if (Objects.nonNull(scoreStatusEnum) && (Objects.equals(scoreStatusEnum, ScoreStatusEnum.CALCULATING) || Objects
+                .equals(scoreStatusEnum, ScoreStatusEnum.NEED_CALCULATE))) {
             throw new BusinessException("当前批次算分未结束,请在结束后操作");
         }
         QueryWrapper<TEExamCourse> teExamCourseQueryWrapper = new QueryWrapper<>();

+ 10 - 6
themis-business/src/main/java/com/qmth/themis/business/service/TBAttachmentService.java

@@ -2,6 +2,7 @@ package com.qmth.themis.business.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.qmth.themis.business.entity.TBAttachment;
+import com.qmth.themis.business.enums.UploadFileEnum;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.io.File;
@@ -30,7 +31,8 @@ public interface TBAttachmentService extends IService<TBAttachment> {
      * @return
      * @throws IOException
      */
-    TBAttachment saveAttachment(MultipartFile file, String md5, String path, Map<String, Object> map, Long orgId, Long userId) throws IOException;
+    TBAttachment saveAttachment(MultipartFile file, String md5, String path, Map<String, Object> map,
+            UploadFileEnum type, Long orgId, Long userId) throws IOException;
 
     /**
      * 保存附件
@@ -42,14 +44,16 @@ public interface TBAttachmentService extends IService<TBAttachment> {
      * @return
      * @throws IOException
      */
-    TBAttachment saveAttachment(String path, Map<String, Object> map, Long orgId, Long userId) throws IOException;
+    TBAttachment saveAttachment(String path, Map<String, Object> map, UploadFileEnum type, Long orgId, Long userId)
+            throws IOException;
+
     /**
      * 删除附件
      *
      * @param map
      * @param tbAttachment
      */
-    void deleteAttachment(Map<String, Object> map, TBAttachment tbAttachment);
+    void deleteAttachment(Map<String, Object> map, UploadFileEnum type, TBAttachment tbAttachment);
 
     /**
      * 批量删除附件
@@ -57,8 +61,8 @@ public interface TBAttachmentService extends IService<TBAttachment> {
      * @param map
      * @param list
      */
-    void batchDeleteAttachment(Map<String, Object> map, List<Map> list);
+    void batchDeleteAttachment(Map<String, Object> map, UploadFileEnum type, List<Map> list);
 
-	TBAttachment saveAttachment(File file, String md5, String path, Map<String, Object> map, Long orgId, Long userId)
-			throws IOException;
+    TBAttachment saveAttachment(File file, String md5, String path, Map<String, Object> map, UploadFileEnum type,
+            Long orgId, Long userId) throws IOException;
 }

+ 33 - 27
themis-business/src/main/java/com/qmth/themis/business/service/impl/TBAttachmentServiceImpl.java

@@ -35,7 +35,9 @@ import java.util.*;
  * @Date: 2020-04-17
  */
 @Service
-public class TBAttachmentServiceImpl extends ServiceImpl<TBAttachmentMapper, TBAttachment> implements TBAttachmentService {
+public class TBAttachmentServiceImpl extends ServiceImpl<TBAttachmentMapper, TBAttachment>
+        implements TBAttachmentService {
+
     private final static Logger log = LoggerFactory.getLogger(TBAttachmentServiceImpl.class);
 
     @Resource
@@ -55,7 +57,8 @@ public class TBAttachmentServiceImpl extends ServiceImpl<TBAttachmentMapper, TBA
      */
     @Override
     @Transactional
-    public TBAttachment saveAttachment(MultipartFile file, String md5, String path, Map<String, Object> map, Long orgId, Long userId) throws IOException {
+    public TBAttachment saveAttachment(MultipartFile file, String md5, String path, Map<String, Object> map,
+            UploadFileEnum type, Long orgId, Long userId) throws IOException {
         log.info("ossMap:{}", JacksonUtil.parseJson(map));
         TBAttachment tbAttachment = null;
         try {
@@ -75,7 +78,8 @@ public class TBAttachmentServiceImpl extends ServiceImpl<TBAttachmentMapper, TBA
             long size = file.getSize();
             BigDecimal b = new BigDecimal(size);
             BigDecimal num = new BigDecimal(1024);
-            b = b.divide(num, 2, BigDecimal.ROUND_HALF_UP).divide(num, 2, BigDecimal.ROUND_HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP);
+            b = b.divide(num, 2, BigDecimal.ROUND_HALF_UP).divide(num, 2, BigDecimal.ROUND_HALF_UP)
+                    .setScale(2, BigDecimal.ROUND_HALF_UP);
             if (b.doubleValue() > 200) {
                 throw new BusinessException("文件大小不能超过200MB");
             }
@@ -111,21 +115,21 @@ public class TBAttachmentServiceImpl extends ServiceImpl<TBAttachmentMapper, TBA
             if (Objects.isNull(uploadType)) {
                 throw new BusinessException(ExceptionResultEnum.ATTACHMENT_TYPE_IS_NULL);
             } else if (Objects.equals(uploadType, UploadFileEnum.base_photo.name())) {
-                stringJoiner.add(uploadType)
-                        .add(File.separator).add(String.valueOf(orgId));
+                stringJoiner.add(uploadType).add(File.separator).add(String.valueOf(orgId));
             } else {
                 stringJoiner.add(uploadType);
             }
-            stringJoiner.add(File.separator).add(String.valueOf(nowTime.getYear()))
-                    .add(File.separator).add(String.valueOf(nowTime.getMonthValue()))
-                    .add(File.separator).add(String.valueOf(nowTime.getDayOfMonth()));
+            stringJoiner.add(File.separator).add(String.valueOf(nowTime.getYear())).add(File.separator)
+                    .add(String.valueOf(nowTime.getMonthValue())).add(File.separator)
+                    .add(String.valueOf(nowTime.getDayOfMonth()));
             if (oss) {//上传至oss
                 stringJoiner.add(File.separator).add(String.valueOf(UUID.randomUUID()).replaceAll("-", ""))
                         .add(tbAttachment.getType());
-                ossUtil.ossUpload(map, stringJoiner.toString(), file.getInputStream());
+                ossUtil.upload(ossUtil.isPublic(type), stringJoiner.toString(), file.getInputStream());
             } else {//上传至服务器
-                File finalFile = new File(stringJoiner.add(File.separator).add(String.valueOf(UUID.randomUUID()).replaceAll("-", ""))
-                        .add(tbAttachment.getType()).toString());
+                File finalFile = new File(
+                        stringJoiner.add(File.separator).add(String.valueOf(UUID.randomUUID()).replaceAll("-", ""))
+                                .add(tbAttachment.getType()).toString());
                 if (!finalFile.exists()) {
                     finalFile.getParentFile().mkdirs();
                     finalFile.createNewFile();
@@ -145,7 +149,7 @@ public class TBAttachmentServiceImpl extends ServiceImpl<TBAttachmentMapper, TBA
             this.save(tbAttachment);
         } catch (Exception e) {
             log.error("请求出错", e);
-            deleteAttachment(map, tbAttachment);
+            deleteAttachment(map, type, tbAttachment);
             if (e instanceof BusinessException) {
                 throw new BusinessException(e.getMessage());
             } else {
@@ -157,7 +161,8 @@ public class TBAttachmentServiceImpl extends ServiceImpl<TBAttachmentMapper, TBA
 
     @Override
     @Transactional
-    public TBAttachment saveAttachment(File file, String md5, String path, Map<String, Object> map, Long orgId, Long userId) throws IOException {
+    public TBAttachment saveAttachment(File file, String md5, String path, Map<String, Object> map, UploadFileEnum type,
+            Long orgId, Long userId) throws IOException {
         log.info("ossMap:{}", JacksonUtil.parseJson(map));
         TBAttachment tbAttachment = null;
         try {
@@ -201,21 +206,21 @@ public class TBAttachmentServiceImpl extends ServiceImpl<TBAttachmentMapper, TBA
             if (Objects.isNull(uploadType)) {
                 throw new BusinessException(ExceptionResultEnum.ATTACHMENT_TYPE_IS_NULL);
             } else if (Objects.equals(uploadType, UploadFileEnum.base_photo.name())) {
-                stringJoiner.add(uploadType)
-                        .add(File.separator).add(String.valueOf(orgId));
+                stringJoiner.add(uploadType).add(File.separator).add(String.valueOf(orgId));
             } else {
                 stringJoiner.add(uploadType);
             }
-            stringJoiner.add(File.separator).add(String.valueOf(nowTime.getYear()))
-                    .add(File.separator).add(String.valueOf(nowTime.getMonthValue()))
-                    .add(File.separator).add(String.valueOf(nowTime.getDayOfMonth()));
+            stringJoiner.add(File.separator).add(String.valueOf(nowTime.getYear())).add(File.separator)
+                    .add(String.valueOf(nowTime.getMonthValue())).add(File.separator)
+                    .add(String.valueOf(nowTime.getDayOfMonth()));
             if (oss) {//上传至oss
                 stringJoiner.add(File.separator).add(String.valueOf(UUID.randomUUID()).replaceAll("-", ""))
                         .add(tbAttachment.getType());
-                OssUtil.ossUpload(map, stringJoiner.toString(), file);
+                ossUtil.upload(ossUtil.isPublic(type), stringJoiner.toString(), file);
             } else {//上传至服务器
-                File finalFile = new File(stringJoiner.add(File.separator).add(String.valueOf(UUID.randomUUID()).replaceAll("-", ""))
-                        .add(tbAttachment.getType()).toString());
+                File finalFile = new File(
+                        stringJoiner.add(File.separator).add(String.valueOf(UUID.randomUUID()).replaceAll("-", ""))
+                                .add(tbAttachment.getType()).toString());
                 if (!finalFile.exists()) {
                     finalFile.getParentFile().mkdirs();
                     finalFile.createNewFile();
@@ -235,7 +240,7 @@ public class TBAttachmentServiceImpl extends ServiceImpl<TBAttachmentMapper, TBA
             this.save(tbAttachment);
         } catch (Exception e) {
             log.error("请求出错", e);
-            deleteAttachment(map, tbAttachment);
+            deleteAttachment(map, type, tbAttachment);
             if (e instanceof BusinessException) {
                 throw new BusinessException(e.getMessage());
             } else {
@@ -246,7 +251,8 @@ public class TBAttachmentServiceImpl extends ServiceImpl<TBAttachmentMapper, TBA
     }
 
     @Override
-    public TBAttachment saveAttachment(String path, Map<String, Object> map, Long orgId, Long userId) throws IOException {
+    public TBAttachment saveAttachment(String path, Map<String, Object> map, UploadFileEnum type, Long orgId,
+            Long userId) throws IOException {
         return null;
     }
 
@@ -257,12 +263,12 @@ public class TBAttachmentServiceImpl extends ServiceImpl<TBAttachmentMapper, TBA
      * @param tbAttachment
      */
     @Override
-    public void deleteAttachment(Map<String, Object> map, TBAttachment tbAttachment) {
+    public void deleteAttachment(Map<String, Object> map, UploadFileEnum fileType, TBAttachment tbAttachment) {
         if (Objects.nonNull(tbAttachment) && Objects.nonNull(tbAttachment.getRemark())) {
             JSONObject jsonObject = JSONObject.parseObject(tbAttachment.getRemark());
             String type = String.valueOf(jsonObject.get(SystemConstant.TYPE));
             if (Objects.nonNull(type) && Objects.equals(type, SystemConstant.OSS)) {//删除阿里云附件
-                ossUtil.ossDelete(map, jsonObject.get(SystemConstant.PATH).toString());
+                ossUtil.delete(ossUtil.isPublic(fileType), jsonObject.get(SystemConstant.PATH).toString());
             } else {//删除服务器附件
                 File file = new File(jsonObject.get(SystemConstant.PATH).toString());
                 file.delete();
@@ -277,7 +283,7 @@ public class TBAttachmentServiceImpl extends ServiceImpl<TBAttachmentMapper, TBA
      * @param list
      */
     @Override
-    public void batchDeleteAttachment(Map<String, Object> map, List<Map> list) {
+    public void batchDeleteAttachment(Map<String, Object> map, UploadFileEnum fileType, List<Map> list) {
         List<String> paths = null;
         String type = null;
         if (Objects.nonNull(map)) {
@@ -289,7 +295,7 @@ public class TBAttachmentServiceImpl extends ServiceImpl<TBAttachmentMapper, TBA
             }
         }
         if (Objects.nonNull(type) && Objects.equals(type, SystemConstant.OSS)) {//删除阿里云附件
-            ossUtil.ossBatchDelete(map, paths);
+            ossUtil.batchDelete(ossUtil.isPublic(fileType), paths);
         } else if (Objects.nonNull(type) && Objects.equals(type, SystemConstant.LOCAL)) {//删除服务器附件
             for (String s : paths) {
                 File file = new File(s);

+ 16 - 40
themis-business/src/main/java/com/qmth/themis/business/service/impl/TEExamPaperServiceImpl.java

@@ -7,13 +7,11 @@ import com.qmth.themis.business.cache.RedisKeyHelper;
 import com.qmth.themis.business.cache.bean.ExamPaperCacheBean;
 import com.qmth.themis.business.cache.bean.ObjectiveAnswerCacheBean;
 import com.qmth.themis.business.constant.SpringContextHolder;
-import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.business.dao.TEExamPaperMapper;
 import com.qmth.themis.business.entity.TEExamPaper;
 import com.qmth.themis.business.service.TEExamPaperService;
 import com.qmth.themis.business.util.OssUtil;
 import com.qmth.themis.common.exception.BusinessException;
-import com.qmth.themis.common.util.FileUtil;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.cache.annotation.CacheEvict;
 import org.springframework.cache.annotation.CachePut;
@@ -22,7 +20,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
-import java.io.File;
+import java.nio.charset.StandardCharsets;
 import java.util.*;
 
 /**
@@ -34,8 +32,10 @@ import java.util.*;
  */
 @Service
 public class TEExamPaperServiceImpl extends ServiceImpl<TEExamPaperMapper, TEExamPaper> implements TEExamPaperService {
+
     @Resource
     OssUtil ossUtil;
+
     @Resource
     TEExamPaperMapper teExamPaperMapper;
 
@@ -138,29 +138,16 @@ public class TEExamPaperServiceImpl extends ServiceImpl<TEExamPaperMapper, TEExa
         if (StringUtils.isBlank(ep.getAnswerPath())) {//没有答案文件
             return null;
         }
-        String structUrl = OssUtil.getUrlForPrivateBucket(ossUtil.getAliYunOssPrivateDomain().getMap(), ep.getStructPath());
-        String answerUrl = OssUtil.getUrlForPrivateBucket(ossUtil.getAliYunOssPrivateDomain().getMap(), ep.getAnswerPath());
-        String tempDir = SystemConstant.TEMP_FILES_DIR;
-        String dir = tempDir + "/" + uuid() + "/";
-        File dfile = new File(dir);
         try {
-            dfile.mkdirs();
-            File structFile = new File(dir + "struct.json");
-            FileUtil.saveUrlAsFile(structUrl, structFile);
-//            File answerEncryptFile = new File(dir + "answer_encrypt_file.json");
-//            FileUtil.saveUrlAsFile(answerUrl, answerEncryptFile);
-            File answerFile = new File(dir + "answer_file.json");
-            FileUtil.saveUrlAsFile(answerUrl, answerFile);
-//            FileUtil.decryptFile(answerEncryptFile, answerFile, ep.getDecryptSecret(), ep.getDecryptVector());
-            String structJson = FileUtil.readFileContent(structFile);
-            String answerjson = FileUtil.readFileContent(answerFile);
+            String structJson = new String(ossUtil.download(false, ep.getStructPath()), StandardCharsets.UTF_8);
+            String answerjson = new String(ossUtil.download(false, ep.getAnswerPath()), StandardCharsets.UTF_8);
             return buildObjectiveAnswerCache(structJson, answerjson);
-        } finally {
-            FileUtil.deleteFolder(dir);
+        } catch (Exception e) {
+            log.error("get struct/answer json error", e);
+            throw new RuntimeException(e);
         }
     }
 
-
     private Map<String, ObjectiveAnswerCacheBean> buildObjectiveAnswerCache(String structStr, String answerStr) {
         Map<String, ObjectiveAnswerCacheBean> map = new HashMap<String, ObjectiveAnswerCacheBean>();
         JSONObject answerJson = JSONObject.parseObject(answerStr);
@@ -177,14 +164,11 @@ public class TEExamPaperServiceImpl extends ServiceImpl<TEExamPaperMapper, TEExa
                 Integer subNum = structquestion.getInteger("number");
                 Double score = structquestion.getDouble("score");
                 Integer structType = structquestion.getInteger("structType");
-                if (structType.intValue() == 1
-                        || structType.intValue() == 2
-                        || structType.intValue() == 3) {
+                if (structType.intValue() == 1 || structType.intValue() == 2 || structType.intValue() == 3) {
                     ObjectiveAnswerCacheBean bean = new ObjectiveAnswerCacheBean();
                     bean.setScore(score);
                     bean.setStructType(structType);
-                    if (structType.intValue() == 1
-                            || structType.intValue() == 2) {
+                    if (structType.intValue() == 1 || structType.intValue() == 2) {
                         JSONArray answer = answerquestion.getJSONArray("answer");
                         bean.setChoiceAnswer(answer);
                     }
@@ -204,14 +188,12 @@ public class TEExamPaperServiceImpl extends ServiceImpl<TEExamPaperMapper, TEExa
                         Double subScore = structsubquestion.getDouble("score");
                         Integer subStructType = structsubquestion.getInteger("structType");
 
-                        if (subStructType.intValue() == 1
-                                || subStructType.intValue() == 2
+                        if (subStructType.intValue() == 1 || subStructType.intValue() == 2
                                 || subStructType.intValue() == 3) {
                             ObjectiveAnswerCacheBean bean = new ObjectiveAnswerCacheBean();
                             bean.setScore(subScore);
                             bean.setStructType(subStructType);
-                            if (subStructType.intValue() == 1
-                                    || subStructType.intValue() == 2) {
+                            if (subStructType.intValue() == 1 || subStructType.intValue() == 2) {
                                 JSONArray answer = answersubquestion.getJSONArray("answer");
                                 bean.setChoiceAnswer(answer);
                             }
@@ -270,18 +252,12 @@ public class TEExamPaperServiceImpl extends ServiceImpl<TEExamPaperMapper, TEExa
         if (StringUtils.isBlank(ep.getStructPath())) {//没有试卷结构文件
             return null;
         }
-        String structUrl = OssUtil.getUrlForPrivateBucket(ossUtil.getAliYunOssPrivateDomain().getMap(), ep.getStructPath());
-        String tempDir = SystemConstant.TEMP_FILES_DIR;
-        String dir = tempDir + "/" + uuid() + "/";
-        File dfile = new File(dir);
         try {
-            dfile.mkdirs();
-            File structFile = new File(dir + "struct.json");
-            FileUtil.saveUrlAsFile(structUrl, structFile);
-            String structJson = FileUtil.readFileContent(structFile);
+            String structJson = new String(ossUtil.download(false, ep.getStructPath()), StandardCharsets.UTF_8);
             return buildPaperStructCache(structJson);
-        } finally {
-            FileUtil.deleteFolder(dir);
+        } catch (Exception e) {
+            log.error("get struct json error", e);
+            throw new RuntimeException(e);
         }
     }
 

+ 155 - 89
themis-business/src/main/java/com/qmth/themis/business/service/impl/TEExamServiceImpl.java

@@ -60,7 +60,9 @@ import java.util.stream.Collectors;
  */
 @Service
 public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> implements TEExamService {
+
     private SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
+
     @Resource
     TEExamMapper teExamMapper;
 
@@ -112,7 +114,8 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
      * @return
      */
     @Override
-    public IPage<TEExamQueryDto> examQuery(IPage<Map> iPage, Long userId, Long id, String code, String name, String mode, Integer enable, Long orgId, String type) {
+    public IPage<TEExamQueryDto> examQuery(IPage<Map> iPage, Long userId, Long id, String code, String name,
+            String mode, Integer enable, Long orgId, String type) {
         return teExamMapper.examQuery(iPage, userId, id, code, name, mode, enable, orgId, type);
     }
 
@@ -129,7 +132,8 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
         List<TEExamDto> list = teExamMapper.getWaitingExam(studentId, examId, orgId);
         if (Objects.nonNull(list) && list.size() > 0) {
             Set<Long> examActivityIds = list.stream().map(s -> s.getExamActivityId()).collect(Collectors.toSet());
-            List<TEExamActivityDto> teExamActivityList = teExamActivityService.getWaitingExam(studentId, examActivityIds, null);
+            List<TEExamActivityDto> teExamActivityList = teExamActivityService
+                    .getWaitingExam(studentId, examActivityIds, null);
             Map<Long, Set<TEExamActivityDto>> map = new HashMap<>();
             teExamActivityList.forEach(v -> {
                 Set<TEExamActivityDto> teExamActivityDtos = null;
@@ -141,8 +145,14 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
                 teExamActivityDtos.add(v);
                 map.put(v.getExamId(), teExamActivityDtos);
                 ExamCacheBean examCache = getExamCacheBeanNative(v.getExamId());
-                ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(v.getExamStudentId());
-                v.setLeftExamCount((examCache.getExamCount().intValue() - (examStudentCacheBean.getAlreadyExamCount().intValue()) < 0 ? 0 : examCache.getExamCount().intValue() - (examStudentCacheBean.getAlreadyExamCount().intValue())));
+                ExamStudentCacheBean examStudentCacheBean = teExamStudentService
+                        .getExamStudentCacheBean(v.getExamStudentId());
+                v.setLeftExamCount(
+                        (examCache.getExamCount().intValue() - (examStudentCacheBean.getAlreadyExamCount().intValue())
+                                < 0 ?
+                                0 :
+                                examCache.getExamCount().intValue() - (examStudentCacheBean.getAlreadyExamCount()
+                                        .intValue())));
                 if (Objects.nonNull(v.getInProcessLivenessFixedRangeStr())) {
                     String[] longs = v.getInProcessLivenessFixedRangeStr().trim().replaceAll(" ", "").split(",");
                     List inProcessLivenessFixedRange = new ArrayList();
@@ -156,19 +166,29 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
                         v.setInProcessLivenessFixedRange(inProcessLivenessFixedRange);
                     }
                 }
-                if (Objects.nonNull(v.getMonitorVideoSourceStr()) && !Objects.equals(v.getMonitorVideoSourceStr().toString().trim().replaceAll(" ", ""), "")) {
-                    v.setMonitorVideoSource(Arrays.asList(v.getMonitorVideoSourceStr().trim().toUpperCase().replaceAll(" ", "").split(",")));
+                if (Objects.nonNull(v.getMonitorVideoSourceStr()) && !Objects
+                        .equals(v.getMonitorVideoSourceStr().toString().trim().replaceAll(" ", ""), "")) {
+                    v.setMonitorVideoSource(Arrays.asList(
+                            v.getMonitorVideoSourceStr().trim().toUpperCase().replaceAll(" ", "").split(",")));
                     v.setMonitorAudioEnable(examCache.getMonitorAudioEnable());
                     //加入hardwareTest逻辑
-                    if (v.getMonitorVideoSourceStr().toUpperCase().contains(MonitorVideoSourceEnum.CLIENT_CAMERA.name()) || (Objects.nonNull(v.getEntryAuthenticationPolicy()) && (Objects.equals(v.getEntryAuthenticationPolicy(), EntryAuthenticationPolicyEnum.LIVENESS_VERIFY.name()) || Objects.equals(v.getEntryAuthenticationPolicy(), EntryAuthenticationPolicyEnum.FACE_VERIFY_FORCE.name()))) || (Objects.nonNull(v.getCameraPhotoUpload()) && v.getCameraPhotoUpload() == 1)) {
+                    if (v.getMonitorVideoSourceStr().toUpperCase().contains(MonitorVideoSourceEnum.CLIENT_CAMERA.name())
+                            || (Objects.nonNull(v.getEntryAuthenticationPolicy()) && (
+                            Objects.equals(v.getEntryAuthenticationPolicy(),
+                                    EntryAuthenticationPolicyEnum.LIVENESS_VERIFY.name()) || Objects
+                                    .equals(v.getEntryAuthenticationPolicy(),
+                                            EntryAuthenticationPolicyEnum.FACE_VERIFY_FORCE.name()))) || (
+                            Objects.nonNull(v.getCameraPhotoUpload()) && v.getCameraPhotoUpload() == 1)) {
                         List<String> hardwareTest = v.getHardwareTest();
                         if (Objects.isNull(hardwareTest)) {
                             hardwareTest = new ArrayList<>();
                         }
                         hardwareTest.add(HardwareTestEnum.CAMERA.name());
                         //取course缓存
-                        ExamCourseCacheBean examCourseCacheBean = teExamCourseService.getExamCourseCacheBean(v.getExamId(), v.getCourseCode());
-                        if (Objects.nonNull(examCourseCacheBean) && Objects.nonNull(examCourseCacheBean.getHasAudio()) && examCourseCacheBean.getHasAudio() == 1) {
+                        ExamCourseCacheBean examCourseCacheBean = teExamCourseService
+                                .getExamCourseCacheBean(v.getExamId(), v.getCourseCode());
+                        if (Objects.nonNull(examCourseCacheBean) && Objects.nonNull(examCourseCacheBean.getHasAudio())
+                                && examCourseCacheBean.getHasAudio() == 1) {
                             hardwareTest.add(HardwareTestEnum.AUDIOPLAY.name());
                         }
                         v.setHardwareTest(hardwareTest);
@@ -233,7 +253,8 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
         if (unFinishedRecordId != null) {
             Long recordId = unFinishedRecordId;
             if (examStudentId.equals(ExamRecordCacheUtil.getExamStudentId(recordId))) {//当前考生已存在候考的考试记录
-                ExamPaperCacheBean ep = teExamPaperService.getExamPaperCacheBean(ExamRecordCacheUtil.getPaperId(recordId));
+                ExamPaperCacheBean ep = teExamPaperService
+                        .getExamPaperCacheBean(ExamRecordCacheUtil.getPaperId(recordId));
                 ExamCourseCacheBean ec = teExamCourseService.getExamCourseCacheBean(es.getExamId(), es.getCourseCode());
                 ExamPrepareBean prepare = new ExamPrepareBean();
                 prepare.setRecordId(recordId);
@@ -243,14 +264,13 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
                         (ec.getObjectiveShuffle() == null || ec.getObjectiveShuffle().intValue() == 0 ? false : true));
                 prepare.setOptionShuffle(
                         (ec.getOptionShuffle() == null || ec.getOptionShuffle().intValue() == 0 ? false : true));
-                String paperurl = OssUtil.getUrlForPrivateBucket(ossUtil.getAliYunOssPrivateDomain().getMap(), ep.getPaperPath());
-                String structurl = OssUtil.getUrlForPrivateBucket(ossUtil.getAliYunOssPrivateDomain().getMap(), ep.getStructPath());
-                prepare.setPaperUrl(paperurl);
-                prepare.setStructUrl(structurl);
+                prepare.setPaperUrl(ossUtil.getPrivateUrl(ep.getPaperPath()));
+                prepare.setStructUrl(ossUtil.getPrivateUrl(ep.getStructPath()));
                 prepare.setMonitorAppId(tencentYunUtil.getTencentYunDomain().getAppId());
                 prepare.setMonitorKey(ExamRecordCacheUtil.getMonitorKey(recordId));
                 prepare.setMonitorUserId("s_" + tbSession.getId());
-                prepare.setMonitorUserSig(tencentYunUtil.getSign(prepare.getMonitorUserId(), SystemConstant.TENCENT_EXPIRE_TIME));
+                prepare.setMonitorUserSig(
+                        tencentYunUtil.getSign(prepare.getMonitorUserId(), SystemConstant.TENCENT_EXPIRE_TIME));
 
                 ExamActivityCacheBean ac = teExamActivityService.getExamActivityCacheBean(es.getExamActivityId());
                 ExamRecordCacheUtil.setStartTime(recordId, ac.getStartTime(), false);
@@ -259,8 +279,12 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
                 ExamRecordCacheUtil.setMinDurationSeconds(recordId, examCache.getMinDurationSeconds(), false);
                 ExamRecordCacheUtil.setMaxDurationSeconds(recordId, ac.getMaxDurationSeconds(), false);
                 ExamRecordCacheUtil.setForceFinish(recordId, examCache.getForceFinish(), false);
-                String[] columns = new String[]{ExamRecordFieldEnum.start_time.name(), ExamRecordFieldEnum.end_time.name(), ExamRecordFieldEnum.opening_seconds.name(), ExamRecordFieldEnum.min_duration_seconds.name(), ExamRecordFieldEnum.max_duration_seconds.name(), ExamRecordFieldEnum.force_finish.name()};
-                Object[] values = new Object[]{ac.getStartTime(), ac.getFinishTime(), ac.getOpeningSeconds(), examCache.getMinDurationSeconds(), ac.getMaxDurationSeconds(), examCache.getForceFinish()};
+                String[] columns = new String[] { ExamRecordFieldEnum.start_time.name(),
+                        ExamRecordFieldEnum.end_time.name(), ExamRecordFieldEnum.opening_seconds.name(),
+                        ExamRecordFieldEnum.min_duration_seconds.name(),
+                        ExamRecordFieldEnum.max_duration_seconds.name(), ExamRecordFieldEnum.force_finish.name() };
+                Object[] values = new Object[] { ac.getStartTime(), ac.getFinishTime(), ac.getOpeningSeconds(),
+                        examCache.getMinDurationSeconds(), ac.getMaxDurationSeconds(), examCache.getForceFinish() };
                 toeExamRecordService.dataUpdatesMq(recordId, columns, values);
                 return prepare;
             }
@@ -301,21 +325,22 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
         if (ec.getPaperIds() == null) {
             throw new BusinessException(ExceptionResultEnum.EXAM_COURSE_OR_EXAM_PAPER_NOT_BIND);
         }
-//        if (ec.getHasAnswer() == null || ec.getHasAnswer().intValue() == 0) {
-//            throw new BusinessException("考试科目答案未补全");
-//        }
+        //        if (ec.getHasAnswer() == null || ec.getHasAnswer().intValue() == 0) {
+        //            throw new BusinessException("考试科目答案未补全");
+        //        }
         // 根据权重选中试卷
         Long paperId = ec.getPaperIds().get(getPaperByWeight(ec.getPaperWeight()));
         ExamPaperCacheBean ep = teExamPaperService.getExamPaperCacheBean(paperId);
         if (ep == null) {
             throw new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_PAPER + ":" + paperId);
         }
-//        if (StringUtils.isBlank(ep.getAnswerPath())) {
-//            throw new BusinessException("试卷答案未上传:" + paperId);
-//        }
+        //        if (StringUtils.isBlank(ep.getAnswerPath())) {
+        //            throw new BusinessException("试卷答案未上传:" + paperId);
+        //        }
 
-        Long recordId = toeExamRecordService.saveByPrepare(es.getExamId(), es.getExamActivityId(), examStudentId,
-                paperId, es.getAlreadyExamCount() + 1);
+        Long recordId = toeExamRecordService
+                .saveByPrepare(es.getExamId(), es.getExamActivityId(), examStudentId, paperId,
+                        es.getAlreadyExamCount() + 1);
 
         es.setCurrentRecordId(recordId);
 
@@ -327,24 +352,25 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
                 (ec.getObjectiveShuffle() == null || ec.getObjectiveShuffle().intValue() == 0 ? false : true));
         prepare.setOptionShuffle(
                 (ec.getOptionShuffle() == null || ec.getOptionShuffle().intValue() == 0 ? false : true));
-        String paperurl = OssUtil.getUrlForPrivateBucket(ossUtil.getAliYunOssPrivateDomain().getMap(), ep.getPaperPath());
-        String structurl = OssUtil.getUrlForPrivateBucket(ossUtil.getAliYunOssPrivateDomain().getMap(), ep.getStructPath());
-        prepare.setPaperUrl(paperurl);
-        prepare.setStructUrl(structurl);
+        prepare.setPaperUrl(ossUtil.getPrivateUrl(ep.getPaperPath()));
+        prepare.setStructUrl(ossUtil.getPrivateUrl(ep.getStructPath()));
         prepare.setMonitorAppId(tencentYunUtil.getTencentYunDomain().getAppId());
         prepare.setMonitorKey(ExamRecordCacheUtil.getMonitorKey(recordId));
         prepare.setMonitorUserId("s_" + tbSession.getId());
-        prepare.setMonitorUserSig(tencentYunUtil.getSign(prepare.getMonitorUserId(), SystemConstant.TENCENT_EXPIRE_TIME));
+        prepare.setMonitorUserSig(
+                tencentYunUtil.getSign(prepare.getMonitorUserId(), SystemConstant.TENCENT_EXPIRE_TIME));
 
         // 更新考生缓存
         redisUtil.set(RedisKeyHelper.examStudentCacheKey(examStudentId), es);
         //更新场次-考试记录缓存
-        ExamActivityRecordCacheUtil.setExamRecordStatus(activityId, recordId, new ExamActivityRecordCacheBean(ExamRecordCacheUtil.getExamStudentId(recordId), ExamRecordCacheUtil.getStatus(recordId)));
+        ExamActivityRecordCacheUtil.setExamRecordStatus(activityId, recordId,
+                new ExamActivityRecordCacheBean(ExamRecordCacheUtil.getExamStudentId(recordId),
+                        ExamRecordCacheUtil.getStatus(recordId)));
         ExamingDataCacheUtil.setUnFinishedRecordId(studentId, recordId);
         //mq发送消息start
-//        TEStudentCacheDto teStudentCacheDto = (TEStudentCacheDto) redisUtil.getStudent(studentId);
-//        MqDto mqDto = new MqDto(MqTopicEnum.THEMIS_TOPIC.getCode(), MqTagEnum.STUDENT.name(), SystemOperationEnum.FIRST_PREPARE, MqTagEnum.STUDENT, String.valueOf(teStudentCacheDto.getId()), teStudentCacheDto.getIdentity());
-//        this.sendOeLogMessage(SystemOperationEnum.FIRST_PREPARE, examStudentId, recordId, mqDto);
+        //        TEStudentCacheDto teStudentCacheDto = (TEStudentCacheDto) redisUtil.getStudent(studentId);
+        //        MqDto mqDto = new MqDto(MqTopicEnum.THEMIS_TOPIC.getCode(), MqTagEnum.STUDENT.name(), SystemOperationEnum.FIRST_PREPARE, MqTagEnum.STUDENT, String.valueOf(teStudentCacheDto.getId()), teStudentCacheDto.getIdentity());
+        //        this.sendOeLogMessage(SystemOperationEnum.FIRST_PREPARE, examStudentId, recordId, mqDto);
         //mq发送消息end
         return prepare;
     }
@@ -354,7 +380,8 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
         transMap.put("examStudentId", examStudentId);
         transMap.put("alreadyExamCount", alreadyExamCount);
         transMap.put("currentRecordId", currentRecordId);
-        MqDto mqDto = new MqDto(MqTopicEnum.THEMIS_TOPIC.getCode(), MqTagEnum.EXAM_STUDNET_UPDATE.name(), transMap, MqTagEnum.EXAM_STUDNET_UPDATE, examStudentId.toString(), examStudentId.toString());
+        MqDto mqDto = new MqDto(MqTopicEnum.THEMIS_TOPIC.getCode(), MqTagEnum.EXAM_STUDNET_UPDATE.name(), transMap,
+                MqTagEnum.EXAM_STUDNET_UPDATE, examStudentId.toString(), examStudentId.toString());
         mqDtoService.assembleSendOneWayMsg(mqDto);
     }
 
@@ -459,17 +486,19 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
         if (Objects.nonNull(exam.getMonitorVideoSource())) {
             String[] strs = exam.getMonitorVideoSource().split(",");
             for (int i = 0; i < strs.length; i++) {
-                MonitorStatusSourceEnum clientCameraStatus = ExamRecordCacheUtil.getMonitorStatus(recordId, MonitorVideoSourceEnum.valueOf(strs[i]));
-                if (Objects.isNull(clientCameraStatus) || Objects.equals(MonitorStatusSourceEnum.STOP, clientCameraStatus)) {
+                MonitorStatusSourceEnum clientCameraStatus = ExamRecordCacheUtil
+                        .getMonitorStatus(recordId, MonitorVideoSourceEnum.valueOf(strs[i]));
+                if (Objects.isNull(clientCameraStatus) || Objects
+                        .equals(MonitorStatusSourceEnum.STOP, clientCameraStatus)) {
                     switch (strs[i]) {
-                        case "CLIENT_CAMERA":
-                            throw new BusinessException(ExceptionResultEnum.CLIENT_CAMERA_OFFLINE);
-                        case "CLIENT_SCREEN":
-                            throw new BusinessException(ExceptionResultEnum.CLIENT_SCREEN_OFFLINE);
-                        case "MOBILE_FIRST":
-                            throw new BusinessException(ExceptionResultEnum.MOBILE_FIRST_OFFLINE);
-                        default:
-                            throw new BusinessException(ExceptionResultEnum.MOBILE_SECOND_OFFLINE);
+                    case "CLIENT_CAMERA":
+                        throw new BusinessException(ExceptionResultEnum.CLIENT_CAMERA_OFFLINE);
+                    case "CLIENT_SCREEN":
+                        throw new BusinessException(ExceptionResultEnum.CLIENT_SCREEN_OFFLINE);
+                    case "MOBILE_FIRST":
+                        throw new BusinessException(ExceptionResultEnum.MOBILE_FIRST_OFFLINE);
+                    default:
+                        throw new BusinessException(ExceptionResultEnum.MOBILE_SECOND_OFFLINE);
                     }
                 }
             }
@@ -491,34 +520,49 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
         ExamRecordCacheUtil.setStatus(recordId, ExamRecordStatusEnum.ANSWERING, false);
         Long lastStartTime = System.currentTimeMillis();
         ExamRecordCacheUtil.setLastStartTime(recordId, lastStartTime, false);
-        String[] columns = new String[]{ExamRecordFieldEnum.first_start_time.name(), ExamRecordFieldEnum.status.name(), ExamRecordFieldEnum.last_start_time.name()};
-        Object[] values = new Object[]{firstStartTime, ExamRecordStatusEnum.ANSWERING, lastStartTime};
+        String[] columns = new String[] { ExamRecordFieldEnum.first_start_time.name(),
+                ExamRecordFieldEnum.status.name(), ExamRecordFieldEnum.last_start_time.name() };
+        Object[] values = new Object[] { firstStartTime, ExamRecordStatusEnum.ANSWERING, lastStartTime };
         toeExamRecordService.dataUpdatesMq(recordId, columns, values);
         //更新场次-考试记录缓存
-        ExamActivityRecordCacheUtil.setExamRecordStatus(activityId, recordId, new ExamActivityRecordCacheBean(ExamRecordCacheUtil.getExamStudentId(recordId), ExamRecordCacheUtil.getStatus(recordId)));
+        ExamActivityRecordCacheUtil.setExamRecordStatus(activityId, recordId,
+                new ExamActivityRecordCacheBean(ExamRecordCacheUtil.getExamStudentId(recordId),
+                        ExamRecordCacheUtil.getStatus(recordId)));
 
         //非强制交卷,换算最终交卷时间并生成一次性延时任务
         if (Objects.nonNull(exam.getForceFinish()) && exam.getForceFinish().intValue() == 0) {
             Long date = ExamRecordCacheUtil.getExamFinalFinishTime(recordId);
             if (Objects.isNull(date)) {
                 Long startTime = ExamRecordCacheUtil.getStartTime(recordId);
-                Integer activityMaxDurationSeconds = Objects.nonNull(ac.getMaxDurationSeconds()) ? ac.getMaxDurationSeconds() : null;
-                Integer maxDurationSeconds = Objects.nonNull(exam.getMaxDurationSeconds()) ? exam.getMaxDurationSeconds() : null;
-                Integer finalMaxDurationSeconds = Objects.nonNull(activityMaxDurationSeconds) ? activityMaxDurationSeconds : maxDurationSeconds;
+                Integer activityMaxDurationSeconds = Objects.nonNull(ac.getMaxDurationSeconds()) ?
+                        ac.getMaxDurationSeconds() :
+                        null;
+                Integer maxDurationSeconds = Objects.nonNull(exam.getMaxDurationSeconds()) ?
+                        exam.getMaxDurationSeconds() :
+                        null;
+                Integer finalMaxDurationSeconds = Objects.nonNull(activityMaxDurationSeconds) ?
+                        activityMaxDurationSeconds :
+                        maxDurationSeconds;
                 Calendar calendar = Calendar.getInstance();
                 if (Objects.nonNull(finalMaxDurationSeconds)) {
                     calendar.setTimeInMillis(startTime);
                     calendar.add(Calendar.SECOND, finalMaxDurationSeconds.intValue());
                 }
                 Integer breakResumeCount = exam.getBreakResumeCount();
-                Integer breakExpireSeconds = Objects.isNull(exam.getBreakExpireSeconds()) ? 0 : exam.getBreakExpireSeconds();
-                Long finalFinishTime = (calendar.getTime().getTime() / 1000 + (breakResumeCount * breakExpireSeconds) + (breakResumeCount * 180)) * 1000;
+                Integer breakExpireSeconds = Objects.isNull(exam.getBreakExpireSeconds()) ?
+                        0 :
+                        exam.getBreakExpireSeconds();
+                Long finalFinishTime =
+                        (calendar.getTime().getTime() / 1000 + (breakResumeCount * breakExpireSeconds) + (
+                                breakResumeCount * 180)) * 1000;
                 ExamRecordCacheUtil.setExamFinalFinishTime(recordId, finalFinishTime);
                 //新增quartz任务,发送mq消息start
                 Map<String, Object> prop = new HashMap<>();
                 prop.put("oper", "insert");
                 prop.put("exam", exam);
-                MqDto mqDto = new MqDto(MqTopicEnum.THEMIS_TOPIC.getCode(), MqTagEnum.EXAM_STUDENT.name(), JacksonUtil.parseJson(examStudentCacheBean), MqTagEnum.EXAM_STUDENT, String.valueOf(recordId), prop, es.getName());
+                MqDto mqDto = new MqDto(MqTopicEnum.THEMIS_TOPIC.getCode(), MqTagEnum.EXAM_STUDENT.name(),
+                        JacksonUtil.parseJson(examStudentCacheBean), MqTagEnum.EXAM_STUDENT, String.valueOf(recordId),
+                        prop, es.getName());
                 mqDtoService.assembleSendOneWayMsg(mqDto);
                 //新增quartz任务,发送mq消息end
             }
@@ -563,9 +607,8 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
      * 提交作答结果
      */
     @Override
-    public AnswerSubmitBean answerSubmit(Long studentId, Long recordId, Integer mainNumber, Integer
-            subNumber, Integer subIndex,
-                                         String answer, Long version, Integer durationSeconds) {
+    public AnswerSubmitBean answerSubmit(Long studentId, Long recordId, Integer mainNumber, Integer subNumber,
+            Integer subIndex, String answer, Long version, Integer durationSeconds) {
 
         // 校验当前登录用户和参数一致性
         if (ExamRecordCacheUtil.getId(recordId) == null) {
@@ -584,9 +627,9 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
         if (ExamRecordStatusEnum.FINISHED.equals(sta) || ExamRecordStatusEnum.PERSISTED.equals(sta)) {
             throw new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_STUDENT);
         }
-        ExamStudentAnswerCacheBean answerCache = (ExamStudentAnswerCacheBean) redisUtil.get(
-                RedisKeyHelper.examAnswerKey(recordId),
-                RedisKeyHelper.examAnswerHashKey(mainNumber, subNumber, subIndex));
+        ExamStudentAnswerCacheBean answerCache = (ExamStudentAnswerCacheBean) redisUtil
+                .get(RedisKeyHelper.examAnswerKey(recordId),
+                        RedisKeyHelper.examAnswerHashKey(mainNumber, subNumber, subIndex));
         if (answerCache == null || Objects.isNull(answerCache.getVersion())) {
             answerCache = new ExamStudentAnswerCacheBean();
             answerCache.setMainNumber(mainNumber);
@@ -595,7 +638,8 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
             answerCache.setAnswer(answer);
             answerCache.setVersion(version);
             answerCache.setDurationSeconds(durationSeconds);
-            answerCache.setObjective(checkIsObjective(ExamRecordCacheUtil.getPaperId(recordId), mainNumber, subNumber, subIndex));
+            answerCache.setObjective(
+                    checkIsObjective(ExamRecordCacheUtil.getPaperId(recordId), mainNumber, subNumber, subIndex));
 
         } else {
             if (version.longValue() > answerCache.getVersion().longValue()) {
@@ -604,7 +648,9 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
                 answerCache.setDurationSeconds(durationSeconds);
             }
         }
-        Integer hasAnswerFile = Objects.nonNull(ExamRecordCacheUtil.getHasAnswerFile(recordId)) ? ExamRecordCacheUtil.getHasAnswerFile(recordId) : 0;
+        Integer hasAnswerFile = Objects.nonNull(ExamRecordCacheUtil.getHasAnswerFile(recordId)) ?
+                ExamRecordCacheUtil.getHasAnswerFile(recordId) :
+                0;
         if (hasAnswerFile.intValue() == 1) {
             // 每次提交,清空得分
             answerCache.setScore(null);
@@ -648,8 +694,8 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
         transMap.put("subNumber", subNumber);
         transMap.put("subIndex", subIndex);
         // mq发送消息start
-        MqDto mqDto = new MqDto(MqTopicEnum.THEMIS_TOPIC.getCode(), MqTagEnum.CALCULATE_OBJECTIVE_SCORE.name(), transMap,
-                MqTagEnum.CALCULATE_OBJECTIVE_SCORE, recordId.toString(), recordId.toString());
+        MqDto mqDto = new MqDto(MqTopicEnum.THEMIS_TOPIC.getCode(), MqTagEnum.CALCULATE_OBJECTIVE_SCORE.name(),
+                transMap, MqTagEnum.CALCULATE_OBJECTIVE_SCORE, recordId.toString(), recordId.toString());
         mqDtoService.assembleSendOneWayMsg(mqDto);
     }
 
@@ -657,8 +703,8 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
      * 更新音频剩余播放次数
      */
     @Override
-    public AudioLeftPlayCountSubmitBean audioLeftPlayCountSubmit(Long studentId, Long recordId, String key, Integer
-            count) {
+    public AudioLeftPlayCountSubmitBean audioLeftPlayCountSubmit(Long studentId, Long recordId, String key,
+            Integer count) {
 
         // 校验当前登录用户和参数一致性
         if (ExamRecordCacheUtil.getId(recordId) == null) {
@@ -688,8 +734,7 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
      * 文件上传
      */
     @Override
-    public ExamFileUploadBean fileUpload(Long studentId, Long recordId, MultipartFile file, String suffix, String
-            md5) {
+    public ExamFileUploadBean fileUpload(Long studentId, Long recordId, MultipartFile file, String suffix, String md5) {
         // 校验当前登录用户和参数一致性
         if (ExamRecordCacheUtil.getId(recordId) == null) {
             throw new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_RECORD);
@@ -716,7 +761,7 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
                 throw new BusinessException("文件md5不一致");
             }
             in = file.getInputStream();
-            OssUtil.ossUploadStream(ossUtil.getAliYunOssPrivateDomain().getMap(), filePath, in);
+            ossUtil.upload(false, filePath, in);
             String url = ossUtil.getAliYunOssPrivateDomain().getPrivateUrl() + File.separator + filePath;
             ExamFileUploadBean ret = new ExamFileUploadBean();
             ret.setUrl(url);
@@ -784,8 +829,8 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
         }
         ret = new ExamResumeBean();
         ret.setDurationSeconds(ExamRecordCacheUtil.getDurationSeconds(recordId));
-        ret.setPaperUrl(OssUtil.getUrlForPrivateBucket(ossUtil.getAliYunOssPrivateDomain().getMap(), ep.getPaperPath()));
-        ret.setStructUrl(OssUtil.getUrlForPrivateBucket(ossUtil.getAliYunOssPrivateDomain().getMap(), ep.getStructPath()));
+        ret.setPaperUrl(ossUtil.getPrivateUrl(ep.getPaperPath()));
+        ret.setStructUrl(ossUtil.getPrivateUrl(ep.getStructPath()));
         ret.setHasAudio((ep.getHasAudio() != null && ep.getHasAudio().intValue() == 1 ? true : false));
         ret.setAudioPlayCount(ep.getAudioPlayCount());
         ret.setMonitorAppId(tencentYunUtil.getTencentYunDomain().getAppId());
@@ -812,11 +857,14 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
         Long lastPrepareTime = System.currentTimeMillis();
         ExamRecordCacheUtil.setLastPrepareTime(recordId, lastPrepareTime, false);
         ExamRecordCacheUtil.setStatus(recordId, ExamRecordStatusEnum.RESUME_PREPARE, false);
-        String[] columns = new String[]{ExamRecordFieldEnum.last_prepare_time.name(), ExamRecordFieldEnum.status.name()};
-        Object[] values = new Object[]{lastPrepareTime, ExamRecordStatusEnum.RESUME_PREPARE};
+        String[] columns = new String[] { ExamRecordFieldEnum.last_prepare_time.name(),
+                ExamRecordFieldEnum.status.name() };
+        Object[] values = new Object[] { lastPrepareTime, ExamRecordStatusEnum.RESUME_PREPARE };
         toeExamRecordService.dataUpdatesMq(recordId, columns, values);
         //更新场次-考试记录缓存
-        ExamActivityRecordCacheUtil.setExamRecordStatus(es.getExamActivityId(), recordId, new ExamActivityRecordCacheBean(ExamRecordCacheUtil.getExamStudentId(recordId), ExamRecordCacheUtil.getStatus(recordId)));
+        ExamActivityRecordCacheUtil.setExamRecordStatus(es.getExamActivityId(), recordId,
+                new ExamActivityRecordCacheBean(ExamRecordCacheUtil.getExamStudentId(recordId),
+                        ExamRecordCacheUtil.getStatus(recordId)));
         return ret;
     }
 
@@ -910,12 +958,16 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
         }
 
         //页面结果
-        Integer hasAnswerFile = Objects.nonNull(ExamRecordCacheUtil.getHasAnswerFile(recordId)) ? ExamRecordCacheUtil.getHasAnswerFile(recordId) : 0;
+        Integer hasAnswerFile = Objects.nonNull(ExamRecordCacheUtil.getHasAnswerFile(recordId)) ?
+                ExamRecordCacheUtil.getHasAnswerFile(recordId) :
+                0;
         if (hasAnswerFile.intValue() == 1) {
             if (exam.getShowObjectiveScore() != null && exam.getShowObjectiveScore().intValue() == 1) {//实时出分
                 if (InvigilateVerifyEnum.NOW.equals(exam.getInvigilateVerify())) {//实时审核
                     Integer warningCount = ExamRecordCacheUtil.getWarningCount(recordId);
-                    Integer breachStatus = Objects.isNull(ExamRecordCacheUtil.getBreachStatus(recordId)) ? 1 : ExamRecordCacheUtil.getBreachStatus(recordId);
+                    Integer breachStatus = Objects.isNull(ExamRecordCacheUtil.getBreachStatus(recordId)) ?
+                            1 :
+                            ExamRecordCacheUtil.getBreachStatus(recordId);
                     if (warningCount != null && warningCount.intValue() > 0) {//有预警
                         if (breachStatus == null) {//无违纪结果
                             ret.setStatus(FinishExamResultEnum.AUDITING);
@@ -931,9 +983,11 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
                             ret.setStatus(FinishExamResultEnum.BREACH);
                         }
                     } else {
-                        if (Objects.nonNull(exam.getInvigilateVerify()) && exam.getInvigilateVerify().equals(InvigilateVerifyEnum.NOW)) {
+                        if (Objects.nonNull(exam.getInvigilateVerify()) && exam.getInvigilateVerify()
+                                .equals(InvigilateVerifyEnum.NOW)) {
                             ret.setStatus(FinishExamResultEnum.AUDITING);
-                        } else if (Objects.nonNull(exam.getInvigilateVerify()) && exam.getInvigilateVerify().equals(InvigilateVerifyEnum.LATER)) {
+                        } else if (Objects.nonNull(exam.getInvigilateVerify()) && exam.getInvigilateVerify()
+                                .equals(InvigilateVerifyEnum.LATER)) {
                             ret.setStatus(FinishExamResultEnum.SCORE_VIEW);
                         }
                     }
@@ -955,11 +1009,16 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
         ExamRecordCacheUtil.setDurationSeconds(recordId, durationSeconds, false);
         ExamRecordCacheUtil.setFinishType(recordId, FinishTypeEnum.valueOf(type), false);
         ExamRecordCacheUtil.setStatus(recordId, ExamRecordStatusEnum.FINISHED, false);
-        String[] columns = new String[]{ExamRecordFieldEnum.finish_time.name(), ExamRecordFieldEnum.duration_seconds.name(), ExamRecordFieldEnum.finish_type.name(), ExamRecordFieldEnum.status.name()};
-        Object[] values = new Object[]{finishTime, durationSeconds, FinishTypeEnum.valueOf(type), ExamRecordStatusEnum.FINISHED};
+        String[] columns = new String[] { ExamRecordFieldEnum.finish_time.name(),
+                ExamRecordFieldEnum.duration_seconds.name(), ExamRecordFieldEnum.finish_type.name(),
+                ExamRecordFieldEnum.status.name() };
+        Object[] values = new Object[] { finishTime, durationSeconds, FinishTypeEnum.valueOf(type),
+                ExamRecordStatusEnum.FINISHED };
         toeExamRecordService.dataUpdatesMq(recordId, columns, values);
         //更新场次-考试记录缓存
-        ExamActivityRecordCacheUtil.setExamRecordStatus(es.getExamActivityId(), recordId, new ExamActivityRecordCacheBean(ExamRecordCacheUtil.getExamStudentId(recordId), ExamRecordCacheUtil.getStatus(recordId)));
+        ExamActivityRecordCacheUtil.setExamRecordStatus(es.getExamActivityId(), recordId,
+                new ExamActivityRecordCacheBean(ExamRecordCacheUtil.getExamStudentId(recordId),
+                        ExamRecordCacheUtil.getStatus(recordId)));
         //更新未完成考试记录id
         TEStudentCacheDto teStudentCacheDto = (TEStudentCacheDto) redisUtil.getStudent(es.getStudentId());
         ExamingDataCacheUtil.deleteUnFinishedRecordId(studentId);
@@ -967,7 +1026,9 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
         //异步持久化
         checkToPersisted(recordId);
         //mq发送消息start
-        MqDto mqDto = new MqDto(MqTopicEnum.THEMIS_TOPIC.getCode(), MqTagEnum.STUDENT.name(), SystemOperationEnum.FINISHED, MqTagEnum.STUDENT, String.valueOf(teStudentCacheDto.getId()), teStudentCacheDto.getIdentity());
+        MqDto mqDto = new MqDto(MqTopicEnum.THEMIS_TOPIC.getCode(), MqTagEnum.STUDENT.name(),
+                SystemOperationEnum.FINISHED, MqTagEnum.STUDENT, String.valueOf(teStudentCacheDto.getId()),
+                teStudentCacheDto.getIdentity());
         this.sendOeLogMessage(SystemOperationEnum.FINISHED, examStudentId, recordId, mqDto);
         //mq发送消息end
         return ret;
@@ -993,8 +1054,8 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
         Map<String, Object> propMap = new HashMap<String, Object>();
         propMap.put("timeOut", time);
         propMap.put("mqExecTime", dt.toInstant(ZoneOffset.of("+8")).toEpochMilli());
-        MqDto mqDto = new MqDto(MqTopicEnum.THEMIS_TOPIC.getCode(), MqTagEnum.EXAM_RECORD_PERSISTED.name(),
-                transMap, MqTagEnum.EXAM_RECORD_PERSISTED, recordId.toString(), propMap, recordId.toString());
+        MqDto mqDto = new MqDto(MqTopicEnum.THEMIS_TOPIC.getCode(), MqTagEnum.EXAM_RECORD_PERSISTED.name(), transMap,
+                MqTagEnum.EXAM_RECORD_PERSISTED, recordId.toString(), propMap, recordId.toString());
 
         mqDtoService.assembleSendAsyncDelayMsg(mqDto);
     }
@@ -1062,7 +1123,9 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
             ret.setObjectiveScore(ExamRecordCacheUtil.getObjectiveScore(recordId));
             warningCount = ExamRecordCacheUtil.getWarningCount(recordId);
             breachStatus = ExamRecordCacheUtil.getBreachStatus(recordId);
-            hasAnswerFile = Objects.nonNull(ExamRecordCacheUtil.getHasAnswerFile(recordId)) ? ExamRecordCacheUtil.getHasAnswerFile(recordId) : 0;
+            hasAnswerFile = Objects.nonNull(ExamRecordCacheUtil.getHasAnswerFile(recordId)) ?
+                    ExamRecordCacheUtil.getHasAnswerFile(recordId) :
+                    0;
         }
 
         //页面结果
@@ -1122,8 +1185,8 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
      * @param mqDto
      */
     @Override
-    public void sendOeLogMessage(SystemOperationEnum systemOperationEnum, Long examStudentId, Long recordId, MqDto
-            mqDto) {
+    public void sendOeLogMessage(SystemOperationEnum systemOperationEnum, Long examStudentId, Long recordId,
+            MqDto mqDto) {
         //mq发送消息start
         Map<String, Object> properties = new HashMap<>();
         properties.put("remark", systemOperationEnum.getCode());
@@ -1164,7 +1227,10 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
         String[] strs = null;
         if (Objects.nonNull(ret.getMonitorVideoSource())) {
             strs = ret.getMonitorVideoSource().split(",");
-            if (strs.length == 4 || (ret.getMonitorVideoSource().toUpperCase().contains(MonitorVideoSourceEnum.CLIENT_SCREEN.name()) || ret.getMonitorVideoSource().toUpperCase().contains(MonitorVideoSourceEnum.CLIENT_CAMERA.name()))) {
+            if (strs.length == 4 || (
+                    ret.getMonitorVideoSource().toUpperCase().contains(MonitorVideoSourceEnum.CLIENT_SCREEN.name())
+                            || ret.getMonitorVideoSource().toUpperCase()
+                            .contains(MonitorVideoSourceEnum.CLIENT_CAMERA.name()))) {
                 ret.setMonitorAudioEnable(true);
             }
         }
@@ -1243,7 +1309,7 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
             String reportFilePath = "file/" + sdf.format(new Date()) + "/" + uuid() + SystemConstant.TXT_PREFIX;
             json.put("path", reportFilePath);
             json.put("type", SystemConstant.OSS);
-            OssUtil.ossUploadContent(ossUtil.getAliYunOssPrivateDomain().getMap(), reportFilePath, e.getMessage());
+            ossUtil.upload(false, reportFilePath, e.getMessage());
             task.setReportFilePath(json.toJSONString());
         } finally {
             redisUtil.releaseLock(lockKey);

+ 3 - 3
themis-business/src/main/java/com/qmth/themis/business/service/impl/TEStudentServiceImpl.java

@@ -55,7 +55,8 @@ public class TEStudentServiceImpl extends ServiceImpl<TEStudentMapper, TEStudent
      * @return
      */
     @Override
-    public IPage<TEStudentDto> studentQuery(IPage<Map> iPage, String identity, String name, Integer enable, Long orgId) {
+    public IPage<TEStudentDto> studentQuery(IPage<Map> iPage, String identity, String name, Integer enable,
+            Long orgId) {
         return teStudentMapper.studentQuery(iPage, identity, name, enable, orgId);
     }
 
@@ -72,7 +73,6 @@ public class TEStudentServiceImpl extends ServiceImpl<TEStudentMapper, TEStudent
         return teStudentMapper.studentExamRecordQuery(iPage, studentId, examId);
     }
 
-
     @Transactional
     @Override
     public StudentPhotoUploadResponseBean photoUpload(Long orgId, String identity, MultipartFile file, String md5) {
@@ -98,7 +98,7 @@ public class TEStudentServiceImpl extends ServiceImpl<TEStudentMapper, TEStudent
             TEStudentCacheDto teStudentCacheDto = gson.fromJson(gson.toJson(student), TEStudentCacheDto.class);
             redisUtil.setStudent(student.getId(), teStudentCacheDto);
             in = file.getInputStream();
-            OssUtil.ossUploadStream(ossUtil.getAliYunOssPrivateDomain().getMap(), filePath, in);
+            ossUtil.upload(false, filePath, in);
             String url = ossUtil.getAliYunOssPrivateDomain().getPrivateUrl() + File.separator + filePath;
             StudentPhotoUploadResponseBean ret = new StudentPhotoUploadResponseBean();
             ret.setPhotoUrl(url);

+ 164 - 85
themis-business/src/main/java/com/qmth/themis/business/service/impl/TOeExamRecordServiceImpl.java

@@ -48,7 +48,9 @@ import java.util.*;
  * @Date: 2020/6/25
  */
 @Service
-public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, TOeExamRecord> implements TOeExamRecordService {
+public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, TOeExamRecord>
+        implements TOeExamRecordService {
+
     private final static Logger log = LoggerFactory.getLogger(TOeExamRecordServiceImpl.class);
 
     private SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
@@ -133,7 +135,7 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
     @Transactional
     @Override
     public Long saveByPrepare(Long examId, Long examActivityId, Long examStudentId, Long paperId,
-                              Integer serialNumber) {
+            Integer serialNumber) {
         ExamActivityCacheBean ac = examActivityService.getExamActivityCacheBean(examActivityId);
         ExamCacheBean exam = examService.getExamCacheBean(examId);
         TOeExamRecord er = new TOeExamRecord();
@@ -179,8 +181,8 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
         String key = RedisKeyHelper.examAnswerHashKey(mainNumber, subNumber, subIndex);
 
         //考生作答缓存
-        ExamStudentAnswerCacheBean answer = (ExamStudentAnswerCacheBean) redisUtil.get(
-                RedisKeyHelper.examAnswerKey(recordId), key);
+        ExamStudentAnswerCacheBean answer = (ExamStudentAnswerCacheBean) redisUtil
+                .get(RedisKeyHelper.examAnswerKey(recordId), key);
         if (answer == null) {
             log.error("no ExamStudentAnswerCacheBean for calculateObjectiveScore recordId:" + recordId + " key:" + key);
 
@@ -191,7 +193,8 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
         //整卷客观题标答缓存集合
         Map<String, ObjectiveAnswerCacheBean> map = examPaperService.getObjectiveAnswerCacheBean(paperId);
         if (map == null || map.size() == 0) {
-            log.info("no ObjectiveAnswerCacheBean map for calculateObjectiveScore recordId:" + recordId + " paperId:" + paperId);
+            log.info("no ObjectiveAnswerCacheBean map for calculateObjectiveScore recordId:" + recordId + " paperId:"
+                    + paperId);
             // 更新分数
             answer.setScore(0.0);
             redisUtil.set(RedisKeyHelper.examAnswerKey(recordId), key, answer);
@@ -213,7 +216,6 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
             return;
         }
 
-
         if (cb.getStructType().intValue() == 1) {
             if (checkSingleChoice(answer.getAnswer(), cb.getChoiceAnswer())) {
                 answer.setScore(cb.getScore());
@@ -277,8 +279,9 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
             String key = RedisKeyHelper.examAnswerHashKey(mainNumber, subNumber, subIndex);
             Boolean lock = redisUtil.lock(lockKey, SystemConstant.REDIS_CACHE_TIME_OUT);
             if (lock) {
-                log.info("calculateTotalObjectiveScore get lock sucss recordId:"+recordId+" key:"+key);
-                Map<String, ExamStudentAnswerCacheBean> as = redisUtil.getHashEntries(RedisKeyHelper.examAnswerKey(recordId));
+                log.info("calculateTotalObjectiveScore get lock sucss recordId:" + recordId + " key:" + key);
+                Map<String, ExamStudentAnswerCacheBean> as = redisUtil
+                        .getHashEntries(RedisKeyHelper.examAnswerKey(recordId));
                 if (as != null && as.size() > 0) {
                     Double total = 0.0;
                     for (ExamStudentAnswerCacheBean sa : as.values()) {
@@ -286,7 +289,11 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
                             if (sa.getScore() != null) {//有分值
                                 total = total + sa.getScore();
                             } else {
-                                log.info("calculateTotalObjectiveScore ExamStudentAnswerCacheBean Score is null recordId:"+recordId+" key:"+RedisKeyHelper.examAnswerHashKey(sa.getMainNumber(), sa.getSubNumber(), sa.getSubIndex()));
+                                log.info(
+                                        "calculateTotalObjectiveScore ExamStudentAnswerCacheBean Score is null recordId:"
+                                                + recordId + " key:" + RedisKeyHelper
+                                                .examAnswerHashKey(sa.getMainNumber(), sa.getSubNumber(),
+                                                        sa.getSubIndex()));
                                 total = null;
                                 break;
                             }
@@ -294,12 +301,13 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
                     }
                     if (total != null) {
                         ExamRecordCacheUtil.setObjectiveScore(recordId, total, true);
-                    }else {
-                        log.info("calculateTotalObjectiveScore total Score is null recordId:"+recordId+" key:"+key);
+                    } else {
+                        log.info("calculateTotalObjectiveScore total Score is null recordId:" + recordId + " key:"
+                                + key);
                     }
                 }
-            }else {
-                log.info("calculateTotalObjectiveScore get lock faild recordId:"+recordId+" key:"+key);
+            } else {
+                log.info("calculateTotalObjectiveScore get lock faild recordId:" + recordId + " key:" + key);
                 calculateObjectiveScoreMsg(recordId, mainNumber, subNumber, subIndex);
             }
         } finally {
@@ -385,7 +393,8 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
         try {
             dfile.mkdirs();
             String structFilePath = sdf.format(new Date()) + "/" + uuid() + ".json";
-            ExamStudentPaperStructCacheBean struct = (ExamStudentPaperStructCacheBean) redisUtil.get(RedisKeyHelper.studentPaperStructKey(recordId));
+            ExamStudentPaperStructCacheBean struct = (ExamStudentPaperStructCacheBean) redisUtil
+                    .get(RedisKeyHelper.studentPaperStructKey(recordId));
 
             //保存考试记录
             Map<String, Object> record = redisUtil.getHashEntries(RedisKeyHelper.examRecordCacheKey(recordId));
@@ -397,7 +406,8 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
             er.setPaperStructUpload(1);
             saveOrUpdate(er);
             //保存作答
-            Map<String, ExamStudentAnswerCacheBean> answerMap = redisUtil.getHashEntries(RedisKeyHelper.examAnswerKey(recordId));
+            Map<String, ExamStudentAnswerCacheBean> answerMap = redisUtil
+                    .getHashEntries(RedisKeyHelper.examAnswerKey(recordId));
             for (ExamStudentAnswerCacheBean answerCache : answerMap.values()) {
                 TOeExamAnswer answer = new TOeExamAnswer();
                 BeanUtils.copyProperties(answerCache, answer);
@@ -405,16 +415,16 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
                 answer.setExamRecordId(recordId);
                 examAnswerService.saveOrUpdate(answer);
             }
-//            //更新考生信息
-//            ExamStudentCacheBean examStudentCache = examStudentService.getExamStudentCacheBean(er.getExamStudentId());
-//            TEExamStudent examStudent = new TEExamStudent();
-//            BeanUtils.copyProperties(examStudentCache, examStudent);
-//            examStudentService.saveOrUpdate(examStudent);
+            //            //更新考生信息
+            //            ExamStudentCacheBean examStudentCache = examStudentService.getExamStudentCacheBean(er.getExamStudentId());
+            //            TEExamStudent examStudent = new TEExamStudent();
+            //            BeanUtils.copyProperties(examStudentCache, examStudent);
+            //            examStudentService.saveOrUpdate(examStudent);
             //上传个人试卷结构
             if (struct != null) {
                 File structFile = new File(dir + "struct.json");
                 FileUtil.saveAsFile(structFile.getAbsolutePath(), struct.getContent());
-                OssUtil.ossUpload(ossUtil.getAliYunOssPrivateDomain().getMap(), structFilePath, structFile);
+                ossUtil.upload(false, structFilePath, structFile);
             }
         } finally {
             FileUtil.deleteFolder(dir);
@@ -425,14 +435,15 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
         return UUID.randomUUID().toString().replaceAll("-", "");
     }
 
-
     @Override
-    public void saveFaceVerify(ExamTypeEnum type, Long recordId, Long entryAuthenticationId, VerifyExceptionEnum entryAuthenticationResult) {
+    public void saveFaceVerify(ExamTypeEnum type, Long recordId, Long entryAuthenticationId,
+            VerifyExceptionEnum entryAuthenticationResult) {
         if (ExamTypeEnum.FIRST_START.equals(type)) {
             ExamRecordCacheUtil.setEntryAuthenticationId(recordId, entryAuthenticationId, false);
             ExamRecordCacheUtil.setEntryAuthenticationResult(recordId, entryAuthenticationResult, false);
-            String[] columns = new String[]{ExamRecordFieldEnum.entry_authentication_id.name(), ExamRecordFieldEnum.entry_authentication_result.name()};
-            Object[] values = new Object[]{entryAuthenticationId, entryAuthenticationResult};
+            String[] columns = new String[] { ExamRecordFieldEnum.entry_authentication_id.name(),
+                    ExamRecordFieldEnum.entry_authentication_result.name() };
+            Object[] values = new Object[] { entryAuthenticationId, entryAuthenticationResult };
             this.dataUpdatesMq(recordId, columns, values);
         } else if (ExamTypeEnum.IN_PROCESS.equals(type)) {
 
@@ -440,12 +451,14 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
     }
 
     @Override
-    public void saveLivenessVerify(LivenessTypeEnum type, Long recordId, Long entryAuthenticationId, VerifyExceptionEnum entryAuthenticationResult) {
+    public void saveLivenessVerify(LivenessTypeEnum type, Long recordId, Long entryAuthenticationId,
+            VerifyExceptionEnum entryAuthenticationResult) {
         if (LivenessTypeEnum.FIRST_START.equals(type)) {
             ExamRecordCacheUtil.setEntryAuthenticationId(recordId, entryAuthenticationId, false);
             ExamRecordCacheUtil.setEntryAuthenticationResult(recordId, entryAuthenticationResult, false);
-            String[] columns = new String[]{ExamRecordFieldEnum.entry_authentication_id.name(), ExamRecordFieldEnum.entry_authentication_result.name()};
-            Object[] values = new Object[]{entryAuthenticationId, entryAuthenticationResult};
+            String[] columns = new String[] { ExamRecordFieldEnum.entry_authentication_id.name(),
+                    ExamRecordFieldEnum.entry_authentication_result.name() };
+            Object[] values = new Object[] { entryAuthenticationId, entryAuthenticationResult };
             this.dataUpdatesMq(recordId, columns, values);
         } else if (LivenessTypeEnum.IN_PROCESS.equals(type)) {
             Integer count = ExamRecordCacheUtil.getInProcessLivenessVerifyCount(recordId);
@@ -460,7 +473,8 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
         transMap.put("colName", colName);
         transMap.put("colValue", colValue);
         //mq发送消息start
-        MqDto mqDto = new MqDto(MqTopicEnum.THEMIS_TOPIC.getCode(), MqTagEnum.EXAM_RECORD_UPDATE.name(), transMap, MqTagEnum.EXAM_RECORD_UPDATE, recordId.toString(), colName);
+        MqDto mqDto = new MqDto(MqTopicEnum.THEMIS_TOPIC.getCode(), MqTagEnum.EXAM_RECORD_UPDATE.name(), transMap,
+                MqTagEnum.EXAM_RECORD_UPDATE, recordId.toString(), colName);
         mqDtoService.assembleSendOneWayMsg(mqDto);
     }
 
@@ -492,7 +506,8 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
         transMap.put("colNames", colNames);
         transMap.put("colValues", colValues);
         //mq发送消息start
-        MqDto mqDto = new MqDto(MqTopicEnum.THEMIS_TOPIC.getCode(), MqTagEnum.EXAM_RECORD_UPDATE_COLUMNS.name(), transMap, MqTagEnum.EXAM_RECORD_UPDATE_COLUMNS, recordId.toString(), recordId.toString());
+        MqDto mqDto = new MqDto(MqTopicEnum.THEMIS_TOPIC.getCode(), MqTagEnum.EXAM_RECORD_UPDATE_COLUMNS.name(),
+                transMap, MqTagEnum.EXAM_RECORD_UPDATE_COLUMNS, recordId.toString(), recordId.toString());
         mqDtoService.assembleSendOneWayMsg(mqDto);
     }
 
@@ -501,7 +516,8 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
     public void dataInitMq(Map<String, Object> param) {
         Long id = (Long) param.get("id");
         //mq发送消息start
-        MqDto mqDto = new MqDto(MqTopicEnum.THEMIS_TOPIC.getCode(), MqTagEnum.EXAM_RECORD_INIT.name(), param, MqTagEnum.EXAM_RECORD_INIT, id.toString(), id.toString());
+        MqDto mqDto = new MqDto(MqTopicEnum.THEMIS_TOPIC.getCode(), MqTagEnum.EXAM_RECORD_INIT.name(), param,
+                MqTagEnum.EXAM_RECORD_INIT, id.toString(), id.toString());
         mqDtoService.assembleSendOneWayMsg(mqDto);
     }
 
@@ -548,19 +564,13 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
      * @return
      */
     @Override
-    public IPage<InvigilateListBean> invigilatePageList(IPage<Map> iPage, Long examId,
-                                                        Long examActivityId,
-                                                        String roomCode,
-                                                        Integer paperDownload,
-                                                        String status,
-                                                        String name,
-                                                        String identity,
-                                                        Integer minWarningCount,
-                                                        Integer maxWarningCount,
-                                                        String clientWebsocketStatus,
-                                                        String monitorStatusSource,
-                                                        Long userId) {
-        return tOeExamRecordMapper.invigilatePageList(iPage, examId, examActivityId, roomCode, paperDownload, status, name, identity, minWarningCount, maxWarningCount, clientWebsocketStatus, monitorStatusSource, userId);
+    public IPage<InvigilateListBean> invigilatePageList(IPage<Map> iPage, Long examId, Long examActivityId,
+            String roomCode, Integer paperDownload, String status, String name, String identity,
+            Integer minWarningCount, Integer maxWarningCount, String clientWebsocketStatus, String monitorStatusSource,
+            Long userId) {
+        return tOeExamRecordMapper
+                .invigilatePageList(iPage, examId, examActivityId, roomCode, paperDownload, status, name, identity,
+                        minWarningCount, maxWarningCount, clientWebsocketStatus, monitorStatusSource, userId);
     }
 
     /**
@@ -582,8 +592,12 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
      * @return
      */
     @Override
-    public IPage<InvigilateListVideoBean> invigilatePageListVideo(IPage<Map> iPage, Long examId, Long examActivityId, String roomCode, Integer paperDownload, String status, String name, String identity, Integer minWarningCount, Integer maxWarningCount, String clientWebsocketStatus, Long userId, Long orgId) {
-        return tOeExamRecordMapper.invigilatePageListVideo(iPage, examId, examActivityId, roomCode, paperDownload, status, name, identity, minWarningCount, maxWarningCount, clientWebsocketStatus, userId, orgId);
+    public IPage<InvigilateListVideoBean> invigilatePageListVideo(IPage<Map> iPage, Long examId, Long examActivityId,
+            String roomCode, Integer paperDownload, String status, String name, String identity,
+            Integer minWarningCount, Integer maxWarningCount, String clientWebsocketStatus, Long userId, Long orgId) {
+        return tOeExamRecordMapper
+                .invigilatePageListVideo(iPage, examId, examActivityId, roomCode, paperDownload, status, name, identity,
+                        minWarningCount, maxWarningCount, clientWebsocketStatus, userId, orgId);
     }
 
     /**
@@ -596,7 +610,8 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
      * @return
      */
     @Override
-    public List<InvigilateListVideoBean> invigilatePageListVideoRandom(Long examId, Long userId, Integer randomNum, Long orgId) {
+    public List<InvigilateListVideoBean> invigilatePageListVideoRandom(Long examId, Long userId, Integer randomNum,
+            Long orgId) {
         return tOeExamRecordMapper.invigilatePageListVideoRandom(examId, userId, randomNum, orgId);
     }
 
@@ -622,8 +637,14 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
      * @return
      */
     @Override
-    public IPage<InvigilateListPatrolBean> invigilatePagePatrolList(IPage<Map> iPage, Long examId, Long examActivityId, String roomCode, String status, String name, String identity, Integer minMultipleFaceCount, Integer maxMultipleFaceCount, Integer minExceptionCount, Integer maxExceptionCount, Integer minWarningCount, Integer maxWarningCount, String clientWebsocketStatus, Long userId, Long orgId) {
-        return tOeExamRecordMapper.invigilatePagePatrolList(iPage, examId, examActivityId, roomCode, status, name, identity, minMultipleFaceCount, maxMultipleFaceCount, minExceptionCount, maxExceptionCount, minWarningCount, maxWarningCount, clientWebsocketStatus, userId, orgId);
+    public IPage<InvigilateListPatrolBean> invigilatePagePatrolList(IPage<Map> iPage, Long examId, Long examActivityId,
+            String roomCode, String status, String name, String identity, Integer minMultipleFaceCount,
+            Integer maxMultipleFaceCount, Integer minExceptionCount, Integer maxExceptionCount, Integer minWarningCount,
+            Integer maxWarningCount, String clientWebsocketStatus, Long userId, Long orgId) {
+        return tOeExamRecordMapper
+                .invigilatePagePatrolList(iPage, examId, examActivityId, roomCode, status, name, identity,
+                        minMultipleFaceCount, maxMultipleFaceCount, minExceptionCount, maxExceptionCount,
+                        minWarningCount, maxWarningCount, clientWebsocketStatus, userId, orgId);
     }
 
     /**
@@ -647,8 +668,14 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
      * @return
      */
     @Override
-    public IPage<InvigilateListWarningBean> invigilatePageWarningList(IPage<Map> iPage, Long examId, Long examActivityId, String roomCode, Integer approveStatus, String name, String identity, Integer minMultipleFaceCount, Integer maxMultipleFaceCount, Integer minExceptionCount, Integer maxExceptionCount, Integer minWarningCount, Integer maxWarningCount, Long userId, Long orgId) {
-        return tOeExamRecordMapper.invigilatePageWarningList(iPage, examId, examActivityId, roomCode, approveStatus, name, identity, minMultipleFaceCount, maxMultipleFaceCount, minExceptionCount, maxExceptionCount, minWarningCount, maxWarningCount, userId, orgId);
+    public IPage<InvigilateListWarningBean> invigilatePageWarningList(IPage<Map> iPage, Long examId,
+            Long examActivityId, String roomCode, Integer approveStatus, String name, String identity,
+            Integer minMultipleFaceCount, Integer maxMultipleFaceCount, Integer minExceptionCount,
+            Integer maxExceptionCount, Integer minWarningCount, Integer maxWarningCount, Long userId, Long orgId) {
+        return tOeExamRecordMapper
+                .invigilatePageWarningList(iPage, examId, examActivityId, roomCode, approveStatus, name, identity,
+                        minMultipleFaceCount, maxMultipleFaceCount, minExceptionCount, maxExceptionCount,
+                        minWarningCount, maxWarningCount, userId, orgId);
     }
 
     /**
@@ -671,8 +698,14 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
      * @return
      */
     @Override
-    public Integer approveStatusListUpdate(Long examId, Long examActivityId, String roomCode, Integer approveStatus, String name, String identity, Integer minMultipleFaceCount, Integer maxMultipleFaceCount, Integer minExceptionCount, Integer maxExceptionCount, Integer minWarningCount, Integer maxWarningCount, Long userId, Long orgId) {
-        return tOeExamRecordMapper.approveStatusListUpdate(examId, examActivityId, roomCode, approveStatus, name, identity, minMultipleFaceCount, maxMultipleFaceCount, minExceptionCount, maxExceptionCount, minWarningCount, maxWarningCount, userId, orgId);
+    public Integer approveStatusListUpdate(Long examId, Long examActivityId, String roomCode, Integer approveStatus,
+            String name, String identity, Integer minMultipleFaceCount, Integer maxMultipleFaceCount,
+            Integer minExceptionCount, Integer maxExceptionCount, Integer minWarningCount, Integer maxWarningCount,
+            Long userId, Long orgId) {
+        return tOeExamRecordMapper
+                .approveStatusListUpdate(examId, examActivityId, roomCode, approveStatus, name, identity,
+                        minMultipleFaceCount, maxMultipleFaceCount, minExceptionCount, maxExceptionCount,
+                        minWarningCount, maxWarningCount, userId, orgId);
     }
 
     /**
@@ -689,8 +722,12 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
      * @return
      */
     @Override
-    public IPage<InvigilateListProgressBean> invigilatePageProgressList(IPage<Map> iPage, Long examId, Long examActivityId, String roomCode, String courseCode, String name, String identity, Long userId, Long orgId) {
-        return tOeExamRecordMapper.invigilatePageProgressList(iPage, examId, examActivityId, roomCode, courseCode, name, identity, userId, orgId);
+    public IPage<InvigilateListProgressBean> invigilatePageProgressList(IPage<Map> iPage, Long examId,
+            Long examActivityId, String roomCode, String courseCode, String name, String identity, Long userId,
+            Long orgId) {
+        return tOeExamRecordMapper
+                .invigilatePageProgressList(iPage, examId, examActivityId, roomCode, courseCode, name, identity, userId,
+                        orgId);
     }
 
     /**
@@ -707,8 +744,11 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
      * @return
      */
     @Override
-    public List<InvigilateListProgressExcelBean> invigilatePageProgressListExport(Long examId, Long examActivityId, String roomCode, String courseCode, String name, String identity, Long userId, Long orgId) {
-        return tOeExamRecordMapper.invigilatePageProgressListExport(examId, examActivityId, roomCode, courseCode, name, identity, userId, orgId);
+    public List<InvigilateListProgressExcelBean> invigilatePageProgressListExport(Long examId, Long examActivityId,
+            String roomCode, String courseCode, String name, String identity, Long userId, Long orgId) {
+        return tOeExamRecordMapper
+                .invigilatePageProgressListExport(examId, examActivityId, roomCode, courseCode, name, identity, userId,
+                        orgId);
     }
 
     /**
@@ -735,8 +775,15 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
      * @return
      */
     @Override
-    public IPage<InvigilateListHistoryBean> invigilatePageListHistory(IPage<Map> iPage, Long examId, Long examActivityId, String roomCode, String courseCode, String status, Integer breachStatus, String finishType, String name, String identity, Integer minMultipleFaceCount, Integer maxMultipleFaceCount, Integer minExceptionCount, Integer maxExceptionCount, Integer minWarningCount, Integer maxWarningCount, Long userId, Long orgId) {
-        return tOeExamRecordMapper.invigilatePageListHistory(iPage, examId, examActivityId, roomCode, courseCode, status, breachStatus, finishType, name, identity, minMultipleFaceCount, maxMultipleFaceCount, minExceptionCount, maxExceptionCount, minWarningCount, maxWarningCount, userId, orgId);
+    public IPage<InvigilateListHistoryBean> invigilatePageListHistory(IPage<Map> iPage, Long examId,
+            Long examActivityId, String roomCode, String courseCode, String status, Integer breachStatus,
+            String finishType, String name, String identity, Integer minMultipleFaceCount, Integer maxMultipleFaceCount,
+            Integer minExceptionCount, Integer maxExceptionCount, Integer minWarningCount, Integer maxWarningCount,
+            Long userId, Long orgId) {
+        return tOeExamRecordMapper
+                .invigilatePageListHistory(iPage, examId, examActivityId, roomCode, courseCode, status, breachStatus,
+                        finishType, name, identity, minMultipleFaceCount, maxMultipleFaceCount, minExceptionCount,
+                        maxExceptionCount, minWarningCount, maxWarningCount, userId, orgId);
     }
 
     /**
@@ -893,12 +940,15 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
      * @return
      */
     @Override
-    public TOeExamRecord findMarkResult(MarkResultDto markResultDto, RecordSelectStrategyEnum recordSelectStrategyEnum) {
+    public TOeExamRecord findMarkResult(MarkResultDto markResultDto,
+            RecordSelectStrategyEnum recordSelectStrategyEnum) {
         TOeExamRecord tOeExamRecord = null;
         Double sumScore = null;
         //客观分最高
-        if (Objects.nonNull(recordSelectStrategyEnum) && Objects.equals(recordSelectStrategyEnum, RecordSelectStrategyEnum.HIGHEST_OBJECTIVE_SCORE)) {
-            List<TOeExamRecord> tOeExamRecordList = this.findMaxObjectiveScore(markResultDto.getExamId(), markResultDto.getExamStudentId());
+        if (Objects.nonNull(recordSelectStrategyEnum) && Objects
+                .equals(recordSelectStrategyEnum, RecordSelectStrategyEnum.HIGHEST_OBJECTIVE_SCORE)) {
+            List<TOeExamRecord> tOeExamRecordList = this
+                    .findMaxObjectiveScore(markResultDto.getExamId(), markResultDto.getExamStudentId());
             if (Objects.nonNull(tOeExamRecordList) && tOeExamRecordList.size() > 0) {
                 Long paperId = tOeExamRecordList.get(0).getPaperId();
                 ExamPaperCacheBean paperCacheBean = examPaperService.getExamPaperCacheBean(paperId);
@@ -912,9 +962,11 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
                         if (Objects.isNull(tOeExamRecord)) {
                             tOeExamRecord = t;
                         } else {
-                            if (Objects.nonNull(t.getObjectiveScore()) && Objects.nonNull(tOeExamRecord.getObjectiveScore())
-                                    && t.getObjectiveScore().doubleValue() >= tOeExamRecord.getObjectiveScore().doubleValue()
-                                    && Objects.nonNull(t.getFinishTime()) && Objects.nonNull(tOeExamRecord.getFinishTime())
+                            if (Objects.nonNull(t.getObjectiveScore()) && Objects
+                                    .nonNull(tOeExamRecord.getObjectiveScore())
+                                    && t.getObjectiveScore().doubleValue() >= tOeExamRecord.getObjectiveScore()
+                                    .doubleValue() && Objects.nonNull(t.getFinishTime()) && Objects
+                                    .nonNull(tOeExamRecord.getFinishTime())
                                     && t.getFinishTime().longValue() > tOeExamRecord.getFinishTime().longValue()) {
                                 tOeExamRecord = t;
                             }
@@ -927,8 +979,10 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
             }
         }
         //最后一次提交
-        else if (Objects.nonNull(recordSelectStrategyEnum) && Objects.equals(recordSelectStrategyEnum, RecordSelectStrategyEnum.LATEST)) {
-            List<TOeExamRecord> tOeExamRecordList = this.findMaxObjectiveScore(markResultDto.getExamId(), markResultDto.getExamStudentId());
+        else if (Objects.nonNull(recordSelectStrategyEnum) && Objects
+                .equals(recordSelectStrategyEnum, RecordSelectStrategyEnum.LATEST)) {
+            List<TOeExamRecord> tOeExamRecordList = this
+                    .findMaxObjectiveScore(markResultDto.getExamId(), markResultDto.getExamStudentId());
             for (TOeExamRecord t : tOeExamRecordList) {
                 if (Objects.isNull(tOeExamRecord)) {
                     tOeExamRecord = t;
@@ -941,7 +995,8 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
             }
         }
         //全部阅卷后取最高分
-        else if (Objects.nonNull(recordSelectStrategyEnum) && Objects.equals(recordSelectStrategyEnum, RecordSelectStrategyEnum.HIGHEST_TOTAL_SCORE)) {
+        else if (Objects.nonNull(recordSelectStrategyEnum) && Objects
+                .equals(recordSelectStrategyEnum, RecordSelectStrategyEnum.HIGHEST_TOTAL_SCORE)) {
             tOeExamRecord = getMaxSumScore(tOeExamRecord, sumScore, markResultDto);
         }
         return tOeExamRecord;
@@ -955,9 +1010,12 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
     @Override
     @Transactional
     public void setExamBreak(Long recordId) {
-        if (redisUtil.lock(SystemConstant.REDIS_LOCK_EXAM_BREAK_PREFIX + recordId, SystemConstant.REDIS_LOCK_EXAM_BREAK_TIME_OUT)) {
+        if (redisUtil.lock(SystemConstant.REDIS_LOCK_EXAM_BREAK_PREFIX + recordId,
+                SystemConstant.REDIS_LOCK_EXAM_BREAK_TIME_OUT)) {
             try {
-                Integer alreadyBreakCount = Objects.isNull(ExamRecordCacheUtil.getAlreadyBreakCount(recordId)) ? 0 : ExamRecordCacheUtil.getAlreadyBreakCount(recordId);
+                Integer alreadyBreakCount = Objects.isNull(ExamRecordCacheUtil.getAlreadyBreakCount(recordId)) ?
+                        0 :
+                        ExamRecordCacheUtil.getAlreadyBreakCount(recordId);
                 alreadyBreakCount++;
                 Long examActivityId = ExamRecordCacheUtil.getExamActivityId(recordId);
                 Long breakId = Constants.idGen.next();
@@ -968,19 +1026,26 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
                 ExamRecordCacheUtil.setAlreadyBreakCount(recordId, alreadyBreakCount, false);
                 Long lastStartTime = System.currentTimeMillis();
                 ExamRecordCacheUtil.setLastStartTime(recordId, lastStartTime, false);
-                String[] columns = new String[]{ExamRecordFieldEnum.last_break_id.name(), ExamRecordFieldEnum.status.name(), ExamRecordFieldEnum.last_break_time.name(), ExamRecordFieldEnum.already_break_count.name(), ExamRecordFieldEnum.last_start_time.name()};
-                Object[] values = new Object[]{breakId, ExamRecordStatusEnum.BREAK_OFF, lastBreakTimeNow, alreadyBreakCount, lastStartTime};
+                String[] columns = new String[] { ExamRecordFieldEnum.last_break_id.name(),
+                        ExamRecordFieldEnum.status.name(), ExamRecordFieldEnum.last_break_time.name(),
+                        ExamRecordFieldEnum.already_break_count.name(), ExamRecordFieldEnum.last_start_time.name() };
+                Object[] values = new Object[] { breakId, ExamRecordStatusEnum.BREAK_OFF, lastBreakTimeNow,
+                        alreadyBreakCount, lastStartTime };
                 TOeExamRecordService tOeExamRecordService = SpringContextHolder.getBean(TOeExamRecordService.class);
                 tOeExamRecordService.dataUpdatesMq(recordId, columns, values);
                 //考试断点异常原因 发送mq start
-                MqDto mqDtoBreak = new MqDto(MqTopicEnum.THEMIS_TOPIC.getCode(), MqTagEnum.EXAM_BREAK.name(), ExceptionEnum.NET_TIME_OUT, MqTagEnum.EXAM_BREAK, String.valueOf(recordId), String.valueOf(recordId));
+                MqDto mqDtoBreak = new MqDto(MqTopicEnum.THEMIS_TOPIC.getCode(), MqTagEnum.EXAM_BREAK.name(),
+                        ExceptionEnum.NET_TIME_OUT, MqTagEnum.EXAM_BREAK, String.valueOf(recordId),
+                        String.valueOf(recordId));
                 MqDtoService mqDtoService = SpringContextHolder.getBean(MqDtoService.class);
                 mqDtoService.assembleSendOneWayMsg(mqDtoBreak);
                 //考试断点异常原因 发送mq end
 
                 Long examId = ExamRecordCacheUtil.getExamId(recordId);
                 ExamCacheBean ec = examService.getExamCacheBean(examId);//考试缓存
-                Integer breakExpireSeconds = Objects.isNull(ec.getBreakExpireSeconds()) ? 0 : ec.getBreakExpireSeconds();
+                Integer breakExpireSeconds = Objects.isNull(ec.getBreakExpireSeconds()) ?
+                        0 :
+                        ec.getBreakExpireSeconds();
                 if (breakExpireSeconds > 0) {
                     List<String> list = SystemConstant.mqDelayLevelList.subList(5, 15);
                     String level = null;
@@ -1012,12 +1077,16 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
                     tranMap.put("timeOut", time);
                     tranMap.put("mqExecTime", dt.toInstant(ZoneOffset.of("+8")).toEpochMilli());
                     //考试断点延时消息 发送mq start
-                    MqDto mqDtoBreakDelay = new MqDto(MqTopicEnum.THEMIS_TOPIC.getCode(), MqTagEnum.EXAM_BREAK_DELAY.name(), MqTagEnum.EXAM_BREAK_DELAY, MqTagEnum.EXAM_BREAK_DELAY, String.valueOf(recordId), tranMap, String.valueOf(recordId));
+                    MqDto mqDtoBreakDelay = new MqDto(MqTopicEnum.THEMIS_TOPIC.getCode(),
+                            MqTagEnum.EXAM_BREAK_DELAY.name(), MqTagEnum.EXAM_BREAK_DELAY, MqTagEnum.EXAM_BREAK_DELAY,
+                            String.valueOf(recordId), tranMap, String.valueOf(recordId));
                     mqDtoService.assembleSendAsyncDelayMsg(mqDtoBreakDelay);
                     //考试断点延时消息 发送mq end
                 }
                 //更新场次-考试记录缓存
-                ExamActivityRecordCacheUtil.setExamRecordStatus(examActivityId, recordId, new ExamActivityRecordCacheBean(ExamRecordCacheUtil.getExamStudentId(recordId), ExamRecordCacheUtil.getStatus(recordId)));
+                ExamActivityRecordCacheUtil.setExamRecordStatus(examActivityId, recordId,
+                        new ExamActivityRecordCacheBean(ExamRecordCacheUtil.getExamStudentId(recordId),
+                                ExamRecordCacheUtil.getStatus(recordId)));
             } catch (Exception e) {
                 log.error("请求出错", e);
                 if (e instanceof BusinessException) {
@@ -1043,27 +1112,37 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
     @Override
     public Boolean sendExamBreakMsg(Long recordId, boolean setBreak) {
         Boolean finished = false;
-        if (redisUtil.lock(SystemConstant.REDIS_LOCK_EXAM_BREAK_LOGIC_PREFIX + recordId, SystemConstant.REDIS_LOCK_EXAM_BREAK_LOGIC_TIME_OUT)) {
+        if (redisUtil.lock(SystemConstant.REDIS_LOCK_EXAM_BREAK_LOGIC_PREFIX + recordId,
+                SystemConstant.REDIS_LOCK_EXAM_BREAK_LOGIC_TIME_OUT)) {
             try {
                 Long examId = ExamRecordCacheUtil.getExamId(recordId);
                 Long examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
                 ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
                 ExamCacheBean ec = examService.getExamCacheBean(examId);//考试缓存
                 Long lastBreakTime = ExamRecordCacheUtil.getLastBreakTime(recordId);
-                Integer breakExpireSeconds = Objects.isNull(ec.getBreakExpireSeconds()) ? 0 : ec.getBreakExpireSeconds();
-                Integer durationSeconds = Objects.isNull(ExamRecordCacheUtil.getDurationSeconds(recordId)) ? 0 : ExamRecordCacheUtil.getDurationSeconds(recordId);
-                Integer alreadyBreakCount = Objects.isNull(ExamRecordCacheUtil.getAlreadyBreakCount(recordId)) ? 0 : ExamRecordCacheUtil.getAlreadyBreakCount(recordId);
+                Integer breakExpireSeconds = Objects.isNull(ec.getBreakExpireSeconds()) ?
+                        0 :
+                        ec.getBreakExpireSeconds();
+                Integer durationSeconds = Objects.isNull(ExamRecordCacheUtil.getDurationSeconds(recordId)) ?
+                        0 :
+                        ExamRecordCacheUtil.getDurationSeconds(recordId);
+                Integer alreadyBreakCount = Objects.isNull(ExamRecordCacheUtil.getAlreadyBreakCount(recordId)) ?
+                        0 :
+                        ExamRecordCacheUtil.getAlreadyBreakCount(recordId);
                 if (setBreak) {//如果需要断点,则次数本地先加1,可以避免多生成考试记录
                     alreadyBreakCount++;
                 }
                 Integer leftBreakResumeCount = ec.getBreakResumeCount() - alreadyBreakCount;
-                if (Objects.nonNull(lastBreakTime) && (System.currentTimeMillis() - lastBreakTime) / 1000 >= breakExpireSeconds) {
+                if (Objects.nonNull(lastBreakTime)
+                        && (System.currentTimeMillis() - lastBreakTime) / 1000 >= breakExpireSeconds) {
                     finished = true;
-                    examService.finish(examStudentCacheBean.getStudentId(), recordId, FinishTypeEnum.AUTO.name(), durationSeconds);
+                    examService.finish(examStudentCacheBean.getStudentId(), recordId, FinishTypeEnum.AUTO.name(),
+                            durationSeconds);
                 } else {
                     if (leftBreakResumeCount < 0) {
                         finished = true;
-                        examService.finish(examStudentCacheBean.getStudentId(), recordId, FinishTypeEnum.AUTO.name(), durationSeconds);
+                        examService.finish(examStudentCacheBean.getStudentId(), recordId, FinishTypeEnum.AUTO.name(),
+                                durationSeconds);
                     } else {
                         if (setBreak) {
                             this.setExamBreak(recordId);
@@ -1101,8 +1180,8 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
             examId = markResultDto.getExamId();
             examStudentId = markResultDto.getExamStudentId();
         } else {
-            if (Objects.nonNull(markResultDto.getSumScore())
-                    && markResultDto.getSumScore().doubleValue() >= sumScore.doubleValue()) {
+            if (Objects.nonNull(markResultDto.getSumScore()) && markResultDto.getSumScore().doubleValue() >= sumScore
+                    .doubleValue()) {
                 sumScore = markResultDto.getSumScore();
                 examId = markResultDto.getExamId();
                 examStudentId = markResultDto.getExamStudentId();

+ 20 - 5
themis-business/src/main/java/com/qmth/themis/business/templete/TaskExportCommon.java

@@ -27,18 +27,31 @@ import java.util.*;
  * @Date: 2020/7/19
  */
 public class TaskExportCommon {
+
     private final static Logger log = LoggerFactory.getLogger(TaskExportCommon.class);
+
     private Map<String, Object> map = null;
+
     private Long orgId = null;
+
     private Long createId = null;
+
     private TBTaskHistoryService tbTaskHistoryService = null;
+
     private OssUtil ossUtil = null;
+
     private Map<String, Object> ossEnv = null;
+
     private TBTaskHistory tbTaskHistory = null;
+
     private String timeFormat = null;
+
     private boolean exception = false;
+
     private TBAttachmentService tbAttachmentService = null;
+
     private String type = null;
+
     private List<String> txtList = null;
 
     public TaskExportCommon() {
@@ -80,8 +93,9 @@ public class TaskExportCommon {
      */
     public File createExcel(String path) throws IOException {
         StringJoiner stringJoiner = new StringJoiner("");
-        File file = new File(stringJoiner.add(path).add(File.separator).add(String.valueOf(UUID.randomUUID()).replaceAll("-", ""))
-                .add(SystemConstant.EXCEL_PREFIX).toString());
+        File file = new File(
+                stringJoiner.add(path).add(File.separator).add(String.valueOf(UUID.randomUUID()).replaceAll("-", ""))
+                        .add(SystemConstant.EXCEL_PREFIX).toString());
         if (!file.exists()) {
             file.getParentFile().mkdirs();
             file.createNewFile();
@@ -98,7 +112,7 @@ public class TaskExportCommon {
     public void ossUpload(File file) throws FileNotFoundException {
         boolean oss = (boolean) this.getOssEnv().get(SystemConstant.OSS);
         if (oss) {//上传至oss
-            this.ossUtil.ossUpload(this.ossEnv, file.getPath().replaceAll("\\\\", "/"), new FileInputStream(file));
+            this.ossUtil.upload(false, file.getPath().replaceAll("\\\\", "/"), new FileInputStream(file));
             file.delete();
         }
     }
@@ -128,7 +142,8 @@ public class TaskExportCommon {
     public void writeExportResultTxt(String path, String txtStr, File excelFile) throws IOException {
         FileWriter fileWriter = null;
         try {
-            File file = new File(path + File.separator + String.valueOf(UUID.randomUUID()).replaceAll("-", "") + SystemConstant.TXT_PREFIX);
+            File file = new File(path + File.separator + String.valueOf(UUID.randomUUID()).replaceAll("-", "")
+                    + SystemConstant.TXT_PREFIX);
             if (!file.exists()) {
                 file.getParentFile().mkdirs();
                 file.createNewFile();
@@ -155,7 +170,7 @@ public class TaskExportCommon {
                 this.tbTaskHistory.setResultFilePath(excelJson.toJSONString());
             }
             if (Objects.equals(this.type, SystemConstant.OSS)) {
-                this.ossUtil.ossUpload(this.ossEnv, file.getPath().replaceAll("\\\\", "/"), txtStr);
+                this.ossUtil.upload(false, file.getPath().replaceAll("\\\\", "/"), txtStr);
                 file.delete();
             }
             tbTaskHistoryService.updateById(this.tbTaskHistory);

+ 22 - 4
themis-business/src/main/java/com/qmth/themis/business/templete/TaskImportCommon.java

@@ -25,21 +25,37 @@ import java.util.*;
  * @Date: 2020/7/19
  */
 public class TaskImportCommon {
+
     private final static Logger log = LoggerFactory.getLogger(TaskImportCommon.class);
+
     private String mode = null;//mode
+
     private Map<String, Object> map = null;
+
     private Long orgId = null;
+
     private Long createId = null;
+
     private Long examId = null;
+
     private TBTaskHistoryService tbTaskHistoryService = null;
+
     private String type = null;
+
     private String path = null;
+
     private Integer uploadType = null;
+
     private OssUtil ossUtil = null;
+
     private Map<String, Object> ossEnv = null;
+
     private TBTaskHistory tbTaskHistory = null;
+
     private String timeFormat = null;
+
     private boolean exception = false;
+
     private List<String> txtList = null;
 
     public TaskImportCommon() {
@@ -88,11 +104,12 @@ public class TaskImportCommon {
     public File getUploadFile() {
         File file = null;
         if (Objects.nonNull(this.type) && Objects.equals(this.type, SystemConstant.LOCAL)) {
-            StringJoiner localPath = new StringJoiner("").add(SystemConstant.FILES_DIR).add(File.separator).add(this.path);
+            StringJoiner localPath = new StringJoiner("").add(SystemConstant.FILES_DIR).add(File.separator)
+                    .add(this.path);
             file = new File(localPath.toString());
         } else {
             try {
-                file = this.ossUtil.ossDownload(this.ossEnv, this.path, this.path);
+                file = this.ossUtil.download(false, this.path, this.path);
             } catch (IOException e) {
                 log.error("请求出错", e);
             }
@@ -114,7 +131,8 @@ public class TaskImportCommon {
                 this.path = SystemConstant.FILES_DIR + File.separator + this.path;
             }
             this.path = this.path.substring(0, this.path.lastIndexOf(File.separator) + 1);
-            File file = new File(this.path + String.valueOf(UUID.randomUUID()).replaceAll("-", "") + SystemConstant.TXT_PREFIX);
+            File file = new File(
+                    this.path + String.valueOf(UUID.randomUUID()).replaceAll("-", "") + SystemConstant.TXT_PREFIX);
             if (!file.exists()) {
                 file.getParentFile().mkdirs();
                 file.createNewFile();
@@ -126,7 +144,7 @@ public class TaskImportCommon {
             json.put("type", this.type);
             this.tbTaskHistory.setReportFilePath(json.toJSONString());
             if (Objects.equals(this.type, SystemConstant.OSS)) {
-                this.ossUtil.ossUpload(this.ossEnv, file.getPath(), txtStr);
+                this.ossUtil.upload(false, file.getPath(), txtStr);
                 file.delete();
                 if (Objects.nonNull(excelFile)) {
                     excelFile.delete();

+ 42 - 35
themis-business/src/main/java/com/qmth/themis/business/templete/impl/TaskExamPaperImportTemplete.java

@@ -49,21 +49,26 @@ import java.util.*;
  */
 @Service("taskExamPaperImportTemplete")
 public class TaskExamPaperImportTemplete implements TaskImportTemplete {
+
     private final static Logger log = LoggerFactory.getLogger(TaskExamPaperImportTemplete.class);
+
     private SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
+
     @Resource
     TEExamService teExamService;
+
     @Resource
     OssUtil ossUtil;
+
     @Resource
     TEExamCourseService teExamCourseService;
+
     @Resource
     TEExamPaperService teExamPaperService;
 
     @Resource
     TOeExamRecordService examRecordService;
 
-
     @Resource
     RedisUtil redisUtil;
 
@@ -222,7 +227,7 @@ public class TaskExamPaperImportTemplete implements TaskImportTemplete {
     }
 
     private void disposePaperDir(String rootDir, TEExam teExam, TEExamCourse course, File paperDir,
-                                 Map<String, Object> map) {
+            Map<String, Object> map) {
         String paperCode = paperDir.getName();
         File[] childs = paperDir.listFiles();
 
@@ -242,8 +247,8 @@ public class TaskExamPaperImportTemplete implements TaskImportTemplete {
                 }
             }
         }
-        TEExamPaper paper = teExamPaperService.findByExamIdAndCourseCodeAndPaperCode(teExam.getId(),
-                course.getCourseCode(), paperCode);
+        TEExamPaper paper = teExamPaperService
+                .findByExamIdAndCourseCodeAndPaperCode(teExam.getId(), course.getCourseCode(), paperCode);
         if (paper == null) {
             paper = new TEExamPaper();
             String createId = map.get("createId").toString();
@@ -273,7 +278,7 @@ public class TaskExamPaperImportTemplete implements TaskImportTemplete {
                 structFile = paperFile;
             } else {
                 String structPath = paper.getStructPath();
-                String url = OssUtil.getUrlForPrivateBucket(ossUtil.getAliYunOssPrivateDomain().getMap(), structPath);
+                String url = ossUtil.getPrivateUrl(structPath);
                 structFile = new File(rootDir + uuid() + ".json");
                 FileUtil.saveUrlAsFile(url, structFile);
             }
@@ -316,7 +321,7 @@ public class TaskExamPaperImportTemplete implements TaskImportTemplete {
         FileUtil.saveAsFile(urlPaperFile.getAbsolutePath(), structJson.toJSONString());
         String filePath = sdf.format(new Date()) + "/" + uuid() + ".json";
         paper.setPaperViewPath(filePath);
-        OssUtil.ossUpload(ossUtil.getAliYunOssPrivateDomain().getMap(), filePath, urlPaperFile);
+        ossUtil.upload(false, filePath, urlPaperFile);
     }
 
     private void disposeQuestionBodyUrl(String rootDir, JSONObject body, Long paperId, File attachmentDir) {
@@ -385,7 +390,7 @@ public class TaskExamPaperImportTemplete implements TaskImportTemplete {
         FileUtil.encryptFile(zip, encryptZip, paper.getDecryptSecret(), paper.getDecryptVector());
         String filePath = sdf.format(new Date()) + "/" + uuid() + ".zip";
         paper.setPaperPath(filePath);
-        OssUtil.ossUpload(ossUtil.getAliYunOssPrivateDomain().getMap(), filePath, encryptZip);
+        ossUtil.upload(false, filePath, encryptZip);
     }
 
     private void disposeStruct(String rootDir, TEExamPaper paper, File paperFile) {
@@ -407,9 +412,8 @@ public class TaskExamPaperImportTemplete implements TaskImportTemplete {
                     score = 0.0;
                 }
                 Integer structType = question.getInteger("structType");
-                if (structType.intValue() != 1
-                        && structType.intValue() != 2
-                        && structType.intValue() != 3 && structType.intValue() != 6) {//主观题
+                if (structType.intValue() != 1 && structType.intValue() != 2 && structType.intValue() != 3
+                        && structType.intValue() != 6) {//主观题
                     subTotal = subTotal.add(new BigDecimal(score));
                 } else {//客观题
                     obTotal = obTotal.add(new BigDecimal(score));
@@ -425,8 +429,7 @@ public class TaskExamPaperImportTemplete implements TaskImportTemplete {
                             subScore = 0.0;
                         }
                         Integer subStructType = subquestion.getInteger("structType");
-                        if (subStructType.intValue() != 1
-                                && subStructType.intValue() != 2
+                        if (subStructType.intValue() != 1 && subStructType.intValue() != 2
                                 && subStructType.intValue() != 3) {//主观题
                             subTotal = subTotal.add(new BigDecimal(subScore));
                         } else {//客观题
@@ -443,10 +446,11 @@ public class TaskExamPaperImportTemplete implements TaskImportTemplete {
         paper.setStructPath(filePath);
         paper.setTotalObjectiveScore(obTotal.doubleValue());
         paper.setTotalSubjectiveScore(subTotal.doubleValue());
-        OssUtil.ossUpload(ossUtil.getAliYunOssPrivateDomain().getMap(), filePath, file);
+        ossUtil.upload(false, filePath, file);
     }
 
-    private void disposeAnswer(String rootDir, TEExamPaper paper, File answerFile, File structFile, File attachmentDir) {
+    private void disposeAnswer(String rootDir, TEExamPaper paper, File answerFile, File structFile,
+            File attachmentDir) {
         if (answerFile == null) {
             return;
         }
@@ -487,7 +491,7 @@ public class TaskExamPaperImportTemplete implements TaskImportTemplete {
         FileUtil.saveAsFile(urlAnswerFile.getAbsolutePath(), answerJson.toJSONString());
         String filePath = sdf.format(new Date()) + "/" + uuid() + ".json";
         paper.setAnswerPath(filePath);
-        OssUtil.ossUpload(ossUtil.getAliYunOssPrivateDomain().getMap(), filePath, urlAnswerFile);
+        ossUtil.upload(false, filePath, urlAnswerFile);
     }
 
     private void disposeAnswerUrl(String rootDir, JSONArray answer, Long paperId, File attachmentDir) {
@@ -518,10 +522,8 @@ public class TaskExamPaperImportTemplete implements TaskImportTemplete {
     private void uploadImageAndAudio(String rootDir, JSONObject blockInfo, Long paperId, File attachmentDir) {
         String type = blockInfo.getString("type");
         String value = blockInfo.getString("value");
-        if (("image".equals(type) || "audio".equals(type))
-                && StringUtils.isNotBlank(value)
-                && !value.toLowerCase().startsWith("https://")
-                && !value.toLowerCase().startsWith("http://")) {
+        if (("image".equals(type) || "audio".equals(type)) && StringUtils.isNotBlank(value) && !value.toLowerCase()
+                .startsWith("https://") && !value.toLowerCase().startsWith("http://")) {
             if ("image".equals(type) && value.contains("data:image")) {
                 String suff = value.substring(11, value.indexOf(";"));
                 File iamgeFile = new File(rootDir + uuid() + "." + suff);
@@ -533,13 +535,13 @@ public class TaskExamPaperImportTemplete implements TaskImportTemplete {
                     throw new BusinessException("媒体文件上传处理出错:" + blockInfo.toJSONString() + " errmsg:" + e.getMessage());
                 }
                 String filePath = "upload/paper_file/" + paperId + "/" + uuid() + "." + suff;
-                OssUtil.ossUpload(ossUtil.getAliYunOssPrivateDomain().getMap(), filePath, iamgeFile);
+                ossUtil.upload(false, filePath, iamgeFile);
                 blockInfo.put("value", ossUtil.getAliYunOssPrivateDomain().getPrivateUrl() + "/" + filePath);
             } else {
                 String suff = value.substring(value.indexOf("."));
                 String filePath = "upload/paper_file/" + paperId + "/" + uuid() + suff;
                 File audioFile = new File(attachmentDir.getAbsolutePath() + "/" + value);
-                OssUtil.ossUpload(ossUtil.getAliYunOssPrivateDomain().getMap(), filePath, audioFile);
+                ossUtil.upload(false, filePath, audioFile);
                 blockInfo.put("value", ossUtil.getAliYunOssPrivateDomain().getPrivateUrl() + "/" + filePath);
             }
         }
@@ -638,7 +640,7 @@ public class TaskExamPaperImportTemplete implements TaskImportTemplete {
     }
 
     private void checkAnswerFile(String rootDir, File[] paperDirChilds, Long examId, String courseCode,
-                                 String paperCode) {
+            String paperCode) {
         File paperFile = null;
         File answerFile = null;
         for (File cfile : paperDirChilds) {// 校验试卷下的答案
@@ -651,13 +653,13 @@ public class TaskExamPaperImportTemplete implements TaskImportTemplete {
         }
         if (answerFile != null) {
             if (paperFile == null) {// 没有试卷信息,不能先导入答案
-                TEExamPaper paper = teExamPaperService.findByExamIdAndCourseCodeAndPaperCode(examId, courseCode,
-                        paperCode);
+                TEExamPaper paper = teExamPaperService
+                        .findByExamIdAndCourseCodeAndPaperCode(examId, courseCode, paperCode);
                 if (paper == null) {
                     throw new BusinessException("科目 " + courseCode + " 试卷 " + paperCode + " 没有试卷信息,不能先导入答案");
                 }
                 String structPath = paper.getStructPath();
-                String url = OssUtil.getUrlForPrivateBucket(ossUtil.getAliYunOssPrivateDomain().getMap(), structPath);
+                String url = ossUtil.getPrivateUrl(structPath);
                 String name = structPath.substring(structPath.lastIndexOf("/") + 1);
                 File structFile = new File(rootDir + name);
                 try {
@@ -696,23 +698,26 @@ public class TaskExamPaperImportTemplete implements TaskImportTemplete {
                         || structquestion.getInteger("structType").intValue() == 2) {
                     JSONArray answer = answerquestion.getJSONArray("answer");
                     if (answer == null || answer.size() == 0) {
-                        throw new BusinessException("科目 " + courseCode + " 试卷 " + paperCode + " 答案和试卷第" + (i + 1)
-                                + "大题第" + (j + 1) + "小题没有答案");
+                        throw new BusinessException(
+                                "科目 " + courseCode + " 试卷 " + paperCode + " 答案和试卷第" + (i + 1) + "大题第" + (j + 1)
+                                        + "小题没有答案");
                     }
                 }
                 if (structquestion.getInteger("structType").intValue() == 3) {
                     Boolean answer = answerquestion.getBoolean("answer");
                     if (answer == null) {
-                        throw new BusinessException("科目 " + courseCode + " 试卷 " + paperCode + " 答案和试卷第" + (i + 1)
-                                + "大题第" + (j + 1) + "小题没有答案");
+                        throw new BusinessException(
+                                "科目 " + courseCode + " 试卷 " + paperCode + " 答案和试卷第" + (i + 1) + "大题第" + (j + 1)
+                                        + "小题没有答案");
                     }
                 }
                 if (structquestion.getInteger("structType").intValue() == 6) {
                     JSONArray answersubQuestions = answerquestion.getJSONArray("subQuestions");
                     JSONArray structsubQuestions = structquestion.getJSONArray("subQuestions");
                     if (answersubQuestions.size() != structsubQuestions.size()) {
-                        throw new BusinessException("科目 " + courseCode + " 试卷 " + paperCode + " 答案和试卷第" + (i + 1)
-                                + "大题第" + (j + 1) + "小题子题数量不一致");
+                        throw new BusinessException(
+                                "科目 " + courseCode + " 试卷 " + paperCode + " 答案和试卷第" + (i + 1) + "大题第" + (j + 1)
+                                        + "小题子题数量不一致");
                     }
                     for (int k = 0; k < answersubQuestions.size(); k++) {
                         JSONObject answersubquestion = answersubQuestions.getJSONObject(k);
@@ -721,15 +726,17 @@ public class TaskExamPaperImportTemplete implements TaskImportTemplete {
                                 || structsubquestion.getInteger("structType").intValue() == 2) {
                             JSONArray answer = answersubquestion.getJSONArray("answer");
                             if (answer == null || answer.size() == 0) {
-                                throw new BusinessException("科目 " + courseCode + " 试卷 " + paperCode + " 答案和试卷第"
-                                        + (i + 1) + "大题第" + (j + 1) + "小题第" + (k + 1) + "子题没有答案");
+                                throw new BusinessException(
+                                        "科目 " + courseCode + " 试卷 " + paperCode + " 答案和试卷第" + (i + 1) + "大题第" + (j + 1)
+                                                + "小题第" + (k + 1) + "子题没有答案");
                             }
                         }
                         if (structsubquestion.getInteger("structType").intValue() == 3) {
                             Boolean answer = answersubquestion.getBoolean("answer");
                             if (answer == null) {
-                                throw new BusinessException("科目 " + courseCode + " 试卷 " + paperCode + " 答案和试卷第"
-                                        + (i + 1) + "大题第" + (j + 1) + "小题第" + (k + 1) + "子题没有答案");
+                                throw new BusinessException(
+                                        "科目 " + courseCode + " 试卷 " + paperCode + " 答案和试卷第" + (i + 1) + "大题第" + (j + 1)
+                                                + "小题第" + (k + 1) + "子题没有答案");
                             }
                         }
                     }

+ 106 - 159
themis-business/src/main/java/com/qmth/themis/business/util/OssUtil.java

@@ -1,29 +1,27 @@
 package com.qmth.themis.business.util;
 
+import com.aliyun.oss.ClientBuilderConfiguration;
 import com.aliyun.oss.OSS;
 import com.aliyun.oss.OSSClientBuilder;
 import com.aliyun.oss.model.*;
-import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.business.domain.AliYunOssDomain;
 import com.qmth.themis.business.domain.AliYunOssPrivateDomain;
 import com.qmth.themis.business.domain.AliYunOssPublicDomain;
-import com.qmth.themis.business.domain.TencentYunDomain;
+import com.qmth.themis.business.enums.UploadFileEnum;
+import org.apache.commons.io.IOUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
 import org.springframework.stereotype.Component;
 
-import javax.annotation.Resource;
-import javax.swing.*;
 import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
+import java.nio.charset.StandardCharsets;
 import java.util.Date;
 import java.util.List;
-import java.util.Map;
 
 /**
  * @Description: oss工具
@@ -34,21 +32,46 @@ import java.util.Map;
  */
 @Component
 public class OssUtil {
+
     private final static Logger log = LoggerFactory.getLogger(OssUtil.class);
 
     private AliYunOssPublicDomain aliYunOssPublicDomain;
 
+    private OSS publicClient;
+
+    private OSS privateClient;
+
+    private OSS privateUrlClient;
+
     private AliYunOssPrivateDomain aliYunOssPrivateDomain;
 
     @Bean
     public AliYunOssPublicDomain publicOssEnv(AliYunOssDomain aliYunOssDomain) {
-        aliYunOssPublicDomain = new AliYunOssPublicDomain(aliYunOssDomain.getPublicEndpoint(), aliYunOssDomain.getPublicName(), aliYunOssDomain.getPublicAccessKeyId(), aliYunOssDomain.getPublicAccessKeySecret(), aliYunOssDomain.getPublicBucket(), aliYunOssDomain.getPublicUrl());
+        aliYunOssPublicDomain = new AliYunOssPublicDomain(aliYunOssDomain.getPublicEndpoint(),
+                aliYunOssDomain.getPublicName(), aliYunOssDomain.getPublicAccessKeyId(),
+                aliYunOssDomain.getPublicAccessKeySecret(), aliYunOssDomain.getPublicBucket(),
+                aliYunOssDomain.getPublicUrl());
+        publicClient = new OSSClientBuilder()
+                .build(aliYunOssDomain.getPublicEndpoint(), aliYunOssDomain.getPublicAccessKeyId(),
+                        aliYunOssDomain.getPublicAccessKeySecret());
         return aliYunOssPublicDomain;
     }
 
     @Bean
     public AliYunOssPrivateDomain privateOssEnv(AliYunOssDomain aliYunOssDomain) {
-        aliYunOssPrivateDomain = new AliYunOssPrivateDomain(aliYunOssDomain.getPrivateEndpoint(), aliYunOssDomain.getPrivateName(), aliYunOssDomain.getPrivateAccessKeyId(), aliYunOssDomain.getPrivateAccessKeySecret(), aliYunOssDomain.getPrivateBucket(), aliYunOssDomain.getPrivateUrl());
+        aliYunOssPrivateDomain = new AliYunOssPrivateDomain(aliYunOssDomain.getPrivateEndpoint(),
+                aliYunOssDomain.getPrivateName(), aliYunOssDomain.getPrivateAccessKeyId(),
+                aliYunOssDomain.getPrivateAccessKeySecret(), aliYunOssDomain.getPrivateBucket(),
+                aliYunOssDomain.getPrivateUrl());
+        privateClient = new OSSClientBuilder()
+                .build(aliYunOssDomain.getPrivateEndpoint(), aliYunOssDomain.getPrivateAccessKeyId(),
+                        aliYunOssDomain.getPrivateAccessKeySecret());
+
+        ClientBuilderConfiguration conf = new ClientBuilderConfiguration();
+        conf.setSupportCname(true);
+        privateUrlClient = new OSSClientBuilder()
+                .build(aliYunOssDomain.getPrivateUrl(), aliYunOssDomain.getPrivateAccessKeyId(),
+                        aliYunOssDomain.getPrivateAccessKeySecret(), conf);
         return aliYunOssPrivateDomain;
     }
 
@@ -60,215 +83,139 @@ public class OssUtil {
         return aliYunOssPrivateDomain;
     }
 
+    public boolean isPublic(UploadFileEnum type) {
+        return !UploadFileEnum.file.equals(type);
+    }
+
     /**
-     * oss上传文件
+     * oss上传数据流
      *
-     * @param map
-     * @param dirName
+     * @param isPublic
+     * @param objectName
      * @param inputStream
      */
-    public void ossUpload(Map<String, Object> map, String dirName, InputStream inputStream) {
-        log.info("ossUpload is come in");
-        // Endpoint以杭州为例,其它Region请按实际情况填写。
-        String endpoint = String.valueOf(map.get(SystemConstant.END_POINT));
-        // 阿里云主账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM账号进行API访问或日常运维,请登录 https://ram.console.aliyun.com 创建RAM账号。
-        String accessKeyId = String.valueOf(map.get(SystemConstant.ACCESS_KEY_ID));
-        String accessKeySecret = String.valueOf(map.get(SystemConstant.ACCESS_KEY_SECRET));
-        String bucketName = String.valueOf(map.get(SystemConstant.BUCKET));
-        // <yourObjectName>上传文件到OSS时需要指定包含文件后缀在内的完整路径,例如abc/efg/123.jpg。
-        String objectName = dirName;
-        // 创建OSSClient实例。
-        OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
+    public void upload(boolean isPublic, String objectName, InputStream inputStream) {
+        log.info("oss  upload stream is come in");
+        String bucket = isPublic ? aliYunOssPublicDomain.getPublicBucket() : aliYunOssPrivateDomain.getPrivateBucket();
+        OSS client = isPublic ? publicClient : privateClient;
         // 上传内容到指定的存储空间(bucketName)并保存为指定的文件名称(objectName)。
-        PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, objectName, inputStream);
-        PutObjectResult por = ossClient.putObject(putObjectRequest);
+        PutObjectRequest putObjectRequest = new PutObjectRequest(bucket, objectName, inputStream);
+        PutObjectResult por = client.putObject(putObjectRequest);
         log.info("objectName:{},requestid:{}", objectName, por.getRequestId());
-        ossClient.shutdown();
     }
 
     /**
-     * oss上传文件
+     * oss上传本地文件
      *
-     * @param map
-     * @param dirName
-     * @param content
+     * @param isPublic
+     * @param objectName
+     * @param file
      */
-    public void ossUpload(Map<String, Object> map, String dirName, String content) {
-        log.info("ossUpload is come in");
-        // Endpoint以杭州为例,其它Region请按实际情况填写。
-        String endpoint = String.valueOf(map.get(SystemConstant.END_POINT));
-        // 阿里云主账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM账号进行API访问或日常运维,请登录 https://ram.console.aliyun.com 创建RAM账号。
-        String accessKeyId = String.valueOf(map.get(SystemConstant.ACCESS_KEY_ID));
-        String accessKeySecret = String.valueOf(map.get(SystemConstant.ACCESS_KEY_SECRET));
-        String bucketName = String.valueOf(map.get(SystemConstant.BUCKET));
-        // <yourObjectName>上传文件到OSS时需要指定包含文件后缀在内的完整路径,例如abc/efg/123.jpg。
-        String objectName = dirName;
-        // 创建OSSClient实例。
-        OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
+    public void upload(boolean isPublic, String objectName, File file) {
+        log.info("oss  upload file is come in");
+        String bucket = isPublic ? aliYunOssPublicDomain.getPublicBucket() : aliYunOssPrivateDomain.getPrivateBucket();
+        OSS client = isPublic ? publicClient : privateClient;
         // 上传内容到指定的存储空间(bucketName)并保存为指定的文件名称(objectName)。
-        PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, objectName, new ByteArrayInputStream(content.getBytes()));
-        PutObjectResult por = ossClient.putObject(putObjectRequest);
+        PutObjectRequest putObjectRequest = new PutObjectRequest(bucket, objectName, file);
+        PutObjectResult por = client.putObject(putObjectRequest);
         log.info("objectName:{},requestid:{}", objectName, por.getRequestId());
-        ossClient.shutdown();
     }
 
     /**
-     * oss copy
+     * oss上传数据内容
      *
-     * @param map
-     * @param dirName
-     * @param dirNewName
+     * @param isPublic
+     * @param objectName
+     * @param content
      */
-    public void ossCopy(Map<String, Object> map, String dirName, String dirNewName) {
-        log.info("ossCopy is come in");
-        // Endpoint以杭州为例,其它Region请按实际情况填写。
-        String endpoint = String.valueOf(map.get(SystemConstant.END_POINT));
-        // 阿里云主账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM账号进行API访问或日常运维,请登录 https://ram.console.aliyun.com 创建RAM账号。
-        String accessKeyId = String.valueOf(map.get(SystemConstant.ACCESS_KEY_ID));
-        String accessKeySecret = String.valueOf(map.get(SystemConstant.ACCESS_KEY_SECRET));
-        String sourceBucketName = String.valueOf(map.get(SystemConstant.BUCKET));
-        String sourceObjectName = dirName;
-        String destinationBucketName = String.valueOf(map.get(SystemConstant.BUCKET));
-        String destinationObjectName = dirNewName;
-        // 创建OSSClient实例。
-        OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
-        // 拷贝文件。
-        CopyObjectResult result = ossClient.copyObject(sourceBucketName, sourceObjectName, destinationBucketName, destinationObjectName);
-        log.info("ETag:{},LastModified:{}", result.getETag(), result.getLastModified());
-        // 关闭OSSClient。
-        ossClient.shutdown();
+    public void upload(boolean isPublic, String objectName, String content) {
+        log.info("oss public upload string is come in");
+        String bucket = isPublic ? aliYunOssPublicDomain.getPublicBucket() : aliYunOssPrivateDomain.getPrivateBucket();
+        OSS client = isPublic ? publicClient : privateClient;
+        // 上传内容到指定的存储空间(bucketName)并保存为指定的文件名称(objectName)。
+        PutObjectRequest putObjectRequest = new PutObjectRequest(bucket, objectName,
+                new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8)));
+        PutObjectResult por = client.putObject(putObjectRequest);
+        log.info("objectName:{},requestid:{}", objectName, por.getRequestId());
     }
 
     /**
      * 从oss上下载文件到本地
      *
-     * @param map
-     * @param dirName
+     * @param isPublic
      * @param localPath
      * @throws IOException
      */
-    public File ossDownload(Map<String, Object> map, String dirName, String localPath) throws IOException {
-        log.info("ossDownload is come in");
-        // Endpoint以杭州为例,其它Region请按实际情况填写。
-        String endpoint = String.valueOf(map.get(SystemConstant.END_POINT));
-        // 阿里云主账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM账号进行API访问或日常运维,请登录 https://ram.console.aliyun.com 创建RAM账号。
-        String accessKeyId = String.valueOf(map.get(SystemConstant.ACCESS_KEY_ID));
-        String accessKeySecret = String.valueOf(map.get(SystemConstant.ACCESS_KEY_SECRET));
-        String bucketName = String.valueOf(map.get(SystemConstant.BUCKET));
-        // <yourObjectName>从OSS下载文件时需要指定包含文件后缀在内的完整路径,例如abc/efg/123.jpg。
-        String objectName = dirName;
-        // 创建OSSClient实例。
-        OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
-        // 下载OSS文件到本地文件。如果指定的本地文件存在会覆盖,不存在则新建。
+    public File download(boolean isPublic, String objectName, String localPath) throws IOException {
+        log.info("oss Download is come in");
+        String bucket = isPublic ? aliYunOssPublicDomain.getPublicBucket() : aliYunOssPrivateDomain.getPrivateBucket();
+        OSS client = isPublic ? publicClient : privateClient;
         File localFile = new File(localPath);
         if (!localFile.getParentFile().exists()) {
             localFile.getParentFile().mkdirs();
         }
-        ossClient.getObject(new GetObjectRequest(bucketName, objectName), localFile);
-        // 关闭OSSClient。
-        ossClient.shutdown();
+        client.getObject(new GetObjectRequest(bucket, objectName), localFile);
         return localFile;
     }
 
     /**
-     * oss删除文件
+     * 从oss上下载文件到byte[]
      *
-     * @param map
-     * @param dirName
+     * @param isPublic
+     * @throws IOException
      */
-    public void ossDelete(Map<String, Object> map, String dirName) {
-        // Endpoint以杭州为例,其它Region请按实际情况填写。
-        String endpoint = String.valueOf(map.get(SystemConstant.END_POINT));
-        // 阿里云主账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM账号进行API访问或日常运维,请登录 https://ram.console.aliyun.com 创建RAM账号。
-        String accessKeyId = String.valueOf(map.get(SystemConstant.ACCESS_KEY_ID));
-        String accessKeySecret = String.valueOf(map.get(SystemConstant.ACCESS_KEY_SECRET));
-        String bucketName = String.valueOf(map.get(SystemConstant.BUCKET));
-        String objectName = dirName;
+    public byte[] download(boolean isPublic, String objectName) throws IOException {
+        log.info("oss Download is come in");
+        String bucket = isPublic ? aliYunOssPublicDomain.getPublicBucket() : aliYunOssPrivateDomain.getPrivateBucket();
+        OSS client = isPublic ? publicClient : privateClient;
+        OSSObject obj = client.getObject(new GetObjectRequest(bucket, objectName));
+        byte[] data = IOUtils.toByteArray(obj.getObjectContent());
+        obj.close();
+        return data;
+    }
 
-        // 创建OSSClient实例。
-        OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
+    /**
+     * oss删除文件
+     *
+     * @param isPublic
+     * @param objectName
+     */
+    public void delete(boolean isPublic, String objectName) {
+        String bucket = isPublic ? aliYunOssPublicDomain.getPublicBucket() : aliYunOssPrivateDomain.getPrivateBucket();
+        OSS client = isPublic ? publicClient : privateClient;
         // 删除文件。如需删除文件夹,请将ObjectName设置为对应的文件夹名称。如果文件夹非空,则需要将文件夹下的所有object删除后才能删除该文件夹。
-        ossClient.deleteObject(bucketName, objectName);
-        // 关闭OSSClient。
-        ossClient.shutdown();
+        client.deleteObject(bucket, objectName);
     }
 
     /**
      * oss批量删除文件
      *
-     * @param map
+     * @param isPublic
      * @param paths
      */
-    public void ossBatchDelete(Map<String, Object> map, List<String> paths) {
-        // Endpoint以杭州为例,其它Region请按实际情况填写。
-        String endpoint = String.valueOf(map.get(SystemConstant.END_POINT));
-        // 阿里云主账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM账号进行API访问或日常运维,请登录 https://ram.console.aliyun.com 创建RAM账号。
-        String accessKeyId = String.valueOf(map.get(SystemConstant.ACCESS_KEY_ID));
-        String accessKeySecret = String.valueOf(map.get(SystemConstant.ACCESS_KEY_SECRET));
-        String bucketName = String.valueOf(map.get(SystemConstant.BUCKET));
-
-        // 创建OSSClient实例。
-        OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
-
+    public void batchDelete(boolean isPublic, List<String> paths) {
+        String bucket = isPublic ? aliYunOssPublicDomain.getPublicBucket() : aliYunOssPrivateDomain.getPrivateBucket();
+        OSS client = isPublic ? publicClient : privateClient;
         // 删除文件。key等同于ObjectName,表示删除OSS文件时需要指定包含文件后缀在内的完整路径,例如abc/efg/123.jpg。
-        DeleteObjectsResult deleteObjectsResult = ossClient.deleteObjects(new DeleteObjectsRequest(bucketName).withKeys(paths));
-        List<String> deletedObjects = deleteObjectsResult.getDeletedObjects();
-        // 关闭OSSClient。
-        ossClient.shutdown();
+        DeleteObjectsResult deleteObjectsResult = client
+                .deleteObjects(new DeleteObjectsRequest(bucket).withKeys(paths));
+        deleteObjectsResult.getDeletedObjects();
     }
 
     /**
      * 获取私有bucket文件访问url,一分钟有效
      *
-     * @param map
      * @param objectPath
-     * @param inputStream
      * @return
      */
-    public static String getUrlForPrivateBucket(Map<String, Object> map, String objectPath) {
-        String endpoint = String.valueOf(map.get(SystemConstant.END_POINT));
-        String accessKeyId = String.valueOf(map.get(SystemConstant.ACCESS_KEY_ID));
-        String accessKeySecret = String.valueOf(map.get(SystemConstant.ACCESS_KEY_SECRET));
-        String bucketName = String.valueOf(map.get(SystemConstant.BUCKET));
-        OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
+    public String getPrivateUrl(String objectPath) {
         Date expiration = new Date(System.currentTimeMillis() + 60 * 1000);
         GeneratePresignedUrlRequest generatePresignedUrlRequest;
-        generatePresignedUrlRequest = new GeneratePresignedUrlRequest(bucketName, objectPath);
+        generatePresignedUrlRequest = new GeneratePresignedUrlRequest(aliYunOssPrivateDomain.getPrivateBucket(),
+                objectPath);
         generatePresignedUrlRequest.setExpiration(expiration);
-        URL url = ossClient.generatePresignedUrl(generatePresignedUrlRequest);
+        URL url = privateUrlClient.generatePresignedUrl(generatePresignedUrlRequest);
         return url.toString();
     }
 
-    public static void ossUpload(Map<String, Object> map, String path, File file) {
-        String endpoint = String.valueOf(map.get(SystemConstant.END_POINT));
-        String accessKeyId = String.valueOf(map.get(SystemConstant.ACCESS_KEY_ID));
-        String accessKeySecret = String.valueOf(map.get(SystemConstant.ACCESS_KEY_SECRET));
-        String bucketName = String.valueOf(map.get(SystemConstant.BUCKET));
-        OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
-        PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, path, file);
-        ossClient.putObject(putObjectRequest);
-        ossClient.shutdown();
-    }
-
-    public static void ossUploadStream(Map<String, Object> map, String path, InputStream inputStream) {
-        String endpoint = String.valueOf(map.get(SystemConstant.END_POINT));
-        String accessKeyId = String.valueOf(map.get(SystemConstant.ACCESS_KEY_ID));
-        String accessKeySecret = String.valueOf(map.get(SystemConstant.ACCESS_KEY_SECRET));
-        String bucketName = String.valueOf(map.get(SystemConstant.BUCKET));
-        OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
-        PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, path, inputStream);
-        ossClient.putObject(putObjectRequest);
-        ossClient.shutdown();
-    }
-
-    public static void ossUploadContent(Map<String, Object> map, String path, String fileContent) {
-        String endpoint = String.valueOf(map.get(SystemConstant.END_POINT));
-        String accessKeyId = String.valueOf(map.get(SystemConstant.ACCESS_KEY_ID));
-        String accessKeySecret = String.valueOf(map.get(SystemConstant.ACCESS_KEY_SECRET));
-        String bucketName = String.valueOf(map.get(SystemConstant.BUCKET));
-        OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
-        PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, path, new ByteArrayInputStream(fileContent.getBytes()));
-        ossClient.putObject(putObjectRequest);
-        ossClient.shutdown();
-    }
 }