xyh
2021-06-15 97a2450add4ae6af0f2b87a647cabde380c70093
人口大屏统计接口,人口导入重构
10个文件已修改
10个文件已添加
885 ■■■■ 已修改文件
springcloud_k8s_panzhihuazhihuishequ/common/pom.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/screen/ComActNeighborCircleScreenVO.java 51 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/screen/ComActPopulationCultureVO.java 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/screen/ComActPopulationScreenVO.java 50 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/screen/ComMngPopulationAgeVO.java 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/community/CommunityService.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/ScreenPopulationApi.java 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/ScreenWorkApi.java 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/biz/KeyPersonBizServiceImpl.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/api/ScreenPopulationApi.java 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/api/ScreenWorkApi.java 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComActNeighborCircleDAO.java 24 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComMngPopulationDAO.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/model/dos/ComMngPopulationDO.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/model/dos/ComMngPopulationHouseDO.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/model/dos/ComMngPopulationHouseUserDO.java 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/ComMngPopulationService.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/ScreenWorkService.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngPopulationServiceImpl.java 361 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ScreenWorkServiceImpl.java 56 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/pom.xml
@@ -15,6 +15,11 @@
    <dependencies>
        <dependency>
            <groupId>cn.hutool</groupId>
            <artifactId>hutool-core</artifactId>
            <version>4.0.7</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
        </dependency>
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/screen/ComActNeighborCircleScreenVO.java
New file
@@ -0,0 +1,51 @@
package com.panzhihua.common.model.vos.screen;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
 * @author xyh
 * @date 2021/6/15 14:36
 */
@Data
@ApiModel("大屏邻里圈最新动态")
public class ComActNeighborCircleScreenVO implements Serializable {
    private static final long serialVersionUID = 8407169650740659312L;
    @ApiModelProperty(value = "邻里圈图片轮播")
    private List<String> imgs;
    @ApiModelProperty(value = "邻里圈轮播信息")
    private List<NeighborCircleListVO> neighborCircles;
    @ApiModelProperty(value = "本月新增")
    private Long currentNum;
    @ApiModelProperty(value = "总发表")
    private Long totalNum;
    @ApiModelProperty(value = "点赞量")
    private Long fabulousNum;
    @ApiModelProperty(value = "评论量")
    private Long commentNum;
    @ApiModelProperty(value = "分享量")
    private Long sharedNum;
    @ApiModel("邻里圈列表")
    @Data
    public class NeighborCircleListVO{
        @ApiModelProperty(value = "邻里圈id")
        private Long id;
        @ApiModelProperty(value = "邻里圈内容")
        private String releaseContent;
    }
}
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/screen/ComActPopulationCultureVO.java
New file
@@ -0,0 +1,24 @@
package com.panzhihua.common.model.vos.screen;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
 * @author xyh
 * @date 2021/6/15 14:36
 */
@Data
@ApiModel("实有人口文化程度统计")
public class ComActPopulationCultureVO implements Serializable {
    @ApiModelProperty(value = "文化程度")
    private String level;
    @ApiModelProperty(value = "人口数")
    private Long num;
}
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/screen/ComActPopulationScreenVO.java
New file
@@ -0,0 +1,50 @@
package com.panzhihua.common.model.vos.screen;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
 * @author xyh
 * @date 2021/6/15 14:36
 */
@Data
@ApiModel("大屏人口")
public class ComActPopulationScreenVO implements Serializable {
    @ApiModelProperty(value = "总人口数")
    private Long totalNum;
    @ApiModelProperty(value = "户籍人口数")
    private Long localNum;
    @ApiModelProperty(value = "流动人口数")
    private Long outNum;
    @ApiModelProperty(value = "特殊人口数")
    private Long specialNum;
    @ApiModelProperty(value = "已使用社区同人口数")
    private Long usedCommunityNum;
    @ApiModelProperty(value = "男性数量")
    private Long manNum;
    @ApiModelProperty(value = "男性占比")
    private Integer manPoint;
    @ApiModelProperty(value = "女性数量")
    private Long woman;
    @ApiModelProperty(value = "女性占比")
    private Integer womanPoint;
    @ApiModelProperty("实有人口年龄结构")
    private List<ComMngPopulationAgeVO> ageGroup;
    @ApiModelProperty("实有人口文化程度统计")
    private List<ComActPopulationCultureVO> cultureGroup;
}
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/screen/ComMngPopulationAgeVO.java
New file
@@ -0,0 +1,24 @@
package com.panzhihua.common.model.vos.screen;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
 * @author xyh
 * @date 2021/6/15 16:42
 */
@Data
@ApiModel("年龄段结构统计")
public class ComMngPopulationAgeVO implements Serializable {
    private static final long serialVersionUID = 1562369303787355841L;
    @ApiModelProperty("年龄段")
    private String group;
    @ApiModelProperty("数量")
    private Long num;
}
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/community/CommunityService.java
@@ -2756,4 +2756,19 @@
    @PostMapping("/key_person/batch/save")
    R saveBatchKeyPerson(@RequestBody List<KeyPersonInfoDTO> list);
    /**
     * 大屏统计邻里圈
     * @param communityId
     * @return
     */
    @GetMapping("/screen/work/neighborCircle")
    R statisticNeighborCircle(@RequestParam("communityId") Long communityId);
    /**
     * 大屏统计实有人口
     * @param communityId
     * @return
     */
    @GetMapping("/screen/population/statistic")
    R statistic(@RequestParam("communityId")Long communityId);
}
springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/ScreenPopulationApi.java
New file
@@ -0,0 +1,37 @@
package com.panzhihua.community_backstage.api;
import com.panzhihua.common.controller.BaseController;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.screen.ComActNeighborCircleScreenVO;
import com.panzhihua.common.service.community.CommunityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
 * @author xyh
 * @date 2021/6/15 14:30
 */
