|
@@ -1,7 +1,9 @@
|
|
package com.ruoyi.system.service.webService;
|
|
package com.ruoyi.system.service.webService;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
|
+import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
import cn.ljserver.tool.weboffice.v3.exception.FileNotExist;
|
|
import cn.ljserver.tool.weboffice.v3.exception.FileNotExist;
|
|
import com.ruoyi.common.config.RuoYiConfig;
|
|
import com.ruoyi.common.config.RuoYiConfig;
|
|
@@ -9,9 +11,13 @@ import com.ruoyi.common.core.domain.entity.SysUser;
|
|
import com.ruoyi.common.core.redis.RedisCache;
|
|
import com.ruoyi.common.core.redis.RedisCache;
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
|
|
+import com.ruoyi.common.utils.StringUtils;
|
|
import com.ruoyi.common.utils.file.FileUploadUtils;
|
|
import com.ruoyi.common.utils.file.FileUploadUtils;
|
|
|
|
+import com.ruoyi.common.utils.file.FileUtils;
|
|
import com.ruoyi.system.domain.loan.LoanApplicationFj;
|
|
import com.ruoyi.system.domain.loan.LoanApplicationFj;
|
|
import com.ruoyi.system.domain.webOffice.WebofficeFj;
|
|
import com.ruoyi.system.domain.webOffice.WebofficeFj;
|
|
|
|
+import com.ruoyi.system.mapper.LoanApplicationFjMapper;
|
|
|
|
+import com.ruoyi.system.mapper.SysUserMapper;
|
|
import com.ruoyi.system.mapper.WebofficeFjMapper;
|
|
import com.ruoyi.system.mapper.WebofficeFjMapper;
|
|
import lombok.SneakyThrows;
|
|
import lombok.SneakyThrows;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -19,14 +25,16 @@ import org.springframework.mock.web.MockMultipartFile;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* webOffice附件记录Service业务层处理
|
|
* webOffice附件记录Service业务层处理
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @author boman
|
|
* @author boman
|
|
* @date 2024-05-20
|
|
* @date 2024-05-20
|
|
*/
|
|
*/
|
|
@Service
|
|
@Service
|
|
-public class WebofficeFjServiceImpl implements IWebofficeFjService
|
|
|
|
|
|
+public class WebofficeFjServiceImpl implements IWebofficeFjService
|
|
{
|
|
{
|
|
@Autowired
|
|
@Autowired
|
|
private WebofficeFjMapper webofficeFjMapper;
|
|
private WebofficeFjMapper webofficeFjMapper;
|
|
@@ -34,9 +42,15 @@ public class WebofficeFjServiceImpl implements IWebofficeFjService
|
|
@Autowired
|
|
@Autowired
|
|
private RedisCache redisCache;
|
|
private RedisCache redisCache;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private SysUserMapper userMapper;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private LoanApplicationFjMapper loanApplicationFjMapper;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 查询webOffice附件记录
|
|
* 查询webOffice附件记录
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @param webofficeId webOffice附件记录主键
|
|
* @param webofficeId webOffice附件记录主键
|
|
* @return webOffice附件记录
|
|
* @return webOffice附件记录
|
|
*/
|
|
*/
|
|
@@ -48,7 +62,7 @@ public class WebofficeFjServiceImpl implements IWebofficeFjService
|
|
|
|
|
|
/**
|
|
/**
|
|
* 查询webOffice附件记录列表
|
|
* 查询webOffice附件记录列表
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @param webofficeFj webOffice附件记录
|
|
* @param webofficeFj webOffice附件记录
|
|
* @return webOffice附件记录
|
|
* @return webOffice附件记录
|
|
*/
|
|
*/
|
|
@@ -60,7 +74,7 @@ public class WebofficeFjServiceImpl implements IWebofficeFjService
|
|
|
|
|
|
/**
|
|
/**
|
|
* 新增webOffice附件记录
|
|
* 新增webOffice附件记录
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @param webofficeFj webOffice附件记录
|
|
* @param webofficeFj webOffice附件记录
|
|
* @return 结果
|
|
* @return 结果
|
|
*/
|
|
*/
|
|
@@ -73,7 +87,7 @@ public class WebofficeFjServiceImpl implements IWebofficeFjService
|
|
|
|
|
|
/**
|
|
/**
|
|
* 修改webOffice附件记录
|
|
* 修改webOffice附件记录
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @param webofficeFj webOffice附件记录
|
|
* @param webofficeFj webOffice附件记录
|
|
* @return 结果
|
|
* @return 结果
|
|
*/
|
|
*/
|
|
@@ -86,7 +100,7 @@ public class WebofficeFjServiceImpl implements IWebofficeFjService
|
|
|
|
|
|
/**
|
|
/**
|
|
* 批量删除webOffice附件记录
|
|
* 批量删除webOffice附件记录
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @param webofficeIds 需要删除的webOffice附件记录主键
|
|
* @param webofficeIds 需要删除的webOffice附件记录主键
|
|
* @return 结果
|
|
* @return 结果
|
|
*/
|
|
*/
|
|
@@ -98,7 +112,7 @@ public class WebofficeFjServiceImpl implements IWebofficeFjService
|
|
|
|
|
|
/**
|
|
/**
|
|
* 删除webOffice附件记录信息
|
|
* 删除webOffice附件记录信息
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @param webofficeId webOffice附件记录主键
|
|
* @param webofficeId webOffice附件记录主键
|
|
* @return 结果
|
|
* @return 结果
|
|
*/
|
|
*/
|
|
@@ -115,42 +129,89 @@ public class WebofficeFjServiceImpl implements IWebofficeFjService
|
|
|
|
|
|
@SneakyThrows
|
|
@SneakyThrows
|
|
@Override
|
|
@Override
|
|
- public String upload(String fileId, byte[] content, String suffix) {
|
|
|
|
-
|
|
|
|
- SysUser user = SecurityUtils.getLoginUser().getUser();
|
|
|
|
|
|
+ public String upload(String fileId, byte[] content, String suffix, HttpServletRequest request) {
|
|
|
|
+ //SysUser user = SecurityUtils.getLoginUser().getUser();
|
|
//从redis取文件信息
|
|
//从redis取文件信息
|
|
LoanApplicationFj cacheObject = redisCache.getCacheObject(fileId + "info");
|
|
LoanApplicationFj cacheObject = redisCache.getCacheObject(fileId + "info");
|
|
if (cacheObject == null) {
|
|
if (cacheObject == null) {
|
|
throw new FileNotExist();
|
|
throw new FileNotExist();
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ String userId = request.getHeader("X-WPS-USERID");
|
|
|
|
+ if(StringUtils.isEmpty(userId)){
|
|
|
|
+ return "参数错误";
|
|
|
|
+ }
|
|
|
|
+ SysUser user = userMapper.selectUserById(Long.valueOf(userId));
|
|
MultipartFile file = new MockMultipartFile(cacheObject.getName(), cacheObject.getName(), suffix, content);
|
|
MultipartFile file = new MockMultipartFile(cacheObject.getName(), cacheObject.getName(), suffix, content);
|
|
// 上传文件路径
|
|
// 上传文件路径
|
|
String filePath = RuoYiConfig.getUploadPath();
|
|
String filePath = RuoYiConfig.getUploadPath();
|
|
- // 上传并返回新文件名称
|
|
|
|
- String fileName = FileUploadUtils.uploadLoanApplicationNumber(filePath, file, cacheObject.getLoanApplicationNumber(), file.getOriginalFilename());
|
|
|
|
|
|
+ String fileName = redisCache.getCacheObject(fileId + "fileName");
|
|
|
|
+ if(StringUtils.isEmpty(fileName)){
|
|
|
|
+ //已经存在文件,文件名不变
|
|
|
|
+ if(cacheObject.getFjId()!=null && cacheObject.getFjId()!=0L){
|
|
|
|
+ fileName = FileUploadUtils.uploadLoanApplicationNumberOldName(filePath, file, cacheObject.getLoanApplicationNumber(), file.getOriginalFilename());
|
|
|
|
+ }else{
|
|
|
|
+ // 上传并返回新文件名称
|
|
|
|
+ fileName = FileUploadUtils.uploadLoanApplicationNumber(filePath, file, cacheObject.getLoanApplicationNumber(), file.getOriginalFilename());
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ String name = FileUtils.getName(fileName);
|
|
|
|
+ fileName = FileUploadUtils.uploadLoanApplicationNumberOldName(filePath, file, cacheObject.getLoanApplicationNumber(), name);
|
|
|
|
+ }
|
|
|
|
+ redisCache.setCacheObject(fileId + "fileName",fileName,1, TimeUnit.HOURS);
|
|
//String url = serverConfig.getUrl() + fileName;
|
|
//String url = serverConfig.getUrl() + fileName;
|
|
//将文件存入在线编辑预存表
|
|
//将文件存入在线编辑预存表
|
|
- WebofficeFj webofficeFj = fetchFile(fileId);
|
|
|
|
- webofficeFj.setWebofficeId(0l);
|
|
|
|
|
|
+ /*WebofficeFj webofficeFj = new WebofficeFj();
|
|
|
|
+ webofficeFj.setFjId(fileId);
|
|
webofficeFj.setVersion(webofficeFj.getVersion() + 1);
|
|
webofficeFj.setVersion(webofficeFj.getVersion() + 1);
|
|
|
|
+ webofficeFj.setUrl(fileName);
|
|
webofficeFj.setCreateTime(LocalDateTime.now());
|
|
webofficeFj.setCreateTime(LocalDateTime.now());
|
|
webofficeFj.setUpdateTime(LocalDateTime.now());
|
|
webofficeFj.setUpdateTime(LocalDateTime.now());
|
|
- webofficeFj.setSize(Long.valueOf(file.getSize()));
|
|
|
|
|
|
+ webofficeFj.setSize(file.getSize());
|
|
webofficeFj.setName(file.getName());
|
|
webofficeFj.setName(file.getName());
|
|
webofficeFj.setCreateBy(user.getNickName());
|
|
webofficeFj.setCreateBy(user.getNickName());
|
|
|
|
+ webofficeFj.setCreatorId(String.valueOf(user.getUserId()));
|
|
|
|
+ webofficeFj.setModifierId(String.valueOf(user.getUserId()));
|
|
webofficeFjMapper.insertWebofficeFj(webofficeFj);
|
|
webofficeFjMapper.insertWebofficeFj(webofficeFj);
|
|
|
|
+ System.out.println(webofficeFj.toString()+"6666666666666666666666666");
|
|
|
|
+ if(cacheObject.getFjId()==null || cacheObject.getFjId()==0L){
|
|
|
|
+ if(cacheObject.getLoanApplicationId()!=null && cacheObject.getLoanApplicationId()!=0L){
|
|
|
|
+ //将文件存入loan_application_fj表
|
|
|
|
+ LoanApplicationFj loanApplicationFj = new LoanApplicationFj();
|
|
|
|
+ loanApplicationFj.setLoanApplicationId(cacheObject.getLoanApplicationId());
|
|
|
|
+ loanApplicationFj.setLoanApplicationNumber(cacheObject.getLoanApplicationNumber());
|
|
|
|
+ loanApplicationFj.setOldName(cacheObject.getName());
|
|
|
|
+ loanApplicationFj.setName(cacheObject.getName());
|
|
|
|
+ loanApplicationFj.setUrl(fileName);
|
|
|
|
+ loanApplicationFj.setBigType(cacheObject.getBigType());
|
|
|
|
+ loanApplicationFj.setType(cacheObject.getType());
|
|
|
|
+ loanApplicationFj.setCreateBy(user.getNickName());
|
|
|
|
+ loanApplicationFj.setCreateTime(DateUtils.getNowDate());
|
|
|
|
+ loanApplicationFjMapper.insertLoanApplicationFj(loanApplicationFj);
|
|
|
|
+ System.out.println(loanApplicationFj.toString()+"888888888888888888888888888888");
|
|
|
|
+ }
|
|
|
|
+ }*/
|
|
|
|
+
|
|
return fileName;
|
|
return fileName;
|
|
}
|
|
}
|
|
|
|
|
|
public List<WebofficeFj> selectWebofficeFjList(String fileId)
|
|
public List<WebofficeFj> selectWebofficeFjList(String fileId)
|
|
{
|
|
{
|
|
- if(!DateUtils.isNumeric(fileId)){
|
|
|
|
- fileId = "0";
|
|
|
|
- }
|
|
|
|
|
|
+ List<WebofficeFj> webofficeFjList = new ArrayList<>();
|
|
WebofficeFj webofficeFj = new WebofficeFj();
|
|
WebofficeFj webofficeFj = new WebofficeFj();
|
|
- webofficeFj.setFjId(Long.valueOf(fileId));
|
|
|
|
- return webofficeFjMapper.selectWebofficeFjList(webofficeFj);
|
|
|
|
|
|
+ SysUser user = SecurityUtils.getLoginUser().getUser();
|
|
|
|
+ webofficeFj.setFjId(fileId);
|
|
|
|
+ LoanApplicationFj cacheObject = redisCache.getCacheObject(fileId + "info");
|
|
|
|
+ webofficeFj.setName(cacheObject.getName());
|
|
|
|
+ webofficeFj.setSize(102400L);
|
|
|
|
+ webofficeFj.setUpdateTime(LocalDateTime.now());
|
|
|
|
+ webofficeFj.setUpdateTime(LocalDateTime.now());
|
|
|
|
+ webofficeFj.setCreatorId(String.valueOf(user.getUserId()));
|
|
|
|
+ webofficeFj.setModifierId(String.valueOf(user.getUserId()));
|
|
|
|
+ webofficeFjList.add(webofficeFj);
|
|
|
|
+ WebofficeFj weboffice = new WebofficeFj();
|
|
|
|
+ weboffice.setFjId(fileId);
|
|
|
|
+ webofficeFjList = webofficeFjMapper.selectWebofficeFjList(weboffice);
|
|
|
|
+ return webofficeFjList;
|
|
}
|
|
}
|
|
|
|
|
|
/***
|
|
/***
|
|
@@ -164,7 +225,7 @@ public class WebofficeFjServiceImpl implements IWebofficeFjService
|
|
fileId = "0";
|
|
fileId = "0";
|
|
}
|
|
}
|
|
WebofficeFj webofficeFj = new WebofficeFj();
|
|
WebofficeFj webofficeFj = new WebofficeFj();
|
|
- webofficeFj.setFjId(Long.valueOf(fileId));
|
|
|
|
|
|
+ webofficeFj.setFjId(fileId);
|
|
webofficeFj.setVersion(version);
|
|
webofficeFj.setVersion(version);
|
|
List<WebofficeFj> webofficeFjs = webofficeFjMapper.selectWebofficeFjList(webofficeFj);
|
|
List<WebofficeFj> webofficeFjs = webofficeFjMapper.selectWebofficeFjList(webofficeFj);
|
|
if(webofficeFjs!=null && webofficeFjs.size()>0){
|
|
if(webofficeFjs!=null && webofficeFjs.size()>0){
|
|
@@ -182,16 +243,24 @@ public class WebofficeFjServiceImpl implements IWebofficeFjService
|
|
*/
|
|
*/
|
|
public WebofficeFj fetchFile(String fileId)
|
|
public WebofficeFj fetchFile(String fileId)
|
|
{
|
|
{
|
|
- if(!DateUtils.isNumeric(fileId)){
|
|
|
|
- fileId = "0";
|
|
|
|
- }
|
|
|
|
|
|
+ SysUser user = SecurityUtils.getLoginUser().getUser();
|
|
WebofficeFj webofficeFj = new WebofficeFj();
|
|
WebofficeFj webofficeFj = new WebofficeFj();
|
|
- webofficeFj.setFjId(Long.valueOf(fileId));
|
|
|
|
|
|
+ webofficeFj.setFjId(fileId);
|
|
List<WebofficeFj> webofficeFjs = webofficeFjMapper.selectWebofficeFjList(webofficeFj);
|
|
List<WebofficeFj> webofficeFjs = webofficeFjMapper.selectWebofficeFjList(webofficeFj);
|
|
if(webofficeFjs!=null && webofficeFjs.size()>0){
|
|
if(webofficeFjs!=null && webofficeFjs.size()>0){
|
|
return webofficeFjs.get(0);
|
|
return webofficeFjs.get(0);
|
|
}else {
|
|
}else {
|
|
- return new WebofficeFj();
|
|
|
|
|
|
+ //从redis取文件信息
|
|
|
|
+ LoanApplicationFj cacheObject = redisCache.getCacheObject(fileId + "info");
|
|
|
|
+ webofficeFj.setName(cacheObject.getName());
|
|
|
|
+ webofficeFj.setSize(102400L);
|
|
|
|
+ webofficeFj.setVersion(1);
|
|
|
|
+ webofficeFj.setCreateTime(LocalDateTime.now());
|
|
|
|
+ webofficeFj.setUpdateTime(LocalDateTime.now());
|
|
|
|
+ webofficeFj.setCreatorId(String.valueOf(user.getUserId()));
|
|
|
|
+ webofficeFj.setModifierId(String.valueOf(user.getUserId()));
|
|
|
|
+ return webofficeFj;
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|