Commit fb4377bf authored by zhuangzhuang's avatar zhuangzhuang

3.28-修改线路新增接口以及查询接口,修改数据的返回格式

parent beb6eca9
...@@ -216,6 +216,13 @@ public class RedisConfig extends CachingConfigurerSupport{ ...@@ -216,6 +216,13 @@ public class RedisConfig extends CachingConfigurerSupport{
return template; return template;
} }
@Bean
public RedisTemplate<String, String> alarmRedisTemplate() {
StringRedisTemplate template = new StringRedisTemplate(redisConnectionFactory(3));
JsonRedisSerializer(template, false);
return template;
}
@Bean @Bean
public RedisTemplate<String, String> tokenRedisTemplate() { public RedisTemplate<String, String> tokenRedisTemplate() {
StringRedisTemplate template = new StringRedisTemplate(redisConnectionFactory(15)); StringRedisTemplate template = new StringRedisTemplate(redisConnectionFactory(15));
...@@ -223,5 +230,7 @@ public class RedisConfig extends CachingConfigurerSupport{ ...@@ -223,5 +230,7 @@ public class RedisConfig extends CachingConfigurerSupport{
return template; return template;
} }
} }
...@@ -5,13 +5,15 @@ import java.util.List; ...@@ -5,13 +5,15 @@ import java.util.List;
public class AddCircuitVo { public class AddCircuitVo {
private StartAddressVo startAddressVo;
private List<AddressVo> addressVoList; private List<AddressVo> addressVoList;
private String SN; private EndAddressVo endAddressVo;
private String TDLSN; private String SN;
private String alarmType; private List<TDLAlarmVo> tdlAlarmList;
private String cargoNo;//货物编号 private String cargoNo;//货物编号
...@@ -21,6 +23,14 @@ public class AddCircuitVo { ...@@ -21,6 +23,14 @@ public class AddCircuitVo {
private String remark; private String remark;
public StartAddressVo getStartAddressVo() {
return startAddressVo;
}
public void setStartAddressVo(StartAddressVo startAddressVo) {
this.startAddressVo = startAddressVo;
}
public List<AddressVo> getAddressVoList() { public List<AddressVo> getAddressVoList() {
return addressVoList; return addressVoList;
} }
...@@ -29,28 +39,28 @@ public class AddCircuitVo { ...@@ -29,28 +39,28 @@ public class AddCircuitVo {
this.addressVoList = addressVoList; this.addressVoList = addressVoList;
} }
public String getSN() { public EndAddressVo getEndAddressVo() {
return SN; return endAddressVo;
} }
public void setSN(String SN) { public void setEndAddressVo(EndAddressVo endAddressVo) {
this.SN = SN; this.endAddressVo = endAddressVo;
} }
public String getTDLSN() { public String getSN() {
return TDLSN; return SN;
} }
public void setTDLSN(String TDLSN) { public void setSN(String SN) {
this.TDLSN = TDLSN; this.SN = SN;
} }
public String getAlarmType() { public List<TDLAlarmVo> getTdlAlarmList() {
return alarmType; return tdlAlarmList;
} }
public void setAlarmType(String alarmType) { public void setTdlAlarmList(List<TDLAlarmVo> tdlAlarmList) {
this.alarmType = alarmType; this.tdlAlarmList = tdlAlarmList;
} }
public String getCargoNo() { public String getCargoNo() {
......
...@@ -2,8 +2,6 @@ package com.example.tdl.domain.vo; ...@@ -2,8 +2,6 @@ package com.example.tdl.domain.vo;
public class AddressVo { public class AddressVo {
private Integer sequence;
private String country; private String country;
private String city; private String city;
...@@ -20,15 +18,6 @@ public class AddressVo { ...@@ -20,15 +18,6 @@ public class AddressVo {
private Long compTime;//预计结束时间 private Long compTime;//预计结束时间
public Integer getSequence() {
return sequence;
}
public void setSequence(Integer sequence) {
this.sequence = sequence;
}
public String getCountry() { public String getCountry() {
return country; return country;
} }
......
package com.example.tdl.domain.vo;
public class AlarmRuleVo {
private String rule;
private String maxval;
private String minval;
private String mode;
private String priority;
public String getRule() {
return rule;
}
public void setRule(String rule) {
this.rule = rule;
}
public String getMaxval() {
return maxval;
}
public void setMaxval(String maxval) {
this.maxval = maxval;
}
public String getMinval() {
return minval;
}
public void setMinval(String minval) {
this.minval = minval;
}
public String getMode() {
return mode;
}
public void setMode(String mode) {
this.mode = mode;
}
public String getPriority() {
return priority;
}
public void setPriority(String priority) {
this.priority = priority;
}
}
...@@ -14,6 +14,8 @@ public class BindingVo { ...@@ -14,6 +14,8 @@ public class BindingVo {
private String warehouseNo; private String warehouseNo;
private String alarmType;
public String getSN() { public String getSN() {
return SN; return SN;
} }
...@@ -61,4 +63,12 @@ public class BindingVo { ...@@ -61,4 +63,12 @@ public class BindingVo {
public void setWarehouseNo(String warehouseNo) { public void setWarehouseNo(String warehouseNo) {
this.warehouseNo = warehouseNo; this.warehouseNo = warehouseNo;
} }
public String getAlarmType() {
return alarmType;
}
public void setAlarmType(String alarmType) {
this.alarmType = alarmType;
}
} }
...@@ -18,7 +18,7 @@ public class CircuitMessageVo { ...@@ -18,7 +18,7 @@ public class CircuitMessageVo {
private List<ResultCityVo> list; private List<ResultCityVo> list;
List<ResultAlarmLog> alarmLogList; private List<ResultAlarmLog> alarmLogList;
public CircuitMessageVo() { public CircuitMessageVo() {
} }
......
package com.example.tdl.domain.vo;
import java.util.List;
public class DataVo {
private String description;
private List<HistoryDataVo> dataList;
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public List<HistoryDataVo> getDataList() {
return dataList;
}
public void setDataList(List<HistoryDataVo> dataList) {
this.dataList = dataList;
}
}
package com.example.tdl.domain.vo;
public class EndAddressVo {
private String country;
private String city;
private String addressDetail;
private String lng;
private String lat;
private String postCode;
private Long compTime;//预计结束时间
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getAddressDetail() {
return addressDetail;
}
public void setAddressDetail(String addressDetail) {
this.addressDetail = addressDetail;
}
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 String getPostCode() {
return postCode;
}
public void setPostCode(String postCode) {
this.postCode = postCode;
}
public Long getCompTime() {
return compTime;
}
public void setCompTime(Long compTime) {
this.compTime = compTime;
}
}
package com.example.tdl.domain.vo;
public class HistoryData {
private String time;
private String value;
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
package com.example.tdl.domain.vo;
import java.util.List;
public class HistoryDataVo {
private String TDLSN;
private List<HistoryData> dataList;
public String getTDLSN() {
return TDLSN;
}
public void setTDLSN(String TDLSN) {
this.TDLSN = TDLSN;
}
public List<HistoryData> getDataList() {
return dataList;
}
public void setDataList(List<HistoryData> dataList) {
this.dataList = dataList;
}
}
package com.example.tdl.domain.vo;
public class StartAddressVo {
private String country;
private String city;
private String addressDetail;
private String lng;
private String lat;
private String postCode;
private Long expTime;
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getAddressDetail() {
return addressDetail;
}
public void setAddressDetail(String addressDetail) {
this.addressDetail = addressDetail;
}
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 String getPostCode() {
return postCode;
}
public void setPostCode(String postCode) {
this.postCode = postCode;
}
public Long getExpTime() {
return expTime;
}
public void setExpTime(Long expTime) {
this.expTime = expTime;
}
}
package com.example.tdl.domain.vo;
public class TDLAlarmVo {
private String TDLSN;
private String alarmType;
public String getTDLSN() {
return TDLSN;
}
public void setTDLSN(String TDLSN) {
this.TDLSN = TDLSN;
}
public String getAlarmType() {
return alarmType;
}
public void setAlarmType(String alarmType) {
this.alarmType = alarmType;
}
}
...@@ -204,4 +204,5 @@ public class MqttListener implements MqttCallback { ...@@ -204,4 +204,5 @@ public class MqttListener implements MqttCallback {
return 1;//重发 return 1;//重发
} }
} }
} }
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 AlarmRedisService extends RedisService {
@SuppressWarnings({ "unchecked", "rawtypes" })
@Autowired
public AlarmRedisService(RedisTemplate alarmRedisTemplate) {
super(alarmRedisTemplate);
}
}
...@@ -70,8 +70,8 @@ public class CircuitController { ...@@ -70,8 +70,8 @@ public class CircuitController {
//根据条件查询 //根据条件查询
@ApiOperation(value = "根据条件查询",notes = "根据条件查询:" + @ApiOperation(value = "根据条件查询",notes = "根据条件查询:" +
" cargoNo:货物编号" + " cargoNo:货物编号" +
" endCity:目的城市," + " startTime:出发时间,(时间戳)" +
" endTime:目的时间," + " endTime:目的时间,(时间戳)" +
" circuitState:线路状态(0未开始,1运输中,2完成),"+ " circuitState:线路状态(0未开始,1运输中,2完成),"+
"返回值说明:" + "返回值说明:" +
" transportationNo:运输编号," + " transportationNo:运输编号," +
...@@ -89,15 +89,33 @@ public class CircuitController { ...@@ -89,15 +89,33 @@ public class CircuitController {
}) })
@RequestMapping(value="/getByTerm",method = RequestMethod.POST) @RequestMapping(value="/getByTerm",method = RequestMethod.POST)
public Object getByTerm(@RequestBody CircuitTermVo circuitTermVo){ public Object getByTerm(@RequestBody CircuitTermVo circuitTermVo){
if(StringUtils.isEmpty(circuitTermVo.getCargoNo())){
circuitTermVo.setCargoNo(null);
}
if(circuitTermVo.getCircuitState() == null){
circuitTermVo.setCircuitState(null);
}
if(circuitTermVo.getStartTime()==null){
circuitTermVo.setStartTime(null);
} if(circuitTermVo.getEndTime()==null){
circuitTermVo.setEndTime(null);
}
return circuitService.getByTerm(circuitTermVo); return circuitService.getByTerm(circuitTermVo);
} }
//添加线路信息 //添加线路信息
@ApiOperation(value = "添加线路信息",notes = "添加线路信息," + @ApiOperation(value = "添加线路信息",notes = "添加线路信息," +
" startAddressVo: 线路集合,包含" +
"{country:国家" +
"city:城市" +
"addressDetail:详细地址" +
"lng:经度" +
"lat:纬度" +
"postCode:邮编"+
"expTime:预计开始时间,(传时间戳)}" +
" addressVoList: 线路集合,包含" + " addressVoList: 线路集合,包含" +
"{sequence:顺序(出发地0,目的地从1依次排序)" + "{country:国家" +
"country:国家" +
"city:城市" + "city:城市" +
"addressDetail:详细地址" + "addressDetail:详细地址" +
"lng:经度" + "lng:经度" +
...@@ -105,9 +123,18 @@ public class CircuitController { ...@@ -105,9 +123,18 @@ public class CircuitController {
"postCode:邮编"+ "postCode:邮编"+
"expTime:预计开始时间,(传时间戳)" + "expTime:预计开始时间,(传时间戳)" +
"compTime:预计结束时间,(传时间戳)}" + "compTime:预计结束时间,(传时间戳)}" +
" endAddressVo: 线路集合,包含" +
"{country:国家" +
"city:城市" +
"addressDetail:详细地址" +
"lng:经度" +
"lat:纬度" +
"postCode:邮编"+
"compTime:预计结束时间,(传时间戳)}" +
" gSN:网关编号," + " gSN:网关编号," +
" TDLSN:tdl编号," + " tdlAlarmList: " +
" alarmType:报警类型," + "{TDLSN:tdl编号," +
" alarmType:报警类型,}" +
" cargoNo:货物编号," + " cargoNo:货物编号," +
" plateNo:车牌号," + " plateNo:车牌号," +
" cargoName:货物别名," + " cargoName:货物别名," +
...@@ -117,162 +144,262 @@ public class CircuitController { ...@@ -117,162 +144,262 @@ public class CircuitController {
}) })
@RequestMapping(value="/addCircuit",method = RequestMethod.POST) @RequestMapping(value="/addCircuit",method = RequestMethod.POST)
public Object addCircuit(@RequestBody AddCircuitVo addCircuitVo){ public Object addCircuit(@RequestBody AddCircuitVo addCircuitVo){
if(StringUtils.isEmpty(addCircuitVo.getTDLSN())){ if(StringUtils.isEmpty(addCircuitVo.getStartAddressVo().getCountry())){
fb.setCode(0); fb.setCode(0);
fb.setMessage("TDL编号不能为空"); fb.setMessage("出发国家不能为空");
return gson.toJson(fb); return gson.toJson(fb);
} }
if(StringUtils.isEmpty(addCircuitVo.getSN())){ if (StringUtils.isEmpty(addCircuitVo.getStartAddressVo().getCity())){
fb.setCode(0); fb.setCode(0);
fb.setMessage("网关编号不能为空"); fb.setMessage("出发城市不能为空");
return gson.toJson(fb); return gson.toJson(fb);
} }
if(StringUtils.isEmpty(addCircuitVo.getCargoNo())){ if (StringUtils.isEmpty(addCircuitVo.getStartAddressVo().getAddressDetail())){
fb.setCode(0); fb.setCode(0);
fb.setMessage("货物编号不能为空"); fb.setMessage("出发具体地址不能为空");
return gson.toJson(fb); return gson.toJson(fb);
} }
if(StringUtils.isEmpty(addCircuitVo.getPlateNo())){ if (StringUtils.isEmpty(addCircuitVo.getStartAddressVo().getLat())){
fb.setCode(0); fb.setCode(0);
fb.setMessage("车牌号不能为空"); fb.setMessage("出发地纬度不能为空");
return gson.toJson(fb); return gson.toJson(fb);
} }
if(StringUtils.isEmpty(addCircuitVo.getCargoName())){ if(!addCircuitVo.getStartAddressVo().getLat().matches("^-?(([1-9])((\\.\\d{1,6})?)|([1-8]\\d)((\\.\\d{1,6})?)|90)$")){
fb.setCode(0); fb.setCode(0);
fb.setMessage("货物别名不能为空"); fb.setMessage("出发地纬度的范围为-90~90");
return gson.toJson(fb); return gson.toJson(fb);
} }
if(StringUtils.isEmpty(addCircuitVo.getAlarmType())){ if (StringUtils.isEmpty(addCircuitVo.getStartAddressVo().getLng())){
fb.setCode(0); fb.setCode(0);
fb.setMessage("预警类型"); fb.setMessage("出发地经度不能为空");
return gson.toJson(fb); return gson.toJson(fb);
} }
if(addCircuitVo.getAddressVoList().size()==0){ if(!addCircuitVo.getStartAddressVo().getLng().matches("^-?(([1-9]\\d?)((\\.\\d{1,6})?)|(1[1-7]\\d)((\\.\\d{1,6})?)|180)$")) {
fb.setCode(0); fb.setCode(0);
fb.setMessage("出发地不能为空"); fb.setMessage("出发地经度的范围为-180~180");
return gson.toJson(fb); return gson.toJson(fb);
} }
if(addCircuitVo.getAddressVoList().size()==1){ if (StringUtils.isEmpty(addCircuitVo.getStartAddressVo().getPostCode())){
fb.setCode(0); fb.setCode(0);
fb.setMessage("目的地不能为空"); fb.setMessage("出发地邮编不能为空");
return gson.toJson(fb); return gson.toJson(fb);
} }
if(addCircuitVo.getAddressVoList().size()>4){ if (addCircuitVo.getStartAddressVo().getExpTime()==null){
fb.setCode(0); fb.setCode(0);
fb.setMessage("目的地不能超过3个"); fb.setMessage("出发地预计出发时间不能为空");
return gson.toJson(fb); return gson.toJson(fb);
} }
String countryVar="";
String cityVar="";
String addressDetailVar="";
String lngVar="";
String latVar = "";
String postCodeVar = "";
String expTimeVar = "";
String compTimeVar = "";
String arrivalTimeVar="";
String startTimeVar="";
Long time = System.currentTimeMillis(); Long time = System.currentTimeMillis();
for(int i =0;i<addCircuitVo.getAddressVoList().size();i++){ String countryVar=addCircuitVo.getStartAddressVo().getCountry()+" ";
if(StringUtils.isEmpty(addCircuitVo.getAddressVoList().get(i).getCountry())){ String cityVar=addCircuitVo.getStartAddressVo().getCity()+ " ";
fb.setCode(0); String addressDetailVar=addCircuitVo.getStartAddressVo().getAddressDetail() +" ";
fb.setMessage("国家不能为空"); String lngVar=addCircuitVo.getStartAddressVo().getLng()+" ";
return gson.toJson(fb); String latVar = addCircuitVo.getStartAddressVo().getLat()+" ";
} String postCodeVar = addCircuitVo.getStartAddressVo().getPostCode()+" ";
if (StringUtils.isEmpty(addCircuitVo.getAddressVoList().get(i).getCity())){ String expTimeVar = addCircuitVo.getStartAddressVo().getExpTime()+" ";
fb.setCode(0); String compTimeVar = "0 ";
fb.setMessage("城市不能为空"); String arrivalTimeVar=time +" ";
return gson.toJson(fb); String startTimeVar=time +" ";
} if(addCircuitVo.getAddressVoList() != null){
if (StringUtils.isEmpty(addCircuitVo.getAddressVoList().get(i).getAddressDetail())){ if(addCircuitVo.getAddressVoList().size()>3){
fb.setCode(0);
fb.setMessage("具体地址不能为空");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(addCircuitVo.getAddressVoList().get(i).getLat())){
fb.setCode(0); fb.setCode(0);
fb.setMessage("纬度不能为空"); fb.setMessage("途径地不能超过3个");
return gson.toJson(fb); return gson.toJson(fb);
} }
if(!addCircuitVo.getAddressVoList().get(i).getLat().matches("^-?(([1-9])((\\.\\d{1,6})?)|([1-8]\\d)((\\.\\d{1,6})?)|90)$")){ for(int i =0;i<addCircuitVo.getAddressVoList().size();i++){
fb.setCode(0); if(StringUtils.isEmpty(addCircuitVo.getAddressVoList().get(i).getCountry())){
fb.setMessage("纬度的范围为-90~90"); fb.setCode(0);
return gson.toJson(fb); fb.setMessage("途径地国家不能为空");
} return gson.toJson(fb);
if (StringUtils.isEmpty(addCircuitVo.getAddressVoList().get(i).getLng())){ }
fb.setCode(0); if (StringUtils.isEmpty(addCircuitVo.getAddressVoList().get(i).getCity())){
fb.setMessage("经度不能为空"); fb.setCode(0);
return gson.toJson(fb); fb.setMessage("途径地城市不能为空");
} return gson.toJson(fb);
if(!addCircuitVo.getAddressVoList().get(i).getLng().matches("^-?(([1-9]\\d?)((\\.\\d{1,6})?)|(1[1-7]\\d)((\\.\\d{1,6})?)|180)$")) { }
fb.setCode(0); if (StringUtils.isEmpty(addCircuitVo.getAddressVoList().get(i).getAddressDetail())){
fb.setMessage("经度的范围为-180~180"); fb.setCode(0);
return gson.toJson(fb); fb.setMessage("途径地具体地址不能为空");
} return gson.toJson(fb);
if (StringUtils.isEmpty(addCircuitVo.getAddressVoList().get(i).getPostCode())){ }
fb.setCode(0); if (StringUtils.isEmpty(addCircuitVo.getAddressVoList().get(i).getLat())){
fb.setMessage("邮编不能为空"); fb.setCode(0);
return gson.toJson(fb); fb.setMessage("途径地纬度不能为空");
} return gson.toJson(fb);
if (addCircuitVo.getAddressVoList().get(i).getSequence() == null) { }
fb.setCode(0); if(!addCircuitVo.getAddressVoList().get(i).getLat().matches("^-?(([1-9])((\\.\\d{1,6})?)|([1-8]\\d)((\\.\\d{1,6})?)|90)$")){
fb.setMessage("顺序不能为空"); fb.setCode(0);
return gson.toJson(fb); fb.setMessage("途径地纬度的范围为-90~90");
} return gson.toJson(fb);
if(addCircuitVo.getAddressVoList().get(i).getSequence()>=2 && addCircuitVo.getAddressVoList().get(i).getCompTime() == null){ }
fb.setCode(0); if (StringUtils.isEmpty(addCircuitVo.getAddressVoList().get(i).getLng())){
fb.setMessage("预计到达时间不能为空"); fb.setCode(0);
return gson.toJson(fb); fb.setMessage("途径地经度不能为空");
} return gson.toJson(fb);
if(addCircuitVo.getAddressVoList().get(i).getSequence()==1 && addCircuitVo.getAddressVoList().get(i).getExpTime() == null){ }
fb.setCode(0); if(!addCircuitVo.getAddressVoList().get(i).getLng().matches("^-?(([1-9]\\d?)((\\.\\d{1,6})?)|(1[1-7]\\d)((\\.\\d{1,6})?)|180)$")) {
fb.setMessage("预计开始时间不能为空"); fb.setCode(0);
return gson.toJson(fb); fb.setMessage("途径地经度的范围为-180~180");
} return gson.toJson(fb);
countryVar=countryVar +addCircuitVo.getAddressVoList().get(i).getCountry() +" "; }
cityVar=cityVar +addCircuitVo.getAddressVoList().get(i).getCity() +" "; if (StringUtils.isEmpty(addCircuitVo.getAddressVoList().get(i).getPostCode())){
addressDetailVar =addressDetailVar +addCircuitVo.getAddressVoList().get(i).getAddressDetail() +" "; fb.setCode(0);
lngVar = lngVar + addCircuitVo.getAddressVoList().get(i).getLng() +" "; fb.setMessage("途径地邮编不能为空");
latVar = latVar + addCircuitVo.getAddressVoList().get(i).getLat() +" "; return gson.toJson(fb);
postCodeVar=postCodeVar + addCircuitVo.getAddressVoList().get(i).getPostCode() +" "; }
if(addCircuitVo.getAddressVoList().get(i).getExpTime() ==null){ if (addCircuitVo.getAddressVoList().get(i).getExpTime() == null){
expTimeVar = expTimeVar + "0 "; fb.setCode(0);
}else{ fb.setMessage("途径地预计出发时间不能为空");
return gson.toJson(fb);
}
if (addCircuitVo.getAddressVoList().get(i).getCompTime() == null){
fb.setCode(0);
fb.setMessage("途径地预计到达时间不能为空");
return gson.toJson(fb);
}
countryVar=countryVar +addCircuitVo.getAddressVoList().get(i).getCountry() +" ";
cityVar=cityVar +addCircuitVo.getAddressVoList().get(i).getCity() +" ";
addressDetailVar =addressDetailVar +addCircuitVo.getAddressVoList().get(i).getAddressDetail() +" ";
lngVar = lngVar + addCircuitVo.getAddressVoList().get(i).getLng() +" ";
latVar = latVar + addCircuitVo.getAddressVoList().get(i).getLat() +" ";
postCodeVar=postCodeVar + addCircuitVo.getAddressVoList().get(i).getPostCode() +" ";
expTimeVar = expTimeVar +addCircuitVo.getAddressVoList().get(i).getExpTime() +" "; expTimeVar = expTimeVar +addCircuitVo.getAddressVoList().get(i).getExpTime() +" ";
}
if(addCircuitVo.getAddressVoList().get(i).getCompTime() == null){
compTimeVar = compTimeVar +"0 ";
}else{
compTimeVar = compTimeVar +addCircuitVo.getAddressVoList().get(i).getCompTime() +" "; compTimeVar = compTimeVar +addCircuitVo.getAddressVoList().get(i).getCompTime() +" ";
}
if(i ==0){
startTimeVar =startTimeVar + time +" ";
arrivalTimeVar = arrivalTimeVar +time +" ";
}else{
startTimeVar =startTimeVar + "0 "; startTimeVar =startTimeVar + "0 ";
arrivalTimeVar = arrivalTimeVar +"0 "; arrivalTimeVar = arrivalTimeVar +"0 ";
} }
} }
//根据sn获取type 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("目的地国家不能为空");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(addCircuitVo.getEndAddressVo().getCity())){
fb.setCode(0);
fb.setMessage("目的地城市不能为空");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(addCircuitVo.getEndAddressVo().getAddressDetail())){
fb.setCode(0);
fb.setMessage("目的地具体地址不能为空");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(addCircuitVo.getEndAddressVo().getLat())){
fb.setCode(0);
fb.setMessage("目的地纬度不能为空");
return gson.toJson(fb);
}
if(!addCircuitVo.getEndAddressVo().getLat().matches("^-?(([1-9])((\\.\\d{1,6})?)|([1-8]\\d)((\\.\\d{1,6})?)|90)$")){
fb.setCode(0);
fb.setMessage("目的地纬度的范围为-90~90");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(addCircuitVo.getEndAddressVo().getLng())){
fb.setCode(0);
fb.setMessage("目的地经度不能为空");
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);
fb.setMessage("目的地经度的范围为-180~180");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(addCircuitVo.getEndAddressVo().getPostCode())){
fb.setCode(0);
fb.setMessage("目的地邮编不能为空");
return gson.toJson(fb);
}
if (addCircuitVo.getEndAddressVo().getCompTime()==null){
fb.setCode(0);
fb.setMessage("目的地预计到达时间不能为空");
return gson.toJson(fb);
}
if(StringUtils.isEmpty(addCircuitVo.getSN())){
fb.setCode(0);
fb.setMessage("网关序列号不能为空");
return gson.toJson(fb);
}
String type =gatewayService.getBySN(addCircuitVo.getSN()); String type =gatewayService.getBySN(addCircuitVo.getSN());
//判断当前gateWay是否存在
if(StringUtils.isEmpty(type)){
fb.setCode(0);
fb.setMessage("该网关序不存在");
return gson.toJson(fb);
}
//获取gateway的场景 //获取gateway的场景
if(gatewayService.getBySNAndType(addCircuitVo.getSN(),type).getUseScene() !=2){ if(gatewayService.getBySNAndType(addCircuitVo.getSN(),type).getUseScene()== 2){
fb.setCode(0); fb.setCode(0);
fb.setMessage("该网关的使用场景与当前不符"); fb.setMessage("该网关的使用场景与当前不符");
return gson.toJson(fb); return gson.toJson(fb);
} }
String alarmTypeVar="";
String TDLSNVar="";
List<String> devList = tdlDeviceService.getByGatewaySN(addCircuitVo.getSN(),type); List<String> devList = tdlDeviceService.getByGatewaySN(addCircuitVo.getSN(),type);
devList.add(addCircuitVo.getTDLSN()); for(int j = 0;j<addCircuitVo.getTdlAlarmList().size();j++){
ConfigCMDVo configCMDVo = new ConfigCMDVo("config",5,15,devList,1,System.currentTimeMillis()/1000l); if(StringUtils.isEmpty(addCircuitVo.getTdlAlarmList().get(j).getTDLSN())){
fb.setCode(0);
fb.setMessage("tag序列号不能为空");
return gson.toJson(fb);
}
//判断当前tdl是否存在
ResultTDLDeviceVo tdlDeviceVo = tdlDeviceService.getByTDLSN(addCircuitVo.getTdlAlarmList().get(j).getTDLSN());
if(tdlDeviceVo == null){
fb.setCode(0);
fb.setMessage(addCircuitVo.getTdlAlarmList().get(j).getTDLSN() +"不存在");
return gson.toJson(fb);
}
if(!StringUtils.isEmpty(tdlDeviceVo.getGatewaySN())){
fb.setCode(0);
fb.setMessage(addCircuitVo.getTdlAlarmList().get(j).getTDLSN() +"已经被使用");
return gson.toJson(fb);
}
if(StringUtils.isEmpty(addCircuitVo.getTdlAlarmList().get(j).getAlarmType())){
fb.setCode(0);
fb.setMessage("预警类型");
return gson.toJson(fb);
}
alarmTypeVar =alarmTypeVar + addCircuitVo.getTdlAlarmList().get(j).getAlarmType() +" ";
TDLSNVar =TDLSNVar + addCircuitVo.getTdlAlarmList().get(j).getTDLSN() +" ";
devList.add(addCircuitVo.getTdlAlarmList().get(j).getTDLSN());
}
if(StringUtils.isEmpty(addCircuitVo.getCargoNo())){
fb.setCode(0);
fb.setMessage("货物编号不能为空");
return gson.toJson(fb);
}
if(StringUtils.isEmpty(addCircuitVo.getPlateNo())){
fb.setCode(0);
fb.setMessage("车牌号不能为空");
return gson.toJson(fb);
}
if(StringUtils.isEmpty(addCircuitVo.getCargoName())){
fb.setCode(0);
fb.setMessage("货物别名不能为空");
return gson.toJson(fb);
}
//根据sn获取type
ConfigCMDVo configCMDVo = new ConfigCMDVo("config",5,15,devList,1);
Map<Object,Object> map=new HashMap<>(); Map<Object,Object> map=new HashMap<>();
String transportation = "汽运"; String transportation = "汽运";
String transportationType="本地运输"; String transportationType="本地运输";
map.put("transportationNo",getTransportNo(transportation,transportationType)); map.put("transportationNo",getTransportNo(transportation,transportationType));
map.put("startTime",time); map.put("startTime",time);
map.put("expTime",addCircuitVo.getAddressVoList().get(0).getExpTime()); map.put("expTime",addCircuitVo.getStartAddressVo().getExpTime());
map.put("compTime",addCircuitVo.getAddressVoList().get(addCircuitVo.getAddressVoList().size()-1).getCompTime()); map.put("compTime",addCircuitVo.getEndAddressVo().getCompTime());
map.put("alarmType",addCircuitVo.getAlarmType());
map.put("cargoNo",addCircuitVo.getCargoNo()); map.put("cargoNo",addCircuitVo.getCargoNo());
map.put("cargoName",addCircuitVo.getCargoName()); map.put("cargoName",addCircuitVo.getCargoName());
map.put("plateNo",addCircuitVo.getPlateNo()); map.put("plateNo",addCircuitVo.getPlateNo());
...@@ -281,7 +408,7 @@ public class CircuitController { ...@@ -281,7 +408,7 @@ public class CircuitController {
map.put("transportationType",transportationType); map.put("transportationType",transportationType);
map.put("createTime",time); map.put("createTime",time);
map.put("remark",addCircuitVo.getRemark()); map.put("remark",addCircuitVo.getRemark());
map.put("counts",addCircuitVo.getAddressVoList().size()); map.put("counts",addCircuitVo.getAddressVoList()== null ? 0 : addCircuitVo.getAddressVoList().size());
map.put("countryVar",countryVar); map.put("countryVar",countryVar);
map.put("cityVar",cityVar); map.put("cityVar",cityVar);
map.put("addressDetailVar",addressDetailVar); map.put("addressDetailVar",addressDetailVar);
...@@ -294,7 +421,9 @@ public class CircuitController { ...@@ -294,7 +421,9 @@ public class CircuitController {
map.put("compTimeVar",compTimeVar); map.put("compTimeVar",compTimeVar);
map.put("SN",addCircuitVo.getSN()); map.put("SN",addCircuitVo.getSN());
map.put("type",type); map.put("type",type);
map.put("TDLSN",addCircuitVo.getTDLSN()); map.put("TDLSNVar",TDLSNVar);
map.put("alarmTypeVar",alarmTypeVar);
map.put("TDLCounts",addCircuitVo.getTdlAlarmList()== null ? 0 : addCircuitVo.getTdlAlarmList().size());
map.put("message",gson.toJson(configCMDVo)); map.put("message",gson.toJson(configCMDVo));
map.put("flag",false); map.put("flag",false);
map.put("untie",false); map.put("untie",false);
...@@ -348,226 +477,8 @@ public class CircuitController { ...@@ -348,226 +477,8 @@ public class CircuitController {
} }
// 修改线路信息
@ApiOperation(value = "修改线路信息",notes = "修改线路信息,传值说明:" +
" transportationNo:运输编号(自动生成,作为修改条件)" +
" addressVoList: 线路集合,包含" +
"{sequence:顺序(出发地0,目的地从1依次排序)" +
"country:国家" +
"city:城市" +
"addressDetail:详细地址" +
"lng:经度" +
"lat:纬度" +
"postCode:邮编"+
"expTime:预计开始时间,(传时间戳)" +
"compTime:预计结束时间,(传时间戳)}" +
" gSN:网关编号," +
" TDLSN:tdl编号," +
" alarmType:报警类型," +
" cargoNo:货物编号," +
" plateNo:车牌号," +
" cargoName:货物别名," +
" remark:备注")
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
@RequestMapping(value="/updateCircuit",method = RequestMethod.POST)
public Object updateCircuit(@RequestBody UpdateCircuitInfo updateCircuitInfo){
if (StringUtils.isEmpty(updateCircuitInfo.getTransportationNo())){
fb.setCode(0);
fb.setMessage("运输编号不能为空");
return gson.toJson(fb);
}
if(circuitService.getByTransportationNo(updateCircuitInfo.getTransportationNo()).getCircuitState()!=0){
fb.setCode(0);
fb.setMessage("只能在线路未开始运输时才能修改");
return gson.toJson(fb);
}
if(StringUtils.isEmpty(updateCircuitInfo.getSN())){
fb.setCode(0);
fb.setMessage("网关编号不能为空");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(updateCircuitInfo.getTDLSN())){
fb.setCode(0);
fb.setMessage("TDL编号不能为空");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(updateCircuitInfo.getAlarmType())){
fb.setCode(0);
fb.setMessage("报警类型不能为空");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(updateCircuitInfo.getCargoNo())){
fb.setCode(0);
fb.setMessage("货物编号不能为空");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(updateCircuitInfo.getPlateNo())){
fb.setCode(0);
fb.setMessage("车牌号不能为空");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(updateCircuitInfo.getCargoName())){
fb.setCode(0);
fb.setMessage("货物别名不能为空");
return gson.toJson(fb);
}
if(updateCircuitInfo.getAddressVoList().size() ==0){
fb.setCode(0);
fb.setMessage("起始城市不能为空");
return gson.toJson(fb);
}
if(updateCircuitInfo.getAddressVoList().size()==1){
fb.setCode(0);
fb.setMessage("目的地不能为空");
return gson.toJson(fb);
}
if(updateCircuitInfo.getAddressVoList().size()>4) {
fb.setCode(0);
fb.setMessage("目的地不能超过3个");
return gson.toJson(fb);
}
String countryVar="";
String cityVar="";
String addressDetailVar="";
String lngVar="";
String latVar = "";
String postCodeVar = "";
String expTimeVar = "";
String compTimeVar = "";
String arrivalTimeVar="";
String startTimeVar="";
Long time = System.currentTimeMillis();
for( int i= 0; i<updateCircuitInfo.getAddressVoList().size() ; i++){
if(updateCircuitInfo.getAddressVoList().get(i).getSequence() ==null){
fb.setCode(0);
fb.setMessage("顺序不能为空");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(updateCircuitInfo.getAddressVoList().get(i).getCountry())){
fb.setCode(0);
fb.setMessage("国家不能为空");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(updateCircuitInfo.getAddressVoList().get(i).getCity())){
fb.setCode(0);
fb.setMessage("城市不能为空");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(updateCircuitInfo.getAddressVoList().get(i).getAddressDetail())){
fb.setCode(0);
fb.setMessage("详细地址不能为空");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(updateCircuitInfo.getAddressVoList().get(i).getLng())){
fb.setCode(0);
fb.setMessage("经度不能为空");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(updateCircuitInfo.getAddressVoList().get(i).getLat())){
fb.setCode(0);
fb.setMessage("纬度不能为空");
return gson.toJson(fb);
}
if(!updateCircuitInfo.getAddressVoList().get(i).getLat().matches("^-?(([1-9])((\\.\\d{1,6})?)|([1-8]\\d)((\\.\\d{1,6})?)|90)$")){
fb.setCode(0);
fb.setMessage("纬度的范围为-90~90");
return gson.toJson(fb);
}
if(!updateCircuitInfo.getAddressVoList().get(i).getLng().matches("^-?(([1-9]\\d?)((\\.\\d{1,6})?)|(1[1-7]\\d)((\\.\\d{1,6})?)|180)$")) {
fb.setCode(0);
fb.setMessage("经度的范围为-180~180");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(updateCircuitInfo.getAddressVoList().get(i).getPostCode())){
fb.setCode(0);
fb.setMessage("邮编不能为空");
return gson.toJson(fb);
}
if(updateCircuitInfo.getAddressVoList().get(i).getSequence()>=2 && updateCircuitInfo.getAddressVoList().get(i).getCompTime() == null){
fb.setCode(0);
fb.setMessage("预计到达时间不能为空");
return gson.toJson(fb);
}
if(updateCircuitInfo.getAddressVoList().get(i).getSequence()==1 && updateCircuitInfo.getAddressVoList().get(i).getExpTime() == null){
fb.setCode(0);
fb.setMessage("预计开始时间不能为空");
return gson.toJson(fb);
}
countryVar=countryVar +updateCircuitInfo.getAddressVoList().get(i).getCountry() +" ";
cityVar=cityVar +updateCircuitInfo.getAddressVoList().get(i).getCity() +" ";
addressDetailVar =addressDetailVar +updateCircuitInfo.getAddressVoList().get(i).getAddressDetail() +" ";
lngVar = lngVar + updateCircuitInfo.getAddressVoList().get(i).getLng() +" ";
latVar = latVar + updateCircuitInfo.getAddressVoList().get(i).getLat() +" ";
postCodeVar=postCodeVar + updateCircuitInfo.getAddressVoList().get(i).getPostCode() +" ";
if(updateCircuitInfo.getAddressVoList().get(i).getExpTime() ==null){
expTimeVar = expTimeVar + "0 ";
}else{
expTimeVar = expTimeVar +updateCircuitInfo.getAddressVoList().get(i).getExpTime() +" ";
}
if(updateCircuitInfo.getAddressVoList().get(i).getCompTime() == null){
compTimeVar = compTimeVar +"0 ";
}else{
compTimeVar = compTimeVar +updateCircuitInfo.getAddressVoList().get(i).getCompTime() +" ";
}
if(i ==0){
startTimeVar =startTimeVar + time +" ";
arrivalTimeVar = arrivalTimeVar +time +" ";
}else{
startTimeVar =startTimeVar + "0 ";
arrivalTimeVar = arrivalTimeVar +"0 ";
}
}
Map<Object,Object> map=new HashMap<>();
String transportation = "汽运";
String transportationType="本地运输";
map.put("transportationNo",updateCircuitInfo.getTransportationNo());
map.put("startTime",time);
map.put("expTime",updateCircuitInfo.getAddressVoList().get(0).getExpTime());
map.put("compTime",updateCircuitInfo.getAddressVoList().get(updateCircuitInfo.getAddressVoList().size()-1).getCompTime());
map.put("alarmType",updateCircuitInfo.getAlarmType());
map.put("cargoNo",updateCircuitInfo.getCargoNo());
map.put("cargoName",updateCircuitInfo.getCargoName());
map.put("plateNo",updateCircuitInfo.getPlateNo());
map.put("deliveryAddress","站点");
map.put("transportation",transportation);
map.put("transportationType",transportationType);
map.put("createTime",time);
map.put("remark",updateCircuitInfo.getRemark());
map.put("counts",updateCircuitInfo.getAddressVoList().size());
map.put("countryVar",countryVar);
map.put("cityVar",cityVar);
map.put("addressDetailVar",addressDetailVar);
map.put("lngVar",lngVar);
map.put("latVar",latVar);
map.put("postCodeVar",postCodeVar);
map.put("arrivalTimeVar",arrivalTimeVar);
map.put("startTimeVar",startTimeVar);
map.put("expTimeVar",expTimeVar);
map.put("compTimeVar",compTimeVar);
// map.put("SN",addCircuitVo.getSN());
// map.put("type",type);
// map.put("TDLSN",addCircuitVo.getTDLSN());
// map.put("message",gson.toJson(configCMDVo));
// map.put("flag",false);
// map.put("untie",false);
circuitService.updateCircuit(map);
Map<Object,Object> msg=new HashMap<>();
msg.put("msg",map.get("msg"));
if (msg.get("msg").equals("修改线路成功")){
fb.setCode(1);
fb.setMessage("修改线路成功");
}else{
fb.setCode(0);
fb.setMessage(msg.get("msg").toString());
}
return gson.toJson(fb);
}
//根据车牌号查线路 //根据车牌号查线路
@ApiOperation(value = "获取线路信息",notes = "获取线路信息,返回值说明:" + @ApiOperation(value = "根据车牌号查线路",notes = "根据车牌号查线路,返回值说明:" +
" transportationNo:运输编号," + " transportationNo:运输编号," +
" cargoNo:货物编号" + " cargoNo:货物编号" +
" startCity:起运城市," + " startCity:起运城市," +
...@@ -691,7 +602,25 @@ public class CircuitController { ...@@ -691,7 +602,25 @@ public class CircuitController {
@ApiOperation(value = "根据线路编号获取线路详细信息",notes = "根据线路编号获取线路详细信息,传值说明:" + @ApiOperation(value = "根据线路编号获取线路详细信息",notes = "根据线路编号获取线路详细信息,传值说明:" +
" transportationNo:运输编号; " + " transportationNo:运输编号; " +
"返回值说明:" + "返回值说明:" +
" " ) " transportationNo:运输编号" +
" cargoNo:货物编号" +
" startCity:出发城市" +
" endCity:目的城市" +
" circuitState:线路状态" +
" evaluate:评价" +
" list:" +
" {city:城市" +
" time:到达时间/发车时间" +
" last:运行时长" +
" alarmCount:报警数" +
" type:1--出发时间;2--目的时间}" +
" alarmLogList:" +
" transportationNo:运输编号" +
" TDLSN:tag序列号" +
" description:报警描述" +
" data:数值" +
" alarmTime:报警时间" +
" classify:分类" )
@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"),
}) })
...@@ -834,7 +763,7 @@ public class CircuitController { ...@@ -834,7 +763,7 @@ public class CircuitController {
long nd = 1000 * 24 * 60 * 60; long nd = 1000 * 24 * 60 * 60;
long nh = 1000 * 60 * 60; long nh = 1000 * 60 * 60;
long nm = 1000 * 60; long nm = 1000 * 60;
long ns = 1000; long ns = 1000;
// 获得两个时间的毫秒时间差异 // 获得两个时间的毫秒时间差异
long diff = startTime- arrivalTime; long diff = startTime- arrivalTime;
// 计算差多少天 // 计算差多少天
...@@ -844,10 +773,213 @@ public class CircuitController { ...@@ -844,10 +773,213 @@ public class CircuitController {
// 计算差多少分钟 // 计算差多少分钟
long min = diff % nd % nh / nm; long min = diff % nd % nh / nm;
// 计算差多少秒//输出结果 // 计算差多少秒//输出结果
long sec = diff % nd % nh % nm / ns; long sec = diff % nd % nh % nm / ns;
return day + "天" + hour + "小时" + min + "分钟" +sec +"秒"; return day + "天" + hour + "小时" + min + "分钟" +sec +"秒";
} }
// 修改线路信息
// @ApiOperation(value = "修改线路信息",notes = "修改线路信息,传值说明:" +
// " transportationNo:运输编号(自动生成,作为修改条件)" +
// " addressVoList: 线路集合,包含" +
// "{sequence:顺序(出发地0,目的地从1依次排序)" +
// "country:国家" +
// "city:城市" +
// "addressDetail:详细地址" +
// "lng:经度" +
// "lat:纬度" +
// "postCode:邮编"+
// "expTime:预计开始时间,(传时间戳)" +
// "compTime:预计结束时间,(传时间戳)}" +
// " gSN:网关编号," +
// " TDLSN:tdl编号," +
// " alarmType:报警类型," +
// " cargoNo:货物编号," +
// " plateNo:车牌号," +
// " cargoName:货物别名," +
// " remark:备注")
// @ApiImplicitParams({
// @ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
// })
// @RequestMapping(value="/updateCircuit",method = RequestMethod.POST)
// public Object updateCircuit(@RequestBody UpdateCircuitInfo updateCircuitInfo){
// if (StringUtils.isEmpty(updateCircuitInfo.getTransportationNo())){
// fb.setCode(0);
// fb.setMessage("运输编号不能为空");
// return gson.toJson(fb);
// }
// if(circuitService.getByTransportationNo(updateCircuitInfo.getTransportationNo()).getCircuitState()!=0){
// fb.setCode(0);
// fb.setMessage("只能在线路未开始运输时才能修改");
// return gson.toJson(fb);
// }
// if(StringUtils.isEmpty(updateCircuitInfo.getSN())){
// fb.setCode(0);
// fb.setMessage("网关编号不能为空");
// return gson.toJson(fb);
// }
// if (StringUtils.isEmpty(updateCircuitInfo.getTDLSN())){
// fb.setCode(0);
// fb.setMessage("TDL编号不能为空");
// return gson.toJson(fb);
// }
// if (StringUtils.isEmpty(updateCircuitInfo.getAlarmType())){
// fb.setCode(0);
// fb.setMessage("报警类型不能为空");
// return gson.toJson(fb);
// }
// if (StringUtils.isEmpty(updateCircuitInfo.getCargoNo())){
// fb.setCode(0);
// fb.setMessage("货物编号不能为空");
// return gson.toJson(fb);
// }
// if (StringUtils.isEmpty(updateCircuitInfo.getPlateNo())){
// fb.setCode(0);
// fb.setMessage("车牌号不能为空");
// return gson.toJson(fb);
// }
// if (StringUtils.isEmpty(updateCircuitInfo.getCargoName())){
// fb.setCode(0);
// fb.setMessage("货物别名不能为空");
// return gson.toJson(fb);
// }
// if(updateCircuitInfo.getAddressVoList().size() ==0){
// fb.setCode(0);
// fb.setMessage("起始城市不能为空");
// return gson.toJson(fb);
// }
// if(updateCircuitInfo.getAddressVoList().size()==1){
// fb.setCode(0);
// fb.setMessage("目的地不能为空");
// return gson.toJson(fb);
// }
// if(updateCircuitInfo.getAddressVoList().size()>4) {
// fb.setCode(0);
// fb.setMessage("目的地不能超过3个");
// return gson.toJson(fb);
// }
// String countryVar="";
// String cityVar="";
// String addressDetailVar="";
// String lngVar="";
// String latVar = "";
// String postCodeVar = "";
// String expTimeVar = "";
// String compTimeVar = "";
// String arrivalTimeVar="";
// String startTimeVar="";
// Long time = System.currentTimeMillis();
// for( int i= 0; i<updateCircuitInfo.getAddressVoList().size() ; i++){
// if (StringUtils.isEmpty(updateCircuitInfo.getAddressVoList().get(i).getCountry())){
// fb.setCode(0);
// fb.setMessage("国家不能为空");
// return gson.toJson(fb);
// }
// if (StringUtils.isEmpty(updateCircuitInfo.getAddressVoList().get(i).getCity())){
// fb.setCode(0);
// fb.setMessage("城市不能为空");
// return gson.toJson(fb);
// }
// if (StringUtils.isEmpty(updateCircuitInfo.getAddressVoList().get(i).getAddressDetail())){
// fb.setCode(0);
// fb.setMessage("详细地址不能为空");
// return gson.toJson(fb);
// }
// if (StringUtils.isEmpty(updateCircuitInfo.getAddressVoList().get(i).getLng())){
// fb.setCode(0);
// fb.setMessage("经度不能为空");
// return gson.toJson(fb);
// }
// if (StringUtils.isEmpty(updateCircuitInfo.getAddressVoList().get(i).getLat())){
// fb.setCode(0);
// fb.setMessage("纬度不能为空");
// return gson.toJson(fb);
// }
// if(!updateCircuitInfo.getAddressVoList().get(i).getLat().matches("^-?(([1-9])((\\.\\d{1,6})?)|([1-8]\\d)((\\.\\d{1,6})?)|90)$")){
// fb.setCode(0);
// fb.setMessage("纬度的范围为-90~90");
// return gson.toJson(fb);
// }
// if(!updateCircuitInfo.getAddressVoList().get(i).getLng().matches("^-?(([1-9]\\d?)((\\.\\d{1,6})?)|(1[1-7]\\d)((\\.\\d{1,6})?)|180)$")) {
// fb.setCode(0);
// fb.setMessage("经度的范围为-180~180");
// return gson.toJson(fb);
// }
// if (StringUtils.isEmpty(updateCircuitInfo.getAddressVoList().get(i).getPostCode())){
// fb.setCode(0);
// fb.setMessage("邮编不能为空");
// return gson.toJson(fb);
// }
// countryVar=countryVar +updateCircuitInfo.getAddressVoList().get(i).getCountry() +" ";
// cityVar=cityVar +updateCircuitInfo.getAddressVoList().get(i).getCity() +" ";
// addressDetailVar =addressDetailVar +updateCircuitInfo.getAddressVoList().get(i).getAddressDetail() +" ";
// lngVar = lngVar + updateCircuitInfo.getAddressVoList().get(i).getLng() +" ";
// latVar = latVar + updateCircuitInfo.getAddressVoList().get(i).getLat() +" ";
// postCodeVar=postCodeVar + updateCircuitInfo.getAddressVoList().get(i).getPostCode() +" ";
// if(updateCircuitInfo.getAddressVoList().get(i).getExpTime() ==null){
// expTimeVar = expTimeVar + "0 ";
// }else{
// expTimeVar = expTimeVar +updateCircuitInfo.getAddressVoList().get(i).getExpTime() +" ";
// }
// if(updateCircuitInfo.getAddressVoList().get(i).getCompTime() == null){
// compTimeVar = compTimeVar +"0 ";
// }else{
// compTimeVar = compTimeVar +updateCircuitInfo.getAddressVoList().get(i).getCompTime() +" ";
// }
// if(i ==0){
// startTimeVar =startTimeVar + time +" ";
// arrivalTimeVar = arrivalTimeVar +time +" ";
// }else{
// startTimeVar =startTimeVar + "0 ";
// arrivalTimeVar = arrivalTimeVar +"0 ";
// }
// }
// Map<Object,Object> map=new HashMap<>();
// String transportation = "汽运";
// String transportationType="本地运输";
// map.put("transportationNo",updateCircuitInfo.getTransportationNo());
// map.put("startTime",time);
// map.put("expTime",updateCircuitInfo.getAddressVoList().get(0).getExpTime());
// map.put("compTime",updateCircuitInfo.getAddressVoList().get(updateCircuitInfo.getAddressVoList().size()-1).getCompTime());
// map.put("alarmType",updateCircuitInfo.getAlarmType());
// map.put("cargoNo",updateCircuitInfo.getCargoNo());
// map.put("cargoName",updateCircuitInfo.getCargoName());
// map.put("plateNo",updateCircuitInfo.getPlateNo());
// map.put("deliveryAddress","站点");
// map.put("transportation",transportation);
// map.put("transportationType",transportationType);
// map.put("createTime",time);
// map.put("remark",updateCircuitInfo.getRemark());
// map.put("counts",updateCircuitInfo.getAddressVoList().size());
// map.put("countryVar",countryVar);
// map.put("cityVar",cityVar);
// map.put("addressDetailVar",addressDetailVar);
// map.put("lngVar",lngVar);
// map.put("latVar",latVar);
// map.put("postCodeVar",postCodeVar);
// map.put("arrivalTimeVar",arrivalTimeVar);
// map.put("startTimeVar",startTimeVar);
// map.put("expTimeVar",expTimeVar);
// map.put("compTimeVar",compTimeVar);
//// map.put("SN",addCircuitVo.getSN());
//// map.put("type",type);
//// map.put("TDLSN",addCircuitVo.getTDLSN());
//// map.put("message",gson.toJson(configCMDVo));
//// map.put("flag",false);
//// map.put("untie",false);
// circuitService.updateCircuit(map);
// Map<Object,Object> msg=new HashMap<>();
// msg.put("msg",map.get("msg"));
// if (msg.get("msg").equals("修改线路成功")){
// fb.setCode(1);
// fb.setMessage("修改线路成功");
// }else{
// fb.setCode(0);
// fb.setMessage(msg.get("msg").toString());
// }
// return gson.toJson(fb);
// }
// @ApiOperation(value = "根据线路编号获取线路详细信息",notes = "根据线路编号获取线路详细信息,传值说明:" + // @ApiOperation(value = "根据线路编号获取线路详细信息",notes = "根据线路编号获取线路详细信息,传值说明:" +
// " transportationNo:运输编号; " + // " transportationNo:运输编号; " +
// "返回值说明:" + // "返回值说明:" +
......
...@@ -64,59 +64,6 @@ public class DataController { ...@@ -64,59 +64,6 @@ public class DataController {
private final static String database ="original"; private final static String database ="original";
//获取实时数据
@ApiOperation(value = "获取实时数据",notes = "获取实时数据")
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
@PostMapping("/getRealTimeData")
public Object getRealTimeData(@RequestBody String transportationNo){
JSONObject jsonObject= JSON.parseObject(transportationNo);
transportationNo=jsonObject.getString("transportationNo");
//获取gateway的信息
// ResultGatewayVo gatewayVo = circuitService.getByNo(transportationNo);
ResultGatewayVo gatewayVo = new ResultGatewayVo();
if(gatewayVo==null){
fb.setCode(0);
fb.setMessage("该线路未绑定设备");
return gson.toJson(fb);
}
//获取tdl信息
List<String> devList = tdlDeviceService.getByGatewaySN(gatewayVo.getSN(),gatewayVo.getType());
//根据gateWay获取tdl信息
List<String> key = new ArrayList<>();
key.add(gatewayVo.getSN()+"_"+gatewayVo.getType() +":"+gatewayVo.getSN()+"_"+gatewayVo.getType());
for (int i = 0;i<devList.size();i++){
key.add(gatewayVo.getSN()+"_"+gatewayVo.getType()+":"+devList.get(i));
}
List<LiveDataVo> liveDataVos = new ArrayList<>();
for(int j=0;j<key.size();j++){
Map<Object,Object> ret = realRedisService.getHashAll(key.get(j));
if(ret == null){
continue;
}else{
Iterator entries = ret.entrySet().iterator();
List<String> aliasList = new ArrayList<>();
List<String> valueList = new ArrayList<>();
while(entries.hasNext()){
Map.Entry entry = (Map.Entry) entries.next();
aliasList.add((String) entry.getKey());
valueList.add((String) entry.getValue());
}
//根据通道别名获取通道信息
List<ProbesVo> probesVoList = probesService.getByAliasList(gatewayVo.getSN(),gatewayVo.getType(),aliasList);
for(int m = 0;m<probesVoList.size();m++){
probesVoList.get(m).setValue(valueList.get(m));
}
LiveDataVo liveDataVo = new LiveDataVo();
liveDataVo.setKey(key.get(j).substring(key.get(j).indexOf(":"),key.get(j).length()));
liveDataVo.setProbesVoList(probesVoList);
liveDataVos.add(liveDataVo);
}
}
return gson.toJson(liveDataVos);
}
//获取坐标数据数据 //获取坐标数据数据
@ApiOperation(value = "获取坐标数据数据",notes = "获取坐标数据数据" + @ApiOperation(value = "获取坐标数据数据",notes = "获取坐标数据数据" +
"time:时间" + "time:时间" +
...@@ -195,94 +142,78 @@ public class DataController { ...@@ -195,94 +142,78 @@ public class DataController {
} }
//根据运输编号获取路线以及设备信息 //获取历史数据
@ApiOperation(value = "获取路线以及设备信息",notes = "获取路线以及设备信息" + @ApiOperation(value = "获取历史数据",notes = "获取历史数据" +
"transportationNo:运输编号" + "返回数据格式:" +
"startCity:启运城市" + " ")
"startTime:开始时间" + @PostMapping("/getHistoryData")
"endCity:目的城市" +
"endTime:结束时间(未结束为\"\")" +
"gatewaySN:网关编号" +
"battery:网关点量" +
"TDLSN:tdl编号" +
"batteryVoltage:tdl电压" +
"lastTime:运输时长(未结束为\"\")" +
"circuitState:运输状态(0--未开始,1--运输中,2--完成)" +
"remark:备注信息")
@PostMapping("/getCircuit")
@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"),
}) })
public Object getCircuit(@RequestBody String transportationNo){ public Object getHistoryData(@RequestBody String transportationNo){
JSONObject jsonObject= JSON.parseObject(transportationNo); JSONObject jsonObject= JSON.parseObject(transportationNo);
transportationNo=jsonObject.getString("transportationNo"); transportationNo=jsonObject.getString("transportationNo");
ResultCircuit resultCircuit = new ResultCircuit();
resultCircuit.setTransportationNo(transportationNo);
//根据运输编号获取线路信息,设备信息
ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(transportationNo); ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(transportationNo);
resultCircuit.setStartCity(resultCircuitVo.getStartCity());
resultCircuit.setStartTime(resultCircuitVo.getStartTime());
resultCircuit.setEndCity(resultCircuitVo.getEndCity());
ResultGatewayVo gatewayVo = new ResultGatewayVo(); ResultGatewayVo gatewayVo = new ResultGatewayVo();
if(resultCircuitVo.getEndTime() == 0){ if(resultCircuitVo.getEndTime() == 0){
resultCircuit.setEndTime(null);
resultCircuit.setLastTime(null);
gatewayVo = circuitService.getByNo(transportationNo); gatewayVo = circuitService.getByNo(transportationNo);
}else{ }else{
resultCircuit.setEndTime(resultCircuitVo.getEndTime());
resultCircuit.setLastTime(getDistanceTime(resultCircuit.getStartTime(),resultCircuit.getEndTime()));
gatewayVo = tdlLogService.getByNo(transportationNo); gatewayVo = tdlLogService.getByNo(transportationNo);
} }
//获取gateway的信息
if(gatewayVo==null){
fb.setCode(0);
fb.setMessage("该线路未绑定设备");
return gson.toJson(fb);
}
resultCircuit.setGatewaySN(gatewayVo.getSN());
String device = gatewayVo.getType() +"_" +gatewayVo.getSN(); String device = gatewayVo.getType() +"_" +gatewayVo.getSN();
Long startTime = resultCircuitVo.getStartTime() *1000000l;
//获取tdl信息
String sql = "SELECT \"battery\" FROM \"tdl_policy\".\""+device+"\" where time >= "+startTime +" ORDER BY time desc limit 1";
QueryResult queryResult = influxDBTemplate.query(new Query(sql,database));
if(queryResult.getResults().get(0).getSeries() != null){
List<List<Object>> values = getValues(queryResult);
for(List<Object> value:values){
logger.info(value.get(1).toString());
resultCircuit.setBattery(value.get(1)==null ? "": value.get(1).toString());
}
}
//获取tdl信息 //获取tdl信息
List<String> devList = tdlDeviceService.getByGatewaySN(gatewayVo.getSN(),gatewayVo.getType()); List<String> devList = tdlDeviceService.getByGatewaySN(gatewayVo.getSN(),gatewayVo.getType());
String key=gatewayVo.getSN()+"_"+gatewayVo.getType() +":"+gatewayVo.getSN()+"_"+gatewayVo.getType() ; String devcie=gatewayVo.getType()+"_"+gatewayVo.getSN() ;
//获取网关以及TDL的电量 Long startTime = resultCircuitVo.getStartTime() *1000000l;
if(devList.size() == 0 ){ if(devList.size() == 0){
fb.setCode(0); fb.setCode(0);
fb.setMessage("该线路未绑定设备"); fb.setMessage("没有数据");
return gson.toJson(fb); return gson.toJson(fb);
} }
for(int i = 0;i<devList.size();i++){ List<String> list = new ArrayList<String>(){{
String sql2 = "SELECT \"b\" FROM \"tdl_policy\".\""+device+"\" where \"tdl\"=\'tdl-"+devList.get(i)+"\'and time >= "+startTime +" ORDER BY time desc limit 1"; add("\"t\"");
QueryResult queryResult2 = influxDBTemplate.query(new Query(sql2,database)); add("\"h\"");
if(queryResult2.getResults().get(0).getSeries() != null){ add("\"p\"");
List<List<Object>> values = getValues(queryResult2); add("\"a0\"");
for(List<Object> value:values){ add("\"ta\"");
resultCircuit.setTDLSN(devList.get(i)); //add("\"t\"");
resultCircuit.setBatteryVoltage(value.get(1)==null ? "" :value.get(1).toString()); }};
Map<String,String> map = new HashMap<>();
map.put("\"t\"","temp");
map.put("\"h\"","humidity");
map.put("\"p\"","pressure");
map.put("\"a0\"","shockEnergy");
map.put("\"ta\"","tilt");
List<DataVo> dataVoList = new ArrayList<>();
for(int j = 0;j< list.size();j++){
DataVo dataVo = new DataVo();
dataVo.setDescription(map.get(list.get(j)));
List<HistoryDataVo> historyDataVoList = new ArrayList<>();
for( int i =0;i<devList.size();i++){
HistoryDataVo historyDataVo = new HistoryDataVo();
historyDataVo.setTDLSN(devList.get(i));
String sql = "SELECT "+list.get(i)+" FROM \"tdl_policy\".\""+devcie+"\" where \"tdl\"=\'"+devList.get(i)+"\' and time >="+startTime + " ORDER BY time ";
QueryResult queryResult = influxDBTemplate.query(new Query(sql,database));
List<HistoryData> historyData = new ArrayList<>();
if(queryResult.getResults().get(0).getSeries() != null){
//解析数据
historyData = getHistoryData(queryResult);
} }
historyDataVo.setDataList(historyData);
historyDataVoList.add(historyDataVo);
} }
dataVo.setDataList(historyDataVoList);
dataVoList.add(dataVo);
} }
resultCircuit.setCircuitState(resultCircuitVo.getCircuitState()); return gson.toJson(dataVoList);
return gson.toJson(resultCircuit);
} }
//获取温度数据 //获取温度数据
@ApiOperation(value = "获取温度数据",notes = "获取温度数据" + @ApiOperation(value = "获取温度数据",notes = "获取温度数据" +
"TDLSN:tdl编号" + "TDLSN:tdl编号" +
"temperatureDataVos:" + "temperatureDataVos:" +
"time:时间" + "time:时间" +
"value:温度数据") "value:温度数据")
@PostMapping("/getTemperature") @PostMapping("/getTemperature")
@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"),
...@@ -312,7 +243,7 @@ public class DataController { ...@@ -312,7 +243,7 @@ public class DataController {
for( int i =0;i<devList.size();i++){ for( int i =0;i<devList.size();i++){
Temperature temperature = new Temperature(); Temperature temperature = new Temperature();
temperature.setTDLSN(devList.get(i)); temperature.setTDLSN(devList.get(i));
String sql = "SELECT \"t\" FROM \"tdl_policy\".\""+devcie+"\" where \"tdl\"=\'"+devList.get(i)+"\' and time >="+startTime + " ORDER BY time "; String sql = "SELECT \"t\" FROM \"tdl_policy\".\""+devcie+"\" where \"tdl\"=\'"+devList.get(i)+"\' and time >="+startTime+" ORDER BY time ";
QueryResult queryResult = influxDBTemplate.query(new Query(sql,database)); QueryResult queryResult = influxDBTemplate.query(new Query(sql,database));
List<TemperatureDataVo> temperatureDataVos = new ArrayList<>(); List<TemperatureDataVo> temperatureDataVos = new ArrayList<>();
if(queryResult.getResults().get(0).getSeries() != null){ if(queryResult.getResults().get(0).getSeries() != null){
...@@ -322,17 +253,9 @@ public class DataController { ...@@ -322,17 +253,9 @@ public class DataController {
temperature.setTemperatureDataVos(temperatureDataVos); temperature.setTemperatureDataVos(temperatureDataVos);
temperatures.add(temperature); temperatures.add(temperature);
} }
/*String sql = "SELECT \"t\" FROM \"tdl_policy\".\""+devcie+"\" ORDER BY time ";
QueryResult queryResult = influxDBTemplate.query(new Query(sql,database));
List<TemperatureDataVo> temperatureDataVos = new ArrayList<>();
if(queryResult.getResults().get(0).getSeries() != null){
//解析数据
temperatureDataVos = getTemperature(queryResult);
}*/
return gson.toJson(temperatures); return gson.toJson(temperatures);
} }
//获取湿度数据 //获取湿度数据
@ApiOperation(value = "获取湿度数据",notes = "获取湿度数据") @ApiOperation(value = "获取湿度数据",notes = "获取湿度数据")
@PostMapping("/getHumidity") @PostMapping("/getHumidity")
...@@ -485,113 +408,6 @@ public class DataController { ...@@ -485,113 +408,6 @@ public class DataController {
} }
//根据运输编号获取所有的报警数据
@ApiOperation(value = "根据运输编号获取所有的报警数据????",notes = "根据运输编号获取所有的报警数据")
@PostMapping("/getAlarmData")
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
public Object getAlarmData(@RequestBody String transportationNo){
JSONObject jsonObject= JSON.parseObject(transportationNo);
transportationNo=jsonObject.getString("transportationNo");
//根据运输编号获取报警信息
List<ResultAlarmLog> alarmLogVoList = alarmLogService.getByTransportationNo(transportationNo);
return gson.toJson(alarmLogVoList);
}
//根据时间获取经纬度信息
@ApiOperation(value = "根据时间获取经纬度信息",notes = "根据时间获取经纬度信息" +
"transportationNo:运输编号" +
"TDLSN:tdl编号" +
"gatewaySN:网关编号" +
"startCity:出发城市" +
"endCity:目的城市" +
"startTime:出发时间" +
"endTime:到达时间" +
"alarmTime:报警时间" +
"alarmType:报警类型" +
"alarmValue:报警值" +
"lng:经度" +
"lat:纬度")
@PostMapping("/getLocationByTime")
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
public Object getLocationByTime(@RequestBody LocationVo locationVo ){
//获取线路信息
//获取网关以及tdl信息
ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(locationVo.getTransportationNo());
ResultGatewayVo gatewayVo = new ResultGatewayVo();
if(resultCircuitVo.getEndTime() == 0){
gatewayVo = circuitService.getByNo(locationVo.getTransportationNo());
}else{
gatewayVo = tdlLogService.getByNo(locationVo.getTransportationNo());
}
String device = gatewayVo.getType() +"_" +gatewayVo.getSN();
//获取tdl信息
List<String> devList = tdlDeviceService.getByGatewaySN(gatewayVo.getSN(),gatewayVo.getType());
String devcie=gatewayVo.getType()+"_"+gatewayVo.getSN() ;
//根据时间获取坐标信息
String sql ="SELECT \"lng\",\"lat\" FROM \"tdl_policy\".\""+devcie+"\" where time = "+locationVo.getTime() *1000000l;
QueryResult queryResult = influxDBTemplate.query(new Query(sql,database));
List<LocationMessageVo> locationDataVos = new ArrayList<>();
if(queryResult.getResults().get(0).getSeries() != null){
List<List<Object>> values = getValues(queryResult);
for(List<Object> value:values){
LocationMessageVo messageVo = new LocationMessageVo();
messageVo.setTransportationNo(locationVo.getTransportationNo());
messageVo.setGatewaySN(gatewayVo.getSN());
messageVo.setTDLSN(devList);
messageVo.setStartCity(resultCircuitVo.getStartCity());
messageVo.setEndCity(resultCircuitVo.getEndCity());
messageVo.setStartTime(resultCircuitVo.getStartTime());
messageVo.setEndTime(resultCircuitVo.getEndTime());
messageVo.setAlarmTime(Long.valueOf(parseTime(value.get(0).toString())));
messageVo.setAlarmType(locationVo.getAlarmType());
messageVo.setAlarmValue(locationVo.getVlaue());
messageVo.setLng(value.get(1)==null ? "" : value.get(1).toString());
messageVo.setLat(value.get(2)==null ? "" : value.get(2).toString());
locationDataVos.add(messageVo);
}
}
return gson.toJson(locationDataVos);
}
//获取温度、湿度、震动强度、震动能量、倾斜度
@PostMapping("/getDeviceData")
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
public Object getDeviceData(@RequestBody String transportationNo){
JSONObject jsonObject= JSON.parseObject(transportationNo);
transportationNo=jsonObject.getString("transportationNo");
//获取网关以及tdl信息
ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(transportationNo);
ResultGatewayVo gatewayVo = new ResultGatewayVo();
if(resultCircuitVo.getEndTime() == 0){
gatewayVo = circuitService.getByNo(transportationNo);
}else{
gatewayVo = tdlLogService.getByNo(transportationNo);
}
String device = gatewayVo.getType() +"_" +gatewayVo.getSN();
Long startTime = resultCircuitVo.getStartTime() *1000000l;
//获取tdl信息
List<String> devList = tdlDeviceService.getByGatewaySN(gatewayVo.getSN(),gatewayVo.getType());
String devcie=gatewayVo.getType()+"_"+gatewayVo.getSN() ;
//SELECT "h" FROM "tdl_policy"."WTD93LG_20180314" WHERE "tdl" = 'tdl-0A0B0C0D0F' ORDER BY time DESC
String sql = "SELECT \"t\",\"h\",\"p\",\"a0\",\"ta\" FROM \"tdl_policy\".\""+devcie+"\" where \"tdl\" = \'"+devList.get(0)+"\' and time>="+startTime+" ORDER BY time ";
QueryResult queryResult = influxDBTemplate.query(new Query(sql,database));
//解析经纬度数据
List<DeviceDataVo> deviceDataVos = new ArrayList<>();
if(queryResult.getResults().get(0).getSeries() != null){
deviceDataVos= getDeviceData(queryResult);
}
return gson.toJson(deviceDataVos);
}
//解析数据 //解析数据
public List<LocationDataVo> getLocation(QueryResult queryResult){ public List<LocationDataVo> getLocation(QueryResult queryResult){
List<List<Object>> values = getValues(queryResult); List<List<Object>> values = getValues(queryResult);
...@@ -607,17 +423,13 @@ public class DataController { ...@@ -607,17 +423,13 @@ public class DataController {
return historyDataList; return historyDataList;
} }
public List<DeviceDataVo> getDeviceData(QueryResult queryResult){ public List<HistoryData> getHistoryData(QueryResult queryResult){
List<List<Object>> values = getValues(queryResult); List<List<Object>> values = getValues(queryResult);
List<DeviceDataVo> historyDataList = new ArrayList<>(); List<HistoryData> historyDataList = new ArrayList<>();
for(List<Object> value:values){ for(List<Object> value:values){
DeviceDataVo historyData = new DeviceDataVo(); HistoryData historyData = new HistoryData();
historyData.setTime(parseTime(value.get(0).toString())); historyData.setTime(parseTime(value.get(0).toString()));
historyData.setTemperature(value.get(1)==null ? "" :value.get(1).toString()); historyData.setValue(value.get(1)==null ? "" :value.get(1).toString());
historyData.setHumidity(value.get(2)==null ? "" :value.get(2).toString());
historyData.setPressure(value.get(3)==null ? "" :value.get(3).toString());
historyData.setShockEnergy(value.get(4)==null ? "" :value.get(4).toString());
historyData.setTiltAngle(value.get(5)==null ? "" :value.get(5).toString());
historyDataList.add(historyData); historyDataList.add(historyData);
} }
return historyDataList; return historyDataList;
...@@ -786,7 +598,6 @@ public class DataController { ...@@ -786,7 +598,6 @@ public class DataController {
return String.valueOf(calendar.getTimeInMillis()); return String.valueOf(calendar.getTimeInMillis());
} }
public List<String> getShockLocation(QueryResult queryResult){ public List<String> getShockLocation(QueryResult queryResult){
List<List<Object>> values = new ArrayList<>(); List<List<Object>> values = new ArrayList<>();
for(QueryResult.Result result : queryResult.getResults()){ for(QueryResult.Result result : queryResult.getResults()){
...@@ -805,4 +616,246 @@ public class DataController { ...@@ -805,4 +616,246 @@ public class DataController {
return timeList; return timeList;
} }
public List<DeviceDataVo> getDeviceData(QueryResult queryResult){
List<List<Object>> values = getValues(queryResult);
List<DeviceDataVo> historyDataList = new ArrayList<>();
for(List<Object> value:values){
DeviceDataVo historyData = new DeviceDataVo();
historyData.setTime(parseTime(value.get(0).toString()));
historyData.setTemperature(value.get(1)==null ? "" :value.get(1).toString());
historyData.setHumidity(value.get(2)==null ? "" :value.get(2).toString());
historyData.setPressure(value.get(3)==null ? "" :value.get(3).toString());
historyData.setShockEnergy(value.get(4)==null ? "" :value.get(4).toString());
historyData.setTiltAngle(value.get(5)==null ? "" :value.get(5).toString());
historyDataList.add(historyData);
}
return historyDataList;
}
//根据运输编号获取路线以及设备信息
// @ApiOperation(value = "获取路线以及设备信息",notes = "获取路线以及设备信息" +
// "transportationNo:运输编号" +
// "startCity:启运城市" +
// "startTime:开始时间" +
// "endCity:目的城市" +
// "endTime:结束时间(未结束为\"\")" +
// "gatewaySN:网关编号" +
// "battery:网关点量" +
// "TDLSN:tdl编号" +
// "batteryVoltage:tdl电压" +
// "lastTime:运输时长(未结束为\"\")" +
// "circuitState:运输状态(0--未开始,1--运输中,2--完成)" +
// "remark:备注信息")
// @PostMapping("/getCircuit")
// @ApiImplicitParams({
// @ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
// })
// public Object getCircuit(@RequestBody String transportationNo){
// JSONObject jsonObject= JSON.parseObject(transportationNo);
// transportationNo=jsonObject.getString("transportationNo");
// ResultCircuit resultCircuit = new ResultCircuit();
// resultCircuit.setTransportationNo(transportationNo);
// //根据运输编号获取线路信息,设备信息
// ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(transportationNo);
// resultCircuit.setStartCity(resultCircuitVo.getStartCity());
// resultCircuit.setStartTime(resultCircuitVo.getStartTime());
// resultCircuit.setEndCity(resultCircuitVo.getEndCity());
// ResultGatewayVo gatewayVo = new ResultGatewayVo();
// if(resultCircuitVo.getEndTime() == 0){
// resultCircuit.setEndTime(null);
// resultCircuit.setLastTime(null);
// gatewayVo = circuitService.getByNo(transportationNo);
// }else{
// resultCircuit.setEndTime(resultCircuitVo.getEndTime());
// resultCircuit.setLastTime(getDistanceTime(resultCircuit.getStartTime(),resultCircuit.getEndTime()));
// gatewayVo = tdlLogService.getByNo(transportationNo);
// }
// //获取gateway的信息
// if(gatewayVo==null){
// fb.setCode(0);
// fb.setMessage("该线路未绑定设备");
// return gson.toJson(fb);
// }
// resultCircuit.setGatewaySN(gatewayVo.getSN());
// String device = gatewayVo.getType() +"_" +gatewayVo.getSN();
// Long startTime = resultCircuitVo.getStartTime() *1000000l;
// //获取tdl信息
// String sql = "SELECT \"battery\" FROM \"tdl_policy\".\""+device+"\" where time >= "+startTime +" ORDER BY time desc limit 1";
// QueryResult queryResult = influxDBTemplate.query(new Query(sql,database));
// if(queryResult.getResults().get(0).getSeries() != null){
// List<List<Object>> values = getValues(queryResult);
// for(List<Object> value:values){
// logger.info(value.get(1).toString());
// resultCircuit.setBattery(value.get(1)==null ? "": value.get(1).toString());
// }
// }
// //获取tdl信息
// List<String> devList = tdlDeviceService.getByGatewaySN(gatewayVo.getSN(),gatewayVo.getType());
// String key=gatewayVo.getSN()+"_"+gatewayVo.getType() +":"+gatewayVo.getSN()+"_"+gatewayVo.getType() ;
// //获取网关以及TDL的电量
// if(devList.size() == 0 ){
// fb.setCode(0);
// fb.setMessage("该线路未绑定设备");
// return gson.toJson(fb);
// }
// for(int i = 0;i<devList.size();i++){
// String sql2 = "SELECT \"b\" FROM \"tdl_policy\".\""+device+"\" where \"tdl\"=\'tdl-"+devList.get(i)+"\'and time >= "+startTime +" ORDER BY time desc limit 1";
// QueryResult queryResult2 = influxDBTemplate.query(new Query(sql2,database));
// if(queryResult2.getResults().get(0).getSeries() != null){
// List<List<Object>> values = getValues(queryResult2);
// for(List<Object> value:values){
// resultCircuit.setTDLSN(devList.get(i));
// resultCircuit.setBatteryVoltage(value.get(1)==null ? "" :value.get(1).toString());
// }
// }
// }
// resultCircuit.setCircuitState(resultCircuitVo.getCircuitState());
// return gson.toJson(resultCircuit);
// }
//根据时间获取经纬度信息
// @ApiOperation(value = "根据时间获取经纬度信息",notes = "根据时间获取经纬度信息" +
// "transportationNo:运输编号" +
// "TDLSN:tdl编号" +
// "gatewaySN:网关编号" +
// "startCity:出发城市" +
// "endCity:目的城市" +
// "startTime:出发时间" +
// "endTime:到达时间" +
// "alarmTime:报警时间" +
// "alarmType:报警类型" +
// "alarmValue:报警值" +
// "lng:经度" +
// "lat:纬度")
// @PostMapping("/getLocationByTime")
// @ApiImplicitParams({
// @ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
// })
// public Object getLocationByTime(@RequestBody LocationVo locationVo ){
// //获取线路信息
// //获取网关以及tdl信息
// ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(locationVo.getTransportationNo());
// ResultGatewayVo gatewayVo = new ResultGatewayVo();
// if(resultCircuitVo.getEndTime() == 0){
// gatewayVo = circuitService.getByNo(locationVo.getTransportationNo());
// }else{
// gatewayVo = tdlLogService.getByNo(locationVo.getTransportationNo());
// }
// String device = gatewayVo.getType() +"_" +gatewayVo.getSN();
// //获取tdl信息
// List<String> devList = tdlDeviceService.getByGatewaySN(gatewayVo.getSN(),gatewayVo.getType());
// String devcie=gatewayVo.getType()+"_"+gatewayVo.getSN() ;
// //根据时间获取坐标信息
// String sql ="SELECT \"lng\",\"lat\" FROM \"tdl_policy\".\""+devcie+"\" where time = "+locationVo.getTime() *1000000l;
// QueryResult queryResult = influxDBTemplate.query(new Query(sql,database));
// List<LocationMessageVo> locationDataVos = new ArrayList<>();
// if(queryResult.getResults().get(0).getSeries() != null){
// List<List<Object>> values = getValues(queryResult);
// for(List<Object> value:values){
// LocationMessageVo messageVo = new LocationMessageVo();
// messageVo.setTransportationNo(locationVo.getTransportationNo());
// messageVo.setGatewaySN(gatewayVo.getSN());
// messageVo.setTDLSN(devList);
// messageVo.setStartCity(resultCircuitVo.getStartCity());
// messageVo.setEndCity(resultCircuitVo.getEndCity());
// messageVo.setStartTime(resultCircuitVo.getStartTime());
// messageVo.setEndTime(resultCircuitVo.getEndTime());
// messageVo.setAlarmTime(Long.valueOf(parseTime(value.get(0).toString())));
// messageVo.setAlarmType(locationVo.getAlarmType());
// messageVo.setAlarmValue(locationVo.getVlaue());
// messageVo.setLng(value.get(1)==null ? "" : value.get(1).toString());
// messageVo.setLat(value.get(2)==null ? "" : value.get(2).toString());
// locationDataVos.add(messageVo);
// }
// }
// return gson.toJson(locationDataVos);
// }
//获取温度、湿度、震动强度、震动能量、倾斜度
// @PostMapping("/getDeviceData")
// @ApiImplicitParams({
// @ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
// })
// public Object getDeviceData(@RequestBody String transportationNo){
// JSONObject jsonObject= JSON.parseObject(transportationNo);
// transportationNo=jsonObject.getString("transportationNo");
// //获取网关以及tdl信息
// ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(transportationNo);
// ResultGatewayVo gatewayVo = new ResultGatewayVo();
// if(resultCircuitVo.getEndTime() == 0){
// gatewayVo = circuitService.getByNo(transportationNo);
// }else{
// gatewayVo = tdlLogService.getByNo(transportationNo);
// }
// String device = gatewayVo.getType() +"_" +gatewayVo.getSN();
// Long startTime = resultCircuitVo.getStartTime() *1000000l;
// //获取tdl信息
// List<String> devList = tdlDeviceService.getByGatewaySN(gatewayVo.getSN(),gatewayVo.getType());
// String devcie=gatewayVo.getType()+"_"+gatewayVo.getSN() ;
// //SELECT "h" FROM "tdl_policy"."WTD93LG_20180314" WHERE "tdl" = 'tdl-0A0B0C0D0F' ORDER BY time DESC
// String sql = "SELECT \"t\",\"h\",\"p\",\"a0\",\"ta\" FROM \"tdl_policy\".\""+devcie+"\" where \"tdl\" = \'"+devList.get(0)+"\' and time>="+startTime+" ORDER BY time ";
// QueryResult queryResult = influxDBTemplate.query(new Query(sql,database));
// //解析经纬度数据
// List<DeviceDataVo> deviceDataVos = new ArrayList<>();
// if(queryResult.getResults().get(0).getSeries() != null){
// deviceDataVos= getDeviceData(queryResult);
// }
// return gson.toJson(deviceDataVos);
// }
//获取实时数据
// @ApiOperation(value = "获取实时数据",notes = "获取实时数据")
// @ApiImplicitParams({
// @ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
// })
// @PostMapping("/getRealTimeData")
// public Object getRealTimeData(@RequestBody String transportationNo){
// JSONObject jsonObject= JSON.parseObject(transportationNo);
// transportationNo=jsonObject.getString("transportationNo");
// //获取gateway的信息
// // ResultGatewayVo gatewayVo = circuitService.getByNo(transportationNo);
// ResultGatewayVo gatewayVo = new ResultGatewayVo();
// if(gatewayVo==null){
// fb.setCode(0);
// fb.setMessage("该线路未绑定设备");
// return gson.toJson(fb);
// }
// //获取tdl信息
// List<String> devList = tdlDeviceService.getByGatewaySN(gatewayVo.getSN(),gatewayVo.getType());
// //根据gateWay获取tdl信息
// List<String> key = new ArrayList<>();
// key.add(gatewayVo.getSN()+"_"+gatewayVo.getType() +":"+gatewayVo.getSN()+"_"+gatewayVo.getType());
// for (int i = 0;i<devList.size();i++){
// key.add(gatewayVo.getSN()+"_"+gatewayVo.getType()+":"+devList.get(i));
// }
// List<LiveDataVo> liveDataVos = new ArrayList<>();
// for(int j=0;j<key.size();j++){
// Map<Object,Object> ret = realRedisService.getHashAll(key.get(j));
// if(ret == null){
// continue;
// }else{
// Iterator entries = ret.entrySet().iterator();
// List<String> aliasList = new ArrayList<>();
// List<String> valueList = new ArrayList<>();
// while(entries.hasNext()){
// Map.Entry entry = (Map.Entry) entries.next();
// aliasList.add((String) entry.getKey());
// valueList.add((String) entry.getValue());
// }
// //根据通道别名获取通道信息
// List<ProbesVo> probesVoList = probesService.getByAliasList(gatewayVo.getSN(),gatewayVo.getType(),aliasList);
// for(int m = 0;m<probesVoList.size();m++){
// probesVoList.get(m).setValue(valueList.get(m));
// }
// LiveDataVo liveDataVo = new LiveDataVo();
// liveDataVo.setKey(key.get(j).substring(key.get(j).indexOf(":"),key.get(j).length()));
// liveDataVo.setProbesVoList(probesVoList);
// liveDataVos.add(liveDataVo);
// }
// }
// return gson.toJson(liveDataVos);
// }
} }
\ No newline at end of file
...@@ -3,12 +3,13 @@ package com.example.tdl.web; ...@@ -3,12 +3,13 @@ package com.example.tdl.web;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.FloatArraySerializer;
import com.example.tdl.domain.dto.CommFeedback; import com.example.tdl.domain.dto.CommFeedback;
import com.example.tdl.domain.vo.*; import com.example.tdl.domain.vo.*;
import com.example.tdl.service.AlarmService;
import com.example.tdl.service.ConfigService; import com.example.tdl.service.ConfigService;
import com.example.tdl.service.GatewayService; import com.example.tdl.service.GatewayService;
import com.example.tdl.service.TDLDeviceService; import com.example.tdl.service.TDLDeviceService;
import com.example.tdl.service.redis.AlarmRedisService;
import com.google.gson.Gson; import com.google.gson.Gson;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
...@@ -22,6 +23,7 @@ import org.springframework.web.bind.annotation.RequestBody; ...@@ -22,6 +23,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -44,6 +46,21 @@ public class EquipmentBindingController { ...@@ -44,6 +46,21 @@ public class EquipmentBindingController {
@Autowired @Autowired
private TDLDeviceService tdlDeviceService; private TDLDeviceService tdlDeviceService;
@Autowired
private AlarmRedisService alarmRedisService;
@Autowired
private AlarmService alarmService;
List<String> list = new ArrayList<String>(){{
add("T");
add("h");
add("a0");
add("ta");
// add("");
// add("");
}};
@ApiOperation(value = "绑定gateWay和tdl",notes = "绑定gateWay和tdl" + @ApiOperation(value = "绑定gateWay和tdl",notes = "绑定gateWay和tdl" +
" SN:gateWay编号," + " SN:gateWay编号," +
" type:gateWay类型," + " type:gateWay类型," +
...@@ -86,6 +103,7 @@ public class EquipmentBindingController { ...@@ -86,6 +103,7 @@ public class EquipmentBindingController {
map.put("useScene",bindingVo.getMode()); map.put("useScene",bindingVo.getMode());
map.put("gSN",bindingVo.getSN()); map.put("gSN",bindingVo.getSN());
map.put("gType",bindingVo.getType()); map.put("gType",bindingVo.getType());
map.put("alarmType",bindingVo.getAlarmType());
map.put("message",gson.toJson(configCMDVo)); map.put("message",gson.toJson(configCMDVo));
map.put("flag",false); map.put("flag",false);
map.put("resp",null); map.put("resp",null);
...@@ -99,6 +117,34 @@ public class EquipmentBindingController { ...@@ -99,6 +117,34 @@ public class EquipmentBindingController {
if (msg.get("msg").equals("配置网关成功")){ if (msg.get("msg").equals("配置网关成功")){
fb.setCode(1); fb.setCode(1);
fb.setMessage(msg.get("msg").toString()); fb.setMessage(msg.get("msg").toString());
//根据报警类型货报警信息
ResultAlarmVo alarmVo = alarmService.getByTypeAndScene(bindingVo.getAlarmType(),"运输");
for(String alias :list){
List<AlarmRuleVo> alarmRuleVos = new ArrayList<>();
AlarmRuleVo alarmRuleVo = new AlarmRuleVo();
if(alias.equals("T")){
alarmRuleVo.setMinval(String.valueOf(alarmVo.getTemMin()));
alarmRuleVo.setMaxval(String.valueOf(alarmVo.getTemMax()));
alarmRuleVo.setMode("twoway");
alarmRuleVo.setPriority("1");
}else if(alias.equals("h")){
alarmRuleVo.setMinval(String.valueOf(alarmVo.getHumidityMin()));
alarmRuleVo.setMaxval(String.valueOf(alarmVo.getHumidityMax()));
alarmRuleVo.setMode("twoway");
alarmRuleVo.setPriority("1");
}else if(alias.equals("ta")){
alarmRuleVo.setMinval(String.valueOf(alarmVo.getTilt()));
alarmRuleVo.setMode("equal");
alarmRuleVo.setPriority("1");
}else if(alias.equals("a0")){
alarmRuleVo.setMinval(String.valueOf(alarmVo.getShock()));
alarmRuleVo.setMode("equal");
alarmRuleVo.setPriority("1");
}
alarmRuleVos.add(alarmRuleVo);
//向redis中写入报警信息
alarmRedisService.hmSet("TDL/"+bindingVo.getType()+"/" +bindingVo.getSN()+"/Data","tdl-" +bindingVo.getTDLSN()+"_" +alias,gson.toJson(alarmRuleVos));
}
}else{ }else{
fb.setCode(0); fb.setCode(0);
fb.setMessage(msg.get("msg").toString()); fb.setMessage(msg.get("msg").toString());
...@@ -106,6 +152,9 @@ public class EquipmentBindingController { ...@@ -106,6 +152,9 @@ public class EquipmentBindingController {
return gson.toJson(fb); return gson.toJson(fb);
} }
@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"),
...@@ -141,6 +190,8 @@ public class EquipmentBindingController { ...@@ -141,6 +190,8 @@ public class EquipmentBindingController {
if (msg.get("msg").equals("解除网关成功")){ if (msg.get("msg").equals("解除网关成功")){
fb.setCode(1); fb.setCode(1);
fb.setMessage(msg.get("msg").toString()); fb.setMessage(msg.get("msg").toString());
String key ="TDL/"+resultTDLDeviceVo.getGatewayType()+"/" +resultTDLDeviceVo.getGatewaySN() +"/Data";
alarmRedisService.delKey(key);
}else{ }else{
fb.setCode(0); fb.setCode(0);
fb.setMessage(msg.get("msg").toString()); fb.setMessage(msg.get("msg").toString());
......
...@@ -3,18 +3,14 @@ ...@@ -3,18 +3,14 @@
<mapper namespace="com.example.tdl.mapper.CircuitMapper"> <mapper namespace="com.example.tdl.mapper.CircuitMapper">
<!--获取所有线路的信息--> <!--获取所有线路的信息-->
<select id="getAll" resultType="com.example.tdl.domain.vo.ResultCircuitVo"> <select id="getAll" resultType="com.example.tdl.domain.vo.ResultCircuitVo">
SELECT transportationNo,cargoNo,(SELECT city from city WHERE id =(SELECT city_id from circuit_transfer WHERE circuit_id=c.id ORDER BY sequence LIMIT 1)) startCity, SELECT c.transportationNo,cargoNo,(SELECT city from city WHERE id =(SELECT city_id from circuit_transfer WHERE circuit_id=c.id ORDER BY sequence LIMIT 1)) startCity,startTime,(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(classify) from alarm_log al where al.transportationNo = c.transportationNo) alarm,evaluate
startTime,(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=c.alarm_id) alarmType,(select GROUP_CONCAT(DISTINCT classify) alarm from alarm_log al where al.transportationNo = c.transportationNo) alarm,evaluate
from circuit c where c.state=1 from circuit c where c.state=1
</select> </select>
<!--根据条件查询线路信息--> <!--根据条件查询线路信息-->
<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,cargoNo,(SELECT city from city WHERE id =(SELECT city_id from circuit_transfer WHERE circuit_id=c.id ORDER BY sequence LIMIT 1)) startCity, SELECT c.transportationNo,cargoNo,(SELECT city from city WHERE id =(SELECT city_id from circuit_transfer WHERE circuit_id=c.id ORDER BY sequence LIMIT 1)) startCity,startTime,(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(classify) from alarm_log al where al.transportationNo = c.transportationNo) alarm,evaluate
startTime,(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=c.alarm_id) alarmType,(select GROUP_CONCAT(DISTINCT classify) alarm from alarm_log al where al.transportationNo = c.transportationNo) alarm,evaluate
from circuit c where c.state=1 from circuit c where c.state=1
<if test="circuitState!=null"> <if test="circuitState!=null">
AND circuitState=#{circuitState,jdbcType=INTEGER} AND circuitState=#{circuitState,jdbcType=INTEGER}
...@@ -39,7 +35,6 @@ ...@@ -39,7 +35,6 @@
#{startTime,mode=IN,jdbcType=BIGINT}, #{startTime,mode=IN,jdbcType=BIGINT},
#{expTime,mode=IN,jdbcType=BIGINT}, #{expTime,mode=IN,jdbcType=BIGINT},
#{compTime,mode=IN,jdbcType=BIGINT}, #{compTime,mode=IN,jdbcType=BIGINT},
#{alarmType,mode=IN,jdbcType=VARCHAR},
#{cargoNo,mode=IN,jdbcType=VARCHAR}, #{cargoNo,mode=IN,jdbcType=VARCHAR},
#{cargoName,mode=IN,jdbcType=VARCHAR}, #{cargoName,mode=IN,jdbcType=VARCHAR},
#{plateNo,mode=IN,jdbcType=VARCHAR}, #{plateNo,mode=IN,jdbcType=VARCHAR},
...@@ -61,7 +56,9 @@ ...@@ -61,7 +56,9 @@
#{compTimeVar,mode=IN,jdbcType=VARCHAR}, #{compTimeVar,mode=IN,jdbcType=VARCHAR},
#{SN,mode=IN,jdbcType=VARCHAR}, #{SN,mode=IN,jdbcType=VARCHAR},
#{type,mode=IN,jdbcType=VARCHAR}, #{type,mode=IN,jdbcType=VARCHAR},
#{TDLSN,mode=IN,jdbcType=VARCHAR}, #{TDLSNVar,mode=IN,jdbcType=VARCHAR},
#{alarmTypeVar,mode=IN,jdbcType=VARCHAR},
#{TDLCounts,mode=IN,jdbcType=VARCHAR},
#{message,mode=IN,jdbcType=VARCHAR}, #{message,mode=IN,jdbcType=VARCHAR},
#{flag,mode=IN,jdbcType=INTEGER}, #{flag,mode=IN,jdbcType=INTEGER},
#{untie,mode=IN,jdbcType=INTEGER}, #{untie,mode=IN,jdbcType=INTEGER},
...@@ -113,7 +110,7 @@ ...@@ -113,7 +110,7 @@
WHERE transportationNo=#{transportationNo,jdbcType=VARCHAR} WHERE transportationNo=#{transportationNo,jdbcType=VARCHAR}
</delete> </delete>
<!-- 修改结束时间--> <!-- 修改结束时间-->
<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},circuitState=2 endTime=#{endTime,jdbcType=BIGINT},circuitState=2
...@@ -121,7 +118,7 @@ ...@@ -121,7 +118,7 @@
</update> </update>
<!-- 运输中数量--> <!-- 运输中数量-->
<select id="getOnRoute" resultType="java.lang.Integer" parameterType="String"> <select id="getOnRoute" resultType="java.lang.Integer" parameterType="String">
select count( startTime) from circuit where circuitState=1 and DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(createTime/1000,'%Y-%m-%d %H:%i:%s')) select count( startTime) from circuit where circuitState=1 and DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(createTime/1000,'%Y-%m-%d %H:%i:%s'))
</select> </select>
...@@ -138,28 +135,22 @@ ...@@ -138,28 +135,22 @@
<!--根据线路编号获取线路信息--> <!--根据线路编号获取线路信息-->
<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,cargoNo,(SELECT city from city WHERE id =(SELECT city_id from circuit_transfer WHERE circuit_id=c.id ORDER BY sequence LIMIT 1)) startCity, SELECT c.transportationNo,cargoNo,(SELECT city from city WHERE id =(SELECT city_id from circuit_transfer WHERE circuit_id=c.id ORDER BY sequence LIMIT 1)) startCity,startTime,(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(classify) from alarm_log al where al.transportationNo = c.transportationNo) alarm,evaluate
startTime,(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, from circuit c where c.state=1
IFNULL((SELECT alarmType FROM alarm WHERE id=c.alarm_id),"正常") alarmType from circuit c AND c.transportationNo=#{transportationNo,jdbcType=VARCHAR}
where c.state=1
AND transportationNo=#{transportationNo,jdbcType=VARCHAR}
</select> </select>
<!--根据车牌号查线路--> <!--根据车牌号查线路-->
<select id="getByContainerNo" parameterType="String" resultType="com.example.tdl.domain.vo.ResultCircuitVo"> <select id="getByContainerNo" parameterType="String" resultType="com.example.tdl.domain.vo.ResultCircuitVo">
SELECT transportationNo,cargoNo,(SELECT city from city WHERE id =(SELECT city_id from circuit_transfer WHERE circuit_id=c.id ORDER BY sequence LIMIT 1)) startCity, SELECT c.transportationNo,cargoNo,(SELECT city from city WHERE id =(SELECT city_id from circuit_transfer WHERE circuit_id=c.id ORDER BY sequence LIMIT 1)) startCity,startTime,(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(classify) from alarm_log al where al.transportationNo = c.transportationNo) alarm,evaluate
startTime,(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=c.alarm_id) alarmType,(select GROUP_CONCAT(DISTINCT classify) alarm from alarm_log al where al.transportationNo = c.transportationNo) alarm,evaluate
from circuit c where c.state=1 AND cargoNo=#{cargoNo,jdbcType=VARCHAR} from circuit c where c.state=1 AND cargoNo=#{cargoNo,jdbcType=VARCHAR}
</select> </select>
<!--根据运输状态查询线路信息--> <!--根据运输状态查询线路信息-->
<select id="getByCircuitState" parameterType="java.lang.Integer" resultType="com.example.tdl.domain.vo.ResultCircuitVo"> <select id="getByCircuitState" parameterType="java.lang.Integer" resultType="com.example.tdl.domain.vo.ResultCircuitVo">
SELECT transportationNo,cargoNo,(SELECT city from city WHERE id =(SELECT city_id from circuit_transfer WHERE circuit_id=c.id ORDER BY sequence LIMIT 1)) startCity, SELECT c.transportationNo,cargoNo,(SELECT city from city WHERE id =(SELECT city_id from circuit_transfer WHERE circuit_id=c.id ORDER BY sequence LIMIT 1)) startCity,startTime,(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(classify) from alarm_log al where al.transportationNo = c.transportationNo) alarm,evaluate
startTime,(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, from circuit c where c.state=1 AND circuitState=#{circuitState,jdbcType=INTEGER}
(SELECT alarmType FROM alarm WHERE id=c.alarm_id) alarmType,(select GROUP_CONCAT(DISTINCT classify) alarm from alarm_log al where al.transportationNo = c.transportationNo) alarm,evaluate
from circuit c where c.state=1 AND circuitState=#{circuitState,jdbcType=INTEGER}
</select> </select>
<!--评价--> <!--评价-->
...@@ -181,10 +172,8 @@ ...@@ -181,10 +172,8 @@
</select> </select>
<select id="getByTime" parameterType="java.lang.String" resultType="com.example.tdl.domain.vo.ResultCircuitVo"> <select id="getByTime" parameterType="java.lang.String" resultType="com.example.tdl.domain.vo.ResultCircuitVo">
SELECT transportationNo,cargoNo,(SELECT city from city WHERE id =(SELECT city_id from circuit_transfer WHERE circuit_id=c.id ORDER BY sequence LIMIT 1)) startCity, SELECT c.transportationNo,cargoNo,(SELECT city from city WHERE id =(SELECT city_id from circuit_transfer WHERE circuit_id=c.id ORDER BY sequence LIMIT 1)) startCity,startTime,(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(classify) from alarm_log al where al.transportationNo = c.transportationNo) alarm,evaluate
startTime,(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, from circuit c where c.state=1 AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(createTime/1000,'%Y-%m-%d %H:%i:%s'))
(SELECT alarmType FROM alarm WHERE id=c.alarm_id) alarmType,(select GROUP_CONCAT(DISTINCT classify) alarm from alarm_log al where al.transportationNo = c.transportationNo) alarm,evaluate
from circuit c where c.state=1 AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(createTime/1000,'%Y-%m-%d %H:%i:%s'))
</select> </select>
<!-- <!--
......
<?xml version="1.0" encoding="UTF-8"?> <?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"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.tdl.mapper.ConfigMapper"> <mapper namespace="com.example.tdl.mapper.ConfigMapper">
<!-- &lt;!&ndash;绑定getway和tdl&ndash;&gt; <!--绑定getway和tdl-->
<insert id="addConfig" parameterType="java.util.Map" statementType="CALLABLE"> <insert id="addConfig" parameterType="java.util.Map" statementType="CALLABLE">
<![CDATA[ <![CDATA[
{ {
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#{useScene,mode=IN,jdbcType=INTEGER}, #{useScene,mode=IN,jdbcType=INTEGER},
#{gSN,mode=IN,jdbcType=VARCHAR}, #{gSN,mode=IN,jdbcType=VARCHAR},
#{gType,mode=IN,jdbcType=VARCHAR}, #{gType,mode=IN,jdbcType=VARCHAR},
#{alarmType,mode=IN,jdbcType=VARCHAR},
#{message,mode=IN,jdbcType=VARCHAR}, #{message,mode=IN,jdbcType=VARCHAR},
#{flag,mode=IN,jdbcType=INTEGER}, #{flag,mode=IN,jdbcType=INTEGER},
#{resp,mode=IN,jdbcType=INTEGER}, #{resp,mode=IN,jdbcType=INTEGER},
...@@ -24,12 +25,12 @@ ...@@ -24,12 +25,12 @@
]]> ]]>
</insert> </insert>
&lt;!&ndash;获取绑定消息&ndash;&gt; <!--获取绑定消息-->
<select id="getConfig" parameterType="String" resultType="com.example.tdl.domain.vo.ConfigVo"> <select id="getConfig" parameterType="String" resultType="com.example.tdl.domain.vo.ConfigVo">
select gSN,gType,message,flag,resp,state,untie from config where gSN= #{gSN,jdbcType=VARCHAR} and gType=#{gType,jdbcType=VARCHAR} and state = 1; select gSN,gType,message,flag,resp,state,untie from config where gSN= #{gSN,jdbcType=VARCHAR} and gType=#{gType,jdbcType=VARCHAR} and state = 1;
</select> </select>
&lt;!&ndash; 绑定回复&ndash;&gt; <!--绑定回复-->
<update id="bindiSuccess"> <update id="bindiSuccess">
update config set resp=#{resp,jdbcType=INTEGER},flag=true update config set resp=#{resp,jdbcType=INTEGER},flag=true
where gSN= #{gSN,jdbcType=VARCHAR} where gSN= #{gSN,jdbcType=VARCHAR}
...@@ -37,7 +38,7 @@ ...@@ -37,7 +38,7 @@
and state = 1; and state = 1;
</update> </update>
&lt;!&ndash;重置tdl&ndash;&gt; <!--重置tdl-->
<update id="updateConfig" parameterType="java.util.Map" statementType="CALLABLE"> <update id="updateConfig" parameterType="java.util.Map" statementType="CALLABLE">
<![CDATA[ <![CDATA[
{ {
...@@ -54,28 +55,28 @@ ...@@ -54,28 +55,28 @@
]]> ]]>
</update> </update>
&lt;!&ndash;解绑成功&ndash;&gt; <!--解绑成功-->
<update id="delConfig" parameterType="String"> <update id="delConfig" parameterType="String">
update config set state = 0 where gSN= #{gSN,jdbcType=VARCHAR} and gType=#{gType,jdbcType=VARCHAR} and state = 1; update config set state = 0 where gSN= #{gSN,jdbcType=VARCHAR} and gType=#{gType,jdbcType=VARCHAR} and state = 1;
</update>--> </update>
<!-- <insert id="addConfig" parameterType="com.example.tdl.domain.vo.ConfigVo"> <!--<insert id="addConfig" parameterType="com.example.tdl.domain.vo.ConfigVo">-->
insert into config <!--insert into config-->
values( <!--values(-->
null, <!--null,-->
#{gSN,jdbcType=VARCHAR}, <!--#{gSN,jdbcType=VARCHAR},-->
#{gType,jdbcType=VARCHAR}, <!--#{gType,jdbcType=VARCHAR},-->
#{message,jdbcType=VARCHAR}, <!--#{message,jdbcType=VARCHAR},-->
#{flag,jdbcType=INTEGER}, <!--#{flag,jdbcType=INTEGER},-->
#{resp,jdbcType=INTEGER}, <!--#{resp,jdbcType=INTEGER},-->
#{state,jdbcType=INTEGER}, <!--#{state,jdbcType=INTEGER},-->
#{untie,jdbcType=INTEGER} <!--#{untie,jdbcType=INTEGER}-->
) <!--)-->
</insert>--> <!--</insert>-->
<!--<update id="updateConfig"> <!--<update id="updateConfig">-->
update config set untie=#{untie,jdbcType=INTEGER} <!--update config set untie=#{untie,jdbcType=INTEGER}-->
where gSN= #{gSN,jdbcType=VARCHAR} <!--where gSN= #{gSN,jdbcType=VARCHAR}-->
and gType=#{gType,jdbcType=VARCHAR} <!--and gType=#{gType,jdbcType=VARCHAR}-->
and state = 1; <!--and state = 1;-->
</update>--> <!--</update>-->
</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