| | |
| | | package com.panzhihua.service_community.service.impl; |
| | | |
| | | import cn.hutool.core.date.DateTime; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.panzhihua.common.model.dtos.partybuilding.ComPbActivityDTO; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.screen.*; |
| | | import com.panzhihua.common.utlis.DateUtils; |
| | |
| | | import com.panzhihua.service_community.model.dos.ComActDO; |
| | | import com.panzhihua.service_community.model.dos.ComActDynDO; |
| | | import com.panzhihua.service_community.service.ScreenWorkService; |
| | | import org.apache.commons.net.ntp.TimeStamp; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | import java.util.stream.Stream; |
| | | import cn.hutool.core.date.DateTime; |
| | | import cn.hutool.core.date.DateUtil; |
| | | |
| | | /** |
| | | * @author xyh |
| | |
| | | public class ScreenWorkServiceImpl implements ScreenWorkService { |
| | | |
| | | private static final Integer pageSize = 200; |
| | | |
| | | private final String moth_format_str = "yyyy-MM"; |
| | | private final String[] monthStr = new String[] {"一", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "十二"}; |
| | | @Resource |
| | | private ComActDAO comActDAO; |
| | | @Resource |
| | |
| | | @Resource |
| | | private ComActEasyPhotoDAO comActEasyPhotoDAO; |
| | | |
| | | private final String moth_format_str = "yyyy-MM"; |
| | | |
| | | private final String[] monthStr = new String[]{"一","二","三","四","五","六","七","八","九","十","十一","十二"}; |
| | | |
| | | @Override |
| | | public R statisticNeighborCircle(Long communityId) { |
| | | |
| | |
| | | comActNeighborCircleScreenVO.setCurrentNum(countMap.get("currentNum")); |
| | | comActNeighborCircleScreenVO.setTotalNum(countMap.get("totalNum")); |
| | | Map<String,Object> sumMap = comActNeighborCircleDAO.sumScreenNum(communityId); |
| | | comActNeighborCircleScreenVO.setFabulousNum(sumMap.get("fabulousNum") == null?0L:Long.valueOf(sumMap.get("fabulousNum").toString())); |
| | | comActNeighborCircleScreenVO.setCommentNum(sumMap.get("commentNum") == null?0L:Long.valueOf(sumMap.get("commentNum").toString())); |
| | | comActNeighborCircleScreenVO.setSharedNum(sumMap.get("forwardNum") == null?0L:Long.valueOf(sumMap.get("forwardNum").toString())); |
| | | comActNeighborCircleScreenVO.setFabulousNum( |
| | | sumMap.get("fabulousNum") == null ? 0L : Long.valueOf(sumMap.get("fabulousNum").toString())); |
| | | comActNeighborCircleScreenVO |
| | | .setCommentNum(sumMap.get("commentNum") == null ? 0L : Long.valueOf(sumMap.get("commentNum").toString())); |
| | | comActNeighborCircleScreenVO |
| | | .setSharedNum(sumMap.get("forwardNum") == null ? 0L : Long.valueOf(sumMap.get("forwardNum").toString())); |
| | | //查询最近发布的邻里圈 |
| | | comActNeighborCircleScreenVO.setList(comActNeighborCircleDAO.screenNeighborCircle(communityId,pageSize)); |
| | | //查询最近发布的邻里圈图片 |
| | | comActNeighborCircleScreenVO.setImgs(convertStringList(comActNeighborCircleDAO.screenNeighborCircleImgs(communityId,pageSize))); |
| | | comActNeighborCircleScreenVO |
| | | .setImgs(convertStringList(comActNeighborCircleDAO.screenNeighborCircleImgs(communityId, pageSize))); |
| | | return R.ok(comActNeighborCircleScreenVO); |
| | | } |
| | | |
| | |
| | | wishScreenVO.setImgs(convertStringList(comActMicroWishDAO.getAllImgs(communityId,pageSize))); |
| | | return R.ok(wishScreenVO); |
| | | } |
| | | |
| | | |
| | | |
| | | private List<String> convertStringList(List<String> imgList) { |
| | | List<String> imgs = new ArrayList<>(); |
| | |
| | | comActActivityScreenVO.setTotalNum(countMap.get("totalNum") == null ? 0L : countMap.get("totalNum")); |
| | | comActActivityScreenVO.setCurrentNum(countMap.get("currentNum") == null ? 0L : countMap.get("currentNum")); |
| | | comActActivityScreenVO.setCommonNum(countMap.get("commonNum") == null ? 0L : countMap.get("commonNum")); |
| | | comActActivityScreenVO.setCommonPeopleNum(countMap.get("commonPeopleNum") == null ? 0L : countMap.get("commonPeopleNum")); |
| | | comActActivityScreenVO.setVolunteerNum(countMap.get("volunteerNum") == null ? 0L : countMap.get("volunteerNum")); |
| | | comActActivityScreenVO.setVolunteerPeopleNum(countMap.get("volunteerPeopleNum") == null ? 0L : countMap.get("volunteerPeopleNum")); |
| | | comActActivityScreenVO |
| | | .setCommonPeopleNum(countMap.get("commonPeopleNum") == null ? 0L : countMap.get("commonPeopleNum")); |
| | | comActActivityScreenVO |
| | | .setVolunteerNum(countMap.get("volunteerNum") == null ? 0L : countMap.get("volunteerNum")); |
| | | comActActivityScreenVO.setVolunteerPeopleNum( |
| | | countMap.get("volunteerPeopleNum") == null ? 0L : countMap.get("volunteerPeopleNum")); |
| | | //最近活动 |
| | | comActActivityScreenVO.setList(actActivityDAO.screenActivity(communityId,pageSize)); |
| | | return R.ok(comActActivityScreenVO); |
| | |
| | | return R.ok(pbWorkScreenVO); |
| | | } |
| | | |
| | | |
| | | private List<PbWorkVO> listHalfYear() { |
| | | List<PbWorkVO> dateList = new ArrayList<>(); |
| | | Date now = new Date(); |
| | |
| | | comActEasyPhotoScreenVO.setApproved(comActEasyPhotoDAO.countApproved(communityId)); |
| | | String date = DateUtils.getDateFormatString(new Date(),moth_format_str); |
| | | Map<String,Object> countMap = comActEasyPhotoDAO.countByCommunityId(communityId,date); |
| | | comActEasyPhotoScreenVO.setCurrentNum(countMap.get("currentNum") == null ? 0L : Long.valueOf(countMap.get("currentNum").toString())); |
| | | comActEasyPhotoScreenVO.setNoneDeal(countMap.get("noneDeal") == null ? 0L : Long.valueOf(countMap.get("noneDeal").toString())); |
| | | comActEasyPhotoScreenVO.setPubPoint(countMap.get("pubPoint") == null ? 0 : Integer.valueOf(countMap.get("pubPoint").toString())); |
| | | comActEasyPhotoScreenVO.setDealTime(countMap.get("dealTime") == null ? 0 : Double.valueOf(countMap.get("dealTime").toString()).intValue()); |
| | | comActEasyPhotoScreenVO.setCurrentNum( |
| | | countMap.get("currentNum") == null ? 0L : Long.valueOf(countMap.get("currentNum").toString())); |
| | | comActEasyPhotoScreenVO |
| | | .setNoneDeal(countMap.get("noneDeal") == null ? 0L : Long.valueOf(countMap.get("noneDeal").toString())); |
| | | comActEasyPhotoScreenVO |
| | | .setPubPoint(countMap.get("pubPoint") == null ? 0 : Integer.valueOf(countMap.get("pubPoint").toString())); |
| | | comActEasyPhotoScreenVO.setDealTime( |
| | | countMap.get("dealTime") == null ? 0 : Double.valueOf(countMap.get("dealTime").toString()).intValue()); |
| | | List<EastPhotoVO> list = new ArrayList<>(); |
| | | for(PbWorkVO workVO: listHalfYear()){ |
| | | String nowDate = DateUtils.getDateFormatString(DateUtil.parseDate(workVO.getStart()),moth_format_str); |
| | | EastPhotoVO result = comActEasyPhotoDAO.countByTime(workVO.getStart(),workVO.getEnd(),nowDate,communityId); |
| | | EastPhotoVO result = |
| | | comActEasyPhotoDAO.countByTime(workVO.getStart(), workVO.getEnd(), nowDate, communityId); |
| | | result.setMonth(workVO.getMonth()); |
| | | list.add(result); |
| | | } |
| | |
| | | |
| | | //未完成 |
| | | comActWorkScreenVO.setNoneList(comActNeighborCircleDAO.countAllNoneCompletedWorkByCommunityId(communityId)); |
| | | comActWorkScreenVO.setTotalCompleted(comActWorkScreenVO.getCompletetList().stream().mapToInt(PieElementVO::getNum).sum()); |
| | | comActWorkScreenVO.setTotalNoneCompleted(comActWorkScreenVO.getNoneList().stream().mapToInt(PieElementVO::getNum).sum()); |
| | | comActWorkScreenVO |
| | | .setTotalCompleted(comActWorkScreenVO.getCompletetList().stream().mapToInt(PieElementVO::getNum).sum()); |
| | | comActWorkScreenVO |
| | | .setTotalNoneCompleted(comActWorkScreenVO.getNoneList().stream().mapToInt(PieElementVO::getNum).sum()); |
| | | |
| | | //统计平均耗时、平均每天完成个数 |
| | | Map<String,Object> avgMap = comActNeighborCircleDAO.countAvgByCommunityId(communityId); |
| | | comActWorkScreenVO.setAvgTime(avgMap.get("avgTime") == null?"0h":convertTimeStr(Double.valueOf(avgMap.get("avgTime").toString()).intValue())); |
| | | comActWorkScreenVO.setAvgTime(avgMap.get("avgTime") == null ? "0h" |
| | | : convertTimeStr(Double.valueOf(avgMap.get("avgTime").toString()).intValue())); |
| | | |
| | | ComActDO comActDO = comActDAO.selectById(communityId); |
| | | BigDecimal days = new BigDecimal(DateUtil.betweenDay(comActDO.getCreateAt(),new Date(),false)); |
| | |
| | | String date = DateUtils.getDateFormatString(new Date(),moth_format_str); |
| | | Map<String,Long> countMap = comActDynDAO.countByCommunityId(communityId,date); |
| | | if(!countMap.isEmpty()){ |
| | | workScreenVO.setTotalNum(countMap.get("dynTotal")== null ? 0L : Long.valueOf(countMap.get("dynTotal").toString())); |
| | | workScreenVO.setCurrentNum(countMap.get("currentNum")== null ? 0L : Long.valueOf(countMap.get("currentNum").toString())); |
| | | workScreenVO |
| | | .setTotalNum(countMap.get("dynTotal") == null ? 0L : Long.valueOf(countMap.get("dynTotal").toString())); |
| | | workScreenVO.setCurrentNum( |
| | | countMap.get("currentNum") == null ? 0L : Long.valueOf(countMap.get("currentNum").toString())); |
| | | } |
| | | |
| | | //计算平均每天动态 |
| | |
| | | |
| | | //查询最新的10条社区动态 |
| | | List<String> dynList = new ArrayList<>(); |
| | | List<ComActDynDO> actDynDOList = comActDynDAO.selectList(new QueryWrapper<ComActDynDO>().lambda().eq(ComActDynDO::getCommunityId,communityId).orderByDesc(ComActDynDO::getCreateAt).last("limit 10")); |
| | | List<ComActDynDO> actDynDOList = comActDynDAO.selectList(new QueryWrapper<ComActDynDO>().lambda() |
| | | .eq(ComActDynDO::getCommunityId, communityId).orderByDesc(ComActDynDO::getCreateAt).last("limit 10")); |
| | | if(!actDynDOList.isEmpty()){ |
| | | actDynDOList.forEach(actDyn -> { |
| | | dynList.add(actDyn.getTitle()); |
| | |
| | | //统计近半年数据 |
| | | List<DynamicWorkVO> list = new ArrayList<>(); |
| | | for(DynamicWorkVO dynamicWorkVO: listHalfYearByDyn()){ |
| | | DynamicWorkVO result = comActDynDAO.countByTime(dynamicWorkVO.getStart(),dynamicWorkVO.getEnd(),communityId); |
| | | DynamicWorkVO result = |
| | | comActDynDAO.countByTime(dynamicWorkVO.getStart(), dynamicWorkVO.getEnd(), communityId); |
| | | result.setMonth(dynamicWorkVO.getMonth()); |
| | | list.add(result); |
| | | } |