Browse Source

Merge branch 'dev_party_mange' of http://git.elinkit.com.cn:7070/r/epmet-cloud into dev_party_mange

master
wangxianzhang 3 years ago
parent
commit
8902c07574
  1. 22
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/PartyUnitListbriefFormDTO.java
  2. 4
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/PartyUnitListbrieResultDTO.java
  3. 12
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetHeartOpenFeignClient.java
  4. 15
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/fallback/EpmetHeartOpenFeignClientFallback.java
  5. 3
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcPartyUnitController.java
  6. 6
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiVolunteerController.java
  7. 2
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcPartyUnitDao.java
  8. 2
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcPartyUnitService.java
  9. 10
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/VolunteerInfoService.java
  10. 8
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPartyUnitServiceImpl.java
  11. 36
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/VolunteerInfoServiceImpl.java
  12. 34
      epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcPartyUnitDao.xml
  13. 14
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcVolunteerPolyDTO.java
  14. 12
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcVolunteerPolyController.java
  15. 10
      epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java
  16. 3
      epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcVolunteerPolyDao.java
  17. 13
      epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcVolunteerPolyEntity.java
  18. 20
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcVolunteerPolyService.java
  19. 299
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcVolunteerPolyServiceImpl.java
  20. 24
      epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml
  21. 8
      epmet-user/epmet-user-server/src/main/resources/mapper/IcVolunteerPolyDao.xml

22
epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/PartyUnitListbriefFormDTO.java

@ -5,20 +5,36 @@ import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class PartyUnitListbriefFormDTO extends PageFormDTO implements Serializable {
public class PartyUnitListbriefFormDTO implements Serializable {
private static final long serialVersionUID = -2776705671944626707L;
/**
* 页码
*/
@NotNull
@Min(1)
private Integer pageNo;
/**
* 每页记录数
*/
@NotNull
private Integer pageSize;
/**
* 网格id
*/
private String gridId;
// private String gridId;
/**
* 组织id
@ -51,5 +67,7 @@ public class PartyUnitListbriefFormDTO extends PageFormDTO implements Serializab
*/
private String contactMobile;
private String customerId;
}

4
epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/PartyUnitListbrieResultDTO.java

@ -21,12 +21,12 @@ public class PartyUnitListbrieResultDTO implements Serializable {
/**
* 所属网格
*/
private String gridName;
// private String gridName;
/**
* 所属网格id
*/
private String gridId;
// private String gridId;
/**
* 分类

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);
}
}

3
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcPartyUnitController.java

@ -245,8 +245,9 @@ public class IcPartyUnitController {
*/
@PostMapping("/listbrief")
public Result<PageData> getListbrief(@RequestBody PartyUnitListbriefFormDTO form, @LoginUser TokenDto tokenDto) {
form.setCustomerId(tokenDto.getCustomerId());
ValidatorUtils.validateEntity(form);
PageData data = icPartyUnitService.getListbrief(form, tokenDto);
PageData data = icPartyUnitService.getListbrief(form);
return new Result<PageData>().ok(data);
}

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));
}
}

2
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcPartyUnitDao.java

@ -81,7 +81,7 @@ public interface IcPartyUnitDao extends BaseDao<IcPartyUnitEntity> {
* @author LZN
* @date 2022/5/18 13:54
*/
List<PartyUnitListbrieResultDTO> getListbrief(PartyUnitListbriefFormDTO form, String customerId);
List<PartyUnitListbrieResultDTO> getListbrief(@Param("form") PartyUnitListbriefFormDTO form, @Param("customerId") String customerId);
/**
* 联建单位-按分类统计数量及占比

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

@ -171,7 +171,7 @@ public interface IcPartyUnitService extends BaseService<IcPartyUnitEntity> {
*
* @param form
*/
PageData getListbrief(PartyUnitListbriefFormDTO form, TokenDto tokenDto);
PageData getListbrief(PartyUnitListbriefFormDTO form);
/**
* 联建单位-按分类统计数量及占比

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);
}

8
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPartyUnitServiceImpl.java

@ -599,18 +599,18 @@ public class IcPartyUnitServiceImpl extends BaseServiceImpl<IcPartyUnitDao, IcPa
}
@Override
public PageData getListbrief(PartyUnitListbriefFormDTO form, TokenDto tokenDto) {
public PageData getListbrief(PartyUnitListbriefFormDTO form) {
PageHelper.startPage(form.getPageNo(), form.getPageSize());
List<PartyUnitListbrieResultDTO> dto = baseDao.getListbrief(form, tokenDto.getCustomerId());
List<PartyUnitListbrieResultDTO> dto = baseDao.getListbrief(form, form.getCustomerId());
// 获取gridName
for (PartyUnitListbrieResultDTO item : dto) {
/*for (PartyUnitListbrieResultDTO item : dto) {
if (StringUtils.isNotEmpty(item.getGridId())) {
GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(item.getGridId());
if (null != gridInfo) {
item.setGridName(gridInfo.getGridName());
}
}
}
}*/
PageInfo<PartyUnitListbrieResultDTO> info = new PageInfo<>(dto);
return new PageData<>(dto, info.getTotal());
}

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());
}
}

