Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
dinggang 2022-11-09 15:07:32 +08:00
commit 8d36ad1e56
3 changed files with 121 additions and 15 deletions

View File

@ -216,6 +216,7 @@ public class AbilityCenterControllerV3 {
sysNoticeService.save(dto); sysNoticeService.save(dto);
}, executor); }, executor);
} }
logger.info("开始申请流程!");
List<TAbilityApplicationDTO> tAbilityApplicationDTOList = abilityBatchApplicationDTO.getSystem().stream().map(index -> { List<TAbilityApplicationDTO> tAbilityApplicationDTOList = abilityBatchApplicationDTO.getSystem().stream().map(index -> {
if (tAbilityApplicationService.countUserResourceApply(SecurityUser.getUserId(), Long.valueOf(index.get("resourceId"))) > 0) { // 防止重复发起申请 if (tAbilityApplicationService.countUserResourceApply(SecurityUser.getUserId(), Long.valueOf(index.get("resourceId"))) > 0) { // 防止重复发起申请
logger.error("重复发起申请"); logger.error("重复发起申请");
@ -283,19 +284,24 @@ public class AbilityCenterControllerV3 {
if (deptId == 0L) { // 部门id不存在时 if (deptId == 0L) { // 部门id不存在时
return; return;
} }
final SysDeptDTO sysDeptDTO = sysDeptService.get(deptId); SysDeptDTO sysDeptDTO = sysDeptService.get(deptId);
if (sysDeptDTO == null) { // 部门不存在 if (sysDeptDTO == null) { // 部门不存在
return; logger.info("资源部门不存在时!!!");
if (!deptDTO.isPresent()) {
return;
}
sysDeptDTO = deptDTO.isPresent() ? deptDTO.get() : null;
} }
List<TAbilityApplicationDTO> dtoList = temp.get(deptId); List<TAbilityApplicationDTO> dtoList = temp.get(deptId);
SysDeptDTO finalSysDeptDTO = sysDeptDTO;
dtoList = dtoList.stream().map(index -> { dtoList = dtoList.stream().map(index -> {
index.setResourceOwnerDept(sysDeptDTO); index.setResourceOwnerDept(finalSysDeptDTO);
return index; return index;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
List<TAbilityApplicationDTO> finalDtoList = dtoList; List<TAbilityApplicationDTO> finalDtoList = dtoList;
CompletableFuture.runAsync(() -> { CompletableFuture.runAsync(() -> {
String[] sqls = finalDtoList.stream().map(index -> String.format("UPDATE t_ability_application SET resource_owner_dept = '%s' WHERE id = %s", JSON.toJSONString(sysDeptDTO), index.getId())).collect(Collectors.toList()).toArray(new String[finalDtoList.size()]); String[] sqls = finalDtoList.stream().map(index -> String.format("UPDATE t_ability_application SET resource_owner_dept = '%s' WHERE id = %s", JSON.toJSONString(finalSysDeptDTO), index.getId())).collect(Collectors.toList()).toArray(new String[finalDtoList.size()]);
jdbcTemplate.batchUpdate(sqls); // 批量更新资源所属部门信息 jdbcTemplate.batchUpdate(sqls); // 批量更新资源所属部门信息
logger.info("批量更新申请的资源的部门信息完成"); logger.info("批量更新申请的资源的部门信息完成");
}, executor); }, executor);
@ -362,7 +368,7 @@ public class AbilityCenterControllerV3 {
put("city_apply", finalCityApply); // 是否为市级部门发起申请 put("city_apply", finalCityApply); // 是否为市级部门发起申请
put("cross_region", finalCrossRegion); // 是否跨区 put("cross_region", finalCrossRegion); // 是否跨区
put("city_apply_city", finalCityApplyCity); // 是否为市区申请市区 put("city_apply_city", finalCityApplyCity); // 是否为市区申请市区
put("resource_dept", sysDeptDTO); // 同一审核单内部门信息 put("resource_dept", finalSysDeptDTO); // 同一审核单内部门信息
} }
}); });

View File

@ -505,9 +505,6 @@ public class CensusController {
SysDeptDTO sysDeptDTO = sysDeptService.get(user.getDeptId()); SysDeptDTO sysDeptDTO = sysDeptService.get(user.getDeptId());
params.put("region", sysDeptDTO.getDistrict()); // 管理员只出本部门区域 params.put("region", sysDeptDTO.getDistrict()); // 管理员只出本部门区域
} }
// else if (user.getSuperAdmin() == SuperAdminEnum.YES.value()) { // 超级管理员
//
// }
ArrayList<Map> resultList = (ArrayList<Map>) resourceDao.selectCensusResourceTable(params); ArrayList<Map> resultList = (ArrayList<Map>) resourceDao.selectCensusResourceTable(params);
List<List<Object>> date = resultList.stream().map(index -> { List<List<Object>> date = resultList.stream().map(index -> {
List<Object> data = new ArrayList<>(); List<Object> data = new ArrayList<>();

View File

@ -16,11 +16,18 @@ import io.renren.modules.resource.dataResource.DataResourceFactory;
import io.renren.modules.resource.dto.GetDataResourceListDto; import io.renren.modules.resource.dto.GetDataResourceListDto;
import io.renren.modules.resource.dto.ResourceDTO; import io.renren.modules.resource.dto.ResourceDTO;
import io.renren.modules.resource.excel.ResourceExcelImportListener; import io.renren.modules.resource.excel.ResourceExcelImportListener;
import io.renren.modules.resource.excel.census.config.CustomCellWriteHeightConfig;
import io.renren.modules.resource.excel.census.config.CustomCellWriteWeightConfig;
import io.renren.modules.resource.service.ResourceService; import io.renren.modules.resource.service.ResourceService;
import io.renren.modules.resource.videoPreview.AbstractVideoPreviewService; import io.renren.modules.resource.videoPreview.AbstractVideoPreviewService;
import io.renren.modules.resource.videoPreview.VideoPreviewFactory; import io.renren.modules.resource.videoPreview.VideoPreviewFactory;
import io.renren.modules.security.user.SecurityUser;
import io.renren.modules.sys.dao.SysUserDao;
import io.renren.modules.sys.dto.SysDeptDTO; import io.renren.modules.sys.dto.SysDeptDTO;
import io.renren.modules.sys.dto.SysUserDTO;
import io.renren.modules.sys.entity.SysUserEntity;
import io.renren.modules.sys.service.SysDeptService; import io.renren.modules.sys.service.SysDeptService;
import io.renren.modules.sys.service.SysUserService;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -41,8 +48,10 @@ import springfox.documentation.annotations.ApiIgnore;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.URLEncoder;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@ -109,6 +118,12 @@ public class ResourceController {
@Autowired @Autowired
private SysDeptService sysDeptService; private SysDeptService sysDeptService;
@Autowired
private SysUserDao sysUserDao;
@Autowired
private SysUserService sysUserService;
@Resource(name = "${hisense.gateway.name}") @Resource(name = "${hisense.gateway.name}")
private ApiGateway apiGateway; private ApiGateway apiGateway;
@ -146,6 +161,83 @@ public class ResourceController {
return new Result<PageData<ResourceDTO>>().ok(page); return new Result<PageData<ResourceDTO>>().ok(page);
} }
@GetMapping("/export")
@ApiOperation("导出资源")
@LogOperation("导出资源")
@ApiImplicitParams({
@ApiImplicitParam(name = "startDate", value = "开始时间", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "endDate", value = "结束时间", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "type", value = "资源类型", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "deptId", value = "所属部门", paramType = "query", dataType = "long"),
@ApiImplicitParam(name = "approveStatus", value = "审核状态,可选值(通过、审核中)", paramType = "query", dataType = "String"),
})
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<>();
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("--");
}
return data;
} catch (Exception exception) {
logger.error("导出数据异常", exception);
return null;
}
}).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(exportSelectHead())
.registerWriteHandler(new CustomCellWriteWeightConfig())
.registerWriteHandler(new CustomCellWriteHeightConfig())
.sheet("资源导出").doWrite(date);
}
private List<List<String>> exportSelectHead() {
List<List<String>> list = new ArrayList<>();
List<String> head0 = new ArrayList<>();
head0.add("名称");
List<String> head1 = new ArrayList<>();
head1.add("描述");
List<String> head2 = new ArrayList<>();
head2.add("归属部门");
List<String> head3 = new ArrayList<>();
head3.add("应用领域");
List<String> head4 = new ArrayList<>();
head4.add("上架时间");
List<String> head5 = new ArrayList<>();
head5.add("上架账号");
list.add(head0);
list.add(head1);
list.add(head2);
list.add(head3);
list.add(head4);
list.add(head5);
return list;
}
@PostMapping("/pageWithAttrs") @PostMapping("/pageWithAttrs")
@ApiOperation("分页查询资源信息2") @ApiOperation("分页查询资源信息2")
@LogOperation("分页查询资源信息2") @LogOperation("分页查询资源信息2")
@ -444,21 +536,32 @@ public class ResourceController {
@ApiOperation("资源列表转发") @ApiOperation("资源列表转发")
@LogOperation("资源列表转发") @LogOperation("资源列表转发")
public Result yaweiApproveStatus(@ApiParam("页数") Integer page, public Result yaweiApproveStatus(@ApiParam("页数") Integer page,
@ApiParam("页大小") Integer size, @ApiParam("页大小") Integer size,
@ApiParam("资源模糊搜索") String title) { @ApiParam("资源模糊搜索") String title) {
if (page == null) page = 1; if (page == null) page = 1;
if (size == null) size = 10; if (size == null) size = 10;
String url = "http://15.72.158.81/zyjk/ZywMessage.asmx"; Long userId = SecurityUser.getUserId();
if (userId == null) {
return new Result<>().error("请登录");
}
SysUserEntity sysUser = sysUserDao.getById(userId);
if (sysUser == null || sysUser.getGuid() == null) {
return new Result<>().error("该账号没有权限");
}
String url = "http://15.72.158.81/zyjk/ZywMessage.asmx?op=ZySPPort";
String parame = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + String parame = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
"<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n" + "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n" +
" <soap:Body>\n" + " <soap:Body>\n" +
" <ZySPPort xmlns=\"http://tempuri.org/\">\n" + " <ZySPPort xmlns=\"http://tempuri.org/\">\n" +
" <userguid>e8d2fb43-f512-4918-ab47-1141b925af10</userguid>\n" + // " <userguid>e8d2fb43-f512-4918-ab47-1141b925af10</userguid>\n" +
" <pagenum>1</pagenum>\n" + String.format("<userguid>%s</userguid>", sysUser.getGuid()) +
" <pagesize>10</pagesize>\n" + String.format("<pagenum>%d</pagenum>", page) +
" <title></title>\n" + String.format("<pagesize>%d</pagesize>", size) +
title != null ? String.format("<title>%s</title>", title) : "" +
" </ZySPPort>\n" + " </ZySPPort>\n" +
" </soap:Body>\n" + " </soap:Body>\n" +
"</soap:Envelope>"; "</soap:Envelope>";