Commit 167c4c1b authored by chenying's avatar chenying

4.2修改线路和数据的接口,根据公司名查询数据

parent b8d0e060
package com.example.tdl.domain.vo; package com.example.tdl.domain.vo;
public class CircuitTermVo { public class CircuitTermVo {
private String companyName;
private String cargoNo; private String cargoNo;
private Integer circuitState; private Integer circuitState;
...@@ -9,6 +11,14 @@ public class CircuitTermVo { ...@@ -9,6 +11,14 @@ public class CircuitTermVo {
private Long endTime; private Long endTime;
public String getCompanyName() {
return companyName;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
public String getCargoNo() { public String getCargoNo() {
return cargoNo; return cargoNo;
} }
......
package com.example.tdl.domain.vo;
public class ResultCircuitForAppVo {
private String transportationNo;
private String city;
private Long startTime;
private String cargoNo;
private String plateNo;
private String deliveryAddress;
private String transportation;
private String transportationType;
private String remark;
public Long getStartTime() {
return startTime;
}
public void setStartTime(Long startTime) {
this.startTime = startTime;
}
public String getTransportationNo() {
return transportationNo;
}
public void setTransportationNo(String transportationNo) {
this.transportationNo = transportationNo;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
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 getDeliveryAddress() {
return deliveryAddress;
}
public void setDeliveryAddress(String deliveryAddress) {
this.deliveryAddress = deliveryAddress;
}
public String getTransportation() {
return transportation;
}
public void setTransportation(String transportation) {
this.transportation = transportation;
}
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;
}
}
...@@ -9,12 +9,10 @@ import java.util.Map; ...@@ -9,12 +9,10 @@ import java.util.Map;
@Mapper @Mapper
public interface CircuitMapper { public interface CircuitMapper {
List<ResultCircuitVo> getAll(); List<ResultCircuitVo> getAll(String companyName);
List<ResultCircuitVo> getByTerm(CircuitTermVo circuitTermVo); List<ResultCircuitVo> getByTerm(CircuitTermVo circuitTermVo);
// List<CircuitVo> getDistinct();
int addCircuit(Map<Object,Object> map); int addCircuit(Map<Object,Object> map);
int add(Map<Object,Object> map); int add(Map<Object,Object> map);
...@@ -25,25 +23,30 @@ public interface CircuitMapper { ...@@ -25,25 +23,30 @@ public interface CircuitMapper {
int delCircuit(String transportationNo); int delCircuit(String transportationNo);
ResultCircuitVo getByTransportationNo(String transportation); ResultCircuitVo getByTransportationNo(@Param("transportationNo") String transportationNo,@Param("companyName") String companyName);
Integer getOnRoute(String time); Integer getOnRoute(@Param("time") String time,@Param("companyName") String companyName);
Integer getDelayCount(@Param("compTime") Long compTime, @Param("time") String time); Integer getDelayCount(@Param("compTime") Long compTime, @Param("time") String time,@Param("companyName") String companyName);
Integer getComplted(String time); Integer getCount(@Param("time") String time,@Param("companyName") String companyName);
Integer getCount(String time); List<ResultCircuitVo> getByContainerNo(@Param("cargoNo") String cargoNo,@Param("companyName") String companyName);
List<ResultCircuitVo> getByTime(String time); ResultCircuitForAppVo getByTransportationNoForApp(@Param("transportationNo") String transportationNo,@Param("companyName") String companyName);
List<ResultCircuitVo> getByContainerNo(String cargoNo); List<ResultCircuitVo> getByCircuitState(@Param("circuitState") Integer circuitState,@Param("companyName") String companyName);
int updateEvaluate(UpdateEvaluateVo updateEvaluateVo); int updateEvaluate(UpdateEvaluateVo updateEvaluateVo);
List<ResultCircuitVo> getByCircuitState(Integer circuitState);
Integer getNo(String transportationNo); Integer getNo(String transportationNo);
ResultGatewayVo getByNo(String transportationNo); ResultGatewayVo getByNo(String transportationNo);
List<ResultCircuitVo> getByTime(@Param("time") String time,@Param("companyName") String companyName);
// Integer getComplted(@Param("time") String time);
// List<CircuitVo> getDistinct();
} }
...@@ -14,8 +14,8 @@ public class CircuitService { ...@@ -14,8 +14,8 @@ public class CircuitService {
@Autowired @Autowired
private CircuitMapper circuitMapper; private CircuitMapper circuitMapper;
public List<ResultCircuitVo> getAll(){ public List<ResultCircuitVo> getAll(String companyName){
return circuitMapper.getAll(); return circuitMapper.getAll(companyName);
} }
public List<ResultCircuitVo> getByTerm(CircuitTermVo circuitTermVo){ public List<ResultCircuitVo> getByTerm(CircuitTermVo circuitTermVo){
...@@ -43,43 +43,38 @@ public class CircuitService { ...@@ -43,43 +43,38 @@ public class CircuitService {
return circuitMapper.delCircuit(transportationNo); return circuitMapper.delCircuit(transportationNo);
} }
public ResultCircuitVo getByTransportationNo(String transportationNo){ public ResultCircuitVo getByTransportationNo(String transportationNo,String companyName){
return circuitMapper.getByTransportationNo(transportationNo); return circuitMapper.getByTransportationNo(transportationNo,companyName);
} }
public Integer getOnRoute(String time){ public ResultCircuitForAppVo getByTransportationNoForApp(String transportationNo,String companyName){
return circuitMapper.getOnRoute(time); return circuitMapper.getByTransportationNoForApp(transportationNo,companyName);
} }
public Integer getDelayCount(Long compTime,String time){ public Integer getOnRoute(String time,String comapnyName){
return circuitMapper.getDelayCount(compTime,time); return circuitMapper.getOnRoute(time,comapnyName);
} }
public Integer getComplted(String time){ public Integer getDelayCount(Long compTime,String time,String companyName){
return circuitMapper.getComplted(time); return circuitMapper.getDelayCount(compTime,time,companyName);
} }
public Integer getCount(String time,String companyName){
public Integer getCount(String time){ return circuitMapper.getCount(time,companyName);
return circuitMapper.getCount(time);
} }
public List<ResultCircuitVo> getByTime(String time){ public List<ResultCircuitVo> getByContainerNo(String cargoNo,String companyName){
return circuitMapper.getByTime(time); return circuitMapper.getByContainerNo(cargoNo,companyName);
} }
public List<ResultCircuitVo> getByContainerNo(String cargoNo){ public List<ResultCircuitVo> getByCircuitState(Integer circuitState,String companyName){
return circuitMapper.getByContainerNo(cargoNo); return circuitMapper.getByCircuitState(circuitState,companyName);
} }
public int updateEvaluate(UpdateEvaluateVo updateEvaluateVo){ public int updateEvaluate(UpdateEvaluateVo updateEvaluateVo){
return circuitMapper.updateEvaluate(updateEvaluateVo); return circuitMapper.updateEvaluate(updateEvaluateVo);
} }
public List<ResultCircuitVo> getByCircuitState(Integer circuitState){
return circuitMapper.getByCircuitState(circuitState);
}
public Integer getNo(String transportationNo){ public Integer getNo(String transportationNo){
return circuitMapper.getNo(transportationNo); return circuitMapper.getNo(transportationNo);
} }
...@@ -88,8 +83,17 @@ public class CircuitService { ...@@ -88,8 +83,17 @@ public class CircuitService {
return circuitMapper.getByNo(transportationNo); return circuitMapper.getByNo(transportationNo);
} }
// public List<CircuitVo> getDistinct(){ public List<ResultCircuitVo> getByTime(String time,String companyName){
return circuitMapper.getByTime(time,companyName);
}
// public List<CircuitVo> getDistinct(){
// return circuitMapper.getDistinct(); // return circuitMapper.getDistinct();
// } // }
// public Integer getComplted(String time){
// return circuitMapper.getComplted(time);
// }
} }
...@@ -7,6 +7,7 @@ import com.example.tdl.domain.vo.*; ...@@ -7,6 +7,7 @@ import com.example.tdl.domain.vo.*;
import com.example.tdl.service.CircuitService; import com.example.tdl.service.CircuitService;
import com.example.tdl.service.TDLDeviceService; import com.example.tdl.service.TDLDeviceService;
import com.example.tdl.service.redis.RealRedisService; import com.example.tdl.service.redis.RealRedisService;
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;
...@@ -17,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -17,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.influxdb.InfluxDBTemplate; import org.springframework.data.influxdb.InfluxDBTemplate;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
...@@ -37,6 +39,9 @@ public class AlarmDataController { ...@@ -37,6 +39,9 @@ public class AlarmDataController {
@Autowired @Autowired
private RealRedisService realRedisService; private RealRedisService realRedisService;
@Autowired
private TokenRedisService tokenRedisService;
private final static String database ="original"; private final static String database ="original";
@ApiImplicitParams({ @ApiImplicitParams({
...@@ -134,7 +139,10 @@ public class AlarmDataController { ...@@ -134,7 +139,10 @@ public class AlarmDataController {
@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="/getAlarmCircuit",method = RequestMethod.POST) @RequestMapping(value="/getAlarmCircuit",method = RequestMethod.POST)
public Object getAlarmCircuit(@RequestBody String transportationNo){ public Object getAlarmCircuit(@RequestBody String transportationNo, HttpServletRequest request){
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
// String transportationNo="CHN20180323G1111"; // String transportationNo="CHN20180323G1111";
JSONObject jsonObject= JSON.parseObject(transportationNo); JSONObject jsonObject= JSON.parseObject(transportationNo);
transportationNo=(String)jsonObject.get("transportationNo"); transportationNo=(String)jsonObject.get("transportationNo");
...@@ -144,7 +152,7 @@ public class AlarmDataController { ...@@ -144,7 +152,7 @@ public class AlarmDataController {
fb.setMessage("该线路没有绑定网关"); fb.setMessage("该线路没有绑定网关");
return gson.toJson(fb); return gson.toJson(fb);
} }
Integer circuitState=circuitService.getByTransportationNo(transportationNo).getCircuitState(); Integer circuitState=circuitService.getByTransportationNo(transportationNo,user.getCompanyName()).getCircuitState();
String device = resultGatewayVo.getType() +"_" +resultGatewayVo.getSN(); String device = resultGatewayVo.getType() +"_" +resultGatewayVo.getSN();
if(circuitState==0){ if(circuitState==0){
return null; return null;
......
...@@ -18,6 +18,7 @@ import org.slf4j.LoggerFactory; ...@@ -18,6 +18,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.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
...@@ -49,6 +50,8 @@ public class CircuitController { ...@@ -49,6 +50,8 @@ public class CircuitController {
@Autowired @Autowired
private AlarmRedisService alarmRedisService; private AlarmRedisService alarmRedisService;
@Autowired
private TokenRedisService tokenRedisService;
@Autowired @Autowired
private AlarmService alarmService; private AlarmService alarmService;
...@@ -60,8 +63,8 @@ public class CircuitController { ...@@ -60,8 +63,8 @@ public class CircuitController {
add("ta"); add("ta");
}}; }};
//获取线路信息 //获取本公司的线路信息
@ApiOperation(value = "获取线路信息",notes = "获取线路信息,返回值说明:" + @ApiOperation(value = "获取本公司的线路信息",notes = "获取本公司的线路信息,返回值说明:" +
" transportationNo:运输编号," + " transportationNo:运输编号," +
" cargoNo:货物编号" + " cargoNo:货物编号" +
" startCity:起运城市," + " startCity:起运城市," +
...@@ -73,17 +76,67 @@ public class CircuitController { ...@@ -73,17 +76,67 @@ public class CircuitController {
" alarm:报警详情(比如:温度,湿度,震动)" + " alarm:报警详情(比如:温度,湿度,震动)" +
" evaluate:运输评价") " evaluate:运输评价")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"), @ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
}) })
@RequestMapping(value="/getAll",method = RequestMethod.GET) @RequestMapping(value="/getAll",method = RequestMethod.GET)
public Object getAll(){ public Object getAll(HttpServletRequest request){
return circuitService.getAll(); String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
return circuitService.getAll(user.getCompanyName());
} }
//根据运输编号查询本公司的运输信息(web端)
@ApiOperation(value = "根据运输编号查询本公司的运输信息(web端)",notes = "根据运输编号查询本公司的运输信息(web端),返回值说明:" +
" transportationNo:运输编号," +
" cargoNo:货物编号" +
" startCity:起运城市," +
" startTime:起运时间," +
" endCity:目的城市," +
" endTime:目的时间," +
" circuitState:线路状态(0未开始,1运输中,2完成)," +
" alarmType:预警类型," +
" alarm:报警详情(比如:温度,湿度,震动)" +
" evaluate:运输评价")
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
@RequestMapping(value="/getByTransportationNo",method = RequestMethod.POST)
public Object getByTransportationNo(@RequestBody String transportationNo, HttpServletRequest request){
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
JSONObject jsonObject=JSON.parseObject(transportationNo);
transportationNo=(String) jsonObject.get("transportationNo");
return circuitService.getByTransportationNo(transportationNo,user.getCompanyName());
}
//根据运输编号查询本公司的运输信息(app端)
@ApiOperation(value = "根据运输编号查询本公司的运输信息(app端)",notes = "根据运输编号查询本公司的运输信息(app端),返回值说明:" +
" transportationNo:运输编号," +
" city:城市," +
" startTime:起运时间," +
" cargoNo:货物编号," +
" plateNo:车牌号," +
" deliveryAddress:交付地点," +
" transportation:运输方式," +
" transportationType:运输类型," +
" remark:备注")
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
@RequestMapping(value="/getByTransportationNoForApp",method = RequestMethod.POST)
public Object getByTransportationNoForApp(@RequestBody String transportationNo,HttpServletRequest request){
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
JSONObject jsonObject=JSON.parseObject(transportationNo);
transportationNo=(String) jsonObject.get("transportationNo");
return circuitService.getByTransportationNoForApp(transportationNo,user.getCompanyName());
}
//根据条件查询 //根据条件查询
@ApiOperation(value = "根据条件查询",notes = "根据条件查询:" + @ApiOperation(value = "根据条件查询本公司的线路信息",notes = "companyName不用传,根据条件查询:" +
" cargoNo:货物编号" + " cargoNo:货物编号" +
" startTime:出发时间,(时间戳)" + " startTime:出发时间,(时间戳)" +
" endTime:目的时间,(时间戳)" + " endTime:目的时间,(时间戳)" +
...@@ -97,13 +150,16 @@ public class CircuitController { ...@@ -97,13 +150,16 @@ public class CircuitController {
" endTime:目的时间," + " endTime:目的时间," +
" alarmType:预警类型," + " alarmType:预警类型," +
" circuitState:线路状态(0未开始,1运输中,2完成)," + " circuitState:线路状态(0未开始,1运输中,2完成)," +
" alarm:报警详情(比如:温度,湿度,震动," + " alarm:报警详情(比如:温度,湿度,震动)," +
" evaluate:运输评价") " evaluate:运输评价")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"), @ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
}) })
@RequestMapping(value="/getByTerm",method = RequestMethod.POST) @RequestMapping(value="/getByTerm",method = RequestMethod.POST)
public Object getByTerm(@RequestBody CircuitTermVo circuitTermVo){ public Object getByTerm(@RequestBody CircuitTermVo circuitTermVo,HttpServletRequest request){
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
if(StringUtils.isEmpty(circuitTermVo.getCargoNo())){ if(StringUtils.isEmpty(circuitTermVo.getCargoNo())){
circuitTermVo.setCargoNo(null); circuitTermVo.setCargoNo(null);
} }
...@@ -115,50 +171,62 @@ public class CircuitController { ...@@ -115,50 +171,62 @@ public class CircuitController {
} if(circuitTermVo.getEndTime()==null){ } if(circuitTermVo.getEndTime()==null){
circuitTermVo.setEndTime(null); circuitTermVo.setEndTime(null);
} }
circuitTermVo.setCompanyName(user.getCompanyName());
return circuitService.getByTerm(circuitTermVo); return circuitService.getByTerm(circuitTermVo);
} }
//添加线路信息 //添加线路信息
@ApiOperation(value = "添加线路信息",notes = "添加线路信息," + @ApiOperation(value = "添加线路信息",notes = "添加线路信息," +
" startAddressVo: 线路集合,包含" + " startAddressVo: 线路集合,包含" +
"{country:国家" + " {" +
"city:城市" + " country:国家" +
"addressDetail:详细地址" + " city:城市" +
"lng:经度" + " addressDetail:详细地址" +
"lat:纬度" + " lng:经度" +
"postCode:邮编"+ " lat:纬度" +
"expTime:预计开始时间,(传时间戳)}" + " postCode:邮编"+
" expTime:预计开始时间,(传时间戳)" +
" }" +
" addressVoList: 线路集合,包含" + " addressVoList: 线路集合,包含" +
"{country:国家" + " {" +
"city:城市" + " country:国家" +
"addressDetail:详细地址" + " city:城市" +
"lng:经度" + " addressDetail:详细地址" +
"lat:纬度" + " lng:经度" +
"postCode:邮编"+ " lat:纬度" +
"expTime:预计开始时间,(传时间戳)" + " postCode:邮编"+
"compTime:预计结束时间,(传时间戳)}" + " expTime:预计开始时间,(传时间戳)" +
" compTime:预计结束时间,(传时间戳)" +
" }" +
" endAddressVo: 线路集合,包含" + " endAddressVo: 线路集合,包含" +
"{country:国家" + " {" +
"city:城市" + " country:国家" +
"addressDetail:详细地址" + " city:城市" +
"lng:经度" + " addressDetail:详细地址" +
"lat:纬度" + " lng:经度" +
"postCode:邮编"+ " lat:纬度" +
"compTime:预计结束时间,(传时间戳)}" + " postCode:邮编"+
" compTime:预计结束时间,(传时间戳)" +
" }" +
" SN:网关编号," + " SN:网关编号," +
" tdlAlarmList: " + " tdlAlarmList: " +
"{TDLSN:tdl编号," + " {" +
" alarmType:报警类型,}" + " TDLSN:" +
" tdl编号," +
" alarmType:报警类型," +
" }" +
" cargoNo:货物编号," + " cargoNo:货物编号," +
" plateNo:车牌号," + " plateNo:车牌号," +
" cargoName:货物别名," + " cargoName:货物别名," +
" remark:备注") " remark:备注")
@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"),
}) })
@RequestMapping(value="/addCircuit",method = RequestMethod.POST) @RequestMapping(value="/addCircuit",method = RequestMethod.POST)
public Object addCircuit(@RequestBody AddCircuitVo addCircuitVo){ public Object addCircuit(@RequestBody AddCircuitVo addCircuitVo,HttpServletRequest request){
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
if(StringUtils.isEmpty(addCircuitVo.getStartAddressVo().getCountry())){ if(StringUtils.isEmpty(addCircuitVo.getStartAddressVo().getCountry())){
fb.setCode(0); fb.setCode(0);
fb.setMessage("出发国家不能为空"); fb.setMessage("出发国家不能为空");
...@@ -425,6 +493,7 @@ public class CircuitController { ...@@ -425,6 +493,7 @@ public class CircuitController {
map.put("createTime",time); map.put("createTime",time);
map.put("remark",addCircuitVo.getRemark()); map.put("remark",addCircuitVo.getRemark());
map.put("counts",addCircuitVo.getAddressVoList()== null ? 2 : addCircuitVo.getAddressVoList().size()+2); map.put("counts",addCircuitVo.getAddressVoList()== null ? 2 : addCircuitVo.getAddressVoList().size()+2);
map.put("companyName",user.getCompanyName());
map.put("countryVar",countryVar); map.put("countryVar",countryVar);
map.put("cityVar",cityVar); map.put("cityVar",cityVar);
map.put("addressDetailVar",addressDetailVar); map.put("addressDetailVar",addressDetailVar);
...@@ -457,37 +526,42 @@ public class CircuitController { ...@@ -457,37 +526,42 @@ public class CircuitController {
return gson.toJson(fb); return gson.toJson(fb);
} }
@ApiOperation(value = "添加线路信息----mobile",notes = "添加线路信息," + @ApiOperation(value = "添加线路信息----mobile",notes = "添加线路信息," +
" cargoNo:货物编号," + " cargoNo:货物编号," +
" plateNo:车牌号," + " plateNo:车牌号," +
" cargoName:货物别名," + " cargoName:货物别名," +
" transportation:运输方式,(公路,铁路,海运,空运,快递)" + " transportation:运输方式(公路,铁路,海运,空运,快递)," +
" startAddressVo: 启运城市,包含" + " startAddressVo: 启运城市,包含" +
"{country:国家," + " {" +
"city:城市," + " country:国家," +
"addressDetail:详细地址," + " city:城市," +
"lng:经度," + " addressDetail:详细地址," +
"lat:纬度," + " lng:经度," +
"postCode:邮编,"+ " lat:纬度," +
"expTime:预计开始时间,(13位时间戳)}" + " postCode:邮编,"+
" expTime:预计开始时间(13位时间戳)" +
" }" +
" endAddressVo: 目的城市,包含" + " endAddressVo: 目的城市,包含" +
"{country:国家," + " {" +
"city:城市," + " country:国家," +
"addressDetail:详细地址," + " city:城市," +
"lng:经度," + " addressDetail:详细地址," +
"lat:纬度," + " lng:经度," +
"postCode:邮编,"+ " lat:纬度," +
"compTime:预计结束时间,(13位时间戳)}" + " postCode:邮编,"+
" compTime:预计结束时间(13位时间戳)" +
" }" +
" deliveryAddress:交付地点,(站点,仓库,港口)" + " deliveryAddress:交付地点,(站点,仓库,港口)" +
" transportationType:运输类型,(本地运输,国际运输)" + " transportationType:运输类型,(本地运输,国际运输)," +
" remark:备注,") " remark:备注,")
@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"),
}) })
@RequestMapping(value="/add",method = RequestMethod.POST) @RequestMapping(value="/add",method = RequestMethod.POST)
public Object add(@RequestBody AddCircuit addCircuitVo){ public Object add(@RequestBody AddCircuit addCircuitVo,HttpServletRequest request){
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
if(StringUtils.isEmpty(addCircuitVo.getCargoNo())){ if(StringUtils.isEmpty(addCircuitVo.getCargoNo())){
fb.setCode(0); fb.setCode(0);
fb.setMessage("货物编号不能为空"); fb.setMessage("货物编号不能为空");
...@@ -622,7 +696,6 @@ public class CircuitController { ...@@ -622,7 +696,6 @@ public class CircuitController {
//根据sn获取type //根据sn获取type
Map<Object,Object> map=new HashMap<>(); Map<Object,Object> map=new HashMap<>();
map.put("transportationNo",getTransportNo(addCircuitVo.getTransportation(),addCircuitVo.getTransportationType())); map.put("transportationNo",getTransportNo(addCircuitVo.getTransportation(),addCircuitVo.getTransportationType()));
// map.put("startTime",time);
map.put("expTime",addCircuitVo.getStartAddressVo().getExpTime()); map.put("expTime",addCircuitVo.getStartAddressVo().getExpTime());
map.put("compTime",addCircuitVo.getEndAddressVo().getCompTime()); map.put("compTime",addCircuitVo.getEndAddressVo().getCompTime());
map.put("cargoNo",addCircuitVo.getCargoNo()); map.put("cargoNo",addCircuitVo.getCargoNo());
...@@ -633,6 +706,7 @@ public class CircuitController { ...@@ -633,6 +706,7 @@ public class CircuitController {
map.put("transportationType",addCircuitVo.getTransportationType()); map.put("transportationType",addCircuitVo.getTransportationType());
map.put("createTime",time); map.put("createTime",time);
map.put("remark",addCircuitVo.getRemark()); map.put("remark",addCircuitVo.getRemark());
map.put("companyName",user.getCompanyName());
map.put("counts",2); map.put("counts",2);
map.put("countryVar",countryVar); map.put("countryVar",countryVar);
map.put("cityVar",cityVar); map.put("cityVar",cityVar);
...@@ -657,51 +731,23 @@ public class CircuitController { ...@@ -657,51 +731,23 @@ public class CircuitController {
return gson.toJson(fb); 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 = "修改线路结束时间,传值说明:" + @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"),
}) })
@RequestMapping(value="/updateEndTime",method = RequestMethod.POST) @RequestMapping(value="/updateEndTime",method = RequestMethod.POST)
public Object updateEndTime(@RequestBody UpdateCircuitVo updateCircuitVo){ public Object updateEndTime(@RequestBody UpdateCircuitVo updateCircuitVo,HttpServletRequest request){
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
if (circuitService.getByTransportationNo(updateCircuitVo.getTransportationNo(),user.getCompanyName())==null){
fb.setCode(0);
fb.setMessage("没有该线路");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(updateCircuitVo.getTransportationNo())){ if (StringUtils.isEmpty(updateCircuitVo.getTransportationNo())){
fb.setCode(0); fb.setCode(0);
fb.setMessage("需要修改的运输编号不能为空"); fb.setMessage("需要修改的运输编号不能为空");
...@@ -712,7 +758,7 @@ public class CircuitController { ...@@ -712,7 +758,7 @@ public class CircuitController {
fb.setMessage("线路结束时间不能为空"); fb.setMessage("线路结束时间不能为空");
return gson.toJson(fb); return gson.toJson(fb);
} }
if (circuitService.getByTransportationNo(updateCircuitVo.getTransportationNo()).getCircuitState()!=2){ if (circuitService.getByTransportationNo(updateCircuitVo.getTransportationNo(),user.getCompanyName()).getCircuitState()!=2){
fb.setCode(0); fb.setCode(0);
fb.setMessage("线路未完成"); fb.setMessage("线路未完成");
return gson.toJson(fb); return gson.toJson(fb);
...@@ -728,7 +774,6 @@ public class CircuitController { ...@@ -728,7 +774,6 @@ public class CircuitController {
return gson.toJson(fb); return gson.toJson(fb);
} }
//根据车牌号查线路 //根据车牌号查线路
@ApiOperation(value = "根据车牌号查线路---mobile",notes = "根据车牌号查线路,返回值说明:" + @ApiOperation(value = "根据车牌号查线路---mobile",notes = "根据车牌号查线路,返回值说明:" +
" transportationNo:运输编号," + " transportationNo:运输编号," +
...@@ -742,27 +787,36 @@ public class CircuitController { ...@@ -742,27 +787,36 @@ public class CircuitController {
" alarm:报警详情(比如:温度,湿度,震动)" + " alarm:报警详情(比如:温度,湿度,震动)" +
" evaluate:运输评价") " evaluate:运输评价")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"), @ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
}) })
@RequestMapping(value="/getByContainerNo",method = RequestMethod.POST) @RequestMapping(value="/getByContainerNo",method = RequestMethod.POST)
public Object getByContainerNo(@RequestBody String cargoNo){ public Object getByContainerNo(@RequestBody String cargoNo,HttpServletRequest request){
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
JSONObject jsonObject= JSON.parseObject(cargoNo); JSONObject jsonObject= JSON.parseObject(cargoNo);
cargoNo=(String)jsonObject.get("cargoNo"); cargoNo=(String)jsonObject.get("cargoNo");
return circuitService.getByContainerNo(cargoNo); return circuitService.getByContainerNo(cargoNo,user.getCompanyName());
} }
//评价 //评价
@ApiOperation(value = "评价---mobile",notes = "评价线路传值说明:" + @ApiOperation(value = "评价---mobile",notes = "评价线路传值说明:" +
" transportationNo:运输编号," + " transportationNo:运输编号," +
" evaluate:评分," + " evaluate:评分," +
" evaluateRemark:评分备注") " evaluateRemark:评分备注")
@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"),
}) })
@RequestMapping(value="/updateEvaluate",method = RequestMethod.POST) @RequestMapping(value="/updateEvaluate",method = RequestMethod.POST)
public Object updateEvaluate(@RequestBody UpdateEvaluateVo updateEvaluateVo){ public Object updateEvaluate(@RequestBody UpdateEvaluateVo updateEvaluateVo,HttpServletRequest request){
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
if (circuitService.getByTransportationNo(updateEvaluateVo.getTransportationNo(),user.getCompanyName())==null){
fb.setCode(0);
fb.setMessage("没有该线路");
return gson.toJson(fb);
}
if (updateEvaluateVo.getEvaluate()==null){ if (updateEvaluateVo.getEvaluate()==null){
fb.setCode(0); fb.setCode(0);
fb.setMessage("评价的等级不能为空"); fb.setMessage("评价的等级不能为空");
...@@ -773,7 +827,7 @@ public class CircuitController { ...@@ -773,7 +827,7 @@ public class CircuitController {
fb.setMessage("需要评价的线路编号不能为空"); fb.setMessage("需要评价的线路编号不能为空");
return gson.toJson(fb); return gson.toJson(fb);
} }
if (circuitService.getByTransportationNo(updateEvaluateVo.getTransportationNo()).getCircuitState()!=2){ if (circuitService.getByTransportationNo(updateEvaluateVo.getTransportationNo(),user.getCompanyName()).getCircuitState()!=2){
fb.setCode(0); fb.setCode(0);
fb.setMessage("线路完成运输才能评价"); fb.setMessage("线路完成运输才能评价");
return gson.toJson(fb); return gson.toJson(fb);
...@@ -789,8 +843,6 @@ public class CircuitController { ...@@ -789,8 +843,6 @@ 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:运输编号," +
...@@ -804,36 +856,45 @@ public class CircuitController { ...@@ -804,36 +856,45 @@ public class CircuitController {
" alarm:报警详情(比如:温度,湿度,震动)" + " alarm:报警详情(比如:温度,湿度,震动)" +
" evaluate:运输评价") " evaluate:运输评价")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"), @ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
}) })
@RequestMapping(value="/getByCircuitState",method = RequestMethod.POST) @RequestMapping(value="/getByCircuitState",method = RequestMethod.POST)
public Object getByCircuitState(@RequestBody Map map){ public Object getByCircuitState(@RequestBody Map map,HttpServletRequest request){
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
if (!map.containsKey("circuitState")){ if (!map.containsKey("circuitState")){
fb.setCode(0); fb.setCode(0);
fb.setMessage("需要查询的线路状态不能为空"); fb.setMessage("需要查询的线路状态不能为空");
return gson.toJson(fb); return gson.toJson(fb);
} }
return circuitService.getByCircuitState(Integer.valueOf(map.get("circuitState").toString())); return circuitService.getByCircuitState(Integer.valueOf(map.get("circuitState").toString()),user.getCompanyName());
} }
//删除线路 //删除线路
@ApiOperation(value = "删除线路",notes = "删除线路,传值说明:" + @ApiOperation(value = "删除线路",notes = "删除线路,传值说明:" +
" transportationNo:运输编号" ) " 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"),
}) })
@RequestMapping(value="/delCircuit",method = RequestMethod.POST) @RequestMapping(value="/delCircuit",method = RequestMethod.POST)
public Object delCircuit(@RequestBody String transportationNo){ public Object delCircuit(@RequestBody String transportationNo,HttpServletRequest request){
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
JSONObject jsonObject= JSON.parseObject(transportationNo); JSONObject jsonObject= JSON.parseObject(transportationNo);
transportationNo=(String)jsonObject.get("transportationNo"); transportationNo=(String)jsonObject.get("transportationNo");
if (circuitService.getByTransportationNo(transportationNo,user.getCompanyName())==null){
fb.setCode(0);
fb.setMessage("没有该线路");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(transportationNo)){ if (StringUtils.isEmpty(transportationNo)){
fb.setCode(0); fb.setCode(0);
fb.setMessage("需要删除的运输编号不能为空"); fb.setMessage("需要删除的运输编号不能为空");
return gson.toJson(fb); return gson.toJson(fb);
} }
if (circuitService.getByTransportationNo(transportationNo).getCircuitState()!=0){ if (circuitService.getByTransportationNo(transportationNo,user.getCompanyName()).getCircuitState()!=0){
fb.setCode(0); fb.setCode(0);
fb.setMessage("该线路在运输中或已经完成运输"); fb.setMessage("该线路在运输中或已经完成运输");
return gson.toJson(fb); return gson.toJson(fb);
...@@ -849,7 +910,6 @@ public class CircuitController { ...@@ -849,7 +910,6 @@ public class CircuitController {
return gson.toJson(fb); return gson.toJson(fb);
} }
//根据线路编号获取线路详细信息 //根据线路编号获取线路详细信息
@ApiOperation(value = "根据线路编号获取线路详细信息",notes = "根据线路编号获取线路详细信息,传值说明:" + @ApiOperation(value = "根据线路编号获取线路详细信息",notes = "根据线路编号获取线路详细信息,传值说明:" +
" transportationNo:运输编号; " + " transportationNo:运输编号; " +
...@@ -874,14 +934,17 @@ public class CircuitController { ...@@ -874,14 +934,17 @@ public class CircuitController {
" alarmTime:报警时间" + " alarmTime:报警时间" +
" classify:分类" ) " classify:分类" )
@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"),
}) })
@PostMapping("/getDetails") @PostMapping("/getDetails")
public Object getDetails(@RequestBody String transportationNo){ public Object getDetails(@RequestBody String transportationNo,HttpServletRequest request){
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
JSONObject jsonObject= JSON.parseObject(transportationNo); JSONObject jsonObject= JSON.parseObject(transportationNo);
transportationNo=(String)jsonObject.get("transportationNo"); transportationNo=(String)jsonObject.get("transportationNo");
//获取线路信息 //获取线路信息
ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(transportationNo); ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(transportationNo,user.getCompanyName());
List<ResultAlarmLog> alarmLogList= alarmLogService.getByTransportationNo(transportationNo); List<ResultAlarmLog> alarmLogList= alarmLogService.getByTransportationNo(transportationNo);
CircuitMessageVo messageVo = new CircuitMessageVo(resultCircuitVo.getTransportationNo(),resultCircuitVo.getCargoNo(),resultCircuitVo.getStartCity(),resultCircuitVo.getEndCity(),resultCircuitVo.getCircuitState(),resultCircuitVo.getEvaluate(),alarmLogList); CircuitMessageVo messageVo = new CircuitMessageVo(resultCircuitVo.getTransportationNo(),resultCircuitVo.getCargoNo(),resultCircuitVo.getStartCity(),resultCircuitVo.getEndCity(),resultCircuitVo.getCircuitState(),resultCircuitVo.getEvaluate(),alarmLogList);
//获取线路情况 //获取线路情况
...@@ -980,7 +1043,6 @@ public class CircuitController { ...@@ -980,7 +1043,6 @@ public class CircuitController {
return gson.toJson(messageVo); return gson.toJson(messageVo);
} }
//生成运输编号 //生成运输编号
public String getTransportNo(String transportation,String transportationType){ public String getTransportNo(String transportation,String transportationType){
String transportationNo=""; String transportationNo="";
...@@ -1061,6 +1123,43 @@ public class CircuitController { ...@@ -1061,6 +1123,43 @@ public class CircuitController {
} }
//获取已有线路
// @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 = "修改线路信息,传值说明:" + // @ApiOperation(value = "修改线路信息",notes = "修改线路信息,传值说明:" +
......
...@@ -9,11 +9,13 @@ import com.example.tdl.service.*; ...@@ -9,11 +9,13 @@ import com.example.tdl.service.*;
import com.example.tdl.service.redis.InfoRedisService; import com.example.tdl.service.redis.InfoRedisService;
import com.example.tdl.service.redis.RealRedisService; import com.example.tdl.service.redis.RealRedisService;
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;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.influxdb.dto.Query; import org.influxdb.dto.Query;
import org.influxdb.dto.QueryResult; import org.influxdb.dto.QueryResult;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -25,6 +27,7 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -25,6 +27,7 @@ import org.springframework.web.bind.annotation.RestController;
import org.springframework.data.influxdb.InfluxDBTemplate; import org.springframework.data.influxdb.InfluxDBTemplate;
import javax.servlet.http.HttpServletRequest;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
...@@ -54,22 +57,42 @@ public class DataController { ...@@ -54,22 +57,42 @@ public class DataController {
@Autowired @Autowired
private TDLLogService tdlLogService; private TDLLogService tdlLogService;
@Autowired
private TokenRedisService tokenRedisService;
@Autowired
private RealRedisService realRedisService;
@Autowired
private ProbesService probesService;
private final static String database ="original"; private final static String database ="original";
private List<String> list = new ArrayList<String>(){{
add("\"T\"");
add("\"h\"");
add("\"p\"");
add("\"a0\"");
add("\"ta\"");
}};
//获取坐标数据数据 //获取坐标数据数据
@ApiOperation(value = "获取坐标数据数据",notes = "获取坐标数据数据" + @ApiOperation(value = "获取坐标数据数据",notes = "获取坐标数据数据:" +
"time:时间" + " time:时间," +
"lng:经度" + " lng:经度," +
"lat: 纬度") " lat: 纬度.")
@PostMapping("/getLocation") @PostMapping("/getLocation")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"), @ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
}) })
public Object getLocation(@RequestBody String transportationNo){ public Object getLocation(@RequestBody String transportationNo,HttpServletRequest request){
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
JSONObject jsonObject= JSON.parseObject(transportationNo); JSONObject jsonObject= JSON.parseObject(transportationNo);
transportationNo=jsonObject.getString("transportationNo"); transportationNo=jsonObject.getString("transportationNo");
//根据运输编号获取线路信息 //根据运输编号获取线路信息
ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(transportationNo); ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(transportationNo,user.getCompanyName());
List<LocationDataVo> locationDataVoList =new ArrayList<>(); List<LocationDataVo> locationDataVoList =new ArrayList<>();
if(resultCircuitVo.getStartTime() == null || resultCircuitVo.getStartTime() == 0){ if(resultCircuitVo.getStartTime() == null || resultCircuitVo.getStartTime() == 0){
return gson.toJson(locationDataVoList); return gson.toJson(locationDataVoList);
...@@ -154,83 +177,116 @@ public class DataController { ...@@ -154,83 +177,116 @@ public class DataController {
} }
} }
//获取历史数据 //获取历史数据
@ApiOperation(value = "获取历史数据",notes = "获取历史数据" + @ApiOperation(value = "获取历史数据",notes = "获取历史数据:" +
"返回数据格式:" + "返回数据格式:" +
" ") " ")
@PostMapping("/getHistoryData") @PostMapping("/getHistoryData")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"), @ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
}) })
public Object getHistoryData(@RequestBody String transportationNo){ public Object getHistoryData(@RequestBody String transportationNo,HttpServletRequest request){
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
logger.info("" +System.currentTimeMillis());
logger.info("" + Calendar.getInstance().getTimeInMillis());
JSONObject jsonObject= JSON.parseObject(transportationNo); JSONObject jsonObject= JSON.parseObject(transportationNo);
transportationNo=jsonObject.getString("transportationNo"); transportationNo=jsonObject.getString("transportationNo");
ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(transportationNo); List<DataVo> dataVoList = new ArrayList<>();
ResultGatewayVo gatewayVo = tdlLogService.getByNo(transportationNo); if(StringUtils.isEmpty(transportationNo)){
String device = gatewayVo.getType() +"_" +gatewayVo.getSN();
//获取tdl信息
List<String> devList= tdlDeviceService.getByGatewaySN(gatewayVo.getSN(),gatewayVo.getType());
Long startTime = resultCircuitVo.getStartTime() *1000000l;
if(devList.size() == 0){
fb.setCode(0); fb.setCode(0);
fb.setMessage("没有数据"); fb.setMessage("运输编号不能为空");
return gson.toJson(fb); return gson.toJson(fb);
} }
List<String> list = new ArrayList<String>(){{ ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(transportationNo,user.getCompanyName());
add("\"T\""); if(resultCircuitVo ==null){
add("\"h\""); fb.setCode(0);
add("\"p\""); fb.setMessage("该运输编号不存在");
add("\"a0\""); return gson.toJson(fb);
add("\"ta\""); }
//add("\"t\""); if(resultCircuitVo.getStartTime() == null || resultCircuitVo.getStartTime() == 0){
}}; fb.setCode(0);
Map<String,String> map = new HashMap<>(); fb.setMessage("该线路未开始运输");
map.put("\"T\"","temp"); return gson.toJson(fb);
map.put("\"h\"","humidity"); }
map.put("\"p\"","pressure"); Long startTime = resultCircuitVo.getStartTime() *1000000l;
map.put("\"a0\"","shockEnergy"); if(resultCircuitVo.getEndTime() !=null && resultCircuitVo.getEndTime() !=0 && infoRedisService.hasHashKey("HistoryData",transportationNo)){
map.put("\"ta\"","tilt"); return infoRedisService.getHash("HistoryData",transportationNo);
List<DataVo> dataVoList = new ArrayList<>(); }else{
for(int j = 0;j< list.size();j++){ ResultGatewayVo gatewayVo = tdlLogService.getByNo(transportationNo);
DataVo dataVo = new DataVo(); if(gatewayVo == null){
dataVo.setDescription(map.get(list.get(j))); fb.setCode(0);
List<HistoryDataVo> historyDataVoList = new ArrayList<>(); fb.setMessage("该运输编号不存在");
for( int i =0;i<devList.size();i++){ return gson.toJson(fb);
HistoryDataVo historyDataVo = new HistoryDataVo(); }
String TDLSN=devList.get(i).replace("TDL-","").trim(); String device = gatewayVo.getType() +"_" +gatewayVo.getSN();
historyDataVo.setTDLSN(devList.get(i).replace("TDL-","").trim()); //获取tdl信息
//String sql = "SELECT \"T\" FROM \"tdl_policy\".\"WTD93LG_17110198\" where \"tdl\"=\'TDL-1707010057708\' and time >=1522306792692000000 ORDER BY time"; List<String> devList= tdlDeviceService.getByGatewaySN(gatewayVo.getSN(),gatewayVo.getType());
String sql = "SELECT "+list.get(j)+" FROM \"tdl_policy\".\""+device+"\" where \"tdl\"=\'"+devList.get(i)+"\' and time >="+startTime + " ORDER BY time "; if(devList.size() == 0){
QueryResult queryResult = influxDBTemplate.query(new Query(sql,database)); fb.setCode(0);
List<HistoryData> historyData = new ArrayList<>(); fb.setMessage("没有数据");
if(queryResult.getResults().get(0).getSeries() != null){ return gson.toJson(fb);
//解析数据 }
historyData = getHistoryData(queryResult); Map<String,String> map = new HashMap<>();
map.put("\"T\"","temp");
map.put("\"h\"","humidity");
map.put("\"p\"","pressure");
map.put("\"a0\"","shockEnergy");
map.put("\"ta\"","tilt");
for(int j = 0;j< list.size();j++){
DataVo dataVo = new DataVo();
dataVo.setDescription(map.get(list.get(j)));
List<HistoryDataVo> historyDataVoList = new ArrayList<>();
for( int i =0;i<devList.size();i++){
HistoryDataVo historyDataVo = new HistoryDataVo();
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 >=1522220659993000000 ORDER BY time ";
String sql="";
if(resultCircuitVo.getEndTime() !=null && resultCircuitVo.getEndTime() !=0){
sql = "SELECT "+list.get(j)+" FROM \"tdl_policy\".\""+device+"\" where \"tdl\"='"+devList.get(i)+"' and time >="+startTime + "and time<="+resultCircuitVo.getEndTime() *1000000l+" ORDER BY time ";
}else{
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){
//解析数据
historyData = getHistoryData(queryResult);
}
historyDataVo.setDataList(historyData);
historyDataVoList.add(historyDataVo);
} }
historyDataVo.setDataList(historyData); dataVo.setDataList(historyDataVoList);
historyDataVoList.add(historyDataVo); dataVoList.add(dataVo);
} }
dataVo.setDataList(historyDataVoList); if(resultCircuitVo.getEndTime()!=null && resultCircuitVo.getEndTime()!=0){
dataVoList.add(dataVo); Map<Object,Object> m = new HashMap<>();
map.put(transportationNo,dataVoList.toString());
infoRedisService.setHash("HistoryData",m,System.currentTimeMillis());
}
return gson.toJson(dataVoList);
} }
return gson.toJson(dataVoList);
} }
//获取温度数据 //获取温度数据
@ApiOperation(value = "获取温度数据",notes = "获取温度数据" + @ApiOperation(value = "获取温度数据",notes = "获取温度数据:" +
"TDLSN:tdl编号" + " TDLSN:tdl编号," +
"temperatureDataVos:" + " temperatureDataVos:," +
"time:时间" + " time:时间," +
"value:温度数据") " value:温度数据.")
@PostMapping("/getTemperature") @PostMapping("/getTemperature")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"), @ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
}) })
public Object getTemperature(@RequestBody String transportationNo){ public Object getTemperature(@RequestBody String transportationNo,HttpServletRequest request){
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
JSONObject jsonObject= JSON.parseObject(transportationNo); JSONObject jsonObject= JSON.parseObject(transportationNo);
transportationNo=jsonObject.getString("transportationNo"); transportationNo=jsonObject.getString("transportationNo");
ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(transportationNo); ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(transportationNo,user.getCompanyName());
ResultGatewayVo gatewayVo = new ResultGatewayVo(); ResultGatewayVo gatewayVo = new ResultGatewayVo();
if(resultCircuitVo.getEndTime() == 0){ if(resultCircuitVo.getEndTime() == 0){
gatewayVo = circuitService.getByNo(transportationNo); gatewayVo = circuitService.getByNo(transportationNo);
...@@ -252,7 +308,7 @@ public class DataController { ...@@ -252,7 +308,7 @@ public class DataController {
for( int i =0;i<devList.size();i++){ for( int i =0;i<devList.size();i++){
Temperature temperature = new Temperature(); Temperature temperature = new Temperature();
temperature.setTDLSN(devList.get(i)); temperature.setTDLSN(devList.get(i));
String sql = "SELECT \"t\" FROM \"tdl_policy\".\""+devcie+"\" where \"tdl\"=\'"+devList.get(i)+"\' and time >="+startTime+" ORDER BY time "; String sql = "SELECT \"T\" FROM \"tdl_policy\".\""+devcie+"\" where \"tdl\"=\'"+devList.get(i)+"\' and time >="+startTime+" ORDER BY time ";
QueryResult queryResult = influxDBTemplate.query(new Query(sql,database)); QueryResult queryResult = influxDBTemplate.query(new Query(sql,database));
List<TemperatureDataVo> temperatureDataVos = new ArrayList<>(); List<TemperatureDataVo> temperatureDataVos = new ArrayList<>();
if(queryResult.getResults().get(0).getSeries() != null){ if(queryResult.getResults().get(0).getSeries() != null){
...@@ -266,15 +322,18 @@ public class DataController { ...@@ -266,15 +322,18 @@ public class DataController {
} }
//获取湿度数据 //获取湿度数据
@ApiOperation(value = "获取湿度数据",notes = "获取湿度数据") @ApiOperation(value = "获取湿度数据",notes = "获取湿度数据:")
@PostMapping("/getHumidity") @PostMapping("/getHumidity")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"), @ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
}) })
public Object getHumidity(@RequestBody String transportationNo){ public Object getHumidity(@RequestBody String transportationNo,HttpServletRequest request){
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
JSONObject jsonObject= JSON.parseObject(transportationNo); JSONObject jsonObject= JSON.parseObject(transportationNo);
transportationNo=jsonObject.getString("transportationNo"); transportationNo=jsonObject.getString("transportationNo");
ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(transportationNo); ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(transportationNo,user.getCompanyName());
ResultGatewayVo gatewayVo = new ResultGatewayVo(); ResultGatewayVo gatewayVo = new ResultGatewayVo();
if(resultCircuitVo.getEndTime() == 0){ if(resultCircuitVo.getEndTime() == 0){
gatewayVo = circuitService.getByNo(transportationNo); gatewayVo = circuitService.getByNo(transportationNo);
...@@ -305,14 +364,6 @@ public class DataController { ...@@ -305,14 +364,6 @@ public class DataController {
humidity.setHumidityDataVoList(humidityDataVos); humidity.setHumidityDataVoList(humidityDataVos);
humidities.add(humidity); humidities.add(humidity);
} }
// //SELECT "h" FROM "tdl_policy"."WTD93LG_20180314" WHERE "tdl" = 'tdl-0A0B0C0D0F' ORDER BY time DESC
// String sql = "SELECT \"h\" FROM \"tdl_policy\".\""+devcie+"\" ORDER BY time ";
// QueryResult queryResult = influxDBTemplate.query(new Query(sql,database));
// List<HumidityDataVo> humidityDataVos = new ArrayList<>();
// if(queryResult.getResults().get(0).getSeries() != null){
// //解析数据
// humidityDataVos = getHumidity(queryResult);
// }
return gson.toJson(humidities); return gson.toJson(humidities);
} }
...@@ -320,12 +371,15 @@ public class DataController { ...@@ -320,12 +371,15 @@ public class DataController {
@ApiOperation(value = "获取倾斜度数据",notes = "获取倾斜度数据") @ApiOperation(value = "获取倾斜度数据",notes = "获取倾斜度数据")
@PostMapping("/getTiltAngle") @PostMapping("/getTiltAngle")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"), @ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
}) })
public Object getTiltAngle(@RequestBody String transportationNo){ public Object getTiltAngle(@RequestBody String transportationNo,HttpServletRequest request){
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
JSONObject jsonObject= JSON.parseObject(transportationNo); JSONObject jsonObject= JSON.parseObject(transportationNo);
transportationNo=jsonObject.getString("transportationNo"); transportationNo=jsonObject.getString("transportationNo");
ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(transportationNo); ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(transportationNo,user.getCompanyName());
ResultGatewayVo gatewayVo = new ResultGatewayVo(); ResultGatewayVo gatewayVo = new ResultGatewayVo();
if(resultCircuitVo.getEndTime() == 0){ if(resultCircuitVo.getEndTime() == 0){
gatewayVo = circuitService.getByNo(transportationNo); gatewayVo = circuitService.getByNo(transportationNo);
...@@ -356,13 +410,6 @@ public class DataController { ...@@ -356,13 +410,6 @@ public class DataController {
tiltAngle.setShockEnergyVoList(tiltAngleVos); tiltAngle.setShockEnergyVoList(tiltAngleVos);
tiltAngles.add(tiltAngle); tiltAngles.add(tiltAngle);
} }
// String sql = "SELECT \"ta\" FROM \"tdl_policy\".\""+devcie+"\" ORDER BY time ";
// QueryResult queryResult = influxDBTemplate.query(new Query(sql,database));
// List<TiltAngleVo> tiltAngleVos = new ArrayList<>();
// if(queryResult.getResults().get(0).getSeries() != null){
// //解析数据
// tiltAngleVos = getTiltAngle(queryResult);
// }
return gson.toJson(tiltAngles); return gson.toJson(tiltAngles);
} }
...@@ -372,10 +419,13 @@ public class DataController { ...@@ -372,10 +419,13 @@ public class DataController {
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"), @ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
}) })
public Object getShockEnergy(@RequestBody String transportationNo){ public Object getShockEnergy(@RequestBody String transportationNo,HttpServletRequest request){
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
JSONObject jsonObject= JSON.parseObject(transportationNo); JSONObject jsonObject= JSON.parseObject(transportationNo);
transportationNo=jsonObject.getString("transportationNo"); transportationNo=jsonObject.getString("transportationNo");
ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(transportationNo); ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(transportationNo,user.getCompanyName());
ResultGatewayVo gatewayVo = new ResultGatewayVo(); ResultGatewayVo gatewayVo = new ResultGatewayVo();
if(resultCircuitVo.getEndTime() == 0){ if(resultCircuitVo.getEndTime() == 0){
gatewayVo = circuitService.getByNo(transportationNo); gatewayVo = circuitService.getByNo(transportationNo);
...@@ -406,13 +456,6 @@ public class DataController { ...@@ -406,13 +456,6 @@ public class DataController {
shockEnergy.setShockEnergyVoList(shockEnergyVos); shockEnergy.setShockEnergyVoList(shockEnergyVos);
shockEnergies.add(shockEnergy); shockEnergies.add(shockEnergy);
} }
// String sql = "SELECT \"a0\" FROM \"tdl_policy\".\""+devcie+"\" ORDER BY time ";
// QueryResult queryResult = influxDBTemplate.query(new Query(sql,database));
// List<ShockEnergyVo> shockEnergyVos = new ArrayList<>();
// if(queryResult.getResults().get(0).getSeries() != null){
// //解析数据
// shockEnergyVos = getShockEnergy(queryResult);
// }
return gson.toJson(shockEnergies); return gson.toJson(shockEnergies);
} }
...@@ -437,7 +480,7 @@ public class DataController { ...@@ -437,7 +480,7 @@ public class DataController {
List<HistoryData> historyDataList = new ArrayList<>(); List<HistoryData> historyDataList = new ArrayList<>();
for(List<Object> value:values){ for(List<Object> value:values){
HistoryData historyData = new HistoryData(); HistoryData historyData = new HistoryData();
historyData.setTime(parseTime(value.get(0).toString())); historyData.setTime(UTCToCST(value.get(0).toString()));
historyData.setValue(value.get(1)==null ? "" :value.get(1).toString()); historyData.setValue(value.get(1)==null ? "" :value.get(1).toString());
historyDataList.add(historyData); historyDataList.add(historyData);
} }
...@@ -592,12 +635,17 @@ public class DataController { ...@@ -592,12 +635,17 @@ public class DataController {
return time; return time;
} }
public String UTCToCST(String UTCStr) throws ParseException { public String UTCToCST(String UTCStr) {
Date date =null ; Date date =null ;
if(UTCStr.length() !=20 ) { try {
date = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").parse(UTCStr); if (UTCStr.length() != 20) {
}else{ date = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").parse(UTCStr);
date = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").parse(UTCStr); } else {
date = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").parse(UTCStr);
}
}catch (Exception e){
e.printStackTrace();
logger.info(e.toString());
} }
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.setTime(date); calendar.setTime(date);
...@@ -642,7 +690,7 @@ public class DataController { ...@@ -642,7 +690,7 @@ public class DataController {
} }
//根据运输编号获取路线以及设备信息 // 根据运输编号获取路线以及设备信息
// @ApiOperation(value = "获取路线以及设备信息",notes = "获取路线以及设备信息" + // @ApiOperation(value = "获取路线以及设备信息",notes = "获取路线以及设备信息" +
// "transportationNo:运输编号" + // "transportationNo:运输编号" +
// "startCity:启运城市" + // "startCity:启运城市" +
...@@ -658,15 +706,18 @@ public class DataController { ...@@ -658,15 +706,18 @@ public class DataController {
// "remark:备注信息") // "remark:备注信息")
// @PostMapping("/getCircuit") // @PostMapping("/getCircuit")
// @ApiImplicitParams({ // @ApiImplicitParams({
// @ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"), // @ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
// }) // })
// public Object getCircuit(@RequestBody String transportationNo){ // public Object getCircuit(@RequestBody String transportationNo,HttpServletRequest request){
// String token = request.getHeader("Account_token");
// String datum = tokenRedisService.get("TOKEN_" +token);
// UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
// JSONObject jsonObject= JSON.parseObject(transportationNo); // JSONObject jsonObject= JSON.parseObject(transportationNo);
// transportationNo=jsonObject.getString("transportationNo"); // transportationNo=jsonObject.getString("transportationNo");
// ResultCircuit resultCircuit = new ResultCircuit(); // ResultCircuit resultCircuit = new ResultCircuit();
// resultCircuit.setTransportationNo(transportationNo); // resultCircuit.setTransportationNo(transportationNo);
// //根据运输编号获取线路信息,设备信息 // //根据运输编号获取线路信息,设备信息
// ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(transportationNo); // ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(transportationNo,user.getCompanyName());
// resultCircuit.setStartCity(resultCircuitVo.getStartCity()); // resultCircuit.setStartCity(resultCircuitVo.getStartCity());
// resultCircuit.setStartTime(resultCircuitVo.getStartTime()); // resultCircuit.setStartTime(resultCircuitVo.getStartTime());
// resultCircuit.setEndCity(resultCircuitVo.getEndCity()); // resultCircuit.setEndCity(resultCircuitVo.getEndCity());
...@@ -722,9 +773,9 @@ public class DataController { ...@@ -722,9 +773,9 @@ public class DataController {
// resultCircuit.setCircuitState(resultCircuitVo.getCircuitState()); // resultCircuit.setCircuitState(resultCircuitVo.getCircuitState());
// return gson.toJson(resultCircuit); // return gson.toJson(resultCircuit);
// } // }
//
//
//根据时间获取经纬度信息 //// 根据时间获取经纬度信息
// @ApiOperation(value = "根据时间获取经纬度信息",notes = "根据时间获取经纬度信息" + // @ApiOperation(value = "根据时间获取经纬度信息",notes = "根据时间获取经纬度信息" +
// "transportationNo:运输编号" + // "transportationNo:运输编号" +
// "TDLSN:tdl编号" + // "TDLSN:tdl编号" +
...@@ -740,12 +791,15 @@ public class DataController { ...@@ -740,12 +791,15 @@ public class DataController {
// "lat:纬度") // "lat:纬度")
// @PostMapping("/getLocationByTime") // @PostMapping("/getLocationByTime")
// @ApiImplicitParams({ // @ApiImplicitParams({
// @ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"), // @ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
// }) // })
// public Object getLocationByTime(@RequestBody LocationVo locationVo ){ // public Object getLocationByTime(@RequestBody LocationVo locationVo,HttpServletRequest request){
// String token = request.getHeader("Account_token");
// String datum = tokenRedisService.get("TOKEN_" +token);
// UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
// //获取线路信息 // //获取线路信息
// //获取网关以及tdl信息 // //获取网关以及tdl信息
// ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(locationVo.getTransportationNo()); // ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(locationVo.getTransportationNo(),user.getCompanyName());
// ResultGatewayVo gatewayVo = new ResultGatewayVo(); // ResultGatewayVo gatewayVo = new ResultGatewayVo();
// if(resultCircuitVo.getEndTime() == 0){ // if(resultCircuitVo.getEndTime() == 0){
// gatewayVo = circuitService.getByNo(locationVo.getTransportationNo()); // gatewayVo = circuitService.getByNo(locationVo.getTransportationNo());
...@@ -781,17 +835,20 @@ public class DataController { ...@@ -781,17 +835,20 @@ public class DataController {
// } // }
// return gson.toJson(locationDataVos); // return gson.toJson(locationDataVos);
// } // }
//
//获取温度、湿度、震动强度、震动能量、倾斜度 //// 获取温度、湿度、震动强度、震动能量、倾斜度
// @PostMapping("/getDeviceData") // @PostMapping("/getDeviceData")
// @ApiImplicitParams({ // @ApiImplicitParams({
// @ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"), // @ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
// }) // })
// public Object getDeviceData(@RequestBody String transportationNo){ // public Object getDeviceData(@RequestBody String transportationNo,HttpServletRequest request){
// String token = request.getHeader("Account_token");
// String datum = tokenRedisService.get("TOKEN_" +token);
// UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
// JSONObject jsonObject= JSON.parseObject(transportationNo); // JSONObject jsonObject= JSON.parseObject(transportationNo);
// transportationNo=jsonObject.getString("transportationNo"); // transportationNo=jsonObject.getString("transportationNo");
// //获取网关以及tdl信息 // //获取网关以及tdl信息
// ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(transportationNo); // ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(transportationNo,user.getCompanyName());
// ResultGatewayVo gatewayVo = new ResultGatewayVo(); // ResultGatewayVo gatewayVo = new ResultGatewayVo();
// if(resultCircuitVo.getEndTime() == 0){ // if(resultCircuitVo.getEndTime() == 0){
// gatewayVo = circuitService.getByNo(transportationNo); // gatewayVo = circuitService.getByNo(transportationNo);
...@@ -813,10 +870,10 @@ public class DataController { ...@@ -813,10 +870,10 @@ public class DataController {
// } // }
// return gson.toJson(deviceDataVos); // return gson.toJson(deviceDataVos);
// } // }
//获取实时数据 //// 获取实时数据
// @ApiOperation(value = "获取实时数据",notes = "获取实时数据") // @ApiOperation(value = "获取实时数据",notes = "获取实时数据")
// @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"),
// }) // })
// @PostMapping("/getRealTimeData") // @PostMapping("/getRealTimeData")
// public Object getRealTimeData(@RequestBody String transportationNo){ // public Object getRealTimeData(@RequestBody String transportationNo){
......
...@@ -8,6 +8,7 @@ import com.example.tdl.service.AlarmLogService; ...@@ -8,6 +8,7 @@ import com.example.tdl.service.AlarmLogService;
import com.example.tdl.service.CircuitService; import com.example.tdl.service.CircuitService;
import com.example.tdl.service.TDLLogService; import com.example.tdl.service.TDLLogService;
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;
...@@ -20,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -20,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.influxdb.InfluxDBTemplate; import org.springframework.data.influxdb.InfluxDBTemplate;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -47,6 +49,9 @@ public class HomePageController { ...@@ -47,6 +49,9 @@ public class HomePageController {
@Autowired @Autowired
private InfluxDBTemplate influxDBTemplate; private InfluxDBTemplate influxDBTemplate;
@Autowired
private TokenRedisService tokenRedisService;
private final static String database ="original"; private final static String database ="original";
//获取当天所有的设备数据 //获取当天所有的设备数据
...@@ -77,22 +82,25 @@ public class HomePageController { ...@@ -77,22 +82,25 @@ public class HomePageController {
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"), @ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
}) })
public Object getAll(@RequestBody String time){ public Object getAll(@RequestBody String time, HttpServletRequest request){
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
JSONObject jsonObject= JSON.parseObject(time); JSONObject jsonObject= JSON.parseObject(time);
time=(String) jsonObject.get("time"); time=(String) jsonObject.get("time");
//获取数量 //获取数量
HomePageDataVo dataVo = new HomePageDataVo(); HomePageDataVo dataVo = new HomePageDataVo();
//获取所有的线路数量 //获取所有的线路数量
dataVo.setSum(circuitService.getCount(time));//总数量 dataVo.setSum(circuitService.getCount(time,user.getCompanyName()));//总数量
dataVo.setOnRoute(circuitService.getOnRoute(time));//在途数量 dataVo.setOnRoute(circuitService.getOnRoute(time,user.getCompanyName()));//在途数量
dataVo.setDelay(circuitService.getDelayCount(System.currentTimeMillis(),time));//延误数量 dataVo.setDelay(circuitService.getDelayCount(System.currentTimeMillis(),time,user.getCompanyName()));//延误数量
dataVo.setAlarmed( alarmLogServcie.getCount(time));//报警数量 dataVo.setAlarmed( alarmLogServcie.getCount(time));//报警数量
dataVo.setBump(alarmLogServcie.getBumpCount(time)); //获取颠簸数量 dataVo.setBump(alarmLogServcie.getBumpCount(time)); //获取颠簸数量
dataVo.setAlarmLogVoList(alarmLogServcie.getAlarmLog(time));//报警列表 dataVo.setAlarmLogVoList(alarmLogServcie.getAlarmLog(time));//报警列表
List<HistogramData> list = alarmLogServcie.getByCount(time);//获取报警柱状图 List<HistogramData> list = alarmLogServcie.getByCount(time);//获取报警柱状图
//获取设备的当前位置 //获取设备的当前位置
List<ResultCircuitVo> circuitVos = circuitService.getByTime(time); List<ResultCircuitVo> circuitVos = circuitService.getByTime(time,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();
......
spring.datasource.url=jdbc:mysql://192.168.1.16:3306/tdlCloud?useUnicode=true&characterEncoding=utf-8&useSSL=false spring.datasource.url=jdbc:mysql://127.0.0.1:3306/tdlCloud?useUnicode=true&characterEncoding=utf-8&useSSL=false
spring.datasource.username=root spring.datasource.username=root
spring.datasource.password=37774020 spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.jdbc.Driver spring.datasource.driver-class-name=com.mysql.jdbc.Driver
threadpool.corepoolsize = 30 threadpool.corepoolsize = 30
......
...@@ -2,16 +2,23 @@ ...@@ -2,16 +2,23 @@
<!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.CircuitMapper"> <mapper namespace="com.example.tdl.mapper.CircuitMapper">
<!--获取所有线路的信息--> <!--获取所有线路的信息-->
<select id="getAll" resultType="com.example.tdl.domain.vo.ResultCircuitVo"> <select id="getAll" 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,
from circuit c where c.state=1 (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
from circuit c where c.state=1
AND company_id=(SELECT id from company where companyName=#{companyName,jdbcType=VARCHAR})
</select> </select>
<!--根据条件查询线路信息--> <!--根据条件查询线路信息-->
<select id="getByTerm" resultType="com.example.tdl.domain.vo.ResultCircuitVo" parameterType="com.example.tdl.domain.vo.CircuitTermVo"> <select id="getByTerm" resultType="com.example.tdl.domain.vo.ResultCircuitVo" parameterType="com.example.tdl.domain.vo.CircuitTermVo">
SELECT 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,
from circuit c where c.state=1 (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
from circuit c where c.state=1 AND company_id=(SELECT id from company where companyName=#{companyName,jdbcType=VARCHAR})
<if test="circuitState!=null"> <if test="circuitState!=null">
AND circuitState=#{circuitState,jdbcType=INTEGER} AND circuitState=#{circuitState,jdbcType=INTEGER}
</if> </if>
...@@ -43,6 +50,7 @@ ...@@ -43,6 +50,7 @@
#{transportationType,mode=IN,jdbcType=VARCHAR}, #{transportationType,mode=IN,jdbcType=VARCHAR},
#{createTime,mode=IN,jdbcType=BIGINT}, #{createTime,mode=IN,jdbcType=BIGINT},
#{remark,mode=IN,jdbcType=VARCHAR}, #{remark,mode=IN,jdbcType=VARCHAR},
#{companyName,mode=IN,jdbcType=VARCHAR},
#{counts,mode=IN,jdbcType=INTEGER}, #{counts,mode=IN,jdbcType=INTEGER},
#{countryVar,mode=IN,jdbcType=VARCHAR}, #{countryVar,mode=IN,jdbcType=VARCHAR},
#{cityVar,mode=IN,jdbcType=VARCHAR}, #{cityVar,mode=IN,jdbcType=VARCHAR},
...@@ -68,8 +76,6 @@ ...@@ -68,8 +76,6 @@
]]> ]]>
</insert> </insert>
<insert id="add" parameterType="java.util.Map" statementType="CALLABLE"> <insert id="add" parameterType="java.util.Map" statementType="CALLABLE">
<![CDATA[ <![CDATA[
{ {
...@@ -86,6 +92,7 @@ ...@@ -86,6 +92,7 @@
#{transportationType,mode=IN,jdbcType=VARCHAR}, #{transportationType,mode=IN,jdbcType=VARCHAR},
#{createTime,mode=IN,jdbcType=BIGINT}, #{createTime,mode=IN,jdbcType=BIGINT},
#{remark,mode=IN,jdbcType=VARCHAR}, #{remark,mode=IN,jdbcType=VARCHAR},
#{companyName,mode=IN,jdbcType=VARCHAR},
#{counts,mode=IN,jdbcType=INTEGER}, #{counts,mode=IN,jdbcType=INTEGER},
#{countryVar,mode=IN,jdbcType=VARCHAR}, #{countryVar,mode=IN,jdbcType=VARCHAR},
#{cityVar,mode=IN,jdbcType=VARCHAR}, #{cityVar,mode=IN,jdbcType=VARCHAR},
...@@ -138,6 +145,12 @@ ...@@ -138,6 +145,12 @@
]]> ]]>
</update> </update>
<!-- 修改结束时间-->
<update id="updateEndTime" parameterType="com.example.tdl.domain.vo.UpdateCircuitVo">
UPDATE circuit set
endTime=#{endTime,jdbcType=BIGINT},circuitState=2
WHERE transportationNo=#{transportationNo,jdbcType=VARCHAR}
</update>
<!--删除线路--> <!--删除线路-->
<delete id="delCircuit" parameterType="String"> <delete id="delCircuit" parameterType="String">
...@@ -145,50 +158,67 @@ ...@@ -145,50 +158,67 @@
WHERE transportationNo=#{transportationNo,jdbcType=VARCHAR} WHERE transportationNo=#{transportationNo,jdbcType=VARCHAR}
</delete> </delete>
<!-- 修改结束时间--> <!--根据线路编号获取线路信息-->
<update id="updateEndTime" parameterType="com.example.tdl.domain.vo.UpdateCircuitVo"> <select id="getByTransportationNo" resultType="com.example.tdl.domain.vo.ResultCircuitVo" parameterType="String">
UPDATE circuit set 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,
endTime=#{endTime,jdbcType=BIGINT},circuitState=2 (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,
WHERE transportationNo=#{transportationNo,jdbcType=VARCHAR} (SELECT alarmType FROM alarm WHERE id IN (SELECT alarm_id from tdl_gateway_log WHERE transportationNo=c.transportationNo)) alarmType,
</update> (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}
AND company_id=(SELECT id from company where companyName=#{companyName,jdbcType=VARCHAR})
</select>
<!--根据线路编号获取线路信息 app-->
<select id="getByTransportationNoForApp" resultType="com.example.tdl.domain.vo.ResultCircuitForAppVo" parameterType="String">
SELECT c.transportationNo,(SELECT GROUP_CONCAT(city SEPARATOR '-') city from city WHERE id in (SELECT city_id from circuit_transfer WHERE circuit_id=c.id AND sequence in (LEFT(s.sequence,1),RIGHT(s.sequence,1)))) city,
cargoNo,plateNo,deliveryAddress,transportation,transportationType,remark
from circuit c,(SELECT GROUP_CONCAT(sequence) sequence from circuit_transfer where circuit_id=(SELECT id from circuit where transportationNo=#{transportationNo,jdbcType=VARCHAR})) s
where c.state=1
AND c.transportationNo=#{transportationNo,jdbcType=VARCHAR}
AND company_id=(SELECT id from company where companyName=#{companyName,jdbcType=VARCHAR})
</select>
<!-- 运输中数量--> <!-- 运输中数量-->
<select id="getOnRoute" resultType="java.lang.Integer" parameterType="String"> <select id="getOnRoute" resultType="java.lang.Integer" parameterType="String">
select count( startTime) from circuit where circuitState=1 and DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(createTime/1000,'%Y-%m-%d %H:%i:%s')) select count(startTime) from circuit where circuitState=1
</select> and DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(createTime/1000,'%Y-%m-%d %H:%i:%s'))
AND company_id=(SELECT id from company where companyName=#{companyName,jdbcType=VARCHAR})
</select>
<!--延误数量--> <!--延误数量-->
<select id="getDelayCount" resultType="java.lang.Integer" > <select id="getDelayCount" resultType="java.lang.Integer" >
select count(id) from circuit where state =1 and endtime &lt;=compTime or compTime >= #{compTime,jdbcType=BIGINT} select count(id) from circuit where state =1
and endtime &lt;=compTime or compTime >= #{compTime,jdbcType=BIGINT}
AND company_id=(SELECT id from company where companyName=#{companyName,jdbcType=VARCHAR})
</select> </select>
<!--总数量--> <!--总数量-->
<select id="getCount" resultType="java.lang.Integer" parameterType="String"> <select id="getCount" resultType="java.lang.Integer" parameterType="String">
select count(id) from circuit where DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(createTime/1000,'%Y-%m-%d %H:%i:%s')) select count(id) from circuit
</select> where DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(createTime/1000,'%Y-%m-%d %H:%i:%s'))
AND company_id=(SELECT id from company where companyName=#{companyName,jdbcType=VARCHAR})
<!--根据线路编号获取线路信息-->
<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,ifnull(evaluate,"") evaluate
from circuit c where c.state=1
AND c.transportationNo=#{transportationNo,jdbcType=VARCHAR}
</select> </select>
<!--根据车牌号查线路--> <!--根据车牌号查线路-->
<select id="getByContainerNo" parameterType="String" resultType="com.example.tdl.domain.vo.ResultCircuitVo"> <select id="getByContainerNo" parameterType="String" resultType="com.example.tdl.domain.vo.ResultCircuitVo">
SELECT 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,
from circuit c where c.state=1 AND cargoNo=#{cargoNo,jdbcType=VARCHAR} (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
from circuit c where c.state=1 AND cargoNo=#{cargoNo,jdbcType=VARCHAR}
AND company_id=(SELECT id from company where companyName=#{companyName,jdbcType=VARCHAR})
</select> </select>
<!--根据运输状态查询线路信息--> <!--根据运输状态查询线路信息-->
<select id="getByCircuitState" parameterType="java.lang.Integer" resultType="com.example.tdl.domain.vo.ResultCircuitVo"> <select id="getByCircuitState" resultType="com.example.tdl.domain.vo.ResultCircuitVo">
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,
from circuit c where c.state=1 AND circuitState=#{circuitState,jdbcType=INTEGER} (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
from circuit c where c.state=1 AND circuitState=#{circuitState,jdbcType=INTEGER}
AND company_id=(SELECT id from company where companyName=#{companyName,jdbcType=VARCHAR})
</select> </select>
<!--评价--> <!--评价-->
...@@ -200,18 +230,23 @@ ...@@ -200,18 +230,23 @@
</update> </update>
<select id="getNo" parameterType="String" resultType="java.lang.Integer"> <select id="getNo" parameterType="String" resultType="java.lang.Integer">
SELECT count(transportationNo) from circuit WHERE transportationNo=#{transportationNo,jdbcType=VARCHAR} SELECT count(transportationNo) from circuit
WHERE transportationNo=#{transportationNo,jdbcType=VARCHAR}
</select> </select>
<select id="getByNo" parameterType="String" resultType="com.example.tdl.domain.vo.ResultGatewayVo"> <select id="getByNo" parameterType="String" resultType="com.example.tdl.domain.vo.ResultGatewayVo">
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 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 =( from gateway WHERE id=(SELECT gateway_id from tdldevice where circuit_id =(SELECT id from circuit WHERE transportationNo=#{transportationNo,jdbcType=VARCHAR}) LIMIT 1)
SELECT id from circuit WHERE transportationNo=#{transportationNo,jdbcType=VARCHAR}) LIMIT 1)
</select> </select>
<select id="getByTime" parameterType="java.lang.String" resultType="com.example.tdl.domain.vo.ResultCircuitVo"> <select id="getByTime" parameterType="java.lang.String" resultType="com.example.tdl.domain.vo.ResultCircuitVo">
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,
from circuit c where c.state=1 AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(createTime/1000,'%Y-%m-%d %H:%i:%s')) (SELECT 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
from circuit c where c.state=1
AND company_id=(SELECT id from company where companyName=#{companyName,jdbcType=VARCHAR})
AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(createTime/1000,'%Y-%m-%d %H:%i:%s'))
</select> </select>
<!-- <!--
......
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