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;
......
...@@ -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
......
This diff is collapsed.
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