diff --git a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java b/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java deleted file mode 100644 index b2affe5..0000000 --- a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.casic.PgInterface.devData.dto; - -/** - * Created by yxw on 2017/11/28. - */ -public class PgTempHunDto { -} diff --git a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java b/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java deleted file mode 100644 index b2affe5..0000000 --- a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.casic.PgInterface.devData.dto; - -/** - * Created by yxw on 2017/11/28. - */ -public class PgTempHunDto { -} 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 eb1f7ab..da8f617 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -39,7 +39,6 @@ private List pgShs; private List pgTempHums; - @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") public long getId() { diff --git a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java b/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java deleted file mode 100644 index b2affe5..0000000 --- a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.casic.PgInterface.devData.dto; - -/** - * Created by yxw on 2017/11/28. - */ -public class PgTempHunDto { -} 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 eb1f7ab..da8f617 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -39,7 +39,6 @@ private List pgShs; private List pgTempHums; - @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") public long getId() { diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java index 4278dc1..669b60f 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java @@ -2,21 +2,20 @@ import javax.persistence.*; import java.io.Serializable; -import java.util.List; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Entity @Table(name = "PG_DEVICE_TYPE") @SequenceGenerator(name = "SEQ_PG_DEVICE_TYPE_ID", sequenceName = "SEQ_PG_DEVICE_TYPE_ID", allocationSize = 1, initialValue = 1) public class PgDeviceType implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; private long id; private String devType; private int active; - private List pgDeviceList; + @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_TYPE_ID") @@ -45,13 +44,4 @@ public void setActive(int active) { this.active = active; } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "devTypeId") - public List getPgDeviceList() { - return pgDeviceList; - } - - public void setPgDeviceList(List pgDeviceList) { - this.pgDeviceList = pgDeviceList; - } } diff --git a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java b/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java deleted file mode 100644 index b2affe5..0000000 --- a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.casic.PgInterface.devData.dto; - -/** - * Created by yxw on 2017/11/28. - */ -public class PgTempHunDto { -} 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 eb1f7ab..da8f617 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -39,7 +39,6 @@ private List pgShs; private List pgTempHums; - @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") public long getId() { diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java index 4278dc1..669b60f 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java @@ -2,21 +2,20 @@ import javax.persistence.*; import java.io.Serializable; -import java.util.List; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Entity @Table(name = "PG_DEVICE_TYPE") @SequenceGenerator(name = "SEQ_PG_DEVICE_TYPE_ID", sequenceName = "SEQ_PG_DEVICE_TYPE_ID", allocationSize = 1, initialValue = 1) public class PgDeviceType implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; private long id; private String devType; private int active; - private List pgDeviceList; + @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_TYPE_ID") @@ -45,13 +44,4 @@ public void setActive(int active) { this.active = active; } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "devTypeId") - public List getPgDeviceList() { - return pgDeviceList; - } - - public void setPgDeviceList(List pgDeviceList) { - this.pgDeviceList = pgDeviceList; - } } 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 4fb3d6f..d209733 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java @@ -2,6 +2,7 @@ import javax.persistence.*; import java.io.Serializable; +import java.util.Date; import java.util.List; /** @@ -17,6 +18,12 @@ private long id; private String parName;//分区名称 private String road;//所属道路 + private String pgPosition;//仓段位置 + private String pgNum;//仓位数量 + private String pgType;//仓位类型 + private String pgLength;//分区长度 + private Date buildDate;//建设年代 + private String material;//建设材质 private int active;//状态位 private List pipeGalleryList;//管廊仓 @@ -48,6 +55,60 @@ this.road = road; } + @Column(name = "PGPOSITION") + public String getPgPosition() { + return pgPosition; + } + + public void setPgPosition(String pgPosition) { + this.pgPosition = pgPosition; + } + + @Column(name = "PGNUM") + public String getPgNum() { + return pgNum; + } + + public void setPgNum(String pgNum) { + this.pgNum = pgNum; + } + + @Column(name = "PGTYPE") + public String getPgType() { + return pgType; + } + + public void setPgType(String pgType) { + this.pgType = pgType; + } + + @Column(name = "PGLENGTH") + public String getPgLength() { + return pgLength; + } + + public void setPgLength(String pgLength) { + this.pgLength = pgLength; + } + + @Column(name = "BUILDDATE") + public Date getBuildDate() { + return buildDate; + } + + public void setBuildDate(Date buildDate) { + this.buildDate = buildDate; + } + + @Column(name = "MATERIAL") + public String getMaterial() { + return material; + } + + public void setMaterial(String material) { + this.material = material; + } + @Column(name = "ACTIVE") public int getActive() { return active; diff --git a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java b/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java deleted file mode 100644 index b2affe5..0000000 --- a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.casic.PgInterface.devData.dto; - -/** - * Created by yxw on 2017/11/28. - */ -public class PgTempHunDto { -} 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 eb1f7ab..da8f617 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -39,7 +39,6 @@ private List pgShs; private List pgTempHums; - @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") public long getId() { diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java index 4278dc1..669b60f 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java @@ -2,21 +2,20 @@ import javax.persistence.*; import java.io.Serializable; -import java.util.List; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Entity @Table(name = "PG_DEVICE_TYPE") @SequenceGenerator(name = "SEQ_PG_DEVICE_TYPE_ID", sequenceName = "SEQ_PG_DEVICE_TYPE_ID", allocationSize = 1, initialValue = 1) public class PgDeviceType implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; private long id; private String devType; private int active; - private List pgDeviceList; + @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_TYPE_ID") @@ -45,13 +44,4 @@ public void setActive(int active) { this.active = active; } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "devTypeId") - public List getPgDeviceList() { - return pgDeviceList; - } - - public void setPgDeviceList(List pgDeviceList) { - this.pgDeviceList = pgDeviceList; - } } 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 4fb3d6f..d209733 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java @@ -2,6 +2,7 @@ import javax.persistence.*; import java.io.Serializable; +import java.util.Date; import java.util.List; /** @@ -17,6 +18,12 @@ private long id; private String parName;//分区名称 private String road;//所属道路 + private String pgPosition;//仓段位置 + private String pgNum;//仓位数量 + private String pgType;//仓位类型 + private String pgLength;//分区长度 + private Date buildDate;//建设年代 + private String material;//建设材质 private int active;//状态位 private List pipeGalleryList;//管廊仓 @@ -48,6 +55,60 @@ this.road = road; } + @Column(name = "PGPOSITION") + public String getPgPosition() { + return pgPosition; + } + + public void setPgPosition(String pgPosition) { + this.pgPosition = pgPosition; + } + + @Column(name = "PGNUM") + public String getPgNum() { + return pgNum; + } + + public void setPgNum(String pgNum) { + this.pgNum = pgNum; + } + + @Column(name = "PGTYPE") + public String getPgType() { + return pgType; + } + + public void setPgType(String pgType) { + this.pgType = pgType; + } + + @Column(name = "PGLENGTH") + public String getPgLength() { + return pgLength; + } + + public void setPgLength(String pgLength) { + this.pgLength = pgLength; + } + + @Column(name = "BUILDDATE") + public Date getBuildDate() { + return buildDate; + } + + public void setBuildDate(Date buildDate) { + this.buildDate = buildDate; + } + + @Column(name = "MATERIAL") + public String getMaterial() { + return material; + } + + public void setMaterial(String material) { + this.material = material; + } + @Column(name = "ACTIVE") public int getActive() { return active; 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 95f9fbd..b60c42d 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java @@ -160,7 +160,7 @@ this.setAssetName(pgDevice.getAssetName()); this.setAssetCode(pgDevice.getAssetCode()); this.setAssetBarCode(pgDevice.getAssetBarCode()); - this.setId(pgDevice.getIp()); + this.setIp(pgDevice.getIp()); this.setModBus(pgDevice.getModBus()); this.setMome(pgDevice.getMome()); this.setIsOpen(String.valueOf(pgDevice.getIsOpen())); diff --git a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java b/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java deleted file mode 100644 index b2affe5..0000000 --- a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.casic.PgInterface.devData.dto; - -/** - * Created by yxw on 2017/11/28. - */ -public class PgTempHunDto { -} 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 eb1f7ab..da8f617 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -39,7 +39,6 @@ private List pgShs; private List pgTempHums; - @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") public long getId() { diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java index 4278dc1..669b60f 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java @@ -2,21 +2,20 @@ import javax.persistence.*; import java.io.Serializable; -import java.util.List; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Entity @Table(name = "PG_DEVICE_TYPE") @SequenceGenerator(name = "SEQ_PG_DEVICE_TYPE_ID", sequenceName = "SEQ_PG_DEVICE_TYPE_ID", allocationSize = 1, initialValue = 1) public class PgDeviceType implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; private long id; private String devType; private int active; - private List pgDeviceList; + @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_TYPE_ID") @@ -45,13 +44,4 @@ public void setActive(int active) { this.active = active; } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "devTypeId") - public List getPgDeviceList() { - return pgDeviceList; - } - - public void setPgDeviceList(List pgDeviceList) { - this.pgDeviceList = pgDeviceList; - } } 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 4fb3d6f..d209733 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java @@ -2,6 +2,7 @@ import javax.persistence.*; import java.io.Serializable; +import java.util.Date; import java.util.List; /** @@ -17,6 +18,12 @@ private long id; private String parName;//分区名称 private String road;//所属道路 + private String pgPosition;//仓段位置 + private String pgNum;//仓位数量 + private String pgType;//仓位类型 + private String pgLength;//分区长度 + private Date buildDate;//建设年代 + private String material;//建设材质 private int active;//状态位 private List pipeGalleryList;//管廊仓 @@ -48,6 +55,60 @@ this.road = road; } + @Column(name = "PGPOSITION") + public String getPgPosition() { + return pgPosition; + } + + public void setPgPosition(String pgPosition) { + this.pgPosition = pgPosition; + } + + @Column(name = "PGNUM") + public String getPgNum() { + return pgNum; + } + + public void setPgNum(String pgNum) { + this.pgNum = pgNum; + } + + @Column(name = "PGTYPE") + public String getPgType() { + return pgType; + } + + public void setPgType(String pgType) { + this.pgType = pgType; + } + + @Column(name = "PGLENGTH") + public String getPgLength() { + return pgLength; + } + + public void setPgLength(String pgLength) { + this.pgLength = pgLength; + } + + @Column(name = "BUILDDATE") + public Date getBuildDate() { + return buildDate; + } + + public void setBuildDate(Date buildDate) { + this.buildDate = buildDate; + } + + @Column(name = "MATERIAL") + public String getMaterial() { + return material; + } + + public void setMaterial(String material) { + this.material = material; + } + @Column(name = "ACTIVE") public int getActive() { return active; 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 95f9fbd..b60c42d 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java @@ -160,7 +160,7 @@ this.setAssetName(pgDevice.getAssetName()); this.setAssetCode(pgDevice.getAssetCode()); this.setAssetBarCode(pgDevice.getAssetBarCode()); - this.setId(pgDevice.getIp()); + this.setIp(pgDevice.getIp()); this.setModBus(pgDevice.getModBus()); this.setMome(pgDevice.getMome()); this.setIsOpen(String.valueOf(pgDevice.getIsOpen())); diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java index c1548e0..e348f7a 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java @@ -5,7 +5,7 @@ import java.io.Serializable; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ public class PgDeviceTypeDto implements Serializable { @@ -37,12 +37,11 @@ this.active = active; } - public PgDeviceTypeDto(PgDeviceType pgDeviceType) - { + public PgDeviceTypeDto(PgDeviceType pgDeviceType) { + this.setId(String.valueOf(pgDeviceType.getId())); this.setDevType(pgDeviceType.getDevType()); this.setActive(String.valueOf(pgDeviceType.getActive())); } - } diff --git a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java b/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java deleted file mode 100644 index b2affe5..0000000 --- a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.casic.PgInterface.devData.dto; - -/** - * Created by yxw on 2017/11/28. - */ -public class PgTempHunDto { -} 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 eb1f7ab..da8f617 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -39,7 +39,6 @@ private List pgShs; private List pgTempHums; - @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") public long getId() { diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java index 4278dc1..669b60f 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java @@ -2,21 +2,20 @@ import javax.persistence.*; import java.io.Serializable; -import java.util.List; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Entity @Table(name = "PG_DEVICE_TYPE") @SequenceGenerator(name = "SEQ_PG_DEVICE_TYPE_ID", sequenceName = "SEQ_PG_DEVICE_TYPE_ID", allocationSize = 1, initialValue = 1) public class PgDeviceType implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; private long id; private String devType; private int active; - private List pgDeviceList; + @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_TYPE_ID") @@ -45,13 +44,4 @@ public void setActive(int active) { this.active = active; } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "devTypeId") - public List getPgDeviceList() { - return pgDeviceList; - } - - public void setPgDeviceList(List pgDeviceList) { - this.pgDeviceList = pgDeviceList; - } } 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 4fb3d6f..d209733 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java @@ -2,6 +2,7 @@ import javax.persistence.*; import java.io.Serializable; +import java.util.Date; import java.util.List; /** @@ -17,6 +18,12 @@ private long id; private String parName;//分区名称 private String road;//所属道路 + private String pgPosition;//仓段位置 + private String pgNum;//仓位数量 + private String pgType;//仓位类型 + private String pgLength;//分区长度 + private Date buildDate;//建设年代 + private String material;//建设材质 private int active;//状态位 private List pipeGalleryList;//管廊仓 @@ -48,6 +55,60 @@ this.road = road; } + @Column(name = "PGPOSITION") + public String getPgPosition() { + return pgPosition; + } + + public void setPgPosition(String pgPosition) { + this.pgPosition = pgPosition; + } + + @Column(name = "PGNUM") + public String getPgNum() { + return pgNum; + } + + public void setPgNum(String pgNum) { + this.pgNum = pgNum; + } + + @Column(name = "PGTYPE") + public String getPgType() { + return pgType; + } + + public void setPgType(String pgType) { + this.pgType = pgType; + } + + @Column(name = "PGLENGTH") + public String getPgLength() { + return pgLength; + } + + public void setPgLength(String pgLength) { + this.pgLength = pgLength; + } + + @Column(name = "BUILDDATE") + public Date getBuildDate() { + return buildDate; + } + + public void setBuildDate(Date buildDate) { + this.buildDate = buildDate; + } + + @Column(name = "MATERIAL") + public String getMaterial() { + return material; + } + + public void setMaterial(String material) { + this.material = material; + } + @Column(name = "ACTIVE") public int getActive() { return active; 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 95f9fbd..b60c42d 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java @@ -160,7 +160,7 @@ this.setAssetName(pgDevice.getAssetName()); this.setAssetCode(pgDevice.getAssetCode()); this.setAssetBarCode(pgDevice.getAssetBarCode()); - this.setId(pgDevice.getIp()); + this.setIp(pgDevice.getIp()); this.setModBus(pgDevice.getModBus()); this.setMome(pgDevice.getMome()); this.setIsOpen(String.valueOf(pgDevice.getIsOpen())); diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java index c1548e0..e348f7a 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java @@ -5,7 +5,7 @@ import java.io.Serializable; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ public class PgDeviceTypeDto implements Serializable { @@ -37,12 +37,11 @@ this.active = active; } - public PgDeviceTypeDto(PgDeviceType pgDeviceType) - { + public PgDeviceTypeDto(PgDeviceType pgDeviceType) { + this.setId(String.valueOf(pgDeviceType.getId())); this.setDevType(pgDeviceType.getDevType()); this.setActive(String.valueOf(pgDeviceType.getActive())); } - } 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 3acd0fa..95c18b4 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java @@ -3,6 +3,7 @@ import com.casic.PgInterface.devTable.domain.PgPartition; import java.io.Serializable; +import java.text.SimpleDateFormat; /** * Created by yxw on 2017/11/2. @@ -12,6 +13,12 @@ private String id; private String parName;//分区名称 private String road;//所属道路 + private String pgPosition;//仓段位置 + private String pgNum;//仓位数量 + private String pgType;//仓位类型 + private String pgLength;//分区长度 + private String buildDate;//建设年代 + private String material;//建设材质 private String active;//状态位 @@ -47,11 +54,67 @@ this.road = road; } + public String getPgPosition() { + return pgPosition; + } + + public void setPgPosition(String pgPosition) { + this.pgPosition = pgPosition; + } + + public String getPgNum() { + return pgNum; + } + + public void setPgNum(String pgNum) { + this.pgNum = pgNum; + } + + public String getPgType() { + return pgType; + } + + public void setPgType(String pgType) { + this.pgType = pgType; + } + + public String getPgLength() { + return pgLength; + } + + public void setPgLength(String pgLength) { + this.pgLength = pgLength; + } + + public String getBuildDate() { + return buildDate; + } + + public void setBuildDate(String buildDate) { + this.buildDate = buildDate; + } + + public String getMaterial() { + return material; + } + + public void setMaterial(String material) { + this.material = material; + } + public PgPartitionDto(PgPartition pgPartition) { + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); + this.setId(String.valueOf(pgPartition.getId())); this.setParName(pgPartition.getParName()); this.setRoad(pgPartition.getRoad()); + this.setPgPosition(pgPartition.getPgPosition()); + this.setPgNum(pgPartition.getPgNum()); + this.setPgType(pgPartition.getPgType()); + this.setPgLength(pgPartition.getPgLength()); + this.setBuildDate(sdf.format(pgPartition.getBuildDate())); + this.setMaterial(pgPartition.getMaterial()); this.setActive(String.valueOf(pgPartition.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java b/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java deleted file mode 100644 index b2affe5..0000000 --- a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.casic.PgInterface.devData.dto; - -/** - * Created by yxw on 2017/11/28. - */ -public class PgTempHunDto { -} 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 eb1f7ab..da8f617 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -39,7 +39,6 @@ private List pgShs; private List pgTempHums; - @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") public long getId() { diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java index 4278dc1..669b60f 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java @@ -2,21 +2,20 @@ import javax.persistence.*; import java.io.Serializable; -import java.util.List; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Entity @Table(name = "PG_DEVICE_TYPE") @SequenceGenerator(name = "SEQ_PG_DEVICE_TYPE_ID", sequenceName = "SEQ_PG_DEVICE_TYPE_ID", allocationSize = 1, initialValue = 1) public class PgDeviceType implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; private long id; private String devType; private int active; - private List pgDeviceList; + @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_TYPE_ID") @@ -45,13 +44,4 @@ public void setActive(int active) { this.active = active; } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "devTypeId") - public List getPgDeviceList() { - return pgDeviceList; - } - - public void setPgDeviceList(List pgDeviceList) { - this.pgDeviceList = pgDeviceList; - } } 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 4fb3d6f..d209733 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java @@ -2,6 +2,7 @@ import javax.persistence.*; import java.io.Serializable; +import java.util.Date; import java.util.List; /** @@ -17,6 +18,12 @@ private long id; private String parName;//分区名称 private String road;//所属道路 + private String pgPosition;//仓段位置 + private String pgNum;//仓位数量 + private String pgType;//仓位类型 + private String pgLength;//分区长度 + private Date buildDate;//建设年代 + private String material;//建设材质 private int active;//状态位 private List pipeGalleryList;//管廊仓 @@ -48,6 +55,60 @@ this.road = road; } + @Column(name = "PGPOSITION") + public String getPgPosition() { + return pgPosition; + } + + public void setPgPosition(String pgPosition) { + this.pgPosition = pgPosition; + } + + @Column(name = "PGNUM") + public String getPgNum() { + return pgNum; + } + + public void setPgNum(String pgNum) { + this.pgNum = pgNum; + } + + @Column(name = "PGTYPE") + public String getPgType() { + return pgType; + } + + public void setPgType(String pgType) { + this.pgType = pgType; + } + + @Column(name = "PGLENGTH") + public String getPgLength() { + return pgLength; + } + + public void setPgLength(String pgLength) { + this.pgLength = pgLength; + } + + @Column(name = "BUILDDATE") + public Date getBuildDate() { + return buildDate; + } + + public void setBuildDate(Date buildDate) { + this.buildDate = buildDate; + } + + @Column(name = "MATERIAL") + public String getMaterial() { + return material; + } + + public void setMaterial(String material) { + this.material = material; + } + @Column(name = "ACTIVE") public int getActive() { return active; 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 95f9fbd..b60c42d 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java @@ -160,7 +160,7 @@ this.setAssetName(pgDevice.getAssetName()); this.setAssetCode(pgDevice.getAssetCode()); this.setAssetBarCode(pgDevice.getAssetBarCode()); - this.setId(pgDevice.getIp()); + this.setIp(pgDevice.getIp()); this.setModBus(pgDevice.getModBus()); this.setMome(pgDevice.getMome()); this.setIsOpen(String.valueOf(pgDevice.getIsOpen())); diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java index c1548e0..e348f7a 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java @@ -5,7 +5,7 @@ import java.io.Serializable; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ public class PgDeviceTypeDto implements Serializable { @@ -37,12 +37,11 @@ this.active = active; } - public PgDeviceTypeDto(PgDeviceType pgDeviceType) - { + public PgDeviceTypeDto(PgDeviceType pgDeviceType) { + this.setId(String.valueOf(pgDeviceType.getId())); this.setDevType(pgDeviceType.getDevType()); this.setActive(String.valueOf(pgDeviceType.getActive())); } - } 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 3acd0fa..95c18b4 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java @@ -3,6 +3,7 @@ import com.casic.PgInterface.devTable.domain.PgPartition; import java.io.Serializable; +import java.text.SimpleDateFormat; /** * Created by yxw on 2017/11/2. @@ -12,6 +13,12 @@ private String id; private String parName;//分区名称 private String road;//所属道路 + private String pgPosition;//仓段位置 + private String pgNum;//仓位数量 + private String pgType;//仓位类型 + private String pgLength;//分区长度 + private String buildDate;//建设年代 + private String material;//建设材质 private String active;//状态位 @@ -47,11 +54,67 @@ this.road = road; } + public String getPgPosition() { + return pgPosition; + } + + public void setPgPosition(String pgPosition) { + this.pgPosition = pgPosition; + } + + public String getPgNum() { + return pgNum; + } + + public void setPgNum(String pgNum) { + this.pgNum = pgNum; + } + + public String getPgType() { + return pgType; + } + + public void setPgType(String pgType) { + this.pgType = pgType; + } + + public String getPgLength() { + return pgLength; + } + + public void setPgLength(String pgLength) { + this.pgLength = pgLength; + } + + public String getBuildDate() { + return buildDate; + } + + public void setBuildDate(String buildDate) { + this.buildDate = buildDate; + } + + public String getMaterial() { + return material; + } + + public void setMaterial(String material) { + this.material = material; + } + public PgPartitionDto(PgPartition pgPartition) { + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); + this.setId(String.valueOf(pgPartition.getId())); this.setParName(pgPartition.getParName()); this.setRoad(pgPartition.getRoad()); + this.setPgPosition(pgPartition.getPgPosition()); + this.setPgNum(pgPartition.getPgNum()); + this.setPgType(pgPartition.getPgType()); + this.setPgLength(pgPartition.getPgLength()); + this.setBuildDate(sdf.format(pgPartition.getBuildDate())); + this.setMaterial(pgPartition.getMaterial()); this.setActive(String.valueOf(pgPartition.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java b/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java index d7c6024..9ea43fd 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java @@ -12,10 +12,10 @@ import java.util.List; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Service -public class PgDeviceTypeManager extends HibernateEntityDao{ +public class PgDeviceTypeManager extends HibernateEntityDao { public List getAllDeviceType() { @@ -23,8 +23,8 @@ criteria.add(Restrictions.eq("active", 1)); criteria.addOrder(Order.desc("id")); - List pgDeviceTypeList= criteria.list(); - List pgDeviceTypeDtoList=new ArrayList(); + List pgDeviceTypeList = criteria.list(); + List pgDeviceTypeDtoList = new ArrayList(); for (PgDeviceType pgDeviceType : pgDeviceTypeList) { pgDeviceTypeDtoList.add(new PgDeviceTypeDto(pgDeviceType)); } @@ -32,15 +32,14 @@ return pgDeviceTypeDtoList; } - public PgDeviceType getPgDeviceTypeByDevType(String devType) - { - Criteria criteria=createCriteria(PgDeviceType.class); - criteria.add(Restrictions.eq("devType",devType)); - criteria.add(Restrictions.eq("active",1)); - criteria.addOrder(Order.desc("id")); + public PgDeviceType getDeviceTypeByDeType(String devType) { - List pgDeviceTypeList=criteria.list(); - if(pgDeviceTypeList==null||pgDeviceTypeList.size()==0) + Criteria criteria = createCriteria(PgDeviceType.class); + criteria.add(Restrictions.eq("active", 1)); + criteria.add(Restrictions.eq("devType", devType)); + + List pgDeviceTypeList = criteria.list(); + if (pgDeviceTypeList.size() == 0) return null; else return pgDeviceTypeList.get(0); diff --git a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java b/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java deleted file mode 100644 index b2affe5..0000000 --- a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.casic.PgInterface.devData.dto; - -/** - * Created by yxw on 2017/11/28. - */ -public class PgTempHunDto { -} 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 eb1f7ab..da8f617 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -39,7 +39,6 @@ private List pgShs; private List pgTempHums; - @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") public long getId() { diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java index 4278dc1..669b60f 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java @@ -2,21 +2,20 @@ import javax.persistence.*; import java.io.Serializable; -import java.util.List; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Entity @Table(name = "PG_DEVICE_TYPE") @SequenceGenerator(name = "SEQ_PG_DEVICE_TYPE_ID", sequenceName = "SEQ_PG_DEVICE_TYPE_ID", allocationSize = 1, initialValue = 1) public class PgDeviceType implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; private long id; private String devType; private int active; - private List pgDeviceList; + @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_TYPE_ID") @@ -45,13 +44,4 @@ public void setActive(int active) { this.active = active; } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "devTypeId") - public List getPgDeviceList() { - return pgDeviceList; - } - - public void setPgDeviceList(List pgDeviceList) { - this.pgDeviceList = pgDeviceList; - } } 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 4fb3d6f..d209733 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java @@ -2,6 +2,7 @@ import javax.persistence.*; import java.io.Serializable; +import java.util.Date; import java.util.List; /** @@ -17,6 +18,12 @@ private long id; private String parName;//分区名称 private String road;//所属道路 + private String pgPosition;//仓段位置 + private String pgNum;//仓位数量 + private String pgType;//仓位类型 + private String pgLength;//分区长度 + private Date buildDate;//建设年代 + private String material;//建设材质 private int active;//状态位 private List pipeGalleryList;//管廊仓 @@ -48,6 +55,60 @@ this.road = road; } + @Column(name = "PGPOSITION") + public String getPgPosition() { + return pgPosition; + } + + public void setPgPosition(String pgPosition) { + this.pgPosition = pgPosition; + } + + @Column(name = "PGNUM") + public String getPgNum() { + return pgNum; + } + + public void setPgNum(String pgNum) { + this.pgNum = pgNum; + } + + @Column(name = "PGTYPE") + public String getPgType() { + return pgType; + } + + public void setPgType(String pgType) { + this.pgType = pgType; + } + + @Column(name = "PGLENGTH") + public String getPgLength() { + return pgLength; + } + + public void setPgLength(String pgLength) { + this.pgLength = pgLength; + } + + @Column(name = "BUILDDATE") + public Date getBuildDate() { + return buildDate; + } + + public void setBuildDate(Date buildDate) { + this.buildDate = buildDate; + } + + @Column(name = "MATERIAL") + public String getMaterial() { + return material; + } + + public void setMaterial(String material) { + this.material = material; + } + @Column(name = "ACTIVE") public int getActive() { return active; 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 95f9fbd..b60c42d 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java @@ -160,7 +160,7 @@ this.setAssetName(pgDevice.getAssetName()); this.setAssetCode(pgDevice.getAssetCode()); this.setAssetBarCode(pgDevice.getAssetBarCode()); - this.setId(pgDevice.getIp()); + this.setIp(pgDevice.getIp()); this.setModBus(pgDevice.getModBus()); this.setMome(pgDevice.getMome()); this.setIsOpen(String.valueOf(pgDevice.getIsOpen())); diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java index c1548e0..e348f7a 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java @@ -5,7 +5,7 @@ import java.io.Serializable; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ public class PgDeviceTypeDto implements Serializable { @@ -37,12 +37,11 @@ this.active = active; } - public PgDeviceTypeDto(PgDeviceType pgDeviceType) - { + public PgDeviceTypeDto(PgDeviceType pgDeviceType) { + this.setId(String.valueOf(pgDeviceType.getId())); this.setDevType(pgDeviceType.getDevType()); this.setActive(String.valueOf(pgDeviceType.getActive())); } - } 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 3acd0fa..95c18b4 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java @@ -3,6 +3,7 @@ import com.casic.PgInterface.devTable.domain.PgPartition; import java.io.Serializable; +import java.text.SimpleDateFormat; /** * Created by yxw on 2017/11/2. @@ -12,6 +13,12 @@ private String id; private String parName;//分区名称 private String road;//所属道路 + private String pgPosition;//仓段位置 + private String pgNum;//仓位数量 + private String pgType;//仓位类型 + private String pgLength;//分区长度 + private String buildDate;//建设年代 + private String material;//建设材质 private String active;//状态位 @@ -47,11 +54,67 @@ this.road = road; } + public String getPgPosition() { + return pgPosition; + } + + public void setPgPosition(String pgPosition) { + this.pgPosition = pgPosition; + } + + public String getPgNum() { + return pgNum; + } + + public void setPgNum(String pgNum) { + this.pgNum = pgNum; + } + + public String getPgType() { + return pgType; + } + + public void setPgType(String pgType) { + this.pgType = pgType; + } + + public String getPgLength() { + return pgLength; + } + + public void setPgLength(String pgLength) { + this.pgLength = pgLength; + } + + public String getBuildDate() { + return buildDate; + } + + public void setBuildDate(String buildDate) { + this.buildDate = buildDate; + } + + public String getMaterial() { + return material; + } + + public void setMaterial(String material) { + this.material = material; + } + public PgPartitionDto(PgPartition pgPartition) { + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); + this.setId(String.valueOf(pgPartition.getId())); this.setParName(pgPartition.getParName()); this.setRoad(pgPartition.getRoad()); + this.setPgPosition(pgPartition.getPgPosition()); + this.setPgNum(pgPartition.getPgNum()); + this.setPgType(pgPartition.getPgType()); + this.setPgLength(pgPartition.getPgLength()); + this.setBuildDate(sdf.format(pgPartition.getBuildDate())); + this.setMaterial(pgPartition.getMaterial()); this.setActive(String.valueOf(pgPartition.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java b/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java index d7c6024..9ea43fd 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java @@ -12,10 +12,10 @@ import java.util.List; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Service -public class PgDeviceTypeManager extends HibernateEntityDao{ +public class PgDeviceTypeManager extends HibernateEntityDao { public List getAllDeviceType() { @@ -23,8 +23,8 @@ criteria.add(Restrictions.eq("active", 1)); criteria.addOrder(Order.desc("id")); - List pgDeviceTypeList= criteria.list(); - List pgDeviceTypeDtoList=new ArrayList(); + List pgDeviceTypeList = criteria.list(); + List pgDeviceTypeDtoList = new ArrayList(); for (PgDeviceType pgDeviceType : pgDeviceTypeList) { pgDeviceTypeDtoList.add(new PgDeviceTypeDto(pgDeviceType)); } @@ -32,15 +32,14 @@ return pgDeviceTypeDtoList; } - public PgDeviceType getPgDeviceTypeByDevType(String devType) - { - Criteria criteria=createCriteria(PgDeviceType.class); - criteria.add(Restrictions.eq("devType",devType)); - criteria.add(Restrictions.eq("active",1)); - criteria.addOrder(Order.desc("id")); + public PgDeviceType getDeviceTypeByDeType(String devType) { - List pgDeviceTypeList=criteria.list(); - if(pgDeviceTypeList==null||pgDeviceTypeList.size()==0) + Criteria criteria = createCriteria(PgDeviceType.class); + criteria.add(Restrictions.eq("active", 1)); + criteria.add(Restrictions.eq("devType", devType)); + + List pgDeviceTypeList = criteria.list(); + if (pgDeviceTypeList.size() == 0) return null; else return pgDeviceTypeList.get(0); 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 0c594e7..c6f22cb 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java @@ -64,4 +64,4 @@ -} +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java b/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java deleted file mode 100644 index b2affe5..0000000 --- a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.casic.PgInterface.devData.dto; - -/** - * Created by yxw on 2017/11/28. - */ -public class PgTempHunDto { -} 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 eb1f7ab..da8f617 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -39,7 +39,6 @@ private List pgShs; private List pgTempHums; - @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") public long getId() { diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java index 4278dc1..669b60f 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java @@ -2,21 +2,20 @@ import javax.persistence.*; import java.io.Serializable; -import java.util.List; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Entity @Table(name = "PG_DEVICE_TYPE") @SequenceGenerator(name = "SEQ_PG_DEVICE_TYPE_ID", sequenceName = "SEQ_PG_DEVICE_TYPE_ID", allocationSize = 1, initialValue = 1) public class PgDeviceType implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; private long id; private String devType; private int active; - private List pgDeviceList; + @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_TYPE_ID") @@ -45,13 +44,4 @@ public void setActive(int active) { this.active = active; } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "devTypeId") - public List getPgDeviceList() { - return pgDeviceList; - } - - public void setPgDeviceList(List pgDeviceList) { - this.pgDeviceList = pgDeviceList; - } } 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 4fb3d6f..d209733 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java @@ -2,6 +2,7 @@ import javax.persistence.*; import java.io.Serializable; +import java.util.Date; import java.util.List; /** @@ -17,6 +18,12 @@ private long id; private String parName;//分区名称 private String road;//所属道路 + private String pgPosition;//仓段位置 + private String pgNum;//仓位数量 + private String pgType;//仓位类型 + private String pgLength;//分区长度 + private Date buildDate;//建设年代 + private String material;//建设材质 private int active;//状态位 private List pipeGalleryList;//管廊仓 @@ -48,6 +55,60 @@ this.road = road; } + @Column(name = "PGPOSITION") + public String getPgPosition() { + return pgPosition; + } + + public void setPgPosition(String pgPosition) { + this.pgPosition = pgPosition; + } + + @Column(name = "PGNUM") + public String getPgNum() { + return pgNum; + } + + public void setPgNum(String pgNum) { + this.pgNum = pgNum; + } + + @Column(name = "PGTYPE") + public String getPgType() { + return pgType; + } + + public void setPgType(String pgType) { + this.pgType = pgType; + } + + @Column(name = "PGLENGTH") + public String getPgLength() { + return pgLength; + } + + public void setPgLength(String pgLength) { + this.pgLength = pgLength; + } + + @Column(name = "BUILDDATE") + public Date getBuildDate() { + return buildDate; + } + + public void setBuildDate(Date buildDate) { + this.buildDate = buildDate; + } + + @Column(name = "MATERIAL") + public String getMaterial() { + return material; + } + + public void setMaterial(String material) { + this.material = material; + } + @Column(name = "ACTIVE") public int getActive() { return active; 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 95f9fbd..b60c42d 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java @@ -160,7 +160,7 @@ this.setAssetName(pgDevice.getAssetName()); this.setAssetCode(pgDevice.getAssetCode()); this.setAssetBarCode(pgDevice.getAssetBarCode()); - this.setId(pgDevice.getIp()); + this.setIp(pgDevice.getIp()); this.setModBus(pgDevice.getModBus()); this.setMome(pgDevice.getMome()); this.setIsOpen(String.valueOf(pgDevice.getIsOpen())); diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java index c1548e0..e348f7a 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java @@ -5,7 +5,7 @@ import java.io.Serializable; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ public class PgDeviceTypeDto implements Serializable { @@ -37,12 +37,11 @@ this.active = active; } - public PgDeviceTypeDto(PgDeviceType pgDeviceType) - { + public PgDeviceTypeDto(PgDeviceType pgDeviceType) { + this.setId(String.valueOf(pgDeviceType.getId())); this.setDevType(pgDeviceType.getDevType()); this.setActive(String.valueOf(pgDeviceType.getActive())); } - } 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 3acd0fa..95c18b4 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java @@ -3,6 +3,7 @@ import com.casic.PgInterface.devTable.domain.PgPartition; import java.io.Serializable; +import java.text.SimpleDateFormat; /** * Created by yxw on 2017/11/2. @@ -12,6 +13,12 @@ private String id; private String parName;//分区名称 private String road;//所属道路 + private String pgPosition;//仓段位置 + private String pgNum;//仓位数量 + private String pgType;//仓位类型 + private String pgLength;//分区长度 + private String buildDate;//建设年代 + private String material;//建设材质 private String active;//状态位 @@ -47,11 +54,67 @@ this.road = road; } + public String getPgPosition() { + return pgPosition; + } + + public void setPgPosition(String pgPosition) { + this.pgPosition = pgPosition; + } + + public String getPgNum() { + return pgNum; + } + + public void setPgNum(String pgNum) { + this.pgNum = pgNum; + } + + public String getPgType() { + return pgType; + } + + public void setPgType(String pgType) { + this.pgType = pgType; + } + + public String getPgLength() { + return pgLength; + } + + public void setPgLength(String pgLength) { + this.pgLength = pgLength; + } + + public String getBuildDate() { + return buildDate; + } + + public void setBuildDate(String buildDate) { + this.buildDate = buildDate; + } + + public String getMaterial() { + return material; + } + + public void setMaterial(String material) { + this.material = material; + } + public PgPartitionDto(PgPartition pgPartition) { + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); + this.setId(String.valueOf(pgPartition.getId())); this.setParName(pgPartition.getParName()); this.setRoad(pgPartition.getRoad()); + this.setPgPosition(pgPartition.getPgPosition()); + this.setPgNum(pgPartition.getPgNum()); + this.setPgType(pgPartition.getPgType()); + this.setPgLength(pgPartition.getPgLength()); + this.setBuildDate(sdf.format(pgPartition.getBuildDate())); + this.setMaterial(pgPartition.getMaterial()); this.setActive(String.valueOf(pgPartition.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java b/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java index d7c6024..9ea43fd 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java @@ -12,10 +12,10 @@ import java.util.List; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Service -public class PgDeviceTypeManager extends HibernateEntityDao{ +public class PgDeviceTypeManager extends HibernateEntityDao { public List getAllDeviceType() { @@ -23,8 +23,8 @@ criteria.add(Restrictions.eq("active", 1)); criteria.addOrder(Order.desc("id")); - List pgDeviceTypeList= criteria.list(); - List pgDeviceTypeDtoList=new ArrayList(); + List pgDeviceTypeList = criteria.list(); + List pgDeviceTypeDtoList = new ArrayList(); for (PgDeviceType pgDeviceType : pgDeviceTypeList) { pgDeviceTypeDtoList.add(new PgDeviceTypeDto(pgDeviceType)); } @@ -32,15 +32,14 @@ return pgDeviceTypeDtoList; } - public PgDeviceType getPgDeviceTypeByDevType(String devType) - { - Criteria criteria=createCriteria(PgDeviceType.class); - criteria.add(Restrictions.eq("devType",devType)); - criteria.add(Restrictions.eq("active",1)); - criteria.addOrder(Order.desc("id")); + public PgDeviceType getDeviceTypeByDeType(String devType) { - List pgDeviceTypeList=criteria.list(); - if(pgDeviceTypeList==null||pgDeviceTypeList.size()==0) + Criteria criteria = createCriteria(PgDeviceType.class); + criteria.add(Restrictions.eq("active", 1)); + criteria.add(Restrictions.eq("devType", devType)); + + List pgDeviceTypeList = criteria.list(); + if (pgDeviceTypeList.size() == 0) return null; else return pgDeviceTypeList.get(0); 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 0c594e7..c6f22cb 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java @@ -64,4 +64,4 @@ -} +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java index 9d06235..68b14cf 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java @@ -1,9 +1,5 @@ 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; @@ -19,7 +15,8 @@ private long id; private String highValue;//高限 private String lowValue;//低限 - private PgDevice pgDeviceId;//设备 + private String unit;//单位 + private String devType;//设备类型 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_ALARM_RULE_ID") @@ -49,15 +46,24 @@ this.lowValue = lowValue; } - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PGDEVICEID") - public PgDevice getPgDeviceId() { - return pgDeviceId; + @Column(name="UNIT") + public String getUnit() { + return unit; } - public void setPgDeviceId(PgDevice pgDeviceId) { - this.pgDeviceId = pgDeviceId; + public void setUnit(String unit) { + this.unit = unit; } + @Column(name = "DEVTYPE") + public String getDevType() { + return devType; + } + + public void setDevType(String devType) { + this.devType = devType; + } + + + } diff --git a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java b/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java deleted file mode 100644 index b2affe5..0000000 --- a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.casic.PgInterface.devData.dto; - -/** - * Created by yxw on 2017/11/28. - */ -public class PgTempHunDto { -} 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 eb1f7ab..da8f617 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -39,7 +39,6 @@ private List pgShs; private List pgTempHums; - @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") public long getId() { diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java index 4278dc1..669b60f 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java @@ -2,21 +2,20 @@ import javax.persistence.*; import java.io.Serializable; -import java.util.List; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Entity @Table(name = "PG_DEVICE_TYPE") @SequenceGenerator(name = "SEQ_PG_DEVICE_TYPE_ID", sequenceName = "SEQ_PG_DEVICE_TYPE_ID", allocationSize = 1, initialValue = 1) public class PgDeviceType implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; private long id; private String devType; private int active; - private List pgDeviceList; + @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_TYPE_ID") @@ -45,13 +44,4 @@ public void setActive(int active) { this.active = active; } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "devTypeId") - public List getPgDeviceList() { - return pgDeviceList; - } - - public void setPgDeviceList(List pgDeviceList) { - this.pgDeviceList = pgDeviceList; - } } 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 4fb3d6f..d209733 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java @@ -2,6 +2,7 @@ import javax.persistence.*; import java.io.Serializable; +import java.util.Date; import java.util.List; /** @@ -17,6 +18,12 @@ private long id; private String parName;//分区名称 private String road;//所属道路 + private String pgPosition;//仓段位置 + private String pgNum;//仓位数量 + private String pgType;//仓位类型 + private String pgLength;//分区长度 + private Date buildDate;//建设年代 + private String material;//建设材质 private int active;//状态位 private List pipeGalleryList;//管廊仓 @@ -48,6 +55,60 @@ this.road = road; } + @Column(name = "PGPOSITION") + public String getPgPosition() { + return pgPosition; + } + + public void setPgPosition(String pgPosition) { + this.pgPosition = pgPosition; + } + + @Column(name = "PGNUM") + public String getPgNum() { + return pgNum; + } + + public void setPgNum(String pgNum) { + this.pgNum = pgNum; + } + + @Column(name = "PGTYPE") + public String getPgType() { + return pgType; + } + + public void setPgType(String pgType) { + this.pgType = pgType; + } + + @Column(name = "PGLENGTH") + public String getPgLength() { + return pgLength; + } + + public void setPgLength(String pgLength) { + this.pgLength = pgLength; + } + + @Column(name = "BUILDDATE") + public Date getBuildDate() { + return buildDate; + } + + public void setBuildDate(Date buildDate) { + this.buildDate = buildDate; + } + + @Column(name = "MATERIAL") + public String getMaterial() { + return material; + } + + public void setMaterial(String material) { + this.material = material; + } + @Column(name = "ACTIVE") public int getActive() { return active; 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 95f9fbd..b60c42d 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java @@ -160,7 +160,7 @@ this.setAssetName(pgDevice.getAssetName()); this.setAssetCode(pgDevice.getAssetCode()); this.setAssetBarCode(pgDevice.getAssetBarCode()); - this.setId(pgDevice.getIp()); + this.setIp(pgDevice.getIp()); this.setModBus(pgDevice.getModBus()); this.setMome(pgDevice.getMome()); this.setIsOpen(String.valueOf(pgDevice.getIsOpen())); diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java index c1548e0..e348f7a 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java @@ -5,7 +5,7 @@ import java.io.Serializable; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ public class PgDeviceTypeDto implements Serializable { @@ -37,12 +37,11 @@ this.active = active; } - public PgDeviceTypeDto(PgDeviceType pgDeviceType) - { + public PgDeviceTypeDto(PgDeviceType pgDeviceType) { + this.setId(String.valueOf(pgDeviceType.getId())); this.setDevType(pgDeviceType.getDevType()); this.setActive(String.valueOf(pgDeviceType.getActive())); } - } 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 3acd0fa..95c18b4 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java @@ -3,6 +3,7 @@ import com.casic.PgInterface.devTable.domain.PgPartition; import java.io.Serializable; +import java.text.SimpleDateFormat; /** * Created by yxw on 2017/11/2. @@ -12,6 +13,12 @@ private String id; private String parName;//分区名称 private String road;//所属道路 + private String pgPosition;//仓段位置 + private String pgNum;//仓位数量 + private String pgType;//仓位类型 + private String pgLength;//分区长度 + private String buildDate;//建设年代 + private String material;//建设材质 private String active;//状态位 @@ -47,11 +54,67 @@ this.road = road; } + public String getPgPosition() { + return pgPosition; + } + + public void setPgPosition(String pgPosition) { + this.pgPosition = pgPosition; + } + + public String getPgNum() { + return pgNum; + } + + public void setPgNum(String pgNum) { + this.pgNum = pgNum; + } + + public String getPgType() { + return pgType; + } + + public void setPgType(String pgType) { + this.pgType = pgType; + } + + public String getPgLength() { + return pgLength; + } + + public void setPgLength(String pgLength) { + this.pgLength = pgLength; + } + + public String getBuildDate() { + return buildDate; + } + + public void setBuildDate(String buildDate) { + this.buildDate = buildDate; + } + + public String getMaterial() { + return material; + } + + public void setMaterial(String material) { + this.material = material; + } + public PgPartitionDto(PgPartition pgPartition) { + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); + this.setId(String.valueOf(pgPartition.getId())); this.setParName(pgPartition.getParName()); this.setRoad(pgPartition.getRoad()); + this.setPgPosition(pgPartition.getPgPosition()); + this.setPgNum(pgPartition.getPgNum()); + this.setPgType(pgPartition.getPgType()); + this.setPgLength(pgPartition.getPgLength()); + this.setBuildDate(sdf.format(pgPartition.getBuildDate())); + this.setMaterial(pgPartition.getMaterial()); this.setActive(String.valueOf(pgPartition.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java b/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java index d7c6024..9ea43fd 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java @@ -12,10 +12,10 @@ import java.util.List; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Service -public class PgDeviceTypeManager extends HibernateEntityDao{ +public class PgDeviceTypeManager extends HibernateEntityDao { public List getAllDeviceType() { @@ -23,8 +23,8 @@ criteria.add(Restrictions.eq("active", 1)); criteria.addOrder(Order.desc("id")); - List pgDeviceTypeList= criteria.list(); - List pgDeviceTypeDtoList=new ArrayList(); + List pgDeviceTypeList = criteria.list(); + List pgDeviceTypeDtoList = new ArrayList(); for (PgDeviceType pgDeviceType : pgDeviceTypeList) { pgDeviceTypeDtoList.add(new PgDeviceTypeDto(pgDeviceType)); } @@ -32,15 +32,14 @@ return pgDeviceTypeDtoList; } - public PgDeviceType getPgDeviceTypeByDevType(String devType) - { - Criteria criteria=createCriteria(PgDeviceType.class); - criteria.add(Restrictions.eq("devType",devType)); - criteria.add(Restrictions.eq("active",1)); - criteria.addOrder(Order.desc("id")); + public PgDeviceType getDeviceTypeByDeType(String devType) { - List pgDeviceTypeList=criteria.list(); - if(pgDeviceTypeList==null||pgDeviceTypeList.size()==0) + Criteria criteria = createCriteria(PgDeviceType.class); + criteria.add(Restrictions.eq("active", 1)); + criteria.add(Restrictions.eq("devType", devType)); + + List pgDeviceTypeList = criteria.list(); + if (pgDeviceTypeList.size() == 0) return null; else return pgDeviceTypeList.get(0); 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 0c594e7..c6f22cb 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java @@ -64,4 +64,4 @@ -} +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java index 9d06235..68b14cf 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java @@ -1,9 +1,5 @@ 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; @@ -19,7 +15,8 @@ private long id; private String highValue;//高限 private String lowValue;//低限 - private PgDevice pgDeviceId;//设备 + private String unit;//单位 + private String devType;//设备类型 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_ALARM_RULE_ID") @@ -49,15 +46,24 @@ this.lowValue = lowValue; } - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PGDEVICEID") - public PgDevice getPgDeviceId() { - return pgDeviceId; + @Column(name="UNIT") + public String getUnit() { + return unit; } - public void setPgDeviceId(PgDevice pgDeviceId) { - this.pgDeviceId = pgDeviceId; + public void setUnit(String unit) { + this.unit = unit; } + @Column(name = "DEVTYPE") + public String getDevType() { + return devType; + } + + public void setDevType(String devType) { + this.devType = devType; + } + + + } diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java deleted file mode 100644 index 7907e66..0000000 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.casic.PgInterface.patroler.dto; - -/** - * Created by yxw on 2017/12/14. - */ -public class PgAlarmRule { -} diff --git a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java b/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java deleted file mode 100644 index b2affe5..0000000 --- a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.casic.PgInterface.devData.dto; - -/** - * Created by yxw on 2017/11/28. - */ -public class PgTempHunDto { -} 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 eb1f7ab..da8f617 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -39,7 +39,6 @@ private List pgShs; private List pgTempHums; - @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") public long getId() { diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java index 4278dc1..669b60f 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java @@ -2,21 +2,20 @@ import javax.persistence.*; import java.io.Serializable; -import java.util.List; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Entity @Table(name = "PG_DEVICE_TYPE") @SequenceGenerator(name = "SEQ_PG_DEVICE_TYPE_ID", sequenceName = "SEQ_PG_DEVICE_TYPE_ID", allocationSize = 1, initialValue = 1) public class PgDeviceType implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; private long id; private String devType; private int active; - private List pgDeviceList; + @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_TYPE_ID") @@ -45,13 +44,4 @@ public void setActive(int active) { this.active = active; } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "devTypeId") - public List getPgDeviceList() { - return pgDeviceList; - } - - public void setPgDeviceList(List pgDeviceList) { - this.pgDeviceList = pgDeviceList; - } } 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 4fb3d6f..d209733 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java @@ -2,6 +2,7 @@ import javax.persistence.*; import java.io.Serializable; +import java.util.Date; import java.util.List; /** @@ -17,6 +18,12 @@ private long id; private String parName;//分区名称 private String road;//所属道路 + private String pgPosition;//仓段位置 + private String pgNum;//仓位数量 + private String pgType;//仓位类型 + private String pgLength;//分区长度 + private Date buildDate;//建设年代 + private String material;//建设材质 private int active;//状态位 private List pipeGalleryList;//管廊仓 @@ -48,6 +55,60 @@ this.road = road; } + @Column(name = "PGPOSITION") + public String getPgPosition() { + return pgPosition; + } + + public void setPgPosition(String pgPosition) { + this.pgPosition = pgPosition; + } + + @Column(name = "PGNUM") + public String getPgNum() { + return pgNum; + } + + public void setPgNum(String pgNum) { + this.pgNum = pgNum; + } + + @Column(name = "PGTYPE") + public String getPgType() { + return pgType; + } + + public void setPgType(String pgType) { + this.pgType = pgType; + } + + @Column(name = "PGLENGTH") + public String getPgLength() { + return pgLength; + } + + public void setPgLength(String pgLength) { + this.pgLength = pgLength; + } + + @Column(name = "BUILDDATE") + public Date getBuildDate() { + return buildDate; + } + + public void setBuildDate(Date buildDate) { + this.buildDate = buildDate; + } + + @Column(name = "MATERIAL") + public String getMaterial() { + return material; + } + + public void setMaterial(String material) { + this.material = material; + } + @Column(name = "ACTIVE") public int getActive() { return active; 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 95f9fbd..b60c42d 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java @@ -160,7 +160,7 @@ this.setAssetName(pgDevice.getAssetName()); this.setAssetCode(pgDevice.getAssetCode()); this.setAssetBarCode(pgDevice.getAssetBarCode()); - this.setId(pgDevice.getIp()); + this.setIp(pgDevice.getIp()); this.setModBus(pgDevice.getModBus()); this.setMome(pgDevice.getMome()); this.setIsOpen(String.valueOf(pgDevice.getIsOpen())); diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java index c1548e0..e348f7a 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java @@ -5,7 +5,7 @@ import java.io.Serializable; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ public class PgDeviceTypeDto implements Serializable { @@ -37,12 +37,11 @@ this.active = active; } - public PgDeviceTypeDto(PgDeviceType pgDeviceType) - { + public PgDeviceTypeDto(PgDeviceType pgDeviceType) { + this.setId(String.valueOf(pgDeviceType.getId())); this.setDevType(pgDeviceType.getDevType()); this.setActive(String.valueOf(pgDeviceType.getActive())); } - } 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 3acd0fa..95c18b4 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java @@ -3,6 +3,7 @@ import com.casic.PgInterface.devTable.domain.PgPartition; import java.io.Serializable; +import java.text.SimpleDateFormat; /** * Created by yxw on 2017/11/2. @@ -12,6 +13,12 @@ private String id; private String parName;//分区名称 private String road;//所属道路 + private String pgPosition;//仓段位置 + private String pgNum;//仓位数量 + private String pgType;//仓位类型 + private String pgLength;//分区长度 + private String buildDate;//建设年代 + private String material;//建设材质 private String active;//状态位 @@ -47,11 +54,67 @@ this.road = road; } + public String getPgPosition() { + return pgPosition; + } + + public void setPgPosition(String pgPosition) { + this.pgPosition = pgPosition; + } + + public String getPgNum() { + return pgNum; + } + + public void setPgNum(String pgNum) { + this.pgNum = pgNum; + } + + public String getPgType() { + return pgType; + } + + public void setPgType(String pgType) { + this.pgType = pgType; + } + + public String getPgLength() { + return pgLength; + } + + public void setPgLength(String pgLength) { + this.pgLength = pgLength; + } + + public String getBuildDate() { + return buildDate; + } + + public void setBuildDate(String buildDate) { + this.buildDate = buildDate; + } + + public String getMaterial() { + return material; + } + + public void setMaterial(String material) { + this.material = material; + } + public PgPartitionDto(PgPartition pgPartition) { + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); + this.setId(String.valueOf(pgPartition.getId())); this.setParName(pgPartition.getParName()); this.setRoad(pgPartition.getRoad()); + this.setPgPosition(pgPartition.getPgPosition()); + this.setPgNum(pgPartition.getPgNum()); + this.setPgType(pgPartition.getPgType()); + this.setPgLength(pgPartition.getPgLength()); + this.setBuildDate(sdf.format(pgPartition.getBuildDate())); + this.setMaterial(pgPartition.getMaterial()); this.setActive(String.valueOf(pgPartition.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java b/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java index d7c6024..9ea43fd 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java @@ -12,10 +12,10 @@ import java.util.List; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Service -public class PgDeviceTypeManager extends HibernateEntityDao{ +public class PgDeviceTypeManager extends HibernateEntityDao { public List getAllDeviceType() { @@ -23,8 +23,8 @@ criteria.add(Restrictions.eq("active", 1)); criteria.addOrder(Order.desc("id")); - List pgDeviceTypeList= criteria.list(); - List pgDeviceTypeDtoList=new ArrayList(); + List pgDeviceTypeList = criteria.list(); + List pgDeviceTypeDtoList = new ArrayList(); for (PgDeviceType pgDeviceType : pgDeviceTypeList) { pgDeviceTypeDtoList.add(new PgDeviceTypeDto(pgDeviceType)); } @@ -32,15 +32,14 @@ return pgDeviceTypeDtoList; } - public PgDeviceType getPgDeviceTypeByDevType(String devType) - { - Criteria criteria=createCriteria(PgDeviceType.class); - criteria.add(Restrictions.eq("devType",devType)); - criteria.add(Restrictions.eq("active",1)); - criteria.addOrder(Order.desc("id")); + public PgDeviceType getDeviceTypeByDeType(String devType) { - List pgDeviceTypeList=criteria.list(); - if(pgDeviceTypeList==null||pgDeviceTypeList.size()==0) + Criteria criteria = createCriteria(PgDeviceType.class); + criteria.add(Restrictions.eq("active", 1)); + criteria.add(Restrictions.eq("devType", devType)); + + List pgDeviceTypeList = criteria.list(); + if (pgDeviceTypeList.size() == 0) return null; else return pgDeviceTypeList.get(0); 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 0c594e7..c6f22cb 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java @@ -64,4 +64,4 @@ -} +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java index 9d06235..68b14cf 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java @@ -1,9 +1,5 @@ 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; @@ -19,7 +15,8 @@ private long id; private String highValue;//高限 private String lowValue;//低限 - private PgDevice pgDeviceId;//设备 + private String unit;//单位 + private String devType;//设备类型 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_ALARM_RULE_ID") @@ -49,15 +46,24 @@ this.lowValue = lowValue; } - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PGDEVICEID") - public PgDevice getPgDeviceId() { - return pgDeviceId; + @Column(name="UNIT") + public String getUnit() { + return unit; } - public void setPgDeviceId(PgDevice pgDeviceId) { - this.pgDeviceId = pgDeviceId; + public void setUnit(String unit) { + this.unit = unit; } + @Column(name = "DEVTYPE") + public String getDevType() { + return devType; + } + + public void setDevType(String devType) { + this.devType = devType; + } + + + } diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java deleted file mode 100644 index 7907e66..0000000 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.casic.PgInterface.patroler.dto; - -/** - * Created by yxw on 2017/12/14. - */ -public class PgAlarmRule { -} diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java index 8367ad4..0782c63 100644 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java @@ -12,7 +12,8 @@ private String id; private String highValue;//高限 private String lowValue;//低限 - private String devName;//设备 + private String devType;//设备类型 + private String unit;//单位 public String getId() { return id; @@ -38,20 +39,29 @@ this.lowValue = lowValue; } - public String getDevName() { - return devName; + public String getDevType() { + return devType; } - public void setDevName(String devName) { - this.devName = devName; + public void setDevType(String devType) { + this.devType = devType; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; } public PgAlarmRuleDto(PgAlarmRule pgAlarmRule) { this.setId(String.valueOf(pgAlarmRule.getId())); - this.setDevName(pgAlarmRule.getPgDeviceId().getAssetName()); this.setHighValue(pgAlarmRule.getHighValue()); this.setLowValue(pgAlarmRule.getLowValue()); + this.setDevType(pgAlarmRule.getDevType()); + this.setUnit(pgAlarmRule.getUnit()); } } diff --git a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java b/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java deleted file mode 100644 index b2affe5..0000000 --- a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.casic.PgInterface.devData.dto; - -/** - * Created by yxw on 2017/11/28. - */ -public class PgTempHunDto { -} 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 eb1f7ab..da8f617 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -39,7 +39,6 @@ private List pgShs; private List pgTempHums; - @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") public long getId() { diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java index 4278dc1..669b60f 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java @@ -2,21 +2,20 @@ import javax.persistence.*; import java.io.Serializable; -import java.util.List; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Entity @Table(name = "PG_DEVICE_TYPE") @SequenceGenerator(name = "SEQ_PG_DEVICE_TYPE_ID", sequenceName = "SEQ_PG_DEVICE_TYPE_ID", allocationSize = 1, initialValue = 1) public class PgDeviceType implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; private long id; private String devType; private int active; - private List pgDeviceList; + @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_TYPE_ID") @@ -45,13 +44,4 @@ public void setActive(int active) { this.active = active; } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "devTypeId") - public List getPgDeviceList() { - return pgDeviceList; - } - - public void setPgDeviceList(List pgDeviceList) { - this.pgDeviceList = pgDeviceList; - } } 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 4fb3d6f..d209733 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java @@ -2,6 +2,7 @@ import javax.persistence.*; import java.io.Serializable; +import java.util.Date; import java.util.List; /** @@ -17,6 +18,12 @@ private long id; private String parName;//分区名称 private String road;//所属道路 + private String pgPosition;//仓段位置 + private String pgNum;//仓位数量 + private String pgType;//仓位类型 + private String pgLength;//分区长度 + private Date buildDate;//建设年代 + private String material;//建设材质 private int active;//状态位 private List pipeGalleryList;//管廊仓 @@ -48,6 +55,60 @@ this.road = road; } + @Column(name = "PGPOSITION") + public String getPgPosition() { + return pgPosition; + } + + public void setPgPosition(String pgPosition) { + this.pgPosition = pgPosition; + } + + @Column(name = "PGNUM") + public String getPgNum() { + return pgNum; + } + + public void setPgNum(String pgNum) { + this.pgNum = pgNum; + } + + @Column(name = "PGTYPE") + public String getPgType() { + return pgType; + } + + public void setPgType(String pgType) { + this.pgType = pgType; + } + + @Column(name = "PGLENGTH") + public String getPgLength() { + return pgLength; + } + + public void setPgLength(String pgLength) { + this.pgLength = pgLength; + } + + @Column(name = "BUILDDATE") + public Date getBuildDate() { + return buildDate; + } + + public void setBuildDate(Date buildDate) { + this.buildDate = buildDate; + } + + @Column(name = "MATERIAL") + public String getMaterial() { + return material; + } + + public void setMaterial(String material) { + this.material = material; + } + @Column(name = "ACTIVE") public int getActive() { return active; 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 95f9fbd..b60c42d 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java @@ -160,7 +160,7 @@ this.setAssetName(pgDevice.getAssetName()); this.setAssetCode(pgDevice.getAssetCode()); this.setAssetBarCode(pgDevice.getAssetBarCode()); - this.setId(pgDevice.getIp()); + this.setIp(pgDevice.getIp()); this.setModBus(pgDevice.getModBus()); this.setMome(pgDevice.getMome()); this.setIsOpen(String.valueOf(pgDevice.getIsOpen())); diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java index c1548e0..e348f7a 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java @@ -5,7 +5,7 @@ import java.io.Serializable; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ public class PgDeviceTypeDto implements Serializable { @@ -37,12 +37,11 @@ this.active = active; } - public PgDeviceTypeDto(PgDeviceType pgDeviceType) - { + public PgDeviceTypeDto(PgDeviceType pgDeviceType) { + this.setId(String.valueOf(pgDeviceType.getId())); this.setDevType(pgDeviceType.getDevType()); this.setActive(String.valueOf(pgDeviceType.getActive())); } - } 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 3acd0fa..95c18b4 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java @@ -3,6 +3,7 @@ import com.casic.PgInterface.devTable.domain.PgPartition; import java.io.Serializable; +import java.text.SimpleDateFormat; /** * Created by yxw on 2017/11/2. @@ -12,6 +13,12 @@ private String id; private String parName;//分区名称 private String road;//所属道路 + private String pgPosition;//仓段位置 + private String pgNum;//仓位数量 + private String pgType;//仓位类型 + private String pgLength;//分区长度 + private String buildDate;//建设年代 + private String material;//建设材质 private String active;//状态位 @@ -47,11 +54,67 @@ this.road = road; } + public String getPgPosition() { + return pgPosition; + } + + public void setPgPosition(String pgPosition) { + this.pgPosition = pgPosition; + } + + public String getPgNum() { + return pgNum; + } + + public void setPgNum(String pgNum) { + this.pgNum = pgNum; + } + + public String getPgType() { + return pgType; + } + + public void setPgType(String pgType) { + this.pgType = pgType; + } + + public String getPgLength() { + return pgLength; + } + + public void setPgLength(String pgLength) { + this.pgLength = pgLength; + } + + public String getBuildDate() { + return buildDate; + } + + public void setBuildDate(String buildDate) { + this.buildDate = buildDate; + } + + public String getMaterial() { + return material; + } + + public void setMaterial(String material) { + this.material = material; + } + public PgPartitionDto(PgPartition pgPartition) { + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); + this.setId(String.valueOf(pgPartition.getId())); this.setParName(pgPartition.getParName()); this.setRoad(pgPartition.getRoad()); + this.setPgPosition(pgPartition.getPgPosition()); + this.setPgNum(pgPartition.getPgNum()); + this.setPgType(pgPartition.getPgType()); + this.setPgLength(pgPartition.getPgLength()); + this.setBuildDate(sdf.format(pgPartition.getBuildDate())); + this.setMaterial(pgPartition.getMaterial()); this.setActive(String.valueOf(pgPartition.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java b/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java index d7c6024..9ea43fd 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java @@ -12,10 +12,10 @@ import java.util.List; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Service -public class PgDeviceTypeManager extends HibernateEntityDao{ +public class PgDeviceTypeManager extends HibernateEntityDao { public List getAllDeviceType() { @@ -23,8 +23,8 @@ criteria.add(Restrictions.eq("active", 1)); criteria.addOrder(Order.desc("id")); - List pgDeviceTypeList= criteria.list(); - List pgDeviceTypeDtoList=new ArrayList(); + List pgDeviceTypeList = criteria.list(); + List pgDeviceTypeDtoList = new ArrayList(); for (PgDeviceType pgDeviceType : pgDeviceTypeList) { pgDeviceTypeDtoList.add(new PgDeviceTypeDto(pgDeviceType)); } @@ -32,15 +32,14 @@ return pgDeviceTypeDtoList; } - public PgDeviceType getPgDeviceTypeByDevType(String devType) - { - Criteria criteria=createCriteria(PgDeviceType.class); - criteria.add(Restrictions.eq("devType",devType)); - criteria.add(Restrictions.eq("active",1)); - criteria.addOrder(Order.desc("id")); + public PgDeviceType getDeviceTypeByDeType(String devType) { - List pgDeviceTypeList=criteria.list(); - if(pgDeviceTypeList==null||pgDeviceTypeList.size()==0) + Criteria criteria = createCriteria(PgDeviceType.class); + criteria.add(Restrictions.eq("active", 1)); + criteria.add(Restrictions.eq("devType", devType)); + + List pgDeviceTypeList = criteria.list(); + if (pgDeviceTypeList.size() == 0) return null; else return pgDeviceTypeList.get(0); 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 0c594e7..c6f22cb 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java @@ -64,4 +64,4 @@ -} +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java index 9d06235..68b14cf 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java @@ -1,9 +1,5 @@ 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; @@ -19,7 +15,8 @@ private long id; private String highValue;//高限 private String lowValue;//低限 - private PgDevice pgDeviceId;//设备 + private String unit;//单位 + private String devType;//设备类型 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_ALARM_RULE_ID") @@ -49,15 +46,24 @@ this.lowValue = lowValue; } - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PGDEVICEID") - public PgDevice getPgDeviceId() { - return pgDeviceId; + @Column(name="UNIT") + public String getUnit() { + return unit; } - public void setPgDeviceId(PgDevice pgDeviceId) { - this.pgDeviceId = pgDeviceId; + public void setUnit(String unit) { + this.unit = unit; } + @Column(name = "DEVTYPE") + public String getDevType() { + return devType; + } + + public void setDevType(String devType) { + this.devType = devType; + } + + + } diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java deleted file mode 100644 index 7907e66..0000000 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.casic.PgInterface.patroler.dto; - -/** - * Created by yxw on 2017/12/14. - */ -public class PgAlarmRule { -} diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java index 8367ad4..0782c63 100644 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java @@ -12,7 +12,8 @@ private String id; private String highValue;//高限 private String lowValue;//低限 - private String devName;//设备 + private String devType;//设备类型 + private String unit;//单位 public String getId() { return id; @@ -38,20 +39,29 @@ this.lowValue = lowValue; } - public String getDevName() { - return devName; + public String getDevType() { + return devType; } - public void setDevName(String devName) { - this.devName = devName; + public void setDevType(String devType) { + this.devType = devType; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; } public PgAlarmRuleDto(PgAlarmRule pgAlarmRule) { this.setId(String.valueOf(pgAlarmRule.getId())); - this.setDevName(pgAlarmRule.getPgDeviceId().getAssetName()); this.setHighValue(pgAlarmRule.getHighValue()); this.setLowValue(pgAlarmRule.getLowValue()); + this.setDevType(pgAlarmRule.getDevType()); + this.setUnit(pgAlarmRule.getUnit()); } } diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java index d5c00b2..84e5cdd 100644 --- a/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java @@ -1,13 +1,13 @@ 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.ArrayList; import java.util.List; /** @@ -17,20 +17,21 @@ public class PgAlarmRuleManager extends HibernateEntityDao { //根据设备获取设备报警阈值 - public PgAlarmRuleDto getAlarmRuleDtoBydev(PgDevice pgDeviceId) { + public List getAlarmRuleDto() { 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)); + List pgAlarmRuleDtoList = new ArrayList(); + for (PgAlarmRule pgAlarmRule : pgAlarmRuleList) { + pgAlarmRuleDtoList.add(new PgAlarmRuleDto(pgAlarmRule)); + } + return pgAlarmRuleDtoList; + } - public PgAlarmRule getAlarmRuleBydev(PgDevice pgDeviceId) { + public PgAlarmRule getAlarmRuleBydevType(String devType) { Criteria criteria=createCriteria(PgAlarmRule.class); - criteria.add(Restrictions.eq("pgDeviceId", pgDeviceId)); + criteria.add(Restrictions.eq("devType", devType)); List pgAlarmRuleList=criteria.list(); if(pgAlarmRuleList.size()==0) diff --git a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java b/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java deleted file mode 100644 index b2affe5..0000000 --- a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.casic.PgInterface.devData.dto; - -/** - * Created by yxw on 2017/11/28. - */ -public class PgTempHunDto { -} 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 eb1f7ab..da8f617 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -39,7 +39,6 @@ private List pgShs; private List pgTempHums; - @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") public long getId() { diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java index 4278dc1..669b60f 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java @@ -2,21 +2,20 @@ import javax.persistence.*; import java.io.Serializable; -import java.util.List; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Entity @Table(name = "PG_DEVICE_TYPE") @SequenceGenerator(name = "SEQ_PG_DEVICE_TYPE_ID", sequenceName = "SEQ_PG_DEVICE_TYPE_ID", allocationSize = 1, initialValue = 1) public class PgDeviceType implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; private long id; private String devType; private int active; - private List pgDeviceList; + @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_TYPE_ID") @@ -45,13 +44,4 @@ public void setActive(int active) { this.active = active; } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "devTypeId") - public List getPgDeviceList() { - return pgDeviceList; - } - - public void setPgDeviceList(List pgDeviceList) { - this.pgDeviceList = pgDeviceList; - } } 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 4fb3d6f..d209733 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java @@ -2,6 +2,7 @@ import javax.persistence.*; import java.io.Serializable; +import java.util.Date; import java.util.List; /** @@ -17,6 +18,12 @@ private long id; private String parName;//分区名称 private String road;//所属道路 + private String pgPosition;//仓段位置 + private String pgNum;//仓位数量 + private String pgType;//仓位类型 + private String pgLength;//分区长度 + private Date buildDate;//建设年代 + private String material;//建设材质 private int active;//状态位 private List pipeGalleryList;//管廊仓 @@ -48,6 +55,60 @@ this.road = road; } + @Column(name = "PGPOSITION") + public String getPgPosition() { + return pgPosition; + } + + public void setPgPosition(String pgPosition) { + this.pgPosition = pgPosition; + } + + @Column(name = "PGNUM") + public String getPgNum() { + return pgNum; + } + + public void setPgNum(String pgNum) { + this.pgNum = pgNum; + } + + @Column(name = "PGTYPE") + public String getPgType() { + return pgType; + } + + public void setPgType(String pgType) { + this.pgType = pgType; + } + + @Column(name = "PGLENGTH") + public String getPgLength() { + return pgLength; + } + + public void setPgLength(String pgLength) { + this.pgLength = pgLength; + } + + @Column(name = "BUILDDATE") + public Date getBuildDate() { + return buildDate; + } + + public void setBuildDate(Date buildDate) { + this.buildDate = buildDate; + } + + @Column(name = "MATERIAL") + public String getMaterial() { + return material; + } + + public void setMaterial(String material) { + this.material = material; + } + @Column(name = "ACTIVE") public int getActive() { return active; 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 95f9fbd..b60c42d 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java @@ -160,7 +160,7 @@ this.setAssetName(pgDevice.getAssetName()); this.setAssetCode(pgDevice.getAssetCode()); this.setAssetBarCode(pgDevice.getAssetBarCode()); - this.setId(pgDevice.getIp()); + this.setIp(pgDevice.getIp()); this.setModBus(pgDevice.getModBus()); this.setMome(pgDevice.getMome()); this.setIsOpen(String.valueOf(pgDevice.getIsOpen())); diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java index c1548e0..e348f7a 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java @@ -5,7 +5,7 @@ import java.io.Serializable; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ public class PgDeviceTypeDto implements Serializable { @@ -37,12 +37,11 @@ this.active = active; } - public PgDeviceTypeDto(PgDeviceType pgDeviceType) - { + public PgDeviceTypeDto(PgDeviceType pgDeviceType) { + this.setId(String.valueOf(pgDeviceType.getId())); this.setDevType(pgDeviceType.getDevType()); this.setActive(String.valueOf(pgDeviceType.getActive())); } - } 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 3acd0fa..95c18b4 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java @@ -3,6 +3,7 @@ import com.casic.PgInterface.devTable.domain.PgPartition; import java.io.Serializable; +import java.text.SimpleDateFormat; /** * Created by yxw on 2017/11/2. @@ -12,6 +13,12 @@ private String id; private String parName;//分区名称 private String road;//所属道路 + private String pgPosition;//仓段位置 + private String pgNum;//仓位数量 + private String pgType;//仓位类型 + private String pgLength;//分区长度 + private String buildDate;//建设年代 + private String material;//建设材质 private String active;//状态位 @@ -47,11 +54,67 @@ this.road = road; } + public String getPgPosition() { + return pgPosition; + } + + public void setPgPosition(String pgPosition) { + this.pgPosition = pgPosition; + } + + public String getPgNum() { + return pgNum; + } + + public void setPgNum(String pgNum) { + this.pgNum = pgNum; + } + + public String getPgType() { + return pgType; + } + + public void setPgType(String pgType) { + this.pgType = pgType; + } + + public String getPgLength() { + return pgLength; + } + + public void setPgLength(String pgLength) { + this.pgLength = pgLength; + } + + public String getBuildDate() { + return buildDate; + } + + public void setBuildDate(String buildDate) { + this.buildDate = buildDate; + } + + public String getMaterial() { + return material; + } + + public void setMaterial(String material) { + this.material = material; + } + public PgPartitionDto(PgPartition pgPartition) { + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); + this.setId(String.valueOf(pgPartition.getId())); this.setParName(pgPartition.getParName()); this.setRoad(pgPartition.getRoad()); + this.setPgPosition(pgPartition.getPgPosition()); + this.setPgNum(pgPartition.getPgNum()); + this.setPgType(pgPartition.getPgType()); + this.setPgLength(pgPartition.getPgLength()); + this.setBuildDate(sdf.format(pgPartition.getBuildDate())); + this.setMaterial(pgPartition.getMaterial()); this.setActive(String.valueOf(pgPartition.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java b/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java index d7c6024..9ea43fd 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java @@ -12,10 +12,10 @@ import java.util.List; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Service -public class PgDeviceTypeManager extends HibernateEntityDao{ +public class PgDeviceTypeManager extends HibernateEntityDao { public List getAllDeviceType() { @@ -23,8 +23,8 @@ criteria.add(Restrictions.eq("active", 1)); criteria.addOrder(Order.desc("id")); - List pgDeviceTypeList= criteria.list(); - List pgDeviceTypeDtoList=new ArrayList(); + List pgDeviceTypeList = criteria.list(); + List pgDeviceTypeDtoList = new ArrayList(); for (PgDeviceType pgDeviceType : pgDeviceTypeList) { pgDeviceTypeDtoList.add(new PgDeviceTypeDto(pgDeviceType)); } @@ -32,15 +32,14 @@ return pgDeviceTypeDtoList; } - public PgDeviceType getPgDeviceTypeByDevType(String devType) - { - Criteria criteria=createCriteria(PgDeviceType.class); - criteria.add(Restrictions.eq("devType",devType)); - criteria.add(Restrictions.eq("active",1)); - criteria.addOrder(Order.desc("id")); + public PgDeviceType getDeviceTypeByDeType(String devType) { - List pgDeviceTypeList=criteria.list(); - if(pgDeviceTypeList==null||pgDeviceTypeList.size()==0) + Criteria criteria = createCriteria(PgDeviceType.class); + criteria.add(Restrictions.eq("active", 1)); + criteria.add(Restrictions.eq("devType", devType)); + + List pgDeviceTypeList = criteria.list(); + if (pgDeviceTypeList.size() == 0) return null; else return pgDeviceTypeList.get(0); 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 0c594e7..c6f22cb 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java @@ -64,4 +64,4 @@ -} +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java index 9d06235..68b14cf 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java @@ -1,9 +1,5 @@ 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; @@ -19,7 +15,8 @@ private long id; private String highValue;//高限 private String lowValue;//低限 - private PgDevice pgDeviceId;//设备 + private String unit;//单位 + private String devType;//设备类型 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_ALARM_RULE_ID") @@ -49,15 +46,24 @@ this.lowValue = lowValue; } - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PGDEVICEID") - public PgDevice getPgDeviceId() { - return pgDeviceId; + @Column(name="UNIT") + public String getUnit() { + return unit; } - public void setPgDeviceId(PgDevice pgDeviceId) { - this.pgDeviceId = pgDeviceId; + public void setUnit(String unit) { + this.unit = unit; } + @Column(name = "DEVTYPE") + public String getDevType() { + return devType; + } + + public void setDevType(String devType) { + this.devType = devType; + } + + + } diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java deleted file mode 100644 index 7907e66..0000000 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.casic.PgInterface.patroler.dto; - -/** - * Created by yxw on 2017/12/14. - */ -public class PgAlarmRule { -} diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java index 8367ad4..0782c63 100644 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java @@ -12,7 +12,8 @@ private String id; private String highValue;//高限 private String lowValue;//低限 - private String devName;//设备 + private String devType;//设备类型 + private String unit;//单位 public String getId() { return id; @@ -38,20 +39,29 @@ this.lowValue = lowValue; } - public String getDevName() { - return devName; + public String getDevType() { + return devType; } - public void setDevName(String devName) { - this.devName = devName; + public void setDevType(String devType) { + this.devType = devType; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; } public PgAlarmRuleDto(PgAlarmRule pgAlarmRule) { this.setId(String.valueOf(pgAlarmRule.getId())); - this.setDevName(pgAlarmRule.getPgDeviceId().getAssetName()); this.setHighValue(pgAlarmRule.getHighValue()); this.setLowValue(pgAlarmRule.getLowValue()); + this.setDevType(pgAlarmRule.getDevType()); + this.setUnit(pgAlarmRule.getUnit()); } } diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java index d5c00b2..84e5cdd 100644 --- a/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java @@ -1,13 +1,13 @@ 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.ArrayList; import java.util.List; /** @@ -17,20 +17,21 @@ public class PgAlarmRuleManager extends HibernateEntityDao { //根据设备获取设备报警阈值 - public PgAlarmRuleDto getAlarmRuleDtoBydev(PgDevice pgDeviceId) { + public List getAlarmRuleDto() { 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)); + List pgAlarmRuleDtoList = new ArrayList(); + for (PgAlarmRule pgAlarmRule : pgAlarmRuleList) { + pgAlarmRuleDtoList.add(new PgAlarmRuleDto(pgAlarmRule)); + } + return pgAlarmRuleDtoList; + } - public PgAlarmRule getAlarmRuleBydev(PgDevice pgDeviceId) { + public PgAlarmRule getAlarmRuleBydevType(String devType) { Criteria criteria=createCriteria(PgAlarmRule.class); - criteria.add(Restrictions.eq("pgDeviceId", pgDeviceId)); + criteria.add(Restrictions.eq("devType", devType)); List pgAlarmRuleList=criteria.list(); if(pgAlarmRuleList.size()==0) diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java index f4e48c6..9396013 100644 --- a/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java @@ -39,13 +39,13 @@ } if (StringUtils.isNotBlank(startTime)) { - criteria.add(Restrictions.ge("operateTime", DateUtils.sdf4.parse(startTime))); + criteria.add(Restrictions.ge("operateTime", DateUtils.sdf_day.parse(startTime))); } if (StringUtils.isNotBlank(endTime)) { Calendar calendar = Calendar.getInstance(); - calendar.setTime(DateUtils.sdf4.parse(endTime)); + calendar.setTime(DateUtils.sdf_day.parse(endTime)); calendar.add(Calendar.DATE, 1); - criteria.add(Restrictions.le("time", calendar.getTime())); + criteria.add(Restrictions.le("operateTime", calendar.getTime())); } criteria.add(Restrictions.eq("active", 1)); diff --git a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java b/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java deleted file mode 100644 index b2affe5..0000000 --- a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.casic.PgInterface.devData.dto; - -/** - * Created by yxw on 2017/11/28. - */ -public class PgTempHunDto { -} 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 eb1f7ab..da8f617 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -39,7 +39,6 @@ private List pgShs; private List pgTempHums; - @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") public long getId() { diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java index 4278dc1..669b60f 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java @@ -2,21 +2,20 @@ import javax.persistence.*; import java.io.Serializable; -import java.util.List; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Entity @Table(name = "PG_DEVICE_TYPE") @SequenceGenerator(name = "SEQ_PG_DEVICE_TYPE_ID", sequenceName = "SEQ_PG_DEVICE_TYPE_ID", allocationSize = 1, initialValue = 1) public class PgDeviceType implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; private long id; private String devType; private int active; - private List pgDeviceList; + @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_TYPE_ID") @@ -45,13 +44,4 @@ public void setActive(int active) { this.active = active; } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "devTypeId") - public List getPgDeviceList() { - return pgDeviceList; - } - - public void setPgDeviceList(List pgDeviceList) { - this.pgDeviceList = pgDeviceList; - } } 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 4fb3d6f..d209733 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java @@ -2,6 +2,7 @@ import javax.persistence.*; import java.io.Serializable; +import java.util.Date; import java.util.List; /** @@ -17,6 +18,12 @@ private long id; private String parName;//分区名称 private String road;//所属道路 + private String pgPosition;//仓段位置 + private String pgNum;//仓位数量 + private String pgType;//仓位类型 + private String pgLength;//分区长度 + private Date buildDate;//建设年代 + private String material;//建设材质 private int active;//状态位 private List pipeGalleryList;//管廊仓 @@ -48,6 +55,60 @@ this.road = road; } + @Column(name = "PGPOSITION") + public String getPgPosition() { + return pgPosition; + } + + public void setPgPosition(String pgPosition) { + this.pgPosition = pgPosition; + } + + @Column(name = "PGNUM") + public String getPgNum() { + return pgNum; + } + + public void setPgNum(String pgNum) { + this.pgNum = pgNum; + } + + @Column(name = "PGTYPE") + public String getPgType() { + return pgType; + } + + public void setPgType(String pgType) { + this.pgType = pgType; + } + + @Column(name = "PGLENGTH") + public String getPgLength() { + return pgLength; + } + + public void setPgLength(String pgLength) { + this.pgLength = pgLength; + } + + @Column(name = "BUILDDATE") + public Date getBuildDate() { + return buildDate; + } + + public void setBuildDate(Date buildDate) { + this.buildDate = buildDate; + } + + @Column(name = "MATERIAL") + public String getMaterial() { + return material; + } + + public void setMaterial(String material) { + this.material = material; + } + @Column(name = "ACTIVE") public int getActive() { return active; 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 95f9fbd..b60c42d 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java @@ -160,7 +160,7 @@ this.setAssetName(pgDevice.getAssetName()); this.setAssetCode(pgDevice.getAssetCode()); this.setAssetBarCode(pgDevice.getAssetBarCode()); - this.setId(pgDevice.getIp()); + this.setIp(pgDevice.getIp()); this.setModBus(pgDevice.getModBus()); this.setMome(pgDevice.getMome()); this.setIsOpen(String.valueOf(pgDevice.getIsOpen())); diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java index c1548e0..e348f7a 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java @@ -5,7 +5,7 @@ import java.io.Serializable; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ public class PgDeviceTypeDto implements Serializable { @@ -37,12 +37,11 @@ this.active = active; } - public PgDeviceTypeDto(PgDeviceType pgDeviceType) - { + public PgDeviceTypeDto(PgDeviceType pgDeviceType) { + this.setId(String.valueOf(pgDeviceType.getId())); this.setDevType(pgDeviceType.getDevType()); this.setActive(String.valueOf(pgDeviceType.getActive())); } - } 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 3acd0fa..95c18b4 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java @@ -3,6 +3,7 @@ import com.casic.PgInterface.devTable.domain.PgPartition; import java.io.Serializable; +import java.text.SimpleDateFormat; /** * Created by yxw on 2017/11/2. @@ -12,6 +13,12 @@ private String id; private String parName;//分区名称 private String road;//所属道路 + private String pgPosition;//仓段位置 + private String pgNum;//仓位数量 + private String pgType;//仓位类型 + private String pgLength;//分区长度 + private String buildDate;//建设年代 + private String material;//建设材质 private String active;//状态位 @@ -47,11 +54,67 @@ this.road = road; } + public String getPgPosition() { + return pgPosition; + } + + public void setPgPosition(String pgPosition) { + this.pgPosition = pgPosition; + } + + public String getPgNum() { + return pgNum; + } + + public void setPgNum(String pgNum) { + this.pgNum = pgNum; + } + + public String getPgType() { + return pgType; + } + + public void setPgType(String pgType) { + this.pgType = pgType; + } + + public String getPgLength() { + return pgLength; + } + + public void setPgLength(String pgLength) { + this.pgLength = pgLength; + } + + public String getBuildDate() { + return buildDate; + } + + public void setBuildDate(String buildDate) { + this.buildDate = buildDate; + } + + public String getMaterial() { + return material; + } + + public void setMaterial(String material) { + this.material = material; + } + public PgPartitionDto(PgPartition pgPartition) { + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); + this.setId(String.valueOf(pgPartition.getId())); this.setParName(pgPartition.getParName()); this.setRoad(pgPartition.getRoad()); + this.setPgPosition(pgPartition.getPgPosition()); + this.setPgNum(pgPartition.getPgNum()); + this.setPgType(pgPartition.getPgType()); + this.setPgLength(pgPartition.getPgLength()); + this.setBuildDate(sdf.format(pgPartition.getBuildDate())); + this.setMaterial(pgPartition.getMaterial()); this.setActive(String.valueOf(pgPartition.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java b/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java index d7c6024..9ea43fd 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java @@ -12,10 +12,10 @@ import java.util.List; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Service -public class PgDeviceTypeManager extends HibernateEntityDao{ +public class PgDeviceTypeManager extends HibernateEntityDao { public List getAllDeviceType() { @@ -23,8 +23,8 @@ criteria.add(Restrictions.eq("active", 1)); criteria.addOrder(Order.desc("id")); - List pgDeviceTypeList= criteria.list(); - List pgDeviceTypeDtoList=new ArrayList(); + List pgDeviceTypeList = criteria.list(); + List pgDeviceTypeDtoList = new ArrayList(); for (PgDeviceType pgDeviceType : pgDeviceTypeList) { pgDeviceTypeDtoList.add(new PgDeviceTypeDto(pgDeviceType)); } @@ -32,15 +32,14 @@ return pgDeviceTypeDtoList; } - public PgDeviceType getPgDeviceTypeByDevType(String devType) - { - Criteria criteria=createCriteria(PgDeviceType.class); - criteria.add(Restrictions.eq("devType",devType)); - criteria.add(Restrictions.eq("active",1)); - criteria.addOrder(Order.desc("id")); + public PgDeviceType getDeviceTypeByDeType(String devType) { - List pgDeviceTypeList=criteria.list(); - if(pgDeviceTypeList==null||pgDeviceTypeList.size()==0) + Criteria criteria = createCriteria(PgDeviceType.class); + criteria.add(Restrictions.eq("active", 1)); + criteria.add(Restrictions.eq("devType", devType)); + + List pgDeviceTypeList = criteria.list(); + if (pgDeviceTypeList.size() == 0) return null; else return pgDeviceTypeList.get(0); 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 0c594e7..c6f22cb 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java @@ -64,4 +64,4 @@ -} +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java index 9d06235..68b14cf 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java @@ -1,9 +1,5 @@ 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; @@ -19,7 +15,8 @@ private long id; private String highValue;//高限 private String lowValue;//低限 - private PgDevice pgDeviceId;//设备 + private String unit;//单位 + private String devType;//设备类型 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_ALARM_RULE_ID") @@ -49,15 +46,24 @@ this.lowValue = lowValue; } - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PGDEVICEID") - public PgDevice getPgDeviceId() { - return pgDeviceId; + @Column(name="UNIT") + public String getUnit() { + return unit; } - public void setPgDeviceId(PgDevice pgDeviceId) { - this.pgDeviceId = pgDeviceId; + public void setUnit(String unit) { + this.unit = unit; } + @Column(name = "DEVTYPE") + public String getDevType() { + return devType; + } + + public void setDevType(String devType) { + this.devType = devType; + } + + + } diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java deleted file mode 100644 index 7907e66..0000000 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.casic.PgInterface.patroler.dto; - -/** - * Created by yxw on 2017/12/14. - */ -public class PgAlarmRule { -} diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java index 8367ad4..0782c63 100644 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java @@ -12,7 +12,8 @@ private String id; private String highValue;//高限 private String lowValue;//低限 - private String devName;//设备 + private String devType;//设备类型 + private String unit;//单位 public String getId() { return id; @@ -38,20 +39,29 @@ this.lowValue = lowValue; } - public String getDevName() { - return devName; + public String getDevType() { + return devType; } - public void setDevName(String devName) { - this.devName = devName; + public void setDevType(String devType) { + this.devType = devType; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; } public PgAlarmRuleDto(PgAlarmRule pgAlarmRule) { this.setId(String.valueOf(pgAlarmRule.getId())); - this.setDevName(pgAlarmRule.getPgDeviceId().getAssetName()); this.setHighValue(pgAlarmRule.getHighValue()); this.setLowValue(pgAlarmRule.getLowValue()); + this.setDevType(pgAlarmRule.getDevType()); + this.setUnit(pgAlarmRule.getUnit()); } } diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java index d5c00b2..84e5cdd 100644 --- a/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java @@ -1,13 +1,13 @@ 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.ArrayList; import java.util.List; /** @@ -17,20 +17,21 @@ public class PgAlarmRuleManager extends HibernateEntityDao { //根据设备获取设备报警阈值 - public PgAlarmRuleDto getAlarmRuleDtoBydev(PgDevice pgDeviceId) { + public List getAlarmRuleDto() { 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)); + List pgAlarmRuleDtoList = new ArrayList(); + for (PgAlarmRule pgAlarmRule : pgAlarmRuleList) { + pgAlarmRuleDtoList.add(new PgAlarmRuleDto(pgAlarmRule)); + } + return pgAlarmRuleDtoList; + } - public PgAlarmRule getAlarmRuleBydev(PgDevice pgDeviceId) { + public PgAlarmRule getAlarmRuleBydevType(String devType) { Criteria criteria=createCriteria(PgAlarmRule.class); - criteria.add(Restrictions.eq("pgDeviceId", pgDeviceId)); + criteria.add(Restrictions.eq("devType", devType)); List pgAlarmRuleList=criteria.list(); if(pgAlarmRuleList.size()==0) diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java index f4e48c6..9396013 100644 --- a/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java @@ -39,13 +39,13 @@ } if (StringUtils.isNotBlank(startTime)) { - criteria.add(Restrictions.ge("operateTime", DateUtils.sdf4.parse(startTime))); + criteria.add(Restrictions.ge("operateTime", DateUtils.sdf_day.parse(startTime))); } if (StringUtils.isNotBlank(endTime)) { Calendar calendar = Calendar.getInstance(); - calendar.setTime(DateUtils.sdf4.parse(endTime)); + calendar.setTime(DateUtils.sdf_day.parse(endTime)); calendar.add(Calendar.DATE, 1); - criteria.add(Restrictions.le("time", calendar.getTime())); + criteria.add(Restrictions.le("operateTime", calendar.getTime())); } criteria.add(Restrictions.eq("active", 1)); diff --git a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java index 88255c6..f28ebdf 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java @@ -1,6 +1,5 @@ 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; @@ -15,7 +14,9 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -42,72 +43,43 @@ } /** - * 获取报警阈值信息 - */ - @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 { + public Map addAlarmRule(@FormParam("highValue") String highValue, + @FormParam("lowValue") String lowValue, + @FormParam("unit") String unit, + @FormParam("devType") String devType) 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(); + try { + pgAlarmRule = pgAlarmRuleManager.getAlarmRuleBydevType(devType); + if (pgAlarmRule != null) { result = "false"; - msg = "报警阈值新增失败"; + msg = "设备阈值已经存在"; + } else { + pgAlarmRule = new PgAlarmRule(); + pgAlarmRule.setHighValue(highValue); + pgAlarmRule.setLowValue(lowValue); + pgAlarmRule.setDevType(devType); + pgAlarmRule.setUnit(unit); + + pgAlarmRuleManager.save(pgAlarmRule); + result = "true"; + msg = "报警阈值新增成功"; } + } catch (Exception e) { + e.printStackTrace(); + result = "false"; + msg = "报警阈值新增失败"; } + resultMap.put("msg", msg); resultMap.put("result", result); return resultMap; @@ -119,44 +91,66 @@ @POST @Path("editAlarmRule") @Produces(MediaType.APPLICATION_JSON) - public Map editAlarmRule(@FormParam("id") String id, - @FormParam("assetCode") String assetCode, + public Map editAlarmRule(@FormParam("devType") String devType, @FormParam("highValue") String highValue, - @FormParam("lowValue") String lowValue) throws Exception { + @FormParam("lowValue") String lowValue, + @FormParam("unit") String unit) 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(); + + try { + pgAlarmRule = pgAlarmRuleManager.getAlarmRuleBydevType(devType); + if (pgAlarmRule == null) { + msg = "不存在报警阈值记录"; result = "false"; - msg = "报警阈值编辑失败"; + } else { + pgAlarmRule.setDevType(devType); + pgAlarmRule.setHighValue(highValue); + pgAlarmRule.setLowValue(lowValue); + pgAlarmRule.setUnit(unit); + pgAlarmRuleManager.save(pgAlarmRule); + msg = "编辑成功"; + result = "true"; } + } catch (Exception ex) { + ex.printStackTrace(); + result = "false"; + msg = "报警阈值编辑失败"; } + resultMap.put("msg", msg); resultMap.put("result", result); return resultMap; + } + /** + * 获取报警阈值信息 + */ + @POST + @Path("getAlarmRule") + @Produces(MediaType.APPLICATION_JSON) + public Map getAlarmRule() throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + + List pgAlarmRuleDtoList = new ArrayList(); + try { + pgAlarmRuleDtoList = pgAlarmRuleManager.getAlarmRuleDto(); + if (pgAlarmRuleDtoList == null) + msg = "不存在报警阈值信息"; + else + msg = "报警阈值获取成功"; + } catch (Exception e) { + e.printStackTrace(); + msg = "报警信息获取失败"; + } + resultMap.put("msg", msg); + resultMap.put("result", pgAlarmRuleDtoList); + return resultMap; } } \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java b/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java deleted file mode 100644 index b2affe5..0000000 --- a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.casic.PgInterface.devData.dto; - -/** - * Created by yxw on 2017/11/28. - */ -public class PgTempHunDto { -} 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 eb1f7ab..da8f617 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -39,7 +39,6 @@ private List pgShs; private List pgTempHums; - @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") public long getId() { diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java index 4278dc1..669b60f 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java @@ -2,21 +2,20 @@ import javax.persistence.*; import java.io.Serializable; -import java.util.List; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Entity @Table(name = "PG_DEVICE_TYPE") @SequenceGenerator(name = "SEQ_PG_DEVICE_TYPE_ID", sequenceName = "SEQ_PG_DEVICE_TYPE_ID", allocationSize = 1, initialValue = 1) public class PgDeviceType implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; private long id; private String devType; private int active; - private List pgDeviceList; + @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_TYPE_ID") @@ -45,13 +44,4 @@ public void setActive(int active) { this.active = active; } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "devTypeId") - public List getPgDeviceList() { - return pgDeviceList; - } - - public void setPgDeviceList(List pgDeviceList) { - this.pgDeviceList = pgDeviceList; - } } 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 4fb3d6f..d209733 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java @@ -2,6 +2,7 @@ import javax.persistence.*; import java.io.Serializable; +import java.util.Date; import java.util.List; /** @@ -17,6 +18,12 @@ private long id; private String parName;//分区名称 private String road;//所属道路 + private String pgPosition;//仓段位置 + private String pgNum;//仓位数量 + private String pgType;//仓位类型 + private String pgLength;//分区长度 + private Date buildDate;//建设年代 + private String material;//建设材质 private int active;//状态位 private List pipeGalleryList;//管廊仓 @@ -48,6 +55,60 @@ this.road = road; } + @Column(name = "PGPOSITION") + public String getPgPosition() { + return pgPosition; + } + + public void setPgPosition(String pgPosition) { + this.pgPosition = pgPosition; + } + + @Column(name = "PGNUM") + public String getPgNum() { + return pgNum; + } + + public void setPgNum(String pgNum) { + this.pgNum = pgNum; + } + + @Column(name = "PGTYPE") + public String getPgType() { + return pgType; + } + + public void setPgType(String pgType) { + this.pgType = pgType; + } + + @Column(name = "PGLENGTH") + public String getPgLength() { + return pgLength; + } + + public void setPgLength(String pgLength) { + this.pgLength = pgLength; + } + + @Column(name = "BUILDDATE") + public Date getBuildDate() { + return buildDate; + } + + public void setBuildDate(Date buildDate) { + this.buildDate = buildDate; + } + + @Column(name = "MATERIAL") + public String getMaterial() { + return material; + } + + public void setMaterial(String material) { + this.material = material; + } + @Column(name = "ACTIVE") public int getActive() { return active; 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 95f9fbd..b60c42d 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java @@ -160,7 +160,7 @@ this.setAssetName(pgDevice.getAssetName()); this.setAssetCode(pgDevice.getAssetCode()); this.setAssetBarCode(pgDevice.getAssetBarCode()); - this.setId(pgDevice.getIp()); + this.setIp(pgDevice.getIp()); this.setModBus(pgDevice.getModBus()); this.setMome(pgDevice.getMome()); this.setIsOpen(String.valueOf(pgDevice.getIsOpen())); diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java index c1548e0..e348f7a 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java @@ -5,7 +5,7 @@ import java.io.Serializable; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ public class PgDeviceTypeDto implements Serializable { @@ -37,12 +37,11 @@ this.active = active; } - public PgDeviceTypeDto(PgDeviceType pgDeviceType) - { + public PgDeviceTypeDto(PgDeviceType pgDeviceType) { + this.setId(String.valueOf(pgDeviceType.getId())); this.setDevType(pgDeviceType.getDevType()); this.setActive(String.valueOf(pgDeviceType.getActive())); } - } 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 3acd0fa..95c18b4 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java @@ -3,6 +3,7 @@ import com.casic.PgInterface.devTable.domain.PgPartition; import java.io.Serializable; +import java.text.SimpleDateFormat; /** * Created by yxw on 2017/11/2. @@ -12,6 +13,12 @@ private String id; private String parName;//分区名称 private String road;//所属道路 + private String pgPosition;//仓段位置 + private String pgNum;//仓位数量 + private String pgType;//仓位类型 + private String pgLength;//分区长度 + private String buildDate;//建设年代 + private String material;//建设材质 private String active;//状态位 @@ -47,11 +54,67 @@ this.road = road; } + public String getPgPosition() { + return pgPosition; + } + + public void setPgPosition(String pgPosition) { + this.pgPosition = pgPosition; + } + + public String getPgNum() { + return pgNum; + } + + public void setPgNum(String pgNum) { + this.pgNum = pgNum; + } + + public String getPgType() { + return pgType; + } + + public void setPgType(String pgType) { + this.pgType = pgType; + } + + public String getPgLength() { + return pgLength; + } + + public void setPgLength(String pgLength) { + this.pgLength = pgLength; + } + + public String getBuildDate() { + return buildDate; + } + + public void setBuildDate(String buildDate) { + this.buildDate = buildDate; + } + + public String getMaterial() { + return material; + } + + public void setMaterial(String material) { + this.material = material; + } + public PgPartitionDto(PgPartition pgPartition) { + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); + this.setId(String.valueOf(pgPartition.getId())); this.setParName(pgPartition.getParName()); this.setRoad(pgPartition.getRoad()); + this.setPgPosition(pgPartition.getPgPosition()); + this.setPgNum(pgPartition.getPgNum()); + this.setPgType(pgPartition.getPgType()); + this.setPgLength(pgPartition.getPgLength()); + this.setBuildDate(sdf.format(pgPartition.getBuildDate())); + this.setMaterial(pgPartition.getMaterial()); this.setActive(String.valueOf(pgPartition.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java b/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java index d7c6024..9ea43fd 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java @@ -12,10 +12,10 @@ import java.util.List; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Service -public class PgDeviceTypeManager extends HibernateEntityDao{ +public class PgDeviceTypeManager extends HibernateEntityDao { public List getAllDeviceType() { @@ -23,8 +23,8 @@ criteria.add(Restrictions.eq("active", 1)); criteria.addOrder(Order.desc("id")); - List pgDeviceTypeList= criteria.list(); - List pgDeviceTypeDtoList=new ArrayList(); + List pgDeviceTypeList = criteria.list(); + List pgDeviceTypeDtoList = new ArrayList(); for (PgDeviceType pgDeviceType : pgDeviceTypeList) { pgDeviceTypeDtoList.add(new PgDeviceTypeDto(pgDeviceType)); } @@ -32,15 +32,14 @@ return pgDeviceTypeDtoList; } - public PgDeviceType getPgDeviceTypeByDevType(String devType) - { - Criteria criteria=createCriteria(PgDeviceType.class); - criteria.add(Restrictions.eq("devType",devType)); - criteria.add(Restrictions.eq("active",1)); - criteria.addOrder(Order.desc("id")); + public PgDeviceType getDeviceTypeByDeType(String devType) { - List pgDeviceTypeList=criteria.list(); - if(pgDeviceTypeList==null||pgDeviceTypeList.size()==0) + Criteria criteria = createCriteria(PgDeviceType.class); + criteria.add(Restrictions.eq("active", 1)); + criteria.add(Restrictions.eq("devType", devType)); + + List pgDeviceTypeList = criteria.list(); + if (pgDeviceTypeList.size() == 0) return null; else return pgDeviceTypeList.get(0); 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 0c594e7..c6f22cb 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java @@ -64,4 +64,4 @@ -} +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java index 9d06235..68b14cf 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java @@ -1,9 +1,5 @@ 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; @@ -19,7 +15,8 @@ private long id; private String highValue;//高限 private String lowValue;//低限 - private PgDevice pgDeviceId;//设备 + private String unit;//单位 + private String devType;//设备类型 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_ALARM_RULE_ID") @@ -49,15 +46,24 @@ this.lowValue = lowValue; } - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PGDEVICEID") - public PgDevice getPgDeviceId() { - return pgDeviceId; + @Column(name="UNIT") + public String getUnit() { + return unit; } - public void setPgDeviceId(PgDevice pgDeviceId) { - this.pgDeviceId = pgDeviceId; + public void setUnit(String unit) { + this.unit = unit; } + @Column(name = "DEVTYPE") + public String getDevType() { + return devType; + } + + public void setDevType(String devType) { + this.devType = devType; + } + + + } diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java deleted file mode 100644 index 7907e66..0000000 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.casic.PgInterface.patroler.dto; - -/** - * Created by yxw on 2017/12/14. - */ -public class PgAlarmRule { -} diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java index 8367ad4..0782c63 100644 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java @@ -12,7 +12,8 @@ private String id; private String highValue;//高限 private String lowValue;//低限 - private String devName;//设备 + private String devType;//设备类型 + private String unit;//单位 public String getId() { return id; @@ -38,20 +39,29 @@ this.lowValue = lowValue; } - public String getDevName() { - return devName; + public String getDevType() { + return devType; } - public void setDevName(String devName) { - this.devName = devName; + public void setDevType(String devType) { + this.devType = devType; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; } public PgAlarmRuleDto(PgAlarmRule pgAlarmRule) { this.setId(String.valueOf(pgAlarmRule.getId())); - this.setDevName(pgAlarmRule.getPgDeviceId().getAssetName()); this.setHighValue(pgAlarmRule.getHighValue()); this.setLowValue(pgAlarmRule.getLowValue()); + this.setDevType(pgAlarmRule.getDevType()); + this.setUnit(pgAlarmRule.getUnit()); } } diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java index d5c00b2..84e5cdd 100644 --- a/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java @@ -1,13 +1,13 @@ 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.ArrayList; import java.util.List; /** @@ -17,20 +17,21 @@ public class PgAlarmRuleManager extends HibernateEntityDao { //根据设备获取设备报警阈值 - public PgAlarmRuleDto getAlarmRuleDtoBydev(PgDevice pgDeviceId) { + public List getAlarmRuleDto() { 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)); + List pgAlarmRuleDtoList = new ArrayList(); + for (PgAlarmRule pgAlarmRule : pgAlarmRuleList) { + pgAlarmRuleDtoList.add(new PgAlarmRuleDto(pgAlarmRule)); + } + return pgAlarmRuleDtoList; + } - public PgAlarmRule getAlarmRuleBydev(PgDevice pgDeviceId) { + public PgAlarmRule getAlarmRuleBydevType(String devType) { Criteria criteria=createCriteria(PgAlarmRule.class); - criteria.add(Restrictions.eq("pgDeviceId", pgDeviceId)); + criteria.add(Restrictions.eq("devType", devType)); List pgAlarmRuleList=criteria.list(); if(pgAlarmRuleList.size()==0) diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java index f4e48c6..9396013 100644 --- a/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java @@ -39,13 +39,13 @@ } if (StringUtils.isNotBlank(startTime)) { - criteria.add(Restrictions.ge("operateTime", DateUtils.sdf4.parse(startTime))); + criteria.add(Restrictions.ge("operateTime", DateUtils.sdf_day.parse(startTime))); } if (StringUtils.isNotBlank(endTime)) { Calendar calendar = Calendar.getInstance(); - calendar.setTime(DateUtils.sdf4.parse(endTime)); + calendar.setTime(DateUtils.sdf_day.parse(endTime)); calendar.add(Calendar.DATE, 1); - criteria.add(Restrictions.le("time", calendar.getTime())); + criteria.add(Restrictions.le("operateTime", calendar.getTime())); } criteria.add(Restrictions.eq("active", 1)); diff --git a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java index 88255c6..f28ebdf 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java @@ -1,6 +1,5 @@ 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; @@ -15,7 +14,9 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -42,72 +43,43 @@ } /** - * 获取报警阈值信息 - */ - @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 { + public Map addAlarmRule(@FormParam("highValue") String highValue, + @FormParam("lowValue") String lowValue, + @FormParam("unit") String unit, + @FormParam("devType") String devType) 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(); + try { + pgAlarmRule = pgAlarmRuleManager.getAlarmRuleBydevType(devType); + if (pgAlarmRule != null) { result = "false"; - msg = "报警阈值新增失败"; + msg = "设备阈值已经存在"; + } else { + pgAlarmRule = new PgAlarmRule(); + pgAlarmRule.setHighValue(highValue); + pgAlarmRule.setLowValue(lowValue); + pgAlarmRule.setDevType(devType); + pgAlarmRule.setUnit(unit); + + pgAlarmRuleManager.save(pgAlarmRule); + result = "true"; + msg = "报警阈值新增成功"; } + } catch (Exception e) { + e.printStackTrace(); + result = "false"; + msg = "报警阈值新增失败"; } + resultMap.put("msg", msg); resultMap.put("result", result); return resultMap; @@ -119,44 +91,66 @@ @POST @Path("editAlarmRule") @Produces(MediaType.APPLICATION_JSON) - public Map editAlarmRule(@FormParam("id") String id, - @FormParam("assetCode") String assetCode, + public Map editAlarmRule(@FormParam("devType") String devType, @FormParam("highValue") String highValue, - @FormParam("lowValue") String lowValue) throws Exception { + @FormParam("lowValue") String lowValue, + @FormParam("unit") String unit) 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(); + + try { + pgAlarmRule = pgAlarmRuleManager.getAlarmRuleBydevType(devType); + if (pgAlarmRule == null) { + msg = "不存在报警阈值记录"; result = "false"; - msg = "报警阈值编辑失败"; + } else { + pgAlarmRule.setDevType(devType); + pgAlarmRule.setHighValue(highValue); + pgAlarmRule.setLowValue(lowValue); + pgAlarmRule.setUnit(unit); + pgAlarmRuleManager.save(pgAlarmRule); + msg = "编辑成功"; + result = "true"; } + } catch (Exception ex) { + ex.printStackTrace(); + result = "false"; + msg = "报警阈值编辑失败"; } + resultMap.put("msg", msg); resultMap.put("result", result); return resultMap; + } + /** + * 获取报警阈值信息 + */ + @POST + @Path("getAlarmRule") + @Produces(MediaType.APPLICATION_JSON) + public Map getAlarmRule() throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + + List pgAlarmRuleDtoList = new ArrayList(); + try { + pgAlarmRuleDtoList = pgAlarmRuleManager.getAlarmRuleDto(); + if (pgAlarmRuleDtoList == null) + msg = "不存在报警阈值信息"; + else + msg = "报警阈值获取成功"; + } catch (Exception e) { + e.printStackTrace(); + msg = "报警信息获取失败"; + } + resultMap.put("msg", msg); + resultMap.put("result", pgAlarmRuleDtoList); + 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 bb8c245..36547a7 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java @@ -104,8 +104,8 @@ @POST @Path("addDevice") @Produces(MediaType.APPLICATION_JSON) - public Map addDevice(@FormParam("parName") String parName, - @FormParam("pgName") String pgName, + public Map addDevice(@FormParam("partition") String partition, + @FormParam("pipeGallery") String pipeGallery, @FormParam("road") String road, @FormParam("position") String position, @FormParam("devType") String devType, @@ -129,8 +129,8 @@ } else { PgDevice pgDevice = new PgDevice(); - pgDevice.setPipeGallery(pgName); - pgDevice.setPartition(parName); + pgDevice.setPipeGallery(pipeGallery); + pgDevice.setPartition(partition); pgDevice.setRoad(road); pgDevice.setPosition(position); pgDevice.setDevType(devType); @@ -168,8 +168,8 @@ @Path("editDevice") @Produces(MediaType.APPLICATION_JSON) public Map editPartition(@FormParam("id") String id, - @FormParam("parName") String parName, - @FormParam("pgName") String pgName, + @FormParam("partition") String partition, + @FormParam("pipeGallery") String pipeGallery, @FormParam("road") String road, @FormParam("position") String position, @FormParam("devType") String devType, @@ -187,13 +187,15 @@ String msg = ""; try { + /* if (pgDeviceManager.getDeviceByAssetCode(assetCode)!=null) { result = "false"; msg = "已存在同名设备"; } else { + */ PgDevice pgDevice = pgDeviceManager.get(Long.valueOf(id)); - pgDevice.setPipeGallery(pgName); - pgDevice.setPartition(parName); + pgDevice.setPipeGallery(pipeGallery); + pgDevice.setPartition(partition); pgDevice.setRoad(road); pgDevice.setPosition(position); pgDevice.setDevType(devType); @@ -210,7 +212,7 @@ pgDeviceManager.save(pgDevice); result = "true"; msg = "编辑成功"; - } + //} } catch (Exception e) { result = "false"; msg = "编辑失败"; diff --git a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java b/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java deleted file mode 100644 index b2affe5..0000000 --- a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.casic.PgInterface.devData.dto; - -/** - * Created by yxw on 2017/11/28. - */ -public class PgTempHunDto { -} 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 eb1f7ab..da8f617 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -39,7 +39,6 @@ private List pgShs; private List pgTempHums; - @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") public long getId() { diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java index 4278dc1..669b60f 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java @@ -2,21 +2,20 @@ import javax.persistence.*; import java.io.Serializable; -import java.util.List; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Entity @Table(name = "PG_DEVICE_TYPE") @SequenceGenerator(name = "SEQ_PG_DEVICE_TYPE_ID", sequenceName = "SEQ_PG_DEVICE_TYPE_ID", allocationSize = 1, initialValue = 1) public class PgDeviceType implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; private long id; private String devType; private int active; - private List pgDeviceList; + @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_TYPE_ID") @@ -45,13 +44,4 @@ public void setActive(int active) { this.active = active; } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "devTypeId") - public List getPgDeviceList() { - return pgDeviceList; - } - - public void setPgDeviceList(List pgDeviceList) { - this.pgDeviceList = pgDeviceList; - } } 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 4fb3d6f..d209733 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java @@ -2,6 +2,7 @@ import javax.persistence.*; import java.io.Serializable; +import java.util.Date; import java.util.List; /** @@ -17,6 +18,12 @@ private long id; private String parName;//分区名称 private String road;//所属道路 + private String pgPosition;//仓段位置 + private String pgNum;//仓位数量 + private String pgType;//仓位类型 + private String pgLength;//分区长度 + private Date buildDate;//建设年代 + private String material;//建设材质 private int active;//状态位 private List pipeGalleryList;//管廊仓 @@ -48,6 +55,60 @@ this.road = road; } + @Column(name = "PGPOSITION") + public String getPgPosition() { + return pgPosition; + } + + public void setPgPosition(String pgPosition) { + this.pgPosition = pgPosition; + } + + @Column(name = "PGNUM") + public String getPgNum() { + return pgNum; + } + + public void setPgNum(String pgNum) { + this.pgNum = pgNum; + } + + @Column(name = "PGTYPE") + public String getPgType() { + return pgType; + } + + public void setPgType(String pgType) { + this.pgType = pgType; + } + + @Column(name = "PGLENGTH") + public String getPgLength() { + return pgLength; + } + + public void setPgLength(String pgLength) { + this.pgLength = pgLength; + } + + @Column(name = "BUILDDATE") + public Date getBuildDate() { + return buildDate; + } + + public void setBuildDate(Date buildDate) { + this.buildDate = buildDate; + } + + @Column(name = "MATERIAL") + public String getMaterial() { + return material; + } + + public void setMaterial(String material) { + this.material = material; + } + @Column(name = "ACTIVE") public int getActive() { return active; 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 95f9fbd..b60c42d 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java @@ -160,7 +160,7 @@ this.setAssetName(pgDevice.getAssetName()); this.setAssetCode(pgDevice.getAssetCode()); this.setAssetBarCode(pgDevice.getAssetBarCode()); - this.setId(pgDevice.getIp()); + this.setIp(pgDevice.getIp()); this.setModBus(pgDevice.getModBus()); this.setMome(pgDevice.getMome()); this.setIsOpen(String.valueOf(pgDevice.getIsOpen())); diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java index c1548e0..e348f7a 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java @@ -5,7 +5,7 @@ import java.io.Serializable; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ public class PgDeviceTypeDto implements Serializable { @@ -37,12 +37,11 @@ this.active = active; } - public PgDeviceTypeDto(PgDeviceType pgDeviceType) - { + public PgDeviceTypeDto(PgDeviceType pgDeviceType) { + this.setId(String.valueOf(pgDeviceType.getId())); this.setDevType(pgDeviceType.getDevType()); this.setActive(String.valueOf(pgDeviceType.getActive())); } - } 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 3acd0fa..95c18b4 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java @@ -3,6 +3,7 @@ import com.casic.PgInterface.devTable.domain.PgPartition; import java.io.Serializable; +import java.text.SimpleDateFormat; /** * Created by yxw on 2017/11/2. @@ -12,6 +13,12 @@ private String id; private String parName;//分区名称 private String road;//所属道路 + private String pgPosition;//仓段位置 + private String pgNum;//仓位数量 + private String pgType;//仓位类型 + private String pgLength;//分区长度 + private String buildDate;//建设年代 + private String material;//建设材质 private String active;//状态位 @@ -47,11 +54,67 @@ this.road = road; } + public String getPgPosition() { + return pgPosition; + } + + public void setPgPosition(String pgPosition) { + this.pgPosition = pgPosition; + } + + public String getPgNum() { + return pgNum; + } + + public void setPgNum(String pgNum) { + this.pgNum = pgNum; + } + + public String getPgType() { + return pgType; + } + + public void setPgType(String pgType) { + this.pgType = pgType; + } + + public String getPgLength() { + return pgLength; + } + + public void setPgLength(String pgLength) { + this.pgLength = pgLength; + } + + public String getBuildDate() { + return buildDate; + } + + public void setBuildDate(String buildDate) { + this.buildDate = buildDate; + } + + public String getMaterial() { + return material; + } + + public void setMaterial(String material) { + this.material = material; + } + public PgPartitionDto(PgPartition pgPartition) { + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); + this.setId(String.valueOf(pgPartition.getId())); this.setParName(pgPartition.getParName()); this.setRoad(pgPartition.getRoad()); + this.setPgPosition(pgPartition.getPgPosition()); + this.setPgNum(pgPartition.getPgNum()); + this.setPgType(pgPartition.getPgType()); + this.setPgLength(pgPartition.getPgLength()); + this.setBuildDate(sdf.format(pgPartition.getBuildDate())); + this.setMaterial(pgPartition.getMaterial()); this.setActive(String.valueOf(pgPartition.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java b/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java index d7c6024..9ea43fd 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java @@ -12,10 +12,10 @@ import java.util.List; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Service -public class PgDeviceTypeManager extends HibernateEntityDao{ +public class PgDeviceTypeManager extends HibernateEntityDao { public List getAllDeviceType() { @@ -23,8 +23,8 @@ criteria.add(Restrictions.eq("active", 1)); criteria.addOrder(Order.desc("id")); - List pgDeviceTypeList= criteria.list(); - List pgDeviceTypeDtoList=new ArrayList(); + List pgDeviceTypeList = criteria.list(); + List pgDeviceTypeDtoList = new ArrayList(); for (PgDeviceType pgDeviceType : pgDeviceTypeList) { pgDeviceTypeDtoList.add(new PgDeviceTypeDto(pgDeviceType)); } @@ -32,15 +32,14 @@ return pgDeviceTypeDtoList; } - public PgDeviceType getPgDeviceTypeByDevType(String devType) - { - Criteria criteria=createCriteria(PgDeviceType.class); - criteria.add(Restrictions.eq("devType",devType)); - criteria.add(Restrictions.eq("active",1)); - criteria.addOrder(Order.desc("id")); + public PgDeviceType getDeviceTypeByDeType(String devType) { - List pgDeviceTypeList=criteria.list(); - if(pgDeviceTypeList==null||pgDeviceTypeList.size()==0) + Criteria criteria = createCriteria(PgDeviceType.class); + criteria.add(Restrictions.eq("active", 1)); + criteria.add(Restrictions.eq("devType", devType)); + + List pgDeviceTypeList = criteria.list(); + if (pgDeviceTypeList.size() == 0) return null; else return pgDeviceTypeList.get(0); 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 0c594e7..c6f22cb 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java @@ -64,4 +64,4 @@ -} +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java index 9d06235..68b14cf 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java @@ -1,9 +1,5 @@ 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; @@ -19,7 +15,8 @@ private long id; private String highValue;//高限 private String lowValue;//低限 - private PgDevice pgDeviceId;//设备 + private String unit;//单位 + private String devType;//设备类型 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_ALARM_RULE_ID") @@ -49,15 +46,24 @@ this.lowValue = lowValue; } - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PGDEVICEID") - public PgDevice getPgDeviceId() { - return pgDeviceId; + @Column(name="UNIT") + public String getUnit() { + return unit; } - public void setPgDeviceId(PgDevice pgDeviceId) { - this.pgDeviceId = pgDeviceId; + public void setUnit(String unit) { + this.unit = unit; } + @Column(name = "DEVTYPE") + public String getDevType() { + return devType; + } + + public void setDevType(String devType) { + this.devType = devType; + } + + + } diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java deleted file mode 100644 index 7907e66..0000000 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.casic.PgInterface.patroler.dto; - -/** - * Created by yxw on 2017/12/14. - */ -public class PgAlarmRule { -} diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java index 8367ad4..0782c63 100644 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java @@ -12,7 +12,8 @@ private String id; private String highValue;//高限 private String lowValue;//低限 - private String devName;//设备 + private String devType;//设备类型 + private String unit;//单位 public String getId() { return id; @@ -38,20 +39,29 @@ this.lowValue = lowValue; } - public String getDevName() { - return devName; + public String getDevType() { + return devType; } - public void setDevName(String devName) { - this.devName = devName; + public void setDevType(String devType) { + this.devType = devType; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; } public PgAlarmRuleDto(PgAlarmRule pgAlarmRule) { this.setId(String.valueOf(pgAlarmRule.getId())); - this.setDevName(pgAlarmRule.getPgDeviceId().getAssetName()); this.setHighValue(pgAlarmRule.getHighValue()); this.setLowValue(pgAlarmRule.getLowValue()); + this.setDevType(pgAlarmRule.getDevType()); + this.setUnit(pgAlarmRule.getUnit()); } } diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java index d5c00b2..84e5cdd 100644 --- a/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java @@ -1,13 +1,13 @@ 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.ArrayList; import java.util.List; /** @@ -17,20 +17,21 @@ public class PgAlarmRuleManager extends HibernateEntityDao { //根据设备获取设备报警阈值 - public PgAlarmRuleDto getAlarmRuleDtoBydev(PgDevice pgDeviceId) { + public List getAlarmRuleDto() { 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)); + List pgAlarmRuleDtoList = new ArrayList(); + for (PgAlarmRule pgAlarmRule : pgAlarmRuleList) { + pgAlarmRuleDtoList.add(new PgAlarmRuleDto(pgAlarmRule)); + } + return pgAlarmRuleDtoList; + } - public PgAlarmRule getAlarmRuleBydev(PgDevice pgDeviceId) { + public PgAlarmRule getAlarmRuleBydevType(String devType) { Criteria criteria=createCriteria(PgAlarmRule.class); - criteria.add(Restrictions.eq("pgDeviceId", pgDeviceId)); + criteria.add(Restrictions.eq("devType", devType)); List pgAlarmRuleList=criteria.list(); if(pgAlarmRuleList.size()==0) diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java index f4e48c6..9396013 100644 --- a/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java @@ -39,13 +39,13 @@ } if (StringUtils.isNotBlank(startTime)) { - criteria.add(Restrictions.ge("operateTime", DateUtils.sdf4.parse(startTime))); + criteria.add(Restrictions.ge("operateTime", DateUtils.sdf_day.parse(startTime))); } if (StringUtils.isNotBlank(endTime)) { Calendar calendar = Calendar.getInstance(); - calendar.setTime(DateUtils.sdf4.parse(endTime)); + calendar.setTime(DateUtils.sdf_day.parse(endTime)); calendar.add(Calendar.DATE, 1); - criteria.add(Restrictions.le("time", calendar.getTime())); + criteria.add(Restrictions.le("operateTime", calendar.getTime())); } criteria.add(Restrictions.eq("active", 1)); diff --git a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java index 88255c6..f28ebdf 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java @@ -1,6 +1,5 @@ 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; @@ -15,7 +14,9 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -42,72 +43,43 @@ } /** - * 获取报警阈值信息 - */ - @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 { + public Map addAlarmRule(@FormParam("highValue") String highValue, + @FormParam("lowValue") String lowValue, + @FormParam("unit") String unit, + @FormParam("devType") String devType) 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(); + try { + pgAlarmRule = pgAlarmRuleManager.getAlarmRuleBydevType(devType); + if (pgAlarmRule != null) { result = "false"; - msg = "报警阈值新增失败"; + msg = "设备阈值已经存在"; + } else { + pgAlarmRule = new PgAlarmRule(); + pgAlarmRule.setHighValue(highValue); + pgAlarmRule.setLowValue(lowValue); + pgAlarmRule.setDevType(devType); + pgAlarmRule.setUnit(unit); + + pgAlarmRuleManager.save(pgAlarmRule); + result = "true"; + msg = "报警阈值新增成功"; } + } catch (Exception e) { + e.printStackTrace(); + result = "false"; + msg = "报警阈值新增失败"; } + resultMap.put("msg", msg); resultMap.put("result", result); return resultMap; @@ -119,44 +91,66 @@ @POST @Path("editAlarmRule") @Produces(MediaType.APPLICATION_JSON) - public Map editAlarmRule(@FormParam("id") String id, - @FormParam("assetCode") String assetCode, + public Map editAlarmRule(@FormParam("devType") String devType, @FormParam("highValue") String highValue, - @FormParam("lowValue") String lowValue) throws Exception { + @FormParam("lowValue") String lowValue, + @FormParam("unit") String unit) 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(); + + try { + pgAlarmRule = pgAlarmRuleManager.getAlarmRuleBydevType(devType); + if (pgAlarmRule == null) { + msg = "不存在报警阈值记录"; result = "false"; - msg = "报警阈值编辑失败"; + } else { + pgAlarmRule.setDevType(devType); + pgAlarmRule.setHighValue(highValue); + pgAlarmRule.setLowValue(lowValue); + pgAlarmRule.setUnit(unit); + pgAlarmRuleManager.save(pgAlarmRule); + msg = "编辑成功"; + result = "true"; } + } catch (Exception ex) { + ex.printStackTrace(); + result = "false"; + msg = "报警阈值编辑失败"; } + resultMap.put("msg", msg); resultMap.put("result", result); return resultMap; + } + /** + * 获取报警阈值信息 + */ + @POST + @Path("getAlarmRule") + @Produces(MediaType.APPLICATION_JSON) + public Map getAlarmRule() throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + + List pgAlarmRuleDtoList = new ArrayList(); + try { + pgAlarmRuleDtoList = pgAlarmRuleManager.getAlarmRuleDto(); + if (pgAlarmRuleDtoList == null) + msg = "不存在报警阈值信息"; + else + msg = "报警阈值获取成功"; + } catch (Exception e) { + e.printStackTrace(); + msg = "报警信息获取失败"; + } + resultMap.put("msg", msg); + resultMap.put("result", pgAlarmRuleDtoList); + 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 bb8c245..36547a7 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java @@ -104,8 +104,8 @@ @POST @Path("addDevice") @Produces(MediaType.APPLICATION_JSON) - public Map addDevice(@FormParam("parName") String parName, - @FormParam("pgName") String pgName, + public Map addDevice(@FormParam("partition") String partition, + @FormParam("pipeGallery") String pipeGallery, @FormParam("road") String road, @FormParam("position") String position, @FormParam("devType") String devType, @@ -129,8 +129,8 @@ } else { PgDevice pgDevice = new PgDevice(); - pgDevice.setPipeGallery(pgName); - pgDevice.setPartition(parName); + pgDevice.setPipeGallery(pipeGallery); + pgDevice.setPartition(partition); pgDevice.setRoad(road); pgDevice.setPosition(position); pgDevice.setDevType(devType); @@ -168,8 +168,8 @@ @Path("editDevice") @Produces(MediaType.APPLICATION_JSON) public Map editPartition(@FormParam("id") String id, - @FormParam("parName") String parName, - @FormParam("pgName") String pgName, + @FormParam("partition") String partition, + @FormParam("pipeGallery") String pipeGallery, @FormParam("road") String road, @FormParam("position") String position, @FormParam("devType") String devType, @@ -187,13 +187,15 @@ String msg = ""; try { + /* if (pgDeviceManager.getDeviceByAssetCode(assetCode)!=null) { result = "false"; msg = "已存在同名设备"; } else { + */ PgDevice pgDevice = pgDeviceManager.get(Long.valueOf(id)); - pgDevice.setPipeGallery(pgName); - pgDevice.setPartition(parName); + pgDevice.setPipeGallery(pipeGallery); + pgDevice.setPartition(partition); pgDevice.setRoad(road); pgDevice.setPosition(position); pgDevice.setDevType(devType); @@ -210,7 +212,7 @@ pgDeviceManager.save(pgDevice); result = "true"; msg = "编辑成功"; - } + //} } catch (Exception e) { result = "false"; msg = "编辑失败"; diff --git a/src/main/java/com/casic/PgInterface/rs/PgDeviceTypeRs.java b/src/main/java/com/casic/PgInterface/rs/PgDeviceTypeRs.java index 756894f..b6c84aa 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgDeviceTypeRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgDeviceTypeRs.java @@ -19,12 +19,13 @@ import java.util.Map; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Component @Path("pgDeviceType") public class PgDeviceTypeRs { - private static Logger logger = LoggerFactory.getLogger(PgDeviceRs.class); + + private static Logger logger = LoggerFactory.getLogger(PgDeviceTypeRs.class); private PgDeviceTypeManager pgDeviceTypeManager; @@ -34,21 +35,21 @@ } /** - * 获取设备类型 + * 显示设备列表 */ @POST @Path("getDeviceType") @Produces(MediaType.APPLICATION_JSON) - public Map getDeviceType()throws Exception { + public Map getDeviceTpeyList()throws Exception { Map resultMap = new HashMap(); String msg=""; List pgDeviceTypeDtoList=new ArrayList(); try { pgDeviceTypeDtoList = pgDeviceTypeManager.getAllDeviceType(); if(pgDeviceTypeDtoList.size()==0) - msg="没有设备类型信息"; + msg="没有找到设备类型信息"; else - msg="设备类型获取失败"; + msg="设备类型信息获取成功"; }catch(Exception e){ e.printStackTrace(); msg="设备类型信息获取失败"; @@ -64,37 +65,39 @@ @POST @Path("addDeviceType") @Produces(MediaType.APPLICATION_JSON) - public Map addDeviceType(@FormParam("devType") String devType) + public Map addDevice(@FormParam("devType") String devType) throws Exception { Map resultMap = new HashMap(); String result = ""; String msg = ""; - try { - if (pgDeviceTypeManager.getPgDeviceTypeByDevType(devType)!=null) { - result = "false"; - msg = "已存在同名设备类型"; - } else { - PgDeviceType pgDeviceType=new PgDeviceType(); - pgDeviceType.setDevType(devType); - pgDeviceType.setActive(1); - - pgDeviceTypeManager.save(pgDeviceType); - result = "true"; - msg = "保存成功"; - } - - } catch (Exception e) { + try { + if (pgDeviceTypeManager.getDeviceTypeByDeType(devType)!=null) { result = "false"; - msg = "保存失败"; - e.printStackTrace(); + msg = "已存在设备类型"; + } else { + PgDeviceType pgDeviceType = new PgDeviceType(); + + pgDeviceType.setDevType(devType); + pgDeviceType.setActive(1); + + pgDeviceTypeManager.save(pgDeviceType); + result = "true"; + msg = "保存成功"; } + } catch (Exception e) { + result = "false"; + msg = "保存失败"; + e.printStackTrace(); + } + resultMap.put("success", result); resultMap.put("msg", msg); return resultMap; } + } diff --git a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java b/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java deleted file mode 100644 index b2affe5..0000000 --- a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.casic.PgInterface.devData.dto; - -/** - * Created by yxw on 2017/11/28. - */ -public class PgTempHunDto { -} 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 eb1f7ab..da8f617 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -39,7 +39,6 @@ private List pgShs; private List pgTempHums; - @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") public long getId() { diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java index 4278dc1..669b60f 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java @@ -2,21 +2,20 @@ import javax.persistence.*; import java.io.Serializable; -import java.util.List; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Entity @Table(name = "PG_DEVICE_TYPE") @SequenceGenerator(name = "SEQ_PG_DEVICE_TYPE_ID", sequenceName = "SEQ_PG_DEVICE_TYPE_ID", allocationSize = 1, initialValue = 1) public class PgDeviceType implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; private long id; private String devType; private int active; - private List pgDeviceList; + @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_TYPE_ID") @@ -45,13 +44,4 @@ public void setActive(int active) { this.active = active; } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "devTypeId") - public List getPgDeviceList() { - return pgDeviceList; - } - - public void setPgDeviceList(List pgDeviceList) { - this.pgDeviceList = pgDeviceList; - } } 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 4fb3d6f..d209733 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java @@ -2,6 +2,7 @@ import javax.persistence.*; import java.io.Serializable; +import java.util.Date; import java.util.List; /** @@ -17,6 +18,12 @@ private long id; private String parName;//分区名称 private String road;//所属道路 + private String pgPosition;//仓段位置 + private String pgNum;//仓位数量 + private String pgType;//仓位类型 + private String pgLength;//分区长度 + private Date buildDate;//建设年代 + private String material;//建设材质 private int active;//状态位 private List pipeGalleryList;//管廊仓 @@ -48,6 +55,60 @@ this.road = road; } + @Column(name = "PGPOSITION") + public String getPgPosition() { + return pgPosition; + } + + public void setPgPosition(String pgPosition) { + this.pgPosition = pgPosition; + } + + @Column(name = "PGNUM") + public String getPgNum() { + return pgNum; + } + + public void setPgNum(String pgNum) { + this.pgNum = pgNum; + } + + @Column(name = "PGTYPE") + public String getPgType() { + return pgType; + } + + public void setPgType(String pgType) { + this.pgType = pgType; + } + + @Column(name = "PGLENGTH") + public String getPgLength() { + return pgLength; + } + + public void setPgLength(String pgLength) { + this.pgLength = pgLength; + } + + @Column(name = "BUILDDATE") + public Date getBuildDate() { + return buildDate; + } + + public void setBuildDate(Date buildDate) { + this.buildDate = buildDate; + } + + @Column(name = "MATERIAL") + public String getMaterial() { + return material; + } + + public void setMaterial(String material) { + this.material = material; + } + @Column(name = "ACTIVE") public int getActive() { return active; 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 95f9fbd..b60c42d 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java @@ -160,7 +160,7 @@ this.setAssetName(pgDevice.getAssetName()); this.setAssetCode(pgDevice.getAssetCode()); this.setAssetBarCode(pgDevice.getAssetBarCode()); - this.setId(pgDevice.getIp()); + this.setIp(pgDevice.getIp()); this.setModBus(pgDevice.getModBus()); this.setMome(pgDevice.getMome()); this.setIsOpen(String.valueOf(pgDevice.getIsOpen())); diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java index c1548e0..e348f7a 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java @@ -5,7 +5,7 @@ import java.io.Serializable; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ public class PgDeviceTypeDto implements Serializable { @@ -37,12 +37,11 @@ this.active = active; } - public PgDeviceTypeDto(PgDeviceType pgDeviceType) - { + public PgDeviceTypeDto(PgDeviceType pgDeviceType) { + this.setId(String.valueOf(pgDeviceType.getId())); this.setDevType(pgDeviceType.getDevType()); this.setActive(String.valueOf(pgDeviceType.getActive())); } - } 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 3acd0fa..95c18b4 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java @@ -3,6 +3,7 @@ import com.casic.PgInterface.devTable.domain.PgPartition; import java.io.Serializable; +import java.text.SimpleDateFormat; /** * Created by yxw on 2017/11/2. @@ -12,6 +13,12 @@ private String id; private String parName;//分区名称 private String road;//所属道路 + private String pgPosition;//仓段位置 + private String pgNum;//仓位数量 + private String pgType;//仓位类型 + private String pgLength;//分区长度 + private String buildDate;//建设年代 + private String material;//建设材质 private String active;//状态位 @@ -47,11 +54,67 @@ this.road = road; } + public String getPgPosition() { + return pgPosition; + } + + public void setPgPosition(String pgPosition) { + this.pgPosition = pgPosition; + } + + public String getPgNum() { + return pgNum; + } + + public void setPgNum(String pgNum) { + this.pgNum = pgNum; + } + + public String getPgType() { + return pgType; + } + + public void setPgType(String pgType) { + this.pgType = pgType; + } + + public String getPgLength() { + return pgLength; + } + + public void setPgLength(String pgLength) { + this.pgLength = pgLength; + } + + public String getBuildDate() { + return buildDate; + } + + public void setBuildDate(String buildDate) { + this.buildDate = buildDate; + } + + public String getMaterial() { + return material; + } + + public void setMaterial(String material) { + this.material = material; + } + public PgPartitionDto(PgPartition pgPartition) { + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); + this.setId(String.valueOf(pgPartition.getId())); this.setParName(pgPartition.getParName()); this.setRoad(pgPartition.getRoad()); + this.setPgPosition(pgPartition.getPgPosition()); + this.setPgNum(pgPartition.getPgNum()); + this.setPgType(pgPartition.getPgType()); + this.setPgLength(pgPartition.getPgLength()); + this.setBuildDate(sdf.format(pgPartition.getBuildDate())); + this.setMaterial(pgPartition.getMaterial()); this.setActive(String.valueOf(pgPartition.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java b/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java index d7c6024..9ea43fd 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java @@ -12,10 +12,10 @@ import java.util.List; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Service -public class PgDeviceTypeManager extends HibernateEntityDao{ +public class PgDeviceTypeManager extends HibernateEntityDao { public List getAllDeviceType() { @@ -23,8 +23,8 @@ criteria.add(Restrictions.eq("active", 1)); criteria.addOrder(Order.desc("id")); - List pgDeviceTypeList= criteria.list(); - List pgDeviceTypeDtoList=new ArrayList(); + List pgDeviceTypeList = criteria.list(); + List pgDeviceTypeDtoList = new ArrayList(); for (PgDeviceType pgDeviceType : pgDeviceTypeList) { pgDeviceTypeDtoList.add(new PgDeviceTypeDto(pgDeviceType)); } @@ -32,15 +32,14 @@ return pgDeviceTypeDtoList; } - public PgDeviceType getPgDeviceTypeByDevType(String devType) - { - Criteria criteria=createCriteria(PgDeviceType.class); - criteria.add(Restrictions.eq("devType",devType)); - criteria.add(Restrictions.eq("active",1)); - criteria.addOrder(Order.desc("id")); + public PgDeviceType getDeviceTypeByDeType(String devType) { - List pgDeviceTypeList=criteria.list(); - if(pgDeviceTypeList==null||pgDeviceTypeList.size()==0) + Criteria criteria = createCriteria(PgDeviceType.class); + criteria.add(Restrictions.eq("active", 1)); + criteria.add(Restrictions.eq("devType", devType)); + + List pgDeviceTypeList = criteria.list(); + if (pgDeviceTypeList.size() == 0) return null; else return pgDeviceTypeList.get(0); 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 0c594e7..c6f22cb 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java @@ -64,4 +64,4 @@ -} +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java index 9d06235..68b14cf 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java @@ -1,9 +1,5 @@ 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; @@ -19,7 +15,8 @@ private long id; private String highValue;//高限 private String lowValue;//低限 - private PgDevice pgDeviceId;//设备 + private String unit;//单位 + private String devType;//设备类型 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_ALARM_RULE_ID") @@ -49,15 +46,24 @@ this.lowValue = lowValue; } - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PGDEVICEID") - public PgDevice getPgDeviceId() { - return pgDeviceId; + @Column(name="UNIT") + public String getUnit() { + return unit; } - public void setPgDeviceId(PgDevice pgDeviceId) { - this.pgDeviceId = pgDeviceId; + public void setUnit(String unit) { + this.unit = unit; } + @Column(name = "DEVTYPE") + public String getDevType() { + return devType; + } + + public void setDevType(String devType) { + this.devType = devType; + } + + + } diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java deleted file mode 100644 index 7907e66..0000000 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.casic.PgInterface.patroler.dto; - -/** - * Created by yxw on 2017/12/14. - */ -public class PgAlarmRule { -} diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java index 8367ad4..0782c63 100644 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java @@ -12,7 +12,8 @@ private String id; private String highValue;//高限 private String lowValue;//低限 - private String devName;//设备 + private String devType;//设备类型 + private String unit;//单位 public String getId() { return id; @@ -38,20 +39,29 @@ this.lowValue = lowValue; } - public String getDevName() { - return devName; + public String getDevType() { + return devType; } - public void setDevName(String devName) { - this.devName = devName; + public void setDevType(String devType) { + this.devType = devType; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; } public PgAlarmRuleDto(PgAlarmRule pgAlarmRule) { this.setId(String.valueOf(pgAlarmRule.getId())); - this.setDevName(pgAlarmRule.getPgDeviceId().getAssetName()); this.setHighValue(pgAlarmRule.getHighValue()); this.setLowValue(pgAlarmRule.getLowValue()); + this.setDevType(pgAlarmRule.getDevType()); + this.setUnit(pgAlarmRule.getUnit()); } } diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java index d5c00b2..84e5cdd 100644 --- a/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java @@ -1,13 +1,13 @@ 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.ArrayList; import java.util.List; /** @@ -17,20 +17,21 @@ public class PgAlarmRuleManager extends HibernateEntityDao { //根据设备获取设备报警阈值 - public PgAlarmRuleDto getAlarmRuleDtoBydev(PgDevice pgDeviceId) { + public List getAlarmRuleDto() { 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)); + List pgAlarmRuleDtoList = new ArrayList(); + for (PgAlarmRule pgAlarmRule : pgAlarmRuleList) { + pgAlarmRuleDtoList.add(new PgAlarmRuleDto(pgAlarmRule)); + } + return pgAlarmRuleDtoList; + } - public PgAlarmRule getAlarmRuleBydev(PgDevice pgDeviceId) { + public PgAlarmRule getAlarmRuleBydevType(String devType) { Criteria criteria=createCriteria(PgAlarmRule.class); - criteria.add(Restrictions.eq("pgDeviceId", pgDeviceId)); + criteria.add(Restrictions.eq("devType", devType)); List pgAlarmRuleList=criteria.list(); if(pgAlarmRuleList.size()==0) diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java index f4e48c6..9396013 100644 --- a/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java @@ -39,13 +39,13 @@ } if (StringUtils.isNotBlank(startTime)) { - criteria.add(Restrictions.ge("operateTime", DateUtils.sdf4.parse(startTime))); + criteria.add(Restrictions.ge("operateTime", DateUtils.sdf_day.parse(startTime))); } if (StringUtils.isNotBlank(endTime)) { Calendar calendar = Calendar.getInstance(); - calendar.setTime(DateUtils.sdf4.parse(endTime)); + calendar.setTime(DateUtils.sdf_day.parse(endTime)); calendar.add(Calendar.DATE, 1); - criteria.add(Restrictions.le("time", calendar.getTime())); + criteria.add(Restrictions.le("operateTime", calendar.getTime())); } criteria.add(Restrictions.eq("active", 1)); diff --git a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java index 88255c6..f28ebdf 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java @@ -1,6 +1,5 @@ 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; @@ -15,7 +14,9 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -42,72 +43,43 @@ } /** - * 获取报警阈值信息 - */ - @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 { + public Map addAlarmRule(@FormParam("highValue") String highValue, + @FormParam("lowValue") String lowValue, + @FormParam("unit") String unit, + @FormParam("devType") String devType) 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(); + try { + pgAlarmRule = pgAlarmRuleManager.getAlarmRuleBydevType(devType); + if (pgAlarmRule != null) { result = "false"; - msg = "报警阈值新增失败"; + msg = "设备阈值已经存在"; + } else { + pgAlarmRule = new PgAlarmRule(); + pgAlarmRule.setHighValue(highValue); + pgAlarmRule.setLowValue(lowValue); + pgAlarmRule.setDevType(devType); + pgAlarmRule.setUnit(unit); + + pgAlarmRuleManager.save(pgAlarmRule); + result = "true"; + msg = "报警阈值新增成功"; } + } catch (Exception e) { + e.printStackTrace(); + result = "false"; + msg = "报警阈值新增失败"; } + resultMap.put("msg", msg); resultMap.put("result", result); return resultMap; @@ -119,44 +91,66 @@ @POST @Path("editAlarmRule") @Produces(MediaType.APPLICATION_JSON) - public Map editAlarmRule(@FormParam("id") String id, - @FormParam("assetCode") String assetCode, + public Map editAlarmRule(@FormParam("devType") String devType, @FormParam("highValue") String highValue, - @FormParam("lowValue") String lowValue) throws Exception { + @FormParam("lowValue") String lowValue, + @FormParam("unit") String unit) 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(); + + try { + pgAlarmRule = pgAlarmRuleManager.getAlarmRuleBydevType(devType); + if (pgAlarmRule == null) { + msg = "不存在报警阈值记录"; result = "false"; - msg = "报警阈值编辑失败"; + } else { + pgAlarmRule.setDevType(devType); + pgAlarmRule.setHighValue(highValue); + pgAlarmRule.setLowValue(lowValue); + pgAlarmRule.setUnit(unit); + pgAlarmRuleManager.save(pgAlarmRule); + msg = "编辑成功"; + result = "true"; } + } catch (Exception ex) { + ex.printStackTrace(); + result = "false"; + msg = "报警阈值编辑失败"; } + resultMap.put("msg", msg); resultMap.put("result", result); return resultMap; + } + /** + * 获取报警阈值信息 + */ + @POST + @Path("getAlarmRule") + @Produces(MediaType.APPLICATION_JSON) + public Map getAlarmRule() throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + + List pgAlarmRuleDtoList = new ArrayList(); + try { + pgAlarmRuleDtoList = pgAlarmRuleManager.getAlarmRuleDto(); + if (pgAlarmRuleDtoList == null) + msg = "不存在报警阈值信息"; + else + msg = "报警阈值获取成功"; + } catch (Exception e) { + e.printStackTrace(); + msg = "报警信息获取失败"; + } + resultMap.put("msg", msg); + resultMap.put("result", pgAlarmRuleDtoList); + 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 bb8c245..36547a7 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java @@ -104,8 +104,8 @@ @POST @Path("addDevice") @Produces(MediaType.APPLICATION_JSON) - public Map addDevice(@FormParam("parName") String parName, - @FormParam("pgName") String pgName, + public Map addDevice(@FormParam("partition") String partition, + @FormParam("pipeGallery") String pipeGallery, @FormParam("road") String road, @FormParam("position") String position, @FormParam("devType") String devType, @@ -129,8 +129,8 @@ } else { PgDevice pgDevice = new PgDevice(); - pgDevice.setPipeGallery(pgName); - pgDevice.setPartition(parName); + pgDevice.setPipeGallery(pipeGallery); + pgDevice.setPartition(partition); pgDevice.setRoad(road); pgDevice.setPosition(position); pgDevice.setDevType(devType); @@ -168,8 +168,8 @@ @Path("editDevice") @Produces(MediaType.APPLICATION_JSON) public Map editPartition(@FormParam("id") String id, - @FormParam("parName") String parName, - @FormParam("pgName") String pgName, + @FormParam("partition") String partition, + @FormParam("pipeGallery") String pipeGallery, @FormParam("road") String road, @FormParam("position") String position, @FormParam("devType") String devType, @@ -187,13 +187,15 @@ String msg = ""; try { + /* if (pgDeviceManager.getDeviceByAssetCode(assetCode)!=null) { result = "false"; msg = "已存在同名设备"; } else { + */ PgDevice pgDevice = pgDeviceManager.get(Long.valueOf(id)); - pgDevice.setPipeGallery(pgName); - pgDevice.setPartition(parName); + pgDevice.setPipeGallery(pipeGallery); + pgDevice.setPartition(partition); pgDevice.setRoad(road); pgDevice.setPosition(position); pgDevice.setDevType(devType); @@ -210,7 +212,7 @@ pgDeviceManager.save(pgDevice); result = "true"; msg = "编辑成功"; - } + //} } catch (Exception e) { result = "false"; msg = "编辑失败"; diff --git a/src/main/java/com/casic/PgInterface/rs/PgDeviceTypeRs.java b/src/main/java/com/casic/PgInterface/rs/PgDeviceTypeRs.java index 756894f..b6c84aa 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgDeviceTypeRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgDeviceTypeRs.java @@ -19,12 +19,13 @@ import java.util.Map; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Component @Path("pgDeviceType") public class PgDeviceTypeRs { - private static Logger logger = LoggerFactory.getLogger(PgDeviceRs.class); + + private static Logger logger = LoggerFactory.getLogger(PgDeviceTypeRs.class); private PgDeviceTypeManager pgDeviceTypeManager; @@ -34,21 +35,21 @@ } /** - * 获取设备类型 + * 显示设备列表 */ @POST @Path("getDeviceType") @Produces(MediaType.APPLICATION_JSON) - public Map getDeviceType()throws Exception { + public Map getDeviceTpeyList()throws Exception { Map resultMap = new HashMap(); String msg=""; List pgDeviceTypeDtoList=new ArrayList(); try { pgDeviceTypeDtoList = pgDeviceTypeManager.getAllDeviceType(); if(pgDeviceTypeDtoList.size()==0) - msg="没有设备类型信息"; + msg="没有找到设备类型信息"; else - msg="设备类型获取失败"; + msg="设备类型信息获取成功"; }catch(Exception e){ e.printStackTrace(); msg="设备类型信息获取失败"; @@ -64,37 +65,39 @@ @POST @Path("addDeviceType") @Produces(MediaType.APPLICATION_JSON) - public Map addDeviceType(@FormParam("devType") String devType) + public Map addDevice(@FormParam("devType") String devType) throws Exception { Map resultMap = new HashMap(); String result = ""; String msg = ""; - try { - if (pgDeviceTypeManager.getPgDeviceTypeByDevType(devType)!=null) { - result = "false"; - msg = "已存在同名设备类型"; - } else { - PgDeviceType pgDeviceType=new PgDeviceType(); - pgDeviceType.setDevType(devType); - pgDeviceType.setActive(1); - - pgDeviceTypeManager.save(pgDeviceType); - result = "true"; - msg = "保存成功"; - } - - } catch (Exception e) { + try { + if (pgDeviceTypeManager.getDeviceTypeByDeType(devType)!=null) { result = "false"; - msg = "保存失败"; - e.printStackTrace(); + msg = "已存在设备类型"; + } else { + PgDeviceType pgDeviceType = new PgDeviceType(); + + pgDeviceType.setDevType(devType); + pgDeviceType.setActive(1); + + pgDeviceTypeManager.save(pgDeviceType); + result = "true"; + msg = "保存成功"; } + } catch (Exception e) { + result = "false"; + msg = "保存失败"; + e.printStackTrace(); + } + resultMap.put("success", result); resultMap.put("msg", msg); return resultMap; } + } diff --git a/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java b/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java index 8a42e7e..249b75c 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java @@ -13,10 +13,8 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.text.SimpleDateFormat; +import java.util.*; /** * Created by yxw on 2017/11/6. @@ -40,25 +38,35 @@ @POST @Path("addPartition") @Produces(MediaType.APPLICATION_JSON) - public Map addAlarm(@FormParam("parName") String parName)throws Exception { + public Map addAlarm(@FormParam("parName") String parName, + @FormParam("road") String road, + @FormParam("pgPosition") String pgPosition, + @FormParam("pgNum") String pgNum, + @FormParam("pgType") String pgType, + @FormParam("pgLength") String pgLength, + @FormParam("buildDate") String buildDate, + @FormParam("material") String material)throws Exception { Map resultMap = new HashMap(); String result = ""; String msg = ""; + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); try { - if (pgPartitionManager.getPartitionByParName(parName) != null) { - result = "false"; - msg = "已存在相同分区"; - } else { PgPartition pgPartition = new PgPartition(); pgPartition.setParName(parName); + pgPartition.setRoad(road); + pgPartition.setPgPosition(pgPosition); + pgPartition.setPgNum(pgNum); + pgPartition.setPgType(pgType); + pgPartition.setPgLength(pgLength); + pgPartition.setBuildDate(sdf.parse(buildDate)); + pgPartition.setMaterial(material); pgPartition.setActive(1); logger.info("成功保存"); pgPartitionManager.save(pgPartition); result = "true"; msg = "保存成功"; - } } catch (Exception e) { result = "false"; @@ -71,28 +79,40 @@ return resultMap; } - - @POST @Path("editPartition") @Produces(MediaType.APPLICATION_JSON) public Map editPartition(@FormParam("id") String id, - @FormParam("parName") String parName) throws Exception { + @FormParam("parName") String parName, + @FormParam("road") String road, + @FormParam("pgPosition") String pgPosition, + @FormParam("pgNum") String pgNum, + @FormParam("pgType") String pgType, + @FormParam("pgLength") String pgLength, + @FormParam("buildDate") String buildDate, + @FormParam("material") String material) throws Exception { Map resultMap = new HashMap(); String result = ""; String msg = ""; PgPartition partition = new PgPartition(); + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); try { - if (pgPartitionManager.getPartitionByParName(parName) != null) { result = "false"; msg = "已存在相同分区"; } else { PgPartition pgPartition = pgPartitionManager.get(Long.valueOf(id)); pgPartition.setParName(parName); + pgPartition.setRoad(road); + pgPartition.setPgPosition(pgPosition); + pgPartition.setPgNum(pgNum); + pgPartition.setPgType(pgType); + pgPartition.setPgLength(pgLength); + pgPartition.setBuildDate(sdf.parse(buildDate)); + pgPartition.setMaterial(material); pgPartition.setActive(1); pgPartitionManager.save(pgPartition); diff --git a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java b/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java deleted file mode 100644 index b2affe5..0000000 --- a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.casic.PgInterface.devData.dto; - -/** - * Created by yxw on 2017/11/28. - */ -public class PgTempHunDto { -} 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 eb1f7ab..da8f617 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -39,7 +39,6 @@ private List pgShs; private List pgTempHums; - @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") public long getId() { diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java index 4278dc1..669b60f 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java @@ -2,21 +2,20 @@ import javax.persistence.*; import java.io.Serializable; -import java.util.List; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Entity @Table(name = "PG_DEVICE_TYPE") @SequenceGenerator(name = "SEQ_PG_DEVICE_TYPE_ID", sequenceName = "SEQ_PG_DEVICE_TYPE_ID", allocationSize = 1, initialValue = 1) public class PgDeviceType implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; private long id; private String devType; private int active; - private List pgDeviceList; + @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_TYPE_ID") @@ -45,13 +44,4 @@ public void setActive(int active) { this.active = active; } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "devTypeId") - public List getPgDeviceList() { - return pgDeviceList; - } - - public void setPgDeviceList(List pgDeviceList) { - this.pgDeviceList = pgDeviceList; - } } 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 4fb3d6f..d209733 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java @@ -2,6 +2,7 @@ import javax.persistence.*; import java.io.Serializable; +import java.util.Date; import java.util.List; /** @@ -17,6 +18,12 @@ private long id; private String parName;//分区名称 private String road;//所属道路 + private String pgPosition;//仓段位置 + private String pgNum;//仓位数量 + private String pgType;//仓位类型 + private String pgLength;//分区长度 + private Date buildDate;//建设年代 + private String material;//建设材质 private int active;//状态位 private List pipeGalleryList;//管廊仓 @@ -48,6 +55,60 @@ this.road = road; } + @Column(name = "PGPOSITION") + public String getPgPosition() { + return pgPosition; + } + + public void setPgPosition(String pgPosition) { + this.pgPosition = pgPosition; + } + + @Column(name = "PGNUM") + public String getPgNum() { + return pgNum; + } + + public void setPgNum(String pgNum) { + this.pgNum = pgNum; + } + + @Column(name = "PGTYPE") + public String getPgType() { + return pgType; + } + + public void setPgType(String pgType) { + this.pgType = pgType; + } + + @Column(name = "PGLENGTH") + public String getPgLength() { + return pgLength; + } + + public void setPgLength(String pgLength) { + this.pgLength = pgLength; + } + + @Column(name = "BUILDDATE") + public Date getBuildDate() { + return buildDate; + } + + public void setBuildDate(Date buildDate) { + this.buildDate = buildDate; + } + + @Column(name = "MATERIAL") + public String getMaterial() { + return material; + } + + public void setMaterial(String material) { + this.material = material; + } + @Column(name = "ACTIVE") public int getActive() { return active; 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 95f9fbd..b60c42d 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java @@ -160,7 +160,7 @@ this.setAssetName(pgDevice.getAssetName()); this.setAssetCode(pgDevice.getAssetCode()); this.setAssetBarCode(pgDevice.getAssetBarCode()); - this.setId(pgDevice.getIp()); + this.setIp(pgDevice.getIp()); this.setModBus(pgDevice.getModBus()); this.setMome(pgDevice.getMome()); this.setIsOpen(String.valueOf(pgDevice.getIsOpen())); diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java index c1548e0..e348f7a 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java @@ -5,7 +5,7 @@ import java.io.Serializable; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ public class PgDeviceTypeDto implements Serializable { @@ -37,12 +37,11 @@ this.active = active; } - public PgDeviceTypeDto(PgDeviceType pgDeviceType) - { + public PgDeviceTypeDto(PgDeviceType pgDeviceType) { + this.setId(String.valueOf(pgDeviceType.getId())); this.setDevType(pgDeviceType.getDevType()); this.setActive(String.valueOf(pgDeviceType.getActive())); } - } 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 3acd0fa..95c18b4 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java @@ -3,6 +3,7 @@ import com.casic.PgInterface.devTable.domain.PgPartition; import java.io.Serializable; +import java.text.SimpleDateFormat; /** * Created by yxw on 2017/11/2. @@ -12,6 +13,12 @@ private String id; private String parName;//分区名称 private String road;//所属道路 + private String pgPosition;//仓段位置 + private String pgNum;//仓位数量 + private String pgType;//仓位类型 + private String pgLength;//分区长度 + private String buildDate;//建设年代 + private String material;//建设材质 private String active;//状态位 @@ -47,11 +54,67 @@ this.road = road; } + public String getPgPosition() { + return pgPosition; + } + + public void setPgPosition(String pgPosition) { + this.pgPosition = pgPosition; + } + + public String getPgNum() { + return pgNum; + } + + public void setPgNum(String pgNum) { + this.pgNum = pgNum; + } + + public String getPgType() { + return pgType; + } + + public void setPgType(String pgType) { + this.pgType = pgType; + } + + public String getPgLength() { + return pgLength; + } + + public void setPgLength(String pgLength) { + this.pgLength = pgLength; + } + + public String getBuildDate() { + return buildDate; + } + + public void setBuildDate(String buildDate) { + this.buildDate = buildDate; + } + + public String getMaterial() { + return material; + } + + public void setMaterial(String material) { + this.material = material; + } + public PgPartitionDto(PgPartition pgPartition) { + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); + this.setId(String.valueOf(pgPartition.getId())); this.setParName(pgPartition.getParName()); this.setRoad(pgPartition.getRoad()); + this.setPgPosition(pgPartition.getPgPosition()); + this.setPgNum(pgPartition.getPgNum()); + this.setPgType(pgPartition.getPgType()); + this.setPgLength(pgPartition.getPgLength()); + this.setBuildDate(sdf.format(pgPartition.getBuildDate())); + this.setMaterial(pgPartition.getMaterial()); this.setActive(String.valueOf(pgPartition.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java b/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java index d7c6024..9ea43fd 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java @@ -12,10 +12,10 @@ import java.util.List; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Service -public class PgDeviceTypeManager extends HibernateEntityDao{ +public class PgDeviceTypeManager extends HibernateEntityDao { public List getAllDeviceType() { @@ -23,8 +23,8 @@ criteria.add(Restrictions.eq("active", 1)); criteria.addOrder(Order.desc("id")); - List pgDeviceTypeList= criteria.list(); - List pgDeviceTypeDtoList=new ArrayList(); + List pgDeviceTypeList = criteria.list(); + List pgDeviceTypeDtoList = new ArrayList(); for (PgDeviceType pgDeviceType : pgDeviceTypeList) { pgDeviceTypeDtoList.add(new PgDeviceTypeDto(pgDeviceType)); } @@ -32,15 +32,14 @@ return pgDeviceTypeDtoList; } - public PgDeviceType getPgDeviceTypeByDevType(String devType) - { - Criteria criteria=createCriteria(PgDeviceType.class); - criteria.add(Restrictions.eq("devType",devType)); - criteria.add(Restrictions.eq("active",1)); - criteria.addOrder(Order.desc("id")); + public PgDeviceType getDeviceTypeByDeType(String devType) { - List pgDeviceTypeList=criteria.list(); - if(pgDeviceTypeList==null||pgDeviceTypeList.size()==0) + Criteria criteria = createCriteria(PgDeviceType.class); + criteria.add(Restrictions.eq("active", 1)); + criteria.add(Restrictions.eq("devType", devType)); + + List pgDeviceTypeList = criteria.list(); + if (pgDeviceTypeList.size() == 0) return null; else return pgDeviceTypeList.get(0); 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 0c594e7..c6f22cb 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java @@ -64,4 +64,4 @@ -} +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java index 9d06235..68b14cf 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java @@ -1,9 +1,5 @@ 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; @@ -19,7 +15,8 @@ private long id; private String highValue;//高限 private String lowValue;//低限 - private PgDevice pgDeviceId;//设备 + private String unit;//单位 + private String devType;//设备类型 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_ALARM_RULE_ID") @@ -49,15 +46,24 @@ this.lowValue = lowValue; } - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PGDEVICEID") - public PgDevice getPgDeviceId() { - return pgDeviceId; + @Column(name="UNIT") + public String getUnit() { + return unit; } - public void setPgDeviceId(PgDevice pgDeviceId) { - this.pgDeviceId = pgDeviceId; + public void setUnit(String unit) { + this.unit = unit; } + @Column(name = "DEVTYPE") + public String getDevType() { + return devType; + } + + public void setDevType(String devType) { + this.devType = devType; + } + + + } diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java deleted file mode 100644 index 7907e66..0000000 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.casic.PgInterface.patroler.dto; - -/** - * Created by yxw on 2017/12/14. - */ -public class PgAlarmRule { -} diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java index 8367ad4..0782c63 100644 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java @@ -12,7 +12,8 @@ private String id; private String highValue;//高限 private String lowValue;//低限 - private String devName;//设备 + private String devType;//设备类型 + private String unit;//单位 public String getId() { return id; @@ -38,20 +39,29 @@ this.lowValue = lowValue; } - public String getDevName() { - return devName; + public String getDevType() { + return devType; } - public void setDevName(String devName) { - this.devName = devName; + public void setDevType(String devType) { + this.devType = devType; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; } public PgAlarmRuleDto(PgAlarmRule pgAlarmRule) { this.setId(String.valueOf(pgAlarmRule.getId())); - this.setDevName(pgAlarmRule.getPgDeviceId().getAssetName()); this.setHighValue(pgAlarmRule.getHighValue()); this.setLowValue(pgAlarmRule.getLowValue()); + this.setDevType(pgAlarmRule.getDevType()); + this.setUnit(pgAlarmRule.getUnit()); } } diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java index d5c00b2..84e5cdd 100644 --- a/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java @@ -1,13 +1,13 @@ 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.ArrayList; import java.util.List; /** @@ -17,20 +17,21 @@ public class PgAlarmRuleManager extends HibernateEntityDao { //根据设备获取设备报警阈值 - public PgAlarmRuleDto getAlarmRuleDtoBydev(PgDevice pgDeviceId) { + public List getAlarmRuleDto() { 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)); + List pgAlarmRuleDtoList = new ArrayList(); + for (PgAlarmRule pgAlarmRule : pgAlarmRuleList) { + pgAlarmRuleDtoList.add(new PgAlarmRuleDto(pgAlarmRule)); + } + return pgAlarmRuleDtoList; + } - public PgAlarmRule getAlarmRuleBydev(PgDevice pgDeviceId) { + public PgAlarmRule getAlarmRuleBydevType(String devType) { Criteria criteria=createCriteria(PgAlarmRule.class); - criteria.add(Restrictions.eq("pgDeviceId", pgDeviceId)); + criteria.add(Restrictions.eq("devType", devType)); List pgAlarmRuleList=criteria.list(); if(pgAlarmRuleList.size()==0) diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java index f4e48c6..9396013 100644 --- a/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java @@ -39,13 +39,13 @@ } if (StringUtils.isNotBlank(startTime)) { - criteria.add(Restrictions.ge("operateTime", DateUtils.sdf4.parse(startTime))); + criteria.add(Restrictions.ge("operateTime", DateUtils.sdf_day.parse(startTime))); } if (StringUtils.isNotBlank(endTime)) { Calendar calendar = Calendar.getInstance(); - calendar.setTime(DateUtils.sdf4.parse(endTime)); + calendar.setTime(DateUtils.sdf_day.parse(endTime)); calendar.add(Calendar.DATE, 1); - criteria.add(Restrictions.le("time", calendar.getTime())); + criteria.add(Restrictions.le("operateTime", calendar.getTime())); } criteria.add(Restrictions.eq("active", 1)); diff --git a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java index 88255c6..f28ebdf 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java @@ -1,6 +1,5 @@ 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; @@ -15,7 +14,9 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -42,72 +43,43 @@ } /** - * 获取报警阈值信息 - */ - @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 { + public Map addAlarmRule(@FormParam("highValue") String highValue, + @FormParam("lowValue") String lowValue, + @FormParam("unit") String unit, + @FormParam("devType") String devType) 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(); + try { + pgAlarmRule = pgAlarmRuleManager.getAlarmRuleBydevType(devType); + if (pgAlarmRule != null) { result = "false"; - msg = "报警阈值新增失败"; + msg = "设备阈值已经存在"; + } else { + pgAlarmRule = new PgAlarmRule(); + pgAlarmRule.setHighValue(highValue); + pgAlarmRule.setLowValue(lowValue); + pgAlarmRule.setDevType(devType); + pgAlarmRule.setUnit(unit); + + pgAlarmRuleManager.save(pgAlarmRule); + result = "true"; + msg = "报警阈值新增成功"; } + } catch (Exception e) { + e.printStackTrace(); + result = "false"; + msg = "报警阈值新增失败"; } + resultMap.put("msg", msg); resultMap.put("result", result); return resultMap; @@ -119,44 +91,66 @@ @POST @Path("editAlarmRule") @Produces(MediaType.APPLICATION_JSON) - public Map editAlarmRule(@FormParam("id") String id, - @FormParam("assetCode") String assetCode, + public Map editAlarmRule(@FormParam("devType") String devType, @FormParam("highValue") String highValue, - @FormParam("lowValue") String lowValue) throws Exception { + @FormParam("lowValue") String lowValue, + @FormParam("unit") String unit) 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(); + + try { + pgAlarmRule = pgAlarmRuleManager.getAlarmRuleBydevType(devType); + if (pgAlarmRule == null) { + msg = "不存在报警阈值记录"; result = "false"; - msg = "报警阈值编辑失败"; + } else { + pgAlarmRule.setDevType(devType); + pgAlarmRule.setHighValue(highValue); + pgAlarmRule.setLowValue(lowValue); + pgAlarmRule.setUnit(unit); + pgAlarmRuleManager.save(pgAlarmRule); + msg = "编辑成功"; + result = "true"; } + } catch (Exception ex) { + ex.printStackTrace(); + result = "false"; + msg = "报警阈值编辑失败"; } + resultMap.put("msg", msg); resultMap.put("result", result); return resultMap; + } + /** + * 获取报警阈值信息 + */ + @POST + @Path("getAlarmRule") + @Produces(MediaType.APPLICATION_JSON) + public Map getAlarmRule() throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + + List pgAlarmRuleDtoList = new ArrayList(); + try { + pgAlarmRuleDtoList = pgAlarmRuleManager.getAlarmRuleDto(); + if (pgAlarmRuleDtoList == null) + msg = "不存在报警阈值信息"; + else + msg = "报警阈值获取成功"; + } catch (Exception e) { + e.printStackTrace(); + msg = "报警信息获取失败"; + } + resultMap.put("msg", msg); + resultMap.put("result", pgAlarmRuleDtoList); + 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 bb8c245..36547a7 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java @@ -104,8 +104,8 @@ @POST @Path("addDevice") @Produces(MediaType.APPLICATION_JSON) - public Map addDevice(@FormParam("parName") String parName, - @FormParam("pgName") String pgName, + public Map addDevice(@FormParam("partition") String partition, + @FormParam("pipeGallery") String pipeGallery, @FormParam("road") String road, @FormParam("position") String position, @FormParam("devType") String devType, @@ -129,8 +129,8 @@ } else { PgDevice pgDevice = new PgDevice(); - pgDevice.setPipeGallery(pgName); - pgDevice.setPartition(parName); + pgDevice.setPipeGallery(pipeGallery); + pgDevice.setPartition(partition); pgDevice.setRoad(road); pgDevice.setPosition(position); pgDevice.setDevType(devType); @@ -168,8 +168,8 @@ @Path("editDevice") @Produces(MediaType.APPLICATION_JSON) public Map editPartition(@FormParam("id") String id, - @FormParam("parName") String parName, - @FormParam("pgName") String pgName, + @FormParam("partition") String partition, + @FormParam("pipeGallery") String pipeGallery, @FormParam("road") String road, @FormParam("position") String position, @FormParam("devType") String devType, @@ -187,13 +187,15 @@ String msg = ""; try { + /* if (pgDeviceManager.getDeviceByAssetCode(assetCode)!=null) { result = "false"; msg = "已存在同名设备"; } else { + */ PgDevice pgDevice = pgDeviceManager.get(Long.valueOf(id)); - pgDevice.setPipeGallery(pgName); - pgDevice.setPartition(parName); + pgDevice.setPipeGallery(pipeGallery); + pgDevice.setPartition(partition); pgDevice.setRoad(road); pgDevice.setPosition(position); pgDevice.setDevType(devType); @@ -210,7 +212,7 @@ pgDeviceManager.save(pgDevice); result = "true"; msg = "编辑成功"; - } + //} } catch (Exception e) { result = "false"; msg = "编辑失败"; diff --git a/src/main/java/com/casic/PgInterface/rs/PgDeviceTypeRs.java b/src/main/java/com/casic/PgInterface/rs/PgDeviceTypeRs.java index 756894f..b6c84aa 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgDeviceTypeRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgDeviceTypeRs.java @@ -19,12 +19,13 @@ import java.util.Map; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Component @Path("pgDeviceType") public class PgDeviceTypeRs { - private static Logger logger = LoggerFactory.getLogger(PgDeviceRs.class); + + private static Logger logger = LoggerFactory.getLogger(PgDeviceTypeRs.class); private PgDeviceTypeManager pgDeviceTypeManager; @@ -34,21 +35,21 @@ } /** - * 获取设备类型 + * 显示设备列表 */ @POST @Path("getDeviceType") @Produces(MediaType.APPLICATION_JSON) - public Map getDeviceType()throws Exception { + public Map getDeviceTpeyList()throws Exception { Map resultMap = new HashMap(); String msg=""; List pgDeviceTypeDtoList=new ArrayList(); try { pgDeviceTypeDtoList = pgDeviceTypeManager.getAllDeviceType(); if(pgDeviceTypeDtoList.size()==0) - msg="没有设备类型信息"; + msg="没有找到设备类型信息"; else - msg="设备类型获取失败"; + msg="设备类型信息获取成功"; }catch(Exception e){ e.printStackTrace(); msg="设备类型信息获取失败"; @@ -64,37 +65,39 @@ @POST @Path("addDeviceType") @Produces(MediaType.APPLICATION_JSON) - public Map addDeviceType(@FormParam("devType") String devType) + public Map addDevice(@FormParam("devType") String devType) throws Exception { Map resultMap = new HashMap(); String result = ""; String msg = ""; - try { - if (pgDeviceTypeManager.getPgDeviceTypeByDevType(devType)!=null) { - result = "false"; - msg = "已存在同名设备类型"; - } else { - PgDeviceType pgDeviceType=new PgDeviceType(); - pgDeviceType.setDevType(devType); - pgDeviceType.setActive(1); - - pgDeviceTypeManager.save(pgDeviceType); - result = "true"; - msg = "保存成功"; - } - - } catch (Exception e) { + try { + if (pgDeviceTypeManager.getDeviceTypeByDeType(devType)!=null) { result = "false"; - msg = "保存失败"; - e.printStackTrace(); + msg = "已存在设备类型"; + } else { + PgDeviceType pgDeviceType = new PgDeviceType(); + + pgDeviceType.setDevType(devType); + pgDeviceType.setActive(1); + + pgDeviceTypeManager.save(pgDeviceType); + result = "true"; + msg = "保存成功"; } + } catch (Exception e) { + result = "false"; + msg = "保存失败"; + e.printStackTrace(); + } + resultMap.put("success", result); resultMap.put("msg", msg); return resultMap; } + } diff --git a/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java b/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java index 8a42e7e..249b75c 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java @@ -13,10 +13,8 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.text.SimpleDateFormat; +import java.util.*; /** * Created by yxw on 2017/11/6. @@ -40,25 +38,35 @@ @POST @Path("addPartition") @Produces(MediaType.APPLICATION_JSON) - public Map addAlarm(@FormParam("parName") String parName)throws Exception { + public Map addAlarm(@FormParam("parName") String parName, + @FormParam("road") String road, + @FormParam("pgPosition") String pgPosition, + @FormParam("pgNum") String pgNum, + @FormParam("pgType") String pgType, + @FormParam("pgLength") String pgLength, + @FormParam("buildDate") String buildDate, + @FormParam("material") String material)throws Exception { Map resultMap = new HashMap(); String result = ""; String msg = ""; + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); try { - if (pgPartitionManager.getPartitionByParName(parName) != null) { - result = "false"; - msg = "已存在相同分区"; - } else { PgPartition pgPartition = new PgPartition(); pgPartition.setParName(parName); + pgPartition.setRoad(road); + pgPartition.setPgPosition(pgPosition); + pgPartition.setPgNum(pgNum); + pgPartition.setPgType(pgType); + pgPartition.setPgLength(pgLength); + pgPartition.setBuildDate(sdf.parse(buildDate)); + pgPartition.setMaterial(material); pgPartition.setActive(1); logger.info("成功保存"); pgPartitionManager.save(pgPartition); result = "true"; msg = "保存成功"; - } } catch (Exception e) { result = "false"; @@ -71,28 +79,40 @@ return resultMap; } - - @POST @Path("editPartition") @Produces(MediaType.APPLICATION_JSON) public Map editPartition(@FormParam("id") String id, - @FormParam("parName") String parName) throws Exception { + @FormParam("parName") String parName, + @FormParam("road") String road, + @FormParam("pgPosition") String pgPosition, + @FormParam("pgNum") String pgNum, + @FormParam("pgType") String pgType, + @FormParam("pgLength") String pgLength, + @FormParam("buildDate") String buildDate, + @FormParam("material") String material) throws Exception { Map resultMap = new HashMap(); String result = ""; String msg = ""; PgPartition partition = new PgPartition(); + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); try { - if (pgPartitionManager.getPartitionByParName(parName) != null) { result = "false"; msg = "已存在相同分区"; } else { PgPartition pgPartition = pgPartitionManager.get(Long.valueOf(id)); pgPartition.setParName(parName); + pgPartition.setRoad(road); + pgPartition.setPgPosition(pgPosition); + pgPartition.setPgNum(pgNum); + pgPartition.setPgType(pgType); + pgPartition.setPgLength(pgLength); + pgPartition.setBuildDate(sdf.parse(buildDate)); + pgPartition.setMaterial(material); pgPartition.setActive(1); pgPartitionManager.save(pgPartition); diff --git a/src/main/java/com/casic/PgInterface/rs/PgPatrolerRs.java b/src/main/java/com/casic/PgInterface/rs/PgPatrolerRs.java index aed1ed8..0b3c731 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgPatrolerRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgPatrolerRs.java @@ -123,10 +123,12 @@ String result = ""; String msg = ""; try { + /* if (pgPatrolerManager.userNameIsExits(userName)) { result = "false"; msg = "用户名已经存在!"; } else { + */ PgPatroler pgPatroler = pgPatrolerManager.get(Long.valueOf(id)); pgPatroler.setUserName(userName); pgPatroler.setPassword(password); @@ -136,7 +138,7 @@ pgPatrolerManager.save(pgPatroler); result = "true"; msg = "编辑成功"; - } + //} } catch (Exception e) { result = "false"; msg = "编辑失败"; diff --git a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java b/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java deleted file mode 100644 index b2affe5..0000000 --- a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.casic.PgInterface.devData.dto; - -/** - * Created by yxw on 2017/11/28. - */ -public class PgTempHunDto { -} 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 eb1f7ab..da8f617 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -39,7 +39,6 @@ private List pgShs; private List pgTempHums; - @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") public long getId() { diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java index 4278dc1..669b60f 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java @@ -2,21 +2,20 @@ import javax.persistence.*; import java.io.Serializable; -import java.util.List; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Entity @Table(name = "PG_DEVICE_TYPE") @SequenceGenerator(name = "SEQ_PG_DEVICE_TYPE_ID", sequenceName = "SEQ_PG_DEVICE_TYPE_ID", allocationSize = 1, initialValue = 1) public class PgDeviceType implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; private long id; private String devType; private int active; - private List pgDeviceList; + @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_TYPE_ID") @@ -45,13 +44,4 @@ public void setActive(int active) { this.active = active; } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "devTypeId") - public List getPgDeviceList() { - return pgDeviceList; - } - - public void setPgDeviceList(List pgDeviceList) { - this.pgDeviceList = pgDeviceList; - } } 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 4fb3d6f..d209733 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java @@ -2,6 +2,7 @@ import javax.persistence.*; import java.io.Serializable; +import java.util.Date; import java.util.List; /** @@ -17,6 +18,12 @@ private long id; private String parName;//分区名称 private String road;//所属道路 + private String pgPosition;//仓段位置 + private String pgNum;//仓位数量 + private String pgType;//仓位类型 + private String pgLength;//分区长度 + private Date buildDate;//建设年代 + private String material;//建设材质 private int active;//状态位 private List pipeGalleryList;//管廊仓 @@ -48,6 +55,60 @@ this.road = road; } + @Column(name = "PGPOSITION") + public String getPgPosition() { + return pgPosition; + } + + public void setPgPosition(String pgPosition) { + this.pgPosition = pgPosition; + } + + @Column(name = "PGNUM") + public String getPgNum() { + return pgNum; + } + + public void setPgNum(String pgNum) { + this.pgNum = pgNum; + } + + @Column(name = "PGTYPE") + public String getPgType() { + return pgType; + } + + public void setPgType(String pgType) { + this.pgType = pgType; + } + + @Column(name = "PGLENGTH") + public String getPgLength() { + return pgLength; + } + + public void setPgLength(String pgLength) { + this.pgLength = pgLength; + } + + @Column(name = "BUILDDATE") + public Date getBuildDate() { + return buildDate; + } + + public void setBuildDate(Date buildDate) { + this.buildDate = buildDate; + } + + @Column(name = "MATERIAL") + public String getMaterial() { + return material; + } + + public void setMaterial(String material) { + this.material = material; + } + @Column(name = "ACTIVE") public int getActive() { return active; 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 95f9fbd..b60c42d 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java @@ -160,7 +160,7 @@ this.setAssetName(pgDevice.getAssetName()); this.setAssetCode(pgDevice.getAssetCode()); this.setAssetBarCode(pgDevice.getAssetBarCode()); - this.setId(pgDevice.getIp()); + this.setIp(pgDevice.getIp()); this.setModBus(pgDevice.getModBus()); this.setMome(pgDevice.getMome()); this.setIsOpen(String.valueOf(pgDevice.getIsOpen())); diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java index c1548e0..e348f7a 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java @@ -5,7 +5,7 @@ import java.io.Serializable; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ public class PgDeviceTypeDto implements Serializable { @@ -37,12 +37,11 @@ this.active = active; } - public PgDeviceTypeDto(PgDeviceType pgDeviceType) - { + public PgDeviceTypeDto(PgDeviceType pgDeviceType) { + this.setId(String.valueOf(pgDeviceType.getId())); this.setDevType(pgDeviceType.getDevType()); this.setActive(String.valueOf(pgDeviceType.getActive())); } - } 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 3acd0fa..95c18b4 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java @@ -3,6 +3,7 @@ import com.casic.PgInterface.devTable.domain.PgPartition; import java.io.Serializable; +import java.text.SimpleDateFormat; /** * Created by yxw on 2017/11/2. @@ -12,6 +13,12 @@ private String id; private String parName;//分区名称 private String road;//所属道路 + private String pgPosition;//仓段位置 + private String pgNum;//仓位数量 + private String pgType;//仓位类型 + private String pgLength;//分区长度 + private String buildDate;//建设年代 + private String material;//建设材质 private String active;//状态位 @@ -47,11 +54,67 @@ this.road = road; } + public String getPgPosition() { + return pgPosition; + } + + public void setPgPosition(String pgPosition) { + this.pgPosition = pgPosition; + } + + public String getPgNum() { + return pgNum; + } + + public void setPgNum(String pgNum) { + this.pgNum = pgNum; + } + + public String getPgType() { + return pgType; + } + + public void setPgType(String pgType) { + this.pgType = pgType; + } + + public String getPgLength() { + return pgLength; + } + + public void setPgLength(String pgLength) { + this.pgLength = pgLength; + } + + public String getBuildDate() { + return buildDate; + } + + public void setBuildDate(String buildDate) { + this.buildDate = buildDate; + } + + public String getMaterial() { + return material; + } + + public void setMaterial(String material) { + this.material = material; + } + public PgPartitionDto(PgPartition pgPartition) { + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); + this.setId(String.valueOf(pgPartition.getId())); this.setParName(pgPartition.getParName()); this.setRoad(pgPartition.getRoad()); + this.setPgPosition(pgPartition.getPgPosition()); + this.setPgNum(pgPartition.getPgNum()); + this.setPgType(pgPartition.getPgType()); + this.setPgLength(pgPartition.getPgLength()); + this.setBuildDate(sdf.format(pgPartition.getBuildDate())); + this.setMaterial(pgPartition.getMaterial()); this.setActive(String.valueOf(pgPartition.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java b/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java index d7c6024..9ea43fd 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java @@ -12,10 +12,10 @@ import java.util.List; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Service -public class PgDeviceTypeManager extends HibernateEntityDao{ +public class PgDeviceTypeManager extends HibernateEntityDao { public List getAllDeviceType() { @@ -23,8 +23,8 @@ criteria.add(Restrictions.eq("active", 1)); criteria.addOrder(Order.desc("id")); - List pgDeviceTypeList= criteria.list(); - List pgDeviceTypeDtoList=new ArrayList(); + List pgDeviceTypeList = criteria.list(); + List pgDeviceTypeDtoList = new ArrayList(); for (PgDeviceType pgDeviceType : pgDeviceTypeList) { pgDeviceTypeDtoList.add(new PgDeviceTypeDto(pgDeviceType)); } @@ -32,15 +32,14 @@ return pgDeviceTypeDtoList; } - public PgDeviceType getPgDeviceTypeByDevType(String devType) - { - Criteria criteria=createCriteria(PgDeviceType.class); - criteria.add(Restrictions.eq("devType",devType)); - criteria.add(Restrictions.eq("active",1)); - criteria.addOrder(Order.desc("id")); + public PgDeviceType getDeviceTypeByDeType(String devType) { - List pgDeviceTypeList=criteria.list(); - if(pgDeviceTypeList==null||pgDeviceTypeList.size()==0) + Criteria criteria = createCriteria(PgDeviceType.class); + criteria.add(Restrictions.eq("active", 1)); + criteria.add(Restrictions.eq("devType", devType)); + + List pgDeviceTypeList = criteria.list(); + if (pgDeviceTypeList.size() == 0) return null; else return pgDeviceTypeList.get(0); 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 0c594e7..c6f22cb 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java @@ -64,4 +64,4 @@ -} +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java index 9d06235..68b14cf 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java @@ -1,9 +1,5 @@ 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; @@ -19,7 +15,8 @@ private long id; private String highValue;//高限 private String lowValue;//低限 - private PgDevice pgDeviceId;//设备 + private String unit;//单位 + private String devType;//设备类型 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_ALARM_RULE_ID") @@ -49,15 +46,24 @@ this.lowValue = lowValue; } - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PGDEVICEID") - public PgDevice getPgDeviceId() { - return pgDeviceId; + @Column(name="UNIT") + public String getUnit() { + return unit; } - public void setPgDeviceId(PgDevice pgDeviceId) { - this.pgDeviceId = pgDeviceId; + public void setUnit(String unit) { + this.unit = unit; } + @Column(name = "DEVTYPE") + public String getDevType() { + return devType; + } + + public void setDevType(String devType) { + this.devType = devType; + } + + + } diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java deleted file mode 100644 index 7907e66..0000000 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.casic.PgInterface.patroler.dto; - -/** - * Created by yxw on 2017/12/14. - */ -public class PgAlarmRule { -} diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java index 8367ad4..0782c63 100644 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java @@ -12,7 +12,8 @@ private String id; private String highValue;//高限 private String lowValue;//低限 - private String devName;//设备 + private String devType;//设备类型 + private String unit;//单位 public String getId() { return id; @@ -38,20 +39,29 @@ this.lowValue = lowValue; } - public String getDevName() { - return devName; + public String getDevType() { + return devType; } - public void setDevName(String devName) { - this.devName = devName; + public void setDevType(String devType) { + this.devType = devType; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; } public PgAlarmRuleDto(PgAlarmRule pgAlarmRule) { this.setId(String.valueOf(pgAlarmRule.getId())); - this.setDevName(pgAlarmRule.getPgDeviceId().getAssetName()); this.setHighValue(pgAlarmRule.getHighValue()); this.setLowValue(pgAlarmRule.getLowValue()); + this.setDevType(pgAlarmRule.getDevType()); + this.setUnit(pgAlarmRule.getUnit()); } } diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java index d5c00b2..84e5cdd 100644 --- a/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java @@ -1,13 +1,13 @@ 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.ArrayList; import java.util.List; /** @@ -17,20 +17,21 @@ public class PgAlarmRuleManager extends HibernateEntityDao { //根据设备获取设备报警阈值 - public PgAlarmRuleDto getAlarmRuleDtoBydev(PgDevice pgDeviceId) { + public List getAlarmRuleDto() { 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)); + List pgAlarmRuleDtoList = new ArrayList(); + for (PgAlarmRule pgAlarmRule : pgAlarmRuleList) { + pgAlarmRuleDtoList.add(new PgAlarmRuleDto(pgAlarmRule)); + } + return pgAlarmRuleDtoList; + } - public PgAlarmRule getAlarmRuleBydev(PgDevice pgDeviceId) { + public PgAlarmRule getAlarmRuleBydevType(String devType) { Criteria criteria=createCriteria(PgAlarmRule.class); - criteria.add(Restrictions.eq("pgDeviceId", pgDeviceId)); + criteria.add(Restrictions.eq("devType", devType)); List pgAlarmRuleList=criteria.list(); if(pgAlarmRuleList.size()==0) diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java index f4e48c6..9396013 100644 --- a/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java @@ -39,13 +39,13 @@ } if (StringUtils.isNotBlank(startTime)) { - criteria.add(Restrictions.ge("operateTime", DateUtils.sdf4.parse(startTime))); + criteria.add(Restrictions.ge("operateTime", DateUtils.sdf_day.parse(startTime))); } if (StringUtils.isNotBlank(endTime)) { Calendar calendar = Calendar.getInstance(); - calendar.setTime(DateUtils.sdf4.parse(endTime)); + calendar.setTime(DateUtils.sdf_day.parse(endTime)); calendar.add(Calendar.DATE, 1); - criteria.add(Restrictions.le("time", calendar.getTime())); + criteria.add(Restrictions.le("operateTime", calendar.getTime())); } criteria.add(Restrictions.eq("active", 1)); diff --git a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java index 88255c6..f28ebdf 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java @@ -1,6 +1,5 @@ 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; @@ -15,7 +14,9 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -42,72 +43,43 @@ } /** - * 获取报警阈值信息 - */ - @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 { + public Map addAlarmRule(@FormParam("highValue") String highValue, + @FormParam("lowValue") String lowValue, + @FormParam("unit") String unit, + @FormParam("devType") String devType) 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(); + try { + pgAlarmRule = pgAlarmRuleManager.getAlarmRuleBydevType(devType); + if (pgAlarmRule != null) { result = "false"; - msg = "报警阈值新增失败"; + msg = "设备阈值已经存在"; + } else { + pgAlarmRule = new PgAlarmRule(); + pgAlarmRule.setHighValue(highValue); + pgAlarmRule.setLowValue(lowValue); + pgAlarmRule.setDevType(devType); + pgAlarmRule.setUnit(unit); + + pgAlarmRuleManager.save(pgAlarmRule); + result = "true"; + msg = "报警阈值新增成功"; } + } catch (Exception e) { + e.printStackTrace(); + result = "false"; + msg = "报警阈值新增失败"; } + resultMap.put("msg", msg); resultMap.put("result", result); return resultMap; @@ -119,44 +91,66 @@ @POST @Path("editAlarmRule") @Produces(MediaType.APPLICATION_JSON) - public Map editAlarmRule(@FormParam("id") String id, - @FormParam("assetCode") String assetCode, + public Map editAlarmRule(@FormParam("devType") String devType, @FormParam("highValue") String highValue, - @FormParam("lowValue") String lowValue) throws Exception { + @FormParam("lowValue") String lowValue, + @FormParam("unit") String unit) 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(); + + try { + pgAlarmRule = pgAlarmRuleManager.getAlarmRuleBydevType(devType); + if (pgAlarmRule == null) { + msg = "不存在报警阈值记录"; result = "false"; - msg = "报警阈值编辑失败"; + } else { + pgAlarmRule.setDevType(devType); + pgAlarmRule.setHighValue(highValue); + pgAlarmRule.setLowValue(lowValue); + pgAlarmRule.setUnit(unit); + pgAlarmRuleManager.save(pgAlarmRule); + msg = "编辑成功"; + result = "true"; } + } catch (Exception ex) { + ex.printStackTrace(); + result = "false"; + msg = "报警阈值编辑失败"; } + resultMap.put("msg", msg); resultMap.put("result", result); return resultMap; + } + /** + * 获取报警阈值信息 + */ + @POST + @Path("getAlarmRule") + @Produces(MediaType.APPLICATION_JSON) + public Map getAlarmRule() throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + + List pgAlarmRuleDtoList = new ArrayList(); + try { + pgAlarmRuleDtoList = pgAlarmRuleManager.getAlarmRuleDto(); + if (pgAlarmRuleDtoList == null) + msg = "不存在报警阈值信息"; + else + msg = "报警阈值获取成功"; + } catch (Exception e) { + e.printStackTrace(); + msg = "报警信息获取失败"; + } + resultMap.put("msg", msg); + resultMap.put("result", pgAlarmRuleDtoList); + 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 bb8c245..36547a7 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java @@ -104,8 +104,8 @@ @POST @Path("addDevice") @Produces(MediaType.APPLICATION_JSON) - public Map addDevice(@FormParam("parName") String parName, - @FormParam("pgName") String pgName, + public Map addDevice(@FormParam("partition") String partition, + @FormParam("pipeGallery") String pipeGallery, @FormParam("road") String road, @FormParam("position") String position, @FormParam("devType") String devType, @@ -129,8 +129,8 @@ } else { PgDevice pgDevice = new PgDevice(); - pgDevice.setPipeGallery(pgName); - pgDevice.setPartition(parName); + pgDevice.setPipeGallery(pipeGallery); + pgDevice.setPartition(partition); pgDevice.setRoad(road); pgDevice.setPosition(position); pgDevice.setDevType(devType); @@ -168,8 +168,8 @@ @Path("editDevice") @Produces(MediaType.APPLICATION_JSON) public Map editPartition(@FormParam("id") String id, - @FormParam("parName") String parName, - @FormParam("pgName") String pgName, + @FormParam("partition") String partition, + @FormParam("pipeGallery") String pipeGallery, @FormParam("road") String road, @FormParam("position") String position, @FormParam("devType") String devType, @@ -187,13 +187,15 @@ String msg = ""; try { + /* if (pgDeviceManager.getDeviceByAssetCode(assetCode)!=null) { result = "false"; msg = "已存在同名设备"; } else { + */ PgDevice pgDevice = pgDeviceManager.get(Long.valueOf(id)); - pgDevice.setPipeGallery(pgName); - pgDevice.setPartition(parName); + pgDevice.setPipeGallery(pipeGallery); + pgDevice.setPartition(partition); pgDevice.setRoad(road); pgDevice.setPosition(position); pgDevice.setDevType(devType); @@ -210,7 +212,7 @@ pgDeviceManager.save(pgDevice); result = "true"; msg = "编辑成功"; - } + //} } catch (Exception e) { result = "false"; msg = "编辑失败"; diff --git a/src/main/java/com/casic/PgInterface/rs/PgDeviceTypeRs.java b/src/main/java/com/casic/PgInterface/rs/PgDeviceTypeRs.java index 756894f..b6c84aa 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgDeviceTypeRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgDeviceTypeRs.java @@ -19,12 +19,13 @@ import java.util.Map; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Component @Path("pgDeviceType") public class PgDeviceTypeRs { - private static Logger logger = LoggerFactory.getLogger(PgDeviceRs.class); + + private static Logger logger = LoggerFactory.getLogger(PgDeviceTypeRs.class); private PgDeviceTypeManager pgDeviceTypeManager; @@ -34,21 +35,21 @@ } /** - * 获取设备类型 + * 显示设备列表 */ @POST @Path("getDeviceType") @Produces(MediaType.APPLICATION_JSON) - public Map getDeviceType()throws Exception { + public Map getDeviceTpeyList()throws Exception { Map resultMap = new HashMap(); String msg=""; List pgDeviceTypeDtoList=new ArrayList(); try { pgDeviceTypeDtoList = pgDeviceTypeManager.getAllDeviceType(); if(pgDeviceTypeDtoList.size()==0) - msg="没有设备类型信息"; + msg="没有找到设备类型信息"; else - msg="设备类型获取失败"; + msg="设备类型信息获取成功"; }catch(Exception e){ e.printStackTrace(); msg="设备类型信息获取失败"; @@ -64,37 +65,39 @@ @POST @Path("addDeviceType") @Produces(MediaType.APPLICATION_JSON) - public Map addDeviceType(@FormParam("devType") String devType) + public Map addDevice(@FormParam("devType") String devType) throws Exception { Map resultMap = new HashMap(); String result = ""; String msg = ""; - try { - if (pgDeviceTypeManager.getPgDeviceTypeByDevType(devType)!=null) { - result = "false"; - msg = "已存在同名设备类型"; - } else { - PgDeviceType pgDeviceType=new PgDeviceType(); - pgDeviceType.setDevType(devType); - pgDeviceType.setActive(1); - - pgDeviceTypeManager.save(pgDeviceType); - result = "true"; - msg = "保存成功"; - } - - } catch (Exception e) { + try { + if (pgDeviceTypeManager.getDeviceTypeByDeType(devType)!=null) { result = "false"; - msg = "保存失败"; - e.printStackTrace(); + msg = "已存在设备类型"; + } else { + PgDeviceType pgDeviceType = new PgDeviceType(); + + pgDeviceType.setDevType(devType); + pgDeviceType.setActive(1); + + pgDeviceTypeManager.save(pgDeviceType); + result = "true"; + msg = "保存成功"; } + } catch (Exception e) { + result = "false"; + msg = "保存失败"; + e.printStackTrace(); + } + resultMap.put("success", result); resultMap.put("msg", msg); return resultMap; } + } diff --git a/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java b/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java index 8a42e7e..249b75c 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java @@ -13,10 +13,8 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.text.SimpleDateFormat; +import java.util.*; /** * Created by yxw on 2017/11/6. @@ -40,25 +38,35 @@ @POST @Path("addPartition") @Produces(MediaType.APPLICATION_JSON) - public Map addAlarm(@FormParam("parName") String parName)throws Exception { + public Map addAlarm(@FormParam("parName") String parName, + @FormParam("road") String road, + @FormParam("pgPosition") String pgPosition, + @FormParam("pgNum") String pgNum, + @FormParam("pgType") String pgType, + @FormParam("pgLength") String pgLength, + @FormParam("buildDate") String buildDate, + @FormParam("material") String material)throws Exception { Map resultMap = new HashMap(); String result = ""; String msg = ""; + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); try { - if (pgPartitionManager.getPartitionByParName(parName) != null) { - result = "false"; - msg = "已存在相同分区"; - } else { PgPartition pgPartition = new PgPartition(); pgPartition.setParName(parName); + pgPartition.setRoad(road); + pgPartition.setPgPosition(pgPosition); + pgPartition.setPgNum(pgNum); + pgPartition.setPgType(pgType); + pgPartition.setPgLength(pgLength); + pgPartition.setBuildDate(sdf.parse(buildDate)); + pgPartition.setMaterial(material); pgPartition.setActive(1); logger.info("成功保存"); pgPartitionManager.save(pgPartition); result = "true"; msg = "保存成功"; - } } catch (Exception e) { result = "false"; @@ -71,28 +79,40 @@ return resultMap; } - - @POST @Path("editPartition") @Produces(MediaType.APPLICATION_JSON) public Map editPartition(@FormParam("id") String id, - @FormParam("parName") String parName) throws Exception { + @FormParam("parName") String parName, + @FormParam("road") String road, + @FormParam("pgPosition") String pgPosition, + @FormParam("pgNum") String pgNum, + @FormParam("pgType") String pgType, + @FormParam("pgLength") String pgLength, + @FormParam("buildDate") String buildDate, + @FormParam("material") String material) throws Exception { Map resultMap = new HashMap(); String result = ""; String msg = ""; PgPartition partition = new PgPartition(); + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); try { - if (pgPartitionManager.getPartitionByParName(parName) != null) { result = "false"; msg = "已存在相同分区"; } else { PgPartition pgPartition = pgPartitionManager.get(Long.valueOf(id)); pgPartition.setParName(parName); + pgPartition.setRoad(road); + pgPartition.setPgPosition(pgPosition); + pgPartition.setPgNum(pgNum); + pgPartition.setPgType(pgType); + pgPartition.setPgLength(pgLength); + pgPartition.setBuildDate(sdf.parse(buildDate)); + pgPartition.setMaterial(material); pgPartition.setActive(1); pgPartitionManager.save(pgPartition); diff --git a/src/main/java/com/casic/PgInterface/rs/PgPatrolerRs.java b/src/main/java/com/casic/PgInterface/rs/PgPatrolerRs.java index aed1ed8..0b3c731 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgPatrolerRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgPatrolerRs.java @@ -123,10 +123,12 @@ String result = ""; String msg = ""; try { + /* if (pgPatrolerManager.userNameIsExits(userName)) { result = "false"; msg = "用户名已经存在!"; } else { + */ PgPatroler pgPatroler = pgPatrolerManager.get(Long.valueOf(id)); pgPatroler.setUserName(userName); pgPatroler.setPassword(password); @@ -136,7 +138,7 @@ pgPatrolerManager.save(pgPatroler); result = "true"; msg = "编辑成功"; - } + //} } catch (Exception e) { result = "false"; msg = "编辑失败"; diff --git a/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java b/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java index 8cbdb0a..4c9feac 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java @@ -165,12 +165,14 @@ msg = "不存在管廊仓和分区信息"; } else { try { + /* if(pgPipeLineManager.getPipeLineBylineName(lineName)!=null) { result = "false"; msg = "已存在同名管线"; } else { + */ PgPipeLine pgPipeLine = pgPipeLineManager.get(Long.valueOf(id)); pgPipeLine.setLineName(lineName); @@ -185,7 +187,7 @@ pgPipeLineManager.save(pgPipeLine); result = "true"; msg = "编辑成功"; - } + //} } catch (Exception e) { result = "false"; msg = "编辑失败"; diff --git a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java b/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java deleted file mode 100644 index b2affe5..0000000 --- a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.casic.PgInterface.devData.dto; - -/** - * Created by yxw on 2017/11/28. - */ -public class PgTempHunDto { -} 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 eb1f7ab..da8f617 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -39,7 +39,6 @@ private List pgShs; private List pgTempHums; - @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") public long getId() { diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java index 4278dc1..669b60f 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java @@ -2,21 +2,20 @@ import javax.persistence.*; import java.io.Serializable; -import java.util.List; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Entity @Table(name = "PG_DEVICE_TYPE") @SequenceGenerator(name = "SEQ_PG_DEVICE_TYPE_ID", sequenceName = "SEQ_PG_DEVICE_TYPE_ID", allocationSize = 1, initialValue = 1) public class PgDeviceType implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; private long id; private String devType; private int active; - private List pgDeviceList; + @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_TYPE_ID") @@ -45,13 +44,4 @@ public void setActive(int active) { this.active = active; } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "devTypeId") - public List getPgDeviceList() { - return pgDeviceList; - } - - public void setPgDeviceList(List pgDeviceList) { - this.pgDeviceList = pgDeviceList; - } } 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 4fb3d6f..d209733 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java @@ -2,6 +2,7 @@ import javax.persistence.*; import java.io.Serializable; +import java.util.Date; import java.util.List; /** @@ -17,6 +18,12 @@ private long id; private String parName;//分区名称 private String road;//所属道路 + private String pgPosition;//仓段位置 + private String pgNum;//仓位数量 + private String pgType;//仓位类型 + private String pgLength;//分区长度 + private Date buildDate;//建设年代 + private String material;//建设材质 private int active;//状态位 private List pipeGalleryList;//管廊仓 @@ -48,6 +55,60 @@ this.road = road; } + @Column(name = "PGPOSITION") + public String getPgPosition() { + return pgPosition; + } + + public void setPgPosition(String pgPosition) { + this.pgPosition = pgPosition; + } + + @Column(name = "PGNUM") + public String getPgNum() { + return pgNum; + } + + public void setPgNum(String pgNum) { + this.pgNum = pgNum; + } + + @Column(name = "PGTYPE") + public String getPgType() { + return pgType; + } + + public void setPgType(String pgType) { + this.pgType = pgType; + } + + @Column(name = "PGLENGTH") + public String getPgLength() { + return pgLength; + } + + public void setPgLength(String pgLength) { + this.pgLength = pgLength; + } + + @Column(name = "BUILDDATE") + public Date getBuildDate() { + return buildDate; + } + + public void setBuildDate(Date buildDate) { + this.buildDate = buildDate; + } + + @Column(name = "MATERIAL") + public String getMaterial() { + return material; + } + + public void setMaterial(String material) { + this.material = material; + } + @Column(name = "ACTIVE") public int getActive() { return active; 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 95f9fbd..b60c42d 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java @@ -160,7 +160,7 @@ this.setAssetName(pgDevice.getAssetName()); this.setAssetCode(pgDevice.getAssetCode()); this.setAssetBarCode(pgDevice.getAssetBarCode()); - this.setId(pgDevice.getIp()); + this.setIp(pgDevice.getIp()); this.setModBus(pgDevice.getModBus()); this.setMome(pgDevice.getMome()); this.setIsOpen(String.valueOf(pgDevice.getIsOpen())); diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java index c1548e0..e348f7a 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java @@ -5,7 +5,7 @@ import java.io.Serializable; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ public class PgDeviceTypeDto implements Serializable { @@ -37,12 +37,11 @@ this.active = active; } - public PgDeviceTypeDto(PgDeviceType pgDeviceType) - { + public PgDeviceTypeDto(PgDeviceType pgDeviceType) { + this.setId(String.valueOf(pgDeviceType.getId())); this.setDevType(pgDeviceType.getDevType()); this.setActive(String.valueOf(pgDeviceType.getActive())); } - } 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 3acd0fa..95c18b4 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java @@ -3,6 +3,7 @@ import com.casic.PgInterface.devTable.domain.PgPartition; import java.io.Serializable; +import java.text.SimpleDateFormat; /** * Created by yxw on 2017/11/2. @@ -12,6 +13,12 @@ private String id; private String parName;//分区名称 private String road;//所属道路 + private String pgPosition;//仓段位置 + private String pgNum;//仓位数量 + private String pgType;//仓位类型 + private String pgLength;//分区长度 + private String buildDate;//建设年代 + private String material;//建设材质 private String active;//状态位 @@ -47,11 +54,67 @@ this.road = road; } + public String getPgPosition() { + return pgPosition; + } + + public void setPgPosition(String pgPosition) { + this.pgPosition = pgPosition; + } + + public String getPgNum() { + return pgNum; + } + + public void setPgNum(String pgNum) { + this.pgNum = pgNum; + } + + public String getPgType() { + return pgType; + } + + public void setPgType(String pgType) { + this.pgType = pgType; + } + + public String getPgLength() { + return pgLength; + } + + public void setPgLength(String pgLength) { + this.pgLength = pgLength; + } + + public String getBuildDate() { + return buildDate; + } + + public void setBuildDate(String buildDate) { + this.buildDate = buildDate; + } + + public String getMaterial() { + return material; + } + + public void setMaterial(String material) { + this.material = material; + } + public PgPartitionDto(PgPartition pgPartition) { + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); + this.setId(String.valueOf(pgPartition.getId())); this.setParName(pgPartition.getParName()); this.setRoad(pgPartition.getRoad()); + this.setPgPosition(pgPartition.getPgPosition()); + this.setPgNum(pgPartition.getPgNum()); + this.setPgType(pgPartition.getPgType()); + this.setPgLength(pgPartition.getPgLength()); + this.setBuildDate(sdf.format(pgPartition.getBuildDate())); + this.setMaterial(pgPartition.getMaterial()); this.setActive(String.valueOf(pgPartition.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java b/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java index d7c6024..9ea43fd 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java @@ -12,10 +12,10 @@ import java.util.List; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Service -public class PgDeviceTypeManager extends HibernateEntityDao{ +public class PgDeviceTypeManager extends HibernateEntityDao { public List getAllDeviceType() { @@ -23,8 +23,8 @@ criteria.add(Restrictions.eq("active", 1)); criteria.addOrder(Order.desc("id")); - List pgDeviceTypeList= criteria.list(); - List pgDeviceTypeDtoList=new ArrayList(); + List pgDeviceTypeList = criteria.list(); + List pgDeviceTypeDtoList = new ArrayList(); for (PgDeviceType pgDeviceType : pgDeviceTypeList) { pgDeviceTypeDtoList.add(new PgDeviceTypeDto(pgDeviceType)); } @@ -32,15 +32,14 @@ return pgDeviceTypeDtoList; } - public PgDeviceType getPgDeviceTypeByDevType(String devType) - { - Criteria criteria=createCriteria(PgDeviceType.class); - criteria.add(Restrictions.eq("devType",devType)); - criteria.add(Restrictions.eq("active",1)); - criteria.addOrder(Order.desc("id")); + public PgDeviceType getDeviceTypeByDeType(String devType) { - List pgDeviceTypeList=criteria.list(); - if(pgDeviceTypeList==null||pgDeviceTypeList.size()==0) + Criteria criteria = createCriteria(PgDeviceType.class); + criteria.add(Restrictions.eq("active", 1)); + criteria.add(Restrictions.eq("devType", devType)); + + List pgDeviceTypeList = criteria.list(); + if (pgDeviceTypeList.size() == 0) return null; else return pgDeviceTypeList.get(0); 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 0c594e7..c6f22cb 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java @@ -64,4 +64,4 @@ -} +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java index 9d06235..68b14cf 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java @@ -1,9 +1,5 @@ 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; @@ -19,7 +15,8 @@ private long id; private String highValue;//高限 private String lowValue;//低限 - private PgDevice pgDeviceId;//设备 + private String unit;//单位 + private String devType;//设备类型 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_ALARM_RULE_ID") @@ -49,15 +46,24 @@ this.lowValue = lowValue; } - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PGDEVICEID") - public PgDevice getPgDeviceId() { - return pgDeviceId; + @Column(name="UNIT") + public String getUnit() { + return unit; } - public void setPgDeviceId(PgDevice pgDeviceId) { - this.pgDeviceId = pgDeviceId; + public void setUnit(String unit) { + this.unit = unit; } + @Column(name = "DEVTYPE") + public String getDevType() { + return devType; + } + + public void setDevType(String devType) { + this.devType = devType; + } + + + } diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java deleted file mode 100644 index 7907e66..0000000 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.casic.PgInterface.patroler.dto; - -/** - * Created by yxw on 2017/12/14. - */ -public class PgAlarmRule { -} diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java index 8367ad4..0782c63 100644 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java @@ -12,7 +12,8 @@ private String id; private String highValue;//高限 private String lowValue;//低限 - private String devName;//设备 + private String devType;//设备类型 + private String unit;//单位 public String getId() { return id; @@ -38,20 +39,29 @@ this.lowValue = lowValue; } - public String getDevName() { - return devName; + public String getDevType() { + return devType; } - public void setDevName(String devName) { - this.devName = devName; + public void setDevType(String devType) { + this.devType = devType; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; } public PgAlarmRuleDto(PgAlarmRule pgAlarmRule) { this.setId(String.valueOf(pgAlarmRule.getId())); - this.setDevName(pgAlarmRule.getPgDeviceId().getAssetName()); this.setHighValue(pgAlarmRule.getHighValue()); this.setLowValue(pgAlarmRule.getLowValue()); + this.setDevType(pgAlarmRule.getDevType()); + this.setUnit(pgAlarmRule.getUnit()); } } diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java index d5c00b2..84e5cdd 100644 --- a/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java @@ -1,13 +1,13 @@ 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.ArrayList; import java.util.List; /** @@ -17,20 +17,21 @@ public class PgAlarmRuleManager extends HibernateEntityDao { //根据设备获取设备报警阈值 - public PgAlarmRuleDto getAlarmRuleDtoBydev(PgDevice pgDeviceId) { + public List getAlarmRuleDto() { 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)); + List pgAlarmRuleDtoList = new ArrayList(); + for (PgAlarmRule pgAlarmRule : pgAlarmRuleList) { + pgAlarmRuleDtoList.add(new PgAlarmRuleDto(pgAlarmRule)); + } + return pgAlarmRuleDtoList; + } - public PgAlarmRule getAlarmRuleBydev(PgDevice pgDeviceId) { + public PgAlarmRule getAlarmRuleBydevType(String devType) { Criteria criteria=createCriteria(PgAlarmRule.class); - criteria.add(Restrictions.eq("pgDeviceId", pgDeviceId)); + criteria.add(Restrictions.eq("devType", devType)); List pgAlarmRuleList=criteria.list(); if(pgAlarmRuleList.size()==0) diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java index f4e48c6..9396013 100644 --- a/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java @@ -39,13 +39,13 @@ } if (StringUtils.isNotBlank(startTime)) { - criteria.add(Restrictions.ge("operateTime", DateUtils.sdf4.parse(startTime))); + criteria.add(Restrictions.ge("operateTime", DateUtils.sdf_day.parse(startTime))); } if (StringUtils.isNotBlank(endTime)) { Calendar calendar = Calendar.getInstance(); - calendar.setTime(DateUtils.sdf4.parse(endTime)); + calendar.setTime(DateUtils.sdf_day.parse(endTime)); calendar.add(Calendar.DATE, 1); - criteria.add(Restrictions.le("time", calendar.getTime())); + criteria.add(Restrictions.le("operateTime", calendar.getTime())); } criteria.add(Restrictions.eq("active", 1)); diff --git a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java index 88255c6..f28ebdf 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java @@ -1,6 +1,5 @@ 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; @@ -15,7 +14,9 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -42,72 +43,43 @@ } /** - * 获取报警阈值信息 - */ - @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 { + public Map addAlarmRule(@FormParam("highValue") String highValue, + @FormParam("lowValue") String lowValue, + @FormParam("unit") String unit, + @FormParam("devType") String devType) 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(); + try { + pgAlarmRule = pgAlarmRuleManager.getAlarmRuleBydevType(devType); + if (pgAlarmRule != null) { result = "false"; - msg = "报警阈值新增失败"; + msg = "设备阈值已经存在"; + } else { + pgAlarmRule = new PgAlarmRule(); + pgAlarmRule.setHighValue(highValue); + pgAlarmRule.setLowValue(lowValue); + pgAlarmRule.setDevType(devType); + pgAlarmRule.setUnit(unit); + + pgAlarmRuleManager.save(pgAlarmRule); + result = "true"; + msg = "报警阈值新增成功"; } + } catch (Exception e) { + e.printStackTrace(); + result = "false"; + msg = "报警阈值新增失败"; } + resultMap.put("msg", msg); resultMap.put("result", result); return resultMap; @@ -119,44 +91,66 @@ @POST @Path("editAlarmRule") @Produces(MediaType.APPLICATION_JSON) - public Map editAlarmRule(@FormParam("id") String id, - @FormParam("assetCode") String assetCode, + public Map editAlarmRule(@FormParam("devType") String devType, @FormParam("highValue") String highValue, - @FormParam("lowValue") String lowValue) throws Exception { + @FormParam("lowValue") String lowValue, + @FormParam("unit") String unit) 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(); + + try { + pgAlarmRule = pgAlarmRuleManager.getAlarmRuleBydevType(devType); + if (pgAlarmRule == null) { + msg = "不存在报警阈值记录"; result = "false"; - msg = "报警阈值编辑失败"; + } else { + pgAlarmRule.setDevType(devType); + pgAlarmRule.setHighValue(highValue); + pgAlarmRule.setLowValue(lowValue); + pgAlarmRule.setUnit(unit); + pgAlarmRuleManager.save(pgAlarmRule); + msg = "编辑成功"; + result = "true"; } + } catch (Exception ex) { + ex.printStackTrace(); + result = "false"; + msg = "报警阈值编辑失败"; } + resultMap.put("msg", msg); resultMap.put("result", result); return resultMap; + } + /** + * 获取报警阈值信息 + */ + @POST + @Path("getAlarmRule") + @Produces(MediaType.APPLICATION_JSON) + public Map getAlarmRule() throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + + List pgAlarmRuleDtoList = new ArrayList(); + try { + pgAlarmRuleDtoList = pgAlarmRuleManager.getAlarmRuleDto(); + if (pgAlarmRuleDtoList == null) + msg = "不存在报警阈值信息"; + else + msg = "报警阈值获取成功"; + } catch (Exception e) { + e.printStackTrace(); + msg = "报警信息获取失败"; + } + resultMap.put("msg", msg); + resultMap.put("result", pgAlarmRuleDtoList); + 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 bb8c245..36547a7 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java @@ -104,8 +104,8 @@ @POST @Path("addDevice") @Produces(MediaType.APPLICATION_JSON) - public Map addDevice(@FormParam("parName") String parName, - @FormParam("pgName") String pgName, + public Map addDevice(@FormParam("partition") String partition, + @FormParam("pipeGallery") String pipeGallery, @FormParam("road") String road, @FormParam("position") String position, @FormParam("devType") String devType, @@ -129,8 +129,8 @@ } else { PgDevice pgDevice = new PgDevice(); - pgDevice.setPipeGallery(pgName); - pgDevice.setPartition(parName); + pgDevice.setPipeGallery(pipeGallery); + pgDevice.setPartition(partition); pgDevice.setRoad(road); pgDevice.setPosition(position); pgDevice.setDevType(devType); @@ -168,8 +168,8 @@ @Path("editDevice") @Produces(MediaType.APPLICATION_JSON) public Map editPartition(@FormParam("id") String id, - @FormParam("parName") String parName, - @FormParam("pgName") String pgName, + @FormParam("partition") String partition, + @FormParam("pipeGallery") String pipeGallery, @FormParam("road") String road, @FormParam("position") String position, @FormParam("devType") String devType, @@ -187,13 +187,15 @@ String msg = ""; try { + /* if (pgDeviceManager.getDeviceByAssetCode(assetCode)!=null) { result = "false"; msg = "已存在同名设备"; } else { + */ PgDevice pgDevice = pgDeviceManager.get(Long.valueOf(id)); - pgDevice.setPipeGallery(pgName); - pgDevice.setPartition(parName); + pgDevice.setPipeGallery(pipeGallery); + pgDevice.setPartition(partition); pgDevice.setRoad(road); pgDevice.setPosition(position); pgDevice.setDevType(devType); @@ -210,7 +212,7 @@ pgDeviceManager.save(pgDevice); result = "true"; msg = "编辑成功"; - } + //} } catch (Exception e) { result = "false"; msg = "编辑失败"; diff --git a/src/main/java/com/casic/PgInterface/rs/PgDeviceTypeRs.java b/src/main/java/com/casic/PgInterface/rs/PgDeviceTypeRs.java index 756894f..b6c84aa 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgDeviceTypeRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgDeviceTypeRs.java @@ -19,12 +19,13 @@ import java.util.Map; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Component @Path("pgDeviceType") public class PgDeviceTypeRs { - private static Logger logger = LoggerFactory.getLogger(PgDeviceRs.class); + + private static Logger logger = LoggerFactory.getLogger(PgDeviceTypeRs.class); private PgDeviceTypeManager pgDeviceTypeManager; @@ -34,21 +35,21 @@ } /** - * 获取设备类型 + * 显示设备列表 */ @POST @Path("getDeviceType") @Produces(MediaType.APPLICATION_JSON) - public Map getDeviceType()throws Exception { + public Map getDeviceTpeyList()throws Exception { Map resultMap = new HashMap(); String msg=""; List pgDeviceTypeDtoList=new ArrayList(); try { pgDeviceTypeDtoList = pgDeviceTypeManager.getAllDeviceType(); if(pgDeviceTypeDtoList.size()==0) - msg="没有设备类型信息"; + msg="没有找到设备类型信息"; else - msg="设备类型获取失败"; + msg="设备类型信息获取成功"; }catch(Exception e){ e.printStackTrace(); msg="设备类型信息获取失败"; @@ -64,37 +65,39 @@ @POST @Path("addDeviceType") @Produces(MediaType.APPLICATION_JSON) - public Map addDeviceType(@FormParam("devType") String devType) + public Map addDevice(@FormParam("devType") String devType) throws Exception { Map resultMap = new HashMap(); String result = ""; String msg = ""; - try { - if (pgDeviceTypeManager.getPgDeviceTypeByDevType(devType)!=null) { - result = "false"; - msg = "已存在同名设备类型"; - } else { - PgDeviceType pgDeviceType=new PgDeviceType(); - pgDeviceType.setDevType(devType); - pgDeviceType.setActive(1); - - pgDeviceTypeManager.save(pgDeviceType); - result = "true"; - msg = "保存成功"; - } - - } catch (Exception e) { + try { + if (pgDeviceTypeManager.getDeviceTypeByDeType(devType)!=null) { result = "false"; - msg = "保存失败"; - e.printStackTrace(); + msg = "已存在设备类型"; + } else { + PgDeviceType pgDeviceType = new PgDeviceType(); + + pgDeviceType.setDevType(devType); + pgDeviceType.setActive(1); + + pgDeviceTypeManager.save(pgDeviceType); + result = "true"; + msg = "保存成功"; } + } catch (Exception e) { + result = "false"; + msg = "保存失败"; + e.printStackTrace(); + } + resultMap.put("success", result); resultMap.put("msg", msg); return resultMap; } + } diff --git a/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java b/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java index 8a42e7e..249b75c 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java @@ -13,10 +13,8 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.text.SimpleDateFormat; +import java.util.*; /** * Created by yxw on 2017/11/6. @@ -40,25 +38,35 @@ @POST @Path("addPartition") @Produces(MediaType.APPLICATION_JSON) - public Map addAlarm(@FormParam("parName") String parName)throws Exception { + public Map addAlarm(@FormParam("parName") String parName, + @FormParam("road") String road, + @FormParam("pgPosition") String pgPosition, + @FormParam("pgNum") String pgNum, + @FormParam("pgType") String pgType, + @FormParam("pgLength") String pgLength, + @FormParam("buildDate") String buildDate, + @FormParam("material") String material)throws Exception { Map resultMap = new HashMap(); String result = ""; String msg = ""; + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); try { - if (pgPartitionManager.getPartitionByParName(parName) != null) { - result = "false"; - msg = "已存在相同分区"; - } else { PgPartition pgPartition = new PgPartition(); pgPartition.setParName(parName); + pgPartition.setRoad(road); + pgPartition.setPgPosition(pgPosition); + pgPartition.setPgNum(pgNum); + pgPartition.setPgType(pgType); + pgPartition.setPgLength(pgLength); + pgPartition.setBuildDate(sdf.parse(buildDate)); + pgPartition.setMaterial(material); pgPartition.setActive(1); logger.info("成功保存"); pgPartitionManager.save(pgPartition); result = "true"; msg = "保存成功"; - } } catch (Exception e) { result = "false"; @@ -71,28 +79,40 @@ return resultMap; } - - @POST @Path("editPartition") @Produces(MediaType.APPLICATION_JSON) public Map editPartition(@FormParam("id") String id, - @FormParam("parName") String parName) throws Exception { + @FormParam("parName") String parName, + @FormParam("road") String road, + @FormParam("pgPosition") String pgPosition, + @FormParam("pgNum") String pgNum, + @FormParam("pgType") String pgType, + @FormParam("pgLength") String pgLength, + @FormParam("buildDate") String buildDate, + @FormParam("material") String material) throws Exception { Map resultMap = new HashMap(); String result = ""; String msg = ""; PgPartition partition = new PgPartition(); + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); try { - if (pgPartitionManager.getPartitionByParName(parName) != null) { result = "false"; msg = "已存在相同分区"; } else { PgPartition pgPartition = pgPartitionManager.get(Long.valueOf(id)); pgPartition.setParName(parName); + pgPartition.setRoad(road); + pgPartition.setPgPosition(pgPosition); + pgPartition.setPgNum(pgNum); + pgPartition.setPgType(pgType); + pgPartition.setPgLength(pgLength); + pgPartition.setBuildDate(sdf.parse(buildDate)); + pgPartition.setMaterial(material); pgPartition.setActive(1); pgPartitionManager.save(pgPartition); diff --git a/src/main/java/com/casic/PgInterface/rs/PgPatrolerRs.java b/src/main/java/com/casic/PgInterface/rs/PgPatrolerRs.java index aed1ed8..0b3c731 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgPatrolerRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgPatrolerRs.java @@ -123,10 +123,12 @@ String result = ""; String msg = ""; try { + /* if (pgPatrolerManager.userNameIsExits(userName)) { result = "false"; msg = "用户名已经存在!"; } else { + */ PgPatroler pgPatroler = pgPatrolerManager.get(Long.valueOf(id)); pgPatroler.setUserName(userName); pgPatroler.setPassword(password); @@ -136,7 +138,7 @@ pgPatrolerManager.save(pgPatroler); result = "true"; msg = "编辑成功"; - } + //} } catch (Exception e) { result = "false"; msg = "编辑失败"; diff --git a/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java b/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java index 8cbdb0a..4c9feac 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java @@ -165,12 +165,14 @@ msg = "不存在管廊仓和分区信息"; } else { try { + /* if(pgPipeLineManager.getPipeLineBylineName(lineName)!=null) { result = "false"; msg = "已存在同名管线"; } else { + */ PgPipeLine pgPipeLine = pgPipeLineManager.get(Long.valueOf(id)); pgPipeLine.setLineName(lineName); @@ -185,7 +187,7 @@ pgPipeLineManager.save(pgPipeLine); result = "true"; msg = "编辑成功"; - } + //} } catch (Exception e) { result = "false"; msg = "编辑失败"; diff --git a/src/main/java/com/casic/PgInterface/rs/PgReserveController.java b/src/main/java/com/casic/PgInterface/rs/PgReserveController.java new file mode 100644 index 0000000..863045a --- /dev/null +++ b/src/main/java/com/casic/PgInterface/rs/PgReserveController.java @@ -0,0 +1,207 @@ +package com.casic.PgInterface.rs; + +import com.casic.PgInterface.core.util.StringUtils; +import com.casic.PgInterface.devTable.manager.PgAlarmTypeManager; +import com.casic.PgInterface.reservePlan.domain.PgReservePlan; +import com.casic.PgInterface.reservePlan.manager.PgReservePlanManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.multipart.MultipartFile; +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.List; +import java.util.Map; + +/** + * Created by yxw on 2017/11/8. + */ +@Controller +@RequestMapping("rs/pgReservePlan") +public class PgReserveController { + + private static Logger logger = LoggerFactory.getLogger(PgReservePlan.class); + + private PgReservePlanManager pgReservePlanManager; + + private PgAlarmTypeManager pgAlarmTypeManager; + + @Resource + public void setPgReservePlanManager(PgReservePlanManager pgReservePlanManager) { + this.pgReservePlanManager = pgReservePlanManager; + } + + @Resource + public void setPgAlarmTypeManager(PgAlarmTypeManager pgAlarmTypeManager) { + this.pgAlarmTypeManager = pgAlarmTypeManager; + } + +// //新增预案文档 +// @RequestMapping("addReservePlan") +// @ResponseBody +// public Map addReservePlan(@RequestParam(value = "planName",required = true) String planName, +// @RequestParam(value = "planType",required =false) String planType, +// @RequestParam(value ="resUnit",required =false) String resUnit, +// @RequestParam(value ="alarmType",required =false) String alarmType, +// @RequestParam(value = "planFiels",required =false) List planFiels) +// throws Exception { +// Map resultMap = new HashMap(); +// PgReservePlan pgReservePlan = new PgReservePlan(); +// String result = ""; +// String msg = ""; +// +// try { +// if (planFiels.size() == 0) +// pgReservePlan.setPlanFiel(""); +// else { +// pgReservePlan.setPlanFiel(pgReservePlanManager.saveFiles(planFiels, "reservePlan")); +// } +// +// pgReservePlan.setPlanName(planName); +// pgReservePlan.setPlanType(planType); +// pgReservePlan.setResUnit(resUnit); +// pgReservePlan.setPgAlarmTypeId(pgAlarmTypeManager.getAlarmTypeByAlarmType(alarmType)); +// pgReservePlan.setActive(1); +// +// result = "true"; +// msg = "保存成功"; +// logger.info("保存成功"); +// pgReservePlanManager.save(pgReservePlan); +// } catch (Exception ex) { +// result = "false"; +// msg = "保存失败"; +// ex.printStackTrace(); +// } +// +// resultMap.put("success", result); +// resultMap.put("msg", msg); +// return resultMap; +// } + + //新增预案文档 + @POST + @Path("addReservePlan") + @Produces(MediaType.APPLICATION_JSON) + public Map addReservePlan( + @FormParam("pgName") String planName, + @FormParam("parName") String planType, + @FormParam("parName") String resUnit, + @FormParam("parName") String alarmType, + @FormParam("parName") String fileBuffer, + @FormParam("parName") String fileName)throws Exception { + Map resultMap = new HashMap(); + PgReservePlan pgReservePlan = new PgReservePlan(); + String result = ""; + String msg = ""; + + try { + if (StringUtils.isBlank(fileBuffer)||StringUtils.isBlank(fileName)) + pgReservePlan.setPlanFiel(""); + else { + pgReservePlan.setPlanFiel(pgReservePlanManager.saveFiles(fileBuffer, fileName,"reservePlan")); + } + + pgReservePlan.setPlanName(planName); + pgReservePlan.setPlanType(planType); + pgReservePlan.setResUnit(resUnit); + pgReservePlan.setPgAlarmTypeId(pgAlarmTypeManager.getAlarmTypeByAlarmType(alarmType)); + pgReservePlan.setActive(1); + + result = "true"; + msg = "保存成功"; + logger.info("保存成功"); + pgReservePlanManager.save(pgReservePlan); + } catch (Exception ex) { + result = "false"; + msg = "保存失败"; + ex.printStackTrace(); + } + + resultMap.put("success", result); + resultMap.put("msg", msg); + return resultMap; + } + + //编辑预案文档 + @RequestMapping("editReservePlan") + @ResponseBody + public Map editReservePlan(@FormParam("id") String id, + @RequestParam(value = "planName",required = true) String planName, + @RequestParam(value = "planType",required =false) String planType, + @RequestParam(value ="resUnit",required =false) String resUnit, + @RequestParam(value ="alarmType",required =false) String alarmType) throws Exception { + + Map resultMap = new HashMap(); + String result = ""; + String msg = ""; + + try { + PgReservePlan pgReservePlan = pgReservePlanManager.get(Long.valueOf(id)); + if (pgReservePlan == null) { + result = "false"; + msg = "不存在该预案信息"; + } else { + pgReservePlan.setPlanName(planName); + pgReservePlan.setPlanType(planType); + pgReservePlan.setResUnit(resUnit); + pgReservePlan.setPgAlarmTypeId(pgAlarmTypeManager.getAlarmTypeByAlarmType(alarmType)); + pgReservePlan.setActive(1); + + pgReservePlanManager.save(pgReservePlan); + result = "true"; + msg = "编辑成功"; + } + } catch (Exception e) { + result = "false"; + msg = "编辑失败"; + e.printStackTrace(); + } + return resultMap; + } + + //删除预案文档 + @RequestMapping("deleteReservePlan") + @ResponseBody + public Map deleteReservePlan(@FormParam("id") String id)throws Exception{ + Map resultMap = new HashMap(); + String msg=""; + String result="false"; + + try{ + + PgReservePlan pgReservePlan=pgReservePlanManager.get(Long.valueOf(id)); + if(pgReservePlan==null) + { + result="false"; + msg="不存在该预案信息"; + } + else{ + pgReservePlan.setActive(0); + pgReservePlanManager.save(pgReservePlan); + result="true"; + msg="删除成功"; + } + } + catch(Exception e) + { + e.printStackTrace(); + msg="预案删除失败"; + result="false"; + } + + 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/dto/PgTempHunDto.java b/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java deleted file mode 100644 index b2affe5..0000000 --- a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.casic.PgInterface.devData.dto; - -/** - * Created by yxw on 2017/11/28. - */ -public class PgTempHunDto { -} 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 eb1f7ab..da8f617 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -39,7 +39,6 @@ private List pgShs; private List pgTempHums; - @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") public long getId() { diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java index 4278dc1..669b60f 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java @@ -2,21 +2,20 @@ import javax.persistence.*; import java.io.Serializable; -import java.util.List; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Entity @Table(name = "PG_DEVICE_TYPE") @SequenceGenerator(name = "SEQ_PG_DEVICE_TYPE_ID", sequenceName = "SEQ_PG_DEVICE_TYPE_ID", allocationSize = 1, initialValue = 1) public class PgDeviceType implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; private long id; private String devType; private int active; - private List pgDeviceList; + @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_TYPE_ID") @@ -45,13 +44,4 @@ public void setActive(int active) { this.active = active; } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "devTypeId") - public List getPgDeviceList() { - return pgDeviceList; - } - - public void setPgDeviceList(List pgDeviceList) { - this.pgDeviceList = pgDeviceList; - } } 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 4fb3d6f..d209733 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java @@ -2,6 +2,7 @@ import javax.persistence.*; import java.io.Serializable; +import java.util.Date; import java.util.List; /** @@ -17,6 +18,12 @@ private long id; private String parName;//分区名称 private String road;//所属道路 + private String pgPosition;//仓段位置 + private String pgNum;//仓位数量 + private String pgType;//仓位类型 + private String pgLength;//分区长度 + private Date buildDate;//建设年代 + private String material;//建设材质 private int active;//状态位 private List pipeGalleryList;//管廊仓 @@ -48,6 +55,60 @@ this.road = road; } + @Column(name = "PGPOSITION") + public String getPgPosition() { + return pgPosition; + } + + public void setPgPosition(String pgPosition) { + this.pgPosition = pgPosition; + } + + @Column(name = "PGNUM") + public String getPgNum() { + return pgNum; + } + + public void setPgNum(String pgNum) { + this.pgNum = pgNum; + } + + @Column(name = "PGTYPE") + public String getPgType() { + return pgType; + } + + public void setPgType(String pgType) { + this.pgType = pgType; + } + + @Column(name = "PGLENGTH") + public String getPgLength() { + return pgLength; + } + + public void setPgLength(String pgLength) { + this.pgLength = pgLength; + } + + @Column(name = "BUILDDATE") + public Date getBuildDate() { + return buildDate; + } + + public void setBuildDate(Date buildDate) { + this.buildDate = buildDate; + } + + @Column(name = "MATERIAL") + public String getMaterial() { + return material; + } + + public void setMaterial(String material) { + this.material = material; + } + @Column(name = "ACTIVE") public int getActive() { return active; 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 95f9fbd..b60c42d 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java @@ -160,7 +160,7 @@ this.setAssetName(pgDevice.getAssetName()); this.setAssetCode(pgDevice.getAssetCode()); this.setAssetBarCode(pgDevice.getAssetBarCode()); - this.setId(pgDevice.getIp()); + this.setIp(pgDevice.getIp()); this.setModBus(pgDevice.getModBus()); this.setMome(pgDevice.getMome()); this.setIsOpen(String.valueOf(pgDevice.getIsOpen())); diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java index c1548e0..e348f7a 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java @@ -5,7 +5,7 @@ import java.io.Serializable; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ public class PgDeviceTypeDto implements Serializable { @@ -37,12 +37,11 @@ this.active = active; } - public PgDeviceTypeDto(PgDeviceType pgDeviceType) - { + public PgDeviceTypeDto(PgDeviceType pgDeviceType) { + this.setId(String.valueOf(pgDeviceType.getId())); this.setDevType(pgDeviceType.getDevType()); this.setActive(String.valueOf(pgDeviceType.getActive())); } - } 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 3acd0fa..95c18b4 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java @@ -3,6 +3,7 @@ import com.casic.PgInterface.devTable.domain.PgPartition; import java.io.Serializable; +import java.text.SimpleDateFormat; /** * Created by yxw on 2017/11/2. @@ -12,6 +13,12 @@ private String id; private String parName;//分区名称 private String road;//所属道路 + private String pgPosition;//仓段位置 + private String pgNum;//仓位数量 + private String pgType;//仓位类型 + private String pgLength;//分区长度 + private String buildDate;//建设年代 + private String material;//建设材质 private String active;//状态位 @@ -47,11 +54,67 @@ this.road = road; } + public String getPgPosition() { + return pgPosition; + } + + public void setPgPosition(String pgPosition) { + this.pgPosition = pgPosition; + } + + public String getPgNum() { + return pgNum; + } + + public void setPgNum(String pgNum) { + this.pgNum = pgNum; + } + + public String getPgType() { + return pgType; + } + + public void setPgType(String pgType) { + this.pgType = pgType; + } + + public String getPgLength() { + return pgLength; + } + + public void setPgLength(String pgLength) { + this.pgLength = pgLength; + } + + public String getBuildDate() { + return buildDate; + } + + public void setBuildDate(String buildDate) { + this.buildDate = buildDate; + } + + public String getMaterial() { + return material; + } + + public void setMaterial(String material) { + this.material = material; + } + public PgPartitionDto(PgPartition pgPartition) { + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); + this.setId(String.valueOf(pgPartition.getId())); this.setParName(pgPartition.getParName()); this.setRoad(pgPartition.getRoad()); + this.setPgPosition(pgPartition.getPgPosition()); + this.setPgNum(pgPartition.getPgNum()); + this.setPgType(pgPartition.getPgType()); + this.setPgLength(pgPartition.getPgLength()); + this.setBuildDate(sdf.format(pgPartition.getBuildDate())); + this.setMaterial(pgPartition.getMaterial()); this.setActive(String.valueOf(pgPartition.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java b/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java index d7c6024..9ea43fd 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java @@ -12,10 +12,10 @@ import java.util.List; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Service -public class PgDeviceTypeManager extends HibernateEntityDao{ +public class PgDeviceTypeManager extends HibernateEntityDao { public List getAllDeviceType() { @@ -23,8 +23,8 @@ criteria.add(Restrictions.eq("active", 1)); criteria.addOrder(Order.desc("id")); - List pgDeviceTypeList= criteria.list(); - List pgDeviceTypeDtoList=new ArrayList(); + List pgDeviceTypeList = criteria.list(); + List pgDeviceTypeDtoList = new ArrayList(); for (PgDeviceType pgDeviceType : pgDeviceTypeList) { pgDeviceTypeDtoList.add(new PgDeviceTypeDto(pgDeviceType)); } @@ -32,15 +32,14 @@ return pgDeviceTypeDtoList; } - public PgDeviceType getPgDeviceTypeByDevType(String devType) - { - Criteria criteria=createCriteria(PgDeviceType.class); - criteria.add(Restrictions.eq("devType",devType)); - criteria.add(Restrictions.eq("active",1)); - criteria.addOrder(Order.desc("id")); + public PgDeviceType getDeviceTypeByDeType(String devType) { - List pgDeviceTypeList=criteria.list(); - if(pgDeviceTypeList==null||pgDeviceTypeList.size()==0) + Criteria criteria = createCriteria(PgDeviceType.class); + criteria.add(Restrictions.eq("active", 1)); + criteria.add(Restrictions.eq("devType", devType)); + + List pgDeviceTypeList = criteria.list(); + if (pgDeviceTypeList.size() == 0) return null; else return pgDeviceTypeList.get(0); 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 0c594e7..c6f22cb 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java @@ -64,4 +64,4 @@ -} +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java index 9d06235..68b14cf 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java @@ -1,9 +1,5 @@ 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; @@ -19,7 +15,8 @@ private long id; private String highValue;//高限 private String lowValue;//低限 - private PgDevice pgDeviceId;//设备 + private String unit;//单位 + private String devType;//设备类型 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_ALARM_RULE_ID") @@ -49,15 +46,24 @@ this.lowValue = lowValue; } - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PGDEVICEID") - public PgDevice getPgDeviceId() { - return pgDeviceId; + @Column(name="UNIT") + public String getUnit() { + return unit; } - public void setPgDeviceId(PgDevice pgDeviceId) { - this.pgDeviceId = pgDeviceId; + public void setUnit(String unit) { + this.unit = unit; } + @Column(name = "DEVTYPE") + public String getDevType() { + return devType; + } + + public void setDevType(String devType) { + this.devType = devType; + } + + + } diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java deleted file mode 100644 index 7907e66..0000000 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.casic.PgInterface.patroler.dto; - -/** - * Created by yxw on 2017/12/14. - */ -public class PgAlarmRule { -} diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java index 8367ad4..0782c63 100644 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java @@ -12,7 +12,8 @@ private String id; private String highValue;//高限 private String lowValue;//低限 - private String devName;//设备 + private String devType;//设备类型 + private String unit;//单位 public String getId() { return id; @@ -38,20 +39,29 @@ this.lowValue = lowValue; } - public String getDevName() { - return devName; + public String getDevType() { + return devType; } - public void setDevName(String devName) { - this.devName = devName; + public void setDevType(String devType) { + this.devType = devType; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; } public PgAlarmRuleDto(PgAlarmRule pgAlarmRule) { this.setId(String.valueOf(pgAlarmRule.getId())); - this.setDevName(pgAlarmRule.getPgDeviceId().getAssetName()); this.setHighValue(pgAlarmRule.getHighValue()); this.setLowValue(pgAlarmRule.getLowValue()); + this.setDevType(pgAlarmRule.getDevType()); + this.setUnit(pgAlarmRule.getUnit()); } } diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java index d5c00b2..84e5cdd 100644 --- a/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java @@ -1,13 +1,13 @@ 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.ArrayList; import java.util.List; /** @@ -17,20 +17,21 @@ public class PgAlarmRuleManager extends HibernateEntityDao { //根据设备获取设备报警阈值 - public PgAlarmRuleDto getAlarmRuleDtoBydev(PgDevice pgDeviceId) { + public List getAlarmRuleDto() { 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)); + List pgAlarmRuleDtoList = new ArrayList(); + for (PgAlarmRule pgAlarmRule : pgAlarmRuleList) { + pgAlarmRuleDtoList.add(new PgAlarmRuleDto(pgAlarmRule)); + } + return pgAlarmRuleDtoList; + } - public PgAlarmRule getAlarmRuleBydev(PgDevice pgDeviceId) { + public PgAlarmRule getAlarmRuleBydevType(String devType) { Criteria criteria=createCriteria(PgAlarmRule.class); - criteria.add(Restrictions.eq("pgDeviceId", pgDeviceId)); + criteria.add(Restrictions.eq("devType", devType)); List pgAlarmRuleList=criteria.list(); if(pgAlarmRuleList.size()==0) diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java index f4e48c6..9396013 100644 --- a/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java @@ -39,13 +39,13 @@ } if (StringUtils.isNotBlank(startTime)) { - criteria.add(Restrictions.ge("operateTime", DateUtils.sdf4.parse(startTime))); + criteria.add(Restrictions.ge("operateTime", DateUtils.sdf_day.parse(startTime))); } if (StringUtils.isNotBlank(endTime)) { Calendar calendar = Calendar.getInstance(); - calendar.setTime(DateUtils.sdf4.parse(endTime)); + calendar.setTime(DateUtils.sdf_day.parse(endTime)); calendar.add(Calendar.DATE, 1); - criteria.add(Restrictions.le("time", calendar.getTime())); + criteria.add(Restrictions.le("operateTime", calendar.getTime())); } criteria.add(Restrictions.eq("active", 1)); diff --git a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java index 88255c6..f28ebdf 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java @@ -1,6 +1,5 @@ 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; @@ -15,7 +14,9 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -42,72 +43,43 @@ } /** - * 获取报警阈值信息 - */ - @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 { + public Map addAlarmRule(@FormParam("highValue") String highValue, + @FormParam("lowValue") String lowValue, + @FormParam("unit") String unit, + @FormParam("devType") String devType) 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(); + try { + pgAlarmRule = pgAlarmRuleManager.getAlarmRuleBydevType(devType); + if (pgAlarmRule != null) { result = "false"; - msg = "报警阈值新增失败"; + msg = "设备阈值已经存在"; + } else { + pgAlarmRule = new PgAlarmRule(); + pgAlarmRule.setHighValue(highValue); + pgAlarmRule.setLowValue(lowValue); + pgAlarmRule.setDevType(devType); + pgAlarmRule.setUnit(unit); + + pgAlarmRuleManager.save(pgAlarmRule); + result = "true"; + msg = "报警阈值新增成功"; } + } catch (Exception e) { + e.printStackTrace(); + result = "false"; + msg = "报警阈值新增失败"; } + resultMap.put("msg", msg); resultMap.put("result", result); return resultMap; @@ -119,44 +91,66 @@ @POST @Path("editAlarmRule") @Produces(MediaType.APPLICATION_JSON) - public Map editAlarmRule(@FormParam("id") String id, - @FormParam("assetCode") String assetCode, + public Map editAlarmRule(@FormParam("devType") String devType, @FormParam("highValue") String highValue, - @FormParam("lowValue") String lowValue) throws Exception { + @FormParam("lowValue") String lowValue, + @FormParam("unit") String unit) 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(); + + try { + pgAlarmRule = pgAlarmRuleManager.getAlarmRuleBydevType(devType); + if (pgAlarmRule == null) { + msg = "不存在报警阈值记录"; result = "false"; - msg = "报警阈值编辑失败"; + } else { + pgAlarmRule.setDevType(devType); + pgAlarmRule.setHighValue(highValue); + pgAlarmRule.setLowValue(lowValue); + pgAlarmRule.setUnit(unit); + pgAlarmRuleManager.save(pgAlarmRule); + msg = "编辑成功"; + result = "true"; } + } catch (Exception ex) { + ex.printStackTrace(); + result = "false"; + msg = "报警阈值编辑失败"; } + resultMap.put("msg", msg); resultMap.put("result", result); return resultMap; + } + /** + * 获取报警阈值信息 + */ + @POST + @Path("getAlarmRule") + @Produces(MediaType.APPLICATION_JSON) + public Map getAlarmRule() throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + + List pgAlarmRuleDtoList = new ArrayList(); + try { + pgAlarmRuleDtoList = pgAlarmRuleManager.getAlarmRuleDto(); + if (pgAlarmRuleDtoList == null) + msg = "不存在报警阈值信息"; + else + msg = "报警阈值获取成功"; + } catch (Exception e) { + e.printStackTrace(); + msg = "报警信息获取失败"; + } + resultMap.put("msg", msg); + resultMap.put("result", pgAlarmRuleDtoList); + 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 bb8c245..36547a7 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java @@ -104,8 +104,8 @@ @POST @Path("addDevice") @Produces(MediaType.APPLICATION_JSON) - public Map addDevice(@FormParam("parName") String parName, - @FormParam("pgName") String pgName, + public Map addDevice(@FormParam("partition") String partition, + @FormParam("pipeGallery") String pipeGallery, @FormParam("road") String road, @FormParam("position") String position, @FormParam("devType") String devType, @@ -129,8 +129,8 @@ } else { PgDevice pgDevice = new PgDevice(); - pgDevice.setPipeGallery(pgName); - pgDevice.setPartition(parName); + pgDevice.setPipeGallery(pipeGallery); + pgDevice.setPartition(partition); pgDevice.setRoad(road); pgDevice.setPosition(position); pgDevice.setDevType(devType); @@ -168,8 +168,8 @@ @Path("editDevice") @Produces(MediaType.APPLICATION_JSON) public Map editPartition(@FormParam("id") String id, - @FormParam("parName") String parName, - @FormParam("pgName") String pgName, + @FormParam("partition") String partition, + @FormParam("pipeGallery") String pipeGallery, @FormParam("road") String road, @FormParam("position") String position, @FormParam("devType") String devType, @@ -187,13 +187,15 @@ String msg = ""; try { + /* if (pgDeviceManager.getDeviceByAssetCode(assetCode)!=null) { result = "false"; msg = "已存在同名设备"; } else { + */ PgDevice pgDevice = pgDeviceManager.get(Long.valueOf(id)); - pgDevice.setPipeGallery(pgName); - pgDevice.setPartition(parName); + pgDevice.setPipeGallery(pipeGallery); + pgDevice.setPartition(partition); pgDevice.setRoad(road); pgDevice.setPosition(position); pgDevice.setDevType(devType); @@ -210,7 +212,7 @@ pgDeviceManager.save(pgDevice); result = "true"; msg = "编辑成功"; - } + //} } catch (Exception e) { result = "false"; msg = "编辑失败"; diff --git a/src/main/java/com/casic/PgInterface/rs/PgDeviceTypeRs.java b/src/main/java/com/casic/PgInterface/rs/PgDeviceTypeRs.java index 756894f..b6c84aa 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgDeviceTypeRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgDeviceTypeRs.java @@ -19,12 +19,13 @@ import java.util.Map; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Component @Path("pgDeviceType") public class PgDeviceTypeRs { - private static Logger logger = LoggerFactory.getLogger(PgDeviceRs.class); + + private static Logger logger = LoggerFactory.getLogger(PgDeviceTypeRs.class); private PgDeviceTypeManager pgDeviceTypeManager; @@ -34,21 +35,21 @@ } /** - * 获取设备类型 + * 显示设备列表 */ @POST @Path("getDeviceType") @Produces(MediaType.APPLICATION_JSON) - public Map getDeviceType()throws Exception { + public Map getDeviceTpeyList()throws Exception { Map resultMap = new HashMap(); String msg=""; List pgDeviceTypeDtoList=new ArrayList(); try { pgDeviceTypeDtoList = pgDeviceTypeManager.getAllDeviceType(); if(pgDeviceTypeDtoList.size()==0) - msg="没有设备类型信息"; + msg="没有找到设备类型信息"; else - msg="设备类型获取失败"; + msg="设备类型信息获取成功"; }catch(Exception e){ e.printStackTrace(); msg="设备类型信息获取失败"; @@ -64,37 +65,39 @@ @POST @Path("addDeviceType") @Produces(MediaType.APPLICATION_JSON) - public Map addDeviceType(@FormParam("devType") String devType) + public Map addDevice(@FormParam("devType") String devType) throws Exception { Map resultMap = new HashMap(); String result = ""; String msg = ""; - try { - if (pgDeviceTypeManager.getPgDeviceTypeByDevType(devType)!=null) { - result = "false"; - msg = "已存在同名设备类型"; - } else { - PgDeviceType pgDeviceType=new PgDeviceType(); - pgDeviceType.setDevType(devType); - pgDeviceType.setActive(1); - - pgDeviceTypeManager.save(pgDeviceType); - result = "true"; - msg = "保存成功"; - } - - } catch (Exception e) { + try { + if (pgDeviceTypeManager.getDeviceTypeByDeType(devType)!=null) { result = "false"; - msg = "保存失败"; - e.printStackTrace(); + msg = "已存在设备类型"; + } else { + PgDeviceType pgDeviceType = new PgDeviceType(); + + pgDeviceType.setDevType(devType); + pgDeviceType.setActive(1); + + pgDeviceTypeManager.save(pgDeviceType); + result = "true"; + msg = "保存成功"; } + } catch (Exception e) { + result = "false"; + msg = "保存失败"; + e.printStackTrace(); + } + resultMap.put("success", result); resultMap.put("msg", msg); return resultMap; } + } diff --git a/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java b/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java index 8a42e7e..249b75c 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java @@ -13,10 +13,8 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.text.SimpleDateFormat; +import java.util.*; /** * Created by yxw on 2017/11/6. @@ -40,25 +38,35 @@ @POST @Path("addPartition") @Produces(MediaType.APPLICATION_JSON) - public Map addAlarm(@FormParam("parName") String parName)throws Exception { + public Map addAlarm(@FormParam("parName") String parName, + @FormParam("road") String road, + @FormParam("pgPosition") String pgPosition, + @FormParam("pgNum") String pgNum, + @FormParam("pgType") String pgType, + @FormParam("pgLength") String pgLength, + @FormParam("buildDate") String buildDate, + @FormParam("material") String material)throws Exception { Map resultMap = new HashMap(); String result = ""; String msg = ""; + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); try { - if (pgPartitionManager.getPartitionByParName(parName) != null) { - result = "false"; - msg = "已存在相同分区"; - } else { PgPartition pgPartition = new PgPartition(); pgPartition.setParName(parName); + pgPartition.setRoad(road); + pgPartition.setPgPosition(pgPosition); + pgPartition.setPgNum(pgNum); + pgPartition.setPgType(pgType); + pgPartition.setPgLength(pgLength); + pgPartition.setBuildDate(sdf.parse(buildDate)); + pgPartition.setMaterial(material); pgPartition.setActive(1); logger.info("成功保存"); pgPartitionManager.save(pgPartition); result = "true"; msg = "保存成功"; - } } catch (Exception e) { result = "false"; @@ -71,28 +79,40 @@ return resultMap; } - - @POST @Path("editPartition") @Produces(MediaType.APPLICATION_JSON) public Map editPartition(@FormParam("id") String id, - @FormParam("parName") String parName) throws Exception { + @FormParam("parName") String parName, + @FormParam("road") String road, + @FormParam("pgPosition") String pgPosition, + @FormParam("pgNum") String pgNum, + @FormParam("pgType") String pgType, + @FormParam("pgLength") String pgLength, + @FormParam("buildDate") String buildDate, + @FormParam("material") String material) throws Exception { Map resultMap = new HashMap(); String result = ""; String msg = ""; PgPartition partition = new PgPartition(); + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); try { - if (pgPartitionManager.getPartitionByParName(parName) != null) { result = "false"; msg = "已存在相同分区"; } else { PgPartition pgPartition = pgPartitionManager.get(Long.valueOf(id)); pgPartition.setParName(parName); + pgPartition.setRoad(road); + pgPartition.setPgPosition(pgPosition); + pgPartition.setPgNum(pgNum); + pgPartition.setPgType(pgType); + pgPartition.setPgLength(pgLength); + pgPartition.setBuildDate(sdf.parse(buildDate)); + pgPartition.setMaterial(material); pgPartition.setActive(1); pgPartitionManager.save(pgPartition); diff --git a/src/main/java/com/casic/PgInterface/rs/PgPatrolerRs.java b/src/main/java/com/casic/PgInterface/rs/PgPatrolerRs.java index aed1ed8..0b3c731 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgPatrolerRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgPatrolerRs.java @@ -123,10 +123,12 @@ String result = ""; String msg = ""; try { + /* if (pgPatrolerManager.userNameIsExits(userName)) { result = "false"; msg = "用户名已经存在!"; } else { + */ PgPatroler pgPatroler = pgPatrolerManager.get(Long.valueOf(id)); pgPatroler.setUserName(userName); pgPatroler.setPassword(password); @@ -136,7 +138,7 @@ pgPatrolerManager.save(pgPatroler); result = "true"; msg = "编辑成功"; - } + //} } catch (Exception e) { result = "false"; msg = "编辑失败"; diff --git a/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java b/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java index 8cbdb0a..4c9feac 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java @@ -165,12 +165,14 @@ msg = "不存在管廊仓和分区信息"; } else { try { + /* if(pgPipeLineManager.getPipeLineBylineName(lineName)!=null) { result = "false"; msg = "已存在同名管线"; } else { + */ PgPipeLine pgPipeLine = pgPipeLineManager.get(Long.valueOf(id)); pgPipeLine.setLineName(lineName); @@ -185,7 +187,7 @@ pgPipeLineManager.save(pgPipeLine); result = "true"; msg = "编辑成功"; - } + //} } catch (Exception e) { result = "false"; msg = "编辑失败"; diff --git a/src/main/java/com/casic/PgInterface/rs/PgReserveController.java b/src/main/java/com/casic/PgInterface/rs/PgReserveController.java new file mode 100644 index 0000000..863045a --- /dev/null +++ b/src/main/java/com/casic/PgInterface/rs/PgReserveController.java @@ -0,0 +1,207 @@ +package com.casic.PgInterface.rs; + +import com.casic.PgInterface.core.util.StringUtils; +import com.casic.PgInterface.devTable.manager.PgAlarmTypeManager; +import com.casic.PgInterface.reservePlan.domain.PgReservePlan; +import com.casic.PgInterface.reservePlan.manager.PgReservePlanManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.multipart.MultipartFile; +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.List; +import java.util.Map; + +/** + * Created by yxw on 2017/11/8. + */ +@Controller +@RequestMapping("rs/pgReservePlan") +public class PgReserveController { + + private static Logger logger = LoggerFactory.getLogger(PgReservePlan.class); + + private PgReservePlanManager pgReservePlanManager; + + private PgAlarmTypeManager pgAlarmTypeManager; + + @Resource + public void setPgReservePlanManager(PgReservePlanManager pgReservePlanManager) { + this.pgReservePlanManager = pgReservePlanManager; + } + + @Resource + public void setPgAlarmTypeManager(PgAlarmTypeManager pgAlarmTypeManager) { + this.pgAlarmTypeManager = pgAlarmTypeManager; + } + +// //新增预案文档 +// @RequestMapping("addReservePlan") +// @ResponseBody +// public Map addReservePlan(@RequestParam(value = "planName",required = true) String planName, +// @RequestParam(value = "planType",required =false) String planType, +// @RequestParam(value ="resUnit",required =false) String resUnit, +// @RequestParam(value ="alarmType",required =false) String alarmType, +// @RequestParam(value = "planFiels",required =false) List planFiels) +// throws Exception { +// Map resultMap = new HashMap(); +// PgReservePlan pgReservePlan = new PgReservePlan(); +// String result = ""; +// String msg = ""; +// +// try { +// if (planFiels.size() == 0) +// pgReservePlan.setPlanFiel(""); +// else { +// pgReservePlan.setPlanFiel(pgReservePlanManager.saveFiles(planFiels, "reservePlan")); +// } +// +// pgReservePlan.setPlanName(planName); +// pgReservePlan.setPlanType(planType); +// pgReservePlan.setResUnit(resUnit); +// pgReservePlan.setPgAlarmTypeId(pgAlarmTypeManager.getAlarmTypeByAlarmType(alarmType)); +// pgReservePlan.setActive(1); +// +// result = "true"; +// msg = "保存成功"; +// logger.info("保存成功"); +// pgReservePlanManager.save(pgReservePlan); +// } catch (Exception ex) { +// result = "false"; +// msg = "保存失败"; +// ex.printStackTrace(); +// } +// +// resultMap.put("success", result); +// resultMap.put("msg", msg); +// return resultMap; +// } + + //新增预案文档 + @POST + @Path("addReservePlan") + @Produces(MediaType.APPLICATION_JSON) + public Map addReservePlan( + @FormParam("pgName") String planName, + @FormParam("parName") String planType, + @FormParam("parName") String resUnit, + @FormParam("parName") String alarmType, + @FormParam("parName") String fileBuffer, + @FormParam("parName") String fileName)throws Exception { + Map resultMap = new HashMap(); + PgReservePlan pgReservePlan = new PgReservePlan(); + String result = ""; + String msg = ""; + + try { + if (StringUtils.isBlank(fileBuffer)||StringUtils.isBlank(fileName)) + pgReservePlan.setPlanFiel(""); + else { + pgReservePlan.setPlanFiel(pgReservePlanManager.saveFiles(fileBuffer, fileName,"reservePlan")); + } + + pgReservePlan.setPlanName(planName); + pgReservePlan.setPlanType(planType); + pgReservePlan.setResUnit(resUnit); + pgReservePlan.setPgAlarmTypeId(pgAlarmTypeManager.getAlarmTypeByAlarmType(alarmType)); + pgReservePlan.setActive(1); + + result = "true"; + msg = "保存成功"; + logger.info("保存成功"); + pgReservePlanManager.save(pgReservePlan); + } catch (Exception ex) { + result = "false"; + msg = "保存失败"; + ex.printStackTrace(); + } + + resultMap.put("success", result); + resultMap.put("msg", msg); + return resultMap; + } + + //编辑预案文档 + @RequestMapping("editReservePlan") + @ResponseBody + public Map editReservePlan(@FormParam("id") String id, + @RequestParam(value = "planName",required = true) String planName, + @RequestParam(value = "planType",required =false) String planType, + @RequestParam(value ="resUnit",required =false) String resUnit, + @RequestParam(value ="alarmType",required =false) String alarmType) throws Exception { + + Map resultMap = new HashMap(); + String result = ""; + String msg = ""; + + try { + PgReservePlan pgReservePlan = pgReservePlanManager.get(Long.valueOf(id)); + if (pgReservePlan == null) { + result = "false"; + msg = "不存在该预案信息"; + } else { + pgReservePlan.setPlanName(planName); + pgReservePlan.setPlanType(planType); + pgReservePlan.setResUnit(resUnit); + pgReservePlan.setPgAlarmTypeId(pgAlarmTypeManager.getAlarmTypeByAlarmType(alarmType)); + pgReservePlan.setActive(1); + + pgReservePlanManager.save(pgReservePlan); + result = "true"; + msg = "编辑成功"; + } + } catch (Exception e) { + result = "false"; + msg = "编辑失败"; + e.printStackTrace(); + } + return resultMap; + } + + //删除预案文档 + @RequestMapping("deleteReservePlan") + @ResponseBody + public Map deleteReservePlan(@FormParam("id") String id)throws Exception{ + Map resultMap = new HashMap(); + String msg=""; + String result="false"; + + try{ + + PgReservePlan pgReservePlan=pgReservePlanManager.get(Long.valueOf(id)); + if(pgReservePlan==null) + { + result="false"; + msg="不存在该预案信息"; + } + else{ + pgReservePlan.setActive(0); + pgReservePlanManager.save(pgReservePlan); + result="true"; + msg="删除成功"; + } + } + catch(Exception e) + { + e.printStackTrace(); + msg="预案删除失败"; + result="false"; + } + + 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/PgTextureRs.java b/src/main/java/com/casic/PgInterface/rs/PgTextureRs.java index 5892127..2360251 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgTextureRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgTextureRs.java @@ -163,12 +163,14 @@ msg = "不存在管廊仓和分区信息"; } else { try { + /* if(pgTextureManager.getPgTextureByName(textureName)!=null) { result = "false"; msg = "已存在同名的部件"; } else { + */ PgTexture pgTexture = pgTextureManager.get(Long.valueOf(id)); pgTexture.setTextureName(textureName); pgTexture.setTextureMaterial(textureMaterial); @@ -181,7 +183,7 @@ pgTextureManager.save(pgTexture); result = "true"; msg = "编辑成功"; - } + //} } catch (Exception e) { result = "false"; msg = "编辑失败"; diff --git a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java b/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java deleted file mode 100644 index b2affe5..0000000 --- a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.casic.PgInterface.devData.dto; - -/** - * Created by yxw on 2017/11/28. - */ -public class PgTempHunDto { -} 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 eb1f7ab..da8f617 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -39,7 +39,6 @@ private List pgShs; private List pgTempHums; - @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") public long getId() { diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java index 4278dc1..669b60f 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java @@ -2,21 +2,20 @@ import javax.persistence.*; import java.io.Serializable; -import java.util.List; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Entity @Table(name = "PG_DEVICE_TYPE") @SequenceGenerator(name = "SEQ_PG_DEVICE_TYPE_ID", sequenceName = "SEQ_PG_DEVICE_TYPE_ID", allocationSize = 1, initialValue = 1) public class PgDeviceType implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; private long id; private String devType; private int active; - private List pgDeviceList; + @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_TYPE_ID") @@ -45,13 +44,4 @@ public void setActive(int active) { this.active = active; } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "devTypeId") - public List getPgDeviceList() { - return pgDeviceList; - } - - public void setPgDeviceList(List pgDeviceList) { - this.pgDeviceList = pgDeviceList; - } } 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 4fb3d6f..d209733 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java @@ -2,6 +2,7 @@ import javax.persistence.*; import java.io.Serializable; +import java.util.Date; import java.util.List; /** @@ -17,6 +18,12 @@ private long id; private String parName;//分区名称 private String road;//所属道路 + private String pgPosition;//仓段位置 + private String pgNum;//仓位数量 + private String pgType;//仓位类型 + private String pgLength;//分区长度 + private Date buildDate;//建设年代 + private String material;//建设材质 private int active;//状态位 private List pipeGalleryList;//管廊仓 @@ -48,6 +55,60 @@ this.road = road; } + @Column(name = "PGPOSITION") + public String getPgPosition() { + return pgPosition; + } + + public void setPgPosition(String pgPosition) { + this.pgPosition = pgPosition; + } + + @Column(name = "PGNUM") + public String getPgNum() { + return pgNum; + } + + public void setPgNum(String pgNum) { + this.pgNum = pgNum; + } + + @Column(name = "PGTYPE") + public String getPgType() { + return pgType; + } + + public void setPgType(String pgType) { + this.pgType = pgType; + } + + @Column(name = "PGLENGTH") + public String getPgLength() { + return pgLength; + } + + public void setPgLength(String pgLength) { + this.pgLength = pgLength; + } + + @Column(name = "BUILDDATE") + public Date getBuildDate() { + return buildDate; + } + + public void setBuildDate(Date buildDate) { + this.buildDate = buildDate; + } + + @Column(name = "MATERIAL") + public String getMaterial() { + return material; + } + + public void setMaterial(String material) { + this.material = material; + } + @Column(name = "ACTIVE") public int getActive() { return active; 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 95f9fbd..b60c42d 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java @@ -160,7 +160,7 @@ this.setAssetName(pgDevice.getAssetName()); this.setAssetCode(pgDevice.getAssetCode()); this.setAssetBarCode(pgDevice.getAssetBarCode()); - this.setId(pgDevice.getIp()); + this.setIp(pgDevice.getIp()); this.setModBus(pgDevice.getModBus()); this.setMome(pgDevice.getMome()); this.setIsOpen(String.valueOf(pgDevice.getIsOpen())); diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java index c1548e0..e348f7a 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java @@ -5,7 +5,7 @@ import java.io.Serializable; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ public class PgDeviceTypeDto implements Serializable { @@ -37,12 +37,11 @@ this.active = active; } - public PgDeviceTypeDto(PgDeviceType pgDeviceType) - { + public PgDeviceTypeDto(PgDeviceType pgDeviceType) { + this.setId(String.valueOf(pgDeviceType.getId())); this.setDevType(pgDeviceType.getDevType()); this.setActive(String.valueOf(pgDeviceType.getActive())); } - } 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 3acd0fa..95c18b4 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java @@ -3,6 +3,7 @@ import com.casic.PgInterface.devTable.domain.PgPartition; import java.io.Serializable; +import java.text.SimpleDateFormat; /** * Created by yxw on 2017/11/2. @@ -12,6 +13,12 @@ private String id; private String parName;//分区名称 private String road;//所属道路 + private String pgPosition;//仓段位置 + private String pgNum;//仓位数量 + private String pgType;//仓位类型 + private String pgLength;//分区长度 + private String buildDate;//建设年代 + private String material;//建设材质 private String active;//状态位 @@ -47,11 +54,67 @@ this.road = road; } + public String getPgPosition() { + return pgPosition; + } + + public void setPgPosition(String pgPosition) { + this.pgPosition = pgPosition; + } + + public String getPgNum() { + return pgNum; + } + + public void setPgNum(String pgNum) { + this.pgNum = pgNum; + } + + public String getPgType() { + return pgType; + } + + public void setPgType(String pgType) { + this.pgType = pgType; + } + + public String getPgLength() { + return pgLength; + } + + public void setPgLength(String pgLength) { + this.pgLength = pgLength; + } + + public String getBuildDate() { + return buildDate; + } + + public void setBuildDate(String buildDate) { + this.buildDate = buildDate; + } + + public String getMaterial() { + return material; + } + + public void setMaterial(String material) { + this.material = material; + } + public PgPartitionDto(PgPartition pgPartition) { + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); + this.setId(String.valueOf(pgPartition.getId())); this.setParName(pgPartition.getParName()); this.setRoad(pgPartition.getRoad()); + this.setPgPosition(pgPartition.getPgPosition()); + this.setPgNum(pgPartition.getPgNum()); + this.setPgType(pgPartition.getPgType()); + this.setPgLength(pgPartition.getPgLength()); + this.setBuildDate(sdf.format(pgPartition.getBuildDate())); + this.setMaterial(pgPartition.getMaterial()); this.setActive(String.valueOf(pgPartition.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java b/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java index d7c6024..9ea43fd 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java @@ -12,10 +12,10 @@ import java.util.List; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Service -public class PgDeviceTypeManager extends HibernateEntityDao{ +public class PgDeviceTypeManager extends HibernateEntityDao { public List getAllDeviceType() { @@ -23,8 +23,8 @@ criteria.add(Restrictions.eq("active", 1)); criteria.addOrder(Order.desc("id")); - List pgDeviceTypeList= criteria.list(); - List pgDeviceTypeDtoList=new ArrayList(); + List pgDeviceTypeList = criteria.list(); + List pgDeviceTypeDtoList = new ArrayList(); for (PgDeviceType pgDeviceType : pgDeviceTypeList) { pgDeviceTypeDtoList.add(new PgDeviceTypeDto(pgDeviceType)); } @@ -32,15 +32,14 @@ return pgDeviceTypeDtoList; } - public PgDeviceType getPgDeviceTypeByDevType(String devType) - { - Criteria criteria=createCriteria(PgDeviceType.class); - criteria.add(Restrictions.eq("devType",devType)); - criteria.add(Restrictions.eq("active",1)); - criteria.addOrder(Order.desc("id")); + public PgDeviceType getDeviceTypeByDeType(String devType) { - List pgDeviceTypeList=criteria.list(); - if(pgDeviceTypeList==null||pgDeviceTypeList.size()==0) + Criteria criteria = createCriteria(PgDeviceType.class); + criteria.add(Restrictions.eq("active", 1)); + criteria.add(Restrictions.eq("devType", devType)); + + List pgDeviceTypeList = criteria.list(); + if (pgDeviceTypeList.size() == 0) return null; else return pgDeviceTypeList.get(0); 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 0c594e7..c6f22cb 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java @@ -64,4 +64,4 @@ -} +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java index 9d06235..68b14cf 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java @@ -1,9 +1,5 @@ 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; @@ -19,7 +15,8 @@ private long id; private String highValue;//高限 private String lowValue;//低限 - private PgDevice pgDeviceId;//设备 + private String unit;//单位 + private String devType;//设备类型 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_ALARM_RULE_ID") @@ -49,15 +46,24 @@ this.lowValue = lowValue; } - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PGDEVICEID") - public PgDevice getPgDeviceId() { - return pgDeviceId; + @Column(name="UNIT") + public String getUnit() { + return unit; } - public void setPgDeviceId(PgDevice pgDeviceId) { - this.pgDeviceId = pgDeviceId; + public void setUnit(String unit) { + this.unit = unit; } + @Column(name = "DEVTYPE") + public String getDevType() { + return devType; + } + + public void setDevType(String devType) { + this.devType = devType; + } + + + } diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java deleted file mode 100644 index 7907e66..0000000 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.casic.PgInterface.patroler.dto; - -/** - * Created by yxw on 2017/12/14. - */ -public class PgAlarmRule { -} diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java index 8367ad4..0782c63 100644 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java @@ -12,7 +12,8 @@ private String id; private String highValue;//高限 private String lowValue;//低限 - private String devName;//设备 + private String devType;//设备类型 + private String unit;//单位 public String getId() { return id; @@ -38,20 +39,29 @@ this.lowValue = lowValue; } - public String getDevName() { - return devName; + public String getDevType() { + return devType; } - public void setDevName(String devName) { - this.devName = devName; + public void setDevType(String devType) { + this.devType = devType; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; } public PgAlarmRuleDto(PgAlarmRule pgAlarmRule) { this.setId(String.valueOf(pgAlarmRule.getId())); - this.setDevName(pgAlarmRule.getPgDeviceId().getAssetName()); this.setHighValue(pgAlarmRule.getHighValue()); this.setLowValue(pgAlarmRule.getLowValue()); + this.setDevType(pgAlarmRule.getDevType()); + this.setUnit(pgAlarmRule.getUnit()); } } diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java index d5c00b2..84e5cdd 100644 --- a/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java @@ -1,13 +1,13 @@ 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.ArrayList; import java.util.List; /** @@ -17,20 +17,21 @@ public class PgAlarmRuleManager extends HibernateEntityDao { //根据设备获取设备报警阈值 - public PgAlarmRuleDto getAlarmRuleDtoBydev(PgDevice pgDeviceId) { + public List getAlarmRuleDto() { 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)); + List pgAlarmRuleDtoList = new ArrayList(); + for (PgAlarmRule pgAlarmRule : pgAlarmRuleList) { + pgAlarmRuleDtoList.add(new PgAlarmRuleDto(pgAlarmRule)); + } + return pgAlarmRuleDtoList; + } - public PgAlarmRule getAlarmRuleBydev(PgDevice pgDeviceId) { + public PgAlarmRule getAlarmRuleBydevType(String devType) { Criteria criteria=createCriteria(PgAlarmRule.class); - criteria.add(Restrictions.eq("pgDeviceId", pgDeviceId)); + criteria.add(Restrictions.eq("devType", devType)); List pgAlarmRuleList=criteria.list(); if(pgAlarmRuleList.size()==0) diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java index f4e48c6..9396013 100644 --- a/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java @@ -39,13 +39,13 @@ } if (StringUtils.isNotBlank(startTime)) { - criteria.add(Restrictions.ge("operateTime", DateUtils.sdf4.parse(startTime))); + criteria.add(Restrictions.ge("operateTime", DateUtils.sdf_day.parse(startTime))); } if (StringUtils.isNotBlank(endTime)) { Calendar calendar = Calendar.getInstance(); - calendar.setTime(DateUtils.sdf4.parse(endTime)); + calendar.setTime(DateUtils.sdf_day.parse(endTime)); calendar.add(Calendar.DATE, 1); - criteria.add(Restrictions.le("time", calendar.getTime())); + criteria.add(Restrictions.le("operateTime", calendar.getTime())); } criteria.add(Restrictions.eq("active", 1)); diff --git a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java index 88255c6..f28ebdf 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java @@ -1,6 +1,5 @@ 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; @@ -15,7 +14,9 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -42,72 +43,43 @@ } /** - * 获取报警阈值信息 - */ - @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 { + public Map addAlarmRule(@FormParam("highValue") String highValue, + @FormParam("lowValue") String lowValue, + @FormParam("unit") String unit, + @FormParam("devType") String devType) 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(); + try { + pgAlarmRule = pgAlarmRuleManager.getAlarmRuleBydevType(devType); + if (pgAlarmRule != null) { result = "false"; - msg = "报警阈值新增失败"; + msg = "设备阈值已经存在"; + } else { + pgAlarmRule = new PgAlarmRule(); + pgAlarmRule.setHighValue(highValue); + pgAlarmRule.setLowValue(lowValue); + pgAlarmRule.setDevType(devType); + pgAlarmRule.setUnit(unit); + + pgAlarmRuleManager.save(pgAlarmRule); + result = "true"; + msg = "报警阈值新增成功"; } + } catch (Exception e) { + e.printStackTrace(); + result = "false"; + msg = "报警阈值新增失败"; } + resultMap.put("msg", msg); resultMap.put("result", result); return resultMap; @@ -119,44 +91,66 @@ @POST @Path("editAlarmRule") @Produces(MediaType.APPLICATION_JSON) - public Map editAlarmRule(@FormParam("id") String id, - @FormParam("assetCode") String assetCode, + public Map editAlarmRule(@FormParam("devType") String devType, @FormParam("highValue") String highValue, - @FormParam("lowValue") String lowValue) throws Exception { + @FormParam("lowValue") String lowValue, + @FormParam("unit") String unit) 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(); + + try { + pgAlarmRule = pgAlarmRuleManager.getAlarmRuleBydevType(devType); + if (pgAlarmRule == null) { + msg = "不存在报警阈值记录"; result = "false"; - msg = "报警阈值编辑失败"; + } else { + pgAlarmRule.setDevType(devType); + pgAlarmRule.setHighValue(highValue); + pgAlarmRule.setLowValue(lowValue); + pgAlarmRule.setUnit(unit); + pgAlarmRuleManager.save(pgAlarmRule); + msg = "编辑成功"; + result = "true"; } + } catch (Exception ex) { + ex.printStackTrace(); + result = "false"; + msg = "报警阈值编辑失败"; } + resultMap.put("msg", msg); resultMap.put("result", result); return resultMap; + } + /** + * 获取报警阈值信息 + */ + @POST + @Path("getAlarmRule") + @Produces(MediaType.APPLICATION_JSON) + public Map getAlarmRule() throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + + List pgAlarmRuleDtoList = new ArrayList(); + try { + pgAlarmRuleDtoList = pgAlarmRuleManager.getAlarmRuleDto(); + if (pgAlarmRuleDtoList == null) + msg = "不存在报警阈值信息"; + else + msg = "报警阈值获取成功"; + } catch (Exception e) { + e.printStackTrace(); + msg = "报警信息获取失败"; + } + resultMap.put("msg", msg); + resultMap.put("result", pgAlarmRuleDtoList); + 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 bb8c245..36547a7 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java @@ -104,8 +104,8 @@ @POST @Path("addDevice") @Produces(MediaType.APPLICATION_JSON) - public Map addDevice(@FormParam("parName") String parName, - @FormParam("pgName") String pgName, + public Map addDevice(@FormParam("partition") String partition, + @FormParam("pipeGallery") String pipeGallery, @FormParam("road") String road, @FormParam("position") String position, @FormParam("devType") String devType, @@ -129,8 +129,8 @@ } else { PgDevice pgDevice = new PgDevice(); - pgDevice.setPipeGallery(pgName); - pgDevice.setPartition(parName); + pgDevice.setPipeGallery(pipeGallery); + pgDevice.setPartition(partition); pgDevice.setRoad(road); pgDevice.setPosition(position); pgDevice.setDevType(devType); @@ -168,8 +168,8 @@ @Path("editDevice") @Produces(MediaType.APPLICATION_JSON) public Map editPartition(@FormParam("id") String id, - @FormParam("parName") String parName, - @FormParam("pgName") String pgName, + @FormParam("partition") String partition, + @FormParam("pipeGallery") String pipeGallery, @FormParam("road") String road, @FormParam("position") String position, @FormParam("devType") String devType, @@ -187,13 +187,15 @@ String msg = ""; try { + /* if (pgDeviceManager.getDeviceByAssetCode(assetCode)!=null) { result = "false"; msg = "已存在同名设备"; } else { + */ PgDevice pgDevice = pgDeviceManager.get(Long.valueOf(id)); - pgDevice.setPipeGallery(pgName); - pgDevice.setPartition(parName); + pgDevice.setPipeGallery(pipeGallery); + pgDevice.setPartition(partition); pgDevice.setRoad(road); pgDevice.setPosition(position); pgDevice.setDevType(devType); @@ -210,7 +212,7 @@ pgDeviceManager.save(pgDevice); result = "true"; msg = "编辑成功"; - } + //} } catch (Exception e) { result = "false"; msg = "编辑失败"; diff --git a/src/main/java/com/casic/PgInterface/rs/PgDeviceTypeRs.java b/src/main/java/com/casic/PgInterface/rs/PgDeviceTypeRs.java index 756894f..b6c84aa 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgDeviceTypeRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgDeviceTypeRs.java @@ -19,12 +19,13 @@ import java.util.Map; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Component @Path("pgDeviceType") public class PgDeviceTypeRs { - private static Logger logger = LoggerFactory.getLogger(PgDeviceRs.class); + + private static Logger logger = LoggerFactory.getLogger(PgDeviceTypeRs.class); private PgDeviceTypeManager pgDeviceTypeManager; @@ -34,21 +35,21 @@ } /** - * 获取设备类型 + * 显示设备列表 */ @POST @Path("getDeviceType") @Produces(MediaType.APPLICATION_JSON) - public Map getDeviceType()throws Exception { + public Map getDeviceTpeyList()throws Exception { Map resultMap = new HashMap(); String msg=""; List pgDeviceTypeDtoList=new ArrayList(); try { pgDeviceTypeDtoList = pgDeviceTypeManager.getAllDeviceType(); if(pgDeviceTypeDtoList.size()==0) - msg="没有设备类型信息"; + msg="没有找到设备类型信息"; else - msg="设备类型获取失败"; + msg="设备类型信息获取成功"; }catch(Exception e){ e.printStackTrace(); msg="设备类型信息获取失败"; @@ -64,37 +65,39 @@ @POST @Path("addDeviceType") @Produces(MediaType.APPLICATION_JSON) - public Map addDeviceType(@FormParam("devType") String devType) + public Map addDevice(@FormParam("devType") String devType) throws Exception { Map resultMap = new HashMap(); String result = ""; String msg = ""; - try { - if (pgDeviceTypeManager.getPgDeviceTypeByDevType(devType)!=null) { - result = "false"; - msg = "已存在同名设备类型"; - } else { - PgDeviceType pgDeviceType=new PgDeviceType(); - pgDeviceType.setDevType(devType); - pgDeviceType.setActive(1); - - pgDeviceTypeManager.save(pgDeviceType); - result = "true"; - msg = "保存成功"; - } - - } catch (Exception e) { + try { + if (pgDeviceTypeManager.getDeviceTypeByDeType(devType)!=null) { result = "false"; - msg = "保存失败"; - e.printStackTrace(); + msg = "已存在设备类型"; + } else { + PgDeviceType pgDeviceType = new PgDeviceType(); + + pgDeviceType.setDevType(devType); + pgDeviceType.setActive(1); + + pgDeviceTypeManager.save(pgDeviceType); + result = "true"; + msg = "保存成功"; } + } catch (Exception e) { + result = "false"; + msg = "保存失败"; + e.printStackTrace(); + } + resultMap.put("success", result); resultMap.put("msg", msg); return resultMap; } + } diff --git a/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java b/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java index 8a42e7e..249b75c 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java @@ -13,10 +13,8 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.text.SimpleDateFormat; +import java.util.*; /** * Created by yxw on 2017/11/6. @@ -40,25 +38,35 @@ @POST @Path("addPartition") @Produces(MediaType.APPLICATION_JSON) - public Map addAlarm(@FormParam("parName") String parName)throws Exception { + public Map addAlarm(@FormParam("parName") String parName, + @FormParam("road") String road, + @FormParam("pgPosition") String pgPosition, + @FormParam("pgNum") String pgNum, + @FormParam("pgType") String pgType, + @FormParam("pgLength") String pgLength, + @FormParam("buildDate") String buildDate, + @FormParam("material") String material)throws Exception { Map resultMap = new HashMap(); String result = ""; String msg = ""; + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); try { - if (pgPartitionManager.getPartitionByParName(parName) != null) { - result = "false"; - msg = "已存在相同分区"; - } else { PgPartition pgPartition = new PgPartition(); pgPartition.setParName(parName); + pgPartition.setRoad(road); + pgPartition.setPgPosition(pgPosition); + pgPartition.setPgNum(pgNum); + pgPartition.setPgType(pgType); + pgPartition.setPgLength(pgLength); + pgPartition.setBuildDate(sdf.parse(buildDate)); + pgPartition.setMaterial(material); pgPartition.setActive(1); logger.info("成功保存"); pgPartitionManager.save(pgPartition); result = "true"; msg = "保存成功"; - } } catch (Exception e) { result = "false"; @@ -71,28 +79,40 @@ return resultMap; } - - @POST @Path("editPartition") @Produces(MediaType.APPLICATION_JSON) public Map editPartition(@FormParam("id") String id, - @FormParam("parName") String parName) throws Exception { + @FormParam("parName") String parName, + @FormParam("road") String road, + @FormParam("pgPosition") String pgPosition, + @FormParam("pgNum") String pgNum, + @FormParam("pgType") String pgType, + @FormParam("pgLength") String pgLength, + @FormParam("buildDate") String buildDate, + @FormParam("material") String material) throws Exception { Map resultMap = new HashMap(); String result = ""; String msg = ""; PgPartition partition = new PgPartition(); + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); try { - if (pgPartitionManager.getPartitionByParName(parName) != null) { result = "false"; msg = "已存在相同分区"; } else { PgPartition pgPartition = pgPartitionManager.get(Long.valueOf(id)); pgPartition.setParName(parName); + pgPartition.setRoad(road); + pgPartition.setPgPosition(pgPosition); + pgPartition.setPgNum(pgNum); + pgPartition.setPgType(pgType); + pgPartition.setPgLength(pgLength); + pgPartition.setBuildDate(sdf.parse(buildDate)); + pgPartition.setMaterial(material); pgPartition.setActive(1); pgPartitionManager.save(pgPartition); diff --git a/src/main/java/com/casic/PgInterface/rs/PgPatrolerRs.java b/src/main/java/com/casic/PgInterface/rs/PgPatrolerRs.java index aed1ed8..0b3c731 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgPatrolerRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgPatrolerRs.java @@ -123,10 +123,12 @@ String result = ""; String msg = ""; try { + /* if (pgPatrolerManager.userNameIsExits(userName)) { result = "false"; msg = "用户名已经存在!"; } else { + */ PgPatroler pgPatroler = pgPatrolerManager.get(Long.valueOf(id)); pgPatroler.setUserName(userName); pgPatroler.setPassword(password); @@ -136,7 +138,7 @@ pgPatrolerManager.save(pgPatroler); result = "true"; msg = "编辑成功"; - } + //} } catch (Exception e) { result = "false"; msg = "编辑失败"; diff --git a/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java b/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java index 8cbdb0a..4c9feac 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java @@ -165,12 +165,14 @@ msg = "不存在管廊仓和分区信息"; } else { try { + /* if(pgPipeLineManager.getPipeLineBylineName(lineName)!=null) { result = "false"; msg = "已存在同名管线"; } else { + */ PgPipeLine pgPipeLine = pgPipeLineManager.get(Long.valueOf(id)); pgPipeLine.setLineName(lineName); @@ -185,7 +187,7 @@ pgPipeLineManager.save(pgPipeLine); result = "true"; msg = "编辑成功"; - } + //} } catch (Exception e) { result = "false"; msg = "编辑失败"; diff --git a/src/main/java/com/casic/PgInterface/rs/PgReserveController.java b/src/main/java/com/casic/PgInterface/rs/PgReserveController.java new file mode 100644 index 0000000..863045a --- /dev/null +++ b/src/main/java/com/casic/PgInterface/rs/PgReserveController.java @@ -0,0 +1,207 @@ +package com.casic.PgInterface.rs; + +import com.casic.PgInterface.core.util.StringUtils; +import com.casic.PgInterface.devTable.manager.PgAlarmTypeManager; +import com.casic.PgInterface.reservePlan.domain.PgReservePlan; +import com.casic.PgInterface.reservePlan.manager.PgReservePlanManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.multipart.MultipartFile; +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.List; +import java.util.Map; + +/** + * Created by yxw on 2017/11/8. + */ +@Controller +@RequestMapping("rs/pgReservePlan") +public class PgReserveController { + + private static Logger logger = LoggerFactory.getLogger(PgReservePlan.class); + + private PgReservePlanManager pgReservePlanManager; + + private PgAlarmTypeManager pgAlarmTypeManager; + + @Resource + public void setPgReservePlanManager(PgReservePlanManager pgReservePlanManager) { + this.pgReservePlanManager = pgReservePlanManager; + } + + @Resource + public void setPgAlarmTypeManager(PgAlarmTypeManager pgAlarmTypeManager) { + this.pgAlarmTypeManager = pgAlarmTypeManager; + } + +// //新增预案文档 +// @RequestMapping("addReservePlan") +// @ResponseBody +// public Map addReservePlan(@RequestParam(value = "planName",required = true) String planName, +// @RequestParam(value = "planType",required =false) String planType, +// @RequestParam(value ="resUnit",required =false) String resUnit, +// @RequestParam(value ="alarmType",required =false) String alarmType, +// @RequestParam(value = "planFiels",required =false) List planFiels) +// throws Exception { +// Map resultMap = new HashMap(); +// PgReservePlan pgReservePlan = new PgReservePlan(); +// String result = ""; +// String msg = ""; +// +// try { +// if (planFiels.size() == 0) +// pgReservePlan.setPlanFiel(""); +// else { +// pgReservePlan.setPlanFiel(pgReservePlanManager.saveFiles(planFiels, "reservePlan")); +// } +// +// pgReservePlan.setPlanName(planName); +// pgReservePlan.setPlanType(planType); +// pgReservePlan.setResUnit(resUnit); +// pgReservePlan.setPgAlarmTypeId(pgAlarmTypeManager.getAlarmTypeByAlarmType(alarmType)); +// pgReservePlan.setActive(1); +// +// result = "true"; +// msg = "保存成功"; +// logger.info("保存成功"); +// pgReservePlanManager.save(pgReservePlan); +// } catch (Exception ex) { +// result = "false"; +// msg = "保存失败"; +// ex.printStackTrace(); +// } +// +// resultMap.put("success", result); +// resultMap.put("msg", msg); +// return resultMap; +// } + + //新增预案文档 + @POST + @Path("addReservePlan") + @Produces(MediaType.APPLICATION_JSON) + public Map addReservePlan( + @FormParam("pgName") String planName, + @FormParam("parName") String planType, + @FormParam("parName") String resUnit, + @FormParam("parName") String alarmType, + @FormParam("parName") String fileBuffer, + @FormParam("parName") String fileName)throws Exception { + Map resultMap = new HashMap(); + PgReservePlan pgReservePlan = new PgReservePlan(); + String result = ""; + String msg = ""; + + try { + if (StringUtils.isBlank(fileBuffer)||StringUtils.isBlank(fileName)) + pgReservePlan.setPlanFiel(""); + else { + pgReservePlan.setPlanFiel(pgReservePlanManager.saveFiles(fileBuffer, fileName,"reservePlan")); + } + + pgReservePlan.setPlanName(planName); + pgReservePlan.setPlanType(planType); + pgReservePlan.setResUnit(resUnit); + pgReservePlan.setPgAlarmTypeId(pgAlarmTypeManager.getAlarmTypeByAlarmType(alarmType)); + pgReservePlan.setActive(1); + + result = "true"; + msg = "保存成功"; + logger.info("保存成功"); + pgReservePlanManager.save(pgReservePlan); + } catch (Exception ex) { + result = "false"; + msg = "保存失败"; + ex.printStackTrace(); + } + + resultMap.put("success", result); + resultMap.put("msg", msg); + return resultMap; + } + + //编辑预案文档 + @RequestMapping("editReservePlan") + @ResponseBody + public Map editReservePlan(@FormParam("id") String id, + @RequestParam(value = "planName",required = true) String planName, + @RequestParam(value = "planType",required =false) String planType, + @RequestParam(value ="resUnit",required =false) String resUnit, + @RequestParam(value ="alarmType",required =false) String alarmType) throws Exception { + + Map resultMap = new HashMap(); + String result = ""; + String msg = ""; + + try { + PgReservePlan pgReservePlan = pgReservePlanManager.get(Long.valueOf(id)); + if (pgReservePlan == null) { + result = "false"; + msg = "不存在该预案信息"; + } else { + pgReservePlan.setPlanName(planName); + pgReservePlan.setPlanType(planType); + pgReservePlan.setResUnit(resUnit); + pgReservePlan.setPgAlarmTypeId(pgAlarmTypeManager.getAlarmTypeByAlarmType(alarmType)); + pgReservePlan.setActive(1); + + pgReservePlanManager.save(pgReservePlan); + result = "true"; + msg = "编辑成功"; + } + } catch (Exception e) { + result = "false"; + msg = "编辑失败"; + e.printStackTrace(); + } + return resultMap; + } + + //删除预案文档 + @RequestMapping("deleteReservePlan") + @ResponseBody + public Map deleteReservePlan(@FormParam("id") String id)throws Exception{ + Map resultMap = new HashMap(); + String msg=""; + String result="false"; + + try{ + + PgReservePlan pgReservePlan=pgReservePlanManager.get(Long.valueOf(id)); + if(pgReservePlan==null) + { + result="false"; + msg="不存在该预案信息"; + } + else{ + pgReservePlan.setActive(0); + pgReservePlanManager.save(pgReservePlan); + result="true"; + msg="删除成功"; + } + } + catch(Exception e) + { + e.printStackTrace(); + msg="预案删除失败"; + result="false"; + } + + 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/PgTextureRs.java b/src/main/java/com/casic/PgInterface/rs/PgTextureRs.java index 5892127..2360251 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgTextureRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgTextureRs.java @@ -163,12 +163,14 @@ msg = "不存在管廊仓和分区信息"; } else { try { + /* if(pgTextureManager.getPgTextureByName(textureName)!=null) { result = "false"; msg = "已存在同名的部件"; } else { + */ PgTexture pgTexture = pgTextureManager.get(Long.valueOf(id)); pgTexture.setTextureName(textureName); pgTexture.setTextureMaterial(textureMaterial); @@ -181,7 +183,7 @@ pgTextureManager.save(pgTexture); result = "true"; msg = "编辑成功"; - } + //} } catch (Exception e) { result = "false"; msg = "编辑失败"; diff --git a/src/main/java/com/casic/PgInterface/rs/PipeGalleryRs.java b/src/main/java/com/casic/PgInterface/rs/PipeGalleryRs.java index 6904b9f..42f7d40 100644 --- a/src/main/java/com/casic/PgInterface/rs/PipeGalleryRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PipeGalleryRs.java @@ -132,10 +132,12 @@ result = "false"; msg = "不存在该分区信息"; } else { + /* if (pipeGalleryManager.getPipeGalleryByPgName(pgName, pgPartition) != null) { result = "false"; msg = "已存在相同管廊"; } else { + */ pipeGallery = pipeGalleryManager.get(Long.valueOf(id)); pipeGallery.setPgName(pgName); @@ -145,7 +147,7 @@ pipeGalleryManager.save(pipeGallery); result = "true"; msg = "编辑成功"; - } + //} } } catch (Exception e) { result = "false"; diff --git a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java b/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java deleted file mode 100644 index b2affe5..0000000 --- a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.casic.PgInterface.devData.dto; - -/** - * Created by yxw on 2017/11/28. - */ -public class PgTempHunDto { -} 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 eb1f7ab..da8f617 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -39,7 +39,6 @@ private List pgShs; private List pgTempHums; - @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") public long getId() { diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java index 4278dc1..669b60f 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java @@ -2,21 +2,20 @@ import javax.persistence.*; import java.io.Serializable; -import java.util.List; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Entity @Table(name = "PG_DEVICE_TYPE") @SequenceGenerator(name = "SEQ_PG_DEVICE_TYPE_ID", sequenceName = "SEQ_PG_DEVICE_TYPE_ID", allocationSize = 1, initialValue = 1) public class PgDeviceType implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; private long id; private String devType; private int active; - private List pgDeviceList; + @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_TYPE_ID") @@ -45,13 +44,4 @@ public void setActive(int active) { this.active = active; } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "devTypeId") - public List getPgDeviceList() { - return pgDeviceList; - } - - public void setPgDeviceList(List pgDeviceList) { - this.pgDeviceList = pgDeviceList; - } } 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 4fb3d6f..d209733 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java @@ -2,6 +2,7 @@ import javax.persistence.*; import java.io.Serializable; +import java.util.Date; import java.util.List; /** @@ -17,6 +18,12 @@ private long id; private String parName;//分区名称 private String road;//所属道路 + private String pgPosition;//仓段位置 + private String pgNum;//仓位数量 + private String pgType;//仓位类型 + private String pgLength;//分区长度 + private Date buildDate;//建设年代 + private String material;//建设材质 private int active;//状态位 private List pipeGalleryList;//管廊仓 @@ -48,6 +55,60 @@ this.road = road; } + @Column(name = "PGPOSITION") + public String getPgPosition() { + return pgPosition; + } + + public void setPgPosition(String pgPosition) { + this.pgPosition = pgPosition; + } + + @Column(name = "PGNUM") + public String getPgNum() { + return pgNum; + } + + public void setPgNum(String pgNum) { + this.pgNum = pgNum; + } + + @Column(name = "PGTYPE") + public String getPgType() { + return pgType; + } + + public void setPgType(String pgType) { + this.pgType = pgType; + } + + @Column(name = "PGLENGTH") + public String getPgLength() { + return pgLength; + } + + public void setPgLength(String pgLength) { + this.pgLength = pgLength; + } + + @Column(name = "BUILDDATE") + public Date getBuildDate() { + return buildDate; + } + + public void setBuildDate(Date buildDate) { + this.buildDate = buildDate; + } + + @Column(name = "MATERIAL") + public String getMaterial() { + return material; + } + + public void setMaterial(String material) { + this.material = material; + } + @Column(name = "ACTIVE") public int getActive() { return active; 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 95f9fbd..b60c42d 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java @@ -160,7 +160,7 @@ this.setAssetName(pgDevice.getAssetName()); this.setAssetCode(pgDevice.getAssetCode()); this.setAssetBarCode(pgDevice.getAssetBarCode()); - this.setId(pgDevice.getIp()); + this.setIp(pgDevice.getIp()); this.setModBus(pgDevice.getModBus()); this.setMome(pgDevice.getMome()); this.setIsOpen(String.valueOf(pgDevice.getIsOpen())); diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java index c1548e0..e348f7a 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java @@ -5,7 +5,7 @@ import java.io.Serializable; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ public class PgDeviceTypeDto implements Serializable { @@ -37,12 +37,11 @@ this.active = active; } - public PgDeviceTypeDto(PgDeviceType pgDeviceType) - { + public PgDeviceTypeDto(PgDeviceType pgDeviceType) { + this.setId(String.valueOf(pgDeviceType.getId())); this.setDevType(pgDeviceType.getDevType()); this.setActive(String.valueOf(pgDeviceType.getActive())); } - } 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 3acd0fa..95c18b4 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java @@ -3,6 +3,7 @@ import com.casic.PgInterface.devTable.domain.PgPartition; import java.io.Serializable; +import java.text.SimpleDateFormat; /** * Created by yxw on 2017/11/2. @@ -12,6 +13,12 @@ private String id; private String parName;//分区名称 private String road;//所属道路 + private String pgPosition;//仓段位置 + private String pgNum;//仓位数量 + private String pgType;//仓位类型 + private String pgLength;//分区长度 + private String buildDate;//建设年代 + private String material;//建设材质 private String active;//状态位 @@ -47,11 +54,67 @@ this.road = road; } + public String getPgPosition() { + return pgPosition; + } + + public void setPgPosition(String pgPosition) { + this.pgPosition = pgPosition; + } + + public String getPgNum() { + return pgNum; + } + + public void setPgNum(String pgNum) { + this.pgNum = pgNum; + } + + public String getPgType() { + return pgType; + } + + public void setPgType(String pgType) { + this.pgType = pgType; + } + + public String getPgLength() { + return pgLength; + } + + public void setPgLength(String pgLength) { + this.pgLength = pgLength; + } + + public String getBuildDate() { + return buildDate; + } + + public void setBuildDate(String buildDate) { + this.buildDate = buildDate; + } + + public String getMaterial() { + return material; + } + + public void setMaterial(String material) { + this.material = material; + } + public PgPartitionDto(PgPartition pgPartition) { + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); + this.setId(String.valueOf(pgPartition.getId())); this.setParName(pgPartition.getParName()); this.setRoad(pgPartition.getRoad()); + this.setPgPosition(pgPartition.getPgPosition()); + this.setPgNum(pgPartition.getPgNum()); + this.setPgType(pgPartition.getPgType()); + this.setPgLength(pgPartition.getPgLength()); + this.setBuildDate(sdf.format(pgPartition.getBuildDate())); + this.setMaterial(pgPartition.getMaterial()); this.setActive(String.valueOf(pgPartition.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java b/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java index d7c6024..9ea43fd 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java @@ -12,10 +12,10 @@ import java.util.List; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Service -public class PgDeviceTypeManager extends HibernateEntityDao{ +public class PgDeviceTypeManager extends HibernateEntityDao { public List getAllDeviceType() { @@ -23,8 +23,8 @@ criteria.add(Restrictions.eq("active", 1)); criteria.addOrder(Order.desc("id")); - List pgDeviceTypeList= criteria.list(); - List pgDeviceTypeDtoList=new ArrayList(); + List pgDeviceTypeList = criteria.list(); + List pgDeviceTypeDtoList = new ArrayList(); for (PgDeviceType pgDeviceType : pgDeviceTypeList) { pgDeviceTypeDtoList.add(new PgDeviceTypeDto(pgDeviceType)); } @@ -32,15 +32,14 @@ return pgDeviceTypeDtoList; } - public PgDeviceType getPgDeviceTypeByDevType(String devType) - { - Criteria criteria=createCriteria(PgDeviceType.class); - criteria.add(Restrictions.eq("devType",devType)); - criteria.add(Restrictions.eq("active",1)); - criteria.addOrder(Order.desc("id")); + public PgDeviceType getDeviceTypeByDeType(String devType) { - List pgDeviceTypeList=criteria.list(); - if(pgDeviceTypeList==null||pgDeviceTypeList.size()==0) + Criteria criteria = createCriteria(PgDeviceType.class); + criteria.add(Restrictions.eq("active", 1)); + criteria.add(Restrictions.eq("devType", devType)); + + List pgDeviceTypeList = criteria.list(); + if (pgDeviceTypeList.size() == 0) return null; else return pgDeviceTypeList.get(0); 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 0c594e7..c6f22cb 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java @@ -64,4 +64,4 @@ -} +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java index 9d06235..68b14cf 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java @@ -1,9 +1,5 @@ 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; @@ -19,7 +15,8 @@ private long id; private String highValue;//高限 private String lowValue;//低限 - private PgDevice pgDeviceId;//设备 + private String unit;//单位 + private String devType;//设备类型 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_ALARM_RULE_ID") @@ -49,15 +46,24 @@ this.lowValue = lowValue; } - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PGDEVICEID") - public PgDevice getPgDeviceId() { - return pgDeviceId; + @Column(name="UNIT") + public String getUnit() { + return unit; } - public void setPgDeviceId(PgDevice pgDeviceId) { - this.pgDeviceId = pgDeviceId; + public void setUnit(String unit) { + this.unit = unit; } + @Column(name = "DEVTYPE") + public String getDevType() { + return devType; + } + + public void setDevType(String devType) { + this.devType = devType; + } + + + } diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java deleted file mode 100644 index 7907e66..0000000 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.casic.PgInterface.patroler.dto; - -/** - * Created by yxw on 2017/12/14. - */ -public class PgAlarmRule { -} diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java index 8367ad4..0782c63 100644 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java @@ -12,7 +12,8 @@ private String id; private String highValue;//高限 private String lowValue;//低限 - private String devName;//设备 + private String devType;//设备类型 + private String unit;//单位 public String getId() { return id; @@ -38,20 +39,29 @@ this.lowValue = lowValue; } - public String getDevName() { - return devName; + public String getDevType() { + return devType; } - public void setDevName(String devName) { - this.devName = devName; + public void setDevType(String devType) { + this.devType = devType; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; } public PgAlarmRuleDto(PgAlarmRule pgAlarmRule) { this.setId(String.valueOf(pgAlarmRule.getId())); - this.setDevName(pgAlarmRule.getPgDeviceId().getAssetName()); this.setHighValue(pgAlarmRule.getHighValue()); this.setLowValue(pgAlarmRule.getLowValue()); + this.setDevType(pgAlarmRule.getDevType()); + this.setUnit(pgAlarmRule.getUnit()); } } diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java index d5c00b2..84e5cdd 100644 --- a/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java @@ -1,13 +1,13 @@ 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.ArrayList; import java.util.List; /** @@ -17,20 +17,21 @@ public class PgAlarmRuleManager extends HibernateEntityDao { //根据设备获取设备报警阈值 - public PgAlarmRuleDto getAlarmRuleDtoBydev(PgDevice pgDeviceId) { + public List getAlarmRuleDto() { 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)); + List pgAlarmRuleDtoList = new ArrayList(); + for (PgAlarmRule pgAlarmRule : pgAlarmRuleList) { + pgAlarmRuleDtoList.add(new PgAlarmRuleDto(pgAlarmRule)); + } + return pgAlarmRuleDtoList; + } - public PgAlarmRule getAlarmRuleBydev(PgDevice pgDeviceId) { + public PgAlarmRule getAlarmRuleBydevType(String devType) { Criteria criteria=createCriteria(PgAlarmRule.class); - criteria.add(Restrictions.eq("pgDeviceId", pgDeviceId)); + criteria.add(Restrictions.eq("devType", devType)); List pgAlarmRuleList=criteria.list(); if(pgAlarmRuleList.size()==0) diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java index f4e48c6..9396013 100644 --- a/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java @@ -39,13 +39,13 @@ } if (StringUtils.isNotBlank(startTime)) { - criteria.add(Restrictions.ge("operateTime", DateUtils.sdf4.parse(startTime))); + criteria.add(Restrictions.ge("operateTime", DateUtils.sdf_day.parse(startTime))); } if (StringUtils.isNotBlank(endTime)) { Calendar calendar = Calendar.getInstance(); - calendar.setTime(DateUtils.sdf4.parse(endTime)); + calendar.setTime(DateUtils.sdf_day.parse(endTime)); calendar.add(Calendar.DATE, 1); - criteria.add(Restrictions.le("time", calendar.getTime())); + criteria.add(Restrictions.le("operateTime", calendar.getTime())); } criteria.add(Restrictions.eq("active", 1)); diff --git a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java index 88255c6..f28ebdf 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java @@ -1,6 +1,5 @@ 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; @@ -15,7 +14,9 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -42,72 +43,43 @@ } /** - * 获取报警阈值信息 - */ - @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 { + public Map addAlarmRule(@FormParam("highValue") String highValue, + @FormParam("lowValue") String lowValue, + @FormParam("unit") String unit, + @FormParam("devType") String devType) 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(); + try { + pgAlarmRule = pgAlarmRuleManager.getAlarmRuleBydevType(devType); + if (pgAlarmRule != null) { result = "false"; - msg = "报警阈值新增失败"; + msg = "设备阈值已经存在"; + } else { + pgAlarmRule = new PgAlarmRule(); + pgAlarmRule.setHighValue(highValue); + pgAlarmRule.setLowValue(lowValue); + pgAlarmRule.setDevType(devType); + pgAlarmRule.setUnit(unit); + + pgAlarmRuleManager.save(pgAlarmRule); + result = "true"; + msg = "报警阈值新增成功"; } + } catch (Exception e) { + e.printStackTrace(); + result = "false"; + msg = "报警阈值新增失败"; } + resultMap.put("msg", msg); resultMap.put("result", result); return resultMap; @@ -119,44 +91,66 @@ @POST @Path("editAlarmRule") @Produces(MediaType.APPLICATION_JSON) - public Map editAlarmRule(@FormParam("id") String id, - @FormParam("assetCode") String assetCode, + public Map editAlarmRule(@FormParam("devType") String devType, @FormParam("highValue") String highValue, - @FormParam("lowValue") String lowValue) throws Exception { + @FormParam("lowValue") String lowValue, + @FormParam("unit") String unit) 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(); + + try { + pgAlarmRule = pgAlarmRuleManager.getAlarmRuleBydevType(devType); + if (pgAlarmRule == null) { + msg = "不存在报警阈值记录"; result = "false"; - msg = "报警阈值编辑失败"; + } else { + pgAlarmRule.setDevType(devType); + pgAlarmRule.setHighValue(highValue); + pgAlarmRule.setLowValue(lowValue); + pgAlarmRule.setUnit(unit); + pgAlarmRuleManager.save(pgAlarmRule); + msg = "编辑成功"; + result = "true"; } + } catch (Exception ex) { + ex.printStackTrace(); + result = "false"; + msg = "报警阈值编辑失败"; } + resultMap.put("msg", msg); resultMap.put("result", result); return resultMap; + } + /** + * 获取报警阈值信息 + */ + @POST + @Path("getAlarmRule") + @Produces(MediaType.APPLICATION_JSON) + public Map getAlarmRule() throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + + List pgAlarmRuleDtoList = new ArrayList(); + try { + pgAlarmRuleDtoList = pgAlarmRuleManager.getAlarmRuleDto(); + if (pgAlarmRuleDtoList == null) + msg = "不存在报警阈值信息"; + else + msg = "报警阈值获取成功"; + } catch (Exception e) { + e.printStackTrace(); + msg = "报警信息获取失败"; + } + resultMap.put("msg", msg); + resultMap.put("result", pgAlarmRuleDtoList); + 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 bb8c245..36547a7 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java @@ -104,8 +104,8 @@ @POST @Path("addDevice") @Produces(MediaType.APPLICATION_JSON) - public Map addDevice(@FormParam("parName") String parName, - @FormParam("pgName") String pgName, + public Map addDevice(@FormParam("partition") String partition, + @FormParam("pipeGallery") String pipeGallery, @FormParam("road") String road, @FormParam("position") String position, @FormParam("devType") String devType, @@ -129,8 +129,8 @@ } else { PgDevice pgDevice = new PgDevice(); - pgDevice.setPipeGallery(pgName); - pgDevice.setPartition(parName); + pgDevice.setPipeGallery(pipeGallery); + pgDevice.setPartition(partition); pgDevice.setRoad(road); pgDevice.setPosition(position); pgDevice.setDevType(devType); @@ -168,8 +168,8 @@ @Path("editDevice") @Produces(MediaType.APPLICATION_JSON) public Map editPartition(@FormParam("id") String id, - @FormParam("parName") String parName, - @FormParam("pgName") String pgName, + @FormParam("partition") String partition, + @FormParam("pipeGallery") String pipeGallery, @FormParam("road") String road, @FormParam("position") String position, @FormParam("devType") String devType, @@ -187,13 +187,15 @@ String msg = ""; try { + /* if (pgDeviceManager.getDeviceByAssetCode(assetCode)!=null) { result = "false"; msg = "已存在同名设备"; } else { + */ PgDevice pgDevice = pgDeviceManager.get(Long.valueOf(id)); - pgDevice.setPipeGallery(pgName); - pgDevice.setPartition(parName); + pgDevice.setPipeGallery(pipeGallery); + pgDevice.setPartition(partition); pgDevice.setRoad(road); pgDevice.setPosition(position); pgDevice.setDevType(devType); @@ -210,7 +212,7 @@ pgDeviceManager.save(pgDevice); result = "true"; msg = "编辑成功"; - } + //} } catch (Exception e) { result = "false"; msg = "编辑失败"; diff --git a/src/main/java/com/casic/PgInterface/rs/PgDeviceTypeRs.java b/src/main/java/com/casic/PgInterface/rs/PgDeviceTypeRs.java index 756894f..b6c84aa 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgDeviceTypeRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgDeviceTypeRs.java @@ -19,12 +19,13 @@ import java.util.Map; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Component @Path("pgDeviceType") public class PgDeviceTypeRs { - private static Logger logger = LoggerFactory.getLogger(PgDeviceRs.class); + + private static Logger logger = LoggerFactory.getLogger(PgDeviceTypeRs.class); private PgDeviceTypeManager pgDeviceTypeManager; @@ -34,21 +35,21 @@ } /** - * 获取设备类型 + * 显示设备列表 */ @POST @Path("getDeviceType") @Produces(MediaType.APPLICATION_JSON) - public Map getDeviceType()throws Exception { + public Map getDeviceTpeyList()throws Exception { Map resultMap = new HashMap(); String msg=""; List pgDeviceTypeDtoList=new ArrayList(); try { pgDeviceTypeDtoList = pgDeviceTypeManager.getAllDeviceType(); if(pgDeviceTypeDtoList.size()==0) - msg="没有设备类型信息"; + msg="没有找到设备类型信息"; else - msg="设备类型获取失败"; + msg="设备类型信息获取成功"; }catch(Exception e){ e.printStackTrace(); msg="设备类型信息获取失败"; @@ -64,37 +65,39 @@ @POST @Path("addDeviceType") @Produces(MediaType.APPLICATION_JSON) - public Map addDeviceType(@FormParam("devType") String devType) + public Map addDevice(@FormParam("devType") String devType) throws Exception { Map resultMap = new HashMap(); String result = ""; String msg = ""; - try { - if (pgDeviceTypeManager.getPgDeviceTypeByDevType(devType)!=null) { - result = "false"; - msg = "已存在同名设备类型"; - } else { - PgDeviceType pgDeviceType=new PgDeviceType(); - pgDeviceType.setDevType(devType); - pgDeviceType.setActive(1); - - pgDeviceTypeManager.save(pgDeviceType); - result = "true"; - msg = "保存成功"; - } - - } catch (Exception e) { + try { + if (pgDeviceTypeManager.getDeviceTypeByDeType(devType)!=null) { result = "false"; - msg = "保存失败"; - e.printStackTrace(); + msg = "已存在设备类型"; + } else { + PgDeviceType pgDeviceType = new PgDeviceType(); + + pgDeviceType.setDevType(devType); + pgDeviceType.setActive(1); + + pgDeviceTypeManager.save(pgDeviceType); + result = "true"; + msg = "保存成功"; } + } catch (Exception e) { + result = "false"; + msg = "保存失败"; + e.printStackTrace(); + } + resultMap.put("success", result); resultMap.put("msg", msg); return resultMap; } + } diff --git a/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java b/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java index 8a42e7e..249b75c 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java @@ -13,10 +13,8 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.text.SimpleDateFormat; +import java.util.*; /** * Created by yxw on 2017/11/6. @@ -40,25 +38,35 @@ @POST @Path("addPartition") @Produces(MediaType.APPLICATION_JSON) - public Map addAlarm(@FormParam("parName") String parName)throws Exception { + public Map addAlarm(@FormParam("parName") String parName, + @FormParam("road") String road, + @FormParam("pgPosition") String pgPosition, + @FormParam("pgNum") String pgNum, + @FormParam("pgType") String pgType, + @FormParam("pgLength") String pgLength, + @FormParam("buildDate") String buildDate, + @FormParam("material") String material)throws Exception { Map resultMap = new HashMap(); String result = ""; String msg = ""; + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); try { - if (pgPartitionManager.getPartitionByParName(parName) != null) { - result = "false"; - msg = "已存在相同分区"; - } else { PgPartition pgPartition = new PgPartition(); pgPartition.setParName(parName); + pgPartition.setRoad(road); + pgPartition.setPgPosition(pgPosition); + pgPartition.setPgNum(pgNum); + pgPartition.setPgType(pgType); + pgPartition.setPgLength(pgLength); + pgPartition.setBuildDate(sdf.parse(buildDate)); + pgPartition.setMaterial(material); pgPartition.setActive(1); logger.info("成功保存"); pgPartitionManager.save(pgPartition); result = "true"; msg = "保存成功"; - } } catch (Exception e) { result = "false"; @@ -71,28 +79,40 @@ return resultMap; } - - @POST @Path("editPartition") @Produces(MediaType.APPLICATION_JSON) public Map editPartition(@FormParam("id") String id, - @FormParam("parName") String parName) throws Exception { + @FormParam("parName") String parName, + @FormParam("road") String road, + @FormParam("pgPosition") String pgPosition, + @FormParam("pgNum") String pgNum, + @FormParam("pgType") String pgType, + @FormParam("pgLength") String pgLength, + @FormParam("buildDate") String buildDate, + @FormParam("material") String material) throws Exception { Map resultMap = new HashMap(); String result = ""; String msg = ""; PgPartition partition = new PgPartition(); + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); try { - if (pgPartitionManager.getPartitionByParName(parName) != null) { result = "false"; msg = "已存在相同分区"; } else { PgPartition pgPartition = pgPartitionManager.get(Long.valueOf(id)); pgPartition.setParName(parName); + pgPartition.setRoad(road); + pgPartition.setPgPosition(pgPosition); + pgPartition.setPgNum(pgNum); + pgPartition.setPgType(pgType); + pgPartition.setPgLength(pgLength); + pgPartition.setBuildDate(sdf.parse(buildDate)); + pgPartition.setMaterial(material); pgPartition.setActive(1); pgPartitionManager.save(pgPartition); diff --git a/src/main/java/com/casic/PgInterface/rs/PgPatrolerRs.java b/src/main/java/com/casic/PgInterface/rs/PgPatrolerRs.java index aed1ed8..0b3c731 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgPatrolerRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgPatrolerRs.java @@ -123,10 +123,12 @@ String result = ""; String msg = ""; try { + /* if (pgPatrolerManager.userNameIsExits(userName)) { result = "false"; msg = "用户名已经存在!"; } else { + */ PgPatroler pgPatroler = pgPatrolerManager.get(Long.valueOf(id)); pgPatroler.setUserName(userName); pgPatroler.setPassword(password); @@ -136,7 +138,7 @@ pgPatrolerManager.save(pgPatroler); result = "true"; msg = "编辑成功"; - } + //} } catch (Exception e) { result = "false"; msg = "编辑失败"; diff --git a/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java b/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java index 8cbdb0a..4c9feac 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java @@ -165,12 +165,14 @@ msg = "不存在管廊仓和分区信息"; } else { try { + /* if(pgPipeLineManager.getPipeLineBylineName(lineName)!=null) { result = "false"; msg = "已存在同名管线"; } else { + */ PgPipeLine pgPipeLine = pgPipeLineManager.get(Long.valueOf(id)); pgPipeLine.setLineName(lineName); @@ -185,7 +187,7 @@ pgPipeLineManager.save(pgPipeLine); result = "true"; msg = "编辑成功"; - } + //} } catch (Exception e) { result = "false"; msg = "编辑失败"; diff --git a/src/main/java/com/casic/PgInterface/rs/PgReserveController.java b/src/main/java/com/casic/PgInterface/rs/PgReserveController.java new file mode 100644 index 0000000..863045a --- /dev/null +++ b/src/main/java/com/casic/PgInterface/rs/PgReserveController.java @@ -0,0 +1,207 @@ +package com.casic.PgInterface.rs; + +import com.casic.PgInterface.core.util.StringUtils; +import com.casic.PgInterface.devTable.manager.PgAlarmTypeManager; +import com.casic.PgInterface.reservePlan.domain.PgReservePlan; +import com.casic.PgInterface.reservePlan.manager.PgReservePlanManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.multipart.MultipartFile; +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.List; +import java.util.Map; + +/** + * Created by yxw on 2017/11/8. + */ +@Controller +@RequestMapping("rs/pgReservePlan") +public class PgReserveController { + + private static Logger logger = LoggerFactory.getLogger(PgReservePlan.class); + + private PgReservePlanManager pgReservePlanManager; + + private PgAlarmTypeManager pgAlarmTypeManager; + + @Resource + public void setPgReservePlanManager(PgReservePlanManager pgReservePlanManager) { + this.pgReservePlanManager = pgReservePlanManager; + } + + @Resource + public void setPgAlarmTypeManager(PgAlarmTypeManager pgAlarmTypeManager) { + this.pgAlarmTypeManager = pgAlarmTypeManager; + } + +// //新增预案文档 +// @RequestMapping("addReservePlan") +// @ResponseBody +// public Map addReservePlan(@RequestParam(value = "planName",required = true) String planName, +// @RequestParam(value = "planType",required =false) String planType, +// @RequestParam(value ="resUnit",required =false) String resUnit, +// @RequestParam(value ="alarmType",required =false) String alarmType, +// @RequestParam(value = "planFiels",required =false) List planFiels) +// throws Exception { +// Map resultMap = new HashMap(); +// PgReservePlan pgReservePlan = new PgReservePlan(); +// String result = ""; +// String msg = ""; +// +// try { +// if (planFiels.size() == 0) +// pgReservePlan.setPlanFiel(""); +// else { +// pgReservePlan.setPlanFiel(pgReservePlanManager.saveFiles(planFiels, "reservePlan")); +// } +// +// pgReservePlan.setPlanName(planName); +// pgReservePlan.setPlanType(planType); +// pgReservePlan.setResUnit(resUnit); +// pgReservePlan.setPgAlarmTypeId(pgAlarmTypeManager.getAlarmTypeByAlarmType(alarmType)); +// pgReservePlan.setActive(1); +// +// result = "true"; +// msg = "保存成功"; +// logger.info("保存成功"); +// pgReservePlanManager.save(pgReservePlan); +// } catch (Exception ex) { +// result = "false"; +// msg = "保存失败"; +// ex.printStackTrace(); +// } +// +// resultMap.put("success", result); +// resultMap.put("msg", msg); +// return resultMap; +// } + + //新增预案文档 + @POST + @Path("addReservePlan") + @Produces(MediaType.APPLICATION_JSON) + public Map addReservePlan( + @FormParam("pgName") String planName, + @FormParam("parName") String planType, + @FormParam("parName") String resUnit, + @FormParam("parName") String alarmType, + @FormParam("parName") String fileBuffer, + @FormParam("parName") String fileName)throws Exception { + Map resultMap = new HashMap(); + PgReservePlan pgReservePlan = new PgReservePlan(); + String result = ""; + String msg = ""; + + try { + if (StringUtils.isBlank(fileBuffer)||StringUtils.isBlank(fileName)) + pgReservePlan.setPlanFiel(""); + else { + pgReservePlan.setPlanFiel(pgReservePlanManager.saveFiles(fileBuffer, fileName,"reservePlan")); + } + + pgReservePlan.setPlanName(planName); + pgReservePlan.setPlanType(planType); + pgReservePlan.setResUnit(resUnit); + pgReservePlan.setPgAlarmTypeId(pgAlarmTypeManager.getAlarmTypeByAlarmType(alarmType)); + pgReservePlan.setActive(1); + + result = "true"; + msg = "保存成功"; + logger.info("保存成功"); + pgReservePlanManager.save(pgReservePlan); + } catch (Exception ex) { + result = "false"; + msg = "保存失败"; + ex.printStackTrace(); + } + + resultMap.put("success", result); + resultMap.put("msg", msg); + return resultMap; + } + + //编辑预案文档 + @RequestMapping("editReservePlan") + @ResponseBody + public Map editReservePlan(@FormParam("id") String id, + @RequestParam(value = "planName",required = true) String planName, + @RequestParam(value = "planType",required =false) String planType, + @RequestParam(value ="resUnit",required =false) String resUnit, + @RequestParam(value ="alarmType",required =false) String alarmType) throws Exception { + + Map resultMap = new HashMap(); + String result = ""; + String msg = ""; + + try { + PgReservePlan pgReservePlan = pgReservePlanManager.get(Long.valueOf(id)); + if (pgReservePlan == null) { + result = "false"; + msg = "不存在该预案信息"; + } else { + pgReservePlan.setPlanName(planName); + pgReservePlan.setPlanType(planType); + pgReservePlan.setResUnit(resUnit); + pgReservePlan.setPgAlarmTypeId(pgAlarmTypeManager.getAlarmTypeByAlarmType(alarmType)); + pgReservePlan.setActive(1); + + pgReservePlanManager.save(pgReservePlan); + result = "true"; + msg = "编辑成功"; + } + } catch (Exception e) { + result = "false"; + msg = "编辑失败"; + e.printStackTrace(); + } + return resultMap; + } + + //删除预案文档 + @RequestMapping("deleteReservePlan") + @ResponseBody + public Map deleteReservePlan(@FormParam("id") String id)throws Exception{ + Map resultMap = new HashMap(); + String msg=""; + String result="false"; + + try{ + + PgReservePlan pgReservePlan=pgReservePlanManager.get(Long.valueOf(id)); + if(pgReservePlan==null) + { + result="false"; + msg="不存在该预案信息"; + } + else{ + pgReservePlan.setActive(0); + pgReservePlanManager.save(pgReservePlan); + result="true"; + msg="删除成功"; + } + } + catch(Exception e) + { + e.printStackTrace(); + msg="预案删除失败"; + result="false"; + } + + 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/PgTextureRs.java b/src/main/java/com/casic/PgInterface/rs/PgTextureRs.java index 5892127..2360251 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgTextureRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgTextureRs.java @@ -163,12 +163,14 @@ msg = "不存在管廊仓和分区信息"; } else { try { + /* if(pgTextureManager.getPgTextureByName(textureName)!=null) { result = "false"; msg = "已存在同名的部件"; } else { + */ PgTexture pgTexture = pgTextureManager.get(Long.valueOf(id)); pgTexture.setTextureName(textureName); pgTexture.setTextureMaterial(textureMaterial); @@ -181,7 +183,7 @@ pgTextureManager.save(pgTexture); result = "true"; msg = "编辑成功"; - } + //} } catch (Exception e) { result = "false"; msg = "编辑失败"; diff --git a/src/main/java/com/casic/PgInterface/rs/PipeGalleryRs.java b/src/main/java/com/casic/PgInterface/rs/PipeGalleryRs.java index 6904b9f..42f7d40 100644 --- a/src/main/java/com/casic/PgInterface/rs/PipeGalleryRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PipeGalleryRs.java @@ -132,10 +132,12 @@ result = "false"; msg = "不存在该分区信息"; } else { + /* if (pipeGalleryManager.getPipeGalleryByPgName(pgName, pgPartition) != null) { result = "false"; msg = "已存在相同管廊"; } else { + */ pipeGallery = pipeGalleryManager.get(Long.valueOf(id)); pipeGallery.setPgName(pgName); @@ -145,7 +147,7 @@ pipeGalleryManager.save(pipeGallery); result = "true"; msg = "编辑成功"; - } + //} } } catch (Exception e) { result = "false"; diff --git a/src/main/java/com/casic/PgInterface/rsFiles/web/PgReserveController.java b/src/main/java/com/casic/PgInterface/rsFiles/web/PgReserveController.java deleted file mode 100644 index f13dac6..0000000 --- a/src/main/java/com/casic/PgInterface/rsFiles/web/PgReserveController.java +++ /dev/null @@ -1,158 +0,0 @@ -package com.casic.PgInterface.rsFiles.web; - -import com.casic.PgInterface.devTable.manager.PgAlarmTypeManager; -import com.casic.PgInterface.reservePlan.domain.PgReservePlan; -import com.casic.PgInterface.reservePlan.manager.PgReservePlanManager; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.multipart.MultipartFile; -import javax.annotation.Resource; -import javax.ws.rs.FormParam; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * Created by yxw on 2017/11/8. - */ -@Controller -@RequestMapping("rs/pgReservePlan") -public class PgReserveController { - - private static Logger logger = LoggerFactory.getLogger(PgReservePlan.class); - - private PgReservePlanManager pgReservePlanManager; - - private PgAlarmTypeManager pgAlarmTypeManager; - - @Resource - public void setPgReservePlanManager(PgReservePlanManager pgReservePlanManager) { - this.pgReservePlanManager = pgReservePlanManager; - } - - @Resource - public void setPgAlarmTypeManager(PgAlarmTypeManager pgAlarmTypeManager) { - this.pgAlarmTypeManager = pgAlarmTypeManager; - } - - //新增预案文档 - @RequestMapping("addReservePlan") - @ResponseBody - public Map addReservePlan(@RequestParam(value = "planName",required = true) String planName, - @RequestParam(value = "planType",required =false) String planType, - @RequestParam(value ="resUnit",required =false) String resUnit, - @RequestParam(value ="alarmType",required =false) String alarmType, - @RequestParam(value = "planFiels",required =false) List planFiels) - throws Exception { - Map resultMap = new HashMap(); - PgReservePlan pgReservePlan = new PgReservePlan(); - String result = ""; - String msg = ""; - - try { - if (planFiels.size() == 0) - pgReservePlan.setPlanFiel(""); - else { - pgReservePlan.setPlanFiel(pgReservePlanManager.saveFiles(planFiels, "reservePlan")); - } - - pgReservePlan.setPlanName(planName); - pgReservePlan.setPlanType(planType); - pgReservePlan.setResUnit(resUnit); - pgReservePlan.setPgAlarmTypeId(pgAlarmTypeManager.getAlarmTypeByAlarmType(alarmType)); - pgReservePlan.setActive(1); - - result = "true"; - msg = "保存成功"; - logger.info("保存成功"); - pgReservePlanManager.save(pgReservePlan); - } catch (Exception ex) { - result = "false"; - msg = "保存失败"; - ex.printStackTrace(); - } - - resultMap.put("success", result); - resultMap.put("msg", msg); - return resultMap; - } - - //编辑预案文档 - @RequestMapping("editReservePlan") - @ResponseBody - public Map editReservePlan(@FormParam("id") String id, - @RequestParam(value = "planName",required = true) String planName, - @RequestParam(value = "planType",required =false) String planType, - @RequestParam(value ="resUnit",required =false) String resUnit, - @RequestParam(value ="alarmType",required =false) String alarmType) throws Exception { - - Map resultMap = new HashMap(); - String result = ""; - String msg = ""; - - try { - PgReservePlan pgReservePlan = pgReservePlanManager.get(Long.valueOf(id)); - if (pgReservePlan == null) { - result = "false"; - msg = "不存在该预案信息"; - } else { - pgReservePlan.setPlanName(planName); - pgReservePlan.setPlanType(planType); - pgReservePlan.setResUnit(resUnit); - pgReservePlan.setPgAlarmTypeId(pgAlarmTypeManager.getAlarmTypeByAlarmType(alarmType)); - pgReservePlan.setActive(1); - - pgReservePlanManager.save(pgReservePlan); - result = "true"; - msg = "编辑成功"; - } - } catch (Exception e) { - result = "false"; - msg = "编辑失败"; - e.printStackTrace(); - } - return resultMap; - } - - //删除预案文档 - @RequestMapping("deleteReservePlan") - @ResponseBody - public Map deleteReservePlan(@FormParam("id") String id)throws Exception{ - Map resultMap = new HashMap(); - String msg=""; - String result="false"; - - try{ - - PgReservePlan pgReservePlan=pgReservePlanManager.get(Long.valueOf(id)); - if(pgReservePlan==null) - { - result="false"; - msg="不存在该预案信息"; - } - else{ - pgReservePlan.setActive(0); - pgReservePlanManager.save(pgReservePlan); - result="true"; - msg="删除成功"; - } - } - catch(Exception e) - { - e.printStackTrace(); - msg="预案删除失败"; - result="false"; - } - - 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/dto/PgTempHunDto.java b/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java deleted file mode 100644 index b2affe5..0000000 --- a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.casic.PgInterface.devData.dto; - -/** - * Created by yxw on 2017/11/28. - */ -public class PgTempHunDto { -} 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 eb1f7ab..da8f617 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -39,7 +39,6 @@ private List pgShs; private List pgTempHums; - @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") public long getId() { diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java index 4278dc1..669b60f 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java @@ -2,21 +2,20 @@ import javax.persistence.*; import java.io.Serializable; -import java.util.List; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Entity @Table(name = "PG_DEVICE_TYPE") @SequenceGenerator(name = "SEQ_PG_DEVICE_TYPE_ID", sequenceName = "SEQ_PG_DEVICE_TYPE_ID", allocationSize = 1, initialValue = 1) public class PgDeviceType implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; private long id; private String devType; private int active; - private List pgDeviceList; + @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_TYPE_ID") @@ -45,13 +44,4 @@ public void setActive(int active) { this.active = active; } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "devTypeId") - public List getPgDeviceList() { - return pgDeviceList; - } - - public void setPgDeviceList(List pgDeviceList) { - this.pgDeviceList = pgDeviceList; - } } 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 4fb3d6f..d209733 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java @@ -2,6 +2,7 @@ import javax.persistence.*; import java.io.Serializable; +import java.util.Date; import java.util.List; /** @@ -17,6 +18,12 @@ private long id; private String parName;//分区名称 private String road;//所属道路 + private String pgPosition;//仓段位置 + private String pgNum;//仓位数量 + private String pgType;//仓位类型 + private String pgLength;//分区长度 + private Date buildDate;//建设年代 + private String material;//建设材质 private int active;//状态位 private List pipeGalleryList;//管廊仓 @@ -48,6 +55,60 @@ this.road = road; } + @Column(name = "PGPOSITION") + public String getPgPosition() { + return pgPosition; + } + + public void setPgPosition(String pgPosition) { + this.pgPosition = pgPosition; + } + + @Column(name = "PGNUM") + public String getPgNum() { + return pgNum; + } + + public void setPgNum(String pgNum) { + this.pgNum = pgNum; + } + + @Column(name = "PGTYPE") + public String getPgType() { + return pgType; + } + + public void setPgType(String pgType) { + this.pgType = pgType; + } + + @Column(name = "PGLENGTH") + public String getPgLength() { + return pgLength; + } + + public void setPgLength(String pgLength) { + this.pgLength = pgLength; + } + + @Column(name = "BUILDDATE") + public Date getBuildDate() { + return buildDate; + } + + public void setBuildDate(Date buildDate) { + this.buildDate = buildDate; + } + + @Column(name = "MATERIAL") + public String getMaterial() { + return material; + } + + public void setMaterial(String material) { + this.material = material; + } + @Column(name = "ACTIVE") public int getActive() { return active; 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 95f9fbd..b60c42d 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java @@ -160,7 +160,7 @@ this.setAssetName(pgDevice.getAssetName()); this.setAssetCode(pgDevice.getAssetCode()); this.setAssetBarCode(pgDevice.getAssetBarCode()); - this.setId(pgDevice.getIp()); + this.setIp(pgDevice.getIp()); this.setModBus(pgDevice.getModBus()); this.setMome(pgDevice.getMome()); this.setIsOpen(String.valueOf(pgDevice.getIsOpen())); diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java index c1548e0..e348f7a 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java @@ -5,7 +5,7 @@ import java.io.Serializable; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ public class PgDeviceTypeDto implements Serializable { @@ -37,12 +37,11 @@ this.active = active; } - public PgDeviceTypeDto(PgDeviceType pgDeviceType) - { + public PgDeviceTypeDto(PgDeviceType pgDeviceType) { + this.setId(String.valueOf(pgDeviceType.getId())); this.setDevType(pgDeviceType.getDevType()); this.setActive(String.valueOf(pgDeviceType.getActive())); } - } 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 3acd0fa..95c18b4 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java @@ -3,6 +3,7 @@ import com.casic.PgInterface.devTable.domain.PgPartition; import java.io.Serializable; +import java.text.SimpleDateFormat; /** * Created by yxw on 2017/11/2. @@ -12,6 +13,12 @@ private String id; private String parName;//分区名称 private String road;//所属道路 + private String pgPosition;//仓段位置 + private String pgNum;//仓位数量 + private String pgType;//仓位类型 + private String pgLength;//分区长度 + private String buildDate;//建设年代 + private String material;//建设材质 private String active;//状态位 @@ -47,11 +54,67 @@ this.road = road; } + public String getPgPosition() { + return pgPosition; + } + + public void setPgPosition(String pgPosition) { + this.pgPosition = pgPosition; + } + + public String getPgNum() { + return pgNum; + } + + public void setPgNum(String pgNum) { + this.pgNum = pgNum; + } + + public String getPgType() { + return pgType; + } + + public void setPgType(String pgType) { + this.pgType = pgType; + } + + public String getPgLength() { + return pgLength; + } + + public void setPgLength(String pgLength) { + this.pgLength = pgLength; + } + + public String getBuildDate() { + return buildDate; + } + + public void setBuildDate(String buildDate) { + this.buildDate = buildDate; + } + + public String getMaterial() { + return material; + } + + public void setMaterial(String material) { + this.material = material; + } + public PgPartitionDto(PgPartition pgPartition) { + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); + this.setId(String.valueOf(pgPartition.getId())); this.setParName(pgPartition.getParName()); this.setRoad(pgPartition.getRoad()); + this.setPgPosition(pgPartition.getPgPosition()); + this.setPgNum(pgPartition.getPgNum()); + this.setPgType(pgPartition.getPgType()); + this.setPgLength(pgPartition.getPgLength()); + this.setBuildDate(sdf.format(pgPartition.getBuildDate())); + this.setMaterial(pgPartition.getMaterial()); this.setActive(String.valueOf(pgPartition.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java b/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java index d7c6024..9ea43fd 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java @@ -12,10 +12,10 @@ import java.util.List; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Service -public class PgDeviceTypeManager extends HibernateEntityDao{ +public class PgDeviceTypeManager extends HibernateEntityDao { public List getAllDeviceType() { @@ -23,8 +23,8 @@ criteria.add(Restrictions.eq("active", 1)); criteria.addOrder(Order.desc("id")); - List pgDeviceTypeList= criteria.list(); - List pgDeviceTypeDtoList=new ArrayList(); + List pgDeviceTypeList = criteria.list(); + List pgDeviceTypeDtoList = new ArrayList(); for (PgDeviceType pgDeviceType : pgDeviceTypeList) { pgDeviceTypeDtoList.add(new PgDeviceTypeDto(pgDeviceType)); } @@ -32,15 +32,14 @@ return pgDeviceTypeDtoList; } - public PgDeviceType getPgDeviceTypeByDevType(String devType) - { - Criteria criteria=createCriteria(PgDeviceType.class); - criteria.add(Restrictions.eq("devType",devType)); - criteria.add(Restrictions.eq("active",1)); - criteria.addOrder(Order.desc("id")); + public PgDeviceType getDeviceTypeByDeType(String devType) { - List pgDeviceTypeList=criteria.list(); - if(pgDeviceTypeList==null||pgDeviceTypeList.size()==0) + Criteria criteria = createCriteria(PgDeviceType.class); + criteria.add(Restrictions.eq("active", 1)); + criteria.add(Restrictions.eq("devType", devType)); + + List pgDeviceTypeList = criteria.list(); + if (pgDeviceTypeList.size() == 0) return null; else return pgDeviceTypeList.get(0); 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 0c594e7..c6f22cb 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java @@ -64,4 +64,4 @@ -} +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java index 9d06235..68b14cf 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java @@ -1,9 +1,5 @@ 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; @@ -19,7 +15,8 @@ private long id; private String highValue;//高限 private String lowValue;//低限 - private PgDevice pgDeviceId;//设备 + private String unit;//单位 + private String devType;//设备类型 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_ALARM_RULE_ID") @@ -49,15 +46,24 @@ this.lowValue = lowValue; } - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PGDEVICEID") - public PgDevice getPgDeviceId() { - return pgDeviceId; + @Column(name="UNIT") + public String getUnit() { + return unit; } - public void setPgDeviceId(PgDevice pgDeviceId) { - this.pgDeviceId = pgDeviceId; + public void setUnit(String unit) { + this.unit = unit; } + @Column(name = "DEVTYPE") + public String getDevType() { + return devType; + } + + public void setDevType(String devType) { + this.devType = devType; + } + + + } diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java deleted file mode 100644 index 7907e66..0000000 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.casic.PgInterface.patroler.dto; - -/** - * Created by yxw on 2017/12/14. - */ -public class PgAlarmRule { -} diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java index 8367ad4..0782c63 100644 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java @@ -12,7 +12,8 @@ private String id; private String highValue;//高限 private String lowValue;//低限 - private String devName;//设备 + private String devType;//设备类型 + private String unit;//单位 public String getId() { return id; @@ -38,20 +39,29 @@ this.lowValue = lowValue; } - public String getDevName() { - return devName; + public String getDevType() { + return devType; } - public void setDevName(String devName) { - this.devName = devName; + public void setDevType(String devType) { + this.devType = devType; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; } public PgAlarmRuleDto(PgAlarmRule pgAlarmRule) { this.setId(String.valueOf(pgAlarmRule.getId())); - this.setDevName(pgAlarmRule.getPgDeviceId().getAssetName()); this.setHighValue(pgAlarmRule.getHighValue()); this.setLowValue(pgAlarmRule.getLowValue()); + this.setDevType(pgAlarmRule.getDevType()); + this.setUnit(pgAlarmRule.getUnit()); } } diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java index d5c00b2..84e5cdd 100644 --- a/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java @@ -1,13 +1,13 @@ 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.ArrayList; import java.util.List; /** @@ -17,20 +17,21 @@ public class PgAlarmRuleManager extends HibernateEntityDao { //根据设备获取设备报警阈值 - public PgAlarmRuleDto getAlarmRuleDtoBydev(PgDevice pgDeviceId) { + public List getAlarmRuleDto() { 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)); + List pgAlarmRuleDtoList = new ArrayList(); + for (PgAlarmRule pgAlarmRule : pgAlarmRuleList) { + pgAlarmRuleDtoList.add(new PgAlarmRuleDto(pgAlarmRule)); + } + return pgAlarmRuleDtoList; + } - public PgAlarmRule getAlarmRuleBydev(PgDevice pgDeviceId) { + public PgAlarmRule getAlarmRuleBydevType(String devType) { Criteria criteria=createCriteria(PgAlarmRule.class); - criteria.add(Restrictions.eq("pgDeviceId", pgDeviceId)); + criteria.add(Restrictions.eq("devType", devType)); List pgAlarmRuleList=criteria.list(); if(pgAlarmRuleList.size()==0) diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java index f4e48c6..9396013 100644 --- a/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java @@ -39,13 +39,13 @@ } if (StringUtils.isNotBlank(startTime)) { - criteria.add(Restrictions.ge("operateTime", DateUtils.sdf4.parse(startTime))); + criteria.add(Restrictions.ge("operateTime", DateUtils.sdf_day.parse(startTime))); } if (StringUtils.isNotBlank(endTime)) { Calendar calendar = Calendar.getInstance(); - calendar.setTime(DateUtils.sdf4.parse(endTime)); + calendar.setTime(DateUtils.sdf_day.parse(endTime)); calendar.add(Calendar.DATE, 1); - criteria.add(Restrictions.le("time", calendar.getTime())); + criteria.add(Restrictions.le("operateTime", calendar.getTime())); } criteria.add(Restrictions.eq("active", 1)); diff --git a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java index 88255c6..f28ebdf 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java @@ -1,6 +1,5 @@ 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; @@ -15,7 +14,9 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -42,72 +43,43 @@ } /** - * 获取报警阈值信息 - */ - @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 { + public Map addAlarmRule(@FormParam("highValue") String highValue, + @FormParam("lowValue") String lowValue, + @FormParam("unit") String unit, + @FormParam("devType") String devType) 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(); + try { + pgAlarmRule = pgAlarmRuleManager.getAlarmRuleBydevType(devType); + if (pgAlarmRule != null) { result = "false"; - msg = "报警阈值新增失败"; + msg = "设备阈值已经存在"; + } else { + pgAlarmRule = new PgAlarmRule(); + pgAlarmRule.setHighValue(highValue); + pgAlarmRule.setLowValue(lowValue); + pgAlarmRule.setDevType(devType); + pgAlarmRule.setUnit(unit); + + pgAlarmRuleManager.save(pgAlarmRule); + result = "true"; + msg = "报警阈值新增成功"; } + } catch (Exception e) { + e.printStackTrace(); + result = "false"; + msg = "报警阈值新增失败"; } + resultMap.put("msg", msg); resultMap.put("result", result); return resultMap; @@ -119,44 +91,66 @@ @POST @Path("editAlarmRule") @Produces(MediaType.APPLICATION_JSON) - public Map editAlarmRule(@FormParam("id") String id, - @FormParam("assetCode") String assetCode, + public Map editAlarmRule(@FormParam("devType") String devType, @FormParam("highValue") String highValue, - @FormParam("lowValue") String lowValue) throws Exception { + @FormParam("lowValue") String lowValue, + @FormParam("unit") String unit) 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(); + + try { + pgAlarmRule = pgAlarmRuleManager.getAlarmRuleBydevType(devType); + if (pgAlarmRule == null) { + msg = "不存在报警阈值记录"; result = "false"; - msg = "报警阈值编辑失败"; + } else { + pgAlarmRule.setDevType(devType); + pgAlarmRule.setHighValue(highValue); + pgAlarmRule.setLowValue(lowValue); + pgAlarmRule.setUnit(unit); + pgAlarmRuleManager.save(pgAlarmRule); + msg = "编辑成功"; + result = "true"; } + } catch (Exception ex) { + ex.printStackTrace(); + result = "false"; + msg = "报警阈值编辑失败"; } + resultMap.put("msg", msg); resultMap.put("result", result); return resultMap; + } + /** + * 获取报警阈值信息 + */ + @POST + @Path("getAlarmRule") + @Produces(MediaType.APPLICATION_JSON) + public Map getAlarmRule() throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + + List pgAlarmRuleDtoList = new ArrayList(); + try { + pgAlarmRuleDtoList = pgAlarmRuleManager.getAlarmRuleDto(); + if (pgAlarmRuleDtoList == null) + msg = "不存在报警阈值信息"; + else + msg = "报警阈值获取成功"; + } catch (Exception e) { + e.printStackTrace(); + msg = "报警信息获取失败"; + } + resultMap.put("msg", msg); + resultMap.put("result", pgAlarmRuleDtoList); + 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 bb8c245..36547a7 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java @@ -104,8 +104,8 @@ @POST @Path("addDevice") @Produces(MediaType.APPLICATION_JSON) - public Map addDevice(@FormParam("parName") String parName, - @FormParam("pgName") String pgName, + public Map addDevice(@FormParam("partition") String partition, + @FormParam("pipeGallery") String pipeGallery, @FormParam("road") String road, @FormParam("position") String position, @FormParam("devType") String devType, @@ -129,8 +129,8 @@ } else { PgDevice pgDevice = new PgDevice(); - pgDevice.setPipeGallery(pgName); - pgDevice.setPartition(parName); + pgDevice.setPipeGallery(pipeGallery); + pgDevice.setPartition(partition); pgDevice.setRoad(road); pgDevice.setPosition(position); pgDevice.setDevType(devType); @@ -168,8 +168,8 @@ @Path("editDevice") @Produces(MediaType.APPLICATION_JSON) public Map editPartition(@FormParam("id") String id, - @FormParam("parName") String parName, - @FormParam("pgName") String pgName, + @FormParam("partition") String partition, + @FormParam("pipeGallery") String pipeGallery, @FormParam("road") String road, @FormParam("position") String position, @FormParam("devType") String devType, @@ -187,13 +187,15 @@ String msg = ""; try { + /* if (pgDeviceManager.getDeviceByAssetCode(assetCode)!=null) { result = "false"; msg = "已存在同名设备"; } else { + */ PgDevice pgDevice = pgDeviceManager.get(Long.valueOf(id)); - pgDevice.setPipeGallery(pgName); - pgDevice.setPartition(parName); + pgDevice.setPipeGallery(pipeGallery); + pgDevice.setPartition(partition); pgDevice.setRoad(road); pgDevice.setPosition(position); pgDevice.setDevType(devType); @@ -210,7 +212,7 @@ pgDeviceManager.save(pgDevice); result = "true"; msg = "编辑成功"; - } + //} } catch (Exception e) { result = "false"; msg = "编辑失败"; diff --git a/src/main/java/com/casic/PgInterface/rs/PgDeviceTypeRs.java b/src/main/java/com/casic/PgInterface/rs/PgDeviceTypeRs.java index 756894f..b6c84aa 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgDeviceTypeRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgDeviceTypeRs.java @@ -19,12 +19,13 @@ import java.util.Map; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Component @Path("pgDeviceType") public class PgDeviceTypeRs { - private static Logger logger = LoggerFactory.getLogger(PgDeviceRs.class); + + private static Logger logger = LoggerFactory.getLogger(PgDeviceTypeRs.class); private PgDeviceTypeManager pgDeviceTypeManager; @@ -34,21 +35,21 @@ } /** - * 获取设备类型 + * 显示设备列表 */ @POST @Path("getDeviceType") @Produces(MediaType.APPLICATION_JSON) - public Map getDeviceType()throws Exception { + public Map getDeviceTpeyList()throws Exception { Map resultMap = new HashMap(); String msg=""; List pgDeviceTypeDtoList=new ArrayList(); try { pgDeviceTypeDtoList = pgDeviceTypeManager.getAllDeviceType(); if(pgDeviceTypeDtoList.size()==0) - msg="没有设备类型信息"; + msg="没有找到设备类型信息"; else - msg="设备类型获取失败"; + msg="设备类型信息获取成功"; }catch(Exception e){ e.printStackTrace(); msg="设备类型信息获取失败"; @@ -64,37 +65,39 @@ @POST @Path("addDeviceType") @Produces(MediaType.APPLICATION_JSON) - public Map addDeviceType(@FormParam("devType") String devType) + public Map addDevice(@FormParam("devType") String devType) throws Exception { Map resultMap = new HashMap(); String result = ""; String msg = ""; - try { - if (pgDeviceTypeManager.getPgDeviceTypeByDevType(devType)!=null) { - result = "false"; - msg = "已存在同名设备类型"; - } else { - PgDeviceType pgDeviceType=new PgDeviceType(); - pgDeviceType.setDevType(devType); - pgDeviceType.setActive(1); - - pgDeviceTypeManager.save(pgDeviceType); - result = "true"; - msg = "保存成功"; - } - - } catch (Exception e) { + try { + if (pgDeviceTypeManager.getDeviceTypeByDeType(devType)!=null) { result = "false"; - msg = "保存失败"; - e.printStackTrace(); + msg = "已存在设备类型"; + } else { + PgDeviceType pgDeviceType = new PgDeviceType(); + + pgDeviceType.setDevType(devType); + pgDeviceType.setActive(1); + + pgDeviceTypeManager.save(pgDeviceType); + result = "true"; + msg = "保存成功"; } + } catch (Exception e) { + result = "false"; + msg = "保存失败"; + e.printStackTrace(); + } + resultMap.put("success", result); resultMap.put("msg", msg); return resultMap; } + } diff --git a/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java b/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java index 8a42e7e..249b75c 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java @@ -13,10 +13,8 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.text.SimpleDateFormat; +import java.util.*; /** * Created by yxw on 2017/11/6. @@ -40,25 +38,35 @@ @POST @Path("addPartition") @Produces(MediaType.APPLICATION_JSON) - public Map addAlarm(@FormParam("parName") String parName)throws Exception { + public Map addAlarm(@FormParam("parName") String parName, + @FormParam("road") String road, + @FormParam("pgPosition") String pgPosition, + @FormParam("pgNum") String pgNum, + @FormParam("pgType") String pgType, + @FormParam("pgLength") String pgLength, + @FormParam("buildDate") String buildDate, + @FormParam("material") String material)throws Exception { Map resultMap = new HashMap(); String result = ""; String msg = ""; + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); try { - if (pgPartitionManager.getPartitionByParName(parName) != null) { - result = "false"; - msg = "已存在相同分区"; - } else { PgPartition pgPartition = new PgPartition(); pgPartition.setParName(parName); + pgPartition.setRoad(road); + pgPartition.setPgPosition(pgPosition); + pgPartition.setPgNum(pgNum); + pgPartition.setPgType(pgType); + pgPartition.setPgLength(pgLength); + pgPartition.setBuildDate(sdf.parse(buildDate)); + pgPartition.setMaterial(material); pgPartition.setActive(1); logger.info("成功保存"); pgPartitionManager.save(pgPartition); result = "true"; msg = "保存成功"; - } } catch (Exception e) { result = "false"; @@ -71,28 +79,40 @@ return resultMap; } - - @POST @Path("editPartition") @Produces(MediaType.APPLICATION_JSON) public Map editPartition(@FormParam("id") String id, - @FormParam("parName") String parName) throws Exception { + @FormParam("parName") String parName, + @FormParam("road") String road, + @FormParam("pgPosition") String pgPosition, + @FormParam("pgNum") String pgNum, + @FormParam("pgType") String pgType, + @FormParam("pgLength") String pgLength, + @FormParam("buildDate") String buildDate, + @FormParam("material") String material) throws Exception { Map resultMap = new HashMap(); String result = ""; String msg = ""; PgPartition partition = new PgPartition(); + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); try { - if (pgPartitionManager.getPartitionByParName(parName) != null) { result = "false"; msg = "已存在相同分区"; } else { PgPartition pgPartition = pgPartitionManager.get(Long.valueOf(id)); pgPartition.setParName(parName); + pgPartition.setRoad(road); + pgPartition.setPgPosition(pgPosition); + pgPartition.setPgNum(pgNum); + pgPartition.setPgType(pgType); + pgPartition.setPgLength(pgLength); + pgPartition.setBuildDate(sdf.parse(buildDate)); + pgPartition.setMaterial(material); pgPartition.setActive(1); pgPartitionManager.save(pgPartition); diff --git a/src/main/java/com/casic/PgInterface/rs/PgPatrolerRs.java b/src/main/java/com/casic/PgInterface/rs/PgPatrolerRs.java index aed1ed8..0b3c731 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgPatrolerRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgPatrolerRs.java @@ -123,10 +123,12 @@ String result = ""; String msg = ""; try { + /* if (pgPatrolerManager.userNameIsExits(userName)) { result = "false"; msg = "用户名已经存在!"; } else { + */ PgPatroler pgPatroler = pgPatrolerManager.get(Long.valueOf(id)); pgPatroler.setUserName(userName); pgPatroler.setPassword(password); @@ -136,7 +138,7 @@ pgPatrolerManager.save(pgPatroler); result = "true"; msg = "编辑成功"; - } + //} } catch (Exception e) { result = "false"; msg = "编辑失败"; diff --git a/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java b/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java index 8cbdb0a..4c9feac 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java @@ -165,12 +165,14 @@ msg = "不存在管廊仓和分区信息"; } else { try { + /* if(pgPipeLineManager.getPipeLineBylineName(lineName)!=null) { result = "false"; msg = "已存在同名管线"; } else { + */ PgPipeLine pgPipeLine = pgPipeLineManager.get(Long.valueOf(id)); pgPipeLine.setLineName(lineName); @@ -185,7 +187,7 @@ pgPipeLineManager.save(pgPipeLine); result = "true"; msg = "编辑成功"; - } + //} } catch (Exception e) { result = "false"; msg = "编辑失败"; diff --git a/src/main/java/com/casic/PgInterface/rs/PgReserveController.java b/src/main/java/com/casic/PgInterface/rs/PgReserveController.java new file mode 100644 index 0000000..863045a --- /dev/null +++ b/src/main/java/com/casic/PgInterface/rs/PgReserveController.java @@ -0,0 +1,207 @@ +package com.casic.PgInterface.rs; + +import com.casic.PgInterface.core.util.StringUtils; +import com.casic.PgInterface.devTable.manager.PgAlarmTypeManager; +import com.casic.PgInterface.reservePlan.domain.PgReservePlan; +import com.casic.PgInterface.reservePlan.manager.PgReservePlanManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.multipart.MultipartFile; +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.List; +import java.util.Map; + +/** + * Created by yxw on 2017/11/8. + */ +@Controller +@RequestMapping("rs/pgReservePlan") +public class PgReserveController { + + private static Logger logger = LoggerFactory.getLogger(PgReservePlan.class); + + private PgReservePlanManager pgReservePlanManager; + + private PgAlarmTypeManager pgAlarmTypeManager; + + @Resource + public void setPgReservePlanManager(PgReservePlanManager pgReservePlanManager) { + this.pgReservePlanManager = pgReservePlanManager; + } + + @Resource + public void setPgAlarmTypeManager(PgAlarmTypeManager pgAlarmTypeManager) { + this.pgAlarmTypeManager = pgAlarmTypeManager; + } + +// //新增预案文档 +// @RequestMapping("addReservePlan") +// @ResponseBody +// public Map addReservePlan(@RequestParam(value = "planName",required = true) String planName, +// @RequestParam(value = "planType",required =false) String planType, +// @RequestParam(value ="resUnit",required =false) String resUnit, +// @RequestParam(value ="alarmType",required =false) String alarmType, +// @RequestParam(value = "planFiels",required =false) List planFiels) +// throws Exception { +// Map resultMap = new HashMap(); +// PgReservePlan pgReservePlan = new PgReservePlan(); +// String result = ""; +// String msg = ""; +// +// try { +// if (planFiels.size() == 0) +// pgReservePlan.setPlanFiel(""); +// else { +// pgReservePlan.setPlanFiel(pgReservePlanManager.saveFiles(planFiels, "reservePlan")); +// } +// +// pgReservePlan.setPlanName(planName); +// pgReservePlan.setPlanType(planType); +// pgReservePlan.setResUnit(resUnit); +// pgReservePlan.setPgAlarmTypeId(pgAlarmTypeManager.getAlarmTypeByAlarmType(alarmType)); +// pgReservePlan.setActive(1); +// +// result = "true"; +// msg = "保存成功"; +// logger.info("保存成功"); +// pgReservePlanManager.save(pgReservePlan); +// } catch (Exception ex) { +// result = "false"; +// msg = "保存失败"; +// ex.printStackTrace(); +// } +// +// resultMap.put("success", result); +// resultMap.put("msg", msg); +// return resultMap; +// } + + //新增预案文档 + @POST + @Path("addReservePlan") + @Produces(MediaType.APPLICATION_JSON) + public Map addReservePlan( + @FormParam("pgName") String planName, + @FormParam("parName") String planType, + @FormParam("parName") String resUnit, + @FormParam("parName") String alarmType, + @FormParam("parName") String fileBuffer, + @FormParam("parName") String fileName)throws Exception { + Map resultMap = new HashMap(); + PgReservePlan pgReservePlan = new PgReservePlan(); + String result = ""; + String msg = ""; + + try { + if (StringUtils.isBlank(fileBuffer)||StringUtils.isBlank(fileName)) + pgReservePlan.setPlanFiel(""); + else { + pgReservePlan.setPlanFiel(pgReservePlanManager.saveFiles(fileBuffer, fileName,"reservePlan")); + } + + pgReservePlan.setPlanName(planName); + pgReservePlan.setPlanType(planType); + pgReservePlan.setResUnit(resUnit); + pgReservePlan.setPgAlarmTypeId(pgAlarmTypeManager.getAlarmTypeByAlarmType(alarmType)); + pgReservePlan.setActive(1); + + result = "true"; + msg = "保存成功"; + logger.info("保存成功"); + pgReservePlanManager.save(pgReservePlan); + } catch (Exception ex) { + result = "false"; + msg = "保存失败"; + ex.printStackTrace(); + } + + resultMap.put("success", result); + resultMap.put("msg", msg); + return resultMap; + } + + //编辑预案文档 + @RequestMapping("editReservePlan") + @ResponseBody + public Map editReservePlan(@FormParam("id") String id, + @RequestParam(value = "planName",required = true) String planName, + @RequestParam(value = "planType",required =false) String planType, + @RequestParam(value ="resUnit",required =false) String resUnit, + @RequestParam(value ="alarmType",required =false) String alarmType) throws Exception { + + Map resultMap = new HashMap(); + String result = ""; + String msg = ""; + + try { + PgReservePlan pgReservePlan = pgReservePlanManager.get(Long.valueOf(id)); + if (pgReservePlan == null) { + result = "false"; + msg = "不存在该预案信息"; + } else { + pgReservePlan.setPlanName(planName); + pgReservePlan.setPlanType(planType); + pgReservePlan.setResUnit(resUnit); + pgReservePlan.setPgAlarmTypeId(pgAlarmTypeManager.getAlarmTypeByAlarmType(alarmType)); + pgReservePlan.setActive(1); + + pgReservePlanManager.save(pgReservePlan); + result = "true"; + msg = "编辑成功"; + } + } catch (Exception e) { + result = "false"; + msg = "编辑失败"; + e.printStackTrace(); + } + return resultMap; + } + + //删除预案文档 + @RequestMapping("deleteReservePlan") + @ResponseBody + public Map deleteReservePlan(@FormParam("id") String id)throws Exception{ + Map resultMap = new HashMap(); + String msg=""; + String result="false"; + + try{ + + PgReservePlan pgReservePlan=pgReservePlanManager.get(Long.valueOf(id)); + if(pgReservePlan==null) + { + result="false"; + msg="不存在该预案信息"; + } + else{ + pgReservePlan.setActive(0); + pgReservePlanManager.save(pgReservePlan); + result="true"; + msg="删除成功"; + } + } + catch(Exception e) + { + e.printStackTrace(); + msg="预案删除失败"; + result="false"; + } + + 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/PgTextureRs.java b/src/main/java/com/casic/PgInterface/rs/PgTextureRs.java index 5892127..2360251 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgTextureRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgTextureRs.java @@ -163,12 +163,14 @@ msg = "不存在管廊仓和分区信息"; } else { try { + /* if(pgTextureManager.getPgTextureByName(textureName)!=null) { result = "false"; msg = "已存在同名的部件"; } else { + */ PgTexture pgTexture = pgTextureManager.get(Long.valueOf(id)); pgTexture.setTextureName(textureName); pgTexture.setTextureMaterial(textureMaterial); @@ -181,7 +183,7 @@ pgTextureManager.save(pgTexture); result = "true"; msg = "编辑成功"; - } + //} } catch (Exception e) { result = "false"; msg = "编辑失败"; diff --git a/src/main/java/com/casic/PgInterface/rs/PipeGalleryRs.java b/src/main/java/com/casic/PgInterface/rs/PipeGalleryRs.java index 6904b9f..42f7d40 100644 --- a/src/main/java/com/casic/PgInterface/rs/PipeGalleryRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PipeGalleryRs.java @@ -132,10 +132,12 @@ result = "false"; msg = "不存在该分区信息"; } else { + /* if (pipeGalleryManager.getPipeGalleryByPgName(pgName, pgPartition) != null) { result = "false"; msg = "已存在相同管廊"; } else { + */ pipeGallery = pipeGalleryManager.get(Long.valueOf(id)); pipeGallery.setPgName(pgName); @@ -145,7 +147,7 @@ pipeGalleryManager.save(pipeGallery); result = "true"; msg = "编辑成功"; - } + //} } } catch (Exception e) { result = "false"; diff --git a/src/main/java/com/casic/PgInterface/rsFiles/web/PgReserveController.java b/src/main/java/com/casic/PgInterface/rsFiles/web/PgReserveController.java deleted file mode 100644 index f13dac6..0000000 --- a/src/main/java/com/casic/PgInterface/rsFiles/web/PgReserveController.java +++ /dev/null @@ -1,158 +0,0 @@ -package com.casic.PgInterface.rsFiles.web; - -import com.casic.PgInterface.devTable.manager.PgAlarmTypeManager; -import com.casic.PgInterface.reservePlan.domain.PgReservePlan; -import com.casic.PgInterface.reservePlan.manager.PgReservePlanManager; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.multipart.MultipartFile; -import javax.annotation.Resource; -import javax.ws.rs.FormParam; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * Created by yxw on 2017/11/8. - */ -@Controller -@RequestMapping("rs/pgReservePlan") -public class PgReserveController { - - private static Logger logger = LoggerFactory.getLogger(PgReservePlan.class); - - private PgReservePlanManager pgReservePlanManager; - - private PgAlarmTypeManager pgAlarmTypeManager; - - @Resource - public void setPgReservePlanManager(PgReservePlanManager pgReservePlanManager) { - this.pgReservePlanManager = pgReservePlanManager; - } - - @Resource - public void setPgAlarmTypeManager(PgAlarmTypeManager pgAlarmTypeManager) { - this.pgAlarmTypeManager = pgAlarmTypeManager; - } - - //新增预案文档 - @RequestMapping("addReservePlan") - @ResponseBody - public Map addReservePlan(@RequestParam(value = "planName",required = true) String planName, - @RequestParam(value = "planType",required =false) String planType, - @RequestParam(value ="resUnit",required =false) String resUnit, - @RequestParam(value ="alarmType",required =false) String alarmType, - @RequestParam(value = "planFiels",required =false) List planFiels) - throws Exception { - Map resultMap = new HashMap(); - PgReservePlan pgReservePlan = new PgReservePlan(); - String result = ""; - String msg = ""; - - try { - if (planFiels.size() == 0) - pgReservePlan.setPlanFiel(""); - else { - pgReservePlan.setPlanFiel(pgReservePlanManager.saveFiles(planFiels, "reservePlan")); - } - - pgReservePlan.setPlanName(planName); - pgReservePlan.setPlanType(planType); - pgReservePlan.setResUnit(resUnit); - pgReservePlan.setPgAlarmTypeId(pgAlarmTypeManager.getAlarmTypeByAlarmType(alarmType)); - pgReservePlan.setActive(1); - - result = "true"; - msg = "保存成功"; - logger.info("保存成功"); - pgReservePlanManager.save(pgReservePlan); - } catch (Exception ex) { - result = "false"; - msg = "保存失败"; - ex.printStackTrace(); - } - - resultMap.put("success", result); - resultMap.put("msg", msg); - return resultMap; - } - - //编辑预案文档 - @RequestMapping("editReservePlan") - @ResponseBody - public Map editReservePlan(@FormParam("id") String id, - @RequestParam(value = "planName",required = true) String planName, - @RequestParam(value = "planType",required =false) String planType, - @RequestParam(value ="resUnit",required =false) String resUnit, - @RequestParam(value ="alarmType",required =false) String alarmType) throws Exception { - - Map resultMap = new HashMap(); - String result = ""; - String msg = ""; - - try { - PgReservePlan pgReservePlan = pgReservePlanManager.get(Long.valueOf(id)); - if (pgReservePlan == null) { - result = "false"; - msg = "不存在该预案信息"; - } else { - pgReservePlan.setPlanName(planName); - pgReservePlan.setPlanType(planType); - pgReservePlan.setResUnit(resUnit); - pgReservePlan.setPgAlarmTypeId(pgAlarmTypeManager.getAlarmTypeByAlarmType(alarmType)); - pgReservePlan.setActive(1); - - pgReservePlanManager.save(pgReservePlan); - result = "true"; - msg = "编辑成功"; - } - } catch (Exception e) { - result = "false"; - msg = "编辑失败"; - e.printStackTrace(); - } - return resultMap; - } - - //删除预案文档 - @RequestMapping("deleteReservePlan") - @ResponseBody - public Map deleteReservePlan(@FormParam("id") String id)throws Exception{ - Map resultMap = new HashMap(); - String msg=""; - String result="false"; - - try{ - - PgReservePlan pgReservePlan=pgReservePlanManager.get(Long.valueOf(id)); - if(pgReservePlan==null) - { - result="false"; - msg="不存在该预案信息"; - } - else{ - pgReservePlan.setActive(0); - pgReservePlanManager.save(pgReservePlan); - result="true"; - msg="删除成功"; - } - } - catch(Exception e) - { - e.printStackTrace(); - msg="预案删除失败"; - result="false"; - } - - resultMap.put("msg",msg); - resultMap.put("result",result); - return resultMap; - - } - - -} \ No newline at end of file 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" deleted file mode 100644 index 964daa9..0000000 --- "a/~$\346\216\245\345\217\243\350\257\264\346\230\216.docx" +++ /dev/null Binary files differ diff --git a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java b/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java deleted file mode 100644 index b2affe5..0000000 --- a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.casic.PgInterface.devData.dto; - -/** - * Created by yxw on 2017/11/28. - */ -public class PgTempHunDto { -} 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 eb1f7ab..da8f617 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -39,7 +39,6 @@ private List pgShs; private List pgTempHums; - @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") public long getId() { diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java index 4278dc1..669b60f 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java @@ -2,21 +2,20 @@ import javax.persistence.*; import java.io.Serializable; -import java.util.List; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Entity @Table(name = "PG_DEVICE_TYPE") @SequenceGenerator(name = "SEQ_PG_DEVICE_TYPE_ID", sequenceName = "SEQ_PG_DEVICE_TYPE_ID", allocationSize = 1, initialValue = 1) public class PgDeviceType implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; private long id; private String devType; private int active; - private List pgDeviceList; + @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_TYPE_ID") @@ -45,13 +44,4 @@ public void setActive(int active) { this.active = active; } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "devTypeId") - public List getPgDeviceList() { - return pgDeviceList; - } - - public void setPgDeviceList(List pgDeviceList) { - this.pgDeviceList = pgDeviceList; - } } 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 4fb3d6f..d209733 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java @@ -2,6 +2,7 @@ import javax.persistence.*; import java.io.Serializable; +import java.util.Date; import java.util.List; /** @@ -17,6 +18,12 @@ private long id; private String parName;//分区名称 private String road;//所属道路 + private String pgPosition;//仓段位置 + private String pgNum;//仓位数量 + private String pgType;//仓位类型 + private String pgLength;//分区长度 + private Date buildDate;//建设年代 + private String material;//建设材质 private int active;//状态位 private List pipeGalleryList;//管廊仓 @@ -48,6 +55,60 @@ this.road = road; } + @Column(name = "PGPOSITION") + public String getPgPosition() { + return pgPosition; + } + + public void setPgPosition(String pgPosition) { + this.pgPosition = pgPosition; + } + + @Column(name = "PGNUM") + public String getPgNum() { + return pgNum; + } + + public void setPgNum(String pgNum) { + this.pgNum = pgNum; + } + + @Column(name = "PGTYPE") + public String getPgType() { + return pgType; + } + + public void setPgType(String pgType) { + this.pgType = pgType; + } + + @Column(name = "PGLENGTH") + public String getPgLength() { + return pgLength; + } + + public void setPgLength(String pgLength) { + this.pgLength = pgLength; + } + + @Column(name = "BUILDDATE") + public Date getBuildDate() { + return buildDate; + } + + public void setBuildDate(Date buildDate) { + this.buildDate = buildDate; + } + + @Column(name = "MATERIAL") + public String getMaterial() { + return material; + } + + public void setMaterial(String material) { + this.material = material; + } + @Column(name = "ACTIVE") public int getActive() { return active; 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 95f9fbd..b60c42d 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java @@ -160,7 +160,7 @@ this.setAssetName(pgDevice.getAssetName()); this.setAssetCode(pgDevice.getAssetCode()); this.setAssetBarCode(pgDevice.getAssetBarCode()); - this.setId(pgDevice.getIp()); + this.setIp(pgDevice.getIp()); this.setModBus(pgDevice.getModBus()); this.setMome(pgDevice.getMome()); this.setIsOpen(String.valueOf(pgDevice.getIsOpen())); diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java index c1548e0..e348f7a 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java @@ -5,7 +5,7 @@ import java.io.Serializable; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ public class PgDeviceTypeDto implements Serializable { @@ -37,12 +37,11 @@ this.active = active; } - public PgDeviceTypeDto(PgDeviceType pgDeviceType) - { + public PgDeviceTypeDto(PgDeviceType pgDeviceType) { + this.setId(String.valueOf(pgDeviceType.getId())); this.setDevType(pgDeviceType.getDevType()); this.setActive(String.valueOf(pgDeviceType.getActive())); } - } 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 3acd0fa..95c18b4 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java @@ -3,6 +3,7 @@ import com.casic.PgInterface.devTable.domain.PgPartition; import java.io.Serializable; +import java.text.SimpleDateFormat; /** * Created by yxw on 2017/11/2. @@ -12,6 +13,12 @@ private String id; private String parName;//分区名称 private String road;//所属道路 + private String pgPosition;//仓段位置 + private String pgNum;//仓位数量 + private String pgType;//仓位类型 + private String pgLength;//分区长度 + private String buildDate;//建设年代 + private String material;//建设材质 private String active;//状态位 @@ -47,11 +54,67 @@ this.road = road; } + public String getPgPosition() { + return pgPosition; + } + + public void setPgPosition(String pgPosition) { + this.pgPosition = pgPosition; + } + + public String getPgNum() { + return pgNum; + } + + public void setPgNum(String pgNum) { + this.pgNum = pgNum; + } + + public String getPgType() { + return pgType; + } + + public void setPgType(String pgType) { + this.pgType = pgType; + } + + public String getPgLength() { + return pgLength; + } + + public void setPgLength(String pgLength) { + this.pgLength = pgLength; + } + + public String getBuildDate() { + return buildDate; + } + + public void setBuildDate(String buildDate) { + this.buildDate = buildDate; + } + + public String getMaterial() { + return material; + } + + public void setMaterial(String material) { + this.material = material; + } + public PgPartitionDto(PgPartition pgPartition) { + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); + this.setId(String.valueOf(pgPartition.getId())); this.setParName(pgPartition.getParName()); this.setRoad(pgPartition.getRoad()); + this.setPgPosition(pgPartition.getPgPosition()); + this.setPgNum(pgPartition.getPgNum()); + this.setPgType(pgPartition.getPgType()); + this.setPgLength(pgPartition.getPgLength()); + this.setBuildDate(sdf.format(pgPartition.getBuildDate())); + this.setMaterial(pgPartition.getMaterial()); this.setActive(String.valueOf(pgPartition.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java b/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java index d7c6024..9ea43fd 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java @@ -12,10 +12,10 @@ import java.util.List; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Service -public class PgDeviceTypeManager extends HibernateEntityDao{ +public class PgDeviceTypeManager extends HibernateEntityDao { public List getAllDeviceType() { @@ -23,8 +23,8 @@ criteria.add(Restrictions.eq("active", 1)); criteria.addOrder(Order.desc("id")); - List pgDeviceTypeList= criteria.list(); - List pgDeviceTypeDtoList=new ArrayList(); + List pgDeviceTypeList = criteria.list(); + List pgDeviceTypeDtoList = new ArrayList(); for (PgDeviceType pgDeviceType : pgDeviceTypeList) { pgDeviceTypeDtoList.add(new PgDeviceTypeDto(pgDeviceType)); } @@ -32,15 +32,14 @@ return pgDeviceTypeDtoList; } - public PgDeviceType getPgDeviceTypeByDevType(String devType) - { - Criteria criteria=createCriteria(PgDeviceType.class); - criteria.add(Restrictions.eq("devType",devType)); - criteria.add(Restrictions.eq("active",1)); - criteria.addOrder(Order.desc("id")); + public PgDeviceType getDeviceTypeByDeType(String devType) { - List pgDeviceTypeList=criteria.list(); - if(pgDeviceTypeList==null||pgDeviceTypeList.size()==0) + Criteria criteria = createCriteria(PgDeviceType.class); + criteria.add(Restrictions.eq("active", 1)); + criteria.add(Restrictions.eq("devType", devType)); + + List pgDeviceTypeList = criteria.list(); + if (pgDeviceTypeList.size() == 0) return null; else return pgDeviceTypeList.get(0); 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 0c594e7..c6f22cb 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java @@ -64,4 +64,4 @@ -} +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java index 9d06235..68b14cf 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java @@ -1,9 +1,5 @@ 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; @@ -19,7 +15,8 @@ private long id; private String highValue;//高限 private String lowValue;//低限 - private PgDevice pgDeviceId;//设备 + private String unit;//单位 + private String devType;//设备类型 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_ALARM_RULE_ID") @@ -49,15 +46,24 @@ this.lowValue = lowValue; } - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PGDEVICEID") - public PgDevice getPgDeviceId() { - return pgDeviceId; + @Column(name="UNIT") + public String getUnit() { + return unit; } - public void setPgDeviceId(PgDevice pgDeviceId) { - this.pgDeviceId = pgDeviceId; + public void setUnit(String unit) { + this.unit = unit; } + @Column(name = "DEVTYPE") + public String getDevType() { + return devType; + } + + public void setDevType(String devType) { + this.devType = devType; + } + + + } diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java deleted file mode 100644 index 7907e66..0000000 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.casic.PgInterface.patroler.dto; - -/** - * Created by yxw on 2017/12/14. - */ -public class PgAlarmRule { -} diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java index 8367ad4..0782c63 100644 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java @@ -12,7 +12,8 @@ private String id; private String highValue;//高限 private String lowValue;//低限 - private String devName;//设备 + private String devType;//设备类型 + private String unit;//单位 public String getId() { return id; @@ -38,20 +39,29 @@ this.lowValue = lowValue; } - public String getDevName() { - return devName; + public String getDevType() { + return devType; } - public void setDevName(String devName) { - this.devName = devName; + public void setDevType(String devType) { + this.devType = devType; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; } public PgAlarmRuleDto(PgAlarmRule pgAlarmRule) { this.setId(String.valueOf(pgAlarmRule.getId())); - this.setDevName(pgAlarmRule.getPgDeviceId().getAssetName()); this.setHighValue(pgAlarmRule.getHighValue()); this.setLowValue(pgAlarmRule.getLowValue()); + this.setDevType(pgAlarmRule.getDevType()); + this.setUnit(pgAlarmRule.getUnit()); } } diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java index d5c00b2..84e5cdd 100644 --- a/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java @@ -1,13 +1,13 @@ 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.ArrayList; import java.util.List; /** @@ -17,20 +17,21 @@ public class PgAlarmRuleManager extends HibernateEntityDao { //根据设备获取设备报警阈值 - public PgAlarmRuleDto getAlarmRuleDtoBydev(PgDevice pgDeviceId) { + public List getAlarmRuleDto() { 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)); + List pgAlarmRuleDtoList = new ArrayList(); + for (PgAlarmRule pgAlarmRule : pgAlarmRuleList) { + pgAlarmRuleDtoList.add(new PgAlarmRuleDto(pgAlarmRule)); + } + return pgAlarmRuleDtoList; + } - public PgAlarmRule getAlarmRuleBydev(PgDevice pgDeviceId) { + public PgAlarmRule getAlarmRuleBydevType(String devType) { Criteria criteria=createCriteria(PgAlarmRule.class); - criteria.add(Restrictions.eq("pgDeviceId", pgDeviceId)); + criteria.add(Restrictions.eq("devType", devType)); List pgAlarmRuleList=criteria.list(); if(pgAlarmRuleList.size()==0) diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java index f4e48c6..9396013 100644 --- a/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java @@ -39,13 +39,13 @@ } if (StringUtils.isNotBlank(startTime)) { - criteria.add(Restrictions.ge("operateTime", DateUtils.sdf4.parse(startTime))); + criteria.add(Restrictions.ge("operateTime", DateUtils.sdf_day.parse(startTime))); } if (StringUtils.isNotBlank(endTime)) { Calendar calendar = Calendar.getInstance(); - calendar.setTime(DateUtils.sdf4.parse(endTime)); + calendar.setTime(DateUtils.sdf_day.parse(endTime)); calendar.add(Calendar.DATE, 1); - criteria.add(Restrictions.le("time", calendar.getTime())); + criteria.add(Restrictions.le("operateTime", calendar.getTime())); } criteria.add(Restrictions.eq("active", 1)); diff --git a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java index 88255c6..f28ebdf 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java @@ -1,6 +1,5 @@ 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; @@ -15,7 +14,9 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -42,72 +43,43 @@ } /** - * 获取报警阈值信息 - */ - @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 { + public Map addAlarmRule(@FormParam("highValue") String highValue, + @FormParam("lowValue") String lowValue, + @FormParam("unit") String unit, + @FormParam("devType") String devType) 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(); + try { + pgAlarmRule = pgAlarmRuleManager.getAlarmRuleBydevType(devType); + if (pgAlarmRule != null) { result = "false"; - msg = "报警阈值新增失败"; + msg = "设备阈值已经存在"; + } else { + pgAlarmRule = new PgAlarmRule(); + pgAlarmRule.setHighValue(highValue); + pgAlarmRule.setLowValue(lowValue); + pgAlarmRule.setDevType(devType); + pgAlarmRule.setUnit(unit); + + pgAlarmRuleManager.save(pgAlarmRule); + result = "true"; + msg = "报警阈值新增成功"; } + } catch (Exception e) { + e.printStackTrace(); + result = "false"; + msg = "报警阈值新增失败"; } + resultMap.put("msg", msg); resultMap.put("result", result); return resultMap; @@ -119,44 +91,66 @@ @POST @Path("editAlarmRule") @Produces(MediaType.APPLICATION_JSON) - public Map editAlarmRule(@FormParam("id") String id, - @FormParam("assetCode") String assetCode, + public Map editAlarmRule(@FormParam("devType") String devType, @FormParam("highValue") String highValue, - @FormParam("lowValue") String lowValue) throws Exception { + @FormParam("lowValue") String lowValue, + @FormParam("unit") String unit) 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(); + + try { + pgAlarmRule = pgAlarmRuleManager.getAlarmRuleBydevType(devType); + if (pgAlarmRule == null) { + msg = "不存在报警阈值记录"; result = "false"; - msg = "报警阈值编辑失败"; + } else { + pgAlarmRule.setDevType(devType); + pgAlarmRule.setHighValue(highValue); + pgAlarmRule.setLowValue(lowValue); + pgAlarmRule.setUnit(unit); + pgAlarmRuleManager.save(pgAlarmRule); + msg = "编辑成功"; + result = "true"; } + } catch (Exception ex) { + ex.printStackTrace(); + result = "false"; + msg = "报警阈值编辑失败"; } + resultMap.put("msg", msg); resultMap.put("result", result); return resultMap; + } + /** + * 获取报警阈值信息 + */ + @POST + @Path("getAlarmRule") + @Produces(MediaType.APPLICATION_JSON) + public Map getAlarmRule() throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + + List pgAlarmRuleDtoList = new ArrayList(); + try { + pgAlarmRuleDtoList = pgAlarmRuleManager.getAlarmRuleDto(); + if (pgAlarmRuleDtoList == null) + msg = "不存在报警阈值信息"; + else + msg = "报警阈值获取成功"; + } catch (Exception e) { + e.printStackTrace(); + msg = "报警信息获取失败"; + } + resultMap.put("msg", msg); + resultMap.put("result", pgAlarmRuleDtoList); + 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 bb8c245..36547a7 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java @@ -104,8 +104,8 @@ @POST @Path("addDevice") @Produces(MediaType.APPLICATION_JSON) - public Map addDevice(@FormParam("parName") String parName, - @FormParam("pgName") String pgName, + public Map addDevice(@FormParam("partition") String partition, + @FormParam("pipeGallery") String pipeGallery, @FormParam("road") String road, @FormParam("position") String position, @FormParam("devType") String devType, @@ -129,8 +129,8 @@ } else { PgDevice pgDevice = new PgDevice(); - pgDevice.setPipeGallery(pgName); - pgDevice.setPartition(parName); + pgDevice.setPipeGallery(pipeGallery); + pgDevice.setPartition(partition); pgDevice.setRoad(road); pgDevice.setPosition(position); pgDevice.setDevType(devType); @@ -168,8 +168,8 @@ @Path("editDevice") @Produces(MediaType.APPLICATION_JSON) public Map editPartition(@FormParam("id") String id, - @FormParam("parName") String parName, - @FormParam("pgName") String pgName, + @FormParam("partition") String partition, + @FormParam("pipeGallery") String pipeGallery, @FormParam("road") String road, @FormParam("position") String position, @FormParam("devType") String devType, @@ -187,13 +187,15 @@ String msg = ""; try { + /* if (pgDeviceManager.getDeviceByAssetCode(assetCode)!=null) { result = "false"; msg = "已存在同名设备"; } else { + */ PgDevice pgDevice = pgDeviceManager.get(Long.valueOf(id)); - pgDevice.setPipeGallery(pgName); - pgDevice.setPartition(parName); + pgDevice.setPipeGallery(pipeGallery); + pgDevice.setPartition(partition); pgDevice.setRoad(road); pgDevice.setPosition(position); pgDevice.setDevType(devType); @@ -210,7 +212,7 @@ pgDeviceManager.save(pgDevice); result = "true"; msg = "编辑成功"; - } + //} } catch (Exception e) { result = "false"; msg = "编辑失败"; diff --git a/src/main/java/com/casic/PgInterface/rs/PgDeviceTypeRs.java b/src/main/java/com/casic/PgInterface/rs/PgDeviceTypeRs.java index 756894f..b6c84aa 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgDeviceTypeRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgDeviceTypeRs.java @@ -19,12 +19,13 @@ import java.util.Map; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Component @Path("pgDeviceType") public class PgDeviceTypeRs { - private static Logger logger = LoggerFactory.getLogger(PgDeviceRs.class); + + private static Logger logger = LoggerFactory.getLogger(PgDeviceTypeRs.class); private PgDeviceTypeManager pgDeviceTypeManager; @@ -34,21 +35,21 @@ } /** - * 获取设备类型 + * 显示设备列表 */ @POST @Path("getDeviceType") @Produces(MediaType.APPLICATION_JSON) - public Map getDeviceType()throws Exception { + public Map getDeviceTpeyList()throws Exception { Map resultMap = new HashMap(); String msg=""; List pgDeviceTypeDtoList=new ArrayList(); try { pgDeviceTypeDtoList = pgDeviceTypeManager.getAllDeviceType(); if(pgDeviceTypeDtoList.size()==0) - msg="没有设备类型信息"; + msg="没有找到设备类型信息"; else - msg="设备类型获取失败"; + msg="设备类型信息获取成功"; }catch(Exception e){ e.printStackTrace(); msg="设备类型信息获取失败"; @@ -64,37 +65,39 @@ @POST @Path("addDeviceType") @Produces(MediaType.APPLICATION_JSON) - public Map addDeviceType(@FormParam("devType") String devType) + public Map addDevice(@FormParam("devType") String devType) throws Exception { Map resultMap = new HashMap(); String result = ""; String msg = ""; - try { - if (pgDeviceTypeManager.getPgDeviceTypeByDevType(devType)!=null) { - result = "false"; - msg = "已存在同名设备类型"; - } else { - PgDeviceType pgDeviceType=new PgDeviceType(); - pgDeviceType.setDevType(devType); - pgDeviceType.setActive(1); - - pgDeviceTypeManager.save(pgDeviceType); - result = "true"; - msg = "保存成功"; - } - - } catch (Exception e) { + try { + if (pgDeviceTypeManager.getDeviceTypeByDeType(devType)!=null) { result = "false"; - msg = "保存失败"; - e.printStackTrace(); + msg = "已存在设备类型"; + } else { + PgDeviceType pgDeviceType = new PgDeviceType(); + + pgDeviceType.setDevType(devType); + pgDeviceType.setActive(1); + + pgDeviceTypeManager.save(pgDeviceType); + result = "true"; + msg = "保存成功"; } + } catch (Exception e) { + result = "false"; + msg = "保存失败"; + e.printStackTrace(); + } + resultMap.put("success", result); resultMap.put("msg", msg); return resultMap; } + } diff --git a/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java b/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java index 8a42e7e..249b75c 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java @@ -13,10 +13,8 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.text.SimpleDateFormat; +import java.util.*; /** * Created by yxw on 2017/11/6. @@ -40,25 +38,35 @@ @POST @Path("addPartition") @Produces(MediaType.APPLICATION_JSON) - public Map addAlarm(@FormParam("parName") String parName)throws Exception { + public Map addAlarm(@FormParam("parName") String parName, + @FormParam("road") String road, + @FormParam("pgPosition") String pgPosition, + @FormParam("pgNum") String pgNum, + @FormParam("pgType") String pgType, + @FormParam("pgLength") String pgLength, + @FormParam("buildDate") String buildDate, + @FormParam("material") String material)throws Exception { Map resultMap = new HashMap(); String result = ""; String msg = ""; + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); try { - if (pgPartitionManager.getPartitionByParName(parName) != null) { - result = "false"; - msg = "已存在相同分区"; - } else { PgPartition pgPartition = new PgPartition(); pgPartition.setParName(parName); + pgPartition.setRoad(road); + pgPartition.setPgPosition(pgPosition); + pgPartition.setPgNum(pgNum); + pgPartition.setPgType(pgType); + pgPartition.setPgLength(pgLength); + pgPartition.setBuildDate(sdf.parse(buildDate)); + pgPartition.setMaterial(material); pgPartition.setActive(1); logger.info("成功保存"); pgPartitionManager.save(pgPartition); result = "true"; msg = "保存成功"; - } } catch (Exception e) { result = "false"; @@ -71,28 +79,40 @@ return resultMap; } - - @POST @Path("editPartition") @Produces(MediaType.APPLICATION_JSON) public Map editPartition(@FormParam("id") String id, - @FormParam("parName") String parName) throws Exception { + @FormParam("parName") String parName, + @FormParam("road") String road, + @FormParam("pgPosition") String pgPosition, + @FormParam("pgNum") String pgNum, + @FormParam("pgType") String pgType, + @FormParam("pgLength") String pgLength, + @FormParam("buildDate") String buildDate, + @FormParam("material") String material) throws Exception { Map resultMap = new HashMap(); String result = ""; String msg = ""; PgPartition partition = new PgPartition(); + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); try { - if (pgPartitionManager.getPartitionByParName(parName) != null) { result = "false"; msg = "已存在相同分区"; } else { PgPartition pgPartition = pgPartitionManager.get(Long.valueOf(id)); pgPartition.setParName(parName); + pgPartition.setRoad(road); + pgPartition.setPgPosition(pgPosition); + pgPartition.setPgNum(pgNum); + pgPartition.setPgType(pgType); + pgPartition.setPgLength(pgLength); + pgPartition.setBuildDate(sdf.parse(buildDate)); + pgPartition.setMaterial(material); pgPartition.setActive(1); pgPartitionManager.save(pgPartition); diff --git a/src/main/java/com/casic/PgInterface/rs/PgPatrolerRs.java b/src/main/java/com/casic/PgInterface/rs/PgPatrolerRs.java index aed1ed8..0b3c731 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgPatrolerRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgPatrolerRs.java @@ -123,10 +123,12 @@ String result = ""; String msg = ""; try { + /* if (pgPatrolerManager.userNameIsExits(userName)) { result = "false"; msg = "用户名已经存在!"; } else { + */ PgPatroler pgPatroler = pgPatrolerManager.get(Long.valueOf(id)); pgPatroler.setUserName(userName); pgPatroler.setPassword(password); @@ -136,7 +138,7 @@ pgPatrolerManager.save(pgPatroler); result = "true"; msg = "编辑成功"; - } + //} } catch (Exception e) { result = "false"; msg = "编辑失败"; diff --git a/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java b/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java index 8cbdb0a..4c9feac 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java @@ -165,12 +165,14 @@ msg = "不存在管廊仓和分区信息"; } else { try { + /* if(pgPipeLineManager.getPipeLineBylineName(lineName)!=null) { result = "false"; msg = "已存在同名管线"; } else { + */ PgPipeLine pgPipeLine = pgPipeLineManager.get(Long.valueOf(id)); pgPipeLine.setLineName(lineName); @@ -185,7 +187,7 @@ pgPipeLineManager.save(pgPipeLine); result = "true"; msg = "编辑成功"; - } + //} } catch (Exception e) { result = "false"; msg = "编辑失败"; diff --git a/src/main/java/com/casic/PgInterface/rs/PgReserveController.java b/src/main/java/com/casic/PgInterface/rs/PgReserveController.java new file mode 100644 index 0000000..863045a --- /dev/null +++ b/src/main/java/com/casic/PgInterface/rs/PgReserveController.java @@ -0,0 +1,207 @@ +package com.casic.PgInterface.rs; + +import com.casic.PgInterface.core.util.StringUtils; +import com.casic.PgInterface.devTable.manager.PgAlarmTypeManager; +import com.casic.PgInterface.reservePlan.domain.PgReservePlan; +import com.casic.PgInterface.reservePlan.manager.PgReservePlanManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.multipart.MultipartFile; +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.List; +import java.util.Map; + +/** + * Created by yxw on 2017/11/8. + */ +@Controller +@RequestMapping("rs/pgReservePlan") +public class PgReserveController { + + private static Logger logger = LoggerFactory.getLogger(PgReservePlan.class); + + private PgReservePlanManager pgReservePlanManager; + + private PgAlarmTypeManager pgAlarmTypeManager; + + @Resource + public void setPgReservePlanManager(PgReservePlanManager pgReservePlanManager) { + this.pgReservePlanManager = pgReservePlanManager; + } + + @Resource + public void setPgAlarmTypeManager(PgAlarmTypeManager pgAlarmTypeManager) { + this.pgAlarmTypeManager = pgAlarmTypeManager; + } + +// //新增预案文档 +// @RequestMapping("addReservePlan") +// @ResponseBody +// public Map addReservePlan(@RequestParam(value = "planName",required = true) String planName, +// @RequestParam(value = "planType",required =false) String planType, +// @RequestParam(value ="resUnit",required =false) String resUnit, +// @RequestParam(value ="alarmType",required =false) String alarmType, +// @RequestParam(value = "planFiels",required =false) List planFiels) +// throws Exception { +// Map resultMap = new HashMap(); +// PgReservePlan pgReservePlan = new PgReservePlan(); +// String result = ""; +// String msg = ""; +// +// try { +// if (planFiels.size() == 0) +// pgReservePlan.setPlanFiel(""); +// else { +// pgReservePlan.setPlanFiel(pgReservePlanManager.saveFiles(planFiels, "reservePlan")); +// } +// +// pgReservePlan.setPlanName(planName); +// pgReservePlan.setPlanType(planType); +// pgReservePlan.setResUnit(resUnit); +// pgReservePlan.setPgAlarmTypeId(pgAlarmTypeManager.getAlarmTypeByAlarmType(alarmType)); +// pgReservePlan.setActive(1); +// +// result = "true"; +// msg = "保存成功"; +// logger.info("保存成功"); +// pgReservePlanManager.save(pgReservePlan); +// } catch (Exception ex) { +// result = "false"; +// msg = "保存失败"; +// ex.printStackTrace(); +// } +// +// resultMap.put("success", result); +// resultMap.put("msg", msg); +// return resultMap; +// } + + //新增预案文档 + @POST + @Path("addReservePlan") + @Produces(MediaType.APPLICATION_JSON) + public Map addReservePlan( + @FormParam("pgName") String planName, + @FormParam("parName") String planType, + @FormParam("parName") String resUnit, + @FormParam("parName") String alarmType, + @FormParam("parName") String fileBuffer, + @FormParam("parName") String fileName)throws Exception { + Map resultMap = new HashMap(); + PgReservePlan pgReservePlan = new PgReservePlan(); + String result = ""; + String msg = ""; + + try { + if (StringUtils.isBlank(fileBuffer)||StringUtils.isBlank(fileName)) + pgReservePlan.setPlanFiel(""); + else { + pgReservePlan.setPlanFiel(pgReservePlanManager.saveFiles(fileBuffer, fileName,"reservePlan")); + } + + pgReservePlan.setPlanName(planName); + pgReservePlan.setPlanType(planType); + pgReservePlan.setResUnit(resUnit); + pgReservePlan.setPgAlarmTypeId(pgAlarmTypeManager.getAlarmTypeByAlarmType(alarmType)); + pgReservePlan.setActive(1); + + result = "true"; + msg = "保存成功"; + logger.info("保存成功"); + pgReservePlanManager.save(pgReservePlan); + } catch (Exception ex) { + result = "false"; + msg = "保存失败"; + ex.printStackTrace(); + } + + resultMap.put("success", result); + resultMap.put("msg", msg); + return resultMap; + } + + //编辑预案文档 + @RequestMapping("editReservePlan") + @ResponseBody + public Map editReservePlan(@FormParam("id") String id, + @RequestParam(value = "planName",required = true) String planName, + @RequestParam(value = "planType",required =false) String planType, + @RequestParam(value ="resUnit",required =false) String resUnit, + @RequestParam(value ="alarmType",required =false) String alarmType) throws Exception { + + Map resultMap = new HashMap(); + String result = ""; + String msg = ""; + + try { + PgReservePlan pgReservePlan = pgReservePlanManager.get(Long.valueOf(id)); + if (pgReservePlan == null) { + result = "false"; + msg = "不存在该预案信息"; + } else { + pgReservePlan.setPlanName(planName); + pgReservePlan.setPlanType(planType); + pgReservePlan.setResUnit(resUnit); + pgReservePlan.setPgAlarmTypeId(pgAlarmTypeManager.getAlarmTypeByAlarmType(alarmType)); + pgReservePlan.setActive(1); + + pgReservePlanManager.save(pgReservePlan); + result = "true"; + msg = "编辑成功"; + } + } catch (Exception e) { + result = "false"; + msg = "编辑失败"; + e.printStackTrace(); + } + return resultMap; + } + + //删除预案文档 + @RequestMapping("deleteReservePlan") + @ResponseBody + public Map deleteReservePlan(@FormParam("id") String id)throws Exception{ + Map resultMap = new HashMap(); + String msg=""; + String result="false"; + + try{ + + PgReservePlan pgReservePlan=pgReservePlanManager.get(Long.valueOf(id)); + if(pgReservePlan==null) + { + result="false"; + msg="不存在该预案信息"; + } + else{ + pgReservePlan.setActive(0); + pgReservePlanManager.save(pgReservePlan); + result="true"; + msg="删除成功"; + } + } + catch(Exception e) + { + e.printStackTrace(); + msg="预案删除失败"; + result="false"; + } + + 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/PgTextureRs.java b/src/main/java/com/casic/PgInterface/rs/PgTextureRs.java index 5892127..2360251 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgTextureRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgTextureRs.java @@ -163,12 +163,14 @@ msg = "不存在管廊仓和分区信息"; } else { try { + /* if(pgTextureManager.getPgTextureByName(textureName)!=null) { result = "false"; msg = "已存在同名的部件"; } else { + */ PgTexture pgTexture = pgTextureManager.get(Long.valueOf(id)); pgTexture.setTextureName(textureName); pgTexture.setTextureMaterial(textureMaterial); @@ -181,7 +183,7 @@ pgTextureManager.save(pgTexture); result = "true"; msg = "编辑成功"; - } + //} } catch (Exception e) { result = "false"; msg = "编辑失败"; diff --git a/src/main/java/com/casic/PgInterface/rs/PipeGalleryRs.java b/src/main/java/com/casic/PgInterface/rs/PipeGalleryRs.java index 6904b9f..42f7d40 100644 --- a/src/main/java/com/casic/PgInterface/rs/PipeGalleryRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PipeGalleryRs.java @@ -132,10 +132,12 @@ result = "false"; msg = "不存在该分区信息"; } else { + /* if (pipeGalleryManager.getPipeGalleryByPgName(pgName, pgPartition) != null) { result = "false"; msg = "已存在相同管廊"; } else { + */ pipeGallery = pipeGalleryManager.get(Long.valueOf(id)); pipeGallery.setPgName(pgName); @@ -145,7 +147,7 @@ pipeGalleryManager.save(pipeGallery); result = "true"; msg = "编辑成功"; - } + //} } } catch (Exception e) { result = "false"; diff --git a/src/main/java/com/casic/PgInterface/rsFiles/web/PgReserveController.java b/src/main/java/com/casic/PgInterface/rsFiles/web/PgReserveController.java deleted file mode 100644 index f13dac6..0000000 --- a/src/main/java/com/casic/PgInterface/rsFiles/web/PgReserveController.java +++ /dev/null @@ -1,158 +0,0 @@ -package com.casic.PgInterface.rsFiles.web; - -import com.casic.PgInterface.devTable.manager.PgAlarmTypeManager; -import com.casic.PgInterface.reservePlan.domain.PgReservePlan; -import com.casic.PgInterface.reservePlan.manager.PgReservePlanManager; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.multipart.MultipartFile; -import javax.annotation.Resource; -import javax.ws.rs.FormParam; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * Created by yxw on 2017/11/8. - */ -@Controller -@RequestMapping("rs/pgReservePlan") -public class PgReserveController { - - private static Logger logger = LoggerFactory.getLogger(PgReservePlan.class); - - private PgReservePlanManager pgReservePlanManager; - - private PgAlarmTypeManager pgAlarmTypeManager; - - @Resource - public void setPgReservePlanManager(PgReservePlanManager pgReservePlanManager) { - this.pgReservePlanManager = pgReservePlanManager; - } - - @Resource - public void setPgAlarmTypeManager(PgAlarmTypeManager pgAlarmTypeManager) { - this.pgAlarmTypeManager = pgAlarmTypeManager; - } - - //新增预案文档 - @RequestMapping("addReservePlan") - @ResponseBody - public Map addReservePlan(@RequestParam(value = "planName",required = true) String planName, - @RequestParam(value = "planType",required =false) String planType, - @RequestParam(value ="resUnit",required =false) String resUnit, - @RequestParam(value ="alarmType",required =false) String alarmType, - @RequestParam(value = "planFiels",required =false) List planFiels) - throws Exception { - Map resultMap = new HashMap(); - PgReservePlan pgReservePlan = new PgReservePlan(); - String result = ""; - String msg = ""; - - try { - if (planFiels.size() == 0) - pgReservePlan.setPlanFiel(""); - else { - pgReservePlan.setPlanFiel(pgReservePlanManager.saveFiles(planFiels, "reservePlan")); - } - - pgReservePlan.setPlanName(planName); - pgReservePlan.setPlanType(planType); - pgReservePlan.setResUnit(resUnit); - pgReservePlan.setPgAlarmTypeId(pgAlarmTypeManager.getAlarmTypeByAlarmType(alarmType)); - pgReservePlan.setActive(1); - - result = "true"; - msg = "保存成功"; - logger.info("保存成功"); - pgReservePlanManager.save(pgReservePlan); - } catch (Exception ex) { - result = "false"; - msg = "保存失败"; - ex.printStackTrace(); - } - - resultMap.put("success", result); - resultMap.put("msg", msg); - return resultMap; - } - - //编辑预案文档 - @RequestMapping("editReservePlan") - @ResponseBody - public Map editReservePlan(@FormParam("id") String id, - @RequestParam(value = "planName",required = true) String planName, - @RequestParam(value = "planType",required =false) String planType, - @RequestParam(value ="resUnit",required =false) String resUnit, - @RequestParam(value ="alarmType",required =false) String alarmType) throws Exception { - - Map resultMap = new HashMap(); - String result = ""; - String msg = ""; - - try { - PgReservePlan pgReservePlan = pgReservePlanManager.get(Long.valueOf(id)); - if (pgReservePlan == null) { - result = "false"; - msg = "不存在该预案信息"; - } else { - pgReservePlan.setPlanName(planName); - pgReservePlan.setPlanType(planType); - pgReservePlan.setResUnit(resUnit); - pgReservePlan.setPgAlarmTypeId(pgAlarmTypeManager.getAlarmTypeByAlarmType(alarmType)); - pgReservePlan.setActive(1); - - pgReservePlanManager.save(pgReservePlan); - result = "true"; - msg = "编辑成功"; - } - } catch (Exception e) { - result = "false"; - msg = "编辑失败"; - e.printStackTrace(); - } - return resultMap; - } - - //删除预案文档 - @RequestMapping("deleteReservePlan") - @ResponseBody - public Map deleteReservePlan(@FormParam("id") String id)throws Exception{ - Map resultMap = new HashMap(); - String msg=""; - String result="false"; - - try{ - - PgReservePlan pgReservePlan=pgReservePlanManager.get(Long.valueOf(id)); - if(pgReservePlan==null) - { - result="false"; - msg="不存在该预案信息"; - } - else{ - pgReservePlan.setActive(0); - pgReservePlanManager.save(pgReservePlan); - result="true"; - msg="删除成功"; - } - } - catch(Exception e) - { - e.printStackTrace(); - msg="预案删除失败"; - result="false"; - } - - resultMap.put("msg",msg); - resultMap.put("result",result); - return resultMap; - - } - - -} \ No newline at end of file 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" deleted file mode 100644 index 964daa9..0000000 --- "a/~$\346\216\245\345\217\243\350\257\264\346\230\216.docx" +++ /dev/null Binary files differ diff --git "a/~$\346\225\260\346\215\256\345\272\223\350\256\276\350\256\241\350\257\264\346\230\216.docx" "b/~$\346\225\260\346\215\256\345\272\223\350\256\276\350\256\241\350\257\264\346\230\216.docx" deleted file mode 100644 index 4f71cd9..0000000 --- "a/~$\346\225\260\346\215\256\345\272\223\350\256\276\350\256\241\350\257\264\346\230\216.docx" +++ /dev/null Binary files differ diff --git a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java b/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java deleted file mode 100644 index b2affe5..0000000 --- a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.casic.PgInterface.devData.dto; - -/** - * Created by yxw on 2017/11/28. - */ -public class PgTempHunDto { -} 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 eb1f7ab..da8f617 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -39,7 +39,6 @@ private List pgShs; private List pgTempHums; - @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") public long getId() { diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java index 4278dc1..669b60f 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java @@ -2,21 +2,20 @@ import javax.persistence.*; import java.io.Serializable; -import java.util.List; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Entity @Table(name = "PG_DEVICE_TYPE") @SequenceGenerator(name = "SEQ_PG_DEVICE_TYPE_ID", sequenceName = "SEQ_PG_DEVICE_TYPE_ID", allocationSize = 1, initialValue = 1) public class PgDeviceType implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; private long id; private String devType; private int active; - private List pgDeviceList; + @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_TYPE_ID") @@ -45,13 +44,4 @@ public void setActive(int active) { this.active = active; } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "devTypeId") - public List getPgDeviceList() { - return pgDeviceList; - } - - public void setPgDeviceList(List pgDeviceList) { - this.pgDeviceList = pgDeviceList; - } } 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 4fb3d6f..d209733 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java @@ -2,6 +2,7 @@ import javax.persistence.*; import java.io.Serializable; +import java.util.Date; import java.util.List; /** @@ -17,6 +18,12 @@ private long id; private String parName;//分区名称 private String road;//所属道路 + private String pgPosition;//仓段位置 + private String pgNum;//仓位数量 + private String pgType;//仓位类型 + private String pgLength;//分区长度 + private Date buildDate;//建设年代 + private String material;//建设材质 private int active;//状态位 private List pipeGalleryList;//管廊仓 @@ -48,6 +55,60 @@ this.road = road; } + @Column(name = "PGPOSITION") + public String getPgPosition() { + return pgPosition; + } + + public void setPgPosition(String pgPosition) { + this.pgPosition = pgPosition; + } + + @Column(name = "PGNUM") + public String getPgNum() { + return pgNum; + } + + public void setPgNum(String pgNum) { + this.pgNum = pgNum; + } + + @Column(name = "PGTYPE") + public String getPgType() { + return pgType; + } + + public void setPgType(String pgType) { + this.pgType = pgType; + } + + @Column(name = "PGLENGTH") + public String getPgLength() { + return pgLength; + } + + public void setPgLength(String pgLength) { + this.pgLength = pgLength; + } + + @Column(name = "BUILDDATE") + public Date getBuildDate() { + return buildDate; + } + + public void setBuildDate(Date buildDate) { + this.buildDate = buildDate; + } + + @Column(name = "MATERIAL") + public String getMaterial() { + return material; + } + + public void setMaterial(String material) { + this.material = material; + } + @Column(name = "ACTIVE") public int getActive() { return active; 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 95f9fbd..b60c42d 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java @@ -160,7 +160,7 @@ this.setAssetName(pgDevice.getAssetName()); this.setAssetCode(pgDevice.getAssetCode()); this.setAssetBarCode(pgDevice.getAssetBarCode()); - this.setId(pgDevice.getIp()); + this.setIp(pgDevice.getIp()); this.setModBus(pgDevice.getModBus()); this.setMome(pgDevice.getMome()); this.setIsOpen(String.valueOf(pgDevice.getIsOpen())); diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java index c1548e0..e348f7a 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java @@ -5,7 +5,7 @@ import java.io.Serializable; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ public class PgDeviceTypeDto implements Serializable { @@ -37,12 +37,11 @@ this.active = active; } - public PgDeviceTypeDto(PgDeviceType pgDeviceType) - { + public PgDeviceTypeDto(PgDeviceType pgDeviceType) { + this.setId(String.valueOf(pgDeviceType.getId())); this.setDevType(pgDeviceType.getDevType()); this.setActive(String.valueOf(pgDeviceType.getActive())); } - } 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 3acd0fa..95c18b4 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java @@ -3,6 +3,7 @@ import com.casic.PgInterface.devTable.domain.PgPartition; import java.io.Serializable; +import java.text.SimpleDateFormat; /** * Created by yxw on 2017/11/2. @@ -12,6 +13,12 @@ private String id; private String parName;//分区名称 private String road;//所属道路 + private String pgPosition;//仓段位置 + private String pgNum;//仓位数量 + private String pgType;//仓位类型 + private String pgLength;//分区长度 + private String buildDate;//建设年代 + private String material;//建设材质 private String active;//状态位 @@ -47,11 +54,67 @@ this.road = road; } + public String getPgPosition() { + return pgPosition; + } + + public void setPgPosition(String pgPosition) { + this.pgPosition = pgPosition; + } + + public String getPgNum() { + return pgNum; + } + + public void setPgNum(String pgNum) { + this.pgNum = pgNum; + } + + public String getPgType() { + return pgType; + } + + public void setPgType(String pgType) { + this.pgType = pgType; + } + + public String getPgLength() { + return pgLength; + } + + public void setPgLength(String pgLength) { + this.pgLength = pgLength; + } + + public String getBuildDate() { + return buildDate; + } + + public void setBuildDate(String buildDate) { + this.buildDate = buildDate; + } + + public String getMaterial() { + return material; + } + + public void setMaterial(String material) { + this.material = material; + } + public PgPartitionDto(PgPartition pgPartition) { + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); + this.setId(String.valueOf(pgPartition.getId())); this.setParName(pgPartition.getParName()); this.setRoad(pgPartition.getRoad()); + this.setPgPosition(pgPartition.getPgPosition()); + this.setPgNum(pgPartition.getPgNum()); + this.setPgType(pgPartition.getPgType()); + this.setPgLength(pgPartition.getPgLength()); + this.setBuildDate(sdf.format(pgPartition.getBuildDate())); + this.setMaterial(pgPartition.getMaterial()); this.setActive(String.valueOf(pgPartition.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java b/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java index d7c6024..9ea43fd 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java @@ -12,10 +12,10 @@ import java.util.List; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Service -public class PgDeviceTypeManager extends HibernateEntityDao{ +public class PgDeviceTypeManager extends HibernateEntityDao { public List getAllDeviceType() { @@ -23,8 +23,8 @@ criteria.add(Restrictions.eq("active", 1)); criteria.addOrder(Order.desc("id")); - List pgDeviceTypeList= criteria.list(); - List pgDeviceTypeDtoList=new ArrayList(); + List pgDeviceTypeList = criteria.list(); + List pgDeviceTypeDtoList = new ArrayList(); for (PgDeviceType pgDeviceType : pgDeviceTypeList) { pgDeviceTypeDtoList.add(new PgDeviceTypeDto(pgDeviceType)); } @@ -32,15 +32,14 @@ return pgDeviceTypeDtoList; } - public PgDeviceType getPgDeviceTypeByDevType(String devType) - { - Criteria criteria=createCriteria(PgDeviceType.class); - criteria.add(Restrictions.eq("devType",devType)); - criteria.add(Restrictions.eq("active",1)); - criteria.addOrder(Order.desc("id")); + public PgDeviceType getDeviceTypeByDeType(String devType) { - List pgDeviceTypeList=criteria.list(); - if(pgDeviceTypeList==null||pgDeviceTypeList.size()==0) + Criteria criteria = createCriteria(PgDeviceType.class); + criteria.add(Restrictions.eq("active", 1)); + criteria.add(Restrictions.eq("devType", devType)); + + List pgDeviceTypeList = criteria.list(); + if (pgDeviceTypeList.size() == 0) return null; else return pgDeviceTypeList.get(0); 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 0c594e7..c6f22cb 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java @@ -64,4 +64,4 @@ -} +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java index 9d06235..68b14cf 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java @@ -1,9 +1,5 @@ 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; @@ -19,7 +15,8 @@ private long id; private String highValue;//高限 private String lowValue;//低限 - private PgDevice pgDeviceId;//设备 + private String unit;//单位 + private String devType;//设备类型 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_ALARM_RULE_ID") @@ -49,15 +46,24 @@ this.lowValue = lowValue; } - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PGDEVICEID") - public PgDevice getPgDeviceId() { - return pgDeviceId; + @Column(name="UNIT") + public String getUnit() { + return unit; } - public void setPgDeviceId(PgDevice pgDeviceId) { - this.pgDeviceId = pgDeviceId; + public void setUnit(String unit) { + this.unit = unit; } + @Column(name = "DEVTYPE") + public String getDevType() { + return devType; + } + + public void setDevType(String devType) { + this.devType = devType; + } + + + } diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java deleted file mode 100644 index 7907e66..0000000 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.casic.PgInterface.patroler.dto; - -/** - * Created by yxw on 2017/12/14. - */ -public class PgAlarmRule { -} diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java index 8367ad4..0782c63 100644 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java @@ -12,7 +12,8 @@ private String id; private String highValue;//高限 private String lowValue;//低限 - private String devName;//设备 + private String devType;//设备类型 + private String unit;//单位 public String getId() { return id; @@ -38,20 +39,29 @@ this.lowValue = lowValue; } - public String getDevName() { - return devName; + public String getDevType() { + return devType; } - public void setDevName(String devName) { - this.devName = devName; + public void setDevType(String devType) { + this.devType = devType; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; } public PgAlarmRuleDto(PgAlarmRule pgAlarmRule) { this.setId(String.valueOf(pgAlarmRule.getId())); - this.setDevName(pgAlarmRule.getPgDeviceId().getAssetName()); this.setHighValue(pgAlarmRule.getHighValue()); this.setLowValue(pgAlarmRule.getLowValue()); + this.setDevType(pgAlarmRule.getDevType()); + this.setUnit(pgAlarmRule.getUnit()); } } diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java index d5c00b2..84e5cdd 100644 --- a/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java @@ -1,13 +1,13 @@ 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.ArrayList; import java.util.List; /** @@ -17,20 +17,21 @@ public class PgAlarmRuleManager extends HibernateEntityDao { //根据设备获取设备报警阈值 - public PgAlarmRuleDto getAlarmRuleDtoBydev(PgDevice pgDeviceId) { + public List getAlarmRuleDto() { 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)); + List pgAlarmRuleDtoList = new ArrayList(); + for (PgAlarmRule pgAlarmRule : pgAlarmRuleList) { + pgAlarmRuleDtoList.add(new PgAlarmRuleDto(pgAlarmRule)); + } + return pgAlarmRuleDtoList; + } - public PgAlarmRule getAlarmRuleBydev(PgDevice pgDeviceId) { + public PgAlarmRule getAlarmRuleBydevType(String devType) { Criteria criteria=createCriteria(PgAlarmRule.class); - criteria.add(Restrictions.eq("pgDeviceId", pgDeviceId)); + criteria.add(Restrictions.eq("devType", devType)); List pgAlarmRuleList=criteria.list(); if(pgAlarmRuleList.size()==0) diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java index f4e48c6..9396013 100644 --- a/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java @@ -39,13 +39,13 @@ } if (StringUtils.isNotBlank(startTime)) { - criteria.add(Restrictions.ge("operateTime", DateUtils.sdf4.parse(startTime))); + criteria.add(Restrictions.ge("operateTime", DateUtils.sdf_day.parse(startTime))); } if (StringUtils.isNotBlank(endTime)) { Calendar calendar = Calendar.getInstance(); - calendar.setTime(DateUtils.sdf4.parse(endTime)); + calendar.setTime(DateUtils.sdf_day.parse(endTime)); calendar.add(Calendar.DATE, 1); - criteria.add(Restrictions.le("time", calendar.getTime())); + criteria.add(Restrictions.le("operateTime", calendar.getTime())); } criteria.add(Restrictions.eq("active", 1)); diff --git a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java index 88255c6..f28ebdf 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java @@ -1,6 +1,5 @@ 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; @@ -15,7 +14,9 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -42,72 +43,43 @@ } /** - * 获取报警阈值信息 - */ - @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 { + public Map addAlarmRule(@FormParam("highValue") String highValue, + @FormParam("lowValue") String lowValue, + @FormParam("unit") String unit, + @FormParam("devType") String devType) 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(); + try { + pgAlarmRule = pgAlarmRuleManager.getAlarmRuleBydevType(devType); + if (pgAlarmRule != null) { result = "false"; - msg = "报警阈值新增失败"; + msg = "设备阈值已经存在"; + } else { + pgAlarmRule = new PgAlarmRule(); + pgAlarmRule.setHighValue(highValue); + pgAlarmRule.setLowValue(lowValue); + pgAlarmRule.setDevType(devType); + pgAlarmRule.setUnit(unit); + + pgAlarmRuleManager.save(pgAlarmRule); + result = "true"; + msg = "报警阈值新增成功"; } + } catch (Exception e) { + e.printStackTrace(); + result = "false"; + msg = "报警阈值新增失败"; } + resultMap.put("msg", msg); resultMap.put("result", result); return resultMap; @@ -119,44 +91,66 @@ @POST @Path("editAlarmRule") @Produces(MediaType.APPLICATION_JSON) - public Map editAlarmRule(@FormParam("id") String id, - @FormParam("assetCode") String assetCode, + public Map editAlarmRule(@FormParam("devType") String devType, @FormParam("highValue") String highValue, - @FormParam("lowValue") String lowValue) throws Exception { + @FormParam("lowValue") String lowValue, + @FormParam("unit") String unit) 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(); + + try { + pgAlarmRule = pgAlarmRuleManager.getAlarmRuleBydevType(devType); + if (pgAlarmRule == null) { + msg = "不存在报警阈值记录"; result = "false"; - msg = "报警阈值编辑失败"; + } else { + pgAlarmRule.setDevType(devType); + pgAlarmRule.setHighValue(highValue); + pgAlarmRule.setLowValue(lowValue); + pgAlarmRule.setUnit(unit); + pgAlarmRuleManager.save(pgAlarmRule); + msg = "编辑成功"; + result = "true"; } + } catch (Exception ex) { + ex.printStackTrace(); + result = "false"; + msg = "报警阈值编辑失败"; } + resultMap.put("msg", msg); resultMap.put("result", result); return resultMap; + } + /** + * 获取报警阈值信息 + */ + @POST + @Path("getAlarmRule") + @Produces(MediaType.APPLICATION_JSON) + public Map getAlarmRule() throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + + List pgAlarmRuleDtoList = new ArrayList(); + try { + pgAlarmRuleDtoList = pgAlarmRuleManager.getAlarmRuleDto(); + if (pgAlarmRuleDtoList == null) + msg = "不存在报警阈值信息"; + else + msg = "报警阈值获取成功"; + } catch (Exception e) { + e.printStackTrace(); + msg = "报警信息获取失败"; + } + resultMap.put("msg", msg); + resultMap.put("result", pgAlarmRuleDtoList); + 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 bb8c245..36547a7 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java @@ -104,8 +104,8 @@ @POST @Path("addDevice") @Produces(MediaType.APPLICATION_JSON) - public Map addDevice(@FormParam("parName") String parName, - @FormParam("pgName") String pgName, + public Map addDevice(@FormParam("partition") String partition, + @FormParam("pipeGallery") String pipeGallery, @FormParam("road") String road, @FormParam("position") String position, @FormParam("devType") String devType, @@ -129,8 +129,8 @@ } else { PgDevice pgDevice = new PgDevice(); - pgDevice.setPipeGallery(pgName); - pgDevice.setPartition(parName); + pgDevice.setPipeGallery(pipeGallery); + pgDevice.setPartition(partition); pgDevice.setRoad(road); pgDevice.setPosition(position); pgDevice.setDevType(devType); @@ -168,8 +168,8 @@ @Path("editDevice") @Produces(MediaType.APPLICATION_JSON) public Map editPartition(@FormParam("id") String id, - @FormParam("parName") String parName, - @FormParam("pgName") String pgName, + @FormParam("partition") String partition, + @FormParam("pipeGallery") String pipeGallery, @FormParam("road") String road, @FormParam("position") String position, @FormParam("devType") String devType, @@ -187,13 +187,15 @@ String msg = ""; try { + /* if (pgDeviceManager.getDeviceByAssetCode(assetCode)!=null) { result = "false"; msg = "已存在同名设备"; } else { + */ PgDevice pgDevice = pgDeviceManager.get(Long.valueOf(id)); - pgDevice.setPipeGallery(pgName); - pgDevice.setPartition(parName); + pgDevice.setPipeGallery(pipeGallery); + pgDevice.setPartition(partition); pgDevice.setRoad(road); pgDevice.setPosition(position); pgDevice.setDevType(devType); @@ -210,7 +212,7 @@ pgDeviceManager.save(pgDevice); result = "true"; msg = "编辑成功"; - } + //} } catch (Exception e) { result = "false"; msg = "编辑失败"; diff --git a/src/main/java/com/casic/PgInterface/rs/PgDeviceTypeRs.java b/src/main/java/com/casic/PgInterface/rs/PgDeviceTypeRs.java index 756894f..b6c84aa 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgDeviceTypeRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgDeviceTypeRs.java @@ -19,12 +19,13 @@ import java.util.Map; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Component @Path("pgDeviceType") public class PgDeviceTypeRs { - private static Logger logger = LoggerFactory.getLogger(PgDeviceRs.class); + + private static Logger logger = LoggerFactory.getLogger(PgDeviceTypeRs.class); private PgDeviceTypeManager pgDeviceTypeManager; @@ -34,21 +35,21 @@ } /** - * 获取设备类型 + * 显示设备列表 */ @POST @Path("getDeviceType") @Produces(MediaType.APPLICATION_JSON) - public Map getDeviceType()throws Exception { + public Map getDeviceTpeyList()throws Exception { Map resultMap = new HashMap(); String msg=""; List pgDeviceTypeDtoList=new ArrayList(); try { pgDeviceTypeDtoList = pgDeviceTypeManager.getAllDeviceType(); if(pgDeviceTypeDtoList.size()==0) - msg="没有设备类型信息"; + msg="没有找到设备类型信息"; else - msg="设备类型获取失败"; + msg="设备类型信息获取成功"; }catch(Exception e){ e.printStackTrace(); msg="设备类型信息获取失败"; @@ -64,37 +65,39 @@ @POST @Path("addDeviceType") @Produces(MediaType.APPLICATION_JSON) - public Map addDeviceType(@FormParam("devType") String devType) + public Map addDevice(@FormParam("devType") String devType) throws Exception { Map resultMap = new HashMap(); String result = ""; String msg = ""; - try { - if (pgDeviceTypeManager.getPgDeviceTypeByDevType(devType)!=null) { - result = "false"; - msg = "已存在同名设备类型"; - } else { - PgDeviceType pgDeviceType=new PgDeviceType(); - pgDeviceType.setDevType(devType); - pgDeviceType.setActive(1); - - pgDeviceTypeManager.save(pgDeviceType); - result = "true"; - msg = "保存成功"; - } - - } catch (Exception e) { + try { + if (pgDeviceTypeManager.getDeviceTypeByDeType(devType)!=null) { result = "false"; - msg = "保存失败"; - e.printStackTrace(); + msg = "已存在设备类型"; + } else { + PgDeviceType pgDeviceType = new PgDeviceType(); + + pgDeviceType.setDevType(devType); + pgDeviceType.setActive(1); + + pgDeviceTypeManager.save(pgDeviceType); + result = "true"; + msg = "保存成功"; } + } catch (Exception e) { + result = "false"; + msg = "保存失败"; + e.printStackTrace(); + } + resultMap.put("success", result); resultMap.put("msg", msg); return resultMap; } + } diff --git a/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java b/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java index 8a42e7e..249b75c 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java @@ -13,10 +13,8 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.text.SimpleDateFormat; +import java.util.*; /** * Created by yxw on 2017/11/6. @@ -40,25 +38,35 @@ @POST @Path("addPartition") @Produces(MediaType.APPLICATION_JSON) - public Map addAlarm(@FormParam("parName") String parName)throws Exception { + public Map addAlarm(@FormParam("parName") String parName, + @FormParam("road") String road, + @FormParam("pgPosition") String pgPosition, + @FormParam("pgNum") String pgNum, + @FormParam("pgType") String pgType, + @FormParam("pgLength") String pgLength, + @FormParam("buildDate") String buildDate, + @FormParam("material") String material)throws Exception { Map resultMap = new HashMap(); String result = ""; String msg = ""; + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); try { - if (pgPartitionManager.getPartitionByParName(parName) != null) { - result = "false"; - msg = "已存在相同分区"; - } else { PgPartition pgPartition = new PgPartition(); pgPartition.setParName(parName); + pgPartition.setRoad(road); + pgPartition.setPgPosition(pgPosition); + pgPartition.setPgNum(pgNum); + pgPartition.setPgType(pgType); + pgPartition.setPgLength(pgLength); + pgPartition.setBuildDate(sdf.parse(buildDate)); + pgPartition.setMaterial(material); pgPartition.setActive(1); logger.info("成功保存"); pgPartitionManager.save(pgPartition); result = "true"; msg = "保存成功"; - } } catch (Exception e) { result = "false"; @@ -71,28 +79,40 @@ return resultMap; } - - @POST @Path("editPartition") @Produces(MediaType.APPLICATION_JSON) public Map editPartition(@FormParam("id") String id, - @FormParam("parName") String parName) throws Exception { + @FormParam("parName") String parName, + @FormParam("road") String road, + @FormParam("pgPosition") String pgPosition, + @FormParam("pgNum") String pgNum, + @FormParam("pgType") String pgType, + @FormParam("pgLength") String pgLength, + @FormParam("buildDate") String buildDate, + @FormParam("material") String material) throws Exception { Map resultMap = new HashMap(); String result = ""; String msg = ""; PgPartition partition = new PgPartition(); + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); try { - if (pgPartitionManager.getPartitionByParName(parName) != null) { result = "false"; msg = "已存在相同分区"; } else { PgPartition pgPartition = pgPartitionManager.get(Long.valueOf(id)); pgPartition.setParName(parName); + pgPartition.setRoad(road); + pgPartition.setPgPosition(pgPosition); + pgPartition.setPgNum(pgNum); + pgPartition.setPgType(pgType); + pgPartition.setPgLength(pgLength); + pgPartition.setBuildDate(sdf.parse(buildDate)); + pgPartition.setMaterial(material); pgPartition.setActive(1); pgPartitionManager.save(pgPartition); diff --git a/src/main/java/com/casic/PgInterface/rs/PgPatrolerRs.java b/src/main/java/com/casic/PgInterface/rs/PgPatrolerRs.java index aed1ed8..0b3c731 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgPatrolerRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgPatrolerRs.java @@ -123,10 +123,12 @@ String result = ""; String msg = ""; try { + /* if (pgPatrolerManager.userNameIsExits(userName)) { result = "false"; msg = "用户名已经存在!"; } else { + */ PgPatroler pgPatroler = pgPatrolerManager.get(Long.valueOf(id)); pgPatroler.setUserName(userName); pgPatroler.setPassword(password); @@ -136,7 +138,7 @@ pgPatrolerManager.save(pgPatroler); result = "true"; msg = "编辑成功"; - } + //} } catch (Exception e) { result = "false"; msg = "编辑失败"; diff --git a/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java b/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java index 8cbdb0a..4c9feac 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java @@ -165,12 +165,14 @@ msg = "不存在管廊仓和分区信息"; } else { try { + /* if(pgPipeLineManager.getPipeLineBylineName(lineName)!=null) { result = "false"; msg = "已存在同名管线"; } else { + */ PgPipeLine pgPipeLine = pgPipeLineManager.get(Long.valueOf(id)); pgPipeLine.setLineName(lineName); @@ -185,7 +187,7 @@ pgPipeLineManager.save(pgPipeLine); result = "true"; msg = "编辑成功"; - } + //} } catch (Exception e) { result = "false"; msg = "编辑失败"; diff --git a/src/main/java/com/casic/PgInterface/rs/PgReserveController.java b/src/main/java/com/casic/PgInterface/rs/PgReserveController.java new file mode 100644 index 0000000..863045a --- /dev/null +++ b/src/main/java/com/casic/PgInterface/rs/PgReserveController.java @@ -0,0 +1,207 @@ +package com.casic.PgInterface.rs; + +import com.casic.PgInterface.core.util.StringUtils; +import com.casic.PgInterface.devTable.manager.PgAlarmTypeManager; +import com.casic.PgInterface.reservePlan.domain.PgReservePlan; +import com.casic.PgInterface.reservePlan.manager.PgReservePlanManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.multipart.MultipartFile; +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.List; +import java.util.Map; + +/** + * Created by yxw on 2017/11/8. + */ +@Controller +@RequestMapping("rs/pgReservePlan") +public class PgReserveController { + + private static Logger logger = LoggerFactory.getLogger(PgReservePlan.class); + + private PgReservePlanManager pgReservePlanManager; + + private PgAlarmTypeManager pgAlarmTypeManager; + + @Resource + public void setPgReservePlanManager(PgReservePlanManager pgReservePlanManager) { + this.pgReservePlanManager = pgReservePlanManager; + } + + @Resource + public void setPgAlarmTypeManager(PgAlarmTypeManager pgAlarmTypeManager) { + this.pgAlarmTypeManager = pgAlarmTypeManager; + } + +// //新增预案文档 +// @RequestMapping("addReservePlan") +// @ResponseBody +// public Map addReservePlan(@RequestParam(value = "planName",required = true) String planName, +// @RequestParam(value = "planType",required =false) String planType, +// @RequestParam(value ="resUnit",required =false) String resUnit, +// @RequestParam(value ="alarmType",required =false) String alarmType, +// @RequestParam(value = "planFiels",required =false) List planFiels) +// throws Exception { +// Map resultMap = new HashMap(); +// PgReservePlan pgReservePlan = new PgReservePlan(); +// String result = ""; +// String msg = ""; +// +// try { +// if (planFiels.size() == 0) +// pgReservePlan.setPlanFiel(""); +// else { +// pgReservePlan.setPlanFiel(pgReservePlanManager.saveFiles(planFiels, "reservePlan")); +// } +// +// pgReservePlan.setPlanName(planName); +// pgReservePlan.setPlanType(planType); +// pgReservePlan.setResUnit(resUnit); +// pgReservePlan.setPgAlarmTypeId(pgAlarmTypeManager.getAlarmTypeByAlarmType(alarmType)); +// pgReservePlan.setActive(1); +// +// result = "true"; +// msg = "保存成功"; +// logger.info("保存成功"); +// pgReservePlanManager.save(pgReservePlan); +// } catch (Exception ex) { +// result = "false"; +// msg = "保存失败"; +// ex.printStackTrace(); +// } +// +// resultMap.put("success", result); +// resultMap.put("msg", msg); +// return resultMap; +// } + + //新增预案文档 + @POST + @Path("addReservePlan") + @Produces(MediaType.APPLICATION_JSON) + public Map addReservePlan( + @FormParam("pgName") String planName, + @FormParam("parName") String planType, + @FormParam("parName") String resUnit, + @FormParam("parName") String alarmType, + @FormParam("parName") String fileBuffer, + @FormParam("parName") String fileName)throws Exception { + Map resultMap = new HashMap(); + PgReservePlan pgReservePlan = new PgReservePlan(); + String result = ""; + String msg = ""; + + try { + if (StringUtils.isBlank(fileBuffer)||StringUtils.isBlank(fileName)) + pgReservePlan.setPlanFiel(""); + else { + pgReservePlan.setPlanFiel(pgReservePlanManager.saveFiles(fileBuffer, fileName,"reservePlan")); + } + + pgReservePlan.setPlanName(planName); + pgReservePlan.setPlanType(planType); + pgReservePlan.setResUnit(resUnit); + pgReservePlan.setPgAlarmTypeId(pgAlarmTypeManager.getAlarmTypeByAlarmType(alarmType)); + pgReservePlan.setActive(1); + + result = "true"; + msg = "保存成功"; + logger.info("保存成功"); + pgReservePlanManager.save(pgReservePlan); + } catch (Exception ex) { + result = "false"; + msg = "保存失败"; + ex.printStackTrace(); + } + + resultMap.put("success", result); + resultMap.put("msg", msg); + return resultMap; + } + + //编辑预案文档 + @RequestMapping("editReservePlan") + @ResponseBody + public Map editReservePlan(@FormParam("id") String id, + @RequestParam(value = "planName",required = true) String planName, + @RequestParam(value = "planType",required =false) String planType, + @RequestParam(value ="resUnit",required =false) String resUnit, + @RequestParam(value ="alarmType",required =false) String alarmType) throws Exception { + + Map resultMap = new HashMap(); + String result = ""; + String msg = ""; + + try { + PgReservePlan pgReservePlan = pgReservePlanManager.get(Long.valueOf(id)); + if (pgReservePlan == null) { + result = "false"; + msg = "不存在该预案信息"; + } else { + pgReservePlan.setPlanName(planName); + pgReservePlan.setPlanType(planType); + pgReservePlan.setResUnit(resUnit); + pgReservePlan.setPgAlarmTypeId(pgAlarmTypeManager.getAlarmTypeByAlarmType(alarmType)); + pgReservePlan.setActive(1); + + pgReservePlanManager.save(pgReservePlan); + result = "true"; + msg = "编辑成功"; + } + } catch (Exception e) { + result = "false"; + msg = "编辑失败"; + e.printStackTrace(); + } + return resultMap; + } + + //删除预案文档 + @RequestMapping("deleteReservePlan") + @ResponseBody + public Map deleteReservePlan(@FormParam("id") String id)throws Exception{ + Map resultMap = new HashMap(); + String msg=""; + String result="false"; + + try{ + + PgReservePlan pgReservePlan=pgReservePlanManager.get(Long.valueOf(id)); + if(pgReservePlan==null) + { + result="false"; + msg="不存在该预案信息"; + } + else{ + pgReservePlan.setActive(0); + pgReservePlanManager.save(pgReservePlan); + result="true"; + msg="删除成功"; + } + } + catch(Exception e) + { + e.printStackTrace(); + msg="预案删除失败"; + result="false"; + } + + 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/PgTextureRs.java b/src/main/java/com/casic/PgInterface/rs/PgTextureRs.java index 5892127..2360251 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgTextureRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgTextureRs.java @@ -163,12 +163,14 @@ msg = "不存在管廊仓和分区信息"; } else { try { + /* if(pgTextureManager.getPgTextureByName(textureName)!=null) { result = "false"; msg = "已存在同名的部件"; } else { + */ PgTexture pgTexture = pgTextureManager.get(Long.valueOf(id)); pgTexture.setTextureName(textureName); pgTexture.setTextureMaterial(textureMaterial); @@ -181,7 +183,7 @@ pgTextureManager.save(pgTexture); result = "true"; msg = "编辑成功"; - } + //} } catch (Exception e) { result = "false"; msg = "编辑失败"; diff --git a/src/main/java/com/casic/PgInterface/rs/PipeGalleryRs.java b/src/main/java/com/casic/PgInterface/rs/PipeGalleryRs.java index 6904b9f..42f7d40 100644 --- a/src/main/java/com/casic/PgInterface/rs/PipeGalleryRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PipeGalleryRs.java @@ -132,10 +132,12 @@ result = "false"; msg = "不存在该分区信息"; } else { + /* if (pipeGalleryManager.getPipeGalleryByPgName(pgName, pgPartition) != null) { result = "false"; msg = "已存在相同管廊"; } else { + */ pipeGallery = pipeGalleryManager.get(Long.valueOf(id)); pipeGallery.setPgName(pgName); @@ -145,7 +147,7 @@ pipeGalleryManager.save(pipeGallery); result = "true"; msg = "编辑成功"; - } + //} } } catch (Exception e) { result = "false"; diff --git a/src/main/java/com/casic/PgInterface/rsFiles/web/PgReserveController.java b/src/main/java/com/casic/PgInterface/rsFiles/web/PgReserveController.java deleted file mode 100644 index f13dac6..0000000 --- a/src/main/java/com/casic/PgInterface/rsFiles/web/PgReserveController.java +++ /dev/null @@ -1,158 +0,0 @@ -package com.casic.PgInterface.rsFiles.web; - -import com.casic.PgInterface.devTable.manager.PgAlarmTypeManager; -import com.casic.PgInterface.reservePlan.domain.PgReservePlan; -import com.casic.PgInterface.reservePlan.manager.PgReservePlanManager; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.multipart.MultipartFile; -import javax.annotation.Resource; -import javax.ws.rs.FormParam; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * Created by yxw on 2017/11/8. - */ -@Controller -@RequestMapping("rs/pgReservePlan") -public class PgReserveController { - - private static Logger logger = LoggerFactory.getLogger(PgReservePlan.class); - - private PgReservePlanManager pgReservePlanManager; - - private PgAlarmTypeManager pgAlarmTypeManager; - - @Resource - public void setPgReservePlanManager(PgReservePlanManager pgReservePlanManager) { - this.pgReservePlanManager = pgReservePlanManager; - } - - @Resource - public void setPgAlarmTypeManager(PgAlarmTypeManager pgAlarmTypeManager) { - this.pgAlarmTypeManager = pgAlarmTypeManager; - } - - //新增预案文档 - @RequestMapping("addReservePlan") - @ResponseBody - public Map addReservePlan(@RequestParam(value = "planName",required = true) String planName, - @RequestParam(value = "planType",required =false) String planType, - @RequestParam(value ="resUnit",required =false) String resUnit, - @RequestParam(value ="alarmType",required =false) String alarmType, - @RequestParam(value = "planFiels",required =false) List planFiels) - throws Exception { - Map resultMap = new HashMap(); - PgReservePlan pgReservePlan = new PgReservePlan(); - String result = ""; - String msg = ""; - - try { - if (planFiels.size() == 0) - pgReservePlan.setPlanFiel(""); - else { - pgReservePlan.setPlanFiel(pgReservePlanManager.saveFiles(planFiels, "reservePlan")); - } - - pgReservePlan.setPlanName(planName); - pgReservePlan.setPlanType(planType); - pgReservePlan.setResUnit(resUnit); - pgReservePlan.setPgAlarmTypeId(pgAlarmTypeManager.getAlarmTypeByAlarmType(alarmType)); - pgReservePlan.setActive(1); - - result = "true"; - msg = "保存成功"; - logger.info("保存成功"); - pgReservePlanManager.save(pgReservePlan); - } catch (Exception ex) { - result = "false"; - msg = "保存失败"; - ex.printStackTrace(); - } - - resultMap.put("success", result); - resultMap.put("msg", msg); - return resultMap; - } - - //编辑预案文档 - @RequestMapping("editReservePlan") - @ResponseBody - public Map editReservePlan(@FormParam("id") String id, - @RequestParam(value = "planName",required = true) String planName, - @RequestParam(value = "planType",required =false) String planType, - @RequestParam(value ="resUnit",required =false) String resUnit, - @RequestParam(value ="alarmType",required =false) String alarmType) throws Exception { - - Map resultMap = new HashMap(); - String result = ""; - String msg = ""; - - try { - PgReservePlan pgReservePlan = pgReservePlanManager.get(Long.valueOf(id)); - if (pgReservePlan == null) { - result = "false"; - msg = "不存在该预案信息"; - } else { - pgReservePlan.setPlanName(planName); - pgReservePlan.setPlanType(planType); - pgReservePlan.setResUnit(resUnit); - pgReservePlan.setPgAlarmTypeId(pgAlarmTypeManager.getAlarmTypeByAlarmType(alarmType)); - pgReservePlan.setActive(1); - - pgReservePlanManager.save(pgReservePlan); - result = "true"; - msg = "编辑成功"; - } - } catch (Exception e) { - result = "false"; - msg = "编辑失败"; - e.printStackTrace(); - } - return resultMap; - } - - //删除预案文档 - @RequestMapping("deleteReservePlan") - @ResponseBody - public Map deleteReservePlan(@FormParam("id") String id)throws Exception{ - Map resultMap = new HashMap(); - String msg=""; - String result="false"; - - try{ - - PgReservePlan pgReservePlan=pgReservePlanManager.get(Long.valueOf(id)); - if(pgReservePlan==null) - { - result="false"; - msg="不存在该预案信息"; - } - else{ - pgReservePlan.setActive(0); - pgReservePlanManager.save(pgReservePlan); - result="true"; - msg="删除成功"; - } - } - catch(Exception e) - { - e.printStackTrace(); - msg="预案删除失败"; - result="false"; - } - - resultMap.put("msg",msg); - resultMap.put("result",result); - return resultMap; - - } - - -} \ No newline at end of file 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" deleted file mode 100644 index 964daa9..0000000 --- "a/~$\346\216\245\345\217\243\350\257\264\346\230\216.docx" +++ /dev/null Binary files differ diff --git "a/~$\346\225\260\346\215\256\345\272\223\350\256\276\350\256\241\350\257\264\346\230\216.docx" "b/~$\346\225\260\346\215\256\345\272\223\350\256\276\350\256\241\350\257\264\346\230\216.docx" deleted file mode 100644 index 4f71cd9..0000000 --- "a/~$\346\225\260\346\215\256\345\272\223\350\256\276\350\256\241\350\257\264\346\230\216.docx" +++ /dev/null Binary files differ 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 18ec62a..92330c6 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/dto/PgTempHunDto.java b/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java deleted file mode 100644 index b2affe5..0000000 --- a/src/main/java/com/casic/PgInterface/devData/dto/PgTempHunDto.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.casic.PgInterface.devData.dto; - -/** - * Created by yxw on 2017/11/28. - */ -public class PgTempHunDto { -} 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 eb1f7ab..da8f617 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDevice.java @@ -39,7 +39,6 @@ private List pgShs; private List pgTempHums; - @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_ID") public long getId() { diff --git a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java index 4278dc1..669b60f 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgDeviceType.java @@ -2,21 +2,20 @@ import javax.persistence.*; import java.io.Serializable; -import java.util.List; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Entity @Table(name = "PG_DEVICE_TYPE") @SequenceGenerator(name = "SEQ_PG_DEVICE_TYPE_ID", sequenceName = "SEQ_PG_DEVICE_TYPE_ID", allocationSize = 1, initialValue = 1) public class PgDeviceType implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; private long id; private String devType; private int active; - private List pgDeviceList; + @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_DEVICE_TYPE_ID") @@ -45,13 +44,4 @@ public void setActive(int active) { this.active = active; } - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "devTypeId") - public List getPgDeviceList() { - return pgDeviceList; - } - - public void setPgDeviceList(List pgDeviceList) { - this.pgDeviceList = pgDeviceList; - } } 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 4fb3d6f..d209733 100644 --- a/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java +++ b/src/main/java/com/casic/PgInterface/devTable/domain/PgPartition.java @@ -2,6 +2,7 @@ import javax.persistence.*; import java.io.Serializable; +import java.util.Date; import java.util.List; /** @@ -17,6 +18,12 @@ private long id; private String parName;//分区名称 private String road;//所属道路 + private String pgPosition;//仓段位置 + private String pgNum;//仓位数量 + private String pgType;//仓位类型 + private String pgLength;//分区长度 + private Date buildDate;//建设年代 + private String material;//建设材质 private int active;//状态位 private List pipeGalleryList;//管廊仓 @@ -48,6 +55,60 @@ this.road = road; } + @Column(name = "PGPOSITION") + public String getPgPosition() { + return pgPosition; + } + + public void setPgPosition(String pgPosition) { + this.pgPosition = pgPosition; + } + + @Column(name = "PGNUM") + public String getPgNum() { + return pgNum; + } + + public void setPgNum(String pgNum) { + this.pgNum = pgNum; + } + + @Column(name = "PGTYPE") + public String getPgType() { + return pgType; + } + + public void setPgType(String pgType) { + this.pgType = pgType; + } + + @Column(name = "PGLENGTH") + public String getPgLength() { + return pgLength; + } + + public void setPgLength(String pgLength) { + this.pgLength = pgLength; + } + + @Column(name = "BUILDDATE") + public Date getBuildDate() { + return buildDate; + } + + public void setBuildDate(Date buildDate) { + this.buildDate = buildDate; + } + + @Column(name = "MATERIAL") + public String getMaterial() { + return material; + } + + public void setMaterial(String material) { + this.material = material; + } + @Column(name = "ACTIVE") public int getActive() { return active; 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 95f9fbd..b60c42d 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceDto.java @@ -160,7 +160,7 @@ this.setAssetName(pgDevice.getAssetName()); this.setAssetCode(pgDevice.getAssetCode()); this.setAssetBarCode(pgDevice.getAssetBarCode()); - this.setId(pgDevice.getIp()); + this.setIp(pgDevice.getIp()); this.setModBus(pgDevice.getModBus()); this.setMome(pgDevice.getMome()); this.setIsOpen(String.valueOf(pgDevice.getIsOpen())); diff --git a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java index c1548e0..e348f7a 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgDeviceTypeDto.java @@ -5,7 +5,7 @@ import java.io.Serializable; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ public class PgDeviceTypeDto implements Serializable { @@ -37,12 +37,11 @@ this.active = active; } - public PgDeviceTypeDto(PgDeviceType pgDeviceType) - { + public PgDeviceTypeDto(PgDeviceType pgDeviceType) { + this.setId(String.valueOf(pgDeviceType.getId())); this.setDevType(pgDeviceType.getDevType()); this.setActive(String.valueOf(pgDeviceType.getActive())); } - } 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 3acd0fa..95c18b4 100644 --- a/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java +++ b/src/main/java/com/casic/PgInterface/devTable/dto/PgPartitionDto.java @@ -3,6 +3,7 @@ import com.casic.PgInterface.devTable.domain.PgPartition; import java.io.Serializable; +import java.text.SimpleDateFormat; /** * Created by yxw on 2017/11/2. @@ -12,6 +13,12 @@ private String id; private String parName;//分区名称 private String road;//所属道路 + private String pgPosition;//仓段位置 + private String pgNum;//仓位数量 + private String pgType;//仓位类型 + private String pgLength;//分区长度 + private String buildDate;//建设年代 + private String material;//建设材质 private String active;//状态位 @@ -47,11 +54,67 @@ this.road = road; } + public String getPgPosition() { + return pgPosition; + } + + public void setPgPosition(String pgPosition) { + this.pgPosition = pgPosition; + } + + public String getPgNum() { + return pgNum; + } + + public void setPgNum(String pgNum) { + this.pgNum = pgNum; + } + + public String getPgType() { + return pgType; + } + + public void setPgType(String pgType) { + this.pgType = pgType; + } + + public String getPgLength() { + return pgLength; + } + + public void setPgLength(String pgLength) { + this.pgLength = pgLength; + } + + public String getBuildDate() { + return buildDate; + } + + public void setBuildDate(String buildDate) { + this.buildDate = buildDate; + } + + public String getMaterial() { + return material; + } + + public void setMaterial(String material) { + this.material = material; + } + public PgPartitionDto(PgPartition pgPartition) { + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); + this.setId(String.valueOf(pgPartition.getId())); this.setParName(pgPartition.getParName()); this.setRoad(pgPartition.getRoad()); + this.setPgPosition(pgPartition.getPgPosition()); + this.setPgNum(pgPartition.getPgNum()); + this.setPgType(pgPartition.getPgType()); + this.setPgLength(pgPartition.getPgLength()); + this.setBuildDate(sdf.format(pgPartition.getBuildDate())); + this.setMaterial(pgPartition.getMaterial()); this.setActive(String.valueOf(pgPartition.getActive())); } diff --git a/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java b/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java index d7c6024..9ea43fd 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgDeviceTypeManager.java @@ -12,10 +12,10 @@ import java.util.List; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Service -public class PgDeviceTypeManager extends HibernateEntityDao{ +public class PgDeviceTypeManager extends HibernateEntityDao { public List getAllDeviceType() { @@ -23,8 +23,8 @@ criteria.add(Restrictions.eq("active", 1)); criteria.addOrder(Order.desc("id")); - List pgDeviceTypeList= criteria.list(); - List pgDeviceTypeDtoList=new ArrayList(); + List pgDeviceTypeList = criteria.list(); + List pgDeviceTypeDtoList = new ArrayList(); for (PgDeviceType pgDeviceType : pgDeviceTypeList) { pgDeviceTypeDtoList.add(new PgDeviceTypeDto(pgDeviceType)); } @@ -32,15 +32,14 @@ return pgDeviceTypeDtoList; } - public PgDeviceType getPgDeviceTypeByDevType(String devType) - { - Criteria criteria=createCriteria(PgDeviceType.class); - criteria.add(Restrictions.eq("devType",devType)); - criteria.add(Restrictions.eq("active",1)); - criteria.addOrder(Order.desc("id")); + public PgDeviceType getDeviceTypeByDeType(String devType) { - List pgDeviceTypeList=criteria.list(); - if(pgDeviceTypeList==null||pgDeviceTypeList.size()==0) + Criteria criteria = createCriteria(PgDeviceType.class); + criteria.add(Restrictions.eq("active", 1)); + criteria.add(Restrictions.eq("devType", devType)); + + List pgDeviceTypeList = criteria.list(); + if (pgDeviceTypeList.size() == 0) return null; else return pgDeviceTypeList.get(0); 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 0c594e7..c6f22cb 100644 --- a/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java +++ b/src/main/java/com/casic/PgInterface/devTable/manager/PgPartitionManager.java @@ -64,4 +64,4 @@ -} +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java index 9d06235..68b14cf 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgAlarmRule.java @@ -1,9 +1,5 @@ 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; @@ -19,7 +15,8 @@ private long id; private String highValue;//高限 private String lowValue;//低限 - private PgDevice pgDeviceId;//设备 + private String unit;//单位 + private String devType;//设备类型 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_ALARM_RULE_ID") @@ -49,15 +46,24 @@ this.lowValue = lowValue; } - @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) - @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "PGDEVICEID") - public PgDevice getPgDeviceId() { - return pgDeviceId; + @Column(name="UNIT") + public String getUnit() { + return unit; } - public void setPgDeviceId(PgDevice pgDeviceId) { - this.pgDeviceId = pgDeviceId; + public void setUnit(String unit) { + this.unit = unit; } + @Column(name = "DEVTYPE") + public String getDevType() { + return devType; + } + + public void setDevType(String devType) { + this.devType = devType; + } + + + } diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java deleted file mode 100644 index 7907e66..0000000 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRule.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.casic.PgInterface.patroler.dto; - -/** - * Created by yxw on 2017/12/14. - */ -public class PgAlarmRule { -} diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java index 8367ad4..0782c63 100644 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgAlarmRuleDto.java @@ -12,7 +12,8 @@ private String id; private String highValue;//高限 private String lowValue;//低限 - private String devName;//设备 + private String devType;//设备类型 + private String unit;//单位 public String getId() { return id; @@ -38,20 +39,29 @@ this.lowValue = lowValue; } - public String getDevName() { - return devName; + public String getDevType() { + return devType; } - public void setDevName(String devName) { - this.devName = devName; + public void setDevType(String devType) { + this.devType = devType; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; } public PgAlarmRuleDto(PgAlarmRule pgAlarmRule) { this.setId(String.valueOf(pgAlarmRule.getId())); - this.setDevName(pgAlarmRule.getPgDeviceId().getAssetName()); this.setHighValue(pgAlarmRule.getHighValue()); this.setLowValue(pgAlarmRule.getLowValue()); + this.setDevType(pgAlarmRule.getDevType()); + this.setUnit(pgAlarmRule.getUnit()); } } diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java index d5c00b2..84e5cdd 100644 --- a/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgAlarmRuleManager.java @@ -1,13 +1,13 @@ 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.ArrayList; import java.util.List; /** @@ -17,20 +17,21 @@ public class PgAlarmRuleManager extends HibernateEntityDao { //根据设备获取设备报警阈值 - public PgAlarmRuleDto getAlarmRuleDtoBydev(PgDevice pgDeviceId) { + public List getAlarmRuleDto() { 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)); + List pgAlarmRuleDtoList = new ArrayList(); + for (PgAlarmRule pgAlarmRule : pgAlarmRuleList) { + pgAlarmRuleDtoList.add(new PgAlarmRuleDto(pgAlarmRule)); + } + return pgAlarmRuleDtoList; + } - public PgAlarmRule getAlarmRuleBydev(PgDevice pgDeviceId) { + public PgAlarmRule getAlarmRuleBydevType(String devType) { Criteria criteria=createCriteria(PgAlarmRule.class); - criteria.add(Restrictions.eq("pgDeviceId", pgDeviceId)); + criteria.add(Restrictions.eq("devType", devType)); List pgAlarmRuleList=criteria.list(); if(pgAlarmRuleList.size()==0) diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java index f4e48c6..9396013 100644 --- a/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgLogManager.java @@ -39,13 +39,13 @@ } if (StringUtils.isNotBlank(startTime)) { - criteria.add(Restrictions.ge("operateTime", DateUtils.sdf4.parse(startTime))); + criteria.add(Restrictions.ge("operateTime", DateUtils.sdf_day.parse(startTime))); } if (StringUtils.isNotBlank(endTime)) { Calendar calendar = Calendar.getInstance(); - calendar.setTime(DateUtils.sdf4.parse(endTime)); + calendar.setTime(DateUtils.sdf_day.parse(endTime)); calendar.add(Calendar.DATE, 1); - criteria.add(Restrictions.le("time", calendar.getTime())); + criteria.add(Restrictions.le("operateTime", calendar.getTime())); } criteria.add(Restrictions.eq("active", 1)); diff --git a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java index 88255c6..f28ebdf 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java @@ -1,6 +1,5 @@ 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; @@ -15,7 +14,9 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -42,72 +43,43 @@ } /** - * 获取报警阈值信息 - */ - @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 { + public Map addAlarmRule(@FormParam("highValue") String highValue, + @FormParam("lowValue") String lowValue, + @FormParam("unit") String unit, + @FormParam("devType") String devType) 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(); + try { + pgAlarmRule = pgAlarmRuleManager.getAlarmRuleBydevType(devType); + if (pgAlarmRule != null) { result = "false"; - msg = "报警阈值新增失败"; + msg = "设备阈值已经存在"; + } else { + pgAlarmRule = new PgAlarmRule(); + pgAlarmRule.setHighValue(highValue); + pgAlarmRule.setLowValue(lowValue); + pgAlarmRule.setDevType(devType); + pgAlarmRule.setUnit(unit); + + pgAlarmRuleManager.save(pgAlarmRule); + result = "true"; + msg = "报警阈值新增成功"; } + } catch (Exception e) { + e.printStackTrace(); + result = "false"; + msg = "报警阈值新增失败"; } + resultMap.put("msg", msg); resultMap.put("result", result); return resultMap; @@ -119,44 +91,66 @@ @POST @Path("editAlarmRule") @Produces(MediaType.APPLICATION_JSON) - public Map editAlarmRule(@FormParam("id") String id, - @FormParam("assetCode") String assetCode, + public Map editAlarmRule(@FormParam("devType") String devType, @FormParam("highValue") String highValue, - @FormParam("lowValue") String lowValue) throws Exception { + @FormParam("lowValue") String lowValue, + @FormParam("unit") String unit) 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(); + + try { + pgAlarmRule = pgAlarmRuleManager.getAlarmRuleBydevType(devType); + if (pgAlarmRule == null) { + msg = "不存在报警阈值记录"; result = "false"; - msg = "报警阈值编辑失败"; + } else { + pgAlarmRule.setDevType(devType); + pgAlarmRule.setHighValue(highValue); + pgAlarmRule.setLowValue(lowValue); + pgAlarmRule.setUnit(unit); + pgAlarmRuleManager.save(pgAlarmRule); + msg = "编辑成功"; + result = "true"; } + } catch (Exception ex) { + ex.printStackTrace(); + result = "false"; + msg = "报警阈值编辑失败"; } + resultMap.put("msg", msg); resultMap.put("result", result); return resultMap; + } + /** + * 获取报警阈值信息 + */ + @POST + @Path("getAlarmRule") + @Produces(MediaType.APPLICATION_JSON) + public Map getAlarmRule() throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + + List pgAlarmRuleDtoList = new ArrayList(); + try { + pgAlarmRuleDtoList = pgAlarmRuleManager.getAlarmRuleDto(); + if (pgAlarmRuleDtoList == null) + msg = "不存在报警阈值信息"; + else + msg = "报警阈值获取成功"; + } catch (Exception e) { + e.printStackTrace(); + msg = "报警信息获取失败"; + } + resultMap.put("msg", msg); + resultMap.put("result", pgAlarmRuleDtoList); + 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 bb8c245..36547a7 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgDeviceRs.java @@ -104,8 +104,8 @@ @POST @Path("addDevice") @Produces(MediaType.APPLICATION_JSON) - public Map addDevice(@FormParam("parName") String parName, - @FormParam("pgName") String pgName, + public Map addDevice(@FormParam("partition") String partition, + @FormParam("pipeGallery") String pipeGallery, @FormParam("road") String road, @FormParam("position") String position, @FormParam("devType") String devType, @@ -129,8 +129,8 @@ } else { PgDevice pgDevice = new PgDevice(); - pgDevice.setPipeGallery(pgName); - pgDevice.setPartition(parName); + pgDevice.setPipeGallery(pipeGallery); + pgDevice.setPartition(partition); pgDevice.setRoad(road); pgDevice.setPosition(position); pgDevice.setDevType(devType); @@ -168,8 +168,8 @@ @Path("editDevice") @Produces(MediaType.APPLICATION_JSON) public Map editPartition(@FormParam("id") String id, - @FormParam("parName") String parName, - @FormParam("pgName") String pgName, + @FormParam("partition") String partition, + @FormParam("pipeGallery") String pipeGallery, @FormParam("road") String road, @FormParam("position") String position, @FormParam("devType") String devType, @@ -187,13 +187,15 @@ String msg = ""; try { + /* if (pgDeviceManager.getDeviceByAssetCode(assetCode)!=null) { result = "false"; msg = "已存在同名设备"; } else { + */ PgDevice pgDevice = pgDeviceManager.get(Long.valueOf(id)); - pgDevice.setPipeGallery(pgName); - pgDevice.setPartition(parName); + pgDevice.setPipeGallery(pipeGallery); + pgDevice.setPartition(partition); pgDevice.setRoad(road); pgDevice.setPosition(position); pgDevice.setDevType(devType); @@ -210,7 +212,7 @@ pgDeviceManager.save(pgDevice); result = "true"; msg = "编辑成功"; - } + //} } catch (Exception e) { result = "false"; msg = "编辑失败"; diff --git a/src/main/java/com/casic/PgInterface/rs/PgDeviceTypeRs.java b/src/main/java/com/casic/PgInterface/rs/PgDeviceTypeRs.java index 756894f..b6c84aa 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgDeviceTypeRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgDeviceTypeRs.java @@ -19,12 +19,13 @@ import java.util.Map; /** - * Created by yxw on 2017/11/23. + * Created by yxw on 2018/1/8. */ @Component @Path("pgDeviceType") public class PgDeviceTypeRs { - private static Logger logger = LoggerFactory.getLogger(PgDeviceRs.class); + + private static Logger logger = LoggerFactory.getLogger(PgDeviceTypeRs.class); private PgDeviceTypeManager pgDeviceTypeManager; @@ -34,21 +35,21 @@ } /** - * 获取设备类型 + * 显示设备列表 */ @POST @Path("getDeviceType") @Produces(MediaType.APPLICATION_JSON) - public Map getDeviceType()throws Exception { + public Map getDeviceTpeyList()throws Exception { Map resultMap = new HashMap(); String msg=""; List pgDeviceTypeDtoList=new ArrayList(); try { pgDeviceTypeDtoList = pgDeviceTypeManager.getAllDeviceType(); if(pgDeviceTypeDtoList.size()==0) - msg="没有设备类型信息"; + msg="没有找到设备类型信息"; else - msg="设备类型获取失败"; + msg="设备类型信息获取成功"; }catch(Exception e){ e.printStackTrace(); msg="设备类型信息获取失败"; @@ -64,37 +65,39 @@ @POST @Path("addDeviceType") @Produces(MediaType.APPLICATION_JSON) - public Map addDeviceType(@FormParam("devType") String devType) + public Map addDevice(@FormParam("devType") String devType) throws Exception { Map resultMap = new HashMap(); String result = ""; String msg = ""; - try { - if (pgDeviceTypeManager.getPgDeviceTypeByDevType(devType)!=null) { - result = "false"; - msg = "已存在同名设备类型"; - } else { - PgDeviceType pgDeviceType=new PgDeviceType(); - pgDeviceType.setDevType(devType); - pgDeviceType.setActive(1); - - pgDeviceTypeManager.save(pgDeviceType); - result = "true"; - msg = "保存成功"; - } - - } catch (Exception e) { + try { + if (pgDeviceTypeManager.getDeviceTypeByDeType(devType)!=null) { result = "false"; - msg = "保存失败"; - e.printStackTrace(); + msg = "已存在设备类型"; + } else { + PgDeviceType pgDeviceType = new PgDeviceType(); + + pgDeviceType.setDevType(devType); + pgDeviceType.setActive(1); + + pgDeviceTypeManager.save(pgDeviceType); + result = "true"; + msg = "保存成功"; } + } catch (Exception e) { + result = "false"; + msg = "保存失败"; + e.printStackTrace(); + } + resultMap.put("success", result); resultMap.put("msg", msg); return resultMap; } + } diff --git a/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java b/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java index 8a42e7e..249b75c 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgPartitionRs.java @@ -13,10 +13,8 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.text.SimpleDateFormat; +import java.util.*; /** * Created by yxw on 2017/11/6. @@ -40,25 +38,35 @@ @POST @Path("addPartition") @Produces(MediaType.APPLICATION_JSON) - public Map addAlarm(@FormParam("parName") String parName)throws Exception { + public Map addAlarm(@FormParam("parName") String parName, + @FormParam("road") String road, + @FormParam("pgPosition") String pgPosition, + @FormParam("pgNum") String pgNum, + @FormParam("pgType") String pgType, + @FormParam("pgLength") String pgLength, + @FormParam("buildDate") String buildDate, + @FormParam("material") String material)throws Exception { Map resultMap = new HashMap(); String result = ""; String msg = ""; + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); try { - if (pgPartitionManager.getPartitionByParName(parName) != null) { - result = "false"; - msg = "已存在相同分区"; - } else { PgPartition pgPartition = new PgPartition(); pgPartition.setParName(parName); + pgPartition.setRoad(road); + pgPartition.setPgPosition(pgPosition); + pgPartition.setPgNum(pgNum); + pgPartition.setPgType(pgType); + pgPartition.setPgLength(pgLength); + pgPartition.setBuildDate(sdf.parse(buildDate)); + pgPartition.setMaterial(material); pgPartition.setActive(1); logger.info("成功保存"); pgPartitionManager.save(pgPartition); result = "true"; msg = "保存成功"; - } } catch (Exception e) { result = "false"; @@ -71,28 +79,40 @@ return resultMap; } - - @POST @Path("editPartition") @Produces(MediaType.APPLICATION_JSON) public Map editPartition(@FormParam("id") String id, - @FormParam("parName") String parName) throws Exception { + @FormParam("parName") String parName, + @FormParam("road") String road, + @FormParam("pgPosition") String pgPosition, + @FormParam("pgNum") String pgNum, + @FormParam("pgType") String pgType, + @FormParam("pgLength") String pgLength, + @FormParam("buildDate") String buildDate, + @FormParam("material") String material) throws Exception { Map resultMap = new HashMap(); String result = ""; String msg = ""; PgPartition partition = new PgPartition(); + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); try { - if (pgPartitionManager.getPartitionByParName(parName) != null) { result = "false"; msg = "已存在相同分区"; } else { PgPartition pgPartition = pgPartitionManager.get(Long.valueOf(id)); pgPartition.setParName(parName); + pgPartition.setRoad(road); + pgPartition.setPgPosition(pgPosition); + pgPartition.setPgNum(pgNum); + pgPartition.setPgType(pgType); + pgPartition.setPgLength(pgLength); + pgPartition.setBuildDate(sdf.parse(buildDate)); + pgPartition.setMaterial(material); pgPartition.setActive(1); pgPartitionManager.save(pgPartition); diff --git a/src/main/java/com/casic/PgInterface/rs/PgPatrolerRs.java b/src/main/java/com/casic/PgInterface/rs/PgPatrolerRs.java index aed1ed8..0b3c731 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgPatrolerRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgPatrolerRs.java @@ -123,10 +123,12 @@ String result = ""; String msg = ""; try { + /* if (pgPatrolerManager.userNameIsExits(userName)) { result = "false"; msg = "用户名已经存在!"; } else { + */ PgPatroler pgPatroler = pgPatrolerManager.get(Long.valueOf(id)); pgPatroler.setUserName(userName); pgPatroler.setPassword(password); @@ -136,7 +138,7 @@ pgPatrolerManager.save(pgPatroler); result = "true"; msg = "编辑成功"; - } + //} } catch (Exception e) { result = "false"; msg = "编辑失败"; diff --git a/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java b/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java index 8cbdb0a..4c9feac 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgPipeLineRs.java @@ -165,12 +165,14 @@ msg = "不存在管廊仓和分区信息"; } else { try { + /* if(pgPipeLineManager.getPipeLineBylineName(lineName)!=null) { result = "false"; msg = "已存在同名管线"; } else { + */ PgPipeLine pgPipeLine = pgPipeLineManager.get(Long.valueOf(id)); pgPipeLine.setLineName(lineName); @@ -185,7 +187,7 @@ pgPipeLineManager.save(pgPipeLine); result = "true"; msg = "编辑成功"; - } + //} } catch (Exception e) { result = "false"; msg = "编辑失败"; diff --git a/src/main/java/com/casic/PgInterface/rs/PgReserveController.java b/src/main/java/com/casic/PgInterface/rs/PgReserveController.java new file mode 100644 index 0000000..863045a --- /dev/null +++ b/src/main/java/com/casic/PgInterface/rs/PgReserveController.java @@ -0,0 +1,207 @@ +package com.casic.PgInterface.rs; + +import com.casic.PgInterface.core.util.StringUtils; +import com.casic.PgInterface.devTable.manager.PgAlarmTypeManager; +import com.casic.PgInterface.reservePlan.domain.PgReservePlan; +import com.casic.PgInterface.reservePlan.manager.PgReservePlanManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.multipart.MultipartFile; +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.List; +import java.util.Map; + +/** + * Created by yxw on 2017/11/8. + */ +@Controller +@RequestMapping("rs/pgReservePlan") +public class PgReserveController { + + private static Logger logger = LoggerFactory.getLogger(PgReservePlan.class); + + private PgReservePlanManager pgReservePlanManager; + + private PgAlarmTypeManager pgAlarmTypeManager; + + @Resource + public void setPgReservePlanManager(PgReservePlanManager pgReservePlanManager) { + this.pgReservePlanManager = pgReservePlanManager; + } + + @Resource + public void setPgAlarmTypeManager(PgAlarmTypeManager pgAlarmTypeManager) { + this.pgAlarmTypeManager = pgAlarmTypeManager; + } + +// //新增预案文档 +// @RequestMapping("addReservePlan") +// @ResponseBody +// public Map addReservePlan(@RequestParam(value = "planName",required = true) String planName, +// @RequestParam(value = "planType",required =false) String planType, +// @RequestParam(value ="resUnit",required =false) String resUnit, +// @RequestParam(value ="alarmType",required =false) String alarmType, +// @RequestParam(value = "planFiels",required =false) List planFiels) +// throws Exception { +// Map resultMap = new HashMap(); +// PgReservePlan pgReservePlan = new PgReservePlan(); +// String result = ""; +// String msg = ""; +// +// try { +// if (planFiels.size() == 0) +// pgReservePlan.setPlanFiel(""); +// else { +// pgReservePlan.setPlanFiel(pgReservePlanManager.saveFiles(planFiels, "reservePlan")); +// } +// +// pgReservePlan.setPlanName(planName); +// pgReservePlan.setPlanType(planType); +// pgReservePlan.setResUnit(resUnit); +// pgReservePlan.setPgAlarmTypeId(pgAlarmTypeManager.getAlarmTypeByAlarmType(alarmType)); +// pgReservePlan.setActive(1); +// +// result = "true"; +// msg = "保存成功"; +// logger.info("保存成功"); +// pgReservePlanManager.save(pgReservePlan); +// } catch (Exception ex) { +// result = "false"; +// msg = "保存失败"; +// ex.printStackTrace(); +// } +// +// resultMap.put("success", result); +// resultMap.put("msg", msg); +// return resultMap; +// } + + //新增预案文档 + @POST + @Path("addReservePlan") + @Produces(MediaType.APPLICATION_JSON) + public Map addReservePlan( + @FormParam("pgName") String planName, + @FormParam("parName") String planType, + @FormParam("parName") String resUnit, + @FormParam("parName") String alarmType, + @FormParam("parName") String fileBuffer, + @FormParam("parName") String fileName)throws Exception { + Map resultMap = new HashMap(); + PgReservePlan pgReservePlan = new PgReservePlan(); + String result = ""; + String msg = ""; + + try { + if (StringUtils.isBlank(fileBuffer)||StringUtils.isBlank(fileName)) + pgReservePlan.setPlanFiel(""); + else { + pgReservePlan.setPlanFiel(pgReservePlanManager.saveFiles(fileBuffer, fileName,"reservePlan")); + } + + pgReservePlan.setPlanName(planName); + pgReservePlan.setPlanType(planType); + pgReservePlan.setResUnit(resUnit); + pgReservePlan.setPgAlarmTypeId(pgAlarmTypeManager.getAlarmTypeByAlarmType(alarmType)); + pgReservePlan.setActive(1); + + result = "true"; + msg = "保存成功"; + logger.info("保存成功"); + pgReservePlanManager.save(pgReservePlan); + } catch (Exception ex) { + result = "false"; + msg = "保存失败"; + ex.printStackTrace(); + } + + resultMap.put("success", result); + resultMap.put("msg", msg); + return resultMap; + } + + //编辑预案文档 + @RequestMapping("editReservePlan") + @ResponseBody + public Map editReservePlan(@FormParam("id") String id, + @RequestParam(value = "planName",required = true) String planName, + @RequestParam(value = "planType",required =false) String planType, + @RequestParam(value ="resUnit",required =false) String resUnit, + @RequestParam(value ="alarmType",required =false) String alarmType) throws Exception { + + Map resultMap = new HashMap(); + String result = ""; + String msg = ""; + + try { + PgReservePlan pgReservePlan = pgReservePlanManager.get(Long.valueOf(id)); + if (pgReservePlan == null) { + result = "false"; + msg = "不存在该预案信息"; + } else { + pgReservePlan.setPlanName(planName); + pgReservePlan.setPlanType(planType); + pgReservePlan.setResUnit(resUnit); + pgReservePlan.setPgAlarmTypeId(pgAlarmTypeManager.getAlarmTypeByAlarmType(alarmType)); + pgReservePlan.setActive(1); + + pgReservePlanManager.save(pgReservePlan); + result = "true"; + msg = "编辑成功"; + } + } catch (Exception e) { + result = "false"; + msg = "编辑失败"; + e.printStackTrace(); + } + return resultMap; + } + + //删除预案文档 + @RequestMapping("deleteReservePlan") + @ResponseBody + public Map deleteReservePlan(@FormParam("id") String id)throws Exception{ + Map resultMap = new HashMap(); + String msg=""; + String result="false"; + + try{ + + PgReservePlan pgReservePlan=pgReservePlanManager.get(Long.valueOf(id)); + if(pgReservePlan==null) + { + result="false"; + msg="不存在该预案信息"; + } + else{ + pgReservePlan.setActive(0); + pgReservePlanManager.save(pgReservePlan); + result="true"; + msg="删除成功"; + } + } + catch(Exception e) + { + e.printStackTrace(); + msg="预案删除失败"; + result="false"; + } + + 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/PgTextureRs.java b/src/main/java/com/casic/PgInterface/rs/PgTextureRs.java index 5892127..2360251 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgTextureRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgTextureRs.java @@ -163,12 +163,14 @@ msg = "不存在管廊仓和分区信息"; } else { try { + /* if(pgTextureManager.getPgTextureByName(textureName)!=null) { result = "false"; msg = "已存在同名的部件"; } else { + */ PgTexture pgTexture = pgTextureManager.get(Long.valueOf(id)); pgTexture.setTextureName(textureName); pgTexture.setTextureMaterial(textureMaterial); @@ -181,7 +183,7 @@ pgTextureManager.save(pgTexture); result = "true"; msg = "编辑成功"; - } + //} } catch (Exception e) { result = "false"; msg = "编辑失败"; diff --git a/src/main/java/com/casic/PgInterface/rs/PipeGalleryRs.java b/src/main/java/com/casic/PgInterface/rs/PipeGalleryRs.java index 6904b9f..42f7d40 100644 --- a/src/main/java/com/casic/PgInterface/rs/PipeGalleryRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PipeGalleryRs.java @@ -132,10 +132,12 @@ result = "false"; msg = "不存在该分区信息"; } else { + /* if (pipeGalleryManager.getPipeGalleryByPgName(pgName, pgPartition) != null) { result = "false"; msg = "已存在相同管廊"; } else { + */ pipeGallery = pipeGalleryManager.get(Long.valueOf(id)); pipeGallery.setPgName(pgName); @@ -145,7 +147,7 @@ pipeGalleryManager.save(pipeGallery); result = "true"; msg = "编辑成功"; - } + //} } } catch (Exception e) { result = "false"; diff --git a/src/main/java/com/casic/PgInterface/rsFiles/web/PgReserveController.java b/src/main/java/com/casic/PgInterface/rsFiles/web/PgReserveController.java deleted file mode 100644 index f13dac6..0000000 --- a/src/main/java/com/casic/PgInterface/rsFiles/web/PgReserveController.java +++ /dev/null @@ -1,158 +0,0 @@ -package com.casic.PgInterface.rsFiles.web; - -import com.casic.PgInterface.devTable.manager.PgAlarmTypeManager; -import com.casic.PgInterface.reservePlan.domain.PgReservePlan; -import com.casic.PgInterface.reservePlan.manager.PgReservePlanManager; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.multipart.MultipartFile; -import javax.annotation.Resource; -import javax.ws.rs.FormParam; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * Created by yxw on 2017/11/8. - */ -@Controller -@RequestMapping("rs/pgReservePlan") -public class PgReserveController { - - private static Logger logger = LoggerFactory.getLogger(PgReservePlan.class); - - private PgReservePlanManager pgReservePlanManager; - - private PgAlarmTypeManager pgAlarmTypeManager; - - @Resource - public void setPgReservePlanManager(PgReservePlanManager pgReservePlanManager) { - this.pgReservePlanManager = pgReservePlanManager; - } - - @Resource - public void setPgAlarmTypeManager(PgAlarmTypeManager pgAlarmTypeManager) { - this.pgAlarmTypeManager = pgAlarmTypeManager; - } - - //新增预案文档 - @RequestMapping("addReservePlan") - @ResponseBody - public Map addReservePlan(@RequestParam(value = "planName",required = true) String planName, - @RequestParam(value = "planType",required =false) String planType, - @RequestParam(value ="resUnit",required =false) String resUnit, - @RequestParam(value ="alarmType",required =false) String alarmType, - @RequestParam(value = "planFiels",required =false) List planFiels) - throws Exception { - Map resultMap = new HashMap(); - PgReservePlan pgReservePlan = new PgReservePlan(); - String result = ""; - String msg = ""; - - try { - if (planFiels.size() == 0) - pgReservePlan.setPlanFiel(""); - else { - pgReservePlan.setPlanFiel(pgReservePlanManager.saveFiles(planFiels, "reservePlan")); - } - - pgReservePlan.setPlanName(planName); - pgReservePlan.setPlanType(planType); - pgReservePlan.setResUnit(resUnit); - pgReservePlan.setPgAlarmTypeId(pgAlarmTypeManager.getAlarmTypeByAlarmType(alarmType)); - pgReservePlan.setActive(1); - - result = "true"; - msg = "保存成功"; - logger.info("保存成功"); - pgReservePlanManager.save(pgReservePlan); - } catch (Exception ex) { - result = "false"; - msg = "保存失败"; - ex.printStackTrace(); - } - - resultMap.put("success", result); - resultMap.put("msg", msg); - return resultMap; - } - - //编辑预案文档 - @RequestMapping("editReservePlan") - @ResponseBody - public Map editReservePlan(@FormParam("id") String id, - @RequestParam(value = "planName",required = true) String planName, - @RequestParam(value = "planType",required =false) String planType, - @RequestParam(value ="resUnit",required =false) String resUnit, - @RequestParam(value ="alarmType",required =false) String alarmType) throws Exception { - - Map resultMap = new HashMap(); - String result = ""; - String msg = ""; - - try { - PgReservePlan pgReservePlan = pgReservePlanManager.get(Long.valueOf(id)); - if (pgReservePlan == null) { - result = "false"; - msg = "不存在该预案信息"; - } else { - pgReservePlan.setPlanName(planName); - pgReservePlan.setPlanType(planType); - pgReservePlan.setResUnit(resUnit); - pgReservePlan.setPgAlarmTypeId(pgAlarmTypeManager.getAlarmTypeByAlarmType(alarmType)); - pgReservePlan.setActive(1); - - pgReservePlanManager.save(pgReservePlan); - result = "true"; - msg = "编辑成功"; - } - } catch (Exception e) { - result = "false"; - msg = "编辑失败"; - e.printStackTrace(); - } - return resultMap; - } - - //删除预案文档 - @RequestMapping("deleteReservePlan") - @ResponseBody - public Map deleteReservePlan(@FormParam("id") String id)throws Exception{ - Map resultMap = new HashMap(); - String msg=""; - String result="false"; - - try{ - - PgReservePlan pgReservePlan=pgReservePlanManager.get(Long.valueOf(id)); - if(pgReservePlan==null) - { - result="false"; - msg="不存在该预案信息"; - } - else{ - pgReservePlan.setActive(0); - pgReservePlanManager.save(pgReservePlan); - result="true"; - msg="删除成功"; - } - } - catch(Exception e) - { - e.printStackTrace(); - msg="预案删除失败"; - result="false"; - } - - resultMap.put("msg",msg); - resultMap.put("result",result); - return resultMap; - - } - - -} \ No newline at end of file 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" deleted file mode 100644 index 964daa9..0000000 --- "a/~$\346\216\245\345\217\243\350\257\264\346\230\216.docx" +++ /dev/null Binary files differ diff --git "a/~$\346\225\260\346\215\256\345\272\223\350\256\276\350\256\241\350\257\264\346\230\216.docx" "b/~$\346\225\260\346\215\256\345\272\223\350\256\276\350\256\241\350\257\264\346\230\216.docx" deleted file mode 100644 index 4f71cd9..0000000 --- "a/~$\346\225\260\346\215\256\345\272\223\350\256\276\350\256\241\350\257\264\346\230\216.docx" +++ /dev/null Binary files differ 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 18ec62a..92330c6 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 c7e159f..cceca53 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