You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
admin-client-temperature/src/main/java/com/rehome/mqttclienttemperature/AdminClientTemperatureAppli...

111 lines
4.0 KiB
Java

3 years ago
package com.rehome.mqttclienttemperature;
import com.rehome.mqttclienttemperature.service.TemperatureEspService;
3 years ago
import com.rehome.mqttclienttemperature.service.TemperatureService;
9 months ago
import lombok.extern.slf4j.Slf4j;
3 years ago
import org.springframework.beans.BeansException;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.scheduling.annotation.EnableAsync;
3 years ago
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.bind.annotation.RequestMapping;
10 months ago
import javax.annotation.Resource;
3 years ago
import java.util.Map;
9 months ago
@Slf4j
2 months ago
//@EnableScheduling
//@EnableAsync
3 years ago
@SpringBootApplication
11 months ago
public class AdminClientTemperatureApplication implements CommandLineRunner, ApplicationContextAware {
3 years ago
/**
* Spring
*/
private ApplicationContext applicationContext;
/**
*/
@Resource
private TemperatureService temperatureService;
/**
*/
@Resource
private TemperatureEspService temperatureEspService;
3 years ago
public static void main(String[] args) {
SpringApplication.run(AdminClientTemperatureApplication.class, args);
}
/**
* applicationContext(main使,mainstatic,)
* @param args
*/
@Override
public void run(String... args) throws Exception {
//在这里可以调用applicationContext了
Map<String, Object> controllers = applicationContext.getBeansWithAnnotation(RequestMapping.class);
for (Map.Entry<String, Object> entry : controllers.entrySet()) {
9 months ago
log.info("------------------------");
log.info(entry.getKey());//demo1Controller
3 years ago
}
try {
2 months ago
if (temperatureService != null) {
log.info("------------------------");
log.info("TemperatureController is not empty");
MqttRSAClient client = new MqttRSAClient();
//client.start(temperatureService);
}else {
log.info("temperatureService is empty");
}
6 months ago
// if (temperatureService != null) {
// log.info("------------------------");
// log.info("TemperatureController is not empty");
2 months ago
// MqttHuaWeiYunClient client = new MqttHuaWeiYunClient();
6 months ago
// client.start(temperatureService);
// }else {
// log.info("temperatureService is empty");
// }
2 months ago
if (temperatureEspService != null) {
9 months ago
log.info("------------------------");
2 months ago
log.info("temperatureEspService is not empty");
MqttDianDengTechClient client = new MqttDianDengTechClient();
//client.start(temperatureEspService);
11 months ago
}else {
2 months ago
log.info("temperatureEspService is empty");
3 years ago
}
4 months ago
String DeviceAlermInfoPwd = "";
String strPrivateEncode = RSAAndroid.encryptByPrivateKeyForSpiltStr("AnFang@2025",RSAAndroid.privateRsaKeyLocal);
System.out.println("---------strPrivateEncode----------");
System.out.println(strPrivateEncode);
String strPublicDecode = RSAAndroid.decryptByPublicKeyForSpiltStr(
strPrivateEncode,
RSAAndroid.publicRsaKeyLocal
);
System.out.println("---------strPublicDecode----------");
System.out.println(strPublicDecode);
3 years ago
} catch (Exception ex) {
ex.printStackTrace();
}
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
}
}