| | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.core.annotation.Java110Synchronized; |
| | | import com.java110.core.factory.GenerateCodeFactory; |
| | | import com.java110.core.factory.WechatFactory; |
| | | import com.java110.core.smo.ISaveTransactionLogSMO; |
| | | import com.java110.dto.RoomDto; |
| | | import com.java110.dto.app.AppDto; |
| | | import com.java110.dto.community.CommunityDto; |
| | | import com.java110.dto.logSystemError.LogSystemErrorDto; |
| | | import com.java110.dto.notice.NoticeDto; |
| | | import com.java110.dto.owner.OwnerAppUserDto; |
| | | import com.java110.dto.owner.OwnerRoomRelDto; |
| | |
| | | import com.java110.intf.user.IOwnerAppUserInnerServiceSMO; |
| | | import com.java110.intf.user.IOwnerRoomRelInnerServiceSMO; |
| | | import com.java110.job.quartz.TaskSystemQuartz; |
| | | import com.java110.po.logSystemError.LogSystemErrorPo; |
| | | import com.java110.po.transactionLog.TransactionLogPo; |
| | | import com.java110.service.smo.ISaveSystemErrorSMO; |
| | | import com.java110.utils.cache.MappingCache; |
| | | import com.java110.utils.constant.WechatConstant; |
| | | import com.java110.utils.util.DateUtil; |
| | | import com.java110.utils.util.ExceptionUtil; |
| | | import com.java110.utils.util.StringUtil; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | |
| | | @Autowired |
| | | private RestTemplate outRestTemplate; |
| | | |
| | | @Autowired |
| | | private ISaveSystemErrorSMO saveSystemErrorSMOImpl; |
| | | |
| | | //模板信息推送地址 |
| | | private static String sendMsgUrl = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token="; |
| | | private static String getUser = "https://api.weixin.qq.com/cgi-bin/user/get?access_token=ACCESS_TOKEN"; |
| | |
| | | try { |
| | | publishMsg(taskDto, communityDto); |
| | | } catch (Exception e) { |
| | | LogSystemErrorPo logSystemErrorPo = new LogSystemErrorPo(); |
| | | logSystemErrorPo.setErrId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_errId)); |
| | | logSystemErrorPo.setErrType(LogSystemErrorDto.ERR_TYPE_NOTICE); |
| | | logSystemErrorPo.setMsg(ExceptionUtil.getStackTrace(e)); |
| | | saveSystemErrorSMOImpl.saveLog(logSystemErrorPo); |
| | | logger.error("推送消息失败", e); |
| | | } |
| | | } |
| | |
| | | try { |
| | | doSentWechat(tmpNotice, templateId, accessToken, weChatDto); |
| | | } catch (Exception e) { |
| | | LogSystemErrorPo logSystemErrorPo = new LogSystemErrorPo(); |
| | | logSystemErrorPo.setErrId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_errId)); |
| | | logSystemErrorPo.setErrType(LogSystemErrorDto.ERR_TYPE_NOTICE); |
| | | logSystemErrorPo.setMsg(ExceptionUtil.getStackTrace(e)); |
| | | saveSystemErrorSMOImpl.saveLog(logSystemErrorPo); |
| | | logger.error("通知异常", e); |
| | | } |
| | | } |
| | |
| | | |
| | | private void doSentWechat(NoticeDto noticeDto, String templateId, String accessToken, SmallWeChatDto weChatDto) throws Exception { |
| | | |
| | | Date startTime = DateUtil.getDateFromString(noticeDto.getStartTime(), DateUtil.DATE_FORMATE_STRING_A); |
| | | Date nowTime = DateUtil.getCurrentDate(); |
| | | if (startTime.getTime() > nowTime.getTime()) { //还没有到时间 |
| | | return; |
| | | } |
| | | // Date startTime = DateUtil.getDateFromString(noticeDto.getStartTime(), DateUtil.DATE_FORMATE_STRING_A); |
| | | // Date nowTime = DateUtil.getCurrentDate(); |
| | | // if (startTime.getTime() > nowTime.getTime()) { //还没有到时间 |
| | | // return; |
| | | // } |
| | | |
| | | |
| | | String objType = noticeDto.getObjType(); |
| | |
| | | responseEntity = outRestTemplate.postForEntity(sendTemplate + accessToken, JSON.toJSONString(templateMessage), String.class); |
| | | logger.info("微信模板返回内容:{}", responseEntity); |
| | | } catch (Exception e) { |
| | | LogSystemErrorPo logSystemErrorPo = new LogSystemErrorPo(); |
| | | logSystemErrorPo.setErrId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_errId)); |
| | | logSystemErrorPo.setErrType(LogSystemErrorDto.ERR_TYPE_NOTICE); |
| | | logSystemErrorPo.setMsg(ExceptionUtil.getStackTrace(e)); |
| | | saveSystemErrorSMOImpl.saveLog(logSystemErrorPo); |
| | | logger.error("发送失败", e); |
| | | } finally { |
| | | doSaveLog(startTime, DateUtil.getCurrentDate(), "/pages/notice/detail/detail", JSON.toJSONString(templateMessage), responseEntity, appUserDto.getOpenId()); |
| | |
| | | responseEntity = outRestTemplate.postForEntity(sendTemplate + accessToken, JSON.toJSONString(templateMessage), String.class); |
| | | logger.info("微信模板返回内容:{}", responseEntity); |
| | | } catch (Exception e) { |
| | | LogSystemErrorPo logSystemErrorPo = new LogSystemErrorPo(); |
| | | logSystemErrorPo.setErrId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_errId)); |
| | | logSystemErrorPo.setErrType(LogSystemErrorDto.ERR_TYPE_NOTICE); |
| | | logSystemErrorPo.setMsg(ExceptionUtil.getStackTrace(e)); |
| | | saveSystemErrorSMOImpl.saveLog(logSystemErrorPo); |
| | | logger.error("发送失败", e); |
| | | } finally { |
| | | doSaveLog(startTime, DateUtil.getCurrentDate(), "/pages/notice/detail/detail", JSON.toJSONString(templateMessage), responseEntity, openId); |