Browse Source

数据-项目-机关日统计部分代码提交

master
sunyuchao 5 years ago
parent
commit
fa0525804a
  1. 34
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/constant/ProjectConstant.java
  2. 12
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/StatsProjectController.java
  3. 9
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/project/ProjectDao.java
  4. 43
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/project/ProjectProcessDao.java
  5. 90
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/project/ProjectProcessEntity.java
  6. 8
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/StatsProjectService.java
  7. 205
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsProjectServiceImpl.java
  8. 39
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/project/ProjectProcessService.java
  9. 8
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/project/ProjectService.java
  10. 46
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/project/impl/ProjectProcessServiceImpl.java
  11. 14
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/project/impl/ProjectServiceImpl.java
  12. 12
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/project/ProjectDao.xml
  13. 23
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/project/ProjectProcessDao.xml
  14. 2
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimAgencyDao.xml

34
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/constant/ProjectConstant.java

@ -0,0 +1,34 @@
package com.epmet.constant;
/**
* @author sun
* @dscription 数据-项目-常量
*/
public interface ProjectConstant {
/**
* 状态-待处理
*/
String PENDING = "pending";
/**
* 状态-结案
*/
String CLOSED = "closed";
/**
* 结案状态-已解决
*/
String RESOLVED = "resolved";
/**
* 结案状态-未解决
*/
String UNRESOLVED = "unresolved";
/**
* 项目处理进展-创建项目
*/
String CREATED = "created";
/**
* 项目处理进展-结案
*/
String CLOSE = "close";
}

12
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/StatsProjectController.java

@ -29,4 +29,16 @@ public class StatsProjectController {
return new Result();
}
/**
* @param customerId
* @return
* @Author sun
* @Description 数据-项目-网格日()统计
**/
@PostMapping("gridproject/{customerId}")
public Result statsGridProject(@PathVariable("customerId") String customerId) {
statsProjectService.statsGridProject(customerId);
return new Result();
}
}

9
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/project/ProjectDao.java

@ -20,6 +20,9 @@ package com.epmet.dao.project;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.entity.project.ProjectEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 项目表
@ -30,4 +33,10 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface ProjectDao extends BaseDao<ProjectEntity> {
/**
* @param customerId
* @Author sun
* @Description 根据客户Id查询客户项目业务表有效数据
**/
List<ProjectEntity> selectProjectList(@Param("customerId") String customerId);
}

43
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/project/ProjectProcessDao.java

@ -0,0 +1,43 @@
/**
* 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.epmet.dao.project;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.entity.project.ProjectProcessEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 项目处理进展表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-05-11
*/
@Mapper
public interface ProjectProcessDao extends BaseDao<ProjectProcessEntity> {
/**
* @param customerId
* @Author sun
* @Description 查询客户项目处理进展表中是创建项目和结案两种进展的有效数据(创建日期截取yyyy-mm-dd格式字段值)
**/
List<ProjectProcessEntity> selectProcessList(@Param("customerId") String customerId);
}

90
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/project/ProjectProcessEntity.java

@ -0,0 +1,90 @@
/**
* 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.epmet.entity.project;
import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* 项目处理进展表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-05-11
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("project_process")
public class ProjectProcessEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
/**
* 项目所属机关Id
*/
private String agencyId;
/**
* 项目ID
*/
private String projectId;
/**
* 部门名
*/
private String departmentName;
/**
* 负负责人ID
*/
private String staffId;
/**
* 处理结案close退回return部门流转transfer创建项目created
*/
private String operation;
/**
* 处理名
*/
private String operationName;
/**
* 公开答复
*/
private String publicReply;
/**
* 内部备注
*/
private String internalRemark;
/**
* 结束时间
*/
private Date endTime;
/**
* 耗费天数
*/
private String costWorkdays;
}

8
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/StatsProjectService.java

@ -14,4 +14,12 @@ public interface StatsProjectService {
* @Description 数据-项目-机关日()统计
**/
void statsAgencyProject(String customerId);
/**
* @param customerId
* @return
* @Author sun
* @Description 数据-项目-网格日()统计
**/
void statsGridProject(String customerId);
}

205
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsProjectServiceImpl.java

