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;
......
......@@ -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
......
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