diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/result/heart/VolunteerDemandServiceStatsResultDTO.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/result/heart/VolunteerDemandServiceStatsResultDTO.java new file mode 100644 index 0000000000..2dfcb5426a --- /dev/null +++ b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/result/heart/VolunteerDemandServiceStatsResultDTO.java @@ -0,0 +1,41 @@ +package com.epmet.dto.result.heart; + +import lombok.Data; + +/** + * @Description 描述 + * @Author wangxianzhang + * @Date 2021/12/10 4:24 下午 + * @Version 1.0 + */ +@Data +public class VolunteerDemandServiceStatsResultDTO { + + private String customerId; + private String dateId; + /** + * 客户下志愿者总数 + */ + private Integer volunteerTotal; + /** + * 客户下志愿者中,党员数量 + */ + private Integer partyTotal; + /** + * 客户下志愿者中,居民数量 + */ + private Integer resiTotal; + /** + * 客户下志愿者服务总次数 + */ + private Integer serviceTotal; + /** + * 客户下党员志愿者服务次数 + */ + private Integer partyServiceTotal; + /** + * 客户下居民志愿者服务次数 + */ + private Integer resiServiceTotal; + +} diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/heart/DataReportHeartDemandController.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/heart/DataReportHeartDemandController.java new file mode 100644 index 0000000000..86eabe2b3c --- /dev/null +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/heart/DataReportHeartDemandController.java @@ -0,0 +1,38 @@ +package com.epmet.datareport.controller.heart; + +import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.utils.Result; +import com.epmet.datareport.service.heart.DemandService; +import com.epmet.dto.result.heart.VolunteerDemandServiceStatsResultDTO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @Description 描述 + * @Author wangxianzhang + * @Date 2021/12/10 3:55 下午 + * @Version 1.0 + */ +@RestController +@RequestMapping("heart/demand") +public class DataReportHeartDemandController { + + @Autowired + private DemandService demandService; + + /** + * 查询志愿者需求服务统计信息 + * @param loginUser + * @return + */ + @PostMapping("volunteer/service") + public Result getVolunteerServiceStats(@LoginUser TokenDto loginUser) { + String customerId = loginUser.getCustomerId(); + VolunteerDemandServiceStatsResultDTO r = demandService.getVolunteerServiceStats(customerId); + return new Result().ok(r); + } + +} diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/fact/FactVolunteerServiceDailyDao.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/fact/FactVolunteerServiceDailyDao.java new file mode 100644 index 0000000000..fd4d28afb0 --- /dev/null +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/fact/FactVolunteerServiceDailyDao.java @@ -0,0 +1,43 @@ +/** + * 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.datareport.dao.fact; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.datareport.entity.heart.FactVolunteerServiceDailyEntity; +import com.epmet.dto.result.heart.VolunteerDemandServiceStatsResultDTO; +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 { + + /** + * 查询最新一条"志愿者需求服务统计信息" + * @param customerId + * @return + */ + VolunteerDemandServiceStatsResultDTO getLatestVolunteerDemandServiceStats(@Param("customerId") String customerId); +} \ No newline at end of file diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/entity/heart/FactVolunteerServiceDailyEntity.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/entity/heart/FactVolunteerServiceDailyEntity.java new file mode 100644 index 0000000000..a668e52a63 --- /dev/null +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/entity/heart/FactVolunteerServiceDailyEntity.java @@ -0,0 +1,83 @@ +/** + * 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.datareport.entity.heart; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 志愿者服务情况统计 + * + * @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-report/data-report-server/src/main/java/com/epmet/datareport/service/heart/DemandService.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/heart/DemandService.java new file mode 100644 index 0000000000..ccbbb319a1 --- /dev/null +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/heart/DemandService.java @@ -0,0 +1,13 @@ +package com.epmet.datareport.service.heart; + +import com.epmet.dto.result.heart.VolunteerDemandServiceStatsResultDTO; + +/** + * @Description 需求服务 + * @Author wangxianzhang + * @Date 2021/12/10 4:18 下午 + * @Version 1.0 + */ +public interface DemandService { + VolunteerDemandServiceStatsResultDTO getVolunteerServiceStats(String customerId); +} diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/heart/impl/DemandServiceImpl.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/heart/impl/DemandServiceImpl.java new file mode 100644 index 0000000000..79ba0274ea --- /dev/null +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/heart/impl/DemandServiceImpl.java @@ -0,0 +1,29 @@ +package com.epmet.datareport.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.datareport.dao.fact.FactVolunteerServiceDailyDao; +import com.epmet.datareport.entity.heart.FactVolunteerServiceDailyEntity; +import com.epmet.datareport.service.heart.DemandService; +import com.epmet.dto.result.heart.VolunteerDemandServiceStatsResultDTO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * @Description 需求服务 + * @Author wangxianzhang + * @Date 2021/12/10 4:20 下午 + * @Version 1.0 + */ +@Service +public class DemandServiceImpl implements DemandService { + + @Autowired + private FactVolunteerServiceDailyDao factVolunteerServiceDailyDao; + + @Override + public VolunteerDemandServiceStatsResultDTO getVolunteerServiceStats(String customerId) { + return factVolunteerServiceDailyDao.getLatestVolunteerDemandServiceStats(customerId); + } +} diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactVolunteerServiceDailyDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactVolunteerServiceDailyDao.xml new file mode 100644 index 0000000000..fbe645deb3 --- /dev/null +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactVolunteerServiceDailyDao.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/VolunteerCommonFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/VolunteerCommonFormDTO.java new file mode 100644 index 0000000000..c8893697a8 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/VolunteerCommonFormDTO.java @@ -0,0 +1,26 @@ +package com.epmet.dto.form.resi; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +/** + * @Description + * @Author wangxianzhang + * @Date 2021/12/10 6:10 下午 + * @Version 1.0 + */ +@Data +public class VolunteerCommonFormDTO { + + public interface VolunteerPage { + } + + @NotBlank(message = "客户ID不能为空", groups = {VolunteerPage.class}) + private String customerId; + + private Integer pageNo = 0; + + private Integer pageSize = 20; +} diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/resi/PageVolunteerInfoResultDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/resi/PageVolunteerInfoResultDTO.java new file mode 100644 index 0000000000..d23f2023da --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/resi/PageVolunteerInfoResultDTO.java @@ -0,0 +1,14 @@ +package com.epmet.dto.result.resi; + +import lombok.Data; + +/** + * @Description 志愿者信息分页查询结果 + * @Author wangxianzhang + * @Date 2021/12/10 6:17 下午 + * @Version 1.0 + */ +@Data +public class PageVolunteerInfoResultDTO { + private String userId; +} diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetHeartOpenFeignClient.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetHeartOpenFeignClient.java index 7a4a6c8ad5..4bad8f25d7 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetHeartOpenFeignClient.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetHeartOpenFeignClient.java @@ -6,6 +6,8 @@ import com.epmet.dto.ActInfoDTO; import com.epmet.dto.VolunteerInfoDTO; import com.epmet.dto.form.CommonCustomerFormDTO; import com.epmet.dto.form.demand.UserDemandNameQueryFormDTO; +import com.epmet.dto.form.resi.VolunteerCommonFormDTO; +import com.epmet.dto.result.resi.PageVolunteerInfoResultDTO; import com.epmet.feign.fallback.EpmetHeartOpenFeignClientFallbackFactory; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PathVariable; @@ -56,4 +58,12 @@ public interface EpmetHeartOpenFeignClient { @PostMapping("/heart/icresidemanddict/demangnames") Result queryDemandNames(@RequestBody UserDemandNameQueryFormDTO formDTO); + + /** + * 分页查询志愿者列表 + * @param input + * @return + */ + @PostMapping("/heart/resi/volunteer/page") + Result> queryVolunteerPage(@RequestBody VolunteerCommonFormDTO input); } diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/fallback/EpmetHeartOpenFeignClientFallback.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/fallback/EpmetHeartOpenFeignClientFallback.java index e0e140b02e..27c2c9bdc8 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/fallback/EpmetHeartOpenFeignClientFallback.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/fallback/EpmetHeartOpenFeignClientFallback.java @@ -7,6 +7,8 @@ import com.epmet.dto.ActInfoDTO; import com.epmet.dto.VolunteerInfoDTO; import com.epmet.dto.form.CommonCustomerFormDTO; import com.epmet.dto.form.demand.UserDemandNameQueryFormDTO; +import com.epmet.dto.form.resi.VolunteerCommonFormDTO; +import com.epmet.dto.result.resi.PageVolunteerInfoResultDTO; import com.epmet.feign.EpmetHeartOpenFeignClient; import java.util.List; @@ -53,4 +55,9 @@ public class EpmetHeartOpenFeignClientFallback implements EpmetHeartOpenFeignCli public Result queryDemandNames(UserDemandNameQueryFormDTO formDTO) { return ModuleUtils.feignConError(ServiceConstant.EPMET_HEART_SERVER, "queryDemandNames", formDTO); } + + @Override + public Result> queryVolunteerPage(VolunteerCommonFormDTO input) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_HEART_SERVER, "queryVolunteerPage", input); + } } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiVolunteerController.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiVolunteerController.java index e144e9c11f..e1d18e5536 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiVolunteerController.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiVolunteerController.java @@ -26,7 +26,9 @@ import com.epmet.dto.form.CommonCustomerFormDTO; import com.epmet.dto.form.demand.ServiceQueryFormDTO; import com.epmet.dto.form.resi.ResiSendSmsCodeFormDTO; import com.epmet.dto.form.resi.ResiVolunteerAuthenticateFormDTO; +import com.epmet.dto.form.resi.VolunteerCommonFormDTO; import com.epmet.dto.result.demand.OptionDTO; +import com.epmet.dto.result.resi.PageVolunteerInfoResultDTO; import com.epmet.dto.result.resi.ResiVolunteerInfoResultDTO; import com.epmet.service.VolunteerInfoService; import org.springframework.beans.factory.annotation.Autowired; @@ -125,4 +127,21 @@ public class ResiVolunteerController { public Result> queryListVolunteer(@LoginUser TokenDto tokenDto,@RequestBody ServiceQueryFormDTO formDTO){ return new Result>().ok(volunteerInfoService.queryListVolunteer(tokenDto.getCustomerId(),formDTO.getServiceName())); } + + /** + * 分页查询志愿者列表 + * @param input + * @return + */ + @PostMapping("page") + public Result> queryVolunteerPage(@RequestBody VolunteerCommonFormDTO input) { + + ValidatorUtils.validateEntity(input, VolunteerCommonFormDTO.VolunteerPage.class); + + Integer pageNo = input.getPageNo(); + Integer pageSize = input.getPageSize(); + String customerId = input.getCustomerId(); + List l = volunteerInfoService.queryVolunteerPage(customerId, pageNo, pageSize); + return new Result>().ok(l); + } } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/VolunteerInfoService.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/VolunteerInfoService.java index 850c4367de..6a84fb67a1 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/VolunteerInfoService.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/VolunteerInfoService.java @@ -25,6 +25,7 @@ import com.epmet.dto.form.CommonCustomerFormDTO; import com.epmet.dto.form.resi.ResiSendSmsCodeFormDTO; import com.epmet.dto.form.resi.ResiVolunteerAuthenticateFormDTO; import com.epmet.dto.result.demand.OptionDTO; +import com.epmet.dto.result.resi.PageVolunteerInfoResultDTO; import com.epmet.dto.result.resi.ResiVolunteerInfoResultDTO; import com.epmet.entity.VolunteerInfoEntity; @@ -94,4 +95,6 @@ public interface VolunteerInfoService extends BaseService { * @return */ List queryListVolunteer(String customerId,String userRealName); + + List queryVolunteerPage(String customerId, Integer pageNo, Integer pageSize); } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/VolunteerInfoServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/VolunteerInfoServiceImpl.java index a0ac541131..ac87cc6b4c 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/VolunteerInfoServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/VolunteerInfoServiceImpl.java @@ -18,6 +18,7 @@ package com.epmet.service.impl; import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.MqConstant; import com.epmet.commons.tools.constant.NumConstant; @@ -44,12 +45,14 @@ import com.epmet.dto.result.ResiUserBaseInfoResultDTO; import com.epmet.dto.result.SendVerificationCodeResultDTO; import com.epmet.dto.result.UserBaseInfoResultDTO; import com.epmet.dto.result.demand.OptionDTO; +import com.epmet.dto.result.resi.PageVolunteerInfoResultDTO; import com.epmet.dto.result.resi.ResiVolunteerInfoResultDTO; import com.epmet.entity.VolunteerInfoEntity; import com.epmet.feign.EpmetMessageOpenFeignClient; import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.service.HeartUserInfoService; import com.epmet.service.VolunteerInfoService; +import com.github.pagehelper.PageHelper; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.LogManager; @@ -258,4 +261,21 @@ public class VolunteerInfoServiceImpl extends BaseServiceImpl queryVolunteerPage(String customerId, Integer pageNo, Integer pageSize) { + LambdaQueryWrapper query = new LambdaQueryWrapper<>(); + query.eq(VolunteerInfoEntity::getCustomerId, customerId); + + PageHelper.startPage(pageNo, pageSize); + List volunteerInfoEntities = baseDao.selectList(query); + + List list = volunteerInfoEntities.stream().map(vi -> { + PageVolunteerInfoResultDTO p = new PageVolunteerInfoResultDTO(); + p.setUserId(vi.getUserId()); + return p; + }).collect(Collectors.toList()); + + return list; + } } diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java index 5d713f13e4..f09e1f6ccf 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java @@ -540,4 +540,22 @@ public interface GovOrgOpenFeignClient { */ @PostMapping("/gov/org/agency/getsonagencyid") Result> getSonAgencyId(@RequestParam("orgId")String orgId); + +// /icbuilding/{id}?id=demoData + + /** + * 根据ID查询楼栋信息 + * @param id + * @return + */ + @GetMapping("/gov/org/icbuilding/{id}") + Result getBuildingById(@PathVariable("id") String id); + + /** + * 通过ID查询小区信息 + * @param id + * @return + */ + @GetMapping("/gov/org/icneighborhood/{id}") + Result getIcNeighbordhoodById(@PathVariable("id") String id); } diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java index 46fcb2506c..f85e3471e6 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java @@ -344,4 +344,13 @@ public class GovOrgOpenFeignClientFallback implements GovOrgOpenFeignClient { return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "selectPidsByGridId", gridId); } + @Override + public Result getBuildingById(String id) { + return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getBuildingById", id); + } + + @Override + public Result getIcNeighbordhoodById(String id) { + return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getIcNeighbordhoodById", id); + } } diff --git a/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/form/IcFormOptionsQueryFormDTO.java b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/form/IcFormOptionsQueryFormDTO.java new file mode 100644 index 0000000000..f7fa5bb1da --- /dev/null +++ b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/form/IcFormOptionsQueryFormDTO.java @@ -0,0 +1,27 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +/** + * @Description ic 表单options查询通用dto + * @Author wangxianzhang + * @Date 2021/12/12 1:07 下午 + * @Version 1.0 + */ +@Data +public class IcFormOptionsQueryFormDTO { + + public interface QueryByLabelAndCustomerIdForForm {} + + @NotBlank(message = "客户ID必填", groups = { QueryByLabelAndCustomerIdForForm.class }) + private String customerId; + + @NotBlank(message = "FormCode必填", groups = { QueryByLabelAndCustomerIdForForm.class }) + private String formCode; + + @NotBlank(message = "OptionsLabel必填", groups = { QueryByLabelAndCustomerIdForForm.class }) + private String label; + +} diff --git a/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/OperCustomizeOpenFeignClient.java b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/OperCustomizeOpenFeignClient.java index 2882f9977f..9cda858533 100644 --- a/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/OperCustomizeOpenFeignClient.java +++ b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/OperCustomizeOpenFeignClient.java @@ -3,6 +3,7 @@ package com.epmet.feign; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.CustomerFootBarDTO; +import com.epmet.dto.IcFormItemOptionsDTO; import com.epmet.dto.IcResiCategoryStatsConfigDTO; import com.epmet.dto.IcResiCategoryWarnConfigDTO; import com.epmet.dto.form.*; @@ -120,4 +121,12 @@ public interface OperCustomizeOpenFeignClient { @PostMapping("/oper/customize/icformitemoptions/volunteerlabelbyvalues") Result> volunteerLabelByValues(@RequestBody List volunteers,@RequestParam("customerId") String customerId); + /** + * 使用item相关条件查询关联的options + * @param input + * @return + */ + @PostMapping("/oper/customize/icformitemoptions/list-by-item-conditions") + Result> listOptionsByItemConditions(@RequestBody IcFormOptionsQueryFormDTO input); + } diff --git a/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/fallback/OperCustomizeOpenFeignClientFallback.java b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/fallback/OperCustomizeOpenFeignClientFallback.java index a75999eb0e..da282124bb 100644 --- a/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/fallback/OperCustomizeOpenFeignClientFallback.java +++ b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/fallback/OperCustomizeOpenFeignClientFallback.java @@ -4,6 +4,7 @@ import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.ModuleUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.CustomerFootBarDTO; +import com.epmet.dto.IcFormItemOptionsDTO; import com.epmet.dto.IcResiCategoryStatsConfigDTO; import com.epmet.dto.IcResiCategoryWarnConfigDTO; import com.epmet.dto.form.*; @@ -103,4 +104,9 @@ public class OperCustomizeOpenFeignClientFallback implements OperCustomizeOpenFe public Result> volunteerLabelByValues(List volunteers,String customerId) { return ModuleUtils.feignConError(ServiceConstant.OPER_CUSTOMIZE_SERVER, "volunteerLabelByValues",volunteers,customerId); } + + @Override + public Result> listOptionsByItemConditions(IcFormOptionsQueryFormDTO input) { + return ModuleUtils.feignConError(ServiceConstant.OPER_CUSTOMIZE_SERVER, "listOptionsByItemConditions", input); + } } diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/IcFormItemOptionsController.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/IcFormItemOptionsController.java index 262255826a..ed22604272 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/IcFormItemOptionsController.java +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/IcFormItemOptionsController.java @@ -26,14 +26,17 @@ import com.epmet.commons.tools.validator.group.AddGroup; import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.commons.tools.validator.group.DefaultGroup; import com.epmet.dto.IcFormItemOptionsDTO; +import com.epmet.dto.form.IcFormOptionsQueryFormDTO; import com.epmet.excel.IcFormItemOptionsExcel; import com.epmet.service.IcFormItemOptionsService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import org.springframework.web.servlet.tags.form.InputTag; import javax.servlet.http.HttpServletResponse; import java.util.List; import java.util.Map; +import java.util.function.IntUnaryOperator; /** @@ -102,4 +105,21 @@ public class IcFormItemOptionsController { return new Result>().ok(icFormItemOptionsService.volunteerLabelByValues(volunteers,customerId)); } + /** + * 使用item相关条件查询关联的options + * @param input + * @return + */ + @PostMapping("list-by-item-conditions") + public Result> listOptionsByItemConditions(@RequestBody IcFormOptionsQueryFormDTO input) { + ValidatorUtils.validateEntity(input, IcFormOptionsQueryFormDTO.QueryByLabelAndCustomerIdForForm.class); + String customerId = input.getCustomerId(); + String formCode = input.getFormCode(); + String label = input.getLabel(); + + List r = icFormItemOptionsService.getOptionsByItemConditions(customerId, formCode, label); + return new Result>().ok(r); + } + + } \ No newline at end of file diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/IcFormItemOptionsService.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/IcFormItemOptionsService.java index 387cc05412..7423f85289 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/IcFormItemOptionsService.java +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/IcFormItemOptionsService.java @@ -100,4 +100,13 @@ public interface IcFormItemOptionsService extends BaseService volunteerLabelByValues(List volunteers, String customerId); + + /** + * 使用item相关条件查询options + * @param customerId + * @param formCode + * @param label + * @return + */ + List getOptionsByItemConditions(String customerId, String formCode, String label); } \ No newline at end of file diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcFormItemOptionsServiceImpl.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcFormItemOptionsServiceImpl.java index 144e56e568..970845cbee 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcFormItemOptionsServiceImpl.java +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcFormItemOptionsServiceImpl.java @@ -17,23 +17,30 @@ package com.epmet.service.impl; +import cn.hutool.core.bean.BeanUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.dao.IcFormItemDao; import com.epmet.dao.IcFormItemOptionsDao; import com.epmet.dto.IcFormItemOptionsDTO; +import com.epmet.entity.IcFormItemEntity; import com.epmet.entity.IcFormItemOptionsEntity; import com.epmet.service.IcFormItemOptionsService; import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** * 表单项的选项 @@ -44,7 +51,9 @@ import java.util.Map; @Service public class IcFormItemOptionsServiceImpl extends BaseServiceImpl implements IcFormItemOptionsService { - + @Autowired + private IcFormItemDao icFormItemDao; + @Override public PageData page(Map params) { IPage page = baseDao.selectPage( @@ -61,8 +70,8 @@ public class IcFormItemOptionsServiceImpl extends BaseServiceImpl getWrapper(Map params){ - String id = (String)params.get(FieldConstant.ID_HUMP); + private QueryWrapper getWrapper(Map params) { + String id = (String) params.get(FieldConstant.ID_HUMP); QueryWrapper wrapper = new QueryWrapper<>(); wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); @@ -98,14 +107,40 @@ public class IcFormItemOptionsServiceImpl extends BaseServiceImpl volunteerLabelByValues(List volunteers,String customerId) { - return baseDao.volunteerLabelByValues(volunteers,customerId); + public List volunteerLabelByValues(List volunteers, String customerId) { + return baseDao.volunteerLabelByValues(volunteers, customerId); } + @Override + public List getOptionsByItemConditions(String customerId, String formCode, String label) { + + // 查询item + LambdaQueryWrapper formItemQuery = new LambdaQueryWrapper<>(); + formItemQuery.eq(IcFormItemEntity::getCustomerId, customerId); + formItemQuery.eq(IcFormItemEntity::getFormCode, formCode); + formItemQuery.eq(IcFormItemEntity::getLabel, label); + IcFormItemEntity item = icFormItemDao.selectOne(formItemQuery); + + if (item == null) { + return new ArrayList<>(); + } + + // 通过item查询options + LambdaQueryWrapper query = new LambdaQueryWrapper<>(); + query.eq(IcFormItemOptionsEntity::getItemId, item.getId()); + query.orderByAsc(IcFormItemOptionsEntity::getSort); + + // 属性拷贝 + return baseDao.selectList(query).stream().map(o -> { + IcFormItemOptionsDTO oDTO = new IcFormItemOptionsDTO(); + BeanUtil.copyProperties(o, oDTO); + return oDTO; + }).collect(Collectors.toList()); + } } \ No newline at end of file diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/VolunteerCommonFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/VolunteerCommonFormDTO.java new file mode 100644 index 0000000000..a2c8dff5a1 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/VolunteerCommonFormDTO.java @@ -0,0 +1,26 @@ +package com.epmet.dto.form; + +import lombok.Data; +import lombok.Value; + +import javax.validation.constraints.NotBlank; + +/** + * @Description + * @Author wangxianzhang + * @Date 2021/12/10 5:47 下午 + * @Version 1.0 + */ +@Data +public class VolunteerCommonFormDTO { + + /** + * 查询志愿者分布 + */ + public interface GetVolunteerDistribution { + } + + @NotBlank(message = "客户ID不能为空", groups = {GetVolunteerDistribution.class}) + private String customerId; + +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/IcResiUserBriefDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/IcResiUserBriefDTO.java index ce955f1a56..9d5f1453d3 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/IcResiUserBriefDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/IcResiUserBriefDTO.java @@ -3,7 +3,10 @@ package com.epmet.dto.result; import lombok.Data; import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * 案件居民、家属列表 @@ -12,8 +15,66 @@ import java.util.List; @Data public class IcResiUserBriefDTO extends HouseUserDTO implements Serializable { private String houseId; + + private String gridId; + + private String gridName; + + /** + * 小区id + */ + private String villageId; + + /** + * 小区名 + */ + private String villageName; + + /** + * 是否本地户籍 + */ + private String isBdhj; + + /** + * 手机号 + */ + private String mobile; + + /** + * 性别 + */ + private String gender; + + /** + * 身份证号 + */ + private String idCard; + + /** + * 出生日期 + */ + private String birthday; + + /** + * 联系人 + */ + private String contacts; + + /** + * 联系人电话 + */ + private String contactsMobile; + + /** + * 志愿者类别 + * key:志愿者类型英文 + * value:志愿者类型中文 + */ + private Map volunteerCategories = new HashMap<>(); + /** * 同屋的其他人 */ private List houseUserList; + } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/VolunteerDistributionResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/VolunteerDistributionResultDTO.java new file mode 100644 index 0000000000..c1bb3d866c --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/VolunteerDistributionResultDTO.java @@ -0,0 +1,36 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +/** + * @Description + * @Author wangxianzhang + * @Date 2021/12/10 5:49 下午 + * @Version 1.0 + */ +@Data +public class VolunteerDistributionResultDTO { + + private List legends = new ArrayList<>(); + + private List distributions = new ArrayList<>(); + + @Data + public static class Legend { + private String optionLabel; + private String optionValue; + } + + @Data + public static class Distribution { + private Set volunteerTypes; + private String epmetUserId; + private String icResiUserId; + private String longitude; + private String latitude; + } +} 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..d89449515e 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 @@ -505,4 +505,17 @@ public class IcResiUserController { ValidatorUtils.validateEntity(formDTO, DemandUserFormDTO.InternalGroup.class); return new Result>().ok(icResiUserService.queryDemandUsers(formDTO)); } + + /** + * 根据居民id查询居民信息简介 + * @param resiUserId + * @return + */ + @PostMapping("resi-brief/{resi-user-id}") + public Result getResiBrief(@PathVariable("resi-user-id") String resiUserId, @LoginUser TokenDto loginUser) { + String customerId = loginUser.getCustomerId(); + IcResiUserBriefDTO r = icResiUserService.getResiBrief(resiUserId, customerId); + return new Result().ok(r); + } + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/VolunteerController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/VolunteerController.java new file mode 100644 index 0000000000..40ea2d8807 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/VolunteerController.java @@ -0,0 +1,55 @@ +package com.epmet.controller; + +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.dao.IcResiUserDao; +import com.epmet.dto.form.VolunteerCommonFormDTO; +import com.epmet.dto.result.VolunteerDistributionResultDTO; +import com.epmet.feign.GovOrgOpenFeignClient; +import com.epmet.service.VolunteerService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @Description 志愿者controller + * @Author wangxianzhang + * @Date 2021/12/10 5:45 下午 + * @Version 1.0 + */ +@RestController +@RequestMapping("volunteer") +public class VolunteerController { + + /** + * 不知道为何用注解 注入不进来,暂时用构造方法注入 + */ + @Autowired + private VolunteerService volunteerService; + + //public VolunteerController(VolunteerService volunteerService, IcResiUserDao icResiUserDao, GovOrgOpenFeignClient govOrgOpenFeignClient) { + // this.volunteerService = volunteerService; + // System.out.println(this); + //} + + /** + * 志愿者分布查询 + * + * @param input + * @return + */ + @PostMapping("distribution") + public Result getVolunteerDistribution(@RequestBody VolunteerCommonFormDTO input) { + System.out.println(this); + ValidatorUtils.validateEntity(input, VolunteerCommonFormDTO.GetVolunteerDistribution.class); + + String customerId = input.getCustomerId(); + + VolunteerDistributionResultDTO r = volunteerService.getVolunteerDistributionAndLegends(customerId); + + return new Result().ok(r); + } + +} 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..ee16cd596a 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 @@ -153,4 +153,6 @@ public interface IcResiUserService extends BaseService { IcResiUserDTO getByIdCard(String customerId, String idNum,String icResiUserId); IcResiUserBriefDTO findFamilyMem(String icResiUserId); + + IcResiUserBriefDTO getResiBrief(String resiUserId, String customerId); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/VolunteerService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/VolunteerService.java new file mode 100644 index 0000000000..cd87cf7dd5 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/VolunteerService.java @@ -0,0 +1,15 @@ +package com.epmet.service; + +import com.epmet.dto.result.VolunteerDistributionResultDTO; + +/** + * @Description 志愿者service + * @Author wangxianzhang + * @Date 2021/12/10 5:48 下午 + * @Version 1.0 + */ +public interface VolunteerService { + + VolunteerDistributionResultDTO getVolunteerDistributionAndLegends(String customerId); + +} 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..6fe81d27aa 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 @@ -17,6 +17,7 @@ package com.epmet.service.impl; +import cn.hutool.core.bean.BeanUtil; import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -102,6 +103,8 @@ public class IcResiUserServiceImpl extends BaseServiceImpl getWrapper(Map params){ String id = (String)params.get(FieldConstant.ID_HUMP); @@ -883,4 +886,74 @@ public class IcResiUserServiceImpl extends BaseServiceImpl query = new LambdaQueryWrapper<>(); + query.eq(IcResiUserEntity::getId, resiUserId); + IcResiUserEntity resiEntity = baseDao.selectOne(query); + + IcResiUserBriefDTO r = new IcResiUserBriefDTO(); + + BeanUtil.copyProperties(resiEntity, r); + + r.setHouseId(resiEntity.getHomeId()); + r.setIcResiUserId(resiEntity.getId()); + r.setIcUserName(resiEntity.getName()); + + // 填充网格、小区名称 + String errorMsg = "【居民信息简介】查询网格、小区信息失败"; + IcNeighborHoodDTO neighborHood = getResultDataOrThrowsException(govOrgOpenFeignClient.getIcNeighbordhoodById(resiEntity.getVillageId()), + ServiceConstant.GOV_ORG_SERVER, + EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), + errorMsg, + errorMsg); + + CustomerGridFormDTO gridInfoForm = new CustomerGridFormDTO(); + gridInfoForm.setGridId(resiEntity.getGridId()); + CustomerGridDTO gridInfo = getResultDataOrThrowsException(govOrgOpenFeignClient.getCustomerGridByGridId(gridInfoForm), + ServiceConstant.GOV_ORG_SERVER, + EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), + errorMsg, + errorMsg); + + r.setGridName(gridInfo.getGridName()); + r.setVillageName(neighborHood.getNeighborHoodName()); + + // 2.志愿者类型填充 + List volunteers = icResiUserDao.selectVolunteerByUserId(resiEntity.getId()); + if (CollectionUtils.isNotEmpty(volunteers)) { + String[] vCategories = volunteers.get(0).split(","); + + // 志愿者类型字典 + Map categories = getVolunteerCategoryOptions(customerId); + + for (int i = 0; i < vCategories.length; i++) { + r.getVolunteerCategories().put(vCategories[i], categories.get(vCategories[i])); + } + } + + return r; + } + + /** + * 查询志愿者类别options + * @param customerId + * @return + */ + private Map getVolunteerCategoryOptions(String customerId) { + IcFormOptionsQueryFormDTO optionsQuery = new IcFormOptionsQueryFormDTO(); + optionsQuery.setCustomerId(customerId); + optionsQuery.setFormCode("resi_base_info"); + optionsQuery.setLabel("志愿者类别"); + List categorieDtos = getResultDataOrThrowsException(operCustomizeOpenFeignClient.listOptionsByItemConditions(optionsQuery), + ServiceConstant.OPER_CUSTOMIZE_SERVER, + EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), + "【志愿者分布】志愿者简介-查询志愿者类别失败", + "【志愿者分布】志愿者简介-查询志愿者类别失败"); + + return categorieDtos.stream() + .collect(Collectors.toMap(IcFormItemOptionsDTO::getOptionValue, IcFormItemOptionsDTO::getOptionLabel)); + + } } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/VolunteerServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/VolunteerServiceImpl.java new file mode 100644 index 0000000000..f0e2796a98 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/VolunteerServiceImpl.java @@ -0,0 +1,179 @@ +package com.epmet.service.impl; + +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.feign.ResultDataResolver; +import com.epmet.dao.IcResiUserDao; +import com.epmet.dao.UserBaseInfoDao; +import com.epmet.dto.IcBuildingDTO; +import com.epmet.dto.IcFormItemOptionsDTO; +import com.epmet.dto.IcResiUserDTO; +import com.epmet.dto.form.IcFormOptionsQueryFormDTO; +import com.epmet.dto.form.resi.VolunteerCommonFormDTO; +import com.epmet.dto.result.ResiUserBaseInfoResultDTO; +import com.epmet.dto.result.VolunteerDistributionResultDTO; +import com.epmet.dto.result.resi.PageVolunteerInfoResultDTO; +import com.epmet.feign.EpmetHeartOpenFeignClient; +import com.epmet.feign.GovOrgOpenFeignClient; +import com.epmet.feign.OperCustomizeOpenFeignClient; +import com.epmet.service.VolunteerService; +import org.apache.commons.collections4.CollectionUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * @Description + * @Author wangxianzhang + * @Date 2021/12/10 5:48 下午 + * @Version 1.0 + */ +@Service +public class VolunteerServiceImpl implements VolunteerService, ResultDataResolver { + + @Autowired + private EpmetHeartOpenFeignClient epmetHeartOpenFeignClient; + + @Autowired + private UserBaseInfoDao userBaseInfoDao; + + @Autowired + private IcResiUserDao icResiUserDao; + + @Autowired + private GovOrgOpenFeignClient govOrgOpenFeignClient; + + @Autowired + private OperCustomizeOpenFeignClient operCustomizeOpenFeignClient; + + /** + * 查询志愿者分布以及志愿者图例 + * + * @param customerId + * @return + */ + public VolunteerDistributionResultDTO getVolunteerDistributionAndLegends(String customerId) { + + // 1.查询分布 + VolunteerDistributionResultDTO volunteerDistribution = getVolunteerDistribution(customerId); + + // 2.补充图例 + IcFormOptionsQueryFormDTO optionsForm = new IcFormOptionsQueryFormDTO(); + optionsForm.setCustomerId(customerId); + optionsForm.setFormCode("resi_base_info"); + optionsForm.setLabel("志愿者类别"); + + String errorMsg = "【志愿者分布】查询志愿者图例失败"; + List options = getResultDataOrThrowsException(operCustomizeOpenFeignClient.listOptionsByItemConditions(optionsForm), + ServiceConstant.OPER_CUSTOMIZE_SERVER, + EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), + errorMsg, + errorMsg); + + List legends = options.stream().map(o -> { + VolunteerDistributionResultDTO.Legend legend = new VolunteerDistributionResultDTO.Legend(); + legend.setOptionLabel(o.getOptionLabel()); + legend.setOptionValue(o.getOptionValue()); + return legend; + }).collect(Collectors.toList()); + + volunteerDistribution.setLegends(legends); + return volunteerDistribution; + } + + /** + * 查询志愿者分布 + * + * @param customerId + * @return + */ + public VolunteerDistributionResultDTO getVolunteerDistribution(String customerId) { + //epmetHeartOpenFeignClient.queryVolunteerPage() + + // 1.分页查询出所有志愿者列表 + int pageNo = 1; + int pageSize = 100; + + // 志愿者epmet user id + Set volunteerEpmetUserIds = new HashSet<>(); + + // 分页查询志愿者的epmet user id + while (true) { + + VolunteerCommonFormDTO volunteerForm = new VolunteerCommonFormDTO(); + volunteerForm.setCustomerId(customerId); + volunteerForm.setPageNo(pageNo); + volunteerForm.setPageSize(pageSize); + + String errorMsg = "【志愿者分布】分页查询志愿者列表失败"; + List volunteerPage = getResultDataOrThrowsException(epmetHeartOpenFeignClient.queryVolunteerPage(volunteerForm), + ServiceConstant.EPMET_HEART_SERVER, + EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), + errorMsg, + errorMsg); + + // 将本页userId添加到总集中去 + volunteerEpmetUserIds.addAll(volunteerPage.stream().map(v -> v.getUserId()).collect(Collectors.toSet())); + + if (volunteerPage.size() < pageSize) { + // 说明是最后一页了 + break; + } + + pageNo++; + } + + + VolunteerDistributionResultDTO r = new VolunteerDistributionResultDTO(); + + // 2.填充ic居民信息 + for (String volunteerEpmetUserId : volunteerEpmetUserIds) { + + VolunteerDistributionResultDTO.Distribution distribution = new VolunteerDistributionResultDTO.Distribution(); + + ResiUserBaseInfoResultDTO userBaseInfo = userBaseInfoDao.selecUserBaseInfoByUserId(volunteerEpmetUserId); + + //使用身份证号查询ic resi信息 + IcResiUserDTO icResiUserInfo = icResiUserDao.selectIdByIdCard(customerId, userBaseInfo.getIdNum(), null); + if (icResiUserInfo == null) { + continue; + } + + List volunteer = icResiUserDao.selectVolunteerByUserId(icResiUserInfo.getId()); + if (CollectionUtils.isEmpty(volunteer)) { + // 此人没有志愿者信息 + continue; + } + + // 将志愿者类型列表字符串,切割放到set中 + Set volunteerTypes = new HashSet(); + for (String vTypesString : volunteer) { + String[] vTypes = vTypesString.split(","); + if (vTypes != null && vTypes.length > 0) { + volunteerTypes.addAll(Arrays.asList(vTypes)); + } + } + + + String msg = "【志愿者分布】查询楼栋信息失败"; + IcBuildingDTO building = getResultDataOrThrowsException(govOrgOpenFeignClient.getBuildingById(icResiUserInfo.getBuildId()), + ServiceConstant.GOV_ORG_SERVER, + EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), msg, msg); + + distribution.setVolunteerTypes(volunteerTypes); + distribution.setEpmetUserId(userBaseInfo.getUserId()); + distribution.setIcResiUserId(icResiUserInfo.getId()); + Optional.of(building).ifPresent(b -> { + distribution.setLongitude(b.getLongitude()); + distribution.setLatitude(b.getLatitude()); + }); + + r.getDistributions().add(distribution); + } + + return r; + } + +}