From 767968d01f565828df2192769b3831db4fcc55fa Mon Sep 17 00:00:00 2001 From: dinggang <2498628697@qq.com> Date: Wed, 18 May 2022 18:06:47 +0800 Subject: [PATCH] ... --- .../common/controller/CensusController.java | 5 +- .../controller/HistoryController.java | 1 + .../activiti/service/ActHistoryService.java | 23 +++++++-- .../resourceBrowse/dao/ResourceBrowseDao.java | 11 ++++- .../service/ResourceBrowseService.java | 5 ++ .../impl/ResourceBrowseServiceImpl.java | 47 ++++++++++++++++++- .../src/main/resources/application.yml | 2 + .../resourceBrowse/ResourceBrowseDao.xml | 34 ++++++++++++++ 8 files changed, 119 insertions(+), 9 deletions(-) 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 0080aa28..c706d0d3 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 @@ -162,8 +162,9 @@ public class CensusController { HashMap resultMap = new HashMap<>(); String startDate = jsonObject.getString("startDate"); String endDate = jsonObject.getString("endDate"); - resultMap.put("browseAvg", null); - //resultMap.put("browseMax", resourceBrowseService.selectMax()); + resultMap.put("browseAvg", resourceBrowseService.selectDayAvg()); + resultMap.put("browseMax", resourceBrowseService.selectDayMax()); + resultMap.put("browseDayList", resourceBrowseService.selectDayList(startDate, endDate)); return new Result().ok(resultMap); } } 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 9ee5b0bb..5e72c90e 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 @@ -88,6 +88,7 @@ public class HistoryController { @ApiImplicitParams({ @ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType = "int"), @ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query", required = true, dataType = "int"), + @ApiImplicitParam(name = "name", value = "能力名称", paramType = "query", dataType = "String"), @ApiImplicitParam(name = "processInstanceId", value = "实例ID", paramType = "query", dataType = "String"), @ApiImplicitParam(name = "businessKey", value = "业务KEY", paramType = "query", dataType = "String"), @ApiImplicitParam(name = "processDefinitionId", value = "流程定义ID", paramType = "query", dataType = "String"), 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 0ae84061..3be7fa1d 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 @@ -37,10 +37,7 @@ import javax.imageio.ImageIO; import javax.servlet.http.HttpServletResponse; import java.awt.image.BufferedImage; import java.io.InputStream; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Map; +import java.util.*; /** * 工作流 @@ -254,6 +251,10 @@ public class ActHistoryService { public PageData getMyProcessInstancePage(Map params) { params.put("startBy", SecurityUser.getUserId().toString()); PageData pageData = this.getHistoryProcessInstancePage(params); + if (params.containsKey("name") && StringUtils.isNotBlank(params.get("name").toString())) { + params.put("limit", String.valueOf(pageData.getTotal())); + pageData = this.getHistoryProcessInstancePage(params); + } List list = pageData.getList(); for (ProcessInstanceDTO dto : list) { TAbilityApplicationDTO abilityApplicationDTO = tAbilityApplicationService.getByInstanceId(dto.getProcessInstanceId()); // 获取申请表单 @@ -311,6 +312,20 @@ public class ActHistoryService { } dto.setCurrentTaskList(taskDTOList); } + List list1 = new ArrayList<>(); + if (params.containsKey("name") && StringUtils.isNotBlank(params.get("name").toString())) { + pageData.getList().stream() + .filter(Objects::nonNull) + .filter(index -> null != index.getName() && index.getName().contains(params.get("name").toString())) + .forEach(list1::add); + ArrayList list2 = new ArrayList<>(); + int j = Math.min(Integer.parseInt(params.get("page").toString()) * Integer.parseInt(params.get("limit").toString()), list1.size()); + for (int i = (Integer.parseInt(params.get("page").toString()) - 1) * Integer.parseInt(params.get("limit").toString()); i < j; i++) { + list2.add(list1.get(i)); + } + pageData.setTotal(list1.size()); + pageData.setList(list2); + } return pageData; } diff --git a/renren-admin/src/main/java/io/renren/modules/resourceBrowse/dao/ResourceBrowseDao.java b/renren-admin/src/main/java/io/renren/modules/resourceBrowse/dao/ResourceBrowseDao.java index a1b07512..a70d5375 100644 --- a/renren-admin/src/main/java/io/renren/modules/resourceBrowse/dao/ResourceBrowseDao.java +++ b/renren-admin/src/main/java/io/renren/modules/resourceBrowse/dao/ResourceBrowseDao.java @@ -3,6 +3,10 @@ package io.renren.modules.resourceBrowse.dao; import io.renren.common.dao.BaseDao; import io.renren.modules.resourceBrowse.entity.ResourceBrowseEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; /** * 浏览记录 @@ -12,5 +16,10 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface ResourceBrowseDao extends BaseDao { - + + Integer selectDayAvg(@Param("days") Long days); + + Integer selectDayMax(); + + List selectDayList(@Param("startDate") String startDate,@Param("endDate") String endDate); } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resourceBrowse/service/ResourceBrowseService.java b/renren-admin/src/main/java/io/renren/modules/resourceBrowse/service/ResourceBrowseService.java index 6db2a2e7..76ac4a33 100644 --- a/renren-admin/src/main/java/io/renren/modules/resourceBrowse/service/ResourceBrowseService.java +++ b/renren-admin/src/main/java/io/renren/modules/resourceBrowse/service/ResourceBrowseService.java @@ -12,4 +12,9 @@ import io.renren.modules.resourceBrowse.entity.ResourceBrowseEntity; */ public interface ResourceBrowseService extends CrudService { + Object selectDayAvg(); + + Object selectDayMax(); + + Object selectDayList(String startDate, String endDate); } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resourceBrowse/service/impl/ResourceBrowseServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/resourceBrowse/service/impl/ResourceBrowseServiceImpl.java index 1ec3a15e..59ea8be6 100644 --- a/renren-admin/src/main/java/io/renren/modules/resourceBrowse/service/impl/ResourceBrowseServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/resourceBrowse/service/impl/ResourceBrowseServiceImpl.java @@ -3,15 +3,18 @@ package io.renren.modules.resourceBrowse.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import io.renren.common.service.impl.CrudServiceImpl; import io.renren.common.constant.Constant; +import io.renren.common.utils.DateUtils; import io.renren.modules.resourceBrowse.dao.ResourceBrowseDao; import io.renren.modules.resourceBrowse.dto.ResourceBrowseDTO; import io.renren.modules.resourceBrowse.entity.ResourceBrowseEntity; import io.renren.modules.resourceBrowse.service.ResourceBrowseService; import io.renren.modules.security.user.SecurityUser; import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; -import java.util.Map; +import java.util.*; /** * 浏览记录 @@ -22,10 +25,14 @@ import java.util.Map; @Service public class ResourceBrowseServiceImpl extends CrudServiceImpl implements ResourceBrowseService { + @Autowired + private ResourceBrowseDao resourceBrowseDao; + @Value("${system.startDay}") + private String systemDay; + @Override public QueryWrapper getWrapper(Map params){ QueryWrapper wrapper = new QueryWrapper<>(); - wrapper.eq("state", 0) .eq("user_id", SecurityUser.getUserId()) .orderByDesc("create_date"); @@ -33,4 +40,40 @@ public class ResourceBrowseServiceImpl extends CrudServiceImpl maps = resourceBrowseDao.selectDayList(startDate, endDate); + Date startDay = DateUtils.parse(startDate, DateUtils.DATE_PATTERN); + Date endDay = DateUtils.parse(endDate, DateUtils.DATE_PATTERN); + ArrayList dayList = new ArrayList<>(); + while (startDay.before(endDay)) { + dayList.add(DateUtils.format(startDay, DateUtils.DATE_PATTERN)); + startDay = DateUtils.addDateDays(startDay, 1); + } + ArrayList> resultMap = new ArrayList<>(); + for (int i = 0; i < dayList.size(); i++) { + HashMap dayMap = new HashMap<>(); + dayMap.put(dayList.get(i), 0); + for (Map map : maps) { + if (dayList.get(i).equals(map.get("date"))) { + dayMap.put(dayList.get(i), (Integer) map.get("count")); + } + } + resultMap.add(dayMap); + } + return resultMap; + } } \ No newline at end of file diff --git a/renren-admin/src/main/resources/application.yml b/renren-admin/src/main/resources/application.yml index e3cefe88..e0e83289 100644 --- a/renren-admin/src/main/resources/application.yml +++ b/renren-admin/src/main/resources/application.yml @@ -80,3 +80,5 @@ mybatis-plus: call-setters-on-nulls: true jdbc-type-for-null: 'null' # log-impl: org.apache.ibatis.logging.stdout.StdOutImpl +system: + startDay: 2022-01-01 \ No newline at end of file diff --git a/renren-admin/src/main/resources/mapper/resourceBrowse/ResourceBrowseDao.xml b/renren-admin/src/main/resources/mapper/resourceBrowse/ResourceBrowseDao.xml index 4259186e..11eb4b88 100644 --- a/renren-admin/src/main/resources/mapper/resourceBrowse/ResourceBrowseDao.xml +++ b/renren-admin/src/main/resources/mapper/resourceBrowse/ResourceBrowseDao.xml @@ -16,5 +16,39 @@ + + + + + \ No newline at end of file