diff --git a/config/db/V4.3__fuse_drop_col.sql b/config/db/V4.3__fuse_drop_col.sql new file mode 100644 index 00000000..093b48bf --- /dev/null +++ b/config/db/V4.3__fuse_drop_col.sql @@ -0,0 +1,10 @@ +ALTER TABLE `tb_fuse` +MODIFY COLUMN `description` varchar(1000) DEFAULT NULL COMMENT '融合服务描述', +DROP COLUMN `dept_user`, +DROP COLUMN `mobile`, +DROP COLUMN `provider`, +DROP COLUMN `provider_user`, +DROP COLUMN `provider_mobile`; + +ALTER TABLE `tb_fuse_resource` +ADD COLUMN `type` varchar(128) NULL COMMENT '资源类型'; \ No newline at end of file diff --git a/doc/后端开发约定.md b/doc/后端开发约定.md new file mode 100644 index 00000000..7f9ac6f2 --- /dev/null +++ b/doc/后端开发约定.md @@ -0,0 +1,15 @@ +## 能力超市后端开发约定 + +### 关于数据库或orm + +- 数据库版本管理工具使用flyway,请将文件resource目录下对应位置;文件名称使用 R__XXX 或 Vn.n__XXX ,R开头文件表明该文件为可重复执行sql,当文件内容更改时,该sql文件会在启动时再次执行一次,即该文件无版本执行限制,常用于数据初始化或数据迁移;V开头的文件为版本约束文件,常用于数据库表DDL操作,使用场景一般为创表、加字段、加索引等ddl操作,文件一旦被执行过,不会再次重复执行; +- 使用flyway管理的ddl语句,对表的操作语句不要指定Schema(Database),防止在不同地区部署的数据库名称不一致导致执行异常; +- 使用flyway管理的ddl语句,增加表的字段时不要指定新增字段位于已有字段后;防止表内不存在指定表字段导致ddl失败; + +### 关于编码风格checkstyle + +- 使用idea的同事可以安装checkstyle插件,对更改的文件内容进行代码格式化; + +### 关于性能 + +- 减少使用递归的使用 \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/common/annotation/ActivitiNoticeOperation.java b/renren-admin/src/main/java/io/renren/common/annotation/ActivitiNoticeOperation.java index 1a60a025..bb6d102a 100644 --- a/renren-admin/src/main/java/io/renren/common/annotation/ActivitiNoticeOperation.java +++ b/renren-admin/src/main/java/io/renren/common/annotation/ActivitiNoticeOperation.java @@ -1,9 +1,7 @@ package io.renren.common.annotation; - import java.lang.annotation.*; - /** * 流程流转消息通知 */ @@ -14,20 +12,16 @@ public @interface ActivitiNoticeOperation { /** * 节点名称 - * - * @return */ String value() default ""; /** * 流程名称 - * - * @return */ String process() default ""; /** - * @return activiti 监听器类型 1:TaskListener 任务监听器; 2:ExecutionListener 执行监听器; + * activiti 监听器类型 1:TaskListener 任务监听器; 2:ExecutionListener 执行监听器; */ int type() default 1; } diff --git a/renren-admin/src/main/java/io/renren/common/aspect/ActivitiNoticeAspect.java b/renren-admin/src/main/java/io/renren/common/aspect/ActivitiNoticeAspect.java index 5adc0930..60b2cc70 100644 --- a/renren-admin/src/main/java/io/renren/common/aspect/ActivitiNoticeAspect.java +++ b/renren-admin/src/main/java/io/renren/common/aspect/ActivitiNoticeAspect.java @@ -1,6 +1,5 @@ package io.renren.common.aspect; - import com.alibaba.fastjson.JSON; import io.renren.common.annotation.ActivitiNoticeOperation; import io.renren.modules.notice.dto.SysNoticeDTO; @@ -44,9 +43,9 @@ import java.util.concurrent.Executors; @Component public class ActivitiNoticeAspect { - private static final Integer cpuNUm = Runtime.getRuntime().availableProcessors(); - private static final ExecutorService executor = Executors.newFixedThreadPool(cpuNUm * 3); - private static final Logger logger = LoggerFactory.getLogger(ActivitiNoticeAspect.class); + private static final Integer CPU_NUM = Runtime.getRuntime().availableProcessors(); + private static final ExecutorService EXECUTOR = Executors.newFixedThreadPool(CPU_NUM * 3); + private static final Logger LOGGER = LoggerFactory.getLogger(ActivitiNoticeAspect.class); @Autowired private SysNoticeService sysNoticeService; @@ -59,7 +58,7 @@ public class ActivitiNoticeAspect { @Autowired private SysRoleService sysRoleService; - private Set work_ = new CopyOnWriteArraySet<>(); + private Set work = new CopyOnWriteArraySet<>(); @Value("${big_date.name}") private String bigDateDeptName; // 大数据局名称 @@ -67,28 +66,28 @@ public class ActivitiNoticeAspect { private String roleName; // 具备审批的角色名称 public ActivitiNoticeAspect() { - logger.error("构造:ActivitiNoticeAspect"); + LOGGER.error("构造:ActivitiNoticeAspect"); } @Pointcut("@annotation(io.renren.common.annotation.ActivitiNoticeOperation)") public void activitiNoticePointCut() { - logger.error("切面:ActivitiNoticeAspect"); + LOGGER.error("切面:ActivitiNoticeAspect"); } @After(value = "activitiNoticePointCut()") public void notice(JoinPoint joinPoint) throws NoSuchMethodException { - logger.error("-------------------------------进入流程流转消息切面---------------------------------"); + LOGGER.error("-------------------------------进入流程流转消息切面---------------------------------"); long beginTime = System.currentTimeMillis(); MethodSignature signature = (MethodSignature) joinPoint.getSignature(); Method method = joinPoint.getTarget().getClass().getDeclaredMethod(signature.getName(), signature.getParameterTypes()); final ActivitiNoticeOperation activitiNoticeOperation = method.getAnnotation(ActivitiNoticeOperation.class); - logger.error("切面类型:" + activitiNoticeOperation.type()); + LOGGER.error("切面类型:{}", activitiNoticeOperation.type()); switch (activitiNoticeOperation.type()) { case 1: { - Arrays.asList(joinPoint.getArgs()).stream().findFirst().ifPresent(arg -> { + Arrays.stream(joinPoint.getArgs()).findFirst().ifPresent(arg -> { final DelegateTask delegateTask = (DelegateTask) arg; final String eventName = delegateTask.getEventName(); - logger.error("任务监听器事件:" + eventName); + LOGGER.error("任务监听器事件:{}", eventName); switch (eventName) { case TaskListener.EVENTNAME_ASSIGNMENT: // 节点被委派给某人 assignment_notice(delegateTask, activitiNoticeOperation); @@ -105,20 +104,19 @@ public class ActivitiNoticeAspect { Arrays.asList(joinPoint.getArgs()).stream().findFirst().ifPresent(arg -> { final DelegateExecution execution = (DelegateExecution) arg; final String eventName = execution.getEventName(); - logger.error("执行监听器事件:" + eventName); - switch (eventName) { - case ExecutionListener.EVENTNAME_END: // 流程完成 - end_notice(execution, activitiNoticeOperation); - break; - default: + LOGGER.error("执行监听器事件:{}", eventName); + if (ExecutionListener.EVENTNAME_END.equals(eventName)) { // 流程完成 + end_notice(execution, activitiNoticeOperation); } }); } // 执行监听器 break; + default: + break; } //执行时长(毫秒) long time = System.currentTimeMillis() - beginTime; - logger.error("执行时长{} ms", time); + LOGGER.error("执行时长{} ms", time); } /** @@ -129,12 +127,12 @@ public class ActivitiNoticeAspect { */ private void task_complete_notice(final DelegateTask delegateTask, final ActivitiNoticeOperation activitiNoticeOperation) { Map kv = delegateTask.getVariables(); - logger.error("表单:" + JSON.toJSONString(kv)); - if (work_.contains(TaskListener.EVENTNAME_COMPLETE + kv.get("id").toString())) { - logger.error("------------出现重放------------"); + LOGGER.error("表单:" + JSON.toJSONString(kv)); + if (work.contains(TaskListener.EVENTNAME_COMPLETE + kv.get("id").toString())) { + LOGGER.error("------------出现重放------------"); return; } - work_.add(TaskListener.EVENTNAME_COMPLETE + kv.get("id").toString()); + work.add(TaskListener.EVENTNAME_COMPLETE + kv.get("id").toString()); String creator = null; if (kv.containsKey("creator")) { // 表单存在创建者 creator = kv.get("creator").toString(); @@ -168,7 +166,7 @@ public class ActivitiNoticeAspect { Optional resourceDTO = Optional.ofNullable(resourceService.get(resourceId)); kv.get("resourceId"); kv.get("id"); - String content = "【通知】" + userDTO.getRealName() + ",您发起的" + (resourceDTO.isPresent() ? resourceDTO.get().getName() : "") + activitiNoticeOperation.process() + " " + activitiNoticeOperation.value() + "节点" + finalResult; + String content = "【通知】" + userDTO.getRealName() + ",您发起的" + activitiNoticeOperation.process() + " " + activitiNoticeOperation.value() + "节点" + finalResult; SysNoticeDTO dto = new SysNoticeDTO(); dto.setType(2); dto.setTitle("流程节点系统通知"); @@ -182,9 +180,9 @@ public class ActivitiNoticeAspect { dto.setCreateDate(new Date()); dto.setFrom("通知"); sysNoticeService.save(dto); - }, executor); + }, EXECUTOR); } catch (Exception e) { - logger.error("发送通知消息异常", e); + LOGGER.error("发送通知消息异常", e); } finally { // 防止重放 new Thread(() -> { @@ -193,7 +191,7 @@ public class ActivitiNoticeAspect { } catch (InterruptedException e) { throw new RuntimeException(e); } finally { - work_.remove(TaskListener.EVENTNAME_COMPLETE + kv.get("id").toString()); + work.remove(TaskListener.EVENTNAME_COMPLETE + kv.get("id").toString()); } }).start(); } @@ -207,12 +205,12 @@ public class ActivitiNoticeAspect { */ private void end_notice(final DelegateExecution execution, final ActivitiNoticeOperation activitiNoticeOperation) { Map kv = execution.getVariables(); - logger.error("表单:" + JSON.toJSONString(kv)); - if (work_.contains(ExecutionListener.EVENTNAME_END + kv.get("id").toString())) { - logger.error("------------出现重放------------"); + LOGGER.error("表单:" + JSON.toJSONString(kv)); + if (work.contains(ExecutionListener.EVENTNAME_END + kv.get("id").toString())) { + LOGGER.error("------------出现重放------------"); return; } - work_.add(ExecutionListener.EVENTNAME_END + kv.get("id").toString()); + work.add(ExecutionListener.EVENTNAME_END + kv.get("id").toString()); String creator = null; if (kv.containsKey("creator")) { // 表单存在创建者 creator = kv.get("creator").toString(); @@ -238,7 +236,7 @@ public class ActivitiNoticeAspect { Long resourceId = null; if (kv.containsKey("resourceId") && kv.get("resourceId") != null) { resourceId = Long.valueOf(kv.get("resourceId").toString()); - } else if (kv.containsKey("id") && kv.get("id") != null && kv.containsKey("-")) { + } else if (kv.containsKey("id") && kv.get("id") != null && !kv.get("id").toString().contains("-")) { resourceId = Long.valueOf(kv.get("id").toString()); } else { resourceId = 0L; @@ -248,7 +246,7 @@ public class ActivitiNoticeAspect { SysUserDTO userDTO = sysUserService.get(Long.valueOf(finalCreator)); kv.get("resourceId"); kv.get("id"); - String content = "【通知】" + userDTO.getRealName() + ",您发起的" + (resourceDTO.isPresent() ? resourceDTO.get().getName() : "申请摄像头列表") + activitiNoticeOperation.process() + "已完成,审核结果为:" + finalResult; + String content = "【通知】" + userDTO.getRealName() + ",您发起的" + activitiNoticeOperation.process() + "已完成,审核结果为:" + finalResult; SysNoticeDTO dto = new SysNoticeDTO(); dto.setType(2); dto.setTitle("流程结束系统通知"); @@ -262,19 +260,19 @@ public class ActivitiNoticeAspect { dto.setCreateDate(new Date()); dto.setFrom("通知"); sysNoticeService.save(dto); - }, executor).thenRunAsync(() -> { - logger.error("大数据局名称:" + bigDateDeptName); + }, EXECUTOR).thenRunAsync(() -> { + LOGGER.error("大数据局名称:" + bigDateDeptName); SysDeptDTO deptDTO = sysDeptService.getByName(bigDateDeptName); - logger.error("deptDTOId:" + deptDTO.getId()); + LOGGER.error("deptDTOId:" + deptDTO.getId()); SysRoleDTO roleDTO = sysRoleService.getByName(roleName); - logger.error("roleDTOId:" + roleDTO.getId()); + LOGGER.error("roleDTOId:" + roleDTO.getId()); Optional userDTO = Optional.ofNullable(sysUserService.getByDeptIdAndRoleId(deptDTO.getId(), roleDTO.getId())); userDTO.ifPresent(user -> { SysUserDTO creatorDTO = sysUserService.get(Long.valueOf(finalCreator)); SysNoticeDTO dto = new SysNoticeDTO(); dto.setType(2); dto.setTitle("流程结束系统通知"); - String content = "【通知】" + user.getRealName() + "," + creatorDTO.getRealName() + "发起的" + (resourceDTO.isPresent() ? resourceDTO.get().getName() : "") + activitiNoticeOperation.process() + "已完成,审核结果为:" + finalResult; + String content = "【通知】" + user.getRealName() + "," + creatorDTO.getRealName() + "发起的" + activitiNoticeOperation.process() + "已完成,审核结果为:" + finalResult; dto.setContent(content); // 通知内容 dto.setReceiverType(1); dto.setReceiverTypeIds(userDTO.get().getId().toString()); @@ -286,9 +284,9 @@ public class ActivitiNoticeAspect { dto.setFrom("通知"); sysNoticeService.save(dto); }); - }, executor); + }, EXECUTOR); } catch (Exception exception) { - logger.error("发送通知消息异常", exception); + LOGGER.error("发送通知消息异常", exception); } finally { // 防止重放 new Thread(() -> { @@ -297,7 +295,7 @@ public class ActivitiNoticeAspect { } catch (InterruptedException e) { throw new RuntimeException(e); } finally { - work_.remove(ExecutionListener.EVENTNAME_END + kv.get("id").toString()); + work.remove(ExecutionListener.EVENTNAME_END + kv.get("id").toString()); } }).start(); } @@ -312,12 +310,12 @@ public class ActivitiNoticeAspect { */ private void assignment_notice(final DelegateTask delegateTask, final ActivitiNoticeOperation activitiNoticeOperation) { Map kv = delegateTask.getVariables(); - logger.error("表单:" + JSON.toJSONString(kv)); - if (work_.contains(TaskListener.EVENTNAME_ASSIGNMENT + kv.get("id").toString())) { - logger.error("------------出现重放------------"); + LOGGER.error("表单:" + JSON.toJSONString(kv)); + if (work.contains(TaskListener.EVENTNAME_ASSIGNMENT + kv.get("id").toString())) { + LOGGER.error("------------出现重放------------"); return; } - work_.add(TaskListener.EVENTNAME_ASSIGNMENT + kv.get("id").toString()); + work.add(TaskListener.EVENTNAME_ASSIGNMENT + kv.get("id").toString()); String creator = null; if (kv.containsKey("creator")) { // 表单存在创建者 creator = kv.get("creator").toString(); @@ -332,9 +330,9 @@ public class ActivitiNoticeAspect { CompletableFuture.runAsync(() -> { // 发起人 try { SysUserDTO assignee = sysUserService.get(Long.valueOf(delegateTask.getAssignee())); - logger.error("审核人:" + assignee.getId()); + LOGGER.error("审核人:" + assignee.getId()); String content = "【通知】您发起的流程 " + activitiNoticeOperation.process() + " 当前审核节点为:" + activitiNoticeOperation.value() + ";当前审核人为:\"" + assignee.getDeptName() + "\"审核负责人\"" + assignee.getRealName() + "\""; - logger.info("通知内容:" + content); + LOGGER.info("通知内容:" + content); SysNoticeDTO dto = new SysNoticeDTO(); dto.setType(2); dto.setTitle("流程流转系统通知"); @@ -349,12 +347,12 @@ public class ActivitiNoticeAspect { dto.setFrom("通知"); sysNoticeService.save(dto); } catch (Exception exception) { - logger.error("通知发起人失败", exception); + LOGGER.error("通知发起人失败", exception); } - }, executor).thenRunAsync(() -> { // 审批者 + }, EXECUTOR).thenRunAsync(() -> { // 审批者 try { SysUserDTO owner = sysUserService.get(Long.valueOf(finalCreator)); - String content = "【通知】" + owner.getRealName() + "发起的流程" + activitiNoticeOperation.process() + "已进入审核节点:" + activitiNoticeOperation.value() + ";当前审核人指派为您"; + String content = "【通知】" + owner.getRealName() + "发起的流程" + activitiNoticeOperation.process() + " 已进入审核节点:" + activitiNoticeOperation.value() + ";当前审核人指派为您"; SysNoticeDTO dto = new SysNoticeDTO(); dto.setType(2); dto.setTitle("流程流转系统通知"); @@ -369,16 +367,16 @@ public class ActivitiNoticeAspect { dto.setFrom("通知"); sysNoticeService.save(dto); } catch (Exception exception) { - logger.error("通知审批人失败", exception); + LOGGER.error("通知审批人失败", exception); } - }, executor); + }, EXECUTOR); } catch (Exception e) { - logger.error("发送通知消息异常", e); + LOGGER.error("发送通知消息异常", e); } finally { new Thread(() -> { try { Thread.sleep(200); - work_.remove(TaskListener.EVENTNAME_ASSIGNMENT + kv.get("id").toString()); + work.remove(TaskListener.EVENTNAME_ASSIGNMENT + kv.get("id").toString()); } catch (InterruptedException e) { throw new RuntimeException(e); } diff --git a/renren-admin/src/main/java/io/renren/common/controller/AbilityCenterControllerV2.java b/renren-admin/src/main/java/io/renren/common/controller/AbilityCenterControllerV2.java index 1e8fd77b..f8f2bb26 100644 --- a/renren-admin/src/main/java/io/renren/common/controller/AbilityCenterControllerV2.java +++ b/renren-admin/src/main/java/io/renren/common/controller/AbilityCenterControllerV2.java @@ -53,7 +53,7 @@ import java.util.stream.Collectors; @RestController @RequestMapping("/ability/center/v2") public class AbilityCenterControllerV2 { - private static final ExecutorService executor = Executors.newCachedThreadPool(); + private static final ExecutorService executor = Executors.newWorkStealingPool(); private static final Logger logger = LoggerFactory.getLogger(AbilityCenterController.class); private static final ObjectMapper oMapper = new ObjectMapper(); @Autowired @@ -108,10 +108,9 @@ public class AbilityCenterControllerV2 { abilityBatchApplicationDTO.setApplyFlag(applyFlag); // 同一次的申请标识 final Optional deptDTO = Optional.ofNullable(sysDeptService.getByName(bigDateDeptName)); final UserDetail user = SecurityUser.getUser(); - CompletableFuture.runAsync(() -> { - logger.info("处理能力申请!"); + executor.execute(() -> { deal(abilityBatchApplicationDTO, deptDTO, applyFlag, user); - }, executor); + }); return new Result().ok(LocalDateTime.now().toString()); } @@ -132,10 +131,7 @@ public class AbilityCenterControllerV2 { logger.info("申请入参{}", JSON.toJSONString(abilityBatchApplicationDTO)); final Optional deptDTO = Optional.ofNullable(sysDeptService.getByName(bigDateDeptName)); final UserDetail user = SecurityUser.getUser(); - CompletableFuture.runAsync(() -> { - logger.info("处理能力申请!"); - deal(abilityBatchApplicationDTO, deptDTO, applyFlag, user); - }, executor); + deal(abilityBatchApplicationDTO, deptDTO, applyFlag, user); return new Result().ok(LocalDateTime.now().toString()); } @@ -162,7 +158,7 @@ public class AbilityCenterControllerV2 { tAbilityApplicationDTO.setApproveStatus("审核中"); tAbilityApplicationDTO.setDelFlag(0); // v2 新增字段 - tAbilityApplicationDTO.setCameraList(index.get("cameraId") == null ? null : JSON.toJSONString(index.get("cameraId"))); + tAbilityApplicationDTO.setCameraList(index.get("channelId") == null ? null : JSON.toJSONString(index)); tAbilityApplicationDTO.setTitle(abilityBatchApplicationDTO.getTitle()); tAbilityApplicationDTO.setApplicationBackground(abilityBatchApplicationDTO.getApplicationBackground()); tAbilityApplicationDTO.setApplicationScene(abilityBatchApplicationDTO.getApplicationScene()); @@ -217,14 +213,22 @@ public class AbilityCenterControllerV2 { }, executor); Boolean basic_facilities = dtoList.stream().map(index -> { - Optional resourceDTOOptional = Optional.ofNullable(resourceService.get(Long.valueOf(index.getResourceId()))); // 从本库内查不到 视为其它平台的基础设施资源 - return !resourceDTOOptional.isPresent() || !"基础设施".equals(resourceDTOOptional.get().getType()); - }).filter(index -> !index).findAny().orElse(Boolean.TRUE); + Optional resourceDTOOptional = Optional.ofNullable(resourceService.get(Long.valueOf(index.getResourceId()))); + if (!resourceDTOOptional.isPresent()) { // 从本库内查不到 视为其它平台的基础设施资源 + return true; + } + if ("基础设施".equals(resourceDTOOptional.get().getType())) { // 基础设施 + return true; + } + return false; + }).filter(index -> index).findAny().orElse(Boolean.FALSE); logger.error("--------------------是否全是基础设施{}----------------------------------------------", basic_facilities); final List ids = dtoList.stream().map(TAbilityApplicationDTO::getId).collect(Collectors.toList()); // 发起申请的表单id // 仿照请求接口 /act/running/startOfBusinessKey ProcessStartDTO processStartDTO = new ProcessStartDTO(); - processStartDTO.setBusinessKey(basic_facilities ? tAbilityApplicationDTOList.stream().filter(index -> StringUtils.isNotEmpty(index.getResourceId())).map(TAbilityApplicationDTO::getResourceId).findFirst().orElse(null) : JSON.toJSONString(ids)); // 申请的id列表 json字符 做businesskey + processStartDTO.setBusinessKey(basic_facilities ? tAbilityApplicationDTOList.stream().filter(index -> StringUtils.isNotEmpty(index.getResourceId())) + .map(TAbilityApplicationDTO::getResourceId).findFirst().orElse(null) : + JSON.toJSONString(ids.stream().limit(5).collect(Collectors.toList()))); // 申请的id列表 json字符 做businesskey processStartDTO.setProcessDefinitionKey(key); //限定 AuditingBaseDTO auditingBaseDTO = new AuditingBaseDTO(); auditingBaseDTO.setCompleteEntry(Boolean.TRUE); // 首次录入 @@ -250,11 +254,13 @@ public class AbilityCenterControllerV2 { // 仿照请求接口 /processForm/tabilityapplication/updateInstanceId CompletableFuture.runAsync(() -> { if (dto.getBusinessKey() != null) { - String[] sqls = dtoList.stream().map(i -> String.format("UPDATE t_ability_application SET instance_id = %s WHERE id = %s", dto.getProcessInstanceId(), i.getId())).collect(Collectors.toList()).toArray(new String[dtoList.size()]); + String[] sqls = dtoList.stream().map(i -> String.format("UPDATE t_ability_application SET instance_id = %s WHERE id = %s", dto.getProcessInstanceId(), i.getId())) + .collect(Collectors.toList()).toArray(new String[dtoList.size()]); jdbcTemplate.batchUpdate(sqls); } }, executor); }); } } + } diff --git a/renren-admin/src/main/java/io/renren/common/controller/CensusController.java b/renren-admin/src/main/java/io/renren/common/controller/CensusController.java index 1c78a1ca..9b8183a4 100644 --- a/renren-admin/src/main/java/io/renren/common/controller/CensusController.java +++ b/renren-admin/src/main/java/io/renren/common/controller/CensusController.java @@ -308,7 +308,7 @@ public class CensusController { } catch (JsonProcessingException e) { throw new RuntimeException(e); } - }).reversed().thenComparing(i -> i.toString()) + }).reversed().thenComparing(Object::toString) ); // 按应用领域数目逆序排序 return new Result>>().ok(result); } diff --git a/renren-admin/src/main/java/io/renren/common/controller/CensusControllerV2.java b/renren-admin/src/main/java/io/renren/common/controller/CensusControllerV2.java index 22765634..ac89202f 100644 --- a/renren-admin/src/main/java/io/renren/common/controller/CensusControllerV2.java +++ b/renren-admin/src/main/java/io/renren/common/controller/CensusControllerV2.java @@ -342,40 +342,36 @@ public class CensusControllerV2 { List> dbAmount = (List>) map.get("total"); return dbAmount.stream().filter(index -> "基础设施".equals(index.get("type").toString())) .mapToLong(index -> Long.parseLong(index.get("count").toString())).sum(); - }).thenAccept(sum -> { - result.add(new HashMap() { - { - put("amount", sum); - put("type", "视频资源数量"); - } - }); - }); + }).thenAccept(sum -> result.add(new HashMap() { + { + put("amount", sum); + put("type", "视频资源数量"); + } + })); } break; case BAOTOU: { // 包头 allAmount = CompletableFuture.supplyAsync(() -> { // 获取平台总基础设施数目 return jdbcTemplate.queryForObject("SELECT COUNT(id) FROM tb_data_resource WHERE type = '基础设施' AND del_flag = 0", Long.class); - }).thenAccept(sum -> { - result.add(new HashMap() { - { - put("amount", sum); - put("type", "视频资源数量"); - } - }); - }); + }).thenAccept(sum -> result.add(new HashMap() { + { + put("amount", sum); + put("type", "视频资源数量"); + } + })); } break; case TSINGTAO_XHA: { // 青岛西海岸 allAmount = CompletableFuture.supplyAsync(() -> { // 获取平台总基础设施数目 List result_ = new CopyOnWriteArrayList<>(); - String url = String.format(tsingtao_xhaProperties.getCloudcam(), "", 1, 10); + String url = tsingtao_xhaProperties.getCamCount(); logger.info(url); Request request = new Request.Builder().url(url).build(); try (Response response = client.newCall(request).execute()) { if (response.isSuccessful()) { JSONObject jsonObject = JSON.parseObject(response.body().string()); - if (jsonObject.containsKey("data")) { - result_.add(jsonObject.getJSONObject("data").getLongValue("total")); + if (jsonObject.containsKey("errorNo") && jsonObject.getLongValue("errorNo") == 200) { + result_.add(jsonObject.getLongValue("body")); } } else { logger.error("青岛西海岸获取失败"); @@ -383,15 +379,13 @@ public class CensusControllerV2 { } catch (Exception exception) { logger.error("青岛西海岸失败", exception); } - return result_.stream().filter(index -> index != null).findAny().orElse(0l); - }).thenAccept(sum -> { - result.add(new HashMap() { - { - put("amount", sum); - put("type", "视频资源数量"); - } - }); - }); + return result_.stream().filter(Objects::nonNull).findAny().orElse(0L); + }).thenAccept(sum -> result.add(new HashMap() { + { + put("amount", sum); + put("type", "视频资源数量"); + } + })); } break; } @@ -461,19 +455,17 @@ public class CensusControllerV2 { { List lists = (dataResource != null && dataResource.containsKey("data") && dataResource.get("data") != null) ? (List) dataResource.get("data") : new ArrayList<>(); ArrayList list = new ArrayList<>(); - lists.forEach(item -> { - list.add(new HashMap() {{ - put("服务名称", item.get("zyname")); - put("申请次数", item.get("syqk")); - }}); - }); + lists.forEach(item -> list.add(new HashMap() {{ + put("服务名称", item.get("zyname")); + put("申请次数", item.get("syqk")); + }})); put("resourceTop5", list); } }); } break; case TSINGTAO_XHA: { // 青岛西海岸 - Long total = 0L; + Long total; Request request = new Request.Builder().url(tsingtao_xhaProperties.getResourcecount()).build(); try (Response response = client.newCall(request).execute()) { if (response.isSuccessful()) { diff --git a/renren-admin/src/main/java/io/renren/common/controller/ResourceMountController.java b/renren-admin/src/main/java/io/renren/common/controller/ResourceMountController.java index 595fdfce..268a1b3f 100644 --- a/renren-admin/src/main/java/io/renren/common/controller/ResourceMountController.java +++ b/renren-admin/src/main/java/io/renren/common/controller/ResourceMountController.java @@ -153,7 +153,7 @@ public class ResourceMountController { @PostMapping(value = "/undercarriage") @ApiOperation("批量进行能力下架申请") @LogOperation("批量进行能力下架申请") - public Result> undercarriage(@RequestBody TResourceUndercarriageApplyDTO tResourceUndercarriageApplyDTO) { + public Result undercarriage(@RequestBody TResourceUndercarriageApplyDTO tResourceUndercarriageApplyDTO) { // 仿照请求接口 /act/process/lastestPage PageData> page = actProcessService.page(undercarriage_params); if (page.getTotal() <= 0) { // @@ -175,7 +175,7 @@ public class ResourceMountController { } }).filter(index -> index).findAny(); if (undercarriage.isPresent()) { - return new Result>().error("该资源已发起下架"); + return new Result<>().ok("该资源已发起下架"); } return new Result().ok(tResourceUndercarriageApplyDTO.getResource().stream().map(index -> { List dtoList = new ArrayList<>(); @@ -190,6 +190,7 @@ public class ResourceMountController { throw new RuntimeException("该资源已发起下架"); } dto.setUndercarriageReason(tResourceUndercarriageApplyDTO.getReason()); + dto.setUndercarriageEnclosure(tResourceUndercarriageApplyDTO.getEnclosure()); dto.setDelFlag(ResourceEntityDelFlag.NORMAL.getFlag()); // 设置为正常 String userId = SecurityUser.getUserId().toString(); Optional userDTO = Optional.ofNullable(sysUserService.get(Long.valueOf(userId))); diff --git a/renren-admin/src/main/java/io/renren/common/domain/Tsingtao_xhaProperties.java b/renren-admin/src/main/java/io/renren/common/domain/Tsingtao_xhaProperties.java index deaf2a61..157cba73 100644 --- a/renren-admin/src/main/java/io/renren/common/domain/Tsingtao_xhaProperties.java +++ b/renren-admin/src/main/java/io/renren/common/domain/Tsingtao_xhaProperties.java @@ -1,6 +1,5 @@ package io.renren.common.domain; - import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.PropertySource; @@ -21,4 +20,5 @@ public class Tsingtao_xhaProperties { private String resourcecount; private String resourceapplyinfo; private String sjzy; + private String camCount; } diff --git a/renren-admin/src/main/java/io/renren/common/utils/CodeGenerationUtils.java b/renren-admin/src/main/java/io/renren/common/utils/CodeGenerationUtils.java index 6684ca9d..7d89bdb5 100644 --- a/renren-admin/src/main/java/io/renren/common/utils/CodeGenerationUtils.java +++ b/renren-admin/src/main/java/io/renren/common/utils/CodeGenerationUtils.java @@ -105,7 +105,8 @@ public class CodeGenerationUtils { try { String finalTableName = tableName; String finalNo = no; - String[] sqls = id.stream().map(i -> String.format("UPDATE %s SET apply_number = '%s' WHERE id = %s;", finalTableName, finalNo, i)).collect(Collectors.toList()).toArray(new String[id.size()]); + String[] sqls = id.stream().map(i -> String.format("UPDATE %s SET apply_number = '%s' WHERE id = %s;", finalTableName, finalNo, i)) + .collect(Collectors.toList()).toArray(new String[id.size()]); jdbcTemplate.batchUpdate(sqls); } catch (Exception exception) { logger.error("流水号写入失败", exception); diff --git a/renren-admin/src/main/java/io/renren/modules/activiti/controller/ActRunningController.java b/renren-admin/src/main/java/io/renren/modules/activiti/controller/ActRunningController.java index d48c88f5..7cdfb174 100644 --- a/renren-admin/src/main/java/io/renren/modules/activiti/controller/ActRunningController.java +++ b/renren-admin/src/main/java/io/renren/modules/activiti/controller/ActRunningController.java @@ -11,7 +11,6 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; -import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import springfox.documentation.annotations.ApiIgnore; diff --git a/renren-admin/src/main/java/io/renren/modules/activiti/controller/HistoryController.java b/renren-admin/src/main/java/io/renren/modules/activiti/controller/HistoryController.java index c1cfde9b..21a7b36a 100644 --- a/renren-admin/src/main/java/io/renren/modules/activiti/controller/HistoryController.java +++ b/renren-admin/src/main/java/io/renren/modules/activiti/controller/HistoryController.java @@ -14,6 +14,8 @@ import io.renren.modules.demanData.dto.TDemandDataDTO; import io.renren.modules.demanData.service.TDemandDataService; import io.renren.modules.processForm.dto.TAbilityApplicationDTO; import io.renren.modules.processForm.service.TAbilityApplicationService; +import io.renren.modules.resource.dto.ResourceDTO; +import io.renren.modules.resource.service.ResourceService; import io.renren.modules.resourceMountApply.dto.TResourceMountApplyDTO; import io.renren.modules.resourceMountApply.service.TResourceMountApplyService; import io.renren.modules.sys.dto.SysUserDTO; @@ -22,6 +24,12 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; +import org.activiti.engine.HistoryService; +import org.activiti.engine.RepositoryService; +import org.activiti.engine.RuntimeService; +import org.activiti.engine.TaskService; +import org.activiti.engine.history.HistoricProcessInstance; +import org.activiti.engine.history.HistoricProcessInstanceQuery; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; @@ -45,6 +53,9 @@ import java.util.Optional; @RequestMapping("/act/his") @Api(tags = "流程历史") public class HistoryController { + + @Autowired + protected HistoryService historyService_; @Autowired private ActHistoryService historyService; @Autowired @@ -58,6 +69,15 @@ public class HistoryController { private TResourceMountApplyService tResourceMountApplyService; @Autowired private TDemandDataService tDemandDataService; + @Autowired + private ResourceService resourceService; + + @Autowired + protected TaskService taskService; + @Autowired + protected RepositoryService repositoryService; + @Autowired + protected RuntimeService runtimeService; @GetMapping("getInstImage") @ApiOperation(value = "获取流程活动图", produces = "application/octet-stream") @@ -130,11 +150,21 @@ public class HistoryController { if (params.containsKey("processDefinitionKey") && StringUtils.isNotEmpty(params.get("processDefinitionKey").toString())) { params.replace("processDefinitionKey", params.get("processDefinitionKey").toString() + "%"); } + params.put("ended", "true"); PageData page = activitiService.getMyProcessInstancePage(params); setExtraProcessProperties(Optional.ofNullable(page.getList()).orElse(new ArrayList<>())); return new Result().ok(page); } + @GetMapping("getVariablesByInstanceId") + @ApiOperation("获取已办任务流程参数") + @LogOperation("获取已办任务流程参数") + public Result getVariablesByInstanceId(String instanceId, String variableName) { + HistoricProcessInstanceQuery query = historyService_.createHistoricProcessInstanceQuery(); + Optional processInstance = Optional.ofNullable(query.processInstanceId(instanceId).includeProcessVariables().singleResult()); + return new Result().ok(processInstance.get().getProcessVariables().get(variableName)); + } + @GetMapping("getDeptHandledInstancePage") @ApiOperation("已办任务:根据登录账号查询其所在部门的已办任务") @LogOperation("已办任务:根据登录账号查询其所在部门的已办任务") @@ -174,9 +204,11 @@ public class HistoryController { abilityApplicationService.getByInstanceId(activityDTO.getProcessInstanceId()); TResourceMountApplyDTO tResourceMountApplyDTO = null; TDemandDataDTO tDemandDataDTO = null; + ResourceDTO resourceDTO = null; if (!activityDTO.getBusinessKey().startsWith("[") && !activityDTO.getBusinessKey().startsWith("{")) { // json 内容(批量申请) tResourceMountApplyDTO = tResourceMountApplyService.get(Long.valueOf(activityDTO.getBusinessKey())); tDemandDataDTO = tDemandDataService.get(Long.valueOf(activityDTO.getBusinessKey())); + resourceDTO = resourceService.get(Long.valueOf(activityDTO.getBusinessKey())); } if (abilityApplicationDTOS != null && !abilityApplicationDTOS.isEmpty()) { StringBuffer stringBuffer = new StringBuffer(); @@ -190,6 +222,8 @@ public class HistoryController { activityDTO.setResourceName(tResourceMountApplyDTO.getResourceDTO().getName()); } else if (tDemandDataDTO != null) { activityDTO.setResourceName(tDemandDataDTO.getDemandSubject()); + } else if (resourceDTO != null) { + activityDTO.setResourceName(resourceDTO.getName()); } } } diff --git a/renren-admin/src/main/java/io/renren/modules/activiti/service/ActHistoryService.java b/renren-admin/src/main/java/io/renren/modules/activiti/service/ActHistoryService.java index d805e486..0f65712c 100644 --- a/renren-admin/src/main/java/io/renren/modules/activiti/service/ActHistoryService.java +++ b/renren-admin/src/main/java/io/renren/modules/activiti/service/ActHistoryService.java @@ -277,12 +277,12 @@ public class ActHistoryService { for (ProcessInstanceDTO dto : list) { List abilityApplicationDTO = tAbilityApplicationService.getByInstanceId(dto.getProcessInstanceId()); // 获取申请表单 if (abilityApplicationDTO != null && !abilityApplicationDTO.isEmpty()) { - if (abilityApplicationDTO.stream().filter(index -> StringUtils.isNotEmpty(index.getCameraList())).findAny().isPresent()) { // 存在摄像头 + if (abilityApplicationDTO.stream().anyMatch(index -> StringUtils.isNotEmpty(index.getCameraList()))) { // 存在摄像头 dto.setName("申请摄像头列表"); dto.setResourceId(null); } else { StringBuffer stringBuffer = new StringBuffer(); - abilityApplicationDTO.stream().map(TAbilityApplicationDTO::getSystem).filter(index -> StringUtils.isNotEmpty(index)).forEach(index -> { + abilityApplicationDTO.stream().map(TAbilityApplicationDTO::getSystem).filter(StringUtils::isNotEmpty).forEach(index -> { stringBuffer.append(index); stringBuffer.append(","); }); diff --git a/renren-admin/src/main/java/io/renren/modules/activiti/service/ActTaskService.java b/renren-admin/src/main/java/io/renren/modules/activiti/service/ActTaskService.java index 1380766c..8e85a94e 100644 --- a/renren-admin/src/main/java/io/renren/modules/activiti/service/ActTaskService.java +++ b/renren-admin/src/main/java/io/renren/modules/activiti/service/ActTaskService.java @@ -209,8 +209,6 @@ public class ActTaskService extends BaseServiceImpl { for (Task task : list) { TaskDTO dto = new TaskDTO(); this.convertTaskInfo(task, dto); - //Optional sysUserEntity = Optional.ofNullable(sysUserService.selectById(dto.getUserId())); - //dto.setUserName(sysUserEntity.get().getRealName()); Map processVariable = new LinkedHashMap<>(); if (dto.getBusinessKey().startsWith("{") || dto.getBusinessKey().startsWith("[")) { // 为json内容 (特殊处理批量) diff --git a/renren-admin/src/main/java/io/renren/modules/demandComment/controller/TDemandCommentController.java b/renren-admin/src/main/java/io/renren/modules/demandComment/controller/TDemandCommentController.java index cc292b59..1cf50309 100644 --- a/renren-admin/src/main/java/io/renren/modules/demandComment/controller/TDemandCommentController.java +++ b/renren-admin/src/main/java/io/renren/modules/demandComment/controller/TDemandCommentController.java @@ -27,6 +27,7 @@ import springfox.documentation.annotations.ApiIgnore; import javax.servlet.http.HttpServletResponse; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.stream.Collectors; @@ -97,10 +98,14 @@ public class TDemandCommentController { // @RequiresPermissions("demandComment:tdemandcomment:info") public Result get(@PathVariable("id") Long id) { TDemandCommentDTO data = tDemandCommentService.get(id); + if (null != data) { + data.setDemandDataDTO(tDemandDataService.get(data.getTargetId())); + return new Result().ok(data); + } else { + return new Result().ok(new TDemandCommentDTO()); + } - data.setDemandDataDTO(tDemandDataService.get(data.getTargetId())); - return new Result().ok(data); } @PostMapping diff --git a/renren-admin/src/main/java/io/renren/modules/fuse/controller/FuseController.java b/renren-admin/src/main/java/io/renren/modules/fuse/controller/FuseController.java index da0a3fa6..be37b1e0 100644 --- a/renren-admin/src/main/java/io/renren/modules/fuse/controller/FuseController.java +++ b/renren-admin/src/main/java/io/renren/modules/fuse/controller/FuseController.java @@ -49,12 +49,7 @@ public class FuseController { @ApiImplicitParam(name = "description", value = "融合服务描述", paramType = "query", dataType = "String"), @ApiImplicitParam(name = "type", value = "融合服务类型", paramType = "query", dataType = "String"), @ApiImplicitParam(name = "applicationArea", value = "应用领域", paramType = "query", dataType = "String"), - @ApiImplicitParam(name = "deptId", value = "所属部门", paramType = "query", dataType = "int"), - @ApiImplicitParam(name = "deptUser", value = "部门联系人", paramType = "query", dataType = "String"), - @ApiImplicitParam(name = "mobile", value = "部门联系人电话", paramType = "query", dataType = "String"), - @ApiImplicitParam(name = "provider", value = "服务商", paramType = "query", dataType = "String"), - @ApiImplicitParam(name = "providerUser", value = "服务商联系人", paramType = "query", dataType = "String"), - @ApiImplicitParam(name = "providerMobile", value = "服务商联系人电话", paramType = "query", dataType = "String") + @ApiImplicitParam(name = "deptId", value = "所属部门", paramType = "query", dataType = "int") }) public Result> page(@ApiIgnore @RequestParam Map params) { PageData page = tbFuseService.page(params); diff --git a/renren-admin/src/main/java/io/renren/modules/fuse/dao/TbFuseDao.java b/renren-admin/src/main/java/io/renren/modules/fuse/dao/TbFuseDao.java index 6a3aa6f8..2336dca0 100644 --- a/renren-admin/src/main/java/io/renren/modules/fuse/dao/TbFuseDao.java +++ b/renren-admin/src/main/java/io/renren/modules/fuse/dao/TbFuseDao.java @@ -18,6 +18,4 @@ public interface TbFuseDao extends BaseDao { List getFuseDTOList(Map params); - List> selectGroupByDeptId(); - } diff --git a/renren-admin/src/main/java/io/renren/modules/fuse/dto/TbFuseDTO.java b/renren-admin/src/main/java/io/renren/modules/fuse/dto/TbFuseDTO.java index d1d84a05..66f23296 100644 --- a/renren-admin/src/main/java/io/renren/modules/fuse/dto/TbFuseDTO.java +++ b/renren-admin/src/main/java/io/renren/modules/fuse/dto/TbFuseDTO.java @@ -29,16 +29,6 @@ public class TbFuseDTO { private String applicationArea; @ApiModelProperty(value = "所属部门") private Long deptId; - @ApiModelProperty(value = "部门联系人") - private String deptUser; - @ApiModelProperty(value = "部门联系人电话") - private String mobile; - @ApiModelProperty(value = "服务商") - private String provider; - @ApiModelProperty(value = "服务商联系人") - private String providerUser; - @ApiModelProperty(value = "服务商联系人电话") - private String providerMobile; @ApiModelProperty(value = "创建人") private Long creator; @ApiModelProperty(value = "创建时间") diff --git a/renren-admin/src/main/java/io/renren/modules/fuse/dto/TbFuseResourceDTO.java b/renren-admin/src/main/java/io/renren/modules/fuse/dto/TbFuseResourceDTO.java index 44f2e440..51e0be83 100644 --- a/renren-admin/src/main/java/io/renren/modules/fuse/dto/TbFuseResourceDTO.java +++ b/renren-admin/src/main/java/io/renren/modules/fuse/dto/TbFuseResourceDTO.java @@ -1,6 +1,5 @@ package io.renren.modules.fuse.dto; -import io.renren.modules.resource.dto.ResourceDTO; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -24,6 +23,8 @@ public class TbFuseResourceDTO { @ApiModelProperty(value = "资源挂载顺序") private String sequence; @ApiModelProperty(value = "资源") - private ResourceDTO resource; + private Object resource; + @ApiModelProperty(value = "资源类型") + private String type; } diff --git a/renren-admin/src/main/java/io/renren/modules/fuse/entity/TbFuseEntity.java b/renren-admin/src/main/java/io/renren/modules/fuse/entity/TbFuseEntity.java index 102799eb..beea7fc0 100644 --- a/renren-admin/src/main/java/io/renren/modules/fuse/entity/TbFuseEntity.java +++ b/renren-admin/src/main/java/io/renren/modules/fuse/entity/TbFuseEntity.java @@ -43,26 +43,6 @@ public class TbFuseEntity extends BaseEntity { */ @TableField(fill = FieldFill.INSERT) private Long deptId; - /** - * 部门联系人 - */ - private String deptUser; - /** - * 部门联系人电话 - */ - private String mobile; - /** - * 服务商 - */ - private String provider; - /** - * 服务商联系人 - */ - private String providerUser; - /** - * 服务商联系人电话 - */ - private String providerMobile; /** * 创建人 */ diff --git a/renren-admin/src/main/java/io/renren/modules/fuse/entity/TbFuseResourceEntity.java b/renren-admin/src/main/java/io/renren/modules/fuse/entity/TbFuseResourceEntity.java index d32186d8..f0cf9734 100644 --- a/renren-admin/src/main/java/io/renren/modules/fuse/entity/TbFuseResourceEntity.java +++ b/renren-admin/src/main/java/io/renren/modules/fuse/entity/TbFuseResourceEntity.java @@ -32,4 +32,8 @@ public class TbFuseResourceEntity { * 顺序 */ private String sequence; + /** + * 资源类型 + */ + private String type; } diff --git a/renren-admin/src/main/java/io/renren/modules/fuse/service/TbFuseService.java b/renren-admin/src/main/java/io/renren/modules/fuse/service/TbFuseService.java index bc872ee0..d731cc86 100644 --- a/renren-admin/src/main/java/io/renren/modules/fuse/service/TbFuseService.java +++ b/renren-admin/src/main/java/io/renren/modules/fuse/service/TbFuseService.java @@ -21,6 +21,4 @@ public interface TbFuseService extends CrudService { Integer deleteFuse(Long id); - Integer count(Map params); - } diff --git a/renren-admin/src/main/java/io/renren/modules/fuse/service/impl/TbFuseServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/fuse/service/impl/TbFuseServiceImpl.java index 79204729..a541dfe4 100644 --- a/renren-admin/src/main/java/io/renren/modules/fuse/service/impl/TbFuseServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/fuse/service/impl/TbFuseServiceImpl.java @@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils; import io.renren.common.constant.Constant; import io.renren.common.page.PageData; import io.renren.common.service.impl.CrudServiceImpl; +import io.renren.common.utils.Result; import io.renren.modules.fuse.dao.TbFuseAttrDao; import io.renren.modules.fuse.dao.TbFuseDao; import io.renren.modules.fuse.dao.TbFuseResourceDao; @@ -16,10 +17,17 @@ import io.renren.modules.fuse.entity.TbFuseAttrEntity; import io.renren.modules.fuse.entity.TbFuseEntity; import io.renren.modules.fuse.entity.TbFuseResourceEntity; import io.renren.modules.fuse.service.TbFuseService; +import io.renren.modules.monitor.mapper.CameraChannelMapper; +import io.renren.modules.resource.dataResource.AbstractDataResourceService; +import io.renren.modules.resource.dataResource.DataResourceFactory; +import io.renren.modules.resource.dto.GetDataResourceListDto; +import io.renren.modules.resource.dto.ResourceDTO; import io.renren.modules.resource.service.ResourceService; import io.renren.modules.resource.service.impl.ResourceServiceImpl; import io.renren.modules.resourceCollection.dao.ResourceCollectionDao; import io.renren.modules.security.user.SecurityUser; +import io.renren.modules.sys.service.SysDeptService; +import org.apache.commons.lang3.ObjectUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; @@ -50,6 +58,10 @@ public class TbFuseServiceImpl extends CrudServiceImpl getWrapper(Map params) { @@ -71,21 +83,6 @@ public class TbFuseServiceImpl extends CrudServiceImpl dtoList = baseDao.getFuseDTOList(params); + Map> dataResourceList=getDataResource(); dtoList.forEach(dto -> { - dto.setFuseResourceList(getFuseResourceByFuseId(dto.getId())); + dto.setFuseResourceList(getFuseResourceByFuseId(dto.getId(), dataResourceList)); dto.setFuseAttrList(getAttrByFuseId(dto.getId())); }); List result = dtoList.stream().skip((curPage - 1) * limit).limit(limit).collect(Collectors.toList()); return new PageData(result, dtoList.size()); } - @Override - public Integer count(Map params) { - if (params != null) { - return baseDao.selectCount(getWrapper(params)); - } else { - return baseDao.selectCount(null); - } - } - @Override public TbFuseDTO getFuseById(Long id) { TbFuseEntity fuseEntity = fuseDao.selectById(id); @@ -141,7 +130,7 @@ public class TbFuseServiceImpl extends CrudServiceImpl getFuseResourceByFuseId(Long fuseId) { + private Map> getDataResource() { + Map> result = new HashMap<>(); + Optional factory = DataResourceFactory.build(); + if (factory.isPresent()) { + GetDataResourceListDto dto = new GetDataResourceListDto().setPageNum(0).setPageSize(30); + Map dataMap = (Map) factory.get().getDataResource(dto); + if (dataMap != null) { + List> list = (List>) dataMap.get("data"); + list.stream().forEach(map -> { + if (map.containsKey("zyname")) { + result.put(map.get("guid").toString(), map); + } else { + result.put(map.get("serviceId").toString(), map); + } + }); + } + } + return result; + } + + private List getFuseResourceByFuseId(Long fuseId, Map> dataResourceMap) { + List result = new ArrayList(); QueryWrapper wrapper = new QueryWrapper(); wrapper.eq("fuse_id", fuseId); List list = fuseResourceDao.selectList(wrapper); - return list.stream().map(attr -> { - TbFuseResourceDTO dto = new TbFuseResourceDTO(); - BeanUtils.copyProperties(attr, dto); - dto.setResource(resourceService.get(dto.getResourceId())); - return dto; - }).collect(Collectors.toList()); + list.stream().filter(index -> index.getType() != null).collect(Collectors.groupingBy(TbFuseResourceEntity::getType)).forEach((type, value) -> { + if ("组件服务".equals(type)) { + result.addAll(value.stream().map(attr -> { + TbFuseResourceDTO dto = new TbFuseResourceDTO(); + BeanUtils.copyProperties(attr, dto); + ResourceDTO resourceDTO=resourceService.get(dto.getResourceId()); + resourceDTO.setDeptName(sysDeptService.get(resourceDTO.getDeptId()).getName()); + dto.setResource(resourceDTO); + return dto; + }).collect(Collectors.toList())); + } else if ("数据资源".equals(type)) { + result.addAll(value.stream().map(attr -> { + TbFuseResourceDTO dto = new TbFuseResourceDTO(); + BeanUtils.copyProperties(attr, dto); + dto.setResource(dataResourceMap.get(dto.getResourceId())); + return dto; + }).collect(Collectors.toList())); + } else if ("基础设施".equals(type)) { + result.addAll(value.stream().map(attr -> { + TbFuseResourceDTO dto = new TbFuseResourceDTO(); + BeanUtils.copyProperties(attr, dto); + dto.setResource(cameraChannelMapper.selectById(dto.getResourceId().toString())); + return dto; + }).collect(Collectors.toList())); + } + }); + return result; } @Override diff --git a/renren-admin/src/main/java/io/renren/modules/gateway/service/MonitorService.java b/renren-admin/src/main/java/io/renren/modules/gateway/service/MonitorServiceV2.java similarity index 97% rename from renren-admin/src/main/java/io/renren/modules/gateway/service/MonitorService.java rename to renren-admin/src/main/java/io/renren/modules/gateway/service/MonitorServiceV2.java index 0e935736..88265323 100644 --- a/renren-admin/src/main/java/io/renren/modules/gateway/service/MonitorService.java +++ b/renren-admin/src/main/java/io/renren/modules/gateway/service/MonitorServiceV2.java @@ -13,7 +13,7 @@ import java.util.List; import java.util.Map; @Service -public class MonitorService { +public class MonitorServiceV2 { @Value("${hisense.gateway.url}") private String gatewayDomain; diff --git a/renren-admin/src/main/java/io/renren/modules/log/task/clearLogTask.java b/renren-admin/src/main/java/io/renren/modules/log/task/ClearLogTask.java similarity index 95% rename from renren-admin/src/main/java/io/renren/modules/log/task/clearLogTask.java rename to renren-admin/src/main/java/io/renren/modules/log/task/ClearLogTask.java index 45300d47..c1a3304d 100644 --- a/renren-admin/src/main/java/io/renren/modules/log/task/clearLogTask.java +++ b/renren-admin/src/main/java/io/renren/modules/log/task/ClearLogTask.java @@ -17,9 +17,9 @@ import java.util.Date; * 清理操作日志表任务 */ @Component("clearLogTask") -public class clearLogTask implements ITask { +public class ClearLogTask implements ITask { - private static final Logger logger = LoggerFactory.getLogger(clearLogTask.class); + private static final Logger logger = LoggerFactory.getLogger(ClearLogTask.class); @Autowired private SysLogOperationDao sysLogOperationDao; diff --git a/renren-admin/src/main/java/io/renren/modules/monitor/controller/Controller.java b/renren-admin/src/main/java/io/renren/modules/monitor/controller/Controller.java index 5b8c7a23..0ff053d5 100644 --- a/renren-admin/src/main/java/io/renren/modules/monitor/controller/Controller.java +++ b/renren-admin/src/main/java/io/renren/modules/monitor/controller/Controller.java @@ -1,5 +1,6 @@ package io.renren.modules.monitor.controller; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.google.common.collect.Lists; import io.renren.modules.monitor.dto.*; @@ -151,9 +152,7 @@ public class Controller { List list = cameraChannelMapper.selectByChannelCode(channelCode); - Result success = Result.success(list); - - return success; + return Result.success(list); } @@ -170,9 +169,7 @@ public class Controller { List labels = cameraChannelMapper.selectByChannelName(channelName); - Result success = Result.success(labels); - - return success; + return Result.success(labels); } /** @@ -254,8 +251,7 @@ public class Controller { public Result selectAllByGps(Double gpsX,Double gpsY,Integer radius){ double[] around = LongLatUtil.getAround(gpsX, gpsY, radius); List c = cameraChannelMapper.selectAllByGps(around[0], around[2], around[1], around[3]); - Result success = Result.success(c); - return success; + return Result.success(c); } /** @@ -268,9 +264,7 @@ public class Controller { List