资料维护调整

This commit is contained in:
zhangqinlin
2021-09-10 11:17:39 +08:00
parent 0508ddf5cd
commit faa7605d4f
2 changed files with 66 additions and 23 deletions
@@ -36,6 +36,7 @@ import io.swagger.annotations.ApiImplicitParams;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.transaction.annotation.Transactional;
@@ -76,6 +77,7 @@ public class PayDataFileController extends JeroController<PayDataFile, IPayDataF
//拼接目录结构
StringBuffer stringBuffer;
@Autowired
private IPayFileDownloadRecordService payFileDownloadRecordService;
@@ -96,7 +98,8 @@ public class PayDataFileController extends JeroController<PayDataFile, IPayDataF
) {
QueryWrapper<QueryFileList2> queryWrapper = QueryGenerator.initQueryWrapper(queryFileList2, req.getParameterMap());
queryWrapper.eq("pd.id",id);
List<String> tree = tree(id, 1);
queryWrapper.in("pd.id",tree);
queryWrapper.eq("pd.type",1);
queryWrapper.orderByDesc("pf.create_time");
Page<PayDataFile> page = new Page<>(pageNo, pageSize);
@@ -133,34 +136,65 @@ public class PayDataFileController extends JeroController<PayDataFile, IPayDataF
}
if (ObjectUtil.isNotEmpty(queryFileListBySearch.getFileName())){
queryWrapper.eq("of.file_name",queryFileListBySearch.getFileName());
queryWrapper.like("of.file_name",queryFileListBySearch.getFileName());
}
if (ObjectUtil.isNotEmpty(queryFileListBySearch.getMeetingName())){
queryWrapper.eq("pm.meeting_name",queryFileListBySearch.getMeetingName());
queryWrapper.like("pm.meeting_name",queryFileListBySearch.getMeetingName());
}
Page<PayDataFile> page = new Page<>(pageNo, pageSize);
queryWrapper.eq("pd.type",2);
queryWrapper.orderByDesc("pf.create_time");
queryWrapper.eq("pd.id",id);
List<String> tree = tree(id, 2);
queryWrapper.in("pd.id",tree);
IPage<QueryFileList> pageList = payDataFileService.pageDataMeeting(page,queryWrapper);
return Result.OK(pageList);
}
//
//public List<String> getAllChildrenId(String id){
// QueryWrapper<PayDataDirectory> queryWrapper = new QueryWrapper();
// List<PayDataDirectory> list = payDataDirectoryService.list(queryWrapper);
// List<DirectoryToTree> collect = list.stream()
// .filter(payDataDirectory -> "0".equals(payDataDirectory.getParentId()))
// .map(payDataDirectory -> {
// DirectoryToTree directoryToTree = transtoTree(id, list);
// return directoryToTree;
// }).sorted(Comparator.comparing(DirectoryToTree::getSort))
// .collect(Collectors.toList());
// return Result.OK(collect);
//
//
//}
public List<String> tree(String id , int dataType) {
LoginUser sysUser =(LoginUser) SecurityUtils.getSubject().getPrincipal();
QueryWrapper<PayDataDirectory> queryWrapper = new QueryWrapper();
queryWrapper.eq("type",dataType);
queryWrapper.eq("create_by",sysUser.getUsername());
ArrayList<String> arrayList = new ArrayList<>();
arrayList.add(id);
List<PayDataDirectory> list = payDataDirectoryService.list(queryWrapper);
List<DirectoryToTree> collect = list.stream()
.filter(payDataDirectory -> id.equals(payDataDirectory.getParentId()))
.map(payDataDirectory -> {
arrayList.add(payDataDirectory.getId());
DirectoryToTree directoryToTree = transtoTree(payDataDirectory, list,arrayList);
return directoryToTree;
}).sorted(Comparator.comparing(DirectoryToTree::getSort))
.collect(Collectors.toList());
return arrayList;
}
/**
* 转换为树
* @param payDataDirectory 单个节点用于查找其子节点
* @param list 所以节点集合
* @return
*/
private DirectoryToTree transtoTree(PayDataDirectory payDataDirectory, List<PayDataDirectory> list,List<String> arrayList) {
DirectoryToTree directoryToTree = new DirectoryToTree();
BeanUtils.copyProperties(payDataDirectory, directoryToTree);
List<PayDataDirectory> collect = list.stream()
.filter(payDataDirectory1 -> payDataDirectory.getId().equals(payDataDirectory1.getParentId()))
.map(
payDataDirectory2 -> {
arrayList.add(payDataDirectory2.getId());
DirectoryToTree directoryToTree1 = transtoTree(payDataDirectory2, list, arrayList);
return directoryToTree;
}
).sorted(Comparator.comparing(PayDataDirectory::getSort))
.collect(Collectors.toList());
directoryToTree.setChildren(collect);
return directoryToTree;
}
/**
@@ -4,6 +4,7 @@ import java.io.*;
import java.util.Arrays;
import java.util.List;
import javax.activation.MimetypesFileTypeMap;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -20,6 +21,8 @@ import com.jero.data.entity.PayCaseCommitteeSubitem;
import com.jero.data.entity.PayDistributionRecord;
import com.jero.data.entity.PayFileDownloadRecord;
import com.jero.data.service.IPayFileDownloadRecordService;
import com.jero.modules.oss.entity.OSSFile;
import com.jero.modules.oss.service.IOSSFileService;
import lombok.extern.slf4j.Slf4j;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
@@ -47,6 +50,9 @@ public class PayFileDownloadRecordController extends JeroController<PayFileDownl
@Value("${jero.path.upload}")
private String upLoadPath;
@Resource
private IOSSFileService iossFileService;
@Autowired
private IPayFileDownloadRecordService payFileDownloadRecordService;
@@ -77,19 +83,22 @@ public class PayFileDownloadRecordController extends JeroController<PayFileDownl
@ApiOperation(value="资料下载", notes="资料下载")
@GetMapping(value = "download")
public void download(
@RequestParam(name = "fileName",required = true) String filename
@RequestParam(name = "fileid",required = true) String fileid
) throws IOException {
ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletResponse response = requestAttributes.getResponse();
OSSFile byId = iossFileService.getById(fileid);
String fileName = byId.getFileName();
// 设置信息给客户端不解析
String type = new MimetypesFileTypeMap().getContentType(filename);
String type = new MimetypesFileTypeMap().getContentType(fileName);
// 设置contenttype,即告诉客户端所发送的数据属于什么类型
response.setHeader("Content-type",type);
// 设置编码
String hehe = new String(filename.getBytes("utf-8"), "iso-8859-1");
String hehe = new String(fileName.getBytes("utf-8"), "iso-8859-1");
// 设置扩展头,当Content-Type 的类型为要下载的类型时 , 这个信息头会告诉浏览器这个文件的名字和类型。
response.setHeader("Content-Disposition", "attachment;filename=" + hehe);
download(filename, response);
download(fileName, response);
}