@Slf4j
@Api(tags = {"大屏-人口"})
@RestController
@RequestMapping("/screen/population")
public class ScreenPopulationApi extends BaseController {
    @Resource
    private CommunityService communityService;
    @ApiOperation(value = "人口@xyh",response = ComActNeighborCircleScreenVO.class)
    @GetMapping("/statistic")
    public R statistic(){
        return communityService.statistic(45L);
    }
}
springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/ScreenWorkApi.java
New file
@@ -0,0 +1,37 @@
package com.panzhihua.community_backstage.api;
import com.panzhihua.common.controller.BaseController;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.screen.ComActNeighborCircleScreenVO;
import com.panzhihua.common.service.community.CommunityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
 * @author xyh
 * @date 2021/6/15 14:30
 */
@Slf4j
@Api(tags = {"大屏-工作"})
@RestController
@RequestMapping("/screen/work")
public class ScreenWorkApi extends BaseController {
    @Resource
    private CommunityService communityService;
    @ApiOperation(value = "邻里圈@xyh",response = ComActNeighborCircleScreenVO.class)
    @GetMapping("/statisticNeighborCircle")
    public R statisticNeighborCircle(){
        return communityService.statisticNeighborCircle(this.getLoginUserInfo().getCommunityId());
    }
}
springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/biz/KeyPersonBizServiceImpl.java
@@ -58,4 +58,26 @@
        excelSelectObjectList.add(new ExcelSelectObject(17, 17, (String[]) map.get("family")));
        return excelSelectObjectList;
    }
    /**
     * 定义导出实有人口下拉选项 值
     * @return
     */
    public List<ExcelSelectObject> definePopulationExcelModelData() {
        HashMap map = new HashMap(5);
        List<String> dictNames = Arrays.asList("sex", "family", "education", "nation", "key_person_type");
        dictNames.forEach(dictName -> {
            List<BcDictionaryVO> dictionaryItem = communityService.listDictionaryByKey(dictName).getData();
            String[] dataMap = dictionaryItem.stream().map(dictionaryVO -> dictionaryVO.getDictName() + split + dictionaryVO.getDictValue()).distinct().toArray(String[]::new);
            map.put(dictName, dataMap);
        });
        List<ExcelSelectObject> excelSelectObjectList = new ArrayList<>();
        excelSelectObjectList.add(new ExcelSelectObject(1, 1, (String[]) map.get("sex")));
        excelSelectObjectList.add(new ExcelSelectObject(4, 4, (String[]) map.get("nation")));
        excelSelectObjectList.add(new ExcelSelectObject(8, 8, (String[]) map.get("key_person_type")));
        excelSelectObjectList.add(new ExcelSelectObject(12, 12, (String[]) map.get("education")));
        excelSelectObjectList.add(new ExcelSelectObject(17, 17, (String[]) map.get("family")));
        return excelSelectObjectList;
    }
}
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/api/ScreenPopulationApi.java
New file
@@ -0,0 +1,35 @@
package com.panzhihua.service_community.api;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.service_community.service.ComMngPopulationService;
import com.panzhihua.service_community.service.ScreenWorkService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
 * @author xyh
 * @date 2021/6/15 15:13
 */
@RestController
@RequestMapping("/screen/population")
public class ScreenPopulationApi {
    @Resource
    private ComMngPopulationService comMngPopulationService;
    /**
     * 大屏人口查询
     * @param communityId
     * @return
     */
    @GetMapping("/statistic")
    R statistic(@RequestParam("communityId")Long communityId){
        return R.ok(comMngPopulationService.screenStatistic(communityId));
    }
}
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/api/ScreenWorkApi.java
New file
@@ -0,0 +1,40 @@
package com.panzhihua.service_community.api;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.service_community.service.ScreenWorkService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import javax.annotation.Resource;
/**
 * @author xyh
 * @date 2021/6/15 15:13
 */
