Commit 1a703d3d by 阳浪

问卷参数统计

parent bb7477f1
......@@ -2,6 +2,7 @@ package com.yizhi.site.application.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
......@@ -33,6 +34,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import java.time.LocalDate;
import java.util.*;
import java.util.stream.Collectors;
......@@ -289,13 +291,22 @@ public class EventTrackServiceImpl extends ServiceImpl<EventTrackMapper, EventTr
@Override
public List<EventTrackDeptNumVo> queryTgNumByDept(Long typeId) {
List<EventTrackDeptNumVo> eventTrackDeptNumVoList = this.baseMapper.queryGropByList();
LocalDate today = LocalDate.now();
List<Integer> recentMonths = new ArrayList<>();
// 循环获取最近四个月的月份
for (int i = 0; i < 4; i++) {
Integer month = today.minusMonths(i).getMonthValue();
recentMonths.add(month);
}
if(CollUtil.isNotEmpty(eventTrackDeptNumVoList)){
eventTrackDeptNumVoList.stream().forEach(eventTrackDeptNumVo -> {
List<EventTrackTypeNumVo> eventTrackTypeNumVoList = this.baseMapper.queryTgNumByDept(eventTrackDeptNumVo.getDeptName(),typeId);
if(CollectionUtil.isNotEmpty(eventTrackTypeNumVoList)){
List<EventTrackTypeNumVo> voList = Lists.newArrayList();
eventTrackTypeNumVoList.stream().forEach(numVo->{
Optional<EventTrackTypeNumVo> optional= voList.stream().filter(v->Objects.equals(v.getType(),numVo.getType())).findFirst();
Optional<EventTrackTypeNumVo> optional= CollectionUtil.isEmpty(voList)?null:voList.stream().filter(v->Objects.equals(v.getType(),numVo.getType())).findFirst();
if(optional!=null&&optional.isPresent()){
EventTrackTypeNumVo vo = optional.get();
if(numVo.getNum()!=null) {
......@@ -313,8 +324,29 @@ public class EventTrackServiceImpl extends ServiceImpl<EventTrackMapper, EventTr
}else {
eventTrackDeptNumVo.setEventTrackTypeNumVoList(eventTrackTypeNumVoList);
}
eventTrackTypeNumVoList = Lists.newArrayList();
for(Integer month:recentMonths){
EventTrackTypeNumVo eventTrackTypeNumVo = new EventTrackTypeNumVo();
if(CollectionUtil.isEmpty(eventTrackDeptNumVo.getEventTrackTypeNumVoList())){
eventTrackTypeNumVo.setNum(0);
eventTrackTypeNumVo.setSubType(String.valueOf(month));
}else{
Optional<EventTrackTypeNumVo> optional = eventTrackDeptNumVo.getEventTrackTypeNumVoList().stream().filter(e->Objects.equals(Integer.valueOf(e.getSubType()),month)).findFirst();
if(optional!=null&&optional.isPresent()){
eventTrackTypeNumVo = optional.get();
eventTrackTypeNumVo.setSubType(Integer.valueOf(eventTrackTypeNumVo.getSubType()).toString());
}else{
eventTrackTypeNumVo.setNum(0);
eventTrackTypeNumVo.setSubType(String.valueOf(month));
}
}
eventTrackTypeNumVoList.add(eventTrackTypeNumVo);
}
eventTrackDeptNumVo.setEventTrackTypeNumVoList(eventTrackTypeNumVoList);
});
}
return eventTrackDeptNumVoList;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment