Quellcode durchsuchen

base模块审计修复代码同步

linft vor 2 Jahren
Ursprung
Commit
d050a410df
26 geänderte Dateien mit 226 neuen und 256 gelöschten Zeilen
  1. 2 2
      zd-modules/zd-base/src/main/java/com/zd/base/ZdBaseApplicaion.java
  2. 2 0
      zd-modules/zd-base/src/main/java/com/zd/base/app/HexStrUtils.java
  3. 9 44
      zd-modules/zd-base/src/main/java/com/zd/base/app/controller/LabApi.java
  4. 20 31
      zd-modules/zd-base/src/main/java/com/zd/base/app/controller/LabBoardApi.java
  5. 6 3
      zd-modules/zd-base/src/main/java/com/zd/base/app/controller/SysUserApi.java
  6. 14 6
      zd-modules/zd-base/src/main/java/com/zd/base/files/bigupload/utils/FileUtils.java
  7. 1 9
      zd-modules/zd-base/src/main/java/com/zd/base/files/file/service/LocalSysFileServiceImpl.java
  8. 7 42
      zd-modules/zd-base/src/main/java/com/zd/base/files/file/utils/FileUploadUtils.java
  9. 3 11
      zd-modules/zd-base/src/main/java/com/zd/base/files/ueditor/ActionEnter.java
  10. 17 2
      zd-modules/zd-base/src/main/java/com/zd/base/files/ueditor/ConfigManager.java
  11. 3 3
      zd-modules/zd-base/src/main/java/com/zd/base/files/ueditor/PathFormat.java
  12. 4 4
      zd-modules/zd-base/src/main/java/com/zd/base/files/ueditor/define/BaseState.java
  13. 10 10
      zd-modules/zd-base/src/main/java/com/zd/base/files/ueditor/define/MultiState.java
  14. 4 4
      zd-modules/zd-base/src/main/java/com/zd/base/files/ueditor/hunter/FileManager.java
  15. 59 28
      zd-modules/zd-base/src/main/java/com/zd/base/files/ueditor/upload/StorageManager.java
  16. 0 1
      zd-modules/zd-base/src/main/java/com/zd/base/job/config/ScheduleConfig.java
  17. 1 1
      zd-modules/zd-base/src/main/java/com/zd/base/job/controller/SysJobController.java
  18. 1 1
      zd-modules/zd-base/src/main/java/com/zd/base/job/controller/SysJobLogController.java
  19. 1 1
      zd-modules/zd-base/src/main/java/com/zd/base/job/task/ExamTask.java
  20. 5 5
      zd-modules/zd-base/src/main/java/com/zd/base/job/task/FileViewTask.java
  21. 3 3
      zd-modules/zd-base/src/main/java/com/zd/base/job/task/LabTask.java
  22. 7 3
      zd-modules/zd-base/src/main/java/com/zd/base/job/task/RyTask.java
  23. 23 14
      zd-modules/zd-base/src/main/java/com/zd/base/job/utils/JobInvokeUtil.java
  24. 1 6
      zd-modules/zd-base/src/main/java/com/zd/base/message/controller/WechatMsgController.java
  25. 17 21
      zd-modules/zd-base/src/main/java/com/zd/base/message/service/impl/WechatMsgSendServiceImpl.java
  26. 6 1
      zd-modules/zd-base/src/main/java/com/zd/base/message/utils/SHA1.java

+ 2 - 2
zd-modules/zd-base/src/main/java/com/zd/base/ZdBaseApplicaion.java

@@ -15,8 +15,8 @@ import org.springframework.scheduling.annotation.EnableScheduling;
 @SpringBootApplication
 @EnableScheduling
 @ComponentScan(basePackages = BaseConstants.BASE_PACKAGE)
