Browse Source

大屏相关数据统计

feature/dangjian
zhaoqifeng 3 years ago
parent
commit
19ebbf0125
  1. 1
      esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/screen/form/EventStatisticsFormDTO.java
  2. 21
      esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/screen/result/BarCategoryDTO.java
  3. 21
      esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/screen/result/BarCategoryDetail.java
  4. 19
      esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/screen/result/BarCategoryResultDTO.java
  5. 58
      esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/screen/result/EfficiencyEvaluationResultDTO.java
  6. 19
      esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/screen/result/LegendDTO.java
  7. 86
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/screen/controller/ScreenController.java
  8. 68
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/screen/controller/ScreenItemController.java
  9. 20
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/screen/dao/ScreenDeptEventEfficiencyDao.java
  10. 16
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/screen/entity/ScreenDeptEventEfficiencyEntity.java
  11. 80
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/screen/service/ScreenDeptEventEfficiencyService.java
  12. 258
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/screen/service/impl/ScreenDeptEventEfficiencyServiceImpl.java
  13. 19
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/screen/service/impl/ScreenDeptEventStatServiceImpl.java
  14. 95
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/screen/ScreenDeptEventEfficiencyDao.xml
  15. 1
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/screen/ScreenDeptEventStatDao.xml

1
esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/screen/form/EventStatisticsFormDTO.java

@ -23,4 +23,5 @@ public class EventStatisticsFormDTO implements Serializable {
private String statDate;
private String startDate;
private String endDate;
private String type;
}

21
esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/screen/result/BarCategoryDTO.java

@ -0,0 +1,21 @@
package com.elink.esua.epdc.dto.screen.result;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.List;
/**
* @author Administrator
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class BarCategoryDTO implements Serializable {
private static final long serialVersionUID = 1L;
private String categoryCode;
private String categoryName;
private List<BarCategoryDetail> detail;
}

21
esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/screen/result/BarCategoryDetail.java

@ -0,0 +1,21 @@
package com.elink.esua.epdc.dto.screen.result;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* @Description
* @Author zhaoqifeng
* @Date 2022/10/12 16:06
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class BarCategoryDetail implements Serializable {
private static final long serialVersionUID = 1L;
private String legendName;
private Integer count;
}

19
esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/screen/result/BarCategoryResultDTO.java

@ -0,0 +1,19 @@
package com.elink.esua.epdc.dto.screen.result;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @Description
* @Author zhaoqifeng
* @Date 2022/10/12 16:07
*/
@Data
public class BarCategoryResultDTO implements Serializable {
private static final long serialVersionUID = 1L;
private List<LegendDTO> legend;
private List<BarCategoryDTO> categoryList;
}

58
esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/screen/result/EfficiencyEvaluationResultDTO.java

@ -0,0 +1,58 @@
package com.elink.esua.epdc.dto.screen.result;
import lombok.Data;
import java.io.Serializable;
/**
* @Description
* @Author zhaoqifeng
* @Date 2022/10/12 10:47
*/
@Data
public class EfficiencyEvaluationResultDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 部门ID
*/
private String deptId;
/**
* 部门名称
*/
private String deptName;
/**
* 事件总数
*/
private Integer eventCount;
/**
* 结案数
*/
private Integer closedCount;
/**
* 响应数
*/
private Integer responseCount;
/**
* 满意数
*/
private Integer satisfiedCount;
/**
* 响应率
*/
private String responseRatio;
/**
* 满意率
*/
private String satisfiedRatio;
/**
* 结案率
*/
private String closedRatio;
}

19
esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/screen/result/LegendDTO.java

@ -0,0 +1,19 @@
package com.elink.esua.epdc.dto.screen.result;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* 服务措施分析-柱状图
* @author Administrator
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class LegendDTO implements Serializable {
private static final long serialVersionUID = 1L;
private String legendName;
}

86
esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/screen/controller/ScreenController.java

