Browse Source

抽取小程序和居民信息里的志愿者数据

dev
zhaoqifeng 3 years ago
parent
commit
723b9ba0d9
  1. 12
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetHeartOpenFeignClient.java
  2. 15
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/fallback/EpmetHeartOpenFeignClientFallback.java
  3. 6
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiVolunteerController.java
  4. 10
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/VolunteerInfoService.java
  5. 36
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/VolunteerInfoServiceImpl.java
  6. 14
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcVolunteerPolyDTO.java
  7. 12
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcVolunteerPolyController.java
  8. 10
      epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java
  9. 3
      epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcVolunteerPolyDao.java
  10. 13
      epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcVolunteerPolyEntity.java
  11. 9
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcVolunteerPolyService.java
  12. 116
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcVolunteerPolyServiceImpl.java
  13. 20
      epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml
  14. 8
      epmet-user/epmet-user-server/src/main/resources/mapper/IcVolunteerPolyDao.xml

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

@ -4,6 +4,7 @@ import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.dto.result.OptionResultDTO;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.ActInfoDTO;
import com.epmet.dto.IcVolunteerPolyDTO;
import com.epmet.dto.VolunteerInfoDTO;
import com.epmet.dto.form.AutoEvaluateDemandFormDTO;
import com.epmet.dto.form.CommonCustomerFormDTO;
@ -107,4 +108,15 @@ public interface EpmetHeartOpenFeignClient {
@PostMapping("/heart/icresidemanddict/demandoption")
Result<List<OptionResultDTO>> getDemandOptions();
/**
* 获取客户下志愿者列表
*
* @Param customerId
* @Return {@link Result< List< IcVolunteerPolyDTO>>}
* @Author zhaoqifeng
* @Date 2022/5/19 11:14
*/
@PostMapping("/heart/resi/volunteer/getVolunteerList/{customerId}")
Result<List<IcVolunteerPolyDTO>> getVolunteerList(@PathVariable("customerId") String customerId);
}

15
epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/fallback/EpmetHeartOpenFeignClientFallback.java

@ -5,6 +5,7 @@ import com.epmet.commons.tools.dto.result.OptionResultDTO;
import com.epmet.commons.tools.utils.ModuleUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.ActInfoDTO;
import com.epmet.dto.IcVolunteerPolyDTO;
import com.epmet.dto.VolunteerInfoDTO;
import com.epmet.dto.form.AutoEvaluateDemandFormDTO;
import com.epmet.dto.form.CommonCustomerFormDTO;
@ -108,4 +109,18 @@ public class EpmetHeartOpenFeignClientFallback implements EpmetHeartOpenFeignCli
public Result<List<OptionResultDTO>> getDemandOptions() {
return ModuleUtils.feignConError(ServiceConstant.EPMET_HEART_SERVER, "getDemandOptions", null);
}
/**
* 获取客户下志愿者列表
*
* @param customerId
* @Param customerId
* @Return {@link Result< List< IcVolunteerPolyDTO >>}
* @Author zhaoqifeng
* @Date 2022/5/19 11:14
*/
@Override
public Result<List<IcVolunteerPolyDTO>> getVolunteerList(String customerId) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_HEART_SERVER, "getVolunteerList", customerId);
}
}

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

@ -21,6 +21,7 @@ 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.dto.IcVolunteerPolyDTO;
import com.epmet.dto.VolunteerInfoDTO;
import com.epmet.dto.form.CommonCustomerFormDTO;
import com.epmet.dto.form.demand.ServiceQueryFormDTO;
@ -170,4 +171,9 @@ public class ResiVolunteerController {
volunteerInfoService.modifyVolunteerGrid(volunteerInfoDTO);
return new Result();
}
@PostMapping("getVolunteerList/{customerId}")
public Result<List<IcVolunteerPolyDTO>> getVolunteerList(@PathVariable("customerId") String customerId) {
return new Result<List<IcVolunteerPolyDTO>>().ok(volunteerInfoService.getVolunteerList(customerId));
}
}

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

@ -20,6 +20,7 @@ package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.IcVolunteerPolyDTO;
import com.epmet.dto.VolunteerInfoDTO;
import com.epmet.dto.form.CommonCustomerFormDTO;
import com.epmet.dto.form.resi.ResiSendSmsCodeFormDTO;
@ -117,4 +118,13 @@ public interface VolunteerInfoService extends BaseService<VolunteerInfoEntity> {
* @param volunteerInfoDTO
*/
void modifyVolunteerGrid(VolunteerInfoDTO volunteerInfoDTO);
/**
* 获取客户下志愿者
* @Param customerId
* @Return {@link List< IcVolunteerPolyDTO>}
* @Author zhaoqifeng
* @Date 2022/5/19 10:58
*/
List<IcVolunteerPolyDTO> getVolunteerList(String customerId);
}

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

