Commit ce9d3833 authored by zhuangzhuang's avatar zhuangzhuang

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

parent ffb8719b
......@@ -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 {
private String remark;
private String companyName;
private String companyNo;
public String getAlarmType() {
return alarmType;
......@@ -84,11 +84,11 @@ public class AddAlarmVo {
this.remark = remark;
}
public String getCompanyName() {
return companyName;
public String getCompanyNo() {
return companyNo;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
public void setCompanyNo(String companyNo) {
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 {
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() {
return action;
}
......@@ -103,4 +123,84 @@ public class CheckInVo {
public void setDevList(List<String> 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;
public class CircuitTermVo {
private String companyName;
private String companyNo;
private String cargoNo;
......@@ -13,12 +13,12 @@ public class CircuitTermVo {
private String time;
public String getCompanyName() {
return companyName;
public String getCompanyNo() {
return companyNo;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
public void setCompanyNo(String companyNo) {
this.companyNo = companyNo;
}
public String getCargoNo() {
......
......@@ -12,6 +12,26 @@ public class ConfigCMDVo {
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 Long t;//配置时的时间戳
......@@ -36,6 +56,26 @@ public class ConfigCMDVo {
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() {
return action;
}
......@@ -68,6 +108,86 @@ public class ConfigCMDVo {
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() {
return mode;
}
......
......@@ -8,9 +8,7 @@ public class DataVo {
private List<HistoryDataVo> dataList;
private String min;
private String max;
public String getDescription() {
return description;
......@@ -28,19 +26,5 @@ public class DataVo {
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;
public class DelAlarmVo {
private String alarmType;
private String companyName;
private String companyNo;
public String getCompanyName() {
return companyName;
public String getCompanyNo() {
return companyNo;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
public void setCompanyNo(String companyNo) {
this.companyNo = companyNo;
}
public String getAlarmType() {
......
......@@ -5,6 +5,10 @@ import java.util.List;
public class HistoryDataVo {
private String TDLSN;
private String min;
private String max;
private List<HistoryData> dataList;
public String getTDLSN() {
......@@ -15,6 +19,22 @@ public class HistoryDataVo {
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() {
return dataList;
}
......
......@@ -20,14 +20,14 @@ public class UpdateAlarmVo {
private String oldAlarmType;
private String companyName;
private String companyNo;
public String getCompanyName() {
return companyName;
public String getCompanyNo() {
return companyNo;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
public void setCompanyNo(String companyNo) {
this.companyNo = companyNo;
}
public String getAlarmType() {
......
......@@ -13,10 +13,10 @@ public class UserRedisVo {
private String roleName;
private String companyNo;
private String companyName;
private String companyNo;
public String getCompanyNo() {
return companyNo;
}
......@@ -81,14 +81,14 @@ public class UserRedisVo {
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;
UserNumber = userNumber;
this.nickName = nickName;
this.email = email;
this.phone = phone;
this.roleName = roleName;
this.companyNo=companyNo;
this.companyName=companyName;
this.companyName = companyName;
this.companyNo = companyNo;
}
}
......@@ -11,6 +11,8 @@ public class UserTermVo {
private String companyName;
private String companyNo;
public String getCompanyName() {
return companyName;
}
......@@ -50,4 +52,12 @@ public class UserTermVo {
public void setPhone(String phone) {
this.phone = phone;
}
public String getCompanyNo() {
return companyNo;
}
public void setCompanyNo(String companyNo) {
this.companyNo = companyNo;
}
}
......@@ -10,7 +10,7 @@ public class WareHouseByTermVo {
private String gSN;
private String companyName;
private String companyNo;
public String getWarehouseName() {
return warehouseName;
......@@ -44,11 +44,11 @@ public class WareHouseByTermVo {
this.gSN = gSN;
}
public String getCompanyName() {
return companyName;
public String getCompanyNo() {
return companyNo;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
public void setCompanyNo(String companyNo) {
this.companyNo = companyNo;
}
}
......@@ -6,17 +6,15 @@ public class WarehouseDataVo {
private String TDLSN;
private List<TDLDeviceDetailVo> tdlDeviceDetailVos;
private String batteryVoltage;
private List<WarehouseTDLDetailVo> warehouseTDLDetailVos;
private String temperature;
public List<TDLDeviceDetailVo> getTdlDeviceDetailVos() {
return tdlDeviceDetailVos;
}
private String humidity;
public void setTdlDeviceDetailVos(List<TDLDeviceDetailVo> tdlDeviceDetailVos) {
this.tdlDeviceDetailVos = tdlDeviceDetailVos;
}
private String time;
private List<WarehouseTDLDetailVo> warehouseTDLDetailVos;
public String getTDLSN() {
return TDLSN;
......@@ -26,6 +24,38 @@ public class WarehouseDataVo {
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() {
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 {
private String hardwareLevel;
private String companyName;
private String companyNo;
public String getWarehouseName() {
return warehouseName;
......@@ -63,11 +63,11 @@ public class WarehouseTermVo {
this.hardwareLevel = hardwareLevel;
}
public String getCompanyName() {
return companyName;
public String getCompanyNo() {
return companyNo;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
public void setCompanyNo(String companyNo) {
this.companyNo = companyNo;
}
}
......@@ -14,24 +14,24 @@ public interface AlarmLogMapper {
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);
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);
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;
@Mapper
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);
......@@ -19,7 +19,7 @@ public interface AlarmMapper {
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);
}
......@@ -9,9 +9,9 @@ import java.util.Map;
@Mapper
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);
......@@ -29,24 +29,24 @@ public interface CircuitMapper {
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);
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);
......@@ -54,7 +54,7 @@ public interface CircuitMapper {
ResultGatewayVo getByNo(String transportationNo);
List<ResultCircuitVo> getByTime(String companyName);
List<ResultCircuitVo> getByTime(String companyNo);
CircuitMessage getMessage(String transportationNo);
}
......@@ -2,6 +2,7 @@ package com.example.tdl.mapper;
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.UpdateCompanyVo;
import org.apache.ibatis.annotations.Mapper;
......@@ -13,7 +14,7 @@ import java.util.Map;
@Mapper
public interface CompanyMapper {
List<ResultCompanyVo> getAll();
List<ResultCompanyVo> getAll(@Param("companyNo") String companyNo);
int addCompany(AddCompanyVo addCompanyVo);
......@@ -28,4 +29,5 @@ public interface CompanyMapper {
ResultCompanyVo getByAlias(String alias);
int updateImg(@Param("img") String img, @Param("companyNo") String companyNo);
}
......@@ -9,12 +9,12 @@ import java.util.List;
@Mapper
public interface UserMapper {
List<ResultUserVo> getAll(@Param("companyNo") String companyNo);
int login(LoginUserVo loginUserVo);
UserVo getByUserName(@Param("userName") String userName);
List<ResultUserVo> getAll(String companyName);
List<ResultUserVo> getAllUser();
......@@ -37,4 +37,6 @@ public interface UserMapper {
int updateImg(@Param("img") String img,@Param("userNumber") String userNumber);
int getByRoleName(@Param("roleName") String roleName,@Param("companyName") String companyName);
List<AlarmContactsVo> getAllByCompanyNo(String companyNo);
}
......@@ -39,9 +39,9 @@ public interface WarehouseMapper {
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);
......@@ -50,4 +50,6 @@ public interface WarehouseMapper {
WarehouseDetailVo getWarehouseDetailByNo(@Param("warehouseNo") String warehouseNo);
DeviceMessageVo getDeviceMessage(SearchTdlVo searchTdlVo);
List<WarehouseNameVo> getWarehouseName(@Param("warehouseName") String warehouseName,@Param("companyNo") String companyNo );
}
......@@ -21,6 +21,7 @@ import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
......@@ -33,14 +34,17 @@ import java.util.concurrent.TimeUnit;
* @Date: Created in 9:41 2018/3/13
* @Modified By:
**/
@Component
public class MqttListener implements MqttCallback {
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 String CHECKIN_TOPIC = "CY/+/+/CheckIn";
private static final String CHECKIN_TOPIC = "TDL/+/+/CheckIn";
private MqttTemlateAsync mqttAsyncClient;
private Gson gson = new Gson();
@Autowired
private MqttConfig mqttconfig;
......@@ -132,10 +136,11 @@ public class MqttListener implements MqttCallback {
if(ts - tskey > 60*1000){
GWConfigWorker tmpgwconfigworker = gwconfigworkerMap.get(key);
Boolean boo = tmpgwconfigworker.GCConfigClose();
if(boo)
if(boo){
gwconfigworkerMap.remove(key);
}
}
}
}catch (Exception e){
System.out.println(e.getMessage());
}
......@@ -169,8 +174,15 @@ public class MqttListener implements MqttCallback {
ConfigData = new Gson().toJson(configCMDVo);
gcconfig = new GWConfigWorker(Type,SN,ConfigData,configService, true);
}else if(flag == 1){
ConfigData = configService.getConfig(SN,Type).getMessage();
gcconfig = new GWConfigWorker(Type,SN,ConfigData,configService,true);
String message= configService.getConfig(SN,Type).getMessage();
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(),
mqttconfig.getUsername(), mqttconfig.getPassword(),mqttconfig.getQos(),
......@@ -216,16 +228,50 @@ public class MqttListener implements MqttCallback {
if(configCMDVo == null){
return 0;//休眠
}
if(checkInVo.getDevList().size()==0 && configCMDVo !=null ){
return 1;//重发
}
if(configVo.getUntie() && StringUtils.isEmpty(configVo.getMessage()) ){
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是否一致
if (configCMDVo.getDevList().containsAll(checkInVo.getDevList())
&& checkInVo.getDevList().containsAll(configCMDVo.getDevList())
if (compare(configCMDVo.getDevList(),checkInVo.getDevList())
&& checkInVo.getGprsPeriod().equals(configCMDVo.getGprsPeriod())
&& checkInVo.getGpsPeriod().equals(configCMDVo.getGpsPeriod())
&& checkInVo.getMode().equals(configCMDVo.getMode())) {
......@@ -235,6 +281,23 @@ public class MqttListener implements MqttCallback {
//不一致
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 {
return alarmLogMapper.getAll();
}
public List<AlarmLogVo> getAlarmLog(String time,String companyName){
return alarmLogMapper.getAlarmLog(time,companyName);
public List<AlarmLogVo> getAlarmLog(String time,String companyNo){
return alarmLogMapper.getAlarmLog(time,companyNo);
}
public int addAlarmLog(AlarmLog addAlarmLogVo){
......@@ -30,20 +30,20 @@ public class AlarmLogService {
return alarmLogMapper.getByTransportationNo(transportationNo);
}
public Integer getCount(String time,String companyName){
return alarmLogMapper.getCount(time,companyName);
public Integer getCount(String time,String companyNo){
return alarmLogMapper.getCount(time,companyNo);
}
public Integer getBumpCount(String time,String companyName){
return alarmLogMapper.getBumpCount(time,companyName);
public Integer getBumpCount(String time,String companyNo){
return alarmLogMapper.getBumpCount(time,companyNo);
}
public Integer getAlarmCount(String companyName){
return alarmLogMapper.getAlarmCount(companyName);
public Integer getAlarmCount(String companyNo){
return alarmLogMapper.getAlarmCount(companyNo);
}
public List<HistogramData> getByCount(String time,String companyName){
return alarmLogMapper.getByCount(time,companyName);
public List<HistogramData> getByCount(String time,String companyNo){
return alarmLogMapper.getByCount(time,companyNo);
}
......@@ -55,8 +55,8 @@ public class AlarmLogService {
return alarmLogMapper.getAlarm(alarmTermVo);
}
public List<AlarmLogVo> getRealTimeAlarm(String companyName){
return alarmLogMapper.getRealTimeAlarm(companyName);
public List<AlarmLogVo> getRealTimeAlarm(String companyNo){
return alarmLogMapper.getRealTimeAlarm(companyNo);
}
......
......@@ -15,12 +15,12 @@ public class AlarmService {
@Autowired
private AlarmMapper alarmMapper;
public List<ResultAlarmVo> getAll(String companyName){
return alarmMapper.getAll(companyName);
public List<ResultAlarmVo> getAll(String companyNo){
return alarmMapper.getAll(companyNo);
}
public List<ResultAlarmVo> getAllByAlarmType(String companyName,String alarmType){
return alarmMapper.getAllByAlarmType(companyName,alarmType);
public List<ResultAlarmVo> getAllByAlarmType(String companyNo,String alarmType){
return alarmMapper.getAllByAlarmType(companyNo,alarmType);
}
public int addAlarm(AddAlarmVo addAlarmVo){
......@@ -35,8 +35,8 @@ public class AlarmService {
return alarmMapper.delAlarm(delAlarmVo);
}
public ResultAlarmVo getByType(String alarmType,String companyName){
return alarmMapper.getByType(alarmType,companyName);
public ResultAlarmVo getByType(String alarmType,String companyNo){
return alarmMapper.getByType(alarmType,companyNo);
}
public ResultAlarmVo getAlarmByWarehouseNo(String warehouseNo,String SN, String TDLSN){
......
......@@ -14,11 +14,11 @@ public class CircuitService {
@Autowired
private CircuitMapper circuitMapper;
public List<CircuitResultVo> getAll(String companyName){
return circuitMapper.getAll(companyName);
public List<CircuitResultVo> getAll(String companyNo){
return circuitMapper.getAll(companyNo);
}
public List<ResultCircuitVo> getByTerm(CircuitTermVo circuitTermVo){
public List<CircuitResultVo> getByTerm(CircuitTermVo circuitTermVo){
return circuitMapper.getByTerm(circuitTermVo);
}
......@@ -56,39 +56,40 @@ public class CircuitService {
}
public ResultCircuitVo getByTransportationNo(String transportationNo,String companyName){
return circuitMapper.getByTransportationNo(transportationNo,companyName);
public ResultCircuitVo getByTransportationNo(String transportationNo,String companyNo){
return circuitMapper.getByTransportationNo(transportationNo,companyNo);
}
public ResultCircuitForAppVo getByTransportationNoForApp(String transportationNo,String companyName){
return circuitMapper.getByTransportationNoForApp(transportationNo,companyName);
public ResultCircuitForAppVo getByTransportationNoForApp(String transportationNo,String companyNo){
return circuitMapper.getByTransportationNoForApp(transportationNo,companyNo);
}
public ResultCircuitVo getCircuit(String 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){
return circuitMapper.getDelayCount(compTime,time,companyName);
public Integer getDelayCount(Long compTime,String time,String companyNo){
return circuitMapper.getDelayCount(compTime,time,companyNo);
}
public Integer getDelay(Long compTime,String companyName){
return circuitMapper.getDelay(compTime,companyName);
public Integer getDelay(Long compTime,String companyNo){
return circuitMapper.getDelay(compTime,companyNo);
}
public Integer getCount(String time,Long startTime,String companyName){
return circuitMapper.getCount(time,startTime,companyName);
public Integer getCount(String time,Long startTime,String companyNo){
return circuitMapper.getCount(time,startTime,companyNo);
}
public List<AppCircuitVo> getByPlateNo(String plateNo,String companyName){
return circuitMapper.getByPlateNo(plateNo,companyName);
public List<AppCircuitVo> getByPlateNo(String plateNo,String companyNo){
return circuitMapper.getByPlateNo(plateNo,companyNo);
}
public List<AppCircuitVo> getByCircuitState(Integer circuitState,String companyName){
return circuitMapper.getByCircuitState(circuitState,companyName);
public List<AppCircuitVo> getByCircuitState(Integer circuitState,String companyNo){
return circuitMapper.getByCircuitState(circuitState,companyNo);
}
public int updateEvaluate(UpdateEvaluateVo updateEvaluateVo){
......@@ -103,8 +104,8 @@ public class CircuitService {
return circuitMapper.getByNo(transportationNo);
}
public List<ResultCircuitVo> getByTime(String companyName){
return circuitMapper.getByTime(companyName);
public List<ResultCircuitVo> getByTime(String companyNo){
return circuitMapper.getByTime(companyNo);
}
......
......@@ -2,6 +2,7 @@ package com.example.tdl.service;
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.UpdateCompanyVo;
import com.example.tdl.mapper.CompanyMapper;
......@@ -17,8 +18,8 @@ public class CompanyService {
@Autowired
private CompanyMapper companyMapper;
public List<ResultCompanyVo> getAll(){
return companyMapper.getAll();
public List<ResultCompanyVo> getAll(String companyNo){
return companyMapper.getAll(companyNo);
}
public int addCompany(AddCompanyVo addCompanyVo){
......@@ -49,4 +50,6 @@ public class CompanyService {
return companyMapper.updateImg(img,companyNo);
}
}
......@@ -22,6 +22,11 @@ public class UserService {
@Autowired
private TokenRedisService redisService;
public List<ResultUserVo> getAll(String companyNo){
return userMapper.getAll(companyNo);
}
public int login(LoginUserVo loginUserVo){
return userMapper.login(loginUserVo);
}
......@@ -30,9 +35,7 @@ public class UserService {
return userMapper.getByUserName(userName);
}
public List<ResultUserVo> getAll(String companyName){
return userMapper.getAll(companyName);
}
public List<ResultUserVo> getAllUser(){
return userMapper.getAllUser();
......@@ -95,4 +98,8 @@ public class UserService {
public int getByRoleName(String roleName,String companyName){
return userMapper.getByRoleName(roleName,companyName);
}
public List<AlarmContactsVo> getAllByCompanyNo(String companyNo){
return userMapper.getAllByCompanyNo( companyNo);
}
}
......@@ -15,8 +15,8 @@ public class WarehouseService {
@Autowired
private WarehouseMapper warehouseMapper;
public List<ResultWarehouseVo> getAll(String companyName){
return warehouseMapper.getAll(companyName);
public List<ResultWarehouseVo> getAll(String companyNo){
return warehouseMapper.getAll(companyNo);
}
public List<ResultWarehouseVo> getAllByTerm(WarehouseTermVo warehouseTermVo){
......@@ -68,13 +68,13 @@ public class WarehouseService {
return warehouseMapper.getAlarmContacts(warehouseNo);
}
public ResultWarehouseVo getByWarehouseName(String warehouseName,String companyName){
return warehouseMapper.getByWarehouseName(warehouseName,companyName);
public ResultWarehouseVo getByWarehouseName(String warehouseName,String companyNo){
return warehouseMapper.getByWarehouseName(warehouseName,companyNo);
}
// public List<ResultWarehouseVo> getByAlarm(DelAlarmVo delAlarmVo){
// return warehouseMapper.getByAlarm(delAlarmVo);
// }
public List<ResultWarehouseVo> getByAlarm(DelAlarmVo delAlarmVo){
return warehouseMapper.getByAlarm(delAlarmVo);
}
public List<GatewaySNVo> getGateway(String warehouseNo){
return warehouseMapper.getGateway(warehouseNo);
......@@ -91,4 +91,8 @@ public class WarehouseService {
public DeviceMessageVo getDeviceMessage(SearchTdlVo 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 {
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
return alarmService.getAll(user.getCompanyName());
return alarmService.getAll(user.getCompanyNo());
}
//根据预警类型模糊查询
......@@ -92,7 +92,7 @@ public class AlarmController {
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
JSONObject jsonObject= JSON.parseObject(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 {
fb.setMessage(i18n.getMessage(request,"shock"));
return gson.toJson(fb);
}
if (alarmService.getByType(addAlarmVo.getAlarmType(),user.getCompanyName())!=null){
if (alarmService.getByType(addAlarmVo.getAlarmType(),user.getCompanyNo())!=null){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"alarmExist"));
return gson.toJson(fb);
}
addAlarmVo.setCompanyName(user.getCompanyName());
addAlarmVo.setCompanyNo(user.getCompanyNo());
int a=alarmService.addAlarm(addAlarmVo);
if (a>0){
fb.setCode(1);
......@@ -248,12 +248,12 @@ public class AlarmController {
fb.setMessage(i18n.getMessage(request,"shock"));
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.setMessage(i18n.getMessage(request,"modifiedAlarmExist"));
return gson.toJson(fb);
}
updateAlarmVo.setCompanyName(user.getCompanyName());
updateAlarmVo.setCompanyNo(user.getCompanyNo());
int a=alarmService.updateAlarm(updateAlarmVo);
if (a>0){
fb.setCode(1);
......@@ -266,6 +266,7 @@ public class AlarmController {
}
//删除预警信息
@ApiOperation(value = "删除预警信息",notes = "删除预警信息,companyName不用传,传值说明:" +
" alarmType:需要删除的预警类型," +
......@@ -285,7 +286,7 @@ public class AlarmController {
fb.setMessage(i18n.getMessage(request,"deletedAlarmType"));
return gson.toJson(fb);
}
delAlarmVo.setCompanyName(user.getCompanyName());
delAlarmVo.setCompanyNo(user.getCompanyNo());
if(tdlLogService.getByAlarm(delAlarmVo).size()>0){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"dusedAlarm"));
......
......@@ -69,14 +69,8 @@ public class CompanyController {
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
if(user.getCompanyName().equals("上海辉度")){
return companyService.getAll();
}else {
List<ResultCompanyVo> companyVoList = new ArrayList<>();
ResultCompanyVo companyVo = companyService.getByCompanyName(user.getCompanyName());
companyVoList.add(companyVo);
return companyVoList;
}
return companyService.getAll(user.getCompanyNo());
}
//添加公司信息
......
......@@ -88,11 +88,6 @@ public class EquipmentBindingController {
fb.setMessage("网关编号不能为空");
return gson.toJson(fb);
}
if(StringUtils.isEmpty(bindingVo.getType())){
fb.setCode(0);
fb.setMessage("网关类型不能为空");
return gson.toJson(fb);
}
if(StringUtils.isEmpty(bindingVo.getTDLSN())){
fb.setCode(0);
fb.setMessage("Tdl编号不能为空");
......@@ -108,6 +103,9 @@ public class EquipmentBindingController {
fb.setMessage("使用场景不能为空");
return gson.toJson(fb);
}
if(StringUtils.isEmpty(bindingVo.getType())){
bindingVo.setType(gatewayService.getBySN(bindingVo.getSN(),user.getCompanyNo()));
}
//获取gateWay的信息
ResultGatewayVo resultGatewayVo = gatewayService.getBySNAndType(bindingVo.getSN(),bindingVo.getType());
if(resultGatewayVo == null){
......@@ -122,7 +120,7 @@ public class EquipmentBindingController {
}
//判断当前tdl是否有网关在使用
ResultTDLDeviceVo resultTDLDeviceVo = tdlDeviceService.getByTDLSN(bindingVo.getTDLSN());
if(resultTDLDeviceVo != null &&!StringUtils.isEmpty(resultTDLDeviceVo.getGatewaySN())){
if(!StringUtils.isEmpty(resultTDLDeviceVo.getGatewaySN())){
fb.setCode(0);
fb.setMessage("该TDL已经被使用");
return gson.toJson(fb);
......@@ -132,22 +130,48 @@ public class EquipmentBindingController {
}else if(StringUtils.isEmpty(bindingVo.getWarehouseNo()) && !StringUtils.isEmpty(bindingVo.getTransportationNo())){
bindingVo.setWarehouseNo("");
}
//开始绑定
//获取gateway下的所有tdl的编号
List<String> devList = tdlDeviceService.getByGatewaySN(bindingVo.getSN(),bindingVo.getType());
devList.add("TDL-"+bindingVo.getTDLSN());
String alarmScene = "";
Integer gpsPeriod = null;
Integer gprsPeriod = null;
if(bindingVo.getMode() == 2){
alarmScene="仓库";
gpsPeriod = 43200;
gprsPeriod= 60;
}else{
alarmScene="运输";
gpsPeriod=5;
if("17110194".equals(bindingVo.getSN())){
gprsPeriod=7;
}else{
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.put("companyName",user.getCompanyName());
map.put("transportationNo",bindingVo.getTransportationNo());
......@@ -167,8 +191,10 @@ public class EquipmentBindingController {
Map<Object,Object> msg=new HashMap<>();
msg.put("msg",map.get("msg"));
if (msg.get("msg").equals("配置网关成功")){
fb.setCode(1);
fb.setMessage("配置网关成功");
//根据报警类型货报警信息
ResultAlarmVo alarmVo = alarmService.getByType(bindingVo.getAlarmType(),user.getCompanyName());
for(String alias :list){
List<AlarmRuleVo> alarmRuleVos = new ArrayList<>();
AlarmRuleVo alarmRuleVo = new AlarmRuleVo();
......@@ -194,8 +220,6 @@ public class EquipmentBindingController {
alarmRuleVos.add(alarmRuleVo);
//向redis中写入报警信息
alarmRedisService.hmSet("TDL/"+bindingVo.getType()+"/" +bindingVo.getSN()+"/Data","TDL-" +bindingVo.getTDLSN()+"_" +alias,gson.toJson(alarmRuleVos));
fb.setCode(1);
fb.setMessage("配置网关成功");
}
}else{
fb.setCode(0);
......@@ -206,7 +230,7 @@ public class EquipmentBindingController {
@ApiOperation(value = "解绑tdl",notes = "解绑tdl")
@ApiOperation(value = "重置tdl",notes = "重置tdl")
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
......@@ -226,7 +250,7 @@ public class EquipmentBindingController {
ConfigCMDVo config = gson.fromJson(configVo.getMessage(),ConfigCMDVo.class);
ConfigCMDVo configCMDVo ;
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);
}else{
configCMDVo = new ConfigCMDVo();
......@@ -248,13 +272,12 @@ public class EquipmentBindingController {
alarmRedisService.delKey(key);
}else{
fb.setCode(0);
fb.setMessage("解除tdl失败");
fb.setMessage(msg.get("msg").toString());
}
return gson.toJson(fb);
}
@ApiOperation(value = "解绑网关",notes = "解绑网关")
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
......
......@@ -18,6 +18,7 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
......@@ -61,6 +62,12 @@ public class GatewayController {
@Autowired
private I18nController i18n;
@Value("${tdl.core.add}")
private String addmount;
@Value("${tdl.core.delete}")
private String delmount;
//查询所有网关信息
@ApiOperation(value = "查询所有网关信息",notes = "查询所有网关信息:" +
......@@ -230,11 +237,17 @@ public class GatewayController {
fb.setMessage(i18n.getMessage(request,"gatewayType"));
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.setMessage(i18n.getMessage(request,"existGateway"));
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.put("SN",delGatewayVo.getSN());
map.put("type",delGatewayVo.getType());
......@@ -281,10 +294,10 @@ public class GatewayController {
return gson.toJson(fb);
}
//根据SN,type获取设备状态
boolean state = gatewayService.getBySNAndType(deployProbesVo.getSN(),deployProbesVo.getType()).getState();
if(state){
ResultGatewayVo resultGatewayVo = gatewayService.getBySNAndType(deployProbesVo.getSN(),deployProbesVo.getType());
if(resultGatewayVo.getState()){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"isUseing"));
fb.setMessage(i18n.getMessage(request,"isState"));
return gson.toJson(fb);
}
Map<Object,Object> map=new HashMap<>();
......@@ -304,6 +317,7 @@ public class GatewayController {
return gson.toJson(fb);
}
//挂载设备
@ApiOperation(value = "设备挂载/xie",notes = "使用通道模板配置通道" +
" SN:设备编号" +
......@@ -370,11 +384,11 @@ public class GatewayController {
infoRedisService.hmSet("PubTopic", device.getType() + "_" + device.getSN(), pubList.toString());
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);
} 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);
infoRedisService.delHashKey("DeviceConfig", device.getType() + "_" + device.getSN());
infoRedisService.delHashKey("SubTopic", device.getType() + "_" + device.getSN());
......@@ -396,7 +410,6 @@ public class GatewayController {
return gson.toJson(fb);
}
//获取未使用的网关
@ApiOperation(value = "获取未使用的网关",notes = "获取未使用的网关,传值说明:" +
" gSN:需要查询的网关序列号")
......
......@@ -105,13 +105,13 @@ public class HomePageController {
//获取所有的线路数量
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());
dataVo.setDelay(delay);//延误数量
dataVo.setAlarmed( alarmLogServcie.getCount(time,user.getCompanyName()));//报警数量
dataVo.setBump(alarmLogServcie.getBumpCount(time,user.getCompanyName())); //获取颠簸数量
dataVo.setAlarmLogVoList(alarmLogServcie.getAlarmLog(time,user.getCompanyName()));//报警列表
List<HistogramData> list = alarmLogServcie.getByCount(time,user.getCompanyName());//获取报警柱状图
dataVo.setAlarmed( alarmLogServcie.getCount(time,user.getCompanyNo()));//报警数量
dataVo.setBump(alarmLogServcie.getBumpCount(time,user.getCompanyNo())); //获取颠簸数量
dataVo.setAlarmLogVoList(alarmLogServcie.getAlarmLog(time,user.getCompanyNo()));//报警列表
List<HistogramData> list = alarmLogServcie.getByCount(time,user.getCompanyNo());//获取报警柱状图
for(int j = 0,length = list.size();j<length;j++){
if(list.get(j).getClassify().equals("5")){
Integer count = list.get(j).getCount() +delay;
......@@ -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<>();
Integer num = 0;
for(int i = 0;i<circuitVos.size();i++){
......@@ -185,9 +185,9 @@ public class HomePageController {
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
AlarmDataVo alarmDataVo = new AlarmDataVo();
alarmDataVo.setOnRoute(circuitService.getOnRoute(user.getCompanyName()));
alarmDataVo.setAlarmed(alarmLogServcie.getAlarmCount(user.getCompanyName()));
alarmDataVo.setDelay(circuitService.getDelay(System.currentTimeMillis(),user.getCompanyName()));
alarmDataVo.setOnRoute(circuitService.getOnRoute(user.getCompanyNo()));
alarmDataVo.setAlarmed(alarmLogServcie.getAlarmCount(user.getCompanyNo()));
alarmDataVo.setDelay(circuitService.getDelay(System.currentTimeMillis(),user.getCompanyNo()));
return gson.toJson(alarmDataVo);
}
......
......@@ -8,7 +8,7 @@ import com.example.tdl.entity.LoginLog;
import com.example.tdl.service.LoginLogService;
import com.example.tdl.service.UserService;
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 io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
......@@ -43,6 +43,9 @@ public class LoginController {
@Autowired
private TokenRedisService tokenRedisService;
@Autowired
private UserTokenRedisService userTokenService;
@Autowired
private LoginLogService loginLogService;
......@@ -75,9 +78,10 @@ public class LoginController {
SecurityUtils.getSubject().login(new UsernamePasswordToken(loginUserVo.getUserName(), loginUserVo.getPassword()));
//生成token
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中
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();
int a=loginLogService.addLoginLog(new LoginLog(loginUserVo.getUserName(),System.currentTimeMillis(),ip));
if (a>0){
......
......@@ -66,7 +66,7 @@ public class PermissionController {
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
//获取该公司的所有权限
String name = "管理员";
String name = "系统管理员";
List<String> permissionLists = roleHasPermissionService.getByRoleName(name);
List<String> parentLists =permissionService.getPermissionParentName();
List<PermissionGroupVo> vo =new ArrayList<>();
......@@ -102,16 +102,15 @@ public class PermissionController {
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
JSONObject json = JSON.parseObject(roleName);
roleName= (String) json.get("roleName");
if (roleName.equals("")||roleName==null){
if (StringUtils.isEmpty(roleName)){
fb.setCode(0);
fb.setMessage("查询的角色名不能为空");
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> parentLists =permissionService.getPermissionParentName();
//根据角色名获取拥有的角色
......@@ -160,7 +159,6 @@ public class PermissionController {
return gson.toJson(fb);
}
String permissionVar="";
int num = 0;
for(int i=0;i<addOrUpdatePermissionVo.getPermissionGroupVos().size();i++){
permissionVar+=addOrUpdatePermissionVo.getPermissionGroupVos().get(i)+" ";
}
......@@ -181,6 +179,8 @@ public class PermissionController {
fb.setMessage(ms.get("msg").toString());
}
} catch (DataAccessException e) {
e.printStackTrace();
logger.info(e.toString());
fb.setCode(0);
fb.setMessage("操作失败");
}
......
......@@ -48,6 +48,7 @@ public class PicUploadController {
// 允许上传的格式
private static final String[] IMAGE_TYPE = new String[]{".jpg",".png" };
//上传图片
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
......@@ -59,9 +60,9 @@ public class PicUploadController {
fb.setMessage("图片不能为空");
return gson.toJson(fb);
}
if (multipartFile.getSize() > 5 * 1024 * 1024) {
if (multipartFile.getSize() > 512000) {
fb.setCode(0);
fb.setMessage("上传图片大小不能超过5M!");
fb.setMessage("上传图片大小不能超过500K!");
return gson.toJson(fb);
}
try {
......@@ -70,24 +71,40 @@ public class PicUploadController {
if(sourceImg == null){
fb.setCode(0);
fb.setMessage("上传图片格式不正确");
return gson.toJson(fb);
}else{
if("truck".equals(imageType)){
if(sourceImg.getHeight()>90){
fb.setCode(0);
fb.setMessage("上传图片尺寸不正确");
return gson.toJson(fb);
}
if(sourceImg.getWidth()>60){
fb.setCode(0);
fb.setMessage("上传图片尺寸不正确");
return gson.toJson(fb);
}
}else if("warehouse".equals(imageType)){
if(sourceImg.getHeight()>150){
fb.setCode(0);
fb.setMessage("上传图片尺寸不正确");
return gson.toJson(fb);
}
if(sourceImg.getWidth()>120){
fb.setCode(0);
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 {
e.printStackTrace();
fb.setCode(0);
fb.setMessage("上传图片格式不正确");
return gson.toJson(fb);
}
// 校验图片格式
boolean isLegal = false;
......@@ -154,9 +172,9 @@ public class PicUploadController {
fb.setMessage("图片不能为空");
return gson.toJson(fb);
}
if (multipartFile.getSize() > 5 * 1024 * 1024) {
if (multipartFile.getSize() > 512000) {
fb.setCode(0);
fb.setMessage("上传图片大小不能超过5M!");
fb.setMessage("上传图片大小不能超过500K!");
return gson.toJson(fb);
}
try {
......@@ -165,25 +183,40 @@ public class PicUploadController {
if(sourceImg == null){
fb.setCode(0);
fb.setMessage("上传图片格式不正确");
}else{
return gson.toJson(fb);
}
if("truck".equals(imageType)){
if(sourceImg.getHeight()>90){
fb.setCode(0);
fb.setMessage("上传图片尺寸不正确");
return gson.toJson(fb);
}
if(sourceImg.getWidth()>60){
fb.setCode(0);
fb.setMessage("上传图片尺寸不正确");
return gson.toJson(fb);
}
}else if("warehouse".equals(imageType)){
if(sourceImg.getHeight()>150){
fb.setCode(0);
fb.setMessage("上传图片尺寸不正确");
return gson.toJson(fb);
}
if(sourceImg.getWidth()>120){
fb.setCode(0);
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) {
......@@ -212,13 +245,12 @@ public class PicUploadController {
String img = "https://tdlcloud.oss-cn-shanghai.aliyuncs.com/pic/";
int i = 0;
if("user".equals(imageType)){
img = img +"userImage/" +url;
//修改用户图片
// i = userService.updateImg(number,img);
img = img +"userImage/" +url;
}else if("company".equals(imageType)){
i = companyService.updateImg(number,img);
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)){
img = img +"palteImage/" +url;
i = carService.updateImg(img,number);
......
......@@ -164,6 +164,8 @@ public class TDLDeviceController {
return gson.toJson(fb);
}
//删除TDL信息
@ApiOperation(value = "删除TDL信息",notes = "删除TDL信息,传值说明:" +
" TDLSN:需要删除的TDL序列号")
......@@ -197,6 +199,8 @@ public class TDLDeviceController {
}
@ApiOperation(value = "获取未被使用的TDL序列号",notes = "获取未被使用的TDL序列号,传值说明:" +
" TDLSN:需要查询的TDL序列号")
@ApiImplicitParams({
......@@ -217,6 +221,8 @@ public class TDLDeviceController {
return tdlDeviceService.getUnusedTDL(TDLSN,user.getCompanyNo());
}
//分配TDL
@ApiOperation(value = "分配TDL",notes = "分配TDL,传值说明:" +
" TDLSN:需要分配的网关序列号," +
......
......@@ -11,6 +11,7 @@ import com.example.tdl.service.RoleService;
import com.example.tdl.service.UserService;
import com.example.tdl.service.redis.TokenRedisService;
import com.example.tdl.service.redis.UserTokenRedisService;
import com.google.gson.Gson;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
......@@ -60,6 +61,9 @@ public class UserController {
@Autowired
private I18nController i18n;
@Autowired
private UserTokenRedisService userTokenService;
//获取所有用户信息
@ApiOperation(value = "获取所有用户信息",notes = "获取所有用户信息:" +
......@@ -79,11 +83,7 @@ public class UserController {
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
if(user.getCompanyName().equals("上海辉度")){
return userService.getAllUser();
}else{
return userService.getAll(user.getCompanyName());
}
return userService.getAll(user.getCompanyNo());
}
//根据条件查询
......@@ -108,11 +108,19 @@ public class UserController {
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
if(user.getCompanyName().equals("")){
userTermVo.setCompanyName(null);
}else{
userTermVo.setCompanyName(user.getCompanyName());
if(StringUtils.isEmpty(userTermVo.getUserName())){
userTermVo.setUserName(null);
}
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);
}
......@@ -131,9 +139,7 @@ public class UserController {
})
@RequestMapping(value="/addUser",method = RequestMethod.POST)
public Object addUser(@RequestBody AddUserVo userVo,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");
if (StringUtils.isEmpty(userVo.getUserName())){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"userName"));
......@@ -199,7 +205,7 @@ public class UserController {
fb.setMessage(i18n.getMessage(request,"roleName"));
return gson.toJson(fb);
}
if (roleService.getByRoleName(userVo.getRoleName(),user.getCompanyName())==0){
if (roleService.getByRoleName(userVo.getRoleName(), userVo.getCompanyName())==0){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"existRoleName"));
return gson.toJson(fb);
......@@ -270,7 +276,7 @@ public class UserController {
fb.setMessage(i18n.getMessage(request,"phoneRule"));
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.setMessage(i18n.getMessage(request,"repeatedRule"));
return gson.toJson(fb);
......@@ -296,7 +302,7 @@ public class UserController {
return gson.toJson(fb);
}
if (roleService.getByRoleName(userVo.getRoleName(),user.getCompanyName())==0){
if (roleService.getByRoleName(userVo.getRoleName(),userInfo.getCompanyName())==0){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"existRoleName"));
return gson.toJson(fb);
......@@ -361,6 +367,12 @@ public class UserController {
if (a>0){
fb.setCode(1);
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{
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"resetPasswordFailure"));
......@@ -393,6 +405,12 @@ public class UserController {
if (a>0){
fb.setCode(1);
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{
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"modifiedPasswordFailure"));
......@@ -400,6 +418,7 @@ public class UserController {
return gson.toJson(fb);
}
//获取当前的用户名
@ApiOperation(value = "获取当前用户的信息",notes = "获取用户的信息" +
"userName:用户名" +
......@@ -421,4 +440,20 @@ public class UserController {
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());
}
}
......@@ -61,3 +61,17 @@ spring.influxdb.write-timeout=10
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
tdlUsed={0}\u7684\u4F20\u611F\u5668\u5DF2\u7ECF\u88AB\u4F7F\u7528
cargoNo = \u8D27\u7269\u7F16\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
circuitSuccess = \u6DFB\u52A0\u7EBF\u8DEF\u6210\u529F
circuitFailure = \u6DFB\u52A0\u7EBF\u8DEF\u5931\u8D25
......@@ -205,7 +206,8 @@ updateGatewaySuccess=\u4FEE\u6539\u7F51\u5173\u6210\u529F
updateGatewayFailure=\u4FEE\u6539\u7F51\u5173\u5931\u8D25
updateGatewayByModelSuccess=\u901A\u8FC7\u6A21\u677F\u4FEE\u6539\u8BBE\u5907\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
updateGatewayCompanyFailure=\u7F51\u5173\u5206\u914D\u516C\u53F8\u5931\u8D25
#TDL
......
......@@ -4,20 +4,21 @@
<!--获取所有的报警数据-->
<select id="getAll" resultType="com.example.tdl.domain.vo.ResultAlarmLog">
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;
</select>
<select id="getByTransportationNo" resultType="com.example.tdl.domain.vo.ResultAlarmLog" parameterType="String">
select transportationNo,TDLSN,description,ifnull(data,"") data,alarmTime,classify from alarm_log
where transportationNo=#{transportationNo,jdbcType=VARCHAR}
order by alarmTime DESC
</select>
<!--根据条件获取报警数据-->
<select id="getAlarmLog" parameterType="String" resultType="com.example.tdl.domain.vo.AlarmLogVo">
select transportationNo,description,ifnull(data,"") data,alarmTime
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'))
order by alarmTime desc
</select>
......@@ -41,36 +42,36 @@
<select id="getCount" parameterType="String" resultType="java.lang.Integer">
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'))
</select>
<select id="getBumpCount" resultType="java.lang.Integer" >
select count(DISTINCT transportationNo) 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'))
</select>
<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"
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'))
UNION ALL
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'))
UNION ALL
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'))
UNION ALL
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'))
UNION ALL
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'))
</select>
......@@ -110,7 +111,7 @@
<select id="getRealTimeAlarm" parameterType="java.lang.String" resultType="com.example.tdl.domain.vo.AlarmLogVo">
select transportationNo,description,ifnull(FORMAT(data,2),"") data,alarmTime
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'))
order by alarmTime desc limit 3
</select>
......
......@@ -5,14 +5,14 @@
<select id="getAll" resultType="com.example.tdl.domain.vo.ResultAlarmVo" parameterType="String">
SELECT alarmType,temMax,temMin,humidityMax,humidityMin,tilt,shock,remark
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 id="getAllByAlarmType" resultType="com.example.tdl.domain.vo.ResultAlarmVo" parameterType="String">
SELECT alarmType,temMax,temMin,humidityMax,humidityMin,tilt,shock,remark
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}), '%')
</select>
......@@ -27,7 +27,7 @@
#{humidityMin,jdbcType=FLOAT},
#{tilt,jdbcType=FLOAT},
#{shock,jdbcType=VARCHAR},
(SELECT id from company where companyName=#{companyName,jdbcType=VARCHAR}),
(SELECT id from company where companyNo=#{companyNo,jdbcType=VARCHAR}),
#{remark,jdbcType=VARCHAR}
)
</insert>
......@@ -44,25 +44,25 @@
shock=#{shock,jdbcType=VARCHAR},
remark=#{remark,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>
<!--删除预警信息-->
<delete id="delAlarm" parameterType="com.example.tdl.domain.vo.DelAlarmVo">
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>
<!--根据预警类型和预警场景查询-->
<select id="getByType" parameterType="String" resultType="com.example.tdl.domain.vo.ResultAlarmVo">
SELECT alarmType,temMax,temMin,humidityMax,humidityMin,tilt,shock,remark
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}
</select>
<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
where warehouseNo=#{warehouseNo,jdbcType=VARCHAR}
AND gatewaySN=#{gatewaySN,jdbcType=VARCHAR}
......
This diff is collapsed.
......@@ -3,7 +3,12 @@
<mapper namespace="com.example.tdl.mapper.CompanyMapper">
<!--查询所有公司信息-->
<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>
<insert id="addCompany" parameterType="com.example.tdl.domain.vo.AddCompanyVo">
......
......@@ -110,9 +110,10 @@
<!--根据仓库编号查询网关信息-->
<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}
AND endTime is null
and ISNULL(endTime)
</select>
......
......@@ -43,7 +43,7 @@
NULL ,
NULL,
NULL,
(SELECT id from company where companyName=#{companyName,jdbcType=VARCHAR})
(SELECT id from company where companyNo=#{companyNo,jdbcType=VARCHAR})
)
</insert>
......
......@@ -23,7 +23,9 @@
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
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
</select>
......@@ -54,6 +56,9 @@
<if test="companyName!=null">
AND c.companyName=#{companyName,jdbcType=VARCHAR}
</if>
<if test="companyNo!='TM201803298320'">
and c.companyNo=#{companyNo,jdbcType=VARCHAR}
</if>
AND u.state=1
</select>
......@@ -137,4 +142,9 @@
select COUNT(id) from `user`
WHERE role_id=(select id from role where roleName=#{roleName,jdbcType=VARCHAR});
</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>
\ No newline at end of file
......@@ -9,7 +9,7 @@
where c.id = w.company_id
and r.id = w.region_id
and ct.id = w.city_id
and c.companyName=#{companyName,jdbcType=VARCHAR}
and c.companyNo=#{companyNo,jdbcType=VARCHAR}
order by createTime desc
</select>
......@@ -21,7 +21,7 @@
where c.id = w.company_id
and r.id = w.region_id
and ct.id = w.city_id
and c.companyName=#{companyName,jdbcType=VARCHAR}
and c.companyNo=#{companyNo,jdbcType=VARCHAR}
<if test="warehouseName!=null">
AND warehouseName like CONCAT(CONCAT('%',#{warehouseName,jdbcType=VARCHAR}), '%')
</if>
......@@ -54,8 +54,8 @@
where c.id = w.company_id
and r.id = w.region_id
and ct.id = w.city_id
and c.companyName=#{companyName,jdbcType=VARCHAR}
AND warehouseName=#{warehouseName,jdbcType=VARCHAR}
and c.companyNo=#{companyNo,jdbcType=VARCHAR}
</select>
<insert id="addWarehouse" parameterType="java.util.Map" statementType="CALLABLE">
......@@ -149,6 +149,7 @@
]]>
</insert>
<update id="untieGateway" parameterType="java.util.Map" statementType="CALLABLE">
<![CDATA[
{
......@@ -181,15 +182,15 @@
</select>
<select id="getByWarehouseNoAndSN" resultType="java.lang.Integer" parameterType="String">
select count(w.warehouseNo) from gateway_warehouse gw,warehouse w,gateway g
where gw.gateway_id=g.id
and gw.warehouse_id = w.id
select count(w.warehouseNo) from tdl_gateway_log tgl,warehouse w,gateway g
where tgl.warehouseNo=w.warehouseNo
and tgl.gatewaySN = g.SN
and w.warehouseNo=#{warehouseNo,jdbcType=VARCHAR}
and g.SN=#{SN,jdbcType=VARCHAR}
</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,
type,hardwareLevel,areaIndoor,areaRack,areaOutdoor,areaPlanIndoor,office,timeZone,warehouseInfo,w.remark
from warehouse w,alarm a ,region r,company c,city ct
......@@ -199,15 +200,16 @@
and w.company_id= c.id
and a.company_id =c.id
AND a.alarmType=#{alarmType,jdbcType=VARCHAR}
and c.companyName=#{companyName,jdbcType=VARCHAR}
</select>-->
AND a.alarmScene=#{alarmScene,jdbcType=VARCHAR}
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 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
where c.id=w.company_id
and ct.id = w.city_id
and c.companyName = #{companyName,jdbcType=VARCHAR}
and c.companyNo=#{companyNo,jdbcType=VARCHAR}
<if test="warehouseName!=null">
AND warehouseName like CONCAT(CONCAT('%',#{warehouseName,jdbcType=VARCHAR}), '%')
</if>
......@@ -217,6 +219,7 @@
<if test="city!=null">
AND ct.city like CONCAT(CONCAT('%',#{city,jdbcType=VARCHAR}), '%')
</if>
</select>
<select id="getDevice" parameterType="String" resultType="com.example.tdl.domain.vo.DeviceVo">
......@@ -240,8 +243,8 @@
</select>
<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 COUNT(TDLSN) from tdl_gateway_log WHERE warehouseNo=w.warehouseNo) tdlCounts,property,type,hardwareLevel,areaPlanIndoor
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 and ISNULL(endTime)) tdlCounts,property,type,hardwareLevel,areaPlanIndoor
from warehouse w INNER JOIN city c ON w.city_id=c.id
where warehouseNo=#{warehouseNo,jdbcType=VARCHAR}
</select>
......@@ -259,4 +262,11 @@
AND t.TDLSN=#{TDLSN,jdbcType=VARCHAR}
</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>
\ 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