From 60c455b39a7080c83b54c02205dadf3467d97298 Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Fri, 10 Dec 2021 15:49:55 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=9A=20=E5=BF=97?= =?UTF-8?q?=E6=84=BF=E8=80=85=E6=8E=AA=E6=96=BD=E6=B8=85=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../result/DemandServiceCountResultDTO.java | 15 ++ .../epmet/controller/DemandController.java | 38 ++++ .../dao/heart/IcUserDemandServiceDao.java | 44 +++++ .../com/epmet/dao/heart/VolunteerInfoDao.java | 33 ++++ .../stats/FactVolunteerServiceDailyDao.java | 42 ++++ .../main/java/com/epmet/dao/user/UserDao.java | 2 + .../heart/IcUserDemandServiceEntity.java | 75 +++++++ .../entity/heart/VolunteerInfoEntity.java | 71 +++++++ .../FactVolunteerServiceDailyEntity.java | 86 ++++++++ .../java/com/epmet/service/DemandService.java | 20 ++ .../service/heart/HeartDemandService.java | 15 ++ .../service/heart/HeartVolunteerService.java | 15 ++ .../heart/impl/HeartDemandServiceImpl.java | 40 ++++ .../heart/impl/HeartVolunteerServiceImpl.java | 40 ++++ .../epmet/service/impl/DemandServiceImpl.java | 184 ++++++++++++++++++ .../service/stats/DemandStatsService.java | 18 ++ .../stats/impl/DemandStatsServiceImpl.java | 36 ++++ .../com/epmet/service/user/UserService.java | 2 + .../service/user/impl/UserServiceImpl.java | 4 + ...0.0.26__create_volunteer_service_daily.sql | 21 ++ .../mapper/heart/IcUserDemandServiceDao.xml | 33 ++++ .../mapper/heart/VolunteerInfoDao.xml | 23 +++ .../stats/FactVolunteerServiceDailyDao.xml | 37 ++++ .../main/resources/mapper/user/UserDao.xml | 13 ++ 24 files changed, 907 insertions(+) create mode 100644 epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/heart/result/DemandServiceCountResultDTO.java create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemandController.java create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/heart/IcUserDemandServiceDao.java create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/heart/VolunteerInfoDao.java create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactVolunteerServiceDailyDao.java create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/heart/IcUserDemandServiceEntity.java create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/heart/VolunteerInfoEntity.java create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/stats/FactVolunteerServiceDailyEntity.java create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/DemandService.java create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/heart/HeartDemandService.java create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/heart/HeartVolunteerService.java create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/heart/impl/HeartDemandServiceImpl.java create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/heart/impl/HeartVolunteerServiceImpl.java create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/DemandServiceImpl.java create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DemandStatsService.java create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DemandStatsServiceImpl.java create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/resources/db/migration/V0.0.26__create_volunteer_service_daily.sql create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/heart/IcUserDemandServiceDao.xml create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/heart/VolunteerInfoDao.xml create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactVolunteerServiceDailyDao.xml diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/heart/result/DemandServiceCountResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/heart/result/DemandServiceCountResultDTO.java new file mode 100644 index 0000000000..57cc894ae4 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/heart/result/DemandServiceCountResultDTO.java @@ -0,0 +1,15 @@ +package com.epmet.dto.heart.result; + +import lombok.Data; + +/** + * @Description 描述 + * @Author wangxianzhang + * @Date 2021/12/8 4:39 下午 + * @Version 1.0 + */ +@Data +public class DemandServiceCountResultDTO { + private String serverId; + private String serviceType; +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemandController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemandController.java new file mode 100644 index 0000000000..cd77d2b25a --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemandController.java @@ -0,0 +1,38 @@ +package com.epmet.controller; + +import com.epmet.commons.tools.utils.Result; +import com.epmet.service.DemandService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +/** + * @Description 描述 + * @Author wangxianzhang + * @Date 2021/12/8 10:44 上午 + * @Version 1.0 + */ +@RestController +@RequestMapping("demand") +public class DemandController { + + @Autowired + private DemandService demandStatsService; + + /** + * wangxianzhang + * + * 计算客户下志愿者服务相关数据 + * + * @param customerId 客户ID,可以为空,为空则计算所有客户 + * @return + */ + @PostMapping("volunteer/daily") + public Result statsVolunteerDemandServicesDaily(@RequestParam(value = "customer-id", required = false) String customerId) { + + demandStatsService.statsVolunteerDemandServicesDaily(customerId); + + return new Result(); + } + + +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/heart/IcUserDemandServiceDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/heart/IcUserDemandServiceDao.java new file mode 100644 index 0000000000..602c04da5e --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/heart/IcUserDemandServiceDao.java @@ -0,0 +1,44 @@ +/** + * 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.dao.heart; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.heart.result.DemandServiceCountResultDTO; +import com.epmet.entity.heart.IcUserDemandServiceEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.Date; +import java.util.List; + +/** + * 居民需求服务记录表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-11-19 + */ +@Mapper +public interface IcUserDemandServiceDao extends BaseDao { + + /** + * 需求服务次数查询 + * @param customerId 客户id + * @param serviceType 服务者类型 + */ + List listDemandServiceCountPage(@Param("customerId") String customerId, @Param("endTime") Date endTime, @Param("serviceType") String serviceType); +} \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/heart/VolunteerInfoDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/heart/VolunteerInfoDao.java new file mode 100644 index 0000000000..11b5aad534 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/heart/VolunteerInfoDao.java @@ -0,0 +1,33 @@ +/** + * 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.dao.heart; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.heart.VolunteerInfoEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 志愿者信息 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-12-08 + */ +@Mapper +public interface VolunteerInfoDao extends BaseDao { + +} \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactVolunteerServiceDailyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactVolunteerServiceDailyDao.java new file mode 100644 index 0000000000..605364c820 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactVolunteerServiceDailyDao.java @@ -0,0 +1,42 @@ +/** + * 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.dao.stats; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.stats.FactVolunteerServiceDailyEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 志愿者服务情况统计 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-12-08 + */ +@Mapper +public interface FactVolunteerServiceDailyDao extends BaseDao { + + /** + * 删除指定客户,指定dateId的志愿者服务统计记录 + * @param customerIds + * @param dateDimId + */ + void clearVolunteerDemandServiceDailyStats(@Param("customerIds") List customerIds, @Param("dateDimId") String dateDimId); +} \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/user/UserDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/user/UserDao.java index 2c8f46ea9b..584bfdf64c 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/user/UserDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/user/UserDao.java @@ -264,5 +264,7 @@ public interface UserDao { List getPatrolRecordList(MidPatrolFormDTO formDTO); List getPatrolDetailList(MidPatrolFormDTO formDTO); + + List filterUserIds(@Param("userIds") List userIds, @Param("roleKey") String roleKey); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/heart/IcUserDemandServiceEntity.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/heart/IcUserDemandServiceEntity.java new file mode 100644 index 0000000000..002b1db875 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/heart/IcUserDemandServiceEntity.java @@ -0,0 +1,75 @@ +/** + * 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.entity.heart; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 居民需求服务记录表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-11-19 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("ic_user_demand_service") +public class IcUserDemandServiceEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户id + */ + private String customerId; + + /** + * 需求id + */ + private String demandRecId; + + /** + * 服务方类型:志愿者:volunteer;社会组织:social_org;社区自组织:community_org;区域党建单位:party_unit; + */ + private String serviceType; + + /** + * 志愿者:居民端爱心互助的志愿者userId; + */ + private String serverId; + + /** + * 实际服务开始时间 + */ + private Date serviceStartTime; + + /** + * 实际服务结束时间 + */ + private Date serviceEndTime; + + /** + * 完成情况 + */ + private String finishDesc; + +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/heart/VolunteerInfoEntity.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/heart/VolunteerInfoEntity.java new file mode 100644 index 0000000000..60f41bd0fa --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/heart/VolunteerInfoEntity.java @@ -0,0 +1,71 @@ +/** + * 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.entity.heart; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 志愿者信息 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-12-08 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("volunteer_info") +public class VolunteerInfoEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 用户id + */ + private String userId; + + /** + * 客户id + */ + private String customerId; + + /** + * 志愿者自我介绍 + */ + private String volunteerIntroduce; + + /** + * 志愿者签名 + */ + private String volunteerSignature; + + /** + * 网格id + */ + private String gridId; + + /** + * 网格名称 + */ + private String gridName; + +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/stats/FactVolunteerServiceDailyEntity.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/stats/FactVolunteerServiceDailyEntity.java new file mode 100644 index 0000000000..f2b473bfe9 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/stats/FactVolunteerServiceDailyEntity.java @@ -0,0 +1,86 @@ +/** + * 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.entity.stats; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 志愿者服务情况统计 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-12-08 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("fact_volunteer_service_daily") +public class FactVolunteerServiceDailyEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户id + */ + private String customerId; + + /** + * yyyyMMdd + */ + private String dateId; + + /** + * yyyyMM + */ + private String monthId; + + /** + * 截止到当前dateId,当前客户下,共有多少个爱心互助的志愿者 + */ + private Integer volunteerTotal; + + /** + * 截止到当前dateId,当前客户下,XX个爱心互助志愿者中,党员有多少个 + */ + private Integer partyTotal; + + /** + * 截止到当前dateId,当前客户下,XX个爱心互助志愿者中,居民有多少个 + */ + private Integer resiTotal; + + /** + * 服务总次数 + */ + private Integer serviceTotal; + + /** + * 党员服务总次数 + */ + private Integer partyServiceTotal; + + /** + * 居民服务总次数 + */ + private Integer resiServiceTotal; + +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/DemandService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/DemandService.java new file mode 100644 index 0000000000..a5baf1a613 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/DemandService.java @@ -0,0 +1,20 @@ +package com.epmet.service; + +/** + * @Description 需求service + * @Author wangxianzhang + * @Date 2021/12/8 12:14 下午 + * @Version 1.0 + */ +public interface DemandService { + + /** + * wangxianzhang + * + * 按日统计 + * + * @param customerId 客户ID,可为空,为空计算所有 + */ + void statsVolunteerDemandServicesDaily(String customerId); + +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/heart/HeartDemandService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/heart/HeartDemandService.java new file mode 100644 index 0000000000..1a106fa881 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/heart/HeartDemandService.java @@ -0,0 +1,15 @@ +package com.epmet.service.heart; + +import com.epmet.dto.heart.result.DemandServiceCountResultDTO; + +import java.util.Date; +import java.util.List; + +/** + *@Description 爱心互助,需求service + *@Author wangxianzhang + *@Date 2021/12/8 + */ +public interface HeartDemandService { + List listDemandServiceCountPage(String customerId, Date endTime, int serviceCountPageNo, int serviceCountPageSize); +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/heart/HeartVolunteerService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/heart/HeartVolunteerService.java new file mode 100644 index 0000000000..abccaae1e6 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/heart/HeartVolunteerService.java @@ -0,0 +1,15 @@ +package com.epmet.service.heart; + +import com.epmet.entity.heart.VolunteerInfoEntity; + +import java.util.Date; +import java.util.List; + +/** + *@Description heart 志愿者service + *@Author wangxianzhang + *@Date 2021/12/8 + */ +public interface HeartVolunteerService { + List listVolunteersPage(String customerId, Date endCreateTime, Integer pageNum, Integer pageSize); +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/heart/impl/HeartDemandServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/heart/impl/HeartDemandServiceImpl.java new file mode 100644 index 0000000000..a4192fcd30 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/heart/impl/HeartDemandServiceImpl.java @@ -0,0 +1,40 @@ +package com.epmet.service.heart.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.epmet.commons.dynamic.datasource.annotation.DataSource; +import com.epmet.constant.DataSourceConstant; +import com.epmet.dao.heart.IcUserDemandServiceDao; +import com.epmet.dto.heart.result.DemandServiceCountResultDTO; +import com.epmet.service.heart.HeartDemandService; +import com.github.pagehelper.ISelect; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Date; +import java.util.List; + +/** + * @Description 爱心互助,需求service + * @Author wangxianzhang + * @Date 2021/12/8 12:33 下午 + * @Version 1.0 + */ +@Service +@DataSource(DataSourceConstant.EPMET_HEART) +public class HeartDemandServiceImpl implements HeartDemandService { + + @Autowired + private IcUserDemandServiceDao demandServiceDao; + + @Override + public List listDemandServiceCountPage(String customerId, Date endTime, int serviceCountPageNo, int serviceCountPageSize) { + return PageHelper.startPage(serviceCountPageNo, serviceCountPageSize).doSelectPage(new ISelect() { + @Override + public void doSelect() { + demandServiceDao.listDemandServiceCountPage(customerId, endTime, "volunteer"); + } + }); + } +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/heart/impl/HeartVolunteerServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/heart/impl/HeartVolunteerServiceImpl.java new file mode 100644 index 0000000000..c95fd094fe --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/heart/impl/HeartVolunteerServiceImpl.java @@ -0,0 +1,40 @@ +package com.epmet.service.heart.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.epmet.commons.dynamic.datasource.annotation.DataSource; +import com.epmet.constant.DataSourceConstant; +import com.epmet.dao.heart.VolunteerInfoDao; +import com.epmet.entity.heart.VolunteerInfoEntity; +import com.epmet.service.heart.HeartVolunteerService; +import com.github.pagehelper.ISelect; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Date; +import java.util.List; + +/** + * @Description 描述 + * @Author wangxianzhang + * @Date 2021/12/8 1:35 下午 + * @Version 1.0 + */ +@Service +@DataSource(DataSourceConstant.EPMET_HEART) +public class HeartVolunteerServiceImpl implements HeartVolunteerService { + + @Autowired + private VolunteerInfoDao volunteerInfoDao; + + @Override + public List listVolunteersPage(String customerId, Date endCreateTime, Integer pageNum, Integer pageSize) { + return PageHelper.startPage(pageNum, pageSize).doSelectPage(() -> { + LambdaQueryWrapper query = new LambdaQueryWrapper<>(); + query.eq(VolunteerInfoEntity::getCustomerId, customerId); + query.lt(VolunteerInfoEntity::getCreatedTime, endCreateTime); + volunteerInfoDao.selectList(query); + }); + } +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/DemandServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/DemandServiceImpl.java new file mode 100644 index 0000000000..7782226923 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/DemandServiceImpl.java @@ -0,0 +1,184 @@ +package com.epmet.service.impl; + +import com.epmet.commons.tools.constant.EpmetRoleKeyConstant; +import com.epmet.commons.tools.utils.DateUtils; +import com.epmet.dto.heart.result.DemandServiceCountResultDTO; +import com.epmet.entity.crm.CustomerEntity; +import com.epmet.entity.heart.VolunteerInfoEntity; +import com.epmet.entity.stats.FactVolunteerServiceDailyEntity; +import com.epmet.service.DemandService; +import com.epmet.service.crm.CustomerService; +import com.epmet.service.heart.HeartDemandService; +import com.epmet.service.heart.HeartVolunteerService; +import com.epmet.service.stats.DemandStatsService; +import com.epmet.service.user.UserService; +import com.epmet.util.DimIdGenerator; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * @Description 需求service + * @Author wangxianzhang + * @Date 2021/12/8 12:14 下午 + * @Version 1.0 + */ +@Service +public class DemandServiceImpl implements DemandService { + + @Autowired + private HeartDemandService heartDemandService; + + @Autowired + private HeartVolunteerService heartVolunteerService; + + @Autowired + private UserService userService; + + @Autowired + private DemandStatsService demandStatsService; + + @Autowired + private CustomerService customerService; + + @Override + public void statsVolunteerDemandServicesDaily(String customerId) { + + Date now = new Date(); + Date today = DateUtils.integrate(now, "yyyy-MM-dd"); + Date yestoday = DateUtils.addDateDays(today, -1); + + if (StringUtils.isNotBlank(customerId)) { + // 只计算单个客户 + clearOldDatas(Arrays.asList(customerId), yestoday); + statsVolunteerDemandServicesDaily4Customer(customerId, today, yestoday); + } else { + // 查询所有客户ID + List customerIds = customerService.listValidCustomersByCreateTime(null, null).stream().map(c -> c.getId()).collect(Collectors.toList()); + clearOldDatas(customerIds, yestoday); + customerIds.stream().forEach(cId -> { + statsVolunteerDemandServicesDaily4Customer(cId, today, yestoday); + }); + } + } + + /** + * 清理旧数据 + * @param yestoday + */ + private void clearOldDatas(List customerIds, Date yestoday) { + + String dateDimId = DimIdGenerator.getDateDimId(yestoday); + + demandStatsService.clearVolunteerDemandServiceDailyStats(customerIds, dateDimId); + + } + + /** + * 统计单个客户的志愿者服务情况 + * @param customerId 客户ID + * @param endTime 统计截止时间( partymemberVolunteerUserIds = new ArrayList<>(16); + + int pageNum = 1; + int volunteerPageSize = 5; + + while (true) { + + int shardingStartIndex = 0; + int shardingSize = 2; + + List volunteersPage = heartVolunteerService.listVolunteersPage(customerId, endTime, pageNum, volunteerPageSize); + + // 如果查询结果为0,说明没有更多的志愿者了 + if (volunteersPage.size() == 0) { + break; + } + + volunteerTotalCount += volunteersPage.size(); + + // 分片去确定党员身份 + while (true) { + int realShardingSize = Math.min(shardingSize, volunteersPage.size() - shardingStartIndex); + + if (realShardingSize == 0) { + break; + } + + int shardingEndIndex = shardingStartIndex + realShardingSize; + List volunteerUserIds = volunteersPage.subList(shardingStartIndex, shardingEndIndex) + .stream() + .map((volunteerInfoEntity) -> volunteerInfoEntity.getUserId()) + .collect(Collectors.toList()); + + List tempPartymemberUserIds = userService.filterUserIds(volunteerUserIds, EpmetRoleKeyConstant.PARTYMEMBER); + + partymemberVolunteerUserIds.addAll(tempPartymemberUserIds); + + shardingStartIndex = shardingEndIndex; + } + + pageNum++; + } + + partymemberVolunteerCount += partymemberVolunteerUserIds.size(); + resiVolunteerCount = volunteerTotalCount - partymemberVolunteerCount; + + //2. 查询志愿者服务次数 + + // 总服务次数 + int totalDemandServiceCount = 0; + // 党员服务次数 + int partymemberDemandServiceCount = 0; + // 居民服务次数 + int resiDemandServiceCount = 0; + + int serviceCountPageNo = 0; + int serviceCountPageSize = 1000; + while (true) { + + List damendServiceCounts = heartDemandService.listDemandServiceCountPage(customerId, endTime, serviceCountPageNo, serviceCountPageSize); + + for (DemandServiceCountResultDTO damendServiceCount : damendServiceCounts) { + String serverId = damendServiceCount.getServerId(); + if (partymemberVolunteerUserIds.contains(serverId)) { + partymemberDemandServiceCount++; + } else { + resiDemandServiceCount++; + } + } + + totalDemandServiceCount += damendServiceCounts.size(); + + if (damendServiceCounts.size() <= serviceCountPageSize) { + break; + } + } + + // 3.持久化 + FactVolunteerServiceDailyEntity insert = new FactVolunteerServiceDailyEntity(); + insert.setDateId(DimIdGenerator.getDateDimId(belongTime)); + insert.setCustomerId(customerId); + insert.setMonthId(DimIdGenerator.getMonthDimId(belongTime)); + insert.setPartyServiceTotal(partymemberDemandServiceCount); + insert.setServiceTotal(totalDemandServiceCount); + insert.setPartyTotal(partymemberVolunteerCount); + insert.setResiServiceTotal(resiDemandServiceCount); + insert.setResiTotal(resiVolunteerCount); + insert.setVolunteerTotal(volunteerTotalCount); + + demandStatsService.addVolunteerServiceDaily(insert); + } +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DemandStatsService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DemandStatsService.java new file mode 100644 index 0000000000..dec4ed26ef --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DemandStatsService.java @@ -0,0 +1,18 @@ +package com.epmet.service.stats; + +import com.epmet.entity.stats.FactVolunteerServiceDailyEntity; + +import java.util.List; + +/** + *@Description 统计客户下的志愿者需求服务数据 + *@Author wangxianzhang + *@Date 2021/12/8 + */ +public interface DemandStatsService { + + + void addVolunteerServiceDaily(FactVolunteerServiceDailyEntity entity); + + void clearVolunteerDemandServiceDailyStats(List customerIds, String dateDimId); +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DemandStatsServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DemandStatsServiceImpl.java new file mode 100644 index 0000000000..54a8525877 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DemandStatsServiceImpl.java @@ -0,0 +1,36 @@ +package com.epmet.service.stats.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.epmet.commons.dynamic.datasource.annotation.DataSource; +import com.epmet.constant.DataSourceConstant; +import com.epmet.dao.stats.FactVolunteerServiceDailyDao; +import com.epmet.entity.stats.FactVolunteerServiceDailyEntity; +import com.epmet.service.stats.DemandStatsService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * @Description 描述 + * @Author wangxianzhang + * @Date 2021/12/8 10:54 上午 + * @Version 1.0 + */ +@Service +@DataSource(DataSourceConstant.STATS) +public class DemandStatsServiceImpl implements DemandStatsService { + + @Autowired + private FactVolunteerServiceDailyDao factVolunteerServiceDailyDao; + + @Override + public void addVolunteerServiceDaily(FactVolunteerServiceDailyEntity entity) { + factVolunteerServiceDailyDao.insert(entity); + } + + @Override + public void clearVolunteerDemandServiceDailyStats(List customerIds, String dateDimId) { + factVolunteerServiceDailyDao.clearVolunteerDemandServiceDailyStats(customerIds, dateDimId); + } +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/UserService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/UserService.java index ffa464d4fa..1d0a500b0a 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/UserService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/UserService.java @@ -146,4 +146,6 @@ public interface UserService { List getPatrolRecordList(MidPatrolFormDTO formDTO); List getPatrolDetailList(MidPatrolFormDTO formDTO); + + List filterUserIds(List userIds, String roleKey); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/UserServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/UserServiceImpl.java index a8bf95d7f0..a2d56125a6 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/UserServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/UserServiceImpl.java @@ -1109,4 +1109,8 @@ public class UserServiceImpl implements UserService { return userDao.getPatrolDetailList(formDTO); } + @Override + public List filterUserIds(List userIds, String roleKey) { + return userDao.filterUserIds(userIds, roleKey); + } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/db/migration/V0.0.26__create_volunteer_service_daily.sql b/epmet-module/data-statistical/data-statistical-server/src/main/resources/db/migration/V0.0.26__create_volunteer_service_daily.sql new file mode 100644 index 0000000000..7eade2a679 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/db/migration/V0.0.26__create_volunteer_service_daily.sql @@ -0,0 +1,21 @@ +CREATE TABLE epmet_data_statistical.`fact_volunteer_service_daily` +( + `ID` varchar(64) NOT NULL COMMENT '主键', + `CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户id', + `DATE_ID` varchar(8) NOT NULL COMMENT 'yyyyMMdd', + `MONTH_ID` varchar(6) NOT NULL COMMENT 'yyyyMM', + `VOLUNTEER_TOTAL` int(11) NOT NULL COMMENT '截止到当前dateId,当前客户下,共有多少个爱心互助的志愿者', + `PARTY_TOTAL` int(11) NOT NULL COMMENT '截止到当前dateId,当前客户下,XX个爱心互助志愿者中,党员有多少个', + `RESI_TOTAL` int(11) NOT NULL COMMENT '截止到当前dateId,当前客户下,XX个爱心互助志愿者中,居民有多少个', + `SERVICE_TOTAL` int(11) NOT NULL COMMENT '服务总次数', + `PARTY_SERVICE_TOTAL` int(11) NOT NULL COMMENT '党员服务总次数', + `RESI_SERVICE_TOTAL` int(11) NOT NULL COMMENT '居民服务总次数', + `DEL_FLAG` int(11) NOT NULL COMMENT '删除标识:0.未删除 1.已删除', + `REVISION` int(11) NOT NULL COMMENT '乐观锁', + `CREATED_BY` varchar(32) NOT NULL COMMENT '创建人', + `CREATED_TIME` datetime NOT NULL COMMENT '创建时间', + `UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人', + `UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', + PRIMARY KEY (`ID`), + UNIQUE KEY `uni_vsd` (`CUSTOMER_ID`,`DATE_ID`,`DEL_FLAG`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='志愿者服务情况统计' \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/heart/IcUserDemandServiceDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/heart/IcUserDemandServiceDao.xml new file mode 100644 index 0000000000..1c13f56e87 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/heart/IcUserDemandServiceDao.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/heart/VolunteerInfoDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/heart/VolunteerInfoDao.xml new file mode 100644 index 0000000000..a426712a22 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/heart/VolunteerInfoDao.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactVolunteerServiceDailyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactVolunteerServiceDailyDao.xml new file mode 100644 index 0000000000..59dfd96c12 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactVolunteerServiceDailyDao.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + delete + from fact_volunteer_service_daily + where DATE_ID=#{dateDimId} + and CUSTOMER_ID in + + #{customerId} + + + + + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/UserDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/UserDao.xml index 4715f23c2a..6542440fb8 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/UserDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/UserDao.xml @@ -1052,5 +1052,18 @@ order by created_time LIMIT #{offset},#{pageSize} + + + From 48e64d6161cdc6886780d8aefccac6d1909eff02 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Fri, 10 Dec 2021 15:55:26 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=86=E7=B1=BB?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/dto/result/ResiBuzzDTO.java | 13 ++++++-- .../result/ResiBuzzLeftPieChartResultDTO.java | 2 ++ .../src/main/java/com/epmet/dao/IssueDao.java | 2 +- .../epmet/service/impl/IssueServiceImpl.java | 3 +- .../src/main/resources/mapper/IssueDao.xml | 33 ++++++++++++++----- 5 files changed, 41 insertions(+), 12 deletions(-) diff --git a/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/result/ResiBuzzDTO.java b/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/result/ResiBuzzDTO.java index 72da12a996..c2c0960c0a 100644 --- a/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/result/ResiBuzzDTO.java +++ b/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/result/ResiBuzzDTO.java @@ -5,6 +5,8 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Data; import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; /** * @Author zxc @@ -72,7 +74,7 @@ public class ResiBuzzDTO implements Serializable { /** * 分类名字 */ - private String categoryName; + private List categoryName; public ResiBuzzDTO() { this.createdBy = ""; @@ -86,6 +88,13 @@ public class ResiBuzzDTO implements Serializable { this.oppositionCount = NumConstant.ZERO; this.voteAccount = ""; this.issueOriginator = ""; - this.categoryName = "其他"; + this.categoryName = getDefaultCategoryName(); + } + + @JsonIgnore + public List getDefaultCategoryName(){ + List list = new ArrayList<>(); + list.add("其他"); + return list; } } diff --git a/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/result/ResiBuzzLeftPieChartResultDTO.java b/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/result/ResiBuzzLeftPieChartResultDTO.java index 7349b7967b..c55641f333 100644 --- a/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/result/ResiBuzzLeftPieChartResultDTO.java +++ b/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/result/ResiBuzzLeftPieChartResultDTO.java @@ -1,6 +1,7 @@ package com.epmet.dto.result; import com.epmet.commons.tools.constant.NumConstant; +import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Data; import java.io.Serializable; @@ -23,6 +24,7 @@ public class ResiBuzzLeftPieChartResultDTO implements Serializable { /** * 分类编码 */ + @JsonIgnore private String categoryCode; /** diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueDao.java b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueDao.java index d81143c74c..a853364839 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueDao.java +++ b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueDao.java @@ -234,7 +234,7 @@ public interface IssueDao extends BaseDao { * @author zxc * @date 2021/12/8 4:08 下午 */ - List selectIssueLimit50(@Param("orgId")String orgId,@Param("orgType")String orgType,@Param("status")String status); + List selectIssueLimit50(@Param("orgId")String orgId,@Param("orgType")String orgType,@Param("status")String status,@Param("length")Integer length); /** * @Description 查询客户下1级分类的长度 diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueServiceImpl.java b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueServiceImpl.java index 3111b567b0..4e7a09fd26 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueServiceImpl.java +++ b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueServiceImpl.java @@ -1586,7 +1586,8 @@ public class IssueServiceImpl extends BaseServiceImpl imp formDTO.setOrgId(staffInfo.getAgencyId()); formDTO.setOrgType(IssueConstant.ISSUE_AGENCY); } - PageInfo pageInfo = PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize()).doSelectPageInfo(() -> baseDao.selectIssueLimit50(formDTO.getOrgId(), formDTO.getOrgType(), formDTO.getStatus())); + Integer length = baseDao.selectOneLevelCategoryLength(tokenDto.getCustomerId()); + PageInfo pageInfo = PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize()).doSelectPageInfo(() -> baseDao.selectIssueLimit50(formDTO.getOrgId(), formDTO.getOrgType(), formDTO.getStatus(),length)); List list = pageInfo.getList(); if (CollectionUtils.isEmpty(list)){ return new ResiBuzzResultDTO(); diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueDao.xml b/epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueDao.xml index 827f52b774..8a81f0ab47 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueDao.xml +++ b/epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueDao.xml @@ -579,22 +579,39 @@ - SELECT i.ID AS issueId, - i.ISSUE_TITLE, - i.SUGGESTION, - i.CREATED_BY, + i.ISSUE_TITLE AS issueTitle, + i.SUGGESTION AS suggestion, + i.CREATED_BY AS createdBy, (CASE WHEN i.ISSUE_STATUS = 'shift_project' THEN '已转项目' WHEN i.ISSUE_STATUS = 'voting' THEN '表决中' WHEN i.ISSUE_STATUS = 'closed' THEN '已关闭' ELSE '表决中' END ) AS `status`, - i.CREATED_TIME, - s.SUPPORT_COUNT, - s.OPPOSITION_COUNT, - CONCAT(s.SUPPORT_COUNT + s.OPPOSITION_COUNT,'/',s.VOTABLE_COUNT) AS voteAccount + i.CREATED_TIME AS createdTime, + s.SUPPORT_COUNT AS supportCount, + s.OPPOSITION_COUNT AS oppositionCount, + CONCAT(s.SUPPORT_COUNT + s.OPPOSITION_COUNT,'/',s.VOTABLE_COUNT) AS voteAccount, + cd.CATEGORY_NAME as cn FROM issue i LEFT JOIN issue_vote_statistical s ON (s.ISSUE_ID = i.ID AND s.DEL_FLAG = '0') + LEFT JOIN issue_category ic ON (ic.ISSUE_ID = i.ID AND ic.DEL_FLAG = '0' AND ic.CUSTOMER_ID = i.CUSTOMER_ID) + LEFT JOIN issue_project_category_dict cd ON (cd.CATEGORY_CODE = LEFT(ic.CATEGORY_CODE,#{length}) AND cd.DEL_FLAG = '0' AND cd.CUSTOMER_ID = ic.CUSTOMER_ID) WHERE i.DEL_FLAG = '0' AND i.ISSUE_STATUS = #{status} From 200d2849c8c1c537cb5b3a3db5ad5b3c99f50081 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Fri, 10 Dec 2021 16:34:56 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/epmet/service/impl/ProjectServiceImpl.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java index 59e08ee55a..22cceba501 100644 --- a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java +++ b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java @@ -2878,9 +2878,10 @@ public class ProjectServiceImpl extends BaseServiceImpl allCount = orgList.stream().map(m -> m.getCount()).collect(Collectors.toList()); Integer max = Collections.max(allCount); Integer min = Collections.min(allCount); From e331619802ffbbe7339a25c6456b229006a02e4f Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Fri, 10 Dec 2021 16:46:54 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E5=AD=97=E6=AE=B5=E8=A1=A5=E5=85=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/dto/issue/IssueProjectCategoryDictDTO.java | 5 +++++ .../epmet/entity/issue/IssueProjectCategoryDictEntity.java | 5 +++++ .../main/java/com/epmet/dto/IssueProjectCategoryDictDTO.java | 5 +++++ .../com/epmet/entity/IssueProjectCategoryDictEntity.java | 5 +++++ 4 files changed, 20 insertions(+) diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/issue/IssueProjectCategoryDictDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/issue/IssueProjectCategoryDictDTO.java index c07037ee92..d99c772f8b 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/issue/IssueProjectCategoryDictDTO.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/issue/IssueProjectCategoryDictDTO.java @@ -113,4 +113,9 @@ public class IssueProjectCategoryDictDTO implements Serializable { */ private Date updatedTime; + /** + * 颜色 + */ + private String colour; + } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/issue/IssueProjectCategoryDictEntity.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/issue/IssueProjectCategoryDictEntity.java index 67c82fee00..a029bb6f00 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/issue/IssueProjectCategoryDictEntity.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/issue/IssueProjectCategoryDictEntity.java @@ -80,4 +80,9 @@ public class IssueProjectCategoryDictEntity extends BaseEpmetEntity { */ private String isDisable; + /** + * 颜色 + */ + private String colour; + } diff --git a/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/IssueProjectCategoryDictDTO.java b/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/IssueProjectCategoryDictDTO.java index a93a616cbf..83920372a1 100644 --- a/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/IssueProjectCategoryDictDTO.java +++ b/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/IssueProjectCategoryDictDTO.java @@ -113,4 +113,9 @@ public class IssueProjectCategoryDictDTO implements Serializable { */ private Date updatedTime; + /** + * 颜色 + */ + private String colour; + } \ No newline at end of file diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/entity/IssueProjectCategoryDictEntity.java b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/entity/IssueProjectCategoryDictEntity.java index b99f37a2bf..7481f4f4ed 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/entity/IssueProjectCategoryDictEntity.java +++ b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/entity/IssueProjectCategoryDictEntity.java @@ -83,4 +83,9 @@ public class IssueProjectCategoryDictEntity extends BaseEpmetEntity { */ private String isDisable; + /** + * 颜色 + */ + private String colour; + } From 2536b86b3ff29982a18ab5f4b9fd04e3308449d9 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Fri, 10 Dec 2021 17:12:37 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProjectDistributionAnalysisRightResultDTO.java | 13 ++++--------- .../com/epmet/service/impl/ProjectServiceImpl.java | 11 ++++------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/result/ProjectDistributionAnalysisRightResultDTO.java b/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/result/ProjectDistributionAnalysisRightResultDTO.java index 5b52084e9d..fb56a9f178 100644 --- a/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/result/ProjectDistributionAnalysisRightResultDTO.java +++ b/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/result/ProjectDistributionAnalysisRightResultDTO.java @@ -19,23 +19,18 @@ public class ProjectDistributionAnalysisRightResultDTO implements Serializable { /** * ..以上 */ - private String under; + private Integer under; - /** - * 中间区间 - */ - private String middle; /** * ..以下 */ - private String above; + private Integer above; private List list; public ProjectDistributionAnalysisRightResultDTO() { - this.under = ""; - this.middle = ""; - this.above = ""; + this.under = null; + this.above = null; this.list = new ArrayList<>(); } } diff --git a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java index 22cceba501..13b710ec7f 100644 --- a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java +++ b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java @@ -2830,7 +2830,7 @@ public class ProjectServiceImpl extends BaseServiceImpl Date: Fri, 10 Dec 2021 18:02:44 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E7=A4=BE=E5=8C=BA=E5=85=9A=E5=BB=BA?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=88=86=E6=9E=90-=E5=85=9A=E5=91=98?= =?UTF-8?q?=E7=9B=B8=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../commons/tools/enums/DictTypeEnum.java | 3 +- .../service/impl/IcPartyUnitServiceImpl.java | 10 +- .../dto/form/PartyMemberListFormDTO.java | 24 ++++ .../form/PartyMemberStatisticsFormDTO.java | 20 +++ .../dto/result/PartyMemberAgeResultDTO.java | 19 +++ .../result/PartyMemberEducationResultDTO.java | 19 +++ .../controller/IcResiUserController.java | 53 ++++++++ .../java/com/epmet/dao/IcResiUserDao.java | 47 +++++++ .../com/epmet/service/IcResiUserService.java | 37 +++++ .../service/impl/IcResiUserServiceImpl.java | 117 ++++++++++++++-- .../main/resources/mapper/IcResiUserDao.xml | 128 ++++++++++++++++++ 11 files changed, 467 insertions(+), 10 deletions(-) create mode 100644 epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/PartyMemberListFormDTO.java create mode 100644 epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/PartyMemberStatisticsFormDTO.java create mode 100644 epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/PartyMemberAgeResultDTO.java create mode 100644 epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/PartyMemberEducationResultDTO.java diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/DictTypeEnum.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/DictTypeEnum.java index 478e7d4376..e1fa6b1456 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/DictTypeEnum.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/DictTypeEnum.java @@ -18,7 +18,8 @@ public enum DictTypeEnum { GENDER("gender", "性别", 8), USER_DEMAND_STATUS("user_demand_status", "居民需求状态",8), USER_DEMAND_REPORT_TYPE("user_demand_report_type","居民需求上报类型",9), - USER_DEMAND_SERVICE_TYPE("user_demand_service_type","居民需求服务方类型",10) + USER_DEMAND_SERVICE_TYPE("user_demand_service_type","居民需求服务方类型",10), + AGE_GROUP("age_group", "年龄范围", 11), ; private final String code; diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPartyUnitServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPartyUnitServiceImpl.java index 336c60f7be..10aa4239a9 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPartyUnitServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPartyUnitServiceImpl.java @@ -415,7 +415,15 @@ public class IcPartyUnitServiceImpl extends BaseServiceImpl distribution(PartyActivityFormDTO formDTO) { - return baseDao.getDistribution(formDTO.getAgencyId()); + Result> unitTypeMap = epmetAdminOpenFeignClient.dictMap(DictTypeEnum.PARTY_UNIT_TYPE.getCode()); + List list = baseDao.getDistribution(formDTO.getAgencyId()); + if (CollectionUtils.isEmpty(list)) { + return Collections.emptyList(); + } + list.forEach(item -> { + item.setType(unitTypeMap.getData().get(item.getType())); + }); + return list; } private String getServiceMatter(Map map, String matter) { diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/PartyMemberListFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/PartyMemberListFormDTO.java new file mode 100644 index 0000000000..a6ffad6477 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/PartyMemberListFormDTO.java @@ -0,0 +1,24 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Description + * @Author zhaoqifeng + * @Date 2021/12/10 15:49 + */ +@Data +public class PartyMemberListFormDTO implements Serializable { + + private static final long serialVersionUID = -6085134769034337175L; + @NotBlank(message = "组织类型不能为空") + private String orgType; + @NotBlank(message = "组织ID不能为空") + private String orgId; + private String code; + private Integer pageNo = 1; + private Integer pageSize = 20; +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/PartyMemberStatisticsFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/PartyMemberStatisticsFormDTO.java new file mode 100644 index 0000000000..a5bb86915f --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/PartyMemberStatisticsFormDTO.java @@ -0,0 +1,20 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Description + * @Author zhaoqifeng + * @Date 2021/12/10 15:46 + */ +@Data +public class PartyMemberStatisticsFormDTO implements Serializable { + private static final long serialVersionUID = 1027174449735636944L; + @NotBlank(message = "组织类型不能为空") + private String orgType; + @NotBlank(message = "组织ID不能为空") + private String orgId; +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/PartyMemberAgeResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/PartyMemberAgeResultDTO.java new file mode 100644 index 0000000000..85b0ced524 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/PartyMemberAgeResultDTO.java @@ -0,0 +1,19 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Description + * @Author zhaoqifeng + * @Date 2021/12/10 17:05 + */ +@Data +public class PartyMemberAgeResultDTO implements Serializable { + private static final long serialVersionUID = 3421162784157903637L; + private String userId; + private String name; + private String age; + private String mobile; +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/PartyMemberEducationResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/PartyMemberEducationResultDTO.java new file mode 100644 index 0000000000..421d0139a3 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/PartyMemberEducationResultDTO.java @@ -0,0 +1,19 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Description + * @Author zhaoqifeng + * @Date 2021/12/10 17:07 + */ +@Data +public class PartyMemberEducationResultDTO implements Serializable { + private static final long serialVersionUID = -5042362121277863249L; + private String userId; + private String name; + private String education; + private String mobile; +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java index 5c76d8e578..aa88bf73ab 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java @@ -27,6 +27,7 @@ import com.epmet.commons.tools.aop.NoRepeatSubmit; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; +import com.epmet.commons.tools.dto.result.OptionDataResultDTO; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.ExceptionUtils; import com.epmet.commons.tools.exception.RenException; @@ -505,4 +506,56 @@ public class IcResiUserController { ValidatorUtils.validateEntity(formDTO, DemandUserFormDTO.InternalGroup.class); return new Result>().ok(icResiUserService.queryDemandUsers(formDTO)); } + + /** + * 党员年龄范围统计 + * @Param formDTO + * @Return {@link Result< List< OptionDataResultDTO >>} + * @Author zhaoqifeng + * @Date 2021/12/10 15:52 + */ + @PostMapping("partymemberagestatistics") + public Result> partyMemberAgeStatistics(@RequestBody PartyMemberStatisticsFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO); + return new Result>().ok(icResiUserService.partyMemberAgeStatistics(formDTO)); + } + + /** + * 党员年龄列表 + * @Param formDTO + * @Return {@link Result< PageData< PartyMemberEducationResultDTO>>} + * @Author zhaoqifeng + * @Date 2021/12/10 17:54 + */ + @PostMapping("partymemberagelist") + public Result> partyMemberAgelist(@RequestBody PartyMemberListFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO); + return new Result>().ok(icResiUserService.getPartyMemberAgeList(formDTO)); + } + + /** + * 党员学历统计 + * @Param formDTO + * @Return {@link Result< List< OptionDataResultDTO>>} + * @Author zhaoqifeng + * @Date 2021/12/10 17:58 + */ + @PostMapping("partymembereducationstatistics") + public Result> partyMemberEducationStatistics(@RequestBody PartyMemberStatisticsFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO); + return new Result>().ok(icResiUserService.partyMemberEducationStatistics(formDTO)); + } + + /** + * 党员学历列表 + * @Param formDTO + * @Return {@link Result< PageData< PartyMemberEducationResultDTO>>} + * @Author zhaoqifeng + * @Date 2021/12/10 17:58 + */ + @PostMapping("partymembereducationlist") + public Result> partyMemberEducationlist(@RequestBody PartyMemberListFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO); + return new Result>().ok(icResiUserService.getPartyMemberEducationList(formDTO)); + } } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java index 09f467f6bf..c3f1da8654 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java @@ -18,6 +18,7 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.commons.tools.dto.result.OptionDataResultDTO; import com.epmet.dto.IcResiUserDTO; import com.epmet.dto.form.ResiUserQueryValueDTO; import com.epmet.dto.result.*; @@ -179,4 +180,50 @@ public interface IcResiUserDao extends BaseDao { * @return */ List selectListFamilyMember(@Param("currentIcResiUserId") String currentIcResiUserId, @Param("homeId") String homeId); + + /** + * 组织内党员年龄范围统计 + * @Param orgType + * @Param orgId + * @Return {@link List< OptionDataResultDTO>} + * @Author zhaoqifeng + * @Date 2021/12/10 17:11 + */ + List getPartyMemberAgeStatistics(@Param("orgType") String orgType, @Param("orgId") String orgId); + + /** + * 获取年龄范围内党员列表 + * @Param orgType + * @Param orgId + * @Param min + * @Param max + * @Return {@link List< PartyMemberAgeResultDTO>} + * @Author zhaoqifeng + * @Date 2021/12/10 17:11 + */ + List getPartyMemberAgeList(@Param("orgType") String orgType, @Param("orgId") String orgId, + @Param("code") String code); + + + /** + * 党员文化程度统计 + * @Param orgType + * @Param orgId + * @Return {@link List< OptionDataResultDTO>} + * @Author zhaoqifeng + * @Date 2021/12/10 17:29 + */ + List getPartyMemberEducationStatistics(@Param("orgType") String orgType, @Param("orgId") String orgId); + + /** + * 按教育程度获取党员列表 + * @Param orgType + * @Param orgId + * @Param code + * @Return {@link List< PartyMemberAgeResultDTO>} + * @Author zhaoqifeng + * @Date 2021/12/10 17:24 + */ + List getPartyMemberEducationList(@Param("orgType") String orgType, @Param("orgId") String orgId, + @Param("code") String code); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserService.java index 450ee74c70..db5ad290cf 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserService.java @@ -18,6 +18,7 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.dto.result.OptionDataResultDTO; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.dto.IcResiUserDTO; @@ -153,4 +154,40 @@ public interface IcResiUserService extends BaseService { IcResiUserDTO getByIdCard(String customerId, String idNum,String icResiUserId); IcResiUserBriefDTO findFamilyMem(String icResiUserId); + + /** + * 党员年龄范围统计 + * @Param formDTO + * @Return {@link List< OptionDataResultDTO >} + * @Author zhaoqifeng + * @Date 2021/12/10 15:54 + */ + List partyMemberAgeStatistics(PartyMemberStatisticsFormDTO formDTO); + + /** + * 获取年龄范围内党员列表 + * @Param formDTO + * @Return {@link PageData< PartyMemberAgeResultDTO>} + * @Author zhaoqifeng + * @Date 2021/12/10 17:40 + */ + PageData getPartyMemberAgeList(PartyMemberListFormDTO formDTO); + + /** + * 党员文化程度统计 + * @Param formDTO + * @Return {@link List< OptionDataResultDTO>} + * @Author zhaoqifeng + * @Date 2021/12/10 17:40 + */ + List partyMemberEducationStatistics(PartyMemberStatisticsFormDTO formDTO); + + /** + * 按教育程度获取党员列表 + * @Param formDTO + * @Return {@link PageData< PartyMemberEducationResultDTO>} + * @Author zhaoqifeng + * @Date 2021/12/10 17:40 + */ + PageData getPartyMemberEducationList(PartyMemberListFormDTO formDTO); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java index d045c08f3d..0a697f0093 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java @@ -25,11 +25,11 @@ import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.constant.StrConstant; +import com.epmet.commons.tools.dto.form.DictListFormDTO; import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; -import com.epmet.commons.tools.enums.FormItemTypeEnum; -import com.epmet.commons.tools.enums.GenderEnum; -import com.epmet.commons.tools.enums.HouseTypeEnum; -import com.epmet.commons.tools.enums.RelationshipEnum; +import com.epmet.commons.tools.dto.result.DictListResultDTO; +import com.epmet.commons.tools.dto.result.OptionDataResultDTO; +import com.epmet.commons.tools.enums.*; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.exception.RenException; @@ -54,10 +54,7 @@ import com.epmet.dto.form.demand.UserDemandNameQueryFormDTO; import com.epmet.dto.result.*; import com.epmet.entity.IcResiUserEntity; import com.epmet.excel.support.ExportResiUserItemDTO; -import com.epmet.feign.EpmetHeartOpenFeignClient; -import com.epmet.feign.EpmetMessageOpenFeignClient; -import com.epmet.feign.GovOrgOpenFeignClient; -import com.epmet.feign.OperCustomizeOpenFeignClient; +import com.epmet.feign.*; import com.epmet.service.IcResiUserService; import com.epmet.service.UserService; import com.github.pagehelper.Page; @@ -102,6 +99,8 @@ public class IcResiUserServiceImpl extends BaseServiceImpl getWrapper(Map params){ String id = (String)params.get(FieldConstant.ID_HUMP); @@ -883,4 +882,106 @@ public class IcResiUserServiceImpl extends BaseServiceImpl} + * @Author zhaoqifeng + * @Date 2021/12/10 15:54 + */ + @Override + public List partyMemberAgeStatistics(PartyMemberStatisticsFormDTO formDTO) { + //获取年龄范围字典 + DictListFormDTO dictFormDTO = new DictListFormDTO(); + dictFormDTO.setDictType(DictTypeEnum.AGE_GROUP.getCode()); + Result> dictResult = epmetAdminOpenFeignClient.dictList(dictFormDTO); + Map map = new HashMap<>(); + //统计组织下各年龄范围人数 + List list = baseDao.getPartyMemberAgeStatistics(formDTO.getOrgType(), formDTO.getOrgId()); + if (CollectionUtils.isNotEmpty(list)) { + map = list.stream().collect(Collectors.toMap(OptionDataResultDTO::getCode, OptionDataResultDTO::getValue)); + } + Map finalMap = map; + return dictResult.getData().stream().map(item -> { + OptionDataResultDTO dto = new OptionDataResultDTO(); + dto.setCode(item.getValue()); + dto.setLabel(item.getLabel()); + dto.setValue(null == finalMap.get(item.getValue())?NumConstant.ZERO_STR:finalMap.get(item.getValue())); + return dto; + }).collect(Collectors.toList()); + } + + /** + * 获取年龄范围内党员列表 + * + * @param formDTO + * @Param formDTO + * @Return {@link List< PartyMemberAgeResultDTO>} + * @Author zhaoqifeng + * @Date 2021/12/10 17:40 + */ + @Override + public PageData getPartyMemberAgeList(PartyMemberListFormDTO formDTO) { + PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize()); + List list = baseDao.getPartyMemberAgeList(formDTO.getOrgType(), formDTO.getOrgId(), formDTO.getCode()); + PageInfo pageInfo = new PageInfo<>(list); + return new PageData<>(list, pageInfo.getTotal()); + } + + /** + * 党员文化程度统计 + * + * @param formDTO + * @Param formDTO + * @Return {@link List< OptionDataResultDTO>} + * @Author zhaoqifeng + * @Date 2021/12/10 17:40 + */ + @Override + public List partyMemberEducationStatistics(PartyMemberStatisticsFormDTO formDTO) { + //获取文化程度字典 + DictListFormDTO dictFormDTO = new DictListFormDTO(); + dictFormDTO.setDictType(DictTypeEnum.EDUCATION.getCode()); + Result> dictResult = epmetAdminOpenFeignClient.dictList(dictFormDTO); + Map map = new HashMap<>(); + //统计组织下文化程度党员人数 + List list = baseDao.getPartyMemberEducationStatistics(formDTO.getOrgType(), formDTO.getOrgId()); + if (CollectionUtils.isNotEmpty(list)) { + map = list.stream().collect(Collectors.toMap(OptionDataResultDTO::getCode, OptionDataResultDTO::getValue)); + } + Map finalMap = map; + return dictResult.getData().stream().map(item -> { + OptionDataResultDTO dto = new OptionDataResultDTO(); + dto.setCode(item.getValue()); + dto.setLabel(item.getLabel()); + dto.setValue(null == finalMap.get(item.getValue())?NumConstant.ZERO_STR:finalMap.get(item.getValue())); + return dto; + }).collect(Collectors.toList()); + } + + /** + * 按教育程度获取党员列表 + * + * @param formDTO + * @Param formDTO + * @Return {@link List< PartyMemberEducationResultDTO>} + * @Author zhaoqifeng + * @Date 2021/12/10 17:40 + */ + @Override + public PageData getPartyMemberEducationList(PartyMemberListFormDTO formDTO) { + PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize()); + List list = baseDao.getPartyMemberEducationList(formDTO.getOrgType(), formDTO.getOrgId(), formDTO.getCode()); + Result> mapResult = epmetAdminOpenFeignClient.dictMap(DictTypeEnum.EDUCATION.getCode()); + PageInfo pageInfo = new PageInfo<>(list); + if (CollectionUtils.isNotEmpty(list)) { + list.forEach(item -> { + item.setEducation(null == mapResult.getData().get(item.getEducation()) ? "" : mapResult.getData().get(item.getEducation())); + }); + } + return new PageData<>(list, pageInfo.getTotal()); + } } diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml index 8414cf5e4b..b10e6e259f 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml @@ -361,4 +361,132 @@ and m.HOME_ID=#{homeId} order by m.CREATED_TIME asc + + + + + From 6185d0bb7274df6e70a4fe2105766552a91a1ba7 Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Sat, 11 Dec 2021 10:03:52 +0800 Subject: [PATCH 7/8] bugfix --- .../form/demand/CategoryAnalysisFormDTO.java | 42 +++++++++ .../result/demand/CategoryAnalysisDTO.java | 19 +++++ .../result/demand/CategoryAnalysisDetail.java | 32 +++++++ .../result/demand/CategoryAnalysisResDTO.java | 17 ++++ .../epmet/dto/result/demand/LegendDTO.java | 26 ++++++ .../controller/IcUserDemandRecController.java | 14 +++ .../com/epmet/dao/IcUserDemandRecDao.java | 11 +++ .../epmet/service/IcUserDemandRecService.java | 8 ++ .../impl/IcUserDemandRecServiceImpl.java | 85 +++++++++++++++++-- .../resources/mapper/IcUserDemandRecDao.xml | 22 +++++ 10 files changed, 269 insertions(+), 7 deletions(-) create mode 100644 epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/CategoryAnalysisFormDTO.java create mode 100644 epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/CategoryAnalysisDTO.java create mode 100644 epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/CategoryAnalysisDetail.java create mode 100644 epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/CategoryAnalysisResDTO.java create mode 100644 epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/LegendDTO.java diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/CategoryAnalysisFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/CategoryAnalysisFormDTO.java new file mode 100644 index 0000000000..f4e792f75e --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/CategoryAnalysisFormDTO.java @@ -0,0 +1,42 @@ +package com.epmet.dto.form.demand; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + + + +/** + * 服务措施分析-柱状图入参 + */ +@Data +public class CategoryAnalysisFormDTO implements Serializable { + + public interface AddUserInternalGroup { + } + + public interface AddUserShowGroup extends CustomerClientShowGroup { + } + + @NotBlank(message = "先选择组织或网格", groups = AddUserShowGroup.class) + private String orgId; + @NotBlank(message = "组织或网格的上级", groups = PageListAnalysisFormDTO.AddUserShowGroup.class) + private String pid; + @NotBlank(message = "组织:agency,网格:grid", groups = AddUserShowGroup.class) + private String orgType; + @NotBlank(message = "起止日期不能为空,格式yyyyMMdd", groups = AddUserShowGroup.class) + private String startDateId; + @NotBlank(message = "截止日期不能为空,格式yyyyMMdd", groups = AddUserShowGroup.class) + private String endDateId; + + @NotBlank(message = "先选择组织或网格", groups = AddUserInternalGroup.class) + private String cusotmerId; + + + /** + * orgType=agency时pid拼接上orgId + */ + private String gridPids; +} diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/CategoryAnalysisDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/CategoryAnalysisDTO.java new file mode 100644 index 0000000000..fc7a8eaad8 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/CategoryAnalysisDTO.java @@ -0,0 +1,19 @@ +package com.epmet.dto.result.demand; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class CategoryAnalysisDTO implements Serializable { + private static final long serialVersionUID = 3007202497989446585L; + private String categoryCode; + private String categoryName; + private Integer total; + private List detail; +} diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/CategoryAnalysisDetail.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/CategoryAnalysisDetail.java new file mode 100644 index 0000000000..c082d11074 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/CategoryAnalysisDetail.java @@ -0,0 +1,32 @@ +package com.epmet.dto.result.demand; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class CategoryAnalysisDetail implements Serializable { + private static final long serialVersionUID = -4606305611297470078L; + /** + * 区域党建单位:party_unit; + * 社会组织:social_org; + * 社区自组织:community_org; + * 志愿者:volunteer; + * 未完成:unfinished + */ + private String legendCode; + + /** + * 服务方类型名称 + */ + private String legendName; + + /** + * 服务方的个数 + */ + private Integer totalService; + /** + * 需求个数 + */ + private Integer serviceDemandTotal; +} diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/CategoryAnalysisResDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/CategoryAnalysisResDTO.java new file mode 100644 index 0000000000..1b39a2befd --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/CategoryAnalysisResDTO.java @@ -0,0 +1,17 @@ +package com.epmet.dto.result.demand; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class CategoryAnalysisResDTO implements Serializable { + private static final long serialVersionUID = -3112952115061180189L; + private List legend; + private List categoryList; +} diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/LegendDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/LegendDTO.java new file mode 100644 index 0000000000..e1f6c9b282 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/LegendDTO.java @@ -0,0 +1,26 @@ +package com.epmet.dto.result.demand; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * 服务措施分析-柱状图 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class LegendDTO implements Serializable { + private static final long serialVersionUID = 7205666632591639499L; + /** + * 区域党建单位:party_unit; + * 社会组织:social_org; + * 社区自组织:community_org; + * 志愿者:volunteer; + * 未完成:unfinished + */ + private String legendCode; + private String legendName; +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcUserDemandRecController.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcUserDemandRecController.java index 666243eee0..08a28e2f25 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcUserDemandRecController.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcUserDemandRecController.java @@ -257,4 +257,18 @@ public class IcUserDemandRecController { } return new Result(); } + + /** + * 数据分析-服务措施分析-柱状图 + * + * @return + */ + @PostMapping("category-analysis") + public Result categoryAnalysis(@LoginUser TokenDto tokenDto,@RequestBody CategoryAnalysisFormDTO formDTO){ + formDTO.setCusotmerId(tokenDto.getCustomerId()); + ValidatorUtils.validateEntity(formDTO,CategoryAnalysisFormDTO.AddUserShowGroup.class,CategoryAnalysisFormDTO.AddUserInternalGroup.class); + return new Result().ok(icUserDemandRecService.categoryAnalysis(formDTO)); + } + + } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcUserDemandRecDao.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcUserDemandRecDao.java index aa7c3c68c1..299576cfcf 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcUserDemandRecDao.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcUserDemandRecDao.java @@ -21,8 +21,10 @@ import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.dto.form.demand.IcResiUserDemandFromDTO; import com.epmet.dto.form.demand.PageListAnalysisFormDTO; import com.epmet.dto.form.demand.UserDemandPageFormDTO; +import com.epmet.dto.result.demand.CategoryAnalysisDTO; import com.epmet.dto.result.demand.DemandRecResultDTO; import com.epmet.dto.result.demand.IcResiUserReportDemandRes; +import com.epmet.dto.result.demand.OptionDTO; import com.epmet.entity.IcUserDemandRecEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -65,4 +67,13 @@ public interface IcUserDemandRecDao extends BaseDao { * @return */ List pageListAnalysis(PageListAnalysisFormDTO formDTO); + + + List selectListCategoryAnalysisDTO(@Param("firstCategoryList") List firstCategoryList, + @Param("customerId") String customerId, + @Param("orgId") String orgId, + @Param("orgType") String orgType, + @Param("gridPids") String gridPids, + @Param("startDateId") String startDateId, + @Param("endDateId") String endDateId); } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcUserDemandRecService.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcUserDemandRecService.java index 685261ec33..1ffeca3931 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcUserDemandRecService.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcUserDemandRecService.java @@ -21,6 +21,7 @@ import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; import com.epmet.dto.IcUserDemandRecDTO; import com.epmet.dto.form.demand.*; +import com.epmet.dto.result.demand.CategoryAnalysisResDTO; import com.epmet.dto.result.demand.DemandRecResultDTO; import com.epmet.dto.result.demand.DemandResearchAnalysisResultDTO; import com.epmet.dto.result.demand.IcResiUserReportDemandRes; @@ -161,4 +162,11 @@ public interface IcUserDemandRecService extends BaseService pageListAnalysis(PageListAnalysisFormDTO formDTO); + + /** + * 数据分析-服务措施分析-柱状图 + * + * @return + */ + CategoryAnalysisResDTO categoryAnalysis(CategoryAnalysisFormDTO formDTO); } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcUserDemandRecServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcUserDemandRecServiceImpl.java index 51bc5fc35c..8a8e9280af 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcUserDemandRecServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcUserDemandRecServiceImpl.java @@ -45,9 +45,7 @@ import com.epmet.dto.form.demand.*; import com.epmet.dto.result.AllGridsByUserIdResultDTO; import com.epmet.dto.result.IcResiUserBriefDTO; import com.epmet.dto.result.UserBaseInfoResultDTO; -import com.epmet.dto.result.demand.DemandRecResultDTO; -import com.epmet.dto.result.demand.DemandResearchAnalysisResultDTO; -import com.epmet.dto.result.demand.IcResiUserReportDemandRes; +import com.epmet.dto.result.demand.*; import com.epmet.entity.*; import com.epmet.feign.EpmetAdminOpenFeignClient; import com.epmet.feign.EpmetUserOpenFeignClient; @@ -239,9 +237,9 @@ public class IcUserDemandRecServiceImpl extends BaseServiceImpl userInfoMap=new HashMap<>(); - List userIdList=list.stream().filter(item->item.getServiceType().equals(UserDemandConstant.VOLUNTEER)).map(DemandRecResultDTO::getServerId).collect(Collectors.toList()); + Set userIdList=list.stream().filter(item->item.getServiceType().equals(UserDemandConstant.VOLUNTEER)).map(DemandRecResultDTO::getServerId).collect(Collectors.toSet()); if(CollectionUtils.isNotEmpty(userIdList)){ - Result> userInfoRes = epmetUserOpenFeignClient.queryUserBaseInfo(userIdList); + Result> userInfoRes = epmetUserOpenFeignClient.queryUserBaseInfo(new ArrayList<>(userIdList)); if(!userInfoRes.success()||CollectionUtils.isEmpty(userInfoRes.getData())){ throw new RenException("查询志愿者信息异常"); } @@ -654,9 +652,9 @@ public class IcUserDemandRecServiceImpl extends BaseServiceImpl userInfoMap=new HashMap<>(); - List userIdList=list.stream().filter(item->item.getServiceType().equals(UserDemandConstant.VOLUNTEER)).map(DemandRecResultDTO::getServerId).collect(Collectors.toList()); + Set userIdList=list.stream().filter(item->item.getServiceType().equals(UserDemandConstant.VOLUNTEER)).map(DemandRecResultDTO::getServerId).collect(Collectors.toSet()); if(CollectionUtils.isNotEmpty(userIdList)){ - Result> userInfoRes = epmetUserOpenFeignClient.queryUserBaseInfo(userIdList); + Result> userInfoRes = epmetUserOpenFeignClient.queryUserBaseInfo(new ArrayList<>(userIdList)); if(!userInfoRes.success()||CollectionUtils.isEmpty(userInfoRes.getData())){ throw new RenException("查询志愿者信息异常"); } @@ -696,6 +694,79 @@ public class IcUserDemandRecServiceImpl extends BaseServiceImpl(list, total); } + /** + * 数据分析-服务措施分析-柱状图 + * + * @param formDTO + * @return + */ + @Override + public CategoryAnalysisResDTO categoryAnalysis(CategoryAnalysisFormDTO formDTO) { + //1、一级分类字典,没有分类直接退出 + SubCodeFormDTO subCodeFormDTO=new SubCodeFormDTO(); + subCodeFormDTO.setCustomerId(formDTO.getCusotmerId()); + subCodeFormDTO.setParentCategoryCode(NumConstant.ZERO_STR); + List firstCategoryList=demandDictService.querySubCodeList(subCodeFormDTO); + if(CollectionUtils.isEmpty(firstCategoryList)){ + return new CategoryAnalysisResDTO(Collections.EMPTY_LIST,Collections.EMPTY_LIST); + } + //2、没有服务类型直接退出 + Result> serviceTypeRes=adminOpenFeignClient.dictMap(DictTypeEnum.USER_DEMAND_SERVICE_TYPE.getCode()); + if(!serviceTypeRes.success()||MapUtils.isEmpty(serviceTypeRes.getData())){ + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"查询服务方类型异常,请检查是否已经配置字典信息"); + } + List legend=new ArrayList<>(); + serviceTypeRes.getData().forEach((code,name)->{ + LegendDTO legendDTO=new LegendDTO(code,name); + legend.add(legendDTO); + }); + LegendDTO unfinishLegend = new LegendDTO("unfinished", "未完成"); + legend.add(unfinishLegend); + // 3、传进来的是组织id的话,查询出全路径 + if("agency".equals(formDTO.getOrgType())){ + if(NumConstant.ZERO_STR.equals(formDTO.getPid())){ + //当前传入的组织id=客户的根组织 + formDTO.setGridPids(formDTO.getOrgId()); + }else{ + //找到当前组织的所有上级,再拼接上自己 + Result customerAgencyDTOResult=govOrgOpenFeignClient.getAgencyById(formDTO.getOrgId()); + if(!customerAgencyDTOResult.success()||null==customerAgencyDTOResult.getData()){ + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取组织信息异常govOrgOpenFeignClient.getAgencyById"); + } + formDTO.setGridPids(customerAgencyDTOResult.getData().getPids().concat(StrConstant.COLON).concat(formDTO.getOrgId())); + } + } + + // 4、查询出有数据的一级分类 + // 4、sql计算出detail + List haveDemandList=baseDao.selectListCategoryAnalysisDTO(firstCategoryList, + formDTO.getCusotmerId(), + formDTO.getOrgId(), + formDTO.getOrgType(), + formDTO.getGridPids(), + formDTO.getStartDateId(), + formDTO.getEndDateId()); + if(!CollectionUtils.isEmpty(haveDemandList)){ + for(CategoryAnalysisDTO analysisRes:haveDemandList){ + //todo + //List detail= + } + } + + + //构造最后的反参 + List list=new ArrayList<>(); + // firstCategoryList是所有的一级分类字典 + firstCategoryList.forEach(firstCategory->{ + CategoryAnalysisDTO categoryAnalysisDTO=new CategoryAnalysisDTO(firstCategory.getValue(),firstCategory.getLabel(),NumConstant.ZERO,Collections.EMPTY_LIST); + list.add(categoryAnalysisDTO); + }); + + CategoryAnalysisResDTO result=new CategoryAnalysisResDTO(); + result.setLegend(legend); + result.setCategoryList(list); + return null; + } } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcUserDemandRecDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcUserDemandRecDao.xml index 804ddac6d6..ffc3aa454f 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcUserDemandRecDao.xml +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcUserDemandRecDao.xml @@ -261,4 +261,26 @@ order by r.WANT_SERVICE_TIME desc,r.REPORT_TIME asc + + + \ No newline at end of file From a021aefa0327ad260fb377cbb87eed45a5140e00 Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Sat, 11 Dec 2021 11:09:25 +0800 Subject: [PATCH 8/8] test --- .../dto/result/demand/CategoryDetailDTO.java | 11 +++ .../com/epmet/dao/IcUserDemandRecDao.java | 13 ++- .../impl/IcUserDemandRecServiceImpl.java | 52 ++++++++---- .../resources/mapper/IcUserDemandRecDao.xml | 81 ++++++++++++++++++- 4 files changed, 134 insertions(+), 23 deletions(-) create mode 100644 epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/CategoryDetailDTO.java diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/CategoryDetailDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/CategoryDetailDTO.java new file mode 100644 index 0000000000..9e2802362a --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/CategoryDetailDTO.java @@ -0,0 +1,11 @@ +package com.epmet.dto.result.demand; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class CategoryDetailDTO extends CategoryAnalysisDetail implements Serializable { + private static final long serialVersionUID = 4459219163308113201L; + private String categoryCode; +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcUserDemandRecDao.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcUserDemandRecDao.java index 299576cfcf..1dfaf2cb85 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcUserDemandRecDao.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcUserDemandRecDao.java @@ -21,10 +21,7 @@ import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.dto.form.demand.IcResiUserDemandFromDTO; import com.epmet.dto.form.demand.PageListAnalysisFormDTO; import com.epmet.dto.form.demand.UserDemandPageFormDTO; -import com.epmet.dto.result.demand.CategoryAnalysisDTO; -import com.epmet.dto.result.demand.DemandRecResultDTO; -import com.epmet.dto.result.demand.IcResiUserReportDemandRes; -import com.epmet.dto.result.demand.OptionDTO; +import com.epmet.dto.result.demand.*; import com.epmet.entity.IcUserDemandRecEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -69,6 +66,14 @@ public interface IcUserDemandRecDao extends BaseDao { List pageListAnalysis(PageListAnalysisFormDTO formDTO); + List selectDetail(@Param("categoryCode") String categoryCode, + @Param("orgType") String orgType, + @Param("orgId") String orgId, + @Param("gridPids") String gridPids, + @Param("customerId") String customerId, + @Param("startDateId") String startDateId, + @Param("endDateId") String endDateId); + List selectListCategoryAnalysisDTO(@Param("firstCategoryList") List firstCategoryList, @Param("customerId") String customerId, @Param("orgId") String orgId, diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcUserDemandRecServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcUserDemandRecServiceImpl.java index 8a8e9280af..89d464e3fe 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcUserDemandRecServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcUserDemandRecServiceImpl.java @@ -17,6 +17,7 @@ package com.epmet.service.impl; +import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; @@ -54,6 +55,7 @@ import com.epmet.service.IcResiDemandDictService; import com.epmet.service.IcUserDemandRecService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; @@ -71,6 +73,7 @@ import java.util.stream.Collectors; * @author generator generator@elink-cn.com * @since v1.0.0 2021-11-19 */ +@Slf4j @Service public class IcUserDemandRecServiceImpl extends BaseServiceImpl implements IcUserDemandRecService { @Autowired @@ -722,6 +725,8 @@ public class IcUserDemandRecServiceImpl extends BaseServiceImpl list=new ArrayList<>(); + // firstCategoryList是所有的一级分类字典 + firstCategoryList.forEach(firstCategory->{ + CategoryAnalysisDTO categoryAnalysisDTO=new CategoryAnalysisDTO(firstCategory.getValue(),firstCategory.getLabel(),NumConstant.ZERO,Collections.EMPTY_LIST); + categoryAnalysisDTO.setDetail(constructDefaultDetail(legend)); + list.add(categoryAnalysisDTO); + }); + + log.info("阶段性胜利2:"+ JSON.toJSONString(list)); + + // 5、查询出有数据的一级分类,sql计算出detail List haveDemandList=baseDao.selectListCategoryAnalysisDTO(firstCategoryList, formDTO.getCusotmerId(), formDTO.getOrgId(), @@ -747,25 +762,32 @@ public class IcUserDemandRecServiceImpl extends BaseServiceImpl detail= + log.info("阶段性胜利3:"+ JSON.toJSONString(haveDemandList)); + Map map = haveDemandList.stream().filter(temp -> CollectionUtils.isNotEmpty(temp.getDetail())).collect(Collectors.toMap(CategoryAnalysisDTO::getCategoryCode, dto -> dto)); + if(MapUtils.isNotEmpty(map)){ + for(CategoryAnalysisDTO result:list){ + if (map.containsKey(result.getCategoryCode()) && null != map.get(result.getCategoryCode())) { + result.setDetail(map.get(result.getCategoryCode()).getDetail()); + } + } } } - - //构造最后的反参 - List list=new ArrayList<>(); - // firstCategoryList是所有的一级分类字典 - firstCategoryList.forEach(firstCategory->{ - CategoryAnalysisDTO categoryAnalysisDTO=new CategoryAnalysisDTO(firstCategory.getValue(),firstCategory.getLabel(),NumConstant.ZERO,Collections.EMPTY_LIST); - list.add(categoryAnalysisDTO); - }); - + //返回结果,也不知道对不对 CategoryAnalysisResDTO result=new CategoryAnalysisResDTO(); result.setLegend(legend); result.setCategoryList(list); - return null; + return result; + } + + private List constructDefaultDetail(List legend) { + List l = new ArrayList<>(); + legend.forEach(legendDTO -> { + CategoryAnalysisDetail d = ConvertUtils.sourceToTarget(legendDTO, CategoryAnalysisDetail.class); + d.setServiceDemandTotal(NumConstant.ZERO); + d.setTotalService(NumConstant.ZERO); + }); + return l; } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcUserDemandRecDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcUserDemandRecDao.xml index ffc3aa454f..eff843c279 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcUserDemandRecDao.xml +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcUserDemandRecDao.xml @@ -263,12 +263,29 @@ - select - #{category.value} as categoryCode, - #{category.label} as categoryName, - count(m.id) as total + #{category.value} as category_code, + #{category.label} as category_name, + count(m.id) as TOTAL, + #{orgType} as org_type, + #{orgId} as org_id, + #{gridPids} as grid_pids, + #{customerId} as customer_id, + #{startDateId} as start_date_id, + #{endDateId} as end_date_id from ic_user_demand_rec m where m.DEL_FLAG='0' and m.CUSTOMER_ID=#{customerId} @@ -281,6 +298,62 @@ and DATE_FORMAT(m.REPORT_TIME,'%Y%m%d') >= #{startDateId} and DATE_FORMAT(m.REPORT_TIME,'%Y%m%d') <= #{endDateId} and m.CATEGORY_CODE like concat(#{category.value},'%') + and m.status !='canceled' + + \ No newline at end of file