| | |
| | | package com.panzhihua.service_community.message; |
| | | |
| | | import static java.util.Objects.nonNull; |
| | | |
| | | import java.util.List; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import cn.binarywang.wx.miniapp.api.WxMaService; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.panzhihua.common.model.vos.community.ComActDynVO; |
| | | import com.panzhihua.service_community.dao.ComActDAO; |
| | | import com.panzhihua.service_community.dao.SysUserDao; |
| | | import com.panzhihua.service_community.model.dos.ComActDO; |
| | | import org.springframework.amqp.rabbit.annotation.RabbitListener; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.panzhihua.common.model.vos.LoginUserInfoVO; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.community.ComActDynVO; |
| | | import com.panzhihua.common.model.vos.community.acid.ComActAcidDangerMemberVO; |
| | | import com.panzhihua.common.model.vos.community.acid.ComActAcidMemberVO; |
| | | import com.panzhihua.common.model.vos.community.acid.ComActAcidRecordVO; |
| | |
| | | import com.panzhihua.common.utlis.StringUtils; |
| | | import com.panzhihua.common.utlis.WxUtil; |
| | | import com.panzhihua.common.utlis.WxXCXTempSend; |
| | | import com.panzhihua.service_community.dao.ComActDAO; |
| | | import com.panzhihua.service_community.dao.SysUserDao; |
| | | import com.panzhihua.service_community.model.dos.ComActDO; |
| | | import com.panzhihua.service_community.service.ComActAcidMemberService; |
| | | import com.panzhihua.service_community.util.WxMaConfiguration; |
| | | import org.springframework.amqp.rabbit.annotation.RabbitListener; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | | import static java.util.Objects.nonNull; |
| | | |
| | | /** |
| | | * @author zzj |
| | | */ |
| | | @Component |
| | | public class AcidMessage { |
| | | public static final String DELAYED_QUEUE="huacheng.acid.queue"; |
| | | public static final String DELAYED_QUEUE = "huacheng.acid.queue"; |
| | | public static final String ACID_DANGER_QUEUE = "huacheng.acid.danger.queue"; |
| | | public static final String DIRECT_QUEUE="huacheng.acid.direct.queue"; |
| | | public static final String ACID_MESSAGE_QUEUE="huacheng.acid.message.queue"; |
| | | public static final String DIRECT_QUEUE = "huacheng.acid.direct.queue"; |
| | | public static final String ACID_MESSAGE_QUEUE = "huacheng.acid.message.queue"; |
| | | @Resource |
| | | private UserService userService; |
| | | @Resource |
| | |
| | | private ComActDAO comActDAO; |
| | | @Resource |
| | | private SysUserDao sysUserDao; |
| | | @Resource |
| | | private WxMaConfiguration wxMaConfiguration; |
| | | |
| | | @RabbitListener(queues=DELAYED_QUEUE) |
| | | @RabbitListener(queues = DELAYED_QUEUE) |
| | | public void doTemplate(ComActAcidRecordVO comActAcidRecordVO) { |
| | | R<LoginUserInfoVO> loginUserInfoVOR= userService.getUserInfoByUserId(comActAcidRecordVO.getUserId().toString()); |
| | | LoginUserInfoVO loginUserInfoVO=loginUserInfoVOR.getData(); |
| | | if(loginUserInfoVO!=null&& StringUtils.isNotEmpty(loginUserInfoVO.getOpenid())){ |
| | | WxXCXTempSend util = new WxXCXTempSend(); |
| | | String accessToken = null; |
| | | try { |
| | | accessToken = util.getAccessToken(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | WxUtil.sendSubscribeTXTZ(loginUserInfoVO.getOpenid(),accessToken,"pov2BTQ_uILduT5OoVKubeS2dibbZ_p79cy5AMb_BGE"); |
| | | } |
| | | R<LoginUserInfoVO> loginUserInfoVOR = userService.getUserInfoByUserId(comActAcidRecordVO.getUserId().toString()); |
| | | LoginUserInfoVO loginUserInfoVO = loginUserInfoVOR.getData(); |
| | | WxMaService maService = wxMaConfiguration.getMaService("wx118de8a734d269f0"); |
| | | if (loginUserInfoVO != null && StringUtils.isNotEmpty(loginUserInfoVO.getOpenid())) { |
| | | try { |
| | | WxUtil.sendSubscribeTXTZ(loginUserInfoVO.getOpenid(), maService.getAccessToken(), "pov2BTQ_uILduT5OoVKubeS2dibbZ_p79cy5AMb_BGE"); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | @RabbitListener(queues=ACID_DANGER_QUEUE) |
| | | @RabbitListener(queues = ACID_DANGER_QUEUE) |
| | | public void pushMessage(ComActAcidDangerMemberVO dangerMember) { |
| | | R r = comActAcidMemberService.selectPushList(dangerMember.getRelationName()); |
| | | WxMaService maService = wxMaConfiguration.getMaService("wx118de8a734d269f0"); |
| | | if (R.isOk(r) && nonNull(r.getData())) { |
| | | List<ComActAcidMemberVO> members = JSONArray.parseArray(JSONArray.toJSONString(r.getData()), ComActAcidMemberVO.class); |
| | | if (nonNull(members) && !members.isEmpty()) { |
| | | members.forEach(member -> { |
| | | WxXCXTempSend util = new WxXCXTempSend(); |
| | | String accessToken = null; |
| | | try { |
| | | accessToken = util.getAccessToken(); |
| | | WxUtil.sendSubscribeDanger(member.getOpenid(), maService.getAccessToken(), dangerMember, "Yr5idSziLRiRo0t07mcz284sMm41Kr2KsA5UmSc0jWU"); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | WxUtil.sendSubscribeDanger(member.getOpenid(), accessToken, dangerMember, "Yr5idSziLRiRo0t07mcz284sMm41Kr2KsA5UmSc0jWU"); |
| | | |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @RabbitListener(queues = DIRECT_QUEUE) |
| | | public void updateUserInfo(ComActAcidRecordVO comActAcidRecordVO){ |
| | | public void updateUserInfo(ComActAcidRecordVO comActAcidRecordVO) { |
| | | //防疫登记提交默认绑定用户信息 |
| | | R<LoginUserInfoVO> loginUserInfoVOR= userService.getUserInfoByUserId(comActAcidRecordVO.getUserId().toString()); |
| | | if(R.isOk(loginUserInfoVOR)&&loginUserInfoVOR.getData()!=null){ |
| | | LoginUserInfoVO loginUserInfoVO=loginUserInfoVOR.getData(); |
| | | if(StringUtils.isEmpty(loginUserInfoVO.getPhone())||StringUtils.isEmpty(loginUserInfoVO.getIdCard())){ |
| | | R<LoginUserInfoVO> loginUserInfoVOR = userService.getUserInfoByUserId(comActAcidRecordVO.getUserId().toString()); |
| | | if (R.isOk(loginUserInfoVOR) && loginUserInfoVOR.getData() != null) { |
| | | LoginUserInfoVO loginUserInfoVO = loginUserInfoVOR.getData(); |
| | | if (StringUtils.isEmpty(loginUserInfoVO.getPhone()) || StringUtils.isEmpty(loginUserInfoVO.getIdCard())) { |
| | | loginUserInfoVO.setPhone(comActAcidRecordVO.getPhone()); |
| | | loginUserInfoVO.setIdCard(comActAcidRecordVO.getIdCard()); |
| | | loginUserInfoVO.setName(comActAcidRecordVO.getName()); |
| | | if(StringUtils.isNotEmpty(comActAcidRecordVO.getLocalCity())){ |
| | | String town=comActAcidRecordVO.getLocalCity().split(",")[2]; |
| | | String area=comActAcidRecordVO.getLocalCity().split(",")[1]; |
| | | String country=comActAcidRecordVO.getLocalCity().split(",")[0]; |
| | | List<ComActDO> comActDOS=comActDAO.selectList(new QueryWrapper<ComActDO>().lambda().eq(ComActDO::getName,town).eq(ComActDO::getAppId,"wx118de8a734d269f0")); |
| | | if(CollectionUtils.isNotEmpty(comActDOS)){ |
| | | if(comActDOS.size()==1){ |
| | | if (StringUtils.isNotEmpty(comActAcidRecordVO.getLocalCity())) { |
| | | String town = comActAcidRecordVO.getLocalCity().split(",")[2]; |
| | | String area = comActAcidRecordVO.getLocalCity().split(",")[1]; |
| | | String country = comActAcidRecordVO.getLocalCity().split(",")[0]; |
| | | List<ComActDO> comActDOS = comActDAO.selectList(new QueryWrapper<ComActDO>().lambda().eq(ComActDO::getName, town).eq(ComActDO::getAppId, "wx118de8a734d269f0")); |
| | | if (CollectionUtils.isNotEmpty(comActDOS)) { |
| | | if (comActDOS.size() == 1) { |
| | | loginUserInfoVO.setCommunityId(comActDOS.get(0).getCommunityId()); |
| | | } |
| | | else { |
| | | ComActDO comActDO=comActDAO.selectOne(new QueryWrapper<ComActDO>().lambda().eq(ComActDO::getAppId,"wx118de8a734d269f0").eq(ComActDO::getName,town).and(comActDOLambdaQueryWrapper -> comActDOLambdaQueryWrapper.like(ComActDO::getAddress,town).or().like(ComActDO::getAddress,area).or().like(ComActDO::getAddress,country))); |
| | | if(comActDO!=null){ |
| | | } else { |
| | | ComActDO comActDO = comActDAO.selectOne(new QueryWrapper<ComActDO>().lambda().eq(ComActDO::getAppId, "wx118de8a734d269f0").eq(ComActDO::getName, town).and(comActDOLambdaQueryWrapper -> comActDOLambdaQueryWrapper.like(ComActDO::getAddress, town).or().like(ComActDO::getAddress, area).or().like(ComActDO::getAddress, country))); |
| | | if (comActDO != null) { |
| | | loginUserInfoVO.setCommunityId(comActDO.getCommunityId()); |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | @RabbitListener(queues = ACID_MESSAGE_QUEUE) |
| | | public void sendMessage(ComActDynVO comActDynVO){ |
| | | try{ |
| | | List<String> openIds=sysUserDao.selectOpenId(); |
| | | public void sendMessage(ComActDynVO comActDynVO) { |
| | | try { |
| | | List<String> openIds = sysUserDao.selectOpenId(); |
| | | String appId = "wx118de8a734d269f0"; |
| | | WxXCXTempSend wxXCXTempSend=new WxXCXTempSend(); |
| | | WxXCXTempSend wxXCXTempSend = new WxXCXTempSend(); |
| | | WxMaService maService = wxMaConfiguration.getMaService("wx118de8a734d269f0"); |
| | | for (int i = 0; i < openIds.size(); i++) { |
| | | try { |
| | | WxUtil.sendLongTimeTemplate(openIds.get(i),wxXCXTempSend.getAccessTokenValid(appId,i),"疫情快讯",comActDynVO.getTitle().length()>10?comActDynVO.getTitle().substring(0,10)+"..":comActDynVO.getTitle(),"/pages/community_child/community/detail?id="+comActDynVO.getId()+"&title=疫情快讯详情"); |
| | | WxUtil.sendLongTimeTemplate(openIds.get(i), maService.getAccessToken(), "疫情快讯", comActDynVO.getTitle().length() > 10 ? comActDynVO.getTitle().substring(0, 10) + ".." : comActDynVO.getTitle(), "/pages/community_child/community/detail?id=" + comActDynVO.getId() + "&title=疫情快讯详情"); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |