Commit b8d0e060 authored by zhuangzhuang's avatar zhuangzhuang

3.30--将线路报警传入redis,增加报警,手机端新增线路接口

parent 521b63a3
......@@ -84,14 +84,14 @@ public class GWConfigWorker implements Callable<String>, MqttCallback {
this.clientpwd = mclientpwd;
}
public GWConfigWorker(String type,String sn, String CMD,Boolean flag) throws Exception{
this.SN = sn;
public GWConfigWorker(String type,String SN, String CMD,Boolean flag) throws Exception{
this.SN = SN;
this.Type = type;
this.Device = Type + "_" + SN;
this.ConfigCMD = CMD;
this.NeedResp = flag;
this.ConfigTopic = "GW/" + Type + "/" + SN + PUB_TOPIC;
this.RespTopic = "GW/" + Type + "/" + SN + SUB_TOPIC;
this.ConfigTopic = "TDL/" + Type + "/" + SN + PUB_TOPIC;
this.RespTopic = "TDL/" + Type + "/" + SN + SUB_TOPIC;
}
@Override
......@@ -214,4 +214,13 @@ public class GWConfigWorker implements Callable<String>, MqttCallback {
mqttAsyncClient.publish(ConfigTopic,msg);
}
public void GCConfigClose(){
try {
mqttAsyncClient.disconnect();
}catch (Exception e){
e.printStackTrace();
}
}
}
......@@ -22,9 +22,9 @@ public class MyWebMvcConfigurer extends WebMvcConfigurerAdapter {
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(loginInterceptor())
registry.addInterceptor(loginInterceptor()).excludePathPatterns("/alarmLog/**")
.excludePathPatterns("/login/**");
registry.addInterceptor(permissionInterceptor()).excludePathPatterns("/login/**");
registry.addInterceptor(permissionInterceptor()).excludePathPatterns("/login/**").excludePathPatterns("/alarmLog/add");
super.addInterceptors(registry);
}
}
package com.example.tdl.domain.vo;
import java.util.List;
public class AddAlarmLogVo {
private String transportationNo;
private Integer mode;
private String TDLSN;
private String gSN;
private String description;
private String gType;
private Float data;
private Long ts;
private Long alarmTime;
private List<AlarmData> alarm;
public AddAlarmLogVo() {
}
public static class AlarmData {
private String TDLSN;
public AddAlarmLogVo(String transportationNo, String TDLSN, String description, Float data, Long alarmTime) {
this.transportationNo = transportationNo;
this.TDLSN = TDLSN;
this.description = description;
this.data = data;
this.alarmTime = alarmTime;
}
private String desp;
private Float value;
public String getTransportationNo() {
return transportationNo;
private Long ts;
public AlarmData() {
}
public void setTransportationNo(String transportationNo) {
this.transportationNo = transportationNo;
public AlarmData(String TDLSN, String desp, Float value, Long ts) {
this.TDLSN = TDLSN;
this.desp = desp;
this.value = value;
this.ts = ts;
}
public String getTDLSN() {
......@@ -39,27 +42,68 @@ public class AddAlarmLogVo {
this.TDLSN = TDLSN;
}
public String getDescription() {
return description;
public String getDesp() {
return desp;
}
public void setDesp(String desp) {
this.desp = desp;
}
public Float getValue() {
return value;
}
public void setValue(Float value) {
this.value = value;
}
public Long getTs() {
return ts;
}
public void setTs(Long ts) {
this.ts = ts;
}
}
public Integer getMode() {
return mode;
}
public void setMode(Integer mode) {
this.mode = mode;
}
public String getgSN() {
return gSN;
}
public void setgSN(String gSN) {
this.gSN = gSN;
}
public String getgType() {
return gType;
}
public void setDescription(String description) {
this.description = description;
public void setgType(String gType) {
this.gType = gType;
}
public Float getData() {
return data;
public Long getTs() {
return ts;
}
public void setData(Float data) {
this.data = data;
public void setTs(Long ts) {
this.ts = ts;
}
public Long getAlarmTime() {
return alarmTime;
public List<AlarmData> getAlarm() {
return alarm;
}
public void setAlarmTime(Long alarmTime) {
this.alarmTime = alarmTime;
public void setAlarm(List<AlarmData> alarm) {
this.alarm = alarm;
}
}
package com.example.tdl.domain.vo;
public class AddCircuit {
private String cargoNo;//货物编号
private String plateNo;//车牌号
private String cargoName;
private String transportation;
private StartAddressVo startAddressVo;
private EndAddressVo endAddressVo;
private String deliveryAddress;
private String transportationType;
private String remark;
public String getCargoNo() {
return cargoNo;
}
public void setCargoNo(String cargoNo) {
this.cargoNo = cargoNo;
}
public String getPlateNo() {
return plateNo;
}
public void setPlateNo(String plateNo) {
this.plateNo = plateNo;
}
public String getCargoName() {
return cargoName;
}
public void setCargoName(String cargoName) {
this.cargoName = cargoName;
}
public String getTransportation() {
return transportation;
}
public void setTransportation(String transportation) {
this.transportation = transportation;
}
public StartAddressVo getStartAddressVo() {
return startAddressVo;
}
public void setStartAddressVo(StartAddressVo startAddressVo) {
this.startAddressVo = startAddressVo;
}
public EndAddressVo getEndAddressVo() {
return endAddressVo;
}
public void setEndAddressVo(EndAddressVo endAddressVo) {
this.endAddressVo = endAddressVo;
}
public String getDeliveryAddress() {
return deliveryAddress;
}
public void setDeliveryAddress(String deliveryAddress) {
this.deliveryAddress = deliveryAddress;
}
public String getTransportationType() {
return transportationType;
}
public void setTransportationType(String transportationType) {
this.transportationType = transportationType;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
}
......@@ -41,4 +41,14 @@ public class LocationDataVo {
public void setError(Integer error) {
this.error = error;
}
@Override
public String toString() {
return "{" +
"\"time\""+":\"" + time + '\"' +
",\"lng\""+":" + lng +
",\" lat\""+":" + lat +
", \"error\""+":" + error +
'}';
}
}
......@@ -6,7 +6,7 @@ public class AlarmLog {
private String transportationNo;
private String routeName;
private String TDLSN;
private String description;
......@@ -14,6 +14,16 @@ public class AlarmLog {
private Long alarmTime;
private String classify;
public AlarmLog(String transportationNo, String TDLSN, String description, Float data, Long alarmTime, String classify) {
this.transportationNo = transportationNo;
this.TDLSN = TDLSN;
this.description = description;
this.data = data;
this.alarmTime = alarmTime;
this.classify = classify;
}
public Integer getId() {
return id;
......@@ -31,12 +41,12 @@ public class AlarmLog {
this.transportationNo = transportationNo;
}
public String getRouteName() {
return routeName;
public String getTDLSN() {
return TDLSN;
}
public void setRouteName(String routeName) {
this.routeName = routeName;
public void setTDLSN(String TDLSN) {
this.TDLSN = TDLSN;
}
public String getDescription() {
......@@ -62,4 +72,12 @@ public class AlarmLog {
public void setAlarmTime(Long alarmTime) {
this.alarmTime = alarmTime;
}
public String getClassify() {
return classify;
}
public void setClassify(String classify) {
this.classify = classify;
}
}
......@@ -4,6 +4,7 @@ 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.entity.AlarmLog;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
......@@ -18,7 +19,7 @@ public interface AlarmLogMapper {
List<AlarmLogVo> getAlarmLog(String time);
//新增报警数据
int addAlarmLog(AddAlarmLogVo addAlarmLogVo);
int addAlarmLog(AlarmLog addAlarmLogVo);
List<ResultAlarmLog> getByTransportationNo(String transportationNo);
......
......@@ -17,6 +17,8 @@ public interface CircuitMapper {
int addCircuit(Map<Object,Object> map);
int add(Map<Object,Object> map);
int updateCircuit(Map<Object,Object> map);
int updateEndTime(UpdateCircuitVo updateCircuitVo);
......
......@@ -28,4 +28,6 @@ public interface GatewayMapper {
String getBySN(String SN);
Integer updateState(GatewayState gatewayState);
String getTransportationNo(@Param("SN") String SN,@Param("type") String type);
}
......@@ -25,4 +25,7 @@ public interface TDLDeviceMapper {
ResultTDLDeviceVo getByTDLSN(String TDLSN);
List<String> getByGatewaySN(@Param("SN") String SN, @Param("type") String type);
List<String> getTdlSN(@Param("SN") String SN, @Param("type") String type);
}
......@@ -124,10 +124,11 @@ public class MqttListener implements MqttCallback {
public void messageArrived(String topic, MqttMessage mqttMessage) throws Exception {
String Message = mqttMessage.toString();
Long timestamp = System.currentTimeMillis();
try {
String[] tmparray = topic.split("/");
String Type = tmparray[1];
String SN = tmparray[2];
if(SN.matches("^[0-9]*$")){
try {
Integer flag = parseData(Message,SN,Type);
// String ConfigData ="{\"action\":\"config\"}";
String ConfigData;
......@@ -147,9 +148,8 @@ public class MqttListener implements MqttCallback {
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 = 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());
......@@ -160,7 +160,6 @@ public class MqttListener implements MqttCallback {
// String respcmd = result.get();
// }
// futureMap.put(timestamp.toString(),result);
} catch (JsonSyntaxException e) {
e.printStackTrace();
System.out.println("mqttAsyncClient: message " + Message + " received syntax error.");
......@@ -172,6 +171,7 @@ public class MqttListener implements MqttCallback {
System.out.println(e.toString());
}
}
}
@Override
public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) {
......
......@@ -4,6 +4,7 @@ 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.entity.AlarmLog;
import com.example.tdl.mapper.AlarmLogMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -24,7 +25,7 @@ public class AlarmLogService {
return alarmLogMapper.getAlarmLog(time);
}
public int addAlarmLog(AddAlarmLogVo addAlarmLogVo){
public int addAlarmLog(AlarmLog addAlarmLogVo){
return alarmLogMapper.addAlarmLog(addAlarmLogVo);
}
......
......@@ -26,6 +26,10 @@ public class CircuitService {
return circuitMapper.addCircuit(map);
}
public int add(Map<Object,Object> map){
return circuitMapper.add(map);
}
public int updateCircuit(Map<Object,Object> map){
return circuitMapper.updateCircuit(map);
}
......
......@@ -50,4 +50,8 @@ public class GatewayService {
public Boolean updateState(GatewayState gatewayState){
return gatewayMapper.updateState(gatewayState)==1;
}
public String getTransportationNo(String SN,String type){
return gatewayMapper.getTransportationNo(SN,type);
}
}
......@@ -42,4 +42,8 @@ public class TDLDeviceService {
public List<String> getByGatewaySN(String SN,String type){
return tdlDeviceMapper.getByGatewaySN(SN,type);
}
public List<String> getTdlSN(String SN,String type){
return tdlDeviceMapper.getTdlSN(SN,type);
}
}
......@@ -2,7 +2,9 @@ package com.example.tdl.web;
import com.example.tdl.domain.dto.CommFeedback;
import com.example.tdl.domain.vo.AddAlarmLogVo;
import com.example.tdl.entity.AlarmLog;
import com.example.tdl.service.AlarmLogService;
import com.example.tdl.service.GatewayService;
import com.google.gson.Gson;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
......@@ -25,45 +27,57 @@ public class AlarmLogController {
@Autowired
private AlarmLogService alarmLogServcie;
@Autowired
private GatewayService gatewayService;
//新增报警消息
@PostMapping("/addAlarmLog")
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
public Object addAlarmLog(@RequestBody AddAlarmLogVo addAlarmLogVo){
if(StringUtils.isEmpty(addAlarmLogVo.getTransportationNo())){
fb.setCode(0);
fb.setMessage("运输编号不能为空");
return gson.toJson(fb);
}
if(StringUtils.isEmpty(addAlarmLogVo.getTDLSN())){
@RequestMapping(value = "/addAlarmLog",method = RequestMethod.POST)
public String addAlarmLog(@RequestBody AddAlarmLogVo addAlarmLogVo){
if(StringUtils.isEmpty(addAlarmLogVo.getgSN())){
fb.setCode(0);
fb.setMessage("路由名称不能为空");
return gson.toJson(fb);
fb.setMessage("网关序列号不能为空");
}
if(StringUtils.isEmpty(addAlarmLogVo.getDescription())){
if(StringUtils.isEmpty(addAlarmLogVo.getgType())){
fb.setCode(0);
fb.setMessage("报警描述不能为空");
return gson.toJson(fb);
fb.setMessage("网关类型不能为空");
}
if(addAlarmLogVo.getData() == null){
if(addAlarmLogVo.getAlarm()==null){
fb.setCode(0);
fb.setMessage("报警数据不能为空");
return gson.toJson(fb);
}
if(addAlarmLogVo.getAlarmTime() == null){
if(addAlarmLogVo.getTs() == null){
fb.setCode(0);
fb.setMessage("报警时间不能为空");
return gson.toJson(fb);
fb.setMessage("时间不能为空");
}
//获取报警的线路信息
int i= alarmLogServcie.addAlarmLog(addAlarmLogVo);
if(i == 0){
fb.setCode(0);
fb.setMessage("添加成功");
}else{
//根据gateway的信息获取线路信息
String transportationNo = gatewayService.getTransportationNo(addAlarmLogVo.getgSN(),addAlarmLogVo.getgType());
for(int i = 0;i<addAlarmLogVo.getAlarm().size();i++){
// String classify="";
// if(addAlarmLogVo.getAlarm().get(i).getDesp().contains("温度")){
// classify = "1";
// } else if(addAlarmLogVo.getAlarm().get(i).getDesp().contains("湿度")){
// classify = "2";
// } else if(addAlarmLogVo.getAlarm().get(i).getDesp().contains("震动")){
// classify = "3";
// } else if(addAlarmLogVo.getAlarm().get(i).getDesp().contains("倾角")){
// classify = "4";
// }
//// else if(addAlarmLogVo.getAlarm().get(i).getDesp().contains("光爆")){
//// classify = "5";
//// }
// else if(addAlarmLogVo.getAlarm().get(i).getDesp().contains("离线")){
// classify = "6";
// }
// AlarmLog alarmLog = new AlarmLog(transportationNo,addAlarmLogVo.getAlarm().get(i).getTDLSN(),addAlarmLogVo.getAlarm().get(i).getDesp(),addAlarmLogVo.getAlarm().get(i).getValue(),addAlarmLogVo.getAlarm().get(i).getTs()*1000,classify);
AlarmLog alarmLog = new AlarmLog(transportationNo,addAlarmLogVo.getAlarm().get(i).getTDLSN(),"温度异常",addAlarmLogVo.getAlarm().get(i).getValue(),addAlarmLogVo.getAlarm().get(i).getTs()*1000,"1");
int a = alarmLogServcie.addAlarmLog(alarmLog);
if(a == 0){
fb.setCode(0);
fb.setMessage("添加失败");
}else{
fb.setCode(1);
fb.setMessage("添加成功");
}
}
return gson.toJson(fb);
}
......
......@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
import com.example.tdl.domain.dto.CommFeedback;
import com.example.tdl.domain.vo.*;
import com.example.tdl.service.*;
import com.example.tdl.service.redis.AlarmRedisService;
import com.example.tdl.service.redis.TokenRedisService;
import com.google.gson.Gson;
import io.swagger.annotations.ApiImplicitParam;
......@@ -45,6 +46,20 @@ public class CircuitController {
@Autowired
private AlarmLogService alarmLogService;
@Autowired
private AlarmRedisService alarmRedisService;
@Autowired
private AlarmService alarmService;
List<String> list = new ArrayList<String>(){{
add("T");
add("h");
add("a0");
add("ta");
}};
//获取线路信息
@ApiOperation(value = "获取线路信息",notes = "获取线路信息,返回值说明:" +
" transportationNo:运输编号," +
......@@ -131,7 +146,7 @@ public class CircuitController {
"lat:纬度" +
"postCode:邮编"+
"compTime:预计结束时间,(传时间戳)}" +
" gSN:网关编号," +
" SN:网关编号," +
" tdlAlarmList: " +
"{TDLSN:tdl编号," +
" alarmType:报警类型,}" +
......@@ -373,7 +388,8 @@ public class CircuitController {
}
alarmTypeVar =alarmTypeVar + addCircuitVo.getTdlAlarmList().get(j).getAlarmType() +" ";
TDLSNVar =TDLSNVar + addCircuitVo.getTdlAlarmList().get(j).getTDLSN() +" ";
devList.add(addCircuitVo.getTdlAlarmList().get(j).getTDLSN());
devList.add("tdl-"+addCircuitVo.getTdlAlarmList().get(j).getTDLSN());
saveAlarmRule("TDL/"+type+"/" +addCircuitVo.getSN()+"/Data",addCircuitVo.getTdlAlarmList().get(j).getTDLSN(),addCircuitVo.getTdlAlarmList().get(j).getAlarmType());
}
if(StringUtils.isEmpty(addCircuitVo.getCargoNo())){
......@@ -394,7 +410,7 @@ public class CircuitController {
//根据sn获取type
ConfigCMDVo configCMDVo = new ConfigCMDVo("config",5,15,devList,1);
Map<Object,Object> map=new HashMap<>();
String transportation = "汽运";
String transportation = "公路";
String transportationType="本地运输";
map.put("transportationNo",getTransportNo(transportation,transportationType));
map.put("startTime",time);
......@@ -408,7 +424,7 @@ public class CircuitController {
map.put("transportationType",transportationType);
map.put("createTime",time);
map.put("remark",addCircuitVo.getRemark());
map.put("counts",addCircuitVo.getAddressVoList()== null ? 0 : addCircuitVo.getAddressVoList().size());
map.put("counts",addCircuitVo.getAddressVoList()== null ? 2 : addCircuitVo.getAddressVoList().size()+2);
map.put("countryVar",countryVar);
map.put("cityVar",cityVar);
map.put("addressDetailVar",addressDetailVar);
......@@ -433,6 +449,207 @@ public class CircuitController {
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 = "添加线路信息----mobile",notes = "添加线路信息," +
" cargoNo:货物编号," +
" plateNo:车牌号," +
" cargoName:货物别名," +
" transportation:运输方式,(公路,铁路,海运,空运,快递)" +
" startAddressVo: 启运城市,包含" +
"{country:国家," +
"city:城市," +
"addressDetail:详细地址," +
"lng:经度," +
"lat:纬度," +
"postCode:邮编,"+
"expTime:预计开始时间,(13位时间戳)}" +
" endAddressVo: 目的城市,包含" +
"{country:国家," +
"city:城市," +
"addressDetail:详细地址," +
"lng:经度," +
"lat:纬度," +
"postCode:邮编,"+
"compTime:预计结束时间,(13位时间戳)}" +
" deliveryAddress:交付地点,(站点,仓库,港口)" +
" transportationType:运输类型,(本地运输,国际运输)" +
" remark:备注,")
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
@RequestMapping(value="/add",method = RequestMethod.POST)
public Object add(@RequestBody AddCircuit addCircuitVo){
if(StringUtils.isEmpty(addCircuitVo.getCargoNo())){
fb.setCode(0);
fb.setMessage("货物编号不能为空");
return gson.toJson(fb);
}
if(StringUtils.isEmpty(addCircuitVo.getPlateNo())){
fb.setCode(0);
fb.setMessage("车牌号不能为空");
return gson.toJson(fb);
}
if(StringUtils.isEmpty(addCircuitVo.getCargoName())){
fb.setCode(0);
fb.setMessage("货物别名不能为空");
return gson.toJson(fb);
}
if(StringUtils.isEmpty(addCircuitVo.getTransportation())){
fb.setCode(0);
fb.setMessage("运输方式不能为空");
return gson.toJson(fb);
}
if(StringUtils.isEmpty(addCircuitVo.getStartAddressVo().getCountry())){
fb.setCode(0);
fb.setMessage("出发国家不能为空");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(addCircuitVo.getStartAddressVo().getCity())){
fb.setCode(0);
fb.setMessage("出发城市不能为空");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(addCircuitVo.getStartAddressVo().getAddressDetail())){
fb.setCode(0);
fb.setMessage("出发具体地址不能为空");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(addCircuitVo.getStartAddressVo().getLat())){
fb.setCode(0);
fb.setMessage("出发地纬度不能为空");
return gson.toJson(fb);
}
if(!addCircuitVo.getStartAddressVo().getLat().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 (StringUtils.isEmpty(addCircuitVo.getStartAddressVo().getLng())){
fb.setCode(0);
fb.setMessage("出发地经度不能为空");
return gson.toJson(fb);
}
if(!addCircuitVo.getStartAddressVo().getLng().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(addCircuitVo.getStartAddressVo().getPostCode())){
fb.setCode(0);
fb.setMessage("出发地邮编不能为空");
return gson.toJson(fb);
}
if (addCircuitVo.getStartAddressVo().getExpTime()==null){
fb.setCode(0);
fb.setMessage("出发地预计出发时间不能为空");
return gson.toJson(fb);
}
if(StringUtils.isEmpty(addCircuitVo.getEndAddressVo().getCountry())){
fb.setCode(0);
fb.setMessage("目的地国家不能为空");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(addCircuitVo.getEndAddressVo().getCity())){
fb.setCode(0);
fb.setMessage("目的地城市不能为空");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(addCircuitVo.getEndAddressVo().getAddressDetail())){
fb.setCode(0);
fb.setMessage("目的地具体地址不能为空");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(addCircuitVo.getEndAddressVo().getLat())){
fb.setCode(0);
fb.setMessage("目的地纬度不能为空");
return gson.toJson(fb);
}
if(!addCircuitVo.getEndAddressVo().getLat().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 (StringUtils.isEmpty(addCircuitVo.getEndAddressVo().getLng())){
fb.setCode(0);
fb.setMessage("目的地经度不能为空");
return gson.toJson(fb);
}
if(!addCircuitVo.getEndAddressVo().getLng().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(addCircuitVo.getEndAddressVo().getPostCode())){
fb.setCode(0);
fb.setMessage("目的地邮编不能为空");
return gson.toJson(fb);
}
if (addCircuitVo.getEndAddressVo().getCompTime()==null){
fb.setCode(0);
fb.setMessage("目的地预计到达时间不能为空");
return gson.toJson(fb);
}
if(StringUtils.isEmpty(addCircuitVo.getDeliveryAddress())){
fb.setCode(0);
fb.setMessage("交付地点不能为空");
return gson.toJson(fb);
}
if(StringUtils.isEmpty(addCircuitVo.getTransportationType())){
fb.setCode(0);
fb.setMessage("运输类型不能为空");
return gson.toJson(fb);
}
Long time = System.currentTimeMillis();
String countryVar=addCircuitVo.getStartAddressVo().getCountry()+" "+addCircuitVo.getEndAddressVo().getCountry() +" ";
String cityVar=addCircuitVo.getStartAddressVo().getCity()+ " "+addCircuitVo.getEndAddressVo().getCity() +" ";
String addressDetailVar=addCircuitVo.getStartAddressVo().getAddressDetail() +" "+addCircuitVo.getEndAddressVo().getAddressDetail() +" ";
String lngVar=addCircuitVo.getStartAddressVo().getLng()+" "+ addCircuitVo.getEndAddressVo().getLng() +" ";
String latVar = addCircuitVo.getStartAddressVo().getLat()+" "+ addCircuitVo.getEndAddressVo().getLat() +" ";
String postCodeVar = addCircuitVo.getStartAddressVo().getPostCode()+" "+ addCircuitVo.getEndAddressVo().getPostCode() +" ";
String expTimeVar = addCircuitVo.getStartAddressVo().getExpTime()+" "+"0 ";
String compTimeVar = "0 "+addCircuitVo.getEndAddressVo().getCompTime() +" ";
String arrivalTimeVar="0 0 ";
String startTimeVar="0 0 ";
//根据sn获取type
Map<Object,Object> map=new HashMap<>();
map.put("transportationNo",getTransportNo(addCircuitVo.getTransportation(),addCircuitVo.getTransportationType()));
// map.put("startTime",time);
map.put("expTime",addCircuitVo.getStartAddressVo().getExpTime());
map.put("compTime",addCircuitVo.getEndAddressVo().getCompTime());
map.put("cargoNo",addCircuitVo.getCargoNo());
map.put("cargoName",addCircuitVo.getCargoName());
map.put("plateNo",addCircuitVo.getPlateNo());
map.put("deliveryAddress",addCircuitVo.getDeliveryAddress());
map.put("transportation",addCircuitVo.getTransportation());
map.put("transportationType",addCircuitVo.getTransportationType());
map.put("createTime",time);
map.put("remark",addCircuitVo.getRemark());
map.put("counts",2);
map.put("countryVar",countryVar);
map.put("cityVar",cityVar);
map.put("addressDetailVar",addressDetailVar);
map.put("lngVar",lngVar);
map.put("latVar",latVar);
map.put("postCodeVar",postCodeVar);
map.put("arrivalTimeVar",arrivalTimeVar);
map.put("startTimeVar",startTimeVar);
map.put("expTimeVar",expTimeVar);
map.put("compTimeVar",compTimeVar);
circuitService.add(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());
......@@ -440,6 +657,41 @@ public class CircuitController {
return gson.toJson(fb);
}
//获取已有线路
@ApiOperation(value = "添加线路信息----mobile",notes = "添加线路信息," +
" cargoNo:货物编号," +
" plateNo:车牌号," +
" cargoName:货物别名," +
" transportation:运输方式,(公路,铁路,海运,空运,快递)" +
" startAddressVo: 启运城市,包含" +
"{country:国家," +
"city:城市," +
"addressDetail:详细地址," +
"lng:经度," +
"lat:纬度," +
"postCode:邮编,"+
"expTime:预计开始时间,(13位时间戳)}" +
" endAddressVo: 目的城市,包含" +
"{country:国家," +
"city:城市," +
"addressDetail:详细地址," +
"lng:经度," +
"lat:纬度," +
"postCode:邮编,"+
"compTime:预计结束时间,(13位时间戳)}" +
" deliveryAddress:交付地点,(站点,仓库,港口)" +
" transportationType:运输类型,(本地运输,国际运输)" +
" remark:备注,")
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
@RequestMapping(value="/getExsitCircuit",method = RequestMethod.GET)
public Object getExsitCircuit(){
return gson.toJson(fb);
}
//修改线路结束时间
@ApiOperation(value = "修改线路结束时间",notes = "修改线路结束时间,传值说明:" +
......@@ -478,7 +730,7 @@ public class CircuitController {
//根据车牌号查线路
@ApiOperation(value = "根据车牌号查线路",notes = "根据车牌号查线路,返回值说明:" +
@ApiOperation(value = "根据车牌号查线路---mobile",notes = "根据车牌号查线路,返回值说明:" +
" transportationNo:运输编号," +
" cargoNo:货物编号" +
" startCity:起运城市," +
......@@ -502,7 +754,7 @@ public class CircuitController {
//评价
@ApiOperation(value = "评价",notes = "评价线路传值说明:" +
@ApiOperation(value = "评价---mobile",notes = "评价线路传值说明:" +
" transportationNo:运输编号," +
" evaluate:评分," +
" evaluateRemark:评分备注")
......@@ -540,7 +792,7 @@ public class CircuitController {
//根据运输状态查询线路信息
@ApiOperation(value = "根据运输状态查询线路信息",notes = "根据运输状态查询线路信息,传值说明:{\"circuitState\":2} ,circuitState:线路状态(0未开始,1运输中,2完成),返回值说明:" +
@ApiOperation(value = "根据运输状态查询线路信息---mobile",notes = "根据运输状态查询线路信息,传值说明:{\"circuitState\":2} ,circuitState:线路状态(0未开始,1运输中,2完成),返回值说明:" +
" transportationNo:运输编号," +
" cargoNo:货物编号" +
" startCity:起运城市," +
......@@ -738,7 +990,7 @@ public class CircuitController {
transportationNo = transportationNo+"HUN";
}
transportationNo=transportationNo+new SimpleDateFormat("yyyyMMdd").format(new Date());
if(transportation.equals("汽运")){
if(transportation.equals("公路")){
transportationNo = transportationNo +"G";
} else if (transportation.equals("铁路")){
transportationNo = transportationNo +"T";
......@@ -777,6 +1029,38 @@ public class CircuitController {
return day + "天" + hour + "小时" + min + "分钟" +sec +"秒";
}
//将报警规则存到redis中
public void saveAlarmRule(String topic,String TDLSN,String alarmType){
ResultAlarmVo alarmVo = alarmService.getByTypeAndScene(alarmType,"运输");
for(String alias :list){
List<AlarmRuleVo> alarmRuleVos = new ArrayList<>();
AlarmRuleVo alarmRuleVo = new AlarmRuleVo();
if(alias.equals("T")){
alarmRuleVo.setMinval(String.valueOf(alarmVo.getTemMin()));
alarmRuleVo.setMaxval(String.valueOf(alarmVo.getTemMax()));
alarmRuleVo.setMode("twoway");
alarmRuleVo.setPriority("1");
}else if(alias.equals("h")){
alarmRuleVo.setMinval(String.valueOf(alarmVo.getHumidityMin()));
alarmRuleVo.setMaxval(String.valueOf(alarmVo.getHumidityMax()));
alarmRuleVo.setMode("twoway");
alarmRuleVo.setPriority("1");
}else if(alias.equals("ta")){
alarmRuleVo.setMinval(String.valueOf(alarmVo.getTilt()));
alarmRuleVo.setMode("equal");
alarmRuleVo.setPriority("1");
}else if(alias.equals("a0")){
alarmRuleVo.setMinval(String.valueOf(alarmVo.getShock()));
alarmRuleVo.setMode("equal");
alarmRuleVo.setPriority("1");
}
alarmRuleVos.add(alarmRuleVo);
//向redis中写入报警信息
alarmRedisService.hmSet(topic,"TDL-" +TDLSN+"_" +alias,gson.toJson(alarmRuleVos));
}
}
// 修改线路信息
// @ApiOperation(value = "修改线路信息",notes = "修改线路信息,传值说明:" +
......
......@@ -41,11 +41,6 @@ public class DataController {
@Autowired
private TDLDeviceService tdlDeviceService;
@Autowired
private ProbesService probesService;
@Autowired
private RealRedisService realRedisService;
@Autowired
private InfoRedisService infoRedisService;
......@@ -53,9 +48,6 @@ public class DataController {
@Autowired
private InfluxDBTemplate influxDBTemplate;
@Autowired
private AlarmLogService alarmLogService;
@Autowired
private CircuitService circuitService;
......@@ -78,26 +70,30 @@ public class DataController {
transportationNo=jsonObject.getString("transportationNo");
//根据运输编号获取线路信息
ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(transportationNo);
if(resultCircuitVo.getEndTime() !=0 && infoRedisService.hasHashKey("TransportConfig",transportationNo)){
List<LocationDataVo> locationDataVoList =new ArrayList<>();
if(resultCircuitVo.getStartTime() == null || resultCircuitVo.getStartTime() == 0){
return gson.toJson(locationDataVoList);
}
Long startTime = resultCircuitVo.getStartTime() *1000000l;
if(resultCircuitVo.getEndTime() !=null && infoRedisService.hasHashKey("TransportConfig",transportationNo)){
Object ret = infoRedisService.getHash("TransportConfig",transportationNo);
return ret;
}else{
//获取gateway的信息
ResultGatewayVo gatewayVo = new ResultGatewayVo();
if(resultCircuitVo.getEndTime() == 0){
gatewayVo = circuitService.getByNo(transportationNo);
}else{
gatewayVo = tdlLogService.getByNo(transportationNo);
}
//获取gateway的信息
ResultGatewayVo gatewayVo = tdlLogService.getByNo(transportationNo);
if(gatewayVo==null){
fb.setCode(0);
fb.setMessage("该线路未绑定设备");
return gson.toJson(fb);
return gson.toJson(locationDataVoList);
}
String device = gatewayVo.getType() +"_" +gatewayVo.getSN();
Long startTime = resultCircuitVo.getStartTime() *1000000l;
String sql ="";
if(resultCircuitVo.getEndTime() != null && resultCircuitVo.getEndTime() != 0){
Long time = resultCircuitVo.getEndTime()*1000000l;
sql = "SELECT \"lng\",\"lat\" FROM \"tdl_policy\".\""+device+"\"where time >= "+startTime +" and time<= "+time+" ORDER BY time ";
}else{
sql = "SELECT \"lng\",\"lat\" FROM \"tdl_policy\".\""+device+"\"where time >= "+startTime +" ORDER BY time ";
}
//获取tdl信息
String sql = "SELECT \"lng\",\"lat\" FROM \"tdl_policy\".\""+device+"\"where time >= "+startTime +" ORDER BY time ";
QueryResult queryResult = influxDBTemplate.query(new Query(sql,database));
//解析经纬度数据
List<LocationDataVo> locationDataVos = new ArrayList<>();
......@@ -105,13 +101,21 @@ public class DataController {
locationDataVos=getLocation(queryResult);
}
//获取震动的数据
String sql2 = "SELECT \"b\" FROM \"tdl_policy\".\""+device+"\"where time >= "+startTime +" ORDER BY time";
String sql2 ="";
if(resultCircuitVo.getEndTime() != null && resultCircuitVo.getEndTime() != 0){
Long time = resultCircuitVo.getEndTime()*1000000l;
sql2 = "SELECT \"a0\" FROM \"tdl_policy\".\""+device+"\"where time >= "+startTime +" and time<=" +time+ " ORDER BY time";
}else{
sql2 = "SELECT \"a0\" FROM \"tdl_policy\".\""+device+"\"where time >= "+startTime +" ORDER BY time";
}
QueryResult queryResult2 = influxDBTemplate.query(new Query(sql2,database));
List<String> timeList = new ArrayList<>();
if(queryResult2.getResults().get(0).getSeries() != null){
//获取震动的时间戳
timeList = getTime(queryResult2);
}
if(timeList.size()>0){
//获取震动数据的坐标
String sql3 ="";
for(String time : timeList){
......@@ -123,7 +127,6 @@ public class DataController {
if(queryResult3.getResults() !=null){
time = getShockLocation(queryResult3);
}
List<LocationDataVo> locationDataVoList =new ArrayList<>();
for(LocationDataVo locationDataVo :locationDataVos){
if(time.contains(locationDataVo.getTime())){
locationDataVo.setError(1);
......@@ -134,10 +137,20 @@ public class DataController {
}
}
//如果是已经完结保存到redis中
if(resultCircuitVo.getEndTime() != 0){
infoRedisService.setHash("TransportConfig",transportationNo,locationDataVoList.toString(),60*30);
if(resultCircuitVo.getEndTime() != null && resultCircuitVo.getEndTime() != 0){
Map<Object,Object> map=new HashMap<>();
map.put(transportationNo,locationDataVoList.toString());
infoRedisService.setHash("TransportConfig",map,System.currentTimeMillis());
}
return gson.toJson(locationDataVoList);
}else{
//如果是已经完结保存到redis中
if (resultCircuitVo.getEndTime() != null && resultCircuitVo.getEndTime() != 0) {
Map<Object, Object> map = new HashMap<>();
map.put(transportationNo, locationDataVos.toString());
infoRedisService.setHash("TransportConfig", map,System.currentTimeMillis());
}
return gson.toJson(locationDataVos);
}
}
......@@ -154,16 +167,10 @@ public class DataController {
JSONObject jsonObject= JSON.parseObject(transportationNo);
transportationNo=jsonObject.getString("transportationNo");
ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(transportationNo);
ResultGatewayVo gatewayVo = new ResultGatewayVo();
if(resultCircuitVo.getEndTime() == 0){
gatewayVo = circuitService.getByNo(transportationNo);
}else{
gatewayVo = tdlLogService.getByNo(transportationNo);
}
ResultGatewayVo gatewayVo = tdlLogService.getByNo(transportationNo);
String device = gatewayVo.getType() +"_" +gatewayVo.getSN();
//获取tdl信息
List<String> devList = tdlDeviceService.getByGatewaySN(gatewayVo.getSN(),gatewayVo.getType());
String devcie=gatewayVo.getType()+"_"+gatewayVo.getSN() ;
List<String> devList= tdlDeviceService.getByGatewaySN(gatewayVo.getSN(),gatewayVo.getType());
Long startTime = resultCircuitVo.getStartTime() *1000000l;
if(devList.size() == 0){
fb.setCode(0);
......@@ -171,7 +178,7 @@ public class DataController {
return gson.toJson(fb);
}
List<String> list = new ArrayList<String>(){{
add("\"t\"");
add("\"T\"");
add("\"h\"");
add("\"p\"");
add("\"a0\"");
......@@ -179,7 +186,7 @@ public class DataController {
//add("\"t\"");
}};
Map<String,String> map = new HashMap<>();
map.put("\"t\"","temp");
map.put("\"T\"","temp");
map.put("\"h\"","humidity");
map.put("\"p\"","pressure");
map.put("\"a0\"","shockEnergy");
......@@ -191,8 +198,10 @@ public class DataController {
List<HistoryDataVo> historyDataVoList = new ArrayList<>();
for( int i =0;i<devList.size();i++){
HistoryDataVo historyDataVo = new HistoryDataVo();
historyDataVo.setTDLSN(devList.get(i));
String sql = "SELECT "+list.get(i)+" FROM \"tdl_policy\".\""+devcie+"\" where \"tdl\"=\'"+devList.get(i)+"\' and time >="+startTime + " ORDER BY time ";
String TDLSN=devList.get(i).replace("TDL-","").trim();
historyDataVo.setTDLSN(devList.get(i).replace("TDL-","").trim());
//String sql = "SELECT \"T\" FROM \"tdl_policy\".\"WTD93LG_17110198\" where \"tdl\"=\'TDL-1707010057708\' and time >=1522306792692000000 ORDER BY time";
String sql = "SELECT "+list.get(j)+" FROM \"tdl_policy\".\""+device+"\" where \"tdl\"=\'"+devList.get(i)+"\' and time >="+startTime + " ORDER BY time ";
QueryResult queryResult = influxDBTemplate.query(new Query(sql,database));
List<HistoryData> historyData = new ArrayList<>();
if(queryResult.getResults().get(0).getSeries() != null){
......
......@@ -109,7 +109,7 @@ public class EquipmentBindingController {
map.put("resp",null);
map.put("state",1);
map.put("untie",false);
map.put("TDLSN",bindingVo.getTDLSN());
map.put("TDLSN","tdl-"+bindingVo.getTDLSN());
map.put("createTime",System.currentTimeMillis());
configService.addConfig(map);
Map<Object,Object> msg=new HashMap<>();
......@@ -143,7 +143,7 @@ public class EquipmentBindingController {
}
alarmRuleVos.add(alarmRuleVo);
//向redis中写入报警信息
alarmRedisService.hmSet("TDL/"+bindingVo.getType()+"/" +bindingVo.getSN()+"/Data","tdl-" +bindingVo.getTDLSN()+"_" +alias,gson.toJson(alarmRuleVos));
alarmRedisService.hmSet("TDL/"+bindingVo.getType()+"/" +bindingVo.getSN()+"/Data","TDL-" +bindingVo.getTDLSN()+"_" +alias,gson.toJson(alarmRuleVos));
}
}else{
fb.setCode(0);
......
......@@ -339,11 +339,11 @@ public class GatewayController {
if (device.getState() == 0) {
//挂载
String sr = HttpRequester.sendPost("http://127.0.0.1:8079/witium/addMount", gson.toJson(new GatewaySNAndTypeVo(device.getSN(), device.getType())));
String sr = HttpRequester.sendPost("http://192.168.1.171: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())));
String sr = HttpRequester.sendPost("http://192.168.1.171: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());
......
......@@ -81,8 +81,8 @@ public class LoginController {
fb.setMessage("添加日志失败");
}
} catch (Exception e) {
// e.printStackTrace();
// logger.info(e.toString());
e.printStackTrace();
logger.info(e.toString());
fb.setCode(0);
fb.setMessage("用户名或密码错误");
}
......
......@@ -19,7 +19,7 @@
order by alarmTime desc;
</select>
<insert id="addAlarmLog" parameterType="com.example.tdl.domain.vo.AddAlarmLogVo">
<insert id="addAlarmLog" parameterType="com.example.tdl.entity.AlarmLog">
insert into alarm_log
values(
null,
......@@ -27,7 +27,8 @@
#{TDLSN,jdbcType=VARCHAR},
#{description,jdbcType=VARCHAR},
#{data,jdbcType=FLOAT},
#{alarmTime,jdbcType=INTEGER}
#{alarmTime,jdbcType=INTEGER},
#{classify,jdbcType=VARCHAR}
)
</insert>
......@@ -43,22 +44,22 @@
</select>
<select id = "getByCount" parameterType="String" resultType="com.example.tdl.domain.vo.HistogramData" >
SELECT classify,count(description) FROM alarm_log WHERE classify = "温度"
SELECT classify,count(description) FROM alarm_log WHERE classify = "1"
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 = "震动"
SELECT classify,count(description) FROM alarm_log WHERE classify = "3"
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 = "湿度"
SELECT classify,count(description) FROM alarm_log WHERE classify = "2"
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 = "光爆"
SELECT classify,count(description) FROM alarm_log WHERE classify = "5"
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 = "延迟"
SELECT classify,count(description) FROM alarm_log WHERE classify = "4"
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 = "离线"
SELECT classify,count(description) FROM alarm_log WHERE classify = "6"
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 = "倾角"
......
......@@ -68,6 +68,41 @@
]]>
</insert>
<insert id="add" parameterType="java.util.Map" statementType="CALLABLE">
<![CDATA[
{
call pro_addOneCircuit(
#{transportationNo,mode=IN,jdbcType=VARCHAR},
#{startTime,mode=IN,jdbcType=BIGINT},
#{expTime,mode=IN,jdbcType=BIGINT},
#{compTime,mode=IN,jdbcType=BIGINT},
#{cargoNo,mode=IN,jdbcType=VARCHAR},
#{cargoName,mode=IN,jdbcType=VARCHAR},
#{plateNo,mode=IN,jdbcType=VARCHAR},
#{deliveryAddress,mode=IN,jdbcType=VARCHAR},
#{transportation,mode=IN,jdbcType=VARCHAR},
#{transportationType,mode=IN,jdbcType=VARCHAR},
#{createTime,mode=IN,jdbcType=BIGINT},
#{remark,mode=IN,jdbcType=VARCHAR},
#{counts,mode=IN,jdbcType=INTEGER},
#{countryVar,mode=IN,jdbcType=VARCHAR},
#{cityVar,mode=IN,jdbcType=VARCHAR},
#{addressDetailVar,mode=IN,jdbcType=VARCHAR},
#{lngVar,mode=IN,jdbcType=VARCHAR},
#{latVar,mode=IN,jdbcType=VARCHAR},
#{postCodeVar,mode=IN,jdbcType=VARCHAR},
#{arrivalTimeVar,mode=IN,jdbcType=VARCHAR},
#{startTimeVar,mode=IN,jdbcType=VARCHAR},
#{expTimeVar,mode=IN,jdbcType=BIGINT},
#{compTimeVar,mode=IN,jdbcType=VARCHAR},
#{msg,mode=OUT,jdbcType=VARCHAR}
)
}
]]>
</insert>
<!--修改线路信息-->
<update id="updateCircuit" parameterType="java.util.Map" statementType="CALLABLE">
<![CDATA[
......@@ -135,7 +170,10 @@
<!--根据线路编号获取线路信息-->
<select id="getByTransportationNo" resultType="com.example.tdl.domain.vo.ResultCircuitVo" parameterType="String">
SELECT c.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 IN (SELECT alarm_id from tdl_gateway_log WHERE transportationNo=c.transportationNo)) alarmType,(select GROUP_CONCAT(classify) from alarm_log al where al.transportationNo = c.transportationNo) alarm,evaluate
SELECT c.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 IN (SELECT alarm_id from tdl_gateway_log WHERE transportationNo=c.transportationNo)) alarmType,(select GROUP_CONCAT(classify)
from alarm_log al where al.transportationNo = c.transportationNo) alarm,ifnull(evaluate,"") evaluate
from circuit c where c.state=1
AND c.transportationNo=#{transportationNo,jdbcType=VARCHAR}
</select>
......
......@@ -27,7 +27,7 @@
<!--获取绑定消息-->
<select id="getConfig" parameterType="String" resultType="com.example.tdl.domain.vo.ConfigVo">
select gSN,gType,message,flag,resp,state,untie from config where gSN= #{gSN,jdbcType=VARCHAR} and gType=#{gType,jdbcType=VARCHAR} and state = 1;
select gSN,gType,message,flag,resp,state,untie from config where gSN= #{gSN,jdbcType=VARCHAR} and gType=#{gType,jdbcType=VARCHAR} and state = 1
</select>
<!--绑定回复-->
......
......@@ -76,6 +76,12 @@
AND type=#{type,jdbcType=VARCHAR}
</update>
<select id="getTransportationNo" parameterType="String" resultType="String">
select transportationNo from circuit where id = (select circuit_id from tdldevice
where gateway_id =(SELECT id from gateway where SN=#{SN,jdbcType=VARCHAR}
AND type=#{type,jdbcType=VARCHAR}))
</select>
<!-- <insert id="addGateway" parameterType="com.example.tdl.domain.vo.AddGatewayVo">
INSERT into gateway VALUES (
......
......@@ -57,6 +57,16 @@
</select>
<select id="getByGatewaySN" parameterType="String" resultType="String">
select TDLSN from tdldevice t,gateway g where t.gateway_id = g.id and g.SN =#{SN,jdbcType=VARCHAR} and g.type=#{type,jdbcType=VARCHAR}
select CONCAT("TDL-",TDLSN) TDLSN from tdldevice t,gateway g
where t.gateway_id = g.id
and g.SN =#{SN,jdbcType=VARCHAR}
and g.type=#{type,jdbcType=VARCHAR}
</select>
<select id="getTdlSN" parameterType="String" resultType="String">
select TDLSN from tdldevice t,gateway g
where t.gateway_id = g.id
and g.SN =#{SN,jdbcType=VARCHAR}
and g.type=#{type,jdbcType=VARCHAR}
</select>
</mapper>
\ No newline at end of file
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