Browse Source

组织能力-用户相关:下级机关柱状图

master
yinzuomei 5 years ago
parent
commit
0abc2aaad2
  1. 15
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/constant/UserAnalysisConstant.java
  2. 106
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/DimAgencyDTO.java
  3. 3
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/form/user/UserSubAgencyFormDTO.java
  4. 3
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/form/user/UserSubGridFormDTO.java
  5. 45
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/result/user/UserSubAgencyResDTO.java
  6. 5
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/result/user/UserSubAgencyResultDTO.java
  7. 20
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/controller/user/UserAnalysisController.java
  8. 35
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/dao/user/UserAnalysisDao.java
  9. 8
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/service/user/UserAnalysisService.java
  10. 103
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/service/user/impl/UserAnalysisServiceImpl.java
  11. 55
      epmet-module/data-report/data-report-server/src/main/resources/mapper/user/UserAnalysisDao.xml

15
epmet-module/data-report/data-report-client/src/main/java/com/epmet/constant/UserAnalysisConstant.java

@ -19,4 +19,19 @@ public interface UserAnalysisConstant {
String PARTI_FLAG="parti";
String QUERY_USER_AGENCY_FAILED="查询用户所属机关信息失败";
/**
* 普通居民(已注册)
*/
String REGISTERED_RESI= "居民";
/**
* 热心居民
*/
String WARMHEARTED="热心居民";
/**
* 党员
*/
String PARTYMEMBER="党员";
}

106
epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/DimAgencyDTO.java

@ -0,0 +1,106 @@
/**
* 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.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 机关维度
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-06-16
*/
@Data
public class DimAgencyDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 组织IDAGENCY_ID
*/
private String id;
/**
* 组织名称
*/
private String agencyName;
/**
* 客户ID
*/
private String customerId;
/**
* 上级组织机构ID根组织为0
*/
private String pid;
/**
* 所有上级组织机构ID(以英文:隔开)
*/
private String pids;
/**
* 所有上级名称,-连接
*/
private String allParentName;
/**
* 机关级别社区级community
街道:street,
区县级: district,
市级: city
省级:province
*/
private String level;
/**
* 删除标识0未删除1已删除
*/
private String delFlag;
/**
* 乐观锁
*/
private Integer revision;
/**
* 创建人
*/
private String createdBy;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新人
*/
private String updatedBy;
/**
* 更新时间
*/
private Date updatedTime;
}

3
epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/form/user/UserSubAgencyFormDTO.java

@ -19,4 +19,7 @@ public class UserSubAgencyFormDTO implements Serializable {
*/
@NotBlank(message = "regOrPartiFlag不能为空")
private String regOrPartiFlag;
@NotBlank(message = "查询日期不能为空")
private String dateId;
}

3
epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/form/user/UserSubGridFormDTO.java

@ -19,4 +19,7 @@ public class UserSubGridFormDTO implements Serializable {
*/
@NotBlank(message = "regOrPartiFlag不能为空")
private String regOrPartiFlag;
@NotBlank(message = "查询日期不能为空")
private String dateId;
}

45
epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/result/user/UserSubAgencyResDTO.java

@ -0,0 +1,45 @@
package com.epmet.dto.result.user;
import lombok.Data;
import java.io.Serializable;
/**
* 描述一下
*
* @author yinzuomei@elink-cn.com
* @date 2020/6/22 21:45
*/
@Data
public class UserSubAgencyResDTO implements Serializable {
private static final long serialVersionUID = 5807572279154511198L;
/**
* 机关id
*/
private String agencyId;
/**
* 机关名称
*/
private String agencyName;
/**
* 截止到本日参与用户总数
*/
private Integer regTotal;
/**
* 截止到本日参与用户中居民总数
*/
private Integer resiTotal;
/**
* 截止到本日参与用户中热心居民总数
*/
private Integer warmHeartedTotal;
/**
* 截止到本日参与用户中党员总数
*/
private Integer partymemberTotal;
}

5
epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/result/user/UserSubAgencyResultDTO.java

