Commit 497ef35e authored by chenying's avatar chenying

3.23添加查询线路报警接口

parent ff916343
package com.example.tdl.domain.vo;
public class AddUserRouteVo {
private String name;
private String country;
private String province;
private String city;
private String address;
private String longitude;
private String latitude;
private String remark;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getProvince() {
return province;
}
public void setProvince(String province) {
this.province = province;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getLongitude() {
return longitude;
}
public void setLongitude(String longitude) {
this.longitude = longitude;
}
public String getLatitude() {
return latitude;
}
public void setLatitude(String latitude) {
this.latitude = latitude;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
}
package com.example.tdl.domain.vo;
public class CircuitAlarmVo {
private String time;
private String tdl;
private String shockEnergy;
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
public String getTdl() {
return tdl;
}
public void setTdl(String tdl) {
this.tdl = tdl;
}
public String getShockEnergy() {
return shockEnergy;
}
public void setShockEnergy(String shockEnergy) {
this.shockEnergy = shockEnergy;
}
}
...@@ -45,6 +45,26 @@ public class ResultCircuitVo { ...@@ -45,6 +45,26 @@ public class ResultCircuitVo {
private String createTime; private String createTime;
private String evaluate;
private String evaluateRemark;
public String getEvaluate() {
return evaluate;
}
public void setEvaluate(String evaluate) {
this.evaluate = evaluate;
}
public String getEvaluateRemark() {
return evaluateRemark;
}
public void setEvaluateRemark(String evaluateRemark) {
this.evaluateRemark = evaluateRemark;
}
public String getCreateTime() { public String getCreateTime() {
return createTime; return createTime;
} }
......
package com.example.tdl.domain.vo;
public class ResultUserRouteVo {
private String userNumber;
private String userName;
private String name;
private String country;
private String province;
private String city;
private String address;
private String longitude;
private String latitude;
private String remark;
public String getUserNumber() {
return userNumber;
}
public void setUserNumber(String userNumber) {
this.userNumber = userNumber;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getProvince() {
return province;
}
public void setProvince(String province) {
this.province = province;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getLongitude() {
return longitude;
}
public void setLongitude(String longitude) {
this.longitude = longitude;
}
public String getLatitude() {
return latitude;
}
public void setLatitude(String latitude) {
this.latitude = latitude;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
}
package com.example.tdl.domain.vo;
public class UpdateEvaluateVo {
private String transportationNo;
private Float evaluate;
private String evaluateRemark;
public String getTransportationNo() {
return transportationNo;
}
public void setTransportationNo(String transportationNo) {
this.transportationNo = transportationNo;
}
public Float getEvaluate() {
return evaluate;
}
public void setEvaluate(Float evaluate) {
this.evaluate = evaluate;
}
public String getEvaluateRemark() {
return evaluateRemark;
}
public void setEvaluateRemark(String evaluateRemark) {
this.evaluateRemark = evaluateRemark;
}
}
package com.example.tdl.domain.vo;
public class UpdateUserRouteVo {
private String oldName;
private String name;
private String country;
private String province;
private String city;
private String address;
private String longitude;
private String latitude;
private String remark;
public String getOldName() {
return oldName;
}
public void setOldName(String oldName) {
this.oldName = oldName;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getProvince() {
return province;
}
public void setProvince(String province) {
this.province = province;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getLongitude() {
return longitude;
}
public void setLongitude(String longitude) {
this.longitude = longitude;
}
public String getLatitude() {
return latitude;
}
public void setLatitude(String latitude) {
this.latitude = latitude;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
}
...@@ -5,7 +5,21 @@ public class UserRoute { ...@@ -5,7 +5,21 @@ public class UserRoute {
private String userNumber; private String userNumber;
private String routeNumber; private String name;
private String country;
private String province;
private String city;
private String address;
private String longitude;
private String latitude;
private String remark;
public Integer getId() { public Integer getId() {
return id; return id;
...@@ -23,11 +37,67 @@ public class UserRoute { ...@@ -23,11 +37,67 @@ public class UserRoute {
this.userNumber = userNumber; this.userNumber = userNumber;
} }
public String getRouteNumber() { public String getName() {
return routeNumber; return name;
}
public void setName(String name) {
this.name = name;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getProvince() {
return province;
}
public void setProvince(String province) {
this.province = province;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getLongitude() {
return longitude;
}
public void setLongitude(String longitude) {
this.longitude = longitude;
}
public String getLatitude() {
return latitude;
}
public void setLatitude(String latitude) {
this.latitude = latitude;
}
public String getRemark() {
return remark;
} }
public void setRouteNumber(String routeNumber) { public void setRemark(String remark) {
this.routeNumber = routeNumber; this.remark = remark;
} }
} }
...@@ -33,4 +33,10 @@ public interface CircuitMapper { ...@@ -33,4 +33,10 @@ public interface CircuitMapper {
Integer getCount(); Integer getCount();
List<CircuitVo> getByTime(String time); List<CircuitVo> getByTime(String time);
List<ResultCircuitVo> getByContainerNo(String containerNo);
int updateEvaluate(UpdateEvaluateVo updateEvaluateVo);
List<ResultCircuitVo> getByCircuitState(Integer circuitState);
} }
package com.example.tdl.mapper;
import com.example.tdl.domain.vo.ResultUserRouteVo;
import com.example.tdl.domain.vo.RoleNameVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
@Mapper
public interface UserRouteMapper {
List<ResultUserRouteVo> getByUserNumber(String userNumber);
int addUserRoute(Map<Object,Object> map);
int updateUserRoute(Map<Object,Object> map);
int delUserRoute(@Param("userNumber") String userNumber,@Param("name") String name);
ResultUserRouteVo getByUserNumberAndName(@Param("userNumber") String userNumber,@Param("name") String name);
}
...@@ -35,7 +35,7 @@ import java.util.concurrent.TimeUnit; ...@@ -35,7 +35,7 @@ import java.util.concurrent.TimeUnit;
public class MqttListener implements MqttCallback { public class MqttListener implements MqttCallback {
private static final int INIT_DELAY_DEFAULT = 1000; // unit:ms private static final int INIT_DELAY_DEFAULT = 1000; // unit:ms
private static final int SCH_PERIOD_DEFAULT = 10 * INIT_DELAY_DEFAULT; // unit:ms private static final int SCH_PERIOD_DEFAULT = 10 * INIT_DELAY_DEFAULT; // unit:ms
private static final String CHECKIN_TOPIC = "GW/+/+/CheckIn"; private static final String CHECKIN_TOPIC = "TDL/+/+/CheckIn";
private MqttTemlateAsync mqttAsyncClient; private MqttTemlateAsync mqttAsyncClient;
......
...@@ -68,4 +68,16 @@ public class CircuitService { ...@@ -68,4 +68,16 @@ public class CircuitService {
return circuitMapper.getByTime(time); return circuitMapper.getByTime(time);
} }
public List<ResultCircuitVo> getByContainerNo(String containerNo){
return circuitMapper.getByContainerNo(containerNo);
}
public int updateEvaluate(UpdateEvaluateVo updateEvaluateVo){
return circuitMapper.updateEvaluate(updateEvaluateVo);
}
public List<ResultCircuitVo> getByCircuitState(Integer circuitState){
return circuitMapper.getByCircuitState(circuitState);
}
} }
package com.example.tdl.service;
import com.example.tdl.domain.vo.ResultUserRouteVo;
import com.example.tdl.mapper.UserRouteMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
@Service
public class UserRouteService {
@Autowired
private UserRouteMapper userRouteMapper;
public List<ResultUserRouteVo> getByUserNumber(String userNumber){
return userRouteMapper.getByUserNumber(userNumber);
}
public int addUserRoute(Map<Object,Object> map){
return userRouteMapper.addUserRoute(map);
}
public int updateUserRoute(Map<Object,Object> map){
return userRouteMapper.updateUserRoute(map);
}
public int delUserRoute(String userNumber,String name){
return userRouteMapper.delUserRoute(userNumber,name);
}
public ResultUserRouteVo getByUserNumberAndName(String userNumber,String name){
return userRouteMapper.getByUserNumberAndName(userNumber,name);
}
}
package com.example.tdl.service.redis;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
@Service
public class InfoRedisService extends RedisService {
@SuppressWarnings({ "unchecked", "rawtypes" })
@Autowired
public InfoRedisService(RedisTemplate infoRedisTemplate) {
super(infoRedisTemplate);
}
}
package com.example.tdl.web;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.example.tdl.domain.dto.CommFeedback;
import com.example.tdl.domain.vo.CircuitAlarmVo;
import com.example.tdl.domain.vo.LocationDataVo;
import com.example.tdl.domain.vo.LocationMessageVo;
import com.example.tdl.domain.vo.ResultGatewayVo;
import com.example.tdl.service.CircuitService;
import com.example.tdl.service.TDLDeviceService;
import com.example.tdl.service.redis.RealRedisService;
import com.google.gson.Gson;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.influxdb.dto.Query;
import org.influxdb.dto.QueryResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.influxdb.InfluxDBTemplate;
import org.springframework.web.bind.annotation.*;
import java.text.SimpleDateFormat;
import java.util.*;
@RestController
public class AlarmDataController {
private CommFeedback fb=new CommFeedback();
private Gson gson=new Gson();
@Autowired
private CircuitService circuitService;
@Autowired
private InfluxDBTemplate influxDBTemplate;
@Autowired
private TDLDeviceService tdlDeviceService;
@Autowired
private RealRedisService realRedisService;
private final static String database ="original";
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
@RequestMapping(value="/getAlarmCircuit",method = RequestMethod.POST)
public Object getAlarmCircuit(@RequestBody String transportationNo){
// String transportationNo="CHN20180227G0505";
JSONObject jsonObject= JSON.parseObject(transportationNo);
transportationNo=(String)jsonObject.get("transportationNo");
ResultGatewayVo resultGatewayVo=circuitService.getByNo(transportationNo);
if (resultGatewayVo==null){
fb.setCode(0);
fb.setMessage("该线路没有绑定网关");
return gson.toJson(fb);
}
Integer circuitState=circuitService.getByTransportationNo(transportationNo).getCircuitState();
String device = resultGatewayVo.getType() +"_" +resultGatewayVo.getSN();
if(circuitState==0){
return null;
}else if(circuitState==1){
List<String> list=tdlDeviceService.getByGatewaySN(resultGatewayVo.getSN(),resultGatewayVo.getType());
String tdl="";
if (list.size()==1){
tdl="'tdl-"+list.get(0)+"'";
}else if(list.size()==0){
fb.setCode(0);
fb.setMessage("该网关下没有tdl设备");
return gson.toJson(fb);
}else{
for (int a=0;a<list.size();a++){
tdl=tdl+"'tdl-"+list.get(a)+"'";
if (a<list.size()-1){
tdl=tdl+"or \"tdl\"=";
}
}
}
String sql = "SELECT \"b\",\"tdl\" FROM \"tdl_policy\".\""+device+"\" where \"tdl\"= "+tdl;
QueryResult queryResult = influxDBTemplate.query(new Query(sql,database));
List<CircuitAlarmVo> circuitAlarmVos=new ArrayList<>();
if (queryResult.getResults().get(0).getSeries()!=null){
circuitAlarmVos=getAlarmData(queryResult);
}
String sqls ="";
for (int a=0;a<circuitAlarmVos.size();a++){
sqls=sqls+"SELECT \"time\",\"lng\",\"lat\" FROM \"tdl_policy\".\""+device+"\" where time <='"+circuitAlarmVos.get(a).getTime()+"' ORDER BY time desc limit 1;";
}
QueryResult queryResults = influxDBTemplate.query(new Query(sqls,database));
List<LocationDataVo> locationDataVos = new ArrayList<>();
if (queryResults.getResults().get(0).getSeries()!=null){
locationDataVos=getAddress(queryResults);
}
String sql1="SELECT \"time\",\"lng\",\"lat\" FROM \"tdl_policy\".\""+device+"\" order by time";
QueryResult queryResult1 = influxDBTemplate.query(new Query(sql1,database));
List<LocationDataVo> locationDataVos1 = new ArrayList<>();
if (queryResult1.getResults().get(0).getSeries()!=null){
locationDataVos1=getAllAddress(queryResult1);
}
for (int a=0;a<locationDataVos1.size();a++){
for (int b=0;b<locationDataVos.size();b++){
if (locationDataVos1.get(a).getLng().equals(locationDataVos.get(b).getLng())&&locationDataVos1.get(a).getLat().equals(locationDataVos.get(b).getLat())){
locationDataVos1.get(a).setError(1);
}
}
}
return gson.toJson(locationDataVos1);
}else{
// Map<Object,Object> map=new HashMap<>();
// map.put(device,locationDataVos1);
// realRedisService.setHash("CircuitAlarm",map,System.currentTimeMillis());
Object o =realRedisService.getHash("CircuitAlarm",device);
return gson.toJson(o);
}
}
public List<LocationDataVo> getAddress(QueryResult queryResult){
List<List<Object>> lists=getValue(queryResult);
List<LocationDataVo> locationDataVos=new ArrayList<>();
for (List<Object> value:lists){
LocationDataVo locationDataVo=new LocationDataVo();
locationDataVo.setTime(dateToStamp(value.get(0).toString()));
locationDataVo.setLng((Double)value.get(1));
locationDataVo.setLat((Double)value.get(2));
locationDataVos.add(locationDataVo);
}
return locationDataVos;
}
public List<LocationDataVo> getAllAddress(QueryResult queryResult){
List<List<Object>> lists=getValues(queryResult);
List<LocationDataVo> locationDataVos=new ArrayList<>();
for (List<Object> value:lists){
LocationDataVo locationDataVo=new LocationDataVo();
locationDataVo.setTime(dateToStamp(value.get(0).toString()));
locationDataVo.setLng((Double)value.get(1));
locationDataVo.setLat((Double)value.get(2));
locationDataVo.setError(0);
locationDataVos.add(locationDataVo);
}
return locationDataVos;
}
public List<CircuitAlarmVo> getAlarmData(QueryResult queryResult){
List<List<Object>> lists=getValues(queryResult);
List<CircuitAlarmVo> alarmVoList=new ArrayList<>();
for (List<Object> value:lists){
CircuitAlarmVo circuitAlarmVo=new CircuitAlarmVo();
circuitAlarmVo.setTime(value.get(0).toString());
circuitAlarmVo.setShockEnergy(value.get(1).toString());
circuitAlarmVo.setTdl(value.get(2).toString());
alarmVoList.add(circuitAlarmVo);
}
return alarmVoList;
}
public List<List<Object>> getValues(QueryResult queryResult){
List<List<Object>> lists=new ArrayList<>();
for (QueryResult.Result result:queryResult.getResults()){
if (result.getSeries()!=null){
for (QueryResult.Series series:result.getSeries()){
if (series!=null){
lists=series.getValues();
}
}
}
}
return lists;
}
public List<List<Object>> getValue(QueryResult queryResult){
List<List<Object>> lists=new ArrayList<>();
for (QueryResult.Result result:queryResult.getResults()){
if (result.getSeries()!=null){
for (int a=0;a<result.getSeries().size();a++){
lists.add(result.getSeries().get(a).getValues().get(0));
}
}
}
return lists;
}
public String dateToStamp(String time){
String res;
Date date=null;
try {
if (time.length()!=20){
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
date = simpleDateFormat.parse(time);
}else{
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
date=simpleDateFormat.parse(time);
}
long ts = date.getTime()*1000000;
res = String.valueOf(ts);
}catch (Exception e){
fb.setCode(0);
fb.setMessage("时间转换出错");
return gson.toJson(fb);
}
return res;
}
}
\ No newline at end of file
...@@ -69,7 +69,9 @@ public class CircuitController { ...@@ -69,7 +69,9 @@ public class CircuitController {
" transportationType:运输类型" + " transportationType:运输类型" +
" circuitState:线路状态(0未开始,1运输中,2完成)," + " circuitState:线路状态(0未开始,1运输中,2完成)," +
" remark:备注," + " remark:备注," +
" createTime:创建线路时间") " createTime:创建线路时间" +
" evaluate:评分," +
" evaluateRemark:评分备注")
@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"),
}) })
...@@ -112,7 +114,9 @@ public class CircuitController { ...@@ -112,7 +114,9 @@ public class CircuitController {
" transportationType:运输类型" + " transportationType:运输类型" +
" circuitState:线路状态(0未开始,1运输中,2完成)," + " circuitState:线路状态(0未开始,1运输中,2完成)," +
" remark:备注," + " remark:备注," +
" createTime:创建线路时间") " createTime:创建线路时间," +
" evaluate:评分," +
" evaluateRemark:评分备注")
@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"),
}) })
...@@ -388,6 +392,11 @@ public class CircuitController { ...@@ -388,6 +392,11 @@ public class CircuitController {
fb.setMessage("线路结束时间不能为空"); fb.setMessage("线路结束时间不能为空");
return gson.toJson(fb); return gson.toJson(fb);
} }
if (circuitService.getByTransportationNo(updateCircuitVo.getTransportationNo()).getCircuitState()!=2){
fb.setCode(0);
fb.setMessage("线路未完成");
return gson.toJson(fb);
}
int a = circuitService.updateEndTime(updateCircuitVo); int a = circuitService.updateEndTime(updateCircuitVo);
if (a>0){ if (a>0){
fb.setCode(1); fb.setCode(1);
...@@ -552,6 +561,11 @@ public class CircuitController { ...@@ -552,6 +561,11 @@ public class CircuitController {
fb.setMessage("请输入正确的运输类型"); fb.setMessage("请输入正确的运输类型");
return gson.toJson(fb); return gson.toJson(fb);
} }
if(circuitService.getByTransportationNo(updateCircuitInfo.getTransportationNo()).getCircuitState()!=0){
fb.setCode(0);
fb.setMessage("线路只能在未开始运输时才能修改");
return gson.toJson(fb);
}
String routeNumber=""; String routeNumber="";
Date day=new Date(); Date day=new Date();
SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd"); SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");
...@@ -640,6 +654,11 @@ public class CircuitController { ...@@ -640,6 +654,11 @@ public class CircuitController {
fb.setMessage("需要删除的运输编号不能为空"); fb.setMessage("需要删除的运输编号不能为空");
return gson.toJson(fb); return gson.toJson(fb);
} }
if (circuitService.getByTransportationNo(transportationNo).getCircuitState()==1){
fb.setCode(0);
fb.setMessage("线路运输中不能删除");
return gson.toJson(fb);
}
int a = circuitService.delCircuit(transportationNo); int a = circuitService.delCircuit(transportationNo);
if (a>0){ if (a>0){
fb.setCode(1); fb.setCode(1);
...@@ -651,4 +670,120 @@ public class CircuitController { ...@@ -651,4 +670,120 @@ public class CircuitController {
return gson.toJson(fb); return gson.toJson(fb);
} }
//根据车牌号查线路
@ApiOperation(value = "获取线路信息",notes = "获取线路信息,返回值说明:" +
" transportationNo:运输编号," +
" routeNumber:路由编号," +
" routeName:路由名" +
" startLongitude:起运经度," +
" startLatitude:起运纬度," +
" startCity:起运城市," +
" startAddress:起运具体地址," +
" startTime:起运时间," +
" endLongitude:目的经度," +
" endLatitude:目的纬度," +
" endCity:目的城市," +
" endAddress:目的具体地址," +
" endTime:目的时间," +
" transport:运输方式," +
" alarmType:预警类型," +
" boxNo:箱单号," +
" containerNo:集装箱号," +
" deliveryAddress:交付地址," +
" transportationType:运输类型" +
" circuitState:线路状态(0未开始,1运输中,2完成)," +
" remark:备注," +
" createTime:创建线路时间" +
" evaluate:评分," +
" evaluateRemark:评分备注")
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
@RequestMapping(value="/getByContainerNo",method = RequestMethod.POST)
public Object getByContainerNo(@RequestBody String containerNo){
JSONObject jsonObject=JSON.parseObject(containerNo);
containerNo=(String)jsonObject.get("containerNo");
return circuitService.getByContainerNo(containerNo);
}
//评价
@ApiOperation(value = "评价",notes = "评价线路传值说明:" +
" transportationNo:运输编号," +
" evaluate:评分," +
" evaluateRemark:评分备注")
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
@RequestMapping(value="/updateEvaluate",method = RequestMethod.POST)
public Object updateEvaluate(@RequestBody UpdateEvaluateVo updateEvaluateVo){
if (updateEvaluateVo.getEvaluate()==null){
fb.setCode(0);
fb.setMessage("评价的等级不能为空");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(updateEvaluateVo.getTransportationNo())){
fb.setCode(0);
fb.setMessage("需要评价的线路编号不能为空");
return gson.toJson(fb);
}
if (circuitService.getByTransportationNo(updateEvaluateVo.getTransportationNo()).getCircuitState()!=2){
fb.setCode(0);
fb.setMessage("线路完成运输才能评价");
return gson.toJson(fb);
}
if (circuitService.getByTransportationNo(updateEvaluateVo.getTransportationNo()).getEvaluate()!=null){
fb.setCode(0);
fb.setMessage("该线路已经被评价");
return gson.toJson(fb);
}
int a = circuitService.updateEvaluate(updateEvaluateVo);
if (a>0){
fb.setCode(1);
fb.setMessage("评价成功");
}else{
fb.setCode(0);
fb.setMessage("评价失败");
}
return gson.toJson(fb);
}
//根据运输状态查询线路信息
@ApiOperation(value = "根据运输状态查询线路信息",notes = "根据运输状态查询线路信息,传值说明:{\"circuitState\":2} ,circuitState:线路状态(0未开始,1运输中,2完成),返回值说明:" +
" transportationNo:运输编号," +
" routeNumber:路由编号," +
" routeName:路由名" +
" startLongitude:起运经度," +
" startLatitude:起运纬度," +
" startCity:起运城市," +
" startAddress:起运具体地址," +
" startTime:起运时间," +
" endLongitude:目的经度," +
" endLatitude:目的纬度," +
" endCity:目的城市," +
" endAddress:目的具体地址," +
" endTime:目的时间," +
" transport:运输方式," +
" alarmType:预警类型," +
" boxNo:箱单号," +
" containerNo:集装箱号," +
" deliveryAddress:交付地址," +
" transportationType:运输类型" +
" circuitState:线路状态(0未开始,1运输中,2完成)," +
" remark:备注," +
" createTime:创建线路时间" +
" evaluate:评分," +
" evaluateRemark:评分备注")
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
@RequestMapping(value="/getByCircuitState",method = RequestMethod.POST)
public Object getByCircuitState(@RequestBody Map map){
if (!map.containsKey("circuitState")){
fb.setCode(0);
fb.setMessage("需要查询的线路状态不能为空");
return gson.toJson(fb);
}
return circuitService.getByCircuitState(Integer.valueOf(map.get("circuitState").toString()));
}
} }
This diff is collapsed.
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
<select id="getAll" resultType="com.example.tdl.domain.vo.ResultCircuitVo"> <select id="getAll" resultType="com.example.tdl.domain.vo.ResultCircuitVo">
SELECT transportationNo,routeNumber,routeName,startLongitude,startLatitude,(select city from city_config where id=r.start_id) startCity, SELECT transportationNo,routeNumber,routeName,startLongitude,startLatitude,(select city from city_config where id=r.start_id) startCity,
startAddress,startTime,endLongitude,endLatitude,(select city from city_config where id=r.end_id) endCity,endAddress,endTime,transport, startAddress,startTime,endLongitude,endLatitude,(select city from city_config where id=r.end_id) endCity,endAddress,endTime,transport,
(SELECT alarmType FROM alarm WHERE id=c.alarm_id) alarmType,boxNo,containerNo,deliveryAddress,transportationType,circuitState,c.remark,createTime IFNULL((SELECT alarmType FROM alarm WHERE id=c.alarm_id),"正常") alarmType,boxNo,containerNo,deliveryAddress,transportationType,
circuitState,c.remark,c.createTime,c.evaluate,c.evaluateRemark
from circuit c,route r WHERE c.route_id=r.id AND r.state=1 AND c.state=1 order BY c.id DESC from circuit c,route r WHERE c.route_id=r.id AND r.state=1 AND c.state=1 order BY c.id DESC
</select> </select>
...@@ -24,7 +25,8 @@ ...@@ -24,7 +25,8 @@
<select id="getByTerm" resultType="com.example.tdl.domain.vo.ResultCircuitVo" parameterType="com.example.tdl.domain.vo.CircuitTermVo"> <select id="getByTerm" resultType="com.example.tdl.domain.vo.ResultCircuitVo" parameterType="com.example.tdl.domain.vo.CircuitTermVo">
SELECT transportationNo,routeNumber,routeName,startLongitude,startLatitude,(select city from city_config where id=r.start_id) startCity, SELECT transportationNo,routeNumber,routeName,startLongitude,startLatitude,(select city from city_config where id=r.start_id) startCity,
startAddress,startTime,endLongitude,endLatitude,(select city from city_config where id=r.end_id) endCity,endAddress,endTime,transport, startAddress,startTime,endLongitude,endLatitude,(select city from city_config where id=r.end_id) endCity,endAddress,endTime,transport,
(SELECT alarmType FROM alarm WHERE id=c.alarm_id) alarmType,boxNo,containerNo,deliveryAddress,transportationType,circuitState,c.remark,createTime IFNULL((SELECT alarmType FROM alarm WHERE id=c.alarm_id),"正常") alarmType,boxNo,containerNo,deliveryAddress,transportationType,
circuitState,c.remark,c.createTime,c.evaluate,c.evaluateRemark
from circuit c,route r WHERE c.route_id=r.id AND r.state=1 AND c.state=1 from circuit c,route r WHERE c.route_id=r.id AND r.state=1 AND c.state=1
<if test="transportationNo!=null"> <if test="transportationNo!=null">
AND transportationNo like CONCAT(CONCAT('%',#{transportationNo,jdbcType=VARCHAR}),'%') AND transportationNo like CONCAT(CONCAT('%',#{transportationNo,jdbcType=VARCHAR}),'%')
...@@ -93,7 +95,7 @@ ...@@ -93,7 +95,7 @@
<update id="updateEndTime" parameterType="com.example.tdl.domain.vo.UpdateCircuitVo"> <update id="updateEndTime" parameterType="com.example.tdl.domain.vo.UpdateCircuitVo">
UPDATE circuit set UPDATE circuit set
endTime=#{endTime,jdbcType=BIGINT} endTime=#{endTime,jdbcType=BIGINT},circuitState=2
WHERE transportationNo=#{transportationNo,jdbcType=VARCHAR} WHERE transportationNo=#{transportationNo,jdbcType=VARCHAR}
</update> </update>
...@@ -141,14 +143,16 @@ ...@@ -141,14 +143,16 @@
<select id="getByTransportationNo" resultType="com.example.tdl.domain.vo.ResultCircuitVo" parameterType="String"> <select id="getByTransportationNo" resultType="com.example.tdl.domain.vo.ResultCircuitVo" parameterType="String">
SELECT transportationNo,routeNumber,routeName,startLongitude,startLatitude,(select city from city_config where id=r.start_id) startCity, SELECT transportationNo,routeNumber,routeName,startLongitude,startLatitude,(select city from city_config where id=r.start_id) startCity,
startAddress,startTime,endLongitude,endLatitude,(select city from city_config where id=r.end_id) endCity,endAddress,endTime,transport, startAddress,startTime,endLongitude,endLatitude,(select city from city_config where id=r.end_id) endCity,endAddress,endTime,transport,
(SELECT alarmType FROM alarm WHERE id=c.alarm_id) alarmType,boxNo,containerNo,deliveryAddress,transportationType,circuitState,c.remark,createTime IFNULL((SELECT alarmType FROM alarm WHERE id=c.alarm_id),"正常") alarmType,boxNo,containerNo,deliveryAddress,transportationType,
circuitState,c.remark,c.createTime,c.evaluate,c.evaluateRemark
from circuit c,route r WHERE c.route_id=r.id AND r.state=1 AND c.state=1 AND transportationNo=#{transportationNo,jdbcType=VARCHAR} from circuit c,route r WHERE c.route_id=r.id AND r.state=1 AND c.state=1 AND transportationNo=#{transportationNo,jdbcType=VARCHAR}
</select> </select>
<select id="getByNo" parameterType="String" resultType="com.example.tdl.domain.vo.ResultGatewayVo"> <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 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})) 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>
<select id="getOnRoute" resultType="java.lang.Integer"> <select id="getOnRoute" resultType="java.lang.Integer">
...@@ -175,4 +179,28 @@ ...@@ -175,4 +179,28 @@
GROUP BY routes GROUP BY routes
order BY c.id order BY c.id
</select> </select>
<select id="getByContainerNo" parameterType="String" resultType="com.example.tdl.domain.vo.ResultCircuitVo">
SELECT transportationNo,routeNumber,routeName,startLongitude,startLatitude,(select city from city_config where id=r.start_id) startCity,
startAddress,startTime,endLongitude,endLatitude,(select city from city_config where id=r.end_id) endCity,endAddress,endTime,transport,
IFNULL((SELECT alarmType FROM alarm WHERE id=c.alarm_id),"正常") alarmType,boxNo,containerNo,deliveryAddress,transportationType,
circuitState,c.remark,c.createTime,c.evaluate,c.evaluateRemark
from circuit c,route r WHERE c.route_id=r.id AND r.state=1 AND c.state=1 AND containerNo=#{containerNo,jdbcType=VARCHAR}
</select>
<update id="updateEvaluate" parameterType="com.example.tdl.domain.vo.UpdateEvaluateVo">
update circuit set
evaluate=#{evaluate,jdbcType=FLOAT},
evaluateRemark=#{evaluateRemark,jdbcType=VARCHAR}
WHERE transportationNo=#{transportationNo,jdbcType=VARCHAR}
</update>
<select id="getByCircuitState" parameterType="java.lang.Integer" resultType="com.example.tdl.domain.vo.ResultCircuitVo">
SELECT transportationNo,routeNumber,routeName,startLongitude,startLatitude,(select city from city_config where id=r.start_id) startCity,
startAddress,startTime,endLongitude,endLatitude,(select city from city_config where id=r.end_id) endCity,endAddress,endTime,transport,
IFNULL((SELECT alarmType FROM alarm WHERE id=c.alarm_id),"正常") alarmType,boxNo,containerNo,deliveryAddress,transportationType,
circuitState,c.remark,c.createTime,c.evaluate,c.evaluateRemark
from circuit c,route r WHERE c.route_id=r.id AND r.state=1 AND c.state=1
AND circuitState=#{circuitState,jdbcType=INTEGER}
</select>
</mapper> </mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.tdl.mapper.UserRouteMapper">
<select id="getByUserNumber" parameterType="String" resultType="com.example.tdl.domain.vo.ResultUserRouteVo">
SELECT userNumber,userName,name,country,province,city,address,longitude,latitude,remark
from city_config c,user_route r INNER JOIN `user` u ON r.user_id=u.id
WHERE r.cityConfig_id=c.id AND userNumber=#{userNumber,jdbcType=VARCHAR}
</select>
<insert id="addUserRoute" parameterType="java.util.Map" statementType="CALLABLE">
<![CDATA[
{
call pro_addUserRoute(
#{userNumber,mode=IN,jdbcType=VARCHAR},
#{name,mode=IN,jdbcType=VARCHAR},
#{country,mode=IN,jdbcType=VARCHAR},
#{province,mode=IN,jdbcType=VARCHAR},
#{city,mode=IN,jdbcType=VARCHAR},
#{address,mode=IN,jdbcType=VARCHAR},
#{longitude,mode=IN,jdbcType=VARCHAR},
#{latitude,mode=IN,jdbcType=VARCHAR},
#{remark,mode=IN,jdbcType=VARCHAR},
#{msg,mode=OUT,jdbcType=VARCHAR}
)
}
]]>
</insert>
<update id="updateUserRoute" parameterType="java.util.Map" statementType="CALLABLE">
<![CDATA[
{
call pro_updateUserRoute(
#{userNumber,mode=IN,jdbcType=VARCHAR},
#{oldName,mode=IN,jdbcType=VARCHAR},
#{name,mode=IN,jdbcType=VARCHAR},
#{country,mode=IN,jdbcType=VARCHAR},
#{province,mode=IN,jdbcType=VARCHAR},
#{city,mode=IN,jdbcType=VARCHAR},
#{address,mode=IN,jdbcType=VARCHAR},
#{longitude,mode=IN,jdbcType=VARCHAR},
#{latitude,mode=IN,jdbcType=VARCHAR},
#{remark,mode=IN,jdbcType=VARCHAR},
#{msg,mode=OUT,jdbcType=VARCHAR}
)
}
]]>
</update>
<delete id="delUserRoute" parameterType="String">
DELETE from user_route
WHERE user_id=(SELECT id from user where userNumber=#{userNumber,jdbcType=VARCHAR})
AND name=#{name,jdbcType=VARCHAR}
</delete>
<select id="getByUserNumberAndName" parameterType="String" resultType="com.example.tdl.domain.vo.ResultUserRouteVo">
SELECT userNumber,userName,name,country,province,city,address,longitude,latitude,remark
from city_config c,user_route r INNER JOIN `user` u ON r.user_id=u.id
WHERE r.cityConfig_id=c.id
AND userNumber=#{userNumber,jdbcType=VARCHAR}
AND name=#{name,jdbcType=VARCHAR}
</select>
</mapper>
\ No newline at end of file
...@@ -47,5 +47,6 @@ ...@@ -47,5 +47,6 @@
<mapper resource="mapper/TopicMapper.xml"/> <mapper resource="mapper/TopicMapper.xml"/>
<mapper resource="mapper/TopicConfigMapper.xml"/> <mapper resource="mapper/TopicConfigMapper.xml"/>
<mapper resource="mapper/CityConfigMapper.xml"/> <mapper resource="mapper/CityConfigMapper.xml"/>
<mapper resource="mapper/UserRouteMapper.xml"/>
</mappers> </mappers>
</configuration> </configuration>
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