@RequestMapping("/screen/work")
public class ScreenWorkApi {
    @Resource
    private ScreenWorkService screenWorkService;
    /**
     * 大屏统计邻里圈
     * @param communityId
     * @return
     */
    @GetMapping("/screen/work/neighborCircle")
    R statisticNeighborCircle(@RequestParam("communityId") Long communityId){
        return screenWorkService.statisticNeighborCircle(communityId);
    }
    /**
     * 大屏统计党建工作
     * @param communityId
     * @return
     */
//    @GetMapping("/screen/work/neighborCircle")
//    R statisticNeighborCircle(@RequestParam("communityId") Long communityId){
//        return screenWorkService.statisticNeighborCircle(communityId);
//    }
}
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComActNeighborCircleDAO.java
@@ -5,16 +5,16 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.panzhihua.common.model.dtos.neighbor.ComActNeighborCircleAdminDTO;
import com.panzhihua.common.model.dtos.neighbor.ComActNeighborCircleAppDTO;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.neighbor.ComActNeighborCircleAdminVO;
import com.panzhihua.common.model.vos.neighbor.ComActNeighborCircleAppVO;
import com.panzhihua.common.model.vos.neighbor.ComActNeighborCircleDetailAppVO;
import com.panzhihua.common.model.vos.neighbor.ComActNeighborCommentReplyAppVO;
import com.panzhihua.common.model.vos.neighbor.*;
import com.panzhihua.common.model.vos.screen.ComActNeighborCircleScreenVO;
import com.panzhihua.common.model.vos.user.AdministratorsUserVO;
import com.panzhihua.service_community.model.dos.ComActNeighborCircleDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
import java.util.Map;
/**
 * @auther lyq
@@ -109,4 +109,18 @@
            " where reply.comment_id = #{commentId} and reply.status = 1")
    IPage<ComActNeighborCommentReplyAppVO> neighborCommentReplyByApp(Page page, @Param("commentId") Long commentId);
    @Select("SELECT id,release_content FROM com_act_neighbor_circle WHERE status = 2 AND community_id =#{communityId} ORDER BY create_at DESC limit 0,#{neighborSize}")
    List<ComActNeighborCircleScreenVO.NeighborCircleListVO> screenNeighborCircle(@Param("communityId") Long communityId, @Param("neighborSize") Integer neighborSize);
    @Select("SELECT COUNT(id) FROM com_act_neighbor_circle WHERE STATUS = 2 AND community_id = #{communityId}")
    Long countByCommunityId(@Param("communityId")Long communityId);
    @Select("SELECT SUM(comment_num),SUM(fabulous_num),SUM(forward_num) FROM com_act_neighbor_circle WHERE STATUS = 2 AND community_id = #{communityId} group by community_id ")
    Map<String, Long> sumScreenNum(Long communityId);
    @Select("SELECT release_images FROM com_act_neighbor_circle_comment WHERE STATUS = 2 AND community_id = #{communityId} group by community_id ")
    List<String> screenNeighborCircleImgs(@Param("communityId") Long communityId,@Param("neighborSize") Integer neighborSize);
    @Select("SELECT COUNT(id) FROM com_act_neighbor_circle WHERE STATUS = 2 AND community_id = #{communityId} AND create_at LIKE CONCAT(#{nowDate},'%')")
    Long countCurrentNeighborCircles(@Param("communityId")Long communityId,@Param("nowDate") String nowDate);
}
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComMngPopulationDAO.java
@@ -20,6 +20,7 @@
import org.apache.ibatis.annotations.Select;
import java.util.List;
import java.util.Map;
/**
 * 实有人口Dao
@@ -238,4 +239,35 @@
            ",(select count(id) from com_mng_population where act_id = #{communityId} and label is not null) as specialTotal " +
            " from com_mng_population as cmp where act_id = #{communityId}")
    ComMngPopulationTotalVO getPopulationTotalByAdmin(@Param("communityId") Long communityId);
    @Select("SELECT COUNT(id) AS man,(SELECT COUNT(id) FROM com_mng_population WHERE sex = 2 AND act_id = #{communityId}) AS woman FROM com_mng_population WHERE sex = 1 AND act_id = #{communityId}")
    Map<String, Long> countBySex(@Param("communityId") Long communityId);
    @Select(
            "SELECT " +
                    "(SELECT COUNT(aa.age) FROM " +
                    "(SELECT (SELECT  TIMESTAMPDIFF(YEAR, birthday, CURDATE()) ) AS age FROM com_mng_population WHERE act_id = #{communityId}) as aa where aa.age<= 16) as age16," +
                    "(SELECT COUNT(aa.age) FROM " +
                    "(SELECT (SELECT  TIMESTAMPDIFF(YEAR, birthday, CURDATE()) ) AS age FROM com_mng_population WHERE act_id = #{communityId}) AS aa WHERE aa.age > 16 and aa.age<= 25) AS age25," +
                    "(SELECT COUNT(aa.age) FROM " +
                    "(SELECT (SELECT  TIMESTAMPDIFF(YEAR, birthday, CURDATE()) ) AS age FROM com_mng_population WHERE act_id = #{communityId}) AS aa WHERE aa.age > 25 and aa.age<= 35) AS age35," +
                    "(SELECT COUNT(aa.age) FROM " +
                    "(SELECT (SELECT  TIMESTAMPDIFF(YEAR, birthday, CURDATE()) ) AS age FROM com_mng_population WHERE act_id = #{communityId}) AS aa WHERE aa.age > 35 and aa.age<= 45) AS age45," +
                    "(SELECT COUNT(aa.age) FROM " +
                    "(SELECT (SELECT  TIMESTAMPDIFF(YEAR, birthday, CURDATE()) ) AS age FROM com_mng_population WHERE act_id = #{communityId}) AS aa WHERE aa.age > 45 and aa.age<= 55) AS age55," +
                    "(SELECT COUNT(aa.age) FROM " +
                    "(SELECT (SELECT  TIMESTAMPDIFF(YEAR, birthday, CURDATE()) ) AS age FROM com_mng_population WHERE act_id = #{communityId}) AS aa WHERE aa.age > 55) AS age55over")
    Map<String, Long> countByAge(@Param("communityId")Long communityId);
    @Select("SELECT COUNT(id)AS xx," +
            "(SELECT COUNT(id) FROM com_mng_population WHERE culture_level = 2 AND act_id = #{communityId}) as cz," +
            "(SELECT COUNT(id) FROM com_mng_population WHERE culture_level = 3 AND act_id = #{communityId}) as gz," +
            "(SELECT COUNT(id) FROM com_mng_population WHERE culture_level = 4 AND act_id = #{communityId}) as zz," +
            "(SELECT COUNT(id) FROM com_mng_population WHERE culture_level = 5 AND act_id = #{communityId}) as dz," +
            "(SELECT COUNT(id) FROM com_mng_population WHERE culture_level = 6 AND act_id = #{communityId}) as bk," +
            "(SELECT COUNT(id) FROM com_mng_population WHERE culture_level = 7 AND act_id = #{communityId}) as ss," +
            "(SELECT COUNT(id) FROM com_mng_population WHERE culture_level = 8 AND act_id = #{communityId}) as bs," +
            "(SELECT COUNT(id) FROM com_mng_population WHERE culture_level = 9 AND act_id = #{communityId}) as qt" +
            " FROM com_mng_population WHERE culture_level = 1 AND act_id = #{communityId}")
    Map<String, Long> countByCulture(Long communityId);
}
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/model/dos/ComMngPopulationDO.java
@@ -17,7 +17,7 @@
    /**
     * 自增 id
     */
    @TableId(type = IdType.AUTO)
    @TableId(type = IdType.INPUT)
    private Long id;
    /**
     * 街道id
@@ -42,12 +42,17 @@
    /**
     * 年龄
     */
    private Integer age;
//    private Integer age;
    /**
     * 身份证号码
     */
    @EncryptDecryptField
    private String cardNo;
    /**
     * 临时用
     */
    private String cardNoStr;
    /**
     * 街路巷
     */
@@ -132,9 +137,9 @@
    /**
     * 与户主关系(1.户主 2.配偶 3.子女 4.孙女 5.父母 6.其他)
     */
    private Integer relation;
    private String relationStr;
//    private Integer relation;
//
//    private String relationStr;
    /**
     * 文化程度(1.小学 2.初中 3.高中 4.中专 5.大专 6.本科 7.硕士 8.博士 9.其他)
@@ -146,8 +151,6 @@
     */
    private Integer marriage;
    private String marriageStr;
    /**
     * 健康状况
@@ -157,7 +160,7 @@
    /**
     * 房屋地址
     */
    private String houseAddress;
