Browse Source

Merge branch 'wxz_demand_service_stats' into develop

dev
wangxianzhang 4 years ago
parent
commit
4a58966f6b
  1. 19
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/form/heart/VolunteerDemandServiceFormDTO.java
  2. 12
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/heart/DataReportHeartDemandController.java
  3. 5
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/fact/FactVolunteerServiceDailyDao.java
  4. 2
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/heart/DemandService.java
  5. 44
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/heart/impl/DemandServiceImpl.java
  6. 13
      epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactVolunteerServiceDailyDao.xml
  7. 7
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/form/ScreenCentralZoneDataFormDTO.java
  8. 23
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java
  9. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/heart/IcUserDemandServiceDao.java
  10. 9
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/stats/FactVolunteerServiceDailyEntity.java
  11. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/heart/HeartDemandService.java
  12. 4
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/heart/impl/HeartDemandServiceImpl.java
  13. 83
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/DemandServiceImpl.java
  14. 14
      epmet-module/data-statistical/data-statistical-server/src/main/resources/db/migration/V0.0.27__volunteer_service_daily_add_gridid.sql
  15. 2
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/heart/IcUserDemandServiceDao.xml
  16. 2
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactVolunteerServiceDailyDao.xml
  17. 12
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/VolunteerCommonFormDTO.java
  18. 1
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetHeartOpenFeignClient.java
  19. 6
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiVolunteerController.java
  20. 4
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/VolunteerInfoEntity.java
  21. 2
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/VolunteerInfoService.java
  22. 29
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/VolunteerInfoServiceImpl.java
  23. 2
      epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/VolunteerInfoDao.xml
  24. 3
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/VolunteerCommonFormDTO.java
  25. 3
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/VolunteerController.java
  26. 2
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/VolunteerService.java
  27. 7
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/VolunteerServiceImpl.java

19
epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/form/heart/VolunteerDemandServiceFormDTO.java

@ -0,0 +1,19 @@
package com.epmet.dto.form.heart;
import lombok.Data;
/**
* @Description
* @Author wangxianzhang
* @Date 2021/12/22 3:12 下午
* @Version 1.0
*/
@Data
public class VolunteerDemandServiceFormDTO {
/**
* 组织ID
*/
private String agencyId;
}

12
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/heart/DataReportHeartDemandController.java

