|
@@ -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);
|
|
|
}
|
|
|
|