Explorar o código

福永-温控数据对接处理

szjbdgzl hai 1 ano
pai
achega
77e6877888

+ 5 - 0
exchange/pom.xml

@@ -35,6 +35,11 @@
             <artifactId>orai18n</artifactId>
             <version>19.3.0.0</version>
         </dependency>
+        <dependency>
+            <groupId>com.microsoft.sqlserver</groupId>
+            <artifactId>mssql-jdbc</artifactId>
+            <version>12.8.0.jre8</version>
+        </dependency>
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-test</artifactId>

+ 13 - 0
exchange/src/main/java/com/jyxt/thridparty/exchange/bx/VendorBinxiang.java

@@ -22,6 +22,19 @@ public class VendorBinxiang {
     //实验组ID
     private String shiyanzhuId;
 
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+        VendorBinxiang that = (VendorBinxiang) o;
+        return id != null ? id.equals(that.id) : that.id == null;
+    }
+
+    @Override
+    public int hashCode() {
+        return id != null ? id.hashCode() : 0;
+    }
+
     public String getWendu() {
         return wendu;
     }

+ 40 - 0
exchange/src/main/java/com/jyxt/thridparty/exchange/bx/entity/EquipHumiture.java

@@ -0,0 +1,40 @@
+package com.jyxt.thridparty.exchange.bx.entity;
+
+import java.util.Date;
+
+/**
+ * @author Administrator
+ */
+public class EquipHumiture {
+
+
+    private Date logsTime;
+
+    private String logsChone;
+
+    private String logsChtwo;
+
+    public Date getLogsTime() {
+        return logsTime;
+    }
+
+    public void setLogsTime(Date logsTime) {
+        this.logsTime = logsTime;
+    }
+
+    public String getLogsChone() {
+        return logsChone;
+    }
+
+    public void setLogsChone(String logsChone) {
+        this.logsChone = logsChone;
+    }
+
+    public String getLogsChtwo() {
+        return logsChtwo;
+    }
+
+    public void setLogsChtwo(String logsChtwo) {
+        this.logsChtwo = logsChtwo;
+    }
+}

+ 567 - 0
exchange/src/main/java/com/jyxt/thridparty/exchange/bx/entity/ToLoggerInfo.java