-public class ZdBaseApplicaion {
+public class ZdBaseApplication {
     public static void main(String[] args) {
-        ZdStartApplication.run(ApplicationConstants.BASE_SERVICE, ZdBaseApplicaion.class, args);
+        ZdStartApplication.run(ApplicationConstants.BASE_SERVICE, ZdBaseApplication.class, args);
     }
 }

+ 2 - 0
zd-modules/zd-base/src/main/java/com/zd/base/app/HexStrUtils.java

@@ -9,6 +9,8 @@ import java.io.ByteArrayOutputStream;
  */
 public class HexStrUtils {
 
+    private HexStrUtils(){}
+
     private static String hexString = "0123456789ABCDEFabcdef";
 
     public static String encode(String str) {

+ 9 - 44
zd-modules/zd-base/src/main/java/com/zd/base/app/controller/LabApi.java

@@ -32,15 +32,9 @@ public class LabApi {
     @ApiOperation(value = "新增随手拍记录")
     @PostMapping("/addPhotoNote")
     public R<Object> addPhotoNote(@RequestBody Map<String, Object> labPhotoNote) {
-
-//        if (StringUtils.isBlank((String) labPhotoNote.get("imgUrls"))) {
-//            return R.fail("图片不能为空");
-//        }
         if (labPhotoNote.get("subjectId") == null) {
             return R.fail("实验室ID不能为空");
         }
-        // describe 随手拍描述
-
         return laboratoryService.addPhotoNote(labPhotoNote);
     }
 
@@ -59,8 +53,7 @@ public class LabApi {
         map.put("appPageNum", pageNum);
         map.put("appPageSize", pageSize);
         map.put("handleStatus", handleStatus);
-        TableDataInfo list = laboratoryService.getAppList(map);
-        return list;
+        return laboratoryService.getAppList(map);
     }
 
     @ApiOperation(value = "获取随手拍记录未处理列表信息(管理端)")
@@ -71,8 +64,7 @@ public class LabApi {
         map.put("appPageNum", pageNum);
         map.put("appPageSize", pageSize);
         map.put("handleStatus", "0");
-        TableDataInfo list = laboratoryService.getAppList(map);
-        return list;
+        return laboratoryService.getAppList(map);
     }
 
     @ApiOperation(value = "查询登录用户是否是实验室管理员(数据权限)")
@@ -120,15 +112,6 @@ public class LabApi {
     @ApiOperation(value = "新增拍照检查附件")
     @PostMapping("/addPhotoInspection")
     public R<Object> addPhotoInspection(@RequestBody Map<String,Object> labPhotoInspection) {
-//        List <LabPhotoInspection> inspecList  = labPhotoInspection.getLabPhotoInspection();
-//        List <Map<String,Object>> labPhotoInspectionList = new ArrayList <>();
-//        for(LabPhotoInspection inspec:inspecList){
-//            Map<String,Object> inspecMap = new HashMap<>();
-//            inspecMap.put("accessId",inspec.getAccessId());
-//            inspecMap.put("annexTitle",inspec.getAnnexTitle());
-//            inspecMap.put("annexUrl",inspec.getAnnexUrl());
-//            labPhotoInspectionList.add(inspecMap);
-//        }
         return laboratoryService.addPhotoInspection(labPhotoInspection);
     }
 
@@ -153,8 +136,7 @@ public class LabApi {
         }
         map.put("appPageNum", pageNum);
         map.put("appPageSize", pageSize);
-        TableDataInfo list = laboratoryService.getApprovalList(map);
-        return list;
+        return laboratoryService.getApprovalList(map);
     }
 
     @ApiOperation(value = "查询违规记录列表 (用户端)")
@@ -165,8 +147,7 @@ public class LabApi {
         map.put("appPageNum", pageNum);
         map.put("appPageSize", pageSize);
         map.put("isHandle", 0);
-        TableDataInfo list = laboratoryService.getViolationList(map);
-        return list;
+        return laboratoryService.getViolationList(map);
     }
 
     @ApiOperation(value = "查询我的违规记录统计(用户端)")
@@ -189,8 +170,7 @@ public class LabApi {
     @ApiOperation(value = "获取当前用户学生卡和人脸信息")
     @GetMapping(value = "/studentinfo/my")
     public R<LabStudentsInfo> getMyCardInfo() {
-        R info = laboratoryService.getMyCardInfo();
-        return info;
+        return laboratoryService.getMyCardInfo();
     }
 
     @ApiOperation(value = "查询安全准入申请实验室列表(用户端)")
@@ -263,8 +243,7 @@ public class LabApi {
         map.put("count", count);
         map.put("groupStatus", groupStatus);
 
-        TableDataInfo list = laboratoryService.getSafeWarnList(map);
-        return list;
+        return laboratoryService.getSafeWarnList(map);
     }
 
     @ApiOperation(value = "查询安全预警统计 (管理端)")
@@ -284,8 +263,7 @@ public class LabApi {
         map.put("typeId", typeId);
         map.put("strStartDate", startDate);
         map.put("strEndDate", endDate);
-        TableDataInfo list = laboratoryService.getSubByRiskPlan(map);
-        return list;
+        return laboratoryService.getSubByRiskPlan(map);
     }
 
     @ApiOperation(value = "查询实验室下的预案详情 (管理端)")
@@ -295,21 +273,8 @@ public class LabApi {
         map.put("appPageNum", 1);
         map.put("appPageSize", 1);
         map.put("id", id);
-        TableDataInfo list = laboratoryService.getSubByRiskPlan(map);
-        return list;
-    }
-
-//    @ApiOperation(value = "获取小程序人脸识别接口")
-//    @GetMapping(value = "/studentinfo/facemy")
-//    public R<LabStudentsInfo> facemy(){
-//        Long userId = SecurityUtils.getUserIdEx();
-//        R <LabStudentsInfo> info = studentsService.getInfo(userId);
-//        if(info.getData()!=null&&info.getData().getFaceFeature()!=null&&info.getData().getFaceFeature().length>1)
-//        {
-//            info.getData().setIfFaceFeature(true);
-//        }
-//        return info;
-//    }
+        return laboratoryService.getSubByRiskPlan(map);
+    }
 
     @ApiOperation(value = "小程序安全检查记录-按时间分组")
     @GetMapping(value = "/listGroupBy")

+ 20 - 31
zd-modules/zd-base/src/main/java/com/zd/base/app/controller/LabBoardApi.java

@@ -176,14 +176,9 @@ public class LabBoardApi {
             //处理人员信息,根据一周的日期分组
             return ResultData.success(groupPersonInfo(allDate,dutyData.getData(),sdf));
         } catch (ParseException e) {
-            e.printStackTrace();
+            logger.error("值班人员列表异常:"+e);
         }
         return ResultData.fail("日期格式有误,请联系管理员!!");
-//        ResultData<List<Map<String, Object>>> dutyData=remoteDutyService.selectDutyUserList(labId,startTime,endTime);
-//        if(null==dutyData || dutyData.getCode()!=HttpStatus.SUCCESS){
-//            return ResultData.fail("值班人员列表获取失败!");
-//        }
-//        return ResultData.success(dutyData.getData());
     }
 
 
@@ -204,14 +199,9 @@ public class LabBoardApi {
             //处理人员信息,根据一周的日期分组
             return ResultData.success(groupPersonInfo(allDate,dutyData.getData(),sdf));
         } catch (ParseException e) {
-            e.printStackTrace();
+            logger.error("巡查人员列表异常:"+e);
         }
         return ResultData.fail("日期格式有误,请联系管理员!!");
-//        ResultData<List<Map<String, Object>>> dutyData=remoteDutyService.selectUserXxpInspectionList(labId,startTime,endTime);
-//        if(null==dutyData || dutyData.getCode()!=HttpStatus.SUCCESS){
-//            return ResultData.fail("值班人员列表获取失败!");
-//        }
-//        return ResultData.success();
     }
 
     @ApiOperation(value = "实验室签到人员")
@@ -241,8 +231,7 @@ public class LabBoardApi {
     @ApiOperation(value = "实验室简介")
     @GetMapping(value = "/labIntro")
     public ResultData labIntro(@RequestParam Long labId) {
-        ResultData resultData= remoteDutyService.getSubjectDetails(labId);
-        return resultData;
+        return remoteDutyService.getSubjectDetails(labId);
     }
 
 
@@ -253,11 +242,10 @@ public class LabBoardApi {
     @GetMapping(value = "/cameraBySubjectId")
     public ResultData getCamera(@RequestParam Long labId) {
         ResultData<String> resultData=remoteDutyService.getCameraBySubjectId(labId);
-        if(null==resultData || resultData.getCode()!=200){
+        if(null==resultData || resultData.getCode()!=HttpStatus.SUCCESS){
             return ResultData.fail("获取摄像头编号失败!");
         }
-        ResultData data=remoteXxpService.selectSubjectCameraList(resultData.getData(),null,1,5000);
-        return data;
+        return remoteXxpService.selectSubjectCameraList(resultData.getData(),null,1,5000);
     }
 
 
@@ -300,7 +288,13 @@ public class LabBoardApi {
     }
 
 
-    //处理分组一周内的人员信息
+    /**
+     * 处理分组一周内的人员信息
+     * @param allDate
+     * @param personList
+     * @param sdf
+     * @return
+     */
     public DutyPersonVo groupPersonInfo(List<Date> allDate,List<Map<String, Object>> personList,SimpleDateFormat sdf){
         StringBuffer startTimeStr = new StringBuffer();
         DutyPersonVo dutyPersonVo = new DutyPersonVo();
@@ -379,7 +373,7 @@ public class LabBoardApi {
         for(int i=0;i<7;i++){
             Calendar   calendar = new GregorianCalendar();
             calendar.setTime(mdate);
-            calendar.add(calendar.DATE,i); //把日期往后增加一天,整数  往后推,负数往前移动
+            calendar.add(Calendar.DATE,i); //把日期往后增加一天,整数  往后推,负数往前移动
             allDate.add(calendar.getTime());//这个时间就是日期往后推一天的结果
         }
         return allDate;
@@ -394,8 +388,7 @@ public class LabBoardApi {
     @ApiOperation(value = "电子信息牌获取准入人员的指纹信息列表")
     @GetMapping(value = "/getFingerList")
     public ResultData getFingerList(@RequestParam("labId") Long labId) {
-        ResultData resultData=remoteDutyService.securityFingerList(labId);
-        return resultData;
+        return remoteDutyService.securityFingerList(labId);
     }
 
 
@@ -414,7 +407,7 @@ public class LabBoardApi {
         cardNum= HexStrUtils.decode(cardNum);
         logger.info("转换后cardNum:"+cardNum);
         ResultData resultData=remoteDutyService.securityNumList(labId,cardNum);
-        if(resultData==null && resultData.getCode()!=HttpStatus.SUCCESS){
+        if(resultData==null || resultData.getCode()!=HttpStatus.SUCCESS){
             return ResultData.fail("未识别到身份信息,请联系管理人员录入卡号信息");
         }
         Object resultObj=resultData.getData();
@@ -440,7 +433,7 @@ public class LabBoardApi {
         cardNum= HexStrUtils.decode(cardNum);
         logger.info("转换后cardNum:"+cardNum);
         ResultData resultData=remoteDutyService.securityNumList(labId,cardNum);
-        if(resultData==null && resultData.getCode()!=HttpStatus.SUCCESS){
+        if(resultData==null || resultData.getCode()!=HttpStatus.SUCCESS){
             return ResultData.fail("未识别到身份信息,请联系管理人员录入卡号信息");
         }
         Object resultObj=resultData.getData();
@@ -459,8 +452,7 @@ public class LabBoardApi {
     @ApiOperation(value = "指纹录入")
     @PostMapping(value = "/addUserFinger")
     public ResultData addUserFinger(@RequestBody XxpUserAuthVo xxpUserAuthVo) {
-        ResultData resultData=remoteDutyService.addUserAuth(xxpUserAuthVo);
-        return resultData;
+        return remoteDutyService.addUserAuth(xxpUserAuthVo);
     }
 
 
@@ -472,8 +464,7 @@ public class LabBoardApi {
     @ApiOperation(value = "根据用户查询指纹列表")
     @GetMapping(value = "/getFingerByUserId")
     public ResultData getFingerByUserId(@RequestParam("labId") Long labId,@RequestParam("userId") Long userId){
-        ResultData resultData=remoteDutyService.getFingerByUserId(labId,userId);
-        return resultData;
+        return remoteDutyService.getFingerByUserId(labId,userId);
     }
 
 
@@ -538,8 +529,7 @@ public class LabBoardApi {
     @ApiOperation(value = "巡查签到")
     @PostMapping(value = "/XxpInspection/addInspection/signIn")
     public ResultData addInspection(@RequestBody XxpInspectionVo xxpInspectionVo){
-        ResultData resultData= remoteDutyService.addInspection(xxpInspectionVo);
-        return resultData;
+        return remoteDutyService.addInspection(xxpInspectionVo);
     }
 
 
@@ -573,8 +563,7 @@ public class LabBoardApi {
     @ApiOperation(value = "Ai检测判断是否已签到")
     @PostMapping(value = "/XxpInspection/isSignInspection")
     public ResultData isSignInspection(@RequestParam("labId") Long labId,@RequestParam("userId") Long userId){
-        ResultData resultData= remoteDutyService.isSignInspection(labId,userId);
-        return resultData;
+        return remoteDutyService.isSignInspection(labId,userId);
     }
 
 }

+ 6 - 3
zd-modules/zd-base/src/main/java/com/zd/base/app/controller/SysUserApi.java

@@ -12,6 +12,8 @@ import com.zd.system.api.vo.SimpleUserVO;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.apache.commons.codec.binary.Base64;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
@@ -30,6 +32,8 @@ import java.util.Map;
 @Api(tags = {"用户相关"})
 public class SysUserApi {
 
+    private final Logger logger = LoggerFactory.getLogger(SysUserApi.class);
+
     @Autowired
     private TokenService tokenService;
 
@@ -51,8 +55,7 @@ public class SysUserApi {
     @ApiOperation(value = "查询当前用户简略信息")
     @GetMapping(value = "/my/simple/info")
     public R<SimpleUserVO> myInfoSimple() {
-        R<SimpleUserVO> simpleUserVOR = remoteUserService.myInfoSimple(SecurityConstants.INNER);
-        return simpleUserVOR;
+        return remoteUserService.myInfoSimple(SecurityConstants.INNER);
     }
 
 
@@ -80,7 +83,7 @@ public class SysUserApi {
             // 抠图工具类 169为灰色
             return R.ok(ImageUtils.transparent(file.getInputStream(), 152));
         } catch (Exception e) {
-            e.printStackTrace();
+            logger.error("小程序端电子签名抠图生成图片异常:"+e);
         }
         return R.fail("生成失败!");
 

+ 14 - 6
zd-modules/zd-base/src/main/java/com/zd/base/files/bigupload/utils/FileUtils.java

@@ -1,19 +1,29 @@
 package com.zd.base.files.bigupload.utils;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import java.io.File;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 
 public class FileUtils {
+
+    private static final Logger logger = LoggerFactory.getLogger(FileUtils.class);
+
+    private FileUtils(){}
+
     //删除文件夹
     public static void delFolder(String folderPath) {
         try {
-            delAllFile(folderPath); //删除完里面所有内容
+            //删除完里面所有内容
+            delAllFile(folderPath);
             String filePath = folderPath;
             File myFilePath = new File(filePath);
-            myFilePath.delete(); //删除空文件夹
+            //删除空文件夹
+            myFilePath.delete();
         } catch (Exception e) {
-            e.printStackTrace();
+            logger.error("删除文件夹异常:"+e);
         }
     }
 
@@ -55,10 +65,8 @@ public class FileUtils {
      */
     public static String getFormatter() {
         Date d = new Date();
-        System.out.println(d);
         SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHH");
-        String dateNowStr = sdf.format(d);
-        return dateNowStr;
+        return sdf.format(d);
     }
 
 }

+ 1 - 9
zd-modules/zd-base/src/main/java/com/zd/base/files/file/service/LocalSysFileServiceImpl.java

@@ -31,15 +31,7 @@ public class LocalSysFileServiceImpl implements ISysFileService {
     @Override
     public String uploadFile(MultipartFile file, Boolean ifAsy) throws Exception {
         String name = FileUploadUtils.upload(ResourcesConfig.filePath, file, ifAsy);
-        //TODO 去掉拼接前缀
-//        String urlPrefix = domain;
-//        String localIP = "127.0.0.1";
-//        if (urlPrefix.contains(localIP)) {
-//            String ip = InetAddress.getLocalHost().getHostAddress();;
-//            urlPrefix = urlPrefix.replace(localIP, ip);
-//        }
-        String url =ResourcesConfig.filePrefix + name;
-        return url;
+        return ResourcesConfig.filePrefix + name;
     }
 
     @Override

+ 7 - 42
zd-modules/zd-base/src/main/java/com/zd/base/files/file/utils/FileUploadUtils.java

@@ -24,10 +24,13 @@ import java.io.IOException;
  */
 @Slf4j
 public class FileUploadUtils {
+
+    private FileUploadUtils(){}
+
     /**
      * 默认大小 50M
      */
-    public static final long DEFAULT_MAX_SIZE = 3000000 * 1024 * 1024;
+    public static final long DEFAULT_MAX_SIZE = 3000000L * 1024L * 1024L;
 
     /**
      * 默认的文件名最大长度 100
@@ -63,11 +66,9 @@ public class FileUploadUtils {
      * @throws InvalidExtensionException            文件校验异常
      */
     public static final String upload(String baseDir, MultipartFile file, String[] allowedExtension, Boolean ifAsy)
-            throws FileSizeLimitExceededException, IOException, FileNameLengthLimitExceededException,
-            InvalidExtensionException {
+            throws IOException, InvalidExtensionException {
         int fileNamelength = file.getOriginalFilename().length();
         if (fileNamelength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH) {
-//            throw new FileNameLengthLimitExceededException(FileUploadUtils.DEFAULT_FILE_NAME_LENGTH);
             throw new ServiceException("图片名字太长,请修改名字后,从新上传!");
         }
 
@@ -88,7 +89,6 @@ public class FileUploadUtils {
                         log.info("文件异步上传成功:" + fileName);
                         log.info("文件成功上传时间:" + DateUtils.getTime());
                     } catch (IOException e) {
-                        e.printStackTrace();
                         log.error("文件异步上传出现异常:" + e.getMessage());
                     }
                 }
@@ -111,7 +111,6 @@ public class FileUploadUtils {
         if (length > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH) {
             throw new ServiceException("文件名过长,请修改后再次上传");
         }
-        //assertAllowed(file, allowedExtension);
         String fileName = extractFilename(file);
         String path = getPathFileName(fileName);
         //发布要上传的文件信息
@@ -132,37 +131,6 @@ public class FileUploadUtils {
         File desc = getAbsoluteFile(fileInfo.getBaseDir(), fileInfo.getFileName());
         fileInfo.getFile().transferTo(desc);
     }
-//
-//    /**
-//     * 文件上传 -不修改文件名
-//     *
-//     * @param baseDir          相对应用的基目录
-//     * @param file             上传的文件
-//     * @param allowedExtension 上传文件类型
-//     * @return 返回上传成功的文件名
-//     * @throws FileSizeLimitExceededException       如果超出最大大小
-//     * @throws FileNameLengthLimitExceededException 文件名太长
-//     * @throws IOException                          比如读写文件出错时
-//     * @throws InvalidExtensionException            文件校验异常
-//     */
-//    public static final String uploadNoUpdateName(String baseDir, MultipartFile file, String[] allowedExtension)
-//            throws FileSizeLimitExceededException, IOException, FileNameLengthLimitExceededException,
-//            InvalidExtensionException {
-//        int fileNamelength = file.getOriginalFilename().length();
-//        if (fileNamelength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH) {
-//            throw new FileNameLengthLimitExceededException(FileUploadUtils.DEFAULT_FILE_NAME_LENGTH);
-//        }
-//
-//        assertAllowed(file, allowedExtension);
-//
-////        String fileName = extractFilename(file);
-//
-//        String originalFilename = file.getOriginalFilename();
-//        File desc = getAbsoluteFile(baseDir, originalFilename);
-//        file.transferTo(desc);
-//        String pathFileName = getPathFileName(originalFilename);
-//        return pathFileName;
-//    }
 
     /**
      * 编码文件名
@@ -173,17 +141,14 @@ public class FileUploadUtils {
 
     private static final File getAbsoluteFile(String uploadDir, String fileName){
         File desc = new File(uploadDir + File.separator + fileName);
-        if (!desc.exists()) {
-            if (!desc.getParentFile().exists()) {
+            if (!desc.exists() && !desc.getParentFile().exists()) {
                 desc.getParentFile().mkdirs();
             }
-        }
         return desc.isAbsolute() ? desc : desc.getAbsoluteFile();
     }
 
     private static final String getPathFileName(String fileName){
-        String pathFileName = "/" + fileName;
-        return pathFileName;
+        return "/" + fileName;
     }
 
     /**

+ 3 - 11
zd-modules/zd-base/src/main/java/com/zd/base/files/ueditor/ActionEnter.java

@@ -80,21 +80,13 @@ public class ActionEnter {
                 state = new FileManager(conf).listFile(start);
                 break;
             }
+            default:
+                break;
         }
-        return state.toJSONString();
+        return state!=null? state.toJSONString():null;
     }
 
     public static String getIpUrl(String localIP, String urlPrefix, String localFilePrefix) {
-//        if (urlPrefix.contains(localIP)) {
-//            String ip= null;
-//            try {
-//                ip = InetAddress.getLocalHost().getHostAddress();
-//            } catch (UnknownHostException e) {
-//                ip="";
-//                e.printStackTrace();
-//            }
-//            urlPrefix = urlPrefix.replace(localIP, ip);
-//        }
         return localFilePrefix;
     }
 

+ 17 - 2
zd-modules/zd-base/src/main/java/com/zd/base/files/ueditor/ConfigManager.java

@@ -2,14 +2,18 @@ package com.zd.base.files.ueditor;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.core.io.ClassPathResource;
 
 import java.io.*;
+import java.nio.charset.StandardCharsets;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.stream.Collectors;
 
 public class ConfigManager {
+    private final Logger logger = LoggerFactory.getLogger(ConfigManager.class);
     private String localPath;
     private JSONObject jsonConfig;
 
@@ -111,15 +115,26 @@ public class ConfigManager {
 
     private String readFile(String path) throws IOException {
         StringBuilder builder = new StringBuilder();
+        InputStreamReader reader =null;
+        BufferedReader bfReader =null;
         try {
-            InputStreamReader reader = new InputStreamReader(new FileInputStream(path), "UTF-8");
-            BufferedReader bfReader = new BufferedReader(reader);
+            reader = new InputStreamReader(new FileInputStream(path), StandardCharsets.UTF_8);
+            bfReader = new BufferedReader(reader);
             String tmpContent ;
             while ((tmpContent = bfReader.readLine()) != null) {
                 builder.append(tmpContent);
             }
             bfReader.close();
+            reader.close();
         } catch (UnsupportedEncodingException ex) {
+            logger.error("readFileÒì³££º"+ex);
+        }finally {
+            if(reader!=null){
+                reader.close();
+            }
+            if(bfReader!=null){
+                bfReader.close();
+            }
         }
         return this.filter(builder.toString());
     }

+ 3 - 3
zd-modules/zd-base/src/main/java/com/zd/base/files/ueditor/PathFormat.java

@@ -6,6 +6,9 @@ import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 public class PathFormat {
+
+    private PathFormat(){}
+
     private static String TIME = "time";
     private static String FULL_YEAR = "yyyy";
     private static String YEAR = "yy";
@@ -126,7 +129,4 @@ public class PathFormat {
         length = Integer.parseInt(pattern);
         return new StringBuilder(String.valueOf(Math.random())).toString().replace(".", "").substring(0, length);
     }
-
-    public static void main(String[] args) {
-    }
 }

+ 4 - 4
zd-modules/zd-base/src/main/java/com/zd/base/files/ueditor/define/BaseState.java

@@ -14,21 +14,21 @@ public class BaseState implements State {
     public BaseState() {
         this.state = false;
         this.info = null;
-        this.infoMap = new HashMap<String, String>();
+        this.infoMap = new HashMap<>();
         this.state = true;
     }
 
     public BaseState(final boolean state) {
         this.state = false;
         this.info = null;
-        this.infoMap = new HashMap<String, String>();
+        this.infoMap = new HashMap<>();
         this.setState(state);
     }
 
     public BaseState(final boolean state, final String info) {
         this.state = false;
         this.info = null;
-        this.infoMap = new HashMap<String, String>();
+        this.infoMap = new HashMap<>();
         this.setState(state);
         this.info = info;
     }
@@ -36,7 +36,7 @@ public class BaseState implements State {
     public BaseState(final boolean state, final int infoCode) {
         this.state = false;
         this.info = null;
-        this.infoMap = new HashMap<String, String>();
+        this.infoMap = new HashMap<>();
         this.setState(state);
         this.info = AppInfo.getStateInfo(infoCode);
     }

+ 10 - 10
zd-modules/zd-base/src/main/java/com/zd/base/files/ueditor/define/MultiState.java

@@ -14,18 +14,18 @@ public class MultiState implements State {
     public MultiState(final boolean state) {
         this.state = false;
         this.info = null;
-        this.intMap = new HashMap<String, Long>();
-        this.infoMap = new HashMap<String, String>();
-        this.stateList = new ArrayList<String>();
+        this.intMap = new HashMap<>();
+        this.infoMap = new HashMap<>();
+        this.stateList = new ArrayList<>();
         this.state = state;
     }
 
     public MultiState(final boolean state, final String info) {
         this.state = false;
         this.info = null;
-        this.intMap = new HashMap<String, Long>();
-        this.infoMap = new HashMap<String, String>();
-        this.stateList = new ArrayList<String>();
+        this.intMap = new HashMap<>();
+        this.infoMap = new HashMap<>();
+        this.stateList = new ArrayList<>();
         this.state = state;
         this.info = info;
     }
@@ -33,9 +33,9 @@ public class MultiState implements State {
     public MultiState(final boolean state, final int infoKey) {
         this.state = false;
         this.info = null;
-        this.intMap = new HashMap<String, Long>();
-        this.infoMap = new HashMap<String, String>();
-        this.stateList = new ArrayList<String>();
+        this.intMap = new HashMap<>();
+        this.infoMap = new HashMap<>();
+        this.stateList = new ArrayList<>();
         this.state = state;
         this.info = AppInfo.getStateInfo(infoKey);
     }
@@ -74,7 +74,7 @@ public class MultiState implements State {
         while (iterator.hasNext()) {
             builder.append(String.valueOf(iterator.next()) + ",");
         }
-        if (this.stateList.size() > 0) {
+        if (this.stateList!=null && !this.stateList.isEmpty()) {
             builder.deleteCharAt(builder.length() - 1);
         }
         builder.append(" ]}");

+ 4 - 4
zd-modules/zd-base/src/main/java/com/zd/base/files/ueditor/hunter/FileManager.java

@@ -34,15 +34,15 @@ public class FileManager {
     }
 
     public State listFile(int index) {
-        File dir = new File(this.dir);
+        File filedir = new File(this.dir);
         State state = null;
-        if (!dir.exists()) {
+        if (!filedir.exists()) {
             return new BaseState(false, 302);
         }
-        if (!dir.isDirectory()) {
+        if (!filedir.isDirectory()) {
             return new BaseState(false, 301);
         }
-        Collection<File> list = (Collection<File>) FileUtils.listFiles(dir, this.allowFiles, true);
+        Collection<File> list = (Collection<File>) FileUtils.listFiles(filedir, this.allowFiles, true);
         if (index < 0 || index > list.size()) {
             state = new MultiState(true);
         } else {

+ 59 - 28
zd-modules/zd-base/src/main/java/com/zd/base/files/ueditor/upload/StorageManager.java

@@ -3,27 +3,41 @@ package com.zd.base.files.ueditor.upload;
 import com.zd.base.files.ueditor.define.BaseState;
 import com.zd.base.files.ueditor.define.State;
 import org.apache.commons.io.FileUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.io.*;
 
-public class StorageManager
-{
+public class StorageManager {
+    private static final Logger logger = LoggerFactory.getLogger(StorageManager.class);
+
+    private StorageManager() {
+    }
+
     public static final int BUFFER_SIZE = 8192;
 
-    public static State saveBinaryFile( byte[] data,  String path) {
-         File file = new File(path);
+    public static State saveBinaryFile(byte[] data, String path) {
+        File file = new File(path);
         State state = valid(file);
         if (!state.isSuccess()) {
             return state;
         }
+        BufferedOutputStream bos = null;
         try {
-             BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file));
+            bos = new BufferedOutputStream(new FileOutputStream(file));
             bos.write(data);
             bos.flush();
             bos.close();
-        }
-        catch (IOException ioe) {
+        } catch (IOException ioe) {
             return new BaseState(false, 4);
+        } finally {
+            if (bos != null) {
+                try {
+                    bos.close();
+                } catch (IOException e) {
+                    logger.error("saveBinaryFileÒì³££º"+e);
+                }
+            }
         }
         state = new BaseState(true, file.getAbsolutePath());
         state.putInfo("size", data.length);
@@ -31,13 +45,15 @@ public class StorageManager
         return state;
     }
 
-    public static State saveFileByInputStream( InputStream is,  String path,  long maxSize) {
+    public static State saveFileByInputStream(InputStream is, String path, long maxSize) {
         State state = null;
-         File tmpFile = getTmpFile();
-         byte[] dataBuf = new byte[2048];
-         BufferedInputStream bis = new BufferedInputStream(is, 8192);
+        File tmpFile = getTmpFile();
+        byte[] dataBuf = new byte[2048];
+        BufferedInputStream bis = null;
+        BufferedOutputStream bos = null;
         try {
-             BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(tmpFile), 8192);
+            bis = new BufferedInputStream(is, BUFFER_SIZE);
+            bos = new BufferedOutputStream(new FileOutputStream(tmpFile), BUFFER_SIZE);
             int count = 0;
             while ((count = bis.read(dataBuf)) != -1) {
                 bos.write(dataBuf, 0, count);
@@ -53,19 +69,28 @@ public class StorageManager
                 tmpFile.delete();
             }
             return state;
-        }
-        catch (IOException ex) {
+        } catch (IOException ex) {
             return new BaseState(false, 4);
+        } finally {
+            if (bos != null) {
+                try {
+                    bos.close();
+                } catch (IOException e) {
+                    logger.error("saveFileByInputStreamÒì³££º"+e);
+                }
+            }
         }
     }
 
-    public static State saveFileByInputStream( InputStream is,  String path) {
+    public static State saveFileByInputStream(InputStream is, String path) {
         State state = null;
-         File tmpFile = getTmpFile();
-         byte[] dataBuf = new byte[2048];
-         BufferedInputStream bis = new BufferedInputStream(is, 8192);
+        File tmpFile = getTmpFile();
+        byte[] dataBuf = new byte[2048];
+        BufferedInputStream bis = null;
+        BufferedOutputStream bos = null;
         try {
-             BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(tmpFile), 8192);
+            bis = new BufferedInputStream(is, BUFFER_SIZE);
+            bos = new BufferedOutputStream(new FileOutputStream(tmpFile), BUFFER_SIZE);
             int count = 0;
             while ((count = bis.read(dataBuf)) != -1) {
                 bos.write(dataBuf, 0, count);
@@ -77,28 +102,34 @@ public class StorageManager
                 tmpFile.delete();
             }
             return state;
-        }
-        catch (IOException ex) {
+        } catch (IOException ex) {
             return new BaseState(false, 4);
+        } finally {
+            if (bos != null) {
+                try {
+                    bos.close();
+                } catch (IOException e) {
+                    logger.error("saveFileByInputStreamÒì³££º"+e);
+                }
+            }
         }
     }
 
     private static File getTmpFile() {
-         File tmpDir = FileUtils.getTempDirectory();
-         String tmpFileName = new StringBuilder(String.valueOf(Math.random() * 10000.0)).toString().replace(".", "");
+        File tmpDir = FileUtils.getTempDirectory();
+        String tmpFileName = new StringBuilder(String.valueOf(Math.random() * 10000.0)).toString().replace(".", "");
         return new File(tmpDir, tmpFileName);
     }
 
-    private static State saveTmpFile( File tmpFile,  String path) {
+    private static State saveTmpFile(File tmpFile, String path) {
         State state = null;
-         File targetFile = new File(path);
+        File targetFile = new File(path);
         if (targetFile.canWrite()) {
             return new BaseState(false, 2);
         }
         try {
             FileUtils.moveFile(tmpFile, targetFile);
-        }
-        catch (IOException e) {
+        } catch (IOException e) {
             return new BaseState(false, 4);
         }
         state = new BaseState(true);
@@ -107,7 +138,7 @@ public class StorageManager
         return state;
     }
 
-    private static State valid( File file) {
+    private static State valid(File file) {
         File parentPath = file.getParentFile();
         if (!parentPath.exists() && !parentPath.mkdirs()) {
             return new BaseState(false, 3);

+ 0 - 1
zd-modules/zd-base/src/main/java/com/zd/base/job/config/ScheduleConfig.java

@@ -36,7 +36,6 @@ public class ScheduleConfig {
         prop.put("org.quartz.jobStore.txIsolationLevelSerializable", "true");
 
         // sqlserver 启用
-        // prop.put("org.quartz.jobStore.selectWithLockSQL", "SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?");
         prop.put("org.quartz.jobStore.misfireThreshold", "12000");
         prop.put("org.quartz.jobStore.tablePrefix", "QRTZ_");
         factory.setQuartzProperties(prop);

+ 1 - 1
zd-modules/zd-base/src/main/java/com/zd/base/job/controller/SysJobController.java

@@ -53,7 +53,7 @@ public class SysJobController extends BaseController {
     @PostMapping("/export")
     public void export(HttpServletResponse response, SysJob sysJob) throws IOException {
         List<SysJob> list = jobService.selectJobList(sysJob);
-        ExcelUtil<SysJob> util = new ExcelUtil<SysJob>(SysJob.class);
+        ExcelUtil<SysJob> util = new ExcelUtil<>(SysJob.class);
         util.exportExcel(response, list, "定时任务");
     }
 

+ 1 - 1
zd-modules/zd-base/src/main/java/com/zd/base/job/controller/SysJobLogController.java

@@ -47,7 +47,7 @@ public class SysJobLogController extends BaseController {
     @PostMapping("/export")
     public void export(HttpServletResponse response, SysJobLog sysJobLog) throws IOException {
         List<SysJobLog> list = jobLogService.selectJobLogList(sysJobLog);
-        ExcelUtil<SysJobLog> util = new ExcelUtil<SysJobLog>(SysJobLog.class);
+        ExcelUtil<SysJobLog> util = new ExcelUtil<>(SysJobLog.class);
         util.exportExcel(response, list, "调度日志");
     }
 

+ 1 - 1
zd-modules/zd-base/src/main/java/com/zd/base/job/task/ExamTask.java

@@ -34,7 +34,7 @@ public class ExamTask {
         Map map = new HashMap();
         R r = remoteExamService.getBonusPointsConfig(map);
         List <Map<String,Object>> list = (List<Map<String,Object>>) r.getData();
-        if(list.size()>0){
+        if(list!=null && !list.isEmpty()){
             Map<String,Object> noViolation = list.get(0);
             Integer monthNoviolationScore= Integer.parseInt(noViolation.get("monthNoviolationScore")+"");
             if(monthNoviolationScore!=null){

+ 5 - 5
zd-modules/zd-base/src/main/java/com/zd/base/job/task/FileViewTask.java

@@ -43,7 +43,7 @@ public class FileViewTask {
         try {
             url = new URI("http://127.0.0.1:8012");
         } catch (URISyntaxException e) {
-            e.printStackTrace();
+            logger.error("URI异常:"+e);
         }
     }
 
@@ -62,11 +62,11 @@ public class FileViewTask {
         for(ElResources resources:resourcesList){
             resources.setPath("http://192.168.251.2/labSystem/"+resources.getPath());
         }
-        if(null!=resourcesList && resourcesList.size()>0){
+        if(resourcesList!=null && !resourcesList.isEmpty()){
             logger.info("resourcesList.size()***********"+resourcesList.size()+"***********");
         }
         // 初始化计时器
-        CountDownLatch cdl = new CountDownLatch(resourcesList.size());
+        CountDownLatch cdl = new CountDownLatch(!resourcesList.isEmpty()?resourcesList.size():5);
         for (ElResources resources : resourcesList) {
             executor.submit(new Runnable() {
                 @Override
@@ -75,7 +75,6 @@ public class FileViewTask {
                         logger.info("ThreadName"+Thread.currentThread().getName()+"resourcesId:"+resources.getId());
                         getKkFileAsync(resources.getPath());
                     }catch (Exception e){
-                        e.printStackTrace();
                         logger.info("error msg:"+e.getMessage());
                     }
                     // 闭锁-1
@@ -86,7 +85,8 @@ public class FileViewTask {
         try {
             cdl.await();
         } catch (InterruptedException e) {
-            e.printStackTrace();
+            logger.error(e.getMessage());
+            Thread.currentThread().interrupt();
         }
         //关闭线程池
         executor.awaitTermination(5, TimeUnit.SECONDS);

+ 3 - 3
zd-modules/zd-base/src/main/java/com/zd/base/job/task/LabTask.java

@@ -35,21 +35,21 @@ public class LabTask {
      */
     public void workOverdue(){
         remoteLaboratoryService.workOverdue();
-    };
+    }
 
     /**
      * 定时任务 下午7点 天管控工作执行通知
      */
     public void workExecuteByDay(){
         remoteLaboratoryService.workExecuteByDay();
-    };
+    }
 
     /**
      * 定时任务 早8点 其他管控工作执行通知
      */
     public void workExecute(){
         remoteLaboratoryService.workExecute();
-    };
+    }
 
     /**
      * 定时器定时查询预案向一体机推送的消息,如果超过两小时,需要清理

+ 7 - 3
zd-modules/zd-base/src/main/java/com/zd/base/job/task/RyTask.java

@@ -3,6 +3,8 @@ package com.zd.base.job.task;
 import com.zd.base.job.domain.SysJob;
 import com.zd.base.job.service.ISysJobService;
 import com.zd.common.core.utils.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
@@ -13,20 +15,22 @@ import org.springframework.stereotype.Component;
  */
 @Component("ryTask")
 public class RyTask {
+    private final Logger logger = LoggerFactory.getLogger(RyTask.class);
+
     @Autowired
     private ISysJobService jobService;
 
     public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) {
-        System.out.println(StringUtils.format("执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}", s, b, l, d, i));
+        logger.info(StringUtils.format("执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}", s, b, l, d, i));
     }
 
     public void ryParams(String params) {
         SysJob job = new SysJob();
         jobService.selectJobList(job);
-        System.out.println("执行有参方法:" + params);
+        logger.info("执行有参方法:" + params);
     }
 
     public void ryNoParams() {
-        System.out.println("执行无参方法");
+        logger.info("执行无参方法");
     }
 }

+ 23 - 14
zd-modules/zd-base/src/main/java/com/zd/base/job/utils/JobInvokeUtil.java

@@ -3,6 +3,8 @@ package com.zd.base.job.utils;
 import com.zd.base.job.domain.SysJob;
 import com.zd.common.core.utils.SpringUtils;
 import com.zd.common.core.utils.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
@@ -15,24 +17,31 @@ import java.util.List;
  * @author zd
  */
 public class JobInvokeUtil {
+
+    private static Logger logger = LoggerFactory.getLogger(JobInvokeUtil.class);
     /**
      * 执行方法
      *
      * @param sysJob 系统任务
      */
-    public static void invokeMethod(SysJob sysJob) throws Exception {
-        String invokeTarget = sysJob.getInvokeTarget();
-        String beanName = getBeanName(invokeTarget);
-        String methodName = getMethodName(invokeTarget);
-        List<Object[]> methodParams = getMethodParams(invokeTarget);
+    public static void invokeMethod(SysJob sysJob)  {
+        try {
+            String invokeTarget = sysJob.getInvokeTarget();
+            String beanName = getBeanName(invokeTarget);
+            String methodName = getMethodName(invokeTarget);
+            List<Object[]> methodParams = getMethodParams(invokeTarget);
 
-        if (!isValidClassName(beanName)) {
-            Object bean = SpringUtils.getBean(beanName);
-            invokeMethod(bean, methodName, methodParams);
-        } else {
-            Object bean = Class.forName(beanName).newInstance();
-            invokeMethod(bean, methodName, methodParams);
+            if (!isValidClassName(beanName)) {
+                Object bean = SpringUtils.getBean(beanName);
+                invokeMethod(bean, methodName, methodParams);
+            } else {
+                Object bean = Class.forName(beanName).newInstance();
+                invokeMethod(bean, methodName, methodParams);
+            }
+        }catch (Exception e){
+            logger.error("系统任务异常:"+e);
         }
+
     }
 
     /**
@@ -45,7 +54,7 @@ public class JobInvokeUtil {
     private static void invokeMethod(Object bean, String methodName, List<Object[]> methodParams)
             throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException,
             InvocationTargetException {
-        if (StringUtils.isNotNull(methodParams) && methodParams.size() > 0) {
+        if (StringUtils.isNotNull(methodParams) && !methodParams.isEmpty()) {
             Method method = bean.getClass().getDeclaredMethod(methodName, getMethodParamsType(methodParams));
             method.invoke(bean, getMethodParamsValue(methodParams));
         } else {
@@ -95,7 +104,7 @@ public class JobInvokeUtil {
     public static List<Object[]> getMethodParams(String invokeTarget) {
         String methodStr = StringUtils.substringBetween(invokeTarget, "(", ")");
         if (StringUtils.isEmpty(methodStr)) {
-            return null;
+            return new LinkedList<>();
         }
         String[] methodParams = methodStr.split(",");
         List<Object[]> classs = new LinkedList<>();
@@ -151,7 +160,7 @@ public class JobInvokeUtil {
         Object[] classs = new Object[methodParams.size()];
         int index = 0;
         for (Object[] os : methodParams) {
-            classs[index] = (Object) os[0];
+            classs[index] = os[0];
             index++;
         }
         return classs;

+ 1 - 6
zd-modules/zd-base/src/main/java/com/zd/base/message/controller/WechatMsgController.java

@@ -2,7 +2,6 @@ package com.zd.base.message.controller;
 
 import com.zd.base.message.service.IWechatMsgSendService;
 import com.zd.common.core.template.TemplateResult;
-import com.zd.common.core.utils.StringUtils;
 import com.zd.model.domain.R;
 import com.zd.model.domain.ResultData;
 import io.swagger.annotations.Api;
@@ -140,10 +139,6 @@ public class WechatMsgController {
     @ApiOperation(value = "获取UrlScheme")
     @ApiImplicitParam(name = "id",value = "传入id",required = false)
     public ResultData getUrlScheme(@RequestParam(value = "id",required = false)  Long id) {
-        String urlScheme = sendService.getUrlScheme(id);
-        if(StringUtils.isNotBlank(urlScheme)){
-            return ResultData.success(urlScheme);
-        }
-        return ResultData.fail();
+        return ResultData.success(sendService.getUrlScheme(id));
     }
 }

+ 17 - 21
zd-modules/zd-base/src/main/java/com/zd/base/message/service/impl/WechatMsgSendServiceImpl.java

@@ -14,6 +14,8 @@ import com.zd.common.core.template.TemplateResult;
 import com.zd.common.core.template.WxUserInfo;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.BoundValueOperations;
 import org.springframework.data.redis.core.RedisTemplate;
@@ -30,6 +32,7 @@ import java.util.concurrent.TimeUnit;
 @Slf4j
 @Service
 public class WechatMsgSendServiceImpl implements IWechatMsgSendService {
+    private static final Logger logger = LoggerFactory.getLogger(WechatMsgSendServiceImpl.class);
 
     @Resource(name = "redisTemplate")
     protected RedisTemplate<String, String> redisTemplate;
@@ -277,7 +280,7 @@ public class WechatMsgSendServiceImpl implements IWechatMsgSendService {
             }
             accessToken = ops.get();
         } catch (Exception e) {
-            e.printStackTrace();
+            logger.error("getAccessToken异常:"+e);
         }
         return accessToken;
     }
@@ -286,34 +289,27 @@ public class WechatMsgSendServiceImpl implements IWechatMsgSendService {
      * @Param [id]
      * @Return java.lang.String
      **/
+    @Override
     public String getUrlScheme(Long id) {
         String accessToken = getAccessToken();
-        if (StringUtils.isBlank(accessToken)) {
-            log.error("获取token失败!accessToken = {}", accessToken);
-            return "";
-        }
-        String url = weChatProperties.getUrlScheme() + accessToken;
+        log.info("获取的token = {}",accessToken);
+        String url = weChatProperties.getUrlScheme()+accessToken;
         JSONObject body = new JSONObject();
         JSONObject jumpWxa = new JSONObject();
-        jumpWxa.put("path", "/pages/earlyWarningManage/earlyWarningDetail");
-        jumpWxa.put("query", "id=" + id);
+        jumpWxa.put("path","/pages/earlyWarningManage/earlyWarningDetail");
+        jumpWxa.put("query","id="+id);
         body.put("jump_wxa", jumpWxa);
         body.put("expire_type", "1");
         body.put("expire_interval", "30");
-        log.info("获取UrlScheme url===>>>{}", url);
-        log.info("请求参数===>>>{}", JSON.toJSONString(body));
-        try {
-            String respData = HttpUtil.post(url, JSON.toJSONString(body));
-            log.info("UrlScheme 返回参数===>>>{}", respData);
-            JSONObject json = JSON.parseObject(respData);
-            if (json.getInteger("errcode") == 0) {
-                String openlink = json.getString("openlink");
-                return openlink;
-            }
-        } catch (Exception e) {
-            log.error("获取UrlScheme异常!==>>{}",e);
-            return "";
+        log.info("获取UrlScheme url===>>>{}",url);
+        log.info("请求参数===>>>{}",JSON.toJSONString(body));
+        String respData = HttpUtil.post(url,JSON.toJSONString(body));
+        log.info("UrlScheme 返回参数===>>>{}", respData);
+        JSONObject json = JSON.parseObject(respData);
+        if (json.getInteger("errcode") == 0) {
+            return json.getString("openlink");
         }
+        log.info("生成openlink失败!");
         return "";
     }
 }

+ 6 - 1
zd-modules/zd-base/src/main/java/com/zd/base/message/utils/SHA1.java

@@ -1,10 +1,15 @@
 package com.zd.base.message.utils;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import java.security.MessageDigest;
 import java.util.Arrays;
 
 public class SHA1 {
 
+    private static final Logger logger = LoggerFactory.getLogger(SHA1.class);
+
     private SHA1() {
         throw new IllegalStateException("SHA1 class");
     }
@@ -42,7 +47,7 @@ public class SHA1 {
             }
             return hexstr.toString();
         } catch (Exception e) {
-            e.printStackTrace();
+            logger.error("getSHA1异常:"+e);
             throw new SecurityException(e.getMessage());
         }
     }