@ -0,0 +1,86 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.modules.screen.controller;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils;
import com.elink.esua.epdc.commons.tools.validator.group.AddGroup;
import com.elink.esua.epdc.dto.events.form.ItemDailyStatisFormDTO;
import com.elink.esua.epdc.dto.events.result.ItemDailyStatisResultDTO;
import com.elink.esua.epdc.dto.screen.form.EventStatisticsFormDTO;
import com.elink.esua.epdc.dto.screen.result.BarCategoryResultDTO;
import com.elink.esua.epdc.dto.screen.result.EfficiencyEvaluationResultDTO;
import com.elink.esua.epdc.dto.screen.result.EventStatisticsResultDTO;
import com.elink.esua.epdc.modules.screen.service.ScreenDeptEventEfficiencyService;
import com.elink.esua.epdc.modules.screen.service.ScreenDeptEventStatService;
import com.elink.esua.epdc.modules.screen.service.ScreenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
/**
* 大屏接口
* @author Administrator
*/
@RestController
@RequestMapping("screen")
public class ScreenController {
@Resource
private ScreenDeptEventEfficiencyService screenDeptEventEfficiencyService;
@Resource
private ScreenDeptEventStatService screenDeptEventStatService;
/**
* 大屏-事件&结案数统计柱状图
*
* @return
*/
@PostMapping("getEventBar")
public Result<BarCategoryResultDTO> getEventBar(@RequestBody EventStatisticsFormDTO formDTO) {
return new Result<BarCategoryResultDTO>().ok(screenDeptEventEfficiencyService.getEventBar(formDTO));
}
/**
* 大屏-效能评价
*
* @return
*/
@PostMapping("getEfficiencyEvaluation")
public Result<List<EfficiencyEvaluationResultDTO>> getEfficiencyEvaluation(@RequestBody EventStatisticsFormDTO formDTO) {
return new Result<List<EfficiencyEvaluationResultDTO>>().ok(screenDeptEventEfficiencyService.getEfficiencyEvaluation(formDTO));
}
/**
* 大屏-汇总统计
*/
@PostMapping("getEventStat")
public Result<List<EventStatisticsResultDTO>> getEventStat(@RequestBody EventStatisticsFormDTO formDTO) {
return new Result<List<EventStatisticsResultDTO>>().ok(screenDeptEventStatService.getEventStat(formDTO));
}
}

68
esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/screen/controller/ScreenItemController.java

@ -17,18 +17,30 @@
package com.elink.esua.epdc.modules.screen.controller;
import com.elink.esua.epdc.commons.tools.constant.NumConstant;
import com.elink.esua.epdc.commons.tools.utils.DateUtils;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils;
import com.elink.esua.epdc.commons.tools.validator.group.AddGroup;
import com.elink.esua.epdc.dto.events.form.ItemDailyStatisFormDTO;
import com.elink.esua.epdc.dto.events.result.ItemDailyStatisResultDTO;
import com.elink.esua.epdc.dto.screen.form.DataStatisticsFormDTO;
import com.elink.esua.epdc.modules.screen.service.ScreenDeptEventEfficiencyService;
import com.elink.esua.epdc.modules.screen.service.ScreenDeptEventStatService;
import com.elink.esua.epdc.modules.screen.service.ScreenService;
import org.apache.commons.lang3.StringUtils;
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* 项目统计相关接口
@ -39,7 +51,10 @@ public class ScreenItemController {
@Autowired
private ScreenService screenService;
@Resource
private ScreenDeptEventEfficiencyService screenDeptEventEfficiencyService;
@Resource
private ScreenDeptEventStatService screenDeptEventStatService;
/**
@ -53,4 +68,55 @@ public class ScreenItemController {
return new Result<ItemDailyStatisResultDTO>().ok(screenService.itemDailyStatis(formDTO));
}
@PostMapping("deptEventStat/dataStatistics")
public Result dataStatistics(@RequestBody DataStatisticsFormDTO formDTO) {
List<String> dateIds = new ArrayList<>();
if ((StringUtils.isBlank(formDTO.getStartDate()) && StringUtils.isBlank(formDTO.getEndDate()))){
if (StringUtils.isNotBlank(formDTO.getStatDate())){
dateIds.add(formDTO.getStatDate());
}else {
dateIds.add(DateUtils.format(DateUtils.addDateDays(new Date(), -1), DateUtils.DATE_PATTERN));
}
}else {
dateIds = DateUtils.getDaysBetween(formDTO.getStartDate(), formDTO.getEndDate());
}
dateIds.forEach(date -> {
formDTO.setStatDate(date);
screenDeptEventStatService.dataStatistics(formDTO);
});
return new Result();
}
@PostMapping("deptEventEfficiency/dataStatistics")
public Result eventEfficiencyStatistics(@RequestBody DataStatisticsFormDTO formDTO) {
List<String> dateIds = new ArrayList<>();
if ((StringUtils.isBlank(formDTO.getStartDate()) && StringUtils.isBlank(formDTO.getEndDate()))){
if (StringUtils.isNotBlank(formDTO.getStatDate())){
dateIds.add(formDTO.getStatDate());
}else {
dateIds.add(DateUtils.format(DateUtils.addDateDays(new Date(), -1), DateUtils.DATE_PATTERN));
}
}else {
dateIds = DateUtils.getDaysBetween(formDTO.getStartDate(), formDTO.getEndDate());
}
dateIds.forEach(date -> {
Date d = DateUtils.parse(date, DateUtils.DATE_PATTERN);
formDTO.setStatDate(date);
screenDeptEventEfficiencyService.dataStatisticsDaily(formDTO);
DateTime dateTime = new DateTime(d);
if (dateTime.getDayOfMonth() == 1) {
String statDate = DateUtils.format(DateUtils.addDateMonths(d, -1), "yyyy-MM");
formDTO.setStatDate(statDate);
screenDeptEventEfficiencyService.dataStatisticsMonthly(formDTO);
}
if (dateTime.getDayOfYear() == 1) {
String statDate = DateUtils.format(DateUtils.addDateYears(d, -1), "yyyy");
formDTO.setStatDate(statDate);
screenDeptEventEfficiencyService.dataStatisticsYearly(formDTO);
}
});
return new Result();
}
}

20
esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/screen/dao/ScreenDeptEventEfficiencyDao.java

@ -18,6 +18,8 @@
package com.elink.esua.epdc.modules.screen.dao;
import com.elink.esua.epdc.commons.mybatis.dao.BaseDao;
import com.elink.esua.epdc.dto.screen.form.EventStatisticsFormDTO;
import com.elink.esua.epdc.dto.screen.result.EfficiencyEvaluationResultDTO;
import com.elink.esua.epdc.modules.screen.entity.ScreenDeptEventEfficiencyEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -58,4 +60,22 @@ public interface ScreenDeptEventEfficiencyDao extends BaseDao<ScreenDeptEventEff
* @Date 2022/10/11 15:50
*/
List<ScreenDeptEventEfficiencyEntity> getEventEfficiencyYearly(@Param("statDate") String statDate);
/**
* 获取大屏数据
* @Param formDTO
* @Return {@link List< EfficiencyEvaluationResultDTO>}
* @Author zhaoqifeng
* @Date 2022/10/12 14:04
*/
List<EfficiencyEvaluationResultDTO> getScreenData(EventStatisticsFormDTO formDTO);
/**
* 获取大屏数据-自定义时间区间
* @Param formDTO
* @Return {@link List< EfficiencyEvaluationResultDTO>}
* @Author zhaoqifeng
* @Date 2022/10/12 14:40
*/
List<EfficiencyEvaluationResultDTO> getScreenDataByInterval(EventStatisticsFormDTO formDTO);
}

