diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/constant/WxmpMessageConstant.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/constant/WxmpMessageConstant.java index 667a8b3bfc..07350f0695 100644 --- a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/constant/WxmpMessageConstant.java +++ b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/constant/WxmpMessageConstant.java @@ -22,7 +22,9 @@ public interface WxmpMessageConstant { String RESI = "resi"; - String WORK = "work"; + String GOV_REDIS = "work"; + + String GOV_DB = "gov"; String ACCESS_TOKEN = "access_token"; diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/WxmpMessageServiceImpl.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/WxmpMessageServiceImpl.java index 832ef44a33..c7b938a6ff 100644 --- a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/WxmpMessageServiceImpl.java +++ b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/WxmpMessageServiceImpl.java @@ -86,34 +86,34 @@ public class WxmpMessageServiceImpl implements WxmpMessageService { @Autowired private WxmpMsgSendRecordService wxmpMsgSendRecordService; - @Autowired - private WxmpUserSubscribeRecordDao subscribeRecordDao; - - /** - * @Description 保存系统授权信息 - * @return void - * @author wxz - * @date 2020.10.21 17:29 - */ - @Override - public void saveSysAuthorizeInfo(String customerId, String clientType, String alwaysVisit, String subscribeStatus, String userId, String templateId) { - WxmpTemplateMsgSubscribeStatusEntity userSubscribeStatusEntity = msgSubscribeStatusDao.getUserSubscribeStatusEntity(userId, customerId, clientType, templateId); - if (userSubscribeStatusEntity != null) { - userSubscribeStatusEntity.setAlwaysVisit(alwaysVisit); - userSubscribeStatusEntity.setSubscribeStatus(subscribeStatus); - msgSubscribeStatusDao.updateById(userSubscribeStatusEntity); - return; - } - - userSubscribeStatusEntity = new WxmpTemplateMsgSubscribeStatusEntity(); - userSubscribeStatusEntity.setCustomerId(customerId); - userSubscribeStatusEntity.setClientType(clientType); - userSubscribeStatusEntity.setTemplateId(templateId); - userSubscribeStatusEntity.setAlwaysVisit(alwaysVisit); - userSubscribeStatusEntity.setSubscribeStatus(subscribeStatus); - userSubscribeStatusEntity.setUserId(userId); - msgSubscribeStatusDao.insert(userSubscribeStatusEntity); - } + @Autowired + private WxmpUserSubscribeRecordDao subscribeRecordDao; + + /** + * @return void + * @Description 保存系统授权信息 + * @author wxz + * @date 2020.10.21 17:29 + */ + @Override + public void saveSysAuthorizeInfo(String customerId, String clientType, String alwaysVisit, String subscribeStatus, String userId, String templateId) { + WxmpTemplateMsgSubscribeStatusEntity userSubscribeStatusEntity = msgSubscribeStatusDao.getUserSubscribeStatusEntity(userId, customerId, clientType, templateId); + if (userSubscribeStatusEntity != null) { + userSubscribeStatusEntity.setAlwaysVisit(alwaysVisit); + userSubscribeStatusEntity.setSubscribeStatus(subscribeStatus); + msgSubscribeStatusDao.updateById(userSubscribeStatusEntity); + return; + } + + userSubscribeStatusEntity = new WxmpTemplateMsgSubscribeStatusEntity(); + userSubscribeStatusEntity.setCustomerId(customerId); + userSubscribeStatusEntity.setClientType(clientType); + userSubscribeStatusEntity.setTemplateId(templateId); + userSubscribeStatusEntity.setAlwaysVisit(alwaysVisit); + userSubscribeStatusEntity.setSubscribeStatus(subscribeStatus); + userSubscribeStatusEntity.setUserId(userId); + msgSubscribeStatusDao.insert(userSubscribeStatusEntity); + } /** * @param msgList @@ -139,7 +139,7 @@ public class WxmpMessageServiceImpl implements WxmpMessageService { UserBasicInfoFormDTO userBasicInfoFormDTO = new UserBasicInfoFormDTO(); userBasicInfoFormDTO.setUserId(userId); openId = epmetUserOpenFeignClient.getUserBasicInfo(userBasicInfoFormDTO).getData().getOpenId(); - } else if (WxmpMessageConstant.WORK.equals(clientType)) { + } else if (WxmpMessageConstant.GOV_DB.equals(clientType)) { StaffBasicInfoFormDTO staffBasicInfoFormDTO = new StaffBasicInfoFormDTO(); staffBasicInfoFormDTO.setStaffId(userId); openId = epmetUserOpenFeignClient.getStaffBasicInfo(staffBasicInfoFormDTO).getData().getOpenId(); @@ -155,7 +155,14 @@ public class WxmpMessageServiceImpl implements WxmpMessageService { } //获取accessToken - StringBuilder key = new StringBuilder(msg.getCustomerId()).append(":").append(msg.getClientType()); + String clientTypeRedis = null; + if (WxmpMessageConstant.RESI.equals(msg.getClientType())){ + clientTypeRedis = WxmpMessageConstant.RESI; + } + if (WxmpMessageConstant.GOV_DB.equals(msg.getClientType())){ + clientTypeRedis = WxmpMessageConstant.GOV_REDIS; + } + StringBuilder key = new StringBuilder(msg.getCustomerId()).append(":").append(clientTypeRedis); Map authorizerRefreshToken = new HashMap<>(); try { authorizerRefreshToken = wxmpMessageRedis.getAuthorizerRefreshToken(key.toString()); @@ -170,7 +177,7 @@ public class WxmpMessageServiceImpl implements WxmpMessageService { //获取模板id if (WxmpMessageConstant.RESI.equals(clientType)) { templateId = wxmpResiUserSubscribeDao.getResiSubscribeTemplateId(openId, customerId); - } else if (WxmpMessageConstant.WORK.equals(clientType)) { + } else if (WxmpMessageConstant.GOV_DB.equals(clientType)) { templateId = wxmpWorkUserSubscribeDao.getWorkSubscribeTemplateId(openId, customerId); } if (StringUtils.isBlank(templateId)) { @@ -181,7 +188,7 @@ public class WxmpMessageServiceImpl implements WxmpMessageService { Integer count = null; if (WxmpMessageConstant.RESI.equals(clientType)) { count = wxmpResiUserSubscribeDao.getResiSubscribeInfo(openId, templateId, customerId); - } else if (WxmpMessageConstant.WORK.equals(clientType)) { + } else if (WxmpMessageConstant.GOV_DB.equals(clientType)) { count = wxmpWorkUserSubscribeDao.getWorkSubscribeInfo(openId, templateId, customerId); } if (count == null) { @@ -199,15 +206,22 @@ public class WxmpMessageServiceImpl implements WxmpMessageService { jsonObject.put(WxmpMessageConstant.ACCESS_TOKEN, accessToken); jsonObject.put(WxmpMessageConstant.TOUSER, openId); jsonObject.put(WxmpMessageConstant.TEMPLATE_ID, templateId); - data.put(WxmpMessageConstant.TITLE, new JSONObject().put("value", ("您有一条" + msg.getBehaviorType()).substring(0, WxmpMessageConstant.TITLE_LIMIT))); - data.put(WxmpMessageConstant.MESSAGE_CONTENT, new JSONObject().put("value", msg.getMessageContent().substring(0, WxmpMessageConstant.MESSAGE_CONTENT_LIMIT))); - data.put(WxmpMessageConstant.MESSAGE_TIME, new JSONObject().put("value", new SimpleDateFormat("yyyy-MM-dd HH:mm").format(msg.getMessageTime()))); + String title = "您有一条" + msg.getBehaviorType(); + JSONObject titleJson = new JSONObject(); + titleJson.put("value", title.length() > WxmpMessageConstant.TITLE_LIMIT ? title.substring(0, WxmpMessageConstant.TITLE_LIMIT) : title); + data.put(WxmpMessageConstant.TITLE, titleJson); + JSONObject contentJson = new JSONObject(); + contentJson.put("value", msg.getMessageContent().length() > WxmpMessageConstant.MESSAGE_CONTENT_LIMIT ? msg.getMessageContent().substring(0, WxmpMessageConstant.MESSAGE_CONTENT_LIMIT) : msg.getMessageContent()); + data.put(WxmpMessageConstant.MESSAGE_CONTENT, contentJson); + JSONObject timeJson = new JSONObject(); + timeJson.put("value", new SimpleDateFormat("yyyy-MM-dd HH:mm").format(msg.getMessageTime())); + data.put(WxmpMessageConstant.MESSAGE_TIME,timeJson); jsonObject.put(WxmpMessageConstant.DATA, data); EnvEnum envEnum = EnvEnum.getCurrentEnv(); //选填项 if (WxmpMessageConstant.RESI.equals(clientType)) { jsonObject.put(WxmpMessageConstant.PAGE, WxmpMessageConstant.PAGE_RESI); - } else if (WxmpMessageConstant.WORK.equals(clientType)) { + } else if (WxmpMessageConstant.GOV_DB.equals(clientType)) { jsonObject.put(WxmpMessageConstant.PAGE, WxmpMessageConstant.PAGE_WORK); } //开发环境 @@ -229,7 +243,7 @@ public class WxmpMessageServiceImpl implements WxmpMessageService { int decrease = 0; if (WxmpMessageConstant.RESI.equals(clientType)) { decrease = wxmpResiUserSubscribeDao.decreaseResiSubscribeCount(openId, templateId, customerId, 1); - } else if (WxmpMessageConstant.WORK.equals(clientType)) { + } else if (WxmpMessageConstant.GOV_DB.equals(clientType)) { decrease = wxmpWorkUserSubscribeDao.decreaseWorkSubscribeCount(openId, templateId, customerId, 1); } if (decrease == 0) { @@ -247,7 +261,7 @@ public class WxmpMessageServiceImpl implements WxmpMessageService { int clear = 0; if (WxmpMessageConstant.RESI.equals(clientType)) { clear = wxmpResiUserSubscribeDao.clearResiSubscribeCount(openId, templateId, customerId); - } else if (WxmpMessageConstant.WORK.equals(clientType)) { + } else if (WxmpMessageConstant.GOV_DB.equals(clientType)) { clear = wxmpWorkUserSubscribeDao.clearWorkSubscribeCount(openId, templateId, customerId); } if (clear == 0) { @@ -256,7 +270,7 @@ public class WxmpMessageServiceImpl implements WxmpMessageService { } //抛出错误 - throw new WxSubscribeException(String.valueOf(resultMap.get(WxmpMessageConstant.ERR_MSG)),templateId, openId); + throw new WxSubscribeException(String.valueOf(resultMap.get(WxmpMessageConstant.ERR_MSG)), templateId, openId); } succecssCount++; @@ -299,175 +313,175 @@ public class WxmpMessageServiceImpl implements WxmpMessageService { return wxmpMsgSendRecordEntity; } - /** - * @return - * @Description 居民端、工作端-获取客户小程序模板列表 - * @author sun - */ - @Override - public List templateList(GetTemplateListFormDTO formDTO) { - GetTemplateListFormDTO dto = ConvertUtils.sourceToTarget(formDTO, GetTemplateListFormDTO.class); - String url = "https://epmet-cloud.elinkservice.cn/api/third/personaltemplate/templatelist"; - //String url = "http://localhost:8080/api/third/personaltemplate/templatelist"; - String data = HttpClientManager.getInstance().sendPostByJSON(url, JSON.toJSONString(dto)).getData(); - logger.info("ThirdLoginServiceImpl.getUserWeChat:httpclient->url:"+url+",结果->"+data); - JSONObject toResult = JSON.parseObject(data); - Result mapToResult = ConvertUtils.mapToEntity(toResult, Result.class); - if (null != toResult.get("code")) { - mapToResult.setCode(((Integer) toResult.get("code")).intValue()); - } - if (!mapToResult.success()) { - logger.error("调用epmet_third服务获取小程序消息订阅模板数据失败"); - throw new RenException(mapToResult.getCode()); - } - List resultList = (List) mapToResult.getData(); - return resultList; - } - - @Override - public WxMsgAuthInfoResultDTO getAuthorizationInfo(String customerId, String clientType, String loginUserId, String templateId) { - return msgSubscribeStatusDao.getUserSubscribeStatusDTO(loginUserId, customerId, clientType, templateId); - } - - @Override - public void saveWxSubscribe(String customerId, String clientType, String templateId, String wxAlwaysVisit, - String wxSubscribeStatus, String behaviorType, String userId) { - - String openId; - // 1. 用户订阅信息表新增或者更新 - if (AppClientConstant.APP_GOV.equals(clientType)) { - // 工作端 - openId = getWorkOpenId(userId); - saveWxWorkSubscribe(customerId, templateId, wxSubscribeStatus, userId, openId); - } else { - //居民端 - openId = getResiOpenId(userId); - saveWxResiSubscribe(customerId, templateId, wxSubscribeStatus, userId, openId); - } - - // 2.保存行为记录 - WxmpUserSubscribeRecordEntity record = new WxmpUserSubscribeRecordEntity(); - record.setBehaviorType(behaviorType); - record.setCustomerId(customerId); - record.setTemplateId(templateId); - record.setUserId(userId); - record.setWxAlwaysVisit(wxAlwaysVisit); - record.setWxOpenId(openId); - record.setWxSubscribeStatus(wxSubscribeStatus); - subscribeRecordDao.insert(record); - - // 3.更新用户模板订阅状态 - WxmpTemplateMsgSubscribeStatusEntity subscribeStatusEntity = msgSubscribeStatusDao.getUserSubscribeStatusEntity(userId, customerId, clientType, templateId); - if (subscribeStatusEntity == null) { - subscribeStatusEntity = new WxmpTemplateMsgSubscribeStatusEntity(); - subscribeStatusEntity.setUserId(userId); - subscribeStatusEntity.setWxSubscribeStatus(wxSubscribeStatus); - subscribeStatusEntity.setTemplateId(templateId); - subscribeStatusEntity.setWxAlwaysVisit(wxAlwaysVisit); - subscribeStatusEntity.setCustomerId(customerId); - subscribeStatusEntity.setClientType(clientType); - msgSubscribeStatusDao.insert(subscribeStatusEntity); - return; - } - - subscribeStatusEntity.setWxAlwaysVisit(wxAlwaysVisit); - subscribeStatusEntity.setWxSubscribeStatus(wxSubscribeStatus); - - msgSubscribeStatusDao.updateById(subscribeStatusEntity); - } - - /** - * @Description 保存居民端微信订阅信息 - * @return void - * @author wxz - * @date 2020.10.22 09:56 - */ - private void saveWxResiSubscribe(String customerId, String templateId, String wxSubscribeStatus, String userId, String openId) { - - WxmpResiUserSubscribeEntity wxResiSubscribe = wxmpResiUserSubscribeDao.getWxResiSubscribe(userId, customerId, templateId); - if (wxResiSubscribe == null) { - WxmpResiUserSubscribeEntity insert = new WxmpResiUserSubscribeEntity(); - insert.setCount(WxMsgTemplateSubscribeStatus.SUBSCRIBE.equals(wxSubscribeStatus) ? 1 : 0); - insert.setCustomerId(customerId); - insert.setTemplateId(templateId); - insert.setUserId(userId); - insert.setWxOpenId(openId); - insert.setWxSubscribeStatus(wxSubscribeStatus); - return; - } - - if (WxMsgTemplateSubscribeStatus.SUBSCRIBE.equals(wxSubscribeStatus)) { + /** + * @return + * @Description 居民端、工作端-获取客户小程序模板列表 + * @author sun + */ + @Override + public List templateList(GetTemplateListFormDTO formDTO) { + GetTemplateListFormDTO dto = ConvertUtils.sourceToTarget(formDTO, GetTemplateListFormDTO.class); + String url = "https://epmet-cloud.elinkservice.cn/api/third/personaltemplate/templatelist"; + //String url = "http://localhost:8080/api/third/personaltemplate/templatelist"; + String data = HttpClientManager.getInstance().sendPostByJSON(url, JSON.toJSONString(dto)).getData(); + logger.info("ThirdLoginServiceImpl.getUserWeChat:httpclient->url:" + url + ",结果->" + data); + JSONObject toResult = JSON.parseObject(data); + Result mapToResult = ConvertUtils.mapToEntity(toResult, Result.class); + if (null != toResult.get("code")) { + mapToResult.setCode(((Integer) toResult.get("code")).intValue()); + } + if (!mapToResult.success()) { + logger.error("调用epmet_third服务获取小程序消息订阅模板数据失败"); + throw new RenException(mapToResult.getCode()); + } + List resultList = (List) mapToResult.getData(); + return resultList; + } + + @Override + public WxMsgAuthInfoResultDTO getAuthorizationInfo(String customerId, String clientType, String loginUserId, String templateId) { + return msgSubscribeStatusDao.getUserSubscribeStatusDTO(loginUserId, customerId, clientType, templateId); + } + + @Override + public void saveWxSubscribe(String customerId, String clientType, String templateId, String wxAlwaysVisit, + String wxSubscribeStatus, String behaviorType, String userId) { + + String openId; + // 1. 用户订阅信息表新增或者更新 + if (AppClientConstant.APP_GOV.equals(clientType)) { + // 工作端 + openId = getWorkOpenId(userId); + saveWxWorkSubscribe(customerId, templateId, wxSubscribeStatus, userId, openId); + } else { + //居民端 + openId = getResiOpenId(userId); + saveWxResiSubscribe(customerId, templateId, wxSubscribeStatus, userId, openId); + } + + // 2.保存行为记录 + WxmpUserSubscribeRecordEntity record = new WxmpUserSubscribeRecordEntity(); + record.setBehaviorType(behaviorType); + record.setCustomerId(customerId); + record.setTemplateId(templateId); + record.setUserId(userId); + record.setWxAlwaysVisit(wxAlwaysVisit); + record.setWxOpenId(openId); + record.setWxSubscribeStatus(wxSubscribeStatus); + subscribeRecordDao.insert(record); + + // 3.更新用户模板订阅状态 + WxmpTemplateMsgSubscribeStatusEntity subscribeStatusEntity = msgSubscribeStatusDao.getUserSubscribeStatusEntity(userId, customerId, clientType, templateId); + if (subscribeStatusEntity == null) { + subscribeStatusEntity = new WxmpTemplateMsgSubscribeStatusEntity(); + subscribeStatusEntity.setUserId(userId); + subscribeStatusEntity.setWxSubscribeStatus(wxSubscribeStatus); + subscribeStatusEntity.setTemplateId(templateId); + subscribeStatusEntity.setWxAlwaysVisit(wxAlwaysVisit); + subscribeStatusEntity.setCustomerId(customerId); + subscribeStatusEntity.setClientType(clientType); + msgSubscribeStatusDao.insert(subscribeStatusEntity); + return; + } + + subscribeStatusEntity.setWxAlwaysVisit(wxAlwaysVisit); + subscribeStatusEntity.setWxSubscribeStatus(wxSubscribeStatus); + + msgSubscribeStatusDao.updateById(subscribeStatusEntity); + } + + /** + * @return void + * @Description 保存居民端微信订阅信息 + * @author wxz + * @date 2020.10.22 09:56 + */ + private void saveWxResiSubscribe(String customerId, String templateId, String wxSubscribeStatus, String userId, String openId) { + + WxmpResiUserSubscribeEntity wxResiSubscribe = wxmpResiUserSubscribeDao.getWxResiSubscribe(userId, customerId, templateId); + if (wxResiSubscribe == null) { + WxmpResiUserSubscribeEntity insert = new WxmpResiUserSubscribeEntity(); + insert.setCount(WxMsgTemplateSubscribeStatus.SUBSCRIBE.equals(wxSubscribeStatus) ? 1 : 0); + insert.setCustomerId(customerId); + insert.setTemplateId(templateId); + insert.setUserId(userId); + insert.setWxOpenId(openId); + insert.setWxSubscribeStatus(wxSubscribeStatus); + return; + } + + if (WxMsgTemplateSubscribeStatus.SUBSCRIBE.equals(wxSubscribeStatus)) { wxmpResiUserSubscribeDao.incrSubscribeCount(1, userId, customerId, templateId, openId); - } else { + } else { wxmpResiUserSubscribeDao.unSubscribe(userId, customerId, templateId, openId); - } - } - - /** - * @Description 保存工作端订阅信息 - * @return void - * @author wxz - * @date 2020.10.22 14:21 - */ - private void saveWxWorkSubscribe(String customerId, String templateId, String wxSubscribeStatus, String userId, String openId) { - WxmpWorkUserSubscribeEntity wxWorkSubscribe = wxmpWorkUserSubscribeDao.getWxWorkSubscribe(userId, customerId, templateId); - if (wxWorkSubscribe == null) { - WxmpWorkUserSubscribeEntity insert = new WxmpWorkUserSubscribeEntity(); - insert.setCount(WxMsgTemplateSubscribeStatus.SUBSCRIBE.equals(wxSubscribeStatus) ? 1 : 0); - insert.setCustomerId(customerId); - insert.setTemplateId(templateId); - insert.setUserId(userId); - insert.setWxOpenId(openId); - insert.setWxSubscribeStatus(wxSubscribeStatus); - wxmpWorkUserSubscribeDao.insert(insert); - return ; - } - - if (WxMsgTemplateSubscribeStatus.SUBSCRIBE.equals(wxSubscribeStatus)) { - wxmpWorkUserSubscribeDao.incrSubscribeCount(1, userId, customerId, templateId, openId); - } else { - wxmpWorkUserSubscribeDao.unSubscribe(userId, customerId, templateId, openId); - } - - } - - /** - * @Description 根据UserId查询居民OpenId - * @return string - * @author wxz - * @date 2020.10.22 13:35 - */ - public String getResiOpenId(String userId) { - UserBasicInfoFormDTO bif = new UserBasicInfoFormDTO(); - bif.setUserId(userId); - Result result = epmetUserOpenFeignClient.getUserBasicInfo(bif); - if (!result.success()) { - throw new RenException(String.format("查询居民OpenId失败,userId:%s,错误信息:%s",userId , result.getInternalMsg())); - } - UserBasicInfo userBasicInfo = result.getData(); - if (userBasicInfo == null) { - throw new RenException(String.format("根据userId:%s,没有查询到居民OpenId",userId)); - } - return userBasicInfo.getOpenId(); - } - - /** - * @Description 查询工作人员openId - * @return java.lang.String - * @author wxz - * @date 2020.10.22 14:46 - */ - public String getWorkOpenId(String userId) { - StaffBasicInfoFormDTO form = new StaffBasicInfoFormDTO(); - form.setStaffId(userId); - Result result = epmetUserOpenFeignClient.getStaffBasicInfo(form); - if (!result.success()) { - throw new RenException(String.format("查询工作人员OpenId失败,userId:%s,错误信息:%s",userId , result.getInternalMsg())); - } - StaffBasicInfo staffBasicInfo = result.getData(); - if (staffBasicInfo == null) { - throw new RenException(String.format("根据userId:%s,没有查询到工作人员OpenId",userId)); - } - return staffBasicInfo.getOpenId(); - } + } + } + + /** + * @return void + * @Description 保存工作端订阅信息 + * @author wxz + * @date 2020.10.22 14:21 + */ + private void saveWxWorkSubscribe(String customerId, String templateId, String wxSubscribeStatus, String userId, String openId) { + WxmpWorkUserSubscribeEntity wxWorkSubscribe = wxmpWorkUserSubscribeDao.getWxWorkSubscribe(userId, customerId, templateId); + if (wxWorkSubscribe == null) { + WxmpWorkUserSubscribeEntity insert = new WxmpWorkUserSubscribeEntity(); + insert.setCount(WxMsgTemplateSubscribeStatus.SUBSCRIBE.equals(wxSubscribeStatus) ? 1 : 0); + insert.setCustomerId(customerId); + insert.setTemplateId(templateId); + insert.setUserId(userId); + insert.setWxOpenId(openId); + insert.setWxSubscribeStatus(wxSubscribeStatus); + wxmpWorkUserSubscribeDao.insert(insert); + return; + } + + if (WxMsgTemplateSubscribeStatus.SUBSCRIBE.equals(wxSubscribeStatus)) { + wxmpWorkUserSubscribeDao.incrSubscribeCount(1, userId, customerId, templateId, openId); + } else { + wxmpWorkUserSubscribeDao.unSubscribe(userId, customerId, templateId, openId); + } + + } + + /** + * @return string + * @Description 根据UserId查询居民OpenId + * @author wxz + * @date 2020.10.22 13:35 + */ + public String getResiOpenId(String userId) { + UserBasicInfoFormDTO bif = new UserBasicInfoFormDTO(); + bif.setUserId(userId); + Result result = epmetUserOpenFeignClient.getUserBasicInfo(bif); + if (!result.success()) { + throw new RenException(String.format("查询居民OpenId失败,userId:%s,错误信息:%s", userId, result.getInternalMsg())); + } + UserBasicInfo userBasicInfo = result.getData(); + if (userBasicInfo == null) { + throw new RenException(String.format("根据userId:%s,没有查询到居民OpenId", userId)); + } + return userBasicInfo.getOpenId(); + } + + /** + * @return java.lang.String + * @Description 查询工作人员openId + * @author wxz + * @date 2020.10.22 14:46 + */ + public String getWorkOpenId(String userId) { + StaffBasicInfoFormDTO form = new StaffBasicInfoFormDTO(); + form.setStaffId(userId); + Result result = epmetUserOpenFeignClient.getStaffBasicInfo(form); + if (!result.success()) { + throw new RenException(String.format("查询工作人员OpenId失败,userId:%s,错误信息:%s", userId, result.getInternalMsg())); + } + StaffBasicInfo staffBasicInfo = result.getData(); + if (staffBasicInfo == null) { + throw new RenException(String.format("根据userId:%s,没有查询到工作人员OpenId", userId)); + } + return staffBasicInfo.getOpenId(); + } }