@ -1,13 +1,30 @@
package com.epmet.service.impl;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.constant.ProjectConstant;
import com.epmet.dto.stats.DimAgencyDTO;
import com.epmet.dto.stats.DimDateDTO;
import com.epmet.entity.project.ProjectEntity;
import com.epmet.entity.project.ProjectProcessEntity;
import com.epmet.entity.stats.DimDateEntity;
import com.epmet.entity.stats.FactAgencyProjectDailyEntity;
import com.epmet.service.StatsProjectService;
import com.epmet.service.project.ProjectProcessService;
import com.epmet.service.project.ProjectService;
import com.epmet.service.stats.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.text.DateFormat;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
/**
* 数据统计-项目独立于任何具体数据源外层的service
*
* @author sun
*/
@Service
@ -28,6 +45,8 @@ public class StatsProjectServiceImpl implements StatsProjectService {
@Autowired
private ProjectService projectService;
@Autowired
private ProjectProcessService projectProcessService;
@Autowired
private FactAgencyProjectDailyService factAgencyProjectDailyService;
@Autowired
private FactAgencyProjectMonthlyService factAgencyProjectMonthlyService;
@ -44,6 +63,192 @@ public class StatsProjectServiceImpl implements StatsProjectService {
**/
@Override
public void statsAgencyProject(String customerId) {
//1:执行机关日数据统计
agencyDateProjectStats(customerId);
//2:执行机关月数据统计
if (Calendar.getInstance().get(Calendar.DATE) == 1) {
agencyMonthProjectStats(customerId);
}
}
/**
* @param customerId
* @Author sun
* @Description 数据-项目-机关日统计
**/
private String agencyDateProjectStats(String customerId) {
Date date = yesterDay();
//1:查询各维度表Id,方便使用 //TODO
DimDateDTO dimDateDTO = new DimDateDTO();
dimDateDTO.setCreatedTime(date);
dimDateDTO = dimDateService.getDimDate(dimDateDTO).get(0);
//2:根据客户Id查询机关维度表数据
DimAgencyDTO dimAgencyDTO = new DimAgencyDTO();
dimAgencyDTO.setCustomerId(customerId);
List<DimAgencyDTO> dimAgencyList = dimAgencyService.getDimAgencyList(dimAgencyDTO);
if (null == dimAgencyList || dimAgencyList.size() < NumConstant.ONE) {
return null;
}
//3:根据客户Id查询项目业务表数据
List<ProjectEntity> projectList = projectService.getProjectList(customerId);
//4:查询项目处理进展表中是创建项目和结案两种进展的有效数据(创建日期截取yyyy-mm-dd格式字段值)
List<ProjectProcessEntity> processList = projectProcessService.getProcessList(customerId);
//5:遍历统计每个机关各项指标数
//批量机关日统计新增对象
List<FactAgencyProjectDailyEntity> dimDateEntityList = new ArrayList<>();
//计算百分比使用,保留小数点后两位
NumberFormat numberFormat = NumberFormat.getInstance();
numberFormat.setMaximumFractionDigits(2);
//遍历机关维度数据
for (DimAgencyDTO agency : dimAgencyList) {
//存放当前机关及所有下级机关Id
Map map = new HashMap<>();
map.put(agency.getId(), agency.getId());
String subPids = ((null == agency.getPids() || "".equals(agency.getPids())) ? agency.getId() : agency.getPids() + ":" + agency.getId());
dimAgencyList.forEach(sub -> {
if (sub.getPids().contains(subPids)) {
map.put(sub.getId(), sub.getId());
}
});
//机关下截止当前日期的项目总数、处理中总数、已结案总数、已结案已解决总数、已结案未解决总数
AtomicInteger projectTotal = new AtomicInteger(0);
AtomicInteger pendingTotal = new AtomicInteger(0);
AtomicInteger closedTotal = new AtomicInteger(0);
AtomicInteger resolvedTotal = new AtomicInteger(0);
AtomicInteger unResolvedTotal = new AtomicInteger(0);
//存放当前机关及下级已结案切已解决的项目信息
Map resolvedMap = new HashMap<>();
//存放当前机关及下级已结案切未解决的项目信息
Map unResolvedMap = new HashMap<>();
//遍历项目数据,统计不同数据值
projectList.forEach(project -> {
if (map.containsKey(project.getAgencyId())) {
projectTotal.addAndGet(1);
if (ProjectConstant.PENDING.equals(project.getStatus())) {
pendingTotal.addAndGet(1);
}
if (ProjectConstant.CLOSED.equals(project.getStatus())) {
closedTotal.addAndGet(1);
if (ProjectConstant.RESOLVED.equals(project.getClosedStatus())) {
resolvedTotal.addAndGet(1);
resolvedMap.put(project.getAgencyId(), project.getClosedStatus());
}
if (ProjectConstant.UNRESOLVED.equals(project.getClosedStatus())) {
unResolvedTotal.addAndGet(1);
unResolvedMap.put(project.getAgencyId(), project.getClosedStatus());
}
}
}
});
//日增量中项目总数、处理中总数、已结案总数、已结案已解决总数、已结案未解决总数
AtomicInteger pendingIncr = new AtomicInteger(0);
AtomicInteger closedIncr = new AtomicInteger(0);
AtomicInteger resolvedIncr = new AtomicInteger(0);
AtomicInteger unResolvedIncr = new AtomicInteger(0);
//遍历项目进展列表数据,统计日增量数据
processList.forEach(process -> {
if (date.equals(process.getCreatedTime())) {
if (ProjectConstant.CREATED.equals(process.getOperation())) {
pendingIncr.addAndGet(1);
}
if (ProjectConstant.CLOSE.equals(process.getOperation())) {
closedIncr.addAndGet(1);
}
if (resolvedMap.containsKey(process.getAgencyId())) {
resolvedIncr.addAndGet(1);
}
if (unResolvedMap.containsKey(process.getAgencyId())) {
unResolvedIncr.addAndGet(1);
}
}
});
//封装日数据对象
FactAgencyProjectDailyEntity agencyDailyEntity = new FactAgencyProjectDailyEntity();
agencyDailyEntity.setCustomerId(customerId);
agencyDailyEntity.setAgencyId(agency.getId());
agencyDailyEntity.setParentId(agency.getPid());
//TODO
agencyDailyEntity.setDateId("");
agencyDailyEntity.setWeekId("");
agencyDailyEntity.setMonthId("");
agencyDailyEntity.setYearId("");
agencyDailyEntity.setProjectTotal(projectTotal.intValue());
agencyDailyEntity.setPendingTotal(pendingTotal.intValue());
agencyDailyEntity.setClosedTotal(closedTotal.intValue());
agencyDailyEntity.setResolvedTotal(resolvedTotal.intValue());
agencyDailyEntity.setUnresolvedTotal(unResolvedTotal.intValue());
if (projectTotal.intValue() > NumConstant.ZERO) {
agencyDailyEntity.setPendingRatio(new BigDecimal(numberFormat.format((float) pendingTotal.intValue() / (float) projectTotal.intValue() * 100)));
agencyDailyEntity.setClosedRatio(new BigDecimal(numberFormat.format((float) closedTotal.intValue() / (float) projectTotal.intValue() * 100)));
}
if (closedTotal.intValue() > NumConstant.ZERO) {
agencyDailyEntity.setResolvedRatio(new BigDecimal(numberFormat.format((float) resolvedTotal.intValue() / (float) closedTotal.intValue() * 100)));
agencyDailyEntity.setUnresolvedRatio(new BigDecimal(numberFormat.format((float) unResolvedTotal.intValue() / (float) closedTotal.intValue() * 100)));
}
agencyDailyEntity.setProjectIncr(pendingIncr.intValue() + closedIncr.intValue());
agencyDailyEntity.setPendingIncr(pendingIncr.intValue());
agencyDailyEntity.setClosedIncr(closedIncr.intValue());
agencyDailyEntity.setResolvedIncr(resolvedIncr.intValue());
agencyDailyEntity.setUnresolvedIncr(unResolvedIncr.intValue());
dimDateEntityList.add(agencyDailyEntity);
}
//6:批量保存机关日统计数据
if (null != dimDateEntityList && dimDateEntityList.size() > NumConstant.ZERO) {
factAgencyProjectDailyService.insertBatch(dimDateEntityList);
}
return null;
}
/**
* @param customerId
* @Author sun
* @Description 数据-项目-机关月统计
**/
private void agencyMonthProjectStats(String customerId) {
}
/**
* @param customerId
* @return
* @Author sun
* @Description 数据-项目-网格日()统计
**/
@Override
public void statsGridProject(String customerId) {
//1:查询各维度表Id,方便使用
//2:根据客户Id查询网格维度表数据
//3:根据客户Id查询项目业务表数据
//4:查询项目处理进展表中是创建项目和结案两种进展的有效数据(创建日期截取yyyy-mm-dd格式字段值)
//5:根据客户Id查询议题表已转项目的议题数据(为了匹配项目所属的网格Id)
//6:遍历统计每个网格各项指标数据
//7:批量保存网格日统计数据
//8:判断当前日期是否为当月首日,执行网格月数据统计
}
/**
* @Author sun
* @Description 获取当前日期的前一天日期yyyy-mm-dd
**/
private Date yesterDay() {
Date date = new Date();
try {
DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, -24);
String str = sdf.format(calendar.getTime());
date = sdf.parse(str);
} catch (Exception e) {
e.printStackTrace();
}
return date;
}
}

