Browse Source

议题增量统计修改

master
zhaoqifeng 5 years ago
parent
commit
07a192de76
  1. 15
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/StatsIssueController.java
  2. 3
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/issue/StatsIssueDao.java
  3. 3
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/Issue/IssueService.java
  4. 4
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/Issue/impl/IssueServiceImpl.java
  5. 9
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/StatsIssueService.java
  6. 55
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsIssueServiceImpl.java
  7. 102
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/issue/StatsIssueDao.xml

15
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/StatsIssueController.java

@ -1,12 +1,17 @@
package com.epmet.controller;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.service.StatsIssueService;
import lombok.Data;
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 java.io.Serializable;
/**
* @author zhaoqifeng
* @dscription
@ -30,4 +35,14 @@ public class StatsIssueController {
statsIssueService.agencyGridIssueStats();
return new Result();
}
@Data
private static class StatsDate implements Serializable {
private static final long serialVersionUID = 149723067011918433L;
private String date;
}
@PostMapping("date")
public Result agencyGridIssueStatsOfDate(@RequestBody StatsDate statsDate) {
statsIssueService.agencyGridIssueStatsOfDate(DateUtils.parse(statsDate.getDate(), DateUtils.DATE_PATTERN));
return new Result();
}
}

3
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/issue/StatsIssueDao.java

@ -18,11 +18,12 @@ public interface StatsIssueDao extends BaseDao<IssueEntity> {
* 获取当前日期组织下议题统计结果
*
* @param customerId
* @param date
* @return java.util.List<com.epmet.dto.issue.IssueAgencyDTO>
* @author zhaoqifeng
* @date 2020/6/17 14:13
*/
List<IssueAgencyDTO> selectAgencyIssueTotal(@Param("customerId") String customerId);
List<IssueAgencyDTO> selectAgencyIssueTotal(@Param("customerId") String customerId, @Param("date") String date);
/**
* 获取当前日期组织下议题增量

3
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/Issue/IssueService.java

@ -18,9 +18,10 @@ public interface IssueService {
* @author zhaoqifeng
* @date 2020/6/17 16:04
* @param customerId
* @param date
* @return java.util.List<com.epmet.dto.issue.IssueAgencyDTO>
*/
List<IssueAgencyDTO> getAgencyIssueTotal(String customerId);
List<IssueAgencyDTO> getAgencyIssueTotal(String customerId, String date);
/**
* 获取当前日期组织下议题增量

4
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/Issue/impl/IssueServiceImpl.java

@ -26,8 +26,8 @@ public class IssueServiceImpl implements IssueService {
private StatsIssueDao statsIssueDao;
@Override
public List<IssueAgencyDTO> getAgencyIssueTotal(String customerId) {
List<IssueAgencyDTO> list = statsIssueDao.selectAgencyIssueTotal(customerId);
public List<IssueAgencyDTO> getAgencyIssueTotal(String customerId, String date) {
List<IssueAgencyDTO> list = statsIssueDao.selectAgencyIssueTotal(customerId, date);
list.forEach(dto -> {
String[] pIds = dto.getPIds().split(":");
dto.setPId(pIds[pIds.length - 2]);

9
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/StatsIssueService.java

@ -17,6 +17,15 @@ public interface StatsIssueService {
*/
void agencyGridIssueStats();
/**
* 指定日期议题统计
* @author zhaoqifeng
* @date 2020/6/28 11:01
* @param date
* @return void
*/
void agencyGridIssueStatsOfDate(Date date);
/**
* 机关下议题日统计
* @author zhaoqifeng

55
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsIssueServiceImpl.java

@ -20,6 +20,7 @@ import com.epmet.service.project.ProjectService;
import com.epmet.service.stats.*;
import com.epmet.util.DimIdGenerator;
import lombok.extern.slf4j.Slf4j;
import oracle.sql.DATE;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
@ -66,6 +67,28 @@ public class StatsIssueServiceImpl implements StatsIssueService {
//获取当前日期前一天
Date date = DateUtils.getBeforeDay(new Date());
customerIdList = dimCustomerService.selectCustomerIdPage(pageNo++, pageSize);
if (!CollectionUtils.isEmpty(customerIdList)) {
for (String customerId : customerIdList) {
//遍历统计每一个客户数据
try {
customerStats(customerId, date);
} catch(Exception e) {
log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "agencyGridIssueStats", customerId, DateUtils.format(date),
e.getMessage()));
}
}
}
} while (!CollectionUtils.isEmpty(customerIdList) && customerIdList.size() == pageSize);
}
@Override
public void agencyGridIssueStatsOfDate(Date date) {
int pageNo = 1;
int pageSize = 100;
List<String> customerIdList = null;
do {
//获取当前日期前一天
customerIdList = dimCustomerService.selectCustomerIdPage(pageNo++, pageSize);
if (!CollectionUtils.isEmpty(customerIdList)) {
for (String customerId : customerIdList) {
//遍历统计每一个客户数据
@ -109,7 +132,7 @@ public class StatsIssueServiceImpl implements StatsIssueService {
//获取当前客户下所有机关
List<DimAgencyDTO> agencyList = dimAgencyService.getDimAgencyList(dimAgencyDTO);
//获取机关下议题各种状态的数目统计
List<IssueAgencyDTO> issueAgencyTotalList = issueService.getAgencyIssueTotal(customerId);
List<IssueAgencyDTO> issueAgencyTotalList = issueService.getAgencyIssueTotal(customerId, dateString);
//获取机关下议题各种状态的数目增量
List<IssueAgencyDTO> issueAgencyIncList = issueService.getAgencyIssueInc(customerId, dateString);
//获取机关下已关闭议题统计
@ -129,10 +152,10 @@ public class StatsIssueServiceImpl implements StatsIssueService {
entity.setPid(agency.getPid());
String pIds;
if (null == agency.getPids() || agency.getPids().isEmpty()) {
pIds = agency.getPid().concat(":").concat(agency.getId());
if (NumConstant.ZERO_STR.equals(agency.getPid())) {
pIds = agency.getPid();
} else {
pIds = ("0").concat(":").concat(agency.getPids()).concat(":").concat(agency.getId());
pIds = agency.getPids().concat(":").concat(agency.getId());
}
//总量统计
saveTotal(issueAgencyTotalList, agency, entity, pIds);
@ -172,7 +195,7 @@ public class StatsIssueServiceImpl implements StatsIssueService {
//获取当前客户下所有机关
List<DimAgencyDTO> agencyList = dimAgencyService.getDimAgencyList(dimAgencyDTO);
//获取机关下议题各种状态的数目统计
List<IssueAgencyDTO> issueAgencyTotalList = issueService.getAgencyIssueTotal(customerId);
List<IssueAgencyDTO> issueAgencyTotalList = issueService.getAgencyIssueTotal(customerId, dateString);
//获取机关下已关闭议题统计
List<IssueAgencyDTO> issueAgencyClosedTotalList = issueService.getAgencyClosedIssueTotal(customerId, dateString);
//已结案项目统计
@ -185,10 +208,10 @@ public class StatsIssueServiceImpl implements StatsIssueService {
FactIssueAgencyMonthlyEntity monthly = initIssueAgencyMonthly(dimId);
String pIds;
if (null == agency.getPids() || agency.getPids().isEmpty()) {
pIds = agency.getPid().concat(":").concat(agency.getId());
if (NumConstant.ZERO_STR.equals(agency.getPid())) {
pIds = agency.getPid();
} else {
pIds = ("0").concat(":").concat(agency.getPids()).concat(":").concat(agency.getId());
pIds = agency.getPids().concat(":").concat(agency.getId());
}
//总量统计
saveTotal(issueAgencyTotalList, agency, daily, pIds);
@ -550,6 +573,8 @@ public class StatsIssueServiceImpl implements StatsIssueService {
int shiftInc = NumConstant.ZERO;
//已关闭增量
int closedInc = NumConstant.ZERO;
//议题增量
int issueInc = NumConstant.ZERO;
for (IssueGridDTO dto : list) {
if (grid.getId().equals(dto.getGridId())) {
if (IssueConstant.VOTING.equals(dto.getStatus())) {
@ -558,13 +583,15 @@ public class StatsIssueServiceImpl implements StatsIssueService {
} else if (IssueConstant.SHIFT_PROJECT.equals(dto.getStatus())) {
//已转项目议题数量
shiftInc = dto.getCount();
} else {
} else if(IssueConstant.CLOSED.equals(dto.getStatus())) {
//已关闭议题数量
closedInc = dto.getCount();
} else {
issueInc = dto.getCount();
}
}
}
int issueInc = votingInc + shiftInc + closedInc;
entity.setVotingIncr(votingInc);
entity.setShiftProjectIncr(shiftInc);
entity.setClosedIncr(closedInc);
@ -712,6 +739,8 @@ public class StatsIssueServiceImpl implements StatsIssueService {
int shiftInc = NumConstant.ZERO;
//已关闭增量
int closedInc = NumConstant.ZERO;
//议题增量
int issueInc = NumConstant.ZERO;
for (IssueAgencyDTO issueAgency : list) {
if (agency.getId().equals(issueAgency.getAgencyId()) || issueAgency.getPIds().contains(pIds)) {
if (IssueConstant.VOTING.equals(issueAgency.getStatus())) {
@ -720,13 +749,15 @@ public class StatsIssueServiceImpl implements StatsIssueService {
} else if (IssueConstant.SHIFT_PROJECT.equals(issueAgency.getStatus())) {
//已转项目议题数量
shiftInc = shiftInc + issueAgency.getCount();
} else {
} else if(IssueConstant.CLOSED.equals(issueAgency.getStatus())) {
//已关闭议题数量
closedInc = closedInc + issueAgency.getCount();
} else {
//议题增量
issueInc = issueInc + issueAgency.getCount();
}
}
}
int issueInc = votingInc + shiftInc + closedInc;
entity.setVotingIncr(votingInc);
entity.setShiftProjectIncr(shiftInc);
entity.setClosedIncr(closedInc);

102
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/issue/StatsIssueDao.xml

@ -12,26 +12,49 @@
WHERE
DEL_FLAG = '0'
AND CUSTOMER_ID = #{customerId}
AND DATE(UPDATED_TIME) <![CDATA[ <= ]]> #{date}
GROUP BY
ORG_ID, ISSUE_STATUS
</select>
<select id="selectAgencyIssueInc" resultType="com.epmet.dto.issue.IssueAgencyDTO">
SELECT
i.ORG_ID AS "agencyId",
i.ORG_ID_PATH AS "pIds",
ip.ISSUE_STATUS AS "status",
COUNT(ip.ID) AS "count"
*
FROM
issue i
INNER JOIN issue_process ip ON i.ID = ip.ISSUE_ID
AND ip.DEL_FLAG = '0'
WHERE
i.DEL_FLAG = '0'
AND i.CUSTOMER_ID = #{customerId}
AND DATE(ip.CREATED_TIME) = #{date}
GROUP BY
i.ORG_ID,
ip.ISSUE_STATUS
(
SELECT
i.ORG_ID AS "agencyId",
i.ORG_ID_PATH AS "pIds",
ip.ISSUE_STATUS AS "status",
COUNT( ip.ID ) AS "count"
FROM
issue i
INNER JOIN issue_process ip ON i.ID = ip.ISSUE_ID
AND ip.DEL_FLAG = '0'
WHERE
i.DEL_FLAG = '0'
AND i.CUSTOMER_ID = #{customerId}
AND DATE(ip.CREATED_TIME) = #{date}
GROUP BY
i.ORG_ID,
ip.ISSUE_STATUS
UNION
SELECT
i.ORG_ID AS "agencyId",
i.ORG_ID_PATH AS "pIds",
"all" AS "status",
COUNT( ip.ISSUE_ID ) AS "count"
FROM
issue i
INNER JOIN ( SELECT DISTINCT ISSUE_ID FROM issue_process WHERE DEL_FLAG = '0' AND DATE( CREATED_TIME ) = #{date} ) ip ON i.ID = ip.ISSUE_ID
WHERE
i.DEL_FLAG = '0'
AND i.CUSTOMER_ID = #{customerId}
GROUP BY
i.ORG_ID
) a
ORDER BY
agencyId
</select>
<select id="selectAgencyClosedIssueTotal" resultType="com.epmet.dto.issue.IssueAgencyDTO">
SELECT
@ -83,22 +106,43 @@
</select>
<select id="selectGridIssueInc" resultType="com.epmet.dto.issue.IssueGridDTO">
SELECT
i.ORG_ID AS "agencyId",
i.GRID_ID AS "gridId",
ip.ISSUE_STATUS AS "status",
COUNT(ip.ID) AS "count"
*
FROM
issue i
INNER JOIN issue_process ip ON i.ID = ip.ISSUE_ID
AND ip.DEL_FLAG = '0'
WHERE
i.DEL_FLAG = '0'
AND i.CUSTOMER_ID = #{customerId}
AND DATE(ip.CREATED_TIME) = #{date}
GROUP BY
i.ORG_ID,
i.GRID_ID,
ip.ISSUE_STATUS
(
SELECT
i.ORG_ID AS "agencyId",
i.GRID_ID AS "gridId",
ip.ISSUE_STATUS AS "status",
COUNT( ip.ID ) AS "count"
FROM
issue i
INNER JOIN issue_process ip ON i.ID = ip.ISSUE_ID
AND ip.DEL_FLAG = '0'
WHERE
i.DEL_FLAG = '0'
AND i.CUSTOMER_ID = #{customerId}
AND DATE(ip.CREATED_TIME) = #{date}
GROUP BY
i.ORG_ID,
i.GRID_ID,
ip.ISSUE_STATUS UNION
SELECT
i.ORG_ID AS "agencyId",
i.GRID_ID AS "gridId",
"all" AS "status",
COUNT( ip.ISSUE_ID ) AS "count"
FROM
issue i
INNER JOIN ( SELECT DISTINCT ISSUE_ID FROM issue_process WHERE DEL_FLAG = '0' AND DATE( CREATED_TIME ) = #{date} ) ip ON i.ID = ip.ISSUE_ID
WHERE
i.DEL_FLAG = '0'
AND i.CUSTOMER_ID = #{customerId}
GROUP BY
i.ORG_ID,
i.GRID_ID
) a
ORDER BY
agencyId
</select>
<select id="selectGridClosedIssueTotal" resultType="com.epmet.dto.issue.IssueGridDTO">
SELECT

Loading…
Cancel
Save