diff --git a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java index 80625c7..d8f5e6b 100644 --- a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java +++ b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java @@ -43,9 +43,7 @@ this.intoTime = intoTime; } - @Column(name = "OUT_TIME") - public Date getOutTime() { return outTime; } diff --git a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java index 80625c7..d8f5e6b 100644 --- a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java +++ b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java @@ -43,9 +43,7 @@ this.intoTime = intoTime; } - @Column(name = "OUT_TIME") - public Date getOutTime() { return outTime; } diff --git a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java index a99981e..b1d63a4 100644 --- a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java +++ b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java @@ -1,11 +1,28 @@ package com.casic.PgInterface.devData.manager; +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.core.util.DateUtils; +import com.casic.PgInterface.core.util.StringUtils; +import com.casic.PgInterface.devData.domain.PgCo; +import com.casic.PgInterface.devData.domain.PgLocation; +import com.casic.PgInterface.devData.dto.PgCoDto; +import com.casic.PgInterface.devData.dto.PgLocationDto; +import com.casic.PgInterface.devTable.domain.PgDevice; +import org.hibernate.Criteria; +import org.hibernate.criterion.Order; +import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; + /** * Created by yxw on 2017/11/2. */ @Service -public class PgLocationManager { +public class PgLocationManager extends HibernateEntityDao { + + //获取设备时间段内所有的监测数据 } diff --git a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java index 80625c7..d8f5e6b 100644 --- a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java +++ b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java @@ -43,9 +43,7 @@ this.intoTime = intoTime; } - @Column(name = "OUT_TIME") - public Date getOutTime() { return outTime; } diff --git a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java index a99981e..b1d63a4 100644 --- a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java +++ b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java @@ -1,11 +1,28 @@ package com.casic.PgInterface.devData.manager; +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.core.util.DateUtils; +import com.casic.PgInterface.core.util.StringUtils; +import com.casic.PgInterface.devData.domain.PgCo; +import com.casic.PgInterface.devData.domain.PgLocation; +import com.casic.PgInterface.devData.dto.PgCoDto; +import com.casic.PgInterface.devData.dto.PgLocationDto; +import com.casic.PgInterface.devTable.domain.PgDevice; +import org.hibernate.Criteria; +import org.hibernate.criterion.Order; +import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; + /** * Created by yxw on 2017/11/2. */ @Service -public class PgLocationManager { +public class PgLocationManager extends HibernateEntityDao { + + //获取设备时间段内所有的监测数据 } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java index cfa0281..7fb5953 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -1,12 +1,12 @@ package com.casic.PgInterface.devTable.domain; import com.casic.PgInterface.devData.domain.*; +import com.casic.PgInterface.patroler.domain.PgAlarmRule; import org.hibernate.annotations.NotFound; import org.hibernate.annotations.NotFoundAction; import javax.persistence.*; import java.io.Serializable; -import java.util.Date; import java.util.List; /** @@ -19,21 +19,27 @@ private static final long serialVersionUID = 1L; private long id; + private PipeGallery pipeGalleryId;//所在管廊信息 + private String road;//路名 + private String position;//设备位置 + private String devType;//设备类型 private String devCode;//设备编号 - private String devName;//设备名称 - private String brand;//品牌 - private String ownerUnit;//权属单位 - private Date installDate;//安装时间 + private String assetName;//资产名称 + private String assetCode;//资产编码 + private String assetBarCode;//资产条码 + private String ip;//IP地址 + private String modBus;//modBus地址 + private String mome;//备注 private int isOpen;//设备是否开启 private int active;//状态位 - private PgDeviceType devTypeId;//设备类型 + private List pgAlarms; - private PgPartition pgPartitionId;//所在管廊信息 private List pgTempHums;//温湿度 private List pgCos;//一氧化碳 private List pgO2s;//氧气 private List pgCh4s;//甲烷 private List pgShs;//硫化氢 + private List pgAlarmRules;//报警规则 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") @@ -45,6 +51,33 @@ this.id = id; } + @Column(name = "ROAD") + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + @Column(name = "POSITION") + public String getPosition() { + return position; + } + + public void setPosition(String position) { + this.position = position; + } + + @Column(name = "DEV_TYPE") + public String getDevType() { + return devType; + } + + public void setDevType(String devType) { + this.devType = devType; + } + @Column(name = "DEV_CODE") public String getDevCode() { return devCode; @@ -54,40 +87,58 @@ this.devCode = devCode; } - @Column(name = "DEV_NAME") - public String getDevName() { - return devName; + @Column(name = "ASSET_NAME") + public String getAssetName() { + return assetName; } - public void setDevName(String devName) { - this.devName = devName; + public void setAssetName(String assetName) { + this.assetName = assetName; } - @Column(name = "BRAND") - public String getBrand() { - return brand; + @Column(name = "ASSET_CODE") + public String getAssetCode() { + return assetCode; } - public void setBrand(String brand) { - this.brand = brand; + public void setAssetCode(String assetCode) { + this.assetCode = assetCode; } - @Column(name = "OWNERUNIT") - public String getOwnerUnit() { - return ownerUnit; + @Column(name = "ASSET_BAR_CODE") + public String getAssetBarCode() { + return assetBarCode; } - public void setOwnerUnit(String ownerUnit) { - this.ownerUnit = ownerUnit; + public void setAssetBarCode(String assetBarCode) { + this.assetBarCode = assetBarCode; } - @Column(name = "INSTALDATE") - public Date getInstallDate() { - return installDate; + @Column(name = "IP") + public String getIp() { + return ip; } - public void setInstallDate(Date installDate) { - this.installDate = installDate; + public void setIp(String ip) { + this.ip = ip; + } + + @Column(name = "MODBUS") + public String getModBus() { + return modBus; + } + + public void setModBus(String modBus) { + this.modBus = modBus; + } + + @Column(name = "MOME") + public String getMome() { + return mome; + } + + public void setMome(String mome) { + this.mome = mome; } @Column(name = "ISOPEN") @@ -119,24 +170,13 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; - } - - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "DEVICE_TYPE_ID") - public PgDeviceType getDevTypeId() { - return devTypeId; - } - - public void setDevTypeId(PgDeviceType devTypeId) { - this.devTypeId = devTypeId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgDeviceId") @@ -184,4 +224,13 @@ this.pgShs = pgShs; } + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgDeviceId") + public List getPgAlarmRules() { + return pgAlarmRules; + } + + public void setPgAlarmRules(List pgAlarmRules) { + this.pgAlarmRules = pgAlarmRules; + } + } diff --git a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java index 80625c7..d8f5e6b 100644 --- a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java +++ b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java @@ -43,9 +43,7 @@ this.intoTime = intoTime; } - @Column(name = "OUT_TIME") - public Date getOutTime() { return outTime; } diff --git a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java index a99981e..b1d63a4 100644 --- a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java +++ b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java @@ -1,11 +1,28 @@ package com.casic.PgInterface.devData.manager; +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.core.util.DateUtils; +import com.casic.PgInterface.core.util.StringUtils; +import com.casic.PgInterface.devData.domain.PgCo; +import com.casic.PgInterface.devData.domain.PgLocation; +import com.casic.PgInterface.devData.dto.PgCoDto; +import com.casic.PgInterface.devData.dto.PgLocationDto; +import com.casic.PgInterface.devTable.domain.PgDevice; +import org.hibernate.Criteria; +import org.hibernate.criterion.Order; +import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; + /** * Created by yxw on 2017/11/2. */ @Service -public class PgLocationManager { +public class PgLocationManager extends HibernateEntityDao { + + //获取设备时间段内所有的监测数据 } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java index cfa0281..7fb5953 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -1,12 +1,12 @@ package com.casic.PgInterface.devTable.domain; import com.casic.PgInterface.devData.domain.*; +import com.casic.PgInterface.patroler.domain.PgAlarmRule; import org.hibernate.annotations.NotFound; import org.hibernate.annotations.NotFoundAction; import javax.persistence.*; import java.io.Serializable; -import java.util.Date; import java.util.List; /** @@ -19,21 +19,27 @@ private static final long serialVersionUID = 1L; private long id; + private PipeGallery pipeGalleryId;//所在管廊信息 + private String road;//路名 + private String position;//设备位置 + private String devType;//设备类型 private String devCode;//设备编号 - private String devName;//设备名称 - private String brand;//品牌 - private String ownerUnit;//权属单位 - private Date installDate;//安装时间 + private String assetName;//资产名称 + private String assetCode;//资产编码 + private String assetBarCode;//资产条码 + private String ip;//IP地址 + private String modBus;//modBus地址 + private String mome;//备注 private int isOpen;//设备是否开启 private int active;//状态位 - private PgDeviceType devTypeId;//设备类型 + private List pgAlarms; - private PgPartition pgPartitionId;//所在管廊信息 private List pgTempHums;//温湿度 private List pgCos;//一氧化碳 private List pgO2s;//氧气 private List pgCh4s;//甲烷 private List pgShs;//硫化氢 + private List pgAlarmRules;//报警规则 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") @@ -45,6 +51,33 @@ this.id = id; } + @Column(name = "ROAD") + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + @Column(name = "POSITION") + public String getPosition() { + return position; + } + + public void setPosition(String position) { + this.position = position; + } + + @Column(name = "DEV_TYPE") + public String getDevType() { + return devType; + } + + public void setDevType(String devType) { + this.devType = devType; + } + @Column(name = "DEV_CODE") public String getDevCode() { return devCode; @@ -54,40 +87,58 @@ this.devCode = devCode; } - @Column(name = "DEV_NAME") - public String getDevName() { - return devName; + @Column(name = "ASSET_NAME") + public String getAssetName() { + return assetName; } - public void setDevName(String devName) { - this.devName = devName; + public void setAssetName(String assetName) { + this.assetName = assetName; } - @Column(name = "BRAND") - public String getBrand() { - return brand; + @Column(name = "ASSET_CODE") + public String getAssetCode() { + return assetCode; } - public void setBrand(String brand) { - this.brand = brand; + public void setAssetCode(String assetCode) { + this.assetCode = assetCode; } - @Column(name = "OWNERUNIT") - public String getOwnerUnit() { - return ownerUnit; + @Column(name = "ASSET_BAR_CODE") + public String getAssetBarCode() { + return assetBarCode; } - public void setOwnerUnit(String ownerUnit) { - this.ownerUnit = ownerUnit; + public void setAssetBarCode(String assetBarCode) { + this.assetBarCode = assetBarCode; } - @Column(name = "INSTALDATE") - public Date getInstallDate() { - return installDate; + @Column(name = "IP") + public String getIp() { + return ip; } - public void setInstallDate(Date installDate) { - this.installDate = installDate; + public void setIp(String ip) { + this.ip = ip; + } + + @Column(name = "MODBUS") + public String getModBus() { + return modBus; + } + + public void setModBus(String modBus) { + this.modBus = modBus; + } + + @Column(name = "MOME") + public String getMome() { + return mome; + } + + public void setMome(String mome) { + this.mome = mome; } @Column(name = "ISOPEN") @@ -119,24 +170,13 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; - } - - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "DEVICE_TYPE_ID") - public PgDeviceType getDevTypeId() { - return devTypeId; - } - - public void setDevTypeId(PgDeviceType devTypeId) { - this.devTypeId = devTypeId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgDeviceId") @@ -184,4 +224,13 @@ this.pgShs = pgShs; } + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgDeviceId") + public List getPgAlarmRules() { + return pgAlarmRules; + } + + public void setPgAlarmRules(List pgAlarmRules) { + this.pgAlarmRules = pgAlarmRules; + } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java index b997b29..4fb3d6f 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java @@ -1,8 +1,5 @@ package com.casic.PgInterface.devTable.domain; -import org.hibernate.annotations.NotFound; -import org.hibernate.annotations.NotFoundAction; - import javax.persistence.*; import java.io.Serializable; import java.util.List; @@ -19,11 +16,9 @@ private long id; private String parName;//分区名称 - private PipeGallery pipeGalleryId;//管廊仓 + private String road;//所属道路 private int active;//状态位 - private List pgTextureList; - private List pgPipeLineList; - private List pgDeviceList; + private List pipeGalleryList;//管廊仓 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PARTITION_ID") @@ -44,6 +39,15 @@ this.parName = parName; } + @Column(name = "ROAD") + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + @Column(name = "ACTIVE") public int getActive() { return active; @@ -53,41 +57,14 @@ this.active = active; } - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PIPEGALLERYID") - public PipeGallery getPipeGalleryId() { - return pipeGalleryId; - } - - public void setPipeGalleryId(PipeGallery pipeGalleryId) { - this.pipeGalleryId = pipeGalleryId; - } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgTextureList() { - return pgTextureList; + public List getPipeGalleryList() { + return pipeGalleryList; } - public void setPgTextureList(List pgTextureList) { - this.pgTextureList = pgTextureList; + public void setPipeGalleryList(List pipeGalleryList) { + this.pipeGalleryList = pipeGalleryList; } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgPipeLineList() { - return pgPipeLineList; - } - public void setPgPipeLineList(List pgPipeLineList) { - this.pgPipeLineList = pgPipeLineList; - } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgDeviceList() { - return pgDeviceList; - } - - public void setPgDeviceList(List pgDeviceList) { - this.pgDeviceList = pgDeviceList; - } } diff --git a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java index 80625c7..d8f5e6b 100644 --- a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java +++ b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java @@ -43,9 +43,7 @@ this.intoTime = intoTime; } - @Column(name = "OUT_TIME") - public Date getOutTime() { return outTime; } diff --git a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java index a99981e..b1d63a4 100644 --- a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java +++ b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java @@ -1,11 +1,28 @@ package com.casic.PgInterface.devData.manager; +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.core.util.DateUtils; +import com.casic.PgInterface.core.util.StringUtils; +import com.casic.PgInterface.devData.domain.PgCo; +import com.casic.PgInterface.devData.domain.PgLocation; +import com.casic.PgInterface.devData.dto.PgCoDto; +import com.casic.PgInterface.devData.dto.PgLocationDto; +import com.casic.PgInterface.devTable.domain.PgDevice; +import org.hibernate.Criteria; +import org.hibernate.criterion.Order; +import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; + /** * Created by yxw on 2017/11/2. */ @Service -public class PgLocationManager { +public class PgLocationManager extends HibernateEntityDao { + + //获取设备时间段内所有的监测数据 } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java index cfa0281..7fb5953 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -1,12 +1,12 @@ package com.casic.PgInterface.devTable.domain; import com.casic.PgInterface.devData.domain.*; +import com.casic.PgInterface.patroler.domain.PgAlarmRule; import org.hibernate.annotations.NotFound; import org.hibernate.annotations.NotFoundAction; import javax.persistence.*; import java.io.Serializable; -import java.util.Date; import java.util.List; /** @@ -19,21 +19,27 @@ private static final long serialVersionUID = 1L; private long id; + private PipeGallery pipeGalleryId;//所在管廊信息 + private String road;//路名 + private String position;//设备位置 + private String devType;//设备类型 private String devCode;//设备编号 - private String devName;//设备名称 - private String brand;//品牌 - private String ownerUnit;//权属单位 - private Date installDate;//安装时间 + private String assetName;//资产名称 + private String assetCode;//资产编码 + private String assetBarCode;//资产条码 + private String ip;//IP地址 + private String modBus;//modBus地址 + private String mome;//备注 private int isOpen;//设备是否开启 private int active;//状态位 - private PgDeviceType devTypeId;//设备类型 + private List pgAlarms; - private PgPartition pgPartitionId;//所在管廊信息 private List pgTempHums;//温湿度 private List pgCos;//一氧化碳 private List pgO2s;//氧气 private List pgCh4s;//甲烷 private List pgShs;//硫化氢 + private List pgAlarmRules;//报警规则 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") @@ -45,6 +51,33 @@ this.id = id; } + @Column(name = "ROAD") + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + @Column(name = "POSITION") + public String getPosition() { + return position; + } + + public void setPosition(String position) { + this.position = position; + } + + @Column(name = "DEV_TYPE") + public String getDevType() { + return devType; + } + + public void setDevType(String devType) { + this.devType = devType; + } + @Column(name = "DEV_CODE") public String getDevCode() { return devCode; @@ -54,40 +87,58 @@ this.devCode = devCode; } - @Column(name = "DEV_NAME") - public String getDevName() { - return devName; + @Column(name = "ASSET_NAME") + public String getAssetName() { + return assetName; } - public void setDevName(String devName) { - this.devName = devName; + public void setAssetName(String assetName) { + this.assetName = assetName; } - @Column(name = "BRAND") - public String getBrand() { - return brand; + @Column(name = "ASSET_CODE") + public String getAssetCode() { + return assetCode; } - public void setBrand(String brand) { - this.brand = brand; + public void setAssetCode(String assetCode) { + this.assetCode = assetCode; } - @Column(name = "OWNERUNIT") - public String getOwnerUnit() { - return ownerUnit; + @Column(name = "ASSET_BAR_CODE") + public String getAssetBarCode() { + return assetBarCode; } - public void setOwnerUnit(String ownerUnit) { - this.ownerUnit = ownerUnit; + public void setAssetBarCode(String assetBarCode) { + this.assetBarCode = assetBarCode; } - @Column(name = "INSTALDATE") - public Date getInstallDate() { - return installDate; + @Column(name = "IP") + public String getIp() { + return ip; } - public void setInstallDate(Date installDate) { - this.installDate = installDate; + public void setIp(String ip) { + this.ip = ip; + } + + @Column(name = "MODBUS") + public String getModBus() { + return modBus; + } + + public void setModBus(String modBus) { + this.modBus = modBus; + } + + @Column(name = "MOME") + public String getMome() { + return mome; + } + + public void setMome(String mome) { + this.mome = mome; } @Column(name = "ISOPEN") @@ -119,24 +170,13 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; - } - - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "DEVICE_TYPE_ID") - public PgDeviceType getDevTypeId() { - return devTypeId; - } - - public void setDevTypeId(PgDeviceType devTypeId) { - this.devTypeId = devTypeId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgDeviceId") @@ -184,4 +224,13 @@ this.pgShs = pgShs; } + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgDeviceId") + public List getPgAlarmRules() { + return pgAlarmRules; + } + + public void setPgAlarmRules(List pgAlarmRules) { + this.pgAlarmRules = pgAlarmRules; + } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java index b997b29..4fb3d6f 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java @@ -1,8 +1,5 @@ package com.casic.PgInterface.devTable.domain; -import org.hibernate.annotations.NotFound; -import org.hibernate.annotations.NotFoundAction; - import javax.persistence.*; import java.io.Serializable; import java.util.List; @@ -19,11 +16,9 @@ private long id; private String parName;//分区名称 - private PipeGallery pipeGalleryId;//管廊仓 + private String road;//所属道路 private int active;//状态位 - private List pgTextureList; - private List pgPipeLineList; - private List pgDeviceList; + private List pipeGalleryList;//管廊仓 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PARTITION_ID") @@ -44,6 +39,15 @@ this.parName = parName; } + @Column(name = "ROAD") + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + @Column(name = "ACTIVE") public int getActive() { return active; @@ -53,41 +57,14 @@ this.active = active; } - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PIPEGALLERYID") - public PipeGallery getPipeGalleryId() { - return pipeGalleryId; - } - - public void setPipeGalleryId(PipeGallery pipeGalleryId) { - this.pipeGalleryId = pipeGalleryId; - } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgTextureList() { - return pgTextureList; + public List getPipeGalleryList() { + return pipeGalleryList; } - public void setPgTextureList(List pgTextureList) { - this.pgTextureList = pgTextureList; + public void setPipeGalleryList(List pipeGalleryList) { + this.pipeGalleryList = pipeGalleryList; } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgPipeLineList() { - return pgPipeLineList; - } - public void setPgPipeLineList(List pgPipeLineList) { - this.pgPipeLineList = pgPipeLineList; - } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgDeviceList() { - return pgDeviceList; - } - - public void setPgDeviceList(List pgDeviceList) { - this.pgDeviceList = pgDeviceList; - } } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java index d936d18..e5ff9b3 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java @@ -22,7 +22,7 @@ private Date enterDate;//入廊时间 private String layerNum;//所在层数 private String diameter;//管径 - private PgPartition pgPartitionId;//所在管廊信息 + private PipeGallery pipeGalleryId;//所在管廊信息 private int active;//状态位 @Id @@ -100,12 +100,12 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } } diff --git a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java index 80625c7..d8f5e6b 100644 --- a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java +++ b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java @@ -43,9 +43,7 @@ this.intoTime = intoTime; } - @Column(name = "OUT_TIME") - public Date getOutTime() { return outTime; } diff --git a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java index a99981e..b1d63a4 100644 --- a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java +++ b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java @@ -1,11 +1,28 @@ package com.casic.PgInterface.devData.manager; +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.core.util.DateUtils; +import com.casic.PgInterface.core.util.StringUtils; +import com.casic.PgInterface.devData.domain.PgCo; +import com.casic.PgInterface.devData.domain.PgLocation; +import com.casic.PgInterface.devData.dto.PgCoDto; +import com.casic.PgInterface.devData.dto.PgLocationDto; +import com.casic.PgInterface.devTable.domain.PgDevice; +import org.hibernate.Criteria; +import org.hibernate.criterion.Order; +import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; + /** * Created by yxw on 2017/11/2. */ @Service -public class PgLocationManager { +public class PgLocationManager extends HibernateEntityDao { + + //获取设备时间段内所有的监测数据 } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java index cfa0281..7fb5953 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -1,12 +1,12 @@ package com.casic.PgInterface.devTable.domain; import com.casic.PgInterface.devData.domain.*; +import com.casic.PgInterface.patroler.domain.PgAlarmRule; import org.hibernate.annotations.NotFound; import org.hibernate.annotations.NotFoundAction; import javax.persistence.*; import java.io.Serializable; -import java.util.Date; import java.util.List; /** @@ -19,21 +19,27 @@ private static final long serialVersionUID = 1L; private long id; + private PipeGallery pipeGalleryId;//所在管廊信息 + private String road;//路名 + private String position;//设备位置 + private String devType;//设备类型 private String devCode;//设备编号 - private String devName;//设备名称 - private String brand;//品牌 - private String ownerUnit;//权属单位 - private Date installDate;//安装时间 + private String assetName;//资产名称 + private String assetCode;//资产编码 + private String assetBarCode;//资产条码 + private String ip;//IP地址 + private String modBus;//modBus地址 + private String mome;//备注 private int isOpen;//设备是否开启 private int active;//状态位 - private PgDeviceType devTypeId;//设备类型 + private List pgAlarms; - private PgPartition pgPartitionId;//所在管廊信息 private List pgTempHums;//温湿度 private List pgCos;//一氧化碳 private List pgO2s;//氧气 private List pgCh4s;//甲烷 private List pgShs;//硫化氢 + private List pgAlarmRules;//报警规则 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") @@ -45,6 +51,33 @@ this.id = id; } + @Column(name = "ROAD") + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + @Column(name = "POSITION") + public String getPosition() { + return position; + } + + public void setPosition(String position) { + this.position = position; + } + + @Column(name = "DEV_TYPE") + public String getDevType() { + return devType; + } + + public void setDevType(String devType) { + this.devType = devType; + } + @Column(name = "DEV_CODE") public String getDevCode() { return devCode; @@ -54,40 +87,58 @@ this.devCode = devCode; } - @Column(name = "DEV_NAME") - public String getDevName() { - return devName; + @Column(name = "ASSET_NAME") + public String getAssetName() { + return assetName; } - public void setDevName(String devName) { - this.devName = devName; + public void setAssetName(String assetName) { + this.assetName = assetName; } - @Column(name = "BRAND") - public String getBrand() { - return brand; + @Column(name = "ASSET_CODE") + public String getAssetCode() { + return assetCode; } - public void setBrand(String brand) { - this.brand = brand; + public void setAssetCode(String assetCode) { + this.assetCode = assetCode; } - @Column(name = "OWNERUNIT") - public String getOwnerUnit() { - return ownerUnit; + @Column(name = "ASSET_BAR_CODE") + public String getAssetBarCode() { + return assetBarCode; } - public void setOwnerUnit(String ownerUnit) { - this.ownerUnit = ownerUnit; + public void setAssetBarCode(String assetBarCode) { + this.assetBarCode = assetBarCode; } - @Column(name = "INSTALDATE") - public Date getInstallDate() { - return installDate; + @Column(name = "IP") + public String getIp() { + return ip; } - public void setInstallDate(Date installDate) { - this.installDate = installDate; + public void setIp(String ip) { + this.ip = ip; + } + + @Column(name = "MODBUS") + public String getModBus() { + return modBus; + } + + public void setModBus(String modBus) { + this.modBus = modBus; + } + + @Column(name = "MOME") + public String getMome() { + return mome; + } + + public void setMome(String mome) { + this.mome = mome; } @Column(name = "ISOPEN") @@ -119,24 +170,13 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; - } - - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "DEVICE_TYPE_ID") - public PgDeviceType getDevTypeId() { - return devTypeId; - } - - public void setDevTypeId(PgDeviceType devTypeId) { - this.devTypeId = devTypeId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgDeviceId") @@ -184,4 +224,13 @@ this.pgShs = pgShs; } + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgDeviceId") + public List getPgAlarmRules() { + return pgAlarmRules; + } + + public void setPgAlarmRules(List pgAlarmRules) { + this.pgAlarmRules = pgAlarmRules; + } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java index b997b29..4fb3d6f 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java @@ -1,8 +1,5 @@ package com.casic.PgInterface.devTable.domain; -import org.hibernate.annotations.NotFound; -import org.hibernate.annotations.NotFoundAction; - import javax.persistence.*; import java.io.Serializable; import java.util.List; @@ -19,11 +16,9 @@ private long id; private String parName;//分区名称 - private PipeGallery pipeGalleryId;//管廊仓 + private String road;//所属道路 private int active;//状态位 - private List pgTextureList; - private List pgPipeLineList; - private List pgDeviceList; + private List pipeGalleryList;//管廊仓 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PARTITION_ID") @@ -44,6 +39,15 @@ this.parName = parName; } + @Column(name = "ROAD") + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + @Column(name = "ACTIVE") public int getActive() { return active; @@ -53,41 +57,14 @@ this.active = active; } - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PIPEGALLERYID") - public PipeGallery getPipeGalleryId() { - return pipeGalleryId; - } - - public void setPipeGalleryId(PipeGallery pipeGalleryId) { - this.pipeGalleryId = pipeGalleryId; - } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgTextureList() { - return pgTextureList; + public List getPipeGalleryList() { + return pipeGalleryList; } - public void setPgTextureList(List pgTextureList) { - this.pgTextureList = pgTextureList; + public void setPipeGalleryList(List pipeGalleryList) { + this.pipeGalleryList = pipeGalleryList; } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgPipeLineList() { - return pgPipeLineList; - } - public void setPgPipeLineList(List pgPipeLineList) { - this.pgPipeLineList = pgPipeLineList; - } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgDeviceList() { - return pgDeviceList; - } - - public void setPgDeviceList(List pgDeviceList) { - this.pgDeviceList = pgDeviceList; - } } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java index d936d18..e5ff9b3 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java @@ -22,7 +22,7 @@ private Date enterDate;//入廊时间 private String layerNum;//所在层数 private String diameter;//管径 - private PgPartition pgPartitionId;//所在管廊信息 + private PipeGallery pipeGalleryId;//所在管廊信息 private int active;//状态位 @Id @@ -100,12 +100,12 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java index 1f22bf9..4ebfbda 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java @@ -21,7 +21,7 @@ private String ownerUnit;//权属单位 private Date buildDate;//建设年代 private int active;//状态位 - private PgPartition pgPartitionId;//所在管廊信息 + private PipeGallery pipeGalleryId;//所在管廊信息 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_TEXTURE_ID") @@ -91,12 +91,13 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } + } diff --git a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java index 80625c7..d8f5e6b 100644 --- a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java +++ b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java @@ -43,9 +43,7 @@ this.intoTime = intoTime; } - @Column(name = "OUT_TIME") - public Date getOutTime() { return outTime; } diff --git a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java index a99981e..b1d63a4 100644 --- a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java +++ b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java @@ -1,11 +1,28 @@ package com.casic.PgInterface.devData.manager; +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.core.util.DateUtils; +import com.casic.PgInterface.core.util.StringUtils; +import com.casic.PgInterface.devData.domain.PgCo; +import com.casic.PgInterface.devData.domain.PgLocation; +import com.casic.PgInterface.devData.dto.PgCoDto; +import com.casic.PgInterface.devData.dto.PgLocationDto; +import com.casic.PgInterface.devTable.domain.PgDevice; +import org.hibernate.Criteria; +import org.hibernate.criterion.Order; +import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; + /** * Created by yxw on 2017/11/2. */ @Service -public class PgLocationManager { +public class PgLocationManager extends HibernateEntityDao { + + //获取设备时间段内所有的监测数据 } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java index cfa0281..7fb5953 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -1,12 +1,12 @@ package com.casic.PgInterface.devTable.domain; import com.casic.PgInterface.devData.domain.*; +import com.casic.PgInterface.patroler.domain.PgAlarmRule; import org.hibernate.annotations.NotFound; import org.hibernate.annotations.NotFoundAction; import javax.persistence.*; import java.io.Serializable; -import java.util.Date; import java.util.List; /** @@ -19,21 +19,27 @@ private static final long serialVersionUID = 1L; private long id; + private PipeGallery pipeGalleryId;//所在管廊信息 + private String road;//路名 + private String position;//设备位置 + private String devType;//设备类型 private String devCode;//设备编号 - private String devName;//设备名称 - private String brand;//品牌 - private String ownerUnit;//权属单位 - private Date installDate;//安装时间 + private String assetName;//资产名称 + private String assetCode;//资产编码 + private String assetBarCode;//资产条码 + private String ip;//IP地址 + private String modBus;//modBus地址 + private String mome;//备注 private int isOpen;//设备是否开启 private int active;//状态位 - private PgDeviceType devTypeId;//设备类型 + private List pgAlarms; - private PgPartition pgPartitionId;//所在管廊信息 private List pgTempHums;//温湿度 private List pgCos;//一氧化碳 private List pgO2s;//氧气 private List pgCh4s;//甲烷 private List pgShs;//硫化氢 + private List pgAlarmRules;//报警规则 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") @@ -45,6 +51,33 @@ this.id = id; } + @Column(name = "ROAD") + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + @Column(name = "POSITION") + public String getPosition() { + return position; + } + + public void setPosition(String position) { + this.position = position; + } + + @Column(name = "DEV_TYPE") + public String getDevType() { + return devType; + } + + public void setDevType(String devType) { + this.devType = devType; + } + @Column(name = "DEV_CODE") public String getDevCode() { return devCode; @@ -54,40 +87,58 @@ this.devCode = devCode; } - @Column(name = "DEV_NAME") - public String getDevName() { - return devName; + @Column(name = "ASSET_NAME") + public String getAssetName() { + return assetName; } - public void setDevName(String devName) { - this.devName = devName; + public void setAssetName(String assetName) { + this.assetName = assetName; } - @Column(name = "BRAND") - public String getBrand() { - return brand; + @Column(name = "ASSET_CODE") + public String getAssetCode() { + return assetCode; } - public void setBrand(String brand) { - this.brand = brand; + public void setAssetCode(String assetCode) { + this.assetCode = assetCode; } - @Column(name = "OWNERUNIT") - public String getOwnerUnit() { - return ownerUnit; + @Column(name = "ASSET_BAR_CODE") + public String getAssetBarCode() { + return assetBarCode; } - public void setOwnerUnit(String ownerUnit) { - this.ownerUnit = ownerUnit; + public void setAssetBarCode(String assetBarCode) { + this.assetBarCode = assetBarCode; } - @Column(name = "INSTALDATE") - public Date getInstallDate() { - return installDate; + @Column(name = "IP") + public String getIp() { + return ip; } - public void setInstallDate(Date installDate) { - this.installDate = installDate; + public void setIp(String ip) { + this.ip = ip; + } + + @Column(name = "MODBUS") + public String getModBus() { + return modBus; + } + + public void setModBus(String modBus) { + this.modBus = modBus; + } + + @Column(name = "MOME") + public String getMome() { + return mome; + } + + public void setMome(String mome) { + this.mome = mome; } @Column(name = "ISOPEN") @@ -119,24 +170,13 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; - } - - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "DEVICE_TYPE_ID") - public PgDeviceType getDevTypeId() { - return devTypeId; - } - - public void setDevTypeId(PgDeviceType devTypeId) { - this.devTypeId = devTypeId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgDeviceId") @@ -184,4 +224,13 @@ this.pgShs = pgShs; } + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgDeviceId") + public List getPgAlarmRules() { + return pgAlarmRules; + } + + public void setPgAlarmRules(List pgAlarmRules) { + this.pgAlarmRules = pgAlarmRules; + } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java index b997b29..4fb3d6f 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java @@ -1,8 +1,5 @@ package com.casic.PgInterface.devTable.domain; -import org.hibernate.annotations.NotFound; -import org.hibernate.annotations.NotFoundAction; - import javax.persistence.*; import java.io.Serializable; import java.util.List; @@ -19,11 +16,9 @@ private long id; private String parName;//分区名称 - private PipeGallery pipeGalleryId;//管廊仓 + private String road;//所属道路 private int active;//状态位 - private List pgTextureList; - private List pgPipeLineList; - private List pgDeviceList; + private List pipeGalleryList;//管廊仓 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PARTITION_ID") @@ -44,6 +39,15 @@ this.parName = parName; } + @Column(name = "ROAD") + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + @Column(name = "ACTIVE") public int getActive() { return active; @@ -53,41 +57,14 @@ this.active = active; } - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PIPEGALLERYID") - public PipeGallery getPipeGalleryId() { - return pipeGalleryId; - } - - public void setPipeGalleryId(PipeGallery pipeGalleryId) { - this.pipeGalleryId = pipeGalleryId; - } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgTextureList() { - return pgTextureList; + public List getPipeGalleryList() { + return pipeGalleryList; } - public void setPgTextureList(List pgTextureList) { - this.pgTextureList = pgTextureList; + public void setPipeGalleryList(List pipeGalleryList) { + this.pipeGalleryList = pipeGalleryList; } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgPipeLineList() { - return pgPipeLineList; - } - public void setPgPipeLineList(List pgPipeLineList) { - this.pgPipeLineList = pgPipeLineList; - } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgDeviceList() { - return pgDeviceList; - } - - public void setPgDeviceList(List pgDeviceList) { - this.pgDeviceList = pgDeviceList; - } } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java index d936d18..e5ff9b3 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java @@ -22,7 +22,7 @@ private Date enterDate;//入廊时间 private String layerNum;//所在层数 private String diameter;//管径 - private PgPartition pgPartitionId;//所在管廊信息 + private PipeGallery pipeGalleryId;//所在管廊信息 private int active;//状态位 @Id @@ -100,12 +100,12 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java index 1f22bf9..4ebfbda 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java @@ -21,7 +21,7 @@ private String ownerUnit;//权属单位 private Date buildDate;//建设年代 private int active;//状态位 - private PgPartition pgPartitionId;//所在管廊信息 + private PipeGallery pipeGalleryId;//所在管廊信息 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_TEXTURE_ID") @@ -91,12 +91,13 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java b/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java index 49a246c..650d623 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java @@ -1,5 +1,8 @@ package com.casic.PgInterface.devTable.domain; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + import javax.persistence.*; import java.io.Serializable; import java.util.List; @@ -16,7 +19,10 @@ private long id; private String pgName;//管廊名称 private int active;//状态位 - private List partitionList; + private PgPartition pgPartitionId;// + private List pgTextureList; + private List pgPipeLineList; + private List pgDeviceList; @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PIPE_GALLERY_ID") @@ -46,12 +52,42 @@ this.active = active; } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") - public List getPartitionList() { - return partitionList; + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "PARTITIONID") + public PgPartition getPgPartitionId() { + return pgPartitionId; } - public void setPartitionList(List partitionList) { - this.partitionList = partitionList; + public void setPgPartitionId(PgPartition pgPartitionId) { + this.pgPartitionId = pgPartitionId; } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgTextureList() { + return pgTextureList; + } + + public void setPgTextureList(List pgTextureList) { + this.pgTextureList = pgTextureList; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgPipeLineList() { + return pgPipeLineList; + } + + public void setPgPipeLineList(List pgPipeLineList) { + this.pgPipeLineList = pgPipeLineList; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgDeviceList() { + return pgDeviceList; + } + + public void setPgDeviceList(List pgDeviceList) { + this.pgDeviceList = pgDeviceList; + } + } diff --git a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java index 80625c7..d8f5e6b 100644 --- a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java +++ b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java @@ -43,9 +43,7 @@ this.intoTime = intoTime; } - @Column(name = "OUT_TIME") - public Date getOutTime() { return outTime; } diff --git a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java index a99981e..b1d63a4 100644 --- a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java +++ b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java @@ -1,11 +1,28 @@ package com.casic.PgInterface.devData.manager; +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.core.util.DateUtils; +import com.casic.PgInterface.core.util.StringUtils; +import com.casic.PgInterface.devData.domain.PgCo; +import com.casic.PgInterface.devData.domain.PgLocation; +import com.casic.PgInterface.devData.dto.PgCoDto; +import com.casic.PgInterface.devData.dto.PgLocationDto; +import com.casic.PgInterface.devTable.domain.PgDevice; +import org.hibernate.Criteria; +import org.hibernate.criterion.Order; +import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; + /** * Created by yxw on 2017/11/2. */ @Service -public class PgLocationManager { +public class PgLocationManager extends HibernateEntityDao { + + //获取设备时间段内所有的监测数据 } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java index cfa0281..7fb5953 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -1,12 +1,12 @@ package com.casic.PgInterface.devTable.domain; import com.casic.PgInterface.devData.domain.*; +import com.casic.PgInterface.patroler.domain.PgAlarmRule; import org.hibernate.annotations.NotFound; import org.hibernate.annotations.NotFoundAction; import javax.persistence.*; import java.io.Serializable; -import java.util.Date; import java.util.List; /** @@ -19,21 +19,27 @@ private static final long serialVersionUID = 1L; private long id; + private PipeGallery pipeGalleryId;//所在管廊信息 + private String road;//路名 + private String position;//设备位置 + private String devType;//设备类型 private String devCode;//设备编号 - private String devName;//设备名称 - private String brand;//品牌 - private String ownerUnit;//权属单位 - private Date installDate;//安装时间 + private String assetName;//资产名称 + private String assetCode;//资产编码 + private String assetBarCode;//资产条码 + private String ip;//IP地址 + private String modBus;//modBus地址 + private String mome;//备注 private int isOpen;//设备是否开启 private int active;//状态位 - private PgDeviceType devTypeId;//设备类型 + private List pgAlarms; - private PgPartition pgPartitionId;//所在管廊信息 private List pgTempHums;//温湿度 private List pgCos;//一氧化碳 private List pgO2s;//氧气 private List pgCh4s;//甲烷 private List pgShs;//硫化氢 + private List pgAlarmRules;//报警规则 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") @@ -45,6 +51,33 @@ this.id = id; } + @Column(name = "ROAD") + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + @Column(name = "POSITION") + public String getPosition() { + return position; + } + + public void setPosition(String position) { + this.position = position; + } + + @Column(name = "DEV_TYPE") + public String getDevType() { + return devType; + } + + public void setDevType(String devType) { + this.devType = devType; + } + @Column(name = "DEV_CODE") public String getDevCode() { return devCode; @@ -54,40 +87,58 @@ this.devCode = devCode; } - @Column(name = "DEV_NAME") - public String getDevName() { - return devName; + @Column(name = "ASSET_NAME") + public String getAssetName() { + return assetName; } - public void setDevName(String devName) { - this.devName = devName; + public void setAssetName(String assetName) { + this.assetName = assetName; } - @Column(name = "BRAND") - public String getBrand() { - return brand; + @Column(name = "ASSET_CODE") + public String getAssetCode() { + return assetCode; } - public void setBrand(String brand) { - this.brand = brand; + public void setAssetCode(String assetCode) { + this.assetCode = assetCode; } - @Column(name = "OWNERUNIT") - public String getOwnerUnit() { - return ownerUnit; + @Column(name = "ASSET_BAR_CODE") + public String getAssetBarCode() { + return assetBarCode; } - public void setOwnerUnit(String ownerUnit) { - this.ownerUnit = ownerUnit; + public void setAssetBarCode(String assetBarCode) { + this.assetBarCode = assetBarCode; } - @Column(name = "INSTALDATE") - public Date getInstallDate() { - return installDate; + @Column(name = "IP") + public String getIp() { + return ip; } - public void setInstallDate(Date installDate) { - this.installDate = installDate; + public void setIp(String ip) { + this.ip = ip; + } + + @Column(name = "MODBUS") + public String getModBus() { + return modBus; + } + + public void setModBus(String modBus) { + this.modBus = modBus; + } + + @Column(name = "MOME") + public String getMome() { + return mome; + } + + public void setMome(String mome) { + this.mome = mome; } @Column(name = "ISOPEN") @@ -119,24 +170,13 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; - } - - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "DEVICE_TYPE_ID") - public PgDeviceType getDevTypeId() { - return devTypeId; - } - - public void setDevTypeId(PgDeviceType devTypeId) { - this.devTypeId = devTypeId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgDeviceId") @@ -184,4 +224,13 @@ this.pgShs = pgShs; } + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgDeviceId") + public List getPgAlarmRules() { + return pgAlarmRules; + } + + public void setPgAlarmRules(List pgAlarmRules) { + this.pgAlarmRules = pgAlarmRules; + } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java index b997b29..4fb3d6f 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java @@ -1,8 +1,5 @@ package com.casic.PgInterface.devTable.domain; -import org.hibernate.annotations.NotFound; -import org.hibernate.annotations.NotFoundAction; - import javax.persistence.*; import java.io.Serializable; import java.util.List; @@ -19,11 +16,9 @@ private long id; private String parName;//分区名称 - private PipeGallery pipeGalleryId;//管廊仓 + private String road;//所属道路 private int active;//状态位 - private List pgTextureList; - private List pgPipeLineList; - private List pgDeviceList; + private List pipeGalleryList;//管廊仓 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PARTITION_ID") @@ -44,6 +39,15 @@ this.parName = parName; } + @Column(name = "ROAD") + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + @Column(name = "ACTIVE") public int getActive() { return active; @@ -53,41 +57,14 @@ this.active = active; } - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PIPEGALLERYID") - public PipeGallery getPipeGalleryId() { - return pipeGalleryId; - } - - public void setPipeGalleryId(PipeGallery pipeGalleryId) { - this.pipeGalleryId = pipeGalleryId; - } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgTextureList() { - return pgTextureList; + public List getPipeGalleryList() { + return pipeGalleryList; } - public void setPgTextureList(List pgTextureList) { - this.pgTextureList = pgTextureList; + public void setPipeGalleryList(List pipeGalleryList) { + this.pipeGalleryList = pipeGalleryList; } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgPipeLineList() { - return pgPipeLineList; - } - public void setPgPipeLineList(List pgPipeLineList) { - this.pgPipeLineList = pgPipeLineList; - } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgDeviceList() { - return pgDeviceList; - } - - public void setPgDeviceList(List pgDeviceList) { - this.pgDeviceList = pgDeviceList; - } } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java index d936d18..e5ff9b3 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java @@ -22,7 +22,7 @@ private Date enterDate;//入廊时间 private String layerNum;//所在层数 private String diameter;//管径 - private PgPartition pgPartitionId;//所在管廊信息 + private PipeGallery pipeGalleryId;//所在管廊信息 private int active;//状态位 @Id @@ -100,12 +100,12 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java index 1f22bf9..4ebfbda 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java @@ -21,7 +21,7 @@ private String ownerUnit;//权属单位 private Date buildDate;//建设年代 private int active;//状态位 - private PgPartition pgPartitionId;//所在管廊信息 + private PipeGallery pipeGalleryId;//所在管廊信息 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_TEXTURE_ID") @@ -91,12 +91,13 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java b/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java index 49a246c..650d623 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java @@ -1,5 +1,8 @@ package com.casic.PgInterface.devTable.domain; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + import javax.persistence.*; import java.io.Serializable; import java.util.List; @@ -16,7 +19,10 @@ private long id; private String pgName;//管廊名称 private int active;//状态位 - private List partitionList; + private PgPartition pgPartitionId;// + private List pgTextureList; + private List pgPipeLineList; + private List pgDeviceList; @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PIPE_GALLERY_ID") @@ -46,12 +52,42 @@ this.active = active; } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") - public List getPartitionList() { - return partitionList; + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "PARTITIONID") + public PgPartition getPgPartitionId() { + return pgPartitionId; } - public void setPartitionList(List partitionList) { - this.partitionList = partitionList; + public void setPgPartitionId(PgPartition pgPartitionId) { + this.pgPartitionId = pgPartitionId; } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgTextureList() { + return pgTextureList; + } + + public void setPgTextureList(List pgTextureList) { + this.pgTextureList = pgTextureList; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgPipeLineList() { + return pgPipeLineList; + } + + public void setPgPipeLineList(List pgPipeLineList) { + this.pgPipeLineList = pgPipeLineList; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgDeviceList() { + return pgDeviceList; + } + + public void setPgDeviceList(List pgDeviceList) { + this.pgDeviceList = pgDeviceList; + } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java index b4048d9..c3dfc55 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java @@ -101,18 +101,17 @@ this.active = active; } - public PgAlarmDto(PgAlarm pgAlarm) - { - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + public PgAlarmDto(PgAlarm pgAlarm) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); this.setId(String.valueOf(pgAlarm.getId())); this.setAlarmType(pgAlarm.getAlarmTypeId().getAlarmType()); this.setAlarmValue(pgAlarm.getAlarmValue()); this.setAlarmDate(sdf.format(pgAlarm.getAlarmDate())); this.setDescription(pgAlarm.getDescription()); - this.setAlarmDevName(pgAlarm.getAlarmDevId().getDevName()); - this.setAlarmLocation(pgAlarm.getAlarmDevId().getPgPartitionId().getPipeGalleryId().getPgName() - + pgAlarm.getAlarmDevId().getPgPartitionId().getParName()); + this.setAlarmDevName(pgAlarm.getAlarmDevId().getAssetName()); + this.setAlarmLocation(pgAlarm.getAlarmDevId().getPipeGalleryId().getPgPartitionId().getParName() + + pgAlarm.getAlarmDevId().getPipeGalleryId().getPgName()); this.setUserName(pgAlarm.getPatrolerId().getUserName()); this.setPhoneNumber(pgAlarm.getPatrolerId().getPhoneNumber()); this.setActive(String.valueOf(pgAlarm.getActive())); diff --git a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java index 80625c7..d8f5e6b 100644 --- a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java +++ b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java @@ -43,9 +43,7 @@ this.intoTime = intoTime; } - @Column(name = "OUT_TIME") - public Date getOutTime() { return outTime; } diff --git a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java index a99981e..b1d63a4 100644 --- a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java +++ b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java @@ -1,11 +1,28 @@ package com.casic.PgInterface.devData.manager; +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.core.util.DateUtils; +import com.casic.PgInterface.core.util.StringUtils; +import com.casic.PgInterface.devData.domain.PgCo; +import com.casic.PgInterface.devData.domain.PgLocation; +import com.casic.PgInterface.devData.dto.PgCoDto; +import com.casic.PgInterface.devData.dto.PgLocationDto; +import com.casic.PgInterface.devTable.domain.PgDevice; +import org.hibernate.Criteria; +import org.hibernate.criterion.Order; +import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; + /** * Created by yxw on 2017/11/2. */ @Service -public class PgLocationManager { +public class PgLocationManager extends HibernateEntityDao { + + //获取设备时间段内所有的监测数据 } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java index cfa0281..7fb5953 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -1,12 +1,12 @@ package com.casic.PgInterface.devTable.domain; import com.casic.PgInterface.devData.domain.*; +import com.casic.PgInterface.patroler.domain.PgAlarmRule; import org.hibernate.annotations.NotFound; import org.hibernate.annotations.NotFoundAction; import javax.persistence.*; import java.io.Serializable; -import java.util.Date; import java.util.List; /** @@ -19,21 +19,27 @@ private static final long serialVersionUID = 1L; private long id; + private PipeGallery pipeGalleryId;//所在管廊信息 + private String road;//路名 + private String position;//设备位置 + private String devType;//设备类型 private String devCode;//设备编号 - private String devName;//设备名称 - private String brand;//品牌 - private String ownerUnit;//权属单位 - private Date installDate;//安装时间 + private String assetName;//资产名称 + private String assetCode;//资产编码 + private String assetBarCode;//资产条码 + private String ip;//IP地址 + private String modBus;//modBus地址 + private String mome;//备注 private int isOpen;//设备是否开启 private int active;//状态位 - private PgDeviceType devTypeId;//设备类型 + private List pgAlarms; - private PgPartition pgPartitionId;//所在管廊信息 private List pgTempHums;//温湿度 private List pgCos;//一氧化碳 private List pgO2s;//氧气 private List pgCh4s;//甲烷 private List pgShs;//硫化氢 + private List pgAlarmRules;//报警规则 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") @@ -45,6 +51,33 @@ this.id = id; } + @Column(name = "ROAD") + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + @Column(name = "POSITION") + public String getPosition() { + return position; + } + + public void setPosition(String position) { + this.position = position; + } + + @Column(name = "DEV_TYPE") + public String getDevType() { + return devType; + } + + public void setDevType(String devType) { + this.devType = devType; + } + @Column(name = "DEV_CODE") public String getDevCode() { return devCode; @@ -54,40 +87,58 @@ this.devCode = devCode; } - @Column(name = "DEV_NAME") - public String getDevName() { - return devName; + @Column(name = "ASSET_NAME") + public String getAssetName() { + return assetName; } - public void setDevName(String devName) { - this.devName = devName; + public void setAssetName(String assetName) { + this.assetName = assetName; } - @Column(name = "BRAND") - public String getBrand() { - return brand; + @Column(name = "ASSET_CODE") + public String getAssetCode() { + return assetCode; } - public void setBrand(String brand) { - this.brand = brand; + public void setAssetCode(String assetCode) { + this.assetCode = assetCode; } - @Column(name = "OWNERUNIT") - public String getOwnerUnit() { - return ownerUnit; + @Column(name = "ASSET_BAR_CODE") + public String getAssetBarCode() { + return assetBarCode; } - public void setOwnerUnit(String ownerUnit) { - this.ownerUnit = ownerUnit; + public void setAssetBarCode(String assetBarCode) { + this.assetBarCode = assetBarCode; } - @Column(name = "INSTALDATE") - public Date getInstallDate() { - return installDate; + @Column(name = "IP") + public String getIp() { + return ip; } - public void setInstallDate(Date installDate) { - this.installDate = installDate; + public void setIp(String ip) { + this.ip = ip; + } + + @Column(name = "MODBUS") + public String getModBus() { + return modBus; + } + + public void setModBus(String modBus) { + this.modBus = modBus; + } + + @Column(name = "MOME") + public String getMome() { + return mome; + } + + public void setMome(String mome) { + this.mome = mome; } @Column(name = "ISOPEN") @@ -119,24 +170,13 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; - } - - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "DEVICE_TYPE_ID") - public PgDeviceType getDevTypeId() { - return devTypeId; - } - - public void setDevTypeId(PgDeviceType devTypeId) { - this.devTypeId = devTypeId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgDeviceId") @@ -184,4 +224,13 @@ this.pgShs = pgShs; } + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgDeviceId") + public List getPgAlarmRules() { + return pgAlarmRules; + } + + public void setPgAlarmRules(List pgAlarmRules) { + this.pgAlarmRules = pgAlarmRules; + } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java index b997b29..4fb3d6f 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java @@ -1,8 +1,5 @@ package com.casic.PgInterface.devTable.domain; -import org.hibernate.annotations.NotFound; -import org.hibernate.annotations.NotFoundAction; - import javax.persistence.*; import java.io.Serializable; import java.util.List; @@ -19,11 +16,9 @@ private long id; private String parName;//分区名称 - private PipeGallery pipeGalleryId;//管廊仓 + private String road;//所属道路 private int active;//状态位 - private List pgTextureList; - private List pgPipeLineList; - private List pgDeviceList; + private List pipeGalleryList;//管廊仓 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PARTITION_ID") @@ -44,6 +39,15 @@ this.parName = parName; } + @Column(name = "ROAD") + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + @Column(name = "ACTIVE") public int getActive() { return active; @@ -53,41 +57,14 @@ this.active = active; } - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PIPEGALLERYID") - public PipeGallery getPipeGalleryId() { - return pipeGalleryId; - } - - public void setPipeGalleryId(PipeGallery pipeGalleryId) { - this.pipeGalleryId = pipeGalleryId; - } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgTextureList() { - return pgTextureList; + public List getPipeGalleryList() { + return pipeGalleryList; } - public void setPgTextureList(List pgTextureList) { - this.pgTextureList = pgTextureList; + public void setPipeGalleryList(List pipeGalleryList) { + this.pipeGalleryList = pipeGalleryList; } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgPipeLineList() { - return pgPipeLineList; - } - public void setPgPipeLineList(List pgPipeLineList) { - this.pgPipeLineList = pgPipeLineList; - } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgDeviceList() { - return pgDeviceList; - } - - public void setPgDeviceList(List pgDeviceList) { - this.pgDeviceList = pgDeviceList; - } } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java index d936d18..e5ff9b3 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java @@ -22,7 +22,7 @@ private Date enterDate;//入廊时间 private String layerNum;//所在层数 private String diameter;//管径 - private PgPartition pgPartitionId;//所在管廊信息 + private PipeGallery pipeGalleryId;//所在管廊信息 private int active;//状态位 @Id @@ -100,12 +100,12 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java index 1f22bf9..4ebfbda 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java @@ -21,7 +21,7 @@ private String ownerUnit;//权属单位 private Date buildDate;//建设年代 private int active;//状态位 - private PgPartition pgPartitionId;//所在管廊信息 + private PipeGallery pipeGalleryId;//所在管廊信息 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_TEXTURE_ID") @@ -91,12 +91,13 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java b/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java index 49a246c..650d623 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java @@ -1,5 +1,8 @@ package com.casic.PgInterface.devTable.domain; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + import javax.persistence.*; import java.io.Serializable; import java.util.List; @@ -16,7 +19,10 @@ private long id; private String pgName;//管廊名称 private int active;//状态位 - private List partitionList; + private PgPartition pgPartitionId;// + private List pgTextureList; + private List pgPipeLineList; + private List pgDeviceList; @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PIPE_GALLERY_ID") @@ -46,12 +52,42 @@ this.active = active; } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") - public List getPartitionList() { - return partitionList; + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "PARTITIONID") + public PgPartition getPgPartitionId() { + return pgPartitionId; } - public void setPartitionList(List partitionList) { - this.partitionList = partitionList; + public void setPgPartitionId(PgPartition pgPartitionId) { + this.pgPartitionId = pgPartitionId; } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgTextureList() { + return pgTextureList; + } + + public void setPgTextureList(List pgTextureList) { + this.pgTextureList = pgTextureList; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgPipeLineList() { + return pgPipeLineList; + } + + public void setPgPipeLineList(List pgPipeLineList) { + this.pgPipeLineList = pgPipeLineList; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgDeviceList() { + return pgDeviceList; + } + + public void setPgDeviceList(List pgDeviceList) { + this.pgDeviceList = pgDeviceList; + } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java index b4048d9..c3dfc55 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java @@ -101,18 +101,17 @@ this.active = active; } - public PgAlarmDto(PgAlarm pgAlarm) - { - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + public PgAlarmDto(PgAlarm pgAlarm) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); this.setId(String.valueOf(pgAlarm.getId())); this.setAlarmType(pgAlarm.getAlarmTypeId().getAlarmType()); this.setAlarmValue(pgAlarm.getAlarmValue()); this.setAlarmDate(sdf.format(pgAlarm.getAlarmDate())); this.setDescription(pgAlarm.getDescription()); - this.setAlarmDevName(pgAlarm.getAlarmDevId().getDevName()); - this.setAlarmLocation(pgAlarm.getAlarmDevId().getPgPartitionId().getPipeGalleryId().getPgName() - + pgAlarm.getAlarmDevId().getPgPartitionId().getParName()); + this.setAlarmDevName(pgAlarm.getAlarmDevId().getAssetName()); + this.setAlarmLocation(pgAlarm.getAlarmDevId().getPipeGalleryId().getPgPartitionId().getParName() + + pgAlarm.getAlarmDevId().getPipeGalleryId().getPgName()); this.setUserName(pgAlarm.getPatrolerId().getUserName()); this.setPhoneNumber(pgAlarm.getPatrolerId().getPhoneNumber()); this.setActive(String.valueOf(pgAlarm.getActive())); diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java index ae76e95..49bd436 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java @@ -11,16 +11,20 @@ public class PgDeviceDto implements Serializable { private String id; - private String devType;//设备类型 - private String devCode;//设备编号 - private String devName;//设备名称 - private String brand;//品牌 - private String ownerUnit;//权属单位 - private String installDate;//安装时间 - private String isOpen;//设备开启状态 - private String active;//状态位 private String pipeGallery;//仓位 private String partition;//分区 + private String road;//路名 + private String position;//设备位置 + private String devType;//设备类型 + private String devCode;//设备编号 + private String assetName;//资产名称 + private String assetCode;//资产名称 + private String assetBarCode;//资产条码 + private String ip;//IP地址 + private String modBus;//modBus地址 + private String mome;//备注 + private String isOpen;//设备开启状态 + private String active;//状态位 public String getId() { return id; @@ -30,6 +34,38 @@ this.id = id; } + public String getPartition() { + return partition; + } + + public void setPartition(String partition) { + this.partition = partition; + } + + public String getPipeGallery() { + return pipeGallery; + } + + public void setPipeGallery(String pipeGallery) { + this.pipeGallery = pipeGallery; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getPosition() { + return position; + } + + public void setPosition(String position) { + this.position = position; + } + public String getDevType() { return devType; } @@ -46,36 +82,52 @@ this.devCode = devCode; } - public String getDevName() { - return devName; + public String getAssetName() { + return assetName; } - public void setDevName(String devName) { - this.devName = devName; + public void setAssetName(String assetName) { + this.assetName = assetName; } - public String getBrand() { - return brand; + public String getAssetCode() { + return assetCode; } - public void setBrand(String brand) { - this.brand = brand; + public void setAssetCode(String assetCode) { + this.assetCode = assetCode; } - public String getOwnerUnit() { - return ownerUnit; + public String getAssetBarCode() { + return assetBarCode; } - public void setOwnerUnit(String ownerUnit) { - this.ownerUnit = ownerUnit; + public void setAssetBarCode(String assetBarCode) { + this.assetBarCode = assetBarCode; } - public String getInstallDate() { - return installDate; + public String getIp() { + return ip; } - public void setInstallDate(String installDate) { - this.installDate = installDate; + public void setIp(String ip) { + this.ip = ip; + } + + public String getModBus() { + return modBus; + } + + public void setModBus(String modBus) { + this.modBus = modBus; + } + + public String getMome() { + return mome; + } + + public void setMome(String mome) { + this.mome = mome; } public String getIsOpen() { @@ -94,39 +146,26 @@ this.active = active; } - public String getPipeGallery() { - return pipeGallery; - } - - public void setPipeGallery(String pipeGallery) { - this.pipeGallery = pipeGallery; - } - - public String getPartition() { - return partition; - } - - public void setPartition(String partition) { - this.partition = partition; - } - public PgDeviceDto(PgDevice pgDevice) { SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); this.setId(String.valueOf(pgDevice.getId())); - this.setDevType(pgDevice.getDevTypeId().getDevType()); + this.setPipeGallery(pgDevice.getPipeGalleryId().getPgName()); + this.setPartition(pgDevice.getPipeGalleryId().getPgPartitionId().getParName()); + this.setRoad(pgDevice.getRoad()); + this.setPosition(pgDevice.getPosition()); + this.setDevType(pgDevice.getDevType()); this.setDevCode(pgDevice.getDevCode()); - this.setDevName(pgDevice.getDevName()); - this.setBrand(pgDevice.getBrand()); - this.setOwnerUnit(pgDevice.getOwnerUnit()); - this.setInstallDate(sdf.format(pgDevice.getInstallDate())); + this.setAssetName(pgDevice.getAssetName()); + this.setAssetCode(pgDevice.getAssetCode()); + this.setAssetBarCode(pgDevice.getAssetBarCode()); + this.setId(pgDevice.getIp()); + this.setModBus(pgDevice.getModBus()); + this.setMome(pgDevice.getMome()); this.setIsOpen(String.valueOf(pgDevice.getIsOpen())); this.setActive(String.valueOf(pgDevice.getActive())); - this.setPipeGallery(pgDevice.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgDevice.getPgPartitionId().getParName()); + } - -} - +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java index 80625c7..d8f5e6b 100644 --- a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java +++ b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java @@ -43,9 +43,7 @@ this.intoTime = intoTime; } - @Column(name = "OUT_TIME") - public Date getOutTime() { return outTime; } diff --git a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java index a99981e..b1d63a4 100644 --- a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java +++ b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java @@ -1,11 +1,28 @@ package com.casic.PgInterface.devData.manager; +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.core.util.DateUtils; +import com.casic.PgInterface.core.util.StringUtils; +import com.casic.PgInterface.devData.domain.PgCo; +import com.casic.PgInterface.devData.domain.PgLocation; +import com.casic.PgInterface.devData.dto.PgCoDto; +import com.casic.PgInterface.devData.dto.PgLocationDto; +import com.casic.PgInterface.devTable.domain.PgDevice; +import org.hibernate.Criteria; +import org.hibernate.criterion.Order; +import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; + /** * Created by yxw on 2017/11/2. */ @Service -public class PgLocationManager { +public class PgLocationManager extends HibernateEntityDao { + + //获取设备时间段内所有的监测数据 } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java index cfa0281..7fb5953 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -1,12 +1,12 @@ package com.casic.PgInterface.devTable.domain; import com.casic.PgInterface.devData.domain.*; +import com.casic.PgInterface.patroler.domain.PgAlarmRule; import org.hibernate.annotations.NotFound; import org.hibernate.annotations.NotFoundAction; import javax.persistence.*; import java.io.Serializable; -import java.util.Date; import java.util.List; /** @@ -19,21 +19,27 @@ private static final long serialVersionUID = 1L; private long id; + private PipeGallery pipeGalleryId;//所在管廊信息 + private String road;//路名 + private String position;//设备位置 + private String devType;//设备类型 private String devCode;//设备编号 - private String devName;//设备名称 - private String brand;//品牌 - private String ownerUnit;//权属单位 - private Date installDate;//安装时间 + private String assetName;//资产名称 + private String assetCode;//资产编码 + private String assetBarCode;//资产条码 + private String ip;//IP地址 + private String modBus;//modBus地址 + private String mome;//备注 private int isOpen;//设备是否开启 private int active;//状态位 - private PgDeviceType devTypeId;//设备类型 + private List pgAlarms; - private PgPartition pgPartitionId;//所在管廊信息 private List pgTempHums;//温湿度 private List pgCos;//一氧化碳 private List pgO2s;//氧气 private List pgCh4s;//甲烷 private List pgShs;//硫化氢 + private List pgAlarmRules;//报警规则 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") @@ -45,6 +51,33 @@ this.id = id; } + @Column(name = "ROAD") + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + @Column(name = "POSITION") + public String getPosition() { + return position; + } + + public void setPosition(String position) { + this.position = position; + } + + @Column(name = "DEV_TYPE") + public String getDevType() { + return devType; + } + + public void setDevType(String devType) { + this.devType = devType; + } + @Column(name = "DEV_CODE") public String getDevCode() { return devCode; @@ -54,40 +87,58 @@ this.devCode = devCode; } - @Column(name = "DEV_NAME") - public String getDevName() { - return devName; + @Column(name = "ASSET_NAME") + public String getAssetName() { + return assetName; } - public void setDevName(String devName) { - this.devName = devName; + public void setAssetName(String assetName) { + this.assetName = assetName; } - @Column(name = "BRAND") - public String getBrand() { - return brand; + @Column(name = "ASSET_CODE") + public String getAssetCode() { + return assetCode; } - public void setBrand(String brand) { - this.brand = brand; + public void setAssetCode(String assetCode) { + this.assetCode = assetCode; } - @Column(name = "OWNERUNIT") - public String getOwnerUnit() { - return ownerUnit; + @Column(name = "ASSET_BAR_CODE") + public String getAssetBarCode() { + return assetBarCode; } - public void setOwnerUnit(String ownerUnit) { - this.ownerUnit = ownerUnit; + public void setAssetBarCode(String assetBarCode) { + this.assetBarCode = assetBarCode; } - @Column(name = "INSTALDATE") - public Date getInstallDate() { - return installDate; + @Column(name = "IP") + public String getIp() { + return ip; } - public void setInstallDate(Date installDate) { - this.installDate = installDate; + public void setIp(String ip) { + this.ip = ip; + } + + @Column(name = "MODBUS") + public String getModBus() { + return modBus; + } + + public void setModBus(String modBus) { + this.modBus = modBus; + } + + @Column(name = "MOME") + public String getMome() { + return mome; + } + + public void setMome(String mome) { + this.mome = mome; } @Column(name = "ISOPEN") @@ -119,24 +170,13 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; - } - - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "DEVICE_TYPE_ID") - public PgDeviceType getDevTypeId() { - return devTypeId; - } - - public void setDevTypeId(PgDeviceType devTypeId) { - this.devTypeId = devTypeId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgDeviceId") @@ -184,4 +224,13 @@ this.pgShs = pgShs; } + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgDeviceId") + public List getPgAlarmRules() { + return pgAlarmRules; + } + + public void setPgAlarmRules(List pgAlarmRules) { + this.pgAlarmRules = pgAlarmRules; + } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java index b997b29..4fb3d6f 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java @@ -1,8 +1,5 @@ package com.casic.PgInterface.devTable.domain; -import org.hibernate.annotations.NotFound; -import org.hibernate.annotations.NotFoundAction; - import javax.persistence.*; import java.io.Serializable; import java.util.List; @@ -19,11 +16,9 @@ private long id; private String parName;//分区名称 - private PipeGallery pipeGalleryId;//管廊仓 + private String road;//所属道路 private int active;//状态位 - private List pgTextureList; - private List pgPipeLineList; - private List pgDeviceList; + private List pipeGalleryList;//管廊仓 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PARTITION_ID") @@ -44,6 +39,15 @@ this.parName = parName; } + @Column(name = "ROAD") + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + @Column(name = "ACTIVE") public int getActive() { return active; @@ -53,41 +57,14 @@ this.active = active; } - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PIPEGALLERYID") - public PipeGallery getPipeGalleryId() { - return pipeGalleryId; - } - - public void setPipeGalleryId(PipeGallery pipeGalleryId) { - this.pipeGalleryId = pipeGalleryId; - } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgTextureList() { - return pgTextureList; + public List getPipeGalleryList() { + return pipeGalleryList; } - public void setPgTextureList(List pgTextureList) { - this.pgTextureList = pgTextureList; + public void setPipeGalleryList(List pipeGalleryList) { + this.pipeGalleryList = pipeGalleryList; } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgPipeLineList() { - return pgPipeLineList; - } - public void setPgPipeLineList(List pgPipeLineList) { - this.pgPipeLineList = pgPipeLineList; - } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgDeviceList() { - return pgDeviceList; - } - - public void setPgDeviceList(List pgDeviceList) { - this.pgDeviceList = pgDeviceList; - } } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java index d936d18..e5ff9b3 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java @@ -22,7 +22,7 @@ private Date enterDate;//入廊时间 private String layerNum;//所在层数 private String diameter;//管径 - private PgPartition pgPartitionId;//所在管廊信息 + private PipeGallery pipeGalleryId;//所在管廊信息 private int active;//状态位 @Id @@ -100,12 +100,12 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java index 1f22bf9..4ebfbda 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java @@ -21,7 +21,7 @@ private String ownerUnit;//权属单位 private Date buildDate;//建设年代 private int active;//状态位 - private PgPartition pgPartitionId;//所在管廊信息 + private PipeGallery pipeGalleryId;//所在管廊信息 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_TEXTURE_ID") @@ -91,12 +91,13 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java b/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java index 49a246c..650d623 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java @@ -1,5 +1,8 @@ package com.casic.PgInterface.devTable.domain; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + import javax.persistence.*; import java.io.Serializable; import java.util.List; @@ -16,7 +19,10 @@ private long id; private String pgName;//管廊名称 private int active;//状态位 - private List partitionList; + private PgPartition pgPartitionId;// + private List pgTextureList; + private List pgPipeLineList; + private List pgDeviceList; @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PIPE_GALLERY_ID") @@ -46,12 +52,42 @@ this.active = active; } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") - public List getPartitionList() { - return partitionList; + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "PARTITIONID") + public PgPartition getPgPartitionId() { + return pgPartitionId; } - public void setPartitionList(List partitionList) { - this.partitionList = partitionList; + public void setPgPartitionId(PgPartition pgPartitionId) { + this.pgPartitionId = pgPartitionId; } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgTextureList() { + return pgTextureList; + } + + public void setPgTextureList(List pgTextureList) { + this.pgTextureList = pgTextureList; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgPipeLineList() { + return pgPipeLineList; + } + + public void setPgPipeLineList(List pgPipeLineList) { + this.pgPipeLineList = pgPipeLineList; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgDeviceList() { + return pgDeviceList; + } + + public void setPgDeviceList(List pgDeviceList) { + this.pgDeviceList = pgDeviceList; + } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java index b4048d9..c3dfc55 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java @@ -101,18 +101,17 @@ this.active = active; } - public PgAlarmDto(PgAlarm pgAlarm) - { - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + public PgAlarmDto(PgAlarm pgAlarm) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); this.setId(String.valueOf(pgAlarm.getId())); this.setAlarmType(pgAlarm.getAlarmTypeId().getAlarmType()); this.setAlarmValue(pgAlarm.getAlarmValue()); this.setAlarmDate(sdf.format(pgAlarm.getAlarmDate())); this.setDescription(pgAlarm.getDescription()); - this.setAlarmDevName(pgAlarm.getAlarmDevId().getDevName()); - this.setAlarmLocation(pgAlarm.getAlarmDevId().getPgPartitionId().getPipeGalleryId().getPgName() - + pgAlarm.getAlarmDevId().getPgPartitionId().getParName()); + this.setAlarmDevName(pgAlarm.getAlarmDevId().getAssetName()); + this.setAlarmLocation(pgAlarm.getAlarmDevId().getPipeGalleryId().getPgPartitionId().getParName() + + pgAlarm.getAlarmDevId().getPipeGalleryId().getPgName()); this.setUserName(pgAlarm.getPatrolerId().getUserName()); this.setPhoneNumber(pgAlarm.getPatrolerId().getPhoneNumber()); this.setActive(String.valueOf(pgAlarm.getActive())); diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java index ae76e95..49bd436 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java @@ -11,16 +11,20 @@ public class PgDeviceDto implements Serializable { private String id; - private String devType;//设备类型 - private String devCode;//设备编号 - private String devName;//设备名称 - private String brand;//品牌 - private String ownerUnit;//权属单位 - private String installDate;//安装时间 - private String isOpen;//设备开启状态 - private String active;//状态位 private String pipeGallery;//仓位 private String partition;//分区 + private String road;//路名 + private String position;//设备位置 + private String devType;//设备类型 + private String devCode;//设备编号 + private String assetName;//资产名称 + private String assetCode;//资产名称 + private String assetBarCode;//资产条码 + private String ip;//IP地址 + private String modBus;//modBus地址 + private String mome;//备注 + private String isOpen;//设备开启状态 + private String active;//状态位 public String getId() { return id; @@ -30,6 +34,38 @@ this.id = id; } + public String getPartition() { + return partition; + } + + public void setPartition(String partition) { + this.partition = partition; + } + + public String getPipeGallery() { + return pipeGallery; + } + + public void setPipeGallery(String pipeGallery) { + this.pipeGallery = pipeGallery; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getPosition() { + return position; + } + + public void setPosition(String position) { + this.position = position; + } + public String getDevType() { return devType; } @@ -46,36 +82,52 @@ this.devCode = devCode; } - public String getDevName() { - return devName; + public String getAssetName() { + return assetName; } - public void setDevName(String devName) { - this.devName = devName; + public void setAssetName(String assetName) { + this.assetName = assetName; } - public String getBrand() { - return brand; + public String getAssetCode() { + return assetCode; } - public void setBrand(String brand) { - this.brand = brand; + public void setAssetCode(String assetCode) { + this.assetCode = assetCode; } - public String getOwnerUnit() { - return ownerUnit; + public String getAssetBarCode() { + return assetBarCode; } - public void setOwnerUnit(String ownerUnit) { - this.ownerUnit = ownerUnit; + public void setAssetBarCode(String assetBarCode) { + this.assetBarCode = assetBarCode; } - public String getInstallDate() { - return installDate; + public String getIp() { + return ip; } - public void setInstallDate(String installDate) { - this.installDate = installDate; + public void setIp(String ip) { + this.ip = ip; + } + + public String getModBus() { + return modBus; + } + + public void setModBus(String modBus) { + this.modBus = modBus; + } + + public String getMome() { + return mome; + } + + public void setMome(String mome) { + this.mome = mome; } public String getIsOpen() { @@ -94,39 +146,26 @@ this.active = active; } - public String getPipeGallery() { - return pipeGallery; - } - - public void setPipeGallery(String pipeGallery) { - this.pipeGallery = pipeGallery; - } - - public String getPartition() { - return partition; - } - - public void setPartition(String partition) { - this.partition = partition; - } - public PgDeviceDto(PgDevice pgDevice) { SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); this.setId(String.valueOf(pgDevice.getId())); - this.setDevType(pgDevice.getDevTypeId().getDevType()); + this.setPipeGallery(pgDevice.getPipeGalleryId().getPgName()); + this.setPartition(pgDevice.getPipeGalleryId().getPgPartitionId().getParName()); + this.setRoad(pgDevice.getRoad()); + this.setPosition(pgDevice.getPosition()); + this.setDevType(pgDevice.getDevType()); this.setDevCode(pgDevice.getDevCode()); - this.setDevName(pgDevice.getDevName()); - this.setBrand(pgDevice.getBrand()); - this.setOwnerUnit(pgDevice.getOwnerUnit()); - this.setInstallDate(sdf.format(pgDevice.getInstallDate())); + this.setAssetName(pgDevice.getAssetName()); + this.setAssetCode(pgDevice.getAssetCode()); + this.setAssetBarCode(pgDevice.getAssetBarCode()); + this.setId(pgDevice.getIp()); + this.setModBus(pgDevice.getModBus()); + this.setMome(pgDevice.getMome()); this.setIsOpen(String.valueOf(pgDevice.getIsOpen())); this.setActive(String.valueOf(pgDevice.getActive())); - this.setPipeGallery(pgDevice.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgDevice.getPgPartitionId().getParName()); + } - -} - +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java index e8751d3..3acd0fa 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java @@ -11,7 +11,7 @@ private String id; private String parName;//分区名称 - private String pipeGallery;//管廊仓 + private String road;//所属道路 private String active;//状态位 @@ -31,14 +31,6 @@ this.parName = parName; } - public String getPipeGallery() { - return pipeGallery; - } - - public void setPipeGallery(String pipeGallery) { - this.pipeGallery = pipeGallery; - } - public String getActive() { return active; } @@ -47,11 +39,19 @@ this.active = active; } + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + public PgPartitionDto(PgPartition pgPartition) { this.setId(String.valueOf(pgPartition.getId())); this.setParName(pgPartition.getParName()); - this.setPipeGallery(pgPartition.getPipeGalleryId().getPgName()); + this.setRoad(pgPartition.getRoad()); this.setActive(String.valueOf(pgPartition.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java index 80625c7..d8f5e6b 100644 --- a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java +++ b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java @@ -43,9 +43,7 @@ this.intoTime = intoTime; } - @Column(name = "OUT_TIME") - public Date getOutTime() { return outTime; } diff --git a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java index a99981e..b1d63a4 100644 --- a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java +++ b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java @@ -1,11 +1,28 @@ package com.casic.PgInterface.devData.manager; +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.core.util.DateUtils; +import com.casic.PgInterface.core.util.StringUtils; +import com.casic.PgInterface.devData.domain.PgCo; +import com.casic.PgInterface.devData.domain.PgLocation; +import com.casic.PgInterface.devData.dto.PgCoDto; +import com.casic.PgInterface.devData.dto.PgLocationDto; +import com.casic.PgInterface.devTable.domain.PgDevice; +import org.hibernate.Criteria; +import org.hibernate.criterion.Order; +import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; + /** * Created by yxw on 2017/11/2. */ @Service -public class PgLocationManager { +public class PgLocationManager extends HibernateEntityDao { + + //获取设备时间段内所有的监测数据 } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java index cfa0281..7fb5953 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -1,12 +1,12 @@ package com.casic.PgInterface.devTable.domain; import com.casic.PgInterface.devData.domain.*; +import com.casic.PgInterface.patroler.domain.PgAlarmRule; import org.hibernate.annotations.NotFound; import org.hibernate.annotations.NotFoundAction; import javax.persistence.*; import java.io.Serializable; -import java.util.Date; import java.util.List; /** @@ -19,21 +19,27 @@ private static final long serialVersionUID = 1L; private long id; + private PipeGallery pipeGalleryId;//所在管廊信息 + private String road;//路名 + private String position;//设备位置 + private String devType;//设备类型 private String devCode;//设备编号 - private String devName;//设备名称 - private String brand;//品牌 - private String ownerUnit;//权属单位 - private Date installDate;//安装时间 + private String assetName;//资产名称 + private String assetCode;//资产编码 + private String assetBarCode;//资产条码 + private String ip;//IP地址 + private String modBus;//modBus地址 + private String mome;//备注 private int isOpen;//设备是否开启 private int active;//状态位 - private PgDeviceType devTypeId;//设备类型 + private List pgAlarms; - private PgPartition pgPartitionId;//所在管廊信息 private List pgTempHums;//温湿度 private List pgCos;//一氧化碳 private List pgO2s;//氧气 private List pgCh4s;//甲烷 private List pgShs;//硫化氢 + private List pgAlarmRules;//报警规则 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") @@ -45,6 +51,33 @@ this.id = id; } + @Column(name = "ROAD") + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + @Column(name = "POSITION") + public String getPosition() { + return position; + } + + public void setPosition(String position) { + this.position = position; + } + + @Column(name = "DEV_TYPE") + public String getDevType() { + return devType; + } + + public void setDevType(String devType) { + this.devType = devType; + } + @Column(name = "DEV_CODE") public String getDevCode() { return devCode; @@ -54,40 +87,58 @@ this.devCode = devCode; } - @Column(name = "DEV_NAME") - public String getDevName() { - return devName; + @Column(name = "ASSET_NAME") + public String getAssetName() { + return assetName; } - public void setDevName(String devName) { - this.devName = devName; + public void setAssetName(String assetName) { + this.assetName = assetName; } - @Column(name = "BRAND") - public String getBrand() { - return brand; + @Column(name = "ASSET_CODE") + public String getAssetCode() { + return assetCode; } - public void setBrand(String brand) { - this.brand = brand; + public void setAssetCode(String assetCode) { + this.assetCode = assetCode; } - @Column(name = "OWNERUNIT") - public String getOwnerUnit() { - return ownerUnit; + @Column(name = "ASSET_BAR_CODE") + public String getAssetBarCode() { + return assetBarCode; } - public void setOwnerUnit(String ownerUnit) { - this.ownerUnit = ownerUnit; + public void setAssetBarCode(String assetBarCode) { + this.assetBarCode = assetBarCode; } - @Column(name = "INSTALDATE") - public Date getInstallDate() { - return installDate; + @Column(name = "IP") + public String getIp() { + return ip; } - public void setInstallDate(Date installDate) { - this.installDate = installDate; + public void setIp(String ip) { + this.ip = ip; + } + + @Column(name = "MODBUS") + public String getModBus() { + return modBus; + } + + public void setModBus(String modBus) { + this.modBus = modBus; + } + + @Column(name = "MOME") + public String getMome() { + return mome; + } + + public void setMome(String mome) { + this.mome = mome; } @Column(name = "ISOPEN") @@ -119,24 +170,13 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; - } - - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "DEVICE_TYPE_ID") - public PgDeviceType getDevTypeId() { - return devTypeId; - } - - public void setDevTypeId(PgDeviceType devTypeId) { - this.devTypeId = devTypeId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgDeviceId") @@ -184,4 +224,13 @@ this.pgShs = pgShs; } + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgDeviceId") + public List getPgAlarmRules() { + return pgAlarmRules; + } + + public void setPgAlarmRules(List pgAlarmRules) { + this.pgAlarmRules = pgAlarmRules; + } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java index b997b29..4fb3d6f 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java @@ -1,8 +1,5 @@ package com.casic.PgInterface.devTable.domain; -import org.hibernate.annotations.NotFound; -import org.hibernate.annotations.NotFoundAction; - import javax.persistence.*; import java.io.Serializable; import java.util.List; @@ -19,11 +16,9 @@ private long id; private String parName;//分区名称 - private PipeGallery pipeGalleryId;//管廊仓 + private String road;//所属道路 private int active;//状态位 - private List pgTextureList; - private List pgPipeLineList; - private List pgDeviceList; + private List pipeGalleryList;//管廊仓 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PARTITION_ID") @@ -44,6 +39,15 @@ this.parName = parName; } + @Column(name = "ROAD") + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + @Column(name = "ACTIVE") public int getActive() { return active; @@ -53,41 +57,14 @@ this.active = active; } - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PIPEGALLERYID") - public PipeGallery getPipeGalleryId() { - return pipeGalleryId; - } - - public void setPipeGalleryId(PipeGallery pipeGalleryId) { - this.pipeGalleryId = pipeGalleryId; - } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgTextureList() { - return pgTextureList; + public List getPipeGalleryList() { + return pipeGalleryList; } - public void setPgTextureList(List pgTextureList) { - this.pgTextureList = pgTextureList; + public void setPipeGalleryList(List pipeGalleryList) { + this.pipeGalleryList = pipeGalleryList; } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgPipeLineList() { - return pgPipeLineList; - } - public void setPgPipeLineList(List pgPipeLineList) { - this.pgPipeLineList = pgPipeLineList; - } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgDeviceList() { - return pgDeviceList; - } - - public void setPgDeviceList(List pgDeviceList) { - this.pgDeviceList = pgDeviceList; - } } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java index d936d18..e5ff9b3 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java @@ -22,7 +22,7 @@ private Date enterDate;//入廊时间 private String layerNum;//所在层数 private String diameter;//管径 - private PgPartition pgPartitionId;//所在管廊信息 + private PipeGallery pipeGalleryId;//所在管廊信息 private int active;//状态位 @Id @@ -100,12 +100,12 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java index 1f22bf9..4ebfbda 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java @@ -21,7 +21,7 @@ private String ownerUnit;//权属单位 private Date buildDate;//建设年代 private int active;//状态位 - private PgPartition pgPartitionId;//所在管廊信息 + private PipeGallery pipeGalleryId;//所在管廊信息 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_TEXTURE_ID") @@ -91,12 +91,13 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java b/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java index 49a246c..650d623 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java @@ -1,5 +1,8 @@ package com.casic.PgInterface.devTable.domain; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + import javax.persistence.*; import java.io.Serializable; import java.util.List; @@ -16,7 +19,10 @@ private long id; private String pgName;//管廊名称 private int active;//状态位 - private List partitionList; + private PgPartition pgPartitionId;// + private List pgTextureList; + private List pgPipeLineList; + private List pgDeviceList; @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PIPE_GALLERY_ID") @@ -46,12 +52,42 @@ this.active = active; } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") - public List getPartitionList() { - return partitionList; + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "PARTITIONID") + public PgPartition getPgPartitionId() { + return pgPartitionId; } - public void setPartitionList(List partitionList) { - this.partitionList = partitionList; + public void setPgPartitionId(PgPartition pgPartitionId) { + this.pgPartitionId = pgPartitionId; } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgTextureList() { + return pgTextureList; + } + + public void setPgTextureList(List pgTextureList) { + this.pgTextureList = pgTextureList; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgPipeLineList() { + return pgPipeLineList; + } + + public void setPgPipeLineList(List pgPipeLineList) { + this.pgPipeLineList = pgPipeLineList; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgDeviceList() { + return pgDeviceList; + } + + public void setPgDeviceList(List pgDeviceList) { + this.pgDeviceList = pgDeviceList; + } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java index b4048d9..c3dfc55 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java @@ -101,18 +101,17 @@ this.active = active; } - public PgAlarmDto(PgAlarm pgAlarm) - { - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + public PgAlarmDto(PgAlarm pgAlarm) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); this.setId(String.valueOf(pgAlarm.getId())); this.setAlarmType(pgAlarm.getAlarmTypeId().getAlarmType()); this.setAlarmValue(pgAlarm.getAlarmValue()); this.setAlarmDate(sdf.format(pgAlarm.getAlarmDate())); this.setDescription(pgAlarm.getDescription()); - this.setAlarmDevName(pgAlarm.getAlarmDevId().getDevName()); - this.setAlarmLocation(pgAlarm.getAlarmDevId().getPgPartitionId().getPipeGalleryId().getPgName() - + pgAlarm.getAlarmDevId().getPgPartitionId().getParName()); + this.setAlarmDevName(pgAlarm.getAlarmDevId().getAssetName()); + this.setAlarmLocation(pgAlarm.getAlarmDevId().getPipeGalleryId().getPgPartitionId().getParName() + + pgAlarm.getAlarmDevId().getPipeGalleryId().getPgName()); this.setUserName(pgAlarm.getPatrolerId().getUserName()); this.setPhoneNumber(pgAlarm.getPatrolerId().getPhoneNumber()); this.setActive(String.valueOf(pgAlarm.getActive())); diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java index ae76e95..49bd436 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java @@ -11,16 +11,20 @@ public class PgDeviceDto implements Serializable { private String id; - private String devType;//设备类型 - private String devCode;//设备编号 - private String devName;//设备名称 - private String brand;//品牌 - private String ownerUnit;//权属单位 - private String installDate;//安装时间 - private String isOpen;//设备开启状态 - private String active;//状态位 private String pipeGallery;//仓位 private String partition;//分区 + private String road;//路名 + private String position;//设备位置 + private String devType;//设备类型 + private String devCode;//设备编号 + private String assetName;//资产名称 + private String assetCode;//资产名称 + private String assetBarCode;//资产条码 + private String ip;//IP地址 + private String modBus;//modBus地址 + private String mome;//备注 + private String isOpen;//设备开启状态 + private String active;//状态位 public String getId() { return id; @@ -30,6 +34,38 @@ this.id = id; } + public String getPartition() { + return partition; + } + + public void setPartition(String partition) { + this.partition = partition; + } + + public String getPipeGallery() { + return pipeGallery; + } + + public void setPipeGallery(String pipeGallery) { + this.pipeGallery = pipeGallery; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getPosition() { + return position; + } + + public void setPosition(String position) { + this.position = position; + } + public String getDevType() { return devType; } @@ -46,36 +82,52 @@ this.devCode = devCode; } - public String getDevName() { - return devName; + public String getAssetName() { + return assetName; } - public void setDevName(String devName) { - this.devName = devName; + public void setAssetName(String assetName) { + this.assetName = assetName; } - public String getBrand() { - return brand; + public String getAssetCode() { + return assetCode; } - public void setBrand(String brand) { - this.brand = brand; + public void setAssetCode(String assetCode) { + this.assetCode = assetCode; } - public String getOwnerUnit() { - return ownerUnit; + public String getAssetBarCode() { + return assetBarCode; } - public void setOwnerUnit(String ownerUnit) { - this.ownerUnit = ownerUnit; + public void setAssetBarCode(String assetBarCode) { + this.assetBarCode = assetBarCode; } - public String getInstallDate() { - return installDate; + public String getIp() { + return ip; } - public void setInstallDate(String installDate) { - this.installDate = installDate; + public void setIp(String ip) { + this.ip = ip; + } + + public String getModBus() { + return modBus; + } + + public void setModBus(String modBus) { + this.modBus = modBus; + } + + public String getMome() { + return mome; + } + + public void setMome(String mome) { + this.mome = mome; } public String getIsOpen() { @@ -94,39 +146,26 @@ this.active = active; } - public String getPipeGallery() { - return pipeGallery; - } - - public void setPipeGallery(String pipeGallery) { - this.pipeGallery = pipeGallery; - } - - public String getPartition() { - return partition; - } - - public void setPartition(String partition) { - this.partition = partition; - } - public PgDeviceDto(PgDevice pgDevice) { SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); this.setId(String.valueOf(pgDevice.getId())); - this.setDevType(pgDevice.getDevTypeId().getDevType()); + this.setPipeGallery(pgDevice.getPipeGalleryId().getPgName()); + this.setPartition(pgDevice.getPipeGalleryId().getPgPartitionId().getParName()); + this.setRoad(pgDevice.getRoad()); + this.setPosition(pgDevice.getPosition()); + this.setDevType(pgDevice.getDevType()); this.setDevCode(pgDevice.getDevCode()); - this.setDevName(pgDevice.getDevName()); - this.setBrand(pgDevice.getBrand()); - this.setOwnerUnit(pgDevice.getOwnerUnit()); - this.setInstallDate(sdf.format(pgDevice.getInstallDate())); + this.setAssetName(pgDevice.getAssetName()); + this.setAssetCode(pgDevice.getAssetCode()); + this.setAssetBarCode(pgDevice.getAssetBarCode()); + this.setId(pgDevice.getIp()); + this.setModBus(pgDevice.getModBus()); + this.setMome(pgDevice.getMome()); this.setIsOpen(String.valueOf(pgDevice.getIsOpen())); this.setActive(String.valueOf(pgDevice.getActive())); - this.setPipeGallery(pgDevice.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgDevice.getPgPartitionId().getParName()); + } - -} - +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java index e8751d3..3acd0fa 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java @@ -11,7 +11,7 @@ private String id; private String parName;//分区名称 - private String pipeGallery;//管廊仓 + private String road;//所属道路 private String active;//状态位 @@ -31,14 +31,6 @@ this.parName = parName; } - public String getPipeGallery() { - return pipeGallery; - } - - public void setPipeGallery(String pipeGallery) { - this.pipeGallery = pipeGallery; - } - public String getActive() { return active; } @@ -47,11 +39,19 @@ this.active = active; } + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + public PgPartitionDto(PgPartition pgPartition) { this.setId(String.valueOf(pgPartition.getId())); this.setParName(pgPartition.getParName()); - this.setPipeGallery(pgPartition.getPipeGalleryId().getPgName()); + this.setRoad(pgPartition.getRoad()); this.setActive(String.valueOf(pgPartition.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java index 9b161bf..8b430dc 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java @@ -112,8 +112,8 @@ this.setEnterDate(sdf.format(pgPipeLine.getEnterDate())); this.setLayerNum(pgPipeLine.getLayerNum()); this.setDiameter(pgPipeLine.getDiameter()); - this.setPipeGallery(pgPipeLine.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgPipeLine.getPgPartitionId().getParName()); + this.setPipeGallery(pgPipeLine.getPipeGalleryId().getPgName()); + this.setPartition(pgPipeLine.getPipeGalleryId().getPgPartitionId().getParName()); this.setActive(String.valueOf(pgPipeLine.getActive())); } } diff --git a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java index 80625c7..d8f5e6b 100644 --- a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java +++ b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java @@ -43,9 +43,7 @@ this.intoTime = intoTime; } - @Column(name = "OUT_TIME") - public Date getOutTime() { return outTime; } diff --git a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java index a99981e..b1d63a4 100644 --- a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java +++ b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java @@ -1,11 +1,28 @@ package com.casic.PgInterface.devData.manager; +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.core.util.DateUtils; +import com.casic.PgInterface.core.util.StringUtils; +import com.casic.PgInterface.devData.domain.PgCo; +import com.casic.PgInterface.devData.domain.PgLocation; +import com.casic.PgInterface.devData.dto.PgCoDto; +import com.casic.PgInterface.devData.dto.PgLocationDto; +import com.casic.PgInterface.devTable.domain.PgDevice; +import org.hibernate.Criteria; +import org.hibernate.criterion.Order; +import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; + /** * Created by yxw on 2017/11/2. */ @Service -public class PgLocationManager { +public class PgLocationManager extends HibernateEntityDao { + + //获取设备时间段内所有的监测数据 } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java index cfa0281..7fb5953 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -1,12 +1,12 @@ package com.casic.PgInterface.devTable.domain; import com.casic.PgInterface.devData.domain.*; +import com.casic.PgInterface.patroler.domain.PgAlarmRule; import org.hibernate.annotations.NotFound; import org.hibernate.annotations.NotFoundAction; import javax.persistence.*; import java.io.Serializable; -import java.util.Date; import java.util.List; /** @@ -19,21 +19,27 @@ private static final long serialVersionUID = 1L; private long id; + private PipeGallery pipeGalleryId;//所在管廊信息 + private String road;//路名 + private String position;//设备位置 + private String devType;//设备类型 private String devCode;//设备编号 - private String devName;//设备名称 - private String brand;//品牌 - private String ownerUnit;//权属单位 - private Date installDate;//安装时间 + private String assetName;//资产名称 + private String assetCode;//资产编码 + private String assetBarCode;//资产条码 + private String ip;//IP地址 + private String modBus;//modBus地址 + private String mome;//备注 private int isOpen;//设备是否开启 private int active;//状态位 - private PgDeviceType devTypeId;//设备类型 + private List pgAlarms; - private PgPartition pgPartitionId;//所在管廊信息 private List pgTempHums;//温湿度 private List pgCos;//一氧化碳 private List pgO2s;//氧气 private List pgCh4s;//甲烷 private List pgShs;//硫化氢 + private List pgAlarmRules;//报警规则 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") @@ -45,6 +51,33 @@ this.id = id; } + @Column(name = "ROAD") + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + @Column(name = "POSITION") + public String getPosition() { + return position; + } + + public void setPosition(String position) { + this.position = position; + } + + @Column(name = "DEV_TYPE") + public String getDevType() { + return devType; + } + + public void setDevType(String devType) { + this.devType = devType; + } + @Column(name = "DEV_CODE") public String getDevCode() { return devCode; @@ -54,40 +87,58 @@ this.devCode = devCode; } - @Column(name = "DEV_NAME") - public String getDevName() { - return devName; + @Column(name = "ASSET_NAME") + public String getAssetName() { + return assetName; } - public void setDevName(String devName) { - this.devName = devName; + public void setAssetName(String assetName) { + this.assetName = assetName; } - @Column(name = "BRAND") - public String getBrand() { - return brand; + @Column(name = "ASSET_CODE") + public String getAssetCode() { + return assetCode; } - public void setBrand(String brand) { - this.brand = brand; + public void setAssetCode(String assetCode) { + this.assetCode = assetCode; } - @Column(name = "OWNERUNIT") - public String getOwnerUnit() { - return ownerUnit; + @Column(name = "ASSET_BAR_CODE") + public String getAssetBarCode() { + return assetBarCode; } - public void setOwnerUnit(String ownerUnit) { - this.ownerUnit = ownerUnit; + public void setAssetBarCode(String assetBarCode) { + this.assetBarCode = assetBarCode; } - @Column(name = "INSTALDATE") - public Date getInstallDate() { - return installDate; + @Column(name = "IP") + public String getIp() { + return ip; } - public void setInstallDate(Date installDate) { - this.installDate = installDate; + public void setIp(String ip) { + this.ip = ip; + } + + @Column(name = "MODBUS") + public String getModBus() { + return modBus; + } + + public void setModBus(String modBus) { + this.modBus = modBus; + } + + @Column(name = "MOME") + public String getMome() { + return mome; + } + + public void setMome(String mome) { + this.mome = mome; } @Column(name = "ISOPEN") @@ -119,24 +170,13 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; - } - - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "DEVICE_TYPE_ID") - public PgDeviceType getDevTypeId() { - return devTypeId; - } - - public void setDevTypeId(PgDeviceType devTypeId) { - this.devTypeId = devTypeId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgDeviceId") @@ -184,4 +224,13 @@ this.pgShs = pgShs; } + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgDeviceId") + public List getPgAlarmRules() { + return pgAlarmRules; + } + + public void setPgAlarmRules(List pgAlarmRules) { + this.pgAlarmRules = pgAlarmRules; + } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java index b997b29..4fb3d6f 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java @@ -1,8 +1,5 @@ package com.casic.PgInterface.devTable.domain; -import org.hibernate.annotations.NotFound; -import org.hibernate.annotations.NotFoundAction; - import javax.persistence.*; import java.io.Serializable; import java.util.List; @@ -19,11 +16,9 @@ private long id; private String parName;//分区名称 - private PipeGallery pipeGalleryId;//管廊仓 + private String road;//所属道路 private int active;//状态位 - private List pgTextureList; - private List pgPipeLineList; - private List pgDeviceList; + private List pipeGalleryList;//管廊仓 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PARTITION_ID") @@ -44,6 +39,15 @@ this.parName = parName; } + @Column(name = "ROAD") + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + @Column(name = "ACTIVE") public int getActive() { return active; @@ -53,41 +57,14 @@ this.active = active; } - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PIPEGALLERYID") - public PipeGallery getPipeGalleryId() { - return pipeGalleryId; - } - - public void setPipeGalleryId(PipeGallery pipeGalleryId) { - this.pipeGalleryId = pipeGalleryId; - } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgTextureList() { - return pgTextureList; + public List getPipeGalleryList() { + return pipeGalleryList; } - public void setPgTextureList(List pgTextureList) { - this.pgTextureList = pgTextureList; + public void setPipeGalleryList(List pipeGalleryList) { + this.pipeGalleryList = pipeGalleryList; } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgPipeLineList() { - return pgPipeLineList; - } - public void setPgPipeLineList(List pgPipeLineList) { - this.pgPipeLineList = pgPipeLineList; - } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgDeviceList() { - return pgDeviceList; - } - - public void setPgDeviceList(List pgDeviceList) { - this.pgDeviceList = pgDeviceList; - } } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java index d936d18..e5ff9b3 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java @@ -22,7 +22,7 @@ private Date enterDate;//入廊时间 private String layerNum;//所在层数 private String diameter;//管径 - private PgPartition pgPartitionId;//所在管廊信息 + private PipeGallery pipeGalleryId;//所在管廊信息 private int active;//状态位 @Id @@ -100,12 +100,12 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java index 1f22bf9..4ebfbda 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java @@ -21,7 +21,7 @@ private String ownerUnit;//权属单位 private Date buildDate;//建设年代 private int active;//状态位 - private PgPartition pgPartitionId;//所在管廊信息 + private PipeGallery pipeGalleryId;//所在管廊信息 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_TEXTURE_ID") @@ -91,12 +91,13 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java b/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java index 49a246c..650d623 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java @@ -1,5 +1,8 @@ package com.casic.PgInterface.devTable.domain; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + import javax.persistence.*; import java.io.Serializable; import java.util.List; @@ -16,7 +19,10 @@ private long id; private String pgName;//管廊名称 private int active;//状态位 - private List partitionList; + private PgPartition pgPartitionId;// + private List pgTextureList; + private List pgPipeLineList; + private List pgDeviceList; @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PIPE_GALLERY_ID") @@ -46,12 +52,42 @@ this.active = active; } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") - public List getPartitionList() { - return partitionList; + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "PARTITIONID") + public PgPartition getPgPartitionId() { + return pgPartitionId; } - public void setPartitionList(List partitionList) { - this.partitionList = partitionList; + public void setPgPartitionId(PgPartition pgPartitionId) { + this.pgPartitionId = pgPartitionId; } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgTextureList() { + return pgTextureList; + } + + public void setPgTextureList(List pgTextureList) { + this.pgTextureList = pgTextureList; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgPipeLineList() { + return pgPipeLineList; + } + + public void setPgPipeLineList(List pgPipeLineList) { + this.pgPipeLineList = pgPipeLineList; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgDeviceList() { + return pgDeviceList; + } + + public void setPgDeviceList(List pgDeviceList) { + this.pgDeviceList = pgDeviceList; + } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java index b4048d9..c3dfc55 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java @@ -101,18 +101,17 @@ this.active = active; } - public PgAlarmDto(PgAlarm pgAlarm) - { - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + public PgAlarmDto(PgAlarm pgAlarm) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); this.setId(String.valueOf(pgAlarm.getId())); this.setAlarmType(pgAlarm.getAlarmTypeId().getAlarmType()); this.setAlarmValue(pgAlarm.getAlarmValue()); this.setAlarmDate(sdf.format(pgAlarm.getAlarmDate())); this.setDescription(pgAlarm.getDescription()); - this.setAlarmDevName(pgAlarm.getAlarmDevId().getDevName()); - this.setAlarmLocation(pgAlarm.getAlarmDevId().getPgPartitionId().getPipeGalleryId().getPgName() - + pgAlarm.getAlarmDevId().getPgPartitionId().getParName()); + this.setAlarmDevName(pgAlarm.getAlarmDevId().getAssetName()); + this.setAlarmLocation(pgAlarm.getAlarmDevId().getPipeGalleryId().getPgPartitionId().getParName() + + pgAlarm.getAlarmDevId().getPipeGalleryId().getPgName()); this.setUserName(pgAlarm.getPatrolerId().getUserName()); this.setPhoneNumber(pgAlarm.getPatrolerId().getPhoneNumber()); this.setActive(String.valueOf(pgAlarm.getActive())); diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java index ae76e95..49bd436 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java @@ -11,16 +11,20 @@ public class PgDeviceDto implements Serializable { private String id; - private String devType;//设备类型 - private String devCode;//设备编号 - private String devName;//设备名称 - private String brand;//品牌 - private String ownerUnit;//权属单位 - private String installDate;//安装时间 - private String isOpen;//设备开启状态 - private String active;//状态位 private String pipeGallery;//仓位 private String partition;//分区 + private String road;//路名 + private String position;//设备位置 + private String devType;//设备类型 + private String devCode;//设备编号 + private String assetName;//资产名称 + private String assetCode;//资产名称 + private String assetBarCode;//资产条码 + private String ip;//IP地址 + private String modBus;//modBus地址 + private String mome;//备注 + private String isOpen;//设备开启状态 + private String active;//状态位 public String getId() { return id; @@ -30,6 +34,38 @@ this.id = id; } + public String getPartition() { + return partition; + } + + public void setPartition(String partition) { + this.partition = partition; + } + + public String getPipeGallery() { + return pipeGallery; + } + + public void setPipeGallery(String pipeGallery) { + this.pipeGallery = pipeGallery; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getPosition() { + return position; + } + + public void setPosition(String position) { + this.position = position; + } + public String getDevType() { return devType; } @@ -46,36 +82,52 @@ this.devCode = devCode; } - public String getDevName() { - return devName; + public String getAssetName() { + return assetName; } - public void setDevName(String devName) { - this.devName = devName; + public void setAssetName(String assetName) { + this.assetName = assetName; } - public String getBrand() { - return brand; + public String getAssetCode() { + return assetCode; } - public void setBrand(String brand) { - this.brand = brand; + public void setAssetCode(String assetCode) { + this.assetCode = assetCode; } - public String getOwnerUnit() { - return ownerUnit; + public String getAssetBarCode() { + return assetBarCode; } - public void setOwnerUnit(String ownerUnit) { - this.ownerUnit = ownerUnit; + public void setAssetBarCode(String assetBarCode) { + this.assetBarCode = assetBarCode; } - public String getInstallDate() { - return installDate; + public String getIp() { + return ip; } - public void setInstallDate(String installDate) { - this.installDate = installDate; + public void setIp(String ip) { + this.ip = ip; + } + + public String getModBus() { + return modBus; + } + + public void setModBus(String modBus) { + this.modBus = modBus; + } + + public String getMome() { + return mome; + } + + public void setMome(String mome) { + this.mome = mome; } public String getIsOpen() { @@ -94,39 +146,26 @@ this.active = active; } - public String getPipeGallery() { - return pipeGallery; - } - - public void setPipeGallery(String pipeGallery) { - this.pipeGallery = pipeGallery; - } - - public String getPartition() { - return partition; - } - - public void setPartition(String partition) { - this.partition = partition; - } - public PgDeviceDto(PgDevice pgDevice) { SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); this.setId(String.valueOf(pgDevice.getId())); - this.setDevType(pgDevice.getDevTypeId().getDevType()); + this.setPipeGallery(pgDevice.getPipeGalleryId().getPgName()); + this.setPartition(pgDevice.getPipeGalleryId().getPgPartitionId().getParName()); + this.setRoad(pgDevice.getRoad()); + this.setPosition(pgDevice.getPosition()); + this.setDevType(pgDevice.getDevType()); this.setDevCode(pgDevice.getDevCode()); - this.setDevName(pgDevice.getDevName()); - this.setBrand(pgDevice.getBrand()); - this.setOwnerUnit(pgDevice.getOwnerUnit()); - this.setInstallDate(sdf.format(pgDevice.getInstallDate())); + this.setAssetName(pgDevice.getAssetName()); + this.setAssetCode(pgDevice.getAssetCode()); + this.setAssetBarCode(pgDevice.getAssetBarCode()); + this.setId(pgDevice.getIp()); + this.setModBus(pgDevice.getModBus()); + this.setMome(pgDevice.getMome()); this.setIsOpen(String.valueOf(pgDevice.getIsOpen())); this.setActive(String.valueOf(pgDevice.getActive())); - this.setPipeGallery(pgDevice.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgDevice.getPgPartitionId().getParName()); + } - -} - +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java index e8751d3..3acd0fa 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java @@ -11,7 +11,7 @@ private String id; private String parName;//分区名称 - private String pipeGallery;//管廊仓 + private String road;//所属道路 private String active;//状态位 @@ -31,14 +31,6 @@ this.parName = parName; } - public String getPipeGallery() { - return pipeGallery; - } - - public void setPipeGallery(String pipeGallery) { - this.pipeGallery = pipeGallery; - } - public String getActive() { return active; } @@ -47,11 +39,19 @@ this.active = active; } + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + public PgPartitionDto(PgPartition pgPartition) { this.setId(String.valueOf(pgPartition.getId())); this.setParName(pgPartition.getParName()); - this.setPipeGallery(pgPartition.getPipeGalleryId().getPgName()); + this.setRoad(pgPartition.getRoad()); this.setActive(String.valueOf(pgPartition.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java index 9b161bf..8b430dc 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java @@ -112,8 +112,8 @@ this.setEnterDate(sdf.format(pgPipeLine.getEnterDate())); this.setLayerNum(pgPipeLine.getLayerNum()); this.setDiameter(pgPipeLine.getDiameter()); - this.setPipeGallery(pgPipeLine.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgPipeLine.getPgPartitionId().getParName()); + this.setPipeGallery(pgPipeLine.getPipeGalleryId().getPgName()); + this.setPartition(pgPipeLine.getPipeGalleryId().getPgPartitionId().getParName()); this.setActive(String.valueOf(pgPipeLine.getActive())); } } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java index 03c580c..709dcea 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java @@ -103,8 +103,8 @@ this.setOwnerUnit(pgTexture.getOwnerUnit()); this.setBuildDate(sdf.format(pgTexture.getBuildDate())); this.setActive(String.valueOf(pgTexture.getActive())); - this.setPipeGallery(pgTexture.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgTexture.getPgPartitionId().getParName()); + this.setPipeGallery(pgTexture.getPipeGalleryId().getPgName()); + this.setPartition(pgTexture.getPipeGalleryId().getPgPartitionId().getParName()); } } diff --git a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java index 80625c7..d8f5e6b 100644 --- a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java +++ b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java @@ -43,9 +43,7 @@ this.intoTime = intoTime; } - @Column(name = "OUT_TIME") - public Date getOutTime() { return outTime; } diff --git a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java index a99981e..b1d63a4 100644 --- a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java +++ b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java @@ -1,11 +1,28 @@ package com.casic.PgInterface.devData.manager; +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.core.util.DateUtils; +import com.casic.PgInterface.core.util.StringUtils; +import com.casic.PgInterface.devData.domain.PgCo; +import com.casic.PgInterface.devData.domain.PgLocation; +import com.casic.PgInterface.devData.dto.PgCoDto; +import com.casic.PgInterface.devData.dto.PgLocationDto; +import com.casic.PgInterface.devTable.domain.PgDevice; +import org.hibernate.Criteria; +import org.hibernate.criterion.Order; +import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; + /** * Created by yxw on 2017/11/2. */ @Service -public class PgLocationManager { +public class PgLocationManager extends HibernateEntityDao { + + //获取设备时间段内所有的监测数据 } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java index cfa0281..7fb5953 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -1,12 +1,12 @@ package com.casic.PgInterface.devTable.domain; import com.casic.PgInterface.devData.domain.*; +import com.casic.PgInterface.patroler.domain.PgAlarmRule; import org.hibernate.annotations.NotFound; import org.hibernate.annotations.NotFoundAction; import javax.persistence.*; import java.io.Serializable; -import java.util.Date; import java.util.List; /** @@ -19,21 +19,27 @@ private static final long serialVersionUID = 1L; private long id; + private PipeGallery pipeGalleryId;//所在管廊信息 + private String road;//路名 + private String position;//设备位置 + private String devType;//设备类型 private String devCode;//设备编号 - private String devName;//设备名称 - private String brand;//品牌 - private String ownerUnit;//权属单位 - private Date installDate;//安装时间 + private String assetName;//资产名称 + private String assetCode;//资产编码 + private String assetBarCode;//资产条码 + private String ip;//IP地址 + private String modBus;//modBus地址 + private String mome;//备注 private int isOpen;//设备是否开启 private int active;//状态位 - private PgDeviceType devTypeId;//设备类型 + private List pgAlarms; - private PgPartition pgPartitionId;//所在管廊信息 private List pgTempHums;//温湿度 private List pgCos;//一氧化碳 private List pgO2s;//氧气 private List pgCh4s;//甲烷 private List pgShs;//硫化氢 + private List pgAlarmRules;//报警规则 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") @@ -45,6 +51,33 @@ this.id = id; } + @Column(name = "ROAD") + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + @Column(name = "POSITION") + public String getPosition() { + return position; + } + + public void setPosition(String position) { + this.position = position; + } + + @Column(name = "DEV_TYPE") + public String getDevType() { + return devType; + } + + public void setDevType(String devType) { + this.devType = devType; + } + @Column(name = "DEV_CODE") public String getDevCode() { return devCode; @@ -54,40 +87,58 @@ this.devCode = devCode; } - @Column(name = "DEV_NAME") - public String getDevName() { - return devName; + @Column(name = "ASSET_NAME") + public String getAssetName() { + return assetName; } - public void setDevName(String devName) { - this.devName = devName; + public void setAssetName(String assetName) { + this.assetName = assetName; } - @Column(name = "BRAND") - public String getBrand() { - return brand; + @Column(name = "ASSET_CODE") + public String getAssetCode() { + return assetCode; } - public void setBrand(String brand) { - this.brand = brand; + public void setAssetCode(String assetCode) { + this.assetCode = assetCode; } - @Column(name = "OWNERUNIT") - public String getOwnerUnit() { - return ownerUnit; + @Column(name = "ASSET_BAR_CODE") + public String getAssetBarCode() { + return assetBarCode; } - public void setOwnerUnit(String ownerUnit) { - this.ownerUnit = ownerUnit; + public void setAssetBarCode(String assetBarCode) { + this.assetBarCode = assetBarCode; } - @Column(name = "INSTALDATE") - public Date getInstallDate() { - return installDate; + @Column(name = "IP") + public String getIp() { + return ip; } - public void setInstallDate(Date installDate) { - this.installDate = installDate; + public void setIp(String ip) { + this.ip = ip; + } + + @Column(name = "MODBUS") + public String getModBus() { + return modBus; + } + + public void setModBus(String modBus) { + this.modBus = modBus; + } + + @Column(name = "MOME") + public String getMome() { + return mome; + } + + public void setMome(String mome) { + this.mome = mome; } @Column(name = "ISOPEN") @@ -119,24 +170,13 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; - } - - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "DEVICE_TYPE_ID") - public PgDeviceType getDevTypeId() { - return devTypeId; - } - - public void setDevTypeId(PgDeviceType devTypeId) { - this.devTypeId = devTypeId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgDeviceId") @@ -184,4 +224,13 @@ this.pgShs = pgShs; } + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgDeviceId") + public List getPgAlarmRules() { + return pgAlarmRules; + } + + public void setPgAlarmRules(List pgAlarmRules) { + this.pgAlarmRules = pgAlarmRules; + } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java index b997b29..4fb3d6f 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java @@ -1,8 +1,5 @@ package com.casic.PgInterface.devTable.domain; -import org.hibernate.annotations.NotFound; -import org.hibernate.annotations.NotFoundAction; - import javax.persistence.*; import java.io.Serializable; import java.util.List; @@ -19,11 +16,9 @@ private long id; private String parName;//分区名称 - private PipeGallery pipeGalleryId;//管廊仓 + private String road;//所属道路 private int active;//状态位 - private List pgTextureList; - private List pgPipeLineList; - private List pgDeviceList; + private List pipeGalleryList;//管廊仓 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PARTITION_ID") @@ -44,6 +39,15 @@ this.parName = parName; } + @Column(name = "ROAD") + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + @Column(name = "ACTIVE") public int getActive() { return active; @@ -53,41 +57,14 @@ this.active = active; } - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PIPEGALLERYID") - public PipeGallery getPipeGalleryId() { - return pipeGalleryId; - } - - public void setPipeGalleryId(PipeGallery pipeGalleryId) { - this.pipeGalleryId = pipeGalleryId; - } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgTextureList() { - return pgTextureList; + public List getPipeGalleryList() { + return pipeGalleryList; } - public void setPgTextureList(List pgTextureList) { - this.pgTextureList = pgTextureList; + public void setPipeGalleryList(List pipeGalleryList) { + this.pipeGalleryList = pipeGalleryList; } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgPipeLineList() { - return pgPipeLineList; - } - public void setPgPipeLineList(List pgPipeLineList) { - this.pgPipeLineList = pgPipeLineList; - } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgDeviceList() { - return pgDeviceList; - } - - public void setPgDeviceList(List pgDeviceList) { - this.pgDeviceList = pgDeviceList; - } } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java index d936d18..e5ff9b3 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java @@ -22,7 +22,7 @@ private Date enterDate;//入廊时间 private String layerNum;//所在层数 private String diameter;//管径 - private PgPartition pgPartitionId;//所在管廊信息 + private PipeGallery pipeGalleryId;//所在管廊信息 private int active;//状态位 @Id @@ -100,12 +100,12 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java index 1f22bf9..4ebfbda 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java @@ -21,7 +21,7 @@ private String ownerUnit;//权属单位 private Date buildDate;//建设年代 private int active;//状态位 - private PgPartition pgPartitionId;//所在管廊信息 + private PipeGallery pipeGalleryId;//所在管廊信息 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_TEXTURE_ID") @@ -91,12 +91,13 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java b/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java index 49a246c..650d623 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java @@ -1,5 +1,8 @@ package com.casic.PgInterface.devTable.domain; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + import javax.persistence.*; import java.io.Serializable; import java.util.List; @@ -16,7 +19,10 @@ private long id; private String pgName;//管廊名称 private int active;//状态位 - private List partitionList; + private PgPartition pgPartitionId;// + private List pgTextureList; + private List pgPipeLineList; + private List pgDeviceList; @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PIPE_GALLERY_ID") @@ -46,12 +52,42 @@ this.active = active; } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") - public List getPartitionList() { - return partitionList; + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "PARTITIONID") + public PgPartition getPgPartitionId() { + return pgPartitionId; } - public void setPartitionList(List partitionList) { - this.partitionList = partitionList; + public void setPgPartitionId(PgPartition pgPartitionId) { + this.pgPartitionId = pgPartitionId; } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgTextureList() { + return pgTextureList; + } + + public void setPgTextureList(List pgTextureList) { + this.pgTextureList = pgTextureList; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgPipeLineList() { + return pgPipeLineList; + } + + public void setPgPipeLineList(List pgPipeLineList) { + this.pgPipeLineList = pgPipeLineList; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgDeviceList() { + return pgDeviceList; + } + + public void setPgDeviceList(List pgDeviceList) { + this.pgDeviceList = pgDeviceList; + } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java index b4048d9..c3dfc55 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java @@ -101,18 +101,17 @@ this.active = active; } - public PgAlarmDto(PgAlarm pgAlarm) - { - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + public PgAlarmDto(PgAlarm pgAlarm) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); this.setId(String.valueOf(pgAlarm.getId())); this.setAlarmType(pgAlarm.getAlarmTypeId().getAlarmType()); this.setAlarmValue(pgAlarm.getAlarmValue()); this.setAlarmDate(sdf.format(pgAlarm.getAlarmDate())); this.setDescription(pgAlarm.getDescription()); - this.setAlarmDevName(pgAlarm.getAlarmDevId().getDevName()); - this.setAlarmLocation(pgAlarm.getAlarmDevId().getPgPartitionId().getPipeGalleryId().getPgName() - + pgAlarm.getAlarmDevId().getPgPartitionId().getParName()); + this.setAlarmDevName(pgAlarm.getAlarmDevId().getAssetName()); + this.setAlarmLocation(pgAlarm.getAlarmDevId().getPipeGalleryId().getPgPartitionId().getParName() + + pgAlarm.getAlarmDevId().getPipeGalleryId().getPgName()); this.setUserName(pgAlarm.getPatrolerId().getUserName()); this.setPhoneNumber(pgAlarm.getPatrolerId().getPhoneNumber()); this.setActive(String.valueOf(pgAlarm.getActive())); diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java index ae76e95..49bd436 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java @@ -11,16 +11,20 @@ public class PgDeviceDto implements Serializable { private String id; - private String devType;//设备类型 - private String devCode;//设备编号 - private String devName;//设备名称 - private String brand;//品牌 - private String ownerUnit;//权属单位 - private String installDate;//安装时间 - private String isOpen;//设备开启状态 - private String active;//状态位 private String pipeGallery;//仓位 private String partition;//分区 + private String road;//路名 + private String position;//设备位置 + private String devType;//设备类型 + private String devCode;//设备编号 + private String assetName;//资产名称 + private String assetCode;//资产名称 + private String assetBarCode;//资产条码 + private String ip;//IP地址 + private String modBus;//modBus地址 + private String mome;//备注 + private String isOpen;//设备开启状态 + private String active;//状态位 public String getId() { return id; @@ -30,6 +34,38 @@ this.id = id; } + public String getPartition() { + return partition; + } + + public void setPartition(String partition) { + this.partition = partition; + } + + public String getPipeGallery() { + return pipeGallery; + } + + public void setPipeGallery(String pipeGallery) { + this.pipeGallery = pipeGallery; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getPosition() { + return position; + } + + public void setPosition(String position) { + this.position = position; + } + public String getDevType() { return devType; } @@ -46,36 +82,52 @@ this.devCode = devCode; } - public String getDevName() { - return devName; + public String getAssetName() { + return assetName; } - public void setDevName(String devName) { - this.devName = devName; + public void setAssetName(String assetName) { + this.assetName = assetName; } - public String getBrand() { - return brand; + public String getAssetCode() { + return assetCode; } - public void setBrand(String brand) { - this.brand = brand; + public void setAssetCode(String assetCode) { + this.assetCode = assetCode; } - public String getOwnerUnit() { - return ownerUnit; + public String getAssetBarCode() { + return assetBarCode; } - public void setOwnerUnit(String ownerUnit) { - this.ownerUnit = ownerUnit; + public void setAssetBarCode(String assetBarCode) { + this.assetBarCode = assetBarCode; } - public String getInstallDate() { - return installDate; + public String getIp() { + return ip; } - public void setInstallDate(String installDate) { - this.installDate = installDate; + public void setIp(String ip) { + this.ip = ip; + } + + public String getModBus() { + return modBus; + } + + public void setModBus(String modBus) { + this.modBus = modBus; + } + + public String getMome() { + return mome; + } + + public void setMome(String mome) { + this.mome = mome; } public String getIsOpen() { @@ -94,39 +146,26 @@ this.active = active; } - public String getPipeGallery() { - return pipeGallery; - } - - public void setPipeGallery(String pipeGallery) { - this.pipeGallery = pipeGallery; - } - - public String getPartition() { - return partition; - } - - public void setPartition(String partition) { - this.partition = partition; - } - public PgDeviceDto(PgDevice pgDevice) { SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); this.setId(String.valueOf(pgDevice.getId())); - this.setDevType(pgDevice.getDevTypeId().getDevType()); + this.setPipeGallery(pgDevice.getPipeGalleryId().getPgName()); + this.setPartition(pgDevice.getPipeGalleryId().getPgPartitionId().getParName()); + this.setRoad(pgDevice.getRoad()); + this.setPosition(pgDevice.getPosition()); + this.setDevType(pgDevice.getDevType()); this.setDevCode(pgDevice.getDevCode()); - this.setDevName(pgDevice.getDevName()); - this.setBrand(pgDevice.getBrand()); - this.setOwnerUnit(pgDevice.getOwnerUnit()); - this.setInstallDate(sdf.format(pgDevice.getInstallDate())); + this.setAssetName(pgDevice.getAssetName()); + this.setAssetCode(pgDevice.getAssetCode()); + this.setAssetBarCode(pgDevice.getAssetBarCode()); + this.setId(pgDevice.getIp()); + this.setModBus(pgDevice.getModBus()); + this.setMome(pgDevice.getMome()); this.setIsOpen(String.valueOf(pgDevice.getIsOpen())); this.setActive(String.valueOf(pgDevice.getActive())); - this.setPipeGallery(pgDevice.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgDevice.getPgPartitionId().getParName()); + } - -} - +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java index e8751d3..3acd0fa 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java @@ -11,7 +11,7 @@ private String id; private String parName;//分区名称 - private String pipeGallery;//管廊仓 + private String road;//所属道路 private String active;//状态位 @@ -31,14 +31,6 @@ this.parName = parName; } - public String getPipeGallery() { - return pipeGallery; - } - - public void setPipeGallery(String pipeGallery) { - this.pipeGallery = pipeGallery; - } - public String getActive() { return active; } @@ -47,11 +39,19 @@ this.active = active; } + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + public PgPartitionDto(PgPartition pgPartition) { this.setId(String.valueOf(pgPartition.getId())); this.setParName(pgPartition.getParName()); - this.setPipeGallery(pgPartition.getPipeGalleryId().getPgName()); + this.setRoad(pgPartition.getRoad()); this.setActive(String.valueOf(pgPartition.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java index 9b161bf..8b430dc 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java @@ -112,8 +112,8 @@ this.setEnterDate(sdf.format(pgPipeLine.getEnterDate())); this.setLayerNum(pgPipeLine.getLayerNum()); this.setDiameter(pgPipeLine.getDiameter()); - this.setPipeGallery(pgPipeLine.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgPipeLine.getPgPartitionId().getParName()); + this.setPipeGallery(pgPipeLine.getPipeGalleryId().getPgName()); + this.setPartition(pgPipeLine.getPipeGalleryId().getPgPartitionId().getParName()); this.setActive(String.valueOf(pgPipeLine.getActive())); } } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java index 03c580c..709dcea 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java @@ -103,8 +103,8 @@ this.setOwnerUnit(pgTexture.getOwnerUnit()); this.setBuildDate(sdf.format(pgTexture.getBuildDate())); this.setActive(String.valueOf(pgTexture.getActive())); - this.setPipeGallery(pgTexture.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgTexture.getPgPartitionId().getParName()); + this.setPipeGallery(pgTexture.getPipeGalleryId().getPgName()); + this.setPartition(pgTexture.getPipeGalleryId().getPgPartitionId().getParName()); } } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java index b40ce84..319cf21 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java @@ -11,6 +11,7 @@ private String id; private String pgName;//管廊名称 + private String pgPartition;//分区名称 private String active;//状态位 public String getId() { @@ -37,10 +38,19 @@ this.active = active; } + public String getPgPartition() { + return pgPartition; + } + + public void setPgPartition(String pgPartition) { + this.pgPartition = pgPartition; + } + public PipeGalleryDto(PipeGallery pipeGallery) { this.setId(String.valueOf(pipeGallery.getId())); this.setPgName(pipeGallery.getPgName()); + this.setPgPartition(pipeGallery.getPgPartitionId().getParName()); this.setActive(String.valueOf(pipeGallery.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java index 80625c7..d8f5e6b 100644 --- a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java +++ b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java @@ -43,9 +43,7 @@ this.intoTime = intoTime; } - @Column(name = "OUT_TIME") - public Date getOutTime() { return outTime; } diff --git a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java index a99981e..b1d63a4 100644 --- a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java +++ b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java @@ -1,11 +1,28 @@ package com.casic.PgInterface.devData.manager; +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.core.util.DateUtils; +import com.casic.PgInterface.core.util.StringUtils; +import com.casic.PgInterface.devData.domain.PgCo; +import com.casic.PgInterface.devData.domain.PgLocation; +import com.casic.PgInterface.devData.dto.PgCoDto; +import com.casic.PgInterface.devData.dto.PgLocationDto; +import com.casic.PgInterface.devTable.domain.PgDevice; +import org.hibernate.Criteria; +import org.hibernate.criterion.Order; +import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; + /** * Created by yxw on 2017/11/2. */ @Service -public class PgLocationManager { +public class PgLocationManager extends HibernateEntityDao { + + //获取设备时间段内所有的监测数据 } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java index cfa0281..7fb5953 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -1,12 +1,12 @@ package com.casic.PgInterface.devTable.domain; import com.casic.PgInterface.devData.domain.*; +import com.casic.PgInterface.patroler.domain.PgAlarmRule; import org.hibernate.annotations.NotFound; import org.hibernate.annotations.NotFoundAction; import javax.persistence.*; import java.io.Serializable; -import java.util.Date; import java.util.List; /** @@ -19,21 +19,27 @@ private static final long serialVersionUID = 1L; private long id; + private PipeGallery pipeGalleryId;//所在管廊信息 + private String road;//路名 + private String position;//设备位置 + private String devType;//设备类型 private String devCode;//设备编号 - private String devName;//设备名称 - private String brand;//品牌 - private String ownerUnit;//权属单位 - private Date installDate;//安装时间 + private String assetName;//资产名称 + private String assetCode;//资产编码 + private String assetBarCode;//资产条码 + private String ip;//IP地址 + private String modBus;//modBus地址 + private String mome;//备注 private int isOpen;//设备是否开启 private int active;//状态位 - private PgDeviceType devTypeId;//设备类型 + private List pgAlarms; - private PgPartition pgPartitionId;//所在管廊信息 private List pgTempHums;//温湿度 private List pgCos;//一氧化碳 private List pgO2s;//氧气 private List pgCh4s;//甲烷 private List pgShs;//硫化氢 + private List pgAlarmRules;//报警规则 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") @@ -45,6 +51,33 @@ this.id = id; } + @Column(name = "ROAD") + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + @Column(name = "POSITION") + public String getPosition() { + return position; + } + + public void setPosition(String position) { + this.position = position; + } + + @Column(name = "DEV_TYPE") + public String getDevType() { + return devType; + } + + public void setDevType(String devType) { + this.devType = devType; + } + @Column(name = "DEV_CODE") public String getDevCode() { return devCode; @@ -54,40 +87,58 @@ this.devCode = devCode; } - @Column(name = "DEV_NAME") - public String getDevName() { - return devName; + @Column(name = "ASSET_NAME") + public String getAssetName() { + return assetName; } - public void setDevName(String devName) { - this.devName = devName; + public void setAssetName(String assetName) { + this.assetName = assetName; } - @Column(name = "BRAND") - public String getBrand() { - return brand; + @Column(name = "ASSET_CODE") + public String getAssetCode() { + return assetCode; } - public void setBrand(String brand) { - this.brand = brand; + public void setAssetCode(String assetCode) { + this.assetCode = assetCode; } - @Column(name = "OWNERUNIT") - public String getOwnerUnit() { - return ownerUnit; + @Column(name = "ASSET_BAR_CODE") + public String getAssetBarCode() { + return assetBarCode; } - public void setOwnerUnit(String ownerUnit) { - this.ownerUnit = ownerUnit; + public void setAssetBarCode(String assetBarCode) { + this.assetBarCode = assetBarCode; } - @Column(name = "INSTALDATE") - public Date getInstallDate() { - return installDate; + @Column(name = "IP") + public String getIp() { + return ip; } - public void setInstallDate(Date installDate) { - this.installDate = installDate; + public void setIp(String ip) { + this.ip = ip; + } + + @Column(name = "MODBUS") + public String getModBus() { + return modBus; + } + + public void setModBus(String modBus) { + this.modBus = modBus; + } + + @Column(name = "MOME") + public String getMome() { + return mome; + } + + public void setMome(String mome) { + this.mome = mome; } @Column(name = "ISOPEN") @@ -119,24 +170,13 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; - } - - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "DEVICE_TYPE_ID") - public PgDeviceType getDevTypeId() { - return devTypeId; - } - - public void setDevTypeId(PgDeviceType devTypeId) { - this.devTypeId = devTypeId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgDeviceId") @@ -184,4 +224,13 @@ this.pgShs = pgShs; } + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgDeviceId") + public List getPgAlarmRules() { + return pgAlarmRules; + } + + public void setPgAlarmRules(List pgAlarmRules) { + this.pgAlarmRules = pgAlarmRules; + } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java index b997b29..4fb3d6f 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java @@ -1,8 +1,5 @@ package com.casic.PgInterface.devTable.domain; -import org.hibernate.annotations.NotFound; -import org.hibernate.annotations.NotFoundAction; - import javax.persistence.*; import java.io.Serializable; import java.util.List; @@ -19,11 +16,9 @@ private long id; private String parName;//分区名称 - private PipeGallery pipeGalleryId;//管廊仓 + private String road;//所属道路 private int active;//状态位 - private List pgTextureList; - private List pgPipeLineList; - private List pgDeviceList; + private List pipeGalleryList;//管廊仓 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PARTITION_ID") @@ -44,6 +39,15 @@ this.parName = parName; } + @Column(name = "ROAD") + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + @Column(name = "ACTIVE") public int getActive() { return active; @@ -53,41 +57,14 @@ this.active = active; } - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PIPEGALLERYID") - public PipeGallery getPipeGalleryId() { - return pipeGalleryId; - } - - public void setPipeGalleryId(PipeGallery pipeGalleryId) { - this.pipeGalleryId = pipeGalleryId; - } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgTextureList() { - return pgTextureList; + public List getPipeGalleryList() { + return pipeGalleryList; } - public void setPgTextureList(List pgTextureList) { - this.pgTextureList = pgTextureList; + public void setPipeGalleryList(List pipeGalleryList) { + this.pipeGalleryList = pipeGalleryList; } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgPipeLineList() { - return pgPipeLineList; - } - public void setPgPipeLineList(List pgPipeLineList) { - this.pgPipeLineList = pgPipeLineList; - } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgDeviceList() { - return pgDeviceList; - } - - public void setPgDeviceList(List pgDeviceList) { - this.pgDeviceList = pgDeviceList; - } } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java index d936d18..e5ff9b3 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java @@ -22,7 +22,7 @@ private Date enterDate;//入廊时间 private String layerNum;//所在层数 private String diameter;//管径 - private PgPartition pgPartitionId;//所在管廊信息 + private PipeGallery pipeGalleryId;//所在管廊信息 private int active;//状态位 @Id @@ -100,12 +100,12 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java index 1f22bf9..4ebfbda 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java @@ -21,7 +21,7 @@ private String ownerUnit;//权属单位 private Date buildDate;//建设年代 private int active;//状态位 - private PgPartition pgPartitionId;//所在管廊信息 + private PipeGallery pipeGalleryId;//所在管廊信息 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_TEXTURE_ID") @@ -91,12 +91,13 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java b/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java index 49a246c..650d623 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java @@ -1,5 +1,8 @@ package com.casic.PgInterface.devTable.domain; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + import javax.persistence.*; import java.io.Serializable; import java.util.List; @@ -16,7 +19,10 @@ private long id; private String pgName;//管廊名称 private int active;//状态位 - private List partitionList; + private PgPartition pgPartitionId;// + private List pgTextureList; + private List pgPipeLineList; + private List pgDeviceList; @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PIPE_GALLERY_ID") @@ -46,12 +52,42 @@ this.active = active; } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") - public List getPartitionList() { - return partitionList; + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "PARTITIONID") + public PgPartition getPgPartitionId() { + return pgPartitionId; } - public void setPartitionList(List partitionList) { - this.partitionList = partitionList; + public void setPgPartitionId(PgPartition pgPartitionId) { + this.pgPartitionId = pgPartitionId; } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgTextureList() { + return pgTextureList; + } + + public void setPgTextureList(List pgTextureList) { + this.pgTextureList = pgTextureList; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgPipeLineList() { + return pgPipeLineList; + } + + public void setPgPipeLineList(List pgPipeLineList) { + this.pgPipeLineList = pgPipeLineList; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgDeviceList() { + return pgDeviceList; + } + + public void setPgDeviceList(List pgDeviceList) { + this.pgDeviceList = pgDeviceList; + } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java index b4048d9..c3dfc55 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java @@ -101,18 +101,17 @@ this.active = active; } - public PgAlarmDto(PgAlarm pgAlarm) - { - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + public PgAlarmDto(PgAlarm pgAlarm) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); this.setId(String.valueOf(pgAlarm.getId())); this.setAlarmType(pgAlarm.getAlarmTypeId().getAlarmType()); this.setAlarmValue(pgAlarm.getAlarmValue()); this.setAlarmDate(sdf.format(pgAlarm.getAlarmDate())); this.setDescription(pgAlarm.getDescription()); - this.setAlarmDevName(pgAlarm.getAlarmDevId().getDevName()); - this.setAlarmLocation(pgAlarm.getAlarmDevId().getPgPartitionId().getPipeGalleryId().getPgName() - + pgAlarm.getAlarmDevId().getPgPartitionId().getParName()); + this.setAlarmDevName(pgAlarm.getAlarmDevId().getAssetName()); + this.setAlarmLocation(pgAlarm.getAlarmDevId().getPipeGalleryId().getPgPartitionId().getParName() + + pgAlarm.getAlarmDevId().getPipeGalleryId().getPgName()); this.setUserName(pgAlarm.getPatrolerId().getUserName()); this.setPhoneNumber(pgAlarm.getPatrolerId().getPhoneNumber()); this.setActive(String.valueOf(pgAlarm.getActive())); diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java index ae76e95..49bd436 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java @@ -11,16 +11,20 @@ public class PgDeviceDto implements Serializable { private String id; - private String devType;//设备类型 - private String devCode;//设备编号 - private String devName;//设备名称 - private String brand;//品牌 - private String ownerUnit;//权属单位 - private String installDate;//安装时间 - private String isOpen;//设备开启状态 - private String active;//状态位 private String pipeGallery;//仓位 private String partition;//分区 + private String road;//路名 + private String position;//设备位置 + private String devType;//设备类型 + private String devCode;//设备编号 + private String assetName;//资产名称 + private String assetCode;//资产名称 + private String assetBarCode;//资产条码 + private String ip;//IP地址 + private String modBus;//modBus地址 + private String mome;//备注 + private String isOpen;//设备开启状态 + private String active;//状态位 public String getId() { return id; @@ -30,6 +34,38 @@ this.id = id; } + public String getPartition() { + return partition; + } + + public void setPartition(String partition) { + this.partition = partition; + } + + public String getPipeGallery() { + return pipeGallery; + } + + public void setPipeGallery(String pipeGallery) { + this.pipeGallery = pipeGallery; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getPosition() { + return position; + } + + public void setPosition(String position) { + this.position = position; + } + public String getDevType() { return devType; } @@ -46,36 +82,52 @@ this.devCode = devCode; } - public String getDevName() { - return devName; + public String getAssetName() { + return assetName; } - public void setDevName(String devName) { - this.devName = devName; + public void setAssetName(String assetName) { + this.assetName = assetName; } - public String getBrand() { - return brand; + public String getAssetCode() { + return assetCode; } - public void setBrand(String brand) { - this.brand = brand; + public void setAssetCode(String assetCode) { + this.assetCode = assetCode; } - public String getOwnerUnit() { - return ownerUnit; + public String getAssetBarCode() { + return assetBarCode; } - public void setOwnerUnit(String ownerUnit) { - this.ownerUnit = ownerUnit; + public void setAssetBarCode(String assetBarCode) { + this.assetBarCode = assetBarCode; } - public String getInstallDate() { - return installDate; + public String getIp() { + return ip; } - public void setInstallDate(String installDate) { - this.installDate = installDate; + public void setIp(String ip) { + this.ip = ip; + } + + public String getModBus() { + return modBus; + } + + public void setModBus(String modBus) { + this.modBus = modBus; + } + + public String getMome() { + return mome; + } + + public void setMome(String mome) { + this.mome = mome; } public String getIsOpen() { @@ -94,39 +146,26 @@ this.active = active; } - public String getPipeGallery() { - return pipeGallery; - } - - public void setPipeGallery(String pipeGallery) { - this.pipeGallery = pipeGallery; - } - - public String getPartition() { - return partition; - } - - public void setPartition(String partition) { - this.partition = partition; - } - public PgDeviceDto(PgDevice pgDevice) { SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); this.setId(String.valueOf(pgDevice.getId())); - this.setDevType(pgDevice.getDevTypeId().getDevType()); + this.setPipeGallery(pgDevice.getPipeGalleryId().getPgName()); + this.setPartition(pgDevice.getPipeGalleryId().getPgPartitionId().getParName()); + this.setRoad(pgDevice.getRoad()); + this.setPosition(pgDevice.getPosition()); + this.setDevType(pgDevice.getDevType()); this.setDevCode(pgDevice.getDevCode()); - this.setDevName(pgDevice.getDevName()); - this.setBrand(pgDevice.getBrand()); - this.setOwnerUnit(pgDevice.getOwnerUnit()); - this.setInstallDate(sdf.format(pgDevice.getInstallDate())); + this.setAssetName(pgDevice.getAssetName()); + this.setAssetCode(pgDevice.getAssetCode()); + this.setAssetBarCode(pgDevice.getAssetBarCode()); + this.setId(pgDevice.getIp()); + this.setModBus(pgDevice.getModBus()); + this.setMome(pgDevice.getMome()); this.setIsOpen(String.valueOf(pgDevice.getIsOpen())); this.setActive(String.valueOf(pgDevice.getActive())); - this.setPipeGallery(pgDevice.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgDevice.getPgPartitionId().getParName()); + } - -} - +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java index e8751d3..3acd0fa 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java @@ -11,7 +11,7 @@ private String id; private String parName;//分区名称 - private String pipeGallery;//管廊仓 + private String road;//所属道路 private String active;//状态位 @@ -31,14 +31,6 @@ this.parName = parName; } - public String getPipeGallery() { - return pipeGallery; - } - - public void setPipeGallery(String pipeGallery) { - this.pipeGallery = pipeGallery; - } - public String getActive() { return active; } @@ -47,11 +39,19 @@ this.active = active; } + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + public PgPartitionDto(PgPartition pgPartition) { this.setId(String.valueOf(pgPartition.getId())); this.setParName(pgPartition.getParName()); - this.setPipeGallery(pgPartition.getPipeGalleryId().getPgName()); + this.setRoad(pgPartition.getRoad()); this.setActive(String.valueOf(pgPartition.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java index 9b161bf..8b430dc 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java @@ -112,8 +112,8 @@ this.setEnterDate(sdf.format(pgPipeLine.getEnterDate())); this.setLayerNum(pgPipeLine.getLayerNum()); this.setDiameter(pgPipeLine.getDiameter()); - this.setPipeGallery(pgPipeLine.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgPipeLine.getPgPartitionId().getParName()); + this.setPipeGallery(pgPipeLine.getPipeGalleryId().getPgName()); + this.setPartition(pgPipeLine.getPipeGalleryId().getPgPartitionId().getParName()); this.setActive(String.valueOf(pgPipeLine.getActive())); } } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java index 03c580c..709dcea 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java @@ -103,8 +103,8 @@ this.setOwnerUnit(pgTexture.getOwnerUnit()); this.setBuildDate(sdf.format(pgTexture.getBuildDate())); this.setActive(String.valueOf(pgTexture.getActive())); - this.setPipeGallery(pgTexture.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgTexture.getPgPartitionId().getParName()); + this.setPipeGallery(pgTexture.getPipeGalleryId().getPgName()); + this.setPartition(pgTexture.getPipeGalleryId().getPgPartitionId().getParName()); } } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java index b40ce84..319cf21 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java @@ -11,6 +11,7 @@ private String id; private String pgName;//管廊名称 + private String pgPartition;//分区名称 private String active;//状态位 public String getId() { @@ -37,10 +38,19 @@ this.active = active; } + public String getPgPartition() { + return pgPartition; + } + + public void setPgPartition(String pgPartition) { + this.pgPartition = pgPartition; + } + public PipeGalleryDto(PipeGallery pipeGallery) { this.setId(String.valueOf(pipeGallery.getId())); this.setPgName(pipeGallery.getPgName()); + this.setPgPartition(pipeGallery.getPgPartitionId().getParName()); this.setActive(String.valueOf(pipeGallery.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java b/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java index 8b413e7..0c594e7 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java @@ -5,10 +5,10 @@ import com.casic.PgInterface.devTable.domain.PipeGallery; import com.casic.PgInterface.devTable.dto.PgPartitionDto; import org.hibernate.Criteria; +import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; -import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; @@ -18,44 +18,50 @@ @Service public class PgPartitionManager extends HibernateEntityDao { - private PipeGalleryManager pipeGalleryManager; - - @Resource - public void setPipeGalleryManager(PipeGalleryManager pipeGalleryManager) { - this.pipeGalleryManager = pipeGalleryManager; - } - - public PgPartition getPartitionByParName(String parName,PipeGallery pipeGallery) { - if(pipeGallery==null) - return null; - Criteria criteria = getSession().createCriteria(PgPartition.class); + public PgPartition getPartitionByParName(String parName) { + Criteria criteria = getSession().createCriteria(PipeGallery.class); criteria.add(Restrictions.eq("parName", parName)); - criteria.add(Restrictions.eq("pipeGalleryId",pipeGallery)); + criteria.add(Restrictions.eq("active",1)); List pgPartitionList = criteria.list(); - //TODO LIST:为空判断 pgPartitionList==null? if (pgPartitionList != null && pgPartitionList.size() > 0) return pgPartitionList.get(0); else return null; } - public List getPartitionByPG(String pgName){ - PipeGallery pipeGallery=pipeGalleryManager.getPipeGalleryByPgName(pgName); - - Criteria criteria=getSession().createCriteria(PgPartition.class); - criteria.add(Restrictions.eq("pipeGalleryId",pipeGallery)); + public List getPartitionByRoad(String road) { + Criteria criteria = getSession().createCriteria(PipeGallery.class); + criteria.add(Restrictions.eq("road", road)); + criteria.add(Restrictions.eq("active",1)); List pgPartitionList = criteria.list(); List pgPartitionDtoList=new ArrayList(); - for(PgPartition pgPartition:pgPartitionList) - { - pgPartitionDtoList.add(new PgPartitionDto(pgPartition)); - } + for(PgPartition pgPartition:pgPartitionList) { + pgPartitionDtoList.add(new PgPartitionDto(pgPartition)); + } return pgPartitionDtoList; } + public List getPgPartitionDtoList() + { + Criteria criteria=getSession().createCriteria(PgPartition.class); + criteria.add(Restrictions.eq("active",1)); + criteria.addOrder(Order.desc("id")); + + List pgPartitionList=criteria.list(); + if(pgPartitionList.size()==0||pgPartitionList==null) + return null; + List pgPartitionDtoList=new ArrayList(); + for(PgPartition pgPartition:pgPartitionList) { + pgPartitionDtoList.add(new PgPartitionDto(pgPartition)); + } + return pgPartitionDtoList; + } + + + } diff --git a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java index 80625c7..d8f5e6b 100644 --- a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java +++ b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java @@ -43,9 +43,7 @@ this.intoTime = intoTime; } - @Column(name = "OUT_TIME") - public Date getOutTime() { return outTime; } diff --git a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java index a99981e..b1d63a4 100644 --- a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java +++ b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java @@ -1,11 +1,28 @@ package com.casic.PgInterface.devData.manager; +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.core.util.DateUtils; +import com.casic.PgInterface.core.util.StringUtils; +import com.casic.PgInterface.devData.domain.PgCo; +import com.casic.PgInterface.devData.domain.PgLocation; +import com.casic.PgInterface.devData.dto.PgCoDto; +import com.casic.PgInterface.devData.dto.PgLocationDto; +import com.casic.PgInterface.devTable.domain.PgDevice; +import org.hibernate.Criteria; +import org.hibernate.criterion.Order; +import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; + /** * Created by yxw on 2017/11/2. */ @Service -public class PgLocationManager { +public class PgLocationManager extends HibernateEntityDao { + + //获取设备时间段内所有的监测数据 } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java index cfa0281..7fb5953 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -1,12 +1,12 @@ package com.casic.PgInterface.devTable.domain; import com.casic.PgInterface.devData.domain.*; +import com.casic.PgInterface.patroler.domain.PgAlarmRule; import org.hibernate.annotations.NotFound; import org.hibernate.annotations.NotFoundAction; import javax.persistence.*; import java.io.Serializable; -import java.util.Date; import java.util.List; /** @@ -19,21 +19,27 @@ private static final long serialVersionUID = 1L; private long id; + private PipeGallery pipeGalleryId;//所在管廊信息 + private String road;//路名 + private String position;//设备位置 + private String devType;//设备类型 private String devCode;//设备编号 - private String devName;//设备名称 - private String brand;//品牌 - private String ownerUnit;//权属单位 - private Date installDate;//安装时间 + private String assetName;//资产名称 + private String assetCode;//资产编码 + private String assetBarCode;//资产条码 + private String ip;//IP地址 + private String modBus;//modBus地址 + private String mome;//备注 private int isOpen;//设备是否开启 private int active;//状态位 - private PgDeviceType devTypeId;//设备类型 + private List pgAlarms; - private PgPartition pgPartitionId;//所在管廊信息 private List pgTempHums;//温湿度 private List pgCos;//一氧化碳 private List pgO2s;//氧气 private List pgCh4s;//甲烷 private List pgShs;//硫化氢 + private List pgAlarmRules;//报警规则 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") @@ -45,6 +51,33 @@ this.id = id; } + @Column(name = "ROAD") + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + @Column(name = "POSITION") + public String getPosition() { + return position; + } + + public void setPosition(String position) { + this.position = position; + } + + @Column(name = "DEV_TYPE") + public String getDevType() { + return devType; + } + + public void setDevType(String devType) { + this.devType = devType; + } + @Column(name = "DEV_CODE") public String getDevCode() { return devCode; @@ -54,40 +87,58 @@ this.devCode = devCode; } - @Column(name = "DEV_NAME") - public String getDevName() { - return devName; + @Column(name = "ASSET_NAME") + public String getAssetName() { + return assetName; } - public void setDevName(String devName) { - this.devName = devName; + public void setAssetName(String assetName) { + this.assetName = assetName; } - @Column(name = "BRAND") - public String getBrand() { - return brand; + @Column(name = "ASSET_CODE") + public String getAssetCode() { + return assetCode; } - public void setBrand(String brand) { - this.brand = brand; + public void setAssetCode(String assetCode) { + this.assetCode = assetCode; } - @Column(name = "OWNERUNIT") - public String getOwnerUnit() { - return ownerUnit; + @Column(name = "ASSET_BAR_CODE") + public String getAssetBarCode() { + return assetBarCode; } - public void setOwnerUnit(String ownerUnit) { - this.ownerUnit = ownerUnit; + public void setAssetBarCode(String assetBarCode) { + this.assetBarCode = assetBarCode; } - @Column(name = "INSTALDATE") - public Date getInstallDate() { - return installDate; + @Column(name = "IP") + public String getIp() { + return ip; } - public void setInstallDate(Date installDate) { - this.installDate = installDate; + public void setIp(String ip) { + this.ip = ip; + } + + @Column(name = "MODBUS") + public String getModBus() { + return modBus; + } + + public void setModBus(String modBus) { + this.modBus = modBus; + } + + @Column(name = "MOME") + public String getMome() { + return mome; + } + + public void setMome(String mome) { + this.mome = mome; } @Column(name = "ISOPEN") @@ -119,24 +170,13 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; - } - - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "DEVICE_TYPE_ID") - public PgDeviceType getDevTypeId() { - return devTypeId; - } - - public void setDevTypeId(PgDeviceType devTypeId) { - this.devTypeId = devTypeId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgDeviceId") @@ -184,4 +224,13 @@ this.pgShs = pgShs; } + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgDeviceId") + public List getPgAlarmRules() { + return pgAlarmRules; + } + + public void setPgAlarmRules(List pgAlarmRules) { + this.pgAlarmRules = pgAlarmRules; + } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java index b997b29..4fb3d6f 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java @@ -1,8 +1,5 @@ package com.casic.PgInterface.devTable.domain; -import org.hibernate.annotations.NotFound; -import org.hibernate.annotations.NotFoundAction; - import javax.persistence.*; import java.io.Serializable; import java.util.List; @@ -19,11 +16,9 @@ private long id; private String parName;//分区名称 - private PipeGallery pipeGalleryId;//管廊仓 + private String road;//所属道路 private int active;//状态位 - private List pgTextureList; - private List pgPipeLineList; - private List pgDeviceList; + private List pipeGalleryList;//管廊仓 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PARTITION_ID") @@ -44,6 +39,15 @@ this.parName = parName; } + @Column(name = "ROAD") + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + @Column(name = "ACTIVE") public int getActive() { return active; @@ -53,41 +57,14 @@ this.active = active; } - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PIPEGALLERYID") - public PipeGallery getPipeGalleryId() { - return pipeGalleryId; - } - - public void setPipeGalleryId(PipeGallery pipeGalleryId) { - this.pipeGalleryId = pipeGalleryId; - } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgTextureList() { - return pgTextureList; + public List getPipeGalleryList() { + return pipeGalleryList; } - public void setPgTextureList(List pgTextureList) { - this.pgTextureList = pgTextureList; + public void setPipeGalleryList(List pipeGalleryList) { + this.pipeGalleryList = pipeGalleryList; } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgPipeLineList() { - return pgPipeLineList; - } - public void setPgPipeLineList(List pgPipeLineList) { - this.pgPipeLineList = pgPipeLineList; - } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgDeviceList() { - return pgDeviceList; - } - - public void setPgDeviceList(List pgDeviceList) { - this.pgDeviceList = pgDeviceList; - } } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java index d936d18..e5ff9b3 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java @@ -22,7 +22,7 @@ private Date enterDate;//入廊时间 private String layerNum;//所在层数 private String diameter;//管径 - private PgPartition pgPartitionId;//所在管廊信息 + private PipeGallery pipeGalleryId;//所在管廊信息 private int active;//状态位 @Id @@ -100,12 +100,12 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java index 1f22bf9..4ebfbda 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java @@ -21,7 +21,7 @@ private String ownerUnit;//权属单位 private Date buildDate;//建设年代 private int active;//状态位 - private PgPartition pgPartitionId;//所在管廊信息 + private PipeGallery pipeGalleryId;//所在管廊信息 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_TEXTURE_ID") @@ -91,12 +91,13 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java b/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java index 49a246c..650d623 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java @@ -1,5 +1,8 @@ package com.casic.PgInterface.devTable.domain; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + import javax.persistence.*; import java.io.Serializable; import java.util.List; @@ -16,7 +19,10 @@ private long id; private String pgName;//管廊名称 private int active;//状态位 - private List partitionList; + private PgPartition pgPartitionId;// + private List pgTextureList; + private List pgPipeLineList; + private List pgDeviceList; @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PIPE_GALLERY_ID") @@ -46,12 +52,42 @@ this.active = active; } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") - public List getPartitionList() { - return partitionList; + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "PARTITIONID") + public PgPartition getPgPartitionId() { + return pgPartitionId; } - public void setPartitionList(List partitionList) { - this.partitionList = partitionList; + public void setPgPartitionId(PgPartition pgPartitionId) { + this.pgPartitionId = pgPartitionId; } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgTextureList() { + return pgTextureList; + } + + public void setPgTextureList(List pgTextureList) { + this.pgTextureList = pgTextureList; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgPipeLineList() { + return pgPipeLineList; + } + + public void setPgPipeLineList(List pgPipeLineList) { + this.pgPipeLineList = pgPipeLineList; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgDeviceList() { + return pgDeviceList; + } + + public void setPgDeviceList(List pgDeviceList) { + this.pgDeviceList = pgDeviceList; + } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java index b4048d9..c3dfc55 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java @@ -101,18 +101,17 @@ this.active = active; } - public PgAlarmDto(PgAlarm pgAlarm) - { - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + public PgAlarmDto(PgAlarm pgAlarm) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); this.setId(String.valueOf(pgAlarm.getId())); this.setAlarmType(pgAlarm.getAlarmTypeId().getAlarmType()); this.setAlarmValue(pgAlarm.getAlarmValue()); this.setAlarmDate(sdf.format(pgAlarm.getAlarmDate())); this.setDescription(pgAlarm.getDescription()); - this.setAlarmDevName(pgAlarm.getAlarmDevId().getDevName()); - this.setAlarmLocation(pgAlarm.getAlarmDevId().getPgPartitionId().getPipeGalleryId().getPgName() - + pgAlarm.getAlarmDevId().getPgPartitionId().getParName()); + this.setAlarmDevName(pgAlarm.getAlarmDevId().getAssetName()); + this.setAlarmLocation(pgAlarm.getAlarmDevId().getPipeGalleryId().getPgPartitionId().getParName() + + pgAlarm.getAlarmDevId().getPipeGalleryId().getPgName()); this.setUserName(pgAlarm.getPatrolerId().getUserName()); this.setPhoneNumber(pgAlarm.getPatrolerId().getPhoneNumber()); this.setActive(String.valueOf(pgAlarm.getActive())); diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java index ae76e95..49bd436 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java @@ -11,16 +11,20 @@ public class PgDeviceDto implements Serializable { private String id; - private String devType;//设备类型 - private String devCode;//设备编号 - private String devName;//设备名称 - private String brand;//品牌 - private String ownerUnit;//权属单位 - private String installDate;//安装时间 - private String isOpen;//设备开启状态 - private String active;//状态位 private String pipeGallery;//仓位 private String partition;//分区 + private String road;//路名 + private String position;//设备位置 + private String devType;//设备类型 + private String devCode;//设备编号 + private String assetName;//资产名称 + private String assetCode;//资产名称 + private String assetBarCode;//资产条码 + private String ip;//IP地址 + private String modBus;//modBus地址 + private String mome;//备注 + private String isOpen;//设备开启状态 + private String active;//状态位 public String getId() { return id; @@ -30,6 +34,38 @@ this.id = id; } + public String getPartition() { + return partition; + } + + public void setPartition(String partition) { + this.partition = partition; + } + + public String getPipeGallery() { + return pipeGallery; + } + + public void setPipeGallery(String pipeGallery) { + this.pipeGallery = pipeGallery; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getPosition() { + return position; + } + + public void setPosition(String position) { + this.position = position; + } + public String getDevType() { return devType; } @@ -46,36 +82,52 @@ this.devCode = devCode; } - public String getDevName() { - return devName; + public String getAssetName() { + return assetName; } - public void setDevName(String devName) { - this.devName = devName; + public void setAssetName(String assetName) { + this.assetName = assetName; } - public String getBrand() { - return brand; + public String getAssetCode() { + return assetCode; } - public void setBrand(String brand) { - this.brand = brand; + public void setAssetCode(String assetCode) { + this.assetCode = assetCode; } - public String getOwnerUnit() { - return ownerUnit; + public String getAssetBarCode() { + return assetBarCode; } - public void setOwnerUnit(String ownerUnit) { - this.ownerUnit = ownerUnit; + public void setAssetBarCode(String assetBarCode) { + this.assetBarCode = assetBarCode; } - public String getInstallDate() { - return installDate; + public String getIp() { + return ip; } - public void setInstallDate(String installDate) { - this.installDate = installDate; + public void setIp(String ip) { + this.ip = ip; + } + + public String getModBus() { + return modBus; + } + + public void setModBus(String modBus) { + this.modBus = modBus; + } + + public String getMome() { + return mome; + } + + public void setMome(String mome) { + this.mome = mome; } public String getIsOpen() { @@ -94,39 +146,26 @@ this.active = active; } - public String getPipeGallery() { - return pipeGallery; - } - - public void setPipeGallery(String pipeGallery) { - this.pipeGallery = pipeGallery; - } - - public String getPartition() { - return partition; - } - - public void setPartition(String partition) { - this.partition = partition; - } - public PgDeviceDto(PgDevice pgDevice) { SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); this.setId(String.valueOf(pgDevice.getId())); - this.setDevType(pgDevice.getDevTypeId().getDevType()); + this.setPipeGallery(pgDevice.getPipeGalleryId().getPgName()); + this.setPartition(pgDevice.getPipeGalleryId().getPgPartitionId().getParName()); + this.setRoad(pgDevice.getRoad()); + this.setPosition(pgDevice.getPosition()); + this.setDevType(pgDevice.getDevType()); this.setDevCode(pgDevice.getDevCode()); - this.setDevName(pgDevice.getDevName()); - this.setBrand(pgDevice.getBrand()); - this.setOwnerUnit(pgDevice.getOwnerUnit()); - this.setInstallDate(sdf.format(pgDevice.getInstallDate())); + this.setAssetName(pgDevice.getAssetName()); + this.setAssetCode(pgDevice.getAssetCode()); + this.setAssetBarCode(pgDevice.getAssetBarCode()); + this.setId(pgDevice.getIp()); + this.setModBus(pgDevice.getModBus()); + this.setMome(pgDevice.getMome()); this.setIsOpen(String.valueOf(pgDevice.getIsOpen())); this.setActive(String.valueOf(pgDevice.getActive())); - this.setPipeGallery(pgDevice.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgDevice.getPgPartitionId().getParName()); + } - -} - +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java index e8751d3..3acd0fa 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java @@ -11,7 +11,7 @@ private String id; private String parName;//分区名称 - private String pipeGallery;//管廊仓 + private String road;//所属道路 private String active;//状态位 @@ -31,14 +31,6 @@ this.parName = parName; } - public String getPipeGallery() { - return pipeGallery; - } - - public void setPipeGallery(String pipeGallery) { - this.pipeGallery = pipeGallery; - } - public String getActive() { return active; } @@ -47,11 +39,19 @@ this.active = active; } + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + public PgPartitionDto(PgPartition pgPartition) { this.setId(String.valueOf(pgPartition.getId())); this.setParName(pgPartition.getParName()); - this.setPipeGallery(pgPartition.getPipeGalleryId().getPgName()); + this.setRoad(pgPartition.getRoad()); this.setActive(String.valueOf(pgPartition.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java index 9b161bf..8b430dc 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java @@ -112,8 +112,8 @@ this.setEnterDate(sdf.format(pgPipeLine.getEnterDate())); this.setLayerNum(pgPipeLine.getLayerNum()); this.setDiameter(pgPipeLine.getDiameter()); - this.setPipeGallery(pgPipeLine.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgPipeLine.getPgPartitionId().getParName()); + this.setPipeGallery(pgPipeLine.getPipeGalleryId().getPgName()); + this.setPartition(pgPipeLine.getPipeGalleryId().getPgPartitionId().getParName()); this.setActive(String.valueOf(pgPipeLine.getActive())); } } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java index 03c580c..709dcea 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java @@ -103,8 +103,8 @@ this.setOwnerUnit(pgTexture.getOwnerUnit()); this.setBuildDate(sdf.format(pgTexture.getBuildDate())); this.setActive(String.valueOf(pgTexture.getActive())); - this.setPipeGallery(pgTexture.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgTexture.getPgPartitionId().getParName()); + this.setPipeGallery(pgTexture.getPipeGalleryId().getPgName()); + this.setPartition(pgTexture.getPipeGalleryId().getPgPartitionId().getParName()); } } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java index b40ce84..319cf21 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java @@ -11,6 +11,7 @@ private String id; private String pgName;//管廊名称 + private String pgPartition;//分区名称 private String active;//状态位 public String getId() { @@ -37,10 +38,19 @@ this.active = active; } + public String getPgPartition() { + return pgPartition; + } + + public void setPgPartition(String pgPartition) { + this.pgPartition = pgPartition; + } + public PipeGalleryDto(PipeGallery pipeGallery) { this.setId(String.valueOf(pipeGallery.getId())); this.setPgName(pipeGallery.getPgName()); + this.setPgPartition(pipeGallery.getPgPartitionId().getParName()); this.setActive(String.valueOf(pipeGallery.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java b/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java index 8b413e7..0c594e7 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java @@ -5,10 +5,10 @@ import com.casic.PgInterface.devTable.domain.PipeGallery; import com.casic.PgInterface.devTable.dto.PgPartitionDto; import org.hibernate.Criteria; +import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; -import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; @@ -18,44 +18,50 @@ @Service public class PgPartitionManager extends HibernateEntityDao { - private PipeGalleryManager pipeGalleryManager; - - @Resource - public void setPipeGalleryManager(PipeGalleryManager pipeGalleryManager) { - this.pipeGalleryManager = pipeGalleryManager; - } - - public PgPartition getPartitionByParName(String parName,PipeGallery pipeGallery) { - if(pipeGallery==null) - return null; - Criteria criteria = getSession().createCriteria(PgPartition.class); + public PgPartition getPartitionByParName(String parName) { + Criteria criteria = getSession().createCriteria(PipeGallery.class); criteria.add(Restrictions.eq("parName", parName)); - criteria.add(Restrictions.eq("pipeGalleryId",pipeGallery)); + criteria.add(Restrictions.eq("active",1)); List pgPartitionList = criteria.list(); - //TODO LIST:为空判断 pgPartitionList==null? if (pgPartitionList != null && pgPartitionList.size() > 0) return pgPartitionList.get(0); else return null; } - public List getPartitionByPG(String pgName){ - PipeGallery pipeGallery=pipeGalleryManager.getPipeGalleryByPgName(pgName); - - Criteria criteria=getSession().createCriteria(PgPartition.class); - criteria.add(Restrictions.eq("pipeGalleryId",pipeGallery)); + public List getPartitionByRoad(String road) { + Criteria criteria = getSession().createCriteria(PipeGallery.class); + criteria.add(Restrictions.eq("road", road)); + criteria.add(Restrictions.eq("active",1)); List pgPartitionList = criteria.list(); List pgPartitionDtoList=new ArrayList(); - for(PgPartition pgPartition:pgPartitionList) - { - pgPartitionDtoList.add(new PgPartitionDto(pgPartition)); - } + for(PgPartition pgPartition:pgPartitionList) { + pgPartitionDtoList.add(new PgPartitionDto(pgPartition)); + } return pgPartitionDtoList; } + public List getPgPartitionDtoList() + { + Criteria criteria=getSession().createCriteria(PgPartition.class); + criteria.add(Restrictions.eq("active",1)); + criteria.addOrder(Order.desc("id")); + + List pgPartitionList=criteria.list(); + if(pgPartitionList.size()==0||pgPartitionList==null) + return null; + List pgPartitionDtoList=new ArrayList(); + for(PgPartition pgPartition:pgPartitionList) { + pgPartitionDtoList.add(new PgPartitionDto(pgPartition)); + } + return pgPartitionDtoList; + } + + + } diff --git a/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java b/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java index 16370c6..9bce32b 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java @@ -1,14 +1,16 @@ package com.casic.PgInterface.devTable.manager; import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.devTable.domain.PgPartition; import com.casic.PgInterface.devTable.domain.PipeGallery; import com.casic.PgInterface.devTable.dto.PipeGalleryDto; import org.hibernate.Criteria; -import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; -import java.util.*; +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; /** * Created by yxw on 2017/11/4. @@ -16,36 +18,44 @@ @Service public class PipeGalleryManager extends HibernateEntityDao { - public PipeGallery getPipeGalleryByPgName(String pgName) { - Criteria criteria = getSession().createCriteria(PipeGallery.class); + private PgPartitionManager pgPartitionManager; + + @Resource + public void setPgPartitionManager(PgPartitionManager pgPartitionManager) { + this.pgPartitionManager = pgPartitionManager; + } + + public PipeGallery getPipeGalleryByPgName(String pgName,PgPartition pgPartition) { + if(pgPartition==null) + return null; + Criteria criteria = getSession().createCriteria(PgPartition.class); criteria.add(Restrictions.eq("pgName", pgName)); - criteria.add(Restrictions.eq("active",1)); + criteria.add(Restrictions.eq("pgPartitionId",pgPartition)); List pipeGalleryList = criteria.list(); - //TODO LIST:为空判断 pipeGalleryList==null? + //TODO LIST:为空判断 pgPartitionList==null? if (pipeGalleryList != null && pipeGalleryList.size() > 0) return pipeGalleryList.get(0); else return null; } - public List getPIpeGalleryDtoList() - { - Criteria criteria=getSession().createCriteria(PipeGallery.class); - criteria.add(Restrictions.eq("active",1)); - criteria.addOrder(Order.desc("id")); - List pipeGalleryList=criteria.list(); - if(pipeGalleryList.size()==0||pipeGalleryList==null) - return null; - List pipeGalleryDtoList=new ArrayList(); - for(PipeGallery pipeGallery:pipeGalleryList) { + public List getPipeGalleryByParName(String parName) { + + PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName); + Criteria criteria = getSession().createCriteria(PipeGallery.class); + criteria.add(Restrictions.eq("pgPartitionId", pgPartition)); + + List pipeGalleryList = criteria.list(); + + List pipeGalleryDtoList = new ArrayList(); + for (PipeGallery pipeGallery : pipeGalleryList) { pipeGalleryDtoList.add(new PipeGalleryDto(pipeGallery)); } + return pipeGalleryDtoList; } - - } diff --git a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java index 80625c7..d8f5e6b 100644 --- a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java +++ b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java @@ -43,9 +43,7 @@ this.intoTime = intoTime; } - @Column(name = "OUT_TIME") - public Date getOutTime() { return outTime; } diff --git a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java index a99981e..b1d63a4 100644 --- a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java +++ b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java @@ -1,11 +1,28 @@ package com.casic.PgInterface.devData.manager; +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.core.util.DateUtils; +import com.casic.PgInterface.core.util.StringUtils; +import com.casic.PgInterface.devData.domain.PgCo; +import com.casic.PgInterface.devData.domain.PgLocation; +import com.casic.PgInterface.devData.dto.PgCoDto; +import com.casic.PgInterface.devData.dto.PgLocationDto; +import com.casic.PgInterface.devTable.domain.PgDevice; +import org.hibernate.Criteria; +import org.hibernate.criterion.Order; +import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; + /** * Created by yxw on 2017/11/2. */ @Service -public class PgLocationManager { +public class PgLocationManager extends HibernateEntityDao { + + //获取设备时间段内所有的监测数据 } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java index cfa0281..7fb5953 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -1,12 +1,12 @@ package com.casic.PgInterface.devTable.domain; import com.casic.PgInterface.devData.domain.*; +import com.casic.PgInterface.patroler.domain.PgAlarmRule; import org.hibernate.annotations.NotFound; import org.hibernate.annotations.NotFoundAction; import javax.persistence.*; import java.io.Serializable; -import java.util.Date; import java.util.List; /** @@ -19,21 +19,27 @@ private static final long serialVersionUID = 1L; private long id; + private PipeGallery pipeGalleryId;//所在管廊信息 + private String road;//路名 + private String position;//设备位置 + private String devType;//设备类型 private String devCode;//设备编号 - private String devName;//设备名称 - private String brand;//品牌 - private String ownerUnit;//权属单位 - private Date installDate;//安装时间 + private String assetName;//资产名称 + private String assetCode;//资产编码 + private String assetBarCode;//资产条码 + private String ip;//IP地址 + private String modBus;//modBus地址 + private String mome;//备注 private int isOpen;//设备是否开启 private int active;//状态位 - private PgDeviceType devTypeId;//设备类型 + private List pgAlarms; - private PgPartition pgPartitionId;//所在管廊信息 private List pgTempHums;//温湿度 private List pgCos;//一氧化碳 private List pgO2s;//氧气 private List pgCh4s;//甲烷 private List pgShs;//硫化氢 + private List pgAlarmRules;//报警规则 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") @@ -45,6 +51,33 @@ this.id = id; } + @Column(name = "ROAD") + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + @Column(name = "POSITION") + public String getPosition() { + return position; + } + + public void setPosition(String position) { + this.position = position; + } + + @Column(name = "DEV_TYPE") + public String getDevType() { + return devType; + } + + public void setDevType(String devType) { + this.devType = devType; + } + @Column(name = "DEV_CODE") public String getDevCode() { return devCode; @@ -54,40 +87,58 @@ this.devCode = devCode; } - @Column(name = "DEV_NAME") - public String getDevName() { - return devName; + @Column(name = "ASSET_NAME") + public String getAssetName() { + return assetName; } - public void setDevName(String devName) { - this.devName = devName; + public void setAssetName(String assetName) { + this.assetName = assetName; } - @Column(name = "BRAND") - public String getBrand() { - return brand; + @Column(name = "ASSET_CODE") + public String getAssetCode() { + return assetCode; } - public void setBrand(String brand) { - this.brand = brand; + public void setAssetCode(String assetCode) { + this.assetCode = assetCode; } - @Column(name = "OWNERUNIT") - public String getOwnerUnit() { - return ownerUnit; + @Column(name = "ASSET_BAR_CODE") + public String getAssetBarCode() { + return assetBarCode; } - public void setOwnerUnit(String ownerUnit) { - this.ownerUnit = ownerUnit; + public void setAssetBarCode(String assetBarCode) { + this.assetBarCode = assetBarCode; } - @Column(name = "INSTALDATE") - public Date getInstallDate() { - return installDate; + @Column(name = "IP") + public String getIp() { + return ip; } - public void setInstallDate(Date installDate) { - this.installDate = installDate; + public void setIp(String ip) { + this.ip = ip; + } + + @Column(name = "MODBUS") + public String getModBus() { + return modBus; + } + + public void setModBus(String modBus) { + this.modBus = modBus; + } + + @Column(name = "MOME") + public String getMome() { + return mome; + } + + public void setMome(String mome) { + this.mome = mome; } @Column(name = "ISOPEN") @@ -119,24 +170,13 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; - } - - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "DEVICE_TYPE_ID") - public PgDeviceType getDevTypeId() { - return devTypeId; - } - - public void setDevTypeId(PgDeviceType devTypeId) { - this.devTypeId = devTypeId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgDeviceId") @@ -184,4 +224,13 @@ this.pgShs = pgShs; } + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgDeviceId") + public List getPgAlarmRules() { + return pgAlarmRules; + } + + public void setPgAlarmRules(List pgAlarmRules) { + this.pgAlarmRules = pgAlarmRules; + } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java index b997b29..4fb3d6f 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java @@ -1,8 +1,5 @@ package com.casic.PgInterface.devTable.domain; -import org.hibernate.annotations.NotFound; -import org.hibernate.annotations.NotFoundAction; - import javax.persistence.*; import java.io.Serializable; import java.util.List; @@ -19,11 +16,9 @@ private long id; private String parName;//分区名称 - private PipeGallery pipeGalleryId;//管廊仓 + private String road;//所属道路 private int active;//状态位 - private List pgTextureList; - private List pgPipeLineList; - private List pgDeviceList; + private List pipeGalleryList;//管廊仓 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PARTITION_ID") @@ -44,6 +39,15 @@ this.parName = parName; } + @Column(name = "ROAD") + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + @Column(name = "ACTIVE") public int getActive() { return active; @@ -53,41 +57,14 @@ this.active = active; } - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PIPEGALLERYID") - public PipeGallery getPipeGalleryId() { - return pipeGalleryId; - } - - public void setPipeGalleryId(PipeGallery pipeGalleryId) { - this.pipeGalleryId = pipeGalleryId; - } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgTextureList() { - return pgTextureList; + public List getPipeGalleryList() { + return pipeGalleryList; } - public void setPgTextureList(List pgTextureList) { - this.pgTextureList = pgTextureList; + public void setPipeGalleryList(List pipeGalleryList) { + this.pipeGalleryList = pipeGalleryList; } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgPipeLineList() { - return pgPipeLineList; - } - public void setPgPipeLineList(List pgPipeLineList) { - this.pgPipeLineList = pgPipeLineList; - } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgDeviceList() { - return pgDeviceList; - } - - public void setPgDeviceList(List pgDeviceList) { - this.pgDeviceList = pgDeviceList; - } } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java index d936d18..e5ff9b3 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java @@ -22,7 +22,7 @@ private Date enterDate;//入廊时间 private String layerNum;//所在层数 private String diameter;//管径 - private PgPartition pgPartitionId;//所在管廊信息 + private PipeGallery pipeGalleryId;//所在管廊信息 private int active;//状态位 @Id @@ -100,12 +100,12 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java index 1f22bf9..4ebfbda 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java @@ -21,7 +21,7 @@ private String ownerUnit;//权属单位 private Date buildDate;//建设年代 private int active;//状态位 - private PgPartition pgPartitionId;//所在管廊信息 + private PipeGallery pipeGalleryId;//所在管廊信息 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_TEXTURE_ID") @@ -91,12 +91,13 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java b/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java index 49a246c..650d623 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java @@ -1,5 +1,8 @@ package com.casic.PgInterface.devTable.domain; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + import javax.persistence.*; import java.io.Serializable; import java.util.List; @@ -16,7 +19,10 @@ private long id; private String pgName;//管廊名称 private int active;//状态位 - private List partitionList; + private PgPartition pgPartitionId;// + private List pgTextureList; + private List pgPipeLineList; + private List pgDeviceList; @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PIPE_GALLERY_ID") @@ -46,12 +52,42 @@ this.active = active; } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") - public List getPartitionList() { - return partitionList; + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "PARTITIONID") + public PgPartition getPgPartitionId() { + return pgPartitionId; } - public void setPartitionList(List partitionList) { - this.partitionList = partitionList; + public void setPgPartitionId(PgPartition pgPartitionId) { + this.pgPartitionId = pgPartitionId; } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgTextureList() { + return pgTextureList; + } + + public void setPgTextureList(List pgTextureList) { + this.pgTextureList = pgTextureList; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgPipeLineList() { + return pgPipeLineList; + } + + public void setPgPipeLineList(List pgPipeLineList) { + this.pgPipeLineList = pgPipeLineList; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgDeviceList() { + return pgDeviceList; + } + + public void setPgDeviceList(List pgDeviceList) { + this.pgDeviceList = pgDeviceList; + } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java index b4048d9..c3dfc55 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java @@ -101,18 +101,17 @@ this.active = active; } - public PgAlarmDto(PgAlarm pgAlarm) - { - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + public PgAlarmDto(PgAlarm pgAlarm) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); this.setId(String.valueOf(pgAlarm.getId())); this.setAlarmType(pgAlarm.getAlarmTypeId().getAlarmType()); this.setAlarmValue(pgAlarm.getAlarmValue()); this.setAlarmDate(sdf.format(pgAlarm.getAlarmDate())); this.setDescription(pgAlarm.getDescription()); - this.setAlarmDevName(pgAlarm.getAlarmDevId().getDevName()); - this.setAlarmLocation(pgAlarm.getAlarmDevId().getPgPartitionId().getPipeGalleryId().getPgName() - + pgAlarm.getAlarmDevId().getPgPartitionId().getParName()); + this.setAlarmDevName(pgAlarm.getAlarmDevId().getAssetName()); + this.setAlarmLocation(pgAlarm.getAlarmDevId().getPipeGalleryId().getPgPartitionId().getParName() + + pgAlarm.getAlarmDevId().getPipeGalleryId().getPgName()); this.setUserName(pgAlarm.getPatrolerId().getUserName()); this.setPhoneNumber(pgAlarm.getPatrolerId().getPhoneNumber()); this.setActive(String.valueOf(pgAlarm.getActive())); diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java index ae76e95..49bd436 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java @@ -11,16 +11,20 @@ public class PgDeviceDto implements Serializable { private String id; - private String devType;//设备类型 - private String devCode;//设备编号 - private String devName;//设备名称 - private String brand;//品牌 - private String ownerUnit;//权属单位 - private String installDate;//安装时间 - private String isOpen;//设备开启状态 - private String active;//状态位 private String pipeGallery;//仓位 private String partition;//分区 + private String road;//路名 + private String position;//设备位置 + private String devType;//设备类型 + private String devCode;//设备编号 + private String assetName;//资产名称 + private String assetCode;//资产名称 + private String assetBarCode;//资产条码 + private String ip;//IP地址 + private String modBus;//modBus地址 + private String mome;//备注 + private String isOpen;//设备开启状态 + private String active;//状态位 public String getId() { return id; @@ -30,6 +34,38 @@ this.id = id; } + public String getPartition() { + return partition; + } + + public void setPartition(String partition) { + this.partition = partition; + } + + public String getPipeGallery() { + return pipeGallery; + } + + public void setPipeGallery(String pipeGallery) { + this.pipeGallery = pipeGallery; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getPosition() { + return position; + } + + public void setPosition(String position) { + this.position = position; + } + public String getDevType() { return devType; } @@ -46,36 +82,52 @@ this.devCode = devCode; } - public String getDevName() { - return devName; + public String getAssetName() { + return assetName; } - public void setDevName(String devName) { - this.devName = devName; + public void setAssetName(String assetName) { + this.assetName = assetName; } - public String getBrand() { - return brand; + public String getAssetCode() { + return assetCode; } - public void setBrand(String brand) { - this.brand = brand; + public void setAssetCode(String assetCode) { + this.assetCode = assetCode; } - public String getOwnerUnit() { - return ownerUnit; + public String getAssetBarCode() { + return assetBarCode; } - public void setOwnerUnit(String ownerUnit) { - this.ownerUnit = ownerUnit; + public void setAssetBarCode(String assetBarCode) { + this.assetBarCode = assetBarCode; } - public String getInstallDate() { - return installDate; + public String getIp() { + return ip; } - public void setInstallDate(String installDate) { - this.installDate = installDate; + public void setIp(String ip) { + this.ip = ip; + } + + public String getModBus() { + return modBus; + } + + public void setModBus(String modBus) { + this.modBus = modBus; + } + + public String getMome() { + return mome; + } + + public void setMome(String mome) { + this.mome = mome; } public String getIsOpen() { @@ -94,39 +146,26 @@ this.active = active; } - public String getPipeGallery() { - return pipeGallery; - } - - public void setPipeGallery(String pipeGallery) { - this.pipeGallery = pipeGallery; - } - - public String getPartition() { - return partition; - } - - public void setPartition(String partition) { - this.partition = partition; - } - public PgDeviceDto(PgDevice pgDevice) { SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); this.setId(String.valueOf(pgDevice.getId())); - this.setDevType(pgDevice.getDevTypeId().getDevType()); + this.setPipeGallery(pgDevice.getPipeGalleryId().getPgName()); + this.setPartition(pgDevice.getPipeGalleryId().getPgPartitionId().getParName()); + this.setRoad(pgDevice.getRoad()); + this.setPosition(pgDevice.getPosition()); + this.setDevType(pgDevice.getDevType()); this.setDevCode(pgDevice.getDevCode()); - this.setDevName(pgDevice.getDevName()); - this.setBrand(pgDevice.getBrand()); - this.setOwnerUnit(pgDevice.getOwnerUnit()); - this.setInstallDate(sdf.format(pgDevice.getInstallDate())); + this.setAssetName(pgDevice.getAssetName()); + this.setAssetCode(pgDevice.getAssetCode()); + this.setAssetBarCode(pgDevice.getAssetBarCode()); + this.setId(pgDevice.getIp()); + this.setModBus(pgDevice.getModBus()); + this.setMome(pgDevice.getMome()); this.setIsOpen(String.valueOf(pgDevice.getIsOpen())); this.setActive(String.valueOf(pgDevice.getActive())); - this.setPipeGallery(pgDevice.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgDevice.getPgPartitionId().getParName()); + } - -} - +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java index e8751d3..3acd0fa 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java @@ -11,7 +11,7 @@ private String id; private String parName;//分区名称 - private String pipeGallery;//管廊仓 + private String road;//所属道路 private String active;//状态位 @@ -31,14 +31,6 @@ this.parName = parName; } - public String getPipeGallery() { - return pipeGallery; - } - - public void setPipeGallery(String pipeGallery) { - this.pipeGallery = pipeGallery; - } - public String getActive() { return active; } @@ -47,11 +39,19 @@ this.active = active; } + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + public PgPartitionDto(PgPartition pgPartition) { this.setId(String.valueOf(pgPartition.getId())); this.setParName(pgPartition.getParName()); - this.setPipeGallery(pgPartition.getPipeGalleryId().getPgName()); + this.setRoad(pgPartition.getRoad()); this.setActive(String.valueOf(pgPartition.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java index 9b161bf..8b430dc 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java @@ -112,8 +112,8 @@ this.setEnterDate(sdf.format(pgPipeLine.getEnterDate())); this.setLayerNum(pgPipeLine.getLayerNum()); this.setDiameter(pgPipeLine.getDiameter()); - this.setPipeGallery(pgPipeLine.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgPipeLine.getPgPartitionId().getParName()); + this.setPipeGallery(pgPipeLine.getPipeGalleryId().getPgName()); + this.setPartition(pgPipeLine.getPipeGalleryId().getPgPartitionId().getParName()); this.setActive(String.valueOf(pgPipeLine.getActive())); } } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java index 03c580c..709dcea 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java @@ -103,8 +103,8 @@ this.setOwnerUnit(pgTexture.getOwnerUnit()); this.setBuildDate(sdf.format(pgTexture.getBuildDate())); this.setActive(String.valueOf(pgTexture.getActive())); - this.setPipeGallery(pgTexture.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgTexture.getPgPartitionId().getParName()); + this.setPipeGallery(pgTexture.getPipeGalleryId().getPgName()); + this.setPartition(pgTexture.getPipeGalleryId().getPgPartitionId().getParName()); } } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java index b40ce84..319cf21 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java @@ -11,6 +11,7 @@ private String id; private String pgName;//管廊名称 + private String pgPartition;//分区名称 private String active;//状态位 public String getId() { @@ -37,10 +38,19 @@ this.active = active; } + public String getPgPartition() { + return pgPartition; + } + + public void setPgPartition(String pgPartition) { + this.pgPartition = pgPartition; + } + public PipeGalleryDto(PipeGallery pipeGallery) { this.setId(String.valueOf(pipeGallery.getId())); this.setPgName(pipeGallery.getPgName()); + this.setPgPartition(pipeGallery.getPgPartitionId().getParName()); this.setActive(String.valueOf(pipeGallery.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java b/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java index 8b413e7..0c594e7 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java @@ -5,10 +5,10 @@ import com.casic.PgInterface.devTable.domain.PipeGallery; import com.casic.PgInterface.devTable.dto.PgPartitionDto; import org.hibernate.Criteria; +import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; -import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; @@ -18,44 +18,50 @@ @Service public class PgPartitionManager extends HibernateEntityDao { - private PipeGalleryManager pipeGalleryManager; - - @Resource - public void setPipeGalleryManager(PipeGalleryManager pipeGalleryManager) { - this.pipeGalleryManager = pipeGalleryManager; - } - - public PgPartition getPartitionByParName(String parName,PipeGallery pipeGallery) { - if(pipeGallery==null) - return null; - Criteria criteria = getSession().createCriteria(PgPartition.class); + public PgPartition getPartitionByParName(String parName) { + Criteria criteria = getSession().createCriteria(PipeGallery.class); criteria.add(Restrictions.eq("parName", parName)); - criteria.add(Restrictions.eq("pipeGalleryId",pipeGallery)); + criteria.add(Restrictions.eq("active",1)); List pgPartitionList = criteria.list(); - //TODO LIST:为空判断 pgPartitionList==null? if (pgPartitionList != null && pgPartitionList.size() > 0) return pgPartitionList.get(0); else return null; } - public List getPartitionByPG(String pgName){ - PipeGallery pipeGallery=pipeGalleryManager.getPipeGalleryByPgName(pgName); - - Criteria criteria=getSession().createCriteria(PgPartition.class); - criteria.add(Restrictions.eq("pipeGalleryId",pipeGallery)); + public List getPartitionByRoad(String road) { + Criteria criteria = getSession().createCriteria(PipeGallery.class); + criteria.add(Restrictions.eq("road", road)); + criteria.add(Restrictions.eq("active",1)); List pgPartitionList = criteria.list(); List pgPartitionDtoList=new ArrayList(); - for(PgPartition pgPartition:pgPartitionList) - { - pgPartitionDtoList.add(new PgPartitionDto(pgPartition)); - } + for(PgPartition pgPartition:pgPartitionList) { + pgPartitionDtoList.add(new PgPartitionDto(pgPartition)); + } return pgPartitionDtoList; } + public List getPgPartitionDtoList() + { + Criteria criteria=getSession().createCriteria(PgPartition.class); + criteria.add(Restrictions.eq("active",1)); + criteria.addOrder(Order.desc("id")); + + List pgPartitionList=criteria.list(); + if(pgPartitionList.size()==0||pgPartitionList==null) + return null; + List pgPartitionDtoList=new ArrayList(); + for(PgPartition pgPartition:pgPartitionList) { + pgPartitionDtoList.add(new PgPartitionDto(pgPartition)); + } + return pgPartitionDtoList; + } + + + } diff --git a/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java b/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java index 16370c6..9bce32b 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java @@ -1,14 +1,16 @@ package com.casic.PgInterface.devTable.manager; import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.devTable.domain.PgPartition; import com.casic.PgInterface.devTable.domain.PipeGallery; import com.casic.PgInterface.devTable.dto.PipeGalleryDto; import org.hibernate.Criteria; -import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; -import java.util.*; +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; /** * Created by yxw on 2017/11/4. @@ -16,36 +18,44 @@ @Service public class PipeGalleryManager extends HibernateEntityDao { - public PipeGallery getPipeGalleryByPgName(String pgName) { - Criteria criteria = getSession().createCriteria(PipeGallery.class); + private PgPartitionManager pgPartitionManager; + + @Resource + public void setPgPartitionManager(PgPartitionManager pgPartitionManager) { + this.pgPartitionManager = pgPartitionManager; + } + + public PipeGallery getPipeGalleryByPgName(String pgName,PgPartition pgPartition) { + if(pgPartition==null) + return null; + Criteria criteria = getSession().createCriteria(PgPartition.class); criteria.add(Restrictions.eq("pgName", pgName)); - criteria.add(Restrictions.eq("active",1)); + criteria.add(Restrictions.eq("pgPartitionId",pgPartition)); List pipeGalleryList = criteria.list(); - //TODO LIST:为空判断 pipeGalleryList==null? + //TODO LIST:为空判断 pgPartitionList==null? if (pipeGalleryList != null && pipeGalleryList.size() > 0) return pipeGalleryList.get(0); else return null; } - public List getPIpeGalleryDtoList() - { - Criteria criteria=getSession().createCriteria(PipeGallery.class); - criteria.add(Restrictions.eq("active",1)); - criteria.addOrder(Order.desc("id")); - List pipeGalleryList=criteria.list(); - if(pipeGalleryList.size()==0||pipeGalleryList==null) - return null; - List pipeGalleryDtoList=new ArrayList(); - for(PipeGallery pipeGallery:pipeGalleryList) { + public List getPipeGalleryByParName(String parName) { + + PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName); + Criteria criteria = getSession().createCriteria(PipeGallery.class); + criteria.add(Restrictions.eq("pgPartitionId", pgPartition)); + + List pipeGalleryList = criteria.list(); + + List pipeGalleryDtoList = new ArrayList(); + for (PipeGallery pipeGallery : pipeGalleryList) { pipeGalleryDtoList.add(new PipeGalleryDto(pipeGallery)); } + return pipeGalleryDtoList; } - - } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java new file mode 100644 index 0000000..9d06235 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java @@ -0,0 +1,63 @@ +package com.casic.PgInterface.patroler.domain; + +import com.casic.PgInterface.devTable.domain.PgDevice; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + +import javax.persistence.*; +import java.io.Serializable; + +/** + * Created by yxw on 2017/12/14. + */ +@Entity +@Table(name = "PG_ALARM_RULE") +@SequenceGenerator(name = "SEQ_PG_ALARM_RULE_ID", sequenceName = "SEQ_PG_ALARM_RULE_ID",allocationSize=1,initialValue=1) +public class PgAlarmRule implements Serializable { + + private static final long serialVersionUID = 1L; + private long id; + private String highValue;//高限 + private String lowValue;//低限 + private PgDevice pgDeviceId;//设备 + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_ALARM_RULE_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "HIGHVALUE") + public String getHighValue() { + return highValue; + } + + public void setHighValue(String highValue) { + this.highValue = highValue; + } + + @Column(name = "LOWVALUE") + public String getLowValue() { + return lowValue; + } + + public void setLowValue(String lowValue) { + this.lowValue = lowValue; + } + + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "PGDEVICEID") + public PgDevice getPgDeviceId() { + return pgDeviceId; + } + + public void setPgDeviceId(PgDevice pgDeviceId) { + this.pgDeviceId = pgDeviceId; + } + +} diff --git a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java index 80625c7..d8f5e6b 100644 --- a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java +++ b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java @@ -43,9 +43,7 @@ this.intoTime = intoTime; } - @Column(name = "OUT_TIME") - public Date getOutTime() { return outTime; } diff --git a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java index a99981e..b1d63a4 100644 --- a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java +++ b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java @@ -1,11 +1,28 @@ package com.casic.PgInterface.devData.manager; +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.core.util.DateUtils; +import com.casic.PgInterface.core.util.StringUtils; +import com.casic.PgInterface.devData.domain.PgCo; +import com.casic.PgInterface.devData.domain.PgLocation; +import com.casic.PgInterface.devData.dto.PgCoDto; +import com.casic.PgInterface.devData.dto.PgLocationDto; +import com.casic.PgInterface.devTable.domain.PgDevice; +import org.hibernate.Criteria; +import org.hibernate.criterion.Order; +import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; + /** * Created by yxw on 2017/11/2. */ @Service -public class PgLocationManager { +public class PgLocationManager extends HibernateEntityDao { + + //获取设备时间段内所有的监测数据 } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java index cfa0281..7fb5953 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -1,12 +1,12 @@ package com.casic.PgInterface.devTable.domain; import com.casic.PgInterface.devData.domain.*; +import com.casic.PgInterface.patroler.domain.PgAlarmRule; import org.hibernate.annotations.NotFound; import org.hibernate.annotations.NotFoundAction; import javax.persistence.*; import java.io.Serializable; -import java.util.Date; import java.util.List; /** @@ -19,21 +19,27 @@ private static final long serialVersionUID = 1L; private long id; + private PipeGallery pipeGalleryId;//所在管廊信息 + private String road;//路名 + private String position;//设备位置 + private String devType;//设备类型 private String devCode;//设备编号 - private String devName;//设备名称 - private String brand;//品牌 - private String ownerUnit;//权属单位 - private Date installDate;//安装时间 + private String assetName;//资产名称 + private String assetCode;//资产编码 + private String assetBarCode;//资产条码 + private String ip;//IP地址 + private String modBus;//modBus地址 + private String mome;//备注 private int isOpen;//设备是否开启 private int active;//状态位 - private PgDeviceType devTypeId;//设备类型 + private List pgAlarms; - private PgPartition pgPartitionId;//所在管廊信息 private List pgTempHums;//温湿度 private List pgCos;//一氧化碳 private List pgO2s;//氧气 private List pgCh4s;//甲烷 private List pgShs;//硫化氢 + private List pgAlarmRules;//报警规则 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") @@ -45,6 +51,33 @@ this.id = id; } + @Column(name = "ROAD") + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + @Column(name = "POSITION") + public String getPosition() { + return position; + } + + public void setPosition(String position) { + this.position = position; + } + + @Column(name = "DEV_TYPE") + public String getDevType() { + return devType; + } + + public void setDevType(String devType) { + this.devType = devType; + } + @Column(name = "DEV_CODE") public String getDevCode() { return devCode; @@ -54,40 +87,58 @@ this.devCode = devCode; } - @Column(name = "DEV_NAME") - public String getDevName() { - return devName; + @Column(name = "ASSET_NAME") + public String getAssetName() { + return assetName; } - public void setDevName(String devName) { - this.devName = devName; + public void setAssetName(String assetName) { + this.assetName = assetName; } - @Column(name = "BRAND") - public String getBrand() { - return brand; + @Column(name = "ASSET_CODE") + public String getAssetCode() { + return assetCode; } - public void setBrand(String brand) { - this.brand = brand; + public void setAssetCode(String assetCode) { + this.assetCode = assetCode; } - @Column(name = "OWNERUNIT") - public String getOwnerUnit() { - return ownerUnit; + @Column(name = "ASSET_BAR_CODE") + public String getAssetBarCode() { + return assetBarCode; } - public void setOwnerUnit(String ownerUnit) { - this.ownerUnit = ownerUnit; + public void setAssetBarCode(String assetBarCode) { + this.assetBarCode = assetBarCode; } - @Column(name = "INSTALDATE") - public Date getInstallDate() { - return installDate; + @Column(name = "IP") + public String getIp() { + return ip; } - public void setInstallDate(Date installDate) { - this.installDate = installDate; + public void setIp(String ip) { + this.ip = ip; + } + + @Column(name = "MODBUS") + public String getModBus() { + return modBus; + } + + public void setModBus(String modBus) { + this.modBus = modBus; + } + + @Column(name = "MOME") + public String getMome() { + return mome; + } + + public void setMome(String mome) { + this.mome = mome; } @Column(name = "ISOPEN") @@ -119,24 +170,13 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; - } - - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "DEVICE_TYPE_ID") - public PgDeviceType getDevTypeId() { - return devTypeId; - } - - public void setDevTypeId(PgDeviceType devTypeId) { - this.devTypeId = devTypeId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgDeviceId") @@ -184,4 +224,13 @@ this.pgShs = pgShs; } + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgDeviceId") + public List getPgAlarmRules() { + return pgAlarmRules; + } + + public void setPgAlarmRules(List pgAlarmRules) { + this.pgAlarmRules = pgAlarmRules; + } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java index b997b29..4fb3d6f 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java @@ -1,8 +1,5 @@ package com.casic.PgInterface.devTable.domain; -import org.hibernate.annotations.NotFound; -import org.hibernate.annotations.NotFoundAction; - import javax.persistence.*; import java.io.Serializable; import java.util.List; @@ -19,11 +16,9 @@ private long id; private String parName;//分区名称 - private PipeGallery pipeGalleryId;//管廊仓 + private String road;//所属道路 private int active;//状态位 - private List pgTextureList; - private List pgPipeLineList; - private List pgDeviceList; + private List pipeGalleryList;//管廊仓 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PARTITION_ID") @@ -44,6 +39,15 @@ this.parName = parName; } + @Column(name = "ROAD") + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + @Column(name = "ACTIVE") public int getActive() { return active; @@ -53,41 +57,14 @@ this.active = active; } - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PIPEGALLERYID") - public PipeGallery getPipeGalleryId() { - return pipeGalleryId; - } - - public void setPipeGalleryId(PipeGallery pipeGalleryId) { - this.pipeGalleryId = pipeGalleryId; - } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgTextureList() { - return pgTextureList; + public List getPipeGalleryList() { + return pipeGalleryList; } - public void setPgTextureList(List pgTextureList) { - this.pgTextureList = pgTextureList; + public void setPipeGalleryList(List pipeGalleryList) { + this.pipeGalleryList = pipeGalleryList; } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgPipeLineList() { - return pgPipeLineList; - } - public void setPgPipeLineList(List pgPipeLineList) { - this.pgPipeLineList = pgPipeLineList; - } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgDeviceList() { - return pgDeviceList; - } - - public void setPgDeviceList(List pgDeviceList) { - this.pgDeviceList = pgDeviceList; - } } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java index d936d18..e5ff9b3 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java @@ -22,7 +22,7 @@ private Date enterDate;//入廊时间 private String layerNum;//所在层数 private String diameter;//管径 - private PgPartition pgPartitionId;//所在管廊信息 + private PipeGallery pipeGalleryId;//所在管廊信息 private int active;//状态位 @Id @@ -100,12 +100,12 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java index 1f22bf9..4ebfbda 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java @@ -21,7 +21,7 @@ private String ownerUnit;//权属单位 private Date buildDate;//建设年代 private int active;//状态位 - private PgPartition pgPartitionId;//所在管廊信息 + private PipeGallery pipeGalleryId;//所在管廊信息 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_TEXTURE_ID") @@ -91,12 +91,13 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java b/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java index 49a246c..650d623 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java @@ -1,5 +1,8 @@ package com.casic.PgInterface.devTable.domain; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + import javax.persistence.*; import java.io.Serializable; import java.util.List; @@ -16,7 +19,10 @@ private long id; private String pgName;//管廊名称 private int active;//状态位 - private List partitionList; + private PgPartition pgPartitionId;// + private List pgTextureList; + private List pgPipeLineList; + private List pgDeviceList; @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PIPE_GALLERY_ID") @@ -46,12 +52,42 @@ this.active = active; } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") - public List getPartitionList() { - return partitionList; + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "PARTITIONID") + public PgPartition getPgPartitionId() { + return pgPartitionId; } - public void setPartitionList(List partitionList) { - this.partitionList = partitionList; + public void setPgPartitionId(PgPartition pgPartitionId) { + this.pgPartitionId = pgPartitionId; } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgTextureList() { + return pgTextureList; + } + + public void setPgTextureList(List pgTextureList) { + this.pgTextureList = pgTextureList; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgPipeLineList() { + return pgPipeLineList; + } + + public void setPgPipeLineList(List pgPipeLineList) { + this.pgPipeLineList = pgPipeLineList; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgDeviceList() { + return pgDeviceList; + } + + public void setPgDeviceList(List pgDeviceList) { + this.pgDeviceList = pgDeviceList; + } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java index b4048d9..c3dfc55 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java @@ -101,18 +101,17 @@ this.active = active; } - public PgAlarmDto(PgAlarm pgAlarm) - { - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + public PgAlarmDto(PgAlarm pgAlarm) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); this.setId(String.valueOf(pgAlarm.getId())); this.setAlarmType(pgAlarm.getAlarmTypeId().getAlarmType()); this.setAlarmValue(pgAlarm.getAlarmValue()); this.setAlarmDate(sdf.format(pgAlarm.getAlarmDate())); this.setDescription(pgAlarm.getDescription()); - this.setAlarmDevName(pgAlarm.getAlarmDevId().getDevName()); - this.setAlarmLocation(pgAlarm.getAlarmDevId().getPgPartitionId().getPipeGalleryId().getPgName() - + pgAlarm.getAlarmDevId().getPgPartitionId().getParName()); + this.setAlarmDevName(pgAlarm.getAlarmDevId().getAssetName()); + this.setAlarmLocation(pgAlarm.getAlarmDevId().getPipeGalleryId().getPgPartitionId().getParName() + + pgAlarm.getAlarmDevId().getPipeGalleryId().getPgName()); this.setUserName(pgAlarm.getPatrolerId().getUserName()); this.setPhoneNumber(pgAlarm.getPatrolerId().getPhoneNumber()); this.setActive(String.valueOf(pgAlarm.getActive())); diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java index ae76e95..49bd436 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java @@ -11,16 +11,20 @@ public class PgDeviceDto implements Serializable { private String id; - private String devType;//设备类型 - private String devCode;//设备编号 - private String devName;//设备名称 - private String brand;//品牌 - private String ownerUnit;//权属单位 - private String installDate;//安装时间 - private String isOpen;//设备开启状态 - private String active;//状态位 private String pipeGallery;//仓位 private String partition;//分区 + private String road;//路名 + private String position;//设备位置 + private String devType;//设备类型 + private String devCode;//设备编号 + private String assetName;//资产名称 + private String assetCode;//资产名称 + private String assetBarCode;//资产条码 + private String ip;//IP地址 + private String modBus;//modBus地址 + private String mome;//备注 + private String isOpen;//设备开启状态 + private String active;//状态位 public String getId() { return id; @@ -30,6 +34,38 @@ this.id = id; } + public String getPartition() { + return partition; + } + + public void setPartition(String partition) { + this.partition = partition; + } + + public String getPipeGallery() { + return pipeGallery; + } + + public void setPipeGallery(String pipeGallery) { + this.pipeGallery = pipeGallery; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getPosition() { + return position; + } + + public void setPosition(String position) { + this.position = position; + } + public String getDevType() { return devType; } @@ -46,36 +82,52 @@ this.devCode = devCode; } - public String getDevName() { - return devName; + public String getAssetName() { + return assetName; } - public void setDevName(String devName) { - this.devName = devName; + public void setAssetName(String assetName) { + this.assetName = assetName; } - public String getBrand() { - return brand; + public String getAssetCode() { + return assetCode; } - public void setBrand(String brand) { - this.brand = brand; + public void setAssetCode(String assetCode) { + this.assetCode = assetCode; } - public String getOwnerUnit() { - return ownerUnit; + public String getAssetBarCode() { + return assetBarCode; } - public void setOwnerUnit(String ownerUnit) { - this.ownerUnit = ownerUnit; + public void setAssetBarCode(String assetBarCode) { + this.assetBarCode = assetBarCode; } - public String getInstallDate() { - return installDate; + public String getIp() { + return ip; } - public void setInstallDate(String installDate) { - this.installDate = installDate; + public void setIp(String ip) { + this.ip = ip; + } + + public String getModBus() { + return modBus; + } + + public void setModBus(String modBus) { + this.modBus = modBus; + } + + public String getMome() { + return mome; + } + + public void setMome(String mome) { + this.mome = mome; } public String getIsOpen() { @@ -94,39 +146,26 @@ this.active = active; } - public String getPipeGallery() { - return pipeGallery; - } - - public void setPipeGallery(String pipeGallery) { - this.pipeGallery = pipeGallery; - } - - public String getPartition() { - return partition; - } - - public void setPartition(String partition) { - this.partition = partition; - } - public PgDeviceDto(PgDevice pgDevice) { SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); this.setId(String.valueOf(pgDevice.getId())); - this.setDevType(pgDevice.getDevTypeId().getDevType()); + this.setPipeGallery(pgDevice.getPipeGalleryId().getPgName()); + this.setPartition(pgDevice.getPipeGalleryId().getPgPartitionId().getParName()); + this.setRoad(pgDevice.getRoad()); + this.setPosition(pgDevice.getPosition()); + this.setDevType(pgDevice.getDevType()); this.setDevCode(pgDevice.getDevCode()); - this.setDevName(pgDevice.getDevName()); - this.setBrand(pgDevice.getBrand()); - this.setOwnerUnit(pgDevice.getOwnerUnit()); - this.setInstallDate(sdf.format(pgDevice.getInstallDate())); + this.setAssetName(pgDevice.getAssetName()); + this.setAssetCode(pgDevice.getAssetCode()); + this.setAssetBarCode(pgDevice.getAssetBarCode()); + this.setId(pgDevice.getIp()); + this.setModBus(pgDevice.getModBus()); + this.setMome(pgDevice.getMome()); this.setIsOpen(String.valueOf(pgDevice.getIsOpen())); this.setActive(String.valueOf(pgDevice.getActive())); - this.setPipeGallery(pgDevice.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgDevice.getPgPartitionId().getParName()); + } - -} - +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java index e8751d3..3acd0fa 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java @@ -11,7 +11,7 @@ private String id; private String parName;//分区名称 - private String pipeGallery;//管廊仓 + private String road;//所属道路 private String active;//状态位 @@ -31,14 +31,6 @@ this.parName = parName; } - public String getPipeGallery() { - return pipeGallery; - } - - public void setPipeGallery(String pipeGallery) { - this.pipeGallery = pipeGallery; - } - public String getActive() { return active; } @@ -47,11 +39,19 @@ this.active = active; } + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + public PgPartitionDto(PgPartition pgPartition) { this.setId(String.valueOf(pgPartition.getId())); this.setParName(pgPartition.getParName()); - this.setPipeGallery(pgPartition.getPipeGalleryId().getPgName()); + this.setRoad(pgPartition.getRoad()); this.setActive(String.valueOf(pgPartition.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java index 9b161bf..8b430dc 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java @@ -112,8 +112,8 @@ this.setEnterDate(sdf.format(pgPipeLine.getEnterDate())); this.setLayerNum(pgPipeLine.getLayerNum()); this.setDiameter(pgPipeLine.getDiameter()); - this.setPipeGallery(pgPipeLine.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgPipeLine.getPgPartitionId().getParName()); + this.setPipeGallery(pgPipeLine.getPipeGalleryId().getPgName()); + this.setPartition(pgPipeLine.getPipeGalleryId().getPgPartitionId().getParName()); this.setActive(String.valueOf(pgPipeLine.getActive())); } } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java index 03c580c..709dcea 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java @@ -103,8 +103,8 @@ this.setOwnerUnit(pgTexture.getOwnerUnit()); this.setBuildDate(sdf.format(pgTexture.getBuildDate())); this.setActive(String.valueOf(pgTexture.getActive())); - this.setPipeGallery(pgTexture.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgTexture.getPgPartitionId().getParName()); + this.setPipeGallery(pgTexture.getPipeGalleryId().getPgName()); + this.setPartition(pgTexture.getPipeGalleryId().getPgPartitionId().getParName()); } } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java index b40ce84..319cf21 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java @@ -11,6 +11,7 @@ private String id; private String pgName;//管廊名称 + private String pgPartition;//分区名称 private String active;//状态位 public String getId() { @@ -37,10 +38,19 @@ this.active = active; } + public String getPgPartition() { + return pgPartition; + } + + public void setPgPartition(String pgPartition) { + this.pgPartition = pgPartition; + } + public PipeGalleryDto(PipeGallery pipeGallery) { this.setId(String.valueOf(pipeGallery.getId())); this.setPgName(pipeGallery.getPgName()); + this.setPgPartition(pipeGallery.getPgPartitionId().getParName()); this.setActive(String.valueOf(pipeGallery.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java b/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java index 8b413e7..0c594e7 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java @@ -5,10 +5,10 @@ import com.casic.PgInterface.devTable.domain.PipeGallery; import com.casic.PgInterface.devTable.dto.PgPartitionDto; import org.hibernate.Criteria; +import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; -import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; @@ -18,44 +18,50 @@ @Service public class PgPartitionManager extends HibernateEntityDao { - private PipeGalleryManager pipeGalleryManager; - - @Resource - public void setPipeGalleryManager(PipeGalleryManager pipeGalleryManager) { - this.pipeGalleryManager = pipeGalleryManager; - } - - public PgPartition getPartitionByParName(String parName,PipeGallery pipeGallery) { - if(pipeGallery==null) - return null; - Criteria criteria = getSession().createCriteria(PgPartition.class); + public PgPartition getPartitionByParName(String parName) { + Criteria criteria = getSession().createCriteria(PipeGallery.class); criteria.add(Restrictions.eq("parName", parName)); - criteria.add(Restrictions.eq("pipeGalleryId",pipeGallery)); + criteria.add(Restrictions.eq("active",1)); List pgPartitionList = criteria.list(); - //TODO LIST:为空判断 pgPartitionList==null? if (pgPartitionList != null && pgPartitionList.size() > 0) return pgPartitionList.get(0); else return null; } - public List getPartitionByPG(String pgName){ - PipeGallery pipeGallery=pipeGalleryManager.getPipeGalleryByPgName(pgName); - - Criteria criteria=getSession().createCriteria(PgPartition.class); - criteria.add(Restrictions.eq("pipeGalleryId",pipeGallery)); + public List getPartitionByRoad(String road) { + Criteria criteria = getSession().createCriteria(PipeGallery.class); + criteria.add(Restrictions.eq("road", road)); + criteria.add(Restrictions.eq("active",1)); List pgPartitionList = criteria.list(); List pgPartitionDtoList=new ArrayList(); - for(PgPartition pgPartition:pgPartitionList) - { - pgPartitionDtoList.add(new PgPartitionDto(pgPartition)); - } + for(PgPartition pgPartition:pgPartitionList) { + pgPartitionDtoList.add(new PgPartitionDto(pgPartition)); + } return pgPartitionDtoList; } + public List getPgPartitionDtoList() + { + Criteria criteria=getSession().createCriteria(PgPartition.class); + criteria.add(Restrictions.eq("active",1)); + criteria.addOrder(Order.desc("id")); + + List pgPartitionList=criteria.list(); + if(pgPartitionList.size()==0||pgPartitionList==null) + return null; + List pgPartitionDtoList=new ArrayList(); + for(PgPartition pgPartition:pgPartitionList) { + pgPartitionDtoList.add(new PgPartitionDto(pgPartition)); + } + return pgPartitionDtoList; + } + + + } diff --git a/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java b/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java index 16370c6..9bce32b 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java @@ -1,14 +1,16 @@ package com.casic.PgInterface.devTable.manager; import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.devTable.domain.PgPartition; import com.casic.PgInterface.devTable.domain.PipeGallery; import com.casic.PgInterface.devTable.dto.PipeGalleryDto; import org.hibernate.Criteria; -import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; -import java.util.*; +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; /** * Created by yxw on 2017/11/4. @@ -16,36 +18,44 @@ @Service public class PipeGalleryManager extends HibernateEntityDao { - public PipeGallery getPipeGalleryByPgName(String pgName) { - Criteria criteria = getSession().createCriteria(PipeGallery.class); + private PgPartitionManager pgPartitionManager; + + @Resource + public void setPgPartitionManager(PgPartitionManager pgPartitionManager) { + this.pgPartitionManager = pgPartitionManager; + } + + public PipeGallery getPipeGalleryByPgName(String pgName,PgPartition pgPartition) { + if(pgPartition==null) + return null; + Criteria criteria = getSession().createCriteria(PgPartition.class); criteria.add(Restrictions.eq("pgName", pgName)); - criteria.add(Restrictions.eq("active",1)); + criteria.add(Restrictions.eq("pgPartitionId",pgPartition)); List pipeGalleryList = criteria.list(); - //TODO LIST:为空判断 pipeGalleryList==null? + //TODO LIST:为空判断 pgPartitionList==null? if (pipeGalleryList != null && pipeGalleryList.size() > 0) return pipeGalleryList.get(0); else return null; } - public List getPIpeGalleryDtoList() - { - Criteria criteria=getSession().createCriteria(PipeGallery.class); - criteria.add(Restrictions.eq("active",1)); - criteria.addOrder(Order.desc("id")); - List pipeGalleryList=criteria.list(); - if(pipeGalleryList.size()==0||pipeGalleryList==null) - return null; - List pipeGalleryDtoList=new ArrayList(); - for(PipeGallery pipeGallery:pipeGalleryList) { + public List getPipeGalleryByParName(String parName) { + + PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName); + Criteria criteria = getSession().createCriteria(PipeGallery.class); + criteria.add(Restrictions.eq("pgPartitionId", pgPartition)); + + List pipeGalleryList = criteria.list(); + + List pipeGalleryDtoList = new ArrayList(); + for (PipeGallery pipeGallery : pipeGalleryList) { pipeGalleryDtoList.add(new PipeGalleryDto(pipeGallery)); } + return pipeGalleryDtoList; } - - } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java new file mode 100644 index 0000000..9d06235 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java @@ -0,0 +1,63 @@ +package com.casic.PgInterface.patroler.domain; + +import com.casic.PgInterface.devTable.domain.PgDevice; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + +import javax.persistence.*; +import java.io.Serializable; + +/** + * Created by yxw on 2017/12/14. + */ +@Entity +@Table(name = "PG_ALARM_RULE") +@SequenceGenerator(name = "SEQ_PG_ALARM_RULE_ID", sequenceName = "SEQ_PG_ALARM_RULE_ID",allocationSize=1,initialValue=1) +public class PgAlarmRule implements Serializable { + + private static final long serialVersionUID = 1L; + private long id; + private String highValue;//高限 + private String lowValue;//低限 + private PgDevice pgDeviceId;//设备 + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_ALARM_RULE_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "HIGHVALUE") + public String getHighValue() { + return highValue; + } + + public void setHighValue(String highValue) { + this.highValue = highValue; + } + + @Column(name = "LOWVALUE") + public String getLowValue() { + return lowValue; + } + + public void setLowValue(String lowValue) { + this.lowValue = lowValue; + } + + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "PGDEVICEID") + public PgDevice getPgDeviceId() { + return pgDeviceId; + } + + public void setPgDeviceId(PgDevice pgDeviceId) { + this.pgDeviceId = pgDeviceId; + } + +} diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java new file mode 100644 index 0000000..8367ad4 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java @@ -0,0 +1,57 @@ +package com.casic.PgInterface.patroler.dto; + +import com.casic.PgInterface.patroler.domain.PgAlarmRule; + +import java.io.Serializable; + +/** + * Created by yxw on 2017/12/14. + */ +public class PgAlarmRuleDto implements Serializable { + + private String id; + private String highValue;//高限 + private String lowValue;//低限 + private String devName;//设备 + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getHighValue() { + return highValue; + } + + public void setHighValue(String highValue) { + this.highValue = highValue; + } + + public String getLowValue() { + return lowValue; + } + + public void setLowValue(String lowValue) { + this.lowValue = lowValue; + } + + public String getDevName() { + return devName; + } + + public void setDevName(String devName) { + this.devName = devName; + } + + public PgAlarmRuleDto(PgAlarmRule pgAlarmRule) + { + this.setId(String.valueOf(pgAlarmRule.getId())); + this.setDevName(pgAlarmRule.getPgDeviceId().getAssetName()); + this.setHighValue(pgAlarmRule.getHighValue()); + this.setLowValue(pgAlarmRule.getLowValue()); + } + +} diff --git a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java index 80625c7..d8f5e6b 100644 --- a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java +++ b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java @@ -43,9 +43,7 @@ this.intoTime = intoTime; } - @Column(name = "OUT_TIME") - public Date getOutTime() { return outTime; } diff --git a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java index a99981e..b1d63a4 100644 --- a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java +++ b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java @@ -1,11 +1,28 @@ package com.casic.PgInterface.devData.manager; +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.core.util.DateUtils; +import com.casic.PgInterface.core.util.StringUtils; +import com.casic.PgInterface.devData.domain.PgCo; +import com.casic.PgInterface.devData.domain.PgLocation; +import com.casic.PgInterface.devData.dto.PgCoDto; +import com.casic.PgInterface.devData.dto.PgLocationDto; +import com.casic.PgInterface.devTable.domain.PgDevice; +import org.hibernate.Criteria; +import org.hibernate.criterion.Order; +import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; + /** * Created by yxw on 2017/11/2. */ @Service -public class PgLocationManager { +public class PgLocationManager extends HibernateEntityDao { + + //获取设备时间段内所有的监测数据 } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java index cfa0281..7fb5953 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -1,12 +1,12 @@ package com.casic.PgInterface.devTable.domain; import com.casic.PgInterface.devData.domain.*; +import com.casic.PgInterface.patroler.domain.PgAlarmRule; import org.hibernate.annotations.NotFound; import org.hibernate.annotations.NotFoundAction; import javax.persistence.*; import java.io.Serializable; -import java.util.Date; import java.util.List; /** @@ -19,21 +19,27 @@ private static final long serialVersionUID = 1L; private long id; + private PipeGallery pipeGalleryId;//所在管廊信息 + private String road;//路名 + private String position;//设备位置 + private String devType;//设备类型 private String devCode;//设备编号 - private String devName;//设备名称 - private String brand;//品牌 - private String ownerUnit;//权属单位 - private Date installDate;//安装时间 + private String assetName;//资产名称 + private String assetCode;//资产编码 + private String assetBarCode;//资产条码 + private String ip;//IP地址 + private String modBus;//modBus地址 + private String mome;//备注 private int isOpen;//设备是否开启 private int active;//状态位 - private PgDeviceType devTypeId;//设备类型 + private List pgAlarms; - private PgPartition pgPartitionId;//所在管廊信息 private List pgTempHums;//温湿度 private List pgCos;//一氧化碳 private List pgO2s;//氧气 private List pgCh4s;//甲烷 private List pgShs;//硫化氢 + private List pgAlarmRules;//报警规则 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") @@ -45,6 +51,33 @@ this.id = id; } + @Column(name = "ROAD") + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + @Column(name = "POSITION") + public String getPosition() { + return position; + } + + public void setPosition(String position) { + this.position = position; + } + + @Column(name = "DEV_TYPE") + public String getDevType() { + return devType; + } + + public void setDevType(String devType) { + this.devType = devType; + } + @Column(name = "DEV_CODE") public String getDevCode() { return devCode; @@ -54,40 +87,58 @@ this.devCode = devCode; } - @Column(name = "DEV_NAME") - public String getDevName() { - return devName; + @Column(name = "ASSET_NAME") + public String getAssetName() { + return assetName; } - public void setDevName(String devName) { - this.devName = devName; + public void setAssetName(String assetName) { + this.assetName = assetName; } - @Column(name = "BRAND") - public String getBrand() { - return brand; + @Column(name = "ASSET_CODE") + public String getAssetCode() { + return assetCode; } - public void setBrand(String brand) { - this.brand = brand; + public void setAssetCode(String assetCode) { + this.assetCode = assetCode; } - @Column(name = "OWNERUNIT") - public String getOwnerUnit() { - return ownerUnit; + @Column(name = "ASSET_BAR_CODE") + public String getAssetBarCode() { + return assetBarCode; } - public void setOwnerUnit(String ownerUnit) { - this.ownerUnit = ownerUnit; + public void setAssetBarCode(String assetBarCode) { + this.assetBarCode = assetBarCode; } - @Column(name = "INSTALDATE") - public Date getInstallDate() { - return installDate; + @Column(name = "IP") + public String getIp() { + return ip; } - public void setInstallDate(Date installDate) { - this.installDate = installDate; + public void setIp(String ip) { + this.ip = ip; + } + + @Column(name = "MODBUS") + public String getModBus() { + return modBus; + } + + public void setModBus(String modBus) { + this.modBus = modBus; + } + + @Column(name = "MOME") + public String getMome() { + return mome; + } + + public void setMome(String mome) { + this.mome = mome; } @Column(name = "ISOPEN") @@ -119,24 +170,13 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; - } - - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "DEVICE_TYPE_ID") - public PgDeviceType getDevTypeId() { - return devTypeId; - } - - public void setDevTypeId(PgDeviceType devTypeId) { - this.devTypeId = devTypeId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgDeviceId") @@ -184,4 +224,13 @@ this.pgShs = pgShs; } + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgDeviceId") + public List getPgAlarmRules() { + return pgAlarmRules; + } + + public void setPgAlarmRules(List pgAlarmRules) { + this.pgAlarmRules = pgAlarmRules; + } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java index b997b29..4fb3d6f 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java @@ -1,8 +1,5 @@ package com.casic.PgInterface.devTable.domain; -import org.hibernate.annotations.NotFound; -import org.hibernate.annotations.NotFoundAction; - import javax.persistence.*; import java.io.Serializable; import java.util.List; @@ -19,11 +16,9 @@ private long id; private String parName;//分区名称 - private PipeGallery pipeGalleryId;//管廊仓 + private String road;//所属道路 private int active;//状态位 - private List pgTextureList; - private List pgPipeLineList; - private List pgDeviceList; + private List pipeGalleryList;//管廊仓 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PARTITION_ID") @@ -44,6 +39,15 @@ this.parName = parName; } + @Column(name = "ROAD") + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + @Column(name = "ACTIVE") public int getActive() { return active; @@ -53,41 +57,14 @@ this.active = active; } - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PIPEGALLERYID") - public PipeGallery getPipeGalleryId() { - return pipeGalleryId; - } - - public void setPipeGalleryId(PipeGallery pipeGalleryId) { - this.pipeGalleryId = pipeGalleryId; - } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgTextureList() { - return pgTextureList; + public List getPipeGalleryList() { + return pipeGalleryList; } - public void setPgTextureList(List pgTextureList) { - this.pgTextureList = pgTextureList; + public void setPipeGalleryList(List pipeGalleryList) { + this.pipeGalleryList = pipeGalleryList; } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgPipeLineList() { - return pgPipeLineList; - } - public void setPgPipeLineList(List pgPipeLineList) { - this.pgPipeLineList = pgPipeLineList; - } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgDeviceList() { - return pgDeviceList; - } - - public void setPgDeviceList(List pgDeviceList) { - this.pgDeviceList = pgDeviceList; - } } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java index d936d18..e5ff9b3 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java @@ -22,7 +22,7 @@ private Date enterDate;//入廊时间 private String layerNum;//所在层数 private String diameter;//管径 - private PgPartition pgPartitionId;//所在管廊信息 + private PipeGallery pipeGalleryId;//所在管廊信息 private int active;//状态位 @Id @@ -100,12 +100,12 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java index 1f22bf9..4ebfbda 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java @@ -21,7 +21,7 @@ private String ownerUnit;//权属单位 private Date buildDate;//建设年代 private int active;//状态位 - private PgPartition pgPartitionId;//所在管廊信息 + private PipeGallery pipeGalleryId;//所在管廊信息 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_TEXTURE_ID") @@ -91,12 +91,13 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java b/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java index 49a246c..650d623 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java @@ -1,5 +1,8 @@ package com.casic.PgInterface.devTable.domain; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + import javax.persistence.*; import java.io.Serializable; import java.util.List; @@ -16,7 +19,10 @@ private long id; private String pgName;//管廊名称 private int active;//状态位 - private List partitionList; + private PgPartition pgPartitionId;// + private List pgTextureList; + private List pgPipeLineList; + private List pgDeviceList; @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PIPE_GALLERY_ID") @@ -46,12 +52,42 @@ this.active = active; } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") - public List getPartitionList() { - return partitionList; + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "PARTITIONID") + public PgPartition getPgPartitionId() { + return pgPartitionId; } - public void setPartitionList(List partitionList) { - this.partitionList = partitionList; + public void setPgPartitionId(PgPartition pgPartitionId) { + this.pgPartitionId = pgPartitionId; } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgTextureList() { + return pgTextureList; + } + + public void setPgTextureList(List pgTextureList) { + this.pgTextureList = pgTextureList; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgPipeLineList() { + return pgPipeLineList; + } + + public void setPgPipeLineList(List pgPipeLineList) { + this.pgPipeLineList = pgPipeLineList; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgDeviceList() { + return pgDeviceList; + } + + public void setPgDeviceList(List pgDeviceList) { + this.pgDeviceList = pgDeviceList; + } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java index b4048d9..c3dfc55 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java @@ -101,18 +101,17 @@ this.active = active; } - public PgAlarmDto(PgAlarm pgAlarm) - { - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + public PgAlarmDto(PgAlarm pgAlarm) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); this.setId(String.valueOf(pgAlarm.getId())); this.setAlarmType(pgAlarm.getAlarmTypeId().getAlarmType()); this.setAlarmValue(pgAlarm.getAlarmValue()); this.setAlarmDate(sdf.format(pgAlarm.getAlarmDate())); this.setDescription(pgAlarm.getDescription()); - this.setAlarmDevName(pgAlarm.getAlarmDevId().getDevName()); - this.setAlarmLocation(pgAlarm.getAlarmDevId().getPgPartitionId().getPipeGalleryId().getPgName() - + pgAlarm.getAlarmDevId().getPgPartitionId().getParName()); + this.setAlarmDevName(pgAlarm.getAlarmDevId().getAssetName()); + this.setAlarmLocation(pgAlarm.getAlarmDevId().getPipeGalleryId().getPgPartitionId().getParName() + + pgAlarm.getAlarmDevId().getPipeGalleryId().getPgName()); this.setUserName(pgAlarm.getPatrolerId().getUserName()); this.setPhoneNumber(pgAlarm.getPatrolerId().getPhoneNumber()); this.setActive(String.valueOf(pgAlarm.getActive())); diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java index ae76e95..49bd436 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java @@ -11,16 +11,20 @@ public class PgDeviceDto implements Serializable { private String id; - private String devType;//设备类型 - private String devCode;//设备编号 - private String devName;//设备名称 - private String brand;//品牌 - private String ownerUnit;//权属单位 - private String installDate;//安装时间 - private String isOpen;//设备开启状态 - private String active;//状态位 private String pipeGallery;//仓位 private String partition;//分区 + private String road;//路名 + private String position;//设备位置 + private String devType;//设备类型 + private String devCode;//设备编号 + private String assetName;//资产名称 + private String assetCode;//资产名称 + private String assetBarCode;//资产条码 + private String ip;//IP地址 + private String modBus;//modBus地址 + private String mome;//备注 + private String isOpen;//设备开启状态 + private String active;//状态位 public String getId() { return id; @@ -30,6 +34,38 @@ this.id = id; } + public String getPartition() { + return partition; + } + + public void setPartition(String partition) { + this.partition = partition; + } + + public String getPipeGallery() { + return pipeGallery; + } + + public void setPipeGallery(String pipeGallery) { + this.pipeGallery = pipeGallery; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getPosition() { + return position; + } + + public void setPosition(String position) { + this.position = position; + } + public String getDevType() { return devType; } @@ -46,36 +82,52 @@ this.devCode = devCode; } - public String getDevName() { - return devName; + public String getAssetName() { + return assetName; } - public void setDevName(String devName) { - this.devName = devName; + public void setAssetName(String assetName) { + this.assetName = assetName; } - public String getBrand() { - return brand; + public String getAssetCode() { + return assetCode; } - public void setBrand(String brand) { - this.brand = brand; + public void setAssetCode(String assetCode) { + this.assetCode = assetCode; } - public String getOwnerUnit() { - return ownerUnit; + public String getAssetBarCode() { + return assetBarCode; } - public void setOwnerUnit(String ownerUnit) { - this.ownerUnit = ownerUnit; + public void setAssetBarCode(String assetBarCode) { + this.assetBarCode = assetBarCode; } - public String getInstallDate() { - return installDate; + public String getIp() { + return ip; } - public void setInstallDate(String installDate) { - this.installDate = installDate; + public void setIp(String ip) { + this.ip = ip; + } + + public String getModBus() { + return modBus; + } + + public void setModBus(String modBus) { + this.modBus = modBus; + } + + public String getMome() { + return mome; + } + + public void setMome(String mome) { + this.mome = mome; } public String getIsOpen() { @@ -94,39 +146,26 @@ this.active = active; } - public String getPipeGallery() { - return pipeGallery; - } - - public void setPipeGallery(String pipeGallery) { - this.pipeGallery = pipeGallery; - } - - public String getPartition() { - return partition; - } - - public void setPartition(String partition) { - this.partition = partition; - } - public PgDeviceDto(PgDevice pgDevice) { SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); this.setId(String.valueOf(pgDevice.getId())); - this.setDevType(pgDevice.getDevTypeId().getDevType()); + this.setPipeGallery(pgDevice.getPipeGalleryId().getPgName()); + this.setPartition(pgDevice.getPipeGalleryId().getPgPartitionId().getParName()); + this.setRoad(pgDevice.getRoad()); + this.setPosition(pgDevice.getPosition()); + this.setDevType(pgDevice.getDevType()); this.setDevCode(pgDevice.getDevCode()); - this.setDevName(pgDevice.getDevName()); - this.setBrand(pgDevice.getBrand()); - this.setOwnerUnit(pgDevice.getOwnerUnit()); - this.setInstallDate(sdf.format(pgDevice.getInstallDate())); + this.setAssetName(pgDevice.getAssetName()); + this.setAssetCode(pgDevice.getAssetCode()); + this.setAssetBarCode(pgDevice.getAssetBarCode()); + this.setId(pgDevice.getIp()); + this.setModBus(pgDevice.getModBus()); + this.setMome(pgDevice.getMome()); this.setIsOpen(String.valueOf(pgDevice.getIsOpen())); this.setActive(String.valueOf(pgDevice.getActive())); - this.setPipeGallery(pgDevice.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgDevice.getPgPartitionId().getParName()); + } - -} - +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java index e8751d3..3acd0fa 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java @@ -11,7 +11,7 @@ private String id; private String parName;//分区名称 - private String pipeGallery;//管廊仓 + private String road;//所属道路 private String active;//状态位 @@ -31,14 +31,6 @@ this.parName = parName; } - public String getPipeGallery() { - return pipeGallery; - } - - public void setPipeGallery(String pipeGallery) { - this.pipeGallery = pipeGallery; - } - public String getActive() { return active; } @@ -47,11 +39,19 @@ this.active = active; } + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + public PgPartitionDto(PgPartition pgPartition) { this.setId(String.valueOf(pgPartition.getId())); this.setParName(pgPartition.getParName()); - this.setPipeGallery(pgPartition.getPipeGalleryId().getPgName()); + this.setRoad(pgPartition.getRoad()); this.setActive(String.valueOf(pgPartition.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java index 9b161bf..8b430dc 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java @@ -112,8 +112,8 @@ this.setEnterDate(sdf.format(pgPipeLine.getEnterDate())); this.setLayerNum(pgPipeLine.getLayerNum()); this.setDiameter(pgPipeLine.getDiameter()); - this.setPipeGallery(pgPipeLine.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgPipeLine.getPgPartitionId().getParName()); + this.setPipeGallery(pgPipeLine.getPipeGalleryId().getPgName()); + this.setPartition(pgPipeLine.getPipeGalleryId().getPgPartitionId().getParName()); this.setActive(String.valueOf(pgPipeLine.getActive())); } } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java index 03c580c..709dcea 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java @@ -103,8 +103,8 @@ this.setOwnerUnit(pgTexture.getOwnerUnit()); this.setBuildDate(sdf.format(pgTexture.getBuildDate())); this.setActive(String.valueOf(pgTexture.getActive())); - this.setPipeGallery(pgTexture.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgTexture.getPgPartitionId().getParName()); + this.setPipeGallery(pgTexture.getPipeGalleryId().getPgName()); + this.setPartition(pgTexture.getPipeGalleryId().getPgPartitionId().getParName()); } } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java index b40ce84..319cf21 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java @@ -11,6 +11,7 @@ private String id; private String pgName;//管廊名称 + private String pgPartition;//分区名称 private String active;//状态位 public String getId() { @@ -37,10 +38,19 @@ this.active = active; } + public String getPgPartition() { + return pgPartition; + } + + public void setPgPartition(String pgPartition) { + this.pgPartition = pgPartition; + } + public PipeGalleryDto(PipeGallery pipeGallery) { this.setId(String.valueOf(pipeGallery.getId())); this.setPgName(pipeGallery.getPgName()); + this.setPgPartition(pipeGallery.getPgPartitionId().getParName()); this.setActive(String.valueOf(pipeGallery.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java b/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java index 8b413e7..0c594e7 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java @@ -5,10 +5,10 @@ import com.casic.PgInterface.devTable.domain.PipeGallery; import com.casic.PgInterface.devTable.dto.PgPartitionDto; import org.hibernate.Criteria; +import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; -import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; @@ -18,44 +18,50 @@ @Service public class PgPartitionManager extends HibernateEntityDao { - private PipeGalleryManager pipeGalleryManager; - - @Resource - public void setPipeGalleryManager(PipeGalleryManager pipeGalleryManager) { - this.pipeGalleryManager = pipeGalleryManager; - } - - public PgPartition getPartitionByParName(String parName,PipeGallery pipeGallery) { - if(pipeGallery==null) - return null; - Criteria criteria = getSession().createCriteria(PgPartition.class); + public PgPartition getPartitionByParName(String parName) { + Criteria criteria = getSession().createCriteria(PipeGallery.class); criteria.add(Restrictions.eq("parName", parName)); - criteria.add(Restrictions.eq("pipeGalleryId",pipeGallery)); + criteria.add(Restrictions.eq("active",1)); List pgPartitionList = criteria.list(); - //TODO LIST:为空判断 pgPartitionList==null? if (pgPartitionList != null && pgPartitionList.size() > 0) return pgPartitionList.get(0); else return null; } - public List getPartitionByPG(String pgName){ - PipeGallery pipeGallery=pipeGalleryManager.getPipeGalleryByPgName(pgName); - - Criteria criteria=getSession().createCriteria(PgPartition.class); - criteria.add(Restrictions.eq("pipeGalleryId",pipeGallery)); + public List getPartitionByRoad(String road) { + Criteria criteria = getSession().createCriteria(PipeGallery.class); + criteria.add(Restrictions.eq("road", road)); + criteria.add(Restrictions.eq("active",1)); List pgPartitionList = criteria.list(); List pgPartitionDtoList=new ArrayList(); - for(PgPartition pgPartition:pgPartitionList) - { - pgPartitionDtoList.add(new PgPartitionDto(pgPartition)); - } + for(PgPartition pgPartition:pgPartitionList) { + pgPartitionDtoList.add(new PgPartitionDto(pgPartition)); + } return pgPartitionDtoList; } + public List getPgPartitionDtoList() + { + Criteria criteria=getSession().createCriteria(PgPartition.class); + criteria.add(Restrictions.eq("active",1)); + criteria.addOrder(Order.desc("id")); + + List pgPartitionList=criteria.list(); + if(pgPartitionList.size()==0||pgPartitionList==null) + return null; + List pgPartitionDtoList=new ArrayList(); + for(PgPartition pgPartition:pgPartitionList) { + pgPartitionDtoList.add(new PgPartitionDto(pgPartition)); + } + return pgPartitionDtoList; + } + + + } diff --git a/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java b/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java index 16370c6..9bce32b 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java @@ -1,14 +1,16 @@ package com.casic.PgInterface.devTable.manager; import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.devTable.domain.PgPartition; import com.casic.PgInterface.devTable.domain.PipeGallery; import com.casic.PgInterface.devTable.dto.PipeGalleryDto; import org.hibernate.Criteria; -import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; -import java.util.*; +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; /** * Created by yxw on 2017/11/4. @@ -16,36 +18,44 @@ @Service public class PipeGalleryManager extends HibernateEntityDao { - public PipeGallery getPipeGalleryByPgName(String pgName) { - Criteria criteria = getSession().createCriteria(PipeGallery.class); + private PgPartitionManager pgPartitionManager; + + @Resource + public void setPgPartitionManager(PgPartitionManager pgPartitionManager) { + this.pgPartitionManager = pgPartitionManager; + } + + public PipeGallery getPipeGalleryByPgName(String pgName,PgPartition pgPartition) { + if(pgPartition==null) + return null; + Criteria criteria = getSession().createCriteria(PgPartition.class); criteria.add(Restrictions.eq("pgName", pgName)); - criteria.add(Restrictions.eq("active",1)); + criteria.add(Restrictions.eq("pgPartitionId",pgPartition)); List pipeGalleryList = criteria.list(); - //TODO LIST:为空判断 pipeGalleryList==null? + //TODO LIST:为空判断 pgPartitionList==null? if (pipeGalleryList != null && pipeGalleryList.size() > 0) return pipeGalleryList.get(0); else return null; } - public List getPIpeGalleryDtoList() - { - Criteria criteria=getSession().createCriteria(PipeGallery.class); - criteria.add(Restrictions.eq("active",1)); - criteria.addOrder(Order.desc("id")); - List pipeGalleryList=criteria.list(); - if(pipeGalleryList.size()==0||pipeGalleryList==null) - return null; - List pipeGalleryDtoList=new ArrayList(); - for(PipeGallery pipeGallery:pipeGalleryList) { + public List getPipeGalleryByParName(String parName) { + + PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName); + Criteria criteria = getSession().createCriteria(PipeGallery.class); + criteria.add(Restrictions.eq("pgPartitionId", pgPartition)); + + List pipeGalleryList = criteria.list(); + + List pipeGalleryDtoList = new ArrayList(); + for (PipeGallery pipeGallery : pipeGalleryList) { pipeGalleryDtoList.add(new PipeGalleryDto(pipeGallery)); } + return pipeGalleryDtoList; } - - } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java new file mode 100644 index 0000000..9d06235 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java @@ -0,0 +1,63 @@ +package com.casic.PgInterface.patroler.domain; + +import com.casic.PgInterface.devTable.domain.PgDevice; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + +import javax.persistence.*; +import java.io.Serializable; + +/** + * Created by yxw on 2017/12/14. + */ +@Entity +@Table(name = "PG_ALARM_RULE") +@SequenceGenerator(name = "SEQ_PG_ALARM_RULE_ID", sequenceName = "SEQ_PG_ALARM_RULE_ID",allocationSize=1,initialValue=1) +public class PgAlarmRule implements Serializable { + + private static final long serialVersionUID = 1L; + private long id; + private String highValue;//高限 + private String lowValue;//低限 + private PgDevice pgDeviceId;//设备 + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_ALARM_RULE_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "HIGHVALUE") + public String getHighValue() { + return highValue; + } + + public void setHighValue(String highValue) { + this.highValue = highValue; + } + + @Column(name = "LOWVALUE") + public String getLowValue() { + return lowValue; + } + + public void setLowValue(String lowValue) { + this.lowValue = lowValue; + } + + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "PGDEVICEID") + public PgDevice getPgDeviceId() { + return pgDeviceId; + } + + public void setPgDeviceId(PgDevice pgDeviceId) { + this.pgDeviceId = pgDeviceId; + } + +} diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java new file mode 100644 index 0000000..8367ad4 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java @@ -0,0 +1,57 @@ +package com.casic.PgInterface.patroler.dto; + +import com.casic.PgInterface.patroler.domain.PgAlarmRule; + +import java.io.Serializable; + +/** + * Created by yxw on 2017/12/14. + */ +public class PgAlarmRuleDto implements Serializable { + + private String id; + private String highValue;//高限 + private String lowValue;//低限 + private String devName;//设备 + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getHighValue() { + return highValue; + } + + public void setHighValue(String highValue) { + this.highValue = highValue; + } + + public String getLowValue() { + return lowValue; + } + + public void setLowValue(String lowValue) { + this.lowValue = lowValue; + } + + public String getDevName() { + return devName; + } + + public void setDevName(String devName) { + this.devName = devName; + } + + public PgAlarmRuleDto(PgAlarmRule pgAlarmRule) + { + this.setId(String.valueOf(pgAlarmRule.getId())); + this.setDevName(pgAlarmRule.getPgDeviceId().getAssetName()); + this.setHighValue(pgAlarmRule.getHighValue()); + this.setLowValue(pgAlarmRule.getLowValue()); + } + +} diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java new file mode 100644 index 0000000..d5c00b2 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java @@ -0,0 +1,42 @@ +package com.casic.PgInterface.patroler.manager; + +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.devTable.domain.PgDevice; +import com.casic.PgInterface.patroler.domain.PgAlarmRule; +import com.casic.PgInterface.patroler.dto.PgAlarmRuleDto; +import org.hibernate.Criteria; +import org.hibernate.criterion.Restrictions; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * Created by yxw on 2017/12/14. + */ +@Service +public class PgAlarmRuleManager extends HibernateEntityDao { + + //根据设备获取设备报警阈值 + public PgAlarmRuleDto getAlarmRuleDtoBydev(PgDevice pgDeviceId) { + Criteria criteria=createCriteria(PgAlarmRule.class); + criteria.add(Restrictions.eq("pgDeviceId", pgDeviceId)); + + List pgAlarmRuleList=criteria.list(); + if(pgAlarmRuleList.size()==0) + return null; + else + return new PgAlarmRuleDto(pgAlarmRuleList.get(0)); + } + + public PgAlarmRule getAlarmRuleBydev(PgDevice pgDeviceId) { + Criteria criteria=createCriteria(PgAlarmRule.class); + criteria.add(Restrictions.eq("pgDeviceId", pgDeviceId)); + + List pgAlarmRuleList=criteria.list(); + if(pgAlarmRuleList.size()==0) + return null; + else + return pgAlarmRuleList.get(0); + } + +} diff --git a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java index 80625c7..d8f5e6b 100644 --- a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java +++ b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java @@ -43,9 +43,7 @@ this.intoTime = intoTime; } - @Column(name = "OUT_TIME") - public Date getOutTime() { return outTime; } diff --git a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java index a99981e..b1d63a4 100644 --- a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java +++ b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java @@ -1,11 +1,28 @@ package com.casic.PgInterface.devData.manager; +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.core.util.DateUtils; +import com.casic.PgInterface.core.util.StringUtils; +import com.casic.PgInterface.devData.domain.PgCo; +import com.casic.PgInterface.devData.domain.PgLocation; +import com.casic.PgInterface.devData.dto.PgCoDto; +import com.casic.PgInterface.devData.dto.PgLocationDto; +import com.casic.PgInterface.devTable.domain.PgDevice; +import org.hibernate.Criteria; +import org.hibernate.criterion.Order; +import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; + /** * Created by yxw on 2017/11/2. */ @Service -public class PgLocationManager { +public class PgLocationManager extends HibernateEntityDao { + + //获取设备时间段内所有的监测数据 } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java index cfa0281..7fb5953 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -1,12 +1,12 @@ package com.casic.PgInterface.devTable.domain; import com.casic.PgInterface.devData.domain.*; +import com.casic.PgInterface.patroler.domain.PgAlarmRule; import org.hibernate.annotations.NotFound; import org.hibernate.annotations.NotFoundAction; import javax.persistence.*; import java.io.Serializable; -import java.util.Date; import java.util.List; /** @@ -19,21 +19,27 @@ private static final long serialVersionUID = 1L; private long id; + private PipeGallery pipeGalleryId;//所在管廊信息 + private String road;//路名 + private String position;//设备位置 + private String devType;//设备类型 private String devCode;//设备编号 - private String devName;//设备名称 - private String brand;//品牌 - private String ownerUnit;//权属单位 - private Date installDate;//安装时间 + private String assetName;//资产名称 + private String assetCode;//资产编码 + private String assetBarCode;//资产条码 + private String ip;//IP地址 + private String modBus;//modBus地址 + private String mome;//备注 private int isOpen;//设备是否开启 private int active;//状态位 - private PgDeviceType devTypeId;//设备类型 + private List pgAlarms; - private PgPartition pgPartitionId;//所在管廊信息 private List pgTempHums;//温湿度 private List pgCos;//一氧化碳 private List pgO2s;//氧气 private List pgCh4s;//甲烷 private List pgShs;//硫化氢 + private List pgAlarmRules;//报警规则 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") @@ -45,6 +51,33 @@ this.id = id; } + @Column(name = "ROAD") + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + @Column(name = "POSITION") + public String getPosition() { + return position; + } + + public void setPosition(String position) { + this.position = position; + } + + @Column(name = "DEV_TYPE") + public String getDevType() { + return devType; + } + + public void setDevType(String devType) { + this.devType = devType; + } + @Column(name = "DEV_CODE") public String getDevCode() { return devCode; @@ -54,40 +87,58 @@ this.devCode = devCode; } - @Column(name = "DEV_NAME") - public String getDevName() { - return devName; + @Column(name = "ASSET_NAME") + public String getAssetName() { + return assetName; } - public void setDevName(String devName) { - this.devName = devName; + public void setAssetName(String assetName) { + this.assetName = assetName; } - @Column(name = "BRAND") - public String getBrand() { - return brand; + @Column(name = "ASSET_CODE") + public String getAssetCode() { + return assetCode; } - public void setBrand(String brand) { - this.brand = brand; + public void setAssetCode(String assetCode) { + this.assetCode = assetCode; } - @Column(name = "OWNERUNIT") - public String getOwnerUnit() { - return ownerUnit; + @Column(name = "ASSET_BAR_CODE") + public String getAssetBarCode() { + return assetBarCode; } - public void setOwnerUnit(String ownerUnit) { - this.ownerUnit = ownerUnit; + public void setAssetBarCode(String assetBarCode) { + this.assetBarCode = assetBarCode; } - @Column(name = "INSTALDATE") - public Date getInstallDate() { - return installDate; + @Column(name = "IP") + public String getIp() { + return ip; } - public void setInstallDate(Date installDate) { - this.installDate = installDate; + public void setIp(String ip) { + this.ip = ip; + } + + @Column(name = "MODBUS") + public String getModBus() { + return modBus; + } + + public void setModBus(String modBus) { + this.modBus = modBus; + } + + @Column(name = "MOME") + public String getMome() { + return mome; + } + + public void setMome(String mome) { + this.mome = mome; } @Column(name = "ISOPEN") @@ -119,24 +170,13 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; - } - - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "DEVICE_TYPE_ID") - public PgDeviceType getDevTypeId() { - return devTypeId; - } - - public void setDevTypeId(PgDeviceType devTypeId) { - this.devTypeId = devTypeId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgDeviceId") @@ -184,4 +224,13 @@ this.pgShs = pgShs; } + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgDeviceId") + public List getPgAlarmRules() { + return pgAlarmRules; + } + + public void setPgAlarmRules(List pgAlarmRules) { + this.pgAlarmRules = pgAlarmRules; + } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java index b997b29..4fb3d6f 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java @@ -1,8 +1,5 @@ package com.casic.PgInterface.devTable.domain; -import org.hibernate.annotations.NotFound; -import org.hibernate.annotations.NotFoundAction; - import javax.persistence.*; import java.io.Serializable; import java.util.List; @@ -19,11 +16,9 @@ private long id; private String parName;//分区名称 - private PipeGallery pipeGalleryId;//管廊仓 + private String road;//所属道路 private int active;//状态位 - private List pgTextureList; - private List pgPipeLineList; - private List pgDeviceList; + private List pipeGalleryList;//管廊仓 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PARTITION_ID") @@ -44,6 +39,15 @@ this.parName = parName; } + @Column(name = "ROAD") + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + @Column(name = "ACTIVE") public int getActive() { return active; @@ -53,41 +57,14 @@ this.active = active; } - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PIPEGALLERYID") - public PipeGallery getPipeGalleryId() { - return pipeGalleryId; - } - - public void setPipeGalleryId(PipeGallery pipeGalleryId) { - this.pipeGalleryId = pipeGalleryId; - } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgTextureList() { - return pgTextureList; + public List getPipeGalleryList() { + return pipeGalleryList; } - public void setPgTextureList(List pgTextureList) { - this.pgTextureList = pgTextureList; + public void setPipeGalleryList(List pipeGalleryList) { + this.pipeGalleryList = pipeGalleryList; } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgPipeLineList() { - return pgPipeLineList; - } - public void setPgPipeLineList(List pgPipeLineList) { - this.pgPipeLineList = pgPipeLineList; - } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgDeviceList() { - return pgDeviceList; - } - - public void setPgDeviceList(List pgDeviceList) { - this.pgDeviceList = pgDeviceList; - } } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java index d936d18..e5ff9b3 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java @@ -22,7 +22,7 @@ private Date enterDate;//入廊时间 private String layerNum;//所在层数 private String diameter;//管径 - private PgPartition pgPartitionId;//所在管廊信息 + private PipeGallery pipeGalleryId;//所在管廊信息 private int active;//状态位 @Id @@ -100,12 +100,12 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java index 1f22bf9..4ebfbda 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java @@ -21,7 +21,7 @@ private String ownerUnit;//权属单位 private Date buildDate;//建设年代 private int active;//状态位 - private PgPartition pgPartitionId;//所在管廊信息 + private PipeGallery pipeGalleryId;//所在管廊信息 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_TEXTURE_ID") @@ -91,12 +91,13 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java b/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java index 49a246c..650d623 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java @@ -1,5 +1,8 @@ package com.casic.PgInterface.devTable.domain; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + import javax.persistence.*; import java.io.Serializable; import java.util.List; @@ -16,7 +19,10 @@ private long id; private String pgName;//管廊名称 private int active;//状态位 - private List partitionList; + private PgPartition pgPartitionId;// + private List pgTextureList; + private List pgPipeLineList; + private List pgDeviceList; @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PIPE_GALLERY_ID") @@ -46,12 +52,42 @@ this.active = active; } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") - public List getPartitionList() { - return partitionList; + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "PARTITIONID") + public PgPartition getPgPartitionId() { + return pgPartitionId; } - public void setPartitionList(List partitionList) { - this.partitionList = partitionList; + public void setPgPartitionId(PgPartition pgPartitionId) { + this.pgPartitionId = pgPartitionId; } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgTextureList() { + return pgTextureList; + } + + public void setPgTextureList(List pgTextureList) { + this.pgTextureList = pgTextureList; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgPipeLineList() { + return pgPipeLineList; + } + + public void setPgPipeLineList(List pgPipeLineList) { + this.pgPipeLineList = pgPipeLineList; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgDeviceList() { + return pgDeviceList; + } + + public void setPgDeviceList(List pgDeviceList) { + this.pgDeviceList = pgDeviceList; + } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java index b4048d9..c3dfc55 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java @@ -101,18 +101,17 @@ this.active = active; } - public PgAlarmDto(PgAlarm pgAlarm) - { - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + public PgAlarmDto(PgAlarm pgAlarm) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); this.setId(String.valueOf(pgAlarm.getId())); this.setAlarmType(pgAlarm.getAlarmTypeId().getAlarmType()); this.setAlarmValue(pgAlarm.getAlarmValue()); this.setAlarmDate(sdf.format(pgAlarm.getAlarmDate())); this.setDescription(pgAlarm.getDescription()); - this.setAlarmDevName(pgAlarm.getAlarmDevId().getDevName()); - this.setAlarmLocation(pgAlarm.getAlarmDevId().getPgPartitionId().getPipeGalleryId().getPgName() - + pgAlarm.getAlarmDevId().getPgPartitionId().getParName()); + this.setAlarmDevName(pgAlarm.getAlarmDevId().getAssetName()); + this.setAlarmLocation(pgAlarm.getAlarmDevId().getPipeGalleryId().getPgPartitionId().getParName() + + pgAlarm.getAlarmDevId().getPipeGalleryId().getPgName()); this.setUserName(pgAlarm.getPatrolerId().getUserName()); this.setPhoneNumber(pgAlarm.getPatrolerId().getPhoneNumber()); this.setActive(String.valueOf(pgAlarm.getActive())); diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java index ae76e95..49bd436 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java @@ -11,16 +11,20 @@ public class PgDeviceDto implements Serializable { private String id; - private String devType;//设备类型 - private String devCode;//设备编号 - private String devName;//设备名称 - private String brand;//品牌 - private String ownerUnit;//权属单位 - private String installDate;//安装时间 - private String isOpen;//设备开启状态 - private String active;//状态位 private String pipeGallery;//仓位 private String partition;//分区 + private String road;//路名 + private String position;//设备位置 + private String devType;//设备类型 + private String devCode;//设备编号 + private String assetName;//资产名称 + private String assetCode;//资产名称 + private String assetBarCode;//资产条码 + private String ip;//IP地址 + private String modBus;//modBus地址 + private String mome;//备注 + private String isOpen;//设备开启状态 + private String active;//状态位 public String getId() { return id; @@ -30,6 +34,38 @@ this.id = id; } + public String getPartition() { + return partition; + } + + public void setPartition(String partition) { + this.partition = partition; + } + + public String getPipeGallery() { + return pipeGallery; + } + + public void setPipeGallery(String pipeGallery) { + this.pipeGallery = pipeGallery; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getPosition() { + return position; + } + + public void setPosition(String position) { + this.position = position; + } + public String getDevType() { return devType; } @@ -46,36 +82,52 @@ this.devCode = devCode; } - public String getDevName() { - return devName; + public String getAssetName() { + return assetName; } - public void setDevName(String devName) { - this.devName = devName; + public void setAssetName(String assetName) { + this.assetName = assetName; } - public String getBrand() { - return brand; + public String getAssetCode() { + return assetCode; } - public void setBrand(String brand) { - this.brand = brand; + public void setAssetCode(String assetCode) { + this.assetCode = assetCode; } - public String getOwnerUnit() { - return ownerUnit; + public String getAssetBarCode() { + return assetBarCode; } - public void setOwnerUnit(String ownerUnit) { - this.ownerUnit = ownerUnit; + public void setAssetBarCode(String assetBarCode) { + this.assetBarCode = assetBarCode; } - public String getInstallDate() { - return installDate; + public String getIp() { + return ip; } - public void setInstallDate(String installDate) { - this.installDate = installDate; + public void setIp(String ip) { + this.ip = ip; + } + + public String getModBus() { + return modBus; + } + + public void setModBus(String modBus) { + this.modBus = modBus; + } + + public String getMome() { + return mome; + } + + public void setMome(String mome) { + this.mome = mome; } public String getIsOpen() { @@ -94,39 +146,26 @@ this.active = active; } - public String getPipeGallery() { - return pipeGallery; - } - - public void setPipeGallery(String pipeGallery) { - this.pipeGallery = pipeGallery; - } - - public String getPartition() { - return partition; - } - - public void setPartition(String partition) { - this.partition = partition; - } - public PgDeviceDto(PgDevice pgDevice) { SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); this.setId(String.valueOf(pgDevice.getId())); - this.setDevType(pgDevice.getDevTypeId().getDevType()); + this.setPipeGallery(pgDevice.getPipeGalleryId().getPgName()); + this.setPartition(pgDevice.getPipeGalleryId().getPgPartitionId().getParName()); + this.setRoad(pgDevice.getRoad()); + this.setPosition(pgDevice.getPosition()); + this.setDevType(pgDevice.getDevType()); this.setDevCode(pgDevice.getDevCode()); - this.setDevName(pgDevice.getDevName()); - this.setBrand(pgDevice.getBrand()); - this.setOwnerUnit(pgDevice.getOwnerUnit()); - this.setInstallDate(sdf.format(pgDevice.getInstallDate())); + this.setAssetName(pgDevice.getAssetName()); + this.setAssetCode(pgDevice.getAssetCode()); + this.setAssetBarCode(pgDevice.getAssetBarCode()); + this.setId(pgDevice.getIp()); + this.setModBus(pgDevice.getModBus()); + this.setMome(pgDevice.getMome()); this.setIsOpen(String.valueOf(pgDevice.getIsOpen())); this.setActive(String.valueOf(pgDevice.getActive())); - this.setPipeGallery(pgDevice.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgDevice.getPgPartitionId().getParName()); + } - -} - +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java index e8751d3..3acd0fa 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java @@ -11,7 +11,7 @@ private String id; private String parName;//分区名称 - private String pipeGallery;//管廊仓 + private String road;//所属道路 private String active;//状态位 @@ -31,14 +31,6 @@ this.parName = parName; } - public String getPipeGallery() { - return pipeGallery; - } - - public void setPipeGallery(String pipeGallery) { - this.pipeGallery = pipeGallery; - } - public String getActive() { return active; } @@ -47,11 +39,19 @@ this.active = active; } + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + public PgPartitionDto(PgPartition pgPartition) { this.setId(String.valueOf(pgPartition.getId())); this.setParName(pgPartition.getParName()); - this.setPipeGallery(pgPartition.getPipeGalleryId().getPgName()); + this.setRoad(pgPartition.getRoad()); this.setActive(String.valueOf(pgPartition.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java index 9b161bf..8b430dc 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java @@ -112,8 +112,8 @@ this.setEnterDate(sdf.format(pgPipeLine.getEnterDate())); this.setLayerNum(pgPipeLine.getLayerNum()); this.setDiameter(pgPipeLine.getDiameter()); - this.setPipeGallery(pgPipeLine.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgPipeLine.getPgPartitionId().getParName()); + this.setPipeGallery(pgPipeLine.getPipeGalleryId().getPgName()); + this.setPartition(pgPipeLine.getPipeGalleryId().getPgPartitionId().getParName()); this.setActive(String.valueOf(pgPipeLine.getActive())); } } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java index 03c580c..709dcea 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java @@ -103,8 +103,8 @@ this.setOwnerUnit(pgTexture.getOwnerUnit()); this.setBuildDate(sdf.format(pgTexture.getBuildDate())); this.setActive(String.valueOf(pgTexture.getActive())); - this.setPipeGallery(pgTexture.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgTexture.getPgPartitionId().getParName()); + this.setPipeGallery(pgTexture.getPipeGalleryId().getPgName()); + this.setPartition(pgTexture.getPipeGalleryId().getPgPartitionId().getParName()); } } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java index b40ce84..319cf21 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java @@ -11,6 +11,7 @@ private String id; private String pgName;//管廊名称 + private String pgPartition;//分区名称 private String active;//状态位 public String getId() { @@ -37,10 +38,19 @@ this.active = active; } + public String getPgPartition() { + return pgPartition; + } + + public void setPgPartition(String pgPartition) { + this.pgPartition = pgPartition; + } + public PipeGalleryDto(PipeGallery pipeGallery) { this.setId(String.valueOf(pipeGallery.getId())); this.setPgName(pipeGallery.getPgName()); + this.setPgPartition(pipeGallery.getPgPartitionId().getParName()); this.setActive(String.valueOf(pipeGallery.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java b/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java index 8b413e7..0c594e7 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java @@ -5,10 +5,10 @@ import com.casic.PgInterface.devTable.domain.PipeGallery; import com.casic.PgInterface.devTable.dto.PgPartitionDto; import org.hibernate.Criteria; +import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; -import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; @@ -18,44 +18,50 @@ @Service public class PgPartitionManager extends HibernateEntityDao { - private PipeGalleryManager pipeGalleryManager; - - @Resource - public void setPipeGalleryManager(PipeGalleryManager pipeGalleryManager) { - this.pipeGalleryManager = pipeGalleryManager; - } - - public PgPartition getPartitionByParName(String parName,PipeGallery pipeGallery) { - if(pipeGallery==null) - return null; - Criteria criteria = getSession().createCriteria(PgPartition.class); + public PgPartition getPartitionByParName(String parName) { + Criteria criteria = getSession().createCriteria(PipeGallery.class); criteria.add(Restrictions.eq("parName", parName)); - criteria.add(Restrictions.eq("pipeGalleryId",pipeGallery)); + criteria.add(Restrictions.eq("active",1)); List pgPartitionList = criteria.list(); - //TODO LIST:为空判断 pgPartitionList==null? if (pgPartitionList != null && pgPartitionList.size() > 0) return pgPartitionList.get(0); else return null; } - public List getPartitionByPG(String pgName){ - PipeGallery pipeGallery=pipeGalleryManager.getPipeGalleryByPgName(pgName); - - Criteria criteria=getSession().createCriteria(PgPartition.class); - criteria.add(Restrictions.eq("pipeGalleryId",pipeGallery)); + public List getPartitionByRoad(String road) { + Criteria criteria = getSession().createCriteria(PipeGallery.class); + criteria.add(Restrictions.eq("road", road)); + criteria.add(Restrictions.eq("active",1)); List pgPartitionList = criteria.list(); List pgPartitionDtoList=new ArrayList(); - for(PgPartition pgPartition:pgPartitionList) - { - pgPartitionDtoList.add(new PgPartitionDto(pgPartition)); - } + for(PgPartition pgPartition:pgPartitionList) { + pgPartitionDtoList.add(new PgPartitionDto(pgPartition)); + } return pgPartitionDtoList; } + public List getPgPartitionDtoList() + { + Criteria criteria=getSession().createCriteria(PgPartition.class); + criteria.add(Restrictions.eq("active",1)); + criteria.addOrder(Order.desc("id")); + + List pgPartitionList=criteria.list(); + if(pgPartitionList.size()==0||pgPartitionList==null) + return null; + List pgPartitionDtoList=new ArrayList(); + for(PgPartition pgPartition:pgPartitionList) { + pgPartitionDtoList.add(new PgPartitionDto(pgPartition)); + } + return pgPartitionDtoList; + } + + + } diff --git a/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java b/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java index 16370c6..9bce32b 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java @@ -1,14 +1,16 @@ package com.casic.PgInterface.devTable.manager; import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.devTable.domain.PgPartition; import com.casic.PgInterface.devTable.domain.PipeGallery; import com.casic.PgInterface.devTable.dto.PipeGalleryDto; import org.hibernate.Criteria; -import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; -import java.util.*; +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; /** * Created by yxw on 2017/11/4. @@ -16,36 +18,44 @@ @Service public class PipeGalleryManager extends HibernateEntityDao { - public PipeGallery getPipeGalleryByPgName(String pgName) { - Criteria criteria = getSession().createCriteria(PipeGallery.class); + private PgPartitionManager pgPartitionManager; + + @Resource + public void setPgPartitionManager(PgPartitionManager pgPartitionManager) { + this.pgPartitionManager = pgPartitionManager; + } + + public PipeGallery getPipeGalleryByPgName(String pgName,PgPartition pgPartition) { + if(pgPartition==null) + return null; + Criteria criteria = getSession().createCriteria(PgPartition.class); criteria.add(Restrictions.eq("pgName", pgName)); - criteria.add(Restrictions.eq("active",1)); + criteria.add(Restrictions.eq("pgPartitionId",pgPartition)); List pipeGalleryList = criteria.list(); - //TODO LIST:为空判断 pipeGalleryList==null? + //TODO LIST:为空判断 pgPartitionList==null? if (pipeGalleryList != null && pipeGalleryList.size() > 0) return pipeGalleryList.get(0); else return null; } - public List getPIpeGalleryDtoList() - { - Criteria criteria=getSession().createCriteria(PipeGallery.class); - criteria.add(Restrictions.eq("active",1)); - criteria.addOrder(Order.desc("id")); - List pipeGalleryList=criteria.list(); - if(pipeGalleryList.size()==0||pipeGalleryList==null) - return null; - List pipeGalleryDtoList=new ArrayList(); - for(PipeGallery pipeGallery:pipeGalleryList) { + public List getPipeGalleryByParName(String parName) { + + PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName); + Criteria criteria = getSession().createCriteria(PipeGallery.class); + criteria.add(Restrictions.eq("pgPartitionId", pgPartition)); + + List pipeGalleryList = criteria.list(); + + List pipeGalleryDtoList = new ArrayList(); + for (PipeGallery pipeGallery : pipeGalleryList) { pipeGalleryDtoList.add(new PipeGalleryDto(pipeGallery)); } + return pipeGalleryDtoList; } - - } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java new file mode 100644 index 0000000..9d06235 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java @@ -0,0 +1,63 @@ +package com.casic.PgInterface.patroler.domain; + +import com.casic.PgInterface.devTable.domain.PgDevice; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + +import javax.persistence.*; +import java.io.Serializable; + +/** + * Created by yxw on 2017/12/14. + */ +@Entity +@Table(name = "PG_ALARM_RULE") +@SequenceGenerator(name = "SEQ_PG_ALARM_RULE_ID", sequenceName = "SEQ_PG_ALARM_RULE_ID",allocationSize=1,initialValue=1) +public class PgAlarmRule implements Serializable { + + private static final long serialVersionUID = 1L; + private long id; + private String highValue;//高限 + private String lowValue;//低限 + private PgDevice pgDeviceId;//设备 + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_ALARM_RULE_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "HIGHVALUE") + public String getHighValue() { + return highValue; + } + + public void setHighValue(String highValue) { + this.highValue = highValue; + } + + @Column(name = "LOWVALUE") + public String getLowValue() { + return lowValue; + } + + public void setLowValue(String lowValue) { + this.lowValue = lowValue; + } + + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "PGDEVICEID") + public PgDevice getPgDeviceId() { + return pgDeviceId; + } + + public void setPgDeviceId(PgDevice pgDeviceId) { + this.pgDeviceId = pgDeviceId; + } + +} diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java new file mode 100644 index 0000000..8367ad4 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java @@ -0,0 +1,57 @@ +package com.casic.PgInterface.patroler.dto; + +import com.casic.PgInterface.patroler.domain.PgAlarmRule; + +import java.io.Serializable; + +/** + * Created by yxw on 2017/12/14. + */ +public class PgAlarmRuleDto implements Serializable { + + private String id; + private String highValue;//高限 + private String lowValue;//低限 + private String devName;//设备 + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getHighValue() { + return highValue; + } + + public void setHighValue(String highValue) { + this.highValue = highValue; + } + + public String getLowValue() { + return lowValue; + } + + public void setLowValue(String lowValue) { + this.lowValue = lowValue; + } + + public String getDevName() { + return devName; + } + + public void setDevName(String devName) { + this.devName = devName; + } + + public PgAlarmRuleDto(PgAlarmRule pgAlarmRule) + { + this.setId(String.valueOf(pgAlarmRule.getId())); + this.setDevName(pgAlarmRule.getPgDeviceId().getAssetName()); + this.setHighValue(pgAlarmRule.getHighValue()); + this.setLowValue(pgAlarmRule.getLowValue()); + } + +} diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java new file mode 100644 index 0000000..d5c00b2 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java @@ -0,0 +1,42 @@ +package com.casic.PgInterface.patroler.manager; + +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.devTable.domain.PgDevice; +import com.casic.PgInterface.patroler.domain.PgAlarmRule; +import com.casic.PgInterface.patroler.dto.PgAlarmRuleDto; +import org.hibernate.Criteria; +import org.hibernate.criterion.Restrictions; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * Created by yxw on 2017/12/14. + */ +@Service +public class PgAlarmRuleManager extends HibernateEntityDao { + + //根据设备获取设备报警阈值 + public PgAlarmRuleDto getAlarmRuleDtoBydev(PgDevice pgDeviceId) { + Criteria criteria=createCriteria(PgAlarmRule.class); + criteria.add(Restrictions.eq("pgDeviceId", pgDeviceId)); + + List pgAlarmRuleList=criteria.list(); + if(pgAlarmRuleList.size()==0) + return null; + else + return new PgAlarmRuleDto(pgAlarmRuleList.get(0)); + } + + public PgAlarmRule getAlarmRuleBydev(PgDevice pgDeviceId) { + Criteria criteria=createCriteria(PgAlarmRule.class); + criteria.add(Restrictions.eq("pgDeviceId", pgDeviceId)); + + List pgAlarmRuleList=criteria.list(); + if(pgAlarmRuleList.size()==0) + return null; + else + return pgAlarmRuleList.get(0); + } + +} diff --git a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java new file mode 100644 index 0000000..88255c6 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java @@ -0,0 +1,162 @@ +package com.casic.PgInterface.rs; + +import com.casic.PgInterface.devTable.domain.PgDevice; +import com.casic.PgInterface.devTable.manager.PgDeviceManager; +import com.casic.PgInterface.patroler.domain.PgAlarmRule; +import com.casic.PgInterface.patroler.dto.PgAlarmRuleDto; +import com.casic.PgInterface.patroler.manager.PgAlarmRuleManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import javax.ws.rs.FormParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import java.util.HashMap; +import java.util.Map; + +/** + * Created by yxw on 2017/12/14. + */ +@Component +@Path("pgAlarmRule") +public class PgAlarmRuleRs { + + private static Logger logger = LoggerFactory.getLogger(PgAlarmRule.class); + + private PgDeviceManager pgDeviceManager; + + private PgAlarmRuleManager pgAlarmRuleManager; + + @Resource + public void setPgAlarmRuleManager(PgAlarmRuleManager pgAlarmRuleManager) { + this.pgAlarmRuleManager = pgAlarmRuleManager; + } + + @Resource + public void setPgDeviceManager(PgDeviceManager pgDeviceManager) { + this.pgDeviceManager = pgDeviceManager; + } + + /** + * 获取报警阈值信息 + */ + @POST + @Path("getAlarmRuleByAssetCode") + @Produces(MediaType.APPLICATION_JSON) + public Map getAlarmRuleByAssetCode(@FormParam("assetCode") String assetCode) throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + + PgAlarmRuleDto pgAlarmRuleDto = null; + PgDevice pgDevice = pgDeviceManager.getDeviceByAssetCode(assetCode); + try { + pgAlarmRuleDto = pgAlarmRuleManager.getAlarmRuleDtoBydev(pgDevice); + if (pgAlarmRuleDto == null) + msg = "不存在报警阈值信息"; + else + msg = "报警阈值获取成功"; + } catch (Exception e) { + e.printStackTrace(); + msg = "报警信息获取失败"; + } + resultMap.put("msg", msg); + resultMap.put("result", pgAlarmRuleDto); + return resultMap; + } + + /** + * 新增报警阈值 + */ + @POST + @Path("addAlarmRule") + @Produces(MediaType.APPLICATION_JSON) + public Map addAlarmRule(@FormParam("assetCode") String assetCode, + @FormParam("highValue") String highValue, + @FormParam("lowValue") String lowValue) throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + String result = ""; + + PgAlarmRule pgAlarmRule = null; + PgDevice pgDevice = pgDeviceManager.getDeviceByAssetCode(assetCode); + if (pgDevice == null) + msg = "不存在设备信息"; + else { + try { + pgAlarmRule = pgAlarmRuleManager.getAlarmRuleBydev(pgDevice); + if (pgAlarmRule != null) { + result = "false"; + msg = "设备阈值已经存在"; + } else { + pgAlarmRule = new PgAlarmRule(); + pgAlarmRule.setHighValue(highValue); + pgAlarmRule.setLowValue(lowValue); + pgAlarmRule.setPgDeviceId(pgDevice); + + pgAlarmRuleManager.save(pgAlarmRule); + result = "true"; + msg = "报警阈值新增成功"; + } + + } catch (Exception e) { + e.printStackTrace(); + result = "false"; + msg = "报警阈值新增失败"; + } + } + resultMap.put("msg", msg); + resultMap.put("result", result); + return resultMap; + } + + /** + * 编辑报警阈值 + */ + @POST + @Path("editAlarmRule") + @Produces(MediaType.APPLICATION_JSON) + public Map editAlarmRule(@FormParam("id") String id, + @FormParam("assetCode") String assetCode, + @FormParam("highValue") String highValue, + @FormParam("lowValue") String lowValue) throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + String result = ""; + + PgAlarmRule pgAlarmRule = null; + PgDevice pgDevice = pgDeviceManager.getDeviceByAssetCode(assetCode); + if (pgDevice == null) { + msg = "不存在设备信息"; + result = "false"; + } else { + try { + pgAlarmRule = pgAlarmRuleManager.get(id); + if (pgAlarmRule == null) { + msg="不存在报警阈值记录"; + result="false"; + } else { + pgAlarmRule.setPgDeviceId(pgDevice); + pgAlarmRule.setHighValue(highValue); + pgAlarmRule.setLowValue(lowValue); + pgAlarmRuleManager.save(pgAlarmRule); + msg="编辑成功"; + result="true"; + } + } catch (Exception ex) { + ex.printStackTrace(); + result = "false"; + msg = "报警阈值编辑失败"; + } + } + resultMap.put("msg", msg); + resultMap.put("result", result); + + return resultMap; + + } + +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java index 80625c7..d8f5e6b 100644 --- a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java +++ b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java @@ -43,9 +43,7 @@ this.intoTime = intoTime; } - @Column(name = "OUT_TIME") - public Date getOutTime() { return outTime; } diff --git a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java index a99981e..b1d63a4 100644 --- a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java +++ b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java @@ -1,11 +1,28 @@ package com.casic.PgInterface.devData.manager; +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.core.util.DateUtils; +import com.casic.PgInterface.core.util.StringUtils; +import com.casic.PgInterface.devData.domain.PgCo; +import com.casic.PgInterface.devData.domain.PgLocation; +import com.casic.PgInterface.devData.dto.PgCoDto; +import com.casic.PgInterface.devData.dto.PgLocationDto; +import com.casic.PgInterface.devTable.domain.PgDevice; +import org.hibernate.Criteria; +import org.hibernate.criterion.Order; +import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; + /** * Created by yxw on 2017/11/2. */ @Service -public class PgLocationManager { +public class PgLocationManager extends HibernateEntityDao { + + //获取设备时间段内所有的监测数据 } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java index cfa0281..7fb5953 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -1,12 +1,12 @@ package com.casic.PgInterface.devTable.domain; import com.casic.PgInterface.devData.domain.*; +import com.casic.PgInterface.patroler.domain.PgAlarmRule; import org.hibernate.annotations.NotFound; import org.hibernate.annotations.NotFoundAction; import javax.persistence.*; import java.io.Serializable; -import java.util.Date; import java.util.List; /** @@ -19,21 +19,27 @@ private static final long serialVersionUID = 1L; private long id; + private PipeGallery pipeGalleryId;//所在管廊信息 + private String road;//路名 + private String position;//设备位置 + private String devType;//设备类型 private String devCode;//设备编号 - private String devName;//设备名称 - private String brand;//品牌 - private String ownerUnit;//权属单位 - private Date installDate;//安装时间 + private String assetName;//资产名称 + private String assetCode;//资产编码 + private String assetBarCode;//资产条码 + private String ip;//IP地址 + private String modBus;//modBus地址 + private String mome;//备注 private int isOpen;//设备是否开启 private int active;//状态位 - private PgDeviceType devTypeId;//设备类型 + private List pgAlarms; - private PgPartition pgPartitionId;//所在管廊信息 private List pgTempHums;//温湿度 private List pgCos;//一氧化碳 private List pgO2s;//氧气 private List pgCh4s;//甲烷 private List pgShs;//硫化氢 + private List pgAlarmRules;//报警规则 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") @@ -45,6 +51,33 @@ this.id = id; } + @Column(name = "ROAD") + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + @Column(name = "POSITION") + public String getPosition() { + return position; + } + + public void setPosition(String position) { + this.position = position; + } + + @Column(name = "DEV_TYPE") + public String getDevType() { + return devType; + } + + public void setDevType(String devType) { + this.devType = devType; + } + @Column(name = "DEV_CODE") public String getDevCode() { return devCode; @@ -54,40 +87,58 @@ this.devCode = devCode; } - @Column(name = "DEV_NAME") - public String getDevName() { - return devName; + @Column(name = "ASSET_NAME") + public String getAssetName() { + return assetName; } - public void setDevName(String devName) { - this.devName = devName; + public void setAssetName(String assetName) { + this.assetName = assetName; } - @Column(name = "BRAND") - public String getBrand() { - return brand; + @Column(name = "ASSET_CODE") + public String getAssetCode() { + return assetCode; } - public void setBrand(String brand) { - this.brand = brand; + public void setAssetCode(String assetCode) { + this.assetCode = assetCode; } - @Column(name = "OWNERUNIT") - public String getOwnerUnit() { - return ownerUnit; + @Column(name = "ASSET_BAR_CODE") + public String getAssetBarCode() { + return assetBarCode; } - public void setOwnerUnit(String ownerUnit) { - this.ownerUnit = ownerUnit; + public void setAssetBarCode(String assetBarCode) { + this.assetBarCode = assetBarCode; } - @Column(name = "INSTALDATE") - public Date getInstallDate() { - return installDate; + @Column(name = "IP") + public String getIp() { + return ip; } - public void setInstallDate(Date installDate) { - this.installDate = installDate; + public void setIp(String ip) { + this.ip = ip; + } + + @Column(name = "MODBUS") + public String getModBus() { + return modBus; + } + + public void setModBus(String modBus) { + this.modBus = modBus; + } + + @Column(name = "MOME") + public String getMome() { + return mome; + } + + public void setMome(String mome) { + this.mome = mome; } @Column(name = "ISOPEN") @@ -119,24 +170,13 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; - } - - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "DEVICE_TYPE_ID") - public PgDeviceType getDevTypeId() { - return devTypeId; - } - - public void setDevTypeId(PgDeviceType devTypeId) { - this.devTypeId = devTypeId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgDeviceId") @@ -184,4 +224,13 @@ this.pgShs = pgShs; } + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgDeviceId") + public List getPgAlarmRules() { + return pgAlarmRules; + } + + public void setPgAlarmRules(List pgAlarmRules) { + this.pgAlarmRules = pgAlarmRules; + } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java index b997b29..4fb3d6f 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java @@ -1,8 +1,5 @@ package com.casic.PgInterface.devTable.domain; -import org.hibernate.annotations.NotFound; -import org.hibernate.annotations.NotFoundAction; - import javax.persistence.*; import java.io.Serializable; import java.util.List; @@ -19,11 +16,9 @@ private long id; private String parName;//分区名称 - private PipeGallery pipeGalleryId;//管廊仓 + private String road;//所属道路 private int active;//状态位 - private List pgTextureList; - private List pgPipeLineList; - private List pgDeviceList; + private List pipeGalleryList;//管廊仓 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PARTITION_ID") @@ -44,6 +39,15 @@ this.parName = parName; } + @Column(name = "ROAD") + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + @Column(name = "ACTIVE") public int getActive() { return active; @@ -53,41 +57,14 @@ this.active = active; } - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PIPEGALLERYID") - public PipeGallery getPipeGalleryId() { - return pipeGalleryId; - } - - public void setPipeGalleryId(PipeGallery pipeGalleryId) { - this.pipeGalleryId = pipeGalleryId; - } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgTextureList() { - return pgTextureList; + public List getPipeGalleryList() { + return pipeGalleryList; } - public void setPgTextureList(List pgTextureList) { - this.pgTextureList = pgTextureList; + public void setPipeGalleryList(List pipeGalleryList) { + this.pipeGalleryList = pipeGalleryList; } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgPipeLineList() { - return pgPipeLineList; - } - public void setPgPipeLineList(List pgPipeLineList) { - this.pgPipeLineList = pgPipeLineList; - } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgDeviceList() { - return pgDeviceList; - } - - public void setPgDeviceList(List pgDeviceList) { - this.pgDeviceList = pgDeviceList; - } } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java index d936d18..e5ff9b3 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java @@ -22,7 +22,7 @@ private Date enterDate;//入廊时间 private String layerNum;//所在层数 private String diameter;//管径 - private PgPartition pgPartitionId;//所在管廊信息 + private PipeGallery pipeGalleryId;//所在管廊信息 private int active;//状态位 @Id @@ -100,12 +100,12 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java index 1f22bf9..4ebfbda 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java @@ -21,7 +21,7 @@ private String ownerUnit;//权属单位 private Date buildDate;//建设年代 private int active;//状态位 - private PgPartition pgPartitionId;//所在管廊信息 + private PipeGallery pipeGalleryId;//所在管廊信息 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_TEXTURE_ID") @@ -91,12 +91,13 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java b/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java index 49a246c..650d623 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java @@ -1,5 +1,8 @@ package com.casic.PgInterface.devTable.domain; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + import javax.persistence.*; import java.io.Serializable; import java.util.List; @@ -16,7 +19,10 @@ private long id; private String pgName;//管廊名称 private int active;//状态位 - private List partitionList; + private PgPartition pgPartitionId;// + private List pgTextureList; + private List pgPipeLineList; + private List pgDeviceList; @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PIPE_GALLERY_ID") @@ -46,12 +52,42 @@ this.active = active; } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") - public List getPartitionList() { - return partitionList; + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "PARTITIONID") + public PgPartition getPgPartitionId() { + return pgPartitionId; } - public void setPartitionList(List partitionList) { - this.partitionList = partitionList; + public void setPgPartitionId(PgPartition pgPartitionId) { + this.pgPartitionId = pgPartitionId; } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgTextureList() { + return pgTextureList; + } + + public void setPgTextureList(List pgTextureList) { + this.pgTextureList = pgTextureList; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgPipeLineList() { + return pgPipeLineList; + } + + public void setPgPipeLineList(List pgPipeLineList) { + this.pgPipeLineList = pgPipeLineList; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgDeviceList() { + return pgDeviceList; + } + + public void setPgDeviceList(List pgDeviceList) { + this.pgDeviceList = pgDeviceList; + } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java index b4048d9..c3dfc55 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java @@ -101,18 +101,17 @@ this.active = active; } - public PgAlarmDto(PgAlarm pgAlarm) - { - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + public PgAlarmDto(PgAlarm pgAlarm) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); this.setId(String.valueOf(pgAlarm.getId())); this.setAlarmType(pgAlarm.getAlarmTypeId().getAlarmType()); this.setAlarmValue(pgAlarm.getAlarmValue()); this.setAlarmDate(sdf.format(pgAlarm.getAlarmDate())); this.setDescription(pgAlarm.getDescription()); - this.setAlarmDevName(pgAlarm.getAlarmDevId().getDevName()); - this.setAlarmLocation(pgAlarm.getAlarmDevId().getPgPartitionId().getPipeGalleryId().getPgName() - + pgAlarm.getAlarmDevId().getPgPartitionId().getParName()); + this.setAlarmDevName(pgAlarm.getAlarmDevId().getAssetName()); + this.setAlarmLocation(pgAlarm.getAlarmDevId().getPipeGalleryId().getPgPartitionId().getParName() + + pgAlarm.getAlarmDevId().getPipeGalleryId().getPgName()); this.setUserName(pgAlarm.getPatrolerId().getUserName()); this.setPhoneNumber(pgAlarm.getPatrolerId().getPhoneNumber()); this.setActive(String.valueOf(pgAlarm.getActive())); diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java index ae76e95..49bd436 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java @@ -11,16 +11,20 @@ public class PgDeviceDto implements Serializable { private String id; - private String devType;//设备类型 - private String devCode;//设备编号 - private String devName;//设备名称 - private String brand;//品牌 - private String ownerUnit;//权属单位 - private String installDate;//安装时间 - private String isOpen;//设备开启状态 - private String active;//状态位 private String pipeGallery;//仓位 private String partition;//分区 + private String road;//路名 + private String position;//设备位置 + private String devType;//设备类型 + private String devCode;//设备编号 + private String assetName;//资产名称 + private String assetCode;//资产名称 + private String assetBarCode;//资产条码 + private String ip;//IP地址 + private String modBus;//modBus地址 + private String mome;//备注 + private String isOpen;//设备开启状态 + private String active;//状态位 public String getId() { return id; @@ -30,6 +34,38 @@ this.id = id; } + public String getPartition() { + return partition; + } + + public void setPartition(String partition) { + this.partition = partition; + } + + public String getPipeGallery() { + return pipeGallery; + } + + public void setPipeGallery(String pipeGallery) { + this.pipeGallery = pipeGallery; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getPosition() { + return position; + } + + public void setPosition(String position) { + this.position = position; + } + public String getDevType() { return devType; } @@ -46,36 +82,52 @@ this.devCode = devCode; } - public String getDevName() { - return devName; + public String getAssetName() { + return assetName; } - public void setDevName(String devName) { - this.devName = devName; + public void setAssetName(String assetName) { + this.assetName = assetName; } - public String getBrand() { - return brand; + public String getAssetCode() { + return assetCode; } - public void setBrand(String brand) { - this.brand = brand; + public void setAssetCode(String assetCode) { + this.assetCode = assetCode; } - public String getOwnerUnit() { - return ownerUnit; + public String getAssetBarCode() { + return assetBarCode; } - public void setOwnerUnit(String ownerUnit) { - this.ownerUnit = ownerUnit; + public void setAssetBarCode(String assetBarCode) { + this.assetBarCode = assetBarCode; } - public String getInstallDate() { - return installDate; + public String getIp() { + return ip; } - public void setInstallDate(String installDate) { - this.installDate = installDate; + public void setIp(String ip) { + this.ip = ip; + } + + public String getModBus() { + return modBus; + } + + public void setModBus(String modBus) { + this.modBus = modBus; + } + + public String getMome() { + return mome; + } + + public void setMome(String mome) { + this.mome = mome; } public String getIsOpen() { @@ -94,39 +146,26 @@ this.active = active; } - public String getPipeGallery() { - return pipeGallery; - } - - public void setPipeGallery(String pipeGallery) { - this.pipeGallery = pipeGallery; - } - - public String getPartition() { - return partition; - } - - public void setPartition(String partition) { - this.partition = partition; - } - public PgDeviceDto(PgDevice pgDevice) { SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); this.setId(String.valueOf(pgDevice.getId())); - this.setDevType(pgDevice.getDevTypeId().getDevType()); + this.setPipeGallery(pgDevice.getPipeGalleryId().getPgName()); + this.setPartition(pgDevice.getPipeGalleryId().getPgPartitionId().getParName()); + this.setRoad(pgDevice.getRoad()); + this.setPosition(pgDevice.getPosition()); + this.setDevType(pgDevice.getDevType()); this.setDevCode(pgDevice.getDevCode()); - this.setDevName(pgDevice.getDevName()); - this.setBrand(pgDevice.getBrand()); - this.setOwnerUnit(pgDevice.getOwnerUnit()); - this.setInstallDate(sdf.format(pgDevice.getInstallDate())); + this.setAssetName(pgDevice.getAssetName()); + this.setAssetCode(pgDevice.getAssetCode()); + this.setAssetBarCode(pgDevice.getAssetBarCode()); + this.setId(pgDevice.getIp()); + this.setModBus(pgDevice.getModBus()); + this.setMome(pgDevice.getMome()); this.setIsOpen(String.valueOf(pgDevice.getIsOpen())); this.setActive(String.valueOf(pgDevice.getActive())); - this.setPipeGallery(pgDevice.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgDevice.getPgPartitionId().getParName()); + } - -} - +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java index e8751d3..3acd0fa 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java @@ -11,7 +11,7 @@ private String id; private String parName;//分区名称 - private String pipeGallery;//管廊仓 + private String road;//所属道路 private String active;//状态位 @@ -31,14 +31,6 @@ this.parName = parName; } - public String getPipeGallery() { - return pipeGallery; - } - - public void setPipeGallery(String pipeGallery) { - this.pipeGallery = pipeGallery; - } - public String getActive() { return active; } @@ -47,11 +39,19 @@ this.active = active; } + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + public PgPartitionDto(PgPartition pgPartition) { this.setId(String.valueOf(pgPartition.getId())); this.setParName(pgPartition.getParName()); - this.setPipeGallery(pgPartition.getPipeGalleryId().getPgName()); + this.setRoad(pgPartition.getRoad()); this.setActive(String.valueOf(pgPartition.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java index 9b161bf..8b430dc 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java @@ -112,8 +112,8 @@ this.setEnterDate(sdf.format(pgPipeLine.getEnterDate())); this.setLayerNum(pgPipeLine.getLayerNum()); this.setDiameter(pgPipeLine.getDiameter()); - this.setPipeGallery(pgPipeLine.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgPipeLine.getPgPartitionId().getParName()); + this.setPipeGallery(pgPipeLine.getPipeGalleryId().getPgName()); + this.setPartition(pgPipeLine.getPipeGalleryId().getPgPartitionId().getParName()); this.setActive(String.valueOf(pgPipeLine.getActive())); } } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java index 03c580c..709dcea 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java @@ -103,8 +103,8 @@ this.setOwnerUnit(pgTexture.getOwnerUnit()); this.setBuildDate(sdf.format(pgTexture.getBuildDate())); this.setActive(String.valueOf(pgTexture.getActive())); - this.setPipeGallery(pgTexture.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgTexture.getPgPartitionId().getParName()); + this.setPipeGallery(pgTexture.getPipeGalleryId().getPgName()); + this.setPartition(pgTexture.getPipeGalleryId().getPgPartitionId().getParName()); } } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java index b40ce84..319cf21 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java @@ -11,6 +11,7 @@ private String id; private String pgName;//管廊名称 + private String pgPartition;//分区名称 private String active;//状态位 public String getId() { @@ -37,10 +38,19 @@ this.active = active; } + public String getPgPartition() { + return pgPartition; + } + + public void setPgPartition(String pgPartition) { + this.pgPartition = pgPartition; + } + public PipeGalleryDto(PipeGallery pipeGallery) { this.setId(String.valueOf(pipeGallery.getId())); this.setPgName(pipeGallery.getPgName()); + this.setPgPartition(pipeGallery.getPgPartitionId().getParName()); this.setActive(String.valueOf(pipeGallery.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java b/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java index 8b413e7..0c594e7 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java @@ -5,10 +5,10 @@ import com.casic.PgInterface.devTable.domain.PipeGallery; import com.casic.PgInterface.devTable.dto.PgPartitionDto; import org.hibernate.Criteria; +import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; -import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; @@ -18,44 +18,50 @@ @Service public class PgPartitionManager extends HibernateEntityDao { - private PipeGalleryManager pipeGalleryManager; - - @Resource - public void setPipeGalleryManager(PipeGalleryManager pipeGalleryManager) { - this.pipeGalleryManager = pipeGalleryManager; - } - - public PgPartition getPartitionByParName(String parName,PipeGallery pipeGallery) { - if(pipeGallery==null) - return null; - Criteria criteria = getSession().createCriteria(PgPartition.class); + public PgPartition getPartitionByParName(String parName) { + Criteria criteria = getSession().createCriteria(PipeGallery.class); criteria.add(Restrictions.eq("parName", parName)); - criteria.add(Restrictions.eq("pipeGalleryId",pipeGallery)); + criteria.add(Restrictions.eq("active",1)); List pgPartitionList = criteria.list(); - //TODO LIST:为空判断 pgPartitionList==null? if (pgPartitionList != null && pgPartitionList.size() > 0) return pgPartitionList.get(0); else return null; } - public List getPartitionByPG(String pgName){ - PipeGallery pipeGallery=pipeGalleryManager.getPipeGalleryByPgName(pgName); - - Criteria criteria=getSession().createCriteria(PgPartition.class); - criteria.add(Restrictions.eq("pipeGalleryId",pipeGallery)); + public List getPartitionByRoad(String road) { + Criteria criteria = getSession().createCriteria(PipeGallery.class); + criteria.add(Restrictions.eq("road", road)); + criteria.add(Restrictions.eq("active",1)); List pgPartitionList = criteria.list(); List pgPartitionDtoList=new ArrayList(); - for(PgPartition pgPartition:pgPartitionList) - { - pgPartitionDtoList.add(new PgPartitionDto(pgPartition)); - } + for(PgPartition pgPartition:pgPartitionList) { + pgPartitionDtoList.add(new PgPartitionDto(pgPartition)); + } return pgPartitionDtoList; } + public List getPgPartitionDtoList() + { + Criteria criteria=getSession().createCriteria(PgPartition.class); + criteria.add(Restrictions.eq("active",1)); + criteria.addOrder(Order.desc("id")); + + List pgPartitionList=criteria.list(); + if(pgPartitionList.size()==0||pgPartitionList==null) + return null; + List pgPartitionDtoList=new ArrayList(); + for(PgPartition pgPartition:pgPartitionList) { + pgPartitionDtoList.add(new PgPartitionDto(pgPartition)); + } + return pgPartitionDtoList; + } + + + } diff --git a/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java b/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java index 16370c6..9bce32b 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java @@ -1,14 +1,16 @@ package com.casic.PgInterface.devTable.manager; import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.devTable.domain.PgPartition; import com.casic.PgInterface.devTable.domain.PipeGallery; import com.casic.PgInterface.devTable.dto.PipeGalleryDto; import org.hibernate.Criteria; -import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; -import java.util.*; +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; /** * Created by yxw on 2017/11/4. @@ -16,36 +18,44 @@ @Service public class PipeGalleryManager extends HibernateEntityDao { - public PipeGallery getPipeGalleryByPgName(String pgName) { - Criteria criteria = getSession().createCriteria(PipeGallery.class); + private PgPartitionManager pgPartitionManager; + + @Resource + public void setPgPartitionManager(PgPartitionManager pgPartitionManager) { + this.pgPartitionManager = pgPartitionManager; + } + + public PipeGallery getPipeGalleryByPgName(String pgName,PgPartition pgPartition) { + if(pgPartition==null) + return null; + Criteria criteria = getSession().createCriteria(PgPartition.class); criteria.add(Restrictions.eq("pgName", pgName)); - criteria.add(Restrictions.eq("active",1)); + criteria.add(Restrictions.eq("pgPartitionId",pgPartition)); List pipeGalleryList = criteria.list(); - //TODO LIST:为空判断 pipeGalleryList==null? + //TODO LIST:为空判断 pgPartitionList==null? if (pipeGalleryList != null && pipeGalleryList.size() > 0) return pipeGalleryList.get(0); else return null; } - public List getPIpeGalleryDtoList() - { - Criteria criteria=getSession().createCriteria(PipeGallery.class); - criteria.add(Restrictions.eq("active",1)); - criteria.addOrder(Order.desc("id")); - List pipeGalleryList=criteria.list(); - if(pipeGalleryList.size()==0||pipeGalleryList==null) - return null; - List pipeGalleryDtoList=new ArrayList(); - for(PipeGallery pipeGallery:pipeGalleryList) { + public List getPipeGalleryByParName(String parName) { + + PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName); + Criteria criteria = getSession().createCriteria(PipeGallery.class); + criteria.add(Restrictions.eq("pgPartitionId", pgPartition)); + + List pipeGalleryList = criteria.list(); + + List pipeGalleryDtoList = new ArrayList(); + for (PipeGallery pipeGallery : pipeGalleryList) { pipeGalleryDtoList.add(new PipeGalleryDto(pipeGallery)); } + return pipeGalleryDtoList; } - - } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java new file mode 100644 index 0000000..9d06235 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java @@ -0,0 +1,63 @@ +package com.casic.PgInterface.patroler.domain; + +import com.casic.PgInterface.devTable.domain.PgDevice; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + +import javax.persistence.*; +import java.io.Serializable; + +/** + * Created by yxw on 2017/12/14. + */ +@Entity +@Table(name = "PG_ALARM_RULE") +@SequenceGenerator(name = "SEQ_PG_ALARM_RULE_ID", sequenceName = "SEQ_PG_ALARM_RULE_ID",allocationSize=1,initialValue=1) +public class PgAlarmRule implements Serializable { + + private static final long serialVersionUID = 1L; + private long id; + private String highValue;//高限 + private String lowValue;//低限 + private PgDevice pgDeviceId;//设备 + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_ALARM_RULE_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "HIGHVALUE") + public String getHighValue() { + return highValue; + } + + public void setHighValue(String highValue) { + this.highValue = highValue; + } + + @Column(name = "LOWVALUE") + public String getLowValue() { + return lowValue; + } + + public void setLowValue(String lowValue) { + this.lowValue = lowValue; + } + + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "PGDEVICEID") + public PgDevice getPgDeviceId() { + return pgDeviceId; + } + + public void setPgDeviceId(PgDevice pgDeviceId) { + this.pgDeviceId = pgDeviceId; + } + +} diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java new file mode 100644 index 0000000..8367ad4 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java @@ -0,0 +1,57 @@ +package com.casic.PgInterface.patroler.dto; + +import com.casic.PgInterface.patroler.domain.PgAlarmRule; + +import java.io.Serializable; + +/** + * Created by yxw on 2017/12/14. + */ +public class PgAlarmRuleDto implements Serializable { + + private String id; + private String highValue;//高限 + private String lowValue;//低限 + private String devName;//设备 + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getHighValue() { + return highValue; + } + + public void setHighValue(String highValue) { + this.highValue = highValue; + } + + public String getLowValue() { + return lowValue; + } + + public void setLowValue(String lowValue) { + this.lowValue = lowValue; + } + + public String getDevName() { + return devName; + } + + public void setDevName(String devName) { + this.devName = devName; + } + + public PgAlarmRuleDto(PgAlarmRule pgAlarmRule) + { + this.setId(String.valueOf(pgAlarmRule.getId())); + this.setDevName(pgAlarmRule.getPgDeviceId().getAssetName()); + this.setHighValue(pgAlarmRule.getHighValue()); + this.setLowValue(pgAlarmRule.getLowValue()); + } + +} diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java new file mode 100644 index 0000000..d5c00b2 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java @@ -0,0 +1,42 @@ +package com.casic.PgInterface.patroler.manager; + +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.devTable.domain.PgDevice; +import com.casic.PgInterface.patroler.domain.PgAlarmRule; +import com.casic.PgInterface.patroler.dto.PgAlarmRuleDto; +import org.hibernate.Criteria; +import org.hibernate.criterion.Restrictions; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * Created by yxw on 2017/12/14. + */ +@Service +public class PgAlarmRuleManager extends HibernateEntityDao { + + //根据设备获取设备报警阈值 + public PgAlarmRuleDto getAlarmRuleDtoBydev(PgDevice pgDeviceId) { + Criteria criteria=createCriteria(PgAlarmRule.class); + criteria.add(Restrictions.eq("pgDeviceId", pgDeviceId)); + + List pgAlarmRuleList=criteria.list(); + if(pgAlarmRuleList.size()==0) + return null; + else + return new PgAlarmRuleDto(pgAlarmRuleList.get(0)); + } + + public PgAlarmRule getAlarmRuleBydev(PgDevice pgDeviceId) { + Criteria criteria=createCriteria(PgAlarmRule.class); + criteria.add(Restrictions.eq("pgDeviceId", pgDeviceId)); + + List pgAlarmRuleList=criteria.list(); + if(pgAlarmRuleList.size()==0) + return null; + else + return pgAlarmRuleList.get(0); + } + +} diff --git a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java new file mode 100644 index 0000000..88255c6 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java @@ -0,0 +1,162 @@ +package com.casic.PgInterface.rs; + +import com.casic.PgInterface.devTable.domain.PgDevice; +import com.casic.PgInterface.devTable.manager.PgDeviceManager; +import com.casic.PgInterface.patroler.domain.PgAlarmRule; +import com.casic.PgInterface.patroler.dto.PgAlarmRuleDto; +import com.casic.PgInterface.patroler.manager.PgAlarmRuleManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import javax.ws.rs.FormParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import java.util.HashMap; +import java.util.Map; + +/** + * Created by yxw on 2017/12/14. + */ +@Component +@Path("pgAlarmRule") +public class PgAlarmRuleRs { + + private static Logger logger = LoggerFactory.getLogger(PgAlarmRule.class); + + private PgDeviceManager pgDeviceManager; + + private PgAlarmRuleManager pgAlarmRuleManager; + + @Resource + public void setPgAlarmRuleManager(PgAlarmRuleManager pgAlarmRuleManager) { + this.pgAlarmRuleManager = pgAlarmRuleManager; + } + + @Resource + public void setPgDeviceManager(PgDeviceManager pgDeviceManager) { + this.pgDeviceManager = pgDeviceManager; + } + + /** + * 获取报警阈值信息 + */ + @POST + @Path("getAlarmRuleByAssetCode") + @Produces(MediaType.APPLICATION_JSON) + public Map getAlarmRuleByAssetCode(@FormParam("assetCode") String assetCode) throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + + PgAlarmRuleDto pgAlarmRuleDto = null; + PgDevice pgDevice = pgDeviceManager.getDeviceByAssetCode(assetCode); + try { + pgAlarmRuleDto = pgAlarmRuleManager.getAlarmRuleDtoBydev(pgDevice); + if (pgAlarmRuleDto == null) + msg = "不存在报警阈值信息"; + else + msg = "报警阈值获取成功"; + } catch (Exception e) { + e.printStackTrace(); + msg = "报警信息获取失败"; + } + resultMap.put("msg", msg); + resultMap.put("result", pgAlarmRuleDto); + return resultMap; + } + + /** + * 新增报警阈值 + */ + @POST + @Path("addAlarmRule") + @Produces(MediaType.APPLICATION_JSON) + public Map addAlarmRule(@FormParam("assetCode") String assetCode, + @FormParam("highValue") String highValue, + @FormParam("lowValue") String lowValue) throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + String result = ""; + + PgAlarmRule pgAlarmRule = null; + PgDevice pgDevice = pgDeviceManager.getDeviceByAssetCode(assetCode); + if (pgDevice == null) + msg = "不存在设备信息"; + else { + try { + pgAlarmRule = pgAlarmRuleManager.getAlarmRuleBydev(pgDevice); + if (pgAlarmRule != null) { + result = "false"; + msg = "设备阈值已经存在"; + } else { + pgAlarmRule = new PgAlarmRule(); + pgAlarmRule.setHighValue(highValue); + pgAlarmRule.setLowValue(lowValue); + pgAlarmRule.setPgDeviceId(pgDevice); + + pgAlarmRuleManager.save(pgAlarmRule); + result = "true"; + msg = "报警阈值新增成功"; + } + + } catch (Exception e) { + e.printStackTrace(); + result = "false"; + msg = "报警阈值新增失败"; + } + } + resultMap.put("msg", msg); + resultMap.put("result", result); + return resultMap; + } + + /** + * 编辑报警阈值 + */ + @POST + @Path("editAlarmRule") + @Produces(MediaType.APPLICATION_JSON) + public Map editAlarmRule(@FormParam("id") String id, + @FormParam("assetCode") String assetCode, + @FormParam("highValue") String highValue, + @FormParam("lowValue") String lowValue) throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + String result = ""; + + PgAlarmRule pgAlarmRule = null; + PgDevice pgDevice = pgDeviceManager.getDeviceByAssetCode(assetCode); + if (pgDevice == null) { + msg = "不存在设备信息"; + result = "false"; + } else { + try { + pgAlarmRule = pgAlarmRuleManager.get(id); + if (pgAlarmRule == null) { + msg="不存在报警阈值记录"; + result="false"; + } else { + pgAlarmRule.setPgDeviceId(pgDevice); + pgAlarmRule.setHighValue(highValue); + pgAlarmRule.setLowValue(lowValue); + pgAlarmRuleManager.save(pgAlarmRule); + msg="编辑成功"; + result="true"; + } + } catch (Exception ex) { + ex.printStackTrace(); + result = "false"; + msg = "报警阈值编辑失败"; + } + } + resultMap.put("msg", msg); + resultMap.put("result", result); + + return resultMap; + + } + +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java b/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java index 36a4fc5..4f77754 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java @@ -18,7 +18,6 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; -import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -65,14 +64,14 @@ * 获取设备信息 */ @POST - @Path("getPgDeviceByName") + @Path("getPgDeviceByAssetCode") @Produces(MediaType.APPLICATION_JSON) - public Map getPgDeviceByName(@FormParam("devName") String devName) throws Exception { + public Map getPgDeviceByAssetCode(@FormParam("assetCode") String assetCode) throws Exception { Map resultMap = new HashMap(); String msg = ""; PgDeviceDto pgDeviceDto=null; try { - PgDevice pgDevice = pgDeviceManager.getDeviceBydevName(devName); + PgDevice pgDevice = pgDeviceManager.getDeviceByAssetCode(assetCode); pgDeviceDto=new PgDeviceDto(pgDevice); msg = "获取成功"; } catch (Exception e) { @@ -84,7 +83,6 @@ return resultMap; } - /** * 显示设备列表 */ @@ -116,42 +114,49 @@ @POST @Path("addDevice") @Produces(MediaType.APPLICATION_JSON) - public Map addDevice(@FormParam("devType") String devType, - @FormParam("devCode") String devCode, - @FormParam("devName") String devName, - @FormParam("brand") String brand, - @FormParam("ownerUnit") String ownerUnit, - @FormParam("installDate") String installDate, - @FormParam("pgName") String pgName, - @FormParam("parName") String parName) + public Map addDevice(@FormParam("parName") String parName, + @FormParam("pgName") String pgName, + @FormParam("road") String road, + @FormParam("position") String position, + @FormParam("devType") String devType, + @FormParam("devCode") String devCode, + @FormParam("assetName") String assetName, + @FormParam("assetCode") String assetCode, + @FormParam("assetBarCode") String assetBarCode, + @FormParam("ip") String ip, + @FormParam("modBus") String modBus, + @FormParam("mome") String mome) throws Exception { - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - Map resultMap = new HashMap(); String result = ""; String msg = ""; - PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName); - PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName, pipeGallery); + PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName); + PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName,pgPartition); + if (pgPartition == null) { result = "false"; msg = "不存在管廊仓和分区信息"; } else { try { - if (pgDeviceManager.getDeviceBydevName(devName)!=null) { + if (pgDeviceManager.getDeviceByAssetCode(assetCode)!=null) { result = "false"; msg = "已存在同名设备"; } else { PgDevice pgDevice = new PgDevice(); - pgDevice.setDevTypeId(pgDeviceTypeManager.getPgDeviceTypeByDevType(devType)); + pgDevice.setPipeGalleryId(pipeGallery); + pgDevice.setRoad(road); + pgDevice.setPosition(position); + pgDevice.setDevType(devType); pgDevice.setDevCode(devCode); - pgDevice.setDevName(devName); - pgDevice.setBrand(brand); - pgDevice.setOwnerUnit(ownerUnit); - pgDevice.setInstallDate(sdf.parse(installDate)); - pgDevice.setPgPartitionId(pgPartition); + pgDevice.setAssetName(assetName); + pgDevice.setAssetCode(assetCode); + pgDevice.setAssetBarCode(assetBarCode); + pgDevice.setIp(ip); + pgDevice.setModBus(modBus); + pgDevice.setMome(mome); pgDevice.setIsOpen(0); pgDevice.setActive(1); @@ -179,41 +184,49 @@ @Path("editDevice") @Produces(MediaType.APPLICATION_JSON) public Map editPartition(@FormParam("id") String id, + @FormParam("parName") String parName, + @FormParam("pgName") String pgName, + @FormParam("road") String road, + @FormParam("position") String position, @FormParam("devType") String devType, @FormParam("devCode") String devCode, - @FormParam("devName") String devName, - @FormParam("brand") String brand, - @FormParam("ownerUnit") String ownerUnit, - @FormParam("installDate") String installDate, - @FormParam("pgName") String pgName, - @FormParam("parName") String parName, + @FormParam("assetName") String assetName, + @FormParam("assetCode") String assetCode, + @FormParam("assetBarCode") String assetBarCode, + @FormParam("ip") String ip, + @FormParam("modBus") String modBus, + @FormParam("mome") String mome, @FormParam("isOpen") String isOpen) throws Exception { - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - Map resultMap = new HashMap(); String result = ""; String msg = ""; - PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName); - PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName, pipeGallery); + PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName); + PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName,pgPartition); + if (pgPartition == null) { result = "false"; msg = "不存在管廊仓和分区信息"; } else { try { - if (pgDeviceManager.getDeviceBydevName(devName)!=null) { + if (pgDeviceManager.getDeviceByAssetCode(assetCode)!=null) { result = "false"; msg = "已存在同名设备"; } else { PgDevice pgDevice = pgDeviceManager.get(Long.valueOf(id)); - pgDevice.setDevTypeId(pgDeviceTypeManager.getPgDeviceTypeByDevType(devType)); + pgDevice.setPipeGalleryId(pipeGallery); + pgDevice.setRoad(road); + pgDevice.setPosition(position); + pgDevice.setDevType(devType); pgDevice.setDevCode(devCode); - pgDevice.setDevName(devName); - pgDevice.setBrand(brand); - pgDevice.setOwnerUnit(ownerUnit); - pgDevice.setInstallDate(sdf.parse(installDate)); - pgDevice.setPgPartitionId(pgPartition); + pgDevice.setAssetName(assetName); + pgDevice.setAssetCode(assetCode); + pgDevice.setAssetBarCode(assetBarCode); + pgDevice.setIp(ip); + pgDevice.setModBus(modBus); + pgDevice.setMome(mome); + pgDevice.setActive(1); pgDevice.setIsOpen(Integer.valueOf(isOpen)); pgDeviceManager.save(pgDevice); diff --git a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java index 80625c7..d8f5e6b 100644 --- a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java +++ b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java @@ -43,9 +43,7 @@ this.intoTime = intoTime; } - @Column(name = "OUT_TIME") - public Date getOutTime() { return outTime; } diff --git a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java index a99981e..b1d63a4 100644 --- a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java +++ b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java @@ -1,11 +1,28 @@ package com.casic.PgInterface.devData.manager; +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.core.util.DateUtils; +import com.casic.PgInterface.core.util.StringUtils; +import com.casic.PgInterface.devData.domain.PgCo; +import com.casic.PgInterface.devData.domain.PgLocation; +import com.casic.PgInterface.devData.dto.PgCoDto; +import com.casic.PgInterface.devData.dto.PgLocationDto; +import com.casic.PgInterface.devTable.domain.PgDevice; +import org.hibernate.Criteria; +import org.hibernate.criterion.Order; +import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; + /** * Created by yxw on 2017/11/2. */ @Service -public class PgLocationManager { +public class PgLocationManager extends HibernateEntityDao { + + //获取设备时间段内所有的监测数据 } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java index cfa0281..7fb5953 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -1,12 +1,12 @@ package com.casic.PgInterface.devTable.domain; import com.casic.PgInterface.devData.domain.*; +import com.casic.PgInterface.patroler.domain.PgAlarmRule; import org.hibernate.annotations.NotFound; import org.hibernate.annotations.NotFoundAction; import javax.persistence.*; import java.io.Serializable; -import java.util.Date; import java.util.List; /** @@ -19,21 +19,27 @@ private static final long serialVersionUID = 1L; private long id; + private PipeGallery pipeGalleryId;//所在管廊信息 + private String road;//路名 + private String position;//设备位置 + private String devType;//设备类型 private String devCode;//设备编号 - private String devName;//设备名称 - private String brand;//品牌 - private String ownerUnit;//权属单位 - private Date installDate;//安装时间 + private String assetName;//资产名称 + private String assetCode;//资产编码 + private String assetBarCode;//资产条码 + private String ip;//IP地址 + private String modBus;//modBus地址 + private String mome;//备注 private int isOpen;//设备是否开启 private int active;//状态位 - private PgDeviceType devTypeId;//设备类型 + private List pgAlarms; - private PgPartition pgPartitionId;//所在管廊信息 private List pgTempHums;//温湿度 private List pgCos;//一氧化碳 private List pgO2s;//氧气 private List pgCh4s;//甲烷 private List pgShs;//硫化氢 + private List pgAlarmRules;//报警规则 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") @@ -45,6 +51,33 @@ this.id = id; } + @Column(name = "ROAD") + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + @Column(name = "POSITION") + public String getPosition() { + return position; + } + + public void setPosition(String position) { + this.position = position; + } + + @Column(name = "DEV_TYPE") + public String getDevType() { + return devType; + } + + public void setDevType(String devType) { + this.devType = devType; + } + @Column(name = "DEV_CODE") public String getDevCode() { return devCode; @@ -54,40 +87,58 @@ this.devCode = devCode; } - @Column(name = "DEV_NAME") - public String getDevName() { - return devName; + @Column(name = "ASSET_NAME") + public String getAssetName() { + return assetName; } - public void setDevName(String devName) { - this.devName = devName; + public void setAssetName(String assetName) { + this.assetName = assetName; } - @Column(name = "BRAND") - public String getBrand() { - return brand; + @Column(name = "ASSET_CODE") + public String getAssetCode() { + return assetCode; } - public void setBrand(String brand) { - this.brand = brand; + public void setAssetCode(String assetCode) { + this.assetCode = assetCode; } - @Column(name = "OWNERUNIT") - public String getOwnerUnit() { - return ownerUnit; + @Column(name = "ASSET_BAR_CODE") + public String getAssetBarCode() { + return assetBarCode; } - public void setOwnerUnit(String ownerUnit) { - this.ownerUnit = ownerUnit; + public void setAssetBarCode(String assetBarCode) { + this.assetBarCode = assetBarCode; } - @Column(name = "INSTALDATE") - public Date getInstallDate() { - return installDate; + @Column(name = "IP") + public String getIp() { + return ip; } - public void setInstallDate(Date installDate) { - this.installDate = installDate; + public void setIp(String ip) { + this.ip = ip; + } + + @Column(name = "MODBUS") + public String getModBus() { + return modBus; + } + + public void setModBus(String modBus) { + this.modBus = modBus; + } + + @Column(name = "MOME") + public String getMome() { + return mome; + } + + public void setMome(String mome) { + this.mome = mome; } @Column(name = "ISOPEN") @@ -119,24 +170,13 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; - } - - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "DEVICE_TYPE_ID") - public PgDeviceType getDevTypeId() { - return devTypeId; - } - - public void setDevTypeId(PgDeviceType devTypeId) { - this.devTypeId = devTypeId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgDeviceId") @@ -184,4 +224,13 @@ this.pgShs = pgShs; } + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgDeviceId") + public List getPgAlarmRules() { + return pgAlarmRules; + } + + public void setPgAlarmRules(List pgAlarmRules) { + this.pgAlarmRules = pgAlarmRules; + } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java index b997b29..4fb3d6f 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java @@ -1,8 +1,5 @@ package com.casic.PgInterface.devTable.domain; -import org.hibernate.annotations.NotFound; -import org.hibernate.annotations.NotFoundAction; - import javax.persistence.*; import java.io.Serializable; import java.util.List; @@ -19,11 +16,9 @@ private long id; private String parName;//分区名称 - private PipeGallery pipeGalleryId;//管廊仓 + private String road;//所属道路 private int active;//状态位 - private List pgTextureList; - private List pgPipeLineList; - private List pgDeviceList; + private List pipeGalleryList;//管廊仓 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PARTITION_ID") @@ -44,6 +39,15 @@ this.parName = parName; } + @Column(name = "ROAD") + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + @Column(name = "ACTIVE") public int getActive() { return active; @@ -53,41 +57,14 @@ this.active = active; } - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PIPEGALLERYID") - public PipeGallery getPipeGalleryId() { - return pipeGalleryId; - } - - public void setPipeGalleryId(PipeGallery pipeGalleryId) { - this.pipeGalleryId = pipeGalleryId; - } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgTextureList() { - return pgTextureList; + public List getPipeGalleryList() { + return pipeGalleryList; } - public void setPgTextureList(List pgTextureList) { - this.pgTextureList = pgTextureList; + public void setPipeGalleryList(List pipeGalleryList) { + this.pipeGalleryList = pipeGalleryList; } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgPipeLineList() { - return pgPipeLineList; - } - public void setPgPipeLineList(List pgPipeLineList) { - this.pgPipeLineList = pgPipeLineList; - } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgDeviceList() { - return pgDeviceList; - } - - public void setPgDeviceList(List pgDeviceList) { - this.pgDeviceList = pgDeviceList; - } } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java index d936d18..e5ff9b3 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java @@ -22,7 +22,7 @@ private Date enterDate;//入廊时间 private String layerNum;//所在层数 private String diameter;//管径 - private PgPartition pgPartitionId;//所在管廊信息 + private PipeGallery pipeGalleryId;//所在管廊信息 private int active;//状态位 @Id @@ -100,12 +100,12 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java index 1f22bf9..4ebfbda 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java @@ -21,7 +21,7 @@ private String ownerUnit;//权属单位 private Date buildDate;//建设年代 private int active;//状态位 - private PgPartition pgPartitionId;//所在管廊信息 + private PipeGallery pipeGalleryId;//所在管廊信息 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_TEXTURE_ID") @@ -91,12 +91,13 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java b/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java index 49a246c..650d623 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java @@ -1,5 +1,8 @@ package com.casic.PgInterface.devTable.domain; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + import javax.persistence.*; import java.io.Serializable; import java.util.List; @@ -16,7 +19,10 @@ private long id; private String pgName;//管廊名称 private int active;//状态位 - private List partitionList; + private PgPartition pgPartitionId;// + private List pgTextureList; + private List pgPipeLineList; + private List pgDeviceList; @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PIPE_GALLERY_ID") @@ -46,12 +52,42 @@ this.active = active; } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") - public List getPartitionList() { - return partitionList; + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "PARTITIONID") + public PgPartition getPgPartitionId() { + return pgPartitionId; } - public void setPartitionList(List partitionList) { - this.partitionList = partitionList; + public void setPgPartitionId(PgPartition pgPartitionId) { + this.pgPartitionId = pgPartitionId; } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgTextureList() { + return pgTextureList; + } + + public void setPgTextureList(List pgTextureList) { + this.pgTextureList = pgTextureList; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgPipeLineList() { + return pgPipeLineList; + } + + public void setPgPipeLineList(List pgPipeLineList) { + this.pgPipeLineList = pgPipeLineList; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgDeviceList() { + return pgDeviceList; + } + + public void setPgDeviceList(List pgDeviceList) { + this.pgDeviceList = pgDeviceList; + } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java index b4048d9..c3dfc55 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java @@ -101,18 +101,17 @@ this.active = active; } - public PgAlarmDto(PgAlarm pgAlarm) - { - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + public PgAlarmDto(PgAlarm pgAlarm) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); this.setId(String.valueOf(pgAlarm.getId())); this.setAlarmType(pgAlarm.getAlarmTypeId().getAlarmType()); this.setAlarmValue(pgAlarm.getAlarmValue()); this.setAlarmDate(sdf.format(pgAlarm.getAlarmDate())); this.setDescription(pgAlarm.getDescription()); - this.setAlarmDevName(pgAlarm.getAlarmDevId().getDevName()); - this.setAlarmLocation(pgAlarm.getAlarmDevId().getPgPartitionId().getPipeGalleryId().getPgName() - + pgAlarm.getAlarmDevId().getPgPartitionId().getParName()); + this.setAlarmDevName(pgAlarm.getAlarmDevId().getAssetName()); + this.setAlarmLocation(pgAlarm.getAlarmDevId().getPipeGalleryId().getPgPartitionId().getParName() + + pgAlarm.getAlarmDevId().getPipeGalleryId().getPgName()); this.setUserName(pgAlarm.getPatrolerId().getUserName()); this.setPhoneNumber(pgAlarm.getPatrolerId().getPhoneNumber()); this.setActive(String.valueOf(pgAlarm.getActive())); diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java index ae76e95..49bd436 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java @@ -11,16 +11,20 @@ public class PgDeviceDto implements Serializable { private String id; - private String devType;//设备类型 - private String devCode;//设备编号 - private String devName;//设备名称 - private String brand;//品牌 - private String ownerUnit;//权属单位 - private String installDate;//安装时间 - private String isOpen;//设备开启状态 - private String active;//状态位 private String pipeGallery;//仓位 private String partition;//分区 + private String road;//路名 + private String position;//设备位置 + private String devType;//设备类型 + private String devCode;//设备编号 + private String assetName;//资产名称 + private String assetCode;//资产名称 + private String assetBarCode;//资产条码 + private String ip;//IP地址 + private String modBus;//modBus地址 + private String mome;//备注 + private String isOpen;//设备开启状态 + private String active;//状态位 public String getId() { return id; @@ -30,6 +34,38 @@ this.id = id; } + public String getPartition() { + return partition; + } + + public void setPartition(String partition) { + this.partition = partition; + } + + public String getPipeGallery() { + return pipeGallery; + } + + public void setPipeGallery(String pipeGallery) { + this.pipeGallery = pipeGallery; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getPosition() { + return position; + } + + public void setPosition(String position) { + this.position = position; + } + public String getDevType() { return devType; } @@ -46,36 +82,52 @@ this.devCode = devCode; } - public String getDevName() { - return devName; + public String getAssetName() { + return assetName; } - public void setDevName(String devName) { - this.devName = devName; + public void setAssetName(String assetName) { + this.assetName = assetName; } - public String getBrand() { - return brand; + public String getAssetCode() { + return assetCode; } - public void setBrand(String brand) { - this.brand = brand; + public void setAssetCode(String assetCode) { + this.assetCode = assetCode; } - public String getOwnerUnit() { - return ownerUnit; + public String getAssetBarCode() { + return assetBarCode; } - public void setOwnerUnit(String ownerUnit) { - this.ownerUnit = ownerUnit; + public void setAssetBarCode(String assetBarCode) { + this.assetBarCode = assetBarCode; } - public String getInstallDate() { - return installDate; + public String getIp() { + return ip; } - public void setInstallDate(String installDate) { - this.installDate = installDate; + public void setIp(String ip) { + this.ip = ip; + } + + public String getModBus() { + return modBus; + } + + public void setModBus(String modBus) { + this.modBus = modBus; + } + + public String getMome() { + return mome; + } + + public void setMome(String mome) { + this.mome = mome; } public String getIsOpen() { @@ -94,39 +146,26 @@ this.active = active; } - public String getPipeGallery() { - return pipeGallery; - } - - public void setPipeGallery(String pipeGallery) { - this.pipeGallery = pipeGallery; - } - - public String getPartition() { - return partition; - } - - public void setPartition(String partition) { - this.partition = partition; - } - public PgDeviceDto(PgDevice pgDevice) { SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); this.setId(String.valueOf(pgDevice.getId())); - this.setDevType(pgDevice.getDevTypeId().getDevType()); + this.setPipeGallery(pgDevice.getPipeGalleryId().getPgName()); + this.setPartition(pgDevice.getPipeGalleryId().getPgPartitionId().getParName()); + this.setRoad(pgDevice.getRoad()); + this.setPosition(pgDevice.getPosition()); + this.setDevType(pgDevice.getDevType()); this.setDevCode(pgDevice.getDevCode()); - this.setDevName(pgDevice.getDevName()); - this.setBrand(pgDevice.getBrand()); - this.setOwnerUnit(pgDevice.getOwnerUnit()); - this.setInstallDate(sdf.format(pgDevice.getInstallDate())); + this.setAssetName(pgDevice.getAssetName()); + this.setAssetCode(pgDevice.getAssetCode()); + this.setAssetBarCode(pgDevice.getAssetBarCode()); + this.setId(pgDevice.getIp()); + this.setModBus(pgDevice.getModBus()); + this.setMome(pgDevice.getMome()); this.setIsOpen(String.valueOf(pgDevice.getIsOpen())); this.setActive(String.valueOf(pgDevice.getActive())); - this.setPipeGallery(pgDevice.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgDevice.getPgPartitionId().getParName()); + } - -} - +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java index e8751d3..3acd0fa 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java @@ -11,7 +11,7 @@ private String id; private String parName;//分区名称 - private String pipeGallery;//管廊仓 + private String road;//所属道路 private String active;//状态位 @@ -31,14 +31,6 @@ this.parName = parName; } - public String getPipeGallery() { - return pipeGallery; - } - - public void setPipeGallery(String pipeGallery) { - this.pipeGallery = pipeGallery; - } - public String getActive() { return active; } @@ -47,11 +39,19 @@ this.active = active; } + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + public PgPartitionDto(PgPartition pgPartition) { this.setId(String.valueOf(pgPartition.getId())); this.setParName(pgPartition.getParName()); - this.setPipeGallery(pgPartition.getPipeGalleryId().getPgName()); + this.setRoad(pgPartition.getRoad()); this.setActive(String.valueOf(pgPartition.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java index 9b161bf..8b430dc 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java @@ -112,8 +112,8 @@ this.setEnterDate(sdf.format(pgPipeLine.getEnterDate())); this.setLayerNum(pgPipeLine.getLayerNum()); this.setDiameter(pgPipeLine.getDiameter()); - this.setPipeGallery(pgPipeLine.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgPipeLine.getPgPartitionId().getParName()); + this.setPipeGallery(pgPipeLine.getPipeGalleryId().getPgName()); + this.setPartition(pgPipeLine.getPipeGalleryId().getPgPartitionId().getParName()); this.setActive(String.valueOf(pgPipeLine.getActive())); } } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java index 03c580c..709dcea 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java @@ -103,8 +103,8 @@ this.setOwnerUnit(pgTexture.getOwnerUnit()); this.setBuildDate(sdf.format(pgTexture.getBuildDate())); this.setActive(String.valueOf(pgTexture.getActive())); - this.setPipeGallery(pgTexture.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgTexture.getPgPartitionId().getParName()); + this.setPipeGallery(pgTexture.getPipeGalleryId().getPgName()); + this.setPartition(pgTexture.getPipeGalleryId().getPgPartitionId().getParName()); } } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java index b40ce84..319cf21 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java @@ -11,6 +11,7 @@ private String id; private String pgName;//管廊名称 + private String pgPartition;//分区名称 private String active;//状态位 public String getId() { @@ -37,10 +38,19 @@ this.active = active; } + public String getPgPartition() { + return pgPartition; + } + + public void setPgPartition(String pgPartition) { + this.pgPartition = pgPartition; + } + public PipeGalleryDto(PipeGallery pipeGallery) { this.setId(String.valueOf(pipeGallery.getId())); this.setPgName(pipeGallery.getPgName()); + this.setPgPartition(pipeGallery.getPgPartitionId().getParName()); this.setActive(String.valueOf(pipeGallery.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java b/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java index 8b413e7..0c594e7 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java @@ -5,10 +5,10 @@ import com.casic.PgInterface.devTable.domain.PipeGallery; import com.casic.PgInterface.devTable.dto.PgPartitionDto; import org.hibernate.Criteria; +import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; -import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; @@ -18,44 +18,50 @@ @Service public class PgPartitionManager extends HibernateEntityDao { - private PipeGalleryManager pipeGalleryManager; - - @Resource - public void setPipeGalleryManager(PipeGalleryManager pipeGalleryManager) { - this.pipeGalleryManager = pipeGalleryManager; - } - - public PgPartition getPartitionByParName(String parName,PipeGallery pipeGallery) { - if(pipeGallery==null) - return null; - Criteria criteria = getSession().createCriteria(PgPartition.class); + public PgPartition getPartitionByParName(String parName) { + Criteria criteria = getSession().createCriteria(PipeGallery.class); criteria.add(Restrictions.eq("parName", parName)); - criteria.add(Restrictions.eq("pipeGalleryId",pipeGallery)); + criteria.add(Restrictions.eq("active",1)); List pgPartitionList = criteria.list(); - //TODO LIST:为空判断 pgPartitionList==null? if (pgPartitionList != null && pgPartitionList.size() > 0) return pgPartitionList.get(0); else return null; } - public List getPartitionByPG(String pgName){ - PipeGallery pipeGallery=pipeGalleryManager.getPipeGalleryByPgName(pgName); - - Criteria criteria=getSession().createCriteria(PgPartition.class); - criteria.add(Restrictions.eq("pipeGalleryId",pipeGallery)); + public List getPartitionByRoad(String road) { + Criteria criteria = getSession().createCriteria(PipeGallery.class); + criteria.add(Restrictions.eq("road", road)); + criteria.add(Restrictions.eq("active",1)); List pgPartitionList = criteria.list(); List pgPartitionDtoList=new ArrayList(); - for(PgPartition pgPartition:pgPartitionList) - { - pgPartitionDtoList.add(new PgPartitionDto(pgPartition)); - } + for(PgPartition pgPartition:pgPartitionList) { + pgPartitionDtoList.add(new PgPartitionDto(pgPartition)); + } return pgPartitionDtoList; } + public List getPgPartitionDtoList() + { + Criteria criteria=getSession().createCriteria(PgPartition.class); + criteria.add(Restrictions.eq("active",1)); + criteria.addOrder(Order.desc("id")); + + List pgPartitionList=criteria.list(); + if(pgPartitionList.size()==0||pgPartitionList==null) + return null; + List pgPartitionDtoList=new ArrayList(); + for(PgPartition pgPartition:pgPartitionList) { + pgPartitionDtoList.add(new PgPartitionDto(pgPartition)); + } + return pgPartitionDtoList; + } + + + } diff --git a/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java b/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java index 16370c6..9bce32b 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java @@ -1,14 +1,16 @@ package com.casic.PgInterface.devTable.manager; import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.devTable.domain.PgPartition; import com.casic.PgInterface.devTable.domain.PipeGallery; import com.casic.PgInterface.devTable.dto.PipeGalleryDto; import org.hibernate.Criteria; -import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; -import java.util.*; +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; /** * Created by yxw on 2017/11/4. @@ -16,36 +18,44 @@ @Service public class PipeGalleryManager extends HibernateEntityDao { - public PipeGallery getPipeGalleryByPgName(String pgName) { - Criteria criteria = getSession().createCriteria(PipeGallery.class); + private PgPartitionManager pgPartitionManager; + + @Resource + public void setPgPartitionManager(PgPartitionManager pgPartitionManager) { + this.pgPartitionManager = pgPartitionManager; + } + + public PipeGallery getPipeGalleryByPgName(String pgName,PgPartition pgPartition) { + if(pgPartition==null) + return null; + Criteria criteria = getSession().createCriteria(PgPartition.class); criteria.add(Restrictions.eq("pgName", pgName)); - criteria.add(Restrictions.eq("active",1)); + criteria.add(Restrictions.eq("pgPartitionId",pgPartition)); List pipeGalleryList = criteria.list(); - //TODO LIST:为空判断 pipeGalleryList==null? + //TODO LIST:为空判断 pgPartitionList==null? if (pipeGalleryList != null && pipeGalleryList.size() > 0) return pipeGalleryList.get(0); else return null; } - public List getPIpeGalleryDtoList() - { - Criteria criteria=getSession().createCriteria(PipeGallery.class); - criteria.add(Restrictions.eq("active",1)); - criteria.addOrder(Order.desc("id")); - List pipeGalleryList=criteria.list(); - if(pipeGalleryList.size()==0||pipeGalleryList==null) - return null; - List pipeGalleryDtoList=new ArrayList(); - for(PipeGallery pipeGallery:pipeGalleryList) { + public List getPipeGalleryByParName(String parName) { + + PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName); + Criteria criteria = getSession().createCriteria(PipeGallery.class); + criteria.add(Restrictions.eq("pgPartitionId", pgPartition)); + + List pipeGalleryList = criteria.list(); + + List pipeGalleryDtoList = new ArrayList(); + for (PipeGallery pipeGallery : pipeGalleryList) { pipeGalleryDtoList.add(new PipeGalleryDto(pipeGallery)); } + return pipeGalleryDtoList; } - - } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java new file mode 100644 index 0000000..9d06235 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java @@ -0,0 +1,63 @@ +package com.casic.PgInterface.patroler.domain; + +import com.casic.PgInterface.devTable.domain.PgDevice; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + +import javax.persistence.*; +import java.io.Serializable; + +/** + * Created by yxw on 2017/12/14. + */ +@Entity +@Table(name = "PG_ALARM_RULE") +@SequenceGenerator(name = "SEQ_PG_ALARM_RULE_ID", sequenceName = "SEQ_PG_ALARM_RULE_ID",allocationSize=1,initialValue=1) +public class PgAlarmRule implements Serializable { + + private static final long serialVersionUID = 1L; + private long id; + private String highValue;//高限 + private String lowValue;//低限 + private PgDevice pgDeviceId;//设备 + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_ALARM_RULE_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "HIGHVALUE") + public String getHighValue() { + return highValue; + } + + public void setHighValue(String highValue) { + this.highValue = highValue; + } + + @Column(name = "LOWVALUE") + public String getLowValue() { + return lowValue; + } + + public void setLowValue(String lowValue) { + this.lowValue = lowValue; + } + + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "PGDEVICEID") + public PgDevice getPgDeviceId() { + return pgDeviceId; + } + + public void setPgDeviceId(PgDevice pgDeviceId) { + this.pgDeviceId = pgDeviceId; + } + +} diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java new file mode 100644 index 0000000..8367ad4 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java @@ -0,0 +1,57 @@ +package com.casic.PgInterface.patroler.dto; + +import com.casic.PgInterface.patroler.domain.PgAlarmRule; + +import java.io.Serializable; + +/** + * Created by yxw on 2017/12/14. + */ +public class PgAlarmRuleDto implements Serializable { + + private String id; + private String highValue;//高限 + private String lowValue;//低限 + private String devName;//设备 + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getHighValue() { + return highValue; + } + + public void setHighValue(String highValue) { + this.highValue = highValue; + } + + public String getLowValue() { + return lowValue; + } + + public void setLowValue(String lowValue) { + this.lowValue = lowValue; + } + + public String getDevName() { + return devName; + } + + public void setDevName(String devName) { + this.devName = devName; + } + + public PgAlarmRuleDto(PgAlarmRule pgAlarmRule) + { + this.setId(String.valueOf(pgAlarmRule.getId())); + this.setDevName(pgAlarmRule.getPgDeviceId().getAssetName()); + this.setHighValue(pgAlarmRule.getHighValue()); + this.setLowValue(pgAlarmRule.getLowValue()); + } + +} diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java new file mode 100644 index 0000000..d5c00b2 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java @@ -0,0 +1,42 @@ +package com.casic.PgInterface.patroler.manager; + +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.devTable.domain.PgDevice; +import com.casic.PgInterface.patroler.domain.PgAlarmRule; +import com.casic.PgInterface.patroler.dto.PgAlarmRuleDto; +import org.hibernate.Criteria; +import org.hibernate.criterion.Restrictions; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * Created by yxw on 2017/12/14. + */ +@Service +public class PgAlarmRuleManager extends HibernateEntityDao { + + //根据设备获取设备报警阈值 + public PgAlarmRuleDto getAlarmRuleDtoBydev(PgDevice pgDeviceId) { + Criteria criteria=createCriteria(PgAlarmRule.class); + criteria.add(Restrictions.eq("pgDeviceId", pgDeviceId)); + + List pgAlarmRuleList=criteria.list(); + if(pgAlarmRuleList.size()==0) + return null; + else + return new PgAlarmRuleDto(pgAlarmRuleList.get(0)); + } + + public PgAlarmRule getAlarmRuleBydev(PgDevice pgDeviceId) { + Criteria criteria=createCriteria(PgAlarmRule.class); + criteria.add(Restrictions.eq("pgDeviceId", pgDeviceId)); + + List pgAlarmRuleList=criteria.list(); + if(pgAlarmRuleList.size()==0) + return null; + else + return pgAlarmRuleList.get(0); + } + +} diff --git a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java new file mode 100644 index 0000000..88255c6 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java @@ -0,0 +1,162 @@ +package com.casic.PgInterface.rs; + +import com.casic.PgInterface.devTable.domain.PgDevice; +import com.casic.PgInterface.devTable.manager.PgDeviceManager; +import com.casic.PgInterface.patroler.domain.PgAlarmRule; +import com.casic.PgInterface.patroler.dto.PgAlarmRuleDto; +import com.casic.PgInterface.patroler.manager.PgAlarmRuleManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import javax.ws.rs.FormParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import java.util.HashMap; +import java.util.Map; + +/** + * Created by yxw on 2017/12/14. + */ +@Component +@Path("pgAlarmRule") +public class PgAlarmRuleRs { + + private static Logger logger = LoggerFactory.getLogger(PgAlarmRule.class); + + private PgDeviceManager pgDeviceManager; + + private PgAlarmRuleManager pgAlarmRuleManager; + + @Resource + public void setPgAlarmRuleManager(PgAlarmRuleManager pgAlarmRuleManager) { + this.pgAlarmRuleManager = pgAlarmRuleManager; + } + + @Resource + public void setPgDeviceManager(PgDeviceManager pgDeviceManager) { + this.pgDeviceManager = pgDeviceManager; + } + + /** + * 获取报警阈值信息 + */ + @POST + @Path("getAlarmRuleByAssetCode") + @Produces(MediaType.APPLICATION_JSON) + public Map getAlarmRuleByAssetCode(@FormParam("assetCode") String assetCode) throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + + PgAlarmRuleDto pgAlarmRuleDto = null; + PgDevice pgDevice = pgDeviceManager.getDeviceByAssetCode(assetCode); + try { + pgAlarmRuleDto = pgAlarmRuleManager.getAlarmRuleDtoBydev(pgDevice); + if (pgAlarmRuleDto == null) + msg = "不存在报警阈值信息"; + else + msg = "报警阈值获取成功"; + } catch (Exception e) { + e.printStackTrace(); + msg = "报警信息获取失败"; + } + resultMap.put("msg", msg); + resultMap.put("result", pgAlarmRuleDto); + return resultMap; + } + + /** + * 新增报警阈值 + */ + @POST + @Path("addAlarmRule") + @Produces(MediaType.APPLICATION_JSON) + public Map addAlarmRule(@FormParam("assetCode") String assetCode, + @FormParam("highValue") String highValue, + @FormParam("lowValue") String lowValue) throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + String result = ""; + + PgAlarmRule pgAlarmRule = null; + PgDevice pgDevice = pgDeviceManager.getDeviceByAssetCode(assetCode); + if (pgDevice == null) + msg = "不存在设备信息"; + else { + try { + pgAlarmRule = pgAlarmRuleManager.getAlarmRuleBydev(pgDevice); + if (pgAlarmRule != null) { + result = "false"; + msg = "设备阈值已经存在"; + } else { + pgAlarmRule = new PgAlarmRule(); + pgAlarmRule.setHighValue(highValue); + pgAlarmRule.setLowValue(lowValue); + pgAlarmRule.setPgDeviceId(pgDevice); + + pgAlarmRuleManager.save(pgAlarmRule); + result = "true"; + msg = "报警阈值新增成功"; + } + + } catch (Exception e) { + e.printStackTrace(); + result = "false"; + msg = "报警阈值新增失败"; + } + } + resultMap.put("msg", msg); + resultMap.put("result", result); + return resultMap; + } + + /** + * 编辑报警阈值 + */ + @POST + @Path("editAlarmRule") + @Produces(MediaType.APPLICATION_JSON) + public Map editAlarmRule(@FormParam("id") String id, + @FormParam("assetCode") String assetCode, + @FormParam("highValue") String highValue, + @FormParam("lowValue") String lowValue) throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + String result = ""; + + PgAlarmRule pgAlarmRule = null; + PgDevice pgDevice = pgDeviceManager.getDeviceByAssetCode(assetCode); + if (pgDevice == null) { + msg = "不存在设备信息"; + result = "false"; + } else { + try { + pgAlarmRule = pgAlarmRuleManager.get(id); + if (pgAlarmRule == null) { + msg="不存在报警阈值记录"; + result="false"; + } else { + pgAlarmRule.setPgDeviceId(pgDevice); + pgAlarmRule.setHighValue(highValue); + pgAlarmRule.setLowValue(lowValue); + pgAlarmRuleManager.save(pgAlarmRule); + msg="编辑成功"; + result="true"; + } + } catch (Exception ex) { + ex.printStackTrace(); + result = "false"; + msg = "报警阈值编辑失败"; + } + } + resultMap.put("msg", msg); + resultMap.put("result", result); + + return resultMap; + + } + +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java b/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java index 36a4fc5..4f77754 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java @@ -18,7 +18,6 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; -import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -65,14 +64,14 @@ * 获取设备信息 */ @POST - @Path("getPgDeviceByName") + @Path("getPgDeviceByAssetCode") @Produces(MediaType.APPLICATION_JSON) - public Map getPgDeviceByName(@FormParam("devName") String devName) throws Exception { + public Map getPgDeviceByAssetCode(@FormParam("assetCode") String assetCode) throws Exception { Map resultMap = new HashMap(); String msg = ""; PgDeviceDto pgDeviceDto=null; try { - PgDevice pgDevice = pgDeviceManager.getDeviceBydevName(devName); + PgDevice pgDevice = pgDeviceManager.getDeviceByAssetCode(assetCode); pgDeviceDto=new PgDeviceDto(pgDevice); msg = "获取成功"; } catch (Exception e) { @@ -84,7 +83,6 @@ return resultMap; } - /** * 显示设备列表 */ @@ -116,42 +114,49 @@ @POST @Path("addDevice") @Produces(MediaType.APPLICATION_JSON) - public Map addDevice(@FormParam("devType") String devType, - @FormParam("devCode") String devCode, - @FormParam("devName") String devName, - @FormParam("brand") String brand, - @FormParam("ownerUnit") String ownerUnit, - @FormParam("installDate") String installDate, - @FormParam("pgName") String pgName, - @FormParam("parName") String parName) + public Map addDevice(@FormParam("parName") String parName, + @FormParam("pgName") String pgName, + @FormParam("road") String road, + @FormParam("position") String position, + @FormParam("devType") String devType, + @FormParam("devCode") String devCode, + @FormParam("assetName") String assetName, + @FormParam("assetCode") String assetCode, + @FormParam("assetBarCode") String assetBarCode, + @FormParam("ip") String ip, + @FormParam("modBus") String modBus, + @FormParam("mome") String mome) throws Exception { - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - Map resultMap = new HashMap(); String result = ""; String msg = ""; - PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName); - PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName, pipeGallery); + PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName); + PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName,pgPartition); + if (pgPartition == null) { result = "false"; msg = "不存在管廊仓和分区信息"; } else { try { - if (pgDeviceManager.getDeviceBydevName(devName)!=null) { + if (pgDeviceManager.getDeviceByAssetCode(assetCode)!=null) { result = "false"; msg = "已存在同名设备"; } else { PgDevice pgDevice = new PgDevice(); - pgDevice.setDevTypeId(pgDeviceTypeManager.getPgDeviceTypeByDevType(devType)); + pgDevice.setPipeGalleryId(pipeGallery); + pgDevice.setRoad(road); + pgDevice.setPosition(position); + pgDevice.setDevType(devType); pgDevice.setDevCode(devCode); - pgDevice.setDevName(devName); - pgDevice.setBrand(brand); - pgDevice.setOwnerUnit(ownerUnit); - pgDevice.setInstallDate(sdf.parse(installDate)); - pgDevice.setPgPartitionId(pgPartition); + pgDevice.setAssetName(assetName); + pgDevice.setAssetCode(assetCode); + pgDevice.setAssetBarCode(assetBarCode); + pgDevice.setIp(ip); + pgDevice.setModBus(modBus); + pgDevice.setMome(mome); pgDevice.setIsOpen(0); pgDevice.setActive(1); @@ -179,41 +184,49 @@ @Path("editDevice") @Produces(MediaType.APPLICATION_JSON) public Map editPartition(@FormParam("id") String id, + @FormParam("parName") String parName, + @FormParam("pgName") String pgName, + @FormParam("road") String road, + @FormParam("position") String position, @FormParam("devType") String devType, @FormParam("devCode") String devCode, - @FormParam("devName") String devName, - @FormParam("brand") String brand, - @FormParam("ownerUnit") String ownerUnit, - @FormParam("installDate") String installDate, - @FormParam("pgName") String pgName, - @FormParam("parName") String parName, + @FormParam("assetName") String assetName, + @FormParam("assetCode") String assetCode, + @FormParam("assetBarCode") String assetBarCode, + @FormParam("ip") String ip, + @FormParam("modBus") String modBus, + @FormParam("mome") String mome, @FormParam("isOpen") String isOpen) throws Exception { - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - Map resultMap = new HashMap(); String result = ""; String msg = ""; - PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName); - PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName, pipeGallery); + PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName); + PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName,pgPartition); + if (pgPartition == null) { result = "false"; msg = "不存在管廊仓和分区信息"; } else { try { - if (pgDeviceManager.getDeviceBydevName(devName)!=null) { + if (pgDeviceManager.getDeviceByAssetCode(assetCode)!=null) { result = "false"; msg = "已存在同名设备"; } else { PgDevice pgDevice = pgDeviceManager.get(Long.valueOf(id)); - pgDevice.setDevTypeId(pgDeviceTypeManager.getPgDeviceTypeByDevType(devType)); + pgDevice.setPipeGalleryId(pipeGallery); + pgDevice.setRoad(road); + pgDevice.setPosition(position); + pgDevice.setDevType(devType); pgDevice.setDevCode(devCode); - pgDevice.setDevName(devName); - pgDevice.setBrand(brand); - pgDevice.setOwnerUnit(ownerUnit); - pgDevice.setInstallDate(sdf.parse(installDate)); - pgDevice.setPgPartitionId(pgPartition); + pgDevice.setAssetName(assetName); + pgDevice.setAssetCode(assetCode); + pgDevice.setAssetBarCode(assetBarCode); + pgDevice.setIp(ip); + pgDevice.setModBus(modBus); + pgDevice.setMome(mome); + pgDevice.setActive(1); pgDevice.setIsOpen(Integer.valueOf(isOpen)); pgDeviceManager.save(pgDevice); diff --git a/src/main/java/com/casic/PgInterface/rs/PgLocationRs.java b/src/main/java/com/casic/PgInterface/rs/PgLocationRs.java new file mode 100644 index 0000000..e8daabc --- /dev/null +++ b/src/main/java/com/casic/PgInterface/rs/PgLocationRs.java @@ -0,0 +1,39 @@ +package com.casic.PgInterface.rs; + +import com.casic.PgInterface.devData.manager.PgLocationManager; +import com.casic.PgInterface.devTable.manager.PgDeviceManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import javax.ws.rs.Path; + +/** + * Created by yxw on 2017/12/11. + */ +@Component +@Path("location") +public class PgLocationRs { + + private static Logger logger = LoggerFactory.getLogger(PgLocationRs.class); + + private PgDeviceManager pgDeviceManager; + + private PgLocationManager pgLocationManager; + + @Resource + public void setPgDeviceManager(PgDeviceManager pgDeviceManager) { + this.pgDeviceManager = pgDeviceManager; + } + + @Resource + public void setPgLocationManager(PgLocationManager pgLocationManager) { + this.pgLocationManager = pgLocationManager; + } + + + + + +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java index 80625c7..d8f5e6b 100644 --- a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java +++ b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java @@ -43,9 +43,7 @@ this.intoTime = intoTime; } - @Column(name = "OUT_TIME") - public Date getOutTime() { return outTime; } diff --git a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java index a99981e..b1d63a4 100644 --- a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java +++ b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java @@ -1,11 +1,28 @@ package com.casic.PgInterface.devData.manager; +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.core.util.DateUtils; +import com.casic.PgInterface.core.util.StringUtils; +import com.casic.PgInterface.devData.domain.PgCo; +import com.casic.PgInterface.devData.domain.PgLocation; +import com.casic.PgInterface.devData.dto.PgCoDto; +import com.casic.PgInterface.devData.dto.PgLocationDto; +import com.casic.PgInterface.devTable.domain.PgDevice; +import org.hibernate.Criteria; +import org.hibernate.criterion.Order; +import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; + /** * Created by yxw on 2017/11/2. */ @Service -public class PgLocationManager { +public class PgLocationManager extends HibernateEntityDao { + + //获取设备时间段内所有的监测数据 } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java index cfa0281..7fb5953 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -1,12 +1,12 @@ package com.casic.PgInterface.devTable.domain; import com.casic.PgInterface.devData.domain.*; +import com.casic.PgInterface.patroler.domain.PgAlarmRule; import org.hibernate.annotations.NotFound; import org.hibernate.annotations.NotFoundAction; import javax.persistence.*; import java.io.Serializable; -import java.util.Date; import java.util.List; /** @@ -19,21 +19,27 @@ private static final long serialVersionUID = 1L; private long id; + private PipeGallery pipeGalleryId;//所在管廊信息 + private String road;//路名 + private String position;//设备位置 + private String devType;//设备类型 private String devCode;//设备编号 - private String devName;//设备名称 - private String brand;//品牌 - private String ownerUnit;//权属单位 - private Date installDate;//安装时间 + private String assetName;//资产名称 + private String assetCode;//资产编码 + private String assetBarCode;//资产条码 + private String ip;//IP地址 + private String modBus;//modBus地址 + private String mome;//备注 private int isOpen;//设备是否开启 private int active;//状态位 - private PgDeviceType devTypeId;//设备类型 + private List pgAlarms; - private PgPartition pgPartitionId;//所在管廊信息 private List pgTempHums;//温湿度 private List pgCos;//一氧化碳 private List pgO2s;//氧气 private List pgCh4s;//甲烷 private List pgShs;//硫化氢 + private List pgAlarmRules;//报警规则 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") @@ -45,6 +51,33 @@ this.id = id; } + @Column(name = "ROAD") + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + @Column(name = "POSITION") + public String getPosition() { + return position; + } + + public void setPosition(String position) { + this.position = position; + } + + @Column(name = "DEV_TYPE") + public String getDevType() { + return devType; + } + + public void setDevType(String devType) { + this.devType = devType; + } + @Column(name = "DEV_CODE") public String getDevCode() { return devCode; @@ -54,40 +87,58 @@ this.devCode = devCode; } - @Column(name = "DEV_NAME") - public String getDevName() { - return devName; + @Column(name = "ASSET_NAME") + public String getAssetName() { + return assetName; } - public void setDevName(String devName) { - this.devName = devName; + public void setAssetName(String assetName) { + this.assetName = assetName; } - @Column(name = "BRAND") - public String getBrand() { - return brand; + @Column(name = "ASSET_CODE") + public String getAssetCode() { + return assetCode; } - public void setBrand(String brand) { - this.brand = brand; + public void setAssetCode(String assetCode) { + this.assetCode = assetCode; } - @Column(name = "OWNERUNIT") - public String getOwnerUnit() { - return ownerUnit; + @Column(name = "ASSET_BAR_CODE") + public String getAssetBarCode() { + return assetBarCode; } - public void setOwnerUnit(String ownerUnit) { - this.ownerUnit = ownerUnit; + public void setAssetBarCode(String assetBarCode) { + this.assetBarCode = assetBarCode; } - @Column(name = "INSTALDATE") - public Date getInstallDate() { - return installDate; + @Column(name = "IP") + public String getIp() { + return ip; } - public void setInstallDate(Date installDate) { - this.installDate = installDate; + public void setIp(String ip) { + this.ip = ip; + } + + @Column(name = "MODBUS") + public String getModBus() { + return modBus; + } + + public void setModBus(String modBus) { + this.modBus = modBus; + } + + @Column(name = "MOME") + public String getMome() { + return mome; + } + + public void setMome(String mome) { + this.mome = mome; } @Column(name = "ISOPEN") @@ -119,24 +170,13 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; - } - - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "DEVICE_TYPE_ID") - public PgDeviceType getDevTypeId() { - return devTypeId; - } - - public void setDevTypeId(PgDeviceType devTypeId) { - this.devTypeId = devTypeId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgDeviceId") @@ -184,4 +224,13 @@ this.pgShs = pgShs; } + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgDeviceId") + public List getPgAlarmRules() { + return pgAlarmRules; + } + + public void setPgAlarmRules(List pgAlarmRules) { + this.pgAlarmRules = pgAlarmRules; + } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java index b997b29..4fb3d6f 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java @@ -1,8 +1,5 @@ package com.casic.PgInterface.devTable.domain; -import org.hibernate.annotations.NotFound; -import org.hibernate.annotations.NotFoundAction; - import javax.persistence.*; import java.io.Serializable; import java.util.List; @@ -19,11 +16,9 @@ private long id; private String parName;//分区名称 - private PipeGallery pipeGalleryId;//管廊仓 + private String road;//所属道路 private int active;//状态位 - private List pgTextureList; - private List pgPipeLineList; - private List pgDeviceList; + private List pipeGalleryList;//管廊仓 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PARTITION_ID") @@ -44,6 +39,15 @@ this.parName = parName; } + @Column(name = "ROAD") + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + @Column(name = "ACTIVE") public int getActive() { return active; @@ -53,41 +57,14 @@ this.active = active; } - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PIPEGALLERYID") - public PipeGallery getPipeGalleryId() { - return pipeGalleryId; - } - - public void setPipeGalleryId(PipeGallery pipeGalleryId) { - this.pipeGalleryId = pipeGalleryId; - } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgTextureList() { - return pgTextureList; + public List getPipeGalleryList() { + return pipeGalleryList; } - public void setPgTextureList(List pgTextureList) { - this.pgTextureList = pgTextureList; + public void setPipeGalleryList(List pipeGalleryList) { + this.pipeGalleryList = pipeGalleryList; } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgPipeLineList() { - return pgPipeLineList; - } - public void setPgPipeLineList(List pgPipeLineList) { - this.pgPipeLineList = pgPipeLineList; - } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgDeviceList() { - return pgDeviceList; - } - - public void setPgDeviceList(List pgDeviceList) { - this.pgDeviceList = pgDeviceList; - } } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java index d936d18..e5ff9b3 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java @@ -22,7 +22,7 @@ private Date enterDate;//入廊时间 private String layerNum;//所在层数 private String diameter;//管径 - private PgPartition pgPartitionId;//所在管廊信息 + private PipeGallery pipeGalleryId;//所在管廊信息 private int active;//状态位 @Id @@ -100,12 +100,12 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java index 1f22bf9..4ebfbda 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java @@ -21,7 +21,7 @@ private String ownerUnit;//权属单位 private Date buildDate;//建设年代 private int active;//状态位 - private PgPartition pgPartitionId;//所在管廊信息 + private PipeGallery pipeGalleryId;//所在管廊信息 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_TEXTURE_ID") @@ -91,12 +91,13 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java b/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java index 49a246c..650d623 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java @@ -1,5 +1,8 @@ package com.casic.PgInterface.devTable.domain; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + import javax.persistence.*; import java.io.Serializable; import java.util.List; @@ -16,7 +19,10 @@ private long id; private String pgName;//管廊名称 private int active;//状态位 - private List partitionList; + private PgPartition pgPartitionId;// + private List pgTextureList; + private List pgPipeLineList; + private List pgDeviceList; @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PIPE_GALLERY_ID") @@ -46,12 +52,42 @@ this.active = active; } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") - public List getPartitionList() { - return partitionList; + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "PARTITIONID") + public PgPartition getPgPartitionId() { + return pgPartitionId; } - public void setPartitionList(List partitionList) { - this.partitionList = partitionList; + public void setPgPartitionId(PgPartition pgPartitionId) { + this.pgPartitionId = pgPartitionId; } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgTextureList() { + return pgTextureList; + } + + public void setPgTextureList(List pgTextureList) { + this.pgTextureList = pgTextureList; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgPipeLineList() { + return pgPipeLineList; + } + + public void setPgPipeLineList(List pgPipeLineList) { + this.pgPipeLineList = pgPipeLineList; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgDeviceList() { + return pgDeviceList; + } + + public void setPgDeviceList(List pgDeviceList) { + this.pgDeviceList = pgDeviceList; + } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java index b4048d9..c3dfc55 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java @@ -101,18 +101,17 @@ this.active = active; } - public PgAlarmDto(PgAlarm pgAlarm) - { - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + public PgAlarmDto(PgAlarm pgAlarm) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); this.setId(String.valueOf(pgAlarm.getId())); this.setAlarmType(pgAlarm.getAlarmTypeId().getAlarmType()); this.setAlarmValue(pgAlarm.getAlarmValue()); this.setAlarmDate(sdf.format(pgAlarm.getAlarmDate())); this.setDescription(pgAlarm.getDescription()); - this.setAlarmDevName(pgAlarm.getAlarmDevId().getDevName()); - this.setAlarmLocation(pgAlarm.getAlarmDevId().getPgPartitionId().getPipeGalleryId().getPgName() - + pgAlarm.getAlarmDevId().getPgPartitionId().getParName()); + this.setAlarmDevName(pgAlarm.getAlarmDevId().getAssetName()); + this.setAlarmLocation(pgAlarm.getAlarmDevId().getPipeGalleryId().getPgPartitionId().getParName() + + pgAlarm.getAlarmDevId().getPipeGalleryId().getPgName()); this.setUserName(pgAlarm.getPatrolerId().getUserName()); this.setPhoneNumber(pgAlarm.getPatrolerId().getPhoneNumber()); this.setActive(String.valueOf(pgAlarm.getActive())); diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java index ae76e95..49bd436 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java @@ -11,16 +11,20 @@ public class PgDeviceDto implements Serializable { private String id; - private String devType;//设备类型 - private String devCode;//设备编号 - private String devName;//设备名称 - private String brand;//品牌 - private String ownerUnit;//权属单位 - private String installDate;//安装时间 - private String isOpen;//设备开启状态 - private String active;//状态位 private String pipeGallery;//仓位 private String partition;//分区 + private String road;//路名 + private String position;//设备位置 + private String devType;//设备类型 + private String devCode;//设备编号 + private String assetName;//资产名称 + private String assetCode;//资产名称 + private String assetBarCode;//资产条码 + private String ip;//IP地址 + private String modBus;//modBus地址 + private String mome;//备注 + private String isOpen;//设备开启状态 + private String active;//状态位 public String getId() { return id; @@ -30,6 +34,38 @@ this.id = id; } + public String getPartition() { + return partition; + } + + public void setPartition(String partition) { + this.partition = partition; + } + + public String getPipeGallery() { + return pipeGallery; + } + + public void setPipeGallery(String pipeGallery) { + this.pipeGallery = pipeGallery; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getPosition() { + return position; + } + + public void setPosition(String position) { + this.position = position; + } + public String getDevType() { return devType; } @@ -46,36 +82,52 @@ this.devCode = devCode; } - public String getDevName() { - return devName; + public String getAssetName() { + return assetName; } - public void setDevName(String devName) { - this.devName = devName; + public void setAssetName(String assetName) { + this.assetName = assetName; } - public String getBrand() { - return brand; + public String getAssetCode() { + return assetCode; } - public void setBrand(String brand) { - this.brand = brand; + public void setAssetCode(String assetCode) { + this.assetCode = assetCode; } - public String getOwnerUnit() { - return ownerUnit; + public String getAssetBarCode() { + return assetBarCode; } - public void setOwnerUnit(String ownerUnit) { - this.ownerUnit = ownerUnit; + public void setAssetBarCode(String assetBarCode) { + this.assetBarCode = assetBarCode; } - public String getInstallDate() { - return installDate; + public String getIp() { + return ip; } - public void setInstallDate(String installDate) { - this.installDate = installDate; + public void setIp(String ip) { + this.ip = ip; + } + + public String getModBus() { + return modBus; + } + + public void setModBus(String modBus) { + this.modBus = modBus; + } + + public String getMome() { + return mome; + } + + public void setMome(String mome) { + this.mome = mome; } public String getIsOpen() { @@ -94,39 +146,26 @@ this.active = active; } - public String getPipeGallery() { - return pipeGallery; - } - - public void setPipeGallery(String pipeGallery) { - this.pipeGallery = pipeGallery; - } - - public String getPartition() { - return partition; - } - - public void setPartition(String partition) { - this.partition = partition; - } - public PgDeviceDto(PgDevice pgDevice) { SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); this.setId(String.valueOf(pgDevice.getId())); - this.setDevType(pgDevice.getDevTypeId().getDevType()); + this.setPipeGallery(pgDevice.getPipeGalleryId().getPgName()); + this.setPartition(pgDevice.getPipeGalleryId().getPgPartitionId().getParName()); + this.setRoad(pgDevice.getRoad()); + this.setPosition(pgDevice.getPosition()); + this.setDevType(pgDevice.getDevType()); this.setDevCode(pgDevice.getDevCode()); - this.setDevName(pgDevice.getDevName()); - this.setBrand(pgDevice.getBrand()); - this.setOwnerUnit(pgDevice.getOwnerUnit()); - this.setInstallDate(sdf.format(pgDevice.getInstallDate())); + this.setAssetName(pgDevice.getAssetName()); + this.setAssetCode(pgDevice.getAssetCode()); + this.setAssetBarCode(pgDevice.getAssetBarCode()); + this.setId(pgDevice.getIp()); + this.setModBus(pgDevice.getModBus()); + this.setMome(pgDevice.getMome()); this.setIsOpen(String.valueOf(pgDevice.getIsOpen())); this.setActive(String.valueOf(pgDevice.getActive())); - this.setPipeGallery(pgDevice.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgDevice.getPgPartitionId().getParName()); + } - -} - +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java index e8751d3..3acd0fa 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java @@ -11,7 +11,7 @@ private String id; private String parName;//分区名称 - private String pipeGallery;//管廊仓 + private String road;//所属道路 private String active;//状态位 @@ -31,14 +31,6 @@ this.parName = parName; } - public String getPipeGallery() { - return pipeGallery; - } - - public void setPipeGallery(String pipeGallery) { - this.pipeGallery = pipeGallery; - } - public String getActive() { return active; } @@ -47,11 +39,19 @@ this.active = active; } + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + public PgPartitionDto(PgPartition pgPartition) { this.setId(String.valueOf(pgPartition.getId())); this.setParName(pgPartition.getParName()); - this.setPipeGallery(pgPartition.getPipeGalleryId().getPgName()); + this.setRoad(pgPartition.getRoad()); this.setActive(String.valueOf(pgPartition.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java index 9b161bf..8b430dc 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java @@ -112,8 +112,8 @@ this.setEnterDate(sdf.format(pgPipeLine.getEnterDate())); this.setLayerNum(pgPipeLine.getLayerNum()); this.setDiameter(pgPipeLine.getDiameter()); - this.setPipeGallery(pgPipeLine.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgPipeLine.getPgPartitionId().getParName()); + this.setPipeGallery(pgPipeLine.getPipeGalleryId().getPgName()); + this.setPartition(pgPipeLine.getPipeGalleryId().getPgPartitionId().getParName()); this.setActive(String.valueOf(pgPipeLine.getActive())); } } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java index 03c580c..709dcea 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java @@ -103,8 +103,8 @@ this.setOwnerUnit(pgTexture.getOwnerUnit()); this.setBuildDate(sdf.format(pgTexture.getBuildDate())); this.setActive(String.valueOf(pgTexture.getActive())); - this.setPipeGallery(pgTexture.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgTexture.getPgPartitionId().getParName()); + this.setPipeGallery(pgTexture.getPipeGalleryId().getPgName()); + this.setPartition(pgTexture.getPipeGalleryId().getPgPartitionId().getParName()); } } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java index b40ce84..319cf21 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java @@ -11,6 +11,7 @@ private String id; private String pgName;//管廊名称 + private String pgPartition;//分区名称 private String active;//状态位 public String getId() { @@ -37,10 +38,19 @@ this.active = active; } + public String getPgPartition() { + return pgPartition; + } + + public void setPgPartition(String pgPartition) { + this.pgPartition = pgPartition; + } + public PipeGalleryDto(PipeGallery pipeGallery) { this.setId(String.valueOf(pipeGallery.getId())); this.setPgName(pipeGallery.getPgName()); + this.setPgPartition(pipeGallery.getPgPartitionId().getParName()); this.setActive(String.valueOf(pipeGallery.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java b/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java index 8b413e7..0c594e7 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java @@ -5,10 +5,10 @@ import com.casic.PgInterface.devTable.domain.PipeGallery; import com.casic.PgInterface.devTable.dto.PgPartitionDto; import org.hibernate.Criteria; +import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; -import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; @@ -18,44 +18,50 @@ @Service public class PgPartitionManager extends HibernateEntityDao { - private PipeGalleryManager pipeGalleryManager; - - @Resource - public void setPipeGalleryManager(PipeGalleryManager pipeGalleryManager) { - this.pipeGalleryManager = pipeGalleryManager; - } - - public PgPartition getPartitionByParName(String parName,PipeGallery pipeGallery) { - if(pipeGallery==null) - return null; - Criteria criteria = getSession().createCriteria(PgPartition.class); + public PgPartition getPartitionByParName(String parName) { + Criteria criteria = getSession().createCriteria(PipeGallery.class); criteria.add(Restrictions.eq("parName", parName)); - criteria.add(Restrictions.eq("pipeGalleryId",pipeGallery)); + criteria.add(Restrictions.eq("active",1)); List pgPartitionList = criteria.list(); - //TODO LIST:为空判断 pgPartitionList==null? if (pgPartitionList != null && pgPartitionList.size() > 0) return pgPartitionList.get(0); else return null; } - public List getPartitionByPG(String pgName){ - PipeGallery pipeGallery=pipeGalleryManager.getPipeGalleryByPgName(pgName); - - Criteria criteria=getSession().createCriteria(PgPartition.class); - criteria.add(Restrictions.eq("pipeGalleryId",pipeGallery)); + public List getPartitionByRoad(String road) { + Criteria criteria = getSession().createCriteria(PipeGallery.class); + criteria.add(Restrictions.eq("road", road)); + criteria.add(Restrictions.eq("active",1)); List pgPartitionList = criteria.list(); List pgPartitionDtoList=new ArrayList(); - for(PgPartition pgPartition:pgPartitionList) - { - pgPartitionDtoList.add(new PgPartitionDto(pgPartition)); - } + for(PgPartition pgPartition:pgPartitionList) { + pgPartitionDtoList.add(new PgPartitionDto(pgPartition)); + } return pgPartitionDtoList; } + public List getPgPartitionDtoList() + { + Criteria criteria=getSession().createCriteria(PgPartition.class); + criteria.add(Restrictions.eq("active",1)); + criteria.addOrder(Order.desc("id")); + + List pgPartitionList=criteria.list(); + if(pgPartitionList.size()==0||pgPartitionList==null) + return null; + List pgPartitionDtoList=new ArrayList(); + for(PgPartition pgPartition:pgPartitionList) { + pgPartitionDtoList.add(new PgPartitionDto(pgPartition)); + } + return pgPartitionDtoList; + } + + + } diff --git a/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java b/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java index 16370c6..9bce32b 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java @@ -1,14 +1,16 @@ package com.casic.PgInterface.devTable.manager; import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.devTable.domain.PgPartition; import com.casic.PgInterface.devTable.domain.PipeGallery; import com.casic.PgInterface.devTable.dto.PipeGalleryDto; import org.hibernate.Criteria; -import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; -import java.util.*; +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; /** * Created by yxw on 2017/11/4. @@ -16,36 +18,44 @@ @Service public class PipeGalleryManager extends HibernateEntityDao { - public PipeGallery getPipeGalleryByPgName(String pgName) { - Criteria criteria = getSession().createCriteria(PipeGallery.class); + private PgPartitionManager pgPartitionManager; + + @Resource + public void setPgPartitionManager(PgPartitionManager pgPartitionManager) { + this.pgPartitionManager = pgPartitionManager; + } + + public PipeGallery getPipeGalleryByPgName(String pgName,PgPartition pgPartition) { + if(pgPartition==null) + return null; + Criteria criteria = getSession().createCriteria(PgPartition.class); criteria.add(Restrictions.eq("pgName", pgName)); - criteria.add(Restrictions.eq("active",1)); + criteria.add(Restrictions.eq("pgPartitionId",pgPartition)); List pipeGalleryList = criteria.list(); - //TODO LIST:为空判断 pipeGalleryList==null? + //TODO LIST:为空判断 pgPartitionList==null? if (pipeGalleryList != null && pipeGalleryList.size() > 0) return pipeGalleryList.get(0); else return null; } - public List getPIpeGalleryDtoList() - { - Criteria criteria=getSession().createCriteria(PipeGallery.class); - criteria.add(Restrictions.eq("active",1)); - criteria.addOrder(Order.desc("id")); - List pipeGalleryList=criteria.list(); - if(pipeGalleryList.size()==0||pipeGalleryList==null) - return null; - List pipeGalleryDtoList=new ArrayList(); - for(PipeGallery pipeGallery:pipeGalleryList) { + public List getPipeGalleryByParName(String parName) { + + PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName); + Criteria criteria = getSession().createCriteria(PipeGallery.class); + criteria.add(Restrictions.eq("pgPartitionId", pgPartition)); + + List pipeGalleryList = criteria.list(); + + List pipeGalleryDtoList = new ArrayList(); + for (PipeGallery pipeGallery : pipeGalleryList) { pipeGalleryDtoList.add(new PipeGalleryDto(pipeGallery)); } + return pipeGalleryDtoList; } - - } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java new file mode 100644 index 0000000..9d06235 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java @@ -0,0 +1,63 @@ +package com.casic.PgInterface.patroler.domain; + +import com.casic.PgInterface.devTable.domain.PgDevice; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + +import javax.persistence.*; +import java.io.Serializable; + +/** + * Created by yxw on 2017/12/14. + */ +@Entity +@Table(name = "PG_ALARM_RULE") +@SequenceGenerator(name = "SEQ_PG_ALARM_RULE_ID", sequenceName = "SEQ_PG_ALARM_RULE_ID",allocationSize=1,initialValue=1) +public class PgAlarmRule implements Serializable { + + private static final long serialVersionUID = 1L; + private long id; + private String highValue;//高限 + private String lowValue;//低限 + private PgDevice pgDeviceId;//设备 + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_ALARM_RULE_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "HIGHVALUE") + public String getHighValue() { + return highValue; + } + + public void setHighValue(String highValue) { + this.highValue = highValue; + } + + @Column(name = "LOWVALUE") + public String getLowValue() { + return lowValue; + } + + public void setLowValue(String lowValue) { + this.lowValue = lowValue; + } + + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "PGDEVICEID") + public PgDevice getPgDeviceId() { + return pgDeviceId; + } + + public void setPgDeviceId(PgDevice pgDeviceId) { + this.pgDeviceId = pgDeviceId; + } + +} diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java new file mode 100644 index 0000000..8367ad4 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java @@ -0,0 +1,57 @@ +package com.casic.PgInterface.patroler.dto; + +import com.casic.PgInterface.patroler.domain.PgAlarmRule; + +import java.io.Serializable; + +/** + * Created by yxw on 2017/12/14. + */ +public class PgAlarmRuleDto implements Serializable { + + private String id; + private String highValue;//高限 + private String lowValue;//低限 + private String devName;//设备 + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getHighValue() { + return highValue; + } + + public void setHighValue(String highValue) { + this.highValue = highValue; + } + + public String getLowValue() { + return lowValue; + } + + public void setLowValue(String lowValue) { + this.lowValue = lowValue; + } + + public String getDevName() { + return devName; + } + + public void setDevName(String devName) { + this.devName = devName; + } + + public PgAlarmRuleDto(PgAlarmRule pgAlarmRule) + { + this.setId(String.valueOf(pgAlarmRule.getId())); + this.setDevName(pgAlarmRule.getPgDeviceId().getAssetName()); + this.setHighValue(pgAlarmRule.getHighValue()); + this.setLowValue(pgAlarmRule.getLowValue()); + } + +} diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java new file mode 100644 index 0000000..d5c00b2 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java @@ -0,0 +1,42 @@ +package com.casic.PgInterface.patroler.manager; + +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.devTable.domain.PgDevice; +import com.casic.PgInterface.patroler.domain.PgAlarmRule; +import com.casic.PgInterface.patroler.dto.PgAlarmRuleDto; +import org.hibernate.Criteria; +import org.hibernate.criterion.Restrictions; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * Created by yxw on 2017/12/14. + */ +@Service +public class PgAlarmRuleManager extends HibernateEntityDao { + + //根据设备获取设备报警阈值 + public PgAlarmRuleDto getAlarmRuleDtoBydev(PgDevice pgDeviceId) { + Criteria criteria=createCriteria(PgAlarmRule.class); + criteria.add(Restrictions.eq("pgDeviceId", pgDeviceId)); + + List pgAlarmRuleList=criteria.list(); + if(pgAlarmRuleList.size()==0) + return null; + else + return new PgAlarmRuleDto(pgAlarmRuleList.get(0)); + } + + public PgAlarmRule getAlarmRuleBydev(PgDevice pgDeviceId) { + Criteria criteria=createCriteria(PgAlarmRule.class); + criteria.add(Restrictions.eq("pgDeviceId", pgDeviceId)); + + List pgAlarmRuleList=criteria.list(); + if(pgAlarmRuleList.size()==0) + return null; + else + return pgAlarmRuleList.get(0); + } + +} diff --git a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java new file mode 100644 index 0000000..88255c6 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java @@ -0,0 +1,162 @@ +package com.casic.PgInterface.rs; + +import com.casic.PgInterface.devTable.domain.PgDevice; +import com.casic.PgInterface.devTable.manager.PgDeviceManager; +import com.casic.PgInterface.patroler.domain.PgAlarmRule; +import com.casic.PgInterface.patroler.dto.PgAlarmRuleDto; +import com.casic.PgInterface.patroler.manager.PgAlarmRuleManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import javax.ws.rs.FormParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import java.util.HashMap; +import java.util.Map; + +/** + * Created by yxw on 2017/12/14. + */ +@Component +@Path("pgAlarmRule") +public class PgAlarmRuleRs { + + private static Logger logger = LoggerFactory.getLogger(PgAlarmRule.class); + + private PgDeviceManager pgDeviceManager; + + private PgAlarmRuleManager pgAlarmRuleManager; + + @Resource + public void setPgAlarmRuleManager(PgAlarmRuleManager pgAlarmRuleManager) { + this.pgAlarmRuleManager = pgAlarmRuleManager; + } + + @Resource + public void setPgDeviceManager(PgDeviceManager pgDeviceManager) { + this.pgDeviceManager = pgDeviceManager; + } + + /** + * 获取报警阈值信息 + */ + @POST + @Path("getAlarmRuleByAssetCode") + @Produces(MediaType.APPLICATION_JSON) + public Map getAlarmRuleByAssetCode(@FormParam("assetCode") String assetCode) throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + + PgAlarmRuleDto pgAlarmRuleDto = null; + PgDevice pgDevice = pgDeviceManager.getDeviceByAssetCode(assetCode); + try { + pgAlarmRuleDto = pgAlarmRuleManager.getAlarmRuleDtoBydev(pgDevice); + if (pgAlarmRuleDto == null) + msg = "不存在报警阈值信息"; + else + msg = "报警阈值获取成功"; + } catch (Exception e) { + e.printStackTrace(); + msg = "报警信息获取失败"; + } + resultMap.put("msg", msg); + resultMap.put("result", pgAlarmRuleDto); + return resultMap; + } + + /** + * 新增报警阈值 + */ + @POST + @Path("addAlarmRule") + @Produces(MediaType.APPLICATION_JSON) + public Map addAlarmRule(@FormParam("assetCode") String assetCode, + @FormParam("highValue") String highValue, + @FormParam("lowValue") String lowValue) throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + String result = ""; + + PgAlarmRule pgAlarmRule = null; + PgDevice pgDevice = pgDeviceManager.getDeviceByAssetCode(assetCode); + if (pgDevice == null) + msg = "不存在设备信息"; + else { + try { + pgAlarmRule = pgAlarmRuleManager.getAlarmRuleBydev(pgDevice); + if (pgAlarmRule != null) { + result = "false"; + msg = "设备阈值已经存在"; + } else { + pgAlarmRule = new PgAlarmRule(); + pgAlarmRule.setHighValue(highValue); + pgAlarmRule.setLowValue(lowValue); + pgAlarmRule.setPgDeviceId(pgDevice); + + pgAlarmRuleManager.save(pgAlarmRule); + result = "true"; + msg = "报警阈值新增成功"; + } + + } catch (Exception e) { + e.printStackTrace(); + result = "false"; + msg = "报警阈值新增失败"; + } + } + resultMap.put("msg", msg); + resultMap.put("result", result); + return resultMap; + } + + /** + * 编辑报警阈值 + */ + @POST + @Path("editAlarmRule") + @Produces(MediaType.APPLICATION_JSON) + public Map editAlarmRule(@FormParam("id") String id, + @FormParam("assetCode") String assetCode, + @FormParam("highValue") String highValue, + @FormParam("lowValue") String lowValue) throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + String result = ""; + + PgAlarmRule pgAlarmRule = null; + PgDevice pgDevice = pgDeviceManager.getDeviceByAssetCode(assetCode); + if (pgDevice == null) { + msg = "不存在设备信息"; + result = "false"; + } else { + try { + pgAlarmRule = pgAlarmRuleManager.get(id); + if (pgAlarmRule == null) { + msg="不存在报警阈值记录"; + result="false"; + } else { + pgAlarmRule.setPgDeviceId(pgDevice); + pgAlarmRule.setHighValue(highValue); + pgAlarmRule.setLowValue(lowValue); + pgAlarmRuleManager.save(pgAlarmRule); + msg="编辑成功"; + result="true"; + } + } catch (Exception ex) { + ex.printStackTrace(); + result = "false"; + msg = "报警阈值编辑失败"; + } + } + resultMap.put("msg", msg); + resultMap.put("result", result); + + return resultMap; + + } + +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java b/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java index 36a4fc5..4f77754 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java @@ -18,7 +18,6 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; -import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -65,14 +64,14 @@ * 获取设备信息 */ @POST - @Path("getPgDeviceByName") + @Path("getPgDeviceByAssetCode") @Produces(MediaType.APPLICATION_JSON) - public Map getPgDeviceByName(@FormParam("devName") String devName) throws Exception { + public Map getPgDeviceByAssetCode(@FormParam("assetCode") String assetCode) throws Exception { Map resultMap = new HashMap(); String msg = ""; PgDeviceDto pgDeviceDto=null; try { - PgDevice pgDevice = pgDeviceManager.getDeviceBydevName(devName); + PgDevice pgDevice = pgDeviceManager.getDeviceByAssetCode(assetCode); pgDeviceDto=new PgDeviceDto(pgDevice); msg = "获取成功"; } catch (Exception e) { @@ -84,7 +83,6 @@ return resultMap; } - /** * 显示设备列表 */ @@ -116,42 +114,49 @@ @POST @Path("addDevice") @Produces(MediaType.APPLICATION_JSON) - public Map addDevice(@FormParam("devType") String devType, - @FormParam("devCode") String devCode, - @FormParam("devName") String devName, - @FormParam("brand") String brand, - @FormParam("ownerUnit") String ownerUnit, - @FormParam("installDate") String installDate, - @FormParam("pgName") String pgName, - @FormParam("parName") String parName) + public Map addDevice(@FormParam("parName") String parName, + @FormParam("pgName") String pgName, + @FormParam("road") String road, + @FormParam("position") String position, + @FormParam("devType") String devType, + @FormParam("devCode") String devCode, + @FormParam("assetName") String assetName, + @FormParam("assetCode") String assetCode, + @FormParam("assetBarCode") String assetBarCode, + @FormParam("ip") String ip, + @FormParam("modBus") String modBus, + @FormParam("mome") String mome) throws Exception { - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - Map resultMap = new HashMap(); String result = ""; String msg = ""; - PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName); - PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName, pipeGallery); + PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName); + PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName,pgPartition); + if (pgPartition == null) { result = "false"; msg = "不存在管廊仓和分区信息"; } else { try { - if (pgDeviceManager.getDeviceBydevName(devName)!=null) { + if (pgDeviceManager.getDeviceByAssetCode(assetCode)!=null) { result = "false"; msg = "已存在同名设备"; } else { PgDevice pgDevice = new PgDevice(); - pgDevice.setDevTypeId(pgDeviceTypeManager.getPgDeviceTypeByDevType(devType)); + pgDevice.setPipeGalleryId(pipeGallery); + pgDevice.setRoad(road); + pgDevice.setPosition(position); + pgDevice.setDevType(devType); pgDevice.setDevCode(devCode); - pgDevice.setDevName(devName); - pgDevice.setBrand(brand); - pgDevice.setOwnerUnit(ownerUnit); - pgDevice.setInstallDate(sdf.parse(installDate)); - pgDevice.setPgPartitionId(pgPartition); + pgDevice.setAssetName(assetName); + pgDevice.setAssetCode(assetCode); + pgDevice.setAssetBarCode(assetBarCode); + pgDevice.setIp(ip); + pgDevice.setModBus(modBus); + pgDevice.setMome(mome); pgDevice.setIsOpen(0); pgDevice.setActive(1); @@ -179,41 +184,49 @@ @Path("editDevice") @Produces(MediaType.APPLICATION_JSON) public Map editPartition(@FormParam("id") String id, + @FormParam("parName") String parName, + @FormParam("pgName") String pgName, + @FormParam("road") String road, + @FormParam("position") String position, @FormParam("devType") String devType, @FormParam("devCode") String devCode, - @FormParam("devName") String devName, - @FormParam("brand") String brand, - @FormParam("ownerUnit") String ownerUnit, - @FormParam("installDate") String installDate, - @FormParam("pgName") String pgName, - @FormParam("parName") String parName, + @FormParam("assetName") String assetName, + @FormParam("assetCode") String assetCode, + @FormParam("assetBarCode") String assetBarCode, + @FormParam("ip") String ip, + @FormParam("modBus") String modBus, + @FormParam("mome") String mome, @FormParam("isOpen") String isOpen) throws Exception { - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - Map resultMap = new HashMap(); String result = ""; String msg = ""; - PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName); - PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName, pipeGallery); + PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName); + PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName,pgPartition); + if (pgPartition == null) { result = "false"; msg = "不存在管廊仓和分区信息"; } else { try { - if (pgDeviceManager.getDeviceBydevName(devName)!=null) { + if (pgDeviceManager.getDeviceByAssetCode(assetCode)!=null) { result = "false"; msg = "已存在同名设备"; } else { PgDevice pgDevice = pgDeviceManager.get(Long.valueOf(id)); - pgDevice.setDevTypeId(pgDeviceTypeManager.getPgDeviceTypeByDevType(devType)); + pgDevice.setPipeGalleryId(pipeGallery); + pgDevice.setRoad(road); + pgDevice.setPosition(position); + pgDevice.setDevType(devType); pgDevice.setDevCode(devCode); - pgDevice.setDevName(devName); - pgDevice.setBrand(brand); - pgDevice.setOwnerUnit(ownerUnit); - pgDevice.setInstallDate(sdf.parse(installDate)); - pgDevice.setPgPartitionId(pgPartition); + pgDevice.setAssetName(assetName); + pgDevice.setAssetCode(assetCode); + pgDevice.setAssetBarCode(assetBarCode); + pgDevice.setIp(ip); + pgDevice.setModBus(modBus); + pgDevice.setMome(mome); + pgDevice.setActive(1); pgDevice.setIsOpen(Integer.valueOf(isOpen)); pgDeviceManager.save(pgDevice); diff --git a/src/main/java/com/casic/PgInterface/rs/PgLocationRs.java b/src/main/java/com/casic/PgInterface/rs/PgLocationRs.java new file mode 100644 index 0000000..e8daabc --- /dev/null +++ b/src/main/java/com/casic/PgInterface/rs/PgLocationRs.java @@ -0,0 +1,39 @@ +package com.casic.PgInterface.rs; + +import com.casic.PgInterface.devData.manager.PgLocationManager; +import com.casic.PgInterface.devTable.manager.PgDeviceManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import javax.ws.rs.Path; + +/** + * Created by yxw on 2017/12/11. + */ +@Component +@Path("location") +public class PgLocationRs { + + private static Logger logger = LoggerFactory.getLogger(PgLocationRs.class); + + private PgDeviceManager pgDeviceManager; + + private PgLocationManager pgLocationManager; + + @Resource + public void setPgDeviceManager(PgDeviceManager pgDeviceManager) { + this.pgDeviceManager = pgDeviceManager; + } + + @Resource + public void setPgLocationManager(PgLocationManager pgLocationManager) { + this.pgLocationManager = pgLocationManager; + } + + + + + +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java b/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java index 45fc210..8a42e7e 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java @@ -1,10 +1,8 @@ package com.casic.PgInterface.rs; import com.casic.PgInterface.devTable.domain.PgPartition; -import com.casic.PgInterface.devTable.domain.PipeGallery; import com.casic.PgInterface.devTable.dto.PgPartitionDto; import com.casic.PgInterface.devTable.manager.PgPartitionManager; -import com.casic.PgInterface.devTable.manager.PipeGalleryManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; @@ -29,8 +27,6 @@ private static Logger logger = LoggerFactory.getLogger(PgPartitionRs.class); - private PipeGalleryManager pipeGalleryManager; - private PgPartitionManager pgPartitionManager; @Resource @@ -38,38 +34,24 @@ this.pgPartitionManager = pgPartitionManager; } - @Resource - public void setPipeGalleryManager(PipeGalleryManager pipeGalleryManager) { - - this.pipeGalleryManager = pipeGalleryManager; - } - /** * 新增分区 */ @POST @Path("addPartition") @Produces(MediaType.APPLICATION_JSON) - public Map addAlarm(@FormParam("parName") String parName, - @FormParam("pgName") String pgName)throws Exception { + public Map addAlarm(@FormParam("parName") String parName)throws Exception { Map resultMap = new HashMap(); String result = ""; String msg = ""; try { - PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName); - - if (pipeGallery == null) { - result = "false"; - msg = "不存在" + pgName + "管廊仓"; - } else { - if (pgPartitionManager.getPartitionByParName(parName, pipeGallery) != null) { + if (pgPartitionManager.getPartitionByParName(parName) != null) { result = "false"; msg = "已存在相同分区"; } else { PgPartition pgPartition = new PgPartition(); pgPartition.setParName(parName); - pgPartition.setPipeGalleryId(pipeGallery); pgPartition.setActive(1); logger.info("成功保存"); @@ -77,7 +59,7 @@ result = "true"; msg = "保存成功"; } - } + } catch (Exception e) { result = "false"; msg = "保存失败"; @@ -89,37 +71,13 @@ return resultMap; } - /** - *获取管廊仓下的分区列表 - */ - @POST - @Path("getPartition") - @Produces(MediaType.APPLICATION_JSON) - public Map getPartitionList(@FormParam("pgName") String pgName)throws Exception { - Map resultMap = new HashMap(); - String msg=""; - List pgPartitionDtoList=new ArrayList(); - try { - pgPartitionDtoList=pgPartitionManager.getPartitionByPG(pgName); - if(pgPartitionDtoList.size()==0) - msg="没有分区信息"; - else - msg="分区信息获取成功"; - }catch(Exception e){ - e.printStackTrace(); - msg="分区信息获取失败"; - } - resultMap.put("msg",msg); - resultMap.put("result",pgPartitionDtoList); - return resultMap; - } + @POST @Path("editPartition") @Produces(MediaType.APPLICATION_JSON) public Map editPartition(@FormParam("id") String id, - @FormParam("parName") String parName, - @FormParam("pgName") String pgName) throws Exception { + @FormParam("parName") String parName) throws Exception { Map resultMap = new HashMap(); String result = ""; @@ -128,25 +86,20 @@ PgPartition partition = new PgPartition(); try { - PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName); - if (pipeGallery == null) { - result = "false"; - msg = "不存在该管廊信息"; - } else { - if (pgPartitionManager.getPartitionByParName(parName, pipeGallery) != null) { + + if (pgPartitionManager.getPartitionByParName(parName) != null) { result = "false"; msg = "已存在相同分区"; } else { PgPartition pgPartition = pgPartitionManager.get(Long.valueOf(id)); pgPartition.setParName(parName); - pgPartition.setPipeGalleryId(pipeGallery); pgPartition.setActive(1); pgPartitionManager.save(pgPartition); result = "true"; msg = "编辑成功"; } - } + } catch (Exception e) { result = "false"; msg = "编辑失败"; @@ -194,5 +147,49 @@ return resultMap; } + /** + * 获取分区信息 + */ + @POST + @Path("getPartitionList") + @Produces(MediaType.APPLICATION_JSON) + public Map getPartition() throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + List pgPartitionDtoList = new ArrayList(); + try { + pgPartitionDtoList = pgPartitionManager.getPgPartitionDtoList(); + msg = "获取成功"; + } catch (Exception e) { + msg = "获取失败"; + e.printStackTrace(); + } + resultMap.put("msg", msg); + resultMap.put("result", pgPartitionDtoList); + return resultMap; + } + + /** + * 获取分区信息 + */ + @POST + @Path("getPartitionListByRoad") + @Produces(MediaType.APPLICATION_JSON) + public Map getPartitionListByRoad(@FormParam("road") String road) throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + List pgPartitionDtoList = new ArrayList(); + try { + pgPartitionDtoList = pgPartitionManager.getPartitionByRoad(road); + msg = "获取成功"; + } catch (Exception e) { + msg = "获取失败"; + e.printStackTrace(); + } + resultMap.put("msg", msg); + resultMap.put("result", pgPartitionDtoList); + return resultMap; + } + } diff --git a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java index 80625c7..d8f5e6b 100644 --- a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java +++ b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java @@ -43,9 +43,7 @@ this.intoTime = intoTime; } - @Column(name = "OUT_TIME") - public Date getOutTime() { return outTime; } diff --git a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java index a99981e..b1d63a4 100644 --- a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java +++ b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java @@ -1,11 +1,28 @@ package com.casic.PgInterface.devData.manager; +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.core.util.DateUtils; +import com.casic.PgInterface.core.util.StringUtils; +import com.casic.PgInterface.devData.domain.PgCo; +import com.casic.PgInterface.devData.domain.PgLocation; +import com.casic.PgInterface.devData.dto.PgCoDto; +import com.casic.PgInterface.devData.dto.PgLocationDto; +import com.casic.PgInterface.devTable.domain.PgDevice; +import org.hibernate.Criteria; +import org.hibernate.criterion.Order; +import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; + /** * Created by yxw on 2017/11/2. */ @Service -public class PgLocationManager { +public class PgLocationManager extends HibernateEntityDao { + + //获取设备时间段内所有的监测数据 } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java index cfa0281..7fb5953 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -1,12 +1,12 @@ package com.casic.PgInterface.devTable.domain; import com.casic.PgInterface.devData.domain.*; +import com.casic.PgInterface.patroler.domain.PgAlarmRule; import org.hibernate.annotations.NotFound; import org.hibernate.annotations.NotFoundAction; import javax.persistence.*; import java.io.Serializable; -import java.util.Date; import java.util.List; /** @@ -19,21 +19,27 @@ private static final long serialVersionUID = 1L; private long id; + private PipeGallery pipeGalleryId;//所在管廊信息 + private String road;//路名 + private String position;//设备位置 + private String devType;//设备类型 private String devCode;//设备编号 - private String devName;//设备名称 - private String brand;//品牌 - private String ownerUnit;//权属单位 - private Date installDate;//安装时间 + private String assetName;//资产名称 + private String assetCode;//资产编码 + private String assetBarCode;//资产条码 + private String ip;//IP地址 + private String modBus;//modBus地址 + private String mome;//备注 private int isOpen;//设备是否开启 private int active;//状态位 - private PgDeviceType devTypeId;//设备类型 + private List pgAlarms; - private PgPartition pgPartitionId;//所在管廊信息 private List pgTempHums;//温湿度 private List pgCos;//一氧化碳 private List pgO2s;//氧气 private List pgCh4s;//甲烷 private List pgShs;//硫化氢 + private List pgAlarmRules;//报警规则 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") @@ -45,6 +51,33 @@ this.id = id; } + @Column(name = "ROAD") + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + @Column(name = "POSITION") + public String getPosition() { + return position; + } + + public void setPosition(String position) { + this.position = position; + } + + @Column(name = "DEV_TYPE") + public String getDevType() { + return devType; + } + + public void setDevType(String devType) { + this.devType = devType; + } + @Column(name = "DEV_CODE") public String getDevCode() { return devCode; @@ -54,40 +87,58 @@ this.devCode = devCode; } - @Column(name = "DEV_NAME") - public String getDevName() { - return devName; + @Column(name = "ASSET_NAME") + public String getAssetName() { + return assetName; } - public void setDevName(String devName) { - this.devName = devName; + public void setAssetName(String assetName) { + this.assetName = assetName; } - @Column(name = "BRAND") - public String getBrand() { - return brand; + @Column(name = "ASSET_CODE") + public String getAssetCode() { + return assetCode; } - public void setBrand(String brand) { - this.brand = brand; + public void setAssetCode(String assetCode) { + this.assetCode = assetCode; } - @Column(name = "OWNERUNIT") - public String getOwnerUnit() { - return ownerUnit; + @Column(name = "ASSET_BAR_CODE") + public String getAssetBarCode() { + return assetBarCode; } - public void setOwnerUnit(String ownerUnit) { - this.ownerUnit = ownerUnit; + public void setAssetBarCode(String assetBarCode) { + this.assetBarCode = assetBarCode; } - @Column(name = "INSTALDATE") - public Date getInstallDate() { - return installDate; + @Column(name = "IP") + public String getIp() { + return ip; } - public void setInstallDate(Date installDate) { - this.installDate = installDate; + public void setIp(String ip) { + this.ip = ip; + } + + @Column(name = "MODBUS") + public String getModBus() { + return modBus; + } + + public void setModBus(String modBus) { + this.modBus = modBus; + } + + @Column(name = "MOME") + public String getMome() { + return mome; + } + + public void setMome(String mome) { + this.mome = mome; } @Column(name = "ISOPEN") @@ -119,24 +170,13 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; - } - - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "DEVICE_TYPE_ID") - public PgDeviceType getDevTypeId() { - return devTypeId; - } - - public void setDevTypeId(PgDeviceType devTypeId) { - this.devTypeId = devTypeId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgDeviceId") @@ -184,4 +224,13 @@ this.pgShs = pgShs; } + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgDeviceId") + public List getPgAlarmRules() { + return pgAlarmRules; + } + + public void setPgAlarmRules(List pgAlarmRules) { + this.pgAlarmRules = pgAlarmRules; + } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java index b997b29..4fb3d6f 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java @@ -1,8 +1,5 @@ package com.casic.PgInterface.devTable.domain; -import org.hibernate.annotations.NotFound; -import org.hibernate.annotations.NotFoundAction; - import javax.persistence.*; import java.io.Serializable; import java.util.List; @@ -19,11 +16,9 @@ private long id; private String parName;//分区名称 - private PipeGallery pipeGalleryId;//管廊仓 + private String road;//所属道路 private int active;//状态位 - private List pgTextureList; - private List pgPipeLineList; - private List pgDeviceList; + private List pipeGalleryList;//管廊仓 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PARTITION_ID") @@ -44,6 +39,15 @@ this.parName = parName; } + @Column(name = "ROAD") + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + @Column(name = "ACTIVE") public int getActive() { return active; @@ -53,41 +57,14 @@ this.active = active; } - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PIPEGALLERYID") - public PipeGallery getPipeGalleryId() { - return pipeGalleryId; - } - - public void setPipeGalleryId(PipeGallery pipeGalleryId) { - this.pipeGalleryId = pipeGalleryId; - } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgTextureList() { - return pgTextureList; + public List getPipeGalleryList() { + return pipeGalleryList; } - public void setPgTextureList(List pgTextureList) { - this.pgTextureList = pgTextureList; + public void setPipeGalleryList(List pipeGalleryList) { + this.pipeGalleryList = pipeGalleryList; } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgPipeLineList() { - return pgPipeLineList; - } - public void setPgPipeLineList(List pgPipeLineList) { - this.pgPipeLineList = pgPipeLineList; - } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgDeviceList() { - return pgDeviceList; - } - - public void setPgDeviceList(List pgDeviceList) { - this.pgDeviceList = pgDeviceList; - } } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java index d936d18..e5ff9b3 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java @@ -22,7 +22,7 @@ private Date enterDate;//入廊时间 private String layerNum;//所在层数 private String diameter;//管径 - private PgPartition pgPartitionId;//所在管廊信息 + private PipeGallery pipeGalleryId;//所在管廊信息 private int active;//状态位 @Id @@ -100,12 +100,12 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java index 1f22bf9..4ebfbda 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java @@ -21,7 +21,7 @@ private String ownerUnit;//权属单位 private Date buildDate;//建设年代 private int active;//状态位 - private PgPartition pgPartitionId;//所在管廊信息 + private PipeGallery pipeGalleryId;//所在管廊信息 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_TEXTURE_ID") @@ -91,12 +91,13 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java b/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java index 49a246c..650d623 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java @@ -1,5 +1,8 @@ package com.casic.PgInterface.devTable.domain; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + import javax.persistence.*; import java.io.Serializable; import java.util.List; @@ -16,7 +19,10 @@ private long id; private String pgName;//管廊名称 private int active;//状态位 - private List partitionList; + private PgPartition pgPartitionId;// + private List pgTextureList; + private List pgPipeLineList; + private List pgDeviceList; @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PIPE_GALLERY_ID") @@ -46,12 +52,42 @@ this.active = active; } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") - public List getPartitionList() { - return partitionList; + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "PARTITIONID") + public PgPartition getPgPartitionId() { + return pgPartitionId; } - public void setPartitionList(List partitionList) { - this.partitionList = partitionList; + public void setPgPartitionId(PgPartition pgPartitionId) { + this.pgPartitionId = pgPartitionId; } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgTextureList() { + return pgTextureList; + } + + public void setPgTextureList(List pgTextureList) { + this.pgTextureList = pgTextureList; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgPipeLineList() { + return pgPipeLineList; + } + + public void setPgPipeLineList(List pgPipeLineList) { + this.pgPipeLineList = pgPipeLineList; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgDeviceList() { + return pgDeviceList; + } + + public void setPgDeviceList(List pgDeviceList) { + this.pgDeviceList = pgDeviceList; + } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java index b4048d9..c3dfc55 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java @@ -101,18 +101,17 @@ this.active = active; } - public PgAlarmDto(PgAlarm pgAlarm) - { - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + public PgAlarmDto(PgAlarm pgAlarm) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); this.setId(String.valueOf(pgAlarm.getId())); this.setAlarmType(pgAlarm.getAlarmTypeId().getAlarmType()); this.setAlarmValue(pgAlarm.getAlarmValue()); this.setAlarmDate(sdf.format(pgAlarm.getAlarmDate())); this.setDescription(pgAlarm.getDescription()); - this.setAlarmDevName(pgAlarm.getAlarmDevId().getDevName()); - this.setAlarmLocation(pgAlarm.getAlarmDevId().getPgPartitionId().getPipeGalleryId().getPgName() - + pgAlarm.getAlarmDevId().getPgPartitionId().getParName()); + this.setAlarmDevName(pgAlarm.getAlarmDevId().getAssetName()); + this.setAlarmLocation(pgAlarm.getAlarmDevId().getPipeGalleryId().getPgPartitionId().getParName() + + pgAlarm.getAlarmDevId().getPipeGalleryId().getPgName()); this.setUserName(pgAlarm.getPatrolerId().getUserName()); this.setPhoneNumber(pgAlarm.getPatrolerId().getPhoneNumber()); this.setActive(String.valueOf(pgAlarm.getActive())); diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java index ae76e95..49bd436 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java @@ -11,16 +11,20 @@ public class PgDeviceDto implements Serializable { private String id; - private String devType;//设备类型 - private String devCode;//设备编号 - private String devName;//设备名称 - private String brand;//品牌 - private String ownerUnit;//权属单位 - private String installDate;//安装时间 - private String isOpen;//设备开启状态 - private String active;//状态位 private String pipeGallery;//仓位 private String partition;//分区 + private String road;//路名 + private String position;//设备位置 + private String devType;//设备类型 + private String devCode;//设备编号 + private String assetName;//资产名称 + private String assetCode;//资产名称 + private String assetBarCode;//资产条码 + private String ip;//IP地址 + private String modBus;//modBus地址 + private String mome;//备注 + private String isOpen;//设备开启状态 + private String active;//状态位 public String getId() { return id; @@ -30,6 +34,38 @@ this.id = id; } + public String getPartition() { + return partition; + } + + public void setPartition(String partition) { + this.partition = partition; + } + + public String getPipeGallery() { + return pipeGallery; + } + + public void setPipeGallery(String pipeGallery) { + this.pipeGallery = pipeGallery; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getPosition() { + return position; + } + + public void setPosition(String position) { + this.position = position; + } + public String getDevType() { return devType; } @@ -46,36 +82,52 @@ this.devCode = devCode; } - public String getDevName() { - return devName; + public String getAssetName() { + return assetName; } - public void setDevName(String devName) { - this.devName = devName; + public void setAssetName(String assetName) { + this.assetName = assetName; } - public String getBrand() { - return brand; + public String getAssetCode() { + return assetCode; } - public void setBrand(String brand) { - this.brand = brand; + public void setAssetCode(String assetCode) { + this.assetCode = assetCode; } - public String getOwnerUnit() { - return ownerUnit; + public String getAssetBarCode() { + return assetBarCode; } - public void setOwnerUnit(String ownerUnit) { - this.ownerUnit = ownerUnit; + public void setAssetBarCode(String assetBarCode) { + this.assetBarCode = assetBarCode; } - public String getInstallDate() { - return installDate; + public String getIp() { + return ip; } - public void setInstallDate(String installDate) { - this.installDate = installDate; + public void setIp(String ip) { + this.ip = ip; + } + + public String getModBus() { + return modBus; + } + + public void setModBus(String modBus) { + this.modBus = modBus; + } + + public String getMome() { + return mome; + } + + public void setMome(String mome) { + this.mome = mome; } public String getIsOpen() { @@ -94,39 +146,26 @@ this.active = active; } - public String getPipeGallery() { - return pipeGallery; - } - - public void setPipeGallery(String pipeGallery) { - this.pipeGallery = pipeGallery; - } - - public String getPartition() { - return partition; - } - - public void setPartition(String partition) { - this.partition = partition; - } - public PgDeviceDto(PgDevice pgDevice) { SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); this.setId(String.valueOf(pgDevice.getId())); - this.setDevType(pgDevice.getDevTypeId().getDevType()); + this.setPipeGallery(pgDevice.getPipeGalleryId().getPgName()); + this.setPartition(pgDevice.getPipeGalleryId().getPgPartitionId().getParName()); + this.setRoad(pgDevice.getRoad()); + this.setPosition(pgDevice.getPosition()); + this.setDevType(pgDevice.getDevType()); this.setDevCode(pgDevice.getDevCode()); - this.setDevName(pgDevice.getDevName()); - this.setBrand(pgDevice.getBrand()); - this.setOwnerUnit(pgDevice.getOwnerUnit()); - this.setInstallDate(sdf.format(pgDevice.getInstallDate())); + this.setAssetName(pgDevice.getAssetName()); + this.setAssetCode(pgDevice.getAssetCode()); + this.setAssetBarCode(pgDevice.getAssetBarCode()); + this.setId(pgDevice.getIp()); + this.setModBus(pgDevice.getModBus()); + this.setMome(pgDevice.getMome()); this.setIsOpen(String.valueOf(pgDevice.getIsOpen())); this.setActive(String.valueOf(pgDevice.getActive())); - this.setPipeGallery(pgDevice.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgDevice.getPgPartitionId().getParName()); + } - -} - +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java index e8751d3..3acd0fa 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java @@ -11,7 +11,7 @@ private String id; private String parName;//分区名称 - private String pipeGallery;//管廊仓 + private String road;//所属道路 private String active;//状态位 @@ -31,14 +31,6 @@ this.parName = parName; } - public String getPipeGallery() { - return pipeGallery; - } - - public void setPipeGallery(String pipeGallery) { - this.pipeGallery = pipeGallery; - } - public String getActive() { return active; } @@ -47,11 +39,19 @@ this.active = active; } + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + public PgPartitionDto(PgPartition pgPartition) { this.setId(String.valueOf(pgPartition.getId())); this.setParName(pgPartition.getParName()); - this.setPipeGallery(pgPartition.getPipeGalleryId().getPgName()); + this.setRoad(pgPartition.getRoad()); this.setActive(String.valueOf(pgPartition.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java index 9b161bf..8b430dc 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java @@ -112,8 +112,8 @@ this.setEnterDate(sdf.format(pgPipeLine.getEnterDate())); this.setLayerNum(pgPipeLine.getLayerNum()); this.setDiameter(pgPipeLine.getDiameter()); - this.setPipeGallery(pgPipeLine.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgPipeLine.getPgPartitionId().getParName()); + this.setPipeGallery(pgPipeLine.getPipeGalleryId().getPgName()); + this.setPartition(pgPipeLine.getPipeGalleryId().getPgPartitionId().getParName()); this.setActive(String.valueOf(pgPipeLine.getActive())); } } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java index 03c580c..709dcea 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java @@ -103,8 +103,8 @@ this.setOwnerUnit(pgTexture.getOwnerUnit()); this.setBuildDate(sdf.format(pgTexture.getBuildDate())); this.setActive(String.valueOf(pgTexture.getActive())); - this.setPipeGallery(pgTexture.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgTexture.getPgPartitionId().getParName()); + this.setPipeGallery(pgTexture.getPipeGalleryId().getPgName()); + this.setPartition(pgTexture.getPipeGalleryId().getPgPartitionId().getParName()); } } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java index b40ce84..319cf21 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java @@ -11,6 +11,7 @@ private String id; private String pgName;//管廊名称 + private String pgPartition;//分区名称 private String active;//状态位 public String getId() { @@ -37,10 +38,19 @@ this.active = active; } + public String getPgPartition() { + return pgPartition; + } + + public void setPgPartition(String pgPartition) { + this.pgPartition = pgPartition; + } + public PipeGalleryDto(PipeGallery pipeGallery) { this.setId(String.valueOf(pipeGallery.getId())); this.setPgName(pipeGallery.getPgName()); + this.setPgPartition(pipeGallery.getPgPartitionId().getParName()); this.setActive(String.valueOf(pipeGallery.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java b/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java index 8b413e7..0c594e7 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java @@ -5,10 +5,10 @@ import com.casic.PgInterface.devTable.domain.PipeGallery; import com.casic.PgInterface.devTable.dto.PgPartitionDto; import org.hibernate.Criteria; +import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; -import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; @@ -18,44 +18,50 @@ @Service public class PgPartitionManager extends HibernateEntityDao { - private PipeGalleryManager pipeGalleryManager; - - @Resource - public void setPipeGalleryManager(PipeGalleryManager pipeGalleryManager) { - this.pipeGalleryManager = pipeGalleryManager; - } - - public PgPartition getPartitionByParName(String parName,PipeGallery pipeGallery) { - if(pipeGallery==null) - return null; - Criteria criteria = getSession().createCriteria(PgPartition.class); + public PgPartition getPartitionByParName(String parName) { + Criteria criteria = getSession().createCriteria(PipeGallery.class); criteria.add(Restrictions.eq("parName", parName)); - criteria.add(Restrictions.eq("pipeGalleryId",pipeGallery)); + criteria.add(Restrictions.eq("active",1)); List pgPartitionList = criteria.list(); - //TODO LIST:为空判断 pgPartitionList==null? if (pgPartitionList != null && pgPartitionList.size() > 0) return pgPartitionList.get(0); else return null; } - public List getPartitionByPG(String pgName){ - PipeGallery pipeGallery=pipeGalleryManager.getPipeGalleryByPgName(pgName); - - Criteria criteria=getSession().createCriteria(PgPartition.class); - criteria.add(Restrictions.eq("pipeGalleryId",pipeGallery)); + public List getPartitionByRoad(String road) { + Criteria criteria = getSession().createCriteria(PipeGallery.class); + criteria.add(Restrictions.eq("road", road)); + criteria.add(Restrictions.eq("active",1)); List pgPartitionList = criteria.list(); List pgPartitionDtoList=new ArrayList(); - for(PgPartition pgPartition:pgPartitionList) - { - pgPartitionDtoList.add(new PgPartitionDto(pgPartition)); - } + for(PgPartition pgPartition:pgPartitionList) { + pgPartitionDtoList.add(new PgPartitionDto(pgPartition)); + } return pgPartitionDtoList; } + public List getPgPartitionDtoList() + { + Criteria criteria=getSession().createCriteria(PgPartition.class); + criteria.add(Restrictions.eq("active",1)); + criteria.addOrder(Order.desc("id")); + + List pgPartitionList=criteria.list(); + if(pgPartitionList.size()==0||pgPartitionList==null) + return null; + List pgPartitionDtoList=new ArrayList(); + for(PgPartition pgPartition:pgPartitionList) { + pgPartitionDtoList.add(new PgPartitionDto(pgPartition)); + } + return pgPartitionDtoList; + } + + + } diff --git a/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java b/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java index 16370c6..9bce32b 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java @@ -1,14 +1,16 @@ package com.casic.PgInterface.devTable.manager; import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.devTable.domain.PgPartition; import com.casic.PgInterface.devTable.domain.PipeGallery; import com.casic.PgInterface.devTable.dto.PipeGalleryDto; import org.hibernate.Criteria; -import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; -import java.util.*; +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; /** * Created by yxw on 2017/11/4. @@ -16,36 +18,44 @@ @Service public class PipeGalleryManager extends HibernateEntityDao { - public PipeGallery getPipeGalleryByPgName(String pgName) { - Criteria criteria = getSession().createCriteria(PipeGallery.class); + private PgPartitionManager pgPartitionManager; + + @Resource + public void setPgPartitionManager(PgPartitionManager pgPartitionManager) { + this.pgPartitionManager = pgPartitionManager; + } + + public PipeGallery getPipeGalleryByPgName(String pgName,PgPartition pgPartition) { + if(pgPartition==null) + return null; + Criteria criteria = getSession().createCriteria(PgPartition.class); criteria.add(Restrictions.eq("pgName", pgName)); - criteria.add(Restrictions.eq("active",1)); + criteria.add(Restrictions.eq("pgPartitionId",pgPartition)); List pipeGalleryList = criteria.list(); - //TODO LIST:为空判断 pipeGalleryList==null? + //TODO LIST:为空判断 pgPartitionList==null? if (pipeGalleryList != null && pipeGalleryList.size() > 0) return pipeGalleryList.get(0); else return null; } - public List getPIpeGalleryDtoList() - { - Criteria criteria=getSession().createCriteria(PipeGallery.class); - criteria.add(Restrictions.eq("active",1)); - criteria.addOrder(Order.desc("id")); - List pipeGalleryList=criteria.list(); - if(pipeGalleryList.size()==0||pipeGalleryList==null) - return null; - List pipeGalleryDtoList=new ArrayList(); - for(PipeGallery pipeGallery:pipeGalleryList) { + public List getPipeGalleryByParName(String parName) { + + PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName); + Criteria criteria = getSession().createCriteria(PipeGallery.class); + criteria.add(Restrictions.eq("pgPartitionId", pgPartition)); + + List pipeGalleryList = criteria.list(); + + List pipeGalleryDtoList = new ArrayList(); + for (PipeGallery pipeGallery : pipeGalleryList) { pipeGalleryDtoList.add(new PipeGalleryDto(pipeGallery)); } + return pipeGalleryDtoList; } - - } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java new file mode 100644 index 0000000..9d06235 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java @@ -0,0 +1,63 @@ +package com.casic.PgInterface.patroler.domain; + +import com.casic.PgInterface.devTable.domain.PgDevice; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + +import javax.persistence.*; +import java.io.Serializable; + +/** + * Created by yxw on 2017/12/14. + */ +@Entity +@Table(name = "PG_ALARM_RULE") +@SequenceGenerator(name = "SEQ_PG_ALARM_RULE_ID", sequenceName = "SEQ_PG_ALARM_RULE_ID",allocationSize=1,initialValue=1) +public class PgAlarmRule implements Serializable { + + private static final long serialVersionUID = 1L; + private long id; + private String highValue;//高限 + private String lowValue;//低限 + private PgDevice pgDeviceId;//设备 + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_ALARM_RULE_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "HIGHVALUE") + public String getHighValue() { + return highValue; + } + + public void setHighValue(String highValue) { + this.highValue = highValue; + } + + @Column(name = "LOWVALUE") + public String getLowValue() { + return lowValue; + } + + public void setLowValue(String lowValue) { + this.lowValue = lowValue; + } + + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "PGDEVICEID") + public PgDevice getPgDeviceId() { + return pgDeviceId; + } + + public void setPgDeviceId(PgDevice pgDeviceId) { + this.pgDeviceId = pgDeviceId; + } + +} diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java new file mode 100644 index 0000000..8367ad4 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java @@ -0,0 +1,57 @@ +package com.casic.PgInterface.patroler.dto; + +import com.casic.PgInterface.patroler.domain.PgAlarmRule; + +import java.io.Serializable; + +/** + * Created by yxw on 2017/12/14. + */ +public class PgAlarmRuleDto implements Serializable { + + private String id; + private String highValue;//高限 + private String lowValue;//低限 + private String devName;//设备 + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getHighValue() { + return highValue; + } + + public void setHighValue(String highValue) { + this.highValue = highValue; + } + + public String getLowValue() { + return lowValue; + } + + public void setLowValue(String lowValue) { + this.lowValue = lowValue; + } + + public String getDevName() { + return devName; + } + + public void setDevName(String devName) { + this.devName = devName; + } + + public PgAlarmRuleDto(PgAlarmRule pgAlarmRule) + { + this.setId(String.valueOf(pgAlarmRule.getId())); + this.setDevName(pgAlarmRule.getPgDeviceId().getAssetName()); + this.setHighValue(pgAlarmRule.getHighValue()); + this.setLowValue(pgAlarmRule.getLowValue()); + } + +} diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java new file mode 100644 index 0000000..d5c00b2 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java @@ -0,0 +1,42 @@ +package com.casic.PgInterface.patroler.manager; + +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.devTable.domain.PgDevice; +import com.casic.PgInterface.patroler.domain.PgAlarmRule; +import com.casic.PgInterface.patroler.dto.PgAlarmRuleDto; +import org.hibernate.Criteria; +import org.hibernate.criterion.Restrictions; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * Created by yxw on 2017/12/14. + */ +@Service +public class PgAlarmRuleManager extends HibernateEntityDao { + + //根据设备获取设备报警阈值 + public PgAlarmRuleDto getAlarmRuleDtoBydev(PgDevice pgDeviceId) { + Criteria criteria=createCriteria(PgAlarmRule.class); + criteria.add(Restrictions.eq("pgDeviceId", pgDeviceId)); + + List pgAlarmRuleList=criteria.list(); + if(pgAlarmRuleList.size()==0) + return null; + else + return new PgAlarmRuleDto(pgAlarmRuleList.get(0)); + } + + public PgAlarmRule getAlarmRuleBydev(PgDevice pgDeviceId) { + Criteria criteria=createCriteria(PgAlarmRule.class); + criteria.add(Restrictions.eq("pgDeviceId", pgDeviceId)); + + List pgAlarmRuleList=criteria.list(); + if(pgAlarmRuleList.size()==0) + return null; + else + return pgAlarmRuleList.get(0); + } + +} diff --git a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java new file mode 100644 index 0000000..88255c6 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java @@ -0,0 +1,162 @@ +package com.casic.PgInterface.rs; + +import com.casic.PgInterface.devTable.domain.PgDevice; +import com.casic.PgInterface.devTable.manager.PgDeviceManager; +import com.casic.PgInterface.patroler.domain.PgAlarmRule; +import com.casic.PgInterface.patroler.dto.PgAlarmRuleDto; +import com.casic.PgInterface.patroler.manager.PgAlarmRuleManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import javax.ws.rs.FormParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import java.util.HashMap; +import java.util.Map; + +/** + * Created by yxw on 2017/12/14. + */ +@Component +@Path("pgAlarmRule") +public class PgAlarmRuleRs { + + private static Logger logger = LoggerFactory.getLogger(PgAlarmRule.class); + + private PgDeviceManager pgDeviceManager; + + private PgAlarmRuleManager pgAlarmRuleManager; + + @Resource + public void setPgAlarmRuleManager(PgAlarmRuleManager pgAlarmRuleManager) { + this.pgAlarmRuleManager = pgAlarmRuleManager; + } + + @Resource + public void setPgDeviceManager(PgDeviceManager pgDeviceManager) { + this.pgDeviceManager = pgDeviceManager; + } + + /** + * 获取报警阈值信息 + */ + @POST + @Path("getAlarmRuleByAssetCode") + @Produces(MediaType.APPLICATION_JSON) + public Map getAlarmRuleByAssetCode(@FormParam("assetCode") String assetCode) throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + + PgAlarmRuleDto pgAlarmRuleDto = null; + PgDevice pgDevice = pgDeviceManager.getDeviceByAssetCode(assetCode); + try { + pgAlarmRuleDto = pgAlarmRuleManager.getAlarmRuleDtoBydev(pgDevice); + if (pgAlarmRuleDto == null) + msg = "不存在报警阈值信息"; + else + msg = "报警阈值获取成功"; + } catch (Exception e) { + e.printStackTrace(); + msg = "报警信息获取失败"; + } + resultMap.put("msg", msg); + resultMap.put("result", pgAlarmRuleDto); + return resultMap; + } + + /** + * 新增报警阈值 + */ + @POST + @Path("addAlarmRule") + @Produces(MediaType.APPLICATION_JSON) + public Map addAlarmRule(@FormParam("assetCode") String assetCode, + @FormParam("highValue") String highValue, + @FormParam("lowValue") String lowValue) throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + String result = ""; + + PgAlarmRule pgAlarmRule = null; + PgDevice pgDevice = pgDeviceManager.getDeviceByAssetCode(assetCode); + if (pgDevice == null) + msg = "不存在设备信息"; + else { + try { + pgAlarmRule = pgAlarmRuleManager.getAlarmRuleBydev(pgDevice); + if (pgAlarmRule != null) { + result = "false"; + msg = "设备阈值已经存在"; + } else { + pgAlarmRule = new PgAlarmRule(); + pgAlarmRule.setHighValue(highValue); + pgAlarmRule.setLowValue(lowValue); + pgAlarmRule.setPgDeviceId(pgDevice); + + pgAlarmRuleManager.save(pgAlarmRule); + result = "true"; + msg = "报警阈值新增成功"; + } + + } catch (Exception e) { + e.printStackTrace(); + result = "false"; + msg = "报警阈值新增失败"; + } + } + resultMap.put("msg", msg); + resultMap.put("result", result); + return resultMap; + } + + /** + * 编辑报警阈值 + */ + @POST + @Path("editAlarmRule") + @Produces(MediaType.APPLICATION_JSON) + public Map editAlarmRule(@FormParam("id") String id, + @FormParam("assetCode") String assetCode, + @FormParam("highValue") String highValue, + @FormParam("lowValue") String lowValue) throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + String result = ""; + + PgAlarmRule pgAlarmRule = null; + PgDevice pgDevice = pgDeviceManager.getDeviceByAssetCode(assetCode); + if (pgDevice == null) { + msg = "不存在设备信息"; + result = "false"; + } else { + try { + pgAlarmRule = pgAlarmRuleManager.get(id); + if (pgAlarmRule == null) { + msg="不存在报警阈值记录"; + result="false"; + } else { + pgAlarmRule.setPgDeviceId(pgDevice); + pgAlarmRule.setHighValue(highValue); + pgAlarmRule.setLowValue(lowValue); + pgAlarmRuleManager.save(pgAlarmRule); + msg="编辑成功"; + result="true"; + } + } catch (Exception ex) { + ex.printStackTrace(); + result = "false"; + msg = "报警阈值编辑失败"; + } + } + resultMap.put("msg", msg); + resultMap.put("result", result); + + return resultMap; + + } + +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java b/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java index 36a4fc5..4f77754 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java @@ -18,7 +18,6 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; -import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -65,14 +64,14 @@ * 获取设备信息 */ @POST - @Path("getPgDeviceByName") + @Path("getPgDeviceByAssetCode") @Produces(MediaType.APPLICATION_JSON) - public Map getPgDeviceByName(@FormParam("devName") String devName) throws Exception { + public Map getPgDeviceByAssetCode(@FormParam("assetCode") String assetCode) throws Exception { Map resultMap = new HashMap(); String msg = ""; PgDeviceDto pgDeviceDto=null; try { - PgDevice pgDevice = pgDeviceManager.getDeviceBydevName(devName); + PgDevice pgDevice = pgDeviceManager.getDeviceByAssetCode(assetCode); pgDeviceDto=new PgDeviceDto(pgDevice); msg = "获取成功"; } catch (Exception e) { @@ -84,7 +83,6 @@ return resultMap; } - /** * 显示设备列表 */ @@ -116,42 +114,49 @@ @POST @Path("addDevice") @Produces(MediaType.APPLICATION_JSON) - public Map addDevice(@FormParam("devType") String devType, - @FormParam("devCode") String devCode, - @FormParam("devName") String devName, - @FormParam("brand") String brand, - @FormParam("ownerUnit") String ownerUnit, - @FormParam("installDate") String installDate, - @FormParam("pgName") String pgName, - @FormParam("parName") String parName) + public Map addDevice(@FormParam("parName") String parName, + @FormParam("pgName") String pgName, + @FormParam("road") String road, + @FormParam("position") String position, + @FormParam("devType") String devType, + @FormParam("devCode") String devCode, + @FormParam("assetName") String assetName, + @FormParam("assetCode") String assetCode, + @FormParam("assetBarCode") String assetBarCode, + @FormParam("ip") String ip, + @FormParam("modBus") String modBus, + @FormParam("mome") String mome) throws Exception { - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - Map resultMap = new HashMap(); String result = ""; String msg = ""; - PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName); - PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName, pipeGallery); + PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName); + PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName,pgPartition); + if (pgPartition == null) { result = "false"; msg = "不存在管廊仓和分区信息"; } else { try { - if (pgDeviceManager.getDeviceBydevName(devName)!=null) { + if (pgDeviceManager.getDeviceByAssetCode(assetCode)!=null) { result = "false"; msg = "已存在同名设备"; } else { PgDevice pgDevice = new PgDevice(); - pgDevice.setDevTypeId(pgDeviceTypeManager.getPgDeviceTypeByDevType(devType)); + pgDevice.setPipeGalleryId(pipeGallery); + pgDevice.setRoad(road); + pgDevice.setPosition(position); + pgDevice.setDevType(devType); pgDevice.setDevCode(devCode); - pgDevice.setDevName(devName); - pgDevice.setBrand(brand); - pgDevice.setOwnerUnit(ownerUnit); - pgDevice.setInstallDate(sdf.parse(installDate)); - pgDevice.setPgPartitionId(pgPartition); + pgDevice.setAssetName(assetName); + pgDevice.setAssetCode(assetCode); + pgDevice.setAssetBarCode(assetBarCode); + pgDevice.setIp(ip); + pgDevice.setModBus(modBus); + pgDevice.setMome(mome); pgDevice.setIsOpen(0); pgDevice.setActive(1); @@ -179,41 +184,49 @@ @Path("editDevice") @Produces(MediaType.APPLICATION_JSON) public Map editPartition(@FormParam("id") String id, + @FormParam("parName") String parName, + @FormParam("pgName") String pgName, + @FormParam("road") String road, + @FormParam("position") String position, @FormParam("devType") String devType, @FormParam("devCode") String devCode, - @FormParam("devName") String devName, - @FormParam("brand") String brand, - @FormParam("ownerUnit") String ownerUnit, - @FormParam("installDate") String installDate, - @FormParam("pgName") String pgName, - @FormParam("parName") String parName, + @FormParam("assetName") String assetName, + @FormParam("assetCode") String assetCode, + @FormParam("assetBarCode") String assetBarCode, + @FormParam("ip") String ip, + @FormParam("modBus") String modBus, + @FormParam("mome") String mome, @FormParam("isOpen") String isOpen) throws Exception { - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - Map resultMap = new HashMap(); String result = ""; String msg = ""; - PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName); - PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName, pipeGallery); + PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName); + PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName,pgPartition); + if (pgPartition == null) { result = "false"; msg = "不存在管廊仓和分区信息"; } else { try { - if (pgDeviceManager.getDeviceBydevName(devName)!=null) { + if (pgDeviceManager.getDeviceByAssetCode(assetCode)!=null) { result = "false"; msg = "已存在同名设备"; } else { PgDevice pgDevice = pgDeviceManager.get(Long.valueOf(id)); - pgDevice.setDevTypeId(pgDeviceTypeManager.getPgDeviceTypeByDevType(devType)); + pgDevice.setPipeGalleryId(pipeGallery); + pgDevice.setRoad(road); + pgDevice.setPosition(position); + pgDevice.setDevType(devType); pgDevice.setDevCode(devCode); - pgDevice.setDevName(devName); - pgDevice.setBrand(brand); - pgDevice.setOwnerUnit(ownerUnit); - pgDevice.setInstallDate(sdf.parse(installDate)); - pgDevice.setPgPartitionId(pgPartition); + pgDevice.setAssetName(assetName); + pgDevice.setAssetCode(assetCode); + pgDevice.setAssetBarCode(assetBarCode); + pgDevice.setIp(ip); + pgDevice.setModBus(modBus); + pgDevice.setMome(mome); + pgDevice.setActive(1); pgDevice.setIsOpen(Integer.valueOf(isOpen)); pgDeviceManager.save(pgDevice); diff --git a/src/main/java/com/casic/PgInterface/rs/PgLocationRs.java b/src/main/java/com/casic/PgInterface/rs/PgLocationRs.java new file mode 100644 index 0000000..e8daabc --- /dev/null +++ b/src/main/java/com/casic/PgInterface/rs/PgLocationRs.java @@ -0,0 +1,39 @@ +package com.casic.PgInterface.rs; + +import com.casic.PgInterface.devData.manager.PgLocationManager; +import com.casic.PgInterface.devTable.manager.PgDeviceManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import javax.ws.rs.Path; + +/** + * Created by yxw on 2017/12/11. + */ +@Component +@Path("location") +public class PgLocationRs { + + private static Logger logger = LoggerFactory.getLogger(PgLocationRs.class); + + private PgDeviceManager pgDeviceManager; + + private PgLocationManager pgLocationManager; + + @Resource + public void setPgDeviceManager(PgDeviceManager pgDeviceManager) { + this.pgDeviceManager = pgDeviceManager; + } + + @Resource + public void setPgLocationManager(PgLocationManager pgLocationManager) { + this.pgLocationManager = pgLocationManager; + } + + + + + +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java b/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java index 45fc210..8a42e7e 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java @@ -1,10 +1,8 @@ package com.casic.PgInterface.rs; import com.casic.PgInterface.devTable.domain.PgPartition; -import com.casic.PgInterface.devTable.domain.PipeGallery; import com.casic.PgInterface.devTable.dto.PgPartitionDto; import com.casic.PgInterface.devTable.manager.PgPartitionManager; -import com.casic.PgInterface.devTable.manager.PipeGalleryManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; @@ -29,8 +27,6 @@ private static Logger logger = LoggerFactory.getLogger(PgPartitionRs.class); - private PipeGalleryManager pipeGalleryManager; - private PgPartitionManager pgPartitionManager; @Resource @@ -38,38 +34,24 @@ this.pgPartitionManager = pgPartitionManager; } - @Resource - public void setPipeGalleryManager(PipeGalleryManager pipeGalleryManager) { - - this.pipeGalleryManager = pipeGalleryManager; - } - /** * 新增分区 */ @POST @Path("addPartition") @Produces(MediaType.APPLICATION_JSON) - public Map addAlarm(@FormParam("parName") String parName, - @FormParam("pgName") String pgName)throws Exception { + public Map addAlarm(@FormParam("parName") String parName)throws Exception { Map resultMap = new HashMap(); String result = ""; String msg = ""; try { - PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName); - - if (pipeGallery == null) { - result = "false"; - msg = "不存在" + pgName + "管廊仓"; - } else { - if (pgPartitionManager.getPartitionByParName(parName, pipeGallery) != null) { + if (pgPartitionManager.getPartitionByParName(parName) != null) { result = "false"; msg = "已存在相同分区"; } else { PgPartition pgPartition = new PgPartition(); pgPartition.setParName(parName); - pgPartition.setPipeGalleryId(pipeGallery); pgPartition.setActive(1); logger.info("成功保存"); @@ -77,7 +59,7 @@ result = "true"; msg = "保存成功"; } - } + } catch (Exception e) { result = "false"; msg = "保存失败"; @@ -89,37 +71,13 @@ return resultMap; } - /** - *获取管廊仓下的分区列表 - */ - @POST - @Path("getPartition") - @Produces(MediaType.APPLICATION_JSON) - public Map getPartitionList(@FormParam("pgName") String pgName)throws Exception { - Map resultMap = new HashMap(); - String msg=""; - List pgPartitionDtoList=new ArrayList(); - try { - pgPartitionDtoList=pgPartitionManager.getPartitionByPG(pgName); - if(pgPartitionDtoList.size()==0) - msg="没有分区信息"; - else - msg="分区信息获取成功"; - }catch(Exception e){ - e.printStackTrace(); - msg="分区信息获取失败"; - } - resultMap.put("msg",msg); - resultMap.put("result",pgPartitionDtoList); - return resultMap; - } + @POST @Path("editPartition") @Produces(MediaType.APPLICATION_JSON) public Map editPartition(@FormParam("id") String id, - @FormParam("parName") String parName, - @FormParam("pgName") String pgName) throws Exception { + @FormParam("parName") String parName) throws Exception { Map resultMap = new HashMap(); String result = ""; @@ -128,25 +86,20 @@ PgPartition partition = new PgPartition(); try { - PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName); - if (pipeGallery == null) { - result = "false"; - msg = "不存在该管廊信息"; - } else { - if (pgPartitionManager.getPartitionByParName(parName, pipeGallery) != null) { + + if (pgPartitionManager.getPartitionByParName(parName) != null) { result = "false"; msg = "已存在相同分区"; } else { PgPartition pgPartition = pgPartitionManager.get(Long.valueOf(id)); pgPartition.setParName(parName); - pgPartition.setPipeGalleryId(pipeGallery); pgPartition.setActive(1); pgPartitionManager.save(pgPartition); result = "true"; msg = "编辑成功"; } - } + } catch (Exception e) { result = "false"; msg = "编辑失败"; @@ -194,5 +147,49 @@ return resultMap; } + /** + * 获取分区信息 + */ + @POST + @Path("getPartitionList") + @Produces(MediaType.APPLICATION_JSON) + public Map getPartition() throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + List pgPartitionDtoList = new ArrayList(); + try { + pgPartitionDtoList = pgPartitionManager.getPgPartitionDtoList(); + msg = "获取成功"; + } catch (Exception e) { + msg = "获取失败"; + e.printStackTrace(); + } + resultMap.put("msg", msg); + resultMap.put("result", pgPartitionDtoList); + return resultMap; + } + + /** + * 获取分区信息 + */ + @POST + @Path("getPartitionListByRoad") + @Produces(MediaType.APPLICATION_JSON) + public Map getPartitionListByRoad(@FormParam("road") String road) throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + List pgPartitionDtoList = new ArrayList(); + try { + pgPartitionDtoList = pgPartitionManager.getPartitionByRoad(road); + msg = "获取成功"; + } catch (Exception e) { + msg = "获取失败"; + e.printStackTrace(); + } + resultMap.put("msg", msg); + resultMap.put("result", pgPartitionDtoList); + return resultMap; + } + } diff --git a/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java b/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java index 7593027..8cbdb0a 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java @@ -96,8 +96,8 @@ String result = ""; String msg = ""; - PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName); - PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName, pipeGallery); + PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName); + PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName,pgPartition); if (pgPartition == null) { result = "false"; msg = "不存在管廊仓和分区信息"; @@ -118,7 +118,7 @@ pgPipeLine.setLayerNum(layerNum); pgPipeLine.setEnterDate(sdf.parse(enterDate)); pgPipeLine.setDiameter(diameter); - pgPipeLine.setPgPartitionId(pgPartition); + pgPipeLine.setPipeGalleryId(pipeGallery); pgPipeLine.setActive(1); pgPipeLineManager.save(pgPipeLine); @@ -158,8 +158,8 @@ String result = ""; String msg = ""; - PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName); - PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName, pipeGallery); + PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName); + PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName,pgPartition); if (pgPartition == null) { result = "false"; msg = "不存在管廊仓和分区信息"; @@ -179,7 +179,7 @@ pgPipeLine.setEnterDate(sdf.parse(enterDate)); pgPipeLine.setLayerNum(layerNum); pgPipeLine.setDiameter(diameter); - pgPipeLine.setPgPartitionId(pgPartition); + pgPipeLine.setPipeGalleryId(pipeGallery); pgPipeLine.setActive(1); pgPipeLineManager.save(pgPipeLine); diff --git a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java index 80625c7..d8f5e6b 100644 --- a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java +++ b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java @@ -43,9 +43,7 @@ this.intoTime = intoTime; } - @Column(name = "OUT_TIME") - public Date getOutTime() { return outTime; } diff --git a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java index a99981e..b1d63a4 100644 --- a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java +++ b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java @@ -1,11 +1,28 @@ package com.casic.PgInterface.devData.manager; +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.core.util.DateUtils; +import com.casic.PgInterface.core.util.StringUtils; +import com.casic.PgInterface.devData.domain.PgCo; +import com.casic.PgInterface.devData.domain.PgLocation; +import com.casic.PgInterface.devData.dto.PgCoDto; +import com.casic.PgInterface.devData.dto.PgLocationDto; +import com.casic.PgInterface.devTable.domain.PgDevice; +import org.hibernate.Criteria; +import org.hibernate.criterion.Order; +import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; + /** * Created by yxw on 2017/11/2. */ @Service -public class PgLocationManager { +public class PgLocationManager extends HibernateEntityDao { + + //获取设备时间段内所有的监测数据 } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java index cfa0281..7fb5953 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -1,12 +1,12 @@ package com.casic.PgInterface.devTable.domain; import com.casic.PgInterface.devData.domain.*; +import com.casic.PgInterface.patroler.domain.PgAlarmRule; import org.hibernate.annotations.NotFound; import org.hibernate.annotations.NotFoundAction; import javax.persistence.*; import java.io.Serializable; -import java.util.Date; import java.util.List; /** @@ -19,21 +19,27 @@ private static final long serialVersionUID = 1L; private long id; + private PipeGallery pipeGalleryId;//所在管廊信息 + private String road;//路名 + private String position;//设备位置 + private String devType;//设备类型 private String devCode;//设备编号 - private String devName;//设备名称 - private String brand;//品牌 - private String ownerUnit;//权属单位 - private Date installDate;//安装时间 + private String assetName;//资产名称 + private String assetCode;//资产编码 + private String assetBarCode;//资产条码 + private String ip;//IP地址 + private String modBus;//modBus地址 + private String mome;//备注 private int isOpen;//设备是否开启 private int active;//状态位 - private PgDeviceType devTypeId;//设备类型 + private List pgAlarms; - private PgPartition pgPartitionId;//所在管廊信息 private List pgTempHums;//温湿度 private List pgCos;//一氧化碳 private List pgO2s;//氧气 private List pgCh4s;//甲烷 private List pgShs;//硫化氢 + private List pgAlarmRules;//报警规则 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") @@ -45,6 +51,33 @@ this.id = id; } + @Column(name = "ROAD") + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + @Column(name = "POSITION") + public String getPosition() { + return position; + } + + public void setPosition(String position) { + this.position = position; + } + + @Column(name = "DEV_TYPE") + public String getDevType() { + return devType; + } + + public void setDevType(String devType) { + this.devType = devType; + } + @Column(name = "DEV_CODE") public String getDevCode() { return devCode; @@ -54,40 +87,58 @@ this.devCode = devCode; } - @Column(name = "DEV_NAME") - public String getDevName() { - return devName; + @Column(name = "ASSET_NAME") + public String getAssetName() { + return assetName; } - public void setDevName(String devName) { - this.devName = devName; + public void setAssetName(String assetName) { + this.assetName = assetName; } - @Column(name = "BRAND") - public String getBrand() { - return brand; + @Column(name = "ASSET_CODE") + public String getAssetCode() { + return assetCode; } - public void setBrand(String brand) { - this.brand = brand; + public void setAssetCode(String assetCode) { + this.assetCode = assetCode; } - @Column(name = "OWNERUNIT") - public String getOwnerUnit() { - return ownerUnit; + @Column(name = "ASSET_BAR_CODE") + public String getAssetBarCode() { + return assetBarCode; } - public void setOwnerUnit(String ownerUnit) { - this.ownerUnit = ownerUnit; + public void setAssetBarCode(String assetBarCode) { + this.assetBarCode = assetBarCode; } - @Column(name = "INSTALDATE") - public Date getInstallDate() { - return installDate; + @Column(name = "IP") + public String getIp() { + return ip; } - public void setInstallDate(Date installDate) { - this.installDate = installDate; + public void setIp(String ip) { + this.ip = ip; + } + + @Column(name = "MODBUS") + public String getModBus() { + return modBus; + } + + public void setModBus(String modBus) { + this.modBus = modBus; + } + + @Column(name = "MOME") + public String getMome() { + return mome; + } + + public void setMome(String mome) { + this.mome = mome; } @Column(name = "ISOPEN") @@ -119,24 +170,13 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; - } - - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "DEVICE_TYPE_ID") - public PgDeviceType getDevTypeId() { - return devTypeId; - } - - public void setDevTypeId(PgDeviceType devTypeId) { - this.devTypeId = devTypeId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgDeviceId") @@ -184,4 +224,13 @@ this.pgShs = pgShs; } + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgDeviceId") + public List getPgAlarmRules() { + return pgAlarmRules; + } + + public void setPgAlarmRules(List pgAlarmRules) { + this.pgAlarmRules = pgAlarmRules; + } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java index b997b29..4fb3d6f 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java @@ -1,8 +1,5 @@ package com.casic.PgInterface.devTable.domain; -import org.hibernate.annotations.NotFound; -import org.hibernate.annotations.NotFoundAction; - import javax.persistence.*; import java.io.Serializable; import java.util.List; @@ -19,11 +16,9 @@ private long id; private String parName;//分区名称 - private PipeGallery pipeGalleryId;//管廊仓 + private String road;//所属道路 private int active;//状态位 - private List pgTextureList; - private List pgPipeLineList; - private List pgDeviceList; + private List pipeGalleryList;//管廊仓 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PARTITION_ID") @@ -44,6 +39,15 @@ this.parName = parName; } + @Column(name = "ROAD") + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + @Column(name = "ACTIVE") public int getActive() { return active; @@ -53,41 +57,14 @@ this.active = active; } - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PIPEGALLERYID") - public PipeGallery getPipeGalleryId() { - return pipeGalleryId; - } - - public void setPipeGalleryId(PipeGallery pipeGalleryId) { - this.pipeGalleryId = pipeGalleryId; - } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgTextureList() { - return pgTextureList; + public List getPipeGalleryList() { + return pipeGalleryList; } - public void setPgTextureList(List pgTextureList) { - this.pgTextureList = pgTextureList; + public void setPipeGalleryList(List pipeGalleryList) { + this.pipeGalleryList = pipeGalleryList; } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgPipeLineList() { - return pgPipeLineList; - } - public void setPgPipeLineList(List pgPipeLineList) { - this.pgPipeLineList = pgPipeLineList; - } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgDeviceList() { - return pgDeviceList; - } - - public void setPgDeviceList(List pgDeviceList) { - this.pgDeviceList = pgDeviceList; - } } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java index d936d18..e5ff9b3 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java @@ -22,7 +22,7 @@ private Date enterDate;//入廊时间 private String layerNum;//所在层数 private String diameter;//管径 - private PgPartition pgPartitionId;//所在管廊信息 + private PipeGallery pipeGalleryId;//所在管廊信息 private int active;//状态位 @Id @@ -100,12 +100,12 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java index 1f22bf9..4ebfbda 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java @@ -21,7 +21,7 @@ private String ownerUnit;//权属单位 private Date buildDate;//建设年代 private int active;//状态位 - private PgPartition pgPartitionId;//所在管廊信息 + private PipeGallery pipeGalleryId;//所在管廊信息 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_TEXTURE_ID") @@ -91,12 +91,13 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java b/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java index 49a246c..650d623 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java @@ -1,5 +1,8 @@ package com.casic.PgInterface.devTable.domain; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + import javax.persistence.*; import java.io.Serializable; import java.util.List; @@ -16,7 +19,10 @@ private long id; private String pgName;//管廊名称 private int active;//状态位 - private List partitionList; + private PgPartition pgPartitionId;// + private List pgTextureList; + private List pgPipeLineList; + private List pgDeviceList; @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PIPE_GALLERY_ID") @@ -46,12 +52,42 @@ this.active = active; } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") - public List getPartitionList() { - return partitionList; + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "PARTITIONID") + public PgPartition getPgPartitionId() { + return pgPartitionId; } - public void setPartitionList(List partitionList) { - this.partitionList = partitionList; + public void setPgPartitionId(PgPartition pgPartitionId) { + this.pgPartitionId = pgPartitionId; } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgTextureList() { + return pgTextureList; + } + + public void setPgTextureList(List pgTextureList) { + this.pgTextureList = pgTextureList; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgPipeLineList() { + return pgPipeLineList; + } + + public void setPgPipeLineList(List pgPipeLineList) { + this.pgPipeLineList = pgPipeLineList; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgDeviceList() { + return pgDeviceList; + } + + public void setPgDeviceList(List pgDeviceList) { + this.pgDeviceList = pgDeviceList; + } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java index b4048d9..c3dfc55 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java @@ -101,18 +101,17 @@ this.active = active; } - public PgAlarmDto(PgAlarm pgAlarm) - { - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + public PgAlarmDto(PgAlarm pgAlarm) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); this.setId(String.valueOf(pgAlarm.getId())); this.setAlarmType(pgAlarm.getAlarmTypeId().getAlarmType()); this.setAlarmValue(pgAlarm.getAlarmValue()); this.setAlarmDate(sdf.format(pgAlarm.getAlarmDate())); this.setDescription(pgAlarm.getDescription()); - this.setAlarmDevName(pgAlarm.getAlarmDevId().getDevName()); - this.setAlarmLocation(pgAlarm.getAlarmDevId().getPgPartitionId().getPipeGalleryId().getPgName() - + pgAlarm.getAlarmDevId().getPgPartitionId().getParName()); + this.setAlarmDevName(pgAlarm.getAlarmDevId().getAssetName()); + this.setAlarmLocation(pgAlarm.getAlarmDevId().getPipeGalleryId().getPgPartitionId().getParName() + + pgAlarm.getAlarmDevId().getPipeGalleryId().getPgName()); this.setUserName(pgAlarm.getPatrolerId().getUserName()); this.setPhoneNumber(pgAlarm.getPatrolerId().getPhoneNumber()); this.setActive(String.valueOf(pgAlarm.getActive())); diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java index ae76e95..49bd436 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java @@ -11,16 +11,20 @@ public class PgDeviceDto implements Serializable { private String id; - private String devType;//设备类型 - private String devCode;//设备编号 - private String devName;//设备名称 - private String brand;//品牌 - private String ownerUnit;//权属单位 - private String installDate;//安装时间 - private String isOpen;//设备开启状态 - private String active;//状态位 private String pipeGallery;//仓位 private String partition;//分区 + private String road;//路名 + private String position;//设备位置 + private String devType;//设备类型 + private String devCode;//设备编号 + private String assetName;//资产名称 + private String assetCode;//资产名称 + private String assetBarCode;//资产条码 + private String ip;//IP地址 + private String modBus;//modBus地址 + private String mome;//备注 + private String isOpen;//设备开启状态 + private String active;//状态位 public String getId() { return id; @@ -30,6 +34,38 @@ this.id = id; } + public String getPartition() { + return partition; + } + + public void setPartition(String partition) { + this.partition = partition; + } + + public String getPipeGallery() { + return pipeGallery; + } + + public void setPipeGallery(String pipeGallery) { + this.pipeGallery = pipeGallery; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getPosition() { + return position; + } + + public void setPosition(String position) { + this.position = position; + } + public String getDevType() { return devType; } @@ -46,36 +82,52 @@ this.devCode = devCode; } - public String getDevName() { - return devName; + public String getAssetName() { + return assetName; } - public void setDevName(String devName) { - this.devName = devName; + public void setAssetName(String assetName) { + this.assetName = assetName; } - public String getBrand() { - return brand; + public String getAssetCode() { + return assetCode; } - public void setBrand(String brand) { - this.brand = brand; + public void setAssetCode(String assetCode) { + this.assetCode = assetCode; } - public String getOwnerUnit() { - return ownerUnit; + public String getAssetBarCode() { + return assetBarCode; } - public void setOwnerUnit(String ownerUnit) { - this.ownerUnit = ownerUnit; + public void setAssetBarCode(String assetBarCode) { + this.assetBarCode = assetBarCode; } - public String getInstallDate() { - return installDate; + public String getIp() { + return ip; } - public void setInstallDate(String installDate) { - this.installDate = installDate; + public void setIp(String ip) { + this.ip = ip; + } + + public String getModBus() { + return modBus; + } + + public void setModBus(String modBus) { + this.modBus = modBus; + } + + public String getMome() { + return mome; + } + + public void setMome(String mome) { + this.mome = mome; } public String getIsOpen() { @@ -94,39 +146,26 @@ this.active = active; } - public String getPipeGallery() { - return pipeGallery; - } - - public void setPipeGallery(String pipeGallery) { - this.pipeGallery = pipeGallery; - } - - public String getPartition() { - return partition; - } - - public void setPartition(String partition) { - this.partition = partition; - } - public PgDeviceDto(PgDevice pgDevice) { SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); this.setId(String.valueOf(pgDevice.getId())); - this.setDevType(pgDevice.getDevTypeId().getDevType()); + this.setPipeGallery(pgDevice.getPipeGalleryId().getPgName()); + this.setPartition(pgDevice.getPipeGalleryId().getPgPartitionId().getParName()); + this.setRoad(pgDevice.getRoad()); + this.setPosition(pgDevice.getPosition()); + this.setDevType(pgDevice.getDevType()); this.setDevCode(pgDevice.getDevCode()); - this.setDevName(pgDevice.getDevName()); - this.setBrand(pgDevice.getBrand()); - this.setOwnerUnit(pgDevice.getOwnerUnit()); - this.setInstallDate(sdf.format(pgDevice.getInstallDate())); + this.setAssetName(pgDevice.getAssetName()); + this.setAssetCode(pgDevice.getAssetCode()); + this.setAssetBarCode(pgDevice.getAssetBarCode()); + this.setId(pgDevice.getIp()); + this.setModBus(pgDevice.getModBus()); + this.setMome(pgDevice.getMome()); this.setIsOpen(String.valueOf(pgDevice.getIsOpen())); this.setActive(String.valueOf(pgDevice.getActive())); - this.setPipeGallery(pgDevice.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgDevice.getPgPartitionId().getParName()); + } - -} - +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java index e8751d3..3acd0fa 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java @@ -11,7 +11,7 @@ private String id; private String parName;//分区名称 - private String pipeGallery;//管廊仓 + private String road;//所属道路 private String active;//状态位 @@ -31,14 +31,6 @@ this.parName = parName; } - public String getPipeGallery() { - return pipeGallery; - } - - public void setPipeGallery(String pipeGallery) { - this.pipeGallery = pipeGallery; - } - public String getActive() { return active; } @@ -47,11 +39,19 @@ this.active = active; } + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + public PgPartitionDto(PgPartition pgPartition) { this.setId(String.valueOf(pgPartition.getId())); this.setParName(pgPartition.getParName()); - this.setPipeGallery(pgPartition.getPipeGalleryId().getPgName()); + this.setRoad(pgPartition.getRoad()); this.setActive(String.valueOf(pgPartition.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java index 9b161bf..8b430dc 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java @@ -112,8 +112,8 @@ this.setEnterDate(sdf.format(pgPipeLine.getEnterDate())); this.setLayerNum(pgPipeLine.getLayerNum()); this.setDiameter(pgPipeLine.getDiameter()); - this.setPipeGallery(pgPipeLine.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgPipeLine.getPgPartitionId().getParName()); + this.setPipeGallery(pgPipeLine.getPipeGalleryId().getPgName()); + this.setPartition(pgPipeLine.getPipeGalleryId().getPgPartitionId().getParName()); this.setActive(String.valueOf(pgPipeLine.getActive())); } } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java index 03c580c..709dcea 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java @@ -103,8 +103,8 @@ this.setOwnerUnit(pgTexture.getOwnerUnit()); this.setBuildDate(sdf.format(pgTexture.getBuildDate())); this.setActive(String.valueOf(pgTexture.getActive())); - this.setPipeGallery(pgTexture.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgTexture.getPgPartitionId().getParName()); + this.setPipeGallery(pgTexture.getPipeGalleryId().getPgName()); + this.setPartition(pgTexture.getPipeGalleryId().getPgPartitionId().getParName()); } } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java index b40ce84..319cf21 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java @@ -11,6 +11,7 @@ private String id; private String pgName;//管廊名称 + private String pgPartition;//分区名称 private String active;//状态位 public String getId() { @@ -37,10 +38,19 @@ this.active = active; } + public String getPgPartition() { + return pgPartition; + } + + public void setPgPartition(String pgPartition) { + this.pgPartition = pgPartition; + } + public PipeGalleryDto(PipeGallery pipeGallery) { this.setId(String.valueOf(pipeGallery.getId())); this.setPgName(pipeGallery.getPgName()); + this.setPgPartition(pipeGallery.getPgPartitionId().getParName()); this.setActive(String.valueOf(pipeGallery.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java b/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java index 8b413e7..0c594e7 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java @@ -5,10 +5,10 @@ import com.casic.PgInterface.devTable.domain.PipeGallery; import com.casic.PgInterface.devTable.dto.PgPartitionDto; import org.hibernate.Criteria; +import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; -import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; @@ -18,44 +18,50 @@ @Service public class PgPartitionManager extends HibernateEntityDao { - private PipeGalleryManager pipeGalleryManager; - - @Resource - public void setPipeGalleryManager(PipeGalleryManager pipeGalleryManager) { - this.pipeGalleryManager = pipeGalleryManager; - } - - public PgPartition getPartitionByParName(String parName,PipeGallery pipeGallery) { - if(pipeGallery==null) - return null; - Criteria criteria = getSession().createCriteria(PgPartition.class); + public PgPartition getPartitionByParName(String parName) { + Criteria criteria = getSession().createCriteria(PipeGallery.class); criteria.add(Restrictions.eq("parName", parName)); - criteria.add(Restrictions.eq("pipeGalleryId",pipeGallery)); + criteria.add(Restrictions.eq("active",1)); List pgPartitionList = criteria.list(); - //TODO LIST:为空判断 pgPartitionList==null? if (pgPartitionList != null && pgPartitionList.size() > 0) return pgPartitionList.get(0); else return null; } - public List getPartitionByPG(String pgName){ - PipeGallery pipeGallery=pipeGalleryManager.getPipeGalleryByPgName(pgName); - - Criteria criteria=getSession().createCriteria(PgPartition.class); - criteria.add(Restrictions.eq("pipeGalleryId",pipeGallery)); + public List getPartitionByRoad(String road) { + Criteria criteria = getSession().createCriteria(PipeGallery.class); + criteria.add(Restrictions.eq("road", road)); + criteria.add(Restrictions.eq("active",1)); List pgPartitionList = criteria.list(); List pgPartitionDtoList=new ArrayList(); - for(PgPartition pgPartition:pgPartitionList) - { - pgPartitionDtoList.add(new PgPartitionDto(pgPartition)); - } + for(PgPartition pgPartition:pgPartitionList) { + pgPartitionDtoList.add(new PgPartitionDto(pgPartition)); + } return pgPartitionDtoList; } + public List getPgPartitionDtoList() + { + Criteria criteria=getSession().createCriteria(PgPartition.class); + criteria.add(Restrictions.eq("active",1)); + criteria.addOrder(Order.desc("id")); + + List pgPartitionList=criteria.list(); + if(pgPartitionList.size()==0||pgPartitionList==null) + return null; + List pgPartitionDtoList=new ArrayList(); + for(PgPartition pgPartition:pgPartitionList) { + pgPartitionDtoList.add(new PgPartitionDto(pgPartition)); + } + return pgPartitionDtoList; + } + + + } diff --git a/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java b/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java index 16370c6..9bce32b 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java @@ -1,14 +1,16 @@ package com.casic.PgInterface.devTable.manager; import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.devTable.domain.PgPartition; import com.casic.PgInterface.devTable.domain.PipeGallery; import com.casic.PgInterface.devTable.dto.PipeGalleryDto; import org.hibernate.Criteria; -import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; -import java.util.*; +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; /** * Created by yxw on 2017/11/4. @@ -16,36 +18,44 @@ @Service public class PipeGalleryManager extends HibernateEntityDao { - public PipeGallery getPipeGalleryByPgName(String pgName) { - Criteria criteria = getSession().createCriteria(PipeGallery.class); + private PgPartitionManager pgPartitionManager; + + @Resource + public void setPgPartitionManager(PgPartitionManager pgPartitionManager) { + this.pgPartitionManager = pgPartitionManager; + } + + public PipeGallery getPipeGalleryByPgName(String pgName,PgPartition pgPartition) { + if(pgPartition==null) + return null; + Criteria criteria = getSession().createCriteria(PgPartition.class); criteria.add(Restrictions.eq("pgName", pgName)); - criteria.add(Restrictions.eq("active",1)); + criteria.add(Restrictions.eq("pgPartitionId",pgPartition)); List pipeGalleryList = criteria.list(); - //TODO LIST:为空判断 pipeGalleryList==null? + //TODO LIST:为空判断 pgPartitionList==null? if (pipeGalleryList != null && pipeGalleryList.size() > 0) return pipeGalleryList.get(0); else return null; } - public List getPIpeGalleryDtoList() - { - Criteria criteria=getSession().createCriteria(PipeGallery.class); - criteria.add(Restrictions.eq("active",1)); - criteria.addOrder(Order.desc("id")); - List pipeGalleryList=criteria.list(); - if(pipeGalleryList.size()==0||pipeGalleryList==null) - return null; - List pipeGalleryDtoList=new ArrayList(); - for(PipeGallery pipeGallery:pipeGalleryList) { + public List getPipeGalleryByParName(String parName) { + + PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName); + Criteria criteria = getSession().createCriteria(PipeGallery.class); + criteria.add(Restrictions.eq("pgPartitionId", pgPartition)); + + List pipeGalleryList = criteria.list(); + + List pipeGalleryDtoList = new ArrayList(); + for (PipeGallery pipeGallery : pipeGalleryList) { pipeGalleryDtoList.add(new PipeGalleryDto(pipeGallery)); } + return pipeGalleryDtoList; } - - } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java new file mode 100644 index 0000000..9d06235 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java @@ -0,0 +1,63 @@ +package com.casic.PgInterface.patroler.domain; + +import com.casic.PgInterface.devTable.domain.PgDevice; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + +import javax.persistence.*; +import java.io.Serializable; + +/** + * Created by yxw on 2017/12/14. + */ +@Entity +@Table(name = "PG_ALARM_RULE") +@SequenceGenerator(name = "SEQ_PG_ALARM_RULE_ID", sequenceName = "SEQ_PG_ALARM_RULE_ID",allocationSize=1,initialValue=1) +public class PgAlarmRule implements Serializable { + + private static final long serialVersionUID = 1L; + private long id; + private String highValue;//高限 + private String lowValue;//低限 + private PgDevice pgDeviceId;//设备 + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_ALARM_RULE_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "HIGHVALUE") + public String getHighValue() { + return highValue; + } + + public void setHighValue(String highValue) { + this.highValue = highValue; + } + + @Column(name = "LOWVALUE") + public String getLowValue() { + return lowValue; + } + + public void setLowValue(String lowValue) { + this.lowValue = lowValue; + } + + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "PGDEVICEID") + public PgDevice getPgDeviceId() { + return pgDeviceId; + } + + public void setPgDeviceId(PgDevice pgDeviceId) { + this.pgDeviceId = pgDeviceId; + } + +} diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java new file mode 100644 index 0000000..8367ad4 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java @@ -0,0 +1,57 @@ +package com.casic.PgInterface.patroler.dto; + +import com.casic.PgInterface.patroler.domain.PgAlarmRule; + +import java.io.Serializable; + +/** + * Created by yxw on 2017/12/14. + */ +public class PgAlarmRuleDto implements Serializable { + + private String id; + private String highValue;//高限 + private String lowValue;//低限 + private String devName;//设备 + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getHighValue() { + return highValue; + } + + public void setHighValue(String highValue) { + this.highValue = highValue; + } + + public String getLowValue() { + return lowValue; + } + + public void setLowValue(String lowValue) { + this.lowValue = lowValue; + } + + public String getDevName() { + return devName; + } + + public void setDevName(String devName) { + this.devName = devName; + } + + public PgAlarmRuleDto(PgAlarmRule pgAlarmRule) + { + this.setId(String.valueOf(pgAlarmRule.getId())); + this.setDevName(pgAlarmRule.getPgDeviceId().getAssetName()); + this.setHighValue(pgAlarmRule.getHighValue()); + this.setLowValue(pgAlarmRule.getLowValue()); + } + +} diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java new file mode 100644 index 0000000..d5c00b2 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java @@ -0,0 +1,42 @@ +package com.casic.PgInterface.patroler.manager; + +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.devTable.domain.PgDevice; +import com.casic.PgInterface.patroler.domain.PgAlarmRule; +import com.casic.PgInterface.patroler.dto.PgAlarmRuleDto; +import org.hibernate.Criteria; +import org.hibernate.criterion.Restrictions; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * Created by yxw on 2017/12/14. + */ +@Service +public class PgAlarmRuleManager extends HibernateEntityDao { + + //根据设备获取设备报警阈值 + public PgAlarmRuleDto getAlarmRuleDtoBydev(PgDevice pgDeviceId) { + Criteria criteria=createCriteria(PgAlarmRule.class); + criteria.add(Restrictions.eq("pgDeviceId", pgDeviceId)); + + List pgAlarmRuleList=criteria.list(); + if(pgAlarmRuleList.size()==0) + return null; + else + return new PgAlarmRuleDto(pgAlarmRuleList.get(0)); + } + + public PgAlarmRule getAlarmRuleBydev(PgDevice pgDeviceId) { + Criteria criteria=createCriteria(PgAlarmRule.class); + criteria.add(Restrictions.eq("pgDeviceId", pgDeviceId)); + + List pgAlarmRuleList=criteria.list(); + if(pgAlarmRuleList.size()==0) + return null; + else + return pgAlarmRuleList.get(0); + } + +} diff --git a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java new file mode 100644 index 0000000..88255c6 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java @@ -0,0 +1,162 @@ +package com.casic.PgInterface.rs; + +import com.casic.PgInterface.devTable.domain.PgDevice; +import com.casic.PgInterface.devTable.manager.PgDeviceManager; +import com.casic.PgInterface.patroler.domain.PgAlarmRule; +import com.casic.PgInterface.patroler.dto.PgAlarmRuleDto; +import com.casic.PgInterface.patroler.manager.PgAlarmRuleManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import javax.ws.rs.FormParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import java.util.HashMap; +import java.util.Map; + +/** + * Created by yxw on 2017/12/14. + */ +@Component +@Path("pgAlarmRule") +public class PgAlarmRuleRs { + + private static Logger logger = LoggerFactory.getLogger(PgAlarmRule.class); + + private PgDeviceManager pgDeviceManager; + + private PgAlarmRuleManager pgAlarmRuleManager; + + @Resource + public void setPgAlarmRuleManager(PgAlarmRuleManager pgAlarmRuleManager) { + this.pgAlarmRuleManager = pgAlarmRuleManager; + } + + @Resource + public void setPgDeviceManager(PgDeviceManager pgDeviceManager) { + this.pgDeviceManager = pgDeviceManager; + } + + /** + * 获取报警阈值信息 + */ + @POST + @Path("getAlarmRuleByAssetCode") + @Produces(MediaType.APPLICATION_JSON) + public Map getAlarmRuleByAssetCode(@FormParam("assetCode") String assetCode) throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + + PgAlarmRuleDto pgAlarmRuleDto = null; + PgDevice pgDevice = pgDeviceManager.getDeviceByAssetCode(assetCode); + try { + pgAlarmRuleDto = pgAlarmRuleManager.getAlarmRuleDtoBydev(pgDevice); + if (pgAlarmRuleDto == null) + msg = "不存在报警阈值信息"; + else + msg = "报警阈值获取成功"; + } catch (Exception e) { + e.printStackTrace(); + msg = "报警信息获取失败"; + } + resultMap.put("msg", msg); + resultMap.put("result", pgAlarmRuleDto); + return resultMap; + } + + /** + * 新增报警阈值 + */ + @POST + @Path("addAlarmRule") + @Produces(MediaType.APPLICATION_JSON) + public Map addAlarmRule(@FormParam("assetCode") String assetCode, + @FormParam("highValue") String highValue, + @FormParam("lowValue") String lowValue) throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + String result = ""; + + PgAlarmRule pgAlarmRule = null; + PgDevice pgDevice = pgDeviceManager.getDeviceByAssetCode(assetCode); + if (pgDevice == null) + msg = "不存在设备信息"; + else { + try { + pgAlarmRule = pgAlarmRuleManager.getAlarmRuleBydev(pgDevice); + if (pgAlarmRule != null) { + result = "false"; + msg = "设备阈值已经存在"; + } else { + pgAlarmRule = new PgAlarmRule(); + pgAlarmRule.setHighValue(highValue); + pgAlarmRule.setLowValue(lowValue); + pgAlarmRule.setPgDeviceId(pgDevice); + + pgAlarmRuleManager.save(pgAlarmRule); + result = "true"; + msg = "报警阈值新增成功"; + } + + } catch (Exception e) { + e.printStackTrace(); + result = "false"; + msg = "报警阈值新增失败"; + } + } + resultMap.put("msg", msg); + resultMap.put("result", result); + return resultMap; + } + + /** + * 编辑报警阈值 + */ + @POST + @Path("editAlarmRule") + @Produces(MediaType.APPLICATION_JSON) + public Map editAlarmRule(@FormParam("id") String id, + @FormParam("assetCode") String assetCode, + @FormParam("highValue") String highValue, + @FormParam("lowValue") String lowValue) throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + String result = ""; + + PgAlarmRule pgAlarmRule = null; + PgDevice pgDevice = pgDeviceManager.getDeviceByAssetCode(assetCode); + if (pgDevice == null) { + msg = "不存在设备信息"; + result = "false"; + } else { + try { + pgAlarmRule = pgAlarmRuleManager.get(id); + if (pgAlarmRule == null) { + msg="不存在报警阈值记录"; + result="false"; + } else { + pgAlarmRule.setPgDeviceId(pgDevice); + pgAlarmRule.setHighValue(highValue); + pgAlarmRule.setLowValue(lowValue); + pgAlarmRuleManager.save(pgAlarmRule); + msg="编辑成功"; + result="true"; + } + } catch (Exception ex) { + ex.printStackTrace(); + result = "false"; + msg = "报警阈值编辑失败"; + } + } + resultMap.put("msg", msg); + resultMap.put("result", result); + + return resultMap; + + } + +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java b/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java index 36a4fc5..4f77754 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java @@ -18,7 +18,6 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; -import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -65,14 +64,14 @@ * 获取设备信息 */ @POST - @Path("getPgDeviceByName") + @Path("getPgDeviceByAssetCode") @Produces(MediaType.APPLICATION_JSON) - public Map getPgDeviceByName(@FormParam("devName") String devName) throws Exception { + public Map getPgDeviceByAssetCode(@FormParam("assetCode") String assetCode) throws Exception { Map resultMap = new HashMap(); String msg = ""; PgDeviceDto pgDeviceDto=null; try { - PgDevice pgDevice = pgDeviceManager.getDeviceBydevName(devName); + PgDevice pgDevice = pgDeviceManager.getDeviceByAssetCode(assetCode); pgDeviceDto=new PgDeviceDto(pgDevice); msg = "获取成功"; } catch (Exception e) { @@ -84,7 +83,6 @@ return resultMap; } - /** * 显示设备列表 */ @@ -116,42 +114,49 @@ @POST @Path("addDevice") @Produces(MediaType.APPLICATION_JSON) - public Map addDevice(@FormParam("devType") String devType, - @FormParam("devCode") String devCode, - @FormParam("devName") String devName, - @FormParam("brand") String brand, - @FormParam("ownerUnit") String ownerUnit, - @FormParam("installDate") String installDate, - @FormParam("pgName") String pgName, - @FormParam("parName") String parName) + public Map addDevice(@FormParam("parName") String parName, + @FormParam("pgName") String pgName, + @FormParam("road") String road, + @FormParam("position") String position, + @FormParam("devType") String devType, + @FormParam("devCode") String devCode, + @FormParam("assetName") String assetName, + @FormParam("assetCode") String assetCode, + @FormParam("assetBarCode") String assetBarCode, + @FormParam("ip") String ip, + @FormParam("modBus") String modBus, + @FormParam("mome") String mome) throws Exception { - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - Map resultMap = new HashMap(); String result = ""; String msg = ""; - PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName); - PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName, pipeGallery); + PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName); + PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName,pgPartition); + if (pgPartition == null) { result = "false"; msg = "不存在管廊仓和分区信息"; } else { try { - if (pgDeviceManager.getDeviceBydevName(devName)!=null) { + if (pgDeviceManager.getDeviceByAssetCode(assetCode)!=null) { result = "false"; msg = "已存在同名设备"; } else { PgDevice pgDevice = new PgDevice(); - pgDevice.setDevTypeId(pgDeviceTypeManager.getPgDeviceTypeByDevType(devType)); + pgDevice.setPipeGalleryId(pipeGallery); + pgDevice.setRoad(road); + pgDevice.setPosition(position); + pgDevice.setDevType(devType); pgDevice.setDevCode(devCode); - pgDevice.setDevName(devName); - pgDevice.setBrand(brand); - pgDevice.setOwnerUnit(ownerUnit); - pgDevice.setInstallDate(sdf.parse(installDate)); - pgDevice.setPgPartitionId(pgPartition); + pgDevice.setAssetName(assetName); + pgDevice.setAssetCode(assetCode); + pgDevice.setAssetBarCode(assetBarCode); + pgDevice.setIp(ip); + pgDevice.setModBus(modBus); + pgDevice.setMome(mome); pgDevice.setIsOpen(0); pgDevice.setActive(1); @@ -179,41 +184,49 @@ @Path("editDevice") @Produces(MediaType.APPLICATION_JSON) public Map editPartition(@FormParam("id") String id, + @FormParam("parName") String parName, + @FormParam("pgName") String pgName, + @FormParam("road") String road, + @FormParam("position") String position, @FormParam("devType") String devType, @FormParam("devCode") String devCode, - @FormParam("devName") String devName, - @FormParam("brand") String brand, - @FormParam("ownerUnit") String ownerUnit, - @FormParam("installDate") String installDate, - @FormParam("pgName") String pgName, - @FormParam("parName") String parName, + @FormParam("assetName") String assetName, + @FormParam("assetCode") String assetCode, + @FormParam("assetBarCode") String assetBarCode, + @FormParam("ip") String ip, + @FormParam("modBus") String modBus, + @FormParam("mome") String mome, @FormParam("isOpen") String isOpen) throws Exception { - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - Map resultMap = new HashMap(); String result = ""; String msg = ""; - PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName); - PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName, pipeGallery); + PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName); + PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName,pgPartition); + if (pgPartition == null) { result = "false"; msg = "不存在管廊仓和分区信息"; } else { try { - if (pgDeviceManager.getDeviceBydevName(devName)!=null) { + if (pgDeviceManager.getDeviceByAssetCode(assetCode)!=null) { result = "false"; msg = "已存在同名设备"; } else { PgDevice pgDevice = pgDeviceManager.get(Long.valueOf(id)); - pgDevice.setDevTypeId(pgDeviceTypeManager.getPgDeviceTypeByDevType(devType)); + pgDevice.setPipeGalleryId(pipeGallery); + pgDevice.setRoad(road); + pgDevice.setPosition(position); + pgDevice.setDevType(devType); pgDevice.setDevCode(devCode); - pgDevice.setDevName(devName); - pgDevice.setBrand(brand); - pgDevice.setOwnerUnit(ownerUnit); - pgDevice.setInstallDate(sdf.parse(installDate)); - pgDevice.setPgPartitionId(pgPartition); + pgDevice.setAssetName(assetName); + pgDevice.setAssetCode(assetCode); + pgDevice.setAssetBarCode(assetBarCode); + pgDevice.setIp(ip); + pgDevice.setModBus(modBus); + pgDevice.setMome(mome); + pgDevice.setActive(1); pgDevice.setIsOpen(Integer.valueOf(isOpen)); pgDeviceManager.save(pgDevice); diff --git a/src/main/java/com/casic/PgInterface/rs/PgLocationRs.java b/src/main/java/com/casic/PgInterface/rs/PgLocationRs.java new file mode 100644 index 0000000..e8daabc --- /dev/null +++ b/src/main/java/com/casic/PgInterface/rs/PgLocationRs.java @@ -0,0 +1,39 @@ +package com.casic.PgInterface.rs; + +import com.casic.PgInterface.devData.manager.PgLocationManager; +import com.casic.PgInterface.devTable.manager.PgDeviceManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import javax.ws.rs.Path; + +/** + * Created by yxw on 2017/12/11. + */ +@Component +@Path("location") +public class PgLocationRs { + + private static Logger logger = LoggerFactory.getLogger(PgLocationRs.class); + + private PgDeviceManager pgDeviceManager; + + private PgLocationManager pgLocationManager; + + @Resource + public void setPgDeviceManager(PgDeviceManager pgDeviceManager) { + this.pgDeviceManager = pgDeviceManager; + } + + @Resource + public void setPgLocationManager(PgLocationManager pgLocationManager) { + this.pgLocationManager = pgLocationManager; + } + + + + + +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java b/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java index 45fc210..8a42e7e 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java @@ -1,10 +1,8 @@ package com.casic.PgInterface.rs; import com.casic.PgInterface.devTable.domain.PgPartition; -import com.casic.PgInterface.devTable.domain.PipeGallery; import com.casic.PgInterface.devTable.dto.PgPartitionDto; import com.casic.PgInterface.devTable.manager.PgPartitionManager; -import com.casic.PgInterface.devTable.manager.PipeGalleryManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; @@ -29,8 +27,6 @@ private static Logger logger = LoggerFactory.getLogger(PgPartitionRs.class); - private PipeGalleryManager pipeGalleryManager; - private PgPartitionManager pgPartitionManager; @Resource @@ -38,38 +34,24 @@ this.pgPartitionManager = pgPartitionManager; } - @Resource - public void setPipeGalleryManager(PipeGalleryManager pipeGalleryManager) { - - this.pipeGalleryManager = pipeGalleryManager; - } - /** * 新增分区 */ @POST @Path("addPartition") @Produces(MediaType.APPLICATION_JSON) - public Map addAlarm(@FormParam("parName") String parName, - @FormParam("pgName") String pgName)throws Exception { + public Map addAlarm(@FormParam("parName") String parName)throws Exception { Map resultMap = new HashMap(); String result = ""; String msg = ""; try { - PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName); - - if (pipeGallery == null) { - result = "false"; - msg = "不存在" + pgName + "管廊仓"; - } else { - if (pgPartitionManager.getPartitionByParName(parName, pipeGallery) != null) { + if (pgPartitionManager.getPartitionByParName(parName) != null) { result = "false"; msg = "已存在相同分区"; } else { PgPartition pgPartition = new PgPartition(); pgPartition.setParName(parName); - pgPartition.setPipeGalleryId(pipeGallery); pgPartition.setActive(1); logger.info("成功保存"); @@ -77,7 +59,7 @@ result = "true"; msg = "保存成功"; } - } + } catch (Exception e) { result = "false"; msg = "保存失败"; @@ -89,37 +71,13 @@ return resultMap; } - /** - *获取管廊仓下的分区列表 - */ - @POST - @Path("getPartition") - @Produces(MediaType.APPLICATION_JSON) - public Map getPartitionList(@FormParam("pgName") String pgName)throws Exception { - Map resultMap = new HashMap(); - String msg=""; - List pgPartitionDtoList=new ArrayList(); - try { - pgPartitionDtoList=pgPartitionManager.getPartitionByPG(pgName); - if(pgPartitionDtoList.size()==0) - msg="没有分区信息"; - else - msg="分区信息获取成功"; - }catch(Exception e){ - e.printStackTrace(); - msg="分区信息获取失败"; - } - resultMap.put("msg",msg); - resultMap.put("result",pgPartitionDtoList); - return resultMap; - } + @POST @Path("editPartition") @Produces(MediaType.APPLICATION_JSON) public Map editPartition(@FormParam("id") String id, - @FormParam("parName") String parName, - @FormParam("pgName") String pgName) throws Exception { + @FormParam("parName") String parName) throws Exception { Map resultMap = new HashMap(); String result = ""; @@ -128,25 +86,20 @@ PgPartition partition = new PgPartition(); try { - PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName); - if (pipeGallery == null) { - result = "false"; - msg = "不存在该管廊信息"; - } else { - if (pgPartitionManager.getPartitionByParName(parName, pipeGallery) != null) { + + if (pgPartitionManager.getPartitionByParName(parName) != null) { result = "false"; msg = "已存在相同分区"; } else { PgPartition pgPartition = pgPartitionManager.get(Long.valueOf(id)); pgPartition.setParName(parName); - pgPartition.setPipeGalleryId(pipeGallery); pgPartition.setActive(1); pgPartitionManager.save(pgPartition); result = "true"; msg = "编辑成功"; } - } + } catch (Exception e) { result = "false"; msg = "编辑失败"; @@ -194,5 +147,49 @@ return resultMap; } + /** + * 获取分区信息 + */ + @POST + @Path("getPartitionList") + @Produces(MediaType.APPLICATION_JSON) + public Map getPartition() throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + List pgPartitionDtoList = new ArrayList(); + try { + pgPartitionDtoList = pgPartitionManager.getPgPartitionDtoList(); + msg = "获取成功"; + } catch (Exception e) { + msg = "获取失败"; + e.printStackTrace(); + } + resultMap.put("msg", msg); + resultMap.put("result", pgPartitionDtoList); + return resultMap; + } + + /** + * 获取分区信息 + */ + @POST + @Path("getPartitionListByRoad") + @Produces(MediaType.APPLICATION_JSON) + public Map getPartitionListByRoad(@FormParam("road") String road) throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + List pgPartitionDtoList = new ArrayList(); + try { + pgPartitionDtoList = pgPartitionManager.getPartitionByRoad(road); + msg = "获取成功"; + } catch (Exception e) { + msg = "获取失败"; + e.printStackTrace(); + } + resultMap.put("msg", msg); + resultMap.put("result", pgPartitionDtoList); + return resultMap; + } + } diff --git a/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java b/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java index 7593027..8cbdb0a 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java @@ -96,8 +96,8 @@ String result = ""; String msg = ""; - PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName); - PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName, pipeGallery); + PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName); + PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName,pgPartition); if (pgPartition == null) { result = "false"; msg = "不存在管廊仓和分区信息"; @@ -118,7 +118,7 @@ pgPipeLine.setLayerNum(layerNum); pgPipeLine.setEnterDate(sdf.parse(enterDate)); pgPipeLine.setDiameter(diameter); - pgPipeLine.setPgPartitionId(pgPartition); + pgPipeLine.setPipeGalleryId(pipeGallery); pgPipeLine.setActive(1); pgPipeLineManager.save(pgPipeLine); @@ -158,8 +158,8 @@ String result = ""; String msg = ""; - PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName); - PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName, pipeGallery); + PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName); + PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName,pgPartition); if (pgPartition == null) { result = "false"; msg = "不存在管廊仓和分区信息"; @@ -179,7 +179,7 @@ pgPipeLine.setEnterDate(sdf.parse(enterDate)); pgPipeLine.setLayerNum(layerNum); pgPipeLine.setDiameter(diameter); - pgPipeLine.setPgPartitionId(pgPartition); + pgPipeLine.setPipeGalleryId(pipeGallery); pgPipeLine.setActive(1); pgPipeLineManager.save(pgPipeLine); diff --git a/src/main/java/com/casic/PgInterface/rs/PgTextureRs.java b/src/main/java/com/casic/PgInterface/rs/PgTextureRs.java index 1557b38..5892127 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgTextureRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgTextureRs.java @@ -95,8 +95,10 @@ String msg = ""; PgTexture pgTexture = new PgTexture(); - PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName); - PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName, pipeGallery); + + PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName); + PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName,pgPartition); + if (pgPartition == null) { result = "false"; msg = "不存在管廊仓和分区信息"; @@ -113,7 +115,7 @@ pgTexture.setLayerNum(layerNum); pgTexture.setOwnerUnit(ownerUnit); pgTexture.setBuildDate(sdf.parse(buildDate)); - pgTexture.setPgPartitionId(pgPartition); + pgTexture.setPipeGalleryId(pipeGallery); pgTexture.setActive(1); pgTextureManager.save(pgTexture); @@ -154,8 +156,8 @@ String result = ""; String msg = ""; - PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName); - PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName, pipeGallery); + PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName); + PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName,pgPartition); if (pgPartition == null) { result = "false"; msg = "不存在管廊仓和分区信息"; @@ -173,6 +175,7 @@ pgTexture.setLayerNum(layerNum); pgTexture.setOwnerUnit(ownerUnit); pgTexture.setBuildDate(sdf.parse(buildDate)); + pgTexture.setPipeGalleryId(pipeGallery); pgTexture.setActive(1); pgTextureManager.save(pgTexture); diff --git a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java index 80625c7..d8f5e6b 100644 --- a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java +++ b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java @@ -43,9 +43,7 @@ this.intoTime = intoTime; } - @Column(name = "OUT_TIME") - public Date getOutTime() { return outTime; } diff --git a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java index a99981e..b1d63a4 100644 --- a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java +++ b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java @@ -1,11 +1,28 @@ package com.casic.PgInterface.devData.manager; +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.core.util.DateUtils; +import com.casic.PgInterface.core.util.StringUtils; +import com.casic.PgInterface.devData.domain.PgCo; +import com.casic.PgInterface.devData.domain.PgLocation; +import com.casic.PgInterface.devData.dto.PgCoDto; +import com.casic.PgInterface.devData.dto.PgLocationDto; +import com.casic.PgInterface.devTable.domain.PgDevice; +import org.hibernate.Criteria; +import org.hibernate.criterion.Order; +import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; + /** * Created by yxw on 2017/11/2. */ @Service -public class PgLocationManager { +public class PgLocationManager extends HibernateEntityDao { + + //获取设备时间段内所有的监测数据 } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java index cfa0281..7fb5953 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -1,12 +1,12 @@ package com.casic.PgInterface.devTable.domain; import com.casic.PgInterface.devData.domain.*; +import com.casic.PgInterface.patroler.domain.PgAlarmRule; import org.hibernate.annotations.NotFound; import org.hibernate.annotations.NotFoundAction; import javax.persistence.*; import java.io.Serializable; -import java.util.Date; import java.util.List; /** @@ -19,21 +19,27 @@ private static final long serialVersionUID = 1L; private long id; + private PipeGallery pipeGalleryId;//所在管廊信息 + private String road;//路名 + private String position;//设备位置 + private String devType;//设备类型 private String devCode;//设备编号 - private String devName;//设备名称 - private String brand;//品牌 - private String ownerUnit;//权属单位 - private Date installDate;//安装时间 + private String assetName;//资产名称 + private String assetCode;//资产编码 + private String assetBarCode;//资产条码 + private String ip;//IP地址 + private String modBus;//modBus地址 + private String mome;//备注 private int isOpen;//设备是否开启 private int active;//状态位 - private PgDeviceType devTypeId;//设备类型 + private List pgAlarms; - private PgPartition pgPartitionId;//所在管廊信息 private List pgTempHums;//温湿度 private List pgCos;//一氧化碳 private List pgO2s;//氧气 private List pgCh4s;//甲烷 private List pgShs;//硫化氢 + private List pgAlarmRules;//报警规则 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") @@ -45,6 +51,33 @@ this.id = id; } + @Column(name = "ROAD") + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + @Column(name = "POSITION") + public String getPosition() { + return position; + } + + public void setPosition(String position) { + this.position = position; + } + + @Column(name = "DEV_TYPE") + public String getDevType() { + return devType; + } + + public void setDevType(String devType) { + this.devType = devType; + } + @Column(name = "DEV_CODE") public String getDevCode() { return devCode; @@ -54,40 +87,58 @@ this.devCode = devCode; } - @Column(name = "DEV_NAME") - public String getDevName() { - return devName; + @Column(name = "ASSET_NAME") + public String getAssetName() { + return assetName; } - public void setDevName(String devName) { - this.devName = devName; + public void setAssetName(String assetName) { + this.assetName = assetName; } - @Column(name = "BRAND") - public String getBrand() { - return brand; + @Column(name = "ASSET_CODE") + public String getAssetCode() { + return assetCode; } - public void setBrand(String brand) { - this.brand = brand; + public void setAssetCode(String assetCode) { + this.assetCode = assetCode; } - @Column(name = "OWNERUNIT") - public String getOwnerUnit() { - return ownerUnit; + @Column(name = "ASSET_BAR_CODE") + public String getAssetBarCode() { + return assetBarCode; } - public void setOwnerUnit(String ownerUnit) { - this.ownerUnit = ownerUnit; + public void setAssetBarCode(String assetBarCode) { + this.assetBarCode = assetBarCode; } - @Column(name = "INSTALDATE") - public Date getInstallDate() { - return installDate; + @Column(name = "IP") + public String getIp() { + return ip; } - public void setInstallDate(Date installDate) { - this.installDate = installDate; + public void setIp(String ip) { + this.ip = ip; + } + + @Column(name = "MODBUS") + public String getModBus() { + return modBus; + } + + public void setModBus(String modBus) { + this.modBus = modBus; + } + + @Column(name = "MOME") + public String getMome() { + return mome; + } + + public void setMome(String mome) { + this.mome = mome; } @Column(name = "ISOPEN") @@ -119,24 +170,13 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; - } - - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "DEVICE_TYPE_ID") - public PgDeviceType getDevTypeId() { - return devTypeId; - } - - public void setDevTypeId(PgDeviceType devTypeId) { - this.devTypeId = devTypeId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgDeviceId") @@ -184,4 +224,13 @@ this.pgShs = pgShs; } + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgDeviceId") + public List getPgAlarmRules() { + return pgAlarmRules; + } + + public void setPgAlarmRules(List pgAlarmRules) { + this.pgAlarmRules = pgAlarmRules; + } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java index b997b29..4fb3d6f 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java @@ -1,8 +1,5 @@ package com.casic.PgInterface.devTable.domain; -import org.hibernate.annotations.NotFound; -import org.hibernate.annotations.NotFoundAction; - import javax.persistence.*; import java.io.Serializable; import java.util.List; @@ -19,11 +16,9 @@ private long id; private String parName;//分区名称 - private PipeGallery pipeGalleryId;//管廊仓 + private String road;//所属道路 private int active;//状态位 - private List pgTextureList; - private List pgPipeLineList; - private List pgDeviceList; + private List pipeGalleryList;//管廊仓 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PARTITION_ID") @@ -44,6 +39,15 @@ this.parName = parName; } + @Column(name = "ROAD") + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + @Column(name = "ACTIVE") public int getActive() { return active; @@ -53,41 +57,14 @@ this.active = active; } - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PIPEGALLERYID") - public PipeGallery getPipeGalleryId() { - return pipeGalleryId; - } - - public void setPipeGalleryId(PipeGallery pipeGalleryId) { - this.pipeGalleryId = pipeGalleryId; - } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgTextureList() { - return pgTextureList; + public List getPipeGalleryList() { + return pipeGalleryList; } - public void setPgTextureList(List pgTextureList) { - this.pgTextureList = pgTextureList; + public void setPipeGalleryList(List pipeGalleryList) { + this.pipeGalleryList = pipeGalleryList; } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgPipeLineList() { - return pgPipeLineList; - } - public void setPgPipeLineList(List pgPipeLineList) { - this.pgPipeLineList = pgPipeLineList; - } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgDeviceList() { - return pgDeviceList; - } - - public void setPgDeviceList(List pgDeviceList) { - this.pgDeviceList = pgDeviceList; - } } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java index d936d18..e5ff9b3 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java @@ -22,7 +22,7 @@ private Date enterDate;//入廊时间 private String layerNum;//所在层数 private String diameter;//管径 - private PgPartition pgPartitionId;//所在管廊信息 + private PipeGallery pipeGalleryId;//所在管廊信息 private int active;//状态位 @Id @@ -100,12 +100,12 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java index 1f22bf9..4ebfbda 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java @@ -21,7 +21,7 @@ private String ownerUnit;//权属单位 private Date buildDate;//建设年代 private int active;//状态位 - private PgPartition pgPartitionId;//所在管廊信息 + private PipeGallery pipeGalleryId;//所在管廊信息 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_TEXTURE_ID") @@ -91,12 +91,13 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java b/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java index 49a246c..650d623 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java @@ -1,5 +1,8 @@ package com.casic.PgInterface.devTable.domain; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + import javax.persistence.*; import java.io.Serializable; import java.util.List; @@ -16,7 +19,10 @@ private long id; private String pgName;//管廊名称 private int active;//状态位 - private List partitionList; + private PgPartition pgPartitionId;// + private List pgTextureList; + private List pgPipeLineList; + private List pgDeviceList; @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PIPE_GALLERY_ID") @@ -46,12 +52,42 @@ this.active = active; } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") - public List getPartitionList() { - return partitionList; + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "PARTITIONID") + public PgPartition getPgPartitionId() { + return pgPartitionId; } - public void setPartitionList(List partitionList) { - this.partitionList = partitionList; + public void setPgPartitionId(PgPartition pgPartitionId) { + this.pgPartitionId = pgPartitionId; } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgTextureList() { + return pgTextureList; + } + + public void setPgTextureList(List pgTextureList) { + this.pgTextureList = pgTextureList; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgPipeLineList() { + return pgPipeLineList; + } + + public void setPgPipeLineList(List pgPipeLineList) { + this.pgPipeLineList = pgPipeLineList; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgDeviceList() { + return pgDeviceList; + } + + public void setPgDeviceList(List pgDeviceList) { + this.pgDeviceList = pgDeviceList; + } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java index b4048d9..c3dfc55 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java @@ -101,18 +101,17 @@ this.active = active; } - public PgAlarmDto(PgAlarm pgAlarm) - { - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + public PgAlarmDto(PgAlarm pgAlarm) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); this.setId(String.valueOf(pgAlarm.getId())); this.setAlarmType(pgAlarm.getAlarmTypeId().getAlarmType()); this.setAlarmValue(pgAlarm.getAlarmValue()); this.setAlarmDate(sdf.format(pgAlarm.getAlarmDate())); this.setDescription(pgAlarm.getDescription()); - this.setAlarmDevName(pgAlarm.getAlarmDevId().getDevName()); - this.setAlarmLocation(pgAlarm.getAlarmDevId().getPgPartitionId().getPipeGalleryId().getPgName() - + pgAlarm.getAlarmDevId().getPgPartitionId().getParName()); + this.setAlarmDevName(pgAlarm.getAlarmDevId().getAssetName()); + this.setAlarmLocation(pgAlarm.getAlarmDevId().getPipeGalleryId().getPgPartitionId().getParName() + + pgAlarm.getAlarmDevId().getPipeGalleryId().getPgName()); this.setUserName(pgAlarm.getPatrolerId().getUserName()); this.setPhoneNumber(pgAlarm.getPatrolerId().getPhoneNumber()); this.setActive(String.valueOf(pgAlarm.getActive())); diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java index ae76e95..49bd436 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java @@ -11,16 +11,20 @@ public class PgDeviceDto implements Serializable { private String id; - private String devType;//设备类型 - private String devCode;//设备编号 - private String devName;//设备名称 - private String brand;//品牌 - private String ownerUnit;//权属单位 - private String installDate;//安装时间 - private String isOpen;//设备开启状态 - private String active;//状态位 private String pipeGallery;//仓位 private String partition;//分区 + private String road;//路名 + private String position;//设备位置 + private String devType;//设备类型 + private String devCode;//设备编号 + private String assetName;//资产名称 + private String assetCode;//资产名称 + private String assetBarCode;//资产条码 + private String ip;//IP地址 + private String modBus;//modBus地址 + private String mome;//备注 + private String isOpen;//设备开启状态 + private String active;//状态位 public String getId() { return id; @@ -30,6 +34,38 @@ this.id = id; } + public String getPartition() { + return partition; + } + + public void setPartition(String partition) { + this.partition = partition; + } + + public String getPipeGallery() { + return pipeGallery; + } + + public void setPipeGallery(String pipeGallery) { + this.pipeGallery = pipeGallery; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getPosition() { + return position; + } + + public void setPosition(String position) { + this.position = position; + } + public String getDevType() { return devType; } @@ -46,36 +82,52 @@ this.devCode = devCode; } - public String getDevName() { - return devName; + public String getAssetName() { + return assetName; } - public void setDevName(String devName) { - this.devName = devName; + public void setAssetName(String assetName) { + this.assetName = assetName; } - public String getBrand() { - return brand; + public String getAssetCode() { + return assetCode; } - public void setBrand(String brand) { - this.brand = brand; + public void setAssetCode(String assetCode) { + this.assetCode = assetCode; } - public String getOwnerUnit() { - return ownerUnit; + public String getAssetBarCode() { + return assetBarCode; } - public void setOwnerUnit(String ownerUnit) { - this.ownerUnit = ownerUnit; + public void setAssetBarCode(String assetBarCode) { + this.assetBarCode = assetBarCode; } - public String getInstallDate() { - return installDate; + public String getIp() { + return ip; } - public void setInstallDate(String installDate) { - this.installDate = installDate; + public void setIp(String ip) { + this.ip = ip; + } + + public String getModBus() { + return modBus; + } + + public void setModBus(String modBus) { + this.modBus = modBus; + } + + public String getMome() { + return mome; + } + + public void setMome(String mome) { + this.mome = mome; } public String getIsOpen() { @@ -94,39 +146,26 @@ this.active = active; } - public String getPipeGallery() { - return pipeGallery; - } - - public void setPipeGallery(String pipeGallery) { - this.pipeGallery = pipeGallery; - } - - public String getPartition() { - return partition; - } - - public void setPartition(String partition) { - this.partition = partition; - } - public PgDeviceDto(PgDevice pgDevice) { SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); this.setId(String.valueOf(pgDevice.getId())); - this.setDevType(pgDevice.getDevTypeId().getDevType()); + this.setPipeGallery(pgDevice.getPipeGalleryId().getPgName()); + this.setPartition(pgDevice.getPipeGalleryId().getPgPartitionId().getParName()); + this.setRoad(pgDevice.getRoad()); + this.setPosition(pgDevice.getPosition()); + this.setDevType(pgDevice.getDevType()); this.setDevCode(pgDevice.getDevCode()); - this.setDevName(pgDevice.getDevName()); - this.setBrand(pgDevice.getBrand()); - this.setOwnerUnit(pgDevice.getOwnerUnit()); - this.setInstallDate(sdf.format(pgDevice.getInstallDate())); + this.setAssetName(pgDevice.getAssetName()); + this.setAssetCode(pgDevice.getAssetCode()); + this.setAssetBarCode(pgDevice.getAssetBarCode()); + this.setId(pgDevice.getIp()); + this.setModBus(pgDevice.getModBus()); + this.setMome(pgDevice.getMome()); this.setIsOpen(String.valueOf(pgDevice.getIsOpen())); this.setActive(String.valueOf(pgDevice.getActive())); - this.setPipeGallery(pgDevice.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgDevice.getPgPartitionId().getParName()); + } - -} - +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java index e8751d3..3acd0fa 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java @@ -11,7 +11,7 @@ private String id; private String parName;//分区名称 - private String pipeGallery;//管廊仓 + private String road;//所属道路 private String active;//状态位 @@ -31,14 +31,6 @@ this.parName = parName; } - public String getPipeGallery() { - return pipeGallery; - } - - public void setPipeGallery(String pipeGallery) { - this.pipeGallery = pipeGallery; - } - public String getActive() { return active; } @@ -47,11 +39,19 @@ this.active = active; } + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + public PgPartitionDto(PgPartition pgPartition) { this.setId(String.valueOf(pgPartition.getId())); this.setParName(pgPartition.getParName()); - this.setPipeGallery(pgPartition.getPipeGalleryId().getPgName()); + this.setRoad(pgPartition.getRoad()); this.setActive(String.valueOf(pgPartition.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java index 9b161bf..8b430dc 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java @@ -112,8 +112,8 @@ this.setEnterDate(sdf.format(pgPipeLine.getEnterDate())); this.setLayerNum(pgPipeLine.getLayerNum()); this.setDiameter(pgPipeLine.getDiameter()); - this.setPipeGallery(pgPipeLine.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgPipeLine.getPgPartitionId().getParName()); + this.setPipeGallery(pgPipeLine.getPipeGalleryId().getPgName()); + this.setPartition(pgPipeLine.getPipeGalleryId().getPgPartitionId().getParName()); this.setActive(String.valueOf(pgPipeLine.getActive())); } } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java index 03c580c..709dcea 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java @@ -103,8 +103,8 @@ this.setOwnerUnit(pgTexture.getOwnerUnit()); this.setBuildDate(sdf.format(pgTexture.getBuildDate())); this.setActive(String.valueOf(pgTexture.getActive())); - this.setPipeGallery(pgTexture.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgTexture.getPgPartitionId().getParName()); + this.setPipeGallery(pgTexture.getPipeGalleryId().getPgName()); + this.setPartition(pgTexture.getPipeGalleryId().getPgPartitionId().getParName()); } } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java index b40ce84..319cf21 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java @@ -11,6 +11,7 @@ private String id; private String pgName;//管廊名称 + private String pgPartition;//分区名称 private String active;//状态位 public String getId() { @@ -37,10 +38,19 @@ this.active = active; } + public String getPgPartition() { + return pgPartition; + } + + public void setPgPartition(String pgPartition) { + this.pgPartition = pgPartition; + } + public PipeGalleryDto(PipeGallery pipeGallery) { this.setId(String.valueOf(pipeGallery.getId())); this.setPgName(pipeGallery.getPgName()); + this.setPgPartition(pipeGallery.getPgPartitionId().getParName()); this.setActive(String.valueOf(pipeGallery.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java b/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java index 8b413e7..0c594e7 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java @@ -5,10 +5,10 @@ import com.casic.PgInterface.devTable.domain.PipeGallery; import com.casic.PgInterface.devTable.dto.PgPartitionDto; import org.hibernate.Criteria; +import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; -import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; @@ -18,44 +18,50 @@ @Service public class PgPartitionManager extends HibernateEntityDao { - private PipeGalleryManager pipeGalleryManager; - - @Resource - public void setPipeGalleryManager(PipeGalleryManager pipeGalleryManager) { - this.pipeGalleryManager = pipeGalleryManager; - } - - public PgPartition getPartitionByParName(String parName,PipeGallery pipeGallery) { - if(pipeGallery==null) - return null; - Criteria criteria = getSession().createCriteria(PgPartition.class); + public PgPartition getPartitionByParName(String parName) { + Criteria criteria = getSession().createCriteria(PipeGallery.class); criteria.add(Restrictions.eq("parName", parName)); - criteria.add(Restrictions.eq("pipeGalleryId",pipeGallery)); + criteria.add(Restrictions.eq("active",1)); List pgPartitionList = criteria.list(); - //TODO LIST:为空判断 pgPartitionList==null? if (pgPartitionList != null && pgPartitionList.size() > 0) return pgPartitionList.get(0); else return null; } - public List getPartitionByPG(String pgName){ - PipeGallery pipeGallery=pipeGalleryManager.getPipeGalleryByPgName(pgName); - - Criteria criteria=getSession().createCriteria(PgPartition.class); - criteria.add(Restrictions.eq("pipeGalleryId",pipeGallery)); + public List getPartitionByRoad(String road) { + Criteria criteria = getSession().createCriteria(PipeGallery.class); + criteria.add(Restrictions.eq("road", road)); + criteria.add(Restrictions.eq("active",1)); List pgPartitionList = criteria.list(); List pgPartitionDtoList=new ArrayList(); - for(PgPartition pgPartition:pgPartitionList) - { - pgPartitionDtoList.add(new PgPartitionDto(pgPartition)); - } + for(PgPartition pgPartition:pgPartitionList) { + pgPartitionDtoList.add(new PgPartitionDto(pgPartition)); + } return pgPartitionDtoList; } + public List getPgPartitionDtoList() + { + Criteria criteria=getSession().createCriteria(PgPartition.class); + criteria.add(Restrictions.eq("active",1)); + criteria.addOrder(Order.desc("id")); + + List pgPartitionList=criteria.list(); + if(pgPartitionList.size()==0||pgPartitionList==null) + return null; + List pgPartitionDtoList=new ArrayList(); + for(PgPartition pgPartition:pgPartitionList) { + pgPartitionDtoList.add(new PgPartitionDto(pgPartition)); + } + return pgPartitionDtoList; + } + + + } diff --git a/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java b/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java index 16370c6..9bce32b 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java @@ -1,14 +1,16 @@ package com.casic.PgInterface.devTable.manager; import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.devTable.domain.PgPartition; import com.casic.PgInterface.devTable.domain.PipeGallery; import com.casic.PgInterface.devTable.dto.PipeGalleryDto; import org.hibernate.Criteria; -import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; -import java.util.*; +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; /** * Created by yxw on 2017/11/4. @@ -16,36 +18,44 @@ @Service public class PipeGalleryManager extends HibernateEntityDao { - public PipeGallery getPipeGalleryByPgName(String pgName) { - Criteria criteria = getSession().createCriteria(PipeGallery.class); + private PgPartitionManager pgPartitionManager; + + @Resource + public void setPgPartitionManager(PgPartitionManager pgPartitionManager) { + this.pgPartitionManager = pgPartitionManager; + } + + public PipeGallery getPipeGalleryByPgName(String pgName,PgPartition pgPartition) { + if(pgPartition==null) + return null; + Criteria criteria = getSession().createCriteria(PgPartition.class); criteria.add(Restrictions.eq("pgName", pgName)); - criteria.add(Restrictions.eq("active",1)); + criteria.add(Restrictions.eq("pgPartitionId",pgPartition)); List pipeGalleryList = criteria.list(); - //TODO LIST:为空判断 pipeGalleryList==null? + //TODO LIST:为空判断 pgPartitionList==null? if (pipeGalleryList != null && pipeGalleryList.size() > 0) return pipeGalleryList.get(0); else return null; } - public List getPIpeGalleryDtoList() - { - Criteria criteria=getSession().createCriteria(PipeGallery.class); - criteria.add(Restrictions.eq("active",1)); - criteria.addOrder(Order.desc("id")); - List pipeGalleryList=criteria.list(); - if(pipeGalleryList.size()==0||pipeGalleryList==null) - return null; - List pipeGalleryDtoList=new ArrayList(); - for(PipeGallery pipeGallery:pipeGalleryList) { + public List getPipeGalleryByParName(String parName) { + + PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName); + Criteria criteria = getSession().createCriteria(PipeGallery.class); + criteria.add(Restrictions.eq("pgPartitionId", pgPartition)); + + List pipeGalleryList = criteria.list(); + + List pipeGalleryDtoList = new ArrayList(); + for (PipeGallery pipeGallery : pipeGalleryList) { pipeGalleryDtoList.add(new PipeGalleryDto(pipeGallery)); } + return pipeGalleryDtoList; } - - } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java new file mode 100644 index 0000000..9d06235 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java @@ -0,0 +1,63 @@ +package com.casic.PgInterface.patroler.domain; + +import com.casic.PgInterface.devTable.domain.PgDevice; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + +import javax.persistence.*; +import java.io.Serializable; + +/** + * Created by yxw on 2017/12/14. + */ +@Entity +@Table(name = "PG_ALARM_RULE") +@SequenceGenerator(name = "SEQ_PG_ALARM_RULE_ID", sequenceName = "SEQ_PG_ALARM_RULE_ID",allocationSize=1,initialValue=1) +public class PgAlarmRule implements Serializable { + + private static final long serialVersionUID = 1L; + private long id; + private String highValue;//高限 + private String lowValue;//低限 + private PgDevice pgDeviceId;//设备 + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_ALARM_RULE_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "HIGHVALUE") + public String getHighValue() { + return highValue; + } + + public void setHighValue(String highValue) { + this.highValue = highValue; + } + + @Column(name = "LOWVALUE") + public String getLowValue() { + return lowValue; + } + + public void setLowValue(String lowValue) { + this.lowValue = lowValue; + } + + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "PGDEVICEID") + public PgDevice getPgDeviceId() { + return pgDeviceId; + } + + public void setPgDeviceId(PgDevice pgDeviceId) { + this.pgDeviceId = pgDeviceId; + } + +} diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java new file mode 100644 index 0000000..8367ad4 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java @@ -0,0 +1,57 @@ +package com.casic.PgInterface.patroler.dto; + +import com.casic.PgInterface.patroler.domain.PgAlarmRule; + +import java.io.Serializable; + +/** + * Created by yxw on 2017/12/14. + */ +public class PgAlarmRuleDto implements Serializable { + + private String id; + private String highValue;//高限 + private String lowValue;//低限 + private String devName;//设备 + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getHighValue() { + return highValue; + } + + public void setHighValue(String highValue) { + this.highValue = highValue; + } + + public String getLowValue() { + return lowValue; + } + + public void setLowValue(String lowValue) { + this.lowValue = lowValue; + } + + public String getDevName() { + return devName; + } + + public void setDevName(String devName) { + this.devName = devName; + } + + public PgAlarmRuleDto(PgAlarmRule pgAlarmRule) + { + this.setId(String.valueOf(pgAlarmRule.getId())); + this.setDevName(pgAlarmRule.getPgDeviceId().getAssetName()); + this.setHighValue(pgAlarmRule.getHighValue()); + this.setLowValue(pgAlarmRule.getLowValue()); + } + +} diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java new file mode 100644 index 0000000..d5c00b2 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java @@ -0,0 +1,42 @@ +package com.casic.PgInterface.patroler.manager; + +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.devTable.domain.PgDevice; +import com.casic.PgInterface.patroler.domain.PgAlarmRule; +import com.casic.PgInterface.patroler.dto.PgAlarmRuleDto; +import org.hibernate.Criteria; +import org.hibernate.criterion.Restrictions; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * Created by yxw on 2017/12/14. + */ +@Service +public class PgAlarmRuleManager extends HibernateEntityDao { + + //根据设备获取设备报警阈值 + public PgAlarmRuleDto getAlarmRuleDtoBydev(PgDevice pgDeviceId) { + Criteria criteria=createCriteria(PgAlarmRule.class); + criteria.add(Restrictions.eq("pgDeviceId", pgDeviceId)); + + List pgAlarmRuleList=criteria.list(); + if(pgAlarmRuleList.size()==0) + return null; + else + return new PgAlarmRuleDto(pgAlarmRuleList.get(0)); + } + + public PgAlarmRule getAlarmRuleBydev(PgDevice pgDeviceId) { + Criteria criteria=createCriteria(PgAlarmRule.class); + criteria.add(Restrictions.eq("pgDeviceId", pgDeviceId)); + + List pgAlarmRuleList=criteria.list(); + if(pgAlarmRuleList.size()==0) + return null; + else + return pgAlarmRuleList.get(0); + } + +} diff --git a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java new file mode 100644 index 0000000..88255c6 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java @@ -0,0 +1,162 @@ +package com.casic.PgInterface.rs; + +import com.casic.PgInterface.devTable.domain.PgDevice; +import com.casic.PgInterface.devTable.manager.PgDeviceManager; +import com.casic.PgInterface.patroler.domain.PgAlarmRule; +import com.casic.PgInterface.patroler.dto.PgAlarmRuleDto; +import com.casic.PgInterface.patroler.manager.PgAlarmRuleManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import javax.ws.rs.FormParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import java.util.HashMap; +import java.util.Map; + +/** + * Created by yxw on 2017/12/14. + */ +@Component +@Path("pgAlarmRule") +public class PgAlarmRuleRs { + + private static Logger logger = LoggerFactory.getLogger(PgAlarmRule.class); + + private PgDeviceManager pgDeviceManager; + + private PgAlarmRuleManager pgAlarmRuleManager; + + @Resource + public void setPgAlarmRuleManager(PgAlarmRuleManager pgAlarmRuleManager) { + this.pgAlarmRuleManager = pgAlarmRuleManager; + } + + @Resource + public void setPgDeviceManager(PgDeviceManager pgDeviceManager) { + this.pgDeviceManager = pgDeviceManager; + } + + /** + * 获取报警阈值信息 + */ + @POST + @Path("getAlarmRuleByAssetCode") + @Produces(MediaType.APPLICATION_JSON) + public Map getAlarmRuleByAssetCode(@FormParam("assetCode") String assetCode) throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + + PgAlarmRuleDto pgAlarmRuleDto = null; + PgDevice pgDevice = pgDeviceManager.getDeviceByAssetCode(assetCode); + try { + pgAlarmRuleDto = pgAlarmRuleManager.getAlarmRuleDtoBydev(pgDevice); + if (pgAlarmRuleDto == null) + msg = "不存在报警阈值信息"; + else + msg = "报警阈值获取成功"; + } catch (Exception e) { + e.printStackTrace(); + msg = "报警信息获取失败"; + } + resultMap.put("msg", msg); + resultMap.put("result", pgAlarmRuleDto); + return resultMap; + } + + /** + * 新增报警阈值 + */ + @POST + @Path("addAlarmRule") + @Produces(MediaType.APPLICATION_JSON) + public Map addAlarmRule(@FormParam("assetCode") String assetCode, + @FormParam("highValue") String highValue, + @FormParam("lowValue") String lowValue) throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + String result = ""; + + PgAlarmRule pgAlarmRule = null; + PgDevice pgDevice = pgDeviceManager.getDeviceByAssetCode(assetCode); + if (pgDevice == null) + msg = "不存在设备信息"; + else { + try { + pgAlarmRule = pgAlarmRuleManager.getAlarmRuleBydev(pgDevice); + if (pgAlarmRule != null) { + result = "false"; + msg = "设备阈值已经存在"; + } else { + pgAlarmRule = new PgAlarmRule(); + pgAlarmRule.setHighValue(highValue); + pgAlarmRule.setLowValue(lowValue); + pgAlarmRule.setPgDeviceId(pgDevice); + + pgAlarmRuleManager.save(pgAlarmRule); + result = "true"; + msg = "报警阈值新增成功"; + } + + } catch (Exception e) { + e.printStackTrace(); + result = "false"; + msg = "报警阈值新增失败"; + } + } + resultMap.put("msg", msg); + resultMap.put("result", result); + return resultMap; + } + + /** + * 编辑报警阈值 + */ + @POST + @Path("editAlarmRule") + @Produces(MediaType.APPLICATION_JSON) + public Map editAlarmRule(@FormParam("id") String id, + @FormParam("assetCode") String assetCode, + @FormParam("highValue") String highValue, + @FormParam("lowValue") String lowValue) throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + String result = ""; + + PgAlarmRule pgAlarmRule = null; + PgDevice pgDevice = pgDeviceManager.getDeviceByAssetCode(assetCode); + if (pgDevice == null) { + msg = "不存在设备信息"; + result = "false"; + } else { + try { + pgAlarmRule = pgAlarmRuleManager.get(id); + if (pgAlarmRule == null) { + msg="不存在报警阈值记录"; + result="false"; + } else { + pgAlarmRule.setPgDeviceId(pgDevice); + pgAlarmRule.setHighValue(highValue); + pgAlarmRule.setLowValue(lowValue); + pgAlarmRuleManager.save(pgAlarmRule); + msg="编辑成功"; + result="true"; + } + } catch (Exception ex) { + ex.printStackTrace(); + result = "false"; + msg = "报警阈值编辑失败"; + } + } + resultMap.put("msg", msg); + resultMap.put("result", result); + + return resultMap; + + } + +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java b/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java index 36a4fc5..4f77754 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java @@ -18,7 +18,6 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; -import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -65,14 +64,14 @@ * 获取设备信息 */ @POST - @Path("getPgDeviceByName") + @Path("getPgDeviceByAssetCode") @Produces(MediaType.APPLICATION_JSON) - public Map getPgDeviceByName(@FormParam("devName") String devName) throws Exception { + public Map getPgDeviceByAssetCode(@FormParam("assetCode") String assetCode) throws Exception { Map resultMap = new HashMap(); String msg = ""; PgDeviceDto pgDeviceDto=null; try { - PgDevice pgDevice = pgDeviceManager.getDeviceBydevName(devName); + PgDevice pgDevice = pgDeviceManager.getDeviceByAssetCode(assetCode); pgDeviceDto=new PgDeviceDto(pgDevice); msg = "获取成功"; } catch (Exception e) { @@ -84,7 +83,6 @@ return resultMap; } - /** * 显示设备列表 */ @@ -116,42 +114,49 @@ @POST @Path("addDevice") @Produces(MediaType.APPLICATION_JSON) - public Map addDevice(@FormParam("devType") String devType, - @FormParam("devCode") String devCode, - @FormParam("devName") String devName, - @FormParam("brand") String brand, - @FormParam("ownerUnit") String ownerUnit, - @FormParam("installDate") String installDate, - @FormParam("pgName") String pgName, - @FormParam("parName") String parName) + public Map addDevice(@FormParam("parName") String parName, + @FormParam("pgName") String pgName, + @FormParam("road") String road, + @FormParam("position") String position, + @FormParam("devType") String devType, + @FormParam("devCode") String devCode, + @FormParam("assetName") String assetName, + @FormParam("assetCode") String assetCode, + @FormParam("assetBarCode") String assetBarCode, + @FormParam("ip") String ip, + @FormParam("modBus") String modBus, + @FormParam("mome") String mome) throws Exception { - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - Map resultMap = new HashMap(); String result = ""; String msg = ""; - PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName); - PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName, pipeGallery); + PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName); + PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName,pgPartition); + if (pgPartition == null) { result = "false"; msg = "不存在管廊仓和分区信息"; } else { try { - if (pgDeviceManager.getDeviceBydevName(devName)!=null) { + if (pgDeviceManager.getDeviceByAssetCode(assetCode)!=null) { result = "false"; msg = "已存在同名设备"; } else { PgDevice pgDevice = new PgDevice(); - pgDevice.setDevTypeId(pgDeviceTypeManager.getPgDeviceTypeByDevType(devType)); + pgDevice.setPipeGalleryId(pipeGallery); + pgDevice.setRoad(road); + pgDevice.setPosition(position); + pgDevice.setDevType(devType); pgDevice.setDevCode(devCode); - pgDevice.setDevName(devName); - pgDevice.setBrand(brand); - pgDevice.setOwnerUnit(ownerUnit); - pgDevice.setInstallDate(sdf.parse(installDate)); - pgDevice.setPgPartitionId(pgPartition); + pgDevice.setAssetName(assetName); + pgDevice.setAssetCode(assetCode); + pgDevice.setAssetBarCode(assetBarCode); + pgDevice.setIp(ip); + pgDevice.setModBus(modBus); + pgDevice.setMome(mome); pgDevice.setIsOpen(0); pgDevice.setActive(1); @@ -179,41 +184,49 @@ @Path("editDevice") @Produces(MediaType.APPLICATION_JSON) public Map editPartition(@FormParam("id") String id, + @FormParam("parName") String parName, + @FormParam("pgName") String pgName, + @FormParam("road") String road, + @FormParam("position") String position, @FormParam("devType") String devType, @FormParam("devCode") String devCode, - @FormParam("devName") String devName, - @FormParam("brand") String brand, - @FormParam("ownerUnit") String ownerUnit, - @FormParam("installDate") String installDate, - @FormParam("pgName") String pgName, - @FormParam("parName") String parName, + @FormParam("assetName") String assetName, + @FormParam("assetCode") String assetCode, + @FormParam("assetBarCode") String assetBarCode, + @FormParam("ip") String ip, + @FormParam("modBus") String modBus, + @FormParam("mome") String mome, @FormParam("isOpen") String isOpen) throws Exception { - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - Map resultMap = new HashMap(); String result = ""; String msg = ""; - PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName); - PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName, pipeGallery); + PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName); + PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName,pgPartition); + if (pgPartition == null) { result = "false"; msg = "不存在管廊仓和分区信息"; } else { try { - if (pgDeviceManager.getDeviceBydevName(devName)!=null) { + if (pgDeviceManager.getDeviceByAssetCode(assetCode)!=null) { result = "false"; msg = "已存在同名设备"; } else { PgDevice pgDevice = pgDeviceManager.get(Long.valueOf(id)); - pgDevice.setDevTypeId(pgDeviceTypeManager.getPgDeviceTypeByDevType(devType)); + pgDevice.setPipeGalleryId(pipeGallery); + pgDevice.setRoad(road); + pgDevice.setPosition(position); + pgDevice.setDevType(devType); pgDevice.setDevCode(devCode); - pgDevice.setDevName(devName); - pgDevice.setBrand(brand); - pgDevice.setOwnerUnit(ownerUnit); - pgDevice.setInstallDate(sdf.parse(installDate)); - pgDevice.setPgPartitionId(pgPartition); + pgDevice.setAssetName(assetName); + pgDevice.setAssetCode(assetCode); + pgDevice.setAssetBarCode(assetBarCode); + pgDevice.setIp(ip); + pgDevice.setModBus(modBus); + pgDevice.setMome(mome); + pgDevice.setActive(1); pgDevice.setIsOpen(Integer.valueOf(isOpen)); pgDeviceManager.save(pgDevice); diff --git a/src/main/java/com/casic/PgInterface/rs/PgLocationRs.java b/src/main/java/com/casic/PgInterface/rs/PgLocationRs.java new file mode 100644 index 0000000..e8daabc --- /dev/null +++ b/src/main/java/com/casic/PgInterface/rs/PgLocationRs.java @@ -0,0 +1,39 @@ +package com.casic.PgInterface.rs; + +import com.casic.PgInterface.devData.manager.PgLocationManager; +import com.casic.PgInterface.devTable.manager.PgDeviceManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import javax.ws.rs.Path; + +/** + * Created by yxw on 2017/12/11. + */ +@Component +@Path("location") +public class PgLocationRs { + + private static Logger logger = LoggerFactory.getLogger(PgLocationRs.class); + + private PgDeviceManager pgDeviceManager; + + private PgLocationManager pgLocationManager; + + @Resource + public void setPgDeviceManager(PgDeviceManager pgDeviceManager) { + this.pgDeviceManager = pgDeviceManager; + } + + @Resource + public void setPgLocationManager(PgLocationManager pgLocationManager) { + this.pgLocationManager = pgLocationManager; + } + + + + + +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java b/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java index 45fc210..8a42e7e 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java @@ -1,10 +1,8 @@ package com.casic.PgInterface.rs; import com.casic.PgInterface.devTable.domain.PgPartition; -import com.casic.PgInterface.devTable.domain.PipeGallery; import com.casic.PgInterface.devTable.dto.PgPartitionDto; import com.casic.PgInterface.devTable.manager.PgPartitionManager; -import com.casic.PgInterface.devTable.manager.PipeGalleryManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; @@ -29,8 +27,6 @@ private static Logger logger = LoggerFactory.getLogger(PgPartitionRs.class); - private PipeGalleryManager pipeGalleryManager; - private PgPartitionManager pgPartitionManager; @Resource @@ -38,38 +34,24 @@ this.pgPartitionManager = pgPartitionManager; } - @Resource - public void setPipeGalleryManager(PipeGalleryManager pipeGalleryManager) { - - this.pipeGalleryManager = pipeGalleryManager; - } - /** * 新增分区 */ @POST @Path("addPartition") @Produces(MediaType.APPLICATION_JSON) - public Map addAlarm(@FormParam("parName") String parName, - @FormParam("pgName") String pgName)throws Exception { + public Map addAlarm(@FormParam("parName") String parName)throws Exception { Map resultMap = new HashMap(); String result = ""; String msg = ""; try { - PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName); - - if (pipeGallery == null) { - result = "false"; - msg = "不存在" + pgName + "管廊仓"; - } else { - if (pgPartitionManager.getPartitionByParName(parName, pipeGallery) != null) { + if (pgPartitionManager.getPartitionByParName(parName) != null) { result = "false"; msg = "已存在相同分区"; } else { PgPartition pgPartition = new PgPartition(); pgPartition.setParName(parName); - pgPartition.setPipeGalleryId(pipeGallery); pgPartition.setActive(1); logger.info("成功保存"); @@ -77,7 +59,7 @@ result = "true"; msg = "保存成功"; } - } + } catch (Exception e) { result = "false"; msg = "保存失败"; @@ -89,37 +71,13 @@ return resultMap; } - /** - *获取管廊仓下的分区列表 - */ - @POST - @Path("getPartition") - @Produces(MediaType.APPLICATION_JSON) - public Map getPartitionList(@FormParam("pgName") String pgName)throws Exception { - Map resultMap = new HashMap(); - String msg=""; - List pgPartitionDtoList=new ArrayList(); - try { - pgPartitionDtoList=pgPartitionManager.getPartitionByPG(pgName); - if(pgPartitionDtoList.size()==0) - msg="没有分区信息"; - else - msg="分区信息获取成功"; - }catch(Exception e){ - e.printStackTrace(); - msg="分区信息获取失败"; - } - resultMap.put("msg",msg); - resultMap.put("result",pgPartitionDtoList); - return resultMap; - } + @POST @Path("editPartition") @Produces(MediaType.APPLICATION_JSON) public Map editPartition(@FormParam("id") String id, - @FormParam("parName") String parName, - @FormParam("pgName") String pgName) throws Exception { + @FormParam("parName") String parName) throws Exception { Map resultMap = new HashMap(); String result = ""; @@ -128,25 +86,20 @@ PgPartition partition = new PgPartition(); try { - PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName); - if (pipeGallery == null) { - result = "false"; - msg = "不存在该管廊信息"; - } else { - if (pgPartitionManager.getPartitionByParName(parName, pipeGallery) != null) { + + if (pgPartitionManager.getPartitionByParName(parName) != null) { result = "false"; msg = "已存在相同分区"; } else { PgPartition pgPartition = pgPartitionManager.get(Long.valueOf(id)); pgPartition.setParName(parName); - pgPartition.setPipeGalleryId(pipeGallery); pgPartition.setActive(1); pgPartitionManager.save(pgPartition); result = "true"; msg = "编辑成功"; } - } + } catch (Exception e) { result = "false"; msg = "编辑失败"; @@ -194,5 +147,49 @@ return resultMap; } + /** + * 获取分区信息 + */ + @POST + @Path("getPartitionList") + @Produces(MediaType.APPLICATION_JSON) + public Map getPartition() throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + List pgPartitionDtoList = new ArrayList(); + try { + pgPartitionDtoList = pgPartitionManager.getPgPartitionDtoList(); + msg = "获取成功"; + } catch (Exception e) { + msg = "获取失败"; + e.printStackTrace(); + } + resultMap.put("msg", msg); + resultMap.put("result", pgPartitionDtoList); + return resultMap; + } + + /** + * 获取分区信息 + */ + @POST + @Path("getPartitionListByRoad") + @Produces(MediaType.APPLICATION_JSON) + public Map getPartitionListByRoad(@FormParam("road") String road) throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + List pgPartitionDtoList = new ArrayList(); + try { + pgPartitionDtoList = pgPartitionManager.getPartitionByRoad(road); + msg = "获取成功"; + } catch (Exception e) { + msg = "获取失败"; + e.printStackTrace(); + } + resultMap.put("msg", msg); + resultMap.put("result", pgPartitionDtoList); + return resultMap; + } + } diff --git a/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java b/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java index 7593027..8cbdb0a 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java @@ -96,8 +96,8 @@ String result = ""; String msg = ""; - PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName); - PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName, pipeGallery); + PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName); + PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName,pgPartition); if (pgPartition == null) { result = "false"; msg = "不存在管廊仓和分区信息"; @@ -118,7 +118,7 @@ pgPipeLine.setLayerNum(layerNum); pgPipeLine.setEnterDate(sdf.parse(enterDate)); pgPipeLine.setDiameter(diameter); - pgPipeLine.setPgPartitionId(pgPartition); + pgPipeLine.setPipeGalleryId(pipeGallery); pgPipeLine.setActive(1); pgPipeLineManager.save(pgPipeLine); @@ -158,8 +158,8 @@ String result = ""; String msg = ""; - PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName); - PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName, pipeGallery); + PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName); + PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName,pgPartition); if (pgPartition == null) { result = "false"; msg = "不存在管廊仓和分区信息"; @@ -179,7 +179,7 @@ pgPipeLine.setEnterDate(sdf.parse(enterDate)); pgPipeLine.setLayerNum(layerNum); pgPipeLine.setDiameter(diameter); - pgPipeLine.setPgPartitionId(pgPartition); + pgPipeLine.setPipeGalleryId(pipeGallery); pgPipeLine.setActive(1); pgPipeLineManager.save(pgPipeLine); diff --git a/src/main/java/com/casic/PgInterface/rs/PgTextureRs.java b/src/main/java/com/casic/PgInterface/rs/PgTextureRs.java index 1557b38..5892127 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgTextureRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgTextureRs.java @@ -95,8 +95,10 @@ String msg = ""; PgTexture pgTexture = new PgTexture(); - PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName); - PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName, pipeGallery); + + PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName); + PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName,pgPartition); + if (pgPartition == null) { result = "false"; msg = "不存在管廊仓和分区信息"; @@ -113,7 +115,7 @@ pgTexture.setLayerNum(layerNum); pgTexture.setOwnerUnit(ownerUnit); pgTexture.setBuildDate(sdf.parse(buildDate)); - pgTexture.setPgPartitionId(pgPartition); + pgTexture.setPipeGalleryId(pipeGallery); pgTexture.setActive(1); pgTextureManager.save(pgTexture); @@ -154,8 +156,8 @@ String result = ""; String msg = ""; - PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName); - PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName, pipeGallery); + PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName); + PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName,pgPartition); if (pgPartition == null) { result = "false"; msg = "不存在管廊仓和分区信息"; @@ -173,6 +175,7 @@ pgTexture.setLayerNum(layerNum); pgTexture.setOwnerUnit(ownerUnit); pgTexture.setBuildDate(sdf.parse(buildDate)); + pgTexture.setPipeGalleryId(pipeGallery); pgTexture.setActive(1); pgTextureManager.save(pgTexture); diff --git a/src/main/java/com/casic/PgInterface/rs/PipeGalleryRs.java b/src/main/java/com/casic/PgInterface/rs/PipeGalleryRs.java index 52a7b71..6904b9f 100644 --- a/src/main/java/com/casic/PgInterface/rs/PipeGalleryRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PipeGalleryRs.java @@ -1,7 +1,9 @@ package com.casic.PgInterface.rs; +import com.casic.PgInterface.devTable.domain.PgPartition; import com.casic.PgInterface.devTable.domain.PipeGallery; import com.casic.PgInterface.devTable.dto.PipeGalleryDto; +import com.casic.PgInterface.devTable.manager.PgPartitionManager; import com.casic.PgInterface.devTable.manager.PipeGalleryManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -29,31 +31,16 @@ private PipeGalleryManager pipeGalleryManager; + private PgPartitionManager pgPartitionManager; + @Resource public void setPipeGalleryManager(PipeGalleryManager pipeGalleryManager) { this.pipeGalleryManager = pipeGalleryManager; } - /** - * 获取管廊信息 - */ - @POST - @Path("getPipeGallery") - @Produces(MediaType.APPLICATION_JSON) - public Map getPipeGallery() throws Exception { - Map resultMap = new HashMap(); - String msg = ""; - List pipeGalleryDtoList = new ArrayList(); - try { - pipeGalleryDtoList = pipeGalleryManager.getPIpeGalleryDtoList(); - msg = "获取成功"; - } catch (Exception e) { - msg = "获取失败"; - e.printStackTrace(); - } - resultMap.put("msg", msg); - resultMap.put("result", pipeGalleryDtoList); - return resultMap; + @Resource + public void setPgPartitionManager(PgPartitionManager pgPartitionManager) { + this.pgPartitionManager = pgPartitionManager; } /** @@ -62,24 +49,31 @@ @POST @Path("addPipeGallery") @Produces(MediaType.APPLICATION_JSON) - public Map addPipeGallery(@FormParam("pgName") String pgName) throws Exception { + public Map addPipeGallery(@FormParam("pgName") String pgName, + @FormParam("parName") String parName) throws Exception { Map resultMap = new HashMap(); String result = ""; String msg = ""; PipeGallery pipeGallery = new PipeGallery(); try { - if(pipeGalleryManager.getPipeGalleryByPgName(pgName)!=null) - { + PgPartition pgPartition=pgPartitionManager.getPartitionByParName(parName); + if(pgPartition==null) { result = "false"; - msg = "已存在相同管廊"; + msg = "不存在分区信息"; } else { - pipeGallery.setPgName(pgName); - pipeGallery.setActive(1); - logger.info("成功保存"); - pipeGalleryManager.save(pipeGallery); - result = "true"; - msg = "保存成功"; + if (pipeGalleryManager.getPipeGalleryByPgName(pgName,pgPartition) != null) { + result = "false"; + msg = "已存在相同管廊"; + } else { + pipeGallery.setPgName(pgName); + pipeGallery.setPgPartitionId(pgPartition); + pipeGallery.setActive(1); + logger.info("成功保存"); + pipeGalleryManager.save(pipeGallery); + result = "true"; + msg = "保存成功"; + } } } catch (Exception e) { result = "false"; @@ -92,6 +86,31 @@ return resultMap; } + /** + *获取分区下的管廊仓列表 + */ + @POST + @Path("getPiprGallerys") + @Produces(MediaType.APPLICATION_JSON) + public Map getPipeGalleryList(@FormParam("parName") String parName)throws Exception { + Map resultMap = new HashMap(); + String msg=""; + List pipeGalleryDtoList=new ArrayList(); + try { + pipeGalleryDtoList=pipeGalleryManager.getPipeGalleryByParName(parName); + if(pipeGalleryDtoList.size()==0) + msg="没有分区信息"; + else + msg="分区信息获取成功"; + }catch(Exception e){ + e.printStackTrace(); + msg="分区信息获取失败"; + } + resultMap.put("msg",msg); + resultMap.put("result",pipeGalleryDtoList); + return resultMap; + } + /* *编辑管廊信息 */ @@ -99,25 +118,28 @@ @Path("editPipeGallery") @Produces(MediaType.APPLICATION_JSON) public Map editPipeGallery(@FormParam("id") String id, - @FormParam("pgName") String pgName) throws Exception { + @FormParam("pgName") String pgName, + @FormParam("parName") String parName) throws Exception { Map resultMap = new HashMap(); String result = ""; String msg = ""; + PipeGallery pipeGallery=new PipeGallery(); try { - PipeGallery pipeGallery = pipeGalleryManager.get(Long.valueOf(id)); - if (pipeGallery == null) { + PgPartition pgPartition=pgPartitionManager.getPartitionByParName(parName); + if (pgPartition == null) { result = "false"; - msg = "不存在该管廊信息"; + msg = "不存在该分区信息"; } else { - if(pipeGalleryManager.getPipeGalleryByPgName(pgName)!=null) - { + if (pipeGalleryManager.getPipeGalleryByPgName(pgName, pgPartition) != null) { result = "false"; msg = "已存在相同管廊"; - } - else { + } else { + pipeGallery = pipeGalleryManager.get(Long.valueOf(id)); + pipeGallery.setPgName(pgName); + pipeGallery.setPgPartitionId(pgPartition); pipeGallery.setActive(1); pipeGalleryManager.save(pipeGallery); diff --git a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java index 80625c7..d8f5e6b 100644 --- a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java +++ b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java @@ -43,9 +43,7 @@ this.intoTime = intoTime; } - @Column(name = "OUT_TIME") - public Date getOutTime() { return outTime; } diff --git a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java index a99981e..b1d63a4 100644 --- a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java +++ b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java @@ -1,11 +1,28 @@ package com.casic.PgInterface.devData.manager; +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.core.util.DateUtils; +import com.casic.PgInterface.core.util.StringUtils; +import com.casic.PgInterface.devData.domain.PgCo; +import com.casic.PgInterface.devData.domain.PgLocation; +import com.casic.PgInterface.devData.dto.PgCoDto; +import com.casic.PgInterface.devData.dto.PgLocationDto; +import com.casic.PgInterface.devTable.domain.PgDevice; +import org.hibernate.Criteria; +import org.hibernate.criterion.Order; +import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; + /** * Created by yxw on 2017/11/2. */ @Service -public class PgLocationManager { +public class PgLocationManager extends HibernateEntityDao { + + //获取设备时间段内所有的监测数据 } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java index cfa0281..7fb5953 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -1,12 +1,12 @@ package com.casic.PgInterface.devTable.domain; import com.casic.PgInterface.devData.domain.*; +import com.casic.PgInterface.patroler.domain.PgAlarmRule; import org.hibernate.annotations.NotFound; import org.hibernate.annotations.NotFoundAction; import javax.persistence.*; import java.io.Serializable; -import java.util.Date; import java.util.List; /** @@ -19,21 +19,27 @@ private static final long serialVersionUID = 1L; private long id; + private PipeGallery pipeGalleryId;//所在管廊信息 + private String road;//路名 + private String position;//设备位置 + private String devType;//设备类型 private String devCode;//设备编号 - private String devName;//设备名称 - private String brand;//品牌 - private String ownerUnit;//权属单位 - private Date installDate;//安装时间 + private String assetName;//资产名称 + private String assetCode;//资产编码 + private String assetBarCode;//资产条码 + private String ip;//IP地址 + private String modBus;//modBus地址 + private String mome;//备注 private int isOpen;//设备是否开启 private int active;//状态位 - private PgDeviceType devTypeId;//设备类型 + private List pgAlarms; - private PgPartition pgPartitionId;//所在管廊信息 private List pgTempHums;//温湿度 private List pgCos;//一氧化碳 private List pgO2s;//氧气 private List pgCh4s;//甲烷 private List pgShs;//硫化氢 + private List pgAlarmRules;//报警规则 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") @@ -45,6 +51,33 @@ this.id = id; } + @Column(name = "ROAD") + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + @Column(name = "POSITION") + public String getPosition() { + return position; + } + + public void setPosition(String position) { + this.position = position; + } + + @Column(name = "DEV_TYPE") + public String getDevType() { + return devType; + } + + public void setDevType(String devType) { + this.devType = devType; + } + @Column(name = "DEV_CODE") public String getDevCode() { return devCode; @@ -54,40 +87,58 @@ this.devCode = devCode; } - @Column(name = "DEV_NAME") - public String getDevName() { - return devName; + @Column(name = "ASSET_NAME") + public String getAssetName() { + return assetName; } - public void setDevName(String devName) { - this.devName = devName; + public void setAssetName(String assetName) { + this.assetName = assetName; } - @Column(name = "BRAND") - public String getBrand() { - return brand; + @Column(name = "ASSET_CODE") + public String getAssetCode() { + return assetCode; } - public void setBrand(String brand) { - this.brand = brand; + public void setAssetCode(String assetCode) { + this.assetCode = assetCode; } - @Column(name = "OWNERUNIT") - public String getOwnerUnit() { - return ownerUnit; + @Column(name = "ASSET_BAR_CODE") + public String getAssetBarCode() { + return assetBarCode; } - public void setOwnerUnit(String ownerUnit) { - this.ownerUnit = ownerUnit; + public void setAssetBarCode(String assetBarCode) { + this.assetBarCode = assetBarCode; } - @Column(name = "INSTALDATE") - public Date getInstallDate() { - return installDate; + @Column(name = "IP") + public String getIp() { + return ip; } - public void setInstallDate(Date installDate) { - this.installDate = installDate; + public void setIp(String ip) { + this.ip = ip; + } + + @Column(name = "MODBUS") + public String getModBus() { + return modBus; + } + + public void setModBus(String modBus) { + this.modBus = modBus; + } + + @Column(name = "MOME") + public String getMome() { + return mome; + } + + public void setMome(String mome) { + this.mome = mome; } @Column(name = "ISOPEN") @@ -119,24 +170,13 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; - } - - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "DEVICE_TYPE_ID") - public PgDeviceType getDevTypeId() { - return devTypeId; - } - - public void setDevTypeId(PgDeviceType devTypeId) { - this.devTypeId = devTypeId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgDeviceId") @@ -184,4 +224,13 @@ this.pgShs = pgShs; } + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgDeviceId") + public List getPgAlarmRules() { + return pgAlarmRules; + } + + public void setPgAlarmRules(List pgAlarmRules) { + this.pgAlarmRules = pgAlarmRules; + } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java index b997b29..4fb3d6f 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java @@ -1,8 +1,5 @@ package com.casic.PgInterface.devTable.domain; -import org.hibernate.annotations.NotFound; -import org.hibernate.annotations.NotFoundAction; - import javax.persistence.*; import java.io.Serializable; import java.util.List; @@ -19,11 +16,9 @@ private long id; private String parName;//分区名称 - private PipeGallery pipeGalleryId;//管廊仓 + private String road;//所属道路 private int active;//状态位 - private List pgTextureList; - private List pgPipeLineList; - private List pgDeviceList; + private List pipeGalleryList;//管廊仓 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PARTITION_ID") @@ -44,6 +39,15 @@ this.parName = parName; } + @Column(name = "ROAD") + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + @Column(name = "ACTIVE") public int getActive() { return active; @@ -53,41 +57,14 @@ this.active = active; } - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PIPEGALLERYID") - public PipeGallery getPipeGalleryId() { - return pipeGalleryId; - } - - public void setPipeGalleryId(PipeGallery pipeGalleryId) { - this.pipeGalleryId = pipeGalleryId; - } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgTextureList() { - return pgTextureList; + public List getPipeGalleryList() { + return pipeGalleryList; } - public void setPgTextureList(List pgTextureList) { - this.pgTextureList = pgTextureList; + public void setPipeGalleryList(List pipeGalleryList) { + this.pipeGalleryList = pipeGalleryList; } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgPipeLineList() { - return pgPipeLineList; - } - public void setPgPipeLineList(List pgPipeLineList) { - this.pgPipeLineList = pgPipeLineList; - } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgDeviceList() { - return pgDeviceList; - } - - public void setPgDeviceList(List pgDeviceList) { - this.pgDeviceList = pgDeviceList; - } } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java index d936d18..e5ff9b3 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java @@ -22,7 +22,7 @@ private Date enterDate;//入廊时间 private String layerNum;//所在层数 private String diameter;//管径 - private PgPartition pgPartitionId;//所在管廊信息 + private PipeGallery pipeGalleryId;//所在管廊信息 private int active;//状态位 @Id @@ -100,12 +100,12 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java index 1f22bf9..4ebfbda 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java @@ -21,7 +21,7 @@ private String ownerUnit;//权属单位 private Date buildDate;//建设年代 private int active;//状态位 - private PgPartition pgPartitionId;//所在管廊信息 + private PipeGallery pipeGalleryId;//所在管廊信息 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_TEXTURE_ID") @@ -91,12 +91,13 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java b/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java index 49a246c..650d623 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java @@ -1,5 +1,8 @@ package com.casic.PgInterface.devTable.domain; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + import javax.persistence.*; import java.io.Serializable; import java.util.List; @@ -16,7 +19,10 @@ private long id; private String pgName;//管廊名称 private int active;//状态位 - private List partitionList; + private PgPartition pgPartitionId;// + private List pgTextureList; + private List pgPipeLineList; + private List pgDeviceList; @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PIPE_GALLERY_ID") @@ -46,12 +52,42 @@ this.active = active; } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") - public List getPartitionList() { - return partitionList; + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "PARTITIONID") + public PgPartition getPgPartitionId() { + return pgPartitionId; } - public void setPartitionList(List partitionList) { - this.partitionList = partitionList; + public void setPgPartitionId(PgPartition pgPartitionId) { + this.pgPartitionId = pgPartitionId; } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgTextureList() { + return pgTextureList; + } + + public void setPgTextureList(List pgTextureList) { + this.pgTextureList = pgTextureList; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgPipeLineList() { + return pgPipeLineList; + } + + public void setPgPipeLineList(List pgPipeLineList) { + this.pgPipeLineList = pgPipeLineList; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgDeviceList() { + return pgDeviceList; + } + + public void setPgDeviceList(List pgDeviceList) { + this.pgDeviceList = pgDeviceList; + } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java index b4048d9..c3dfc55 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java @@ -101,18 +101,17 @@ this.active = active; } - public PgAlarmDto(PgAlarm pgAlarm) - { - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + public PgAlarmDto(PgAlarm pgAlarm) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); this.setId(String.valueOf(pgAlarm.getId())); this.setAlarmType(pgAlarm.getAlarmTypeId().getAlarmType()); this.setAlarmValue(pgAlarm.getAlarmValue()); this.setAlarmDate(sdf.format(pgAlarm.getAlarmDate())); this.setDescription(pgAlarm.getDescription()); - this.setAlarmDevName(pgAlarm.getAlarmDevId().getDevName()); - this.setAlarmLocation(pgAlarm.getAlarmDevId().getPgPartitionId().getPipeGalleryId().getPgName() - + pgAlarm.getAlarmDevId().getPgPartitionId().getParName()); + this.setAlarmDevName(pgAlarm.getAlarmDevId().getAssetName()); + this.setAlarmLocation(pgAlarm.getAlarmDevId().getPipeGalleryId().getPgPartitionId().getParName() + + pgAlarm.getAlarmDevId().getPipeGalleryId().getPgName()); this.setUserName(pgAlarm.getPatrolerId().getUserName()); this.setPhoneNumber(pgAlarm.getPatrolerId().getPhoneNumber()); this.setActive(String.valueOf(pgAlarm.getActive())); diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java index ae76e95..49bd436 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java @@ -11,16 +11,20 @@ public class PgDeviceDto implements Serializable { private String id; - private String devType;//设备类型 - private String devCode;//设备编号 - private String devName;//设备名称 - private String brand;//品牌 - private String ownerUnit;//权属单位 - private String installDate;//安装时间 - private String isOpen;//设备开启状态 - private String active;//状态位 private String pipeGallery;//仓位 private String partition;//分区 + private String road;//路名 + private String position;//设备位置 + private String devType;//设备类型 + private String devCode;//设备编号 + private String assetName;//资产名称 + private String assetCode;//资产名称 + private String assetBarCode;//资产条码 + private String ip;//IP地址 + private String modBus;//modBus地址 + private String mome;//备注 + private String isOpen;//设备开启状态 + private String active;//状态位 public String getId() { return id; @@ -30,6 +34,38 @@ this.id = id; } + public String getPartition() { + return partition; + } + + public void setPartition(String partition) { + this.partition = partition; + } + + public String getPipeGallery() { + return pipeGallery; + } + + public void setPipeGallery(String pipeGallery) { + this.pipeGallery = pipeGallery; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getPosition() { + return position; + } + + public void setPosition(String position) { + this.position = position; + } + public String getDevType() { return devType; } @@ -46,36 +82,52 @@ this.devCode = devCode; } - public String getDevName() { - return devName; + public String getAssetName() { + return assetName; } - public void setDevName(String devName) { - this.devName = devName; + public void setAssetName(String assetName) { + this.assetName = assetName; } - public String getBrand() { - return brand; + public String getAssetCode() { + return assetCode; } - public void setBrand(String brand) { - this.brand = brand; + public void setAssetCode(String assetCode) { + this.assetCode = assetCode; } - public String getOwnerUnit() { - return ownerUnit; + public String getAssetBarCode() { + return assetBarCode; } - public void setOwnerUnit(String ownerUnit) { - this.ownerUnit = ownerUnit; + public void setAssetBarCode(String assetBarCode) { + this.assetBarCode = assetBarCode; } - public String getInstallDate() { - return installDate; + public String getIp() { + return ip; } - public void setInstallDate(String installDate) { - this.installDate = installDate; + public void setIp(String ip) { + this.ip = ip; + } + + public String getModBus() { + return modBus; + } + + public void setModBus(String modBus) { + this.modBus = modBus; + } + + public String getMome() { + return mome; + } + + public void setMome(String mome) { + this.mome = mome; } public String getIsOpen() { @@ -94,39 +146,26 @@ this.active = active; } - public String getPipeGallery() { - return pipeGallery; - } - - public void setPipeGallery(String pipeGallery) { - this.pipeGallery = pipeGallery; - } - - public String getPartition() { - return partition; - } - - public void setPartition(String partition) { - this.partition = partition; - } - public PgDeviceDto(PgDevice pgDevice) { SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); this.setId(String.valueOf(pgDevice.getId())); - this.setDevType(pgDevice.getDevTypeId().getDevType()); + this.setPipeGallery(pgDevice.getPipeGalleryId().getPgName()); + this.setPartition(pgDevice.getPipeGalleryId().getPgPartitionId().getParName()); + this.setRoad(pgDevice.getRoad()); + this.setPosition(pgDevice.getPosition()); + this.setDevType(pgDevice.getDevType()); this.setDevCode(pgDevice.getDevCode()); - this.setDevName(pgDevice.getDevName()); - this.setBrand(pgDevice.getBrand()); - this.setOwnerUnit(pgDevice.getOwnerUnit()); - this.setInstallDate(sdf.format(pgDevice.getInstallDate())); + this.setAssetName(pgDevice.getAssetName()); + this.setAssetCode(pgDevice.getAssetCode()); + this.setAssetBarCode(pgDevice.getAssetBarCode()); + this.setId(pgDevice.getIp()); + this.setModBus(pgDevice.getModBus()); + this.setMome(pgDevice.getMome()); this.setIsOpen(String.valueOf(pgDevice.getIsOpen())); this.setActive(String.valueOf(pgDevice.getActive())); - this.setPipeGallery(pgDevice.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgDevice.getPgPartitionId().getParName()); + } - -} - +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java index e8751d3..3acd0fa 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java @@ -11,7 +11,7 @@ private String id; private String parName;//分区名称 - private String pipeGallery;//管廊仓 + private String road;//所属道路 private String active;//状态位 @@ -31,14 +31,6 @@ this.parName = parName; } - public String getPipeGallery() { - return pipeGallery; - } - - public void setPipeGallery(String pipeGallery) { - this.pipeGallery = pipeGallery; - } - public String getActive() { return active; } @@ -47,11 +39,19 @@ this.active = active; } + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + public PgPartitionDto(PgPartition pgPartition) { this.setId(String.valueOf(pgPartition.getId())); this.setParName(pgPartition.getParName()); - this.setPipeGallery(pgPartition.getPipeGalleryId().getPgName()); + this.setRoad(pgPartition.getRoad()); this.setActive(String.valueOf(pgPartition.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java index 9b161bf..8b430dc 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java @@ -112,8 +112,8 @@ this.setEnterDate(sdf.format(pgPipeLine.getEnterDate())); this.setLayerNum(pgPipeLine.getLayerNum()); this.setDiameter(pgPipeLine.getDiameter()); - this.setPipeGallery(pgPipeLine.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgPipeLine.getPgPartitionId().getParName()); + this.setPipeGallery(pgPipeLine.getPipeGalleryId().getPgName()); + this.setPartition(pgPipeLine.getPipeGalleryId().getPgPartitionId().getParName()); this.setActive(String.valueOf(pgPipeLine.getActive())); } } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java index 03c580c..709dcea 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java @@ -103,8 +103,8 @@ this.setOwnerUnit(pgTexture.getOwnerUnit()); this.setBuildDate(sdf.format(pgTexture.getBuildDate())); this.setActive(String.valueOf(pgTexture.getActive())); - this.setPipeGallery(pgTexture.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgTexture.getPgPartitionId().getParName()); + this.setPipeGallery(pgTexture.getPipeGalleryId().getPgName()); + this.setPartition(pgTexture.getPipeGalleryId().getPgPartitionId().getParName()); } } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java index b40ce84..319cf21 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java @@ -11,6 +11,7 @@ private String id; private String pgName;//管廊名称 + private String pgPartition;//分区名称 private String active;//状态位 public String getId() { @@ -37,10 +38,19 @@ this.active = active; } + public String getPgPartition() { + return pgPartition; + } + + public void setPgPartition(String pgPartition) { + this.pgPartition = pgPartition; + } + public PipeGalleryDto(PipeGallery pipeGallery) { this.setId(String.valueOf(pipeGallery.getId())); this.setPgName(pipeGallery.getPgName()); + this.setPgPartition(pipeGallery.getPgPartitionId().getParName()); this.setActive(String.valueOf(pipeGallery.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java b/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java index 8b413e7..0c594e7 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java @@ -5,10 +5,10 @@ import com.casic.PgInterface.devTable.domain.PipeGallery; import com.casic.PgInterface.devTable.dto.PgPartitionDto; import org.hibernate.Criteria; +import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; -import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; @@ -18,44 +18,50 @@ @Service public class PgPartitionManager extends HibernateEntityDao { - private PipeGalleryManager pipeGalleryManager; - - @Resource - public void setPipeGalleryManager(PipeGalleryManager pipeGalleryManager) { - this.pipeGalleryManager = pipeGalleryManager; - } - - public PgPartition getPartitionByParName(String parName,PipeGallery pipeGallery) { - if(pipeGallery==null) - return null; - Criteria criteria = getSession().createCriteria(PgPartition.class); + public PgPartition getPartitionByParName(String parName) { + Criteria criteria = getSession().createCriteria(PipeGallery.class); criteria.add(Restrictions.eq("parName", parName)); - criteria.add(Restrictions.eq("pipeGalleryId",pipeGallery)); + criteria.add(Restrictions.eq("active",1)); List pgPartitionList = criteria.list(); - //TODO LIST:为空判断 pgPartitionList==null? if (pgPartitionList != null && pgPartitionList.size() > 0) return pgPartitionList.get(0); else return null; } - public List getPartitionByPG(String pgName){ - PipeGallery pipeGallery=pipeGalleryManager.getPipeGalleryByPgName(pgName); - - Criteria criteria=getSession().createCriteria(PgPartition.class); - criteria.add(Restrictions.eq("pipeGalleryId",pipeGallery)); + public List getPartitionByRoad(String road) { + Criteria criteria = getSession().createCriteria(PipeGallery.class); + criteria.add(Restrictions.eq("road", road)); + criteria.add(Restrictions.eq("active",1)); List pgPartitionList = criteria.list(); List pgPartitionDtoList=new ArrayList(); - for(PgPartition pgPartition:pgPartitionList) - { - pgPartitionDtoList.add(new PgPartitionDto(pgPartition)); - } + for(PgPartition pgPartition:pgPartitionList) { + pgPartitionDtoList.add(new PgPartitionDto(pgPartition)); + } return pgPartitionDtoList; } + public List getPgPartitionDtoList() + { + Criteria criteria=getSession().createCriteria(PgPartition.class); + criteria.add(Restrictions.eq("active",1)); + criteria.addOrder(Order.desc("id")); + + List pgPartitionList=criteria.list(); + if(pgPartitionList.size()==0||pgPartitionList==null) + return null; + List pgPartitionDtoList=new ArrayList(); + for(PgPartition pgPartition:pgPartitionList) { + pgPartitionDtoList.add(new PgPartitionDto(pgPartition)); + } + return pgPartitionDtoList; + } + + + } diff --git a/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java b/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java index 16370c6..9bce32b 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java @@ -1,14 +1,16 @@ package com.casic.PgInterface.devTable.manager; import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.devTable.domain.PgPartition; import com.casic.PgInterface.devTable.domain.PipeGallery; import com.casic.PgInterface.devTable.dto.PipeGalleryDto; import org.hibernate.Criteria; -import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; -import java.util.*; +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; /** * Created by yxw on 2017/11/4. @@ -16,36 +18,44 @@ @Service public class PipeGalleryManager extends HibernateEntityDao { - public PipeGallery getPipeGalleryByPgName(String pgName) { - Criteria criteria = getSession().createCriteria(PipeGallery.class); + private PgPartitionManager pgPartitionManager; + + @Resource + public void setPgPartitionManager(PgPartitionManager pgPartitionManager) { + this.pgPartitionManager = pgPartitionManager; + } + + public PipeGallery getPipeGalleryByPgName(String pgName,PgPartition pgPartition) { + if(pgPartition==null) + return null; + Criteria criteria = getSession().createCriteria(PgPartition.class); criteria.add(Restrictions.eq("pgName", pgName)); - criteria.add(Restrictions.eq("active",1)); + criteria.add(Restrictions.eq("pgPartitionId",pgPartition)); List pipeGalleryList = criteria.list(); - //TODO LIST:为空判断 pipeGalleryList==null? + //TODO LIST:为空判断 pgPartitionList==null? if (pipeGalleryList != null && pipeGalleryList.size() > 0) return pipeGalleryList.get(0); else return null; } - public List getPIpeGalleryDtoList() - { - Criteria criteria=getSession().createCriteria(PipeGallery.class); - criteria.add(Restrictions.eq("active",1)); - criteria.addOrder(Order.desc("id")); - List pipeGalleryList=criteria.list(); - if(pipeGalleryList.size()==0||pipeGalleryList==null) - return null; - List pipeGalleryDtoList=new ArrayList(); - for(PipeGallery pipeGallery:pipeGalleryList) { + public List getPipeGalleryByParName(String parName) { + + PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName); + Criteria criteria = getSession().createCriteria(PipeGallery.class); + criteria.add(Restrictions.eq("pgPartitionId", pgPartition)); + + List pipeGalleryList = criteria.list(); + + List pipeGalleryDtoList = new ArrayList(); + for (PipeGallery pipeGallery : pipeGalleryList) { pipeGalleryDtoList.add(new PipeGalleryDto(pipeGallery)); } + return pipeGalleryDtoList; } - - } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java new file mode 100644 index 0000000..9d06235 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java @@ -0,0 +1,63 @@ +package com.casic.PgInterface.patroler.domain; + +import com.casic.PgInterface.devTable.domain.PgDevice; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + +import javax.persistence.*; +import java.io.Serializable; + +/** + * Created by yxw on 2017/12/14. + */ +@Entity +@Table(name = "PG_ALARM_RULE") +@SequenceGenerator(name = "SEQ_PG_ALARM_RULE_ID", sequenceName = "SEQ_PG_ALARM_RULE_ID",allocationSize=1,initialValue=1) +public class PgAlarmRule implements Serializable { + + private static final long serialVersionUID = 1L; + private long id; + private String highValue;//高限 + private String lowValue;//低限 + private PgDevice pgDeviceId;//设备 + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_ALARM_RULE_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "HIGHVALUE") + public String getHighValue() { + return highValue; + } + + public void setHighValue(String highValue) { + this.highValue = highValue; + } + + @Column(name = "LOWVALUE") + public String getLowValue() { + return lowValue; + } + + public void setLowValue(String lowValue) { + this.lowValue = lowValue; + } + + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "PGDEVICEID") + public PgDevice getPgDeviceId() { + return pgDeviceId; + } + + public void setPgDeviceId(PgDevice pgDeviceId) { + this.pgDeviceId = pgDeviceId; + } + +} diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java new file mode 100644 index 0000000..8367ad4 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java @@ -0,0 +1,57 @@ +package com.casic.PgInterface.patroler.dto; + +import com.casic.PgInterface.patroler.domain.PgAlarmRule; + +import java.io.Serializable; + +/** + * Created by yxw on 2017/12/14. + */ +public class PgAlarmRuleDto implements Serializable { + + private String id; + private String highValue;//高限 + private String lowValue;//低限 + private String devName;//设备 + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getHighValue() { + return highValue; + } + + public void setHighValue(String highValue) { + this.highValue = highValue; + } + + public String getLowValue() { + return lowValue; + } + + public void setLowValue(String lowValue) { + this.lowValue = lowValue; + } + + public String getDevName() { + return devName; + } + + public void setDevName(String devName) { + this.devName = devName; + } + + public PgAlarmRuleDto(PgAlarmRule pgAlarmRule) + { + this.setId(String.valueOf(pgAlarmRule.getId())); + this.setDevName(pgAlarmRule.getPgDeviceId().getAssetName()); + this.setHighValue(pgAlarmRule.getHighValue()); + this.setLowValue(pgAlarmRule.getLowValue()); + } + +} diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java new file mode 100644 index 0000000..d5c00b2 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java @@ -0,0 +1,42 @@ +package com.casic.PgInterface.patroler.manager; + +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.devTable.domain.PgDevice; +import com.casic.PgInterface.patroler.domain.PgAlarmRule; +import com.casic.PgInterface.patroler.dto.PgAlarmRuleDto; +import org.hibernate.Criteria; +import org.hibernate.criterion.Restrictions; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * Created by yxw on 2017/12/14. + */ +@Service +public class PgAlarmRuleManager extends HibernateEntityDao { + + //根据设备获取设备报警阈值 + public PgAlarmRuleDto getAlarmRuleDtoBydev(PgDevice pgDeviceId) { + Criteria criteria=createCriteria(PgAlarmRule.class); + criteria.add(Restrictions.eq("pgDeviceId", pgDeviceId)); + + List pgAlarmRuleList=criteria.list(); + if(pgAlarmRuleList.size()==0) + return null; + else + return new PgAlarmRuleDto(pgAlarmRuleList.get(0)); + } + + public PgAlarmRule getAlarmRuleBydev(PgDevice pgDeviceId) { + Criteria criteria=createCriteria(PgAlarmRule.class); + criteria.add(Restrictions.eq("pgDeviceId", pgDeviceId)); + + List pgAlarmRuleList=criteria.list(); + if(pgAlarmRuleList.size()==0) + return null; + else + return pgAlarmRuleList.get(0); + } + +} diff --git a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java new file mode 100644 index 0000000..88255c6 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java @@ -0,0 +1,162 @@ +package com.casic.PgInterface.rs; + +import com.casic.PgInterface.devTable.domain.PgDevice; +import com.casic.PgInterface.devTable.manager.PgDeviceManager; +import com.casic.PgInterface.patroler.domain.PgAlarmRule; +import com.casic.PgInterface.patroler.dto.PgAlarmRuleDto; +import com.casic.PgInterface.patroler.manager.PgAlarmRuleManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import javax.ws.rs.FormParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import java.util.HashMap; +import java.util.Map; + +/** + * Created by yxw on 2017/12/14. + */ +@Component +@Path("pgAlarmRule") +public class PgAlarmRuleRs { + + private static Logger logger = LoggerFactory.getLogger(PgAlarmRule.class); + + private PgDeviceManager pgDeviceManager; + + private PgAlarmRuleManager pgAlarmRuleManager; + + @Resource + public void setPgAlarmRuleManager(PgAlarmRuleManager pgAlarmRuleManager) { + this.pgAlarmRuleManager = pgAlarmRuleManager; + } + + @Resource + public void setPgDeviceManager(PgDeviceManager pgDeviceManager) { + this.pgDeviceManager = pgDeviceManager; + } + + /** + * 获取报警阈值信息 + */ + @POST + @Path("getAlarmRuleByAssetCode") + @Produces(MediaType.APPLICATION_JSON) + public Map getAlarmRuleByAssetCode(@FormParam("assetCode") String assetCode) throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + + PgAlarmRuleDto pgAlarmRuleDto = null; + PgDevice pgDevice = pgDeviceManager.getDeviceByAssetCode(assetCode); + try { + pgAlarmRuleDto = pgAlarmRuleManager.getAlarmRuleDtoBydev(pgDevice); + if (pgAlarmRuleDto == null) + msg = "不存在报警阈值信息"; + else + msg = "报警阈值获取成功"; + } catch (Exception e) { + e.printStackTrace(); + msg = "报警信息获取失败"; + } + resultMap.put("msg", msg); + resultMap.put("result", pgAlarmRuleDto); + return resultMap; + } + + /** + * 新增报警阈值 + */ + @POST + @Path("addAlarmRule") + @Produces(MediaType.APPLICATION_JSON) + public Map addAlarmRule(@FormParam("assetCode") String assetCode, + @FormParam("highValue") String highValue, + @FormParam("lowValue") String lowValue) throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + String result = ""; + + PgAlarmRule pgAlarmRule = null; + PgDevice pgDevice = pgDeviceManager.getDeviceByAssetCode(assetCode); + if (pgDevice == null) + msg = "不存在设备信息"; + else { + try { + pgAlarmRule = pgAlarmRuleManager.getAlarmRuleBydev(pgDevice); + if (pgAlarmRule != null) { + result = "false"; + msg = "设备阈值已经存在"; + } else { + pgAlarmRule = new PgAlarmRule(); + pgAlarmRule.setHighValue(highValue); + pgAlarmRule.setLowValue(lowValue); + pgAlarmRule.setPgDeviceId(pgDevice); + + pgAlarmRuleManager.save(pgAlarmRule); + result = "true"; + msg = "报警阈值新增成功"; + } + + } catch (Exception e) { + e.printStackTrace(); + result = "false"; + msg = "报警阈值新增失败"; + } + } + resultMap.put("msg", msg); + resultMap.put("result", result); + return resultMap; + } + + /** + * 编辑报警阈值 + */ + @POST + @Path("editAlarmRule") + @Produces(MediaType.APPLICATION_JSON) + public Map editAlarmRule(@FormParam("id") String id, + @FormParam("assetCode") String assetCode, + @FormParam("highValue") String highValue, + @FormParam("lowValue") String lowValue) throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + String result = ""; + + PgAlarmRule pgAlarmRule = null; + PgDevice pgDevice = pgDeviceManager.getDeviceByAssetCode(assetCode); + if (pgDevice == null) { + msg = "不存在设备信息"; + result = "false"; + } else { + try { + pgAlarmRule = pgAlarmRuleManager.get(id); + if (pgAlarmRule == null) { + msg="不存在报警阈值记录"; + result="false"; + } else { + pgAlarmRule.setPgDeviceId(pgDevice); + pgAlarmRule.setHighValue(highValue); + pgAlarmRule.setLowValue(lowValue); + pgAlarmRuleManager.save(pgAlarmRule); + msg="编辑成功"; + result="true"; + } + } catch (Exception ex) { + ex.printStackTrace(); + result = "false"; + msg = "报警阈值编辑失败"; + } + } + resultMap.put("msg", msg); + resultMap.put("result", result); + + return resultMap; + + } + +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java b/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java index 36a4fc5..4f77754 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java @@ -18,7 +18,6 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; -import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -65,14 +64,14 @@ * 获取设备信息 */ @POST - @Path("getPgDeviceByName") + @Path("getPgDeviceByAssetCode") @Produces(MediaType.APPLICATION_JSON) - public Map getPgDeviceByName(@FormParam("devName") String devName) throws Exception { + public Map getPgDeviceByAssetCode(@FormParam("assetCode") String assetCode) throws Exception { Map resultMap = new HashMap(); String msg = ""; PgDeviceDto pgDeviceDto=null; try { - PgDevice pgDevice = pgDeviceManager.getDeviceBydevName(devName); + PgDevice pgDevice = pgDeviceManager.getDeviceByAssetCode(assetCode); pgDeviceDto=new PgDeviceDto(pgDevice); msg = "获取成功"; } catch (Exception e) { @@ -84,7 +83,6 @@ return resultMap; } - /** * 显示设备列表 */ @@ -116,42 +114,49 @@ @POST @Path("addDevice") @Produces(MediaType.APPLICATION_JSON) - public Map addDevice(@FormParam("devType") String devType, - @FormParam("devCode") String devCode, - @FormParam("devName") String devName, - @FormParam("brand") String brand, - @FormParam("ownerUnit") String ownerUnit, - @FormParam("installDate") String installDate, - @FormParam("pgName") String pgName, - @FormParam("parName") String parName) + public Map addDevice(@FormParam("parName") String parName, + @FormParam("pgName") String pgName, + @FormParam("road") String road, + @FormParam("position") String position, + @FormParam("devType") String devType, + @FormParam("devCode") String devCode, + @FormParam("assetName") String assetName, + @FormParam("assetCode") String assetCode, + @FormParam("assetBarCode") String assetBarCode, + @FormParam("ip") String ip, + @FormParam("modBus") String modBus, + @FormParam("mome") String mome) throws Exception { - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - Map resultMap = new HashMap(); String result = ""; String msg = ""; - PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName); - PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName, pipeGallery); + PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName); + PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName,pgPartition); + if (pgPartition == null) { result = "false"; msg = "不存在管廊仓和分区信息"; } else { try { - if (pgDeviceManager.getDeviceBydevName(devName)!=null) { + if (pgDeviceManager.getDeviceByAssetCode(assetCode)!=null) { result = "false"; msg = "已存在同名设备"; } else { PgDevice pgDevice = new PgDevice(); - pgDevice.setDevTypeId(pgDeviceTypeManager.getPgDeviceTypeByDevType(devType)); + pgDevice.setPipeGalleryId(pipeGallery); + pgDevice.setRoad(road); + pgDevice.setPosition(position); + pgDevice.setDevType(devType); pgDevice.setDevCode(devCode); - pgDevice.setDevName(devName); - pgDevice.setBrand(brand); - pgDevice.setOwnerUnit(ownerUnit); - pgDevice.setInstallDate(sdf.parse(installDate)); - pgDevice.setPgPartitionId(pgPartition); + pgDevice.setAssetName(assetName); + pgDevice.setAssetCode(assetCode); + pgDevice.setAssetBarCode(assetBarCode); + pgDevice.setIp(ip); + pgDevice.setModBus(modBus); + pgDevice.setMome(mome); pgDevice.setIsOpen(0); pgDevice.setActive(1); @@ -179,41 +184,49 @@ @Path("editDevice") @Produces(MediaType.APPLICATION_JSON) public Map editPartition(@FormParam("id") String id, + @FormParam("parName") String parName, + @FormParam("pgName") String pgName, + @FormParam("road") String road, + @FormParam("position") String position, @FormParam("devType") String devType, @FormParam("devCode") String devCode, - @FormParam("devName") String devName, - @FormParam("brand") String brand, - @FormParam("ownerUnit") String ownerUnit, - @FormParam("installDate") String installDate, - @FormParam("pgName") String pgName, - @FormParam("parName") String parName, + @FormParam("assetName") String assetName, + @FormParam("assetCode") String assetCode, + @FormParam("assetBarCode") String assetBarCode, + @FormParam("ip") String ip, + @FormParam("modBus") String modBus, + @FormParam("mome") String mome, @FormParam("isOpen") String isOpen) throws Exception { - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - Map resultMap = new HashMap(); String result = ""; String msg = ""; - PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName); - PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName, pipeGallery); + PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName); + PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName,pgPartition); + if (pgPartition == null) { result = "false"; msg = "不存在管廊仓和分区信息"; } else { try { - if (pgDeviceManager.getDeviceBydevName(devName)!=null) { + if (pgDeviceManager.getDeviceByAssetCode(assetCode)!=null) { result = "false"; msg = "已存在同名设备"; } else { PgDevice pgDevice = pgDeviceManager.get(Long.valueOf(id)); - pgDevice.setDevTypeId(pgDeviceTypeManager.getPgDeviceTypeByDevType(devType)); + pgDevice.setPipeGalleryId(pipeGallery); + pgDevice.setRoad(road); + pgDevice.setPosition(position); + pgDevice.setDevType(devType); pgDevice.setDevCode(devCode); - pgDevice.setDevName(devName); - pgDevice.setBrand(brand); - pgDevice.setOwnerUnit(ownerUnit); - pgDevice.setInstallDate(sdf.parse(installDate)); - pgDevice.setPgPartitionId(pgPartition); + pgDevice.setAssetName(assetName); + pgDevice.setAssetCode(assetCode); + pgDevice.setAssetBarCode(assetBarCode); + pgDevice.setIp(ip); + pgDevice.setModBus(modBus); + pgDevice.setMome(mome); + pgDevice.setActive(1); pgDevice.setIsOpen(Integer.valueOf(isOpen)); pgDeviceManager.save(pgDevice); diff --git a/src/main/java/com/casic/PgInterface/rs/PgLocationRs.java b/src/main/java/com/casic/PgInterface/rs/PgLocationRs.java new file mode 100644 index 0000000..e8daabc --- /dev/null +++ b/src/main/java/com/casic/PgInterface/rs/PgLocationRs.java @@ -0,0 +1,39 @@ +package com.casic.PgInterface.rs; + +import com.casic.PgInterface.devData.manager.PgLocationManager; +import com.casic.PgInterface.devTable.manager.PgDeviceManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import javax.ws.rs.Path; + +/** + * Created by yxw on 2017/12/11. + */ +@Component +@Path("location") +public class PgLocationRs { + + private static Logger logger = LoggerFactory.getLogger(PgLocationRs.class); + + private PgDeviceManager pgDeviceManager; + + private PgLocationManager pgLocationManager; + + @Resource + public void setPgDeviceManager(PgDeviceManager pgDeviceManager) { + this.pgDeviceManager = pgDeviceManager; + } + + @Resource + public void setPgLocationManager(PgLocationManager pgLocationManager) { + this.pgLocationManager = pgLocationManager; + } + + + + + +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java b/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java index 45fc210..8a42e7e 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java @@ -1,10 +1,8 @@ package com.casic.PgInterface.rs; import com.casic.PgInterface.devTable.domain.PgPartition; -import com.casic.PgInterface.devTable.domain.PipeGallery; import com.casic.PgInterface.devTable.dto.PgPartitionDto; import com.casic.PgInterface.devTable.manager.PgPartitionManager; -import com.casic.PgInterface.devTable.manager.PipeGalleryManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; @@ -29,8 +27,6 @@ private static Logger logger = LoggerFactory.getLogger(PgPartitionRs.class); - private PipeGalleryManager pipeGalleryManager; - private PgPartitionManager pgPartitionManager; @Resource @@ -38,38 +34,24 @@ this.pgPartitionManager = pgPartitionManager; } - @Resource - public void setPipeGalleryManager(PipeGalleryManager pipeGalleryManager) { - - this.pipeGalleryManager = pipeGalleryManager; - } - /** * 新增分区 */ @POST @Path("addPartition") @Produces(MediaType.APPLICATION_JSON) - public Map addAlarm(@FormParam("parName") String parName, - @FormParam("pgName") String pgName)throws Exception { + public Map addAlarm(@FormParam("parName") String parName)throws Exception { Map resultMap = new HashMap(); String result = ""; String msg = ""; try { - PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName); - - if (pipeGallery == null) { - result = "false"; - msg = "不存在" + pgName + "管廊仓"; - } else { - if (pgPartitionManager.getPartitionByParName(parName, pipeGallery) != null) { + if (pgPartitionManager.getPartitionByParName(parName) != null) { result = "false"; msg = "已存在相同分区"; } else { PgPartition pgPartition = new PgPartition(); pgPartition.setParName(parName); - pgPartition.setPipeGalleryId(pipeGallery); pgPartition.setActive(1); logger.info("成功保存"); @@ -77,7 +59,7 @@ result = "true"; msg = "保存成功"; } - } + } catch (Exception e) { result = "false"; msg = "保存失败"; @@ -89,37 +71,13 @@ return resultMap; } - /** - *获取管廊仓下的分区列表 - */ - @POST - @Path("getPartition") - @Produces(MediaType.APPLICATION_JSON) - public Map getPartitionList(@FormParam("pgName") String pgName)throws Exception { - Map resultMap = new HashMap(); - String msg=""; - List pgPartitionDtoList=new ArrayList(); - try { - pgPartitionDtoList=pgPartitionManager.getPartitionByPG(pgName); - if(pgPartitionDtoList.size()==0) - msg="没有分区信息"; - else - msg="分区信息获取成功"; - }catch(Exception e){ - e.printStackTrace(); - msg="分区信息获取失败"; - } - resultMap.put("msg",msg); - resultMap.put("result",pgPartitionDtoList); - return resultMap; - } + @POST @Path("editPartition") @Produces(MediaType.APPLICATION_JSON) public Map editPartition(@FormParam("id") String id, - @FormParam("parName") String parName, - @FormParam("pgName") String pgName) throws Exception { + @FormParam("parName") String parName) throws Exception { Map resultMap = new HashMap(); String result = ""; @@ -128,25 +86,20 @@ PgPartition partition = new PgPartition(); try { - PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName); - if (pipeGallery == null) { - result = "false"; - msg = "不存在该管廊信息"; - } else { - if (pgPartitionManager.getPartitionByParName(parName, pipeGallery) != null) { + + if (pgPartitionManager.getPartitionByParName(parName) != null) { result = "false"; msg = "已存在相同分区"; } else { PgPartition pgPartition = pgPartitionManager.get(Long.valueOf(id)); pgPartition.setParName(parName); - pgPartition.setPipeGalleryId(pipeGallery); pgPartition.setActive(1); pgPartitionManager.save(pgPartition); result = "true"; msg = "编辑成功"; } - } + } catch (Exception e) { result = "false"; msg = "编辑失败"; @@ -194,5 +147,49 @@ return resultMap; } + /** + * 获取分区信息 + */ + @POST + @Path("getPartitionList") + @Produces(MediaType.APPLICATION_JSON) + public Map getPartition() throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + List pgPartitionDtoList = new ArrayList(); + try { + pgPartitionDtoList = pgPartitionManager.getPgPartitionDtoList(); + msg = "获取成功"; + } catch (Exception e) { + msg = "获取失败"; + e.printStackTrace(); + } + resultMap.put("msg", msg); + resultMap.put("result", pgPartitionDtoList); + return resultMap; + } + + /** + * 获取分区信息 + */ + @POST + @Path("getPartitionListByRoad") + @Produces(MediaType.APPLICATION_JSON) + public Map getPartitionListByRoad(@FormParam("road") String road) throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + List pgPartitionDtoList = new ArrayList(); + try { + pgPartitionDtoList = pgPartitionManager.getPartitionByRoad(road); + msg = "获取成功"; + } catch (Exception e) { + msg = "获取失败"; + e.printStackTrace(); + } + resultMap.put("msg", msg); + resultMap.put("result", pgPartitionDtoList); + return resultMap; + } + } diff --git a/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java b/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java index 7593027..8cbdb0a 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java @@ -96,8 +96,8 @@ String result = ""; String msg = ""; - PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName); - PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName, pipeGallery); + PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName); + PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName,pgPartition); if (pgPartition == null) { result = "false"; msg = "不存在管廊仓和分区信息"; @@ -118,7 +118,7 @@ pgPipeLine.setLayerNum(layerNum); pgPipeLine.setEnterDate(sdf.parse(enterDate)); pgPipeLine.setDiameter(diameter); - pgPipeLine.setPgPartitionId(pgPartition); + pgPipeLine.setPipeGalleryId(pipeGallery); pgPipeLine.setActive(1); pgPipeLineManager.save(pgPipeLine); @@ -158,8 +158,8 @@ String result = ""; String msg = ""; - PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName); - PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName, pipeGallery); + PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName); + PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName,pgPartition); if (pgPartition == null) { result = "false"; msg = "不存在管廊仓和分区信息"; @@ -179,7 +179,7 @@ pgPipeLine.setEnterDate(sdf.parse(enterDate)); pgPipeLine.setLayerNum(layerNum); pgPipeLine.setDiameter(diameter); - pgPipeLine.setPgPartitionId(pgPartition); + pgPipeLine.setPipeGalleryId(pipeGallery); pgPipeLine.setActive(1); pgPipeLineManager.save(pgPipeLine); diff --git a/src/main/java/com/casic/PgInterface/rs/PgTextureRs.java b/src/main/java/com/casic/PgInterface/rs/PgTextureRs.java index 1557b38..5892127 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgTextureRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgTextureRs.java @@ -95,8 +95,10 @@ String msg = ""; PgTexture pgTexture = new PgTexture(); - PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName); - PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName, pipeGallery); + + PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName); + PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName,pgPartition); + if (pgPartition == null) { result = "false"; msg = "不存在管廊仓和分区信息"; @@ -113,7 +115,7 @@ pgTexture.setLayerNum(layerNum); pgTexture.setOwnerUnit(ownerUnit); pgTexture.setBuildDate(sdf.parse(buildDate)); - pgTexture.setPgPartitionId(pgPartition); + pgTexture.setPipeGalleryId(pipeGallery); pgTexture.setActive(1); pgTextureManager.save(pgTexture); @@ -154,8 +156,8 @@ String result = ""; String msg = ""; - PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName); - PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName, pipeGallery); + PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName); + PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName,pgPartition); if (pgPartition == null) { result = "false"; msg = "不存在管廊仓和分区信息"; @@ -173,6 +175,7 @@ pgTexture.setLayerNum(layerNum); pgTexture.setOwnerUnit(ownerUnit); pgTexture.setBuildDate(sdf.parse(buildDate)); + pgTexture.setPipeGalleryId(pipeGallery); pgTexture.setActive(1); pgTextureManager.save(pgTexture); diff --git a/src/main/java/com/casic/PgInterface/rs/PipeGalleryRs.java b/src/main/java/com/casic/PgInterface/rs/PipeGalleryRs.java index 52a7b71..6904b9f 100644 --- a/src/main/java/com/casic/PgInterface/rs/PipeGalleryRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PipeGalleryRs.java @@ -1,7 +1,9 @@ package com.casic.PgInterface.rs; +import com.casic.PgInterface.devTable.domain.PgPartition; import com.casic.PgInterface.devTable.domain.PipeGallery; import com.casic.PgInterface.devTable.dto.PipeGalleryDto; +import com.casic.PgInterface.devTable.manager.PgPartitionManager; import com.casic.PgInterface.devTable.manager.PipeGalleryManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -29,31 +31,16 @@ private PipeGalleryManager pipeGalleryManager; + private PgPartitionManager pgPartitionManager; + @Resource public void setPipeGalleryManager(PipeGalleryManager pipeGalleryManager) { this.pipeGalleryManager = pipeGalleryManager; } - /** - * 获取管廊信息 - */ - @POST - @Path("getPipeGallery") - @Produces(MediaType.APPLICATION_JSON) - public Map getPipeGallery() throws Exception { - Map resultMap = new HashMap(); - String msg = ""; - List pipeGalleryDtoList = new ArrayList(); - try { - pipeGalleryDtoList = pipeGalleryManager.getPIpeGalleryDtoList(); - msg = "获取成功"; - } catch (Exception e) { - msg = "获取失败"; - e.printStackTrace(); - } - resultMap.put("msg", msg); - resultMap.put("result", pipeGalleryDtoList); - return resultMap; + @Resource + public void setPgPartitionManager(PgPartitionManager pgPartitionManager) { + this.pgPartitionManager = pgPartitionManager; } /** @@ -62,24 +49,31 @@ @POST @Path("addPipeGallery") @Produces(MediaType.APPLICATION_JSON) - public Map addPipeGallery(@FormParam("pgName") String pgName) throws Exception { + public Map addPipeGallery(@FormParam("pgName") String pgName, + @FormParam("parName") String parName) throws Exception { Map resultMap = new HashMap(); String result = ""; String msg = ""; PipeGallery pipeGallery = new PipeGallery(); try { - if(pipeGalleryManager.getPipeGalleryByPgName(pgName)!=null) - { + PgPartition pgPartition=pgPartitionManager.getPartitionByParName(parName); + if(pgPartition==null) { result = "false"; - msg = "已存在相同管廊"; + msg = "不存在分区信息"; } else { - pipeGallery.setPgName(pgName); - pipeGallery.setActive(1); - logger.info("成功保存"); - pipeGalleryManager.save(pipeGallery); - result = "true"; - msg = "保存成功"; + if (pipeGalleryManager.getPipeGalleryByPgName(pgName,pgPartition) != null) { + result = "false"; + msg = "已存在相同管廊"; + } else { + pipeGallery.setPgName(pgName); + pipeGallery.setPgPartitionId(pgPartition); + pipeGallery.setActive(1); + logger.info("成功保存"); + pipeGalleryManager.save(pipeGallery); + result = "true"; + msg = "保存成功"; + } } } catch (Exception e) { result = "false"; @@ -92,6 +86,31 @@ return resultMap; } + /** + *获取分区下的管廊仓列表 + */ + @POST + @Path("getPiprGallerys") + @Produces(MediaType.APPLICATION_JSON) + public Map getPipeGalleryList(@FormParam("parName") String parName)throws Exception { + Map resultMap = new HashMap(); + String msg=""; + List pipeGalleryDtoList=new ArrayList(); + try { + pipeGalleryDtoList=pipeGalleryManager.getPipeGalleryByParName(parName); + if(pipeGalleryDtoList.size()==0) + msg="没有分区信息"; + else + msg="分区信息获取成功"; + }catch(Exception e){ + e.printStackTrace(); + msg="分区信息获取失败"; + } + resultMap.put("msg",msg); + resultMap.put("result",pipeGalleryDtoList); + return resultMap; + } + /* *编辑管廊信息 */ @@ -99,25 +118,28 @@ @Path("editPipeGallery") @Produces(MediaType.APPLICATION_JSON) public Map editPipeGallery(@FormParam("id") String id, - @FormParam("pgName") String pgName) throws Exception { + @FormParam("pgName") String pgName, + @FormParam("parName") String parName) throws Exception { Map resultMap = new HashMap(); String result = ""; String msg = ""; + PipeGallery pipeGallery=new PipeGallery(); try { - PipeGallery pipeGallery = pipeGalleryManager.get(Long.valueOf(id)); - if (pipeGallery == null) { + PgPartition pgPartition=pgPartitionManager.getPartitionByParName(parName); + if (pgPartition == null) { result = "false"; - msg = "不存在该管廊信息"; + msg = "不存在该分区信息"; } else { - if(pipeGalleryManager.getPipeGalleryByPgName(pgName)!=null) - { + if (pipeGalleryManager.getPipeGalleryByPgName(pgName, pgPartition) != null) { result = "false"; msg = "已存在相同管廊"; - } - else { + } else { + pipeGallery = pipeGalleryManager.get(Long.valueOf(id)); + pipeGallery.setPgName(pgName); + pipeGallery.setPgPartitionId(pgPartition); pipeGallery.setActive(1); pipeGalleryManager.save(pipeGallery); diff --git "a/\346\216\245\345\217\243\350\257\264\346\230\216.docx" "b/\346\216\245\345\217\243\350\257\264\346\230\216.docx" index 681b604..18ec62a 100644 --- "a/\346\216\245\345\217\243\350\257\264\346\230\216.docx" +++ "b/\346\216\245\345\217\243\350\257\264\346\230\216.docx" Binary files differ diff --git a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java index 80625c7..d8f5e6b 100644 --- a/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java +++ b/src/main/java/com/casic/PgInterface/devData/domain/PgLocation.java @@ -43,9 +43,7 @@ this.intoTime = intoTime; } - @Column(name = "OUT_TIME") - public Date getOutTime() { return outTime; } diff --git a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java index a99981e..b1d63a4 100644 --- a/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java +++ b/src/main/java/com/casic/PgInterface/devData/manager/PgLocationManager.java @@ -1,11 +1,28 @@ package com.casic.PgInterface.devData.manager; +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.core.util.DateUtils; +import com.casic.PgInterface.core.util.StringUtils; +import com.casic.PgInterface.devData.domain.PgCo; +import com.casic.PgInterface.devData.domain.PgLocation; +import com.casic.PgInterface.devData.dto.PgCoDto; +import com.casic.PgInterface.devData.dto.PgLocationDto; +import com.casic.PgInterface.devTable.domain.PgDevice; +import org.hibernate.Criteria; +import org.hibernate.criterion.Order; +import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; + /** * Created by yxw on 2017/11/2. */ @Service -public class PgLocationManager { +public class PgLocationManager extends HibernateEntityDao { + + //获取设备时间段内所有的监测数据 } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java index cfa0281..7fb5953 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -1,12 +1,12 @@ package com.casic.PgInterface.devTable.domain; import com.casic.PgInterface.devData.domain.*; +import com.casic.PgInterface.patroler.domain.PgAlarmRule; import org.hibernate.annotations.NotFound; import org.hibernate.annotations.NotFoundAction; import javax.persistence.*; import java.io.Serializable; -import java.util.Date; import java.util.List; /** @@ -19,21 +19,27 @@ private static final long serialVersionUID = 1L; private long id; + private PipeGallery pipeGalleryId;//所在管廊信息 + private String road;//路名 + private String position;//设备位置 + private String devType;//设备类型 private String devCode;//设备编号 - private String devName;//设备名称 - private String brand;//品牌 - private String ownerUnit;//权属单位 - private Date installDate;//安装时间 + private String assetName;//资产名称 + private String assetCode;//资产编码 + private String assetBarCode;//资产条码 + private String ip;//IP地址 + private String modBus;//modBus地址 + private String mome;//备注 private int isOpen;//设备是否开启 private int active;//状态位 - private PgDeviceType devTypeId;//设备类型 + private List pgAlarms; - private PgPartition pgPartitionId;//所在管廊信息 private List pgTempHums;//温湿度 private List pgCos;//一氧化碳 private List pgO2s;//氧气 private List pgCh4s;//甲烷 private List pgShs;//硫化氢 + private List pgAlarmRules;//报警规则 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") @@ -45,6 +51,33 @@ this.id = id; } + @Column(name = "ROAD") + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + @Column(name = "POSITION") + public String getPosition() { + return position; + } + + public void setPosition(String position) { + this.position = position; + } + + @Column(name = "DEV_TYPE") + public String getDevType() { + return devType; + } + + public void setDevType(String devType) { + this.devType = devType; + } + @Column(name = "DEV_CODE") public String getDevCode() { return devCode; @@ -54,40 +87,58 @@ this.devCode = devCode; } - @Column(name = "DEV_NAME") - public String getDevName() { - return devName; + @Column(name = "ASSET_NAME") + public String getAssetName() { + return assetName; } - public void setDevName(String devName) { - this.devName = devName; + public void setAssetName(String assetName) { + this.assetName = assetName; } - @Column(name = "BRAND") - public String getBrand() { - return brand; + @Column(name = "ASSET_CODE") + public String getAssetCode() { + return assetCode; } - public void setBrand(String brand) { - this.brand = brand; + public void setAssetCode(String assetCode) { + this.assetCode = assetCode; } - @Column(name = "OWNERUNIT") - public String getOwnerUnit() { - return ownerUnit; + @Column(name = "ASSET_BAR_CODE") + public String getAssetBarCode() { + return assetBarCode; } - public void setOwnerUnit(String ownerUnit) { - this.ownerUnit = ownerUnit; + public void setAssetBarCode(String assetBarCode) { + this.assetBarCode = assetBarCode; } - @Column(name = "INSTALDATE") - public Date getInstallDate() { - return installDate; + @Column(name = "IP") + public String getIp() { + return ip; } - public void setInstallDate(Date installDate) { - this.installDate = installDate; + public void setIp(String ip) { + this.ip = ip; + } + + @Column(name = "MODBUS") + public String getModBus() { + return modBus; + } + + public void setModBus(String modBus) { + this.modBus = modBus; + } + + @Column(name = "MOME") + public String getMome() { + return mome; + } + + public void setMome(String mome) { + this.mome = mome; } @Column(name = "ISOPEN") @@ -119,24 +170,13 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; - } - - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "DEVICE_TYPE_ID") - public PgDeviceType getDevTypeId() { - return devTypeId; - } - - public void setDevTypeId(PgDeviceType devTypeId) { - this.devTypeId = devTypeId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgDeviceId") @@ -184,4 +224,13 @@ this.pgShs = pgShs; } + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgDeviceId") + public List getPgAlarmRules() { + return pgAlarmRules; + } + + public void setPgAlarmRules(List pgAlarmRules) { + this.pgAlarmRules = pgAlarmRules; + } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java index b997b29..4fb3d6f 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java @@ -1,8 +1,5 @@ package com.casic.PgInterface.devTable.domain; -import org.hibernate.annotations.NotFound; -import org.hibernate.annotations.NotFoundAction; - import javax.persistence.*; import java.io.Serializable; import java.util.List; @@ -19,11 +16,9 @@ private long id; private String parName;//分区名称 - private PipeGallery pipeGalleryId;//管廊仓 + private String road;//所属道路 private int active;//状态位 - private List pgTextureList; - private List pgPipeLineList; - private List pgDeviceList; + private List pipeGalleryList;//管廊仓 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PARTITION_ID") @@ -44,6 +39,15 @@ this.parName = parName; } + @Column(name = "ROAD") + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + @Column(name = "ACTIVE") public int getActive() { return active; @@ -53,41 +57,14 @@ this.active = active; } - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PIPEGALLERYID") - public PipeGallery getPipeGalleryId() { - return pipeGalleryId; - } - - public void setPipeGalleryId(PipeGallery pipeGalleryId) { - this.pipeGalleryId = pipeGalleryId; - } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgTextureList() { - return pgTextureList; + public List getPipeGalleryList() { + return pipeGalleryList; } - public void setPgTextureList(List pgTextureList) { - this.pgTextureList = pgTextureList; + public void setPipeGalleryList(List pipeGalleryList) { + this.pipeGalleryList = pipeGalleryList; } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgPipeLineList() { - return pgPipeLineList; - } - public void setPgPipeLineList(List pgPipeLineList) { - this.pgPipeLineList = pgPipeLineList; - } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgPartitionId") - public List getPgDeviceList() { - return pgDeviceList; - } - - public void setPgDeviceList(List pgDeviceList) { - this.pgDeviceList = pgDeviceList; - } } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java index d936d18..e5ff9b3 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPipeLine.java @@ -22,7 +22,7 @@ private Date enterDate;//入廊时间 private String layerNum;//所在层数 private String diameter;//管径 - private PgPartition pgPartitionId;//所在管廊信息 + private PipeGallery pipeGalleryId;//所在管廊信息 private int active;//状态位 @Id @@ -100,12 +100,12 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java index 1f22bf9..4ebfbda 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgTexture.java @@ -21,7 +21,7 @@ private String ownerUnit;//权属单位 private Date buildDate;//建设年代 private int active;//状态位 - private PgPartition pgPartitionId;//所在管廊信息 + private PipeGallery pipeGalleryId;//所在管廊信息 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_TEXTURE_ID") @@ -91,12 +91,13 @@ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PARID") - public PgPartition getPgPartitionId() { - return pgPartitionId; + @JoinColumn(name = "PGID") + public PipeGallery getPipeGalleryId() { + return pipeGalleryId; } - public void setPgPartitionId(PgPartition pgPartitionId) { - this.pgPartitionId = pgPartitionId; + public void setPipeGalleryId(PipeGallery pipeGalleryId) { + this.pipeGalleryId = pipeGalleryId; } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java b/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java index 49a246c..650d623 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PipeGallery.java @@ -1,5 +1,8 @@ package com.casic.PgInterface.devTable.domain; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + import javax.persistence.*; import java.io.Serializable; import java.util.List; @@ -16,7 +19,10 @@ private long id; private String pgName;//管廊名称 private int active;//状态位 - private List partitionList; + private PgPartition pgPartitionId;// + private List pgTextureList; + private List pgPipeLineList; + private List pgDeviceList; @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PIPE_GALLERY_ID") @@ -46,12 +52,42 @@ this.active = active; } - @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") - public List getPartitionList() { - return partitionList; + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "PARTITIONID") + public PgPartition getPgPartitionId() { + return pgPartitionId; } - public void setPartitionList(List partitionList) { - this.partitionList = partitionList; + public void setPgPartitionId(PgPartition pgPartitionId) { + this.pgPartitionId = pgPartitionId; } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgTextureList() { + return pgTextureList; + } + + public void setPgTextureList(List pgTextureList) { + this.pgTextureList = pgTextureList; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgPipeLineList() { + return pgPipeLineList; + } + + public void setPgPipeLineList(List pgPipeLineList) { + this.pgPipeLineList = pgPipeLineList; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId") + public List getPgDeviceList() { + return pgDeviceList; + } + + public void setPgDeviceList(List pgDeviceList) { + this.pgDeviceList = pgDeviceList; + } + } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java index b4048d9..c3dfc55 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgAlarmDto.java @@ -101,18 +101,17 @@ this.active = active; } - public PgAlarmDto(PgAlarm pgAlarm) - { - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + public PgAlarmDto(PgAlarm pgAlarm) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); this.setId(String.valueOf(pgAlarm.getId())); this.setAlarmType(pgAlarm.getAlarmTypeId().getAlarmType()); this.setAlarmValue(pgAlarm.getAlarmValue()); this.setAlarmDate(sdf.format(pgAlarm.getAlarmDate())); this.setDescription(pgAlarm.getDescription()); - this.setAlarmDevName(pgAlarm.getAlarmDevId().getDevName()); - this.setAlarmLocation(pgAlarm.getAlarmDevId().getPgPartitionId().getPipeGalleryId().getPgName() - + pgAlarm.getAlarmDevId().getPgPartitionId().getParName()); + this.setAlarmDevName(pgAlarm.getAlarmDevId().getAssetName()); + this.setAlarmLocation(pgAlarm.getAlarmDevId().getPipeGalleryId().getPgPartitionId().getParName() + + pgAlarm.getAlarmDevId().getPipeGalleryId().getPgName()); this.setUserName(pgAlarm.getPatrolerId().getUserName()); this.setPhoneNumber(pgAlarm.getPatrolerId().getPhoneNumber()); this.setActive(String.valueOf(pgAlarm.getActive())); diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java index ae76e95..49bd436 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java @@ -11,16 +11,20 @@ public class PgDeviceDto implements Serializable { private String id; - private String devType;//设备类型 - private String devCode;//设备编号 - private String devName;//设备名称 - private String brand;//品牌 - private String ownerUnit;//权属单位 - private String installDate;//安装时间 - private String isOpen;//设备开启状态 - private String active;//状态位 private String pipeGallery;//仓位 private String partition;//分区 + private String road;//路名 + private String position;//设备位置 + private String devType;//设备类型 + private String devCode;//设备编号 + private String assetName;//资产名称 + private String assetCode;//资产名称 + private String assetBarCode;//资产条码 + private String ip;//IP地址 + private String modBus;//modBus地址 + private String mome;//备注 + private String isOpen;//设备开启状态 + private String active;//状态位 public String getId() { return id; @@ -30,6 +34,38 @@ this.id = id; } + public String getPartition() { + return partition; + } + + public void setPartition(String partition) { + this.partition = partition; + } + + public String getPipeGallery() { + return pipeGallery; + } + + public void setPipeGallery(String pipeGallery) { + this.pipeGallery = pipeGallery; + } + + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + + public String getPosition() { + return position; + } + + public void setPosition(String position) { + this.position = position; + } + public String getDevType() { return devType; } @@ -46,36 +82,52 @@ this.devCode = devCode; } - public String getDevName() { - return devName; + public String getAssetName() { + return assetName; } - public void setDevName(String devName) { - this.devName = devName; + public void setAssetName(String assetName) { + this.assetName = assetName; } - public String getBrand() { - return brand; + public String getAssetCode() { + return assetCode; } - public void setBrand(String brand) { - this.brand = brand; + public void setAssetCode(String assetCode) { + this.assetCode = assetCode; } - public String getOwnerUnit() { - return ownerUnit; + public String getAssetBarCode() { + return assetBarCode; } - public void setOwnerUnit(String ownerUnit) { - this.ownerUnit = ownerUnit; + public void setAssetBarCode(String assetBarCode) { + this.assetBarCode = assetBarCode; } - public String getInstallDate() { - return installDate; + public String getIp() { + return ip; } - public void setInstallDate(String installDate) { - this.installDate = installDate; + public void setIp(String ip) { + this.ip = ip; + } + + public String getModBus() { + return modBus; + } + + public void setModBus(String modBus) { + this.modBus = modBus; + } + + public String getMome() { + return mome; + } + + public void setMome(String mome) { + this.mome = mome; } public String getIsOpen() { @@ -94,39 +146,26 @@ this.active = active; } - public String getPipeGallery() { - return pipeGallery; - } - - public void setPipeGallery(String pipeGallery) { - this.pipeGallery = pipeGallery; - } - - public String getPartition() { - return partition; - } - - public void setPartition(String partition) { - this.partition = partition; - } - public PgDeviceDto(PgDevice pgDevice) { SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); this.setId(String.valueOf(pgDevice.getId())); - this.setDevType(pgDevice.getDevTypeId().getDevType()); + this.setPipeGallery(pgDevice.getPipeGalleryId().getPgName()); + this.setPartition(pgDevice.getPipeGalleryId().getPgPartitionId().getParName()); + this.setRoad(pgDevice.getRoad()); + this.setPosition(pgDevice.getPosition()); + this.setDevType(pgDevice.getDevType()); this.setDevCode(pgDevice.getDevCode()); - this.setDevName(pgDevice.getDevName()); - this.setBrand(pgDevice.getBrand()); - this.setOwnerUnit(pgDevice.getOwnerUnit()); - this.setInstallDate(sdf.format(pgDevice.getInstallDate())); + this.setAssetName(pgDevice.getAssetName()); + this.setAssetCode(pgDevice.getAssetCode()); + this.setAssetBarCode(pgDevice.getAssetBarCode()); + this.setId(pgDevice.getIp()); + this.setModBus(pgDevice.getModBus()); + this.setMome(pgDevice.getMome()); this.setIsOpen(String.valueOf(pgDevice.getIsOpen())); this.setActive(String.valueOf(pgDevice.getActive())); - this.setPipeGallery(pgDevice.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgDevice.getPgPartitionId().getParName()); + } - -} - +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java index e8751d3..3acd0fa 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java @@ -11,7 +11,7 @@ private String id; private String parName;//分区名称 - private String pipeGallery;//管廊仓 + private String road;//所属道路 private String active;//状态位 @@ -31,14 +31,6 @@ this.parName = parName; } - public String getPipeGallery() { - return pipeGallery; - } - - public void setPipeGallery(String pipeGallery) { - this.pipeGallery = pipeGallery; - } - public String getActive() { return active; } @@ -47,11 +39,19 @@ this.active = active; } + public String getRoad() { + return road; + } + + public void setRoad(String road) { + this.road = road; + } + public PgPartitionDto(PgPartition pgPartition) { this.setId(String.valueOf(pgPartition.getId())); this.setParName(pgPartition.getParName()); - this.setPipeGallery(pgPartition.getPipeGalleryId().getPgName()); + this.setRoad(pgPartition.getRoad()); this.setActive(String.valueOf(pgPartition.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java index 9b161bf..8b430dc 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPipeLineDto.java @@ -112,8 +112,8 @@ this.setEnterDate(sdf.format(pgPipeLine.getEnterDate())); this.setLayerNum(pgPipeLine.getLayerNum()); this.setDiameter(pgPipeLine.getDiameter()); - this.setPipeGallery(pgPipeLine.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgPipeLine.getPgPartitionId().getParName()); + this.setPipeGallery(pgPipeLine.getPipeGalleryId().getPgName()); + this.setPartition(pgPipeLine.getPipeGalleryId().getPgPartitionId().getParName()); this.setActive(String.valueOf(pgPipeLine.getActive())); } } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java index 03c580c..709dcea 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgTextureDto.java @@ -103,8 +103,8 @@ this.setOwnerUnit(pgTexture.getOwnerUnit()); this.setBuildDate(sdf.format(pgTexture.getBuildDate())); this.setActive(String.valueOf(pgTexture.getActive())); - this.setPipeGallery(pgTexture.getPgPartitionId().getPipeGalleryId().getPgName()); - this.setPartition(pgTexture.getPgPartitionId().getParName()); + this.setPipeGallery(pgTexture.getPipeGalleryId().getPgName()); + this.setPartition(pgTexture.getPipeGalleryId().getPgPartitionId().getParName()); } } diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java index b40ce84..319cf21 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PipeGalleryDto.java @@ -11,6 +11,7 @@ private String id; private String pgName;//管廊名称 + private String pgPartition;//分区名称 private String active;//状态位 public String getId() { @@ -37,10 +38,19 @@ this.active = active; } + public String getPgPartition() { + return pgPartition; + } + + public void setPgPartition(String pgPartition) { + this.pgPartition = pgPartition; + } + public PipeGalleryDto(PipeGallery pipeGallery) { this.setId(String.valueOf(pipeGallery.getId())); this.setPgName(pipeGallery.getPgName()); + this.setPgPartition(pipeGallery.getPgPartitionId().getParName()); this.setActive(String.valueOf(pipeGallery.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java b/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java index 8b413e7..0c594e7 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java @@ -5,10 +5,10 @@ import com.casic.PgInterface.devTable.domain.PipeGallery; import com.casic.PgInterface.devTable.dto.PgPartitionDto; import org.hibernate.Criteria; +import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; -import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; @@ -18,44 +18,50 @@ @Service public class PgPartitionManager extends HibernateEntityDao { - private PipeGalleryManager pipeGalleryManager; - - @Resource - public void setPipeGalleryManager(PipeGalleryManager pipeGalleryManager) { - this.pipeGalleryManager = pipeGalleryManager; - } - - public PgPartition getPartitionByParName(String parName,PipeGallery pipeGallery) { - if(pipeGallery==null) - return null; - Criteria criteria = getSession().createCriteria(PgPartition.class); + public PgPartition getPartitionByParName(String parName) { + Criteria criteria = getSession().createCriteria(PipeGallery.class); criteria.add(Restrictions.eq("parName", parName)); - criteria.add(Restrictions.eq("pipeGalleryId",pipeGallery)); + criteria.add(Restrictions.eq("active",1)); List pgPartitionList = criteria.list(); - //TODO LIST:为空判断 pgPartitionList==null? if (pgPartitionList != null && pgPartitionList.size() > 0) return pgPartitionList.get(0); else return null; } - public List getPartitionByPG(String pgName){ - PipeGallery pipeGallery=pipeGalleryManager.getPipeGalleryByPgName(pgName); - - Criteria criteria=getSession().createCriteria(PgPartition.class); - criteria.add(Restrictions.eq("pipeGalleryId",pipeGallery)); + public List getPartitionByRoad(String road) { + Criteria criteria = getSession().createCriteria(PipeGallery.class); + criteria.add(Restrictions.eq("road", road)); + criteria.add(Restrictions.eq("active",1)); List pgPartitionList = criteria.list(); List pgPartitionDtoList=new ArrayList(); - for(PgPartition pgPartition:pgPartitionList) - { - pgPartitionDtoList.add(new PgPartitionDto(pgPartition)); - } + for(PgPartition pgPartition:pgPartitionList) { + pgPartitionDtoList.add(new PgPartitionDto(pgPartition)); + } return pgPartitionDtoList; } + public List getPgPartitionDtoList() + { + Criteria criteria=getSession().createCriteria(PgPartition.class); + criteria.add(Restrictions.eq("active",1)); + criteria.addOrder(Order.desc("id")); + + List pgPartitionList=criteria.list(); + if(pgPartitionList.size()==0||pgPartitionList==null) + return null; + List pgPartitionDtoList=new ArrayList(); + for(PgPartition pgPartition:pgPartitionList) { + pgPartitionDtoList.add(new PgPartitionDto(pgPartition)); + } + return pgPartitionDtoList; + } + + + } diff --git a/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java b/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java index 16370c6..9bce32b 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PipeGalleryManager.java @@ -1,14 +1,16 @@ package com.casic.PgInterface.devTable.manager; import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.devTable.domain.PgPartition; import com.casic.PgInterface.devTable.domain.PipeGallery; import com.casic.PgInterface.devTable.dto.PipeGalleryDto; import org.hibernate.Criteria; -import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; -import java.util.*; +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; /** * Created by yxw on 2017/11/4. @@ -16,36 +18,44 @@ @Service public class PipeGalleryManager extends HibernateEntityDao { - public PipeGallery getPipeGalleryByPgName(String pgName) { - Criteria criteria = getSession().createCriteria(PipeGallery.class); + private PgPartitionManager pgPartitionManager; + + @Resource + public void setPgPartitionManager(PgPartitionManager pgPartitionManager) { + this.pgPartitionManager = pgPartitionManager; + } + + public PipeGallery getPipeGalleryByPgName(String pgName,PgPartition pgPartition) { + if(pgPartition==null) + return null; + Criteria criteria = getSession().createCriteria(PgPartition.class); criteria.add(Restrictions.eq("pgName", pgName)); - criteria.add(Restrictions.eq("active",1)); + criteria.add(Restrictions.eq("pgPartitionId",pgPartition)); List pipeGalleryList = criteria.list(); - //TODO LIST:为空判断 pipeGalleryList==null? + //TODO LIST:为空判断 pgPartitionList==null? if (pipeGalleryList != null && pipeGalleryList.size() > 0) return pipeGalleryList.get(0); else return null; } - public List getPIpeGalleryDtoList() - { - Criteria criteria=getSession().createCriteria(PipeGallery.class); - criteria.add(Restrictions.eq("active",1)); - criteria.addOrder(Order.desc("id")); - List pipeGalleryList=criteria.list(); - if(pipeGalleryList.size()==0||pipeGalleryList==null) - return null; - List pipeGalleryDtoList=new ArrayList(); - for(PipeGallery pipeGallery:pipeGalleryList) { + public List getPipeGalleryByParName(String parName) { + + PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName); + Criteria criteria = getSession().createCriteria(PipeGallery.class); + criteria.add(Restrictions.eq("pgPartitionId", pgPartition)); + + List pipeGalleryList = criteria.list(); + + List pipeGalleryDtoList = new ArrayList(); + for (PipeGallery pipeGallery : pipeGalleryList) { pipeGalleryDtoList.add(new PipeGalleryDto(pipeGallery)); } + return pipeGalleryDtoList; } - - } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java new file mode 100644 index 0000000..9d06235 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java @@ -0,0 +1,63 @@ +package com.casic.PgInterface.patroler.domain; + +import com.casic.PgInterface.devTable.domain.PgDevice; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + +import javax.persistence.*; +import java.io.Serializable; + +/** + * Created by yxw on 2017/12/14. + */ +@Entity +@Table(name = "PG_ALARM_RULE") +@SequenceGenerator(name = "SEQ_PG_ALARM_RULE_ID", sequenceName = "SEQ_PG_ALARM_RULE_ID",allocationSize=1,initialValue=1) +public class PgAlarmRule implements Serializable { + + private static final long serialVersionUID = 1L; + private long id; + private String highValue;//高限 + private String lowValue;//低限 + private PgDevice pgDeviceId;//设备 + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_ALARM_RULE_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "HIGHVALUE") + public String getHighValue() { + return highValue; + } + + public void setHighValue(String highValue) { + this.highValue = highValue; + } + + @Column(name = "LOWVALUE") + public String getLowValue() { + return lowValue; + } + + public void setLowValue(String lowValue) { + this.lowValue = lowValue; + } + + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "PGDEVICEID") + public PgDevice getPgDeviceId() { + return pgDeviceId; + } + + public void setPgDeviceId(PgDevice pgDeviceId) { + this.pgDeviceId = pgDeviceId; + } + +} diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java new file mode 100644 index 0000000..8367ad4 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java @@ -0,0 +1,57 @@ +package com.casic.PgInterface.patroler.dto; + +import com.casic.PgInterface.patroler.domain.PgAlarmRule; + +import java.io.Serializable; + +/** + * Created by yxw on 2017/12/14. + */ +public class PgAlarmRuleDto implements Serializable { + + private String id; + private String highValue;//高限 + private String lowValue;//低限 + private String devName;//设备 + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getHighValue() { + return highValue; + } + + public void setHighValue(String highValue) { + this.highValue = highValue; + } + + public String getLowValue() { + return lowValue; + } + + public void setLowValue(String lowValue) { + this.lowValue = lowValue; + } + + public String getDevName() { + return devName; + } + + public void setDevName(String devName) { + this.devName = devName; + } + + public PgAlarmRuleDto(PgAlarmRule pgAlarmRule) + { + this.setId(String.valueOf(pgAlarmRule.getId())); + this.setDevName(pgAlarmRule.getPgDeviceId().getAssetName()); + this.setHighValue(pgAlarmRule.getHighValue()); + this.setLowValue(pgAlarmRule.getLowValue()); + } + +} diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java new file mode 100644 index 0000000..d5c00b2 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java @@ -0,0 +1,42 @@ +package com.casic.PgInterface.patroler.manager; + +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.devTable.domain.PgDevice; +import com.casic.PgInterface.patroler.domain.PgAlarmRule; +import com.casic.PgInterface.patroler.dto.PgAlarmRuleDto; +import org.hibernate.Criteria; +import org.hibernate.criterion.Restrictions; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * Created by yxw on 2017/12/14. + */ +@Service +public class PgAlarmRuleManager extends HibernateEntityDao { + + //根据设备获取设备报警阈值 + public PgAlarmRuleDto getAlarmRuleDtoBydev(PgDevice pgDeviceId) { + Criteria criteria=createCriteria(PgAlarmRule.class); + criteria.add(Restrictions.eq("pgDeviceId", pgDeviceId)); + + List pgAlarmRuleList=criteria.list(); + if(pgAlarmRuleList.size()==0) + return null; + else + return new PgAlarmRuleDto(pgAlarmRuleList.get(0)); + } + + public PgAlarmRule getAlarmRuleBydev(PgDevice pgDeviceId) { + Criteria criteria=createCriteria(PgAlarmRule.class); + criteria.add(Restrictions.eq("pgDeviceId", pgDeviceId)); + + List pgAlarmRuleList=criteria.list(); + if(pgAlarmRuleList.size()==0) + return null; + else + return pgAlarmRuleList.get(0); + } + +} diff --git a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java new file mode 100644 index 0000000..88255c6 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java @@ -0,0 +1,162 @@ +package com.casic.PgInterface.rs; + +import com.casic.PgInterface.devTable.domain.PgDevice; +import com.casic.PgInterface.devTable.manager.PgDeviceManager; +import com.casic.PgInterface.patroler.domain.PgAlarmRule; +import com.casic.PgInterface.patroler.dto.PgAlarmRuleDto; +import com.casic.PgInterface.patroler.manager.PgAlarmRuleManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import javax.ws.rs.FormParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import java.util.HashMap; +import java.util.Map; + +/** + * Created by yxw on 2017/12/14. + */ +@Component +@Path("pgAlarmRule") +public class PgAlarmRuleRs { + + private static Logger logger = LoggerFactory.getLogger(PgAlarmRule.class); + + private PgDeviceManager pgDeviceManager; + + private PgAlarmRuleManager pgAlarmRuleManager; + + @Resource + public void setPgAlarmRuleManager(PgAlarmRuleManager pgAlarmRuleManager) { + this.pgAlarmRuleManager = pgAlarmRuleManager; + } + + @Resource + public void setPgDeviceManager(PgDeviceManager pgDeviceManager) { + this.pgDeviceManager = pgDeviceManager; + } + + /** + * 获取报警阈值信息 + */ + @POST + @Path("getAlarmRuleByAssetCode") + @Produces(MediaType.APPLICATION_JSON) + public Map getAlarmRuleByAssetCode(@FormParam("assetCode") String assetCode) throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + + PgAlarmRuleDto pgAlarmRuleDto = null; + PgDevice pgDevice = pgDeviceManager.getDeviceByAssetCode(assetCode); + try { + pgAlarmRuleDto = pgAlarmRuleManager.getAlarmRuleDtoBydev(pgDevice); + if (pgAlarmRuleDto == null) + msg = "不存在报警阈值信息"; + else + msg = "报警阈值获取成功"; + } catch (Exception e) { + e.printStackTrace(); + msg = "报警信息获取失败"; + } + resultMap.put("msg", msg); + resultMap.put("result", pgAlarmRuleDto); + return resultMap; + } + + /** + * 新增报警阈值 + */ + @POST + @Path("addAlarmRule") + @Produces(MediaType.APPLICATION_JSON) + public Map addAlarmRule(@FormParam("assetCode") String assetCode, + @FormParam("highValue") String highValue, + @FormParam("lowValue") String lowValue) throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + String result = ""; + + PgAlarmRule pgAlarmRule = null; + PgDevice pgDevice = pgDeviceManager.getDeviceByAssetCode(assetCode); + if (pgDevice == null) + msg = "不存在设备信息"; + else { + try { + pgAlarmRule = pgAlarmRuleManager.getAlarmRuleBydev(pgDevice); + if (pgAlarmRule != null) { + result = "false"; + msg = "设备阈值已经存在"; + } else { + pgAlarmRule = new PgAlarmRule(); + pgAlarmRule.setHighValue(highValue); + pgAlarmRule.setLowValue(lowValue); + pgAlarmRule.setPgDeviceId(pgDevice); + + pgAlarmRuleManager.save(pgAlarmRule); + result = "true"; + msg = "报警阈值新增成功"; + } + + } catch (Exception e) { + e.printStackTrace(); + result = "false"; + msg = "报警阈值新增失败"; + } + } + resultMap.put("msg", msg); + resultMap.put("result", result); + return resultMap; + } + + /** + * 编辑报警阈值 + */ + @POST + @Path("editAlarmRule") + @Produces(MediaType.APPLICATION_JSON) + public Map editAlarmRule(@FormParam("id") String id, + @FormParam("assetCode") String assetCode, + @FormParam("highValue") String highValue, + @FormParam("lowValue") String lowValue) throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + String result = ""; + + PgAlarmRule pgAlarmRule = null; + PgDevice pgDevice = pgDeviceManager.getDeviceByAssetCode(assetCode); + if (pgDevice == null) { + msg = "不存在设备信息"; + result = "false"; + } else { + try { + pgAlarmRule = pgAlarmRuleManager.get(id); + if (pgAlarmRule == null) { + msg="不存在报警阈值记录"; + result="false"; + } else { + pgAlarmRule.setPgDeviceId(pgDevice); + pgAlarmRule.setHighValue(highValue); + pgAlarmRule.setLowValue(lowValue); + pgAlarmRuleManager.save(pgAlarmRule); + msg="编辑成功"; + result="true"; + } + } catch (Exception ex) { + ex.printStackTrace(); + result = "false"; + msg = "报警阈值编辑失败"; + } + } + resultMap.put("msg", msg); + resultMap.put("result", result); + + return resultMap; + + } + +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java b/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java index 36a4fc5..4f77754 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java @@ -18,7 +18,6 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; -import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -65,14 +64,14 @@ * 获取设备信息 */ @POST - @Path("getPgDeviceByName") + @Path("getPgDeviceByAssetCode") @Produces(MediaType.APPLICATION_JSON) - public Map getPgDeviceByName(@FormParam("devName") String devName) throws Exception { + public Map getPgDeviceByAssetCode(@FormParam("assetCode") String assetCode) throws Exception { Map resultMap = new HashMap(); String msg = ""; PgDeviceDto pgDeviceDto=null; try { - PgDevice pgDevice = pgDeviceManager.getDeviceBydevName(devName); + PgDevice pgDevice = pgDeviceManager.getDeviceByAssetCode(assetCode); pgDeviceDto=new PgDeviceDto(pgDevice); msg = "获取成功"; } catch (Exception e) { @@ -84,7 +83,6 @@ return resultMap; } - /** * 显示设备列表 */ @@ -116,42 +114,49 @@ @POST @Path("addDevice") @Produces(MediaType.APPLICATION_JSON) - public Map addDevice(@FormParam("devType") String devType, - @FormParam("devCode") String devCode, - @FormParam("devName") String devName, - @FormParam("brand") String brand, - @FormParam("ownerUnit") String ownerUnit, - @FormParam("installDate") String installDate, - @FormParam("pgName") String pgName, - @FormParam("parName") String parName) + public Map addDevice(@FormParam("parName") String parName, + @FormParam("pgName") String pgName, + @FormParam("road") String road, + @FormParam("position") String position, + @FormParam("devType") String devType, + @FormParam("devCode") String devCode, + @FormParam("assetName") String assetName, + @FormParam("assetCode") String assetCode, + @FormParam("assetBarCode") String assetBarCode, + @FormParam("ip") String ip, + @FormParam("modBus") String modBus, + @FormParam("mome") String mome) throws Exception { - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - Map resultMap = new HashMap(); String result = ""; String msg = ""; - PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName); - PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName, pipeGallery); + PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName); + PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName,pgPartition); + if (pgPartition == null) { result = "false"; msg = "不存在管廊仓和分区信息"; } else { try { - if (pgDeviceManager.getDeviceBydevName(devName)!=null) { + if (pgDeviceManager.getDeviceByAssetCode(assetCode)!=null) { result = "false"; msg = "已存在同名设备"; } else { PgDevice pgDevice = new PgDevice(); - pgDevice.setDevTypeId(pgDeviceTypeManager.getPgDeviceTypeByDevType(devType)); + pgDevice.setPipeGalleryId(pipeGallery); + pgDevice.setRoad(road); + pgDevice.setPosition(position); + pgDevice.setDevType(devType); pgDevice.setDevCode(devCode); - pgDevice.setDevName(devName); - pgDevice.setBrand(brand); - pgDevice.setOwnerUnit(ownerUnit); - pgDevice.setInstallDate(sdf.parse(installDate)); - pgDevice.setPgPartitionId(pgPartition); + pgDevice.setAssetName(assetName); + pgDevice.setAssetCode(assetCode); + pgDevice.setAssetBarCode(assetBarCode); + pgDevice.setIp(ip); + pgDevice.setModBus(modBus); + pgDevice.setMome(mome); pgDevice.setIsOpen(0); pgDevice.setActive(1); @@ -179,41 +184,49 @@ @Path("editDevice") @Produces(MediaType.APPLICATION_JSON) public Map editPartition(@FormParam("id") String id, + @FormParam("parName") String parName, + @FormParam("pgName") String pgName, + @FormParam("road") String road, + @FormParam("position") String position, @FormParam("devType") String devType, @FormParam("devCode") String devCode, - @FormParam("devName") String devName, - @FormParam("brand") String brand, - @FormParam("ownerUnit") String ownerUnit, - @FormParam("installDate") String installDate, - @FormParam("pgName") String pgName, - @FormParam("parName") String parName, + @FormParam("assetName") String assetName, + @FormParam("assetCode") String assetCode, + @FormParam("assetBarCode") String assetBarCode, + @FormParam("ip") String ip, + @FormParam("modBus") String modBus, + @FormParam("mome") String mome, @FormParam("isOpen") String isOpen) throws Exception { - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - Map resultMap = new HashMap(); String result = ""; String msg = ""; - PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName); - PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName, pipeGallery); + PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName); + PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName,pgPartition); + if (pgPartition == null) { result = "false"; msg = "不存在管廊仓和分区信息"; } else { try { - if (pgDeviceManager.getDeviceBydevName(devName)!=null) { + if (pgDeviceManager.getDeviceByAssetCode(assetCode)!=null) { result = "false"; msg = "已存在同名设备"; } else { PgDevice pgDevice = pgDeviceManager.get(Long.valueOf(id)); - pgDevice.setDevTypeId(pgDeviceTypeManager.getPgDeviceTypeByDevType(devType)); + pgDevice.setPipeGalleryId(pipeGallery); + pgDevice.setRoad(road); + pgDevice.setPosition(position); + pgDevice.setDevType(devType); pgDevice.setDevCode(devCode); - pgDevice.setDevName(devName); - pgDevice.setBrand(brand); - pgDevice.setOwnerUnit(ownerUnit); - pgDevice.setInstallDate(sdf.parse(installDate)); - pgDevice.setPgPartitionId(pgPartition); + pgDevice.setAssetName(assetName); + pgDevice.setAssetCode(assetCode); + pgDevice.setAssetBarCode(assetBarCode); + pgDevice.setIp(ip); + pgDevice.setModBus(modBus); + pgDevice.setMome(mome); + pgDevice.setActive(1); pgDevice.setIsOpen(Integer.valueOf(isOpen)); pgDeviceManager.save(pgDevice); diff --git a/src/main/java/com/casic/PgInterface/rs/PgLocationRs.java b/src/main/java/com/casic/PgInterface/rs/PgLocationRs.java new file mode 100644 index 0000000..e8daabc --- /dev/null +++ b/src/main/java/com/casic/PgInterface/rs/PgLocationRs.java @@ -0,0 +1,39 @@ +package com.casic.PgInterface.rs; + +import com.casic.PgInterface.devData.manager.PgLocationManager; +import com.casic.PgInterface.devTable.manager.PgDeviceManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import javax.ws.rs.Path; + +/** + * Created by yxw on 2017/12/11. + */ +@Component +@Path("location") +public class PgLocationRs { + + private static Logger logger = LoggerFactory.getLogger(PgLocationRs.class); + + private PgDeviceManager pgDeviceManager; + + private PgLocationManager pgLocationManager; + + @Resource + public void setPgDeviceManager(PgDeviceManager pgDeviceManager) { + this.pgDeviceManager = pgDeviceManager; + } + + @Resource + public void setPgLocationManager(PgLocationManager pgLocationManager) { + this.pgLocationManager = pgLocationManager; + } + + + + + +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java b/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java index 45fc210..8a42e7e 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java @@ -1,10 +1,8 @@ package com.casic.PgInterface.rs; import com.casic.PgInterface.devTable.domain.PgPartition; -import com.casic.PgInterface.devTable.domain.PipeGallery; import com.casic.PgInterface.devTable.dto.PgPartitionDto; import com.casic.PgInterface.devTable.manager.PgPartitionManager; -import com.casic.PgInterface.devTable.manager.PipeGalleryManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; @@ -29,8 +27,6 @@ private static Logger logger = LoggerFactory.getLogger(PgPartitionRs.class); - private PipeGalleryManager pipeGalleryManager; - private PgPartitionManager pgPartitionManager; @Resource @@ -38,38 +34,24 @@ this.pgPartitionManager = pgPartitionManager; } - @Resource - public void setPipeGalleryManager(PipeGalleryManager pipeGalleryManager) { - - this.pipeGalleryManager = pipeGalleryManager; - } - /** * 新增分区 */ @POST @Path("addPartition") @Produces(MediaType.APPLICATION_JSON) - public Map addAlarm(@FormParam("parName") String parName, - @FormParam("pgName") String pgName)throws Exception { + public Map addAlarm(@FormParam("parName") String parName)throws Exception { Map resultMap = new HashMap(); String result = ""; String msg = ""; try { - PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName); - - if (pipeGallery == null) { - result = "false"; - msg = "不存在" + pgName + "管廊仓"; - } else { - if (pgPartitionManager.getPartitionByParName(parName, pipeGallery) != null) { + if (pgPartitionManager.getPartitionByParName(parName) != null) { result = "false"; msg = "已存在相同分区"; } else { PgPartition pgPartition = new PgPartition(); pgPartition.setParName(parName); - pgPartition.setPipeGalleryId(pipeGallery); pgPartition.setActive(1); logger.info("成功保存"); @@ -77,7 +59,7 @@ result = "true"; msg = "保存成功"; } - } + } catch (Exception e) { result = "false"; msg = "保存失败"; @@ -89,37 +71,13 @@ return resultMap; } - /** - *获取管廊仓下的分区列表 - */ - @POST - @Path("getPartition") - @Produces(MediaType.APPLICATION_JSON) - public Map getPartitionList(@FormParam("pgName") String pgName)throws Exception { - Map resultMap = new HashMap(); - String msg=""; - List pgPartitionDtoList=new ArrayList(); - try { - pgPartitionDtoList=pgPartitionManager.getPartitionByPG(pgName); - if(pgPartitionDtoList.size()==0) - msg="没有分区信息"; - else - msg="分区信息获取成功"; - }catch(Exception e){ - e.printStackTrace(); - msg="分区信息获取失败"; - } - resultMap.put("msg",msg); - resultMap.put("result",pgPartitionDtoList); - return resultMap; - } + @POST @Path("editPartition") @Produces(MediaType.APPLICATION_JSON) public Map editPartition(@FormParam("id") String id, - @FormParam("parName") String parName, - @FormParam("pgName") String pgName) throws Exception { + @FormParam("parName") String parName) throws Exception { Map resultMap = new HashMap(); String result = ""; @@ -128,25 +86,20 @@ PgPartition partition = new PgPartition(); try { - PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName); - if (pipeGallery == null) { - result = "false"; - msg = "不存在该管廊信息"; - } else { - if (pgPartitionManager.getPartitionByParName(parName, pipeGallery) != null) { + + if (pgPartitionManager.getPartitionByParName(parName) != null) { result = "false"; msg = "已存在相同分区"; } else { PgPartition pgPartition = pgPartitionManager.get(Long.valueOf(id)); pgPartition.setParName(parName); - pgPartition.setPipeGalleryId(pipeGallery); pgPartition.setActive(1); pgPartitionManager.save(pgPartition); result = "true"; msg = "编辑成功"; } - } + } catch (Exception e) { result = "false"; msg = "编辑失败"; @@ -194,5 +147,49 @@ return resultMap; } + /** + * 获取分区信息 + */ + @POST + @Path("getPartitionList") + @Produces(MediaType.APPLICATION_JSON) + public Map getPartition() throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + List pgPartitionDtoList = new ArrayList(); + try { + pgPartitionDtoList = pgPartitionManager.getPgPartitionDtoList(); + msg = "获取成功"; + } catch (Exception e) { + msg = "获取失败"; + e.printStackTrace(); + } + resultMap.put("msg", msg); + resultMap.put("result", pgPartitionDtoList); + return resultMap; + } + + /** + * 获取分区信息 + */ + @POST + @Path("getPartitionListByRoad") + @Produces(MediaType.APPLICATION_JSON) + public Map getPartitionListByRoad(@FormParam("road") String road) throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + List pgPartitionDtoList = new ArrayList(); + try { + pgPartitionDtoList = pgPartitionManager.getPartitionByRoad(road); + msg = "获取成功"; + } catch (Exception e) { + msg = "获取失败"; + e.printStackTrace(); + } + resultMap.put("msg", msg); + resultMap.put("result", pgPartitionDtoList); + return resultMap; + } + } diff --git a/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java b/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java index 7593027..8cbdb0a 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java @@ -96,8 +96,8 @@ String result = ""; String msg = ""; - PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName); - PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName, pipeGallery); + PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName); + PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName,pgPartition); if (pgPartition == null) { result = "false"; msg = "不存在管廊仓和分区信息"; @@ -118,7 +118,7 @@ pgPipeLine.setLayerNum(layerNum); pgPipeLine.setEnterDate(sdf.parse(enterDate)); pgPipeLine.setDiameter(diameter); - pgPipeLine.setPgPartitionId(pgPartition); + pgPipeLine.setPipeGalleryId(pipeGallery); pgPipeLine.setActive(1); pgPipeLineManager.save(pgPipeLine); @@ -158,8 +158,8 @@ String result = ""; String msg = ""; - PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName); - PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName, pipeGallery); + PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName); + PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName,pgPartition); if (pgPartition == null) { result = "false"; msg = "不存在管廊仓和分区信息"; @@ -179,7 +179,7 @@ pgPipeLine.setEnterDate(sdf.parse(enterDate)); pgPipeLine.setLayerNum(layerNum); pgPipeLine.setDiameter(diameter); - pgPipeLine.setPgPartitionId(pgPartition); + pgPipeLine.setPipeGalleryId(pipeGallery); pgPipeLine.setActive(1); pgPipeLineManager.save(pgPipeLine); diff --git a/src/main/java/com/casic/PgInterface/rs/PgTextureRs.java b/src/main/java/com/casic/PgInterface/rs/PgTextureRs.java index 1557b38..5892127 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgTextureRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgTextureRs.java @@ -95,8 +95,10 @@ String msg = ""; PgTexture pgTexture = new PgTexture(); - PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName); - PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName, pipeGallery); + + PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName); + PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName,pgPartition); + if (pgPartition == null) { result = "false"; msg = "不存在管廊仓和分区信息"; @@ -113,7 +115,7 @@ pgTexture.setLayerNum(layerNum); pgTexture.setOwnerUnit(ownerUnit); pgTexture.setBuildDate(sdf.parse(buildDate)); - pgTexture.setPgPartitionId(pgPartition); + pgTexture.setPipeGalleryId(pipeGallery); pgTexture.setActive(1); pgTextureManager.save(pgTexture); @@ -154,8 +156,8 @@ String result = ""; String msg = ""; - PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName); - PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName, pipeGallery); + PgPartition pgPartition = pgPartitionManager.getPartitionByParName(parName); + PipeGallery pipeGallery = pipeGalleryManager.getPipeGalleryByPgName(pgName,pgPartition); if (pgPartition == null) { result = "false"; msg = "不存在管廊仓和分区信息"; @@ -173,6 +175,7 @@ pgTexture.setLayerNum(layerNum); pgTexture.setOwnerUnit(ownerUnit); pgTexture.setBuildDate(sdf.parse(buildDate)); + pgTexture.setPipeGalleryId(pipeGallery); pgTexture.setActive(1); pgTextureManager.save(pgTexture); diff --git a/src/main/java/com/casic/PgInterface/rs/PipeGalleryRs.java b/src/main/java/com/casic/PgInterface/rs/PipeGalleryRs.java index 52a7b71..6904b9f 100644 --- a/src/main/java/com/casic/PgInterface/rs/PipeGalleryRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PipeGalleryRs.java @@ -1,7 +1,9 @@ package com.casic.PgInterface.rs; +import com.casic.PgInterface.devTable.domain.PgPartition; import com.casic.PgInterface.devTable.domain.PipeGallery; import com.casic.PgInterface.devTable.dto.PipeGalleryDto; +import com.casic.PgInterface.devTable.manager.PgPartitionManager; import com.casic.PgInterface.devTable.manager.PipeGalleryManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -29,31 +31,16 @@ private PipeGalleryManager pipeGalleryManager; + private PgPartitionManager pgPartitionManager; + @Resource public void setPipeGalleryManager(PipeGalleryManager pipeGalleryManager) { this.pipeGalleryManager = pipeGalleryManager; } - /** - * 获取管廊信息 - */ - @POST - @Path("getPipeGallery") - @Produces(MediaType.APPLICATION_JSON) - public Map getPipeGallery() throws Exception { - Map resultMap = new HashMap(); - String msg = ""; - List pipeGalleryDtoList = new ArrayList(); - try { - pipeGalleryDtoList = pipeGalleryManager.getPIpeGalleryDtoList(); - msg = "获取成功"; - } catch (Exception e) { - msg = "获取失败"; - e.printStackTrace(); - } - resultMap.put("msg", msg); - resultMap.put("result", pipeGalleryDtoList); - return resultMap; + @Resource + public void setPgPartitionManager(PgPartitionManager pgPartitionManager) { + this.pgPartitionManager = pgPartitionManager; } /** @@ -62,24 +49,31 @@ @POST @Path("addPipeGallery") @Produces(MediaType.APPLICATION_JSON) - public Map addPipeGallery(@FormParam("pgName") String pgName) throws Exception { + public Map addPipeGallery(@FormParam("pgName") String pgName, + @FormParam("parName") String parName) throws Exception { Map resultMap = new HashMap(); String result = ""; String msg = ""; PipeGallery pipeGallery = new PipeGallery(); try { - if(pipeGalleryManager.getPipeGalleryByPgName(pgName)!=null) - { + PgPartition pgPartition=pgPartitionManager.getPartitionByParName(parName); + if(pgPartition==null) { result = "false"; - msg = "已存在相同管廊"; + msg = "不存在分区信息"; } else { - pipeGallery.setPgName(pgName); - pipeGallery.setActive(1); - logger.info("成功保存"); - pipeGalleryManager.save(pipeGallery); - result = "true"; - msg = "保存成功"; + if (pipeGalleryManager.getPipeGalleryByPgName(pgName,pgPartition) != null) { + result = "false"; + msg = "已存在相同管廊"; + } else { + pipeGallery.setPgName(pgName); + pipeGallery.setPgPartitionId(pgPartition); + pipeGallery.setActive(1); + logger.info("成功保存"); + pipeGalleryManager.save(pipeGallery); + result = "true"; + msg = "保存成功"; + } } } catch (Exception e) { result = "false"; @@ -92,6 +86,31 @@ return resultMap; } + /** + *获取分区下的管廊仓列表 + */ + @POST + @Path("getPiprGallerys") + @Produces(MediaType.APPLICATION_JSON) + public Map getPipeGalleryList(@FormParam("parName") String parName)throws Exception { + Map resultMap = new HashMap(); + String msg=""; + List pipeGalleryDtoList=new ArrayList(); + try { + pipeGalleryDtoList=pipeGalleryManager.getPipeGalleryByParName(parName); + if(pipeGalleryDtoList.size()==0) + msg="没有分区信息"; + else + msg="分区信息获取成功"; + }catch(Exception e){ + e.printStackTrace(); + msg="分区信息获取失败"; + } + resultMap.put("msg",msg); + resultMap.put("result",pipeGalleryDtoList); + return resultMap; + } + /* *编辑管廊信息 */ @@ -99,25 +118,28 @@ @Path("editPipeGallery") @Produces(MediaType.APPLICATION_JSON) public Map editPipeGallery(@FormParam("id") String id, - @FormParam("pgName") String pgName) throws Exception { + @FormParam("pgName") String pgName, + @FormParam("parName") String parName) throws Exception { Map resultMap = new HashMap(); String result = ""; String msg = ""; + PipeGallery pipeGallery=new PipeGallery(); try { - PipeGallery pipeGallery = pipeGalleryManager.get(Long.valueOf(id)); - if (pipeGallery == null) { + PgPartition pgPartition=pgPartitionManager.getPartitionByParName(parName); + if (pgPartition == null) { result = "false"; - msg = "不存在该管廊信息"; + msg = "不存在该分区信息"; } else { - if(pipeGalleryManager.getPipeGalleryByPgName(pgName)!=null) - { + if (pipeGalleryManager.getPipeGalleryByPgName(pgName, pgPartition) != null) { result = "false"; msg = "已存在相同管廊"; - } - else { + } else { + pipeGallery = pipeGalleryManager.get(Long.valueOf(id)); + pipeGallery.setPgName(pgName); + pipeGallery.setPgPartitionId(pgPartition); pipeGallery.setActive(1); pipeGalleryManager.save(pipeGallery); diff --git "a/\346\216\245\345\217\243\350\257\264\346\230\216.docx" "b/\346\216\245\345\217\243\350\257\264\346\230\216.docx" index 681b604..18ec62a 100644 --- "a/\346\216\245\345\217\243\350\257\264\346\230\216.docx" +++ "b/\346\216\245\345\217\243\350\257\264\346\230\216.docx" Binary files differ diff --git "a/\347\256\241\345\273\212\346\225\260\346\215\256\345\272\223\350\256\276\350\256\241\350\257\264\346\230\216.docx" "b/\347\256\241\345\273\212\346\225\260\346\215\256\345\272\223\350\256\276\350\256\241\350\257\264\346\230\216.docx" index 371f1a3..966901a 100644 --- "a/\347\256\241\345\273\212\346\225\260\346\215\256\345\272\223\350\256\276\350\256\241\350\257\264\346\230\216.docx" +++ "b/\347\256\241\345\273\212\346\225\260\346\215\256\345\272\223\350\256\276\350\256\241\350\257\264\346\230\216.docx" Binary files differ