8 changed files with 321 additions and 24 deletions
-
13glue-modbus-collector/src/main/java/com/xujie/devicecollector/dao/DeviceGatherDao.java
-
17glue-modbus-collector/src/main/java/com/xujie/devicecollector/dao/ResourceDao.java
-
30glue-modbus-collector/src/main/java/com/xujie/devicecollector/dao/ResourceScheduledDao.java
-
60glue-modbus-collector/src/main/java/com/xujie/devicecollector/entity/Resource.java
-
90glue-modbus-collector/src/main/java/com/xujie/devicecollector/entity/ResourceScheduled.java
-
26glue-modbus-collector/src/main/java/com/xujie/devicecollector/runner/DeviceRunner.java
-
88glue-modbus-collector/src/main/java/com/xujie/devicecollector/service/impl/DeviceGatherServiceImpl.java
-
21glue-modbus-collector/src/main/java/com/xujie/devicecollector/util/DateUtils.java
@ -0,0 +1,17 @@ |
|||
package com.xujie.devicecollector.dao; |
|||
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.xujie.devicecollector.entity.Resource; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
import org.apache.ibatis.annotations.Select; |
|||
|
|||
@Mapper |
|||
public interface ResourceDao extends BaseMapper<Resource> { |
|||
|
|||
/** |
|||
* 根据site和ip查询resource是否激活 |
|||
*/ |
|||
@Select("select count(1) from resource where site = #{site} and resource_ip_addr = #{ip} and 3in1Flag = 'Y'") |
|||
int countActiveBySiteAndIp(@Param("site") String site, @Param("ip") String ip); |
|||
} |
|||
@ -0,0 +1,30 @@ |
|||
package com.xujie.devicecollector.dao; |
|||
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.xujie.devicecollector.entity.ResourceScheduled; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
import org.apache.ibatis.annotations.Select; |
|||
import org.apache.ibatis.annotations.Update; |
|||
|
|||
@Mapper |
|||
public interface ResourceScheduledDao extends BaseMapper<ResourceScheduled> { |
|||
|
|||
/** |
|||
* 根据site和ip定位resource_scheduled并更新iserror |
|||
*/ |
|||
@Update("update resource_scheduled set iserror = 'Y' where id in (" + |
|||
"select top 1 rs.id from resource_scheduled rs " + |
|||
"inner join resource r on rs.site = r.site and rs.resource_id = r.resource_id " + |
|||
"where r.site = #{site} and r.resource_ip_addr = #{ip} " + |
|||
"order by rs.id desc)") |
|||
int markIsErrorBySiteAndIp(@Param("site") String site, @Param("ip") String ip); |
|||
|
|||
/** |
|||
* 根据设备IP判断是否存在iserror为Y的数据 |
|||
*/ |
|||
@Select("select count(1) from resource_scheduled rs " + |
|||
"inner join resource r on rs.site = r.site and rs.resource_id = r.resource_id " + |
|||
"where r.resource_ip_addr = #{ip} and rs.iserror = 'Y' and r.site = #{site}") |
|||
int countErrorByIp(@Param("site") String site,@Param("ip") String ip); |
|||
} |
|||
@ -0,0 +1,60 @@ |
|||
package com.xujie.devicecollector.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.IdType; |
|||
import com.baomidou.mybatisplus.annotation.TableId; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
|
|||
@TableName("resource") |
|||
public class Resource { |
|||
|
|||
@TableId(type = IdType.AUTO) |
|||
private Integer id; |
|||
|
|||
private String site; |
|||
|
|||
private String resourceId; |
|||
|
|||
private String resourceIpAddr; |
|||
|
|||
private String active; |
|||
|
|||
public Integer getId() { |
|||
return id; |
|||
} |
|||
|
|||
public void setId(Integer id) { |
|||
this.id = id; |
|||
} |
|||
|
|||
public String getSite() { |
|||
return site; |
|||
} |
|||
|
|||
public void setSite(String site) { |
|||
this.site = site; |
|||
} |
|||
|
|||
public String getResourceId() { |
|||
return resourceId; |
|||
} |
|||
|
|||
public void setResourceId(String resourceId) { |
|||
this.resourceId = resourceId; |
|||
} |
|||
|
|||
public String getResourceIpAddr() { |
|||
return resourceIpAddr; |
|||
} |
|||
|
|||
public void setResourceIpAddr(String resourceIpAddr) { |
|||
this.resourceIpAddr = resourceIpAddr; |
|||
} |
|||
|
|||
public String getActive() { |
|||
return active; |
|||
} |
|||
|
|||
public void setActive(String active) { |
|||
this.active = active; |
|||
} |
|||
} |
|||
@ -0,0 +1,90 @@ |
|||
package com.xujie.devicecollector.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.IdType; |
|||
import com.baomidou.mybatisplus.annotation.TableId; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
|
|||
@TableName("resource_scheduled") |
|||
public class ResourceScheduled { |
|||
|
|||
@TableId(type = IdType.AUTO) |
|||
private Integer id; |
|||
|
|||
private String site; |
|||
|
|||
private String resourceId; |
|||
|
|||
private String seqNo; |
|||
|
|||
private String status; |
|||
|
|||
private String issend; |
|||
|
|||
private Integer sfdcid; |
|||
|
|||
private String iserror; |
|||
|
|||
public Integer getId() { |
|||
return id; |
|||
} |
|||
|
|||
public void setId(Integer id) { |
|||
this.id = id; |
|||
} |
|||
|
|||
public String getSite() { |
|||
return site; |
|||
} |
|||
|
|||
public void setSite(String site) { |
|||
this.site = site; |
|||
} |
|||
|
|||
public String getResourceId() { |
|||
return resourceId; |
|||
} |
|||
|
|||
public void setResourceId(String resourceId) { |
|||
this.resourceId = resourceId; |
|||
} |
|||
|
|||
public String getSeqNo() { |
|||
return seqNo; |
|||
} |
|||
|
|||
public void setSeqNo(String seqNo) { |
|||
this.seqNo = seqNo; |
|||
} |
|||
|
|||
public String getStatus() { |
|||
return status; |
|||
} |
|||
|
|||
public void setStatus(String status) { |
|||
this.status = status; |
|||
} |
|||
|
|||
public String getIssend() { |
|||
return issend; |
|||
} |
|||
|
|||
public void setIssend(String issend) { |
|||
this.issend = issend; |
|||
} |
|||
|
|||
public Integer getSfdcid() { |
|||
return sfdcid; |
|||
} |
|||
|
|||
public void setSfdcid(Integer sfdcid) { |
|||
this.sfdcid = sfdcid; |
|||
} |
|||
|
|||
public String getIserror() { |
|||
return iserror; |
|||
} |
|||
|
|||
public void setIserror(String iserror) { |
|||
this.iserror = iserror; |
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue