Merge branch 'dev'

This commit is contained in:
wangliwen 2022-11-09 12:42:15 +08:00
commit 9aec520986
1 changed files with 33 additions and 32 deletions

View File

@ -171,50 +171,51 @@ public class ResourceController {
@ApiImplicitParam(name = "deptId", value = "所属部门", paramType = "query", dataType = "long"),
@ApiImplicitParam(name = "approveStatus", value = "审核状态,可选值(通过、审核中)", paramType = "query", dataType = "String"),
})
public void exportSelectCensusResourceTable(@RequestParam Map<String, Object> params, HttpServletResponse response) throws IOException {
public void exportSelect(@RequestParam Map<String, Object> params, HttpServletResponse response) throws IOException {
List<ResourceDTO> result = resourceService.list(params);
List<List<Object>> date = result.stream().map(index -> {
List<Object> data = new ArrayList<>();
data.add(index.getName());
data.add(index.getDescription());
Optional<SysDeptDTO> sysDeptDTOOptional = Optional.ofNullable(sysDeptService.get(index.getDeptId() == null ? 0l : index.getDeptId()));
if (sysDeptDTOOptional.isPresent()) {
data.add(sysDeptDTOOptional.get().getName());
} else {
data.add("--");
}
// Optional<String> yyly = index.getInfoList()
// .stream()
// .filter(index_ -> index_.getAttrType().equals("应用领域") && index_.getDelFlag().intValue() == 0)
// .map(index_ -> index_.getAttrValue()).findFirst();
String sql = String.format("SELECT attr_value FROM tb_data_attr WHERE data_resource_id = %d AND attr_type = '应用领域' AND del_flag = 0 LIMIT 1;", index.getId());
Optional<String> yyly = Optional.ofNullable(jdbcTemplate.queryForObject(sql, String.class));
if (yyly.isPresent()) {
data.add(yyly.get());
} else {
data.add("--");
}
data.add(index.getCreateDate() == null ? "--" : index.getCreateDate().toString());
try {
data.add(index.getName());
data.add(index.getDescription());
Optional<SysDeptDTO> sysDeptDTOOptional = Optional.ofNullable(sysDeptService.get(index.getDeptId() == null ? 0l : index.getDeptId()));
if (sysDeptDTOOptional.isPresent()) {
data.add(sysDeptDTOOptional.get().getName());
} else {
data.add("--");
}
String sql = String.format("SELECT attr_value FROM tb_data_attr WHERE data_resource_id = %d AND attr_type = '应用领域' AND del_flag = 0 LIMIT 1;", index.getId());
Optional<String> yyly = Optional.ofNullable(jdbcTemplate.queryForObject(sql, String.class));
if (yyly.isPresent()) {
data.add(yyly.get());
} else {
data.add("--");
}
data.add(index.getCreateDate() == null ? "--" : index.getCreateDate().toString());
SysUserDTO userDTO = sysUserService.get(index.getCreator() == null ? 0l : index.getCreator());
if (userDTO != null) {
data.add(userDTO.getUsername());
} else {
data.add("--");
SysUserDTO userDTO = sysUserService.get(index.getCreator() == null ? 0l : index.getCreator());
if (userDTO != null) {
data.add(userDTO.getUsername());
} else {
data.add("--");
}
return data;
} catch (Exception exception) {
logger.error("导出数据异常", exception);
return null;
}
return data;
}).collect(Collectors.toList());
}).filter(index -> index != null).collect(Collectors.toList());
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8");
String fileName = URLEncoder.encode("资源导出_" + System.currentTimeMillis(), "UTF-8").replaceAll("\\+", "%20");
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
EasyExcel.write(response.getOutputStream()).head(exportSelectCensusResourceTableHead())
EasyExcel.write(response.getOutputStream()).head(exportSelectHead())
.registerWriteHandler(new CustomCellWriteWeightConfig())
.registerWriteHandler(new CustomCellWriteHeightConfig())
.sheet("上架情况").doWrite(date);
.sheet("资源导出").doWrite(date);
}
private List<List<String>> exportSelectCensusResourceTableHead() {
private List<List<String>> exportSelectHead() {
List<List<String>> list = new ArrayList<>();
List<String> head0 = new ArrayList<>();
head0.add("名称");
@ -542,7 +543,7 @@ public class ResourceController {
if (size == null) size = 10;
Long userId = SecurityUser.getUserId();
if (userId == null){
if (userId == null) {
return new Result<>().error("请登录");
}