Commit 672338c6 authored by zhuangzhuang's avatar zhuangzhuang

6.13--修改仓库绑定网关和传感器的传参格式,完善仓库报警的邮件发送

parent b31ce2f3
...@@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.sql.Timestamp;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
...@@ -31,13 +32,13 @@ public class ScheduleConfig { ...@@ -31,13 +32,13 @@ public class ScheduleConfig {
@Autowired @Autowired
private WarehouseAlarmLogService warehouseAlarmLogService; private WarehouseAlarmLogService warehouseAlarmLogService;
@Scheduled(cron ="0 0 1 * * ?") //每隔一小时执行一次 @Scheduled(cron ="0 0 0/12 * * ?") //每隔一小时执行一次
public void scheduler() { public void scheduler() {
Long endTime = System.currentTimeMillis(); Long endTime = System.currentTimeMillis();
Long startTime = endTime-12*60*60*1000l; Long startTime = endTime-12*60*60*1000l;
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//获取所有的仓库信息 //获取所有的仓库信息
List<ResultWarehouseVo> resultWarehouseList = warehouseService.getAll("TM201803298320"); List<ResultWarehouseVo> resultWarehouseList = warehouseService.getAllWarehouse();
for(int i =0,length = resultWarehouseList.size();i<length;i++){ for(int i =0,length = resultWarehouseList.size();i<length;i++){
//获取相关的报警联系人 //获取相关的报警联系人
List<String> emailList = warehouseService.getEmailByWarehouse(resultWarehouseList.get(i).getWarehouseNo()); List<String> emailList = warehouseService.getEmailByWarehouse(resultWarehouseList.get(i).getWarehouseNo());
...@@ -52,7 +53,7 @@ public class ScheduleConfig { ...@@ -52,7 +53,7 @@ public class ScheduleConfig {
} }
try { try {
MailUtil.sendMail(emailList, "辉度物流监测系统------仓库报警提醒", MailUtil.sendMail(emailList, "辉度物流监测系统------仓库报警提醒",
message(sdf.format(new Date(Long.parseLong(String.valueOf(startTime)))), message(resultWarehouseList.get(i).getWarehouseNo(),sdf.format(new Date(Long.parseLong(String.valueOf(startTime)))),
sdf.format(new Date(Long.parseLong(String.valueOf(endTime)))), sdf.format(new Date(Long.parseLong(String.valueOf(endTime)))),
getSumCount(tempCount), getSumCount(tempCount),
getMaxTime(tempCount), getMaxTime(tempCount),
...@@ -66,7 +67,7 @@ public class ScheduleConfig { ...@@ -66,7 +67,7 @@ public class ScheduleConfig {
} }
public String message(String startTime,String endTime,Integer tempCount,String tempTime,Integer humCount,String humTime){ public String message(String warehouseNo,String startTime,String endTime,Integer tempCount,String tempTime,Integer humCount,String humTime){
String html="<!DOCTYPE html>\n" + String html="<!DOCTYPE html>\n" +
"<html lang=\"en\">\n" + "<html lang=\"en\">\n" +
"<head>\n" + "<head>\n" +
...@@ -77,12 +78,11 @@ public class ScheduleConfig { ...@@ -77,12 +78,11 @@ public class ScheduleConfig {
" <div style=\"width: 800px;margin: 0px auto;\">\n" + " <div style=\"width: 800px;margin: 0px auto;\">\n" +
" <div style=\"font-size: 15px;\">\n" + " <div style=\"font-size: 15px;\">\n" +
" <p>尊敬的用户,您好:</p>\n" + " <p>尊敬的用户,您好:</p>\n" +
" <p>&nbsp;&nbsp;&nbsp;&nbsp;自"+startTime+"到"+endTime+",您所管理的仓库报警情况如下:</p>" + " <p>&nbsp;&nbsp;&nbsp;&nbsp;自"+startTime+"到"+endTime+",您所管理的仓库编号为"+warehouseNo+"报警情况如下:</p>" +
" <p>&nbsp;&nbsp;&nbsp;&nbsp;发生温度报警"+tempCount+"次主要集中在"+tempTime+";" + " <p>&nbsp;&nbsp;&nbsp;&nbsp;发生温度报警"+tempCount+"次,主要集中在"+tempTime+";" +
" <p>&nbsp;&nbsp;&nbsp;&nbsp;发生湿度报警"+humCount+"次,主要集中在"+humTime+"</p>\n" + " <p>&nbsp;&nbsp;&nbsp;&nbsp;发生湿度报警"+humCount+"次,主要集中在"+humTime+"</p>\n" +
" <br>\n" + " <br>\n" +
" <p>致好!</p>\n" + " <p>致好!</p>\n" +
" <p>上海辉度智能系统有限公司</p>\n" +
" <br>\n" + " <br>\n" +
" </div>\n" + " </div>\n" +
" <br>\n" + " <br>\n" +
...@@ -130,9 +130,22 @@ public class ScheduleConfig { ...@@ -130,9 +130,22 @@ public class ScheduleConfig {
return num; return num;
} }
public String getMaxTime(List<WarehouseCountVo> counts){ public String getMaxTime(List<WarehouseCountVo> counts){
String time=""; String time="";
Collections.sort(counts, Comparator.comparing(WarehouseCountVo::getNum)); Collections.sort(counts, Comparator.comparing(WarehouseCountVo::getNum));
return counts.get(0).getHours(); time = counts.get(0).getHours();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
Date d = format.parse(time);
Calendar c = Calendar.getInstance();
c.setTime(d);
c.add(Calendar.HOUR_OF_DAY, 1);
String ts = format.format(c.getTime());
return time + "到" + ts;
}catch (Exception e){
e.printStackTrace();
return time;
}
} }
} }
...@@ -4,7 +4,7 @@ public class AddWarehouseGatewayVo { ...@@ -4,7 +4,7 @@ public class AddWarehouseGatewayVo {
private String warehouseNo; private String warehouseNo;
private String SN; private String gSN;
public String getWarehouseNo() { public String getWarehouseNo() {
return warehouseNo; return warehouseNo;
...@@ -14,11 +14,11 @@ public class AddWarehouseGatewayVo { ...@@ -14,11 +14,11 @@ public class AddWarehouseGatewayVo {
this.warehouseNo = warehouseNo; this.warehouseNo = warehouseNo;
} }
public String getSN() { public String getgSN() {
return SN; return gSN;
} }
public void setSN(String SN) { public void setgSN(String gSN) {
this.SN = SN; this.gSN = gSN;
} }
} }
...@@ -2,7 +2,7 @@ package com.example.tdl.domain.vo; ...@@ -2,7 +2,7 @@ package com.example.tdl.domain.vo;
public class BindingVo { public class BindingVo {
private String SN; private String gSN;
private String type; private String type;
...@@ -16,12 +16,12 @@ public class BindingVo { ...@@ -16,12 +16,12 @@ public class BindingVo {
private String alarmType; private String alarmType;
public String getSN() { public String getgSN() {
return SN; return gSN;
} }
public void setSN(String SN) { public void setgSN(String gSN) {
this.SN = SN; this.gSN = gSN;
} }
public String getType() { public String getType() {
......
...@@ -3,7 +3,7 @@ package com.example.tdl.domain.vo; ...@@ -3,7 +3,7 @@ package com.example.tdl.domain.vo;
import java.util.List; import java.util.List;
public class GatewayOnLineVo { public class GatewayOnLineVo {
private String SN; private String gSN;
private String type; private String type;
...@@ -15,12 +15,12 @@ public class GatewayOnLineVo { ...@@ -15,12 +15,12 @@ public class GatewayOnLineVo {
private List<TDLDeviceDetailVo> tdlDeviceDetailVos; private List<TDLDeviceDetailVo> tdlDeviceDetailVos;
public String getSN() { public String getgSN() {
return SN; return gSN;
} }
public void setSN(String SN) { public void setgSN(String gSN) {
this.SN = SN; this.gSN = gSN;
} }
public String getType() { public String getType() {
......
...@@ -25,6 +25,8 @@ public interface TDLLogMapper { ...@@ -25,6 +25,8 @@ public interface TDLLogMapper {
List<WarehouseLogVo> getByWarehouse(String warehouseNo); List<WarehouseLogVo> getByWarehouse(String warehouseNo);
Long getTimeByWarehouseNo(@Param("warehouseNo")String warehouseNo,@Param("gatewaySN")String gatewaySN);
List<ResultWarehouseNoAndTDLSNAndTimeVo> getByWarehouseNoAndTDLSNAndTime(DownloadForWarehouseVo downloadForWarehouseVo); List<ResultWarehouseNoAndTDLSNAndTimeVo> getByWarehouseNoAndTDLSNAndTime(DownloadForWarehouseVo downloadForWarehouseVo);
} }
...@@ -15,6 +15,8 @@ import java.util.Map; ...@@ -15,6 +15,8 @@ import java.util.Map;
public interface WarehouseMapper { public interface WarehouseMapper {
List<ResultWarehouseVo> getAll(String companyName); List<ResultWarehouseVo> getAll(String companyName);
List<ResultWarehouseVo> getAllWarehouse();
List<ResultWarehouseVo> getAllByTerm(WarehouseTermVo warehouseTermVo); List<ResultWarehouseVo> getAllByTerm(WarehouseTermVo warehouseTermVo);
List<SimpleWarehouseVo> getByWarehouse(WareHouseByTermVo wareHouseByTermVo); List<SimpleWarehouseVo> getByWarehouse(WareHouseByTermVo wareHouseByTermVo);
......
...@@ -47,6 +47,10 @@ public class TDLLogService { ...@@ -47,6 +47,10 @@ public class TDLLogService {
return tdlLogMapper.getByWarehouse(warehouseNo); return tdlLogMapper.getByWarehouse(warehouseNo);
} }
public Long getTimeByWarehouseNo(String warehouseNo,String SN){
return tdlLogMapper.getTimeByWarehouseNo(warehouseNo,SN);
}
public List<ResultWarehouseNoAndTDLSNAndTimeVo> getByWarehouseNoAndTDLSNAndTime(DownloadForWarehouseVo downloadForWarehouseVo){ public List<ResultWarehouseNoAndTDLSNAndTimeVo> getByWarehouseNoAndTDLSNAndTime(DownloadForWarehouseVo downloadForWarehouseVo){
return tdlLogMapper.getByWarehouseNoAndTDLSNAndTime(downloadForWarehouseVo); return tdlLogMapper.getByWarehouseNoAndTDLSNAndTime(downloadForWarehouseVo);
} }
......
...@@ -19,6 +19,11 @@ public class WarehouseService { ...@@ -19,6 +19,11 @@ public class WarehouseService {
return warehouseMapper.getAll(companyNo); return warehouseMapper.getAll(companyNo);
} }
public List<ResultWarehouseVo> getAllWarehouse(){
return warehouseMapper.getAllWarehouse();
}
public List<ResultWarehouseVo> getAllByTerm(WarehouseTermVo warehouseTermVo){ public List<ResultWarehouseVo> getAllByTerm(WarehouseTermVo warehouseTermVo){
return warehouseMapper.getAllByTerm(warehouseTermVo); return warehouseMapper.getAllByTerm(warehouseTermVo);
} }
......
...@@ -88,11 +88,11 @@ public class DataUtil { ...@@ -88,11 +88,11 @@ public class DataUtil {
logger.info(count+"------"); logger.info(count+"------");
String sql = ""; String sql = "";
if (count > 500) { if (count > 500) {
long times = ( resultCircuitVo.getEndTime() * 1000000l - startTime) / 500;
if (resultCircuitVo.getEndTime() != null && resultCircuitVo.getEndTime() != 0) { if (resultCircuitVo.getEndTime() != null && resultCircuitVo.getEndTime() != 0) {
sql = getSQL( gatewayVo.getgSN(),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(gatewayVo.getgSN(), field, device, devList.get(i), startTime, System.currentTimeMillis() * 1000000l); sql = getSQL(gatewayVo.getgSN(), field, device, devList.get(i), startTime, t1 * 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) {
...@@ -119,111 +119,6 @@ public class DataUtil { ...@@ -119,111 +119,6 @@ public class DataUtil {
return gson.toJson(historyDataVoList); return gson.toJson(historyDataVoList);
} }
// public static String getHistoryData(String transportationNo, HttpServletRequest request, I18nController i18n, String companyNo, CircuitService circuitService, TDLLogService tdlLogService, InfluxDBService influxDBService, String field){
// Long t1 = System.currentTimeMillis();
// logger.info(t1+"---------t1");
// ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(transportationNo, companyNo);
// if (resultCircuitVo == null) {
// fb.setCode(0);
// fb.setMessage(i18n.getMessage(request, "noCircuit"));
// return gson.toJson(fb);
// }
// if (resultCircuitVo.getStartTime() == null || resultCircuitVo.getStartTime() == 0) {
// fb.setCode(0);
// fb.setMessage(i18n.getMessage(request, "notStarted"));
// return gson.toJson(fb);
// }
// Long startTime = resultCircuitVo.getStartTime() * 1000000l;
// TDLLogVo gatewayVo = tdlLogService.getByTransportationNo(transportationNo);
// if (gatewayVo == null) {
// fb.setCode(0);
// fb.setMessage(i18n.getMessage(request, "noCircuit"));
// return gson.toJson(fb);
// }
// String device = gatewayVo.getgType() + "_" + gatewayVo.getgSN();
// //获取tdl信息
// List<String> devList = tdlLogService.getTdlSN(transportationNo);
// if (devList.size() == 0) {
// fb.setCode(0);
// fb.setMessage(i18n.getMessage(request, "noCircuit"));
// return gson.toJson(fb);
// }
// Long t2 = System.currentTimeMillis();
// logger.info(t2-t1+"--------------t2-t1");
// List<HistoryDataVo> historyDataVoList = new ArrayList<>();
// for (int i = 0; i < devList.size(); i++) {
// HistoryDataVo historyDataVo = new HistoryDataVo();
// String TDLSN = devList.get(i).replace("TDL-", "").trim();
// historyDataVo.setTDLSN(TDLSN);
// if("\"T\"".equals(field) || "\"h\"".equals(field)){
// ResultAlarmVo resultAlarmVo = tdlLogService.getByTdl(transportationNo, TDLSN);
// //根据tdl货物报警信息
// historyDataVo.setMax(resultAlarmVo.getTemMax().toString());
// historyDataVo.setMin(resultAlarmVo.getTemMin().toString());
// }
// List<HistoryData> historyData = new ArrayList<>();
// String sqls = "";
// Long t3 = System.currentTimeMillis();
// logger.info(t3-t2+"------t3");
// QueryResult queryResults = null;
// if (resultCircuitVo.getEndTime() != null && resultCircuitVo.getEndTime() != 0) {
// queryResults = influxDBService.getData(device,devList.get(i),field,startTime,resultCircuitVo.getEndTime() * 1000000l);
// } else {
// queryResults = influxDBService.getData(device,devList.get(i),field,startTime,System.currentTimeMillis() * 1000000l);
// }
// Long t4 = System.currentTimeMillis();
// logger.info(t4-t3+"------t4");
// Integer count;
// if (queryResults.getResults().get(0).getSeries() != null) {
// count = Double.valueOf(queryResults.getResults().get(0).getSeries().get(0).getValues().get(0).get(1).toString()).intValue();
// } else {
// historyDataVo.setDataList(historyData);
// historyDataVoList.add(historyDataVo);
// continue;
// }
// Long t5 = System.currentTimeMillis();
// logger.info(t5-t4+"------t5-----"+ count);
// String sql = "";
// if (count > 500) {
// Long t6 = System.currentTimeMillis();
// logger.info(t6 - t5 + "------t6");
// QueryResult queryResult = null;
// if (resultCircuitVo.getEndTime() != null && resultCircuitVo.getEndTime() != 0) {
// queryResult = influxDBService.getHistoryData(device, devList.get(i), field, startTime, resultCircuitVo.getEndTime() * 1000000l);
// } else {
// queryResult = influxDBService.getHistoryData(device, devList.get(i), field, startTime, resultCircuitVo.getEndTime() * 1000000l);
// }
// Long t7 = System.currentTimeMillis();
// logger.info(t7 - t6 + "------t7-------" + t7);
// if (queryResult.getResults() != null) {
// historyData = getHistoryDatas(queryResult, field);
// }
// Long t8 = System.currentTimeMillis();
// logger.info(t8 - t7 + "------t8-------" + t8);
// historyDataVo.setDataList(historyData);
// historyDataVoList.add(historyDataVo);
// logger.info(System.currentTimeMillis() + "");
// }
//// } else {
//// if (resultCircuitVo.getEndTime() != null && resultCircuitVo.getEndTime() != 0) {
//// sql = "SELECT "+field+" FROM \"tdl_policy\".\"" + device + "\" where \"tdl\"='" + devList.get(i) + "' and time >=" + startTime + " and time<=" + resultCircuitVo.getEndTime() * 1000000l + " ORDER BY time ";
//// } else {
//// sql = "SELECT "+field+" FROM \"tdl_policy\".\"" + device + "\" where \"tdl\"='" + devList.get(i) + "' and time >=" + startTime + " ORDER BY time";
//// }
//// QueryResult queryResult = influxDBTemplate.query(new Query(sql, database));
//// if (queryResult.getResults().get(0).getSeries() != null) {
//// //解析数据
//// historyData = getHistoryData(queryResult, field);
//// }
//// historyDataVo.setDataList(historyData);
//// historyDataVoList.add(historyDataVo);
//// }
// }
// logger.info(System.currentTimeMillis()-t1+"____________");
// return gson.toJson(historyDataVoList);
// }
public static String getSQL(String SN,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;
...@@ -231,21 +126,13 @@ public class DataUtil { ...@@ -231,21 +126,13 @@ public class DataUtil {
Long maxTime = startTime + times; Long maxTime = startTime + times;
sql = sql + "Select " + field + " From \"tdl_policy\".\"" + device + "\" where " + sql = sql + "Select " + field + " From \"tdl_policy\".\"" + device + "\" where " +
" \"SN\" = '"+SN+"' " + " \"SN\" = '"+SN+"' " +
" AND \"topic\" = 'Data' " +
" AND \"data_type\" = 'data' " +
" AND \"tdl\"='" + tdl + "' " + " AND \"tdl\"='" + tdl + "' " +
" AND \"event\" = 'Regular measurement' " +
" AND \"data_id\" = '2' " +
"and time >= "+startTime +" and time <= " + maxTime + " order by time limit 1;"; "and time >= "+startTime +" and time <= " + maxTime + " order by time limit 1;";
startTime = maxTime; startTime = maxTime;
} }
sql = sql + "Select " + field + " From \"tdl_policy\".\"" + device + "\" where " + sql = sql + "Select " + field + " From \"tdl_policy\".\"" + device + "\" where " +
" \"SN\" = '"+SN+"' " + " \"SN\" = '"+SN+"' " +
" AND \"topic\" = 'Data' " +
" AND \"data_type\" = 'data' " +
" AND \"tdl\"='" + tdl + "' " + " AND \"tdl\"='" + tdl + "' " +
" AND \"event\" = 'Regular measurement' " +
" AND \"data_id\" = '2' " +
"and time >= "+startTime+" and time <= " + endTime + " order by time desc limit 1;"; "and time >= "+startTime+" and time <= " + endTime + " order by time desc limit 1;";
return sql; return sql;
} }
......
...@@ -58,4 +58,6 @@ public class MailUtil { ...@@ -58,4 +58,6 @@ public class MailUtil {
transport.close(); transport.close();
System.out.println("ok"); System.out.println("ok");
} }
} }
...@@ -1118,16 +1118,16 @@ public class CircuitController { ...@@ -1118,16 +1118,16 @@ public class CircuitController {
return gson.toJson(fb); return gson.toJson(fb);
} }
Long time = System.currentTimeMillis(); Long time = System.currentTimeMillis();
String countryVar=addCircuitVo.getStartAddressVo().getCountry()+" "+addCircuitVo.getEndAddressVo().getCountry() +" "; String countryVar=addCircuitVo.getStartAddressVo().getCountry()+"&"+addCircuitVo.getEndAddressVo().getCountry() +"&";
String cityVar=addCircuitVo.getStartAddressVo().getCity()+ " "+addCircuitVo.getEndAddressVo().getCity() +" "; String cityVar=addCircuitVo.getStartAddressVo().getCity()+ "&"+addCircuitVo.getEndAddressVo().getCity() +"&";
String addressDetailVar=addCircuitVo.getStartAddressVo().getAddressDetail() +" "+addCircuitVo.getEndAddressVo().getAddressDetail() +" "; String addressDetailVar=addCircuitVo.getStartAddressVo().getAddressDetail() +"&"+addCircuitVo.getEndAddressVo().getAddressDetail() +"&";
String lngVar=addCircuitVo.getStartAddressVo().getLng()+" "+ addCircuitVo.getEndAddressVo().getLng() +" "; String lngVar=addCircuitVo.getStartAddressVo().getLng()+"&"+ addCircuitVo.getEndAddressVo().getLng() +"&";
String latVar = addCircuitVo.getStartAddressVo().getLat()+" "+ addCircuitVo.getEndAddressVo().getLat() +" "; String latVar = addCircuitVo.getStartAddressVo().getLat()+"&"+ addCircuitVo.getEndAddressVo().getLat() +"&";
String postCodeVar = addCircuitVo.getStartAddressVo().getPostCode()+" "+ addCircuitVo.getEndAddressVo().getPostCode() +" "; String postCodeVar = addCircuitVo.getStartAddressVo().getPostCode()+"&"+ addCircuitVo.getEndAddressVo().getPostCode() +"&";
String expTimeVar = addCircuitVo.getStartAddressVo().getExpTime()+" "+"0 "; String expTimeVar = addCircuitVo.getStartAddressVo().getExpTime()+"&"+"0 ";
String compTimeVar = "0 "+addCircuitVo.getEndAddressVo().getCompTime() +" "; String compTimeVar = "0&"+addCircuitVo.getEndAddressVo().getCompTime() +"&";
String arrivalTimeVar="0 0 "; String arrivalTimeVar="0&0&";
String startTimeVar="0 0 "; String startTimeVar="0&0&";
//根据sn获取type //根据sn获取type
Map<Object,Object> map=new HashMap<>(); Map<Object,Object> map=new HashMap<>();
map.put("transportationNo",getTransportNo(addCircuitVo.getTransportation(),addCircuitVo.getTransportationType())); map.put("transportationNo",getTransportNo(addCircuitVo.getTransportation(),addCircuitVo.getTransportationType()));
......
package com.example.tdl.web; package com.example.tdl.web;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.example.tdl.domain.dto.CommFeedback; import com.example.tdl.domain.dto.CommFeedback;
...@@ -8,6 +9,7 @@ import com.example.tdl.domain.vo.ResultCompanyVo; ...@@ -8,6 +9,7 @@ import com.example.tdl.domain.vo.ResultCompanyVo;
import com.example.tdl.domain.vo.UpdateCompanyVo; import com.example.tdl.domain.vo.UpdateCompanyVo;
import com.example.tdl.domain.vo.UserRedisVo; import com.example.tdl.domain.vo.UserRedisVo;
import com.example.tdl.service.CompanyService; import com.example.tdl.service.CompanyService;
import com.example.tdl.service.RoleService;
import com.example.tdl.service.redis.TokenRedisService; import com.example.tdl.service.redis.TokenRedisService;
import com.google.gson.Gson; import com.google.gson.Gson;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
...@@ -26,6 +28,7 @@ import javax.servlet.http.HttpServletRequest; ...@@ -26,6 +28,7 @@ import javax.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
@RestController @RestController
@RequestMapping("/company") @RequestMapping("/company")
public class CompanyController { public class CompanyController {
...@@ -87,9 +90,6 @@ public class CompanyController { ...@@ -87,9 +90,6 @@ public class CompanyController {
}) })
@RequestMapping(value="/addCompany",method = RequestMethod.POST) @RequestMapping(value="/addCompany",method = RequestMethod.POST)
public Object addCompany(@RequestBody AddCompanyVo addCompanyVo,HttpServletRequest request){ public Object addCompany(@RequestBody AddCompanyVo addCompanyVo,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"); String port = request.getHeader("AccountLanguage");
if (StringUtils.isEmpty(addCompanyVo.getCompanyName())){ if (StringUtils.isEmpty(addCompanyVo.getCompanyName())){
fb.setCode(0); fb.setCode(0);
...@@ -126,7 +126,7 @@ public class CompanyController { ...@@ -126,7 +126,7 @@ public class CompanyController {
fb.setMessage(i18n.getMessage(request,"manager")); fb.setMessage(i18n.getMessage(request,"manager"));
return gson.toJson(fb); return gson.toJson(fb);
} }
if (!addCompanyVo.getTel().matches("^1[34578]\\d{9}$")){ if( !addCompanyVo.getTel().matches("^1[34578]\\d{9}$")){
fb.setCode(0); fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"wrongTel")); fb.setMessage(i18n.getMessage(request,"wrongTel"));
return gson.toJson(fb); return gson.toJson(fb);
...@@ -165,7 +165,6 @@ public class CompanyController { ...@@ -165,7 +165,6 @@ public class CompanyController {
map.put("tel",addCompanyVo.getTel()); map.put("tel",addCompanyVo.getTel());
map.put("manager",addCompanyVo.getManager()); map.put("manager",addCompanyVo.getManager());
map.put("img",addCompanyVo.getImg()); map.put("img",addCompanyVo.getImg());
map.put("parentCompanyNo",user.getCompanyNo());
map.put("roleName",addCompanyVo.getRoleName()); map.put("roleName",addCompanyVo.getRoleName());
map.put("createTime",System.currentTimeMillis()); map.put("createTime",System.currentTimeMillis());
companyService.addCompany(map); companyService.addCompany(map);
...@@ -264,6 +263,8 @@ public class CompanyController { ...@@ -264,6 +263,8 @@ public class CompanyController {
return gson.toJson(fb); return gson.toJson(fb);
} }
//删除公司 //删除公司
@ApiOperation(value = "删除公司",notes = "删除公司,传值说明:companyName:公司编号") @ApiOperation(value = "删除公司",notes = "删除公司,传值说明:companyName:公司编号")
@ApiImplicitParams({ @ApiImplicitParams({
...@@ -278,7 +279,6 @@ public class CompanyController { ...@@ -278,7 +279,6 @@ public class CompanyController {
fb.setMessage(i18n.getMessage(request,"companyNo")); fb.setMessage(i18n.getMessage(request,"companyNo"));
return gson.toJson(fb); return gson.toJson(fb);
} }
JSONObject jsonObject= JSON.parseObject(companyNo); JSONObject jsonObject= JSON.parseObject(companyNo);
companyNo=(String) jsonObject.get("companyNo"); companyNo=(String) jsonObject.get("companyNo");
Map<Object,Object> map=new HashMap<>(); Map<Object,Object> map=new HashMap<>();
......
...@@ -78,7 +78,7 @@ public class EquipmentBindingController { ...@@ -78,7 +78,7 @@ public class EquipmentBindingController {
String token = request.getHeader("Account_token"); String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token); String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class); UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
if(StringUtils.isEmpty(bindingVo.getSN())){ if(StringUtils.isEmpty(bindingVo.getgSN())){
fb.setCode(0); fb.setCode(0);
fb.setMessage("网关编号不能为空"); fb.setMessage("网关编号不能为空");
return gson.toJson(fb); return gson.toJson(fb);
...@@ -99,10 +99,10 @@ public class EquipmentBindingController { ...@@ -99,10 +99,10 @@ public class EquipmentBindingController {
return gson.toJson(fb); return gson.toJson(fb);
} }
if(StringUtils.isEmpty(bindingVo.getType())){ if(StringUtils.isEmpty(bindingVo.getType())){
bindingVo.setType(gatewayService.getBySN(bindingVo.getSN(),user.getCompanyNo())); bindingVo.setType(gatewayService.getBySN(bindingVo.getgSN(),user.getCompanyNo()));
} }
//获取gateWay的信息 //获取gateWay的信息
ResultGatewayVo resultGatewayVo = gatewayService.getBySNAndType(bindingVo.getSN(),bindingVo.getType()); ResultGatewayVo resultGatewayVo = gatewayService.getBySNAndType(bindingVo.getgSN(),bindingVo.getType());
if(resultGatewayVo == null){ if(resultGatewayVo == null){
fb.setCode(0); fb.setCode(0);
fb.setMessage("该网关不存在"); fb.setMessage("该网关不存在");
...@@ -132,7 +132,7 @@ public class EquipmentBindingController { ...@@ -132,7 +132,7 @@ public class EquipmentBindingController {
gprsPeriod= 60; gprsPeriod= 60;
}else{ }else{
gpsPeriod=5; gpsPeriod=5;
if("17110194".equals(bindingVo.getSN())){ if("17110194".equals(bindingVo.getgSN())){
gprsPeriod=7; gprsPeriod=7;
}else{ }else{
gprsPeriod=15; gprsPeriod=15;
...@@ -161,7 +161,7 @@ public class EquipmentBindingController { ...@@ -161,7 +161,7 @@ public class EquipmentBindingController {
accThreshold.add(Float.valueOf(alarmVo.getShock())); accThreshold.add(Float.valueOf(alarmVo.getShock()));
timeThreshold.add(5); timeThreshold.add(5);
tiltThreshold.add((int)Double.parseDouble(alarmVo.getTilt().toString())); tiltThreshold.add((int)Double.parseDouble(alarmVo.getTilt().toString()));
List<String> devList = tdlDeviceService.getByGatewaySN(bindingVo.getSN(),bindingVo.getType()); List<String> devList = tdlDeviceService.getByGatewaySN(bindingVo.getgSN(),bindingVo.getType());
devList.add("TDL-"+bindingVo.getTDLSN()); 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); ConfigCMDVo configCMDVo = new ConfigCMDVo("config",gpsPeriod,gprsPeriod,devList,tempL,tempH,humiL,humiH,pressL,pressH,sugEnergy,accThreshold,timeThreshold,tiltThreshold,bindingVo.getMode(),System.currentTimeMillis()/1000l);
Map<Object,Object> map=new HashMap<>(); Map<Object,Object> map=new HashMap<>();
...@@ -169,7 +169,7 @@ public class EquipmentBindingController { ...@@ -169,7 +169,7 @@ public class EquipmentBindingController {
map.put("transportationNo",bindingVo.getTransportationNo()); map.put("transportationNo",bindingVo.getTransportationNo());
map.put("warehouseNo",bindingVo.getWarehouseNo()); map.put("warehouseNo",bindingVo.getWarehouseNo());
map.put("useScene",bindingVo.getMode()); map.put("useScene",bindingVo.getMode());
map.put("gSN",bindingVo.getSN()); map.put("gSN",bindingVo.getgSN());
map.put("gType",bindingVo.getType()); map.put("gType",bindingVo.getType());
map.put("alarmType",bindingVo.getAlarmType()); map.put("alarmType",bindingVo.getAlarmType());
map.put("message",gson.toJson(configCMDVo)); map.put("message",gson.toJson(configCMDVo));
...@@ -186,7 +186,7 @@ public class EquipmentBindingController { ...@@ -186,7 +186,7 @@ public class EquipmentBindingController {
fb.setCode(1); fb.setCode(1);
fb.setMessage("配置网关成功"); fb.setMessage("配置网关成功");
//根据报警类型货报警信息 //根据报警类型货报警信息
AlarmRule.saveAlarmRule("TDL/"+bindingVo.getType()+"/" +bindingVo.getSN()+"/Data",bindingVo.getTDLSN(),bindingVo.getAlarmType(),user.getCompanyNo(),alarmService,alarmRedisService); AlarmRule.saveAlarmRule("TDL/"+bindingVo.getType()+"/" +bindingVo.getgSN()+"/Data",bindingVo.getTDLSN(),bindingVo.getAlarmType(),user.getCompanyNo(),alarmService,alarmRedisService);
}else{ }else{
fb.setCode(0); fb.setCode(0);
fb.setMessage(msg.get("msg").toString()); fb.setMessage(msg.get("msg").toString());
...@@ -263,18 +263,18 @@ public class EquipmentBindingController { ...@@ -263,18 +263,18 @@ public class EquipmentBindingController {
fb.setMessage("仓库编号不存在"); fb.setMessage("仓库编号不存在");
return gson.toJson(fb); return gson.toJson(fb);
} }
if (StringUtils.isEmpty(addWarehouseGatewayVo.getSN())){ if (StringUtils.isEmpty(addWarehouseGatewayVo.getgSN())){
fb.setCode(0); fb.setCode(0);
fb.setMessage("网关编号不能为空"); fb.setMessage("网关编号不能为空");
return gson.toJson(fb); return gson.toJson(fb);
} }
if( gatewayService.getBySN(addWarehouseGatewayVo.getSN(),user.getCompanyNo())==null){ if( gatewayService.getBySN(addWarehouseGatewayVo.getgSN(),user.getCompanyNo())==null){
fb.setCode(0); fb.setCode(0);
fb.setMessage("该网关不存在"); fb.setMessage("该网关不存在");
return gson.toJson(fb); return gson.toJson(fb);
} }
//判断该网关是否属于当前仓库 //判断该网关是否属于当前仓库
Integer i = warehouseService.getByWarehouseNoAndSN(addWarehouseGatewayVo.getWarehouseNo(),addWarehouseGatewayVo.getSN()); Integer i = warehouseService.getByWarehouseNoAndSN(addWarehouseGatewayVo.getWarehouseNo(),addWarehouseGatewayVo.getgSN());
if(i == 0){ if(i == 0){
fb.setCode(0); fb.setCode(0);
fb.setMessage("该网关不属于该仓库"); fb.setMessage("该网关不属于该仓库");
...@@ -282,7 +282,7 @@ public class EquipmentBindingController { ...@@ -282,7 +282,7 @@ public class EquipmentBindingController {
} }
Map<Object,Object> map=new HashMap<>(); Map<Object,Object> map=new HashMap<>();
map.put("warehouseNo",addWarehouseGatewayVo.getWarehouseNo()); map.put("warehouseNo",addWarehouseGatewayVo.getWarehouseNo());
map.put("gSN",addWarehouseGatewayVo.getSN()); map.put("gSN",addWarehouseGatewayVo.getgSN());
map.put("gType","WTD93LG"); map.put("gType","WTD93LG");
map.put("endTime",System.currentTimeMillis()); map.put("endTime",System.currentTimeMillis());
warehouseService.untieGateway(map); warehouseService.untieGateway(map);
......
...@@ -237,6 +237,11 @@ public class PermissionController { ...@@ -237,6 +237,11 @@ public class PermissionController {
fb.setMessage(i18n.getMessage(request,"roleName")); fb.setMessage(i18n.getMessage(request,"roleName"));
return gson.toJson(fb); return gson.toJson(fb);
} }
if("管理员".equals(addOrUpdatePermissionVo.getRoleName())){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"adminInoperable"));
return gson.toJson(fb);
}
String permissionVar=""; String permissionVar="";
for(int i=0;i<addOrUpdatePermissionVo.getPermissionGroupVos().size();i++){ for(int i=0;i<addOrUpdatePermissionVo.getPermissionGroupVos().size();i++){
permissionVar+=addOrUpdatePermissionVo.getPermissionGroupVos().get(i)+" "; permissionVar+=addOrUpdatePermissionVo.getPermissionGroupVos().get(i)+" ";
......
...@@ -415,8 +415,6 @@ public class RoleController { ...@@ -415,8 +415,6 @@ public class RoleController {
} }
......
...@@ -245,7 +245,7 @@ public class TDLDeviceController { ...@@ -245,7 +245,7 @@ public class TDLDeviceController {
fb.setMessage(i18n.getMessage(request,"companyNo")); fb.setMessage(i18n.getMessage(request,"companyNo"));
return gson.toJson(fb); return gson.toJson(fb);
} }
int a=tdlDeviceService.updateCompany(updateTDLCompanyVo.getTDLSN(),user.getCompanyNo()); int a=tdlDeviceService.updateCompany(updateTDLCompanyVo.getTDLSN(),updateTDLCompanyVo.getCompanyNo());
if (a>=0){ if (a>=0){
fb.setCode(1); fb.setCode(1);
fb.setMessage(i18n.getMessage(request,"updateTDLCompanySuccess")); fb.setMessage(i18n.getMessage(request,"updateTDLCompanySuccess"));
......
...@@ -184,6 +184,7 @@ public class TransferModelController { ...@@ -184,6 +184,7 @@ public class TransferModelController {
return gson.toJson(fb); return gson.toJson(fb);
} }
@ApiOperation(value = "修改主题模板",notes = "修改模板只能修改模板名,updateTime不用传,传递的参数:" + @ApiOperation(value = "修改主题模板",notes = "修改模板只能修改模板名,updateTime不用传,传递的参数:" +
" transferNo: 需要修改的线路模板编号," + " transferNo: 需要修改的线路模板编号," +
" transferModelName: 修改后的线路模板名") " transferModelName: 修改后的线路模板名")
......
...@@ -303,6 +303,7 @@ public class WarehouseController { ...@@ -303,6 +303,7 @@ public class WarehouseController {
List<WarehouseLogVo> list =tdlLogService.getByWarehouse(warehouseNo); List<WarehouseLogVo> list =tdlLogService.getByWarehouse(warehouseNo);
List<GatewayOnLineVo> gatewayOnLineVos=new ArrayList<>(); List<GatewayOnLineVo> gatewayOnLineVos=new ArrayList<>();
for (int a=0;a<list.size();a++){ for (int a=0;a<list.size();a++){
if(list.get(a) == null){ if(list.get(a) == null){
continue; continue;
} }
...@@ -310,7 +311,7 @@ public class WarehouseController { ...@@ -310,7 +311,7 @@ public class WarehouseController {
continue; continue;
} }
GatewayOnLineVo gatewayOnLineVo = new GatewayOnLineVo(); GatewayOnLineVo gatewayOnLineVo = new GatewayOnLineVo();
gatewayOnLineVo.setSN(list.get(a).getSN()); gatewayOnLineVo.setgSN(list.get(a).getSN());
gatewayOnLineVo.setType(list.get(a).getType()); gatewayOnLineVo.setType(list.get(a).getType());
Object data = infoRedisService.getHash("DeviceOnline", list.get(a).getDevice() ); Object data = infoRedisService.getHash("DeviceOnline", list.get(a).getDevice() );
if(data !=null){ if(data !=null){
...@@ -324,7 +325,9 @@ public class WarehouseController { ...@@ -324,7 +325,9 @@ public class WarehouseController {
}else{ }else{
gatewayOnLineVo.setState(6); gatewayOnLineVo.setState(6);
} }
String sql ="SELECT \"battery\" FROM \"tdl_policy\".\""+list.get(a).getDevice() +"\"where time >="+list.get(a).getCreateTime()+" ORDER BY time DESC LIMIT 1"; //根据网关线路编号获取时间
Long startTime = tdlLogService.getTimeByWarehouseNo(warehouseNo,list.get(a).getSN());
String sql ="SELECT \"battery\" FROM \"tdl_policy\".\""+list.get(a).getDevice() +"\"where time >="+startTime*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){
...@@ -340,7 +343,7 @@ public class WarehouseController { ...@@ -340,7 +343,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)+"') and time>="+list.get(a).getEndTime()+" 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>="+startTime*1000000l+" 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()));
...@@ -849,21 +852,21 @@ public class WarehouseController { ...@@ -849,21 +852,21 @@ public class WarehouseController {
fb.setMessage(i18n.getMessage(request,"Nonexistent")); fb.setMessage(i18n.getMessage(request,"Nonexistent"));
return gson.toJson(fb); return gson.toJson(fb);
} }
if (StringUtils.isEmpty(addWarehouseGatewayVo.getSN())){ if (StringUtils.isEmpty(addWarehouseGatewayVo.getgSN())){
fb.setCode(0); fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"gatewaySN")); fb.setMessage(i18n.getMessage(request,"gatewaySN"));
return gson.toJson(fb); return gson.toJson(fb);
} }
if( gatewayService.getBySN(addWarehouseGatewayVo.getSN(),user.getCompanyNo())==null){ if( gatewayService.getBySN(addWarehouseGatewayVo.getgSN(),user.getCompanyNo())==null){
fb.setCode(0); fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"existGateway")); fb.setMessage(i18n.getMessage(request,"existGateway"));
return gson.toJson(fb); return gson.toJson(fb);
} }
String type = gatewayService.getBySN(addWarehouseGatewayVo.getSN(),user.getCompanyNo()); String type = gatewayService.getBySN(addWarehouseGatewayVo.getgSN(),user.getCompanyNo());
//判断当前网关是否已经被使用 //判断当前网关是否已经被使用
Map<Object,Object> map=new HashMap<>(); Map<Object,Object> map=new HashMap<>();
map.put("warehouseNo",addWarehouseGatewayVo.getWarehouseNo()); map.put("warehouseNo",addWarehouseGatewayVo.getWarehouseNo());
map.put("gSN",addWarehouseGatewayVo.getSN()); map.put("gSN",addWarehouseGatewayVo.getgSN());
map.put("gType",type); map.put("gType",type);
map.put("startTime",System.currentTimeMillis()); map.put("startTime",System.currentTimeMillis());
warehouseService.addGateway(map); warehouseService.addGateway(map);
...@@ -916,7 +919,7 @@ public class WarehouseController { ...@@ -916,7 +919,7 @@ public class WarehouseController {
fb.setMessage(i18n.getMessage(request,"NonexistentUser")); fb.setMessage(i18n.getMessage(request,"NonexistentUser"));
return gson.toJson(fb); return gson.toJson(fb);
} }
userNameVar = userNameVar +warehouseUserVo.getUserNameList().get(i).getUserName() +" "; userNameVar = userNameVar +warehouseUserVo.getUserNameList().get(i).getUserName() +"&";
} }
Map<Object,Object> map=new HashMap<>(); Map<Object,Object> map=new HashMap<>();
map.put("warehouseNo",warehouseUserVo.getWarehouseNo()); map.put("warehouseNo",warehouseUserVo.getWarehouseNo());
...@@ -971,10 +974,13 @@ public class WarehouseController { ...@@ -971,10 +974,13 @@ public class WarehouseController {
List<WarehouseGatewayDateVo> warehouseGatewayDateVoList=new ArrayList<>(); List<WarehouseGatewayDateVo> warehouseGatewayDateVoList=new ArrayList<>();
List<GatewayOnLineVo> gatewayOnLineVos=gatewayService.getByWarehouseNo(warehouseNo); List<GatewayOnLineVo> gatewayOnLineVos=gatewayService.getByWarehouseNo(warehouseNo);
for (int a=0;a<gatewayOnLineVos.size();a++){ for (int a=0;a<gatewayOnLineVos.size();a++){
if(gatewayOnLineVos.get(a) == null){
continue;
}
WarehouseGatewayDateVo warehouseGatewayDateVo=new WarehouseGatewayDateVo(); WarehouseGatewayDateVo warehouseGatewayDateVo=new WarehouseGatewayDateVo();
warehouseGatewayDateVo.setgSN(gatewayOnLineVos.get(a).getSN()); warehouseGatewayDateVo.setgSN(gatewayOnLineVos.get(a).getgSN());
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).getgSN();
String sql ="SELECT \"battery\" FROM \"tdl_policy\".\""+device +"\" where time >="+ gatewayOnLineVos.get(a).getStartTime()*1000000l+" 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) {
...@@ -999,7 +1005,7 @@ public class WarehouseController { ...@@ -999,7 +1005,7 @@ public class WarehouseController {
warehouseGatewayDateVo.setState(6); warehouseGatewayDateVo.setState(6);
} }
List<String> tdls=tdlDeviceService.getByGatewaySN(gatewayOnLineVos.get(a).getSN(),gatewayOnLineVos.get(a).getType()); List<String> tdls=tdlDeviceService.getByGatewaySN(gatewayOnLineVos.get(a).getgSN(),gatewayOnLineVos.get(a).getType());
List<WarehouseDataVo> warehouseDataVos=new ArrayList<>(); List<WarehouseDataVo> warehouseDataVos=new ArrayList<>();
for (int b=0;b<tdls.size();b++){ for (int b=0;b<tdls.size();b++){
...@@ -1010,7 +1016,7 @@ public class WarehouseController { ...@@ -1010,7 +1016,7 @@ public class WarehouseController {
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)+"' AND time >="+ gatewayOnLineVos.get(a).getStartTime()*1000000l+" 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).getgSN(),tdls.get(b).replace("TDL-","").trim());
if (queryResults.getResults().get(0).getSeries() != null) { if (queryResults.getResults().get(0).getSeries() != null) {
warehouseDataVo.setTime(parseTime(queryResults.getResults().get(0).getSeries().get(0).getValues().get(0).get(0).toString())); warehouseDataVo.setTime(parseTime(queryResults.getResults().get(0).getSeries().get(0).getValues().get(0).get(0).toString()));
warehouseDataVo.setBatteryVoltage(queryResults.getResults().get(0).getSeries().get(0).getValues().get(0).get(2).toString()); warehouseDataVo.setBatteryVoltage(queryResults.getResults().get(0).getSeries().get(0).getValues().get(0).get(2).toString());
......
...@@ -17,12 +17,12 @@ spring.influxdb.url=http://housetest-influxdb:8086 ...@@ -17,12 +17,12 @@ spring.influxdb.url=http://housetest-influxdb:8086
#spring.datasource.username=root #spring.datasource.username=root
#spring.datasource.password=37774020 #spring.datasource.password=37774020
#spring.datasource.driver-class-name=com.mysql.jdbc.Driver #spring.datasource.driver-class-name=com.mysql.jdbc.Driver
#
#tdl.redis.host=witcloud-redis #tdl.redis.host=witcloud-redis
#
# InfluxDB ## InfluxDB
#spring.influxdb.url=http://witcloud-influxdb:8086 #spring.influxdb.url=http://witcloud-influxdb:8086
#
#tdl.mqtt.url = ssl://47.96.128.181 #tdl.mqtt.url = ssl://47.96.128.181
#tdl.mqtt.port = 8883 #tdl.mqtt.port = 8883
#tdl.mqtt.username = logistics #tdl.mqtt.username = logistics
......
spring.datasource.url=jdbc:mysql://192.168.1.16:3306/tdlcloud?useUnicode=true&characterEncoding=utf-8&useSSL=false spring.datasource.url=jdbc:mysql://47.97.184.225:3306/tdlcloud?useUnicode=true&characterEncoding=utf-8&useSSL=false
spring.datasource.username=root spring.datasource.username=root
spring.datasource.password=37774020 spring.datasource.password=37774020
spring.datasource.driver-class-name=com.mysql.jdbc.Driver spring.datasource.driver-class-name=com.mysql.jdbc.Driver
...@@ -61,17 +61,18 @@ spring.influxdb.write-timeout=10 ...@@ -61,17 +61,18 @@ spring.influxdb.write-timeout=10
spring.influxdb.gzip=true spring.influxdb.gzip=true
#tdl.core.add =http://logisticscore-java:8079/witium/addMount #tdl.core.add =http://192.168.1.16:8079/witium/addMount
#tdl.core.delete =http://logisticscore-java:8079/witium/delMount #tdl.core.delete =http://192.168.1.16:8079/witium/delMount
#
#mqtt.userName = ugen
#mqtt.password = ugen
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 tdl.core.add =http://logisticscore-java:8079/witium/addMount
mqtt.password = ugen tdl.core.delete =http://logisticscore-java:8079/witium/delMount
#mqtt.userName = wtlogistics mqtt.userName = wtlogistics
#mqtt.password = wtlogistics mqtt.password = wtlogistics
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
from company from company
WHERE state=1 WHERE state=1
<if test="companyNo!='TM201803298320'"> <if test="companyNo!='TM201803298320'">
and pid=(SELECT id from company where companyNo=#{companyNo,jdbcType=VARCHAR}) and companyNo=#{companyNo,jdbcType=VARCHAR}
</if> </if>
</select> </select>
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
#{tel,mode=IN,jdbcType=VARCHAR}, #{tel,mode=IN,jdbcType=VARCHAR},
#{manager,mode=IN,jdbcType=VARCHAR}, #{manager,mode=IN,jdbcType=VARCHAR},
#{img,mode=IN,jdbcType=VARCHAR}, #{img,mode=IN,jdbcType=VARCHAR},
#{parentCompanyNo,mode=IN,jdbcType=VARCHAR},
#{roleName,mode=IN,jdbcType=VARCHAR}, #{roleName,mode=IN,jdbcType=VARCHAR},
#{createTime,mode=IN,jdbcType=VARCHAR}, #{createTime,mode=IN,jdbcType=VARCHAR},
#{msg,mode=OUT,jdbcType=VARCHAR} #{msg,mode=OUT,jdbcType=VARCHAR}
......
...@@ -118,7 +118,7 @@ ...@@ -118,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,min(createTime) startTime SELECT DISTINCT gatewaySN gSN, 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)
......
...@@ -60,6 +60,15 @@ ...@@ -60,6 +60,15 @@
and ISNULL(endTime) and ISNULL(endTime)
</select> </select>
<select id="getTimeByWarehouseNo" parameterType="String" resultType="java.lang.Long">
select min(tgl.createTime) createTime
from tdl_gateway_log tgl,warehouse w
where tgl.warehouseNo = w.warehouseNo
and w.warehouseNo=#{warehouseNo,jdbcType=VARCHAR}
and tgl.gatewaySN = #{gatewaySN,jdbcType=VARCHAR}
and ISNULL(endTime)
</select>
<select id="getByWarehouseNoAndTime" parameterType="com.example.tdl.domain.vo.DownloadForWarehouseVo" resultType="com.example.tdl.domain.vo.ResultWarehouseNoAndTDLSNAndTimeVo"> <select id="getByWarehouseNoAndTime" parameterType="com.example.tdl.domain.vo.DownloadForWarehouseVo" resultType="com.example.tdl.domain.vo.ResultWarehouseNoAndTDLSNAndTimeVo">
SELECT TDLSN,gatewaySN,gatewayType,warehouseNo,alarmType,temMax,temMin,humidityMax,humidityMin,t.createTime,t.endTime SELECT TDLSN,gatewaySN,gatewayType,warehouseNo,alarmType,temMax,temMin,humidityMax,humidityMin,t.createTime,t.endTime
from tdl_gateway_log t INNER JOIN alarm a ON t.alarm_id=a.id from tdl_gateway_log t INNER JOIN alarm a ON t.alarm_id=a.id
......
...@@ -13,6 +13,17 @@ ...@@ -13,6 +13,17 @@
order by createTime desc order by createTime desc
</select> </select>
<select id="getAllWarehouse" resultType="com.example.tdl.domain.vo.ResultWarehouseVo">
select w.warehouseNo,w.img,warehouseName,ct.country,ct.city,CONCAT_WS("-",ct.country,ct.city) regions ,w.addressDetail,r.regionName,lng,lat,property,
type,hardwareLevel,areaIndoor,areaRack,areaOutdoor,areaPlanIndoor,office,timeZone,warehouseInfo,companyName,w.remark
from warehouse w,region r,city ct ,company c
where c.id = w.company_id
and r.id = w.region_id
and ct.id = w.city_id
order by createTime desc
</select>
<!-- 根据条件查询仓库信息--> <!-- 根据条件查询仓库信息-->
<select id="getAllByTerm" resultType="com.example.tdl.domain.vo.ResultWarehouseVo" parameterType="com.example.tdl.domain.vo.WarehouseTermVo"> <select id="getAllByTerm" resultType="com.example.tdl.domain.vo.ResultWarehouseVo" parameterType="com.example.tdl.domain.vo.WarehouseTermVo">
select warehouseNo,w.img,warehouseName,ct.country,ct.city,CONCAT_WS("-",ct.country,ct.city) regions ,w.addressDetail,r.regionName,lng,lat,property, select warehouseNo,w.img,warehouseName,ct.country,ct.city,CONCAT_WS("-",ct.country,ct.city) regions ,w.addressDetail,r.regionName,lng,lat,property,
......
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