Commit ce41a02a authored by zhuangzhuang's avatar zhuangzhuang

4.26--获取实时报警,获取在途线路的信息

parent e9d625d6
...@@ -162,7 +162,7 @@ public class GWConfigWorker implements Callable<String>, MqttCallback { ...@@ -162,7 +162,7 @@ public class GWConfigWorker implements Callable<String>, MqttCallback {
@Override @Override
public void connectionLost(Throwable cause) { public void connectionLost(Throwable cause) {
System.out.println(cause); System.out.println(cause);
clientReconnect(); // clientReconnect();
} }
@Override @Override
......
package com.example.tdl.domain.vo;
public class AlarmDataVo {
private Integer onRoute;
private Integer delay;
private Integer alarmed;
public Integer getOnRoute() {
return onRoute;
}
public void setOnRoute(Integer onRoute) {
this.onRoute = onRoute;
}
public Integer getDelay() {
return delay;
}
public void setDelay(Integer delay) {
this.delay = delay;
}
public Integer getAlarmed() {
return alarmed;
}
public void setAlarmed(Integer alarmed) {
this.alarmed = alarmed;
}
}
...@@ -2,12 +2,22 @@ package com.example.tdl.domain.vo; ...@@ -2,12 +2,22 @@ package com.example.tdl.domain.vo;
public class AlarmLogVo { public class AlarmLogVo {
private String transportationNo;
private String description; private String description;
private String data; private String data;
private Long alarmTime; private Long alarmTime;
public String getTransportationNo() {
return transportationNo;
}
public void setTransportationNo(String transportationNo) {
this.transportationNo = transportationNo;
}
public String getDescription() { public String getDescription() {
return description; return description;
} }
......
...@@ -2,6 +2,8 @@ package com.example.tdl.domain.vo; ...@@ -2,6 +2,8 @@ package com.example.tdl.domain.vo;
public class AlarmTermVo { public class AlarmTermVo {
private String companyName;
private String transportationNo; private String transportationNo;
private String description; private String description;
...@@ -14,6 +16,14 @@ public class AlarmTermVo { ...@@ -14,6 +16,14 @@ public class AlarmTermVo {
private Long endTime; private Long endTime;
public String getCompanyName() {
return companyName;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
public String getTransportationNo() { public String getTransportationNo() {
return transportationNo; return transportationNo;
} }
......
package com.example.tdl.domain.vo;
public class AppCircuitVo {
private String transportationNo;
private String cargoNo;//货物编号
private String cargoName;
private Long expTime;
private Long compTime;
private String startCity;
private Long startTime;
private String endCity;
private Long endTime;
private Integer circuitState;
private String alarmType;
private String alarm;
private String evaluate;
private String transportation;
private String SN;
private String TDLSN;
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 getCargoName() {
return cargoName;
}
public void setCargoName(String cargoName) {
this.cargoName = cargoName;
}
public Long getExpTime() {
return expTime;
}
public void setExpTime(Long expTime) {
this.expTime = expTime;
}
public Long getCompTime() {
return compTime;
}
public void setCompTime(Long compTime) {
this.compTime = compTime;
}
public String getStartCity() {
return startCity;
}
public void setStartCity(String startCity) {
this.startCity = startCity;
}
public Long getStartTime() {
return startTime;
}
public void setStartTime(Long startTime) {
this.startTime = startTime;
}
public String getEndCity() {
return endCity;
}
public void setEndCity(String endCity) {
this.endCity = endCity;
}
public Long getEndTime() {
return endTime;
}
public void setEndTime(Long endTime) {
this.endTime = endTime;
}
public Integer getCircuitState() {
return circuitState;
}
public void setCircuitState(Integer circuitState) {
this.circuitState = circuitState;
}
public String getAlarmType() {
return alarmType;
}
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;
}
public String getTransportation() {
return transportation;
}
public void setTransportation(String transportation) {
this.transportation = transportation;
}
public String getSN() {
return SN;
}
public void setSN(String SN) {
this.SN = SN;
}
public String getTDLSN() {
return TDLSN;
}
public void setTDLSN(String TDLSN) {
this.TDLSN = TDLSN;
}
}
...@@ -12,17 +12,17 @@ public class CheckInVo { ...@@ -12,17 +12,17 @@ public class CheckInVo {
private String version; private String version;
private String bleVersion; private String bleVersion;
private Boolean first; private Boolean first;
private Integer gpsPeriod; private Integer gpsPeriod;
private Integer gprsPeriod; private Integer gprsPeriod;
private Integer mode; private Integer mode;
private List<String> devList; private List<String> devList;
public String getAction() { public String getAction() {
return action; return action;
......
...@@ -3,8 +3,14 @@ package com.example.tdl.domain.vo; ...@@ -3,8 +3,14 @@ package com.example.tdl.domain.vo;
public class ResultCircuitForAppVo { public class ResultCircuitForAppVo {
private String transportationNo; private String transportationNo;
private String cargoName;
private String city; private String city;
private Long expTime;
private Long compTime;
private Long startTime; private Long startTime;
private String cargoNo; private String cargoNo;
...@@ -31,6 +37,14 @@ public class ResultCircuitForAppVo { ...@@ -31,6 +37,14 @@ public class ResultCircuitForAppVo {
this.transportationNo = transportationNo; this.transportationNo = transportationNo;
} }
public String getCargoName() {
return cargoName;
}
public void setCargoName(String cargoName) {
this.cargoName = cargoName;
}
public String getCity() { public String getCity() {
return city; return city;
} }
...@@ -39,6 +53,22 @@ public class ResultCircuitForAppVo { ...@@ -39,6 +53,22 @@ public class ResultCircuitForAppVo {
this.city = city; this.city = city;
} }
public Long getExpTime() {
return expTime;
}
public void setExpTime(Long expTime) {
this.expTime = expTime;
}
public Long getCompTime() {
return compTime;
}
public void setCompTime(Long compTime) {
this.compTime = compTime;
}
public Long getStartTime() { public Long getStartTime() {
return startTime; return startTime;
} }
......
...@@ -5,6 +5,8 @@ public class ResultCircuitVo { ...@@ -5,6 +5,8 @@ public class ResultCircuitVo {
private String cargoNo;//货物编号 private String cargoNo;//货物编号
private String cargoName;
private String startCity; private String startCity;
private Long startTime; private Long startTime;
...@@ -43,6 +45,14 @@ public class ResultCircuitVo { ...@@ -43,6 +45,14 @@ public class ResultCircuitVo {
this.cargoNo = cargoNo; this.cargoNo = cargoNo;
} }
public String getCargoName() {
return cargoName;
}
public void setCargoName(String cargoName) {
this.cargoName = cargoName;
}
public String getStartCity() { public String getStartCity() {
return startCity; return startCity;
} }
......
...@@ -4,6 +4,7 @@ import com.example.tdl.domain.vo.*; ...@@ -4,6 +4,7 @@ import com.example.tdl.domain.vo.*;
import com.example.tdl.entity.AlarmLog; import com.example.tdl.entity.AlarmLog;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import retrofit2.http.PATCH;
import java.util.List; import java.util.List;
...@@ -13,20 +14,24 @@ public interface AlarmLogMapper { ...@@ -13,20 +14,24 @@ public interface AlarmLogMapper {
List<ResultAlarmLog> getAll(); List<ResultAlarmLog> getAll();
//根据条件获取报警数据 //根据条件获取报警数据
List<AlarmLogVo> getAlarmLog(String time); List<AlarmLogVo> getAlarmLog(@Param("time") String time, @Param("companyName") String companyName);
//新增报警数据 //新增报警数据
int addAlarmLog(AlarmLog addAlarmLogVo); int addAlarmLog(AlarmLog addAlarmLogVo);
List<ResultAlarmLog> getByTransportationNo(String transportationNo); List<ResultAlarmLog> getByTransportationNo(String transportationNo);
Integer getCount(String time); Integer getCount(@Param("time") String time, @Param("companyName") String companyName);
Integer getBumpCount(String time); Integer getBumpCount(@Param("time")String time,@Param("companyName") String companyName);
List<HistogramData> getByCount(String time); List<HistogramData> getByCount(@Param("time")String time,@Param("companyName") String companyName);
Integer getByTime(@Param("transportationNo") String transportationNo,@Param("startTime") Long startTime, @Param("endTime") Long endTime); Integer getByTime(@Param("transportationNo") String transportationNo,@Param("startTime") Long startTime, @Param("endTime") Long endTime);
List<ResultAlarmLogVo> getAlarm(AlarmTermVo alarmTermVo); List<ResultAlarmLogVo> getAlarm(AlarmTermVo alarmTermVo);
List<AlarmLogVo> getRealTimeAlarm(String companyName);
Integer getAlarmCount(String companyName);
} }
...@@ -23,7 +23,7 @@ public interface CircuitMapper { ...@@ -23,7 +23,7 @@ public interface CircuitMapper {
int updateEndTime(UpdateCircuitVo updateCircuitVo); int updateEndTime(UpdateCircuitVo updateCircuitVo);
int updateStartTime(StartCircuitVo startCircuitVo); int updateStartTime(Map<Object,Object> map);
int delCircuit(String transportationNo); int delCircuit(String transportationNo);
...@@ -31,19 +31,22 @@ public interface CircuitMapper { ...@@ -31,19 +31,22 @@ public interface CircuitMapper {
ResultCircuitVo getByTransportationNo(@Param("transportationNo") String transportationNo,@Param("companyName") String companyName); ResultCircuitVo getByTransportationNo(@Param("transportationNo") String transportationNo,@Param("companyName") String companyName);
Integer getOnRoute(@Param("time") String time,@Param("companyName") String companyName); Integer getOnRoute(@Param("companyName") String companyName);
Integer getDelayCount(@Param("compTime") Long compTime, @Param("time") String time,@Param("companyName") String companyName); Integer getDelayCount(@Param("compTime") Long compTime, @Param("time") String time,@Param("companyName") String companyName);
Integer getCount(@Param("time") String time,@Param("companyName") String companyName); Integer getDelay(@Param("compTime")Long compTime,@Param("companyName") String companyName);
List<ResultCircuitVo> getByPlateNo(@Param("plateNo") String plateNo,@Param("companyName") String companyName);
Integer getCount(@Param("time") String time,@Param("endTime") Long endTime,@Param("companyName") String companyName);
List<AppCircuitVo> getByPlateNo(@Param("plateNo") String plateNo,@Param("companyName") String companyName);
ResultCircuitForAppVo getByTransportationNoForApp(@Param("transportationNo") String transportationNo,@Param("companyName") String companyName); ResultCircuitForAppVo getByTransportationNoForApp(@Param("transportationNo") String transportationNo,@Param("companyName") String companyName);
ResultCircuitVo getCircuit(String transportationNo); ResultCircuitVo getCircuit(String transportationNo);
List<ResultCircuitVo> getByCircuitState(@Param("circuitState") Integer circuitState,@Param("companyName") String companyName); List<AppCircuitVo> getByCircuitState(@Param("circuitState") Integer circuitState,@Param("companyName") String companyName);
int updateEvaluate(UpdateEvaluateVo updateEvaluateVo); int updateEvaluate(UpdateEvaluateVo updateEvaluateVo);
...@@ -51,10 +54,5 @@ public interface CircuitMapper { ...@@ -51,10 +54,5 @@ public interface CircuitMapper {
ResultGatewayVo getByNo(String transportationNo); ResultGatewayVo getByNo(String transportationNo);
List<ResultCircuitVo> getByTime(@Param("time") String time,@Param("companyName") String companyName); List<ResultCircuitVo> getByTime(String companyName);
// Integer getComplted(@Param("time") String time);
// List<CircuitVo> getDistinct();
} }
...@@ -5,14 +5,15 @@ import com.example.tdl.domain.vo.LoginLogTermVo; ...@@ -5,14 +5,15 @@ import com.example.tdl.domain.vo.LoginLogTermVo;
import com.example.tdl.domain.vo.ResultLoginLogVo; import com.example.tdl.domain.vo.ResultLoginLogVo;
import com.example.tdl.entity.LoginLog; import com.example.tdl.entity.LoginLog;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
@Mapper @Mapper
public interface LoginLogMapper { public interface LoginLogMapper {
List<ResultLoginLogVo> getAll(); List<ResultLoginLogVo> getAll(String companyName);
int addLoginLog(LoginLog loginLog); int addLoginLog(LoginLog loginLog);
List<ResultLoginLogVo> getByTime(LoginLogTermVo loginLogTermVo); List<ResultLoginLogVo> getByTime(@Param("startTime") Long startTime,@Param("stopTime") Long stopTime,@Param("companyName") String companyName);
} }
...@@ -12,6 +12,7 @@ import com.google.gson.JsonObject; ...@@ -12,6 +12,7 @@ import com.google.gson.JsonObject;
import com.google.gson.JsonParser; import com.google.gson.JsonParser;
import com.google.gson.JsonSyntaxException; import com.google.gson.JsonSyntaxException;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.jdbc.Null;
import org.eclipse.paho.client.mqttv3.*; import org.eclipse.paho.client.mqttv3.*;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.expression.spel.ast.NullLiteral; import org.springframework.expression.spel.ast.NullLiteral;
...@@ -117,7 +118,7 @@ public class MqttListener implements MqttCallback { ...@@ -117,7 +118,7 @@ public class MqttListener implements MqttCallback {
@Override @Override
public void connectionLost(Throwable cause) { public void connectionLost(Throwable cause) {
System.out.println(cause); System.out.println(cause);
clientReconnect(); // clientReconnect();
} }
@Override @Override
...@@ -186,9 +187,13 @@ public class MqttListener implements MqttCallback { ...@@ -186,9 +187,13 @@ public class MqttListener implements MqttCallback {
} }
// 有设备信息 // 有设备信息
ConfigVo configVo = configService.getConfig(SN,Type); ConfigVo configVo = configService.getConfig(SN,Type);
if(StringUtils.isEmpty(configVo.getMessage())){ if(configVo == null){
//解绑状态 if(StringUtils.isEmpty(configVo.getMessage())){
return 2;//解绑 //解绑状态
return 2;//解绑
}
}else{
return 0;
} }
ConfigCMDVo configCMDVo = new Gson().fromJson(configVo.getMessage(),ConfigCMDVo.class); ConfigCMDVo configCMDVo = new Gson().fromJson(configVo.getMessage(),ConfigCMDVo.class);
//判断两者的devList是否一致 //判断两者的devList是否一致
......
...@@ -18,8 +18,8 @@ public class AlarmLogService { ...@@ -18,8 +18,8 @@ public class AlarmLogService {
return alarmLogMapper.getAll(); return alarmLogMapper.getAll();
} }
public List<AlarmLogVo> getAlarmLog(String time){ public List<AlarmLogVo> getAlarmLog(String time,String companyName){
return alarmLogMapper.getAlarmLog(time); return alarmLogMapper.getAlarmLog(time,companyName);
} }
public int addAlarmLog(AlarmLog addAlarmLogVo){ public int addAlarmLog(AlarmLog addAlarmLogVo){
...@@ -30,16 +30,20 @@ public class AlarmLogService { ...@@ -30,16 +30,20 @@ public class AlarmLogService {
return alarmLogMapper.getByTransportationNo(transportationNo); return alarmLogMapper.getByTransportationNo(transportationNo);
} }
public Integer getCount(String time){ public Integer getCount(String time,String companyName){
return alarmLogMapper.getCount(time); return alarmLogMapper.getCount(time,companyName);
} }
public Integer getBumpCount(String time){ public Integer getBumpCount(String time,String companyName){
return alarmLogMapper.getBumpCount(time); return alarmLogMapper.getBumpCount(time,companyName);
} }
public List<HistogramData> getByCount(String time){ public Integer getAlarmCount(String companyName){
return alarmLogMapper.getByCount(time); return alarmLogMapper.getAlarmCount(companyName);
}
public List<HistogramData> getByCount(String time,String companyName){
return alarmLogMapper.getByCount(time,companyName);
} }
...@@ -51,5 +55,9 @@ public class AlarmLogService { ...@@ -51,5 +55,9 @@ public class AlarmLogService {
return alarmLogMapper.getAlarm(alarmTermVo); return alarmLogMapper.getAlarm(alarmTermVo);
} }
public List<AlarmLogVo> getRealTimeAlarm(String companyName){
return alarmLogMapper.getRealTimeAlarm(companyName);
}
} }
...@@ -43,8 +43,8 @@ public class CircuitService { ...@@ -43,8 +43,8 @@ public class CircuitService {
return circuitMapper.updateEndTime(updateCircuitVo); return circuitMapper.updateEndTime(updateCircuitVo);
} }
public int updateStartTime(StartCircuitVo startCircuitVo){ public int updateStartTime(Map<Object,Object> map){
return circuitMapper.updateStartTime(startCircuitVo); return circuitMapper.updateStartTime(map);
} }
public int delCircuit(String transportationNo){ public int delCircuit(String transportationNo){
...@@ -67,23 +67,27 @@ public class CircuitService { ...@@ -67,23 +67,27 @@ public class CircuitService {
public ResultCircuitVo getCircuit(String transportationNo){ public ResultCircuitVo getCircuit(String transportationNo){
return circuitMapper.getCircuit(transportationNo); return circuitMapper.getCircuit(transportationNo);
} }
public Integer getOnRoute(String time,String comapnyName){ public Integer getOnRoute(String comapnyName){
return circuitMapper.getOnRoute(time,comapnyName); return circuitMapper.getOnRoute(comapnyName);
} }
public Integer getDelayCount(Long compTime,String time,String companyName){ public Integer getDelayCount(Long compTime,String time,String companyName){
return circuitMapper.getDelayCount(compTime,time,companyName); return circuitMapper.getDelayCount(compTime,time,companyName);
} }
public Integer getCount(String time,String companyName){ public Integer getDelay(Long compTime,String companyName){
return circuitMapper.getCount(time,companyName); return circuitMapper.getDelay(compTime,companyName);
} }
public List<ResultCircuitVo> getByPlateNo(String plateNo,String companyName){ public Integer getCount(String time,Long startTime,String companyName){
return circuitMapper.getCount(time,startTime,companyName);
}
public List<AppCircuitVo> getByPlateNo(String plateNo,String companyName){
return circuitMapper.getByPlateNo(plateNo,companyName); return circuitMapper.getByPlateNo(plateNo,companyName);
} }
public List<ResultCircuitVo> getByCircuitState(Integer circuitState,String companyName){ public List<AppCircuitVo> getByCircuitState(Integer circuitState,String companyName){
return circuitMapper.getByCircuitState(circuitState,companyName); return circuitMapper.getByCircuitState(circuitState,companyName);
} }
...@@ -99,8 +103,8 @@ public class CircuitService { ...@@ -99,8 +103,8 @@ public class CircuitService {
return circuitMapper.getByNo(transportationNo); return circuitMapper.getByNo(transportationNo);
} }
public List<ResultCircuitVo> getByTime(String time,String companyName){ public List<ResultCircuitVo> getByTime(String companyName){
return circuitMapper.getByTime(time,companyName); return circuitMapper.getByTime(companyName);
} }
// public List<CircuitVo> getDistinct(){ // public List<CircuitVo> getDistinct(){
......
...@@ -16,15 +16,15 @@ public class LoginLogService { ...@@ -16,15 +16,15 @@ public class LoginLogService {
@Autowired @Autowired
private LoginLogMapper loginLogMapper; private LoginLogMapper loginLogMapper;
public List<ResultLoginLogVo> getAll(){ public List<ResultLoginLogVo> getAll(String companyName){
return loginLogMapper.getAll(); return loginLogMapper.getAll(companyName);
} }
public int addLoginLog(LoginLog loginLog){ public int addLoginLog(LoginLog loginLog){
return loginLogMapper.addLoginLog(loginLog); return loginLogMapper.addLoginLog(loginLog);
} }
public List<ResultLoginLogVo> getByTime(LoginLogTermVo loginLogTermVo){ public List<ResultLoginLogVo> getByTime(Long startTime,Long stopTime,String companyName){
return loginLogMapper.getByTime(loginLogTermVo); return loginLogMapper.getByTime(startTime,stopTime,companyName);
} }
} }
package com.example.tdl.web; package com.example.tdl.web;
import com.example.tdl.domain.dto.CommFeedback; import com.example.tdl.domain.dto.CommFeedback;
import com.example.tdl.domain.vo.AddAlarmLogVo; import com.example.tdl.domain.vo.*;
import com.example.tdl.domain.vo.AlarmTermVo;
import com.example.tdl.domain.vo.ResultCircuit;
import com.example.tdl.domain.vo.ResultCircuitVo;
import com.example.tdl.entity.AlarmLog; import com.example.tdl.entity.AlarmLog;
import com.example.tdl.service.AlarmLogService; import com.example.tdl.service.AlarmLogService;
import com.example.tdl.service.CircuitService; import com.example.tdl.service.CircuitService;
import com.example.tdl.service.GatewayService; import com.example.tdl.service.GatewayService;
import com.example.tdl.service.redis.TokenRedisService;
import com.google.gson.Gson; import com.google.gson.Gson;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
...@@ -19,6 +17,7 @@ import org.slf4j.LoggerFactory; ...@@ -19,6 +17,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
...@@ -41,6 +40,69 @@ public class AlarmLogController { ...@@ -41,6 +40,69 @@ public class AlarmLogController {
@Autowired @Autowired
private CircuitService circuitService; private CircuitService circuitService;
@Autowired
private TokenRedisService tokenRedisService;
//获取报警信息
@ApiOperation(value = "获取报警信息",notes = "获取报警信息" +
" transportationNo:运输编号" +
" description:报警内容" +
" startCity:启运城市" +
" endCity:目的城市" +
" startTime:出发时间(时间戳)" +
" endTime:结束时间(时间戳)" +
"返回值: transportationNo:运输编号" +
" cargoNo:货号" +
" startCity:启运城市" +
" endCity:目的城市" +
" description:报警内容" +
" alarmTime:报警时间" )
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
@PostMapping("/getAlarm")
public Object getAlarm(@RequestBody AlarmTermVo alarmTermVo ,HttpServletRequest request){
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" + token);
UserRedisVo user = gson.fromJson(datum, UserRedisVo.class);
if(StringUtils.isEmpty(alarmTermVo.getTransportationNo())){
alarmTermVo.setTransportationNo(null);
}
if(StringUtils.isEmpty(alarmTermVo.getDescription())){
alarmTermVo.setDescription(null);
}
if(StringUtils.isEmpty(alarmTermVo.getEndCity())){
alarmTermVo.setEndCity(null);
}
if(StringUtils.isEmpty(alarmTermVo.getStartCity())){
alarmTermVo.setStartCity(null);
}
if(alarmTermVo.getStartTime()==null){
alarmTermVo.setStartTime(null);
}
if(alarmTermVo.getDescription()==null){
alarmTermVo.setEndTime(null);
}
alarmTermVo.setCompanyName(user.getCompanyName());
return alarmLogServcie.getAlarm(alarmTermVo);
}
//获取最新报警
@ApiOperation(value = "获取报警信息",notes = "获取报警信息" +
"返回值: transportationNo:运输编号" +
"data:报警数据" +
"description:报警内容" +
"alarmTime:报警时间" )
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
@PostMapping("/getRealTimeAlarm")
public Object getRealTimeAlarm(HttpServletRequest request){
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" + token);
UserRedisVo user = gson.fromJson(datum, UserRedisVo.class);
return alarmLogServcie.getRealTimeAlarm(user.getCompanyName());
}
//新增报警消息 //新增报警消息
@ApiOperation(value = "增加报警",notes = "增加报警") @ApiOperation(value = "增加报警",notes = "增加报警")
...@@ -72,30 +134,25 @@ public class AlarmLogController { ...@@ -72,30 +134,25 @@ public class AlarmLogController {
map.put(4,"过低"); map.put(4,"过低");
map.put(5,"未知"); map.put(5,"未知");
//根据gateway的信息获取线路信息 //根据gateway的信息获取线路信息
String transportationNo = gatewayService.getTransportationNo(addAlarmLogVo.getGsn(),addAlarmLogVo.getGtype()); String transportationNo = gatewayService.getTransportationNo(addAlarmLogVo.getGsn(),addAlarmLogVo.getGtype());
//获取终点,起点 //获取终点,起点
ResultCircuitVo resultCircuitVo = circuitService.getCircuit(transportationNo); ResultCircuitVo resultCircuitVo = circuitService.getCircuit(transportationNo);
for(int i = 0;i<addAlarmLogVo.getAlarm().size();i++){ for(int i = 0;i<addAlarmLogVo.getAlarm().size();i++){
String classify=""; String classify="";
String desp = ""; String desp = "";
if(addAlarmLogVo.getAlarm().get(i).getAlias().contains("T")){ if(addAlarmLogVo.getAlarm().get(i).getAlias().contains("T")){
desp = "温度" +map.get(addAlarmLogVo.getAlarm().get(i).getAlarmno()); desp = "温度" +map.get(addAlarmLogVo.getAlarm().get(i).getAlarmno());
classify = "1"; classify = "1";
} else if(addAlarmLogVo.getAlarm().get(i).getDesp().contains("h")){ } else if(addAlarmLogVo.getAlarm().get(i).getDesp().contains("h")){
desp = "湿度" +map.get(addAlarmLogVo.getAlarm().get(i).getAlarmno()); desp = "湿度" +map.get(addAlarmLogVo.getAlarm().get(i).getAlarmno());
classify = "2"; classify = "2";
} else if(addAlarmLogVo.getAlarm().get(i).getDesp().contains("a0")){ } else if(addAlarmLogVo.getAlarm().get(i).getDesp().contains("a0")){
desp = "震动" +map.get(addAlarmLogVo.getAlarm().get(i).getAlarmno()); desp = "震动" +map.get(addAlarmLogVo.getAlarm().get(i).getAlarmno());
classify = "3"; classify = "3";
} else if(addAlarmLogVo.getAlarm().get(i).getDesp().contains("ta")){ } else if(addAlarmLogVo.getAlarm().get(i).getDesp().contains("ta")){
desp = "倾角" +map.get(addAlarmLogVo.getAlarm().get(i).getAlarmno()); desp = "倾角" +map.get(addAlarmLogVo.getAlarm().get(i).getAlarmno());
classify = "4"; classify = "4";
} } else if(addAlarmLogVo.getAlarm().get(i).getDesp().contains("离线")){
// else if(addAlarmLogVo.getAlarm().get(i).getDesp().contains("光爆")){
// desp = "温度" +map.get(addAlarmLogVo.getAlarm().get(i).getAlarmno());
// classify = "5";
// }
else if(addAlarmLogVo.getAlarm().get(i).getDesp().contains("离线")){
desp = addAlarmLogVo.getAlarm().get(i).getTdlsn()+"离线"; desp = addAlarmLogVo.getAlarm().get(i).getTdlsn()+"离线";
classify = "6"; classify = "6";
} }
...@@ -112,43 +169,4 @@ public class AlarmLogController { ...@@ -112,43 +169,4 @@ public class AlarmLogController {
return gson.toJson(fb); return gson.toJson(fb);
} }
//获取报警信息
@ApiOperation(value = "获取报警信息",notes = "获取报警信息" +
"transportationNo:运输编号" +
"description:报警内容" +
"startCity:启运城市" +
"endCity:目的城市" +
"startTime:出发时间(时间戳)" +
"endTime:结束时间(时间戳)" +
"返回值: transportationNo:运输编号" +
"cargoNo:货号" +
"startCity:启运城市" +
"endCity:目的城市" +
"description:报警内容" +
"alarmTime:报警时间" )
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
@PostMapping("/getAlarm")
public Object getAlarm(@RequestBody AlarmTermVo alarmTermVo ){
if(StringUtils.isEmpty(alarmTermVo.getTransportationNo())){
alarmTermVo.setTransportationNo(null);
}
if(StringUtils.isEmpty(alarmTermVo.getDescription())){
alarmTermVo.setDescription(null);
}
if(StringUtils.isEmpty(alarmTermVo.getEndCity())){
alarmTermVo.setEndCity(null);
}
if(StringUtils.isEmpty(alarmTermVo.getStartCity())){
alarmTermVo.setStartCity(null);
}
if(alarmTermVo.getStartTime()==null){
alarmTermVo.setStartTime(null);
}
if(alarmTermVo.getDescription()==null){
alarmTermVo.setEndTime(null);
}
return alarmLogServcie.getAlarm(alarmTermVo);
}
} }
...@@ -75,6 +75,7 @@ public class CircuitController { ...@@ -75,6 +75,7 @@ public class CircuitController {
@ApiOperation(value = "获取本公司的线路信息",notes = "获取本公司的线路信息,返回值说明:" + @ApiOperation(value = "获取本公司的线路信息",notes = "获取本公司的线路信息,返回值说明:" +
" transportationNo:运输编号," + " transportationNo:运输编号," +
" cargoNo:货物编号" + " cargoNo:货物编号" +
" cargoName:货物别名" +
" startCity:起运城市," + " startCity:起运城市," +
" startTime:起运时间," + " startTime:起运时间," +
" endCity:目的城市," + " endCity:目的城市," +
...@@ -94,10 +95,13 @@ public class CircuitController { ...@@ -94,10 +95,13 @@ public class CircuitController {
return circuitService.getAll(user.getCompanyName()); return circuitService.getAll(user.getCompanyName());
} }
//根据运输编号查询本公司的运输信息(web端) //根据运输编号查询本公司的运输信息(web端)
@ApiOperation(value = "根据运输编号查询本公司的运输信息(web端)",notes = "根据运输编号查询本公司的运输信息(web端),返回值说明:" + @ApiOperation(value = "根据运输编号查询本公司的运输信息(web端)",notes = "根据运输编号查询本公司的运输信息(web端),返回值说明:" +
" transportationNo:运输编号," + " transportationNo:运输编号," +
" cargoNo:货物编号" + " cargoNo:货物编号" +
" cargoName:货物别名" +
" startCity:起运城市," + " startCity:起运城市," +
" startTime:起运时间," + " startTime:起运时间," +
" endCity:目的城市," + " endCity:目的城市," +
...@@ -119,9 +123,12 @@ public class CircuitController { ...@@ -119,9 +123,12 @@ public class CircuitController {
return circuitService.getByTransportationNo(transportationNo,user.getCompanyName()); return circuitService.getByTransportationNo(transportationNo,user.getCompanyName());
} }
//根据运输编号查询本公司的运输信息(app端) //根据运输编号查询本公司的运输信息(app端)
@ApiOperation(value = "根据运输编号查询本公司的运输信息(app端)",notes = "根据运输编号查询本公司的运输信息(app端),返回值说明:" + @ApiOperation(value = "根据运输编号查询本公司的运输信息(app端)",notes = "根据运输编号查询本公司的运输信息(app端),返回值说明:" +
" transportationNo:运输编号," + " transportationNo:运输编号," +
" cargoName:货物别名" +
" city:城市," + " city:城市," +
" startTime:起运时间," + " startTime:起运时间," +
" cargoNo:货物编号," + " cargoNo:货物编号," +
...@@ -147,6 +154,8 @@ public class CircuitController { ...@@ -147,6 +154,8 @@ public class CircuitController {
return resultCircuitForAppVo; return resultCircuitForAppVo;
} }
//根据条件查询 //根据条件查询
@ApiOperation(value = "根据条件查询本公司的线路信息",notes = "companyName不用传,根据条件查询:" + @ApiOperation(value = "根据条件查询本公司的线路信息",notes = "companyName不用传,根据条件查询:" +
" cargoNo:货物编号" + " cargoNo:货物编号" +
...@@ -156,6 +165,7 @@ public class CircuitController { ...@@ -156,6 +165,7 @@ public class CircuitController {
"返回值说明:" + "返回值说明:" +
" transportationNo:运输编号," + " transportationNo:运输编号," +
" cargoNo:货物编号" + " cargoNo:货物编号" +
" cargoName:货物别名" +
" startCity:起运城市," + " startCity:起运城市," +
" startTime:起运时间," + " startTime:起运时间," +
" endCity:目的城市," + " endCity:目的城市," +
...@@ -188,6 +198,8 @@ public class CircuitController { ...@@ -188,6 +198,8 @@ public class CircuitController {
return circuitService.getByTerm(circuitTermVo); return circuitService.getByTerm(circuitTermVo);
} }
//添加线路信息 //添加线路信息
@ApiOperation(value = "添加线路信息",notes = "添加线路信息," + @ApiOperation(value = "添加线路信息",notes = "添加线路信息," +
" startAddressVo: 线路集合,包含" + " startAddressVo: 线路集合,包含" +
...@@ -295,7 +307,7 @@ public class CircuitController { ...@@ -295,7 +307,7 @@ public class CircuitController {
String expTimeVar = addCircuitVo.getStartAddressVo().getExpTime()+" "; String expTimeVar = addCircuitVo.getStartAddressVo().getExpTime()+" ";
String compTimeVar = "0 "; String compTimeVar = "0 ";
String arrivalTimeVar=time +" "; String arrivalTimeVar=time +" ";
String startTimeVar=time +" "; String startTimeVar=0 +" ";
if(addCircuitVo.getAddressVoList() != null){ if(addCircuitVo.getAddressVoList() != null){
if(addCircuitVo.getAddressVoList().size()>3){ if(addCircuitVo.getAddressVoList().size()>3){
fb.setCode(0); fb.setCode(0);
...@@ -553,6 +565,8 @@ public class CircuitController { ...@@ -553,6 +565,8 @@ public class CircuitController {
return gson.toJson(fb); return gson.toJson(fb);
} }
@ApiOperation(value = "添加线路信息----mobile",notes = "添加线路信息," + @ApiOperation(value = "添加线路信息----mobile",notes = "添加线路信息," +
" cargoNo:货物编号," + " cargoNo:货物编号," +
" plateNo:车牌号," + " plateNo:车牌号," +
...@@ -758,10 +772,12 @@ public class CircuitController { ...@@ -758,10 +772,12 @@ public class CircuitController {
return gson.toJson(fb); return gson.toJson(fb);
} }
//修改线路结束时间 //修改线路结束时间
@ApiOperation(value = "修改线路结束时间",notes = "修改线路结束时间,传值说明:" + @ApiOperation(value = "修改线路结束时间",notes = "修改线路结束时间,传值说明:" +
" transportationNo:运输编号," + " transportationNo:运输编号," +
" endTime:目的时间 " ) " endTime:到达时间 " )
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"), @ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
}) })
...@@ -788,6 +804,7 @@ public class CircuitController { ...@@ -788,6 +804,7 @@ public class CircuitController {
fb.setMessage("线路未开始"); fb.setMessage("线路未开始");
return gson.toJson(fb); return gson.toJson(fb);
} }
ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(updateCircuitVo.getTransportationNo(),user.getCompanyName());
//获取当前线路的gateway 和tdl信息 //获取当前线路的gateway 和tdl信息
TDLLogVo tdlLogVo = tdlLogService.getByTransportationNo(updateCircuitVo.getTransportationNo()); TDLLogVo tdlLogVo = tdlLogService.getByTransportationNo(updateCircuitVo.getTransportationNo());
if(tdlLogVo == null){ if(tdlLogVo == null){
...@@ -837,12 +854,14 @@ public class CircuitController { ...@@ -837,12 +854,14 @@ public class CircuitController {
map.put("transportationNo",updateCircuitVo.getTransportationNo()); map.put("transportationNo",updateCircuitVo.getTransportationNo());
map.put("gSN",tdlLogVo.getgSN()); map.put("gSN",tdlLogVo.getgSN());
map.put("gType",tdlLogVo.getgType()); map.put("gType",tdlLogVo.getgType());
map.put("startCity",resultCircuitVo.getStartCity());
map.put("endCity",resultCircuitVo.getEndCity());
map.put("message",gson.toJson(configCMDVo)); map.put("message",gson.toJson(configCMDVo));
map.put("endTime",updateCircuitVo.getEndTime()); map.put("endTime",updateCircuitVo.getEndTime());
circuitService.endCircuit(map); circuitService.endCircuit(map);
Map<Object,Object> msg=new HashMap<>(); Map<Object,Object> msg=new HashMap<>();
msg.put("msg",map.get("msg")); msg.put("msg",map.get("msg"));
if (msg.get("msg").equals("解除网关成功")){ if (msg.get("msg").equals("修改成功")){
fb.setCode(1); fb.setCode(1);
fb.setMessage(msg.get("msg").toString()); fb.setMessage(msg.get("msg").toString());
String key ="TDL/"+tdlLogVo.getgType()+"/" +tdlLogVo.getgSN() +"/Data"; String key ="TDL/"+tdlLogVo.getgType()+"/" +tdlLogVo.getgSN() +"/Data";
...@@ -854,10 +873,12 @@ public class CircuitController { ...@@ -854,10 +873,12 @@ public class CircuitController {
return gson.toJson(fb); return gson.toJson(fb);
} }
//根据车牌号查线路 //根据车牌号查线路
@ApiOperation(value = "根据车牌号查线路---mobile",notes = "根据车牌号查线路,返回值说明:" + @ApiOperation(value = "根据车牌号查线路---mobile",notes = "根据车牌号查线路,返回值说明:" +
" transportationNo:运输编号," + " transportationNo:运输编号," +
" cargoNo:货物编号" + " cargoNo:货物编号" +
" cargoName:货物别名" +
" startCity:起运城市," + " startCity:起运城市," +
" startTime:起运时间," + " startTime:起运时间," +
" endCity:目的城市," + " endCity:目的城市," +
...@@ -879,6 +900,8 @@ public class CircuitController { ...@@ -879,6 +900,8 @@ public class CircuitController {
return circuitService.getByPlateNo(plateNo,user.getCompanyName()); return circuitService.getByPlateNo(plateNo,user.getCompanyName());
} }
//评价 //评价
@ApiOperation(value = "评价---mobile",notes = "评价线路传值说明:" + @ApiOperation(value = "评价---mobile",notes = "评价线路传值说明:" +
" transportationNo:运输编号," + " transportationNo:运输编号," +
...@@ -923,10 +946,13 @@ public class CircuitController { ...@@ -923,10 +946,13 @@ public class CircuitController {
return gson.toJson(fb); return gson.toJson(fb);
} }
//根据运输状态查询线路信息 //根据运输状态查询线路信息
@ApiOperation(value = "根据运输状态查询线路信息---mobile",notes = "根据运输状态查询线路信息,传值说明:{\"circuitState\":2} ,circuitState:线路状态(0未开始,1运输中,2完成),返回值说明:" + @ApiOperation(value = "根据运输状态查询线路信息---mobile",notes = "根据运输状态查询线路信息,传值说明:{\"circuitState\":2} ,circuitState:线路状态(0未开始,1运输中,2完成),返回值说明:" +
" transportationNo:运输编号," + " transportationNo:运输编号," +
" cargoNo:货物编号" + " cargoNo:货物编号" +
" cargoName:货物别名" +
" startCity:起运城市," + " startCity:起运城市," +
" startTime:起运时间," + " startTime:起运时间," +
" endCity:目的城市," + " endCity:目的城市," +
...@@ -952,6 +978,7 @@ public class CircuitController { ...@@ -952,6 +978,7 @@ public class CircuitController {
return circuitService.getByCircuitState(Integer.valueOf(map.get("circuitState").toString()),user.getCompanyName()); return circuitService.getByCircuitState(Integer.valueOf(map.get("circuitState").toString()),user.getCompanyName());
} }
//删除线路 //删除线路
@ApiOperation(value = "删除线路",notes = "删除线路,传值说明:" + @ApiOperation(value = "删除线路",notes = "删除线路,传值说明:" +
" transportationNo:运输编号" ) " transportationNo:运输编号" )
...@@ -1057,12 +1084,14 @@ public class CircuitController { ...@@ -1057,12 +1084,14 @@ public class CircuitController {
return gson.toJson(fb); return gson.toJson(fb);
} }
//根据线路编号获取线路详细信息 //根据线路编号获取线路详细信息
@ApiOperation(value = "根据线路编号获取线路详细信息",notes = "根据线路编号获取线路详细信息,传值说明:" + @ApiOperation(value = "根据线路编号获取线路详细信息",notes = "根据线路编号获取线路详细信息,传值说明:" +
" transportationNo:运输编号; " + " transportationNo:运输编号; " +
"返回值说明:" + "返回值说明:" +
" transportationNo:运输编号" + " transportationNo:运输编号" +
" cargoNo:货物编号" + " cargoNo:货物编号" +
" cargoName:货物别名" +
" startCity:出发城市" + " startCity:出发城市" +
" endCity:目的城市" + " endCity:目的城市" +
" circuitState:线路状态" + " circuitState:线路状态" +
...@@ -1214,7 +1243,9 @@ public class CircuitController { ...@@ -1214,7 +1243,9 @@ public class CircuitController {
//开始运输 //开始运输
@ApiOperation(value = "开始运输",notes = "开始运输") @ApiOperation(value = "开始运输",notes = "开始运输" +
"startTime:开始时间(13位时间戳)" +
"transportationNo:运输编号")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"), @ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
}) })
...@@ -1223,7 +1254,6 @@ public class CircuitController { ...@@ -1223,7 +1254,6 @@ public class CircuitController {
String token = request.getHeader("Account_token"); String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token); String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class); UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
if (StringUtils.isEmpty(startCircuitVo.getTransportationNo())){ if (StringUtils.isEmpty(startCircuitVo.getTransportationNo())){
fb.setCode(0); fb.setCode(0);
fb.setMessage("运输编号不能为空"); fb.setMessage("运输编号不能为空");
...@@ -1246,17 +1276,24 @@ public class CircuitController { ...@@ -1246,17 +1276,24 @@ public class CircuitController {
fb.setMessage("该线路未绑定tdl和gateway"); fb.setMessage("该线路未绑定tdl和gateway");
return gson.toJson(fb); return gson.toJson(fb);
} }
int a = circuitService.updateStartTime(startCircuitVo); Map<Object,Object> map=new HashMap<>();
if (a>0){ map.put("transportationNo",startCircuitVo.getTransportationNo());
map.put("startTime",startCircuitVo.getStartTime());
circuitService.updateStartTime(map);
Map<Object,Object> msg=new HashMap<>();
msg.put("msg",map.get("msg"));
if (msg.get("msg").equals("修改成功")){
fb.setCode(1); fb.setCode(1);
fb.setMessage("线路开启成功"); fb.setMessage("添加线路成功");
}else{ }else {
fb.setCode(0); fb.setCode(0);
fb.setMessage("线路开启失败"); fb.setMessage(msg.get("msg").toString());
} }
return gson.toJson(fb); return gson.toJson(fb);
} }
//生成运输编号 //生成运输编号
public String getTransportNo(String transportation,String transportationType){ public String getTransportNo(String transportation,String transportationType){
String transportationNo=""; String transportationNo="";
......
...@@ -292,10 +292,10 @@ public class GatewayController { ...@@ -292,10 +292,10 @@ public class GatewayController {
} }
//挂载设备 //挂载设备
@ApiOperation(value = "使用通道模板配置通道",notes = "使用通道模板配置通道" + @ApiOperation(value = "设备挂载/xie",notes = "使用通道模板配置通道" +
" SN:设备编号" + " SN:设备编号" +
" type:设备类型" + " type:设备类型" +
" state:挂载/卸载" + " state:挂载-0/卸载-1" +
" bConfig:是否配置通道") " bConfig:是否配置通道")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"), @ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
...@@ -356,13 +356,12 @@ public class GatewayController { ...@@ -356,13 +356,12 @@ public class GatewayController {
infoRedisService.hmSet("SubTopic", device.getType() + "_" + device.getSN(), subList.toString()); infoRedisService.hmSet("SubTopic", device.getType() + "_" + device.getSN(), subList.toString());
infoRedisService.hmSet("PubTopic", device.getType() + "_" + device.getSN(), pubList.toString()); infoRedisService.hmSet("PubTopic", device.getType() + "_" + device.getSN(), pubList.toString());
if (device.getState() == 0) { if (device.getState() == 0) {
//挂载 //挂载
String sr = HttpRequester.sendPost("http://192.168.1.13:8079/witium/addMount", gson.toJson(new GatewaySNAndTypeVo(device.getSN(), device.getType()))); String sr = HttpRequester.sendPost("http://192.168.1.16:8079/witium/addMount", gson.toJson(new GatewaySNAndTypeVo(device.getSN(), device.getType())));
device.setState(1); device.setState(1);
} else if (device.getState() == 1) { } else if (device.getState() == 1) {
//卸载 //卸载
String sr = HttpRequester.sendPost("http://192.168.1.13:8079/witium/delMount", gson.toJson(new GatewaySNAndTypeVo(device.getSN(), device.getType()))); String sr = HttpRequester.sendPost("http://192.168.1.16:8079/witium/delMount", gson.toJson(new GatewaySNAndTypeVo(device.getSN(), device.getType())));
device.setState(0); device.setState(0);
infoRedisService.delHashKey("DeviceConfig", device.getType() + "_" + device.getSN()); infoRedisService.delHashKey("DeviceConfig", device.getType() + "_" + device.getSN());
infoRedisService.delHashKey("SubTopic", device.getType() + "_" + device.getSN()); infoRedisService.delHashKey("SubTopic", device.getType() + "_" + device.getSN());
......
...@@ -95,17 +95,17 @@ public class HomePageController { ...@@ -95,17 +95,17 @@ public class HomePageController {
//获取数量 //获取数量
HomePageDataVo dataVo = new HomePageDataVo(); HomePageDataVo dataVo = new HomePageDataVo();
//获取所有的线路数量 //获取所有的线路数量
dataVo.setSum(circuitService.getCount(time,user.getCompanyName()));//总数量 dataVo.setSum(circuitService.getCount(time,System.currentTimeMillis()/1000l,user.getCompanyName()));//总数量
//获取近几天的线路信息 //获取近几天的线路信息
dataVo.setOnRoute(circuitService.getOnRoute(time,user.getCompanyName()));//在途数量 dataVo.setOnRoute(circuitService.getOnRoute(user.getCompanyName()));//在途数量
dataVo.setDelay(circuitService.getDelayCount(System.currentTimeMillis(),time,user.getCompanyName()));//延误数量 dataVo.setDelay(circuitService.getDelayCount(System.currentTimeMillis(),time,user.getCompanyName()));//延误数量
dataVo.setAlarmed( alarmLogServcie.getCount(time));//报警数量 dataVo.setAlarmed( alarmLogServcie.getCount(time,user.getCompanyName()));//报警数量
dataVo.setBump(alarmLogServcie.getBumpCount(time)); //获取颠簸数量 dataVo.setBump(alarmLogServcie.getBumpCount(time,user.getCompanyName())); //获取颠簸数量
dataVo.setAlarmLogVoList(alarmLogServcie.getAlarmLog(time));//报警列表 dataVo.setAlarmLogVoList(alarmLogServcie.getAlarmLog(time,user.getCompanyName()));//报警列表
List<HistogramData> list = alarmLogServcie.getByCount(time);//获取报警柱状图 List<HistogramData> list = alarmLogServcie.getByCount(time,user.getCompanyName());//获取报警柱状图
dataVo.setHistogramDataList(list); dataVo.setHistogramDataList(list);
//获取设备的当前位置 //获取设备的当前位置
List<ResultCircuitVo> circuitVos = circuitService.getByTime(time,user.getCompanyName()); List<ResultCircuitVo> circuitVos = circuitService.getByTime(user.getCompanyName());
List<CircuitVo> circuitList = new ArrayList<>(); List<CircuitVo> circuitList = new ArrayList<>();
for(int i = 0;i<circuitVos.size();i++){ for(int i = 0;i<circuitVos.size();i++){
CircuitVo circuitVo = new CircuitVo(); CircuitVo circuitVo = new CircuitVo();
...@@ -150,6 +150,28 @@ public class HomePageController { ...@@ -150,6 +150,28 @@ public class HomePageController {
return gson.toJson(dataVo); return gson.toJson(dataVo);
} }
//获取当天所有的设备数据
@ApiOperation(value = "获取所有的运输数据",notes = "获取运输设备数据:" +
"onRoute:在途数量;" +
"delay:延误数量;" +
"alarmed: 报警数量;")
@PostMapping("/getAllForAPP")
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
public Object getAllForAPP(HttpServletRequest request){
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
AlarmDataVo alarmDataVo = new AlarmDataVo();
alarmDataVo.setOnRoute(circuitService.getOnRoute(user.getCompanyName()));
alarmDataVo.setAlarmed(alarmLogServcie.getAlarmCount(user.getCompanyName()));
alarmDataVo.setDelay(circuitService.getDelay(System.currentTimeMillis(),user.getCompanyName()));
return gson.toJson(alarmDataVo);
}
//解析时间 //解析时间
public String parseTime(String time){ public String parseTime(String time){
String dateResult =null; String dateResult =null;
......
...@@ -3,6 +3,7 @@ package com.example.tdl.web; ...@@ -3,6 +3,7 @@ package com.example.tdl.web;
import com.example.tdl.domain.dto.CommFeedback; import com.example.tdl.domain.dto.CommFeedback;
import com.example.tdl.domain.vo.LoginLogTermVo; import com.example.tdl.domain.vo.LoginLogTermVo;
import com.example.tdl.domain.vo.UserRedisVo;
import com.example.tdl.service.LoginLogService; import com.example.tdl.service.LoginLogService;
import com.example.tdl.service.redis.TokenRedisService; import com.example.tdl.service.redis.TokenRedisService;
import com.google.gson.Gson; import com.google.gson.Gson;
...@@ -18,6 +19,8 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -18,6 +19,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
@RestController @RestController
@RequestMapping("/loginLog") @RequestMapping("/loginLog")
public class LoginLogController { public class LoginLogController {
...@@ -43,8 +46,11 @@ public class LoginLogController { ...@@ -43,8 +46,11 @@ public class LoginLogController {
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"), @ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
}) })
@RequestMapping(value="/getAll",method = RequestMethod.GET) @RequestMapping(value="/getAll",method = RequestMethod.GET)
public Object getAll(){ public Object getAll(HttpServletRequest request){
return loginLogService.getAll(); String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
return loginLogService.getAll(user.getCompanyName());
} }
//根据时间查询登录日志 //根据时间查询登录日志
...@@ -59,7 +65,10 @@ public class LoginLogController { ...@@ -59,7 +65,10 @@ public class LoginLogController {
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"), @ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
}) })
@RequestMapping(value="/getByTime",method = RequestMethod.POST) @RequestMapping(value="/getByTime",method = RequestMethod.POST)
public Object getByTime(@RequestBody LoginLogTermVo loginLogTermVo){ public Object getByTime(@RequestBody LoginLogTermVo loginLogTermVo, HttpServletRequest request){
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
if (loginLogTermVo.getStartTime() == null){ if (loginLogTermVo.getStartTime() == null){
fb.setCode(0); fb.setCode(0);
fb.setMessage("查询开始时间不能为空"); fb.setMessage("查询开始时间不能为空");
...@@ -70,6 +79,6 @@ public class LoginLogController { ...@@ -70,6 +79,6 @@ public class LoginLogController {
fb.setMessage("查询结束时间不能为空"); fb.setMessage("查询结束时间不能为空");
return gson.toJson(fb); return gson.toJson(fb);
} }
return loginLogService.getByTime(loginLogTermVo); return loginLogService.getByTime(loginLogTermVo.getStartTime(),loginLogTermVo.getStopTime(),user.getCompanyName());
} }
} }
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/tdlCloud?useUnicode=true&characterEncoding=utf-8&useSSL=false spring.datasource.url=jdbc:mysql://192.168.1.16:3306/tdlCloud?useUnicode=true&characterEncoding=utf-8&useSSL=false
spring.datasource.username=root spring.datasource.username=root
spring.datasource.password=root spring.datasource.password=37774020
spring.datasource.driver-class-name=com.mysql.jdbc.Driver spring.datasource.driver-class-name=com.mysql.jdbc.Driver
threadpool.corepoolsize = 30 threadpool.corepoolsize = 30
threadpool.maxpoolsize = 50 threadpool.maxpoolsize = 50
server.port=8092 server.port=8092
management.security.enabled=false management.security.enabled=false
mybatis.type-aliases-package=com.example.demo.entity
mybatis.type-aliases-package=com.example.demo.entity
mybatis.config-location=classpath:mybatis-config.xml mybatis.config-location=classpath:mybatis-config.xml
# Redis服务器地址 # Redis服务器地址
tdl.redis.host=127.0.0.1 tdl.redis.host=192.168.1.16
# Redis数据库索引(默认为0) # Redis数据库索引(默认为0)
tdl.redis.index=0 tdl.redis.index=0
# Redis服务器连接端口 # Redis服务器连接端口
...@@ -37,6 +38,7 @@ tdl.redis.timeout=0 ...@@ -37,6 +38,7 @@ tdl.redis.timeout=0
# Logging # Logging
logging.config=classpath:logback.xml logging.config=classpath:logback.xml
# Mqtt # Mqtt
tdl.mqtt.url = ssl://192.168.1.11 tdl.mqtt.url = ssl://192.168.1.11
tdl.mqtt.port = 8883 tdl.mqtt.port = 8883
......
...@@ -3,20 +3,23 @@ ...@@ -3,20 +3,23 @@
<mapper namespace="com.example.tdl.mapper.AlarmLogMapper"> <mapper namespace="com.example.tdl.mapper.AlarmLogMapper">
<!--获取所有的报警数据--> <!--获取所有的报警数据-->
<select id="getAll" resultType="com.example.tdl.domain.vo.ResultAlarmLog"> <select id="getAll" resultType="com.example.tdl.domain.vo.ResultAlarmLog">
select transportationNo,TDLSN,description,data,alarmTime,classify from alarm_log select transportationNo,TDLSN,description,ifnull(data,"") data,alarmTime,classify from alarm_log
where transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyName =#{companyName,jdbcType=VARCHAR}))
order by alarmTime desc; order by alarmTime desc;
</select> </select>
<select id="getByTransportationNo" resultType="com.example.tdl.domain.vo.ResultAlarmLog" parameterType="String"> <select id="getByTransportationNo" resultType="com.example.tdl.domain.vo.ResultAlarmLog" parameterType="String">
select transportationNo,TDLSN,description,data,alarmTime,classify from alarm_log where transportationNo=#{transportationNo,jdbcType=VARCHAR}; select transportationNo,TDLSN,description,ifnull(data,"") data,alarmTime,classify from alarm_log
where transportationNo=#{transportationNo,jdbcType=VARCHAR}
</select> </select>
<!--根据条件获取报警数据--> <!--根据条件获取报警数据-->
<select id="getAlarmLog" parameterType="String" resultType="com.example.tdl.domain.vo.AlarmLogVo"> <select id="getAlarmLog" parameterType="String" resultType="com.example.tdl.domain.vo.AlarmLogVo">
select description,data,alarmTime select transportationNo,description,ifnull(data,"") data,alarmTime
from alarm_log from alarm_log
where DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s')) where transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyName =#{companyName,jdbcType=VARCHAR}))
order by alarmTime desc; and DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s'))
order by alarmTime desc
</select> </select>
<insert id="addAlarmLog" parameterType="com.example.tdl.entity.AlarmLog"> <insert id="addAlarmLog" parameterType="com.example.tdl.entity.AlarmLog">
...@@ -35,34 +38,42 @@ ...@@ -35,34 +38,42 @@
) )
</insert> </insert>
<select id="getCount" resultType="java.lang.Integer" parameterType="String"> <select id="getCount" parameterType="String" resultType="java.lang.Integer">
select count(DISTINCT transportationNo) from alarm_log select count(DISTINCT transportationNo) from alarm_log
where DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s')) where transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyName =#{companyName,jdbcType=VARCHAR}))
and DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s'))
</select> </select>
<select id="getBumpCount" resultType="java.lang.Integer" parameterType="String"> <select id="getBumpCount" resultType="java.lang.Integer" >
select count(DISTINCT transportationNo) from alarm_log select count(DISTINCT transportationNo) from alarm_log
where description like CONCAT(CONCAT('%',"震动"),'%') where classify = "3"
and transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyName =#{companyName,jdbcType=VARCHAR}))
and DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s')) and DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s'))
</select> </select>
<select id = "getByCount" parameterType="String" resultType="com.example.tdl.domain.vo.HistogramData" > <select id = "getByCount" parameterType="String" resultType="com.example.tdl.domain.vo.HistogramData" >
SELECT ifnull(classify,"1") classify,count(description) count FROM alarm_log WHERE classify = "1" SELECT ifnull(classify,"1") classify,count(description) count FROM alarm_log WHERE classify = "1"
and transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyName =#{companyName,jdbcType=VARCHAR}))
AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s')) AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s'))
UNION ALL UNION ALL
SELECT ifnull(classify,"2") classify,count(description) count FROM alarm_log WHERE classify = "2" SELECT ifnull(classify,"2") classify,count(description) count FROM alarm_log WHERE classify = "2"
and transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyName =#{companyName,jdbcType=VARCHAR}))
AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s')) AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s'))
UNION ALL UNION ALL
SELECT ifnull(classify,"3") classify,count(description) count FROM alarm_log WHERE classify = "3" SELECT ifnull(classify,"3") classify,count(description) count FROM alarm_log WHERE classify = "3"
and transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyName =#{companyName,jdbcType=VARCHAR}))
AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s')) AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s'))
UNION ALL UNION ALL
SELECT ifnull(classify,"4") classify,count(description) count FROM alarm_log WHERE classify = "4" SELECT ifnull(classify,"4") classify,count(description) count FROM alarm_log WHERE classify = "4"
and transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyName =#{companyName,jdbcType=VARCHAR}))
AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s')) AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s'))
UNION ALL UNION ALL
SELECT ifnull(classify,"5") classify,count(description) count FROM alarm_log WHERE classify = "5" SELECT ifnull(classify,"5") classify,count(description) count FROM alarm_log WHERE classify = "5"
and transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyName =#{companyName,jdbcType=VARCHAR}))
AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s')) AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s'))
UNION ALL UNION ALL
SELECT ifnull(classify,"6") classify,count(description) count FROM alarm_log WHERE classify = "6" SELECT ifnull(classify,"6") classify,count(description) count FROM alarm_log WHERE classify = "6"
and transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyName =#{companyName,jdbcType=VARCHAR}))
AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} 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>
...@@ -73,8 +84,10 @@ ...@@ -73,8 +84,10 @@
</select> </select>
<select id="getAlarm" parameterType="com.example.tdl.domain.vo.AlarmTermVo" resultType="com.example.tdl.domain.vo.ResultAlarmLogVo"> <select id="getAlarm" parameterType="com.example.tdl.domain.vo.AlarmTermVo" resultType="com.example.tdl.domain.vo.ResultAlarmLogVo">
select c.transportationNo,al.startCity,al.endCity,c.cargoNo,al.description,al.alarmTime from alarm_log al,circuit c select c.transportationNo,al.startCity,al.endCity,c.cargoNo,al.description,al.alarmTime
from alarm_log al,circuit c,company co
where al.transportationNo =c.transportationNo where al.transportationNo =c.transportationNo
and c.company_id = co.id
<if test="transportationNo!=null"> <if test="transportationNo!=null">
AND c.transportationNo = #{transportationNo,jdbcType=VARCHAR} AND c.transportationNo = #{transportationNo,jdbcType=VARCHAR}
</if> </if>
...@@ -94,4 +107,19 @@ ...@@ -94,4 +107,19 @@
AND c.endTime &lt;= #{endTime,jdbcType=INTEGER} AND c.endTime &lt;= #{endTime,jdbcType=INTEGER}
</if> </if>
</select> </select>
<select id="getRealTimeAlarm" parameterType="java.lang.String" resultType="com.example.tdl.domain.vo.AlarmLogVo">
select transportationNo,description,ifnull(FORMAT(data,2),"") data,alarmTime
from alarm_log
where transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyName =#{companyName,jdbcType=VARCHAR}))
and DATE_SUB(CURDATE(), INTERVAL 1 HOUR ) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s'))
order by alarmTime desc limit 3
</select>
<select id="getAlarmCount" resultType="java.lang.Integer">
select count(DISTINCT transportationNo) from alarm_log
where transportationNo in (select transportationNo from circuit where company_id = (SELECT id from company where companyName =#{companyName,jdbcType=VARCHAR}) and circuitState = 1)
</select>
</mapper> </mapper>
\ No newline at end of file
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?> <?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"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.tdl.mapper.LoginLogMapper"> <mapper namespace="com.example.tdl.mapper.LoginLogMapper">
<select id="getAll" resultType="com.example.tdl.domain.vo.ResultLoginLogVo"> <select id="getAll" parameterType="java.lang.String" resultType="com.example.tdl.domain.vo.ResultLoginLogVo">
SELECT userName,from_unixtime((createTime/1000),'%Y-%m-%d %T') createTime,inet_ntoa(ipAddress) ipAddress from login_log SELECT userName,createTime,inet_ntoa(ipAddress) ipAddress
from login_log
where userName in (select userName from user where company_id = (select id from company where companyName=#{companyName,jdbcType=VARCHAR}))
order by createTime
</select> </select>
<insert id="addLoginLog" parameterType="com.example.tdl.entity.LoginLog"> <insert id="addLoginLog" parameterType="com.example.tdl.entity.LoginLog">
...@@ -14,10 +17,11 @@ ...@@ -14,10 +17,11 @@
) )
</insert> </insert>
<select id="getByTime" resultType="com.example.tdl.domain.vo.ResultLoginLogVo" parameterType="com.example.tdl.domain.vo.LoginLogTermVo"> <select id="getByTime" resultType="com.example.tdl.domain.vo.ResultLoginLogVo" >
SELECT userName,from_unixtime((createTime/1000),'%Y-%m-%d %T') createTime,inet_ntoa(ipAddress) ipAddress SELECT userName,createTime,inet_ntoa(ipAddress) ipAddress
from login_log WHERE createTime BETWEEN #{startTime,jdbcType=BIGINT} from login_log
where userName in (select userName from user where company_id = (select id from company where companyName=#{companyName,jdbcType=VARCHAR}))
and createTime BETWEEN #{startTime,jdbcType=BIGINT}
AND #{stopTime,jdbcType=BIGINT} ORDER BY createTime DESC AND #{stopTime,jdbcType=BIGINT} ORDER BY createTime DESC
</select> </select>
</mapper> </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