Browse Source

新增:事件处理分析-处理状态比例查询完成

dev
wangxianzhang 3 years ago
parent
commit
68a27f1c68
  1. 50
      epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/form/EventProcessAnalysisCommonFormDTO.java
  2. 4
      epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/result/IcEventListResultDTO.java
  3. 11
      epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/result/ProcessStatusRatioResultDTO.java
  4. 22
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/controller/IcEventController.java
  5. 21
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/dao/IcEventDao.java
  6. 4
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/IcEventService.java
  7. 91
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/IcEventServiceImpl.java
  8. 10
      epmet-module/gov-project/gov-project-server/src/main/resources/mapper/IcEventDao.xml

50
epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/form/EventProcessAnalysisCommonFormDTO.java

@ -0,0 +1,50 @@
package com.epmet.dto.form;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;
/**
* 事件处理分析通用
*/
@Data
public class EventProcessAnalysisCommonFormDTO {
/**
* 处理状态比例查询
*/
public interface ProcessStatusRatioQuery {}
/**
* 要查询的组织ID
*/
@NotBlank(message = "组织ID为必填项", groups = { ProcessStatusRatioQuery.class })
private String orgId;
/**
* 组织类型grid,agency
*/
@NotBlank(message = "组织类型为必填项", groups = { ProcessStatusRatioQuery.class })
private String orgType;
/**
* 查询起始时间 yyyy-MM-dd
*/
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd")
@NotNull(message = "查询时间为必填项", groups = { ProcessStatusRatioQuery.class })
private Date queryStartTime;
/**
* 查询截止时间 yyyy-MM-dd
*/
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd")
@NotNull(message = "查询时间为必填项", groups = { ProcessStatusRatioQuery.class })
private Date queryEndTime;
}

4
epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/result/IcEventListResultDTO.java

@ -1,3 +1,7 @@
package com.epmet.dto.result;
import java.io.Serializable;
public class IcEventListResultDTO implements Serializable {
}

11
epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/result/ProcessStatusRatioResultDTO.java

@ -0,0 +1,11 @@
package com.epmet.dto.result;
import lombok.Data;
@Data
public class ProcessStatusRatioResultDTO {
private Long processingCount;
private Long closedCount;
private Double processingRatio;
private Double closedRatio;
}

22
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/controller/IcEventController.java

@ -11,12 +11,16 @@ import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.DefaultGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.dto.IcEventDTO;
import com.epmet.dto.form.EventProcessAnalysisCommonFormDTO;
import com.epmet.dto.form.IcEventListFormDTO;
import com.epmet.dto.result.IcEventListResultDTO;
import com.epmet.dto.result.ProcessStatusRatioResultDTO;
import com.epmet.service.IcEventService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
/**
* 事件管理表
@ -70,6 +74,24 @@ public class IcEventController {
return new Result();
}
/**
* 处理状态比例查询
* @param formDTO
* @return
*/
@PostMapping("processAnalysis/processStatusRatio")
public Result<ProcessStatusRatioResultDTO> getProcessStatusRatio(@RequestBody EventProcessAnalysisCommonFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, EventProcessAnalysisCommonFormDTO.ProcessStatusRatioQuery.class);
String orgId = formDTO.getOrgId();
String orgType = formDTO.getOrgType();
Date queryStartTime = formDTO.getQueryStartTime();
Date queryEndTime = formDTO.getQueryEndTime();
ProcessStatusRatioResultDTO r = icEventService.getProcessStatusRatio(orgId, orgType, queryStartTime, queryEndTime);
return new Result<ProcessStatusRatioResultDTO>().ok(r);
}

21
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/dao/IcEventDao.java

@ -1,8 +1,15 @@
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.result.ProcessStatusRatioResultDTO;
import com.epmet.entity.IcEventEntity;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* 事件管理表
@ -12,5 +19,17 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public interface IcEventDao extends BaseDao<IcEventEntity> {
/**
* 查询事件处理状态比例
* @param gridPids
* @param queryStartTime
* @param queryEndTime
* @return List[Map<状态key:事件数量>]
*/
@MapKey("status")
List<Map<String, Long>> getProcessStatusRatio(@Param("customerId") String customerId,
@Param("gridPids") String gridPids,
@Param("queryStartTime") Date queryStartTime,
@Param("queryEndTime") Date queryEndTime);
}

4
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/IcEventService.java

@ -5,8 +5,10 @@ import com.epmet.commons.tools.page.PageData;
import com.epmet.dto.IcEventDTO;
import com.epmet.dto.form.IcEventListFormDTO;
import com.epmet.dto.result.IcEventListResultDTO;
import com.epmet.dto.result.ProcessStatusRatioResultDTO;
import com.epmet.entity.IcEventEntity;
import java.util.Date;
import java.util.Map;
/**
@ -66,4 +68,6 @@ public interface IcEventService extends BaseService<IcEventEntity> {
* @date 2022-05-17
*/
void delete(String[] ids);
ProcessStatusRatioResultDTO getProcessStatusRatio(String orgId, String orgType, Date queryStartTime, Date queryEndTime);
}

91
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/IcEventServiceImpl.java

@ -2,23 +2,40 @@ package com.epmet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.AppClientConstant;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.feign.ResultDataResolver;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.EpmetRequestHolder;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dao.IcEventDao;
import com.epmet.dto.CustomerAgencyDTO;
import com.epmet.dto.IcEventDTO;
import com.epmet.dto.form.AgencyInfoFormDTO;
import com.epmet.dto.form.IcEventListFormDTO;
import com.epmet.dto.result.AgencyInfoResultDTO;
import com.epmet.dto.result.GridInfoResultDTO;
import com.epmet.dto.result.IcEventListResultDTO;
import com.epmet.dto.result.ProcessStatusRatioResultDTO;
import com.epmet.entity.IcEventEntity;
import com.epmet.feign.GovOrgFeignClient;
import com.epmet.feign.GovOrgOpenFeignClient;
import com.epmet.service.IcEventService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
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 org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -29,8 +46,10 @@ import java.util.Map;
* @since v1.0.0 2022-05-17
*/
@Service
public class IcEventServiceImpl extends BaseServiceImpl<IcEventDao, IcEventEntity> implements IcEventService {
public class IcEventServiceImpl extends BaseServiceImpl<IcEventDao, IcEventEntity> implements IcEventService, ResultDataResolver {
@Autowired
private GovOrgOpenFeignClient govOrgOpenFeignClient;
@Override
public PageData<IcEventListResultDTO> list(IcEventListFormDTO formDTO) {
@ -77,4 +96,74 @@ public class IcEventServiceImpl extends BaseServiceImpl<IcEventDao, IcEventEntit
baseDao.deleteBatchIds(Arrays.asList(ids));
}
@Override
public ProcessStatusRatioResultDTO getProcessStatusRatio(String orgId, String orgType, Date queryStartTime, Date queryEndTime) {
String gridPids;
AgencyInfoFormDTO form = new AgencyInfoFormDTO();
form.setOrgId(orgId);
form.setOrgType(orgType);
if ("agency".equals(orgType)) {
String errorMsg = "查询组织信息失败";
CustomerAgencyDTO agencyInfo = getResultDataOrThrowsException(govOrgOpenFeignClient.getAgencyById(orgId),
ServiceConstant.GOV_ORG_SERVER,
EpmetErrorCode.SERVER_ERROR.getCode(),
errorMsg,
errorMsg);
if (agencyInfo == null) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "组织信息未找到", "网格信息未找到");
}
String purePids = agencyInfo.getPids();
if ("0".equals(purePids) || StringUtils.isBlank(purePids)) {
gridPids = agencyInfo.getId();
} else {
gridPids = purePids.concat(":").concat(agencyInfo.getId());
}
} else if ("grid".equals(orgType)) {
String errorMsg = "查询agency信息失败";
GridInfoResultDTO gridInfo = getResultDataOrThrowsException(govOrgOpenFeignClient.queryGridInfo(orgId),
ServiceConstant.GOV_ORG_SERVER,
EpmetErrorCode.SERVER_ERROR.getCode(),
errorMsg,
errorMsg);
if (gridInfo == null) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "网格信息未找到", "网格信息未找到");
}
gridPids = gridInfo.getPids();
} else {
String errorMsg= "组织类型参数错误";
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), errorMsg, errorMsg);
}
List<Map<String, Long>> m = baseDao.getProcessStatusRatio(EpmetRequestHolder.getHeader(AppClientConstant.CUSTOMER_ID), gridPids, queryStartTime, queryEndTime);
ProcessStatusRatioResultDTO r = new ProcessStatusRatioResultDTO();
BigDecimal processingCount = null;
BigDecimal closedCount = null;
BigDecimal processingRatio = null;
BigDecimal closedRatio = null;
for (Map<String, Long> entry : m) {
if ("processing".equals(entry.get("status"))) {
processingCount = new BigDecimal(entry.get("eventCount"));
} else if ("closed_case".equals(entry.get("status"))) {
closedCount = new BigDecimal(entry.get("eventCount"));
}
}
// 根据个数,计算比例
BigDecimal total = processingCount.add(closedCount);
processingRatio = processingCount.divide(total, 2, BigDecimal.ROUND_HALF_UP);
closedRatio = new BigDecimal(1).subtract(processingRatio);
r.setProcessingCount(processingCount.longValue());
r.setClosedCount(closedCount.longValue());
r.setProcessingRatio(processingRatio.doubleValue());
r.setClosedRatio(closedRatio.doubleValue());
return r;
}
}

10
epmet-module/gov-project/gov-project-server/src/main/resources/mapper/IcEventDao.xml

@ -39,6 +39,16 @@
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
<select id="getProcessStatusRatio" resultType="java.util.Map">
select STATUS status, count(1) eventCount
from ic_event e
where
e.GRID_PIDS like CONCAT(#{gridPids},'%')
and CUSTOMER_ID = #{customerId}
and CREATED_TIME >= #{queryStartTime}
and CREATED_TIME <![CDATA[<=]]> #{queryEndTime}
group by STATUS
</select>
</mapper>
Loading…
Cancel
Save