From 79cd742d9b211c8705a6a7c6b1e71ff819403bcd Mon Sep 17 00:00:00 2001 From: 罗元桥 <2376770955@qq.com> Date: 星期五, 18 六月 2021 10:00:32 +0800 Subject: [PATCH] Merge branch 'test_screen' into 'test' --- springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ScreenWorkServiceImpl.java | 101 +++++++++++++++++--------------------------------- 1 files changed, 34 insertions(+), 67 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ScreenWorkServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ScreenWorkServiceImpl.java index f01e54a..9da51fd 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ScreenWorkServiceImpl.java +++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ScreenWorkServiceImpl.java @@ -9,10 +9,13 @@ import com.panzhihua.common.utlis.DateUtils; import com.panzhihua.common.utlis.StringUtils; import com.panzhihua.service_community.dao.*; +import com.panzhihua.service_community.model.dos.ComActDO; import com.panzhihua.service_community.service.ScreenWorkService; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.math.BigDecimal; +import java.math.RoundingMode; import java.text.SimpleDateFormat; import java.util.*; import java.util.stream.Collectors; @@ -44,6 +47,8 @@ @Resource private ComActEasyPhotoDAO comActEasyPhotoDAO; + + @Resource ComActDAO comActDAO; /** * 项目开始时间,超过的不统计 @@ -206,94 +211,56 @@ 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 : Double.valueOf(countMap.get("pubPoint").toString()).intValue()); - comActEasyPhotoScreenVO.setDealTime(countMap.get("dealTime") == null ? 0 : Double.valueOf(countMap.get("dealTime").toString()).intValue()); + comActEasyPhotoScreenVO.setDealTime(countMap.get("dealTime") == null ? "0h" : convertTimeStr(Double.valueOf(countMap.get("dealTime").toString()).intValue())); List<EastPhotoVO> list = new ArrayList<>(); //统计半年数据 int n = 6; - for(Map<String,String> map : listHalfYear(n)){ + List<Map<String,String>> timeList = listHalfYear(n); + for(Map<String,String> map : timeList){ String nowDate = DateUtils.getDateFormatString(DateUtil.parseDate(map.get("start")),moth_format_str); EastPhotoVO result = comActEasyPhotoDAO.countByTime(map.get("start"),map.get("end"),nowDate,communityId); result.setMonth(map.get("name")); list.add(result); } comActEasyPhotoScreenVO.setList(list); - String fmt = "yyyy-MM-01 00:00:00"; - Date start = DateUtil.parse(DateUtil.format(DateUtils.getDateM(new Date(),-n),new SimpleDateFormat(fmt))); - Date initTime = DateUtil.parse(initMonth +"-01 00:00:00", DatePattern.NORM_DATETIME_FORMAT); - if(!DateUtils.before(initTime,start)){ - start = initTime; - } - comActEasyPhotoScreenVO.setListTimes(DateUtil.format(start,moth_format_ch)+"-"+DateUtil.format(DateUtils.getDateM(new Date(),-1),moth_format_ch)); + comActEasyPhotoScreenVO.setListTimes(DateUtil.format(DateUtil.parse(timeList.get(0).get("start"),DatePattern.NORM_DATETIME_FORMAT),moth_format_ch)+"-"+DateUtil.format(DateUtil.parse(timeList.get(timeList.size()-1).get("start"),DatePattern.NORM_DATETIME_FORMAT),moth_format_ch)); return R.ok(comActEasyPhotoScreenVO); } - + private String convertTimeStr(int minute) { + int hour = minute/60; + int min = minute%60; + StringBuilder timestr = new StringBuilder(); + if(hour > 0){ + timestr.append(hour).append("h"); + } + if(min > 0){ + timestr.append(min).append("min"); + } + return timestr.toString(); + } @Override public R workCount(Long communityId) { ComActWorkScreenVO comActWorkScreenVO = new ComActWorkScreenVO(); //已完成 -// Map<String,Long> countMap = comActNeighborCircleDAO.countAllWorkBy(communityId); + comActWorkScreenVO.setCompletetList(comActNeighborCircleDAO.countAllCompletedWorkByCommunityId(communityId)); + //未完成 + comActWorkScreenVO.setNoneList(comActNeighborCircleDAO.countAllNoneCompletedWorkByCommunityId(communityId)); + 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("1小时"); - comActWorkScreenVO.setTotalCompletedPoint(70); - comActWorkScreenVO.setEveryDayNum("0.3"); - List<ActWorkCountVO> completetPoint = new ArrayList<>(); - ActWorkCountVO easyPhoto = new ActWorkCountVO(); - easyPhoto.setName("随手拍"); - easyPhoto.setNum(10); - completetPoint.add(easyPhoto); - ActWorkCountVO wish = new ActWorkCountVO(); - wish.setName("微心愿"); - wish.setNum(23); - completetPoint.add(wish); - ActWorkCountVO discuss = new ActWorkCountVO(); - discuss.setName("一起议"); - discuss.setNum(33); - completetPoint.add(discuss); - ActWorkCountVO neighbor = new ActWorkCountVO(); - neighbor.setName("邻里圈"); - neighbor.setNum(43); - completetPoint.add(neighbor); - ActWorkCountVO pbWork = new ActWorkCountVO(); - pbWork.setName("党建工作"); - pbWork.setNum(13); - completetPoint.add(pbWork); - ActWorkCountVO activity = new ActWorkCountVO(); - activity.setName("社区活动"); - activity.setNum(63); - completetPoint.add(activity); - comActWorkScreenVO.setCompletetPoint(completetPoint); - - List<ActWorkCountVO> completetPoint2 = new ArrayList<>(); - ActWorkCountVO easyPhoto2 = new ActWorkCountVO(); - easyPhoto2.setName("随手拍"); - easyPhoto2.setNum(10); - completetPoint2.add(easyPhoto2); - ActWorkCountVO wish2 = new ActWorkCountVO(); - wish2.setName("微心愿"); - wish2.setNum(23); - completetPoint2.add(wish2); - ActWorkCountVO discuss2 = new ActWorkCountVO(); - discuss2.setName("一起议"); - discuss2.setNum(33); - completetPoint2.add(discuss2); - ActWorkCountVO neighbor2 = new ActWorkCountVO(); - neighbor2.setName("邻里圈"); - neighbor2.setNum(43); - completetPoint2.add(neighbor2); - ActWorkCountVO pbWork2 = new ActWorkCountVO(); - pbWork2.setName("党建工作"); - pbWork2.setNum(13); - completetPoint2.add(pbWork2); - ActWorkCountVO activity2 = new ActWorkCountVO(); - activity2.setName("社区活动"); - activity2.setNum(63); - completetPoint2.add(activity2); - comActWorkScreenVO.setNonePoint(completetPoint2); + ComActDO comActDO = comActDAO.selectById(communityId); + BigDecimal days = new BigDecimal(DateUtil.betweenDay(comActDO.getCreateAt(),new Date(),false)); + BigDecimal num = new BigDecimal(comActWorkScreenVO.getTotalCompleted()); + BigDecimal rt = num.divide(days,1,RoundingMode.HALF_UP); + comActWorkScreenVO.setEveryDayNum(rt.toString()); return R.ok(comActWorkScreenVO); } -- Gitblit v1.7.1