@ -3,10 +3,13 @@ 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.commons.tools.validator.ValidatorUtils;
import com.epmet.datareport.service.heart.DemandService;
import com.epmet.dto.form.heart.VolunteerDemandServiceFormDTO;
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.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@ -29,9 +32,14 @@ public class DataReportHeartDemandController {
* @return
*/
@PostMapping("volunteer/service")
public Result<VolunteerDemandServiceStatsResultDTO> getVolunteerServiceStats(@LoginUser TokenDto loginUser) {
public Result<VolunteerDemandServiceStatsResultDTO> getVolunteerServiceStats(@LoginUser TokenDto loginUser, @RequestBody VolunteerDemandServiceFormDTO input) {
ValidatorUtils.validateEntity(input);
String agencyId = input.getAgencyId();
String customerId = loginUser.getCustomerId();
VolunteerDemandServiceStatsResultDTO r = demandService.getVolunteerServiceStats(customerId);
VolunteerDemandServiceStatsResultDTO r = demandService.getVolunteerServiceStats(customerId, agencyId);
return new Result<VolunteerDemandServiceStatsResultDTO>().ok(r);
}

5
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/fact/FactVolunteerServiceDailyDao.java

@ -36,8 +36,9 @@ public interface FactVolunteerServiceDailyDao extends BaseDao<FactVolunteerServi
/**
* 查询最新一条"志愿者需求服务统计信息"
* @param customerId
* @param customerId 客户ID
* @param agencyPids 查询条件的组织的PIDS
* @return
*/
VolunteerDemandServiceStatsResultDTO getLatestVolunteerDemandServiceStats(@Param("customerId") String customerId);
VolunteerDemandServiceStatsResultDTO getLatestVolunteerDemandServiceStats(@Param("customerId") String customerId, @Param("agencyPids") String agencyPids);
}

2
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/heart/DemandService.java

@ -9,5 +9,5 @@ import com.epmet.dto.result.heart.VolunteerDemandServiceStatsResultDTO;
* @Version 1.0
*/
public interface DemandService {
VolunteerDemandServiceStatsResultDTO getVolunteerServiceStats(String customerId);
VolunteerDemandServiceStatsResultDTO getVolunteerServiceStats(String customerId, String agencyId);
}

44
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/heart/impl/DemandServiceImpl.java

@ -1,12 +1,14 @@
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.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.feign.ResultDataResolver;
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.CustomerAgencyDTO;
import com.epmet.dto.result.heart.VolunteerDemandServiceStatsResultDTO;
import com.epmet.feign.GovOrgOpenFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -17,13 +19,41 @@ import org.springframework.stereotype.Service;
* @Version 1.0
*/
@Service
public class DemandServiceImpl implements DemandService {
public class DemandServiceImpl implements DemandService, ResultDataResolver {
@Autowired
private FactVolunteerServiceDailyDao factVolunteerServiceDailyDao;
@Autowired
private GovOrgOpenFeignClient govOrgOpenFeignClient;
@Override
public VolunteerDemandServiceStatsResultDTO getVolunteerServiceStats(String customerId) {
return factVolunteerServiceDailyDao.getLatestVolunteerDemandServiceStats(customerId);
public VolunteerDemandServiceStatsResultDTO getVolunteerServiceStats(String customerId, String agencyId) {
String errorMsg = "【查询志愿者需求服务信息】查询选中组织信息失败";
CustomerAgencyDTO agencyInfo = getResultDataOrThrowsException(govOrgOpenFeignClient.getAgencyById(agencyId),
ServiceConstant.GOV_ORG_SERVER,
EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),
errorMsg, errorMsg);
if (agencyInfo == null) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), errorMsg, errorMsg);
}
String agencyIdPath = agencyInfo.getPids().concat(":").concat(agencyId);
agencyIdPath = agencyIdPath.startsWith(":") ? agencyIdPath.replaceFirst(":", "") : agencyIdPath;
VolunteerDemandServiceStatsResultDTO r = factVolunteerServiceDailyDao.getLatestVolunteerDemandServiceStats(customerId, agencyIdPath);
if (r == null) {
r = new VolunteerDemandServiceStatsResultDTO();
r.setCustomerId(customerId);
r.setDateId(null);
r.setPartyServiceTotal(0);
r.setServiceTotal(0);
r.setResiServiceTotal(0);
r.setVolunteerTotal(0);
r.setPartyTotal(0);
r.setResiTotal(0);
}
return r;
}
}

13
epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactVolunteerServiceDailyDao.xml

