|
|
@ -7,6 +7,9 @@ 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.dto.form.mq.MqBaseFormDTO; |
|
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
|
import com.epmet.commons.tools.exception.EpmetException; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.redis.common.CustomerIcHouseRedis; |
|
|
|
import com.epmet.commons.tools.redis.common.CustomerOrgRedis; |
|
|
@ -15,13 +18,17 @@ import com.epmet.commons.tools.redis.common.bean.HouseInfoCache; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.dao.IcResiUserDao; |
|
|
|
import com.epmet.dao.IcVolunteerPolyCategoryDao; |
|
|
|
import com.epmet.dao.IcVolunteerPolyDao; |
|
|
|
import com.epmet.dao.UserBaseInfoDao; |
|
|
|
import com.epmet.dto.IcVolunteerPolyDTO; |
|
|
|
import com.epmet.dto.VolunteerInfoDTO; |
|
|
|
import com.epmet.dto.form.VolunteerPolyListFormDTO; |
|
|
|
import com.epmet.dto.form.VolunteerPolyMapDataFormDTO; |
|
|
|
import com.epmet.dto.result.ResiUserBaseInfoResultDTO; |
|
|
|
import com.epmet.dto.result.VolunteerPolyListResultDTO; |
|
|
|
import com.epmet.dto.result.VolunteerPolyMapDataResultDTO; |
|
|
|
import com.epmet.entity.IcResiUserEntity; |
|
|
|
import com.epmet.entity.IcVolunteerPolyCategoryEntity; |
|
|
|
import com.epmet.entity.IcVolunteerPolyEntity; |
|
|
|
import com.epmet.entity.UserBaseInfoEntity; |
|
|
@ -62,7 +69,8 @@ public class IcVolunteerPolyServiceImpl extends BaseServiceImpl<IcVolunteerPolyD |
|
|
|
private UserBaseInfoDao userBaseInfoDao; |
|
|
|
@Resource |
|
|
|
private IcVolunteerPolyCategoryService icVolunteerPolyCategoryService; |
|
|
|
|
|
|
|
@Resource |
|
|
|
private IcVolunteerPolyCategoryDao icVolunteerPolyCategoryDao; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<IcVolunteerPolyDTO> page(Map<String, Object> params) { |
|
|
@ -172,9 +180,13 @@ public class IcVolunteerPolyServiceImpl extends BaseServiceImpl<IcVolunteerPolyD |
|
|
|
* @Date 2022/5/19 10:00 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void volunteerDataExtraction(String customerId) { |
|
|
|
if (StringUtils.isEmpty(customerId)) { |
|
|
|
throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(), "客户ID不能为空", "客户ID不能为空"); |
|
|
|
} |
|
|
|
//获取居民信息表的志愿者
|
|
|
|
List<IcVolunteerPolyDTO> volunteerList = icResiUserDao.getVolunteerList(customerId); |
|
|
|
List<IcVolunteerPolyDTO> volunteerList = icResiUserDao.getVolunteerList(customerId, null); |
|
|
|
if (CollectionUtils.isEmpty(volunteerList)) { |
|
|
|
volunteerList = new ArrayList<>(); |
|
|
|
} |
|
|
@ -204,6 +216,7 @@ public class IcVolunteerPolyServiceImpl extends BaseServiceImpl<IcVolunteerPolyD |
|
|
|
item.setName(userInfo.getRealName()); |
|
|
|
item.setIdCard(userInfo.getIdNum()); |
|
|
|
item.setMobile(userInfo.getMobile()); |
|
|
|
item.setGender(userInfo.getGender()); |
|
|
|
} |
|
|
|
//小程序与居民信息匹配不上的志愿者拿出来
|
|
|
|
if (!volunteerMap.containsKey(item.getIdCard())) { |
|
|
@ -242,6 +255,176 @@ public class IcVolunteerPolyServiceImpl extends BaseServiceImpl<IcVolunteerPolyD |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 志愿者变动 |
|
|
|
* |
|
|
|
* @param dto |
|
|
|
* @Param dto |
|
|
|
* @Return |
|
|
|
* @Author zhaoqifeng |
|
|
|
* @Date 2022/5/19 16:02 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void volunteerChanged(MqBaseFormDTO dto) { |
|
|
|
if (StringUtils.isBlank(dto.getObjectId()) && CollectionUtils.isEmpty(dto.getObjectIdList())) { |
|
|
|
volunteerDataExtraction(dto.getCustomerId()); |
|
|
|
} else { |
|
|
|
if (StringUtils.isNotBlank(dto.getObjectId())) { |
|
|
|
icVolunteer(dto.getCustomerId(), dto.getObjectId()); |
|
|
|
appVolunteer(dto.getCustomerId(), dto.getObjectId()); |
|
|
|
} |
|
|
|
if (CollectionUtils.isNotEmpty(dto.getObjectIdList())) { |
|
|
|
dto.getObjectIdList().forEach(id -> { |
|
|
|
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<IcVolunteerPolyDTO> volunteerList = icResiUserDao.getVolunteerList(customerId, null); |
|
|
|
LambdaQueryWrapper<IcVolunteerPolyEntity> wrapper = new LambdaQueryWrapper<>(); |
|
|
|
wrapper.eq(IcVolunteerPolyEntity::getCustomerId, customerId); |
|
|
|
wrapper.eq(IcVolunteerPolyEntity::getIcResiUser, userId); |
|
|
|
|
|
|
|
LambdaQueryWrapper<IcVolunteerPolyCategoryEntity> 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<String> categoryList = Arrays.asList(volunteerList.get(NumConstant.ZERO).getVolunteerCategory().split(StrConstant.COMMA)); |
|
|
|
List<IcVolunteerPolyCategoryEntity> 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<VolunteerInfoDTO> volunteerResult = epmetHeartOpenFeignClient.queryUserVolunteerInfo(userId); |
|
|
|
if (!volunteerResult.success()) { |
|
|
|
log.error("志愿者变更-获取小程序志愿者失败"); |
|
|
|
} |
|
|
|
|
|
|
|
//判断是否是志愿者
|
|
|
|
if (null != volunteerResult.getData()) { |
|
|
|
VolunteerInfoDTO appVolunteer = volunteerResult.getData(); |
|
|
|
//设置wrapper条件
|
|
|
|
LambdaQueryWrapper<IcVolunteerPolyEntity> wrapper = new LambdaQueryWrapper<>(); |
|
|
|
wrapper.eq(IcVolunteerPolyEntity::getCustomerId, customerId); |
|
|
|
wrapper.eq(IcVolunteerPolyEntity::getUserId, userId); |
|
|
|
|
|
|
|
LambdaQueryWrapper<IcVolunteerPolyCategoryEntity> 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<IcResiUserEntity> 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<UserBaseInfoEntity> getUserInfoList(List<String> userIds) { |
|
|
|
LambdaQueryWrapper<UserBaseInfoEntity> userInfoWrapper = new LambdaQueryWrapper<>(); |
|
|
|
userInfoWrapper.in(UserBaseInfoEntity::getUserId, userIds); |
|
|
|