From 42239f79490e7130a63d51a67efd1f2c8d23be37 Mon Sep 17 00:00:00 2001 From: xyh <18782104331@139.com> Date: 星期五, 18 六月 2021 09:50:44 +0800 Subject: [PATCH] 平均耗时格式 --- springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/screen/ComActEasyPhotoScreenVO.java | 2 +- springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ScreenWorkServiceImpl.java | 18 +++++++++++++++--- springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComActNeighborCircleDAO.java | 4 ++-- springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComActEasyPhotoDAO.java | 2 +- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/screen/ComActEasyPhotoScreenVO.java b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/screen/ComActEasyPhotoScreenVO.java index a9769f8..2c38b96 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/screen/ComActEasyPhotoScreenVO.java +++ b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/screen/ComActEasyPhotoScreenVO.java @@ -34,7 +34,7 @@ private Integer pubPoint; @ApiModelProperty("平均耗时") - private Integer dealTime; + private String dealTime; @ApiModelProperty("线形图统计时间段") private String listTimes; diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComActEasyPhotoDAO.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComActEasyPhotoDAO.java index 1a6ec2d..34163db 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComActEasyPhotoDAO.java +++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComActEasyPhotoDAO.java @@ -260,7 +260,7 @@ "(" + "(SELECT COUNT(id) FROM com_act_easy_photo WHERE community_id = #{communityId} AND status = 4 )*100/(SELECT COUNT(id) FROM com_act_easy_photo WHERE community_id = #{communityId} and (status = 3 or status = 4)) " + ") AS pubPoint," + - "(SELECT AVG(TIMESTAMPDIFF(HOUR,create_at,feedback_at)) FROM com_act_easy_photo WHERE community_id = #{communityId} and status = 4 ) AS dealTime " + + "(SELECT AVG(TIMESTAMPDIFF(MINUTE,create_at,feedback_at)) FROM com_act_easy_photo WHERE community_id = #{communityId} and status = 4 ) AS dealTime " + "FROM com_act_easy_photo where community_id = #{communityId} and status = 1 ") Map<String, Object> countByCommunityId(@Param("communityId")Long communityId,@Param("nowDate") String nowDate); diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComActNeighborCircleDAO.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComActNeighborCircleDAO.java index c3ca8b4..d85a2f2 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComActNeighborCircleDAO.java +++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComActNeighborCircleDAO.java @@ -152,8 +152,8 @@ List<PieElementVO> countAllNoneCompletedWorkByCommunityId(@Param("communityId")Long communityId); @Select(" SELECT AVG(b.t)AS avgTime " + - " FROM (SELECT TIMESTAMPDIFF(HOUR,create_at,feedback_at) AS t FROM com_act_easy_photo WHERE community_id = #{communityId} and STATUS = 4 " + - " UNION ALL SELECT TIMESTAMPDIFF(HOUR,create_at,finish_at) AS t FROM com_act_micro_wish WHERE community_id = #{communityId} and STATUS = 6 " + + " FROM (SELECT TIMESTAMPDIFF(MINUTE,create_at,feedback_at) AS t FROM com_act_easy_photo WHERE community_id = #{communityId} and STATUS = 4 " + + " UNION ALL SELECT TIMESTAMPDIFF(MINUTE,create_at,finish_at) AS t FROM com_act_micro_wish WHERE community_id = #{communityId} and STATUS = 6 " + " )AS b ") Map<String, Object> countAvgByCommunityId(@Param("communityId")Long communityId); } \ No newline at end of file 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 91d44e9..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 @@ -211,7 +211,7 @@ 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; @@ -227,7 +227,18 @@ 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 @@ -243,7 +254,8 @@ //统计平均耗时、平均每天完成个数 Map<String,Object> avgMap = comActNeighborCircleDAO.countAvgByCommunityId(communityId); - comActWorkScreenVO.setAvgTime(avgMap.get("avgTime")==null?"0":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)); BigDecimal num = new BigDecimal(comActWorkScreenVO.getTotalCompleted()); -- Gitblit v1.7.1