springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/community/sanshuo/IndexDateDTO.java
@@ -8,7 +8,7 @@ @Data @ApiModel("大屏事件入参(区三说会堂,行业分中心,街道,社区数据)") public class IndexDateDTO { @ApiModelProperty("1区三说会堂,2行业分中心,3街道、镇,4社区/村") @ApiModelProperty("1区三说会堂,2行业分中心,3街道、镇,4社区/村,空为所有") private Integer type; @ApiModelProperty("行业分中心id或街道id或社区id(type=1不传,type=2传行业分中心id,type=3传街道id,type=4传社区id)") private Long id; springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/sanshuo/EventRateVO.java
New file @@ -0,0 +1,19 @@ package com.panzhihua.common.model.vos.sanshuo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.math.BigDecimal; @Data @ApiModel("事件级别占比统计") public class EventRateVO { @ApiModelProperty("级别") private String name; @ApiModelProperty("占比") private BigDecimal rate; @ApiModelProperty("数量") private Integer count; private Integer type; } springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/sanshuo/MediateTypeVO.java
New file @@ -0,0 +1,18 @@ package com.panzhihua.common.model.vos.sanshuo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.math.BigDecimal; @Data @ApiModel("事件类型统计") public class MediateTypeVO { @ApiModelProperty("事件类型") private String name; @ApiModelProperty("数量") private Integer count; @ApiModelProperty("占比") private BigDecimal rate; } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/api/ComEventController.java
@@ -3,6 +3,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.panzhihua.common.controller.BaseController; import com.panzhihua.common.enums.SanShuoEventStatusEnum; import com.panzhihua.common.model.dtos.community.sanshuo.IndexDateDTO; import com.panzhihua.common.model.dtos.user.IndexDataDTO; import com.panzhihua.common.model.vos.LoginUserInfoVO; import com.panzhihua.common.model.vos.R; import com.panzhihua.common.model.vos.sanshuo.ComEventArchiveVO; @@ -313,4 +315,21 @@ public R calculate() { return comEventService.calculate(); } /** * 大屏事件统计 * @param indexDataDTO 查询参数 * */ @PostMapping("/indexData") public R indexData(@RequestBody IndexDateDTO indexDataDTO ){ return comEventService.indexData(indexDataDTO); } /** * 大屏事件统计(事件和专家各级别占比) * */ @GetMapping("/indexData/event") public R eventIndexData(@RequestParam Integer type){ return comEventService.eventIndexData(type); } } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComEventMapper.java
@@ -6,11 +6,14 @@ import com.panzhihua.common.model.dtos.community.sanshuo.IndexDateDTO; import com.panzhihua.common.model.vos.IndexDataVO; import com.panzhihua.common.model.vos.sanshuo.ComEventCalculateVO; import com.panzhihua.common.model.vos.sanshuo.EventRateVO; import com.panzhihua.common.model.vos.sanshuo.IndexDateVO; import com.panzhihua.common.model.vos.sanshuo.MediateTypeVO; import com.panzhihua.service_community.entity.ComEvent; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import java.util.Date; import java.util.List; /** * 三说会堂事件表Mapper @@ -58,7 +61,7 @@ * @param endDate 结束时间 * @author zhangtiansen * */ Integer dateAnalysisY(@Param("beginDate")String beginDate,@Param("endDate")String endDate); Integer dateAnalysisY(@Param("beginDate") Date beginDate, @Param("endDate")Date endDate, @Param("dto") IndexDateDTO indexDateDTO); /** * 大屏事件统计-月办结 @@ -66,5 +69,21 @@ * @param endDate 结束时间 * @author zhangtiansen * */ Integer dateAnalysisYTwo(@Param("beginDate")String beginDate,@Param("endDate")String endDate); Integer dateAnalysisYTwo(@Param("beginDate")Date beginDate,@Param("endDate")Date endDate,@Param("dto") IndexDateDTO indexDateDTO); /** * 大屏事件级别统计 * */ List<EventRateVO> eventRate(); /** * 大屏统计-专家级别占比 * */ List<EventRateVO> expertRate(); /** * 大屏统计-事件类型占比 * */ List<EventRateVO> mediateTypeRate(); } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/IComEventService.java
@@ -2,6 +2,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; import com.panzhihua.common.model.dtos.community.sanshuo.IndexDateDTO; import com.panzhihua.common.model.dtos.user.IndexDataDTO; import com.panzhihua.common.model.vos.LoginUserInfoVO; import com.panzhihua.common.model.vos.R; import com.panzhihua.common.model.vos.sanshuo.ComEventArchiveVO; @@ -87,4 +89,15 @@ R calculate(); R archiveRequest(ComEventArchiveVO comEventArchiveVO, LoginUserInfoVO sysUser); /** * 大屏事件统计 * @param indexDataDTO 查询入参 * */ R indexData(IndexDateDTO indexDataDTO); /** * 大屏事件统计 * */ R eventIndexData(Integer type); } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComEventServiceImpl.java
@@ -1,11 +1,16 @@ package com.panzhihua.service_community.service.impl; import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.NumberUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.panzhihua.common.constants.ReturnMsgConstants; import com.panzhihua.common.enums.SanShuoEventStatusEnum; import com.panzhihua.common.model.dtos.community.sanshuo.IndexDateDTO; import com.panzhihua.common.model.dtos.user.IndexDataDTO; import com.panzhihua.common.model.vos.LoginUserInfoVO; import com.panzhihua.common.model.vos.R; import com.panzhihua.common.model.vos.sanshuo.*; @@ -21,12 +26,16 @@ import com.panzhihua.service_community.model.dos.ComStreetDO; import com.panzhihua.service_community.service.*; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.time.DateFormatUtils; import org.apache.commons.lang3.RandomUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.math.BigDecimal; import java.util.*; import static java.util.Objects.nonNull; /** * Description 三说会堂事件表业务层实现类 @@ -56,6 +65,9 @@ @Resource private ComSanShuoIndustryCenterService comSanShuoIndustryCenterService; @Resource private ComEventMapper comEventMapper; @Override public R pageByComEvent(ComEvent comEvent, Page pagination) { @@ -281,6 +293,136 @@ return R.ok(); } /** * 大屏事件统计 * @param indexDataDTO 查询入参 * */ @Override public R indexData(IndexDateDTO indexDataDTO) { IndexDateVO vo = comEventMapper.dateAnalysis(indexDataDTO); //计算率 if (nonNull(vo.getSuccess()) && !vo.getSuccess().equals(0)){ if (nonNull(vo.getAccepted()) && !vo.getAccepted().equals(0)){ //计算成功率 vo.setSuccessRate(NumberUtil.div(vo.getSuccess(),vo.getAccepted(),2)); } } //折线图X轴 List<Date> dates = pastTwelveMoth(); vo.setX(getYAndM(dates)); //新增 List<Integer> Y1=new ArrayList<>(); List<Integer> Y2=new ArrayList<>(); for (Date date : dates) { Y1.add(comEventMapper.dateAnalysisY(date,DateUtil.endOfMonth(date),indexDataDTO)); Y2.add(comEventMapper.dateAnalysisYTwo(date,DateUtil.endOfMonth(date),indexDataDTO)); } vo.setY1(Y1); vo.setY2(Y2); return R.ok(vo); } @Override public R eventIndexData(Integer type) { //获取事件总数 Integer eventCount = comEventMapper.selectCount(new QueryWrapper<ComEvent>().notIn("event_process_status", (7), (8))); if (type.equals(1)){ //受理级别占比 List<EventRateVO> eventRateVOS = comEventMapper.eventRate(); for (EventRateVO eventRateVO : eventRateVOS) { if (nonNull(eventRateVO)){ eventRateVO.setName(typeToName(eventRateVO.getType())); if (nonNull(eventCount) && !eventCount.equals(0)){ //计算占比 eventRateVO.setRate(NumberUtil.div(eventRateVO.getCount(),eventCount,2)); } } } return R.ok(eventRateVOS); }else if (type.equals(2)){ //专家级别 List<EventRateVO> eventRateVOS = comEventMapper.expertRate(); for (EventRateVO eventRateVO : eventRateVOS) { if (nonNull(eventRateVO)){ eventRateVO.setName(typeToNameExpert(eventRateVO.getType())); if (nonNull(eventCount) && !eventCount.equals(0)){ //计算占比 eventRateVO.setRate(NumberUtil.div(eventRateVO.getCount(),eventCount,2)); } } } return R.ok(eventRateVOS); }else{ //事件类型占比 List<EventRateVO> eventRateVOS = comEventMapper.mediateTypeRate(); for (EventRateVO eventRateVO : eventRateVOS) { if (nonNull(eventRateVO)){ if (nonNull(eventCount) && !eventCount.equals(0)){ //计算占比 eventRateVO.setRate(NumberUtil.div(eventRateVO.getCount(),eventCount,2)); } } } return R.ok(eventRateVOS); } } public String typeToName(Integer type){ switch (type){ case 1: return "行业分中心受理"; case 2: return "街道调解站受理"; case 3: return "社区调解站受理"; case 4: return "区三说会堂受理"; } return null; } public String typeToNameExpert(Integer type){ switch (type){ case 1: return "区三说会堂专家"; case 2: return "行业分中心专家"; case 3: return "街道调解站专家"; case 4: return "社区调解站专家"; } return null; } /** * 过去12个月的月份 * */ private List<Date> pastTwelveMoth(){ List<Date> list=new ArrayList<>(); Date now = new Date(); for (int i = 0; i < 12; i++) { //本月 DateTime dateTime = DateUtil.beginOfMonth(now); DateUtil.format(dateTime,"yyyy-MM-dd"); list.add(dateTime); //减一天进入下一个月 now=DateUtil.offsetDay(now,-1); } return list; } /** * 截取年,月 * */ private List<String> getYAndM(List<Date> dateList){ List<String> list=new ArrayList<>(); for (Date date : dateList) { list.add(DateUtil.format(date,"yyyy-MM").toString()); } return list; } private Boolean checkExist(String sn, Long id) { ComEvent comEvent = new ComEvent(); comEvent.setOrderSn(sn); springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/resources/mapper/ComEventMapper.xml
@@ -89,10 +89,16 @@ AND request_user_community=#{dto.id} </if> </if> <if test="dto.type == 1"> AND type=4 </if> ) as accept, (SELECT count(id) FROM com_sanshuo_event_info where event_process_status = 5 AND user_event_status not in(3,4) <if test="dto.type == 1"> AND type=4 </if> <if test="dto.type == 2"> AND type=1 <if test="dto.id != null"> @@ -114,6 +120,9 @@ (SELECT count(id) FROM com_sanshuo_event_info where event_process_status = 6 AND user_event_status not in(3,4) <if test="dto.type == 1"> AND type=4 </if> <if test="dto.type == 2"> AND type=1 <if test="dto.id != null"> @@ -135,6 +144,9 @@ (SELECT count(id) FROM com_sanshuo_event_info where event_process_status in (6,7) AND user_event_status not in(3,4) <if test="dto.type == 1"> AND type=4 </if> <if test="dto.type == 2"> AND type=1 <if test="dto.id != null"> @@ -156,6 +168,9 @@ (select count(id) FROM com_sanshuo_event_info where event_result=1 AND user_event_status not in(3,4) <if test="dto.type == 1"> AND type=4 </if> <if test="dto.type == 2"> AND type=1 <if test="dto.id != null"> @@ -177,6 +192,9 @@ (select count(id) FROM com_sanshuo_event_info where event_result=2 AND user_event_status not in(3,4) <if test="dto.type == 1"> AND type=4 </if> <if test="dto.type == 2"> AND type=1 <if test="dto.id != null"> @@ -197,6 +215,9 @@ </if>) as fail, (select count(id) from com_sanshuo_expert where `status`=1 and del_flag=1 AND user_event_status not in(3,4) <if test="dto.type == 1"> AND type=4 </if> <if test="dto.type == 2"> AND type=1 <if test="dto.id != null"> @@ -220,11 +241,73 @@ <select id="dateAnalysisY" resultType="java.lang.Integer"> SELECT COUNT(id) FROM com_sanshuo_event_info WHERE create_time BETWEEN DATE_FORMAT(#{beginDate}, '%Y-%m-%d 00:00:00') AND DATE_FORMAT(#{endDate}, '%Y-%m-%d 23:59:59') <if test="dto.type != null"> <if test="dto.type == 1"> AND type=4 </if> <if test="dto.type=2"> AND type=1 <if test="dto.id != null"> AND center_id=#{dto.id} </if> </if> <if test="dto.type == 3"> AND type=2 <if test="dto.id != null"> AND request_user_community in (select com_act.community_id from com_act where street_id=#{dto.id}) </if> </if> <if test="dto.type == 4"> AND type=3 <if test="dto.id != null"> AND request_user_community=#{dto.id} </if> </if> </if> </select> <select id="dateAnalysisYTwo" resultType="java.lang.Integer"> SELECT COUNT(id) FROM com_sanshuo_event_info WHERE create_time BETWEEN DATE_FORMAT(#{beginDate}, '%Y-%m-%d 00:00:00') AND DATE_FORMAT(#{endDate}, '%Y-%m-%d 23:59:59') AND event_process_status=6 <if test="dto.type != null"> <if test="dto.type == 1"> AND type=4 </if> <if test="dto.type=2"> AND type=1 <if test="dto.id != null"> AND center_id=#{dto.id} </if> </if> <if test="dto.type == 3"> AND type=2 <if test="dto.id != null"> AND request_user_community in (select com_act.community_id from com_act where street_id=#{dto.id}) </if> </if> <if test="dto.type == 4"> AND type=3 <if test="dto.id != null"> AND request_user_community=#{dto.id} </if> </if> </if> </select> <select id="eventRate" resultType="com.panzhihua.common.model.vos.sanshuo.EventRateVO"> select count(id) as count,type from com_sanshuo_event_info where event_process_status not in(7.8) group by type </select> <select id="expertRate" resultType="com.panzhihua.common.model.vos.sanshuo.EventRateVO"> select count(id) as count,type from com_sanshuo_event_info where event_process_status not in(7.8) group by type </select> <select id="mediateTypeRate" resultType="com.panzhihua.common.model.vos.sanshuo.EventRateVO"> select count(t.id) as count,t1.name from com_sanshuo_event_info t left join com_mediate_type t1 on t.event_category=t1.id where t.event_process_status not in(7.8) group by t.event_category </select>