@ -39,10 +39,7 @@ import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.SmsTemplateConstant;
import com.epmet.constant.SystemMessageType;
import com.epmet.dao.VolunteerInfoDao;
import com.epmet.dto.CustomerAgencyDTO;
import com.epmet.dto.CustomerGridDTO;
import com.epmet.dto.HeartUserInfoDTO;
import com.epmet.dto.VolunteerInfoDTO;
import com.epmet.dto.*;
import com.epmet.dto.form.*;
import com.epmet.dto.form.resi.ResiSendSmsCodeFormDTO;
import com.epmet.dto.form.resi.ResiVolunteerAuthenticateFormDTO;
@ -424,4 +421,35 @@ public class VolunteerInfoServiceImpl extends BaseServiceImpl<VolunteerInfoDao,
public void modifyVolunteerGrid(VolunteerInfoDTO volunteerInfoDTO) {
baseDao.updateVolunteerGrid(volunteerInfoDTO);
}
/**
* 获取客户下志愿者
*
* @param customerId
* @Param customerId
* @Return {@link List< IcVolunteerPolyDTO >}
* @Author zhaoqifeng
* @Date 2022/5/19 10:58
*/
@Override
public List<IcVolunteerPolyDTO> getVolunteerList(String customerId) {
if (StringUtils.isBlank(customerId)) {
return Collections.emptyList();
}
LambdaQueryWrapper<VolunteerInfoEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(VolunteerInfoEntity::getCustomerId, customerId);
List<VolunteerInfoEntity> list = baseDao.selectList(wrapper);
if (CollectionUtils.isEmpty(list)) {
return Collections.emptyList();
}
return list.stream().map(item -> {
IcVolunteerPolyDTO dto = new IcVolunteerPolyDTO();
dto.setCustomerId(item.getCustomerId());
dto.setAgencyId(item.getPid());
dto.setAgencyPids(item.getPids());
dto.setUserId(item.getUserId());
dto.setVolunteerCategory("qita");
return dto;
}).collect(Collectors.toList());
}
}

14
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcVolunteerPolyDTO.java

