6 Commits 282ef4bab0 ... 2c6d49fb66

Author SHA1 Message Date
  leo.xie 2c6d49fb66 fix bug 3 years ago
  leo.xie d7844d8053 fix bug 3 years ago
  leo.xie 50c066b478 fix bug 3 years ago
  leo.xie 9b1136125a fix bug 3 years ago
  leo.xie e3488ca0a7 fix bug 3 years ago
  leo.xie 0e2c2fe5fe fix bug 3 years ago

+ 1 - 1
docker-prod.yaml

@@ -14,7 +14,7 @@ services:
       - "8015:8073"
     networks:
       root_prenet:
-        ipv4_address: 172.29.0.5
+        ipv4_address: 172.29.0.3
 
 networks:
   root_prenet:

+ 52 - 24
src/main/java/com/ads/business/service/impl/DocServiceImpl.java

@@ -197,6 +197,18 @@ public class DocServiceImpl extends ServiceImpl<DocDao, Doc> implements DocServi
             docRoleDao.insertBatch(docRoles);
         }
         if (flag) {
+
+            //不相等,那么删除当前目录的下的文件
+            File imageFile = new File(getImageFilePath(doc.getId()));
+            File pdfFile = new File(getImageFilePath(doc.getId())+".pdf");
+            if(imageFile.exists()){
+                imageFile.delete();
+            }
+            if(pdfFile.exists()){
+                pdfFile.delete();
+            }
+
+
             DocHistory docHistory = new DocHistory();
             BeanUtil.copyProperties(doc, docHistory);
             docHistory.setCreateTime(new Date());
@@ -245,35 +257,29 @@ public class DocServiceImpl extends ServiceImpl<DocDao, Doc> implements DocServi
         return outData;
     }
 
