Commit a2d311e5 authored by zhuangzhuang's avatar zhuangzhuang

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

parent 7f3645d4
......@@ -73,6 +73,16 @@ public class CircuitMessageVo {
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() {
return transportationNo;
}
......
......@@ -23,6 +23,7 @@ import org.springframework.data.influxdb.InfluxDBTemplate;
import org.springframework.web.bind.annotation.*;
import javax.print.DocFlavor;
import javax.print.attribute.standard.RequestingUserName;
import javax.servlet.http.HttpServletRequest;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
......@@ -171,6 +172,11 @@ public class CircuitController {
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
if(StringUtils.isEmpty(transportationNo)){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"transportationNo"));
return gson.toJson(fb);
}
JSONObject jsonObject=JSON.parseObject(transportationNo);
transportationNo=(String) jsonObject.get("transportationNo");
return circuitService.getByTransportationNo(transportationNo,user.getCompanyName());
......@@ -201,6 +207,11 @@ public class CircuitController {
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
if(StringUtils.isEmpty(transportationNo)){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"transportationNo"));
return gson.toJson(fb);
}
JSONObject jsonObject=JSON.parseObject(transportationNo);
transportationNo=(String) jsonObject.get("transportationNo");
ResultCircuitForAppVo resultCircuitForAppVo=circuitService.getByTransportationNoForApp(transportationNo,user.getCompanyName());
......@@ -299,17 +310,9 @@ public class CircuitController {
})
@PostMapping("/getDetails")
public Object getDetails(@RequestBody String transportationNo,HttpServletRequest request) {
String port = request.getHeader("AccountLanguage");
if(StringUtils.isEmpty(transportationNo)){
fb.setCode(0);
if(!StringUtils.isEmpty(port) &&port.equals("en")){
fb.setMessage("The number of goods can not be empty");
}else if(!StringUtils.isEmpty(port) &&port.equals("jp")) {
fb.setMessage("輸送番号 を入力してください。");
}else{
fb.setMessage("线路编号不能为空");
}
fb.setMessage(i18n.getMessage(request,"wrongTime"));
fb.setMessage(i18n.getMessage(request,"transportationNo"));
return gson.toJson(fb);
}
JSONObject jsonObject= JSON.parseObject(transportationNo);
......@@ -318,32 +321,27 @@ public class CircuitController {
CircuitMessage circuitVo = circuitService.getMessage(transportationNo);
if(circuitVo == null){
fb.setCode(0);
if(!StringUtils.isEmpty(port) &&port.equals("en")){
fb.setMessage("There is no such line");
} else if(!StringUtils.isEmpty(port) &&port.equals("jp")){
fb.setMessage("ルートが存在していません");
}else{
fb.setMessage("没有该线路");
}
fb.setMessage(i18n.getMessage(request,"wrongTime"));
fb.setMessage(i18n.getMessage(request,"noCircuit"));
return gson.toJson(fb);
}
CircuitMessageVo messageVo = new CircuitMessageVo(circuitVo.getTransportationNo(),circuitVo.getRouteName(),circuitVo.getCargoName(),circuitVo.getPlateNo(),circuitVo.getTransportation(),circuitVo.getEvaluate(),circuitVo.getAlarmType());
//获取gateway信息
TDLLogVo gatewayVo = tdlLogService.getByTransportationNo(transportationNo);
if(gatewayVo == null){
fb.setCode(0);
if(!StringUtils.isEmpty(port) &&port.equals("en")){
fb.setMessage("There is no such line");
} else if(!StringUtils.isEmpty(port) &&port.equals("jp")){
fb.setMessage("ルートが存在していません");
}else{
fb.setMessage("没有该线路");
}
fb.setMessage(i18n.getMessage(request,"wrongTime"));
return gson.toJson(fb);
}
List<ResultAlarmLog> alarmLogList= alarmLogService.getByTransportationNo(transportationNo);
CircuitMessageVo messageVo = new CircuitMessageVo(circuitVo.getTransportationNo(),circuitVo.getRouteName(),circuitVo.getCargoName(),circuitVo.getPlateNo(),circuitVo.getTransportation(),circuitVo.getEvaluate(),circuitVo.getAlarmType(),gatewayVo.getgSN(),alarmLogList);
List<String> TDL= tdlLogService.getTdlSN(transportationNo);
List<ResultAlarmLog> alarmLogList = new ArrayList<>();
List<CircuitMessageVo.TDL> tdlList = new ArrayList<>();
List<ResultCityVo> cityVoList = new ArrayList<>();
if(gatewayVo == null || TDL.size() == 0){
messageVo.setSN("");
messageVo.setBattery("");
messageVo.setAlarmLogList(alarmLogList);
messageVo.setTdlList(tdlList);
messageVo.setList(cityVoList);
return gson.toJson(messageVo);
}
messageVo.setSN(gatewayVo.getgSN());
alarmLogList= alarmLogService.getByTransportationNo(transportationNo);
messageVo.setAlarmLogList(alarmLogList);
String sql ="";
if (circuitVo.getEndTime() != null && circuitVo.getEndTime() != 0) {
sql = "SELECT \"battery\" FROM \"tdl_policy\".\"" + gatewayVo.getgType() + "_" + gatewayVo.getgSN() + "\" where time >=" + circuitVo.getStartTime() + " and time<=" + circuitVo.getEndTime() * 1000000l + " ORDER BY time desc limit 1";
......@@ -358,20 +356,6 @@ public class CircuitController {
String value = queryResult.getResults().get(0).getSeries().get(0).getValues().get(0).get(1) == null ? "" : queryResult.getResults().get(0).getSeries().get(0).getValues().get(0).get(1).toString();
messageVo.setBattery(df.format(Double.valueOf(value)));
}
List<String> TDL= tdlLogService.getTdlSN(transportationNo);
if(TDL.size() == 0){
fb.setCode(0);
if(!StringUtils.isEmpty(port) &&port.equals("en")){
fb.setMessage("There is no such line");
} else if(!StringUtils.isEmpty(port) &&port.equals("jp")){
fb.setMessage("ルートが存在していません");
}else{
fb.setMessage("没有该线路");
}
fb.setMessage(i18n.getMessage(request,"wrongTime"));
return gson.toJson(fb);
}
List<CircuitMessageVo.TDL> tdlList = new ArrayList<>();
for(int i=0;i<TDL.size();i++){
CircuitMessageVo.TDL tdl = new CircuitMessageVo.TDL();
tdl.setTdlsn(TDL.get(i).replace("TDL-", "").trim());
......@@ -398,18 +382,9 @@ public class CircuitController {
messageVo.setTdlList(tdlList);
//获取线路情况
List<CircuitTransferVo> list =circuitTransferService.getCity(transportationNo);
List<ResultCityVo> cityVoList = new ArrayList<>();
if(list == null){
fb.setCode(0);
if(port.equals("en")){
fb.setMessage("There is no such line");
} else if(port.equals("jp")){
fb.setMessage("ルートが存在していません");
}else{
fb.setMessage("没有该线路");
}
fb.setMessage(i18n.getMessage(request,"wrongTime"));
return gson.toJson(fb);
messageVo.setList(cityVoList);
return gson.toJson(messageVo);
}
for (int i = 0; i < list.size(); i++) {
if (list.get(i).getSequence() == 1) {
......@@ -533,11 +508,17 @@ public class CircuitController {
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
if(StringUtils.isEmpty(plateNo)){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"plateNo"));
return gson.toJson(fb);
}
JSONObject jsonObject= JSON.parseObject(plateNo);
plateNo=(String)jsonObject.get("plateNo");
return circuitService.getByPlateNo(plateNo,user.getCompanyName());
}
//添加线路信息
@ApiOperation(value = "添加线路信息",notes = "添加线路信息," +
" startAddressVo: 线路集合,包含" +
......@@ -592,7 +573,6 @@ public class CircuitController {
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
ResultCompanyVo companyVo = companyService.getByCompanyName(user.getCompanyName());
String port = request.getHeader("AccountLanguage");
if(StringUtils.isEmpty(addCircuitVo.getStartAddressVo().getCountry())){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"startCountry"));
......@@ -730,16 +710,6 @@ public class CircuitController {
arrivalTimeVar = arrivalTimeVar +"0 ";
}
}
countryVar=countryVar +addCircuitVo.getEndAddressVo().getCountry() +" ";
cityVar=cityVar +addCircuitVo.getEndAddressVo().getCity() +" ";
addressDetailVar =addressDetailVar +addCircuitVo.getEndAddressVo().getAddressDetail() +" ";
lngVar = lngVar + addCircuitVo.getEndAddressVo().getLng() +" ";
latVar = latVar + addCircuitVo.getEndAddressVo().getLat() +" ";
postCodeVar=postCodeVar + addCircuitVo.getEndAddressVo().getPostCode() +" ";
expTimeVar = expTimeVar +"0 ";
compTimeVar = compTimeVar +addCircuitVo.getEndAddressVo().getCompTime() +" ";
startTimeVar =startTimeVar + "0 ";
arrivalTimeVar = arrivalTimeVar +"0 ";
if(StringUtils.isEmpty(addCircuitVo.getEndAddressVo().getCountry())){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"endCountry"));
......@@ -795,7 +765,16 @@ public class CircuitController {
fb.setMessage(i18n.getMessage(request,"gateway"));
return gson.toJson(fb);
}
countryVar=countryVar +addCircuitVo.getEndAddressVo().getCountry() +" ";
cityVar=cityVar +addCircuitVo.getEndAddressVo().getCity() +" ";
addressDetailVar =addressDetailVar +addCircuitVo.getEndAddressVo().getAddressDetail() +" ";
lngVar = lngVar + addCircuitVo.getEndAddressVo().getLng() +" ";
latVar = latVar + addCircuitVo.getEndAddressVo().getLat() +" ";
postCodeVar=postCodeVar + addCircuitVo.getEndAddressVo().getPostCode() +" ";
expTimeVar = expTimeVar +"0 ";
compTimeVar = compTimeVar +addCircuitVo.getEndAddressVo().getCompTime() +" ";
startTimeVar =startTimeVar + "0 ";
arrivalTimeVar = arrivalTimeVar +"0 ";
String type =gatewayService.getBySN(addCircuitVo.getSN());
//判断当前gateWay是否存在
if(StringUtils.isEmpty(type)){
......@@ -957,280 +936,124 @@ public class CircuitController {
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
int port = request.getServerPort();
if(StringUtils.isEmpty(addCircuitVo.getCargoNo())){
fb.setCode(0);
if(port == 58080){
fb.setMessage("货物编号不能为空");
}else if(port == 58081){
}else if (port == 58082){
}
fb.setMessage(i18n.getMessage(request,"cargoNo"));
return gson.toJson(fb);
}
if(StringUtils.isEmpty(addCircuitVo.getPlateNo())){
fb.setCode(0);
if(port == 58080){
fb.setMessage("车牌号不能为空");
}else if(port == 58081){
}else if (port == 58082){
}
fb.setMessage(i18n.getMessage(request,"plateNo"));
return gson.toJson(fb);
}
if(StringUtils.isEmpty(addCircuitVo.getCargoName())){
fb.setCode(0);
if(port == 58080){
fb.setMessage("货物别名不能为空");
}else if(port == 58081){
}else if (port == 58082){
}
fb.setMessage(i18n.getMessage(request,"cargoName"));
return gson.toJson(fb);
}
if(StringUtils.isEmpty(addCircuitVo.getTransportation())){
fb.setCode(0);
if(port == 58080){
fb.setMessage("运输方式不能为空");
}else if(port == 58081){
}else if (port == 58082){
}
fb.setMessage(i18n.getMessage(request,"transportation"));
return gson.toJson(fb);
}
if(StringUtils.isEmpty(addCircuitVo.getStartAddressVo().getCountry())){
fb.setCode(0);
if(port == 58080){
fb.setMessage("出发国家不能为空");
}else if(port == 58081){
}else if (port == 58082){
}
fb.setMessage(i18n.getMessage(request,"startCountry"));
return gson.toJson(fb);
}
if (StringUtils.isEmpty(addCircuitVo.getStartAddressVo().getCity())){
fb.setCode(0);
if(port == 58080){
fb.setMessage("出发城市不能为空");
}else if(port == 58081){
}else if (port == 58082){
}
fb.setMessage(i18n.getMessage(request,"startCity"));
return gson.toJson(fb);
}
if (StringUtils.isEmpty(addCircuitVo.getStartAddressVo().getAddressDetail())){
fb.setCode(0);
if(port == 58080){
fb.setMessage("出发具体地址不能为空");
}else if(port == 58081){
}else if (port == 58082){
}
fb.setMessage(i18n.getMessage(request,"startAddressDetail"));
return gson.toJson(fb);
}
if (StringUtils.isEmpty(addCircuitVo.getStartAddressVo().getLat())){
fb.setCode(0);
if(port == 58080){
fb.setMessage("出发地纬度不能为空");
}else if(port == 58081){
}else if (port == 58082){
}
fb.setMessage(i18n.getMessage(request,"startLat"));
return gson.toJson(fb);
}
if(!addCircuitVo.getStartAddressVo().getLat().matches("^-?(([1-9])((\\.\\d{1,6})?)|([1-8]\\d)((\\.\\d{1,6})?)|90)$")){
fb.setCode(0);
if(port == 58080){
fb.setMessage("出发地纬度的范围为-90~90");
}else if(port == 58081){
}else if (port == 58082){
}
fb.setMessage(i18n.getMessage(request,"wrongStartLat"));
return gson.toJson(fb);
}
if (StringUtils.isEmpty(addCircuitVo.getStartAddressVo().getLng())){
fb.setCode(0);
if(port == 58080){
fb.setMessage("出发地经度不能为空");
}else if(port == 58081){
}else if (port == 58082){
}
fb.setMessage(i18n.getMessage(request,"startLng"));
return gson.toJson(fb);
}
if(!addCircuitVo.getStartAddressVo().getLng().matches("^-?(([1-9]\\d?)((\\.\\d{1,6})?)|(1[1-7]\\d)((\\.\\d{1,6})?)|180)$")) {
fb.setCode(0);
if(port == 58080){
fb.setMessage("出发地纬度的范围为-90~90");
}else if(port == 58081){
}else if (port == 58082){
}
fb.setMessage(i18n.getMessage(request,"wrongStartLng"));
return gson.toJson(fb);
}
if (StringUtils.isEmpty(addCircuitVo.getStartAddressVo().getPostCode())){
fb.setCode(0);
if(port == 58080){
fb.setMessage("出发地邮编不能为空");
}else if(port == 58081){
}else if (port == 58082){
}
fb.setMessage(i18n.getMessage(request,"startPostCode"));
return gson.toJson(fb);
}
if (addCircuitVo.getStartAddressVo().getExpTime()==null){
fb.setCode(0);
if(port == 58080){
fb.setMessage("出发地预计出发时间不能为空");
}else if(port == 58081){
}else if (port == 58082){
}
fb.setMessage(i18n.getMessage(request,"starExpTime"));
return gson.toJson(fb);
}
if(StringUtils.isEmpty(addCircuitVo.getEndAddressVo().getCountry())){
fb.setCode(0);
if(port == 58080){
fb.setMessage("目的地国家不能为空");
}else if(port == 58081){
}else if (port == 58082){
}
fb.setMessage(i18n.getMessage(request,"endCountry"));
return gson.toJson(fb);
}
if (StringUtils.isEmpty(addCircuitVo.getEndAddressVo().getCity())){
fb.setCode(0);
if(port == 58080){
fb.setMessage("目的地城市不能为空");
}else if(port == 58081){
}else if (port == 58082){
}
fb.setMessage(i18n.getMessage(request,"endCity"));
return gson.toJson(fb);
}
if (StringUtils.isEmpty(addCircuitVo.getEndAddressVo().getAddressDetail())){
fb.setCode(0);
if(port == 58080){
fb.setMessage("目的地具体地址不能为空");
}else if(port == 58081){
}else if (port == 58082){
}
fb.setMessage(i18n.getMessage(request,"endAddressDetail"));
return gson.toJson(fb);
}
if (StringUtils.isEmpty(addCircuitVo.getEndAddressVo().getLat())){
fb.setCode(0);
if(port == 58080){
fb.setMessage("目的地纬度不能为空");
}else if(port == 58081){
}else if (port == 58082){
}
fb.setMessage(i18n.getMessage(request,"endLat"));
return gson.toJson(fb);
}
if(!addCircuitVo.getEndAddressVo().getLat().matches("^-?(([1-9])((\\.\\d{1,6})?)|([1-8]\\d)((\\.\\d{1,6})?)|90)$")){
fb.setCode(0);
if(port == 58080){
fb.setMessage("目的地纬度的范围为-90~90");
}else if(port == 58081){
}else if (port == 58082){
}
fb.setMessage(i18n.getMessage(request,"wrongEndLat"));
return gson.toJson(fb);
}
if (StringUtils.isEmpty(addCircuitVo.getEndAddressVo().getLng())){
fb.setCode(0);
if(port == 58080){
fb.setMessage("目的地经度不能为空");
}else if(port == 58081){
}else if (port == 58082){
}
fb.setMessage(i18n.getMessage(request,"endLng"));
return gson.toJson(fb);
}
if(!addCircuitVo.getEndAddressVo().getLng().matches("^-?(([1-9]\\d?)((\\.\\d{1,6})?)|(1[1-7]\\d)((\\.\\d{1,6})?)|180)$")) {
fb.setCode(0);
if(port == 58080){
fb.setMessage("目的地经度的范围为-180~180");
}else if(port == 58081){
}else if (port == 58082){
}
fb.setMessage(i18n.getMessage(request,"wrongEndLng"));
return gson.toJson(fb);
}
if (StringUtils.isEmpty(addCircuitVo.getEndAddressVo().getPostCode())){
fb.setCode(0);
if(port == 58080){
fb.setMessage("目的地邮编不能为空");
}else if(port == 58081){
}else if (port == 58082){
}
fb.setMessage(i18n.getMessage(request,"endPostCode"));
return gson.toJson(fb);
}
if (addCircuitVo.getEndAddressVo().getCompTime()==null){
fb.setCode(0);
if(port == 58080){
fb.setMessage("目的地预计到达时间不能为空");
}else if(port == 58081){
}else if (port == 58082){
}
fb.setMessage(i18n.getMessage(request,"endCompTime"));
return gson.toJson(fb);
}
if(StringUtils.isEmpty(addCircuitVo.getDeliveryAddress())){
fb.setCode(0);
if(port == 58080){
fb.setMessage("交付地点不能为空");
}else if(port == 58081){
}else if (port == 58082){
}
fb.setMessage(i18n.getMessage(request,"deliveryAddress"));
return gson.toJson(fb);
}
if(StringUtils.isEmpty(addCircuitVo.getTransportationType())){
fb.setCode(0);
if(port == 58080){
fb.setMessage("运输类型不能为空");
}else if(port == 58081){
}else if (port == 58082){
}
fb.setMessage(i18n.getMessage(request,"transportationType"));
return gson.toJson(fb);
}
Long time = System.currentTimeMillis();
......@@ -1274,24 +1097,10 @@ public class CircuitController {
msg.put("msg",map.get("msg"));
if (msg.get("msg").equals("线路添加成功")){
fb.setCode(1);
if(port == 58080){
fb.setMessage("添加线路成功");
}else if(port == 58081){
}else if (port == 58082){
}
fb.setMessage(i18n.getMessage(request,"circuitSuccess"));
}else {
fb.setCode(0);
if(port == 58080){
fb.setMessage(msg.get("msg").toString());
}else if(port == 58081){
}else if (port == 58082){
}
fb.setMessage(i18n.getMessage(request,"circuitFailure"));
}
return gson.toJson(fb);
}
......@@ -1311,7 +1120,6 @@ public class CircuitController {
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
String port = request.getHeader("AccountLanguage");
ResultCompanyVo companyVo = companyService.getByCompanyName(user.getCompanyName());
if (StringUtils.isEmpty(updateCircuitVo.getTransportationNo())){
fb.setCode(0);
......@@ -1323,7 +1131,6 @@ public class CircuitController {
fb.setMessage(i18n.getMessage(request,"noCircuit"));
return gson.toJson(fb);
}
if (updateCircuitVo.getEndTime()==null){
updateCircuitVo.setEndTime(System.currentTimeMillis());
}
......@@ -1418,7 +1225,6 @@ public class CircuitController {
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
String port = request.getHeader("AccountLanguage");
if (StringUtils.isEmpty(updateEvaluateVo.getTransportationNo())){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"transportationNo"));
......@@ -1476,7 +1282,6 @@ public class CircuitController {
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
String port = request.getHeader("AccountLanguage");
if (!map.containsKey("circuitState")){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"circuitState"));
......@@ -1498,7 +1303,6 @@ public class CircuitController {
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
String port = request.getHeader("AccountLanguage");
if (StringUtils.isEmpty(transportationNo)){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"transportationNo"));
......@@ -1609,7 +1413,6 @@ public class CircuitController {
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
String port = request.getHeader("AccountLanguage");
if (StringUtils.isEmpty(startCircuitVo.getTransportationNo())){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"transportationNo"));
......
......@@ -107,11 +107,18 @@ public class HomePageController {
dataVo.setSum(circuitService.getCount(time,System.currentTimeMillis()/1000l,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.setBump(alarmLogServcie.getBumpCount(time,user.getCompanyName())); //获取颠簸数量
dataVo.setAlarmLogVoList(alarmLogServcie.getAlarmLog(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<CircuitVo> circuitList = new ArrayList<>();
......@@ -142,9 +149,9 @@ public class HomePageController {
Long startTime = circuitVos.get(i).getStartTime() * 1000000l;
String sql = "";
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 {
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));
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
systemManage=System Administrator
superManage=Super Administrator
warehouse=Warehouse Manager
transportManage=Transport Manager
\ No newline at end of file
transportManage=Transport Manager
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
systemManage=\u30B7\u30B9\u30C6\u30E0\u7BA1\u7406\u8005
superManage=\u30B9\u30FC\u30D1\u30FC\u7BA1\u7406\u8005
warehouse=\u5009\u5EAB\u7BA1\u7406\u8005
transportManage=\u904B\u8F38\u7BA1\u7406\u8005
\ No newline at end of file
transportManage=\u904B\u8F38\u7BA1\u7406\u8005
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
notBound = \u8BE5\u7EBF\u8DEF\u672A\u7ED1\u5B9A\u7F51\u5173\u6216\u8005tdl
endCircuitSuccess =\u7EBF\u8DEF\u7ED3\u675F\u6210\u529F
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
completedCircuit = \u7EBF\u8DEF\u5B8C\u6210\u8FD0\u8F93\u624D\u80FD\u8BC4\u4EF7
evaluateSuccess = \u8BC4\u4EF7\u6210\u529F
......@@ -158,4 +161,9 @@ systemManage = \u7CFB\u7EDF\u7BA1\u7406\u5458
superManage = \u8D85\u7EA7\u7BA1\u7406\u5458
warehouse = \u4ED3\u5E93\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 @@
(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( 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
where c.state=1
AND company_id=(SELECT id from company where companyName=#{companyName,jdbcType=VARCHAR})
......@@ -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 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 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
where c.state=1
AND c.transportationNo=#{transportationNo,jdbcType=VARCHAR}
......@@ -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 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 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
where c.state=1
and c.transportationNo=#{transportationNo,jdbcType=VARCHAR}
......@@ -244,7 +245,9 @@
<!--根据线路编号获取线路信息 app-->
<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,
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
where c.state=1
AND c.transportationNo=#{transportationNo,jdbcType=VARCHAR}
......@@ -341,7 +344,8 @@
<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,
(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
......
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