@@ -0,0 +1,567 @@
+package com.jyxt.thridparty.exchange.bx.entity;
+
+import java.util.Date;
+import java.io.Serializable;
+
+/**
+ * (ToLoggerInfo)实体类
+ *
+ * @author makejava
+ * @since 2024-09-10 15:31:41
+ */
+public class ToLoggerInfo implements Serializable {
+    private static final long serialVersionUID = 305659140600002845L;
+    
+    private String loggerSn;
+    
+    private Integer groupId;
+    
+    private String loggerName;
+    
+    private Integer samplingInt;
+    
+    private Integer loggerChnum;
+    
+    private Integer loggerState;
+    
+    private Integer choneType;
+    
+    private String choneHigh;
+    
+    private String choneLow;
+    
+    private Integer choneDot;
+    
+    private String choneUs;
+    
+    private Integer chtwoType;
+    
+    private String chtwoHigh;
+    
+    private String chtwoLow;
+    
+    private Integer chtwoDot;
+    
+    private String chtwoUs;
+    
+    private Integer chthrType;
+    
+    private String chthrHigh;
+    
+    private String chthrLow;
+    
+    private Integer chthrDot;
+    
+    private String chthrUs;
+    
+    private Integer chfouType;
+    
+    private String chfouHigh;
+    
+    private String chfouLow;
+    
+    private Integer chfouDot;
+    
+    private String chfouUs;
+    
+    private Integer limitAlarmType;
+    
+    private Integer limitAlarmWorkDelay;
+    
+    private Integer limitAlarmOffDelay;
+    
+    private Integer disAlarmType;
+    
+    private Integer disAlarmWorkDelay;
+    
+    private Integer disAlarmOffDelay;
+    
+    private Integer powerOffType;
+    
+    private Integer maxAlarmsLimit;
+    
+    private Integer closeSound;
+    
+    private Integer verId;
+    
+    private String ipAddr;
+    
+    private Integer ipPort;
+    
+    private String posLeft;
+    
+    private String posTop;
+    
+    private String posRight;
+    
+    private String posBottom;
+    
+    private Integer alarmExtendTime;
+    
+    private String alarmExtendMsg;
+    
+    private Date logsTime;
+    
+    private String logsChone;
+    
+    private String logsChtwo;
+    
+    private Integer logsChthree;
+    
+    private String logsChfour;
+    
+    private Integer choneColor;
+    
+    private Integer chtwoColor;
+    
+    private Integer chthreeColor;
+    
+    private Integer chfourColor;
+    
+    private Integer posPageno;
+    
+    private Integer lowDcAlarmType;
+
+
+    public String getLoggerSn() {
+        return loggerSn;
+    }
+
+    public void setLoggerSn(String loggerSn) {
+        this.loggerSn = loggerSn;
+    }
+
+    public Integer getGroupId() {
+        return groupId;
+    }
+
+    public void setGroupId(Integer groupId) {
+        this.groupId = groupId;
+    }
+
+    public String getLoggerName() {
+        return loggerName;
+    }
+
+    public void setLoggerName(String loggerName) {
+        this.loggerName = loggerName;
+    }
+
+    public Integer getSamplingInt() {
+        return samplingInt;
+    }
+
+    public void setSamplingInt(Integer samplingInt) {
+        this.samplingInt = samplingInt;
+    }
+
+    public Integer getLoggerChnum() {
+        return loggerChnum;
+    }
+
+    public void setLoggerChnum(Integer loggerChnum) {
+        this.loggerChnum = loggerChnum;
+    }
+
+    public Integer getLoggerState() {
+        return loggerState;
+    }
+
+    public void setLoggerState(Integer loggerState) {
+        this.loggerState = loggerState;
+    }
+
+    public Integer getChoneType() {
+        return choneType;
+    }
+
+    public void setChoneType(Integer choneType) {
+        this.choneType = choneType;
+    }
+
+    public String getChoneHigh() {
+        return choneHigh;
+    }
+
+    public void setChoneHigh(String choneHigh) {
+        this.choneHigh = choneHigh;
+    }
+
+    public String getChoneLow() {
+        return choneLow;
+    }
+
+    public void setChoneLow(String choneLow) {
+        this.choneLow = choneLow;
+    }
+
+    public Integer getChoneDot() {
+        return choneDot;
+    }
+
+    public void setChoneDot(Integer choneDot) {
+        this.choneDot = choneDot;
+    }
+
+    public String getChoneUs() {
+        return choneUs;
+    }
+
+    public void setChoneUs(String choneUs) {
+        this.choneUs = choneUs;
+    }
+
+    public Integer getChtwoType() {
+        return chtwoType;
+    }
+
+    public void setChtwoType(Integer chtwoType) {
+        this.chtwoType = chtwoType;
+    }
+
+    public String getChtwoHigh() {
+        return chtwoHigh;
+    }
+
+    public void setChtwoHigh(String chtwoHigh) {
+        this.chtwoHigh = chtwoHigh;
+    }
+
+    public String getChtwoLow() {
+        return chtwoLow;
+    }
+
+    public void setChtwoLow(String chtwoLow) {
+        this.chtwoLow = chtwoLow;
+    }
+
+    public Integer getChtwoDot() {
+        return chtwoDot;
+    }
+
+    public void setChtwoDot(Integer chtwoDot) {
+        this.chtwoDot = chtwoDot;
+    }
+
+    public String getChtwoUs() {
+        return chtwoUs;
+    }
+
+    public void setChtwoUs(String chtwoUs) {
+        this.chtwoUs = chtwoUs;
+    }
+
+    public Integer getChthrType() {
+        return chthrType;
+    }
+
+    public void setChthrType(Integer chthrType) {
+        this.chthrType = chthrType;
+    }
+
+    public String getChthrHigh() {
+        return chthrHigh;
+    }
+
+    public void setChthrHigh(String chthrHigh) {
+        this.chthrHigh = chthrHigh;
+    }
+
+    public String getChthrLow() {
+        return chthrLow;
+    }
+
+    public void setChthrLow(String chthrLow) {
+        this.chthrLow = chthrLow;
+    }
+
+    public Integer getChthrDot() {
+        return chthrDot;
+    }
+
+    public void setChthrDot(Integer chthrDot) {
+        this.chthrDot = chthrDot;
+    }
+
+    public String getChthrUs() {
+        return chthrUs;
+    }
+
+    public void setChthrUs(String chthrUs) {
+        this.chthrUs = chthrUs;
+    }
+
+    public Integer getChfouType() {
+        return chfouType;
+    }
+
+    public void setChfouType(Integer chfouType) {
+        this.chfouType = chfouType;
+    }
+
+    public String getChfouHigh() {
+        return chfouHigh;
+    }
+
+    public void setChfouHigh(String chfouHigh) {
+        this.chfouHigh = chfouHigh;
+    }
+
+    public String getChfouLow() {
+        return chfouLow;
+    }
+
+    public void setChfouLow(String chfouLow) {
+        this.chfouLow = chfouLow;
+    }
+
+    public Integer getChfouDot() {
+        return chfouDot;
+    }
+
+    public void setChfouDot(Integer chfouDot) {
+        this.chfouDot = chfouDot;
+    }
+
+    public String getChfouUs() {
+        return chfouUs;
+    }
+
+    public void setChfouUs(String chfouUs) {
+        this.chfouUs = chfouUs;
+    }
+
+    public Integer getLimitAlarmType() {
+        return limitAlarmType;
+    }
+
+    public void setLimitAlarmType(Integer limitAlarmType) {
+        this.limitAlarmType = limitAlarmType;
+    }
+
+    public Integer getLimitAlarmWorkDelay() {
+        return limitAlarmWorkDelay;
+    }
+
+    public void setLimitAlarmWorkDelay(Integer limitAlarmWorkDelay) {
+        this.limitAlarmWorkDelay = limitAlarmWorkDelay;
+    }
+
+    public Integer getLimitAlarmOffDelay() {
+        return limitAlarmOffDelay;
+    }
+
+    public void setLimitAlarmOffDelay(Integer limitAlarmOffDelay) {
+        this.limitAlarmOffDelay = limitAlarmOffDelay;
+    }
+
+    public Integer getDisAlarmType() {
+        return disAlarmType;
+    }
+
+    public void setDisAlarmType(Integer disAlarmType) {
+        this.disAlarmType = disAlarmType;
+    }
+
+    public Integer getDisAlarmWorkDelay() {
+        return disAlarmWorkDelay;
+    }
+
+    public void setDisAlarmWorkDelay(Integer disAlarmWorkDelay) {
+        this.disAlarmWorkDelay = disAlarmWorkDelay;
+    }
+
+    public Integer getDisAlarmOffDelay() {
+        return disAlarmOffDelay;
+    }
+
+    public void setDisAlarmOffDelay(Integer disAlarmOffDelay) {
+        this.disAlarmOffDelay = disAlarmOffDelay;
+    }
+
+    public Integer getPowerOffType() {
+        return powerOffType;
+    }
+
+    public void setPowerOffType(Integer powerOffType) {
+        this.powerOffType = powerOffType;
+    }
+
+    public Integer getMaxAlarmsLimit() {
+        return maxAlarmsLimit;
+    }
+
+    public void setMaxAlarmsLimit(Integer maxAlarmsLimit) {
+        this.maxAlarmsLimit = maxAlarmsLimit;
+    }
+
+    public Integer getCloseSound() {
+        return closeSound;
+    }
+
+    public void setCloseSound(Integer closeSound) {
+        this.closeSound = closeSound;
+    }
+
+    public Integer getVerId() {
+        return verId;
+    }
+
+    public void setVerId(Integer verId) {
+        this.verId = verId;
+    }
+
+    public String getIpAddr() {
+        return ipAddr;
+    }
+
+    public void setIpAddr(String ipAddr) {
+        this.ipAddr = ipAddr;
+    }
+
+    public Integer getIpPort() {
+        return ipPort;
+    }
+
+    public void setIpPort(Integer ipPort) {
+        this.ipPort = ipPort;
+    }
+
+    public String getPosLeft() {
+        return posLeft;
+    }
+
+    public void setPosLeft(String posLeft) {
+        this.posLeft = posLeft;
+    }
+
+    public String getPosTop() {
+        return posTop;
+    }
+
+    public void setPosTop(String posTop) {
+        this.posTop = posTop;
+    }
+
+    public String getPosRight() {
+        return posRight;
+    }
+
+    public void setPosRight(String posRight) {
+        this.posRight = posRight;
+    }
+
+    public String getPosBottom() {
+        return posBottom;
+    }
+
+    public void setPosBottom(String posBottom) {
+        this.posBottom = posBottom;
+    }
+
+    public Integer getAlarmExtendTime() {
+        return alarmExtendTime;
+    }
+
+    public void setAlarmExtendTime(Integer alarmExtendTime) {
+        this.alarmExtendTime = alarmExtendTime;
+    }
+
+    public String getAlarmExtendMsg() {
+        return alarmExtendMsg;
+    }
+
+    public void setAlarmExtendMsg(String alarmExtendMsg) {
+        this.alarmExtendMsg = alarmExtendMsg;
+    }
+
+    public Date getLogsTime() {
+        return logsTime;
+    }
+
+    public void setLogsTime(Date logsTime) {
+        this.logsTime = logsTime;
+    }
+
+    public String getLogsChone() {
+        return logsChone;
+    }
+
+    public void setLogsChone(String logsChone) {
+        this.logsChone = logsChone;
+    }
+
+    public String getLogsChtwo() {
+        return logsChtwo;
+    }
+
+    public void setLogsChtwo(String logsChtwo) {
+        this.logsChtwo = logsChtwo;
+    }
+
+    public Integer getLogsChthree() {
+        return logsChthree;
+    }
+
+    public void setLogsChthree(Integer logsChthree) {
+        this.logsChthree = logsChthree;
+    }
+
+    public String getLogsChfour() {
+        return logsChfour;
+    }
+
+    public void setLogsChfour(String logsChfour) {
+        this.logsChfour = logsChfour;
+    }
+
+    public Integer getChoneColor() {
+        return choneColor;
+    }
+
+    public void setChoneColor(Integer choneColor) {
+        this.choneColor = choneColor;
+    }
+
+    public Integer getChtwoColor() {
+        return chtwoColor;
+    }
+
+    public void setChtwoColor(Integer chtwoColor) {
+        this.chtwoColor = chtwoColor;
+    }
+
+    public Integer getChthreeColor() {
+        return chthreeColor;
+    }
+
+    public void setChthreeColor(Integer chthreeColor) {
+        this.chthreeColor = chthreeColor;
+    }
+
+    public Integer getChfourColor() {
+        return chfourColor;
+    }
+
+    public void setChfourColor(Integer chfourColor) {
+        this.chfourColor = chfourColor;
+    }
+
+    public Integer getPosPageno() {
+        return posPageno;
+    }
+
+    public void setPosPageno(Integer posPageno) {
+        this.posPageno = posPageno;
+    }
+
+    public Integer getLowDcAlarmType() {
+        return lowDcAlarmType;
+    }
+
+    public void setLowDcAlarmType(Integer lowDcAlarmType) {
+        this.lowDcAlarmType = lowDcAlarmType;
+    }
+
+}
+

+ 68 - 24
exchange/src/main/java/com/jyxt/thridparty/exchange/bx/repository/VendorBinxiangRepository.java

@@ -1,50 +1,94 @@
 package com.jyxt.thridparty.exchange.bx.repository;
 
-import com.jyxt.thridparty.exchange.ExchangeApplication;
 import com.jyxt.thridparty.exchange.bx.VendorBinxiang;
+import com.jyxt.thridparty.exchange.bx.entity.EquipHumiture;
+import com.jyxt.thridparty.exchange.bx.entity.ToLoggerInfo;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.jdbc.core.RowMapper;
 import org.springframework.stereotype.Repository;
 
-import java.sql.ResultSet;
-import java.sql.SQLException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.LinkedHashSet;
 import java.util.List;
+import java.util.Set;
+
 @Repository
 public class VendorBinxiangRepository {
     private static final Logger log = LoggerFactory.getLogger(VendorBinxiangRepository.class);
     @Autowired
     private JdbcTemplate jdbcTemplate;
 
-    @Value("${fetch.sql}")
-    private String sql;
+    @Value("${fetch.condition}")
+    private String condition;
 
     public List<VendorBinxiang> query() {
-        log.info(sql);
-        return jdbcTemplate.query(
-                sql,new RowMapper<VendorBinxiang>(){
-
-                    @Override
-                    public VendorBinxiang mapRow(ResultSet rs, int rowNum) throws SQLException {
+        String sql = "select *from to_logger_info";
+        RowMapper<ToLoggerInfo> infoRowMapper = new BeanPropertyRowMapper<>(ToLoggerInfo.class);
+        RowMapper<EquipHumiture> humitureRowMapper = new BeanPropertyRowMapper<>(EquipHumiture.class);
+        List<ToLoggerInfo> equipList = jdbcTemplate.query(sql, infoRowMapper);
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmm");
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        Set<VendorBinxiang> bxSet = new LinkedHashSet<>();
+        for (ToLoggerInfo equip : equipList) {
+            String equipSn = equip.getLoggerSn();
+            String equipName = equip.getLoggerName();
+//            String subSql = "select *from logs_"+equipSn+" WHERE DATE_FORMAT(LOGS_TIME,'%Y-%m-%d')=CURRENT_DATE";
+            String subSql = "SELECT *FROM LOGS_"+equipSn+" WHERE DATE_FORMAT(LOGS_TIME,'%Y-%m-%d')='2024-09-05'";
+            log.warn(subSql);
+            List<EquipHumiture> list;
+            try {
+                list = jdbcTemplate.query(subSql, humitureRowMapper);
+            } catch (Exception e) {
+                continue;
+            }
+            for (EquipHumiture hum : list) {
+                String strDate = "";
+                try {
+                    strDate = sdf.format(hum.getLogsTime());
+                } catch (Exception e) {
+                    log.warn("时间格式化异常{},设备编号:{}",hum.getLogsTime(),equipSn);
+                    e.printStackTrace();
+                }
+                if (equip.getLoggerChnum()==1){
+                    VendorBinxiang bx = new VendorBinxiang();
+                    bx.setId(equipSn+"-"+strDate);
+                    bx.setWendu(hum.getLogsChone());
+                    bx.setBinXiangId(equipSn);
+                    bx.setBinxiangName(equipName);
+                    bx.setCaiJiId(equipSn);
+                    bx.setCaiJiName(equipSn);
+                    bx.setCaiJiTime(formatter.format(hum.getLogsTime()));
+                    bx.setWenduUp(equip.getChoneHigh());
+                    bx.setWenduDown(equip.getChoneLow());
+                    bx.setShiyanzhuName(equip.getGroupId().toString());
+                    bx.setShiyanzhuId(equip.getGroupId().toString());
+                    bxSet.add(bx);
+                }else {
+                    for (int i = 1; i<=2; i++){
                         VendorBinxiang bx = new VendorBinxiang();
-                        bx.setId(rs.getString("id"));
-                        bx.setWendu(rs.getString("温度"));
-                        bx.setBinXiangId(rs.getString("冰箱ID"));
-                        bx.setBinxiangName(rs.getString("冰箱名称"));
-                        bx.setCaiJiId(rs.getString("采集器ID"));
-                        bx.setCaiJiName(rs.getString("采集器名称"));
-                        bx.setCaiJiTime(rs.getString("采集时间"));
-                        bx.setWenduUp(rs.getString("温度上限"));
-                        bx.setWenduDown(rs.getString("温度下限"));
-                        bx.setShiyanzhuName(rs.getString("实验组"));
-                        bx.setShiyanzhuId(rs.getString("实验组ID"));
-                        return bx;
+                        bx.setId(equipSn+"-"+i+"-"+strDate);
+                        bx.setWendu(i==1?hum.getLogsChone():hum.getLogsChtwo());
+                        bx.setBinXiangId(equipSn);
+                        bx.setCaiJiId(equipSn+"-"+i);
+                        bx.setCaiJiName(equipSn+"-"+i);
+                        bx.setBinxiangName(equipName);
+                        bx.setCaiJiTime(formatter.format(hum.getLogsTime()));
+                        bx.setWenduUp(i==1?equip.getChoneHigh():equip.getChtwoHigh());
+                        bx.setWenduDown(i==1?equip.getChoneLow():equip.getChtwoLow());
+                        bx.setShiyanzhuName(equip.getGroupId().toString());
+                        bx.setShiyanzhuId(equip.getGroupId().toString());
+                        bxSet.add(bx);
                     }
                 }
-        );
+            }
+        }
+        return new ArrayList<>(bxSet);
     }
 
 }

+ 2 - 1
exchange/src/main/resources/application.properties

@@ -6,4 +6,5 @@ spring.second-datasource.jdbc-url = jdbc:mysql://dev1.local:3306/klims-ibps3?cha
 spring.second-datasource.username = root
 spring.second-datasource.password = test001
 spring.second-datasource.driver-class-name = com.mysql.cj.jdbc.Driver
-fetch.sql=select * from v_get_ref_temperature  where date(\u91c7\u96c6\u65f6\u95f4)=curdate()
+fetch.sql=select * from v_get_ref_temperature  where date(\u91c7\u96c6\u65f6\u95f4)=curdate()
+fetch.condition=DATEDIFF(day, LOGS_TIME, GETDATE()) = 0