package com.doumee.service.business.impl; import com.doumee.core.annotation.excel.ExcelExporter; import com.doumee.core.constants.ResponseStatus; import com.doumee.core.exception.BusinessException; import com.doumee.core.utils.Constants; import com.doumee.core.utils.DateUtil; import com.doumee.core.utils.Utils; import com.doumee.dao.business.CategoryMapper; import com.doumee.dao.business.InoutRecordMapper; import com.doumee.dao.business.dto.InParkDataDTO; import com.doumee.dao.business.model.Category; import com.doumee.dao.business.model.InoutRecord; import com.doumee.dao.business.vo.GeneralDataVO; import com.doumee.dao.business.vo.InParkUserDataVO; import com.doumee.service.business.InoutRecordService; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.doumee.service.business.third.model.PageData; import com.doumee.service.business.third.model.PageWrap; import com.github.yulichang.wrapper.MPJLambdaWrapper; import io.swagger.annotations.ApiModelProperty; import io.swagger.models.auth.In; import org.apache.commons.lang.StringUtils; import org.checkerframework.checker.units.qual.C; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.math.BigDecimal; import java.net.URLEncoder; import java.nio.charset.Charset; import java.text.DecimalFormat; import java.time.*; import java.time.format.DateTimeFormatter; import java.time.temporal.TemporalAdjusters; import java.util.*; import java.util.stream.Collectors; /** * 出入场人次车次每日统计表Service实现 * @author 江蹄蹄 * @date 2025/04/28 16:19 */ @Service public class InoutRecordServiceImpl implements InoutRecordService { @Autowired private InoutRecordMapper inoutRecordMapper; @Autowired private CategoryMapper categoryMapper; @Override public Integer create(InoutRecord inoutRecord) { inoutRecordMapper.insert(inoutRecord); return inoutRecord.getId(); } @Override public void deleteById(Integer id) { inoutRecordMapper.deleteById(id); } @Override public void delete(InoutRecord inoutRecord) { UpdateWrapper deleteWrapper = new UpdateWrapper<>(inoutRecord); inoutRecordMapper.delete(deleteWrapper); } @Override public void deleteByIdInBatch(List ids) { if (CollectionUtils.isEmpty(ids)) { return; } inoutRecordMapper.deleteBatchIds(ids); } @Override public void updateById(InoutRecord inoutRecord) { inoutRecordMapper.updateById(inoutRecord); } @Override public void updateByIdInBatch(List inoutRecords) { if (CollectionUtils.isEmpty(inoutRecords)) { return; } for (InoutRecord inoutRecord: inoutRecords) { this.updateById(inoutRecord); } } @Override public InoutRecord findById(Integer id) { return inoutRecordMapper.selectById(id); } @Override public InoutRecord findOne(InoutRecord inoutRecord) { QueryWrapper wrapper = new QueryWrapper<>(inoutRecord); return inoutRecordMapper.selectOne(wrapper); } @Override public List findList(InoutRecord inoutRecord) { QueryWrapper wrapper = new QueryWrapper<>(inoutRecord); return inoutRecordMapper.selectList(wrapper); } @Override public PageData findPage(PageWrap pageWrap) { IPage page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); QueryWrapper queryWrapper = new QueryWrapper<>(); Utils.MP.blankToNull(pageWrap.getModel()); if (pageWrap.getModel().getId() != null) { queryWrapper.lambda().eq(InoutRecord::getId, pageWrap.getModel().getId()); } if (pageWrap.getModel().getCreator() != null) { queryWrapper.lambda().eq(InoutRecord::getCreator, pageWrap.getModel().getCreator()); } if (pageWrap.getModel().getCreateDate() != null) { queryWrapper.lambda().ge(InoutRecord::getCreateDate, Utils.Date.getStart(pageWrap.getModel().getCreateDate())); queryWrapper.lambda().le(InoutRecord::getCreateDate, Utils.Date.getEnd(pageWrap.getModel().getCreateDate())); } if (pageWrap.getModel().getEditor() != null) { queryWrapper.lambda().eq(InoutRecord::getEditor, pageWrap.getModel().getEditor()); } if (pageWrap.getModel().getEditDate() != null) { queryWrapper.lambda().ge(InoutRecord::getEditDate, Utils.Date.getStart(pageWrap.getModel().getEditDate())); queryWrapper.lambda().le(InoutRecord::getEditDate, Utils.Date.getEnd(pageWrap.getModel().getEditDate())); } if (pageWrap.getModel().getIsdeleted() != null) { queryWrapper.lambda().eq(InoutRecord::getIsdeleted, pageWrap.getModel().getIsdeleted()); } if (pageWrap.getModel().getRemark() != null) { queryWrapper.lambda().eq(InoutRecord::getRemark, pageWrap.getModel().getRemark()); } if (pageWrap.getModel().getType() != null) { queryWrapper.lambda().eq(InoutRecord::getType, pageWrap.getModel().getType()); } if (pageWrap.getModel().getHkEventId() != null) { queryWrapper.lambda().eq(InoutRecord::getHkEventId, pageWrap.getModel().getHkEventId()); } if (pageWrap.getModel().getHkId() != null) { queryWrapper.lambda().eq(InoutRecord::getHkId, pageWrap.getModel().getHkId()); } if (pageWrap.getModel().getMemberId() != null) { queryWrapper.lambda().eq(InoutRecord::getMemberId, pageWrap.getModel().getMemberId()); } if (pageWrap.getModel().getCarId() != null) { queryWrapper.lambda().eq(InoutRecord::getCarId, pageWrap.getModel().getCarId()); } if (pageWrap.getModel().getCategoryId() != null) { queryWrapper.lambda().eq(InoutRecord::getCategoryId, pageWrap.getModel().getCategoryId()); } if (pageWrap.getModel().getCategoryName() != null) { queryWrapper.lambda().eq(InoutRecord::getCategoryName, pageWrap.getModel().getCategoryName()); } if (pageWrap.getModel().getCarBizType() != null) { queryWrapper.lambda().eq(InoutRecord::getCarBizType, pageWrap.getModel().getCarBizType()); } if (pageWrap.getModel().getMemberType() != null) { queryWrapper.lambda().eq(InoutRecord::getMemberType, pageWrap.getModel().getMemberType()); } if (pageWrap.getModel().getMemberName() != null) { queryWrapper.lambda().eq(InoutRecord::getMemberName, pageWrap.getModel().getMemberName()); } if (pageWrap.getModel().getCarCode() != null) { queryWrapper.lambda().eq(InoutRecord::getCarCode, pageWrap.getModel().getCarCode()); } if (pageWrap.getModel().getObjType() != null) { queryWrapper.lambda().eq(InoutRecord::getObjType, pageWrap.getModel().getObjType()); } if (pageWrap.getModel().getObjId() != null) { queryWrapper.lambda().eq(InoutRecord::getObjId, pageWrap.getModel().getObjId()); } if (pageWrap.getModel().getInOrOut() != null) { queryWrapper.lambda().eq(InoutRecord::getInOrOut, pageWrap.getModel().getInOrOut()); } if (pageWrap.getModel().getDeviceName() != null) { queryWrapper.lambda().eq(InoutRecord::getDeviceName, pageWrap.getModel().getDeviceName()); } for(PageWrap.SortData sortData: pageWrap.getSorts()) { if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) { queryWrapper.orderByDesc(sortData.getProperty()); } else { queryWrapper.orderByAsc(sortData.getProperty()); } } return PageData.from(inoutRecordMapper.selectPage(page, queryWrapper)); } @Override public long count(InoutRecord inoutRecord) { QueryWrapper wrapper = new QueryWrapper<>(inoutRecord); return inoutRecordMapper.selectCount(wrapper); } //人员分类 单独处理人员数据 0劳务访客 1普通访客 2内部员工 3车辆信息 4相关方人员 5货运司机 private static String[] userTypeList = new String[]{"","普通访客","内部人员","","相关方人员","货运司机"}; /** * 查询基础数据 * @return */ @Override public InParkUserDataVO getInParkUserData(InParkDataDTO inParkDataDTO){ if(Objects.isNull(inParkDataDTO) || Objects.isNull(inParkDataDTO.getType()) || Objects.isNull(inParkDataDTO.getIsGroupBy()) || (Objects.nonNull(inParkDataDTO.getType())&& !(Constants.equalsInteger(inParkDataDTO.getType(),Constants.ZERO) || Constants.equalsInteger(inParkDataDTO.getType(),Constants.ONE) )) || (Objects.nonNull(inParkDataDTO.getIsGroupBy())&& !(Constants.equalsInteger(inParkDataDTO.getIsGroupBy(),Constants.ZERO) || Constants.equalsInteger(inParkDataDTO.getIsGroupBy(),Constants.ONE) )) ){ throw new BusinessException(ResponseStatus.BAD_REQUEST); } //查询本周的开始日期和结束日期 Long weekStart = LocalDate.now().with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY)).atStartOfDay(ZoneOffset.UTC).toInstant().toEpochMilli(); InParkUserDataVO inParkUserDataVO = new InParkUserDataVO(); List yearList = inoutRecordMapper.selectJoinList(InoutRecord.class,new MPJLambdaWrapper() .selectAll(InoutRecord.class) .eq(InoutRecord::getIsdeleted,Constants.ZERO) .isNotNull(Constants.equalsInteger(inParkDataDTO.getType(),Constants.ZERO),InoutRecord::getCarCode) .isNotNull(Constants.equalsInteger(inParkDataDTO.getType(),Constants.ONE),InoutRecord::getMemberPhone) .apply(" ( DATE_FORMAT(CREATE_DATE, '%Y') = DATE_FORMAT(now(), '%Y') ) ") ); List monthList = yearList.stream().filter(i->DateUtil.formatDate(i.getCreateDate(),"yyyy-MM").equals(DateUtil.formatDate(new Date(),"yyyy-MM"))).collect(Collectors.toList()); List weekList = yearList.stream().filter(i->i.getCreateDate().getTime()>=weekStart).collect(Collectors.toList()); List todayList = weekList.stream().filter(i-> DateUtil.formatDate(i.getCreateDate(),"yyyy-MM-dd").equals(DateUtil.formatDate(new Date(),"yyyy-MM-dd"))).collect(Collectors.toList()); List yesterdayList = yearList.stream().filter(i-> DateUtil.formatDate(i.getCreateDate(),"yyyy-MM-dd").equals(DateUtil.getBeforDay(new Date(),1))).collect(Collectors.toList()); if(Constants.equalsInteger(inParkDataDTO.getIsGroupBy(),Constants.ZERO)){ inParkUserDataVO.setYearTotal(yearList.size()); inParkUserDataVO.setMonthTotal(monthList.size()); inParkUserDataVO.setTodayTotal(todayList.size()); inParkUserDataVO.setWeekTotal(weekList.size()); inParkUserDataVO.setYesterdayTotal(yesterdayList.size()); }else{ yearList = this.getListByType(yearList,inParkDataDTO.getType()); monthList = this.getListByType(monthList,inParkDataDTO.getType()); weekList = this.getListByType(weekList,inParkDataDTO.getType()); todayList = this.getListByType(todayList,inParkDataDTO.getType()); yesterdayList = this.getListByType(yesterdayList,inParkDataDTO.getType()); inParkUserDataVO.setYearTotal(yearList.size()); inParkUserDataVO.setMonthTotal(monthList.size()); inParkUserDataVO.setTodayTotal(todayList.size()); inParkUserDataVO.setWeekTotal(weekList.size()); inParkUserDataVO.setYesterdayTotal(yesterdayList.size()); } //处理年度折线图数据 List cumulativeDataList = new ArrayList<>(); for (int i = 1; i <=12 ; i++) { GeneralDataVO generalDataVO = new GeneralDataVO(); generalDataVO.setName(Integer.toString(i)); generalDataVO.setTotal(yearList.stream().filter(j->Constants.equalsInteger(Integer.valueOf(generalDataVO.getName()),Integer.valueOf(DateUtil.formatDate(j.getCreateDate(),"MM")))).collect(Collectors.toList()).size()); generalDataVO.setName(generalDataVO.getName()+"月"); cumulativeDataList.add(generalDataVO); } inParkUserDataVO.setCumulativeDataList(cumulativeDataList); //处理分类数据 List yearSortList = new ArrayList<>(); if(Constants.equalsInteger(inParkDataDTO.getType(),Constants.ONE)){ for (int i = 0; i < userTypeList.length; i++) { if(StringUtils.isBlank(userTypeList[i])){ continue; } GeneralDataVO generalDataVO = new GeneralDataVO(); generalDataVO.setName(userTypeList[i]); int index = i; generalDataVO.setTotal(yearList.stream().filter(j->Constants.equalsInteger(j.getType(), index)).collect(Collectors.toList()).size()); yearSortList.add(generalDataVO); } }else{ List categoryNameList = yearList.stream().filter(i-> StringUtils.isNotBlank(i.getCategoryName())).map(i->i.getCategoryName()).collect(Collectors.toList()); if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(categoryNameList)){ Set setList = new HashSet<>(categoryNameList); for (String categoryName:setList) { GeneralDataVO generalDataVO = new GeneralDataVO(); generalDataVO.setName(categoryName); generalDataVO.setTotal(yearList.stream().filter(j->StringUtils.isNotBlank(j.getCategoryName())&&j.getCategoryName().equals(categoryName)).collect(Collectors.toList()).size()); yearSortList.add(generalDataVO); } } } if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(yearSortList)){ Collections.sort(yearSortList, new Comparator() { @Override public int compare(GeneralDataVO o1, GeneralDataVO o2) { // 返回值为int类型,大于0表示正序,小于0表示逆序 return o2.getTotal() - o1.getTotal(); } }); inParkUserDataVO.setYearSortList(yearSortList); } return inParkUserDataVO; } /** * 查询占比数据 * @return */ @Override public List getRataList(InParkDataDTO inParkDataDTO){ if(Objects.isNull(inParkDataDTO) || Objects.isNull(inParkDataDTO.getType()) || Objects.isNull(inParkDataDTO.getIsGroupBy()) || StringUtils.isBlank(inParkDataDTO.getDateStr()) || (Objects.nonNull(inParkDataDTO.getType())&& !(Constants.equalsInteger(inParkDataDTO.getType(),Constants.ZERO) || Constants.equalsInteger(inParkDataDTO.getType(),Constants.ONE) )) || (Objects.nonNull(inParkDataDTO.getIsGroupBy())&& !(Constants.equalsInteger(inParkDataDTO.getIsGroupBy(),Constants.ZERO) || Constants.equalsInteger(inParkDataDTO.getIsGroupBy(),Constants.ONE) )) || !( Constants.equalsInteger(inParkDataDTO.getDateStr().length(),4) || Constants.equalsInteger(inParkDataDTO.getDateStr().length(),7) ) ){ throw new BusinessException(ResponseStatus.BAD_REQUEST); } List rataList = new ArrayList<>(); List yearList = inoutRecordMapper.selectJoinList(InoutRecord.class,new MPJLambdaWrapper() .selectAll(InoutRecord.class) .eq(InoutRecord::getIsdeleted,Constants.ZERO) .isNotNull(Constants.equalsInteger(inParkDataDTO.getType(),Constants.ZERO),InoutRecord::getCarCode) .isNotNull(Constants.equalsInteger(inParkDataDTO.getType(),Constants.ONE),InoutRecord::getMemberPhone) .apply(Constants.equalsInteger(inParkDataDTO.getDateStr().length(),4)," ( DATE_FORMAT(CREATE_DATE, '%Y') = '"+inParkDataDTO.getDateStr()+"' ) ") .apply(Constants.equalsInteger(inParkDataDTO.getDateStr().length(),7)," ( DATE_FORMAT(CREATE_DATE, '%Y-%m') = '"+inParkDataDTO.getDateStr()+"' ) ") ); if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isEmpty(yearList)){ return rataList; } if(Constants.equalsInteger(inParkDataDTO.getIsGroupBy(),Constants.ONE)){ yearList = this.getListByType(yearList,inParkDataDTO.getType()); } if(Constants.equalsInteger(inParkDataDTO.getType(),Constants.ONE)){ for (int i = 0; i < userTypeList.length; i++) { if(StringUtils.isBlank(userTypeList[i])){ continue; } GeneralDataVO generalDataVO = new GeneralDataVO(); generalDataVO.setName(userTypeList[i]); int index = i; generalDataVO.setTotal(yearList.stream().filter(j->Constants.equalsInteger(j.getType(), index)).collect(Collectors.toList()).size()); generalDataVO.setRata(new BigDecimal(generalDataVO.getTotal().toString()).divide(new BigDecimal(yearList.size()+""),2,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"))); rataList.add(generalDataVO); } }else{ List categoryNameList = yearList.stream().filter(i-> StringUtils.isNotBlank(i.getCategoryParentName())).map(i->i.getCategoryParentName()).collect(Collectors.toList()); if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(categoryNameList)){ Set setList = new HashSet<>(categoryNameList); for (String categoryName:setList) { GeneralDataVO generalDataVO = new GeneralDataVO(); generalDataVO.setName(categoryName); generalDataVO.setTotal(yearList.stream().filter(j->StringUtils.isNotBlank(j.getCategoryParentName())&&j.getCategoryName().equals(categoryName)).collect(Collectors.toList()).size()); generalDataVO.setRata(new BigDecimal(generalDataVO.getTotal().toString()).divide(new BigDecimal(yearList.size()+""),2,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"))); rataList.add(generalDataVO); } } } return rataList; } @Override public List> getReportList(InParkDataDTO inParkDataDTO){ if(Objects.isNull(inParkDataDTO) || Objects.isNull(inParkDataDTO.getType()) || Objects.isNull(inParkDataDTO.getIsGroupBy()) || StringUtils.isBlank(inParkDataDTO.getDateStr()) || (Objects.nonNull(inParkDataDTO.getType())&& !(Constants.equalsInteger(inParkDataDTO.getType(),Constants.ZERO) || Constants.equalsInteger(inParkDataDTO.getType(),Constants.ONE) )) || (Objects.nonNull(inParkDataDTO.getIsGroupBy())&& !(Constants.equalsInteger(inParkDataDTO.getIsGroupBy(),Constants.ZERO) || Constants.equalsInteger(inParkDataDTO.getIsGroupBy(),Constants.ONE) )) || !( Constants.equalsInteger(inParkDataDTO.getDateStr().length(),4) || Constants.equalsInteger(inParkDataDTO.getDateStr().length(),7) ) ){ throw new BusinessException(ResponseStatus.BAD_REQUEST); } List allList = inoutRecordMapper.selectJoinList(InoutRecord.class,new MPJLambdaWrapper() .selectAll(InoutRecord.class) .eq(InoutRecord::getIsdeleted,Constants.ZERO) .isNotNull(Constants.equalsInteger(inParkDataDTO.getType(),Constants.ZERO),InoutRecord::getCarCode) .isNotNull(Constants.equalsInteger(inParkDataDTO.getType(),Constants.ONE),InoutRecord::getMemberPhone) .apply(Constants.equalsInteger(inParkDataDTO.getDateStr().length(),4)," ( DATE_FORMAT(CREATE_DATE, '%Y') = '"+inParkDataDTO.getDateStr()+"' ) ") .apply(Constants.equalsInteger(inParkDataDTO.getDateStr().length(),7)," ( DATE_FORMAT(CREATE_DATE, '%Y-%m') = '"+inParkDataDTO.getDateStr()+"' ) ") ); List> resultList = new ArrayList<>(); if(CollectionUtils.isEmpty(allList)){ return resultList; } if(Constants.equalsInteger(inParkDataDTO.getIsGroupBy(),Constants.ONE)){ allList = this.getListByType(allList,inParkDataDTO.getType()); } List dateList = new ArrayList<>(); //年份 if(Constants.equalsInteger(inParkDataDTO.getDateStr().length(),4)){ Integer maxMonth = 12; if(Constants.equalsInteger(DateUtil.getNowYearNum(),Integer.valueOf(inParkDataDTO.getDateStr()))){ maxMonth = DateUtil.getNowMonthNum(); } for (int i = 1; i <= maxMonth; i++) { dateList.add(DateUtil.getNowYearNum()+"-"+ StringUtils.leftPad(i+"",2,"0")); } }else { //日期 Integer year = Integer.valueOf(inParkDataDTO.getDateStr().substring(0,4)); Integer month = Integer.valueOf(inParkDataDTO.getDateStr().substring(5,6)); Integer today = DateUtil.getNowDayNum(); YearMonth yearMonth = YearMonth.of(year, month); // 获取该月的最后一天 LocalDate lastDayDate = yearMonth.atEndOfMonth(); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); Integer lastDay = Integer.valueOf(lastDayDate.format(formatter)); if(Constants.equalsInteger(year,DateUtil.getNowYearNum()) && Constants.equalsInteger(month,DateUtil.getNowMonthNum())){ if(today < lastDay){ lastDay = today; } } for (int i = 1; i <= lastDay; i++) { dateList.add(year + "-" + StringUtils.leftPad(month.toString(),2,"0") + "-" + StringUtils.leftPad(lastDay.toString(),2,"0")); } } return this.dealResultData(allList,dateList,inParkDataDTO.getType(),inParkDataDTO.getDateStr()); } public List> dealResultData(List allList,List dataList ,Integer type,String dateStr){ List> resultList = new ArrayList<>(); List totalString = new ArrayList<>(); totalString.add("日期"); if(Constants.equalsInteger(type,Constants.ZERO)){ List categoryNameList = allList.stream().filter(j-> StringUtils.isNotBlank(j.getCategoryName())).map(j->j.getCategoryName()).collect(Collectors.toList()); if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isEmpty(categoryNameList)){ return resultList; } Set setList = new HashSet<>(categoryNameList); for (String categoryName:setList) { totalString.add(categoryName); } totalString.add("合计"); resultList.add(totalString); Integer total = 0; for (String str:dataList) { for (String categoryName:setList) { List dataChildList = new ArrayList<>(); dataChildList.add(str); if(Constants.equalsInteger(dateStr.length(),4)){ Integer childNum = allList.stream().filter(i->categoryName.equals(i.getCategoryName()) && DateUtil.formatDate(i.getCreateDate(),"yyyy-MM").equals(str)).collect(Collectors.toList()).size(); dataChildList.add( Integer.toString(childNum) ); total = total + childNum; }else if(Constants.equalsInteger(dateStr.length(),7)){ Integer childNum = allList.stream().filter(i->categoryName.equals(i.getCategoryName()) &&DateUtil.formatDate(i.getCreateDate(),"yyyy-MM-dd").equals(str)).collect(Collectors.toList()).size(); dataChildList.add( Integer.toString(childNum) ); total = total + childNum; } dataChildList.add(Integer.toString(total)); resultList.add(dataChildList); } } }else{ for (int j = 0; j < userTypeList.length; j++) { if(StringUtils.isBlank(userTypeList[j])){ continue; } totalString.add(userTypeList[j]); totalString.add("合计"); resultList.add(totalString); } Integer total = 0; for (String str:dataList) { for (String typeName:userTypeList) { List dataChildList = new ArrayList<>(); dataChildList.add(str); if(Constants.equalsInteger(dateStr.length(),4)){ Integer childNum = allList.stream().filter(i->typeName.equals(i.getCategoryName()) && DateUtil.formatDate(i.getCreateDate(),"yyyy-MM").equals(str)).collect(Collectors.toList()).size(); dataChildList.add( Integer.toString(childNum) ); total = total + childNum; }else if(Constants.equalsInteger(dateStr.length(),7)){ Integer childNum = allList.stream().filter(i->typeName.equals(i.getCategoryName()) &&DateUtil.formatDate(i.getCreateDate(),"yyyy-MM-dd").equals(str)).collect(Collectors.toList()).size(); dataChildList.add( Integer.toString(childNum) ); total = total + childNum; } dataChildList.add(Integer.toString(total)); resultList.add(dataChildList); } } } return resultList; } public List getListByType(List list,Integer type){ return Constants.equalsInteger(type,Constants.ONE)?this.getDataByMemberPhoneSize(list):this.getDataByCarCodeSize(list); } public List getDataByMemberPhoneSize(List list){ Map uniqueByMemberPhone = list.stream() .collect(Collectors.toMap( InoutRecord::getMemberPhone, person -> person, (existing, replacement) -> existing )); List uniqueList = new ArrayList<>(uniqueByMemberPhone.values()); return uniqueList; } public List getDataByCarCodeSize(List list){ Map uniqueByCarCode = list.stream() .collect(Collectors.toMap( InoutRecord::getCarCode, person -> person, (existing, replacement) -> existing )); List uniqueList = new ArrayList<>(uniqueByCarCode.values()); return uniqueList; } @Override public void excel(InParkDataDTO inParkDataDTO, HttpServletResponse response){ List> data = this.getReportList(inParkDataDTO); try { String fileName = Constants.equalsInteger(inParkDataDTO.getType(),Constants.ZERO)?"入园车辆统计表_":"入园人员统计表_"+System.currentTimeMillis(); String encodeFileName = URLEncoder.encode(fileName, Charset.forName("UTF-8").toString()) + ".xlsx"; response.setHeader("Content-Disposition","attachment;filename=" + encodeFileName); response.setContentType("application/octet-stream"); response.setHeader("eva-opera-type", "download"); response.setHeader("eva-download-filename", encodeFileName); ExcelExporter.exportList(data, fileName, response.getOutputStream()); } catch (IOException e) { throw new BusinessException(ResponseStatus.EXPORT_EXCEL_ERROR, e); } } }