//    private String houseAddress;
    /**
     * 出生年月日
@@ -167,7 +170,7 @@
    /**
     * 居住地房屋id
     */
    private Long houseId;
//    private Long houseId;
    /**
     * 性别(1.男 2.女 3.未知)
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/model/dos/ComMngPopulationHouseDO.java
@@ -23,7 +23,7 @@
    /**
     * 主键id
     */
    @TableId(type = IdType.AUTO)
    @TableId(type = IdType.INPUT)
    private Long id;
    /**
@@ -111,10 +111,22 @@
     */
    private Long villageId;
    /**
     * 街道id
     * @return
     */
    private Long streetId;
    /**
     * 层次递归字段(省>市>区县>街道>社区>小区>详细地址)
     */
    private String path;
    @Override
    public String toString() {
        return "ComMngPopulationHouseDO{" +
                "id=" + id +
                ", streetId="+streetId+
                ", address=" + address +
                ", code=" + code +
                ", alley=" + alley +
@@ -125,6 +137,7 @@
                ", isEmpty=" + isEmpty +
                ", constructPurpose=" + constructPurpose +
                ", constructArea=" + constructArea +
                ", path="+path+
                ", createAt=" + createAt +
                ", updateAt=" + updateAt +
                "}";
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/model/dos/ComMngPopulationHouseUserDO.java
@@ -23,7 +23,7 @@
    /**
     * 主键id
     */
    @TableId(type = IdType.AUTO)
    @TableId(type = IdType.INPUT)
    private Long id;
    /**
@@ -41,7 +41,20 @@
     */
    private Integer relation;
    private String relationStr;
    /**
     * 人和房屋关系’ (1.自住2、租住)
     */
    private Integer relationId;
    /**
     * 入住开始时间
     */
    private Date startAt;
    /**
     * 入住结束时间
     */
    private Date endAt;
    /**
     * 创建时间
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/ComMngPopulationService.java
@@ -190,4 +190,11 @@
     * @date 2021/6/10 17:00
     */
    ComMngPopulationDO getPopulationByCardNo(String cardNo);
    /**
     *  大屏统计实有人口
     * @param communityId
     * @return
     */
    R screenStatistic(Long communityId);
}
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/ScreenWorkService.java
New file
@@ -0,0 +1,12 @@
package com.panzhihua.service_community.service;
import com.panzhihua.common.model.vos.R;
/**
 * @author xyh
 * @date 2021/6/15 15:14
 */
public interface ScreenWorkService {
    R statisticNeighborCircle(Long communityId);
}
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngPopulationServiceImpl.java
@@ -7,16 +7,19 @@
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.base.Joiner;
import com.google.common.collect.Lists;
import com.panzhihua.common.enums.PopulCultureLevelEnum;
import com.panzhihua.common.enums.PopulHouseUseEnum;
import com.panzhihua.common.enums.PopulIsOksEnum;
import com.panzhihua.common.exceptions.ServiceException;
import com.panzhihua.common.model.dtos.community.*;
import com.panzhihua.common.model.dtos.user.PageInputUserDTO;
import com.panzhihua.common.model.helper.AESUtil;
import com.panzhihua.common.model.helper.AESUtil;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.area.AreaAddressVO;
import com.panzhihua.common.model.vos.community.*;
import com.panzhihua.common.model.vos.screen.ComActPopulationCultureVO;
import com.panzhihua.common.model.vos.screen.ComActPopulationScreenVO;
import com.panzhihua.common.model.vos.screen.ComMngPopulationAgeVO;
import com.panzhihua.common.model.vos.user.*;
import com.panzhihua.common.utlis.*;
import com.panzhihua.service_community.dao.*;
@@ -25,8 +28,6 @@
import com.panzhihua.service_community.service.ComMngPopulationService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
@@ -135,18 +136,18 @@
        if (ObjectUtils.isEmpty(comMngPopulationDO)) {
            return R.fail("用户信息不存在");
        }
        if(StringUtils.isNotEmpty(comMngPopulationDO.getBirthday())){//计算年龄
            comMngPopulationDO.setAge(AgeUtils.getAgeFromBirthTimes(comMngPopulationDO.getBirthday()));
        }
//        if(StringUtils.isNotEmpty(comMngPopulationDO.getBirthday())){//计算年龄
//            comMngPopulationDO.setAge(AgeUtils.getAgeFromBirthTimes(comMngPopulationDO.getBirthday()));
//        }
        ComMngPopulationVO comMngPopulationVO = new ComMngPopulationVO();
        BeanUtils.copyProperties(comMngPopulationDO, comMngPopulationVO);
        //查询户主关系信息
        List<ComHouseMemberVo> comMngFamilyInfoVOS = populationDAO.listHouseMermberByUserId(comMngPopulationDO.getHouseId(),comMngPopulationDO.getId());
        if (!comMngFamilyInfoVOS.isEmpty()) {
            comMngPopulationVO.setComMngFamilyInfoVOS(comMngFamilyInfoVOS);
        }