16
esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/screen/entity/ScreenDeptEventEfficiencyEntity.java

@ -23,6 +23,7 @@ import com.elink.esua.epdc.commons.mybatis.entity.BaseEpdcEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
import java.util.Date;
/**
@ -98,4 +99,19 @@ public class ScreenDeptEventEfficiencyEntity extends BaseEpdcEntity {
*/
private Integer closedCount;
/**
* 响应率
*/
private BigDecimal responseRatio;
/**
* 满意率
*/
private BigDecimal satisfiedRatio;
/**
* 结案率
*/
private BigDecimal closedRatio;
}

80
esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/screen/service/ScreenDeptEventEfficiencyService.java

@ -18,12 +18,13 @@
package com.elink.esua.epdc.modules.screen.service;
import com.elink.esua.epdc.commons.mybatis.service.BaseService;
import com.elink.esua.epdc.commons.tools.page.PageData;
import com.elink.esua.epdc.dto.screen.ScreenDeptEventEfficiencyDTO;
import com.elink.esua.epdc.dto.screen.form.DataStatisticsFormDTO;
import com.elink.esua.epdc.dto.screen.form.EventStatisticsFormDTO;
import com.elink.esua.epdc.dto.screen.result.BarCategoryResultDTO;
import com.elink.esua.epdc.dto.screen.result.EfficiencyEvaluationResultDTO;
import com.elink.esua.epdc.modules.screen.entity.ScreenDeptEventEfficiencyEntity;
import java.util.List;
import java.util.Map;
/**
* 大屏-事件结案数与效能评价统计
@ -32,64 +33,51 @@ import java.util.Map;
* @since v1.0.0 2022-10-11
*/
public interface ScreenDeptEventEfficiencyService extends BaseService<ScreenDeptEventEfficiencyEntity> {
/**
* 默认分页
* 大屏数据统计-按天
*
* @param params
* @return PageData<ScreenDeptEventEfficiencyDTO>
* @author generator
* @date 2022-10-11
* @Param formDTO
* @Return
* @Author zhaoqifeng
* @Date 2022/10/11 10:24
*/
PageData<ScreenDeptEventEfficiencyDTO> page(Map<String, Object> params);
void dataStatisticsDaily(DataStatisticsFormDTO formDTO);
/**
* 默认查询
* 大屏数据统计-按月
*
* @param params
* @return java.util.List<ScreenDeptEventEfficiencyDTO>
* @author generator
* @date 2022-10-11
* @Param formDTO
* @Return
* @Author zhaoqifeng
* @Date 2022/10/11 10:24
*/
List<ScreenDeptEventEfficiencyDTO> list(Map<String, Object> params);
void dataStatisticsMonthly(DataStatisticsFormDTO formDTO);
/**
* 单条查询
* 大屏数据统计-按年
*
* @param id
* @return ScreenDeptEventEfficiencyDTO
* @author generator
* @date 2022-10-11
* @Param formDTO
* @Return
* @Author zhaoqifeng
* @Date 2022/10/11 10:24
*/
ScreenDeptEventEfficiencyDTO get(String id);
void dataStatisticsYearly(DataStatisticsFormDTO formDTO);
/**
* 默认保存
*
* @param dto
* @return void
* @author generator
* @date 2022-10-11
* 大屏-效能评价
* @Param formDTO
* @Return {@link List< EfficiencyEvaluationResultDTO>}
* @Author zhaoqifeng
* @Date 2022/10/12 11:00
*/
void save(ScreenDeptEventEfficiencyDTO dto);
List<EfficiencyEvaluationResultDTO> getEfficiencyEvaluation(EventStatisticsFormDTO formDTO);
/**
* 默认更新
*
* @param dto
* @return void
* @author generator
* @date 2022-10-11
*/
void update(ScreenDeptEventEfficiencyDTO dto);
/**
* 批量删除
*
* @param ids
* @return void
* @author generator
* @date 2022-10-11
* 大屏-事件数&结案数柱状图
* @Param formDTO
* @Return {@link BarCategoryResultDTO}
* @Author zhaoqifeng
* @Date 2022/10/12 16:11
*/
void delete(String[] ids);
BarCategoryResultDTO getEventBar(EventStatisticsFormDTO formDTO);
}