@ -1,8 +1,9 @@
package com.epmet.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
@ -36,6 +37,16 @@ public class IcVolunteerPolyDTO implements Serializable {
*/
private String agencyPids;
/**
* 居民端用户id
*/
private String userId;
/**
* 对应的ic_resi_user主表Id
*/
private String icResiUser;
/**
* 居住成员1姓名
*/
@ -65,6 +76,7 @@ public class IcVolunteerPolyDTO implements Serializable {
* 纬度
*/
private String latitude;
private String volunteerCategory;
/**
* 乐观锁

12
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcVolunteerPolyController.java

@ -104,4 +104,16 @@ public class IcVolunteerPolyController {
return new Result<PageData>().ok(data);
}
/**
* 抽取志愿者数据
* @Param customerId
* @Return {@link Result}
* @Author zhaoqifeng
* @Date 2022/5/19 15:41
*/
@PostMapping("volunteerDataExtraction/{customerId}")
public Result volunteerDataExtraction(@PathVariable("customerId") String customerId){
icVolunteerPolyService.volunteerDataExtraction(customerId);
return new Result();
}
}

10
epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java

@ -20,6 +20,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.IcVolunteerPolyDTO;
import com.epmet.dto.form.EpidemicPreventionFormDTO;
import com.epmet.dto.form.RentTenantDataFormDTO;
import com.epmet.dto.form.ResiUserQueryValueDTO;
@ -309,4 +310,13 @@ public interface IcResiUserDao extends BaseDao<IcResiUserEntity> {
* @return
*/
List<HouseIcResiUserResultDTO> getResiUserGroupHomeId(RentTenantDataFormDTO formDTO);
/**
* 获取客户下志愿者信息
* @Param customerId
* @Return {@link List< IcVolunteerPolyDTO>}
* @Author zhaoqifeng
* @Date 2022/5/19 10:40
*/
List<IcVolunteerPolyDTO> getVolunteerList(@Param("customerId") String customerId);
}

3
epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcVolunteerPolyDao.java

@ -31,4 +31,7 @@ public interface IcVolunteerPolyDao extends BaseDao<IcVolunteerPolyEntity> {
*/
List<VolunteerPolyListResultDTO> getList(@Param("code") String code,
@Param("customerId") String customerId);
void deleteDataByCustomerId(@Param("customerId") String customerId);
void deleteCategoryByCustomerId(@Param("customerId") String customerId);
}

13
epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcVolunteerPolyEntity.java

@ -1,13 +1,10 @@
package com.epmet.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* 志愿者信息聚合
*
@ -36,6 +33,16 @@ public class IcVolunteerPolyEntity extends BaseEpmetEntity {
*/
private String agencyPids;
/**
* 居民端用户id
*/
private String userId;
/**
* 对应的ic_resi_user主表Id
*/
private String icResiUser;
/**
* 居住成员1姓名
*/

9
epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcVolunteerPolyService.java

@ -98,4 +98,13 @@ public interface IcVolunteerPolyService extends BaseService<IcVolunteerPolyEntit
* @date 2022/5/19 14:49
*/
PageData getList(VolunteerPolyListFormDTO form);
/**
* 志愿者数据抽取
* @Param customerId
* @Return void
* @Author zhaoqifeng
* @Date 2022/5/19 10:00
*/
void volunteerDataExtraction(String customerId);
}

116
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcVolunteerPolyServiceImpl.java

@ -1,34 +1,48 @@
package com.epmet.service.impl;
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.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.redis.common.CustomerIcHouseRedis;
import com.epmet.commons.tools.redis.common.CustomerOrgRedis;
import com.epmet.commons.tools.redis.common.bean.GridInfoCache;
import com.epmet.commons.tools.redis.common.bean.HouseInfoCache;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dao.IcResiUserDao;
import com.epmet.dao.IcVolunteerPolyDao;
import com.epmet.dao.UserBaseInfoDao;
import com.epmet.dto.IcVolunteerPolyDTO;
import com.epmet.dto.form.VolunteerPolyListFormDTO;
import com.epmet.dto.form.VolunteerPolyMapDataFormDTO;
import com.epmet.dto.result.PartyUnitListbrieResultDTO;
import com.epmet.dto.result.VolunteerPolyListResultDTO;
import com.epmet.dto.result.VolunteerPolyMapDataResultDTO;
import com.epmet.entity.IcVolunteerPolyCategoryEntity;
import com.epmet.entity.IcVolunteerPolyEntity;
import com.epmet.entity.UserBaseInfoEntity;
import com.epmet.feign.EpmetHeartOpenFeignClient;
import com.epmet.service.IcVolunteerPolyCategoryService;
import com.epmet.service.IcVolunteerPolyService;
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.ListUtils;
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 javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 志愿者信息聚合
@ -37,8 +51,18 @@ import java.util.Map;
* @since v1.0.0 2022-05-19
*/
@Service
@Slf4j
public class IcVolunteerPolyServiceImpl extends BaseServiceImpl<IcVolunteerPolyDao, IcVolunteerPolyEntity> implements IcVolunteerPolyService {
@Resource
private IcResiUserDao icResiUserDao;
@Resource
private EpmetHeartOpenFeignClient epmetHeartOpenFeignClient;
@Resource
private UserBaseInfoDao userBaseInfoDao;
@Resource
private IcVolunteerPolyCategoryService icVolunteerPolyCategoryService;
@Override
public PageData<IcVolunteerPolyDTO> page(Map<String, Object> params) {
@ -138,4 +162,90 @@ public class IcVolunteerPolyServiceImpl extends BaseServiceImpl<IcVolunteerPolyD
return new PageData<>(result, info.getTotal());
}
/**
* 志愿者数据抽取
*
* @param customerId
* @Param customerId
* @Return void
* @Author zhaoqifeng
* @Date 2022/5/19 10:00
*/
@Override
public void volunteerDataExtraction(String customerId) {
//获取居民信息表的志愿者
List<IcVolunteerPolyDTO> volunteerList = icResiUserDao.getVolunteerList(customerId);
if (CollectionUtils.isEmpty(volunteerList)) {
volunteerList = new ArrayList<>();
}
//获取小程序居民端志愿者
Result<List<IcVolunteerPolyDTO>> result = epmetHeartOpenFeignClient.getVolunteerList(customerId);
if (!result.success()) {
log.error("志愿者数据抽取-获取小程序志愿者失败");
}
List<IcVolunteerPolyDTO> appVolunteerList = result.getData();
if (CollectionUtils.isNotEmpty(appVolunteerList)) {
//获取居民信息
List<String> userIds = appVolunteerList.stream().map(IcVolunteerPolyDTO::getUserId).collect(Collectors.toList());
//根据志愿者的userId获取居民信息并转成map
List<UserBaseInfoEntity> userList = new ArrayList<>();
List<List<String>> partition = ListUtils.partition(userIds, NumConstant.FIFTY);
partition.forEach(part -> userList.addAll(getUserInfoList(part)));
Map<String, UserBaseInfoEntity> userMap = userList.stream().collect(Collectors.toMap(UserBaseInfoEntity::getUserId, a -> a, (o, n) -> o));
//将居民志愿者转成map
Map<String, IcVolunteerPolyDTO> volunteerMap = volunteerList.stream().collect(Collectors.toMap(IcVolunteerPolyDTO::getIdCard,a -> a, (o, n) -> o));
//小程序与居民信息匹配不上的志愿者
List<IcVolunteerPolyDTO> notInList = new ArrayList<>();
appVolunteerList.forEach(item -> {
//补充志愿者信息
if (userMap.containsKey(item.getUserId())) {
UserBaseInfoEntity userInfo = userMap.get(item.getUserId());
item.setName(userInfo.getRealName());
item.setIdCard(userInfo.getIdNum());
item.setMobile(userInfo.getMobile());
}
//小程序与居民信息匹配不上的志愿者拿出来
if (!volunteerMap.containsKey(item.getIdCard())) {
notInList.add(item);
}
});
//将小程序的志愿者列表转成map
Map<String, IcVolunteerPolyDTO> appVolunteerMap = appVolunteerList.stream().collect(Collectors.toMap(IcVolunteerPolyDTO::getIdCard,a -> a, (o, n) -> o));
////小程序与居民信息匹配上的志愿者userId更新到居民志愿者列表
volunteerList.forEach(item -> {
if (appVolunteerMap.containsKey(item.getIdCard())) {
item.setUserId(appVolunteerMap.get(item.getIdCard()).getUserId());
}
});
volunteerList.addAll(notInList);
}
if (CollectionUtils.isNotEmpty(volunteerList)) {
//删除原数据
baseDao.deleteDataByCustomerId(customerId);
baseDao.deleteCategoryByCustomerId(customerId);
//保存新数据
volunteerList.forEach(item -> {
IcVolunteerPolyEntity entity = ConvertUtils.sourceToTarget(item, IcVolunteerPolyEntity.class);
baseDao.insert(entity);
List<String> categoryList = Arrays.asList(item.getVolunteerCategory().split(StrConstant.COMMA));
List<IcVolunteerPolyCategoryEntity> entityList = categoryList.stream().map(o -> {
IcVolunteerPolyCategoryEntity category = new IcVolunteerPolyCategoryEntity();
category.setCustomerId(item.getCustomerId());
category.setIdCard(item.getIdCard());
category.setLatitude(item.getLatitude());
category.setLongitude(item.getLongitude());
category.setVolunteerCategory(o);
return category;
}).collect(Collectors.toList());
icVolunteerPolyCategoryService.insertBatch(entityList);
});
}
}
private List<UserBaseInfoEntity> getUserInfoList(List<String> userIds) {
LambdaQueryWrapper<UserBaseInfoEntity> userInfoWrapper = new LambdaQueryWrapper<>();
userInfoWrapper.in(UserBaseInfoEntity::getUserId, userIds);
return userBaseInfoDao.selectList(userInfoWrapper);
}
}

20
epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml

@ -972,4 +972,24 @@
</if>
</select>
<select id="getVolunteerList" resultType="com.epmet.dto.IcVolunteerPolyDTO">
SELECT
a.CUSTOMER_ID,
a.AGENCY_ID,
a.PIDS AS agencyPids,
`NAME`,
ID_CARD,
MOBILE,
GENDER,
VOLUNTEER_CATEGORY
FROM
ic_resi_user a
INNER JOIN ic_volunteer b ON a.ID = b.IC_RESI_USER
AND b.DEL_FLAG = '0'
WHERE
a.DEL_FLAG = '0'
AND a.IS_VOLUNTEER = '1'
AND a.CUSTOMER_ID = #{customerId}
</select>
</mapper>

8
epmet-user/epmet-user-server/src/main/resources/mapper/IcVolunteerPolyDao.xml

@ -54,6 +54,10 @@
c.VOLUNTEER_CATEGORY = #{code}
AND c.CUSTOMER_ID = #{customerId}
</select>
<delete id="deleteDataByCustomerId">
delete from ic_volunteer_poly where CUSTOMER_ID = #{customerId}
</delete>
<delete id="deleteCategoryByCustomerId">
delete from ic_volunteer_poly_category where CUSTOMER_ID = #{customerId}
</delete>
</mapper>
Loading…
Cancel
Save