//        List<ComHouseMemberVo> comMngFamilyInfoVOS = populationDAO.listHouseMermberByUserId(comMngPopulationDO.getHouseId(),comMngPopulationDO.getId());
//        if (!comMngFamilyInfoVOS.isEmpty()) {
//            comMngPopulationVO.setComMngFamilyInfoVOS(comMngFamilyInfoVOS);
//        }
        //查询当前用户电子档信息
        if(!StringUtils.isEmpty(comMngPopulationDO.getCardNo())){
@@ -301,27 +302,25 @@
        //查询该社区的省市区地址
        AreaAddressVO areaAddressVO = populationDAO.getAreaAddress(comActDO.getProvinceCode(),comActDO.getCityCode(),comActDO.getAreaCode());
        //查询社区上街道信息
        String street = "";
        String streetName = "";
        if(comActDO.getStreetId() != null){
            ComStreetDO streetDO = comStreetDAO.selectById(comActDO.getStreetId());
            if(streetDO != null){
                street = streetDO.getName();
                streetName = streetDO.getName();
            }
        }
        int index = 2;
        StringBuilder areaPath = new StringBuilder();
        areaPath.append(areaAddressVO.getProvince()).append(">").append(areaAddressVO.getCity()).append(">").append(areaAddressVO.getDistrict()).append(">");
        //处理实有人口信息
        List<ComMngPopulationDO> savePopulList = new ArrayList<>();
        List<ComMngPopulationHouseDO> saveHouseList = new ArrayList<>();
        for (ComMngPopulationServeExcelVO vo : list) {
            String address = "";
            //查询街路巷是否存在
            //查询小区街路巷是否存在
            ComMngVillageDO comMngVillageDO = comActVillageDAO.selectOne(new QueryWrapper<ComMngVillageDO>().eq("alley",vo.getRoad()).eq("house_num",vo.getDoorNo()).eq("community_id",communityId));
            if (comMngVillageDO == null) {
                ComMngPopulationImportErrorVO importErrorVO = new ComMngPopulationImportErrorVO();
                importErrorVO.setErrorMsg("查无:" + vo.getRoad() + vo.getDoorNo() + "小区/房租地址,请先新建地址");
                importErrorVO.setErrorPosition("第" + index + "行,第7、8列");
                importErrorVO.setErrorMsg("街路巷或小区号不存在");
                importErrorVO.setErrorPosition("街路巷:" + vo.getRoad() + ",小区号:"+vo.getDoorNo());
                populationImportErrorVOList.add(importErrorVO);
                index++;
                continue;
            }
@@ -329,8 +328,9 @@
                comMngVillageDO.setHouseNum(comMngVillageDO.getHouseNum() + "号");
            }
            //小区详细地址
            address = areaAddressVO.getProvince() + areaAddressVO.getCity()
                    + areaAddressVO.getDistrict() + street + comMngVillageDO.getAlley() + comMngVillageDO.getHouseNum()
                    + areaAddressVO.getDistrict() + streetName + comMngVillageDO.getAlley() + comMngVillageDO.getHouseNum()
                    + vo.getFloor() + vo.getUnitNo() + vo.getHouseNo();
            vo.setAddress(address);
@@ -340,151 +340,40 @@
                    .eq(ComMngPopulationHouseDO::getFloor,vo.getFloor()).eq(ComMngPopulationHouseDO::getUnitNo,vo.getUnitNo())
                    .eq(ComMngPopulationHouseDO::getHouseNo,vo.getHouseNo()));
            if(populationHouseDO == null){
                boolean isExits = true;
                if(!saveHouseList.isEmpty()){
                    for (ComMngPopulationHouseDO saveHouse:saveHouseList){
                        if(saveHouse.getVillageId().equals(comMngVillageDO.getVillageId())
                                && saveHouse.getFloor().equals(vo.getFloor()) && saveHouse.getUnitNo().equals(vo.getUnitNo())
                                && saveHouse.getHouseNo().equals(vo.getHouseNo())){
                            populationHouseDO = saveHouse;
                            isExits = false;
                            break;
                        }
                    }
                }
                if(isExits){
                    //查询该房屋未建立,执行建立房屋信息
                    populationHouseDO = new ComMngPopulationHouseDO();
                    populationHouseDO.setVillageId(comMngVillageDO.getVillageId());
                    populationHouseDO.setAlley(vo.getRoad());
                    populationHouseDO.setHouseNum(vo.getDoorNo());
                    populationHouseDO.setCode(vo.getDoorNo());
                    populationHouseDO.setStatus(vo.getIsRent());
                    populationHouseDO.setCommunityId(communityId);
                    populationHouseDO.setFloor(vo.getFloor());
                    populationHouseDO.setUnitNo(vo.getUnitNo());
                    populationHouseDO.setHouseNo(vo.getHouseNo());
                    populationHouseDO.setAddress(address);
                    populationHouseDO.setUpdateAt(new Date());
                    populationHouseDO.setConstructPurpose(vo.getBuildPurpose());
                    try {
                        populationHouseDO.setConstructArea(new BigDecimal(vo.getBuildArea()));
                    }catch (Exception e){
                    }
                    if(StringUtils.isEmpty(vo.getName()) && StringUtils.isEmpty(vo.getCardNo())){
                        populationHouseDO.setIsEmpty(PopulIsOksEnum.YES.getCode());
                    }
                    if(vo.getHouseStatus() != null){
                        populationHouseDO.setStatus(vo.getHouseStatus());
                    }
                    if(vo.getHousePurpose() != null){
                        populationHouseDO.setPurpose(vo.getHousePurpose());
                    }
                    if(vo.getControlStatus() != null){
                        populationHouseDO.setControlStatus(vo.getControlStatus());
                    }
                    comMngPopulationHouseDAO.insert(populationHouseDO);
                    saveHouseList.add(populationHouseDO);
                }
                //房屋信息不存在建立房屋信息
                populationHouseDO = savePopulationHouse(vo,comMngVillageDO,communityId,address,areaPath,comActDO.getName());
            }
            if(StringUtils.isEmpty(vo.getName()) && StringUtils.isEmpty(vo.getCardNo())){
                //空户处理完房屋信息,直接返回
                continue;
            }
            String cardNoAES = AESUtil.encrypt128(vo.getCardNo(), aesKey);
            //判断实有人口是否已存在
            ComMngPopulationDO populationDO = this.baseMapper.selectOne(new QueryWrapper<ComMngPopulationDO>().lambda()
                    .eq(ComMngPopulationDO::getCardNo,AESUtil.encrypt128(vo.getCardNo(), aesKey)).eq(ComMngPopulationDO::getName,vo.getName()));
                    .eq(ComMngPopulationDO::getCardNo,cardNoAES));
            if(populationDO == null){
                if(savePopulList.size() > 0){
                    String name = vo.getName();
                    String cardNo = AESUtil.encrypt128(vo.getCardNo(), aesKey);
                    if(savePopulList.stream().anyMatch(populDo -> name.equals(populDo.getName()) && cardNo.equals(populDo.getCardNo()))){
                        //实有人口已存在,判断录入的这个房屋信息是否是用户的居住地
                        for (ComMngPopulationDO savePopul:savePopulList) {
                            if(savePopul.getName().equals(name) && savePopul.getCardNo().equals(cardNo)){
                                if(vo.getIsResidence() != null && vo.getIsResidence().equals(PopulIsOksEnum.YES.getCode())) {
                                    savePopul.setRoad(vo.getRoad());
                                    savePopul.setDoorNo(vo.getDoorNo());
                                    savePopul.setFloor(vo.getFloor());
                                    savePopul.setUnitNo(vo.getUnitNo());
                                    savePopul.setHouseNo(vo.getHouseNo());
                                    savePopul.setHouseAddress(vo.getAddress());
                                    savePopul.setHouseId(populationHouseDO.getId());
                                    savePopul.setCardNo(cardNo);
                                    savePopul.setPhone(AESUtil.encrypt128(savePopul.getPhone(), aesKey));
                                    this.baseMapper.updateById(savePopul);
                                }
                                populationDO = savePopul;
                                break;
                            }
                        }
                    }else{
                        //不存在实有人口则新增
                        populationDO = new ComMngPopulationDO();
                        BeanUtils.copyProperties(vo,populationDO);
                        List<String> userTag = vo.getUserTagStr().stream().map(userTagStr -> userTagStr.split("\\(")[0]).collect(Collectors.toList());
                        populationDO.setVillageId(comMngVillageDO.getVillageId());
                        populationDO.setActId(comActDO.getCommunityId());
                        populationDO.setStreetId(comActDO.getStreetId());
                        populationDO.setLabel(Joiner.on(",").join(userTag));
                        populationDO.setVillageName(comMngVillageDO.getGroupAt());
                        populationDO.setHouseAddress(address);
                        populationDO.setHouseId(populationHouseDO.getId());
                        populationDO.setUpdateAt(new Date());
                        this.baseMapper.insert(populationDO);
                        savePopulList.add(populationDO);
                        index++;
                    }
                }else {
                    //不存在实有人口则新增
                    populationDO = new ComMngPopulationDO();
                    BeanUtils.copyProperties(vo,populationDO);
                    List<String> userTag = vo.getUserTagStr().stream().map(userTagStr -> userTagStr.split("\\(")[0]).collect(Collectors.toList());
                    populationDO.setVillageId(comMngVillageDO.getVillageId());
                    populationDO.setActId(comActDO.getCommunityId());
                    populationDO.setStreetId(comActDO.getStreetId());
                    populationDO.setLabel(Joiner.on(",").join(userTag));
                    populationDO.setVillageName(comMngVillageDO.getGroupAt());
                    populationDO.setHouseAddress(address);
                    populationDO.setHouseId(populationHouseDO.getId());
                    populationDO.setUpdateAt(new Date());
                    this.baseMapper.insert(populationDO);
                    savePopulList.add(populationDO);
                    index++;
                }
                //不存在实有人口,则新增
                populationDO = savePopulationDO(vo,comActDO,comMngVillageDO,cardNoAES);
            }else {
                //实有人口已存在,判断录入的这个房屋信息是否是用户的居住地
                //如果存在人口信息,且是自用房,则更新人口默认的房屋信息
                if(vo.getIsRent() != null && vo.getIsRent().equals(PopulHouseUseEnum.SELF.getCode())){
                    populationDO.setRoad(vo.getRoad());
                    populationDO.setDoorNo(vo.getDoorNo());
                    populationDO.setFloor(vo.getFloor());
                    populationDO.setUnitNo(vo.getUnitNo());
                    populationDO.setHouseNo(vo.getHouseNo());
                    populationDO.setHouseAddress(address);
                    populationDO.setCardNo(AESUtil.encrypt128(populationDO.getCardNo(), aesKey));
                    if(StringUtils.isNotEmpty(populationDO.getPhone())){
                        populationDO.setPhone(AESUtil.encrypt128(populationDO.getPhone(), aesKey));
                    }
                    populationDO.setHouseId(populationHouseDO.getId());
                    this.baseMapper.updateById(populationDO);
                    populationDO = updatePopulationHouseUse(vo,populationDO,cardNoAES);
                }
            }
            //处理实有房屋居住信息
            //处理实有人口房屋居住信息
            if(populationDO != null){
                ComMngPopulationHouseUserDO populationHouseUserDO = comMngPopulationHouseUserDAO.selectOne(new QueryWrapper<ComMngPopulationHouseUserDO>()
                        .lambda().eq(ComMngPopulationHouseUserDO::getHouseId,populationHouseDO.getId())
                        .eq(ComMngPopulationHouseUserDO::getPopulId,populationDO.getId()));
                if(populationHouseUserDO == null){
                    populationHouseUserDO = new ComMngPopulationHouseUserDO();
                    populationHouseUserDO.setId(Snowflake.getId());
                    populationHouseUserDO.setHouseId(populationHouseDO.getId());
                    populationHouseUserDO.setPopulId(populationDO.getId());
                    populationHouseUserDO.setRelation(populationDO.getRelation());
                    populationHouseUserDO.setRelationStr(populationDO.getRelationStr());
                    populationHouseUserDO.setRelation(vo.getRelation());
                    populationHouseUserDO.setRelationId(vo.getIsRent());
                    comMngPopulationHouseUserDAO.insert(populationHouseUserDO);
                }
            }
