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