This commit is contained in:
dinggang 2022-05-18 18:06:47 +08:00
parent c2d82d8ddc
commit 767968d01f
8 changed files with 119 additions and 9 deletions

View File

@ -162,8 +162,9 @@ public class CensusController {
HashMap<String, Object> resultMap = new HashMap<>(); HashMap<String, Object> resultMap = new HashMap<>();
String startDate = jsonObject.getString("startDate"); String startDate = jsonObject.getString("startDate");
String endDate = jsonObject.getString("endDate"); String endDate = jsonObject.getString("endDate");
resultMap.put("browseAvg", null); resultMap.put("browseAvg", resourceBrowseService.selectDayAvg());
//resultMap.put("browseMax", resourceBrowseService.selectMax()); resultMap.put("browseMax", resourceBrowseService.selectDayMax());
resultMap.put("browseDayList", resourceBrowseService.selectDayList(startDate, endDate));
return new Result().ok(resultMap); return new Result().ok(resultMap);
} }
} }

View File

@ -88,6 +88,7 @@ public class HistoryController {
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码从1开始", paramType = "query", required = true, dataType = "int"), @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 = 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 = "processInstanceId", value = "实例ID", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "businessKey", value = "业务KEY", paramType = "query", dataType = "String"), @ApiImplicitParam(name = "businessKey", value = "业务KEY", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "processDefinitionId", value = "流程定义ID", paramType = "query", dataType = "String"), @ApiImplicitParam(name = "processDefinitionId", value = "流程定义ID", paramType = "query", dataType = "String"),

View File

@ -37,10 +37,7 @@ import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.InputStream; import java.io.InputStream;
import java.util.ArrayList; import java.util.*;
import java.util.Date;
import java.util.List;
import java.util.Map;
/** /**
* 工作流 * 工作流
@ -254,6 +251,10 @@ public class ActHistoryService {
public PageData<ProcessInstanceDTO> getMyProcessInstancePage(Map<String, Object> params) { public PageData<ProcessInstanceDTO> getMyProcessInstancePage(Map<String, Object> params) {
params.put("startBy", SecurityUser.getUserId().toString()); params.put("startBy", SecurityUser.getUserId().toString());
PageData<ProcessInstanceDTO> pageData = this.getHistoryProcessInstancePage(params); PageData<ProcessInstanceDTO> 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<ProcessInstanceDTO> list = pageData.getList(); List<ProcessInstanceDTO> list = pageData.getList();
for (ProcessInstanceDTO dto : list) { for (ProcessInstanceDTO dto : list) {
TAbilityApplicationDTO abilityApplicationDTO = tAbilityApplicationService.getByInstanceId(dto.getProcessInstanceId()); // 获取申请表单 TAbilityApplicationDTO abilityApplicationDTO = tAbilityApplicationService.getByInstanceId(dto.getProcessInstanceId()); // 获取申请表单
@ -311,6 +312,20 @@ public class ActHistoryService {
} }
dto.setCurrentTaskList(taskDTOList); dto.setCurrentTaskList(taskDTOList);
} }
List<ProcessInstanceDTO> 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<ProcessInstanceDTO> 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; return pageData;
} }

View File

@ -3,6 +3,10 @@ package io.renren.modules.resourceBrowse.dao;
import io.renren.common.dao.BaseDao; import io.renren.common.dao.BaseDao;
import io.renren.modules.resourceBrowse.entity.ResourceBrowseEntity; import io.renren.modules.resourceBrowse.entity.ResourceBrowseEntity;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/** /**
* 浏览记录 * 浏览记录
@ -13,4 +17,9 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper @Mapper
public interface ResourceBrowseDao extends BaseDao<ResourceBrowseEntity> { public interface ResourceBrowseDao extends BaseDao<ResourceBrowseEntity> {
Integer selectDayAvg(@Param("days") Long days);
Integer selectDayMax();
List<Map> selectDayList(@Param("startDate") String startDate,@Param("endDate") String endDate);
} }

View File

@ -12,4 +12,9 @@ import io.renren.modules.resourceBrowse.entity.ResourceBrowseEntity;
*/ */
public interface ResourceBrowseService extends CrudService<ResourceBrowseEntity, ResourceBrowseDTO> { public interface ResourceBrowseService extends CrudService<ResourceBrowseEntity, ResourceBrowseDTO> {
Object selectDayAvg();
Object selectDayMax();
Object selectDayList(String startDate, String endDate);
} }

View File

@ -3,15 +3,18 @@ package io.renren.modules.resourceBrowse.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.renren.common.service.impl.CrudServiceImpl; import io.renren.common.service.impl.CrudServiceImpl;
import io.renren.common.constant.Constant; import io.renren.common.constant.Constant;
import io.renren.common.utils.DateUtils;
import io.renren.modules.resourceBrowse.dao.ResourceBrowseDao; import io.renren.modules.resourceBrowse.dao.ResourceBrowseDao;
import io.renren.modules.resourceBrowse.dto.ResourceBrowseDTO; import io.renren.modules.resourceBrowse.dto.ResourceBrowseDTO;
import io.renren.modules.resourceBrowse.entity.ResourceBrowseEntity; import io.renren.modules.resourceBrowse.entity.ResourceBrowseEntity;
import io.renren.modules.resourceBrowse.service.ResourceBrowseService; import io.renren.modules.resourceBrowse.service.ResourceBrowseService;
import io.renren.modules.security.user.SecurityUser; import io.renren.modules.security.user.SecurityUser;
import org.apache.commons.lang3.StringUtils; 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 org.springframework.stereotype.Service;
import java.util.Map; import java.util.*;
/** /**
* 浏览记录 * 浏览记录
@ -22,10 +25,14 @@ import java.util.Map;
@Service @Service
public class ResourceBrowseServiceImpl extends CrudServiceImpl<ResourceBrowseDao, ResourceBrowseEntity, ResourceBrowseDTO> implements ResourceBrowseService { public class ResourceBrowseServiceImpl extends CrudServiceImpl<ResourceBrowseDao, ResourceBrowseEntity, ResourceBrowseDTO> implements ResourceBrowseService {
@Autowired
private ResourceBrowseDao resourceBrowseDao;
@Value("${system.startDay}")
private String systemDay;
@Override @Override
public QueryWrapper<ResourceBrowseEntity> getWrapper(Map<String, Object> params){ public QueryWrapper<ResourceBrowseEntity> getWrapper(Map<String, Object> params){
QueryWrapper<ResourceBrowseEntity> wrapper = new QueryWrapper<>(); QueryWrapper<ResourceBrowseEntity> wrapper = new QueryWrapper<>();
wrapper.eq("state", 0) wrapper.eq("state", 0)
.eq("user_id", SecurityUser.getUserId()) .eq("user_id", SecurityUser.getUserId())
.orderByDesc("create_date"); .orderByDesc("create_date");
@ -33,4 +40,40 @@ public class ResourceBrowseServiceImpl extends CrudServiceImpl<ResourceBrowseDao
} }
@Override
public Object selectDayAvg() {
Date startDay = DateUtils.stringToDate(systemDay, DateUtils.DATE_PATTERN);
Date today = new Date();
Long days = (today.getTime() - startDay.getTime()) / (1000 * 60 * 60 * 24);
return resourceBrowseDao.selectDayAvg(days);
}
@Override
public Object selectDayMax() {
return resourceBrowseDao.selectDayMax();
}
@Override
public Object selectDayList(String startDate, String endDate) {
List<Map> maps = resourceBrowseDao.selectDayList(startDate, endDate);
Date startDay = DateUtils.parse(startDate, DateUtils.DATE_PATTERN);
Date endDay = DateUtils.parse(endDate, DateUtils.DATE_PATTERN);
ArrayList<String> dayList = new ArrayList<>();
while (startDay.before(endDay)) {
dayList.add(DateUtils.format(startDay, DateUtils.DATE_PATTERN));
startDay = DateUtils.addDateDays(startDay, 1);
}
ArrayList<Map<String, Integer>> resultMap = new ArrayList<>();
for (int i = 0; i < dayList.size(); i++) {
HashMap<String, Integer> 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;
}
} }

View File

@ -80,3 +80,5 @@ mybatis-plus:
call-setters-on-nulls: true call-setters-on-nulls: true
jdbc-type-for-null: 'null' jdbc-type-for-null: 'null'
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
system:
startDay: 2022-01-01

View File

@ -16,5 +16,39 @@
<result property="note2" column="note2"/> <result property="note2" column="note2"/>
<result property="note3" column="note3"/> <result property="note3" column="note3"/>
</resultMap> </resultMap>
<select id="selectDayAvg" resultType="java.lang.Integer">
SELECT IFNULL(COUNT(id), 0) / ${days}
FROM tb_resource_browse
WHERE 1 = 1
AND state = 0
</select>
<select id="selectDayMax" resultType="java.lang.Integer">
SELECT IFNULL(MAX(count), 0)
FROM
(SELECT
COUNT( id ) AS "count"
FROM
tb_resource_browse
WHERE
1 = 1
AND state = 0
GROUP BY
SUBSTR(create_date, 1, 10)) temp
</select>
<select id="selectDayList" resultType="java.util.Map">
SELECT
SUBSTR(create_date, 1, 10) AS "date",
COUNT( id ) AS "count"
FROM
tb_resource_browse
WHERE
1 = 1
AND state = 0
AND create_date BETWEEN ${startDate} AND ${endDate}
GROUP BY
SUBSTR(create_date, 1, 10)
</select>
</mapper> </mapper>