diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 2ee3724..276272c 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,6 +2,20 @@ + + + + + + + + + + + + + + @@ -44,13 +58,6 @@ @@ -249,6 +263,36 @@ - @@ -911,13 +1031,14 @@ + - + @@ -926,7 +1047,6 @@ - @@ -1011,7 +1131,7 @@ - @@ -1019,62 +1139,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1173,13 +1237,6 @@ - - - - - - - @@ -1201,20 +1258,6 @@ - - - - - - - - - - - - - - @@ -1229,13 +1272,6 @@ - - - - - - - @@ -1278,45 +1314,11 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -1335,13 +1337,6 @@ - - - - - - - @@ -1349,13 +1344,6 @@ - - - - - - - @@ -1382,6 +1370,217 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 2ee3724..276272c 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,6 +2,20 @@ + + + + + + + + + + + + + + @@ -44,13 +58,6 @@ @@ -249,6 +263,36 @@ - @@ -911,13 +1031,14 @@ + - + @@ -926,7 +1047,6 @@ - @@ -1011,7 +1131,7 @@ - @@ -1019,62 +1139,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1173,13 +1237,6 @@ - - - - - - - @@ -1201,20 +1258,6 @@ - - - - - - - - - - - - - - @@ -1229,13 +1272,6 @@ - - - - - - - @@ -1278,45 +1314,11 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -1335,13 +1337,6 @@ - - - - - - - @@ -1349,13 +1344,6 @@ - - - - - - - @@ -1382,6 +1370,217 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java b/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java index fad34cb..a928236 100644 --- a/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java +++ b/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java @@ -20,7 +20,6 @@ private static final long serialVersionUID = 1L; private long id; private String cs_name;//项目名称 - private String cs_status;//项目状态 private String cs_detail;//施工内容 private Date cs_beginTime;//施工开始时间 private Date cs_endTime;//施工结束时间 @@ -28,6 +27,7 @@ private String cs_phone;//联系方式 private String cs_type;//工程类别 private PgPartition pgPartitionId;//施工区域 + private PgConstructionType pgConstructionTypeId;//项目状态 private List pgCsDocumentList;//施工文档 private int active;//状态位 @@ -42,11 +42,6 @@ public void setCs_name(String cs_name){ this.cs_name = cs_name; } - @Column(name = "CS_STATUS") - public String getCs_status(){ return cs_status; } - - public void setCs_status(String cs_status){ this.cs_status = cs_status; } - @Column(name = "CS_DETAIL") public String getCs_detail(){ return cs_detail; } @@ -97,6 +92,16 @@ this.pgCsDocumentList = pgCsDocumentList; } + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "PGCONSTRUCTIONTYPE_ID") + public PgConstructionType getPgConstructionTypeId() { + return pgConstructionTypeId; + } + + public void setPgConstructionTypeId(PgConstructionType pgConstructionTypeId) { + this.pgConstructionTypeId = pgConstructionTypeId; + } @Column(name = "ACTIVE") public int getActive(){ return active; } diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 2ee3724..276272c 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,6 +2,20 @@ + + + + + + + + + + + + + + @@ -44,13 +58,6 @@ @@ -249,6 +263,36 @@ - @@ -911,13 +1031,14 @@ + - + @@ -926,7 +1047,6 @@ - @@ -1011,7 +1131,7 @@ - @@ -1019,62 +1139,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1173,13 +1237,6 @@ - - - - - - - @@ -1201,20 +1258,6 @@ - - - - - - - - - - - - - - @@ -1229,13 +1272,6 @@ - - - - - - - @@ -1278,45 +1314,11 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -1335,13 +1337,6 @@ - - - - - - - @@ -1349,13 +1344,6 @@ - - - - - - - @@ -1382,6 +1370,217 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java b/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java index fad34cb..a928236 100644 --- a/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java +++ b/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java @@ -20,7 +20,6 @@ private static final long serialVersionUID = 1L; private long id; private String cs_name;//项目名称 - private String cs_status;//项目状态 private String cs_detail;//施工内容 private Date cs_beginTime;//施工开始时间 private Date cs_endTime;//施工结束时间 @@ -28,6 +27,7 @@ private String cs_phone;//联系方式 private String cs_type;//工程类别 private PgPartition pgPartitionId;//施工区域 + private PgConstructionType pgConstructionTypeId;//项目状态 private List pgCsDocumentList;//施工文档 private int active;//状态位 @@ -42,11 +42,6 @@ public void setCs_name(String cs_name){ this.cs_name = cs_name; } - @Column(name = "CS_STATUS") - public String getCs_status(){ return cs_status; } - - public void setCs_status(String cs_status){ this.cs_status = cs_status; } - @Column(name = "CS_DETAIL") public String getCs_detail(){ return cs_detail; } @@ -97,6 +92,16 @@ this.pgCsDocumentList = pgCsDocumentList; } + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "PGCONSTRUCTIONTYPE_ID") + public PgConstructionType getPgConstructionTypeId() { + return pgConstructionTypeId; + } + + public void setPgConstructionTypeId(PgConstructionType pgConstructionTypeId) { + this.pgConstructionTypeId = pgConstructionTypeId; + } @Column(name = "ACTIVE") public int getActive(){ return active; } diff --git a/src/main/java/com/casic/PgInterface/construction/domain/PgConstructionType.java b/src/main/java/com/casic/PgInterface/construction/domain/PgConstructionType.java new file mode 100644 index 0000000..6909234 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/construction/domain/PgConstructionType.java @@ -0,0 +1,57 @@ +package com.casic.PgInterface.construction.domain; + +import javax.persistence.*; +import java.io.Serializable; +import java.util.List; + +/** + * Created by yxw on 2018/4/10. + */ +@Entity +@Table(name = "PG_CONSTRUCTION_TYPE") +@SequenceGenerator(name = "SEQ_PG_CONSTRUCTION_TYPE_ID", sequenceName = "SEQ_PG_CONSTRUCTION_TYPE_ID", allocationSize = 1,initialValue = 1) +public class PgConstructionType implements Serializable { + + private static final long serialVersionUID = 1L; + private long id; + private String typeName;//项目状态 + private List pgConstructionList;//项目 + private int active;//状态位 + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_CONSTRUCTION_TYPE_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "TYPENAME") + public String getTypeName() { + return typeName; + } + + public void setTypeName(String typeName) { + this.typeName = typeName; + } + + @Column(name = "ACTIVE") + public int getActive() { + return active; + } + + public void setActive(int active) { + this.active = active; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgConstructionTypeId") + public List getPgConstructionList() { + return pgConstructionList; + } + + public void setPgConstructionList(List pgConstructionList) { + this.pgConstructionList = pgConstructionList; + } +} diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 2ee3724..276272c 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,6 +2,20 @@ + + + + + + + + + + + + + + @@ -44,13 +58,6 @@ @@ -249,6 +263,36 @@ - @@ -911,13 +1031,14 @@ + - + @@ -926,7 +1047,6 @@ - @@ -1011,7 +1131,7 @@ - @@ -1019,62 +1139,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1173,13 +1237,6 @@ - - - - - - - @@ -1201,20 +1258,6 @@ - - - - - - - - - - - - - - @@ -1229,13 +1272,6 @@ - - - - - - - @@ -1278,45 +1314,11 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -1335,13 +1337,6 @@ - - - - - - - @@ -1349,13 +1344,6 @@ - - - - - - - @@ -1382,6 +1370,217 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java b/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java index fad34cb..a928236 100644 --- a/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java +++ b/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java @@ -20,7 +20,6 @@ private static final long serialVersionUID = 1L; private long id; private String cs_name;//项目名称 - private String cs_status;//项目状态 private String cs_detail;//施工内容 private Date cs_beginTime;//施工开始时间 private Date cs_endTime;//施工结束时间 @@ -28,6 +27,7 @@ private String cs_phone;//联系方式 private String cs_type;//工程类别 private PgPartition pgPartitionId;//施工区域 + private PgConstructionType pgConstructionTypeId;//项目状态 private List pgCsDocumentList;//施工文档 private int active;//状态位 @@ -42,11 +42,6 @@ public void setCs_name(String cs_name){ this.cs_name = cs_name; } - @Column(name = "CS_STATUS") - public String getCs_status(){ return cs_status; } - - public void setCs_status(String cs_status){ this.cs_status = cs_status; } - @Column(name = "CS_DETAIL") public String getCs_detail(){ return cs_detail; } @@ -97,6 +92,16 @@ this.pgCsDocumentList = pgCsDocumentList; } + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "PGCONSTRUCTIONTYPE_ID") + public PgConstructionType getPgConstructionTypeId() { + return pgConstructionTypeId; + } + + public void setPgConstructionTypeId(PgConstructionType pgConstructionTypeId) { + this.pgConstructionTypeId = pgConstructionTypeId; + } @Column(name = "ACTIVE") public int getActive(){ return active; } diff --git a/src/main/java/com/casic/PgInterface/construction/domain/PgConstructionType.java b/src/main/java/com/casic/PgInterface/construction/domain/PgConstructionType.java new file mode 100644 index 0000000..6909234 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/construction/domain/PgConstructionType.java @@ -0,0 +1,57 @@ +package com.casic.PgInterface.construction.domain; + +import javax.persistence.*; +import java.io.Serializable; +import java.util.List; + +/** + * Created by yxw on 2018/4/10. + */ +@Entity +@Table(name = "PG_CONSTRUCTION_TYPE") +@SequenceGenerator(name = "SEQ_PG_CONSTRUCTION_TYPE_ID", sequenceName = "SEQ_PG_CONSTRUCTION_TYPE_ID", allocationSize = 1,initialValue = 1) +public class PgConstructionType implements Serializable { + + private static final long serialVersionUID = 1L; + private long id; + private String typeName;//项目状态 + private List pgConstructionList;//项目 + private int active;//状态位 + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_CONSTRUCTION_TYPE_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "TYPENAME") + public String getTypeName() { + return typeName; + } + + public void setTypeName(String typeName) { + this.typeName = typeName; + } + + @Column(name = "ACTIVE") + public int getActive() { + return active; + } + + public void setActive(int active) { + this.active = active; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgConstructionTypeId") + public List getPgConstructionList() { + return pgConstructionList; + } + + public void setPgConstructionList(List pgConstructionList) { + this.pgConstructionList = pgConstructionList; + } +} diff --git a/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionDto.java b/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionDto.java index c5ac9f9..4fa1888 100644 --- a/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionDto.java +++ b/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionDto.java @@ -11,7 +11,6 @@ private String id; private String cs_name;//项目名称 - private String cs_status;//项目状态 private String cs_detail;//施工内容 private String cs_beginTime;//施工开始时间 private String cs_endTime;//施工结束时间 @@ -19,6 +18,7 @@ private String cs_phone;//联系方式 private String cs_type;//工程类别 private String parName;//施工区域 + private String ConstructionType;//项目状态 private String active;//状态位 public String getId() { @@ -37,14 +37,6 @@ this.cs_name = cs_name; } - public String getCs_status() { - return cs_status; - } - - public void setCs_status(String cs_status) { - this.cs_status = cs_status; - } - public String getCs_detail() { return cs_detail; } @@ -105,13 +97,20 @@ public void setActive(String active){ this.active = active; } + public String getConstructionType() { + return ConstructionType; + } + + public void setConstructionType(String constructionType) { + ConstructionType = constructionType; + } + public PgConstructionDto(PgConstruction pgConstruction) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); this.setId(String.valueOf(pgConstruction.getId())); this.setCs_name(pgConstruction.getCs_name()); - this.setCs_status(pgConstruction.getCs_status()); this.setCs_detail(pgConstruction.getCs_detail()); this.setCs_beginTime(sdf.format(pgConstruction.getCs_beginTime())); this.setCs_endTime(sdf.format(pgConstruction.getCs_endTime())); @@ -119,6 +118,7 @@ this.setCs_phone(pgConstruction.getCs_phone()); this.setCs_type(pgConstruction.getCs_type()); this.setParName(pgConstruction.getPgPartitionId().getParName()); + this.setConstructionType(pgConstruction.getPgConstructionTypeId().getTypeName()); this.setActive(String.valueOf(pgConstruction.getActive())); } } diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 2ee3724..276272c 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,6 +2,20 @@ + + + + + + + + + + + + + + @@ -44,13 +58,6 @@ @@ -249,6 +263,36 @@ - @@ -911,13 +1031,14 @@ + - + @@ -926,7 +1047,6 @@ - @@ -1011,7 +1131,7 @@ - @@ -1019,62 +1139,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1173,13 +1237,6 @@ - - - - - - - @@ -1201,20 +1258,6 @@ - - - - - - - - - - - - - - @@ -1229,13 +1272,6 @@ - - - - - - - @@ -1278,45 +1314,11 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -1335,13 +1337,6 @@ - - - - - - - @@ -1349,13 +1344,6 @@ - - - - - - - @@ -1382,6 +1370,217 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java b/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java index fad34cb..a928236 100644 --- a/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java +++ b/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java @@ -20,7 +20,6 @@ private static final long serialVersionUID = 1L; private long id; private String cs_name;//项目名称 - private String cs_status;//项目状态 private String cs_detail;//施工内容 private Date cs_beginTime;//施工开始时间 private Date cs_endTime;//施工结束时间 @@ -28,6 +27,7 @@ private String cs_phone;//联系方式 private String cs_type;//工程类别 private PgPartition pgPartitionId;//施工区域 + private PgConstructionType pgConstructionTypeId;//项目状态 private List pgCsDocumentList;//施工文档 private int active;//状态位 @@ -42,11 +42,6 @@ public void setCs_name(String cs_name){ this.cs_name = cs_name; } - @Column(name = "CS_STATUS") - public String getCs_status(){ return cs_status; } - - public void setCs_status(String cs_status){ this.cs_status = cs_status; } - @Column(name = "CS_DETAIL") public String getCs_detail(){ return cs_detail; } @@ -97,6 +92,16 @@ this.pgCsDocumentList = pgCsDocumentList; } + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "PGCONSTRUCTIONTYPE_ID") + public PgConstructionType getPgConstructionTypeId() { + return pgConstructionTypeId; + } + + public void setPgConstructionTypeId(PgConstructionType pgConstructionTypeId) { + this.pgConstructionTypeId = pgConstructionTypeId; + } @Column(name = "ACTIVE") public int getActive(){ return active; } diff --git a/src/main/java/com/casic/PgInterface/construction/domain/PgConstructionType.java b/src/main/java/com/casic/PgInterface/construction/domain/PgConstructionType.java new file mode 100644 index 0000000..6909234 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/construction/domain/PgConstructionType.java @@ -0,0 +1,57 @@ +package com.casic.PgInterface.construction.domain; + +import javax.persistence.*; +import java.io.Serializable; +import java.util.List; + +/** + * Created by yxw on 2018/4/10. + */ +@Entity +@Table(name = "PG_CONSTRUCTION_TYPE") +@SequenceGenerator(name = "SEQ_PG_CONSTRUCTION_TYPE_ID", sequenceName = "SEQ_PG_CONSTRUCTION_TYPE_ID", allocationSize = 1,initialValue = 1) +public class PgConstructionType implements Serializable { + + private static final long serialVersionUID = 1L; + private long id; + private String typeName;//项目状态 + private List pgConstructionList;//项目 + private int active;//状态位 + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_CONSTRUCTION_TYPE_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "TYPENAME") + public String getTypeName() { + return typeName; + } + + public void setTypeName(String typeName) { + this.typeName = typeName; + } + + @Column(name = "ACTIVE") + public int getActive() { + return active; + } + + public void setActive(int active) { + this.active = active; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgConstructionTypeId") + public List getPgConstructionList() { + return pgConstructionList; + } + + public void setPgConstructionList(List pgConstructionList) { + this.pgConstructionList = pgConstructionList; + } +} diff --git a/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionDto.java b/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionDto.java index c5ac9f9..4fa1888 100644 --- a/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionDto.java +++ b/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionDto.java @@ -11,7 +11,6 @@ private String id; private String cs_name;//项目名称 - private String cs_status;//项目状态 private String cs_detail;//施工内容 private String cs_beginTime;//施工开始时间 private String cs_endTime;//施工结束时间 @@ -19,6 +18,7 @@ private String cs_phone;//联系方式 private String cs_type;//工程类别 private String parName;//施工区域 + private String ConstructionType;//项目状态 private String active;//状态位 public String getId() { @@ -37,14 +37,6 @@ this.cs_name = cs_name; } - public String getCs_status() { - return cs_status; - } - - public void setCs_status(String cs_status) { - this.cs_status = cs_status; - } - public String getCs_detail() { return cs_detail; } @@ -105,13 +97,20 @@ public void setActive(String active){ this.active = active; } + public String getConstructionType() { + return ConstructionType; + } + + public void setConstructionType(String constructionType) { + ConstructionType = constructionType; + } + public PgConstructionDto(PgConstruction pgConstruction) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); this.setId(String.valueOf(pgConstruction.getId())); this.setCs_name(pgConstruction.getCs_name()); - this.setCs_status(pgConstruction.getCs_status()); this.setCs_detail(pgConstruction.getCs_detail()); this.setCs_beginTime(sdf.format(pgConstruction.getCs_beginTime())); this.setCs_endTime(sdf.format(pgConstruction.getCs_endTime())); @@ -119,6 +118,7 @@ this.setCs_phone(pgConstruction.getCs_phone()); this.setCs_type(pgConstruction.getCs_type()); this.setParName(pgConstruction.getPgPartitionId().getParName()); + this.setConstructionType(pgConstruction.getPgConstructionTypeId().getTypeName()); this.setActive(String.valueOf(pgConstruction.getActive())); } } diff --git a/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionTypeDto.java b/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionTypeDto.java new file mode 100644 index 0000000..109c774 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionTypeDto.java @@ -0,0 +1,46 @@ +package com.casic.PgInterface.construction.dto; + +import com.casic.PgInterface.construction.domain.PgConstructionType; + +import java.io.Serializable; + +/** + * Created by yxw on 2018/4/10. + */ +public class PgConstructionTypeDto implements Serializable { + + private String id; + private String typeName;//项目状态 + private String active;//状态位 + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTypeName() { + return typeName; + } + + public void setTypeName(String typeName) { + this.typeName = typeName; + } + + public String getActive() { + return active; + } + + public void setActive(String active) { + this.active = active; + } + + public PgConstructionTypeDto(PgConstructionType pgConstructionType) + { + this.setId(String.valueOf(pgConstructionType.getId())); + this.setTypeName(pgConstructionType.getTypeName()); + this.setActive(String.valueOf(pgConstructionType.getActive())); + } +} diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 2ee3724..276272c 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,6 +2,20 @@ + + + + + + + + + + + + + + @@ -44,13 +58,6 @@ @@ -249,6 +263,36 @@ - @@ -911,13 +1031,14 @@ + - + @@ -926,7 +1047,6 @@ - @@ -1011,7 +1131,7 @@ - @@ -1019,62 +1139,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1173,13 +1237,6 @@ - - - - - - - @@ -1201,20 +1258,6 @@ - - - - - - - - - - - - - - @@ -1229,13 +1272,6 @@ - - - - - - - @@ -1278,45 +1314,11 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -1335,13 +1337,6 @@ - - - - - - - @@ -1349,13 +1344,6 @@ - - - - - - - @@ -1382,6 +1370,217 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java b/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java index fad34cb..a928236 100644 --- a/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java +++ b/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java @@ -20,7 +20,6 @@ private static final long serialVersionUID = 1L; private long id; private String cs_name;//项目名称 - private String cs_status;//项目状态 private String cs_detail;//施工内容 private Date cs_beginTime;//施工开始时间 private Date cs_endTime;//施工结束时间 @@ -28,6 +27,7 @@ private String cs_phone;//联系方式 private String cs_type;//工程类别 private PgPartition pgPartitionId;//施工区域 + private PgConstructionType pgConstructionTypeId;//项目状态 private List pgCsDocumentList;//施工文档 private int active;//状态位 @@ -42,11 +42,6 @@ public void setCs_name(String cs_name){ this.cs_name = cs_name; } - @Column(name = "CS_STATUS") - public String getCs_status(){ return cs_status; } - - public void setCs_status(String cs_status){ this.cs_status = cs_status; } - @Column(name = "CS_DETAIL") public String getCs_detail(){ return cs_detail; } @@ -97,6 +92,16 @@ this.pgCsDocumentList = pgCsDocumentList; } + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "PGCONSTRUCTIONTYPE_ID") + public PgConstructionType getPgConstructionTypeId() { + return pgConstructionTypeId; + } + + public void setPgConstructionTypeId(PgConstructionType pgConstructionTypeId) { + this.pgConstructionTypeId = pgConstructionTypeId; + } @Column(name = "ACTIVE") public int getActive(){ return active; } diff --git a/src/main/java/com/casic/PgInterface/construction/domain/PgConstructionType.java b/src/main/java/com/casic/PgInterface/construction/domain/PgConstructionType.java new file mode 100644 index 0000000..6909234 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/construction/domain/PgConstructionType.java @@ -0,0 +1,57 @@ +package com.casic.PgInterface.construction.domain; + +import javax.persistence.*; +import java.io.Serializable; +import java.util.List; + +/** + * Created by yxw on 2018/4/10. + */ +@Entity +@Table(name = "PG_CONSTRUCTION_TYPE") +@SequenceGenerator(name = "SEQ_PG_CONSTRUCTION_TYPE_ID", sequenceName = "SEQ_PG_CONSTRUCTION_TYPE_ID", allocationSize = 1,initialValue = 1) +public class PgConstructionType implements Serializable { + + private static final long serialVersionUID = 1L; + private long id; + private String typeName;//项目状态 + private List pgConstructionList;//项目 + private int active;//状态位 + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_CONSTRUCTION_TYPE_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "TYPENAME") + public String getTypeName() { + return typeName; + } + + public void setTypeName(String typeName) { + this.typeName = typeName; + } + + @Column(name = "ACTIVE") + public int getActive() { + return active; + } + + public void setActive(int active) { + this.active = active; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgConstructionTypeId") + public List getPgConstructionList() { + return pgConstructionList; + } + + public void setPgConstructionList(List pgConstructionList) { + this.pgConstructionList = pgConstructionList; + } +} diff --git a/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionDto.java b/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionDto.java index c5ac9f9..4fa1888 100644 --- a/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionDto.java +++ b/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionDto.java @@ -11,7 +11,6 @@ private String id; private String cs_name;//项目名称 - private String cs_status;//项目状态 private String cs_detail;//施工内容 private String cs_beginTime;//施工开始时间 private String cs_endTime;//施工结束时间 @@ -19,6 +18,7 @@ private String cs_phone;//联系方式 private String cs_type;//工程类别 private String parName;//施工区域 + private String ConstructionType;//项目状态 private String active;//状态位 public String getId() { @@ -37,14 +37,6 @@ this.cs_name = cs_name; } - public String getCs_status() { - return cs_status; - } - - public void setCs_status(String cs_status) { - this.cs_status = cs_status; - } - public String getCs_detail() { return cs_detail; } @@ -105,13 +97,20 @@ public void setActive(String active){ this.active = active; } + public String getConstructionType() { + return ConstructionType; + } + + public void setConstructionType(String constructionType) { + ConstructionType = constructionType; + } + public PgConstructionDto(PgConstruction pgConstruction) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); this.setId(String.valueOf(pgConstruction.getId())); this.setCs_name(pgConstruction.getCs_name()); - this.setCs_status(pgConstruction.getCs_status()); this.setCs_detail(pgConstruction.getCs_detail()); this.setCs_beginTime(sdf.format(pgConstruction.getCs_beginTime())); this.setCs_endTime(sdf.format(pgConstruction.getCs_endTime())); @@ -119,6 +118,7 @@ this.setCs_phone(pgConstruction.getCs_phone()); this.setCs_type(pgConstruction.getCs_type()); this.setParName(pgConstruction.getPgPartitionId().getParName()); + this.setConstructionType(pgConstruction.getPgConstructionTypeId().getTypeName()); this.setActive(String.valueOf(pgConstruction.getActive())); } } diff --git a/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionTypeDto.java b/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionTypeDto.java new file mode 100644 index 0000000..109c774 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionTypeDto.java @@ -0,0 +1,46 @@ +package com.casic.PgInterface.construction.dto; + +import com.casic.PgInterface.construction.domain.PgConstructionType; + +import java.io.Serializable; + +/** + * Created by yxw on 2018/4/10. + */ +public class PgConstructionTypeDto implements Serializable { + + private String id; + private String typeName;//项目状态 + private String active;//状态位 + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTypeName() { + return typeName; + } + + public void setTypeName(String typeName) { + this.typeName = typeName; + } + + public String getActive() { + return active; + } + + public void setActive(String active) { + this.active = active; + } + + public PgConstructionTypeDto(PgConstructionType pgConstructionType) + { + this.setId(String.valueOf(pgConstructionType.getId())); + this.setTypeName(pgConstructionType.getTypeName()); + this.setActive(String.valueOf(pgConstructionType.getActive())); + } +} diff --git a/src/main/java/com/casic/PgInterface/construction/manager/PgConstructionTypeManager.java b/src/main/java/com/casic/PgInterface/construction/manager/PgConstructionTypeManager.java new file mode 100644 index 0000000..f81a33d --- /dev/null +++ b/src/main/java/com/casic/PgInterface/construction/manager/PgConstructionTypeManager.java @@ -0,0 +1,49 @@ +package com.casic.PgInterface.construction.manager; + +import com.casic.PgInterface.construction.domain.PgConstructionType; +import com.casic.PgInterface.construction.dto.PgConstructionTypeDto; +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import org.hibernate.Criteria; +import org.hibernate.criterion.Order; +import org.hibernate.criterion.Restrictions; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by yxw on 2018/4/10. + */ +@Service +public class PgConstructionTypeManager extends HibernateEntityDao { + + public PgConstructionType getConstructionTypeByType(String typeName) + { + Criteria criteria=createCriteria(PgConstructionType.class); + criteria.add(Restrictions.eq("typeName",typeName)); + criteria.add(Restrictions.eq("active",1)); + + List pgConstructionTypeList=criteria.list(); + if(pgConstructionTypeList!=null&&pgConstructionTypeList.size()!=0) + return pgConstructionTypeList.get(0); + else + return null; + } + + public List getAllConstructionTypeDto() + { + Criteria criteria=createCriteria(PgConstructionType.class); + criteria.add(Restrictions.eq("active",1)); + criteria.addOrder(Order.desc("id")); + + List pgConstructionTypeList=criteria.list(); + List pgConstructionTypeDtoList=new ArrayList(); + for(PgConstructionType pgConstructionType : pgConstructionTypeList) + { + pgConstructionTypeDtoList.add(new PgConstructionTypeDto(pgConstructionType)); + } + + return pgConstructionTypeDtoList; + } + +} diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 2ee3724..276272c 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,6 +2,20 @@ + + + + + + + + + + + + + + @@ -44,13 +58,6 @@ @@ -249,6 +263,36 @@ - @@ -911,13 +1031,14 @@ + - + @@ -926,7 +1047,6 @@ - @@ -1011,7 +1131,7 @@ - @@ -1019,62 +1139,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1173,13 +1237,6 @@ - - - - - - - @@ -1201,20 +1258,6 @@ - - - - - - - - - - - - - - @@ -1229,13 +1272,6 @@ - - - - - - - @@ -1278,45 +1314,11 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -1335,13 +1337,6 @@ - - - - - - - @@ -1349,13 +1344,6 @@ - - - - - - - @@ -1382,6 +1370,217 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java b/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java index fad34cb..a928236 100644 --- a/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java +++ b/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java @@ -20,7 +20,6 @@ private static final long serialVersionUID = 1L; private long id; private String cs_name;//项目名称 - private String cs_status;//项目状态 private String cs_detail;//施工内容 private Date cs_beginTime;//施工开始时间 private Date cs_endTime;//施工结束时间 @@ -28,6 +27,7 @@ private String cs_phone;//联系方式 private String cs_type;//工程类别 private PgPartition pgPartitionId;//施工区域 + private PgConstructionType pgConstructionTypeId;//项目状态 private List pgCsDocumentList;//施工文档 private int active;//状态位 @@ -42,11 +42,6 @@ public void setCs_name(String cs_name){ this.cs_name = cs_name; } - @Column(name = "CS_STATUS") - public String getCs_status(){ return cs_status; } - - public void setCs_status(String cs_status){ this.cs_status = cs_status; } - @Column(name = "CS_DETAIL") public String getCs_detail(){ return cs_detail; } @@ -97,6 +92,16 @@ this.pgCsDocumentList = pgCsDocumentList; } + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "PGCONSTRUCTIONTYPE_ID") + public PgConstructionType getPgConstructionTypeId() { + return pgConstructionTypeId; + } + + public void setPgConstructionTypeId(PgConstructionType pgConstructionTypeId) { + this.pgConstructionTypeId = pgConstructionTypeId; + } @Column(name = "ACTIVE") public int getActive(){ return active; } diff --git a/src/main/java/com/casic/PgInterface/construction/domain/PgConstructionType.java b/src/main/java/com/casic/PgInterface/construction/domain/PgConstructionType.java new file mode 100644 index 0000000..6909234 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/construction/domain/PgConstructionType.java @@ -0,0 +1,57 @@ +package com.casic.PgInterface.construction.domain; + +import javax.persistence.*; +import java.io.Serializable; +import java.util.List; + +/** + * Created by yxw on 2018/4/10. + */ +@Entity +@Table(name = "PG_CONSTRUCTION_TYPE") +@SequenceGenerator(name = "SEQ_PG_CONSTRUCTION_TYPE_ID", sequenceName = "SEQ_PG_CONSTRUCTION_TYPE_ID", allocationSize = 1,initialValue = 1) +public class PgConstructionType implements Serializable { + + private static final long serialVersionUID = 1L; + private long id; + private String typeName;//项目状态 + private List pgConstructionList;//项目 + private int active;//状态位 + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_CONSTRUCTION_TYPE_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "TYPENAME") + public String getTypeName() { + return typeName; + } + + public void setTypeName(String typeName) { + this.typeName = typeName; + } + + @Column(name = "ACTIVE") + public int getActive() { + return active; + } + + public void setActive(int active) { + this.active = active; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgConstructionTypeId") + public List getPgConstructionList() { + return pgConstructionList; + } + + public void setPgConstructionList(List pgConstructionList) { + this.pgConstructionList = pgConstructionList; + } +} diff --git a/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionDto.java b/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionDto.java index c5ac9f9..4fa1888 100644 --- a/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionDto.java +++ b/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionDto.java @@ -11,7 +11,6 @@ private String id; private String cs_name;//项目名称 - private String cs_status;//项目状态 private String cs_detail;//施工内容 private String cs_beginTime;//施工开始时间 private String cs_endTime;//施工结束时间 @@ -19,6 +18,7 @@ private String cs_phone;//联系方式 private String cs_type;//工程类别 private String parName;//施工区域 + private String ConstructionType;//项目状态 private String active;//状态位 public String getId() { @@ -37,14 +37,6 @@ this.cs_name = cs_name; } - public String getCs_status() { - return cs_status; - } - - public void setCs_status(String cs_status) { - this.cs_status = cs_status; - } - public String getCs_detail() { return cs_detail; } @@ -105,13 +97,20 @@ public void setActive(String active){ this.active = active; } + public String getConstructionType() { + return ConstructionType; + } + + public void setConstructionType(String constructionType) { + ConstructionType = constructionType; + } + public PgConstructionDto(PgConstruction pgConstruction) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); this.setId(String.valueOf(pgConstruction.getId())); this.setCs_name(pgConstruction.getCs_name()); - this.setCs_status(pgConstruction.getCs_status()); this.setCs_detail(pgConstruction.getCs_detail()); this.setCs_beginTime(sdf.format(pgConstruction.getCs_beginTime())); this.setCs_endTime(sdf.format(pgConstruction.getCs_endTime())); @@ -119,6 +118,7 @@ this.setCs_phone(pgConstruction.getCs_phone()); this.setCs_type(pgConstruction.getCs_type()); this.setParName(pgConstruction.getPgPartitionId().getParName()); + this.setConstructionType(pgConstruction.getPgConstructionTypeId().getTypeName()); this.setActive(String.valueOf(pgConstruction.getActive())); } } diff --git a/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionTypeDto.java b/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionTypeDto.java new file mode 100644 index 0000000..109c774 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionTypeDto.java @@ -0,0 +1,46 @@ +package com.casic.PgInterface.construction.dto; + +import com.casic.PgInterface.construction.domain.PgConstructionType; + +import java.io.Serializable; + +/** + * Created by yxw on 2018/4/10. + */ +public class PgConstructionTypeDto implements Serializable { + + private String id; + private String typeName;//项目状态 + private String active;//状态位 + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTypeName() { + return typeName; + } + + public void setTypeName(String typeName) { + this.typeName = typeName; + } + + public String getActive() { + return active; + } + + public void setActive(String active) { + this.active = active; + } + + public PgConstructionTypeDto(PgConstructionType pgConstructionType) + { + this.setId(String.valueOf(pgConstructionType.getId())); + this.setTypeName(pgConstructionType.getTypeName()); + this.setActive(String.valueOf(pgConstructionType.getActive())); + } +} diff --git a/src/main/java/com/casic/PgInterface/construction/manager/PgConstructionTypeManager.java b/src/main/java/com/casic/PgInterface/construction/manager/PgConstructionTypeManager.java new file mode 100644 index 0000000..f81a33d --- /dev/null +++ b/src/main/java/com/casic/PgInterface/construction/manager/PgConstructionTypeManager.java @@ -0,0 +1,49 @@ +package com.casic.PgInterface.construction.manager; + +import com.casic.PgInterface.construction.domain.PgConstructionType; +import com.casic.PgInterface.construction.dto.PgConstructionTypeDto; +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import org.hibernate.Criteria; +import org.hibernate.criterion.Order; +import org.hibernate.criterion.Restrictions; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by yxw on 2018/4/10. + */ +@Service +public class PgConstructionTypeManager extends HibernateEntityDao { + + public PgConstructionType getConstructionTypeByType(String typeName) + { + Criteria criteria=createCriteria(PgConstructionType.class); + criteria.add(Restrictions.eq("typeName",typeName)); + criteria.add(Restrictions.eq("active",1)); + + List pgConstructionTypeList=criteria.list(); + if(pgConstructionTypeList!=null&&pgConstructionTypeList.size()!=0) + return pgConstructionTypeList.get(0); + else + return null; + } + + public List getAllConstructionTypeDto() + { + Criteria criteria=createCriteria(PgConstructionType.class); + criteria.add(Restrictions.eq("active",1)); + criteria.addOrder(Order.desc("id")); + + List pgConstructionTypeList=criteria.list(); + List pgConstructionTypeDtoList=new ArrayList(); + for(PgConstructionType pgConstructionType : pgConstructionTypeList) + { + pgConstructionTypeDtoList.add(new PgConstructionTypeDto(pgConstructionType)); + } + + return pgConstructionTypeDtoList; + } + +} diff --git a/src/main/java/com/casic/PgInterface/reservePlan/manager/PgReservePlanManager.java b/src/main/java/com/casic/PgInterface/reservePlan/manager/PgReservePlanManager.java index bbb735b..365737e 100644 --- a/src/main/java/com/casic/PgInterface/reservePlan/manager/PgReservePlanManager.java +++ b/src/main/java/com/casic/PgInterface/reservePlan/manager/PgReservePlanManager.java @@ -4,14 +4,12 @@ import com.casic.PgInterface.devTable.domain.PgAlarm; import com.casic.PgInterface.reservePlan.domain.PgReservePlan; import com.casic.PgInterface.reservePlan.dto.PgReservePlanDto; -import com.sun.org.apache.xml.internal.security.utils.Base64; import org.hibernate.Criteria; import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; -import org.springframework.web.multipart.MultipartFile; import sun.misc.BASE64Decoder; import javax.servlet.http.HttpServletRequest; @@ -26,45 +24,7 @@ @Service public class PgReservePlanManager extends HibernateEntityDao { - public String saveFiles(List files,String fileType){ - String [] fileNames = new String[files.size()]; - String [] fileBuffers = new String[files.size()]; - try { - for (int i = 0; i < files.size(); i++) { - fileNames[i] = files.get(i).getOriginalFilename(); - byte[] fis = files.get(i).getBytes(); - fileBuffers[i] = new String(Base64.encode(fis, Base64.BASE64DEFAULTLENGTH)); - } - HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); - String strDirPath = request.getSession().getServletContext().getRealPath(""); - - FileOutputStream fos = null; - String image_toDir = strDirPath + "\\"+fileType;//存储路径 - String imageName = ""; - for (int i = 0; i < fileBuffers.length; i++) { - if (fileBuffers[i] != null && fileNames[i] != null) { - imageName += fileType+"/"+fileNames[i] + ","; - byte[] buffer = new BASE64Decoder().decodeBuffer(fileBuffers[i]);//对android传过来的图片字符串进行解码 - File destDir = new File(image_toDir); - if (!destDir.exists()) - destDir.mkdirs(); - File imageFile = new File(destDir, fileNames[i]); - fos = new FileOutputStream(imageFile);//保存图片 - fos.write(buffer); - fos.flush(); - fos.close(); - } - } - return imageName.substring(0,imageName.length()-1); - } - catch(Exception ex) - { - ex.printStackTrace(); - return ""; - } - } - - public String saveFiles(String fileBuffer,String fileName,String fileType){ + public String saveFiles(String fileBuffer, String fileName, String fileType){ try { HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); @@ -92,6 +52,8 @@ } } + + public List getReservePlanDtoByAlarmType(PgAlarm pgAlarm) { try { diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 2ee3724..276272c 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,6 +2,20 @@ + + + + + + + + + + + + + + @@ -44,13 +58,6 @@ @@ -249,6 +263,36 @@ - @@ -911,13 +1031,14 @@ + - + @@ -926,7 +1047,6 @@ - @@ -1011,7 +1131,7 @@ - @@ -1019,62 +1139,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1173,13 +1237,6 @@ - - - - - - - @@ -1201,20 +1258,6 @@ - - - - - - - - - - - - - - @@ -1229,13 +1272,6 @@ - - - - - - - @@ -1278,45 +1314,11 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -1335,13 +1337,6 @@ - - - - - - - @@ -1349,13 +1344,6 @@ - - - - - - - @@ -1382,6 +1370,217 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java b/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java index fad34cb..a928236 100644 --- a/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java +++ b/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java @@ -20,7 +20,6 @@ private static final long serialVersionUID = 1L; private long id; private String cs_name;//项目名称 - private String cs_status;//项目状态 private String cs_detail;//施工内容 private Date cs_beginTime;//施工开始时间 private Date cs_endTime;//施工结束时间 @@ -28,6 +27,7 @@ private String cs_phone;//联系方式 private String cs_type;//工程类别 private PgPartition pgPartitionId;//施工区域 + private PgConstructionType pgConstructionTypeId;//项目状态 private List pgCsDocumentList;//施工文档 private int active;//状态位 @@ -42,11 +42,6 @@ public void setCs_name(String cs_name){ this.cs_name = cs_name; } - @Column(name = "CS_STATUS") - public String getCs_status(){ return cs_status; } - - public void setCs_status(String cs_status){ this.cs_status = cs_status; } - @Column(name = "CS_DETAIL") public String getCs_detail(){ return cs_detail; } @@ -97,6 +92,16 @@ this.pgCsDocumentList = pgCsDocumentList; } + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "PGCONSTRUCTIONTYPE_ID") + public PgConstructionType getPgConstructionTypeId() { + return pgConstructionTypeId; + } + + public void setPgConstructionTypeId(PgConstructionType pgConstructionTypeId) { + this.pgConstructionTypeId = pgConstructionTypeId; + } @Column(name = "ACTIVE") public int getActive(){ return active; } diff --git a/src/main/java/com/casic/PgInterface/construction/domain/PgConstructionType.java b/src/main/java/com/casic/PgInterface/construction/domain/PgConstructionType.java new file mode 100644 index 0000000..6909234 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/construction/domain/PgConstructionType.java @@ -0,0 +1,57 @@ +package com.casic.PgInterface.construction.domain; + +import javax.persistence.*; +import java.io.Serializable; +import java.util.List; + +/** + * Created by yxw on 2018/4/10. + */ +@Entity +@Table(name = "PG_CONSTRUCTION_TYPE") +@SequenceGenerator(name = "SEQ_PG_CONSTRUCTION_TYPE_ID", sequenceName = "SEQ_PG_CONSTRUCTION_TYPE_ID", allocationSize = 1,initialValue = 1) +public class PgConstructionType implements Serializable { + + private static final long serialVersionUID = 1L; + private long id; + private String typeName;//项目状态 + private List pgConstructionList;//项目 + private int active;//状态位 + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_CONSTRUCTION_TYPE_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "TYPENAME") + public String getTypeName() { + return typeName; + } + + public void setTypeName(String typeName) { + this.typeName = typeName; + } + + @Column(name = "ACTIVE") + public int getActive() { + return active; + } + + public void setActive(int active) { + this.active = active; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgConstructionTypeId") + public List getPgConstructionList() { + return pgConstructionList; + } + + public void setPgConstructionList(List pgConstructionList) { + this.pgConstructionList = pgConstructionList; + } +} diff --git a/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionDto.java b/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionDto.java index c5ac9f9..4fa1888 100644 --- a/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionDto.java +++ b/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionDto.java @@ -11,7 +11,6 @@ private String id; private String cs_name;//项目名称 - private String cs_status;//项目状态 private String cs_detail;//施工内容 private String cs_beginTime;//施工开始时间 private String cs_endTime;//施工结束时间 @@ -19,6 +18,7 @@ private String cs_phone;//联系方式 private String cs_type;//工程类别 private String parName;//施工区域 + private String ConstructionType;//项目状态 private String active;//状态位 public String getId() { @@ -37,14 +37,6 @@ this.cs_name = cs_name; } - public String getCs_status() { - return cs_status; - } - - public void setCs_status(String cs_status) { - this.cs_status = cs_status; - } - public String getCs_detail() { return cs_detail; } @@ -105,13 +97,20 @@ public void setActive(String active){ this.active = active; } + public String getConstructionType() { + return ConstructionType; + } + + public void setConstructionType(String constructionType) { + ConstructionType = constructionType; + } + public PgConstructionDto(PgConstruction pgConstruction) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); this.setId(String.valueOf(pgConstruction.getId())); this.setCs_name(pgConstruction.getCs_name()); - this.setCs_status(pgConstruction.getCs_status()); this.setCs_detail(pgConstruction.getCs_detail()); this.setCs_beginTime(sdf.format(pgConstruction.getCs_beginTime())); this.setCs_endTime(sdf.format(pgConstruction.getCs_endTime())); @@ -119,6 +118,7 @@ this.setCs_phone(pgConstruction.getCs_phone()); this.setCs_type(pgConstruction.getCs_type()); this.setParName(pgConstruction.getPgPartitionId().getParName()); + this.setConstructionType(pgConstruction.getPgConstructionTypeId().getTypeName()); this.setActive(String.valueOf(pgConstruction.getActive())); } } diff --git a/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionTypeDto.java b/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionTypeDto.java new file mode 100644 index 0000000..109c774 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionTypeDto.java @@ -0,0 +1,46 @@ +package com.casic.PgInterface.construction.dto; + +import com.casic.PgInterface.construction.domain.PgConstructionType; + +import java.io.Serializable; + +/** + * Created by yxw on 2018/4/10. + */ +public class PgConstructionTypeDto implements Serializable { + + private String id; + private String typeName;//项目状态 + private String active;//状态位 + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTypeName() { + return typeName; + } + + public void setTypeName(String typeName) { + this.typeName = typeName; + } + + public String getActive() { + return active; + } + + public void setActive(String active) { + this.active = active; + } + + public PgConstructionTypeDto(PgConstructionType pgConstructionType) + { + this.setId(String.valueOf(pgConstructionType.getId())); + this.setTypeName(pgConstructionType.getTypeName()); + this.setActive(String.valueOf(pgConstructionType.getActive())); + } +} diff --git a/src/main/java/com/casic/PgInterface/construction/manager/PgConstructionTypeManager.java b/src/main/java/com/casic/PgInterface/construction/manager/PgConstructionTypeManager.java new file mode 100644 index 0000000..f81a33d --- /dev/null +++ b/src/main/java/com/casic/PgInterface/construction/manager/PgConstructionTypeManager.java @@ -0,0 +1,49 @@ +package com.casic.PgInterface.construction.manager; + +import com.casic.PgInterface.construction.domain.PgConstructionType; +import com.casic.PgInterface.construction.dto.PgConstructionTypeDto; +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import org.hibernate.Criteria; +import org.hibernate.criterion.Order; +import org.hibernate.criterion.Restrictions; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by yxw on 2018/4/10. + */ +@Service +public class PgConstructionTypeManager extends HibernateEntityDao { + + public PgConstructionType getConstructionTypeByType(String typeName) + { + Criteria criteria=createCriteria(PgConstructionType.class); + criteria.add(Restrictions.eq("typeName",typeName)); + criteria.add(Restrictions.eq("active",1)); + + List pgConstructionTypeList=criteria.list(); + if(pgConstructionTypeList!=null&&pgConstructionTypeList.size()!=0) + return pgConstructionTypeList.get(0); + else + return null; + } + + public List getAllConstructionTypeDto() + { + Criteria criteria=createCriteria(PgConstructionType.class); + criteria.add(Restrictions.eq("active",1)); + criteria.addOrder(Order.desc("id")); + + List pgConstructionTypeList=criteria.list(); + List pgConstructionTypeDtoList=new ArrayList(); + for(PgConstructionType pgConstructionType : pgConstructionTypeList) + { + pgConstructionTypeDtoList.add(new PgConstructionTypeDto(pgConstructionType)); + } + + return pgConstructionTypeDtoList; + } + +} diff --git a/src/main/java/com/casic/PgInterface/reservePlan/manager/PgReservePlanManager.java b/src/main/java/com/casic/PgInterface/reservePlan/manager/PgReservePlanManager.java index bbb735b..365737e 100644 --- a/src/main/java/com/casic/PgInterface/reservePlan/manager/PgReservePlanManager.java +++ b/src/main/java/com/casic/PgInterface/reservePlan/manager/PgReservePlanManager.java @@ -4,14 +4,12 @@ import com.casic.PgInterface.devTable.domain.PgAlarm; import com.casic.PgInterface.reservePlan.domain.PgReservePlan; import com.casic.PgInterface.reservePlan.dto.PgReservePlanDto; -import com.sun.org.apache.xml.internal.security.utils.Base64; import org.hibernate.Criteria; import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; -import org.springframework.web.multipart.MultipartFile; import sun.misc.BASE64Decoder; import javax.servlet.http.HttpServletRequest; @@ -26,45 +24,7 @@ @Service public class PgReservePlanManager extends HibernateEntityDao { - public String saveFiles(List files,String fileType){ - String [] fileNames = new String[files.size()]; - String [] fileBuffers = new String[files.size()]; - try { - for (int i = 0; i < files.size(); i++) { - fileNames[i] = files.get(i).getOriginalFilename(); - byte[] fis = files.get(i).getBytes(); - fileBuffers[i] = new String(Base64.encode(fis, Base64.BASE64DEFAULTLENGTH)); - } - HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); - String strDirPath = request.getSession().getServletContext().getRealPath(""); - - FileOutputStream fos = null; - String image_toDir = strDirPath + "\\"+fileType;//存储路径 - String imageName = ""; - for (int i = 0; i < fileBuffers.length; i++) { - if (fileBuffers[i] != null && fileNames[i] != null) { - imageName += fileType+"/"+fileNames[i] + ","; - byte[] buffer = new BASE64Decoder().decodeBuffer(fileBuffers[i]);//对android传过来的图片字符串进行解码 - File destDir = new File(image_toDir); - if (!destDir.exists()) - destDir.mkdirs(); - File imageFile = new File(destDir, fileNames[i]); - fos = new FileOutputStream(imageFile);//保存图片 - fos.write(buffer); - fos.flush(); - fos.close(); - } - } - return imageName.substring(0,imageName.length()-1); - } - catch(Exception ex) - { - ex.printStackTrace(); - return ""; - } - } - - public String saveFiles(String fileBuffer,String fileName,String fileType){ + public String saveFiles(String fileBuffer, String fileName, String fileType){ try { HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); @@ -92,6 +52,8 @@ } } + + public List getReservePlanDtoByAlarmType(PgAlarm pgAlarm) { try { diff --git a/src/main/java/com/casic/PgInterface/rs/PgConstructionRs.java b/src/main/java/com/casic/PgInterface/rs/PgConstructionRs.java index 6ec29e1..932f2e2 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgConstructionRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgConstructionRs.java @@ -1,9 +1,11 @@ package com.casic.PgInterface.rs; import com.casic.PgInterface.construction.domain.PgConstruction; +import com.casic.PgInterface.construction.domain.PgConstructionType; import com.casic.PgInterface.construction.dto.PgConstructTjDto; import com.casic.PgInterface.construction.dto.PgConstructionDto; import com.casic.PgInterface.construction.manager.PgConstructionManager; +import com.casic.PgInterface.construction.manager.PgConstructionTypeManager; import com.casic.PgInterface.devTable.domain.PgPartition; import com.casic.PgInterface.devTable.dto.PgDeviceDto; import com.casic.PgInterface.devTable.manager.PgDeviceManager; @@ -34,6 +36,8 @@ private static Logger logger = LoggerFactory.getLogger(PgConstructionRs.class); + private PgConstructionTypeManager pgConstructionTypeManager; + private PgConstructionManager pgConstructionManager; private PgPartitionManager pgPartitionManager; @@ -52,6 +56,11 @@ } @Resource + public void setPgConstructionTypeManager(PgConstructionTypeManager pgConstructionTypeManager) { + this.pgConstructionTypeManager = pgConstructionTypeManager; + } + + @Resource public void setPgDeviceManager(PgDeviceManager pgDeviceManager) { this.pgDeviceManager = pgDeviceManager; } @@ -63,7 +72,7 @@ @Path("addConstruction") @Produces(MediaType.APPLICATION_JSON) public Map addConstruction(@FormParam("cs_name")String cs_name, - @FormParam("cs_status")String cs_status, + @FormParam("constructionType")String constructionType, @FormParam("cs_detail")String cs_detail, @FormParam("cs_beginTime")String cs_beginTime, @FormParam("cs_endTime")String cs_endTime, @@ -77,11 +86,12 @@ String msg = "" ; SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); try { + + PgConstructionType pgConstructionType=pgConstructionTypeManager.getConstructionTypeByType(constructionType); PgPartition pgPartition=pgPartitionManager.getPartitionByParName(parName); PgConstruction pgConstruction = new PgConstruction(); pgConstruction.setCs_name(cs_name); - pgConstruction.setCs_status(cs_status); pgConstruction.setCs_detail(cs_detail); pgConstruction.setCs_beginTime(sdf.parse(cs_beginTime)); pgConstruction.setCs_endTime(sdf.parse(cs_endTime)); @@ -89,6 +99,7 @@ pgConstruction.setCs_phone(cs_phone); pgConstruction.setCs_type(cs_type); pgConstruction.setPgPartitionId(pgPartition); + pgConstruction.setPgConstructionTypeId(pgConstructionType); pgConstruction.setActive(1); logger.info("保存成功"); @@ -114,7 +125,7 @@ @Produces(MediaType.APPLICATION_JSON) public Map editConstruction(@FormParam("id")String id, @FormParam("cs_name")String cs_name, - @FormParam("cs_status")String cs_status, + @FormParam("constructionType")String constructionType, @FormParam("cs_detail")String cs_detail, @FormParam("cs_beginTime")String cs_beginTime, @FormParam("cs_endTime")String cs_endTime, @@ -136,11 +147,12 @@ result = "false"; msg = "请输入ID"; }else { + PgConstructionType pgConstructionType=pgConstructionTypeManager.getConstructionTypeByType(constructionType); + PgPartition pgPartition=pgPartitionManager.getPartitionByParName(parName); PgConstruction pgConstruction = pgConstructionManager.get(Long.valueOf(id)); pgConstruction.setCs_name(cs_name); - pgConstruction.setCs_status(cs_status); pgConstruction.setCs_detail(cs_detail); pgConstruction.setCs_beginTime(sdf.parse(cs_beginTime)); pgConstruction.setCs_endTime(sdf.parse(cs_endTime)); @@ -148,6 +160,7 @@ pgConstruction.setCs_phone(cs_phone); pgConstruction.setCs_type(cs_type); pgConstruction.setPgPartitionId(pgPartition); + pgConstruction.setPgConstructionTypeId(pgConstructionType); pgConstruction.setActive(1); pgConstructionManager.save(pgConstruction); diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 2ee3724..276272c 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,6 +2,20 @@ + + + + + + + + + + + + + + @@ -44,13 +58,6 @@ @@ -249,6 +263,36 @@ - @@ -911,13 +1031,14 @@ + - + @@ -926,7 +1047,6 @@ - @@ -1011,7 +1131,7 @@ - @@ -1019,62 +1139,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1173,13 +1237,6 @@ - - - - - - - @@ -1201,20 +1258,6 @@ - - - - - - - - - - - - - - @@ -1229,13 +1272,6 @@ - - - - - - - @@ -1278,45 +1314,11 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -1335,13 +1337,6 @@ - - - - - - - @@ -1349,13 +1344,6 @@ - - - - - - - @@ -1382,6 +1370,217 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java b/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java index fad34cb..a928236 100644 --- a/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java +++ b/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java @@ -20,7 +20,6 @@ private static final long serialVersionUID = 1L; private long id; private String cs_name;//项目名称 - private String cs_status;//项目状态 private String cs_detail;//施工内容 private Date cs_beginTime;//施工开始时间 private Date cs_endTime;//施工结束时间 @@ -28,6 +27,7 @@ private String cs_phone;//联系方式 private String cs_type;//工程类别 private PgPartition pgPartitionId;//施工区域 + private PgConstructionType pgConstructionTypeId;//项目状态 private List pgCsDocumentList;//施工文档 private int active;//状态位 @@ -42,11 +42,6 @@ public void setCs_name(String cs_name){ this.cs_name = cs_name; } - @Column(name = "CS_STATUS") - public String getCs_status(){ return cs_status; } - - public void setCs_status(String cs_status){ this.cs_status = cs_status; } - @Column(name = "CS_DETAIL") public String getCs_detail(){ return cs_detail; } @@ -97,6 +92,16 @@ this.pgCsDocumentList = pgCsDocumentList; } + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "PGCONSTRUCTIONTYPE_ID") + public PgConstructionType getPgConstructionTypeId() { + return pgConstructionTypeId; + } + + public void setPgConstructionTypeId(PgConstructionType pgConstructionTypeId) { + this.pgConstructionTypeId = pgConstructionTypeId; + } @Column(name = "ACTIVE") public int getActive(){ return active; } diff --git a/src/main/java/com/casic/PgInterface/construction/domain/PgConstructionType.java b/src/main/java/com/casic/PgInterface/construction/domain/PgConstructionType.java new file mode 100644 index 0000000..6909234 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/construction/domain/PgConstructionType.java @@ -0,0 +1,57 @@ +package com.casic.PgInterface.construction.domain; + +import javax.persistence.*; +import java.io.Serializable; +import java.util.List; + +/** + * Created by yxw on 2018/4/10. + */ +@Entity +@Table(name = "PG_CONSTRUCTION_TYPE") +@SequenceGenerator(name = "SEQ_PG_CONSTRUCTION_TYPE_ID", sequenceName = "SEQ_PG_CONSTRUCTION_TYPE_ID", allocationSize = 1,initialValue = 1) +public class PgConstructionType implements Serializable { + + private static final long serialVersionUID = 1L; + private long id; + private String typeName;//项目状态 + private List pgConstructionList;//项目 + private int active;//状态位 + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_CONSTRUCTION_TYPE_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "TYPENAME") + public String getTypeName() { + return typeName; + } + + public void setTypeName(String typeName) { + this.typeName = typeName; + } + + @Column(name = "ACTIVE") + public int getActive() { + return active; + } + + public void setActive(int active) { + this.active = active; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgConstructionTypeId") + public List getPgConstructionList() { + return pgConstructionList; + } + + public void setPgConstructionList(List pgConstructionList) { + this.pgConstructionList = pgConstructionList; + } +} diff --git a/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionDto.java b/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionDto.java index c5ac9f9..4fa1888 100644 --- a/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionDto.java +++ b/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionDto.java @@ -11,7 +11,6 @@ private String id; private String cs_name;//项目名称 - private String cs_status;//项目状态 private String cs_detail;//施工内容 private String cs_beginTime;//施工开始时间 private String cs_endTime;//施工结束时间 @@ -19,6 +18,7 @@ private String cs_phone;//联系方式 private String cs_type;//工程类别 private String parName;//施工区域 + private String ConstructionType;//项目状态 private String active;//状态位 public String getId() { @@ -37,14 +37,6 @@ this.cs_name = cs_name; } - public String getCs_status() { - return cs_status; - } - - public void setCs_status(String cs_status) { - this.cs_status = cs_status; - } - public String getCs_detail() { return cs_detail; } @@ -105,13 +97,20 @@ public void setActive(String active){ this.active = active; } + public String getConstructionType() { + return ConstructionType; + } + + public void setConstructionType(String constructionType) { + ConstructionType = constructionType; + } + public PgConstructionDto(PgConstruction pgConstruction) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); this.setId(String.valueOf(pgConstruction.getId())); this.setCs_name(pgConstruction.getCs_name()); - this.setCs_status(pgConstruction.getCs_status()); this.setCs_detail(pgConstruction.getCs_detail()); this.setCs_beginTime(sdf.format(pgConstruction.getCs_beginTime())); this.setCs_endTime(sdf.format(pgConstruction.getCs_endTime())); @@ -119,6 +118,7 @@ this.setCs_phone(pgConstruction.getCs_phone()); this.setCs_type(pgConstruction.getCs_type()); this.setParName(pgConstruction.getPgPartitionId().getParName()); + this.setConstructionType(pgConstruction.getPgConstructionTypeId().getTypeName()); this.setActive(String.valueOf(pgConstruction.getActive())); } } diff --git a/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionTypeDto.java b/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionTypeDto.java new file mode 100644 index 0000000..109c774 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionTypeDto.java @@ -0,0 +1,46 @@ +package com.casic.PgInterface.construction.dto; + +import com.casic.PgInterface.construction.domain.PgConstructionType; + +import java.io.Serializable; + +/** + * Created by yxw on 2018/4/10. + */ +public class PgConstructionTypeDto implements Serializable { + + private String id; + private String typeName;//项目状态 + private String active;//状态位 + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTypeName() { + return typeName; + } + + public void setTypeName(String typeName) { + this.typeName = typeName; + } + + public String getActive() { + return active; + } + + public void setActive(String active) { + this.active = active; + } + + public PgConstructionTypeDto(PgConstructionType pgConstructionType) + { + this.setId(String.valueOf(pgConstructionType.getId())); + this.setTypeName(pgConstructionType.getTypeName()); + this.setActive(String.valueOf(pgConstructionType.getActive())); + } +} diff --git a/src/main/java/com/casic/PgInterface/construction/manager/PgConstructionTypeManager.java b/src/main/java/com/casic/PgInterface/construction/manager/PgConstructionTypeManager.java new file mode 100644 index 0000000..f81a33d --- /dev/null +++ b/src/main/java/com/casic/PgInterface/construction/manager/PgConstructionTypeManager.java @@ -0,0 +1,49 @@ +package com.casic.PgInterface.construction.manager; + +import com.casic.PgInterface.construction.domain.PgConstructionType; +import com.casic.PgInterface.construction.dto.PgConstructionTypeDto; +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import org.hibernate.Criteria; +import org.hibernate.criterion.Order; +import org.hibernate.criterion.Restrictions; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by yxw on 2018/4/10. + */ +@Service +public class PgConstructionTypeManager extends HibernateEntityDao { + + public PgConstructionType getConstructionTypeByType(String typeName) + { + Criteria criteria=createCriteria(PgConstructionType.class); + criteria.add(Restrictions.eq("typeName",typeName)); + criteria.add(Restrictions.eq("active",1)); + + List pgConstructionTypeList=criteria.list(); + if(pgConstructionTypeList!=null&&pgConstructionTypeList.size()!=0) + return pgConstructionTypeList.get(0); + else + return null; + } + + public List getAllConstructionTypeDto() + { + Criteria criteria=createCriteria(PgConstructionType.class); + criteria.add(Restrictions.eq("active",1)); + criteria.addOrder(Order.desc("id")); + + List pgConstructionTypeList=criteria.list(); + List pgConstructionTypeDtoList=new ArrayList(); + for(PgConstructionType pgConstructionType : pgConstructionTypeList) + { + pgConstructionTypeDtoList.add(new PgConstructionTypeDto(pgConstructionType)); + } + + return pgConstructionTypeDtoList; + } + +} diff --git a/src/main/java/com/casic/PgInterface/reservePlan/manager/PgReservePlanManager.java b/src/main/java/com/casic/PgInterface/reservePlan/manager/PgReservePlanManager.java index bbb735b..365737e 100644 --- a/src/main/java/com/casic/PgInterface/reservePlan/manager/PgReservePlanManager.java +++ b/src/main/java/com/casic/PgInterface/reservePlan/manager/PgReservePlanManager.java @@ -4,14 +4,12 @@ import com.casic.PgInterface.devTable.domain.PgAlarm; import com.casic.PgInterface.reservePlan.domain.PgReservePlan; import com.casic.PgInterface.reservePlan.dto.PgReservePlanDto; -import com.sun.org.apache.xml.internal.security.utils.Base64; import org.hibernate.Criteria; import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; -import org.springframework.web.multipart.MultipartFile; import sun.misc.BASE64Decoder; import javax.servlet.http.HttpServletRequest; @@ -26,45 +24,7 @@ @Service public class PgReservePlanManager extends HibernateEntityDao { - public String saveFiles(List files,String fileType){ - String [] fileNames = new String[files.size()]; - String [] fileBuffers = new String[files.size()]; - try { - for (int i = 0; i < files.size(); i++) { - fileNames[i] = files.get(i).getOriginalFilename(); - byte[] fis = files.get(i).getBytes(); - fileBuffers[i] = new String(Base64.encode(fis, Base64.BASE64DEFAULTLENGTH)); - } - HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); - String strDirPath = request.getSession().getServletContext().getRealPath(""); - - FileOutputStream fos = null; - String image_toDir = strDirPath + "\\"+fileType;//存储路径 - String imageName = ""; - for (int i = 0; i < fileBuffers.length; i++) { - if (fileBuffers[i] != null && fileNames[i] != null) { - imageName += fileType+"/"+fileNames[i] + ","; - byte[] buffer = new BASE64Decoder().decodeBuffer(fileBuffers[i]);//对android传过来的图片字符串进行解码 - File destDir = new File(image_toDir); - if (!destDir.exists()) - destDir.mkdirs(); - File imageFile = new File(destDir, fileNames[i]); - fos = new FileOutputStream(imageFile);//保存图片 - fos.write(buffer); - fos.flush(); - fos.close(); - } - } - return imageName.substring(0,imageName.length()-1); - } - catch(Exception ex) - { - ex.printStackTrace(); - return ""; - } - } - - public String saveFiles(String fileBuffer,String fileName,String fileType){ + public String saveFiles(String fileBuffer, String fileName, String fileType){ try { HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); @@ -92,6 +52,8 @@ } } + + public List getReservePlanDtoByAlarmType(PgAlarm pgAlarm) { try { diff --git a/src/main/java/com/casic/PgInterface/rs/PgConstructionRs.java b/src/main/java/com/casic/PgInterface/rs/PgConstructionRs.java index 6ec29e1..932f2e2 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgConstructionRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgConstructionRs.java @@ -1,9 +1,11 @@ package com.casic.PgInterface.rs; import com.casic.PgInterface.construction.domain.PgConstruction; +import com.casic.PgInterface.construction.domain.PgConstructionType; import com.casic.PgInterface.construction.dto.PgConstructTjDto; import com.casic.PgInterface.construction.dto.PgConstructionDto; import com.casic.PgInterface.construction.manager.PgConstructionManager; +import com.casic.PgInterface.construction.manager.PgConstructionTypeManager; import com.casic.PgInterface.devTable.domain.PgPartition; import com.casic.PgInterface.devTable.dto.PgDeviceDto; import com.casic.PgInterface.devTable.manager.PgDeviceManager; @@ -34,6 +36,8 @@ private static Logger logger = LoggerFactory.getLogger(PgConstructionRs.class); + private PgConstructionTypeManager pgConstructionTypeManager; + private PgConstructionManager pgConstructionManager; private PgPartitionManager pgPartitionManager; @@ -52,6 +56,11 @@ } @Resource + public void setPgConstructionTypeManager(PgConstructionTypeManager pgConstructionTypeManager) { + this.pgConstructionTypeManager = pgConstructionTypeManager; + } + + @Resource public void setPgDeviceManager(PgDeviceManager pgDeviceManager) { this.pgDeviceManager = pgDeviceManager; } @@ -63,7 +72,7 @@ @Path("addConstruction") @Produces(MediaType.APPLICATION_JSON) public Map addConstruction(@FormParam("cs_name")String cs_name, - @FormParam("cs_status")String cs_status, + @FormParam("constructionType")String constructionType, @FormParam("cs_detail")String cs_detail, @FormParam("cs_beginTime")String cs_beginTime, @FormParam("cs_endTime")String cs_endTime, @@ -77,11 +86,12 @@ String msg = "" ; SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); try { + + PgConstructionType pgConstructionType=pgConstructionTypeManager.getConstructionTypeByType(constructionType); PgPartition pgPartition=pgPartitionManager.getPartitionByParName(parName); PgConstruction pgConstruction = new PgConstruction(); pgConstruction.setCs_name(cs_name); - pgConstruction.setCs_status(cs_status); pgConstruction.setCs_detail(cs_detail); pgConstruction.setCs_beginTime(sdf.parse(cs_beginTime)); pgConstruction.setCs_endTime(sdf.parse(cs_endTime)); @@ -89,6 +99,7 @@ pgConstruction.setCs_phone(cs_phone); pgConstruction.setCs_type(cs_type); pgConstruction.setPgPartitionId(pgPartition); + pgConstruction.setPgConstructionTypeId(pgConstructionType); pgConstruction.setActive(1); logger.info("保存成功"); @@ -114,7 +125,7 @@ @Produces(MediaType.APPLICATION_JSON) public Map editConstruction(@FormParam("id")String id, @FormParam("cs_name")String cs_name, - @FormParam("cs_status")String cs_status, + @FormParam("constructionType")String constructionType, @FormParam("cs_detail")String cs_detail, @FormParam("cs_beginTime")String cs_beginTime, @FormParam("cs_endTime")String cs_endTime, @@ -136,11 +147,12 @@ result = "false"; msg = "请输入ID"; }else { + PgConstructionType pgConstructionType=pgConstructionTypeManager.getConstructionTypeByType(constructionType); + PgPartition pgPartition=pgPartitionManager.getPartitionByParName(parName); PgConstruction pgConstruction = pgConstructionManager.get(Long.valueOf(id)); pgConstruction.setCs_name(cs_name); - pgConstruction.setCs_status(cs_status); pgConstruction.setCs_detail(cs_detail); pgConstruction.setCs_beginTime(sdf.parse(cs_beginTime)); pgConstruction.setCs_endTime(sdf.parse(cs_endTime)); @@ -148,6 +160,7 @@ pgConstruction.setCs_phone(cs_phone); pgConstruction.setCs_type(cs_type); pgConstruction.setPgPartitionId(pgPartition); + pgConstruction.setPgConstructionTypeId(pgConstructionType); pgConstruction.setActive(1); pgConstructionManager.save(pgConstruction); diff --git a/src/main/java/com/casic/PgInterface/rs/PgConstructionTypeRs.java b/src/main/java/com/casic/PgInterface/rs/PgConstructionTypeRs.java new file mode 100644 index 0000000..549b8e5 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/rs/PgConstructionTypeRs.java @@ -0,0 +1,178 @@ +package com.casic.PgInterface.rs; + +import com.casic.PgInterface.construction.domain.PgConstructionType; +import com.casic.PgInterface.construction.dto.PgConstructionTypeDto; +import com.casic.PgInterface.construction.manager.PgConstructionTypeManager; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import javax.ws.rs.FormParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Created by yxw on 2018/4/10. + */ +@Component +@Path("pgConstructionType") +public class PgConstructionTypeRs { + + private PgConstructionTypeManager pgConstructionTypeManager; + + @Resource + public void setPgConstructionTypeManager(PgConstructionTypeManager pgConstructionTypeManager) { + this.pgConstructionTypeManager = pgConstructionTypeManager; + } + + /** + * 获取项目状态 + */ + @POST + @Path("getConstructionType") + @Produces(MediaType.APPLICATION_JSON) + public Map getConstructionType() throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + List pgConstructionTypeDtoList = new ArrayList(); + try { + pgConstructionTypeDtoList = pgConstructionTypeManager.getAllConstructionTypeDto(); + if (pgConstructionTypeDtoList.size() == 0) + msg = "没有项目类型信息"; + else + msg = "项目类型获取成功"; + } catch (Exception e) { + e.printStackTrace(); + msg = "项目类型信息获取失败"; + } + resultMap.put("msg", msg); + resultMap.put("result", pgConstructionTypeDtoList); + return resultMap; + } + + /** + * 新增项目状态 + */ + @POST + @Path("addConstructionType") + @Produces(MediaType.APPLICATION_JSON) + public Map addConstructionType(@FormParam("typeName") String typeName) throws Exception { + Map resultMap = new HashMap(); + String result = ""; + String msg = ""; + + try { + if (pgConstructionTypeManager.getConstructionTypeByType(typeName) != null) { + result = "false"; + msg = "已存项目状态"; + } else { + PgConstructionType pgConstructionType = new PgConstructionType(); + pgConstructionType.setTypeName(typeName); + pgConstructionType.setActive(1); + + pgConstructionTypeManager.save(pgConstructionType); + result = "true"; + msg = "保存成功"; + } + } catch (Exception e) { + result = "false"; + msg = "保存失败"; + e.printStackTrace(); + } + + resultMap.put("result", result); + resultMap.put("msg", msg); + return resultMap; + } + + /** + * 编辑项目状态 + */ + @POST + @Path("editConstruction") + @Produces(MediaType.APPLICATION_JSON) + public Map editConstruction(@FormParam("id") String id, + @FormParam("typeName") String typeName)throws Exception{ + Map resultMap = new HashMap(); + String result = ""; + String msg = ""; + + try{ + if(pgConstructionTypeManager.getConstructionTypeByType(typeName)!=null) + { + result = "false"; + msg = "已存项目状态"; + } + else { + PgConstructionType pgConstructionType = pgConstructionTypeManager.get(Long.valueOf(id)); + if(pgConstructionType==null) + { + result = "false"; + msg = "不存在项目状态"; + } + else { + pgConstructionType.setTypeName(typeName); + + pgConstructionTypeManager.save(pgConstructionType); + result = "true"; + msg = "编辑成功"; + } + } + } + catch(Exception e) + { + result = "false"; + msg = "编辑失败"; + e.printStackTrace(); + } + + resultMap.put("result",result); + resultMap.put("msg",msg); + + return resultMap; + } + + + /** + * 删除项目状态 + */ + @POST + @Path("deleteConstructionType") + @Produces(MediaType.APPLICATION_JSON) + public Map deleteConstructionType(@FormParam("id") String id)throws Exception { + + Map resultMap = new HashMap(); + String msg=""; + String result="false"; + + try { + PgConstructionType pgConstructionType=pgConstructionTypeManager.get(Long.valueOf(id)); + if(pgConstructionType==null) { + msg = "不存项目状态"; + result="false"; + } + else + { + pgConstructionType.setActive(0); + pgConstructionTypeManager.save(pgConstructionType); + msg="项目状态删除成功"; + result="true"; + } + }catch(Exception e){ + e.printStackTrace(); + msg="项目状态删除失败"; + result="false"; + } + resultMap.put("msg",msg); + resultMap.put("result",result); + + return resultMap; + } + + +} diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 2ee3724..276272c 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,6 +2,20 @@ + + + + + + + + + + + + + + @@ -44,13 +58,6 @@ @@ -249,6 +263,36 @@ - @@ -911,13 +1031,14 @@ + - + @@ -926,7 +1047,6 @@ - @@ -1011,7 +1131,7 @@ - @@ -1019,62 +1139,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1173,13 +1237,6 @@ - - - - - - - @@ -1201,20 +1258,6 @@ - - - - - - - - - - - - - - @@ -1229,13 +1272,6 @@ - - - - - - - @@ -1278,45 +1314,11 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -1335,13 +1337,6 @@ - - - - - - - @@ -1349,13 +1344,6 @@ - - - - - - - @@ -1382,6 +1370,217 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java b/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java index fad34cb..a928236 100644 --- a/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java +++ b/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java @@ -20,7 +20,6 @@ private static final long serialVersionUID = 1L; private long id; private String cs_name;//项目名称 - private String cs_status;//项目状态 private String cs_detail;//施工内容 private Date cs_beginTime;//施工开始时间 private Date cs_endTime;//施工结束时间 @@ -28,6 +27,7 @@ private String cs_phone;//联系方式 private String cs_type;//工程类别 private PgPartition pgPartitionId;//施工区域 + private PgConstructionType pgConstructionTypeId;//项目状态 private List pgCsDocumentList;//施工文档 private int active;//状态位 @@ -42,11 +42,6 @@ public void setCs_name(String cs_name){ this.cs_name = cs_name; } - @Column(name = "CS_STATUS") - public String getCs_status(){ return cs_status; } - - public void setCs_status(String cs_status){ this.cs_status = cs_status; } - @Column(name = "CS_DETAIL") public String getCs_detail(){ return cs_detail; } @@ -97,6 +92,16 @@ this.pgCsDocumentList = pgCsDocumentList; } + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "PGCONSTRUCTIONTYPE_ID") + public PgConstructionType getPgConstructionTypeId() { + return pgConstructionTypeId; + } + + public void setPgConstructionTypeId(PgConstructionType pgConstructionTypeId) { + this.pgConstructionTypeId = pgConstructionTypeId; + } @Column(name = "ACTIVE") public int getActive(){ return active; } diff --git a/src/main/java/com/casic/PgInterface/construction/domain/PgConstructionType.java b/src/main/java/com/casic/PgInterface/construction/domain/PgConstructionType.java new file mode 100644 index 0000000..6909234 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/construction/domain/PgConstructionType.java @@ -0,0 +1,57 @@ +package com.casic.PgInterface.construction.domain; + +import javax.persistence.*; +import java.io.Serializable; +import java.util.List; + +/** + * Created by yxw on 2018/4/10. + */ +@Entity +@Table(name = "PG_CONSTRUCTION_TYPE") +@SequenceGenerator(name = "SEQ_PG_CONSTRUCTION_TYPE_ID", sequenceName = "SEQ_PG_CONSTRUCTION_TYPE_ID", allocationSize = 1,initialValue = 1) +public class PgConstructionType implements Serializable { + + private static final long serialVersionUID = 1L; + private long id; + private String typeName;//项目状态 + private List pgConstructionList;//项目 + private int active;//状态位 + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_CONSTRUCTION_TYPE_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "TYPENAME") + public String getTypeName() { + return typeName; + } + + public void setTypeName(String typeName) { + this.typeName = typeName; + } + + @Column(name = "ACTIVE") + public int getActive() { + return active; + } + + public void setActive(int active) { + this.active = active; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgConstructionTypeId") + public List getPgConstructionList() { + return pgConstructionList; + } + + public void setPgConstructionList(List pgConstructionList) { + this.pgConstructionList = pgConstructionList; + } +} diff --git a/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionDto.java b/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionDto.java index c5ac9f9..4fa1888 100644 --- a/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionDto.java +++ b/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionDto.java @@ -11,7 +11,6 @@ private String id; private String cs_name;//项目名称 - private String cs_status;//项目状态 private String cs_detail;//施工内容 private String cs_beginTime;//施工开始时间 private String cs_endTime;//施工结束时间 @@ -19,6 +18,7 @@ private String cs_phone;//联系方式 private String cs_type;//工程类别 private String parName;//施工区域 + private String ConstructionType;//项目状态 private String active;//状态位 public String getId() { @@ -37,14 +37,6 @@ this.cs_name = cs_name; } - public String getCs_status() { - return cs_status; - } - - public void setCs_status(String cs_status) { - this.cs_status = cs_status; - } - public String getCs_detail() { return cs_detail; } @@ -105,13 +97,20 @@ public void setActive(String active){ this.active = active; } + public String getConstructionType() { + return ConstructionType; + } + + public void setConstructionType(String constructionType) { + ConstructionType = constructionType; + } + public PgConstructionDto(PgConstruction pgConstruction) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); this.setId(String.valueOf(pgConstruction.getId())); this.setCs_name(pgConstruction.getCs_name()); - this.setCs_status(pgConstruction.getCs_status()); this.setCs_detail(pgConstruction.getCs_detail()); this.setCs_beginTime(sdf.format(pgConstruction.getCs_beginTime())); this.setCs_endTime(sdf.format(pgConstruction.getCs_endTime())); @@ -119,6 +118,7 @@ this.setCs_phone(pgConstruction.getCs_phone()); this.setCs_type(pgConstruction.getCs_type()); this.setParName(pgConstruction.getPgPartitionId().getParName()); + this.setConstructionType(pgConstruction.getPgConstructionTypeId().getTypeName()); this.setActive(String.valueOf(pgConstruction.getActive())); } } diff --git a/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionTypeDto.java b/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionTypeDto.java new file mode 100644 index 0000000..109c774 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionTypeDto.java @@ -0,0 +1,46 @@ +package com.casic.PgInterface.construction.dto; + +import com.casic.PgInterface.construction.domain.PgConstructionType; + +import java.io.Serializable; + +/** + * Created by yxw on 2018/4/10. + */ +public class PgConstructionTypeDto implements Serializable { + + private String id; + private String typeName;//项目状态 + private String active;//状态位 + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTypeName() { + return typeName; + } + + public void setTypeName(String typeName) { + this.typeName = typeName; + } + + public String getActive() { + return active; + } + + public void setActive(String active) { + this.active = active; + } + + public PgConstructionTypeDto(PgConstructionType pgConstructionType) + { + this.setId(String.valueOf(pgConstructionType.getId())); + this.setTypeName(pgConstructionType.getTypeName()); + this.setActive(String.valueOf(pgConstructionType.getActive())); + } +} diff --git a/src/main/java/com/casic/PgInterface/construction/manager/PgConstructionTypeManager.java b/src/main/java/com/casic/PgInterface/construction/manager/PgConstructionTypeManager.java new file mode 100644 index 0000000..f81a33d --- /dev/null +++ b/src/main/java/com/casic/PgInterface/construction/manager/PgConstructionTypeManager.java @@ -0,0 +1,49 @@ +package com.casic.PgInterface.construction.manager; + +import com.casic.PgInterface.construction.domain.PgConstructionType; +import com.casic.PgInterface.construction.dto.PgConstructionTypeDto; +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import org.hibernate.Criteria; +import org.hibernate.criterion.Order; +import org.hibernate.criterion.Restrictions; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by yxw on 2018/4/10. + */ +@Service +public class PgConstructionTypeManager extends HibernateEntityDao { + + public PgConstructionType getConstructionTypeByType(String typeName) + { + Criteria criteria=createCriteria(PgConstructionType.class); + criteria.add(Restrictions.eq("typeName",typeName)); + criteria.add(Restrictions.eq("active",1)); + + List pgConstructionTypeList=criteria.list(); + if(pgConstructionTypeList!=null&&pgConstructionTypeList.size()!=0) + return pgConstructionTypeList.get(0); + else + return null; + } + + public List getAllConstructionTypeDto() + { + Criteria criteria=createCriteria(PgConstructionType.class); + criteria.add(Restrictions.eq("active",1)); + criteria.addOrder(Order.desc("id")); + + List pgConstructionTypeList=criteria.list(); + List pgConstructionTypeDtoList=new ArrayList(); + for(PgConstructionType pgConstructionType : pgConstructionTypeList) + { + pgConstructionTypeDtoList.add(new PgConstructionTypeDto(pgConstructionType)); + } + + return pgConstructionTypeDtoList; + } + +} diff --git a/src/main/java/com/casic/PgInterface/reservePlan/manager/PgReservePlanManager.java b/src/main/java/com/casic/PgInterface/reservePlan/manager/PgReservePlanManager.java index bbb735b..365737e 100644 --- a/src/main/java/com/casic/PgInterface/reservePlan/manager/PgReservePlanManager.java +++ b/src/main/java/com/casic/PgInterface/reservePlan/manager/PgReservePlanManager.java @@ -4,14 +4,12 @@ import com.casic.PgInterface.devTable.domain.PgAlarm; import com.casic.PgInterface.reservePlan.domain.PgReservePlan; import com.casic.PgInterface.reservePlan.dto.PgReservePlanDto; -import com.sun.org.apache.xml.internal.security.utils.Base64; import org.hibernate.Criteria; import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; -import org.springframework.web.multipart.MultipartFile; import sun.misc.BASE64Decoder; import javax.servlet.http.HttpServletRequest; @@ -26,45 +24,7 @@ @Service public class PgReservePlanManager extends HibernateEntityDao { - public String saveFiles(List files,String fileType){ - String [] fileNames = new String[files.size()]; - String [] fileBuffers = new String[files.size()]; - try { - for (int i = 0; i < files.size(); i++) { - fileNames[i] = files.get(i).getOriginalFilename(); - byte[] fis = files.get(i).getBytes(); - fileBuffers[i] = new String(Base64.encode(fis, Base64.BASE64DEFAULTLENGTH)); - } - HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); - String strDirPath = request.getSession().getServletContext().getRealPath(""); - - FileOutputStream fos = null; - String image_toDir = strDirPath + "\\"+fileType;//存储路径 - String imageName = ""; - for (int i = 0; i < fileBuffers.length; i++) { - if (fileBuffers[i] != null && fileNames[i] != null) { - imageName += fileType+"/"+fileNames[i] + ","; - byte[] buffer = new BASE64Decoder().decodeBuffer(fileBuffers[i]);//对android传过来的图片字符串进行解码 - File destDir = new File(image_toDir); - if (!destDir.exists()) - destDir.mkdirs(); - File imageFile = new File(destDir, fileNames[i]); - fos = new FileOutputStream(imageFile);//保存图片 - fos.write(buffer); - fos.flush(); - fos.close(); - } - } - return imageName.substring(0,imageName.length()-1); - } - catch(Exception ex) - { - ex.printStackTrace(); - return ""; - } - } - - public String saveFiles(String fileBuffer,String fileName,String fileType){ + public String saveFiles(String fileBuffer, String fileName, String fileType){ try { HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); @@ -92,6 +52,8 @@ } } + + public List getReservePlanDtoByAlarmType(PgAlarm pgAlarm) { try { diff --git a/src/main/java/com/casic/PgInterface/rs/PgConstructionRs.java b/src/main/java/com/casic/PgInterface/rs/PgConstructionRs.java index 6ec29e1..932f2e2 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgConstructionRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgConstructionRs.java @@ -1,9 +1,11 @@ package com.casic.PgInterface.rs; import com.casic.PgInterface.construction.domain.PgConstruction; +import com.casic.PgInterface.construction.domain.PgConstructionType; import com.casic.PgInterface.construction.dto.PgConstructTjDto; import com.casic.PgInterface.construction.dto.PgConstructionDto; import com.casic.PgInterface.construction.manager.PgConstructionManager; +import com.casic.PgInterface.construction.manager.PgConstructionTypeManager; import com.casic.PgInterface.devTable.domain.PgPartition; import com.casic.PgInterface.devTable.dto.PgDeviceDto; import com.casic.PgInterface.devTable.manager.PgDeviceManager; @@ -34,6 +36,8 @@ private static Logger logger = LoggerFactory.getLogger(PgConstructionRs.class); + private PgConstructionTypeManager pgConstructionTypeManager; + private PgConstructionManager pgConstructionManager; private PgPartitionManager pgPartitionManager; @@ -52,6 +56,11 @@ } @Resource + public void setPgConstructionTypeManager(PgConstructionTypeManager pgConstructionTypeManager) { + this.pgConstructionTypeManager = pgConstructionTypeManager; + } + + @Resource public void setPgDeviceManager(PgDeviceManager pgDeviceManager) { this.pgDeviceManager = pgDeviceManager; } @@ -63,7 +72,7 @@ @Path("addConstruction") @Produces(MediaType.APPLICATION_JSON) public Map addConstruction(@FormParam("cs_name")String cs_name, - @FormParam("cs_status")String cs_status, + @FormParam("constructionType")String constructionType, @FormParam("cs_detail")String cs_detail, @FormParam("cs_beginTime")String cs_beginTime, @FormParam("cs_endTime")String cs_endTime, @@ -77,11 +86,12 @@ String msg = "" ; SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); try { + + PgConstructionType pgConstructionType=pgConstructionTypeManager.getConstructionTypeByType(constructionType); PgPartition pgPartition=pgPartitionManager.getPartitionByParName(parName); PgConstruction pgConstruction = new PgConstruction(); pgConstruction.setCs_name(cs_name); - pgConstruction.setCs_status(cs_status); pgConstruction.setCs_detail(cs_detail); pgConstruction.setCs_beginTime(sdf.parse(cs_beginTime)); pgConstruction.setCs_endTime(sdf.parse(cs_endTime)); @@ -89,6 +99,7 @@ pgConstruction.setCs_phone(cs_phone); pgConstruction.setCs_type(cs_type); pgConstruction.setPgPartitionId(pgPartition); + pgConstruction.setPgConstructionTypeId(pgConstructionType); pgConstruction.setActive(1); logger.info("保存成功"); @@ -114,7 +125,7 @@ @Produces(MediaType.APPLICATION_JSON) public Map editConstruction(@FormParam("id")String id, @FormParam("cs_name")String cs_name, - @FormParam("cs_status")String cs_status, + @FormParam("constructionType")String constructionType, @FormParam("cs_detail")String cs_detail, @FormParam("cs_beginTime")String cs_beginTime, @FormParam("cs_endTime")String cs_endTime, @@ -136,11 +147,12 @@ result = "false"; msg = "请输入ID"; }else { + PgConstructionType pgConstructionType=pgConstructionTypeManager.getConstructionTypeByType(constructionType); + PgPartition pgPartition=pgPartitionManager.getPartitionByParName(parName); PgConstruction pgConstruction = pgConstructionManager.get(Long.valueOf(id)); pgConstruction.setCs_name(cs_name); - pgConstruction.setCs_status(cs_status); pgConstruction.setCs_detail(cs_detail); pgConstruction.setCs_beginTime(sdf.parse(cs_beginTime)); pgConstruction.setCs_endTime(sdf.parse(cs_endTime)); @@ -148,6 +160,7 @@ pgConstruction.setCs_phone(cs_phone); pgConstruction.setCs_type(cs_type); pgConstruction.setPgPartitionId(pgPartition); + pgConstruction.setPgConstructionTypeId(pgConstructionType); pgConstruction.setActive(1); pgConstructionManager.save(pgConstruction); diff --git a/src/main/java/com/casic/PgInterface/rs/PgConstructionTypeRs.java b/src/main/java/com/casic/PgInterface/rs/PgConstructionTypeRs.java new file mode 100644 index 0000000..549b8e5 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/rs/PgConstructionTypeRs.java @@ -0,0 +1,178 @@ +package com.casic.PgInterface.rs; + +import com.casic.PgInterface.construction.domain.PgConstructionType; +import com.casic.PgInterface.construction.dto.PgConstructionTypeDto; +import com.casic.PgInterface.construction.manager.PgConstructionTypeManager; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import javax.ws.rs.FormParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Created by yxw on 2018/4/10. + */ +@Component +@Path("pgConstructionType") +public class PgConstructionTypeRs { + + private PgConstructionTypeManager pgConstructionTypeManager; + + @Resource + public void setPgConstructionTypeManager(PgConstructionTypeManager pgConstructionTypeManager) { + this.pgConstructionTypeManager = pgConstructionTypeManager; + } + + /** + * 获取项目状态 + */ + @POST + @Path("getConstructionType") + @Produces(MediaType.APPLICATION_JSON) + public Map getConstructionType() throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + List pgConstructionTypeDtoList = new ArrayList(); + try { + pgConstructionTypeDtoList = pgConstructionTypeManager.getAllConstructionTypeDto(); + if (pgConstructionTypeDtoList.size() == 0) + msg = "没有项目类型信息"; + else + msg = "项目类型获取成功"; + } catch (Exception e) { + e.printStackTrace(); + msg = "项目类型信息获取失败"; + } + resultMap.put("msg", msg); + resultMap.put("result", pgConstructionTypeDtoList); + return resultMap; + } + + /** + * 新增项目状态 + */ + @POST + @Path("addConstructionType") + @Produces(MediaType.APPLICATION_JSON) + public Map addConstructionType(@FormParam("typeName") String typeName) throws Exception { + Map resultMap = new HashMap(); + String result = ""; + String msg = ""; + + try { + if (pgConstructionTypeManager.getConstructionTypeByType(typeName) != null) { + result = "false"; + msg = "已存项目状态"; + } else { + PgConstructionType pgConstructionType = new PgConstructionType(); + pgConstructionType.setTypeName(typeName); + pgConstructionType.setActive(1); + + pgConstructionTypeManager.save(pgConstructionType); + result = "true"; + msg = "保存成功"; + } + } catch (Exception e) { + result = "false"; + msg = "保存失败"; + e.printStackTrace(); + } + + resultMap.put("result", result); + resultMap.put("msg", msg); + return resultMap; + } + + /** + * 编辑项目状态 + */ + @POST + @Path("editConstruction") + @Produces(MediaType.APPLICATION_JSON) + public Map editConstruction(@FormParam("id") String id, + @FormParam("typeName") String typeName)throws Exception{ + Map resultMap = new HashMap(); + String result = ""; + String msg = ""; + + try{ + if(pgConstructionTypeManager.getConstructionTypeByType(typeName)!=null) + { + result = "false"; + msg = "已存项目状态"; + } + else { + PgConstructionType pgConstructionType = pgConstructionTypeManager.get(Long.valueOf(id)); + if(pgConstructionType==null) + { + result = "false"; + msg = "不存在项目状态"; + } + else { + pgConstructionType.setTypeName(typeName); + + pgConstructionTypeManager.save(pgConstructionType); + result = "true"; + msg = "编辑成功"; + } + } + } + catch(Exception e) + { + result = "false"; + msg = "编辑失败"; + e.printStackTrace(); + } + + resultMap.put("result",result); + resultMap.put("msg",msg); + + return resultMap; + } + + + /** + * 删除项目状态 + */ + @POST + @Path("deleteConstructionType") + @Produces(MediaType.APPLICATION_JSON) + public Map deleteConstructionType(@FormParam("id") String id)throws Exception { + + Map resultMap = new HashMap(); + String msg=""; + String result="false"; + + try { + PgConstructionType pgConstructionType=pgConstructionTypeManager.get(Long.valueOf(id)); + if(pgConstructionType==null) { + msg = "不存项目状态"; + result="false"; + } + else + { + pgConstructionType.setActive(0); + pgConstructionTypeManager.save(pgConstructionType); + msg="项目状态删除成功"; + result="true"; + } + }catch(Exception e){ + e.printStackTrace(); + msg="项目状态删除失败"; + result="false"; + } + resultMap.put("msg",msg); + resultMap.put("result",result); + + return resultMap; + } + + +} diff --git a/src/main/java/com/casic/PgInterface/rs/PgOverViewRs.java b/src/main/java/com/casic/PgInterface/rs/PgOverViewRs.java index 8bca0fb..4f83629 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgOverViewRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgOverViewRs.java @@ -272,4 +272,5 @@ } + } \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 2ee3724..276272c 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,6 +2,20 @@ + + + + + + + + + + + + + + @@ -44,13 +58,6 @@ @@ -249,6 +263,36 @@ - @@ -911,13 +1031,14 @@ + - + @@ -926,7 +1047,6 @@ - @@ -1011,7 +1131,7 @@ - @@ -1019,62 +1139,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1173,13 +1237,6 @@ - - - - - - - @@ -1201,20 +1258,6 @@ - - - - - - - - - - - - - - @@ -1229,13 +1272,6 @@ - - - - - - - @@ -1278,45 +1314,11 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -1335,13 +1337,6 @@ - - - - - - - @@ -1349,13 +1344,6 @@ - - - - - - - @@ -1382,6 +1370,217 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java b/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java index fad34cb..a928236 100644 --- a/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java +++ b/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java @@ -20,7 +20,6 @@ private static final long serialVersionUID = 1L; private long id; private String cs_name;//项目名称 - private String cs_status;//项目状态 private String cs_detail;//施工内容 private Date cs_beginTime;//施工开始时间 private Date cs_endTime;//施工结束时间 @@ -28,6 +27,7 @@ private String cs_phone;//联系方式 private String cs_type;//工程类别 private PgPartition pgPartitionId;//施工区域 + private PgConstructionType pgConstructionTypeId;//项目状态 private List pgCsDocumentList;//施工文档 private int active;//状态位 @@ -42,11 +42,6 @@ public void setCs_name(String cs_name){ this.cs_name = cs_name; } - @Column(name = "CS_STATUS") - public String getCs_status(){ return cs_status; } - - public void setCs_status(String cs_status){ this.cs_status = cs_status; } - @Column(name = "CS_DETAIL") public String getCs_detail(){ return cs_detail; } @@ -97,6 +92,16 @@ this.pgCsDocumentList = pgCsDocumentList; } + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "PGCONSTRUCTIONTYPE_ID") + public PgConstructionType getPgConstructionTypeId() { + return pgConstructionTypeId; + } + + public void setPgConstructionTypeId(PgConstructionType pgConstructionTypeId) { + this.pgConstructionTypeId = pgConstructionTypeId; + } @Column(name = "ACTIVE") public int getActive(){ return active; } diff --git a/src/main/java/com/casic/PgInterface/construction/domain/PgConstructionType.java b/src/main/java/com/casic/PgInterface/construction/domain/PgConstructionType.java new file mode 100644 index 0000000..6909234 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/construction/domain/PgConstructionType.java @@ -0,0 +1,57 @@ +package com.casic.PgInterface.construction.domain; + +import javax.persistence.*; +import java.io.Serializable; +import java.util.List; + +/** + * Created by yxw on 2018/4/10. + */ +@Entity +@Table(name = "PG_CONSTRUCTION_TYPE") +@SequenceGenerator(name = "SEQ_PG_CONSTRUCTION_TYPE_ID", sequenceName = "SEQ_PG_CONSTRUCTION_TYPE_ID", allocationSize = 1,initialValue = 1) +public class PgConstructionType implements Serializable { + + private static final long serialVersionUID = 1L; + private long id; + private String typeName;//项目状态 + private List pgConstructionList;//项目 + private int active;//状态位 + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_CONSTRUCTION_TYPE_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "TYPENAME") + public String getTypeName() { + return typeName; + } + + public void setTypeName(String typeName) { + this.typeName = typeName; + } + + @Column(name = "ACTIVE") + public int getActive() { + return active; + } + + public void setActive(int active) { + this.active = active; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgConstructionTypeId") + public List getPgConstructionList() { + return pgConstructionList; + } + + public void setPgConstructionList(List pgConstructionList) { + this.pgConstructionList = pgConstructionList; + } +} diff --git a/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionDto.java b/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionDto.java index c5ac9f9..4fa1888 100644 --- a/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionDto.java +++ b/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionDto.java @@ -11,7 +11,6 @@ private String id; private String cs_name;//项目名称 - private String cs_status;//项目状态 private String cs_detail;//施工内容 private String cs_beginTime;//施工开始时间 private String cs_endTime;//施工结束时间 @@ -19,6 +18,7 @@ private String cs_phone;//联系方式 private String cs_type;//工程类别 private String parName;//施工区域 + private String ConstructionType;//项目状态 private String active;//状态位 public String getId() { @@ -37,14 +37,6 @@ this.cs_name = cs_name; } - public String getCs_status() { - return cs_status; - } - - public void setCs_status(String cs_status) { - this.cs_status = cs_status; - } - public String getCs_detail() { return cs_detail; } @@ -105,13 +97,20 @@ public void setActive(String active){ this.active = active; } + public String getConstructionType() { + return ConstructionType; + } + + public void setConstructionType(String constructionType) { + ConstructionType = constructionType; + } + public PgConstructionDto(PgConstruction pgConstruction) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); this.setId(String.valueOf(pgConstruction.getId())); this.setCs_name(pgConstruction.getCs_name()); - this.setCs_status(pgConstruction.getCs_status()); this.setCs_detail(pgConstruction.getCs_detail()); this.setCs_beginTime(sdf.format(pgConstruction.getCs_beginTime())); this.setCs_endTime(sdf.format(pgConstruction.getCs_endTime())); @@ -119,6 +118,7 @@ this.setCs_phone(pgConstruction.getCs_phone()); this.setCs_type(pgConstruction.getCs_type()); this.setParName(pgConstruction.getPgPartitionId().getParName()); + this.setConstructionType(pgConstruction.getPgConstructionTypeId().getTypeName()); this.setActive(String.valueOf(pgConstruction.getActive())); } } diff --git a/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionTypeDto.java b/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionTypeDto.java new file mode 100644 index 0000000..109c774 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionTypeDto.java @@ -0,0 +1,46 @@ +package com.casic.PgInterface.construction.dto; + +import com.casic.PgInterface.construction.domain.PgConstructionType; + +import java.io.Serializable; + +/** + * Created by yxw on 2018/4/10. + */ +public class PgConstructionTypeDto implements Serializable { + + private String id; + private String typeName;//项目状态 + private String active;//状态位 + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTypeName() { + return typeName; + } + + public void setTypeName(String typeName) { + this.typeName = typeName; + } + + public String getActive() { + return active; + } + + public void setActive(String active) { + this.active = active; + } + + public PgConstructionTypeDto(PgConstructionType pgConstructionType) + { + this.setId(String.valueOf(pgConstructionType.getId())); + this.setTypeName(pgConstructionType.getTypeName()); + this.setActive(String.valueOf(pgConstructionType.getActive())); + } +} diff --git a/src/main/java/com/casic/PgInterface/construction/manager/PgConstructionTypeManager.java b/src/main/java/com/casic/PgInterface/construction/manager/PgConstructionTypeManager.java new file mode 100644 index 0000000..f81a33d --- /dev/null +++ b/src/main/java/com/casic/PgInterface/construction/manager/PgConstructionTypeManager.java @@ -0,0 +1,49 @@ +package com.casic.PgInterface.construction.manager; + +import com.casic.PgInterface.construction.domain.PgConstructionType; +import com.casic.PgInterface.construction.dto.PgConstructionTypeDto; +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import org.hibernate.Criteria; +import org.hibernate.criterion.Order; +import org.hibernate.criterion.Restrictions; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by yxw on 2018/4/10. + */ +@Service +public class PgConstructionTypeManager extends HibernateEntityDao { + + public PgConstructionType getConstructionTypeByType(String typeName) + { + Criteria criteria=createCriteria(PgConstructionType.class); + criteria.add(Restrictions.eq("typeName",typeName)); + criteria.add(Restrictions.eq("active",1)); + + List pgConstructionTypeList=criteria.list(); + if(pgConstructionTypeList!=null&&pgConstructionTypeList.size()!=0) + return pgConstructionTypeList.get(0); + else + return null; + } + + public List getAllConstructionTypeDto() + { + Criteria criteria=createCriteria(PgConstructionType.class); + criteria.add(Restrictions.eq("active",1)); + criteria.addOrder(Order.desc("id")); + + List pgConstructionTypeList=criteria.list(); + List pgConstructionTypeDtoList=new ArrayList(); + for(PgConstructionType pgConstructionType : pgConstructionTypeList) + { + pgConstructionTypeDtoList.add(new PgConstructionTypeDto(pgConstructionType)); + } + + return pgConstructionTypeDtoList; + } + +} diff --git a/src/main/java/com/casic/PgInterface/reservePlan/manager/PgReservePlanManager.java b/src/main/java/com/casic/PgInterface/reservePlan/manager/PgReservePlanManager.java index bbb735b..365737e 100644 --- a/src/main/java/com/casic/PgInterface/reservePlan/manager/PgReservePlanManager.java +++ b/src/main/java/com/casic/PgInterface/reservePlan/manager/PgReservePlanManager.java @@ -4,14 +4,12 @@ import com.casic.PgInterface.devTable.domain.PgAlarm; import com.casic.PgInterface.reservePlan.domain.PgReservePlan; import com.casic.PgInterface.reservePlan.dto.PgReservePlanDto; -import com.sun.org.apache.xml.internal.security.utils.Base64; import org.hibernate.Criteria; import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; -import org.springframework.web.multipart.MultipartFile; import sun.misc.BASE64Decoder; import javax.servlet.http.HttpServletRequest; @@ -26,45 +24,7 @@ @Service public class PgReservePlanManager extends HibernateEntityDao { - public String saveFiles(List files,String fileType){ - String [] fileNames = new String[files.size()]; - String [] fileBuffers = new String[files.size()]; - try { - for (int i = 0; i < files.size(); i++) { - fileNames[i] = files.get(i).getOriginalFilename(); - byte[] fis = files.get(i).getBytes(); - fileBuffers[i] = new String(Base64.encode(fis, Base64.BASE64DEFAULTLENGTH)); - } - HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); - String strDirPath = request.getSession().getServletContext().getRealPath(""); - - FileOutputStream fos = null; - String image_toDir = strDirPath + "\\"+fileType;//存储路径 - String imageName = ""; - for (int i = 0; i < fileBuffers.length; i++) { - if (fileBuffers[i] != null && fileNames[i] != null) { - imageName += fileType+"/"+fileNames[i] + ","; - byte[] buffer = new BASE64Decoder().decodeBuffer(fileBuffers[i]);//对android传过来的图片字符串进行解码 - File destDir = new File(image_toDir); - if (!destDir.exists()) - destDir.mkdirs(); - File imageFile = new File(destDir, fileNames[i]); - fos = new FileOutputStream(imageFile);//保存图片 - fos.write(buffer); - fos.flush(); - fos.close(); - } - } - return imageName.substring(0,imageName.length()-1); - } - catch(Exception ex) - { - ex.printStackTrace(); - return ""; - } - } - - public String saveFiles(String fileBuffer,String fileName,String fileType){ + public String saveFiles(String fileBuffer, String fileName, String fileType){ try { HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); @@ -92,6 +52,8 @@ } } + + public List getReservePlanDtoByAlarmType(PgAlarm pgAlarm) { try { diff --git a/src/main/java/com/casic/PgInterface/rs/PgConstructionRs.java b/src/main/java/com/casic/PgInterface/rs/PgConstructionRs.java index 6ec29e1..932f2e2 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgConstructionRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgConstructionRs.java @@ -1,9 +1,11 @@ package com.casic.PgInterface.rs; import com.casic.PgInterface.construction.domain.PgConstruction; +import com.casic.PgInterface.construction.domain.PgConstructionType; import com.casic.PgInterface.construction.dto.PgConstructTjDto; import com.casic.PgInterface.construction.dto.PgConstructionDto; import com.casic.PgInterface.construction.manager.PgConstructionManager; +import com.casic.PgInterface.construction.manager.PgConstructionTypeManager; import com.casic.PgInterface.devTable.domain.PgPartition; import com.casic.PgInterface.devTable.dto.PgDeviceDto; import com.casic.PgInterface.devTable.manager.PgDeviceManager; @@ -34,6 +36,8 @@ private static Logger logger = LoggerFactory.getLogger(PgConstructionRs.class); + private PgConstructionTypeManager pgConstructionTypeManager; + private PgConstructionManager pgConstructionManager; private PgPartitionManager pgPartitionManager; @@ -52,6 +56,11 @@ } @Resource + public void setPgConstructionTypeManager(PgConstructionTypeManager pgConstructionTypeManager) { + this.pgConstructionTypeManager = pgConstructionTypeManager; + } + + @Resource public void setPgDeviceManager(PgDeviceManager pgDeviceManager) { this.pgDeviceManager = pgDeviceManager; } @@ -63,7 +72,7 @@ @Path("addConstruction") @Produces(MediaType.APPLICATION_JSON) public Map addConstruction(@FormParam("cs_name")String cs_name, - @FormParam("cs_status")String cs_status, + @FormParam("constructionType")String constructionType, @FormParam("cs_detail")String cs_detail, @FormParam("cs_beginTime")String cs_beginTime, @FormParam("cs_endTime")String cs_endTime, @@ -77,11 +86,12 @@ String msg = "" ; SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); try { + + PgConstructionType pgConstructionType=pgConstructionTypeManager.getConstructionTypeByType(constructionType); PgPartition pgPartition=pgPartitionManager.getPartitionByParName(parName); PgConstruction pgConstruction = new PgConstruction(); pgConstruction.setCs_name(cs_name); - pgConstruction.setCs_status(cs_status); pgConstruction.setCs_detail(cs_detail); pgConstruction.setCs_beginTime(sdf.parse(cs_beginTime)); pgConstruction.setCs_endTime(sdf.parse(cs_endTime)); @@ -89,6 +99,7 @@ pgConstruction.setCs_phone(cs_phone); pgConstruction.setCs_type(cs_type); pgConstruction.setPgPartitionId(pgPartition); + pgConstruction.setPgConstructionTypeId(pgConstructionType); pgConstruction.setActive(1); logger.info("保存成功"); @@ -114,7 +125,7 @@ @Produces(MediaType.APPLICATION_JSON) public Map editConstruction(@FormParam("id")String id, @FormParam("cs_name")String cs_name, - @FormParam("cs_status")String cs_status, + @FormParam("constructionType")String constructionType, @FormParam("cs_detail")String cs_detail, @FormParam("cs_beginTime")String cs_beginTime, @FormParam("cs_endTime")String cs_endTime, @@ -136,11 +147,12 @@ result = "false"; msg = "请输入ID"; }else { + PgConstructionType pgConstructionType=pgConstructionTypeManager.getConstructionTypeByType(constructionType); + PgPartition pgPartition=pgPartitionManager.getPartitionByParName(parName); PgConstruction pgConstruction = pgConstructionManager.get(Long.valueOf(id)); pgConstruction.setCs_name(cs_name); - pgConstruction.setCs_status(cs_status); pgConstruction.setCs_detail(cs_detail); pgConstruction.setCs_beginTime(sdf.parse(cs_beginTime)); pgConstruction.setCs_endTime(sdf.parse(cs_endTime)); @@ -148,6 +160,7 @@ pgConstruction.setCs_phone(cs_phone); pgConstruction.setCs_type(cs_type); pgConstruction.setPgPartitionId(pgPartition); + pgConstruction.setPgConstructionTypeId(pgConstructionType); pgConstruction.setActive(1); pgConstructionManager.save(pgConstruction); diff --git a/src/main/java/com/casic/PgInterface/rs/PgConstructionTypeRs.java b/src/main/java/com/casic/PgInterface/rs/PgConstructionTypeRs.java new file mode 100644 index 0000000..549b8e5 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/rs/PgConstructionTypeRs.java @@ -0,0 +1,178 @@ +package com.casic.PgInterface.rs; + +import com.casic.PgInterface.construction.domain.PgConstructionType; +import com.casic.PgInterface.construction.dto.PgConstructionTypeDto; +import com.casic.PgInterface.construction.manager.PgConstructionTypeManager; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import javax.ws.rs.FormParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Created by yxw on 2018/4/10. + */ +@Component +@Path("pgConstructionType") +public class PgConstructionTypeRs { + + private PgConstructionTypeManager pgConstructionTypeManager; + + @Resource + public void setPgConstructionTypeManager(PgConstructionTypeManager pgConstructionTypeManager) { + this.pgConstructionTypeManager = pgConstructionTypeManager; + } + + /** + * 获取项目状态 + */ + @POST + @Path("getConstructionType") + @Produces(MediaType.APPLICATION_JSON) + public Map getConstructionType() throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + List pgConstructionTypeDtoList = new ArrayList(); + try { + pgConstructionTypeDtoList = pgConstructionTypeManager.getAllConstructionTypeDto(); + if (pgConstructionTypeDtoList.size() == 0) + msg = "没有项目类型信息"; + else + msg = "项目类型获取成功"; + } catch (Exception e) { + e.printStackTrace(); + msg = "项目类型信息获取失败"; + } + resultMap.put("msg", msg); + resultMap.put("result", pgConstructionTypeDtoList); + return resultMap; + } + + /** + * 新增项目状态 + */ + @POST + @Path("addConstructionType") + @Produces(MediaType.APPLICATION_JSON) + public Map addConstructionType(@FormParam("typeName") String typeName) throws Exception { + Map resultMap = new HashMap(); + String result = ""; + String msg = ""; + + try { + if (pgConstructionTypeManager.getConstructionTypeByType(typeName) != null) { + result = "false"; + msg = "已存项目状态"; + } else { + PgConstructionType pgConstructionType = new PgConstructionType(); + pgConstructionType.setTypeName(typeName); + pgConstructionType.setActive(1); + + pgConstructionTypeManager.save(pgConstructionType); + result = "true"; + msg = "保存成功"; + } + } catch (Exception e) { + result = "false"; + msg = "保存失败"; + e.printStackTrace(); + } + + resultMap.put("result", result); + resultMap.put("msg", msg); + return resultMap; + } + + /** + * 编辑项目状态 + */ + @POST + @Path("editConstruction") + @Produces(MediaType.APPLICATION_JSON) + public Map editConstruction(@FormParam("id") String id, + @FormParam("typeName") String typeName)throws Exception{ + Map resultMap = new HashMap(); + String result = ""; + String msg = ""; + + try{ + if(pgConstructionTypeManager.getConstructionTypeByType(typeName)!=null) + { + result = "false"; + msg = "已存项目状态"; + } + else { + PgConstructionType pgConstructionType = pgConstructionTypeManager.get(Long.valueOf(id)); + if(pgConstructionType==null) + { + result = "false"; + msg = "不存在项目状态"; + } + else { + pgConstructionType.setTypeName(typeName); + + pgConstructionTypeManager.save(pgConstructionType); + result = "true"; + msg = "编辑成功"; + } + } + } + catch(Exception e) + { + result = "false"; + msg = "编辑失败"; + e.printStackTrace(); + } + + resultMap.put("result",result); + resultMap.put("msg",msg); + + return resultMap; + } + + + /** + * 删除项目状态 + */ + @POST + @Path("deleteConstructionType") + @Produces(MediaType.APPLICATION_JSON) + public Map deleteConstructionType(@FormParam("id") String id)throws Exception { + + Map resultMap = new HashMap(); + String msg=""; + String result="false"; + + try { + PgConstructionType pgConstructionType=pgConstructionTypeManager.get(Long.valueOf(id)); + if(pgConstructionType==null) { + msg = "不存项目状态"; + result="false"; + } + else + { + pgConstructionType.setActive(0); + pgConstructionTypeManager.save(pgConstructionType); + msg="项目状态删除成功"; + result="true"; + } + }catch(Exception e){ + e.printStackTrace(); + msg="项目状态删除失败"; + result="false"; + } + resultMap.put("msg",msg); + resultMap.put("result",result); + + return resultMap; + } + + +} diff --git a/src/main/java/com/casic/PgInterface/rs/PgOverViewRs.java b/src/main/java/com/casic/PgInterface/rs/PgOverViewRs.java index 8bca0fb..4f83629 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgOverViewRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgOverViewRs.java @@ -272,4 +272,5 @@ } + } \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/rs/PgReserveController.java b/src/main/java/com/casic/PgInterface/rs/PgReserveController.java deleted file mode 100644 index 27b1482..0000000 --- a/src/main/java/com/casic/PgInterface/rs/PgReserveController.java +++ /dev/null @@ -1,208 +0,0 @@ -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.Component; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; - -import javax.annotation.Resource; -import javax.ws.rs.FormParam; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import java.util.HashMap; -import java.util.Map; - -/** - * Created by yxw on 2017/11/8. - */ -//@Controller -//@RequestMapping("pgReservePlan") -@Component -@Path("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("planName") String planName, - @FormParam("planType") String planType, - @FormParam("resUnit") String resUnit, - @FormParam("alarmType") String alarmType, - @FormParam("planFile") String fileBuffer, - @FormParam("fileName") 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("result", 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/.idea/workspace.xml b/.idea/workspace.xml index 2ee3724..276272c 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,6 +2,20 @@ + + + + + + + + + + + + + + @@ -44,13 +58,6 @@ @@ -249,6 +263,36 @@ - @@ -911,13 +1031,14 @@ + - + @@ -926,7 +1047,6 @@ - @@ -1011,7 +1131,7 @@ - @@ -1019,62 +1139,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1173,13 +1237,6 @@ - - - - - - - @@ -1201,20 +1258,6 @@ - - - - - - - - - - - - - - @@ -1229,13 +1272,6 @@ - - - - - - - @@ -1278,45 +1314,11 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -1335,13 +1337,6 @@ - - - - - - - @@ -1349,13 +1344,6 @@ - - - - - - - @@ -1382,6 +1370,217 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java b/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java index fad34cb..a928236 100644 --- a/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java +++ b/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java @@ -20,7 +20,6 @@ private static final long serialVersionUID = 1L; private long id; private String cs_name;//项目名称 - private String cs_status;//项目状态 private String cs_detail;//施工内容 private Date cs_beginTime;//施工开始时间 private Date cs_endTime;//施工结束时间 @@ -28,6 +27,7 @@ private String cs_phone;//联系方式 private String cs_type;//工程类别 private PgPartition pgPartitionId;//施工区域 + private PgConstructionType pgConstructionTypeId;//项目状态 private List pgCsDocumentList;//施工文档 private int active;//状态位 @@ -42,11 +42,6 @@ public void setCs_name(String cs_name){ this.cs_name = cs_name; } - @Column(name = "CS_STATUS") - public String getCs_status(){ return cs_status; } - - public void setCs_status(String cs_status){ this.cs_status = cs_status; } - @Column(name = "CS_DETAIL") public String getCs_detail(){ return cs_detail; } @@ -97,6 +92,16 @@ this.pgCsDocumentList = pgCsDocumentList; } + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "PGCONSTRUCTIONTYPE_ID") + public PgConstructionType getPgConstructionTypeId() { + return pgConstructionTypeId; + } + + public void setPgConstructionTypeId(PgConstructionType pgConstructionTypeId) { + this.pgConstructionTypeId = pgConstructionTypeId; + } @Column(name = "ACTIVE") public int getActive(){ return active; } diff --git a/src/main/java/com/casic/PgInterface/construction/domain/PgConstructionType.java b/src/main/java/com/casic/PgInterface/construction/domain/PgConstructionType.java new file mode 100644 index 0000000..6909234 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/construction/domain/PgConstructionType.java @@ -0,0 +1,57 @@ +package com.casic.PgInterface.construction.domain; + +import javax.persistence.*; +import java.io.Serializable; +import java.util.List; + +/** + * Created by yxw on 2018/4/10. + */ +@Entity +@Table(name = "PG_CONSTRUCTION_TYPE") +@SequenceGenerator(name = "SEQ_PG_CONSTRUCTION_TYPE_ID", sequenceName = "SEQ_PG_CONSTRUCTION_TYPE_ID", allocationSize = 1,initialValue = 1) +public class PgConstructionType implements Serializable { + + private static final long serialVersionUID = 1L; + private long id; + private String typeName;//项目状态 + private List pgConstructionList;//项目 + private int active;//状态位 + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_CONSTRUCTION_TYPE_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "TYPENAME") + public String getTypeName() { + return typeName; + } + + public void setTypeName(String typeName) { + this.typeName = typeName; + } + + @Column(name = "ACTIVE") + public int getActive() { + return active; + } + + public void setActive(int active) { + this.active = active; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgConstructionTypeId") + public List getPgConstructionList() { + return pgConstructionList; + } + + public void setPgConstructionList(List pgConstructionList) { + this.pgConstructionList = pgConstructionList; + } +} diff --git a/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionDto.java b/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionDto.java index c5ac9f9..4fa1888 100644 --- a/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionDto.java +++ b/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionDto.java @@ -11,7 +11,6 @@ private String id; private String cs_name;//项目名称 - private String cs_status;//项目状态 private String cs_detail;//施工内容 private String cs_beginTime;//施工开始时间 private String cs_endTime;//施工结束时间 @@ -19,6 +18,7 @@ private String cs_phone;//联系方式 private String cs_type;//工程类别 private String parName;//施工区域 + private String ConstructionType;//项目状态 private String active;//状态位 public String getId() { @@ -37,14 +37,6 @@ this.cs_name = cs_name; } - public String getCs_status() { - return cs_status; - } - - public void setCs_status(String cs_status) { - this.cs_status = cs_status; - } - public String getCs_detail() { return cs_detail; } @@ -105,13 +97,20 @@ public void setActive(String active){ this.active = active; } + public String getConstructionType() { + return ConstructionType; + } + + public void setConstructionType(String constructionType) { + ConstructionType = constructionType; + } + public PgConstructionDto(PgConstruction pgConstruction) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); this.setId(String.valueOf(pgConstruction.getId())); this.setCs_name(pgConstruction.getCs_name()); - this.setCs_status(pgConstruction.getCs_status()); this.setCs_detail(pgConstruction.getCs_detail()); this.setCs_beginTime(sdf.format(pgConstruction.getCs_beginTime())); this.setCs_endTime(sdf.format(pgConstruction.getCs_endTime())); @@ -119,6 +118,7 @@ this.setCs_phone(pgConstruction.getCs_phone()); this.setCs_type(pgConstruction.getCs_type()); this.setParName(pgConstruction.getPgPartitionId().getParName()); + this.setConstructionType(pgConstruction.getPgConstructionTypeId().getTypeName()); this.setActive(String.valueOf(pgConstruction.getActive())); } } diff --git a/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionTypeDto.java b/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionTypeDto.java new file mode 100644 index 0000000..109c774 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionTypeDto.java @@ -0,0 +1,46 @@ +package com.casic.PgInterface.construction.dto; + +import com.casic.PgInterface.construction.domain.PgConstructionType; + +import java.io.Serializable; + +/** + * Created by yxw on 2018/4/10. + */ +public class PgConstructionTypeDto implements Serializable { + + private String id; + private String typeName;//项目状态 + private String active;//状态位 + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTypeName() { + return typeName; + } + + public void setTypeName(String typeName) { + this.typeName = typeName; + } + + public String getActive() { + return active; + } + + public void setActive(String active) { + this.active = active; + } + + public PgConstructionTypeDto(PgConstructionType pgConstructionType) + { + this.setId(String.valueOf(pgConstructionType.getId())); + this.setTypeName(pgConstructionType.getTypeName()); + this.setActive(String.valueOf(pgConstructionType.getActive())); + } +} diff --git a/src/main/java/com/casic/PgInterface/construction/manager/PgConstructionTypeManager.java b/src/main/java/com/casic/PgInterface/construction/manager/PgConstructionTypeManager.java new file mode 100644 index 0000000..f81a33d --- /dev/null +++ b/src/main/java/com/casic/PgInterface/construction/manager/PgConstructionTypeManager.java @@ -0,0 +1,49 @@ +package com.casic.PgInterface.construction.manager; + +import com.casic.PgInterface.construction.domain.PgConstructionType; +import com.casic.PgInterface.construction.dto.PgConstructionTypeDto; +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import org.hibernate.Criteria; +import org.hibernate.criterion.Order; +import org.hibernate.criterion.Restrictions; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by yxw on 2018/4/10. + */ +@Service +public class PgConstructionTypeManager extends HibernateEntityDao { + + public PgConstructionType getConstructionTypeByType(String typeName) + { + Criteria criteria=createCriteria(PgConstructionType.class); + criteria.add(Restrictions.eq("typeName",typeName)); + criteria.add(Restrictions.eq("active",1)); + + List pgConstructionTypeList=criteria.list(); + if(pgConstructionTypeList!=null&&pgConstructionTypeList.size()!=0) + return pgConstructionTypeList.get(0); + else + return null; + } + + public List getAllConstructionTypeDto() + { + Criteria criteria=createCriteria(PgConstructionType.class); + criteria.add(Restrictions.eq("active",1)); + criteria.addOrder(Order.desc("id")); + + List pgConstructionTypeList=criteria.list(); + List pgConstructionTypeDtoList=new ArrayList(); + for(PgConstructionType pgConstructionType : pgConstructionTypeList) + { + pgConstructionTypeDtoList.add(new PgConstructionTypeDto(pgConstructionType)); + } + + return pgConstructionTypeDtoList; + } + +} diff --git a/src/main/java/com/casic/PgInterface/reservePlan/manager/PgReservePlanManager.java b/src/main/java/com/casic/PgInterface/reservePlan/manager/PgReservePlanManager.java index bbb735b..365737e 100644 --- a/src/main/java/com/casic/PgInterface/reservePlan/manager/PgReservePlanManager.java +++ b/src/main/java/com/casic/PgInterface/reservePlan/manager/PgReservePlanManager.java @@ -4,14 +4,12 @@ import com.casic.PgInterface.devTable.domain.PgAlarm; import com.casic.PgInterface.reservePlan.domain.PgReservePlan; import com.casic.PgInterface.reservePlan.dto.PgReservePlanDto; -import com.sun.org.apache.xml.internal.security.utils.Base64; import org.hibernate.Criteria; import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; -import org.springframework.web.multipart.MultipartFile; import sun.misc.BASE64Decoder; import javax.servlet.http.HttpServletRequest; @@ -26,45 +24,7 @@ @Service public class PgReservePlanManager extends HibernateEntityDao { - public String saveFiles(List files,String fileType){ - String [] fileNames = new String[files.size()]; - String [] fileBuffers = new String[files.size()]; - try { - for (int i = 0; i < files.size(); i++) { - fileNames[i] = files.get(i).getOriginalFilename(); - byte[] fis = files.get(i).getBytes(); - fileBuffers[i] = new String(Base64.encode(fis, Base64.BASE64DEFAULTLENGTH)); - } - HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); - String strDirPath = request.getSession().getServletContext().getRealPath(""); - - FileOutputStream fos = null; - String image_toDir = strDirPath + "\\"+fileType;//存储路径 - String imageName = ""; - for (int i = 0; i < fileBuffers.length; i++) { - if (fileBuffers[i] != null && fileNames[i] != null) { - imageName += fileType+"/"+fileNames[i] + ","; - byte[] buffer = new BASE64Decoder().decodeBuffer(fileBuffers[i]);//对android传过来的图片字符串进行解码 - File destDir = new File(image_toDir); - if (!destDir.exists()) - destDir.mkdirs(); - File imageFile = new File(destDir, fileNames[i]); - fos = new FileOutputStream(imageFile);//保存图片 - fos.write(buffer); - fos.flush(); - fos.close(); - } - } - return imageName.substring(0,imageName.length()-1); - } - catch(Exception ex) - { - ex.printStackTrace(); - return ""; - } - } - - public String saveFiles(String fileBuffer,String fileName,String fileType){ + public String saveFiles(String fileBuffer, String fileName, String fileType){ try { HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); @@ -92,6 +52,8 @@ } } + + public List getReservePlanDtoByAlarmType(PgAlarm pgAlarm) { try { diff --git a/src/main/java/com/casic/PgInterface/rs/PgConstructionRs.java b/src/main/java/com/casic/PgInterface/rs/PgConstructionRs.java index 6ec29e1..932f2e2 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgConstructionRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgConstructionRs.java @@ -1,9 +1,11 @@ package com.casic.PgInterface.rs; import com.casic.PgInterface.construction.domain.PgConstruction; +import com.casic.PgInterface.construction.domain.PgConstructionType; import com.casic.PgInterface.construction.dto.PgConstructTjDto; import com.casic.PgInterface.construction.dto.PgConstructionDto; import com.casic.PgInterface.construction.manager.PgConstructionManager; +import com.casic.PgInterface.construction.manager.PgConstructionTypeManager; import com.casic.PgInterface.devTable.domain.PgPartition; import com.casic.PgInterface.devTable.dto.PgDeviceDto; import com.casic.PgInterface.devTable.manager.PgDeviceManager; @@ -34,6 +36,8 @@ private static Logger logger = LoggerFactory.getLogger(PgConstructionRs.class); + private PgConstructionTypeManager pgConstructionTypeManager; + private PgConstructionManager pgConstructionManager; private PgPartitionManager pgPartitionManager; @@ -52,6 +56,11 @@ } @Resource + public void setPgConstructionTypeManager(PgConstructionTypeManager pgConstructionTypeManager) { + this.pgConstructionTypeManager = pgConstructionTypeManager; + } + + @Resource public void setPgDeviceManager(PgDeviceManager pgDeviceManager) { this.pgDeviceManager = pgDeviceManager; } @@ -63,7 +72,7 @@ @Path("addConstruction") @Produces(MediaType.APPLICATION_JSON) public Map addConstruction(@FormParam("cs_name")String cs_name, - @FormParam("cs_status")String cs_status, + @FormParam("constructionType")String constructionType, @FormParam("cs_detail")String cs_detail, @FormParam("cs_beginTime")String cs_beginTime, @FormParam("cs_endTime")String cs_endTime, @@ -77,11 +86,12 @@ String msg = "" ; SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); try { + + PgConstructionType pgConstructionType=pgConstructionTypeManager.getConstructionTypeByType(constructionType); PgPartition pgPartition=pgPartitionManager.getPartitionByParName(parName); PgConstruction pgConstruction = new PgConstruction(); pgConstruction.setCs_name(cs_name); - pgConstruction.setCs_status(cs_status); pgConstruction.setCs_detail(cs_detail); pgConstruction.setCs_beginTime(sdf.parse(cs_beginTime)); pgConstruction.setCs_endTime(sdf.parse(cs_endTime)); @@ -89,6 +99,7 @@ pgConstruction.setCs_phone(cs_phone); pgConstruction.setCs_type(cs_type); pgConstruction.setPgPartitionId(pgPartition); + pgConstruction.setPgConstructionTypeId(pgConstructionType); pgConstruction.setActive(1); logger.info("保存成功"); @@ -114,7 +125,7 @@ @Produces(MediaType.APPLICATION_JSON) public Map editConstruction(@FormParam("id")String id, @FormParam("cs_name")String cs_name, - @FormParam("cs_status")String cs_status, + @FormParam("constructionType")String constructionType, @FormParam("cs_detail")String cs_detail, @FormParam("cs_beginTime")String cs_beginTime, @FormParam("cs_endTime")String cs_endTime, @@ -136,11 +147,12 @@ result = "false"; msg = "请输入ID"; }else { + PgConstructionType pgConstructionType=pgConstructionTypeManager.getConstructionTypeByType(constructionType); + PgPartition pgPartition=pgPartitionManager.getPartitionByParName(parName); PgConstruction pgConstruction = pgConstructionManager.get(Long.valueOf(id)); pgConstruction.setCs_name(cs_name); - pgConstruction.setCs_status(cs_status); pgConstruction.setCs_detail(cs_detail); pgConstruction.setCs_beginTime(sdf.parse(cs_beginTime)); pgConstruction.setCs_endTime(sdf.parse(cs_endTime)); @@ -148,6 +160,7 @@ pgConstruction.setCs_phone(cs_phone); pgConstruction.setCs_type(cs_type); pgConstruction.setPgPartitionId(pgPartition); + pgConstruction.setPgConstructionTypeId(pgConstructionType); pgConstruction.setActive(1); pgConstructionManager.save(pgConstruction); diff --git a/src/main/java/com/casic/PgInterface/rs/PgConstructionTypeRs.java b/src/main/java/com/casic/PgInterface/rs/PgConstructionTypeRs.java new file mode 100644 index 0000000..549b8e5 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/rs/PgConstructionTypeRs.java @@ -0,0 +1,178 @@ +package com.casic.PgInterface.rs; + +import com.casic.PgInterface.construction.domain.PgConstructionType; +import com.casic.PgInterface.construction.dto.PgConstructionTypeDto; +import com.casic.PgInterface.construction.manager.PgConstructionTypeManager; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import javax.ws.rs.FormParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Created by yxw on 2018/4/10. + */ +@Component +@Path("pgConstructionType") +public class PgConstructionTypeRs { + + private PgConstructionTypeManager pgConstructionTypeManager; + + @Resource + public void setPgConstructionTypeManager(PgConstructionTypeManager pgConstructionTypeManager) { + this.pgConstructionTypeManager = pgConstructionTypeManager; + } + + /** + * 获取项目状态 + */ + @POST + @Path("getConstructionType") + @Produces(MediaType.APPLICATION_JSON) + public Map getConstructionType() throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + List pgConstructionTypeDtoList = new ArrayList(); + try { + pgConstructionTypeDtoList = pgConstructionTypeManager.getAllConstructionTypeDto(); + if (pgConstructionTypeDtoList.size() == 0) + msg = "没有项目类型信息"; + else + msg = "项目类型获取成功"; + } catch (Exception e) { + e.printStackTrace(); + msg = "项目类型信息获取失败"; + } + resultMap.put("msg", msg); + resultMap.put("result", pgConstructionTypeDtoList); + return resultMap; + } + + /** + * 新增项目状态 + */ + @POST + @Path("addConstructionType") + @Produces(MediaType.APPLICATION_JSON) + public Map addConstructionType(@FormParam("typeName") String typeName) throws Exception { + Map resultMap = new HashMap(); + String result = ""; + String msg = ""; + + try { + if (pgConstructionTypeManager.getConstructionTypeByType(typeName) != null) { + result = "false"; + msg = "已存项目状态"; + } else { + PgConstructionType pgConstructionType = new PgConstructionType(); + pgConstructionType.setTypeName(typeName); + pgConstructionType.setActive(1); + + pgConstructionTypeManager.save(pgConstructionType); + result = "true"; + msg = "保存成功"; + } + } catch (Exception e) { + result = "false"; + msg = "保存失败"; + e.printStackTrace(); + } + + resultMap.put("result", result); + resultMap.put("msg", msg); + return resultMap; + } + + /** + * 编辑项目状态 + */ + @POST + @Path("editConstruction") + @Produces(MediaType.APPLICATION_JSON) + public Map editConstruction(@FormParam("id") String id, + @FormParam("typeName") String typeName)throws Exception{ + Map resultMap = new HashMap(); + String result = ""; + String msg = ""; + + try{ + if(pgConstructionTypeManager.getConstructionTypeByType(typeName)!=null) + { + result = "false"; + msg = "已存项目状态"; + } + else { + PgConstructionType pgConstructionType = pgConstructionTypeManager.get(Long.valueOf(id)); + if(pgConstructionType==null) + { + result = "false"; + msg = "不存在项目状态"; + } + else { + pgConstructionType.setTypeName(typeName); + + pgConstructionTypeManager.save(pgConstructionType); + result = "true"; + msg = "编辑成功"; + } + } + } + catch(Exception e) + { + result = "false"; + msg = "编辑失败"; + e.printStackTrace(); + } + + resultMap.put("result",result); + resultMap.put("msg",msg); + + return resultMap; + } + + + /** + * 删除项目状态 + */ + @POST + @Path("deleteConstructionType") + @Produces(MediaType.APPLICATION_JSON) + public Map deleteConstructionType(@FormParam("id") String id)throws Exception { + + Map resultMap = new HashMap(); + String msg=""; + String result="false"; + + try { + PgConstructionType pgConstructionType=pgConstructionTypeManager.get(Long.valueOf(id)); + if(pgConstructionType==null) { + msg = "不存项目状态"; + result="false"; + } + else + { + pgConstructionType.setActive(0); + pgConstructionTypeManager.save(pgConstructionType); + msg="项目状态删除成功"; + result="true"; + } + }catch(Exception e){ + e.printStackTrace(); + msg="项目状态删除失败"; + result="false"; + } + resultMap.put("msg",msg); + resultMap.put("result",result); + + return resultMap; + } + + +} diff --git a/src/main/java/com/casic/PgInterface/rs/PgOverViewRs.java b/src/main/java/com/casic/PgInterface/rs/PgOverViewRs.java index 8bca0fb..4f83629 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgOverViewRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgOverViewRs.java @@ -272,4 +272,5 @@ } + } \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/rs/PgReserveController.java b/src/main/java/com/casic/PgInterface/rs/PgReserveController.java deleted file mode 100644 index 27b1482..0000000 --- a/src/main/java/com/casic/PgInterface/rs/PgReserveController.java +++ /dev/null @@ -1,208 +0,0 @@ -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.Component; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; - -import javax.annotation.Resource; -import javax.ws.rs.FormParam; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import java.util.HashMap; -import java.util.Map; - -/** - * Created by yxw on 2017/11/8. - */ -//@Controller -//@RequestMapping("pgReservePlan") -@Component -@Path("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("planName") String planName, - @FormParam("planType") String planType, - @FormParam("resUnit") String resUnit, - @FormParam("alarmType") String alarmType, - @FormParam("planFile") String fileBuffer, - @FormParam("fileName") 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("result", 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/PgReservePlanRs.java b/src/main/java/com/casic/PgInterface/rs/PgReservePlanRs.java new file mode 100644 index 0000000..33da431 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/rs/PgReservePlanRs.java @@ -0,0 +1,172 @@ +package com.casic.PgInterface.rs; + +import com.casic.PgInterface.core.util.StringUtils; +import com.casic.PgInterface.devTable.domain.PgAlarmType; +import com.casic.PgInterface.devTable.manager.PgAlarmTypeManager; +import com.casic.PgInterface.reservePlan.domain.PgReservePlan; +import com.casic.PgInterface.reservePlan.manager.PgReservePlanManager; +import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +import javax.annotation.Resource; +import javax.ws.rs.FormParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import java.util.HashMap; +import java.util.Map; + +/** + * Created by yxw on 2018/4/10. + */ +@Component +@Path("PgReservePlan") +public class PgReservePlanRs { + + private PgReservePlanManager pgReservePlanManager; + + private PgAlarmTypeManager pgAlarmTypeManager; + + @Resource + public void setPgReservePlanManager(PgReservePlanManager pgReservePlanManager) { + this.pgReservePlanManager = pgReservePlanManager; + } + + @Resource + public void setPgAlarmTypeManager(PgAlarmTypeManager pgAlarmTypeManager) { + this.pgAlarmTypeManager = pgAlarmTypeManager; + } + + /* + 新增&上传 + */ + @POST + @Path("addReservePlan") + @Produces(MediaType.APPLICATION_JSON) + public Map addReservePlan(@FormParam("planName") String planName, + @FormParam("planType") String planType, + @FormParam("resUnit") String resUnit, + @FormParam("planFiel") String planFiel, + @FormParam("alarmType") String alarmType)throws Exception { + + Map resultMap=new HashMap(); + String msg=""; + String result=""; + + try { + + PgReservePlan pgReservePlan = new PgReservePlan(); + + pgReservePlan.setPlanName(planName); + pgReservePlan.setPlanType(planType); + pgReservePlan.setResUnit(resUnit); + pgReservePlan.setActive(1); + PgAlarmType pgAlarmType = pgAlarmTypeManager.getAlarmTypeByAlarmType(alarmType); + pgReservePlan.setPgAlarmTypeId(pgAlarmType); + if (StringUtils.isBlank(planFiel)||StringUtils.isBlank(planName)) + pgReservePlan.setPlanFiel(""); + else { + pgReservePlan.setPlanFiel(pgReservePlanManager.saveFiles(planFiel, planName, "ReservePlan")); + } + + pgReservePlanManager.save(pgReservePlan); + msg="新增成功"; + result="true"; + + } + catch(Exception e) + { + e.printStackTrace(); + msg="新增失败"; + result="false"; + } + + resultMap.put("msg",msg); + resultMap.put("result",result); + + return resultMap; + } + + + //编辑文档 + @RequestMapping("editReservePlan") + @ResponseBody + public Map editReservePlan(@FormParam("id") String id, + @FormParam("planName") String planName, + @FormParam("planType") String planType, + @FormParam("resUnit") String resUnit, + @FormParam("alarmType") 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 { + PgAlarmType pgAlarmType = pgAlarmTypeManager.getAlarmTypeByAlarmType(alarmType); + pgReservePlan.setPlanName(planName); + pgReservePlan.setPlanType(planType); + pgReservePlan.setResUnit(resUnit); + pgReservePlan.setPgAlarmTypeId(pgAlarmType); + + pgReservePlanManager.save(pgReservePlan); + + result = "true"; + msg = "编辑成功"; + } + } catch (Exception e) { + + result = "false"; + msg = "编辑失败"; + e.printStackTrace(); + } + resultMap.put("msg",msg); + resultMap.put("result",result); + + return resultMap; + } + + //删除预案文档 + @RequestMapping("delReservePlan") + @ResponseBody + public Map delReservePlan(@FormParam("id") String id)throws Exception{ + Map resultMap = new HashMap(); + String msg=""; + String result=""; + + 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; + } + + + +} diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 2ee3724..276272c 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,6 +2,20 @@ + + + + + + + + + + + + + + @@ -44,13 +58,6 @@ @@ -249,6 +263,36 @@ - @@ -911,13 +1031,14 @@ + - + @@ -926,7 +1047,6 @@ - @@ -1011,7 +1131,7 @@ - @@ -1019,62 +1139,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1173,13 +1237,6 @@ - - - - - - - @@ -1201,20 +1258,6 @@ - - - - - - - - - - - - - - @@ -1229,13 +1272,6 @@ - - - - - - - @@ -1278,45 +1314,11 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -1335,13 +1337,6 @@ - - - - - - - @@ -1349,13 +1344,6 @@ - - - - - - - @@ -1382,6 +1370,217 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java b/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java index fad34cb..a928236 100644 --- a/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java +++ b/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java @@ -20,7 +20,6 @@ private static final long serialVersionUID = 1L; private long id; private String cs_name;//项目名称 - private String cs_status;//项目状态 private String cs_detail;//施工内容 private Date cs_beginTime;//施工开始时间 private Date cs_endTime;//施工结束时间 @@ -28,6 +27,7 @@ private String cs_phone;//联系方式 private String cs_type;//工程类别 private PgPartition pgPartitionId;//施工区域 + private PgConstructionType pgConstructionTypeId;//项目状态 private List pgCsDocumentList;//施工文档 private int active;//状态位 @@ -42,11 +42,6 @@ public void setCs_name(String cs_name){ this.cs_name = cs_name; } - @Column(name = "CS_STATUS") - public String getCs_status(){ return cs_status; } - - public void setCs_status(String cs_status){ this.cs_status = cs_status; } - @Column(name = "CS_DETAIL") public String getCs_detail(){ return cs_detail; } @@ -97,6 +92,16 @@ this.pgCsDocumentList = pgCsDocumentList; } + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "PGCONSTRUCTIONTYPE_ID") + public PgConstructionType getPgConstructionTypeId() { + return pgConstructionTypeId; + } + + public void setPgConstructionTypeId(PgConstructionType pgConstructionTypeId) { + this.pgConstructionTypeId = pgConstructionTypeId; + } @Column(name = "ACTIVE") public int getActive(){ return active; } diff --git a/src/main/java/com/casic/PgInterface/construction/domain/PgConstructionType.java b/src/main/java/com/casic/PgInterface/construction/domain/PgConstructionType.java new file mode 100644 index 0000000..6909234 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/construction/domain/PgConstructionType.java @@ -0,0 +1,57 @@ +package com.casic.PgInterface.construction.domain; + +import javax.persistence.*; +import java.io.Serializable; +import java.util.List; + +/** + * Created by yxw on 2018/4/10. + */ +@Entity +@Table(name = "PG_CONSTRUCTION_TYPE") +@SequenceGenerator(name = "SEQ_PG_CONSTRUCTION_TYPE_ID", sequenceName = "SEQ_PG_CONSTRUCTION_TYPE_ID", allocationSize = 1,initialValue = 1) +public class PgConstructionType implements Serializable { + + private static final long serialVersionUID = 1L; + private long id; + private String typeName;//项目状态 + private List pgConstructionList;//项目 + private int active;//状态位 + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_CONSTRUCTION_TYPE_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "TYPENAME") + public String getTypeName() { + return typeName; + } + + public void setTypeName(String typeName) { + this.typeName = typeName; + } + + @Column(name = "ACTIVE") + public int getActive() { + return active; + } + + public void setActive(int active) { + this.active = active; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgConstructionTypeId") + public List getPgConstructionList() { + return pgConstructionList; + } + + public void setPgConstructionList(List pgConstructionList) { + this.pgConstructionList = pgConstructionList; + } +} diff --git a/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionDto.java b/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionDto.java index c5ac9f9..4fa1888 100644 --- a/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionDto.java +++ b/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionDto.java @@ -11,7 +11,6 @@ private String id; private String cs_name;//项目名称 - private String cs_status;//项目状态 private String cs_detail;//施工内容 private String cs_beginTime;//施工开始时间 private String cs_endTime;//施工结束时间 @@ -19,6 +18,7 @@ private String cs_phone;//联系方式 private String cs_type;//工程类别 private String parName;//施工区域 + private String ConstructionType;//项目状态 private String active;//状态位 public String getId() { @@ -37,14 +37,6 @@ this.cs_name = cs_name; } - public String getCs_status() { - return cs_status; - } - - public void setCs_status(String cs_status) { - this.cs_status = cs_status; - } - public String getCs_detail() { return cs_detail; } @@ -105,13 +97,20 @@ public void setActive(String active){ this.active = active; } + public String getConstructionType() { + return ConstructionType; + } + + public void setConstructionType(String constructionType) { + ConstructionType = constructionType; + } + public PgConstructionDto(PgConstruction pgConstruction) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); this.setId(String.valueOf(pgConstruction.getId())); this.setCs_name(pgConstruction.getCs_name()); - this.setCs_status(pgConstruction.getCs_status()); this.setCs_detail(pgConstruction.getCs_detail()); this.setCs_beginTime(sdf.format(pgConstruction.getCs_beginTime())); this.setCs_endTime(sdf.format(pgConstruction.getCs_endTime())); @@ -119,6 +118,7 @@ this.setCs_phone(pgConstruction.getCs_phone()); this.setCs_type(pgConstruction.getCs_type()); this.setParName(pgConstruction.getPgPartitionId().getParName()); + this.setConstructionType(pgConstruction.getPgConstructionTypeId().getTypeName()); this.setActive(String.valueOf(pgConstruction.getActive())); } } diff --git a/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionTypeDto.java b/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionTypeDto.java new file mode 100644 index 0000000..109c774 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionTypeDto.java @@ -0,0 +1,46 @@ +package com.casic.PgInterface.construction.dto; + +import com.casic.PgInterface.construction.domain.PgConstructionType; + +import java.io.Serializable; + +/** + * Created by yxw on 2018/4/10. + */ +public class PgConstructionTypeDto implements Serializable { + + private String id; + private String typeName;//项目状态 + private String active;//状态位 + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTypeName() { + return typeName; + } + + public void setTypeName(String typeName) { + this.typeName = typeName; + } + + public String getActive() { + return active; + } + + public void setActive(String active) { + this.active = active; + } + + public PgConstructionTypeDto(PgConstructionType pgConstructionType) + { + this.setId(String.valueOf(pgConstructionType.getId())); + this.setTypeName(pgConstructionType.getTypeName()); + this.setActive(String.valueOf(pgConstructionType.getActive())); + } +} diff --git a/src/main/java/com/casic/PgInterface/construction/manager/PgConstructionTypeManager.java b/src/main/java/com/casic/PgInterface/construction/manager/PgConstructionTypeManager.java new file mode 100644 index 0000000..f81a33d --- /dev/null +++ b/src/main/java/com/casic/PgInterface/construction/manager/PgConstructionTypeManager.java @@ -0,0 +1,49 @@ +package com.casic.PgInterface.construction.manager; + +import com.casic.PgInterface.construction.domain.PgConstructionType; +import com.casic.PgInterface.construction.dto.PgConstructionTypeDto; +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import org.hibernate.Criteria; +import org.hibernate.criterion.Order; +import org.hibernate.criterion.Restrictions; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by yxw on 2018/4/10. + */ +@Service +public class PgConstructionTypeManager extends HibernateEntityDao { + + public PgConstructionType getConstructionTypeByType(String typeName) + { + Criteria criteria=createCriteria(PgConstructionType.class); + criteria.add(Restrictions.eq("typeName",typeName)); + criteria.add(Restrictions.eq("active",1)); + + List pgConstructionTypeList=criteria.list(); + if(pgConstructionTypeList!=null&&pgConstructionTypeList.size()!=0) + return pgConstructionTypeList.get(0); + else + return null; + } + + public List getAllConstructionTypeDto() + { + Criteria criteria=createCriteria(PgConstructionType.class); + criteria.add(Restrictions.eq("active",1)); + criteria.addOrder(Order.desc("id")); + + List pgConstructionTypeList=criteria.list(); + List pgConstructionTypeDtoList=new ArrayList(); + for(PgConstructionType pgConstructionType : pgConstructionTypeList) + { + pgConstructionTypeDtoList.add(new PgConstructionTypeDto(pgConstructionType)); + } + + return pgConstructionTypeDtoList; + } + +} diff --git a/src/main/java/com/casic/PgInterface/reservePlan/manager/PgReservePlanManager.java b/src/main/java/com/casic/PgInterface/reservePlan/manager/PgReservePlanManager.java index bbb735b..365737e 100644 --- a/src/main/java/com/casic/PgInterface/reservePlan/manager/PgReservePlanManager.java +++ b/src/main/java/com/casic/PgInterface/reservePlan/manager/PgReservePlanManager.java @@ -4,14 +4,12 @@ import com.casic.PgInterface.devTable.domain.PgAlarm; import com.casic.PgInterface.reservePlan.domain.PgReservePlan; import com.casic.PgInterface.reservePlan.dto.PgReservePlanDto; -import com.sun.org.apache.xml.internal.security.utils.Base64; import org.hibernate.Criteria; import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; -import org.springframework.web.multipart.MultipartFile; import sun.misc.BASE64Decoder; import javax.servlet.http.HttpServletRequest; @@ -26,45 +24,7 @@ @Service public class PgReservePlanManager extends HibernateEntityDao { - public String saveFiles(List files,String fileType){ - String [] fileNames = new String[files.size()]; - String [] fileBuffers = new String[files.size()]; - try { - for (int i = 0; i < files.size(); i++) { - fileNames[i] = files.get(i).getOriginalFilename(); - byte[] fis = files.get(i).getBytes(); - fileBuffers[i] = new String(Base64.encode(fis, Base64.BASE64DEFAULTLENGTH)); - } - HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); - String strDirPath = request.getSession().getServletContext().getRealPath(""); - - FileOutputStream fos = null; - String image_toDir = strDirPath + "\\"+fileType;//存储路径 - String imageName = ""; - for (int i = 0; i < fileBuffers.length; i++) { - if (fileBuffers[i] != null && fileNames[i] != null) { - imageName += fileType+"/"+fileNames[i] + ","; - byte[] buffer = new BASE64Decoder().decodeBuffer(fileBuffers[i]);//对android传过来的图片字符串进行解码 - File destDir = new File(image_toDir); - if (!destDir.exists()) - destDir.mkdirs(); - File imageFile = new File(destDir, fileNames[i]); - fos = new FileOutputStream(imageFile);//保存图片 - fos.write(buffer); - fos.flush(); - fos.close(); - } - } - return imageName.substring(0,imageName.length()-1); - } - catch(Exception ex) - { - ex.printStackTrace(); - return ""; - } - } - - public String saveFiles(String fileBuffer,String fileName,String fileType){ + public String saveFiles(String fileBuffer, String fileName, String fileType){ try { HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); @@ -92,6 +52,8 @@ } } + + public List getReservePlanDtoByAlarmType(PgAlarm pgAlarm) { try { diff --git a/src/main/java/com/casic/PgInterface/rs/PgConstructionRs.java b/src/main/java/com/casic/PgInterface/rs/PgConstructionRs.java index 6ec29e1..932f2e2 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgConstructionRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgConstructionRs.java @@ -1,9 +1,11 @@ package com.casic.PgInterface.rs; import com.casic.PgInterface.construction.domain.PgConstruction; +import com.casic.PgInterface.construction.domain.PgConstructionType; import com.casic.PgInterface.construction.dto.PgConstructTjDto; import com.casic.PgInterface.construction.dto.PgConstructionDto; import com.casic.PgInterface.construction.manager.PgConstructionManager; +import com.casic.PgInterface.construction.manager.PgConstructionTypeManager; import com.casic.PgInterface.devTable.domain.PgPartition; import com.casic.PgInterface.devTable.dto.PgDeviceDto; import com.casic.PgInterface.devTable.manager.PgDeviceManager; @@ -34,6 +36,8 @@ private static Logger logger = LoggerFactory.getLogger(PgConstructionRs.class); + private PgConstructionTypeManager pgConstructionTypeManager; + private PgConstructionManager pgConstructionManager; private PgPartitionManager pgPartitionManager; @@ -52,6 +56,11 @@ } @Resource + public void setPgConstructionTypeManager(PgConstructionTypeManager pgConstructionTypeManager) { + this.pgConstructionTypeManager = pgConstructionTypeManager; + } + + @Resource public void setPgDeviceManager(PgDeviceManager pgDeviceManager) { this.pgDeviceManager = pgDeviceManager; } @@ -63,7 +72,7 @@ @Path("addConstruction") @Produces(MediaType.APPLICATION_JSON) public Map addConstruction(@FormParam("cs_name")String cs_name, - @FormParam("cs_status")String cs_status, + @FormParam("constructionType")String constructionType, @FormParam("cs_detail")String cs_detail, @FormParam("cs_beginTime")String cs_beginTime, @FormParam("cs_endTime")String cs_endTime, @@ -77,11 +86,12 @@ String msg = "" ; SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); try { + + PgConstructionType pgConstructionType=pgConstructionTypeManager.getConstructionTypeByType(constructionType); PgPartition pgPartition=pgPartitionManager.getPartitionByParName(parName); PgConstruction pgConstruction = new PgConstruction(); pgConstruction.setCs_name(cs_name); - pgConstruction.setCs_status(cs_status); pgConstruction.setCs_detail(cs_detail); pgConstruction.setCs_beginTime(sdf.parse(cs_beginTime)); pgConstruction.setCs_endTime(sdf.parse(cs_endTime)); @@ -89,6 +99,7 @@ pgConstruction.setCs_phone(cs_phone); pgConstruction.setCs_type(cs_type); pgConstruction.setPgPartitionId(pgPartition); + pgConstruction.setPgConstructionTypeId(pgConstructionType); pgConstruction.setActive(1); logger.info("保存成功"); @@ -114,7 +125,7 @@ @Produces(MediaType.APPLICATION_JSON) public Map editConstruction(@FormParam("id")String id, @FormParam("cs_name")String cs_name, - @FormParam("cs_status")String cs_status, + @FormParam("constructionType")String constructionType, @FormParam("cs_detail")String cs_detail, @FormParam("cs_beginTime")String cs_beginTime, @FormParam("cs_endTime")String cs_endTime, @@ -136,11 +147,12 @@ result = "false"; msg = "请输入ID"; }else { + PgConstructionType pgConstructionType=pgConstructionTypeManager.getConstructionTypeByType(constructionType); + PgPartition pgPartition=pgPartitionManager.getPartitionByParName(parName); PgConstruction pgConstruction = pgConstructionManager.get(Long.valueOf(id)); pgConstruction.setCs_name(cs_name); - pgConstruction.setCs_status(cs_status); pgConstruction.setCs_detail(cs_detail); pgConstruction.setCs_beginTime(sdf.parse(cs_beginTime)); pgConstruction.setCs_endTime(sdf.parse(cs_endTime)); @@ -148,6 +160,7 @@ pgConstruction.setCs_phone(cs_phone); pgConstruction.setCs_type(cs_type); pgConstruction.setPgPartitionId(pgPartition); + pgConstruction.setPgConstructionTypeId(pgConstructionType); pgConstruction.setActive(1); pgConstructionManager.save(pgConstruction); diff --git a/src/main/java/com/casic/PgInterface/rs/PgConstructionTypeRs.java b/src/main/java/com/casic/PgInterface/rs/PgConstructionTypeRs.java new file mode 100644 index 0000000..549b8e5 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/rs/PgConstructionTypeRs.java @@ -0,0 +1,178 @@ +package com.casic.PgInterface.rs; + +import com.casic.PgInterface.construction.domain.PgConstructionType; +import com.casic.PgInterface.construction.dto.PgConstructionTypeDto; +import com.casic.PgInterface.construction.manager.PgConstructionTypeManager; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import javax.ws.rs.FormParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Created by yxw on 2018/4/10. + */ +@Component +@Path("pgConstructionType") +public class PgConstructionTypeRs { + + private PgConstructionTypeManager pgConstructionTypeManager; + + @Resource + public void setPgConstructionTypeManager(PgConstructionTypeManager pgConstructionTypeManager) { + this.pgConstructionTypeManager = pgConstructionTypeManager; + } + + /** + * 获取项目状态 + */ + @POST + @Path("getConstructionType") + @Produces(MediaType.APPLICATION_JSON) + public Map getConstructionType() throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + List pgConstructionTypeDtoList = new ArrayList(); + try { + pgConstructionTypeDtoList = pgConstructionTypeManager.getAllConstructionTypeDto(); + if (pgConstructionTypeDtoList.size() == 0) + msg = "没有项目类型信息"; + else + msg = "项目类型获取成功"; + } catch (Exception e) { + e.printStackTrace(); + msg = "项目类型信息获取失败"; + } + resultMap.put("msg", msg); + resultMap.put("result", pgConstructionTypeDtoList); + return resultMap; + } + + /** + * 新增项目状态 + */ + @POST + @Path("addConstructionType") + @Produces(MediaType.APPLICATION_JSON) + public Map addConstructionType(@FormParam("typeName") String typeName) throws Exception { + Map resultMap = new HashMap(); + String result = ""; + String msg = ""; + + try { + if (pgConstructionTypeManager.getConstructionTypeByType(typeName) != null) { + result = "false"; + msg = "已存项目状态"; + } else { + PgConstructionType pgConstructionType = new PgConstructionType(); + pgConstructionType.setTypeName(typeName); + pgConstructionType.setActive(1); + + pgConstructionTypeManager.save(pgConstructionType); + result = "true"; + msg = "保存成功"; + } + } catch (Exception e) { + result = "false"; + msg = "保存失败"; + e.printStackTrace(); + } + + resultMap.put("result", result); + resultMap.put("msg", msg); + return resultMap; + } + + /** + * 编辑项目状态 + */ + @POST + @Path("editConstruction") + @Produces(MediaType.APPLICATION_JSON) + public Map editConstruction(@FormParam("id") String id, + @FormParam("typeName") String typeName)throws Exception{ + Map resultMap = new HashMap(); + String result = ""; + String msg = ""; + + try{ + if(pgConstructionTypeManager.getConstructionTypeByType(typeName)!=null) + { + result = "false"; + msg = "已存项目状态"; + } + else { + PgConstructionType pgConstructionType = pgConstructionTypeManager.get(Long.valueOf(id)); + if(pgConstructionType==null) + { + result = "false"; + msg = "不存在项目状态"; + } + else { + pgConstructionType.setTypeName(typeName); + + pgConstructionTypeManager.save(pgConstructionType); + result = "true"; + msg = "编辑成功"; + } + } + } + catch(Exception e) + { + result = "false"; + msg = "编辑失败"; + e.printStackTrace(); + } + + resultMap.put("result",result); + resultMap.put("msg",msg); + + return resultMap; + } + + + /** + * 删除项目状态 + */ + @POST + @Path("deleteConstructionType") + @Produces(MediaType.APPLICATION_JSON) + public Map deleteConstructionType(@FormParam("id") String id)throws Exception { + + Map resultMap = new HashMap(); + String msg=""; + String result="false"; + + try { + PgConstructionType pgConstructionType=pgConstructionTypeManager.get(Long.valueOf(id)); + if(pgConstructionType==null) { + msg = "不存项目状态"; + result="false"; + } + else + { + pgConstructionType.setActive(0); + pgConstructionTypeManager.save(pgConstructionType); + msg="项目状态删除成功"; + result="true"; + } + }catch(Exception e){ + e.printStackTrace(); + msg="项目状态删除失败"; + result="false"; + } + resultMap.put("msg",msg); + resultMap.put("result",result); + + return resultMap; + } + + +} diff --git a/src/main/java/com/casic/PgInterface/rs/PgOverViewRs.java b/src/main/java/com/casic/PgInterface/rs/PgOverViewRs.java index 8bca0fb..4f83629 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgOverViewRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgOverViewRs.java @@ -272,4 +272,5 @@ } + } \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/rs/PgReserveController.java b/src/main/java/com/casic/PgInterface/rs/PgReserveController.java deleted file mode 100644 index 27b1482..0000000 --- a/src/main/java/com/casic/PgInterface/rs/PgReserveController.java +++ /dev/null @@ -1,208 +0,0 @@ -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.Component; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; - -import javax.annotation.Resource; -import javax.ws.rs.FormParam; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import java.util.HashMap; -import java.util.Map; - -/** - * Created by yxw on 2017/11/8. - */ -//@Controller -//@RequestMapping("pgReservePlan") -@Component -@Path("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("planName") String planName, - @FormParam("planType") String planType, - @FormParam("resUnit") String resUnit, - @FormParam("alarmType") String alarmType, - @FormParam("planFile") String fileBuffer, - @FormParam("fileName") 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("result", 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/PgReservePlanRs.java b/src/main/java/com/casic/PgInterface/rs/PgReservePlanRs.java new file mode 100644 index 0000000..33da431 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/rs/PgReservePlanRs.java @@ -0,0 +1,172 @@ +package com.casic.PgInterface.rs; + +import com.casic.PgInterface.core.util.StringUtils; +import com.casic.PgInterface.devTable.domain.PgAlarmType; +import com.casic.PgInterface.devTable.manager.PgAlarmTypeManager; +import com.casic.PgInterface.reservePlan.domain.PgReservePlan; +import com.casic.PgInterface.reservePlan.manager.PgReservePlanManager; +import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +import javax.annotation.Resource; +import javax.ws.rs.FormParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import java.util.HashMap; +import java.util.Map; + +/** + * Created by yxw on 2018/4/10. + */ +@Component +@Path("PgReservePlan") +public class PgReservePlanRs { + + private PgReservePlanManager pgReservePlanManager; + + private PgAlarmTypeManager pgAlarmTypeManager; + + @Resource + public void setPgReservePlanManager(PgReservePlanManager pgReservePlanManager) { + this.pgReservePlanManager = pgReservePlanManager; + } + + @Resource + public void setPgAlarmTypeManager(PgAlarmTypeManager pgAlarmTypeManager) { + this.pgAlarmTypeManager = pgAlarmTypeManager; + } + + /* + 新增&上传 + */ + @POST + @Path("addReservePlan") + @Produces(MediaType.APPLICATION_JSON) + public Map addReservePlan(@FormParam("planName") String planName, + @FormParam("planType") String planType, + @FormParam("resUnit") String resUnit, + @FormParam("planFiel") String planFiel, + @FormParam("alarmType") String alarmType)throws Exception { + + Map resultMap=new HashMap(); + String msg=""; + String result=""; + + try { + + PgReservePlan pgReservePlan = new PgReservePlan(); + + pgReservePlan.setPlanName(planName); + pgReservePlan.setPlanType(planType); + pgReservePlan.setResUnit(resUnit); + pgReservePlan.setActive(1); + PgAlarmType pgAlarmType = pgAlarmTypeManager.getAlarmTypeByAlarmType(alarmType); + pgReservePlan.setPgAlarmTypeId(pgAlarmType); + if (StringUtils.isBlank(planFiel)||StringUtils.isBlank(planName)) + pgReservePlan.setPlanFiel(""); + else { + pgReservePlan.setPlanFiel(pgReservePlanManager.saveFiles(planFiel, planName, "ReservePlan")); + } + + pgReservePlanManager.save(pgReservePlan); + msg="新增成功"; + result="true"; + + } + catch(Exception e) + { + e.printStackTrace(); + msg="新增失败"; + result="false"; + } + + resultMap.put("msg",msg); + resultMap.put("result",result); + + return resultMap; + } + + + //编辑文档 + @RequestMapping("editReservePlan") + @ResponseBody + public Map editReservePlan(@FormParam("id") String id, + @FormParam("planName") String planName, + @FormParam("planType") String planType, + @FormParam("resUnit") String resUnit, + @FormParam("alarmType") 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 { + PgAlarmType pgAlarmType = pgAlarmTypeManager.getAlarmTypeByAlarmType(alarmType); + pgReservePlan.setPlanName(planName); + pgReservePlan.setPlanType(planType); + pgReservePlan.setResUnit(resUnit); + pgReservePlan.setPgAlarmTypeId(pgAlarmType); + + pgReservePlanManager.save(pgReservePlan); + + result = "true"; + msg = "编辑成功"; + } + } catch (Exception e) { + + result = "false"; + msg = "编辑失败"; + e.printStackTrace(); + } + resultMap.put("msg",msg); + resultMap.put("result",result); + + return resultMap; + } + + //删除预案文档 + @RequestMapping("delReservePlan") + @ResponseBody + public Map delReservePlan(@FormParam("id") String id)throws Exception{ + Map resultMap = new HashMap(); + String msg=""; + String result=""; + + 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; + } + + + +} diff --git a/~WRL1002.tmp b/~WRL1002.tmp new file mode 100644 index 0000000..e0b14d9 --- /dev/null +++ b/~WRL1002.tmp Binary files differ diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 2ee3724..276272c 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,6 +2,20 @@ + + + + + + + + + + + + + + @@ -44,13 +58,6 @@ @@ -249,6 +263,36 @@ - @@ -911,13 +1031,14 @@ + - + @@ -926,7 +1047,6 @@ - @@ -1011,7 +1131,7 @@ - @@ -1019,62 +1139,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1173,13 +1237,6 @@ - - - - - - - @@ -1201,20 +1258,6 @@ - - - - - - - - - - - - - - @@ -1229,13 +1272,6 @@ - - - - - - - @@ -1278,45 +1314,11 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -1335,13 +1337,6 @@ - - - - - - - @@ -1349,13 +1344,6 @@ - - - - - - - @@ -1382,6 +1370,217 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java b/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java index fad34cb..a928236 100644 --- a/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java +++ b/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java @@ -20,7 +20,6 @@ private static final long serialVersionUID = 1L; private long id; private String cs_name;//项目名称 - private String cs_status;//项目状态 private String cs_detail;//施工内容 private Date cs_beginTime;//施工开始时间 private Date cs_endTime;//施工结束时间 @@ -28,6 +27,7 @@ private String cs_phone;//联系方式 private String cs_type;//工程类别 private PgPartition pgPartitionId;//施工区域 + private PgConstructionType pgConstructionTypeId;//项目状态 private List pgCsDocumentList;//施工文档 private int active;//状态位 @@ -42,11 +42,6 @@ public void setCs_name(String cs_name){ this.cs_name = cs_name; } - @Column(name = "CS_STATUS") - public String getCs_status(){ return cs_status; } - - public void setCs_status(String cs_status){ this.cs_status = cs_status; } - @Column(name = "CS_DETAIL") public String getCs_detail(){ return cs_detail; } @@ -97,6 +92,16 @@ this.pgCsDocumentList = pgCsDocumentList; } + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "PGCONSTRUCTIONTYPE_ID") + public PgConstructionType getPgConstructionTypeId() { + return pgConstructionTypeId; + } + + public void setPgConstructionTypeId(PgConstructionType pgConstructionTypeId) { + this.pgConstructionTypeId = pgConstructionTypeId; + } @Column(name = "ACTIVE") public int getActive(){ return active; } diff --git a/src/main/java/com/casic/PgInterface/construction/domain/PgConstructionType.java b/src/main/java/com/casic/PgInterface/construction/domain/PgConstructionType.java new file mode 100644 index 0000000..6909234 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/construction/domain/PgConstructionType.java @@ -0,0 +1,57 @@ +package com.casic.PgInterface.construction.domain; + +import javax.persistence.*; +import java.io.Serializable; +import java.util.List; + +/** + * Created by yxw on 2018/4/10. + */ +@Entity +@Table(name = "PG_CONSTRUCTION_TYPE") +@SequenceGenerator(name = "SEQ_PG_CONSTRUCTION_TYPE_ID", sequenceName = "SEQ_PG_CONSTRUCTION_TYPE_ID", allocationSize = 1,initialValue = 1) +public class PgConstructionType implements Serializable { + + private static final long serialVersionUID = 1L; + private long id; + private String typeName;//项目状态 + private List pgConstructionList;//项目 + private int active;//状态位 + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_CONSTRUCTION_TYPE_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "TYPENAME") + public String getTypeName() { + return typeName; + } + + public void setTypeName(String typeName) { + this.typeName = typeName; + } + + @Column(name = "ACTIVE") + public int getActive() { + return active; + } + + public void setActive(int active) { + this.active = active; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgConstructionTypeId") + public List getPgConstructionList() { + return pgConstructionList; + } + + public void setPgConstructionList(List pgConstructionList) { + this.pgConstructionList = pgConstructionList; + } +} diff --git a/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionDto.java b/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionDto.java index c5ac9f9..4fa1888 100644 --- a/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionDto.java +++ b/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionDto.java @@ -11,7 +11,6 @@ private String id; private String cs_name;//项目名称 - private String cs_status;//项目状态 private String cs_detail;//施工内容 private String cs_beginTime;//施工开始时间 private String cs_endTime;//施工结束时间 @@ -19,6 +18,7 @@ private String cs_phone;//联系方式 private String cs_type;//工程类别 private String parName;//施工区域 + private String ConstructionType;//项目状态 private String active;//状态位 public String getId() { @@ -37,14 +37,6 @@ this.cs_name = cs_name; } - public String getCs_status() { - return cs_status; - } - - public void setCs_status(String cs_status) { - this.cs_status = cs_status; - } - public String getCs_detail() { return cs_detail; } @@ -105,13 +97,20 @@ public void setActive(String active){ this.active = active; } + public String getConstructionType() { + return ConstructionType; + } + + public void setConstructionType(String constructionType) { + ConstructionType = constructionType; + } + public PgConstructionDto(PgConstruction pgConstruction) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); this.setId(String.valueOf(pgConstruction.getId())); this.setCs_name(pgConstruction.getCs_name()); - this.setCs_status(pgConstruction.getCs_status()); this.setCs_detail(pgConstruction.getCs_detail()); this.setCs_beginTime(sdf.format(pgConstruction.getCs_beginTime())); this.setCs_endTime(sdf.format(pgConstruction.getCs_endTime())); @@ -119,6 +118,7 @@ this.setCs_phone(pgConstruction.getCs_phone()); this.setCs_type(pgConstruction.getCs_type()); this.setParName(pgConstruction.getPgPartitionId().getParName()); + this.setConstructionType(pgConstruction.getPgConstructionTypeId().getTypeName()); this.setActive(String.valueOf(pgConstruction.getActive())); } } diff --git a/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionTypeDto.java b/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionTypeDto.java new file mode 100644 index 0000000..109c774 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionTypeDto.java @@ -0,0 +1,46 @@ +package com.casic.PgInterface.construction.dto; + +import com.casic.PgInterface.construction.domain.PgConstructionType; + +import java.io.Serializable; + +/** + * Created by yxw on 2018/4/10. + */ +public class PgConstructionTypeDto implements Serializable { + + private String id; + private String typeName;//项目状态 + private String active;//状态位 + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTypeName() { + return typeName; + } + + public void setTypeName(String typeName) { + this.typeName = typeName; + } + + public String getActive() { + return active; + } + + public void setActive(String active) { + this.active = active; + } + + public PgConstructionTypeDto(PgConstructionType pgConstructionType) + { + this.setId(String.valueOf(pgConstructionType.getId())); + this.setTypeName(pgConstructionType.getTypeName()); + this.setActive(String.valueOf(pgConstructionType.getActive())); + } +} diff --git a/src/main/java/com/casic/PgInterface/construction/manager/PgConstructionTypeManager.java b/src/main/java/com/casic/PgInterface/construction/manager/PgConstructionTypeManager.java new file mode 100644 index 0000000..f81a33d --- /dev/null +++ b/src/main/java/com/casic/PgInterface/construction/manager/PgConstructionTypeManager.java @@ -0,0 +1,49 @@ +package com.casic.PgInterface.construction.manager; + +import com.casic.PgInterface.construction.domain.PgConstructionType; +import com.casic.PgInterface.construction.dto.PgConstructionTypeDto; +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import org.hibernate.Criteria; +import org.hibernate.criterion.Order; +import org.hibernate.criterion.Restrictions; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by yxw on 2018/4/10. + */ +@Service +public class PgConstructionTypeManager extends HibernateEntityDao { + + public PgConstructionType getConstructionTypeByType(String typeName) + { + Criteria criteria=createCriteria(PgConstructionType.class); + criteria.add(Restrictions.eq("typeName",typeName)); + criteria.add(Restrictions.eq("active",1)); + + List pgConstructionTypeList=criteria.list(); + if(pgConstructionTypeList!=null&&pgConstructionTypeList.size()!=0) + return pgConstructionTypeList.get(0); + else + return null; + } + + public List getAllConstructionTypeDto() + { + Criteria criteria=createCriteria(PgConstructionType.class); + criteria.add(Restrictions.eq("active",1)); + criteria.addOrder(Order.desc("id")); + + List pgConstructionTypeList=criteria.list(); + List pgConstructionTypeDtoList=new ArrayList(); + for(PgConstructionType pgConstructionType : pgConstructionTypeList) + { + pgConstructionTypeDtoList.add(new PgConstructionTypeDto(pgConstructionType)); + } + + return pgConstructionTypeDtoList; + } + +} diff --git a/src/main/java/com/casic/PgInterface/reservePlan/manager/PgReservePlanManager.java b/src/main/java/com/casic/PgInterface/reservePlan/manager/PgReservePlanManager.java index bbb735b..365737e 100644 --- a/src/main/java/com/casic/PgInterface/reservePlan/manager/PgReservePlanManager.java +++ b/src/main/java/com/casic/PgInterface/reservePlan/manager/PgReservePlanManager.java @@ -4,14 +4,12 @@ import com.casic.PgInterface.devTable.domain.PgAlarm; import com.casic.PgInterface.reservePlan.domain.PgReservePlan; import com.casic.PgInterface.reservePlan.dto.PgReservePlanDto; -import com.sun.org.apache.xml.internal.security.utils.Base64; import org.hibernate.Criteria; import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; -import org.springframework.web.multipart.MultipartFile; import sun.misc.BASE64Decoder; import javax.servlet.http.HttpServletRequest; @@ -26,45 +24,7 @@ @Service public class PgReservePlanManager extends HibernateEntityDao { - public String saveFiles(List files,String fileType){ - String [] fileNames = new String[files.size()]; - String [] fileBuffers = new String[files.size()]; - try { - for (int i = 0; i < files.size(); i++) { - fileNames[i] = files.get(i).getOriginalFilename(); - byte[] fis = files.get(i).getBytes(); - fileBuffers[i] = new String(Base64.encode(fis, Base64.BASE64DEFAULTLENGTH)); - } - HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); - String strDirPath = request.getSession().getServletContext().getRealPath(""); - - FileOutputStream fos = null; - String image_toDir = strDirPath + "\\"+fileType;//存储路径 - String imageName = ""; - for (int i = 0; i < fileBuffers.length; i++) { - if (fileBuffers[i] != null && fileNames[i] != null) { - imageName += fileType+"/"+fileNames[i] + ","; - byte[] buffer = new BASE64Decoder().decodeBuffer(fileBuffers[i]);//对android传过来的图片字符串进行解码 - File destDir = new File(image_toDir); - if (!destDir.exists()) - destDir.mkdirs(); - File imageFile = new File(destDir, fileNames[i]); - fos = new FileOutputStream(imageFile);//保存图片 - fos.write(buffer); - fos.flush(); - fos.close(); - } - } - return imageName.substring(0,imageName.length()-1); - } - catch(Exception ex) - { - ex.printStackTrace(); - return ""; - } - } - - public String saveFiles(String fileBuffer,String fileName,String fileType){ + public String saveFiles(String fileBuffer, String fileName, String fileType){ try { HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); @@ -92,6 +52,8 @@ } } + + public List getReservePlanDtoByAlarmType(PgAlarm pgAlarm) { try { diff --git a/src/main/java/com/casic/PgInterface/rs/PgConstructionRs.java b/src/main/java/com/casic/PgInterface/rs/PgConstructionRs.java index 6ec29e1..932f2e2 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgConstructionRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgConstructionRs.java @@ -1,9 +1,11 @@ package com.casic.PgInterface.rs; import com.casic.PgInterface.construction.domain.PgConstruction; +import com.casic.PgInterface.construction.domain.PgConstructionType; import com.casic.PgInterface.construction.dto.PgConstructTjDto; import com.casic.PgInterface.construction.dto.PgConstructionDto; import com.casic.PgInterface.construction.manager.PgConstructionManager; +import com.casic.PgInterface.construction.manager.PgConstructionTypeManager; import com.casic.PgInterface.devTable.domain.PgPartition; import com.casic.PgInterface.devTable.dto.PgDeviceDto; import com.casic.PgInterface.devTable.manager.PgDeviceManager; @@ -34,6 +36,8 @@ private static Logger logger = LoggerFactory.getLogger(PgConstructionRs.class); + private PgConstructionTypeManager pgConstructionTypeManager; + private PgConstructionManager pgConstructionManager; private PgPartitionManager pgPartitionManager; @@ -52,6 +56,11 @@ } @Resource + public void setPgConstructionTypeManager(PgConstructionTypeManager pgConstructionTypeManager) { + this.pgConstructionTypeManager = pgConstructionTypeManager; + } + + @Resource public void setPgDeviceManager(PgDeviceManager pgDeviceManager) { this.pgDeviceManager = pgDeviceManager; } @@ -63,7 +72,7 @@ @Path("addConstruction") @Produces(MediaType.APPLICATION_JSON) public Map addConstruction(@FormParam("cs_name")String cs_name, - @FormParam("cs_status")String cs_status, + @FormParam("constructionType")String constructionType, @FormParam("cs_detail")String cs_detail, @FormParam("cs_beginTime")String cs_beginTime, @FormParam("cs_endTime")String cs_endTime, @@ -77,11 +86,12 @@ String msg = "" ; SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); try { + + PgConstructionType pgConstructionType=pgConstructionTypeManager.getConstructionTypeByType(constructionType); PgPartition pgPartition=pgPartitionManager.getPartitionByParName(parName); PgConstruction pgConstruction = new PgConstruction(); pgConstruction.setCs_name(cs_name); - pgConstruction.setCs_status(cs_status); pgConstruction.setCs_detail(cs_detail); pgConstruction.setCs_beginTime(sdf.parse(cs_beginTime)); pgConstruction.setCs_endTime(sdf.parse(cs_endTime)); @@ -89,6 +99,7 @@ pgConstruction.setCs_phone(cs_phone); pgConstruction.setCs_type(cs_type); pgConstruction.setPgPartitionId(pgPartition); + pgConstruction.setPgConstructionTypeId(pgConstructionType); pgConstruction.setActive(1); logger.info("保存成功"); @@ -114,7 +125,7 @@ @Produces(MediaType.APPLICATION_JSON) public Map editConstruction(@FormParam("id")String id, @FormParam("cs_name")String cs_name, - @FormParam("cs_status")String cs_status, + @FormParam("constructionType")String constructionType, @FormParam("cs_detail")String cs_detail, @FormParam("cs_beginTime")String cs_beginTime, @FormParam("cs_endTime")String cs_endTime, @@ -136,11 +147,12 @@ result = "false"; msg = "请输入ID"; }else { + PgConstructionType pgConstructionType=pgConstructionTypeManager.getConstructionTypeByType(constructionType); + PgPartition pgPartition=pgPartitionManager.getPartitionByParName(parName); PgConstruction pgConstruction = pgConstructionManager.get(Long.valueOf(id)); pgConstruction.setCs_name(cs_name); - pgConstruction.setCs_status(cs_status); pgConstruction.setCs_detail(cs_detail); pgConstruction.setCs_beginTime(sdf.parse(cs_beginTime)); pgConstruction.setCs_endTime(sdf.parse(cs_endTime)); @@ -148,6 +160,7 @@ pgConstruction.setCs_phone(cs_phone); pgConstruction.setCs_type(cs_type); pgConstruction.setPgPartitionId(pgPartition); + pgConstruction.setPgConstructionTypeId(pgConstructionType); pgConstruction.setActive(1); pgConstructionManager.save(pgConstruction); diff --git a/src/main/java/com/casic/PgInterface/rs/PgConstructionTypeRs.java b/src/main/java/com/casic/PgInterface/rs/PgConstructionTypeRs.java new file mode 100644 index 0000000..549b8e5 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/rs/PgConstructionTypeRs.java @@ -0,0 +1,178 @@ +package com.casic.PgInterface.rs; + +import com.casic.PgInterface.construction.domain.PgConstructionType; +import com.casic.PgInterface.construction.dto.PgConstructionTypeDto; +import com.casic.PgInterface.construction.manager.PgConstructionTypeManager; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import javax.ws.rs.FormParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Created by yxw on 2018/4/10. + */ +@Component +@Path("pgConstructionType") +public class PgConstructionTypeRs { + + private PgConstructionTypeManager pgConstructionTypeManager; + + @Resource + public void setPgConstructionTypeManager(PgConstructionTypeManager pgConstructionTypeManager) { + this.pgConstructionTypeManager = pgConstructionTypeManager; + } + + /** + * 获取项目状态 + */ + @POST + @Path("getConstructionType") + @Produces(MediaType.APPLICATION_JSON) + public Map getConstructionType() throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + List pgConstructionTypeDtoList = new ArrayList(); + try { + pgConstructionTypeDtoList = pgConstructionTypeManager.getAllConstructionTypeDto(); + if (pgConstructionTypeDtoList.size() == 0) + msg = "没有项目类型信息"; + else + msg = "项目类型获取成功"; + } catch (Exception e) { + e.printStackTrace(); + msg = "项目类型信息获取失败"; + } + resultMap.put("msg", msg); + resultMap.put("result", pgConstructionTypeDtoList); + return resultMap; + } + + /** + * 新增项目状态 + */ + @POST + @Path("addConstructionType") + @Produces(MediaType.APPLICATION_JSON) + public Map addConstructionType(@FormParam("typeName") String typeName) throws Exception { + Map resultMap = new HashMap(); + String result = ""; + String msg = ""; + + try { + if (pgConstructionTypeManager.getConstructionTypeByType(typeName) != null) { + result = "false"; + msg = "已存项目状态"; + } else { + PgConstructionType pgConstructionType = new PgConstructionType(); + pgConstructionType.setTypeName(typeName); + pgConstructionType.setActive(1); + + pgConstructionTypeManager.save(pgConstructionType); + result = "true"; + msg = "保存成功"; + } + } catch (Exception e) { + result = "false"; + msg = "保存失败"; + e.printStackTrace(); + } + + resultMap.put("result", result); + resultMap.put("msg", msg); + return resultMap; + } + + /** + * 编辑项目状态 + */ + @POST + @Path("editConstruction") + @Produces(MediaType.APPLICATION_JSON) + public Map editConstruction(@FormParam("id") String id, + @FormParam("typeName") String typeName)throws Exception{ + Map resultMap = new HashMap(); + String result = ""; + String msg = ""; + + try{ + if(pgConstructionTypeManager.getConstructionTypeByType(typeName)!=null) + { + result = "false"; + msg = "已存项目状态"; + } + else { + PgConstructionType pgConstructionType = pgConstructionTypeManager.get(Long.valueOf(id)); + if(pgConstructionType==null) + { + result = "false"; + msg = "不存在项目状态"; + } + else { + pgConstructionType.setTypeName(typeName); + + pgConstructionTypeManager.save(pgConstructionType); + result = "true"; + msg = "编辑成功"; + } + } + } + catch(Exception e) + { + result = "false"; + msg = "编辑失败"; + e.printStackTrace(); + } + + resultMap.put("result",result); + resultMap.put("msg",msg); + + return resultMap; + } + + + /** + * 删除项目状态 + */ + @POST + @Path("deleteConstructionType") + @Produces(MediaType.APPLICATION_JSON) + public Map deleteConstructionType(@FormParam("id") String id)throws Exception { + + Map resultMap = new HashMap(); + String msg=""; + String result="false"; + + try { + PgConstructionType pgConstructionType=pgConstructionTypeManager.get(Long.valueOf(id)); + if(pgConstructionType==null) { + msg = "不存项目状态"; + result="false"; + } + else + { + pgConstructionType.setActive(0); + pgConstructionTypeManager.save(pgConstructionType); + msg="项目状态删除成功"; + result="true"; + } + }catch(Exception e){ + e.printStackTrace(); + msg="项目状态删除失败"; + result="false"; + } + resultMap.put("msg",msg); + resultMap.put("result",result); + + return resultMap; + } + + +} diff --git a/src/main/java/com/casic/PgInterface/rs/PgOverViewRs.java b/src/main/java/com/casic/PgInterface/rs/PgOverViewRs.java index 8bca0fb..4f83629 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgOverViewRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgOverViewRs.java @@ -272,4 +272,5 @@ } + } \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/rs/PgReserveController.java b/src/main/java/com/casic/PgInterface/rs/PgReserveController.java deleted file mode 100644 index 27b1482..0000000 --- a/src/main/java/com/casic/PgInterface/rs/PgReserveController.java +++ /dev/null @@ -1,208 +0,0 @@ -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.Component; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; - -import javax.annotation.Resource; -import javax.ws.rs.FormParam; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import java.util.HashMap; -import java.util.Map; - -/** - * Created by yxw on 2017/11/8. - */ -//@Controller -//@RequestMapping("pgReservePlan") -@Component -@Path("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("planName") String planName, - @FormParam("planType") String planType, - @FormParam("resUnit") String resUnit, - @FormParam("alarmType") String alarmType, - @FormParam("planFile") String fileBuffer, - @FormParam("fileName") 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("result", 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/PgReservePlanRs.java b/src/main/java/com/casic/PgInterface/rs/PgReservePlanRs.java new file mode 100644 index 0000000..33da431 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/rs/PgReservePlanRs.java @@ -0,0 +1,172 @@ +package com.casic.PgInterface.rs; + +import com.casic.PgInterface.core.util.StringUtils; +import com.casic.PgInterface.devTable.domain.PgAlarmType; +import com.casic.PgInterface.devTable.manager.PgAlarmTypeManager; +import com.casic.PgInterface.reservePlan.domain.PgReservePlan; +import com.casic.PgInterface.reservePlan.manager.PgReservePlanManager; +import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +import javax.annotation.Resource; +import javax.ws.rs.FormParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import java.util.HashMap; +import java.util.Map; + +/** + * Created by yxw on 2018/4/10. + */ +@Component +@Path("PgReservePlan") +public class PgReservePlanRs { + + private PgReservePlanManager pgReservePlanManager; + + private PgAlarmTypeManager pgAlarmTypeManager; + + @Resource + public void setPgReservePlanManager(PgReservePlanManager pgReservePlanManager) { + this.pgReservePlanManager = pgReservePlanManager; + } + + @Resource + public void setPgAlarmTypeManager(PgAlarmTypeManager pgAlarmTypeManager) { + this.pgAlarmTypeManager = pgAlarmTypeManager; + } + + /* + 新增&上传 + */ + @POST + @Path("addReservePlan") + @Produces(MediaType.APPLICATION_JSON) + public Map addReservePlan(@FormParam("planName") String planName, + @FormParam("planType") String planType, + @FormParam("resUnit") String resUnit, + @FormParam("planFiel") String planFiel, + @FormParam("alarmType") String alarmType)throws Exception { + + Map resultMap=new HashMap(); + String msg=""; + String result=""; + + try { + + PgReservePlan pgReservePlan = new PgReservePlan(); + + pgReservePlan.setPlanName(planName); + pgReservePlan.setPlanType(planType); + pgReservePlan.setResUnit(resUnit); + pgReservePlan.setActive(1); + PgAlarmType pgAlarmType = pgAlarmTypeManager.getAlarmTypeByAlarmType(alarmType); + pgReservePlan.setPgAlarmTypeId(pgAlarmType); + if (StringUtils.isBlank(planFiel)||StringUtils.isBlank(planName)) + pgReservePlan.setPlanFiel(""); + else { + pgReservePlan.setPlanFiel(pgReservePlanManager.saveFiles(planFiel, planName, "ReservePlan")); + } + + pgReservePlanManager.save(pgReservePlan); + msg="新增成功"; + result="true"; + + } + catch(Exception e) + { + e.printStackTrace(); + msg="新增失败"; + result="false"; + } + + resultMap.put("msg",msg); + resultMap.put("result",result); + + return resultMap; + } + + + //编辑文档 + @RequestMapping("editReservePlan") + @ResponseBody + public Map editReservePlan(@FormParam("id") String id, + @FormParam("planName") String planName, + @FormParam("planType") String planType, + @FormParam("resUnit") String resUnit, + @FormParam("alarmType") 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 { + PgAlarmType pgAlarmType = pgAlarmTypeManager.getAlarmTypeByAlarmType(alarmType); + pgReservePlan.setPlanName(planName); + pgReservePlan.setPlanType(planType); + pgReservePlan.setResUnit(resUnit); + pgReservePlan.setPgAlarmTypeId(pgAlarmType); + + pgReservePlanManager.save(pgReservePlan); + + result = "true"; + msg = "编辑成功"; + } + } catch (Exception e) { + + result = "false"; + msg = "编辑失败"; + e.printStackTrace(); + } + resultMap.put("msg",msg); + resultMap.put("result",result); + + return resultMap; + } + + //删除预案文档 + @RequestMapping("delReservePlan") + @ResponseBody + public Map delReservePlan(@FormParam("id") String id)throws Exception{ + Map resultMap = new HashMap(); + String msg=""; + String result=""; + + 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; + } + + + +} diff --git a/~WRL1002.tmp b/~WRL1002.tmp new file mode 100644 index 0000000..e0b14d9 --- /dev/null +++ b/~WRL1002.tmp Binary files differ diff --git "a/\346\216\245\345\217\243\350\257\264\346\230\216\346\226\260\351\234\200\346\261\202.docx" "b/\346\216\245\345\217\243\350\257\264\346\230\216\346\226\260\351\234\200\346\261\202.docx" index 471ee96..63f4e43 100644 --- "a/\346\216\245\345\217\243\350\257\264\346\230\216\346\226\260\351\234\200\346\261\202.docx" +++ "b/\346\216\245\345\217\243\350\257\264\346\230\216\346\226\260\351\234\200\346\261\202.docx" Binary files differ diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 2ee3724..276272c 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,6 +2,20 @@ + + + + + + + + + + + + + + @@ -44,13 +58,6 @@ @@ -249,6 +263,36 @@ - @@ -911,13 +1031,14 @@ + - + @@ -926,7 +1047,6 @@ - @@ -1011,7 +1131,7 @@ - @@ -1019,62 +1139,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1173,13 +1237,6 @@ - - - - - - - @@ -1201,20 +1258,6 @@ - - - - - - - - - - - - - - @@ -1229,13 +1272,6 @@ - - - - - - - @@ -1278,45 +1314,11 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -1335,13 +1337,6 @@ - - - - - - - @@ -1349,13 +1344,6 @@ - - - - - - - @@ -1382,6 +1370,217 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java b/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java index fad34cb..a928236 100644 --- a/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java +++ b/src/main/java/com/casic/PgInterface/construction/domain/PgConstruction.java @@ -20,7 +20,6 @@ private static final long serialVersionUID = 1L; private long id; private String cs_name;//项目名称 - private String cs_status;//项目状态 private String cs_detail;//施工内容 private Date cs_beginTime;//施工开始时间 private Date cs_endTime;//施工结束时间 @@ -28,6 +27,7 @@ private String cs_phone;//联系方式 private String cs_type;//工程类别 private PgPartition pgPartitionId;//施工区域 + private PgConstructionType pgConstructionTypeId;//项目状态 private List pgCsDocumentList;//施工文档 private int active;//状态位 @@ -42,11 +42,6 @@ public void setCs_name(String cs_name){ this.cs_name = cs_name; } - @Column(name = "CS_STATUS") - public String getCs_status(){ return cs_status; } - - public void setCs_status(String cs_status){ this.cs_status = cs_status; } - @Column(name = "CS_DETAIL") public String getCs_detail(){ return cs_detail; } @@ -97,6 +92,16 @@ this.pgCsDocumentList = pgCsDocumentList; } + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "PGCONSTRUCTIONTYPE_ID") + public PgConstructionType getPgConstructionTypeId() { + return pgConstructionTypeId; + } + + public void setPgConstructionTypeId(PgConstructionType pgConstructionTypeId) { + this.pgConstructionTypeId = pgConstructionTypeId; + } @Column(name = "ACTIVE") public int getActive(){ return active; } diff --git a/src/main/java/com/casic/PgInterface/construction/domain/PgConstructionType.java b/src/main/java/com/casic/PgInterface/construction/domain/PgConstructionType.java new file mode 100644 index 0000000..6909234 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/construction/domain/PgConstructionType.java @@ -0,0 +1,57 @@ +package com.casic.PgInterface.construction.domain; + +import javax.persistence.*; +import java.io.Serializable; +import java.util.List; + +/** + * Created by yxw on 2018/4/10. + */ +@Entity +@Table(name = "PG_CONSTRUCTION_TYPE") +@SequenceGenerator(name = "SEQ_PG_CONSTRUCTION_TYPE_ID", sequenceName = "SEQ_PG_CONSTRUCTION_TYPE_ID", allocationSize = 1,initialValue = 1) +public class PgConstructionType implements Serializable { + + private static final long serialVersionUID = 1L; + private long id; + private String typeName;//项目状态 + private List pgConstructionList;//项目 + private int active;//状态位 + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_CONSTRUCTION_TYPE_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "TYPENAME") + public String getTypeName() { + return typeName; + } + + public void setTypeName(String typeName) { + this.typeName = typeName; + } + + @Column(name = "ACTIVE") + public int getActive() { + return active; + } + + public void setActive(int active) { + this.active = active; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgConstructionTypeId") + public List getPgConstructionList() { + return pgConstructionList; + } + + public void setPgConstructionList(List pgConstructionList) { + this.pgConstructionList = pgConstructionList; + } +} diff --git a/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionDto.java b/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionDto.java index c5ac9f9..4fa1888 100644 --- a/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionDto.java +++ b/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionDto.java @@ -11,7 +11,6 @@ private String id; private String cs_name;//项目名称 - private String cs_status;//项目状态 private String cs_detail;//施工内容 private String cs_beginTime;//施工开始时间 private String cs_endTime;//施工结束时间 @@ -19,6 +18,7 @@ private String cs_phone;//联系方式 private String cs_type;//工程类别 private String parName;//施工区域 + private String ConstructionType;//项目状态 private String active;//状态位 public String getId() { @@ -37,14 +37,6 @@ this.cs_name = cs_name; } - public String getCs_status() { - return cs_status; - } - - public void setCs_status(String cs_status) { - this.cs_status = cs_status; - } - public String getCs_detail() { return cs_detail; } @@ -105,13 +97,20 @@ public void setActive(String active){ this.active = active; } + public String getConstructionType() { + return ConstructionType; + } + + public void setConstructionType(String constructionType) { + ConstructionType = constructionType; + } + public PgConstructionDto(PgConstruction pgConstruction) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); this.setId(String.valueOf(pgConstruction.getId())); this.setCs_name(pgConstruction.getCs_name()); - this.setCs_status(pgConstruction.getCs_status()); this.setCs_detail(pgConstruction.getCs_detail()); this.setCs_beginTime(sdf.format(pgConstruction.getCs_beginTime())); this.setCs_endTime(sdf.format(pgConstruction.getCs_endTime())); @@ -119,6 +118,7 @@ this.setCs_phone(pgConstruction.getCs_phone()); this.setCs_type(pgConstruction.getCs_type()); this.setParName(pgConstruction.getPgPartitionId().getParName()); + this.setConstructionType(pgConstruction.getPgConstructionTypeId().getTypeName()); this.setActive(String.valueOf(pgConstruction.getActive())); } } diff --git a/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionTypeDto.java b/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionTypeDto.java new file mode 100644 index 0000000..109c774 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/construction/dto/PgConstructionTypeDto.java @@ -0,0 +1,46 @@ +package com.casic.PgInterface.construction.dto; + +import com.casic.PgInterface.construction.domain.PgConstructionType; + +import java.io.Serializable; + +/** + * Created by yxw on 2018/4/10. + */ +public class PgConstructionTypeDto implements Serializable { + + private String id; + private String typeName;//项目状态 + private String active;//状态位 + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTypeName() { + return typeName; + } + + public void setTypeName(String typeName) { + this.typeName = typeName; + } + + public String getActive() { + return active; + } + + public void setActive(String active) { + this.active = active; + } + + public PgConstructionTypeDto(PgConstructionType pgConstructionType) + { + this.setId(String.valueOf(pgConstructionType.getId())); + this.setTypeName(pgConstructionType.getTypeName()); + this.setActive(String.valueOf(pgConstructionType.getActive())); + } +} diff --git a/src/main/java/com/casic/PgInterface/construction/manager/PgConstructionTypeManager.java b/src/main/java/com/casic/PgInterface/construction/manager/PgConstructionTypeManager.java new file mode 100644 index 0000000..f81a33d --- /dev/null +++ b/src/main/java/com/casic/PgInterface/construction/manager/PgConstructionTypeManager.java @@ -0,0 +1,49 @@ +package com.casic.PgInterface.construction.manager; + +import com.casic.PgInterface.construction.domain.PgConstructionType; +import com.casic.PgInterface.construction.dto.PgConstructionTypeDto; +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import org.hibernate.Criteria; +import org.hibernate.criterion.Order; +import org.hibernate.criterion.Restrictions; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by yxw on 2018/4/10. + */ +@Service +public class PgConstructionTypeManager extends HibernateEntityDao { + + public PgConstructionType getConstructionTypeByType(String typeName) + { + Criteria criteria=createCriteria(PgConstructionType.class); + criteria.add(Restrictions.eq("typeName",typeName)); + criteria.add(Restrictions.eq("active",1)); + + List pgConstructionTypeList=criteria.list(); + if(pgConstructionTypeList!=null&&pgConstructionTypeList.size()!=0) + return pgConstructionTypeList.get(0); + else + return null; + } + + public List getAllConstructionTypeDto() + { + Criteria criteria=createCriteria(PgConstructionType.class); + criteria.add(Restrictions.eq("active",1)); + criteria.addOrder(Order.desc("id")); + + List pgConstructionTypeList=criteria.list(); + List pgConstructionTypeDtoList=new ArrayList(); + for(PgConstructionType pgConstructionType : pgConstructionTypeList) + { + pgConstructionTypeDtoList.add(new PgConstructionTypeDto(pgConstructionType)); + } + + return pgConstructionTypeDtoList; + } + +} diff --git a/src/main/java/com/casic/PgInterface/reservePlan/manager/PgReservePlanManager.java b/src/main/java/com/casic/PgInterface/reservePlan/manager/PgReservePlanManager.java index bbb735b..365737e 100644 --- a/src/main/java/com/casic/PgInterface/reservePlan/manager/PgReservePlanManager.java +++ b/src/main/java/com/casic/PgInterface/reservePlan/manager/PgReservePlanManager.java @@ -4,14 +4,12 @@ import com.casic.PgInterface.devTable.domain.PgAlarm; import com.casic.PgInterface.reservePlan.domain.PgReservePlan; import com.casic.PgInterface.reservePlan.dto.PgReservePlanDto; -import com.sun.org.apache.xml.internal.security.utils.Base64; import org.hibernate.Criteria; import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; import org.springframework.stereotype.Service; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; -import org.springframework.web.multipart.MultipartFile; import sun.misc.BASE64Decoder; import javax.servlet.http.HttpServletRequest; @@ -26,45 +24,7 @@ @Service public class PgReservePlanManager extends HibernateEntityDao { - public String saveFiles(List files,String fileType){ - String [] fileNames = new String[files.size()]; - String [] fileBuffers = new String[files.size()]; - try { - for (int i = 0; i < files.size(); i++) { - fileNames[i] = files.get(i).getOriginalFilename(); - byte[] fis = files.get(i).getBytes(); - fileBuffers[i] = new String(Base64.encode(fis, Base64.BASE64DEFAULTLENGTH)); - } - HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); - String strDirPath = request.getSession().getServletContext().getRealPath(""); - - FileOutputStream fos = null; - String image_toDir = strDirPath + "\\"+fileType;//存储路径 - String imageName = ""; - for (int i = 0; i < fileBuffers.length; i++) { - if (fileBuffers[i] != null && fileNames[i] != null) { - imageName += fileType+"/"+fileNames[i] + ","; - byte[] buffer = new BASE64Decoder().decodeBuffer(fileBuffers[i]);//对android传过来的图片字符串进行解码 - File destDir = new File(image_toDir); - if (!destDir.exists()) - destDir.mkdirs(); - File imageFile = new File(destDir, fileNames[i]); - fos = new FileOutputStream(imageFile);//保存图片 - fos.write(buffer); - fos.flush(); - fos.close(); - } - } - return imageName.substring(0,imageName.length()-1); - } - catch(Exception ex) - { - ex.printStackTrace(); - return ""; - } - } - - public String saveFiles(String fileBuffer,String fileName,String fileType){ + public String saveFiles(String fileBuffer, String fileName, String fileType){ try { HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); @@ -92,6 +52,8 @@ } } + + public List getReservePlanDtoByAlarmType(PgAlarm pgAlarm) { try { diff --git a/src/main/java/com/casic/PgInterface/rs/PgConstructionRs.java b/src/main/java/com/casic/PgInterface/rs/PgConstructionRs.java index 6ec29e1..932f2e2 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgConstructionRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgConstructionRs.java @@ -1,9 +1,11 @@ package com.casic.PgInterface.rs; import com.casic.PgInterface.construction.domain.PgConstruction; +import com.casic.PgInterface.construction.domain.PgConstructionType; import com.casic.PgInterface.construction.dto.PgConstructTjDto; import com.casic.PgInterface.construction.dto.PgConstructionDto; import com.casic.PgInterface.construction.manager.PgConstructionManager; +import com.casic.PgInterface.construction.manager.PgConstructionTypeManager; import com.casic.PgInterface.devTable.domain.PgPartition; import com.casic.PgInterface.devTable.dto.PgDeviceDto; import com.casic.PgInterface.devTable.manager.PgDeviceManager; @@ -34,6 +36,8 @@ private static Logger logger = LoggerFactory.getLogger(PgConstructionRs.class); + private PgConstructionTypeManager pgConstructionTypeManager; + private PgConstructionManager pgConstructionManager; private PgPartitionManager pgPartitionManager; @@ -52,6 +56,11 @@ } @Resource + public void setPgConstructionTypeManager(PgConstructionTypeManager pgConstructionTypeManager) { + this.pgConstructionTypeManager = pgConstructionTypeManager; + } + + @Resource public void setPgDeviceManager(PgDeviceManager pgDeviceManager) { this.pgDeviceManager = pgDeviceManager; } @@ -63,7 +72,7 @@ @Path("addConstruction") @Produces(MediaType.APPLICATION_JSON) public Map addConstruction(@FormParam("cs_name")String cs_name, - @FormParam("cs_status")String cs_status, + @FormParam("constructionType")String constructionType, @FormParam("cs_detail")String cs_detail, @FormParam("cs_beginTime")String cs_beginTime, @FormParam("cs_endTime")String cs_endTime, @@ -77,11 +86,12 @@ String msg = "" ; SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); try { + + PgConstructionType pgConstructionType=pgConstructionTypeManager.getConstructionTypeByType(constructionType); PgPartition pgPartition=pgPartitionManager.getPartitionByParName(parName); PgConstruction pgConstruction = new PgConstruction(); pgConstruction.setCs_name(cs_name); - pgConstruction.setCs_status(cs_status); pgConstruction.setCs_detail(cs_detail); pgConstruction.setCs_beginTime(sdf.parse(cs_beginTime)); pgConstruction.setCs_endTime(sdf.parse(cs_endTime)); @@ -89,6 +99,7 @@ pgConstruction.setCs_phone(cs_phone); pgConstruction.setCs_type(cs_type); pgConstruction.setPgPartitionId(pgPartition); + pgConstruction.setPgConstructionTypeId(pgConstructionType); pgConstruction.setActive(1); logger.info("保存成功"); @@ -114,7 +125,7 @@ @Produces(MediaType.APPLICATION_JSON) public Map editConstruction(@FormParam("id")String id, @FormParam("cs_name")String cs_name, - @FormParam("cs_status")String cs_status, + @FormParam("constructionType")String constructionType, @FormParam("cs_detail")String cs_detail, @FormParam("cs_beginTime")String cs_beginTime, @FormParam("cs_endTime")String cs_endTime, @@ -136,11 +147,12 @@ result = "false"; msg = "请输入ID"; }else { + PgConstructionType pgConstructionType=pgConstructionTypeManager.getConstructionTypeByType(constructionType); + PgPartition pgPartition=pgPartitionManager.getPartitionByParName(parName); PgConstruction pgConstruction = pgConstructionManager.get(Long.valueOf(id)); pgConstruction.setCs_name(cs_name); - pgConstruction.setCs_status(cs_status); pgConstruction.setCs_detail(cs_detail); pgConstruction.setCs_beginTime(sdf.parse(cs_beginTime)); pgConstruction.setCs_endTime(sdf.parse(cs_endTime)); @@ -148,6 +160,7 @@ pgConstruction.setCs_phone(cs_phone); pgConstruction.setCs_type(cs_type); pgConstruction.setPgPartitionId(pgPartition); + pgConstruction.setPgConstructionTypeId(pgConstructionType); pgConstruction.setActive(1); pgConstructionManager.save(pgConstruction); diff --git a/src/main/java/com/casic/PgInterface/rs/PgConstructionTypeRs.java b/src/main/java/com/casic/PgInterface/rs/PgConstructionTypeRs.java new file mode 100644 index 0000000..549b8e5 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/rs/PgConstructionTypeRs.java @@ -0,0 +1,178 @@ +package com.casic.PgInterface.rs; + +import com.casic.PgInterface.construction.domain.PgConstructionType; +import com.casic.PgInterface.construction.dto.PgConstructionTypeDto; +import com.casic.PgInterface.construction.manager.PgConstructionTypeManager; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import javax.ws.rs.FormParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Created by yxw on 2018/4/10. + */ +@Component +@Path("pgConstructionType") +public class PgConstructionTypeRs { + + private PgConstructionTypeManager pgConstructionTypeManager; + + @Resource + public void setPgConstructionTypeManager(PgConstructionTypeManager pgConstructionTypeManager) { + this.pgConstructionTypeManager = pgConstructionTypeManager; + } + + /** + * 获取项目状态 + */ + @POST + @Path("getConstructionType") + @Produces(MediaType.APPLICATION_JSON) + public Map getConstructionType() throws Exception { + Map resultMap = new HashMap(); + String msg = ""; + List pgConstructionTypeDtoList = new ArrayList(); + try { + pgConstructionTypeDtoList = pgConstructionTypeManager.getAllConstructionTypeDto(); + if (pgConstructionTypeDtoList.size() == 0) + msg = "没有项目类型信息"; + else + msg = "项目类型获取成功"; + } catch (Exception e) { + e.printStackTrace(); + msg = "项目类型信息获取失败"; + } + resultMap.put("msg", msg); + resultMap.put("result", pgConstructionTypeDtoList); + return resultMap; + } + + /** + * 新增项目状态 + */ + @POST + @Path("addConstructionType") + @Produces(MediaType.APPLICATION_JSON) + public Map addConstructionType(@FormParam("typeName") String typeName) throws Exception { + Map resultMap = new HashMap(); + String result = ""; + String msg = ""; + + try { + if (pgConstructionTypeManager.getConstructionTypeByType(typeName) != null) { + result = "false"; + msg = "已存项目状态"; + } else { + PgConstructionType pgConstructionType = new PgConstructionType(); + pgConstructionType.setTypeName(typeName); + pgConstructionType.setActive(1); + + pgConstructionTypeManager.save(pgConstructionType); + result = "true"; + msg = "保存成功"; + } + } catch (Exception e) { + result = "false"; + msg = "保存失败"; + e.printStackTrace(); + } + + resultMap.put("result", result); + resultMap.put("msg", msg); + return resultMap; + } + + /** + * 编辑项目状态 + */ + @POST + @Path("editConstruction") + @Produces(MediaType.APPLICATION_JSON) + public Map editConstruction(@FormParam("id") String id, + @FormParam("typeName") String typeName)throws Exception{ + Map resultMap = new HashMap(); + String result = ""; + String msg = ""; + + try{ + if(pgConstructionTypeManager.getConstructionTypeByType(typeName)!=null) + { + result = "false"; + msg = "已存项目状态"; + } + else { + PgConstructionType pgConstructionType = pgConstructionTypeManager.get(Long.valueOf(id)); + if(pgConstructionType==null) + { + result = "false"; + msg = "不存在项目状态"; + } + else { + pgConstructionType.setTypeName(typeName); + + pgConstructionTypeManager.save(pgConstructionType); + result = "true"; + msg = "编辑成功"; + } + } + } + catch(Exception e) + { + result = "false"; + msg = "编辑失败"; + e.printStackTrace(); + } + + resultMap.put("result",result); + resultMap.put("msg",msg); + + return resultMap; + } + + + /** + * 删除项目状态 + */ + @POST + @Path("deleteConstructionType") + @Produces(MediaType.APPLICATION_JSON) + public Map deleteConstructionType(@FormParam("id") String id)throws Exception { + + Map resultMap = new HashMap(); + String msg=""; + String result="false"; + + try { + PgConstructionType pgConstructionType=pgConstructionTypeManager.get(Long.valueOf(id)); + if(pgConstructionType==null) { + msg = "不存项目状态"; + result="false"; + } + else + { + pgConstructionType.setActive(0); + pgConstructionTypeManager.save(pgConstructionType); + msg="项目状态删除成功"; + result="true"; + } + }catch(Exception e){ + e.printStackTrace(); + msg="项目状态删除失败"; + result="false"; + } + resultMap.put("msg",msg); + resultMap.put("result",result); + + return resultMap; + } + + +} diff --git a/src/main/java/com/casic/PgInterface/rs/PgOverViewRs.java b/src/main/java/com/casic/PgInterface/rs/PgOverViewRs.java index 8bca0fb..4f83629 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgOverViewRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgOverViewRs.java @@ -272,4 +272,5 @@ } + } \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/rs/PgReserveController.java b/src/main/java/com/casic/PgInterface/rs/PgReserveController.java deleted file mode 100644 index 27b1482..0000000 --- a/src/main/java/com/casic/PgInterface/rs/PgReserveController.java +++ /dev/null @@ -1,208 +0,0 @@ -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.Component; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; - -import javax.annotation.Resource; -import javax.ws.rs.FormParam; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import java.util.HashMap; -import java.util.Map; - -/** - * Created by yxw on 2017/11/8. - */ -//@Controller -//@RequestMapping("pgReservePlan") -@Component -@Path("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("planName") String planName, - @FormParam("planType") String planType, - @FormParam("resUnit") String resUnit, - @FormParam("alarmType") String alarmType, - @FormParam("planFile") String fileBuffer, - @FormParam("fileName") 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("result", 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/PgReservePlanRs.java b/src/main/java/com/casic/PgInterface/rs/PgReservePlanRs.java new file mode 100644 index 0000000..33da431 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/rs/PgReservePlanRs.java @@ -0,0 +1,172 @@ +package com.casic.PgInterface.rs; + +import com.casic.PgInterface.core.util.StringUtils; +import com.casic.PgInterface.devTable.domain.PgAlarmType; +import com.casic.PgInterface.devTable.manager.PgAlarmTypeManager; +import com.casic.PgInterface.reservePlan.domain.PgReservePlan; +import com.casic.PgInterface.reservePlan.manager.PgReservePlanManager; +import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +import javax.annotation.Resource; +import javax.ws.rs.FormParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import java.util.HashMap; +import java.util.Map; + +/** + * Created by yxw on 2018/4/10. + */ +@Component +@Path("PgReservePlan") +public class PgReservePlanRs { + + private PgReservePlanManager pgReservePlanManager; + + private PgAlarmTypeManager pgAlarmTypeManager; + + @Resource + public void setPgReservePlanManager(PgReservePlanManager pgReservePlanManager) { + this.pgReservePlanManager = pgReservePlanManager; + } + + @Resource + public void setPgAlarmTypeManager(PgAlarmTypeManager pgAlarmTypeManager) { + this.pgAlarmTypeManager = pgAlarmTypeManager; + } + + /* + 新增&上传 + */ + @POST + @Path("addReservePlan") + @Produces(MediaType.APPLICATION_JSON) + public Map addReservePlan(@FormParam("planName") String planName, + @FormParam("planType") String planType, + @FormParam("resUnit") String resUnit, + @FormParam("planFiel") String planFiel, + @FormParam("alarmType") String alarmType)throws Exception { + + Map resultMap=new HashMap(); + String msg=""; + String result=""; + + try { + + PgReservePlan pgReservePlan = new PgReservePlan(); + + pgReservePlan.setPlanName(planName); + pgReservePlan.setPlanType(planType); + pgReservePlan.setResUnit(resUnit); + pgReservePlan.setActive(1); + PgAlarmType pgAlarmType = pgAlarmTypeManager.getAlarmTypeByAlarmType(alarmType); + pgReservePlan.setPgAlarmTypeId(pgAlarmType); + if (StringUtils.isBlank(planFiel)||StringUtils.isBlank(planName)) + pgReservePlan.setPlanFiel(""); + else { + pgReservePlan.setPlanFiel(pgReservePlanManager.saveFiles(planFiel, planName, "ReservePlan")); + } + + pgReservePlanManager.save(pgReservePlan); + msg="新增成功"; + result="true"; + + } + catch(Exception e) + { + e.printStackTrace(); + msg="新增失败"; + result="false"; + } + + resultMap.put("msg",msg); + resultMap.put("result",result); + + return resultMap; + } + + + //编辑文档 + @RequestMapping("editReservePlan") + @ResponseBody + public Map editReservePlan(@FormParam("id") String id, + @FormParam("planName") String planName, + @FormParam("planType") String planType, + @FormParam("resUnit") String resUnit, + @FormParam("alarmType") 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 { + PgAlarmType pgAlarmType = pgAlarmTypeManager.getAlarmTypeByAlarmType(alarmType); + pgReservePlan.setPlanName(planName); + pgReservePlan.setPlanType(planType); + pgReservePlan.setResUnit(resUnit); + pgReservePlan.setPgAlarmTypeId(pgAlarmType); + + pgReservePlanManager.save(pgReservePlan); + + result = "true"; + msg = "编辑成功"; + } + } catch (Exception e) { + + result = "false"; + msg = "编辑失败"; + e.printStackTrace(); + } + resultMap.put("msg",msg); + resultMap.put("result",result); + + return resultMap; + } + + //删除预案文档 + @RequestMapping("delReservePlan") + @ResponseBody + public Map delReservePlan(@FormParam("id") String id)throws Exception{ + Map resultMap = new HashMap(); + String msg=""; + String result=""; + + 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; + } + + + +} diff --git a/~WRL1002.tmp b/~WRL1002.tmp new file mode 100644 index 0000000..e0b14d9 --- /dev/null +++ b/~WRL1002.tmp Binary files differ diff --git "a/\346\216\245\345\217\243\350\257\264\346\230\216\346\226\260\351\234\200\346\261\202.docx" "b/\346\216\245\345\217\243\350\257\264\346\230\216\346\226\260\351\234\200\346\261\202.docx" index 471ee96..63f4e43 100644 --- "a/\346\216\245\345\217\243\350\257\264\346\230\216\346\226\260\351\234\200\346\261\202.docx" +++ "b/\346\216\245\345\217\243\350\257\264\346\230\216\346\226\260\351\234\200\346\261\202.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\346\226\260\351\234\200\346\261\202.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\346\226\260\351\234\200\346\261\202.docx" index 82d5c2f..d01d485 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\346\226\260\351\234\200\346\261\202.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\346\226\260\351\234\200\346\261\202.docx" Binary files differ