39
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/project/ProjectProcessService.java

@ -0,0 +1,39 @@
/**
* 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.epmet.service.project;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.entity.project.ProjectProcessEntity;
import java.util.List;
/**
* 项目处理进展表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-05-11
*/
public interface ProjectProcessService extends BaseService<ProjectProcessEntity> {
/**
* @param customerId
* @Author sun
* @Description 查询客户项目处理进展表中是创建项目和结案两种进展的有效数据(创建日期截取yyyy-mm-dd格式字段值)
**/
List<ProjectProcessEntity> getProcessList(String customerId);
}

8
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/project/ProjectService.java

@ -20,6 +20,8 @@ package com.epmet.service.project;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.entity.project.ProjectEntity;
import java.util.List;
/**
* 项目表
*
@ -28,4 +30,10 @@ import com.epmet.entity.project.ProjectEntity;
*/
public interface ProjectService extends BaseService<ProjectEntity> {
/**
* @param customerId
* @Author sun
* @Description 根据客户Id查询客户项目业务表有效数据
**/
List<ProjectEntity> getProjectList(String customerId);
}

46
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/project/impl/ProjectProcessServiceImpl.java

@ -0,0 +1,46 @@
/**
* 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.epmet.service.project.impl;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.dao.project.ProjectProcessDao;
import com.epmet.entity.project.ProjectProcessEntity;
import com.epmet.service.project.ProjectProcessService;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 项目处理进展表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-05-11
*/
@Service
public class ProjectProcessServiceImpl extends BaseServiceImpl<ProjectProcessDao, ProjectProcessEntity> implements ProjectProcessService {
/**
* @param customerId
* @Author sun
* @Description 查询客户项目处理进展表中是创建项目和结案两种进展的有效数据(创建日期截取yyyy-mm-dd格式字段值)
**/
@Override
public List<ProjectProcessEntity> getProcessList(String customerId) {
return baseDao.selectProcessList(customerId);
}
}

