|
|
@ -18,19 +18,29 @@ |
|
|
|
package com.epmet.service.evaluationindex.extract.todata.impl; |
|
|
|
|
|
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.constant.DimObjectStatusConstant; |
|
|
|
import com.epmet.constant.ProjectConstant; |
|
|
|
import com.epmet.dao.evaluationindex.extract.FactGridGovernDailyDao; |
|
|
|
import com.epmet.dto.org.GridInfoDTO; |
|
|
|
import com.epmet.entity.evaluationindex.extract.FactGridGovernDailyEntity; |
|
|
|
import com.epmet.entity.evaluationindex.extract.GovernGridTotalCommonDTO; |
|
|
|
import com.epmet.service.evaluationindex.extract.todata.FactGridGovernDailyService; |
|
|
|
import com.epmet.service.group.GroupDataService; |
|
|
|
import com.epmet.service.org.CustomerAgencyService; |
|
|
|
import com.epmet.service.evaluationindex.extract.todata.FactOriginIssueMainDailyService; |
|
|
|
import com.epmet.service.evaluationindex.extract.todata.FactOriginTopicMainDailyService; |
|
|
|
import com.epmet.service.org.CustomerGridService; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
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 java.math.BigDecimal; |
|
|
|
import java.text.NumberFormat; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
/** |
|
|
|
* 网格的治理指数,按天统计 |
|
|
@ -42,9 +52,9 @@ import java.util.List; |
|
|
|
@Service |
|
|
|
public class FactGridGovernDailyServiceImpl extends BaseServiceImpl<FactGridGovernDailyDao, FactGridGovernDailyEntity> implements FactGridGovernDailyService { |
|
|
|
@Autowired |
|
|
|
private GroupDataService groupDataService; |
|
|
|
private FactOriginTopicMainDailyService factOriginTopicMainDailyService; |
|
|
|
@Autowired |
|
|
|
private CustomerAgencyService customerAgencyService; |
|
|
|
private FactOriginIssueMainDailyService factOriginIssueMainDailyService; |
|
|
|
@Autowired |
|
|
|
private CustomerGridService customerGridService; |
|
|
|
|
|
|
@ -62,13 +72,242 @@ public class FactGridGovernDailyServiceImpl extends BaseServiceImpl<FactGridGove |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void extractFactGridGovernDaily(String customerId, String dateId) { |
|
|
|
log.info("extractFactGridGovernDaily start customerId="+customerId+";dateId="+dateId); |
|
|
|
//客户id, dateId不能为空
|
|
|
|
if(StringUtils.isBlank(customerId)||StringUtils.isBlank(dateId)){ |
|
|
|
return; |
|
|
|
} |
|
|
|
// 2、当前客户下所有的网格
|
|
|
|
List<GridInfoDTO> gridInfoDTOList=customerGridService.queryGridInfoList(customerId); |
|
|
|
//todo
|
|
|
|
// List<FactGridGovernDailyEntity>
|
|
|
|
if(CollectionUtils.isEmpty(gridInfoDTOList)){ |
|
|
|
log.info("当前客户customerId=("+customerId+")下没有网格,无需计算"); |
|
|
|
return; |
|
|
|
} |
|
|
|
List<FactGridGovernDailyEntity> insertEntityList=this.constructFactGridGovernDailyEntityList(customerId,dateId,gridInfoDTOList); |
|
|
|
// log.info(JSON.toJSONString(insertEntityList,true));
|
|
|
|
|
|
|
|
NumberFormat numberFormat = NumberFormat.getInstance(); |
|
|
|
numberFormat.setMaximumFractionDigits(NumConstant.SIX); |
|
|
|
|
|
|
|
Map<String, Integer> topicResolvedMap=getTopicMap(customerId, null,ProjectConstant.CLOSED, DimObjectStatusConstant.RESOLVED,NumConstant.ZERO_STR); |
|
|
|
Map<String, Integer> topicUnResolvedMap=getTopicMap(customerId, null,ProjectConstant.CLOSED, DimObjectStatusConstant.UNRESOLVED,NumConstant.ZERO_STR); |
|
|
|
|
|
|
|
Map<String, Integer> issueResolvedMap=getIssueMap(customerId, null,ProjectConstant.CLOSED, DimObjectStatusConstant.RESOLVED); |
|
|
|
Map<String, Integer> issueUnResolvedMap=getIssueMap(customerId, null,ProjectConstant.CLOSED, DimObjectStatusConstant.UNRESOLVED); |
|
|
|
|
|
|
|
for(FactGridGovernDailyEntity insertEntity:insertEntityList){ |
|
|
|
//1、当前网格内,话题关闭已解决数
|
|
|
|
if(topicResolvedMap.containsKey(insertEntity.getGridId())){ |
|
|
|
insertEntity.setTopicResolvedCount(topicResolvedMap.get(insertEntity.getGridId())); |
|
|
|
} |
|
|
|
//2、当前网格内,话题关闭无需解决数
|
|
|
|
if(topicUnResolvedMap.containsKey(insertEntity.getGridId())){ |
|
|
|
insertEntity.setTopicUnResolvedCount(topicUnResolvedMap.get(insertEntity.getGridId())); |
|
|
|
} |
|
|
|
//3、当前网格内,议题关闭已解决数
|
|
|
|
if(issueResolvedMap.containsKey(insertEntity.getGridId())){ |
|
|
|
insertEntity.setIssueResolvedCount(issueResolvedMap.get(insertEntity.getGridId())); |
|
|
|
} |
|
|
|
//4、当前网格内,议题关闭无需解决数
|
|
|
|
if(issueUnResolvedMap.containsKey(insertEntity.getGridId())){ |
|
|
|
insertEntity.setIssueUnResolvedCount(issueUnResolvedMap.get(insertEntity.getGridId())); |
|
|
|
} |
|
|
|
|
|
|
|
// todo
|
|
|
|
// 5、当前网格内:来源于议题的项目:结案已解决数
|
|
|
|
insertEntity.setIssueProjectResolvedCount(calIssueProjectResolvedCount(customerId,insertEntity.getGridId())); |
|
|
|
// 6、当前网格内:来源于议题的项目:结案无需解决数
|
|
|
|
insertEntity.setIssueProjectUnResolvedCount(calIssueProjectUnResolvedCount(customerId,insertEntity.getGridId())); |
|
|
|
//7、当前网格内:项目立项,结案已解决数;默认为0,
|
|
|
|
insertEntity.setApprovalProjectResolvedCount(calApprovalProjectResolvedCount(customerId,insertEntity.getGridId())); |
|
|
|
// 8、当前网格内:项目立项,结案无需解决数;默认为0,
|
|
|
|
insertEntity.setApprovalProjectUnResolvedCount(calApprovalProjectUnResolvedCount(customerId,insertEntity.getGridId())); |
|
|
|
|
|
|
|
|
|
|
|
// 9、当前网格内,未出小组即未转议题的:话题关闭已解决数
|
|
|
|
insertEntity.setInGroupTopicResolvedCount(calInGroupTopicResolvedCount(customerId,insertEntity.getGridId())); |
|
|
|
// 10、当前网格内,未出小组即未转议题的:话题关闭无需解决数
|
|
|
|
insertEntity.setInGroupTopicUnResolvedCount(calInGroupTopicUnResolvedCount(customerId,insertEntity.getGridId())); |
|
|
|
// 11、未出当前网格的,结案项目数
|
|
|
|
insertEntity.setGridSelfGovernProjectTotal(calGridSelfGovernProjectTotal(customerId,insertEntity.getGridId())); |
|
|
|
|
|
|
|
|
|
|
|
//界面展示:1、问题解决总数=1+2+3+4+5+6+7+8
|
|
|
|
insertEntity.setProblemResolvedCount(insertEntity.getTopicResolvedCount()+insertEntity.getTopicUnResolvedCount() |
|
|
|
+insertEntity.getIssueResolvedCount()+insertEntity.getIssueUnResolvedCount() |
|
|
|
+insertEntity.getIssueProjectResolvedCount()+insertEntity.getIssueProjectUnResolvedCount() |
|
|
|
+insertEntity.getApprovalProjectResolvedCount()+insertEntity.getApprovalProjectUnResolvedCount()); |
|
|
|
|
|
|
|
//界面展示:2、党群自治占比=(9+10)/PROBLEM_RESOLVED_COUNT; 此列存储的是小数
|
|
|
|
int groupSelfGovernRatioFz=insertEntity.getInGroupTopicResolvedCount()+insertEntity.getInGroupTopicUnResolvedCount(); |
|
|
|
if (NumConstant.ZERO == groupSelfGovernRatioFz || NumConstant.ZERO == insertEntity.getProblemResolvedCount()) { |
|
|
|
insertEntity.setGroupSelfGovernRatio(BigDecimal.ZERO); |
|
|
|
}else{ |
|
|
|
String groupSelfGovernRatioStr = numberFormat.format((float) groupSelfGovernRatioFz / insertEntity.getProblemResolvedCount()); |
|
|
|
insertEntity.setGroupSelfGovernRatio(new BigDecimal(groupSelfGovernRatioStr)); |
|
|
|
} |
|
|
|
|
|
|
|
//界面展示:3、网格自治占比=GRID_SELF_GOVERN_PROJECT_TOTAL/PROBLEM_RESOLVED_COUNT;此列存储的是小数
|
|
|
|
if(NumConstant.ZERO==insertEntity.getGridSelfGovernProjectTotal()||NumConstant.ZERO == insertEntity.getProblemResolvedCount()){ |
|
|
|
insertEntity.setGridSelfGovernRatio(BigDecimal.ZERO); |
|
|
|
}else{ |
|
|
|
String gridSelfGovernRatioStr = numberFormat.format((float) insertEntity.getGridSelfGovernProjectTotal() / insertEntity.getProblemResolvedCount()); |
|
|
|
insertEntity.setGridSelfGovernRatio(new BigDecimal(gridSelfGovernRatioStr)); |
|
|
|
} |
|
|
|
} |
|
|
|
// 先删除,后新增
|
|
|
|
// 3、批量删除
|
|
|
|
int deleteNum; |
|
|
|
do { |
|
|
|
deleteNum = baseDao.deleteBatchByCustomerIdAndDateId(customerId, dateId, NumConstant.TWO_HUNDRED); |
|
|
|
} while (deleteNum > NumConstant.ZERO); |
|
|
|
|
|
|
|
// 4、插入数据
|
|
|
|
this.insertBatch(insertEntityList); |
|
|
|
log.info("extractFactGridGovernDaily completed"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 构造要插入的数据,每个网格一天一条数据,初始赋值0 |
|
|
|
* |
|
|
|
* @param customerId |
|
|
|
* @param dateId |
|
|
|
* @param gridInfoDTOList |
|
|
|
* @return com.epmet.entity.evaluationindex.extract.FactGridGovernDailyEntity |
|
|
|
*/ |
|
|
|
private List<FactGridGovernDailyEntity> constructFactGridGovernDailyEntityList(String customerId, String dateId, List<GridInfoDTO> gridInfoDTOList) { |
|
|
|
List<FactGridGovernDailyEntity> insertEntityList = new ArrayList<>(); |
|
|
|
for (GridInfoDTO gridInfoDTO : gridInfoDTOList) { |
|
|
|
FactGridGovernDailyEntity entity = new FactGridGovernDailyEntity(); |
|
|
|
entity.setCustomerId(customerId); |
|
|
|
entity.setDateId(dateId); |
|
|
|
entity.setGridId(gridInfoDTO.getGridId()); |
|
|
|
entity.setPid(gridInfoDTO.getPid()); |
|
|
|
entity.setPids(gridInfoDTO.getPids()); |
|
|
|
insertEntityList.add(entity); |
|
|
|
} |
|
|
|
return insertEntityList; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 1、当前网格内,话题关闭已解决数 |
|
|
|
* 2、当前网格内,话题关闭无需解决数 |
|
|
|
* 这两个值可以通过此方法获得 |
|
|
|
* |
|
|
|
* @param customerId |
|
|
|
* @param gridIds |
|
|
|
* @param topicStatus 话题状态(讨论中 - discussing、 已屏蔽 - hidden、 已关闭 - closed) |
|
|
|
* @param closedStatus unresolved,resolved |
|
|
|
* @param shiftIssue 是否转为议题,0:false,1:true; |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private Map<String, Integer> getTopicMap(String customerId, List<String> gridIds, String topicStatus, String closedStatus,String shiftIssue) { |
|
|
|
Map<String, Integer> resultMap = new HashMap<>(); |
|
|
|
List<GovernGridTotalCommonDTO> list = factOriginTopicMainDailyService.queryGridTopicValue(customerId, gridIds, topicStatus, closedStatus,shiftIssue); |
|
|
|
for (GovernGridTotalCommonDTO gridTotalCommonDTO : list) { |
|
|
|
resultMap.put(gridTotalCommonDTO.getGridId(), gridTotalCommonDTO.getTotal()); |
|
|
|
} |
|
|
|
return resultMap; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 3、当前网格内,议题关闭已解决数 |
|
|
|
* 4、当前网格内,议题关闭无需解决数 |
|
|
|
* 这两个值可以通过此方法获得 |
|
|
|
* |
|
|
|
* @param customerId |
|
|
|
* @param gridIds |
|
|
|
* @param issueStatus 议题状态 voting 已转项目:shift_project 已关闭:closed_resloved |
|
|
|
* @param resolveType unresolved,resolved |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private Map<String, Integer> getIssueMap(String customerId, List<String> gridIds, String issueStatus, String resolveType) { |
|
|
|
Map<String, Integer> resultMap = new HashMap<>(); |
|
|
|
List<GovernGridTotalCommonDTO> list = factOriginIssueMainDailyService.queryGridIssueValue(customerId, gridIds, issueStatus, resolveType); |
|
|
|
for (GovernGridTotalCommonDTO gridTotalCommonDTO : list) { |
|
|
|
resultMap.put(gridTotalCommonDTO.getGridId(), gridTotalCommonDTO.getTotal()); |
|
|
|
} |
|
|
|
return resultMap; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 5、当前网格内:来源于议题的项目:结案已解决数 |
|
|
|
* |
|
|
|
* @param customerId |
|
|
|
* @param gridId |
|
|
|
*/ |
|
|
|
private Integer calIssueProjectResolvedCount(String customerId, String gridId) { |
|
|
|
// todo
|
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 6、当前网格内:来源于议题的项目:结案无需解决数 |
|
|
|
* |
|
|
|
* @param customerId |
|
|
|
* @param gridId |
|
|
|
*/ |
|
|
|
private Integer calIssueProjectUnResolvedCount(String customerId, String gridId) { |
|
|
|
// todo
|
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 7、当前网格内:项目立项,结案已解决数;默认为0, |
|
|
|
* |
|
|
|
* @param customerId |
|
|
|
* @param gridId |
|
|
|
*/ |
|
|
|
private Integer calApprovalProjectResolvedCount(String customerId, String gridId) { |
|
|
|
// todo
|
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 8、当前网格内:项目立项,结案无需解决数;默认为0, |
|
|
|
* |
|
|
|
* @param customerId |
|
|
|
* @param gridId |
|
|
|
*/ |
|
|
|
private Integer calApprovalProjectUnResolvedCount(String customerId, String gridId) { |
|
|
|
// todo
|
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 9、当前网格内,未出小组即未转议题的:话题关闭已解决数 |
|
|
|
* |
|
|
|
* @param customerId |
|
|
|
* @param gridId |
|
|
|
*/ |
|
|
|
private Integer calInGroupTopicResolvedCount(String customerId, String gridId) { |
|
|
|
// todo
|
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 10、当前网格内,未出小组即未转议题的:话题关闭无需解决数 |
|
|
|
* |
|
|
|
* @param customerId |
|
|
|
* @param gridId |
|
|
|
*/ |
|
|
|
private Integer calInGroupTopicUnResolvedCount(String customerId, String gridId) { |
|
|
|
// todo
|
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 11、未出当前网格的,结案项目数 |
|
|
|
* |
|
|
|
* @param customerId |
|
|
|
* @param gridId |
|
|
|
*/ |
|
|
|
private Integer calGridSelfGovernProjectTotal(String customerId, String gridId) { |
|
|
|
// todo
|
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
} |