From 4d8f0c63ae998b92982fcc924198ebe2a1986a6b Mon Sep 17 00:00:00 2001 From: dinggang <2498628697@qq.com> Date: Mon, 1 Aug 2022 16:11:59 +0800 Subject: [PATCH] .. --- .../common/aspect/ActivitiNoticeAspect.java | 39 ++--- .../common/aspect/DataFilterAspect.java | 2 +- .../common/aspect/LogOperationAspect.java | 1 - .../common/config/MybatisPlusConfig.java | 10 -- .../common/config/RestTemplateConfig.java | 4 - .../controller/AbilityCenterController.java | 14 +- .../controller/AbilityCenterControllerV2.java | 22 +-- .../common/controller/CensusController.java | 85 ++++----- .../common/controller/CensusControllerV2.java | 164 ++++++++---------- .../common/controller/CensusControllerV3.java | 12 +- .../common/controller/CommentController.java | 12 +- .../controller/DemandDataController.java | 17 +- .../controller/FileUploadController.java | 18 +- .../common/controller/RejectController.java | 7 +- .../controller/ResourceMountController.java | 32 ++-- .../common/domain/BaoTouProperties.java | 2 - .../common/domain/TsingtaoProperties.java | 1 - .../handler/FieldMetaObjectHandler.java | 10 +- .../listener/InitiatorDataEntryListener.java | 13 +- .../common/utils/CodeGenerationUtils.java | 5 +- .../activiti/config/ProcessEngineConfig.java | 2 - .../controller/ActProcessController.java | 4 +- .../fuse/service/impl/TbFuseServiceImpl.java | 2 - .../TAbilityApplicationController.java | 15 +- .../modules/security/config/ShiroConfig.java | 15 -- .../modules/security/oauth2/Oauth2Realm.java | 11 +- .../security/oauth2/ShiroSessionManager.java | 48 +---- 27 files changed, 205 insertions(+), 362 deletions(-) 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 60b2cc70..ac394e2b 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 @@ -5,7 +5,6 @@ import io.renren.common.annotation.ActivitiNoticeOperation; import io.renren.modules.notice.dto.SysNoticeDTO; import io.renren.modules.notice.enums.NoticeStatusEnum; import io.renren.modules.notice.service.SysNoticeService; -import io.renren.modules.resource.dto.ResourceDTO; import io.renren.modules.resource.service.ResourceService; import io.renren.modules.sys.dto.SysDeptDTO; import io.renren.modules.sys.dto.SysRoleDTO; @@ -127,7 +126,7 @@ public class ActivitiNoticeAspect { */ private void task_complete_notice(final DelegateTask delegateTask, final ActivitiNoticeOperation activitiNoticeOperation) { Map kv = delegateTask.getVariables(); - LOGGER.error("表单:" + JSON.toJSONString(kv)); + LOGGER.error("表单:{}", JSON.toJSONString(kv)); if (work.contains(TaskListener.EVENTNAME_COMPLETE + kv.get("id").toString())) { LOGGER.error("------------出现重放------------"); return; @@ -146,7 +145,7 @@ public class ActivitiNoticeAspect { String result; Boolean termination = Boolean.valueOf(kv.get("termination") != null ? kv.get("termination").toString() : Boolean.FALSE.toString()); // 直接终结 Boolean reject = Boolean.valueOf(kv.get("reject") != null ? kv.get("reject").toString() : Boolean.FALSE.toString()); // 被拒绝 - if (termination) { + if (Boolean.TRUE.equals(termination)) { result = "终止被拒"; } else if (reject) { result = "被拒"; @@ -157,13 +156,6 @@ public class ActivitiNoticeAspect { String finalResult = result; CompletableFuture.runAsync(() -> { // 发起人 SysUserDTO userDTO = sysUserService.get(Long.valueOf(finalCreator)); - Long resourceId = null; - if (kv.containsKey("resourceId")) { - resourceId = Long.valueOf(kv.get("resourceId").toString()); - } else if (kv.containsKey("id")) { - resourceId = Long.valueOf(kv.get("id").toString()); - } - Optional resourceDTO = Optional.ofNullable(resourceService.get(resourceId)); kv.get("resourceId"); kv.get("id"); String content = "【通知】" + userDTO.getRealName() + ",您发起的" + activitiNoticeOperation.process() + " " + activitiNoticeOperation.value() + "节点" + finalResult; @@ -205,7 +197,7 @@ public class ActivitiNoticeAspect { */ private void end_notice(final DelegateExecution execution, final ActivitiNoticeOperation activitiNoticeOperation) { Map kv = execution.getVariables(); - LOGGER.error("表单:" + JSON.toJSONString(kv)); + LOGGER.error("表单:{}", JSON.toJSONString(kv)); if (work.contains(ExecutionListener.EVENTNAME_END + kv.get("id").toString())) { LOGGER.error("------------出现重放------------"); return; @@ -224,24 +216,15 @@ public class ActivitiNoticeAspect { String result; Boolean termination = Boolean.valueOf(kv.get("termination") != null ? kv.get("termination").toString() : Boolean.FALSE.toString()); // 直接终结 Boolean reject = Boolean.valueOf(kv.get("reject") != null ? kv.get("reject").toString() : Boolean.FALSE.toString()); // 被拒绝 - if (termination) { + if (Boolean.TRUE.equals(termination)) { result = "终止被拒"; - } else if (reject) { + } else if (Boolean.TRUE.equals(reject)) { result = "被拒"; } else { result = "通过"; } String finalCreator = creator; String finalResult = result; - 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.get("id").toString().contains("-")) { - resourceId = Long.valueOf(kv.get("id").toString()); - } else { - resourceId = 0L; - } - Optional resourceDTO = Optional.ofNullable(resourceService.get(resourceId)); CompletableFuture.runAsync(() -> { // 发起人 SysUserDTO userDTO = sysUserService.get(Long.valueOf(finalCreator)); kv.get("resourceId"); @@ -261,11 +244,11 @@ public class ActivitiNoticeAspect { dto.setFrom("通知"); sysNoticeService.save(dto); }, EXECUTOR).thenRunAsync(() -> { - LOGGER.error("大数据局名称:" + bigDateDeptName); + 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)); @@ -310,7 +293,7 @@ public class ActivitiNoticeAspect { */ private void assignment_notice(final DelegateTask delegateTask, final ActivitiNoticeOperation activitiNoticeOperation) { Map kv = delegateTask.getVariables(); - LOGGER.error("表单:" + JSON.toJSONString(kv)); + LOGGER.error("表单:{}", JSON.toJSONString(kv)); if (work.contains(TaskListener.EVENTNAME_ASSIGNMENT + kv.get("id").toString())) { LOGGER.error("------------出现重放------------"); return; @@ -330,9 +313,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("流程流转系统通知"); diff --git a/renren-admin/src/main/java/io/renren/common/aspect/DataFilterAspect.java b/renren-admin/src/main/java/io/renren/common/aspect/DataFilterAspect.java index c0bcf7fb..aa0b1c20 100644 --- a/renren-admin/src/main/java/io/renren/common/aspect/DataFilterAspect.java +++ b/renren-admin/src/main/java/io/renren/common/aspect/DataFilterAspect.java @@ -36,7 +36,7 @@ public class DataFilterAspect { @Before("dataFilterCut()") public void dataFilter(JoinPoint point) { Object params = point.getArgs()[0]; - if(params != null && params instanceof Map){ + if(params instanceof Map){ UserDetail user = SecurityUser.getUser(); //如果是超级管理员,则不进行数据过滤 diff --git a/renren-admin/src/main/java/io/renren/common/aspect/LogOperationAspect.java b/renren-admin/src/main/java/io/renren/common/aspect/LogOperationAspect.java index 3afb2a5e..5ec31c40 100644 --- a/renren-admin/src/main/java/io/renren/common/aspect/LogOperationAspect.java +++ b/renren-admin/src/main/java/io/renren/common/aspect/LogOperationAspect.java @@ -33,7 +33,6 @@ public class LogOperationAspect { @Pointcut("@annotation(io.renren.common.annotation.LogOperation)") public void logPointCut() { - } @Around("logPointCut()") diff --git a/renren-admin/src/main/java/io/renren/common/config/MybatisPlusConfig.java b/renren-admin/src/main/java/io/renren/common/config/MybatisPlusConfig.java index 9a3fc2e9..4215d09e 100644 --- a/renren-admin/src/main/java/io/renren/common/config/MybatisPlusConfig.java +++ b/renren-admin/src/main/java/io/renren/common/config/MybatisPlusConfig.java @@ -34,15 +34,5 @@ public class MybatisPlusConfig { return new PaginationInterceptor(); } -// @Bean -// @Order(0) -// public MybatisPlusInterceptor mybatisPlusInterceptor(){ -// MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); -// //添加分页插件 -// interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); -// //添加乐观锁插件 -// interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor()); -// return interceptor; -// } } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/common/config/RestTemplateConfig.java b/renren-admin/src/main/java/io/renren/common/config/RestTemplateConfig.java index 34ffd370..a4004984 100644 --- a/renren-admin/src/main/java/io/renren/common/config/RestTemplateConfig.java +++ b/renren-admin/src/main/java/io/renren/common/config/RestTemplateConfig.java @@ -31,10 +31,6 @@ public class RestTemplateConfig { factory.setReadTimeout(30 * 000);//单位为ms factory.setConnectTimeout(5 * 1000);//单位为ms factory.setOutputStreaming(false); - -// SocketAddress address = new InetSocketAddress("127.0.0.1", 8888); -// Proxy proxy = new Proxy(Proxy.Type.HTTP, address); -// factory.setProxy(proxy); return factory; } } diff --git a/renren-admin/src/main/java/io/renren/common/controller/AbilityCenterController.java b/renren-admin/src/main/java/io/renren/common/controller/AbilityCenterController.java index a1376531..13ecf605 100644 --- a/renren-admin/src/main/java/io/renren/common/controller/AbilityCenterController.java +++ b/renren-admin/src/main/java/io/renren/common/controller/AbilityCenterController.java @@ -62,12 +62,12 @@ public class AbilityCenterController { private final CodeGenerationUtils codeGenerationUtils = CodeGenerationUtils.getInstance(); - private static final String key = "abilityprocess"; + private static final String KEY = "abilityprocess"; - private static Map params = new HashMap() { + private static final Map params = new HashMap() { { put("isLatestVersion", true); // 取最新版本 - put("key", key); // 限定 + put("key", KEY); // 限定 } }; @@ -87,7 +87,6 @@ public class AbilityCenterController { if (page.getTotal() <= 0) { // return new Result().error("联系管理员添加流程"); } -// String applyNumber = codeGenerationUtils.getApplyNumber("NLSY"); return new Result().ok(abilityBatchApplicationDTO.getSystem().stream().map(index -> { if (index.get("resourceId") == null) { logger.error("未携带资源id"); @@ -98,7 +97,6 @@ public class AbilityCenterController { return null; } TAbilityApplicationDTO tAbilityApplicationDTO = new TAbilityApplicationDTO(); -// tAbilityApplicationDTO.setApplyNumber(applyNumber); tAbilityApplicationDTO.setArea(abilityBatchApplicationDTO.getArea()); tAbilityApplicationDTO.setAttachment(abilityBatchApplicationDTO.getAttachment()); tAbilityApplicationDTO.setBasis(abilityBatchApplicationDTO.getBasis()); @@ -121,13 +119,13 @@ public class AbilityCenterController { if (tAbilityApplicationDTO.getId() == null) { return null; } - codeGenerationUtils.setApplyNumber("NLSY", Arrays.asList(tAbilityApplicationDTO.getId()), jdbcTemplate); + codeGenerationUtils.setApplyNumber("NLSY", Collections.singletonList(tAbilityApplicationDTO.getId()), jdbcTemplate); tAbilityApplicationDTO.setCompleteEntry(Boolean.TRUE); // 仿照请求接口 /act/running/startOfBusinessKey ProcessStartDTO processStartDTO = new ProcessStartDTO(); processStartDTO.setBusinessKey(tAbilityApplicationDTO.getId().toString()); - processStartDTO.setProcessDefinitionKey(key); //限定 + processStartDTO.setProcessDefinitionKey(KEY); //限定 Map variables = oMapper.convertValue(tAbilityApplicationDTO, Map.class); processStartDTO.setVariables(variables); ProcessInstanceDTO dto = actRunningService.startOfBusinessKey(processStartDTO); @@ -139,7 +137,7 @@ public class AbilityCenterController { } }, executor); return dto; - }).filter(index -> ObjectUtil.isNotNull(index)).collect(Collectors.toList())); + }).filter(ObjectUtil::isNotNull).collect(Collectors.toList())); } 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 f8f2bb26..650d2d08 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 @@ -75,12 +75,12 @@ public class AbilityCenterControllerV2 { @Value("${big_date.name}") private String bigDateDeptName; // 大数据局名称 - private static final String key = "abilityprocess_v2"; + private static final String KEY = "abilityprocess_v2"; - private static Map params = new HashMap() { + private static final Map params = new HashMap() { { put("isLatestVersion", true); // 取最新版本 - put("key", key); // 限定 + put("key", KEY); // 限定 } }; @@ -184,7 +184,7 @@ public class AbilityCenterControllerV2 { codeGenerationUtils.setApplyNumber("NLSY", tAbilityApplicationDTOList.stream().map(TAbilityApplicationDTO::getId).collect(Collectors.toList()), jdbcTemplate); Map> temp = tAbilityApplicationDTOList.stream() - .filter(index -> index != null) + .filter(Objects::nonNull) .filter(index -> StringUtils.isNotEmpty(index.getResourceId())) .collect(Collectors.groupingBy(t -> { ResourceDTO resourceDTO = resourceService.get(Long.valueOf(t.getResourceId())); @@ -207,12 +207,12 @@ public class AbilityCenterControllerV2 { List dtoList = temp.get(deptId); CompletableFuture.runAsync(() -> { - String[] sqls_ = dtoList.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[dtoList.size()]); - jdbcTemplate.batchUpdate(sqls_); // 批量更新资源所属部门信息 + String[] sqls = dtoList.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[dtoList.size()]); + jdbcTemplate.batchUpdate(sqls); // 批量更新资源所属部门信息 logger.info("批量更新申请的资源的部门信息完成"); }, executor); - Boolean basic_facilities = dtoList.stream().map(index -> { + Boolean basicFacilities = dtoList.stream().map(index -> { Optional resourceDTOOptional = Optional.ofNullable(resourceService.get(Long.valueOf(index.getResourceId()))); if (!resourceDTOOptional.isPresent()) { // 从本库内查不到 视为其它平台的基础设施资源 return true; @@ -222,14 +222,14 @@ public class AbilityCenterControllerV2 { } return false; }).filter(index -> index).findAny().orElse(Boolean.FALSE); - logger.error("--------------------是否全是基础设施{}----------------------------------------------", basic_facilities); + logger.error("--------------------是否全是基础设施{}----------------------------------------------", basicFacilities); 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())) + processStartDTO.setBusinessKey(Boolean.TRUE.equals(basicFacilities) ? 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); //限定 + processStartDTO.setProcessDefinitionKey(KEY); //限定 AuditingBaseDTO auditingBaseDTO = new AuditingBaseDTO(); auditingBaseDTO.setCompleteEntry(Boolean.TRUE); // 首次录入 @@ -244,7 +244,7 @@ public class AbilityCenterControllerV2 { put("id", applyFlag); //申请id put("creator", user == null ? null : user.getId().toString()); // 创建人 put("userId", user == null ? null : user.getId().toString()); // 创建人 - put("basic_facilities", basic_facilities); // 是否为基础设施 + put("basic_facilities", basicFacilities); // 是否为基础设施 } }); 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 9b8183a4..a6f61edf 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 @@ -35,8 +35,8 @@ import java.util.stream.Collectors; @RequestMapping("/census/center") public class CensusController { private static final Logger logger = LoggerFactory.getLogger(CensusController.class); - private static Integer cpuNUm = Runtime.getRuntime().availableProcessors(); - private static final ExecutorService executor = Executors.newFixedThreadPool(cpuNUm); + private static final Integer CPUNUM = Runtime.getRuntime().availableProcessors(); + private static final ExecutorService executor = Executors.newFixedThreadPool(CPUNUM); @Autowired private ResourceService resourceService; @@ -80,7 +80,7 @@ public class CensusController { }; finalDbAmount.add(nullMap); }); - Long sum = finalDbAmount.stream().mapToLong(index -> Long.valueOf(index.get("amount").toString())).sum(); + Long sum = finalDbAmount.stream().mapToLong(index -> Long.parseLong(index.get("amount").toString())).sum(); Map sumMap = new HashMap() { { put("amount", sum); @@ -100,59 +100,48 @@ public class CensusController { CompletableFuture resourceAmount = CompletableFuture.supplyAsync(() -> { // 获取资源汇聚总量 Map map = (Map) resourceService.selectTotal(); List> dbAmount = (List>) map.get("total"); - Long sum = dbAmount.stream().mapToLong(index -> Long.parseLong(index.get("count").toString())).sum(); - return sum; - }, executor).thenAccept(sum -> { - result.add(new HashMap() { - { - put("amount", sum); - put("type", "资源汇聚总量"); - } - }); - }); + return dbAmount.stream().mapToLong(index -> Long.parseLong(index.get("count").toString())).sum(); + }, executor).thenAccept(sum -> result.add(new HashMap() { + { + put("amount", sum); + put("type", "资源汇聚总量"); + } + })); CompletableFuture userAmount = CompletableFuture.supplyAsync(() -> { // 获取平台用户总数 return sysUserService.countAllUser(); - }, executor).thenAccept(sum -> { - result.add(new HashMap() { - { - put("amount", sum); - put("type", "用户量"); - } - }); - }); + }, executor).thenAccept(sum -> result.add(new HashMap() { + { + put("amount", sum); + put("type", "用户量"); + } + })); CompletableFuture applyAmount = CompletableFuture.supplyAsync(() -> { // 资源申请量 return tAbilityApplicationService.countApplyAll(); - }, executor).thenAccept(sum -> { - result.add(new HashMap() { - { - put("amount", sum); - put("type", "资源申请量"); - } - }); - }); + }, executor).thenAccept(sum -> result.add(new HashMap() { + { + put("amount", sum); + put("type", "资源申请量"); + } + })); CompletableFuture deptAmount = CompletableFuture.supplyAsync(() -> { // 覆盖部门量 return resourceService.countAllDept(); - }, executor).thenAccept(sum -> { - result.add(new HashMap() { - { - put("amount", sum); - put("type", "覆盖部门量"); - } - }); - }); + }, executor).thenAccept(sum -> result.add(new HashMap() { + { + put("amount", sum); + put("type", "覆盖部门量"); + } + })); CompletableFuture pvAmount = CompletableFuture.supplyAsync(() -> { // 平台访问量 return resourceService.countAllVisits(); - }, executor).thenAccept(sum -> { - result.add(new HashMap() { - { - put("amount", sum); - put("type", "平台访问量"); - } - }); - }); + }, executor).thenAccept(sum -> result.add(new HashMap() { + { + put("amount", sum); + put("type", "平台访问量"); + } + })); CompletableFuture all = CompletableFuture.allOf(resourceAmount, userAmount, applyAmount, deptAmount, pvAmount); all.join(); result.sort(Comparator.comparing(x -> x.get("type").toString())); @@ -204,7 +193,7 @@ public class CensusController { List temp = resourceService.selectDeptProvideCount(n == null ? 24 : n); List> result = Collections.synchronizedList(new ArrayList<>()); List completableFutures = - temp.stream().mapToLong(index -> Long.valueOf(index.get("dept_id").toString())).mapToObj(deptId -> { + temp.stream().mapToLong(index -> Long.parseLong(index.get("dept_id").toString())).mapToObj(deptId -> { CompletableFuture task = CompletableFuture.supplyAsync(() -> { // 获取部门提供能力 List db = resourceService.selectDeptProvide(deptId); @@ -240,7 +229,7 @@ public class CensusController { throw new RuntimeException(e); } } - ).reversed().thenComparing(i -> i.toString())); + ).reversed().thenComparing(Object::toString)); return new Result>>().ok(result); } @@ -279,7 +268,7 @@ public class CensusController { List temp = tAbilityApplicationService.selectDeptApplyCount(n == null ? 24 : n); List> result = Collections.synchronizedList(new ArrayList<>()); List completableFutures = - temp.stream().mapToLong(index -> Long.valueOf(index.get("dept_id").toString())).mapToObj(deptId -> { + temp.stream().mapToLong(index -> Long.parseLong(index.get("dept_id").toString())).mapToObj(deptId -> { CompletableFuture task = CompletableFuture.supplyAsync(() -> { // 获取资源汇聚总量 List db = tAbilityApplicationService.selectDeptApply(deptId); 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 ac89202f..29c0d84b 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 @@ -1,6 +1,5 @@ package io.renren.common.controller; - import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.fasterxml.jackson.core.JsonProcessingException; @@ -37,7 +36,6 @@ import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; - /** * 2022.6.19 版本 */ @@ -46,11 +44,11 @@ import java.util.stream.Collectors; @RequestMapping("/census/center/v2") public class CensusControllerV2 { - private static final Integer cpuNUm = Runtime.getRuntime().availableProcessors(); + private static final Integer CPUNUM = Runtime.getRuntime().availableProcessors(); private static final OkHttpClient client = new OkHttpClient().newBuilder() .connectTimeout(1, TimeUnit.MINUTES) .readTimeout(1, TimeUnit.MINUTES) - .connectionPool(new ConnectionPool(cpuNUm * 2, 2, TimeUnit.MINUTES)) + .connectionPool(new ConnectionPool(CPUNUM * 2, 2, TimeUnit.MINUTES)) .retryOnConnectionFailure(false) .build(); @@ -88,25 +86,21 @@ public class CensusControllerV2 { CompletableFuture userAmount = CompletableFuture.supplyAsync(() -> { // 获取平台用户总数 return sysUserService.countAllUser(); - }).thenAccept(sum -> { - result.add(new HashMap() { - { - put("amount", sum); - put("type", "用户量"); - } - }); - }); + }).thenAccept(sum -> result.add(new HashMap() { + { + put("amount", sum); + put("type", "用户量"); + } + })); CompletableFuture pvAmount = CompletableFuture.supplyAsync(() -> { // 平台访问量 return resourceService.countAllVisits(); - }).thenAccept(sum -> { - result.add(new HashMap() { - { - put("amount", sum); - put("type", "平台访问量"); - } - }); - }); + }).thenAccept(sum -> result.add(new HashMap() { + { + put("amount", sum); + put("type", "平台访问量"); + } + })); CompletableFuture all = CompletableFuture.allOf(userAmount, pvAmount); all.join(); result.sort(Comparator.comparing(x -> x.get("type").toString())); @@ -135,14 +129,12 @@ public class CensusControllerV2 { CompletableFuture allApplicationAmount = 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", "总应用数"); + } + })); CompletableFuture buildingApplicationAmount = CompletableFuture.supplyAsync(() -> { // 获取平台建设中数目 return jdbcTemplate.queryForObject("SELECT COUNT(DISTINCT data_resource_id) FROM tb_data_attr WHERE EXISTS ( SELECT id FROM tb_data_resource WHERE tb_data_resource.id = tb_data_attr.data_resource_id AND tb_data_resource.del_flag = 0 ) AND attr_type = '应用状态' AND attr_value = '建设中';", Long.class); }).thenAccept(sum -> { @@ -155,14 +147,12 @@ public class CensusControllerV2 { }); CompletableFuture endApplicationAmount = CompletableFuture.supplyAsync(() -> { // 获取平台建设中数目 return jdbcTemplate.queryForObject("SELECT COUNT(DISTINCT data_resource_id) FROM tb_data_attr WHERE EXISTS ( SELECT id FROM tb_data_resource WHERE tb_data_resource.id = tb_data_attr.data_resource_id AND tb_data_resource.del_flag = 0 ) AND attr_type = '应用状态' AND attr_value = '停用';", Long.class); - }).thenAccept(sum -> { - result.add(new HashMap() { - { - put("amount", sum); - put("type", "停用应用数"); - } - }); - }); + }).thenAccept(sum -> result.add(new HashMap() { + { + put("amount", sum); + put("type", "停用应用数"); + } + })); CompletableFuture all = CompletableFuture.allOf(allApplicationAmount, buildingApplicationAmount, endApplicationAmount); all.join(); return new Result().ok(result); @@ -213,7 +203,7 @@ public class CensusControllerV2 { re.put("deptName", sysDeptService.get(Long.valueOf(index)).getName()); re.put("count", i.get(index).stream().mapToLong(index_ -> index_.values().stream().mapToLong(count_ -> count_).sum()).sum()); return re; - }).filter(index -> ObjectUtils.allNotNull(index)).collect(Collectors.toList()); + }).filter(ObjectUtils::allNotNull).collect(Collectors.toList()); result.sort(Comparator.comparing(x -> { ObjectMapper mapper = new ObjectMapper(); try { @@ -235,58 +225,48 @@ public class CensusControllerV2 { List> result = new CopyOnWriteArrayList<>(); CompletableFuture allAssemblyAmount = 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", "上架总数"); + } + })); String sqlFormat = "SELECT COUNT( tda.data_resource_id ) FROM tb_data_attr tda JOIN tb_data_resource tdr ON tda.data_resource_id = tdr.id AND MATCH ( tda.attr_value) AGAINST ( '%s' IN BOOLEAN MODE) AND tda.attr_type = '组件类型' AND tda.del_flag = 0 AND tdr.del_flag = 0;"; CompletableFuture aiAssemblyAmount = CompletableFuture.supplyAsync(() -> { // 获取平台智能算法组件服务数目 return jdbcTemplate.queryForObject(String.format(sqlFormat, "智能算法"), Long.class); - }).thenAccept(sum -> { - result.add(new HashMap() { - { - put("amount", sum); - put("type", "智能算法"); - } - }); - }); + }).thenAccept(sum -> result.add(new HashMap() { + { + put("amount", sum); + put("type", "智能算法"); + } + })); CompletableFuture gisAssemblyAmount = CompletableFuture.supplyAsync(() -> { // 获取平台图层服务组件服务数目 return jdbcTemplate.queryForObject(String.format(sqlFormat, "图层服务"), Long.class); - }).thenAccept(sum -> { - result.add(new HashMap() { - { - put("amount", sum); - put("type", "图层服务"); - } - }); - }); + }).thenAccept(sum -> result.add(new HashMap() { + { + put("amount", sum); + put("type", "图层服务"); + } + })); CompletableFuture busAssemblyAmount = CompletableFuture.supplyAsync(() -> { // 获取平台业务组件组件服务数目 return jdbcTemplate.queryForObject(String.format(sqlFormat, "业务组件"), Long.class); - }).thenAccept(sum -> { - result.add(new HashMap() { - { - put("amount", sum); - put("type", "业务组件"); - } - }); - }); + }).thenAccept(sum -> result.add(new HashMap() { + { + put("amount", sum); + put("type", "业务组件"); + } + })); CompletableFuture devAssemblyAmount = CompletableFuture.supplyAsync(() -> { // 获取平台业务组件组件服务数目 return jdbcTemplate.queryForObject(String.format(sqlFormat, "开发组件"), Long.class); - }).thenAccept(sum -> { - result.add(new HashMap() { - { - put("amount", sum); - put("type", "开发组件"); - } - }); - }); + }).thenAccept(sum -> result.add(new HashMap() { + { + put("amount", sum); + put("type", "开发组件"); + } + })); CompletableFuture all = CompletableFuture.allOf(allAssemblyAmount, aiAssemblyAmount, gisAssemblyAmount, busAssemblyAmount, devAssemblyAmount); all.join(); return new Result().ok(result); @@ -299,24 +279,20 @@ public class CensusControllerV2 { List> result = new CopyOnWriteArrayList<>(); CompletableFuture allKnowledgeAmount = 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", "知识库上架总量"); + } + })); CompletableFuture allKnowledgeVisitsAmount = CompletableFuture.supplyAsync(() -> { // 获取平台知识库浏览量 return jdbcTemplate.queryForObject("SELECT IFNULL(SUM(visits),0) visits FROM tb_data_resource WHERE type ='知识库' AND del_flag = 0;", Long.class); - }).thenAccept(sum -> { - result.add(new HashMap() { - { - put("amount", sum == null ? 0L : sum); - put("type", "知识库总浏览量"); - } - }); - }); + }).thenAccept(sum -> result.add(new HashMap() { + { + put("amount", sum == null ? 0L : sum); + put("type", "知识库总浏览量"); + } + })); CompletableFuture all = CompletableFuture.allOf(allKnowledgeAmount, allKnowledgeVisitsAmount); all.join(); return new Result().ok(result); @@ -400,8 +376,6 @@ public class CensusControllerV2 { @LogOperation("能力云图-数据资源简况") public Result>> dataResourceInfo() { List> result = new CopyOnWriteArrayList<>(); - CompletableFuture allAmount = null; - CompletableFuture applyInfo = null; // 申请情况 switch (Constant.ProjectPlace.getByFlag(projectPlace)) { case BAOTOU: { // TODO 包头 result.add(new HashMap() { diff --git a/renren-admin/src/main/java/io/renren/common/controller/CensusControllerV3.java b/renren-admin/src/main/java/io/renren/common/controller/CensusControllerV3.java index a5a79c98..3a351dbb 100644 --- a/renren-admin/src/main/java/io/renren/common/controller/CensusControllerV3.java +++ b/renren-admin/src/main/java/io/renren/common/controller/CensusControllerV3.java @@ -77,7 +77,6 @@ public class CensusControllerV3 { } String type = params.get("resourceType").toString(); - List> list = new ArrayList<>(); switch (type) { case "组件服务": @@ -124,22 +123,15 @@ public class CensusControllerV3 { } String type = params.get("resourceType").toString(); - List> list = new ArrayList<>(); switch (type) { case "组件服务": PageData> pageData = resourceService.resourceBusinessUseDetails(params); return new Result>>().ok(pageData); - case "应用资源": - return null; case "基础设施": + case "数据资源": PageData> pageData1 = resourceService.resourceDatasUseDetails(params); return new Result>>().ok(pageData1); - case "数据资源": - PageData> pageData2 = resourceService.resourceDatasUseDetails(params); - return new Result>>().ok(pageData2); - case "知识库": - return null; default: return null; } @@ -429,7 +421,7 @@ public class CensusControllerV3 { @LogOperation("知识库分布情况") @ApiImplicitParam(name = "id", value = "行政部门编号", paramType = "query", dataType = "Long") public Result>> knowledgeBaseDistriDetail(Long id) { - List> result = new ArrayList<>(); + List> result; Object[] ps = {id, id}; result = jdbcTemplate.queryForList("SELECT COUNT(a.id) AS num,a.attr_value FROM tb_data_attr a INNER JOIN tb_data_resource b ON a.data_resource_id = b.id\n" + "INNER JOIN sys_dept c on b.dept_id = c.id WHERE a.attr_type = '文件类型' AND a.del_flag = 0 AND b.type = '知识库' AND b.del_flag = 0 AND \n" + diff --git a/renren-admin/src/main/java/io/renren/common/controller/CommentController.java b/renren-admin/src/main/java/io/renren/common/controller/CommentController.java index 33c9ef84..78a4a18b 100644 --- a/renren-admin/src/main/java/io/renren/common/controller/CommentController.java +++ b/renren-admin/src/main/java/io/renren/common/controller/CommentController.java @@ -1,6 +1,5 @@ package io.renren.common.controller; - import io.renren.common.annotation.LogOperation; import io.renren.common.page.PageData; import io.renren.common.utils.CodeGenerationUtils; @@ -35,8 +34,8 @@ import java.util.concurrent.Executors; @RestController @RequestMapping("/comment/center") public class CommentController { - private static Integer cpuNUm = Runtime.getRuntime().availableProcessors(); - private static final ExecutorService executor = Executors.newFixedThreadPool(cpuNUm); + private static final Integer CPUNUM = Runtime.getRuntime().availableProcessors(); + private static final ExecutorService executor = Executors.newFixedThreadPool(CPUNUM); private static final ObjectMapper oMapper = new ObjectMapper(); @Autowired @@ -54,12 +53,12 @@ public class CommentController { private static final Logger logger = LoggerFactory.getLogger(CommentController.class); - private static final String key = "comment_review"; + private static final String KEY = "comment_review"; private static Map params = new HashMap() { { put("isLatestVersion", true); // 取最新版本 - put("key", key); // 限定 + put("key", KEY); // 限定 } }; @@ -85,7 +84,6 @@ public class CommentController { if (tDemandCommentDTO.getId() == null) { return new Result().error("该评论不存在"); } -// tDemandCommentDTO.setApplyNumber(codeGenerationUtils.getApplyNumber("XQPL")); tDemandCommentDTO.setDelFlag(2); // 待审核 tDemandCommentDTO.setCompleteEntry(Boolean.TRUE); tDemandCommentService.update(tDemandCommentDTO); @@ -94,7 +92,7 @@ public class CommentController { // 仿照请求接口 /act/running/startOfBusinessKey ProcessStartDTO processStartDTO = new ProcessStartDTO(); processStartDTO.setBusinessKey(tDemandCommentDTO.getId().toString()); - processStartDTO.setProcessDefinitionKey(key); //限定 + processStartDTO.setProcessDefinitionKey(KEY); //限定 Map variables = oMapper.convertValue(tDemandCommentDTO, Map.class); processStartDTO.setVariables(variables); diff --git a/renren-admin/src/main/java/io/renren/common/controller/DemandDataController.java b/renren-admin/src/main/java/io/renren/common/controller/DemandDataController.java index 46b23e1f..fb103716 100644 --- a/renren-admin/src/main/java/io/renren/common/controller/DemandDataController.java +++ b/renren-admin/src/main/java/io/renren/common/controller/DemandDataController.java @@ -1,6 +1,6 @@ package io.renren.common.controller; - +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import io.renren.common.annotation.LogOperation; import io.renren.common.page.PageData; @@ -51,12 +51,12 @@ public class DemandDataController { private final CodeGenerationUtils codeGenerationUtils = CodeGenerationUtils.getInstance(); - private static final String key = "abilitydemandapply"; + private static final String KEY = "abilitydemandapply"; private static Map params = new HashMap() { { put("isLatestVersion", true); // 取最新版本 - put("key", key); // 限定 能力资源上架 + put("key", KEY); // 限定 能力资源上架 } }; @@ -67,13 +67,12 @@ public class DemandDataController { // 仿照请求接口 /act/process/lastestPage PageData> page = actProcessService.page(params); if (page.getTotal() <= 0) { // - return new Result().error("联系管理员添加流程:" + key); + return new Result().error("联系管理员添加流程:" + KEY); } logger.info("---------------------------------------------------"); - logger.info(JSONObject.toJSONString(tDemandDataDTO)); + logger.info(JSON.toJSONString(tDemandDataDTO)); logger.info("####################################################"); tDemandDataDTO.setFlag(TDemandDataEntityFlag.UNDER_REVIEW.getFlag()); -// tDemandDataDTO.setApplyNumber(codeGenerationUtils.getApplyNumber("NLXQ")); ValidatorUtils.validateEntity(tDemandDataDTO, AddGroup.class, DefaultGroup.class); tDemandDataService.save(tDemandDataDTO); @@ -86,18 +85,18 @@ public class DemandDataController { // 仿照请求接口 /act/running/startOfBusinessKey ProcessStartDTO processStartDTO = new ProcessStartDTO(); processStartDTO.setBusinessKey(tDemandDataDTO.getId().toString()); - processStartDTO.setProcessDefinitionKey(key); // 限定资源上架 + processStartDTO.setProcessDefinitionKey(KEY); // 限定资源上架 Map variables = oMapper.convertValue(tDemandDataDTO, Map.class); processStartDTO.setVariables(variables); ProcessInstanceDTO dto = actRunningService.startOfBusinessKey(processStartDTO); logger.info("-------------------2.启动流程成功--------------------------"); - logger.info("ProcessInstanceDTO.getBusinessKey:" + dto.getBusinessKey()); + logger.info("ProcessInstanceDTO.getBusinessKey:{}", dto.getBusinessKey()); if (Long.valueOf(dto.getBusinessKey()) != null) { // 仿照请求接口 /processForm/tabilityapplication/updateInstanceId tDemandDataService.updateInstanceId(dto.getProcessInstanceId(), Long.valueOf(dto.getBusinessKey())); logger.info("-------------------更新updateInstanceId.成功--------------------------"); - logger.info("ProcessInstanceDTO.getProcessInstanceId:" + dto.getProcessInstanceId()); + logger.info("ProcessInstanceDTO.getProcessInstanceId:{}", dto.getProcessInstanceId()); } return new Result().ok(dto); diff --git a/renren-admin/src/main/java/io/renren/common/controller/FileUploadController.java b/renren-admin/src/main/java/io/renren/common/controller/FileUploadController.java index f110293b..035a05dd 100644 --- a/renren-admin/src/main/java/io/renren/common/controller/FileUploadController.java +++ b/renren-admin/src/main/java/io/renren/common/controller/FileUploadController.java @@ -27,13 +27,13 @@ public class FileUploadController { @Value("${resource.path}") private String uploadPath; @Value("${resource.root_url}") - private String root_url; + private String rootUrl; @Value("${server.servlet.context-path}") - private String context_path; + private String contextPath; private static final Logger logger = LoggerFactory.getLogger(FileUploadController.class); - private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd/"); + private static final SimpleDateFormat SIMPLE_DATE_FORMAT = new SimpleDateFormat("yyyy/MM/dd/"); @PostMapping("/upload") @ApiOperation("文件上传") @@ -43,8 +43,8 @@ public class FileUploadController { }) public Result upload(@RequestParam("file") MultipartFile uploadFile, HttpServletRequest request) { - logger.info("上传文件:" + uploadFile.getOriginalFilename()); - String format = sdf.format(new Date()); + logger.info("上传文件:{}", uploadFile.getOriginalFilename()); + String format = SIMPLE_DATE_FORMAT.format(new Date()); File folder = new File(uploadPath + "upload" + File.separator + format); logger.info(uploadPath + format); if (!folder.isDirectory()) { @@ -52,15 +52,15 @@ public class FileUploadController { } // 对上传的文件重命名,避免文件重名 String oldName = uploadFile.getOriginalFilename(); - String newName = UUID.randomUUID().toString() - + oldName.substring(oldName.lastIndexOf("."), oldName.length()); + String newName = UUID.randomUUID() + + oldName.substring(oldName.lastIndexOf(".")); try { // 文件保存 uploadFile.transferTo(new File(folder, newName)); // 返回上传文件的访问路径 - String filePath = request.getScheme() + "://" + root_url - + ":" + request.getServerPort() + context_path + "/upload/" + format + newName; + String filePath = request.getScheme() + "://" + rootUrl + + ":" + request.getServerPort() + contextPath + "/upload/" + format + newName; return new Result().ok(filePath); } catch (IOException e) { return new Result().error(e.getMessage()); diff --git a/renren-admin/src/main/java/io/renren/common/controller/RejectController.java b/renren-admin/src/main/java/io/renren/common/controller/RejectController.java index 4173c3ee..46892259 100644 --- a/renren-admin/src/main/java/io/renren/common/controller/RejectController.java +++ b/renren-admin/src/main/java/io/renren/common/controller/RejectController.java @@ -25,7 +25,7 @@ import java.util.concurrent.atomic.AtomicReference; @RestController @RequestMapping("/reject/center") public class RejectController { - private static Logger logger = LoggerFactory.getLogger(RejectController.class); + private static final Logger logger = LoggerFactory.getLogger(RejectController.class); @Autowired protected TaskService taskService; @Autowired @@ -45,7 +45,6 @@ public class RejectController { Optional taskOptional = Optional.ofNullable(taskService.createTaskQuery().taskId(taskId).includeProcessVariables().singleResult()); taskOptional.ifPresent(task -> { Map combineResultMap = new LinkedHashMap<>(); -// combineResultMap.putAll(task.getProcessVariables()); combineResultMap.putAll(params); if (combineResultMap.containsKey("parameterContent")) { // 上架申请特殊处理 combineResultMap.remove("parameterContent"); @@ -55,7 +54,7 @@ public class RejectController { taskService.removeVariable(task.getId(), "parameterContent"); taskService.removeVariable(task.getId(), "resourceDTO"); taskService.setVariables(task.getId(), combineResultMap); // 更新 - logger.error("-----------" + JSON.toJSONString(combineResultMap)); + logger.error("-----------{}", JSON.toJSONString(combineResultMap)); taskService.setVariable(task.getId(), "backToFirst", Boolean.FALSE); // 标识驳回标签false taskService.setVariable(task.getId(), "completeEntry", Boolean.FALSE); // 标志为非首次录入 taskService.setVariable(task.getId(), "reject", Boolean.FALSE); // 标识流程中是否存在拒绝false @@ -65,7 +64,7 @@ public class RejectController { String name = userDTOOptional.isPresent() ? userDTOOptional.get().getRealName() : ""; actTaskService.completeTask(task.getId(), name + "重新发起审核"); result.set(new Result().ok(name + "重新发起审核成功")); - logger.error(name + "重新发起审核成功"); + logger.error("{}重新发起审核成功", name); }); return result.get(); } 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 53f4ae88..84280e3f 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 @@ -1,8 +1,8 @@ package io.renren.common.controller; - import cn.hutool.core.util.ObjectUtil; import cn.hutool.crypto.SecureUtil; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import io.renren.common.annotation.LogOperation; import io.renren.common.page.PageData; @@ -75,21 +75,21 @@ public class ResourceMountController { @Value("${big_date.name}") private String bigDateDeptName; // 大数据局名称 - private static final String apply_key = "resourcemountapply"; // 资源上架 + private static final String APPLY_KEY = "resourcemountapply"; // 资源上架 - private static final String undercarriage_key = "resourcundercarriageapply"; // 资源下架 + private static final String UNDERCARRIAGE_KEY = "resourcundercarriageapply"; // 资源下架 private static final Map apply_params = new HashMap() { { put("isLatestVersion", true); // 取最新版本 - put("key", apply_key); // 限定 能力资源上架 + put("key", APPLY_KEY); // 限定 能力资源上架 } }; private static final Map undercarriage_params = new HashMap() { { put("isLatestVersion", true); // 取最新版本 - put("key", undercarriage_key); // 限定 资源下架 + put("key", UNDERCARRIAGE_KEY); // 限定 资源下架 } }; @@ -112,11 +112,10 @@ public class ResourceMountController { tResourceMountApplyDTO.setDeptId(tResourceBatchMountApplyDTO.getDeptId()); tResourceMountApplyDTO.setUserId(tResourceBatchMountApplyDTO.getUserId()); tResourceMountApplyDTO.setUserName(tResourceBatchMountApplyDTO.getUserName()); - tResourceMountApplyDTO.setParameterContent(JSONObject.toJSONString(index)); - tResourceMountApplyDTO.setParameterContentMd5(SecureUtil.md5(JSONObject.toJSONString(index))); + tResourceMountApplyDTO.setParameterContent(JSON.toJSONString(index)); + tResourceMountApplyDTO.setParameterContentMd5(SecureUtil.md5(JSON.toJSONString(index))); tResourceMountApplyDTO.setResourceDTO(index); tResourceMountApplyDTO.setEnclosure(index.getEnclosure()); -// tResourceMountApplyDTO.setApplyNumber(codeGenerationUtils.getApplyNumber("NLSJ")); try { tResourceMountApplyDTO.setResourceId(tResourceMountApplyDTO.getResourceDTO().getId()); } catch (Exception e) { @@ -151,22 +150,22 @@ public class ResourceMountController { // 仿照请求接口 /act/running/startOfBusinessKey ProcessStartDTO processStartDTO = new ProcessStartDTO(); processStartDTO.setBusinessKey(tResourceMountApplyDTO.getId().toString()); - processStartDTO.setProcessDefinitionKey(apply_key); // 限定资源上架 + processStartDTO.setProcessDefinitionKey(APPLY_KEY); // 限定资源上架 Map variables = oMapper.convertValue(tResourceMountApplyDTO, Map.class); processStartDTO.setVariables(variables); ProcessInstanceDTO dto = actRunningService.startOfBusinessKey(processStartDTO); logger.info("-------------------2.启动流程成功--------------------------"); - logger.info("ProcessInstanceDTO.getBusinessKey:" + dto.getBusinessKey()); + logger.info("ProcessInstanceDTO.getBusinessKey:{}", dto.getBusinessKey()); if (Long.valueOf(dto.getBusinessKey()) != null) { // 仿照请求接口 /processForm/tabilityapplication/updateInstanceId tResourceMountApplyService.updateInstanceId(dto.getProcessInstanceId(), Long.valueOf(dto.getBusinessKey())); logger.info("-------------------更新updateInstanceId.成功--------------------------"); - logger.info("ProcessInstanceDTO.getProcessInstanceId:" + dto.getProcessInstanceId()); + logger.info("ProcessInstanceDTO.getProcessInstanceId:{}", dto.getProcessInstanceId()); } return dto; - }).filter(index -> ObjectUtil.isNotNull(index)).collect(Collectors.toList())); + }).filter(ObjectUtil::isNotNull).collect(Collectors.toList())); } @PostMapping(value = "/undercarriage") @@ -187,7 +186,7 @@ public class ResourceMountController { Optional resourceDTO = Optional.ofNullable(resourceService.get(resourceId)); if (resourceDTO.isPresent()) { TaskQuery taskQuery = taskService.createTaskQuery(); - long task = taskQuery.active().processDefinitionKey(undercarriage_key).processInstanceBusinessKey(resourceId.toString()).count(); + long task = taskQuery.active().processDefinitionKey(UNDERCARRIAGE_KEY).processInstanceBusinessKey(resourceId.toString()).count(); return task > 0; } else { return true; @@ -199,11 +198,10 @@ public class ResourceMountController { return new Result().ok(tResourceUndercarriageApplyDTO.getResource().stream().map(index -> { List dtoList = new ArrayList<>(); Long resourceId = Long.valueOf(index.get("resourceId")); -// String resourceName = index.get("resourceName"); Optional resourceDTO = Optional.ofNullable(resourceService.get(resourceId)); resourceDTO.ifPresent(dto -> { TaskQuery taskQuery = taskService.createTaskQuery(); - long task = taskQuery.active().processDefinitionKey(undercarriage_key).processInstanceBusinessKey(resourceId.toString()).count(); + long task = taskQuery.active().processDefinitionKey(UNDERCARRIAGE_KEY).processInstanceBusinessKey(resourceId.toString()).count(); if (task > 0) { logger.error("该资源已发起下架"); throw new RuntimeException("该资源已发起下架"); @@ -226,13 +224,13 @@ public class ResourceMountController { // 仿照请求接口 /act/running/startOfBusinessKey ProcessStartDTO processStartDTO = new ProcessStartDTO(); processStartDTO.setBusinessKey(resourceId.toString()); - processStartDTO.setProcessDefinitionKey(undercarriage_key); // 限定资源下架 + processStartDTO.setProcessDefinitionKey(UNDERCARRIAGE_KEY); // 限定资源下架 Map variables = oMapper.convertValue(dto, Map.class); processStartDTO.setVariables(variables); ProcessInstanceDTO index_ = actRunningService.startOfBusinessKey(processStartDTO); logger.info("-------------------2.启动流程成功--------------------------"); - logger.info("ProcessInstanceDTO.getBusinessKey:" + index_.getBusinessKey()); + logger.info("ProcessInstanceDTO.getBusinessKey:{}", index_.getBusinessKey()); dtoList.add(index_); }); return dtoList.stream().findAny().orElse(null); diff --git a/renren-admin/src/main/java/io/renren/common/domain/BaoTouProperties.java b/renren-admin/src/main/java/io/renren/common/domain/BaoTouProperties.java index ba42981b..ecb3e82e 100644 --- a/renren-admin/src/main/java/io/renren/common/domain/BaoTouProperties.java +++ b/renren-admin/src/main/java/io/renren/common/domain/BaoTouProperties.java @@ -1,12 +1,10 @@ package io.renren.common.domain; - import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.PropertySource; import org.springframework.stereotype.Component; - /** * 包头区域配置项 */ diff --git a/renren-admin/src/main/java/io/renren/common/domain/TsingtaoProperties.java b/renren-admin/src/main/java/io/renren/common/domain/TsingtaoProperties.java index e00d2ff9..6bd7a177 100644 --- a/renren-admin/src/main/java/io/renren/common/domain/TsingtaoProperties.java +++ b/renren-admin/src/main/java/io/renren/common/domain/TsingtaoProperties.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; diff --git a/renren-admin/src/main/java/io/renren/common/handler/FieldMetaObjectHandler.java b/renren-admin/src/main/java/io/renren/common/handler/FieldMetaObjectHandler.java index 73ec0c3d..84cbbbc7 100644 --- a/renren-admin/src/main/java/io/renren/common/handler/FieldMetaObjectHandler.java +++ b/renren-admin/src/main/java/io/renren/common/handler/FieldMetaObjectHandler.java @@ -14,11 +14,11 @@ import java.util.Date; */ @Component public class FieldMetaObjectHandler implements MetaObjectHandler { - private final static String CREATE_DATE = "createDate"; - private final static String CREATOR = "creator"; - private final static String UPDATE_DATE = "updateDate"; - private final static String UPDATER = "updater"; - private final static String DEPT_ID = "deptId"; + private static final String CREATE_DATE = "createDate"; + private static final String CREATOR = "creator"; + private static final String UPDATE_DATE = "updateDate"; + private static final String UPDATER = "updater"; + private static final String DEPT_ID = "deptId"; @Override public void insertFill(MetaObject metaObject) { diff --git a/renren-admin/src/main/java/io/renren/common/listener/InitiatorDataEntryListener.java b/renren-admin/src/main/java/io/renren/common/listener/InitiatorDataEntryListener.java index 35878a58..bc7507ea 100644 --- a/renren-admin/src/main/java/io/renren/common/listener/InitiatorDataEntryListener.java +++ b/renren-admin/src/main/java/io/renren/common/listener/InitiatorDataEntryListener.java @@ -30,18 +30,16 @@ public class InitiatorDataEntryListener implements TaskListener { @Override public void notify(DelegateTask delegateTask) { logger.error("----------------------流程发起人录入表单节点---------------------------"); - logger.error("事件类型:" + delegateTask.getEventName()); + logger.error("事件类型:{}", delegateTask.getEventName()); final String eventName = delegateTask.getEventName(); - switch (eventName) { - case EVENTNAME_CREATE: - create(delegateTask); - break; + if (EVENTNAME_CREATE.equals(eventName)) { + create(delegateTask); } } private void create(DelegateTask delegateTask) { Map kv = delegateTask.getVariables(); - logger.error("录入表单:" + kv.toString()); + logger.error("录入表单:{}", kv.toString()); if (kv.containsKey("creator")) { // 表单存在创建者 taskService.setAssignee(delegateTask.getId(), kv.get("creator").toString()); taskService.setOwner(delegateTask.getId(), kv.get("creator").toString()); // 指定流程所有人 @@ -58,13 +56,12 @@ public class InitiatorDataEntryListener implements TaskListener { if (auditingBaseDTO.getBackToFirst() != null && auditingBaseDTO.getBackToFirst()) { logger.error("被驳回,需修改后重新提交"); } else { - if (auditingBaseDTO.getCompleteEntry()) { + if (Boolean.TRUE.equals(auditingBaseDTO.getCompleteEntry())) { taskService.addComment(delegateTask.getId(), delegateTask.getProcessInstanceId(), "完成申请提交"); taskService.complete(delegateTask.getId(), delegateTask.getVariables()); logger.error("首次录入,自动审核通过!"); } } logger.error("----------完成录入表单-----------"); - return; } } 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 7d89bdb5..74e3514d 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 @@ -31,7 +31,7 @@ public class CodeGenerationUtils { */ enum CodeGenerationUtilsEnum { INSTANCE; - private CodeGenerationUtils codeGenerationUtils; + private final CodeGenerationUtils codeGenerationUtils; CodeGenerationUtilsEnum() { codeGenerationUtils = new CodeGenerationUtils(); @@ -86,6 +86,8 @@ public class CodeGenerationUtils { case "NLXJ": tableName = "tb_data_resource"; break; + default: + break; } lock.lock(); String sql = "SELECT SUBSTR(apply_number, 5) FROM " + tableName + @@ -99,7 +101,6 @@ public class CodeGenerationUtils { String s = jdbcTemplate.queryForObject(sql, String.class); no = applyNumberPattern.substring(0, 4) + (Long.parseLong(s) + 1); } catch (Exception e) { - logger.error("流水号生成失败", e); no = applyNumberPattern + "0001"; } finally { try { diff --git a/renren-admin/src/main/java/io/renren/modules/activiti/config/ProcessEngineConfig.java b/renren-admin/src/main/java/io/renren/modules/activiti/config/ProcessEngineConfig.java index 6474d469..ebdfce32 100644 --- a/renren-admin/src/main/java/io/renren/modules/activiti/config/ProcessEngineConfig.java +++ b/renren-admin/src/main/java/io/renren/modules/activiti/config/ProcessEngineConfig.java @@ -20,7 +20,5 @@ public class ProcessEngineConfig implements ProcessEngineConfigurationConfigurer processEngineConfiguration.setJobExecutorActivate(false); processEngineConfiguration.setAsyncExecutorEnabled(false); - //自定义流程图样式 - //processEngineConfiguration.setProcessDiagramGenerator(customProcessDiagramGenerator); } } diff --git a/renren-admin/src/main/java/io/renren/modules/activiti/controller/ActProcessController.java b/renren-admin/src/main/java/io/renren/modules/activiti/controller/ActProcessController.java index 04498ea0..03bd30c9 100644 --- a/renren-admin/src/main/java/io/renren/modules/activiti/controller/ActProcessController.java +++ b/renren-admin/src/main/java/io/renren/modules/activiti/controller/ActProcessController.java @@ -145,9 +145,9 @@ public class ActProcessController { InputStream resourceAsStream = actProcessService.getResourceAsStream(deploymentId, resourceName); String[] fileNames = resourceName.split("\\."); if(fileNames.length>1){ - if(fileNames[fileNames.length-1].toLowerCase().equals("png")){ + if(fileNames[fileNames.length-1].equalsIgnoreCase("png")){ response.setHeader("Content-Type","image/png"); - } else if(fileNames[fileNames.length-1].toLowerCase().equals("xml")){ + } else if(fileNames[fileNames.length-1].equalsIgnoreCase("xml")){ response.setHeader("Content-Type", "text/xml"); response.setHeader("Content-Disposition", "attachment; filename=" + java.net.URLEncoder.encode(resourceName, "UTF-8")); } 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 a541dfe4..a705817c 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,7 +6,6 @@ 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; @@ -27,7 +26,6 @@ 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; diff --git a/renren-admin/src/main/java/io/renren/modules/processForm/controller/TAbilityApplicationController.java b/renren-admin/src/main/java/io/renren/modules/processForm/controller/TAbilityApplicationController.java index 4d0b84d8..7bd124f1 100644 --- a/renren-admin/src/main/java/io/renren/modules/processForm/controller/TAbilityApplicationController.java +++ b/renren-admin/src/main/java/io/renren/modules/processForm/controller/TAbilityApplicationController.java @@ -15,7 +15,6 @@ import io.renren.common.validator.group.DefaultGroup; import io.renren.common.validator.group.UpdateGroup; import io.renren.modules.activiti.dto.HistoryDetailDTO; import io.renren.modules.activiti.service.ActivitiService; -import io.renren.modules.monitor.dto.CameraChannelDto1; import io.renren.modules.monitor.mapper.CameraChannelMapper; import io.renren.modules.processForm.dao.TAbilityApplicationDao; import io.renren.modules.processForm.dto.TAbilityApplicationDTO; @@ -43,10 +42,7 @@ import springfox.documentation.annotations.ApiIgnore; import javax.servlet.http.HttpServletResponse; import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; /** @@ -148,7 +144,7 @@ public class TAbilityApplicationController { } else { String sql = String.format("SELECT IF(COUNT(id) >0 ,FALSE,TRUE) AS ended FROM t_ability_application WHERE apply_flag = '%s' AND EXISTS (SELECT 1 FROM t_ability_application t1 WHERE t1.apply_flag = t_ability_application.apply_flag AND approve_status = '审核中');", index.getApplyFlag()); Boolean ended = jdbcTemplate.queryForObject(sql, Boolean.class); - index.setEnded(Boolean.valueOf(ended)); + index.setEnded(ended); } return index; }).collect(Collectors.toList()); @@ -197,7 +193,7 @@ public class TAbilityApplicationController { return new Result().ok(null); } TAbilityApplicationV2DTO tAbilityApplicationV2DTO = ConvertUtils.sourceToTarget(applicationDTOS.get(0), TAbilityApplicationV2DTO.class); - applicationDTOS.stream().limit(1l).forEach(dto -> { + applicationDTOS.stream().limit(1L).forEach(dto -> { if (StringUtils.isNotEmpty(dto.getCameraList())) { if (applicationDTOS.size() > 1) { tAbilityApplicationV2DTO.setSystem("视频资源申请:(" + dto.getSystem() + " 等" + applicationDTOS.size() + "个摄像头)"); @@ -235,7 +231,7 @@ public class TAbilityApplicationController { camera = cameraList; List finalCamera = camera; - Map resourceApplication = new HashMap() { + return new HashMap() { { put("instanceId", tAbilityApplicationDTOList.get(0).getInstanceId()); // 流程id put("resourceOwnerDept", tAbilityApplicationDTOList.get(0).getResourceOwnerDept()); // 资源所属部门信息 @@ -252,8 +248,7 @@ public class TAbilityApplicationController { } } }; - return resourceApplication; - }).filter(index -> index != null).collect(Collectors.groupingBy(t -> { + }).filter(Objects::nonNull).collect(Collectors.groupingBy(t -> { SysDeptDTO sysDeptDTO = (SysDeptDTO) t.get("resourceOwnerDept"); if (sysDeptDTO == null) { return "未知部门"; // 无部门信息 diff --git a/renren-admin/src/main/java/io/renren/modules/security/config/ShiroConfig.java b/renren-admin/src/main/java/io/renren/modules/security/config/ShiroConfig.java index ea1f4306..0926fb1c 100644 --- a/renren-admin/src/main/java/io/renren/modules/security/config/ShiroConfig.java +++ b/renren-admin/src/main/java/io/renren/modules/security/config/ShiroConfig.java @@ -25,21 +25,6 @@ import java.util.Map; @Configuration public class ShiroConfig { -// @Autowired -// private Oauth2Filter oauth2Filter; - - //@Autowired - //private ShiroSessionManager shiroSessionManager; - - //@Bean - //public DefaultWebSessionManager sessionManager() { - // DefaultWebSessionManager sessionManager = new DefaultWebSessionManager(); - // sessionManager.setSessionValidationSchedulerEnabled(false); - // sessionManager.setSessionIdUrlRewritingEnabled(false); - // sessionManager.setGlobalSessionTimeout(-1000l); - // return sessionManager; - //} - @Bean public DefaultWebSessionManager sessionManager() { ShiroSessionManager sessionManager = new ShiroSessionManager(); diff --git a/renren-admin/src/main/java/io/renren/modules/security/oauth2/Oauth2Realm.java b/renren-admin/src/main/java/io/renren/modules/security/oauth2/Oauth2Realm.java index 74fce510..1a93f497 100644 --- a/renren-admin/src/main/java/io/renren/modules/security/oauth2/Oauth2Realm.java +++ b/renren-admin/src/main/java/io/renren/modules/security/oauth2/Oauth2Realm.java @@ -67,17 +67,16 @@ public class Oauth2Realm extends AuthorizingRealm { //转换成UserDetail对象 UserDetail userDetail = ConvertUtils.sourceToTarget(userEntity, UserDetail.class); - //获取用户对应的部门数据权限 - List deptIdList = shiroService.getDataScopeList(userDetail.getId()); - userDetail.setDeptIdList(deptIdList); - //账号锁定 if(userDetail.getStatus() == 0){ throw new LockedAccountException(MessageUtils.getMessage(ErrorCode.ACCOUNT_LOCK)); } - SimpleAuthenticationInfo info = new SimpleAuthenticationInfo(userDetail, accessToken, getName()); - return info; + //获取用户对应的部门数据权限 + List deptIdList = shiroService.getDataScopeList(userDetail.getId()); + userDetail.setDeptIdList(deptIdList); + + return new SimpleAuthenticationInfo(userDetail, accessToken, getName()); } } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/security/oauth2/ShiroSessionManager.java b/renren-admin/src/main/java/io/renren/modules/security/oauth2/ShiroSessionManager.java index 705e0264..4e04b2f4 100644 --- a/renren-admin/src/main/java/io/renren/modules/security/oauth2/ShiroSessionManager.java +++ b/renren-admin/src/main/java/io/renren/modules/security/oauth2/ShiroSessionManager.java @@ -1,32 +1,22 @@ package io.renren.modules.security.oauth2; import org.apache.commons.lang.StringUtils; -import org.apache.shiro.session.Session; -import org.apache.shiro.session.mgt.SessionContext; import org.apache.shiro.web.servlet.ShiroHttpServletRequest; import org.apache.shiro.web.session.mgt.DefaultWebSessionManager; import org.apache.shiro.web.util.WebUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; import java.io.Serializable; -//@Component public class ShiroSessionManager extends DefaultWebSessionManager { - /** - * 返回客户端的, - */ - public final String TOKEN_NAME = "token"; /** * 这个是客户端请求给服务端带的header */ - public final static String HEADER_TOKEN_NAME = "token"; - public final static Logger log = LoggerFactory.getLogger(ShiroSessionManager.class); + public static final String HEADER_TOKEN_NAME = "token"; + public static final Logger log = LoggerFactory.getLogger(ShiroSessionManager.class); private static final String REFERENCED_SESSION_ID_SOURCE = "Stateless request"; /** @@ -35,7 +25,7 @@ public class ShiroSessionManager extends DefaultWebSessionManager { @Override protected Serializable getSessionId(ServletRequest request, ServletResponse response) { String sessionId = WebUtils.toHttp(request).getHeader(HEADER_TOKEN_NAME); - log.info("获取的sessionId为" + sessionId); + log.error("获取的sessionId为------>{}", sessionId); if (StringUtils.isEmpty(sessionId)) { return super.getSessionId(request, response); } else { @@ -47,36 +37,4 @@ public class ShiroSessionManager extends DefaultWebSessionManager { } } - - /*@Override - protected void onStart(Session session, SessionContext context) { - log.info("执行onStart"); - if (!WebUtils.isHttp(context)) { - log.debug("SessionContext argument is not HTTP compatible or does not have an HTTP request/response pair. No session ID cookie will be set."); - } else { - HttpServletRequest request = WebUtils.getHttpRequest(context); - HttpServletResponse response = WebUtils.getHttpResponse(context); - Serializable sessionId = session.getId(); - this.storeSessionId(sessionId, request, response); - request.removeAttribute(ShiroHttpServletRequest.REFERENCED_SESSION_ID_SOURCE); - request.setAttribute(ShiroHttpServletRequest.REFERENCED_SESSION_IS_NEW, Boolean.TRUE); - } - } - - *//** - * 把sessionId 放入 response header 中 - * onStart时调用 - * 没有sessionid时 会产生sessionid 并放入 response header中 - *//* - private void storeSessionId(Serializable currentId, HttpServletRequest ignored, HttpServletResponse response) { - if (currentId == null) { - String msg = "sessionId cannot be null when persisting for subsequent requests."; - throw new IllegalArgumentException(msg); - } else { - String idString = currentId.toString(); - response.setHeader(this.TOKEN_NAME, idString); - log.info("Set session ID header for session with id {}", idString); - log.trace("Set session ID header for session with id {}", idString); - } - }*/ } \ No newline at end of file