34
epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcPartyUnitDao.xml

@ -76,35 +76,35 @@
<select id="getListbrief" resultType="com.epmet.dto.result.PartyUnitListbrieResultDTO">
SELECT
a.id,
b.GRID_ID,
-- b.GRID_ID,
a.UNIT_NAME,
a.type,
a.SERVICE_MATTER
FROM
ic_party_unit a
LEFT JOIN ic_party_activity b ON a.id = b.UNIT_ID
AND b.DEL_FLAG = '0'
-- LEFT JOIN ic_party_activity b ON a.id = b.UNIT_ID
-- AND b.DEL_FLAG = '0'
<where>
a.DEL_FLAG = '0'
AND a.AGENCY_ID = #{agencyId}
AND a.AGENCY_ID = #{form.agencyId}
AND a.CUSTOMER_ID = #{customerId}
<if test="gridId != null and gridId != ''">
AND b.GRID_ID = #{gridId}
</if>
<if test="unitName != null and unitName != ''">
AND a.UNIT_NAME = #{unitName}
<!-- <if test="gridId != null and gridId != ''">-->
<!-- AND b.GRID_ID = #{form.gridId}-->
<!-- </if>-->
<if test="form.unitName != null and form.unitName != ''">
AND a.UNIT_NAME = #{form.unitName}
</if>
<if test="serviceMatter != null and serviceMatter != ''">
AND a.SERVICE_MATTER = #{serviceMatter}
<if test="form.serviceMatter != null and form.serviceMatter != ''">
AND a.SERVICE_MATTER = #{form.serviceMatter}
</if>
<if test="type != null and type != ''">
AND a.type = #{type}
<if test="form.type != null and form.type != ''">
AND a.type = #{form.type}
</if>
<if test="contact != null and contact != ''">
AND a.CONTACT = #{contact}
<if test="form.contact != null and form.contact != ''">
AND a.CONTACT = #{form.contact}
</if>
<if test="contactMobile != null and contactMobile != ''">
AND a.CONTACT_MOBILE = #{contactMobile}
<if test="form.contactMobile != null and form.contactMobile != ''">
AND a.CONTACT_MOBILE = #{form.contactMobile}
</if>
</where>
order by

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, @Param("userId") String userId);
}

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姓名
*/

20
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;
@ -98,4 +99,23 @@ 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);
/**
* 志愿者变动
*
* @Param dto
* @Return
* @Author zhaoqifeng
* @Date 2022/5/19 16:02
*/
void volunteerChanged(MqBaseFormDTO dto);
}

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

@ -1,34 +1,55 @@
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.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;
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.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.PartyUnitListbrieResultDTO;
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;
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 +58,19 @@ 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;
@Resource
private IcVolunteerPolyCategoryDao icVolunteerPolyCategoryDao;
@Override
public PageData<IcVolunteerPolyDTO> page(Map<String, Object> params) {
@ -138,4 +170,265 @@ 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
@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, null);
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());
item.setGender(userInfo.getGender());
}
//小程序与居民信息匹配不上的志愿者拿出来
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);
});
}
}
/**
* 志愿者变动
*
* @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);
return userBaseInfoDao.selectList(userInfoWrapper);
}
}

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

@ -972,4 +972,28 @@
</if>
</select>
<select id="getVolunteerList" resultType="com.epmet.dto.IcVolunteerPolyDTO">
SELECT
a.ID AS icResiUser,
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}
<if test="null != userId and userId.trim() != ''">
AND a.ID = #{userId}
</if>
</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