Commit a2d311e5 authored by zhuangzhuang's avatar zhuangzhuang

5.18-修改首页延迟线路的bug,增加全局异常处理

parent 7f3645d4
...@@ -73,6 +73,16 @@ public class CircuitMessageVo { ...@@ -73,6 +73,16 @@ public class CircuitMessageVo {
this.alarmLogList = alarmLogList; this.alarmLogList = alarmLogList;
} }
public CircuitMessageVo(String transportationNo, String routeName, String cargoName, String plateNo, String transportation, String evaluate, String alarmType) {
this.transportationNo = transportationNo;
this.routeName = routeName;
this.cargoName = cargoName;
this.plateNo = plateNo;
this.transportation = transportation;
this.evaluate = evaluate;
this.alarmType = alarmType;
}
public String getTransportationNo() { public String getTransportationNo() {
return transportationNo; return transportationNo;
} }
......
...@@ -107,11 +107,18 @@ public class HomePageController { ...@@ -107,11 +107,18 @@ public class HomePageController {
dataVo.setSum(circuitService.getCount(time,System.currentTimeMillis()/1000l,user.getCompanyName()));//总数量 dataVo.setSum(circuitService.getCount(time,System.currentTimeMillis()/1000l,user.getCompanyName()));//总数量
//获取近几天的线路信息 //获取近几天的线路信息
dataVo.setOnRoute(circuitService.getOnRoute(user.getCompanyName()));//在途数量 dataVo.setOnRoute(circuitService.getOnRoute(user.getCompanyName()));//在途数量
dataVo.setDelay(circuitService.getDelayCount(System.currentTimeMillis(),time,user.getCompanyName()));//延误数量 Integer delay = circuitService.getDelayCount(System.currentTimeMillis(),time,user.getCompanyName());
dataVo.setDelay(delay);//延误数量
dataVo.setAlarmed( alarmLogServcie.getCount(time,user.getCompanyName()));//报警数量 dataVo.setAlarmed( alarmLogServcie.getCount(time,user.getCompanyName()));//报警数量
dataVo.setBump(alarmLogServcie.getBumpCount(time,user.getCompanyName())); //获取颠簸数量 dataVo.setBump(alarmLogServcie.getBumpCount(time,user.getCompanyName())); //获取颠簸数量
dataVo.setAlarmLogVoList(alarmLogServcie.getAlarmLog(time,user.getCompanyName()));//报警列表 dataVo.setAlarmLogVoList(alarmLogServcie.getAlarmLog(time,user.getCompanyName()));//报警列表
List<HistogramData> list = alarmLogServcie.getByCount(time,user.getCompanyName());//获取报警柱状图 List<HistogramData> list = alarmLogServcie.getByCount(time,user.getCompanyName());//获取报警柱状图
for(int j = 0,length = list.size();j<length;j++){
if(list.get(j).getClassify().equals("5")){
Integer count = list.get(j).getCount() +delay;
list.get(j).setCount(count);
}
}
//获取设备的当前位置 //获取设备的当前位置
List<ResultCircuitVo> circuitVos = circuitService.getByTime(user.getCompanyName()); List<ResultCircuitVo> circuitVos = circuitService.getByTime(user.getCompanyName());
List<CircuitVo> circuitList = new ArrayList<>(); List<CircuitVo> circuitList = new ArrayList<>();
...@@ -142,9 +149,9 @@ public class HomePageController { ...@@ -142,9 +149,9 @@ public class HomePageController {
Long startTime = circuitVos.get(i).getStartTime() * 1000000l; Long startTime = circuitVos.get(i).getStartTime() * 1000000l;
String sql = ""; String sql = "";
if (circuitVos.get(i).getEndTime() == null || circuitVos.get(i).getEndTime() == 0) { if (circuitVos.get(i).getEndTime() == null || circuitVos.get(i).getEndTime() == 0) {
sql = "SELECT \"lng\",\"lat\" FROM \"tdl_policy\".\"" + device + "\"where time >= " + startTime + " ORDER BY time desc limit 1"; sql = "SELECT \"lng\",\"lat\" FROM \"tdl_policy\".\"" + device + "\"where \"lng\"!=0 and \"lat\"!=0 and time >= " + startTime + " ORDER BY time desc limit 1";
} else { } else {
sql = "SELECT \"lng\",\"lat\" FROM \"tdl_policy\".\"" + device + "\"where time >= " + startTime + " and time<= " + circuitVos.get(i).getEndTime() * 1000000l + " ORDER BY time desc limit 1"; sql = "SELECT \"lng\",\"lat\" FROM \"tdl_policy\".\"" + device + "\"where \"lng\"!=0 and \"lat\"!=0 and time >= " + startTime + " and time<= " + circuitVos.get(i).getEndTime() * 1000000l + " ORDER BY time desc limit 1";
} }
QueryResult queryResult = influxDBTemplate.query(new Query(sql, database)); QueryResult queryResult = influxDBTemplate.query(new Query(sql, database));
if (queryResult.getResults().get(0).getSeries() != null) { if (queryResult.getResults().get(0).getSeries() != null) {
......
package com.example.tdl.web.exception;
import com.example.tdl.domain.dto.CommFeedback;
import com.example.tdl.web.I18nController;
import com.google.gson.Gson;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.BadSqlGrammarException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import java.sql.SQLException;
@ControllerAdvice
@ResponseBody
public class GlobalExceptionHandler {
private Logger logger = LoggerFactory.getLogger(GlobalExceptionHandler.class);
private CommFeedback fb = new CommFeedback();
private Gson gson = new Gson();
@Autowired
private I18nController i18n;
@ExceptionHandler(value=Exception.class)
public String allExceptionHandler(HttpServletRequest request, Exception e) throws Exception {
e.printStackTrace();
if (e instanceof NullPointerException) {
logger.error("代码00:" + e.getMessage(), e);
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"null"));
} else if (e instanceof IllegalArgumentException) {
logger.error("代码01:" + e.getMessage(), e);
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"illegal"));
} else if (e instanceof SQLException) {
logger.error("代码02:" + e.getMessage(), e);
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"sql"));
} else if(e instanceof BadSqlGrammarException) {
logger.error("代码03:" + e.getMessage(), e);
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"badSql"));
}else{
logger.error("代码99:" + e.getMessage(), e);
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"error"));
}
return gson.toJson(fb);
}
}
...@@ -151,4 +151,12 @@ wrongAddressVoExpTime=The estimated arrival time of the current stopover cannot ...@@ -151,4 +151,12 @@ wrongAddressVoExpTime=The estimated arrival time of the current stopover cannot
systemManage=System Administrator systemManage=System Administrator
superManage=Super Administrator superManage=Super Administrator
warehouse=Warehouse Manager warehouse=Warehouse Manager
transportManage=Transport Manager transportManage=Transport Manager
\ No newline at end of file transportation=The mode of transportation cannot be empty
deliveryAddress=The place of delivery cannot be empty
transportationType=Transport type can not be empty
null=NullPointerException
illegal=IllegalArgumentException
sql=SQLException
badSql=BadSqlGrammarException
error=The server code has been exceptions, please contact the administrator
\ No newline at end of file
...@@ -150,4 +150,12 @@ wrongAddressVoExpTime=\u73FE\u5728\u306E\u30EB\u30FC\u30C8\u306E\u5230\u7740\u66 ...@@ -150,4 +150,12 @@ wrongAddressVoExpTime=\u73FE\u5728\u306E\u30EB\u30FC\u30C8\u306E\u5230\u7740\u66
systemManage=\u30B7\u30B9\u30C6\u30E0\u7BA1\u7406\u8005 systemManage=\u30B7\u30B9\u30C6\u30E0\u7BA1\u7406\u8005
superManage=\u30B9\u30FC\u30D1\u30FC\u7BA1\u7406\u8005 superManage=\u30B9\u30FC\u30D1\u30FC\u7BA1\u7406\u8005
warehouse=\u5009\u5EAB\u7BA1\u7406\u8005 warehouse=\u5009\u5EAB\u7BA1\u7406\u8005
transportManage=\u904B\u8F38\u7BA1\u7406\u8005 transportManage=\u904B\u8F38\u7BA1\u7406\u8005
\ No newline at end of file transportation=\u8F38\u9001\u65B9\u5F0F\u306F\u7A7A\u3063\u307D\u306B\u306A\u3089\u306A\u3044
deliveryAddress=\u6E21\u3059\u5834\u6240\u306F\u6687\u3067\u306F\u3042\u308A\u307E\u305B\u3093
transportationType=\u8F38\u9001\u30BF\u30A4\u30D7\u306F\u7A7A\u3051\u3066\u306F\u306A\u3089\u306A\u3044
null=\u7A7A\u306E\u91DD\u304C\u7570\u5E38\u306B\u767A\u751F\u3059\u308B
illegal=\u30D1\u30E9\u30E1\u30FC\u30BF\u30BF\u30A4\u30D7\u306E\u4E0D\u4E00\u81F4\u3092\u8981\u6C42\u3059\u308B
sql=\u30C7\u30FC\u30BF\u30D9\u30FC\u30B9\u30A2\u30AF\u30BB\u30B9\u7570\u5E38
badSql=\u30C7\u30FC\u30BF\u306E\u7570\u5E38
error=\u30B5\u30FC\u30D0\u30FC\u30B3\u30FC\u30C9\u304C\u7570\u5E38\u306B\u767A\u751F\u3057\u305F\u5834\u5408\u3001\u7BA1\u7406\u8005\u306B\u9023\u7D61\u3057\u3066\u304F\u3060\u3055\u3044
...@@ -73,6 +73,9 @@ notStarted = \u7EBF\u8DEF\u672A\u5F00\u59CB\u8FD0\u8F93 ...@@ -73,6 +73,9 @@ notStarted = \u7EBF\u8DEF\u672A\u5F00\u59CB\u8FD0\u8F93
notBound = \u8BE5\u7EBF\u8DEF\u672A\u7ED1\u5B9A\u7F51\u5173\u6216\u8005tdl notBound = \u8BE5\u7EBF\u8DEF\u672A\u7ED1\u5B9A\u7F51\u5173\u6216\u8005tdl
endCircuitSuccess =\u7EBF\u8DEF\u7ED3\u675F\u6210\u529F endCircuitSuccess =\u7EBF\u8DEF\u7ED3\u675F\u6210\u529F
endCircuitFailure =\u7EBF\u8DEF\u7ED3\u675F\u5931\u8D25 endCircuitFailure =\u7EBF\u8DEF\u7ED3\u675F\u5931\u8D25
transportation = \u8FD0\u8F93\u65B9\u5F0F\u4E0D\u80FD\u4E3A\u7A7A
deliveryAddress = \u4EA4\u4ED8\u5730\u70B9\u4E0D\u80FD\u4E3A\u7A7A
transportationType = \u8FD0\u8F93\u7C7B\u578B\u4E0D\u80FD\u4E3A\u7A7A
evaluate = \u8BC4\u4EF7\u7684\u7B49\u7EA7\u4E0D\u80FD\u4E3A\u7A7A evaluate = \u8BC4\u4EF7\u7684\u7B49\u7EA7\u4E0D\u80FD\u4E3A\u7A7A
completedCircuit = \u7EBF\u8DEF\u5B8C\u6210\u8FD0\u8F93\u624D\u80FD\u8BC4\u4EF7 completedCircuit = \u7EBF\u8DEF\u5B8C\u6210\u8FD0\u8F93\u624D\u80FD\u8BC4\u4EF7
evaluateSuccess = \u8BC4\u4EF7\u6210\u529F evaluateSuccess = \u8BC4\u4EF7\u6210\u529F
...@@ -158,4 +161,9 @@ systemManage = \u7CFB\u7EDF\u7BA1\u7406\u5458 ...@@ -158,4 +161,9 @@ systemManage = \u7CFB\u7EDF\u7BA1\u7406\u5458
superManage = \u8D85\u7EA7\u7BA1\u7406\u5458 superManage = \u8D85\u7EA7\u7BA1\u7406\u5458
warehouse = \u4ED3\u5E93\u7BA1\u7406\u5458 warehouse = \u4ED3\u5E93\u7BA1\u7406\u5458
transportManage = \u8FD0\u8F93\u7BA1\u7406\u5458 transportManage = \u8FD0\u8F93\u7BA1\u7406\u5458
null = \u53D1\u751F\u7A7A\u6307\u9488\u5F02\u5E38
illegal = \u8BF7\u6C42\u53C2\u6570\u7C7B\u578B\u4E0D\u5339\u914D
sql = \u6570\u636E\u5E93\u8BBF\u95EE\u5F02\u5E38
badSql = \u6570\u636E\u5F02\u5E38
error = \u670D\u52A1\u5668\u4EE3\u7801\u53D1\u751F\u5F02\u5E38,\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
(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 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 alarmType FROM alarm WHERE id IN (SELECT alarm_id from tdl_gateway_log WHERE transportationNo=c.transportationNo)) alarmType,
(select GROUP_CONCAT( DISTINCT classify) from alarm_log al where al.transportationNo = c.transportationNo) alarm,evaluate,transportation,plateNo, (select GROUP_CONCAT( DISTINCT classify) from alarm_log al where al.transportationNo = c.transportationNo) alarm,evaluate,transportation,plateNo,
(select DISTINCT gatewaySN from tdl_gateway_log WHERE transportationNo=c.transportationNo) gSN,(select DISTINCT gatewayType from tdl_gateway_log WHERE transportationNo=c.transportationNo) gType (select DISTINCT gatewaySN from tdl_gateway_log WHERE transportationNo=c.transportationNo) gSN,
(select DISTINCT gatewayType from tdl_gateway_log WHERE transportationNo=c.transportationNo) gType
from circuit c from circuit c
where c.state=1 where c.state=1
AND company_id=(SELECT id from company where companyName=#{companyName,jdbcType=VARCHAR}) AND company_id=(SELECT id from company where companyName=#{companyName,jdbcType=VARCHAR})
...@@ -222,7 +223,7 @@ ...@@ -222,7 +223,7 @@
(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 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 alarmType FROM alarm WHERE id IN (SELECT alarm_id from tdl_gateway_log WHERE transportationNo=c.transportationNo)) alarmType,
(select GROUP_CONCAT(DISTINCT classify) from alarm_log al where al.transportationNo = c.transportationNo) alarm,ifnull(evaluate,"") evaluate,transportation, (select GROUP_CONCAT(DISTINCT classify) from alarm_log al where al.transportationNo = c.transportationNo) alarm,ifnull(evaluate,"") evaluate,transportation,
(select gatewaySN FROM tdl_gateway_log WHERE transportationNo= #{transportationNo,jdbcType=VARCHAR} ) SN,(SELECT GROUP_CONCAT(TDLSN) FROM tdl_gateway_log WHERE transportationNo= #{transportationNo,jdbcType=VARCHAR}) TDLSN (select DISTINCT gatewaySN FROM tdl_gateway_log WHERE transportationNo= #{transportationNo,jdbcType=VARCHAR} ) SN,(SELECT GROUP_CONCAT(TDLSN) FROM tdl_gateway_log WHERE transportationNo= #{transportationNo,jdbcType=VARCHAR}) TDLSN
from circuit c from circuit c
where c.state=1 where c.state=1
AND c.transportationNo=#{transportationNo,jdbcType=VARCHAR} AND c.transportationNo=#{transportationNo,jdbcType=VARCHAR}
...@@ -235,7 +236,7 @@ ...@@ -235,7 +236,7 @@
(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 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 alarmType FROM alarm WHERE id IN (SELECT alarm_id from tdl_gateway_log WHERE transportationNo=c.transportationNo)) alarmType,
(select GROUP_CONCAT(DISTINCT classify) from alarm_log al where al.transportationNo = c.transportationNo) alarm,ifnull(evaluate,"") evaluate,transportation, (select GROUP_CONCAT(DISTINCT classify) from alarm_log al where al.transportationNo = c.transportationNo) alarm,ifnull(evaluate,"") evaluate,transportation,
(select gatewaySN FROM tdl_gateway_log WHERE transportationNo= #{transportationNo,jdbcType=VARCHAR} ) SN,(SELECT GROUP_CONCAT(TDLSN) FROM tdl_gateway_log WHERE transportationNo= #{transportationNo,jdbcType=VARCHAR}) TDLSN (select DISTINCT gatewaySN FROM tdl_gateway_log WHERE transportationNo= #{transportationNo,jdbcType=VARCHAR} ) SN,(SELECT GROUP_CONCAT(TDLSN) FROM tdl_gateway_log WHERE transportationNo= #{transportationNo,jdbcType=VARCHAR}) TDLSN
from circuit c from circuit c
where c.state=1 where c.state=1
and c.transportationNo=#{transportationNo,jdbcType=VARCHAR} and c.transportationNo=#{transportationNo,jdbcType=VARCHAR}
...@@ -244,7 +245,9 @@ ...@@ -244,7 +245,9 @@
<!--根据线路编号获取线路信息 app--> <!--根据线路编号获取线路信息 app-->
<select id="getByTransportationNoForApp" resultType="com.example.tdl.domain.vo.ResultCircuitForAppVo" parameterType="String"> <select id="getByTransportationNoForApp" resultType="com.example.tdl.domain.vo.ResultCircuitForAppVo" parameterType="String">
SELECT c.transportationNo,cargoName,CONCAT_WS("-",(SELECT city from city WHERE id =(SELECT city_id from circuit_transfer WHERE circuit_id=c.id AND sequence =LEFT(s.sequence,1))),(SELECT city from city WHERE id =(SELECT city_id from circuit_transfer WHERE circuit_id=c.id AND sequence=RIGHT(s.sequence,1)))) city, SELECT c.transportationNo,cargoName,CONCAT_WS("-",(SELECT city from city WHERE id =(SELECT city_id from circuit_transfer WHERE circuit_id=c.id AND sequence =LEFT(s.sequence,1))),(SELECT city from city WHERE id =(SELECT city_id from circuit_transfer WHERE circuit_id=c.id AND sequence=RIGHT(s.sequence,1)))) city,
expTime,compTime,cargoNo,plateNo,deliveryAddress,transportation,transportationType,(select gatewaySN FROM tdl_gateway_log WHERE transportationNo= #{transportationNo,jdbcType=VARCHAR} ) SN,(SELECT GROUP_CONCAT(TDLSN) FROM tdl_gateway_log WHERE transportationNo= #{transportationNo,jdbcType=VARCHAR}) TDLSN,remark expTime,compTime,cargoNo,plateNo,deliveryAddress,transportation,transportationType,
(select DISTINCT gatewaySN FROM tdl_gateway_log WHERE transportationNo= #{transportationNo,jdbcType=VARCHAR} ) SN,
(SELECT GROUP_CONCAT(TDLSN) FROM tdl_gateway_log WHERE transportationNo= #{transportationNo,jdbcType=VARCHAR}) TDLSN,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 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 where c.state=1
AND c.transportationNo=#{transportationNo,jdbcType=VARCHAR} AND c.transportationNo=#{transportationNo,jdbcType=VARCHAR}
...@@ -341,7 +344,8 @@ ...@@ -341,7 +344,8 @@
<select id="getMessage" parameterType="String" resultType="com.example.tdl.domain.vo.CircuitMessage"> <select id="getMessage" parameterType="String" resultType="com.example.tdl.domain.vo.CircuitMessage">
select c.transportationNo,CONCAT_WS("-",(SELECT city from city WHERE id =(SELECT city_id from circuit_transfer WHERE circuit_id=c.id AND sequence =LEFT(s.sequence,1))),(SELECT city from city WHERE id =(SELECT city_id from circuit_transfer WHERE circuit_id=c.id AND sequence=RIGHT(s.sequence,1)))) routeName, select c.transportationNo,CONCAT_WS("-",(SELECT city from city WHERE id =(SELECT city_id from circuit_transfer WHERE circuit_id=c.id AND sequence =LEFT(s.sequence,1))),
(SELECT city from city WHERE id =(SELECT city_id from circuit_transfer WHERE circuit_id=c.id AND sequence=RIGHT(s.sequence,1)))) routeName,
cargoName,plateNo,transportation,IFNULL(evaluate,"") evaluate,circuitState,startTime,endTime, cargoName,plateNo,transportation,IFNULL(evaluate,"") evaluate,circuitState,startTime,endTime,
(SELECT alarmType FROM alarm WHERE id IN (SELECT alarm_id from tdl_gateway_log WHERE transportationNo=c.transportationNo)) alarmType (SELECT alarmType FROM alarm WHERE id IN (SELECT alarm_id from tdl_gateway_log WHERE transportationNo=c.transportationNo)) alarmType
from circuit c,(SELECT GROUP_CONCAT(sequence) sequence from circuit_transfer where circuit_id=(SELECT id from circuit where transportationNo=#{transportationNo,jdbcType=VARCHAR})) s from circuit c,(SELECT GROUP_CONCAT(sequence) sequence from circuit_transfer where circuit_id=(SELECT id from circuit where transportationNo=#{transportationNo,jdbcType=VARCHAR})) s
......
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