Commit ff916343 authored by zhuangzhuang's avatar zhuangzhuang

3.20--修改首页获取线路信息接口,优化实时数据接口

parent 28cd574a
......@@ -203,9 +203,9 @@ public class RedisConfig extends CachingConfigurerSupport{
* @return
*/
@Bean
public RedisTemplate<String, String> redisTemplate() {
public RedisTemplate<String, String> infoRedisTemplate() {
StringRedisTemplate template = new StringRedisTemplate(redisConnectionFactory(0));
JsonRedisSerializer(template, true);
JsonRedisSerializer(template, false);
return template;
}
......
package com.example.tdl.domain.vo;
public class CircuitVo {
private String transportationNo;
private String routeName;
private String startLongitude;
private String startLatitude;
private String startCity;
private String startTime;
private String endLongitude;
private String endLatitude;
private String endCity;
private String endTime;
private String transport;
private String boxNo;
private String containerNo;
private String deliveryAddress;
private String transportationType;
private int circuitState;
private String remark;
public String getTransportationNo() {
return transportationNo;
}
public void setTransportationNo(String transportationNo) {
this.transportationNo = transportationNo;
}
public String getRouteName() {
return routeName;
}
public void setRouteName(String routeName) {
this.routeName = routeName;
}
public String getStartLongitude() {
return startLongitude;
}
public void setStartLongitude(String startLongitude) {
this.startLongitude = startLongitude;
}
public String getStartLatitude() {
return startLatitude;
}
public void setStartLatitude(String startLatitude) {
this.startLatitude = startLatitude;
}
public String getStartCity() {
return startCity;
}
public void setStartCity(String startCity) {
this.startCity = startCity;
}
public String getStartTime() {
return startTime;
}
public void setStartTime(String startTime) {
this.startTime = startTime;
}
public String getEndLongitude() {
return endLongitude;
}
public void setEndLongitude(String endLongitude) {
this.endLongitude = endLongitude;
}
public String getEndLatitude() {
return endLatitude;
}
public void setEndLatitude(String endLatitude) {
this.endLatitude = endLatitude;
}
public String getEndCity() {
return endCity;
}
public void setEndCity(String endCity) {
this.endCity = endCity;
}
public String getEndTime() {
return endTime;
}
public void setEndTime(String endTime) {
this.endTime = endTime;
}
public String getTransport() {
return transport;
}
public void setTransport(String transport) {
this.transport = transport;
}
public String getBoxNo() {
return boxNo;
}
public void setBoxNo(String boxNo) {
this.boxNo = boxNo;
}
public String getContainerNo() {
return containerNo;
}
public void setContainerNo(String containerNo) {
this.containerNo = containerNo;
}
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 int getCircuitState() {
return circuitState;
}
public void setCircuitState(int circuitState) {
this.circuitState = circuitState;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
}
......@@ -12,7 +12,7 @@ public class HomePageDataVo {
private Integer alarmed;//报警线路
private List<ResultRouteVo> routeVoList;//线路列表
private List<CircuitVo> routeVoList;//线路列表
//报警列表
private List<AlarmLogVo> alarmLogVoList;
......@@ -51,11 +51,11 @@ public class HomePageDataVo {
this.alarmed = alarmed;
}
public List<ResultRouteVo> getRouteVoList() {
public List<CircuitVo> getRouteVoList() {
return routeVoList;
}
public void setRouteVoList(List<ResultRouteVo> routeVoList) {
public void setRouteVoList(List<CircuitVo> routeVoList) {
this.routeVoList = routeVoList;
}
......
package com.example.tdl.domain.vo;
public class ResultCircuit {
private String transportationNo;
private String startCity;
private String startTime;
private String endCity;
private String endTime;
private String gatewaySN;
private String battery;
private String TDLSN;
private String BatteryVoltage;
private String lastTime;
private int circuitState;
private String remark;
public String getTransportationNo() {
return transportationNo;
}
public void setTransportationNo(String transportationNo) {
this.transportationNo = transportationNo;
}
public String getStartCity() {
return startCity;
}
public void setStartCity(String startCity) {
this.startCity = startCity;
}
public String getStartTime() {
return startTime;
}
public void setStartTime(String startTime) {
this.startTime = startTime;
}
public String getEndCity() {
return endCity;
}
public void setEndCity(String endCity) {
this.endCity = endCity;
}
public String getEndTime() {
return endTime;
}
public void setEndTime(String endTime) {
this.endTime = endTime;
}
public String getGatewaySN() {
return gatewaySN;
}
public void setGatewaySN(String gatewaySN) {
this.gatewaySN = gatewaySN;
}
public String getBattery() {
return battery;
}
public void setBattery(String battery) {
this.battery = battery;
}
public String getTDLSN() {
return TDLSN;
}
public void setTDLSN(String TDLSN) {
this.TDLSN = TDLSN;
}
public String getBatteryVoltage() {
return BatteryVoltage;
}
public void setBatteryVoltage(String batteryVoltage) {
BatteryVoltage = batteryVoltage;
}
public String getLastTime() {
return lastTime;
}
public void setLastTime(String lastTime) {
this.lastTime = lastTime;
}
public int getCircuitState() {
return circuitState;
}
public void setCircuitState(int circuitState) {
this.circuitState = circuitState;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
}
......@@ -18,4 +18,6 @@ public interface AlarmLogMapper {
int addAlarmLog(AddAlarmLogVo addAlarmLogVo);
List<AlarmLogVo> getByTransportationNo(String transportationNo);
Integer getCount();
}
......@@ -10,6 +10,8 @@ import java.util.Map;
public interface CircuitMapper {
List<ResultCircuitVo> getAll();
List<CircuitVo> getDistinct();
List<ResultCircuitVo> getByTerm(CircuitTermVo circuitTermVo);
int addCircuit(Map<Object,Object> map);
......@@ -23,4 +25,12 @@ public interface CircuitMapper {
ResultCircuitVo getByTransportationNo(String transportation);
ResultGatewayVo getByNo(String transportationNo);
Integer getOnRoute();
Integer getComplted();
Integer getCount();
List<CircuitVo> getByTime(String time);
}
......@@ -30,5 +30,9 @@ public class AlarmLogService {
return alarmLogMapper.getByTransportationNo(transportationNo);
}
public Integer getCount(){
return alarmLogMapper.getCount();
}
}
......@@ -19,6 +19,10 @@ public class CircuitService {
return circuitMapper.getAll();
}
public List<CircuitVo> getDistinct(){
return circuitMapper.getDistinct();
}
public List<ResultCircuitVo> getByTerm(CircuitTermVo circuitTermVo){
return circuitMapper.getByTerm(circuitTermVo);
}
......@@ -47,4 +51,21 @@ public class CircuitService {
return circuitMapper.getByNo(transportationNo);
}
public Integer getOnRoute(){
return circuitMapper.getOnRoute();
}
public Integer getComplted(){
return circuitMapper.getComplted();
}
public Integer getCount(){
return circuitMapper.getCount();
}
public List<CircuitVo> getByTime(String time){
return circuitMapper.getByTime(time);
}
}
......@@ -5,6 +5,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.data.redis.core.HashOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.io.Serializable;
......@@ -12,6 +13,7 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
@Service
public class RedisService {
final static Logger logger = LoggerFactory.getLogger(RedisService.class);
......@@ -76,11 +78,13 @@ public class RedisService {
}
public Object getHashKeys(String key) {
Object result = null;
String ret="{error}";
Object result = ret;
try {
HashOperations<Serializable, Object, Object> hash = redisTemplate.opsForHash();
HashOperations<String, Object, Object> hash= redisTemplate.opsForHash();
//HashOperations<Serializable, Object, Object> hash = redisTemplate.opsForHash();
result = hash.keys(key);
} catch (Exception e) {
}catch (Exception e){
e.printStackTrace();
logger.error("redis获取hash 所有key发生错误", this);
}
......
package com.example.tdl.web;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.example.tdl.domain.dto.CommFeedback;
import com.example.tdl.domain.vo.*;
import com.example.tdl.service.*;
import com.example.tdl.service.redis.RealRedisService;
import com.example.tdl.service.redis.RedisService;
import com.google.gson.Gson;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.influxdb.dto.Query;
import org.influxdb.dto.QueryResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
......@@ -53,7 +59,7 @@ public class DataController {
@Autowired
private CircuitService circuitService;
private String database ="original";
private final static String database ="original";
//获取实时数据
@ApiOperation(value = "获取实时数据",notes = "获取实时数据")
......@@ -62,12 +68,17 @@ public class DataController {
})
@PostMapping("/getRealTimeData")
public Object getRealTimeData(@RequestBody String transportationNo){
JSONObject jsonObject= JSON.parseObject(transportationNo);
transportationNo=jsonObject.getString("transportationNo");
//获取gateway的信息
ResultGatewayVo gatewayVo = circuitService.getByNo(transportationNo);
if(gatewayVo==null){
fb.setCode(0);
fb.setMessage("该线路未绑定设备");
return gson.toJson(fb);
}
//获取tdl信息
List<String> devList = tdlDeviceService.getByGatewaySN(gatewayVo.getSN(),gatewayVo.getType());
// String gSN = "20180314";
// String gType = "WTD93LG";
//根据gateWay获取tdl信息
List<String> key = new ArrayList<>();
key.add(gatewayVo.getSN()+"_"+gatewayVo.getType() +":"+gatewayVo.getSN()+"_"+gatewayVo.getType());
......@@ -102,6 +113,7 @@ public class DataController {
return gson.toJson(liveDataVos);
}
//获取坐标数据数据
@ApiOperation(value = "获取坐标数据数据",notes = "获取坐标数据数据" +
"time:时间" +
......@@ -112,11 +124,18 @@ public class DataController {
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
public Object getLocation(@RequestBody String transportationNo){
JSONObject jsonObject= JSON.parseObject(transportationNo);
transportationNo=jsonObject.getString("transportationNo");
//获取gateway的信息
ResultGatewayVo gatewayVo = circuitService.getByNo(transportationNo);
if(gatewayVo==null){
fb.setCode(0);
fb.setMessage("该线路未绑定设备");
return gson.toJson(fb);
}
String device = gatewayVo.getType() +"_" +gatewayVo.getSN();
//获取tdl信息
// List<String> devList = tdlDeviceService.getByGatewaySN(gatewayVo.getSN(),gatewayVo.getType());
// List<String> devList = tdlDeviceService.getByGatewaySN(gatewayVo.getSN(),gatewayVo.getType());
String sql = "SELECT \"lng\",\"lat\" FROM \"tdl_policy\".\""+device+"\"ORDER BY time ";
QueryResult queryResult = influxDBTemplate.query(new Query(sql,database));
//解析经纬度数据
......@@ -127,27 +146,72 @@ public class DataController {
return gson.toJson(locationDataVos);
}
//根据运输编号获取路线以及设备信息
@PostMapping("/getCircuit")
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
public Object getCircuit(@RequestBody String transportationNo){
JSONObject jsonObject= JSON.parseObject(transportationNo);
transportationNo=jsonObject.getString("transportationNo");
ResultCircuit resultCircuit = new ResultCircuit();
resultCircuit.setTransportationNo(transportationNo);
//根据运输编号获取线路信息,设备信息
ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(transportationNo);
resultCircuit.setStartCity(resultCircuitVo.getStartCity());
resultCircuit.setStartTime(resultCircuitVo.getStartTime());
resultCircuit.setEndCity(resultCircuitVo.getEndCity());
if(StringUtils.isEmpty(resultCircuitVo.getEndTime())){
resultCircuit.setEndTime("");
resultCircuit.setLastTime("");
}else{
resultCircuit.setEndTime(resultCircuitVo.getEndTime());
//int i = differentDaysByMillisecond(Long.valueOf(resultCircuitVo.getStartTime()),Long.valueOf(resultCircuitVo.getEndTime())) +1;
resultCircuit.setLastTime(3+"days");
}
//获取gateway的信息
ResultGatewayVo gatewayVo = circuitService.getByNo(transportationNo);
if(gatewayVo==null){
fb.setCode(0);
fb.setMessage("该线路未绑定设备");
return gson.toJson(fb);
}
resultCircuit.setGatewaySN(gatewayVo.getSN());
String device = gatewayVo.getType() +"_" +gatewayVo.getSN();
String sql = "SELECT \"battery\" FROM \"tdl_policy\".\""+device+"\" ORDER BY time desc limit 1";
QueryResult queryResult = influxDBTemplate.query(new Query(sql,database));
if(queryResult.getResults().get(0).getSeries() != null){
List<List<Object>> values = getValues(queryResult);
for(List<Object> value:values){
logger.info(value.get(1).toString());
resultCircuit.setBattery(value.get(1)==null ? "": value.get(1).toString());
}
}
//获取tdl信息
// List<String> devList = tdlDeviceService.getByGatewaySN(gatewayVo.getSN(),gatewayVo.getType());
List<String> devList = tdlDeviceService.getByGatewaySN(gatewayVo.getSN(),gatewayVo.getType());
String key=gatewayVo.getSN()+"_"+gatewayVo.getType() +":"+gatewayVo.getSN()+"_"+gatewayVo.getType() ;
//获取网关以及TDL的电量
return gson.toJson(fb);
if(devList.size() == 0 ){
fb.setCode(0);
fb.setMessage("该线路未绑定设备");
return gson.toJson(fb);
}
for(int i = 0;i<devList.size();i++){
String sql2 = "SELECT \"b\" FROM \"tdl_policy\".\""+device+"\" where \"tdl\"=\'tdl-"+devList.get(i)+"\' ORDER BY time desc limit 1";
QueryResult queryResult2 = influxDBTemplate.query(new Query(sql2,database));
if(queryResult2.getResults().get(0).getSeries() != null){
List<List<Object>> values = getValues(queryResult2);
for(List<Object> value:values){
resultCircuit.setTDLSN(devList.get(i));
resultCircuit.setBatteryVoltage(value.get(1)==null ? "" :value.get(1).toString());
}
}
}
return gson.toJson(resultCircuit);
}
//获取温度数据
@ApiOperation(value = "获取温度数据",notes = "获取温度数据")
@PostMapping("/getTemperature")
......@@ -155,6 +219,8 @@ public class DataController {
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
public Object getTemperature(@RequestBody String transportationNo){
JSONObject jsonObject= JSON.parseObject(transportationNo);
transportationNo=jsonObject.getString("transportationNo");
ResultGatewayVo gatewayVo = circuitService.getByNo(transportationNo);
String device = gatewayVo.getType() +"_" +gatewayVo.getSN();
//获取tdl信息
......@@ -198,6 +264,8 @@ public class DataController {
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
public Object getHumidity(@RequestBody String transportationNo){
JSONObject jsonObject= JSON.parseObject(transportationNo);
transportationNo=jsonObject.getString("transportationNo");
ResultGatewayVo gatewayVo = circuitService.getByNo(transportationNo);
String device = gatewayVo.getType() +"_" +gatewayVo.getSN();
//获取tdl信息
......@@ -240,6 +308,8 @@ public class DataController {
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
public Object getTiltAngle(@RequestBody String transportationNo){
JSONObject jsonObject= JSON.parseObject(transportationNo);
transportationNo=jsonObject.getString("transportationNo");
ResultGatewayVo gatewayVo = circuitService.getByNo(transportationNo);
String device = gatewayVo.getType() +"_" +gatewayVo.getSN();
//获取tdl信息
......@@ -281,6 +351,8 @@ public class DataController {
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
public Object getShockEnergy(@RequestBody String transportationNo){
JSONObject jsonObject= JSON.parseObject(transportationNo);
transportationNo=jsonObject.getString("transportationNo");
ResultGatewayVo gatewayVo = circuitService.getByNo(transportationNo);
String device = gatewayVo.getType() +"_" +gatewayVo.getSN();
//获取tdl信息
......@@ -324,6 +396,8 @@ public class DataController {
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
public Object getAlarmData(@RequestBody String transportationNo){
JSONObject jsonObject= JSON.parseObject(transportationNo);
transportationNo=jsonObject.getString("transportationNo");
//根据运输编号获取报警信息
List<AlarmLogVo> alarmLogVoList = alarmLogService.getByTransportationNo(transportationNo);
......@@ -364,8 +438,8 @@ public class DataController {
messageVo.setAlarmTime(Long.valueOf(parseTime(value.get(0).toString())));
messageVo.setAlarmType(locationVo.getAlarmType());
messageVo.setAlarmValue(locationVo.getVlaue());
messageVo.setLng(value.get(1)==null ? value.get(1).toString() : "");
messageVo.setLat(value.get(2)==null ? value.get(2).toString() : "");
messageVo.setLng(value.get(1)==null ? "": value.get(1).toString());
messageVo.setLat(value.get(2)==null ? "" :value.get(2).toString());
locationDataVos.add(messageVo);
}
}
......@@ -379,6 +453,8 @@ public class DataController {
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
public Object getDeviceData(@RequestBody String transportationNo){
JSONObject jsonObject= JSON.parseObject(transportationNo);
transportationNo=jsonObject.getString("transportationNo");
//获取网关以及tdl信息
ResultGatewayVo gatewayVo = circuitService.getByNo(transportationNo);
String device = gatewayVo.getType() +"_" +gatewayVo.getSN();
......@@ -514,4 +590,13 @@ public class DataController {
}
return dateResult;
}
//判断两个时间相差多少
public static int differentDaysByMillisecond(Long date1,Long date2){
int days = (int) ((date2-date1) / (1000*3600*24)) ;
return days;
}
}
\ No newline at end of file
package com.example.tdl.web;
import com.example.tdl.domain.dto.CommFeedback;
import com.example.tdl.domain.vo.AlarmLogVo;
import com.example.tdl.domain.vo.HomePageDataVo;
import com.example.tdl.domain.vo.ResultRouteVo;
import com.example.tdl.domain.vo.TermVo;
import com.example.tdl.domain.vo.*;
import com.example.tdl.service.AlarmLogService;
import com.example.tdl.service.CircuitService;
import com.example.tdl.service.RouteService;
import com.google.gson.Gson;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -28,7 +27,7 @@ public class HomePageController {
CommFeedback fb = new CommFeedback();
@Autowired
private RouteService routeService;
private CircuitService circuitService;
@Autowired
private AlarmLogService alarmLogServcie;
......@@ -40,23 +39,22 @@ public class HomePageController {
"complted:已完成数量" +
"alarmed: 报警数量" +
"routeVoList: " +
"routeNumber:路由编号(R+TyyyyMMdd+运输方式+四位随机数)"+
"transportationNo:线路编号(R+TyyyyMMdd+运输方式+四位随机数)"+
"routeName:路由名称(出发地-启运地)"+
"abbreviation:名称缩写(出发地-启运地-运输方式)"+
"startLongitude:启运经度"+
"startLatitude:启运纬度"+
"startCounrty:启运国"+
"startProvince:启运省"+
"startCity:启运市"+
"startAddress:启运地址"+
"startTime:开始时间"+
"endLongitude:目的经度"+
"endLatitude:目的纬度"+
"endCounrty:目的国"+
"endProvince:目的省"+
"endCity:目的市"+
"endAddress:目的地址"+
"endTime:结束时间"+
"transport:运输方式(T铁路,G汽运,H海运,K空运,D快递)"+
"transportRemark:运输方式备注"+
"boxNo:箱单号" +
"containerNo:集装箱号/车牌号" +
"deliveryAddress:交付地点" +
"transportationType:运输类型" +
"circuitState:线路状态"+
"remark:备注" +
"alarmLogVoList :"+
"routeName:线路名称"+
......@@ -69,38 +67,50 @@ public class HomePageController {
})
public Object getAll(){
HomePageDataVo dataVo = new HomePageDataVo();
//获取所有的路线
// List<ResultRouteVo> routeVos = routeService.getAll();//所有的路线
//List<ResultRouteVo> routeVoList = routeService.getAllRoute();//当天的数量
//获取所有的线路信息
List<CircuitVo> resultCircuitVos = circuitService.getDistinct();
//获取所有的报警
List<AlarmLogVo> alarmLogVos = alarmLogServcie.getAll();
// 获取所有的路线数量
// dataVo.setRouteVoList(routeVos);//路线列表
dataVo.setRouteVoList(resultCircuitVos);//路线列表
dataVo.setAlarmLogVoList(alarmLogVos);//报警列表
// dataVo.setSum(routeVos.size());//总数量
dataVo.setOnRoute(0);//在途数量
dataVo.setComplted(0);//已完成数量
dataVo.setAlarmed(0);//报警数量
Integer sum = circuitService.getCount();
dataVo.setSum(sum);//总数量
Integer onRoute = circuitService.getOnRoute();
dataVo.setOnRoute(onRoute);//在途数量
//获取已经完成的数量
Integer finished = circuitService.getComplted();
dataVo.setComplted(finished);//已完成数量
Integer alarmed = alarmLogServcie.getCount();
dataVo.setAlarmed(alarmed);//报警数量
return gson.toJson(dataVo);
}
//根据条件获取路线数据(所有的)
@ApiOperation(value = "根据条件获取运输数据",notes = "传值:" +
"time:时间(1,3,7,30...)" +
"evaluation:评价" )
@PostMapping("/getByTerm")
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
public Object getByTerm(@RequestBody TermVo termVo){
HomePageDataVo dataVo = new HomePageDataVo();
List<ResultRouteVo> routeVos = routeService.getAll();//所有的路线
// List<ResultRouteVo> routeVoList = routeService.getAllRoute(termVo.getTime());//根据条件获取数据
List<CircuitVo> resultCircuitVoList = circuitService.getByTime(termVo.getTime());//所有的路线
List<AlarmLogVo> alarmLogVos = alarmLogServcie.getAlarmLog(termVo.getTime());
dataVo.setRouteVoList(routeVos);//路线列表
dataVo.setRouteVoList(resultCircuitVoList);//路线列表
dataVo.setAlarmLogVoList(alarmLogVos);//报警列表
dataVo.setSum(routeVos.size());//总数量
dataVo.setOnRoute(0);//在途数量
dataVo.setComplted(0);//已完成数量
dataVo.setAlarmed(0);//报警数量
Integer sum = circuitService.getCount();
dataVo.setSum(sum);//总数量
//获取已经完成的数量
Integer onRoute = circuitService.getOnRoute();
dataVo.setOnRoute(onRoute);//在途数量
//获取已经完成的数量
Integer finished = circuitService.getComplted();
dataVo.setComplted(finished);//已完成数量
Integer alarmed = alarmLogServcie.getCount();
dataVo.setAlarmed(alarmed);//报警数量
return gson.toJson(dataVo);
}
......
spring.datasource.url=jdbc:mysql://HostTest-mysql:3306/cy?useUnicode=true&characterEncoding=utf-8&useSSL=false
spring.datasource.username=root
spring.datasource.password=37774020
spring.datasource.url=jdbc:mysql://housetest-mysql:3306/tdlCloud?useUnicode=true&characterEncoding=utf-8&useSSL=false
# Redisַ
spring.redis.host=HostTest-redis
spring.redis.port=6379
tdl.redis.host=housetest-redis
tdl.influxdb.host=http://HostTest-influxdb:8086
# InfluxDB
spring.influxdb.url=http://housetest-influxdb:8086
# Logging
logging.config=classpath:logback.xml
......@@ -25,4 +25,9 @@
#{alarmTime,jdbcType=INTEGER}
)
</insert>
<select id="getCount" resultType="java.lang.Integer">
select count(DISTINCT transportationNo) from alarm_log
</select>
</mapper>
\ No newline at end of file
......@@ -8,6 +8,19 @@
from circuit c,route r WHERE c.route_id=r.id AND r.state=1 AND c.state=1 order BY c.id DESC
</select>
<select id="getDistinct" resultType="com.example.tdl.domain.vo.CircuitVo">
SELECT transportationNo,routeName,startLongitude,startLatitude,(select city from city_config where id=r.start_id) startCity,startTime,endLongitude,endLatitude,
(select city from city_config where id=r.end_id) endCity,endTime,transport,boxNo,containerNo,deliveryAddress,
transportationType,circuitState,c.remark ,SUBSTRING_INDEX(routeName,'_',2) routes
from circuit c,route r
WHERE c.route_id=r.id
AND r.state=1
AND c.state=1
GROUP BY routes
order BY c.id
</select>
<select id="getByTerm" resultType="com.example.tdl.domain.vo.ResultCircuitVo" parameterType="com.example.tdl.domain.vo.CircuitTermVo">
SELECT transportationNo,routeNumber,routeName,startLongitude,startLatitude,(select city from city_config where id=r.start_id) startCity,
startAddress,startTime,endLongitude,endLatitude,(select city from city_config where id=r.end_id) endCity,endAddress,endTime,transport,
......@@ -137,4 +150,29 @@
SELECT SN,`name`,type,state,bConfig,useScene,from_unixtime((createTime/1000),'%Y-%m-%d %T') createTime,from_unixtime((updateTime/1000),'%Y-%m-%d %T') updateTime
from gateway WHERE id=(SELECT gateway_id from tdldevice where circuit_id =(SELECT id from circuit WHERE transportationNo=#{transportationNo,jdbcType=VARCHAR}))
</select>
<select id="getOnRoute" resultType="java.lang.Integer">
select count( startTime) from circuit where circuitState=1
</select>
<select id="getComplted" resultType="java.lang.Integer">
select count(id) from circuit where circuitState=2
</select>
<select id="getCount" resultType="java.lang.Integer">
select count(id) from circuit
</select>
<select id="getByTime" resultType="com.example.tdl.domain.vo.CircuitVo">
SELECT transportationNo,routeName,startLongitude,startLatitude,(select city from city_config where id=r.start_id) startCity,startTime,endLongitude,endLatitude,
(select city from city_config where id=r.end_id) endCity,endTime,transport,boxNo,containerNo,deliveryAddress,
transportationType,circuitState,c.remark ,SUBSTRING_INDEX(routeName,'_',2) routes
from circuit c,route r
WHERE c.route_id=r.id
AND r.state=1
AND c.state=1
AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(createTime/1000,'%Y-%m-%d %H:%i:%s'))
GROUP BY routes
order BY c.id
</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