Commit 167c4c1b authored by chenying's avatar chenying

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

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