|
|
@ -1,15 +1,19 @@ |
|
|
|
package com.epmet.modules.partyOrg.service.impl; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.epmet.commons.rocketmq.messages.PartyMeetingMessageMQMsg; |
|
|
|
import com.epmet.commons.tools.constant.Constant; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; |
|
|
|
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.page.PageData; |
|
|
|
import com.epmet.commons.tools.redis.common.CustomerStaffRedis; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.DateUtils; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.commons.tools.utils.SpringContextUtils; |
|
|
|
import com.epmet.modules.partyOrg.dao.*; |
|
|
|
import com.epmet.modules.partyOrg.entity.IcPartyActEntity; |
|
|
@ -19,6 +23,8 @@ import com.epmet.modules.partyOrg.service.IcPartyActOrgService; |
|
|
|
import com.epmet.modules.partyOrg.service.IcPartyActService; |
|
|
|
import com.epmet.modules.partyOrg.service.IcPartyOrgService; |
|
|
|
import com.epmet.modules.partyOrg.service.ResiPartymemberAttachmentService; |
|
|
|
import com.epmet.resi.group.dto.member.ResiGroupMemberDTO; |
|
|
|
import com.epmet.resi.group.feign.ResiGroupOpenFeignClient; |
|
|
|
import com.epmet.resi.partymember.dto.icpartyact.form.IcPartyActAddOrUpdateFormDTO; |
|
|
|
import com.epmet.resi.partymember.dto.icpartyact.form.IcPartyActPageFormDTO; |
|
|
|
import com.epmet.resi.partymember.dto.icpartyact.result.IcPartActTypeDTO; |
|
|
@ -47,7 +53,8 @@ import java.util.stream.Collectors; |
|
|
|
*/ |
|
|
|
@Service |
|
|
|
public class IcPartyActServiceImpl extends BaseServiceImpl<IcPartyActDao, IcPartyActEntity> implements IcPartyActService { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private ResiGroupOpenFeignClient resiGroupOpenFeignClient; |
|
|
|
@Autowired |
|
|
|
private IcScheduleDao scheduleDao; |
|
|
|
@Autowired |
|
|
@ -262,6 +269,102 @@ public class IcPartyActServiceImpl extends BaseServiceImpl<IcPartyActDao, IcPart |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public List<ActAndScheduleListResultDTO> homeSearch(ActAndScheduleListFormDTO formDTO) { |
|
|
|
return null; |
|
|
|
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getStaffId()); |
|
|
|
if (null == staffInfo){ |
|
|
|
throw new EpmetException("查询工作人员失败:"+formDTO.getStaffId()); |
|
|
|
} |
|
|
|
formDTO.setAgencyId(staffInfo.getAgencyId()); |
|
|
|
IcPartyOrgDTO icPartyOrgDTO = partyOrgService.get(formDTO.getOrgId()); |
|
|
|
if (null == icPartyOrgDTO){ |
|
|
|
throw new EpmetException("未查询到党组织信息:"+formDTO.getOrgId()); |
|
|
|
} |
|
|
|
formDTO.setPath(icPartyOrgDTO.getOrgPids().equals("") || icPartyOrgDTO.getOrgPids().equals(NumConstant.ZERO_STR) ? icPartyOrgDTO.getId() : icPartyOrgDTO.getOrgPids().concat(":").concat(icPartyOrgDTO.getId())); |
|
|
|
List<ActAndScheduleListResultDTO> result = constructHomeSearchData(formDTO.getStartDate(), formDTO.getEndDate()); |
|
|
|
List<ActAndScheduleListResultDTO.ActivityListDTO> activityList = baseDao.getActivityList(formDTO); |
|
|
|
if (CollectionUtils.isNotEmpty(activityList)){ |
|
|
|
activityList.forEach(a -> { |
|
|
|
a.setIsMe(formDTO.getStaffId().equals(a.getStaffId())); |
|
|
|
}); |
|
|
|
Map<String, List<ActAndScheduleListResultDTO.ActivityListDTO>> groupByDateId = activityList.stream().collect(Collectors.groupingBy(ActAndScheduleListResultDTO.ActivityListDTO::getDateId)); |
|
|
|
result.forEach(r -> { |
|
|
|
groupByDateId.forEach((dateId,list) -> { |
|
|
|
if (r.getDateId().equals(dateId)){ |
|
|
|
r.setActivityList(list); |
|
|
|
r.setActivityTotal(list.size()); |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
List<ActAndScheduleListResultDTO.ScheduleListDTO> scheduleList = scheduleDao.getScheduleList(formDTO); |
|
|
|
if (CollectionUtils.isNotEmpty(scheduleList)){ |
|
|
|
scheduleList.forEach(s -> { |
|
|
|
s.setIsMe(formDTO.getStaffId().equals(s.getStaffId())); |
|
|
|
}); |
|
|
|
Map<String, List<ActAndScheduleListResultDTO.ScheduleListDTO>> groupByDateId = scheduleList.stream().collect(Collectors.groupingBy(ActAndScheduleListResultDTO.ScheduleListDTO::getDateId)); |
|
|
|
result.forEach(r -> { |
|
|
|
groupByDateId.forEach((dateId,list) -> { |
|
|
|
if (r.getDateId().equals(dateId)){ |
|
|
|
r.setScheduleList(list); |
|
|
|
r.setScheduleTotal(list.size()); |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
public static List<ActAndScheduleListResultDTO> constructHomeSearchData(String startDate,String endDate){ |
|
|
|
List<ActAndScheduleListResultDTO> result = new ArrayList<>(); |
|
|
|
if (StringUtils.isNotBlank(startDate) && StringUtils.isNotBlank(endDate)){ |
|
|
|
List<String> days = DateUtils.getDaysBetween(startDate, endDate); |
|
|
|
days.forEach(d -> { |
|
|
|
ActAndScheduleListResultDTO dto = new ActAndScheduleListResultDTO(); |
|
|
|
dto.setDateId(d); |
|
|
|
result.add(dto); |
|
|
|
}); |
|
|
|
} |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 党建小助手活动触发为用户推送消息 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void partyMeetingMessage(PartyMeetingMessageMQMsg formDTO) { |
|
|
|
//1.校验活动数据是否存在
|
|
|
|
IcPartyActEntity entity = baseDao.selectById(formDTO.getIcPartyActId()); |
|
|
|
if(null==entity){ |
|
|
|
String msg = "活动信息不存在,活动Id:" + formDTO.getIcPartyActId(); |
|
|
|
throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(), msg, msg); |
|
|
|
} |
|
|
|
//2.根据不同类型消息触发不同处理逻辑
|
|
|
|
//2-1.发布活动给居民端涉及党员已经工作端活动发布站推送党建活动消息
|
|
|
|
if("publish".equals(formDTO.getType())){ |
|
|
|
//查询活动对应的发布范围信息
|
|
|
|
LambdaQueryWrapper<IcPartyActOrgEntity> orgWrapper = new LambdaQueryWrapper<>(); |
|
|
|
orgWrapper.eq(IcPartyActOrgEntity::getDelFlag, NumConstant.ZERO_STR); |
|
|
|
orgWrapper.eq(IcPartyActOrgEntity::getIcPartyActId, formDTO.getIcPartyActId()); |
|
|
|
List<IcPartyActOrgEntity> list = icPartyActOrgDao.selectList(orgWrapper); |
|
|
|
List<String> groupIdList = list.stream().filter(ca -> ca.getOrgType().equals("6")).map(m -> m.getJoinOrgId()).collect(Collectors.toList()); |
|
|
|
List<String> partyOrgIdList = list.stream().filter(ca -> !ca.getOrgType().equals("6")).map(m -> m.getJoinOrgId()).collect(Collectors.toList()); |
|
|
|
//分别查询党组织、党小组下的人
|
|
|
|
List<String> userIdList = new ArrayList<>(); |
|
|
|
if(!CollectionUtils.isEmpty(groupIdList)){ |
|
|
|
Result<List<ResiGroupMemberDTO>> result = resiGroupOpenFeignClient.getMemberList(groupIdList); |
|
|
|
if (!result.success()) { |
|
|
|
throw new RenException("调用common service查询secret失败"); |
|
|
|
} |
|
|
|
userIdList = result.getData().stream().map(ResiGroupMemberDTO::getCustomerUserId).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
if(!CollectionUtils.isEmpty(groupIdList)){ |
|
|
|
//TODO
|
|
|
|
} |
|
|
|
|
|
|
|
//组装消息
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |