|
|
|
@ -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; |
|
|
|
} |
|
|
|
|
|
|
|
} |