Commit ce7d2c94 authored by zhuangzhuang's avatar zhuangzhuang

6.6--修改获取仓库详情

parent a39f3b50
......@@ -11,6 +11,8 @@ public class TDLDeviceDetailVo {
private String time;
private String gatewaySN;
public String getTDLSN() {
return TDLSN;
}
......@@ -50,4 +52,12 @@ public class TDLDeviceDetailVo {
public void setTime(String time) {
this.time = time;
}
public String getGatewaySN() {
return gatewaySN;
}
public void setGatewaySN(String gatewaySN) {
this.gatewaySN = gatewaySN;
}
}
package com.example.tdl.domain.vo;
public class WarehouseLogVo {
private String warehouseNo;
private String SN;
private String type;
private String device;
private Long createTime;
private Long endTime;
public String getWarehouseNo() {
return warehouseNo;
}
public void setWarehouseNo(String warehouseNo) {
this.warehouseNo = warehouseNo;
}
public String getSN() {
return SN;
}
public void setSN(String SN) {
this.SN = SN;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getDevice() {
return device;
}
public void setDevice(String device) {
this.device = device;
}
public Long getCreateTime() {
return createTime;
}
public void setCreateTime(Long createTime) {
this.createTime = createTime;
}
public Long getEndTime() {
return endTime;
}
public void setEndTime(Long endTime) {
this.endTime = endTime;
}
}
package com.example.tdl.mapper;
import com.example.tdl.domain.vo.DelAlarmVo;
import com.example.tdl.domain.vo.ResultAlarmVo;
import com.example.tdl.domain.vo.ResultGatewayVo;
import com.example.tdl.domain.vo.TDLLogVo;
import com.example.tdl.domain.vo.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
......@@ -24,4 +21,6 @@ public interface TDLLogMapper {
ResultAlarmVo getByTdl(@Param("transportationNo") String transportationNo, @Param("TDLSN") String TDLSN);
List<WarehouseLogVo> getByWarehouse(String warehouseNo);
}
package com.example.tdl.service;
import com.example.tdl.domain.vo.DelAlarmVo;
import com.example.tdl.domain.vo.ResultAlarmVo;
import com.example.tdl.domain.vo.ResultGatewayVo;
import com.example.tdl.domain.vo.TDLLogVo;
import com.example.tdl.domain.vo.*;
import com.example.tdl.mapper.TDLLogMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -41,4 +38,9 @@ public class TDLLogService {
public ResultAlarmVo getByTdl(String transportationNo,String TdlSN){
return tdlLogMapper.getByTdl(transportationNo,TdlSN);
}
public List<WarehouseLogVo> getByWarehouse(String warehouseNo){
return tdlLogMapper.getByWarehouse(warehouseNo);
}
}
......@@ -17,6 +17,10 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.IOException;
@RestController("/picUpload")
public class PicUploadController {
......@@ -60,6 +64,38 @@ public class PicUploadController {
fb.setMessage("上传图片大小不能超过5M!");
return gson.toJson(fb);
}
try {
BufferedImage sourceImg = ImageIO.read(multipartFile.getInputStream());
// 仓库 150*120 //货车 90*60
if(sourceImg == null){
fb.setCode(0);
fb.setMessage("上传图片格式不正确");
}else{
if("truck".equals(imageType)){
if(sourceImg.getHeight()>90){
fb.setCode(0);
fb.setMessage("上传图片尺寸不正确");
}
if(sourceImg.getWidth()>60){
fb.setCode(0);
fb.setMessage("上传图片尺寸不正确");
}
}else if("warehouse".equals(imageType)){
if(sourceImg.getHeight()>150){
fb.setCode(0);
fb.setMessage("上传图片尺寸不正确");
}
if(sourceImg.getWidth()>120){
fb.setCode(0);
fb.setMessage("上传图片尺寸不正确");
}
}
}
} catch (IOException e) {
e.printStackTrace();
fb.setCode(0);
fb.setMessage("上传图片格式不正确");
}
// 校验图片格式
boolean isLegal = false;
// 判断文件后缀名是否符合
......@@ -123,6 +159,38 @@ public class PicUploadController {
fb.setMessage("上传图片大小不能超过5M!");
return gson.toJson(fb);
}
try {
BufferedImage sourceImg = ImageIO.read(multipartFile.getInputStream());
// 仓库 150*120 //货车 90*60
if(sourceImg == null){
fb.setCode(0);
fb.setMessage("上传图片格式不正确");
}else{
if("truck".equals(imageType)){
if(sourceImg.getHeight()>90){
fb.setCode(0);
fb.setMessage("上传图片尺寸不正确");
}
if(sourceImg.getWidth()>60){
fb.setCode(0);
fb.setMessage("上传图片尺寸不正确");
}
}else if("warehouse".equals(imageType)){
if(sourceImg.getHeight()>150){
fb.setCode(0);
fb.setMessage("上传图片尺寸不正确");
}
if(sourceImg.getWidth()>120){
fb.setCode(0);
fb.setMessage("上传图片尺寸不正确");
}
}
}
} catch (IOException e) {
e.printStackTrace();
fb.setCode(0);
fb.setMessage("上传图片格式不正确");
}
boolean isLegal = false;
// 判断文件后缀名是否符合
for (String type : IMAGE_TYPE) {
......
......@@ -67,6 +67,8 @@ public class WarehouseController {
@Autowired
private InfluxDBTemplate influxDBTemplate;
private TDLLogService tdlLogService;
private final static String database ="original";
//查询所有仓库信息
......@@ -274,6 +276,7 @@ public class WarehouseController {
" humidity: 湿度," +
" time: 时间," +
" tdlsn: TDL编号" +
" gatewaySN:网关编号" +
" }" +
" ]," +
" sn: 设备编号" +
......@@ -288,35 +291,61 @@ public class WarehouseController {
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo userRedisVo = gson.fromJson(datum,UserRedisVo.class);
JSONObject jsonObject=JSON.parseObject(warehouseNo);
warehouseNo=(String) jsonObject.get("warehouseNo");
if (StringUtils.isEmpty(warehouseNo)){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"warehouseNo"));
return gson.toJson(fb);
}
JSONObject jsonObject= JSON.parseObject(warehouseNo);
warehouseNo=(String)jsonObject.get("warehouseNo");
if(warehouseService.getWarehouseNo(warehouseNo) ==0){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"Nonexistent"));
return gson.toJson(fb);
}
WarehouseDetailVo warehouseDetailVo=warehouseService.getWarehouseDetailByNo(warehouseNo);
List<GatewayOnLineVo> gatewayOnLineVos=gatewayService.getByWarehouseNo(warehouseNo);
for (int a=0;a<gatewayOnLineVos.size();a++){
String device = gatewayOnLineVos.get(a).getType() + "_" + gatewayOnLineVos.get(a).getSN();
Object data = infoRedisService.getHash("DeviceOnline", device );
//获取
List<WarehouseLogVo> list =tdlLogService.getByWarehouse(warehouseNo);
List<GatewayOnLineVo> gatewayOnLineVos=new ArrayList<>();
for (int a=0;a<list.size();a++){
if(list.get(a) == null){
continue;
}
if(list.get(a).getEndTime()!=null){
continue;
}
GatewayOnLineVo gatewayOnLineVo = new GatewayOnLineVo();
gatewayOnLineVo.setSN(list.get(a).getSN());
gatewayOnLineVo.setType(list.get(a).getType());
Object data = infoRedisService.getHash("DeviceOnline", list.get(a).getDevice() );
if(data !=null){
OnlineVo onlineVo = gson.fromJson(data.toString(),OnlineVo.class);
if(onlineVo.getOnline() == 1){
gatewayOnLineVos.get(a).setState(7);
gatewayOnLineVo.setState(7);
}else {
gatewayOnLineVos.get(a).setState(6);
gatewayOnLineVo.setState(6);
}
}else{
gatewayOnLineVos.get(a).setState(6);
gatewayOnLineVo.setState(6);
}
String sql ="SELECT \"battery\" FROM \"tdl_policy\".\""+device+"\" ORDER BY time DESC LIMIT 1";
String sql ="SELECT \"battery\" FROM \"tdl_policy\".\""+list.get(a).getDevice() +"\" ORDER BY time DESC LIMIT 1";
QueryResult queryResult = influxDBTemplate.query(new Query(sql, database));
if (queryResult.getResults().get(0).getSeries() != null) {
gatewayOnLineVos.get(a).setBattery(queryResult.getResults().get(0).getSeries().get(0).getValues().get(0).get(1).toString());
if(Double.valueOf(queryResult.getResults().get(0).getSeries().get(0).getValues().get(0).get(1).toString())>0){
gatewayOnLineVo.setBattery(queryResult.getResults().get(0).getSeries().get(0).getValues().get(0).get(1)==null ? "NA" :queryResult.getResults().get(0).getSeries().get(0).getValues().get(0).get(1).toString());
}else{
gatewayOnLineVo.setBattery("NA");
}
}else {
gatewayOnLineVos.get(a).setBattery("");
gatewayOnLineVo.setBattery("NA");
}
List<String> tdls=tdlDeviceService.getByGatewaySN(gatewayOnLineVos.get(a).getSN(),gatewayOnLineVos.get(a).getType());
List<String> tdls=tdlDeviceService.getByGatewaySN(list.get(a).getSN(),list.get(a).getType());
List<TDLDeviceDetailVo> tdlDeviceDetailVos=new ArrayList<>();
for (int b=0;b<tdls.size();b++){
TDLDeviceDetailVo tdlDeviceDetailVo=new TDLDeviceDetailVo();
String sqls ="SELECT \"b\", \"T\", \"h\" FROM \"tdl_policy\".\""+device+"\" WHERE (\"tdl\" = '"+tdls.get(b)+"') ORDER BY time DESC LIMIT 1";
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";
QueryResult queryResults = influxDBTemplate.query(new Query(sqls, database));
if (queryResults.getResults().get(0).getSeries() != null) {
tdlDeviceDetailVo.setTime(parseTime(queryResults.getResults().get(0).getSeries().get(0).getValues().get(0).get(0).toString()));
......@@ -324,15 +353,16 @@ public class WarehouseController {
tdlDeviceDetailVo.setTemperature(queryResults.getResults().get(0).getSeries().get(0).getValues().get(0).get(2).toString());
tdlDeviceDetailVo.setHumidity(queryResults.getResults().get(0).getSeries().get(0).getValues().get(0).get(3).toString());
}else{
tdlDeviceDetailVo.setTime("");
tdlDeviceDetailVo.setPressure("");
tdlDeviceDetailVo.setPressure("");
tdlDeviceDetailVo.setHumidity("");
tdlDeviceDetailVo.setTime("NA");
tdlDeviceDetailVo.setPressure("NA");
tdlDeviceDetailVo.setTemperature("NA");
tdlDeviceDetailVo.setHumidity("NA");
}
tdlDeviceDetailVo.setTDLSN(tdls.get(b));
tdlDeviceDetailVo.setTDLSN(tdls.get(b).replace("TDL-","").trim());
tdlDeviceDetailVos.add(tdlDeviceDetailVo);
}
gatewayOnLineVos.get(a).setTdlDeviceDetailVos(tdlDeviceDetailVos);
gatewayOnLineVo.setTdlDeviceDetailVos(tdlDeviceDetailVos);
gatewayOnLineVos.add(gatewayOnLineVo);
}
warehouseDetailVo.setGatewayOnLineVos(gatewayOnLineVos);
return warehouseDetailVo;
......
......@@ -41,4 +41,13 @@
and transportationNo = #{transportationNo,jdbcType=VARCHAR}
and TDLSN = #{TDLSN,jdbcType=VARCHAR}
</select>
<select id="getByWarehouse" parameterType="String" resultType="com.example.tdl.domain.vo.WarehouseLogVo">
select DISTINCT CONCAT( gatewaytype,"_",gatewaySN) device, tgl.gatewaySN SN,gatewaytype type, w.warehouseNo
from tdl_gateway_log tgl,warehouse w
where tgl.warehouseNo = w.warehouseNo
and w.warehouseNo=#{warehouseNo,jdbcType=VARCHAR}
and ISNULL(endTime)
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment