Commit 4b799ee6 authored by chenying's avatar chenying

Merge remote-tracking branch 'origin/master'

parents d5a5f3a0 167e9288
...@@ -49,6 +49,7 @@ dependencies { ...@@ -49,6 +49,7 @@ dependencies {
compile ('com.github.miwurster:spring-data-influxdb:1.6') compile ('com.github.miwurster:spring-data-influxdb:1.6')
compile('com.aliyun.oss:aliyun-sdk-oss:2.5.0') compile('com.aliyun.oss:aliyun-sdk-oss:2.5.0')
compile('org.apache.poi:poi:3.9') compile('org.apache.poi:poi:3.9')
compile('org.springframework.boot:spring-boot-starter-mail')
} }
jar { jar {
String someString = '' String someString = ''
......
package com.example.tdl.config;
import com.example.tdl.domain.vo.AlarmContactsVo;
import com.example.tdl.domain.vo.ResultWarehouseVo;
import com.example.tdl.domain.vo.WarehouseAlarmLog;
import com.example.tdl.domain.vo.WarehouseCountVo;
import com.example.tdl.service.TDLLogService;
import com.example.tdl.service.WarehouseAlarmLogService;
import com.example.tdl.service.WarehouseService;
import com.example.tdl.util.MailUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.text.SimpleDateFormat;
import java.util.*;
@Component
public class ScheduleConfig {
private final Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private WarehouseService warehouseService;
@Autowired
private TDLLogService tdlLogService;
@Autowired
private WarehouseAlarmLogService warehouseAlarmLogService;
@Scheduled(cron ="0 0 1 * * ?") //每隔一小时执行一次
public void scheduler() {
Long endTime = System.currentTimeMillis();
Long startTime = endTime-12*60*60*1000l;
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//获取所有的仓库信息
List<ResultWarehouseVo> resultWarehouseList = warehouseService.getAll("TM201803298320");
for(int i =0,length = resultWarehouseList.size();i<length;i++){
//获取相关的报警联系人
List<String> emailList = warehouseService.getEmailByWarehouse(resultWarehouseList.get(i).getWarehouseNo());
if(emailList.size() == 0){
continue;
}
//查询报警情况
List<WarehouseCountVo> tempCount = warehouseAlarmLogService.getCount(resultWarehouseList.get(i).getWarehouseNo(),startTime,endTime,"Temperature");
List<WarehouseCountVo> humCount = warehouseAlarmLogService.getCount(resultWarehouseList.get(i).getWarehouseNo(),startTime,endTime,"humity");
if(tempCount.size() == 0 && humCount.size() == 0){
continue;
}
try {
MailUtil.sendMail(emailList, "辉度物流监测系统------仓库报警提醒",
message(sdf.format(new Date(Long.parseLong(String.valueOf(startTime)))),
sdf.format(new Date(Long.parseLong(String.valueOf(endTime)))),
getSumCount(tempCount),
getMaxTime(tempCount),
getSumCount(humCount),
getMaxTime(humCount)));
}catch (Exception e){
e.printStackTrace();
}
}
}
public String message(String startTime,String endTime,Integer tempCount,String tempTime,Integer humCount,String humTime){
String html="<!DOCTYPE html>\n" +
"<html lang=\"en\">\n" +
"<head>\n" +
" <meta charset=\"UTF-8\">\n" +
" <title>Title</title>\n" +
"</head>\n" +
"<body style=\"align-content: center;\">\n" +
" <div style=\"width: 800px;margin: 0px auto;\">\n" +
" <div style=\"font-size: 15px;\">\n" +
" <p>尊敬的用户,您好:</p>\n" +
" <p>&nbsp;&nbsp;&nbsp;&nbsp;自"+startTime+"到"+endTime+",您所管理的仓库报警情况如下:</p>" +
" <p>&nbsp;&nbsp;&nbsp;&nbsp;发生温度报警"+tempCount+"次,主要集中在"+tempTime+";" +
" <p>&nbsp;&nbsp;&nbsp;&nbsp;发生湿度报警"+humCount+"次,主要集中在"+humTime+"</p>\n" +
" <br>\n" +
" <p>致好!</p>\n" +
" <p>上海辉度智能系统有限公司</p>\n" +
" <br>\n" +
" </div>\n" +
" <br>\n" +
" <div style=\"background-image: url(http://211.161.200.169:38091/test/dist/assets/images/bg.jpg) ; width: 800px;height: 125px;background-repeat: no-repeat;\">\n" +
" <div style=\"float: left;\">\n" +
" <div style=\"width:240px;height:110px;padding-top:15px;margin-left: 45px;float: left\">\n" +
" <div style=\"width:85px; height:85px;float: right;padding-top: 5px;padding-right: 8px\">\n" +
" <img src=\"http://211.161.200.169:38091/test/dist/assets/images/WitiumGuan.png \" width=\"85\" height=\"85\">\n" +
" </div>\n" +
" <span style=\"display:block;font-size: small;font-family: Arial;margin-left: 13px;font-weight: 300;padding-top: 36px\">辉度官方网站</span>\n" +
" <a href=\"http://www.witium.cn\"><img src=\"http://211.161.200.169:38091/test/dist/assets/images/guan.png\" width=\"110\" height=\"35\" style=\"margin-top: 3px\"></a>\n" +
" </div>\n" +
" <div style=\"width:240px;height:110px;margin-top:-110px;margin-left: 310px;float: inherit;\" >\n" +
" <div style=\"width:85px; height:85px;float: right;padding-top: 5px;padding-right: 8px\">\n" +
" <img src=\"http://211.161.200.169:38091/test/dist/assets/images/WitCloud.png \" width=\"85\" height=\"85\">\n" +
" </div>\n" +
" <span style=\"display:block;font-size: small;font-family: Arial;margin-left: 15px;font-weight: 300;padding-top: 50px\">云平台网站</span>\n" +
" </div>\n" +
" <div style=\"width:240px;height:110px;margin-top: -110px;float: right;\">\n" +
" <div style=\"width:85px; height:85px;float: right;padding-top: 4px;padding-right: 8px\">\n" +
" <img src=\"http://211.161.200.169:38091/test/dist/assets/images/Witium.jpg \" width=\"85\" height=\"85\">\n" +
" </div>\n" +
" <span style=\"display:block;font-size: small;font-family: Arial;margin-left: 35px;font-weight: 300;padding-top: 50px\">辉度微信公众号</span>\n" +
" </div>\n" +
" </div>\n" +
" </div>\n" +
" <div style=\"width: 800px;height:40px;font-size: 14px;background-color: #2196F3;\">\n" +
" <span style=\"display:block;color: #f8f7ff;text-align: center;padding: 10px;\">\n" +
" TEL:086-21-37774020&nbsp;&nbsp;&nbsp;&nbsp;FAX:086-21-37774010&nbsp;&nbsp;&nbsp;&nbsp;Email:sales@witium.com\n" +
" </span>\n" +
" </div>\n" +
" </div>\n" +
"</body>\n" +
"</html>";
return html;
}
public Integer getSumCount(List<WarehouseCountVo> counts){
Integer num = 0;
for(int i = 0;i<counts.size();i++){
num = num +counts.get(i).getNum();
}
return num;
}
public String getMaxTime(List<WarehouseCountVo> counts){
String time="";
Collections.sort(counts, Comparator.comparing(WarehouseCountVo::getNum));
return counts.get(0).getHours();
}
}
...@@ -9,26 +9,12 @@ public class GatewayOnLineVo { ...@@ -9,26 +9,12 @@ public class GatewayOnLineVo {
private Integer state; private Integer state;
private Long startTime;
private String battery; private String battery;
private List<TDLDeviceDetailVo> tdlDeviceDetailVos; private List<TDLDeviceDetailVo> tdlDeviceDetailVos;
public List<TDLDeviceDetailVo> getTdlDeviceDetailVos() {
return tdlDeviceDetailVos;
}
public void setTdlDeviceDetailVos(List<TDLDeviceDetailVo> tdlDeviceDetailVos) {
this.tdlDeviceDetailVos = tdlDeviceDetailVos;
}
public String getBattery() {
return battery;
}
public void setBattery(String battery) {
this.battery = battery;
}
public String getSN() { public String getSN() {
return SN; return SN;
} }
...@@ -52,4 +38,28 @@ public class GatewayOnLineVo { ...@@ -52,4 +38,28 @@ public class GatewayOnLineVo {
public void setState(Integer state) { public void setState(Integer state) {
this.state = state; this.state = state;
} }
public Long getStartTime() {
return startTime;
}
public void setStartTime(Long startTime) {
this.startTime = startTime;
}
public String getBattery() {
return battery;
}
public void setBattery(String battery) {
this.battery = battery;
}
public List<TDLDeviceDetailVo> getTdlDeviceDetailVos() {
return tdlDeviceDetailVos;
}
public void setTdlDeviceDetailVos(List<TDLDeviceDetailVo> tdlDeviceDetailVos) {
this.tdlDeviceDetailVos = tdlDeviceDetailVos;
}
} }
package com.example.tdl.domain.vo;
public class WarehouseAlarmLog {
private String warehouseNo;
private String gSN;
private String gType;
private String TDLSN;
private String description;
private Float data;
private Long alarmTime;
private String desp;
private Integer alarmNo;
public WarehouseAlarmLog() {
}
public WarehouseAlarmLog(String warehouseNo, String gSN, String gType, String TDLSN, String description, Float data, Long alarmTime, String desp, Integer alarmNo) {
this.warehouseNo = warehouseNo;
this.gSN = gSN;
this.gType = gType;
this.TDLSN = TDLSN;
this.description = description;
this.data = data;
this.alarmTime = alarmTime;
this.desp = desp;
this.alarmNo = alarmNo;
}
public String getWarehouseNo() {
return warehouseNo;
}
public void setWarehouseNo(String warehouseNo) {
this.warehouseNo = warehouseNo;
}
public String getgSN() {
return gSN;
}
public void setgSN(String gSN) {
this.gSN = gSN;
}
public String getgType() {
return gType;
}
public void setgType(String gType) {
this.gType = gType;
}
public String getTDLSN() {
return TDLSN;
}
public void setTDLSN(String TDLSN) {
this.TDLSN = TDLSN;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Float getData() {
return data;
}
public void setData(Float data) {
this.data = data;
}
public Long getAlarmTime() {
return alarmTime;
}
public void setAlarmTime(Long alarmTime) {
this.alarmTime = alarmTime;
}
public String getDesp() {
return desp;
}
public void setDesp(String desp) {
this.desp = desp;
}
public Integer getAlarmNo() {
return alarmNo;
}
public void setAlarmNo(Integer alarmNo) {
this.alarmNo = alarmNo;
}
}
package com.example.tdl.domain.vo;
public class WarehouseCountVo {
private String hours;
private Integer num;
public String getHours() {
return hours;
}
public void setHours(String hours) {
this.hours = hours;
}
public Integer getNum() {
return num;
}
public void setNum(Integer num) {
this.num = num;
}
}
...@@ -29,6 +29,8 @@ public interface GatewayMapper { ...@@ -29,6 +29,8 @@ public interface GatewayMapper {
String getTransportationNo(@Param("SN") String SN,@Param("type") String type); String getTransportationNo(@Param("SN") String SN,@Param("type") String type);
String getWarehouseNo(@Param("SN") String SN,@Param("type") String type);
List<GatewaySNVo> getUnusedGateway(@Param("SN") String SN,@Param("companyNo") String companyNo); List<GatewaySNVo> getUnusedGateway(@Param("SN") String SN,@Param("companyNo") String companyNo);
int updateCompany(UpdateGatewayCompanyVo updateGatewayCompanyVo); int updateCompany(UpdateGatewayCompanyVo updateGatewayCompanyVo);
......
package com.example.tdl.mapper;
import com.example.tdl.domain.vo.WarehouseAlarmLog;
import com.example.tdl.domain.vo.WarehouseCountVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface WarehouseAlarmLogMapper {
Integer add(WarehouseAlarmLog alarmLog);
List<WarehouseCountVo> getCount(@Param("warehouseNo") String warehouseNo, @Param("startTime") Long startTime,@Param("endTime") Long endTime ,@Param("desp")String desp);
}
...@@ -52,4 +52,6 @@ public interface WarehouseMapper { ...@@ -52,4 +52,6 @@ public interface WarehouseMapper {
DeviceMessageVo getDeviceMessage(SearchTdlVo searchTdlVo); DeviceMessageVo getDeviceMessage(SearchTdlVo searchTdlVo);
List<WarehouseNameVo> getWarehouseName(@Param("warehouseName") String warehouseName,@Param("companyNo") String companyNo ); List<WarehouseNameVo> getWarehouseName(@Param("warehouseName") String warehouseName,@Param("companyNo") String companyNo );
List<String> getEmailByWarehouse(String warehouseNo);
} }
...@@ -55,6 +55,10 @@ public class GatewayService { ...@@ -55,6 +55,10 @@ public class GatewayService {
return gatewayMapper.getTransportationNo(SN,type); return gatewayMapper.getTransportationNo(SN,type);
} }
public String getWarehouseNo(String SN,String type){
return gatewayMapper.getWarehouseNo(SN,type);
}
public List<GatewaySNVo> getUnusedGateway(String SN,String companyNo){ public List<GatewaySNVo> getUnusedGateway(String SN,String companyNo){
return gatewayMapper.getUnusedGateway(SN,companyNo); return gatewayMapper.getUnusedGateway(SN,companyNo);
} }
......
package com.example.tdl.service;
import com.example.tdl.domain.vo.WarehouseAlarmLog;
import com.example.tdl.domain.vo.WarehouseCountVo;
import com.example.tdl.mapper.WarehouseAlarmLogMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class WarehouseAlarmLogService {
@Autowired
private WarehouseAlarmLogMapper warehouseAlarmLogMapper;
public Integer add(WarehouseAlarmLog alarmLog){
return warehouseAlarmLogMapper.add(alarmLog);
}
public List<WarehouseCountVo> getCount(String warehouseNo, Long startTime, Long endTime,String desp ){
return warehouseAlarmLogMapper.getCount(warehouseNo,startTime,endTime,desp);
}
}
...@@ -95,4 +95,9 @@ public class WarehouseService { ...@@ -95,4 +95,9 @@ public class WarehouseService {
public List<WarehouseNameVo> getWarehouseName(String warehouseName,String companyNo ){ public List<WarehouseNameVo> getWarehouseName(String warehouseName,String companyNo ){
return warehouseMapper.getWarehouseName(warehouseName,companyNo); return warehouseMapper.getWarehouseName(warehouseName,companyNo);
} }
public List<String> getEmailByWarehouse(String warehouseNo){
return warehouseMapper.getEmailByWarehouse(warehouseNo);
}
} }
...@@ -90,9 +90,9 @@ public class DataUtil { ...@@ -90,9 +90,9 @@ public class DataUtil {
if (count > 500) { if (count > 500) {
long times = ( resultCircuitVo.getEndTime() * 1000000l - startTime) / 500; long times = ( resultCircuitVo.getEndTime() * 1000000l - startTime) / 500;
if (resultCircuitVo.getEndTime() != null && resultCircuitVo.getEndTime() != 0) { if (resultCircuitVo.getEndTime() != null && resultCircuitVo.getEndTime() != 0) {
sql = getSQL( field, device, devList.get(i), startTime, resultCircuitVo.getEndTime() * 1000000l); sql = getSQL( gatewayVo.getgSN(),field, device, devList.get(i), startTime, resultCircuitVo.getEndTime() * 1000000l);
} else { } else {
sql = getSQL( field, device, devList.get(i), startTime, System.currentTimeMillis() * 1000000l); sql = getSQL(gatewayVo.getgSN(), field, device, devList.get(i), startTime, System.currentTimeMillis() * 1000000l);
} }
QueryResult queryResult = influxDBTemplate.query(new Query(sql, database,false)); QueryResult queryResult = influxDBTemplate.query(new Query(sql, database,false));
if (queryResult.getResults() != null) { if (queryResult.getResults() != null) {
...@@ -224,15 +224,29 @@ public class DataUtil { ...@@ -224,15 +224,29 @@ public class DataUtil {
// return gson.toJson(historyDataVoList); // return gson.toJson(historyDataVoList);
// } // }
public static String getSQL(String field, String device, String tdl, Long startTime, Long endTime) { public static String getSQL(String SN,String field, String device, String tdl, Long startTime, Long endTime) {
String sql = ""; String sql = "";
long times = (endTime - startTime) / 500; long times = (endTime - startTime) / 500;
for (int i = 0; i < 499; i++) { for (int i = 0; i < 500; i++) {
Long maxTime = startTime + times; Long maxTime = startTime + times;
sql = sql + "Select " + field + " From \"tdl_policy\".\"" + device + "\" where \"tdl\"='" + tdl + "' AND \"topic\" = 'Data' AND \"data_type\" = 'data' AND \"topic\" = 'Data' AND \"event\" = 'Regular measurement' AND \"data_id\" = '2' and time >= "+startTime +" and time <= " + maxTime + " order by time limit 1;"; sql = sql + "Select " + field + " From \"tdl_policy\".\"" + device + "\" where " +
startTime = maxTime; " \"SN\" = '"+SN+"' " +
" AND \"topic\" = 'Data' " +
" AND \"data_type\" = 'data' " +
" AND \"tdl\"='" + tdl + "' " +
" AND \"event\" = 'Regular measurement' " +
" AND \"data_id\" = '2' " +
"and time >= "+startTime +" and time <= " + maxTime + " order by time limit 1;";
startTime = maxTime;
} }
sql = sql + "Select " + field + " From \"tdl_policy\".\"" + device + "\" where \"tdl\"='" + tdl + "' AND \"topic\" = 'Data' AND \"data_type\" = 'data' AND \"topic\" = 'Data' AND \"event\" = 'Regular measurement' AND \"data_id\" = '2' and time >="+startTime+" and time <= " + endTime + " order by time desc limit 1;"; sql = sql + "Select " + field + " From \"tdl_policy\".\"" + device + "\" where " +
" \"SN\" = '"+SN+"' " +
" AND \"topic\" = 'Data' " +
" AND \"data_type\" = 'data' " +
" AND \"tdl\"='" + tdl + "' " +
" AND \"event\" = 'Regular measurement' " +
" AND \"data_id\" = '2' " +
"and time >= "+startTime+" and time <= " + endTime + " order by time desc limit 1;";
return sql; return sql;
} }
......
package com.example.tdl.util;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMessage.RecipientType;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
public class MailUtil {
public static void sendMail(List<String> toAddressStr, String subject, String text) throws Exception{
//设置发送邮件需要的属性
Properties props = new Properties();
//主机地址
props.put("mail.smtp.host", "smtp.qiye.163.com");
//是否打开验证:必须打开
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.socketFactory.class","javax.net.ssl.SSLSocketFactory");
props.setProperty("mail.smtp.socketFactory.fallback","false");
props.setProperty("mail.smtp.port","465");
props.setProperty("mail.smtp.socketFactory.port","465");
//取的与邮件服务器连接
Session session = Session.getDefaultInstance(props);
//创建一封邮件
MimeMessage mimeMessage = new MimeMessage(session);
//设置发送地址
InternetAddress fromAddress = new InternetAddress("postmaster@witium.com");
mimeMessage.setFrom(fromAddress);
//设置接收地址(多个)
InternetAddress[] address = new InternetAddress[toAddressStr.size()];
for(int i = 0;i<toAddressStr.size();i++){
address[i] = new InternetAddress(toAddressStr.get(i)) ;
}
//第一个参数:to,发送 ; cc,抄送 ; bcc,暗送
//第二个参数:接收者的地址
mimeMessage.setRecipients(RecipientType.TO, address);
//设置标题
mimeMessage.setSubject(subject, "UTF-8");
//设置正文
mimeMessage.setContent(text,"text/html;charset=utf-8");
//发送:坐火箭
Transport transport = session.getTransport("smtp");
transport.connect("postmaster@witium.com", "dJZU4LXZtpRc1Ybz");
//第一个参数:邮件
//第二个参数:接收地址
transport.sendMessage(mimeMessage, mimeMessage.getAllRecipients());
//关闭
transport.close();
System.out.println("ok");
}
}
...@@ -61,6 +61,9 @@ public class AlarmLogController { ...@@ -61,6 +61,9 @@ public class AlarmLogController {
@Autowired @Autowired
private InfluxDBTemplate influxDBTemplate; private InfluxDBTemplate influxDBTemplate;
@Autowired
private WarehouseAlarmLogService warehouseAlarmLogService;
private final static String database ="original"; private final static String database ="original";
@Value("${mqtt.userName}") @Value("${mqtt.userName}")
...@@ -181,39 +184,69 @@ public class AlarmLogController { ...@@ -181,39 +184,69 @@ public class AlarmLogController {
map.put(3,"过高"); map.put(3,"过高");
map.put(4,"过低"); map.put(4,"过低");
map.put(5,"未知"); map.put(5,"未知");
//根据gateway的信息获取线路信息 if(addAlarmLogVo.getMode() == 1){
String transportationNo = gatewayService.getTransportationNo(addAlarmLogVo.getGsn(),addAlarmLogVo.getGtype()); //根据gateway的信息获取线路信息
//获取终点,起点 String transportationNo = gatewayService.getTransportationNo(addAlarmLogVo.getGsn(),addAlarmLogVo.getGtype());
ResultCircuitVo resultCircuitVo = circuitService.getCircuit(transportationNo); //获取终点,起点
for(int i = 0,length=addAlarmLogVo.getAlarm().size();i<length;i++){ ResultCircuitVo resultCircuitVo = circuitService.getCircuit(transportationNo);
if(addAlarmLogVo.getAlarm().get(i).getAlarmno() !=null && addAlarmLogVo.getAlarm().get(i).getAlarmno() == 0){ for(int i = 0,length=addAlarmLogVo.getAlarm().size();i<length;i++){
continue; if(addAlarmLogVo.getAlarm().get(i).getAlarmno() !=null && addAlarmLogVo.getAlarm().get(i).getAlarmno() == 0){
} continue;
String classify=""; }
String desp = ""; String classify="";
if(addAlarmLogVo.getAlarm().get(i).getAlias().contains("T")){ String desp = "";
desp = "温度" +map.get(addAlarmLogVo.getAlarm().get(i).getAlarmno()); if(addAlarmLogVo.getAlarm().get(i).getAlias().contains("T")){
classify = "1"; desp = "温度" +map.get(addAlarmLogVo.getAlarm().get(i).getAlarmno());
} else if(addAlarmLogVo.getAlarm().get(i).getAlias().contains("h")){ classify = "1";
desp = "湿度" +map.get(addAlarmLogVo.getAlarm().get(i).getAlarmno()); } else if(addAlarmLogVo.getAlarm().get(i).getAlias().contains("h")){
classify = "2"; desp = "湿度" +map.get(addAlarmLogVo.getAlarm().get(i).getAlarmno());
} else if(addAlarmLogVo.getAlarm().get(i).getAlias().contains("a1")){ classify = "2";
desp = "震动" +map.get(addAlarmLogVo.getAlarm().get(i).getAlarmno()); } else if(addAlarmLogVo.getAlarm().get(i).getAlias().contains("a1")){
classify = "3"; desp = "震动" +map.get(addAlarmLogVo.getAlarm().get(i).getAlarmno());
} else if(addAlarmLogVo.getAlarm().get(i).getAlias().contains("ta")) { classify = "3";
desp = "倾角" + map.get(addAlarmLogVo.getAlarm().get(i).getAlarmno()); } else if(addAlarmLogVo.getAlarm().get(i).getAlias().contains("ta")) {
classify = "4"; desp = "倾角" + map.get(addAlarmLogVo.getAlarm().get(i).getAlarmno());
} classify = "4";
AlarmLog alarmLog = new AlarmLog(transportationNo,resultCircuitVo.getStartCity(),resultCircuitVo.getEndCity(),addAlarmLogVo.getAlarm().get(i).getTdlsn().replace("TDL-","").trim(),desp,addAlarmLogVo.getAlarm().get(i).getValue(),addAlarmLogVo.getAlarm().get(i).getTs()*1000,classify,addAlarmLogVo.getAlarm().get(i).getDesp(),addAlarmLogVo.getAlarm().get(i).getAlarmno()); }
int a = alarmLogServcie.addAlarmLog(alarmLog); AlarmLog alarmLog = new AlarmLog(transportationNo,resultCircuitVo.getStartCity(),resultCircuitVo.getEndCity(),addAlarmLogVo.getAlarm().get(i).getTdlsn().replace("TDL-","").trim(),desp,addAlarmLogVo.getAlarm().get(i).getValue(),addAlarmLogVo.getAlarm().get(i).getTs()*1000,classify,addAlarmLogVo.getAlarm().get(i).getDesp(),addAlarmLogVo.getAlarm().get(i).getAlarmno());
if(a == 0){ int a = alarmLogServcie.addAlarmLog(alarmLog);
fb.setCode(0); if(a == 0){
fb.setMessage("添加失败"); fb.setCode(0);
}else{ fb.setMessage("添加失败");
fb.setCode(1); }else{
fb.setMessage("添加成功"); fb.setCode(1);
fb.setMessage("添加成功");
}
} }
}else{
//根据gateway获取仓库编号
String warehouseNo = gatewayService.getWarehouseNo(addAlarmLogVo.getGsn(),addAlarmLogVo.getGtype());
for(int i = 0,length=addAlarmLogVo.getAlarm().size();i<length;i++){
if(addAlarmLogVo.getAlarm().get(i).getAlarmno() !=null && addAlarmLogVo.getAlarm().get(i).getAlarmno() == 0){
continue;
}
String desp = "";
if(addAlarmLogVo.getAlarm().get(i).getAlias().contains("T")){
desp = "温度" +map.get(addAlarmLogVo.getAlarm().get(i).getAlarmno());
} else if(addAlarmLogVo.getAlarm().get(i).getAlias().contains("h")){
desp = "湿度" +map.get(addAlarmLogVo.getAlarm().get(i).getAlarmno());
} else if(addAlarmLogVo.getAlarm().get(i).getAlias().contains("a1")){
desp = "震动" +map.get(addAlarmLogVo.getAlarm().get(i).getAlarmno());
} else if(addAlarmLogVo.getAlarm().get(i).getAlias().contains("ta")) {
desp = "倾角" + map.get(addAlarmLogVo.getAlarm().get(i).getAlarmno());
}
WarehouseAlarmLog alarmLog = new WarehouseAlarmLog(warehouseNo,addAlarmLogVo.getGsn(),addAlarmLogVo.getGtype(),addAlarmLogVo.getAlarm().get(i).getTdlsn().replace("TDL-","").trim(),desp,addAlarmLogVo.getAlarm().get(i).getValue(),addAlarmLogVo.getAlarm().get(i).getTs()*1000,addAlarmLogVo.getAlarm().get(i).getDesp(),addAlarmLogVo.getAlarm().get(i).getAlarmno());
int a = warehouseAlarmLogService.add(alarmLog);
if(a == 0){
fb.setCode(0);
fb.setMessage("添加失败");
}else{
fb.setCode(1);
fb.setMessage("添加成功");
}
}
} }
return gson.toJson(fb); return gson.toJson(fb);
} }
......
...@@ -253,7 +253,7 @@ public class CircuitController { ...@@ -253,7 +253,7 @@ public class CircuitController {
if(StringUtils.isEmpty(circuitTermVo.getCargoNo())){ if(StringUtils.isEmpty(circuitTermVo.getCargoNo())){
circuitTermVo.setCargoNo(null); circuitTermVo.setCargoNo(null);
} }
if(circuitTermVo.getCircuitState() == null){ if(circuitTermVo.getCircuitState() == null || circuitTermVo.getCircuitState() == 3){
circuitTermVo.setCircuitState(null); circuitTermVo.setCircuitState(null);
} }
if(circuitTermVo.getStartTime()==null){ if(circuitTermVo.getStartTime()==null){
......
...@@ -295,10 +295,10 @@ public class DataController { ...@@ -295,10 +295,10 @@ public class DataController {
String sql = ""; String sql = "";
if (count > 500) { if (count > 500) {
if (resultCircuitVo.getEndTime() != null && resultCircuitVo.getEndTime() != 0) { if (resultCircuitVo.getEndTime() != null && resultCircuitVo.getEndTime() != 0) {
sql = DataUtil.getSQL(list.get(j), device, devList.get(i), startTime, resultCircuitVo.getEndTime() * 1000000l); sql = DataUtil.getSQL(gatewayVo.getgSN(),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 "; // 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 = DataUtil.getSQL(list.get(j), device, devList.get(i), startTime, System.currentTimeMillis() * 1000000l); sql = DataUtil.getSQL(gatewayVo.getgSN(),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"; // 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));
...@@ -326,11 +326,6 @@ public class DataController { ...@@ -326,11 +326,6 @@ public class DataController {
dataVo.setDataList(historyDataVoList); dataVo.setDataList(historyDataVoList);
dataVoList.add(dataVo); 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());
// }
logger.info(System.currentTimeMillis()-time+"-----time"); logger.info(System.currentTimeMillis()-time+"-----time");
return gson.toJson(dataVoList); return gson.toJson(dataVoList);
} }
......
...@@ -25,6 +25,7 @@ import org.springframework.expression.spel.ast.NullLiteral; ...@@ -25,6 +25,7 @@ import org.springframework.expression.spel.ast.NullLiteral;
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.DecimalFormat;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
...@@ -218,10 +219,9 @@ public class WarehouseController { ...@@ -218,10 +219,9 @@ public class WarehouseController {
simpleWarehouseVos.get(i).setHumidity("~"); simpleWarehouseVos.get(i).setHumidity("~");
continue; continue;
} }
Long time = (System.currentTimeMillis()-10*60*1000)*1000000l;
String tdl = list.get(j).getTdl().replace(",","\' or \"tdl\" = \'"); String tdl = list.get(j).getTdl().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(j).getDevice()+"\" where \"tdl\" = \'"+ tdl +"\' GROUP BY \"tdl\" order by time desc limit 1"; sql = "SELECT \"T\",\"h\" FROM \"tdl_policy\".\""+list.get(j).getDevice()+"\" where \"tdl\" = \'"+ tdl +"\' and time >="+ list.get(j).getStartTime() +" 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("~");
...@@ -243,6 +243,8 @@ public class WarehouseController { ...@@ -243,6 +243,8 @@ public class WarehouseController {
return simpleWarehouseVos; return simpleWarehouseVos;
} }
//根据仓库编号获取仓库信息 //根据仓库编号获取仓库信息
@ApiOperation(value = "根据仓库编号获取仓库信息",notes = "根据仓库编号获取仓库信息,传值说明:" + @ApiOperation(value = "根据仓库编号获取仓库信息",notes = "根据仓库编号获取仓库信息,传值说明:" +
" {" + " {" +
...@@ -322,7 +324,7 @@ public class WarehouseController { ...@@ -322,7 +324,7 @@ public class WarehouseController {
}else{ }else{
gatewayOnLineVo.setState(6); gatewayOnLineVo.setState(6);
} }
String sql ="SELECT \"battery\" FROM \"tdl_policy\".\""+list.get(a).getDevice() +"\" ORDER BY time DESC LIMIT 1"; String sql ="SELECT \"battery\" FROM \"tdl_policy\".\""+list.get(a).getDevice() +"\"where time >="+list.get(a).getCreateTime()+" ORDER BY time DESC LIMIT 1";
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) {
if(Double.valueOf(queryResult.getResults().get(0).getSeries().get(0).getValues().get(0).get(1).toString())>0){ if(Double.valueOf(queryResult.getResults().get(0).getSeries().get(0).getValues().get(0).get(1).toString())>0){
...@@ -338,7 +340,7 @@ public class WarehouseController { ...@@ -338,7 +340,7 @@ public class WarehouseController {
for (int b=0;b<tdls.size();b++){ for (int b=0;b<tdls.size();b++){
TDLDeviceDetailVo tdlDeviceDetailVo=new TDLDeviceDetailVo(); TDLDeviceDetailVo tdlDeviceDetailVo=new TDLDeviceDetailVo();
tdlDeviceDetailVo.setGatewaySN(list.get(a).getSN()); tdlDeviceDetailVo.setGatewaySN(list.get(a).getSN());
String sqls ="SELECT \"b\", \"T\", \"h\" FROM \"tdl_policy\".\""+list.get(a).getDevice() +"\" WHERE (\"tdl\" = '"+tdls.get(b)+"') ORDER BY time DESC LIMIT 1"; String sqls ="SELECT \"b\", \"T\", \"h\" FROM \"tdl_policy\".\""+list.get(a).getDevice() +"\" WHERE (\"tdl\" = '"+tdls.get(b)+"') and time>="+list.get(a).getEndTime()+" ORDER BY time DESC LIMIT 1";
QueryResult queryResults = influxDBTemplate.query(new Query(sqls, database)); QueryResult queryResults = influxDBTemplate.query(new Query(sqls, database));
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())); tdlDeviceDetailVo.setTime(parseTime(queryResults.getResults().get(0).getSeries().get(0).getValues().get(0).get(0).toString()));
...@@ -362,6 +364,7 @@ public class WarehouseController { ...@@ -362,6 +364,7 @@ public class WarehouseController {
} }
//根据仓库获取用户 //根据仓库获取用户
@ApiOperation(value="获取报警联系人",notes = "获取报警联系人,传值:仓库编号") @ApiOperation(value="获取报警联系人",notes = "获取报警联系人,传值:仓库编号")
@ApiImplicitParams({ @ApiImplicitParams({
...@@ -387,6 +390,8 @@ public class WarehouseController { ...@@ -387,6 +390,8 @@ public class WarehouseController {
return warehouseService.getAlarmContacts(warehouseNo); return warehouseService.getAlarmContacts(warehouseNo);
} }
//获取某个仓库的网关 //获取某个仓库的网关
@ApiOperation(value="添加网关",notes = "添加网关,传值:" + @ApiOperation(value="添加网关",notes = "添加网关,传值:" +
"warehouseNo:仓库编号" + "warehouseNo:仓库编号" +
...@@ -415,6 +420,8 @@ public class WarehouseController { ...@@ -415,6 +420,8 @@ public class WarehouseController {
return warehouseService.getGateway(warehouseNo); return warehouseService.getGateway(warehouseNo);
} }
//添加仓库信息 //添加仓库信息
@ApiOperation(value = "添加仓库信息",notes = "添加仓库信息,传值说明:" + @ApiOperation(value = "添加仓库信息",notes = "添加仓库信息,传值说明:" +
" img:图片地址" + " img:图片地址" +
...@@ -496,8 +503,8 @@ public class WarehouseController { ...@@ -496,8 +503,8 @@ public class WarehouseController {
fb.setMessage(i18n.getMessage(request,"property")); fb.setMessage(i18n.getMessage(request,"property"));
return gson.toJson(fb); return gson.toJson(fb);
} }
if (!"供应中心".equals(addWarehouseVo.getProperty())&&!"项目仓".equals(addWarehouseVo.getProperty())&& if (!"供应中心".equals(addWarehouseVo.getProperty())&&!"冷藏库".equals(addWarehouseVo.getProperty())&&
!"中心仓".equals(addWarehouseVo.getProperty())&&!"X-dock".equals(addWarehouseVo.getProperty())){ !"中心".equals(addWarehouseVo.getProperty())){
fb.setCode(0); fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"wrongProperty")); fb.setMessage(i18n.getMessage(request,"wrongProperty"));
return gson.toJson(fb); return gson.toJson(fb);
...@@ -596,6 +603,8 @@ public class WarehouseController { ...@@ -596,6 +603,8 @@ public class WarehouseController {
} }
//根据仓库编号修改仓库信息 //根据仓库编号修改仓库信息
@ApiOperation(value = "根据仓库编号修改仓库信息",notes = "根据仓库编号修改仓库信息,updatTime不用传,传值说明:" + @ApiOperation(value = "根据仓库编号修改仓库信息",notes = "根据仓库编号修改仓库信息,updatTime不用传,传值说明:" +
" warehouseName:仓库名," + " warehouseName:仓库名," +
...@@ -677,8 +686,8 @@ public class WarehouseController { ...@@ -677,8 +686,8 @@ public class WarehouseController {
fb.setMessage(i18n.getMessage(request,"property")); fb.setMessage(i18n.getMessage(request,"property"));
return gson.toJson(fb); return gson.toJson(fb);
} }
if (!updateWarehouseVo.getProperty().equals("供应中心")&&!updateWarehouseVo.getProperty().equals("项目仓")&& if (!updateWarehouseVo.getProperty().equals("供应中心")&&!updateWarehouseVo.getProperty().equals("冷藏库")&&
!updateWarehouseVo.getProperty().equals("中心仓")&&!updateWarehouseVo.getProperty().equals("X-dock")){ !updateWarehouseVo.getProperty().equals("中心")){
fb.setCode(0); fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"wrongProperty")); fb.setMessage(i18n.getMessage(request,"wrongProperty"));
return gson.toJson(fb); return gson.toJson(fb);
...@@ -693,7 +702,6 @@ public class WarehouseController { ...@@ -693,7 +702,6 @@ public class WarehouseController {
fb.setMessage(i18n.getMessage(request,"wrongWarehouseType")); fb.setMessage(i18n.getMessage(request,"wrongWarehouseType"));
return gson.toJson(fb); return gson.toJson(fb);
} }
if (StringUtils.isEmpty(updateWarehouseVo.getHardwareLevel())){ if (StringUtils.isEmpty(updateWarehouseVo.getHardwareLevel())){
fb.setCode(0); fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"hardwareLevel")); fb.setMessage(i18n.getMessage(request,"hardwareLevel"));
...@@ -777,6 +785,7 @@ public class WarehouseController { ...@@ -777,6 +785,7 @@ public class WarehouseController {
} }
//删除仓库信息 //删除仓库信息
@ApiOperation(value = "删除仓库信息",notes = "删除仓库信息,只用传仓库编号") @ApiOperation(value = "删除仓库信息",notes = "删除仓库信息,只用传仓库编号")
@ApiImplicitParams({ @ApiImplicitParams({
...@@ -816,6 +825,8 @@ public class WarehouseController { ...@@ -816,6 +825,8 @@ public class WarehouseController {
return gson.toJson(fb); return gson.toJson(fb);
} }
@ApiOperation(value="添加网关",notes = "添加网关,传值:" + @ApiOperation(value="添加网关",notes = "添加网关,传值:" +
"warehouseNo:仓库编号" + "warehouseNo:仓库编号" +
"SN:网关编号" + "SN:网关编号" +
...@@ -869,6 +880,8 @@ public class WarehouseController { ...@@ -869,6 +880,8 @@ public class WarehouseController {
return gson.toJson(fb); return gson.toJson(fb);
} }
//绑定报警联系人 //绑定报警联系人
@ApiOperation(value="绑定报警联系人",notes = "绑定报警联系人,传值:" + @ApiOperation(value="绑定报警联系人",notes = "绑定报警联系人,传值:" +
"warehouseNo:仓库编号" + "warehouseNo:仓库编号" +
...@@ -922,6 +935,8 @@ public class WarehouseController { ...@@ -922,6 +935,8 @@ public class WarehouseController {
return gson.toJson(fb); return gson.toJson(fb);
} }
//根据仓库编号获取仓库实时数据 //根据仓库编号获取仓库实时数据
@ApiOperation(value = "根据仓库编号获取仓库信息",notes = "根据仓库编号获取仓库信息,传值说明:" + @ApiOperation(value = "根据仓库编号获取仓库信息",notes = "根据仓库编号获取仓库信息,传值说明:" +
" warehouseNo:仓库编号," + " warehouseNo:仓库编号," +
...@@ -959,9 +974,8 @@ public class WarehouseController { ...@@ -959,9 +974,8 @@ public class WarehouseController {
WarehouseGatewayDateVo warehouseGatewayDateVo=new WarehouseGatewayDateVo(); WarehouseGatewayDateVo warehouseGatewayDateVo=new WarehouseGatewayDateVo();
warehouseGatewayDateVo.setgSN(gatewayOnLineVos.get(a).getSN()); warehouseGatewayDateVo.setgSN(gatewayOnLineVos.get(a).getSN());
warehouseGatewayDateVo.setType(gatewayOnLineVos.get(a).getType()); warehouseGatewayDateVo.setType(gatewayOnLineVos.get(a).getType());
String device = gatewayOnLineVos.get(a).getType() + "_" + gatewayOnLineVos.get(a).getSN(); String device = gatewayOnLineVos.get(a).getType() + "_" + gatewayOnLineVos.get(a).getSN();
String sql ="SELECT \"battery\" FROM \"tdl_policy\".\""+device +"\" ORDER BY time DESC LIMIT 1"; String sql ="SELECT \"battery\" FROM \"tdl_policy\".\""+device +"\" where time >="+ gatewayOnLineVos.get(a).getStartTime()*1000000l+" ORDER BY time DESC LIMIT 1";
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) {
if(Double.valueOf(queryResult.getResults().get(0).getSeries().get(0).getValues().get(0).get(1).toString())>0){ if(Double.valueOf(queryResult.getResults().get(0).getSeries().get(0).getValues().get(0).get(1).toString())>0){
...@@ -994,7 +1008,7 @@ public class WarehouseController { ...@@ -994,7 +1008,7 @@ public class WarehouseController {
List<WarehouseTimeAndDataVo> warehouseTimeAndDataVos1 = new ArrayList<>(); List<WarehouseTimeAndDataVo> warehouseTimeAndDataVos1 = new ArrayList<>();
WarehouseDataVo warehouseDataVo=new WarehouseDataVo(); WarehouseDataVo warehouseDataVo=new WarehouseDataVo();
warehouseDataVo.setTDLSN(tdls.get(b).replace("TDL-","").trim()); 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)+"' AND time >="+ gatewayOnLineVos.get(a).getStartTime()*1000000l+" ORDER BY time ";
QueryResult queryResults = influxDBTemplate.query(new Query(sqls, database)); QueryResult queryResults = influxDBTemplate.query(new Query(sqls, database));
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());
if (queryResults.getResults().get(0).getSeries() != null) { if (queryResults.getResults().get(0).getSeries() != null) {
...@@ -1035,6 +1049,8 @@ public class WarehouseController { ...@@ -1035,6 +1049,8 @@ public class WarehouseController {
return warehouseGatewayDateVoList; return warehouseGatewayDateVoList;
} }
//货物仓库某一tdl的温湿度 //货物仓库某一tdl的温湿度
@ApiOperation(value="货物仓库某一tdl的温湿度",notes = "货物仓库某一tdl的温湿度,传值:" + @ApiOperation(value="货物仓库某一tdl的温湿度",notes = "货物仓库某一tdl的温湿度,传值:" +
" warehouseNo:仓库编号," + " warehouseNo:仓库编号," +
...@@ -1230,8 +1246,9 @@ public class WarehouseController { ...@@ -1230,8 +1246,9 @@ public class WarehouseController {
List<Double> tempList = new ArrayList<>(); List<Double> tempList = new ArrayList<>();
List<Double> humList = new ArrayList<>(); List<Double> humList = new ArrayList<>();
for(int i = 0,length = value.size();i<length;i++){ for(int i = 0,length = value.size();i<length;i++){
tempList.add(value.get(i).get(1)==null ? 0 :Double.valueOf(value.get(i).get(1).toString())); DecimalFormat df = new DecimalFormat(".0");
humList.add(value.get(i).get(2)==null ? 0 :Double.valueOf(value.get(i).get(2).toString())); tempList.add(value.get(i).get(1)==null ? 0 :Double.valueOf(df.format(Double.valueOf(value.get(i).get(1).toString()))));
humList.add(value.get(i).get(2)==null ? 0 :Double.valueOf(df.format(Double.valueOf(value.get(i).get(2).toString()))));
} }
//设置数据 //设置数据
simpleWarehouseVo.setTemp(getValue(tempList)); simpleWarehouseVo.setTemp(getValue(tempList));
......
...@@ -95,6 +95,14 @@ ...@@ -95,6 +95,14 @@
AND type=#{type,jdbcType=VARCHAR})) AND type=#{type,jdbcType=VARCHAR}))
</select> </select>
<select id="getWarehouseNo" parameterType="String" resultType="String">
select DISTINCT warehouseNo from warehouse
where id in (select warehouse_id from tdldevice
where gateway_id =(SELECT id from gateway where SN=#{SN,jdbcType=VARCHAR}
AND type=#{type,jdbcType=VARCHAR}))
</select>
<select id="getUnusedGateway" parameterType="String" resultType="com.example.tdl.domain.vo.GatewaySNVo"> <select id="getUnusedGateway" parameterType="String" resultType="com.example.tdl.domain.vo.GatewaySNVo">
select SN from gateway g INNER JOIN company c ON g.company_id=c.id select SN from gateway g INNER JOIN company c ON g.company_id=c.id
where SN like CONCAT(CONCAT('%',#{SN,jdbcType=VARCHAR}), '%') where SN like CONCAT(CONCAT('%',#{SN,jdbcType=VARCHAR}), '%')
...@@ -110,7 +118,7 @@ ...@@ -110,7 +118,7 @@
<!--根据仓库编号查询网关信息--> <!--根据仓库编号查询网关信息-->
<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 SELECT DISTINCT gatewaySN SN, gatewayType type,min(createTime) startTime
from tdl_gateway_log from tdl_gateway_log
where warehouseNo=#{warehouseNo,jdbcType=VARCHAR} where warehouseNo=#{warehouseNo,jdbcType=VARCHAR}
and ISNULL(endTime) and ISNULL(endTime)
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.tdl.mapper.WarehouseAlarmLogMapper">
<insert id="add" parameterType="com.example.tdl.domain.vo.WarehouseAlarmLog">
insert into warehouse_alarmlog values(
null,
#{warehouseNo,jdbcType=VARCHAR},
#{gSN,jdbcType=VARCHAR},
#{gType,jdbcType=VARCHAR},
#{TDLSN,jdbcType=VARCHAR},
#{description,jdbcType=VARCHAR},
#{data,jdbcType=FLOAT},
#{alarmTime,jdbcType=BIGINT},
#{desp,jdbcType=VARCHAR},
#{alarmNo,jdbcType=VARCHAR}
)
</insert>
<select id="getCount" resultType="com.example.tdl.domain.vo.WarehouseCountVo">
SELECT COUNT(id) num, FROM_UNIXTIME(alarmTime/1000, '%Y-%m-%d %H:00:00' ) hours
FROM warehouse_alarmlog
where warehouseNo=#{warehouseNo,jdbcType=VARCHAR}
and desp =#{desp,jdbcType=VARCHAR}
and alarmTime between #{startTime,jdbcType=BIGINT} and #{endTime,jdbcType=BIGINT}
GROUP BY hours ,desp
</select>
</mapper>
\ No newline at end of file
...@@ -223,10 +223,11 @@ ...@@ -223,10 +223,11 @@
</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">
select w.warehouseNo,GROUP_CONCAT(CONCAT("TDL-",TDLSN)) tdl,gatewaySN SN,gatewaytype type,CONCAT(gatewaytype,"_",gatewaySN) device,tgl.createTime,tgl.endTime select w.warehouseNo,GROUP_CONCAT(CONCAT("TDL-",TDLSN)) tdl,gatewaySN SN,gatewaytype type,CONCAT(gatewaytype,"_",gatewaySN) device,tgl.createTime startTime,tgl.endTime
from tdl_gateway_log tgl,warehouse w from tdl_gateway_log tgl,warehouse w
where tgl.warehouseNo = w.warehouseNo where tgl.warehouseNo = w.warehouseNo
and w.warehouseNo=#{warehouseNo,jdbcType=VARCHAR} and w.warehouseNo=#{warehouseNo,jdbcType=VARCHAR}
and ISNULL(tgl.endTime)
</select> </select>
<update id="updateImg"> <update id="updateImg">
...@@ -269,4 +270,12 @@ ...@@ -269,4 +270,12 @@
and companyNo=#{companyNo,jdbcType=VARCHAR} and companyNo=#{companyNo,jdbcType=VARCHAR}
</select> </select>
<select id="getEmailByWarehouse" resultType="String" parameterType="String">
select DISTINCT u.email
from warehouse w,warehouse_and_user wu,`user` u
where w.id = wu.warehouse_id
and u.id = wu.user_id
and w.warehouseNo=#{warehouseNo,jdbcType=VARCHAR}
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -56,5 +56,6 @@ ...@@ -56,5 +56,6 @@
<mapper resource="mapper/RegionMapper.xml"/> <mapper resource="mapper/RegionMapper.xml"/>
<mapper resource="mapper/CarMapper.xml"/> <mapper resource="mapper/CarMapper.xml"/>
<mapper resource="mapper/SideMapper.xml"/> <mapper resource="mapper/SideMapper.xml"/>
<mapper resource="mapper/WarehouseAlarmLogMapper.xml"/>
</mappers> </mappers>
</configuration> </configuration>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment