package com.qxueyou.scc.school.service.impl; import java.net.Inet4Address; import java.net.InetAddress; import java.net.NetworkInterface; import java.util.Enumeration; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.stereotype.Service; import com.qxueyou.scc.base.service.IONSExceptionLogService; import com.qxueyou.scc.config.AliOnsConfig; import com.qxueyou.scc.school.service.IHandoutService; /** * Îĵµ´¦ÀíÏûÏ¢¶ÓÁнÓÊÕ·þÎñ * * @author µÂ»¢ * */ @Service("DocdealMsgDealService") @EnableConfigurationProperties(AliOnsConfig.class) public class DocdealMsgDealService{ //public class DocdealMsgDealService extends ONSBaseMsgConsumer implements IONSMsgDealService { @Autowired AliOnsConfig aliOnsConfig; @Autowired IHandoutService handoutService; @Autowired IONSExceptionLogService onsExceptionLogService; @SuppressWarnings("unused") private static Logger log = LogManager.getLogger("ONSExceptionLogService"); // @Override // public void doHandle(Message msg, ConsumeContext context) { // // //TODO ÑϸñÒì³£´¦Àí£¬Á½´Î¾ÍÖ±½Ó·µ»Ø,ÔÝʱһ´Î // try { // // get params // String docPath = msg.getUserProperties("docPath"); // String handoutId = msg.getUserProperties("handoutId"); // String uploadModule = msg.getUserProperties("uploadModule"); // String userId = msg.getUserProperties("userId"); // // // parse office file(ppt\pptx) // // handoutService.insertHandoutPages(docPath, handoutId,uploadModule,userId,"PPT"); // // }catch(Exception e){ // // String businessId = getTopic() + "-" + UUIDUtils.generateUUID(); // String desp = "handoutId:" + msg.getUserProperties("handoutId")+ // ";docPath:" + msg.getUserProperties("docPath") + // ";userId:" + msg.getUserProperties("userId") + // ";uploadModule:" + msg.getUserProperties("uploadModule") ; // // log.error( businessId + " :ÉÏ´«½²ÒåpptÏûÏ¢·¢ËÍʧ°Ü:" + e , e); // onsExceptionLogService.logSaveExceptionLog(getTopic(), "", businessId , desp ); // } // // } // /** * ÅäÖÃÏîons-docdeal-receive-urlsÅäÖÃÁ˶à¸öipµØÖ·£¬Èç¹ûÆäÖаüº¬±¾»úµØÖ·£¬ËµÃ÷Ö§³ÖÎĵµ´¦Àí */ protected boolean turnOn(){ String docdealUrls =aliOnsConfig.getDocdealReceiveUrls(); try { Enumeration nienum = NetworkInterface.getNetworkInterfaces(); while (nienum.hasMoreElements()) { NetworkInterface ni = nienum.nextElement(); Enumeration iaenum = ni.getInetAddresses(); while (iaenum.hasMoreElements()) { InetAddress ia = iaenum.nextElement(); if (ia instanceof Inet4Address&&docdealUrls.contains("#" + ia.getHostAddress() + "#")) { return true; } } } } catch (Exception e) { e.printStackTrace(); } return false; } // @Override // protected String getConsumerId() { // return cfg.getConfigByEnv("ons-docdeal-customer-id"); // } // // @Override // protected String getTopic() { // return cfg.getConfigByEnv("ons-docdeal-topic"); // } }