Commit 302eb8c9 authored by Carit Zhu's avatar Carit Zhu 🎱

Modify logger info for setState interface in GatewayController.

parent 1af72a5e
Pipeline #377 passed with stage
in 0 seconds
......@@ -15,7 +15,7 @@ public class SwaggerConfig {
@Bean
public Docket testApi() {
return new Docket(DocumentationType.SWAGGER_2)
.groupName("test")
.groupName("logistics")
.genericModelSubstitutes(DeferredResult.class)
.useDefaultResponseMessages(false)
.forCodeGeneration(true)
......
......@@ -19,7 +19,7 @@ public class GatewaySNAndTypeVo {
public GatewaySNAndTypeVo(String SN, String type, Integer New) {
this.SN = SN;
this.type = type;
New = New;
this.New = New;
}
public Integer getNew() {
......
......@@ -336,15 +336,13 @@ public class GatewayController {
})
@RequestMapping(value="/setState",method = RequestMethod.POST)
public String setState(@RequestBody GatewayState device){
logger.info("t1:" + System.currentTimeMillis());
if (device.getbConfig() == false) {
if (!device.getbConfig()) {
fb.setCode(0);
fb.setMessage("该网关未配置通道");
return gson.toJson(fb);
}
//根据设备的SN,TYPE获取所有通道
List<ResultProbesVo> list = probesService.getProbesByGateway(device.getSN(),device.getType());
logger.info("t2:" + System.currentTimeMillis());
if (list.size() == 0) {
fb.setCode(0);
fb.setMessage("该网关未配置通道");
......@@ -353,9 +351,8 @@ public class GatewayController {
DeviceConfigVo deviceConfig = new DeviceConfigVo();
//获取网关创建时间
ResultGatewayVo resultGatewayVo = gatewayService.getBySNAndType(device.getSN(),device.getType());
logger.info("t3:" + System.currentTimeMillis());
Integer New = 0;
if(resultGatewayVo.getCreateTime()>1535940000000l){
if(resultGatewayVo != null && resultGatewayVo.getCreateTime()>1535940000000l){
deviceConfig.setType(1);
New =1;
}else{
......@@ -370,7 +367,6 @@ public class GatewayController {
infoRedisService.hmSet("DeviceConfig", device.getType() + "_" + device.getSN(), deviceConfig.toString());
//查询该设备所有的主题类型0-发布,1-订阅,2-发布并订阅
List<ResultTopicVo> topicList = topicService.getByGateway(new GatewaySNAndTypeVo(device.getSN(),device.getType()));
logger.info("t4:" + System.currentTimeMillis());
//将数据放到redis中
List<String> pubList = new ArrayList<>();
List<String> subList = new ArrayList<>();
......@@ -401,29 +397,30 @@ public class GatewayController {
infoRedisService.delHashKey("TopicConfig", topic.getTopicName());
}
}
logger.info("t5:" + System.currentTimeMillis());
infoRedisService.hmSet("SubTopic", device.getType() + "_" + device.getSN(), subList.toString());
infoRedisService.hmSet("PubTopic", device.getType() + "_" + device.getSN(), pubList.toString());
if (device.getState() == 0) {
//挂载
logger.info("t6:" + System.currentTimeMillis());
String sr = HttpRequester.sendPost(addmount, gson.toJson(new GatewaySNAndTypeVo(device.getSN(), device.getType(),New)));
logger.info("t7:" + System.currentTimeMillis());
logger.info("---Mount device " + device.getSN() + "_" + device.getType() + " ---");
String param = gson.toJson(new GatewaySNAndTypeVo(device.getSN(), device.getType(),New));
logger.info("---Mount param: " + param);
String sr = HttpRequester.sendPost(addmount, param);
logger.info("---Mount result: " + sr);
device.setState(1);
} else if (device.getState() == 1) {
//卸载
logger.info("t6:" + System.currentTimeMillis());
String sr = HttpRequester.sendPost(delmount, gson.toJson(new GatewaySNAndTypeVo(device.getSN(), device.getType())));
logger.info("t7:" + System.currentTimeMillis());
logger.info("---Unmount device " + device.getSN() + "_" + device.getType() + " ---");
String param = gson.toJson(new GatewaySNAndTypeVo(device.getSN(), device.getType()));
logger.info("---Unmount param: " + param);
String sr = HttpRequester.sendPost(delmount, param);
logger.info("---Unmount result: " + sr);
device.setState(0);
infoRedisService.delHashKey("DeviceConfig", device.getType() + "_" + device.getSN());
infoRedisService.delHashKey("SubTopic", device.getType() + "_" + device.getSN());
infoRedisService.delHashKey("PubTopic", device.getType() + "_" + device.getSN());
}
try{
logger.info("t8:" + System.currentTimeMillis());
Boolean boo = gatewayService.updateState(device);
logger.info("t9:" + System.currentTimeMillis());
if (!boo) {
fb.setCode(0);
fb.setMessage("修改失败");
......@@ -432,9 +429,8 @@ public class GatewayController {
fb.setMessage("修改成功");
}
} catch (Exception e) {
logger.info("t10:" + System.currentTimeMillis());
e.printStackTrace();
logger.info(e.toString());
//e.printStackTrace();
logger.info("setState exception: " + e.getMessage());
}
return gson.toJson(fb);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment