From 82faf95effef5184b29f227963f0019f6fa337c8 Mon Sep 17 00:00:00 2001 From: dinggang <2498628697@qq.com> Date: Thu, 1 Dec 2022 09:12:54 +0800 Subject: [PATCH 1/2] =?UTF-8?q?1.=E8=A5=BF=E6=B5=B7=E5=B2=B8=E5=AE=A1?= =?UTF-8?q?=E6=89=B9=E9=80=BB=E8=BE=91=E4=BF=AE=E6=94=B9=202.=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E6=B1=87=E8=81=9A=E6=80=BB=E9=87=8F=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E5=8C=BA=E5=88=86=E8=A5=BF=E6=B5=B7=E5=B2=B8=E5=92=8C=E5=B8=82?= =?UTF-8?q?=E5=B1=80=E7=8E=AF=E5=A2=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/AbilityCenterControllerV2.java | 5 +- .../service/impl/ResourceServiceImpl.java | 73 +++++++++++++++---- .../modules/security/user/SecurityUser.java | 2 +- .../service/impl/SysRoleUserServiceImpl.java | 1 - 4 files changed, 61 insertions(+), 20 deletions(-) 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 2ccf3a58..1d417e6a 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 @@ -213,7 +213,7 @@ public class AbilityCenterControllerV2 { tAbilityApplicationDTO.setEnclosureName(abilityBatchApplicationDTO.getEnclosureName()); tAbilityApplicationDTO.setCreateDate(new Date()); tAbilityApplicationDTO.setExpireDate(abilityBatchApplicationDTO.getExpireDate()); - tAbilityApplicationDTO.setResourceOwnerDept(sysDeptService.getByName(index.get("managementUnitName"))); + //tAbilityApplicationDTO.setResourceOwnerDept(sysDeptService.getByName(index.get("managementUnitName"))); // 归为同一次申请 @@ -233,7 +233,6 @@ public class AbilityCenterControllerV2 { }).filter(ObjectUtil::isNotNull).collect(Collectors.toList()); // 申请入库 if (!tAbilityApplicationDTOList.isEmpty()) { codeGenerationUtils.setApplyNumber("NLSY", tAbilityApplicationDTOList.stream().map(TAbilityApplicationDTO::getId).collect(Collectors.toList()), jdbcTemplate); - Map> temp = tAbilityApplicationDTOList.stream() .filter(Objects::nonNull) .filter(index -> StringUtils.isNotEmpty(index.getResourceId())) @@ -262,7 +261,7 @@ public class AbilityCenterControllerV2 { 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); // 批量更新资源所属部门信息 + jdbcTemplate.batchUpdate(sqls);// 批量更新资源所属部门信息 logger.info("批量更新申请的资源的部门信息完成"); }, executor); diff --git a/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java index 2b919cfb..3daf1549 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java @@ -1953,19 +1953,63 @@ public class ResourceServiceImpl extends CrudServiceImpl resultMap = new HashMap<>(); //云资源 - CompletableFuture yzy = CompletableFuture.runAsync(() -> { - resultMap.put("云资源", resourceDao.selectYzyCount()); - }, executor); + CompletableFuture yzy = CompletableFuture.runAsync(() -> resultMap.put("云资源", resourceDao.selectYzyCount()), executor); //视频资源 - CompletableFuture jcss = CompletableFuture.runAsync(() -> { - - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("check_status", 1).ne("gps_x", "").ne("gps_y", "").isNotNull("gps_x").isNotNull("gps_y"); - resultMap.put("视频资源", cameraChannelMapper.selectCount(queryWrapper)); - - - }, executor); + switch (Constant.ProjectPlace.getByFlag(projectPlace)) { + case TSINGTAO_XHA: { // 青岛西海岸 + CompletableFuture allAmount = CompletableFuture.supplyAsync(() -> { // 获取平台总基础设施数目 + List result = new CopyOnWriteArrayList<>(); + CompletableFuture cloud = CompletableFuture.runAsync(() -> { // 云脑专网 + 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("errorNo") && jsonObject.getLongValue("errorNo") == 200) { + result.add(jsonObject.getLongValue("body")); + } + } else { + logger.error("青岛西海岸获取失败"); + } + } catch (Exception exception) { + logger.error("青岛西海岸失败", exception); + } + }, executor); + CompletableFuture local = CompletableFuture.runAsync(() -> { // 金宏网 + String url = tsingtao_xhaProperties.getLocalcam(); + 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("errorNo") && jsonObject.getLongValue("errorNo") == 200) { + result.add(jsonObject.getLongValue("body")); + } + } else { + logger.error("青岛西海岸获取失败"); + } + } catch (Exception exception) { + logger.error("青岛西海岸失败", exception); + } + }, executor); + CompletableFuture all = CompletableFuture.allOf(cloud, local); + all.join(); + return result.stream().filter(Objects::nonNull).findAny().orElse(0L); + }).thenAccept(sum -> resultMap.put("视频资源", sum)); + allAmount.join(); + } + break; + case TSINGTAO: { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("check_status", 1).ne("gps_x", "").ne("gps_y", "").isNotNull("gps_x").isNotNull("gps_y"); + resultMap.put("视频资源", cameraChannelMapper.selectCount(queryWrapper)); + } + break; + default: + break; + } //新增会客厅和视频会议统计 //会客厅 @@ -1977,10 +2021,9 @@ public class ResourceServiceImpl extends CrudServiceImpl sphy = CompletableFuture.runAsync(() -> { - resultMap.put("视频会议", enkeService.page(new HashMap<>()).getTotal()); - }, executor); - CompletableFuture all = CompletableFuture.allOf(jcss, hkt, sphy); + CompletableFuture sphy = CompletableFuture.runAsync(() -> resultMap.put("视频会议", enkeService.page(new HashMap<>()).getTotal()), executor); + + CompletableFuture all = CompletableFuture.allOf(yzy, hkt, sphy); all.join(); return resultMap; diff --git a/renren-admin/src/main/java/io/renren/modules/security/user/SecurityUser.java b/renren-admin/src/main/java/io/renren/modules/security/user/SecurityUser.java index da5b6222..585fb824 100644 --- a/renren-admin/src/main/java/io/renren/modules/security/user/SecurityUser.java +++ b/renren-admin/src/main/java/io/renren/modules/security/user/SecurityUser.java @@ -38,7 +38,7 @@ public class SecurityUser { logger.error("————————————————————————————user为null,返回空对象————————————————————————————"); return new UserDetail(); } - + return user; } diff --git a/renren-admin/src/main/java/io/renren/modules/sys/service/impl/SysRoleUserServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/sys/service/impl/SysRoleUserServiceImpl.java index 2af22b32..2e46727b 100644 --- a/renren-admin/src/main/java/io/renren/modules/sys/service/impl/SysRoleUserServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/sys/service/impl/SysRoleUserServiceImpl.java @@ -1,6 +1,5 @@ package io.renren.modules.sys.service.impl; -import cn.hutool.core.collection.CollUtil; import io.renren.common.service.impl.BaseServiceImpl; import io.renren.modules.security.user.SecurityUser; import io.renren.modules.sys.controller.SysUserController; From 86c0f106ff111325d1fc4be3dc01dc4174da4a87 Mon Sep 17 00:00:00 2001 From: wangliwen Date: Thu, 1 Dec 2022 14:21:44 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=B5=81=E7=A8=8B=E5=86=85=E5=82=AC?= =?UTF-8?q?=E5=8A=9E=E6=9D=A1=E4=BB=B6=E7=9A=84=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../activiti/dto/ProcessInstanceDTO.java | 10 +++++ .../activiti/service/ActHistoryService.java | 43 ++++++++++++++++++- .../modules/reminders/dao/TRemindersDao.java | 22 +++++++--- .../reminders/service/TRemindersService.java | 10 ++++- .../service/impl/TRemindersServiceImpl.java | 32 +++++++++++--- .../service/impl/SysRoleUserServiceImpl.java | 3 +- .../mapper/reminders/TRemindersDao.xml | 12 ++++++ 7 files changed, 116 insertions(+), 16 deletions(-) diff --git a/renren-admin/src/main/java/io/renren/modules/activiti/dto/ProcessInstanceDTO.java b/renren-admin/src/main/java/io/renren/modules/activiti/dto/ProcessInstanceDTO.java index a6320d0a..33313931 100644 --- a/renren-admin/src/main/java/io/renren/modules/activiti/dto/ProcessInstanceDTO.java +++ b/renren-admin/src/main/java/io/renren/modules/activiti/dto/ProcessInstanceDTO.java @@ -91,4 +91,14 @@ public class ProcessInstanceDTO { @ApiModelProperty(value = "申请单号") private String applyNumber; + + /** + * 催办功能增加字段 + */ + @ApiModelProperty(value = "该流程的节点当前是否允许催办") + private Boolean allowReminders; + @ApiModelProperty(value = "该流程的节点当前是否已经进行过催办") + private Boolean doneReminders; + @ApiModelProperty(value = "该流程的节点需几天后进行催办") + private Integer nextRemindersDays; } 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 381f95d9..d5b1df4a 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 @@ -12,6 +12,7 @@ import io.renren.modules.demandComment.entity.TDemandCommentEntityDelFlag; import io.renren.modules.demandComment.service.TDemandCommentService; import io.renren.modules.processForm.dto.TAbilityApplicationDTO; import io.renren.modules.processForm.service.TAbilityApplicationService; +import io.renren.modules.reminders.service.TRemindersService; import io.renren.modules.resource.dto.ResourceDTO; import io.renren.modules.resource.service.ResourceService; import io.renren.modules.resourceMountApply.dto.TResourceMountApplyDTO; @@ -37,12 +38,15 @@ import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import javax.imageio.ImageIO; import javax.servlet.http.HttpServletResponse; import java.awt.image.BufferedImage; import java.io.InputStream; +import java.time.LocalDate; +import java.time.temporal.ChronoUnit; import java.util.*; import java.util.stream.Collectors; @@ -92,6 +96,11 @@ public class ActHistoryService { @Autowired private ProcessEngine processEngine_; + @Autowired + private TRemindersService tRemindersService; + @Value("${reminders.interval:7}") // 流程发起后多少天允许催办 + private Integer interval; + public void getProcessInstanceDiagram(String processInstanceId, HttpServletResponse response) throws Exception { if (StringUtils.isEmpty(processInstanceId)) { @@ -375,10 +384,42 @@ public class ActHistoryService { .filter(Objects::nonNull) .filter(index -> null != index.getName() && index.getName().contains(params.get("name").toString())) .collect(Collectors.toList()); - List list2 = list1.stream().skip((Integer.parseInt(page) - 1) * Integer.parseInt(limit)).limit(Integer.parseInt(limit)).collect(Collectors.toList()); + List list2 = list1.stream().skip((Integer.parseInt(page) - 1) * Integer.parseInt(limit)) + .limit(Integer.parseInt(limit)).collect(Collectors.toList()); pageData.setTotal(list1.size()); pageData.setList(list2); } + /** + * 处理催办相关条件、数据 + */ + pageData.setList(pageData.getList().stream().map(index -> { + Optional nowTask = taskService.createTaskQuery().processInstanceId(index.getProcessInstanceId()) + .orderByTaskCreateTime().desc().active().list().stream().findFirst(); // 尝试获取当前task + if (nowTask.isPresent()) { // 存在正在进行的任务 + LocalDate localDate = tRemindersService.selectRemindersTime(nowTask.get().getId()); + if (localDate == null) {// 未进行过催办 + index.setAllowReminders(Boolean.TRUE); // 允许催办 + index.setDoneReminders(Boolean.FALSE); // 不存在催办记录 + index.setNextRemindersDays(0); // 距离下次催办天数为0 + } else { // 进行过催办 + long between = ChronoUnit.DAYS.between(localDate, LocalDate.now()); // 上次催办距离今天已过天数 + if (between <= interval) { // 间隔天数小于限制天数 + index.setAllowReminders(Boolean.FALSE); // 不允许催办 + index.setDoneReminders(Boolean.TRUE); // 存在催办记录 + index.setNextRemindersDays((int) (interval - between)); // 距离下次催办天数为0 + } else { + index.setAllowReminders(Boolean.TRUE); // 不允许催办 + index.setDoneReminders(Boolean.TRUE); // 存在催办记录 + index.setNextRemindersDays(0); // 距离下次催办天数为0 + } + } + } else { + index.setAllowReminders(Boolean.FALSE); + index.setDoneReminders(Boolean.FALSE); + index.setNextRemindersDays(0); + } + return index; + }).collect(Collectors.toList())); return pageData; } diff --git a/renren-admin/src/main/java/io/renren/modules/reminders/dao/TRemindersDao.java b/renren-admin/src/main/java/io/renren/modules/reminders/dao/TRemindersDao.java index b5ca7961..cba3fa9f 100644 --- a/renren-admin/src/main/java/io/renren/modules/reminders/dao/TRemindersDao.java +++ b/renren-admin/src/main/java/io/renren/modules/reminders/dao/TRemindersDao.java @@ -3,14 +3,24 @@ package io.renren.modules.reminders.dao; import io.renren.common.dao.BaseDao; import io.renren.modules.reminders.entity.TRemindersEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; /** -* 催办信息 -* -* @author wangliwen wangliwen@hisense.com -* @since 1.0 2022-11-30 -*/ + * 催办信息 + * + * @author wangliwen wangliwen@hisense.com + * @since 1.0 2022-11-30 + */ @Mapper public interface TRemindersDao extends BaseDao { - + /** + * 获取该任务的最新催办记录时间 + * + * @param taskId + * @return + */ + List selectRemindersTime(@Param("taskId") String taskId); } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/reminders/service/TRemindersService.java b/renren-admin/src/main/java/io/renren/modules/reminders/service/TRemindersService.java index 6afd759d..44c2b0bb 100644 --- a/renren-admin/src/main/java/io/renren/modules/reminders/service/TRemindersService.java +++ b/renren-admin/src/main/java/io/renren/modules/reminders/service/TRemindersService.java @@ -4,6 +4,8 @@ import io.renren.common.service.CrudService; import io.renren.modules.reminders.dto.TRemindersDTO; import io.renren.modules.reminders.entity.TRemindersEntity; +import java.time.LocalDate; + /** * 催办信息 * @@ -11,5 +13,11 @@ import io.renren.modules.reminders.entity.TRemindersEntity; * @since 1.0 2022-11-30 */ public interface TRemindersService extends CrudService { - + /** + * 获取该任务最近一次催办日期 + * + * @param taskId + * @return + */ + LocalDate selectRemindersTime(String taskId); } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/reminders/service/impl/TRemindersServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/reminders/service/impl/TRemindersServiceImpl.java index 02d735b4..dec619f6 100644 --- a/renren-admin/src/main/java/io/renren/modules/reminders/service/impl/TRemindersServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/reminders/service/impl/TRemindersServiceImpl.java @@ -24,6 +24,10 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; +import java.time.LocalDate; +import java.time.ZoneId; +import java.time.format.DateTimeFormatter; +import java.time.temporal.ChronoUnit; import java.util.Date; import java.util.List; import java.util.Map; @@ -89,6 +93,8 @@ public class TRemindersServiceImpl extends CrudServiceImpl kv = task.getProcessVariables(); + LocalDate taskCreateDate = task.getCreateTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); + long between = ChronoUnit.DAYS.between(taskCreateDate, LocalDate.now()); Boolean allowEntrust = Boolean.valueOf(kv.get("allowEntrust") != null ? kv.get("allowEntrust").toString() : Boolean.FALSE.toString()); // 允许被委托他人(特殊通知) final StringBuilder resourceName = new StringBuilder(); if (kv.containsKey("resourceDTO")) { @@ -112,18 +118,19 @@ public class TRemindersServiceImpl extends CrudServiceImpl + LocalDate.parse(index.get("reminders_time").toString(), formatter) + ).findFirst().orElse(null); + } } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/sys/service/impl/SysRoleUserServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/sys/service/impl/SysRoleUserServiceImpl.java index 2af22b32..51a69a0f 100644 --- a/renren-admin/src/main/java/io/renren/modules/sys/service/impl/SysRoleUserServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/sys/service/impl/SysRoleUserServiceImpl.java @@ -1,6 +1,5 @@ package io.renren.modules.sys.service.impl; -import cn.hutool.core.collection.CollUtil; import io.renren.common.service.impl.BaseServiceImpl; import io.renren.modules.security.user.SecurityUser; import io.renren.modules.sys.controller.SysUserController; @@ -25,7 +24,7 @@ public class SysRoleUserServiceImpl extends BaseServiceImpl roleIdList) { logger.error("------------------准备更新用户角色信息-------------------"); //先删除角色用户关系 diff --git a/renren-admin/src/main/resources/mapper/reminders/TRemindersDao.xml b/renren-admin/src/main/resources/mapper/reminders/TRemindersDao.xml index 4e31f521..6a2fdcfb 100644 --- a/renren-admin/src/main/resources/mapper/reminders/TRemindersDao.xml +++ b/renren-admin/src/main/resources/mapper/reminders/TRemindersDao.xml @@ -21,4 +21,16 @@ + + \ No newline at end of file