From 90d4bfba855f03626e234dc944d380df53a080c3 Mon Sep 17 00:00:00 2001 From: zhaoqifeng Date: Thu, 19 May 2022 17:36:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BF=97=E6=84=BF=E8=80=85=E5=8F=98=E5=8A=A8mq?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/epmet/dao/IcResiUserDao.java | 2 +- .../epmet/service/IcVolunteerPolyService.java | 11 ++ .../impl/IcVolunteerPolyServiceImpl.java | 187 +++++++++++++++++- .../main/resources/mapper/IcResiUserDao.xml | 4 + 4 files changed, 201 insertions(+), 3 deletions(-) diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java index a8b65b6ed2..8948369dcc 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java @@ -318,5 +318,5 @@ public interface IcResiUserDao extends BaseDao { * @Author zhaoqifeng * @Date 2022/5/19 10:40 */ - List getVolunteerList(@Param("customerId") String customerId); + List getVolunteerList(@Param("customerId") String customerId, @Param("userId") String userId); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcVolunteerPolyService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcVolunteerPolyService.java index 897c0cb136..5f020d1eca 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcVolunteerPolyService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcVolunteerPolyService.java @@ -1,6 +1,7 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.dto.form.mq.MqBaseFormDTO; import com.epmet.commons.tools.page.PageData; import com.epmet.dto.IcVolunteerPolyDTO; import com.epmet.dto.form.VolunteerPolyListFormDTO; @@ -107,4 +108,14 @@ public interface IcVolunteerPolyService extends BaseService page(Map params) { @@ -172,9 +180,13 @@ public class IcVolunteerPolyServiceImpl extends BaseServiceImpl volunteerList = icResiUserDao.getVolunteerList(customerId); + List volunteerList = icResiUserDao.getVolunteerList(customerId, null); if (CollectionUtils.isEmpty(volunteerList)) { volunteerList = new ArrayList<>(); } @@ -204,6 +216,7 @@ public class IcVolunteerPolyServiceImpl extends BaseServiceImpl { + icVolunteer(dto.getCustomerId(), id); + appVolunteer(dto.getCustomerId(), id); + }); + } + } + } + + /** + * 居民信息志愿者变动 + * + * @Param customerId + * @Param userId + * @Return + * @Author zhaoqifeng + * @Date 2022/5/19 16:55 + */ + private void icVolunteer(String customerId, String userId) { + IcResiUserEntity icUser = icResiUserDao.selectById(userId); + if (null != icUser) { + //设置wrapper条件 + List volunteerList = icResiUserDao.getVolunteerList(customerId, null); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(IcVolunteerPolyEntity::getCustomerId, customerId); + wrapper.eq(IcVolunteerPolyEntity::getIcResiUser, userId); + + LambdaQueryWrapper categoryWrapper = new LambdaQueryWrapper<>(); + categoryWrapper.eq(IcVolunteerPolyCategoryEntity::getCustomerId, customerId); + categoryWrapper.eq(IcVolunteerPolyCategoryEntity::getIdCard, icUser.getIdCard()); + + //判断是否是志愿者 + if (NumConstant.ONE_STR.equals(icUser.getIsVolunteer())) { + if (CollectionUtils.isNotEmpty(volunteerList)) { + + IcVolunteerPolyEntity volunteer = baseDao.selectOne(wrapper); + IcVolunteerPolyEntity entity = ConvertUtils.sourceToTarget(volunteerList.get(NumConstant.ZERO), IcVolunteerPolyEntity.class); + if (null != volunteer) { + entity.setId(volunteer.getId()); + baseDao.updateById(entity); + } else { + baseDao.insert(entity); + } + List categoryList = Arrays.asList(volunteerList.get(NumConstant.ZERO).getVolunteerCategory().split(StrConstant.COMMA)); + List entityList = categoryList.stream().map(o -> { + IcVolunteerPolyCategoryEntity category = new IcVolunteerPolyCategoryEntity(); + category.setCustomerId(entity.getCustomerId()); + category.setIdCard(entity.getIdCard()); + if (null != volunteer) { + category.setLatitude(volunteer.getLatitude()); + category.setLongitude(volunteer.getLongitude()); + } + category.setVolunteerCategory(o); + return category; + }).collect(Collectors.toList()); + icVolunteerPolyCategoryDao.delete(categoryWrapper); + icVolunteerPolyCategoryService.insertBatch(entityList); + } + } else { + //删除志愿者信息 + baseDao.delete(wrapper); + icVolunteerPolyCategoryDao.delete(categoryWrapper); + } + } + } + + /** + * 居民端小程序志愿者变动 + * + * @Param customerId + * @Param userId + * @Return + * @Author zhaoqifeng + * @Date 2022/5/19 16:55 + */ + private void appVolunteer(String customerId, String userId) { + ResiUserBaseInfoResultDTO user = userBaseInfoDao.selecUserBaseInfoByUserId(userId); + if (null != user) { + //获取志愿者信息 + Result volunteerResult = epmetHeartOpenFeignClient.queryUserVolunteerInfo(userId); + if (!volunteerResult.success()) { + log.error("志愿者变更-获取小程序志愿者失败"); + } + + //判断是否是志愿者 + if (null != volunteerResult.getData()) { + VolunteerInfoDTO appVolunteer = volunteerResult.getData(); + //设置wrapper条件 + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(IcVolunteerPolyEntity::getCustomerId, customerId); + wrapper.eq(IcVolunteerPolyEntity::getUserId, userId); + + LambdaQueryWrapper categoryWrapper = new LambdaQueryWrapper<>(); + categoryWrapper.eq(IcVolunteerPolyCategoryEntity::getCustomerId, customerId); + categoryWrapper.eq(IcVolunteerPolyCategoryEntity::getIdCard, user.getIdNum()); + + IcVolunteerPolyEntity volunteer = baseDao.selectOne(wrapper); + + IcVolunteerPolyEntity entity = new IcVolunteerPolyEntity(); + entity.setUserId(userId); + entity.setCustomerId(customerId); + entity.setAgencyId(appVolunteer.getPid()); + entity.setAgencyPids(appVolunteer.getPids()); + entity.setGender(user.getGender()); + entity.setName(user.getRealName()); + entity.setIdCard(user.getIdNum()); + + //根据身份证判断有没有匹配的居民信息 + LambdaQueryWrapper icUserWrapper = new LambdaQueryWrapper<>(); + icUserWrapper.eq(IcResiUserEntity::getCustomerId, customerId); + icUserWrapper.eq(IcResiUserEntity::getIdCard, user.getIdNum()); + IcResiUserEntity icResiUser = icResiUserDao.selectOne(icUserWrapper); + + + if (null != volunteer && StringUtils.isBlank(volunteer.getIcResiUser())) { + entity.setId(volunteer.getId()); + if (null != icResiUser) { + entity.setIcResiUser(icResiUser.getId()); + } + baseDao.updateById(entity); + + IcVolunteerPolyCategoryEntity category = new IcVolunteerPolyCategoryEntity(); + category.setCustomerId(entity.getCustomerId()); + category.setIdCard(entity.getIdCard()); + category.setLatitude(volunteer.getLatitude()); + category.setLongitude(volunteer.getLongitude()); + category.setVolunteerCategory("qita"); + + icVolunteerPolyCategoryDao.delete(categoryWrapper); + icVolunteerPolyCategoryDao.insert(category); + } else if (null == volunteer) { + if (null != icResiUser) { + entity.setIcResiUser(icResiUser.getId()); + } + baseDao.insert(entity); + IcVolunteerPolyCategoryEntity category = new IcVolunteerPolyCategoryEntity(); + category.setCustomerId(entity.getCustomerId()); + category.setIdCard(entity.getIdCard()); + category.setLatitude(volunteer.getLatitude()); + category.setLongitude(volunteer.getLongitude()); + category.setVolunteerCategory("qita"); + + icVolunteerPolyCategoryDao.delete(categoryWrapper); + icVolunteerPolyCategoryDao.insert(category); + } + } + } + } + + private List getUserInfoList(List userIds) { LambdaQueryWrapper userInfoWrapper = new LambdaQueryWrapper<>(); userInfoWrapper.in(UserBaseInfoEntity::getUserId, userIds); diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml index 7204a7b22b..dbd3f7a285 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml @@ -974,6 +974,7 @@