-    @Override
-    public JsonResult pdfDetail(HttpServletRequest request, Long docId, String userNo) {
-        GetLoginOutData userInfo = OnlineUserUtils.get();
-        if (null == userInfo) {
-            return JsonResult.fail("您没有登录");
-        }
+    private Doc auth(Long docId,GetLoginOutData userInfo){
+
         if (StringUtils.isEmpty(userInfo.getMobile())) {
-            return JsonResult.fail(1000, "请重新登录");
+            throw new BusinessException("请重新登录");
         }
-        //水印 姓名+手机号后四位
-        String watermark = userInfo.getName() + userInfo.getMobile().substring(userInfo.getMobile().length() - 5);
         Doc doc = this.baseMapper.selectById(docId);
         if (null == doc) {
             throw new BusinessException("当前文件信息不存在!");
         }
         if (doc.getStatus() == 0) {
-            return JsonResult.fail(1000, "当前文件已禁用,请启用后查看!");
+            throw new BusinessException("当前文件已禁用,请启用后查看!");
         }
         DocType docType = docTypeService.getById(doc.getTypeId());
         if (ObjectUtil.isEmpty(docType)) {
-            return JsonResult.fail("当前文件说在分类信息不存在");
+            throw new BusinessException("当前文件说在分类信息不存在");
         }
         if (docType.getStatus() == 0) {
-            return JsonResult.fail(1000, "当前文件所在分类已禁用,请启用后查看!");
+            throw new BusinessException("当前文件所在分类已禁用,请启用后查看!");
         }
         //userInfo.setMobile("18896995753");
         //userInfo.setMobile("15261532462");
         if (StringUtils.isEmpty(userInfo.getMobile())) {
-            return JsonResult.fail(1000, "请退出重新登录钉钉");
+            throw new BusinessException("请退出重新登录钉钉");
         }
         log.info("获取文件详情信息--校验会话权限");
         List<DocTypeConversationRel> typeList = docTypeConversationRelDao.getListByMobile(docType.getTypeId(),userInfo.getMobile());
@@ -282,11 +288,11 @@ public class DocServiceImpl extends ServiceImpl<DocDao, Doc> implements DocServi
         //手机号不为空,群组为空
         if (CollectionUtil.isNotEmpty(typeRoleMobiles) && CollectionUtil.isEmpty(typeList)) {
             if (!typeRoleMobiles.contains(userInfo.getMobile())) {
-                return JsonResult.fail(1000, "您没有当前文件的查看权限");
+                throw new BusinessException("您没有当前文件的查看权限");
             }
             Boolean res = checkAuthDetail(userInfo, doc);
             if (res) {
-                return JsonResult.fail(1000, "您没有当前文件的查看权限");
+                throw new BusinessException("您没有当前文件的查看权限");
             }
         }
         //手机号不为空,群组不为空
@@ -294,47 +300,67 @@ public class DocServiceImpl extends ServiceImpl<DocDao, Doc> implements DocServi
             List<String> conversationMobiles = docTypeConversationRelService.getListByTypeId(docType.getTypeId());
             conversationMobiles.addAll(typeRoleMobiles);
             if (!conversationMobiles.contains(OnlineUserUtils.get().getMobile())) {
-                return JsonResult.fail(1000, "您没有当前文件的查看权限");
+                throw new BusinessException("您没有当前文件的查看权限");
             }
             Boolean res = checkAuthDetail(userInfo, doc);
             if (res) {
-                return JsonResult.fail(1000, "您没有当前文件的查看权限");
+                throw new BusinessException("您没有当前文件的查看权限");
             }
         }
         //手机号为空,群组不为空
         if (CollectionUtil.isEmpty(typeRoleMobiles) && CollectionUtil.isNotEmpty(typeList)) {
             List<String> conversationMobiles = docTypeConversationRelService.getListByTypeId(docType.getTypeId());
             if (!conversationMobiles.contains(OnlineUserUtils.get().getMobile())) {
-                return JsonResult.fail(1000, "您没有当前文件的查看权限");
+                throw new BusinessException("您没有当前文件的查看权限");
             }
             Boolean res = checkAuthDetail(userInfo, doc);
             if (res) {
-                return JsonResult.fail(1000, "您没有当前文件的查看权限");
+                throw new BusinessException("您没有当前文件的查看权限");
             }
         }
         //手机号为空,群组为空
         if (CollectionUtil.isEmpty(typeRoleMobiles) && CollectionUtil.isEmpty(typeList)) {
             Boolean res = checkAuthDetail(userInfo, doc);
             if (res) {
-                return JsonResult.fail(1000, "您没有当前文件的查看权限");
+                throw new BusinessException("您没有当前文件的查看权限");
             }
         }
         log.info("校验权限结束!");
 
+        return doc;
+    }
+
+    private String getImageFilePath(Long docId){
+        return pictureConfig.getServerBasePath() +"/"+ pictureConfig.getUploadPath() + "/produce/" +  docId;
+    }
+
+    @Override
+    public JsonResult pdfDetail(HttpServletRequest request, Long docId, String userNo) {
+
+        GetLoginOutData userInfo = OnlineUserUtils.get();
+        if (null == userInfo) {
+            return JsonResult.fail("您没有登录");
+        }
+
+        Doc doc = auth(docId,userInfo);
+
+        //水印 姓名+手机号后四位
+        String watermark = "沪上阿姨SOP";
+
         String fileName = doc.getName();
         String docUrl = doc.getDocUrl();
         String domain = pictureConfig.getServerPath();
         String path = domain + request.getContextPath() + "/";
-        String filePath = pictureConfig.getServerBasePath() +"/"+ pictureConfig.getUploadPath() + "/" + userNo + "/" + docId + fileName + ".pdf";
-        String imageFilePath = pictureConfig.getServerBasePath() +"/"+ pictureConfig.getUploadPath() + "/" + userNo + "/" + docId + fileName + File.separator;
-        String createPath = pictureConfig.getBasePath() + "/" + pictureConfig.getUploadPath() + "/" + userNo + "/" + docId + fileName + ".pdf";
+        String filePath = pictureConfig.getServerBasePath() +"/"+ pictureConfig.getUploadPath() + "/produce/" + docId + ".pdf";
+        String imageFilePath = getImageFilePath(docId) + "/";
+        String createPath = pictureConfig.getBasePath() + "/" + pictureConfig.getUploadPath() + "/produce/" + docId + ".pdf";
         File fromFile = new File(createPath);
         //判断目标文件所在的目录是否存在
         if (!fromFile.getParentFile().exists()) {
             //如果目标文件所在的目录不存在,则创建父目录
             fromFile.getParentFile().mkdirs();
         }
-        String pictureFilePath = docUrl.replace(domain+"file",pictureConfig.getBasePath());
+        String pictureFilePath = docUrl.replace(domain+pictureConfig.getServerBasePath(),pictureConfig.getBasePath());
         if(!new File(pictureFilePath).exists()){
             throw new BusinessException("当前图片不存在"+pictureFilePath+"&"+domain+"&"+pictureConfig.getBasePath());
         }
@@ -362,10 +388,12 @@ public class DocServiceImpl extends ServiceImpl<DocDao, Doc> implements DocServi
                 }
             }
         }
+
         PdfDetailResponse rs = new PdfDetailResponse();
         rs.setPath(path + filePath);
         rs.setFileName(fileName);
         rs.setImageFiles(images);
+        rs.setWatermark(userInfo.getName() + userInfo.getMobile().substring(userInfo.getMobile().length() - 5));
         return JsonResult.success(rs, UtilMessage.GET_MESSAGE_SUCCESS);
     }
 

+ 2 - 0
src/main/java/com/ads/business/service/model/response/PdfDetailResponse.java

@@ -21,4 +21,6 @@ public class PdfDetailResponse {
 
     @ApiModelProperty("文件图片列表")
     private LinkedList<String> imageFiles;
+
+    private String watermark;
 }