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 index 03bf9ad3c2..243404052e 100644 --- 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 @@ -20,7 +20,6 @@ package com.epmet.dto; import lombok.Data; import java.io.Serializable; -import java.util.Date; /** @@ -44,63 +43,4 @@ public class DimAgencyDTO implements Serializable { */ 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/DimGridDTO.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/DimGridDTO.java new file mode 100644 index 0000000000..8487d6d220 --- /dev/null +++ b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/DimGridDTO.java @@ -0,0 +1,45 @@ +/** + * 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; + + +/** + * 客户网格维度 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-06-16 + */ +@Data +public class DimGridDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * GRID_ID + */ + private String id; + + /** + * 网格名称 + */ + private String gridName; +} \ No newline at end of file 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 365435088d..107b189660 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; + /** + * 机关id + */ private String agencyId; @JsonIgnore diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/result/user/UserSubGridResDTO.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/result/user/UserSubGridResDTO.java new file mode 100644 index 0000000000..e20c123147 --- /dev/null +++ b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/result/user/UserSubGridResDTO.java @@ -0,0 +1,21 @@ +package com.epmet.dto.result.user; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 直属网格注册用户数(参与用户、注册用户通用类) + * + * @author yinzuomei@elink-cn.com + * @date 2020/6/22 23:57 + */ +@Data +public class UserSubGridResDTO implements Serializable { + private static final long serialVersionUID = 2203260762393704885L; + private String gridId; + 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/UserSubGridResultDTO.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/result/user/UserSubGridResultDTO.java index 493f6ebc98..5aa50aad9b 100644 --- a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/result/user/UserSubGridResultDTO.java +++ b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/result/user/UserSubGridResultDTO.java @@ -5,6 +5,7 @@ import lombok.Data; import java.io.Serializable; + /** * 直属网格注册用户数 返参DTO * @@ -30,6 +31,11 @@ public class UserSubGridResultDTO implements Serializable { */ private String type; - @JsonIgnore + /** + * 网格id + */ private String gridId; + + @JsonIgnore + private Integer total; } 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 5e74b18b74..2fd8c6b3c8 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 @@ -2,7 +2,9 @@ package com.epmet.dao.user; import com.epmet.dto.DimAgencyDTO; +import com.epmet.dto.DimGridDTO; import com.epmet.dto.result.user.UserSubAgencyResDTO; +import com.epmet.dto.result.user.UserSubGridResDTO; import com.epmet.dto.result.user.UserSummaryInfoResultDTO; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -26,6 +28,15 @@ public interface UserAnalysisDao { **/ List selectSubAgencyList(String myAgencyId); + /** + * @return java.util.List + * @param myAgencyId + * @author yinzuomei + * @description 根据机关id,查询它下面的直属网格列表 + * @Date 2020/6/22 23:51 + **/ + List selectSubGridList(String myAgencyId); + /** * @param myAgencyId * @return com.epmet.user.result.UserSummaryInfoResultDTO @@ -64,4 +75,24 @@ public interface UserAnalysisDao { * @Date 2020/6/22 22:38 **/ List selectRegSubAgencyRes(@Param("dateId") String dateId ,@Param("agencyId")String agencyId); + + /** + * @param dateId 20200618日期 + * @param agencyId 用户所属机关id + * @return java.util.List + * @author yinzuomei + * @description 参与用户:机关下,直属网格用户分析 + * @Date 2020/6/23 0:18 + **/ + List selectParticipationSubGridRes(@Param("dateId") String dateId, @Param("agencyId") String agencyId); + + /** + * @param dateId 20200618日期 + * @param agencyId 用户所属机关id + * @return java.util.List + * @author yinzuomei + * @description 注册用户:机关下,直属网格用户分析 + * @Date 2020/6/23 0:18 + **/ + List selectRegSubGridRes(@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/impl/UserAnalysisServiceImpl.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/service/user/impl/UserAnalysisServiceImpl.java index 9db779d348..dbc4d20f2e 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 @@ -1,6 +1,7 @@ package com.epmet.service.user.impl; import com.alibaba.fastjson.JSON; +import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.security.user.LoginUserUtil; import com.epmet.commons.tools.utils.DateUtils; @@ -8,6 +9,7 @@ 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.DimGridDTO; import com.epmet.dto.form.LoginUserDetailsFormDTO; import com.epmet.dto.form.user.UserIncrTrendFormDTO; import com.epmet.dto.form.user.UserSubAgencyFormDTO; @@ -108,8 +110,9 @@ public class UserAnalysisServiceImpl implements UserAnalysisService { //获取用户所属机关id String myAgencyId = this.getMyAgency(); //初始化横坐标(用户所机关的下级机关列表) - List returnList = this.initUserSubAgencyResultDTO(myAgencyId); - if(CollectionUtils.isEmpty(returnList)){ + List dimList = this.initUserSubAgencyResultDTO(myAgencyId); + if(CollectionUtils.isEmpty(dimList)){ + logger.info(String.format("当前机关(agencyId=%s)下没有下级机关",myAgencyId)); return new ArrayList<>(); } //根据入参,查询注册用户或者参与用户的(机关、按日的查询结果) @@ -124,33 +127,38 @@ public class UserAnalysisServiceImpl implements UserAnalysisService { myAgencyId); } //根据维度表进行对比 - for(UserSubAgencyResDTO userSubAgencyResDTO:userSubAgencyResDTOList){ - for(UserSubAgencyResultDTO returnResultDTO:returnList){ - if(returnResultDTO.getAgencyId().equals(userSubAgencyResDTO.getAgencyId())){ + for(UserSubAgencyResultDTO dimInitResultDto:dimList){ + boolean flag=false; + for(UserSubAgencyResDTO userSubAgencyResDTO:userSubAgencyResDTOList){ + if(dimInitResultDto.getAgencyId().equals(userSubAgencyResDTO.getAgencyId())){ + flag=true; //居民、热心居民、党员总数,用于排序 - returnResultDTO.setTotal(userSubAgencyResDTO.getPartymemberTotal() + dimInitResultDto.setTotal(userSubAgencyResDTO.getPartymemberTotal() +userSubAgencyResDTO.getWarmHeartedTotal() +userSubAgencyResDTO.getResiTotal()); - switch(returnResultDTO.getType()){ + switch(dimInitResultDto.getType()){ case UserAnalysisConstant.REGISTERED_RESI: - returnResultDTO.setValue(userSubAgencyResDTO.getResiTotal()); + dimInitResultDto.setValue(userSubAgencyResDTO.getResiTotal()); break; case UserAnalysisConstant.WARMHEARTED: - returnResultDTO.setValue(userSubAgencyResDTO.getWarmHeartedTotal()); + dimInitResultDto.setValue(userSubAgencyResDTO.getWarmHeartedTotal()); break; case UserAnalysisConstant.PARTYMEMBER: - returnResultDTO.setValue(userSubAgencyResDTO.getPartymemberTotal()); + dimInitResultDto.setValue(userSubAgencyResDTO.getPartymemberTotal()); break; default: break; } } } + if(!flag){ + logger.error(String.format("各机关注册用户数缺少记录:date_id=%s,agencyId=%s",formDTO.getDateId(),dimInitResultDto.getAgencyId())); + } } //返回集合按照total降序排序 - List newList = returnList.stream().sorted(Comparator.comparing(UserSubAgencyResultDTO::getTotal)) + List returnList = dimList.stream().sorted(Comparator.comparing(UserSubAgencyResultDTO::getTotal)) .collect(Collectors.toList()); - return newList; + return returnList; } private List initUserSubAgencyResultDTO(String myAgencyId) { @@ -161,25 +169,25 @@ public class UserAnalysisServiceImpl implements UserAnalysisService { UserSubAgencyResultDTO resi=new UserSubAgencyResultDTO(); resi.setAgencyId(agencyDTO.getId()); resi.setName(agencyDTO.getAgencyName()); - resi.setValue(0); + resi.setValue(NumConstant.ZERO); resi.setType(UserAnalysisConstant.REGISTERED_RESI); - resi.setTotal(0); + resi.setTotal(NumConstant.ZERO); list.add(resi); //热心居民 UserSubAgencyResultDTO warm=new UserSubAgencyResultDTO(); warm.setAgencyId(agencyDTO.getId()); warm.setName(agencyDTO.getAgencyName()); - warm.setValue(0); + warm.setValue(NumConstant.ZERO); warm.setType(UserAnalysisConstant.WARMHEARTED); - warm.setTotal(0); + warm.setTotal(NumConstant.ZERO); list.add(warm); //党员 UserSubAgencyResultDTO party=new UserSubAgencyResultDTO(); party.setAgencyId(agencyDTO.getId()); party.setName(agencyDTO.getAgencyName()); - party.setValue(0); + party.setValue(NumConstant.ZERO); party.setType(UserAnalysisConstant.PARTYMEMBER); - party.setTotal(0); + party.setTotal(NumConstant.ZERO); list.add(party); } return list; @@ -194,7 +202,88 @@ public class UserAnalysisServiceImpl implements UserAnalysisService { **/ @Override public List subGrid(UserSubGridFormDTO formDTO) { - return null; + //获取用户所属机关id + String myAgencyId = this.getMyAgency(); + //初始化横坐标(用户所机关的直属网格) + List dimList = this.initUserSubGridResultDTO(myAgencyId); + if(CollectionUtils.isEmpty(dimList)){ + logger.info(String.format("当前机关(agencyId=%s)下没有网格",myAgencyId)); + return new ArrayList<>(); + } + //根据入参,查询注册用户或者参与用户的(机关、按日的查询结果) + List userSubGridResDTOS=new ArrayList<>(); + if (UserAnalysisConstant.PARTI_FLAG.equals(formDTO.getRegOrPartiFlag())) { + //参与用户 + userSubGridResDTOS=userAnalysisDao.selectParticipationSubGridRes(formDTO.getDateId(),myAgencyId); + } else { + //注册用户 + userSubGridResDTOS=userAnalysisDao.selectRegSubGridRes(formDTO.getDateId(),myAgencyId); + } + //根据维度表进行对比 + for(UserSubGridResultDTO dimInitResultDto:dimList){ + boolean flag=false; + for(UserSubGridResDTO userSubGridResDTO:userSubGridResDTOS){ + if(dimInitResultDto.getGridId().equals(userSubGridResDTO.getGridId())){ + flag=true; + //居民、热心居民、党员总数,用于排序 + dimInitResultDto.setTotal(userSubGridResDTO.getPartymemberTotal() + +userSubGridResDTO.getWarmHeartedTotal() + +userSubGridResDTO.getResiTotal()); + switch(dimInitResultDto.getType()){ + case UserAnalysisConstant.REGISTERED_RESI: + dimInitResultDto.setValue(userSubGridResDTO.getResiTotal()); + break; + case UserAnalysisConstant.WARMHEARTED: + dimInitResultDto.setValue(userSubGridResDTO.getWarmHeartedTotal()); + break; + case UserAnalysisConstant.PARTYMEMBER: + dimInitResultDto.setValue(userSubGridResDTO.getPartymemberTotal()); + break; + default: + break; + } + } + } + if(!flag){ + logger.error(String.format("直属网格注册用户数缺少记录:date_id=%s,gridId=%s",formDTO.getDateId(),dimInitResultDto.getGridId())); + } + } + //返回集合按照total降序排序 + List returnList = dimList.stream().sorted(Comparator.comparing(UserSubGridResultDTO::getTotal)) + .collect(Collectors.toList()); + return returnList; + } + + private List initUserSubGridResultDTO(String myAgencyId) { + List list=new ArrayList<>(); + List gridList=userAnalysisDao.selectSubGridList(myAgencyId); + for(DimGridDTO grid:gridList){ + //居民 + UserSubGridResultDTO resi=new UserSubGridResultDTO(); + resi.setGridId(grid.getId()); + resi.setName(grid.getGridName()); + resi.setValue(NumConstant.ZERO); + resi.setType(UserAnalysisConstant.REGISTERED_RESI); + resi.setTotal(NumConstant.ZERO); + list.add(resi); + //热心居民 + UserSubGridResultDTO warm=new UserSubGridResultDTO(); + warm.setGridId(grid.getId()); + warm.setName(grid.getGridName()); + warm.setValue(NumConstant.ZERO); + warm.setType(UserAnalysisConstant.WARMHEARTED); + warm.setTotal(NumConstant.ZERO); + list.add(warm); + //党员 + UserSubGridResultDTO party=new UserSubGridResultDTO(); + party.setGridId(grid.getId()); + party.setName(grid.getGridName()); + party.setValue(NumConstant.ZERO); + party.setType(UserAnalysisConstant.PARTYMEMBER); + party.setTotal(NumConstant.ZERO); + list.add(party); + } + return list; } /** 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 efd1888940..f00dc28baf 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 @@ -13,6 +13,20 @@ da.DEL_FLAG = '0' AND da.AGENCY_DIM_TYPE = 'all' AND da.PID =#{myAgencyId} + order by CONVERT ( da.AGENCY_NAME USING gbk ) ASC + + + + - + + + + + + \ No newline at end of file