@ -29,6 +29,9 @@ public class UserSubAgencyResultDTO implements Serializable {
*/
private String type;
@JsonIgnore
private String agencyId;
@JsonIgnore
private Integer total;
}

20
epmet-module/data-report/data-report-server/src/main/java/com/epmet/controller/user/UserAnalysisController.java

@ -17,6 +17,8 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 组织能力用户相关接口入口
*
@ -51,10 +53,10 @@ public class UserAnalysisController {
* @Date 2020/6/22 13:30
**/
@PostMapping("subagency")
public Result<UserSubAgencyResultDTO> subAgency(@RequestBody UserSubAgencyFormDTO formDTO) {
public Result<List<UserSubAgencyResultDTO>> subAgency(@RequestBody UserSubAgencyFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO);
UserSubAgencyResultDTO userSubAgencyResultDTO = userService.subAgency(formDTO);
return new Result<UserSubAgencyResultDTO>().ok(userSubAgencyResultDTO);
List<UserSubAgencyResultDTO> userSubAgencyResultDTO = userService.subAgency(formDTO);
return new Result<List<UserSubAgencyResultDTO>>().ok(userSubAgencyResultDTO);
}
/**
@ -65,10 +67,10 @@ public class UserAnalysisController {
* @Date 2020/6/22 13:33
**/
@PostMapping("subgrid")
public Result<UserSubGridResultDTO> subGrid(@RequestBody UserSubGridFormDTO formDTO) {
public Result<List<UserSubGridResultDTO>> subGrid(@RequestBody UserSubGridFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO);
UserSubGridResultDTO userSubGridResultDTO = userService.subGrid(formDTO);
return new Result<UserSubGridResultDTO>().ok(userSubGridResultDTO);
List<UserSubGridResultDTO> userSubGridResultDTO = userService.subGrid(formDTO);
return new Result<List<UserSubGridResultDTO>>().ok(userSubGridResultDTO);
}
/**
@ -79,10 +81,10 @@ public class UserAnalysisController {
* @Date 2020/6/22 13:36
**/
@PostMapping("incrtrend")
public Result<UserIncrTrendResultDTO> incrTrend(@RequestBody UserIncrTrendFormDTO formDTO) {
public Result<List<UserIncrTrendResultDTO>> incrTrend(@RequestBody UserIncrTrendFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO);
UserIncrTrendResultDTO userIncrTrendResultDTO = userService.incrTrend(formDTO);
return new Result<UserIncrTrendResultDTO>().ok(userIncrTrendResultDTO);
List<UserIncrTrendResultDTO> userIncrTrendResultDTO = userService.incrTrend(formDTO);
return new Result<List<UserIncrTrendResultDTO>>().ok(userIncrTrendResultDTO);
}
}

35
epmet-module/data-report/data-report-server/src/main/java/com/epmet/dao/user/UserAnalysisDao.java

@ -1,8 +1,13 @@
package com.epmet.dao.user;
import com.epmet.dto.DimAgencyDTO;
import com.epmet.dto.result.user.UserSubAgencyResDTO;
import com.epmet.dto.result.user.UserSummaryInfoResultDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 描述一下
@ -12,6 +17,15 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public interface UserAnalysisDao {
/**
* @return java.util.List<com.epmet.dto.DimAgencyDTO>
* @param myAgencyId
* @author yinzuomei
* @description 根据机关id,查询它下一级机关列表
* @Date 2020/6/22 22:42
**/
List<DimAgencyDTO> selectSubAgencyList(String myAgencyId);
/**
* @param myAgencyId
* @return com.epmet.user.result.UserSummaryInfoResultDTO
@ -29,4 +43,25 @@ public interface UserAnalysisDao {
* @Date 2020/6/22 16:52
**/
UserSummaryInfoResultDTO selectParticipationUserSummaryInfo(String myAgencyId);
/**
* @return java.util.List<com.epmet.dto.result.user.UserSubAgencyResDTO>
* @param dateId 20200618日期
* @param agencyId 用户所属机关
* @author yinzuomei
* @description 参与用户子级机关用户分析按日date_id查询
* @Date 2020/6/22 21:51
**/
List<UserSubAgencyResDTO> selectParticipationSubAgencyRes(@Param("dateId") String dateId ,@Param("agencyId")String agencyId);
/**
* @param dateId
* @param dateId 20200618日期
* @param agencyId 用户所属机关id
* @return java.util.List<com.epmet.dto.result.user.UserSubAgencyResDTO>
* @author yinzuomei
* @description 注册用户子级机关用户分析按日date_id查询
* @Date 2020/6/22 22:38
**/
List<UserSubAgencyResDTO> selectRegSubAgencyRes(@Param("dateId") String dateId ,@Param("agencyId")String agencyId);
}