258
esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/screen/service/impl/ScreenDeptEventEfficiencyServiceImpl.java

@ -17,24 +17,28 @@
package com.elink.esua.epdc.modules.screen.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl;
import com.elink.esua.epdc.commons.tools.page.PageData;
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils;
import com.elink.esua.epdc.commons.tools.constant.FieldConstant;
import com.elink.esua.epdc.dto.screen.ScreenDeptEventEfficiencyDTO;
import com.elink.esua.epdc.commons.tools.constant.NumConstant;
import com.elink.esua.epdc.commons.tools.utils.DateUtils;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.dto.SysDeptDTO;
import com.elink.esua.epdc.dto.screen.form.DataStatisticsFormDTO;
import com.elink.esua.epdc.dto.screen.form.EventStatisticsFormDTO;
import com.elink.esua.epdc.dto.screen.result.*;
import com.elink.esua.epdc.modules.screen.dao.ScreenDeptEventEfficiencyDao;
import com.elink.esua.epdc.modules.screen.entity.ScreenDeptEventEfficiencyEntity;
import com.elink.esua.epdc.modules.screen.service.ScreenDeptEventEfficiencyService;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 大屏-事件结案数与效能评价统计
@ -46,56 +50,220 @@ import java.util.Map;
public class ScreenDeptEventEfficiencyServiceImpl extends BaseServiceImpl<ScreenDeptEventEfficiencyDao, ScreenDeptEventEfficiencyEntity> implements ScreenDeptEventEfficiencyService {
/**
* 大屏数据统计-按天
*
* @param formDTO
* @Param formDTO
* @Return
* @Author zhaoqifeng
* @Date 2022/10/11 10:24
*/
@Override
public PageData<ScreenDeptEventEfficiencyDTO> page(Map<String, Object> params) {
IPage<ScreenDeptEventEfficiencyEntity> page = baseDao.selectPage(
getPage(params, FieldConstant.CREATED_TIME, false),
getWrapper(params)
);
return getPageData(page, ScreenDeptEventEfficiencyDTO.class);
public void dataStatisticsDaily(DataStatisticsFormDTO formDTO) {
String statDate;
if (StringUtils.isBlank(formDTO.getStatDate())) {
statDate = DateUtils.format(DateUtils.addDateDays(new Date(), -1), DateUtils.DATE_PATTERN);
} else {
statDate = formDTO.getStatDate();
}
List<ScreenDeptEventEfficiencyEntity> list = baseDao.getEventEfficiencyDaily(statDate);
if (CollectionUtils.isNotEmpty(list)) {
list.forEach(item -> {
item.setStatDate(statDate);
BigDecimal hundred = new BigDecimal(NumConstant.ONE_HUNDRED);
BigDecimal eventCount = new BigDecimal(item.getEventCount());
BigDecimal closedCount = new BigDecimal(item.getClosedCount());
BigDecimal responseCount = new BigDecimal(item.getResponseCount());
BigDecimal satisfiedCount = new BigDecimal(item.getSatisfiedCount());
item.setClosedRatio(closedCount.multiply(hundred).divide(eventCount, NumConstant.SIX, RoundingMode.HALF_UP));
item.setResponseRatio(responseCount.multiply(hundred).divide(eventCount, NumConstant.SIX, RoundingMode.HALF_UP));
item.setSatisfiedRatio(satisfiedCount.multiply(hundred).divide(eventCount, NumConstant.SIX, RoundingMode.HALF_UP));
});
insertBatch(list);
}
}
/**
* 大屏数据统计-按月
*
* @param formDTO
* @Param formDTO
* @Return
* @Author zhaoqifeng
* @Date 2022/10/11 10:24
*/
@Override
public List<ScreenDeptEventEfficiencyDTO> list(Map<String, Object> params) {
List<ScreenDeptEventEfficiencyEntity> entityList = baseDao.selectList(getWrapper(params));
public void dataStatisticsMonthly(DataStatisticsFormDTO formDTO) {
String statDate;
if (StringUtils.isBlank(formDTO.getStatDate())) {
statDate = DateUtils.format(DateUtils.addDateMonths(new Date(), -1), "yyyy-MM");
} else {
statDate = formDTO.getStatDate();
}
List<ScreenDeptEventEfficiencyEntity> list = baseDao.getEventEfficiencyDaily(statDate);
if (CollectionUtils.isNotEmpty(list)) {
list.forEach(item -> {
item.setStatDate(statDate);
BigDecimal hundred = new BigDecimal(NumConstant.ONE_HUNDRED);
BigDecimal eventCount = new BigDecimal(item.getEventCount());
BigDecimal closedCount = new BigDecimal(item.getClosedCount());
BigDecimal responseCount = new BigDecimal(item.getResponseCount());
BigDecimal satisfiedCount = new BigDecimal(item.getSatisfiedCount());
item.setClosedRatio(closedCount.multiply(hundred).divide(eventCount, NumConstant.SIX, RoundingMode.HALF_UP));
item.setResponseRatio(responseCount.multiply(hundred).divide(eventCount, NumConstant.SIX, RoundingMode.HALF_UP));
item.setSatisfiedRatio(satisfiedCount.multiply(hundred).divide(eventCount, NumConstant.SIX, RoundingMode.HALF_UP));
});
insertBatch(list);
}
}
return ConvertUtils.sourceToTarget(entityList, ScreenDeptEventEfficiencyDTO.class);
/**
* 大屏数据统计-按年
*
* @param formDTO
* @Param formDTO
* @Return
* @Author zhaoqifeng
* @Date 2022/10/11 10:24
*/
@Override
public void dataStatisticsYearly(DataStatisticsFormDTO formDTO) {
String statDate;
if (StringUtils.isBlank(formDTO.getStatDate())) {
statDate = DateUtils.format(DateUtils.addDateYears(new Date(), -1), "yyyy");
} else {
statDate = formDTO.getStatDate();
}
List<ScreenDeptEventEfficiencyEntity> list = baseDao.getEventEfficiencyDaily(statDate);
if (CollectionUtils.isNotEmpty(list)) {
list.forEach(item -> {
item.setStatDate(statDate);
BigDecimal hundred = new BigDecimal(NumConstant.ONE_HUNDRED);
BigDecimal eventCount = new BigDecimal(item.getEventCount());
BigDecimal closedCount = new BigDecimal(item.getClosedCount());
BigDecimal responseCount = new BigDecimal(item.getResponseCount());
BigDecimal satisfiedCount = new BigDecimal(item.getSatisfiedCount());
item.setClosedRatio(closedCount.multiply(hundred).divide(eventCount, NumConstant.SIX, RoundingMode.HALF_UP));
item.setResponseRatio(responseCount.multiply(hundred).divide(eventCount, NumConstant.SIX, RoundingMode.HALF_UP));
item.setSatisfiedRatio(satisfiedCount.multiply(hundred).divide(eventCount, NumConstant.SIX, RoundingMode.HALF_UP));
});
insertBatch(list);
}
}
private QueryWrapper<ScreenDeptEventEfficiencyEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP);
/**
* 大屏-效能评价
*
* @param formDTO
* @Param formDTO
* @Return {@link List< EfficiencyEvaluationResultDTO >}
* @Author zhaoqifeng
* @Date 2022/10/12 11:00
*/
@Override
public List<EfficiencyEvaluationResultDTO> getEfficiencyEvaluation(EventStatisticsFormDTO formDTO) {
QueryWrapper<ScreenDeptEventEfficiencyEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
if (NumConstant.ONE_STR.equals(formDTO.getStatType())) {
//日期为当前日期前一天
formDTO.setStatDate(DateUtils.format(DateUtils.addDateDays(new Date(), -1), DateUtils.DATE_PATTERN));
} else if (NumConstant.TWO_STR.equals(formDTO.getStatType())) {
//日期为本月
formDTO.setStatDate(DateUtils.format(new Date(), DateUtils.DATE_PATTERN).substring(0, 7));
} else if (NumConstant.THREE_STR.equals(formDTO.getStatType())) {
//日期为本年
formDTO.setStatDate(DateUtils.format(new Date(), DateUtils.DATE_PATTERN).substring(0, 4));
} else {
//自定义区间
List<EfficiencyEvaluationResultDTO> list = baseDao.getScreenDataByInterval(formDTO);
if (CollectionUtils.isNotEmpty(list)) {
list.forEach(item -> {
//计算结案率,响应率,满意率
if (item.getEventCount() != NumConstant.ZERO) {
BigDecimal hundred = new BigDecimal(NumConstant.ONE_HUNDRED);
BigDecimal eventCount = new BigDecimal(item.getEventCount());
BigDecimal closedCount = new BigDecimal(item.getClosedCount());
BigDecimal responseCount = new BigDecimal(item.getResponseCount());
BigDecimal satisfiedCount = new BigDecimal(item.getSatisfiedCount());
String closedRatio = closedCount.multiply(hundred).divide(eventCount, NumConstant.ONE, RoundingMode.HALF_UP).stripTrailingZeros().toPlainString();
String responseRatio = responseCount.multiply(hundred).divide(eventCount, NumConstant.ONE, RoundingMode.HALF_UP).stripTrailingZeros().toPlainString();
String satisfiedRatio = satisfiedCount.multiply(hundred).divide(eventCount, NumConstant.ONE, RoundingMode.HALF_UP).stripTrailingZeros().toPlainString();
item.setClosedRatio(closedRatio.concat("%"));
item.setResponseRatio(responseRatio.concat("%"));
item.setSatisfiedRatio(satisfiedRatio.concat("%"));
} else {
item.setClosedRatio("0%");
item.setResponseRatio("0%");
item.setSatisfiedRatio("0%");
}
});
}
return list;
}
return wrapper;
return baseDao.getScreenData(formDTO);
}
/**
* 大屏-事件数&结案数柱状图
*
* @param formDTO
* @Param formDTO
* @Return {@link BarCategoryResultDTO}
* @Author zhaoqifeng
* @Date 2022/10/12 16:11
*/
@Override
public ScreenDeptEventEfficiencyDTO get(String id) {
ScreenDeptEventEfficiencyEntity entity = baseDao.selectById(id);
return ConvertUtils.sourceToTarget(entity, ScreenDeptEventEfficiencyDTO.class);
}
public BarCategoryResultDTO getEventBar(EventStatisticsFormDTO formDTO) {
BarCategoryResultDTO result = new BarCategoryResultDTO();
@Override
@Transactional(rollbackFor = Exception.class)
public void save(ScreenDeptEventEfficiencyDTO dto) {
ScreenDeptEventEfficiencyEntity entity = ConvertUtils.sourceToTarget(dto, ScreenDeptEventEfficiencyEntity.class);
insert(entity);
}
List<LegendDTO> legendList = new ArrayList<>();
LegendDTO event = new LegendDTO();
event.setLegendName("事件数");
legendList.add(event);
LegendDTO closed = new LegendDTO();
closed.setLegendName("结案数");
legendList.add(closed);
result.setLegend(legendList);
@Override
@Transactional(rollbackFor = Exception.class)
public void update(ScreenDeptEventEfficiencyDTO dto) {
ScreenDeptEventEfficiencyEntity entity = ConvertUtils.sourceToTarget(dto, ScreenDeptEventEfficiencyEntity.class);
updateById(entity);
if (NumConstant.ONE_STR.equals(formDTO.getStatType())) {
//日期为当前日期前一天
formDTO.setStatDate(DateUtils.format(DateUtils.addDateDays(new Date(), -1), DateUtils.DATE_PATTERN));
} else if (NumConstant.TWO_STR.equals(formDTO.getStatType())) {
//日期为本月
formDTO.setStatDate(DateUtils.format(new Date(), DateUtils.DATE_PATTERN).substring(0, 7));
} else if (NumConstant.THREE_STR.equals(formDTO.getStatType())) {
//日期为本年
formDTO.setStatDate(DateUtils.format(new Date(), DateUtils.DATE_PATTERN).substring(0, 4));
} else {
//自定义区间
List<EfficiencyEvaluationResultDTO> list = baseDao.getScreenDataByInterval(formDTO);
return getBarCategoryResultDTO(result, list);
}
List<EfficiencyEvaluationResultDTO> list = baseDao.getScreenData(formDTO);
return getBarCategoryResultDTO(result, list);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(String[] ids) {
// 逻辑删除(@TableLogic 注解)
baseDao.deleteBatchIds(Arrays.asList(ids));
private BarCategoryResultDTO getBarCategoryResultDTO(BarCategoryResultDTO result, List<EfficiencyEvaluationResultDTO> list) {
if (CollectionUtils.isNotEmpty(list)) {
List<BarCategoryDTO> barList = list.stream().map(item -> {
BarCategoryDTO dto = new BarCategoryDTO();
dto.setCategoryCode(item.getDeptId());
dto.setCategoryName(item.getDeptName());
List<BarCategoryDetail> detail = new ArrayList<>();
BarCategoryDetail eventDetail = new BarCategoryDetail();
eventDetail.setLegendName("事件数");
eventDetail.setCount(item.getEventCount());
detail.add(eventDetail);
BarCategoryDetail closedDetail = new BarCategoryDetail();
closedDetail.setLegendName("结案数");
closedDetail.setCount(item.getEventCount());
detail.add(closedDetail);
dto.setDetail(detail);
return dto;
}).collect(Collectors.toList());
result.setCategoryList(barList);
}
return result;
}
}

19
esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/screen/service/impl/ScreenDeptEventStatServiceImpl.java

@ -17,28 +17,27 @@
package com.elink.esua.epdc.modules.screen.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl;
import com.elink.esua.epdc.commons.tools.constant.NumConstant;
import com.elink.esua.epdc.commons.tools.page.PageData;
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils;
import com.elink.esua.epdc.commons.tools.constant.FieldConstant;
import com.elink.esua.epdc.commons.tools.utils.DateUtils;
import com.elink.esua.epdc.dto.screen.ScreenDeptEventStatDTO;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.dto.SysDeptDTO;
import com.elink.esua.epdc.dto.screen.form.DataStatisticsFormDTO;
import com.elink.esua.epdc.dto.screen.form.EventStatisticsFormDTO;
import com.elink.esua.epdc.dto.screen.result.EventStatisticsResultDTO;
import com.elink.esua.epdc.modules.feign.AdminFeignClient;
import com.elink.esua.epdc.modules.screen.dao.ScreenDeptEventStatDao;
import com.elink.esua.epdc.modules.screen.entity.ScreenDeptEventStatEntity;
import com.elink.esua.epdc.modules.screen.service.ScreenDeptEventStatService;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import javax.annotation.Resource;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
@ -65,7 +64,7 @@ public class ScreenDeptEventStatServiceImpl extends BaseServiceImpl<ScreenDeptEv
String statMonth;
String statYear;
if (StringUtils.isBlank(formDTO.getStatDate())) {
statDate = DateUtils.format(new Date(), DateUtils.DATE_PATTERN);
statDate = DateUtils.format(DateUtils.addDateDays(new Date(), -1), DateUtils.DATE_PATTERN);
statMonth = statDate.substring(0,7);
statYear = statDate.substring(0,4);
} else {

95
esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/screen/ScreenDeptEventEfficiencyDao.xml

@ -89,7 +89,6 @@
GROUP BY ALL_DEPT_IDS
) b ON b.ALL_DEPT_IDS LIKE CONCAT('%', a.id, '%')
WHERE a.del_flag = '0'
AND a.type_key = 'street_party'
GROUP BY a.id
</select>
<select id="getEventEfficiencyYearly" resultType="com.elink.esua.epdc.modules.screen.entity.ScreenDeptEventEfficiencyEntity">
@ -144,7 +143,99 @@
GROUP BY ALL_DEPT_IDS
) b ON b.ALL_DEPT_IDS LIKE CONCAT('%', a.id, '%')
WHERE a.del_flag = '0'
AND a.type_key = 'street_party'
GROUP BY a.id
</select>
<select id="getScreenData" resultType="com.elink.esua.epdc.dto.screen.result.EfficiencyEvaluationResultDTO">
SELECT DEPT_ID,
DEPT_NAME,
EVENT_COUNT,
CLOSED_COUNT,
RESPONSE_COUNT,
SATISFIED_COUNT,
CONCAT(ROUND(RESPONSE_RATIO, 1), '%') RESPONSE_RATIO,
CONCAT(ROUND(SATISFIED_RATIO, 1), '%') SATISFIED_RATIO,
CONCAT(ROUND(CLOSED_RATIO, 1), '%') CLOSED_RATIO
FROM screen_dept_event_efficiency
WHERE DEL_FLAG = '0'
AND PID = #{deptId}
<if test='type == "2"'>
AND DEPT_LEVEL = 'street_dept'
</if>
<if test='type != "2"'>
AND DEPT_LEVEL != 'street_dept'
</if>
AND STAT_TYPE = #{statType}
AND STAT_DATE = #{statDate}
ORDER BY DEPT_SORT ASC,
CONVERT(DEPT_NAME USING gbk) ASC
</select>
<select id="getScreenDataByInterval" resultType="com.elink.esua.epdc.dto.screen.result.EfficiencyEvaluationResultDTO">
SELECT a.id AS deptId,
a.`name` AS deptName,
IFNULL(SUM(b.eventCount), 0) AS eventCount,
IFNULL(SUM(b.closedCount), 0) AS closedCount,
IFNULL(SUM(b.responseCount), 0) AS responseCount,
IFNULL(SUM(b.satisfiedCount), 0) AS satisfiedCount
FROM meta_sys_dept a
LEFT JOIN (
SELECT ALL_DEPT_IDS,
COUNT(ID) AS eventCount,
COUNT(CASE
WHEN ITEM_STATE = '10' AND DATE_FORMAT(UPDATED_TIME, '%Y-%m-%d') &gt;= #{startDate} AND
DATE_FORMAT(UPDATED_TIME, '%Y-%m-%d') &lt;= #{endDate}
THEN ID END) AS closedCount,
COUNT(CASE
WHEN DATE_FORMAT(b.CREATED_TIME, '%Y-%m-%d') &gt;= #{startDate} AND
DATE_FORMAT(b.CREATED_TIME,
'%Y-%m-%d') &lt;= #{endDate}
THEN ID END) AS responseCount,
COUNT(CASE
WHEN DATE_FORMAT(EVALUATION_TIME, '%Y-%m-%d') &gt;= #{startDate} AND
DATE_FORMAT(EVALUATION_TIME,
'%Y-%m-%d') &lt;= #{endDate} AND EVALUATION_SCORE > 0
THEN ID END) AS satisfiedCount
FROM epdc_item a
LEFT JOIN (
SELECT a.ITEM_ID,
a.CREATED_TIME
FROM (
SELECT b.ID,
b.ITEM_ID,
b.CREATED_TIME
FROM (
SELECT ID
FROM epdc_item
WHERE DEL_FLAG = '0'
AND PEOPLE_FLAG IS NOT NULL
AND DATE_FORMAT(CREATED_TIME, '%Y-%m-%d') &gt;= #{startDate}
AND DATE_FORMAT(CREATED_TIME, '%Y-%m-%d') &lt;= #{endDate}
) a
STRAIGHT_JOIN epdc_item_handle_process b ON b.ITEM_ID = a.ID AND b.DEL_FLAG = '0'
) a
WHERE a.ID = (
SELECT ID
FROM epdc_item_handle_process
WHERE a.ITEM_ID = ITEM_ID
ORDER BY CREATED_TIME
LIMIT 1, 1
)) b ON a.ID = b.ITEM_ID
WHERE DEL_FLAG = '0'
AND DATE_FORMAT(a.CREATED_TIME, '%Y-%m-%d') &gt;= #{startDate}
AND DATE_FORMAT(a.CREATED_TIME, '%Y-%m-%d') &lt;= #{endDate}
AND PEOPLE_FLAG is not null
GROUP BY ALL_DEPT_IDS
) b ON b.ALL_DEPT_IDS LIKE CONCAT('%', a.id, '%')
WHERE a.del_flag = '0'
<if test='type == "2"'>
AND a.type_key = 'street_dept'
</if>
<if test='type != "2"'>
AND a.type_key != 'street_dept'
</if>
AND a.PID = #{deptId}
GROUP BY a.id
ORDER BY a.sort,
CONVERT(a.`name` USING gbk) ASC
</select>
</mapper>

1
esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/screen/ScreenDeptEventStatDao.xml

@ -68,6 +68,7 @@
SUM(LAW_INCR) LAW_COUNT
FROM screen_dept_event_stat
WHERE PID = #{deptId}
AND DEPT_LEVEL != 'street_dept'
<if test="'2' == statType">
AND STAT_MONTH = #{statDate}
</if>

Loading…
Cancel
Save