Commit cc9776bc authored by zhuangzhuang's avatar zhuangzhuang

3.28-获取线路的详细信息,获取线路数据

parent 1f632754
...@@ -110,8 +110,8 @@ public class GWConfigWorker implements Callable<String>, MqttCallback { ...@@ -110,8 +110,8 @@ public class GWConfigWorker implements Callable<String>, MqttCallback {
mqttAsyncClient.subscribe(RespTopic, qos);//订阅主题 mqttAsyncClient.subscribe(RespTopic, qos);//订阅主题
} }
//获取数据 //获取数据
//ConfigVo configVo = configService.getConfig(SN,Type); ConfigVo configVo = configService.getConfig(SN,Type);
//ConfigCMD = configVo.getMessage(); ConfigCMD = configVo.getMessage();
//发送数据 //发送数据
publish(ConfigCMD,ConfigTopic); publish(ConfigCMD,ConfigTopic);
} catch (MqttException e){ } catch (MqttException e){
...@@ -175,15 +175,15 @@ public class GWConfigWorker implements Callable<String>, MqttCallback { ...@@ -175,15 +175,15 @@ public class GWConfigWorker implements Callable<String>, MqttCallback {
this.ret_data = Message; this.ret_data = Message;
//解析Message消息 //解析Message消息
RespVo respVo = new Gson().fromJson(Message,RespVo.class); RespVo respVo = new Gson().fromJson(Message,RespVo.class);
// if(respVo.getResponse().equals("config")){ if(respVo.getResponse().equals("config")){
// //配置回复 //配置回复
// configService.bindiSuccess(SN,Type,respVo.getStatus()); configService.bindiSuccess(SN,Type,respVo.getStatus());
// }else{ }else{
// //解绑回复 //解绑回复
// if(respVo.getStatus() ==0 || respVo.getStatus() == 1){ if(respVo.getStatus() ==0 || respVo.getStatus() == 1){
// configService.delConfig(SN,Type); configService.delConfig(SN,Type);
// } }
// } }
if(NeedResp){ if(NeedResp){
mqttAsyncClient.unsubscribe(RespTopic);//不监听回复主题 mqttAsyncClient.unsubscribe(RespTopic);//不监听回复主题
} }
......
...@@ -2,22 +2,12 @@ package com.example.tdl.domain.vo; ...@@ -2,22 +2,12 @@ package com.example.tdl.domain.vo;
public class AlarmLogVo { public class AlarmLogVo {
private String TDLSN;
private String description; private String description;
private Float data; private String data;
private Long alarmTime; private Long alarmTime;
public String getTDLSN() {
return TDLSN;
}
public void setTDLSN(String TDLSN) {
this.TDLSN = TDLSN;
}
public String getDescription() { public String getDescription() {
return description; return description;
} }
...@@ -26,11 +16,11 @@ public class AlarmLogVo { ...@@ -26,11 +16,11 @@ public class AlarmLogVo {
this.description = description; this.description = description;
} }
public Float getData() { public String getData() {
return data; return data;
} }
public void setData(Float data) { public void setData(String data) {
this.data = data; this.data = data;
} }
......
package com.example.tdl.domain.vo;
public class ChannelConfigVo {
private Integer port;
private String unit;
private String describe;
private String alias;
public Integer getPort() {
return port;
}
public void setPort(Integer port) {
this.port = port;
}
public String getUnit() {
return unit;
}
public void setUnit(String unit) {
this.unit = unit;
}
public String getDescribe() {
return describe;
}
public void setDescribe(String describe) {
this.describe = describe;
}
public String getAlias() {
return alias;
}
public void setAlias(String alias) {
this.alias = alias;
}
public ChannelConfigVo() {
}
public ChannelConfigVo(Integer port, String unit, String describe, String alias) {
this.port = port;
this.unit = unit;
this.describe = describe;
this.alias = alias;
}
@Override
public String toString() {
return "{" +"\""+
"port"+"\""+":" + port +
","+"\""+ "unit"+"\"" +":"+"\""+ unit +"\"" +
","+"\""+"describe"+"\"" +":"+"\"" + describe +"\"" +
","+"\""+"alias" +"\"" +":"+"\"" + alias + "\"" +
'}';
}
}
package com.example.tdl.domain.vo;
import java.util.List;
public class CircuitMessageVo {
private String transportationNo;
private String cargoNo;//货物编号
private String startCity;
private String endCity;
private Integer circuitState;
private String evaluate;
private List<ResultCityVo> list;
List<ResultAlarmLog> alarmLogList;
public CircuitMessageVo() {
}
public CircuitMessageVo(String transportationNo, String cargoNo, String startCity, String endCity, Integer circuitState, String evaluate, List<ResultAlarmLog> alarmLogList) {
this.transportationNo = transportationNo;
this.cargoNo = cargoNo;
this.startCity = startCity;
this.endCity = endCity;
this.circuitState = circuitState;
this.evaluate = evaluate;
this.alarmLogList = alarmLogList;
}
public String getTransportationNo() {
return transportationNo;
}
public void setTransportationNo(String transportationNo) {
this.transportationNo = transportationNo;
}
public String getCargoNo() {
return cargoNo;
}
public void setCargoNo(String cargoNo) {
this.cargoNo = cargoNo;
}
public String getStartCity() {
return startCity;
}
public void setStartCity(String startCity) {
this.startCity = startCity;
}
public String getEndCity() {
return endCity;
}
public void setEndCity(String endCity) {
this.endCity = endCity;
}
public Integer getCircuitState() {
return circuitState;
}
public void setCircuitState(Integer circuitState) {
this.circuitState = circuitState;
}
public String getEvaluate() {
return evaluate;
}
public void setEvaluate(String evaluate) {
this.evaluate = evaluate;
}
public List<ResultCityVo> getList() {
return list;
}
public void setList(List<ResultCityVo> list) {
this.list = list;
}
public List<ResultAlarmLog> getAlarmLogList() {
return alarmLogList;
}
public void setAlarmLogList(List<ResultAlarmLog> alarmLogList) {
this.alarmLogList = alarmLogList;
}
}
package com.example.tdl.domain.vo;
public class CircuitTransferVo {
private String city;
private Long startTime;
private Long arrivalTime;
private Integer sequence;
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public Long getStartTime() {
return startTime;
}
public void setStartTime(Long startTime) {
this.startTime = startTime;
}
public Long getArrivalTime() {
return arrivalTime;
}
public void setArrivalTime(Long arrivalTime) {
this.arrivalTime = arrivalTime;
}
public Integer getSequence() {
return sequence;
}
public void setSequence(Integer sequence) {
this.sequence = sequence;
}
}
...@@ -5,15 +5,89 @@ public class CircuitVo { ...@@ -5,15 +5,89 @@ public class CircuitVo {
private String cargoNo; private String cargoNo;
private String startCity; private String startCity;//开始城市
private String endCity; private String endCity;//结束城市
private Long startTime; private Long startTime;//开始时间
private Long endTime; private Long endTime;//结束时间
private String lng;
private String lat;
private String time;
public String getTransportationNo() {
return transportationNo;
}
public void setTransportationNo(String transportationNo) {
this.transportationNo = transportationNo;
}
public String getCargoNo() {
return cargoNo;
}
public void setCargoNo(String cargoNo) {
this.cargoNo = cargoNo;
}
public String getStartCity() {
return startCity;
}
public void setStartCity(String startCity) {
this.startCity = startCity;
}
public String getEndCity() {
return endCity;
}
public void setEndCity(String endCity) {
this.endCity = endCity;
}
public Long getStartTime() {
return startTime;
}
public void setStartTime(Long startTime) {
this.startTime = startTime;
}
public Long getEndTime() {
return endTime;
}
public void setEndTime(Long endTime) {
this.endTime = endTime;
}
public String getLng() {
return lng;
}
public void setLng(String lng) {
this.lng = lng;
}
public String getLat() {
return lat;
}
public void setLat(String lat) {
this.lat = lat;
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
} }
package com.example.tdl.domain.vo;
import java.util.List;
public class DeviceConfigVo {
private String config = "Config";
private List<GConfigVo> configList;
public String getConfig() {
return config;
}
public void setConfig(String config) {
this.config = config;
}
public List<GConfigVo> getConfigList() {
return configList;
}
public void setConfigList(List<GConfigVo> configList) {
this.configList = configList;
}
@Override
public String toString() {
return "{" + "\"" + config +"\"" + ":"+ configList + '}';
}
}
package com.example.tdl.domain.vo;
public class GConfigVo {
private Integer port;
private String unit;
private String description;
private String alias;
public GConfigVo() {
}
public GConfigVo(Integer port, String unit, String description, String alias) {
this.port = port;
this.unit = unit;
this.description = description;
this.alias = alias;
}
public Integer getPort() {
return port;
}
public void setPort(Integer port) {
this.port = port;
}
public String getUnit() {
return unit;
}
public void setUnit(String unit) {
this.unit = unit;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getAlias() {
return alias;
}
public void setAlias(String alias) {
this.alias = alias;
}
@Override
public String toString() {
return "{" +"\""+
"port"+"\""+":" + port +
","+"\""+ "unit"+"\"" +":"+"\""+ unit + "\"" +
","+"\""+"description"+"\"" +":"+"\"" + description +"\"" +
","+"\""+"alias" +"\"" +":"+"\"" + alias + "\"" +
'}';
}
}
...@@ -5,6 +5,14 @@ public class GatewaySNAndTypeVo { ...@@ -5,6 +5,14 @@ public class GatewaySNAndTypeVo {
private String type; private String type;
public GatewaySNAndTypeVo() {
}
public GatewaySNAndTypeVo(String SN, String type) {
this.SN = SN;
this.type = type;
}
public String getSN() { public String getSN() {
return SN; return SN;
} }
......
package com.example.tdl.domain.vo;
public class GatewayState {
private String SN;
private String type;
private int state;
private Boolean bConfig;
public String getSN() {
return SN;
}
public void setSN(String SN) {
this.SN = SN;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public int getState() {
return state;
}
public void setState(int state) {
this.state = state;
}
public Boolean getbConfig() {
return bConfig;
}
public void setbConfig(Boolean bConfig) {
this.bConfig = bConfig;
}
}
package com.example.tdl.domain.vo;
public class HistogramData {
private String classify;
private Integer count;
public String getClassify() {
return classify;
}
public void setClassify(String classify) {
this.classify = classify;
}
public Integer getCount() {
return count;
}
public void setCount(Integer count) {
this.count = count;
}
}
...@@ -17,6 +17,8 @@ public class HomePageDataVo { ...@@ -17,6 +17,8 @@ public class HomePageDataVo {
//报警列表 //报警列表
private List<AlarmLogVo> alarmLogVoList; private List<AlarmLogVo> alarmLogVoList;
private List<CircuitVo> circuitList;
public Integer getSum() { public Integer getSum() {
return sum; return sum;
} }
...@@ -64,4 +66,12 @@ public class HomePageDataVo { ...@@ -64,4 +66,12 @@ public class HomePageDataVo {
public void setAlarmLogVoList(List<AlarmLogVo> alarmLogVoList) { public void setAlarmLogVoList(List<AlarmLogVo> alarmLogVoList) {
this.alarmLogVoList = alarmLogVoList; this.alarmLogVoList = alarmLogVoList;
} }
public List<CircuitVo> getCircuitList() {
return circuitList;
}
public void setCircuitList(List<CircuitVo> circuitList) {
this.circuitList = circuitList;
}
} }
package com.example.tdl.domain.vo;
import java.util.List;
public class ProbesConfigVo {
private String name="Channel_Config";
private int intervalTime;
List<ChannelConfigVo> channelConfigs;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getIntervalTime() {
return intervalTime;
}
public void setIntervalTime(int intervalTime) {
this.intervalTime = intervalTime;
}
public List<ChannelConfigVo> getChannelConfigs() {
return channelConfigs;
}
public void setChannelConfigs(List<ChannelConfigVo> channelConfigs) {
this.channelConfigs = channelConfigs;
}
@Override
public String toString() {
return "{" +"\""+ "Interval" +"\""+":" +intervalTime +","+
"\"" + name + '\"'+":" + channelConfigs +
'}';
}
}
...@@ -8,10 +8,12 @@ public class ResultAlarmLog { ...@@ -8,10 +8,12 @@ public class ResultAlarmLog {
private String description; private String description;
private Float data; private String data;
private Long alarmTime; private Long alarmTime;
private String classify;
public String getTransportationNo() { public String getTransportationNo() {
return transportationNo; return transportationNo;
} }
...@@ -36,11 +38,11 @@ public class ResultAlarmLog { ...@@ -36,11 +38,11 @@ public class ResultAlarmLog {
this.description = description; this.description = description;
} }
public Float getData() { public String getData() {
return data; return data;
} }
public void setData(Float data) { public void setData(String data) {
this.data = data; this.data = data;
} }
...@@ -51,4 +53,12 @@ public class ResultAlarmLog { ...@@ -51,4 +53,12 @@ public class ResultAlarmLog {
public void setAlarmTime(Long alarmTime) { public void setAlarmTime(Long alarmTime) {
this.alarmTime = alarmTime; this.alarmTime = alarmTime;
} }
public String getClassify() {
return classify;
}
public void setClassify(String classify) {
this.classify = classify;
}
} }
...@@ -17,6 +17,10 @@ public class ResultCircuitVo { ...@@ -17,6 +17,10 @@ public class ResultCircuitVo {
private String alarmType; private String alarmType;
private String alarm;
private String evaluate;
public String getTransportationNo() { public String getTransportationNo() {
return transportationNo; return transportationNo;
} }
...@@ -80,4 +84,20 @@ public class ResultCircuitVo { ...@@ -80,4 +84,20 @@ public class ResultCircuitVo {
public void setAlarmType(String alarmType) { public void setAlarmType(String alarmType) {
this.alarmType = alarmType; this.alarmType = alarmType;
} }
public String getAlarm() {
return alarm;
}
public void setAlarm(String alarm) {
this.alarm = alarm;
}
public String getEvaluate() {
return evaluate;
}
public void setEvaluate(String evaluate) {
this.evaluate = evaluate;
}
} }
\ No newline at end of file
package com.example.tdl.domain.vo;
public class ResultCityVo {
private String city;
private Long time;
private String last;
private Integer alarmCount;
private Integer type;//1--出发时间;2--目的时间
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public Long getTime() {
return time;
}
public void setTime(Long time) {
this.time = time;
}
public String getLast() {
return last;
}
public void setLast(String last) {
this.last = last;
}
public Integer getAlarmCount() {
return alarmCount;
}
public void setAlarmCount(Integer alarmCount) {
this.alarmCount = alarmCount;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
}
...@@ -2,25 +2,31 @@ package com.example.tdl.mapper; ...@@ -2,25 +2,31 @@ package com.example.tdl.mapper;
import com.example.tdl.domain.vo.AddAlarmLogVo; import com.example.tdl.domain.vo.AddAlarmLogVo;
import com.example.tdl.domain.vo.AlarmLogVo; import com.example.tdl.domain.vo.AlarmLogVo;
import com.example.tdl.domain.vo.HistogramData;
import com.example.tdl.domain.vo.ResultAlarmLog; import com.example.tdl.domain.vo.ResultAlarmLog;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
@Mapper @Mapper
public interface AlarmLogMapper { public interface AlarmLogMapper {
//获取所有的数据 //获取所有的数据
List<AlarmLogVo> getAll(); List<ResultAlarmLog> getAll();
//根据条件获取报警数据 //根据条件获取报警数据
List<AlarmLogVo> getAlarmLog(Integer time); List<AlarmLogVo> getAlarmLog(String time);
//新增报警数据 //新增报警数据
int addAlarmLog(AddAlarmLogVo addAlarmLogVo); int addAlarmLog(AddAlarmLogVo addAlarmLogVo);
List<ResultAlarmLog> getByTransportationNo(String transportationNo); List<ResultAlarmLog> getByTransportationNo(String transportationNo);
Integer getCount(Integer time); Integer getCount(String time);
Integer getBumpCount(Integer time); Integer getBumpCount(String time);
List<HistogramData> getByCount(String time);
Integer getByTime(@Param("transportationNo") String transportationNo,@Param("startTime") Long startTime, @Param("endTime") Long endTime);
} }
...@@ -2,6 +2,7 @@ package com.example.tdl.mapper; ...@@ -2,6 +2,7 @@ package com.example.tdl.mapper;
import com.example.tdl.domain.vo.*; import com.example.tdl.domain.vo.*;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -24,15 +25,15 @@ public interface CircuitMapper { ...@@ -24,15 +25,15 @@ public interface CircuitMapper {
ResultCircuitVo getByTransportationNo(String transportation); ResultCircuitVo getByTransportationNo(String transportation);
Integer getOnRoute(Integer time); Integer getOnRoute(String time);
Integer getDelayCount(Long compTime); Integer getDelayCount(@Param("compTime") Long compTime, @Param("time") String time);
Integer getComplted(Integer time); Integer getComplted(String time);
Integer getCount(Integer time); Integer getCount(String time);
List<CircuitVo> getByTime(Integer time); List<ResultCircuitVo> getByTime(String time);
List<ResultCircuitVo> getByContainerNo(String cargoNo); List<ResultCircuitVo> getByContainerNo(String cargoNo);
......
package com.example.tdl.mapper;
import com.example.tdl.domain.vo.CircuitTransferVo;
import com.example.tdl.domain.vo.ResultCityVo;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface CircuitTransferMapper {
List<CircuitTransferVo> getCity(String transportationNo);
}
package com.example.tdl.mapper; package com.example.tdl.mapper;
import com.example.tdl.domain.vo.GatewayState;
import com.example.tdl.domain.vo.ResultGatewayVo; import com.example.tdl.domain.vo.ResultGatewayVo;
import com.example.tdl.domain.vo.UpdateGatewayVo; import com.example.tdl.domain.vo.UpdateGatewayVo;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
...@@ -25,4 +26,6 @@ public interface GatewayMapper { ...@@ -25,4 +26,6 @@ public interface GatewayMapper {
int deployGateway(Map<Object,Object> map); int deployGateway(Map<Object,Object> map);
String getBySN(String SN); String getBySN(String SN);
Integer updateState(GatewayState gatewayState);
} }
package com.example.tdl.mapper;
import com.example.tdl.domain.vo.ResultRouteVo;
import com.example.tdl.domain.vo.RouteTermVo;
import com.example.tdl.entity.Route;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
import java.util.Map;
@Mapper
public interface RouteMapper {
// List<ResultRouteVo> getAll();
//
// List<ResultRouteVo> getRouteByTerm(RouteTermVo routeTermVo);
//
// int addRoute(Map<Object,Object> map);
//
// int delRoute(String routeNumber);
//
// int getByRouteNumber(String routeNumber);
//
// ResultRouteVo getInfoByRouteNumber(String routeNumber);
//
// ResultRouteVo getInfoByRouteName(String routeName);
// List<ResultRouteVo> getAllRoute(String time);
// int updateRoute(Route route);
}
...@@ -3,6 +3,7 @@ package com.example.tdl.mapper; ...@@ -3,6 +3,7 @@ package com.example.tdl.mapper;
import com.example.tdl.domain.vo.AddTopicConfigVo; import com.example.tdl.domain.vo.AddTopicConfigVo;
import com.example.tdl.domain.vo.ResultTopicConfigVo; import com.example.tdl.domain.vo.ResultTopicConfigVo;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
...@@ -14,10 +15,9 @@ public interface TopicConfigMapper { ...@@ -14,10 +15,9 @@ public interface TopicConfigMapper {
int delTopicConfig(AddTopicConfigVo addTopicConfigVo); int delTopicConfig(AddTopicConfigVo addTopicConfigVo);
// int addTopicConfig(Map<String,Object> map); List<ResultTopicConfigVo> getProbes(@Param("topicName") String topicName, @Param("SN") String SN, @Param("type") String type);
// List<DevChannelVo> getChannelByTopicName(@Param("topicName") String topicName, @Param("SN") String SN, @Param("type") String type);
// int addTopicConfig(Map<String,Object> map);
// int updateTopicConfig(TopicConfig topicConfig); // int updateTopicConfig(TopicConfig topicConfig);
......
...@@ -128,27 +128,28 @@ public class MqttListener implements MqttCallback { ...@@ -128,27 +128,28 @@ public class MqttListener implements MqttCallback {
String[] tmparray = topic.split("/"); String[] tmparray = topic.split("/");
String Type = tmparray[1]; String Type = tmparray[1];
String SN = tmparray[2]; String SN = tmparray[2];
// Integer flag = parseData(Message,SN,Type); Integer flag = parseData(Message,SN,Type);
// String ConfigData ="{\"action\":\"config\"}";
String ConfigData; String ConfigData;
Future<String> result = null; Future<String> result = null;
GWConfigWorker gcconfig = null; GWConfigWorker gcconfig = null;
// if(flag == 0){ if(flag == 0){
// ConfigCMDVo configCMDVo = new ConfigCMDVo(); ConfigCMDVo configCMDVo = new ConfigCMDVo();
// configCMDVo.setAction("sleep"); configCMDVo.setAction("sleep");
// configCMDVo.setT(System.currentTimeMillis()/1000l); configCMDVo.setT(System.currentTimeMillis()/1000l);
// ConfigData = new Gson().toJson(configCMDVo); ConfigData = new Gson().toJson(configCMDVo);
// gcconfig = new GWConfigWorker(Type,SN,ConfigData, false); gcconfig = new GWConfigWorker(Type,SN,ConfigData, false);
// }else if(flag == 2){ }else if(flag == 2){
// ConfigCMDVo configCMDVo = new ConfigCMDVo(); ConfigCMDVo configCMDVo = new ConfigCMDVo();
// configCMDVo.setAction("end"); configCMDVo.setAction("end");
// configCMDVo.setT(System.currentTimeMillis()/1000l); configCMDVo.setT(System.currentTimeMillis()/1000l);
// ConfigData = new Gson().toJson(configCMDVo); ConfigData = new Gson().toJson(configCMDVo);
// gcconfig = new GWConfigWorker(Type,SN,ConfigData, true); gcconfig = new GWConfigWorker(Type,SN,ConfigData, true);
// }else if(flag == 1){ }else if(flag == 1){
//// ConfigData = configService.getConfig(SN,Type).getMessage(); ConfigData = configService.getConfig(SN,Type).getMessage();
//// gcconfig = new GWConfigWorker(Type,SN,ConfigData, true); gcconfig = new GWConfigWorker(Type,SN,ConfigData, true);
// } }
// String ConfigData ="{\"action\":\"config\"}";
gcconfig.SetMqttConfig(mqttconfig.getUrl(),mqttconfig.getPort(), gcconfig.SetMqttConfig(mqttconfig.getUrl(),mqttconfig.getPort(),
mqttconfig.getUsername(), mqttconfig.getPassword(),mqttconfig.getQos(), mqttconfig.getUsername(), mqttconfig.getPassword(),mqttconfig.getQos(),
mqttconfig.getCacrt(),mqttconfig.getClientkey(), mqttconfig.getClientcrt(),mqttconfig.getClientpwd()); mqttconfig.getCacrt(),mqttconfig.getClientkey(), mqttconfig.getClientcrt(),mqttconfig.getClientpwd());
...@@ -178,29 +179,29 @@ public class MqttListener implements MqttCallback { ...@@ -178,29 +179,29 @@ public class MqttListener implements MqttCallback {
} }
//checkIn数据解析,true即发送休眠信息;false发送config信息 //checkIn数据解析,true即发送休眠信息;false发送config信息
// public Integer parseData(String message,String SN,String Type){ public Integer parseData(String message,String SN,String Type){
// CheckInVo checkInVo = new Gson().fromJson(message,CheckInVo.class); CheckInVo checkInVo = new Gson().fromJson(message,CheckInVo.class);
// if(StringUtils.isEmpty(checkInVo.getDevList()==null ? "" :checkInVo.getDevList().toString())){ if(StringUtils.isEmpty(checkInVo.getDevList()==null ? "" :checkInVo.getDevList().toString())){
// return 1;//重发 return 1;//重发
// } }
//有设备信息 // 有设备信息
// ConfigVo configVo = configService.getConfig(SN,Type); ConfigVo configVo = configService.getConfig(SN,Type);
// ConfigCMDVo configCMDVo = new Gson().fromJson(configVo.getMessage(),ConfigCMDVo.class); ConfigCMDVo configCMDVo = new Gson().fromJson(configVo.getMessage(),ConfigCMDVo.class);
// if(configVo.getUntie()){ if(configVo.getUntie()){
// //解绑状态 //解绑状态
// return 2;//解绑 return 2;//解绑
// } }
// //判断两者的devList是否一致 //判断两者的devList是否一致
// if (configCMDVo.getDevList().containsAll(checkInVo.getDevList()) if (configCMDVo.getDevList().containsAll(checkInVo.getDevList())
// && checkInVo.getDevList().containsAll(configCMDVo.getDevList()) && checkInVo.getDevList().containsAll(configCMDVo.getDevList())
// && checkInVo.getGprsPeriod().equals(configCMDVo.getGprsPeriod()) && checkInVo.getGprsPeriod().equals(configCMDVo.getGprsPeriod())
// && checkInVo.getGpsPeriod().equals(configCMDVo.getGpsPeriod()) && checkInVo.getGpsPeriod().equals(configCMDVo.getGpsPeriod())
// && checkInVo.getMode().equals(configCMDVo.getMode())) { && checkInVo.getMode().equals(configCMDVo.getMode())) {
// //一致 //一致
// return 0;//发送休眠信息 return 0;//发送休眠信息
// } else { } else {
// //不一致 //不一致
// return 1;//重发 return 1;//重发
// } }
// } }
} }
...@@ -2,6 +2,7 @@ package com.example.tdl.service; ...@@ -2,6 +2,7 @@ package com.example.tdl.service;
import com.example.tdl.domain.vo.AddAlarmLogVo; import com.example.tdl.domain.vo.AddAlarmLogVo;
import com.example.tdl.domain.vo.AlarmLogVo; import com.example.tdl.domain.vo.AlarmLogVo;
import com.example.tdl.domain.vo.HistogramData;
import com.example.tdl.domain.vo.ResultAlarmLog; import com.example.tdl.domain.vo.ResultAlarmLog;
import com.example.tdl.mapper.AlarmLogMapper; import com.example.tdl.mapper.AlarmLogMapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -15,11 +16,11 @@ public class AlarmLogService { ...@@ -15,11 +16,11 @@ public class AlarmLogService {
@Autowired @Autowired
private AlarmLogMapper alarmLogMapper; private AlarmLogMapper alarmLogMapper;
public List<AlarmLogVo> getAll(){ public List<ResultAlarmLog> getAll(){
return alarmLogMapper.getAll(); return alarmLogMapper.getAll();
} }
public List<AlarmLogVo> getAlarmLog(Integer time){ public List<AlarmLogVo> getAlarmLog(String time){
return alarmLogMapper.getAlarmLog(time); return alarmLogMapper.getAlarmLog(time);
} }
...@@ -31,13 +32,22 @@ public class AlarmLogService { ...@@ -31,13 +32,22 @@ public class AlarmLogService {
return alarmLogMapper.getByTransportationNo(transportationNo); return alarmLogMapper.getByTransportationNo(transportationNo);
} }
public Integer getCount(Integer time){ public Integer getCount(String time){
return alarmLogMapper.getCount(time); return alarmLogMapper.getCount(time);
} }
public Integer getBumpCount(Integer time){ public Integer getBumpCount(String time){
return alarmLogMapper.getBumpCount(time); return alarmLogMapper.getBumpCount(time);
} }
public List<HistogramData> getByCount(String time){
return alarmLogMapper.getByCount(time);
}
public Integer getByTime(String transportationNo,Long startTime,Long endTime){
return alarmLogMapper.getByTime(transportationNo,startTime,endTime);
}
} }
...@@ -18,10 +18,6 @@ public class CircuitService { ...@@ -18,10 +18,6 @@ public class CircuitService {
return circuitMapper.getAll(); return circuitMapper.getAll();
} }
// public List<CircuitVo> getDistinct(){
// return circuitMapper.getDistinct();
// }
public List<ResultCircuitVo> getByTerm(CircuitTermVo circuitTermVo){ public List<ResultCircuitVo> getByTerm(CircuitTermVo circuitTermVo){
return circuitMapper.getByTerm(circuitTermVo); return circuitMapper.getByTerm(circuitTermVo);
} }
...@@ -47,24 +43,24 @@ public class CircuitService { ...@@ -47,24 +43,24 @@ public class CircuitService {
return circuitMapper.getByTransportationNo(transportationNo); return circuitMapper.getByTransportationNo(transportationNo);
} }
public Integer getOnRoute(Integer time){ public Integer getOnRoute(String time){
return circuitMapper.getOnRoute(time); return circuitMapper.getOnRoute(time);
} }
public Integer getDelayCount(Long compTime){ public Integer getDelayCount(Long compTime,String time){
return circuitMapper.getDelayCount(compTime); return circuitMapper.getDelayCount(compTime,time);
} }
public Integer getComplted(Integer time){ public Integer getComplted(String time){
return circuitMapper.getComplted(time); return circuitMapper.getComplted(time);
} }
public Integer getCount(Integer time){ public Integer getCount(String time){
return circuitMapper.getCount(time); return circuitMapper.getCount(time);
} }
public List<CircuitVo> getByTime(Integer time){ public List<ResultCircuitVo> getByTime(String time){
return circuitMapper.getByTime(time); return circuitMapper.getByTime(time);
} }
...@@ -88,4 +84,8 @@ public class CircuitService { ...@@ -88,4 +84,8 @@ public class CircuitService {
return circuitMapper.getByNo(transportationNo); return circuitMapper.getByNo(transportationNo);
} }
// public List<CircuitVo> getDistinct(){
// return circuitMapper.getDistinct();
// }
} }
package com.example.tdl.service;
import com.example.tdl.domain.vo.CircuitTransferVo;
import com.example.tdl.mapper.CircuitTransferMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class CircuitTransferService {
@Autowired
private CircuitTransferMapper circuitTransferMapper;
public List<CircuitTransferVo> getCity(String transportationNo){
return circuitTransferMapper.getCity(transportationNo);
}
}
package com.example.tdl.service; package com.example.tdl.service;
import com.example.tdl.domain.vo.AddGatewayVo; import com.example.tdl.domain.vo.*;
import com.example.tdl.domain.vo.DelGatewayVo;
import com.example.tdl.domain.vo.ResultGatewayVo;
import com.example.tdl.domain.vo.UpdateGatewayVo;
import com.example.tdl.mapper.GatewayMapper; import com.example.tdl.mapper.GatewayMapper;
import com.example.tdl.mapper.RoleMapper; import com.example.tdl.mapper.RoleMapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -49,4 +46,8 @@ public class GatewayService { ...@@ -49,4 +46,8 @@ public class GatewayService {
public String getBySN(String SN){ public String getBySN(String SN){
return gatewayMapper.getBySN(SN); return gatewayMapper.getBySN(SN);
} }
public Boolean updateState(GatewayState gatewayState){
return gatewayMapper.updateState(gatewayState)==1;
}
} }
package com.example.tdl.service;
import org.springframework.stereotype.Service;
@Service
public class RouteService {
// @Autowired
// private RouteMapper routeMapper;
//
// public List<ResultRouteVo> getAll(){
// return routeMapper.getAll();
// }
//
// public List<ResultRouteVo> getRouteByTerm(RouteTermVo routeTermVo){
// return routeMapper.getRouteByTerm(routeTermVo);
// }
//
// public int addRoute(Map<Object,Object> map){
// return routeMapper.addRoute(map);
// }
//
// public int delRoute(String routeNumber){
// return routeMapper.delRoute(routeNumber);
// }
//
// public int getByRouteNumber(String routeNumber){
// return routeMapper.getByRouteNumber(routeNumber);
// }
//
// public ResultRouteVo getInfoByRouteNumber(String routeNumber){
// return routeMapper.getInfoByRouteNumber(routeNumber);
// }
//
// public ResultRouteVo getInfoByRouteName(String routeName){
// return routeMapper.getInfoByRouteName(routeName);
// }
// public List<ResultRouteVo> getAllRoute(String time){
// return routeMapper.getAllRoute(time);
// }
// public int updateRoute(Route route){
// return routeMapper.updateRoute(route);
// }
}
...@@ -26,13 +26,15 @@ public class TopicConfigService { ...@@ -26,13 +26,15 @@ public class TopicConfigService {
return topicConfigMapper.delTopicConfig(addTopicConfigVo); return topicConfigMapper.delTopicConfig(addTopicConfigVo);
} }
public List<ResultTopicConfigVo> getProbes(String topicName, String SN, String type){
return topicConfigMapper.getProbes(topicName,SN,type);
}
// public int updateTopicConfig(TopicConfig topicConfig){ // public int updateTopicConfig(TopicConfig topicConfig){
// return topicConfigMapper.updateTopicConfig(topicConfig); // return topicConfigMapper.updateTopicConfig(topicConfig);
// } // }
// public List<ResultTopicConfigVo> getChannelByTopicName(String topicName, String SN, String type){
// return topicConfigMapper.getChannelByTopicName(topicName,SN,type);
// }
// public TopicConfig getByDevChannelId(Integer devChannelId){ // public TopicConfig getByDevChannelId(Integer devChannelId){
// return topicConfigMapper.getByDevChannelId(devChannelId); // return topicConfigMapper.getByDevChannelId(devChannelId);
......
...@@ -220,4 +220,9 @@ public class RedisService { ...@@ -220,4 +220,9 @@ public class RedisService {
} }
} }
public void hmSet(String key, Object hashKey, Object value) {
HashOperations<String, Object, Object> hash = redisTemplate.opsForHash();
hash.put(key, hashKey, value);
}
} }
package com.example.tdl.util;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
public class HttpRequester {
private static Logger logger = LoggerFactory.getLogger(HttpRequester.class);
//发送post请求
public static String sendPost(String url, String param) {
PrintWriter out = null;
BufferedReader in = null;
String result = "";
try {
URL realUrl = new URL(url);
// 打开和URL之间的连接
HttpURLConnection conn = (HttpURLConnection)realUrl.openConnection();
// 设置通用的请求属性
conn.setRequestProperty("accept", "*/*");
conn.setRequestProperty("connection", "Keep-Alive");
conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
conn.setRequestProperty("content-type","application/json");
conn.setRequestProperty("Accept-Charset", "utf-8");
conn.setRequestProperty("contentType", "utf-8");
conn.setRequestMethod("POST");// 设置请求方式为post
conn.setInstanceFollowRedirects(true);// 设置该HttpURLConnection实例是否自动执行重定向
// 发送POST请求必须设置如下两行
conn.setDoOutput(true); // 设置连接输出流为true,默认false (post 请求是以流的方式隐式的传递参数)
conn.setDoInput(true);
// 获取URLConnection对象对应的输出流
out = new PrintWriter(conn.getOutputStream());
// 发送请求参数
out.print(param);
// flush输出流的缓冲
out.flush();
// 定义BufferedReader输入流来读取URL的响应
in = new BufferedReader(new InputStreamReader(conn.getInputStream(),"utf-8"));
String line;
while ((line = in.readLine()) != null) {
result += line;
}
} catch (Exception e) {
System.out.println("发送 POST 请求出现异常!"+e);
e.printStackTrace();
}
//使用finally块来关闭输出流、输入流
finally{
try{
if(out!=null){
out.close();
}
if(in!=null){
in.close();
}
}
catch(IOException ex){
ex.printStackTrace();
}
}
return result;
}
//发送get请求
public static String get(String url) {
BufferedReader in = null;
try {
URL realUrl = new URL(url);
// 打开和URL之间的连接
URLConnection connection = realUrl.openConnection();
// 设置通用的请求属性
connection.setRequestProperty("accept", "*/*");
connection.setRequestProperty("connection", "Keep-Alive");
connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
connection.setConnectTimeout(5000);
connection.setReadTimeout(5000);
// 建立实际的连接
connection.connect();
// 定义 BufferedReader输入流来读取URL的响应
in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
StringBuffer sb = new StringBuffer();
String line;
while ((line = in.readLine()) != null) {
sb.append(line);
}
return sb.toString();
} catch (Exception e) {
e.printStackTrace();
logger.info(e.toString());
}
// 使用finally块来关闭输入流
finally {
try {
if (in != null) {
in.close();
}
} catch (Exception e2) {
e2.printStackTrace();
logger.info(e2.toString());
}
}
return null;
}
}
package com.example.tdl.web;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.example.tdl.domain.dto.CommFeedback;
import com.example.tdl.domain.vo.CircuitAlarmVo;
import com.example.tdl.domain.vo.LocationDataVo;
import com.example.tdl.domain.vo.LocationMessageVo;
import com.example.tdl.domain.vo.ResultGatewayVo;
import com.example.tdl.service.CircuitService;
import com.example.tdl.service.TDLDeviceService;
import com.example.tdl.service.redis.RealRedisService;
import com.google.gson.Gson;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.influxdb.dto.Query;
import org.influxdb.dto.QueryResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.influxdb.InfluxDBTemplate;
import org.springframework.web.bind.annotation.*;
import java.text.SimpleDateFormat;
import java.util.*;
@RestController
public class AlarmDataController {
private CommFeedback fb=new CommFeedback();
private Gson gson=new Gson();
// @Autowired
// private CircuitService circuitService;
//
// @Autowired
// private InfluxDBTemplate influxDBTemplate;
//
// @Autowired
// private TDLDeviceService tdlDeviceService;
//
// @Autowired
// private RealRedisService realRedisService;
//
// private final static String database ="original";
//
// @ApiImplicitParams({
// @ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
// })
// @RequestMapping(value="/getAlarmCircuit",method = RequestMethod.POST)
// public Object getAlarmCircuit(@RequestBody String transportationNo){
//// String transportationNo="CHN20180227G0505";
// JSONObject jsonObject= JSON.parseObject(transportationNo);
// transportationNo=(String)jsonObject.get("transportationNo");
// ResultGatewayVo resultGatewayVo=circuitService.getByNo(transportationNo);
// if (resultGatewayVo==null){
// fb.setCode(0);
// fb.setMessage("该线路没有绑定网关");
// return gson.toJson(fb);
// }
// Integer circuitState=circuitService.getByTransportationNo(transportationNo).getCircuitState();
// String device = resultGatewayVo.getType() +"_" +resultGatewayVo.getSN();
// if(circuitState==0){
// return null;
// }else if(circuitState==1){
// List<String> list=tdlDeviceService.getByGatewaySN(resultGatewayVo.getSN(),resultGatewayVo.getType());
// String tdl="";
// if (list.size()==1){
// tdl="'tdl-"+list.get(0)+"'";
// }else if(list.size()==0){
// fb.setCode(0);
// fb.setMessage("该网关下没有tdl设备");
// return gson.toJson(fb);
// }else{
// for (int a=0;a<list.size();a++){
// tdl=tdl+"'tdl-"+list.get(a)+"'";
// if (a<list.size()-1){
// tdl=tdl+"or \"tdl\"=";
// }
// }
// }
// String sql = "SELECT \"b\",\"tdl\" FROM \"tdl_policy\".\""+device+"\" where \"tdl\"= "+tdl;
// QueryResult queryResult = influxDBTemplate.query(new Query(sql,database));
// List<CircuitAlarmVo> circuitAlarmVos=new ArrayList<>();
// if (queryResult.getResults().get(0).getSeries()!=null){
// circuitAlarmVos=getAlarmData(queryResult);
// }
// String sqls ="";
// for (int a=0;a<circuitAlarmVos.size();a++){
// sqls=sqls+"SELECT \"time\",\"lng\",\"lat\" FROM \"tdl_policy\".\""+device+"\" where time <='"+circuitAlarmVos.get(a).getTime()+"' ORDER BY time desc limit 1;";
// }
// QueryResult queryResults = influxDBTemplate.query(new Query(sqls,database));
// List<LocationDataVo> locationDataVos = new ArrayList<>();
// if (queryResults.getResults().get(0).getSeries()!=null){
// locationDataVos=getAddress(queryResults);
// }
// String sql1="SELECT \"time\",\"lng\",\"lat\" FROM \"tdl_policy\".\""+device+"\" order by time";
// QueryResult queryResult1 = influxDBTemplate.query(new Query(sql1,database));
// List<LocationDataVo> locationDataVos1 = new ArrayList<>();
// if (queryResult1.getResults().get(0).getSeries()!=null){
// locationDataVos1=getAllAddress(queryResult1);
// }
// for (int a=0;a<locationDataVos1.size();a++){
// for (int b=0;b<locationDataVos.size();b++){
// if (locationDataVos1.get(a).getLng().equals(locationDataVos.get(b).getLng())&&locationDataVos1.get(a).getLat().equals(locationDataVos.get(b).getLat())){
// locationDataVos1.get(a).setError(1);
// }
// }
// }
// return gson.toJson(locationDataVos1);
// }else{
//// Map<Object,Object> map=new HashMap<>();
//// map.put(device,locationDataVos1);
//// realRedisService.setHash("CircuitAlarm",map,System.currentTimeMillis());
// Object o =realRedisService.getHash("CircuitAlarm",device);
// return gson.toJson(o);
// }
//
// }
//
// public List<LocationDataVo> getAddress(QueryResult queryResult){
// List<List<Object>> lists=getValue(queryResult);
// List<LocationDataVo> locationDataVos=new ArrayList<>();
// for (List<Object> value:lists){
// LocationDataVo locationDataVo=new LocationDataVo();
// locationDataVo.setTime(dateToStamp(value.get(0).toString()));
// locationDataVo.setLng((Double)value.get(1));
// locationDataVo.setLat((Double)value.get(2));
// locationDataVos.add(locationDataVo);
// }
// return locationDataVos;
// }
//
// public List<LocationDataVo> getAllAddress(QueryResult queryResult){
// List<List<Object>> lists=getValues(queryResult);
// List<LocationDataVo> locationDataVos=new ArrayList<>();
// for (List<Object> value:lists){
// LocationDataVo locationDataVo=new LocationDataVo();
// locationDataVo.setTime(dateToStamp(value.get(0).toString()));
// locationDataVo.setLng((Double)value.get(1));
// locationDataVo.setLat((Double)value.get(2));
// locationDataVo.setError(0);
// locationDataVos.add(locationDataVo);
// }
// return locationDataVos;
// }
//
// public List<CircuitAlarmVo> getAlarmData(QueryResult queryResult){
// List<List<Object>> lists=getValues(queryResult);
// List<CircuitAlarmVo> alarmVoList=new ArrayList<>();
// for (List<Object> value:lists){
// CircuitAlarmVo circuitAlarmVo=new CircuitAlarmVo();
// circuitAlarmVo.setTime(value.get(0).toString());
// circuitAlarmVo.setShockEnergy(value.get(1).toString());
// circuitAlarmVo.setTdl(value.get(2).toString());
// alarmVoList.add(circuitAlarmVo);
// }
// return alarmVoList;
// }
//
// public List<List<Object>> getValues(QueryResult queryResult){
// List<List<Object>> lists=new ArrayList<>();
// for (QueryResult.Result result:queryResult.getResults()){
// if (result.getSeries()!=null){
// for (QueryResult.Series series:result.getSeries()){
// if (series!=null){
// lists=series.getValues();
// }
// }
// }
// }
// return lists;
// }
//
// public List<List<Object>> getValue(QueryResult queryResult){
// List<List<Object>> lists=new ArrayList<>();
// for (QueryResult.Result result:queryResult.getResults()){
// if (result.getSeries()!=null){
// for (int a=0;a<result.getSeries().size();a++){
// lists.add(result.getSeries().get(a).getValues().get(0));
// }
// }
// }
// return lists;
// }
//
// public String dateToStamp(String time){
// String res;
// Date date=null;
// try {
// if (time.length()!=20){
// SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
// date = simpleDateFormat.parse(time);
// }else{
// SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
// date=simpleDateFormat.parse(time);
// }
// long ts = date.getTime()*1000000;
// res = String.valueOf(ts);
// }catch (Exception e){
// fb.setCode(0);
// fb.setMessage("时间转换出错");
// return gson.toJson(fb);
// }
// return res;
// }
}
\ No newline at end of file
...@@ -5,9 +5,7 @@ import com.alibaba.fastjson.JSON; ...@@ -5,9 +5,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.example.tdl.domain.dto.CommFeedback; import com.example.tdl.domain.dto.CommFeedback;
import com.example.tdl.domain.vo.*; import com.example.tdl.domain.vo.*;
import com.example.tdl.service.CircuitService; import com.example.tdl.service.*;
import com.example.tdl.service.GatewayService;
import com.example.tdl.service.TDLDeviceService;
import com.example.tdl.service.redis.TokenRedisService; import com.example.tdl.service.redis.TokenRedisService;
import com.google.gson.Gson; import com.google.gson.Gson;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
...@@ -17,16 +15,10 @@ import org.apache.commons.lang3.StringUtils; ...@@ -17,16 +15,10 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController @RestController
@RequestMapping("/circuit") @RequestMapping("/circuit")
...@@ -47,6 +39,12 @@ public class CircuitController { ...@@ -47,6 +39,12 @@ public class CircuitController {
@Autowired @Autowired
private TDLDeviceService tdlDeviceService; private TDLDeviceService tdlDeviceService;
@Autowired
private CircuitTransferService circuitTransferService;
@Autowired
private AlarmLogService alarmLogService;
//获取线路信息 //获取线路信息
@ApiOperation(value = "获取线路信息",notes = "获取线路信息,返回值说明:" + @ApiOperation(value = "获取线路信息",notes = "获取线路信息,返回值说明:" +
" transportationNo:运输编号," + " transportationNo:运输编号," +
...@@ -56,7 +54,9 @@ public class CircuitController { ...@@ -56,7 +54,9 @@ public class CircuitController {
" endCity:目的城市," + " endCity:目的城市," +
" endTime:目的时间," + " endTime:目的时间," +
" circuitState:线路状态(0未开始,1运输中,2完成)," + " circuitState:线路状态(0未开始,1运输中,2完成)," +
" alarmType:预警类型,") " alarmType:预警类型," +
" alarm:报警详情(比如:温度,湿度,震动)" +
" evaluate:运输评价")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"), @ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
}) })
...@@ -81,7 +81,9 @@ public class CircuitController { ...@@ -81,7 +81,9 @@ public class CircuitController {
" endCity:目的城市," + " endCity:目的城市," +
" endTime:目的时间," + " endTime:目的时间," +
" alarmType:预警类型," + " alarmType:预警类型," +
" circuitState:线路状态(0未开始,1运输中,2完成),") " circuitState:线路状态(0未开始,1运输中,2完成)," +
" alarm:报警详情(比如:温度,湿度,震动," +
" evaluate:运输评价")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"), @ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
}) })
...@@ -309,6 +311,7 @@ public class CircuitController { ...@@ -309,6 +311,7 @@ public class CircuitController {
return gson.toJson(fb); return gson.toJson(fb);
} }
//修改线路结束时间 //修改线路结束时间
@ApiOperation(value = "修改线路结束时间",notes = "修改线路结束时间,传值说明:" + @ApiOperation(value = "修改线路结束时间",notes = "修改线路结束时间,传值说明:" +
" transportationNo:运输编号," + " transportationNo:运输编号," +
...@@ -572,7 +575,9 @@ public class CircuitController { ...@@ -572,7 +575,9 @@ public class CircuitController {
" endCity:目的城市," + " endCity:目的城市," +
" endTime:目的时间," + " endTime:目的时间," +
" alarmType:预警类型," + " alarmType:预警类型," +
" circuitState:线路状态(0未开始,1运输中,2完成),") " circuitState:线路状态(0未开始,1运输中,2完成)," +
" alarm:报警详情(比如:温度,湿度,震动)" +
" evaluate:运输评价")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"), @ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
}) })
...@@ -632,7 +637,9 @@ public class CircuitController { ...@@ -632,7 +637,9 @@ public class CircuitController {
" endCity:目的城市," + " endCity:目的城市," +
" endTime:目的时间," + " endTime:目的时间," +
" alarmType:预警类型," + " alarmType:预警类型," +
" circuitState:线路状态(0未开始,1运输中,2完成),") " circuitState:线路状态(0未开始,1运输中,2完成)," +
" alarm:报警详情(比如:温度,湿度,震动)" +
" evaluate:运输评价")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"), @ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
}) })
...@@ -680,6 +687,119 @@ public class CircuitController { ...@@ -680,6 +687,119 @@ public class CircuitController {
} }
//根据线路编号获取线路详细信息
@ApiOperation(value = "根据线路编号获取线路详细信息",notes = "根据线路编号获取线路详细信息,传值说明:" +
" transportationNo:运输编号; " +
"返回值说明:" +
" " )
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
@PostMapping("/getDetails")
public Object getDetails(@RequestBody String transportationNo){
JSONObject jsonObject= JSON.parseObject(transportationNo);
transportationNo=(String)jsonObject.get("transportationNo");
//获取线路信息
ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(transportationNo);
List<ResultAlarmLog> alarmLogList= alarmLogService.getByTransportationNo(transportationNo);
CircuitMessageVo messageVo = new CircuitMessageVo(resultCircuitVo.getTransportationNo(),resultCircuitVo.getCargoNo(),resultCircuitVo.getStartCity(),resultCircuitVo.getEndCity(),resultCircuitVo.getCircuitState(),resultCircuitVo.getEvaluate(),alarmLogList);
//获取线路情况
List<CircuitTransferVo> list =circuitTransferService.getCity(transportationNo);
List<ResultCityVo> cityVoList = new ArrayList<>();
for (int i = 0; i < list.size(); i++) {
if (list.get(i).getSequence() == 1) {
ResultCityVo cityVo = new ResultCityVo();
cityVo.setCity(list.get(i).getCity());
cityVo.setType(1);
if(list.get(i).getStartTime() == null || list.get(i).getStartTime() == 0 ){
cityVo.setTime(0l);
cityVo.setLast("0");
cityVo.setAlarmCount(0);
}else{
cityVo.setTime(list.get(i).getStartTime());
if(list.get(i + 1).getArrivalTime() !=null && list.get(i + 1).getArrivalTime() !=0){
//根据时间和运输编号获取报警信息
Integer count = alarmLogService.getByTime(transportationNo, list.get(i).getStartTime(), list.get(i + 1).getArrivalTime());
cityVo.setAlarmCount(count);
cityVo.setLast(getMistiming(list.get(i + 1).getArrivalTime(),list.get(i).getStartTime()));
}else{
Integer count = alarmLogService.getByTime(transportationNo, list.get(i).getStartTime(), System.currentTimeMillis());
cityVo.setAlarmCount(count);
cityVo.setLast(getMistiming(System.currentTimeMillis(),list.get(i).getStartTime()));
}
}
cityVoList.add(cityVo);
}else if(list.get(i).getSequence() == list.size()){
ResultCityVo cityVo = new ResultCityVo();
cityVo.setCity(list.get(i).getCity());
if(list.get(i).getArrivalTime() == null || list.get(i).getArrivalTime() == 0){
cityVo.setTime(0l);
}else {
cityVo.setTime(list.get(i).getArrivalTime());
}
cityVo.setType(2);
cityVoList.add(cityVo);
}else{
ResultCityVo cityVo2 = new ResultCityVo();
cityVo2.setCity(list.get(i).getCity());
cityVo2.setType(2);
if(list.get(i).getArrivalTime() == null ||list.get(i).getArrivalTime() ==0){
cityVo2.setTime(0l);
cityVo2.setAlarmCount(0);
cityVo2.setLast("0");
cityVoList.add(cityVo2);
ResultCityVo cityVo1 = new ResultCityVo();
cityVo1.setCity(list.get(i).getCity());
cityVo1.setTime(0l);
cityVo1.setType(1);
cityVo1.setAlarmCount(0);
cityVo1.setLast("0");
cityVoList.add(cityVo1);
}else{
cityVo2.setTime(list.get(i).getArrivalTime());
//根据时间和运输编号获取报警信息
if(list.get(i).getStartTime() == null ||list.get(i).getStartTime() ==0){
Integer count2 = alarmLogService.getByTime(transportationNo, list.get(i).getArrivalTime(), System.currentTimeMillis());
cityVo2.setAlarmCount(count2);
cityVo2.setLast(getMistiming(System.currentTimeMillis(),list.get(i).getArrivalTime()));
cityVoList.add(cityVo2);
ResultCityVo cityVo1 = new ResultCityVo();
cityVo1.setCity(list.get(i).getCity());
cityVo1.setTime(0l);
cityVo1.setType(1);
cityVo1.setAlarmCount(0);
cityVo1.setLast("0");
cityVoList.add(cityVo1);
}else{
Integer count2 = alarmLogService.getByTime(transportationNo, list.get(i).getArrivalTime(), list.get(i).getStartTime());
cityVo2.setAlarmCount(count2);
cityVo2.setLast(getMistiming(list.get(i ).getStartTime(),list.get(i).getArrivalTime()));
cityVoList.add(cityVo2);
ResultCityVo cityVo1 = new ResultCityVo();
cityVo1.setCity(list.get(i).getCity());
cityVo1.setTime(list.get(i).getStartTime());
cityVo1.setType(1);
if(list.get(i + 1).getArrivalTime() == null ||list.get(i + 1).getArrivalTime() ==0){
Integer count = alarmLogService.getByTime(transportationNo, list.get(i).getStartTime(), System.currentTimeMillis());
cityVo1.setAlarmCount(count);
cityVo1.setLast(getMistiming(System.currentTimeMillis(),list.get(i).getStartTime()));
cityVoList.add(cityVo1);
}else {
Integer count = alarmLogService.getByTime(transportationNo, list.get(i).getStartTime(), list.get(i + 1).getArrivalTime());
cityVo1.setAlarmCount(count);
cityVo1.setLast(getMistiming(list.get(i + 1).getArrivalTime(),list.get(i).getStartTime()));
cityVoList.add(cityVo1);
}
}
}
}
}
messageVo.setList(cityVoList);
return gson.toJson(messageVo);
}
//生成运输编号 //生成运输编号
public String getTransportNo(String transportation,String transportationType){ public String getTransportNo(String transportation,String transportationType){
String transportationNo=""; String transportationNo="";
...@@ -708,4 +828,38 @@ public class CircuitController { ...@@ -708,4 +828,38 @@ public class CircuitController {
} }
return transportationNo; return transportationNo;
} }
//两个时间戳之间相差多少
public String getMistiming(Long startTime,Long arrivalTime){
long nd = 1000 * 24 * 60 * 60;
long nh = 1000 * 60 * 60;
long nm = 1000 * 60;
long ns = 1000;
// 获得两个时间的毫秒时间差异
long diff = startTime- arrivalTime;
// 计算差多少天
long day = diff / nd;
// 计算差多少小时
long hour = diff % nd / nh;
// 计算差多少分钟
long min = diff % nd % nh / nm;
// 计算差多少秒//输出结果
long sec = diff % nd % nh % nm / ns;
return day + "天" + hour + "小时" + min + "分钟" +sec +"秒";
}
// @ApiOperation(value = "根据线路编号获取线路详细信息",notes = "根据线路编号获取线路详细信息,传值说明:" +
// " transportationNo:运输编号; " +
// "返回值说明:" +
// " " )
// @ApiImplicitParams({
// @ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
// })
// @PostMapping("/getAlarmData")
// public Object getAlarmData(@RequestBody String transportationNo){
// JSONObject jsonObject= JSON.parseObject(transportationNo);
// transportationNo=(String)jsonObject.get("transportationNo");
// List<ResultAlarmLog> list= alarmLogService.getByTransportationNo(transportationNo);
// return gson.toJson(list);
// }
} }
...@@ -138,7 +138,7 @@ public class DataController { ...@@ -138,7 +138,7 @@ public class DataController {
//获取gateway的信息 //获取gateway的信息
ResultGatewayVo gatewayVo = new ResultGatewayVo(); ResultGatewayVo gatewayVo = new ResultGatewayVo();
if(resultCircuitVo.getEndTime() == 0){ if(resultCircuitVo.getEndTime() == 0){
//gatewayVo = circuitService.getByNo(transportationNo); gatewayVo = circuitService.getByNo(transportationNo);
}else{ }else{
gatewayVo = tdlLogService.getByNo(transportationNo); gatewayVo = tdlLogService.getByNo(transportationNo);
} }
......
...@@ -3,13 +3,15 @@ package com.example.tdl.web; ...@@ -3,13 +3,15 @@ package com.example.tdl.web;
import com.example.tdl.domain.dto.CommFeedback; import com.example.tdl.domain.dto.CommFeedback;
import com.example.tdl.domain.vo.*; import com.example.tdl.domain.vo.*;
import com.example.tdl.service.GatewayService; import com.example.tdl.service.*;
import com.example.tdl.service.ModelService; import com.example.tdl.service.redis.InfoRedisService;
import com.example.tdl.util.HttpRequester;
import com.google.gson.Gson; import com.google.gson.Gson;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -18,7 +20,7 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -18,7 +20,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
...@@ -40,6 +42,18 @@ public class GatewayController { ...@@ -40,6 +42,18 @@ public class GatewayController {
@Autowired @Autowired
private ModelService modelService; private ModelService modelService;
@Autowired
private ProbesService probesService;
@Autowired
private InfoRedisService infoRedisService;
@Autowired
private TopicService topicService;
@Autowired
private TopicConfigService topicConfigService;
//查询所有网关信息 //查询所有网关信息
@ApiOperation(value = "查询所有网关信息",notes = "查询所有网关信息:" + @ApiOperation(value = "查询所有网关信息",notes = "查询所有网关信息:" +
...@@ -258,4 +272,97 @@ public class GatewayController { ...@@ -258,4 +272,97 @@ public class GatewayController {
return gson.toJson(fb); return gson.toJson(fb);
} }
//挂载设备
@ApiOperation(value = "使用通道模板配置通道",notes = "使用通道模板配置通道" +
" SN:设备编号" +
" type:设备类型" +
" state:挂载/卸载" +
" bConfig:是否配置通道")
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
@RequestMapping(value="/setState",method = RequestMethod.POST)
public String setState(@RequestBody GatewayState device){
if (device.getbConfig() == false) {
fb.setCode(0);
fb.setMessage("该设备未配置通道。");
return gson.toJson(fb);
}
//根据设备的SN,TYPE获取所有通道
List<ResultProbesVo> list = probesService.getProbesByGateway(device.getSN(),device.getType());
if (list.size() == 0) {
fb.setCode(0);
fb.setMessage("该设备没有通道,请先增加通道。");
return gson.toJson(fb);
}
DeviceConfigVo deviceConfig = new DeviceConfigVo();
List<GConfigVo> configList = new ArrayList<>();
for (ResultProbesVo devChannel : list) {
GConfigVo con = new GConfigVo(devChannel.getPort(), devChannel.getUnit(), devChannel.getDescription(), devChannel.getAlias());
configList.add(con);
}
deviceConfig.setConfigList(configList);
infoRedisService.hmSet("DeviceConfig", device.getType() + "_" + device.getSN(), deviceConfig.toString());
//查询该设备所有的主题类型0-发布,1-订阅,2-发布并订阅
List<ResultTopicVo> topicList = topicService.getByGateway(new GatewaySNAndTypeVo(device.getSN(),device.getType()));
//将数据放到redis中
List<String> pubList = new ArrayList<>();
List<String> subList = new ArrayList<>();
for (ResultTopicVo topic : topicList) {
//配置发布还是订阅
if (topic.getType() == 0) {
pubList.add(gson.toJson(topic.getTopicName()));
} else if (topic.getType() == 1) {
subList.add(gson.toJson(topic.getTopicName()));
} else if (topic.getType() == 2) {
pubList.add(gson.toJson(topic.getTopicName()));
subList.add(gson.toJson(topic.getTopicName()));
}
ProbesConfigVo channel_config = new ProbesConfigVo();
//根据设备的主题名,获取所有的通道
List<ResultTopicConfigVo> devChannelList = topicConfigService.getProbes(topic.getTopicName(),device.getSN(),device.getType());
List<ChannelConfigVo> channelConfigs = new ArrayList<>();
for (ResultTopicConfigVo devChannel : devChannelList) {
ChannelConfigVo channelConfig = new ChannelConfigVo(devChannel.getPort(),devChannel.getUnti(),devChannel.getDescription(),devChannel.getAlias());
channelConfigs.add(channelConfig);
}
channel_config.setIntervalTime(topic.getIntervalTime());
channel_config.setChannelConfigs(channelConfigs);
if (device.getState() == 0) {
infoRedisService.hmSet("TopicConfig", topic.getTopicName(), channel_config.toString());
} else {
infoRedisService.delHashKey("TopicConfig", topic.getTopicName());
}
}
infoRedisService.hmSet("SubTopic", device.getType() + "_" + device.getSN(), subList.toString());
infoRedisService.hmSet("PubTopic", device.getType() + "_" + device.getSN(), pubList.toString());
if (device.getState() == 0) {
//挂载
String sr = HttpRequester.sendPost("http://127.0.0.1:8079/witium/addMount", gson.toJson(new GatewaySNAndTypeVo(device.getSN(), device.getType())));
device.setState(1);
} else if (device.getState() == 1) {
//卸载
String sr = HttpRequester.sendPost("http://127.0.0.1:8079/witium/delMount", gson.toJson(new GatewaySNAndTypeVo(device.getSN(), device.getType())));
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{
Boolean boo = gatewayService.updateState(device);
if (!boo) {
fb.setCode(0);
fb.setMessage("修改失败");
} else {
fb.setCode(1);
fb.setMessage("修改成功");
}
} catch (Exception e) {
e.printStackTrace();
logger.info(e.toString());
}
return gson.toJson(fb);
}
} }
package com.example.tdl.web; package com.example.tdl.web;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.example.tdl.domain.dto.CommFeedback; import com.example.tdl.domain.dto.CommFeedback;
import com.example.tdl.domain.vo.*; import com.example.tdl.domain.vo.*;
import com.example.tdl.service.AlarmLogService; import com.example.tdl.service.AlarmLogService;
import com.example.tdl.service.CircuitService; import com.example.tdl.service.CircuitService;
import com.example.tdl.service.TDLLogService;
import com.google.gson.Gson; import com.google.gson.Gson;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.influxdb.dto.Query;
import org.influxdb.dto.QueryResult;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.influxdb.InfluxDBTemplate;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
@RestController @RestController
...@@ -32,62 +41,124 @@ public class HomePageController { ...@@ -32,62 +41,124 @@ public class HomePageController {
@Autowired @Autowired
private AlarmLogService alarmLogServcie; private AlarmLogService alarmLogServcie;
@Autowired
private TDLLogService tdlLogService;
@Autowired
private InfluxDBTemplate influxDBTemplate;
private final static String database ="original";
//获取当天所有的设备数据 //获取当天所有的设备数据
@ApiOperation(value = "获取所有的运输数据",notes = "获取运输设备数据:" + @ApiOperation(value = "获取所有的运输数据",notes = "获取运输设备数据:" +
"sum:总数量" + "sum:总数量;" +
"onRoute:在途数量" + "onRoute:在途数量;" +
"complted:已完成数量" + "delay:延误数量;" +
"alarmed: 报警数量" + "alarmed: 报警数量;" +
"routeVoList: " + "bump:颠簸数量;" +
"transportationNo:线路编号(R+TyyyyMMdd+运输方式+四位随机数)"+ "list: " +
"routeName:路由名称(出发地-启运地)"+ "{classify:报警描述;"+
"startLongitude:启运经度"+ "count:数量;}"+
"startLatitude:启运纬度"+
"startCity:启运市"+
"startTime:开始时间"+
"endLongitude:目的经度"+
"endLatitude:目的纬度"+
"endCity:目的市"+
"endTime:结束时间"+
"transport:运输方式(T铁路,G汽运,H海运,K空运,D快递)"+
"boxNo:箱单号" +
"containerNo:集装箱号/车牌号" +
"deliveryAddress:交付地点" +
"transportationType:运输类型" +
"circuitState:线路状态"+
"remark:备注" +
"alarmLogVoList :"+ "alarmLogVoList :"+
"routeName:线路名称"+ "{description:报警描述;" +
"description:报警描述" + "data:数值;" +
"data:数据"+ "alarmTime:报警时间;}" +
"alarmTime:报警时间") "circuitList:" +
"{transportationNo:运输编号;" +
"cargoNo:货物编号;" +
"startCity:开始城市;" +
"endCity:目的城市;" +
"startTime:开始时间;" +
"endTime:到达时间;" +
"lng:当前经度;" +
"lat:当前纬度;" +
"time:当前时间;}")
@PostMapping("/getAll") @PostMapping("/getAll")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"), @ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
}) })
public Object getAll(@RequestBody Integer time){ public Object getAll(@RequestBody String time){
JSONObject jsonObject= JSON.parseObject(time);
time=(String) jsonObject.get("time");
//获取数量 //获取数量
HomePageDataVo dataVo = new HomePageDataVo(); HomePageDataVo dataVo = new HomePageDataVo();
//获取所有的线路数量 //获取所有的线路数量
Integer sum = circuitService.getCount(time); dataVo.setSum(circuitService.getCount(time));//总数量
dataVo.setSum(sum);//总数量 dataVo.setOnRoute(circuitService.getOnRoute(time));//在途数量
Integer onRoute = circuitService.getOnRoute(time); dataVo.setDelay(circuitService.getDelayCount(System.currentTimeMillis(),time));//延误数量
dataVo.setOnRoute(onRoute);//在途数量 dataVo.setAlarmed( alarmLogServcie.getCount(time));//报警数量
//获取延误数量 dataVo.setBump(alarmLogServcie.getBumpCount(time)); //获取颠簸数量
Integer delay = circuitService.getDelayCount(System.currentTimeMillis()); dataVo.setAlarmLogVoList(alarmLogServcie.getAlarmLog(time));//报警列表
dataVo.setDelay(delay); List<HistogramData> list = alarmLogServcie.getByCount(time);//获取报警柱状图
//获取已经完成的数量
Integer alarmed = alarmLogServcie.getCount(time);
dataVo.setAlarmed(alarmed);//报警数量
//获取颠簸数量
Integer bump = alarmLogServcie.getBumpCount(time);
dataVo.setBump(bump);
//获取所有的报警
// 获取所有的路线数量
List<AlarmLogVo> alarmLogVos = new ArrayList<>();
dataVo.setAlarmLogVoList(alarmLogVos);//报警列表
//获取设备的当前位置
List<ResultCircuitVo> circuitVos = circuitService.getByTime(time);
List<CircuitVo> circuitList = new ArrayList<>();
for(int i = 0;i<circuitVos.size();i++){
CircuitVo circuitVo = new CircuitVo();
circuitVo.setTransportationNo(circuitVos.get(i).getTransportationNo());
circuitVo.setCargoNo(circuitVos.get(i).getCargoNo());
circuitVo.setStartCity(circuitVos.get(i).getStartCity());
circuitVo.setEndCity(circuitVos.get(i).getEndCity());
circuitVo.setStartTime(circuitVos.get(i).getStartTime());
circuitVo.setEndTime(circuitVos.get(i).getEndTime());
ResultGatewayVo gatewayVo = new ResultGatewayVo();
if (circuitVos.get(i).getStartTime() == null || circuitVos.get(i).getStartTime() == 0) {
circuitList.add(circuitVo);
} else {
if(circuitVos.get(i).getEndTime() == null ||circuitVos.get(i).getEndTime() == 0 ){
gatewayVo = circuitService.getByNo(circuitVos.get(i).getTransportationNo());
}else{
gatewayVo = tdlLogService.getByNo(circuitVos.get(i).getTransportationNo());
}
if(gatewayVo==null){
circuitList.add(circuitVo);
}else {
String device = gatewayVo.getType() + "_" + gatewayVo.getSN();
Long startTime = circuitVos.get(i).getStartTime() * 1000000l;
String sql = "";
if (circuitVos.get(i).getEndTime() == null || circuitVos.get(i).getEndTime() == 0) {
sql = "SELECT \"lng\",\"lat\" FROM \"tdl_policy\".\"" + device + "\"where time >= " + startTime + " ORDER BY time desc limit 1";
} else {
sql = "SELECT \"lng\",\"lat\" FROM \"tdl_policy\".\"" + device + "\"where time >= " + startTime + " and time<= " + circuitVos.get(i).getEndTime() * 1000000l + " ORDER BY time desc limit 1";
}
QueryResult queryResult = influxDBTemplate.query(new Query(sql, database));
if (queryResult.getResults().get(0).getSeries() != null) {
String value = queryResult.getResults().get(0).getSeries().get(0).getValues().get(0).get(0).toString();
circuitVo.setTime(parseTime(queryResult.getResults().get(0).getSeries().get(0).getValues().get(0).get(0).toString()));
circuitVo.setLng(queryResult.getResults().get(0).getSeries().get(0).getValues().get(0).get(1).toString());
circuitVo.setLat(queryResult.getResults().get(0).getSeries().get(0).getValues().get(0).get(2).toString());
}
circuitList.add(circuitVo);
}
}
}
dataVo.setCircuitList(circuitList);
return gson.toJson(dataVo); return gson.toJson(dataVo);
} }
//解析时间
public String parseTime(String time){
String dateResult =null;
try {
dateResult = dateToStamp(time);
} catch (ParseException e) {
e.printStackTrace();
logger.info(e.toString());
fb.setCode(0);
fb.setMessage("解析时间异常");
}
return dateResult;
}
//将utc时间转换成时间戳
public static String dateToStamp(String s) throws ParseException {
Date date =null ;
if(s.length() !=20 ) {
date = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").parse(s);
}else{
date = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").parse(s);
}
return String.valueOf(date.getTime());
}
} }
package com.example.tdl.web;
import com.example.tdl.domain.dto.CommFeedback;
import com.google.gson.Gson;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/route")
public class RouteController {
private Logger logger = LoggerFactory.getLogger(RouteController.class);
CommFeedback fb=new CommFeedback();
Gson gson=new Gson();
// @Autowired
// private RouteService routeService=new RouteService();
//
// @Autowired
// private TokenRedisService tokenRedisService;
//
//
// //查询所有路由信息
// @ApiOperation(value = "查询所有路由信息",notes = "查询所有路由信息,返回值说明:" +
// " routeNumber:路由编号," +
// " routeName:路由名称," +
// " startCountry: 启运国家," +
// " startProvince:启运省," +
// " startCity:启运市," +
// " endCountry:目的国家," +
// " endProvince:目的省," +
// " endCity:目的市," +
// " transport:运输方式," +
// " remark:路由备注")
// @ApiImplicitParams({
// @ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
// })
// @RequestMapping(value="/getAll",method = RequestMethod.GET)
// public Object getAll(){
// return routeService.getAll();
// }
//
// //根据条件查询路由信息
// @ApiOperation(value = "根据条件查询路由信息",notes = "根据条件查询路由信息,传值说明:" +
// " routeNumber:路由编号," +
// " routeName:路由名称," +
// " startCity:启运市," +
// " endCity:目的市," +
// " transport:运输方式。" +
// "--------------------" +
// "返回值说明:" +
// " routeNumber:路由编号," +
// " routeName:路由名称," +
// " startCountry: 启运国家," +
// " startProvince:启运省," +
// " startCity:启运市," +
// " endCountry:目的国家," +
// " endProvince:目的省," +
// " endCity:目的市," +
// " transport:运输方式," +
// " remark:路由备注")
// @ApiImplicitParams({
// @ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
// })
// @RequestMapping(value="/getRouteByTerm",method = RequestMethod.POST)
// public Object getRouteByTerm(@RequestBody RouteTermVo routeTermVo){
// return routeService.getRouteByTerm(routeTermVo);
// }
//
// @ApiOperation(value = "添加路由信息",notes = "添加路由信息,都要传,说明:" +
// " startCountry: 启运国家," +
// " startProvince:启运省," +
// " startCity:启运市," +
// " endCountry:目的国家," +
// " endProvince:目的省," +
// " endCity:目的市," +
// " transport:运输方式," +
// " remark:路由备注")
// @ApiImplicitParams({
// @ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
// })
// @RequestMapping(value="/addRoute",method = RequestMethod.POST)
// public Object addRoute(@RequestBody AddRouteVo addRouteVo){
// if (StringUtils.isEmpty(addRouteVo.getStartCountry())){
// fb.setCode(0);
// fb.setMessage("启运国不能为空");
// return gson.toJson(fb);
// }
// if (StringUtils.isEmpty(addRouteVo.getStartCity())){
// fb.setCode(0);
// fb.setMessage("启运市不能为空");
// return gson.toJson(fb);
// }
// if (StringUtils.isEmpty(addRouteVo.getEndCountry())){
// fb.setCode(0);
// fb.setMessage("目的国不能为空");
// return gson.toJson(fb);
// }
// if (StringUtils.isEmpty(addRouteVo.getEndCity())){
// fb.setCode(0);
// fb.setMessage("目的市不能为空");
// return gson.toJson(fb);
// }
// if (StringUtils.isEmpty(addRouteVo.getTransport())){
// fb.setCode(0);
// fb.setMessage("运输方式不能为空");
// return gson.toJson(fb);
// }
// if (!addRouteVo.getTransport().equals("铁路")&&
// !addRouteVo.getTransport().equals("汽运")&&
// !addRouteVo.getTransport().equals("海运")&&
// !addRouteVo.getTransport().equals("空运")&&
// !addRouteVo.getTransport().equals("快递")){
// fb.setCode(0);
// fb.setMessage("请选择正确的运输方式");
// return gson.toJson(fb);
// }
// String routeName=addRouteVo.getStartCountry()+addRouteVo.getStartCity()+"_"+addRouteVo.getEndCountry()+addRouteVo.getEndCity();
// Date day=new Date();
// SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");
// String routeNumbers="RT"+df.format(day);
// if (addRouteVo.getTransport().equals("汽运")){
// routeNumbers=routeNumbers+"G";
// routeName=routeName+"_汽运";
// }
// if (addRouteVo.getTransport().equals("铁路")){
// routeNumbers=routeNumbers+"T";
// routeName=routeName+"_铁路";
// }
// if (addRouteVo.getTransport().equals("空运")){
// routeNumbers=routeNumbers+"K";
// routeName=routeName+"_空运";
// }
// if (addRouteVo.getTransport().equals("快递")){
// routeNumbers=routeNumbers+"D";
// routeName=routeName+"_快递";
// }
// if (addRouteVo.getTransport().equals("海运")){
// routeNumbers=routeNumbers+"H";
// routeName=routeName+"_海运";
// }
// String routeNumber=routeNumbers+((int)(Math.random()*(9999-1000+1))+1000);
// if (routeService.getByRouteNumber(routeNumber)>0){
// while (routeService.getByRouteNumber(routeNumber)>0){
// routeNumber=routeNumbers+((int)(Math.random()*(9999-1000+1))+1000);
// }
// }
// if (routeService.getInfoByRouteName(routeName)!=null){
// fb.setCode(0);
// fb.setMessage("该路由已存在");
// return gson.toJson(fb);
// }
// Map<Object,Object> map=new HashMap<>();
// map.put("routeNumber",routeNumber);
// map.put("routeName",routeName);
// map.put("startCountry",addRouteVo.getStartCountry());
// map.put("startProvince",addRouteVo.getStartProvince());
// map.put("startCity",addRouteVo.getStartCity());
// map.put("endCountry",addRouteVo.getEndCountry());
// map.put("endProvince",addRouteVo.getEndProvince());
// map.put("endCity",addRouteVo.getEndCity());
// map.put("transport",addRouteVo.getTransport());
// map.put("createTime",System.currentTimeMillis());
// map.put("updateTime",System.currentTimeMillis());
// map.put("remark",addRouteVo.getRemark());
// routeService.addRoute(map);
// Map<Object,Object> msg=new HashMap<>();
// msg.put("msg",map.get("msg"));
// if (msg.get("msg").equals("添加路由成功")){
// fb.setCode(1);
// fb.setMessage("添加路由成功");
// }else{
// fb.setCode(0);
// fb.setMessage(msg.get("msg").toString());
// }
// return gson.toJson(fb);
// }
//
// //删除路由信息
// @ApiOperation(value = "删除路由信息",notes = "删除路由信息,传递参数:{\"routeNumber\":\"需要删除的路由编号\"}")
// @RequestMapping(value="/delRoute",method = RequestMethod.POST)
// @ApiImplicitParams({
// @ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
// })
// public Object delRoute(@RequestBody String routeNumber){
// JSONObject jsonObject= JSON.parseObject(routeNumber);
// routeNumber=(String)jsonObject.get("routeNumber");
// if (StringUtils.isEmpty(routeNumber)){
// fb.setCode(0);
// fb.setMessage("需要删除的路由编号不能为空");
// return gson.toJson(fb);
// }
// int a=routeService.delRoute(routeNumber);
// if (a>0){
// fb.setCode(1);
// fb.setMessage("删除路由信息成功");
// }else{
// fb.setCode(0);
// fb.setMessage("删除路由信息失败");
// }
// return gson.toJson(fb);
// }
//
//
//
//
//
//// @ApiOperation(value = "修改路由信息",notes = "修改路由信息,都要传,路由编号是需要修改的路由编号,不能改,说明:" +
//// " routeNumber:路由编号," +
//// " routeName:路由名称," +
//// " abbreviation:名称缩写," +
//// " startLongitude:启运经度," +
//// " startLatitude:启运纬度," +
//// " startCountry: 启运国家," +
//// " startProvince:启运省," +
//// " startCity:启运市," +
//// " startAddress:启运地址," +
//// " endLongitude:目的经度," +
//// " endLatitude:目的纬度," +
//// " endCountry:目的国家," +
//// " endProvince:目的省," +
//// " endCity:目的市," +
//// " endAddress:目的地址," +
//// " transport:运输方式," +
//// " transportRemark:运输方式备注," +
//// " remark:路由备注")
//// @ApiImplicitParams({
//// @ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
//// })
//// @RequestMapping(value="/updateRoute",method = RequestMethod.POST)
//// public Object updateRoute(@RequestBody UpdateRouteVo updateRouteVo){
//// if (StringUtils.isEmpty(updateRouteVo.getStartLatitude())){
//// fb.setCode(0);
//// fb.setMessage("启运纬度不能为空");
//// return gson.toJson(fb);
//// }
//// if (StringUtils.isEmpty(updateRouteVo.getStartLongitude())){
//// fb.setCode(0);
//// fb.setMessage("启运经度不能为空");
//// return gson.toJson(fb);
//// }
//// if(!updateRouteVo.getStartLatitude().matches("^-?(([1-9])((\\.\\d{1,6})?)|([1-8]\\d)((\\.\\d{1,6})?)|90)$")){
//// fb.setCode(0);
//// fb.setMessage("启运纬度的范围为-90~90");
//// return gson.toJson(fb);
//// }
//// if(!updateRouteVo.getStartLongitude().matches("^-?(([1-9]\\d?)((\\.\\d{1,6})?)|(1[1-7]\\d)((\\.\\d{1,6})?)|180)$")) {
//// fb.setCode(0);
//// fb.setMessage("启运经度的范围为-180~180");
//// return gson.toJson(fb);
//// }
//// if (StringUtils.isEmpty(updateRouteVo.getStartCountry())){
//// fb.setCode(0);
//// fb.setMessage("启运国不能为空");
//// return gson.toJson(fb);
//// }
//// if (StringUtils.isEmpty(updateRouteVo.getStartProvince())){
//// fb.setCode(0);
//// fb.setMessage("启运省不能为空");
//// return gson.toJson(fb);
//// }
//// if (StringUtils.isEmpty(updateRouteVo.getStartCity())){
//// fb.setCode(0);
//// fb.setMessage("启运市不能为空");
//// return gson.toJson(fb);
//// }
//// if (StringUtils.isEmpty(updateRouteVo.getStartAddress())){
//// fb.setCode(0);
//// fb.setMessage("启运地址不能为空");
//// return gson.toJson(fb);
//// }
//// if (StringUtils.isEmpty(updateRouteVo.getEndLatitude())){
//// fb.setCode(0);
//// fb.setMessage("目的纬度不能为空");
//// return gson.toJson(fb);
//// }
//// if (StringUtils.isEmpty(updateRouteVo.getEndLongitude())){
//// fb.setCode(0);
//// fb.setMessage("目的经度不能为空");
//// return gson.toJson(fb);
//// }
//// if(!updateRouteVo.getEndLatitude().matches("^-?(([1-9])((\\.\\d{1,6})?)|([1-8]\\d)((\\.\\d{1,6})?)|90)$")){
//// fb.setCode(0);
//// fb.setMessage("目的纬度的范围为-90~90");
//// return gson.toJson(fb);
//// }
//// if(!updateRouteVo.getEndLongitude().matches("^-?(([1-9]\\d?)((\\.\\d{1,6})?)|(1[1-7]\\d)((\\.\\d{1,6})?)|180)$")) {
//// fb.setCode(0);
//// fb.setMessage("目的经度的范围为-180~180");
//// return gson.toJson(fb);
//// }
//// if (StringUtils.isEmpty(updateRouteVo.getEndCountry())){
//// fb.setCode(0);
//// fb.setMessage("目的国不能为空");
//// return gson.toJson(fb);
//// }
//// if (StringUtils.isEmpty(updateRouteVo.getEndProvince())){
//// fb.setCode(0);
//// fb.setMessage("目的省不能为空");
//// return gson.toJson(fb);
//// }
//// if (StringUtils.isEmpty(updateRouteVo.getEndCity())){
//// fb.setCode(0);
//// fb.setMessage("目的市不能为空");
//// return gson.toJson(fb);
//// }
//// if (StringUtils.isEmpty(updateRouteVo.getEndAddress())){
//// fb.setCode(0);
//// fb.setMessage("目的地址不能为空");
//// return gson.toJson(fb);
//// }
//// if (StringUtils.isEmpty(updateRouteVo.getTransport())){
//// fb.setCode(0);
//// fb.setMessage("运输方式不能为空");
//// return gson.toJson(fb);
//// }
//// if (!updateRouteVo.getTransport().equals("铁路")&&!updateRouteVo.getTransport().equals("汽运")&&!updateRouteVo.getTransport().equals("海运")&&
//// !updateRouteVo.getTransport().equals("空运")&&!updateRouteVo.getTransport().equals("快递")){
//// fb.setCode(0);
//// fb.setMessage("请选择正确的运输方式");
//// return gson.toJson(fb);
//// }
//// String routeName=updateRouteVo.getStartCity()+"-"+updateRouteVo.getEndCity();
//// String abbreviation=routeName;
//// if (updateRouteVo.getTransport().equals("汽运")){
//// abbreviation=abbreviation+"-G";
//// }
//// if (updateRouteVo.getTransport().equals("铁路")){
//// abbreviation=abbreviation+"-T";
//// }
//// if (updateRouteVo.getTransport().equals("空运")){
//// abbreviation=abbreviation+"-K";
//// }
//// if (updateRouteVo.getTransport().equals("快递")){
//// abbreviation=abbreviation+"-D";
//// }
//// if (updateRouteVo.getTransport().equals("海运")){
//// abbreviation=abbreviation+"-H";
//// }
//// int a=routeService.updateRoute(new Route(updateRouteVo.getRouteNumber(),routeName,abbreviation,updateRouteVo.getStartLongitude(),updateRouteVo.getStartLatitude(),
//// updateRouteVo.getStartCountry(),updateRouteVo.getStartProvince(),updateRouteVo.getStartCity(),updateRouteVo.getStartAddress(),
//// updateRouteVo.getEndLongitude(),updateRouteVo.getEndLatitude(),updateRouteVo.getEndCountry(),updateRouteVo.getEndProvince(),updateRouteVo.getEndCity(),
//// updateRouteVo.getEndAddress(),updateRouteVo.getTransport(),updateRouteVo.getTransportRemark(),System.currentTimeMillis(),updateRouteVo.getRemark()));
//// if (a>0){
//// fb.setCode(1);
//// fb.setMessage("修改路由成功");
//// }else{
//// fb.setCode(0);
//// fb.setMessage("修改路由失败");
//// }
//// return gson.toJson(fb);
////
//// }
}
...@@ -2,19 +2,18 @@ ...@@ -2,19 +2,18 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.tdl.mapper.AlarmLogMapper"> <mapper namespace="com.example.tdl.mapper.AlarmLogMapper">
<!--获取所有的报警数据--> <!--获取所有的报警数据-->
<select id="getAll" resultType="com.example.tdl.domain.vo.AlarmLogVo"> <select id="getAll" resultType="com.example.tdl.domain.vo.ResultAlarmLog">
select TDLSN,description,data,alarmTime from alarm_log select transportationNo,TDLSN,description,data,alarmTime,classify from alarm_log
where DATE_SUB(CURDATE(), INTERVAL 3 DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s'))
order by alarmTime desc; order by alarmTime desc;
</select> </select>
<select id="getByTransportationNo" resultType="com.example.tdl.domain.vo.ResultAlarmLog" parameterType="String"> <select id="getByTransportationNo" resultType="com.example.tdl.domain.vo.ResultAlarmLog" parameterType="String">
select transportationNo,TDLSN,description,data,alarmTime from alarm_log where transportationNo=#{transportationNo,jdbcType=VARCHAR}; select transportationNo,TDLSN,description,data,alarmTime,classify from alarm_log where transportationNo=#{transportationNo,jdbcType=VARCHAR};
</select> </select>
<!--根据条件获取报警数据--> <!--根据条件获取报警数据-->
<select id="getAlarmLog" resultType="com.example.tdl.domain.vo.AlarmLogVo"> <select id="getAlarmLog" parameterType="String" resultType="com.example.tdl.domain.vo.AlarmLogVo">
select TDLSN,description,data,alarmTime select description,data,alarmTime
from alarm_log from alarm_log
where DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s')) where DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s'))
order by alarmTime desc; order by alarmTime desc;
...@@ -32,34 +31,43 @@ ...@@ -32,34 +31,43 @@
) )
</insert> </insert>
<select id="getCount" resultType="java.lang.Integer"> <select id="getCount" resultType="java.lang.Integer" parameterType="String">
select count(DISTINCT transportationNo) from alarm_log select count(DISTINCT transportationNo) from alarm_log
where DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=INTEGER} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s')) where DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s'))
</select> </select>
<select id="getBumpCount" resultType="java.lang.Integer"> <select id="getBumpCount" resultType="java.lang.Integer" parameterType="String">
select count(DISTINCT transportationNo) from alarm_log select count(DISTINCT transportationNo) from alarm_log
where description like CONCAT(CONCAT('%',"震动"),'%') where description like CONCAT(CONCAT('%',"震动"),'%')
and DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=INTEGER} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s')) and DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s'))
</select> </select>
<select id = "getByCount" parameterType="java.lang.Integer" > <select id = "getByCount" parameterType="String" resultType="com.example.tdl.domain.vo.HistogramData" >
SELECT description,count(description) FROM alarm_log WHERE description LIKE "温度%" SELECT classify,count(description) FROM alarm_log WHERE classify = "温度"
AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=INTEGER} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s')) AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s'))
UNION ALL
SELECT classify,count(description) FROM alarm_log WHERE classify = "震动"
AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s'))
UNION ALL UNION ALL
SELECT description,count(description) FROM alarm_log WHERE description LIKE "震动%" SELECT classify,count(description) FROM alarm_log WHERE classify = "湿度"
AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=INTEGER} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s')) AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s'))
UNION ALL UNION ALL
SELECT description,count(description) FROM alarm_log WHERE description LIKE "湿度%" SELECT classify,count(description) FROM alarm_log WHERE classify = "光爆"
AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=INTEGER} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s')) AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s'))
UNION ALL UNION ALL
SELECT description,count(description) FROM alarm_log WHERE description LIKE "光爆%" SELECT classify,count(description) FROM alarm_log WHERE classify = "延迟"
AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=INTEGER} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s')) AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s'))
UNION ALL UNION ALL
SELECT description,count(description) FROM alarm_log WHERE description LIKE "延迟%" SELECT classify,count(description) FROM alarm_log WHERE classify = "离线"
AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=INTEGER} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s')) AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s'))
UNION ALL UNION ALL
SELECT description,count(description) FROM alarm_log WHERE description LIKE "离线%" SELECT classify,count(description) FROM alarm_log WHERE classify = "倾角"
AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=INTEGER} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s')) AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s'))
</select>
<select id="getByTime" resultType="java.lang.Integer">
select count(id) from alarm_log
where transportationNo= #{transportationNo,jdbcType=VARCHAR}
and alarmTime between #{startTime,jdbcType=BIGINT} and #{endTime,jdbcType=BIGINT}
</select> </select>
</mapper> </mapper>
\ No newline at end of file
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
<select id="getAll" resultType="com.example.tdl.domain.vo.ResultCircuitVo"> <select id="getAll" resultType="com.example.tdl.domain.vo.ResultCircuitVo">
SELECT transportationNo,cargoNo,(SELECT city from city WHERE id =(SELECT city_id from circuit_transfer WHERE circuit_id=c.id ORDER BY sequence LIMIT 1)) startCity, SELECT transportationNo,cargoNo,(SELECT city from city WHERE id =(SELECT city_id from circuit_transfer WHERE circuit_id=c.id ORDER BY sequence LIMIT 1)) startCity,
startTime,(SELECT city from city WHERE id =(SELECT city_id from circuit_transfer WHERE circuit_id=c.id ORDER BY sequence DESC LIMIT 1)) endCity,endTime,circuitState, startTime,(SELECT city from city WHERE id =(SELECT city_id from circuit_transfer WHERE circuit_id=c.id ORDER BY sequence DESC LIMIT 1)) endCity,endTime,circuitState,
IFNULL((SELECT alarmType FROM alarm WHERE id=c.alarm_id),"正常") alarmType from circuit c where c.state=1 (SELECT alarmType FROM alarm WHERE id=c.alarm_id) alarmType,(select GROUP_CONCAT(DISTINCT classify) alarm from alarm_log al where al.transportationNo = c.transportationNo) alarm,evaluate
from circuit c where c.state=1
</select> </select>
...@@ -13,7 +14,8 @@ ...@@ -13,7 +14,8 @@
<select id="getByTerm" resultType="com.example.tdl.domain.vo.ResultCircuitVo" parameterType="com.example.tdl.domain.vo.CircuitTermVo"> <select id="getByTerm" resultType="com.example.tdl.domain.vo.ResultCircuitVo" parameterType="com.example.tdl.domain.vo.CircuitTermVo">
SELECT transportationNo,cargoNo,(SELECT city from city WHERE id =(SELECT city_id from circuit_transfer WHERE circuit_id=c.id ORDER BY sequence LIMIT 1)) startCity, SELECT transportationNo,cargoNo,(SELECT city from city WHERE id =(SELECT city_id from circuit_transfer WHERE circuit_id=c.id ORDER BY sequence LIMIT 1)) startCity,
startTime,(SELECT city from city WHERE id =(SELECT city_id from circuit_transfer WHERE circuit_id=c.id ORDER BY sequence DESC LIMIT 1)) endCity,endTime,circuitState, startTime,(SELECT city from city WHERE id =(SELECT city_id from circuit_transfer WHERE circuit_id=c.id ORDER BY sequence DESC LIMIT 1)) endCity,endTime,circuitState,
IFNULL((SELECT alarmType FROM alarm WHERE id=c.alarm_id),"正常") alarmType from circuit c where c.state=1 (SELECT alarmType FROM alarm WHERE id=c.alarm_id) alarmType,(select GROUP_CONCAT(DISTINCT classify) alarm from alarm_log al where al.transportationNo = c.transportationNo) alarm,evaluate
from circuit c where c.state=1
<if test="circuitState!=null"> <if test="circuitState!=null">
AND circuitState=#{circuitState,jdbcType=INTEGER} AND circuitState=#{circuitState,jdbcType=INTEGER}
</if> </if>
...@@ -28,7 +30,7 @@ ...@@ -28,7 +30,7 @@
</if> </if>
</select> </select>
<!--新增一条线路-->
<insert id="addCircuit" parameterType="java.util.Map" statementType="CALLABLE"> <insert id="addCircuit" parameterType="java.util.Map" statementType="CALLABLE">
<![CDATA[ <![CDATA[
{ {
...@@ -69,7 +71,7 @@ ...@@ -69,7 +71,7 @@
]]> ]]>
</insert> </insert>
<!--修改线路信息-->
<update id="updateCircuit" parameterType="java.util.Map" statementType="CALLABLE"> <update id="updateCircuit" parameterType="java.util.Map" statementType="CALLABLE">
<![CDATA[ <![CDATA[
{ {
...@@ -105,6 +107,12 @@ ...@@ -105,6 +107,12 @@
</update> </update>
<!--删除线路-->
<delete id="delCircuit" parameterType="String">
UPDATE circuit set state=0
WHERE transportationNo=#{transportationNo,jdbcType=VARCHAR}
</delete>
<!-- 修改结束时间--> <!-- 修改结束时间-->
<update id="updateEndTime" parameterType="com.example.tdl.domain.vo.UpdateCircuitVo"> <update id="updateEndTime" parameterType="com.example.tdl.domain.vo.UpdateCircuitVo">
UPDATE circuit set UPDATE circuit set
...@@ -113,29 +121,21 @@ ...@@ -113,29 +121,21 @@
</update> </update>
<!--删除线路-->
<delete id="delCircuit" parameterType="String">
UPDATE circuit set state=0
WHERE transportationNo=#{transportationNo,jdbcType=VARCHAR}
</delete>
<!-- 运输中数量--> <!-- 运输中数量-->
<select id="getOnRoute" resultType="java.lang.Integer"> <select id="getOnRoute" resultType="java.lang.Integer" parameterType="String">
select count( startTime) from circuit where circuitState=1 select count( startTime) from circuit where circuitState=1 and DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(createTime/1000,'%Y-%m-%d %H:%i:%s'))
</select> </select>
<!--延误数量--> <!--延误数量-->
<select id="getDelayCount" resultType="java.lang.Integer" parameterType="java.lang.Integer"> <select id="getDelayCount" resultType="java.lang.Integer" >
select count(id) from circuit where state =1 and endtime &lt;=compTime or compTime >= #{compTime,jdbcType=BIGINT} select count(id) from circuit where state =1 and endtime &lt;=compTime or compTime >= #{compTime,jdbcType=BIGINT}
</select> </select>
<!--总数量--> <!--总数量-->
<select id="getCount" resultType="java.lang.Integer"> <select id="getCount" resultType="java.lang.Integer" parameterType="String">
select count(id) from circuit select count(id) from circuit where DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(createTime/1000,'%Y-%m-%d %H:%i:%s'))
</select> </select>
<!--根据线路编号获取线路信息--> <!--根据线路编号获取线路信息-->
<select id="getByTransportationNo" resultType="com.example.tdl.domain.vo.ResultCircuitVo" parameterType="String"> <select id="getByTransportationNo" resultType="com.example.tdl.domain.vo.ResultCircuitVo" parameterType="String">
SELECT transportationNo,cargoNo,(SELECT city from city WHERE id =(SELECT city_id from circuit_transfer WHERE circuit_id=c.id ORDER BY sequence LIMIT 1)) startCity, SELECT transportationNo,cargoNo,(SELECT city from city WHERE id =(SELECT city_id from circuit_transfer WHERE circuit_id=c.id ORDER BY sequence LIMIT 1)) startCity,
...@@ -145,13 +145,12 @@ ...@@ -145,13 +145,12 @@
AND transportationNo=#{transportationNo,jdbcType=VARCHAR} AND transportationNo=#{transportationNo,jdbcType=VARCHAR}
</select> </select>
<!--根据车牌号查线路--> <!--根据车牌号查线路-->
<select id="getByContainerNo" parameterType="String" resultType="com.example.tdl.domain.vo.ResultCircuitVo"> <select id="getByContainerNo" parameterType="String" resultType="com.example.tdl.domain.vo.ResultCircuitVo">
SELECT transportationNo,cargoNo,(SELECT city from city WHERE id =(SELECT city_id from circuit_transfer WHERE circuit_id=c.id ORDER BY sequence LIMIT 1)) startCity, SELECT transportationNo,cargoNo,(SELECT city from city WHERE id =(SELECT city_id from circuit_transfer WHERE circuit_id=c.id ORDER BY sequence LIMIT 1)) startCity,
startTime,(SELECT city from city WHERE id =(SELECT city_id from circuit_transfer WHERE circuit_id=c.id ORDER BY sequence DESC LIMIT 1)) endCity,endTime,circuitState, startTime,(SELECT city from city WHERE id =(SELECT city_id from circuit_transfer WHERE circuit_id=c.id ORDER BY sequence DESC LIMIT 1)) endCity,endTime,circuitState,
IFNULL((SELECT alarmType FROM alarm WHERE id=c.alarm_id),"正常") alarmType from circuit c (SELECT alarmType FROM alarm WHERE id=c.alarm_id) alarmType,(select GROUP_CONCAT(DISTINCT classify) alarm from alarm_log al where al.transportationNo = c.transportationNo) alarm,evaluate
where c.state=1 AND cargoNo=#{cargoNo,jdbcType=VARCHAR} from circuit c where c.state=1 AND cargoNo=#{cargoNo,jdbcType=VARCHAR}
</select> </select>
...@@ -159,8 +158,8 @@ ...@@ -159,8 +158,8 @@
<select id="getByCircuitState" parameterType="java.lang.Integer" resultType="com.example.tdl.domain.vo.ResultCircuitVo"> <select id="getByCircuitState" parameterType="java.lang.Integer" resultType="com.example.tdl.domain.vo.ResultCircuitVo">
SELECT transportationNo,cargoNo,(SELECT city from city WHERE id =(SELECT city_id from circuit_transfer WHERE circuit_id=c.id ORDER BY sequence LIMIT 1)) startCity, SELECT transportationNo,cargoNo,(SELECT city from city WHERE id =(SELECT city_id from circuit_transfer WHERE circuit_id=c.id ORDER BY sequence LIMIT 1)) startCity,
startTime,(SELECT city from city WHERE id =(SELECT city_id from circuit_transfer WHERE circuit_id=c.id ORDER BY sequence DESC LIMIT 1)) endCity,endTime,circuitState, startTime,(SELECT city from city WHERE id =(SELECT city_id from circuit_transfer WHERE circuit_id=c.id ORDER BY sequence DESC LIMIT 1)) endCity,endTime,circuitState,
IFNULL((SELECT alarmType FROM alarm WHERE id=c.alarm_id),"正常") alarmType from circuit c where c.state=1 (SELECT alarmType FROM alarm WHERE id=c.alarm_id) alarmType,(select GROUP_CONCAT(DISTINCT classify) alarm from alarm_log al where al.transportationNo = c.transportationNo) alarm,evaluate
AND circuitState=#{circuitState,jdbcType=INTEGER} from circuit c where c.state=1 AND circuitState=#{circuitState,jdbcType=INTEGER}
</select> </select>
<!--评价--> <!--评价-->
...@@ -181,6 +180,13 @@ ...@@ -181,6 +180,13 @@
SELECT id from circuit WHERE transportationNo=#{transportationNo,jdbcType=VARCHAR}) LIMIT 1) SELECT id from circuit WHERE transportationNo=#{transportationNo,jdbcType=VARCHAR}) LIMIT 1)
</select> </select>
<select id="getByTime" parameterType="java.lang.String" resultType="com.example.tdl.domain.vo.ResultCircuitVo">
SELECT transportationNo,cargoNo,(SELECT city from city WHERE id =(SELECT city_id from circuit_transfer WHERE circuit_id=c.id ORDER BY sequence LIMIT 1)) startCity,
startTime,(SELECT city from city WHERE id =(SELECT city_id from circuit_transfer WHERE circuit_id=c.id ORDER BY sequence DESC LIMIT 1)) endCity,endTime,circuitState,
(SELECT alarmType FROM alarm WHERE id=c.alarm_id) alarmType,(select GROUP_CONCAT(DISTINCT classify) alarm from alarm_log al where al.transportationNo = c.transportationNo) alarm,evaluate
from circuit c where c.state=1 AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(createTime/1000,'%Y-%m-%d %H:%i:%s'))
</select>
<!-- <!--
<select id="getDistinct" resultType="com.example.tdl.domain.vo.CircuitVo"> <select id="getDistinct" resultType="com.example.tdl.domain.vo.CircuitVo">
SELECT transportationNo,routeName,startLongitude,startLatitude,(select city from city_config where id=r.start_id) startCity,startTime,endLongitude,endLatitude, SELECT transportationNo,routeName,startLongitude,startLatitude,(select city from city_config where id=r.start_id) startCity,startTime,endLongitude,endLatitude,
...@@ -194,7 +200,6 @@ ...@@ -194,7 +200,6 @@
order BY c.id order BY c.id
</select> </select>
<select id="getByTime" resultType="com.example.tdl.domain.vo.CircuitVo"> <select id="getByTime" resultType="com.example.tdl.domain.vo.CircuitVo">
SELECT transportationNo,routeName,startLongitude,startLatitude,(select city from city_config where id=r.start_id) startCity,startTime,endLongitude,endLatitude, SELECT transportationNo,routeName,startLongitude,startLatitude,(select city from city_config where id=r.start_id) startCity,startTime,endLongitude,endLatitude,
(select city from city_config where id=r.end_id) endCity,endTime,transport,boxNo,containerNo,deliveryAddress, (select city from city_config where id=r.end_id) endCity,endTime,transport,boxNo,containerNo,deliveryAddress,
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.tdl.mapper.CircuitTransferMapper">
<select id="getCity" resultType="com.example.tdl.domain.vo.CircuitTransferVo" parameterType="String">
select c.city,ct.arrivalTime,ct.startTime,ct.sequence from circuit_transfer ct,city c,circuit cr
where c.id=ct.city_id
and ct.circuit_id =cr.id
and cr.transportationNo = #{transportationNo,jdbcType=VARCHAR}
</select>
</mapper>
\ No newline at end of file
...@@ -70,6 +70,12 @@ ...@@ -70,6 +70,12 @@
]]> ]]>
</update> </update>
<update id="updateState" parameterType="com.example.tdl.domain.vo.GatewayState">
UPDATE gateway set state= #{state,jdbcType=INTEGER}
where SN=#{SN,jdbcType=VARCHAR}
AND type=#{type,jdbcType=VARCHAR}
</update>
<!-- <insert id="addGateway" parameterType="com.example.tdl.domain.vo.AddGatewayVo"> <!-- <insert id="addGateway" parameterType="com.example.tdl.domain.vo.AddGatewayVo">
INSERT into gateway VALUES ( INSERT into gateway VALUES (
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.tdl.mapper.RouteMapper">
<!--查询所有路由信息-->
<!-- <select id="getAll" resultType="com.example.tdl.domain.vo.ResultRouteVo">
SELECT routeNumber,routeName,c.country startCountry,IFNULL(c.province,"") startProvince,c.city startCity,
f.country endCountry,IFNULL(f.province,"") endProvince,f.city endCity,transport,remark
FROM city_config f,route r INNER JOIN city_config c ON r.start_id=c.id
WHERE r.end_id=f.id AND state=1
</select>
&lt;!&ndash;根据条件查询路由信息&ndash;&gt;
<select id="getRouteByTerm" resultType="com.example.tdl.domain.vo.ResultRouteVo" parameterType="com.example.tdl.domain.vo.RouteTermVo">
SELECT routeNumber,routeName,c.country startCountry,IFNULL(c.province,"") startProvince,c.city startCity,
f.country endCountry,IFNULL(f.province,"") endProvince,f.city endCity,transport,remark
FROM city_config f,route r INNER JOIN city_config c ON r.start_id=c.id
WHERE r.end_id=f.id AND state=1
<if test="routeNumber!=null">
AND routeNumber like CONCAT(CONCAT('%',#{routeNumber,jdbcType=VARCHAR}), '%')
</if>
<if test="routeName!=null">
AND routeName like CONCAT(CONCAT('%',#{routeName,jdbcType=VARCHAR}), '%')
</if>
<if test="startCity!=null">
AND startCity like CONCAT(CONCAT('%',#{startCity,jdbcType=VARCHAR}), '%')
</if>
<if test="endCity!=null">
AND endCity like CONCAT(CONCAT('%',#{endCity,jdbcType=VARCHAR}), '%')
</if>
<if test="transport!=null">
AND transport=#{transport,jdbcType=VARCHAR}
</if>
</select>
&lt;!&ndash;添加路由信息&ndash;&gt;
<insert id="addRoute" parameterType="java.util.Map" statementType="CALLABLE">
<![CDATA[
{
call pro_addRoute(
#{routeNumber,mode=IN,jdbcType=VARCHAR},
#{routeName,mode=IN,jdbcType=VARCHAR},
#{startCountry,mode=IN,jdbcType=VARCHAR},
#{startProvince,mode=IN,jdbcType=VARCHAR},
#{startCity,mode=IN,jdbcType=VARCHAR},
#{endCountry,mode=IN,jdbcType=VARCHAR},
#{endProvince,mode=IN,jdbcType=VARCHAR},
#{endCity,mode=IN,jdbcType=VARCHAR},
#{transport,mode=IN,jdbcType=VARCHAR},
#{createTime,mode=IN,jdbcType=BIGINT},
#{updateTime,mode=IN,jdbcType=BIGINT},
#{remark,mode=IN,jdbcType=VARCHAR},
#{msg,mode=OUT,jdbcType=VARCHAR}
)
}
]]>
</insert>
<delete id="delRoute" parameterType="String">
UPDATE route set state=0 WHERE routeNumber=#{routeNumber,jdbcType=VARCHAR}
</delete>
<select id="getByRouteNumber" resultType="java.lang.Integer" parameterType="String">
SELECT COUNT(routeNumber) FROM route WHERE routeNumber=#{routeNumber,jdbcType=VARCHAR} AND state=1
</select>
<select id="getInfoByRouteNumber" resultType="com.example.tdl.domain.vo.ResultRouteVo" parameterType="String">
SELECT routeNumber,routeName,c.country startCountry,IFNULL(c.province,"") startProvince,c.city startCity,
f.country endCountry,IFNULL(f.province,"") endProvince,f.city endCity,transport,remark
FROM city_config f,route r INNER JOIN city_config c ON r.start_id=c.id
WHERE r.end_id=f.id AND routeNumber=#{routeNumber,jdbcType=VARCHAR} AND state=1
</select>
<select id="getInfoByRouteName" resultType="com.example.tdl.domain.vo.ResultRouteVo" parameterType="String">
SELECT routeNumber,routeName,c.country startCountry,IFNULL(c.province,"") startProvince,c.city startCity,
f.country endCountry,IFNULL(f.province,"") endProvince,f.city endCity,transport,remark
FROM city_config f,route r INNER JOIN city_config c ON r.start_id=c.id
WHERE r.end_id=f.id AND routeName=#{routeName,jdbcType=VARCHAR} AND state=1
</select>-->
<!-- <select id="getAllRoute" resultType="com.example.tdl.domain.vo.ResultRouteVo">
SELECT routeNumber,routeName,abbreviation,startLongitude,startLatitude,startCountry,startProvince,startCity,startAddress,
endLongitude,endLatitude,endCountry,endProvince,endCity,endAddress,transport,transportRemark,remark FROM route
where DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(createTime/1000,'%Y-%m-%d %H:%i:%s'))
AND state=1 order by createTime desc limit 10;
</select>-->
<!--修改路由信息-->
<!-- <update id="updateRoute" parameterType="com.example.tdl.entity.Route">
UPDATE route SET
routeName=#{routeName,jdbcType=VARCHAR},
abbreviation=#{abbreviation,jdbcType=VARCHAR},
startLongitude=#{startLongitude,jdbcType=VARCHAR},
startLatitude=#{startLatitude,jdbcType=VARCHAR},
startCountry=#{startCountry,jdbcType=VARCHAR},
startProvince=#{startProvince,jdbcType=VARCHAR},
startCity=#{startCity,jdbcType=VARCHAR},
startAddress=#{startAddress,jdbcType=VARCHAR},
endLongitude=#{endLongitude,jdbcType=VARCHAR},
endLatitude=#{endLatitude,jdbcType=VARCHAR},
endCountry=#{endCountry,jdbcType=VARCHAR},
endProvince=#{endProvince,jdbcType=VARCHAR},
endCity=#{endCity,jdbcType=VARCHAR},
endAddress=#{endAddress,jdbcType=VARCHAR},
transport=#{transport,jdbcType=VARCHAR},
transportRemark=#{transportRemark,jdbcType=VARCHAR},
updateTime=#{updateTime,jdbcType=BIGINT},
remark=#{remark,jdbcType=VARCHAR}
WHERE routeNumber=#{routeNumber,jdbcType=VARCHAR}
</update>-->
</mapper>
\ No newline at end of file
...@@ -25,14 +25,14 @@ ...@@ -25,14 +25,14 @@
SELECT id from gateway WHERE SN=#{SN,jdbcType=VARCHAR} AND type=#{type,jdbcType=VARCHAR})) SELECT id from gateway WHERE SN=#{SN,jdbcType=VARCHAR} AND type=#{type,jdbcType=VARCHAR}))
</delete> </delete>
<!-- <select id="getChannelByTopicName" parameterType="String" resultType="com.example.demo.domain.vo.DevChannelVo"> <select id="getProbes" parameterType="String" resultType="com.example.tdl.domain.vo.ResultTopicConfigVo">
SELECT dc.port,dc.unit,dc.description,dc.alias SELECT p.port,p.unit,p.description,p.alias,p.type,p.alarmUp,p.alarmDown,t.topicName,t.type tType,t.intervalTime,t.frequency
FROM topic_config tc,topic t,devchannel dc FROM topic_config tc,topic t,probes p
WHERE tc.devchannel_id=dc.id WHERE tc.probes_id=p.id
AND tc.topic_id=t.id AND tc.topic_id=t.id
AND dc.device_id = (select id from device where SN=#{SN,jdbcType=VARCHAR} AND type=#{type,jdbcType=VARCHAR})
AND t.topicName =#{topicName,jdbcType=VARCHAR} AND t.topicName =#{topicName,jdbcType=VARCHAR}
</select>--> AND p.gateway_id = (select id from gateway where SN=#{SN,jdbcType=VARCHAR} AND type=#{type,jdbcType=VARCHAR})
</select>
<!-- <insert id="addTopicConfig" statementType="CALLABLE" parameterType="java.util.Map"> <!-- <insert id="addTopicConfig" statementType="CALLABLE" parameterType="java.util.Map">
<![CDATA[ <![CDATA[
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
<mapper resource="mapper/RoleMapper.xml"/> <mapper resource="mapper/RoleMapper.xml"/>
<mapper resource="mapper/PermissionMapper.xml"/> <mapper resource="mapper/PermissionMapper.xml"/>
<mapper resource="mapper/RoleHasPermissionMapper.xml"/> <mapper resource="mapper/RoleHasPermissionMapper.xml"/>
<mapper resource="mapper/RouteMapper.xml"/>
<mapper resource="mapper/AlarmMapper.xml"/> <mapper resource="mapper/AlarmMapper.xml"/>
<mapper resource="mapper/WarehouseMapper.xml"/> <mapper resource="mapper/WarehouseMapper.xml"/>
<mapper resource="mapper/TDLDeviceMapper.xml"/> <mapper resource="mapper/TDLDeviceMapper.xml"/>
...@@ -51,5 +50,7 @@ ...@@ -51,5 +50,7 @@
<mapper resource="mapper/UserAddressMapper.xml"/> <mapper resource="mapper/UserAddressMapper.xml"/>
<mapper resource="mapper/TransferModelMapper.xml"/> <mapper resource="mapper/TransferModelMapper.xml"/>
<mapper resource="mapper/TransferModelConfigMapper.xml"/> <mapper resource="mapper/TransferModelConfigMapper.xml"/>
<mapper resource="mapper/TransferModelMapper.xml"/>
<mapper resource="mapper/CircuitTransferMapper.xml"/>
</mappers> </mappers>
</configuration> </configuration>
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