@@ -500,6 +389,79 @@
            return R.fail(JSON.toJSONString(populationImportErrorVOList));
        }
        return R.ok();
    }
    private ComMngPopulationDO updatePopulationHouseUse(ComMngPopulationServeExcelVO vo, ComMngPopulationDO populationDO,String cardNoAES) throws Exception {
        populationDO.setRoad(vo.getRoad());
        populationDO.setDoorNo(vo.getDoorNo());
        populationDO.setFloor(vo.getFloor());
        populationDO.setUnitNo(vo.getUnitNo());
        populationDO.setHouseNo(vo.getHouseNo());
        populationDO.setCardNo(cardNoAES);
        populationDO.setCardNoStr(vo.getCardNo());
        if(StringUtils.isNotEmpty(populationDO.getPhone())){
            populationDO.setPhone(AESUtil.encrypt128(populationDO.getPhone(), aesKey));
        }
        this.baseMapper.updateById(populationDO);
        return populationDO;
    }
    private ComMngPopulationDO savePopulationDO(ComMngPopulationServeExcelVO vo, ComActDO comActDO, ComMngVillageDO comMngVillageDO,String cardNoAES) {
        ComMngPopulationDO populationDO = new ComMngPopulationDO();
        BeanUtils.copyProperties(vo,populationDO);
        populationDO.setId(Snowflake.getId());
        List<String> userTag = vo.getUserTagStr().stream().map(userTagStr -> userTagStr.split("\\(")[0]).collect(Collectors.toList());
        populationDO.setVillageId(comMngVillageDO.getVillageId());
        populationDO.setActId(comActDO.getCommunityId());
        populationDO.setStreetId(comActDO.getStreetId());
        populationDO.setLabel(Joiner.on(",").join(userTag));
        populationDO.setVillageName(comMngVillageDO.getGroupAt());
        populationDO.setCardNo(cardNoAES);
        populationDO.setCardNoStr(vo.getCardNo());
        populationDO.setUpdateAt(new Date());
        this.baseMapper.insert(populationDO);
        return populationDO;
    }
    private ComMngPopulationHouseDO savePopulationHouse(ComMngPopulationServeExcelVO vo, ComMngVillageDO comMngVillageDO, Long communityId, String address, StringBuilder areaPath,String actName) {
        //查询该房屋未建立,执行建立房屋信息
        ComMngPopulationHouseDO populationHouseDO = new ComMngPopulationHouseDO();
        populationHouseDO.setId(Snowflake.getId());
        populationHouseDO.setStreetId(comMngVillageDO.getStreetId());
        populationHouseDO.setVillageId(comMngVillageDO.getVillageId());
        populationHouseDO.setAlley(vo.getRoad());
        populationHouseDO.setHouseNum(vo.getDoorNo());
        populationHouseDO.setCode(vo.getDoorNo());
        populationHouseDO.setStatus(vo.getIsRent());
        populationHouseDO.setCommunityId(communityId);
        populationHouseDO.setFloor(vo.getFloor());
        populationHouseDO.setUnitNo(vo.getUnitNo());
        populationHouseDO.setHouseNo(vo.getHouseNo());
        populationHouseDO.setAddress(address);
        populationHouseDO.setUpdateAt(new Date());
        populationHouseDO.setConstructPurpose(vo.getBuildPurpose());
        StringBuilder housePath = new StringBuilder();
        housePath.append(populationHouseDO.getAlley()).append(">").append(actName).append(">").append(comMngVillageDO.getName()).append(">").append(address);
        populationHouseDO.setPath(areaPath.toString()+ housePath.toString());
        try {
            populationHouseDO.setConstructArea(new BigDecimal(vo.getBuildArea()));
        }catch (Exception e){
        }
        if(StringUtils.isEmpty(vo.getName()) && StringUtils.isEmpty(vo.getCardNo())){
            populationHouseDO.setIsEmpty(PopulIsOksEnum.YES.getCode());
        }
        if(vo.getHouseStatus() != null){
            populationHouseDO.setStatus(vo.getHouseStatus());
        }
        if(vo.getHousePurpose() != null){
            populationHouseDO.setPurpose(vo.getHousePurpose());
        }
        if(vo.getControlStatus() != null){
            populationHouseDO.setControlStatus(vo.getControlStatus());
        }
        comMngPopulationHouseDAO.insert(populationHouseDO);
        return populationHouseDO;
    }
    /**
@@ -839,4 +801,117 @@
        return null;
    }
    @Override
    public R screenStatistic(Long communityId) {
        ComActPopulationScreenVO comActPopulationScreenVO = new ComActPopulationScreenVO();
        ComMngPopulationTotalVO vo = populationDAO.getPopulationTotalByAdmin(communityId);
        comActPopulationScreenVO.setTotalNum(vo.getPopulationTotal() == null ? 0 : vo.getPopulationTotal());
        comActPopulationScreenVO.setLocalNum(vo.getLocalTotal() == null ? 0 : vo.getLocalTotal().longValue());
        comActPopulationScreenVO.setOutNum(vo.getOutTotal() == null ? 0 : vo.getOutTotal().longValue());
        comActPopulationScreenVO.setSpecialNum(vo.getSpecialTotal() == null ? 0 : vo.getSpecialTotal().longValue());
        //统计已使用社区通人数
        setUsedCommunityNum(comActPopulationScreenVO,communityId);
        //统计性别
        Map<String,Long> sexMap = populationDAO.countBySex(communityId);
        comActPopulationScreenVO.setWoman(sexMap.get("woman") == null ? 0L : sexMap.get("woman"));
        comActPopulationScreenVO.setManNum(sexMap.get("man") == null ? 0L : sexMap.get("man"));
        int manPoint = (int) (((double)comActPopulationScreenVO.getManNum()/(double)comActPopulationScreenVO.getTotalNum())*100);
        comActPopulationScreenVO.setManPoint(manPoint);
        comActPopulationScreenVO.setWomanPoint(100 - manPoint);
        //统计年龄结构
        setAgeGroup(comActPopulationScreenVO,communityId);
        //统计学历
        setCultureGroup(comActPopulationScreenVO,communityId);
        return R.ok(comActPopulationScreenVO);
    }
    private void setUsedCommunityNum(ComActPopulationScreenVO comActPopulationScreenVO, Long communityId) {
    }
    private void setCultureGroup(ComActPopulationScreenVO comActPopulationScreenVO, Long communityId) {
        Map<String,Long> cultureMap = populationDAO.countByCulture(communityId);
        List<ComActPopulationCultureVO> cultureGroup = new ArrayList<>();
        ComActPopulationCultureVO xx = new ComActPopulationCultureVO();
        xx.setLevel(PopulCultureLevelEnum.XX.getName());
        xx.setNum(cultureMap.get("xx"));
        cultureGroup.add(xx);
        ComActPopulationCultureVO cz = new ComActPopulationCultureVO();
        cz.setLevel(PopulCultureLevelEnum.CZ.getName());
        cz.setNum(cultureMap.get("cz"));
        cultureGroup.add(cz);
        ComActPopulationCultureVO gz = new ComActPopulationCultureVO();
        gz.setLevel(PopulCultureLevelEnum.GZ.getName());
        gz.setNum(cultureMap.get("gz"));
        cultureGroup.add(gz);
        ComActPopulationCultureVO zz = new ComActPopulationCultureVO();
        zz.setLevel(PopulCultureLevelEnum.ZZ.getName());
        zz.setNum(cultureMap.get("zz"));
        cultureGroup.add(zz);
        ComActPopulationCultureVO dz = new ComActPopulationCultureVO();
        dz.setLevel(PopulCultureLevelEnum.DZ.getName());
        dz.setNum(cultureMap.get("dz"));
        cultureGroup.add(dz);
        ComActPopulationCultureVO bk = new ComActPopulationCultureVO();
        bk.setLevel(PopulCultureLevelEnum.BK.getName());
        bk.setNum(cultureMap.get("bk"));
        cultureGroup.add(bk);
        ComActPopulationCultureVO ss = new ComActPopulationCultureVO();
        ss.setLevel(PopulCultureLevelEnum.SS.getName());
        ss.setNum(cultureMap.get("ss"));
        cultureGroup.add(ss);
        ComActPopulationCultureVO bs = new ComActPopulationCultureVO();
        bs.setLevel(PopulCultureLevelEnum.BS.getName());
        bs.setNum(cultureMap.get("bs"));
        cultureGroup.add(bs);
        ComActPopulationCultureVO qt = new ComActPopulationCultureVO();
        qt.setLevel(PopulCultureLevelEnum.QT.getName());
        qt.setNum(cultureMap.get("qt"));
        cultureGroup.add(qt);
        comActPopulationScreenVO.setCultureGroup(cultureGroup);
    }
    private void setAgeGroup(ComActPopulationScreenVO comActPopulationScreenVO,Long communityId) {
        Map<String,Long> ageMap = populationDAO.countByAge(communityId);
        List<ComMngPopulationAgeVO> ageList = new ArrayList<>();
        ComMngPopulationAgeVO ageVO16 = new ComMngPopulationAgeVO();
        ageVO16.setGroup("0-16岁");
        ageVO16.setNum(ageMap.get("age16"));
        ageList.add(ageVO16);
        ComMngPopulationAgeVO ageVO25 = new ComMngPopulationAgeVO();
        ageVO25.setGroup("16-25岁");
        ageVO25.setNum(ageMap.get("age25"));
        ageList.add(ageVO25);
        ComMngPopulationAgeVO ageVO35 = new ComMngPopulationAgeVO();
        ageVO35.setGroup("25-35岁");
        ageVO35.setNum(ageMap.get("age35"));
        ageList.add(ageVO35);
        ComMngPopulationAgeVO ageVO45 = new ComMngPopulationAgeVO();
        ageVO45.setGroup("35-45岁");
        ageVO45.setNum(ageMap.get("age45"));
        ageList.add(ageVO45);
        ComMngPopulationAgeVO ageVO55 = new ComMngPopulationAgeVO();
        ageVO55.setGroup("45-55岁");
        ageVO55.setNum(ageMap.get("age55"));
        ageList.add(ageVO55);
        ComMngPopulationAgeVO ageVO55over = new ComMngPopulationAgeVO();
        ageVO55over.setGroup("55岁以上");
        ageVO55over.setNum(ageMap.get("age55over"));
        ageList.add(ageVO55over);
        comActPopulationScreenVO.setAgeGroup(ageList);
    }
}
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ScreenWorkServiceImpl.java
New file
@@ -0,0 +1,56 @@
package com.panzhihua.service_community.service.impl;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.screen.ComActNeighborCircleScreenVO;
import com.panzhihua.common.utlis.DateUtils;
import com.panzhihua.service_community.dao.ComActNeighborCircleDAO;
import com.panzhihua.service_community.service.ScreenWorkService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.*;
/**
 * @author xyh
 * @date 2021/6/15 15:14
 */
@Service
public class ScreenWorkServiceImpl implements ScreenWorkService {
    private static final Integer neighborSize = 200;
    @Resource
    private ComActNeighborCircleDAO comActNeighborCircleDAO;
    @Override
    public R statisticNeighborCircle(Long communityId) {
        ComActNeighborCircleScreenVO comActNeighborCircleScreenVO = new ComActNeighborCircleScreenVO();
        String date = DateUtils.getDateFormatString(new Date(),"yyyy-MM-dd");
        Long currentNeighborCircles = comActNeighborCircleDAO.countCurrentNeighborCircles(communityId,date);
        comActNeighborCircleScreenVO.setCurrentNum(currentNeighborCircles == null?0:currentNeighborCircles);
        Long totalNum = comActNeighborCircleDAO.countByCommunityId(communityId);
        comActNeighborCircleScreenVO.setTotalNum(totalNum == null?0L:totalNum);
        Map<String,Long> sumMap = comActNeighborCircleDAO.sumScreenNum(communityId);
        comActNeighborCircleScreenVO.setFabulousNum(sumMap.get("fabulousNum")==null?0L:sumMap.get("fabulousNum"));
        comActNeighborCircleScreenVO.setCommentNum(sumMap.get("commentNum")==null?0L:sumMap.get("commentNum"));
        comActNeighborCircleScreenVO.setSharedNum(sumMap.get("forwardNum")==null?0L:sumMap.get("forwardNum"));
        //查询最近发布的邻里圈
        comActNeighborCircleScreenVO.setNeighborCircles(comActNeighborCircleDAO.screenNeighborCircle(communityId,neighborSize));
        //查询最近发布的邻里圈图片
        List<String> imsg = new ArrayList<>();
        List<String> imgList = comActNeighborCircleDAO.screenNeighborCircleImgs(communityId,neighborSize);
        for(String img:imgList){
            String[] imgarr = img.split(",");
            if(imgarr.length > 1){
                for(String arr: imgarr){
                    imsg.add(arr);
                }
            }else{
                imsg.add(img);
            }
        }
        comActNeighborCircleScreenVO.setImgs(imsg);
        return R.ok(comActNeighborCircleScreenVO);
    }
}