@ -24,12 +24,21 @@
<select id="getLatestVolunteerDemandServiceStats"
resultType="com.epmet.dto.result.heart.VolunteerDemandServiceStatsResultDTO">
select *
select CUSTOMER_ID CUSTOMER_ID,
DATE_ID DATE_ID,
sum(VOLUNTEER_TOTAL) VOLUNTEER_TOTAL,
sum(PARTY_TOTAL) PARTY_TOTAL,
sum(RESI_TOTAL) RESI_TOTAL,
sum(SERVICE_TOTAL) SERVICE_TOTAL,
sum(PARTY_SERVICE_TOTAL) PARTY_SERVICE_TOTAL,
sum(RESI_SERVICE_TOTAL) RESI_SERVICE_TOTAL
from fact_volunteer_service_daily
where DEL_FLAG = 0
and CUSTOMER_ID = #{customerId}
and PIDS like CONCAT(#{agencyPids}, "%")
group by CUSTOMER_ID, DATE_ID
order by DATE_ID desc
limit 1
limit 1
</select>

7
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/form/ScreenCentralZoneDataFormDTO.java

@ -1,9 +1,6 @@
package com.epmet.dto.screen.form;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.RequiredArgsConstructor;
import java.io.Serializable;
@ -26,4 +23,8 @@ public class ScreenCentralZoneDataFormDTO implements Serializable {
* 时间维度 不一定是dateId 需要根据其格式进行判断维度的类型
* */
private String dateId;
private String startDate;
private String endDate;
}

23
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java

@ -881,10 +881,17 @@ public class DemoController {
*/
@PostMapping("project-test")
public Result project(@RequestBody ScreenCentralZoneDataFormDTO param) {
if(StringUtils.isBlank(param.getDateId())){
//默认截止到昨天。
param.setDateId(DateUtils.getBeforeNDay(1));
List<String> dateIds = new ArrayList<>();
if ((StringUtils.isBlank(param.getStartDate()) && StringUtils.isBlank(param.getEndDate()))){
if (StringUtils.isNotBlank(param.getDateId())){
dateIds.add(param.getDateId());
}else {
dateIds.add(DimIdGenerator.getDateDimId(DateUtils.addDateDays(new Date(), -1)));
}
}else {
dateIds = DateUtils.getDaysBetween(param.getStartDate(), param.getEndDate());
}
List<String> customerIds = new ArrayList();
if (StringUtils.isNotBlank(param.getCustomerId())) {
customerIds.add(param.getCustomerId());
@ -892,10 +899,12 @@ public class DemoController {
customerIds = dimCustomerService.selectCustomerIdPage(1, 100);
}
for (String customerId : customerIds) {
ScreenCentralZoneDataFormDTO formDTO = new ScreenCentralZoneDataFormDTO();
formDTO.setCustomerId(customerId);
formDTO.setDateId(param.getDateId());
screenProjectSettleService.extractScreenData(param);
dateIds.forEach(dateId -> {
ScreenCentralZoneDataFormDTO formDTO = new ScreenCentralZoneDataFormDTO();
formDTO.setCustomerId(customerId);
formDTO.setDateId(dateId);
screenProjectSettleService.extractScreenData(formDTO);
});
}
return new Result();
}

2
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/heart/IcUserDemandServiceDao.java

@ -40,5 +40,5 @@ public interface IcUserDemandServiceDao extends BaseDao<IcUserDemandServiceEntit
* @param customerId 客户id
* @param serviceType 服务者类型
*/
List<DemandServiceCountResultDTO> listDemandServeTimes(@Param("customerId") String customerId, @Param("endTime") Date endTime, @Param("serviceType") String serviceType);
List<DemandServiceCountResultDTO> listDemandServeTimes(@Param("customerId") String customerId, @Param("gridId") String gridId, @Param("endTime") Date endTime, @Param("serviceType") String serviceType);
}

9
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/stats/FactVolunteerServiceDailyEntity.java

@ -43,6 +43,11 @@ public class FactVolunteerServiceDailyEntity extends BaseEpmetEntity {
*/
private String customerId;
/**
* 网格ID
*/
private String gridId;
/**
* yyyyMMdd
*/
@ -82,5 +87,9 @@ public class FactVolunteerServiceDailyEntity extends BaseEpmetEntity {
* 居民服务总次数
*/
private Integer resiServiceTotal;
private String pid;
private String pids;
}

2
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/heart/HeartDemandService.java

@ -11,5 +11,5 @@ import java.util.List;
*@Date 2021/12/8
*/
public interface HeartDemandService {
List<DemandServiceCountResultDTO> listDemandServeTimesPage(String customerId, Date endTime, int serviceCountPageNo, int serviceCountPageSize);
List<DemandServiceCountResultDTO> listDemandServeTimesPage(String customerId, String gridId, Date endTime, int serviceCountPageNo, int serviceCountPageSize);
}

4
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/heart/impl/HeartDemandServiceImpl.java

@ -29,11 +29,11 @@ public class HeartDemandServiceImpl implements HeartDemandService {
private IcUserDemandServiceDao demandServiceDao;
@Override
public List<DemandServiceCountResultDTO> listDemandServeTimesPage(String customerId, Date endTime, int serviceCountPageNo, int serviceCountPageSize) {
public List<DemandServiceCountResultDTO> listDemandServeTimesPage(String customerId, String gridId, Date endTime, int serviceCountPageNo, int serviceCountPageSize) {
return PageHelper.startPage(serviceCountPageNo, serviceCountPageSize).doSelectPage(new ISelect() {
@Override
public void doSelect() {
demandServiceDao.listDemandServeTimes(customerId, endTime, "volunteer");
demandServiceDao.listDemandServeTimes(customerId, gridId, endTime, "volunteer");
}
});
}

83
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/DemandServiceImpl.java

@ -1,11 +1,16 @@
package com.epmet.service.impl;
import com.epmet.commons.tools.constant.EpmetRoleKeyConstant;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.feign.ResultDataResolver;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.dto.CustomerGridDTO;
import com.epmet.dto.form.CustomerGridFormDTO;
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.feign.GovOrgOpenFeignClient;
import com.epmet.service.DemandService;
import com.epmet.service.crm.CustomerService;
import com.epmet.service.heart.HeartDemandService;
@ -27,7 +32,7 @@ import java.util.stream.Collectors;
* @Version 1.0
*/
@Service
public class DemandServiceImpl implements DemandService {
public class DemandServiceImpl implements DemandService, ResultDataResolver {
@Autowired
private HeartDemandService heartDemandService;
@ -37,12 +42,15 @@ public class DemandServiceImpl implements DemandService {
@Autowired
private UserService userService;
@Autowired
private DemandStatsService demandStatsService;
@Autowired
private CustomerService customerService;
@Autowired
private GovOrgOpenFeignClient govOrgOpenFeignClient;
@Override
public void statsVolunteerDemandServicesDaily(String customerId) {
@ -50,7 +58,7 @@ public class DemandServiceImpl implements DemandService {
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);
@ -67,7 +75,8 @@ public class DemandServiceImpl implements DemandService {
/**
* 清理旧数据
* @param targetDate 要清理哪天的数据
*
* @param targetDate 要清理哪天的数据
* @param customerIds 要清理哪些客户的
*/
private void clearOldDatas(List<String> customerIds, Date targetDate) {
@ -80,12 +89,44 @@ public class DemandServiceImpl implements DemandService {
/**
* 统计单个客户的志愿者服务情况
*
* @param customerId 客户ID
* @param endTime 统计截止时间(<endTime)
* @param endTime 统计截止时间(<endTime)
*/
private void statsVolunteerDemandServicesDaily4Customer(String customerId, Date endTime, Date belongTime) {
// 一.将客户下所有志愿者,按照网格ID,放到map中去
// 网格ID和志愿者列表。key:网格id;value:志愿者列表
HashMap<String, List<VolunteerInfoEntity>> gridIdAndVolunteers = new HashMap<>();
heartVolunteerService.listVolunteers(customerId, endTime).forEach(v -> {
String volunteerGridId = v.getGridId();
if (StringUtils.isNotBlank(volunteerGridId)) {
if (!gridIdAndVolunteers.containsKey(volunteerGridId)) {
gridIdAndVolunteers.put(volunteerGridId, new ArrayList<>());
}
gridIdAndVolunteers.get(volunteerGridId).add(v);
}
});
// 2.按网格分别统计,且持久化
for (Map.Entry<String, List<VolunteerInfoEntity>> entry : gridIdAndVolunteers.entrySet()) {
statsVolunteerDemandServicesDaily4Grid(customerId, entry.getKey(), endTime, entry.getValue(), belongTime);
}
}
/**
* 按日统计网格需求服务数据
* @param customerId
* @param gridId
* @param endTime 统计截止时间
* @param volunteers 志愿者volunteerInfo列表
* @param belongTime 该次统计要归属到哪一天即createTime
* @return 统计结果entity以备他用
*/
private FactVolunteerServiceDailyEntity statsVolunteerDemandServicesDaily4Grid(String customerId, String gridId, Date endTime, List<VolunteerInfoEntity> volunteers, Date belongTime) {
// 1.志愿者分流为党员志愿者&普通居民志愿者
Integer volunteerTotalCount = 0;
Integer volunteerTotalCount = volunteers.size();
// 党员志愿者数量
Integer partymemberVolunteerCount = 0;
// 居民志愿者数量
@ -94,15 +135,13 @@ public class DemandServiceImpl implements DemandService {
// 党员志愿者用户id列表
List<String> partymemberVolunteerUserIds = new ArrayList<>(16);
List<VolunteerInfoEntity> volunteers = heartVolunteerService.listVolunteers(customerId, endTime);
volunteerTotalCount = volunteers.size();
//--------------------------------【以上是结果数据变量】------------------------------------------
// 分片开始下标
int shardingStartIndex = 0;
// 分片大小(条数)
int shardingSize = 100;
// 分片去确定党员身份,防止in条件过大
while (true) {
int realShardingSize = Math.min(shardingSize, volunteerTotalCount - shardingStartIndex);
@ -141,7 +180,7 @@ public class DemandServiceImpl implements DemandService {
while (true) {
// 取出每一个服务者的服务次数
List<DemandServiceCountResultDTO> damendServeTimes = heartDemandService.listDemandServeTimesPage(customerId, endTime, serviceCountPageNo, serviceCountPageSize);
List<DemandServiceCountResultDTO> damendServeTimes = heartDemandService.listDemandServeTimesPage(customerId, gridId, endTime, serviceCountPageNo, serviceCountPageSize);
for (DemandServiceCountResultDTO damendServiceTimes : damendServeTimes) {
String serverId = damendServiceTimes.getServerId();
@ -158,11 +197,12 @@ public class DemandServiceImpl implements DemandService {
}
totalDemandServeTimes = partymemberDemandServeTimes + resiDemandServeTimes;
// 3.持久化
// 3.组装entity数据返回,待存储
FactVolunteerServiceDailyEntity insert = new FactVolunteerServiceDailyEntity();
insert.setDateId(DimIdGenerator.getDateDimId(belongTime));
insert.setCustomerId(customerId);
insert.setGridId(gridId);
insert.setMonthId(DimIdGenerator.getMonthDimId(belongTime));
insert.setPartyServiceTotal(partymemberDemandServeTimes);
insert.setServiceTotal(totalDemandServeTimes);
@ -171,6 +211,19 @@ public class DemandServiceImpl implements DemandService {
insert.setResiTotal(resiVolunteerCount);
insert.setVolunteerTotal(volunteerTotalCount);
CustomerGridFormDTO gridForm = new CustomerGridFormDTO();
gridForm.setGridId(gridId);
String errorMsg = "【志愿者服务按日统计】查询网格基本信息失败";
CustomerGridDTO gridInfo = getResultDataOrThrowsException(govOrgOpenFeignClient.getGridBaseInfoByGridId(gridForm), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), errorMsg, errorMsg);
Optional.ofNullable(gridInfo).ifPresent(gi -> {
insert.setPid(gi.getPid());
insert.setPids(gi.getPids());
});
// 持久化
demandStatsService.addVolunteerServiceDaily(insert);
return insert;
}
}

14
epmet-module/data-statistical/data-statistical-server/src/main/resources/db/migration/V0.0.27__volunteer_service_daily_add_gridid.sql

@ -0,0 +1,14 @@
-- 发布前执行
alter table fact_volunteer_service_daily add column GRID_ID varchar(64) not null comment '网格ID' after CUSTOMER_ID;
alter table fact_volunteer_service_daily add column PID varchar(64) default '' comment 'pid网格父级ID' after RESI_SERVICE_TOTAL;
alter table fact_volunteer_service_daily add column PIDS varchar(255) default '' comment 'pid网格父级ID路径,包含PID' after PID;
-- 发布后执行
delete from fact_volunteer_service_daily;
alter table fact_volunteer_service_daily drop key uni_vsd;
alter table fact_volunteer_service_daily
add constraint uni_vsd
unique (GRID_ID, DATE_ID, DEL_FLAG);

2
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/heart/IcUserDemandServiceDao.xml

@ -24,11 +24,13 @@
select service.SERVER_ID, SERVICE_TYPE, count(1) as SERVE_TIMES
from ic_user_demand_rec damend
inner join ic_user_demand_service service on (damend.ID = service.DEMAND_REC_ID and service.DEL_FLAG = 0)
inner join volunteer_info v on (service.SERVER_ID = v.USER_ID and v.DEL_FLAG = 0)
where damend.DEL_FLAG = 0
and damend.STATUS = 'finished'
and damend.CUSTOMER_ID = #{customerId}
and service.SERVICE_END_TIME <![CDATA[<]]> #{endTime}
and service.SERVICE_TYPE = #{serviceType}
and v.GRID_ID = #{gridId}
group by service.SERVER_ID, SERVICE_TYPE
</select>
</mapper>

2
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactVolunteerServiceDailyDao.xml

@ -14,6 +14,8 @@
<result property="serviceTotal" column="SERVICE_TOTAL"/>
<result property="partyServiceTotal" column="PARTY_SERVICE_TOTAL"/>
<result property="resiServiceTotal" column="RESI_SERVICE_TOTAL"/>
<result property="pid" column="PID"/>
<result property="pids" column="PIDS"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>

12
epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/VolunteerCommonFormDTO.java

@ -14,12 +14,16 @@ import javax.validation.constraints.NotNull;
@Data
public class VolunteerCommonFormDTO {
public interface VolunteerPage {
}
@NotBlank(message = "客户ID不能为空", groups = {VolunteerPage.class})
/**
* 客户ID
*/
private String customerId;
/**
* 上级组织ID使用PIDS like查询该组织下所有志愿者注意是like 'agencyId:%'
*/
private String superiorAgencyId;
private Integer pageNo = 0;
private Integer pageSize = 20;

1
epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetHeartOpenFeignClient.java

@ -23,6 +23,7 @@ import java.util.List;
* @date 2020/6/4 13:25
*/
@FeignClient(name = ServiceConstant.EPMET_HEART_SERVER, fallbackFactory = EpmetHeartOpenFeignClientFallbackFactory.class)
//@FeignClient(name = ServiceConstant.EPMET_HEART_SERVER, fallbackFactory = EpmetHeartOpenFeignClientFallbackFactory.class, url = "http://localhost:8111")
public interface EpmetHeartOpenFeignClient {
/**

6
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiVolunteerController.java

@ -135,13 +135,11 @@ public class ResiVolunteerController {
*/
@PostMapping("page")
public Result<List<PageVolunteerInfoResultDTO>> queryVolunteerPage(@RequestBody VolunteerCommonFormDTO input) {
ValidatorUtils.validateEntity(input, VolunteerCommonFormDTO.VolunteerPage.class);
Integer pageNo = input.getPageNo();
Integer pageSize = input.getPageSize();
String customerId = input.getCustomerId();
List<PageVolunteerInfoResultDTO> l = volunteerInfoService.queryVolunteerPage(customerId, pageNo, pageSize);
String superiorAgencyId = input.getSuperiorAgencyId();
List<PageVolunteerInfoResultDTO> l = volunteerInfoService.queryVolunteerPage(customerId, pageNo, pageSize, superiorAgencyId);
return new Result<List<PageVolunteerInfoResultDTO>>().ok(l);
}
}

4
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/VolunteerInfoEntity.java

@ -67,4 +67,8 @@ public class VolunteerInfoEntity extends BaseEpmetEntity {
* 志愿者注册所在网格名称
*/
private String gridName;
private String pid;
private String pids;
}

2
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/VolunteerInfoService.java

@ -96,5 +96,5 @@ public interface VolunteerInfoService extends BaseService<VolunteerInfoEntity> {
*/
List<OptionDTO> queryListVolunteer(String customerId,String userRealName);
List<PageVolunteerInfoResultDTO> queryVolunteerPage(String customerId, Integer pageNo, Integer pageSize);
List<PageVolunteerInfoResultDTO> queryVolunteerPage(String customerId, Integer pageNo, Integer pageSize, String superiorAgencyId);
}

29
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/VolunteerInfoServiceImpl.java

@ -22,11 +22,14 @@ 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;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.dto.form.mq.MqBaseMsgDTO;
import com.epmet.commons.tools.dto.form.mq.eventmsg.BasePointEventMsg;
import com.epmet.commons.tools.enums.EventEnum;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.feign.ResultDataResolver;
import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.redis.RedisUtils;
import com.epmet.commons.tools.security.dto.TokenDto;
@ -35,6 +38,7 @@ import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.utils.SendMqMsgUtils;
import com.epmet.constant.SmsTemplateConstant;
import com.epmet.dao.VolunteerInfoDao;
import com.epmet.dto.CustomerAgencyDTO;
import com.epmet.dto.HeartUserInfoDTO;
import com.epmet.dto.VolunteerInfoDTO;
import com.epmet.dto.form.CommonCustomerFormDTO;
@ -50,6 +54,7 @@ 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.feign.GovOrgOpenFeignClient;
import com.epmet.service.HeartUserInfoService;
import com.epmet.service.VolunteerInfoService;
import com.github.pagehelper.PageHelper;
@ -64,6 +69,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Collectors;
@ -74,7 +80,7 @@ import java.util.stream.Collectors;
* @since v1.0.0 2020-07-19
*/
@Service
public class VolunteerInfoServiceImpl extends BaseServiceImpl<VolunteerInfoDao, VolunteerInfoEntity> implements VolunteerInfoService {
public class VolunteerInfoServiceImpl extends BaseServiceImpl<VolunteerInfoDao, VolunteerInfoEntity> implements VolunteerInfoService, ResultDataResolver {
private Logger logger = LogManager.getLogger(VolunteerInfoServiceImpl.class);
private static final String SEND_SMS_CODE_ERROR = "发送短信验证码异常,手机号[%s],code[%s],msg[%s]";
@ -89,6 +95,9 @@ public class VolunteerInfoServiceImpl extends BaseServiceImpl<VolunteerInfoDao,
@Autowired
private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient;
@Autowired
private GovOrgOpenFeignClient govOrgOpenFeignClient;
@Override
@Transactional(rollbackFor = Exception.class)
@ -263,9 +272,23 @@ public class VolunteerInfoServiceImpl extends BaseServiceImpl<VolunteerInfoDao,
}
@Override
public List<PageVolunteerInfoResultDTO> queryVolunteerPage(String customerId, Integer pageNo, Integer pageSize) {
public List<PageVolunteerInfoResultDTO> queryVolunteerPage(String customerId, Integer pageNo, Integer pageSize, String superiorAgencyId) {
LambdaQueryWrapper<VolunteerInfoEntity> query = new LambdaQueryWrapper<>();
query.eq(VolunteerInfoEntity::getCustomerId, customerId);
Optional.ofNullable(customerId).ifPresent(cid -> query.eq(VolunteerInfoEntity::getCustomerId, cid));
Optional.ofNullable(superiorAgencyId).ifPresent(cid -> {
// 需要查询agency的pids:id,通过这个字符串去匹配志愿者的Pids字段来查询
String errorMsg = "【分页查询志愿者列表】失败";
CustomerAgencyDTO agencyInfo = getResultDataOrThrowsException(govOrgOpenFeignClient.getAgencyById(superiorAgencyId), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), errorMsg, errorMsg);
if (agencyInfo == null) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), errorMsg, errorMsg);
}
String pidsAndAgencyIdPath = agencyInfo.getPids().concat(":").concat(superiorAgencyId);
if (pidsAndAgencyIdPath.startsWith(":")) pidsAndAgencyIdPath = pidsAndAgencyIdPath.replaceFirst(":", "");
query.likeRight(VolunteerInfoEntity::getPids, pidsAndAgencyIdPath);
});
PageHelper.startPage(pageNo, pageSize);
List<VolunteerInfoEntity> volunteerInfoEntities = baseDao.selectList(query);

2
epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/VolunteerInfoDao.xml

@ -17,6 +17,8 @@
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
<result property="pid" column="PID"/>
<result property="pids" column="PIDS"/>
</resultMap>
<select id="queryVolunteerFlagByUserId" parameterType="java.lang.String" resultType="java.lang.Integer">

3
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/VolunteerCommonFormDTO.java

@ -23,4 +23,7 @@ public class VolunteerCommonFormDTO {
@NotBlank(message = "客户ID不能为空", groups = {GetVolunteerDistribution.class})
private String customerId;
@NotBlank(message = "组织ID不能为空", groups = {GetVolunteerDistribution.class})
private String agencyId;
}

3
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/VolunteerController.java

@ -40,8 +40,9 @@ public class VolunteerController {
ValidatorUtils.validateEntity(input, VolunteerCommonFormDTO.GetVolunteerDistribution.class);
String customerId = input.getCustomerId();
String agencyId = input.getAgencyId();
VolunteerDistributionResultDTO r = volunteerService.getVolunteerDistributionAndLegends(customerId);
VolunteerDistributionResultDTO r = volunteerService.getVolunteerDistributionAndLegends(customerId, agencyId);
return new Result<VolunteerDistributionResultDTO>().ok(r);
}

2
epmet-user/epmet-user-server/src/main/java/com/epmet/service/VolunteerService.java

@ -10,6 +10,6 @@ import com.epmet.dto.result.VolunteerDistributionResultDTO;
*/
public interface VolunteerService {
VolunteerDistributionResultDTO getVolunteerDistributionAndLegends(String customerId);
VolunteerDistributionResultDTO getVolunteerDistributionAndLegends(String customerId, String agencyId);
}

7
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/VolunteerServiceImpl.java

@ -54,10 +54,10 @@ public class VolunteerServiceImpl implements VolunteerService, ResultDataResolve
* @param customerId
* @return
*/
public VolunteerDistributionResultDTO getVolunteerDistributionAndLegends(String customerId) {
public VolunteerDistributionResultDTO getVolunteerDistributionAndLegends(String customerId, String agencyId) {
// 1.查询分布
VolunteerDistributionResultDTO volunteerDistribution = getVolunteerDistribution(customerId);
VolunteerDistributionResultDTO volunteerDistribution = getVolunteerDistribution(customerId, agencyId);
// 2.补充图例
IcFormOptionsQueryFormDTO optionsForm = new IcFormOptionsQueryFormDTO();
@ -89,7 +89,7 @@ public class VolunteerServiceImpl implements VolunteerService, ResultDataResolve
* @param customerId
* @return
*/
public VolunteerDistributionResultDTO getVolunteerDistribution(String customerId) {
public VolunteerDistributionResultDTO getVolunteerDistribution(String customerId, String agencyId) {
//epmetHeartOpenFeignClient.queryVolunteerPage()
// 1.分页查询出所有志愿者列表
@ -104,6 +104,7 @@ public class VolunteerServiceImpl implements VolunteerService, ResultDataResolve
VolunteerCommonFormDTO volunteerForm = new VolunteerCommonFormDTO();
volunteerForm.setCustomerId(customerId);
volunteerForm.setSuperiorAgencyId(agencyId);
volunteerForm.setPageNo(pageNo);
volunteerForm.setPageSize(pageSize);

Loading…
Cancel
Save