Commit ce9d3833 authored by zhuangzhuang's avatar zhuangzhuang

6.7--修改bug(公司的修改,用户的修改,仓库详情及仓库数据的修改,传感器以及网管的修改,上传的图片大小以及尺寸的限制)

parent ffb8719b
...@@ -231,6 +231,14 @@ public class RedisConfig extends CachingConfigurerSupport{ ...@@ -231,6 +231,14 @@ public class RedisConfig extends CachingConfigurerSupport{
} }
@Bean
public RedisTemplate<String, String> userTokenTemplate() {
StringRedisTemplate template = new StringRedisTemplate(redisConnectionFactory(14));
JsonRedisSerializer(template, false);
return template;
}
} }
...@@ -18,7 +18,7 @@ public class AddAlarmVo { ...@@ -18,7 +18,7 @@ public class AddAlarmVo {
private String remark; private String remark;
private String companyName; private String companyNo;
public String getAlarmType() { public String getAlarmType() {
return alarmType; return alarmType;
...@@ -84,11 +84,11 @@ public class AddAlarmVo { ...@@ -84,11 +84,11 @@ public class AddAlarmVo {
this.remark = remark; this.remark = remark;
} }
public String getCompanyName() { public String getCompanyNo() {
return companyName; return companyNo;
} }
public void setCompanyName(String companyName) { public void setCompanyNo(String companyNo) {
this.companyName = companyName; this.companyNo = companyNo;
} }
} }
package com.example.tdl.domain.vo;
public class AlarmMessageVo {
private String transportationNo;
private String TDLSN;
private Long alarmTime;
private String type;
public String getTransportationNo() {
return transportationNo;
}
public void setTransportationNo(String transportationNo) {
this.transportationNo = transportationNo;
}
public String getTDLSN() {
return TDLSN;
}
public void setTDLSN(String TDLSN) {
this.TDLSN = TDLSN;
}
public Long getAlarmTime() {
return alarmTime;
}
public void setAlarmTime(Long alarmTime) {
this.alarmTime = alarmTime;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}
...@@ -24,6 +24,26 @@ public class CheckInVo { ...@@ -24,6 +24,26 @@ public class CheckInVo {
private List<String> devList; private List<String> devList;
private List<Float> tempL;
private List<Float> tempH;
private List<Float> humiL;
private List<Float> humiH;
private List<Integer> pressL;
private List<Integer> pressH;
private List<Integer> sugEnergy;
private List<Float> accThreshold;
private List<Integer> timeThreshold;
private List<Integer> tiltThreshold;
public String getAction() { public String getAction() {
return action; return action;
} }
...@@ -103,4 +123,84 @@ public class CheckInVo { ...@@ -103,4 +123,84 @@ public class CheckInVo {
public void setDevList(List<String> devList) { public void setDevList(List<String> devList) {
this.devList = devList; this.devList = devList;
} }
public List<Float> getTempL() {
return tempL;
}
public void setTempL(List<Float> tempL) {
this.tempL = tempL;
}
public List<Float> getTempH() {
return tempH;
}
public void setTempH(List<Float> tempH) {
this.tempH = tempH;
}
public List<Float> getHumiL() {
return humiL;
}
public void setHumiL(List<Float> humiL) {
this.humiL = humiL;
}
public List<Float> getHumiH() {
return humiH;
}
public void setHumiH(List<Float> humiH) {
this.humiH = humiH;
}
public List<Integer> getPressL() {
return pressL;
}
public void setPressL(List<Integer> pressL) {
this.pressL = pressL;
}
public List<Integer> getPressH() {
return pressH;
}
public void setPressH(List<Integer> pressH) {
this.pressH = pressH;
}
public List<Integer> getSugEnergy() {
return sugEnergy;
}
public void setSugEnergy(List<Integer> sugEnergy) {
this.sugEnergy = sugEnergy;
}
public List<Float> getAccThreshold() {
return accThreshold;
}
public void setAccThreshold(List<Float> accThreshold) {
this.accThreshold = accThreshold;
}
public List<Integer> getTimeThreshold() {
return timeThreshold;
}
public void setTimeThreshold(List<Integer> timeThreshold) {
this.timeThreshold = timeThreshold;
}
public List<Integer> getTiltThreshold() {
return tiltThreshold;
}
public void setTiltThreshold(List<Integer> tiltThreshold) {
this.tiltThreshold = tiltThreshold;
}
} }
package com.example.tdl.domain.vo;
public class CircuitAlarmDataVo {
private String transportationNo;
private String lng;
private String lat;
private String temp;
private String humidity;
private String shock;
private String shockEnergy;
private String titl;
private Long time;
public String getTransportationNo() {
return transportationNo;
}
public void setTransportationNo(String transportationNo) {
this.transportationNo = transportationNo;
}
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 getTemp() {
return temp;
}
public void setTemp(String temp) {
this.temp = temp;
}
public String getHumidity() {
return humidity;
}
public void setHumidity(String humidity) {
this.humidity = humidity;
}
public String getShock() {
return shock;
}
public void setShock(String shock) {
this.shock = shock;
}
public String getShockEnergy() {
return shockEnergy;
}
public void setShockEnergy(String shockEnergy) {
this.shockEnergy = shockEnergy;
}
public String getTitl() {
return titl;
}
public void setTitl(String titl) {
this.titl = titl;
}
public Long getTime() {
return time;
}
public void setTime(Long time) {
this.time = time;
}
}
package com.example.tdl.domain.vo; package com.example.tdl.domain.vo;
public class CircuitTermVo { public class CircuitTermVo {
private String companyName; private String companyNo;
private String cargoNo; private String cargoNo;
...@@ -13,12 +13,12 @@ public class CircuitTermVo { ...@@ -13,12 +13,12 @@ public class CircuitTermVo {
private String time; private String time;
public String getCompanyName() { public String getCompanyNo() {
return companyName; return companyNo;
} }
public void setCompanyName(String companyName) { public void setCompanyNo(String companyNo) {
this.companyName = companyName; this.companyNo = companyNo;
} }
public String getCargoNo() { public String getCargoNo() {
......
...@@ -12,6 +12,26 @@ public class ConfigCMDVo { ...@@ -12,6 +12,26 @@ public class ConfigCMDVo {
private List<String> devList; private List<String> devList;
private List<Float> tempL;
private List<Float> tempH;
private List<Float> humiL;
private List<Float> humiH;
private List<Integer> pressL;
private List<Integer> pressH;
private List<Integer> sugEnergy;
private List<Float> accThreshold;
private List<Integer> timeThreshold;
private List<Integer> tiltThreshold;
private Integer mode; //1为运输,2位仓储 private Integer mode; //1为运输,2位仓储
private Long t;//配置时的时间戳 private Long t;//配置时的时间戳
...@@ -36,6 +56,26 @@ public class ConfigCMDVo { ...@@ -36,6 +56,26 @@ public class ConfigCMDVo {
this.t = t; this.t = t;
} }
public ConfigCMDVo(String action, Integer gpsPeriod, Integer gprsPeriod, List<String> devList, List<Float> tempL, List<Float> tempH, List<Float> humiL, List<Float> humiH, List<Integer> pressL, List<Integer> pressH, List<Integer> sugEnergy, List<Float> accThreshold, List<Integer> timeThreshold, List<Integer> tiltThreshold, Integer mode, Long t) {
this.action = action;
this.gpsPeriod = gpsPeriod;
this.gprsPeriod = gprsPeriod;
this.devList = devList;
this.tempL = tempL;
this.tempH = tempH;
this.humiL = humiL;
this.humiH = humiH;
this.pressL = pressL;
this.pressH = pressH;
this.sugEnergy = sugEnergy;
this.accThreshold = accThreshold;
this.timeThreshold = timeThreshold;
this.tiltThreshold = tiltThreshold;
this.mode = mode;
this.t = t;
}
public String getAction() { public String getAction() {
return action; return action;
} }
...@@ -68,6 +108,86 @@ public class ConfigCMDVo { ...@@ -68,6 +108,86 @@ public class ConfigCMDVo {
this.devList = devList; this.devList = devList;
} }
public List<Float> getTempL() {
return tempL;
}
public void setTempL(List<Float> tempL) {
this.tempL = tempL;
}
public List<Float> getTempH() {
return tempH;
}
public void setTempH(List<Float> tempH) {
this.tempH = tempH;
}
public List<Float> getHumiL() {
return humiL;
}
public void setHumiL(List<Float> humiL) {
this.humiL = humiL;
}
public List<Float> getHumiH() {
return humiH;
}
public void setHumiH(List<Float> humiH) {
this.humiH = humiH;
}
public List<Integer> getPressL() {
return pressL;
}
public void setPressL(List<Integer> pressL) {
this.pressL = pressL;
}
public List<Integer> getPressH() {
return pressH;
}
public void setPressH(List<Integer> pressH) {
this.pressH = pressH;
}
public List<Integer> getSugEnergy() {
return sugEnergy;
}
public void setSugEnergy(List<Integer> sugEnergy) {
this.sugEnergy = sugEnergy;
}
public List<Float> getAccThreshold() {
return accThreshold;
}
public void setAccThreshold(List<Float> accThreshold) {
this.accThreshold = accThreshold;
}
public List<Integer> getTimeThreshold() {
return timeThreshold;
}
public void setTimeThreshold(List<Integer> timeThreshold) {
this.timeThreshold = timeThreshold;
}
public List<Integer> getTiltThreshold() {
return tiltThreshold;
}
public void setTiltThreshold(List<Integer> tiltThreshold) {
this.tiltThreshold = tiltThreshold;
}
public Integer getMode() { public Integer getMode() {
return mode; return mode;
} }
......
...@@ -8,9 +8,7 @@ public class DataVo { ...@@ -8,9 +8,7 @@ public class DataVo {
private List<HistoryDataVo> dataList; private List<HistoryDataVo> dataList;
private String min;
private String max;
public String getDescription() { public String getDescription() {
return description; return description;
...@@ -28,19 +26,5 @@ public class DataVo { ...@@ -28,19 +26,5 @@ public class DataVo {
this.dataList = dataList; this.dataList = dataList;
} }
public String getMin() {
return min;
}
public void setMin(String min) {
this.min = min;
}
public String getMax() {
return max;
}
public void setMax(String max) {
this.max = max;
}
} }
...@@ -3,14 +3,14 @@ package com.example.tdl.domain.vo; ...@@ -3,14 +3,14 @@ package com.example.tdl.domain.vo;
public class DelAlarmVo { public class DelAlarmVo {
private String alarmType; private String alarmType;
private String companyName; private String companyNo;
public String getCompanyName() { public String getCompanyNo() {
return companyName; return companyNo;
} }
public void setCompanyName(String companyName) { public void setCompanyNo(String companyNo) {
this.companyName = companyName; this.companyNo = companyNo;
} }
public String getAlarmType() { public String getAlarmType() {
......
...@@ -5,6 +5,10 @@ import java.util.List; ...@@ -5,6 +5,10 @@ import java.util.List;
public class HistoryDataVo { public class HistoryDataVo {
private String TDLSN; private String TDLSN;
private String min;
private String max;
private List<HistoryData> dataList; private List<HistoryData> dataList;
public String getTDLSN() { public String getTDLSN() {
...@@ -15,6 +19,22 @@ public class HistoryDataVo { ...@@ -15,6 +19,22 @@ public class HistoryDataVo {
this.TDLSN = TDLSN; this.TDLSN = TDLSN;
} }
public String getMin() {
return min;
}
public void setMin(String min) {
this.min = min;
}
public String getMax() {
return max;
}
public void setMax(String max) {
this.max = max;
}
public List<HistoryData> getDataList() { public List<HistoryData> getDataList() {
return dataList; return dataList;
} }
......
...@@ -20,14 +20,14 @@ public class UpdateAlarmVo { ...@@ -20,14 +20,14 @@ public class UpdateAlarmVo {
private String oldAlarmType; private String oldAlarmType;
private String companyName; private String companyNo;
public String getCompanyName() { public String getCompanyNo() {
return companyName; return companyNo;
} }
public void setCompanyName(String companyName) { public void setCompanyNo(String companyNo) {
this.companyName = companyName; this.companyNo = companyNo;
} }
public String getAlarmType() { public String getAlarmType() {
......
...@@ -13,10 +13,10 @@ public class UserRedisVo { ...@@ -13,10 +13,10 @@ public class UserRedisVo {
private String roleName; private String roleName;
private String companyNo;
private String companyName; private String companyName;
private String companyNo;
public String getCompanyNo() { public String getCompanyNo() {
return companyNo; return companyNo;
} }
...@@ -81,14 +81,14 @@ public class UserRedisVo { ...@@ -81,14 +81,14 @@ public class UserRedisVo {
this.roleName = roleName; this.roleName = roleName;
} }
public UserRedisVo(String userName, String userNumber, String nickName, String email, String phone, String roleName,String companyNo,String companyName) { public UserRedisVo(String userName, String userNumber, String nickName, String email, String phone, String roleName, String companyName, String companyNo) {
UserName = userName; UserName = userName;
UserNumber = userNumber; UserNumber = userNumber;
this.nickName = nickName; this.nickName = nickName;
this.email = email; this.email = email;
this.phone = phone; this.phone = phone;
this.roleName = roleName; this.roleName = roleName;
this.companyNo=companyNo; this.companyName = companyName;
this.companyName=companyName; this.companyNo = companyNo;
} }
} }
...@@ -11,6 +11,8 @@ public class UserTermVo { ...@@ -11,6 +11,8 @@ public class UserTermVo {
private String companyName; private String companyName;
private String companyNo;
public String getCompanyName() { public String getCompanyName() {
return companyName; return companyName;
} }
...@@ -50,4 +52,12 @@ public class UserTermVo { ...@@ -50,4 +52,12 @@ public class UserTermVo {
public void setPhone(String phone) { public void setPhone(String phone) {
this.phone = phone; this.phone = phone;
} }
public String getCompanyNo() {
return companyNo;
}
public void setCompanyNo(String companyNo) {
this.companyNo = companyNo;
}
} }
...@@ -10,7 +10,7 @@ public class WareHouseByTermVo { ...@@ -10,7 +10,7 @@ public class WareHouseByTermVo {
private String gSN; private String gSN;
private String companyName; private String companyNo;
public String getWarehouseName() { public String getWarehouseName() {
return warehouseName; return warehouseName;
...@@ -44,11 +44,11 @@ public class WareHouseByTermVo { ...@@ -44,11 +44,11 @@ public class WareHouseByTermVo {
this.gSN = gSN; this.gSN = gSN;
} }
public String getCompanyName() { public String getCompanyNo() {
return companyName; return companyNo;
} }
public void setCompanyName(String companyName) { public void setCompanyNo(String companyNo) {
this.companyName = companyName; this.companyNo = companyNo;
} }
} }
...@@ -6,17 +6,15 @@ public class WarehouseDataVo { ...@@ -6,17 +6,15 @@ public class WarehouseDataVo {
private String TDLSN; private String TDLSN;
private List<TDLDeviceDetailVo> tdlDeviceDetailVos; private String batteryVoltage;
private List<WarehouseTDLDetailVo> warehouseTDLDetailVos; private String temperature;
public List<TDLDeviceDetailVo> getTdlDeviceDetailVos() { private String humidity;
return tdlDeviceDetailVos;
}
public void setTdlDeviceDetailVos(List<TDLDeviceDetailVo> tdlDeviceDetailVos) { private String time;
this.tdlDeviceDetailVos = tdlDeviceDetailVos;
} private List<WarehouseTDLDetailVo> warehouseTDLDetailVos;
public String getTDLSN() { public String getTDLSN() {
return TDLSN; return TDLSN;
...@@ -26,6 +24,38 @@ public class WarehouseDataVo { ...@@ -26,6 +24,38 @@ public class WarehouseDataVo {
this.TDLSN = TDLSN; this.TDLSN = TDLSN;
} }
public String getBatteryVoltage() {
return batteryVoltage;
}
public void setBatteryVoltage(String batteryVoltage) {
this.batteryVoltage = batteryVoltage;
}
public String getTemperature() {
return temperature;
}
public void setTemperature(String temperature) {
this.temperature = temperature;
}
public String getHumidity() {
return humidity;
}
public void setHumidity(String humidity) {
this.humidity = humidity;
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
public List<WarehouseTDLDetailVo> getWarehouseTDLDetailVos() { public List<WarehouseTDLDetailVo> getWarehouseTDLDetailVos() {
return warehouseTDLDetailVos; return warehouseTDLDetailVos;
} }
......
package com.example.tdl.domain.vo;
public class WarehouseNameVo {
private String warehouseName;
public String getWarehouseName() {
return warehouseName;
}
public void setWarehouseName(String warehouseName) {
this.warehouseName = warehouseName;
}
}
...@@ -13,7 +13,7 @@ public class WarehouseTermVo { ...@@ -13,7 +13,7 @@ public class WarehouseTermVo {
private String hardwareLevel; private String hardwareLevel;
private String companyName; private String companyNo;
public String getWarehouseName() { public String getWarehouseName() {
return warehouseName; return warehouseName;
...@@ -63,11 +63,11 @@ public class WarehouseTermVo { ...@@ -63,11 +63,11 @@ public class WarehouseTermVo {
this.hardwareLevel = hardwareLevel; this.hardwareLevel = hardwareLevel;
} }
public String getCompanyName() { public String getCompanyNo() {
return companyName; return companyNo;
} }
public void setCompanyName(String companyName) { public void setCompanyNo(String companyNo) {
this.companyName = companyName; this.companyNo = companyNo;
} }
} }
...@@ -14,24 +14,24 @@ public interface AlarmLogMapper { ...@@ -14,24 +14,24 @@ public interface AlarmLogMapper {
List<ResultAlarmLog> getAll(); List<ResultAlarmLog> getAll();
//根据条件获取报警数据 //根据条件获取报警数据
List<AlarmLogVo> getAlarmLog(@Param("time") String time, @Param("companyName") String companyName); List<AlarmLogVo> getAlarmLog(@Param("time") String time, @Param("companyNo") String companyNo);
//新增报警数据 //新增报警数据
int addAlarmLog(AlarmLog addAlarmLogVo); int addAlarmLog(AlarmLog addAlarmLogVo);
List<ResultAlarmLog> getByTransportationNo(String transportationNo); List<ResultAlarmLog> getByTransportationNo(String transportationNo);
Integer getCount(@Param("time") String time, @Param("companyName") String companyName); Integer getCount(@Param("time") String time, @Param("companyNo") String companyNo);
Integer getBumpCount(@Param("time")String time,@Param("companyName") String companyName); Integer getBumpCount(@Param("time")String time,@Param("companyNo") String companyNo);
List<HistogramData> getByCount(@Param("time")String time,@Param("companyName") String companyName); List<HistogramData> getByCount(@Param("time")String time,@Param("companyNo") String companyNo);
Integer getByTime(@Param("transportationNo") String transportationNo,@Param("startTime") Long startTime, @Param("endTime") Long endTime); Integer getByTime(@Param("transportationNo") String transportationNo,@Param("startTime") Long startTime, @Param("endTime") Long endTime);
List<ResultAlarmLogVo> getAlarm(AlarmTermVo alarmTermVo); List<ResultAlarmLogVo> getAlarm(AlarmTermVo alarmTermVo);
List<AlarmLogVo> getRealTimeAlarm(String companyName); List<AlarmLogVo> getRealTimeAlarm(String companyNo);
Integer getAlarmCount(String companyName); Integer getAlarmCount(String companyNo);
} }
...@@ -9,9 +9,9 @@ import java.util.List; ...@@ -9,9 +9,9 @@ import java.util.List;
@Mapper @Mapper
public interface AlarmMapper { public interface AlarmMapper {
List<ResultAlarmVo> getAll(String companyName); List<ResultAlarmVo> getAll(String companyNo);
List<ResultAlarmVo> getAllByAlarmType(@Param("companyName") String companyName,@Param("alarmType") String alarmType); List<ResultAlarmVo> getAllByAlarmType(@Param("companyNo") String companyNo,@Param("alarmType") String alarmType);
int addAlarm(AddAlarmVo addAlarmVo); int addAlarm(AddAlarmVo addAlarmVo);
...@@ -19,7 +19,7 @@ public interface AlarmMapper { ...@@ -19,7 +19,7 @@ public interface AlarmMapper {
int delAlarm(DelAlarmVo delAlarmVo); int delAlarm(DelAlarmVo delAlarmVo);
ResultAlarmVo getByType(@Param("alarmType") String alarmType,@Param("companyName") String companyName); ResultAlarmVo getByType(@Param("alarmType") String alarmType,@Param("companyNo") String companyNo);
ResultAlarmVo getAlarmByWarehouseNo(@Param("warehouseNo") String warehouseNo ,@Param("gatewaySN")String gatewaySN,@Param("TDLSN")String TDLSN); ResultAlarmVo getAlarmByWarehouseNo(@Param("warehouseNo") String warehouseNo ,@Param("gatewaySN")String gatewaySN,@Param("TDLSN")String TDLSN);
} }
...@@ -9,9 +9,9 @@ import java.util.Map; ...@@ -9,9 +9,9 @@ import java.util.Map;
@Mapper @Mapper
public interface CircuitMapper { public interface CircuitMapper {
List<CircuitResultVo> getAll(String companyName); List<CircuitResultVo> getAll(@Param("companyNo") String companyNo);
List<ResultCircuitVo> getByTerm(CircuitTermVo circuitTermVo); List<CircuitResultVo> getByTerm(CircuitTermVo circuitTermVo);
int addCircuit(Map<Object,Object> map); int addCircuit(Map<Object,Object> map);
...@@ -29,24 +29,24 @@ public interface CircuitMapper { ...@@ -29,24 +29,24 @@ public interface CircuitMapper {
int deleteCircuit(Map<Object,Object> map); int deleteCircuit(Map<Object,Object> map);
ResultCircuitVo getByTransportationNo(@Param("transportationNo") String transportationNo,@Param("companyName") String companyName); ResultCircuitVo getByTransportationNo(@Param("transportationNo") String transportationNo,@Param("companyNo") String companyNo);
Integer getOnRoute(@Param("companyName") String companyName); Integer getOnRoute(@Param("companyNo") String companyNo);
Integer getDelayCount(@Param("compTime") Long compTime, @Param("time") String time,@Param("companyName") String companyName); Integer getDelayCount(@Param("compTime") Long compTime, @Param("time") String time,@Param("companyNo") String companyNo);
Integer getDelay(@Param("compTime")Long compTime,@Param("companyName") String companyName); Integer getDelay(@Param("compTime")Long compTime,@Param("companyNo") String companyNo);
Integer getCount(@Param("time") String time,@Param("endTime") Long endTime,@Param("companyName") String companyName); Integer getCount(@Param("time") String time,@Param("endTime") Long endTime,@Param("companyNo") String companyNo);
List<AppCircuitVo> getByPlateNo(@Param("plateNo") String plateNo,@Param("companyName") String companyName); List<AppCircuitVo> getByPlateNo(@Param("plateNo") String plateNo,@Param("companyNo") String companyNo);
ResultCircuitForAppVo getByTransportationNoForApp(@Param("transportationNo") String transportationNo,@Param("companyName") String companyName); ResultCircuitForAppVo getByTransportationNoForApp(@Param("transportationNo") String transportationNo,@Param("companyNo") String companyNo);
ResultCircuitVo getCircuit(String transportationNo); ResultCircuitVo getCircuit(String transportationNo);
List<AppCircuitVo> getByCircuitState(@Param("circuitState") Integer circuitState,@Param("companyName") String companyName); List<AppCircuitVo> getByCircuitState(@Param("circuitState") Integer circuitState,@Param("companyNo") String companyNo);
int updateEvaluate(UpdateEvaluateVo updateEvaluateVo); int updateEvaluate(UpdateEvaluateVo updateEvaluateVo);
...@@ -54,7 +54,7 @@ public interface CircuitMapper { ...@@ -54,7 +54,7 @@ public interface CircuitMapper {
ResultGatewayVo getByNo(String transportationNo); ResultGatewayVo getByNo(String transportationNo);
List<ResultCircuitVo> getByTime(String companyName); List<ResultCircuitVo> getByTime(String companyNo);
CircuitMessage getMessage(String transportationNo); CircuitMessage getMessage(String transportationNo);
} }
...@@ -2,6 +2,7 @@ package com.example.tdl.mapper; ...@@ -2,6 +2,7 @@ package com.example.tdl.mapper;
import com.example.tdl.domain.vo.AddCompanyVo; import com.example.tdl.domain.vo.AddCompanyVo;
import com.example.tdl.domain.vo.AlarmContactsVo;
import com.example.tdl.domain.vo.ResultCompanyVo; import com.example.tdl.domain.vo.ResultCompanyVo;
import com.example.tdl.domain.vo.UpdateCompanyVo; import com.example.tdl.domain.vo.UpdateCompanyVo;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
...@@ -13,7 +14,7 @@ import java.util.Map; ...@@ -13,7 +14,7 @@ import java.util.Map;
@Mapper @Mapper
public interface CompanyMapper { public interface CompanyMapper {
List<ResultCompanyVo> getAll(); List<ResultCompanyVo> getAll(@Param("companyNo") String companyNo);
int addCompany(AddCompanyVo addCompanyVo); int addCompany(AddCompanyVo addCompanyVo);
...@@ -28,4 +29,5 @@ public interface CompanyMapper { ...@@ -28,4 +29,5 @@ public interface CompanyMapper {
ResultCompanyVo getByAlias(String alias); ResultCompanyVo getByAlias(String alias);
int updateImg(@Param("img") String img, @Param("companyNo") String companyNo); int updateImg(@Param("img") String img, @Param("companyNo") String companyNo);
} }
...@@ -9,12 +9,12 @@ import java.util.List; ...@@ -9,12 +9,12 @@ import java.util.List;
@Mapper @Mapper
public interface UserMapper { public interface UserMapper {
List<ResultUserVo> getAll(@Param("companyNo") String companyNo);
int login(LoginUserVo loginUserVo); int login(LoginUserVo loginUserVo);
UserVo getByUserName(@Param("userName") String userName); UserVo getByUserName(@Param("userName") String userName);
List<ResultUserVo> getAll(String companyName);
List<ResultUserVo> getAllUser(); List<ResultUserVo> getAllUser();
...@@ -37,4 +37,6 @@ public interface UserMapper { ...@@ -37,4 +37,6 @@ public interface UserMapper {
int updateImg(@Param("img") String img,@Param("userNumber") String userNumber); int updateImg(@Param("img") String img,@Param("userNumber") String userNumber);
int getByRoleName(@Param("roleName") String roleName,@Param("companyName") String companyName); int getByRoleName(@Param("roleName") String roleName,@Param("companyName") String companyName);
List<AlarmContactsVo> getAllByCompanyNo(String companyNo);
} }
...@@ -39,9 +39,9 @@ public interface WarehouseMapper { ...@@ -39,9 +39,9 @@ public interface WarehouseMapper {
List<AlarmContactsVo> getAlarmContacts(String warehouseNo); List<AlarmContactsVo> getAlarmContacts(String warehouseNo);
ResultWarehouseVo getByWarehouseName(@Param("warehouseName") String warehouseName, @Param("companyName") String companyName); ResultWarehouseVo getByWarehouseName(@Param("warehouseName") String warehouseName, @Param("companyNo") String companyNo);
// List<ResultWarehouseVo> getByAlarm(DelAlarmVo delAlarmVo); List<ResultWarehouseVo> getByAlarm(DelAlarmVo delAlarmVo);
List<GatewaySNVo> getGateway(String warehouseNo); List<GatewaySNVo> getGateway(String warehouseNo);
...@@ -50,4 +50,6 @@ public interface WarehouseMapper { ...@@ -50,4 +50,6 @@ public interface WarehouseMapper {
WarehouseDetailVo getWarehouseDetailByNo(@Param("warehouseNo") String warehouseNo); WarehouseDetailVo getWarehouseDetailByNo(@Param("warehouseNo") String warehouseNo);
DeviceMessageVo getDeviceMessage(SearchTdlVo searchTdlVo); DeviceMessageVo getDeviceMessage(SearchTdlVo searchTdlVo);
List<WarehouseNameVo> getWarehouseName(@Param("warehouseName") String warehouseName,@Param("companyNo") String companyNo );
} }
...@@ -21,6 +21,7 @@ import org.springframework.stereotype.Component; ...@@ -21,6 +21,7 @@ import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.Future; import java.util.concurrent.Future;
...@@ -33,14 +34,17 @@ import java.util.concurrent.TimeUnit; ...@@ -33,14 +34,17 @@ import java.util.concurrent.TimeUnit;
* @Date: Created in 9:41 2018/3/13 * @Date: Created in 9:41 2018/3/13
* @Modified By: * @Modified By:
**/ **/
@Component @Component
public class MqttListener implements MqttCallback { public class MqttListener implements MqttCallback {
private static final int INIT_DELAY_DEFAULT = 1000; // unit:ms private static final int INIT_DELAY_DEFAULT = 1000; // unit:ms
private static final int SCH_PERIOD_DEFAULT = 10 * INIT_DELAY_DEFAULT; // unit:ms private static final int SCH_PERIOD_DEFAULT = 10 * INIT_DELAY_DEFAULT; // unit:ms
private static final String CHECKIN_TOPIC = "CY/+/+/CheckIn"; private static final String CHECKIN_TOPIC = "TDL/+/+/CheckIn";
private MqttTemlateAsync mqttAsyncClient; private MqttTemlateAsync mqttAsyncClient;
private Gson gson = new Gson();
@Autowired @Autowired
private MqttConfig mqttconfig; private MqttConfig mqttconfig;
...@@ -132,10 +136,11 @@ public class MqttListener implements MqttCallback { ...@@ -132,10 +136,11 @@ public class MqttListener implements MqttCallback {
if(ts - tskey > 60*1000){ if(ts - tskey > 60*1000){
GWConfigWorker tmpgwconfigworker = gwconfigworkerMap.get(key); GWConfigWorker tmpgwconfigworker = gwconfigworkerMap.get(key);
Boolean boo = tmpgwconfigworker.GCConfigClose(); Boolean boo = tmpgwconfigworker.GCConfigClose();
if(boo) if(boo){
gwconfigworkerMap.remove(key); gwconfigworkerMap.remove(key);
} }
} }
}
}catch (Exception e){ }catch (Exception e){
System.out.println(e.getMessage()); System.out.println(e.getMessage());
} }
...@@ -169,8 +174,15 @@ public class MqttListener implements MqttCallback { ...@@ -169,8 +174,15 @@ public class MqttListener implements MqttCallback {
ConfigData = new Gson().toJson(configCMDVo); ConfigData = new Gson().toJson(configCMDVo);
gcconfig = new GWConfigWorker(Type,SN,ConfigData,configService, true); gcconfig = new GWConfigWorker(Type,SN,ConfigData,configService, true);
}else if(flag == 1){ }else if(flag == 1){
ConfigData = configService.getConfig(SN,Type).getMessage(); String message= configService.getConfig(SN,Type).getMessage();
gcconfig = new GWConfigWorker(Type,SN,ConfigData,configService,true); ConfigCMDVo configCMDVo = gson.fromJson(message,ConfigCMDVo.class);
ConfigCMDVo config = new ConfigCMDVo(configCMDVo.getAction(),configCMDVo.getGpsPeriod(),configCMDVo.getGprsPeriod(),configCMDVo.getDevList(),configCMDVo.getMode(),System.currentTimeMillis()/1000l);
gcconfig = new GWConfigWorker(Type,SN,gson.toJson(config),configService,true);
}else if(flag == 3){
String message= configService.getConfig(SN,Type).getMessage();
ConfigCMDVo configCMDVo = gson.fromJson(message,ConfigCMDVo.class);
configCMDVo.setT(System.currentTimeMillis()/1000l);
gcconfig = new GWConfigWorker(Type,SN,gson.toJson(configCMDVo),configService,true);
} }
gcconfig.SetMqttConfig(mqttconfig.getUrl(),mqttconfig.getPort(), gcconfig.SetMqttConfig(mqttconfig.getUrl(),mqttconfig.getPort(),
mqttconfig.getUsername(), mqttconfig.getPassword(),mqttconfig.getQos(), mqttconfig.getUsername(), mqttconfig.getPassword(),mqttconfig.getQos(),
...@@ -216,16 +228,50 @@ public class MqttListener implements MqttCallback { ...@@ -216,16 +228,50 @@ public class MqttListener implements MqttCallback {
if(configCMDVo == null){ if(configCMDVo == null){
return 0;//休眠 return 0;//休眠
} }
if(checkInVo.getDevList().size()==0 && configCMDVo !=null ){
return 1;//重发
}
if(configVo.getUntie() && StringUtils.isEmpty(configVo.getMessage()) ){ if(configVo.getUntie() && StringUtils.isEmpty(configVo.getMessage()) ){
return 2;//解绑 return 2;//解绑
} }
JsonObject returnData = new JsonParser().parse(message).getAsJsonObject();
if(returnData.has("tempL")
&&returnData.has("tempL")
&&returnData.has("tempH")
&&returnData.has("humiL")
&&returnData.has("humiH")
&&returnData.has("pressL")
&&returnData.has("pressH")
&&returnData.has("sugEnergy")
&&returnData.has("accThreshold")
&&returnData.has("timeThreshold")
&&returnData.has("tiltThreshold")){
if(checkInVo.getDevList().size()==0 && configCMDVo !=null ){
return 3;//重发
}
if (compare(configCMDVo.getDevList(),checkInVo.getDevList())
&& checkInVo.getGprsPeriod().equals(configCMDVo.getGprsPeriod())
&& checkInVo.getGpsPeriod().equals(configCMDVo.getGpsPeriod())
&& checkInVo.getMode().equals(configCMDVo.getMode())
&& compare(configCMDVo.getTempL(),checkInVo.getTempL())
&& compare(configCMDVo.getTempH(),checkInVo.getTempH())
&& compare(configCMDVo.getHumiL(),checkInVo.getHumiL())
&& compare(configCMDVo.getHumiH(),checkInVo.getHumiH())
&& compare(configCMDVo.getPressH(),checkInVo.getPressH())
&& compare(configCMDVo.getPressL(),checkInVo.getPressL())
&& compare(configCMDVo.getSugEnergy(),checkInVo.getSugEnergy())
&& compare(configCMDVo.getAccThreshold(),checkInVo.getAccThreshold())
&& compare(configCMDVo.getTimeThreshold(),checkInVo.getTimeThreshold())
&& compare(configCMDVo.getTiltThreshold(),checkInVo.getTiltThreshold())) {
//一致
return 0;//休眠
} else {
//不一致
return 3;//重发
}
}else{
if(checkInVo.getDevList().size()==0 && configCMDVo !=null ){
return 1;//重发
}
//判断两者的devList是否一致 //判断两者的devList是否一致
if (configCMDVo.getDevList().containsAll(checkInVo.getDevList()) if (compare(configCMDVo.getDevList(),checkInVo.getDevList())
&& checkInVo.getDevList().containsAll(configCMDVo.getDevList())
&& checkInVo.getGprsPeriod().equals(configCMDVo.getGprsPeriod()) && checkInVo.getGprsPeriod().equals(configCMDVo.getGprsPeriod())
&& checkInVo.getGpsPeriod().equals(configCMDVo.getGpsPeriod()) && checkInVo.getGpsPeriod().equals(configCMDVo.getGpsPeriod())
&& checkInVo.getMode().equals(configCMDVo.getMode())) { && checkInVo.getMode().equals(configCMDVo.getMode())) {
...@@ -235,6 +281,23 @@ public class MqttListener implements MqttCallback { ...@@ -235,6 +281,23 @@ public class MqttListener implements MqttCallback {
//不一致 //不一致
return 1;//重发 return 1;//重发
} }
}
} }
//判断两个list是否一致
public synchronized <T extends Comparable<T>> boolean compare(List<T> a, List<T> b) {
if (a.size() != b.size()){
return false;
}
for (int i = 0; i < a.size(); i++) {
if (!a.get(i).equals(b.get(i)))
return false;
}
return true;
}
} }
\ No newline at end of file
...@@ -18,8 +18,8 @@ public class AlarmLogService { ...@@ -18,8 +18,8 @@ public class AlarmLogService {
return alarmLogMapper.getAll(); return alarmLogMapper.getAll();
} }
public List<AlarmLogVo> getAlarmLog(String time,String companyName){ public List<AlarmLogVo> getAlarmLog(String time,String companyNo){
return alarmLogMapper.getAlarmLog(time,companyName); return alarmLogMapper.getAlarmLog(time,companyNo);
} }
public int addAlarmLog(AlarmLog addAlarmLogVo){ public int addAlarmLog(AlarmLog addAlarmLogVo){
...@@ -30,20 +30,20 @@ public class AlarmLogService { ...@@ -30,20 +30,20 @@ public class AlarmLogService {
return alarmLogMapper.getByTransportationNo(transportationNo); return alarmLogMapper.getByTransportationNo(transportationNo);
} }
public Integer getCount(String time,String companyName){ public Integer getCount(String time,String companyNo){
return alarmLogMapper.getCount(time,companyName); return alarmLogMapper.getCount(time,companyNo);
} }
public Integer getBumpCount(String time,String companyName){ public Integer getBumpCount(String time,String companyNo){
return alarmLogMapper.getBumpCount(time,companyName); return alarmLogMapper.getBumpCount(time,companyNo);
} }
public Integer getAlarmCount(String companyName){ public Integer getAlarmCount(String companyNo){
return alarmLogMapper.getAlarmCount(companyName); return alarmLogMapper.getAlarmCount(companyNo);
} }
public List<HistogramData> getByCount(String time,String companyName){ public List<HistogramData> getByCount(String time,String companyNo){
return alarmLogMapper.getByCount(time,companyName); return alarmLogMapper.getByCount(time,companyNo);
} }
...@@ -55,8 +55,8 @@ public class AlarmLogService { ...@@ -55,8 +55,8 @@ public class AlarmLogService {
return alarmLogMapper.getAlarm(alarmTermVo); return alarmLogMapper.getAlarm(alarmTermVo);
} }
public List<AlarmLogVo> getRealTimeAlarm(String companyName){ public List<AlarmLogVo> getRealTimeAlarm(String companyNo){
return alarmLogMapper.getRealTimeAlarm(companyName); return alarmLogMapper.getRealTimeAlarm(companyNo);
} }
......
...@@ -15,12 +15,12 @@ public class AlarmService { ...@@ -15,12 +15,12 @@ public class AlarmService {
@Autowired @Autowired
private AlarmMapper alarmMapper; private AlarmMapper alarmMapper;
public List<ResultAlarmVo> getAll(String companyName){ public List<ResultAlarmVo> getAll(String companyNo){
return alarmMapper.getAll(companyName); return alarmMapper.getAll(companyNo);
} }
public List<ResultAlarmVo> getAllByAlarmType(String companyName,String alarmType){ public List<ResultAlarmVo> getAllByAlarmType(String companyNo,String alarmType){
return alarmMapper.getAllByAlarmType(companyName,alarmType); return alarmMapper.getAllByAlarmType(companyNo,alarmType);
} }
public int addAlarm(AddAlarmVo addAlarmVo){ public int addAlarm(AddAlarmVo addAlarmVo){
...@@ -35,8 +35,8 @@ public class AlarmService { ...@@ -35,8 +35,8 @@ public class AlarmService {
return alarmMapper.delAlarm(delAlarmVo); return alarmMapper.delAlarm(delAlarmVo);
} }
public ResultAlarmVo getByType(String alarmType,String companyName){ public ResultAlarmVo getByType(String alarmType,String companyNo){
return alarmMapper.getByType(alarmType,companyName); return alarmMapper.getByType(alarmType,companyNo);
} }
public ResultAlarmVo getAlarmByWarehouseNo(String warehouseNo,String SN, String TDLSN){ public ResultAlarmVo getAlarmByWarehouseNo(String warehouseNo,String SN, String TDLSN){
......
...@@ -14,11 +14,11 @@ public class CircuitService { ...@@ -14,11 +14,11 @@ public class CircuitService {
@Autowired @Autowired
private CircuitMapper circuitMapper; private CircuitMapper circuitMapper;
public List<CircuitResultVo> getAll(String companyName){ public List<CircuitResultVo> getAll(String companyNo){
return circuitMapper.getAll(companyName); return circuitMapper.getAll(companyNo);
} }
public List<ResultCircuitVo> getByTerm(CircuitTermVo circuitTermVo){ public List<CircuitResultVo> getByTerm(CircuitTermVo circuitTermVo){
return circuitMapper.getByTerm(circuitTermVo); return circuitMapper.getByTerm(circuitTermVo);
} }
...@@ -56,39 +56,40 @@ public class CircuitService { ...@@ -56,39 +56,40 @@ public class CircuitService {
} }
public ResultCircuitVo getByTransportationNo(String transportationNo,String companyName){ public ResultCircuitVo getByTransportationNo(String transportationNo,String companyNo){
return circuitMapper.getByTransportationNo(transportationNo,companyName); return circuitMapper.getByTransportationNo(transportationNo,companyNo);
} }
public ResultCircuitForAppVo getByTransportationNoForApp(String transportationNo,String companyName){ public ResultCircuitForAppVo getByTransportationNoForApp(String transportationNo,String companyNo){
return circuitMapper.getByTransportationNoForApp(transportationNo,companyName); return circuitMapper.getByTransportationNoForApp(transportationNo,companyNo);
} }
public ResultCircuitVo getCircuit(String transportationNo){ public ResultCircuitVo getCircuit(String transportationNo){
return circuitMapper.getCircuit(transportationNo); return circuitMapper.getCircuit(transportationNo);
} }
public Integer getOnRoute(String comapnyName){
return circuitMapper.getOnRoute(comapnyName); public Integer getOnRoute(String companyNo){
return circuitMapper.getOnRoute(companyNo);
} }
public Integer getDelayCount(Long compTime,String time,String companyName){ public Integer getDelayCount(Long compTime,String time,String companyNo){
return circuitMapper.getDelayCount(compTime,time,companyName); return circuitMapper.getDelayCount(compTime,time,companyNo);
} }
public Integer getDelay(Long compTime,String companyName){ public Integer getDelay(Long compTime,String companyNo){
return circuitMapper.getDelay(compTime,companyName); return circuitMapper.getDelay(compTime,companyNo);
} }
public Integer getCount(String time,Long startTime,String companyName){ public Integer getCount(String time,Long startTime,String companyNo){
return circuitMapper.getCount(time,startTime,companyName); return circuitMapper.getCount(time,startTime,companyNo);
} }
public List<AppCircuitVo> getByPlateNo(String plateNo,String companyName){ public List<AppCircuitVo> getByPlateNo(String plateNo,String companyNo){
return circuitMapper.getByPlateNo(plateNo,companyName); return circuitMapper.getByPlateNo(plateNo,companyNo);
} }
public List<AppCircuitVo> getByCircuitState(Integer circuitState,String companyName){ public List<AppCircuitVo> getByCircuitState(Integer circuitState,String companyNo){
return circuitMapper.getByCircuitState(circuitState,companyName); return circuitMapper.getByCircuitState(circuitState,companyNo);
} }
public int updateEvaluate(UpdateEvaluateVo updateEvaluateVo){ public int updateEvaluate(UpdateEvaluateVo updateEvaluateVo){
...@@ -103,8 +104,8 @@ public class CircuitService { ...@@ -103,8 +104,8 @@ public class CircuitService {
return circuitMapper.getByNo(transportationNo); return circuitMapper.getByNo(transportationNo);
} }
public List<ResultCircuitVo> getByTime(String companyName){ public List<ResultCircuitVo> getByTime(String companyNo){
return circuitMapper.getByTime(companyName); return circuitMapper.getByTime(companyNo);
} }
......
...@@ -2,6 +2,7 @@ package com.example.tdl.service; ...@@ -2,6 +2,7 @@ package com.example.tdl.service;
import com.example.tdl.domain.vo.AddCompanyVo; import com.example.tdl.domain.vo.AddCompanyVo;
import com.example.tdl.domain.vo.AlarmContactsVo;
import com.example.tdl.domain.vo.ResultCompanyVo; import com.example.tdl.domain.vo.ResultCompanyVo;
import com.example.tdl.domain.vo.UpdateCompanyVo; import com.example.tdl.domain.vo.UpdateCompanyVo;
import com.example.tdl.mapper.CompanyMapper; import com.example.tdl.mapper.CompanyMapper;
...@@ -17,8 +18,8 @@ public class CompanyService { ...@@ -17,8 +18,8 @@ public class CompanyService {
@Autowired @Autowired
private CompanyMapper companyMapper; private CompanyMapper companyMapper;
public List<ResultCompanyVo> getAll(){ public List<ResultCompanyVo> getAll(String companyNo){
return companyMapper.getAll(); return companyMapper.getAll(companyNo);
} }
public int addCompany(AddCompanyVo addCompanyVo){ public int addCompany(AddCompanyVo addCompanyVo){
...@@ -49,4 +50,6 @@ public class CompanyService { ...@@ -49,4 +50,6 @@ public class CompanyService {
return companyMapper.updateImg(img,companyNo); return companyMapper.updateImg(img,companyNo);
} }
} }
...@@ -22,6 +22,11 @@ public class UserService { ...@@ -22,6 +22,11 @@ public class UserService {
@Autowired @Autowired
private TokenRedisService redisService; private TokenRedisService redisService;
public List<ResultUserVo> getAll(String companyNo){
return userMapper.getAll(companyNo);
}
public int login(LoginUserVo loginUserVo){ public int login(LoginUserVo loginUserVo){
return userMapper.login(loginUserVo); return userMapper.login(loginUserVo);
} }
...@@ -30,9 +35,7 @@ public class UserService { ...@@ -30,9 +35,7 @@ public class UserService {
return userMapper.getByUserName(userName); return userMapper.getByUserName(userName);
} }
public List<ResultUserVo> getAll(String companyName){
return userMapper.getAll(companyName);
}
public List<ResultUserVo> getAllUser(){ public List<ResultUserVo> getAllUser(){
return userMapper.getAllUser(); return userMapper.getAllUser();
...@@ -95,4 +98,8 @@ public class UserService { ...@@ -95,4 +98,8 @@ public class UserService {
public int getByRoleName(String roleName,String companyName){ public int getByRoleName(String roleName,String companyName){
return userMapper.getByRoleName(roleName,companyName); return userMapper.getByRoleName(roleName,companyName);
} }
public List<AlarmContactsVo> getAllByCompanyNo(String companyNo){
return userMapper.getAllByCompanyNo( companyNo);
}
} }
...@@ -15,8 +15,8 @@ public class WarehouseService { ...@@ -15,8 +15,8 @@ public class WarehouseService {
@Autowired @Autowired
private WarehouseMapper warehouseMapper; private WarehouseMapper warehouseMapper;
public List<ResultWarehouseVo> getAll(String companyName){ public List<ResultWarehouseVo> getAll(String companyNo){
return warehouseMapper.getAll(companyName); return warehouseMapper.getAll(companyNo);
} }
public List<ResultWarehouseVo> getAllByTerm(WarehouseTermVo warehouseTermVo){ public List<ResultWarehouseVo> getAllByTerm(WarehouseTermVo warehouseTermVo){
...@@ -68,13 +68,13 @@ public class WarehouseService { ...@@ -68,13 +68,13 @@ public class WarehouseService {
return warehouseMapper.getAlarmContacts(warehouseNo); return warehouseMapper.getAlarmContacts(warehouseNo);
} }
public ResultWarehouseVo getByWarehouseName(String warehouseName,String companyName){ public ResultWarehouseVo getByWarehouseName(String warehouseName,String companyNo){
return warehouseMapper.getByWarehouseName(warehouseName,companyName); return warehouseMapper.getByWarehouseName(warehouseName,companyNo);
} }
// public List<ResultWarehouseVo> getByAlarm(DelAlarmVo delAlarmVo){ public List<ResultWarehouseVo> getByAlarm(DelAlarmVo delAlarmVo){
// return warehouseMapper.getByAlarm(delAlarmVo); return warehouseMapper.getByAlarm(delAlarmVo);
// } }
public List<GatewaySNVo> getGateway(String warehouseNo){ public List<GatewaySNVo> getGateway(String warehouseNo){
return warehouseMapper.getGateway(warehouseNo); return warehouseMapper.getGateway(warehouseNo);
...@@ -91,4 +91,8 @@ public class WarehouseService { ...@@ -91,4 +91,8 @@ public class WarehouseService {
public DeviceMessageVo getDeviceMessage(SearchTdlVo searchTdlVo){ public DeviceMessageVo getDeviceMessage(SearchTdlVo searchTdlVo){
return warehouseMapper.getDeviceMessage(searchTdlVo); return warehouseMapper.getDeviceMessage(searchTdlVo);
} }
public List<WarehouseNameVo> getWarehouseName(String warehouseName,String companyNo ){
return warehouseMapper.getWarehouseName(warehouseName,companyNo);
}
} }
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 UserTokenRedisService extends RedisService {
@SuppressWarnings({ "unchecked", "rawtypes" })
@Autowired
public UserTokenRedisService(RedisTemplate realRedisTemplate) {
super(realRedisTemplate);
}
}
...@@ -68,7 +68,7 @@ public class AlarmController { ...@@ -68,7 +68,7 @@ public class AlarmController {
String token = request.getHeader("Account_token"); String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token); String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class); UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
return alarmService.getAll(user.getCompanyName()); return alarmService.getAll(user.getCompanyNo());
} }
//根据预警类型模糊查询 //根据预警类型模糊查询
...@@ -92,7 +92,7 @@ public class AlarmController { ...@@ -92,7 +92,7 @@ public class AlarmController {
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class); UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
JSONObject jsonObject= JSON.parseObject(alarmType); JSONObject jsonObject= JSON.parseObject(alarmType);
alarmType=(String)jsonObject.get("alarmType"); alarmType=(String)jsonObject.get("alarmType");
return alarmService.getAllByAlarmType(user.getCompanyName(),alarmType); return alarmService.getAllByAlarmType(user.getCompanyNo(),alarmType);
} }
//添加预警信息 //添加预警信息
...@@ -160,12 +160,12 @@ public class AlarmController { ...@@ -160,12 +160,12 @@ public class AlarmController {
fb.setMessage(i18n.getMessage(request,"shock")); fb.setMessage(i18n.getMessage(request,"shock"));
return gson.toJson(fb); return gson.toJson(fb);
} }
if (alarmService.getByType(addAlarmVo.getAlarmType(),user.getCompanyName())!=null){ if (alarmService.getByType(addAlarmVo.getAlarmType(),user.getCompanyNo())!=null){
fb.setCode(0); fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"alarmExist")); fb.setMessage(i18n.getMessage(request,"alarmExist"));
return gson.toJson(fb); return gson.toJson(fb);
} }
addAlarmVo.setCompanyName(user.getCompanyName()); addAlarmVo.setCompanyNo(user.getCompanyNo());
int a=alarmService.addAlarm(addAlarmVo); int a=alarmService.addAlarm(addAlarmVo);
if (a>0){ if (a>0){
fb.setCode(1); fb.setCode(1);
...@@ -248,12 +248,12 @@ public class AlarmController { ...@@ -248,12 +248,12 @@ public class AlarmController {
fb.setMessage(i18n.getMessage(request,"shock")); fb.setMessage(i18n.getMessage(request,"shock"));
return gson.toJson(fb); return gson.toJson(fb);
} }
if (alarmService.getByType(updateAlarmVo.getAlarmType(),user.getCompanyName())!=null&&!updateAlarmVo.getAlarmType().equals(updateAlarmVo.getAlarmType())){ if (alarmService.getByType(updateAlarmVo.getAlarmType(),user.getCompanyNo())!=null&&!updateAlarmVo.getAlarmType().equals(updateAlarmVo.getAlarmType())){
fb.setCode(0); fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"modifiedAlarmExist")); fb.setMessage(i18n.getMessage(request,"modifiedAlarmExist"));
return gson.toJson(fb); return gson.toJson(fb);
} }
updateAlarmVo.setCompanyName(user.getCompanyName()); updateAlarmVo.setCompanyNo(user.getCompanyNo());
int a=alarmService.updateAlarm(updateAlarmVo); int a=alarmService.updateAlarm(updateAlarmVo);
if (a>0){ if (a>0){
fb.setCode(1); fb.setCode(1);
...@@ -266,6 +266,7 @@ public class AlarmController { ...@@ -266,6 +266,7 @@ public class AlarmController {
} }
//删除预警信息 //删除预警信息
@ApiOperation(value = "删除预警信息",notes = "删除预警信息,companyName不用传,传值说明:" + @ApiOperation(value = "删除预警信息",notes = "删除预警信息,companyName不用传,传值说明:" +
" alarmType:需要删除的预警类型," + " alarmType:需要删除的预警类型," +
...@@ -285,7 +286,7 @@ public class AlarmController { ...@@ -285,7 +286,7 @@ public class AlarmController {
fb.setMessage(i18n.getMessage(request,"deletedAlarmType")); fb.setMessage(i18n.getMessage(request,"deletedAlarmType"));
return gson.toJson(fb); return gson.toJson(fb);
} }
delAlarmVo.setCompanyName(user.getCompanyName()); delAlarmVo.setCompanyNo(user.getCompanyNo());
if(tdlLogService.getByAlarm(delAlarmVo).size()>0){ if(tdlLogService.getByAlarm(delAlarmVo).size()>0){
fb.setCode(0); fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"dusedAlarm")); fb.setMessage(i18n.getMessage(request,"dusedAlarm"));
......
...@@ -3,23 +3,28 @@ package com.example.tdl.web; ...@@ -3,23 +3,28 @@ package com.example.tdl.web;
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.entity.AlarmLog; import com.example.tdl.entity.AlarmLog;
import com.example.tdl.service.AlarmLogService; import com.example.tdl.service.*;
import com.example.tdl.service.CircuitService;
import com.example.tdl.service.CompanyService;
import com.example.tdl.service.GatewayService;
import com.example.tdl.service.redis.TokenRedisService; import com.example.tdl.service.redis.TokenRedisService;
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;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.influxdb.dto.Query;
import org.influxdb.dto.QueryResult;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.influxdb.InfluxDBTemplate;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -47,9 +52,24 @@ public class AlarmLogController { ...@@ -47,9 +52,24 @@ public class AlarmLogController {
@Autowired @Autowired
private CompanyService companyService; private CompanyService companyService;
@Autowired
private TDLLogService tdlLogService;
@Autowired @Autowired
private I18nController i18n; private I18nController i18n;
@Autowired
private InfluxDBTemplate influxDBTemplate;
private final static String database ="original";
@Value("${mqtt.userName}")
private String userName;
@Value("${mqtt.password}")
private String password;
//获取报警信息 //获取报警信息
@ApiOperation(value = "获取报警信息",notes = "获取报警信息" + @ApiOperation(value = "获取报警信息",notes = "获取报警信息" +
" transportationNo:运输编号" + " transportationNo:运输编号" +
...@@ -110,7 +130,8 @@ public class AlarmLogController { ...@@ -110,7 +130,8 @@ public class AlarmLogController {
String token = request.getHeader("Account_token"); String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" + token); String datum = tokenRedisService.get("TOKEN_" + token);
UserRedisVo user = gson.fromJson(datum, UserRedisVo.class); UserRedisVo user = gson.fromJson(datum, UserRedisVo.class);
return alarmLogServcie.getRealTimeAlarm(user.getCompanyName()); List<AlarmLogVo> list = alarmLogServcie.getRealTimeAlarm(user.getCompanyNo());
return gson.toJson(list);
} }
...@@ -126,10 +147,11 @@ public class AlarmLogController { ...@@ -126,10 +147,11 @@ public class AlarmLogController {
String token = request.getHeader("Account_token"); String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" + token); String datum = tokenRedisService.get("TOKEN_" + token);
UserRedisVo userRedisVo = gson.fromJson(datum,UserRedisVo.class); UserRedisVo userRedisVo = gson.fromJson(datum,UserRedisVo.class);
ResultCompanyVo companyVo = companyService.getByCompanyName(userRedisVo.getCompanyName()); return gson.toJson(new MqttUser(userName,password,userRedisVo.getCompanyNo()));
return gson.toJson(new MqttUser("ugen","ugen",companyVo.getCompanyNo()));
} }
//新增报警消息 //新增报警消息
@ApiOperation(value = "增加报警",notes = "增加报警") @ApiOperation(value = "增加报警",notes = "增加报警")
@RequestMapping(value = "/addAlarmLog",method = RequestMethod.POST) @RequestMapping(value = "/addAlarmLog",method = RequestMethod.POST)
...@@ -199,4 +221,191 @@ public class AlarmLogController { ...@@ -199,4 +221,191 @@ public class AlarmLogController {
} }
return gson.toJson(fb); return gson.toJson(fb);
} }
//获取报警信息
@ApiOperation(value = "获取报警信息",notes = "获取报警信息" +
"transportationNo:运输编号" +
"TDLSN:传感器编号" +
"time :报警时间(13位时间戳)" +
"type:地图类型(百度:bd09,谷歌:wgs84)" +
"返回值:" +
"transportationNo:线路编号" +
"temp:温度" +
"humidity:湿度" +
"shock:震动" +
"shockEnergy:震动能量" +
"titl:倾斜" +
"lng:经度" +
"lat:纬度" +
"time:时间")
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
@ApiImplicitParam(paramType="header", name = "AccountLanguage", value = "language", required = false, dataType = "String"),
})
@PostMapping("/getAlarmData")
public Object getAlarmData(@RequestBody AlarmMessageVo alarmMessageVo,HttpServletRequest request){
if(StringUtils.isEmpty(alarmMessageVo.getTransportationNo())){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"transportationNo"));
return gson.toJson(fb);
}
if (circuitService.getNo(alarmMessageVo.getTransportationNo()) ==0){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"noCircuit"));
return gson.toJson(fb);
}
if(StringUtils.isEmpty(alarmMessageVo.getTDLSN())){
}
if(alarmMessageVo.getAlarmTime() == null){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"time"));
return gson.toJson(fb);
}
if(StringUtils.isEmpty(alarmMessageVo.getType())){
alarmMessageVo.setType("wgs84");
}
//获取设备的网关信息
TDLLogVo tdlLogVo = tdlLogService.getByTransportationNo(alarmMessageVo.getTransportationNo());
if(tdlLogVo ==null){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"noCircuit"));
return gson.toJson(fb);
}
//获取经纬度
String sql = "";
String device = tdlLogVo.getgType()+"_" + tdlLogVo.getgSN();
CircuitAlarmDataVo circuitAlarmDataVo =new CircuitAlarmDataVo();
if("bd09".equals(alarmMessageVo.getType())){
sql = "SELECT \"bdlng\",\"bdlat\" FROM \"tdl_policy\".\""+device+"\" where time >= "+ alarmMessageVo.getAlarmTime()*1000000l +" ORDER BY time limit 1;SELECT \"bdlng\",\"bdlat\" FROM \"tdl_policy\".\""+device+"\" where time <= "+ alarmMessageVo.getAlarmTime()*1000000l +" ORDER BY time desc limit 1";
}else{
sql = "SELECT \"lng\",\"lat\" FROM \"tdl_policy\".\""+device+"\" where time >= "+ alarmMessageVo.getAlarmTime()*1000000l +" ORDER BY time limit 1;SELECT \"lng\",\"lat\" FROM \"tdl_policy\".\""+device+"\" where time <= "+ alarmMessageVo.getAlarmTime()*1000000l +" ORDER BY time desc limit 1;";
}
QueryResult queryResult =influxDBTemplate.query(new Query(sql,database));
if(queryResult.getResults().get(0).getSeries() != null){
//获取最精确的经纬度
circuitAlarmDataVo = parseLocation(queryResult,alarmMessageVo.getAlarmTime());
}else{
circuitAlarmDataVo.setLng("");
circuitAlarmDataVo.setLat("");
}
//获取数据
Map<String,String> map = new HashMap<>();
map.put("\"T\"","temp");
map.put("\"h\"","humidity");
map.put("\"a0\"","shockEnergy");
map.put("\"a1\"","shock");
map.put("\"ta\"","tilt");
String sql1 = "select \"T\" FROM \"tdl_policy\".\""+device+"\" where time >="+ alarmMessageVo.getAlarmTime()*1000000l +" ORDER BY time limit 1 ";
QueryResult queryResult1 =influxDBTemplate.query(new Query(sql1,database));
if(queryResult1.getResults().get(0).getSeries() != null){
circuitAlarmDataVo.setTemp(parseData(queryResult1,alarmMessageVo.getAlarmTime()));
}else{
circuitAlarmDataVo.setTemp("");
}
String sql2 = "select \"h\" FROM \"tdl_policy\".\""+device+"\" where time >="+ alarmMessageVo.getAlarmTime()*1000000l +" ORDER BY time limit 1 ";
QueryResult queryResult2 =influxDBTemplate.query(new Query(sql2,database));
if(queryResult2.getResults().get(0).getSeries() != null){
circuitAlarmDataVo.setHumidity(parseData(queryResult2,alarmMessageVo.getAlarmTime()));
}else{
circuitAlarmDataVo.setHumidity("");
}
String sql3 = "select \"a0\" FROM \"tdl_policy\".\""+device+"\" where time >="+ alarmMessageVo.getAlarmTime()*1000000l +" ORDER BY time limit 1 ";
QueryResult queryResult3 =influxDBTemplate.query(new Query(sql3,database));
if(queryResult3.getResults().get(0).getSeries() != null){
circuitAlarmDataVo.setShockEnergy(parseData(queryResult3,alarmMessageVo.getAlarmTime()));
}else{
circuitAlarmDataVo.setShockEnergy("");
}
String sql4 = "select \"a1\" FROM \"tdl_policy\".\""+device+"\" where time >="+ alarmMessageVo.getAlarmTime()*1000000l +" ORDER BY time limit 1 ";
QueryResult queryResult4 =influxDBTemplate.query(new Query(sql4,database));
if(queryResult4.getResults().get(0).getSeries() != null){
circuitAlarmDataVo.setShock(parseData(queryResult4,alarmMessageVo.getAlarmTime()));
}else{
circuitAlarmDataVo.setShock("");
}
String sql5 = "select \"ta\" FROM \"tdl_policy\".\""+device+"\" where time >="+ alarmMessageVo.getAlarmTime()*1000000l +" ORDER BY time limit 1 ";
QueryResult queryResult5 =influxDBTemplate.query(new Query(sql5,database));
if(queryResult5.getResults().get(0).getSeries() != null){
circuitAlarmDataVo.setTitl(parseData(queryResult5,alarmMessageVo.getAlarmTime()));
}else{
circuitAlarmDataVo.setTitl("");
}
circuitAlarmDataVo.setTransportationNo(alarmMessageVo.getTransportationNo());
circuitAlarmDataVo.setTime(alarmMessageVo.getAlarmTime());
return gson.toJson(circuitAlarmDataVo);
}
//经纬度数据
public CircuitAlarmDataVo parseLocation(QueryResult queryResult,Long time){
String t1 ="";
if(queryResult.getResults().get(0) == null){
t1 = "0";
}else {
t1 = queryResult.getResults().get(0).getSeries().get(0).getValues().get(0).get(0) == null ? "" : queryResult.getResults().get(0).getSeries().get(0).getValues().get(0).get(0).toString();
}
String t2="";
if(queryResult.getResults().get(1) == null){
t2="0";
}else{
t2 = queryResult.getResults().get(1).getSeries().get(0).getValues().get(0).get(0) == null ? "" : queryResult.getResults().get(1).getSeries().get(0).getValues().get(0).get(0).toString();
}
CircuitAlarmDataVo circuitAlarmDataVo = new CircuitAlarmDataVo();
try{
String lng="";
String lat="";
if((Long.valueOf(dateToStamp(t1)) +8*60*60*1000-time)<(time-Long.valueOf(dateToStamp(t2))-8*60*60*1000)){
lng = queryResult.getResults().get(0).getSeries().get(0).getValues().get(0).get(1) == null?"" : queryResult.getResults().get(0).getSeries().get(0).getValues().get(0).get(1).toString();
lat = queryResult.getResults().get(0).getSeries().get(0).getValues().get(0).get(2) == null?"" : queryResult.getResults().get(0).getSeries().get(0).getValues().get(0).get(2).toString();
}else{
lng = queryResult.getResults().get(1).getSeries().get(0).getValues().get(0).get(1) == null?"" : queryResult.getResults().get(1).getSeries().get(0).getValues().get(0).get(1).toString();
lat = queryResult.getResults().get(1).getSeries().get(0).getValues().get(0).get(2) == null?"" : queryResult.getResults().get(1).getSeries().get(0).getValues().get(0).get(2).toString();
}
circuitAlarmDataVo.setLat(lat);
circuitAlarmDataVo.setLng(lng);
}catch (Exception e){
e.printStackTrace();
logger.info(e.toString());
}
return circuitAlarmDataVo;
}
//解析数据
public String parseData(QueryResult queryResult,Long time){
List<Object> values = queryResult.getResults().get(0).getSeries().get(0).getValues().get(0);
//判断时间差距
String t="";
try{
t= dateToStamp(values.get(0).toString());
logger.info(t);
}catch (Exception e){
e.printStackTrace();
logger.info(e.toString());
return "";
}
if((time -Long.valueOf(t)-60*60*8*1000)>1000*60){
return "";
}else{
//数据
String value = values.get(1) == null?"":values.get(1).toString();
logger.info(value);
return value;
}
}
public static String dateToStamp(String s) throws ParseException {
Date date =null ;
if(s.length() !=20 ) {
date = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").parse(s);
}else{
date = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").parse(s);
}
return String.valueOf(date.getTime());
}
} }
...@@ -79,6 +79,9 @@ public class CircuitController { ...@@ -79,6 +79,9 @@ public class CircuitController {
@Autowired @Autowired
private InfluxDBTemplate influxDBTemplate; private InfluxDBTemplate influxDBTemplate;
@Autowired
private CarService carService;
@Autowired @Autowired
private I18nController i18n; private I18nController i18n;
...@@ -115,7 +118,7 @@ public class CircuitController { ...@@ -115,7 +118,7 @@ public class CircuitController {
String token = request.getHeader("Account_token"); String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token); String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class); UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
List<CircuitResultVo> list = circuitService.getAll(user.getCompanyName()); List<CircuitResultVo> list = circuitService.getAll(user.getCompanyNo());
for(int i = 0,length=list.size();i<length;i++){ for(int i = 0,length=list.size();i<length;i++){
if(list.get(i).getCircuitState() == 1){ if(list.get(i).getCircuitState() == 1){
//获取设备在线情况 //获取设备在线情况
...@@ -180,7 +183,8 @@ public class CircuitController { ...@@ -180,7 +183,8 @@ public class CircuitController {
} }
JSONObject jsonObject=JSON.parseObject(transportationNo); JSONObject jsonObject=JSON.parseObject(transportationNo);
transportationNo=(String) jsonObject.get("transportationNo"); transportationNo=(String) jsonObject.get("transportationNo");
return circuitService.getByTransportationNo(transportationNo,user.getCompanyName()); return circuitService.getByTransportationNo(transportationNo,user.getCompanyNo());
} }
...@@ -215,7 +219,7 @@ public class CircuitController { ...@@ -215,7 +219,7 @@ public class CircuitController {
} }
JSONObject jsonObject=JSON.parseObject(transportationNo); JSONObject jsonObject=JSON.parseObject(transportationNo);
transportationNo=(String) jsonObject.get("transportationNo"); transportationNo=(String) jsonObject.get("transportationNo");
ResultCircuitForAppVo resultCircuitForAppVo=circuitService.getByTransportationNoForApp(transportationNo,user.getCompanyName()); ResultCircuitForAppVo resultCircuitForAppVo=circuitService.getByTransportationNoForApp(transportationNo,user.getCompanyNo());
resultCircuitForAppVo.setStartTime(System.currentTimeMillis()); resultCircuitForAppVo.setStartTime(System.currentTimeMillis());
return resultCircuitForAppVo; return resultCircuitForAppVo;
} }
...@@ -272,7 +276,7 @@ public class CircuitController { ...@@ -272,7 +276,7 @@ public class CircuitController {
}else{ }else{
circuitTermVo.setTime(circuitTermVo.getTime().replace("天","").trim()); circuitTermVo.setTime(circuitTermVo.getTime().replace("天","").trim());
} }
circuitTermVo.setCompanyName(user.getCompanyName()); circuitTermVo.setCompanyNo(user.getCompanyNo());
return circuitService.getByTerm(circuitTermVo); return circuitService.getByTerm(circuitTermVo);
} }
...@@ -341,8 +345,8 @@ public class CircuitController { ...@@ -341,8 +345,8 @@ public class CircuitController {
List<ResultCityVo> cityVoList = new ArrayList<>(); List<ResultCityVo> cityVoList = new ArrayList<>();
List<CircuitMessageVo.CityMessage> cityMessageList =new ArrayList<>(); List<CircuitMessageVo.CityMessage> cityMessageList =new ArrayList<>();
if(gatewayVo == null || TDL.size() == 0){ if(gatewayVo == null || TDL.size() == 0){
messageVo.setSN(""); messageVo.setSN("NA");
messageVo.setBattery(""); messageVo.setBattery("NA");
messageVo.setAlarmLogList(alarmLogList); messageVo.setAlarmLogList(alarmLogList);
messageVo.setTdlList(tdlList); messageVo.setTdlList(tdlList);
messageVo.setList(cityVoList); messageVo.setList(cityVoList);
...@@ -360,17 +364,24 @@ public class CircuitController { ...@@ -360,17 +364,24 @@ public class CircuitController {
} }
QueryResult queryResult = influxDBTemplate.query(new Query(sql, database)); QueryResult queryResult = influxDBTemplate.query(new Query(sql, database));
if (queryResult.getResults().get(0).getSeries() == null) { if (queryResult.getResults().get(0).getSeries() == null) {
messageVo.setBattery(""); messageVo.setBattery("NA");
}else{ }else{
DecimalFormat df = new DecimalFormat("######0.0"); DecimalFormat df = new DecimalFormat("######0.0");
String value = queryResult.getResults().get(0).getSeries().get(0).getValues().get(0).get(1) == null ? "" : queryResult.getResults().get(0).getSeries().get(0).getValues().get(0).get(1).toString(); String val = queryResult.getResults().get(0).getSeries().get(0).getValues().get(0).get(1) == null ? "" : queryResult.getResults().get(0).getSeries().get(0).getValues().get(0).get(1).toString();
messageVo.setBattery(df.format(Double.valueOf(value))); Boolean boo = Double.valueOf(val) <0;
if(Double.valueOf(val) <0){
logger.info(Double.valueOf(val) +"_______");
messageVo.setBattery("NA");
}else{
messageVo.setBattery(df.format(Double.valueOf(val)));
}
} }
for(int i=0;i<TDL.size();i++){ for(int i=0;i<TDL.size();i++){
CircuitMessageVo.TDL tdl = new CircuitMessageVo.TDL(); CircuitMessageVo.TDL tdl = new CircuitMessageVo.TDL();
tdl.setTdlsn(TDL.get(i).replace("TDL-", "").trim()); tdl.setTdlsn(TDL.get(i).replace("TDL-", "").trim());
if(circuitVo.getStartTime() == null || circuitVo.getStartTime() == 0){ if(circuitVo.getStartTime() == null || circuitVo.getStartTime() == 0){
tdl.setBatteryVoltage(""); tdl.setBatteryVoltage("NA");
}else { }else {
String sql1 =""; String sql1 ="";
if (circuitVo.getEndTime() != null && circuitVo.getEndTime() != 0) { if (circuitVo.getEndTime() != null && circuitVo.getEndTime() != 0) {
...@@ -380,13 +391,17 @@ public class CircuitController { ...@@ -380,13 +391,17 @@ public class CircuitController {
} }
QueryResult queryResult1 = influxDBTemplate.query(new Query(sql1, database)); QueryResult queryResult1 = influxDBTemplate.query(new Query(sql1, database));
if (queryResult1.getResults().get(0).getSeries() == null) { if (queryResult1.getResults().get(0).getSeries() == null) {
tdl.setBatteryVoltage(""); tdl.setBatteryVoltage("NA");
}else{ }else{
DecimalFormat df = new DecimalFormat("######0.0"); DecimalFormat df = new DecimalFormat("######0.0");
String value = queryResult1.getResults().get(0).getSeries().get(0).getValues().get(0).get(1) == null ? "" : queryResult1.getResults().get(0).getSeries().get(0).getValues().get(0).get(1).toString(); String value = queryResult1.getResults().get(0).getSeries().get(0).getValues().get(0).get(1) == null ? "" : queryResult1.getResults().get(0).getSeries().get(0).getValues().get(0).get(1).toString();
if(Double.valueOf(value) <0){
tdl.setBatteryVoltage("NA");
}else{
tdl.setBatteryVoltage(df.format(Double.valueOf(value))); tdl.setBatteryVoltage(df.format(Double.valueOf(value)));
} }
} }
}
tdlList.add(tdl); tdlList.add(tdl);
} }
messageVo.setTdlList(tdlList); messageVo.setTdlList(tdlList);
...@@ -532,7 +547,7 @@ public class CircuitController { ...@@ -532,7 +547,7 @@ public class CircuitController {
} }
JSONObject jsonObject= JSON.parseObject(plateNo); JSONObject jsonObject= JSON.parseObject(plateNo);
plateNo=(String)jsonObject.get("plateNo"); plateNo=(String)jsonObject.get("plateNo");
return circuitService.getByPlateNo(plateNo,user.getCompanyName()); return circuitService.getByPlateNo(plateNo,user.getCompanyNo());
} }
...@@ -589,7 +604,7 @@ public class CircuitController { ...@@ -589,7 +604,7 @@ public class CircuitController {
String token = request.getHeader("Account_token"); String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token); String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class); UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
ResultCompanyVo companyVo = companyService.getByCompanyName(user.getCompanyName()); ResultCompanyVo companyVo = companyService.getByCompanyNo(user.getCompanyNo());
if(StringUtils.isEmpty(addCircuitVo.getStartAddressVo().getCountry())){ if(StringUtils.isEmpty(addCircuitVo.getStartAddressVo().getCountry())){
fb.setCode(0); fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"startCountry")); fb.setMessage(i18n.getMessage(request,"startCountry"));
...@@ -814,6 +829,16 @@ public class CircuitController { ...@@ -814,6 +829,16 @@ public class CircuitController {
String alarmTypeVar=""; String alarmTypeVar="";
String TDLSNVar=""; String TDLSNVar="";
List<String> devList = tdlDeviceService.getByGatewaySN(addCircuitVo.getSN(),type); List<String> devList = tdlDeviceService.getByGatewaySN(addCircuitVo.getSN(),type);
List<Float> tempL = new ArrayList<>();
List<Float> tempH = new ArrayList<>();
List<Float> humiL = new ArrayList<>();
List<Float> humiH = new ArrayList<>();
List<Integer> pressL = new ArrayList<>();
List<Integer> pressH = new ArrayList<>();
List<Integer> sugEnergy = new ArrayList<>();
List<Float> accThreshold = new ArrayList<>();
List<Integer> timeThreshold = new ArrayList<>();
List<Integer> tiltThreshold = new ArrayList<>();
for(int j = 0,length =addCircuitVo.getTdlAlarmList().size();j<length;j++){ for(int j = 0,length =addCircuitVo.getTdlAlarmList().size();j<length;j++){
if(StringUtils.isEmpty(addCircuitVo.getTdlAlarmList().get(j).getTDLSN())){ if(StringUtils.isEmpty(addCircuitVo.getTdlAlarmList().get(j).getTDLSN())){
fb.setCode(0); fb.setCode(0);
...@@ -839,6 +864,18 @@ public class CircuitController { ...@@ -839,6 +864,18 @@ public class CircuitController {
fb.setMessage(i18n.getMessage(request,"alarmType")); fb.setMessage(i18n.getMessage(request,"alarmType"));
return gson.toJson(fb); return gson.toJson(fb);
} }
//获取阈值信息
ResultAlarmVo resultAlarmVo = alarmService.getByType(addCircuitVo.getTdlAlarmList().get(j).getAlarmType(),user.getCompanyNo());
tempL.add(resultAlarmVo.getTemMin());
tempH.add(resultAlarmVo.getTemMax());
humiL.add(resultAlarmVo.getHumidityMin());
humiH.add(resultAlarmVo.getHumidityMax());
pressL.add(255);
pressH.add(255);
sugEnergy.add(1);
accThreshold.add(Float.valueOf(resultAlarmVo.getShock()));
timeThreshold.add(5);
tiltThreshold.add((int)Double.parseDouble(resultAlarmVo.getTilt().toString()));
alarmTypeVar =alarmTypeVar + addCircuitVo.getTdlAlarmList().get(j).getAlarmType() +"&"; alarmTypeVar =alarmTypeVar + addCircuitVo.getTdlAlarmList().get(j).getAlarmType() +"&";
TDLSNVar =TDLSNVar + addCircuitVo.getTdlAlarmList().get(j).getTDLSN() +"&"; TDLSNVar =TDLSNVar + addCircuitVo.getTdlAlarmList().get(j).getTDLSN() +"&";
devList.add("TDL-"+addCircuitVo.getTdlAlarmList().get(j).getTDLSN()); devList.add("TDL-"+addCircuitVo.getTdlAlarmList().get(j).getTDLSN());
...@@ -854,13 +891,19 @@ public class CircuitController { ...@@ -854,13 +891,19 @@ public class CircuitController {
fb.setMessage(i18n.getMessage(request,"plateNo")); fb.setMessage(i18n.getMessage(request,"plateNo"));
return gson.toJson(fb); return gson.toJson(fb);
} }
//判断当前车牌是否已存在
if(carService.getByCarNo(user.getCompanyName(),addCircuitVo.getCargoNo()) == null){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"nonexistentTruck"));
return gson.toJson(fb);
}
if(StringUtils.isEmpty(addCircuitVo.getCargoName())){ if(StringUtils.isEmpty(addCircuitVo.getCargoName())){
fb.setCode(0); fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"cargoName")); fb.setMessage(i18n.getMessage(request,"cargoName"));
return gson.toJson(fb); return gson.toJson(fb);
} }
//根据sn获取type //根据sn获取type
ConfigCMDVo configCMDVo = new ConfigCMDVo("config",5,15,devList,1,System.currentTimeMillis()/1000l); ConfigCMDVo configCMDVo = new ConfigCMDVo("config",5,15,devList,tempL,tempH,humiL,humiH,pressL,pressH,sugEnergy,accThreshold,timeThreshold,tiltThreshold,1,System.currentTimeMillis()/1000l);
Map<Object,Object> map=new HashMap<>(); Map<Object,Object> map=new HashMap<>();
String transportation = "公路"; String transportation = "公路";
String transportationType="本地运输"; String transportationType="本地运输";
...@@ -962,6 +1005,12 @@ public class CircuitController { ...@@ -962,6 +1005,12 @@ public class CircuitController {
fb.setMessage(i18n.getMessage(request,"plateNo")); fb.setMessage(i18n.getMessage(request,"plateNo"));
return gson.toJson(fb); return gson.toJson(fb);
} }
//判断当前车牌是否已存在
if(carService.getByCarNo(user.getCompanyName(),addCircuitVo.getCargoNo()) == null){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"nonexistentTruck"));
return gson.toJson(fb);
}
if(StringUtils.isEmpty(addCircuitVo.getCargoName())){ if(StringUtils.isEmpty(addCircuitVo.getCargoName())){
fb.setCode(0); fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"cargoName")); fb.setMessage(i18n.getMessage(request,"cargoName"));
...@@ -1136,13 +1185,12 @@ public class CircuitController { ...@@ -1136,13 +1185,12 @@ public class CircuitController {
String token = request.getHeader("Account_token"); String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token); String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class); UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
ResultCompanyVo companyVo = companyService.getByCompanyName(user.getCompanyName());
if (StringUtils.isEmpty(updateCircuitVo.getTransportationNo())){ if (StringUtils.isEmpty(updateCircuitVo.getTransportationNo())){
fb.setCode(0); fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"transportationNo")); fb.setMessage(i18n.getMessage(request,"transportationNo"));
return gson.toJson(fb); return gson.toJson(fb);
} }
if (circuitService.getByTransportationNo(updateCircuitVo.getTransportationNo(),user.getCompanyName())==null){ if (circuitService.getByTransportationNo(updateCircuitVo.getTransportationNo(),user.getCompanyNo())==null){
fb.setCode(0); fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"noCircuit")); fb.setMessage(i18n.getMessage(request,"noCircuit"));
return gson.toJson(fb); return gson.toJson(fb);
...@@ -1150,12 +1198,12 @@ public class CircuitController { ...@@ -1150,12 +1198,12 @@ public class CircuitController {
if (updateCircuitVo.getEndTime()==null){ if (updateCircuitVo.getEndTime()==null){
updateCircuitVo.setEndTime(System.currentTimeMillis()); updateCircuitVo.setEndTime(System.currentTimeMillis());
} }
if (circuitService.getByTransportationNo(updateCircuitVo.getTransportationNo(),user.getCompanyName()).getCircuitState() ==0){ if (circuitService.getByTransportationNo(updateCircuitVo.getTransportationNo(),user.getCompanyNo()).getCircuitState() ==0){
fb.setCode(0); fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"notStarted")); fb.setMessage(i18n.getMessage(request,"notStarted"));
return gson.toJson(fb); return gson.toJson(fb);
} }
ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(updateCircuitVo.getTransportationNo(),user.getCompanyName()); ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(updateCircuitVo.getTransportationNo(),user.getCompanyNo());
//获取当前线路的gateway 和tdl信息 //获取当前线路的gateway 和tdl信息
TDLLogVo tdlLogVo = tdlLogService.getByTransportationNo(updateCircuitVo.getTransportationNo()); TDLLogVo tdlLogVo = tdlLogService.getByTransportationNo(updateCircuitVo.getTransportationNo());
if(tdlLogVo == null){ if(tdlLogVo == null){
...@@ -1246,7 +1294,7 @@ public class CircuitController { ...@@ -1246,7 +1294,7 @@ public class CircuitController {
fb.setMessage(i18n.getMessage(request,"transportationNo")); fb.setMessage(i18n.getMessage(request,"transportationNo"));
return gson.toJson(fb); return gson.toJson(fb);
} }
if (circuitService.getByTransportationNo(updateEvaluateVo.getTransportationNo(),user.getCompanyName())==null){ if (circuitService.getByTransportationNo(updateEvaluateVo.getTransportationNo(),user.getCompanyNo())==null){
fb.setCode(0); fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"noCircuit")); fb.setMessage(i18n.getMessage(request,"noCircuit"));
return gson.toJson(fb); return gson.toJson(fb);
...@@ -1257,7 +1305,7 @@ public class CircuitController { ...@@ -1257,7 +1305,7 @@ public class CircuitController {
return gson.toJson(fb); return gson.toJson(fb);
} }
if (circuitService.getByTransportationNo(updateEvaluateVo.getTransportationNo(),user.getCompanyName()).getCircuitState()!=2){ if (circuitService.getByTransportationNo(updateEvaluateVo.getTransportationNo(),user.getCompanyNo()).getCircuitState()!=2){
fb.setCode(0); fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"completedCircuit")); fb.setMessage(i18n.getMessage(request,"completedCircuit"));
return gson.toJson(fb); return gson.toJson(fb);
...@@ -1303,7 +1351,7 @@ public class CircuitController { ...@@ -1303,7 +1351,7 @@ public class CircuitController {
fb.setMessage(i18n.getMessage(request,"circuitState")); fb.setMessage(i18n.getMessage(request,"circuitState"));
return gson.toJson(fb); return gson.toJson(fb);
} }
return circuitService.getByCircuitState(Integer.valueOf(map.get("circuitState").toString()),user.getCompanyName()); return circuitService.getByCircuitState(Integer.valueOf(map.get("circuitState").toString()),user.getCompanyNo());
} }
...@@ -1326,7 +1374,7 @@ public class CircuitController { ...@@ -1326,7 +1374,7 @@ public class CircuitController {
} }
JSONObject jsonObject= JSON.parseObject(transportationNo); JSONObject jsonObject= JSON.parseObject(transportationNo);
transportationNo=(String)jsonObject.get("transportationNo"); transportationNo=(String)jsonObject.get("transportationNo");
ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(transportationNo,user.getCompanyName()); ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(transportationNo,user.getCompanyNo());
if (resultCircuitVo==null){ if (resultCircuitVo==null){
fb.setCode(0); fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"noCircuit")); fb.setMessage(i18n.getMessage(request,"noCircuit"));
...@@ -1434,7 +1482,7 @@ public class CircuitController { ...@@ -1434,7 +1482,7 @@ public class CircuitController {
fb.setMessage(i18n.getMessage(request,"transportationNo")); fb.setMessage(i18n.getMessage(request,"transportationNo"));
return gson.toJson(fb); return gson.toJson(fb);
} }
if (circuitService.getByTransportationNo(startCircuitVo.getTransportationNo(),user.getCompanyName())==null){ if (circuitService.getByTransportationNo(startCircuitVo.getTransportationNo(),user.getCompanyNo())==null){
fb.setCode(0); fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"noCircuit")); fb.setMessage(i18n.getMessage(request,"noCircuit"));
return gson.toJson(fb); return gson.toJson(fb);
...@@ -1490,7 +1538,7 @@ public class CircuitController { ...@@ -1490,7 +1538,7 @@ public class CircuitController {
} }
JSONObject jsonObject= JSON.parseObject(transportationNo); JSONObject jsonObject= JSON.parseObject(transportationNo);
transportationNo=(String)jsonObject.get("transportationNo"); transportationNo=(String)jsonObject.get("transportationNo");
ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(transportationNo,user.getCompanyName()); ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(transportationNo,user.getCompanyNo());
if (resultCircuitVo==null){ if (resultCircuitVo==null){
fb.setCode(0); fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"noCircuit")); fb.setMessage(i18n.getMessage(request,"noCircuit"));
...@@ -1559,7 +1607,7 @@ public class CircuitController { ...@@ -1559,7 +1607,7 @@ public class CircuitController {
String token = request.getHeader("Account_token"); String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token); String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class); UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
ResultAlarmVo alarmVo = alarmService.getByType(alarmType,user.getCompanyName()); ResultAlarmVo alarmVo = alarmService.getByType(alarmType,user.getCompanyNo());
for(String alias :list){ for(String alias :list){
List<AlarmRuleVo> alarmRuleVos = new ArrayList<>(); List<AlarmRuleVo> alarmRuleVos = new ArrayList<>();
AlarmRuleVo alarmRuleVo = new AlarmRuleVo(); AlarmRuleVo alarmRuleVo = new AlarmRuleVo();
...@@ -1588,43 +1636,7 @@ public class CircuitController { ...@@ -1588,43 +1636,7 @@ public class CircuitController {
} }
} }
//获取已有线路
// @ApiOperation(value = "添加线路信息----mobile",notes = "添加线路信息," +
// " cargoNo:货物编号," +
// " plateNo:车牌号," +
// " cargoName:货物别名," +
// " transportation:运输方式,(公路,铁路,海运,空运,快递)" +
// " startAddressVo: 启运城市,包含" +
// " {" +
// " country:国家," +
// " city:城市," +
// " addressDetail:详细地址," +
// " lng:经度," +
// " lat:纬度," +
// " postCode:邮编,"+
// " expTime:预计开始时间,(13位时间戳)" +
// " }" +
// " endAddressVo: 目的城市,包含" +
// " {" +
// " country:国家," +
// " city:城市," +
// " addressDetail:详细地址," +
// " lng:经度," +
// " lat:纬度," +
// " postCode:邮编,"+
// " compTime:预计结束时间,(13位时间戳)" +
// " }" +
// " deliveryAddress:交付地点,(站点,仓库,港口)" +
// " transportationType:运输类型,(本地运输,国际运输)" +
// " remark:备注,")
// @ApiImplicitParams({
// @ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
// })
// @RequestMapping(value="/getExsitCircuit",method = RequestMethod.GET)
// public Object getExsitCircuit(){
//
// return gson.toJson(fb);
// }
// 修改线路信息 // 修改线路信息
// @ApiOperation(value = "修改线路信息",notes = "修改线路信息,传值说明:" + // @ApiOperation(value = "修改线路信息",notes = "修改线路信息,传值说明:" +
......
...@@ -69,14 +69,8 @@ public class CompanyController { ...@@ -69,14 +69,8 @@ public class CompanyController {
String token = request.getHeader("Account_token"); String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token); String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class); UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
if(user.getCompanyName().equals("上海辉度")){ return companyService.getAll(user.getCompanyNo());
return companyService.getAll();
}else {
List<ResultCompanyVo> companyVoList = new ArrayList<>();
ResultCompanyVo companyVo = companyService.getByCompanyName(user.getCompanyName());
companyVoList.add(companyVo);
return companyVoList;
}
} }
//添加公司信息 //添加公司信息
......
...@@ -99,7 +99,7 @@ public class DataController { ...@@ -99,7 +99,7 @@ public class DataController {
return gson.toJson(fb); return gson.toJson(fb);
} }
//根据运输编号获取线路信息 //根据运输编号获取线路信息
ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(searchLocationVo.getTransportationNo(),user.getCompanyName()); ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(searchLocationVo.getTransportationNo(),user.getCompanyNo());
List<LocationDataVo> locationDataVoList =new ArrayList<>(); List<LocationDataVo> locationDataVoList =new ArrayList<>();
if(resultCircuitVo == null){ if(resultCircuitVo == null){
return gson.toJson(locationDataVoList); return gson.toJson(locationDataVoList);
...@@ -108,10 +108,10 @@ public class DataController { ...@@ -108,10 +108,10 @@ public class DataController {
return gson.toJson(locationDataVoList); return gson.toJson(locationDataVoList);
} }
Long startTime = resultCircuitVo.getStartTime() *1000000l; Long startTime = resultCircuitVo.getStartTime() *1000000l;
if(resultCircuitVo.getEndTime() !=null && infoRedisService.hasHashKey("TransportConfig",searchLocationVo.getTransportationNo())){ // if(resultCircuitVo.getEndTime() !=null && infoRedisService.hasHashKey("TransportConfig",searchLocationVo.getTransportationNo())){
Object ret = infoRedisService.getHash("TransportConfig",searchLocationVo.getTransportationNo()); // Object ret = infoRedisService.getHash("TransportConfig",searchLocationVo.getTransportationNo());
return ret; // return ret;
} // }
//获取gateway的信息 //获取gateway的信息
TDLLogVo tdlLogVo = tdlLogService.getByTransportationNo(searchLocationVo.getTransportationNo()); TDLLogVo tdlLogVo = tdlLogService.getByTransportationNo(searchLocationVo.getTransportationNo());
if(tdlLogVo==null){ if(tdlLogVo==null){
...@@ -190,16 +190,17 @@ public class DataController { ...@@ -190,16 +190,17 @@ public class DataController {
} }
return gson.toJson(locationDataVoList); return gson.toJson(locationDataVoList);
}else{ }else{
//如果是已经完结保存到redis中 // //如果是已经完结保存到redis中
if (resultCircuitVo.getEndTime() != null && resultCircuitVo.getEndTime() != 0) { // if (resultCircuitVo.getEndTime() != null && resultCircuitVo.getEndTime() != 0) {
Map<Object, Object> map = new HashMap<>(); // Map<Object, Object> map = new HashMap<>();
map.put(searchLocationVo.getTransportationNo(), locationDataVos.toString()); // map.put(searchLocationVo.getTransportationNo(), locationDataVos.toString());
infoRedisService.setHash("TransportConfig", map,System.currentTimeMillis()); // infoRedisService.setHash("TransportConfig", map,System.currentTimeMillis());
} // }
return gson.toJson(locationDataVos); return gson.toJson(locationDataVos);
} }
} }
//获取历史数据 //获取历史数据
@ApiOperation(value = "获取历史数据",notes = "获取历史数据:") @ApiOperation(value = "获取历史数据",notes = "获取历史数据:")
@PostMapping("/getHistoryData") @PostMapping("/getHistoryData")
...@@ -212,8 +213,6 @@ public class DataController { ...@@ -212,8 +213,6 @@ public class DataController {
String datum = tokenRedisService.get("TOKEN_" +token); String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class); UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
String port = request.getHeader("AccountLanguage"); String port = request.getHeader("AccountLanguage");
logger.info("" +System.currentTimeMillis());
logger.info("" + Calendar.getInstance().getTimeInMillis());
JSONObject jsonObject= JSON.parseObject(transportationNo); JSONObject jsonObject= JSON.parseObject(transportationNo);
transportationNo=jsonObject.getString("transportationNo"); transportationNo=jsonObject.getString("transportationNo");
List<DataVo> dataVoList = new ArrayList<>(); List<DataVo> dataVoList = new ArrayList<>();
...@@ -222,7 +221,7 @@ public class DataController { ...@@ -222,7 +221,7 @@ public class DataController {
fb.setMessage(i18n.getMessage(request,"transportationNo")); fb.setMessage(i18n.getMessage(request,"transportationNo"));
return gson.toJson(fb); return gson.toJson(fb);
} }
ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(transportationNo,user.getCompanyName()); ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(transportationNo,user.getCompanyNo());
if(resultCircuitVo ==null){ if(resultCircuitVo ==null){
fb.setCode(0); fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"noCircuit")); fb.setMessage(i18n.getMessage(request,"noCircuit"));
...@@ -234,9 +233,6 @@ public class DataController { ...@@ -234,9 +233,6 @@ public class DataController {
return gson.toJson(fb); return gson.toJson(fb);
} }
Long startTime = resultCircuitVo.getStartTime() *1000000l; Long startTime = resultCircuitVo.getStartTime() *1000000l;
if(resultCircuitVo.getEndTime() !=null && resultCircuitVo.getEndTime() !=0 && infoRedisService.hasHashKey("HistoryData",transportationNo)){
return infoRedisService.getHash("HistoryData",transportationNo);
}else{
TDLLogVo gatewayVo = tdlLogService.getByTransportationNo(transportationNo); TDLLogVo gatewayVo = tdlLogService.getByTransportationNo(transportationNo);
if(gatewayVo == null){ if(gatewayVo == null){
fb.setCode(0); fb.setCode(0);
...@@ -256,6 +252,7 @@ public class DataController { ...@@ -256,6 +252,7 @@ public class DataController {
map.put("\"h\"","humidity"); map.put("\"h\"","humidity");
map.put("\"p\"","pressure"); map.put("\"p\"","pressure");
map.put("\"a0\"","shockEnergy"); map.put("\"a0\"","shockEnergy");
map.put("\"a1\"","shock");
map.put("\"ta\"","tilt"); map.put("\"ta\"","tilt");
for(int j = 0;j< list.size();j++){ for(int j = 0;j< list.size();j++){
DataVo dataVo = new DataVo(); DataVo dataVo = new DataVo();
...@@ -268,232 +265,99 @@ public class DataController { ...@@ -268,232 +265,99 @@ public class DataController {
ResultAlarmVo resultAlarmVo = tdlLogService.getByTdl(transportationNo,TDLSN); ResultAlarmVo resultAlarmVo = tdlLogService.getByTdl(transportationNo,TDLSN);
if(list.get(j).equals("\"T\"") ){ if(list.get(j).equals("\"T\"") ){
//根据tdl货物报警信息 //根据tdl货物报警信息
dataVo.setMax(resultAlarmVo.getTemMax().toString()); historyDataVo.setMax(resultAlarmVo.getTemMax().toString());
dataVo.setMin(resultAlarmVo.getTemMin().toString()); historyDataVo.setMin(resultAlarmVo.getTemMin().toString());
}else if(list.get(j).equals("\"h\"")){ }else if(list.get(j).equals("\"h\"")){
dataVo.setMax(resultAlarmVo.getHumidityMax().toString()); historyDataVo.setMax(resultAlarmVo.getHumidityMax().toString());
dataVo.setMin(resultAlarmVo.getHumidityMin().toString()); historyDataVo.setMin(resultAlarmVo.getHumidityMin().toString());
}
List<HistoryData> historyData = new ArrayList<>();
String sqls = "";
if(resultCircuitVo.getEndTime() !=null && resultCircuitVo.getEndTime() !=0){
sqls = "SELECT count(" + list.get(j) + ") FROM \"tdl_policy\".\"" + device + "\" WHERE \"tdl\"='" + devList.get(i) + "' and time>=" + startTime + " and time <=" + resultCircuitVo.getEndTime() * 1000000l;
}else {
sqls = "SELECT count(" + list.get(j) + ") FROM \"tdl_policy\".\"" + device + "\" WHERE \"tdl\"='" + devList.get(i) + "' and time>=" + startTime + " and time <=" + System.currentTimeMillis() * 1000000l;
}
QueryResult queryResults = influxDBTemplate.query(new Query(sqls,database));
Integer count;
if(queryResults.getResults().get(0).getSeries() != null){
count = Double.valueOf(queryResults.getResults().get(0).getSeries().get(0).getValues().get(0).get(1).toString()).intValue();
}else{
historyDataVo.setDataList(historyData);
historyDataVoList.add(historyDataVo);
continue;
} }
String sql=""; String sql="";
if(count >500){
if(resultCircuitVo.getEndTime() !=null && resultCircuitVo.getEndTime() !=0){ if(resultCircuitVo.getEndTime() !=null && resultCircuitVo.getEndTime() !=0){
sql = "SELECT "+list.get(j)+" FROM \"tdl_policy\".\""+device+"\" where \"tdl\"='"+devList.get(i)+"' and time >="+startTime + " and time<="+resultCircuitVo.getEndTime() *1000000l+" ORDER BY time "; sql = getSQL(list.get(j),device,devList.get(i),startTime,resultCircuitVo.getEndTime() *1000000l);
// sql = "SELECT "+list.get(j)+" FROM \"tdl_policy\".\""+device+"\" where \"tdl\"='"+devList.get(i)+"' and time >="+startTime + " and time<="+resultCircuitVo.getEndTime() *1000000l+" ORDER BY time ";
}else{ }else{
sql = "SELECT "+list.get(j)+" FROM \"tdl_policy\".\""+device+"\" where \"tdl\"='"+devList.get(i)+"' and time >="+startTime + " ORDER BY time "; sql = getSQL(list.get(j),device,devList.get(i),startTime,System.currentTimeMillis()*1000000l);
// sql = "SELECT "+list.get(j)+" FROM \"tdl_policy\".\""+device+"\" 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<HistoryData> historyData = new ArrayList<>(); if(queryResult.getResults()!=null){
if(queryResult.getResults().get(0).getSeries() != null){ historyData = getHistoryDatas(queryResult,list.get(j));
//解析数据
historyData = getHistoryData(queryResult,list.get(j));
} }
historyDataVo.setDataList(historyData); historyDataVo.setDataList(historyData);
historyDataVoList.add(historyDataVo); historyDataVoList.add(historyDataVo);
}else{
if(resultCircuitVo.getEndTime() !=null && resultCircuitVo.getEndTime() !=0){
sql = "SELECT "+list.get(j)+" FROM \"tdl_policy\".\""+device+"\" where \"tdl\"='"+devList.get(i)+"' and time >="+startTime + " and time<="+resultCircuitVo.getEndTime() *1000000l+" ORDER BY time ";
}else{
sql = "SELECT "+list.get(j)+" FROM \"tdl_policy\".\""+device+"\" where \"tdl\"='"+devList.get(i)+"' and time >="+startTime + " ORDER BY time";
} }
dataVo.setDataList(historyDataVoList);
dataVoList.add(dataVo);
}
if(resultCircuitVo.getEndTime()!=null && resultCircuitVo.getEndTime()!=0){
Map<Object,Object> m = new HashMap<>();
map.put(transportationNo,dataVoList.toString());
infoRedisService.setHash("HistoryData",m,System.currentTimeMillis());
}
return gson.toJson(dataVoList);
}
}
//获取温度数据
@ApiOperation(value = "获取温度数据",notes = "获取温度数据:" +
" TDLSN:tdl编号," +
" temperatureDataVos:," +
" time:时间," +
" value:温度数据.")
@PostMapping("/getTemperature")
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
public Object getTemperature(@RequestBody String transportationNo,HttpServletRequest request){
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
JSONObject jsonObject= JSON.parseObject(transportationNo);
transportationNo=jsonObject.getString("transportationNo");
ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(transportationNo,user.getCompanyName());
TDLLogVo gatewayVo = tdlLogService.getByTransportationNo(transportationNo);
if(gatewayVo == null){
fb.setCode(0);
fb.setMessage("该线路未绑定gateway和tdl");
return gson.toJson(fb);
}
String device = gatewayVo.getgType() +"_" +gatewayVo.getgSN();
//获取tdl信息
List<String> devList = tdlLogService.getTdlSN(transportationNo);
Long startTime = resultCircuitVo.getStartTime() *1000000l;
//SELECT "h" FROM "tdl_policy"."WTD93LG_20180314" WHERE "tdl" = 'tdl-0A0B0C0D0F' ORDER BY time DESC
if(devList.size() == 0){
fb.setCode(0);
fb.setMessage("该线路未绑定gateway和tdl");
return gson.toJson(fb);
}
List<Temperature> temperatures = new ArrayList<>();
for( int i =0;i<devList.size();i++){
Temperature temperature = new Temperature();
temperature.setTDLSN(devList.get(i));
String sql = "SELECT \"T\" FROM \"tdl_policy\".\""+device+"\" 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<>();
if(queryResult.getResults().get(0).getSeries() != null){ if(queryResult.getResults().get(0).getSeries() != null){
//解析数据 //解析数据
temperatureDataVos = getTemperature(queryResult); historyData = getHistoryData(queryResult,list.get(j));
}
temperature.setTemperatureDataVos(temperatureDataVos);
temperatures.add(temperature);
} }
return gson.toJson(temperatures); historyDataVo.setDataList(historyData);
historyDataVoList.add(historyDataVo);
} }
//获取湿度数据
@ApiOperation(value = "获取湿度数据",notes = "获取湿度数据:")
@PostMapping("/getHumidity")
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
public Object getHumidity(@RequestBody String transportationNo,HttpServletRequest request){
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
JSONObject jsonObject= JSON.parseObject(transportationNo);
transportationNo=jsonObject.getString("transportationNo");
ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(transportationNo,user.getCompanyName());
TDLLogVo gatewayVo = tdlLogService.getByTransportationNo(transportationNo);
if(gatewayVo == null){
fb.setCode(0);
fb.setMessage("该线路未绑定gateway和tdl");
return gson.toJson(fb);
}
String device = gatewayVo.getgType() +"_" +gatewayVo.getgSN();
//获取tdl信息
List<String> devList = tdlLogService.getTdlSN(transportationNo);
//获取tdl信息
if(devList.size() == 0){
fb.setCode(0);
fb.setMessage("没有数据");
return gson.toJson(fb);
} }
Long startTime = resultCircuitVo.getStartTime() *1000000l; dataVo.setDataList(historyDataVoList);
List<Humidity> humidities = new ArrayList<>(); dataVoList.add(dataVo);
for( int i =0;i<devList.size();i++){
Humidity humidity = new Humidity();
humidity.setTDLSN(devList.get(i));
String sql = "SELECT \"h\" FROM \"tdl_policy\".\""+device+"\" where \"tdl\"=\'"+devList.get(i)+"\' and time >="+startTime+" ORDER BY time ";
QueryResult queryResult = influxDBTemplate.query(new Query(sql,database));
List<HumidityDataVo> humidityDataVos = new ArrayList<>();
if(queryResult.getResults().get(0).getSeries() != null){
//解析数据
humidityDataVos = getHumidity(queryResult);
}
humidity.setHumidityDataVoList(humidityDataVos);
humidities.add(humidity);
} }
return gson.toJson(humidities); // if(resultCircuitVo.getEndTime()!=null && resultCircuitVo.getEndTime()!=0){
// Map<Object,Object> m = new HashMap<>();
// map.put(transportationNo,dataVoList.toString());
// infoRedisService.setHash("HistoryData",m,System.currentTimeMillis());
// }
return gson.toJson(dataVoList);
} }
//获取倾斜度数据 public List<HistoryData> getHistoryDatas(QueryResult queryResult,String alias){
@ApiOperation(value = "获取倾斜度数据",notes = "获取倾斜度数据") String dateResult =null;
@PostMapping("/getTiltAngle") List<Object> values = new ArrayList<>();
@ApiImplicitParams({ List<List<Object>> value = new ArrayList<>();
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"), for(QueryResult.Result result : queryResult.getResults()){
}) if(result.getSeries() !=null){
public Object getTiltAngle(@RequestBody String transportationNo,HttpServletRequest request){ for (QueryResult.Series series : result.getSeries()) {
String token = request.getHeader("Account_token"); if(series !=null){
String datum = tokenRedisService.get("TOKEN_" +token); values = series.getValues().get(0);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class); value.add(values);
JSONObject jsonObject= JSON.parseObject(transportationNo); }else{
transportationNo=jsonObject.getString("transportationNo"); continue;
ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(transportationNo,user.getCompanyName());
Long startTime = resultCircuitVo.getStartTime() *1000000l;
TDLLogVo gatewayVo = tdlLogService.getByTransportationNo(transportationNo);
if(gatewayVo == null){
fb.setCode(0);
fb.setMessage("该线路未绑定gateway和tdl");
return gson.toJson(fb);
}
String device = gatewayVo.getgType() +"_" +gatewayVo.getgSN();
//获取tdl信息
List<String> devList = tdlLogService.getTdlSN(transportationNo);
if(devList.size() == 0){
fb.setCode(0);
fb.setMessage("没有数据");
return gson.toJson(fb);
}
List<TiltAngle> tiltAngles = new ArrayList<>();
for( int i =0;i<devList.size();i++){
TiltAngle tiltAngle = new TiltAngle();
tiltAngle.setTDLSN(devList.get(i));
String sql = "SELECT \"ta\" FROM \"tdl_policy\".\""+device+"\" where \"tdl\"=\'"+devList.get(i)+"\' and time >="+startTime+" ORDER BY time ";
QueryResult queryResult = influxDBTemplate.query(new Query(sql,database));
List<TiltAngleVo> tiltAngleVos = new ArrayList<>();
if(queryResult.getResults().get(0).getSeries() != null){
//解析数据
tiltAngleVos = getTiltAngle(queryResult);
}
tiltAngle.setShockEnergyVoList(tiltAngleVos);
tiltAngles.add(tiltAngle);
}
return gson.toJson(tiltAngles);
} }
//获取震动能量
@ApiOperation(value = "获取震动能量",notes = "获取震动能量")
@PostMapping("/getShockEnergy")
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
public Object getShockEnergy(@RequestBody String transportationNo,HttpServletRequest request){
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
JSONObject jsonObject= JSON.parseObject(transportationNo);
transportationNo=jsonObject.getString("transportationNo");
ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(transportationNo,user.getCompanyName());
TDLLogVo gatewayVo = tdlLogService.getByTransportationNo(transportationNo);
if(gatewayVo == null){
fb.setCode(0);
fb.setMessage("该线路未绑定gateway和tdl");
return gson.toJson(fb);
} }
String device = gatewayVo.getgType() +"_" +gatewayVo.getgSN(); }else{
//获取tdl信息 continue;
List<String> devList = tdlLogService.getTdlSN(transportationNo);
Long startTime = resultCircuitVo.getStartTime() *1000000l;
//获取tdl信息
if(devList.size() == 0){
fb.setCode(0);
fb.setMessage("没有数据");
return gson.toJson(fb);
} }
List<ShockEnergy> shockEnergies = new ArrayList<>();
for( int i =0;i<devList.size();i++){
ShockEnergy shockEnergy = new ShockEnergy();
shockEnergy.setTDLSN(devList.get(i));
String sql = "SELECT \"a0\" FROM \"tdl_policy\".\""+device+"\" where \"tdl\"=\'"+devList.get(i)+"\' and time >="+startTime+" ORDER BY time ";
QueryResult queryResult = influxDBTemplate.query(new Query(sql,database));
List<ShockEnergyVo> shockEnergyVos = new ArrayList<>();
if(queryResult.getResults().get(0).getSeries() != null){
//解析数据
shockEnergyVos = getShockEnergy(queryResult);
} }
shockEnergy.setShockEnergyVoList(shockEnergyVos); List<HistoryData> historyDataList = new ArrayList<>();
shockEnergies.add(shockEnergy); for(int i =0;i<value.size(); i++){
HistoryData historyData = new HistoryData();
historyData.setTime(parseTime(value.get(i).get(0).toString()));
historyData.setValue(value.get(i).get(1).toString());
historyDataList.add(historyData);
} }
return gson.toJson(shockEnergies); return historyDataList;
} }
//解析数据 //解析数据
public List<LocationDataVo> getLocation(QueryResult queryResult){ public List<LocationDataVo> getLocation(QueryResult queryResult){
List<List<Object>> values = getValues(queryResult); List<List<Object>> values = getValues(queryResult);
...@@ -736,6 +600,312 @@ public class DataController { ...@@ -736,6 +600,312 @@ public class DataController {
return historyDataList; return historyDataList;
} }
public String getSQL(String field,String device,String tdl,Long startTime,Long endTime){
String sql="";
long times = (endTime - startTime) / 500;
for (int i = 0;i<500;i++){
Long maxTime = startTime + times;
sql = sql +String.format("Select %s From \"tdl_policy\".\"%s\" where \"tdl\"='%s' and time >= %d and time <= %d order by time limit 1;", field, device,tdl, startTime, maxTime);
startTime = maxTime;
}
sql = sql +"";
return sql;
}
//获取温度数据
// @ApiOperation(value = "获取温度数据",notes = "获取温度数据:" +
// " TDLSN:tdl编号," +
// " temperatureDataVos:," +
// " time:时间," +
// " value:温度数据.")
// @PostMapping("/getTemperature")
// @ApiImplicitParams({
// @ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
// })
// public Object getTemperature(@RequestBody String transportationNo,HttpServletRequest request){
// String token = request.getHeader("Account_token");
// String datum = tokenRedisService.get("TOKEN_" +token);
// UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
// JSONObject jsonObject= JSON.parseObject(transportationNo);
// transportationNo=jsonObject.getString("transportationNo");
// ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(transportationNo,user.getCompanyName());
// TDLLogVo gatewayVo = tdlLogService.getByTransportationNo(transportationNo);
// if(gatewayVo == null){
// fb.setCode(0);
// fb.setMessage("该线路未绑定gateway和tdl");
// return gson.toJson(fb);
// }
// String device = gatewayVo.getgType() +"_" +gatewayVo.getgSN();
// //获取tdl信息
// List<String> devList = tdlLogService.getTdlSN(transportationNo);
// Long startTime = resultCircuitVo.getStartTime() *1000000l;
// //SELECT "h" FROM "tdl_policy"."WTD93LG_20180314" WHERE "tdl" = 'tdl-0A0B0C0D0F' ORDER BY time DESC
// if(devList.size() == 0){
// fb.setCode(0);
// fb.setMessage("该线路未绑定gateway和tdl");
// return gson.toJson(fb);
// }
// List<Temperature> temperatures = new ArrayList<>();
// for( int i =0;i<devList.size();i++){
// Temperature temperature = new Temperature();
// temperature.setTDLSN(devList.get(i));
// String sql = "SELECT \"T\" FROM \"tdl_policy\".\""+device+"\" where \"tdl\"=\'"+devList.get(i)+"\' and time >="+startTime+" 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);
// }
// temperature.setTemperatureDataVos(temperatureDataVos);
// temperatures.add(temperature);
// }
// return gson.toJson(temperatures);
// }
//
//
// //获取湿度数据
// @ApiOperation(value = "获取湿度数据",notes = "获取湿度数据:")
// @PostMapping("/getHumidity")
// @ApiImplicitParams({
// @ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
// })
// public Object getHumidity(@RequestBody String transportationNo,HttpServletRequest request){
// String token = request.getHeader("Account_token");
// String datum = tokenRedisService.get("TOKEN_" +token);
// UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
// JSONObject jsonObject= JSON.parseObject(transportationNo);
// transportationNo=jsonObject.getString("transportationNo");
// ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(transportationNo,user.getCompanyName());
// TDLLogVo gatewayVo = tdlLogService.getByTransportationNo(transportationNo);
// if(gatewayVo == null){
// fb.setCode(0);
// fb.setMessage("该线路未绑定gateway和tdl");
// return gson.toJson(fb);
// }
// String device = gatewayVo.getgType() +"_" +gatewayVo.getgSN();
// //获取tdl信息
// List<String> devList = tdlLogService.getTdlSN(transportationNo);
// //获取tdl信息
// if(devList.size() == 0){
// fb.setCode(0);
// fb.setMessage("没有数据");
// return gson.toJson(fb);
// }
// Long startTime = resultCircuitVo.getStartTime() *1000000l;
// List<Humidity> humidities = new ArrayList<>();
// for( int i =0;i<devList.size();i++){
// Humidity humidity = new Humidity();
// humidity.setTDLSN(devList.get(i));
// String sql = "SELECT \"h\" FROM \"tdl_policy\".\""+device+"\" where \"tdl\"=\'"+devList.get(i)+"\' and time >="+startTime+" ORDER BY time ";
// QueryResult queryResult = influxDBTemplate.query(new Query(sql,database));
// List<HumidityDataVo> humidityDataVos = new ArrayList<>();
// if(queryResult.getResults().get(0).getSeries() != null){
// //解析数据
// humidityDataVos = getHumidity(queryResult);
// }
// humidity.setHumidityDataVoList(humidityDataVos);
// humidities.add(humidity);
// }
// return gson.toJson(humidities);
// }
//
//
// //获取倾斜度数据
// @ApiOperation(value = "获取倾斜度数据",notes = "获取倾斜度数据")
// @PostMapping("/getTiltAngle")
// @ApiImplicitParams({
// @ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
// })
// public Object getTiltAngle(@RequestBody String transportationNo,HttpServletRequest request){
// String token = request.getHeader("Account_token");
// String datum = tokenRedisService.get("TOKEN_" +token);
// UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
// JSONObject jsonObject= JSON.parseObject(transportationNo);
// transportationNo=jsonObject.getString("transportationNo");
// ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(transportationNo,user.getCompanyName());
// Long startTime = resultCircuitVo.getStartTime() *1000000l;
// TDLLogVo gatewayVo = tdlLogService.getByTransportationNo(transportationNo);
// if(gatewayVo == null){
// fb.setCode(0);
// fb.setMessage("该线路未绑定gateway和tdl");
// return gson.toJson(fb);
// }
// String device = gatewayVo.getgType() +"_" +gatewayVo.getgSN();
// //获取tdl信息
// List<String> devList = tdlLogService.getTdlSN(transportationNo);
// if(devList.size() == 0){
// fb.setCode(0);
// fb.setMessage("没有数据");
// return gson.toJson(fb);
// }
// List<TiltAngle> tiltAngles = new ArrayList<>();
// for( int i =0;i<devList.size();i++){
// TiltAngle tiltAngle = new TiltAngle();
// tiltAngle.setTDLSN(devList.get(i));
// String sql = "SELECT \"ta\" FROM \"tdl_policy\".\""+device+"\" where \"tdl\"=\'"+devList.get(i)+"\' and time >="+startTime+" ORDER BY time ";
// QueryResult queryResult = influxDBTemplate.query(new Query(sql,database));
// List<TiltAngleVo> tiltAngleVos = new ArrayList<>();
// if(queryResult.getResults().get(0).getSeries() != null){
// //解析数据
// tiltAngleVos = getTiltAngle(queryResult);
// }
// tiltAngle.setShockEnergyVoList(tiltAngleVos);
// tiltAngles.add(tiltAngle);
// }
// return gson.toJson(tiltAngles);
// }
//
//
//
// //获取震动能量
// @ApiOperation(value = "获取震动能量",notes = "获取震动能量")
// @PostMapping("/getShockEnergy")
// @ApiImplicitParams({
// @ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
// })
// public Object getShockEnergy(@RequestBody String transportationNo,HttpServletRequest request){
// String token = request.getHeader("Account_token");
// String datum = tokenRedisService.get("TOKEN_" +token);
// UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
// JSONObject jsonObject= JSON.parseObject(transportationNo);
// transportationNo=jsonObject.getString("transportationNo");
// ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(transportationNo,user.getCompanyName());
// TDLLogVo gatewayVo = tdlLogService.getByTransportationNo(transportationNo);
// if(gatewayVo == null){
// fb.setCode(0);
// fb.setMessage("该线路未绑定gateway和tdl");
// return gson.toJson(fb);
// }
// String device = gatewayVo.getgType() +"_" +gatewayVo.getgSN();
// //获取tdl信息
// List<String> devList = tdlLogService.getTdlSN(transportationNo);
// Long startTime = resultCircuitVo.getStartTime() *1000000l;
// //获取tdl信息
// if(devList.size() == 0){
// fb.setCode(0);
// fb.setMessage("没有数据");
// return gson.toJson(fb);
// }
// List<ShockEnergy> shockEnergies = new ArrayList<>();
// for( int i =0;i<devList.size();i++){
// ShockEnergy shockEnergy = new ShockEnergy();
// shockEnergy.setTDLSN(devList.get(i));
// String sql = "SELECT \"a0\" FROM \"tdl_policy\".\""+device+"\" where \"tdl\"=\'"+devList.get(i)+"\' and time >="+startTime+" ORDER BY time ";
// QueryResult queryResult = influxDBTemplate.query(new Query(sql,database));
// List<ShockEnergyVo> shockEnergyVos = new ArrayList<>();
// if(queryResult.getResults().get(0).getSeries() != null){
// //解析数据
// shockEnergyVos = getShockEnergy(queryResult);
// }
// shockEnergy.setShockEnergyVoList(shockEnergyVos);
// shockEnergies.add(shockEnergy);
// }
// return gson.toJson(shockEnergies);
// }
//获取历史数据
// @ApiOperation(value = "获取历史数据",notes = "获取历史数据:")
// @PostMapping("/getHistoryData")
// @ApiImplicitParams({
// @ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
// @ApiImplicitParam(paramType="header", name = "AccountLanguage", value = "language", required = false, dataType = "String"),
// })
// public Object getHistoryData(@RequestBody String transportationNo,HttpServletRequest request){
// String token = request.getHeader("Account_token");
// String datum = tokenRedisService.get("TOKEN_" +token);
// UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
// String port = request.getHeader("AccountLanguage");
// logger.info("" +System.currentTimeMillis());
// logger.info("" + Calendar.getInstance().getTimeInMillis());
// JSONObject jsonObject= JSON.parseObject(transportationNo);
// transportationNo=jsonObject.getString("transportationNo");
// List<DataVo> dataVoList = new ArrayList<>();
// if(StringUtils.isEmpty(transportationNo)){
// fb.setCode(0);
// fb.setMessage(i18n.getMessage(request,"transportationNo"));
// return gson.toJson(fb);
// }
// ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(transportationNo,user.getCompanyName());
// if(resultCircuitVo ==null){
// fb.setCode(0);
// fb.setMessage(i18n.getMessage(request,"noCircuit"));
// return gson.toJson(fb);
// }
// if(resultCircuitVo.getStartTime() == null || resultCircuitVo.getStartTime() == 0){
// fb.setCode(0);
// fb.setMessage(i18n.getMessage(request,"notStarted"));
// return gson.toJson(fb);
// }
// Long startTime = resultCircuitVo.getStartTime() *1000000l;
// if(resultCircuitVo.getEndTime() !=null && resultCircuitVo.getEndTime() !=0 && infoRedisService.hasHashKey("HistoryData",transportationNo)){
// return infoRedisService.getHash("HistoryData",transportationNo);
// }else{
// TDLLogVo gatewayVo = tdlLogService.getByTransportationNo(transportationNo);
// if(gatewayVo == null){
// fb.setCode(0);
// fb.setMessage(i18n.getMessage(request,"noCircuit"));
// return gson.toJson(fb);
// }
// String device = gatewayVo.getgType() +"_" +gatewayVo.getgSN();
// //获取tdl信息
// List<String> devList= tdlLogService.getTdlSN(transportationNo);
// if(devList.size() == 0){
// fb.setCode(0);
// fb.setMessage(i18n.getMessage(request,"noCircuit"));
// return gson.toJson(fb);
// }
// 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");
// 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();
// String TDLSN=devList.get(i).replace("TDL-","").trim();
// historyDataVo.setTDLSN(TDLSN);
// ResultAlarmVo resultAlarmVo = tdlLogService.getByTdl(transportationNo,TDLSN);
// if(list.get(j).equals("\"T\"") ){
// //根据tdl货物报警信息
// dataVo.setMax(resultAlarmVo.getTemMax().toString());
// dataVo.setMin(resultAlarmVo.getTemMin().toString());
// }else if(list.get(j).equals("\"h\"")){
// dataVo.setMax(resultAlarmVo.getHumidityMax().toString());
// dataVo.setMin(resultAlarmVo.getHumidityMin().toString());
// }
// String sql="";
// if(resultCircuitVo.getEndTime() !=null && resultCircuitVo.getEndTime() !=0){
// sql = "SELECT "+list.get(j)+" FROM \"tdl_policy\".\""+device+"\" where \"tdl\"='"+devList.get(i)+"' and time >="+startTime + " and time<="+resultCircuitVo.getEndTime() *1000000l+" ORDER BY time ";
// }else{
// sql = "SELECT "+list.get(j)+" FROM \"tdl_policy\".\""+device+"\" 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,list.get(j));
// }
// historyDataVo.setDataList(historyData);
// historyDataVoList.add(historyDataVo);
// }
// dataVo.setDataList(historyDataVoList);
// dataVoList.add(dataVo);
// }
// if(resultCircuitVo.getEndTime()!=null && resultCircuitVo.getEndTime()!=0){
// Map<Object,Object> m = new HashMap<>();
// map.put(transportationNo,dataVoList.toString());
// infoRedisService.setHash("HistoryData",m,System.currentTimeMillis());
// }
// return gson.toJson(dataVoList);
// }
// }
// 根据运输编号获取路线以及设备信息 // 根据运输编号获取路线以及设备信息
// @ApiOperation(value = "获取路线以及设备信息",notes = "获取路线以及设备信息" + // @ApiOperation(value = "获取路线以及设备信息",notes = "获取路线以及设备信息" +
// "transportationNo:运输编号" + // "transportationNo:运输编号" +
......
...@@ -88,11 +88,6 @@ public class EquipmentBindingController { ...@@ -88,11 +88,6 @@ public class EquipmentBindingController {
fb.setMessage("网关编号不能为空"); fb.setMessage("网关编号不能为空");
return gson.toJson(fb); return gson.toJson(fb);
} }
if(StringUtils.isEmpty(bindingVo.getType())){
fb.setCode(0);
fb.setMessage("网关类型不能为空");
return gson.toJson(fb);
}
if(StringUtils.isEmpty(bindingVo.getTDLSN())){ if(StringUtils.isEmpty(bindingVo.getTDLSN())){
fb.setCode(0); fb.setCode(0);
fb.setMessage("Tdl编号不能为空"); fb.setMessage("Tdl编号不能为空");
...@@ -108,6 +103,9 @@ public class EquipmentBindingController { ...@@ -108,6 +103,9 @@ public class EquipmentBindingController {
fb.setMessage("使用场景不能为空"); fb.setMessage("使用场景不能为空");
return gson.toJson(fb); return gson.toJson(fb);
} }
if(StringUtils.isEmpty(bindingVo.getType())){
bindingVo.setType(gatewayService.getBySN(bindingVo.getSN(),user.getCompanyNo()));
}
//获取gateWay的信息 //获取gateWay的信息
ResultGatewayVo resultGatewayVo = gatewayService.getBySNAndType(bindingVo.getSN(),bindingVo.getType()); ResultGatewayVo resultGatewayVo = gatewayService.getBySNAndType(bindingVo.getSN(),bindingVo.getType());
if(resultGatewayVo == null){ if(resultGatewayVo == null){
...@@ -122,7 +120,7 @@ public class EquipmentBindingController { ...@@ -122,7 +120,7 @@ public class EquipmentBindingController {
} }
//判断当前tdl是否有网关在使用 //判断当前tdl是否有网关在使用
ResultTDLDeviceVo resultTDLDeviceVo = tdlDeviceService.getByTDLSN(bindingVo.getTDLSN()); ResultTDLDeviceVo resultTDLDeviceVo = tdlDeviceService.getByTDLSN(bindingVo.getTDLSN());
if(resultTDLDeviceVo != null &&!StringUtils.isEmpty(resultTDLDeviceVo.getGatewaySN())){ if(!StringUtils.isEmpty(resultTDLDeviceVo.getGatewaySN())){
fb.setCode(0); fb.setCode(0);
fb.setMessage("该TDL已经被使用"); fb.setMessage("该TDL已经被使用");
return gson.toJson(fb); return gson.toJson(fb);
...@@ -132,22 +130,48 @@ public class EquipmentBindingController { ...@@ -132,22 +130,48 @@ public class EquipmentBindingController {
}else if(StringUtils.isEmpty(bindingVo.getWarehouseNo()) && !StringUtils.isEmpty(bindingVo.getTransportationNo())){ }else if(StringUtils.isEmpty(bindingVo.getWarehouseNo()) && !StringUtils.isEmpty(bindingVo.getTransportationNo())){
bindingVo.setWarehouseNo(""); bindingVo.setWarehouseNo("");
} }
String alarmScene = "";
//开始绑定
//获取gateway下的所有tdl的编号
List<String> devList = tdlDeviceService.getByGatewaySN(bindingVo.getSN(),bindingVo.getType());
devList.add("TDL-"+bindingVo.getTDLSN());
Integer gpsPeriod = null; Integer gpsPeriod = null;
Integer gprsPeriod = null; Integer gprsPeriod = null;
if(bindingVo.getMode() == 2){ if(bindingVo.getMode() == 2){
alarmScene="仓库";
gpsPeriod = 43200; gpsPeriod = 43200;
gprsPeriod= 60; gprsPeriod= 60;
}else{ }else{
alarmScene="运输";
gpsPeriod=5; gpsPeriod=5;
if("17110194".equals(bindingVo.getSN())){
gprsPeriod=7;
}else{
gprsPeriod=15; gprsPeriod=15;
} }
ConfigCMDVo configCMDVo = new ConfigCMDVo("config",gpsPeriod,gprsPeriod,devList,bindingVo.getMode(),System.currentTimeMillis()/1000l); }
//开始绑定
//获取gateway下的所有tdl的编号
List<Float> tempL = new ArrayList<>();
List<Float> tempH = new ArrayList<>();
List<Float> humiL = new ArrayList<>();
List<Float> humiH = new ArrayList<>();
List<Integer> pressL = new ArrayList<>();
List<Integer> pressH = new ArrayList<>();
List<Integer> sugEnergy = new ArrayList<>();
List<Float> accThreshold = new ArrayList<>();
List<Integer> timeThreshold = new ArrayList<>();
List<Integer> tiltThreshold = new ArrayList<>();
ResultAlarmVo alarmVo = alarmService.getByType(bindingVo.getAlarmType(),user.getCompanyNo());
tempL.add(alarmVo.getTemMin());
tempH.add(alarmVo.getTemMax());
humiL.add(alarmVo.getHumidityMin());
humiH.add(alarmVo.getHumidityMax());
pressL.add(255);
pressH.add(255);
sugEnergy.add(1);
accThreshold.add(Float.valueOf(alarmVo.getShock()));
timeThreshold.add(5);
tiltThreshold.add((int)Double.parseDouble(alarmVo.getTilt().toString()));
List<String> devList = tdlDeviceService.getByGatewaySN(bindingVo.getSN(),bindingVo.getType());
devList.add("TDL-"+bindingVo.getTDLSN());
ConfigCMDVo configCMDVo = new ConfigCMDVo("config",gpsPeriod,gprsPeriod,devList,tempL,tempH,humiL,humiH,pressL,pressH,sugEnergy,accThreshold,timeThreshold,tiltThreshold,bindingVo.getMode(),System.currentTimeMillis()/1000l);
Map<Object,Object> map=new HashMap<>(); Map<Object,Object> map=new HashMap<>();
map.put("companyName",user.getCompanyName()); map.put("companyName",user.getCompanyName());
map.put("transportationNo",bindingVo.getTransportationNo()); map.put("transportationNo",bindingVo.getTransportationNo());
...@@ -167,8 +191,10 @@ public class EquipmentBindingController { ...@@ -167,8 +191,10 @@ public class EquipmentBindingController {
Map<Object,Object> msg=new HashMap<>(); Map<Object,Object> msg=new HashMap<>();
msg.put("msg",map.get("msg")); msg.put("msg",map.get("msg"));
if (msg.get("msg").equals("配置网关成功")){ if (msg.get("msg").equals("配置网关成功")){
fb.setCode(1);
fb.setMessage("配置网关成功");
//根据报警类型货报警信息 //根据报警类型货报警信息
ResultAlarmVo alarmVo = alarmService.getByType(bindingVo.getAlarmType(),user.getCompanyName());
for(String alias :list){ for(String alias :list){
List<AlarmRuleVo> alarmRuleVos = new ArrayList<>(); List<AlarmRuleVo> alarmRuleVos = new ArrayList<>();
AlarmRuleVo alarmRuleVo = new AlarmRuleVo(); AlarmRuleVo alarmRuleVo = new AlarmRuleVo();
...@@ -194,8 +220,6 @@ public class EquipmentBindingController { ...@@ -194,8 +220,6 @@ public class EquipmentBindingController {
alarmRuleVos.add(alarmRuleVo); alarmRuleVos.add(alarmRuleVo);
//向redis中写入报警信息 //向redis中写入报警信息
alarmRedisService.hmSet("TDL/"+bindingVo.getType()+"/" +bindingVo.getSN()+"/Data","TDL-" +bindingVo.getTDLSN()+"_" +alias,gson.toJson(alarmRuleVos)); alarmRedisService.hmSet("TDL/"+bindingVo.getType()+"/" +bindingVo.getSN()+"/Data","TDL-" +bindingVo.getTDLSN()+"_" +alias,gson.toJson(alarmRuleVos));
fb.setCode(1);
fb.setMessage("配置网关成功");
} }
}else{ }else{
fb.setCode(0); fb.setCode(0);
...@@ -206,7 +230,7 @@ public class EquipmentBindingController { ...@@ -206,7 +230,7 @@ public class EquipmentBindingController {
@ApiOperation(value = "解绑tdl",notes = "解绑tdl") @ApiOperation(value = "重置tdl",notes = "重置tdl")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"), @ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
}) })
...@@ -226,7 +250,7 @@ public class EquipmentBindingController { ...@@ -226,7 +250,7 @@ public class EquipmentBindingController {
ConfigCMDVo config = gson.fromJson(configVo.getMessage(),ConfigCMDVo.class); ConfigCMDVo config = gson.fromJson(configVo.getMessage(),ConfigCMDVo.class);
ConfigCMDVo configCMDVo ; ConfigCMDVo configCMDVo ;
if(devList.size()>1){ if(devList.size()>1){
devList.remove(TDLSN); devList.remove("TDL-"+TDLSN);
configCMDVo = new ConfigCMDVo("config",config.getGpsPeriod(),config.getGprsPeriod(),devList,config.getMode(),System.currentTimeMillis()/1000l); configCMDVo = new ConfigCMDVo("config",config.getGpsPeriod(),config.getGprsPeriod(),devList,config.getMode(),System.currentTimeMillis()/1000l);
}else{ }else{
configCMDVo = new ConfigCMDVo(); configCMDVo = new ConfigCMDVo();
...@@ -248,13 +272,12 @@ public class EquipmentBindingController { ...@@ -248,13 +272,12 @@ public class EquipmentBindingController {
alarmRedisService.delKey(key); alarmRedisService.delKey(key);
}else{ }else{
fb.setCode(0); fb.setCode(0);
fb.setMessage("解除tdl失败"); fb.setMessage(msg.get("msg").toString());
} }
return gson.toJson(fb); return gson.toJson(fb);
} }
@ApiOperation(value = "解绑网关",notes = "解绑网关") @ApiOperation(value = "解绑网关",notes = "解绑网关")
@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"),
......
...@@ -18,6 +18,7 @@ import org.apache.commons.lang3.StringUtils; ...@@ -18,6 +18,7 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -61,6 +62,12 @@ public class GatewayController { ...@@ -61,6 +62,12 @@ public class GatewayController {
@Autowired @Autowired
private I18nController i18n; private I18nController i18n;
@Value("${tdl.core.add}")
private String addmount;
@Value("${tdl.core.delete}")
private String delmount;
//查询所有网关信息 //查询所有网关信息
@ApiOperation(value = "查询所有网关信息",notes = "查询所有网关信息:" + @ApiOperation(value = "查询所有网关信息",notes = "查询所有网关信息:" +
...@@ -230,11 +237,17 @@ public class GatewayController { ...@@ -230,11 +237,17 @@ public class GatewayController {
fb.setMessage(i18n.getMessage(request,"gatewayType")); fb.setMessage(i18n.getMessage(request,"gatewayType"));
return gson.toJson(fb); return gson.toJson(fb);
} }
if (gatewayService.getBySNAndType(delGatewayVo.getSN(),delGatewayVo.getType())==null){ ResultGatewayVo resultGatewayVo = gatewayService.getBySNAndType(delGatewayVo.getSN(),delGatewayVo.getType());
if (resultGatewayVo==null){
fb.setCode(0); fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"existGateway")); fb.setMessage(i18n.getMessage(request,"existGateway"));
return gson.toJson(fb); return gson.toJson(fb);
} }
if(resultGatewayVo.getUseScene()!=0){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"beingUsed"));
return gson.toJson(fb);
}
Map<Object,Object> map=new HashMap<>(); Map<Object,Object> map=new HashMap<>();
map.put("SN",delGatewayVo.getSN()); map.put("SN",delGatewayVo.getSN());
map.put("type",delGatewayVo.getType()); map.put("type",delGatewayVo.getType());
...@@ -281,10 +294,10 @@ public class GatewayController { ...@@ -281,10 +294,10 @@ public class GatewayController {
return gson.toJson(fb); return gson.toJson(fb);
} }
//根据SN,type获取设备状态 //根据SN,type获取设备状态
boolean state = gatewayService.getBySNAndType(deployProbesVo.getSN(),deployProbesVo.getType()).getState(); ResultGatewayVo resultGatewayVo = gatewayService.getBySNAndType(deployProbesVo.getSN(),deployProbesVo.getType());
if(state){ if(resultGatewayVo.getState()){
fb.setCode(0); fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"isUseing")); fb.setMessage(i18n.getMessage(request,"isState"));
return gson.toJson(fb); return gson.toJson(fb);
} }
Map<Object,Object> map=new HashMap<>(); Map<Object,Object> map=new HashMap<>();
...@@ -304,6 +317,7 @@ public class GatewayController { ...@@ -304,6 +317,7 @@ public class GatewayController {
return gson.toJson(fb); return gson.toJson(fb);
} }
//挂载设备 //挂载设备
@ApiOperation(value = "设备挂载/xie",notes = "使用通道模板配置通道" + @ApiOperation(value = "设备挂载/xie",notes = "使用通道模板配置通道" +
" SN:设备编号" + " SN:设备编号" +
...@@ -370,11 +384,11 @@ public class GatewayController { ...@@ -370,11 +384,11 @@ public class GatewayController {
infoRedisService.hmSet("PubTopic", device.getType() + "_" + device.getSN(), pubList.toString()); infoRedisService.hmSet("PubTopic", device.getType() + "_" + device.getSN(), pubList.toString());
if (device.getState() == 0) { if (device.getState() == 0) {
//挂载 //挂载
String sr = HttpRequester.sendPost("http://192.168.1.16:8079/witium/addMount", gson.toJson(new GatewaySNAndTypeVo(device.getSN(), device.getType()))); String sr = HttpRequester.sendPost(addmount, gson.toJson(new GatewaySNAndTypeVo(device.getSN(), device.getType())));
device.setState(1); device.setState(1);
} else if (device.getState() == 1) { } else if (device.getState() == 1) {
//卸载 //卸载
String sr = HttpRequester.sendPost("http://192.168.1.16:8079/witium/delMount", gson.toJson(new GatewaySNAndTypeVo(device.getSN(), device.getType()))); String sr = HttpRequester.sendPost(delmount, gson.toJson(new GatewaySNAndTypeVo(device.getSN(), device.getType())));
device.setState(0); device.setState(0);
infoRedisService.delHashKey("DeviceConfig", device.getType() + "_" + device.getSN()); infoRedisService.delHashKey("DeviceConfig", device.getType() + "_" + device.getSN());
infoRedisService.delHashKey("SubTopic", device.getType() + "_" + device.getSN()); infoRedisService.delHashKey("SubTopic", device.getType() + "_" + device.getSN());
...@@ -396,7 +410,6 @@ public class GatewayController { ...@@ -396,7 +410,6 @@ public class GatewayController {
return gson.toJson(fb); return gson.toJson(fb);
} }
//获取未使用的网关 //获取未使用的网关
@ApiOperation(value = "获取未使用的网关",notes = "获取未使用的网关,传值说明:" + @ApiOperation(value = "获取未使用的网关",notes = "获取未使用的网关,传值说明:" +
" gSN:需要查询的网关序列号") " gSN:需要查询的网关序列号")
......
...@@ -105,13 +105,13 @@ public class HomePageController { ...@@ -105,13 +105,13 @@ public class HomePageController {
//获取所有的线路数量 //获取所有的线路数量
dataVo.setSum(circuitService.getCount(time,System.currentTimeMillis()/1000l,user.getCompanyName()));//总数量 dataVo.setSum(circuitService.getCount(time,System.currentTimeMillis()/1000l,user.getCompanyName()));//总数量
//获取近几天的线路信息 //获取近几天的线路信息
dataVo.setOnRoute(circuitService.getOnRoute(user.getCompanyName()));//在途数量 dataVo.setOnRoute(circuitService.getOnRoute(user.getCompanyNo()));//在途数量
Integer delay = circuitService.getDelayCount(System.currentTimeMillis(),time,user.getCompanyName()); Integer delay = circuitService.getDelayCount(System.currentTimeMillis(),time,user.getCompanyName());
dataVo.setDelay(delay);//延误数量 dataVo.setDelay(delay);//延误数量
dataVo.setAlarmed( alarmLogServcie.getCount(time,user.getCompanyName()));//报警数量 dataVo.setAlarmed( alarmLogServcie.getCount(time,user.getCompanyNo()));//报警数量
dataVo.setBump(alarmLogServcie.getBumpCount(time,user.getCompanyName())); //获取颠簸数量 dataVo.setBump(alarmLogServcie.getBumpCount(time,user.getCompanyNo())); //获取颠簸数量
dataVo.setAlarmLogVoList(alarmLogServcie.getAlarmLog(time,user.getCompanyName()));//报警列表 dataVo.setAlarmLogVoList(alarmLogServcie.getAlarmLog(time,user.getCompanyNo()));//报警列表
List<HistogramData> list = alarmLogServcie.getByCount(time,user.getCompanyName());//获取报警柱状图 List<HistogramData> list = alarmLogServcie.getByCount(time,user.getCompanyNo());//获取报警柱状图
for(int j = 0,length = list.size();j<length;j++){ for(int j = 0,length = list.size();j<length;j++){
if(list.get(j).getClassify().equals("5")){ if(list.get(j).getClassify().equals("5")){
Integer count = list.get(j).getCount() +delay; Integer count = list.get(j).getCount() +delay;
...@@ -119,7 +119,7 @@ public class HomePageController { ...@@ -119,7 +119,7 @@ public class HomePageController {
} }
} }
//获取设备的当前位置 //获取设备的当前位置
List<ResultCircuitVo> circuitVos = circuitService.getByTime(user.getCompanyName()); List<ResultCircuitVo> circuitVos = circuitService.getByTime(user.getCompanyNo());
List<CircuitVo> circuitList = new ArrayList<>(); List<CircuitVo> circuitList = new ArrayList<>();
Integer num = 0; Integer num = 0;
for(int i = 0;i<circuitVos.size();i++){ for(int i = 0;i<circuitVos.size();i++){
...@@ -185,9 +185,9 @@ public class HomePageController { ...@@ -185,9 +185,9 @@ public class HomePageController {
String datum = tokenRedisService.get("TOKEN_" +token); String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class); UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
AlarmDataVo alarmDataVo = new AlarmDataVo(); AlarmDataVo alarmDataVo = new AlarmDataVo();
alarmDataVo.setOnRoute(circuitService.getOnRoute(user.getCompanyName())); alarmDataVo.setOnRoute(circuitService.getOnRoute(user.getCompanyNo()));
alarmDataVo.setAlarmed(alarmLogServcie.getAlarmCount(user.getCompanyName())); alarmDataVo.setAlarmed(alarmLogServcie.getAlarmCount(user.getCompanyNo()));
alarmDataVo.setDelay(circuitService.getDelay(System.currentTimeMillis(),user.getCompanyName())); alarmDataVo.setDelay(circuitService.getDelay(System.currentTimeMillis(),user.getCompanyNo()));
return gson.toJson(alarmDataVo); return gson.toJson(alarmDataVo);
} }
......
...@@ -8,7 +8,7 @@ import com.example.tdl.entity.LoginLog; ...@@ -8,7 +8,7 @@ import com.example.tdl.entity.LoginLog;
import com.example.tdl.service.LoginLogService; import com.example.tdl.service.LoginLogService;
import com.example.tdl.service.UserService; import com.example.tdl.service.UserService;
import com.example.tdl.service.redis.TokenRedisService; import com.example.tdl.service.redis.TokenRedisService;
import com.example.tdl.util.CookieUtils; import com.example.tdl.service.redis.UserTokenRedisService;
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;
...@@ -43,6 +43,9 @@ public class LoginController { ...@@ -43,6 +43,9 @@ public class LoginController {
@Autowired @Autowired
private TokenRedisService tokenRedisService; private TokenRedisService tokenRedisService;
@Autowired
private UserTokenRedisService userTokenService;
@Autowired @Autowired
private LoginLogService loginLogService; private LoginLogService loginLogService;
...@@ -75,9 +78,10 @@ public class LoginController { ...@@ -75,9 +78,10 @@ public class LoginController {
SecurityUtils.getSubject().login(new UsernamePasswordToken(loginUserVo.getUserName(), loginUserVo.getPassword())); SecurityUtils.getSubject().login(new UsernamePasswordToken(loginUserVo.getUserName(), loginUserVo.getPassword()));
//生成token //生成token
String token = DigestUtils.md5Hex(System.currentTimeMillis() + userVo.getUserName()); String token = DigestUtils.md5Hex(System.currentTimeMillis() + userVo.getUserName());
UserRedisVo redisVo = new UserRedisVo(userVo.getUserName(),userVo.getUserNumber(),userVo.getNickName(),userVo.getEmail(),userVo.getPhone(),userVo.getRoleName(),userVo.getCompanyNo(),userVo.getCompanyName()); UserRedisVo redisVo = new UserRedisVo(userVo.getUserName(),userVo.getUserNumber(),userVo.getNickName(),userVo.getEmail(),userVo.getPhone(),userVo.getRoleName(),userVo.getCompanyName(),userVo.getCompanyNo());
//将用户数据保存到redis中 //将用户数据保存到redis中
tokenRedisService.set("TOKEN_" + token, gson.toJson(redisVo), 60 * 60 *24); userTokenService.hmSet(userVo.getUserNumber(),"TOKEN_" + token,System.currentTimeMillis()+"");
tokenRedisService.set("TOKEN_" + token, gson.toJson(redisVo), 60 * 30);
String ip = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest().getRemoteAddr(); String ip = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest().getRemoteAddr();
int a=loginLogService.addLoginLog(new LoginLog(loginUserVo.getUserName(),System.currentTimeMillis(),ip)); int a=loginLogService.addLoginLog(new LoginLog(loginUserVo.getUserName(),System.currentTimeMillis(),ip));
if (a>0){ if (a>0){
......
...@@ -66,7 +66,7 @@ public class PermissionController { ...@@ -66,7 +66,7 @@ public class PermissionController {
String datum = tokenRedisService.get("TOKEN_" +token); String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class); UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
//获取该公司的所有权限 //获取该公司的所有权限
String name = "管理员"; String name = "系统管理员";
List<String> permissionLists = roleHasPermissionService.getByRoleName(name); List<String> permissionLists = roleHasPermissionService.getByRoleName(name);
List<String> parentLists =permissionService.getPermissionParentName(); List<String> parentLists =permissionService.getPermissionParentName();
List<PermissionGroupVo> vo =new ArrayList<>(); List<PermissionGroupVo> vo =new ArrayList<>();
...@@ -102,16 +102,15 @@ public class PermissionController { ...@@ -102,16 +102,15 @@ public class PermissionController {
String token = request.getHeader("Account_token"); String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token); String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class); UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
JSONObject json = JSON.parseObject(roleName); if (StringUtils.isEmpty(roleName)){
roleName= (String) json.get("roleName");
if (roleName.equals("")||roleName==null){
fb.setCode(0); fb.setCode(0);
fb.setMessage("查询的角色名不能为空"); fb.setMessage("查询的角色名不能为空");
return gson.toJson(fb); return gson.toJson(fb);
} }
JSONObject json = JSON.parseObject(roleName);
roleName= (String) json.get("roleName");
//获取该公司的所有权限 //获取该公司的所有权限
String name = "管理员"; String name = "系统管理员";
List<String> permissionLists = roleHasPermissionService.getByRoleName(name); List<String> permissionLists = roleHasPermissionService.getByRoleName(name);
List<String> parentLists =permissionService.getPermissionParentName(); List<String> parentLists =permissionService.getPermissionParentName();
//根据角色名获取拥有的角色 //根据角色名获取拥有的角色
...@@ -160,7 +159,6 @@ public class PermissionController { ...@@ -160,7 +159,6 @@ public class PermissionController {
return gson.toJson(fb); return gson.toJson(fb);
} }
String permissionVar=""; String permissionVar="";
int num = 0;
for(int i=0;i<addOrUpdatePermissionVo.getPermissionGroupVos().size();i++){ for(int i=0;i<addOrUpdatePermissionVo.getPermissionGroupVos().size();i++){
permissionVar+=addOrUpdatePermissionVo.getPermissionGroupVos().get(i)+" "; permissionVar+=addOrUpdatePermissionVo.getPermissionGroupVos().get(i)+" ";
} }
...@@ -181,6 +179,8 @@ public class PermissionController { ...@@ -181,6 +179,8 @@ public class PermissionController {
fb.setMessage(ms.get("msg").toString()); fb.setMessage(ms.get("msg").toString());
} }
} catch (DataAccessException e) { } catch (DataAccessException e) {
e.printStackTrace();
logger.info(e.toString());
fb.setCode(0); fb.setCode(0);
fb.setMessage("操作失败"); fb.setMessage("操作失败");
} }
......
...@@ -48,6 +48,7 @@ public class PicUploadController { ...@@ -48,6 +48,7 @@ public class PicUploadController {
// 允许上传的格式 // 允许上传的格式
private static final String[] IMAGE_TYPE = new String[]{".jpg",".png" }; private static final String[] IMAGE_TYPE = new String[]{".jpg",".png" };
//上传图片 //上传图片
@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"),
...@@ -59,9 +60,9 @@ public class PicUploadController { ...@@ -59,9 +60,9 @@ public class PicUploadController {
fb.setMessage("图片不能为空"); fb.setMessage("图片不能为空");
return gson.toJson(fb); return gson.toJson(fb);
} }
if (multipartFile.getSize() > 5 * 1024 * 1024) { if (multipartFile.getSize() > 512000) {
fb.setCode(0); fb.setCode(0);
fb.setMessage("上传图片大小不能超过5M!"); fb.setMessage("上传图片大小不能超过500K!");
return gson.toJson(fb); return gson.toJson(fb);
} }
try { try {
...@@ -70,24 +71,40 @@ public class PicUploadController { ...@@ -70,24 +71,40 @@ public class PicUploadController {
if(sourceImg == null){ if(sourceImg == null){
fb.setCode(0); fb.setCode(0);
fb.setMessage("上传图片格式不正确"); fb.setMessage("上传图片格式不正确");
return gson.toJson(fb);
}else{ }else{
if("truck".equals(imageType)){ if("truck".equals(imageType)){
if(sourceImg.getHeight()>90){ if(sourceImg.getHeight()>90){
fb.setCode(0); fb.setCode(0);
fb.setMessage("上传图片尺寸不正确"); fb.setMessage("上传图片尺寸不正确");
return gson.toJson(fb);
} }
if(sourceImg.getWidth()>60){ if(sourceImg.getWidth()>60){
fb.setCode(0); fb.setCode(0);
fb.setMessage("上传图片尺寸不正确"); fb.setMessage("上传图片尺寸不正确");
return gson.toJson(fb);
} }
}else if("warehouse".equals(imageType)){ }else if("warehouse".equals(imageType)){
if(sourceImg.getHeight()>150){ if(sourceImg.getHeight()>150){
fb.setCode(0); fb.setCode(0);
fb.setMessage("上传图片尺寸不正确"); fb.setMessage("上传图片尺寸不正确");
return gson.toJson(fb);
} }
if(sourceImg.getWidth()>120){ if(sourceImg.getWidth()>120){
fb.setCode(0); fb.setCode(0);
fb.setMessage("上传图片尺寸不正确"); fb.setMessage("上传图片尺寸不正确");
return gson.toJson(fb);
}
}else if("company".equals(imageType)){
if(sourceImg.getHeight()>24){
fb.setCode(0);
fb.setMessage("上传图片尺寸不正确");
return gson.toJson(fb);
}
if(sourceImg.getWidth()>24){
fb.setCode(0);
fb.setMessage("上传图片尺寸不正确");
return gson.toJson(fb);
} }
} }
} }
...@@ -95,6 +112,7 @@ public class PicUploadController { ...@@ -95,6 +112,7 @@ public class PicUploadController {
e.printStackTrace(); e.printStackTrace();
fb.setCode(0); fb.setCode(0);
fb.setMessage("上传图片格式不正确"); fb.setMessage("上传图片格式不正确");
return gson.toJson(fb);
} }
// 校验图片格式 // 校验图片格式
boolean isLegal = false; boolean isLegal = false;
...@@ -154,9 +172,9 @@ public class PicUploadController { ...@@ -154,9 +172,9 @@ public class PicUploadController {
fb.setMessage("图片不能为空"); fb.setMessage("图片不能为空");
return gson.toJson(fb); return gson.toJson(fb);
} }
if (multipartFile.getSize() > 5 * 1024 * 1024) { if (multipartFile.getSize() > 512000) {
fb.setCode(0); fb.setCode(0);
fb.setMessage("上传图片大小不能超过5M!"); fb.setMessage("上传图片大小不能超过500K!");
return gson.toJson(fb); return gson.toJson(fb);
} }
try { try {
...@@ -165,25 +183,40 @@ public class PicUploadController { ...@@ -165,25 +183,40 @@ public class PicUploadController {
if(sourceImg == null){ if(sourceImg == null){
fb.setCode(0); fb.setCode(0);
fb.setMessage("上传图片格式不正确"); fb.setMessage("上传图片格式不正确");
}else{ return gson.toJson(fb);
}
if("truck".equals(imageType)){ if("truck".equals(imageType)){
if(sourceImg.getHeight()>90){ if(sourceImg.getHeight()>90){
fb.setCode(0); fb.setCode(0);
fb.setMessage("上传图片尺寸不正确"); fb.setMessage("上传图片尺寸不正确");
return gson.toJson(fb);
} }
if(sourceImg.getWidth()>60){ if(sourceImg.getWidth()>60){
fb.setCode(0); fb.setCode(0);
fb.setMessage("上传图片尺寸不正确"); fb.setMessage("上传图片尺寸不正确");
return gson.toJson(fb);
} }
}else if("warehouse".equals(imageType)){ }else if("warehouse".equals(imageType)){
if(sourceImg.getHeight()>150){ if(sourceImg.getHeight()>150){
fb.setCode(0); fb.setCode(0);
fb.setMessage("上传图片尺寸不正确"); fb.setMessage("上传图片尺寸不正确");
return gson.toJson(fb);
} }
if(sourceImg.getWidth()>120){ if(sourceImg.getWidth()>120){
fb.setCode(0); fb.setCode(0);
fb.setMessage("上传图片尺寸不正确"); fb.setMessage("上传图片尺寸不正确");
return gson.toJson(fb);
} }
}else if("company".equals(imageType)){
if(sourceImg.getHeight()>24){
fb.setCode(0);
fb.setMessage("上传图片尺寸不正确");
return gson.toJson(fb);
}
if(sourceImg.getWidth()>24){
fb.setCode(0);
fb.setMessage("上传图片尺寸不正确");
return gson.toJson(fb);
} }
} }
} catch (IOException e) { } catch (IOException e) {
...@@ -212,13 +245,12 @@ public class PicUploadController { ...@@ -212,13 +245,12 @@ public class PicUploadController {
String img = "https://tdlcloud.oss-cn-shanghai.aliyuncs.com/pic/"; String img = "https://tdlcloud.oss-cn-shanghai.aliyuncs.com/pic/";
int i = 0; int i = 0;
if("user".equals(imageType)){ if("user".equals(imageType)){
img = img +"userImage/" +url;
//修改用户图片 //修改用户图片
// i = userService.updateImg(number,img); // i = userService.updateImg(number,img);
img = img +"userImage/" +url;
}else if("company".equals(imageType)){ }else if("company".equals(imageType)){
i = companyService.updateImg(number,img);
img = img +"companyLog/" +url; img = img +"companyLog/" +url;
fb.setMessage("https://tdlcloud.oss-cn-shanghai.aliyuncs.com/pic/companyLog/" + url); i = companyService.updateImg(img,number);
}else if("truck".equals(imageType)){ }else if("truck".equals(imageType)){
img = img +"palteImage/" +url; img = img +"palteImage/" +url;
i = carService.updateImg(img,number); i = carService.updateImg(img,number);
......
...@@ -164,6 +164,8 @@ public class TDLDeviceController { ...@@ -164,6 +164,8 @@ public class TDLDeviceController {
return gson.toJson(fb); return gson.toJson(fb);
} }
//删除TDL信息 //删除TDL信息
@ApiOperation(value = "删除TDL信息",notes = "删除TDL信息,传值说明:" + @ApiOperation(value = "删除TDL信息",notes = "删除TDL信息,传值说明:" +
" TDLSN:需要删除的TDL序列号") " TDLSN:需要删除的TDL序列号")
...@@ -197,6 +199,8 @@ public class TDLDeviceController { ...@@ -197,6 +199,8 @@ public class TDLDeviceController {
} }
@ApiOperation(value = "获取未被使用的TDL序列号",notes = "获取未被使用的TDL序列号,传值说明:" + @ApiOperation(value = "获取未被使用的TDL序列号",notes = "获取未被使用的TDL序列号,传值说明:" +
" TDLSN:需要查询的TDL序列号") " TDLSN:需要查询的TDL序列号")
@ApiImplicitParams({ @ApiImplicitParams({
...@@ -217,6 +221,8 @@ public class TDLDeviceController { ...@@ -217,6 +221,8 @@ public class TDLDeviceController {
return tdlDeviceService.getUnusedTDL(TDLSN,user.getCompanyNo()); return tdlDeviceService.getUnusedTDL(TDLSN,user.getCompanyNo());
} }
//分配TDL //分配TDL
@ApiOperation(value = "分配TDL",notes = "分配TDL,传值说明:" + @ApiOperation(value = "分配TDL",notes = "分配TDL,传值说明:" +
" TDLSN:需要分配的网关序列号," + " TDLSN:需要分配的网关序列号," +
......
...@@ -11,6 +11,7 @@ import com.example.tdl.service.RoleService; ...@@ -11,6 +11,7 @@ import com.example.tdl.service.RoleService;
import com.example.tdl.service.UserService; import com.example.tdl.service.UserService;
import com.example.tdl.service.redis.TokenRedisService; import com.example.tdl.service.redis.TokenRedisService;
import com.example.tdl.service.redis.UserTokenRedisService;
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;
...@@ -60,6 +61,9 @@ public class UserController { ...@@ -60,6 +61,9 @@ public class UserController {
@Autowired @Autowired
private I18nController i18n; private I18nController i18n;
@Autowired
private UserTokenRedisService userTokenService;
//获取所有用户信息 //获取所有用户信息
@ApiOperation(value = "获取所有用户信息",notes = "获取所有用户信息:" + @ApiOperation(value = "获取所有用户信息",notes = "获取所有用户信息:" +
...@@ -79,11 +83,7 @@ public class UserController { ...@@ -79,11 +83,7 @@ public class UserController {
String token = request.getHeader("Account_token"); String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token); String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class); UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
if(user.getCompanyName().equals("上海辉度")){ return userService.getAll(user.getCompanyNo());
return userService.getAllUser();
}else{
return userService.getAll(user.getCompanyName());
}
} }
//根据条件查询 //根据条件查询
...@@ -108,11 +108,19 @@ public class UserController { ...@@ -108,11 +108,19 @@ public class UserController {
String token = request.getHeader("Account_token"); String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token); String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class); UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
if(user.getCompanyName().equals("")){ if(StringUtils.isEmpty(userTermVo.getUserName())){
userTermVo.setCompanyName(null); userTermVo.setUserName(null);
}else{ }
userTermVo.setCompanyName(user.getCompanyName()); if(StringUtils.isEmpty(userTermVo.getPhone())){
userTermVo.setPhone(null);
}
if(StringUtils.isEmpty(userTermVo.getEmail())){
userTermVo.setEmail(null);
} }
if(StringUtils.isEmpty(userTermVo.getRoleName())){
userTermVo.setRoleName(null);
}
userTermVo.setCompanyNo(user.getCompanyNo());
return userService.getByTerm(userTermVo); return userService.getByTerm(userTermVo);
} }
...@@ -131,9 +139,7 @@ public class UserController { ...@@ -131,9 +139,7 @@ public class UserController {
}) })
@RequestMapping(value="/addUser",method = RequestMethod.POST) @RequestMapping(value="/addUser",method = RequestMethod.POST)
public Object addUser(@RequestBody AddUserVo userVo,HttpServletRequest request){ public Object addUser(@RequestBody AddUserVo userVo,HttpServletRequest request){
String token = request.getHeader("Account_token"); String port = request.getHeader("AccountLanguage");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
if (StringUtils.isEmpty(userVo.getUserName())){ if (StringUtils.isEmpty(userVo.getUserName())){
fb.setCode(0); fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"userName")); fb.setMessage(i18n.getMessage(request,"userName"));
...@@ -199,7 +205,7 @@ public class UserController { ...@@ -199,7 +205,7 @@ public class UserController {
fb.setMessage(i18n.getMessage(request,"roleName")); fb.setMessage(i18n.getMessage(request,"roleName"));
return gson.toJson(fb); return gson.toJson(fb);
} }
if (roleService.getByRoleName(userVo.getRoleName(),user.getCompanyName())==0){ if (roleService.getByRoleName(userVo.getRoleName(), userVo.getCompanyName())==0){
fb.setCode(0); fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"existRoleName")); fb.setMessage(i18n.getMessage(request,"existRoleName"));
return gson.toJson(fb); return gson.toJson(fb);
...@@ -270,7 +276,7 @@ public class UserController { ...@@ -270,7 +276,7 @@ public class UserController {
fb.setMessage(i18n.getMessage(request,"phoneRule")); fb.setMessage(i18n.getMessage(request,"phoneRule"));
return gson.toJson(fb); return gson.toJson(fb);
} }
if (userInfo!=null&& !userInfo.getPhone().equals(userVo.getPhone()) && userService.getByPhone(user.getPhone(),userInfo.getCompanyName()) !=null){ if (userInfo!=null&& !userInfo.getPhone().equals(userVo.getPhone()) && userService.getByPhone(userVo.getPhone(),userInfo.getCompanyName()) !=null){
fb.setCode(0); fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"repeatedRule")); fb.setMessage(i18n.getMessage(request,"repeatedRule"));
return gson.toJson(fb); return gson.toJson(fb);
...@@ -296,7 +302,7 @@ public class UserController { ...@@ -296,7 +302,7 @@ public class UserController {
return gson.toJson(fb); return gson.toJson(fb);
} }
if (roleService.getByRoleName(userVo.getRoleName(),user.getCompanyName())==0){ if (roleService.getByRoleName(userVo.getRoleName(),userInfo.getCompanyName())==0){
fb.setCode(0); fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"existRoleName")); fb.setMessage(i18n.getMessage(request,"existRoleName"));
return gson.toJson(fb); return gson.toJson(fb);
...@@ -361,6 +367,12 @@ public class UserController { ...@@ -361,6 +367,12 @@ public class UserController {
if (a>0){ if (a>0){
fb.setCode(1); fb.setCode(1);
fb.setMessage(i18n.getMessage(request,"resetPasswordSuccess")); fb.setMessage(i18n.getMessage(request,"resetPasswordSuccess"));
String key = userTokenService.getHashKeys(userNumber).toString();
List<String> keys = gson.fromJson(key,List.class);
for( int i = 0;i<keys.size();i++){
tokenRedisService.delKey(keys.get(i));
}
userTokenService.delKey(userNumber);
}else{ }else{
fb.setCode(0); fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"resetPasswordFailure")); fb.setMessage(i18n.getMessage(request,"resetPasswordFailure"));
...@@ -393,6 +405,12 @@ public class UserController { ...@@ -393,6 +405,12 @@ public class UserController {
if (a>0){ if (a>0){
fb.setCode(1); fb.setCode(1);
fb.setMessage(i18n.getMessage(request,"modifiedPasswordSuccess")); fb.setMessage(i18n.getMessage(request,"modifiedPasswordSuccess"));
String key = userTokenService.getHashKeys(updatePasswordVo.getUserNumber()).toString();
List<String> keys = gson.fromJson(key,List.class);
for( int i = 0;i<keys.size();i++){
tokenRedisService.delKey(keys.get(i));
}
userTokenService.delKey(updatePasswordVo.getUserNumber());
}else{ }else{
fb.setCode(0); fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"modifiedPasswordFailure")); fb.setMessage(i18n.getMessage(request,"modifiedPasswordFailure"));
...@@ -400,6 +418,7 @@ public class UserController { ...@@ -400,6 +418,7 @@ public class UserController {
return gson.toJson(fb); return gson.toJson(fb);
} }
//获取当前的用户名 //获取当前的用户名
@ApiOperation(value = "获取当前用户的信息",notes = "获取用户的信息" + @ApiOperation(value = "获取当前用户的信息",notes = "获取用户的信息" +
"userName:用户名" + "userName:用户名" +
...@@ -421,4 +440,20 @@ public class UserController { ...@@ -421,4 +440,20 @@ public class UserController {
return new UserNameVo(userRedisVo.getUserName(),System.currentTimeMillis() +"",ip,img,companyAlias); return new UserNameVo(userRedisVo.getUserName(),System.currentTimeMillis() +"",ip,img,companyAlias);
} }
//获取本公司的所有用户名
@ApiOperation(value = "获取本公司的所有用户名",notes = "获取用户的信息" )
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
@ApiImplicitParam(paramType="header", name = "AccountLanguage", value = "language", required = false, dataType = "String"),
})
@GetMapping(value="/getAllUserName")
public Object getAllUserName(HttpServletRequest request){
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" + token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
return userService.getAllByCompanyNo(user.getCompanyNo());
}
} }
...@@ -21,11 +21,10 @@ import org.slf4j.Logger; ...@@ -21,11 +21,10 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.influxdb.InfluxDBTemplate; import org.springframework.data.influxdb.InfluxDBTemplate;
import org.springframework.expression.spel.ast.NullLiteral;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.print.attribute.standard.RequestingUserName;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.awt.geom.AffineTransform;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
...@@ -105,7 +104,7 @@ public class WarehouseController { ...@@ -105,7 +104,7 @@ public class WarehouseController {
String token = request.getHeader("Account_token"); String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token); String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo userRedisVo = gson.fromJson(datum,UserRedisVo.class); UserRedisVo userRedisVo = gson.fromJson(datum,UserRedisVo.class);
return warehouseService.getAll(userRedisVo.getCompanyName()); return warehouseService.getAll(userRedisVo.getCompanyNo());
} }
//根据条件查询仓库信息 //根据条件查询仓库信息
...@@ -166,7 +165,7 @@ public class WarehouseController { ...@@ -166,7 +165,7 @@ public class WarehouseController {
if(StringUtils.isEmpty(warehouseTermVo.getWarehouseName())){ if(StringUtils.isEmpty(warehouseTermVo.getWarehouseName())){
warehouseTermVo.setWarehouseName(null); warehouseTermVo.setWarehouseName(null);
} }
warehouseTermVo.setCompanyName(userRedisVo.getCompanyName()); warehouseTermVo.setCompanyNo(userRedisVo.getCompanyNo());
return warehouseService.getAllByTerm(warehouseTermVo); return warehouseService.getAllByTerm(warehouseTermVo);
} }
...@@ -191,19 +190,13 @@ public class WarehouseController { ...@@ -191,19 +190,13 @@ public class WarehouseController {
String token = request.getHeader("Account_token"); String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token); String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo userRedisVo = gson.fromJson(datum,UserRedisVo.class); UserRedisVo userRedisVo = gson.fromJson(datum,UserRedisVo.class);
warehouseTermVo.setCompanyName(userRedisVo.getCompanyName()); warehouseTermVo.setCompanyNo(userRedisVo.getCompanyNo());
if(StringUtils.isEmpty(warehouseTermVo.getCity())){ if(StringUtils.isEmpty(warehouseTermVo.getCity())){
warehouseTermVo.setCity(null); warehouseTermVo.setCity(null);
} }
if(StringUtils.isEmpty(warehouseTermVo.getCompanyName())){
warehouseTermVo.setCompanyName(null);
}
if(StringUtils.isEmpty(warehouseTermVo.getCountry())){ if(StringUtils.isEmpty(warehouseTermVo.getCountry())){
warehouseTermVo.setCountry(null); warehouseTermVo.setCountry(null);
} }
if(StringUtils.isEmpty(warehouseTermVo.getgSN())){
warehouseTermVo.setgSN(null);
}
List<SimpleWarehouseVo> simpleWarehouseVos = warehouseService.getByWarehouse(warehouseTermVo); List<SimpleWarehouseVo> simpleWarehouseVos = warehouseService.getByWarehouse(warehouseTermVo);
for( int i = 0,length= simpleWarehouseVos.size();i<length;i++ ){ for( int i = 0,length= simpleWarehouseVos.size();i<length;i++ ){
//判断是否已经绑定设备 //判断是否已经绑定设备
...@@ -220,16 +213,15 @@ public class WarehouseController { ...@@ -220,16 +213,15 @@ public class WarehouseController {
} }
String sql = ""; String sql = "";
for(int j = 0,len=list.size();j<len;j++){ for(int j = 0,len=list.size();j<len;j++){
if( StringUtils.isEmpty(list.get(i).getTdl())){ if( StringUtils.isEmpty(list.get(j).getTdl())){
simpleWarehouseVos.get(i).setTemp("~"); simpleWarehouseVos.get(i).setTemp("~");
simpleWarehouseVos.get(i).setHumidity("~"); simpleWarehouseVos.get(i).setHumidity("~");
continue; continue;
} }
Long time = (System.currentTimeMillis()-10*60*1000)*1000000l; Long time = (System.currentTimeMillis()-10*60*1000)*1000000l;
String tdl = list.get(i).getTdl(); String tdl = list.get(j).getTdl().replace(",","\' or \"tdl\" = \'");
String t = tdl.replace(",","\' or \"tdl\" = \'");
// sql = "SELECT \"T\",\"h\" FROM \"tdl_policy\".\"WTD93LG_17110194\" where \"tdl\" = \'TDL-1706190193608\' or \"tdl\" = \'TDL-1701110082608\' GROUP BY \"tdl\" order by time desc limit 1"; // sql = "SELECT \"T\",\"h\" FROM \"tdl_policy\".\"WTD93LG_17110194\" where \"tdl\" = \'TDL-1706190193608\' or \"tdl\" = \'TDL-1701110082608\' GROUP BY \"tdl\" order by time desc limit 1";
sql = "SELECT \"T\",\"h\" FROM \"tdl_policy\".\""+list.get(i).getDevice()+"\" where \"tdl\" = \'"+ t +"\' GROUP BY \"tdl\" order by time desc limit 1"; sql = "SELECT \"T\",\"h\" FROM \"tdl_policy\".\""+list.get(j).getDevice()+"\" where \"tdl\" = \'"+ tdl +"\' GROUP BY \"tdl\" order by time desc limit 1";
} }
if(StringUtils.isEmpty(sql)){ if(StringUtils.isEmpty(sql)){
simpleWarehouseVos.get(i).setTemp("~"); simpleWarehouseVos.get(i).setTemp("~");
...@@ -396,12 +388,9 @@ public class WarehouseController { ...@@ -396,12 +388,9 @@ public class WarehouseController {
} }
//获取某个仓库的网关 //获取某个仓库的网关
@ApiOperation(value="获取某个仓库的网关",notes = "获取某个仓库的网关,传值:warehouseNo:仓库编号," + @ApiOperation(value="添加网关",notes = "添加网关,传值:" +
" 返回值:[" + "warehouseNo:仓库编号" +
" {" + "SN:网关编号")
" sn: 网关编号" +
" }" +
" ]")
@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"),
}) })
...@@ -428,6 +417,7 @@ public class WarehouseController { ...@@ -428,6 +417,7 @@ public class WarehouseController {
//添加仓库信息 //添加仓库信息
@ApiOperation(value = "添加仓库信息",notes = "添加仓库信息,传值说明:" + @ApiOperation(value = "添加仓库信息",notes = "添加仓库信息,传值说明:" +
" img:图片地址" +
" warehouseName:仓库名," + " warehouseName:仓库名," +
" country:国家," + " country:国家," +
" city:市," + " city:市," +
...@@ -435,7 +425,6 @@ public class WarehouseController { ...@@ -435,7 +425,6 @@ public class WarehouseController {
" regionName:区域名," + " regionName:区域名," +
" property:属性," + " property:属性," +
" type:类型," + " type:类型," +
" alarmType:预警类型," +
" hardwareLevel:硬件等级," + " hardwareLevel:硬件等级," +
" areaIndoor:室内平面面积," + " areaIndoor:室内平面面积," +
" areaRack:货架面积," + " areaRack:货架面积," +
...@@ -528,8 +517,8 @@ public class WarehouseController { ...@@ -528,8 +517,8 @@ public class WarehouseController {
fb.setMessage(i18n.getMessage(request,"hardwareLevel")); fb.setMessage(i18n.getMessage(request,"hardwareLevel"));
return gson.toJson(fb); return gson.toJson(fb);
} }
if (!addWarehouseVo.getHardwareLevel().equals("好")&&!addWarehouseVo.getHardwareLevel().equals("一般")&& if (!addWarehouseVo.getHardwareLevel().equals("优")&&!addWarehouseVo.getHardwareLevel().equals("良")&&
!addWarehouseVo.getHardwareLevel().equals("较差")&&!addWarehouseVo.getHardwareLevel().equals("极差")){ !addWarehouseVo.getHardwareLevel().equals("中")&&!addWarehouseVo.getHardwareLevel().equals("差")){
fb.setCode(0); fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"wrongHardwareLevel")); fb.setMessage(i18n.getMessage(request,"wrongHardwareLevel"));
return gson.toJson(fb); return gson.toJson(fb);
...@@ -559,12 +548,12 @@ public class WarehouseController { ...@@ -559,12 +548,12 @@ public class WarehouseController {
fb.setMessage(i18n.getMessage(request,"office")); fb.setMessage(i18n.getMessage(request,"office"));
return gson.toJson(fb); return gson.toJson(fb);
} }
if (addWarehouseVo.getTimeZone()==null){ if (StringUtils.isEmpty(addWarehouseVo.getTimeZone())){
fb.setCode(0); fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"timeZone")); fb.setMessage(i18n.getMessage(request,"timeZone"));
return gson.toJson(fb); return gson.toJson(fb);
} }
if (warehouseService.getByWarehouseName(addWarehouseVo.getWarehouseName(),user.getCompanyName())!=null){ if (warehouseService.getByWarehouseName(addWarehouseVo.getWarehouseName(),user.getCompanyNo())!=null){
fb.setCode(0); fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"repeateWarehouseName")); fb.setMessage(i18n.getMessage(request,"repeateWarehouseName"));
return gson.toJson(fb); return gson.toJson(fb);
...@@ -609,20 +598,13 @@ public class WarehouseController { ...@@ -609,20 +598,13 @@ public class WarehouseController {
//根据仓库编号修改仓库信息 //根据仓库编号修改仓库信息
@ApiOperation(value = "根据仓库编号修改仓库信息",notes = "根据仓库编号修改仓库信息,updatTime不用传,传值说明:" + @ApiOperation(value = "根据仓库编号修改仓库信息",notes = "根据仓库编号修改仓库信息,updatTime不用传,传值说明:" +
" warehouseNo:需要修改的仓库编号," +
" warehouseName:仓库名," + " warehouseName:仓库名," +
" country:国家," + " country:国家," +
" province:省," +
" city:市," + " city:市," +
" district:区," + " addressDetail:具体地址," +
" address:具体地址," + " regionName:区域名," +
" regionCN:区域中文," +
" regionEN:区域英文," +
" longitude:经度," +
" latitude:纬度," +
" property:属性," + " property:属性," +
" type:类型," + " type:类型," +
" alarmType:预警类型," +
" hardwareLevel:硬件等级," + " hardwareLevel:硬件等级," +
" areaIndoor:室内平面面积," + " areaIndoor:室内平面面积," +
" areaRack:货架面积," + " areaRack:货架面积," +
...@@ -630,7 +612,6 @@ public class WarehouseController { ...@@ -630,7 +612,6 @@ public class WarehouseController {
" areaPlanIndoor:实际室内总面积," + " areaPlanIndoor:实际室内总面积," +
" office:办事处," + " office:办事处," +
" timeZone:时区," + " timeZone:时区," +
" weatherInfo:区域气象信息," +
" warehouseInfo:基础描述," + " warehouseInfo:基础描述," +
" remark:备注") " remark:备注")
@ApiImplicitParams({ @ApiImplicitParams({
...@@ -718,8 +699,8 @@ public class WarehouseController { ...@@ -718,8 +699,8 @@ public class WarehouseController {
fb.setMessage(i18n.getMessage(request,"hardwareLevel")); fb.setMessage(i18n.getMessage(request,"hardwareLevel"));
return gson.toJson(fb); return gson.toJson(fb);
} }
if (!updateWarehouseVo.getHardwareLevel().equals("好")&&!updateWarehouseVo.getHardwareLevel().equals("一般")&& if (!updateWarehouseVo.getHardwareLevel().equals("优")&&!updateWarehouseVo.getHardwareLevel().equals("良")&&
!updateWarehouseVo.getHardwareLevel().equals("较差")&&!updateWarehouseVo.getHardwareLevel().equals("极差")){ !updateWarehouseVo.getHardwareLevel().equals("中")&&!updateWarehouseVo.getHardwareLevel().equals("差")){
fb.setCode(0); fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"wrongHardwareLevel")); fb.setMessage(i18n.getMessage(request,"wrongHardwareLevel"));
return gson.toJson(fb); return gson.toJson(fb);
...@@ -749,12 +730,12 @@ public class WarehouseController { ...@@ -749,12 +730,12 @@ public class WarehouseController {
fb.setMessage(i18n.getMessage(request,"office")); fb.setMessage(i18n.getMessage(request,"office"));
return gson.toJson(fb); return gson.toJson(fb);
} }
if (updateWarehouseVo.getTimeZone()== null){ if (StringUtils.isEmpty(updateWarehouseVo.getTimeZone())){
fb.setCode(0); fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"timeZone")); fb.setMessage(i18n.getMessage(request,"timeZone"));
return gson.toJson(fb); return gson.toJson(fb);
} }
ResultWarehouseVo resultWarehouseVo=warehouseService.getByWarehouseName(updateWarehouseVo.getWarehouseName(),user.getCompanyName()); ResultWarehouseVo resultWarehouseVo=warehouseService.getByWarehouseName(updateWarehouseVo.getWarehouseName(),user.getCompanyNo());
if (resultWarehouseVo!=null&&!resultWarehouseVo.getWarehouseNo().equals(updateWarehouseVo.getWarehouseNo())){ if (resultWarehouseVo!=null&&!resultWarehouseVo.getWarehouseNo().equals(updateWarehouseVo.getWarehouseNo())){
fb.setCode(0); fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"repeateWarehouseName")); fb.setMessage(i18n.getMessage(request,"repeateWarehouseName"));
...@@ -795,6 +776,7 @@ public class WarehouseController { ...@@ -795,6 +776,7 @@ public class WarehouseController {
return gson.toJson(fb); return gson.toJson(fb);
} }
//删除仓库信息 //删除仓库信息
@ApiOperation(value = "删除仓库信息",notes = "删除仓库信息,只用传仓库编号") @ApiOperation(value = "删除仓库信息",notes = "删除仓库信息,只用传仓库编号")
@ApiImplicitParams({ @ApiImplicitParams({
...@@ -824,7 +806,7 @@ public class WarehouseController { ...@@ -824,7 +806,7 @@ public class WarehouseController {
warehouseService.delWarehouse(map); warehouseService.delWarehouse(map);
Map<Object,Object> msg=new HashMap<>(); Map<Object,Object> msg=new HashMap<>();
msg.put("msg",map.get("msg")); msg.put("msg",map.get("msg"));
if(msg.get("msg").equals("仓库删除成功")){ if(msg.get("msg").equals("删除仓库成功")){
fb.setCode(1); fb.setCode(1);
fb.setMessage(i18n.getMessage(request,"deleteWarehouseSuccess")); fb.setMessage(i18n.getMessage(request,"deleteWarehouseSuccess"));
}else{ }else{
...@@ -834,9 +816,12 @@ public class WarehouseController { ...@@ -834,9 +816,12 @@ public class WarehouseController {
return gson.toJson(fb); return gson.toJson(fb);
} }
@ApiOperation(value="添加网关",notes = "添加网关,传值:" + @ApiOperation(value="添加网关",notes = "添加网关,传值:" +
"warehouseNo:仓库编号" + "warehouseNo:仓库编号" +
"SN:网关编号") "SN:网关编号" +
"type:网关类型")
@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"),
}) })
...@@ -865,11 +850,12 @@ public class WarehouseController { ...@@ -865,11 +850,12 @@ public class WarehouseController {
fb.setMessage(i18n.getMessage(request,"existGateway")); fb.setMessage(i18n.getMessage(request,"existGateway"));
return gson.toJson(fb); return gson.toJson(fb);
} }
String type = gatewayService.getBySN(addWarehouseGatewayVo.getSN(),user.getCompanyNo());
//判断当前网关是否已经被使用 //判断当前网关是否已经被使用
Map<Object,Object> map=new HashMap<>(); Map<Object,Object> map=new HashMap<>();
map.put("warehouseNo",addWarehouseGatewayVo.getWarehouseNo()); map.put("warehouseNo",addWarehouseGatewayVo.getWarehouseNo());
map.put("gSN",addWarehouseGatewayVo.getSN()); map.put("gSN",addWarehouseGatewayVo.getSN());
map.put("gType","WTD93LG"); map.put("gType",type);
map.put("startTime",System.currentTimeMillis()); map.put("startTime",System.currentTimeMillis());
warehouseService.addGateway(map); warehouseService.addGateway(map);
Map<Object,Object> msg=new HashMap<>(); Map<Object,Object> msg=new HashMap<>();
...@@ -879,11 +865,13 @@ public class WarehouseController { ...@@ -879,11 +865,13 @@ public class WarehouseController {
fb.setMessage(i18n.getMessage(request,"bindingGatewaySuccess")); fb.setMessage(i18n.getMessage(request,"bindingGatewaySuccess"));
}else{ }else{
fb.setCode(0); fb.setCode(0);
// fb.setMessage(msg.get("msg").toString());
fb.setMessage(i18n.getMessage(request,"bindingGatewayFailure")); fb.setMessage(i18n.getMessage(request,"bindingGatewayFailure"));
} }
return gson.toJson(fb); return gson.toJson(fb);
} }
//绑定报警联系人 //绑定报警联系人
@ApiOperation(value="绑定报警联系人",notes = "绑定报警联系人,传值:" + @ApiOperation(value="绑定报警联系人",notes = "绑定报警联系人,传值:" +
"warehouseNo:仓库编号" + "warehouseNo:仓库编号" +
...@@ -971,7 +959,6 @@ public class WarehouseController { ...@@ -971,7 +959,6 @@ public class WarehouseController {
warehouseNo=(String) jsonObject.get("warehouseNo"); warehouseNo=(String) jsonObject.get("warehouseNo");
List<WarehouseGatewayDateVo> warehouseGatewayDateVoList=new ArrayList<>(); List<WarehouseGatewayDateVo> warehouseGatewayDateVoList=new ArrayList<>();
List<GatewayOnLineVo> gatewayOnLineVos=gatewayService.getByWarehouseNo(warehouseNo); List<GatewayOnLineVo> gatewayOnLineVos=gatewayService.getByWarehouseNo(warehouseNo);
for (int a=0;a<gatewayOnLineVos.size();a++){ for (int a=0;a<gatewayOnLineVos.size();a++){
WarehouseGatewayDateVo warehouseGatewayDateVo=new WarehouseGatewayDateVo(); WarehouseGatewayDateVo warehouseGatewayDateVo=new WarehouseGatewayDateVo();
warehouseGatewayDateVo.setgSN(gatewayOnLineVos.get(a).getSN()); warehouseGatewayDateVo.setgSN(gatewayOnLineVos.get(a).getSN());
...@@ -1004,33 +991,29 @@ public class WarehouseController { ...@@ -1004,33 +991,29 @@ public class WarehouseController {
List<String> tdls=tdlDeviceService.getByGatewaySN(gatewayOnLineVos.get(a).getSN(),gatewayOnLineVos.get(a).getType()); List<String> tdls=tdlDeviceService.getByGatewaySN(gatewayOnLineVos.get(a).getSN(),gatewayOnLineVos.get(a).getType());
List<WarehouseDataVo> warehouseDataVos=new ArrayList<>(); List<WarehouseDataVo> warehouseDataVos=new ArrayList<>();
List<TDLDeviceDetailVo> tdlDeviceDetailVos=new ArrayList<>();
for (int b=0;b<tdls.size();b++){ for (int b=0;b<tdls.size();b++){
List<WarehouseTDLDetailVo> warehouseTDLDetailVos=new ArrayList<>();
List<WarehouseTimeAndDataVo> warehouseTimeAndDataVos = new ArrayList<>();
List<WarehouseTimeAndDataVo> warehouseTimeAndDataVos1 = new ArrayList<>();
WarehouseDataVo warehouseDataVo=new WarehouseDataVo();
warehouseDataVo.setTDLSN(tdls.get(b).replace("TDL-","").trim());
String sqls ="SELECT \"tdl\",\"b\",\"T\",\"h\" FROM \"tdl_policy\".\""+device+"\" WHERE (\"tdl\" = '"+tdls.get(b)+"') ORDER BY time "; String sqls ="SELECT \"tdl\",\"b\",\"T\",\"h\" FROM \"tdl_policy\".\""+device+"\" WHERE (\"tdl\" = '"+tdls.get(b)+"') ORDER BY time ";
QueryResult queryResults = influxDBTemplate.query(new Query(sqls, database)); QueryResult queryResults = influxDBTemplate.query(new Query(sqls, database));
WarehouseDataVo warehouseDataVo=new WarehouseDataVo();
ResultAlarmVo resultAlarmVo=alarmService.getAlarmByWarehouseNo(warehouseNo,gatewayOnLineVos.get(a).getSN(),tdls.get(b).replace("TDL-","").trim()); ResultAlarmVo resultAlarmVo=alarmService.getAlarmByWarehouseNo(warehouseNo,gatewayOnLineVos.get(a).getSN(),tdls.get(b).replace("TDL-","").trim());
TDLDeviceDetailVo tdlDeviceDetailVo=new TDLDeviceDetailVo();
tdlDeviceDetailVo.setGatewaySN(gatewayOnLineVos.get(a).getSN());
tdlDeviceDetailVo.setTDLSN(tdls.get(b).replace("TDL-","").trim());
if (queryResults.getResults().get(0).getSeries() != null) { if (queryResults.getResults().get(0).getSeries() != null) {
tdlDeviceDetailVo.setTime(parseTime(queryResults.getResults().get(0).getSeries().get(0).getValues().get(0).get(0).toString())); warehouseDataVo.setTime(parseTime(queryResults.getResults().get(0).getSeries().get(0).getValues().get(0).get(0).toString()));
tdlDeviceDetailVo.setPressure(queryResults.getResults().get(0).getSeries().get(0).getValues().get(0).get(2).toString()); warehouseDataVo.setBatteryVoltage(queryResults.getResults().get(0).getSeries().get(0).getValues().get(0).get(2).toString());
tdlDeviceDetailVo.setTemperature(queryResults.getResults().get(0).getSeries().get(0).getValues().get(0).get(3).toString()); warehouseDataVo.setTemperature(queryResults.getResults().get(0).getSeries().get(0).getValues().get(0).get(3).toString());
tdlDeviceDetailVo.setHumidity(queryResults.getResults().get(0).getSeries().get(0).getValues().get(0).get(4).toString()); warehouseDataVo.setHumidity(queryResults.getResults().get(0).getSeries().get(0).getValues().get(0).get(4).toString());
}else{ }else{
tdlDeviceDetailVo.setTime("NA"); warehouseDataVo.setTime("NA");
tdlDeviceDetailVo.setPressure("NA"); warehouseDataVo.setBatteryVoltage("NA");
tdlDeviceDetailVo.setTemperature("NA"); warehouseDataVo.setTemperature("NA");
tdlDeviceDetailVo.setHumidity("NA"); warehouseDataVo.setHumidity("NA");
} }
tdlDeviceDetailVos.add(tdlDeviceDetailVo);
List<WarehouseTDLDetailVo> warehouseTDLDetailVos=new ArrayList<>();
List<WarehouseTimeAndDataVo> warehouseTimeAndDataVos = new ArrayList<>();
List<WarehouseTimeAndDataVo> warehouseTimeAndDataVos1 = new ArrayList<>();
warehouseDataVo.setTDLSN(tdls.get(b).replace("TDL-","").trim());
if(queryResults.getResults().get(0).getSeries() != null){ if(queryResults.getResults().get(0).getSeries() != null){
//解析数据 //解析数据
WarehouseTDLDetailVo warehouseTDLDetailVo=new WarehouseTDLDetailVo(); WarehouseTDLDetailVo warehouseTDLDetailVo=new WarehouseTDLDetailVo();
...@@ -1049,7 +1032,6 @@ public class WarehouseController { ...@@ -1049,7 +1032,6 @@ public class WarehouseController {
warehouseTDLDetailVo1.setMin(resultAlarmVo.getHumidityMin()); warehouseTDLDetailVo1.setMin(resultAlarmVo.getHumidityMin());
warehouseTDLDetailVos.add(warehouseTDLDetailVo1); warehouseTDLDetailVos.add(warehouseTDLDetailVo1);
} }
warehouseDataVo.setTdlDeviceDetailVos(tdlDeviceDetailVos);
warehouseDataVo.setWarehouseTDLDetailVos(warehouseTDLDetailVos); warehouseDataVo.setWarehouseTDLDetailVos(warehouseTDLDetailVos);
warehouseDataVos.add(warehouseDataVo); warehouseDataVos.add(warehouseDataVo);
} }
...@@ -1137,6 +1119,30 @@ public class WarehouseController { ...@@ -1137,6 +1119,30 @@ public class WarehouseController {
return tdlDataVo; return tdlDataVo;
} }
//模糊查询所有的仓库名
@ApiOperation(value="模糊查询所有的仓库名",notes = "模糊查询所有的仓库名,传值:" +
"warehouseName:仓库名称")
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
@PostMapping("/getWarehouseName")
public Object getWarehouseName(@RequestBody String warehouseName ,HttpServletRequest request){
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
if(StringUtils.isEmpty(warehouseName)){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"warehouseName"));
return gson.toJson(fb);
}
JSONObject jsonObject=JSON.parseObject(warehouseName);
warehouseName=(String) jsonObject.get("warehouseName");
return warehouseService.getWarehouseName(warehouseName,user.getCompanyNo());
}
//生成仓库编号 //生成仓库编号
public String getWarehouseNo(){ public String getWarehouseNo(){
String warehouseNo = "WH" +System.currentTimeMillis() ; String warehouseNo = "WH" +System.currentTimeMillis() ;
......
...@@ -61,3 +61,17 @@ spring.influxdb.write-timeout=10 ...@@ -61,3 +61,17 @@ spring.influxdb.write-timeout=10
spring.influxdb.gzip=true spring.influxdb.gzip=true
#tdl.core.add =http://logisticscore-java:8079/witium/addMount
#tdl.core.delete =http://logisticscore-java:8079/witium/delMount
tdl.core.add =http://192.168.1.16:8079/witium/addMount
tdl.core.delete =http://192.168.1.16:8079/witium/delMount
mqtt.userName = ugen
mqtt.password = ugen
#mqtt.userName = wtlogistics
#mqtt.password = wtlogistics
...@@ -68,6 +68,7 @@ tdlExist={0}\u4F20\u611F\u5668\u4E0D\u5B58\u5728 ...@@ -68,6 +68,7 @@ tdlExist={0}\u4F20\u611F\u5668\u4E0D\u5B58\u5728
tdlUsed={0}\u7684\u4F20\u611F\u5668\u5DF2\u7ECF\u88AB\u4F7F\u7528 tdlUsed={0}\u7684\u4F20\u611F\u5668\u5DF2\u7ECF\u88AB\u4F7F\u7528
cargoNo = \u8D27\u7269\u7F16\u53F7\u4E0D\u80FD\u4E3A\u7A7A cargoNo = \u8D27\u7269\u7F16\u53F7\u4E0D\u80FD\u4E3A\u7A7A
plateNo = \u8F66\u724C\u53F7\u4E0D\u80FD\u4E3A\u7A7A plateNo = \u8F66\u724C\u53F7\u4E0D\u80FD\u4E3A\u7A7A
nonexistentTruck = \u8BE5\u8F66\u724C\u4E0D\u5B58\u5728
cargoName = \u8D27\u7269\u522B\u540D\u4E0D\u80FD\u4E3A\u7A7A cargoName = \u8D27\u7269\u522B\u540D\u4E0D\u80FD\u4E3A\u7A7A
circuitSuccess = \u6DFB\u52A0\u7EBF\u8DEF\u6210\u529F circuitSuccess = \u6DFB\u52A0\u7EBF\u8DEF\u6210\u529F
circuitFailure = \u6DFB\u52A0\u7EBF\u8DEF\u5931\u8D25 circuitFailure = \u6DFB\u52A0\u7EBF\u8DEF\u5931\u8D25
...@@ -205,7 +206,8 @@ updateGatewaySuccess=\u4FEE\u6539\u7F51\u5173\u6210\u529F ...@@ -205,7 +206,8 @@ updateGatewaySuccess=\u4FEE\u6539\u7F51\u5173\u6210\u529F
updateGatewayFailure=\u4FEE\u6539\u7F51\u5173\u5931\u8D25 updateGatewayFailure=\u4FEE\u6539\u7F51\u5173\u5931\u8D25
updateGatewayByModelSuccess=\u901A\u8FC7\u6A21\u677F\u4FEE\u6539\u8BBE\u5907\u6210\u529F updateGatewayByModelSuccess=\u901A\u8FC7\u6A21\u677F\u4FEE\u6539\u8BBE\u5907\u6210\u529F
deleteGatewaySuccess=\u5220\u9664\u7F51\u5173\u6210\u529F deleteGatewaySuccess=\u5220\u9664\u7F51\u5173\u6210\u529F
isUseing=\u8BBE\u5907\u5728\u6302\u8F7D isState=\u8BE5\u7F51\u5173\u6B63\u6302\u8F7D
beingUsed = \u8BE5\u7F51\u5173\u6B63\u5728\u88AB\u4F7F\u7528
updateGatewayCompanySuccess=\u7F51\u5173\u5206\u914D\u516C\u53F8\u6210\u529F updateGatewayCompanySuccess=\u7F51\u5173\u5206\u914D\u516C\u53F8\u6210\u529F
updateGatewayCompanyFailure=\u7F51\u5173\u5206\u914D\u516C\u53F8\u5931\u8D25 updateGatewayCompanyFailure=\u7F51\u5173\u5206\u914D\u516C\u53F8\u5931\u8D25
#TDL #TDL
......
...@@ -4,20 +4,21 @@ ...@@ -4,20 +4,21 @@
<!--获取所有的报警数据--> <!--获取所有的报警数据-->
<select id="getAll" resultType="com.example.tdl.domain.vo.ResultAlarmLog"> <select id="getAll" resultType="com.example.tdl.domain.vo.ResultAlarmLog">
select transportationNo,TDLSN,description,ifnull(data,"") data,alarmTime,classify from alarm_log select transportationNo,TDLSN,description,ifnull(data,"") data,alarmTime,classify from alarm_log
where transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyName =#{companyName,jdbcType=VARCHAR})) where transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyNo =#{companyNo,jdbcType=VARCHAR}))
order by alarmTime desc; order by alarmTime desc;
</select> </select>
<select id="getByTransportationNo" resultType="com.example.tdl.domain.vo.ResultAlarmLog" parameterType="String"> <select id="getByTransportationNo" resultType="com.example.tdl.domain.vo.ResultAlarmLog" parameterType="String">
select transportationNo,TDLSN,description,ifnull(data,"") data,alarmTime,classify from alarm_log select transportationNo,TDLSN,description,ifnull(data,"") data,alarmTime,classify from alarm_log
where transportationNo=#{transportationNo,jdbcType=VARCHAR} where transportationNo=#{transportationNo,jdbcType=VARCHAR}
order by alarmTime DESC
</select> </select>
<!--根据条件获取报警数据--> <!--根据条件获取报警数据-->
<select id="getAlarmLog" parameterType="String" resultType="com.example.tdl.domain.vo.AlarmLogVo"> <select id="getAlarmLog" parameterType="String" resultType="com.example.tdl.domain.vo.AlarmLogVo">
select transportationNo,description,ifnull(data,"") data,alarmTime select transportationNo,description,ifnull(data,"") data,alarmTime
from alarm_log from alarm_log
where transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyName =#{companyName,jdbcType=VARCHAR})) where transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyNo =#{companyNo,jdbcType=VARCHAR}))
and DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s')) and DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s'))
order by alarmTime desc order by alarmTime desc
</select> </select>
...@@ -41,36 +42,36 @@ ...@@ -41,36 +42,36 @@
<select id="getCount" parameterType="String" resultType="java.lang.Integer"> <select id="getCount" parameterType="String" resultType="java.lang.Integer">
select count(DISTINCT transportationNo) from alarm_log select count(DISTINCT transportationNo) from alarm_log
where transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyName =#{companyName,jdbcType=VARCHAR})) where transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyNo =#{companyNo,jdbcType=VARCHAR}))
and DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s')) and DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s'))
</select> </select>
<select id="getBumpCount" resultType="java.lang.Integer" > <select id="getBumpCount" resultType="java.lang.Integer" >
select count(DISTINCT transportationNo) from alarm_log select count(DISTINCT transportationNo) from alarm_log
where classify = "3" where classify = "3"
and transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyName =#{companyName,jdbcType=VARCHAR})) and transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyNo =#{companyNo,jdbcType=VARCHAR}))
and DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s')) and DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s'))
</select> </select>
<select id = "getByCount" parameterType="String" resultType="com.example.tdl.domain.vo.HistogramData" > <select id = "getByCount" parameterType="String" resultType="com.example.tdl.domain.vo.HistogramData" >
SELECT ifnull(classify,"1") classify,count(description) count FROM alarm_log WHERE classify = "1" SELECT ifnull(classify,"1") classify,count(description) count FROM alarm_log WHERE classify = "1"
and transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyName =#{companyName,jdbcType=VARCHAR})) and transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyNo =#{companyNo,jdbcType=VARCHAR}))
AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s')) AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s'))
UNION ALL UNION ALL
SELECT ifnull(classify,"2") classify,count(description) count FROM alarm_log WHERE classify = "2" SELECT ifnull(classify,"2") classify,count(description) count FROM alarm_log WHERE classify = "2"
and transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyName =#{companyName,jdbcType=VARCHAR})) and transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyNo =#{companyNo,jdbcType=VARCHAR}))
AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s')) AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s'))
UNION ALL UNION ALL
SELECT ifnull(classify,"3") classify,count(description) count FROM alarm_log WHERE classify = "3" SELECT ifnull(classify,"3") classify,count(description) count FROM alarm_log WHERE classify = "3"
and transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyName =#{companyName,jdbcType=VARCHAR})) and transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyNo =#{companyNo,jdbcType=VARCHAR}))
AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s')) AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s'))
UNION ALL UNION ALL
SELECT ifnull(classify,"4") classify,count(description) count FROM alarm_log WHERE classify = "4" SELECT ifnull(classify,"4") classify,count(description) count FROM alarm_log WHERE classify = "4"
and transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyName =#{companyName,jdbcType=VARCHAR})) and transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyNo =#{companyNo,jdbcType=VARCHAR}))
AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s')) AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s'))
UNION ALL UNION ALL
SELECT ifnull(classify,"5") classify,count(description) count FROM alarm_log WHERE classify = "5" SELECT ifnull(classify,"5") classify,count(description) count FROM alarm_log WHERE classify = "5"
and transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyName =#{companyName,jdbcType=VARCHAR})) and transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyNo =#{companyNo,jdbcType=VARCHAR}))
AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s')) AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s'))
</select> </select>
...@@ -110,7 +111,7 @@ ...@@ -110,7 +111,7 @@
<select id="getRealTimeAlarm" parameterType="java.lang.String" resultType="com.example.tdl.domain.vo.AlarmLogVo"> <select id="getRealTimeAlarm" parameterType="java.lang.String" resultType="com.example.tdl.domain.vo.AlarmLogVo">
select transportationNo,description,ifnull(FORMAT(data,2),"") data,alarmTime select transportationNo,description,ifnull(FORMAT(data,2),"") data,alarmTime
from alarm_log from alarm_log
where transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyName =#{companyName,jdbcType=VARCHAR})) where transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyNo =#{companyNo,jdbcType=VARCHAR}))
and DATE_SUB(CURDATE(), INTERVAL 1 HOUR ) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s')) and DATE_SUB(CURDATE(), INTERVAL 1 HOUR ) &lt;= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s'))
order by alarmTime desc limit 3 order by alarmTime desc limit 3
</select> </select>
......
...@@ -5,14 +5,14 @@ ...@@ -5,14 +5,14 @@
<select id="getAll" resultType="com.example.tdl.domain.vo.ResultAlarmVo" parameterType="String"> <select id="getAll" resultType="com.example.tdl.domain.vo.ResultAlarmVo" parameterType="String">
SELECT alarmType,temMax,temMin,humidityMax,humidityMin,tilt,shock,remark SELECT alarmType,temMax,temMin,humidityMax,humidityMin,tilt,shock,remark
from alarm a INNER JOIN company c ON a.company_id=c.id from alarm a INNER JOIN company c ON a.company_id=c.id
WHERE c.companyName=#{companyName,jdbcType=VARCHAR} WHERE c.companyNo=#{companyNo,jdbcType=VARCHAR}
</select> </select>
<!--根据预警类型模糊查询--> <!--根据预警类型模糊查询-->
<select id="getAllByAlarmType" resultType="com.example.tdl.domain.vo.ResultAlarmVo" parameterType="String"> <select id="getAllByAlarmType" resultType="com.example.tdl.domain.vo.ResultAlarmVo" parameterType="String">
SELECT alarmType,temMax,temMin,humidityMax,humidityMin,tilt,shock,remark SELECT alarmType,temMax,temMin,humidityMax,humidityMin,tilt,shock,remark
from alarm a INNER JOIN company c ON a.company_id=c.id from alarm a INNER JOIN company c ON a.company_id=c.id
WHERE c.companyName=#{companyName,jdbcType=VARCHAR} WHERE c.companyNo=#{companyNo,jdbcType=VARCHAR}
AND alarmType LIKE CONCAT(CONCAT('%',#{alarmType,jdbcType=VARCHAR}), '%') AND alarmType LIKE CONCAT(CONCAT('%',#{alarmType,jdbcType=VARCHAR}), '%')
</select> </select>
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#{humidityMin,jdbcType=FLOAT}, #{humidityMin,jdbcType=FLOAT},
#{tilt,jdbcType=FLOAT}, #{tilt,jdbcType=FLOAT},
#{shock,jdbcType=VARCHAR}, #{shock,jdbcType=VARCHAR},
(SELECT id from company where companyName=#{companyName,jdbcType=VARCHAR}), (SELECT id from company where companyNo=#{companyNo,jdbcType=VARCHAR}),
#{remark,jdbcType=VARCHAR} #{remark,jdbcType=VARCHAR}
) )
</insert> </insert>
...@@ -44,25 +44,25 @@ ...@@ -44,25 +44,25 @@
shock=#{shock,jdbcType=VARCHAR}, shock=#{shock,jdbcType=VARCHAR},
remark=#{remark,jdbcType=VARCHAR} remark=#{remark,jdbcType=VARCHAR}
WHERE alarmType=#{oldAlarmType,jdbcType=VARCHAR} WHERE alarmType=#{oldAlarmType,jdbcType=VARCHAR}
AND company_id=(SELECT id from company where companyName=#{companyName,jdbcType=VARCHAR}) AND company_id=(SELECT id from company where companyNo=#{companyNo,jdbcType=VARCHAR})
</update> </update>
<!--删除预警信息--> <!--删除预警信息-->
<delete id="delAlarm" parameterType="com.example.tdl.domain.vo.DelAlarmVo"> <delete id="delAlarm" parameterType="com.example.tdl.domain.vo.DelAlarmVo">
DELETE from alarm WHERE alarmType=#{alarmType,jdbcType=VARCHAR} DELETE from alarm WHERE alarmType=#{alarmType,jdbcType=VARCHAR}
AND company_id=(SELECT id from company where companyName=#{companyName,jdbcType=VARCHAR}) AND company_id=(SELECT id from company where companyNo=#{companyNo,jdbcType=VARCHAR})
</delete> </delete>
<!--根据预警类型和预警场景查询--> <!--根据预警类型和预警场景查询-->
<select id="getByType" parameterType="String" resultType="com.example.tdl.domain.vo.ResultAlarmVo"> <select id="getByType" parameterType="String" resultType="com.example.tdl.domain.vo.ResultAlarmVo">
SELECT alarmType,temMax,temMin,humidityMax,humidityMin,tilt,shock,remark SELECT alarmType,temMax,temMin,humidityMax,humidityMin,tilt,shock,remark
from alarm a INNER JOIN company c ON a.company_id=c.id from alarm a INNER JOIN company c ON a.company_id=c.id
WHERE c.companyName=#{companyName,jdbcType=VARCHAR} WHERE c.companyNo=#{companyNo,jdbcType=VARCHAR}
AND alarmType=#{alarmType,jdbcType=VARCHAR} AND alarmType=#{alarmType,jdbcType=VARCHAR}
</select> </select>
<select id="getAlarmByWarehouseNo" parameterType="String" resultType="com.example.tdl.domain.vo.ResultAlarmVo"> <select id="getAlarmByWarehouseNo" parameterType="String" resultType="com.example.tdl.domain.vo.ResultAlarmVo">
SELECT alarmType,temMax,temMin,humidityMax,humidityMin,tilt,shock,a.remark SELECT DISTINCT alarmType,temMax,temMin,humidityMax,humidityMin,tilt,shock,a.remark
FROM tdl_gateway_log tgl INNER JOIN alarm a ON tgl.alarm_id=a.id FROM tdl_gateway_log tgl INNER JOIN alarm a ON tgl.alarm_id=a.id
where warehouseNo=#{warehouseNo,jdbcType=VARCHAR} where warehouseNo=#{warehouseNo,jdbcType=VARCHAR}
AND gatewaySN=#{gatewaySN,jdbcType=VARCHAR} AND gatewaySN=#{gatewaySN,jdbcType=VARCHAR}
......
...@@ -6,23 +6,27 @@ ...@@ -6,23 +6,27 @@
SELECT c.transportationNo,cargoNo,cargoName,(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 c.transportationNo,cargoNo,cargoName,(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 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 GROUP_CONCAT(alarmType) FROM alarm WHERE id IN (SELECT alarm_id from tdl_gateway_log WHERE transportationNo=c.transportationNo)) alarmType, (SELECT GROUP_CONCAT(alarmType) FROM alarm WHERE id IN (SELECT alarm_id from tdl_gateway_log WHERE transportationNo=c.transportationNo)) alarmType,
(select GROUP_CONCAT( DISTINCT classify) from alarm_log al where al.transportationNo = c.transportationNo) alarm,evaluate,transportation,plateNo,(select DISTINCT gatewaySN from tdl_gateway_log WHERE transportationNo=c.transportationNo) gSN,(select DISTINCT gatewayType from tdl_gateway_log WHERE transportationNo=c.transportationNo) gType (select GROUP_CONCAT( DISTINCT classify) from alarm_log al where al.transportationNo = c.transportationNo) alarm,evaluate,transportation,plateNo,
(select DISTINCT gatewaySN from tdl_gateway_log WHERE transportationNo=c.transportationNo) gSN,
(select DISTINCT gatewayType from tdl_gateway_log WHERE transportationNo=c.transportationNo) gType
from circuit c from circuit c
where c.state=1 where c.state=1
AND company_id=(SELECT id from company where companyName=#{companyName,jdbcType=VARCHAR}) AND company_id=(SELECT id from company where companyNo=#{companyNo,jdbcType=VARCHAR})
order by c.createTime desc order by c.createTime desc
</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.CircuitResultVo" parameterType="com.example.tdl.domain.vo.CircuitTermVo">
SELECT c.transportationNo,cargoNo,cargoName,(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 c.transportationNo,cargoNo,cargoName,(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 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(alarmType) FROM alarm WHERE id IN (SELECT alarm_id from tdl_gateway_log WHERE transportationNo=c.transportationNo)) alarmType,
(select GROUP_CONCAT(DISTINCT classify) from alarm_log al where al.transportationNo = c.transportationNo) alarm,evaluate,transportation (select GROUP_CONCAT(DISTINCT classify) from alarm_log al where al.transportationNo = c.transportationNo) alarm,evaluate,transportation,plateNo,
(select DISTINCT gatewaySN from tdl_gateway_log WHERE transportationNo=c.transportationNo) gSN,
(select DISTINCT gatewayType from tdl_gateway_log WHERE transportationNo=c.transportationNo) gType
from circuit c from circuit c
where c.state=1 where c.state=1
AND company_id=(SELECT id from company where companyName=#{companyName,jdbcType=VARCHAR}) AND company_id=(SELECT id from company where companyNo=#{companyNo,jdbcType=VARCHAR})
<if test="time !=null"> <if test="time !=null">
AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(createTime/1000,'%Y-%m-%d %H:%i:%s')) AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(createTime/1000,'%Y-%m-%d %H:%i:%s'))
</if> </if>
...@@ -219,20 +223,20 @@ ...@@ -219,20 +223,20 @@
<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 c.transportationNo,cargoNo,cargoName,(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 c.transportationNo,cargoNo,cargoName,(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 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(alarmType) FROM alarm WHERE id IN (SELECT alarm_id from tdl_gateway_log WHERE transportationNo=c.transportationNo)) alarmType,
(select GROUP_CONCAT(DISTINCT classify) from alarm_log al where al.transportationNo = c.transportationNo) alarm,ifnull(evaluate,"") evaluate,transportation, (select GROUP_CONCAT(DISTINCT classify) from alarm_log al where al.transportationNo = c.transportationNo) alarm,ifnull(evaluate,"") evaluate,transportation,
(select DISTINCT gatewaySN FROM tdl_gateway_log WHERE transportationNo= #{transportationNo,jdbcType=VARCHAR} ) SN,(SELECT GROUP_CONCAT(TDLSN) FROM tdl_gateway_log WHERE transportationNo= #{transportationNo,jdbcType=VARCHAR}) TDLSN (select DISTINCT gatewaySN FROM tdl_gateway_log WHERE transportationNo= #{transportationNo,jdbcType=VARCHAR} ) SN,(SELECT GROUP_CONCAT(TDLSN) FROM tdl_gateway_log WHERE transportationNo= #{transportationNo,jdbcType=VARCHAR}) TDLSN
from circuit c from circuit c
where c.state=1 where c.state=1
AND c.transportationNo=#{transportationNo,jdbcType=VARCHAR} AND c.transportationNo=#{transportationNo,jdbcType=VARCHAR}
AND company_id=(SELECT id from company where companyName=#{companyName,jdbcType=VARCHAR}) AND company_id=(SELECT id from company where companyNo=#{companyNo,jdbcType=VARCHAR})
</select> </select>
<select id="getCircuit" resultType="com.example.tdl.domain.vo.ResultCircuitVo" parameterType="String"> <select id="getCircuit" resultType="com.example.tdl.domain.vo.ResultCircuitVo" parameterType="String">
SELECT c.transportationNo,cargoNo,cargoName,(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 c.transportationNo,cargoNo,cargoName,(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 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(alarmType) FROM alarm WHERE id IN (SELECT alarm_id from tdl_gateway_log WHERE transportationNo=c.transportationNo)) alarmType,
(select GROUP_CONCAT(DISTINCT classify) from alarm_log al where al.transportationNo = c.transportationNo) alarm,ifnull(evaluate,"") evaluate,transportation, (select GROUP_CONCAT(DISTINCT classify) from alarm_log al where al.transportationNo = c.transportationNo) alarm,ifnull(evaluate,"") evaluate,transportation,
(select DISTINCT gatewaySN FROM tdl_gateway_log WHERE transportationNo= #{transportationNo,jdbcType=VARCHAR} ) SN,(SELECT GROUP_CONCAT(TDLSN) FROM tdl_gateway_log WHERE transportationNo= #{transportationNo,jdbcType=VARCHAR}) TDLSN (select DISTINCT gatewaySN FROM tdl_gateway_log WHERE transportationNo= #{transportationNo,jdbcType=VARCHAR} ) SN,(SELECT GROUP_CONCAT(TDLSN) FROM tdl_gateway_log WHERE transportationNo= #{transportationNo,jdbcType=VARCHAR}) TDLSN
from circuit c from circuit c
...@@ -249,14 +253,14 @@ ...@@ -249,14 +253,14 @@
from circuit c,(SELECT GROUP_CONCAT(sequence) sequence from circuit_transfer where circuit_id=(SELECT id from circuit where transportationNo=#{transportationNo,jdbcType=VARCHAR})) s from circuit c,(SELECT GROUP_CONCAT(sequence) sequence from circuit_transfer where circuit_id=(SELECT id from circuit where transportationNo=#{transportationNo,jdbcType=VARCHAR})) s
where c.state=1 where c.state=1
AND c.transportationNo=#{transportationNo,jdbcType=VARCHAR} AND c.transportationNo=#{transportationNo,jdbcType=VARCHAR}
AND company_id=(SELECT id from company where companyName=#{companyName,jdbcType=VARCHAR}) AND company_id=(SELECT id from company where companyNo=#{companyNo,jdbcType=VARCHAR})
</select> </select>
<!-- 运输中数量--> <!-- 运输中数量-->
<select id="getOnRoute" resultType="java.lang.Integer" parameterType="String"> <select id="getOnRoute" resultType="java.lang.Integer" parameterType="String">
select count(transportationNo) from circuit where circuitState=1 AND state = 1 select count(transportationNo) from circuit where circuitState=1 AND state = 1
AND company_id=(SELECT id from company where companyName=#{companyName,jdbcType=VARCHAR}) AND company_id=(SELECT id from company where companyNo=#{companyNo,jdbcType=VARCHAR})
</select> </select>
...@@ -264,7 +268,7 @@ ...@@ -264,7 +268,7 @@
<select id="getDelayCount" resultType="java.lang.Integer" > <select id="getDelayCount" resultType="java.lang.Integer" >
select count(id) from circuit where state =1 select count(id) from circuit where state =1
AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(createTime/1000,'%Y-%m-%d %H:%i:%s')) AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(createTime/1000,'%Y-%m-%d %H:%i:%s'))
AND company_id=(SELECT id from company where companyName=#{companyName,jdbcType=VARCHAR}) AND company_id=(SELECT id from company where companyNo=#{companyNo,jdbcType=VARCHAR})
AND ifnull(endtime,#{compTime,jdbcType=BIGINT}) > compTime AND ifnull(endtime,#{compTime,jdbcType=BIGINT}) > compTime
</select> </select>
...@@ -272,7 +276,7 @@ ...@@ -272,7 +276,7 @@
<!--总数量--> <!--总数量-->
<select id="getCount" resultType="java.lang.Integer"> <select id="getCount" resultType="java.lang.Integer">
select count(id) from circuit select count(id) from circuit
where company_id=(SELECT id from company where companyName=#{companyName,jdbcType=VARCHAR}) where company_id=(SELECT id from company where companyNo=#{companyNo,jdbcType=VARCHAR})
AND state =1 AND state =1
and DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(ifnull(endTime/1000, #{endTime,jdbcType=BIGINT}),'%Y-%m-%d %H:%i:%s')) and DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) &lt;= date(FROM_UNIXTIME(ifnull(endTime/1000, #{endTime,jdbcType=BIGINT}),'%Y-%m-%d %H:%i:%s'))
</select> </select>
...@@ -282,10 +286,10 @@ ...@@ -282,10 +286,10 @@
<select id="getByPlateNo" parameterType="String" resultType="com.example.tdl.domain.vo.AppCircuitVo"> <select id="getByPlateNo" parameterType="String" resultType="com.example.tdl.domain.vo.AppCircuitVo">
SELECT c.transportationNo,cargoNo,cargoName,expTime,compTime,(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 c.transportationNo,cargoNo,cargoName,expTime,compTime,(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 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(alarmType) FROM alarm WHERE id IN (SELECT alarm_id from tdl_gateway_log WHERE transportationNo=c.transportationNo)) alarmType,
(select GROUP_CONCAT(DISTINCT classify) from alarm_log al where al.transportationNo = c.transportationNo) alarm,evaluate,transportation (select GROUP_CONCAT(DISTINCT classify) from alarm_log al where al.transportationNo = c.transportationNo) alarm,evaluate,transportation
from circuit c where c.state=1 AND plateNo=#{plateNo,jdbcType=VARCHAR} from circuit c where c.state=1 AND plateNo=#{plateNo,jdbcType=VARCHAR}
AND company_id=(SELECT id from company where companyName=#{companyName,jdbcType=VARCHAR}) AND company_id=(SELECT id from company where companyNo=#{companyNo,jdbcType=VARCHAR})
</select> </select>
...@@ -293,10 +297,10 @@ ...@@ -293,10 +297,10 @@
<select id="getByCircuitState" resultType="com.example.tdl.domain.vo.AppCircuitVo"> <select id="getByCircuitState" resultType="com.example.tdl.domain.vo.AppCircuitVo">
SELECT c.transportationNo,cargoNo,cargoName,expTime,compTime,(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 c.transportationNo,cargoNo,cargoName,expTime,compTime,(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 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(alarmType) FROM alarm WHERE id IN (SELECT alarm_id from tdl_gateway_log WHERE transportationNo=c.transportationNo)) alarmType,
(select GROUP_CONCAT(DISTINCT classify) from alarm_log al where al.transportationNo = c.transportationNo) alarm,evaluate,transportation (select GROUP_CONCAT(DISTINCT classify) from alarm_log al where al.transportationNo = c.transportationNo) alarm,evaluate,transportation
from circuit c where c.state=1 AND circuitState=#{circuitState,jdbcType=INTEGER} from circuit c where c.state=1 AND circuitState=#{circuitState,jdbcType=INTEGER}
AND company_id=(SELECT id from company where companyName=#{companyName,jdbcType=VARCHAR}) AND company_id=(SELECT id from company where companyNo=#{companyNo,jdbcType=VARCHAR})
</select> </select>
...@@ -324,18 +328,18 @@ ...@@ -324,18 +328,18 @@
<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 c.transportationNo,cargoNo,cargoName,(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 c.transportationNo,cargoNo,cargoName,(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 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(alarmType) FROM alarm WHERE id IN (SELECT alarm_id from tdl_gateway_log WHERE transportationNo=c.transportationNo)) alarmType,
(select GROUP_CONCAT(DISTINCT classify) from alarm_log al where al.transportationNo = c.transportationNo) alarm,evaluate,transportation (select GROUP_CONCAT(DISTINCT classify) from alarm_log al where al.transportationNo = c.transportationNo) alarm,evaluate,transportation
from circuit c where c.state=1 from circuit c where c.state=1
and c.circuitState = 1 and c.circuitState = 1
AND company_id=(SELECT id from company where companyName=#{companyName,jdbcType=VARCHAR}) AND company_id=(SELECT id from company where companyNo=#{companyNo,jdbcType=VARCHAR})
</select> </select>
<select id="getDelay" resultType="java.lang.Integer"> <select id="getDelay" resultType="java.lang.Integer">
select count(transportationNo) from circuit select count(transportationNo) from circuit
where #{compTime,jdbcType=BIGINT}> compTime where #{compTime,jdbcType=BIGINT}> compTime
and company_id = (SELECT id from company where companyName=#{companyName,jdbcType=VARCHAR}) and company_id = (SELECT id from company where companyNo=#{companyNo,jdbcType=VARCHAR})
and circuitState = 1 and circuitState = 1
</select> </select>
...@@ -345,7 +349,7 @@ ...@@ -345,7 +349,7 @@
select c.transportationNo,CONCAT_WS("-",(SELECT city from city WHERE id =(SELECT city_id from circuit_transfer WHERE circuit_id=c.id AND sequence =LEFT(s.sequence,1))), select c.transportationNo,CONCAT_WS("-",(SELECT city from city WHERE id =(SELECT city_id from circuit_transfer WHERE circuit_id=c.id AND sequence =LEFT(s.sequence,1))),
(SELECT city from city WHERE id =(SELECT city_id from circuit_transfer WHERE circuit_id=c.id AND sequence=RIGHT(s.sequence,1)))) routeName, (SELECT city from city WHERE id =(SELECT city_id from circuit_transfer WHERE circuit_id=c.id AND sequence=RIGHT(s.sequence,1)))) routeName,
cargoName,plateNo,transportation,IFNULL(evaluate,"") evaluate,circuitState,startTime,endTime, cargoName,plateNo,transportation,IFNULL(evaluate,"") evaluate,circuitState,startTime,endTime,
(SELECT alarmType FROM alarm WHERE id IN (SELECT alarm_id from tdl_gateway_log WHERE transportationNo=c.transportationNo)) alarmType (SELECT GROUP_CONCAT(alarmType) FROM alarm WHERE id IN (SELECT alarm_id from tdl_gateway_log WHERE transportationNo=c.transportationNo)) alarmType
from circuit c,(SELECT GROUP_CONCAT(sequence) sequence from circuit_transfer where circuit_id=(SELECT id from circuit where transportationNo=#{transportationNo,jdbcType=VARCHAR})) s from circuit c,(SELECT GROUP_CONCAT(sequence) sequence from circuit_transfer where circuit_id=(SELECT id from circuit where transportationNo=#{transportationNo,jdbcType=VARCHAR})) s
where c.state = 1 where c.state = 1
and c.transportationNo=#{transportationNo,jdbcType=VARCHAR} and c.transportationNo=#{transportationNo,jdbcType=VARCHAR}
......
...@@ -3,7 +3,12 @@ ...@@ -3,7 +3,12 @@
<mapper namespace="com.example.tdl.mapper.CompanyMapper"> <mapper namespace="com.example.tdl.mapper.CompanyMapper">
<!--查询所有公司信息--> <!--查询所有公司信息-->
<select id="getAll" resultType="com.example.tdl.domain.vo.ResultCompanyVo"> <select id="getAll" resultType="com.example.tdl.domain.vo.ResultCompanyVo">
SELECT companyNo,companyName,alias,country,city,addressDetail,tel,manager,img from company WHERE state=1 SELECT companyNo,companyName,country,city,addressDetail,tel,manager,img,alias
from company
WHERE state=1
<if test="companyNo!='TM201803298320'">
and companyNo=#{companyNo,jdbcType=VARCHAR}
</if>
</select> </select>
<insert id="addCompany" parameterType="com.example.tdl.domain.vo.AddCompanyVo"> <insert id="addCompany" parameterType="com.example.tdl.domain.vo.AddCompanyVo">
......
...@@ -110,9 +110,10 @@ ...@@ -110,9 +110,10 @@
<!--根据仓库编号查询网关信息--> <!--根据仓库编号查询网关信息-->
<select id="getByWarehouseNo" parameterType="String" resultType="com.example.tdl.domain.vo.GatewayOnLineVo"> <select id="getByWarehouseNo" parameterType="String" resultType="com.example.tdl.domain.vo.GatewayOnLineVo">
SELECT DISTINCT gatewaySN SN, gatewayType type from tdl_gateway_log SELECT DISTINCT gatewaySN SN, gatewayType type
from tdl_gateway_log
where warehouseNo=#{warehouseNo,jdbcType=VARCHAR} where warehouseNo=#{warehouseNo,jdbcType=VARCHAR}
AND endTime is null and ISNULL(endTime)
</select> </select>
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
NULL , NULL ,
NULL, NULL,
NULL, NULL,
(SELECT id from company where companyName=#{companyName,jdbcType=VARCHAR}) (SELECT id from company where companyNo=#{companyNo,jdbcType=VARCHAR})
) )
</insert> </insert>
......
...@@ -23,7 +23,9 @@ ...@@ -23,7 +23,9 @@
select userNumber, userName,password,nickName,phone,email,roleName,c.companyName select userNumber, userName,password,nickName,phone,email,roleName,c.companyName
from company c,`user` u INNER JOIN role r ON u.role_id=r.id from company c,`user` u INNER JOIN role r ON u.role_id=r.id
WHERE u.company_id=c.id WHERE u.company_id=c.id
AND c.companyName=#{companyName,jdbcType=VARCHAR} <if test="companyNo!='TM201803298320'">
and c.companyNo=#{companyNo,jdbcType=VARCHAR}
</if>
AND u.state=1 AND u.state=1
</select> </select>
...@@ -54,6 +56,9 @@ ...@@ -54,6 +56,9 @@
<if test="companyName!=null"> <if test="companyName!=null">
AND c.companyName=#{companyName,jdbcType=VARCHAR} AND c.companyName=#{companyName,jdbcType=VARCHAR}
</if> </if>
<if test="companyNo!='TM201803298320'">
and c.companyNo=#{companyNo,jdbcType=VARCHAR}
</if>
AND u.state=1 AND u.state=1
</select> </select>
...@@ -137,4 +142,9 @@ ...@@ -137,4 +142,9 @@
select COUNT(id) from `user` select COUNT(id) from `user`
WHERE role_id=(select id from role where roleName=#{roleName,jdbcType=VARCHAR}); WHERE role_id=(select id from role where roleName=#{roleName,jdbcType=VARCHAR});
</select> </select>
<select id="getAllByCompanyNo" resultType="com.example.tdl.domain.vo.AlarmContactsVo" parameterType="String">
select userName from `user`
where company_id=(select id from company where companyNo =#{companyNo,jdbcType=VARCHAR})
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
where c.id = w.company_id where c.id = w.company_id
and r.id = w.region_id and r.id = w.region_id
and ct.id = w.city_id and ct.id = w.city_id
and c.companyName=#{companyName,jdbcType=VARCHAR} and c.companyNo=#{companyNo,jdbcType=VARCHAR}
order by createTime desc order by createTime desc
</select> </select>
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
where c.id = w.company_id where c.id = w.company_id
and r.id = w.region_id and r.id = w.region_id
and ct.id = w.city_id and ct.id = w.city_id
and c.companyName=#{companyName,jdbcType=VARCHAR} and c.companyNo=#{companyNo,jdbcType=VARCHAR}
<if test="warehouseName!=null"> <if test="warehouseName!=null">
AND warehouseName like CONCAT(CONCAT('%',#{warehouseName,jdbcType=VARCHAR}), '%') AND warehouseName like CONCAT(CONCAT('%',#{warehouseName,jdbcType=VARCHAR}), '%')
</if> </if>
...@@ -54,8 +54,8 @@ ...@@ -54,8 +54,8 @@
where c.id = w.company_id where c.id = w.company_id
and r.id = w.region_id and r.id = w.region_id
and ct.id = w.city_id and ct.id = w.city_id
and c.companyName=#{companyName,jdbcType=VARCHAR}
AND warehouseName=#{warehouseName,jdbcType=VARCHAR} AND warehouseName=#{warehouseName,jdbcType=VARCHAR}
and c.companyNo=#{companyNo,jdbcType=VARCHAR}
</select> </select>
<insert id="addWarehouse" parameterType="java.util.Map" statementType="CALLABLE"> <insert id="addWarehouse" parameterType="java.util.Map" statementType="CALLABLE">
...@@ -149,6 +149,7 @@ ...@@ -149,6 +149,7 @@
]]> ]]>
</insert> </insert>
<update id="untieGateway" parameterType="java.util.Map" statementType="CALLABLE"> <update id="untieGateway" parameterType="java.util.Map" statementType="CALLABLE">
<![CDATA[ <![CDATA[
{ {
...@@ -181,15 +182,15 @@ ...@@ -181,15 +182,15 @@
</select> </select>
<select id="getByWarehouseNoAndSN" resultType="java.lang.Integer" parameterType="String"> <select id="getByWarehouseNoAndSN" resultType="java.lang.Integer" parameterType="String">
select count(w.warehouseNo) from gateway_warehouse gw,warehouse w,gateway g select count(w.warehouseNo) from tdl_gateway_log tgl,warehouse w,gateway g
where gw.gateway_id=g.id where tgl.warehouseNo=w.warehouseNo
and gw.warehouse_id = w.id and tgl.gatewaySN = g.SN
and w.warehouseNo=#{warehouseNo,jdbcType=VARCHAR} and w.warehouseNo=#{warehouseNo,jdbcType=VARCHAR}
and g.SN=#{SN,jdbcType=VARCHAR} and g.SN=#{SN,jdbcType=VARCHAR}
</select> </select>
<!--根据报警信息查询仓库信息--> <!--根据报警信息查询仓库信息-->
<!--<select id="getByAlarm" parameterType="com.example.tdl.domain.vo.DelAlarmVo" resultType="com.example.tdl.domain.vo.ResultWarehouseVo"> <select id="getByAlarm" parameterType="com.example.tdl.domain.vo.DelAlarmVo" resultType="com.example.tdl.domain.vo.ResultWarehouseVo">
SELECT warehouseNo,w.img,warehouseName,ct.country,ct.city,CONCAT_WS("-",ct.country,ct.city) regions ,w.addressDetail,r.regionName,lng,lat,a.alarmType,property, SELECT warehouseNo,w.img,warehouseName,ct.country,ct.city,CONCAT_WS("-",ct.country,ct.city) regions ,w.addressDetail,r.regionName,lng,lat,a.alarmType,property,
type,hardwareLevel,areaIndoor,areaRack,areaOutdoor,areaPlanIndoor,office,timeZone,warehouseInfo,w.remark type,hardwareLevel,areaIndoor,areaRack,areaOutdoor,areaPlanIndoor,office,timeZone,warehouseInfo,w.remark
from warehouse w,alarm a ,region r,company c,city ct from warehouse w,alarm a ,region r,company c,city ct
...@@ -199,15 +200,16 @@ ...@@ -199,15 +200,16 @@
and w.company_id= c.id and w.company_id= c.id
and a.company_id =c.id and a.company_id =c.id
AND a.alarmType=#{alarmType,jdbcType=VARCHAR} AND a.alarmType=#{alarmType,jdbcType=VARCHAR}
and c.companyName=#{companyName,jdbcType=VARCHAR} AND a.alarmScene=#{alarmScene,jdbcType=VARCHAR}
</select>--> and c.companyNo=#{companyNo,jdbcType=VARCHAR}
</select>
<select id="getByWarehouse" parameterType="com.example.tdl.domain.vo.WareHouseByTermVo" resultType="com.example.tdl.domain.vo.SimpleWarehouseVo"> <select id="getByWarehouse" parameterType="com.example.tdl.domain.vo.WareHouseByTermVo" resultType="com.example.tdl.domain.vo.SimpleWarehouseVo">
select warehouseNo, warehouseName,CONCAT_WS("-",ct.country,ct.city) regions,ct.country,ct.city, (select count(id) from tdldevice t where t.warehouse_id = w.id ) count,property,type,hardwareLevel,areaPlanIndoor select warehouseNo, warehouseName,CONCAT_WS("-",ct.country,ct.city) regions,ct.country,ct.city, (select count(id) from tdldevice t where t.warehouse_id = w.id ) count,property,type,hardwareLevel,areaPlanIndoor
from warehouse w ,company c ,city ct from warehouse w ,company c ,city ct
where c.id=w.company_id where c.id=w.company_id
and ct.id = w.city_id and ct.id = w.city_id
and c.companyName = #{companyName,jdbcType=VARCHAR} and c.companyNo=#{companyNo,jdbcType=VARCHAR}
<if test="warehouseName!=null"> <if test="warehouseName!=null">
AND warehouseName like CONCAT(CONCAT('%',#{warehouseName,jdbcType=VARCHAR}), '%') AND warehouseName like CONCAT(CONCAT('%',#{warehouseName,jdbcType=VARCHAR}), '%')
</if> </if>
...@@ -217,6 +219,7 @@ ...@@ -217,6 +219,7 @@
<if test="city!=null"> <if test="city!=null">
AND ct.city like CONCAT(CONCAT('%',#{city,jdbcType=VARCHAR}), '%') AND ct.city like CONCAT(CONCAT('%',#{city,jdbcType=VARCHAR}), '%')
</if> </if>
</select> </select>
<select id="getDevice" parameterType="String" resultType="com.example.tdl.domain.vo.DeviceVo"> <select id="getDevice" parameterType="String" resultType="com.example.tdl.domain.vo.DeviceVo">
...@@ -240,8 +243,8 @@ ...@@ -240,8 +243,8 @@
</select> </select>
<select id="getWarehouseDetailByNo" parameterType="String" resultType="com.example.tdl.domain.vo.WarehouseDetailVo"> <select id="getWarehouseDetailByNo" parameterType="String" resultType="com.example.tdl.domain.vo.WarehouseDetailVo">
SELECT warehouseNo,warehouseName,c.country,c.city,addressDetail,(SELECT COUNT(DISTINCT gatewaySN) from tdl_gateway_log WHERE warehouseNo=w.warehouseNo) gatewayCounts, SELECT warehouseNo,warehouseName,c.country,c.city,addressDetail,(SELECT COUNT(DISTINCT gatewaySN) from tdl_gateway_log WHERE warehouseNo=w.warehouseNo and ISNULL(endTime)) gatewayCounts,
(SELECT COUNT(TDLSN) from tdl_gateway_log WHERE warehouseNo=w.warehouseNo) tdlCounts,property,type,hardwareLevel,areaPlanIndoor (SELECT COUNT(TDLSN) from tdl_gateway_log WHERE warehouseNo=w.warehouseNo and ISNULL(endTime)) tdlCounts,property,type,hardwareLevel,areaPlanIndoor
from warehouse w INNER JOIN city c ON w.city_id=c.id from warehouse w INNER JOIN city c ON w.city_id=c.id
where warehouseNo=#{warehouseNo,jdbcType=VARCHAR} where warehouseNo=#{warehouseNo,jdbcType=VARCHAR}
</select> </select>
...@@ -259,4 +262,11 @@ ...@@ -259,4 +262,11 @@
AND t.TDLSN=#{TDLSN,jdbcType=VARCHAR} AND t.TDLSN=#{TDLSN,jdbcType=VARCHAR}
</select> </select>
<select id="getWarehouseName" resultType="com.example.tdl.domain.vo.WarehouseNameVo" parameterType="String">
select DISTINCT warehouseName from warehouse w
INNER JOIN company c on w.company_id = c.id
where warehouseName like CONCAT(CONCAT('%',#{warehouseName,jdbcType=VARCHAR}), '%')
and companyNo=#{companyNo,jdbcType=VARCHAR}
</select>
</mapper> </mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment