vince
2024-03-01 f7178996ca77a1bccc941c0e7a73b36803e508cb
优化协议
已修改9个文件
已添加7个文件
539 ■■■■■ 文件已修改
src/main/java/com/fzzy/api/Constant.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/gateway/entity/GatewayDevice.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/gateway/hx2023/data/GrainData.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/gateway/hx2023/data/GrainOutPut.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/gateway/view/GatewayDevice.view.xml 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/protocol/bhzn/analysis/AnalysisService.java 51 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/protocol/bhzn/service/Bhzn2GatewayGrainService.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/protocol/fzzy/analysis/AnalysisSystem.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/protocol/fzzy/service/FzzyGatewayGrainService.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ld/igds/grain/dto/GrainData.java 111 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ld/igds/grain/dto/GrainIotData.java 57 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ld/igds/grain/dto/GrainLay.java 56 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ld/igds/grain/dto/GrainPoint.java 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ld/igds/grain/dto/GrainRow.java 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ld/igds/models/Depot.java 89 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ld/igds/models/MQuality.java 59 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/api/Constant.java
@@ -325,7 +325,7 @@
    public static ApiCommonDevice getCommonDeviceCache(String sn) {
        if (null == sn) return null;
        log.info("在线设备:" + JSON.toJSONString(contextDeviceMap));
        //log.info("在线设备:" + JSON.toJSONString(contextDeviceMap));
        return contextDeviceMap.get(sn);
    }
@@ -333,7 +333,7 @@
        if (null == ip) return null;
        if (contextDeviceMap.isEmpty()) return null;
        log.info("在线设备:" + JSON.toJSONString(contextDeviceMap));
        //log.info("在线设备:" + JSON.toJSONString(contextDeviceMap));
        for (ApiCommonDevice device : contextDeviceMap.values()) {
            if (ip.equals(device.getIp())) return device;
        }
src/main/java/com/fzzy/gateway/entity/GatewayDevice.java
@@ -153,4 +153,8 @@
    @PropertyDef(label = "备注", description = "备注信息")
    private String remark;
    @Column(name = "BH_ID_", length = 50)
    @PropertyDef(label = "分机内部仓库编码")
    private String bhId;
}
src/main/java/com/fzzy/gateway/hx2023/data/GrainData.java
@@ -28,4 +28,5 @@
    private JSONObject properties;
}
src/main/java/com/fzzy/gateway/hx2023/data/GrainOutPut.java
@@ -39,5 +39,8 @@
    private List<GrainTemp> temperature;
    private String liquidHeight = "0.0";
    private String detectTime ;
}
src/main/java/com/fzzy/gateway/view/GatewayDevice.view.xml
@@ -150,13 +150,17 @@
        <Property name="label">电缆类型</Property>
      </PropertyDef>
      <PropertyDef name="depotType">
        <Property/>
        <Property></Property>
        <Property name="label">仓库类型</Property>
        <Property name="mapping">
          <Property name="mapValues">${dorado.getDataProvider(&quot;apiTriggerPR#listDepotType&quot;).getResult()}</Property>
          <Property name="keyProperty">code</Property>
          <Property name="valueProperty">name</Property>
        </Property>
      </PropertyDef>
      <PropertyDef name="bhId">
        <Property></Property>
        <Property name="label">分机内部仓库编码</Property>
      </PropertyDef>
    </DataType>
    <DataType name="dtParam" parent="Map">
@@ -449,7 +453,12 @@
                  <Property name="property">position</Property>
                  <Editor/>
                </AutoFormElement>
                <AutoFormElement layoutConstraint="colSpan:2">
                <AutoFormElement>
                  <Property name="name">bhId</Property>
                  <Property name="property">bhId</Property>
                  <Editor/>
                </AutoFormElement>
                <AutoFormElement layoutConstraint="colSpan:1">
                  <Property name="name">remark</Property>
                  <Property name="property">remark</Property>
                  <Editor/>
src/main/java/com/fzzy/protocol/bhzn/analysis/AnalysisService.java
@@ -125,7 +125,7 @@
            //获取请求信息
            BaseReqData reqData = ProtocolUtils.getSyncReq(gatewayDevice.getDepotIdSys());
            BaseReqData reqData = ProtocolUtils.getSyncReq(gatewayDevice.getDeviceSn());
            if (null == reqData) {
                replayGrain(message);
                log.error("主机-------->>平台,解析粮情失败,未获取到粮情请求信息:" + message.getAddr());
@@ -350,18 +350,46 @@
        JSONObject properties = new JSONObject();
        properties.put("data", outPut);
        properties.put("timestamp", grain.getTimestamp());
        properties.put("timestamp", grain.getTimestamp());
        outPut.setDetectTime( grain.getTimestamp());
        String height = this.getCacheHeight(device);
        if (StringUtils.isEmpty(height)) height = "0.0";
        properties.put("liquidHeight", height);
        grain.setProperties(properties);
        outPut.setLiquidHeight(height);
        grain.setOutput(JSONObject.toJSONString(outPut));
        properties.put("output", outPut);
        GatewayDevice gatewayDeviceWeather = GatewayUtils.getCacheByDeviceTypeOne(GatewayDeviceType.TYPE_09.getCode());
        //系统气象站信息
        WeatherWebDto weather = WeatherWebDto.contextMap.get("default");
        //气象信息
        GrainWeather weatherStation = new GrainWeather();
        weatherStation.setMessageId(ScConstant.getMessageId());
        weatherStation.setMessgeId(weatherStation.getMessageId());
        if (null != gatewayDeviceWeather) {
            weatherStation.setId(gatewayDeviceWeather.getDeviceId());
        } else {
            weatherStation.setId(device.getDeviceId());
        }
        weatherStation.setAirPressure(weather.getPressure());
        weatherStation.setHumidity(weather.getHumidity());
        weatherStation.setPm(weather.getAir_pm25());
        weatherStation.setRadiation("0");
        weatherStation.setRainfallAmount(weather.getWea());
        weatherStation.setTemperature(weather.getTem());
        weatherStation.setWindDirection(weather.getWin());
        weatherStation.setWindPower(weather.getWin_meter());
        weatherStation.setWindSpeed(weather.getWin_speed());
        grain.setWeatherStation(JSONObject.toJSONString(weatherStation));
        //封装好的数据
        log.info("---油罐仓信息封装完成----开始执行推送");
        grain.setProperties(properties);
        reqData.setData(JSONObject.toJSONString(grain));
        doPushGrain(reqData);
@@ -375,8 +403,17 @@
     */
    private String getCacheHeight(GatewayDevice device) {
        //给其他软使用
        String key = RedisConst.KEY_DEPOT_HEIGHT + ":" + configData.getCompanyId() + "_" + device.getDepotIdSys();
        return (String) redisUtil.get(key);
        //igds:5012:DEPOT_HEIGHT:0134
        String key = "igds:"+ device.getOrgId() + ":"  + RedisConst.KEY_DEPOT_HEIGHT+ ":" + device.getDepotIdSys();
        com.ld.igds.grain.dto.GrainData ht = (com.ld.igds.grain.dto.GrainData) redisUtil.get(key);
        log.info("KEY="+key);
        if(ht!=null){
            log.info("VALUE="+ht.getOilHeight());
            return ht.getOilHeight() ;
        }else {
            return "0.0";
        }
    }
src/main/java/com/fzzy/protocol/bhzn/service/Bhzn2GatewayGrainService.java
@@ -58,10 +58,10 @@
        try {
            //Step è¯·æ±‚信息放入内存
            ProtocolUtils.addSyncReq2Map(device.getDepotIdSys(), reqData);
            ProtocolUtils.addSyncReq2Map(device.getDeviceSn(), reqData);
            // ç”Ÿæˆç²®æƒ…信息
            String hexStr = CommandBuild.getInstance().getMsgCheck(device.getDeviceSn(), device.getDepotIdSys());
            String hexStr = CommandBuild.getInstance().getMsgCheck(device.getDeviceSn(), device.getBhId());
            // å‘送命令
            InvokeResult message = BhznGrainV2ServerEngine.push(device.getIp(), device.getPort(), BytesUtil.hexStrToBytes(hexStr));
src/main/java/com/fzzy/protocol/fzzy/analysis/AnalysisSystem.java
@@ -36,10 +36,11 @@
    public void analysis1001(ReMessage reMessage) {
        //获取到登陆信息,执行设备信息整理
        ApiCommonDevice device = Constant.getCommonDeviceCache(reMessage.getSn());
        if (null == device) {
            device = new ApiCommonDevice();
        GatewayDevice d = GatewayUtils.getCacheByDeviceSn(reMessage.getSn());
        if (null == d) {
            d = new GatewayDevice();
        }
        ApiCommonDevice device = new ApiCommonDevice();
        device.setIp(reMessage.getIp());
        device.setPort(reMessage.getPort());
        device.setSn(reMessage.getSn());
src/main/java/com/fzzy/protocol/fzzy/service/FzzyGatewayGrainService.java
@@ -36,8 +36,7 @@
        GatewayDevice device = reqData.getDevice();
        //获取连接中的设备信息
        ApiCommonDevice apiCommonDevice = Constant.getCommonDeviceCache(device.getIp());
        ApiCommonDevice apiCommonDevice = Constant.getCommonDeviceCacheBySn(device.getDeviceSn());
        if (null == apiCommonDevice) {
            resp.setCode(500);
            resp.setMsg("系统未获取到下行连接设备信息,无法执行");
src/main/java/com/ld/igds/grain/dto/GrainData.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,111 @@
package com.ld.igds.grain.dto;
import com.bstek.dorado.annotation.PropertyDef;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ld.igds.models.Depot;
import com.ld.igds.models.MQuality;
import lombok.Data;
import javax.persistence.Transient;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
 * ç”¨äºŽå°è£…的粮情信息,每次获取粮情数据,封装为当前对象
 *
 * @author jiazx
 */
@Data
public class GrainData implements Serializable {
    /**
     *
     */
    private static final long serialVersionUID = 1L;
    @PropertyDef(label = "批次编号")
    private String batchId;
    @PropertyDef(label = "组织编码", description = "")
    private String companyId;
    @PropertyDef(label = "所属仓库", description = "仓库编号")
    private String depotId;
    @PropertyDef(label = "最低温粮温", description = "单位℃,粮情最低温")
    private Double tempMin = 0.0;
    @PropertyDef(label = "最高粮温", description = "单位℃,粮情最高温")
    private Double tempMax = 0.0;
    @PropertyDef(label = "平均粮温", description = "单位℃,粮情平均温度")
    private Double tempAve = 0.0;
    @PropertyDef(label = "仓内湿度")
    private Double humidityIn;
    @PropertyDef(label = "仓内温度")
    private Double tempIn;
    @PropertyDef(label = "仓内湿度")
    private Double humidityOut;
    @PropertyDef(label = "仓外温度")
    private Double tempOut;
    @PropertyDef(label = "层行列", description = "用-隔开的配置信息")
    private String cable;
    @PropertyDef(label = "筒仓层配置", description = "用-隔开的配置信息")
    private String cableCir;
    @PropertyDef(label = "油面高度",description = "用-隔开的两个值,油面高度-建筑高度")
    private String oilHeight;
    @PropertyDef(label = "天气", description = "直接填写中文信息,晴,阴雨天")
    private String weather = "#";
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm",timezone = "GMT+8")
    @PropertyDef(label = "接收时间")
    private Date receiveDate;
    @PropertyDef(label = "检测人")
    private String checkUser;
    @PropertyDef(label = "备注")
    private String remark;
    @PropertyDef(label = "采集点信息", description = "用逗号隔开的温度信息信息")
    private String points;
    @PropertyDef(label = "各个采集点的信息", description = "关系字段")
    private List<GrainPoint> listPoints;
    @PropertyDef(label = "各层粮温", description = "关系字段")
    private List<GrainLay> listLays;
    @PropertyDef(label = "各行温度", description = "关系字段")
    private List<GrainRow> listRows;
    @PropertyDef(label = "仓房信息", description = "关系字段")
    private Depot depotData;
    @PropertyDef(label = "化验信息", description = "关系字段")
    private MQuality mquality;
    @PropertyDef(label = "系统时间", description = "关系字段")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm",timezone = "GMT+8")
    private Date sysDate = new Date();
    @PropertyDef(label = "建筑高度")
    private String depotHeight;
    @PropertyDef(label = "检测储量", description = "单位KG")
    private Double storage;
    @Transient
    @PropertyDef(label = "当前仓iot设备的温湿度数据")
    private List<GrainIotData> grainIotData;
}
src/main/java/com/ld/igds/grain/dto/GrainIotData.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,57 @@
package com.ld.igds.grain.dto;
import lombok.Data;
import java.io.Serializable;
/**
 * ç”¨äºŽå°è£…成品粮温湿度信息
 *
 * @author chen
 */
@Data
public class GrainIotData implements Serializable {
    /**
     *
     */
    private static final long serialVersionUID = 1L;
    /**
     * ç»„织编码
     */
    private String companyId;
    /**
     * ä»“库编码
     */
    private String depotId;
    /**
     * è®¾å¤‡ç¼–码
     */
    private String deviceId;
    /**
     * è®¾å¤‡åç§°
     */
    private String name;
    /**
     * æ—¶é—´
     */
    private String time;
    /**
     * æ¸©åº¦
     */
    private Double temp = 0.0;
    /**
     * æ¹¿åº¦
     */
    private Double hum = 0.0;
    /**
     * å¤–温
     */
    private Double outTemp = 0.0;
    /**
     * å¤–湿
     */
    private Double outHum = 0.0;
}
src/main/java/com/ld/igds/grain/dto/GrainLay.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,56 @@
package com.ld.igds.grain.dto;
import com.bstek.dorado.annotation.PropertyDef;
import lombok.Data;
/**
 * ç²®æƒ…数据解析对象-层信息
 */
@Data
public class GrainLay {
    @PropertyDef(label = "所在层")
    private int fz;
    @PropertyDef(label = "所在层")
    private int z;
    @PropertyDef(label = "层最低温")
    private Double tempMin;
    @PropertyDef(label = "层最高温")
    private Double tempMax;
    @PropertyDef(label = "层平均温")
    private Double tempAve = 0.0;
    @PropertyDef(label = "内圈平均温度", description = "单位℃,粮情平均温度")
    private Double tempAveIn = 0.0;
    @PropertyDef(label = "外圈平均温度", description = "单位℃,粮情平均温度")
    private Double tempAveOut = 0.0;
    private int sumNum;//当前层总数
    private int sumInNum;//内圈个数
    private int sumOutNum;//外圈个数
    private double sumTemp;//层总温度
    private double sumInTemp;
    private double sumOutTemp;
    public GrainLay() {
        super();
    }
    public GrainLay(int fz,int z) {
        super();
        this.fz = fz;
        this.z = z;
    }
}
src/main/java/com/ld/igds/grain/dto/GrainPoint.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,41 @@
package com.ld.igds.grain.dto;
import com.bstek.dorado.annotation.PropertyDef;
import lombok.Data;
/**
 * ç²®æƒ…数据解析对象-采集点对象信息,XYZ表示的列行层,数值从1开始。
 *
 */
@Data
public class GrainPoint {
    @PropertyDef(label = "所在层")
    private int z;
    @PropertyDef(label = "所在层")
    private int fz;
    @PropertyDef(label = "所在列,筒仓所在圈数")
    private int x;
    @PropertyDef(label = "所在行,筒仓根号,总根号")
    private int y;
    @PropertyDef(label = "采集点温度")
    private Double temp = 0.0;
    public GrainPoint() {
        super();
    }
    public GrainPoint(Double temp,int x, int y, int z, int fz) {
        super();
        this.z = z;
        this.x = x;
        this.y = y;
        this.fz = fz;
        this.temp = temp;
    }
}
src/main/java/com/ld/igds/grain/dto/GrainRow.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,36 @@
package com.ld.igds.grain.dto;
import com.bstek.dorado.annotation.PropertyDef;
import lombok.Data;
/**
 * ç²®æƒ…数据解析对象-列信息
 */
@Data
public class GrainRow {
    @PropertyDef(label = "所在行", description = "数据从0开始,如果是筒仓的话,用于记录筒仓的根数")
    private int y;
    @PropertyDef(label = "层最低温")
    private Double tempMin;
    @PropertyDef(label = "层最高温")
    private Double tempMax;
    @PropertyDef(label = "层平均温")
    private Double tempAve = 0.0;
    private int sumNum;// å½“前层总数
    private double sumTemp;// å±‚总温度
    public GrainRow() {
        super();
    }
    public GrainRow(int y) {
        super();
        this.y = y;
    }
}
src/main/java/com/ld/igds/models/Depot.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,89 @@
package com.ld.igds.models;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
 * @Desc: åŸºç¡€ä¿¡æ¯-货位信息
 * @author: Andy
 * @update-time: 2023/5/26
 */
@Data
public class Depot implements Serializable {
    /**
     *
     */
    private static final long serialVersionUID = 1L;
    private String id;
    private String companyId;
    private String deptId;
    private String ggm;
    private String name;
    private String buildingId;
    private String granaryId;
    private String depotType;
    private String depotStatus;
    private String storeType;
    private Double storageMax;
    private Double storageReal;
    private String foodType;
    private String foodVariety;
    private String foodLevel;
    private String foodLocation;
    private String foodYear;
    private Double perWet;
    private Double perImpurity;
    private Double bulkWeight;
    private String storeKeeper;
    private String storeKeeperName;
    private Date storeDate;
    private Date checkDate;
    private String remark;
    private Date updateTime;
    private String bhId;
    // ------------其他属性信息------------//
    private String foodVarietyName;
    private String foodTypeName;
    private String depotTypeName;
    private String depotStatusName;
    private String foodLevelName;
    private Double posX;
    private Double posY;
}
src/main/java/com/ld/igds/models/MQuality.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,59 @@
package com.ld.igds.models;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
 * è´¨é‡ç®¡ç†ï¼Œ2023å¹´5月26日 æ ¹æ®æ–°å›½ç²®è§„优化调整
 *
 * @author chen
 */
@Data
public class MQuality implements Serializable {
    private static final long serialVersionUID = 1L;
    private String id;
    private String companyId;
    private String deptId;
    private String depotId;
    private String foodVariety;
    private String foodLevel;
    private Date storeDate;
    private String type;
    private Date time;
    private String unit;
    private String user;
    private String standard;
    private String zblb;
    private String result;
    private String spaqzbsfhg;
    private Date qfrq;
    private Date bgcjsj;
    private String shrxm;
    private String qydbh;
    private Date checkTime;
    private String checkArea;
    private String checkUser;
    private String jdrxm;
    private String ypbh;
    private Double ypsl;
    private Double dbsl;
    private String ypdj;
    private String normalYear;
    private String remark;
    private Date updateTime;
}