Commit a0e46451 authored by zhuangzhuang's avatar zhuangzhuang

5.30--修改仓库,tdl 预警逻辑

parent 919fccbc
......@@ -22,8 +22,6 @@ public class AddWarehouseVo {
private String type;//类型
private String alarmType;
private String hardwareLevel;//硬件等级
private Double areaIndoor;//室内平面面积
......@@ -122,14 +120,6 @@ public class AddWarehouseVo {
this.type = type;
}
public String getAlarmType() {
return alarmType;
}
public void setAlarmType(String alarmType) {
this.alarmType = alarmType;
}
public String getHardwareLevel() {
return hardwareLevel;
}
......
......@@ -26,8 +26,6 @@ public class ResultWarehouseVo {
private String type;//类型
private String alarmType;
private String hardwareLevel;//硬件等级
private Double areaIndoor;//室内平面面积
......@@ -144,14 +142,6 @@ public class ResultWarehouseVo {
this.type = type;
}
public String getAlarmType() {
return alarmType;
}
public void setAlarmType(String alarmType) {
this.alarmType = alarmType;
}
public String getHardwareLevel() {
return hardwareLevel;
}
......
......@@ -21,8 +21,6 @@ public class UpdateWarehouseVo {
private String type;//类型
private String alarmType;
private String hardwareLevel;//硬件等级
private Double areaIndoor;//室内平面面积
......@@ -123,14 +121,6 @@ public class UpdateWarehouseVo {
this.type = type;
}
public String getAlarmType() {
return alarmType;
}
public void setAlarmType(String alarmType) {
this.alarmType = alarmType;
}
public String getHardwareLevel() {
return hardwareLevel;
}
......
......@@ -25,5 +25,5 @@ public interface AlarmMapper {
List<AlarmTypeVo> getForTransportation(String companyName);
ResultAlarmVo getAlarmByWarehouseNo(@Param("warehouseNo") String warehouseNo);
ResultAlarmVo getAlarmByWarehouseNo(@Param("warehouseNo") String warehouseNo ,@Param("gatewaySN")String gatewaySN,@Param("TDLSN")String TDLSN);
}
......@@ -3,6 +3,7 @@ package com.example.tdl.service;
import com.example.tdl.domain.vo.*;
import com.example.tdl.mapper.AlarmMapper;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -46,8 +47,8 @@ public class AlarmService {
return alarmMapper.getForTransportation(companyName);
}
public ResultAlarmVo getAlarmByWarehouseNo(String warehouseNo){
return alarmMapper.getAlarmByWarehouseNo(warehouseNo);
public ResultAlarmVo getAlarmByWarehouseNo(String warehouseNo,String SN, String TDLSN){
return alarmMapper.getAlarmByWarehouseNo(warehouseNo,SN, TDLSN);
}
}
......@@ -50,7 +50,7 @@ public class PicUploadController {
})
@RequestMapping(value = "/upload",method = RequestMethod.POST)
public String upload(MultipartFile multipartFile, @RequestParam(value = "imageType",required = true) String imageType) {
if (multipartFile.isEmpty() || StringUtils.isBlank(multipartFile.getOriginalFilename())) {
if (multipartFile == null ||multipartFile.isEmpty() || StringUtils.isBlank(multipartFile.getOriginalFilename())) {
fb.setCode(0);
fb.setMessage("图片不能为空");
return gson.toJson(fb);
......@@ -86,7 +86,7 @@ public class PicUploadController {
fb.setMessage("https://tdlcloud.oss-cn-shanghai.aliyuncs.com/pic/companyLog/" + url);
}else if("palte".equals(imageType)){
fb.setMessage("https://tdlcloud.oss-cn-shanghai.aliyuncs.com/pic/palteImage/" + url);
}else if ("wareHouse".equals(imageType)){
}else if ("warehouse".equals(imageType)){
fb.setMessage("https://tdlcloud.oss-cn-shanghai.aliyuncs.com/pic/wareHouseImage/" + url);
}else if("circuit".equals(imageType)){
fb.setMessage("https://tdlcloud.oss-cn-shanghai.aliyuncs.com/pic/userImage/" + url);
......
......@@ -144,6 +144,24 @@ public class WarehouseController {
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo userRedisVo = gson.fromJson(datum,UserRedisVo.class);
if(StringUtils.isEmpty(warehouseTermVo.getCity())){
warehouseTermVo.setCity(null);
}
if(StringUtils.isEmpty(warehouseTermVo.getCountry())){
warehouseTermVo.setCountry(null);
}
if(StringUtils.isEmpty(warehouseTermVo.getHardwareLevel())){
warehouseTermVo.setHardwareLevel(null);
}
if(StringUtils.isEmpty(warehouseTermVo.getProperty())){
warehouseTermVo.setProperty(null);
}
if(StringUtils.isEmpty(warehouseTermVo.getType())){
warehouseTermVo.setType(null);
}
if(StringUtils.isEmpty(warehouseTermVo.getWarehouseName())){
warehouseTermVo.setWarehouseName(null);
}
warehouseTermVo.setCompanyName(userRedisVo.getCompanyName());
return warehouseService.getAllByTerm(warehouseTermVo);
}
......@@ -170,18 +188,30 @@ public class WarehouseController {
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo userRedisVo = gson.fromJson(datum,UserRedisVo.class);
warehouseTermVo.setCompanyName(userRedisVo.getCompanyName());
if(StringUtils.isEmpty(warehouseTermVo.getCity())){
warehouseTermVo.setCity(null);
}
if(StringUtils.isEmpty(warehouseTermVo.getCompanyName())){
warehouseTermVo.setCompanyName(null);
}
if(StringUtils.isEmpty(warehouseTermVo.getCountry())){
warehouseTermVo.setCountry(null);
}
if(StringUtils.isEmpty(warehouseTermVo.getgSN())){
warehouseTermVo.setgSN(null);
}
List<SimpleWarehouseVo> simpleWarehouseVos = warehouseService.getByWarehouse(warehouseTermVo);
for( int i = 0,length= simpleWarehouseVos.size();i<length;i++ ){
//判断是否已经绑定设备
if(simpleWarehouseVos.get(i).getCount() == 0){
simpleWarehouseVos.get(i).setTemp("~");
simpleWarehouseVos.get(i).setTemp("~");
simpleWarehouseVos.get(i).setHumidity("~");
continue;
}
List<DeviceVo> list = warehouseService.getDevice(simpleWarehouseVos.get(i).getWarehouseNo());
if(list.size() == 0){
simpleWarehouseVos.get(i).setTemp("~");
simpleWarehouseVos.get(i).setTemp("~");
simpleWarehouseVos.get(i).setHumidity("~");
continue;
}
String sql = "";
......@@ -199,13 +229,13 @@ public class WarehouseController {
}
if(StringUtils.isEmpty(sql)){
simpleWarehouseVos.get(i).setTemp("~");
simpleWarehouseVos.get(i).setTemp("~");
simpleWarehouseVos.get(i).setHumidity("~");
continue;
}
QueryResult queryResult = influxDBTemplate.query(new Query(sql,database));
if(queryResult.getResults().get(0).getSeries()== null){
simpleWarehouseVos.get(i).setTemp("~");
simpleWarehouseVos.get(i).setTemp("~");
simpleWarehouseVos.get(i).setHumidity("~");
continue;
}
//解析温湿度数据
......@@ -404,16 +434,6 @@ public class WarehouseController {
fb.setMessage("请输入正确的仓库类型");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(addWarehouseVo.getAlarmType())){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"alarmType"));
return gson.toJson(fb);
}
if(alarmService.getAllByAlarmType(user.getCompanyName(),addWarehouseVo.getAlarmType()) == null){
fb.setCode(0);
fb.setMessage("预警类型不存在");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(addWarehouseVo.getHardwareLevel())){
fb.setCode(0);
fb.setMessage("硬件等级不能为空");
......@@ -471,7 +491,6 @@ public class WarehouseController {
map.put("regionName",addWarehouseVo.getRegionName());
map.put("property",addWarehouseVo.getProperty());
map.put("type",addWarehouseVo.getType());
map.put("alarmType",addWarehouseVo.getAlarmType());
map.put("hardwareLevel",addWarehouseVo.getHardwareLevel());
map.put("areaIndoor",addWarehouseVo.getAreaIndoor());
map.put("areaRack",addWarehouseVo.getAreaRack());
......@@ -604,11 +623,7 @@ public class WarehouseController {
fb.setMessage("请输入正确的仓库仓库类型");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(updateWarehouseVo.getAlarmType())){
fb.setCode(0);
fb.setMessage("预警类型不能为空");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(updateWarehouseVo.getHardwareLevel())){
fb.setCode(0);
fb.setMessage("硬件等级不能为空");
......@@ -667,7 +682,6 @@ public class WarehouseController {
map.put("regionName",updateWarehouseVo.getRegionName());
map.put("property",updateWarehouseVo.getProperty());
map.put("type",updateWarehouseVo.getType());
map.put("alarmType",updateWarehouseVo.getAlarmType());
map.put("hardwareLevel",updateWarehouseVo.getHardwareLevel());
map.put("areaIndoor",updateWarehouseVo.getAreaIndoor());
map.put("areaRack",updateWarehouseVo.getAreaRack());
......@@ -731,6 +745,8 @@ public class WarehouseController {
return gson.toJson(fb);
}
@ApiOperation(value="添加网关",notes = "添加网关,传值:" +
"warehouseNo:仓库编号" +
"SN:网关编号")
......@@ -847,7 +863,7 @@ public class WarehouseController {
warehouseNo=(String) jsonObject.get("warehouseNo");
List<WarehouseGatewayDateVo> warehouseGatewayDateVoList=new ArrayList<>();
List<GatewayOnLineVo> gatewayOnLineVos=gatewayService.getByWarehouseNo(warehouseNo);
ResultAlarmVo resultAlarmVo=alarmService.getAlarmByWarehouseNo(warehouseNo);
for (int a=0;a<gatewayOnLineVos.size();a++){
WarehouseGatewayDateVo warehouseGatewayDateVo=new WarehouseGatewayDateVo();
warehouseGatewayDateVo.setgSN(gatewayOnLineVos.get(a).getSN());
......@@ -857,10 +873,10 @@ public class WarehouseController {
List<String> tdls=tdlDeviceService.getByGatewaySN(gatewayOnLineVos.get(a).getSN(),gatewayOnLineVos.get(a).getType());
List<WarehouseDataVo> warehouseDataVos=new ArrayList<>();
for (int b=0;b<tdls.size();b++){
String sqls ="SELECT \"tdl\",\"T\", \"h\" FROM \"tdl_policy\".\""+device+"\" WHERE (\"tdl\" = '"+tdls.get(b)+"') ORDER BY time DESC ";
String sqls ="SELECT \"tdl\",\"T\", \"h\" FROM \"tdl_policy\".\""+device+"\" WHERE (\"tdl\" = '"+tdls.get(b)+"') ORDER BY time ";
QueryResult queryResults = influxDBTemplate.query(new Query(sqls, database));
WarehouseDataVo warehouseDataVo=new WarehouseDataVo();
ResultAlarmVo resultAlarmVo=alarmService.getAlarmByWarehouseNo(warehouseNo,gatewayOnLineVos.get(a).getSN(),tdls.get(b).replace("TDL-","").trim());
List<WarehouseTDLDetailVo> warehouseTDLDetailVos=new ArrayList<>();
List<WarehouseTimeAndDataVo> warehouseTimeAndDataVos = new ArrayList<>();
List<WarehouseTimeAndDataVo> warehouseTimeAndDataVos1 = new ArrayList<>();
......@@ -937,8 +953,8 @@ public class WarehouseController {
List<GraphicDataVo> graphicDataList = new ArrayList<>();
List<TdlDataVo.HistoryDataVo> historyDataList = new ArrayList<>();
//获取TDL数据
// String sql = "SELECT \"T\",\"h\" FROM \"tdl_policy\".\""+deviceMessageVo.getType()+"_"+deviceMessageVo.getSN()+"\" where \"tdl\" = \'TDL-"+searchTdlVo.getTdlSN()+"\' order by time ";
String sql = "SELECT \"T\",\"h\" FROM \"tdl_policy\".\"WTD93LG_17110194\" where \"tdl\" = \'TDL-1706190193608\' order by time ";
String sql = "SELECT \"T\",\"h\" FROM \"tdl_policy\".\""+deviceMessageVo.getType()+"_"+deviceMessageVo.getSN()+"\" where \"tdl\" = \'TDL-"+searchTdlVo.getTDLSN()+"\' order by time ";
// String sql = "SELECT \"T\",\"h\" FROM \"tdl_policy\".\"WTD93LG_17110194\" where \"tdl\" = \'TDL-1706190193608\' order by time ";
QueryResult queryResult = influxDBTemplate.query(new Query(sql,database));
if(queryResult.getResults().get(0).getSeries()== null){
tdlDataVo.setGraphicDataList(graphicDataList);
......
spring.datasource.url=jdbc:mysql://housetest-mysql:3306/tdlCloud?useUnicode=true&characterEncoding=utf-8&useSSL=false
spring.datasource.username=root
spring.datasource.password=37774020
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
tdl.redis.host=housetest-redis
......
......@@ -80,7 +80,9 @@
<select id="getAlarmByWarehouseNo" parameterType="String" resultType="com.example.tdl.domain.vo.ResultAlarmVo">
SELECT alarmType,alarmScene,temMax,temMin,humidityMax,humidityMin,tilt,shock,a.remark
FROM warehouse w INNER JOIN alarm a ON w.alarm_id=a.id
where w.warehouseNo=#{warehouseNo,jdbcType=VARCHAR}
FROM tdl_gateway_log tgl INNER JOIN alarm a ON tgl.alarm_id=a.id
where warehouseNo=#{warehouseNo,jdbcType=VARCHAR}
AND gatewaySN=#{gatewaySN,jdbcType=VARCHAR}
AND TDLSN=#{TDLSN,jdbcType=VARCHAR}
</select>
</mapper>
\ No newline at end of file
......@@ -110,9 +110,7 @@
<!--根据仓库编号查询网关信息-->
<select id="getByWarehouseNo" parameterType="String" resultType="com.example.tdl.domain.vo.GatewayOnLineVo">
SELECT SN,type from gateway
WHERE id IN (SELECT gateway_id from gateway_warehouse where warehouse_id=(
SELECT id from warehouse WHERE warehouseNo=#{warehouseNo,jdbcType=VARCHAR}))
SELECT gatewaySN SN, gatewayType type from tdl_gateway_log where warehouseNo=#{warehouseNo,jdbcType=VARCHAR}
</select>
......
......@@ -3,23 +3,22 @@
<mapper namespace="com.example.tdl.mapper.WarehouseMapper">
<!--查询所有仓库信息-->
<select id="getAll" resultType="com.example.tdl.domain.vo.ResultWarehouseVo">
select warehouseNo,w.img,warehouseName,c.country,c.city,CONCAT_WS("-",c.country,c.city) regions ,w.addressDetail,r.regionName,lng,lat,a.alarmType,property,
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,alarm a,region r,city ct ,company c
from warehouse w,region r,city ct ,company c
where c.id = w.company_id
and a.id = w.alarm_id
and r.id = w.region_id
and ct.id = w.city_id
and c.companyName=#{companyName,jdbcType=VARCHAR}
order by createTime desc
</select>
<!-- 根据条件查询仓库信息-->
<select id="getAllByTerm" resultType="com.example.tdl.domain.vo.ResultWarehouseVo" parameterType="com.example.tdl.domain.vo.WarehouseTermVo">
select warehouseNo,w.img,warehouseName,c.country,c.city,CONCAT_WS("-",c.country,c.city) regions ,w.addressDetail,r.regionName,lng,lat,a.alarmType,property,
select warehouseNo,w.img,warehouseName,ct.country,ct.city,CONCAT_WS("-",ct.country,ct.city) regions ,w.addressDetail,r.regionName,lng,lat,property,
type,hardwareLevel,areaIndoor,areaRack,areaOutdoor,areaPlanIndoor,office,timeZone,warehouseInfo,companyName,w.remark
from warehouse w,alarm a,region r,city ct ,company c
from warehouse w,region r,city ct ,company c
where c.id = w.company_id
and a.id = w.alarm_id
and r.id = w.region_id
and ct.id = w.city_id
and c.companyName=#{companyName,jdbcType=VARCHAR}
......@@ -41,6 +40,7 @@
<if test="hardwareLevel!=null">
AND hardwareLevel=#{hardwareLevel,jdbcType=VARCHAR}
</if>
order by createTime desc
</select>
<select id="getWarehouseNo" resultType="java.lang.Integer" parameterType="String">
......@@ -48,11 +48,10 @@
</select>
<select id="getByWarehouseName" parameterType="String" resultType="com.example.tdl.domain.vo.ResultWarehouseVo">
select warehouseNo,w.img,warehouseName,c.country,c.city,CONCAT_WS("-",c.country,c.city) regions ,w.addressDetail,r.regionName,lng,lat,a.alarmType,property,
select warehouseNo,w.img,warehouseName,ct.country,ct.city,CONCAT_WS("-",ct.country,ct.city) regions ,w.addressDetail,r.regionName,lng,lat,property,
type,hardwareLevel,areaIndoor,areaRack,areaOutdoor,areaPlanIndoor,office,timeZone,warehouseInfo,companyName,w.remark
from warehouse w,alarm a,region r,city ct ,company c
from warehouse w,region r,city ct ,company c
where c.id = w.company_id
and a.id = w.alarm_id
and r.id = w.region_id
and ct.id = w.city_id
and c.companyName=#{companyName,jdbcType=VARCHAR}
......@@ -73,7 +72,6 @@
#{regionName,mode=IN,jdbcType=VARCHAR},
#{property,mode=IN,jdbcType=VARCHAR},
#{type,mode=IN,jdbcType=BIGINT},
#{alarmType,mode=IN,jdbcType=BIGINT},
#{hardwareLevel,mode=IN,jdbcType=BIGINT},
#{areaIndoor,mode=IN,jdbcType=VARCHAR},
#{areaRack,mode=IN,jdbcType=VARCHAR},
......@@ -107,7 +105,6 @@
#{regionName,mode=IN,jdbcType=VARCHAR},
#{property,mode=IN,jdbcType=VARCHAR},
#{type,mode=IN,jdbcType=BIGINT},
#{alarmType,mode=IN,jdbcType=BIGINT},
#{hardwareLevel,mode=IN,jdbcType=BIGINT},
#{areaIndoor,mode=IN,jdbcType=VARCHAR},
#{areaRack,mode=IN,jdbcType=VARCHAR},
......@@ -181,10 +178,7 @@
</insert>
<select id = "getGateway" parameterType="String" resultType="com.example.tdl.domain.vo.GatewaySNVo">
select g.SN from gateway_warehouse gw,warehouse w,gateway g
where gw.gateway_id=g.id
and gw.warehouse_id = w.id
and w.warehouseNo=#{warehouseNo,jdbcType=VARCHAR}
select DISTINCT gatewaySN SN from tdl_gateway_log WHERE warehouseNo=#{warehouseNo,jdbcType=VARCHAR}
</select>
<select id="getByWarehouseNoAndSN" resultType="java.lang.Integer" parameterType="String">
......@@ -211,7 +205,7 @@
</select>
<select id="getByWarehouse" parameterType="com.example.tdl.domain.vo.WareHouseByTermVo" resultType="com.example.tdl.domain.vo.SimpleWarehouseVo">
select warehouseNo, warehouseName,CONCAT_WS("-",c.country,c.city) regions,c.country,c.city, (select count(id) from tdldevice t where t.warehouse_id = w.id ) count,property,type,hardwareLevel,areaPlanIndoor
select warehouseNo, warehouseName,CONCAT_WS("-",ct.country,ct.city) regions,ct.country,ct.city, (select count(id) from tdldevice t where t.warehouse_id = w.id ) count,property,type,hardwareLevel,areaPlanIndoor
from warehouse w ,company c ,city ct
where c.id=w.company_id
and ct.id = w.city_id
......@@ -229,14 +223,10 @@
</select>
<select id="getDevice" parameterType="String" resultType="com.example.tdl.domain.vo.DeviceVo">
select w.warehouseNo,GROUP_CONCAT(CONCAT("TDL-",t.TDLSN)) tdl,t.TDLSN,g.SN,g.type,CONCAT(g.type,"_",g.SN) device,startTime,endTime
from gateway_warehouse gw,gateway g,tdldevice t,warehouse w,use_warehouse_log u
where gw.warehouse_id = w.id
and gw.gateway_id = g.id
and t.warehouse_id = w.id
and t.gateway_id = g.id
and u.warehouseNo = w.warehouseNo
and w.warehouseNo= #{warehouseNo,jdbcType=VARCHAR}
select w.warehouseNo,GROUP_CONCAT(CONCAT("TDL-",TDLSN)) tdl,gatewaySN SN,gatewaytype type,CONCAT(gatewaytype,"_",gatewaySN) device,tgl.createTime,tgl.endTime
from tdl_gateway_log tgl,warehouse w
where tgl.warehouseNo = w.warehouseNo
and w.warehouseNo=#{warehouseNo,jdbcType=VARCHAR}
</select>
<update id="updateImg">
......@@ -253,8 +243,8 @@
</select>
<select id="getWarehouseDetailByNo" parameterType="String" resultType="com.example.tdl.domain.vo.WarehouseDetailVo">
SELECT warehouseNo,warehouseName,c.country,c.city,addressDetail,(SELECT COUNT(id) from gateway_warehouse WHERE warehouse_id=w.id) gatewayCounts,
(SELECT COUNT(id) FROM tdldevice WHERE warehouse_id=w.id) tdlCounts,,property,type,hardwareLevel,areaPlanIndoor
SELECT warehouseNo,warehouseName,c.country,c.city,addressDetail,(SELECT COUNT(DISTINCT gatewaySN) from tdl_gateway_log WHERE warehouseNo=w.warehouseNo) gatewayCounts,
(SELECT COUNT(TDLSN) from tdl_gateway_log WHERE warehouseNo=w.warehouseNo) tdlCounts,property,type,hardwareLevel,areaPlanIndoor
from warehouse w INNER JOIN city c ON w.city_id=c.id
where warehouseNo=#{warehouseNo,jdbcType=VARCHAR}
</select>
......@@ -263,11 +253,11 @@
<select id="getDeviceMessage" parameterType="com.example.tdl.domain.vo.SearchTdlVo" resultType="com.example.tdl.domain.vo.DeviceMessageVo">
SELECT t.TDLName,g.SN,g.type,w.warehouseName,w.addressDetail,(SELECT regionName from region where w.region_id=id) regionName,
a.alarmType,a.temMax,a.temMin,a.humidityMax,a.humidityMin
from gateway_warehouse gw INNER JOIN warehouse w ON gw.warehouse_id=w.id,gateway g,tdldevice t,alarm a
where t.gateway_id=g.id
AND gw.gateway_id=g.id
AND w.alarm_id=a.id
AND warehouseNo=#{warehouseNo,jdbcType=VARCHAR}
from tdl_gateway_log tgl INNER JOIN warehouse w ON tgl.warehouseNo=w.warehouseNo,gateway g,tdldevice t,alarm a
where tgl.alarm_id=a.id
and tgl.gatewaySN=g.SN
AND tgl.TDLSN=t.TDLSN
AND w.warehouseNo=#{warehouseNo,jdbcType=VARCHAR}
AND g.SN=#{SN,jdbcType=VARCHAR}
AND t.TDLSN=#{TDLSN,jdbcType=VARCHAR}
</select>
......
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