Commit 3f17add8 authored by zhuangzhuang's avatar zhuangzhuang

5.22-修改线路详情的返回值

parent a2d311e5
...@@ -30,9 +30,6 @@ public class AppCircuitVo { ...@@ -30,9 +30,6 @@ public class AppCircuitVo {
private String transportation; private String transportation;
private String SN;
private String TDLSN;
public String getTransportationNo() { public String getTransportationNo() {
return transportationNo; return transportationNo;
...@@ -145,20 +142,4 @@ public class AppCircuitVo { ...@@ -145,20 +142,4 @@ public class AppCircuitVo {
public void setTransportation(String transportation) { public void setTransportation(String transportation) {
this.transportation = transportation; this.transportation = transportation;
} }
public String getSN() {
return SN;
}
public void setSN(String SN) {
this.SN = SN;
}
public String getTDLSN() {
return TDLSN;
}
public void setTDLSN(String TDLSN) {
this.TDLSN = TDLSN;
}
} }
package com.example.tdl.domain.vo;
public class BindVo {
private Boolean binding;
public Boolean getBinding() {
return binding;
}
public void setBinding(Boolean binding) {
this.binding = binding;
}
}
...@@ -28,6 +28,8 @@ public class CircuitMessageVo { ...@@ -28,6 +28,8 @@ public class CircuitMessageVo {
private List<TDL> tdlList; private List<TDL> tdlList;
private List<CityMessage> cityMessageList;
public static class TDL { public static class TDL {
private String tdlsn; private String tdlsn;
...@@ -58,6 +60,81 @@ public class CircuitMessageVo { ...@@ -58,6 +60,81 @@ public class CircuitMessageVo {
} }
} }
public static class CityMessage{
private String city;
private String lng;
private String lat;
private Long expTime;
private Long comTime;
private Integer type;
public CityMessage() {
}
public CityMessage(String city, String lng, String lat, Long expTime, Long comTime, Integer type) {
this.city = city;
this.lng = lng;
this.lat = lat;
this.expTime = expTime;
this.comTime = comTime;
this.type = type;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getLng() {
return lng;
}
public void setLng(String lng) {
this.lng = lng;
}
public String getLat() {
return lat;
}
public void setLat(String lat) {
this.lat = lat;
}
public Long getComTime() {
return comTime;
}
public void setComTime(Long comTime) {
this.comTime = comTime;
}
public Long getExpTime() {
return expTime;
}
public void setExpTime(Long expTime) {
this.expTime = expTime;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
}
public CircuitMessageVo() { public CircuitMessageVo() {
} }
...@@ -178,4 +255,12 @@ public class CircuitMessageVo { ...@@ -178,4 +255,12 @@ public class CircuitMessageVo {
public void setTdlList(List<TDL> tdlList) { public void setTdlList(List<TDL> tdlList) {
this.tdlList = tdlList; this.tdlList = tdlList;
} }
public List<CityMessage> getCityMessageList() {
return cityMessageList;
}
public void setCityMessageList(List<CityMessage> cityMessageList) {
this.cityMessageList = cityMessageList;
}
} }
...@@ -5,10 +5,18 @@ public class CircuitTransferVo { ...@@ -5,10 +5,18 @@ public class CircuitTransferVo {
private String address; private String address;
private Long startTime; private String lng;
private String lat;
private Long arrivalTime; private Long arrivalTime;
private Long startTime;
private Long expTime;
private Long compTime;
private Integer sequence; private Integer sequence;
public String getCity() { public String getCity() {
...@@ -27,6 +35,22 @@ public class CircuitTransferVo { ...@@ -27,6 +35,22 @@ public class CircuitTransferVo {
this.address = address; this.address = address;
} }
public String getLng() {
return lng;
}
public void setLng(String lng) {
this.lng = lng;
}
public String getLat() {
return lat;
}
public void setLat(String lat) {
this.lat = lat;
}
public Long getStartTime() { public Long getStartTime() {
return startTime; return startTime;
} }
...@@ -43,6 +67,22 @@ public class CircuitTransferVo { ...@@ -43,6 +67,22 @@ public class CircuitTransferVo {
this.arrivalTime = arrivalTime; this.arrivalTime = arrivalTime;
} }
public Long getCompTime() {
return compTime;
}
public void setCompTime(Long compTime) {
this.compTime = compTime;
}
public Long getExpTime() {
return expTime;
}
public void setExpTime(Long expTime) {
this.expTime = expTime;
}
public Integer getSequence() { public Integer getSequence() {
return sequence; return sequence;
} }
......
...@@ -28,4 +28,6 @@ public interface TDLDeviceMapper { ...@@ -28,4 +28,6 @@ public interface TDLDeviceMapper {
String getTdl(@Param("SN") String SN, @Param("type") String type); String getTdl(@Param("SN") String SN, @Param("type") String type);
List<TdlSNVo> getUnusedTDL(String TDLSN); List<TdlSNVo> getUnusedTDL(String TDLSN);
ResultTDLDeviceVo getByTransportationNo(String transportationNo);
} }
...@@ -51,4 +51,9 @@ public class TDLDeviceService { ...@@ -51,4 +51,9 @@ public class TDLDeviceService {
public List<TdlSNVo> getUnusedTDL(String TDLSN){ public List<TdlSNVo> getUnusedTDL(String TDLSN){
return tdlDeviceMapper.getUnusedTDL(TDLSN); return tdlDeviceMapper.getUnusedTDL(TDLSN);
} }
public ResultTDLDeviceVo getByTransportationNo(String transportationNo){
return tdlDeviceMapper.getByTransportationNo(transportationNo);
}
} }
...@@ -21,6 +21,7 @@ import org.slf4j.LoggerFactory; ...@@ -21,6 +21,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.influxdb.InfluxDBTemplate; import org.springframework.data.influxdb.InfluxDBTemplate;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import retrofit2.http.POST;
import javax.print.DocFlavor; import javax.print.DocFlavor;
import javax.print.attribute.standard.RequestingUserName; import javax.print.attribute.standard.RequestingUserName;
...@@ -292,18 +293,25 @@ public class CircuitController { ...@@ -292,18 +293,25 @@ public class CircuitController {
" tdlsn:TDLSN序列号" + " tdlsn:TDLSN序列号" +
" batteryVoltage:电池电压}," + " batteryVoltage:电池电压}," +
" list:{" + " list:{" +
" city:城市;" + " city:城市;" +
" time:到达时间/发车时间;" + " time:到达时间/发车时间;" +
" last:运行时长;" + " last:运行时长;" +
" alarmCount:报警数;" + " alarmCount:报警数;" +
" type:1--出发时间;2--目的时间}," + " type:1--出发时间;2--目的时间}," +
" alarmLogList:{" + " alarmLogList:{" +
" transportationNo:运输编号;" + " transportationNo:运输编号;" +
" TDLSN:tag序列号;" + " TDLSN:tag序列号;" +
" description:报警描述;" + " description:报警描述;" +
" data:数值;" + " data:数值;" +
" alarmTime:报警时间;" + " alarmTime:报警时间;" +
" classify:分类}" ) " classify:分类}" +
" cityMessageList:{" +
" city:城市;" +
" lng:经度;" +
" lat:纬度;" +
" expTime:预计发车时间;" +
" comTime:预计到达时间" +
" type:1--出发地;2--目的地}" )
@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"),
@ApiImplicitParam(paramType="header", name = "AccountLanguage", value = "language", required = false, dataType = "String"), @ApiImplicitParam(paramType="header", name = "AccountLanguage", value = "language", required = false, dataType = "String"),
...@@ -331,12 +339,14 @@ public class CircuitController { ...@@ -331,12 +339,14 @@ public class CircuitController {
List<ResultAlarmLog> alarmLogList = new ArrayList<>(); List<ResultAlarmLog> alarmLogList = new ArrayList<>();
List<CircuitMessageVo.TDL> tdlList = new ArrayList<>(); List<CircuitMessageVo.TDL> tdlList = new ArrayList<>();
List<ResultCityVo> cityVoList = new ArrayList<>(); List<ResultCityVo> cityVoList = new ArrayList<>();
List<CircuitMessageVo.CityMessage> cityMessageList =new ArrayList<>();
if(gatewayVo == null || TDL.size() == 0){ if(gatewayVo == null || TDL.size() == 0){
messageVo.setSN(""); messageVo.setSN("");
messageVo.setBattery(""); messageVo.setBattery("");
messageVo.setAlarmLogList(alarmLogList); messageVo.setAlarmLogList(alarmLogList);
messageVo.setTdlList(tdlList); messageVo.setTdlList(tdlList);
messageVo.setList(cityVoList); messageVo.setList(cityVoList);
messageVo.setCityMessageList(cityMessageList);
return gson.toJson(messageVo); return gson.toJson(messageVo);
} }
messageVo.setSN(gatewayVo.getgSN()); messageVo.setSN(gatewayVo.getgSN());
...@@ -384,10 +394,14 @@ public class CircuitController { ...@@ -384,10 +394,14 @@ public class CircuitController {
List<CircuitTransferVo> list =circuitTransferService.getCity(transportationNo); List<CircuitTransferVo> list =circuitTransferService.getCity(transportationNo);
if(list == null){ if(list == null){
messageVo.setList(cityVoList); messageVo.setList(cityVoList);
messageVo.setCityMessageList(cityMessageList);
return gson.toJson(messageVo); return gson.toJson(messageVo);
} }
for (int i = 0; i < list.size(); i++) {
for (int i = 0,length = list.size(); i < length; i++) {
if (list.get(i).getSequence() == 1) { if (list.get(i).getSequence() == 1) {
CircuitMessageVo.CityMessage cityMessage = new CircuitMessageVo.CityMessage(list.get(i).getCity(),list.get(i).getLng(), list.get(i).getLat(),list.get(i).getExpTime(),null,1);
cityMessageList.add(cityMessage);
ResultCityVo cityVo = new ResultCityVo(); ResultCityVo cityVo = new ResultCityVo();
cityVo.setCity(list.get(i).getCity()); cityVo.setCity(list.get(i).getCity());
cityVo.setAddress(list.get(i).getAddress()); cityVo.setAddress(list.get(i).getAddress());
...@@ -411,6 +425,8 @@ public class CircuitController { ...@@ -411,6 +425,8 @@ public class CircuitController {
} }
cityVoList.add(cityVo); cityVoList.add(cityVo);
}else if(list.get(i).getSequence() == list.size()){ }else if(list.get(i).getSequence() == list.size()){
CircuitMessageVo.CityMessage cityMessage = new CircuitMessageVo.CityMessage(list.get(i).getCity(),list.get(i).getLng(), list.get(i).getLat(),null,list.get(i).getCompTime(),2);
cityMessageList.add(cityMessage);
ResultCityVo cityVo = new ResultCityVo(); ResultCityVo cityVo = new ResultCityVo();
cityVo.setCity(list.get(i).getCity()); cityVo.setCity(list.get(i).getCity());
cityVo.setAddress(list.get(i).getAddress()); cityVo.setAddress(list.get(i).getAddress());
...@@ -480,6 +496,7 @@ public class CircuitController { ...@@ -480,6 +496,7 @@ public class CircuitController {
} }
} }
} }
messageVo.setCityMessageList(cityMessageList);
messageVo.setList(cityVoList); messageVo.setList(cityVoList);
return gson.toJson(messageVo); return gson.toJson(messageVo);
} }
...@@ -1453,6 +1470,43 @@ public class CircuitController { ...@@ -1453,6 +1470,43 @@ public class CircuitController {
//判断线路是否已经绑定了tdl和gateway
@ApiOperation(value = "判断线路是否已经绑定了tdl和gateway",notes = "判断线路是否已经绑定了tdl和gateway" +
"transportationNo:运输编号" +
"返回值:" +
"binding:false未绑定/true绑定了")
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
@ApiImplicitParam(paramType="header", name = "AccountLanguage", value = "language", required = false, dataType = "String"),
})
@PostMapping("/circuitbBinding")
public Object circuitbBinding(@RequestBody String transportationNo,HttpServletRequest request){
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");
ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(transportationNo,user.getCompanyName());
if (resultCircuitVo==null){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"noCircuit"));
return gson.toJson(fb);
}
ResultTDLDeviceVo tdlDeviceVo = tdlDeviceService.getByTransportationNo(transportationNo);
BindVo bindVo = new BindVo();
if(tdlDeviceVo == null){
bindVo.setBinding(false);
}else{
bindVo.setBinding(true);
}
return gson.toJson(bindVo);
}
//生成运输编号 //生成运输编号
public String getTransportNo(String transportation,String transportationType){ public String getTransportNo(String transportation,String transportationType){
String transportationNo=""; String transportationNo="";
......
...@@ -98,6 +98,9 @@ public class DataController { ...@@ -98,6 +98,9 @@ public class DataController {
//根据运输编号获取线路信息 //根据运输编号获取线路信息
ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(transportationNo,user.getCompanyName()); ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(transportationNo,user.getCompanyName());
List<LocationDataVo> locationDataVoList =new ArrayList<>(); List<LocationDataVo> locationDataVoList =new ArrayList<>();
if(resultCircuitVo == null){
return gson.toJson(locationDataVoList);
}
if(resultCircuitVo.getStartTime() == null || resultCircuitVo.getStartTime() == 0){ if(resultCircuitVo.getStartTime() == null || resultCircuitVo.getStartTime() == 0){
return gson.toJson(locationDataVoList); return gson.toJson(locationDataVoList);
} }
......
...@@ -65,8 +65,6 @@ public class EquipmentBindingController { ...@@ -65,8 +65,6 @@ public class EquipmentBindingController {
add("h"); add("h");
add("a0"); add("a0");
add("ta"); add("ta");
// add("");
// add("");
}}; }};
@ApiOperation(value = "绑定gateWay和tdl",notes = "绑定gateWay和tdl" + @ApiOperation(value = "绑定gateWay和tdl",notes = "绑定gateWay和tdl" +
...@@ -85,8 +83,38 @@ public class EquipmentBindingController { ...@@ -85,8 +83,38 @@ public class EquipmentBindingController {
String token = request.getHeader("Account_token"); String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token); String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class); UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
if(StringUtils.isEmpty(bindingVo.getSN())){
fb.setCode(0);
fb.setMessage("网关编号不能为空");
return gson.toJson(fb);
}
if(StringUtils.isEmpty(bindingVo.getType())){
fb.setCode(0);
fb.setMessage("网关类型不能为空");
return gson.toJson(fb);
}
if(StringUtils.isEmpty(bindingVo.getTDLSN())){
fb.setCode(0);
fb.setMessage("Tdl编号不能为空");
return gson.toJson(fb);
}
if(StringUtils.isEmpty(bindingVo.getAlarmType())){
fb.setCode(0);
fb.setMessage("预警类型不能为空");
return gson.toJson(fb);
}
if(bindingVo.getMode() == null){
fb.setCode(0);
fb.setMessage("使用场景不能为空");
return gson.toJson(fb);
}
//获取gateWay的信息 //获取gateWay的信息
ResultGatewayVo resultGatewayVo = gatewayService.getBySNAndType(bindingVo.getSN(),bindingVo.getType()); ResultGatewayVo resultGatewayVo = gatewayService.getBySNAndType(bindingVo.getSN(),bindingVo.getType());
if(resultGatewayVo == null){
fb.setCode(0);
fb.setMessage("该网关不存在");
return gson.toJson(fb);
}
if(resultGatewayVo.getUseScene() !=0 && resultGatewayVo.getUseScene() !=bindingVo.getMode()){ if(resultGatewayVo.getUseScene() !=0 && resultGatewayVo.getUseScene() !=bindingVo.getMode()){
fb.setCode(0); fb.setCode(0);
fb.setMessage("该网关所属环境与当前不符"); fb.setMessage("该网关所属环境与当前不符");
...@@ -104,12 +132,14 @@ public class EquipmentBindingController { ...@@ -104,12 +132,14 @@ public class EquipmentBindingController {
}else if(StringUtils.isEmpty(bindingVo.getWarehouseNo()) && !StringUtils.isEmpty(bindingVo.getTransportationNo())){ }else if(StringUtils.isEmpty(bindingVo.getWarehouseNo()) && !StringUtils.isEmpty(bindingVo.getTransportationNo())){
bindingVo.setWarehouseNo(""); bindingVo.setWarehouseNo("");
} }
//开始绑定 //开始绑定
//获取gateway下的所有tdl的编号 //获取gateway下的所有tdl的编号
List<String> devList = tdlDeviceService.getByGatewaySN(bindingVo.getSN(),bindingVo.getType()); List<String> devList = tdlDeviceService.getByGatewaySN(bindingVo.getSN(),bindingVo.getType());
devList.add("TDL-"+bindingVo.getTDLSN()); devList.add("TDL-"+bindingVo.getTDLSN());
ConfigCMDVo configCMDVo = new ConfigCMDVo("config",5,15,devList,bindingVo.getMode(),System.currentTimeMillis()/1000l); ConfigCMDVo configCMDVo = new ConfigCMDVo("config",5,15,devList,bindingVo.getMode(),System.currentTimeMillis()/1000l);
Map<Object,Object> map=new HashMap<>(); Map<Object,Object> map=new HashMap<>();
map.put("companyName",user.getCompanyName());
map.put("transportationNo",bindingVo.getTransportationNo()); map.put("transportationNo",bindingVo.getTransportationNo());
map.put("warehouseNo",bindingVo.getWarehouseNo()); map.put("warehouseNo",bindingVo.getWarehouseNo());
map.put("useScene",bindingVo.getMode()); map.put("useScene",bindingVo.getMode());
...@@ -121,7 +151,7 @@ public class EquipmentBindingController { ...@@ -121,7 +151,7 @@ public class EquipmentBindingController {
map.put("resp",null); map.put("resp",null);
map.put("state",1); map.put("state",1);
map.put("untie",false); map.put("untie",false);
map.put("TDLSN","TDL-"+bindingVo.getTDLSN()); map.put("TDLSN",bindingVo.getTDLSN());
map.put("createTime",System.currentTimeMillis()); map.put("createTime",System.currentTimeMillis());
configService.addConfig(map); configService.addConfig(map);
Map<Object,Object> msg=new HashMap<>(); Map<Object,Object> msg=new HashMap<>();
...@@ -165,6 +195,8 @@ public class EquipmentBindingController { ...@@ -165,6 +195,8 @@ public class EquipmentBindingController {
} }
@ApiOperation(value = "重置tdl",notes = "重置tdl") @ApiOperation(value = "重置tdl",notes = "重置tdl")
@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"),
......
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.tdl.mapper.CircuitTransferMapper"> <mapper namespace="com.example.tdl.mapper.CircuitTransferMapper">
<select id="getCity" resultType="com.example.tdl.domain.vo.CircuitTransferVo" parameterType="String"> <select id="getCity" resultType="com.example.tdl.domain.vo.CircuitTransferVo" parameterType="String">
select c.city,CONCAT(c.country,c.city,ct.addressDetail) address,ct.arrivalTime,ct.startTime,ct.sequence from circuit_transfer ct,city c,circuit cr select c.city,CONCAT(c.country,c.city,ct.addressDetail) address,ct.lng,ct.lat,ct.arrivalTime,ct.startTime,ct.expTime,ct.compTime,ct.sequence
from circuit_transfer ct,city c,circuit cr
where c.id=ct.city_id where c.id=ct.city_id
and ct.circuit_id =cr.id and ct.circuit_id =cr.id
and cr.transportationNo = #{transportationNo,jdbcType=VARCHAR} and cr.transportationNo = #{transportationNo,jdbcType=VARCHAR}
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
<![CDATA[ <![CDATA[
{ {
call pro_addTDLGatewayLog( call pro_addTDLGatewayLog(
#{companyName,mode=IN,jdbcType=VARCHAR},
#{transportationNo,mode=IN,jdbcType=VARCHAR}, #{transportationNo,mode=IN,jdbcType=VARCHAR},
#{warehouseNo,mode=IN,jdbcType=VARCHAR}, #{warehouseNo,mode=IN,jdbcType=VARCHAR},
#{useScene,mode=IN,jdbcType=INTEGER}, #{useScene,mode=IN,jdbcType=INTEGER},
......
...@@ -82,4 +82,13 @@ ...@@ -82,4 +82,13 @@
where TDLSN like CONCAT(CONCAT('%',#{TDLSN,jdbcType=VARCHAR}), '%') where TDLSN like CONCAT(CONCAT('%',#{TDLSN,jdbcType=VARCHAR}), '%')
and useScene = 0 and useScene = 0
</select> </select>
<select id="getByTransportationNo" parameterType="String" resultType="com.example.tdl.domain.vo.ResultTDLDeviceVo">
SELECT TDLName,TDLSN,counts,lastTime,t.useScene,(SELECT warehouseName from warehouse WHERE id=t.warehouse_id) warehouseName,
c.transportationNo, g.SN gatewaySN, g.type gatewayType
from tdldevice t ,circuit c,gateway g
WHERE t.gateway_id = g.id
and t.circuit_id = c.id
and c.transportationNo=#{transportationNo,jdbcType=VARCHAR}
</select>
</mapper> </mapper>
\ No newline at end of file
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