From 0abc2aaad24463e308fde2b95a555c474717bf84 Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Mon, 22 Jun 2020 23:42:47 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=84=E7=BB=87=E8=83=BD=E5=8A=9B-=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E7=9B=B8=E5=85=B3=EF=BC=9A=E4=B8=8B=E7=BA=A7=E6=9C=BA?= =?UTF-8?q?=E5=85=B3=E6=9F=B1=E7=8A=B6=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/constant/UserAnalysisConstant.java | 15 +++ .../main/java/com/epmet/dto/DimAgencyDTO.java | 106 ++++++++++++++++++ .../dto/form/user/UserSubAgencyFormDTO.java | 3 + .../dto/form/user/UserSubGridFormDTO.java | 3 + .../dto/result/user/UserSubAgencyResDTO.java | 45 ++++++++ .../result/user/UserSubAgencyResultDTO.java | 5 +- .../user/UserAnalysisController.java | 20 ++-- .../com/epmet/dao/user/UserAnalysisDao.java | 35 ++++++ .../service/user/UserAnalysisService.java | 8 +- .../user/impl/UserAnalysisServiceImpl.java | 103 +++++++++++++++-- .../resources/mapper/user/UserAnalysisDao.xml | 55 +++++++++ 11 files changed, 375 insertions(+), 23 deletions(-) create mode 100644 epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/DimAgencyDTO.java create mode 100644 epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/result/user/UserSubAgencyResDTO.java diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/constant/UserAnalysisConstant.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/constant/UserAnalysisConstant.java index 9041875b52..ffd096b2bd 100644 --- a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/constant/UserAnalysisConstant.java +++ b/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="党员"; } diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/DimAgencyDTO.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/DimAgencyDTO.java new file mode 100644 index 0000000000..03bf9ad3c2 --- /dev/null +++ b/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 + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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; + +} \ No newline at end of file diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/form/user/UserSubAgencyFormDTO.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/form/user/UserSubAgencyFormDTO.java index 5f7f22b089..43d089e01a 100644 --- a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/form/user/UserSubAgencyFormDTO.java +++ b/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; } diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/form/user/UserSubGridFormDTO.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/form/user/UserSubGridFormDTO.java index 81e54c8756..c9bc20b734 100644 --- a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/form/user/UserSubGridFormDTO.java +++ b/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; } diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/result/user/UserSubAgencyResDTO.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/result/user/UserSubAgencyResDTO.java new file mode 100644 index 0000000000..f01c273e2b --- /dev/null +++ b/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; +} diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/result/user/UserSubAgencyResultDTO.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/result/user/UserSubAgencyResultDTO.java index 38969b9199..365435088d 100644 --- a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/result/user/UserSubAgencyResultDTO.java +++ b/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; + } diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/controller/user/UserAnalysisController.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/controller/user/UserAnalysisController.java index 2855f60a7f..da00a281d0 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/controller/user/UserAnalysisController.java +++ b/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 subAgency(@RequestBody UserSubAgencyFormDTO formDTO) { + public Result> subAgency(@RequestBody UserSubAgencyFormDTO formDTO) { ValidatorUtils.validateEntity(formDTO); - UserSubAgencyResultDTO userSubAgencyResultDTO = userService.subAgency(formDTO); - return new Result().ok(userSubAgencyResultDTO); + List userSubAgencyResultDTO = userService.subAgency(formDTO); + return new Result>().ok(userSubAgencyResultDTO); } /** @@ -65,10 +67,10 @@ public class UserAnalysisController { * @Date 2020/6/22 13:33 **/ @PostMapping("subgrid") - public Result subGrid(@RequestBody UserSubGridFormDTO formDTO) { + public Result> subGrid(@RequestBody UserSubGridFormDTO formDTO) { ValidatorUtils.validateEntity(formDTO); - UserSubGridResultDTO userSubGridResultDTO = userService.subGrid(formDTO); - return new Result().ok(userSubGridResultDTO); + List userSubGridResultDTO = userService.subGrid(formDTO); + return new Result>().ok(userSubGridResultDTO); } /** @@ -79,10 +81,10 @@ public class UserAnalysisController { * @Date 2020/6/22 13:36 **/ @PostMapping("incrtrend") - public Result incrTrend(@RequestBody UserIncrTrendFormDTO formDTO) { + public Result> incrTrend(@RequestBody UserIncrTrendFormDTO formDTO) { ValidatorUtils.validateEntity(formDTO); - UserIncrTrendResultDTO userIncrTrendResultDTO = userService.incrTrend(formDTO); - return new Result().ok(userIncrTrendResultDTO); + List userIncrTrendResultDTO = userService.incrTrend(formDTO); + return new Result>().ok(userIncrTrendResultDTO); } } diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/dao/user/UserAnalysisDao.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/dao/user/UserAnalysisDao.java index 80ac956bf4..5e74b18b74 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/dao/user/UserAnalysisDao.java +++ b/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 + * @param myAgencyId + * @author yinzuomei + * @description 根据机关id,查询它下一级机关列表 + * @Date 2020/6/22 22:42 + **/ + List 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 + * @param dateId 20200618日期 + * @param agencyId 用户所属机关 + * @author yinzuomei + * @description 参与用户:子级机关用户分析,按日(date_id)查询 + * @Date 2020/6/22 21:51 + **/ + List selectParticipationSubAgencyRes(@Param("dateId") String dateId ,@Param("agencyId")String agencyId); + + /** + * @param dateId + * @param dateId 20200618日期 + * @param agencyId 用户所属机关id + * @return java.util.List + * @author yinzuomei + * @description 注册用户:子级机关用户分析,按日(date_id)查询 + * @Date 2020/6/22 22:38 + **/ + List selectRegSubAgencyRes(@Param("dateId") String dateId ,@Param("agencyId")String agencyId); } diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/service/user/UserAnalysisService.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/service/user/UserAnalysisService.java index 7f99be9033..cdb05ec73b 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/service/user/UserAnalysisService.java +++ b/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 subAgency(UserSubAgencyFormDTO formDTO); /** * @param formDTO @@ -42,7 +44,7 @@ public interface UserAnalysisService { * @description 直属网格柱状图查询 * @Date 2020/6/22 13:42 **/ - UserSubGridResultDTO subGrid(UserSubGridFormDTO formDTO); + List subGrid(UserSubGridFormDTO formDTO); /** * @param formDTO @@ -51,5 +53,5 @@ public interface UserAnalysisService { * @description 按日、按月查询注册用户数(参与用户数)增量折线图 * @Date 2020/6/22 13:42 **/ - UserIncrTrendResultDTO incrTrend(UserIncrTrendFormDTO formDTO); + List incrTrend(UserIncrTrendFormDTO formDTO); } diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/service/user/impl/UserAnalysisServiceImpl.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/service/user/impl/UserAnalysisServiceImpl.java index 4ce17aee57..9db779d348 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/service/user/impl/UserAnalysisServiceImpl.java +++ b/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 subAgency(UserSubAgencyFormDTO formDTO) { + //获取用户所属机关id + String myAgencyId = this.getMyAgency(); + //初始化横坐标(用户所机关的下级机关列表) + List returnList = this.initUserSubAgencyResultDTO(myAgencyId); + if(CollectionUtils.isEmpty(returnList)){ + return new ArrayList<>(); + } + //根据入参,查询注册用户或者参与用户的(机关、按日的查询结果) + List 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 newList = returnList.stream().sorted(Comparator.comparing(UserSubAgencyResultDTO::getTotal)) + .collect(Collectors.toList()); + return newList; + } + + private List initUserSubAgencyResultDTO(String myAgencyId) { + List list=new ArrayList<>(); + List 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 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 incrTrend(UserIncrTrendFormDTO formDTO) { return null; } } diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/user/UserAnalysisDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/user/UserAnalysisDao.xml index 982c0526a6..efd1888940 100644 --- a/epmet-module/data-report/data-report-server/src/main/resources/mapper/user/UserAnalysisDao.xml +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/user/UserAnalysisDao.xml @@ -2,6 +2,18 @@ + + + + + + + + \ No newline at end of file