Commit cc9776bc authored by zhuangzhuang's avatar zhuangzhuang

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

parent 1f632754
......@@ -110,8 +110,8 @@ public class GWConfigWorker implements Callable<String>, MqttCallback {
mqttAsyncClient.subscribe(RespTopic, qos);//订阅主题
}
//获取数据
//ConfigVo configVo = configService.getConfig(SN,Type);
//ConfigCMD = configVo.getMessage();
ConfigVo configVo = configService.getConfig(SN,Type);
ConfigCMD = configVo.getMessage();
//发送数据
publish(ConfigCMD,ConfigTopic);
} catch (MqttException e){
......@@ -175,15 +175,15 @@ public class GWConfigWorker implements Callable<String>, MqttCallback {
this.ret_data = Message;
//解析Message消息
RespVo respVo = new Gson().fromJson(Message,RespVo.class);
// if(respVo.getResponse().equals("config")){
// //配置回复
// configService.bindiSuccess(SN,Type,respVo.getStatus());
// }else{
// //解绑回复
// if(respVo.getStatus() ==0 || respVo.getStatus() == 1){
// configService.delConfig(SN,Type);
// }
// }
if(respVo.getResponse().equals("config")){
//配置回复
configService.bindiSuccess(SN,Type,respVo.getStatus());
}else{
//解绑回复
if(respVo.getStatus() ==0 || respVo.getStatus() == 1){
configService.delConfig(SN,Type);
}
}
if(NeedResp){
mqttAsyncClient.unsubscribe(RespTopic);//不监听回复主题
}
......
......@@ -2,22 +2,12 @@ package com.example.tdl.domain.vo;
public class AlarmLogVo {
private String TDLSN;
private String description;
private Float data;
private String data;
private Long alarmTime;
public String getTDLSN() {
return TDLSN;
}
public void setTDLSN(String TDLSN) {
this.TDLSN = TDLSN;
}
public String getDescription() {
return description;
}
......@@ -26,11 +16,11 @@ public class AlarmLogVo {
this.description = description;
}
public Float getData() {
public String getData() {
return data;
}
public void setData(Float data) {
public void setData(String 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 {
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 {
private String type;
public GatewaySNAndTypeVo() {
}
public GatewaySNAndTypeVo(String SN, String type) {
this.SN = SN;
this.type = type;
}
public String getSN() {
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 {
//报警列表
private List<AlarmLogVo> alarmLogVoList;
private List<CircuitVo> circuitList;
public Integer getSum() {
return sum;
}
......@@ -64,4 +66,12 @@ public class HomePageDataVo {
public void setAlarmLogVoList(List<AlarmLogVo> 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 {
private String description;
private Float data;
private String data;
private Long alarmTime;
private String classify;
public String getTransportationNo() {
return transportationNo;
}
......@@ -36,11 +38,11 @@ public class ResultAlarmLog {
this.description = description;
}
public Float getData() {
public String getData() {
return data;
}
public void setData(Float data) {
public void setData(String data) {
this.data = data;
}
......@@ -51,4 +53,12 @@ public class ResultAlarmLog {
public void setAlarmTime(Long alarmTime) {
this.alarmTime = alarmTime;
}
public String getClassify() {
return classify;
}
public void setClassify(String classify) {
this.classify = classify;
}
}
......@@ -13,10 +13,14 @@ public class ResultCircuitVo {
private Long endTime;
private Integer circuitState;
private Integer circuitState;
private String alarmType;
private String alarm;
private String evaluate;
public String getTransportationNo() {
return transportationNo;
}
......@@ -80,4 +84,20 @@ public class ResultCircuitVo {
public void setAlarmType(String 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;
import com.example.tdl.domain.vo.AddAlarmLogVo;
import com.example.tdl.domain.vo.AlarmLogVo;
import com.example.tdl.domain.vo.HistogramData;
import com.example.tdl.domain.vo.ResultAlarmLog;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface AlarmLogMapper {
//获取所有的数据
List<AlarmLogVo> getAll();
List<ResultAlarmLog> getAll();
//根据条件获取报警数据
List<AlarmLogVo> getAlarmLog(Integer time);
List<AlarmLogVo> getAlarmLog(String time);
//新增报警数据
int addAlarmLog(AddAlarmLogVo addAlarmLogVo);
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;
import com.example.tdl.domain.vo.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
......@@ -24,15 +25,15 @@ public interface CircuitMapper {
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);
......
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;
import com.example.tdl.domain.vo.GatewayState;
import com.example.tdl.domain.vo.ResultGatewayVo;
import com.example.tdl.domain.vo.UpdateGatewayVo;
import org.apache.ibatis.annotations.Mapper;
......@@ -25,4 +26,6 @@ public interface GatewayMapper {
int deployGateway(Map<Object,Object> map);
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;
import com.example.tdl.domain.vo.AddTopicConfigVo;
import com.example.tdl.domain.vo.ResultTopicConfigVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
......@@ -14,10 +15,9 @@ public interface TopicConfigMapper {
int delTopicConfig(AddTopicConfigVo addTopicConfigVo);
// int addTopicConfig(Map<String,Object> map);
// List<DevChannelVo> getChannelByTopicName(@Param("topicName") String topicName, @Param("SN") String SN, @Param("type") String type);
List<ResultTopicConfigVo> getProbes(@Param("topicName") String topicName, @Param("SN") String SN, @Param("type") String type);
// int addTopicConfig(Map<String,Object> map);
// int updateTopicConfig(TopicConfig topicConfig);
......
......@@ -128,27 +128,28 @@ public class MqttListener implements MqttCallback {
String[] tmparray = topic.split("/");
String Type = tmparray[1];
String SN = tmparray[2];
// Integer flag = parseData(Message,SN,Type);
Integer flag = parseData(Message,SN,Type);
// String ConfigData ="{\"action\":\"config\"}";
String ConfigData;
Future<String> result = null;
GWConfigWorker gcconfig = null;
// if(flag == 0){
// ConfigCMDVo configCMDVo = new ConfigCMDVo();
// configCMDVo.setAction("sleep");
// configCMDVo.setT(System.currentTimeMillis()/1000l);
// ConfigData = new Gson().toJson(configCMDVo);
// gcconfig = new GWConfigWorker(Type,SN,ConfigData, false);
// }else if(flag == 2){
// ConfigCMDVo configCMDVo = new ConfigCMDVo();
// configCMDVo.setAction("end");
// configCMDVo.setT(System.currentTimeMillis()/1000l);
// ConfigData = new Gson().toJson(configCMDVo);
// gcconfig = new GWConfigWorker(Type,SN,ConfigData, true);
// }else if(flag == 1){
//// ConfigData = configService.getConfig(SN,Type).getMessage();
//// gcconfig = new GWConfigWorker(Type,SN,ConfigData, true);
// }
// String ConfigData ="{\"action\":\"config\"}";
if(flag == 0){
ConfigCMDVo configCMDVo = new ConfigCMDVo();
configCMDVo.setAction("sleep");
configCMDVo.setT(System.currentTimeMillis()/1000l);
ConfigData = new Gson().toJson(configCMDVo);
gcconfig = new GWConfigWorker(Type,SN,ConfigData, false);
}else if(flag == 2){
ConfigCMDVo configCMDVo = new ConfigCMDVo();
configCMDVo.setAction("end");
configCMDVo.setT(System.currentTimeMillis()/1000l);
ConfigData = new Gson().toJson(configCMDVo);
gcconfig = new GWConfigWorker(Type,SN,ConfigData, true);
}else if(flag == 1){
ConfigData = configService.getConfig(SN,Type).getMessage();
gcconfig = new GWConfigWorker(Type,SN,ConfigData, true);
}
gcconfig.SetMqttConfig(mqttconfig.getUrl(),mqttconfig.getPort(),
mqttconfig.getUsername(), mqttconfig.getPassword(),mqttconfig.getQos(),
mqttconfig.getCacrt(),mqttconfig.getClientkey(), mqttconfig.getClientcrt(),mqttconfig.getClientpwd());
......@@ -178,29 +179,29 @@ public class MqttListener implements MqttCallback {
}
//checkIn数据解析,true即发送休眠信息;false发送config信息
// public Integer parseData(String message,String SN,String Type){
// CheckInVo checkInVo = new Gson().fromJson(message,CheckInVo.class);
// if(StringUtils.isEmpty(checkInVo.getDevList()==null ? "" :checkInVo.getDevList().toString())){
// return 1;//重发
// }
//有设备信息
// ConfigVo configVo = configService.getConfig(SN,Type);
// ConfigCMDVo configCMDVo = new Gson().fromJson(configVo.getMessage(),ConfigCMDVo.class);
// if(configVo.getUntie()){
// //解绑状态
// return 2;//解绑
// }
// //判断两者的devList是否一致
// if (configCMDVo.getDevList().containsAll(checkInVo.getDevList())
// && checkInVo.getDevList().containsAll(configCMDVo.getDevList())
// && checkInVo.getGprsPeriod().equals(configCMDVo.getGprsPeriod())
// && checkInVo.getGpsPeriod().equals(configCMDVo.getGpsPeriod())
// && checkInVo.getMode().equals(configCMDVo.getMode())) {
// //一致
// return 0;//发送休眠信息
// } else {
// //不一致
// return 1;//重发
// }
// }
public Integer parseData(String message,String SN,String Type){
CheckInVo checkInVo = new Gson().fromJson(message,CheckInVo.class);
if(StringUtils.isEmpty(checkInVo.getDevList()==null ? "" :checkInVo.getDevList().toString())){
return 1;//重发
}
// 有设备信息
ConfigVo configVo = configService.getConfig(SN,Type);
ConfigCMDVo configCMDVo = new Gson().fromJson(configVo.getMessage(),ConfigCMDVo.class);
if(configVo.getUntie()){
//解绑状态
return 2;//解绑
}
//判断两者的devList是否一致
if (configCMDVo.getDevList().containsAll(checkInVo.getDevList())
&& checkInVo.getDevList().containsAll(configCMDVo.getDevList())
&& checkInVo.getGprsPeriod().equals(configCMDVo.getGprsPeriod())
&& checkInVo.getGpsPeriod().equals(configCMDVo.getGpsPeriod())
&& checkInVo.getMode().equals(configCMDVo.getMode())) {
//一致
return 0;//发送休眠信息
} else {
//不一致
return 1;//重发
}
}
}
......@@ -2,6 +2,7 @@ package com.example.tdl.service;
import com.example.tdl.domain.vo.AddAlarmLogVo;
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.mapper.AlarmLogMapper;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -15,11 +16,11 @@ public class AlarmLogService {
@Autowired
private AlarmLogMapper alarmLogMapper;
public List<AlarmLogVo> getAll(){
public List<ResultAlarmLog> getAll(){
return alarmLogMapper.getAll();
}
public List<AlarmLogVo> getAlarmLog(Integer time){
public List<AlarmLogVo> getAlarmLog(String time){
return alarmLogMapper.getAlarmLog(time);
}
......@@ -31,13 +32,22 @@ public class AlarmLogService {
return alarmLogMapper.getByTransportationNo(transportationNo);
}
public Integer getCount(Integer time){
public Integer getCount(String time){
return alarmLogMapper.getCount(time);
}
public Integer getBumpCount(Integer time){
public Integer getBumpCount(String 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 {
return circuitMapper.getAll();
}
// public List<CircuitVo> getDistinct(){
// return circuitMapper.getDistinct();
// }
public List<ResultCircuitVo> getByTerm(CircuitTermVo circuitTermVo){
return circuitMapper.getByTerm(circuitTermVo);
}
......@@ -47,24 +43,24 @@ public class CircuitService {
return circuitMapper.getByTransportationNo(transportationNo);
}
public Integer getOnRoute(Integer time){
public Integer getOnRoute(String time){
return circuitMapper.getOnRoute(time);
}
public Integer getDelayCount(Long compTime){
return circuitMapper.getDelayCount(compTime);
public Integer getDelayCount(Long compTime,String time){
return circuitMapper.getDelayCount(compTime,time);
}
public Integer getComplted(Integer time){
public Integer getComplted(String time){
return circuitMapper.getComplted(time);
}
public Integer getCount(Integer time){
public Integer getCount(String time){
return circuitMapper.getCount(time);
}
public List<CircuitVo> getByTime(Integer time){
public List<ResultCircuitVo> getByTime(String time){
return circuitMapper.getByTime(time);
}
......@@ -88,4 +84,8 @@ public class CircuitService {
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;
import com.example.tdl.domain.vo.AddGatewayVo;
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.domain.vo.*;
import com.example.tdl.mapper.GatewayMapper;
import com.example.tdl.mapper.RoleMapper;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -49,4 +46,8 @@ public class GatewayService {
public String getBySN(String 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 {
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){
// 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){
// return topicConfigMapper.getByDevChannelId(devChannelId);
......
......@@ -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
......@@ -138,7 +138,7 @@ public class DataController {
//获取gateway的信息
ResultGatewayVo gatewayVo = new ResultGatewayVo();
if(resultCircuitVo.getEndTime() == 0){
//gatewayVo = circuitService.getByNo(transportationNo);
gatewayVo = circuitService.getByNo(transportationNo);
}else{
gatewayVo = tdlLogService.getByNo(transportationNo);
}
......
......@@ -3,13 +3,15 @@ package com.example.tdl.web;
import com.example.tdl.domain.dto.CommFeedback;
import com.example.tdl.domain.vo.*;
import com.example.tdl.service.GatewayService;
import com.example.tdl.service.ModelService;
import com.example.tdl.service.*;
import com.example.tdl.service.redis.InfoRedisService;
import com.example.tdl.util.HttpRequester;
import com.google.gson.Gson;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -18,7 +20,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
......@@ -40,6 +42,18 @@ public class GatewayController {
@Autowired
private ModelService modelService;
@Autowired
private ProbesService probesService;
@Autowired
private InfoRedisService infoRedisService;
@Autowired
private TopicService topicService;
@Autowired
private TopicConfigService topicConfigService;
//查询所有网关信息
@ApiOperation(value = "查询所有网关信息",notes = "查询所有网关信息:" +
......@@ -258,4 +272,97 @@ public class GatewayController {
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;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.example.tdl.domain.dto.CommFeedback;
import com.example.tdl.domain.vo.*;
import com.example.tdl.service.AlarmLogService;
import com.example.tdl.service.CircuitService;
import com.example.tdl.service.TDLLogService;
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.influxdb.InfluxDBTemplate;
import org.springframework.web.bind.annotation.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@RestController
......@@ -32,62 +41,124 @@ public class HomePageController {
@Autowired
private AlarmLogService alarmLogServcie;
@Autowired
private TDLLogService tdlLogService;
@Autowired
private InfluxDBTemplate influxDBTemplate;
private final static String database ="original";
//获取当天所有的设备数据
@ApiOperation(value = "获取所有的运输数据",notes = "获取运输设备数据:" +
"sum:总数量" +
"onRoute:在途数量" +
"complted:已完成数量" +
"alarmed: 报警数量" +
"routeVoList: " +
"transportationNo:线路编号(R+TyyyyMMdd+运输方式+四位随机数)"+
"routeName:路由名称(出发地-启运地)"+
"startLongitude:启运经度"+
"startLatitude:启运纬度"+
"startCity:启运市"+
"startTime:开始时间"+
"endLongitude:目的经度"+
"endLatitude:目的纬度"+
"endCity:目的市"+
"endTime:结束时间"+
"transport:运输方式(T铁路,G汽运,H海运,K空运,D快递)"+
"boxNo:箱单号" +
"containerNo:集装箱号/车牌号" +
"deliveryAddress:交付地点" +
"transportationType:运输类型" +
"circuitState:线路状态"+
"remark:备注" +
"sum:总数量;" +
"onRoute:在途数量;" +
"delay:延误数量;" +
"alarmed: 报警数量;" +
"bump:颠簸数量;" +
"list: " +
"{classify:报警描述;"+
"count:数量;}"+
"alarmLogVoList :"+
"routeName:线路名称"+
"description:报警描述" +
"data:数据"+
"alarmTime:报警时间")
"{description:报警描述;" +
"data:数值;" +
"alarmTime:报警时间;}" +
"circuitList:" +
"{transportationNo:运输编号;" +
"cargoNo:货物编号;" +
"startCity:开始城市;" +
"endCity:目的城市;" +
"startTime:开始时间;" +
"endTime:到达时间;" +
"lng:当前经度;" +
"lat:当前纬度;" +
"time:当前时间;}")
@PostMapping("/getAll")
@ApiImplicitParams({
@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();
//获取所有的线路数量
Integer sum = circuitService.getCount(time);
dataVo.setSum(sum);//总数量
Integer onRoute = circuitService.getOnRoute(time);
dataVo.setOnRoute(onRoute);//在途数量
//获取延误数量
Integer delay = circuitService.getDelayCount(System.currentTimeMillis());
dataVo.setDelay(delay);
//获取已经完成的数量
Integer alarmed = alarmLogServcie.getCount(time);
dataVo.setAlarmed(alarmed);//报警数量
//获取颠簸数量
Integer bump = alarmLogServcie.getBumpCount(time);
dataVo.setBump(bump);
//获取所有的报警
// 获取所有的路线数量
List<AlarmLogVo> alarmLogVos = new ArrayList<>();
dataVo.setAlarmLogVoList(alarmLogVos);//报警列表
dataVo.setSum(circuitService.getCount(time));//总数量
dataVo.setOnRoute(circuitService.getOnRoute(time));//在途数量
dataVo.setDelay(circuitService.getDelayCount(System.currentTimeMillis(),time));//延误数量
dataVo.setAlarmed( alarmLogServcie.getCount(time));//报警数量
dataVo.setBump(alarmLogServcie.getBumpCount(time)); //获取颠簸数量
dataVo.setAlarmLogVoList(alarmLogServcie.getAlarmLog(time));//报警列表
List<HistogramData> list = alarmLogServcie.getByCount(time);//获取报警柱状图
//获取设备的当前位置
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);
}
//解析时间
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());
}
}
This diff is collapsed.
......@@ -2,19 +2,18 @@
<!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">
<!--获取所有的报警数据-->
<select id="getAll" resultType="com.example.tdl.domain.vo.AlarmLogVo">
select TDLSN,description,data,alarmTime from alarm_log
where DATE_SUB(CURDATE(), INTERVAL 3 DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s'))
<select id="getAll" resultType="com.example.tdl.domain.vo.ResultAlarmLog">
select transportationNo,TDLSN,description,data,alarmTime,classify from alarm_log
order by alarmTime desc;
</select>
<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 id="getAlarmLog" resultType="com.example.tdl.domain.vo.AlarmLogVo">
select TDLSN,description,data,alarmTime
<select id="getAlarmLog" parameterType="String" resultType="com.example.tdl.domain.vo.AlarmLogVo">
select description,data,alarmTime
from alarm_log
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;
......@@ -32,34 +31,43 @@
)
</insert>
<select id="getCount" resultType="java.lang.Integer">
<select id="getCount" resultType="java.lang.Integer" parameterType="String">
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 id="getBumpCount" resultType="java.lang.Integer">
<select id="getBumpCount" resultType="java.lang.Integer" parameterType="String">
select count(DISTINCT transportationNo) from alarm_log
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 id = "getByCount" parameterType="java.lang.Integer" >
SELECT description,count(description) FROM alarm_log WHERE description LIKE "温度%"
AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=INTEGER} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s'))
<select id = "getByCount" parameterType="String" resultType="com.example.tdl.domain.vo.HistogramData" >
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
SELECT description,count(description) FROM alarm_log WHERE description LIKE "震动%"
AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=INTEGER} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s'))
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
SELECT description,count(description) FROM alarm_log WHERE description LIKE "湿度%"
AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=INTEGER} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s'))
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
SELECT description,count(description) FROM alarm_log WHERE description LIKE "光爆%"
AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=INTEGER} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s'))
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
SELECT description,count(description) FROM alarm_log WHERE description LIKE "延迟%"
AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=INTEGER} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s'))
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
SELECT description,count(description) FROM alarm_log WHERE description LIKE "离线%"
AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=INTEGER} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s'))
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
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'))
</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>
</mapper>
\ No newline at end of file
......@@ -5,7 +5,8 @@
<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,
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>
......@@ -13,7 +14,8 @@
<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,
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">
AND circuitState=#{circuitState,jdbcType=INTEGER}
</if>
......@@ -28,7 +30,7 @@
</if>
</select>
<!--新增一条线路-->
<insert id="addCircuit" parameterType="java.util.Map" statementType="CALLABLE">
<![CDATA[
{
......@@ -69,7 +71,7 @@
]]>
</insert>
<!--修改线路信息-->
<update id="updateCircuit" parameterType="java.util.Map" statementType="CALLABLE">
<![CDATA[
{
......@@ -105,6 +107,12 @@
</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 circuit set
......@@ -113,29 +121,21 @@
</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 count( startTime) from circuit where circuitState=1
<select id="getOnRoute" resultType="java.lang.Integer" parameterType="String">
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 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>
<!--总数量-->
<select id="getCount" resultType="java.lang.Integer">
select count(id) from circuit
<select id="getCount" resultType="java.lang.Integer" parameterType="String">
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 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,
......@@ -145,22 +145,21 @@
AND transportationNo=#{transportationNo,jdbcType=VARCHAR}
</select>
<!--根据车牌号查线路-->
<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,
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 AND cargoNo=#{cargoNo,jdbcType=VARCHAR}
(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 cargoNo=#{cargoNo,jdbcType=VARCHAR}
</select>
<!--根据运输状态查询线路信息-->
<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,
IFNULL((SELECT alarmType FROM alarm WHERE id=c.alarm_id),"正常") alarmType from circuit c where c.state=1
AND circuitState=#{circuitState,jdbcType=INTEGER}
(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 circuitState=#{circuitState,jdbcType=INTEGER}
</select>
<!--评价-->
......@@ -181,6 +180,13 @@
SELECT id from circuit WHERE transportationNo=#{transportationNo,jdbcType=VARCHAR}) LIMIT 1)
</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 transportationNo,routeName,startLongitude,startLatitude,(select city from city_config where id=r.start_id) startCity,startTime,endLongitude,endLatitude,
......@@ -194,7 +200,6 @@
order BY c.id
</select>
<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 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 @@
]]>
</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 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 @@
SELECT id from gateway WHERE SN=#{SN,jdbcType=VARCHAR} AND type=#{type,jdbcType=VARCHAR}))
</delete>
<!-- <select id="getChannelByTopicName" parameterType="String" resultType="com.example.demo.domain.vo.DevChannelVo">
SELECT dc.port,dc.unit,dc.description,dc.alias
FROM topic_config tc,topic t,devchannel dc
WHERE tc.devchannel_id=dc.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}
</select>-->
<select id="getProbes" parameterType="String" resultType="com.example.tdl.domain.vo.ResultTopicConfigVo">
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,probes p
WHERE tc.probes_id=p.id
AND tc.topic_id=t.id
AND t.topicName =#{topicName,jdbcType=VARCHAR}
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">
<![CDATA[
......
......@@ -28,7 +28,6 @@
<mapper resource="mapper/RoleMapper.xml"/>
<mapper resource="mapper/PermissionMapper.xml"/>
<mapper resource="mapper/RoleHasPermissionMapper.xml"/>
<mapper resource="mapper/RouteMapper.xml"/>
<mapper resource="mapper/AlarmMapper.xml"/>
<mapper resource="mapper/WarehouseMapper.xml"/>
<mapper resource="mapper/TDLDeviceMapper.xml"/>
......@@ -51,5 +50,7 @@
<mapper resource="mapper/UserAddressMapper.xml"/>
<mapper resource="mapper/TransferModelMapper.xml"/>
<mapper resource="mapper/TransferModelConfigMapper.xml"/>
<mapper resource="mapper/TransferModelMapper.xml"/>
<mapper resource="mapper/CircuitTransferMapper.xml"/>
</mappers>
</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