8
epmet-module/data-report/data-report-server/src/main/java/com/epmet/service/user/UserAnalysisService.java

@ -10,6 +10,8 @@ import com.epmet.dto.result.user.UserSubAgencyResultDTO;
import com.epmet.dto.result.user.UserSubGridResultDTO;
import com.epmet.dto.result.user.UserSummaryInfoResultDTO;
import java.util.List;
/**
* 组织能力用户相关接口
*
@ -33,7 +35,7 @@ public interface UserAnalysisService {
* @description 直属机关柱状图查询
* @Date 2020/6/22 13:42
**/
UserSubAgencyResultDTO subAgency(UserSubAgencyFormDTO formDTO);
List<UserSubAgencyResultDTO> subAgency(UserSubAgencyFormDTO formDTO);
/**
* @param formDTO
@ -42,7 +44,7 @@ public interface UserAnalysisService {
* @description 直属网格柱状图查询
* @Date 2020/6/22 13:42
**/
UserSubGridResultDTO subGrid(UserSubGridFormDTO formDTO);
List<UserSubGridResultDTO> subGrid(UserSubGridFormDTO formDTO);
/**
* @param formDTO
@ -51,5 +53,5 @@ public interface UserAnalysisService {
* @description 按日按月查询注册用户数参与用户数增量折线图
* @Date 2020/6/22 13:42
**/
UserIncrTrendResultDTO incrTrend(UserIncrTrendFormDTO formDTO);
List<UserIncrTrendResultDTO> incrTrend(UserIncrTrendFormDTO formDTO);
}

103
epmet-module/data-report/data-report-server/src/main/java/com/epmet/service/user/impl/UserAnalysisServiceImpl.java