14
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/project/impl/ProjectServiceImpl.java

@ -26,6 +26,8 @@ import com.epmet.service.project.ProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 项目表
*
@ -35,7 +37,15 @@ import org.springframework.stereotype.Service;
@Service
@DataSource(DataSourceConstant.GOV_PROJECT)
public class ProjectServiceImpl extends BaseServiceImpl<ProjectDao, ProjectEntity> implements ProjectService {
@Autowired
private ProjectDao projectDao;
/**
* @param customerId
* @Author sun
* @Description 根据客户Id查询客户项目业务表有效数据
**/
@Override
public List<ProjectEntity> getProjectList(String customerId) {
return baseDao.selectProjectList(customerId);
}
}

12
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/project/ProjectDao.xml

@ -3,5 +3,17 @@
<mapper namespace="com.epmet.dao.project.ProjectDao">
<select id="selectProjectList" resultType="com.epmet.entity.project.ProjectEntity">
SELECT
*
FROM
project
WHERE
del_flag = '0'
<if test="customerId != null and customerId.trim() != ''">
AND customer_id = #{customerId}
</if>
ORDER BY created_time DESC
</select>
</mapper>

23
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/project/ProjectProcessDao.xml

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dao.project.ProjectProcessDao">
<select id="selectProcessList" resultType="com.epmet.entity.project.ProjectProcessEntity">
SELECT
pro.project_id,
pro.operation,
DATE_FORMAT(pro.created_time, "%Y-%m-%d"),
p.agency_id
FROM
project_process pro
INNER JOIN project p ON pro.project_id = p.id
WHERE
pro.del_flag = '0'
AND p.del_flag = '0'
AND p.customer_id = #{customerId}
ORDER BY
pro.project_id
</select>
</mapper>

2
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimAgencyDao.xml

@ -12,7 +12,7 @@
WHERE
del_flag = '0'
<if test="customerId != null and customerId.trim() != ''">
AND customerId = #{customerId}
AND customer_id = #{customerId}
</if>
</select>

Loading…
Cancel
Save