@ -7,16 +7,14 @@ import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.UserAnalysisConstant;
import com.epmet.dao.user.UserAnalysisDao;
import com.epmet.dto.DimAgencyDTO;
import com.epmet.dto.form.LoginUserDetailsFormDTO;
import com.epmet.dto.form.user.UserIncrTrendFormDTO;
import com.epmet.dto.form.user.UserSubAgencyFormDTO;
import com.epmet.dto.form.user.UserSubGridFormDTO;
import com.epmet.dto.form.user.UserSummaryInfoFormDTO;
import com.epmet.dto.result.LoginUserDetailsResultDTO;
import com.epmet.dto.result.user.UserIncrTrendResultDTO;
import com.epmet.dto.result.user.UserSubAgencyResultDTO;
import com.epmet.dto.result.user.UserSubGridResultDTO;
import com.epmet.dto.result.user.UserSummaryInfoResultDTO;
import com.epmet.dto.result.user.*;
import com.epmet.feign.EpmetUserOpenFeignClient;
import com.epmet.service.user.UserAnalysisService;
import org.apache.commons.lang.StringUtils;
@ -24,6 +22,12 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
/**
* 组织能力用户相关接口
@ -76,9 +80,11 @@ public class UserAnalysisServiceImpl implements UserAnalysisService {
UserSummaryInfoResultDTO userSummaryInfoResultDTO=new UserSummaryInfoResultDTO();
String myAgencyId=this.getMyAgency();
if(UserAnalysisConstant.PARTI_FLAG.equals(formDTO.getRegOrPartiFlag())){
userSummaryInfoResultDTO=userAnalysisDao.selectRegUserSummaryInfo(myAgencyId);
}else{
//参与用户
userSummaryInfoResultDTO=userAnalysisDao.selectParticipationUserSummaryInfo(myAgencyId);
}else{
//注册用户
userSummaryInfoResultDTO=userAnalysisDao.selectRegUserSummaryInfo(myAgencyId);
}
if(null!=userSummaryInfoResultDTO){
userSummaryInfoResultDTO.setCurrentDate(DateUtils.getDatePointPattern(userSummaryInfoResultDTO.getCurrentDate()));
@ -98,8 +104,85 @@ public class UserAnalysisServiceImpl implements UserAnalysisService {
* @Date 2020/6/22 13:42
**/
@Override
public UserSubAgencyResultDTO subAgency(UserSubAgencyFormDTO formDTO) {
return null;
public List<UserSubAgencyResultDTO> subAgency(UserSubAgencyFormDTO formDTO) {
//获取用户所属机关id
String myAgencyId = this.getMyAgency();
//初始化横坐标(用户所机关的下级机关列表)
List<UserSubAgencyResultDTO> returnList = this.initUserSubAgencyResultDTO(myAgencyId);
if(CollectionUtils.isEmpty(returnList)){
return new ArrayList<>();
}
//根据入参,查询注册用户或者参与用户的(机关、按日的查询结果)
List<UserSubAgencyResDTO> userSubAgencyResDTOList=new ArrayList<>();
if (UserAnalysisConstant.PARTI_FLAG.equals(formDTO.getRegOrPartiFlag())) {
//参与用户
userSubAgencyResDTOList = userAnalysisDao.selectParticipationSubAgencyRes(formDTO.getDateId(),
myAgencyId);
} else {
//注册用户
userSubAgencyResDTOList = userAnalysisDao.selectRegSubAgencyRes(formDTO.getDateId(),
myAgencyId);
}
//根据维度表进行对比
for(UserSubAgencyResDTO userSubAgencyResDTO:userSubAgencyResDTOList){
for(UserSubAgencyResultDTO returnResultDTO:returnList){
if(returnResultDTO.getAgencyId().equals(userSubAgencyResDTO.getAgencyId())){
//居民、热心居民、党员总数,用于排序
returnResultDTO.setTotal(userSubAgencyResDTO.getPartymemberTotal()
+userSubAgencyResDTO.getWarmHeartedTotal()
+userSubAgencyResDTO.getResiTotal());
switch(returnResultDTO.getType()){
case UserAnalysisConstant.REGISTERED_RESI:
returnResultDTO.setValue(userSubAgencyResDTO.getResiTotal());
break;
case UserAnalysisConstant.WARMHEARTED:
returnResultDTO.setValue(userSubAgencyResDTO.getWarmHeartedTotal());
break;
case UserAnalysisConstant.PARTYMEMBER:
returnResultDTO.setValue(userSubAgencyResDTO.getPartymemberTotal());
break;
default:
break;
}
}
}
}
//返回集合按照total降序排序
List<UserSubAgencyResultDTO> newList = returnList.stream().sorted(Comparator.comparing(UserSubAgencyResultDTO::getTotal))
.collect(Collectors.toList());
return newList;
}
private List<UserSubAgencyResultDTO> initUserSubAgencyResultDTO(String myAgencyId) {
List<UserSubAgencyResultDTO> list=new ArrayList<>();
List<DimAgencyDTO> dimAgencyDTOS=userAnalysisDao.selectSubAgencyList(myAgencyId);
for(DimAgencyDTO agencyDTO:dimAgencyDTOS){
//居民
UserSubAgencyResultDTO resi=new UserSubAgencyResultDTO();
resi.setAgencyId(agencyDTO.getId());
resi.setName(agencyDTO.getAgencyName());
resi.setValue(0);
resi.setType(UserAnalysisConstant.REGISTERED_RESI);
resi.setTotal(0);
list.add(resi);
//热心居民
UserSubAgencyResultDTO warm=new UserSubAgencyResultDTO();
warm.setAgencyId(agencyDTO.getId());
warm.setName(agencyDTO.getAgencyName());
warm.setValue(0);
warm.setType(UserAnalysisConstant.WARMHEARTED);
warm.setTotal(0);
list.add(warm);
//党员
UserSubAgencyResultDTO party=new UserSubAgencyResultDTO();
party.setAgencyId(agencyDTO.getId());
party.setName(agencyDTO.getAgencyName());
party.setValue(0);
party.setType(UserAnalysisConstant.PARTYMEMBER);
party.setTotal(0);
list.add(party);
}
return list;
}
/**
@ -110,7 +193,7 @@ public class UserAnalysisServiceImpl implements UserAnalysisService {
* @Date 2020/6/22 13:42
**/
@Override
public UserSubGridResultDTO subGrid(UserSubGridFormDTO formDTO) {
public List<UserSubGridResultDTO> subGrid(UserSubGridFormDTO formDTO) {
return null;
}
@ -122,7 +205,7 @@ public class UserAnalysisServiceImpl implements UserAnalysisService {
* @Date 2020/6/22 13:42
**/
@Override
public UserIncrTrendResultDTO incrTrend(UserIncrTrendFormDTO formDTO) {
public List<UserIncrTrendResultDTO> incrTrend(UserIncrTrendFormDTO formDTO) {
return null;
}
}

55
epmet-module/data-report/data-report-server/src/main/resources/mapper/user/UserAnalysisDao.xml

@ -2,6 +2,18 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dao.user.UserAnalysisDao">
<!-- 根据机关id,查询它下一级机关列表 -->
<select id="selectSubAgencyList" resultType="com.epmet.dto.DimAgencyDTO" parameterType="java.lang.String">
SELECT
da.id,
da.AGENCY_NAME
FROM
dim_agency da
WHERE
da.DEL_FLAG = '0'
AND da.AGENCY_DIM_TYPE = 'all'
AND da.PID =#{myAgencyId}
</select>
<!-- 查询注册用户汇总信息 -->
<select id="selectRegUserSummaryInfo" parameterType="java.lang.String" resultType="com.epmet.dto.result.user.UserSummaryInfoResultDTO">
SELECT
@ -44,4 +56,47 @@
m.DATE_ID DESC
LIMIT 1
</select>
<!-- 参与用户:子级机关用户分析,按日(date_id)查询 -->
<select id="selectParticipationSubAgencyRes" parameterType="map"
resultType="com.epmet.dto.result.user.UserSubAgencyResDTO">
SELECT
m.AGENCY_ID,
da.AGENCY_NAME,
m.REG_TOTAL,
M.RESI_TOTAL,
M.WARM_HEARTED_TOTAL,
M.PARTYMEMBER_TOTAL
FROM
fact_participation_user_agency_daily m
LEFT JOIN dim_agency da
ON ( m.AGENCY_ID = da.ID
AND da.PID =#{agencyId}
AND da.DEL_FLAG = '0' )
WHERE
m.DEL_FLAG = '0'
and m.DATE_ID=#{dateId}
order by m.REG_TOTAL desc
</select>
<!-- 注册用户:子级机关用户分析,按日(date_id)查询 -->
<select id="selectRegSubAgencyRes" parameterType="map" resultType="com.epmet.dto.result.user.UserSubAgencyResDTO">
SELECT
m.AGENCY_ID,
da.AGENCY_NAME,
m.REG_TOTAL,
M.RESI_TOTAL,
M.WARM_HEARTED_TOTAL,
M.PARTYMEMBER_TOTAL
FROM
fact_reg_user_agency_daily m
LEFT JOIN dim_agency da
ON ( m.AGENCY_ID = da.ID
AND da.PID =#{agencyId}
AND da.DEL_FLAG = '0' )
WHERE
m.DEL_FLAG = '0'
and m.DATE_ID=#{dateId}
order by m.REG_TOTAL desc
</select>
</mapper>
Loading…
Cancel
Save